| | |
| | | // 其它类型的表单数据:如图片、文件单独存表的。历史、运行中的流程需各存一份 |
| | | v.setVAR_TYPE_("serializable"); |
| | | v.setBYTEARRAY_ID_(new StrongUuidGenerator().getNextId()); |
| | | projectProcessMapper.insertByteArray(v.getBYTEARRAY_ID_(), 1, "hist.var-" + key, newV.get(key)); |
| | | projectProcessMapper.insertByteArray(v.getBYTEARRAY_ID_(), 1, "hist.var-" + key, objectToInputStream(newV.get(key))); |
| | | |
| | | run.setVAR_TYPE_("serializable"); |
| | | run.setBYTEARRAY_ID_(new StrongUuidGenerator().getNextId()); |
| | | projectProcessMapper.insertByteArray(run.getBYTEARRAY_ID_(), 1, "var-" + key, newV.get(key)); |
| | | projectProcessMapper.insertByteArray(run.getBYTEARRAY_ID_(), 1, "var-" + key, objectToInputStream(newV.get(key))); |
| | | } |
| | | |
| | | projectProcessMapper.insertHisFlowableVar(v); |
| | |
| | | oos.flush(); |
| | | return bos.toByteArray(); // 返回字节数组 |
| | | } |
| | | } |
| | | |
| | | // 将对象转换为 InputStream,适配 BLOB 写入 |
| | | public static InputStream objectToInputStream(Object obj) throws IOException { |
| | | byte[] bytes = objectToBytes(obj); |
| | | return Objects.isNull(bytes) ? null : new ByteArrayInputStream(bytes); |
| | | } |
| | | |
| | | /** |
| | |
| | | if (disableInput) { |
| | | options.put("disabled", true); |
| | | } |
| | | // 处理文件上传ip问题 |
| | | if ("file-upload".equals(oldField.get("type"))) { |
| | | options.put("uploadURL", String.format("http://%s:10076/common/upload", this.targetIp)); |
| | | } |
| | | } |
| | | |
| | | formJson.put(ProcessConstants.WIDGET_LIST, oldFields); |
| | | normalizeUploadUrl(formJson); |
| | | newP.put(ProcessConstants.TASK_FORM_KEY, formJson); |
| | | newP.remove(formDetailVO.getBeforeNodeDefId() + "&" + ProcessConstants.TASK_FORM_KEY); |
| | | // 处理已经上传的文件的ip地址 |
| | |
| | | continue; |
| | | } |
| | | if (s.startsWith("fileupload")) { |
| | | List files = (List) newP.get(s); |
| | | Object o = newP.get(s); |
| | | log.info("输出object------------》{}",JSON.toJSONString(o)); |
| | | if (Objects.isNull(o)) { |
| | | continue; |
| | | } |
| | | List files = (List) o; |
| | | for (Object file : files) { |
| | | LinkedHashMap<String, String> fileMap = (LinkedHashMap<String, String>) file; |
| | | String url = fileMap.get("url"); |
| | | if (StringUtils.isBlank(url)) { |
| | | continue; |
| | | } |
| | | fileMap.put("url", url.replace("42.193.1.25", this.targetIp)); |
| | | if (url.contains("119.6.246.90")){ |
| | | fileMap.put("url", url.replace("119.6.246.90", this.targetIp)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | formDetailVO.setFormJsonObj(newP); |
| | | } |
| | | |
| | | } else { |
| | | // 当前节点一般使用模板初始化数据,统一在这里改写上传地址,避免旧IP残留 |
| | | Map<String, Object> formObj = formDetailVO.getFormJsonObj(); |
| | | if (Objects.nonNull(formObj) && Objects.nonNull(formObj.get(ProcessConstants.TASK_FORM_KEY))) { |
| | | JSONObject formJson = JSONObject.parseObject(JSON.toJSONString(formObj.get(ProcessConstants.TASK_FORM_KEY))); |
| | | normalizeUploadUrl(formJson); |
| | | formObj.put(ProcessConstants.TASK_FORM_KEY, formJson); |
| | | formDetailVO.setFormJsonObj(formObj); |
| | | } |
| | | } |
| | | } |
| | | return beforeNodes; |
| | | } |
| | | |
| | | private void normalizeUploadUrl(JSONObject formJson) { |
| | | if (Objects.isNull(formJson)) { |
| | | return; |
| | | } |
| | | List<JSONObject> fields = JSON.parseObject(JSON.toJSONString(formJson.get(ProcessConstants.WIDGET_LIST)), new TypeReference<List<JSONObject>>() { |
| | | }); |
| | | if (CollectionUtils.isEmpty(fields)) { |
| | | return; |
| | | } |
| | | for (JSONObject field : fields) { |
| | | if (!"file-upload".equals(field.get("type"))) { |
| | | continue; |
| | | } |
| | | JSONObject options = field.getJSONObject("options"); |
| | | if (Objects.isNull(options)) { |
| | | continue; |
| | | } |
| | | options.put("uploadURL", String.format("http://%s:10076/common/upload", this.targetIp)); |
| | | } |
| | | formJson.put(ProcessConstants.WIDGET_LIST, fields); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 流程节点信息 |