diff --git a/javascript/xuanran.wang/longgong/NewProductTest.js b/javascript/xuanran.wang/longgong/NewProductTest.js index fe457d8..9e7768e 100644 --- a/javascript/xuanran.wang/longgong/NewProductTest.js +++ b/javascript/xuanran.wang/longgong/NewProductTest.js @@ -59,7 +59,7 @@ function initTimeoutDate(){ console.log('计算下次超时日期 ', computeTimeoutDate); var trackingLine = parseInt(WfForm.getFieldValue(trackingLineField)); var detail2LineNum = WfForm.getDetailRowCount("detail_2"); - setTimeout(()=>{ + setTimeout(function (){ WfForm.changeFieldValue(timeoutRemindDateFiled, {value: computeTimeoutDate}); // 判断流程提交走向 console.log('主表跟踪触发行数 : ', trackingLine) @@ -101,7 +101,10 @@ function getCurrentDate() { function parseDate(date) { var currentYear = date.getFullYear(); - var currentMonth = date.getMonth() + 1; // getMonth()返回0~11,需要加1 + var currentMonth = date.getMonth() + 1;// getMonth()返回0~11,需要加1 + if(currentMonth < 10){ + currentMonth = '0' + currentMonth; + } var currentDay = date.getDate(); return currentYear + '-' + currentMonth + '-' + currentDay; } diff --git a/src/main/java/weaver/xuanran/wang/immc/cusfieldvalue/CusListValue.java b/src/main/java/weaver/xuanran/wang/immc/cusfieldvalue/CusListValue.java index 4694a75..8079d3e 100644 --- a/src/main/java/weaver/xuanran/wang/immc/cusfieldvalue/CusListValue.java +++ b/src/main/java/weaver/xuanran/wang/immc/cusfieldvalue/CusListValue.java @@ -32,19 +32,20 @@ public class CusListValue implements CusInterfaceGetValue { // 如果fileName不为空则对集合中每个map添加"fileName":value value则是附件字段名称 String fileName = Util.null2DefaultStr(pathParam.get("fileName"), ""); if(StringUtils.isNotBlank(cusSql)){ + cusSql = cusSql.replace("{?requestid}",Util.null2DefaultStr(mainMap.get("requestid"),"")); if (StringUtils.isNotBlank(attachmentField)) { - for (String item : attachmentField.split(",")) { + String[] fields = attachmentField.split(","); + for (String item : fields) { String filedValue = Util.null2DefaultStr(mainMap.get(item),""); - if(StringUtils.isNotBlank(Util.null2DefaultStr(mainMap.get(filedValue),""))){ - cusSql = cusSql - .replace("{?docIds}", "( " + filedValue + " )") - .replace("{?requestid}",Util.null2DefaultStr(mainMap.get("requestid"),"")); - List> attachmentInfo = mapper.getAttachmentInfo(cusSql); + String fileSql = cusSql; + if(StringUtils.isNotBlank(filedValue)){ + fileSql = fileSql.replace("{?docIds}", "( " + filedValue + " )"); + List> attachmentInfo = mapper.getAttachmentInfo(fileSql); if(CollectionUtils.isEmpty(attachmentInfo)){ continue; } // 往map中put附件字段名 - if(StringUtils.isBlank(fileName)){ + if(StringUtils.isNotBlank(fileName)){ attachmentInfo.forEach(file ->{ file.put(fileName, item); }); @@ -52,6 +53,11 @@ public class CusListValue implements CusInterfaceGetValue { list.addAll(attachmentInfo); } } + }else { + List> attachmentInfo = mapper.getAttachmentInfo(cusSql); + if(CollectionUtils.isNotEmpty(attachmentInfo)){ + list.addAll(attachmentInfo); + } } } return list; diff --git a/src/main/java/weaver/xuanran/wang/immc/service/WorkFlowToVmsAndMQService.java b/src/main/java/weaver/xuanran/wang/immc/service/WorkFlowToVmsAndMQService.java index efcbf85..6de58fa 100644 --- a/src/main/java/weaver/xuanran/wang/immc/service/WorkFlowToVmsAndMQService.java +++ b/src/main/java/weaver/xuanran/wang/immc/service/WorkFlowToVmsAndMQService.java @@ -42,7 +42,6 @@ public class WorkFlowToVmsAndMQService { // 表单字段 private static final String VMS_SUCCESS = "vms_success"; private static final String SUCCESS = "0"; - { httpUtils.getGlobalCache().header.put("Content-Type", MediaType.APPLICATION_JSON); // 全局请求头 } @@ -51,11 +50,11 @@ public class WorkFlowToVmsAndMQService { /** *

推送数据

* - * @param onlyMark 唯一编码 - * @param billTable 表名 - * @param requestId 请求id + * @param onlyMark 唯一编码 + * @param billTable 表名 + * @param requestId 请求id * @param vmsResponseVoField vms成功标识 - * @param config kafka配置文件名称 + * @param config kafka配置文件名称 * @author xuanran.wang * @dateTime 2022/12/5 17:05 **/ @@ -69,9 +68,9 @@ public class WorkFlowToVmsAndMQService { String url = requestMappingConfig.getRequestUrl(); dealWithMapping.setMainTable(billTable); Map param = dealWithMapping.getRequestParam(recordSet, requestMappingConfig); - String vmsSuccess = Util.null2DefaultStr(recordSet.getString(VMS_SUCCESS), ""); - String mqSuccess = Util.null2DefaultStr(recordSet.getString(MQ_SUCCESS), ""); - if (!SUCCESS.equals(vmsSuccess)) { + String vmsSuccess = Util.null2DefaultStr(recordSet.getString(VMS_SUCCESS),""); + String mqSuccess = Util.null2DefaultStr(recordSet.getString(MQ_SUCCESS),""); + if(!SUCCESS.equals(vmsSuccess)){ ResponeVo responeVo; try { responeVo = httpUtils.apiPost(url, param); @@ -81,7 +80,7 @@ public class WorkFlowToVmsAndMQService { parseResponseVo(responeVo, url, param, vmsResponseVoField); updateWorkFlow(VMS_SUCCESS, billTable, requestId); } - if (!SUCCESS.equals(mqSuccess) && StringUtils.isNotBlank(config)) { + if(!SUCCESS.equals(mqSuccess) && StringUtils.isNotBlank(config)){ sendToMQ(config, param); updateWorkFlow(MQ_SUCCESS, billTable, requestId); } @@ -89,14 +88,13 @@ public class WorkFlowToVmsAndMQService { /** *

解析响应对象

- * - * @param responseVo 响应对象 - * @param url 地址 - * @param requestParam 请求 * @author xuanran.wang * @dateTime 2022/12/23 11:25 + * @param responseVo 响应对象 + * @param url 地址 + * @param requestParam 请求 **/ - private void parseResponseVo(ResponeVo responseVo, String url, Map requestParam, VmsResponseVoField vmsResponseVoField) { + private void parseResponseVo(ResponeVo responseVo, String url, Map requestParam, VmsResponseVoField vmsResponseVoField){ if (responseVo.getCode() != SUCCESS_CODE) { // 相应状态码 log.error(Util.logStr("can not fetch [{}],this request params is [{}]," + // 构建日志字符串 "this request heard is [{}],but response status code is [{}]," + @@ -114,65 +112,63 @@ public class WorkFlowToVmsAndMQService { /** *

将流程信息发送到kafka

- * - * @param kafkaConfig kafka配置文件名称 - * @param message 消息对象 * @author xuanran.wang * @dateTime 2023/3/30 14:56 + * @param kafkaConfig kafka配置文件名称 + * @param message 消息对象 **/ - public void sendToMQ(String kafkaConfig, Map message) { + public void sendToMQ(String kafkaConfig, Map message){ KafkaProducer producer = null; InputStream inputStream = null; - try { - String path = GCONST.getPropertyPath() + "prop2map" + File.separator + kafkaConfig + ".properties"; - File configFile = new File(path); - if (!configFile.exists()) { - throw new CustomerException("please check /web-inf/prop2map has " + kafkaConfig + ".properties"); - } - Properties prop = new Properties(); - inputStream = new BufferedInputStream(Files.newInputStream(configFile.toPath())); - prop.load(inputStream); - log.info("prop => " + JSONObject.toJSONString(prop)); - log.info("msg => " + JSONObject.toJSONString(message)); - String topic = Util.null2DefaultStr(prop.getProperty("topic"), ""); - if (StringUtils.isBlank(topic)) { - throw new CustomerException("kafka properties topic can not null!"); - } - producer = new KafkaProducer<>(prop); - // 发送消息到指定主题 - ProducerRecord record = new ProducerRecord<>(topic, JSONObject.toJSONString(message)); - producer.send(record).get(); - } catch (Exception e) { - log.error(Util.getErrString(e)); - throw new CustomerException(Util.logStr("send to kafka error!: [{}]", e.getMessage())); - } finally { - // 关闭Kafka生产者实例 - if (producer != null) { - producer.close(); - } - if (inputStream != null) { - try { - inputStream.close(); - } catch (Exception e) { - log.error("inputStream close error! " + e.getMessage()); - } - } - } + try { + String path = GCONST.getPropertyPath() + "prop2map" + File.separator + kafkaConfig + ".properties"; + File configFile = new File(path); + if(!configFile.exists()){ + throw new CustomerException("please check /web-inf/prop2map has " + kafkaConfig + ".properties"); + } + Properties prop = new Properties(); + inputStream= new BufferedInputStream(Files.newInputStream(configFile.toPath())); + prop.load(inputStream); + log.info("prop => " + JSONObject.toJSONString(prop)); + log.info("msg => " + JSONObject.toJSONString(message)); + String topic = Util.null2DefaultStr(prop.getProperty("topic"),""); + if(StringUtils.isBlank(topic)){ + throw new CustomerException("kafka properties topic can not null!"); + } + producer = new KafkaProducer<>(prop); + // 发送消息到指定主题 + ProducerRecord record = new ProducerRecord<>(topic, JSONObject.toJSONString(message)); + producer.send(record).get(); + }catch (Exception e){ + log.error(Util.getErrString(e)); + throw new CustomerException(Util.logStr("send to kafka error!: [{}]", e.getMessage())); + }finally { + // 关闭Kafka生产者实例 + if(producer != null){ + producer.close(); + } + if(inputStream != null){ + try { + inputStream.close(); + }catch (Exception e){ + log.error("inputStream close error! " + e.getMessage()); + } + } + } } /** *

更新流程sql

- * - * @param field 主表字段 - * @param tableName 表名 - * @param requestId 请求id * @author xuanran.wang * @dateTime 2023/3/30 19:18 + * @param field 主表字段 + * @param tableName 表名 + * @param requestId 请求id **/ - public void updateWorkFlow(String field, String tableName, String requestId) { + public void updateWorkFlow(String field, String tableName, String requestId){ String updateSQL = "update " + tableName + " set " + field + " = " + SUCCESS + " where requestid = ?"; RecordSet recordSet = new RecordSet(); - if (!recordSet.executeUpdate(updateSQL, requestId)) { + if(!recordSet.executeUpdate(updateSQL, requestId)){ log.error(Util.logStr("update field error! sql: {}, requestId: {}", updateSQL, requestId)); throw new CustomerException("更新表单字段失败!"); } diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/SendTodoTaskUtil.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/SendTodoTaskUtil.java index 4a9e12d..b6c8e8c 100644 --- a/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/SendTodoTaskUtil.java +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/SendTodoTaskUtil.java @@ -80,15 +80,16 @@ public class SendTodoTaskUtil { } todoTask.setPcAgentId(pcAgentId); String todoSSOCallBackUrl = ShBigDataUtil.getPropertiesValByKey("todoSSOCallBackUrl"); - StringBuilder sb = new StringBuilder(todoSSOCallBackUrl); - sb.append("?user=") - .append(userId) - .append("&requestId=") - .append(requestId); -// todoTask.setLinkUrl(Util.null2DefaultStr(ShBigDataUtil.getPropertiesValByKey("taskPcUrl"), oaAddress) + "/spa/workflow/static4form/index.html?#/main/workflow/req?requestid="+requestId); -// todoTask.setMobileLinkUrl(Util.null2DefaultStr(ShBigDataUtil.getPropertiesValByKey("taskMobileUrl"), oaAddress) + "/spa/workflow/static4mobileform/index.html?#/req?requestid="+requestId); - todoTask.setLinkUrl(sb.toString()); - todoTask.setMobileLinkUrl(sb.append("&mobile=1").toString()); + String todoPcSSOCallBackUrl = ShBigDataUtil.getPropertiesValByKey("todoPcSSOCallBackUrl"); + if(StringUtils.isBlank(todoPcSSOCallBackUrl)){ + todoPcSSOCallBackUrl = todoSSOCallBackUrl; + } + // 移动端链接 + StringBuilder mobileUrl = new StringBuilder(todoSSOCallBackUrl); + // pc端链接 + StringBuilder pcUrl = new StringBuilder(todoPcSSOCallBackUrl); + todoTask.setLinkUrl(appendParam(pcUrl, userId, requestId).toString()); + todoTask.setMobileLinkUrl(appendParam(mobileUrl, userId, requestId).append("&mobile=1").toString()); todoTask.setSender(getConvertHrm(0, obj, String.valueOf(obj.getCreator().getUID()))); todoTask.setReceiver(getConvertHrm(1, obj, String.valueOf(userId))); res.add(todoTask); @@ -96,6 +97,14 @@ public class SendTodoTaskUtil { return res; } + public static StringBuilder appendParam(StringBuilder sb, int userId, int requestId){ + sb.append("?user=") + .append(userId) + .append("&requestId=") + .append(requestId); + return sb; + } + /** *

将oa任务对象转换成三方系统任务对象

* @author xuanran.wang diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/ShBigDataUtil.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/ShBigDataUtil.java index 022066b..88d217c 100644 --- a/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/ShBigDataUtil.java +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/ShBigDataUtil.java @@ -38,6 +38,8 @@ public class ShBigDataUtil { WHILTE_LIST.add("ssoInterfaceCompareField"); WHILTE_LIST.add("ssoOaCompareField"); WHILTE_LIST.add("pcAgentId"); + // pc回调地址 + WHILTE_LIST.add("todoPcSSOCallBackUrl"); } /** diff --git a/src/main/resources/WEB-INF/prop/prop2map/ShBigdataConf.properties b/src/main/resources/WEB-INF/prop/prop2map/ShBigdataConf.properties index 5c93ffa..7c96873 100644 --- a/src/main/resources/WEB-INF/prop/prop2map/ShBigdataConf.properties +++ b/src/main/resources/WEB-INF/prop/prop2map/ShBigdataConf.properties @@ -26,9 +26,10 @@ taskPcUrl=http://127.0.0.1/spa/workflow/static4form/index.html?#/main/workflow/r taskMobileUrl=http://127.0.0.1/spa/workflow/static4mobileform/index.html?#/req?requestid={requestId} # oa token缓存对象提前过期时间 expiryBeforeTime=5 -# 统一待办单点接口地址 +# 统一待办单点移动端接口地址 todoSSOCallBackUrl=http://127.0.0.1/api/wxr/sh_big_data/sso/login/dhajhdsajdhsajdaskdlakdl - +# 统一待办单点pc接口地址 +todoPcSSOCallBackUrl=http://127.0.0.1/api/wxr/sh_big_data/sso/login/dhajhdsajdhsajdaskdlakdl # ================ 组织架构同步新增 ================ # 分部最大的层级 maxLevel=3 diff --git a/src/test/java/xuanran/wang/NormalTest.java b/src/test/java/xuanran/wang/NormalTest.java index 0fc4fb5..17b6aac 100644 --- a/src/test/java/xuanran/wang/NormalTest.java +++ b/src/test/java/xuanran/wang/NormalTest.java @@ -4,6 +4,7 @@ import aiyh.utils.GenerateFileUtil; import basetest.BaseTest; import org.junit.Test; import weaver.xuanran.wang.eighty_five_degreec.sap.action.WorkflowToSap; +import weaver.xuanran.wang.immc.WorkFlowToVmsAndMQ; /** *

@@ -16,6 +17,6 @@ public class NormalTest extends BaseTest { @Test public void testWord(){ - GenerateFileUtil.createActionDocument(WorkflowToSap.class); + GenerateFileUtil.createActionDocument(WorkFlowToVmsAndMQ.class); } }