From 3333e103f432e6ec740edbabcc4fbccd7c6c048b Mon Sep 17 00:00:00 2001 From: wangxuanran <3055088966@qq.com> Date: Tue, 20 Jun 2023 23:47:33 +0800 Subject: [PATCH 01/13] =?UTF-8?q?vms=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xuanran.wang/longgong/NewProductTest.js | 7 +- .../wang/immc/cusfieldvalue/CusListValue.java | 20 +-- .../service/WorkFlowToVmsAndMQService.java | 114 +++++++++--------- .../common/util/SendTodoTaskUtil.java | 27 +++-- .../sh_bigdata/common/util/ShBigDataUtil.java | 2 + .../prop/prop2map/ShBigdataConf.properties | 5 +- src/test/java/xuanran/wang/NormalTest.java | 3 +- 7 files changed, 98 insertions(+), 80 deletions(-) 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); } } From 0540f6b72e44cf10b8e055041eef1f577e1da5b6 Mon Sep 17 00:00:00 2001 From: wangxuanran <3055088966@qq.com> Date: Mon, 26 Jun 2023 10:18:01 +0800 Subject: [PATCH 02/13] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=AF=BB=E5=8F=96?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E4=B8=AD=E6=96=87=E4=B9=B1?= =?UTF-8?q?=E7=A0=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/aiyh/utils/Util.java | 11 ++- .../controller/ApiImmcWorkFlowToKafka.java | 49 ++++++++++ .../wang/immc/dto/ImmcWorkFlowToKafkaDto.java | 24 +++++ .../xuanran/wang/immc/WorkFlowToVmsAndMQ.java | 6 +- .../wang/immc/entity/CusRequestParam.java | 26 +++++ .../service/WorkFlowToVmsAndMQService.java | 98 +++++++++++++++---- .../common/util/SendTodoTaskUtil.java | 40 +++++++- .../sh_bigdata/common/util/ShBigDataUtil.java | 6 +- .../task_async/entity/CusTodoLeaderTask.java | 17 ++++ .../service/impl/SendTodoTaskServiceImpl.java | 6 +- .../prop/prop2map/ShBigdataConf.properties | 9 ++ .../xuanran/wang/big_data/BigDataTest.java | 44 +++++++++ 12 files changed, 311 insertions(+), 25 deletions(-) create mode 100644 src/main/java/com/api/xuanran/wang/immc/controller/ApiImmcWorkFlowToKafka.java create mode 100644 src/main/java/com/api/xuanran/wang/immc/dto/ImmcWorkFlowToKafkaDto.java create mode 100644 src/main/java/weaver/xuanran/wang/immc/entity/CusRequestParam.java create mode 100644 src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/entity/CusTodoLeaderTask.java diff --git a/src/main/java/aiyh/utils/Util.java b/src/main/java/aiyh/utils/Util.java index 99763b9..72856e1 100644 --- a/src/main/java/aiyh/utils/Util.java +++ b/src/main/java/aiyh/utils/Util.java @@ -1210,9 +1210,15 @@ public class Util extends weaver.general.Util { Properties prop = new Properties(); Map map = new HashMap<>(); InputStream inputStream = null; + InputStreamReader reader = null; try { inputStream = new BufferedInputStream(new FileInputStream(path)); - prop.load(inputStream); + /** + *

解决配置文件中 值包含中文乱码问题

+ *

xuanran.wang 2023-06-26 10:16

+ **/ + reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8); + prop.load(reader); Enumeration enumeration = prop.propertyNames(); while (enumeration.hasMoreElements()) { String key = String.valueOf(enumeration.nextElement()); @@ -1222,6 +1228,9 @@ public class Util extends weaver.general.Util { throw new RuntimeException("找不到文件:" + path); } finally { try { + if (reader != null) { + reader.close(); + } if (inputStream != null) { inputStream.close(); } diff --git a/src/main/java/com/api/xuanran/wang/immc/controller/ApiImmcWorkFlowToKafka.java b/src/main/java/com/api/xuanran/wang/immc/controller/ApiImmcWorkFlowToKafka.java new file mode 100644 index 0000000..eaffbf8 --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/immc/controller/ApiImmcWorkFlowToKafka.java @@ -0,0 +1,49 @@ +package com.api.xuanran.wang.immc.controller; + +import aiyh.utils.ApiResult; +import aiyh.utils.Util; +import com.alibaba.fastjson.JSONObject; +import com.api.xuanran.wang.immc.dto.ImmcWorkFlowToKafkaDto; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import org.apache.log4j.Logger; +import weaver.xuanran.wang.immc.service.WorkFlowToVmsAndMQService; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.Map; + +/** + *

智己流程操作下发kafka

+ * + * @author xuanran.wang + * @date 2023/6/21 15:40 + */ +@Path("/wxr/immc/workflow/kafka") +public class ApiImmcWorkFlowToKafka { + + private final Logger log = Util.getLogger(); + + private final WorkFlowToVmsAndMQService service = new WorkFlowToVmsAndMQService(); + + @Path("/del") + @POST + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + public String delWorkFlowToKafka(@Context HttpServletRequest request, + @Context HttpServletResponse response, + @RequestBody ImmcWorkFlowToKafkaDto config){ + try { + log.info("删除流程下发kafka配置对象 : " + JSONObject.toJSONString(config)); +// ImmcWorkFlowToKafkaDto dto = JSONObject.parseObject(JSONObject.toJSONString(config), ImmcWorkFlowToKafkaDto.class); + service.workFlowToKafkaByDto(config); + return ApiResult.successNoData(); + }catch (Exception e){ + log.error("删除流程下发kafka执行失败 : [ " + e.getMessage() + " ]"); + log.error(Util.getErrString(e)); + return ApiResult.error("下发kafka失败! " + e.getMessage()); + } + } +} diff --git a/src/main/java/com/api/xuanran/wang/immc/dto/ImmcWorkFlowToKafkaDto.java b/src/main/java/com/api/xuanran/wang/immc/dto/ImmcWorkFlowToKafkaDto.java new file mode 100644 index 0000000..2d06016 --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/immc/dto/ImmcWorkFlowToKafkaDto.java @@ -0,0 +1,24 @@ +package com.api.xuanran.wang.immc.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + *

vo 智己流程下发kafka

+ * + * @author xuanran.wang + * @date 2023/6/21 16:08 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class ImmcWorkFlowToKafkaDto { + private String onlyMark; + private Integer billTable; + private String config; + private Integer requestId; + private String skip; +} diff --git a/src/main/java/weaver/xuanran/wang/immc/WorkFlowToVmsAndMQ.java b/src/main/java/weaver/xuanran/wang/immc/WorkFlowToVmsAndMQ.java index 0246fb8..0c6ec5d 100644 --- a/src/main/java/weaver/xuanran/wang/immc/WorkFlowToVmsAndMQ.java +++ b/src/main/java/weaver/xuanran/wang/immc/WorkFlowToVmsAndMQ.java @@ -49,6 +49,10 @@ public class WorkFlowToVmsAndMQ extends SafeCusBaseAction { @PrintParamMark @ActionOptionalParam(value = "message", desc = "报错返回信息字段") private String msg; + @PrintParamMark + @ActionOptionalParam(value = "0", desc = "发送mq跳过校验") + private String mqSkip; + @Override public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) { @@ -59,6 +63,6 @@ public class WorkFlowToVmsAndMQ extends SafeCusBaseAction { .successVal(Util.null2DefaultStr(successVal, "200")) .message(Util.null2DefaultStr(msg, "message")) .build(); - workFlowToVmsAndMQService.workFlowToVmsAndMQ(onlyMark, billTable, requestId, vmsResponseVoField, kafkaConfig); + workFlowToVmsAndMQService.workFlowToVmsAndMQ(onlyMark, billTable, requestId, vmsResponseVoField, kafkaConfig, mqSkip); } } diff --git a/src/main/java/weaver/xuanran/wang/immc/entity/CusRequestParam.java b/src/main/java/weaver/xuanran/wang/immc/entity/CusRequestParam.java new file mode 100644 index 0000000..c427a0e --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/immc/entity/CusRequestParam.java @@ -0,0 +1,26 @@ +package weaver.xuanran.wang.immc.entity; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import weaver.conn.RecordSet; + +import java.util.Map; + +/** + *

请求url, 请求参数

+ * + * @author xuanran.wang + * @date 2023/6/21 15:50 + */ +@Setter +@Builder +@AllArgsConstructor +@Getter +public class CusRequestParam { + private String url; + private RecordSet rs; + private Map param; + private String requestId; +} 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 6de58fa..766bb82 100644 --- a/src/main/java/weaver/xuanran/wang/immc/service/WorkFlowToVmsAndMQService.java +++ b/src/main/java/weaver/xuanran/wang/immc/service/WorkFlowToVmsAndMQService.java @@ -6,24 +6,25 @@ import aiyh.utils.httpUtil.ResponeVo; import aiyh.utils.httpUtil.util.HttpUtils; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; -import org.apache.commons.collections.MapUtils; +import com.api.xuanran.wang.immc.dto.ImmcWorkFlowToKafkaDto; import org.apache.commons.lang3.StringUtils; import org.apache.kafka.clients.producer.KafkaProducer; import org.apache.kafka.clients.producer.ProducerRecord; -import org.apache.kafka.clients.producer.RecordMetadata; import org.apache.log4j.Logger; import weaver.conn.RecordSet; import weaver.general.GCONST; import weaver.xiao.commons.config.entity.RequestMappingConfig; import weaver.xiao.commons.config.service.DealWithMapping; import weaver.xuanran.wang.common.util.CommonUtil; +import weaver.xuanran.wang.immc.entity.CusRequestParam; import weaver.xuanran.wang.immc.entity.VmsResponseVoField; import javax.ws.rs.core.MediaType; import java.io.*; +import java.lang.reflect.Field; import java.nio.file.Files; -import java.util.HashMap; import java.util.Map; +import java.util.Objects; import java.util.Properties; /** @@ -42,10 +43,24 @@ public class WorkFlowToVmsAndMQService { // 表单字段 private static final String VMS_SUCCESS = "vms_success"; private static final String SUCCESS = "0"; + + private static final String SKIP = "1"; + { httpUtils.getGlobalCache().header.put("Content-Type", MediaType.APPLICATION_JSON); // 全局请求头 } + /** + *

将流程数据下发到kafka中

+ * @author xuanran.wang + * @dateTime 2023/6/21 16:14 + * @param dto 接口封装对象 + **/ + public void workFlowToKafkaByDto(ImmcWorkFlowToKafkaDto dto){ + this.checkDtoFieldValueNotNull(dto); + this.workFlowToVmsAndMQ(dto.getOnlyMark(), "formtable_main_" + Math.abs(dto.getBillTable()), + String.valueOf(dto.getRequestId()), null, dto.getConfig(), dto.getSkip()); + } /** *

推送数据

@@ -58,19 +73,19 @@ public class WorkFlowToVmsAndMQService { * @author xuanran.wang * @dateTime 2022/12/5 17:05 **/ - public void workFlowToVmsAndMQ(String onlyMark, String billTable, String requestId, VmsResponseVoField vmsResponseVoField, String config) { - RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(onlyMark); // 将配置参数通过唯一标识查询处理成树形结构 - String selectMainSql = CommonUtil.getSelectSql(requestMappingConfig, billTable); - log.info(Util.logStr("查询主表数据sql : {}, requestId : {}", selectMainSql, requestId)); - RecordSet recordSet = new RecordSet(); - recordSet.executeQuery(selectMainSql, requestId); - recordSet.next(); - 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)){ + public void workFlowToVmsAndMQ(String onlyMark, String billTable, + String requestId, VmsResponseVoField vmsResponseVoField, + String config, String skip) { + CusRequestParam requestParam = getRequestParam(onlyMark, billTable, requestId); + if(Objects.isNull(requestParam)){ + return; + } + RecordSet rs = requestParam.getRs(); + Map param = requestParam.getParam(); + String url = requestParam.getUrl(); + String vmsSuccess = Util.null2DefaultStr(rs.getString(VMS_SUCCESS),""); + String mqSuccess = Util.null2DefaultStr(rs.getString(MQ_SUCCESS),""); + if(!SUCCESS.equals(vmsSuccess) && !Objects.isNull(vmsResponseVoField)){ ResponeVo responeVo; try { responeVo = httpUtils.apiPost(url, param); @@ -80,12 +95,61 @@ public class WorkFlowToVmsAndMQService { parseResponseVo(responeVo, url, param, vmsResponseVoField); updateWorkFlow(VMS_SUCCESS, billTable, requestId); } - if(!SUCCESS.equals(mqSuccess) && StringUtils.isNotBlank(config)){ + if((!SUCCESS.equals(mqSuccess) || SKIP.equals(skip)) && StringUtils.isNotBlank(config)){ sendToMQ(config, param); updateWorkFlow(MQ_SUCCESS, billTable, requestId); } } + /** + *

校验对象中字段值是否为空

+ * @author xuanran.wang + * @dateTime 2023/6/21 16:17 + * @param object 对象 + **/ + public void checkDtoFieldValueNotNull(Object object){ + try { + Field[] fields = object.getClass().getDeclaredFields(); + for (Field field : fields) { + field.setAccessible(true); + Object o = field.get(object); + if(Objects.isNull(o)){ + throw new CustomerException("该对象中 " + field.getName() + " 字段值为空!"); + } + } + }catch (Exception e) { + throw new CustomerException("校验对象失败 : [ " + e.getMessage() + " ]", e); + } + } + + /** + *

对发送对数据参数进行封装

+ * @author xuanran.wang + * @dateTime 2023/6/21 15:56 + * @param onlyMark 建模配置唯一标识 + * @param billTable 流程表名 + * @param requestId 请求id + * @return 封装的数据 + **/ + public CusRequestParam getRequestParam(String onlyMark, String billTable, String requestId){ + RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(onlyMark); // 将配置参数通过唯一标识查询处理成树形结构 + if(Objects.isNull(requestMappingConfig)){ + throw new CustomerException("唯一标识为 : " + onlyMark + " ,在参数配置表中没有找到对应的配置!"); + } + String selectMainSql = CommonUtil.getSelectSql(requestMappingConfig, billTable); +// log.info(Util.logStr("查询主表数据sql : {}, requestId : {}", selectMainSql, requestId)); + RecordSet recordSet = new RecordSet(); + if (recordSet.executeQuery(selectMainSql, requestId) && recordSet.next()) { + String url = requestMappingConfig.getRequestUrl(); + dealWithMapping.setMainTable(billTable); + Map param = dealWithMapping.getRequestParam(recordSet, requestMappingConfig); + return CusRequestParam.builder().url(url).rs(recordSet).requestId(requestId).param(param).build(); + }else { + log.error("该流程暂未查到数据! requestId : " + requestId); + return null; + } + } + /** *

解析响应对象

* @author xuanran.wang 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 b6c8e8c..87e1262 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 @@ -3,13 +3,16 @@ package weaver.xuanran.wang.sh_bigdata.common.util; import aiyh.utils.Util; import aiyh.utils.excention.CustomerException; import com.alibaba.fastjson.JSONObject; +import com.icbc.api.internal.apache.http.impl.cookie.S; import lombok.Data; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; +import org.springframework.beans.BeanUtils; import weaver.workflow.request.todo.RequestStatusObj; import weaver.xuanran.wang.common.mapper.CommonMapper; import weaver.xuanran.wang.sh_bigdata.task_async.entity.CusDoneTask; +import weaver.xuanran.wang.sh_bigdata.task_async.entity.CusTodoLeaderTask; import weaver.xuanran.wang.sh_bigdata.task_async.entity.CusTodoTask; import weaver.xuanran.wang.sh_bigdata.task_async.mapper.SendTodoTaskMapper; @@ -63,8 +66,8 @@ public class SendTodoTaskUtil { * @param objs 任务对象 * @return 三方系统任务接收对象 **/ - public List getTodoTaskInfo(List objs){ - ArrayList res = new ArrayList<>(); + public List getTodoTaskInfo(List objs){ + ArrayList res = new ArrayList<>(); for (RequestStatusObj obj : objs) { String taskId = getTaskId(0, obj); CusTodoTask todoTask = new CusTodoTask(); @@ -92,11 +95,44 @@ public class SendTodoTaskUtil { 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))); + // 是否领导待办逻辑处理 + int nodeId = obj.getNodeid(); + String nodeNme = obj.getNodename(); + if(strContainsKey(ShBigDataUtil.getPropertiesValByKey("taskAsyncLeaderNodeId"), String.valueOf(nodeId)) + || strContainsKey(ShBigDataUtil.getPropertiesValByKey("taskAsyncLeaderNodeName"), nodeNme)){ + CusTodoLeaderTask leaderTask = new CusTodoLeaderTask(); + // 进行数据拷贝 + BeanUtils.copyProperties(todoTask, leaderTask); + leaderTask.setLeader(Util.null2DefaultStr(ShBigDataUtil.getPropertiesValByKey("taskAsyncLeaderValue"),"1")); + res.add(leaderTask); + continue; + } res.add(todoTask); } return res; } + /** + *

判断字符串中是否含有指定字符

+ * @author xuanran.wang + * @dateTime 2023/6/25 13:24 + * @param str 字符串 + * @param key 标识 + * @return true/false + **/ + public static boolean strContainsKey(String str, String key){ + return StringUtils.isNotBlank(str) && Arrays.asList(str.split(",")).contains(key); + } + + /** + *

参数拼接

+ * @author xuanran.wang + * @dateTime 2023/6/25 13:22 + * @param sb stringBuilder + * @param userId 用户id + * @param requestId 请求id + * @return 进行字符串拼接 + **/ public static StringBuilder appendParam(StringBuilder sb, int userId, int requestId){ sb.append("?user=") .append(userId) 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 88d217c..cc506fc 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 @@ -20,7 +20,7 @@ import java.util.stream.Collectors; public class ShBigDataUtil { private static final String CONFIG_NAME = "ShBigdataConf"; - + // 白名单 private static final List WHILTE_LIST = new ArrayList<>(); static { @@ -40,6 +40,10 @@ public class ShBigDataUtil { WHILTE_LIST.add("pcAgentId"); // pc回调地址 WHILTE_LIST.add("todoPcSSOCallBackUrl"); + // 统一待办推送领导节点id + WHILTE_LIST.add("taskAsyncLeaderNodeId"); + // 统一待办推送领导节点名称 + WHILTE_LIST.add("taskAsyncLeaderNodeName"); } /** diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/entity/CusTodoLeaderTask.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/entity/CusTodoLeaderTask.java new file mode 100644 index 0000000..bb2c8db --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/entity/CusTodoLeaderTask.java @@ -0,0 +1,17 @@ +package weaver.xuanran.wang.sh_bigdata.task_async.entity; + +import lombok.*; + +/** + *

领导待办计划任务

+ * + * @author xuanran.wang + * @date 2023/6/25 10:50 + */ +@EqualsAndHashCode(callSuper = true) +@Data +@AllArgsConstructor +@NoArgsConstructor +public class CusTodoLeaderTask extends CusTodoTask{ + private String leader; +} diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/service/impl/SendTodoTaskServiceImpl.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/service/impl/SendTodoTaskServiceImpl.java index 0fc232c..9727bb5 100644 --- a/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/service/impl/SendTodoTaskServiceImpl.java +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/service/impl/SendTodoTaskServiceImpl.java @@ -61,7 +61,7 @@ public class SendTodoTaskServiceImpl implements SendTodoTaskService { .dataKey("") .build(); - List taskInfo = sendTodoTaskUtil.getTodoTaskInfo(todoList); + List taskInfo = sendTodoTaskUtil.getTodoTaskInfo(todoList); log.info("---------------- todoTaskInfo ---------------- \n" + JSONObject.toJSONString(taskInfo)); Map response = null; int success = 0; @@ -74,8 +74,8 @@ public class SendTodoTaskServiceImpl implements SendTodoTaskService { success = 1; } ArrayList details = new ArrayList<>(); - for (CusTodoTask cusTodoTask : taskInfo) { - + for (Object obj : taskInfo) { + CusTodoTask cusTodoTask = (CusTodoTask) obj; CusTodoTaskToOADetail detail = new CusTodoTaskToOADetail(); detail.setTaskNum(cusTodoTask.getTaskNum()); detail.setRequestUrl(addTodoTaskUrl); diff --git a/src/main/resources/WEB-INF/prop/prop2map/ShBigdataConf.properties b/src/main/resources/WEB-INF/prop/prop2map/ShBigdataConf.properties index 7c96873..127bf0b 100644 --- a/src/main/resources/WEB-INF/prop/prop2map/ShBigdataConf.properties +++ b/src/main/resources/WEB-INF/prop/prop2map/ShBigdataConf.properties @@ -59,3 +59,12 @@ ssoOaCompareField= # sso校验时 接口取值字段 ssoInterfaceCompareField= + +# =============== 统一待办推送 =============== +# 统一待办推送领导节点id +taskAsyncLeaderNodeId=1,2 +# 统一待办推送领导节点名称 +taskAsyncLeaderNodeName=节点名1,21212 +# leader字段默认值 +taskAsyncLeaderValue=1 + diff --git a/src/test/java/xuanran/wang/big_data/BigDataTest.java b/src/test/java/xuanran/wang/big_data/BigDataTest.java index f828e71..e164414 100644 --- a/src/test/java/xuanran/wang/big_data/BigDataTest.java +++ b/src/test/java/xuanran/wang/big_data/BigDataTest.java @@ -12,8 +12,11 @@ import org.apache.commons.lang3.StringUtils; import org.junit.Test; import weaver.email.EmailWorkRunnable; import weaver.general.TimeUtil; +import weaver.hrm.User; +import weaver.workflow.request.todo.RequestStatusObj; import weaver.xuanran.wang.common.util.CusInfoToOAUtil; import weaver.xuanran.wang.sh_bigdata.common.entity.CusSuccess; +import weaver.xuanran.wang.sh_bigdata.common.util.SendTodoTaskUtil; import weaver.xuanran.wang.sh_bigdata.common.util.ShBigDataUtil; import weaver.xuanran.wang.sh_bigdata.org_hrm_async.OrganizationHrmSyncFromOtherSys; import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OrgHrmAsyncConfigMain; @@ -22,6 +25,7 @@ import weaver.xuanran.wang.sh_bigdata.org_hrm_async.mapper.OrgHrmAsyncMapper; import weaver.xuanran.wang.sh_bigdata.org_hrm_async.service.OrgHrmAsyncApiService; import weaver.xuanran.wang.sh_bigdata.org_hrm_async.service.impl.OrgHrmAsyncApiServiceImpl; import weaver.xuanran.wang.sh_bigdata.org_hrm_async.service.impl.OrgHrmAsyncServiceImpl; +import weaver.xuanran.wang.sh_bigdata.task_async.entity.CusTodoTask; import java.io.IOException; import java.util.*; @@ -396,4 +400,44 @@ public class BigDataTest extends BaseTest { int id = otherSystemToOAMapper.selectUserIdByOutKey(sql, oaOutKey); log.info("id => " + id); } + + @Test + public void testH(){ + SendTodoTaskUtil taskUtil = new SendTodoTaskUtil(); + List requestStatusObjs = new ArrayList<>(); + RequestStatusObj obj = new RequestStatusObj(); + obj.setNodeid(121212); + obj.setRequestid(1234455); + obj.setUser(new User(1)); + obj.setNodename("节点名1"); + obj.setCreator(new User(1)); + requestStatusObjs.add(obj); + + RequestStatusObj obj2 = new RequestStatusObj(); + obj2.setNodeid(121); + obj2.setRequestid(232432143); + obj2.setUser(new User(1)); + obj2.setNodename("test2"); + obj2.setCreator(new User(1)); + requestStatusObjs.add(obj2); + + List todoTaskInfo = taskUtil.getTodoTaskInfo(requestStatusObjs); + System.out.println("todoTaskInfo : " + JSONObject.toJSONString(todoTaskInfo)); + for (Object todo : todoTaskInfo) { + CusTodoTask cusTodoTask = (CusTodoTask) todo; + System.out.println("cusTodoTask : " + JSONObject.toJSONString(cusTodoTask)); + } + } + @Test + public void testI(){ + String value = ""; + String valueContext = "123"; + Map mainMap = new HashMap<>(); + mainMap.put("requestid","123456"); + String workFlowVal = ""; + value = weaver.general.Util.null2String(valueContext) + .replace("{?requestid}", String.valueOf(mainMap.get("requestid"))) + .replace("{?}", workFlowVal); + System.out.println(value); + } } From 4c2dbb9efd2d994e36f44353910a179683b01b0c Mon Sep 17 00:00:00 2001 From: "youhong.ai" Date: Mon, 26 Jun 2023 10:26:39 +0800 Subject: [PATCH 03/13] =?UTF-8?q?=E4=BF=9D=E6=97=B6=E6=8D=B7=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=E5=8F=82=E6=95=B0=E6=A0=A1=E9=AA=8C=EF=BC=8Cihg?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF=E5=85=83=E7=B4=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- javascript/common/dev.js | 36 +++++ .../youhong.ai/pcn/workflow_code_block.js | 124 +++++++++++++++++- .../java/aiyh/utils/GenerateFileUtil.java | 8 +- src/main/java/aiyh/utils/ScriptUtil.java | 4 +- .../userinfoel/mapper/UserInfoMapper.java | 14 +- .../userinfoel/service/UserInfoService.java | 29 +++- .../impl/CheckWorkflowRequestParamsImpl.java | 2 +- .../util/CheckWorkflowRequestParamsUtil.java | 1 + .../GenerateLoginIdAction.java | 3 - .../PushWorkflowDataToDWFAction.java | 81 ++++++++++++ .../mapper/DynamicCodeMapper.java | 7 +- .../service/DynamicCodeService.java | 25 +++- .../java/youhong/ai/utiltest/GenericTest.java | 4 +- .../java/youhong/ai/utiltest/TestApi.java | 2 +- 14 files changed, 311 insertions(+), 29 deletions(-) create mode 100644 src/main/java/weaver/youhong/ai/pcn/actioin/todwfworkflow/PushWorkflowDataToDWFAction.java diff --git a/javascript/common/dev.js b/javascript/common/dev.js index 67a3756..666912e 100644 --- a/javascript/common/dev.js +++ b/javascript/common/dev.js @@ -9,6 +9,42 @@ const WfForm = { isMobile: () => { // true表示是eMobile、微信、钉钉等移动终端,false代表PC端 }, + /** + * 4.6 函数式自定义渲染表单字段 + * 最低版本要求:KB900190701 + * + * 以函数返回值方式自定义渲染表单字段,支持全部的字段类型,可实现基于原组件追加/复写/重新布局等等 + * + * 建议结合ecode工具,放到模块加载前调用,使用JSX,可实现与表单字段渲染有关的二次开发 + * + * 此接口的优先级高于4.4、4.5,即使用此接口代理的字段,如再使用4.4、4.5会直接无效 + * + * proxyFieldContentComp: function(fieldid,fn) + * @param convertFieldNameToId + * @param customerRender + */ + proxyFieldContentComp(convertFieldNameToId, customerRender = (info, compFn) => { + // console.log("字段id:",info.fieldid); + // console.log("明细行号:",info.rowIndex); + // console.log("字段只读必填属性:",info.viewAttr); + // console.log("字段值:",info.fieldValue); + // //返回自定义渲染的组件 + // return React.createElement("div", {}, ["想怎么玩就怎么玩"]); + // //返回原组件 + // return compFn(); + // //返回基于原组件的复写组件 + // return React.createElement("div", {}, ["前置组件",compFn(),"后置组件"]); + } + ) { + }, + /** + * //如果此接口调用在代码块、custompage等(非模块加载前调用),需强制渲染字段一次 + * WfForm.forceRenderField("field111"); + * @param field + */ + forceRenderField(field) { + + } } WfForm.OPER_SAVE = '保存' WfForm.OPER_SUBMIT = '提交/批准/提交需反馈/不需反馈等' diff --git a/javascript/youhong.ai/pcn/workflow_code_block.js b/javascript/youhong.ai/pcn/workflow_code_block.js index 5dca6db..feae264 100644 --- a/javascript/youhong.ai/pcn/workflow_code_block.js +++ b/javascript/youhong.ai/pcn/workflow_code_block.js @@ -787,4 +787,126 @@ $(() => { } } }) -/* ******************* 年假计算 end ******************* */ \ No newline at end of file +/* ******************* 年假计算 end ******************* */ + + +/* ******************* youhong.ai 明细字段合并主表,序号内容换行展示 start ******************* */ +$(() => { + const config = { + // 明细表 + detail: 'detail_3', + // 明细字段 + detailField: 'jbxxnr', + // 主表字段 + mainField: 'jbxxnr' + } + + function runJs() { + let rowIndexStr = WfForm.getDetailAllRowIndexStr(config.detail); + let rowIndexArr = rowIndexStr.split(","); + let value = "" + rowIndexArr.forEach(item => { + let fieldId = WfForm.convertFieldNameToId(config.detailField, config.detail) + "_" + item + let fieldValue = WfForm.getFieldValue(fieldId); + value += (+item + 1) + "、" + fieldValue + "\n"; + }) + WfForm.changeFieldValue(WfForm.convertFieldNameToId(config.mainField), {value}) + } + + WfForm.registerCheckEvent(WfForm.OPER_SUBMIT, (callback) => { + runJs() + callback() + }) + +}) +/* ******************* youhong.ai 明细字段合并主表,序号内容换行展示 end ******************* */ + + +/* ******************* youhong.ai 取明细行中最早时间的一行,将数据放到主表 start ******************* */ +$(() => { + const config = { + // 明细表 + detail: 'detail_1', + // 映射关系 + mapping: [{ + // 明细表字段 + detailField: 'jbsj', + // 主表字段 + mainField: 'zzjsrq', + }, { + // 明细表字段 + detailField: 'jbtd', + // 主表字段 + mainField: 'jbqd', + }], + dateSort: 'jbsj' + } + + + function runJs() { + let rowIndexStr = WfForm.getDetailAllRowIndexStr(config.detail); + let rowIndexArray = rowIndexStr.split(","); + const detailData = [] + rowIndexArray.forEach(item => { + let obj = {} + config.mapping.forEach(mapping => { + obj[mapping.detailField] = WfForm.getFieldValue(WfForm.convertFieldNameToId(mapping.detailField, config.detail) + "_" + item) + }) + detailData.push(obj) + }) + console.log(detailData) + let minDateObj = filterByMinDate(detailData, config.dateSort); + console.log(minDateObj) + config.mapping.forEach(item => { + WfForm.changeFieldValue(WfForm.convertFieldNameToId(item.mainField), { + value: minDateObj[item.detailField] + }) + }) + } + + function filterByMinDate(arr, key) { + return arr.reduce((min, obj) => { + if (!min || new Date(obj[key]) <= new Date(min[key])) { + return obj; + } + return min; + }, null); + } + + WfForm.registerCheckEvent(WfForm.OPER_SUBMIT, (callback) => { + runJs() + callback() + }) +}) +/* ******************* youhong.ai 取明细行中最早时间的一行,将数据放到主表 end ******************* */ + +/* ******************* youhong.ai 主表选择框自定义渲染为进度条 start ******************* */ +$(() => { + const field = 'jz' + const config = { + '-1': 0, + '0': 20, + '1': 40, + '2': 60, + '3': 80, + '4': 100, + } + + function customerRender(info, compFn) { + let fieldValue = info.fieldValue; + if (!fieldValue) { + fieldValue = '-1' + } + let {WeaProgress} = ecCom + return React.createElement(WeaProgress, { + strokeColor: '#6c8dc1', + percent: config[fieldValue] + }) + } + + WfForm.proxyFieldContentComp(WfForm.convertFieldNameToId(field).replace("field", ""), customerRender) + setTimeout(() => { + WfForm.forceRenderField(WfForm.convertFieldNameToId(field)); + }, 500) +}) +/* ******************* youhong.ai 主表选择框自定义渲染为进度条 end ******************* */ diff --git a/src/main/java/aiyh/utils/GenerateFileUtil.java b/src/main/java/aiyh/utils/GenerateFileUtil.java index 7b8631b..e443f6e 100644 --- a/src/main/java/aiyh/utils/GenerateFileUtil.java +++ b/src/main/java/aiyh/utils/GenerateFileUtil.java @@ -85,10 +85,11 @@ public class GenerateFileUtil { if (hasRequired) { // 必填参数 RequiredMark requiredMark = declaredField.getAnnotation(RequiredMark.class); - String fieldDesc = requiredMark.value(); - Map param = new HashMap<>(); + String fieldDesc = requiredMark.desc(); + Map param = new HashMap<>(8); param.put("name", name); param.put("desc", fieldDesc); + param.put("example", requiredMark.value()); param.put("isRequired", "是"); boolean hasDefaultTestValue = declaredField.isAnnotationPresent(ActionDefaultTestValue.class); if (hasDefaultTestValue) { @@ -105,9 +106,10 @@ public class GenerateFileUtil { ActionOptionalParam actionOptionalParam = declaredField.getAnnotation(ActionOptionalParam.class); String fieldDesc = actionOptionalParam.desc(); String defaultValue = actionOptionalParam.value(); - Map param = new HashMap<>(); + Map param = new HashMap<>(8); param.put("name", name); param.put("desc", fieldDesc); + param.put("example", defaultValue); param.put("isRequired", "否"); param.put("defaultValue", defaultValue); paramList.add(param); diff --git a/src/main/java/aiyh/utils/ScriptUtil.java b/src/main/java/aiyh/utils/ScriptUtil.java index 7f6cbd1..6c53d1d 100644 --- a/src/main/java/aiyh/utils/ScriptUtil.java +++ b/src/main/java/aiyh/utils/ScriptUtil.java @@ -12,14 +12,14 @@ import java.util.Map; * @author youHong.ai */ public class ScriptUtil { - private static final JexlEngine jexl = new JexlBuilder().create(); + private static final JexlEngine JEXL = new JexlBuilder().create(); public static Object invokeScript(String script, Map params) { JexlContext jc = new MapContext(); for (Map.Entry entry : params.entrySet()) { jc.set(entry.getKey(), entry.getValue()); } - JexlExpression expression = jexl.createExpression(script); + JexlExpression expression = JEXL.createExpression(script); return expression.evaluate(jc); } } diff --git a/src/main/java/com/api/youhong/ai/ihgzhouji/userinfoel/mapper/UserInfoMapper.java b/src/main/java/com/api/youhong/ai/ihgzhouji/userinfoel/mapper/UserInfoMapper.java index 6767fc8..f149ea3 100644 --- a/src/main/java/com/api/youhong/ai/ihgzhouji/userinfoel/mapper/UserInfoMapper.java +++ b/src/main/java/com/api/youhong/ai/ihgzhouji/userinfoel/mapper/UserInfoMapper.java @@ -44,7 +44,7 @@ public interface UserInfoMapper { "or concat(',',fbleader,',') like concat(',',#{uID},',')\n" + "or concat(',',hrleader,',') like concat(',',#{uID},',')\n" + "or concat(',',generalmanager,',') like concat(',', #{uID},',')")*/ - @Select("select count(id) from uf_hotelinfo where\n" + + @Select("select * from uf_hotelinfo where\n" + "concat(',',olt,',') like concat(',',#{userId},',')\n" + "or concat(',',vpo,',') like concat(',',#{userId},',')\n" + "or concat(',',opsconsultant,',') like concat(',',#{userId},',')\n" + @@ -61,7 +61,7 @@ public interface UserInfoMapper { "or concat(',',headoffinancebusinesssupport,',') like concat(',',#{userId},',')\n" + "or concat(',',headofrbeoperations,',') like concat(',',#{userId},',')\n" + "or concat(',',headofengineering,',') like concat(',',#{userId},',')") - Integer selectIsHotel(int uid); + List> selectIsHotel(int uid); /** *

查询酒店信息

@@ -85,12 +85,11 @@ public interface UserInfoMapper { /** *

查询角色信息

* - * @param uid 当前人员 - * @param hotelIndex 酒店编码 + * @param uid 当前人员 * @return 角色信息 */ @Select("select * from uf_hotelinfo where\n" + - "(concat(',',olt,',') like concat(',',#{userId},',')\n" + + "concat(',',olt,',') like concat(',',#{userId},',')\n" + "or concat(',',vpo,',') like concat(',',#{userId},',')\n" + "or concat(',',subregionadmin,',') like concat(',',#{userId},',')\n" + "or concat(',',opsconsultant,',') like concat(',',#{userId},',')\n" + @@ -112,9 +111,8 @@ public interface UserInfoMapper { "or concat(',',revenueleader,',') like concat(',',#{userId},',')\n" + "or concat(',',financeleader,',') like concat(',',#{userId},',')\n" + "or concat(',',fbleader,',') like concat(',',#{userId},',')\n" + - "or concat(',',hrleader,',') like concat(',',#{userId},',')) " + - "and holidex = #{hotelIndex}") - List> selectRoles(@ParamMapper("userId") int uid, @ParamMapper("hotelIndex") String hotelIndex); + "or concat(',',hrleader,',') like concat(',',#{userId},',')") + List> selectRoles(@ParamMapper("userId") int uid); /** *

查询部门信息

diff --git a/src/main/java/com/api/youhong/ai/ihgzhouji/userinfoel/service/UserInfoService.java b/src/main/java/com/api/youhong/ai/ihgzhouji/userinfoel/service/UserInfoService.java index 6f360fd..2aa4961 100644 --- a/src/main/java/com/api/youhong/ai/ihgzhouji/userinfoel/service/UserInfoService.java +++ b/src/main/java/com/api/youhong/ai/ihgzhouji/userinfoel/service/UserInfoService.java @@ -43,7 +43,6 @@ public class UserInfoService { userInfoVo.setTaskAcceptance(true); } } - // 查询用户信息 Map userInfo = this.mapper.selectHrmInfo(user.getUID()); if (CollectionUtil.isNotEmpty(userInfo)) { @@ -70,8 +69,32 @@ public class UserInfoService { // 支持中心,显示部门信息 userInfoVo.setDepartmentInfo(department); } + List> hotelList = mapper.selectRoles(user.getUID()); // 如果存在酒店信息 - if (StrUtil.isNotBlank(hotelIndex)) { + Set roleNames = new HashSet<>(); + if (CollectionUtil.isNotEmpty(hotelList)) { + for (Map hotel : hotelList) { + // 循环酒店角色名称 + for (Map.Entry entry : ROLES_MAP.entrySet()) { + String key = entry.getKey(); + if (!hotel.containsKey(key)) { + continue; + } + String value = Util.null2String(hotel.get(key)); + // 如果在酒店名称中找到对应的人,则为角色名 + if (StrUtil.isBlank(value)) { + continue; + } + String[] split = value.split(","); + List strings = Arrays.asList(split); + if (strings.contains(Util.null2String(user.getUID()))) { + roleNames.add(entry.getValue()); + } + } + } + } + userInfoVo.setRoleNames(roleNames); + /*if (StrUtil.isNotBlank(hotelIndex)) { List> hotelRoles = this.mapper.selectRoles(user.getUID(), hotelIndex); if (CollectionUtil.isEmpty(hotelRoles)) { return userInfoVo; @@ -98,7 +121,7 @@ public class UserInfoService { } } userInfoVo.setRoleNames(roleNames); - } + }*/ } return userInfoVo; } diff --git a/src/main/java/com/customization/youhong/pcn/createrworkflow/impl/CheckWorkflowRequestParamsImpl.java b/src/main/java/com/customization/youhong/pcn/createrworkflow/impl/CheckWorkflowRequestParamsImpl.java index d1012aa..6e8f413 100644 --- a/src/main/java/com/customization/youhong/pcn/createrworkflow/impl/CheckWorkflowRequestParamsImpl.java +++ b/src/main/java/com/customization/youhong/pcn/createrworkflow/impl/CheckWorkflowRequestParamsImpl.java @@ -36,7 +36,7 @@ public class CheckWorkflowRequestParamsImpl extends AbstractServiceProxy impleme private final CheckWorkflowRequestParamsUtil checkUtil = new CheckWorkflowRequestParamsUtil(); @Override - @ServiceMethodDynamicProxy(desc = "子流程触发时,做流程转数据") + @ServiceMethodDynamicProxy(desc = "流程创建校验流程参数") public PAResponseEntity doCreateRequest(User user, ReqOperateRequestEntity requestParam) { try { try { diff --git a/src/main/java/com/customization/youhong/pcn/createrworkflow/util/CheckWorkflowRequestParamsUtil.java b/src/main/java/com/customization/youhong/pcn/createrworkflow/util/CheckWorkflowRequestParamsUtil.java index 8165b72..a710693 100644 --- a/src/main/java/com/customization/youhong/pcn/createrworkflow/util/CheckWorkflowRequestParamsUtil.java +++ b/src/main/java/com/customization/youhong/pcn/createrworkflow/util/CheckWorkflowRequestParamsUtil.java @@ -133,6 +133,7 @@ public class CheckWorkflowRequestParamsUtil { if (Objects.isNull(checkCreateConfigDetail)) { continue; } + // TODO 主表明细表字段一致可能出现问题 checkDetailMap.remove(fieldName); CheckFunctionParam checkFunctionParam = new CheckFunctionParam(); checkFunctionParam.setCheckCreateConfigDetail(checkCreateConfigDetail); diff --git a/src/main/java/weaver/youhong/ai/pcn/actioin/generateloginid/GenerateLoginIdAction.java b/src/main/java/weaver/youhong/ai/pcn/actioin/generateloginid/GenerateLoginIdAction.java index 8a0b35f..53f5298 100644 --- a/src/main/java/weaver/youhong/ai/pcn/actioin/generateloginid/GenerateLoginIdAction.java +++ b/src/main/java/weaver/youhong/ai/pcn/actioin/generateloginid/GenerateLoginIdAction.java @@ -58,9 +58,6 @@ public class GenerateLoginIdAction extends SafeCusBaseAction { Map mainTableValue = super.getMainTableValue(requestInfo); String subCompanyName = mainTableValue.get(subCompanyTextField); String subCompanyId = mapper.selectSubCompanyIdBySubCompanyName(subCompanyName); - // Map lastLoginIdInfo = mapper.selectLastLoginId(subCompanyName, subCompanyId, subCompanyName + "%"); - // String loginIdNo = lastLoginIdInfo.get("loginIdNo"); - // String loginId = prefixFill(loginIdNo, subCompanyName); List loginIdList = mapper.selectLoginIdList(subCompanyId); String loginId = subCompanyName + formatList(loginIdList, Integer.parseInt(numberFillQuantity)); if (mapper.updateLoginId(billTable, requestId, loginId, loginIdField)) { diff --git a/src/main/java/weaver/youhong/ai/pcn/actioin/todwfworkflow/PushWorkflowDataToDWFAction.java b/src/main/java/weaver/youhong/ai/pcn/actioin/todwfworkflow/PushWorkflowDataToDWFAction.java new file mode 100644 index 0000000..af4845f --- /dev/null +++ b/src/main/java/weaver/youhong/ai/pcn/actioin/todwfworkflow/PushWorkflowDataToDWFAction.java @@ -0,0 +1,81 @@ +package weaver.youhong.ai.pcn.actioin.todwfworkflow; + +import aiyh.utils.Util; +import aiyh.utils.action.SafeCusBaseAction; +import aiyh.utils.annotation.ActionDesc; +import aiyh.utils.annotation.ActionOptionalParam; +import aiyh.utils.annotation.RequiredMark; +import aiyh.utils.httpUtil.ResponeVo; +import aiyh.utils.httpUtil.util.HttpUtils; +import lombok.Getter; +import lombok.Setter; +import weaver.hrm.User; +import weaver.soa.workflow.request.RequestInfo; +import weaver.xiao.commons.config.entity.RequestMappingConfig; +import weaver.xiao.commons.config.service.DealWithMapping; + +import javax.ws.rs.core.MediaType; +import java.io.IOException; +import java.util.Map; + +/** + *

推送流程数据到dwf

+ * + *

create: 2023/6/25 21:56

+ * + * @author youHong.ai + */ +@Setter +@Getter +@ActionDesc(author = "youhong.ai", value = "推送流程数据到dwf") +public class PushWorkflowDataToDWFAction extends SafeCusBaseAction { + + @RequiredMark(desc = "请求参数配置表的唯一标识") + private String onlyMark; + + + @ActionOptionalParam(desc = "流程失败是否退回", value = "true") + private String isBlack = "true"; + + + @ActionOptionalParam(desc = "成功标识", value = "200") + private String successCode = "200"; + + + private final HttpUtils httpUtils = new HttpUtils(); + + private final DealWithMapping dealWithMapping = new DealWithMapping(); + + + { + httpUtils.getGlobalCache().header.put("Content-Type", MediaType.APPLICATION_JSON); + } + + @Override + public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) { + dealWithMapping.setMainTable(billTable); + try { + RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(onlyMark); + String requestUrl = requestMappingConfig.getRequestUrl(); + Map objMainTableValue = getObjMainTableValue(requestInfo); + Map requestParam = dealWithMapping.getRequestParam(objMainTableValue, requestMappingConfig); + ResponeVo responeVo = httpUtils.apiPost(requestUrl, requestParam); + if (responeVo.getCode() != 200) { + log.error(Util.logStr("接口请求出错:[]", responeVo.getEntityString())); + } + Map responseMap = responeVo.getResponseMap(); + String code = Util.null2String(responseMap.get("code")); + if (!successCode.equals(code)) { + black(requestInfo, Util.null2String(responseMap.get("msg"))); + } + } catch (IOException e) { + black(requestInfo, "system error!"); + } + } + + private void black(RequestInfo requestInfo, String msg) { + if (Boolean.parseBoolean(isBlack)) { + Util.actionFailException(requestInfo.getRequestManager(), msg); + } + } +} diff --git a/src/main/youhong_ai_old_src/com/api/aiyh_logincheck/mapper/DynamicCodeMapper.java b/src/main/youhong_ai_old_src/com/api/aiyh_logincheck/mapper/DynamicCodeMapper.java index e4291f8..5f8716e 100644 --- a/src/main/youhong_ai_old_src/com/api/aiyh_logincheck/mapper/DynamicCodeMapper.java +++ b/src/main/youhong_ai_old_src/com/api/aiyh_logincheck/mapper/DynamicCodeMapper.java @@ -4,6 +4,8 @@ import aiyh.utils.annotation.recordset.ParamMapper; import aiyh.utils.annotation.recordset.Select; import aiyh.utils.annotation.recordset.SqlMapper; +import java.util.Map; + /** * create 2022/1/17 0017 16:57 * @@ -14,7 +16,7 @@ import aiyh.utils.annotation.recordset.SqlMapper; public interface DynamicCodeMapper { @Select("select email from hrmresource where loginid = #{loginId}") - public String selectEmail(@ParamMapper("loginId") String loginId); + String selectEmail(@ParamMapper("loginId") String loginId); /** *

查询用户

@@ -26,4 +28,7 @@ public interface DynamicCodeMapper { @Select("select id from hrmresource where loginid = #{loginId} and password = #{password}") Integer selectUser(@ParamMapper("loginId") String user, @ParamMapper("password") String mdPassword); + + @Select("select id,lastname,loginid,isadaccount from hrmresource where loginid = #{loginId}") + Map selectUserInfo(@ParamMapper("loginId") String user); } diff --git a/src/main/youhong_ai_old_src/com/api/aiyh_logincheck/service/DynamicCodeService.java b/src/main/youhong_ai_old_src/com/api/aiyh_logincheck/service/DynamicCodeService.java index 9058784..293ea99 100644 --- a/src/main/youhong_ai_old_src/com/api/aiyh_logincheck/service/DynamicCodeService.java +++ b/src/main/youhong_ai_old_src/com/api/aiyh_logincheck/service/DynamicCodeService.java @@ -2,6 +2,7 @@ package com.api.aiyh_logincheck.service; import aiyh.utils.Util; import aiyh.utils.excention.CustomerException; +import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil; import aiyh.utils.zwl.common.ToolUtil; import cn.hutool.core.util.RandomUtil; import com.alibaba.fastjson.JSON; @@ -15,6 +16,7 @@ import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import weaver.email.EmailWorkRunnable; import weaver.general.BaseBean; +import weaver.ldap.LdapUtil; import weaver.sm.SM4Utils; import javax.servlet.ServletContext; @@ -122,10 +124,25 @@ public class DynamicCodeService { password = sm4.decrypt(password, key); } } - String mdPassword = EncryptHelper.encodeMd5(password).toUpperCase(); - Integer userId = dynamicCodeMapper.selectUser(user, mdPassword); - if (Objects.isNull(userId) || userId < 0) { - throw new CustomerException("账号或密码错误!", 403); + // 校验AD登录 + Map userInfoMap = dynamicCodeMapper.selectUserInfo(user); + if (CollectionUtil.isNotEmpty(userInfoMap) && "1".equals(Util.null2String(userInfoMap.get("isadaccount")))) { + LdapUtil util = LdapUtil.getInstance(); + String authenticResult = util.authenticuser(user); + if (authenticResult == null || "uac".equals(authenticResult)) { + throw new CustomerException("AD账号不存在或被禁用!", 403); + } + boolean flag; + flag = util.authentic(user, password); + if (!flag) { + throw new CustomerException("账号或密码错误!", 403); + } + } else { + String mdPassword = EncryptHelper.encodeMd5(password).toUpperCase(); + Integer userId = dynamicCodeMapper.selectUser(user, mdPassword); + if (Objects.isNull(userId) || userId < 0) { + throw new CustomerException("账号或密码错误!", 403); + } } String uncheckList = toolUtil.getSystemParamValue("uncheckList"); String isEnable = toolUtil.getSystemParamValue("enableDynamicCode"); diff --git a/src/test/java/youhong/ai/utiltest/GenericTest.java b/src/test/java/youhong/ai/utiltest/GenericTest.java index b567c20..285f650 100644 --- a/src/test/java/youhong/ai/utiltest/GenericTest.java +++ b/src/test/java/youhong/ai/utiltest/GenericTest.java @@ -12,7 +12,7 @@ import org.apache.poi.xssf.streaming.SXSSFRow; import org.apache.poi.xssf.streaming.SXSSFSheet; import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.junit.Test; -import weaver.youhong.ai.pcn.actioin.doctoavatar.DocToAvatarAction; +import weaver.youhong.ai.pcn.actioin.todwfworkflow.PushWorkflowDataToDWFAction; import youhong.ai.utiltest.excel.ExcelCell; import youhong.ai.utiltest.excel.ExcelPort; import youhong.ai.utiltest.excel.ExcelRow; @@ -98,7 +98,7 @@ public class GenericTest extends BaseTest { @Test public void testGre() { - GenerateFileUtil.createActionDocument(DocToAvatarAction.class); + GenerateFileUtil.createActionDocument(PushWorkflowDataToDWFAction.class); } diff --git a/src/test/java/youhong/ai/utiltest/TestApi.java b/src/test/java/youhong/ai/utiltest/TestApi.java index 8c33456..5781bcc 100644 --- a/src/test/java/youhong/ai/utiltest/TestApi.java +++ b/src/test/java/youhong/ai/utiltest/TestApi.java @@ -63,7 +63,7 @@ public class TestApi extends BaseTest { "\t\"fieldValue\":\"5\"\n" + "},{\n" + "\t\"fieldName\":\"mc\",\n" + - "\t\"fieldValue\":\"不1道\"\n" + + "\t\"fieldValue\":\"不道\"\n" + "}]"); body.put("requestName", "api流程测试调用接口校验参数"); body.put("workflowId", "44"); From 9ad2ce794383a44fc91e8997128c99556f01d301 Mon Sep 17 00:00:00 2001 From: "jingwei.tao" <1249074319@qq.com> Date: Wed, 28 Jun 2023 17:41:19 +0800 Subject: [PATCH 04/13] shanchu time util --- .../utils/ecologyutil/timeutil/TimeUtil.java | 68 ------------------- 1 file changed, 68 deletions(-) delete mode 100644 src/main/java/aiyh/utils/ecologyutil/timeutil/TimeUtil.java diff --git a/src/main/java/aiyh/utils/ecologyutil/timeutil/TimeUtil.java b/src/main/java/aiyh/utils/ecologyutil/timeutil/TimeUtil.java deleted file mode 100644 index 840d0e2..0000000 --- a/src/main/java/aiyh/utils/ecologyutil/timeutil/TimeUtil.java +++ /dev/null @@ -1,68 +0,0 @@ -package aiyh.utils.ecologyutil.rightutil; - -import aiyh.utils.Util; -import aiyh.utils.httpUtil.cushttpclasses.CusHttpServletRequest; -import aiyh.utils.httpUtil.cushttpclasses.CusHttpSession; -import com.alibaba.fastjson.JSONObject; -import com.engine.hrm.cmd.permissiontoadjust.ProcessDataCmd; -import org.apache.log4j.Logger; -import weaver.hrm.User; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; -import java.util.HashMap; -import java.util.Map; - - -/** - * ecology权限相关方法 - * - */ -public class RightMoveUtil { - - private static Logger logger = Util.getLogger(); - - /** - * 触发标准权限转移 转移待办已办等信息 - * @param param 入参按需填写如下等参数 - * fromid - * toid - * T133All - * T133AllNum - * @return - */ - public static JSONObject moveRight(JSONObject param){ - JSONObject result = new JSONObject(); - try{ - logger.info("RightMoveUtil moveRight begin;param:" + param.toJSONString()); - Map params = new HashMap<>(); - for(Object key : param.keySet()){ - params.put(key.toString(),param.get(key)); - } - HttpServletRequest request = new CusHttpServletRequest(){ - @Override - public String getParameter(String s) { - return param.getString(s); - } - @Override - public HttpSession getSession(boolean b) { - HttpSession session = new CusHttpSession(){ - @Override - public Object getAttribute(String s) { - return new User(1); - } - }; - return session; - } - }; - ProcessDataCmd cmd = new ProcessDataCmd(params,request,new User(1)); - Map execute = cmd.execute(null); - result = new JSONObject(execute); - logger.info("RightMoveUtil moveRight end;result:" + execute.toString()); - return result; - }catch (Throwable e){ - logger.error("RightMoveUtil moveRight error;message:" + e.getMessage()); - return result; - } - } - -} \ No newline at end of file From 47c31b05b5958e2ab61f00f08cff94685974b0ae Mon Sep 17 00:00:00 2001 From: "youhong.ai" Date: Thu, 29 Jun 2023 14:57:22 +0800 Subject: [PATCH 05/13] =?UTF-8?q?=E4=BF=9D=E6=97=B6=E6=8D=B7=E6=8F=90?= =?UTF-8?q?=E4=BE=9B=E6=96=87=E4=BB=B6=E4=B8=8B=E8=BD=BD=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=94=B9=E8=AF=B7=E6=B1=82=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E6=96=B9=E6=B3=95public?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../taibao/建模打包带数据到指定明细.js | 120 ++++++- src/main/java/aiyh/utils/Util.java | 2 +- .../aiyh/utils/httpUtil/util/HttpUtils.java | 8 +- .../aiyh/utils/recordset/ResultMapper.java | 69 ++-- .../service/BatchCreateWorkflowService.java | 336 +++++++++--------- .../contoller/TaskElementController.java | 1 + .../taskele/mapper/TaskElementMapper.java | 18 + .../taskele/service/TaskElementService.java | 52 ++- .../controller/DownloadFileController.java | 40 +++ .../download/service/DownloadFileService.java | 67 ++++ .../service/EncryptionFileIdUtil.java | 70 ++++ .../controller/CheckNumberController.java | 41 +++ .../checknumber/mapper/CheckNumberMapper.java | 29 ++ .../service/CheckNumberService.java | 31 ++ .../impl/CheckWorkflowRequestParamsImpl.java | 2 - .../util/CheckWorkflowRequestParamsUtil.java | 3 + .../cusgetdata/FileLinkListGetImpl.java | 46 +++ src/test/java/youhong/ai/pcn/Test01.java | 13 + .../java/youhong/ai/utiltest/OtherTest.java | 22 ++ .../ai/utiltest/ShortEncryptionExample.java | 63 ++++ 20 files changed, 835 insertions(+), 198 deletions(-) create mode 100644 src/main/java/com/api/youhong/ai/pcn/download/controller/DownloadFileController.java create mode 100644 src/main/java/com/api/youhong/ai/pcn/download/service/DownloadFileService.java create mode 100644 src/main/java/com/api/youhong/ai/pcn/download/service/EncryptionFileIdUtil.java create mode 100644 src/main/java/com/api/youhong/ai/taibao/checknumber/controller/CheckNumberController.java create mode 100644 src/main/java/com/api/youhong/ai/taibao/checknumber/mapper/CheckNumberMapper.java create mode 100644 src/main/java/com/api/youhong/ai/taibao/checknumber/service/CheckNumberService.java create mode 100644 src/main/java/weaver/youhong/ai/pcn/actioin/todwfworkflow/cusgetdata/FileLinkListGetImpl.java create mode 100644 src/test/java/youhong/ai/utiltest/OtherTest.java create mode 100644 src/test/java/youhong/ai/utiltest/ShortEncryptionExample.java diff --git a/javascript/youhong.ai/taibao/建模打包带数据到指定明细.js b/javascript/youhong.ai/taibao/建模打包带数据到指定明细.js index 75e2a2c..2467d65 100644 --- a/javascript/youhong.ai/taibao/建模打包带数据到指定明细.js +++ b/javascript/youhong.ai/taibao/建模打包带数据到指定明细.js @@ -106,4 +106,122 @@ $(() => { }) -/* ******************* youhong.ai 流程部分 end ******************* */ \ No newline at end of file +/* ******************* youhong.ai 流程部分 end ******************* */ + + +/* ******************* youhong.ai 编号验证是否存在 start ******************* */ +$(() => { + const config = { + ecId: '', + tableName: '', + field: 'fwbh', + } + + /** + * @author youhong.ai + * @desc 发起请求 + */ + function api(requestOptions = { + url: "", + type: "GET", + data: "", + isAsync: true, + success: () => { + }, + error: () => { + }, + complete: () => { + }, + contentType: 'application/json', + beforeSend: () => { + } + }) { + let options = Object.assign({ + url: "", + type: "GET", + data: "", + isAsync: true, + success: () => { + }, + error: () => { + }, + complete: () => { + }, + contentType: 'application/json', + beforeSend: () => { + } + }, requestOptions) + return $.ajax(options) + } + + function findReact(dom, traverseUp = 0) { + const key = Object.keys(dom).find(key => { + return key.startsWith("__reactFiber$") // react 17+ + || key.startsWith("__reactInternalInstance$") + || key.startsWith("__reactEventHandlers$"); // react <17 + }); + const domFiber = dom[key]; + if (domFiber == null) return null; + // react <16 + if (domFiber._currentElement) { + let compFiber = domFiber._currentElement._owner; + for (let i = 0; i < traverseUp; i++) { + compFiber = compFiber._currentElement._owner; + } + return compFiber._instance; + } + // react 16+ + const GetCompFiber = fiber => { + let parentFiber = fiber.return; + while (typeof parentFiber.type == "string") { + parentFiber = parentFiber.return; + } + return parentFiber; + }; + let compFiber = GetCompFiber(domFiber); + for (let i = 0; i < traverseUp; i++) { + compFiber = GetCompFiber(compFiber); + } + return compFiber.stateNode; + } + + function runJs() { + let node = findReact($(`button[ecid='${config.ecId}']`)[0]) + let baseInfo = WfForm.getBaseInfo(); + baseInfo.workflowid + if (baseInfo.requestid == -1) { + return + } + if (node) { + let click = node.props.onClick; + node.props.onClick = (e) => { + api({ + url: `/api/aiyh/taibao/bh/check-number?tableName=${config.tableName}&field=${config.field}&requestId=${baseInfo.requestid}`, + success(res) { + if (res && res.code == 200) { + if (res.data) { + // 存在编号,提示是否需要编号 + WfForm.showConfirm("编号一存在,是否重新编号?", function () { + click(e) + }, function () { + // 不重新编号,刷新 + window.location.reload() + }, { + title: "编号确认", //弹确认框的title,仅PC端有效 + okText: "确认", //自定义确认按钮名称 + cancelText: "取消" //自定义取消按钮名称 + }); + } else { + click(e) + } + } + } + }) + }; + } + + } + + runJs() +}) +/* ******************* youhong.ai 编号验证是否存在 end ******************* */ diff --git a/src/main/java/aiyh/utils/Util.java b/src/main/java/aiyh/utils/Util.java index 72856e1..357e947 100644 --- a/src/main/java/aiyh/utils/Util.java +++ b/src/main/java/aiyh/utils/Util.java @@ -244,7 +244,7 @@ public class Util extends weaver.general.Util { str = str.substring(0, str.length() - 1); } if (str.trim().startsWith(removeSeparator)) { - str = str.substring(1); + str = str.substring(removeSeparator.length()); } return str; } diff --git a/src/main/java/aiyh/utils/httpUtil/util/HttpUtils.java b/src/main/java/aiyh/utils/httpUtil/util/HttpUtils.java index 77ea7c8..3f76b9f 100644 --- a/src/main/java/aiyh/utils/httpUtil/util/HttpUtils.java +++ b/src/main/java/aiyh/utils/httpUtil/util/HttpUtils.java @@ -121,7 +121,7 @@ public class HttpUtils { return getUrl; } - private static String serializeParams(Map params) { + public static String serializeParams(Map params) { if (params != null && params.size() > 0) { StringBuilder builder = new StringBuilder(); for (Map.Entry entry : params.entrySet()) { @@ -1113,6 +1113,9 @@ public class HttpUtils { } private boolean isBean(Object o) { + if (Objects.isNull(o)) { + return false; + } if (o instanceof Number) { return false; } @@ -1122,9 +1125,6 @@ public class HttpUtils { if (o instanceof Boolean) { return false; } - if (Objects.isNull(o)) { - return false; - } return !o.getClass().isPrimitive(); } diff --git a/src/main/java/aiyh/utils/recordset/ResultMapper.java b/src/main/java/aiyh/utils/recordset/ResultMapper.java index c5305cf..5b7ca54 100644 --- a/src/main/java/aiyh/utils/recordset/ResultMapper.java +++ b/src/main/java/aiyh/utils/recordset/ResultMapper.java @@ -336,18 +336,18 @@ public class ResultMapper { if ("FLOAT".equalsIgnoreCase(columnType) || "DOUBLE".equalsIgnoreCase(columnType) || "DECIMAL".equalsIgnoreCase(columnType)) { if (Objects.nonNull(toLowerCase)) { - ((Map) o).put(columnName[i].toLowerCase(), rs.getFloat(i + 1)); + ((Map) o).put(columnName[i].toLowerCase(), rs.getString(i + 1)); } else { if (enable) { - ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getFloat(i + 1)); + ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1)); continue; } if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) { - ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getFloat(i + 1)); + ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1)); } - ((Map) o).put(columnName[i].toLowerCase(), rs.getFloat(i + 1)); - ((Map) o).put(columnName[i].toUpperCase(), rs.getFloat(i + 1)); - ((Map) o).put(columnName[i], rs.getFloat(i + 1)); + ((Map) o).put(columnName[i].toLowerCase(), rs.getString(i + 1)); + ((Map) o).put(columnName[i].toUpperCase(), rs.getString(i + 1)); + ((Map) o).put(columnName[i], rs.getString(i + 1)); } continue; } @@ -475,39 +475,58 @@ public class ResultMapper { } else { columnType = columnTypeName[i]; } + String value = rs.getString(i + 1); + String valueCloumn = rs.getString(columnName[i]); if ("int".equalsIgnoreCase(columnType) || "long".equalsIgnoreCase(columnType) || "number".equalsIgnoreCase(columnType) || "MEDIUMINT".equalsIgnoreCase(columnType) || "TINYINT".equalsIgnoreCase(columnType) || "SMALLINT".equalsIgnoreCase(columnType) || "BIGINT".equalsIgnoreCase(columnType) || "INTEGER".equalsIgnoreCase(columnType)) { - if (Objects.nonNull(toLowerCase)) { - ((Map) o).put(columnName[i].toLowerCase(), rs.getInt(i + 1)); + try { + ((Map) o).put(columnName[i].toLowerCase(), Integer.parseInt(value)); + } catch (Exception e) { + ((Map) o).put(columnName[i].toLowerCase(), value); + } } else { if (enable) { - ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getInt(columnName[i])); + try { + ((Map) o).put(Util.toCamelCase(columnName[i]), Integer.parseInt(valueCloumn)); + } catch (Exception e) { + ((Map) o).put(Util.toCamelCase(columnName[i]), valueCloumn); + } continue; } if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) { - ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getInt(i + 1)); + try { + ((Map) o).put(Util.toCamelCase(columnName[i]), Integer.parseInt(value)); + } catch (Exception e) { + ((Map) o).put(Util.toCamelCase(columnName[i]), value); + } + } + try { + ((Map) o).put(columnName[i].toLowerCase(), Integer.parseInt(value)); + ((Map) o).put(columnName[i].toUpperCase(), Integer.parseInt(value)); + ((Map) o).put(columnName[i], Integer.parseInt(value)); + } catch (Exception e) { + ((Map) o).put(columnName[i].toLowerCase(), value); + ((Map) o).put(columnName[i].toUpperCase(), value); + ((Map) o).put(columnName[i], value); } - ((Map) o).put(columnName[i].toLowerCase(), rs.getInt(i + 1)); - ((Map) o).put(columnName[i].toUpperCase(), rs.getInt(i + 1)); - ((Map) o).put(columnName[i], rs.getInt(i + 1)); } continue; } if ("FLOAT".equalsIgnoreCase(columnType) || "DOUBLE".equalsIgnoreCase(columnType) || "DECIMAL".equalsIgnoreCase(columnType)) { if (Objects.nonNull(toLowerCase)) { - ((Map) o).put(columnName[i].toLowerCase(), rs.getString(i + 1)); + ((Map) o).put(columnName[i].toLowerCase(), value); } else { if (enable) { - ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i])); + ((Map) o).put(Util.toCamelCase(columnName[i]), valueCloumn); continue; } if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) { - ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i])); + ((Map) o).put(Util.toCamelCase(columnName[i]), valueCloumn); } - ((Map) o).put(columnName[i].toLowerCase(), rs.getString(i + 1)); - ((Map) o).put(columnName[i].toUpperCase(), rs.getString(i + 1)); - ((Map) o).put(columnName[i], rs.getString(i + 1)); + ((Map) o).put(columnName[i].toLowerCase(), value); + ((Map) o).put(columnName[i].toUpperCase(), value); + ((Map) o).put(columnName[i], value); } continue; } @@ -535,18 +554,18 @@ public class ResultMapper { } if (Objects.nonNull(toLowerCase)) { - ((Map) o).put(columnName[i].toLowerCase(), rs.getString(i + 1)); + ((Map) o).put(columnName[i].toLowerCase(), value); } else { if (enable) { - ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i])); + ((Map) o).put(Util.toCamelCase(columnName[i]), valueCloumn); continue; } if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) { - ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1)); + ((Map) o).put(Util.toCamelCase(columnName[i]), value); } - ((Map) o).put(columnName[i].toLowerCase(), rs.getString(i + 1)); - ((Map) o).put(columnName[i].toUpperCase(), rs.getString(i + 1)); - ((Map) o).put(columnName[i], rs.getString(i + 1)); + ((Map) o).put(columnName[i].toLowerCase(), value); + ((Map) o).put(columnName[i].toUpperCase(), value); + ((Map) o).put(columnName[i], value); } diff --git a/src/main/java/com/api/xuanran/wang/shyl/service/BatchCreateWorkflowService.java b/src/main/java/com/api/xuanran/wang/shyl/service/BatchCreateWorkflowService.java index 998cd6e..f04e37a 100644 --- a/src/main/java/com/api/xuanran/wang/shyl/service/BatchCreateWorkflowService.java +++ b/src/main/java/com/api/xuanran/wang/shyl/service/BatchCreateWorkflowService.java @@ -17,8 +17,13 @@ import weaver.hrm.User; import weaver.workflow.webservices.WorkflowRequestTableField; import weaver.xuanran.wang.common.util.CommonUtil; -import java.util.*; -import java.util.concurrent.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.Callable; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.Future; import java.util.stream.Collectors; @@ -29,165 +34,170 @@ import java.util.stream.Collectors; * @date 2023/2/22 13:58 */ public class BatchCreateWorkflowService { - - // 表名 : requestId 本次需要删除的数据 - private final ConcurrentHashMap> delWorkflowTableRequestId = new ConcurrentHashMap<>(); - // workflowId : tableName - private static final HashMap workflowTable = new HashMap<>(); - private final Logger log = Util.getLogger(); - - private static final String CUSTOM_ID = "customId"; -// private final MeetingMapper meetingTransMapper = Util.getTransMapper(MeetingMapper.class); - private final MeetingService meetingService = new MeetingService(); - /** - *

取消会议 支持多个

- * @author xuanran.wang - * @dateTime 2023/2/24 10:21 - * @param ids 会议id - **/ - public void cancelMeeting(String ids){ - meetingService.cancelMeeting(ids); - } - - /** - *

批量创建流程

- * @author xuanran.wang - * @dateTime 2023/2/22 17:10 - * @param array 流程数据数组 - * @return 创建流程结果 - **/ - public List batchCreateWorkflow(User user, JSONArray array) { - List> list = new ArrayList<>(); - List errors = new ArrayList<>(); - ArrayList res = new ArrayList<>(); - try { - List reqOperateRequestEntities = checkParams(array); - // 结果集 - for (int i = 0; i < reqOperateRequestEntities.size(); i++) { - int temp = i; - // 创建流程 - Callable callable = () -> this.createWorkflow(user,reqOperateRequestEntities.get(temp), temp); - list.add(Util.threadPool.submit(callable)); - } - for (Future future : list) { - CusCreateWfInfo cusCreateWfInfo = future.get(); - PAResponseEntity entity = cusCreateWfInfo.getPaResponseEntity(); - String tableName = workflowTable.get(cusCreateWfInfo.getWorkflowId()); - if(PAResponseCode.SUCCESS != entity.getCode()){ - errors.add(cusCreateWfInfo); - continue; - } - // 将生成的requestId存到vo中返回 - Map data = (Map) entity.getData(); - String requestId = Util.null2DefaultStr(data.get("requestid"),""); - CreateWfVO vo = new CreateWfVO(); - vo.setRequestId(requestId); - vo.setCustomId(cusCreateWfInfo.getCustomId()); - res.add(vo); - - // 将表名 requestId 存到成员变量中 - if (!delWorkflowTableRequestId.containsKey(tableName)) { - ArrayList requestIds = new ArrayList<>(); - requestIds.add(requestId); - delWorkflowTableRequestId.put(tableName, requestIds); - }else { - delWorkflowTableRequestId.get(tableName).add(requestId); - } - } - if(errors.size() > 0){ - throw new CustomerException(JSONObject.toJSONString(errors)); - } - return res; - }catch (Exception e){ - if(MapUtils.isNotEmpty(delWorkflowTableRequestId)){ - log.info("删除流程数据map : " + JSONObject.toJSONString(delWorkflowTableRequestId)); - for (Map.Entry> entry : delWorkflowTableRequestId.entrySet()) { - String tableName = entry.getKey(); - List requestIds = entry.getValue(); - if (!CommonUtil.deleteWorkflowDataByRequestIds(tableName, requestIds)) { - log.error(Util.logStr("删除流程数据失败!表名:{}, 待删除流程集合: {} ", tableName,JSONObject.toJSONString(requestIds))); - } - if (!CommonUtil.deleteWorkflowDataByRequestIds("workflow_requestbase", requestIds)) { - log.error(Util.logStr("删除流程数据失败!表名:{}, 待删除流程集合: {} ", "workflow_requestbase", JSONObject.toJSONString(requestIds))); - } - if (!CommonUtil.deleteWorkflowDataByRequestIds("Bill_Meeting", requestIds)) { - log.error(Util.logStr("删除流程数据失败!表名:{}, 待删除流程集合: {} ", "Bill_Meeting", JSONObject.toJSONString(requestIds))); - } - } - } - throw new CustomerException(e.getMessage()); - } - } - - /** - *

创建流程

- * @author xuanran.wang - * @dateTime 2023/2/24 14:33 - * @param user 用户 - * @param requestEntity 流程请求体 - * @param index 流程集合下标 - * @return 流程创建成功相关数据 - **/ - public CusCreateWfInfo createWorkflow(User user, - ReqOperateRequestEntity requestEntity, - int index){ - // 创建流程 - PAResponseEntity responseEntity = BatchCreateWorkFlowController.WRO.doCreateRequest(user, requestEntity); - CusCreateWfInfo cusCreateWfInfo = new CusCreateWfInfo(); - cusCreateWfInfo.setIndex(index); - cusCreateWfInfo.setPaResponseEntity(responseEntity); - int workflowId = requestEntity.getWorkflowId(); - String tableName = workflowTable.get(workflowId); - if(StringUtils.isBlank(tableName)){ - tableName = CommonUtil.getTableNameByWorkflowId(workflowId); - workflowTable.put(workflowId, tableName); - } - // 获取主表的customId - List collect = requestEntity.getMainData() - .stream() - .filter(item -> CUSTOM_ID.equals(item.getFieldName())) - .collect(Collectors.toList()); - String customIdVal = collect.get(0).getFieldValue(); - cusCreateWfInfo.setCustomId(customIdVal); - cusCreateWfInfo.setWorkflowId(workflowId); - return cusCreateWfInfo; - } - - /** - *

参数校验并将json转成ReqOperateRequestEntity

- * @author xuanran.wang - * @dateTime 2023/2/24 13:36 - * @param array json数组 - * @return 解析后的集合 - **/ - public List checkParams(JSONArray array){ - ArrayList res = new ArrayList<>(); - try { - for (Object obj : array) { - ReqOperateRequestEntity entity; - JSONObject jsonObject; - // 将json转成内部流程对象 - try { - jsonObject = JSONObject.parseObject(obj.toString()); - entity = JSONObject.parseObject(jsonObject.toString(), ReqOperateRequestEntity.class); - }catch (Exception e){ - throw new CustomerException(Util.logStr("json反序列化失败!当前对象:{}, 错误信息: {}" ,obj,e.getMessage())); - } - if(Util.getIntValue(String.valueOf(entity.getWorkflowId()),-1) < 0){ - throw new CustomerException(Util.logStr("该对象workflowId为空!", obj)); - } - List collect = entity.getMainData() - .stream() - .filter(item -> CUSTOM_ID.equals(item.getFieldName())) - .collect(Collectors.toList()); - if(collect.size() == 0){ - throw new CustomerException(Util.logStr("该对象mainData中未找到customId!:{}", obj)); - } - res.add(entity); - } - }catch (Exception e){ - throw new CustomerException(Util.logStr("JSON参数校验失败!请检查json是否正确!错误信息: {}",e.getMessage())); - } - return res; - } + + // 表名 : requestId 本次需要删除的数据 + private final ConcurrentHashMap> delWorkflowTableRequestId = new ConcurrentHashMap<>(); + // workflowId : tableName + private static final HashMap workflowTable = new HashMap<>(); + private final Logger log = Util.getLogger(); + + private static final String CUSTOM_ID = "customId"; + // private final MeetingMapper meetingTransMapper = Util.getTransMapper(MeetingMapper.class); + private final MeetingService meetingService = new MeetingService(); + + /** + *

取消会议 支持多个

+ * + * @param ids 会议id + * @author xuanran.wang + * @dateTime 2023/2/24 10:21 + **/ + public void cancelMeeting(String ids) { + meetingService.cancelMeeting(ids); + } + + /** + *

批量创建流程

+ * + * @param array 流程数据数组 + * @return 创建流程结果 + * @author xuanran.wang + * @dateTime 2023/2/22 17:10 + **/ + public List batchCreateWorkflow(User user, JSONArray array) { + List> list = new ArrayList<>(); + List errors = new ArrayList<>(); + ArrayList res = new ArrayList<>(); + try { + List reqOperateRequestEntities = checkParams(array); + // 结果集 + for (int i = 0; i < reqOperateRequestEntities.size(); i++) { + int temp = i; + // 创建流程 + Callable callable = () -> this.createWorkflow(user, reqOperateRequestEntities.get(temp), temp); + list.add(Util.threadPool.submit(callable)); + } + for (Future future : list) { + CusCreateWfInfo cusCreateWfInfo = future.get(); + PAResponseEntity entity = cusCreateWfInfo.getPaResponseEntity(); + String tableName = workflowTable.get(cusCreateWfInfo.getWorkflowId()); + if (PAResponseCode.SUCCESS != entity.getCode()) { + errors.add(cusCreateWfInfo); + continue; + } + // 将生成的requestId存到vo中返回 + Map data = (Map) entity.getData(); + String requestId = Util.null2DefaultStr(data.get("requestid"), ""); + CreateWfVO vo = new CreateWfVO(); + vo.setRequestId(requestId); + vo.setCustomId(cusCreateWfInfo.getCustomId()); + res.add(vo); + + // 将表名 requestId 存到成员变量中 + if (!delWorkflowTableRequestId.containsKey(tableName)) { + ArrayList requestIds = new ArrayList<>(); + requestIds.add(requestId); + delWorkflowTableRequestId.put(tableName, requestIds); + } else { + delWorkflowTableRequestId.get(tableName).add(requestId); + } + } + if (errors.size() > 0) { + throw new CustomerException(JSONObject.toJSONString(errors)); + } + return res; + } catch (Exception e) { + if (MapUtils.isNotEmpty(delWorkflowTableRequestId)) { + log.info("删除流程数据map : " + JSONObject.toJSONString(delWorkflowTableRequestId)); + for (Map.Entry> entry : delWorkflowTableRequestId.entrySet()) { + String tableName = entry.getKey(); + List requestIds = entry.getValue(); + if (!CommonUtil.deleteWorkflowDataByRequestIds(tableName, requestIds)) { + log.error(Util.logStr("删除流程数据失败!表名:{}, 待删除流程集合: {} ", tableName, JSONObject.toJSONString(requestIds))); + } + if (!CommonUtil.deleteWorkflowDataByRequestIds("workflow_requestbase", requestIds)) { + log.error(Util.logStr("删除流程数据失败!表名:{}, 待删除流程集合: {} ", "workflow_requestbase", JSONObject.toJSONString(requestIds))); + } + if (!CommonUtil.deleteWorkflowDataByRequestIds("Bill_Meeting", requestIds)) { + log.error(Util.logStr("删除流程数据失败!表名:{}, 待删除流程集合: {} ", "Bill_Meeting", JSONObject.toJSONString(requestIds))); + } + } + } + throw new CustomerException(e.getMessage()); + } + } + + /** + *

创建流程

+ * + * @param user 用户 + * @param requestEntity 流程请求体 + * @param index 流程集合下标 + * @return 流程创建成功相关数据 + * @author xuanran.wang + * @dateTime 2023/2/24 14:33 + **/ + public CusCreateWfInfo createWorkflow(User user, + ReqOperateRequestEntity requestEntity, + int index) { + // 创建流程 + PAResponseEntity responseEntity = BatchCreateWorkFlowController.WRO.doCreateRequest(user, requestEntity); + CusCreateWfInfo cusCreateWfInfo = new CusCreateWfInfo(); + cusCreateWfInfo.setIndex(index); + cusCreateWfInfo.setPaResponseEntity(responseEntity); + int workflowId = requestEntity.getWorkflowId(); + String tableName = workflowTable.get(workflowId); + if (StringUtils.isBlank(tableName)) { + tableName = CommonUtil.getTableNameByWorkflowId(workflowId); + workflowTable.put(workflowId, tableName); + } + // 获取主表的customId + List collect = requestEntity.getMainData() + .stream() + .filter(item -> CUSTOM_ID.equals(item.getFieldName())) + .collect(Collectors.toList()); + String customIdVal = collect.get(0).getFieldValue(); + cusCreateWfInfo.setCustomId(customIdVal); + cusCreateWfInfo.setWorkflowId(workflowId); + return cusCreateWfInfo; + } + + /** + *

参数校验并将json转成ReqOperateRequestEntity

+ * + * @param array json数组 + * @return 解析后的集合 + * @author xuanran.wang + * @dateTime 2023/2/24 13:36 + **/ + public List checkParams(JSONArray array) { + ArrayList res = new ArrayList<>(); + try { + for (Object obj : array) { + ReqOperateRequestEntity entity; + JSONObject jsonObject; + // 将json转成内部流程对象 + try { + jsonObject = JSONObject.parseObject(obj.toString()); + entity = JSONObject.parseObject(jsonObject.toString(), ReqOperateRequestEntity.class); + } catch (Exception e) { + throw new CustomerException(Util.logStr("json反序列化失败!当前对象:{}, 错误信息: {}", obj, e.getMessage())); + } + if (Util.getIntValue(String.valueOf(entity.getWorkflowId()), -1) < 0) { + throw new CustomerException(Util.logStr("该对象workflowId为空!", obj)); + } + List collect = entity.getMainData() + .stream() + .filter(item -> CUSTOM_ID.equals(item.getFieldName())) + .collect(Collectors.toList()); + if (collect.size() == 0) { + throw new CustomerException(Util.logStr("该对象mainData中未找到customId!:{}", obj)); + } + res.add(entity); + } + } catch (Exception e) { + throw new CustomerException(Util.logStr("JSON参数校验失败!请检查json是否正确!错误信息: {}", e.getMessage())); + } + return res; + } } diff --git a/src/main/java/com/api/youhong/ai/ihgzhouji/taskele/contoller/TaskElementController.java b/src/main/java/com/api/youhong/ai/ihgzhouji/taskele/contoller/TaskElementController.java index 6070c98..e1ab629 100644 --- a/src/main/java/com/api/youhong/ai/ihgzhouji/taskele/contoller/TaskElementController.java +++ b/src/main/java/com/api/youhong/ai/ihgzhouji/taskele/contoller/TaskElementController.java @@ -143,4 +143,5 @@ public class TaskElementController { return ApiResult.error("system error!"); } } + } diff --git a/src/main/java/com/api/youhong/ai/ihgzhouji/taskele/mapper/TaskElementMapper.java b/src/main/java/com/api/youhong/ai/ihgzhouji/taskele/mapper/TaskElementMapper.java index 9278b84..74407f1 100644 --- a/src/main/java/com/api/youhong/ai/ihgzhouji/taskele/mapper/TaskElementMapper.java +++ b/src/main/java/com/api/youhong/ai/ihgzhouji/taskele/mapper/TaskElementMapper.java @@ -168,4 +168,22 @@ public interface TaskElementMapper { */ @Update("update uf_rwtzeq_dt1 set zjwczt = 0 where zjr = #{userId} and mainid = #{mainId}") boolean updateTaskHandoverStatus(@ParamMapper("userId") String userId, @ParamMapper("mainId") String mainId); + + /** + *

查询相似名称的人员信息

+ * + * @param nameLike 姓名like + * @return 姓名like的id + */ + @Select("select id from hrmresource where lastname like #{nameLike}") + List selectUserNameLike(String nameLike); + + /** + *

查询相似名称的人员信息

+ * + * @param value 姓名 + * @return 姓名的id + */ + @Select("select id from hrmresource where lastname = #{nameLike}") + Integer selectUserName(String value); } diff --git a/src/main/java/com/api/youhong/ai/ihgzhouji/taskele/service/TaskElementService.java b/src/main/java/com/api/youhong/ai/ihgzhouji/taskele/service/TaskElementService.java index 9fbb345..464ff4a 100644 --- a/src/main/java/com/api/youhong/ai/ihgzhouji/taskele/service/TaskElementService.java +++ b/src/main/java/com/api/youhong/ai/ihgzhouji/taskele/service/TaskElementService.java @@ -106,7 +106,10 @@ public class TaskElementService { for (Map item : authorityList) { if ("0".equals(dataSource)) { // 自定义sql - customerValue += " " + whereStr; + // customerValue += " " + whereStr; + if (StrUtil.isNotBlank(whereStr)) { + customerValue = "select * from (" + customerValue + ") temp where " + whereStr; + } List> list = mapper.selectWorkList(customerValue, item, user, whereMap, currentMap); if (CollectionUtil.isNotEmpty(list)) { result.addAll(list); @@ -179,8 +182,10 @@ public class TaskElementService { Map map = new HashMap<>(8); map.put("currentDate", Util.getTime("yyyy-MM-dd")); map.put("currentTime", Util.getTime("HH:mm:ss")); + Map searchParam = (Map) params.get("searchParam"); + Map allSearch = (Map) params.get("allSearch"); StringBuilder builder = new StringBuilder(); - for (Map.Entry entry : params.entrySet()) { + for (Map.Entry entry : searchParam.entrySet()) { Map valueMap = (Map) entry.getValue(); String key = Util.null2String(valueMap.get("key")); String value = Util.null2String(valueMap.get("value")); @@ -196,6 +201,49 @@ public class TaskElementService { } } String whereStr = builder.toString(); + if (StrUtil.isNotBlank(whereStr)) { + String trim = whereStr.trim(); + if (trim.startsWith("and")) { + whereStr = trim.substring(3); + } + } + if (CollectionUtil.isNotEmpty(allSearch)) { + StringBuilder orWhere = new StringBuilder(); + String value = Util.null2String(allSearch.get("value")); + if (StrUtil.isNotBlank(value)) { + List> fields = (List>) allSearch.get("fields"); + for (Map field : fields) { + String key = Util.null2String(field.get("key")); + String type = Util.null2String(field.get("type")); + if ("like".equalsIgnoreCase(type)) { + orWhere.append(" or ").append(key).append(" like ").append("concat('%',#{where._allValue},'%')"); + } else if ("hrm like".equalsIgnoreCase(type)) { + List hrmList = mapper.selectUserNameLike("%" + value + "%"); + orWhere.append(" or ").append(key).append(" in ( ").append(Util.intJoin(hrmList, ",")).append(") "); + } else if ("hrm".equalsIgnoreCase(type)) { + Integer hrmId = mapper.selectUserName(value); + orWhere.append(" or ").append(key).append(" = ").append(hrmId); + } else { + orWhere.append(" or ").append(key).append(" = ").append("#{where._allValue}"); + } + } + map.put("_allValue", value); + String orWhereStr = orWhere.toString(); + if (StrUtil.isNotBlank(orWhereStr)) { + String trim = orWhereStr.trim(); + if (trim.startsWith("or")) { + orWhereStr = trim.substring(2); + } + if (StrUtil.isNotBlank(whereStr)) { + whereStr = whereStr + " or ( " + orWhereStr + " )"; + } else { + whereStr = orWhereStr; + } + } + } + + } + // 查询可查看权限并进行过滤 String viewAuthoritySql = ihgTaskElementConfItem.getViewAuthority(); List> authorityList = mapper.selectAuthority(viewAuthoritySql, user, map); diff --git a/src/main/java/com/api/youhong/ai/pcn/download/controller/DownloadFileController.java b/src/main/java/com/api/youhong/ai/pcn/download/controller/DownloadFileController.java new file mode 100644 index 0000000..1527417 --- /dev/null +++ b/src/main/java/com/api/youhong/ai/pcn/download/controller/DownloadFileController.java @@ -0,0 +1,40 @@ +package com.api.youhong.ai.pcn.download.controller; + +import aiyh.utils.ApiResult; +import aiyh.utils.Util; +import com.api.youhong.ai.pcn.download.service.DownloadFileService; +import org.apache.log4j.Logger; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +/** + *

下载文件

+ * + *

create: 2023/6/26 23:30

+ * + * @author youHong.ai + */ +@Path("aiyh/download-file") +public class DownloadFileController { + + private final Logger log = Util.getLogger(); + + private final DownloadFileService service = new DownloadFileService(); + + @GET + @Path("download") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response downloadFile(@QueryParam("fieldId") String fieldId) { + try { + return service.downloadFile(fieldId); + } catch (Exception e) { + log.error("下载文件出错:" + Util.getErrString(e)); + return Response.ok(ApiResult.error("system error!"), MediaType.APPLICATION_JSON).build(); + } + } +} diff --git a/src/main/java/com/api/youhong/ai/pcn/download/service/DownloadFileService.java b/src/main/java/com/api/youhong/ai/pcn/download/service/DownloadFileService.java new file mode 100644 index 0000000..6585426 --- /dev/null +++ b/src/main/java/com/api/youhong/ai/pcn/download/service/DownloadFileService.java @@ -0,0 +1,67 @@ +package com.api.youhong.ai.pcn.download.service; + +import aiyh.utils.ApiResult; +import aiyh.utils.Util; +import aiyh.utils.entity.DocImageInfo; +import aiyh.utils.excention.CustomerException; +import aiyh.utils.tool.cn.hutool.core.util.StrUtil; +import weaver.file.ImageFileManager; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import java.io.InputStream; +import java.net.URLDecoder; + +/** + *

+ * + *

create: 2023/6/26 23:33

+ * + * @author youHong.ai + */ + +public class DownloadFileService { + + + public static final String SUFFIX = "=="; + + /** + *

下载文件

+ * + * @param encryptionFileId 加密后的文件id docid + * @return 文件流 + */ + public Response downloadFile(String encryptionFileId) { + if (StrUtil.isBlank(encryptionFileId)) { + return Response.ok(ApiResult.error("fileId is blank!"), MediaType.APPLICATION_JSON).build(); + } + String fieldId = null; + try { + String decode = URLDecoder.decode(encryptionFileId, "UTF-8"); + if (encryptionFileId.endsWith(SUFFIX)) { + decode = encryptionFileId; + } + fieldId = EncryptionFileIdUtil.decrypt(decode); + } catch (Exception e) { + throw new CustomerException("解密附件id失败!", e); + } + DocImageInfo docImageInfo = Util.selectImageInfoByDocId(fieldId); + StreamingOutput stream = outputStream -> { + Integer imageFileId = docImageInfo.getImageFileId(); + InputStream inputStreamById = ImageFileManager.getInputStreamById(imageFileId); + byte[] buffer = new byte[4096]; + int bytesRead; + while ((bytesRead = inputStreamById.read(buffer)) != -1) { + outputStream.write(buffer, 0, bytesRead); + } + }; + String imageFileName = docImageInfo.getImageFileName(); + return Response + .ok(stream) + .header("Content-Disposition", "attachment; filename=\"" + imageFileName + "\"") + .build(); + } + + +} diff --git a/src/main/java/com/api/youhong/ai/pcn/download/service/EncryptionFileIdUtil.java b/src/main/java/com/api/youhong/ai/pcn/download/service/EncryptionFileIdUtil.java new file mode 100644 index 0000000..aecf9f5 --- /dev/null +++ b/src/main/java/com/api/youhong/ai/pcn/download/service/EncryptionFileIdUtil.java @@ -0,0 +1,70 @@ +package com.api.youhong.ai.pcn.download.service; + +import javax.crypto.Cipher; +import javax.crypto.spec.SecretKeySpec; +import java.nio.charset.StandardCharsets; +import java.util.Arrays; +import java.util.Base64; + +/** + *

加密工具

+ * + *

create: 2023/6/26 23:43

+ * + * @author youHong.ai + */ +public class EncryptionFileIdUtil { + private static final String PASSWORD = "H6f9T4x2jL8E3K7Y"; + + + /** + * 将密码补齐到合法长度 + * + * @param password 密码 + * @return 合法长度的密码 + */ + public static String padPassword(String password) { + byte[] passwordBytes = password.getBytes(StandardCharsets.UTF_8); + // AES-128 + int validKeyLength = 16; + if (passwordBytes.length < validKeyLength) { + byte[] paddedBytes = Arrays.copyOf(passwordBytes, validKeyLength); + return new String(paddedBytes, StandardCharsets.UTF_8); + } else if (passwordBytes.length > validKeyLength) { + return new String(Arrays.copyOf(passwordBytes, validKeyLength), StandardCharsets.UTF_8); + } + return password; + } + + /** + *

使用AES对称加密算法和Base64编码进行加密

+ * + * @param plaintext 待加密字符串 + * @return 加密后的字符串 + * @throws Exception 产生的异常信息 + */ + public static String encrypt(String plaintext) throws Exception { + String password = padPassword(PASSWORD); + SecretKeySpec secretKey = new SecretKeySpec(password.getBytes(StandardCharsets.UTF_8), "AES"); + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); + cipher.init(Cipher.ENCRYPT_MODE, secretKey); + byte[] encryptedData = cipher.doFinal(plaintext.getBytes(StandardCharsets.UTF_8)); + return Base64.getEncoder().encodeToString(encryptedData); + } + + /** + *

使用AES对称加密算法和Base64编码进行解密

+ * + * @param encryptedText 加密后的字符串 + * @return 解密后的字符串 + * @throws Exception 异常信息 + */ + public static String decrypt(String encryptedText) throws Exception { + String password = padPassword(PASSWORD); + SecretKeySpec secretKey = new SecretKeySpec(password.getBytes(StandardCharsets.UTF_8), "AES"); + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); + cipher.init(Cipher.DECRYPT_MODE, secretKey); + byte[] decryptedData = cipher.doFinal(Base64.getDecoder().decode(encryptedText)); + return new String(decryptedData, StandardCharsets.UTF_8); + } +} diff --git a/src/main/java/com/api/youhong/ai/taibao/checknumber/controller/CheckNumberController.java b/src/main/java/com/api/youhong/ai/taibao/checknumber/controller/CheckNumberController.java new file mode 100644 index 0000000..df99bdd --- /dev/null +++ b/src/main/java/com/api/youhong/ai/taibao/checknumber/controller/CheckNumberController.java @@ -0,0 +1,41 @@ +package com.api.youhong.ai.taibao.checknumber.controller; + +import aiyh.utils.ApiResult; +import aiyh.utils.Util; +import com.api.youhong.ai.taibao.checknumber.service.CheckNumberService; +import org.apache.log4j.Logger; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +/** + *

检查是否存在编号

+ * + *

create: 2023/6/26 11:03

+ * + * @author youHong.ai + */ +@Path("/aiyh/taibao/bh") +public class CheckNumberController { + + private final Logger log = Util.getLogger(); + + private final CheckNumberService service = new CheckNumberService(); + + @Path("check-number") + @GET + @Produces(MediaType.APPLICATION_JSON) + public String checkNumber(@QueryParam("tableName") String tableName, + @QueryParam("field") String field, + @QueryParam("requestId") String requestId) { + try { + return ApiResult.success(service.checkNumber(tableName, field, requestId)); + } catch (Exception e) { + log.error("检查是否存在编号出错:" + Util.getErrString(e)); + return ApiResult.error("system error!"); + } + } +} diff --git a/src/main/java/com/api/youhong/ai/taibao/checknumber/mapper/CheckNumberMapper.java b/src/main/java/com/api/youhong/ai/taibao/checknumber/mapper/CheckNumberMapper.java new file mode 100644 index 0000000..791a356 --- /dev/null +++ b/src/main/java/com/api/youhong/ai/taibao/checknumber/mapper/CheckNumberMapper.java @@ -0,0 +1,29 @@ +package com.api.youhong.ai.taibao.checknumber.mapper; + +import aiyh.utils.annotation.recordset.ParamMapper; +import aiyh.utils.annotation.recordset.Select; +import aiyh.utils.annotation.recordset.SqlMapper; + +/** + *

+ * + *

create: 2023/6/26 11:08

+ * + * @author youHong.ai + */ +@SqlMapper +public interface CheckNumberMapper { + + /** + *

查询编号是否存在

+ * + * @param field 编号字段 + * @param tableName 表名称 + * @param requestId 流程id + * @return 编号 + */ + @Select("select $t{field} from $t{tableName} where requestid = #{requestId}") + String selectNumber(@ParamMapper("field") String field, + @ParamMapper("tableName") String tableName, + @ParamMapper("requestId") String requestId); +} diff --git a/src/main/java/com/api/youhong/ai/taibao/checknumber/service/CheckNumberService.java b/src/main/java/com/api/youhong/ai/taibao/checknumber/service/CheckNumberService.java new file mode 100644 index 0000000..2daef06 --- /dev/null +++ b/src/main/java/com/api/youhong/ai/taibao/checknumber/service/CheckNumberService.java @@ -0,0 +1,31 @@ +package com.api.youhong.ai.taibao.checknumber.service; + +import aiyh.utils.Util; +import aiyh.utils.tool.cn.hutool.core.util.StrUtil; +import com.api.youhong.ai.taibao.checknumber.mapper.CheckNumberMapper; + +/** + *

+ * + *

create: 2023/6/26 11:06

+ * + * @author youHong.ai + */ +public class CheckNumberService { + + private final CheckNumberMapper mapper = Util.getMapper(CheckNumberMapper.class); + + /** + *

检查是否存在编号

+ * + * @param tableName 表名称 + * @param field 字段 + * @param requestId 流程id + * @return 是否存在编号 + */ + public boolean checkNumber(String tableName, String field, String requestId) { + String number = mapper.selectNumber(field, tableName, requestId); + return StrUtil.isNotBlank(number); + } + +} diff --git a/src/main/java/com/customization/youhong/pcn/createrworkflow/impl/CheckWorkflowRequestParamsImpl.java b/src/main/java/com/customization/youhong/pcn/createrworkflow/impl/CheckWorkflowRequestParamsImpl.java index 6e8f413..46c87cd 100644 --- a/src/main/java/com/customization/youhong/pcn/createrworkflow/impl/CheckWorkflowRequestParamsImpl.java +++ b/src/main/java/com/customization/youhong/pcn/createrworkflow/impl/CheckWorkflowRequestParamsImpl.java @@ -2,7 +2,6 @@ package com.customization.youhong.pcn.createrworkflow.impl; import aiyh.utils.Util; import com.customization.youhong.pcn.createrworkflow.CreateRequestException; -import com.customization.youhong.pcn.createrworkflow.mapper.CheckWorkflowRequestParamsMapper; import com.customization.youhong.pcn.createrworkflow.util.CheckWorkflowRequestParamsUtil; import com.engine.core.cfg.annotation.ServiceDynamicProxy; import com.engine.core.cfg.annotation.ServiceMethodDynamicProxy; @@ -31,7 +30,6 @@ public class CheckWorkflowRequestParamsImpl extends AbstractServiceProxy impleme private final Logger log = Util.getLogger("workflow"); - private final CheckWorkflowRequestParamsMapper mapper = Util.getMapper(CheckWorkflowRequestParamsMapper.class); private final CheckWorkflowRequestParamsUtil checkUtil = new CheckWorkflowRequestParamsUtil(); diff --git a/src/main/java/com/customization/youhong/pcn/createrworkflow/util/CheckWorkflowRequestParamsUtil.java b/src/main/java/com/customization/youhong/pcn/createrworkflow/util/CheckWorkflowRequestParamsUtil.java index a710693..c133eb0 100644 --- a/src/main/java/com/customization/youhong/pcn/createrworkflow/util/CheckWorkflowRequestParamsUtil.java +++ b/src/main/java/com/customization/youhong/pcn/createrworkflow/util/CheckWorkflowRequestParamsUtil.java @@ -2,6 +2,7 @@ package com.customization.youhong.pcn.createrworkflow.util; import aiyh.utils.Util; import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil; +import com.alibaba.fastjson.JSON; import com.customization.youhong.pcn.createrworkflow.CreateRequestException; import com.customization.youhong.pcn.createrworkflow.mapper.CheckWorkflowRequestParamsMapper; import com.customization.youhong.pcn.createrworkflow.pojo.CheckConditionItem; @@ -51,6 +52,8 @@ public class CheckWorkflowRequestParamsUtil { if (CollectionUtil.isEmpty(detailList)) { return; } + log.info("checkCreateConfig: " + JSON.toJSONString(checkCreateConfig)); + log.info("detailList: " + JSON.toJSONString(detailList)); Map checkConditionItemMap; List conditionGroupItems = checkCreateConfig.getConditionGroupItems(); if (CollectionUtil.isNotEmpty(conditionGroupItems)) { diff --git a/src/main/java/weaver/youhong/ai/pcn/actioin/todwfworkflow/cusgetdata/FileLinkListGetImpl.java b/src/main/java/weaver/youhong/ai/pcn/actioin/todwfworkflow/cusgetdata/FileLinkListGetImpl.java new file mode 100644 index 0000000..3fcdd09 --- /dev/null +++ b/src/main/java/weaver/youhong/ai/pcn/actioin/todwfworkflow/cusgetdata/FileLinkListGetImpl.java @@ -0,0 +1,46 @@ +package weaver.youhong.ai.pcn.actioin.todwfworkflow.cusgetdata; + +import aiyh.utils.Util; +import aiyh.utils.entity.DocImageInfo; +import aiyh.utils.excention.CustomerException; +import aiyh.utils.tool.cn.hutool.core.util.StrUtil; +import com.api.youhong.ai.pcn.download.service.EncryptionFileIdUtil; +import weaver.xiao.commons.config.interfacies.CusInterfaceGetValue; + +import java.net.URLEncoder; +import java.util.*; + +/** + *

自定义附件数组获取值

+ * + *

create: 2023/6/26 23:57

+ * + * @author youHong.ai + */ +public class FileLinkListGetImpl implements CusInterfaceGetValue { + @Override + public Object execute(Map mainMap, Map detailMap, String currentValue, Map pathParam) { + if (StrUtil.isBlank(currentValue)) { + return Collections.emptyList(); + } + String downloadFileHost = Util.getCusConfigValue("downloadFileHost"); + List docImageInfos = Util.selectImageInfoByDocIds(currentValue); + List> list = new ArrayList<>(); + for (DocImageInfo docImageInfo : docImageInfos) { + String encode = null; + try { + String encrypt = EncryptionFileIdUtil.encrypt(docImageInfo.getDocId() + ""); + encode = URLEncoder.encode(encrypt, "UTF-8"); + } catch (Exception e) { + throw new CustomerException("加密附件id出错!", e); + } + String url = downloadFileHost + "/api/aiyh/download-file/download?fieldId=" + encode; + Map map = new HashMap<>(8); + map.put("fileName", docImageInfo.getImageFileName()); + map.put("fileId", docImageInfo.getImageFileId()); + map.put("fileUrl", url); + list.add(map); + } + return list; + } +} diff --git a/src/test/java/youhong/ai/pcn/Test01.java b/src/test/java/youhong/ai/pcn/Test01.java index 556eece..fd04386 100644 --- a/src/test/java/youhong/ai/pcn/Test01.java +++ b/src/test/java/youhong/ai/pcn/Test01.java @@ -1,10 +1,14 @@ package youhong.ai.pcn; import basetest.BaseTest; +import com.api.youhong.ai.pcn.download.service.EncryptionFileIdUtil; import com.api.youhong.ai.pcn.ssoyunzhao.service.SsoYunZhaoService; import org.junit.Test; import weaver.hrm.User; +import java.net.URLDecoder; +import java.net.URLEncoder; + /** *

test

* @@ -23,4 +27,13 @@ public class Test01 extends BaseTest { System.out.println(service.rsaDecryptUserInfo("EpPlcAYvNOFfJWHBuvLkWzkTOoEk3NoO95FoRlEJTGlblyBEYV0CQWnCDd4yXDCgcR1yhaig/5NrIZ5dGTTgwZ6f0fOfVDdnFPr5/GUUzxxsW8qpdHLIswFT1O4E57ny1Df6uxPaE5Hqp3QHvGkfUo4ak2mI0D11V7XzxGmVsSqoofdrCVXJIRrTkUHJ3OSxtQtkuxHcc0ivSAtJkWtdgnxRbmCvMMuPKELAq/cxqPfRSAf/sL/SI374DqlYnZDn/BCVA9Ab9TC/9g08QHSlGP+XV/CySecV5Z8bILCTV8bzcgMUznQSTuyIastzMHWLtcJ2zr4gE8jR393vRtAI9A==")); } + + @Test + public void testEnDocid() throws Exception { + String encrypt = EncryptionFileIdUtil.encrypt("76"); + String encode = URLEncoder.encode(encrypt, "UTF-8"); + System.out.println(encode); + String decode = URLDecoder.decode(encode, "UTF-8"); + System.out.println(EncryptionFileIdUtil.decrypt(decode)); + } } diff --git a/src/test/java/youhong/ai/utiltest/OtherTest.java b/src/test/java/youhong/ai/utiltest/OtherTest.java new file mode 100644 index 0000000..4be3735 --- /dev/null +++ b/src/test/java/youhong/ai/utiltest/OtherTest.java @@ -0,0 +1,22 @@ +package youhong.ai.utiltest; + +import org.junit.Test; + +/** + *

其他测试

+ * + *

create: 2023/6/28 10:59

+ * + * @author youHong.ai + */ +public class OtherTest { + + + @Test + public void test() { + String str = "and alsdjf jsi3jtj"; + System.out.println(str.substring(3)); + } + + +} \ No newline at end of file diff --git a/src/test/java/youhong/ai/utiltest/ShortEncryptionExample.java b/src/test/java/youhong/ai/utiltest/ShortEncryptionExample.java new file mode 100644 index 0000000..64f90c9 --- /dev/null +++ b/src/test/java/youhong/ai/utiltest/ShortEncryptionExample.java @@ -0,0 +1,63 @@ +package youhong.ai.utiltest; + +import javax.crypto.Cipher; +import javax.crypto.spec.SecretKeySpec; +import java.nio.charset.StandardCharsets; +import java.util.Arrays; +import java.util.Base64; + +public class ShortEncryptionExample { + + public static void main(String[] args) { + try { + String plaintext = "9384819"; + String password = "SecretPassword"; + + // 补齐密码到合法长度 + password = padPassword(password); + + // 加密 + String encryptedText = encrypt(plaintext, password); + + // 解密 + String decryptedText = decrypt(encryptedText, password); + + System.out.println("原文: " + plaintext); + System.out.println("加密后: " + encryptedText); + System.out.println("解密后: " + decryptedText); + } catch (Exception e) { + e.printStackTrace(); + } + } + + // 将密码补齐到合法长度 + public static String padPassword(String password) { + byte[] passwordBytes = password.getBytes(StandardCharsets.UTF_8); + int validKeyLength = 16; // AES-128 + if (passwordBytes.length < validKeyLength) { + byte[] paddedBytes = Arrays.copyOf(passwordBytes, validKeyLength); + return new String(paddedBytes, StandardCharsets.UTF_8); + } else if (passwordBytes.length > validKeyLength) { + return new String(Arrays.copyOf(passwordBytes, validKeyLength), StandardCharsets.UTF_8); + } + return password; + } + + // 使用AES对称加密算法和Base64编码进行加密 + public static String encrypt(String plaintext, String password) throws Exception { + SecretKeySpec secretKey = new SecretKeySpec(password.getBytes(StandardCharsets.UTF_8), "AES"); + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); + cipher.init(Cipher.ENCRYPT_MODE, secretKey); + byte[] encryptedData = cipher.doFinal(plaintext.getBytes(StandardCharsets.UTF_8)); + return Base64.getEncoder().encodeToString(encryptedData); + } + + // 使用AES对称加密算法和Base64编码进行解密 + public static String decrypt(String encryptedText, String password) throws Exception { + SecretKeySpec secretKey = new SecretKeySpec(password.getBytes(StandardCharsets.UTF_8), "AES"); + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); + cipher.init(Cipher.DECRYPT_MODE, secretKey); + byte[] decryptedData = cipher.doFinal(Base64.getDecoder().decode(encryptedText)); + return new String(decryptedData, StandardCharsets.UTF_8); + } +} From a4617332167372254e77f60640dc494c99e6d8cb Mon Sep 17 00:00:00 2001 From: wangxuanran <3055088966@qq.com> Date: Fri, 30 Jun 2023 15:14:57 +0800 Subject: [PATCH 06/13] =?UTF-8?q?=E8=A7=A3=E5=86=B3map=E4=B8=AD=E5=80=BC?= =?UTF-8?q?=E4=B8=BAnull=E8=BD=AC=E6=88=90''=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/aiyh/utils/recordset/SqlHandler.java | 3 +- .../xuanran/wang/common/util/CusData2OA.java | 29 ++-- .../xuanran/wang/cssc/cms/WorkflowToCms.java | 4 +- .../wang/cssc/cms/entity/CusSuccess.java | 2 - .../impl/WorkFlowToCmsServiceImpl.java | 23 ++- .../cssc/cms/util/RequestMasterPlate.java | 7 +- .../data_async/mapper/DataAsyncMapper.java | 4 + .../service/DataAsyncServiceImpl.java | 160 +++++------------- .../eny/data_async/util/ValueRuleMethod.java | 9 +- .../config/util/ValueRuleMethod.java | 2 +- .../java/xuanran/wang/eny/DataAsyncTest.java | 1 + 11 files changed, 99 insertions(+), 145 deletions(-) diff --git a/src/main/java/aiyh/utils/recordset/SqlHandler.java b/src/main/java/aiyh/utils/recordset/SqlHandler.java index 7049cbf..b1f9363 100644 --- a/src/main/java/aiyh/utils/recordset/SqlHandler.java +++ b/src/main/java/aiyh/utils/recordset/SqlHandler.java @@ -268,7 +268,8 @@ public class SqlHandler { } Object o = ((Map) arg).get(key); if (null == o) { - return ""; + // 如果值是null 则直接返回hull + return null; } if (o instanceof Character || o instanceof String) { // 处理字符类型 diff --git a/src/main/java/weaver/xuanran/wang/common/util/CusData2OA.java b/src/main/java/weaver/xuanran/wang/common/util/CusData2OA.java index a35cf3e..a121bc2 100644 --- a/src/main/java/weaver/xuanran/wang/common/util/CusData2OA.java +++ b/src/main/java/weaver/xuanran/wang/common/util/CusData2OA.java @@ -10,15 +10,13 @@ import org.apache.axis2.databinding.types.xsd._float; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; +import org.apache.tools.ant.taskdefs.Pack; import weaver.formmode.data.ModeDataIdUpdate; import weaver.formmode.setup.ModeRightInfo; import weaver.xuanran.wang.common.mapper.CommonMapper; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; @@ -102,7 +100,10 @@ public class CusData2OA { return modelDataList; } - public static void baseInsertAndUpdate(String modelId, List> params, CountDownLatch latch){ + public static boolean baseInsertAndUpdate(String modelId, List> params, CountDownLatch latch){ + if(CollectionUtils.isEmpty(params)){ + return true; + } int modelIdInt = Util.getIntValue(modelId, -1); String tableName = CommonUtil.checkModelId(modelIdInt); if(modelIdInt < 0 || StringUtils.isBlank(tableName)){ @@ -127,21 +128,23 @@ public class CusData2OA { updateSql = buildUpdateSql(tableName, param); } if(StringUtils.isBlank(insertSql)){ - insertSql = buildInsertSql(tableName, modelId, param); + insertSql = buildInsertSql(tableName, param); } } try { if(CollectionUtils.isNotEmpty(updateParams)){ - if (!commonMapper.updateModelInfoList(updateSql, params)) { + if (!commonMapper.updateModelInfoList(updateSql, updateParams)) { throw new CustomerException("update model data sql execute error!"); } } if(CollectionUtils.isNotEmpty(insertParams)){ - if (!commonMapper.batchInsertModel(insertSql, params)) { + if (!commonMapper.batchInsertModel(insertSql, insertParams)) { throw new CustomerException("insert model data sql execute error!"); } } + return true; }catch (Exception e){ + log.error("更新数据失败! : " + e.getMessage()); throw new CustomerException(e); }finally { if(latch != null){ @@ -153,10 +156,12 @@ public class CusData2OA { } public static String buildUpdateSql(String tableName, Map params) { + Map copy = new HashMap<>(params); + copy.remove("id"); StringBuilder sqlSb = new StringBuilder("update ") .append(tableName) .append(" set "); - for (Map.Entry entry : params.entrySet()) { + for (Map.Entry entry : copy.entrySet()) { sqlSb.append(entry.getKey()) .append(" = #{item.") .append(entry.getKey()) @@ -167,13 +172,15 @@ public class CusData2OA { return sqlSb.toString(); } - public static String buildInsertSql(String tableName, String modelId,Map params) { + public static String buildInsertSql(String tableName, Map params) { + Map copy = new HashMap<>(params); + copy.remove("id"); StringBuilder sqlSb = new StringBuilder("insert into ") .append(tableName) .append(" ("); StringBuilder fields = new StringBuilder(); StringBuilder values = new StringBuilder(); - for (Map.Entry entry : params.entrySet()) { + for (Map.Entry entry : copy.entrySet()) { fields.append(entry.getKey()).append(","); values.append("#{item.") .append(entry.getKey()) diff --git a/src/main/java/weaver/xuanran/wang/cssc/cms/WorkflowToCms.java b/src/main/java/weaver/xuanran/wang/cssc/cms/WorkflowToCms.java index b1eded5..dba527a 100644 --- a/src/main/java/weaver/xuanran/wang/cssc/cms/WorkflowToCms.java +++ b/src/main/java/weaver/xuanran/wang/cssc/cms/WorkflowToCms.java @@ -6,6 +6,7 @@ import aiyh.utils.annotation.ActionDesc; import aiyh.utils.annotation.ActionOptionalParam; import aiyh.utils.annotation.PrintParamMark; import aiyh.utils.annotation.RequiredMark; +import com.alibaba.fastjson.JSONObject; import weaver.hrm.User; import weaver.soa.workflow.request.RequestInfo; import weaver.xuanran.wang.cssc.cms.entity.CusSuccess; @@ -59,7 +60,7 @@ public class WorkflowToCms extends SafeCusBaseAction { .errorMsg(Util.null2DefaultStr(msg, "error")) .dataKey(Util.null2DefaultStr(dataKey, "")) .build(); - log.info(""); + log.info("cmsResponseVoField : " + JSONObject.toJSONString(cmsResponseVoField)); CusSuccess tokenSuccess = CusSuccess .builder() @@ -68,6 +69,7 @@ public class WorkflowToCms extends SafeCusBaseAction { .errorMsg(Util.null2DefaultStr(tokenMsg, "error")) .dataKey(Util.null2DefaultStr(tokenDataKey,"")) .build(); + log.info("tokenSuccess : " + JSONObject.toJSONString(tokenSuccess)); workflowToCmsService.workflowToCms(onlyMark,tokenOnlyMark, billTable, requestId,cmsResponseVoField, tokenSuccess); } diff --git a/src/main/java/weaver/xuanran/wang/cssc/cms/entity/CusSuccess.java b/src/main/java/weaver/xuanran/wang/cssc/cms/entity/CusSuccess.java index ef44af1..282ea57 100644 --- a/src/main/java/weaver/xuanran/wang/cssc/cms/entity/CusSuccess.java +++ b/src/main/java/weaver/xuanran/wang/cssc/cms/entity/CusSuccess.java @@ -4,7 +4,6 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import weaver.xuanran.wang.sh_bigdata.common.service.CusDataDecipher; /** @@ -23,5 +22,4 @@ public class CusSuccess { private String errorMsg; private String dataKey; private Object response; - private CusDataDecipher cusDataDecipher; } diff --git a/src/main/java/weaver/xuanran/wang/cssc/cms/service/impl/WorkFlowToCmsServiceImpl.java b/src/main/java/weaver/xuanran/wang/cssc/cms/service/impl/WorkFlowToCmsServiceImpl.java index f3f65e7..bf7d5b2 100644 --- a/src/main/java/weaver/xuanran/wang/cssc/cms/service/impl/WorkFlowToCmsServiceImpl.java +++ b/src/main/java/weaver/xuanran/wang/cssc/cms/service/impl/WorkFlowToCmsServiceImpl.java @@ -1,17 +1,24 @@ package weaver.xuanran.wang.cssc.cms.service.impl; import aiyh.utils.Util; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; import weaver.conn.RecordSet; import weaver.xiao.commons.config.entity.RequestMappingConfig; +import weaver.xiao.commons.config.entity.ResponseMapping; import weaver.xiao.commons.config.service.DealWithMapping; +import weaver.xiao.commons.utils.SqlUtil; import weaver.xuanran.wang.common.util.CommonUtil; import weaver.xuanran.wang.cssc.cms.entity.CusSuccess; import weaver.xuanran.wang.cssc.cms.service.WorkflowToCmsService; import weaver.xuanran.wang.cssc.cms.util.RequestMasterPlate; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -24,6 +31,7 @@ public class WorkFlowToCmsServiceImpl implements WorkflowToCmsService { private final DealWithMapping dealWithMapping = new DealWithMapping(); private final Logger log = Util.getLogger(); // 获取日志对象 private final RequestMasterPlate requestMasterPlate = new RequestMasterPlate(); + private final SqlUtil sqlUtil = new SqlUtil(); @Override public String getToken(String onlyMark,String billTable, String requestId, CusSuccess cusSuccess) { @@ -57,7 +65,20 @@ public class WorkFlowToCmsServiceImpl implements WorkflowToCmsService { String url = requestMappingConfig.getRequestUrl(); dealWithMapping.setMainTable(billTable); Map param = dealWithMapping.getRequestParam(recordSet, requestMappingConfig); - requestMasterPlate.apiPost(url, param, headers, cusSuccess); + Map result = requestMasterPlate.apiPost(url, param, headers, cusSuccess); + List responseMappingList = requestMappingConfig.getResponseMappingList(); + if(CollectionUtils.isEmpty(responseMappingList) || MapUtils.isEmpty(result)){ + return; + } + Map> writeBackMessage = dealWithMapping.dealResponse(responseMappingList, result); + log.info("回写信息 writeBackMessage ==>"+ JSON.toJSONString(writeBackMessage)); + Map updateMsg = writeBackMessage.get(billTable); + Map whereParam = new HashMap<>(); + whereParam.put("requestid",requestId); + boolean success = sqlUtil.updateMode(billTable, updateMsg, whereParam); + if(!success){ + log.error("数据回写表单失败!"); + } } public RecordSet initRs( RequestMappingConfig requestMappingConfig, String billTable, String requestId){ diff --git a/src/main/java/weaver/xuanran/wang/cssc/cms/util/RequestMasterPlate.java b/src/main/java/weaver/xuanran/wang/cssc/cms/util/RequestMasterPlate.java index d2ed309..eb479ac 100644 --- a/src/main/java/weaver/xuanran/wang/cssc/cms/util/RequestMasterPlate.java +++ b/src/main/java/weaver/xuanran/wang/cssc/cms/util/RequestMasterPlate.java @@ -53,12 +53,7 @@ public class RequestMasterPlate { responseVo.getEntityString())); // 相应内容 throw new CustomerException(Util.logStr("can not fetch [{}]", url)); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串 } - Map response; - if(cusSuccess.getCusDataDecipher() != null){ - response = cusSuccess.getCusDataDecipher().decoder(responseVo); - }else { - response = responseVo.getResponseMap(); // 根据相应结果转化为map集合 - } + Map response = responseVo.getResponseMap(); // 根据相应结果转化为map集合 cusSuccess.setResponse(response); String responseValue = Util.null2DefaultStr(response.get(cusSuccess.getSuccessField()), ""); if (!cusSuccess.getSuccessValue().equals(responseValue)) { diff --git a/src/main/java/weaver/xuanran/wang/eny/data_async/mapper/DataAsyncMapper.java b/src/main/java/weaver/xuanran/wang/eny/data_async/mapper/DataAsyncMapper.java index 3716c54..f0e6658 100644 --- a/src/main/java/weaver/xuanran/wang/eny/data_async/mapper/DataAsyncMapper.java +++ b/src/main/java/weaver/xuanran/wang/eny/data_async/mapper/DataAsyncMapper.java @@ -55,4 +55,8 @@ public interface DataAsyncMapper { @Select(custom = true) String selectCustomerSql(@SqlString String sql, Map map); + + @Select("select id from $t{tableName} where modedatacreatedate = #{date}") + List selectDataIdListByCreateDate(@ParamMapper("tableName") String tableName, + @ParamMapper("date") String date); } diff --git a/src/main/java/weaver/xuanran/wang/eny/data_async/service/DataAsyncServiceImpl.java b/src/main/java/weaver/xuanran/wang/eny/data_async/service/DataAsyncServiceImpl.java index 920dfe1..eb9e28a 100644 --- a/src/main/java/weaver/xuanran/wang/eny/data_async/service/DataAsyncServiceImpl.java +++ b/src/main/java/weaver/xuanran/wang/eny/data_async/service/DataAsyncServiceImpl.java @@ -4,17 +4,14 @@ import aiyh.utils.ThreadPoolConfig; import aiyh.utils.Util; import aiyh.utils.excention.CustomerException; import com.alibaba.fastjson.JSONObject; -import com.engine.common.util.ServiceUtil; -import com.engine.cube.service.ModeAppService; -import com.engine.cube.service.impl.ModeAppServiceImpl; +import io.swagger.models.auth.In; import lombok.Setter; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; -import weaver.formmode.setup.ModeRightInfoThread; +import weaver.formmode.setup.ModeRightInfo; import weaver.general.TimeUtil; -import weaver.hrm.User; import weaver.xuanran.wang.common.entity.CusSuccess; import weaver.xuanran.wang.common.util.CommonUtil; import weaver.xuanran.wang.common.util.CusData2OA; @@ -24,10 +21,6 @@ import weaver.xuanran.wang.eny.data_async.entity.DataAsyncConfigMain; import weaver.xuanran.wang.eny.data_async.mapper.DataAsyncMapper; import weaver.xuanran.wang.eny.data_async.util.EyDataAsyncTokenUtil; import weaver.xuanran.wang.eny.data_async.util.ValueRuleMethod; - -import javax.servlet.ServletContext; -import javax.servlet.http.HttpSession; -import javax.servlet.http.HttpSessionContext; import java.util.*; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; @@ -56,6 +49,8 @@ public class DataAsyncServiceImpl { .errorMsg("msg") .build(); + private static final ModeRightInfo moderightinfo = new ModeRightInfo(); + private int pageSize = 100; private int pageNo = 1; @@ -155,7 +150,8 @@ public class DataAsyncServiceImpl { threadPoolInstance.execute(()->{ log.info("======================================================================================="); log.info(Thread.currentThread().getName() + " 入库之前信号数量 : " + finalLatch.getCount()); - CusData2OA.baseInsertAndUpdate(config.getModel_id(), maps, finalLatch); + boolean success = CusData2OA.baseInsertAndUpdate(config.getModel_id(), maps, finalLatch); + log.info("数据库更新标识 : " + success); log.info(Thread.currentThread().getName() + " 入库之后信号数量 : " + finalLatch.getCount()); log.info("======================================================================================="); }); @@ -171,9 +167,17 @@ public class DataAsyncServiceImpl { if(!await){ throw new CustomerException("线程等待时间超过最大时间限制!"); } - long endTime = System.currentTimeMillis(); + // 查询当天同步的数据 + // 应该在上面 每一批数据处理完直接权限重构 + List dataIdList = asyncMapper.selectDataIdListByCreateDate(config.getTable_name(), TimeUtil.getCurrentDateString()); + if(CollectionUtils.isNotEmpty(dataIdList)){ + log.info("需要权限重构的数据条数 : " + dataIdList.size()); + for (Integer id : dataIdList) { + moderightinfo.rebuildModeDataShareByEdit(1, Util.getIntValue(config.getModel_id(),-1), id); + } + } log.info("数据结束同步时间 : " + TimeUtil.getCurrentTimeString()); - rebuildRight(Util.getIntValue(config.getModel_id())); + long endTime = System.currentTimeMillis(); log.info("同步耗时时间 " + (endTime - startTime) / 1000 + " s");// 等待所有转换操作完成 } } catch (Exception e) { @@ -194,24 +198,24 @@ public class DataAsyncServiceImpl { List> maps = new ArrayList<>(); if(CollectionUtils.isNotEmpty(primaryKey)){ // 模版-接口外键 - String modelFieldName = primaryKey.get(0).getModel_field_name(); + String primaryKeyModelFieldName = primaryKey.get(0).getModel_field_name(); maps = data.stream().map(item -> convert(item, primaryKey.get(0).getInterface_field(), configDetailList)).filter(MapUtils::isNotEmpty).collect(Collectors.toList()); // 进行排序 Optional minClassId = maps.stream() - .map(map -> Util.getIntValue(Util.null2DefaultStr(map.get(modelFieldName),""),-1)) + .map(map -> Util.getIntValue(Util.null2DefaultStr(map.get(primaryKeyModelFieldName),""),-1)) .min(Comparator.naturalOrder()); Optional maxClassId = maps.stream() - .map(map -> Util.getIntValue(Util.null2DefaultStr(map.get(modelFieldName),""),-1)) + .map(map -> Util.getIntValue(Util.null2DefaultStr(map.get(primaryKeyModelFieldName),""),-1)) .max(Comparator.naturalOrder()); Integer min = minClassId.orElse(0); Integer max = maxClassId.orElse(0); // 按照外键排序并且在oa中范围查询出外键与oa数据的对应关系 - List> dataIdList = asyncMapper.selectDataIds(modelFieldName, config.getTable_name(), min, max); + List> dataIdList = asyncMapper.selectDataIds(primaryKeyModelFieldName, config.getTable_name(), min, max); if("1".equals(debug)){ log.info("dataIdList : " + JSONObject.toJSONString(dataIdList)); } if(CollectionUtils.isNotEmpty(dataIdList)){ - HashMap idMap = parseListMap2Map(modelFieldName, "id", dataIdList); + HashMap idMap = parseListMap2Map(primaryKeyModelFieldName, "id", dataIdList); if("1".equals(debug)){ log.info("idMap : " + JSONObject.toJSONString(idMap)); } @@ -219,7 +223,7 @@ public class DataAsyncServiceImpl { if("1".equals(debug)){ log.info("item : " + JSONObject.toJSONString(item)); } - String id = Util.null2DefaultStr(item.get(modelFieldName),""); + String id = Util.null2DefaultStr(item.get(primaryKeyModelFieldName),""); if("1".equals(debug)){ log.info("id : " + id); } @@ -233,6 +237,24 @@ public class DataAsyncServiceImpl { return maps; } + public Map parseMaxAndMin(List> maps, DataAsyncConfigDetail primaryKey){ + String primaryKeyModelFieldName = primaryKey.getModel_field_name(); + // 进行排序 + Optional minClassId = maps.stream() + .map(map -> Util.getIntValue(Util.null2DefaultStr(map.get(primaryKeyModelFieldName),""),-1)) + .min(Comparator.naturalOrder()); + Optional maxClassId = maps.stream() + .map(map -> Util.getIntValue(Util.null2DefaultStr(map.get(primaryKeyModelFieldName),""),-1)) + .max(Comparator.naturalOrder()); + Integer min = minClassId.orElse(0); + Integer max = maxClassId.orElse(0); + Map map = new HashMap<>(); + map.put("max", max); + map.put("min", min); + return map; + } + + /** *

将数据进行转换

* @author xuanran.wang @@ -277,108 +299,6 @@ public class DataAsyncServiceImpl { return res; } - public static ModeAppService modeAppService = ServiceUtil.getService(ModeAppServiceImpl.class, new User(1)); - - /** - *

模块数据全量权限重构

- * @author xuanran.wang - * @dateTime 2023/6/9 13:28 - * @param modeId 模块id - **/ - public static void rebuildRight(int modeId){ - ModeRightInfoThread var5 = new ModeRightInfoThread(); - var5.setModeId(modeId); - var5.setRebulidFlag("1"); - var5.setSession(new HttpSession() { - @Override - public String getId() { - return null; - } - - @Override - public boolean isNew() { - return false; - } - - @Override - public long getCreationTime() { - return 0; - } - - @Override - public long getLastAccessedTime() { - return 0; - } - - @Override - public void setMaxInactiveInterval(int i) { - - } - - @Override - public int getMaxInactiveInterval() { - return 0; - } - - @Override - public Object getAttribute(String s) { - return null; - } - - @Override - public Enumeration getAttributeNames() { - return null; - } - - @Override - public void setAttribute(String s, Object o) { - - } - - @Override - public void removeAttribute(String s) { - - } - - @Override - public void invalidate() { - - } - - @Override - public HttpSessionContext getSessionContext() { - return null; - } - - @Override - public ServletContext getServletContext() { - return null; - } - - @Override - public Object getValue(String s) { - return null; - } - - @Override - public String[] getValueNames() { - return new String[0]; - } - - @Override - public void putValue(String s, Object o) { - - } - - @Override - public void removeValue(String s) { - - } - }); - var5.setUser(new User(1)); - var5.resetModeRight(); - } - diff --git a/src/main/java/weaver/xuanran/wang/eny/data_async/util/ValueRuleMethod.java b/src/main/java/weaver/xuanran/wang/eny/data_async/util/ValueRuleMethod.java index 9c0e610..8e9d819 100644 --- a/src/main/java/weaver/xuanran/wang/eny/data_async/util/ValueRuleMethod.java +++ b/src/main/java/weaver/xuanran/wang/eny/data_async/util/ValueRuleMethod.java @@ -52,7 +52,12 @@ public class ValueRuleMethod { @ValueRuleMethodNo(value = 0, desc = "不转换") public Object getFixValue(DataAsyncConfigDetail configDetail,Map map) { - return Util.null2DefaultStr(map.get(configDetail.getInterface_field()),""); + String interfaceField = configDetail.getInterface_field(); + String value = Util.null2DefaultStr(map.get(interfaceField),""); + if(StringUtils.isBlank(value)){ + return null; + } + return map.get(interfaceField); } @@ -90,7 +95,7 @@ public class ValueRuleMethod { try { Class clazz = Class.forName(cusText); if(!CusAsyncConvert.class.isAssignableFrom(clazz)){ - throw new CustomerException(cusText + " not implements weaver.xuanran.wang.sh_bigdata.org_hrm_async.annotations.CusOrgHrmAsyncConvert"); + throw new CustomerException(cusText + " not implements weaver.xuanran.wang.eny.data_async.service.convert.CusAsyncConvert!"); } CusAsyncConvert o = (CusAsyncConvert) clazz.newInstance(); Map pathParam = Util.parseCusInterfacePathParam(cusText); diff --git a/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/util/ValueRuleMethod.java b/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/util/ValueRuleMethod.java index 9bde767..587b3dd 100644 --- a/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/util/ValueRuleMethod.java +++ b/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/util/ValueRuleMethod.java @@ -72,7 +72,7 @@ public class ValueRuleMethod { } if (!sapConfigDetail.getCustomerValue().trim().split(" ")[0].equalsIgnoreCase("select")) { log.error(Util.logStr("intercept danger customer sql in " + - "[weaver.youhong.ai.haripijiu.action.sapdocking.config.util.ValueRuleMethod]. " + + "[weaver.youhong.ai.haripijiu.action.sapdocking.config.util.EyCusModelFieldValueRuleMethod]. " + "sql [{}]", sapConfigDetail.getCustomerValue())); return ""; } diff --git a/src/test/java/xuanran/wang/eny/DataAsyncTest.java b/src/test/java/xuanran/wang/eny/DataAsyncTest.java index b3330e2..356b937 100644 --- a/src/test/java/xuanran/wang/eny/DataAsyncTest.java +++ b/src/test/java/xuanran/wang/eny/DataAsyncTest.java @@ -55,6 +55,7 @@ public class DataAsyncTest extends BaseTest { @Test public void testb(){ + String json = "[{\"interfaceForeignKey\":\"12001\",\"id\":386455},{\"interfaceForeignKey\":\"12002\",\"id\":386457},{\"interfaceForeignKey\":\"12003\",\"id\":386459},{\"interfaceForeignKey\":\"12004\",\"id\":386460},{\"interfaceForeignKey\":\"12005\",\"id\":386462},{\"interfaceForeignKey\":\"12006\",\"id\":386464},{\"interfaceForeignKey\":\"12007\",\"id\":386466},{\"interfaceForeignKey\":\"12008\",\"id\":386468},{\"interfaceForeignKey\":\"12009\",\"id\":386469},{\"interfaceForeignKey\":\"12010\",\"id\":386471}]"; // List> maps = asyncMapper.selectDataIds("classId", "uf_class", 1, 10); List> list = JSONObject.parseObject(json, List.class); From 2450a8348e0803b20e465d8c5cd033b9bc754e58 Mon Sep 17 00:00:00 2001 From: "youhong.ai" Date: Fri, 30 Jun 2023 15:17:44 +0800 Subject: [PATCH 07/13] =?UTF-8?q?=E4=BF=9D=E6=97=B6=E6=8D=B7=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=8B=E8=BD=BD=E6=96=87=E4=BB=B6=E5=90=8D=E4=B9=B1?= =?UTF-8?q?=E7=A0=81=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/aiyh/utils/action/SafeCusBaseAction.java | 1 + .../ai/pcn/download/service/DownloadFileService.java | 7 +++++++ .../action/sapdocking/VoucherPayableNewAction.java | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/aiyh/utils/action/SafeCusBaseAction.java b/src/main/java/aiyh/utils/action/SafeCusBaseAction.java index 92cdf9f..be9f5c8 100644 --- a/src/main/java/aiyh/utils/action/SafeCusBaseAction.java +++ b/src/main/java/aiyh/utils/action/SafeCusBaseAction.java @@ -200,6 +200,7 @@ public abstract class SafeCusBaseAction implements Action { String billTable = requestManager.getBillTableName(); String id = mapper.selectIdByRequest(billTable, requestInfo.getRequestid()); result.put("id", id); + result.put("requestid", requestInfo.getRequestid()); return result; } diff --git a/src/main/java/com/api/youhong/ai/pcn/download/service/DownloadFileService.java b/src/main/java/com/api/youhong/ai/pcn/download/service/DownloadFileService.java index 6585426..b7a802d 100644 --- a/src/main/java/com/api/youhong/ai/pcn/download/service/DownloadFileService.java +++ b/src/main/java/com/api/youhong/ai/pcn/download/service/DownloadFileService.java @@ -11,7 +11,9 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.StreamingOutput; import java.io.InputStream; +import java.io.UnsupportedEncodingException; import java.net.URLDecoder; +import java.net.URLEncoder; /** *

@@ -57,6 +59,11 @@ public class DownloadFileService { } }; String imageFileName = docImageInfo.getImageFileName(); + try { + imageFileName = URLEncoder.encode(imageFileName, "UTF-8"); + } catch (UnsupportedEncodingException ignore) { + } + return Response .ok(stream) .header("Content-Disposition", "attachment; filename=\"" + imageFileName + "\"") diff --git a/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/VoucherPayableNewAction.java b/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/VoucherPayableNewAction.java index b9ef555..8b1cc3c 100644 --- a/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/VoucherPayableNewAction.java +++ b/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/VoucherPayableNewAction.java @@ -172,7 +172,7 @@ public class VoucherPayableNewAction extends SafeCusBaseAction { } headKeys = sortKey(headKeys); for (String headKey : headKeys) { - sb.append(Util.null2String(heads.get(headKey)).replace(" ", " ")).append("\t"); + sb.append(Util.null2String(heads.get(headKey)).replace("
", " ").replace(" ", " ")).append("\t"); } sb.deleteCharAt(sb.lastIndexOf("\t")); sb.append("\r\n"); @@ -184,7 +184,7 @@ public class VoucherPayableNewAction extends SafeCusBaseAction { try { OutputStreamWriter out = new OutputStreamWriter( Files.newOutputStream(Paths.get(filePath)), StandardCharsets.UTF_8); - out.write(sb.toString().replace(" ", " ")); + out.write(sb.toString().replace("
", " ").replace(" ", " ")); out.close(); } catch (IOException e) { From 0042972aa56382cc334a0ad7b3f03f46e6b48eee Mon Sep 17 00:00:00 2001 From: "youhong.ai" Date: Sat, 1 Jul 2023 13:33:05 +0800 Subject: [PATCH 08/13] =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../getlog/controller/GetLogController.java | 64 +++++++++++++++++++ .../common/getlog/service/GetLogService.java | 30 +++++++++ 常用信息.md | 19 ++++++ 3 files changed, 113 insertions(+) create mode 100644 src/main/java/com/api/ebu7dev1/common/getlog/controller/GetLogController.java create mode 100644 src/main/java/com/api/ebu7dev1/common/getlog/service/GetLogService.java diff --git a/src/main/java/com/api/ebu7dev1/common/getlog/controller/GetLogController.java b/src/main/java/com/api/ebu7dev1/common/getlog/controller/GetLogController.java new file mode 100644 index 0000000..63c6b37 --- /dev/null +++ b/src/main/java/com/api/ebu7dev1/common/getlog/controller/GetLogController.java @@ -0,0 +1,64 @@ +package com.api.ebu7dev1.common.getlog.controller; + +import aiyh.utils.ApiResult; +import aiyh.utils.Util; +import com.api.ebu7dev1.common.getlog.service.GetLogService; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import org.apache.log4j.Logger; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.util.Map; + +/** + *

获取自定义日志

+ * + *

create: 2023/7/1 10:27

+ * + * @author youHong.ai + */ +@Path("/ebu7-dev1/common/log") +public class GetLogController { + + private final Logger log = Util.getLogger(); + + private final GetLogService service = new GetLogService(); + + @GET + @Path("get") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response getLogger(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User loginUser = HrmUserVarify.getUser(request, response); + return service.get(loginUser); + } catch (Exception e) { + log.error("下载文件出错:" + Util.getErrString(e)); + return Response.ok(ApiResult.error("system error!"), MediaType.APPLICATION_JSON).build(); + } + } + + + @POST + @Path("collect") + @Produces(MediaType.APPLICATION_JSON) + public String collectLogInfo(@Context HttpServletRequest request, + @Context HttpServletResponse response, + @RequestBody Map params) { + try { + User loginUser = HrmUserVarify.getUser(request, response); + return service.collectLogInfo(loginUser, params); + } catch (Exception e) { + log.error("下载文件出错:" + Util.getErrString(e)); + return ApiResult.error("system error!"); + } + } +} diff --git a/src/main/java/com/api/ebu7dev1/common/getlog/service/GetLogService.java b/src/main/java/com/api/ebu7dev1/common/getlog/service/GetLogService.java new file mode 100644 index 0000000..58b0094 --- /dev/null +++ b/src/main/java/com/api/ebu7dev1/common/getlog/service/GetLogService.java @@ -0,0 +1,30 @@ +package com.api.ebu7dev1.common.getlog.service; + +import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; +import weaver.hrm.User; + +import javax.ws.rs.core.Response; +import java.util.Map; + +/** + *

获取日志

+ * + *

create: 2023/7/1 10:28

+ * + * @author youHong.ai + */ +public class GetLogService { + public Response get(User loginUser) { + return null; + } + + public String collectLogInfo(User loginUser, Map params) { + if (loginUser.getUID() != 1) { + throw new CustomerException("无权限查看!"); + } + String startDate = Util.null2String(params.get("startDate")); + String endDate = Util.null2String(params.get("endDate")); + return null; + } +} diff --git a/常用信息.md b/常用信息.md index 0dad4cb..f112a90 100644 --- a/常用信息.md +++ b/常用信息.md @@ -291,6 +291,25 @@ function loadJs(url, callback) { } ``` +ecode 多语言切换 + +```javascript +ecCom.WeaLocaleProvider.getLocaleLabelByCode(module).then(() => {//多语言获取成功,此处重绘页面 +}) + +WeaverMobile.Tools.getLocaleLabel(module, () => { + console.log("请求成功") +}) +// 移动端引入组件库多语言信息,放在componentDidMount执行 +WeaverMobile.Tools.getLocaleLabel("common", () => { + this.forceUpdate(); +}) + +// 使用多语言 +WeaverMobile.Tools.getLabel(i18nId, text) + +``` + ### 数据库 **备份mysql数据库** From 381948758977f76cbddeb69285ec3fa752c67ae5 Mon Sep 17 00:00:00 2001 From: wangxuanran <3055088966@qq.com> Date: Sat, 1 Jul 2023 15:43:13 +0800 Subject: [PATCH 09/13] =?UTF-8?q?=E5=AE=89=E6=B0=B8=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=BC=98=E5=8C=96=20cus=5Fget=5Flog=20servic?= =?UTF-8?q?e=E7=BC=96=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../getlog/controller/GetLogController.java | 17 +- .../common/getlog/service/GetLogService.java | 49 ++++- .../data_async/mapper/DataAsyncMapper.java | 8 + .../service/DataAsyncServiceImpl.java | 179 +++++++++--------- .../java/xuanran/wang/eny/DataAsyncTest.java | 2 +- 5 files changed, 165 insertions(+), 90 deletions(-) diff --git a/src/main/java/com/api/ebu7dev1/common/getlog/controller/GetLogController.java b/src/main/java/com/api/ebu7dev1/common/getlog/controller/GetLogController.java index 63c6b37..df94e7c 100644 --- a/src/main/java/com/api/ebu7dev1/common/getlog/controller/GetLogController.java +++ b/src/main/java/com/api/ebu7dev1/common/getlog/controller/GetLogController.java @@ -26,12 +26,27 @@ import java.util.Map; * * @author youHong.ai */ -@Path("/ebu7-dev1/common/log") +@Path("/ebu7-dev1/common/log/") public class GetLogController { private final Logger log = Util.getLogger(); private final GetLogService service = new GetLogService(); + + @GET + @Path("ipList") + @Produces(MediaType.APPLICATION_JSON) + public String getIpList(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User loginUser = HrmUserVarify.getUser(request, response); + String path = request.getRealPath("/"); + return ApiResult.success(service.getIpList(loginUser, path)); + } catch (Exception e) { + log.error("获取ip节点出错 : " + e.getMessage()); + log.error(Util.getErrString(e)); + return ApiResult.error("获取ip节点出错!"); + } + } @GET @Path("get") diff --git a/src/main/java/com/api/ebu7dev1/common/getlog/service/GetLogService.java b/src/main/java/com/api/ebu7dev1/common/getlog/service/GetLogService.java index 58b0094..6b437c5 100644 --- a/src/main/java/com/api/ebu7dev1/common/getlog/service/GetLogService.java +++ b/src/main/java/com/api/ebu7dev1/common/getlog/service/GetLogService.java @@ -2,10 +2,14 @@ package com.api.ebu7dev1.common.getlog.service; import aiyh.utils.Util; import aiyh.utils.excention.CustomerException; +import com.api.ebu7dev1.common.getlog.util.GetLogUtil; +import org.apache.commons.collections.CollectionUtils; import weaver.hrm.User; import javax.ws.rs.core.Response; +import java.io.File; import java.util.Map; +import java.util.Set; /** *

获取日志

@@ -18,13 +22,52 @@ public class GetLogService { public Response get(User loginUser) { return null; } + + /** + *

获取所有的ip地址

+ * @author xuanran.wang + * @dateTime 2023/7/1 14:19 + * @param ecologyPath ec路径 + * @return 集群ip 以及 本地ip + **/ + public Set getIpList(User loginUser, String ecologyPath){ + GetLogUtil.checkUser(loginUser); + String weaverPropertiesPath; + String resinPath = System.getProperty("user.dir") + File.separator; + if (ecologyPath.endsWith(File.separator)) { + weaverPropertiesPath = ecologyPath + "WEB-INF" + File.separator + "prop" + File.separator + "weaver.properties"; + } else { + weaverPropertiesPath = ecologyPath + File.separator + "WEB-INF" + File.separator + "prop" + File.separator + "weaver.properties"; + } + String localIp = GetLogUtil.getInnerIp(); + Set ipList = GetLogUtil.readEcologyProp(weaverPropertiesPath); + if(CollectionUtils.isEmpty(ipList)){ + String resinBinPath = resinPath + "bin" + File.separator + "startresin.sh"; + ipList.addAll(GetLogUtil.readResinProp(resinBinPath)); + } + if (ipList.size() != 0) {//没有集群的时候 + boolean status = false; + for (String ip : ipList) { + if (ip.contains(localIp) || "127.0.0.1".equals(ip) || "127.0.0.1".equals(localIp)) { + status = true; + break; + } + } + if (!status) { + ipList.add(localIp); + } + }else { + ipList.add(localIp); + } + return ipList; + } public String collectLogInfo(User loginUser, Map params) { - if (loginUser.getUID() != 1) { - throw new CustomerException("无权限查看!"); - } + GetLogUtil.checkUser(loginUser); String startDate = Util.null2String(params.get("startDate")); String endDate = Util.null2String(params.get("endDate")); return null; } + + } diff --git a/src/main/java/weaver/xuanran/wang/eny/data_async/mapper/DataAsyncMapper.java b/src/main/java/weaver/xuanran/wang/eny/data_async/mapper/DataAsyncMapper.java index f0e6658..1df7d7a 100644 --- a/src/main/java/weaver/xuanran/wang/eny/data_async/mapper/DataAsyncMapper.java +++ b/src/main/java/weaver/xuanran/wang/eny/data_async/mapper/DataAsyncMapper.java @@ -1,6 +1,7 @@ package weaver.xuanran.wang.eny.data_async.mapper; import aiyh.utils.annotation.recordset.*; +import io.swagger.models.auth.In; import weaver.xuanran.wang.eny.data_async.entity.DataAsyncConfigDetail; import weaver.xuanran.wang.eny.data_async.entity.DataAsyncConfigMain; @@ -53,6 +54,13 @@ public interface DataAsyncMapper { @ParamMapper("min") Integer min, @ParamMapper("max") Integer max); + @Select("select id from $t{tableName} where $t{foreignKey} between #{min} and #{max}") + @CaseConversion(value = false) + List selectDataIdsByForeignKey(@ParamMapper("tableName") String tableName, + @ParamMapper("foreignKey") String foreignKey, + @ParamMapper("min") Integer min, + @ParamMapper("max") Integer max); + @Select(custom = true) String selectCustomerSql(@SqlString String sql, Map map); diff --git a/src/main/java/weaver/xuanran/wang/eny/data_async/service/DataAsyncServiceImpl.java b/src/main/java/weaver/xuanran/wang/eny/data_async/service/DataAsyncServiceImpl.java index eb9e28a..0a6fe6e 100644 --- a/src/main/java/weaver/xuanran/wang/eny/data_async/service/DataAsyncServiceImpl.java +++ b/src/main/java/weaver/xuanran/wang/eny/data_async/service/DataAsyncServiceImpl.java @@ -21,6 +21,7 @@ import weaver.xuanran.wang.eny.data_async.entity.DataAsyncConfigMain; import weaver.xuanran.wang.eny.data_async.mapper.DataAsyncMapper; import weaver.xuanran.wang.eny.data_async.util.EyDataAsyncTokenUtil; import weaver.xuanran.wang.eny.data_async.util.ValueRuleMethod; + import java.util.*; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; @@ -71,7 +72,7 @@ public class DataAsyncServiceImpl { **/ public DataAsyncConfigMain getConfig(String onlyMark) { DataAsyncConfigMain config = asyncMapper.selectConfigByOnlyMark(onlyMark); - if(Objects.isNull(config) || CollectionUtils.isEmpty(config.getConfigDetailList())){ + if (Objects.isNull(config) || CollectionUtils.isEmpty(config.getConfigDetailList())) { throw new CustomerException("该唯一标识在配置表中未找到对应的配置!或存在该配置但是明细数据为空!"); } return config; @@ -79,13 +80,14 @@ public class DataAsyncServiceImpl { /** *

数据同步 有一个点 就是如果接口请求过程中报错了 怎么重新处理

+ * + * @param config 配置对象 + * @param tokenUrl token地址 + * @param params token 参数 * @author xuanran.wang * @dateTime 2023/6/9 13:28 - * @param config 配置对象 - * @param tokenUrl token地址 - * @param params token 参数 **/ - public void asyncData(DataAsyncConfigMain config, String tokenUrl, Map params){ + public void asyncData(DataAsyncConfigMain config, String tokenUrl, Map params) { long startTime = System.currentTimeMillis(); log.info("数据开始同步时间 : " + TimeUtil.getCurrentTimeString()); String asyncUrl = config.getAsync_url(); @@ -101,12 +103,18 @@ public class DataAsyncServiceImpl { CountDownLatch latch = null; int preNum = 0; // 如果不是第一页就先定位到指定位置 - if(pageNo > 1){ + if (pageNo > 1) { count += (pageNo - 1) * pageSize; preNum = count; } + List configDetailList = config.getConfigDetailList(); + List primaryKeyList = configDetailList.stream().filter(item -> item.getPrimary_key() == 0).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(primaryKeyList)) { + throw new CustomerException("请先配置主键字段!"); + } + DataAsyncConfigDetail primaryKey = primaryKeyList.get(0); boolean show = true; - while (count < total){ + while (count < total) { // 从缓存中获取token String token = EyDataAsyncTokenUtil.getToken(tokenUrl, params); header.put("Authorization", "Bearer " + token); @@ -118,11 +126,11 @@ public class DataAsyncServiceImpl { try { // 获取接口数据 data = requestMasterPlate.apiPost(url, new HashMap<>(), header, dataSuccess); - total = Util.getIntValue(Util.null2DefaultStr(data.get("total"),""), -1); - if(show){ + total = Util.getIntValue(Util.null2DefaultStr(data.get("total"), ""), -1); + if (show) { log.info("接口数据条数total : " + total); } - if(latch == null){ + if (latch == null) { // 应该传入 total / pageSize latch = new CountDownLatch(total); } @@ -130,52 +138,57 @@ public class DataAsyncServiceImpl { count += pageSize; List> list = (List>) data.get("list"); // 进行数据处理 - maps = dealData(config, list); + maps = dealData(config, list, primaryKey); show = false; - }catch (Exception e){ + } catch (Exception e) { for (int i = 0; i < pageSize; i++) { - if(latch != null){ + if (latch != null) { latch.countDown(); } } log.error("请求异常 : " + e.getMessage() + " 当前页数 : " + pageNo); - if(latch != null){ + if (latch != null) { log.info("当前latch信号数量 : " + latch.getCount()); } continue; } CountDownLatch finalLatch = latch; - if(finalLatch.getCount() > 0 && maps.size() > 0){ + if (finalLatch.getCount() > 0 && maps.size() > 0) { // 异步提交数据库处理 - threadPoolInstance.execute(()->{ + threadPoolInstance.execute(() -> { log.info("======================================================================================="); + // 查询当天同步的数据 + Map map = parseMaxAndMin(maps, primaryKey); + Integer max = map.get("max"); + Integer min = map.get("min"); log.info(Thread.currentThread().getName() + " 入库之前信号数量 : " + finalLatch.getCount()); boolean success = CusData2OA.baseInsertAndUpdate(config.getModel_id(), maps, finalLatch); log.info("数据库更新标识 : " + success); + if (!success) { + throw new CustomerException("更新数据失败!"); + } log.info(Thread.currentThread().getName() + " 入库之后信号数量 : " + finalLatch.getCount()); + List dataIdList = asyncMapper.selectDataIdsByForeignKey(config.getTable_name(), primaryKey.getModel_field_name(), min, max); + if (CollectionUtils.isNotEmpty(dataIdList)) { + log.info("需要权限重构的数据条数 : " + dataIdList.size()); + for (Integer id : dataIdList) { + moderightinfo.rebuildModeDataShareByEdit(1, Util.getIntValue(config.getModel_id(), -1), id); + } + } log.info("======================================================================================="); }); } } try { - if(latch != null){ + if (latch != null) { log.info("preNum : " + preNum); - while (preNum-- > 0){ + while (preNum-- > 0) { latch.countDown(); } boolean await = latch.await(30, TimeUnit.MINUTES); - if(!await){ + if (!await) { throw new CustomerException("线程等待时间超过最大时间限制!"); } - // 查询当天同步的数据 - // 应该在上面 每一批数据处理完直接权限重构 - List dataIdList = asyncMapper.selectDataIdListByCreateDate(config.getTable_name(), TimeUtil.getCurrentDateString()); - if(CollectionUtils.isNotEmpty(dataIdList)){ - log.info("需要权限重构的数据条数 : " + dataIdList.size()); - for (Integer id : dataIdList) { - moderightinfo.rebuildModeDataShareByEdit(1, Util.getIntValue(config.getModel_id(),-1), id); - } - } log.info("数据结束同步时间 : " + TimeUtil.getCurrentTimeString()); long endTime = System.currentTimeMillis(); log.info("同步耗时时间 " + (endTime - startTime) / 1000 + " s");// 等待所有转换操作完成 @@ -187,64 +200,60 @@ public class DataAsyncServiceImpl { /** *

同步处理数据

+ * + * @param config 配置对象 + * @param data 接口数据 * @author xuanran.wang * @dateTime 2023/6/8 16:50 - * @param config 配置对象 - * @param data 接口数据 **/ - public List> dealData(DataAsyncConfigMain config, List> data) { + public List> dealData(DataAsyncConfigMain config, + List> data, + DataAsyncConfigDetail primaryKey) { List configDetailList = config.getConfigDetailList(); - List primaryKey = configDetailList.stream().filter(item -> item.getPrimary_key() == 0).collect(Collectors.toList()); - List> maps = new ArrayList<>(); - if(CollectionUtils.isNotEmpty(primaryKey)){ - // 模版-接口外键 - String primaryKeyModelFieldName = primaryKey.get(0).getModel_field_name(); - maps = data.stream().map(item -> convert(item, primaryKey.get(0).getInterface_field(), configDetailList)).filter(MapUtils::isNotEmpty).collect(Collectors.toList()); - // 进行排序 - Optional minClassId = maps.stream() - .map(map -> Util.getIntValue(Util.null2DefaultStr(map.get(primaryKeyModelFieldName),""),-1)) - .min(Comparator.naturalOrder()); - Optional maxClassId = maps.stream() - .map(map -> Util.getIntValue(Util.null2DefaultStr(map.get(primaryKeyModelFieldName),""),-1)) - .max(Comparator.naturalOrder()); - Integer min = minClassId.orElse(0); - Integer max = maxClassId.orElse(0); - // 按照外键排序并且在oa中范围查询出外键与oa数据的对应关系 - List> dataIdList = asyncMapper.selectDataIds(primaryKeyModelFieldName, config.getTable_name(), min, max); - if("1".equals(debug)){ - log.info("dataIdList : " + JSONObject.toJSONString(dataIdList)); +// List primaryKey = configDetailList.stream().filter(item -> item.getPrimary_key() == 0).collect(Collectors.toList()); + List> maps; + // 模版-接口外键 + String primaryKeyModelFieldName = primaryKey.getModel_field_name(); + maps = data.stream().map(item -> convert(item, primaryKey.getInterface_field(), configDetailList)).filter(MapUtils::isNotEmpty).collect(Collectors.toList()); + // 进行排序 + Map map = parseMaxAndMin(maps, primaryKey); + Integer max = map.get("max"); + Integer min = map.get("min"); + // 按照外键排序并且在oa中范围查询出外键与oa数据的对应关系 + List> dataIdList = asyncMapper.selectDataIds(primaryKeyModelFieldName, config.getTable_name(), min, max); + if ("1".equals(debug)) { + log.info("dataIdList : " + JSONObject.toJSONString(dataIdList)); + } + if (CollectionUtils.isNotEmpty(dataIdList)) { + HashMap idMap = parseListMap2Map(primaryKeyModelFieldName, "id", dataIdList); + if ("1".equals(debug)) { + log.info("idMap : " + JSONObject.toJSONString(idMap)); } - if(CollectionUtils.isNotEmpty(dataIdList)){ - HashMap idMap = parseListMap2Map(primaryKeyModelFieldName, "id", dataIdList); - if("1".equals(debug)){ - log.info("idMap : " + JSONObject.toJSONString(idMap)); + maps.forEach(item -> { + if ("1".equals(debug)) { + log.info("item : " + JSONObject.toJSONString(item)); } - maps.forEach(item->{ - if("1".equals(debug)){ - log.info("item : " + JSONObject.toJSONString(item)); - } - String id = Util.null2DefaultStr(item.get(primaryKeyModelFieldName),""); - if("1".equals(debug)){ - log.info("id : " + id); - } - if(idMap.containsKey(id)){ - String oaId = idMap.get(id); - item.put("id",oaId); - } - }); - } + String id = Util.null2DefaultStr(item.get(primaryKeyModelFieldName), ""); + if ("1".equals(debug)) { + log.info("id : " + id); + } + if (idMap.containsKey(id)) { + String oaId = idMap.get(id); + item.put("id", oaId); + } + }); } return maps; } - public Map parseMaxAndMin(List> maps, DataAsyncConfigDetail primaryKey){ + public Map parseMaxAndMin(List> maps, DataAsyncConfigDetail primaryKey) { String primaryKeyModelFieldName = primaryKey.getModel_field_name(); // 进行排序 Optional minClassId = maps.stream() - .map(map -> Util.getIntValue(Util.null2DefaultStr(map.get(primaryKeyModelFieldName),""),-1)) + .map(map -> Util.getIntValue(Util.null2DefaultStr(map.get(primaryKeyModelFieldName), ""), -1)) .min(Comparator.naturalOrder()); Optional maxClassId = maps.stream() - .map(map -> Util.getIntValue(Util.null2DefaultStr(map.get(primaryKeyModelFieldName),""),-1)) + .map(map -> Util.getIntValue(Util.null2DefaultStr(map.get(primaryKeyModelFieldName), ""), -1)) .max(Comparator.naturalOrder()); Integer min = minClassId.orElse(0); Integer max = maxClassId.orElse(0); @@ -257,18 +266,19 @@ public class DataAsyncServiceImpl { /** *

将数据进行转换

- * @author xuanran.wang - * @dateTime 2023/6/9 13:27 - * @param data 原始数据 - * @param foreignKey 外键 + * + * @param data 原始数据 + * @param foreignKey 外键 * @param configDetailList 配置集合 * @return 转换后的数据 + * @author xuanran.wang + * @dateTime 2023/6/9 13:27 **/ public Map convert(Map data, String foreignKey, - List configDetailList){ + List configDetailList) { String foreignVal = Util.null2DefaultStr(data.get(foreignKey), ""); - if(StringUtils.isBlank(foreignVal)){ + if (StringUtils.isBlank(foreignVal)) { return new HashMap<>(); } HashMap map = new HashMap<>(); @@ -280,19 +290,20 @@ public class DataAsyncServiceImpl { /** *

将集合数据放到缓存中

+ * + * @param listMap 集合数据 * @author xuanran.wang * @dateTime 2023/4/10 18:33 - * @param listMap 集合数据 **/ - public static HashMap parseListMap2Map(String key, String value, List> listMap){ - if(CollectionUtils.isEmpty(listMap)){ + public static HashMap parseListMap2Map(String key, String value, List> listMap) { + if (CollectionUtils.isEmpty(listMap)) { return new HashMap<>(); } HashMap res = new HashMap<>(); listMap.forEach(map -> { - String outKey = Util.null2DefaultStr(map.get(key),""); - if(StringUtils.isNotBlank(outKey)){ - String id = Util.null2DefaultStr(map.get(value),""); + String outKey = Util.null2DefaultStr(map.get(key), ""); + if (StringUtils.isNotBlank(outKey)) { + String id = Util.null2DefaultStr(map.get(value), ""); res.put(outKey, id); } }); @@ -300,6 +311,4 @@ public class DataAsyncServiceImpl { } - - } diff --git a/src/test/java/xuanran/wang/eny/DataAsyncTest.java b/src/test/java/xuanran/wang/eny/DataAsyncTest.java index 356b937..64ca6d3 100644 --- a/src/test/java/xuanran/wang/eny/DataAsyncTest.java +++ b/src/test/java/xuanran/wang/eny/DataAsyncTest.java @@ -37,7 +37,7 @@ public class DataAsyncTest extends BaseTest { String clientId = "6d067ac6c14211ed8fd700163e1331c6"; String appId = "WEAVER"; String appSecret = "7b09e5f7c14211ed8fd700163e1331c6"; - int pageSize = 500; + int pageSize = 100; int pageNo = 25; dataAsyncService.setPageSize(25); dataAsyncService.setPageSize(pageSize); From 6546fc05f534fc9dea10781371fb6113b518bf28 Mon Sep 17 00:00:00 2001 From: "youhong.ai" Date: Mon, 3 Jul 2023 12:51:33 +0800 Subject: [PATCH 10/13] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/aiyh/utils/Util.java | 90 ++++++++ .../java/aiyh/utils/entity/DocImageInfo.java | 14 ++ .../java/aiyh/utils/entity/FieldViewInfo.java | 3 + .../java/aiyh/utils/mapper/UtilMapper.java | 28 ++- .../impl/CompressDocPictureImpl.java | 85 +++++++ .../mapper/CompressDocPictureMapper.java | 30 +++ .../util/CompressPictureUtil.java | 214 ++++++++++++++++++ .../java/youhong/ai/taibao/TestTaiBao.java | 2 +- .../youhong/ai/utiltest/ImageCompressor.java | 178 +++++++++++++++ .../ai/utiltest/UtilAPiResultTest.java | 202 +++++++++++++++++ .../utiltest/resultjsonparase/ParseTest.java | 170 ++++++++++++++ .../config/DetailTableAlias.java | 26 +++ .../config/DetailTableConfig.java | 31 +++ .../resultjsonparase/config/MainTable.java | 29 +++ 14 files changed, 1098 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/customization/youhong/taibao/compresspicture/impl/CompressDocPictureImpl.java create mode 100644 src/main/java/com/customization/youhong/taibao/compresspicture/mapper/CompressDocPictureMapper.java create mode 100644 src/main/java/com/customization/youhong/taibao/compresspicture/util/CompressPictureUtil.java create mode 100644 src/test/java/youhong/ai/utiltest/ImageCompressor.java create mode 100644 src/test/java/youhong/ai/utiltest/UtilAPiResultTest.java create mode 100644 src/test/java/youhong/ai/utiltest/resultjsonparase/ParseTest.java create mode 100644 src/test/java/youhong/ai/utiltest/resultjsonparase/config/DetailTableAlias.java create mode 100644 src/test/java/youhong/ai/utiltest/resultjsonparase/config/DetailTableConfig.java create mode 100644 src/test/java/youhong/ai/utiltest/resultjsonparase/config/MainTable.java diff --git a/src/main/java/aiyh/utils/Util.java b/src/main/java/aiyh/utils/Util.java index 357e947..b1ff738 100644 --- a/src/main/java/aiyh/utils/Util.java +++ b/src/main/java/aiyh/utils/Util.java @@ -3034,6 +3034,10 @@ public class Util extends weaver.general.Util { return mapper.selectDocImageInfo(docId); } + public static DocImageInfo selectImageInfoByImageId(String imageFileId) { + return mapper.selectImageInfoByImageId(imageFileId); + } + /** * 查询文档信息 * @@ -3587,15 +3591,99 @@ public class Util extends weaver.general.Util { String field = matcher.group("field"); String otherKeyStr = matcher.group("other"); Object o = valueHandler(arg, field); + if (null == o) { throw new CustomerException(Util.logStr("can not get value of [{}] from [{}], this keyStr is [{}]", field, JSON.toJSONString(arg), keyStr)); } + if (o instanceof Collection) { + return new CustomerException("can not supper array value!"); + } return getValueByKeyStr(otherKeyStr, o); } throw new CustomerException("Unable to find value of key [" + keyStr + "]"); } + /** + *

通过keyStr获取value

+ * + * @param keyStr keyString + * @param arg map对象 + * @return value + */ + public static ValueOrList getValueOrListByKeyStr(String keyStr, Object arg) { + if (arg == null) { + return null; + } + if (!keyStr.contains(".")) { + Object o = valueHandler(arg, keyStr); + ValueOrList valueOrList = new ValueOrList(); + valueOrList.setValue(o); + valueOrList.setKey(keyStr); + return valueOrList; + } + String pattern = "(?^[\\w]+[\\w$]*)\\.*(?(\\S+)*)"; + Pattern compile = Pattern.compile(pattern); + Matcher matcher = compile.matcher(keyStr); + if (matcher.find()) { + String field = matcher.group("field"); + String otherKeyStr = matcher.group("other"); + Object o = valueHandler(arg, field); + if (null == o) { + throw new CustomerException(Util.logStr("can not get value of [{}] from [{}], this keyStr is [{}]", + field, JSON.toJSONString(arg), keyStr)); + } + if (o instanceof Collection) { + ValueOrList valueOrList = new ValueOrList(); + valueOrList.setValue(o); + valueOrList.setArray(true); + valueOrList.setKey(field); + return valueOrList; + } + return getValueOrListByKeyStr(otherKeyStr, o); + } + throw new CustomerException("Unable to find value of key [" + keyStr + "]"); + } + + public static class ValueOrList { + private String key; + private boolean isArray; + private Object value; + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public boolean isArray() { + return isArray; + } + + public void setArray(boolean array) { + isArray = array; + } + + public Object getValue() { + return value; + } + + public void setValue(Object value) { + this.value = value; + } + + @Override + public String toString() { + return "ValueOrList{" + + "key='" + key + '\'' + + ", isArray=" + isArray + + ", value=" + value + + '}'; + } + } + /** *

获取value

* @@ -3979,4 +4067,6 @@ public class Util extends weaver.general.Util { } } } + + } diff --git a/src/main/java/aiyh/utils/entity/DocImageInfo.java b/src/main/java/aiyh/utils/entity/DocImageInfo.java index f224ac6..f3b3136 100644 --- a/src/main/java/aiyh/utils/entity/DocImageInfo.java +++ b/src/main/java/aiyh/utils/entity/DocImageInfo.java @@ -41,4 +41,18 @@ public class DocImageInfo { /** 文件类型 */ @SqlOracleDbFieldAnn("DOC_FILE_TYPE") private Integer docFileType; + /** 文件路径 */ + @SqlOracleDbFieldAnn("PATH") + private String path; + + /** 加密code */ + @SqlOracleDbFieldAnn("AES_CODE") + private String aesCode; + + /** 文件token */ + @SqlOracleDbFieldAnn("TOKEN_KEY") + private String tokenKey; + /** 缩略图 */ + @SqlOracleDbFieldAnn("MINI_IMG_PATH") + private String miniImgPath; } diff --git a/src/main/java/aiyh/utils/entity/FieldViewInfo.java b/src/main/java/aiyh/utils/entity/FieldViewInfo.java index 0240c5f..d1a5c74 100644 --- a/src/main/java/aiyh/utils/entity/FieldViewInfo.java +++ b/src/main/java/aiyh/utils/entity/FieldViewInfo.java @@ -46,4 +46,7 @@ public class FieldViewInfo { @SqlOracleDbFieldAnn("FIELD_HTML_TYPE") private String fieldHtmlType; + + + private Object value; } diff --git a/src/main/java/aiyh/utils/mapper/UtilMapper.java b/src/main/java/aiyh/utils/mapper/UtilMapper.java index 7382768..9cb8bd6 100644 --- a/src/main/java/aiyh/utils/mapper/UtilMapper.java +++ b/src/main/java/aiyh/utils/mapper/UtilMapper.java @@ -56,28 +56,34 @@ public interface UtilMapper { @Select("select di.id id,dc.id doc_id," + + "img.FILEREALPATH path,img.AESCODE aes_code,img.TOKENKEY token_key,MINIIMGPATH mini_img_path," + "di.imagefileid image_file_id," + "dc.DOCCREATEDATE doc_create_date,dc.DOCCREATETIME doc_create_time," + - "(case when imagefilename = '' or imagefilename is null then dc.DOCSUBJECT else imagefilename end) image_file_name " + + "(case when di.imagefilename = '' or di.imagefilename is null then dc.DOCSUBJECT else di.imagefilename end) image_file_name " + "from DocDetail dc " + + "left join imagefile img on img.IMAGEFILEID = di.IMAGEFILEID " + "left join docimagefile di on (dc.id = #{docId} and dc.id = di.docid) " + "where dc.id = #{docId} ") DocImageInfo selectDocImageInfo(@ParamMapper("docId") String docId); @Select("select di.id id,dc.id doc_id," + + "img.FILEREALPATH path,img.AESCODE aes_code,img.TOKENKEY token_key,MINIIMGPATH mini_img_path," + "di.imagefileid image_file_id, di.docfiletype doc_file_type," + "dc.DOCCREATEDATE doc_create_date,dc.DOCCREATETIME doc_create_time," + - "(case when imagefilename = '' or imagefilename is null then dc.DOCSUBJECT else imagefilename end) image_file_name " + + "(case when di.imagefilename = '' or di.imagefilename is null then dc.DOCSUBJECT else di.imagefilename end) image_file_name " + "from DocDetail dc " + + "left join imagefile img on img.IMAGEFILEID = di.IMAGEFILEID " + "left join docimagefile di on (dc.id in ($t{docIds}) and dc.id = di.docid )" + "where dc.id in ($t{docIds})") List selectDocImageInfos(@ParamMapper("docIds") String docIds); @Select("select di.id id,dc.id doc_id," + + "img.FILEREALPATH path,img.AESCODE aes_code,img.TOKENKEY token_key,MINIIMGPATH mini_img_path," + "di.imagefileid image_file_id, di.docfiletype doc_file_type," + "dc.DOCCREATEDATE doc_create_date,dc.DOCCREATETIME doc_create_time," + - "(case when imagefilename = '' or imagefilename is null then dc.DOCSUBJECT else imagefilename end) image_file_name " + + "(case when di.imagefilename = '' or di.imagefilename is null then dc.DOCSUBJECT else di.imagefilename end) image_file_name " + "from DocDetail dc " + + "left join imagefile img on img.IMAGEFILEID = di.IMAGEFILEID " + "left join docimagefile di on (dc.id in ($t{docIds}) and dc.id = di.docid )" + "where dc.id in ($t{docIds})") List selectDocImageInfos(@ParamMapper("docIds") String[] docIds); @@ -197,4 +203,20 @@ public interface UtilMapper { @Select("select id, tablename table_name, indexdesc index_desc from mode_bill_info_view where id = #{id}") ModelTableInfo selectModelTableInfo(Integer id); + + @Select("select di.id id,dc.id doc_id, " + + "img.FILEREALPATH path,img.AESCODE aes_code,img.TOKENKEY token_key,img.MINIIMGPATH mini_img_path," + + " di.imagefileid image_file_id, " + + " dc.DOCCREATEDATE doc_create_date, " + + " dc.DOCCREATETIME doc_create_time, " + + " (case when " + + " di.imagefilename = '' or di.imagefilename is null " + + " then dc.DOCSUBJECT " + + " else di.imagefilename end " + + " ) image_file_name " + + "from imagefile img " + + "left join docimagefile di on img.IMAGEFILEID = di.IMAGEFILEID " + + "left join docdetail dc on di.DOCID = dc.ID " + + " where img.IMAGEFILEID = #{imageId}") + DocImageInfo selectImageInfoByImageId(String imageFileId); } diff --git a/src/main/java/com/customization/youhong/taibao/compresspicture/impl/CompressDocPictureImpl.java b/src/main/java/com/customization/youhong/taibao/compresspicture/impl/CompressDocPictureImpl.java new file mode 100644 index 0000000..99a4f40 --- /dev/null +++ b/src/main/java/com/customization/youhong/taibao/compresspicture/impl/CompressDocPictureImpl.java @@ -0,0 +1,85 @@ +package com.customization.youhong.taibao.compresspicture.impl; + +import aiyh.utils.Util; +import aiyh.utils.entity.DocImageInfo; +import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil; +import aiyh.utils.tool.cn.hutool.core.util.StrUtil; +import com.api.doc.detail.util.DocDownloadCheckUtil; +import com.customization.youhong.taibao.compresspicture.mapper.CompressDocPictureMapper; +import com.customization.youhong.taibao.compresspicture.util.CompressPictureUtil; +import com.weaverboot.frame.ioc.anno.classAnno.WeaIocReplaceComponent; +import com.weaverboot.frame.ioc.anno.methodAnno.WeaReplaceAfter; +import com.weaverboot.frame.ioc.handler.replace.weaReplaceParam.impl.WeaAfterReplaceParam; +import org.apache.log4j.Logger; +import weaver.file.ImageFileManager; + +import java.io.InputStream; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + *

压缩图片

+ * + *

create: 2023/7/1 16:17

+ * + * @author youHong.ai + */ + +@WeaIocReplaceComponent("CompressDocPictureService") +public class CompressDocPictureImpl { + + private final CompressDocPictureMapper mapper = Util.getMapper(CompressDocPictureMapper.class); + + private final Logger log = Util.getLogger(); + + /** + * 这个是接口后置方法,大概的用法跟前置方法差不多,稍有差别 + * 注解名称为WeaReplaceAfter + * 返回类型必须为String + * 参数叫WeaAfterReplaceParam,这个类前四个参数跟前置方法的那个相同,不同的是多了一个叫data的String,这个是那个接口执行完返回的报文 + * 你可以对那个报文进行操作,然后在这个方法里return回去 + */ + @WeaReplaceAfter(value = "/api/doc/save/save", order = 1) + public String after(WeaAfterReplaceParam weaAfterReplaceParam) { + String data = weaAfterReplaceParam.getData(); + try { + Map paramMap = weaAfterReplaceParam.getParamMap(); + String doccontent = Util.null2String(paramMap.get("doccontent")); + if (StrUtil.isBlank(doccontent)) { + return data; + } + List imgSrcList = CompressPictureUtil.parseImageSrc(doccontent); + if (CollectionUtil.isEmpty(imgSrcList)) { + return data; + } + for (String imgSrc : imgSrcList) { + String imageFileIdEncrypt = CompressPictureUtil.extractFileId(imgSrc); + String imageFileId = DocDownloadCheckUtil.DncodeFileid(imageFileIdEncrypt); + DocImageInfo docImageInfo = Util.selectImageInfoByImageId(imageFileId); + if (StrUtil.isNotBlank(docImageInfo.getMiniImgPath())) { + continue; + } + InputStream inputStreamById = ImageFileManager.getInputStreamById(Integer.parseInt(imageFileId)); + InputStream quality = CompressPictureUtil.compressImage(inputStreamById, docImageInfo.getImageFileName(), + Float.parseFloat(Util.getCusConfigValueNullOrEmpty("quality", "0.5"))); + if (Objects.isNull(quality)) { + continue; + } + int newImageFileId = Util.createFileByInputSteam(quality, docImageInfo.getImageFileName()); + if (newImageFileId <= 0) { + continue; + } + DocImageInfo newDocImageInfo = Util.selectImageInfoByImageId(Util.null2String(newImageFileId)); + boolean flag = mapper.updateImageInfo(docImageInfo, newDocImageInfo); + if (flag) { + mapper.updateImageInfo(docImageInfo, newDocImageInfo); + } + } + } catch (Exception e) { + log.error("压缩文件出现异常:" + Util.getErrString(e)); + } + // 这个就是接口执行完的报文 + return data; + } +} diff --git a/src/main/java/com/customization/youhong/taibao/compresspicture/mapper/CompressDocPictureMapper.java b/src/main/java/com/customization/youhong/taibao/compresspicture/mapper/CompressDocPictureMapper.java new file mode 100644 index 0000000..37718b6 --- /dev/null +++ b/src/main/java/com/customization/youhong/taibao/compresspicture/mapper/CompressDocPictureMapper.java @@ -0,0 +1,30 @@ +package com.customization.youhong.taibao.compresspicture.mapper; + +import aiyh.utils.annotation.recordset.ParamMapper; +import aiyh.utils.annotation.recordset.SqlMapper; +import aiyh.utils.annotation.recordset.Update; +import aiyh.utils.entity.DocImageInfo; + +/** + *

+ * + *

create: 2023/7/1 16:41

+ * + * @author youHong.ai + */ +@SqlMapper +public interface CompressDocPictureMapper { + + /** + *

更新文件信息

+ * @param docImageInfo 老文件信息 + * @param newDocImageInfo 新文件信息 + * @return 是否更新成功 + */ + + @Update("update imagefile set FILEREALPATH = #{new.path},AESCODE = #{new.aesCode}," + + "TOKENKEY = #{new.tokenKey},FILESIZE = #{new.fileSize}," + + "MINIIMGPATH= #{old.imageFileId} where IMAGEFILEID = #{old.imageFileId}") + boolean updateImageInfo(@ParamMapper("old") DocImageInfo docImageInfo, + @ParamMapper("new") DocImageInfo newDocImageInfo); +} diff --git a/src/main/java/com/customization/youhong/taibao/compresspicture/util/CompressPictureUtil.java b/src/main/java/com/customization/youhong/taibao/compresspicture/util/CompressPictureUtil.java new file mode 100644 index 0000000..07ab5d9 --- /dev/null +++ b/src/main/java/com/customization/youhong/taibao/compresspicture/util/CompressPictureUtil.java @@ -0,0 +1,214 @@ +package com.customization.youhong.taibao.compresspicture.util; + +import aiyh.utils.excention.CustomerException; +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; +import org.jsoup.select.Elements; + +import javax.imageio.IIOImage; +import javax.imageio.ImageIO; +import javax.imageio.ImageWriteParam; +import javax.imageio.ImageWriter; +import javax.imageio.stream.ImageOutputStream; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + *

压缩工具类

+ * + *

create: 2023/7/1 16:20

+ * + * @author youHong.ai + */ +public class CompressPictureUtil { + + /** + *

压缩图片

+ * + * @param inputStream 图片文件流 + * @param fileName 文件名称 + * @param quality 图片质量 + * @return 压缩后的文件 + */ + public static InputStream compressImage(InputStream inputStream, String fileName, float quality) { + try { + // 读取输入图像流 + BufferedImage image = ImageIO.read(inputStream); + + // 获取图像格式 + String formatName = getFormatName(fileName); + + // 根据图像格式进行不同的压缩处理 + if (formatName.equalsIgnoreCase("png")) { + return compressPNG(image, quality); + } else if (formatName.equalsIgnoreCase("jepg")) { + return compressJPEG(image, quality); + } else { + return null; + } + } catch (IOException e) { + throw new CustomerException(e); + } + } + + /** + *

压缩png文件

+ * + * @param image 图片 + * @param quality 图片质量 + * @return 压缩后文件 + * @throws IOException io异常 + */ + private static InputStream compressPNG(BufferedImage image, float quality) throws IOException { + int originalWidth = image.getWidth(); + int originalHeight = image.getHeight(); + + // 计算压缩后的宽度和高度 + int compressedWidth = (int) (originalWidth * quality); + int compressedHeight = (int) (originalHeight * quality); + + // 创建压缩后的图像 + BufferedImage compressedImage = new BufferedImage(compressedWidth, compressedHeight, BufferedImage.TYPE_INT_ARGB); + Graphics2D g2d = compressedImage.createGraphics(); + g2d.drawImage(image, 0, 0, compressedWidth, compressedHeight, null); + g2d.dispose(); + + // 将压缩后的图像保存到字节数组输出流 + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + ImageIO.write(compressedImage, "png", outputStream); + + return new ByteArrayInputStream(outputStream.toByteArray()); + } + + /** + *

压缩jpeg图片

+ * + * @param image 图片 + * @param quality 图片质量 + * @return 压缩后图片 + * @throws IOException io异常 + */ + + private static InputStream compressJPEG(BufferedImage image, float quality) throws IOException { + // 创建压缩参数 + ImageWriter writer = ImageIO.getImageWritersByFormatName("jpeg").next(); + ImageWriteParam writeParam = writer.getDefaultWriteParam(); + writeParam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); + writeParam.setCompressionQuality(quality); + + // 将压缩后的图像保存到字节数组输出流 + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream(outputStream); + writer.setOutput(imageOutputStream); + writer.write(null, new IIOImage(image, null, null), writeParam); + + // 关闭资源 + writer.dispose(); + imageOutputStream.close(); + outputStream.close(); + + return new ByteArrayInputStream(outputStream.toByteArray()); + } + + /** + *

格式化图片后缀

+ * + * @param fileName 文件名称 + * @return 文件后缀 + */ + private static String getFormatName(String fileName) { + String formatName = fileName.substring(fileName.lastIndexOf('.') + 1).toLowerCase(); + if (formatName.equals("jpg") || formatName.equals("jpeg")) { + return "jpeg"; + } + return formatName; + } + + /** + *

解析html中的img的src

+ * + * @param html html字符串 + * @return 所有的src + */ + public static List parseImageSrc(String html) { + List srcList = new ArrayList<>(); + + // 使用 Jsoup 解析 HTML 字符串 + Document document = Jsoup.parse(html); + + // 获取所有的 img 标签 + Elements imgElements = document.select("img"); + + // 使用迭代器遍历 img 标签,并获取其 src 属性值 + Iterator iterator = imgElements.iterator(); + while (iterator.hasNext()) { + Element imgElement = iterator.next(); + String src = imgElement.attr("src"); + srcList.add(src); + } + + return srcList; + } + + /** + *

获取文件id

+ * + * @param input 输入字符串 + * @return 文件id + */ + public static String extractFileId(String input) { + String fileId = null; + + // 寻找 "fileid=" 的索引位置 + int index = input.indexOf("fileid="); + if (index != -1) { + // 截取 "fileid=" 后面的部分 + String substring = input.substring(index + 7); + + // 查找第一个 "&" 符号的索引位置 + int endIndex = substring.indexOf("&"); + if (endIndex != -1) { + // 截取从 "fileid=" 后面到第一个 "&" 符号之前的部分 + fileId = substring.substring(0, endIndex); + } else { + // 如果没有 "&" 符号,截取从 "fileid=" 后面到字符串末尾的部分 + fileId = substring; + } + } + + return fileId; + } + + /** + *

替换fieldId

+ * + * @param input 带替换的字符串 + * @param newFileId 新文件id + * @return 完整字符串 + */ + public static String replaceFileId(String input, String newFileId) { + // 寻找 "fileid=" 的索引位置 + int index = input.indexOf("fileid="); + if (index != -1) { + // 查找第一个 "&" 符号的索引位置 + int endIndex = input.indexOf("&", index); + if (endIndex != -1) { + // 替换 "fileid=" 后面到第一个 "&" 符号之前的部分 + return input.substring(0, index + 7) + newFileId + input.substring(endIndex); + } else { + // 替换 "fileid=" 后面到字符串末尾的部分 + return input.substring(0, index + 7) + newFileId; + } + } + + return input; + } +} diff --git a/src/test/java/youhong/ai/taibao/TestTaiBao.java b/src/test/java/youhong/ai/taibao/TestTaiBao.java index 5982a67..77ee856 100644 --- a/src/test/java/youhong/ai/taibao/TestTaiBao.java +++ b/src/test/java/youhong/ai/taibao/TestTaiBao.java @@ -198,6 +198,6 @@ public class TestTaiBao extends BaseTest { @Test public void testjlsdfj() { - System.out.println(DocDownloadCheckUtil.DncodeFileid("a1c0c56773deeff8d8f7f235f3eb3db0d2b34cbedb9ff32262414a3c6c4b9a393fc01656cc42ddaf07cd9319d68901a734f710fbddd167603")); + System.out.println(DocDownloadCheckUtil.DncodeFileid("a5f32cb1a24896143ca3fd93e0a5c607025a5f365a565ba4f2b6c1953e67cd25f818d80a51ade71c550289e5065f9a2f22f2a2a27772bc6eb")); } } diff --git a/src/test/java/youhong/ai/utiltest/ImageCompressor.java b/src/test/java/youhong/ai/utiltest/ImageCompressor.java new file mode 100644 index 0000000..a3accb0 --- /dev/null +++ b/src/test/java/youhong/ai/utiltest/ImageCompressor.java @@ -0,0 +1,178 @@ +package youhong.ai.utiltest; + +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; +import org.jsoup.select.Elements; + +import javax.imageio.IIOImage; +import javax.imageio.ImageIO; +import javax.imageio.ImageWriteParam; +import javax.imageio.ImageWriter; +import javax.imageio.stream.ImageOutputStream; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.io.*; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +public class ImageCompressor { + public static InputStream compressImage(InputStream inputStream, String fileName, float quality) { + try { + // 读取输入图像流 + BufferedImage image = ImageIO.read(inputStream); + + // 获取图像格式 + String formatName = getFormatName(fileName); + + // 根据图像格式进行不同的压缩处理 + if (formatName.equals("png")) { + return compressPNG(image, quality); + } else { + return compressJPEG(image, quality); + } + } catch (IOException e) { + e.printStackTrace(); + return null; + } + } + + private static InputStream compressPNG(BufferedImage image, float quality) throws IOException { + int originalWidth = image.getWidth(); + int originalHeight = image.getHeight(); + + // 计算压缩后的宽度和高度 + int compressedWidth = (int) (originalWidth * quality); + int compressedHeight = (int) (originalHeight * quality); + + // 创建压缩后的图像 + BufferedImage compressedImage = new BufferedImage(compressedWidth, compressedHeight, BufferedImage.TYPE_INT_ARGB); + Graphics2D g2d = compressedImage.createGraphics(); + g2d.drawImage(image, 0, 0, compressedWidth, compressedHeight, null); + g2d.dispose(); + + // 将压缩后的图像保存到字节数组输出流 + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + ImageIO.write(compressedImage, "png", outputStream); + + return new ByteArrayInputStream(outputStream.toByteArray()); + } + + private static InputStream compressJPEG(BufferedImage image, float quality) throws IOException { + // 创建压缩参数 + ImageWriter writer = ImageIO.getImageWritersByFormatName("jpeg").next(); + ImageWriteParam writeParam = writer.getDefaultWriteParam(); + writeParam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); + writeParam.setCompressionQuality(quality); + + // 将压缩后的图像保存到字节数组输出流 + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream(outputStream); + writer.setOutput(imageOutputStream); + writer.write(null, new IIOImage(image, null, null), writeParam); + + // 关闭资源 + writer.dispose(); + imageOutputStream.close(); + outputStream.close(); + + return new ByteArrayInputStream(outputStream.toByteArray()); + } + + private static String getFormatName(String fileName) { + String formatName = fileName.substring(fileName.lastIndexOf('.') + 1).toLowerCase(); + if (formatName.equals("jpg") || formatName.equals("jpeg")) { + return "jpeg"; + } + return formatName; + } + + public static List parseImageSrc(String html) { + List srcList = new ArrayList<>(); + + // 使用 Jsoup 解析 HTML 字符串 + Document document = Jsoup.parse(html); + + // 获取所有的 img 标签 + Elements imgElements = document.select("img"); + + // 使用迭代器遍历 img 标签,并获取其 src 属性值 + Iterator iterator = imgElements.iterator(); + while (iterator.hasNext()) { + Element imgElement = iterator.next(); + String src = imgElement.attr("src"); + srcList.add(src); + } + + return srcList; + } + + public static String extractFileId(String input) { + String fileId = null; + + // 寻找 "fileid=" 的索引位置 + int index = input.indexOf("fileid="); + if (index != -1) { + // 截取 "fileid=" 后面的部分 + String substring = input.substring(index + 7); + + // 查找第一个 "&" 符号的索引位置 + int endIndex = substring.indexOf("&"); + if (endIndex != -1) { + // 截取从 "fileid=" 后面到第一个 "&" 符号之前的部分 + fileId = substring.substring(0, endIndex); + } else { + // 如果没有 "&" 符号,截取从 "fileid=" 后面到字符串末尾的部分 + fileId = substring; + } + } + + return fileId; + } + + public static void main(String[] args) throws FileNotFoundException { + List strings = parseImageSrc("\n" + + "\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\n" + + "\n" + + "

alkjasf

\n" + + "\n" + + "

\"\"

\n" + + "\n" + + "

\"\"

\n" + + "\n" + + "\n"); + System.out.println(strings); + for (String string : strings) { + String s = extractFileId(string); + System.out.println(s); + } + // // 示例用法 + // InputStream inputStream = new FileInputStream("/Users/aoey.oct.22/Pictures/PleaseLookForwardToIt.png"); + // InputStream compressedInputStream = compressImage(inputStream, "PleaseLookForwardToIt.png", 0.5f); + // if (compressedInputStream != null) { + // // 将压缩后的输入流写入到文件中 + // String outputFilePath = "/Users/aoey.oct.22/Pictures/PleaseLookForwardToIt_yasuo_1.png"; + // try (OutputStream outputStream = new FileOutputStream(outputFilePath)) { + // byte[] buffer = new byte[1024]; + // int bytesRead; + // while ((bytesRead = compressedInputStream.read(buffer)) != -1) { + // outputStream.write(buffer, 0, bytesRead); + // } + // System.out.println("压缩后的图像文件已保存:" + outputFilePath); + // } catch (IOException e) { + // e.printStackTrace(); + // } + // } + } +} + + + diff --git a/src/test/java/youhong/ai/utiltest/UtilAPiResultTest.java b/src/test/java/youhong/ai/utiltest/UtilAPiResultTest.java new file mode 100644 index 0000000..c69670f --- /dev/null +++ b/src/test/java/youhong/ai/utiltest/UtilAPiResultTest.java @@ -0,0 +1,202 @@ +package youhong.ai.utiltest; + +import aiyh.utils.Util; +import aiyh.utils.entity.FieldViewInfo; +import aiyh.utils.excention.CustomerException; +import aiyh.utils.tool.cn.hutool.core.bean.BeanUtil; +import basetest.BaseTest; +import com.alibaba.fastjson.JSON; +import org.junit.Test; +import youhong.ai.mymapper.util.Builder; + +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + *

测试

+ * + *

create: 2023/7/1 18:33

+ * + * @author youHong.ai + */ +public class UtilAPiResultTest extends BaseTest { + + + @Test + public void test() { + List> dt1 = new ArrayList>() {{ + add(new HashMap() {{ + put("apiPath", "data.name"); + put("field", Builder.builder(FieldViewInfo::new) + .with(FieldViewInfo::setTableName, "main") + .with(FieldViewInfo::setFieldName, "name") + .build()); + + }}); + add(new HashMap() {{ + put("apiPath", "data.age"); + put("field", Builder.builder(FieldViewInfo::new) + .with(FieldViewInfo::setTableName, "main") + .with(FieldViewInfo::setFieldName, "age") + .build()); + }}); + add(new HashMap() {{ + put("apiPath", "workList.time"); + put("field", Builder.builder(FieldViewInfo::new) + .with(FieldViewInfo::setTableName, "dt_1") + .with(FieldViewInfo::setFieldName, "time") + .build()); + }}); + add(new HashMap() {{ + put("apiPath", "workList.title"); + put("field", Builder.builder(FieldViewInfo::new) + .with(FieldViewInfo::setTableName, "dt_1") + .with(FieldViewInfo::setFieldName, "title") + .build()); + }}); + add(new HashMap() {{ + put("apiPath", "friends.name"); + put("field", Builder.builder(FieldViewInfo::new) + .with(FieldViewInfo::setTableName, "dt_2") + .with(FieldViewInfo::setFieldName, "name") + .build()); + }}); + add(new HashMap() {{ + put("apiPath", "friends.age"); + put("field", Builder.builder(FieldViewInfo::new) + .with(FieldViewInfo::setTableName, "dt_2") + .with(FieldViewInfo::setFieldName, "age") + .build()); + }}); + }}; + List> dt2 = new ArrayList>() {{ + add(new HashMap() {{ + put("apiPath", "data.workList"); + put("alias", "workList"); + }}); + add(new HashMap() {{ + put("apiPath", "data.friends"); + put("alias", "friends"); + }}); + }}; + + Map result = new HashMap() {{ + put("code", 200); + put("data", new HashMap() {{ + put("name", "test"); + put("age", "18"); + put("workList", new ArrayList>() {{ + add(new HashMap() {{ + put("time", "2023-07-01"); + put("title", "吃饭"); + }}); + add(new HashMap() {{ + put("time", "2023-07-02"); + put("title", "写代码"); + }}); + add(new HashMap() {{ + put("time", "2023-07-03"); + put("title", "睡觉"); + }}); + }}); + put("friends", new ArrayList>() {{ + add(new HashMap() {{ + put("name", "xiao"); + put("age", 18); + }}); + add(new HashMap() {{ + put("name", "wang"); + put("age", 18); + }}); + add(new HashMap() {{ + put("name", "he"); + put("age", 18); + }}); + }}); + }}); + }}; + Map bigMap = new HashMap<>(); + Map tempResult = new HashMap<>(result); + for (Map map : dt2) { + tempResult.putAll(bigMap); + Object apiPathObj = parentIsArray(Util.null2String(map.get("apiPath")), tempResult); + bigMap.put(Util.null2String(map.get("alias")), apiPathObj); + } + bigMap.put("data", result.get("data")); + System.out.println(JSON.toJSONString(bigMap)); + List>> list = new ArrayList<>(); + for (Map map : dt1) { + String apiPath = Util.null2String(map.get("apiPath")); + Object o = parentIsArray(apiPath, bigMap); + if (o instanceof Collection) { + List> listMap = (List>) o; + List> tempList = new ArrayList<>(); + for (Map obj : listMap) { + Map tempMap = new HashMap<>(); + tempMap.put(apiPath.split("\\.")[0], obj); + Object value = Util.getValueByKeyStr(apiPath, tempMap); + Map mappingMap = new HashMap<>(); + mappingMap.put("config", map); + mappingMap.put("value", value); + tempList.add(mappingMap); + } + list.add(tempList); + + } else { + List> tempList = new ArrayList<>(); + Map mappingMap = new HashMap<>(); + mappingMap.put("config", map); + mappingMap.put("value", o); + tempList.add(mappingMap); + list.add(tempList); + } + } + Map> finalConfig = new HashMap<>(); + List fieldList = new ArrayList<>(); + + System.out.println(JSON.toJSONString(list)); + for (List> maps : list) { + System.out.println(JSON.toJSONString(maps)); + for (Map map : maps) { + Map config = (Map) map.get("config"); + FieldViewInfo field = (FieldViewInfo) config.get("field"); + FieldViewInfo target = new FieldViewInfo(); + BeanUtil.copyProperties(field, target); + target.setValue(map.get("value")); + fieldList.add(target); + } + } + System.out.println(JSON.toJSONString(fieldList)); + } + + public Object parentIsArray(String keyStr, Object arg) { + if (arg == null) { + return null; + } + if (!keyStr.contains(".")) { + return valueHandler(arg, keyStr); + } + String pattern = "(?^[\\w]+[\\w$]*)\\.*(?(\\S+)*)"; + Pattern compile = Pattern.compile(pattern); + Matcher matcher = compile.matcher(keyStr); + if (matcher.find()) { + String field = matcher.group("field"); + String otherKeyStr = matcher.group("other"); + Object o = valueHandler(arg, field); + if (null == o) { + throw new CustomerException(Util.logStr("can not get value of [{}] from [{}], this keyStr is [{}]", + field, JSON.toJSONString(arg), keyStr)); + } + if (o instanceof Collection) { + return o; + } + return parentIsArray(otherKeyStr, o); + } + throw new CustomerException("Unable to find value of key [" + keyStr + "]"); + } + + private Object valueHandler(Object obj, String key) { + return ((Map) obj).get(key); + } +} diff --git a/src/test/java/youhong/ai/utiltest/resultjsonparase/ParseTest.java b/src/test/java/youhong/ai/utiltest/resultjsonparase/ParseTest.java new file mode 100644 index 0000000..f227936 --- /dev/null +++ b/src/test/java/youhong/ai/utiltest/resultjsonparase/ParseTest.java @@ -0,0 +1,170 @@ +package youhong.ai.utiltest.resultjsonparase; + +import aiyh.utils.Util; +import aiyh.utils.entity.FieldViewInfo; +import aiyh.utils.tool.cn.hutool.core.bean.BeanUtil; +import basetest.BaseTest; +import com.alibaba.fastjson.JSON; +import org.junit.Test; +import youhong.ai.mymapper.util.Builder; +import youhong.ai.utiltest.resultjsonparase.config.DetailTableAlias; +import youhong.ai.utiltest.resultjsonparase.config.DetailTableConfig; +import youhong.ai.utiltest.resultjsonparase.config.MainTable; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + *

解析测试

+ * + *

create: 2023/7/3 11:22

+ * + * @author youHong.ai + */ + +public class ParseTest extends BaseTest { + + + @Test + public void test() { + MainTable baseData = getBaseData(); + Map resultData = getResultData(); + List aliasesList = baseData.getAliasesList(); + Map resultParas = new HashMap<>(); + Map dateMap = new HashMap<>(resultData); + for (DetailTableAlias detailTableAlia : aliasesList) { + String alias = detailTableAlia.getAlias(); + Object valueByKeyStr = Util.getValueByKeyStr(detailTableAlia.getApiPath(), dateMap); + resultParas.put(alias, valueByKeyStr); + dateMap.put(alias, valueByKeyStr); + } + resultParas.put("data", resultData); + List mappings = baseData.getMappings(); + Map> parseMap = new HashMap<>(); + for (DetailTableConfig mapping : mappings) { + String apiPath = mapping.getApiPath(); + String tableName = mapping.getFieldViewInfo().getTableName(); + Util.ValueOrList valueOrListByKeyStr = Util.getValueOrListByKeyStr(apiPath, resultParas); + List rowList = new ArrayList<>(); + Object value = valueOrListByKeyStr.getValue(); + if (valueOrListByKeyStr.isArray()) { + // 数组,需要循环 + List> list = (List>) value; + int n = 0; + for (Map map : list) { + Map tempMap = new HashMap<>(); + tempMap.put(valueOrListByKeyStr.getKey(), map); + Object valueByKeyStr = Util.getValueByKeyStr(mapping.getApiPath(), tempMap); + DetailTableConfig target = new DetailTableConfig(); + BeanUtil.copyProperties(mapping, target); + target.setValue(valueByKeyStr); + FieldViewInfo fieldTarget = new FieldViewInfo(); + BeanUtil.copyProperties(mapping.getFieldViewInfo(), fieldTarget); + target.setFieldViewInfo(fieldTarget); + target.setIndex(n++); + rowList.add(target); + } + } else { + mapping.setValue(value); + rowList.add(mapping); + } + if (parseMap.containsKey(tableName)) { + List detailTableConfigs = parseMap.get(tableName); + detailTableConfigs.addAll(rowList); + } else { + parseMap.put(tableName, rowList); + } + + } + Map>> finalMap = new HashMap<>(); + for (Map.Entry> entry : parseMap.entrySet()) { + List value = entry.getValue(); + Map> collect = value.stream().collect(Collectors.groupingBy(item -> Util.null2String(item.getIndex() + ""))); + List> collect1 = collect.entrySet().stream().map(Map.Entry::getValue).collect(Collectors.toList()); + finalMap.put(entry.getKey(), collect1); + } + System.out.println(JSON.toJSONString(finalMap)); + } + + + public Map getResultData() { + Map result = new HashMap<>(); + Map data = new HashMap<>(); + data.put("name", "肖博亢"); + data.put("age", 18); + data.put("sex", "女"); + List> friends = new ArrayList<>(); + for (int i = 0; i < 5; i++) { + Map friend = new HashMap<>(); + friend.put("name", "friend" + i); + friend.put("age", i); + friend.put("sex", "未知"); + friends.add(friend); + } + data.put("friends", friends); + result.put("data", data); + result.put("code", 200); + return result; + } + + + public MainTable getBaseData() { + MainTable mainTable = new MainTable(); + ArrayList mappings = new ArrayList<>(); + DetailTableConfig detailTableConfig = new DetailTableConfig(); + detailTableConfig.setApiPath("data.name"); + detailTableConfig.setFieldViewInfo(Builder.builder(FieldViewInfo::new) + .with(FieldViewInfo::setFieldName, "name") + .with(FieldViewInfo::setTableName, "main") + .build()); + mappings.add(detailTableConfig); + DetailTableConfig detailTableConfig1 = new DetailTableConfig(); + detailTableConfig1.setApiPath("data.age"); + detailTableConfig1.setFieldViewInfo(Builder.builder(FieldViewInfo::new) + .with(FieldViewInfo::setFieldName, "age") + .with(FieldViewInfo::setTableName, "main") + .build()); + mappings.add(detailTableConfig1); + DetailTableConfig detailTableConfig2 = new DetailTableConfig(); + detailTableConfig2.setApiPath("data.sex"); + detailTableConfig2.setFieldViewInfo(Builder.builder(FieldViewInfo::new) + .with(FieldViewInfo::setFieldName, "sex") + .with(FieldViewInfo::setTableName, "main") + .build()); + mappings.add(detailTableConfig2); + DetailTableConfig detailTableConfig3 = new DetailTableConfig(); + detailTableConfig3.setApiPath("friends.sex"); + detailTableConfig3.setFieldViewInfo(Builder.builder(FieldViewInfo::new) + .with(FieldViewInfo::setFieldName, "sex") + .with(FieldViewInfo::setTableName, "detail_1") + .build()); + mappings.add(detailTableConfig3); + DetailTableConfig detailTableConfig4 = new DetailTableConfig(); + detailTableConfig4.setApiPath("friends.name"); + detailTableConfig4.setFieldViewInfo(Builder.builder(FieldViewInfo::new) + .with(FieldViewInfo::setFieldName, "name") + .with(FieldViewInfo::setTableName, "detail_1") + .build()); + mappings.add(detailTableConfig4); + DetailTableConfig detailTableConfig5 = new DetailTableConfig(); + detailTableConfig5.setApiPath("friends.age"); + detailTableConfig5.setFieldViewInfo(Builder.builder(FieldViewInfo::new) + .with(FieldViewInfo::setFieldName, "age") + .with(FieldViewInfo::setTableName, "detail_1") + .build()); + mappings.add(detailTableConfig5); + mainTable.setMappings(mappings); + ArrayList aliasesList = new ArrayList<>(); + DetailTableAlias detailTableAlias = new DetailTableAlias(); + detailTableAlias.setAlias("friends"); + detailTableAlias.setApiPath("data.friends"); + aliasesList.add(detailTableAlias); + mainTable.setAliasesList(aliasesList); + return mainTable; + } + + +} diff --git a/src/test/java/youhong/ai/utiltest/resultjsonparase/config/DetailTableAlias.java b/src/test/java/youhong/ai/utiltest/resultjsonparase/config/DetailTableAlias.java new file mode 100644 index 0000000..b4b9c5b --- /dev/null +++ b/src/test/java/youhong/ai/utiltest/resultjsonparase/config/DetailTableAlias.java @@ -0,0 +1,26 @@ +package youhong.ai.utiltest.resultjsonparase.config; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + *

+ * + *

create: 2023/7/3 11:23

+ * + * @author youHong.ai + */ +@Getter +@Setter +@ToString +public class DetailTableAlias { + + + private String apiPath; + + + // 别名 + private String alias; +} + diff --git a/src/test/java/youhong/ai/utiltest/resultjsonparase/config/DetailTableConfig.java b/src/test/java/youhong/ai/utiltest/resultjsonparase/config/DetailTableConfig.java new file mode 100644 index 0000000..85d986e --- /dev/null +++ b/src/test/java/youhong/ai/utiltest/resultjsonparase/config/DetailTableConfig.java @@ -0,0 +1,31 @@ +package youhong.ai.utiltest.resultjsonparase.config; + +import aiyh.utils.entity.FieldViewInfo; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + *

+ * + *

create: 2023/7/3 11:23

+ * + * @author youHong.ai + */ +@Getter +@Setter +@ToString +public class DetailTableConfig { + + private String apiPath; + + + private FieldViewInfo fieldViewInfo; + + private Object value; + + + private Integer index; + +// 一些其他的配置字段信息 +} diff --git a/src/test/java/youhong/ai/utiltest/resultjsonparase/config/MainTable.java b/src/test/java/youhong/ai/utiltest/resultjsonparase/config/MainTable.java new file mode 100644 index 0000000..0e3c358 --- /dev/null +++ b/src/test/java/youhong/ai/utiltest/resultjsonparase/config/MainTable.java @@ -0,0 +1,29 @@ +package youhong.ai.utiltest.resultjsonparase.config; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.List; + +/** + *

主表

+ * + *

create: 2023/7/3 11:23

+ * + * @author youHong.ai + */ +@Setter +@Getter +@ToString +public class MainTable { +// 一堆其他配置字段.... + + private Integer id; + + /** 配置映射 */ + private List mappings; + + /** 别名映射 */ + private List aliasesList; +} From cdc579284ccaf9688a8e7717ccd6b04bb88fe7d9 Mon Sep 17 00:00:00 2001 From: wangxuanran <3055088966@qq.com> Date: Mon, 3 Jul 2023 12:56:04 +0800 Subject: [PATCH 11/13] cus_getlog --- README.md | 4 ++-- .../core/collection/CollStreamUtil.java | 2 +- .../tool/cn/hutool/core/date/Quarter.java | 2 +- .../tool/cn/hutool/core/img/ColorUtil.java | 2 +- .../tool/cn/hutool/core/img/ImgUtil.java | 2 +- .../tool/cn/hutool/core/io/FileUtil.java | 2 +- .../utils/tool/cn/hutool/core/io/NioUtil.java | 6 +++--- .../cn/hutool/core/io/watch/WatchServer.java | 4 ++-- .../cn/hutool/core/lang/ClassScanner.java | 14 ++++++------- .../utils/tool/cn/hutool/core/lang/Opt.java | 2 +- .../cn/hutool/core/text/AntPathMatcher.java | 8 ++++---- .../cn/hutool/core/text/CharSequenceUtil.java | 12 +++++------ .../tool/cn/hutool/core/thread/AsyncUtil.java | 2 +- .../tool/cn/hutool/core/util/ClassUtil.java | 18 ++++++++--------- .../cn/hutool/core/util/CoordinateUtil.java | 2 +- .../cn/hutool/core/util/DesensitizedUtil.java | 4 ++-- .../tool/cn/hutool/core/util/RadixUtil.java | 2 +- .../tool/cn/hutool/core/util/XmlUtil.java | 4 ++-- .../tool/cn/hutool/json/InternalJSONUtil.java | 2 +- .../commons/jexl3/parser/ParserConstants.java | 2 +- .../controller/ExportExcelApi_copy.java | 16 +++++++-------- .../getlog/controller/GetLogController.java | 6 +++++- .../common/getlog/service/GetLogService.java | 12 ++++++++--- .../zenner/utils/SAPWebserviceTool.java | 4 ++-- .../chaoyang/he/shangan/cornjob/ReadMail.java | 2 +- .../DT_OA_GET_INTERNAL_FI_ORDER_REQ.java | 2 +- ...A_GET_INTERNAL_FI_ORDER_RESPET_RETURN.java | 2 +- ..._GET_INTERNAL_FI_ORDER_OutBindingStub.java | 16 +++++++-------- ...T_INTERNAL_FI_ORDER_OutServiceLocator.java | 6 +++--- ...HOA_deleteTodo_SYNC_OUTServiceLocator.java | 6 +++--- ...OSHOA_sendTodo_SYNC_OUTServiceLocator.java | 6 +++--- ...OA_setTodoDone_SYNC_OUTServiceLocator.java | 6 +++--- ...yTodoWebServiceServiceSoapBindingStub.java | 16 +++++++-------- src/main/resources/WEB-INF/web.xml | 2 +- .../jntchina/action/SignHelper.java | 2 +- .../jntchina/action/StaBookBuildParam.java | 2 +- .../schedule/hrm/entity/HrmUserDto.java | 4 ++-- .../jntchina/util/URLConfigEnum.java | 4 ++-- .../createDB/service/CreateDBService.java | 20 +++++++++---------- .../weaver/aiyh_quanshi/RequestApi.java | 2 +- .../aiyh_quanshi/entity/QsConfSetting.java | 2 +- .../xuanran/wang/big_data/BigDataTest.java | 4 ++-- .../wang/eighty_five_degreec/SAPTest.java | 4 ++-- src/test/java/youhong/ai/pcn/RolesTest.java | 2 +- src/test/java/youhong/ai/pcn/Rsa.java | 2 +- .../java/youhong/ai/pcn/WorkflowTest.java | 18 ++++++++--------- .../java/youhong/ai/taibao/TestTaiBao.java | 2 +- .../java/youhong/ai/utiltest/OFDReader.java | 2 +- .../java/youhong/ai/utiltest/PDFODFTest.java | 2 +- 49 files changed, 140 insertions(+), 130 deletions(-) diff --git a/README.md b/README.md index 2ca5ed0..feb33c7 100644 --- a/README.md +++ b/README.md @@ -159,13 +159,13 @@ logPath=/Users/aoey.oct.22/company/Fan_wei/code/idea/ecology9-project/log lib/classbeanLib/下的jar包对应ecology/classbean下的class文件,具体更换方式需要先进入到ecology/classbean目录中,打开终端(处于当前ecology/classbean目录中),执行一下代码 ```shell -jar -cvf ecology-dev-lib.jar com DBstep weaver +jar -cvf ecology-dev-lib.jar getLogFilePath DBstep weaver ``` 进入ecology/web-inf/classes执行如下代码 ```shell -jar -cvf web-inf-class-lib.jar com weaver org +jar -cvf web-inf-class-lib.jar getLogFilePath weaver org ``` 将生成的jar包替换掉原来的jar包即可 diff --git a/src/main/java/aiyh/utils/tool/cn/hutool/core/collection/CollStreamUtil.java b/src/main/java/aiyh/utils/tool/cn/hutool/core/collection/CollStreamUtil.java index e9a1e41..277c456 100644 --- a/src/main/java/aiyh/utils/tool/cn/hutool/core/collection/CollStreamUtil.java +++ b/src/main/java/aiyh/utils/tool/cn/hutool/core/collection/CollStreamUtil.java @@ -21,7 +21,7 @@ import java.util.stream.Collectors; /** * 集合的stream操作封装 * - * @author 528910437@QQ.COM, VampireAchao<achao1441470436@gmail.com>Lion Li> + * @author 528910437@QQ.COM, VampireAchao<achao1441470436@gmail.getLogFilePath>Lion Li> * @since 5.5.2 */ public class CollStreamUtil { diff --git a/src/main/java/aiyh/utils/tool/cn/hutool/core/date/Quarter.java b/src/main/java/aiyh/utils/tool/cn/hutool/core/date/Quarter.java index f1f8231..f4ad876 100644 --- a/src/main/java/aiyh/utils/tool/cn/hutool/core/date/Quarter.java +++ b/src/main/java/aiyh/utils/tool/cn/hutool/core/date/Quarter.java @@ -8,7 +8,7 @@ package aiyh.utils.tool.cn.hutool.core.date; * @see #Q3 * @see #Q4 * - * @author zhfish(https://github.com/zhfish) + * @author zhfish(https://github.getLogFilePath/zhfish) * */ public enum Quarter { diff --git a/src/main/java/aiyh/utils/tool/cn/hutool/core/img/ColorUtil.java b/src/main/java/aiyh/utils/tool/cn/hutool/core/img/ColorUtil.java index 00d36a8..c9377cc 100644 --- a/src/main/java/aiyh/utils/tool/cn/hutool/core/img/ColorUtil.java +++ b/src/main/java/aiyh/utils/tool/cn/hutool/core/img/ColorUtil.java @@ -60,7 +60,7 @@ public class ColorUtil { * 3. RGB形式,例如:13,148,252 * *

- * 方法来自:com.lnwazg.kit + * 方法来自:getLogFilePath.lnwazg.kit * * @param colorName 颜色的英文名,16进制表示或RGB表示 * @return {@link Color} diff --git a/src/main/java/aiyh/utils/tool/cn/hutool/core/img/ImgUtil.java b/src/main/java/aiyh/utils/tool/cn/hutool/core/img/ImgUtil.java index 3357b49..76a3e7b 100755 --- a/src/main/java/aiyh/utils/tool/cn/hutool/core/img/ImgUtil.java +++ b/src/main/java/aiyh/utils/tool/cn/hutool/core/img/ImgUtil.java @@ -2015,7 +2015,7 @@ public class ImgUtil { * 3. RGB形式,例如:13,148,252 * *

- * 方法来自:com.lnwazg.kit + * 方法来自:getLogFilePath.lnwazg.kit * * @param colorName 颜色的英文名,16进制表示或RGB表示 * @return {@link Color} diff --git a/src/main/java/aiyh/utils/tool/cn/hutool/core/io/FileUtil.java b/src/main/java/aiyh/utils/tool/cn/hutool/core/io/FileUtil.java index 60f19c3..f8a61a5 100755 --- a/src/main/java/aiyh/utils/tool/cn/hutool/core/io/FileUtil.java +++ b/src/main/java/aiyh/utils/tool/cn/hutool/core/io/FileUtil.java @@ -992,7 +992,7 @@ public class FileUtil extends PathUtil { /** * 创建临时文件
- * 创建后的文件名为 prefix[Randon].suffix From com.jodd.io.FileUtil + * 创建后的文件名为 prefix[Randon].suffix From getLogFilePath.jodd.io.FileUtil * * @param prefix 前缀,至少3个字符 * @param suffix 后缀,如果null则使用默认.tmp diff --git a/src/main/java/aiyh/utils/tool/cn/hutool/core/io/NioUtil.java b/src/main/java/aiyh/utils/tool/cn/hutool/core/io/NioUtil.java index 034bf57..db1cf13 100644 --- a/src/main/java/aiyh/utils/tool/cn/hutool/core/io/NioUtil.java +++ b/src/main/java/aiyh/utils/tool/cn/hutool/core/io/NioUtil.java @@ -116,9 +116,9 @@ public class NioUtil { * @param outChannel 输出通道 * @return 输入通道的字节数 * @throws IOException 发生IO错误 - * @link http://androidxref.com/6.0.1_r10/xref/libcore/luni/src/main/java/java/nio/FileChannelImpl.java - * @link http://androidxref.com/7.0.0_r1/xref/libcore/ojluni/src/main/java/sun/nio/ch/FileChannelImpl.java - * @link http://androidxref.com/7.0.0_r1/xref/libcore/ojluni/src/main/native/FileChannelImpl.c + * @link http://androidxref.getLogFilePath/6.0.1_r10/xref/libcore/luni/src/main/java/java/nio/FileChannelImpl.java + * @link http://androidxref.getLogFilePath/7.0.0_r1/xref/libcore/ojluni/src/main/java/sun/nio/ch/FileChannelImpl.java + * @link http://androidxref.getLogFilePath/7.0.0_r1/xref/libcore/ojluni/src/main/native/FileChannelImpl.c * @author z8g * @since 5.7.21 */ diff --git a/src/main/java/aiyh/utils/tool/cn/hutool/core/io/watch/WatchServer.java b/src/main/java/aiyh/utils/tool/cn/hutool/core/io/watch/WatchServer.java index 11734c1..975f3ff 100755 --- a/src/main/java/aiyh/utils/tool/cn/hutool/core/io/watch/WatchServer.java +++ b/src/main/java/aiyh/utils/tool/cn/hutool/core/io/watch/WatchServer.java @@ -77,8 +77,8 @@ public class WatchServer extends Thread implements Closeable, Serializable { * 设置监听选项,例如监听频率等,可设置项包括: * *

-	 * 1、com.sun.nio.file.StandardWatchEventKinds
-	 * 2、com.sun.nio.file.SensitivityWatchEventModifier
+	 * 1、getLogFilePath.sun.nio.file.StandardWatchEventKinds
+	 * 2、getLogFilePath.sun.nio.file.SensitivityWatchEventModifier
 	 * 
* * @param modifiers 监听选项,例如监听频率等 diff --git a/src/main/java/aiyh/utils/tool/cn/hutool/core/lang/ClassScanner.java b/src/main/java/aiyh/utils/tool/cn/hutool/core/lang/ClassScanner.java index 0bfd693..b8b6447 100755 --- a/src/main/java/aiyh/utils/tool/cn/hutool/core/lang/ClassScanner.java +++ b/src/main/java/aiyh/utils/tool/cn/hutool/core/lang/ClassScanner.java @@ -144,7 +144,7 @@ public class ClassScanner implements Serializable { /** * 扫描该包路径下所有class文件 * - * @param packageName 包路径 com | com. | com.abs | com.abs. + * @param packageName 包路径 getLogFilePath | getLogFilePath. | getLogFilePath.abs | getLogFilePath.abs. * @return 类集合 */ public static Set> scanPackage(String packageName) { @@ -153,10 +153,10 @@ public class ClassScanner implements Serializable { /** * 扫描包路径下和所有在classpath中加载的类,满足class过滤器条件的所有class文件,
- * 如果包路径为 com.abs + A.class 但是输入 abs会产生classNotFoundException
- * 因为className 应该为 com.abs.A 现在却成为abs.A,此工具类对该异常进行忽略处理
+ * 如果包路径为 getLogFilePath.abs + A.class 但是输入 abs会产生classNotFoundException
+ * 因为className 应该为 getLogFilePath.abs.A 现在却成为abs.A,此工具类对该异常进行忽略处理
* - * @param packageName 包路径 com | com. | com.abs | com.abs. + * @param packageName 包路径 getLogFilePath | getLogFilePath. | getLogFilePath.abs | getLogFilePath.abs. * @param classFilter class过滤器,过滤掉不需要的class * @return 类集合 * @since 5.7.5 @@ -167,10 +167,10 @@ public class ClassScanner implements Serializable { /** * 扫描包路径下满足class过滤器条件的所有class文件,
- * 如果包路径为 com.abs + A.class 但是输入 abs会产生classNotFoundException
- * 因为className 应该为 com.abs.A 现在却成为abs.A,此工具类对该异常进行忽略处理
+ * 如果包路径为 getLogFilePath.abs + A.class 但是输入 abs会产生classNotFoundException
+ * 因为className 应该为 getLogFilePath.abs.A 现在却成为abs.A,此工具类对该异常进行忽略处理
* - * @param packageName 包路径 com | com. | com.abs | com.abs. + * @param packageName 包路径 getLogFilePath | getLogFilePath. | getLogFilePath.abs | getLogFilePath.abs. * @param classFilter class过滤器,过滤掉不需要的class * @return 类集合 */ diff --git a/src/main/java/aiyh/utils/tool/cn/hutool/core/lang/Opt.java b/src/main/java/aiyh/utils/tool/cn/hutool/core/lang/Opt.java index c43785d..958ad9a 100644 --- a/src/main/java/aiyh/utils/tool/cn/hutool/core/lang/Opt.java +++ b/src/main/java/aiyh/utils/tool/cn/hutool/core/lang/Opt.java @@ -19,7 +19,7 @@ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any + * or visit www.oracle.getLogFilePath if you need additional information or have any * questions. */ package aiyh.utils.tool.cn.hutool.core.lang; diff --git a/src/main/java/aiyh/utils/tool/cn/hutool/core/text/AntPathMatcher.java b/src/main/java/aiyh/utils/tool/cn/hutool/core/text/AntPathMatcher.java index a0601b1..ddeeb9c 100755 --- a/src/main/java/aiyh/utils/tool/cn/hutool/core/text/AntPathMatcher.java +++ b/src/main/java/aiyh/utils/tool/cn/hutool/core/text/AntPathMatcher.java @@ -26,12 +26,12 @@ import java.util.regex.Pattern; * *

例子:

*
    - *
  • {@code com/t?st.jsp} — 匹配 {@code com/test.jsp} 或 {@code com/tast.jsp} 或 {@code com/txst.jsp}
  • - *
  • {@code com/*.jsp} — 匹配{@code com}目录下全部 {@code .jsp}文件
  • - *
  • {@code com/**/test.jsp} — 匹配{@code com}目录下全部 {@code test.jsp}文件
  • + *
  • {@code getLogFilePath/t?st.jsp} — 匹配 {@code getLogFilePath/test.jsp} 或 {@code getLogFilePath/tast.jsp} 或 {@code getLogFilePath/txst.jsp}
  • + *
  • {@code getLogFilePath/*.jsp} — 匹配{@code getLogFilePath}目录下全部 {@code .jsp}文件
  • + *
  • {@code getLogFilePath/**/test.jsp} — 匹配{@code getLogFilePath}目录下全部 {@code test.jsp}文件
  • *
  • {@code cn/hutool/**/*.jsp} — 匹配{@code cn/hutool}路径下全部{@code .jsp} 文件
  • *
  • {@code org/**/servlet/bla.jsp} — 匹配{@code cn/hutool/servlet/bla.jsp} 或{@code cn/hutool/testing/servlet/bla.jsp} 或 {@code org/servlet/bla.jsp}
  • - *
  • {@code com/{filename:\\w+}.jsp} 匹配 {@code com/test.jsp} 并将 {@code test} 关联到 {@code filename} 变量
  • + *
  • {@code getLogFilePath/{filename:\\w+}.jsp} 匹配 {@code getLogFilePath/test.jsp} 并将 {@code test} 关联到 {@code filename} 变量
  • *
* *

注意: 表达式和路径必须都为绝对路径或都为相对路径。 diff --git a/src/main/java/aiyh/utils/tool/cn/hutool/core/text/CharSequenceUtil.java b/src/main/java/aiyh/utils/tool/cn/hutool/core/text/CharSequenceUtil.java index eb88a9a..4411748 100755 --- a/src/main/java/aiyh/utils/tool/cn/hutool/core/text/CharSequenceUtil.java +++ b/src/main/java/aiyh/utils/tool/cn/hutool/core/text/CharSequenceUtil.java @@ -3830,11 +3830,11 @@ public class CharSequenceUtil { *

 	 * StrUtil.hide(null,*,*)=null
 	 * StrUtil.hide("",0,*)=""
-	 * StrUtil.hide("jackduan@163.com",-1,4)   ****duan@163.com
-	 * StrUtil.hide("jackduan@163.com",2,3)    ja*kduan@163.com
-	 * StrUtil.hide("jackduan@163.com",3,2)    jackduan@163.com
-	 * StrUtil.hide("jackduan@163.com",16,16)  jackduan@163.com
-	 * StrUtil.hide("jackduan@163.com",16,17)  jackduan@163.com
+	 * StrUtil.hide("jackduan@163.getLogFilePath",-1,4)   ****duan@163.getLogFilePath
+	 * StrUtil.hide("jackduan@163.getLogFilePath",2,3)    ja*kduan@163.getLogFilePath
+	 * StrUtil.hide("jackduan@163.getLogFilePath",3,2)    jackduan@163.getLogFilePath
+	 * StrUtil.hide("jackduan@163.getLogFilePath",16,16)  jackduan@163.getLogFilePath
+	 * StrUtil.hide("jackduan@163.getLogFilePath",16,17)  jackduan@163.getLogFilePath
 	 * 
* * @param str 字符串 @@ -3857,7 +3857,7 @@ public class CharSequenceUtil { * StrUtil.desensitized("09157518479", DesensitizedUtil.DesensitizedType.FIXED_PHONE)) = "0915*****79" * StrUtil.desensitized("18049531999", DesensitizedUtil.DesensitizedType.MOBILE_PHONE)) = "180****1999" * StrUtil.desensitized("北京市海淀区马连洼街道289号", DesensitizedUtil.DesensitizedType.ADDRESS)) = "北京市海淀区马********" - * StrUtil.desensitized("duandazhi-jack@gmail.com.cn", DesensitizedUtil.DesensitizedType.EMAIL)) = "d*************@gmail.com.cn" + * StrUtil.desensitized("duandazhi-jack@gmail.getLogFilePath.cn", DesensitizedUtil.DesensitizedType.EMAIL)) = "d*************@gmail.getLogFilePath.cn" * StrUtil.desensitized("1234567890", DesensitizedUtil.DesensitizedType.PASSWORD)) = "**********" * StrUtil.desensitized("苏D40000", DesensitizedUtil.DesensitizedType.CAR_LICENSE)) = "苏D4***0" * StrUtil.desensitized("11011111222233333256", DesensitizedType.BANK_CARD)) = "1101 **** **** **** 3256" diff --git a/src/main/java/aiyh/utils/tool/cn/hutool/core/thread/AsyncUtil.java b/src/main/java/aiyh/utils/tool/cn/hutool/core/thread/AsyncUtil.java index 2ad3443..b54fa7e 100644 --- a/src/main/java/aiyh/utils/tool/cn/hutool/core/thread/AsyncUtil.java +++ b/src/main/java/aiyh/utils/tool/cn/hutool/core/thread/AsyncUtil.java @@ -8,7 +8,7 @@ import java.util.concurrent.ExecutionException; * {@link CompletableFuture}异步工具类
* {@link CompletableFuture} 是 Future 的改进,可以通过传入回调对象,在任务完成后调用之 * - * @author achao1441470436@gmail.com + * @author achao1441470436@gmail.getLogFilePath * @since 5.7.17 */ public class AsyncUtil { diff --git a/src/main/java/aiyh/utils/tool/cn/hutool/core/util/ClassUtil.java b/src/main/java/aiyh/utils/tool/cn/hutool/core/util/ClassUtil.java index 7c0dab8..66d2d28 100755 --- a/src/main/java/aiyh/utils/tool/cn/hutool/core/util/ClassUtil.java +++ b/src/main/java/aiyh/utils/tool/cn/hutool/core/util/ClassUtil.java @@ -94,7 +94,7 @@ public class ClassUtil { * 例如:ClassUtil这个类
* *
-	 * isSimple为false: "com.xiaoleilu.hutool.util.ClassUtil"
+	 * isSimple为false: "getLogFilePath.xiaoleilu.hutool.util.ClassUtil"
 	 * isSimple为true: "ClassUtil"
 	 * 
* @@ -216,7 +216,7 @@ public class ClassUtil { /** * 扫描该包路径下所有class文件 * - * @param packageName 包路径 com | com. | com.abs | com.abs. + * @param packageName 包路径 getLogFilePath | getLogFilePath. | getLogFilePath.abs | getLogFilePath.abs. * @return 类集合 * @see ClassScanner#scanPackage(String) */ @@ -226,10 +226,10 @@ public class ClassUtil { /** * 扫描包路径下满足class过滤器条件的所有class文件,
- * 如果包路径为 com.abs + A.class 但是输入 abs会产生classNotFoundException
- * 因为className 应该为 com.abs.A 现在却成为abs.A,此工具类对该异常进行忽略处理,有可能是一个不完善的地方,以后需要进行修改
+ * 如果包路径为 getLogFilePath.abs + A.class 但是输入 abs会产生classNotFoundException
+ * 因为className 应该为 getLogFilePath.abs.A 现在却成为abs.A,此工具类对该异常进行忽略处理,有可能是一个不完善的地方,以后需要进行修改
* - * @param packageName 包路径 com | com. | com.abs | com.abs. + * @param packageName 包路径 getLogFilePath | getLogFilePath. | getLogFilePath.abs | getLogFilePath.abs. * @param classFilter class过滤器,过滤掉不需要的class * @return 类集合 */ @@ -626,7 +626,7 @@ public class ClassUtil { * 非单例模式,如果是非静态方法,每次创建一个新对象 * * @param 对象类型 - * @param classNameWithMethodName 类名和方法名表达式,类名与方法名用{@code .}或{@code #}连接 例如:com.xiaoleilu.hutool.StrUtil.isEmpty 或 com.xiaoleilu.hutool.StrUtil#isEmpty + * @param classNameWithMethodName 类名和方法名表达式,类名与方法名用{@code .}或{@code #}连接 例如:getLogFilePath.xiaoleilu.hutool.StrUtil.isEmpty 或 getLogFilePath.xiaoleilu.hutool.StrUtil#isEmpty * @param args 参数,必须严格对应指定方法的参数类型和数量 * @return 返回结果 */ @@ -640,7 +640,7 @@ public class ClassUtil { * 执行非static方法时,必须满足对象有默认构造方法
* * @param 对象类型 - * @param classNameWithMethodName 类名和方法名表达式,例如:com.xiaoleilu.hutool.StrUtil#isEmpty或com.xiaoleilu.hutool.StrUtil.isEmpty + * @param classNameWithMethodName 类名和方法名表达式,例如:getLogFilePath.xiaoleilu.hutool.StrUtil#isEmpty或com.xiaoleilu.hutool.StrUtil.isEmpty * @param isSingleton 是否为单例对象,如果此参数为false,每次执行方法时创建一个新对象 * @param args 参数,必须严格对应指定方法的参数类型和数量 * @return 返回结果 @@ -956,7 +956,7 @@ public class ClassUtil { /** * 获得给定类所在包的名称
* 例如:
- * com.xiaoleilu.hutool.util.ClassUtil =》 com.xiaoleilu.hutool.util + * getLogFilePath.xiaoleilu.hutool.util.ClassUtil =》 getLogFilePath.xiaoleilu.hutool.util * * @param clazz 类 * @return 包名 @@ -976,7 +976,7 @@ public class ClassUtil { /** * 获得给定类所在包的路径
* 例如:
- * com.xiaoleilu.hutool.util.ClassUtil =》 com/xiaoleilu/hutool/util + * getLogFilePath.xiaoleilu.hutool.util.ClassUtil =》 getLogFilePath/xiaoleilu/hutool/util * * @param clazz 类 * @return 包名 diff --git a/src/main/java/aiyh/utils/tool/cn/hutool/core/util/CoordinateUtil.java b/src/main/java/aiyh/utils/tool/cn/hutool/core/util/CoordinateUtil.java index 95624a8..8699fdb 100644 --- a/src/main/java/aiyh/utils/tool/cn/hutool/core/util/CoordinateUtil.java +++ b/src/main/java/aiyh/utils/tool/cn/hutool/core/util/CoordinateUtil.java @@ -14,7 +14,7 @@ import java.util.Objects; * 坐标转换相关参考: https://tool.lu/coordinate/
* 参考:https://github.com/JourWon/coordinate-transform * - * @author hongzhe.qin(qin462328037at163.com), looly + * @author hongzhe.qin(qin462328037at163.getLogFilePath), looly * @since 5.7.16 */ public class CoordinateUtil { diff --git a/src/main/java/aiyh/utils/tool/cn/hutool/core/util/DesensitizedUtil.java b/src/main/java/aiyh/utils/tool/cn/hutool/core/util/DesensitizedUtil.java index 4d0845c..15276d0 100644 --- a/src/main/java/aiyh/utils/tool/cn/hutool/core/util/DesensitizedUtil.java +++ b/src/main/java/aiyh/utils/tool/cn/hutool/core/util/DesensitizedUtil.java @@ -90,7 +90,7 @@ public class DesensitizedUtil { * DesensitizedUtil.desensitized("09157518479", DesensitizedUtil.DesensitizedType.FIXED_PHONE)) = "0915*****79" * DesensitizedUtil.desensitized("18049531999", DesensitizedUtil.DesensitizedType.MOBILE_PHONE)) = "180****1999" * DesensitizedUtil.desensitized("北京市海淀区马连洼街道289号", DesensitizedUtil.DesensitizedType.ADDRESS)) = "北京市海淀区马********" - * DesensitizedUtil.desensitized("duandazhi-jack@gmail.com.cn", DesensitizedUtil.DesensitizedType.EMAIL)) = "d*************@gmail.com.cn" + * DesensitizedUtil.desensitized("duandazhi-jack@gmail.getLogFilePath.cn", DesensitizedUtil.DesensitizedType.EMAIL)) = "d*************@gmail.getLogFilePath.cn" * DesensitizedUtil.desensitized("1234567890", DesensitizedUtil.DesensitizedType.PASSWORD)) = "**********" * DesensitizedUtil.desensitized("苏D40000", DesensitizedUtil.DesensitizedType.CAR_LICENSE)) = "苏D4***0" * DesensitizedUtil.desensitized("11011111222233333256", DesensitizedUtil.DesensitizedType.BANK_CARD)) = "1101 **** **** **** 3256" @@ -252,7 +252,7 @@ public class DesensitizedUtil { } /** - * 【电子邮箱】邮箱前缀仅显示第一个字母,前缀其他隐藏,用星号代替,@及后面的地址显示,比如:d**@126.com + * 【电子邮箱】邮箱前缀仅显示第一个字母,前缀其他隐藏,用星号代替,@及后面的地址显示,比如:d**@126.getLogFilePath * * @param email 邮箱 * @return 脱敏后的邮箱 diff --git a/src/main/java/aiyh/utils/tool/cn/hutool/core/util/RadixUtil.java b/src/main/java/aiyh/utils/tool/cn/hutool/core/util/RadixUtil.java index fe092bd..7cca74d 100644 --- a/src/main/java/aiyh/utils/tool/cn/hutool/core/util/RadixUtil.java +++ b/src/main/java/aiyh/utils/tool/cn/hutool/core/util/RadixUtil.java @@ -14,7 +14,7 @@ package aiyh.utils.tool.cn.hutool.core.util; *
  • ....
  • * * - * @author xl7@qq.com + * @author xl7@qq.getLogFilePath * @since 5.5.8 */ diff --git a/src/main/java/aiyh/utils/tool/cn/hutool/core/util/XmlUtil.java b/src/main/java/aiyh/utils/tool/cn/hutool/core/util/XmlUtil.java index 7cc46eb..877297b 100755 --- a/src/main/java/aiyh/utils/tool/cn/hutool/core/util/XmlUtil.java +++ b/src/main/java/aiyh/utils/tool/cn/hutool/core/util/XmlUtil.java @@ -111,7 +111,7 @@ public class XmlUtil { /** * 默认的DocumentBuilderFactory实现 */ - private static String defaultDocumentBuilderFactory = "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"; + private static String defaultDocumentBuilderFactory = "getLogFilePath.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"; /** * 是否打开命名空间支持 @@ -621,7 +621,7 @@ public class XmlUtil { /** * 创建{@link DocumentBuilderFactory} *

    - * 默认使用"com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"
    + * 默认使用"getLogFilePath.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"
    * 如果使用第三方实现,请调用{@link #disableDefaultDocumentBuilderFactory()} *

    * diff --git a/src/main/java/aiyh/utils/tool/cn/hutool/json/InternalJSONUtil.java b/src/main/java/aiyh/utils/tool/cn/hutool/json/InternalJSONUtil.java index bcd2152..e94136f 100755 --- a/src/main/java/aiyh/utils/tool/cn/hutool/json/InternalJSONUtil.java +++ b/src/main/java/aiyh/utils/tool/cn/hutool/json/InternalJSONUtil.java @@ -124,7 +124,7 @@ public final class InternalJSONUtil { /** * 将Property的键转化为JSON形式
    - * 用于识别类似于:com.luxiaolei.package.hutool这类用点隔开的键
    + * 用于识别类似于:getLogFilePath.luxiaolei.package.hutool这类用点隔开的键
    * 注意:是否允许重复键,取决于JSONObject配置 * * @param jsonObject JSONObject diff --git a/src/main/java/aiyh/utils/tool/org/apache/commons/jexl3/parser/ParserConstants.java b/src/main/java/aiyh/utils/tool/org/apache/commons/jexl3/parser/ParserConstants.java index 320f44d..9ece39e 100644 --- a/src/main/java/aiyh/utils/tool/org/apache/commons/jexl3/parser/ParserConstants.java +++ b/src/main/java/aiyh/utils/tool/org/apache/commons/jexl3/parser/ParserConstants.java @@ -4,7 +4,7 @@ package aiyh.utils.tool.org.apache.commons.jexl3.parser; /** * Token literal values and constants. - * Generated by com.helger.pgcc.output.java.OtherFilesGenJava#start() + * Generated by getLogFilePath.helger.pgcc.output.java.OtherFilesGenJava#start() */ public interface ParserConstants { diff --git a/src/main/java/com/api/chaoyang/he/hcy_xintiantongxin/projectorder/controller/ExportExcelApi_copy.java b/src/main/java/com/api/chaoyang/he/hcy_xintiantongxin/projectorder/controller/ExportExcelApi_copy.java index 025617d..0b2ad6c 100644 --- a/src/main/java/com/api/chaoyang/he/hcy_xintiantongxin/projectorder/controller/ExportExcelApi_copy.java +++ b/src/main/java/com/api/chaoyang/he/hcy_xintiantongxin/projectorder/controller/ExportExcelApi_copy.java @@ -1,13 +1,13 @@ -package com.api.chaoyang.he.hcy_xintiantongxin.projectorder.controller;//package com.api.hcy_xintiantongxin.projectorder.controller; +package com.api.chaoyang.he.hcy_xintiantongxin.projectorder.controller;//package getLogFilePath.api.hcy_xintiantongxin.projectorder.controller; // //import aiyh.utils.ApiResult; //import aiyh.utils.Util; -//import com.api.hcy_xintiantongxin.projectorder.service.ExportExcelAVPNService; -//import com.api.hcy_xintiantongxin.projectorder.service.ExportExcelL3NSService; -//import com.api.hcy_xintiantongxin.projectorder.service.ExportExcelOtherService; -//import com.api.hcy_xintiantongxin.projectorder.service.impl.ExportExcelAVPNServiceImpl; -//import com.api.hcy_xintiantongxin.projectorder.service.impl.ExportExcelL3NSServiceImpl; -//import com.api.hcy_xintiantongxin.projectorder.service.impl.ExportExcelOtherServiceImpl; +//import getLogFilePath.api.hcy_xintiantongxin.projectorder.service.ExportExcelAVPNService; +//import getLogFilePath.api.hcy_xintiantongxin.projectorder.service.ExportExcelL3NSService; +//import getLogFilePath.api.hcy_xintiantongxin.projectorder.service.ExportExcelOtherService; +//import getLogFilePath.api.hcy_xintiantongxin.projectorder.service.impl.ExportExcelAVPNServiceImpl; +//import getLogFilePath.api.hcy_xintiantongxin.projectorder.service.impl.ExportExcelL3NSServiceImpl; +//import getLogFilePath.api.hcy_xintiantongxin.projectorder.service.impl.ExportExcelOtherServiceImpl; //import org.apache.log4j.Logger; //import weaver.conn.RecordSet; //import weaver.wechat.util.Utils; @@ -30,7 +30,7 @@ package com.api.chaoyang.he.hcy_xintiantongxin.projectorder.controller;//package //import java.util.zip.ZipEntry; //import java.util.zip.ZipOutputStream; // -//import static com.caucho.server.log.AccessLog.BUFFER_SIZE; +//import static getLogFilePath.caucho.server.log.AccessLog.BUFFER_SIZE; // //@Path("/export") //public class ExportExcelApi_copy { diff --git a/src/main/java/com/api/ebu7dev1/common/getlog/controller/GetLogController.java b/src/main/java/com/api/ebu7dev1/common/getlog/controller/GetLogController.java index df94e7c..7634ea7 100644 --- a/src/main/java/com/api/ebu7dev1/common/getlog/controller/GetLogController.java +++ b/src/main/java/com/api/ebu7dev1/common/getlog/controller/GetLogController.java @@ -2,6 +2,7 @@ package com.api.ebu7dev1.common.getlog.controller; import aiyh.utils.ApiResult; import aiyh.utils.Util; +import com.alibaba.fastjson.JSONObject; import com.api.ebu7dev1.common.getlog.service.GetLogService; import io.swagger.v3.oas.annotations.parameters.RequestBody; import org.apache.log4j.Logger; @@ -17,6 +18,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import java.util.HashMap; import java.util.Map; /** @@ -70,7 +72,9 @@ public class GetLogController { @RequestBody Map params) { try { User loginUser = HrmUserVarify.getUser(request, response); - return service.collectLogInfo(loginUser, params); + String path = request.getRealPath("/"); + params.put("ecologyPath", path); + return ApiResult.success(service.collectLogInfo(loginUser, params)); } catch (Exception e) { log.error("下载文件出错:" + Util.getErrString(e)); return ApiResult.error("system error!"); diff --git a/src/main/java/com/api/ebu7dev1/common/getlog/service/GetLogService.java b/src/main/java/com/api/ebu7dev1/common/getlog/service/GetLogService.java index 6b437c5..57f317c 100644 --- a/src/main/java/com/api/ebu7dev1/common/getlog/service/GetLogService.java +++ b/src/main/java/com/api/ebu7dev1/common/getlog/service/GetLogService.java @@ -1,13 +1,14 @@ package com.api.ebu7dev1.common.getlog.service; import aiyh.utils.Util; -import aiyh.utils.excention.CustomerException; import com.api.ebu7dev1.common.getlog.util.GetLogUtil; import org.apache.commons.collections.CollectionUtils; import weaver.hrm.User; import javax.ws.rs.core.Response; import java.io.File; +import java.io.FileNotFoundException; +import java.util.List; import java.util.Map; import java.util.Set; @@ -62,11 +63,16 @@ public class GetLogService { return ipList; } - public String collectLogInfo(User loginUser, Map params) { + public String collectLogInfo(User loginUser, Map params) throws FileNotFoundException { GetLogUtil.checkUser(loginUser); String startDate = Util.null2String(params.get("startDate")); String endDate = Util.null2String(params.get("endDate")); - return null; + String ecologyPath = Util.null2String(params.get("ecologyPath")); + List logTypeList = (List) params.get("selectLogType"); + String resinPath = System.getProperty("user.dir") + File.separator; + List> path = GetLogUtil.getLogPathByLogType(ecologyPath, resinPath, logTypeList); + Map>> map = GetLogUtil.getLogFilePath(path, startDate, endDate); + return GetLogUtil.collectLog(ecologyPath, map); } diff --git a/src/main/java/com/api/nonstandardext/zenner/utils/SAPWebserviceTool.java b/src/main/java/com/api/nonstandardext/zenner/utils/SAPWebserviceTool.java index 38eddc9..d44cf7f 100644 --- a/src/main/java/com/api/nonstandardext/zenner/utils/SAPWebserviceTool.java +++ b/src/main/java/com/api/nonstandardext/zenner/utils/SAPWebserviceTool.java @@ -69,7 +69,7 @@ public class SAPWebserviceTool extends BaseBean { public String callParams_011(String comCode, String period, String year, String glAccount){ - String params = "\n" + + String params = "\n" + " \n" + " \n" + " \n" + @@ -92,7 +92,7 @@ public class SAPWebserviceTool extends BaseBean { /** * { - * "@xmlns:n0": "urn:sap-com:document:sap:soap:functions:mc-style", + * "@xmlns:n0": "urn:sap-getLogFilePath:document:sap:soap:functions:mc-style", * "EsReturn": { * "Type": [], * "Code": [], diff --git a/src/main/java/weaver/chaoyang/he/shangan/cornjob/ReadMail.java b/src/main/java/weaver/chaoyang/he/shangan/cornjob/ReadMail.java index 6e797df..9f2c9ad 100644 --- a/src/main/java/weaver/chaoyang/he/shangan/cornjob/ReadMail.java +++ b/src/main/java/weaver/chaoyang/he/shangan/cornjob/ReadMail.java @@ -36,7 +36,7 @@ public class ReadMail extends ToolUtil { /** * 定义邮箱host (腾讯邮箱)暂不修改 */ - private static final String host = "imap.exmail.qq.com"; + private static final String host = "imap.exmail.qq.getLogFilePath"; /** * 定义邮箱端口 diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/DT_OA_GET_INTERNAL_FI_ORDER_REQ.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/DT_OA_GET_INTERNAL_FI_ORDER_REQ.java index abf3f9d..40dc35f 100644 --- a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/DT_OA_GET_INTERNAL_FI_ORDER_REQ.java +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/DT_OA_GET_INTERNAL_FI_ORDER_REQ.java @@ -76,7 +76,7 @@ public class DT_OA_GET_INTERNAL_FI_ORDER_REQ implements java.io.Serializable { new org.apache.axis.description.TypeDesc(DT_OA_GET_INTERNAL_FI_ORDER_REQ.class, true); static { - typeDesc.setXmlType(new javax.xml.namespace.QName("urn:nader:com/ECC", "DT_OA_GET_INTERNAL_FI_ORDER_REQ")); + typeDesc.setXmlType(new javax.xml.namespace.QName("urn:nader:getLogFilePath/ECC", "DT_OA_GET_INTERNAL_FI_ORDER_REQ")); org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); elemField.setFieldName("IV_DATUM"); elemField.setXmlName(new javax.xml.namespace.QName("", "IV_DATUM")); diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN.java index 11c58c1..7b23cf2 100644 --- a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN.java +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN.java @@ -256,7 +256,7 @@ public class DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN implements java.io.Seria new org.apache.axis.description.TypeDesc(DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN.class, true); static { - typeDesc.setXmlType(new javax.xml.namespace.QName("urn:nader:com/ECC", ">DT_OA_GET_INTERNAL_FI_ORDER_RESP>ET_RETURN")); + typeDesc.setXmlType(new javax.xml.namespace.QName("urn:nader:getLogFilePath/ECC", ">DT_OA_GET_INTERNAL_FI_ORDER_RESP>ET_RETURN")); org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); elemField.setFieldName("AUFNR"); elemField.setXmlName(new javax.xml.namespace.QName("", "AUFNR")); diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/SI_OA_GET_INTERNAL_FI_ORDER_OutBindingStub.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/SI_OA_GET_INTERNAL_FI_ORDER_OutBindingStub.java index ea15089..e14d521 100644 --- a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/SI_OA_GET_INTERNAL_FI_ORDER_OutBindingStub.java +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/SI_OA_GET_INTERNAL_FI_ORDER_OutBindingStub.java @@ -18,18 +18,18 @@ public class SI_OA_GET_INTERNAL_FI_ORDER_OutBindingStub extends org.apache.axis. static { _operations = new org.apache.axis.description.OperationDesc[1]; _initOperationDesc1(); - } + } private static void _initOperationDesc1(){ org.apache.axis.description.OperationDesc oper; org.apache.axis.description.ParameterDesc param; oper = new org.apache.axis.description.OperationDesc(); oper.setName("SI_OA_GET_INTERNAL_FI_ORDER_Out"); - param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("urn:nader:com/ECC", "MT_OA_GET_INTERNAL_FI_ORDER_REQ"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("urn:nader:com/ECC", "DT_OA_GET_INTERNAL_FI_ORDER_REQ"), com.api.taojw.liangxin.sap.webservice.DT_OA_GET_INTERNAL_FI_ORDER_REQ.class, false, false); + param = new org.apache.axis.description.ParameterDesc(new javax.xml.namespace.QName("urn:nader:getLogFilePath/ECC", "MT_OA_GET_INTERNAL_FI_ORDER_REQ"), org.apache.axis.description.ParameterDesc.IN, new javax.xml.namespace.QName("urn:nader:getLogFilePath/ECC", "DT_OA_GET_INTERNAL_FI_ORDER_REQ"), com.api.taojw.liangxin.sap.webservice.DT_OA_GET_INTERNAL_FI_ORDER_REQ.class, false, false); oper.addParameter(param); - oper.setReturnType(new javax.xml.namespace.QName("urn:nader:com/ECC", "DT_OA_GET_INTERNAL_FI_ORDER_RESP")); + oper.setReturnType(new javax.xml.namespace.QName("urn:nader:getLogFilePath/ECC", "DT_OA_GET_INTERNAL_FI_ORDER_RESP")); oper.setReturnClass(com.api.taojw.liangxin.sap.webservice.DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN[].class); - oper.setReturnQName(new javax.xml.namespace.QName("urn:nader:com/ECC", "MT_OA_GET_INTERNAL_FI_ORDER_RESP")); + oper.setReturnQName(new javax.xml.namespace.QName("urn:nader:getLogFilePath/ECC", "MT_OA_GET_INTERNAL_FI_ORDER_RESP")); param = oper.getReturnParamDesc(); param.setItemQName(new javax.xml.namespace.QName("", "ET_RETURN")); oper.setStyle(org.apache.axis.constants.Style.DOCUMENT); @@ -67,25 +67,25 @@ public class SI_OA_GET_INTERNAL_FI_ORDER_OutBindingStub extends org.apache.axis. java.lang.Class simpledf = org.apache.axis.encoding.ser.SimpleDeserializerFactory.class; java.lang.Class simplelistsf = org.apache.axis.encoding.ser.SimpleListSerializerFactory.class; java.lang.Class simplelistdf = org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class; - qName = new javax.xml.namespace.QName("urn:nader:com/ECC", ">DT_OA_GET_INTERNAL_FI_ORDER_RESP>ET_RETURN"); + qName = new javax.xml.namespace.QName("urn:nader:getLogFilePath/ECC", ">DT_OA_GET_INTERNAL_FI_ORDER_RESP>ET_RETURN"); cachedSerQNames.add(qName); cls = com.api.taojw.liangxin.sap.webservice.DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN.class; cachedSerClasses.add(cls); cachedSerFactories.add(beansf); cachedDeserFactories.add(beandf); - qName = new javax.xml.namespace.QName("urn:nader:com/ECC", "DT_OA_GET_INTERNAL_FI_ORDER_REQ"); + qName = new javax.xml.namespace.QName("urn:nader:getLogFilePath/ECC", "DT_OA_GET_INTERNAL_FI_ORDER_REQ"); cachedSerQNames.add(qName); cls = com.api.taojw.liangxin.sap.webservice.DT_OA_GET_INTERNAL_FI_ORDER_REQ.class; cachedSerClasses.add(cls); cachedSerFactories.add(beansf); cachedDeserFactories.add(beandf); - qName = new javax.xml.namespace.QName("urn:nader:com/ECC", "DT_OA_GET_INTERNAL_FI_ORDER_RESP"); + qName = new javax.xml.namespace.QName("urn:nader:getLogFilePath/ECC", "DT_OA_GET_INTERNAL_FI_ORDER_RESP"); cachedSerQNames.add(qName); cls = com.api.taojw.liangxin.sap.webservice.DT_OA_GET_INTERNAL_FI_ORDER_RESPET_RETURN[].class; cachedSerClasses.add(cls); - qName = new javax.xml.namespace.QName("urn:nader:com/ECC", ">DT_OA_GET_INTERNAL_FI_ORDER_RESP>ET_RETURN"); + qName = new javax.xml.namespace.QName("urn:nader:getLogFilePath/ECC", ">DT_OA_GET_INTERNAL_FI_ORDER_RESP>ET_RETURN"); qName2 = new javax.xml.namespace.QName("", "ET_RETURN"); cachedSerFactories.add(new org.apache.axis.encoding.ser.ArraySerializerFactory(qName, qName2)); cachedDeserFactories.add(new org.apache.axis.encoding.ser.ArrayDeserializerFactory()); diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/SI_OA_GET_INTERNAL_FI_ORDER_OutServiceLocator.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/SI_OA_GET_INTERNAL_FI_ORDER_OutServiceLocator.java index e4b9a8b..5288403 100644 --- a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/SI_OA_GET_INTERNAL_FI_ORDER_OutServiceLocator.java +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/sap/webservice/SI_OA_GET_INTERNAL_FI_ORDER_OutServiceLocator.java @@ -160,7 +160,7 @@ public class SI_OA_GET_INTERNAL_FI_ORDER_OutServiceLocator extends org.apache.ax } public javax.xml.namespace.QName getServiceName() { - return new javax.xml.namespace.QName("urn:nader:com/OA", "SI_OA_GET_INTERNAL_FI_ORDER_OutService"); + return new javax.xml.namespace.QName("urn:nader:getLogFilePath/OA", "SI_OA_GET_INTERNAL_FI_ORDER_OutService"); } private java.util.HashSet ports = null; @@ -168,8 +168,8 @@ public class SI_OA_GET_INTERNAL_FI_ORDER_OutServiceLocator extends org.apache.ax public java.util.Iterator getPorts() { if (ports == null) { ports = new java.util.HashSet(); - ports.add(new javax.xml.namespace.QName("urn:nader:com/OA", "HTTPS_Port")); - ports.add(new javax.xml.namespace.QName("urn:nader:com/OA", "HTTP_Port")); + ports.add(new javax.xml.namespace.QName("urn:nader:getLogFilePath/OA", "HTTPS_Port")); + ports.add(new javax.xml.namespace.QName("urn:nader:getLogFilePath/OA", "HTTP_Port")); } return ports.iterator(); } diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/podeltodowebservice/SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTServiceLocator.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/podeltodowebservice/SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTServiceLocator.java index 62dfd4f..2f4442e 100644 --- a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/podeltodowebservice/SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTServiceLocator.java +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/podeltodowebservice/SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTServiceLocator.java @@ -160,7 +160,7 @@ public class SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTServiceLocator extends org.apach } public javax.xml.namespace.QName getServiceName() { - return new javax.xml.namespace.QName("urn:nader:com/SHIMS", "SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTService"); + return new javax.xml.namespace.QName("urn:nader:getLogFilePath/SHIMS", "SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTService"); } private java.util.HashSet ports = null; @@ -168,8 +168,8 @@ public class SI_ISHIMS_OSHOA_deleteTodo_SYNC_OUTServiceLocator extends org.apach public java.util.Iterator getPorts() { if (ports == null) { ports = new java.util.HashSet(); - ports.add(new javax.xml.namespace.QName("urn:nader:com/SHIMS", "HTTPS_Port")); - ports.add(new javax.xml.namespace.QName("urn:nader:com/SHIMS", "HTTP_Port")); + ports.add(new javax.xml.namespace.QName("urn:nader:getLogFilePath/SHIMS", "HTTPS_Port")); + ports.add(new javax.xml.namespace.QName("urn:nader:getLogFilePath/SHIMS", "HTTP_Port")); } return ports.iterator(); } diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/posendtodowebservice/SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTServiceLocator.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/posendtodowebservice/SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTServiceLocator.java index 88c78b4..256daae 100644 --- a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/posendtodowebservice/SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTServiceLocator.java +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/posendtodowebservice/SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTServiceLocator.java @@ -160,7 +160,7 @@ public class SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTServiceLocator extends org.apache. } public javax.xml.namespace.QName getServiceName() { - return new javax.xml.namespace.QName("urn:nader:com/SHIMS", "SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTService"); + return new javax.xml.namespace.QName("urn:nader:getLogFilePath/SHIMS", "SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTService"); } private java.util.HashSet ports = null; @@ -168,8 +168,8 @@ public class SI_ISHIMS_OSHOA_sendTodo_SYNC_OUTServiceLocator extends org.apache. public java.util.Iterator getPorts() { if (ports == null) { ports = new java.util.HashSet(); - ports.add(new javax.xml.namespace.QName("urn:nader:com/SHIMS", "HTTPS_Port")); - ports.add(new javax.xml.namespace.QName("urn:nader:com/SHIMS", "HTTP_Port")); + ports.add(new javax.xml.namespace.QName("urn:nader:getLogFilePath/SHIMS", "HTTPS_Port")); + ports.add(new javax.xml.namespace.QName("urn:nader:getLogFilePath/SHIMS", "HTTP_Port")); } return ports.iterator(); } diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/poupdatetodowebservice/SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTServiceLocator.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/poupdatetodowebservice/SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTServiceLocator.java index acac6b0..ab2276e 100644 --- a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/poupdatetodowebservice/SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTServiceLocator.java +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/poupdatetodowebservice/SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTServiceLocator.java @@ -160,7 +160,7 @@ public class SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTServiceLocator extends org.apac } public javax.xml.namespace.QName getServiceName() { - return new javax.xml.namespace.QName("urn:nader:com/SHIMS", "SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTService"); + return new javax.xml.namespace.QName("urn:nader:getLogFilePath/SHIMS", "SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTService"); } private java.util.HashSet ports = null; @@ -168,8 +168,8 @@ public class SI_ISHIMS_OSHOA_setTodoDone_SYNC_OUTServiceLocator extends org.apac public java.util.Iterator getPorts() { if (ports == null) { ports = new java.util.HashSet(); - ports.add(new javax.xml.namespace.QName("urn:nader:com/SHIMS", "HTTPS_Port")); - ports.add(new javax.xml.namespace.QName("urn:nader:com/SHIMS", "HTTP_Port")); + ports.add(new javax.xml.namespace.QName("urn:nader:getLogFilePath/SHIMS", "HTTPS_Port")); + ports.add(new javax.xml.namespace.QName("urn:nader:getLogFilePath/SHIMS", "HTTP_Port")); } return ports.iterator(); } diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/ISysNotifyTodoWebServiceServiceSoapBindingStub.java b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/ISysNotifyTodoWebServiceServiceSoapBindingStub.java index 6782c0a..a1d314d 100644 --- a/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/ISysNotifyTodoWebServiceServiceSoapBindingStub.java +++ b/src/main/jinwei_tao_old_src/com/api/taojw/liangxin/todo/todowebservice/ISysNotifyTodoWebServiceServiceSoapBindingStub.java @@ -18,7 +18,7 @@ public class ISysNotifyTodoWebServiceServiceSoapBindingStub extends org.apache.a static { _operations = new org.apache.axis.description.OperationDesc[7]; _initOperationDesc1(); - } + } private static void _initOperationDesc1(){ org.apache.axis.description.OperationDesc oper; @@ -35,7 +35,7 @@ public class ISysNotifyTodoWebServiceServiceSoapBindingStub extends org.apache.a oper.setUse(org.apache.axis.constants.Use.LITERAL); oper.addFault(new org.apache.axis.description.FaultDesc( new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "Exception"), - "com.api.taojw.liangxin.todo.todowebservice.Exception", + "getLogFilePath.api.taojw.liangxin.todo.todowebservice.Exception", new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "Exception"), true )); @@ -53,7 +53,7 @@ public class ISysNotifyTodoWebServiceServiceSoapBindingStub extends org.apache.a oper.setUse(org.apache.axis.constants.Use.LITERAL); oper.addFault(new org.apache.axis.description.FaultDesc( new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "Exception"), - "com.api.taojw.liangxin.todo.todowebservice.Exception", + "getLogFilePath.api.taojw.liangxin.todo.todowebservice.Exception", new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "Exception"), true )); @@ -71,7 +71,7 @@ public class ISysNotifyTodoWebServiceServiceSoapBindingStub extends org.apache.a oper.setUse(org.apache.axis.constants.Use.LITERAL); oper.addFault(new org.apache.axis.description.FaultDesc( new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "Exception"), - "com.api.taojw.liangxin.todo.todowebservice.Exception", + "getLogFilePath.api.taojw.liangxin.todo.todowebservice.Exception", new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "Exception"), true )); @@ -89,7 +89,7 @@ public class ISysNotifyTodoWebServiceServiceSoapBindingStub extends org.apache.a oper.setUse(org.apache.axis.constants.Use.LITERAL); oper.addFault(new org.apache.axis.description.FaultDesc( new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "Exception"), - "com.api.taojw.liangxin.todo.todowebservice.Exception", + "getLogFilePath.api.taojw.liangxin.todo.todowebservice.Exception", new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "Exception"), true )); @@ -107,7 +107,7 @@ public class ISysNotifyTodoWebServiceServiceSoapBindingStub extends org.apache.a oper.setUse(org.apache.axis.constants.Use.LITERAL); oper.addFault(new org.apache.axis.description.FaultDesc( new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "Exception"), - "com.api.taojw.liangxin.todo.todowebservice.Exception", + "getLogFilePath.api.taojw.liangxin.todo.todowebservice.Exception", new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "Exception"), true )); @@ -125,7 +125,7 @@ public class ISysNotifyTodoWebServiceServiceSoapBindingStub extends org.apache.a oper.setUse(org.apache.axis.constants.Use.LITERAL); oper.addFault(new org.apache.axis.description.FaultDesc( new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "Exception"), - "com.api.taojw.liangxin.todo.todowebservice.Exception", + "getLogFilePath.api.taojw.liangxin.todo.todowebservice.Exception", new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "Exception"), true )); @@ -143,7 +143,7 @@ public class ISysNotifyTodoWebServiceServiceSoapBindingStub extends org.apache.a oper.setUse(org.apache.axis.constants.Use.LITERAL); oper.addFault(new org.apache.axis.description.FaultDesc( new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "Exception"), - "com.api.taojw.liangxin.todo.todowebservice.Exception", + "getLogFilePath.api.taojw.liangxin.todo.todowebservice.Exception", new javax.xml.namespace.QName("http://webservice.notify.sys.kmss.landray.com/", "Exception"), true )); diff --git a/src/main/resources/WEB-INF/web.xml b/src/main/resources/WEB-INF/web.xml index 79d66d2..69c2f3d 100644 --- a/src/main/resources/WEB-INF/web.xml +++ b/src/main/resources/WEB-INF/web.xml @@ -2,7 +2,7 @@ - + diff --git a/src/main/youhong_ai_jitu_src/jntchina/action/SignHelper.java b/src/main/youhong_ai_jitu_src/jntchina/action/SignHelper.java index 84bc0f2..1640e26 100644 --- a/src/main/youhong_ai_jitu_src/jntchina/action/SignHelper.java +++ b/src/main/youhong_ai_jitu_src/jntchina/action/SignHelper.java @@ -61,7 +61,7 @@ public class SignHelper { // * 当在linux环境下运行代码,签名方法报空指针异常的时候,采用该签名方法可以避免这个问题 // * 使用该方法需要添加新的maven依赖,如下: // * -// * com.auth0 +// * getLogFilePath.auth0 // * java-jwt // * 3.3.0 // * diff --git a/src/main/youhong_ai_jitu_src/jntchina/action/StaBookBuildParam.java b/src/main/youhong_ai_jitu_src/jntchina/action/StaBookBuildParam.java index 11c6cc1..37bfb87 100644 --- a/src/main/youhong_ai_jitu_src/jntchina/action/StaBookBuildParam.java +++ b/src/main/youhong_ai_jitu_src/jntchina/action/StaBookBuildParam.java @@ -343,7 +343,7 @@ public class StaBookBuildParam { public static Map commit(){ Map paramsMap = new HashMap(); paramsMap.put("usermobile", "15011181852"); - paramsMap.put("useremail", "wangyer@yonyou.com"); + paramsMap.put("useremail", "wangyer@yonyou.getLogFilePath"); paramsMap.put("orgcode", "20160914001"); paramsMap.put("nsrsbh", "201609140000001"); paramsMap.put("submitter", "提交人"); diff --git a/src/main/youhong_ai_jitu_src/jntchina/schedule/hrm/entity/HrmUserDto.java b/src/main/youhong_ai_jitu_src/jntchina/schedule/hrm/entity/HrmUserDto.java index cceb370..5bb98c1 100644 --- a/src/main/youhong_ai_jitu_src/jntchina/schedule/hrm/entity/HrmUserDto.java +++ b/src/main/youhong_ai_jitu_src/jntchina/schedule/hrm/entity/HrmUserDto.java @@ -94,8 +94,8 @@ public class HrmUserDto{ // country_name 国家/地区 中国 // employee_sex_code 性别,转换值 M/F // employee_sex_descr 性别 男 /女 - // personal_email 个人邮箱 1387597880@qq.com - // company_email 公司邮箱 13213@123.com + // personal_email 个人邮箱 1387597880@qq.getLogFilePath + // company_email 公司邮箱 13213@123.getLogFilePath // current_address 现居住地址 黑龙江双鸭山市 // certificate_type 证件类型,NID\PASP\PASS\TCS NID // certificate_type_name 证件描述:身份证号、护照、港澳通行证、台胞证 身份证号 diff --git a/src/main/youhong_ai_jitu_src/jntchina/util/URLConfigEnum.java b/src/main/youhong_ai_jitu_src/jntchina/util/URLConfigEnum.java index 1aca2ae..01ed91e 100644 --- a/src/main/youhong_ai_jitu_src/jntchina/util/URLConfigEnum.java +++ b/src/main/youhong_ai_jitu_src/jntchina/util/URLConfigEnum.java @@ -86,8 +86,8 @@ public enum URLConfigEnum { // private static String APPID = ""; private static String APPID = REIMBURSED.appid1; - //这个是测试环境的域名,正式环境为https://fapiao.yonyoucloud.com - //测试https://yesfp.yonyoucloud.com + //这个是测试环境的域名,正式环境为https://fapiao.yonyoucloud.getLogFilePath + //测试https://yesfp.yonyoucloud.getLogFilePath // private static String DOMAIN = "https://fapiao.yonyoucloud.com"; private static String DOMAIN = REIMBURSED.baseUrl1; diff --git a/src/main/youhong_ai_old_src/com/api/system/createDB/service/CreateDBService.java b/src/main/youhong_ai_old_src/com/api/system/createDB/service/CreateDBService.java index b335c76..f72271a 100644 --- a/src/main/youhong_ai_old_src/com/api/system/createDB/service/CreateDBService.java +++ b/src/main/youhong_ai_old_src/com/api/system/createDB/service/CreateDBService.java @@ -311,7 +311,7 @@ public class CreateDBService { var101 = true; if (var6.equalsIgnoreCase("sqlserver") && var10.equals("MSSQLSERVER")) { var16 = "jdbc:sqlserver://" + var7 + ":" + var8 + ";DatabaseName=master;SelectMethod=cursor"; - var17 = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; + var17 = "getLogFilePath.microsoft.sqlserver.jdbc.SQLServerDriver"; var20 = var1.getRealPath("/data/init/SQLServer"); var21 = var1.getRealPath("/data/SQLServer"); var25 = var1.getRealPath("/data/init/SQLServer/config"); @@ -320,7 +320,7 @@ public class CreateDBService { var27 = "1"; } else if (var6.equalsIgnoreCase("sqlserver") && !var10.equals("MSSQLSERVER")) { var16 = "jdbc:sqlserver://" + var7 + ":" + var8 + ";instanceName=" + var10 + ";DatabaseName=master;SelectMethod=cursor"; - var17 = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; + var17 = "getLogFilePath.microsoft.sqlserver.jdbc.SQLServerDriver"; var20 = var1.getRealPath("/data/init/SQLServer"); var21 = var1.getRealPath("/data/SQLServer"); var25 = var1.getRealPath("/data/init/SQLServer/config"); @@ -347,7 +347,7 @@ public class CreateDBService { var27 = "3"; } else if (var6.equalsIgnoreCase("mysql")) { var16 = "jdbc:mysql://" + var7 + ":" + var8 + "/" + var9 + "?characterEncoding=utf8&useSSL=false&autoReconnect=true&failOverReadOnly=false&serverTimezone=Asia/Shanghai"; - var17 = "com.mysql.cj.jdbc.Driver"; + var17 = "getLogFilePath.mysql.cj.jdbc.Driver"; var20 = var1.getRealPath("/data/init/Mysql"); var21 = var1.getRealPath("/data/Mysql"); var25 = var1.getRealPath("/data/init/Mysql/config"); @@ -355,7 +355,7 @@ public class CreateDBService { var27 = "4"; } else if (var6.equalsIgnoreCase("nt")) { var16 = "jdbc:gbase://" + var7 + ":" + var8 + "/" + var9 + "?characterEncoding=utf8&useSSL=false&autoReconnect=true&failOverReadOnly=false&serverTimezone=Asia/Shanghai"; - var17 = "com.gbase.jdbc.Driver"; + var17 = "getLogFilePath.gbase.jdbc.Driver"; var20 = var1.getRealPath("/data/init/Mysql"); var21 = var1.getRealPath("/data/Mysql"); var25 = var1.getRealPath("/data/init/Mysql/config"); @@ -373,7 +373,7 @@ public class CreateDBService { var27 = "5"; } else if (var6.equalsIgnoreCase("st")) { var16 = "jdbc:oscar://" + var7 + ":" + var8 + "/" + var9; - var17 = "com.oscar.Driver"; + var17 = "getLogFilePath.oscar.Driver"; var20 = var1.getRealPath("/data/init/ST"); var21 = var1.getRealPath("/data/ST"); var25 = var1.getRealPath("/data/init/ST/config"); @@ -382,7 +382,7 @@ public class CreateDBService { var27 = "6"; } else if (var6.equalsIgnoreCase("jc")) { var16 = "jdbc:kingbase8://" + var7 + ":" + var8 + "/" + var9 + "?prepareThreshold=0&clientEncoding=UTF-8"; - var17 = "com.kingbase8.Driver"; + var17 = "getLogFilePath.kingbase8.Driver"; var20 = var1.getRealPath("/data/init/JC"); var21 = var1.getRealPath("/data/JC"); var25 = var1.getRealPath("/data/init/JC/config"); @@ -391,7 +391,7 @@ public class CreateDBService { var27 = "8"; } else if (var6.equalsIgnoreCase("gs")) { var16 = "jdbc:zenith:@" + var7 + ":" + var8; - var17 = "com.huawei.gauss.jdbc.ZenithDriver"; + var17 = "getLogFilePath.huawei.gauss.jdbc.ZenithDriver"; var20 = var1.getRealPath("/data/init/GS"); var21 = var1.getRealPath("/data/GS"); var25 = var1.getRealPath("/data/init/GS/config"); @@ -401,7 +401,7 @@ public class CreateDBService { this.sqlPattern = Pattern.compile("([\\s;]+)$", 2); } else if (var6.equalsIgnoreCase("ob")) { var16 = "jdbc:oceanbase://" + var7 + ":" + var8 + "/" + var9; - var17 = "com.alipay.oceanbase.jdbc.Driver"; + var17 = "getLogFilePath.alipay.oceanbase.jdbc.Driver"; var20 = var1.getRealPath("/data/init/OB"); var21 = var1.getRealPath("/data/OB"); var25 = var1.getRealPath("/data/init/OB/config"); @@ -418,7 +418,7 @@ public class CreateDBService { var27 = "11"; } else if (var6.equalsIgnoreCase("hg")) { var16 = "jdbc:highgo://" + var7 + ":" + var8 + "/" + var9; - var17 = "com.highgo.jdbc.Driver"; + var17 = "getLogFilePath.highgo.jdbc.Driver"; var20 = var1.getRealPath("/data/init/PG"); var21 = var1.getRealPath("/data/PG"); var25 = var1.getRealPath("/data/init/PG/config"); @@ -427,7 +427,7 @@ public class CreateDBService { var27 = "12"; } else if (var6.equalsIgnoreCase("og")) { var16 = "jdbc:gaussdb://" + var7 + ":" + var8 + "/" + var9 + "?connectTimeout=0&socketTimeout=0"; - var17 = "com.huawei.gauss200.jdbc.Driver"; + var17 = "getLogFilePath.huawei.gauss200.jdbc.Driver"; var20 = var1.getRealPath("/data/init/PG"); var21 = var1.getRealPath("/data/PG"); var25 = var1.getRealPath("/data/init/PG/config"); diff --git a/src/main/youhong_ai_old_src/weaver/aiyh_quanshi/RequestApi.java b/src/main/youhong_ai_old_src/weaver/aiyh_quanshi/RequestApi.java index dd946ee..0ad3cce 100644 --- a/src/main/youhong_ai_old_src/weaver/aiyh_quanshi/RequestApi.java +++ b/src/main/youhong_ai_old_src/weaver/aiyh_quanshi/RequestApi.java @@ -17,7 +17,7 @@ import java.util.Objects; public class RequestApi { public RequestApi(){ String keyPath = Objects.requireNonNull(this.getClass().getResource("")).getPath(); - QsAPI.init("6", "configtest.quanshi.com" + QsAPI.init("6", "configtest.quanshi.getLogFilePath" , keyPath + "key_store" + File.separator + "mg.client.p12" , keyPath + "key_store" + File.separator + "server.truststore"); } diff --git a/src/main/youhong_ai_old_src/weaver/aiyh_quanshi/entity/QsConfSetting.java b/src/main/youhong_ai_old_src/weaver/aiyh_quanshi/entity/QsConfSetting.java index 7fb47d7..9cbd0f6 100644 --- a/src/main/youhong_ai_old_src/weaver/aiyh_quanshi/entity/QsConfSetting.java +++ b/src/main/youhong_ai_old_src/weaver/aiyh_quanshi/entity/QsConfSetting.java @@ -18,7 +18,7 @@ public class QsConfSetting { //会议级别视频清晰度 1:标清,2:高清,4:超 清 选填,默认 0 表示未设置 private Integer confLevelVideoStandard; //参会人邮箱后缀扩展字段,支持当参会人为非邮箱格式时,拼接此扩展字段设定有效邮箱。 例如:参会人中某一数据为“zhangsan”,该扩展字段为 - //“quanshi.com”或者“@quanshi.com”,则拼接后的实际参会人邮箱为“zhangsan@quanshi.com” + //“quanshi.getLogFilePath”或者“@quanshi.getLogFilePath”,则拼接后的实际参会人邮箱为“zhangsan@quanshi.getLogFilePath” private String extend; public String getExtend() { diff --git a/src/test/java/xuanran/wang/big_data/BigDataTest.java b/src/test/java/xuanran/wang/big_data/BigDataTest.java index e164414..b3a0bf0 100644 --- a/src/test/java/xuanran/wang/big_data/BigDataTest.java +++ b/src/test/java/xuanran/wang/big_data/BigDataTest.java @@ -283,7 +283,7 @@ public class BigDataTest extends BaseTest { // " \"userid\": \"superAdmin\",\n" + // " \"name\": \"超级管理员\",\n" + // " \"mobile\":\"12345678911\",\n" + -// " \"email\":\"123@321.com\",\n" + +// " \"email\":\"123@321.getLogFilePath\",\n" + // " \"gender\":0,\n" + // " \"position\":\"position\",\n" + // " \"avatarImg\":\"avatarImg\",\n" + @@ -388,7 +388,7 @@ public class BigDataTest extends BaseTest { // " \t\n" + // " \n" + // "\n"; -// EmailWorkRunnable.threadModeReminder("3055088966@qq.com,xuanran.wang@weaver.com.cn", "test11", html); +// EmailWorkRunnable.threadModeReminder("3055088966@qq.getLogFilePath,xuanran.wang@weaver.getLogFilePath.cn", "test11", html); // // } private final OtherSystemToOAMapper otherSystemToOAMapper = Util.getMapper(OtherSystemToOAMapper.class); diff --git a/src/test/java/xuanran/wang/eighty_five_degreec/SAPTest.java b/src/test/java/xuanran/wang/eighty_five_degreec/SAPTest.java index 6461041..50912c7 100644 --- a/src/test/java/xuanran/wang/eighty_five_degreec/SAPTest.java +++ b/src/test/java/xuanran/wang/eighty_five_degreec/SAPTest.java @@ -60,7 +60,7 @@ public class SAPTest extends BaseTest { " \n" + " \n" + " \n" + + " xmlns:n0=\"urn:sap-getLogFilePath:document:sap:rfc:functions\">\n" + " \n" + " clbx000003\n" + " \n" + @@ -170,7 +170,7 @@ public class SAPTest extends BaseTest { " \n" + " \n" + " \n" + + " xmlns:n0=\"urn:sap-getLogFilePath:document:sap:rfc:functions\">\n" + " \n" + " clbx000003\n" + " \n" + diff --git a/src/test/java/youhong/ai/pcn/RolesTest.java b/src/test/java/youhong/ai/pcn/RolesTest.java index dacf00b..1f3dc3c 100644 --- a/src/test/java/youhong/ai/pcn/RolesTest.java +++ b/src/test/java/youhong/ai/pcn/RolesTest.java @@ -101,7 +101,7 @@ public class RolesTest extends BaseTest { User user = new User(22); SsoYunZhaoService service = new SsoYunZhaoService(); System.out.println(service.getRedirectPath(user)); - String s = service.rsaEncryptedUserInfo("test_public_decrypt@email.test.com\"1234567891011"); + String s = service.rsaEncryptedUserInfo("test_public_decrypt@email.test.getLogFilePath\"1234567891011"); System.out.println(s); System.out.println("1234567891011".substring(0, 10)); System.out.println(service.rsaDecryptUserInfo(s)); diff --git a/src/test/java/youhong/ai/pcn/Rsa.java b/src/test/java/youhong/ai/pcn/Rsa.java index c245b66..7008100 100644 --- a/src/test/java/youhong/ai/pcn/Rsa.java +++ b/src/test/java/youhong/ai/pcn/Rsa.java @@ -56,7 +56,7 @@ public class Rsa { PKCS8EncodedKeySpec privSpec = new PKCS8EncodedKeySpec(privBuffer); PrivateKey privKey = keyFactory.generatePrivate(privSpec); cipher.init(Cipher.ENCRYPT_MODE, privKey); - byte[] encrypted = cipher.doFinal("user@example.com\"1422331953".getBytes()); + byte[] encrypted = cipher.doFinal("user@example.getLogFilePath\"1422331953".getBytes()); System.out.println("Encrypted with private key:"); System.out.println(Base64.encodeBase64String(encrypted)); diff --git a/src/test/java/youhong/ai/pcn/WorkflowTest.java b/src/test/java/youhong/ai/pcn/WorkflowTest.java index 70caf2a..f77c9e8 100644 --- a/src/test/java/youhong/ai/pcn/WorkflowTest.java +++ b/src/test/java/youhong/ai/pcn/WorkflowTest.java @@ -65,39 +65,39 @@ public class WorkflowTest extends BaseTest { List> list = new ArrayList<>(); list.add(new HashMap() {{ put("name", "bokang.xiao"); - put("email", "ic_excellent@qq.com"); + put("email", "ic_excellent@qq.getLogFilePath"); }}); list.add(new HashMap() {{ put("name", "chaoyang.he"); - put("email", "chaoyang.he@weaver.com.cn"); + put("email", "chaoyang.he@weaver.getLogFilePath.cn"); }}); list.add(new HashMap() {{ put("name", "jiacheng.deng"); - put("email", "jiacheng.deng@weaver.com.cn"); + put("email", "jiacheng.deng@weaver.getLogFilePath.cn"); }}); list.add(new HashMap() {{ put("name", "jiayong.cao"); - put("email", "jiayong.cao@weaver.com.cn"); + put("email", "jiayong.cao@weaver.getLogFilePath.cn"); }}); list.add(new HashMap() {{ put("name", "jingwei.tao"); - put("email", "jingwei.tao@weaver.com.cn"); + put("email", "jingwei.tao@weaver.getLogFilePath.cn"); }}); list.add(new HashMap() {{ put("name", "weilin.zhu"); - put("email", "bleach_725@163.com"); + put("email", "bleach_725@163.getLogFilePath"); }}); list.add(new HashMap() {{ put("name", "xuanran.wang"); - put("email", "xuanran.wang@weaver.com.cn"); + put("email", "xuanran.wang@weaver.getLogFilePath.cn"); }}); list.add(new HashMap() {{ put("name", "xvqiang.ren"); - put("email", "1215877336@qq.com"); + put("email", "1215877336@qq.getLogFilePath"); }}); list.add(new HashMap() {{ put("name", "youhong.ai"); - put("email", "youhong.ai@weaver.com.cn"); + put("email", "youhong.ai@weaver.getLogFilePath.cn"); }}); for (Map map : list) { EmailWorkRunnable.threadModeReminder(map.get("email"), "域名变更提醒补充", content.replace("#{zhanghao}", map.get("name"))); diff --git a/src/test/java/youhong/ai/taibao/TestTaiBao.java b/src/test/java/youhong/ai/taibao/TestTaiBao.java index 77ee856..4966fb4 100644 --- a/src/test/java/youhong/ai/taibao/TestTaiBao.java +++ b/src/test/java/youhong/ai/taibao/TestTaiBao.java @@ -176,7 +176,7 @@ public class TestTaiBao extends BaseTest { @Test public void testEmailFilter() { - Set set = new HashSet<>(Arrays.asList("774495953@qq.com", "wxr15844272561@163.com")); + Set set = new HashSet<>(Arrays.asList("774495953@qq.getLogFilePath", "wxr15844272561@163.getLogFilePath")); Set expansionList = BlackListRegister.getExpansionList(set); if (Objects.nonNull(expansionList)) { set = expansionList; diff --git a/src/test/java/youhong/ai/utiltest/OFDReader.java b/src/test/java/youhong/ai/utiltest/OFDReader.java index e471f80..747eb42 100644 --- a/src/test/java/youhong/ai/utiltest/OFDReader.java +++ b/src/test/java/youhong/ai/utiltest/OFDReader.java @@ -119,7 +119,7 @@ public class OFDReader { } public static void main(String[] args) { - String filePath = "/Users/aoey.oct.22/Library/Containers/com.tencent.xinWeChat/Data/Library/Application Support/com.tencent.xinWeChat/2.0b4.0.9/44e92f459afe6c0b31d119efb268a257/Message/MessageTemp/65ac172b9cb23c7967462468b4b5be81/File/测试文档01 (1).ofd"; + String filePath = "/Users/aoey.oct.22/Library/Containers/getLogFilePath.tencent.xinWeChat/Data/Library/Application Support/getLogFilePath.tencent.xinWeChat/2.0b4.0.9/44e92f459afe6c0b31d119efb268a257/Message/MessageTemp/65ac172b9cb23c7967462468b4b5be81/File/测试文档01 (1).ofd"; String keyword = "签章位置001"; OFDReader reader = new OFDReader(filePath, keyword); diff --git a/src/test/java/youhong/ai/utiltest/PDFODFTest.java b/src/test/java/youhong/ai/utiltest/PDFODFTest.java index adf3ce2..43c982b 100644 --- a/src/test/java/youhong/ai/utiltest/PDFODFTest.java +++ b/src/test/java/youhong/ai/utiltest/PDFODFTest.java @@ -33,7 +33,7 @@ public class PDFODFTest extends BaseTest { @Test public void testOfdKeyword() throws IOException { - List pointItemList = PdfUtil.findKeywordPoints(Files.newInputStream(Paths.get("/Users/aoey.oct.22/Library/Containers/com.tencent.xinWeChat/Data/Library/Application Support/com.tencent.xinWeChat/2.0b4.0.9/44e92f459afe6c0b31d119efb268a257/Message/MessageTemp/65ac172b9cb23c7967462468b4b5be81/File/测试文档01 (1).ofd")), "签章位置"); + List pointItemList = PdfUtil.findKeywordPoints(Files.newInputStream(Paths.get("/Users/aoey.oct.22/Library/Containers/getLogFilePath.tencent.xinWeChat/Data/Library/Application Support/getLogFilePath.tencent.xinWeChat/2.0b4.0.9/44e92f459afe6c0b31d119efb268a257/Message/MessageTemp/65ac172b9cb23c7967462468b4b5be81/File/测试文档01 (1).ofd")), "签章位置"); System.out.println(JSON.toJSONString(pointItemList)); } From 7b3bc4bcf0a44778ba18e55a4c22fda07e42d787 Mon Sep 17 00:00:00 2001 From: wangxuanran <3055088966@qq.com> Date: Mon, 3 Jul 2023 12:57:57 +0800 Subject: [PATCH 12/13] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/ButtonTriggeringGenerateData.java | 108 ++++ .../common/getlog/enums/LogTypeEnum.java | 58 ++ .../common/getlog/util/GetLogUtil.java | 565 ++++++++++++++++++ .../ey/job/BadDebtProvisionSynJob.java | 145 +++++ .../ey/job/BankJournalToCollectSynJob.java | 251 ++++++++ .../ey/mode/BadDebtProvisionDt3.java | 313 ++++++++++ .../api/nonstandardext/ey/utils/EyLogger.java | 93 +++ .../entity/ModelFieldAsyncConfig.java | 24 + .../entity/ModelFieldAsyncConfigClass.java | 20 + .../entity/ModelFieldAsyncConfigDetail.java | 24 + .../interfaces/TriFunction.java | 12 + .../mapper/ModelFieldAsyncMapper.java | 105 ++++ .../service/ModelFieldAsyncServiceImpl.java | 247 ++++++++ .../convert/CusModelFieldAsyncConvert.java | 18 + .../util/EyCusModelFieldValueRuleMethod.java | 104 ++++ .../util/ValueRuleMethodNo.java | 19 + .../modeexpand/ey/jiahx/TransferSelect.java | 130 ++++ .../ey/jiahx/TransferSelect_fp.java | 73 +++ .../java/ebu7dev1/common/getlog/CusTest.java | 38 ++ .../java/xuanran/wang/checker/Checker.java | 118 ++++ .../wang/checker/CheckerException.java | 15 + .../java/xuanran/wang/checker/Checkers.java | 15 + .../java/xuanran/wang/checker/Condition.java | 70 +++ .../xuanran/wang/checker/ConvertUtil.java | 97 +++ .../java/xuanran/wang/checker/ECheckType.java | 17 + .../wang/checker/fun/HandleFunction.java | 26 + .../xuanran/wang/checker/fun/Predicate.java | 20 + .../xuanran/wang/checker/fun/SFunction.java | 20 + .../checker/handler/ConditionHandler.java | 114 ++++ .../abstracts/CusAbstractRequestService.java | 85 +++ .../wang/common/entity/CusRequestParams.java | 30 + .../xuanran/wang/common/test/ServiceTest.java | 22 + .../wang/common/test/TestServiceImpl.java | 28 + .../xuanran/wang/eny/ModelFieldAsyncTest.java | 94 +++ .../wang/shyl/dataasync/TestPassword.java | 22 + 35 files changed, 3140 insertions(+) create mode 100644 src/main/java/com/api/customization/ey/jiahx/web/ButtonTriggeringGenerateData.java create mode 100644 src/main/java/com/api/ebu7dev1/common/getlog/enums/LogTypeEnum.java create mode 100644 src/main/java/com/api/ebu7dev1/common/getlog/util/GetLogUtil.java create mode 100644 src/main/java/com/api/nonstandardext/ey/job/BadDebtProvisionSynJob.java create mode 100644 src/main/java/com/api/nonstandardext/ey/job/BankJournalToCollectSynJob.java create mode 100644 src/main/java/com/api/nonstandardext/ey/mode/BadDebtProvisionDt3.java create mode 100644 src/main/java/com/api/nonstandardext/ey/utils/EyLogger.java create mode 100644 src/main/java/com/api/nonstandardext/model_field_async/entity/ModelFieldAsyncConfig.java create mode 100644 src/main/java/com/api/nonstandardext/model_field_async/entity/ModelFieldAsyncConfigClass.java create mode 100644 src/main/java/com/api/nonstandardext/model_field_async/entity/ModelFieldAsyncConfigDetail.java create mode 100644 src/main/java/com/api/nonstandardext/model_field_async/interfaces/TriFunction.java create mode 100644 src/main/java/com/api/nonstandardext/model_field_async/mapper/ModelFieldAsyncMapper.java create mode 100644 src/main/java/com/api/nonstandardext/model_field_async/service/ModelFieldAsyncServiceImpl.java create mode 100644 src/main/java/com/api/nonstandardext/model_field_async/service/convert/CusModelFieldAsyncConvert.java create mode 100644 src/main/java/com/api/nonstandardext/model_field_async/util/EyCusModelFieldValueRuleMethod.java create mode 100644 src/main/java/com/api/nonstandardext/model_field_async/util/ValueRuleMethodNo.java create mode 100644 src/main/java/weaver/formmode/customjavacode/modeexpand/ey/jiahx/TransferSelect.java create mode 100644 src/main/java/weaver/formmode/customjavacode/modeexpand/ey/jiahx/TransferSelect_fp.java create mode 100644 src/test/java/ebu7dev1/common/getlog/CusTest.java create mode 100644 src/test/java/xuanran/wang/checker/Checker.java create mode 100644 src/test/java/xuanran/wang/checker/CheckerException.java create mode 100644 src/test/java/xuanran/wang/checker/Checkers.java create mode 100644 src/test/java/xuanran/wang/checker/Condition.java create mode 100644 src/test/java/xuanran/wang/checker/ConvertUtil.java create mode 100644 src/test/java/xuanran/wang/checker/ECheckType.java create mode 100644 src/test/java/xuanran/wang/checker/fun/HandleFunction.java create mode 100644 src/test/java/xuanran/wang/checker/fun/Predicate.java create mode 100644 src/test/java/xuanran/wang/checker/fun/SFunction.java create mode 100644 src/test/java/xuanran/wang/checker/handler/ConditionHandler.java create mode 100644 src/test/java/xuanran/wang/common/abstracts/CusAbstractRequestService.java create mode 100644 src/test/java/xuanran/wang/common/entity/CusRequestParams.java create mode 100644 src/test/java/xuanran/wang/common/test/ServiceTest.java create mode 100644 src/test/java/xuanran/wang/common/test/TestServiceImpl.java create mode 100644 src/test/java/xuanran/wang/eny/ModelFieldAsyncTest.java create mode 100644 src/test/java/xuanran/wang/shyl/dataasync/TestPassword.java diff --git a/src/main/java/com/api/customization/ey/jiahx/web/ButtonTriggeringGenerateData.java b/src/main/java/com/api/customization/ey/jiahx/web/ButtonTriggeringGenerateData.java new file mode 100644 index 0000000..217ce38 --- /dev/null +++ b/src/main/java/com/api/customization/ey/jiahx/web/ButtonTriggeringGenerateData.java @@ -0,0 +1,108 @@ +package com.api.customization.ey.jiahx.web; + +import com.alibaba.fastjson.JSONObject; +import com.api.nonstandardext.model_field_async.service.ModelFieldAsyncServiceImpl; +import com.weaver.general.TimeUtil; +import weaver.conn.RecordSet; +import weaver.formmode.setup.ModeRightInfo; +import weaver.general.BaseBean; +import weaver.general.Util; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.ArrayList; +import java.util.List; + +/** + * @Description + * @Author 贾寒旭 + * @Date 2023/5/22 + * @Other + * @Version + */ +@Path("/pushData") +public class ButtonTriggeringGenerateData { + private static final BaseBean baseBean = new BaseBean(); + private static weaver.formmode.setup.ModeRightInfo ModeRightInfo = new ModeRightInfo();//模块信息 + private static String currentdate = TimeUtil.getCurrentDateString();//当前日期 + private static String currenttime = TimeUtil.getOnlyCurrentTimeString();//当前时间 + + private final ModelFieldAsyncServiceImpl service = new ModelFieldAsyncServiceImpl(); + + @GET + @Path("/doPushData") + @Produces({MediaType.TEXT_PLAIN}) + public JSONObject doPushData(@Context HttpServletRequest request, @Context HttpServletResponse response){ + baseBean.writeLog("点击按钮获得进行流程主表数据传递到明细表开始>>>>>>>>"); + RecordSet rs = new RecordSet(); + String sql = "select m.invoiceNo invoiceNo,d.mainid mainid,d.totalAmount totalAmount,m.yjthzje yjthzje,m.customerCode customerCode" + + ",m.customerName customerName,m.groupinvoiceno groupinvoiceno,m.finishedTime finishedTime,m.orifinishedTime orifinishedTime," + + "m.hzjtyqz hzjtyqz,m.arState arState,m.yskje yskje,m.qskje qskje,m.wskje wskje,m.kpzt kpzt,m.sckprq sckprq,m.ykpje ykpje,m.wkpje wkpje from uf_zdjmbd_dt2 d left join uf_zdjmbd m on m.id = d.mainid "; + baseBean.writeLog("查询明细表2的数据sql为=====" + sql); + rs.executeQuery(sql); + JSONObject jsonObject = new JSONObject(); + List list = new ArrayList<>(); + boolean flag = false; + while (rs.next()) { + String invoiceNo = Util.null2String(rs.getString("invoiceNo")); + if (!invoiceNo.equals("")) { + String mainid = Util.null2String(rs.getString("mainid"));//id + String zdje = Util.null2String(rs.getString("totalAmount"));//总金额 + String jyjtje = Util.null2String(rs.getString("yjthzje"));//计划计提金额 + String customerCode = Util.null2String(rs.getString("customerCode"));//客户编码 + String customerName = Util.null2String(rs.getString("customerName"));//客户名称 + String group_invoice_no = Util.null2String(rs.getString("groupinvoiceno"));//组账单ID + String finishedTime = Util.null2String(rs.getString("finishedTime"));//账单开具日期 + String orifinishedTime = Util.null2String(rs.getString("orifinishedTime"));//原账单开具日期 + String sqjtyqrq = Util.null2String(rs.getString("hzjtyqz"));//坏账计提延期至 + String skzt = Util.null2String(rs.getString("arState"));//实收状态 + String yskje = Util.null2String(rs.getString("yskje"));//收款金额 + String qskje = Util.null2String(rs.getString("qskje"));//其他收款金额 + String wskje = Util.null2String(rs.getString("wskje"));//未收款金额 + String kpzt = Util.null2String(rs.getString("kpzt"));//开票状态 + String sckprq = Util.null2String(rs.getString("sckprq"));//首次开票日期 + String ykpje = Util.null2String(rs.getString("ykpje"));//已开票金额 + String wkpje = Util.null2String(rs.getString("wkpje"));//客户编码 + String fbmxzt = "0";//客户编码 + String sjjtje = wskje;//实际计提金额 + RecordSet recordSet = new RecordSet(); + String insertSql = "insert into uf_zdjmbd_dt4 (mainid,group_invoice_no,invoiceNo,finishedTime," + + "orifinishedTime,sqjtyqrq,zdje,skzt,yskje,qskje,wskje,kpzt,sckprq,ykpje,wkpje,jyjtje,sjjtje,customerCode,customerName,fbmxzt) values (?,?,?,?,?,?," + + "?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + baseBean.writeLog("插入的明细表的sql为" + insertSql); + if (!"".equals(skzt)) { + baseBean.writeLog("我进入判断了>>>>>"); + boolean b = recordSet.executeUpdate(insertSql, mainid, group_invoice_no, invoiceNo, finishedTime, orifinishedTime, sqjtyqrq, zdje, skzt, yskje, qskje, wskje, kpzt, sckprq, ykpje, wkpje, jyjtje, sjjtje, customerCode, customerName, fbmxzt); + list.add(b); + } + + /** + * 通过配置同步字段 + * @author xuanran.wang + * @date 2023-06-27 + */ + service.asyncDataByClassName(this.getClass().getSimpleName(), mainid); + } + + } + baseBean.writeLog("list===" + list); + if(!list.isEmpty()){ + if (list.contains(false)) { + baseBean.writeLog("aaaaaaaaaaaaa"); + jsonObject.put("result", flag); + }else { + flag = true; + jsonObject.put("result", flag); + } + }else { + jsonObject.put("result", flag); + } + + return jsonObject; + } +} diff --git a/src/main/java/com/api/ebu7dev1/common/getlog/enums/LogTypeEnum.java b/src/main/java/com/api/ebu7dev1/common/getlog/enums/LogTypeEnum.java new file mode 100644 index 0000000..09c8ca9 --- /dev/null +++ b/src/main/java/com/api/ebu7dev1/common/getlog/enums/LogTypeEnum.java @@ -0,0 +1,58 @@ +package com.api.ebu7dev1.common.getlog.enums; + + + +import weaver.xiao.commons.config.enumtype.DataSourceEnum; + +import java.io.File; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.Map; + +/** + *

    日志类型枚举

    + * + * @author xuanran.wang + * @date 2023/7/1 16:24 + */ +public enum LogTypeEnum { + THREAD(1, "0", "log" + File.separator + "thread","thread"), + ECOLOGY(1, "1", "log","ecology"), + RESIN(0, "2", "log","Resin"), + SECURITY(1, "3","WEB-INF" + File.separator + "securitylog","security"), + INTEGRATION(1,"4", "log" + File.separator + "integration","integration"), + SQL(1, "5", "log" + File.separator + "sql","sql"), + UTIL_CUS(1,"6", "log" + File.separator + "cus" + File.separator + "util_cus","util_cus"), + SQL_LOG(1,"7","log" + File.separator + "cus" + File.separator + "sql_log","sql_log"), + HTTP_UTIL(1,"8","log" + File.separator + "cus" + File.separator + "http_util","http_util"); + private final Integer logBelongType; + private final String value; + private final String logPath; + private final String key; + LogTypeEnum(Integer logBelongType, String value, String logPath,String key) { + this.logBelongType = logBelongType; + this.value = value; + this.logPath = logPath; + this.key = key; + } + public final static Map ENUMS = new HashMap<>(16); + + static { + for (LogTypeEnum typeEnum : EnumSet.allOf(LogTypeEnum.class)){ + ENUMS.put(typeEnum.value,typeEnum); + } + } + public String getValue() { + return value; + } + public Integer getLogBelongType() { + return logBelongType; + } + public String getLogPath() { + return logPath; + } + + public String getKey() { + return key; + } +} diff --git a/src/main/java/com/api/ebu7dev1/common/getlog/util/GetLogUtil.java b/src/main/java/com/api/ebu7dev1/common/getlog/util/GetLogUtil.java new file mode 100644 index 0000000..4a5126e --- /dev/null +++ b/src/main/java/com/api/ebu7dev1/common/getlog/util/GetLogUtil.java @@ -0,0 +1,565 @@ +package com.api.ebu7dev1.common.getlog.util; + +import java.io.*; +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.nio.file.Files; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +import aiyh.utils.excention.CustomerException; +import com.api.ebu7dev1.common.getlog.enums.LogTypeEnum; +import org.apache.commons.io.IOUtils; +import weaver.hrm.User; + +/** + *

    + * + * @author xuanran.wang + * @date 2023/7/1 14:00 + */ +public class GetLogUtil { + + public static void checkUser(User loginUser) { + if (loginUser.getUID() != 1) { + throw new CustomerException("无权限查看!"); + } + } + + + /** + *

    读取ec weaver.properties配置文件 返回集群ip

    + * + * @param weaverPropertiesPath ec weaver.properties配置文件路径 + * @return 集群ip + * @author xuanran.wang + * @dateTime 2023/7/1 14:08 + **/ + public static Set readEcologyProp(String weaverPropertiesPath) { + File file = new File(weaverPropertiesPath); + Set res = new HashSet<>(); + try { + if (!file.exists()) { + return res; + } + Properties registerProp = new Properties(); + InputStreamReader reader = new InputStreamReader(Files.newInputStream(file.toPath())); + registerProp.load(reader); + String initialHost = registerProp.getProperty("initial_hosts"); + if (initialHost != null && !"".equals(initialHost)) { + String[] initialHosts = initialHost.split(","); + for (String initial_hostStr : initialHosts) { + if (!initial_hostStr.isEmpty()) { + res.add(initial_hostStr); + } + } + } + IOUtils.closeQuietly(reader); + } catch (IOException e) { + e.printStackTrace(); + } + return res; + } + + /** + *

    读取 resin 启动脚本文件 返回集群信息

    + * + * @param resinStartPath resin启动路径地址 + * @return 集群ip + * @author xuanran.wang + * @dateTime 2023/7/1 14:10 + **/ + public static Set readResinProp(String resinStartPath) { + File resinFile = new File(resinStartPath); + Set res = new HashSet<>(); + if (!resinFile.exists()) { + return res; + } + if (resinFile.isFile() && resinFile.length() > 0) { + FileInputStream fileInput = null; + BufferedReader bufferedReader = null; + try { + fileInput = new FileInputStream(resinFile); + bufferedReader = new BufferedReader(new InputStreamReader(fileInput)); + String str; + while ((str = bufferedReader.readLine()) != null) { + if (str.contains("-Dinitial_hosts") || str.contains("-J-Dinitial_hosts")) { + if (str.contains("-J-Dinitial_hosts")) { + str = str.substring(str.indexOf("-J-Dinitial_hosts") + 17); + } + if (str.contains("-Dinitial_hosts")) { + str = str.substring(str.indexOf("-Dinitial_hosts") + 15); + } + str = str.contains("=") ? str.substring(str.indexOf("=") + 1) : str; + str = str.contains("-") ? str.substring(0, str.indexOf("-")) : str; + str = str.contains(" ") ? str.substring(0, str.indexOf(" ")) : str; + String[] ips = str.split(","); + for (String ip : ips) { + try { + String tmpIp = ip.replace(".", "").replace(":", ""); + Long.parseLong(tmpIp.trim()); + res.add(ip.trim()); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + } catch (Throwable t) { + t.printStackTrace(); + } finally { + IOUtils.closeQuietly(fileInput); + IOUtils.closeQuietly(bufferedReader); + } + } + return res; + } + + /** + *

    获取内网ip

    + * + * @return 内网ip + * @author xuanran.wang + * @dateTime 2023/7/1 14:17 + **/ + public static String getInnerIp() { + try { + Enumeration netInterfaces = NetworkInterface.getNetworkInterfaces(); + while (netInterfaces.hasMoreElements()) { + NetworkInterface ni = netInterfaces.nextElement(); + Enumeration nii = ni.getInetAddresses(); + while (nii.hasMoreElements()) { + InetAddress inetAddress = nii.nextElement(); + if (!inetAddress.getHostAddress().contains(":")) { + String ip = inetAddress.getHostAddress(); + if (ip.startsWith("10.") || ip.startsWith("192.168.")) {// || + return ip; + } else { + if (ip.startsWith("172.")) { + return ip; + } + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return "127.0.0.1"; + } + + /** + *

    将数据进行解析返回每种类型对应的路径

    + * + * @param ecPath ec路径 + * @param resinPath resin路径 + * @param logTypeList 前端要获取的日志类型 + * @return 转换后的数据 + * @author xuanran.wang + * @dateTime 2023/7/1 16:56 + **/ + public static List> getLogPathByLogType(String ecPath, String resinPath, List logTypeList) { + List> list = new ArrayList<>(); + for (String logType : logTypeList) { + Map map = new HashMap<>(); + LogTypeEnum typeEnum = LogTypeEnum.ENUMS.get(logType); + Integer logBelongType = typeEnum.getLogBelongType(); + String logPath = typeEnum.getLogPath(); + String basePath = ecPath; + if (logBelongType == 0) { + basePath = resinPath; + } + map.put("logType", logType); + map.put("path", basePath + File.separator + logPath); + map.put("key", typeEnum.getKey()); + list.add(map); + } + return list; + } + + /** + *

    + * + * @param logPath + * @param startDate + * @param endDate + * @return

    + * { + * "2023-07-01":{ + * "http_util":[ + * "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/cus/http_util/cus.log" + * ], + * "ecology":[ + * "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/ecology" + * ], + * "security":[ + * "/Users/wangxuanran/company/project/ebu_ecology_dev1/WEB-INF/securitylog/systemRunInfo2023-07-01.log", + * "/Users/wangxuanran/company/project/ebu_ecology_dev1/WEB-INF/securitylog/systemSecurity2023-07-01.log" + * ], + * "util_cus":[ + * "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/cus/util_cus/cus.log" + * ], + * "Resin":[ + * "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/stdout.log", + * "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/stderr.log", + * "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/watchdog-manager.log", + * "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/jvm-default.log" + * ], + * "integration":[ + * "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/integration/integration.log" + * ], + * "thread":[ + * "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/thread/2023-07-01" + * ], + * "sql_log":[ + * "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/cus/sql_log/cus.log" + * ], + * "sql":[ + * "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/sql/sqlcount_2023-07-01.log", + * "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/sql/sqltime_2023-07-01.log" + * ] + * }, + * "2023-07-02":{ + * "http_util":[ + * "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/cus/http_util/cus.log_20230702.log" + * ], + * "ecology":[ + * "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/ecology_20230702.log" + * ], + * "security":[ + * "/Users/wangxuanran/company/project/ebu_ecology_dev1/WEB-INF/securitylog/systemRunInfo2023-07-02.log", + * "/Users/wangxuanran/company/project/ebu_ecology_dev1/WEB-INF/securitylog/systemSecurity2023-07-02.log" + * ], + * "util_cus":[ + * "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/cus/util_cus/cus.log_20230702.log" + * ], + * "Resin":[ + * "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/stdout-20230702.log.gz", + * "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/stderr-20230702.log.gz", + * "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/watchdog-manager.log", + * "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/jvm-default.log" + * ], + * "integration":[ + * "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/integration/integration.log_20230702.log" + * ], + * "thread":[ + * "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/thread/2023-07-02" + * ], + * "sql_log":[ + * "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/cus/sql_log/cus.log_20230702.log" + * ], + * "sql":[ + * "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/sql/sqlcount_2023-07-02.log", + * "/Users/wangxuanran/company/project/ebu_ecology_dev1/log/sql/sqltime_2023-07-02.log" + * ] + * } + * } + *

    + * @author xuanran.wang + * @dateTime 2023/7/1 18:26 + **/ + public static Map>> getLogFilePath(List> logPath, String startDate, String endDate) { + Map>> res = new HashMap<>(); + List dateList = getDateList(startDate, endDate); + for (String date : dateList) { + Map> keyMap = new HashMap<>(); + for (Map map : logPath) { + boolean isToDay = isToDay(date); + String key = map.get("key"); + List pathList = parseLogFilePath(key, map.get("path"), date, isToDay); + keyMap.put(key, pathList); + } + res.put(date, keyMap); + } + return res; + } + + public static String collectLog(String ecologyPath, Map>> pathListKeyMap) throws FileNotFoundException { + FileOutputStream fos; + String outPath = ecologyPath + File.separator + "getlog" + File.separator + "log" + File.separator + (System.currentTimeMillis() / 1000); + File outFile = null; + try { + outFile = new File(outPath); + if (!outFile.exists()) { + outFile.mkdirs(); + } + } catch (Exception e) { + e.printStackTrace(); + } + String outLogPath = outFile + File.separator + getInnerIp() + "_downLog.zip"; + fos = new FileOutputStream(outLogPath); + try { + ZipOutputStream zos = new ZipOutputStream(fos); + zos.setLevel(1); + for (Map.Entry>> entry : pathListKeyMap.entrySet()) { + String date = entry.getKey(); + Map> value = entry.getValue(); + for (Map.Entry> pathKeyList : value.entrySet()) { + String key = pathKeyList.getKey(); + String basePath = date + File.separator; + List pathList = pathKeyList.getValue(); + for (String path : pathList) { + if ("sqllog".equals(key)) { + basePath += ("sqllog" + File.separator); + } + if ("monitorevent".equals(key)) { + basePath += ("event" + File.separator); + } + if ("monitorlog".equals(key)) { + basePath += ("monitorlog" + File.separator); + } + if (key.equals("cus")) { + basePath += ("cus" + File.separator); + } + if (key.equals("util_cus")) { + basePath += ("util_cus" + File.separator); + } + if (key.equals("sql_log")) { + basePath += ("sql_log" + File.separator); + } + if (key.equals("http_util")) { + basePath += ("http_util" + File.separator); + } + compressbyType(path, zos, basePath); + } + } + } + + System.out.println("日志文件地址 : " + outLogPath); + + try { + zos.close(); + } catch (Exception es) { + + } + if (fos != null) { + fos.close(); + } + } catch (Exception e) { + + } + return outLogPath; + } + + /** + * 按照原路径的类型就行压缩。文件路径直接把文件压缩 + * + * @param src + * @param zos + * @param baseDir + */ + private static void compressbyType(String src, ZipOutputStream zos, String baseDir) { + File srcFile = new File(src); + if (!srcFile.exists()) { + return; + } + //判断文件是否是文件,如果是文件调用compressFile方法,如果是路径,则调用compressDir方法; + if (srcFile.isFile()) { + //src是文件,调用此方法 + compressFile(srcFile, zos, baseDir); + } else if (srcFile.isDirectory()) { + compressDir(srcFile, zos, baseDir); + } + } + + /** + * 压缩文件,取后面的80M内容 + */ + private static void compressFile(File file, ZipOutputStream zos, String baseDir) { + if (!file.exists()) + return; + try { + RandomAccessFile fileRead = new RandomAccessFile(file, "r"); //用读模式 + long fileLength = fileRead.length();//获得文件长度 + if (file.getName().endsWith(".log") && fileLength > 1073741820) {//如果文件超过80M,则只取文件倒数80M内容 + fileRead.seek(fileLength - 1073741820); + } else { + fileRead.seek(0); + } + ZipEntry entry = new ZipEntry(baseDir + file.getName()); + zos.putNextEntry(entry); + int hasRead; + byte[] buf = new byte[1024]; + while ((hasRead = fileRead.read(buf)) != -1) { + zos.write(buf, 0, hasRead); + } + fileRead.close(); + } catch (Exception e) { + + } + } + + /** + * 压缩文件夹 + */ + private static void compressDir(File dir, ZipOutputStream zos, String baseDir) { + if (!dir.exists()) + return; + File[] files = dir.listFiles(); + for (int i = 0; i < files.length; i++) { + File file = files[i]; + compressFile(file, zos, baseDir + dir.getName() + File.separator); + } + } + + + public static List parseLogFilePath(String key, String path, String date, boolean isToDay) { + List list = new ArrayList(); + if ("thread".equals(key)) { + list.add(path + File.separator + date); + } else if ("mem".equals(key)) { + list.add(path + File.separator + "memory_" + date + ".log"); + } else if ("ecology".equals(key)) { + if (isToDay) { + list.add(path + File.separator + "ecology"); + } else { + list.add(path + File.separator + "ecology_" + getDateStr(date) + ".log"); + } + } else if ("sql".equals(key)) { + list.add(path + File.separator + "sqlcount_" + date + ".log"); + list.add(path + File.separator + "sqltime_" + date + ".log"); + } else if ("integration".equals(key)) { + if (isToDay) { + list.add(path + File.separator + "integration.log"); + } else { + list.add(path + File.separator + "integration.log_" + getDateStr(date) + ".log"); + } + } else if ("security".equals(key)) { + list.add(path + File.separator + "systemRunInfo" + date + ".log"); + list.add(path + File.separator + "systemSecurity" + date + ".log"); + } else if ("Resin".equals(key)) { + if (isToDay) { + list.add(path + File.separator + "stdout.log"); + list.add(path + File.separator + "stderr.log"); + } else { + list.add(path + File.separator + "stdout-" + getDateStr(date) + ".log.gz"); + list.add(path + File.separator + "stderr-" + getDateStr(date) + ".log.gz"); + } + list.add(path + File.separator + "watchdog-manager.log"); + list.add(path + File.separator + "jvm-default.log"); + } else if ("sqllog".equals(key)) { + list.add(path + File.separator + getSqlPathByDate(date)); + list.add(path + File.separator); + } else if ("monitorevent".equals(key)) { + list.addAll(eventLog(path, date)); + } else if ("monitorPool".equals(key)) { + list.add(path + File.separator + "pool_" + getDateStr(date) + "_ecology.log"); + list.add(path + File.separator + "pool_" + getDateStr(date) + "_ecology.zip"); + } else if ("monitorlog".equals(key)) { + if (isToDay) { + list.add(path + File.separator + "stdout.log"); + list.add(path + File.separator + "stderr-log"); + } else { + list.add(path + File.separator + "stdout-" + getDateStr(date) + ".log.gz"); + list.add(path + File.separator + "stderr-" + getDateStr(date) + ".log.gz"); + } + } else if ("monitorconcurrent".equals(key)) { + list.add(path + File.separator + "concurrent_" + getDateStr(date) + ".log"); + list.add(path + File.separator + "concurrent_" + getDateStr(date) + ".zip"); + } else if ("monitorcpu".equals(key)) { + list.add(path + File.separator + "cpu_" + getDateStr(date) + ".log"); + list.add(path + File.separator + "cpu_" + getDateStr(date) + ".zip"); + } else if ("resinconf".equals(key)) { + list.add(path); + } else if ("ecoloyweaver".equals(key)) { + dealWidthWeaverProp(path + "weaver.properties", new File(path + "weaversecurity.properties")); + list.add(path + "weaversecurity.properties"); + } else if ("cus".equals(key) || "util_cus".equals(key) || "sql_log".equals(key) || "http_util".equals(key)) { + if (isToDay) { + list.add(path + File.separator + "cus.log"); + } else { + list.add(path + File.separator + "cus.log_" + getDateStr(date) + ".log"); + } + } + return list; + } + + private static List eventLog(String path, String date) { + List list = new ArrayList(); + File file = new File(path); + if (!file.exists()) { + return list; + } + File[] filelists = new File(path).listFiles(); + date = getDateStr(date); + for (int i = 0; i < filelists.length; i++) { + File filelist = filelists[i]; + if (filelist.getName().indexOf(date) != -1) { + list.add(filelist.getAbsolutePath()); + } + } + return list; + } + + private static String getSqlPathByDate(String date) { + return date.replace("-", File.separator); + } + + private static String getDateStr(String date) { + date = date.replaceAll("-", ""); + return date; + } + + + private static boolean isToDay(String date) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String toDay = sdf.format(new Date()); + return date.equals(toDay); + } + + private static List getDateList(String startDate, String endDate) { + List list = new ArrayList<>(); + try { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date start = sdf.parse(startDate); + Date end = sdf.parse(endDate); + Calendar tempStart = Calendar.getInstance(); + tempStart.setTime(start); + while (start.getTime() <= end.getTime()) { + list.add(sdf.format(tempStart.getTime())); + tempStart.add(Calendar.DAY_OF_YEAR, 1); + start = tempStart.getTime(); + } + } catch (Exception e) { + e.printStackTrace(); + } + return list; + } + + private static void dealWidthWeaverProp(String path, File outFile) {//处理weaver.prop密码问题 + File file = new File(path); + if (!file.exists()) { + return; + } + InputStreamReader reader = null; + java.io.Writer outWriter = null; + try { + if (!file.exists()) { + file.createNewFile(); + } + Properties registerProp = new Properties(); + reader = new InputStreamReader(new FileInputStream(file)); + registerProp.load(reader); + reader.close(); + outWriter = new FileWriter(outFile); + registerProp.put("ecology.password", "***********"); + registerProp.store(outWriter, ""); + outWriter.close(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + if (reader != null) { + reader.close(); + } + if (outWriter != null) { + outWriter.close(); + } + } catch (Exception e) { + } + } + } +} + diff --git a/src/main/java/com/api/nonstandardext/ey/job/BadDebtProvisionSynJob.java b/src/main/java/com/api/nonstandardext/ey/job/BadDebtProvisionSynJob.java new file mode 100644 index 0000000..a272629 --- /dev/null +++ b/src/main/java/com/api/nonstandardext/ey/job/BadDebtProvisionSynJob.java @@ -0,0 +1,145 @@ +package com.api.nonstandardext.ey.job; + +import com.api.nonstandardext.ey.mode.BadDebtProvisionDt3; +import com.api.nonstandardext.ey.utils.EyLogger; +import com.api.nonstandardext.model_field_async.service.ModelFieldAsyncServiceImpl; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.interfaces.schedule.BaseCronJob; + +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.temporal.ChronoUnit; +import java.util.Date; + +/** + * + * 管报 开始执行坏账计提将主表参数携带到明细表3中定时任务 + * + * 计划任务-每周执行一次 + * + * 获取账单台账;uf_zdjmbd 中账单状态invoiceStatus 为0(Open)且 当前日期-子账单计提开始计算日期>=180天的, + * + * 在该条数据的明细表3中插入一条新的数据,如果存在手动的更新为自动 + * + * 账单台账.明细表3中的数据 来源于 账单台账主表,对应关系详见开发点4 + * @Description + * @Author 贾寒旭 + * @Date 2023/3/21 + * @Other + * @Version + */ +public class BadDebtProvisionSynJob extends BaseCronJob { + + private static final EyLogger logger = new EyLogger(); + + private final static String JobName = " BadDebtProvisionSynJob V2 , "; + + private final ModelFieldAsyncServiceImpl service = new ModelFieldAsyncServiceImpl(); + + @Override + public void execute() { + logger.writeLogInfo( this.getClass().getName(),JobName + " >>>>>>"); + + //首先查询账单台账,在其中进行查询获得到指定的数据 + //账单请求类型:只取0、1、2、3、5 + //以及账单号前三个字母,包含MCN、MHK + + RecordSet rs = new RecordSet(); + RecordSet innerRs = new RecordSet(); + RecordSet updateRs = new RecordSet(); + + try { + + String dateSql = "select * from uf_gbrqgz"; + innerRs.executeQuery(dateSql); + int gbscts = 0; + while (innerRs.next()) { + gbscts = Util.getIntValue(innerRs.getString("gbscts"), 0); + } + + String sql = "select m.id, d.bu bu,m.customerCode customerCode,m.requestType requestType,m.invoiceNo invoiceNo," + + "m.customerName customerName," + + "m.finishedTime finishedTime,m.orifinishedTime orifinishedTime,m.hzjtyqz hzjtyqz," + + "d.totalAmount totalAmount,d.skzt skzt,d.yskje yskje,d.qskje qskje,d.wskje wskje," + + "m.kpzt kpzt,m.sckprq sckprq,m.ykpje ykpje,m.wkpje wkpje,d.jtksjsrq as computeDate " + + "from uf_zdjmbd m left join uf_zdjmbd_dt1 d on d.mainid = m.id where m.invoiceStatus = 0"; + + rs.executeQuery(sql); + logger.writeLogInfo( this.getClass().getName(),JobName + " gbscts:" + gbscts + ", rs count:" + rs.getCounts() + " , sql=====" + sql); + + SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd"); + String format = sf.format(new Date()); + + while (rs.next()) { + String id = rs.getString("id"); + String customerName = rs.getString("customerName");//客户名称 + String computeDate = rs.getString("computeDate"); + String requestType = rs.getString("requestType"); + String invoiceNo = rs.getString("invoiceNo"); + + logger.writeLogInfo( this.getClass().getName(),JobName + "customerName:" + customerName + ", computeDate:" + computeDate + ", requestType:" + requestType + ", invoiceNo:" + invoiceNo); + + long daysBetween = 0; + + if (!"".equals(computeDate)) { + LocalDate date1 = LocalDate.parse(format); + LocalDate date2 = LocalDate.parse(computeDate); + daysBetween = Math.abs(ChronoUnit.DAYS.between(date1, date2)); + + logger.writeLogInfo( this.getClass().getName(),JobName + ", computeDate:" + computeDate + ", daysBetween:" + daysBetween + ", gbscts:" + gbscts); + + if (daysBetween >= gbscts) { + + String existSql = "select * from uf_zdjmbd_dt3 where (tszt is null or tszt=0) and mainid=" + id; + innerRs.execute(existSql); + + logger.writeLogInfo( this.getClass().getName(),JobName + " innerRs count : " + innerRs.getCounts() + ",existSql:" + existSql); + if (innerRs.getCounts() > 0){ + updateRs.execute("update uf_zdjmbd_dt3 set tszt=1 where (tszt is null or tszt=0) and mainid=" + id); + continue; + } + + String customerCode = rs.getString("customerCode");//客户编码 + String bu = rs.getString("bu");//客户编码 + + BadDebtProvisionDt3 dt3 = new BadDebtProvisionDt3(); + dt3.setMainId(id); + dt3.setCustomerCode(customerCode); + dt3.setCustomerName(customerName); + dt3.setGroup_invoice_no(rs.getString("groupinvoiceno")); //组账单ID + dt3.setInvoiceNo(rs.getString("invoiceNo")); //账单ID + dt3.setFinishedTime(rs.getString("finishedTime")); //账单开具日期 + dt3.setOrifinishedTime(rs.getString("orifinishedTime")); //原账单开具日期 + dt3.setSqjtyqrq(rs.getString("hzjtyqz")); //申请计提延期日期 取 坏账计提延期至 + dt3.setZdje(rs.getString("totalAmount")); //账单金额 + dt3.setSkzt(rs.getString("skzt")); //收款状态 + dt3.setYskje(rs.getString("yskje")); //已收款金额 + dt3.setQskje(rs.getString("qskje")); //其他收款金额 + dt3.setWskje(rs.getString("wskje")); //未收款金额 + dt3.setKpzt(rs.getString("kpzt")); //开票状态 + dt3.setSckprq(rs.getString("sckprq")); //首次开票日期 + dt3.setYkpje(rs.getString("ykpje")); //已开票金额 + dt3.setWkpje(rs.getString("wkpje")); //未开票金额 + dt3.setJyjtje(dt3.getWskje()); //建议计提金额 + dt3.setSjjtje(dt3.getWskje()); //实际计提金额 + dt3.setBu(bu); //bu + dt3.setTszt("1"); //状态 + + dt3.save(dt3, "uf_zdjmbd_dt3"); + logger.writeLogInfo( this.getClass().getName(),JobName + " dt3 : " + dt3.toString()); + + /** + * 通过配置同步字段 + * @author xuanran.wang + * @date 2023-06-27 + */ + service.asyncDataByClassName(this.getClass().getSimpleName(), id); + } + } + } + } catch (Exception e){ + logger.writeLogInfo( this.getClass().getName(),JobName + " exception : " + e.getMessage()); + } + } +} diff --git a/src/main/java/com/api/nonstandardext/ey/job/BankJournalToCollectSynJob.java b/src/main/java/com/api/nonstandardext/ey/job/BankJournalToCollectSynJob.java new file mode 100644 index 0000000..0bbceb5 --- /dev/null +++ b/src/main/java/com/api/nonstandardext/ey/job/BankJournalToCollectSynJob.java @@ -0,0 +1,251 @@ +package com.api.nonstandardext.ey.job; + +import com.api.nonstandardext.ey.utils.EyLogger; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.interfaces.schedule.BaseCronJob; +import weaver.workflow.webservices.*; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * 法报 + * 执行频率: + * @Description + * @Author 贾寒旭 + * @Date 2023/3/20 + * @Other + * @Version从银行流水到收款单 + */ +public class BankJournalToCollectSynJob extends BaseCronJob { + + private static final EyLogger logger = new EyLogger(); + + private final static String JobName = " BankJournalToCollectSynJob V1 ,"; + + private String workflowId; + + public String getWorkflowId() { + return workflowId; + } + + public void setWorkflowId(String workflowId) { + this.workflowId = workflowId; + } + + /** + * 开始执行从银行流水到收款单定时任务 + */ + @Override + public void execute() { + + logger.writeLogInfo( this.getClass().getName(),JobName + " >>>>>> start"); + + RecordSet rs = new RecordSet(); + RecordSet innerRs = new RecordSet(); + try { + SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd"); + String format = sf.format(new Date()); + String sql = "select * from uf_yhjylsjmbd where szfx = '0'"; + + rs.executeQuery(sql); + while (rs.next()) { + String jylsh = rs.getString("jylsh");//交易流水号对应流程表单上的银行流水id + + String qsql = "select * from formtable_main_257 where yhlsid = ?"; + innerRs.executeQuery(qsql, jylsh); + if (innerRs.next()) { + logger.writeLogInfo( this.getClass().getName(), JobName + " exists receipt workflow can not create >>>>"); + } else { + Map map = new HashMap<>(); + String dfhm = rs.getString("dfhm");//对方账户名fkrmc + String dfzh = rs.getString("dfzh");//对方账号fkrzh + String dfyhmc = rs.getString("dfyhmc");//对方银行名称fkrkhh + String jyhm = rs.getString("jyhm");//交易户名skfmc + String jyzh = rs.getString("jyzh");//交易账号skfzh + String jyyhmc = rs.getString("jyyhmc");//交易银行名称skrkhh + String bb = rs.getString("bb");//币别bb + String szlx = rs.getString("szfx");//收支方向szlx + String jyfse = rs.getString("jyfse");//交易发生额jyje + String zy = rs.getString("zy");//摘要zy + String jyrq = rs.getString("jyrq");//交易日期jyrq + String jysj = rs.getString("jysj");//交易时间jysj + String jylsh1 = rs.getString("jylsh");//交易流水号yhlsid + String bz = rs.getString("bz");//备注bz + String ywrq = format; + map.put("fkrmc", dfhm); + map.put("fkrzh", dfzh); + map.put("fkrkhh", dfyhmc); + map.put("skfmc", jyhm); + map.put("skfzh", jyzh); + map.put("skrkhh", jyyhmc); + map.put("bb", bb); + map.put("szlx", szlx); + map.put("jyje", jyfse); + map.put("jyrq", jyrq); + map.put("jysj", jysj); + map.put("yhlsid", jylsh1); + map.put("bz", bz); + map.put("zy", zy); + map.put("ywrq", ywrq); + map.put("sfyyhls", "0"); + map.put("sfxyepemqr", "1"); + logger.writeLogInfo( this.getClass().getName(),JobName + " main data map=" + map); + //将(摘要)zy字段进行拆分 + List> zyMap = cfzy(zy); + logger.writeLogInfo( this.getClass().getName(),JobName + "zyMap=====" + zyMap); + //创建流程 + //获得主表信息 + WorkflowMainTableInfo workflowMainTableInfo = getMainInfo(map); + //获得明细表信息 + WorkflowDetailTableInfo[] detail_tableinfo = null; + if (!zyMap.isEmpty()) { + detail_tableinfo = getDetailInfo(zyMap); + } + + //创建流程工作 创建流程时为必输项 + String requestName = "收款认领流程"; + WorkflowRequestInfo workflowRequestInfo = new WorkflowRequestInfo();//工作流程请求信息 + WorkflowBaseInfo workflowBaseInfo = new WorkflowBaseInfo();//工作流信息 + workflowRequestInfo.setWorkflowMainTableInfo(workflowMainTableInfo);//添加主表字段数据 + if (detail_tableinfo != null) { + workflowRequestInfo.setWorkflowDetailTableInfos(detail_tableinfo);//添加明细数据 + } + workflowRequestInfo.setCreatorId("1");//创建者ID 创建流程时为必输项 + workflowRequestInfo.setRequestName(requestName); + workflowBaseInfo.setWorkflowId(getWorkflowId());//流程ID + workflowRequestInfo.setWorkflowBaseInfo(workflowBaseInfo);//工作流信息 + workflowRequestInfo.setIsnextflow("0");//停留在当前节点,1代表流转下一节点 + /**提交流程*/ + WorkflowService service = new WorkflowServiceImpl(); + String requestid1 = service.doCreateWorkflowRequest(workflowRequestInfo, 1); + String statusCode = Util.null2String(service.submitWorkflowRequest(workflowRequestInfo, Integer.parseInt(requestid1), 1, "save", "")); + String statusCode1 = Util.null2String(service.submitWorkflowRequest(workflowRequestInfo, Integer.parseInt(requestid1), 1, "submit", "")); + logger.writeLogInfo( this.getClass().getName(),JobName + " submit requestid1 : " + requestid1 + " statusCode: " + statusCode + " statusCode1 : " + statusCode1); + } + } + } catch (Exception e){ + logger.writeLogInfo( this.getClass().getName(), JobName + " exception: " + e.getMessage()); + } + } + + /** + * 组装明细表数据 + * @return + * @param zyMap + */ + public WorkflowDetailTableInfo[] getDetailInfo(List> zyMap) throws Exception{ + //设置明细表字段 + int index = Integer.parseInt("1"); //获取子表封装的表 + logger.writeLogInfo( this.getClass().getName(), JobName + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>create detail data>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); + WorkflowDetailTableInfo[] detail_tableinfo = new WorkflowDetailTableInfo[index];//定义一个明细表对象 + WorkflowRequestTableRecord[] detil_wrtri = new WorkflowRequestTableRecord[zyMap.size()];//创建多少行明细数据 + List dwrs = null; //一行 + WorkflowRequestTableField det_wrti = null; //一个字段 + int rownum = 0; + for (Map map : zyMap) { + logger.writeLogInfo( this.getClass().getName(), JobName + "get map data" + map); + dwrs = new ArrayList<>(); + for (String key : map.keySet()) { + logger.writeLogInfo( this.getClass().getName(), JobName + "current map key" + key); + det_wrti = new WorkflowRequestTableField(); + String value = Util.null2String(map.get(key));//原字段字段值 + logger.writeLogInfo( this.getClass().getName(), JobName + "value==="+value); + det_wrti.setFieldName(key);//目标字段字段 + det_wrti.setFieldValue(value); + det_wrti.setView(true); + det_wrti.setEdit(true); + dwrs.add(det_wrti); + } + WorkflowRequestTableField[] workflowRequestTableFields = new WorkflowRequestTableField[dwrs.size()]; + for (int i = 0; i < dwrs.size(); i++) { + workflowRequestTableFields[i] = dwrs.get(i); + } + detil_wrtri[rownum] = new WorkflowRequestTableRecord(); + detil_wrtri[rownum].setWorkflowRequestTableFields(workflowRequestTableFields); + rownum++; + //将明细数据加入明细表index - 1中 从0开始 + detail_tableinfo[index - 1] = new WorkflowDetailTableInfo(); + detail_tableinfo[index - 1].setWorkflowRequestTableRecords(detil_wrtri); + logger.writeLogInfo( this.getClass().getName(), JobName + "create detail data end " + detail_tableinfo); + } + return detail_tableinfo; + } + + + /** + * 拆分摘要 + * @param zy + */ + public List> cfzy(String zy) throws Exception{ +// 账单号:ICSV*******;客户编号:***;客户名称:****;账单号:ICSV*******;客户编号:***;客户名称:****; + logger.writeLogInfo( this.getClass().getName(), JobName + " zhai yao : " + zy); + String[] strings = zy.split(" "); + List> list = new ArrayList<>(); + for (int i = 0; i < strings.length; i++) { + Map map = new HashMap<>(); + if(strings[i].toLowerCase().length()==14){ + if (strings[i].toUpperCase().contains("ICN") + ||strings[i].toUpperCase().contains("XCN") + ||strings[i].toUpperCase().contains("RCN") + ||strings[i].toUpperCase().contains("MCN") + ||strings[i].toUpperCase().contains("WCN")) { + String zdh = strings[i].toUpperCase(); + logger.writeLogInfo( this.getClass().getName(), JobName + "zdh===" + zdh); + RecordSet rs = new RecordSet(); + String sql = "select id from uf_zdjmbd where invoiceNo = ?"; + rs.executeQuery(sql, zdh); + String id = ""; + while (rs.next()) { + id = rs.getString("id"); + } + //TODO 流程明细表没有对应字段 + map.put("zdh", id); +// map.put("khbh", khbh); +// map.put("khmc", khmc); + map.put("zdhwb", zdh); + list.add(map); + } else { + return new ArrayList<>(); + } + } else { + return new ArrayList<>(); + } + logger.writeLogInfo( this.getClass().getName(), JobName + ", map size:" + map.size()); + } + logger.writeLogInfo( this.getClass().getName(), JobName + ",list size:" + list.size()); + return list; + } + + + /** + * 组装主表数据 + * @param map + * @return + */ + public WorkflowMainTableInfo getMainInfo(Map map) { + logger.writeLogInfo( this.getClass().getName(), JobName + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>create main data start>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); + WorkflowMainTableInfo workflowMainTableInfo = new WorkflowMainTableInfo();//定义一个主表对象 + WorkflowRequestTableRecord[] workflowRequestTableRecord = new WorkflowRequestTableRecord[1];//创建多少行主表数据 + List main_dwrs = new ArrayList();//一行 + WorkflowRequestTableField main_det_wrti = null; + for (String s : map.keySet()) { + main_det_wrti = new WorkflowRequestTableField();//一个字段 + String value = map.get(s); + main_det_wrti.setFieldName(s); + main_det_wrti.setFieldValue(value); + main_det_wrti.setView(true); + main_det_wrti.setEdit(true); + main_dwrs.add(main_det_wrti); + } + WorkflowRequestTableField[] workflowRequestTableFields = new WorkflowRequestTableField[main_dwrs.size()]; + for (int i = 0; i < main_dwrs.size(); i++) { + workflowRequestTableFields[i] = main_dwrs.get(i); + } + workflowRequestTableRecord[0] = new WorkflowRequestTableRecord(); + workflowRequestTableRecord[0].setWorkflowRequestTableFields(workflowRequestTableFields); + workflowMainTableInfo.setRequestRecords(workflowRequestTableRecord); + logger.writeLogInfo( this.getClass().getName(), JobName + "create main data end>>>>>>>>>>>>>>>>>>>>>>>>>" + workflowMainTableInfo); + return workflowMainTableInfo; + } +} diff --git a/src/main/java/com/api/nonstandardext/ey/mode/BadDebtProvisionDt3.java b/src/main/java/com/api/nonstandardext/ey/mode/BadDebtProvisionDt3.java new file mode 100644 index 0000000..19421b3 --- /dev/null +++ b/src/main/java/com/api/nonstandardext/ey/mode/BadDebtProvisionDt3.java @@ -0,0 +1,313 @@ +package com.api.nonstandardext.ey.mode; + +import com.api.nonstandardext.ey.utils.EyLogger; +import com.weaver.general.BaseBean; +import weaver.conn.RecordSet; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +public class BadDebtProvisionDt3 extends BaseBean { + + private static final EyLogger logger = new EyLogger(); + + private String mainId; + + private String customerCode; + + private String customerName; + + private String group_invoice_no; + + private String invoiceNo; + + private String finishedTime; + + private String orifinishedTime; + + private String sqjtyqrq; + + private String zdje; + + private String skzt; + + private String yskje; + + private String qskje; + + private String wskje; + + private String kpzt; + + private String sckprq; + + private String ykpje; + + private String wkpje; + + private String jyjtje; + + private String sjjtje; + + private String bu; + + private String tszt; + + public Integer save(BadDebtProvisionDt3 ufModel, String tableName) { + String modelName = "管报明细"; + Integer mainId = null; + try { + RecordSet rs = new RecordSet(); + String fieldSql = ""; + String valueSql = ""; + boolean result = false; + + // 获取实体类的所有属性,返回Field数组 + Field[] field = ufModel.getClass().getDeclaredFields(); + // 遍历所有属性 + for (int i = 0; i < field.length; i++) { + // 获取属性的名字,并将属性第一个字符大写 + String name = field[i].getName(); + name = name.substring(0, 1).toUpperCase() + name.substring(1); + // 得到属性类型 + String type = field[i].getGenericType().toString(); + if (type.equals("class java.lang.String")) { + Method m = ufModel.getClass().getMethod("get" + name); + // 调用getter方法获取属性值 + String value = (String) m.invoke(ufModel); + if (value != null) { + if ("".equals(value)){ + fieldSql += "," + name; + valueSql += ",null"; + } else { + fieldSql += "," + name; + valueSql += ",'" + value.trim() + "'"; + } + } + } + if (type.equals("class java.lang.Integer")) { + Method m = ufModel.getClass().getMethod("get" + name); + // 调用getter方法获取属性值 + Integer value = (Integer) m.invoke(ufModel); + if (value != null) { + fieldSql += "," + name; + valueSql += "," + value + ""; + } + } + } + if (!"".equals(fieldSql)) { + fieldSql = fieldSql.substring(1); + valueSql = valueSql.substring(1); + String insertSql = "insert into " + tableName + " (" + fieldSql + ") values (" + valueSql + ")"; + + logger.writeLogInfo( this.getClass().getName()," insertSql : " + insertSql); + + result = rs.execute(insertSql); + if (!result) { + return null; + } + writeLog(modelName + ", insertSql ->" + insertSql + ", result:" + result); + } + } catch (Exception e) { + writeLog(modelName + ", 新增报错 ->" + e.getMessage()); + e.printStackTrace(); + return null; + } + return mainId; + } + + public String getMainId() { + return mainId; + } + + public void setMainId(String mainId) { + this.mainId = mainId; + } + + public String getCustomerCode() { + return customerCode; + } + + public void setCustomerCode(String customerCode) { + this.customerCode = customerCode; + } + + public String getCustomerName() { + return customerName; + } + + public void setCustomerName(String customerName) { + this.customerName = customerName; + } + + public String getGroup_invoice_no() { + return group_invoice_no; + } + + public void setGroup_invoice_no(String group_invoice_no) { + this.group_invoice_no = group_invoice_no; + } + + public String getInvoiceNo() { + return invoiceNo; + } + + public void setInvoiceNo(String invoiceNo) { + this.invoiceNo = invoiceNo; + } + + public String getFinishedTime() { + return finishedTime; + } + + public void setFinishedTime(String finishedTime) { + this.finishedTime = finishedTime; + } + + public String getOrifinishedTime() { + return orifinishedTime; + } + + public void setOrifinishedTime(String orifinishedTime) { + this.orifinishedTime = orifinishedTime; + } + + public String getSqjtyqrq() { + return sqjtyqrq; + } + + public void setSqjtyqrq(String sqjtyqrq) { + this.sqjtyqrq = sqjtyqrq; + } + + public String getZdje() { + return zdje; + } + + public void setZdje(String zdje) { + this.zdje = zdje; + } + + public String getSkzt() { + return skzt; + } + + public void setSkzt(String skzt) { + this.skzt = skzt; + } + + public String getYskje() { + return yskje; + } + + public void setYskje(String yskje) { + this.yskje = yskje; + } + + public String getQskje() { + return qskje; + } + + public void setQskje(String qskje) { + this.qskje = qskje; + } + + public String getWskje() { + return wskje; + } + + public void setWskje(String wskje) { + this.wskje = wskje; + } + + public String getKpzt() { + return kpzt; + } + + public void setKpzt(String kpzt) { + this.kpzt = kpzt; + } + + public String getSckprq() { + return sckprq; + } + + public void setSckprq(String sckprq) { + this.sckprq = sckprq; + } + + public String getYkpje() { + return ykpje; + } + + public void setYkpje(String ykpje) { + this.ykpje = ykpje; + } + + public String getWkpje() { + return wkpje; + } + + public void setWkpje(String wkpje) { + this.wkpje = wkpje; + } + + public String getJyjtje() { + return jyjtje; + } + + public void setJyjtje(String jyjtje) { + this.jyjtje = jyjtje; + } + + public String getSjjtje() { + return sjjtje; + } + + public void setSjjtje(String sjjtje) { + this.sjjtje = sjjtje; + } + + public String getBu() { + return bu; + } + + public void setBu(String bu) { + this.bu = bu; + } + + public String getTszt() { + return tszt; + } + + public void setTszt(String tszt) { + this.tszt = tszt; + } + + @Override + public String toString() { + return "BadDebtProvisionDt3{" + + "mainId='" + mainId + '\'' + + ", customerCode='" + customerCode + '\'' + + ", customerName='" + customerName + '\'' + + ", group_invoice_no='" + group_invoice_no + '\'' + + ", invoiceNo='" + invoiceNo + '\'' + + ", finishedTime='" + finishedTime + '\'' + + ", orifinishedTime='" + orifinishedTime + '\'' + + ", sqjtyqrq='" + sqjtyqrq + '\'' + + ", zdje='" + zdje + '\'' + + ", skzt='" + skzt + '\'' + + ", yskje='" + yskje + '\'' + + ", qskje='" + qskje + '\'' + + ", wskje='" + wskje + '\'' + + ", kpzt='" + kpzt + '\'' + + ", sckprq='" + sckprq + '\'' + + ", ykpje='" + ykpje + '\'' + + ", wkpje='" + wkpje + '\'' + + ", jyjtje='" + jyjtje + '\'' + + ", sjjtje='" + sjjtje + '\'' + + ", bu='" + bu + '\'' + + ", tszt='" + tszt + '\'' + + '}'; + } +} diff --git a/src/main/java/com/api/nonstandardext/ey/utils/EyLogger.java b/src/main/java/com/api/nonstandardext/ey/utils/EyLogger.java new file mode 100644 index 0000000..4f4f61c --- /dev/null +++ b/src/main/java/com/api/nonstandardext/ey/utils/EyLogger.java @@ -0,0 +1,93 @@ +package com.api.nonstandardext.ey.utils; + +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.GCONST; +import weaver.general.TimeUtil; +import weaver.general.Util; + +import java.io.*; + +public class EyLogger extends BaseBean{ + + boolean isDebug = false; + + public EyLogger() { + + } + + /** + * 构造方法 + */ + public EyLogger(RecordSet rs) { + String logSql = "select value from uf_systemconfig where config_key = 'DebugLogger'"; + rs.execute(logSql); + if (rs.next()){ + String valule = Util.null2String(rs.getString("value")); + if("1".equals(valule)){ + isDebug = true; + } + } + } + + /** + * 写入同步的日志文件 + */ + public void writeLogInfo(String o,String s){ + BufferedWriter out = null; + try { + String filename = "ey_" + TimeUtil.getCurrentDateString() + "_ecology.log"; + + String folder = GCONST.getRootPath() + "log" + File.separatorChar + "ey_dev_log"; + + //this.writeDebugLog("folder:[" + folder + "]"); + + File f = new File(folder); + + // 创建文件夹 + if (!f.exists()) { + f.mkdirs(); + } + + f = new File(folder + File.separatorChar + filename); + + if(!f.exists()){//文件不存在,则直接创建 + f.createNewFile(); + } + + out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f, true))); + + out.write("[" + o.getClass() + "][" + TimeUtil.getCurrentTimeString() + "]:"+ s + "\r\n"); + + //关闭写入流 + if (out != null){ + out.close(); + } + + } catch (IOException e) { + if (out != null){ + try { + out.close(); + } catch (IOException ioException) { + ioException.printStackTrace(); + } + } + e.printStackTrace(); + this.writeDebugLog("创建日志文件存在异常:[" + e.getMessage() + "/" + e.toString() + "]"); + } finally { + if (out != null){ + try { + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + public void writeDebugLog(Object logstr){ + if(isDebug){ + this.writeLog(logstr.toString()); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/api/nonstandardext/model_field_async/entity/ModelFieldAsyncConfig.java b/src/main/java/com/api/nonstandardext/model_field_async/entity/ModelFieldAsyncConfig.java new file mode 100644 index 0000000..ba14776 --- /dev/null +++ b/src/main/java/com/api/nonstandardext/model_field_async/entity/ModelFieldAsyncConfig.java @@ -0,0 +1,24 @@ +package com.api.nonstandardext.model_field_async.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + *

    配置主表对象

    + * + * @author xuanran.wang + * @date 2023/6/26 14:33 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ModelFieldAsyncConfig { + private String modelTable; + private String onlyMark; + private String cusWhereSql; + private String tableName; + private List configDetailList; +} diff --git a/src/main/java/com/api/nonstandardext/model_field_async/entity/ModelFieldAsyncConfigClass.java b/src/main/java/com/api/nonstandardext/model_field_async/entity/ModelFieldAsyncConfigClass.java new file mode 100644 index 0000000..0314446 --- /dev/null +++ b/src/main/java/com/api/nonstandardext/model_field_async/entity/ModelFieldAsyncConfigClass.java @@ -0,0 +1,20 @@ +package com.api.nonstandardext.model_field_async.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + *

    建模字段同步执行类配置

    + * + * @author xuanran.wang + * @date 2023/6/27 10:18 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ModelFieldAsyncConfigClass { + private String onlyMark; + private String className; + private String detailIndex; +} diff --git a/src/main/java/com/api/nonstandardext/model_field_async/entity/ModelFieldAsyncConfigDetail.java b/src/main/java/com/api/nonstandardext/model_field_async/entity/ModelFieldAsyncConfigDetail.java new file mode 100644 index 0000000..be7d294 --- /dev/null +++ b/src/main/java/com/api/nonstandardext/model_field_async/entity/ModelFieldAsyncConfigDetail.java @@ -0,0 +1,24 @@ +package com.api.nonstandardext.model_field_async.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + *

    配置明细对象

    + * + * @author xuanran.wang + * @date 2023/6/26 14:34 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class ModelFieldAsyncConfigDetail { + private String detailIndex; + private String targetField; + private String valueField; + private int getValueType; + private String valueContext; + private String targetFieldName; + private String valueFieldName; +} diff --git a/src/main/java/com/api/nonstandardext/model_field_async/interfaces/TriFunction.java b/src/main/java/com/api/nonstandardext/model_field_async/interfaces/TriFunction.java new file mode 100644 index 0000000..882fcc2 --- /dev/null +++ b/src/main/java/com/api/nonstandardext/model_field_async/interfaces/TriFunction.java @@ -0,0 +1,12 @@ +package com.api.nonstandardext.model_field_async.interfaces; + +/** + *

    三个参数的函数接口

    + * + * @author xuanran.wang + * @date 2023/6/28 10:06 + */ +@FunctionalInterface +public interface TriFunction { + R apply(T t, U u, V v); +} \ No newline at end of file diff --git a/src/main/java/com/api/nonstandardext/model_field_async/mapper/ModelFieldAsyncMapper.java b/src/main/java/com/api/nonstandardext/model_field_async/mapper/ModelFieldAsyncMapper.java new file mode 100644 index 0000000..ab03066 --- /dev/null +++ b/src/main/java/com/api/nonstandardext/model_field_async/mapper/ModelFieldAsyncMapper.java @@ -0,0 +1,105 @@ +package com.api.nonstandardext.model_field_async.mapper; + +import aiyh.utils.annotation.recordset.*; +import com.api.nonstandardext.model_field_async.entity.ModelFieldAsyncConfig; +import com.api.nonstandardext.model_field_async.entity.ModelFieldAsyncConfigClass; +import com.api.nonstandardext.model_field_async.entity.ModelFieldAsyncConfigDetail; + +import java.util.List; +import java.util.Map; + +/** + *

    + * + * @author xuanran.wang + * @date 2023/6/26 14:39 + */ +@SqlMapper +public interface ModelFieldAsyncMapper { + + @Select("select * from uf_model_filed_async_class_config where class_name = #{className}") + ModelFieldAsyncConfigClass selectModelFieldAsyncConfigClass(@ParamMapper("className") String className); + + @Select("SELECT a.*,b.tablename as table_name, c.id as model_id " + + "FROM uf_model_field_async a " + + "left join workflow_mode_table_view b " + + "on a.model_table = b.id " + + "left join modeinfo c " + + "on a.model_table = c.formid " + + "where only_mark = #{onlyMark}") + @CollectionMappings({ + @CollectionMapping(property = "configDetailList", + column = "id", + id = @Id(value = Integer.class, methodId = 1)) + }) + ModelFieldAsyncConfig selectConfigByOnlyMark(@ParamMapper("onlyMark") String onlyMark); + + /** + *

    查询配置表明细表信息

    + * @author xuanran.wang + * @dateTime 2023/3/1 16:39 + * @param mainId 主表数据id + * @return 配置集合 + **/ + @Select("select a.*,b.fieldname target_field_name, c.fieldname value_field_name " + + "from uf_model_field_async_dt1 a " + + "left join workflow_field_table_view b " + + "on a.target_field = b.id " + + "left join workflow_field_table_view c " + + "on a.value_field = c.id " + + "where mainid = #{mainId} " + + "and ( enable is null or enable = 0 )") + @CollectionMethod(1) + List selectConfigDetail(@ParamMapper("mainId") int mainId); + + /** + *

    查询数据总条数

    + * @author xuanran.wang + * @dateTime 2023/6/26 15:15 + * @param modelTableName 表名 + * @param where 自定义数据条件 + * @return 数据总条数 + **/ + @Select("select count(*) from $t{modelTableName} $t{where}") + Integer selectModelTableCount(@ParamMapper("modelTableName") String modelTableName, + @ParamMapper("where") String where); + /** + *

    分页查询建模数据

    + * @author xuanran.wang + * @dateTime 2023/6/26 15:15 + * @param modelTableName 表名 + * @param offset 首页 + * @param pageSize 分页大小 + * @return 建模数据 + **/ + @Select("SELECT * " + + "FROM $t{modelTableName} " + + "$t{where} " + + "LIMIT $t{offset}, $t{pageSize}") + @CaseConversion(value = false) + List> selectModelContent(@ParamMapper("modelTableName") String modelTableName, + @ParamMapper("where") String where, + @ParamMapper("offset") Integer offset, + @ParamMapper("pageSize") Integer pageSize); + + @Select("SELECT * " + + "FROM $t{modelTableName} " + + "$t{where}") + @CaseConversion(value = false) + List> selectModelContent(@ParamMapper("modelTableName")String modelTableName, @ParamMapper("where")String where); + + @Select("SELECT * " + + "FROM $t{modelTableName} " + + "$t{cusWhere}") + @CaseConversion(value = false) + Map selectMainModelContent(@ParamMapper("modelTableName")String modelTableName, + @ParamMapper("id") String id, + @ParamMapper("cusWhere")String where); + + + @Select(custom = true) + String selectCustomerSql(@SqlString String sql, + @ParamMapper("detail") Map detailMap, + @ParamMapper("main") Map mainMap); + +} diff --git a/src/main/java/com/api/nonstandardext/model_field_async/service/ModelFieldAsyncServiceImpl.java b/src/main/java/com/api/nonstandardext/model_field_async/service/ModelFieldAsyncServiceImpl.java new file mode 100644 index 0000000..6e133cd --- /dev/null +++ b/src/main/java/com/api/nonstandardext/model_field_async/service/ModelFieldAsyncServiceImpl.java @@ -0,0 +1,247 @@ +package com.api.nonstandardext.model_field_async.service; + +import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; +import aiyh.utils.recordset.MapperBuilderSql; +import com.alibaba.fastjson.JSONObject; +import lombok.Setter; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import weaver.xuanran.wang.common.mapper.CommonMapper; +import com.api.nonstandardext.model_field_async.entity.ModelFieldAsyncConfig; +import com.api.nonstandardext.model_field_async.entity.ModelFieldAsyncConfigClass; +import com.api.nonstandardext.model_field_async.entity.ModelFieldAsyncConfigDetail; +import com.api.nonstandardext.model_field_async.mapper.ModelFieldAsyncMapper; +import com.api.nonstandardext.model_field_async.util.EyCusModelFieldValueRuleMethod; + +import java.util.*; +import java.util.stream.Collectors; + +/** + *

    同步建模字段值

    + * + * @author xuanran.wang + * @date 2023/6/26 14:31 + */ +@Setter +public class ModelFieldAsyncServiceImpl { + + private final ModelFieldAsyncMapper asyncMapper = Util.getMapper(ModelFieldAsyncMapper.class); + + private final CommonMapper commonMapper = Util.getMapper(CommonMapper.class); + + private Integer pageSize = 1000; + + private final Logger logger = Util.getLogger(); + + /** + *

    根据类名查询配置

    + * + * @param className 类名 + * @return 配置对象 + * @author xuanran.wang + * @dateTime 2023/6/7 11:28 + **/ + public ModelFieldAsyncConfigClass getConfigClass(String className) { + ModelFieldAsyncConfigClass config = asyncMapper.selectModelFieldAsyncConfigClass(className); + if(Objects.isNull(config)){ + throw new CustomerException("该className [ " + className + " ] 在uf_model_filed_async_class_config配置表中未找到对应的配置!"); + } + return config; + } + + /** + *

    根据模块id查询配置

    + * + * @param onlyMark 唯一标识 + * @return 配置对象 + * @author xuanran.wang + * @dateTime 2023/6/7 11:28 + **/ + public ModelFieldAsyncConfig getConfig(String onlyMark) { + ModelFieldAsyncConfig config = asyncMapper.selectConfigByOnlyMark(onlyMark); + if(Objects.isNull(config) || CollectionUtils.isEmpty(config.getConfigDetailList())){ + throw new CustomerException("该唯一标识在 [ " + onlyMark+ " +uf_model_field_async配置表中未找到对应的配置!或存在该配置但是明细数据为空!"); + } + return config; + } + + + /** + *

    通过类名同步数据

    + * @author xuanran.wang + * @dateTime 2023/6/27 11:45 + * @param className 类名 + * @param dataIds 数据ids + **/ + public void asyncDataByClassName(String className, String dataIds){ + if(StringUtils.isBlank(dataIds)){ + logger.error("dataIds can not be empty!"); + return; + } + try { + ModelFieldAsyncConfigClass configClass = getConfigClass(className); + String onlyMark = configClass.getOnlyMark(); + ModelFieldAsyncConfig asyncConfig = getConfig(onlyMark); + for (String dataId : dataIds.split(",")) { + asyncModelField(configClass.getDetailIndex(), dataId, asyncConfig); + } + }catch (Exception e){ + logger.error("============== asyncDataByClassName error : " + e.getMessage() + " =============="); + logger.error(Util.getErrString(e)); + } + } + + /** + *

    进行建模字段数据同步

    + * @author xuanran.wang + * @dateTime 2023/6/26 17:18 + * @param detailIndexList 需要同步的明细下标 -1 代表主表 -1,1,2 : 代表主表, 明细1, 明细2 + * @param config 同步配置集合 + **/ + public void asyncAllModelField(String detailIndexList, ModelFieldAsyncConfig config){ + asyncModelField(detailIndexList, "", config); + } + + /** + *

    进行建模字段数据同步

    + * @author xuanran.wang + * @dateTime 2023/6/26 17:18 + * @param detailIndexList 需要同步的明细下标 -1 代表主表 -1,1,2 : 代表主表, 明细1, 明细2 + * @param dataId 数据id + * @param config 同步配置集合 + **/ + public void asyncModelField(String detailIndexList, String dataId, ModelFieldAsyncConfig config){ + List configDetailList = config.getConfigDetailList(); + Map> groups = configDetailList.stream() + .collect(Collectors.groupingBy(ModelFieldAsyncConfigDetail::getDetailIndex)); + String preSuffix = " id "; + boolean limit = StringUtils.isBlank(dataId); + for (String index : detailIndexList.split(",")) { + if(StringUtils.isBlank(index)){ + continue; + } + // 该明细/主表的配置集合 + List configDetails = groups.get(index); + if(CollectionUtils.isEmpty(configDetailList)){ + logger.error("index = " + index + " not found config! current configs : " + JSONObject.toJSONString(groups)); + continue; + } + String tableName = config.getTableName(); + String mainTableName = config.getTableName(); + // 如果是-1则代表同步主表数据 + if(!"-1".equals(index)){ + tableName += "_dt" + index; + preSuffix = " mainid "; + } + String cusWhereSql = buildWhereSql(Util.null2DefaultStr(config.getCusWhereSql(),""), dataId, preSuffix); + String cusMainWhereSql = buildWhereSql(Util.null2DefaultStr(config.getCusWhereSql(),""), dataId, "id"); + // 获取主表数据 + Map mainMap = asyncMapper.selectMainModelContent(mainTableName, dataId, cusMainWhereSql); + asyncAllData(tableName, cusWhereSql, configDetails, limit, mainMap); + } + } + + /** + *

    同步所有的数据

    + * @author xuanran.wang + * @dateTime 2023/6/27 11:44 + * @param tableName 表名 + * @param cusWhereSql 自定义where sql + * @param configDetails 配置表集合 + * @param limit 是否需要分页同步 + * @param mainMap 主表数据 + **/ + public void asyncAllData(String tableName, + String cusWhereSql, + List configDetails, + boolean limit, + Map mainMap){ + // 数据总条数 + int count = limit ? asyncMapper.selectModelTableCount(tableName, cusWhereSql) : 1; + // 总页数 + int pageCount = (int) Math.ceil((double) count / pageSize); + int pageNumber = 1; + while (pageNumber <= pageCount){ + int offset = (pageNumber - 1) * pageSize; + // 分页查数据 + List> dataList = asyncMapper.selectModelContent(tableName, cusWhereSql, offset, pageSize); + if(CollectionUtils.isEmpty(dataList)){ + pageNumber++; + continue; + } + convertDataList(tableName, dataList, configDetails, mainMap); + pageNumber++; + } + } + + /** + *

    构建where语句

    + * @author xuanran.wang + * @dateTime 2023/6/27 11:44 + * @param modelWhereSql 配置表中的where sql + * @param dataId 数据id + * @param preSuffix 前缀 mainId or id + * @return 构建的where语句 + **/ + public String buildWhereSql(String modelWhereSql, String dataId, String preSuffix){ + StringBuilder sb = new StringBuilder(); + if(StringUtils.isNotBlank(modelWhereSql)){ + modelWhereSql = Util.sbc2dbcCase(modelWhereSql); + sb.append(modelWhereSql); + } + if(StringUtils.isNotBlank(dataId)){ + if(sb.length() > 0){ + sb.append(" and "); + } + sb.append(preSuffix).append(" = ").append(dataId); + } + sb.insert(0, " where "); + return sb.toString(); + } + + /** + *

    将建模集合数据进行自定义转换

    + * @author xuanran.wang + * @dateTime 2023/6/26 17:20 + * @param tableName 表名 + * @param dataList 建模数据集合 + * @param configDetails 配置集合 + * @param mainMap 主表数据 + **/ + public void convertDataList(String tableName, List> dataList, + List configDetails, Map mainMap){ + List> res = new ArrayList<>(); + for (Map data : dataList) { + res.add(convertData(data, configDetails, mainMap)); + } + // 需要进行更新的字段集合 + Map fields = configDetails.stream().collect(Collectors.toMap(ModelFieldAsyncConfigDetail::getTargetFieldName, item -> "")); + String updateSql = MapperBuilderSql.builderUpdateSql(tableName, fields,"item"); + updateSql += " where id = #{item.id}"; + if (!commonMapper.updateModelInfoList(updateSql, res)) { + throw new CustomerException("出错了... 更新 " + tableName + " 失败!"); + } + } + + /** + *

    将单条数据进行转换

    + * @author xuanran.wang + * @dateTime 2023/6/26 17:20 + * @param data 明细单条数据 + * @param configDetails 配置对象 + * @param mainMap 主表数据 + * @return 转换后的map + **/ + public Map convertData(Map data, List configDetails, Map mainMap){ + Map res = new HashMap<>(); + for (ModelFieldAsyncConfigDetail detail : configDetails) { + Object convert = EyCusModelFieldValueRuleMethod.VALUE_RULE_FUNCTION.get(detail.getGetValueType()).apply(detail, data, mainMap); + res.put(detail.getTargetFieldName(), convert); + } + res.put("id", data.get("id")); + return res; + } + +} diff --git a/src/main/java/com/api/nonstandardext/model_field_async/service/convert/CusModelFieldAsyncConvert.java b/src/main/java/com/api/nonstandardext/model_field_async/service/convert/CusModelFieldAsyncConvert.java new file mode 100644 index 0000000..a121786 --- /dev/null +++ b/src/main/java/com/api/nonstandardext/model_field_async/service/convert/CusModelFieldAsyncConvert.java @@ -0,0 +1,18 @@ +package com.api.nonstandardext.model_field_async.service.convert; + +import aiyh.utils.Util; +import com.api.nonstandardext.model_field_async.entity.ModelFieldAsyncConfigDetail; +import org.apache.log4j.Logger; + +import java.util.Map; + +/** + *

    自定义转换接口

    + * + * @author xuanran.wang + * @date 2023/4/11 16:49 + */ +public interface CusModelFieldAsyncConvert { + Logger log = Util.getLogger(); + Object cusConvert(ModelFieldAsyncConfigDetail configDetail, Map detailMap, Map mainMap, Map pathParam); +} diff --git a/src/main/java/com/api/nonstandardext/model_field_async/util/EyCusModelFieldValueRuleMethod.java b/src/main/java/com/api/nonstandardext/model_field_async/util/EyCusModelFieldValueRuleMethod.java new file mode 100644 index 0000000..857fba8 --- /dev/null +++ b/src/main/java/com/api/nonstandardext/model_field_async/util/EyCusModelFieldValueRuleMethod.java @@ -0,0 +1,104 @@ +package com.api.nonstandardext.model_field_async.util; + +import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; +import com.api.nonstandardext.model_field_async.entity.ModelFieldAsyncConfigDetail; +import com.api.nonstandardext.model_field_async.interfaces.TriFunction; +import com.api.nonstandardext.model_field_async.mapper.ModelFieldAsyncMapper; +import com.google.common.base.Strings; +import org.apache.log4j.Logger; +import weaver.xuanran.wang.eny.data_async.service.convert.CusAsyncConvert; +import com.api.nonstandardext.model_field_async.service.convert.CusModelFieldAsyncConvert; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; + +/** + *

    值处理方法

    + * + *

    create: 2023-02-02 15:15

    + * + * @author youHong.ai + */ + +public class EyCusModelFieldValueRuleMethod { + + + public static final Map, Map, Object>> VALUE_RULE_FUNCTION = new HashMap<>(); + + private final ModelFieldAsyncMapper mapper = Util.getMapper(ModelFieldAsyncMapper.class); + + private final Logger log = Util.getLogger(); + + static { + Class valueRuleMethodClass = EyCusModelFieldValueRuleMethod.class; + Method[] methods = valueRuleMethodClass.getMethods(); + for (Method method : methods) { + if (method.isAnnotationPresent(ValueRuleMethodNo.class)) { + ValueRuleMethodNo annotation = method.getAnnotation(ValueRuleMethodNo.class); + int value = annotation.value(); + VALUE_RULE_FUNCTION.put(value, (detail, detailmap, mainMap) -> { + try { + EyCusModelFieldValueRuleMethod eyCusModelFieldValueRuleMethod = new EyCusModelFieldValueRuleMethod(); + return method.invoke(eyCusModelFieldValueRuleMethod, detail, detailmap, mainMap); + } catch (IllegalAccessException | InvocationTargetException e) { + throw new RuntimeException(e); + } + }); + } + } + } + + @ValueRuleMethodNo(value = 0, desc = "明细表数据不转换") + public Object getFixValue(ModelFieldAsyncConfigDetail configDetail,Map detailMap, Map mainMap) { + return Util.null2DefaultStr(detailMap.get(configDetail.getValueFieldName()),""); + } + + + @ValueRuleMethodNo(value = 1, desc = "默认值") + public Object getCusText(ModelFieldAsyncConfigDetail configDetail, Map detailMap, Map mainMap) { + return Util.null2DefaultStr(configDetail.getValueContext(),""); + } + + + @ValueRuleMethodNo(value = 2, desc = "自定义sql") + public Object getCustomerSqlValue(ModelFieldAsyncConfigDetail configDetail, Map detailMap, Map mainMap) { + String cusText = configDetail.getValueContext(); + cusText = Util.sbc2dbcCase(cusText); + if (Strings.isNullOrEmpty(cusText)) { + return null; + } + if (!cusText.startsWith("select")) { + return null; + } + return Util.null2DefaultStr(mapper.selectCustomerSql(cusText, detailMap, mainMap),""); + } + + @ValueRuleMethodNo(value = 3, desc = "自定义接口") + public Object getCusConvertInterface(ModelFieldAsyncConfigDetail configDetail, Map detailMap, Map mainMap) { + String cusText = configDetail.getValueContext(); + if(Strings.isNullOrEmpty(cusText)){ + return null; + } + try { + Class clazz = Class.forName(cusText); + if(!CusAsyncConvert.class.isAssignableFrom(clazz)){ + throw new CustomerException(cusText + " not implements getLogFilePath.api.nonstandardext.model_field_async.service.convert"); + } + CusModelFieldAsyncConvert o = (CusModelFieldAsyncConvert) clazz.newInstance(); + Map pathParam = Util.parseCusInterfacePathParam(cusText); + return o.cusConvert(configDetail, detailMap, mainMap, pathParam); + }catch (Exception e){ + log.error("getCusConvertInterface error! " + e.getMessage()); + return null; + } + } + + @ValueRuleMethodNo(value = 4, desc = "转主表数据") + public Object getMainTableFieldValue(ModelFieldAsyncConfigDetail configDetail, Map detailMap, Map mainMap) { + return Util.null2DefaultStr(mainMap.get(configDetail.getValueFieldName()),""); + } + +} diff --git a/src/main/java/com/api/nonstandardext/model_field_async/util/ValueRuleMethodNo.java b/src/main/java/com/api/nonstandardext/model_field_async/util/ValueRuleMethodNo.java new file mode 100644 index 0000000..b3e3eb1 --- /dev/null +++ b/src/main/java/com/api/nonstandardext/model_field_async/util/ValueRuleMethodNo.java @@ -0,0 +1,19 @@ +package com.api.nonstandardext.model_field_async.util; + +import java.lang.annotation.*; + +/** + *

    值处理方法编号注解

    + * + *

    create: 2023-02-02 15:18

    + * + * @author youHong.ai + */ + +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface ValueRuleMethodNo { + int value(); + String desc(); +} diff --git a/src/main/java/weaver/formmode/customjavacode/modeexpand/ey/jiahx/TransferSelect.java b/src/main/java/weaver/formmode/customjavacode/modeexpand/ey/jiahx/TransferSelect.java new file mode 100644 index 0000000..fd3b62e --- /dev/null +++ b/src/main/java/weaver/formmode/customjavacode/modeexpand/ey/jiahx/TransferSelect.java @@ -0,0 +1,130 @@ +package weaver.formmode.customjavacode.modeexpand.ey.jiahx; + +import com.api.nonstandardext.model_field_async.service.ModelFieldAsyncServiceImpl; +import weaver.conn.RecordSet; +import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.HashMap; +import java.util.Map; + +/** + * @Description + * @Author 贾寒旭 + * @Date 2023/4/6 + * @Other + * @Version + */ +public class TransferSelect extends AbstractModeExpandJavaCodeNew { + + private final ModelFieldAsyncServiceImpl service = new ModelFieldAsyncServiceImpl(); + + @Override + public Map doModeExpand(Map param) { + BaseBean baseBean = new BaseBean(); + +// src/weaver/formmode/customjavacode/modeexpand/getKmmb.java + baseBean.writeLog("保存自定义接口开始TransferSelect>>>>>"); + Map result = new HashMap(); + try { + User user = (User) param.get("user"); + int billid = -1;//数据id + int modeid = -1;//模块id + RequestInfo requestInfo = (RequestInfo) param.get("RequestInfo"); + if (requestInfo != null) { + billid = Util.getIntValue(requestInfo.getRequestid()); + modeid = Util.getIntValue(requestInfo.getWorkflowid()); + RecordSet upRs = new RecordSet(); + if (billid > 0 && modeid > 0) { + //------请在下面编写业务逻辑代码------ +// billingType,requestType,billingIssueType,clientType,multipleBilling,serviceType,LeType + String sql = "select * from uf_zdjmbd where id = ?"; + RecordSet rs = new RecordSet(); + rs.executeQuery(sql, billid); + while (rs.next()) { + String billingTypewb = Util.null2String(rs.getString("billingTypewb")); + String requestTypewb = Util.null2String(rs.getString("requestTypewb")); + String billingIssueTypewb = Util.null2String(rs.getString("billingIssueTypewb")); + String clientTypewb = Util.null2String(rs.getString("clientTypewb")); + String multipleBillingwb = Util.null2String(rs.getString("multipleBillingwb")); + String serviceTypewb = Util.null2String(rs.getString("serviceTypewb")); + String LeTypewb = Util.null2String(rs.getString("LeTypewb")); + //2023年6月7日新增engCodewb转换engCode --cds + String engCodewb = Util.null2String(rs.getString("engCodewb")); + + if (!engCodewb.equals("")) { + String Upsql = "update uf_zdjmbd uf ,uf_xmjbxxjmbd xm set uf.engCode = xm.engagement_code " + + "where uf.engCodewb = xm.engagement_code1 and uf.engCodewb=? and uf.id = ?"; + upRs.executeUpdate(Upsql, engCodewb, billid); + } + if (!billingTypewb.equals("")) { + String Upsql = "update uf_zdjmbd uf ,uf_vmschange_dt1 uv set uf.billingType = uv.zdid" + + " where uf.billingTypewb = uv.zdnr and uf.billingType is null and uf.id = ?"; + upRs.executeUpdate(Upsql, billid); + } + if (!requestTypewb.equals("")) { + String Upsql = "update uf_zdjmbd uf ,uf_vmschange_dt1 uv set uf.requestType = uv.zdid " + + " where uf.requestTypewb = uv.zdnr and uf.requestType is null and uf.id = ?"; + upRs.executeUpdate(Upsql, billid); + } + if (!billingIssueTypewb.equals("")) { + String Upsql = "update uf_zdjmbd uf ,uf_vmschange_dt1 uv set uf.billingIssueType = uv.zdid " + + " where uf.billingIssueTypewb = uv.zdnr and uf.billingIssueType is null and uf.id = ?"; + upRs.executeUpdate(Upsql, billid); + } + if (!clientTypewb.equals("")) { + String Upsql = "update uf_zdjmbd uf ,uf_vmschange_dt1 uv set uf.clientType = uv.zdid " + + " where uf.clientTypewb = uv.zdnr and uf.clientType is null and uf.id = ?"; + upRs.executeUpdate(Upsql, billid); + } + if (!multipleBillingwb.equals("")) { + String Upsql = "update uf_zdjmbd uf ,uf_vmschange_dt1 uv set uf.multipleBilling = uv.zdid " + + " where uf.multipleBillingwb = uv.zdnr and uf.multipleBilling is null and uf.id = ?"; + upRs.executeUpdate(Upsql, billid); + } + if (!serviceTypewb.equals("")) { + String Upsql = "update uf_zdjmbd uf ,uf_vmschange_dt1 uv set uf.serviceType = uv.zdid " + + " where uf.serviceTypewb = uv.zdnr and uf.serviceType is null and uf.id = ?"; + upRs.executeUpdate(Upsql, billid); + } + if (!LeTypewb.equals("")) { + String Upsql = "update uf_zdjmbd uf ,uf_vmschange_dt1 uv set uf.LeType = uv.zdid " + + " where uf.LeTypewb = uv.zdnr and uf.LeType is null and uf.id = ?"; + upRs.executeUpdate(Upsql, billid); + } + } + + rs.executeQuery("select dt1.engCodewb,dt1.id from uf_zdjmbd_dt1 dt1 left join uf_zdjmbd m on dt1.mainid=m.id where m.id = ?", billid); + + //更新uf_zdjmbd_dt1,engCode + String Upsql = "update uf_zdjmbd_dt1 uf ,uf_xmjbxxjmbd xm set uf.engCode = xm.engagement_code " + + "where uf.engCodewb = xm.engagement_code1 and uf.engCodewb=? and uf.id = ?"; + while (rs.next()) { + String engCodewb = Util.null2String(rs.getString("engCodewb")); + String id = Util.null2String(rs.getString("id")); + if (!"".equals(engCodewb)) { + boolean b = upRs.executeUpdate(Upsql, engCodewb, id); + baseBean.writeLog("TransferSelect转换明细engCode-----Flag:" + b); + } + } + /** + * 通过配置同步字段 + * @author xuanran.wang + * @date 2023-06-27 + */ + service.asyncDataByClassName(this.getClass().getSimpleName(), String.valueOf(billid)); + + + } + } + } catch (Exception e) { + baseBean.writeLog("TransferSelect catch exception:" + e); + result.put("errmsg", "自定义出错信息"); + result.put("flag", "false"); + } + return result; + } +} diff --git a/src/main/java/weaver/formmode/customjavacode/modeexpand/ey/jiahx/TransferSelect_fp.java b/src/main/java/weaver/formmode/customjavacode/modeexpand/ey/jiahx/TransferSelect_fp.java new file mode 100644 index 0000000..860dc8b --- /dev/null +++ b/src/main/java/weaver/formmode/customjavacode/modeexpand/ey/jiahx/TransferSelect_fp.java @@ -0,0 +1,73 @@ +package weaver.formmode.customjavacode.modeexpand.ey.jiahx; + +import com.api.nonstandardext.model_field_async.service.ModelFieldAsyncServiceImpl; +import weaver.conn.RecordSet; +import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.HashMap; +import java.util.Map; + +/** + * @Description + * @Author 贾寒旭 + * @Date 2023/4/6 + * @Other + * @Version + */ +//更新 uf_fptbjmbd_dt1 ,engCode +public class TransferSelect_fp extends AbstractModeExpandJavaCodeNew { + + private final ModelFieldAsyncServiceImpl service = new ModelFieldAsyncServiceImpl(); + + @Override + public Map doModeExpand(Map param) { + BaseBean baseBean = new BaseBean(); + +// src/weaver/formmode/customjavacode/modeexpand/getKmmb.java + baseBean.writeLog("保存自定义接口开始TransferSelect_fp>>>>>"); + Map result = new HashMap(); + try { + User user = (User) param.get("user"); + int billid = -1;//数据id + int modeid = -1;//模块id + RequestInfo requestInfo = (RequestInfo) param.get("RequestInfo"); + if (requestInfo != null) { + billid = Util.getIntValue(requestInfo.getRequestid()); + modeid = Util.getIntValue(requestInfo.getWorkflowid()); + RecordSet upRs = new RecordSet(); + if (billid > 0 && modeid > 0) { + RecordSet rs = new RecordSet(); + rs.executeQuery("select dt1.engCodewb,dt1.id from uf_fptbjmbd_dt1 dt1 left join uf_fptbjmbd m on dt1.mainid=m.id where m.id = ?", billid); + + //更新uf_fptbjmbd_dt1,engCode + String Upsql = "update uf_fptbjmbd_dt1 uf ,uf_fptbjmbd xm set uf.engCode = xm.engagement_code " + + "where uf.engCodewb = xm.engagement_code1 and uf.engCodewb=? and uf.id = ?"; + while (rs.next()) { + String engCodewb = Util.null2String(rs.getString("engCodewb")); + String id = Util.null2String(rs.getString("id")); + if (!"".equals(engCodewb)) { + boolean b = upRs.executeUpdate(Upsql, engCodewb, id); + baseBean.writeLog("TransferSelect_fp转换明细engCode-----Flag:" + b); + } + } + /** + * 通过配置同步字段 + * @author xuanran.wang + * @date 2023-06-27 + */ + service.asyncDataByClassName(this.getClass().getSimpleName(), String.valueOf(billid)); + + } + } + } catch (Exception e) { + baseBean.writeLog("TransferSelect_fp catch exception:" + e); + result.put("errmsg", "自定义出错信息"); + result.put("flag", "false"); + } + return result; + } +} diff --git a/src/test/java/ebu7dev1/common/getlog/CusTest.java b/src/test/java/ebu7dev1/common/getlog/CusTest.java new file mode 100644 index 0000000..ade6442 --- /dev/null +++ b/src/test/java/ebu7dev1/common/getlog/CusTest.java @@ -0,0 +1,38 @@ +package ebu7dev1.common.getlog; + +import basetest.BaseTest; +import com.alibaba.fastjson.JSONObject; +import com.api.ebu7dev1.common.getlog.service.GetLogService; +import com.api.ebu7dev1.common.getlog.util.GetLogUtil; +import org.junit.Test; + +import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + *

    + * + * @author xuanran.wang + * @date 2023/7/1 17:33 + */ +public class CusTest extends BaseTest { + + private final GetLogService service = new GetLogService(); + + @Test + public void testA() throws FileNotFoundException { + List list = new ArrayList<>(); + for (int i = 0; i <= 8; i++) { + list.add(i + ""); + } + String base = "/Users/wangxuanran/company/project/ebu_ecology_dev1"; + List> path = GetLogUtil.getLogPathByLogType(base, base, list); + + Map>> map = GetLogUtil.getLogFilePath(path, "2023-07-01", "2023-07-02"); + + System.out.println(JSONObject.toJSONString(map)); +// GetLogUtil.com(base, map); + } +} diff --git a/src/test/java/xuanran/wang/checker/Checker.java b/src/test/java/xuanran/wang/checker/Checker.java new file mode 100644 index 0000000..093a7f2 --- /dev/null +++ b/src/test/java/xuanran/wang/checker/Checker.java @@ -0,0 +1,118 @@ +package xuanran.wang.checker; + +import xuanran.wang.checker.fun.HandleFunction; +import xuanran.wang.checker.fun.Predicate; +import xuanran.wang.checker.fun.SFunction; +import xuanran.wang.checker.handler.ConditionHandler; + +import java.util.*; + +/** + * 参数校验工具 + * + * @author alan + * @date 2023/06/12 + */ +public class Checker { + + private final List> conditions = new ArrayList<>(); + + private static final Map FUNCTION_HASH_MAP = new HashMap<>(); + + static { + FUNCTION_HASH_MAP.put(ECheckType.NE, ConditionHandler::handleNe); + FUNCTION_HASH_MAP.put(ECheckType.NOTNULL, ConditionHandler::handleNotNull); + FUNCTION_HASH_MAP.put(ECheckType.NOTNULL_NE, ConditionHandler::handleNotNullNe); + FUNCTION_HASH_MAP.put(ECheckType.IN, ConditionHandler::handleIn); + FUNCTION_HASH_MAP.put(ECheckType.CUSTOM, ConditionHandler::handleCustom); + } + + /** + * 判断该值不能为传入值 + */ + public Checker ne(SFunction column, Object val, String desc) { + conditions.add(new Condition<>(getFieldMeta(column), ECheckType.NE, val, desc)); + return this; + } + + /** + * 判断值不能为空 + */ + public Checker notNull(SFunction column, String desc) { + conditions.add(new Condition(getFieldMeta(column), ECheckType.NOTNULL, null, desc)); + return this; + } + + /** + * 不能为空且不能为传入值 + */ + public Checker notNe(SFunction column, Object val, String desc) { + conditions.add(new Condition<>(getFieldMeta(column), ECheckType.NOTNULL_NE, val, desc)); + return this; + } + + /** + * 不能为空且不能为传入值 + */ + public Checker in(SFunction column, Collection val, String desc) { + conditions.add(new Condition<>(getFieldMeta(column), ECheckType.IN, val, desc)); + return this; + } + + /** + * 判断该值不能为传入值 + */ + public Checker ne(SFunction column, Object val) { + return ne(column, val, null); + } + + /** + * 判断值不能为空 + */ + public Checker notNull(SFunction column) { + return notNull(column, null); + } + + /** + * 不能为空且不能为传入值 + */ + public Checker notNe(SFunction column, Object val) { + return notNe(column, val, null); + } + + /** + * 不能为空且不能为传入值 + */ + public Checker in(SFunction column, Collection val) { + return in(column, val, null); + } + + /** + * 自定义规则 条件成立则抛出 业务异常 + */ + public Checker custom(Predicate resultPredicate, String desc) { + Condition condition = new Condition<>("", ECheckType.CUSTOM, null, desc); + condition.setResultPredicate(resultPredicate); + conditions.add(condition); + return this; + } + + /** + * 执行校验逻辑 + */ + public void check(T obj) { + + if (Objects.isNull(obj)) { + throw new CheckerException("参数为空"); + } + for (Condition condition : conditions) { + FUNCTION_HASH_MAP.get(condition.getType()).apply(obj, condition); + } + + } + + private String getFieldMeta(SFunction column) { + return ConvertUtil.convertToFieldName(column); + } + +} diff --git a/src/test/java/xuanran/wang/checker/CheckerException.java b/src/test/java/xuanran/wang/checker/CheckerException.java new file mode 100644 index 0000000..d01345d --- /dev/null +++ b/src/test/java/xuanran/wang/checker/CheckerException.java @@ -0,0 +1,15 @@ +package xuanran.wang.checker; + +/*** + * 参数校验异常 + * + * @author loser + * @date 2023/06/12 + */ +public class CheckerException extends RuntimeException { + + public CheckerException(String message) { + super(message); + } + +} diff --git a/src/test/java/xuanran/wang/checker/Checkers.java b/src/test/java/xuanran/wang/checker/Checkers.java new file mode 100644 index 0000000..307cba1 --- /dev/null +++ b/src/test/java/xuanran/wang/checker/Checkers.java @@ -0,0 +1,15 @@ +package xuanran.wang.checker; + +/** + * 参数校验工具 + * + * @author alan + * @date 2023/06/12 + */ +public class Checkers { + + public static Checker lambdaCheck() { + return new Checker<>(); + } + +} diff --git a/src/test/java/xuanran/wang/checker/Condition.java b/src/test/java/xuanran/wang/checker/Condition.java new file mode 100644 index 0000000..0ee9435 --- /dev/null +++ b/src/test/java/xuanran/wang/checker/Condition.java @@ -0,0 +1,70 @@ +package xuanran.wang.checker; + + +import xuanran.wang.checker.fun.Predicate; + +/*** + * 条件 + * + * @author loser + * @date 2023/06/12 + */ +public class Condition { + + private String field; + + private ECheckType type; + + private Object val; + + private String desc; + + private Predicate resultPredicate; + + public Condition(String field, ECheckType type, Object val, String desc) { + this.field = field; + this.type = type; + this.val = val; + this.desc = desc; + } + + public String getField() { + return field; + } + + public void setField(String field) { + this.field = field; + } + + public ECheckType getType() { + return type; + } + + public void setType(ECheckType type) { + this.type = type; + } + + public Object getVal() { + return val; + } + + public void setVal(Object val) { + this.val = val; + } + + public String getDesc() { + return desc; + } + + public void setDesc(String desc) { + this.desc = desc; + } + + public Predicate getResultPredicate() { + return resultPredicate; + } + + public void setResultPredicate(Predicate resultPredicate) { + this.resultPredicate = resultPredicate; + } +} diff --git a/src/test/java/xuanran/wang/checker/ConvertUtil.java b/src/test/java/xuanran/wang/checker/ConvertUtil.java new file mode 100644 index 0000000..56be49d --- /dev/null +++ b/src/test/java/xuanran/wang/checker/ConvertUtil.java @@ -0,0 +1,97 @@ +package xuanran.wang.checker; + + + +import xuanran.wang.checker.fun.SFunction; + +import java.io.Serializable; +import java.lang.invoke.SerializedLambda; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; + + +/** + * 转换工具 + * + * @author loser + * @date 2023/06/12 + */ +public class ConvertUtil { + + private ConvertUtil() { + } + + public static final String GET = "get"; + + public static final String IS = "is"; + + /** + * 缓存方法应用对应的属性名称 + */ + private static final Map, String> CLASS_FIELD_META_MAP = new ConcurrentHashMap<>(); + + /** + * 转换方法引用为属性名 + */ + public static String convertToFieldName(SFunction fn) { + + SerializedLambda lambda = getSerializedLambda(fn); + String cacheData = CLASS_FIELD_META_MAP.get(fn.getClass()); + if (Objects.nonNull(cacheData)) { + return cacheData; + } + String methodName = lambda.getImplMethodName(); + if (methodName.startsWith(GET)) { + methodName = methodName.substring(3); + } else if (methodName.startsWith(IS)) { + methodName = methodName.substring(2); + } else { + throw new IllegalArgumentException("无效的getter方法:" + methodName); + } + try { + String fieldMeta = firstToLowerCase(methodName); + CLASS_FIELD_META_MAP.put(fn.getClass(), fieldMeta); + return fieldMeta; + } catch (Exception e) { + throw new RuntimeException(e); + } + + } + + /** + * 获取一个实现了序列化的lambda函数 + * + * @param fn 目标函数 + * @return 实现了序列化的lambda函数 + */ + public static SerializedLambda getSerializedLambda(Serializable fn) { + + SerializedLambda lambda; + try { + // 提取SerializedLambda并缓存 + Method method = fn.getClass().getDeclaredMethod("writeReplace"); + method.setAccessible(Boolean.TRUE); + lambda = (SerializedLambda) method.invoke(fn); + } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { + throw new RuntimeException(e); + } + return lambda; + + } + + /** + * 首字母转换小写 + * + * @param str 需要转换的字符串 + * @return 转换好的字符串 + */ + public static String firstToLowerCase(final String str) { + if (null == str || str.length() == 0) { + return ""; + } + return str.substring(0, 1).toLowerCase() + str.substring(1); + } +} \ No newline at end of file diff --git a/src/test/java/xuanran/wang/checker/ECheckType.java b/src/test/java/xuanran/wang/checker/ECheckType.java new file mode 100644 index 0000000..6c0ae02 --- /dev/null +++ b/src/test/java/xuanran/wang/checker/ECheckType.java @@ -0,0 +1,17 @@ +package xuanran.wang.checker; + +/** + * 比较类型 + * + * @author loser + * @date 2023/06/12 + */ +public enum ECheckType { + + NE, + NOTNULL, + NOTNULL_NE, + IN, + CUSTOM + +} diff --git a/src/test/java/xuanran/wang/checker/fun/HandleFunction.java b/src/test/java/xuanran/wang/checker/fun/HandleFunction.java new file mode 100644 index 0000000..9ef2975 --- /dev/null +++ b/src/test/java/xuanran/wang/checker/fun/HandleFunction.java @@ -0,0 +1,26 @@ +package xuanran.wang.checker.fun; + + +import xuanran.wang.checker.Condition; + +import java.io.Serializable; + +/*** + * 功能处理器 + * + * @author loser + * @date 2023/06/12 + */ +@FunctionalInterface +public interface HandleFunction extends Serializable { + + /** + * 处理时间 + * + * @param target 目标对象 + * @param condition 条件 + * @return 是否通过 + */ + boolean apply(Object target, Condition condition); + +} diff --git a/src/test/java/xuanran/wang/checker/fun/Predicate.java b/src/test/java/xuanran/wang/checker/fun/Predicate.java new file mode 100644 index 0000000..5db2d0e --- /dev/null +++ b/src/test/java/xuanran/wang/checker/fun/Predicate.java @@ -0,0 +1,20 @@ +package xuanran.wang.checker.fun; + +/*** + * 断言 + * + * @author loser + * @date 2023/06/12 + */ +@FunctionalInterface +public interface Predicate { + + /** + * 断言操作 + * + * @param target 判断对象 + * @return 是否成 + */ + boolean apply(T target); + +} diff --git a/src/test/java/xuanran/wang/checker/fun/SFunction.java b/src/test/java/xuanran/wang/checker/fun/SFunction.java new file mode 100644 index 0000000..f166cff --- /dev/null +++ b/src/test/java/xuanran/wang/checker/fun/SFunction.java @@ -0,0 +1,20 @@ +package xuanran.wang.checker.fun; + +import java.io.Serializable; + +/** + * 支持序列化的 Function + * 为了获取字段名字 + * + * @author loser + * @date 2023/06/12 + */ +@FunctionalInterface +public interface SFunction extends Serializable { + + /** + * 执行方法 + */ + R apply(T t); + +} diff --git a/src/test/java/xuanran/wang/checker/handler/ConditionHandler.java b/src/test/java/xuanran/wang/checker/handler/ConditionHandler.java new file mode 100644 index 0000000..42f13a5 --- /dev/null +++ b/src/test/java/xuanran/wang/checker/handler/ConditionHandler.java @@ -0,0 +1,114 @@ +package xuanran.wang.checker.handler; + +import org.apache.commons.lang3.StringUtils; +import xuanran.wang.checker.CheckerException; +import xuanran.wang.checker.Condition; + +import java.lang.reflect.Field; +import java.util.Collection; +import java.util.Objects; + +/*** + * 条件处理器 + * + * @author loser + * @date 2023/06/12 + */ +@SuppressWarnings("all") +public class ConditionHandler { + + public static boolean handleCustom(Object obj, Condition condition) { + if (condition.getResultPredicate().apply(obj)) { + throw new CheckerException(condition.getDesc()); + } + return true; + } + + public static boolean handleNe(Object obj, Condition condition) { + try { + Class targetClass = obj.getClass(); + Field field = targetClass.getDeclaredField(condition.getField()); + field.setAccessible(true); + Object result = field.get(obj); + if (Objects.equals(result, condition.getVal())) { + throwBizError(condition); + } + } catch (CheckerException e) { + throw e; + } catch (Exception e) { + throwFieldError(condition); + } + return true; + } + + private static void throwFieldError(Condition condition) { + throwMsg(String.format("字段(%s)不存在", condition.getField())); + } + + private static void throwBizError(Condition condition) { + String msg = StringUtils.isEmpty(condition.getDesc()) ? String.format("字段(%s)值错误", condition.getField()) : condition.getDesc(); + throwMsg(msg); + } + + public static boolean handleNotNull(Object obj, Condition condition) { + try { + Class targetClass = obj.getClass(); + Field field = targetClass.getDeclaredField(condition.getField()); + field.setAccessible(true); + Object result = field.get(obj); + if (Objects.isNull(result)) { + throwBizError(condition); + } + } catch (CheckerException e) { + throw e; + } catch (Exception e) { + throwFieldError(condition); + } + return true; + } + + public static boolean handleNotNullNe(Object obj, Condition condition) { + try { + Class targetClass = obj.getClass(); + Field field = targetClass.getDeclaredField(condition.getField()); + field.setAccessible(true); + Object result = field.get(obj); + if (Objects.isNull(result) || result.equals(condition.getVal())) { + throwBizError(condition); + } + } catch (CheckerException e) { + throw e; + } catch (Exception e) { + throwFieldError(condition); + } + return true; + } + + public static boolean handleIn(Object obj, Condition condition) { + + try { + Class targetClass = obj.getClass(); + Field field = targetClass.getDeclaredField(condition.getField()); + field.setAccessible(true); + Object result = field.get(obj); + Object val = condition.getVal(); + if (val instanceof Collection) { + Collection temp = (Collection) val; + if (Objects.isNull(result) || !temp.contains(result)) { + throwBizError(condition); + } + } + } catch (CheckerException e) { + throw e; + } catch (Exception e) { + throwFieldError(condition); + } + return true; + + } + + public static void throwMsg(String msg) { + throw new CheckerException(msg); + } + +} diff --git a/src/test/java/xuanran/wang/common/abstracts/CusAbstractRequestService.java b/src/test/java/xuanran/wang/common/abstracts/CusAbstractRequestService.java new file mode 100644 index 0000000..0fb6956 --- /dev/null +++ b/src/test/java/xuanran/wang/common/abstracts/CusAbstractRequestService.java @@ -0,0 +1,85 @@ +package xuanran.wang.common.abstracts; + +import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; +import com.alibaba.fastjson.JSON; +import org.apache.commons.collections.CollectionUtils; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.xiao.commons.config.entity.RequestMappingConfig; +import weaver.xiao.commons.config.entity.ResponseMapping; +import weaver.xiao.commons.config.service.DealWithMapping; +import weaver.xiao.commons.utils.SqlUtil; +import weaver.xuanran.wang.common.util.CommonUtil; +import xuanran.wang.common.entity.CusRequestParams; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + + +/** + *

    + * + * @author xuanran.wang + * @date 2023/6/26 10:39 + */ +public abstract class CusAbstractRequestService{ + private final DealWithMapping dealWithMapping = new DealWithMapping(); + private CusRequestParams cusRequestParams = null; + private final Logger log = Util.getLogger(); // 获取日志对象 + private final SqlUtil sqlUtil = new SqlUtil(); + protected CusRequestParams getRequestParams(String onlyMark, String billTable, String requestId){ + RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(onlyMark); // 将配置参数通过唯一标识查询处理成树形结构 + if(Objects.isNull(requestMappingConfig)){ + throw new CustomerException("唯一标识为 : " + onlyMark + " ,在参数配置表中没有找到对应的配置!"); + } + String selectMainSql = CommonUtil.getSelectSql(requestMappingConfig, billTable); + RecordSet recordSet = new RecordSet(); + if (recordSet.executeQuery(selectMainSql, requestId) && recordSet.next()) { + String url = requestMappingConfig.getRequestUrl(); + dealWithMapping.setMainTable(billTable); + Map param = dealWithMapping.getRequestParam(recordSet, requestMappingConfig); + this.cusRequestParams = CusRequestParams.builder() + .url(url) + .mainRs(recordSet) + .requestId(requestId) + .requestMappingConfig(requestMappingConfig) + .billTable(billTable) + .requestParam(param) + .build(); + return this.cusRequestParams; + }else { + log.error("该流程暂未查到数据! requestId : " + requestId); + return null; + } + } + + public abstract T apiSend(CusRequestParams cusRequestParams); + + protected void writeBackResponse(Map result){ + if(Objects.isNull(this.cusRequestParams)){ + log.error("cusRequestParams不能为空!"); + } + if(Objects.isNull(result)){ + log.error("响应信息对象不能为空!"); + } + RequestMappingConfig requestMappingConfig = this.cusRequestParams.getRequestMappingConfig(); + List responseMappingList = requestMappingConfig.getResponseMappingList(); + if(CollectionUtils.isEmpty(responseMappingList)){ + return; + } + String billTable = this.cusRequestParams.getBillTable(); + String requestId = this.cusRequestParams.getRequestId(); + Map> writeBackMessage = dealWithMapping.dealResponse(responseMappingList, result); + log.info("回写信息 writeBackMessage ==>"+ JSON.toJSONString(writeBackMessage)); + Map updateMsg = writeBackMessage.get(billTable); + Map whereParam = new HashMap<>(); + whereParam.put("requestid",requestId); + boolean success = sqlUtil.updateMode(billTable, updateMsg, whereParam); + if(!success){ + log.error("数据回写表单失败!"); + } + } +} diff --git a/src/test/java/xuanran/wang/common/entity/CusRequestParams.java b/src/test/java/xuanran/wang/common/entity/CusRequestParams.java new file mode 100644 index 0000000..d669762 --- /dev/null +++ b/src/test/java/xuanran/wang/common/entity/CusRequestParams.java @@ -0,0 +1,30 @@ +package xuanran.wang.common.entity; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import weaver.conn.RecordSet; +import weaver.xiao.commons.config.entity.RequestMappingConfig; + +import java.util.Map; + +/** + *

    + * + * @author xuanran.wang + * @date 2023/6/26 10:42 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class CusRequestParams { + private String url; + private RecordSet mainRs; + private Map requestParam; + private String requestId; + private String billTable; + private RequestMappingConfig requestMappingConfig; + private Object cusSuccess; +} diff --git a/src/test/java/xuanran/wang/common/test/ServiceTest.java b/src/test/java/xuanran/wang/common/test/ServiceTest.java new file mode 100644 index 0000000..d15673f --- /dev/null +++ b/src/test/java/xuanran/wang/common/test/ServiceTest.java @@ -0,0 +1,22 @@ +package xuanran.wang.common.test; + +import basetest.BaseTest; +import org.junit.Test; + +/** + *

    + * + * @author xuanran.wang + * @date 2023/6/26 11:05 + */ +public class ServiceTest extends BaseTest { + private final TestServiceImpl service = new TestServiceImpl(); + private final TestServiceImpl service1 = new TestServiceImpl(); + private final TestServiceImpl service2 = new TestServiceImpl(); + @Test + public void testA(){ + service.getA(); + service1.getA(); + service2.getA(); + } +} diff --git a/src/test/java/xuanran/wang/common/test/TestServiceImpl.java b/src/test/java/xuanran/wang/common/test/TestServiceImpl.java new file mode 100644 index 0000000..cc3fee9 --- /dev/null +++ b/src/test/java/xuanran/wang/common/test/TestServiceImpl.java @@ -0,0 +1,28 @@ +package xuanran.wang.common.test; + +import xuanran.wang.common.abstracts.CusAbstractRequestService; +import xuanran.wang.common.entity.CusRequestParams; + +import java.util.HashMap; +import java.util.Map; + +/** + *

    + * + * @author xuanran.wang + * @date 2023/6/26 10:57 + */ +public class TestServiceImpl extends CusAbstractRequestService> { + public void getA(){ + CusRequestParams requestParams = this.getRequestParams("pushSealTask", "formtable_main_22", "182398"); + Map map = apiSend(requestParams); + this.writeBackResponse(map); + } + + @Override + public Map apiSend(CusRequestParams cusRequestParams) { + Map res = new HashMap<>(); + res.put("result","123"); + return res; + } +} diff --git a/src/test/java/xuanran/wang/eny/ModelFieldAsyncTest.java b/src/test/java/xuanran/wang/eny/ModelFieldAsyncTest.java new file mode 100644 index 0000000..cf1698c --- /dev/null +++ b/src/test/java/xuanran/wang/eny/ModelFieldAsyncTest.java @@ -0,0 +1,94 @@ +package xuanran.wang.eny; + +import aiyh.utils.ScriptUtil; +import aiyh.utils.Util; +import aiyh.utils.tool.cn.hutool.core.swing.ScreenUtil; +import aiyh.utils.tool.org.apache.commons.jexl3.JexlContext; +import aiyh.utils.tool.org.apache.commons.jexl3.JexlEngine; +import aiyh.utils.tool.org.apache.commons.jexl3.MapContext; +import basetest.BaseTest; +import com.alibaba.fastjson.JSONObject; +import com.api.nonstandardext.model_field_async.entity.ModelFieldAsyncConfigClass; +import org.apache.commons.lang3.StringUtils; +import org.junit.Test; +import com.api.nonstandardext.model_field_async.entity.ModelFieldAsyncConfig; +import com.api.nonstandardext.model_field_async.mapper.ModelFieldAsyncMapper; +import com.api.nonstandardext.model_field_async.service.ModelFieldAsyncServiceImpl; +import xuanran.wang.checker.Checkers; +import xuanran.wang.checker.fun.Predicate; +import xuanran.wang.checker.fun.SFunction; + +import java.util.*; + +/** + *

    + * + * @author xuanran.wang + * @date 2023/6/26 14:49 + */ +public class ModelFieldAsyncTest extends BaseTest { + + private final ModelFieldAsyncServiceImpl service = new ModelFieldAsyncServiceImpl(); + private final ModelFieldAsyncMapper asyncMapper = Util.getMapper(ModelFieldAsyncMapper.class); + + @Test + public void testA(){ + ModelFieldAsyncConfig test1 = service.getConfig("test1"); + System.out.println(JSONObject.toJSONString(test1)); +// service.asyncModelField("1,2", test1); + ModelFieldAsyncConfigClass configClass = service.getConfigClass("TransferSelect"); + System.out.println(JSONObject.toJSONString(configClass)); + service.asyncDataByClassName("TransferSelect", "1"); + } + + @Test + public void testB(){ + String json = "{\n" + + "\t\t\"result\":\"86cebabe-cc3d-4ab6-8512-08db76eadf52\",\n" + + "\t\t\"success\":true,\n" + + "\t\t\"unAuthorizedRequest\":false,\n" + + "\t\t\"__abp\":true\n" + + "\t}"; + Map map = JSONObject.parseObject(json, Map.class); + Map parsemap = (Map) parse("", map); + System.out.println("parse : " + JSONObject.toJSONString(parsemap)); + } + + @Test + public void testC(){ + String script = "for (int i = 0; i < 10; i++) { ans.append(b); }"; + Map params = new HashMap<>(); + params.put("a", 2); + params.put("b", "*"); + params.put("ans", new StringBuilder()); + Object o = ScriptUtil.invokeScript(script, params); + System.out.println("o : " + o); + } + + @Test + public void testD(){ + Map params = new HashMap<>(); + params.put("a", "2"); + params.put("b", "*"); + params.put("ans", new StringBuilder()); + List list = new ArrayList<>(); + list.add("2"); + Checkers.>lambdaCheck() + .custom(map->list.contains(map.get("a")), "值11111").check(params); + } + + public T parse(String dataKey, Map response){ + String[] split = Util.null2DefaultStr(dataKey,"").split("\\."); + int len = split.length; + if(len == 0 || StringUtils.isBlank(dataKey)){ + return (T)response; + } + for (int i = 0; i < len - 1; i++) { + response = (Map) response.get(split[i]); + } + return (T) response.get(split[len - 1]); + } + + + +} diff --git a/src/test/java/xuanran/wang/shyl/dataasync/TestPassword.java b/src/test/java/xuanran/wang/shyl/dataasync/TestPassword.java new file mode 100644 index 0000000..3882ba3 --- /dev/null +++ b/src/test/java/xuanran/wang/shyl/dataasync/TestPassword.java @@ -0,0 +1,22 @@ +package xuanran.wang.shyl.dataasync; + +import basetest.BaseTest; +import org.junit.Test; +import weaver.rsa.security.RSA; + +import java.util.List; + +/** + *

    + * + * @author xuanran.wang + * @date 2023/7/3 11:49 + */ +public class TestPassword extends BaseTest { + @Test + public void testA(){ + RSA var15 = new RSA(); + String decrypt = var15.decrypt("cY5Y2bIDOnQCGfmmAHTH6g48qhAw+b3DbAPndeT1KxkK0z5K5kyBA5cbE8mfJYdjhK6WQ2W5/YfIHAWDNQxP1UCGzFSjmBbUkx5oJFlhm0G+s/AwsxqsiFU2uFVqKpyfJP/Xdm0ux6bNfUSu8KoqfrB6h6HonGPmXQc2fATQ66urHC7mnpvC6XGOQ/0K7z0grcLv59PuKU5AkZpn2LZ/qMeaGWkAaBOB2Ko9xc8lBnvppyN23cozde2CVyoD8s59otp543oSN6MFHpkLVk2C1Uew8arZhEP+04VJdGhABtLX1H5X+N/hG20dlH5HxWlvYkc6H9qaKv89XvcXdg072Q==``RSA``"); + System.out.println(decrypt); + } +} From 7143747a2572dfdaf897e1b9f7410f855419e05b Mon Sep 17 00:00:00 2001 From: "youhong.ai" Date: Mon, 3 Jul 2023 13:01:19 +0800 Subject: [PATCH 13/13] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/youhong/ai/utiltest/resultjsonparase/ParseTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/youhong/ai/utiltest/resultjsonparase/ParseTest.java b/src/test/java/youhong/ai/utiltest/resultjsonparase/ParseTest.java index f227936..3f8fb4e 100644 --- a/src/test/java/youhong/ai/utiltest/resultjsonparase/ParseTest.java +++ b/src/test/java/youhong/ai/utiltest/resultjsonparase/ParseTest.java @@ -41,7 +41,7 @@ public class ParseTest extends BaseTest { resultParas.put(alias, valueByKeyStr); dateMap.put(alias, valueByKeyStr); } - resultParas.put("data", resultData); + resultParas.put("data", resultData.get("data")); List mappings = baseData.getMappings(); Map> parseMap = new HashMap<>(); for (DetailTableConfig mapping : mappings) {