合并远程分支,保时捷流程数据推送,api创建流程,ihg用户信息元素后段
dev
youhong.ai 2023-06-26 10:26:46 +08:00
commit 2c3fcb7ac4
15 changed files with 404 additions and 100 deletions

View File

@ -59,7 +59,7 @@ function initTimeoutDate(){
console.log('计算下次超时日期 ', computeTimeoutDate); console.log('计算下次超时日期 ', computeTimeoutDate);
var trackingLine = parseInt(WfForm.getFieldValue(trackingLineField)); var trackingLine = parseInt(WfForm.getFieldValue(trackingLineField));
var detail2LineNum = WfForm.getDetailRowCount("detail_2"); var detail2LineNum = WfForm.getDetailRowCount("detail_2");
setTimeout(()=>{ setTimeout(function (){
WfForm.changeFieldValue(timeoutRemindDateFiled, {value: computeTimeoutDate}); WfForm.changeFieldValue(timeoutRemindDateFiled, {value: computeTimeoutDate});
// 判断流程提交走向 // 判断流程提交走向
console.log('主表跟踪触发行数 : ', trackingLine) console.log('主表跟踪触发行数 : ', trackingLine)
@ -101,7 +101,10 @@ function getCurrentDate() {
function parseDate(date) { function parseDate(date) {
var currentYear = date.getFullYear(); 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(); var currentDay = date.getDate();
return currentYear + '-' + currentMonth + '-' + currentDay; return currentYear + '-' + currentMonth + '-' + currentDay;
} }

View File

@ -1210,9 +1210,15 @@ public class Util extends weaver.general.Util {
Properties prop = new Properties(); Properties prop = new Properties();
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
InputStream inputStream = null; InputStream inputStream = null;
InputStreamReader reader = null;
try { try {
inputStream = new BufferedInputStream(new FileInputStream(path)); inputStream = new BufferedInputStream(new FileInputStream(path));
prop.load(inputStream); /**
* <h2> </h2>
* <h2>xuanran.wang 2023-06-26 10:16</h2>
**/
reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
prop.load(reader);
Enumeration<?> enumeration = prop.propertyNames(); Enumeration<?> enumeration = prop.propertyNames();
while (enumeration.hasMoreElements()) { while (enumeration.hasMoreElements()) {
String key = String.valueOf(enumeration.nextElement()); String key = String.valueOf(enumeration.nextElement());
@ -1222,6 +1228,9 @@ public class Util extends weaver.general.Util {
throw new RuntimeException("找不到文件:" + path); throw new RuntimeException("找不到文件:" + path);
} finally { } finally {
try { try {
if (reader != null) {
reader.close();
}
if (inputStream != null) { if (inputStream != null) {
inputStream.close(); inputStream.close();
} }

View File

@ -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;
/**
* <h1>kafka</h1>
*
* @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());
}
}
}

View File

@ -0,0 +1,24 @@
package com.api.xuanran.wang.immc.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* <h1>vo kafka</h1>
*
* @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;
}

View File

@ -49,6 +49,10 @@ public class WorkFlowToVmsAndMQ extends SafeCusBaseAction {
@PrintParamMark @PrintParamMark
@ActionOptionalParam(value = "message", desc = "报错返回信息字段") @ActionOptionalParam(value = "message", desc = "报错返回信息字段")
private String msg; private String msg;
@PrintParamMark
@ActionOptionalParam(value = "0", desc = "发送mq跳过校验")
private String mqSkip;
@Override @Override
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) { 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")) .successVal(Util.null2DefaultStr(successVal, "200"))
.message(Util.null2DefaultStr(msg, "message")) .message(Util.null2DefaultStr(msg, "message"))
.build(); .build();
workFlowToVmsAndMQService.workFlowToVmsAndMQ(onlyMark, billTable, requestId, vmsResponseVoField, kafkaConfig); workFlowToVmsAndMQService.workFlowToVmsAndMQ(onlyMark, billTable, requestId, vmsResponseVoField, kafkaConfig, mqSkip);
} }
} }

View File

@ -32,19 +32,20 @@ public class CusListValue implements CusInterfaceGetValue {
// 如果fileName不为空则对集合中每个map添加"fileName":value value则是附件字段名称 // 如果fileName不为空则对集合中每个map添加"fileName":value value则是附件字段名称
String fileName = Util.null2DefaultStr(pathParam.get("fileName"), ""); String fileName = Util.null2DefaultStr(pathParam.get("fileName"), "");
if(StringUtils.isNotBlank(cusSql)){ if(StringUtils.isNotBlank(cusSql)){
cusSql = cusSql.replace("{?requestid}",Util.null2DefaultStr(mainMap.get("requestid"),""));
if (StringUtils.isNotBlank(attachmentField)) { if (StringUtils.isNotBlank(attachmentField)) {
for (String item : attachmentField.split(",")) { String[] fields = attachmentField.split(",");
for (String item : fields) {
String filedValue = Util.null2DefaultStr(mainMap.get(item),""); String filedValue = Util.null2DefaultStr(mainMap.get(item),"");
if(StringUtils.isNotBlank(Util.null2DefaultStr(mainMap.get(filedValue),""))){ String fileSql = cusSql;
cusSql = cusSql if(StringUtils.isNotBlank(filedValue)){
.replace("{?docIds}", "( " + filedValue + " )") fileSql = fileSql.replace("{?docIds}", "( " + filedValue + " )");
.replace("{?requestid}",Util.null2DefaultStr(mainMap.get("requestid"),"")); List<Map<String, String>> attachmentInfo = mapper.getAttachmentInfo(fileSql);
List<Map<String, String>> attachmentInfo = mapper.getAttachmentInfo(cusSql);
if(CollectionUtils.isEmpty(attachmentInfo)){ if(CollectionUtils.isEmpty(attachmentInfo)){
continue; continue;
} }
// 往map中put附件字段名 // 往map中put附件字段名
if(StringUtils.isBlank(fileName)){ if(StringUtils.isNotBlank(fileName)){
attachmentInfo.forEach(file ->{ attachmentInfo.forEach(file ->{
file.put(fileName, item); file.put(fileName, item);
}); });
@ -52,6 +53,11 @@ public class CusListValue implements CusInterfaceGetValue {
list.addAll(attachmentInfo); list.addAll(attachmentInfo);
} }
} }
}else {
List<Map<String, String>> attachmentInfo = mapper.getAttachmentInfo(cusSql);
if(CollectionUtils.isNotEmpty(attachmentInfo)){
list.addAll(attachmentInfo);
}
} }
} }
return list; return list;

View File

@ -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;
/**
* <h1>url, </h1>
*
* @author xuanran.wang
* @date 2023/6/21 15:50
*/
@Setter
@Builder
@AllArgsConstructor
@Getter
public class CusRequestParam {
private String url;
private RecordSet rs;
private Map<String, Object> param;
private String requestId;
}

View File

@ -6,24 +6,25 @@ import aiyh.utils.httpUtil.ResponeVo;
import aiyh.utils.httpUtil.util.HttpUtils; import aiyh.utils.httpUtil.util.HttpUtils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; 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.commons.lang3.StringUtils;
import org.apache.kafka.clients.producer.KafkaProducer; import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord; import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.clients.producer.RecordMetadata;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import weaver.conn.RecordSet; import weaver.conn.RecordSet;
import weaver.general.GCONST; import weaver.general.GCONST;
import weaver.xiao.commons.config.entity.RequestMappingConfig; import weaver.xiao.commons.config.entity.RequestMappingConfig;
import weaver.xiao.commons.config.service.DealWithMapping; import weaver.xiao.commons.config.service.DealWithMapping;
import weaver.xuanran.wang.common.util.CommonUtil; import weaver.xuanran.wang.common.util.CommonUtil;
import weaver.xuanran.wang.immc.entity.CusRequestParam;
import weaver.xuanran.wang.immc.entity.VmsResponseVoField; import weaver.xuanran.wang.immc.entity.VmsResponseVoField;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import java.io.*; import java.io.*;
import java.lang.reflect.Field;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.Properties; import java.util.Properties;
/** /**
@ -43,35 +44,48 @@ public class WorkFlowToVmsAndMQService {
private static final String VMS_SUCCESS = "vms_success"; private static final String VMS_SUCCESS = "vms_success";
private static final String SUCCESS = "0"; private static final String SUCCESS = "0";
private static final String SKIP = "1";
{ {
httpUtils.getGlobalCache().header.put("Content-Type", MediaType.APPLICATION_JSON); // 全局请求头 httpUtils.getGlobalCache().header.put("Content-Type", MediaType.APPLICATION_JSON); // 全局请求头
} }
/**
* <h1>kafka</h1>
* @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());
}
/** /**
* <h1></h1> * <h1></h1>
* *
* @param onlyMark * @param onlyMark
* @param billTable * @param billTable
* @param requestId id * @param requestId id
* @param vmsResponseVoField vms * @param vmsResponseVoField vms
* @param config kafka * @param config kafka
* @author xuanran.wang * @author xuanran.wang
* @dateTime 2022/12/5 17:05 * @dateTime 2022/12/5 17:05
**/ **/
public void workFlowToVmsAndMQ(String onlyMark, String billTable, String requestId, VmsResponseVoField vmsResponseVoField, String config) { public void workFlowToVmsAndMQ(String onlyMark, String billTable,
RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(onlyMark); // 将配置参数通过唯一标识查询处理成树形结构 String requestId, VmsResponseVoField vmsResponseVoField,
String selectMainSql = CommonUtil.getSelectSql(requestMappingConfig, billTable); String config, String skip) {
log.info(Util.logStr("查询主表数据sql : {}, requestId : {}", selectMainSql, requestId)); CusRequestParam requestParam = getRequestParam(onlyMark, billTable, requestId);
RecordSet recordSet = new RecordSet(); if(Objects.isNull(requestParam)){
recordSet.executeQuery(selectMainSql, requestId); return;
recordSet.next(); }
String url = requestMappingConfig.getRequestUrl(); RecordSet rs = requestParam.getRs();
dealWithMapping.setMainTable(billTable); Map<String, Object> param = requestParam.getParam();
Map<String, Object> param = dealWithMapping.getRequestParam(recordSet, requestMappingConfig); String url = requestParam.getUrl();
String vmsSuccess = Util.null2DefaultStr(recordSet.getString(VMS_SUCCESS), ""); String vmsSuccess = Util.null2DefaultStr(rs.getString(VMS_SUCCESS),"");
String mqSuccess = Util.null2DefaultStr(recordSet.getString(MQ_SUCCESS), ""); String mqSuccess = Util.null2DefaultStr(rs.getString(MQ_SUCCESS),"");
if (!SUCCESS.equals(vmsSuccess)) { if(!SUCCESS.equals(vmsSuccess) && !Objects.isNull(vmsResponseVoField)){
ResponeVo responeVo; ResponeVo responeVo;
try { try {
responeVo = httpUtils.apiPost(url, param); responeVo = httpUtils.apiPost(url, param);
@ -81,22 +95,70 @@ public class WorkFlowToVmsAndMQService {
parseResponseVo(responeVo, url, param, vmsResponseVoField); parseResponseVo(responeVo, url, param, vmsResponseVoField);
updateWorkFlow(VMS_SUCCESS, billTable, requestId); 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); sendToMQ(config, param);
updateWorkFlow(MQ_SUCCESS, billTable, requestId); updateWorkFlow(MQ_SUCCESS, billTable, requestId);
} }
} }
/**
* <h1></h1>
* @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);
}
}
/**
* <h1></h1>
* @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<String, Object> param = dealWithMapping.getRequestParam(recordSet, requestMappingConfig);
return CusRequestParam.builder().url(url).rs(recordSet).requestId(requestId).param(param).build();
}else {
log.error("该流程暂未查到数据! requestId : " + requestId);
return null;
}
}
/** /**
* <h1></h1> * <h1></h1>
*
* @param responseVo
* @param url
* @param requestParam
* @author xuanran.wang * @author xuanran.wang
* @dateTime 2022/12/23 11:25 * @dateTime 2022/12/23 11:25
* @param responseVo
* @param url
* @param requestParam
**/ **/
private void parseResponseVo(ResponeVo responseVo, String url, Map<String, Object> requestParam, VmsResponseVoField vmsResponseVoField) { private void parseResponseVo(ResponeVo responseVo, String url, Map<String, Object> requestParam, VmsResponseVoField vmsResponseVoField){
if (responseVo.getCode() != SUCCESS_CODE) { // 相应状态码 if (responseVo.getCode() != SUCCESS_CODE) { // 相应状态码
log.error(Util.logStr("can not fetch [{}]this request params is [{}]" + // 构建日志字符串 log.error(Util.logStr("can not fetch [{}]this request params is [{}]" + // 构建日志字符串
"this request heard is [{}]but response status code is [{}]" + "this request heard is [{}]but response status code is [{}]" +
@ -114,65 +176,63 @@ public class WorkFlowToVmsAndMQService {
/** /**
* <h1>kafka</h1> * <h1>kafka</h1>
*
* @param kafkaConfig kafka
* @param message
* @author xuanran.wang * @author xuanran.wang
* @dateTime 2023/3/30 14:56 * @dateTime 2023/3/30 14:56
* @param kafkaConfig kafka
* @param message
**/ **/
public void sendToMQ(String kafkaConfig, Map<String, Object> message) { public void sendToMQ(String kafkaConfig, Map<String, Object> message){
KafkaProducer<String, String> producer = null; KafkaProducer<String, String> producer = null;
InputStream inputStream = null; InputStream inputStream = null;
try { try {
String path = GCONST.getPropertyPath() + "prop2map" + File.separator + kafkaConfig + ".properties"; String path = GCONST.getPropertyPath() + "prop2map" + File.separator + kafkaConfig + ".properties";
File configFile = new File(path); File configFile = new File(path);
if (!configFile.exists()) { if(!configFile.exists()){
throw new CustomerException("please check /web-inf/prop2map has " + kafkaConfig + ".properties"); throw new CustomerException("please check /web-inf/prop2map has " + kafkaConfig + ".properties");
} }
Properties prop = new Properties(); Properties prop = new Properties();
inputStream = new BufferedInputStream(Files.newInputStream(configFile.toPath())); inputStream= new BufferedInputStream(Files.newInputStream(configFile.toPath()));
prop.load(inputStream); prop.load(inputStream);
log.info("prop => " + JSONObject.toJSONString(prop)); log.info("prop => " + JSONObject.toJSONString(prop));
log.info("msg => " + JSONObject.toJSONString(message)); log.info("msg => " + JSONObject.toJSONString(message));
String topic = Util.null2DefaultStr(prop.getProperty("topic"), ""); String topic = Util.null2DefaultStr(prop.getProperty("topic"),"");
if (StringUtils.isBlank(topic)) { if(StringUtils.isBlank(topic)){
throw new CustomerException("kafka properties topic can not null!"); throw new CustomerException("kafka properties topic can not null!");
} }
producer = new KafkaProducer<>(prop); producer = new KafkaProducer<>(prop);
// 发送消息到指定主题 // 发送消息到指定主题
ProducerRecord<String, String> record = new ProducerRecord<>(topic, JSONObject.toJSONString(message)); ProducerRecord<String, String> record = new ProducerRecord<>(topic, JSONObject.toJSONString(message));
producer.send(record).get(); producer.send(record).get();
} catch (Exception e) { }catch (Exception e){
log.error(Util.getErrString(e)); log.error(Util.getErrString(e));
throw new CustomerException(Util.logStr("send to kafka error!: [{}]", e.getMessage())); throw new CustomerException(Util.logStr("send to kafka error!: [{}]", e.getMessage()));
} finally { }finally {
// 关闭Kafka生产者实例 // 关闭Kafka生产者实例
if (producer != null) { if(producer != null){
producer.close(); producer.close();
} }
if (inputStream != null) { if(inputStream != null){
try { try {
inputStream.close(); inputStream.close();
} catch (Exception e) { }catch (Exception e){
log.error("inputStream close error! " + e.getMessage()); log.error("inputStream close error! " + e.getMessage());
} }
} }
} }
} }
/** /**
* <h1>sql</h1> * <h1>sql</h1>
*
* @param field
* @param tableName
* @param requestId id
* @author xuanran.wang * @author xuanran.wang
* @dateTime 2023/3/30 19:18 * @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 = ?"; String updateSQL = "update " + tableName + " set " + field + " = " + SUCCESS + " where requestid = ?";
RecordSet recordSet = new RecordSet(); 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)); log.error(Util.logStr("update field error! sql: {}, requestId: {}", updateSQL, requestId));
throw new CustomerException("更新表单字段失败!"); throw new CustomerException("更新表单字段失败!");
} }

View File

@ -3,13 +3,16 @@ package weaver.xuanran.wang.sh_bigdata.common.util;
import aiyh.utils.Util; import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException; import aiyh.utils.excention.CustomerException;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.icbc.api.internal.apache.http.impl.cookie.S;
import lombok.Data; import lombok.Data;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.springframework.beans.BeanUtils;
import weaver.workflow.request.todo.RequestStatusObj; import weaver.workflow.request.todo.RequestStatusObj;
import weaver.xuanran.wang.common.mapper.CommonMapper; 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.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.entity.CusTodoTask;
import weaver.xuanran.wang.sh_bigdata.task_async.mapper.SendTodoTaskMapper; import weaver.xuanran.wang.sh_bigdata.task_async.mapper.SendTodoTaskMapper;
@ -63,8 +66,8 @@ public class SendTodoTaskUtil {
* @param objs * @param objs
* @return * @return
**/ **/
public List<CusTodoTask> getTodoTaskInfo(List<RequestStatusObj> objs){ public List<Object> getTodoTaskInfo(List<RequestStatusObj> objs){
ArrayList<CusTodoTask> res = new ArrayList<>(); ArrayList<Object> res = new ArrayList<>();
for (RequestStatusObj obj : objs) { for (RequestStatusObj obj : objs) {
String taskId = getTaskId(0, obj); String taskId = getTaskId(0, obj);
CusTodoTask todoTask = new CusTodoTask(); CusTodoTask todoTask = new CusTodoTask();
@ -80,22 +83,64 @@ public class SendTodoTaskUtil {
} }
todoTask.setPcAgentId(pcAgentId); todoTask.setPcAgentId(pcAgentId);
String todoSSOCallBackUrl = ShBigDataUtil.getPropertiesValByKey("todoSSOCallBackUrl"); String todoSSOCallBackUrl = ShBigDataUtil.getPropertiesValByKey("todoSSOCallBackUrl");
StringBuilder sb = new StringBuilder(todoSSOCallBackUrl); String todoPcSSOCallBackUrl = ShBigDataUtil.getPropertiesValByKey("todoPcSSOCallBackUrl");
sb.append("?user=") if(StringUtils.isBlank(todoPcSSOCallBackUrl)){
.append(userId) todoPcSSOCallBackUrl = todoSSOCallBackUrl;
.append("&requestId=") }
.append(requestId); // 移动端链接
// todoTask.setLinkUrl(Util.null2DefaultStr(ShBigDataUtil.getPropertiesValByKey("taskPcUrl"), oaAddress) + "/spa/workflow/static4form/index.html?#/main/workflow/req?requestid="+requestId); StringBuilder mobileUrl = new StringBuilder(todoSSOCallBackUrl);
// todoTask.setMobileLinkUrl(Util.null2DefaultStr(ShBigDataUtil.getPropertiesValByKey("taskMobileUrl"), oaAddress) + "/spa/workflow/static4mobileform/index.html?#/req?requestid="+requestId); // pc端链接
todoTask.setLinkUrl(sb.toString()); StringBuilder pcUrl = new StringBuilder(todoPcSSOCallBackUrl);
todoTask.setMobileLinkUrl(sb.append("&mobile=1").toString()); 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.setSender(getConvertHrm(0, obj, String.valueOf(obj.getCreator().getUID())));
todoTask.setReceiver(getConvertHrm(1, obj, String.valueOf(userId))); 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); res.add(todoTask);
} }
return res; return res;
} }
/**
* <h1></h1>
* @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);
}
/**
* <h1></h1>
* @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;
}
/** /**
* <h1>oa</h1> * <h1>oa</h1>
* @author xuanran.wang * @author xuanran.wang

View File

@ -20,7 +20,7 @@ import java.util.stream.Collectors;
public class ShBigDataUtil { public class ShBigDataUtil {
private static final String CONFIG_NAME = "ShBigdataConf"; private static final String CONFIG_NAME = "ShBigdataConf";
// 白名单
private static final List<String> WHILTE_LIST = new ArrayList<>(); private static final List<String> WHILTE_LIST = new ArrayList<>();
static { static {
@ -38,6 +38,12 @@ public class ShBigDataUtil {
WHILTE_LIST.add("ssoInterfaceCompareField"); WHILTE_LIST.add("ssoInterfaceCompareField");
WHILTE_LIST.add("ssoOaCompareField"); WHILTE_LIST.add("ssoOaCompareField");
WHILTE_LIST.add("pcAgentId"); WHILTE_LIST.add("pcAgentId");
// pc回调地址
WHILTE_LIST.add("todoPcSSOCallBackUrl");
// 统一待办推送领导节点id
WHILTE_LIST.add("taskAsyncLeaderNodeId");
// 统一待办推送领导节点名称
WHILTE_LIST.add("taskAsyncLeaderNodeName");
} }
/** /**

View File

@ -0,0 +1,17 @@
package weaver.xuanran.wang.sh_bigdata.task_async.entity;
import lombok.*;
/**
* <h1></h1>
*
* @author xuanran.wang
* @date 2023/6/25 10:50
*/
@EqualsAndHashCode(callSuper = true)
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CusTodoLeaderTask extends CusTodoTask{
private String leader;
}

View File

@ -61,7 +61,7 @@ public class SendTodoTaskServiceImpl implements SendTodoTaskService {
.dataKey("") .dataKey("")
.build(); .build();
List<CusTodoTask> taskInfo = sendTodoTaskUtil.getTodoTaskInfo(todoList); List<Object> taskInfo = sendTodoTaskUtil.getTodoTaskInfo(todoList);
log.info("---------------- todoTaskInfo ---------------- \n" + JSONObject.toJSONString(taskInfo)); log.info("---------------- todoTaskInfo ---------------- \n" + JSONObject.toJSONString(taskInfo));
Map<String, Object> response = null; Map<String, Object> response = null;
int success = 0; int success = 0;
@ -74,8 +74,8 @@ public class SendTodoTaskServiceImpl implements SendTodoTaskService {
success = 1; success = 1;
} }
ArrayList<CusTodoTaskToOADetail> details = new ArrayList<>(); ArrayList<CusTodoTaskToOADetail> details = new ArrayList<>();
for (CusTodoTask cusTodoTask : taskInfo) { for (Object obj : taskInfo) {
CusTodoTask cusTodoTask = (CusTodoTask) obj;
CusTodoTaskToOADetail detail = new CusTodoTaskToOADetail(); CusTodoTaskToOADetail detail = new CusTodoTaskToOADetail();
detail.setTaskNum(cusTodoTask.getTaskNum()); detail.setTaskNum(cusTodoTask.getTaskNum());
detail.setRequestUrl(addTodoTaskUrl); detail.setRequestUrl(addTodoTaskUrl);

View File

@ -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} taskMobileUrl=http://127.0.0.1/spa/workflow/static4mobileform/index.html?#/req?requestid={requestId}
# oa token缓存对象提前过期时间 # oa token缓存对象提前过期时间
expiryBeforeTime=5 expiryBeforeTime=5
# 统一待办单点接口地址 # 统一待办单点移动端接口地址
todoSSOCallBackUrl=http://127.0.0.1/api/wxr/sh_big_data/sso/login/dhajhdsajdhsajdaskdlakdl 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 maxLevel=3
@ -58,3 +59,12 @@ ssoOaCompareField=
# sso校验时 接口取值字段 # sso校验时 接口取值字段
ssoInterfaceCompareField= ssoInterfaceCompareField=
# =============== 统一待办推送 ===============
# 统一待办推送领导节点id
taskAsyncLeaderNodeId=1,2
# 统一待办推送领导节点名称
taskAsyncLeaderNodeName=节点名1,21212
# leader字段默认值
taskAsyncLeaderValue=1

View File

@ -4,6 +4,7 @@ import aiyh.utils.GenerateFileUtil;
import basetest.BaseTest; import basetest.BaseTest;
import org.junit.Test; import org.junit.Test;
import weaver.xuanran.wang.eighty_five_degreec.sap.action.WorkflowToSap; import weaver.xuanran.wang.eighty_five_degreec.sap.action.WorkflowToSap;
import weaver.xuanran.wang.immc.WorkFlowToVmsAndMQ;
/** /**
* <h1></h1> * <h1></h1>
@ -16,6 +17,6 @@ public class NormalTest extends BaseTest {
@Test @Test
public void testWord(){ public void testWord(){
GenerateFileUtil.createActionDocument(WorkflowToSap.class); GenerateFileUtil.createActionDocument(WorkFlowToVmsAndMQ.class);
} }
} }

View File

@ -12,8 +12,11 @@ import org.apache.commons.lang3.StringUtils;
import org.junit.Test; import org.junit.Test;
import weaver.email.EmailWorkRunnable; import weaver.email.EmailWorkRunnable;
import weaver.general.TimeUtil; 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.common.util.CusInfoToOAUtil;
import weaver.xuanran.wang.sh_bigdata.common.entity.CusSuccess; 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.common.util.ShBigDataUtil;
import weaver.xuanran.wang.sh_bigdata.org_hrm_async.OrganizationHrmSyncFromOtherSys; import weaver.xuanran.wang.sh_bigdata.org_hrm_async.OrganizationHrmSyncFromOtherSys;
import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OrgHrmAsyncConfigMain; 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.OrgHrmAsyncApiService;
import weaver.xuanran.wang.sh_bigdata.org_hrm_async.service.impl.OrgHrmAsyncApiServiceImpl; 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.org_hrm_async.service.impl.OrgHrmAsyncServiceImpl;
import weaver.xuanran.wang.sh_bigdata.task_async.entity.CusTodoTask;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
@ -396,4 +400,44 @@ public class BigDataTest extends BaseTest {
int id = otherSystemToOAMapper.selectUserIdByOutKey(sql, oaOutKey); int id = otherSystemToOAMapper.selectUserIdByOutKey(sql, oaOutKey);
log.info("id => " + id); log.info("id => " + id);
} }
@Test
public void testH(){
SendTodoTaskUtil taskUtil = new SendTodoTaskUtil();
List<RequestStatusObj> 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<Object> 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<String, Object> 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);
}
} }