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/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/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/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 efcbf85..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; /** @@ -43,35 +44,48 @@ 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()); + } /** *

推送数据

* - * @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 **/ - 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); @@ -81,22 +95,70 @@ 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; + } + } + /** *

解析响应对象

- * - * @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 +176,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..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(); @@ -80,22 +83,64 @@ 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))); + // 是否领导待办逻辑处理 + 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) + .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..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 { @@ -38,6 +38,12 @@ public class ShBigDataUtil { WHILTE_LIST.add("ssoInterfaceCompareField"); WHILTE_LIST.add("ssoOaCompareField"); 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 5c93ffa..127bf0b 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 @@ -58,3 +59,12 @@ ssoOaCompareField= # sso校验时 接口取值字段 ssoInterfaceCompareField= + +# =============== 统一待办推送 =============== +# 统一待办推送领导节点id +taskAsyncLeaderNodeId=1,2 +# 统一待办推送领导节点名称 +taskAsyncLeaderNodeName=节点名1,21212 +# leader字段默认值 +taskAsyncLeaderValue=1 + 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); } } 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); + } }