建模生成json类日志文件修改

jingwei
wangxuanran 2023-05-12 13:42:20 +08:00
parent b5d95fb201
commit a0bc9c30b9
3 changed files with 151 additions and 45 deletions

View File

@ -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);
}

View File

@ -6,6 +6,7 @@ import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import weaver.conn.RecordSet; import weaver.conn.RecordSet;
import weaver.file.ImageFileManager; import weaver.file.ImageFileManager;
import weaver.general.Util; import weaver.general.Util;
@ -59,12 +60,14 @@ public class DealWithMapping extends ToolUtil {
private RecordSet tempRs; private RecordSet tempRs;
private DealWithMapper mapper = null; private DealWithMapper mapper = null;
private final Logger logger = aiyh.utils.Util.getLogger("json-util");
{ {
try { try {
mapper = aiyh.utils.Util.getMapper(DealWithMapper.class); mapper = aiyh.utils.Util.getMapper(DealWithMapper.class);
} catch (Exception e) { } catch (Exception e) {
this.writeErrorLog("缺少 aiyh_utils.jar依赖初始化失败"); logger.error("缺少 aiyh_utils.jar依赖初始化失败");
} }
} }
@ -190,7 +193,7 @@ public class DealWithMapping extends ToolUtil {
* @return * @return
*/ */
public RequestMappingConfig treeDealWithUniqueCode(String uniqueCode) { public RequestMappingConfig treeDealWithUniqueCode(String uniqueCode) {
this.writeDebuggerLog("============== 根据uniqueCode查询请求配置树形列表 treeDealWith begin ================="); logger.info("============== 根据uniqueCode查询请求配置树形列表 treeDealWith begin =================");
RequestMappingConfig tempConfig = mappingCMD.selectByUniqueCode(uniqueCode); RequestMappingConfig tempConfig = mappingCMD.selectByUniqueCode(uniqueCode);
return this.dealWith(tempConfig); return this.dealWith(tempConfig);
} }
@ -202,7 +205,7 @@ public class DealWithMapping extends ToolUtil {
* @return * @return
*/ */
public RequestMappingConfig dealWith(RequestMappingConfig tempConfig) { public RequestMappingConfig dealWith(RequestMappingConfig tempConfig) {
this.writeDebuggerLog("查询到的请求配置列表 query RequestMappingConfig list >>>" + JSON.toJSONString(tempConfig)); logger.info("查询到的请求配置列表 query RequestMappingConfig list >>>" + JSON.toJSONString(tempConfig));
List<MappingDetail> mappingDetails = tempConfig.getConfigDetail(); List<MappingDetail> mappingDetails = tempConfig.getConfigDetail();
List<MappingDetail> subMappingDetailList = new ArrayList<>(); List<MappingDetail> subMappingDetailList = new ArrayList<>();
// 过滤出指定节点的子节点,并返回除去子节点之外的节点列表 // 过滤出指定节点的子节点,并返回除去子节点之外的节点列表
@ -227,7 +230,7 @@ public class DealWithMapping extends ToolUtil {
mappingDetailList.add(mappingDetail); mappingDetailList.add(mappingDetail);
} }
requestMappingConfig.setConfigDetail(mappingDetailList); requestMappingConfig.setConfigDetail(mappingDetailList);
this.writeDebuggerLog("通过处理后得到的树形参数列表 deal with tree >>>" + JSON.toJSONString(requestMappingConfig)); logger.info("通过处理后得到的树形参数列表 deal with tree >>>" + JSON.toJSONString(requestMappingConfig));
return requestMappingConfig; return requestMappingConfig;
} }
@ -820,7 +823,7 @@ public class DealWithMapping extends ToolUtil {
Date date = value instanceof Date ? (Date) value : parseDate(String.valueOf(value)); Date date = value instanceof Date ? (Date) value : parseDate(String.valueOf(value));
value = this.diyDateFortMat(date, "yyyy-MM-dd"); value = this.diyDateFortMat(date, "yyyy-MM-dd");
} catch (Exception e) { } catch (Exception e) {
this.writeDebuggerLog("时间处理异常:" + e); logger.info("时间处理异常:" + e);
throw new ValueDealException("时间处理异常:参数>>" + paramName); throw new ValueDealException("时间处理异常:参数>>" + paramName);
} }
} }
@ -835,7 +838,7 @@ public class DealWithMapping extends ToolUtil {
Date date = value instanceof Date ? (Date) value : parseDate(String.valueOf(value)); Date date = value instanceof Date ? (Date) value : parseDate(String.valueOf(value));
value = this.diyDateFortMat(date, "yyyy-MM-dd HH:mm:ss"); value = this.diyDateFortMat(date, "yyyy-MM-dd HH:mm:ss");
} catch (Exception e) { } catch (Exception e) {
this.writeDebuggerLog("时间处理异常:" + e); logger.info("时间处理异常:" + e);
throw new ValueDealException("时间处理异常:参数>>" + paramName + " 异常信息:" + 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)); Date date = value instanceof Date ? (Date) value : parseDate(String.valueOf(value));
value = this.diyDateFortMat(date, forMatString); value = this.diyDateFortMat(date, forMatString);
} catch (Exception e) { } catch (Exception e) {
this.writeDebuggerLog("时间处理异常:" + e); logger.info("时间处理异常:" + e);
throw new ValueDealException("时间处理异常:参数>>" + paramName + " 异常信息:" + e.getMessage()); 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)); Date date = value instanceof Date ? (Date) value : parseDate(String.valueOf(value));
value = date.getTime(); value = date.getTime();
} catch (Exception e) { } catch (Exception e) {
this.writeDebuggerLog("时间处理异常:" + e); logger.info("时间处理异常:" + e);
throw new ValueDealException("时间处理异常:参数>>" + paramName + " 异常信息:" + e.getMessage()); throw new ValueDealException("时间处理异常:参数>>" + paramName + " 异常信息:" + e.getMessage());
} }
} }
@ -918,7 +921,7 @@ public class DealWithMapping extends ToolUtil {
FieldMessage fieldMassage = mappingDetail.getFieldMassage(); FieldMessage fieldMassage = mappingDetail.getFieldMassage();
String fieldName = fieldMassage.getFieldName(); String fieldName = fieldMassage.getFieldName();
String fieldNameLower = fieldName.toLowerCase(); String fieldNameLower = fieldName.toLowerCase();
this.writeDebuggerLog("fieldName:" + fieldName); logger.info("fieldName:" + fieldName);
if ("1".equals(childSource)) { if ("1".equals(childSource)) {
value = Util.null2String(detailMap.get(fieldNameLower)); value = Util.null2String(detailMap.get(fieldNameLower));
if ("".equals(value)) { if ("".equals(value)) {
@ -1081,7 +1084,7 @@ public class DealWithMapping extends ToolUtil {
multipartFile.setStream(fileInputStream); multipartFile.setStream(fileInputStream);
multipartFile.setFileName(docImageFile.getImageFileName()); multipartFile.setFileName(docImageFile.getImageFileName());
multipartFile.setFileSize(docImageFile.getFileSize() / 1024); multipartFile.setFileSize(docImageFile.getFileSize() / 1024);
this.writeDebuggerLog("multipartFile ==>" + multipartFile); logger.info("multipartFile ==>" + multipartFile);
multipartFileList.add(multipartFile); multipartFileList.add(multipartFile);
} }
return null; return null;
@ -1132,7 +1135,7 @@ public class DealWithMapping extends ToolUtil {
default: default:
throw new ValueDealException("不支持的取值方式"); throw new ValueDealException("不支持的取值方式");
} }
this.writeDebuggerLog("value1:" + value); logger.info("value1:" + value);
switch (typeEnum) { switch (typeEnum) {
// String类型 // String类型
case STRING: { case STRING: {
@ -1415,7 +1418,7 @@ public class DealWithMapping extends ToolUtil {
* @return * @return
*/ */
public Map<String, Map<String, Object>> dealResponse(List<ResponseMapping> responseMappingList, Map<String, Object> requestRes) { public Map<String, Map<String, Object>> dealResponse(List<ResponseMapping> responseMappingList, Map<String, Object> requestRes) {
this.writeDebuggerLog("回写信息转换处理 responseMappingList==>" + responseMappingList + " requestRes==>" + requestRes + "mainTable ==>" + mainTable); logger.info("回写信息转换处理 responseMappingList==>" + responseMappingList + " requestRes==>" + requestRes + "mainTable ==>" + mainTable);
Map<String, Map<String, Object>> tableUpdateMap = new HashMap<>(); Map<String, Map<String, Object>> tableUpdateMap = new HashMap<>();
if (responseMappingList != null && !responseMappingList.isEmpty()) { if (responseMappingList != null && !responseMappingList.isEmpty()) {
Map<String, Object> mainUpdateMap = new HashMap<>(); Map<String, Object> mainUpdateMap = new HashMap<>();
@ -1443,7 +1446,7 @@ public class DealWithMapping extends ToolUtil {
tableUpdateMap.put(detailTableName, detailUpdateMap); tableUpdateMap.put(detailTableName, detailUpdateMap);
} }
} }
this.writeDebuggerLog("回写信息tableUpdateMap==> " + tableUpdateMap); logger.info("回写信息tableUpdateMap==> " + tableUpdateMap);
return tableUpdateMap; return tableUpdateMap;
} }

View File

@ -2,6 +2,7 @@ package xuanran.wang.shyl.dataasync;
import aiyh.utils.Util; import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException; import aiyh.utils.excention.CustomerException;
import aiyh.utils.httpUtil.ResponeVo;
import aiyh.utils.httpUtil.util.HttpUtils; import aiyh.utils.httpUtil.util.HttpUtils;
import aiyh.utils.tool.cn.hutool.http.HttpRequest; import aiyh.utils.tool.cn.hutool.http.HttpRequest;
import basetest.BaseTest; import basetest.BaseTest;
@ -238,29 +239,13 @@ public class AsyncTest extends BaseTest {
@Test @Test
public void testB() { public void testB() {
String json = "[{\n" + 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";
"\t\"requestName\": \"你个沙雕32323\",\n" + testRestful("http://183.192.65.115:8080", "/api/workflow/paService/doCreateRequest", json);
"\t\"workflowId\": \"45\",\n" + }
"\t\"mainData\": [{\n" +
"\t\t\"fieldName\": \"yysy\",\n" + @Test
"\t\t\"fieldValue\": \"测试20230309\"\n" + public void testA(){
"\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);
} }
/** /**
@ -348,21 +333,22 @@ public class AsyncTest extends BaseTest {
// 封装请求头参数 // 封装请求头参数
RSA rsa = new RSA(null, spk); RSA rsa = new RSA(null, spk);
// 对用户信息进行加密传输,暂仅支持传输OA用户ID // 对用户信息进行加密传输,暂仅支持传输OA用户ID
String encryptUserid = rsa.encryptBase64("1", CharsetUtil.CHARSET_UTF_8, KeyType.PublicKey); String encryptUserid = rsa.encryptBase64("54", CharsetUtil.CHARSET_UTF_8, KeyType.PublicKey);
List list = JSONObject.parseObject(jsonParams, List.class); Map<String, Object> list = JSONObject.parseObject(jsonParams, Map.class);
HttpUtils httpUtils = new HttpUtils(); HttpUtils httpUtils = new HttpUtils();
HashMap<String, String> headers = new HashMap<>(); HashMap<String, String> headers = new HashMap<>();
headers.put("appid", APPID); headers.put("appid", APPID);
headers.put("token", token); headers.put("token", token);
headers.put("userid", encryptUserid); 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); log.info("请求头 = > " + headers);
// try { try {
// ResponeVo responeVo = httpUtils.apiPostObject(address + api, list, headers); log.info("list : " + list);
// log.info("reslut => " + JSONObject.toJSON(responeVo)); ResponeVo responeVo = httpUtils.apiPostObject(address + api, list, headers);
// } catch (Exception e) { log.info("reslut => " + JSONObject.toJSON(responeVo));
// log.error("e => " + e.getMessage()); } catch (Exception e) {
// } log.error("e => " + e.getMessage());
}
return ""; return "";
} }