diff --git a/javascript/xuanran.wang/longgong/NewProductTest.js b/javascript/xuanran.wang/longgong/NewProductTest.js new file mode 100644 index 0000000..b0f6285 --- /dev/null +++ b/javascript/xuanran.wang/longgong/NewProductTest.js @@ -0,0 +1,117 @@ +// 首台销售日期 +const firstSaleDateField = WfForm.convertFieldNameToId("stxsrq"); +// 跟踪时间 +const trackTimeField = WfForm.convertFieldNameToId("gzsj"); +// 跟踪时间为三个月以内 +const threeMonthIndex = 1; +// 是否提交等待节点 +const submitWaitNode = WfForm.convertFieldNameToId("sftjddjd"); +// 下次超时提醒日期 +const timeoutRemindDateFiled = WfForm.convertFieldNameToId("cstxrq"); +// 跟踪天数 +const trackingDays = WfForm.getFieldValue(trackTimeField) <= 1 ? 15 : 30; +// 跟踪触发行数 +const trackingLineField = WfForm.convertFieldNameToId("gzcfxs"); +$(() => { + let detail2LineNum = WfForm.getDetailRowCount("detail_2"); + // let firstTrack = Boolean(true); + // if (new Date(firstSaleDate) < new Date(currentDate) && dayDiff > 0) { + // firstTrack = false; + // } + // console.log('firstTrack ', firstTrack) + // 到达节点次数 + const nodeNum = getNodeNum(); + let trackingLine = parseInt(WfForm.getFieldValue(trackingLineField)); + // 如果不是则自动添加一行明细让他自己填写 + if (detail2LineNum < trackingLine && detail2LineNum < nodeNum) { + console.log('添加一行明细!'); + WfForm.addDetailRow("detail_2", {}); + } + if(detail2LineNum >= trackingLine){ + WfForm.changeFieldValue(submitWaitNode, {value: 1}); + WfForm.changeFieldValue(timeoutRemindDateFiled, {value: ''}); + return; + } + initTimeoutDate(); + WfForm.bindFieldChangeEvent(`${firstSaleDateField},${trackTimeField}`,()=>{ + initTimeoutDate(); + }); +}); + +function getNodeNum(){ + let firstSaleDate = WfForm.getFieldValue(firstSaleDateField); + console.log('首台销售日期 ', firstSaleDate); + let currentDate = getCurrentDate(); + let dayDiff = getDaysDiff(firstSaleDate, currentDate); + console.log('当前天数与首台销售日期相差天数 : ', dayDiff) + return Math.floor(dayDiff / trackingDays) + 1; +} + +function initTimeoutDate(){ + console.log('==== initTimeoutDate begin ====') + let firstSaleDate = WfForm.getFieldValue(firstSaleDateField); + const nodeNum = getNodeNum(); + console.log('到达节点次数 ', nodeNum); + console.log('跟踪天数 ', trackingDays); + let computeTimeoutDate = addDays(firstSaleDate, nodeNum * trackingDays); + console.log('计算下次超时日期 ', computeTimeoutDate); + let trackingLine = parseInt(WfForm.getFieldValue(trackingLineField)); + let detail2LineNum = WfForm.getDetailRowCount("detail_2"); + setTimeout(()=>{ + WfForm.changeFieldValue(timeoutRemindDateFiled, {value: computeTimeoutDate}); + // 判断流程提交走向 + console.log('主表跟踪触发行数 : ', trackingLine) + if (nodeNum >= trackingLine) { + console.log('nodeNum >= trackingLine'); + WfForm.changeFieldValue(submitWaitNode, {value: 1}); + WfForm.changeFieldValue(timeoutRemindDateFiled, {value: ''}); + WfForm.registerCheckEvent(WfForm.OPER_SUBMIT, function (callback) { + detail2LineNum = WfForm.getDetailRowCount("detail_2"); + if (detail2LineNum < trackingLine) { + WfForm.showMessage('请填写明细表信息!'); + detail2LineNum = WfForm.getDetailRowCount("detail_2"); + for (let i = 0; i < trackingLine - parseInt(detail2LineNum); i++) { + WfForm.addDetailRow("detail_2", {}); + } + return; + } + callback(); + }); + } else { + WfForm.changeFieldValue(submitWaitNode, {value: 0}); + } + console.log('==== initTimeoutDate end ====') + },10); +} + +function getDaysDiff(date1, date2) { + date1 = new Date(date1); + date2 = new Date(date2); + const oneDay = 24 * 60 * 60 * 1000; // 一天的毫秒数 + const timeDiff = Math.abs(date1.getTime() - date2.getTime()); // 两个日期对象的毫秒数差值 + // 将毫秒数差值转换为天数差值并四舍五入 + return Math.round(timeDiff / oneDay); +} + +function getCurrentDate() { + return parseDate(new Date()); +} + +function parseDate(date) { + const currentYear = date.getFullYear(); + const currentMonth = date.getMonth() + 1; // getMonth()返回0~11,需要加1 + const currentDay = date.getDate(); + return currentYear + '-' + currentMonth + '-' + currentDay; +} + +function addDays(date, days) { + const newDate = new Date(date); + newDate.setDate(newDate.getDate() + days); + console.log('newDate ', newDate) + return parseDate(newDate); +} + + + + + diff --git a/src/main/java/weaver/xiao/commons/config/service/DealWithMapping.java b/src/main/java/weaver/xiao/commons/config/service/DealWithMapping.java index a893b70..a9af287 100644 --- a/src/main/java/weaver/xiao/commons/config/service/DealWithMapping.java +++ b/src/main/java/weaver/xiao/commons/config/service/DealWithMapping.java @@ -6,6 +6,7 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; import weaver.conn.RecordSet; import weaver.file.ImageFileManager; import weaver.general.Util; @@ -59,12 +60,14 @@ public class DealWithMapping extends ToolUtil { private RecordSet tempRs; private DealWithMapper mapper = null; + + private final Logger logger = aiyh.utils.Util.getLogger("json-util"); { try { mapper = aiyh.utils.Util.getMapper(DealWithMapper.class); } catch (Exception e) { - this.writeErrorLog("缺少 aiyh_utils.jar依赖,初始化失败!"); + logger.error("缺少 aiyh_utils.jar依赖,初始化失败!"); } } @@ -190,7 +193,7 @@ public class DealWithMapping extends ToolUtil { * @return */ public RequestMappingConfig treeDealWithUniqueCode(String uniqueCode) { - this.writeDebuggerLog("============== 根据uniqueCode查询请求配置树形列表 treeDealWith begin ================="); + logger.info("============== 根据uniqueCode查询请求配置树形列表 treeDealWith begin ================="); RequestMappingConfig tempConfig = mappingCMD.selectByUniqueCode(uniqueCode); return this.dealWith(tempConfig); } @@ -202,7 +205,7 @@ public class DealWithMapping extends ToolUtil { * @return */ public RequestMappingConfig dealWith(RequestMappingConfig tempConfig) { - this.writeDebuggerLog("查询到的请求配置列表 query RequestMappingConfig list >>>" + JSON.toJSONString(tempConfig)); + logger.info("查询到的请求配置列表 query RequestMappingConfig list >>>" + JSON.toJSONString(tempConfig)); List mappingDetails = tempConfig.getConfigDetail(); List subMappingDetailList = new ArrayList<>(); // 过滤出指定节点的子节点,并返回除去子节点之外的节点列表 @@ -227,7 +230,7 @@ public class DealWithMapping extends ToolUtil { mappingDetailList.add(mappingDetail); } requestMappingConfig.setConfigDetail(mappingDetailList); - this.writeDebuggerLog("通过处理后得到的树形参数列表 deal with tree >>>" + JSON.toJSONString(requestMappingConfig)); + logger.info("通过处理后得到的树形参数列表 deal with tree >>>" + JSON.toJSONString(requestMappingConfig)); return requestMappingConfig; } @@ -820,7 +823,7 @@ public class DealWithMapping extends ToolUtil { Date date = value instanceof Date ? (Date) value : parseDate(String.valueOf(value)); value = this.diyDateFortMat(date, "yyyy-MM-dd"); } catch (Exception e) { - this.writeDebuggerLog("时间处理异常:" + e); + logger.info("时间处理异常:" + e); throw new ValueDealException("时间处理异常:参数>>" + paramName); } } @@ -835,7 +838,7 @@ public class DealWithMapping extends ToolUtil { Date date = value instanceof Date ? (Date) value : parseDate(String.valueOf(value)); value = this.diyDateFortMat(date, "yyyy-MM-dd HH:mm:ss"); } catch (Exception e) { - this.writeDebuggerLog("时间处理异常:" + e); + logger.info("时间处理异常:" + e); throw new ValueDealException("时间处理异常:参数>>" + paramName + " 异常信息:" + e); } } @@ -851,7 +854,7 @@ public class DealWithMapping extends ToolUtil { Date date = value instanceof Date ? (Date) value : parseDate(String.valueOf(value)); value = this.diyDateFortMat(date, forMatString); } catch (Exception e) { - this.writeDebuggerLog("时间处理异常:" + e); + logger.info("时间处理异常:" + e); throw new ValueDealException("时间处理异常:参数>>" + paramName + " 异常信息:" + e.getMessage()); } } @@ -866,7 +869,7 @@ public class DealWithMapping extends ToolUtil { Date date = value instanceof Date ? (Date) value : parseDate(String.valueOf(value)); value = date.getTime(); } catch (Exception e) { - this.writeDebuggerLog("时间处理异常:" + e); + logger.info("时间处理异常:" + e); throw new ValueDealException("时间处理异常:参数>>" + paramName + " 异常信息:" + e.getMessage()); } } @@ -918,7 +921,7 @@ public class DealWithMapping extends ToolUtil { FieldMessage fieldMassage = mappingDetail.getFieldMassage(); String fieldName = fieldMassage.getFieldName(); String fieldNameLower = fieldName.toLowerCase(); - this.writeDebuggerLog("fieldName:" + fieldName); + logger.info("fieldName:" + fieldName); if ("1".equals(childSource)) { value = Util.null2String(detailMap.get(fieldNameLower)); if ("".equals(value)) { @@ -1081,7 +1084,7 @@ public class DealWithMapping extends ToolUtil { multipartFile.setStream(fileInputStream); multipartFile.setFileName(docImageFile.getImageFileName()); multipartFile.setFileSize(docImageFile.getFileSize() / 1024); - this.writeDebuggerLog("multipartFile ==>" + multipartFile); + logger.info("multipartFile ==>" + multipartFile); multipartFileList.add(multipartFile); } return null; @@ -1132,7 +1135,7 @@ public class DealWithMapping extends ToolUtil { default: throw new ValueDealException("不支持的取值方式"); } - this.writeDebuggerLog("value1:" + value); + logger.info("value1:" + value); switch (typeEnum) { // String类型 case STRING: { @@ -1415,7 +1418,7 @@ public class DealWithMapping extends ToolUtil { * @return 要插入的信息 */ public Map> dealResponse(List responseMappingList, Map requestRes) { - this.writeDebuggerLog("回写信息转换处理 responseMappingList==>" + responseMappingList + " requestRes==>" + requestRes + "mainTable ==>" + mainTable); + logger.info("回写信息转换处理 responseMappingList==>" + responseMappingList + " requestRes==>" + requestRes + "mainTable ==>" + mainTable); Map> tableUpdateMap = new HashMap<>(); if (responseMappingList != null && !responseMappingList.isEmpty()) { Map mainUpdateMap = new HashMap<>(); @@ -1443,7 +1446,7 @@ public class DealWithMapping extends ToolUtil { tableUpdateMap.put(detailTableName, detailUpdateMap); } } - this.writeDebuggerLog("回写信息tableUpdateMap==> " + tableUpdateMap); + logger.info("回写信息tableUpdateMap==> " + tableUpdateMap); return tableUpdateMap; } diff --git a/src/test/java/xuanran/wang/shyl/dataasync/AsyncTest.java b/src/test/java/xuanran/wang/shyl/dataasync/AsyncTest.java index 2db4f9b..6ec1a1e 100644 --- a/src/test/java/xuanran/wang/shyl/dataasync/AsyncTest.java +++ b/src/test/java/xuanran/wang/shyl/dataasync/AsyncTest.java @@ -2,6 +2,7 @@ package xuanran.wang.shyl.dataasync; import aiyh.utils.Util; import aiyh.utils.excention.CustomerException; +import aiyh.utils.httpUtil.ResponeVo; import aiyh.utils.httpUtil.util.HttpUtils; import aiyh.utils.tool.cn.hutool.http.HttpRequest; import basetest.BaseTest; @@ -238,29 +239,13 @@ public class AsyncTest extends BaseTest { @Test public void testB() { - String json = "[{\n" + - "\t\"requestName\": \"你个沙雕32323\",\n" + - "\t\"workflowId\": \"45\",\n" + - "\t\"mainData\": [{\n" + - "\t\t\"fieldName\": \"yysy\",\n" + - "\t\t\"fieldValue\": \"测试20230309\"\n" + - "\t}]\n" + - "}, {\n" + - "\t\"requestName\": \"沙雕2号\",\n" + - "\t\"workflowId\": \"45\",\n" + - "\t\"mainData\": [{\n" + - "\t\t\"fieldName\": \"yysy\",\n" + - "\t\t\"fieldValue\": \"沙雕沙雕沙雕沙雕沙雕\"\n" + - "\t}]\n" + - "}, {\n" + - "\t\"requestName\": \"沙雕2号\",\n" + - "\t\"workflowId\": \"451\",\n" + - "\t\"mainData\": [{\n" + - "\t\t\"fieldName\": \"yysy\",\n" + - "\t\t\"fieldValue\": \"沙雕沙雕沙雕沙雕沙雕\"\n" + - "\t}]\n" + - "}]"; - testRestful("http://183.192.65.115:8080", "/api/wxr/shyl/workflow/batchCreate233", json); + String json = "{\"requestName\":\"教研资批量新增会议室申请流程\",\"mainData\":[{\"fieldName\":\"Address\",\"fieldValue\":192},{\"fieldName\":\"customId\",\"fieldValue\":\"500ffadfad744d5a90212f776ff13bb2\"},{\"fieldName\":\"field_1716678529\",\"fieldValue\":0},{\"fieldName\":\"MeetingType\",\"fieldValue\":0},{\"fieldName\":\"MeetingName\",\"fieldValue\":\"测试青干BB班0511-新时代中国青年的使命与担当——关于新时代中国青年,总书记怎么说-2023-05-11-授课场地预定\"},{\"fieldName\":\"description\",\"fieldValue\":\"授课场地预定\"},{\"fieldName\":\"field_1168264962\",\"fieldValue\":1},{\"fieldName\":\"BeginDate\",\"fieldValue\":\"2023-05-11\"},{\"fieldName\":\"BeginTime\",\"fieldValue\":\"18:01\"},{\"fieldName\":\"EndDate\",\"fieldValue\":\"2023-05-11\"},{\"fieldName\":\"EndTime\",\"fieldValue\":\"18:05\"}],\"detailData\":[],\"workflowId\":46}\n"; + testRestful("http://183.192.65.115:8080", "/api/workflow/paService/doCreateRequest", json); + } + + @Test + public void testA(){ + } /** @@ -348,21 +333,22 @@ public class AsyncTest extends BaseTest { // 封装请求头参数 RSA rsa = new RSA(null, spk); // 对用户信息进行加密传输,暂仅支持传输OA用户ID - String encryptUserid = rsa.encryptBase64("1", CharsetUtil.CHARSET_UTF_8, KeyType.PublicKey); - List list = JSONObject.parseObject(jsonParams, List.class); + String encryptUserid = rsa.encryptBase64("54", CharsetUtil.CHARSET_UTF_8, KeyType.PublicKey); + Map list = JSONObject.parseObject(jsonParams, Map.class); HttpUtils httpUtils = new HttpUtils(); HashMap headers = new HashMap<>(); headers.put("appid", APPID); headers.put("token", token); headers.put("userid", encryptUserid); - headers.put("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); + httpUtils.getGlobalCache().header.put("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); log.info("请求头 = > " + headers); -// try { -// ResponeVo responeVo = httpUtils.apiPostObject(address + api, list, headers); -// log.info("reslut => " + JSONObject.toJSON(responeVo)); -// } catch (Exception e) { -// log.error("e => " + e.getMessage()); -// } + try { + log.info("list : " + list); + ResponeVo responeVo = httpUtils.apiPostObject(address + api, list, headers); + log.info("reslut => " + JSONObject.toJSON(responeVo)); + } catch (Exception e) { + log.error("e => " + e.getMessage()); + } return ""; }