diff --git a/src/main/java/com/api/bokang/xiao/porsche_review/controller/YearReviewController.java b/src/main/java/com/api/bokang/xiao/porsche_review/controller/YearReviewController.java index 70a6a1f..8da6d2f 100644 --- a/src/main/java/com/api/bokang/xiao/porsche_review/controller/YearReviewController.java +++ b/src/main/java/com/api/bokang/xiao/porsche_review/controller/YearReviewController.java @@ -124,7 +124,7 @@ public class YearReviewController { try{ log.info("into getWorkflowTop success params ==> "+param); User loginUser = HrmUserVarify.getUser(request, response); - loginUser.setLoginid("9"); + loginUser.setLoginid("8"); param.put("workflowIds",workflowIds); if(!param.containsKey("limit")){ param.put("limit",3); diff --git a/src/main/java/com/api/bokang/xiao/porsche_review/mapper/ReviewMapper.java b/src/main/java/com/api/bokang/xiao/porsche_review/mapper/ReviewMapper.java index 66e1c99..38150a3 100644 --- a/src/main/java/com/api/bokang/xiao/porsche_review/mapper/ReviewMapper.java +++ b/src/main/java/com/api/bokang/xiao/porsche_review/mapper/ReviewMapper.java @@ -125,14 +125,14 @@ public interface ReviewMapper { * @return 前五条流程数据 */ @Select("select " + - " wrb.workflowid,wb.workflowname,count(*) wcount " + + " wrb.workflowid,wb.workflowname workflowName,count(*) wcount " + "from workflow_requestoperatelog wfo " + "inner join workflow_requestbase wrb on wfo.requestid = wrb.requestid " + "inner join workflow_base wb on wrb.workflowid = wb.id " + "inner join workflow_nodebase wnb on wfo.nodeid = wnb.id " + "where (wfo.operatorid <> wrb.creater || (wfo.operatorid = wrb.creater && wnb.isstart <> 1)) " + " and (wfo.operatedate between #{param.startDate} and #{param.endDate}) " + - " and operatorid = #{uid} and workflowid not in (${param.workflowIds}) " + + " and operatorid = #{uid} and workflowid not in ($t{param.workflowIds}) " + "group by workflowid " + "order by wcount desc " + "limit ${param.limit}") diff --git a/src/main/java/com/api/bokang/xiao/porsche_review/service/impl/ReviewServiceImpl.java b/src/main/java/com/api/bokang/xiao/porsche_review/service/impl/ReviewServiceImpl.java index ca2a769..caefbb7 100644 --- a/src/main/java/com/api/bokang/xiao/porsche_review/service/impl/ReviewServiceImpl.java +++ b/src/main/java/com/api/bokang/xiao/porsche_review/service/impl/ReviewServiceImpl.java @@ -6,6 +6,7 @@ import com.api.bokang.xiao.porsche_review.service.ReviewService; import io.swagger.models.auth.In; import org.apache.log4j.Logger; import weaver.hrm.User; +import weaver.workflow.request.RequestLogOperateName; import java.util.HashMap; import java.util.List; @@ -60,12 +61,18 @@ public class ReviewServiceImpl implements ReviewService { @Override public List> getCreateTop5(Map param, User user) { - return reviewMapper.queryCreateTop5(param,user.getUID()); + List> maps = reviewMapper.queryCreateTop5(param, user.getUID()); + maps.forEach(item -> item.put("workflowName",Util.formatMultiLang(Util.null2String(item.get("workflowName")),"8"))); + log.info("maps ==>"+maps); + return maps; } @Override public List> getOperateTop5(Map param, User user) { - return reviewMapper.queryOperateTop5(param,user.getUID()); + List> maps = reviewMapper.queryOperateTop5(param, user.getUID()); + maps.forEach(item -> item.put("workflowName",Util.formatMultiLang(Util.null2String(item.get("workflowName")),"8"))); + log.info("maps ==>"+maps); + return maps; } @Override diff --git a/src/main/java/com/api/bokang/xiao/xhny_report/ReportController.java b/src/main/java/com/api/bokang/xiao/xhny_report/ReportController.java deleted file mode 100644 index 8d49250..0000000 --- a/src/main/java/com/api/bokang/xiao/xhny_report/ReportController.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.api.bokang.xiao.xhny_report; - -import aiyh.utils.Util; -import org.apache.log4j.Logger; -import weaver.general.StaticObj; -import weaver.interfaces.datasource.DataSource; - -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.sql.CallableStatement; -import java.sql.Connection; -import java.sql.ResultSet; - - -/** - * @ClassName ReportController - * @Author 肖博亢 - * @Date 2023/3/20 15:49 - * @Description

- **/ -@Path("/xbk/xhny_report") -public class ReportController { - - private final Logger log = Util.getLogger(); - - /** - *

获取搜索组件信息

- * @param request 请求体 - * @param response 响应体 - * @return 请求结果 - */ - @Path("/testDataSource") - @GET - @Produces(MediaType.APPLICATION_JSON) - public String testDataSource(@Context HttpServletRequest request, @Context HttpServletResponse response){ - DataSource ds = (DataSource) StaticObj.getServiceByFullname(("datasource.NCC"),DataSource.class); - Connection conn = null ; - // CallableStatement对象 - CallableStatement callableStatement = null; - // 结果集对象 - ResultSet resultSet = null; - try{ - conn = ds.getConnection(); - callableStatement = conn.prepareCall("{CALL kd_po_nastnumAndnassistnum(?,?,?)}"); - - callableStatement.setString(1,"GC736"); - callableStatement.setString(2,"2023-01-01"); - callableStatement.setString(3,"2023-04-01"); - - resultSet = callableStatement.executeQuery(); - if(resultSet.next()){ - log.info("数据源请求结果 ==>"+resultSet.getString("nrate")); - } - } catch (Exception e) { - log.error("远程调用存储过程失败 ==>"+Util.getErrString(e)); - } - return "查看日志信息"; - } -} diff --git a/src/main/java/com/api/bokang/xiao/zscq/controller/ReserveSelectController.java b/src/main/java/com/api/bokang/xiao/zscq/controller/ReserveSelectController.java new file mode 100644 index 0000000..3be017f --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/zscq/controller/ReserveSelectController.java @@ -0,0 +1,124 @@ +package com.api.bokang.xiao.zscq.controller; + +import aiyh.utils.ApiResult; +import aiyh.utils.Util; +import com.api.bokang.xiao.zscq.service.ReserveService; +import com.api.bokang.xiao.zscq.service.impl.ReserveServiceImpl; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import org.apache.log4j.Logger; +import weaver.file.ImageFileManager; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.xiao.commons.config.entity.WeaverFile; + +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 javax.ws.rs.core.Response; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +/** + * @ClassName ReserveSelectController + * @Author 肖博亢 + * @Date 2023/4/12 17:42 + * @Description

+ **/ +@Path("/xbk/zscq") +public class ReserveSelectController { + + private final Logger log = Util.getLogger(); + + private final ReserveService reserveService = new ReserveServiceImpl(); + + /** + *

获取搜索组件信息

+ * @param request 请求体 + * @param response 响应体 + * @return 请求结果 + */ + @Path("/reserveSelect") + @POST + @Produces(MediaType.APPLICATION_JSON) + public String reserveSelect(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map param) { + try{ + log.info("====== into getReportData success ======="); + log.info("param:"+param); + User loginUser = HrmUserVarify.getUser(request, response); + List> result = reserveService.reserveSelect(param); + return ApiResult.success(result); + }catch (Exception e){ + log.error("获取搜索组件信息 ==> "+ Util.getErrString(e)); + return ApiResult.error(e.getMessage()); + } + } + + //@GET + //@Path("/batch") + //@Produces(MediaType.APPLICATION_OCTET_STREAM) + //public void downloadFiles(@QueryParam("ids") String ids, @Context HttpServletResponse response) { + // try { + // log.info("Start downloading files: {}"+ids); + // // 解析文件ID列表 + // List idList = Arrays.stream(ids.split(",")) + // .map(Long::parseLong) + // .collect(Collectors.toList()); + // + // // 生成压缩文件名 + // String zipFileName = "attachments.zip"; + // + // // 设置响应头,告诉浏览器该响应体是一个附件,浏览器会自动下载该响应体 + // response.setContentType(MediaType.APPLICATION_OCTET_STREAM); + // response.setHeader("Content-Disposition", "attachment; filename=\"" + zipFileName + "\""); + // + // // 创建压缩输出流 + // try (ZipOutputStream zipOutputStream = new ZipOutputStream(response.getOutputStream())) { + // + // // 遍历文件ID列表,将对应的文件加入到压缩文件中 + // for (Long id : idList) { + // // 通过ID获取文件信息 + // WeaverFile file = WeaverFileUtil.getFileMsgById(id); + // + // // 获取文件名和后缀名 + // String fileName = file.getName(); + // String fileExtension = fileName.substring(fileName.lastIndexOf(".") + 1); + // + // // 创建一个ZipEntry,表示压缩文件中的一个文件 + // ZipEntry zipEntry = new ZipEntry(fileName); + // zipEntry.setSize(file.getSize()); + // zipEntry.setTime(System.currentTimeMillis()); + // + // // 将ZipEntry添加到压缩输出流中 + // zipOutputStream.putNextEntry(zipEntry); + // + // // 将文件内容写入到压缩输出流中 + // byte[] buffer = new byte[BUFFER_SIZE]; + // int len; + // try (InputStream inputStream = file.getInputStream()) { + // while ((len = inputStream.read(buffer)) > 0) { + // zipOutputStream.write(buffer, 0, len); + // } + // } + // zipOutputStream.closeEntry(); + // } + // + // // 刷新压缩输出流 + // zipOutputStream.flush(); + // } + // log.info("Finish downloading files: {}"+ids); + // } catch (Exception e) { + // log.error("下载附件异常: {}"+Util.getErrString(e)); + // // 如果出现异常,返回一个空的响应体 + // response.reset(); + // response.setContentType(MediaType.APPLICATION_OCTET_STREAM); + // response.setContentLength(0); + // } + //} + +} diff --git a/src/main/java/com/api/bokang/xiao/zscq/mapper/ReserveSelectMapper.java b/src/main/java/com/api/bokang/xiao/zscq/mapper/ReserveSelectMapper.java new file mode 100644 index 0000000..53d5086 --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/zscq/mapper/ReserveSelectMapper.java @@ -0,0 +1,55 @@ +package com.api.bokang.xiao.zscq.mapper; + +import aiyh.utils.annotation.recordset.*; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName ReserveSelectMapper + * @Author 肖博亢 + * @Date 2023/4/14 10:28 + * @Description

+ **/ +@SqlMapper +public interface ReserveSelectMapper { + + /** + *

从日志中去找最后一个操作者

+ * @param requestId 流程id + * @return 操作人信息 + */ + @Select("select operator userId,operatortype userType from workflow_requestlog where requestid=#{requestId}" + + " and (logtype='2' or logtype='0' or logtype='3' or logtype='e') " + + " and exists(select 1 from workflow_currentoperator where requestid=workflow_requestlog.requestid and userid=workflow_requestlog.operator and usertype=workflow_requestlog.operatortype and isremark='2' and preisremark='0' and operatedate is not null and operatedate>' ') " + + " group by operator,operatortype order by max(logid) desc") + Map queryRequestMsg(@ParamMapper("requestId")String requestId); + + /** + *

从日志中去找最后一个操作者

+ * @param requestId 流程id + * @return 操作人信息 + */ + @Select("select userid userId,usertype userType from workflow_currentoperator where requestid = #{requestId} and isremark = '2' and preisremark='0' and operatedate is not null and operatedate>' ' order by operatedate desc ,operatetime desc") + Map queryOperator(@ParamMapper("requestId")String requestId); + + /** + *

查询时间区域内的建模数据

+ * @param param 参数信息 + * @return 建模数据 + */ + @Select("select id, $t{applicationNoField}, $t{workflowInfoField}, $t{checkResultField} from $t{modeTableName} where $t{dateField} = #{datePicker}") + @CaseConversion(value = false) + List> queryModeList(Map param); + + /** + *

更新检查结果

+ * @param forceOverList 强制归档流程id集合 + * @param param 参数信息 + * @return 更新结果 + */ + @Update("update $t{param.modeTableName} set $t{param.checkResultField} = #{param.repossessedValue} " + + " where $t{param.workflowInfoField} in (${doRepossessedList})") + boolean updateRepossessed(@ParamMapper("doRepossessedList") List forceOverList, + @ParamMapper("param") Map param); +} diff --git a/src/main/java/com/api/bokang/xiao/zscq/service/ReserveService.java b/src/main/java/com/api/bokang/xiao/zscq/service/ReserveService.java new file mode 100644 index 0000000..37f0d30 --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/zscq/service/ReserveService.java @@ -0,0 +1,25 @@ +package com.api.bokang.xiao.zscq.service; + +import aiyh.utils.Util; +import org.apache.log4j.Logger; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName ReserveService + * @Author 肖博亢 + * @Date 2023/4/12 17:44 + * @Description

+ **/ +public interface ReserveService { + + Logger log = Util.getLogger(); + + /** + *

反选操作

+ * @param param 参数信息 + * @return 操作结果 + */ + List> reserveSelect(Map param); +} diff --git a/src/main/java/com/api/bokang/xiao/zscq/service/impl/ReserveServiceImpl.java b/src/main/java/com/api/bokang/xiao/zscq/service/impl/ReserveServiceImpl.java new file mode 100644 index 0000000..96d6ef1 --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/zscq/service/impl/ReserveServiceImpl.java @@ -0,0 +1,114 @@ +package com.api.bokang.xiao.zscq.service.impl; + +import aiyh.utils.Util; +import com.api.bokang.xiao.zscq.mapper.ReserveSelectMapper; +import com.api.bokang.xiao.zscq.service.ReserveService; +import weaver.hrm.User; +import weaver.workflow.workflow.RequestForceDrawBack; +import weaver.workflow.workflow.WfForceDrawBack; +import weaver.workflow.workflow.WfForceOver; +import weaver.workflow.workflow.WfFunctionManageUtil; + +import java.util.*; +import java.util.stream.Collectors; + + +/** + * @ClassName ReserveServiceImpl + * @Author 肖博亢 + * @Date 2023/4/14 10:11 + * @Description

+ **/ +public class ReserveServiceImpl implements ReserveService { + + private final ReserveSelectMapper reserveSelectMapper = Util.getMapper(ReserveSelectMapper.class); + + private final WfForceOver wfForceOver = new WfForceOver(); + + private final WfFunctionManageUtil wfFunctionManageUtil = new WfFunctionManageUtil(); + + private final WfForceDrawBack wfForceDrawBack = new WfForceDrawBack(); + private final RequestForceDrawBack requestForceDrawBack = new RequestForceDrawBack(); + + /** + *

流程强制收回 + * @param requestIdList 流程id集合 + * @param user 用户信息 + * @return 操作结果 + */ + private List> doRepossessed(List requestIdList, User user){ + return requestIdList.stream().map(item -> { + Map repossessedResult = new HashMap<>(); + boolean flag = doRepossessedSign(item, user); + repossessedResult.put(String.valueOf(item),flag); + return repossessedResult; + }).collect(Collectors.toList()); + } + + /** + *

流程强制收回 + * @param requestId 流程id + * @param user 用户信息 + * @return 操作结果 + */ + private boolean doRepossessedSign(int requestId,User user){ + //查询最后一个操作者 + Map operateInfo = reserveSelectMapper.queryRequestMsg(String.valueOf(requestId)); + log.info(" doRepossessedSign operateInfo ==>"+operateInfo); + if(Objects.isNull(operateInfo)){ + operateInfo = reserveSelectMapper.queryOperator(String.valueOf(requestId)); + } + int tempUser = operateInfo.get("userId"); + int tempUserType = operateInfo.get("userType"); + boolean canForceDrawBack = false; + if(RequestForceDrawBack.isOldRequest(requestId) == RequestForceDrawBack.OLDDATA){ + canForceDrawBack = wfForceDrawBack.isHavePurview(requestId, user.getUID(), Integer.parseInt(user.getLogintype()), tempUser, tempUserType); + }else{ + canForceDrawBack = RequestForceDrawBack.isHavePurview(user.getUID(), requestId, true); + } + if (canForceDrawBack && wfFunctionManageUtil.haveOtherOperationRight(requestId)) { + int result = requestForceDrawBack.foreceDrawBack(user, requestId, true, tempUser, tempUserType); + return requestForceDrawBack.isAddInOperateSuccess(); + }else{ + return false; + } + } + + /** + *

流程强制归档 + * @param requestIdList 流程id集合 + * @param user 用户信息 + */ + private void doForceOver(ArrayList requestIdList, User user){ + wfForceOver.doForceOver(requestIdList,user); + } + + @Override + public List> reserveSelect(Map param) { + List> result = new ArrayList<>(); + List> modeList = reserveSelectMapper.queryModeList(param); + String checkResultField = Util.null2String(param.get("checkResultField")); + String workflowInfoField = Util.null2String(param.get("workflowInfoField")); + String checkResultValue = Util.null2String(param.get("checkResultValue")); + if(Objects.nonNull(modeList) && !modeList.isEmpty()){ + ArrayList forceOverList = new ArrayList<>(); + List doRepossessedList = new ArrayList<>(); + for (Map modeInfo : modeList) { + String checkResult = Util.null2String(modeInfo.get(checkResultField)); + int requestId = Util.getIntValue(Util.null2String(modeInfo.get(workflowInfoField))); + if(checkResult.equals(checkResultValue)){ + forceOverList.add(requestId+""); + }else { + doRepossessedList.add(requestId); + } + } + log.info(String.format("doRepossessedList ==> %s forceOverList ==> %s",doRepossessedList,forceOverList)); + result = doRepossessed(doRepossessedList, new User(1)); + log.info("撤回处理结果 ==>"+result); + doForceOver(forceOverList,new User(1)); + boolean flag = reserveSelectMapper.updateRepossessed(forceOverList, param); + log.info("更新检查结果字段结果 ==>"+flag); + } + return result; + } +} diff --git a/src/main/java/com/api/bokang/xiao/zxyh/generate_code/controller/GenerateContractNoController.java b/src/main/java/com/api/bokang/xiao/zxyh/generate_code/controller/GenerateContractNoController.java new file mode 100644 index 0000000..0b1f2ab --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/zxyh/generate_code/controller/GenerateContractNoController.java @@ -0,0 +1,76 @@ +package com.api.bokang.xiao.zxyh.generate_code.controller; + +import aiyh.utils.ApiResult; +import aiyh.utils.Util; +import com.api.bokang.xiao.zxyh.generate_code.service.GenerateContractNoService; +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.POST; + +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.Map; + +/** + * @ClassName GenerateContractNo + * @Author 肖博亢 + * @Date 2023/3/23 15:26 + * @Description

+ **/ + +@Path("/xbk/zxyh_generate") +public class GenerateContractNoController { + + private final Logger log = Util.getLogger(); + + private final GenerateContractNoService generateContractNoService = new GenerateContractNoService(); + + /** + *

生成合同文件编码

+ * @param request 请求体 + * @param response 响应体 + * @return 请求结果 + */ + @Path("/generateCode") + @POST + @Produces(MediaType.APPLICATION_JSON) + public String generateCode(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map param) { + try{ + log.info("========= into generateCode success =========="); + log.info("param:"+param); + User loginUser = HrmUserVarify.getUser(request, response); + return ApiResult.success(generateContractNoService.generateCode(param)); + }catch (Exception e){ + log.error("generateCode error ==>"+Util.getErrString(e)); + return ApiResult.error(); + } + } + + /** + *

删除编码

+ * @param request 请求体 + * @param response 响应体 + * @return 请求结果 + */ + @Path("/deleteCode") + @POST + @Produces(MediaType.APPLICATION_JSON) + public String deleteCode(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map param) { + try{ + log.info("========= into deleteCode success =========="); + log.info("param:"+param); + User loginUser = HrmUserVarify.getUser(request, response); + return ApiResult.success(generateContractNoService.deleteContractCode(param)); + }catch (Exception e){ + log.error("generateCode error ==>"+Util.getErrString(e)); + return ApiResult.error(); + } + } +} diff --git a/src/main/java/com/api/bokang/xiao/zxyh/generate_code/mapper/GenerateMapper.java b/src/main/java/com/api/bokang/xiao/zxyh/generate_code/mapper/GenerateMapper.java new file mode 100644 index 0000000..30c312f --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/zxyh/generate_code/mapper/GenerateMapper.java @@ -0,0 +1,44 @@ +package com.api.bokang.xiao.zxyh.generate_code.mapper; + +import aiyh.utils.annotation.recordset.Delete; +import aiyh.utils.annotation.recordset.Select; +import aiyh.utils.annotation.recordset.SqlMapper; +import aiyh.utils.annotation.recordset.Update; + +import java.util.Map; + +/** + * @ClassName GenerateMapper + * @Author 肖博亢 + * @Date 2023/3/23 15:38 + * @Description

+ **/ + +@SqlMapper +public interface GenerateMapper { + + /** + *

更新合同文件编号信息

+ * @param param 参数信息 + * @return 更新结果 + */ + @Update("update uf_contract_num_log set workflow_info = #{workflowInfo},file_info = #{fileInfo},detail_id = #{detailId}," + + "row_id = #{rowId},contract_name = #{contractName},contract_num = #{contractNum},flow_num = #{flowNum} where id = #{dataId}") + boolean updateContractLog(Map param); + + /** + *

查询最大的流水号

+ * @return 最大的流水号 + */ + @Select("select max(flow_num) from uf_contract_num_log") + int getMaxFlow(); + + /** + *

删除编号信息

+ * @param param 参数信息 + * @return 删除结果 + */ + @Delete("delete from uf_contract_num_log where workflow_info = #{workflowInfo} and file_info = #{fileInfo} and detail_id = #{detailId} " + + " and row_id = #{rowId} and contract_num = #{contractNum} ") + boolean deleteContractFileCode(Map param); +} diff --git a/src/main/java/com/api/bokang/xiao/zxyh/generate_code/service/GenerateContractNoService.java b/src/main/java/com/api/bokang/xiao/zxyh/generate_code/service/GenerateContractNoService.java new file mode 100644 index 0000000..f9dc06d --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/zxyh/generate_code/service/GenerateContractNoService.java @@ -0,0 +1,67 @@ +package com.api.bokang.xiao.zxyh.generate_code.service; + +import aiyh.utils.Util; +import com.api.bokang.xiao.zxyh.generate_code.mapper.GenerateMapper; +import org.apache.log4j.Logger; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Map; + +/** + * @ClassName GenerateContractNoService + * @Author 肖博亢 + * @Date 2023/3/23 15:52 + * @Description

+ **/ +public class GenerateContractNoService { + + private final GenerateMapper generateMapper = Util.getMapper(GenerateMapper.class); + + private final Logger log = Util.getLogger(); + + private final static String FORMAT_STRING = "yyyyMM"; + + private final static String DEFAULT_STR = "YYHT"; + + private final static String TABLE_NAME = "uf_contract_num_log"; + + private final static Integer FLOW_LENGTH = 3; + + public String generateCode(Map param){ + int maxFlow = generateMapper.getMaxFlow(); + maxFlow = Math.max(maxFlow,0); + maxFlow++; + String contractNo = ""; + String formatDate = this.getFormatDate(new Date(), FORMAT_STRING); + StringBuilder flowStr = new StringBuilder(maxFlow + ""); + //长度不足补0 + if(flowStr.length() < FLOW_LENGTH){ + for (int i = flowStr.length(); i < FLOW_LENGTH; i++) { + flowStr.insert(0, "0"); + } + } + contractNo = DEFAULT_STR + formatDate + flowStr; + log.info(" contractFileNo ==>"+contractNo); + int dataId = Util.getModeDataId(TABLE_NAME, 1); + param.put("dataId",dataId); + param.put("contractNum",contractNo); + param.put("flowNum",maxFlow); + boolean updateFlag = generateMapper.updateContractLog(param); + Util.rebuildModeDataShareByAsync(1,TABLE_NAME,dataId); + if(updateFlag){ + return contractNo; + } + return ""; + } + + public boolean deleteContractCode(Map param){ + return generateMapper.deleteContractFileCode(param); + } + + private String getFormatDate(Date date, String formatString){ + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(formatString); + return simpleDateFormat.format(date); + } + +} diff --git a/src/main/java/com/api/bokang/xiao/zxyh/remind/controller/RemindController.java b/src/main/java/com/api/bokang/xiao/zxyh/remind/controller/RemindController.java new file mode 100644 index 0000000..1392d16 --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/zxyh/remind/controller/RemindController.java @@ -0,0 +1,55 @@ +package com.api.bokang.xiao.zxyh.remind.controller; + +import aiyh.utils.ApiResult; +import aiyh.utils.Util; +import com.api.bokang.xiao.zxyh.remind.service.RemindService; +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.POST; +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.List; +import java.util.Map; + +/** + * @ClassName RemindController + * @Author 肖博亢 + * @Date 2023/4/18 9:59 + * @Description

+ **/ +@Path("/xbk/remind") +public class RemindController { + + private final Logger log = Util.getLogger(); + + private final RemindService remindService = new RemindService(); + + /** + *

生成合同文件编码

+ * @param request 请求体 + * @param response 响应体 + * @return 请求结果 + */ + @Path("/getRemindList") + @POST + @Produces(MediaType.APPLICATION_JSON) + public String getRemindList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map param) { + try{ + log.info("========= into getRemindList success =========="); + log.info("param:"+param); + User loginUser = HrmUserVarify.getUser(request, response); + List> remindList = remindService.getRemindList(param,loginUser); + return ApiResult.success(remindList); + }catch (Exception e){ + log.error("getRemindList error ==>"+Util.getErrString(e)); + return ApiResult.error(); + } + } +} diff --git a/src/main/java/com/api/bokang/xiao/zxyh/remind/mapper/RemindMapper.java b/src/main/java/com/api/bokang/xiao/zxyh/remind/mapper/RemindMapper.java new file mode 100644 index 0000000..263cb63 --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/zxyh/remind/mapper/RemindMapper.java @@ -0,0 +1,32 @@ +package com.api.bokang.xiao.zxyh.remind.mapper; + +import aiyh.utils.annotation.recordset.Select; +import aiyh.utils.annotation.recordset.SqlMapper; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName RemindMapper + * @Author 肖博亢 + * @Date 2023/4/18 9:59 + * @Description

+ **/ +@SqlMapper +public interface RemindMapper { + + /** + *

查询超时提醒的流程集合

+ * @param param 条件参数 + * @return 超时提醒集合 + */ + @Select("select distinct wr.REQUESTID as requestId, " + + " wr.REQUESTNAME, " + + " wr.requestnamenew as requestName, " + + " wc.RECEIVEDATE as receiveDate, " + + " datediff(now(),wc.RECEIVEDATE) as overDays " + + "from workflow_requestbase wr " + + "inner join workflow_currentoperator wc on wr.REQUESTID = wc.REQUESTID and wr.CURRENTNODEID = wc.NODEID " + + "where wr.WORKFLOWID in ($t{workflowIds}) and wc.NODEID in ($t{nodeIds}) and wr.CREATER = #{userId} and datediff(now(),wc.RECEIVEDATE) > #{dayLimit}") + List> queryRemindList(Map param); +} diff --git a/src/main/java/com/api/bokang/xiao/zxyh/remind/service/RemindService.java b/src/main/java/com/api/bokang/xiao/zxyh/remind/service/RemindService.java new file mode 100644 index 0000000..692e2b4 --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/zxyh/remind/service/RemindService.java @@ -0,0 +1,27 @@ +package com.api.bokang.xiao.zxyh.remind.service; + +import aiyh.utils.Util; +import com.api.bokang.xiao.zxyh.remind.mapper.RemindMapper; +import org.apache.log4j.Logger; +import weaver.hrm.User; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName RemindService + * @Author 肖博亢 + * @Date 2023/4/18 9:59 + * @Description

+ **/ +public class RemindService { + + private final Logger log = Util.getLogger(); + + private final RemindMapper remindMapper = Util.getMapper(RemindMapper.class); + + public List> getRemindList(Map param, User loginUser) { + param.put("userId",loginUser.getUID()); + return remindMapper.queryRemindList(param); + } +} diff --git a/src/main/java/weaver/bokang/xiao/common/mapper/HrmMapper.java b/src/main/java/weaver/bokang/xiao/common/mapper/HrmMapper.java new file mode 100644 index 0000000..25617c5 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/common/mapper/HrmMapper.java @@ -0,0 +1,25 @@ +package weaver.bokang.xiao.common.mapper; + +import aiyh.utils.annotation.recordset.ParamMapper; +import aiyh.utils.annotation.recordset.Select; +import aiyh.utils.annotation.recordset.SqlMapper; + +import java.util.Map; + +/** + * @ClassName HrmMapper + * @Author 肖博亢 + * @Date 2023/4/3 20:21 + * @Description

+ **/ +@SqlMapper +public interface HrmMapper { + + /** + *

通过部门id查询部门信息

+ * @param departId 部门id + * @return 部门信息 + */ + @Select("select * from hrmDepartment where id = #{departId}") + Map getDepartInfoById(@ParamMapper("departId")int departId); +} diff --git a/src/main/java/weaver/bokang/xiao/common/mapper/ModeMapper.java b/src/main/java/weaver/bokang/xiao/common/mapper/ModeMapper.java new file mode 100644 index 0000000..e0c6025 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/common/mapper/ModeMapper.java @@ -0,0 +1,35 @@ +package weaver.bokang.xiao.common.mapper; + +import aiyh.utils.annotation.recordset.ParamMapper; +import aiyh.utils.annotation.recordset.Select; +import aiyh.utils.annotation.recordset.SqlMapper; + +import java.util.Map; + +/** + * @ClassName ModeMapper + * @Author 肖博亢 + * @Date 2023/4/3 17:44 + * @Description

+ **/ +@SqlMapper +public interface ModeMapper { + + /** + *

查询建模数据信息

+ * @param tableName 建模表名 + * @param param 条件参数 + * @return 建模数据 + */ + @Select("select * from $t{tableName} where $t{param.fieldName} = #{param.fieldValue}") + Map queryModeDataInfo(@ParamMapper("tableName") String tableName, + @ParamMapper("param") Map param); + + /** + *

通过formId查询建模表名

+ * @param formId 表id + * @return 建模数据 + */ + @Select("select tablename from workflow_bill where id = #{formId}") + String queryTableName(@ParamMapper("tableName") String formId); +} diff --git a/src/main/java/weaver/bokang/xiao/deg_repeat_check/action/RepeatCheckAction.java b/src/main/java/weaver/bokang/xiao/deg_repeat_check/action/RepeatCheckAction.java new file mode 100644 index 0000000..d0de9a7 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/deg_repeat_check/action/RepeatCheckAction.java @@ -0,0 +1,56 @@ +package weaver.bokang.xiao.deg_repeat_check.action; + +import aiyh.utils.Util; +import aiyh.utils.action.SafeCusBaseAction; +import aiyh.utils.annotation.ActionDesc; +import aiyh.utils.annotation.ActionOptionalParam; +import aiyh.utils.annotation.PrintParamMark; +import aiyh.utils.excention.CustomerException; +import lombok.Setter; +import weaver.bokang.xiao.deg_repeat_check.mapper.RepeatCheckMapper; +import weaver.hrm.User; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.Map; + +/** + * @ClassName RepeatCheckAction + * @Author 肖博亢 + * @Date 2023/3/31 15:19 + * @Description

+ **/ +@ActionDesc(value = "流程编号重复校验",author = "bokang.xiao") +@Setter +public class RepeatCheckAction extends SafeCusBaseAction { + + @ActionOptionalParam(value = "bh",desc = "流程编号字段") + @PrintParamMark + private String workflowNumField = "bh"; + + @ActionOptionalParam(value = "bh",desc = "建模编号字段") + @PrintParamMark + private String modeNumField = "bh"; + + @ActionOptionalParam(value = "uf_xszktz",desc = "建模表名") + @PrintParamMark + private String modeTableName = "uf_xszktz"; + + @ActionOptionalParam(value = "编号重复,不允许提交",desc = "建模表名") + @PrintParamMark + private String errorMsg = "编号重复,不允许提交"; + + private final RepeatCheckMapper repeatCheckMapper = Util.getMapper(RepeatCheckMapper.class); + + @Override + public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) { + log.info(String.format("=================== {%s} {requestId : %s} begin ======================", this.getClass().getName(),requestId)); + Map mainTable = this.getMainTableValue(requestInfo); + String workflowNum = Util.null2String(mainTable.get(workflowNumField)); + int workflowCount = repeatCheckMapper.getWorkflowCount(billTable,workflowNumField,requestId, workflowNum); + int modeCount = repeatCheckMapper.getModeCount(modeTableName,modeNumField,workflowNum); + log.info(String.format("workflowCount:[%s] workflowNum:[%s] modeCount:[%s]",workflowCount,workflowNum,modeCount)); + if(workflowCount > 0 || modeCount > 0){ + throw new CustomerException(errorMsg); + } + } +} diff --git a/src/main/java/weaver/bokang/xiao/deg_repeat_check/mapper/RepeatCheckMapper.java b/src/main/java/weaver/bokang/xiao/deg_repeat_check/mapper/RepeatCheckMapper.java new file mode 100644 index 0000000..0b5203d --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/deg_repeat_check/mapper/RepeatCheckMapper.java @@ -0,0 +1,48 @@ +package weaver.bokang.xiao.deg_repeat_check.mapper; + +import aiyh.utils.annotation.recordset.ParamMapper; +import aiyh.utils.annotation.recordset.Select; +import aiyh.utils.annotation.recordset.SqlMapper; + + +/** + * @ClassName RepeatCheckMapper + * @Author 肖博亢 + * @Date 2023/3/31 15:23 + * @Description

+ **/ +@SqlMapper +public interface RepeatCheckMapper { + + /** + *

获取相同编号流程数

+ * @param tableName 流程表名 + * @param fieldName 编号字段名 + * @param requestId requestId + * @param number 编号 + * @return 流程数 + */ + @Select("select count(1) " + + "from $t{tableName} main " + + " inner join workflow_currentoperator wco on main.REQUESTID = wco.REQUESTID " + + " inner join workflow_nodebase wnb on wco.NODEID = wnb.id " + + "where $t{fieldName} = #{number} and main.REQUESTID <> #{requestId} and wnb.ISSTART <> 1") + int getWorkflowCount(@ParamMapper("tableName")String tableName, + @ParamMapper("fieldName")String fieldName, + @ParamMapper("requestId")String requestId, + @ParamMapper("number")String number); + + /** + *

获取相同编号建模数

+ * @param tableName 流程表名 + * @param fieldName 编号字段名 + * @param number 编号 + * @return 台账数 + */ + @Select("select count(1) " + + "from $t{tableName} main where main.bh = #{number}") + int getModeCount(@ParamMapper("tableName")String tableName, + @ParamMapper("fieldName")String fieldName, + @ParamMapper("number")String number); + +} diff --git a/src/main/java/weaver/bokang/xiao/xhny_mode/entity/SqlConditionDtEntity.java b/src/main/java/weaver/bokang/xiao/xhny_mode/entity/SqlConditionDtEntity.java new file mode 100644 index 0000000..db4d871 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/xhny_mode/entity/SqlConditionDtEntity.java @@ -0,0 +1,22 @@ +package weaver.bokang.xiao.xhny_mode.entity; + +import lombok.Data; + +/** + * @ClassName SqlConditionDtEntity + * @Author 肖博亢 + * @Date 2023/4/9 13:15 + * @Description

+ **/ +@Data +public class SqlConditionDtEntity { + + /** 数据库字段名 */ + private String fieldName; + + /** 条件类型 */ + private Integer cusCondition; + + /** 文本框 */ + private String cusText; +} diff --git a/src/main/java/weaver/bokang/xiao/xhny_mode/entity/SqlConditionEntity.java b/src/main/java/weaver/bokang/xiao/xhny_mode/entity/SqlConditionEntity.java new file mode 100644 index 0000000..0d4df8c --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/xhny_mode/entity/SqlConditionEntity.java @@ -0,0 +1,29 @@ +package weaver.bokang.xiao.xhny_mode.entity; + +import lombok.Data; + + +import java.util.List; + +/** + * @ClassName SqlConditonEntity + * @Author 肖博亢 + * @Date 2023/4/9 13:15 + * @Description

+ **/ +@Data +public class SqlConditionEntity { + + /** 选择查询 */ + private String selectInfo; + + /** 唯一标识 */ + private String uniqueCode; + + /** 说明 */ + private String description; + + /** 配置明细 */ + private List sqlConditionDtEntityList; + +} diff --git a/src/main/java/weaver/bokang/xiao/xhny_mode/mapper/SearchMapper.java b/src/main/java/weaver/bokang/xiao/xhny_mode/mapper/SearchMapper.java new file mode 100644 index 0000000..1f5b603 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/xhny_mode/mapper/SearchMapper.java @@ -0,0 +1,58 @@ +package weaver.bokang.xiao.xhny_mode.mapper; + +import aiyh.utils.annotation.recordset.*; +import weaver.bokang.xiao.xhny_mode.entity.SqlConditionDtEntity; +import weaver.bokang.xiao.xhny_mode.entity.SqlConditionEntity; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName SearchMapper + * @Author 肖博亢 + * @Date 2023/4/3 21:33 + * @Description

+ **/ +@SqlMapper +public interface SearchMapper { + + /** + *

通过用户id获取部门编码

+ * @param userId 用户id + * @return 部门编码 + */ + @Select("select departmentcode from HrmDepartment where departmentmark = ("+ + " select lastname from hrmresource where id = #{userId})") + String getDepartCode(@ParamMapper("userId")int userId); + + /** + *

查询sql条件配置信息

+ * @param customId 查询id + * @return 配置信息 + */ + @Select("select * from uf_sql_config where select_info = #{customId}") + @CollectionMappings({ + @CollectionMapping(column = "id",property = "sqlConditionDtEntityList",id = @Id(value = Integer.class,methodId = 1)) + }) + SqlConditionEntity querySqlCondition(@ParamMapper("customId")String customId); + + /** + *

查询明细配置

+ * @param mainId 主数据id + * @return 明细列表 + */ + @CollectionMethod(1) + @Select("select * from uf_sql_config_dt1 where mainid = #{mainId}") + List querySqlConditionDt(@ParamMapper("mainId")int mainId); + + /** + *

执行自定义查询sql

+ * @param cusSql 自定义sql + * @param param 参数信息 + * @param cusParam 参数信息 + * @return 查询结果 + */ + @Select(custom = true) + String executeCusSql(@SqlString String cusSql, @ParamMapper("user") Map param, @ParamMapper("cusParam")Map cusParam); + +} diff --git a/src/main/java/weaver/bokang/xiao/xhny_mode/search/CustomSearchDepart.java b/src/main/java/weaver/bokang/xiao/xhny_mode/search/CustomSearchDepart.java new file mode 100644 index 0000000..69ce570 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/xhny_mode/search/CustomSearchDepart.java @@ -0,0 +1,49 @@ +package weaver.bokang.xiao.xhny_mode.search; + +import java.util.*; + +import aiyh.utils.Util; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import weaver.bokang.xiao.common.mapper.HrmMapper; +import weaver.bokang.xiao.xhny_mode.entity.SqlConditionDtEntity; +import weaver.bokang.xiao.xhny_mode.entity.SqlConditionEntity; +import weaver.bokang.xiao.xhny_mode.mapper.SearchMapper; +import weaver.bokang.xiao.xhny_mode.service.SqlConditionGenerate; +import weaver.hrm.User; +import weaver.formmode.customjavacode.AbstractCustomSqlConditionJavaCode; + +/** + * 说明 + * 修改时 + * 类名要与文件名保持一致 + * class文件存放位置与路径保持一致。 + * 请把编译后的class文件,放在对应的目录中才能生效 + * 注意 同一路径下java名不能相同。 + * @author Administrator + * + */ +public class CustomSearchDepart extends AbstractCustomSqlConditionJavaCode { + + private final Logger logger = Util.getLogger(); + + private final SqlConditionGenerate sqlConditionGenerate = new SqlConditionGenerate(); + + /** + * 生成SQL查询限制条件 + * @param param + * param包含(但不限于)以下数据 + * user 当前用户 + * + * @return + * 返回的查询限制条件的格式举例为: t1.a = '1' and t1.b = '3' and t1.c like '%22%' + * 其中t1为表单主表表名的别名 + */ + public String generateSqlCondition(Map param) throws Exception { + logger.info(String.format("search before Param ==> %s", param)); + return sqlConditionGenerate.getSqlCondition(param); + } + + + +} diff --git a/src/main/java/weaver/bokang/xiao/xhny_mode/service/CusFunction.java b/src/main/java/weaver/bokang/xiao/xhny_mode/service/CusFunction.java new file mode 100644 index 0000000..9e0af0d --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/xhny_mode/service/CusFunction.java @@ -0,0 +1,19 @@ +package weaver.bokang.xiao.xhny_mode.service; + +/** + * @ClassName CusFunction + * @Author 肖博亢 + * @Date 2023/4/9 14:42 + * @Description

+ **/ +public interface CusFunction { + + /** + *

条件处理

+ * @param p 参数 + * @param q 参数 + * @param k 参数 + * @return 返回值 + */ + R apply(P p,Q q,K k); +} diff --git a/src/main/java/weaver/bokang/xiao/xhny_mode/service/SqlConditionGenerate.java b/src/main/java/weaver/bokang/xiao/xhny_mode/service/SqlConditionGenerate.java new file mode 100644 index 0000000..56c575f --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/xhny_mode/service/SqlConditionGenerate.java @@ -0,0 +1,124 @@ +package weaver.bokang.xiao.xhny_mode.service; + +import aiyh.utils.Util; +import aiyh.utils.annotation.MethodRuleNo; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import weaver.bokang.xiao.xhny_mode.entity.SqlConditionDtEntity; +import weaver.bokang.xiao.xhny_mode.entity.SqlConditionEntity; +import weaver.bokang.xiao.xhny_mode.mapper.SearchMapper; +import weaver.hrm.User; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * @ClassName SqlConditonGenerate + * @Author 肖博亢 + * @Date 2023/4/9 13:35 + * @Description

+ **/ +public class SqlConditionGenerate { + + public final Map, String>> METHOD_MAP = new HashMap<>(); + + private final SearchMapper searchMapper = Util.getMapper(SearchMapper.class); + + private final Logger logger = Util.getLogger(); + + { + try { + Class sqlConditionGenerate = SqlConditionGenerate.class; + Method[] methods = sqlConditionGenerate.getDeclaredMethods(); + for (Method method : methods) { + if (method.isAnnotationPresent(MethodRuleNo.class)) { + MethodRuleNo annotation = method.getAnnotation(MethodRuleNo.class); + int value = annotation.value(); + METHOD_MAP.put(value, (sqlConditionDtEntity,userInfo, sqlCondition) -> { + try { + return (String) method.invoke(this,sqlConditionDtEntity,userInfo,sqlCondition); + } catch (IllegalAccessException | InvocationTargetException e) { + throw new RuntimeException(e); + } + }); + } + } + }catch (Exception exception){ + logger.error("SqlConditionGenerate init error !!! "+Util.getErrString(exception)); + } + } + + /** + *

生成sql条件

+ * @param param 参数信息 + * @return sql + */ + public String getSqlCondition(Map param){ + String sqlCondition = ""; + try { + User user = (User) param.get("user"); + String customId = Util.null2String(param.get("customid")); + logger.info("userId ==>" + user.getUID() + " customId==>" + customId); + SqlConditionEntity sqlConditionEntity = searchMapper.querySqlCondition(customId); + Map userInfo = new HashMap<>(8); + userInfo.put("userId",user.getUID()); + userInfo.put("departmentId",user.getUserDepartment()); + userInfo.put("subCompanyId",user.getUserSubCompany1()); + userInfo.put("loginId",user.getLoginid()); + if(Objects.nonNull(sqlConditionEntity)){ + List sqlConditionDtEntityList = sqlConditionEntity.getSqlConditionDtEntityList(); + if(!sqlConditionDtEntityList.isEmpty()){ + for (SqlConditionDtEntity sqlConditionDtEntity : sqlConditionDtEntityList) { + CusFunction, String> conditionFunction = this.METHOD_MAP.get(sqlConditionDtEntity.getCusCondition()); + if(Objects.nonNull(conditionFunction)){ + sqlCondition = conditionFunction.apply(sqlConditionDtEntity,userInfo,sqlCondition); + } + } + } + if(StringUtils.isNotBlank(sqlCondition)){ + sqlCondition = sqlCondition.replaceFirst(" and "," "); + } + } + }catch (Exception e){ + logger.error("生成sql条件异常 ==>"+Util.getErrString(e)); + } + logger.info(String.format("sqlCondition ==> %s",sqlCondition)); + return sqlCondition; + } + + @MethodRuleNo(value = 0,desc = "默认值") + public String defaultValue(SqlConditionDtEntity sqlConditionDtEntity,Map userInfo,String sqlCondition){ + String fieldName = sqlConditionDtEntity.getFieldName(); + String cusText = sqlConditionDtEntity.getCusText(); + cusText = Util.sbc2dbcCase(cusText); + sqlCondition += " and t1." + fieldName + " = " + cusText; + return sqlCondition; + } + + @MethodRuleNo(value = 1,desc = "用户信息") + public String userInfo(SqlConditionDtEntity sqlConditionDtEntity,Map userInfo,String sqlCondition){ + String fieldName = sqlConditionDtEntity.getFieldName(); + String cusText = sqlConditionDtEntity.getCusText(); + cusText = Util.sbc2dbcCase(cusText); + sqlCondition += " and t1." + fieldName + " = " + userInfo.get(cusText); + return sqlCondition; + } + + @MethodRuleNo(value = 2,desc = "自定义sql") + public String cusSql(SqlConditionDtEntity sqlConditionDtEntity,Map userInfo,String sqlCondition){ + String fieldName = sqlConditionDtEntity.getFieldName(); + String cusText = sqlConditionDtEntity.getCusText(); + cusText = Util.sbc2dbcCase(cusText); + if(StringUtils.isBlank(fieldName)) { + sqlCondition += cusText; + }else { + String value = searchMapper.executeCusSql(cusText, userInfo, new HashMap<>(8)); + sqlCondition += " and t1." + fieldName + " = " + value; + } + return sqlCondition; + } +} diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/entity/pojo/QuotaData.java b/src/main/java/weaver/bokang/xiao/xhny_report/entity/pojo/QuotaData.java index 1cab43c..4d3782d 100644 --- a/src/main/java/weaver/bokang/xiao/xhny_report/entity/pojo/QuotaData.java +++ b/src/main/java/weaver/bokang/xiao/xhny_report/entity/pojo/QuotaData.java @@ -4,6 +4,7 @@ import aiyh.utils.annotation.recordset.SqlDbFieldAnn; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; +import lombok.ToString; import java.util.Objects; @@ -15,6 +16,7 @@ import java.util.Objects; **/ @Getter @Setter +@ToString @NoArgsConstructor public class QuotaData { diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/entity/pojo/VendorMarkReportDt.java b/src/main/java/weaver/bokang/xiao/xhny_report/entity/pojo/VendorMarkReportDt.java index 4cd72da..f5e19be 100644 --- a/src/main/java/weaver/bokang/xiao/xhny_report/entity/pojo/VendorMarkReportDt.java +++ b/src/main/java/weaver/bokang/xiao/xhny_report/entity/pojo/VendorMarkReportDt.java @@ -33,6 +33,10 @@ public class VendorMarkReportDt { @SqlDbFieldAnn("ms") private String desc; + /** 描述 */ + @SqlDbFieldAnn("mxx") + private String detailDesc; + /** 权重 */ @SqlDbFieldAnn("qz") private Double weight; diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/mapper/VendorReportMapper.java b/src/main/java/weaver/bokang/xiao/xhny_report/mapper/VendorReportMapper.java index 7b08df1..fc8cf46 100644 --- a/src/main/java/weaver/bokang/xiao/xhny_report/mapper/VendorReportMapper.java +++ b/src/main/java/weaver/bokang/xiao/xhny_report/mapper/VendorReportMapper.java @@ -35,8 +35,8 @@ public interface VendorReportMapper { * @param vendorMarkReportDtList 报表明细数据 * @return 插入结果 */ - @BatchInsert("insert into uf_vendorMarkReport_dt1 (xm,ms,qz,sjdf,mainid) " + - "values(#{item.project},#{item.desc},#{item.weight},#{item.score},#{mainId})") + @BatchInsert("insert into uf_vendorMarkReport_dt1 (xm,ms,qz,sjdf,mxx,mainid) " + + "values(#{item.project},#{item.desc},#{item.weight},#{item.score},#{item.detailDesc},#{mainId})") boolean insertReportDt(@BatchSqlArgs List vendorMarkReportDtList,@ParamMapper("mainId") int mainId); /** diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/schedule/GenerateReportSchedule.java b/src/main/java/weaver/bokang/xiao/xhny_report/schedule/GenerateReportSchedule.java index e1c4ba3..ecec69c 100644 --- a/src/main/java/weaver/bokang/xiao/xhny_report/schedule/GenerateReportSchedule.java +++ b/src/main/java/weaver/bokang/xiao/xhny_report/schedule/GenerateReportSchedule.java @@ -60,10 +60,22 @@ public class GenerateReportSchedule extends CusBaseCronJob { return; } log.info("询价单信息 sourceTrackingDataList ==>"+ JSON.toJSONString(sourceTrackingDataList)); + //生成报表数据 + doGenerateReport(sourceTrackingDataList,scoreChain); + } + + /** + *

生成报表数据

+ * @param sourceTrackingDataList 询报价数据 + * @param scoreChain 评分处理链 + */ + private void doGenerateReport(List sourceTrackingDataList,AbstractScoreChain scoreChain){ for (SourceTrackingData sourceTrackingData : sourceTrackingDataList) { List sourceVendorList = sourceTrackingData.getSourceVendorList(); + //待评分供应商数据初始化 List vendorMarkReportList = sourceVendorList.stream().map(item -> VendorMarkReport.builder() .supplier(item.getVendorId()) + .supplierCode(item.getVendorCode()) .evaluationStartDate(sourceTrackingData.getQuotaBeginDate()) .evaluationEndDate(sourceTrackingData.getQuotaEndDate()) .sourceTrackingCode(sourceTrackingData.getSourceTrackingCode()) diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/service/ScoreChainPattern.java b/src/main/java/weaver/bokang/xiao/xhny_report/service/ScoreChainPattern.java index 0f9f7d6..6b000a0 100644 --- a/src/main/java/weaver/bokang/xiao/xhny_report/service/ScoreChainPattern.java +++ b/src/main/java/weaver/bokang/xiao/xhny_report/service/ScoreChainPattern.java @@ -43,6 +43,10 @@ public class ScoreChainPattern { SCORE_CHAIN_MAP.put(11,new SortingServiceChain()); } + /** + *

获取评分处理链路

+ * @return 处理链 + */ public static AbstractScoreChain getScoreChain(){ List configEntities = VENDOR_MAPPER.queryVendorConfig(); if(configEntities.isEmpty()){ diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/AbstractScoreChain.java b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/AbstractScoreChain.java index 9560057..3bbc45c 100644 --- a/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/AbstractScoreChain.java +++ b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/AbstractScoreChain.java @@ -9,7 +9,6 @@ import weaver.bokang.xiao.xhny_report.service.store.VendorStore; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.stream.Collectors; /** diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/ArrivalRateChain.java b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/ArrivalRateChain.java index 8c10821..9a36d58 100644 --- a/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/ArrivalRateChain.java +++ b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/ArrivalRateChain.java @@ -4,6 +4,7 @@ import aiyh.utils.Util; import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData; import weaver.bokang.xiao.xhny_report.entity.pojo.*; import weaver.bokang.xiao.xhny_report.service.util.VendorUtil; +import weaver.conn.RecordSetDataSource; import weaver.general.StaticObj; import weaver.interfaces.datasource.DataSource; @@ -29,9 +30,11 @@ public class ArrivalRateChain extends AbstractScoreChain{ @Override public void handle(List vendorMarkReportList, SourceTrackingData sourceTrackingData) { //具体评分逻辑 + logger.info(" DeliveryCycleChain deal 到货率评分 "); Map configEntityMap = this.configEntityMap; for (VendorMarkReport vendorMarkReport : vendorMarkReportList) { double arrivalRate = this.getArrivalRateByCall(vendorMarkReport.getSupplierCode(), sourceTrackingData.getQuotaBeginDate(), sourceTrackingData.getQuotaEndDate()); + logger.info(String.format("调用存储过程获取到货率 [供应商:%s,到货率:%s]",vendorMarkReport.getSupplierCode(),arrivalRate)); int scoreId = 0; if(arrivalRate >= 1){ //到货率100% @@ -82,6 +85,13 @@ public class ArrivalRateChain extends AbstractScoreChain{ } } catch (Exception e) { logger.error("远程调用存储过程失败 ==>"+ Util.getErrString(e)); + }finally { + try{ + assert conn != null; + conn.close(); + }catch (Exception e){ + logger.error("关闭连接异常 ==>"+Util.getErrString(e)); + } } return arrivalRate; } diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/BadCountChain.java b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/BadCountChain.java index 852820e..fd56529 100644 --- a/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/BadCountChain.java +++ b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/BadCountChain.java @@ -23,6 +23,7 @@ public class BadCountChain extends AbstractScoreChain{ @Override public void handle(List vendorMarkReportList, SourceTrackingData sourceTrackingData) { //具体评分逻辑 + logger.info(" BadCountChain deal 不良品数评分 "); for (VendorMarkReport vendorMarkReport : vendorMarkReportList) { Map queryParam = new HashMap<>(); queryParam.put("beginDate",sourceTrackingData.getQuotaBeginDate()); diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/MoneyAmountChain.java b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/MoneyAmountChain.java index bf3c5ed..0b8b689 100644 --- a/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/MoneyAmountChain.java +++ b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/MoneyAmountChain.java @@ -1,5 +1,6 @@ package weaver.bokang.xiao.xhny_report.service.chain; +import com.alibaba.fastjson.JSON; import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData; import weaver.bokang.xiao.xhny_report.entity.pojo.*; import weaver.bokang.xiao.xhny_report.service.util.VendorUtil; @@ -37,16 +38,18 @@ public class MoneyAmountChain extends AbstractScoreChain{ } //求出每个供应商都报价的物料(求交集) List retainQuotaList = VendorUtil.retainElementList(sourceList); + logger.info(String.format("交集数据 ==> %s", JSON.toJSONString(retainQuotaList))); if(!retainQuotaList.isEmpty()){ - //统计报价总和 + //统计交集部分物料报价总和 Map quotaScoreMap = vendorQuotaMap.entrySet().stream() .collect(Collectors.toMap( Map.Entry::getKey, v -> v.getValue().stream().filter(retainQuotaList::contains).mapToDouble(QuotaData::getQuotaValue).sum()) ); + logger.info("统计交集部分物料报价总和 ==>"+quotaScoreMap); //统计报价最小值 Optional> min = quotaScoreMap.entrySet().stream().min(Map.Entry.comparingByValue()); - + logger.info("报价最低值 ==>"+min); if(min.isPresent()){ double minValue = min.get().getValue(); for (VendorMarkReport vendorMarkReport : vendorMarkReportList) { diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/QuotationNumberChain.java b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/QuotationNumberChain.java index 17b27c9..ff13ea1 100644 --- a/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/QuotationNumberChain.java +++ b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/QuotationNumberChain.java @@ -1,5 +1,6 @@ package weaver.bokang.xiao.xhny_report.service.chain; +import com.alibaba.fastjson.JSON; import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData; import weaver.bokang.xiao.xhny_report.entity.pojo.ConfigEntity; import weaver.bokang.xiao.xhny_report.entity.pojo.QuotaData; @@ -41,18 +42,26 @@ public class QuotationNumberChain extends AbstractScoreChain{ } //求出每个供应商都报价的物料(求交集) List retainQuotaList = VendorUtil.retainElementList(sourceList); + logger.info(String.format("交集数据 ==> %s", JSON.toJSONString(retainQuotaList))); if(!retainQuotaList.isEmpty()) { - //过滤出交集部分的物料报价 - Map> materialQuotaMap = quotaDataList.stream() - .filter(retainQuotaList::contains) - .collect(Collectors.groupingBy(QuotaData::getMaterialId)); - //统计每个物料报价的最低值 - Map materialMinMap = materialQuotaMap.entrySet().stream().collect(Collectors.toMap( + + //统计交集部分每个物料报价的最低值 + Map materialMinMap = quotaDataList.stream() + //过滤出交集部分 + .filter(retainQuotaList::contains) + //按物料id分组 + .collect(Collectors.groupingBy(QuotaData::getMaterialId)) + .entrySet() + //重新组合(key:物料id;value:报价最低值) + .stream().collect(Collectors.toMap( Map.Entry::getKey, + //取报价最低值 v -> v.getValue().stream() .min(Comparator.comparing(QuotaData::getQuotaValue)) - .get().getQuotaValue() - )); + .get().getQuotaValue()) + ); + logger.info("每个物料的报价最低值 ==>"+materialMinMap); + //统计每个供应商报价最低物料数量 Map minQuotaCount = vendorQuotaMap.entrySet().stream().collect(Collectors.toMap( Map.Entry::getKey, @@ -62,6 +71,8 @@ public class QuotationNumberChain extends AbstractScoreChain{ return materialMinMap.containsKey(materialId) && new BigDecimal(quotaValue).compareTo(BigDecimal.valueOf(materialMinMap.get(materialId))) == 0; }).count() )); + logger.info("每个供应商报价最低次数 ==>"+minQuotaCount); + //统计出报价最低 最多的次数 Integer maxCount = minQuotaCount.entrySet().stream().max(Map.Entry.comparingByValue()).get().getValue(); for (Map.Entry entry : minQuotaCount.entrySet()) { @@ -73,6 +84,7 @@ public class QuotationNumberChain extends AbstractScoreChain{ vendorScoreMap.put(entry.getKey(),19); } } + } //整理评分数据 for (VendorMarkReport vendorMarkReport : vendorMarkReportList) { diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/TopThirtyChain.java b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/TopThirtyChain.java index da5b11c..1544f72 100644 --- a/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/TopThirtyChain.java +++ b/src/main/java/weaver/bokang/xiao/xhny_report/service/chain/TopThirtyChain.java @@ -1,5 +1,6 @@ package weaver.bokang.xiao.xhny_report.service.chain; +import com.alibaba.fastjson.JSON; import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData; import weaver.bokang.xiao.xhny_report.entity.pojo.ConfigEntity; import weaver.bokang.xiao.xhny_report.entity.pojo.MaterialEntity; @@ -41,15 +42,18 @@ public class TopThirtyChain extends AbstractScoreChain{ } //求出每个供应商都报价的物料(求交集) List retainQuotaList = VendorUtil.retainElementList(sourceList); + logger.info(String.format("交集数据 ==> %s", JSON.toJSONString(retainQuotaList))); if(!retainQuotaList.isEmpty()){ //过滤top30的物料信息 Map topThirtyMaterial = this.vendorStore.getTopThirtyMaterial(); Map mappingMaterial = sourceTrackingData.getSourceMaterialList().stream().collect(Collectors.toMap(MaterialEntity::getMaterialId, MaterialEntity::getMaterialCode)); + //过滤出包含top30的部分 List collect = retainQuotaList.stream().filter(item -> { Integer materialId = item.getMaterialId(); String materialCode = mappingMaterial.get(materialId); return topThirtyMaterial.containsKey(materialCode); }).collect(Collectors.toList()); + logger.info(String.format("包含top30的交集数据 ==> %s", JSON.toJSONString(collect))); if(!collect.isEmpty()) { //统计报价总和 Map quotaScoreMap = vendorQuotaMap.entrySet().stream() @@ -57,9 +61,10 @@ public class TopThirtyChain extends AbstractScoreChain{ Map.Entry::getKey, v -> v.getValue().stream().filter(collect::contains).mapToDouble(QuotaData::getQuotaValue).sum()) ); + logger.info("统计交集部分物料报价总和 ==>"+quotaScoreMap); //统计报价最小值 Optional> min = quotaScoreMap.entrySet().stream().min(Map.Entry.comparingByValue()); - + logger.info("报价最低值 ==>"+min); if (min.isPresent()) { double minValue = min.get().getValue(); for (VendorMarkReport vendorMarkReport : vendorMarkReportList) { diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/service/store/VendorStore.java b/src/main/java/weaver/bokang/xiao/xhny_report/service/store/VendorStore.java index 279711d..72d1d21 100644 --- a/src/main/java/weaver/bokang/xiao/xhny_report/service/store/VendorStore.java +++ b/src/main/java/weaver/bokang/xiao/xhny_report/service/store/VendorStore.java @@ -31,6 +31,7 @@ public class VendorStore { /** 公司信息 */ private List companyEntityList; + /** 公司数据 */ private Map companyMap = new HashMap<>(); /** 数据源名称 */ @@ -40,9 +41,11 @@ public class VendorStore { private static final VendorMapper VENDOR_MAPPER = Util.getMapper(VendorMapper.class); + /** top30物料数据 */ private final Map topThirtyMaterial = new HashMap<>(); private VendorStore(){ + //this.init(); } @@ -54,7 +57,7 @@ public class VendorStore { companyMap = companyEntityList.stream().collect(Collectors.toMap(CompanyEntity::getId, item -> item)); } this.queryTopThirtyMaterial(); - logger.info(String.format("公共数据初始化成功 VendorStore init success !! [VENDOR_MAPPER:%s \n topThirtyMaterial:%s]", JSON.toJSONString(VENDOR_MAPPER), JSON.toJSONString(topThirtyMaterial))); + logger.info(String.format("公共数据初始化成功 VendorStore init success !! [companyMap:%s \n topThirtyMaterial:%s \n datasource:%s]", JSON.toJSONString(companyMap), JSON.toJSONString(topThirtyMaterial),this.dataSource)); }catch (Exception exception){ logger.error("VendorStore 初始化异常 ==>"+Util.getErrString(exception)); } diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/service/util/VendorUtil.java b/src/main/java/weaver/bokang/xiao/xhny_report/service/util/VendorUtil.java index 324071b..6d09ffa 100644 --- a/src/main/java/weaver/bokang/xiao/xhny_report/service/util/VendorUtil.java +++ b/src/main/java/weaver/bokang/xiao/xhny_report/service/util/VendorUtil.java @@ -1,7 +1,7 @@ package weaver.bokang.xiao.xhny_report.service.util; +import com.cloudstore.dev.api.util.EMManager; import weaver.bokang.xiao.xhny_report.entity.pojo.ConfigEntity; -import weaver.bokang.xiao.xhny_report.entity.pojo.QuotaData; import weaver.bokang.xiao.xhny_report.entity.pojo.VendorMarkReport; import weaver.bokang.xiao.xhny_report.entity.pojo.VendorMarkReportDt; @@ -48,6 +48,7 @@ public class VendorUtil { VendorMarkReportDt.builder() .score(score) .project(configEntity.getChildItem()) + .detailDesc(configEntity.getDetail()) .weight(configEntity.getWeight()) .desc(desc).build()); double totalScore = vendorMarkReport.getTotalScore(); diff --git a/src/main/java/weaver/bokang/xiao/zscq/action/OneNetComAction.java b/src/main/java/weaver/bokang/xiao/zscq/action/OneNetComAction.java new file mode 100644 index 0000000..09e9820 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/zscq/action/OneNetComAction.java @@ -0,0 +1,167 @@ +package weaver.bokang.xiao.zscq.action; + +import aiyh.utils.Util; +import aiyh.utils.action.SafeCusBaseAction; +import aiyh.utils.annotation.ActionDesc; +import aiyh.utils.annotation.ActionOptionalParam; +import aiyh.utils.annotation.PrintParamMark; +import aiyh.utils.annotation.RequiredMark; +import aiyh.utils.excention.CustomerException; +import aiyh.utils.httpUtil.ResponeVo; +import aiyh.utils.httpUtil.util.HttpUtils; +import com.alibaba.fastjson.JSON; +import com.gbasedbt.base64.BASE64Encoder; +import lombok.Setter; +import org.apache.commons.lang3.StringUtils; +import weaver.bokang.xiao.common.mapper.WorkflowMapper; +import weaver.hrm.User; +import weaver.soa.workflow.request.RequestInfo; +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 javax.crypto.Cipher; +import javax.crypto.spec.SecretKeySpec; +import java.io.IOException; + +import java.nio.charset.StandardCharsets; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @ClassName OneNetcomAction + * @Author 肖博亢 + * @Date 2023/3/27 14:04 + * @Description

一网通接口调用action

+ **/ +@Setter +@ActionDesc(value = "一网通接口调用action",author = "bokang.xiao") +public class OneNetComAction extends SafeCusBaseAction { + + /** 受理接口唯一标识 */ + @PrintParamMark + @ActionOptionalParam(value = "",desc = "受理接口唯一标识") + private String acceptUnique; + + + /** 办理接口唯一标识 */ + @PrintParamMark + @ActionOptionalParam(value = "",desc = "受理接口唯一标识") + private String handleUnique; + + @RequiredMark("网关应用app_ID") + @PrintParamMark + private String appId; + + @RequiredMark("网关应用app_key") + @PrintParamMark + private String appKey; + + /** 网关调用受理接口的apiId */ + @PrintParamMark + @ActionOptionalParam(value = "",desc = "网关调用受理接口的apiId") + private String acceptApiName; + + /** 网关调用办理接口的apiId */ + @PrintParamMark + @ActionOptionalParam(value = "",desc = "网关调用办理接口的apiId") + private String handleApiName; + + private final WorkflowMapper workflowMapper = Util.getMapper(WorkflowMapper.class); + + private final DealWithMapping dealWithMapping = new DealWithMapping(); + + private final HttpUtils httpUtils = new HttpUtils(); + + private final SqlUtil sqlUtil = new SqlUtil(); + + @Override + public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) { + log.info(String.format("=================== {%s} {requestId : %s} begin ======================", this.getClass().getName(),requestId)); + Map workflowMessage = workflowMapper.queryWorkflowByRequestId(requestId, billTable); + dealWithMapping.setMainTable(billTable); + try{ + if(StringUtils.isNotBlank(acceptUnique) && StringUtils.isNotBlank(acceptApiName)) { + requestHandle(workflowMessage,acceptUnique,acceptApiName,requestId,billTable,"受理请求"); + } + if(StringUtils.isNotBlank(handleUnique) && StringUtils.isNotBlank(handleApiName)) { + requestHandle(workflowMessage,handleUnique,handleApiName,requestId,billTable,"处理请求"); + } + }catch (IOException exception){ + log.error("请求发送异常 ==>"+Util.getErrString(exception)); + throw new CustomerException("请求发送异常"); + } + } + + /** + *

接口具体调用逻辑

+ * @param workflowMessage 流程表单数据 + * @param uniqueCode 请求唯一标识 + * @param apiName 网关调用接口的apiId + * @param requestId 流程id + * @param billTable 主表表名 + * @param desc 接口描述 + * @throws IOException + */ + private void requestHandle(Map workflowMessage, + String uniqueCode,String apiName, + String requestId,String billTable, + String desc) throws IOException { + RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(uniqueCode); + Map requestParam = dealWithMapping.getRequestParam(workflowMessage, requestMappingConfig); + Map header = this.getHeader(apiName); + ResponeVo responeVo = httpUtils.apiPost(requestMappingConfig.getRequestUrl(), requestParam,header); + if(responeVo.getCode() == 200){ + Map result = responeVo.getResponseMap(); + int requestCode = Util.getIntValue(Util.null2String(result.get("code"))); + String message = Util.null2String(result.get("msg")); + if(requestCode == 200){ + List responseMappingList = requestMappingConfig.getResponseMappingList(); + 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); + sqlUtil.updateMode(billTable, updateMsg, whereParam); + }else { + throw new CustomerException(desc+"请求失败 ==>"+message); + } + }else { + throw new CustomerException(desc+" 状态码不为200"); + } + + } + + /** + *

获取请求头信息

+ * @param apiName 网关接口的apiId + * @return 请求头信息 + */ + + public Map getHeader(String apiName){ + Map header = new HashMap<>(); + try { + String timestamp = String.valueOf(System.currentTimeMillis()/1000); + String stringToSign = appId + apiName + timestamp; + SecretKeySpec keySpec = new SecretKeySpec(appKey.getBytes(StandardCharsets.UTF_8), "AES"); + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); + cipher.init(Cipher.ENCRYPT_MODE, keySpec); + byte[] bytes = cipher.doFinal(stringToSign.getBytes(StandardCharsets.UTF_8)); + String signature = new BASE64Encoder().encode(bytes); + signature = signature.replace("\n", "").replace("\r", ""); + header.put("Content-Type", "application/json"); + header.put("appid", appId); + header.put("apiName", apiName); + header.put("signature", signature); + }catch (Exception e){ + log.info("获取请求头异常 ==>"+Util.getErrString(e)); + throw new CustomerException("获取请求头异常 ==>"+e.getMessage()); + } + return header; + } + +} diff --git a/src/main/java/weaver/bokang/xiao/zscq/action/StatusChangeAction.java b/src/main/java/weaver/bokang/xiao/zscq/action/StatusChangeAction.java new file mode 100644 index 0000000..e46001a --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/zscq/action/StatusChangeAction.java @@ -0,0 +1,48 @@ +package weaver.bokang.xiao.zscq.action; + +import aiyh.utils.ThreadPoolConfig; +import aiyh.utils.Util; +import aiyh.utils.action.SafeCusBaseAction; +import aiyh.utils.annotation.ActionDesc; +import aiyh.utils.annotation.PrintParamMark; +import aiyh.utils.annotation.RequiredMark; +import lombok.Setter; +import weaver.bokang.xiao.zscq.mapper.StatusMapper; +import weaver.hrm.User; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.concurrent.ExecutorService; + +/** + * @ClassName StatusChangeAction + * @Author 肖博亢 + * @Date 2023/4/7 12:42 + * @Description

+ **/ +@Setter +@ActionDesc(value = "更新抄送的流程为已读",author = "bokang.xiao") +public class StatusChangeAction extends SafeCusBaseAction { + + @RequiredMark("用户id集合 , 分割") + @PrintParamMark + private String userIds; + + private String sleepMillis; + + private StatusMapper statusMapper = Util.getMapper(StatusMapper.class); + + private ExecutorService threadPoolInstance = ThreadPoolConfig.createThreadPoolInstance(); + + @Override + public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) { + threadPoolInstance.execute(() -> { + try { + Thread.sleep(Util.getIntValue(sleepMillis,1000)); + log.info("更新抄送流程为已读 ==>"+requestId+" userIds ==>"+userIds); + statusMapper.changeWorkflowStatus(requestId,userIds); + } catch (InterruptedException e) { + log.error("线程修改抄送流程状态失败==>"+Util.getErrString(e)); + } + }); + } +} diff --git a/src/main/java/weaver/bokang/xiao/zscq/config/entity/AssignmentEntity.java b/src/main/java/weaver/bokang/xiao/zscq/config/entity/AssignmentEntity.java new file mode 100644 index 0000000..9f01e39 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/zscq/config/entity/AssignmentEntity.java @@ -0,0 +1,31 @@ +package weaver.bokang.xiao.zscq.config.entity; + +import lombok.Data; + +/** + * @ClassName AssignmentEntity + * @Author 肖博亢 + * @Date 2023/4/4 15:42 + * @Description

+ **/ +@Data +public class AssignmentEntity { + + /** 赋值字段 */ + private String assignmentField; + + /** 值选择 */ + private Integer valueSelect; + + /** 源字段 */ + private String sourceField; + + /** 赋值字段名 */ + private String assignmentFieldName; + + /** 源字段名 */ + private String sourceFieldName; + + /** 文本框 */ + private String context; +} diff --git a/src/main/java/weaver/bokang/xiao/zscq/config/entity/ConditionEntity.java b/src/main/java/weaver/bokang/xiao/zscq/config/entity/ConditionEntity.java new file mode 100644 index 0000000..4509aea --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/zscq/config/entity/ConditionEntity.java @@ -0,0 +1,37 @@ +package weaver.bokang.xiao.zscq.config.entity; + +import lombok.Data; + +/** + * @ClassName ConditionEntity + * @Author 肖博亢 + * @Date 2023/4/4 15:39 + * @Description

+ **/ +@Data +public class ConditionEntity { + + /** 条件类型 */ + private Integer conditionType; + + /** 条件 */ + private Integer conditionValue; + + /** 源字段 */ + private String conditionSourceField; + + /** 值类型 */ + private Integer valueType; + + /** 目标字段 */ + private String conditionTargetField; + + /** 源字段名 */ + private String conditionSourceFieldName; + + /** 目标字段名 */ + private String conditionTargetFieldName; + + /** 文本框 */ + private String cusText; +} diff --git a/src/main/java/weaver/bokang/xiao/zscq/config/entity/UpdateModeConf.java b/src/main/java/weaver/bokang/xiao/zscq/config/entity/UpdateModeConf.java new file mode 100644 index 0000000..8489d61 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/zscq/config/entity/UpdateModeConf.java @@ -0,0 +1,49 @@ +package weaver.bokang.xiao.zscq.config.entity; + +import lombok.Data; + +import java.util.List; + +/** + * @ClassName UpdateModeConf + * @Author 肖博亢 + * @Date 2023/4/4 15:32 + * @Description

+ **/ +@Data +public class UpdateModeConf { + + /** 源建模 */ + private String sourceMode; + + /** 触发建模 */ + private String targetMode; + + /** 说明 */ + private String description; + + /** 唯一标识 */ + private String uniqueCode; + + /** 源表名 */ + private String sourceTableName; + + /** 触发表名 */ + private String targetTableName; + + /** 数据写入方式 */ + private Integer dataInType; + + /** 自定义操作类全路径 */ + private String operatePath; + + /** 无条件触发 */ + private Integer noRule; + + /** 条件列表 */ + private List conditionList; + + /** 赋值列表 */ + private List assignmentList; + +} diff --git a/src/main/java/weaver/bokang/xiao/zscq/config/function/ConditionFunction.java b/src/main/java/weaver/bokang/xiao/zscq/config/function/ConditionFunction.java new file mode 100644 index 0000000..d58cc16 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/zscq/config/function/ConditionFunction.java @@ -0,0 +1,20 @@ +package weaver.bokang.xiao.zscq.config.function; + +/** + * @ClassName ConditionFunction + * @Author 肖博亢 + * @Date 2023/4/4 17:58 + * @Description

+ **/ +@FunctionalInterface +public interface ConditionFunction { + + /** + *

条件处理

+ * @param p 参数 + * @param q 参数 + * @param k 参数 + * @return 返回值 + */ + R apply(P p,Q q,K k); +} diff --git a/src/main/java/weaver/bokang/xiao/zscq/config/function/CusOperateInterface.java b/src/main/java/weaver/bokang/xiao/zscq/config/function/CusOperateInterface.java new file mode 100644 index 0000000..d4c5c1f --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/zscq/config/function/CusOperateInterface.java @@ -0,0 +1,36 @@ +package weaver.bokang.xiao.zscq.config.function; + +import aiyh.utils.Util; +import org.apache.log4j.Logger; + +import java.util.Map; + +/** + * @ClassName CusOperateInterface + * @Author 肖博亢 + * @Date 2023/4/7 14:52 + * @Description

+ **/ +public interface CusOperateInterface { + + Logger logger = Util.getLogger(); + + /** + *

自定义接口操作

+ * + *

+ * whereParam: 条件参数信息 key为数据库字段名,值为条件值 + * param{ + * tableName:"更新数据表名", + * whereSql:"条件sql", + * operatePath:"接口全路径类名" + * } + * pathParam: 路径参数 + *

+ * + * @param whereParam 条件参数信息 + * @param param 基本参数 + * @param pathParam 路径参数 + */ + void execute(Map whereParam, Map param,Map pathParam); +} diff --git a/src/main/java/weaver/bokang/xiao/zscq/config/mapper/UpdateModeMapper.java b/src/main/java/weaver/bokang/xiao/zscq/config/mapper/UpdateModeMapper.java new file mode 100644 index 0000000..8c9dd44 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/zscq/config/mapper/UpdateModeMapper.java @@ -0,0 +1,80 @@ +package weaver.bokang.xiao.zscq.config.mapper; + +import aiyh.utils.annotation.recordset.*; +import weaver.bokang.xiao.zscq.config.entity.AssignmentEntity; +import weaver.bokang.xiao.zscq.config.entity.ConditionEntity; +import weaver.bokang.xiao.zscq.config.entity.UpdateModeConf; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName UpdateModeMapper + * @Author 肖博亢 + * @Date 2023/4/4 15:47 + * @Description

+ **/ +@SqlMapper +public interface UpdateModeMapper { + + /** + *

通过formId查询相关配置信息

+ * @param formId 表单id + * @return 配置列表 + */ + @Select("select * from uf_update_mode_conf where source_mode = #{formId}") + @CollectionMappings({ + @CollectionMapping(property = "conditionList", column = "id", id = @Id(value = Integer.class, methodId = 1)), + @CollectionMapping(property = "assignmentList", column = "id", id = @Id(value = Integer.class, methodId = 2)), + }) + List queryUpdateModeConfByFormId(@ParamMapper("formId")String formId); + + /** + *

查询条件列表

+ * @param mainId 主数据id + * @return 条件列表 + */ + @Select("select * from uf_update_mode_conf_dt1 where mainid = #{mainId}") + @CollectionMethod(1) + List queryConditionList(@ParamMapper("mainId")int mainId); + + /** + *

查询赋值列表

+ * @param mainId 主数据id + * @return 赋值列表 + */ + @Select("select * from uf_update_mode_conf_dt2 where mainid = #{mainId}") + @CollectionMethod(2) + List queryAssignmentList(@ParamMapper("mainId")int mainId); + + /** + *

执行自定义查询sql

+ * @param cusSql 自定义sql + * @param param 参数信息 + * @param cusParam 参数信息 + * @return 查询结果 + */ + @Select(custom = true) + String executeCusSql(@SqlString String cusSql, @ParamMapper("param")Map param,Map cusParam); + + /** + *

执行自定义查询sql

+ * @param cusSql 自定义sql + * @param whereParam 参数信息 + * @param cusParam 参数信息 + * @return 查询结果 + */ + @Select(custom = true) + Map executeCusSqlMap(@SqlString String cusSql, @ParamMapper("whereParam")Map whereParam,@ParamMapper("cusParam")Map cusParam); + + /** + *

执行自定义更新sql

+ * @param cusSql 自定义sql + * @param updateParam 更新参数信息 + * @param whereParam 条件参数信息 + * @return 查询结果 + */ + @Update(custom = true) + boolean executeUpdateCusSql(@SqlString String cusSql, @ParamMapper("updateParam")Map updateParam,@ParamMapper("whereParam")Map whereParam); + +} diff --git a/src/main/java/weaver/bokang/xiao/zscq/config/process/ConditionTargetProcess.java b/src/main/java/weaver/bokang/xiao/zscq/config/process/ConditionTargetProcess.java new file mode 100644 index 0000000..0161001 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/zscq/config/process/ConditionTargetProcess.java @@ -0,0 +1,83 @@ +package weaver.bokang.xiao.zscq.config.process; + +import aiyh.utils.Util; +import aiyh.utils.annotation.MethodRuleNo; +import org.apache.log4j.Logger; +import weaver.bokang.xiao.zscq.config.function.ConditionFunction; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; + + +/** + * @ClassName ConditionTargetProcess + * @Author 肖博亢 + * @Date 2023/4/4 17:54 + * @Description

目标建模条件sql生成处理

+ **/ +public class ConditionTargetProcess { + + public static final Map,Map,String>> TARGET_MODE_METHOD_MAP = new HashMap<>(); + + public static final Logger logger = Util.getLogger(); + + static { + try { + Class valueRuleMethodClass = ConditionTargetProcess.class; + Method[] methods = valueRuleMethodClass.getDeclaredMethods(); + for (Method method : methods) { + if (method.isAnnotationPresent(MethodRuleNo.class)) { + MethodRuleNo annotation = method.getAnnotation(MethodRuleNo.class); + int value = annotation.value(); + TARGET_MODE_METHOD_MAP.put(value, (whereParam,param,whereSql) -> { + try { + return (String) method.invoke(null,whereParam,param,whereSql); + } catch (IllegalAccessException | InvocationTargetException e) { + throw new RuntimeException(e); + } + }); + } + } + }catch (Exception exception){ + logger.error("ConditionTargetProcess init error !!! "+Util.getErrString(exception)); + } + } + + /** + *

目标建模等于处理方法

+ * @param whereParam 条件参数 + * @param param 参数信息 + * @param whereSql 条件sql + * @return 条件sql + */ + @MethodRuleNo(value = 0, desc = "等于") + public static String equals(Map whereParam,Map param,String whereSql) { + String conditionValue = Util.null2String(param.get("conditionValue")); + String targetFieldName = Util.null2String(param.get("targetFieldName")); + String targetStr = " and "+targetFieldName+" = #{whereParam."+targetFieldName+"}"; + whereSql += targetStr; + whereParam.put(targetFieldName,conditionValue); + return whereSql; + } + + /** + *

目标建模不等于处理方法

+ * @param whereParam 条件参数 + * @param param 参数信息 + * @param whereSql 条件sql + * @return 条件sql + */ + @MethodRuleNo(value = 1, desc = "不等于") + public static String noEquals(Map whereParam,Map param,String whereSql) { + String sourceFieldName = Util.null2String(param.get("sourceValue")); + String conditionValue = Util.null2String(param.get("conditionValue")); + String targetFieldName = Util.null2String(param.get("targetFieldName")); + String targetStr = " and "+sourceFieldName+" <> #{whereParam."+targetFieldName+"}"; + whereSql += targetStr; + whereParam.put(targetFieldName,conditionValue); + return whereSql; + } + +} diff --git a/src/main/java/weaver/bokang/xiao/zscq/config/process/ConditionValueProcess.java b/src/main/java/weaver/bokang/xiao/zscq/config/process/ConditionValueProcess.java new file mode 100644 index 0000000..f05f074 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/zscq/config/process/ConditionValueProcess.java @@ -0,0 +1,71 @@ +package weaver.bokang.xiao.zscq.config.process; + +import aiyh.utils.Util; +import aiyh.utils.annotation.MethodRuleNo; +import org.apache.log4j.Logger; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; +import java.util.function.BiFunction; + +/** + * @ClassName ConditionValueProcess + * @Author 肖博亢 + * @Date 2023/4/4 16:19 + * @Description

源建模数据判读条件相关处理

+ **/ +public class ConditionValueProcess { + + public static final Map> SOURCE_MODE_METHOD_MAP = new HashMap<>(); + + + public static final Logger logger = Util.getLogger(); + + static { + try { + Class valueRuleMethodClass = ConditionValueProcess.class; + Method[] methods = valueRuleMethodClass.getDeclaredMethods(); + for (Method method : methods) { + if (method.isAnnotationPresent(MethodRuleNo.class)) { + MethodRuleNo annotation = method.getAnnotation(MethodRuleNo.class); + int value = annotation.value(); + SOURCE_MODE_METHOD_MAP.put(value, (sourceValue, conditionValue) -> { + try { + return (Boolean) method.invoke(null,sourceValue, conditionValue); + } catch (IllegalAccessException | InvocationTargetException e) { + throw new RuntimeException(e); + } + }); + } + } + }catch (Exception exception){ + logger.error("ConditionValueProcess init error !!! "+Util.getErrString(exception)); + } + } + + /** + *

源建模等于处理方法

+ * @param sourceValue 源建模值 + * @param value 目标值 + * @return 是否符合 + */ + @MethodRuleNo(value = 0, desc = "等于") + public static boolean equals(String sourceValue, String value) { + return sourceValue.equals(value); + } + + /** + *

源建模不等于处理方法

+ * @param sourceValue 源建模值 + * @param value 目标值 + * @return 是否符合 + */ + @MethodRuleNo(value = 1, desc = "不等于") + public static boolean noEquals(String sourceValue, String value) { + return !sourceValue.equals(value); + } + + +} diff --git a/src/main/java/weaver/bokang/xiao/zscq/config/process/DataTypeProcess.java b/src/main/java/weaver/bokang/xiao/zscq/config/process/DataTypeProcess.java new file mode 100644 index 0000000..55f2086 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/zscq/config/process/DataTypeProcess.java @@ -0,0 +1,229 @@ +package weaver.bokang.xiao.zscq.config.process; + +import aiyh.utils.Util; +import aiyh.utils.annotation.MethodRuleNo; +import aiyh.utils.excention.CustomerException; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import weaver.bokang.xiao.zscq.config.function.ConditionFunction; +import weaver.bokang.xiao.zscq.config.function.CusOperateInterface; +import weaver.bokang.xiao.zscq.config.mapper.UpdateModeMapper; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + + +/** + * @ClassName DataTypeProcess + * @Author 肖博亢 + * @Date 2023/4/6 13:10 + * @Description

建模数据更新处理

+ **/ +public class DataTypeProcess { + + public static final Map,Map, Map>> SOURCE_MODE_METHOD_MAP = new HashMap<>(); + + private static final UpdateModeMapper UPDATE_MODE_MAPPER = Util.getMapper(UpdateModeMapper.class); + + public static final Logger logger = Util.getLogger(); + + static { + try { + Class valueRuleMethodClass = DataTypeProcess.class; + Method[] methods = valueRuleMethodClass.getDeclaredMethods(); + for (Method method : methods) { + if (method.isAnnotationPresent(MethodRuleNo.class)) { + MethodRuleNo annotation = method.getAnnotation(MethodRuleNo.class); + int value = annotation.value(); + SOURCE_MODE_METHOD_MAP.put(value, (updateParam, whereParam,param) -> { + try { + return (boolean) method.invoke(null,updateParam, whereParam,param); + } catch (IllegalAccessException | InvocationTargetException e) { + throw new RuntimeException(e); + } + }); + } + } + }catch (Exception exception){ + logger.error("DataTypeProcess init error !!! "+Util.getErrString(exception)); + } + } + + /** + *

更新处理方法

+ * @param updateParam 更新参数 + * @param whereParam 条件参数 + * @param param 表参数 + * @return 更新字符串 + */ + @MethodRuleNo(value = 0, desc = "更新") + public static boolean update(Map updateParam, Map whereParam,Map param) { + String tableName = Util.null2String(param.get("tableName")); + String whereSql = Util.null2String(param.get("whereSql")); + String updateSql = DataTypeProcess.buildUpdateSql(tableName, updateParam); + if(!"".equals(whereSql)){ + whereSql = whereSql.replaceFirst(" and "," where "); + } + updateSql = updateSql + whereSql; + logger.info("updateSql ==>"+updateSql); + return UPDATE_MODE_MAPPER.executeUpdateCusSql(updateSql, updateParam, whereParam); + } + + /** + *

插入处理方法

+ * @param updateParam 更新参数 + * @param whereParam 条件参数 + * @param param 表参数 + * @return 更新字符串 + */ + @MethodRuleNo(value = 1, desc = "插入") + public static boolean insert(Map updateParam, Map whereParam,Map param) { + String tableName = Util.null2String(param.get("tableName")); + String modeId = Util.getModeIdByTableName(tableName); + int dataId = Util.getModeDataId(tableName, Util.getIntValue(modeId), 1); + whereParam.clear(); + whereParam.put("id",dataId); + String updateSql = buildUpdateSql(tableName, updateParam); + String whereSql = DataTypeProcess.buildWhereSql(whereParam); + updateSql = updateSql + " " + whereSql; + logger.info("updateSql ==>"+updateSql); + return UPDATE_MODE_MAPPER.executeUpdateCusSql(updateSql,updateParam,whereParam); + } + + /** + *

执行自定义处理方法

+ * @param updateParam 更新参数 + * @param whereParam 条件参数 + * @param param 表参数 + * @return 执行结果 + */ + @MethodRuleNo(value = 2,desc = "自定义操作") + public static boolean cusOperate(Map updateParam, Map whereParam,Map param) { + String operatePath = Util.null2String(param.get("operatePath")); + if(StringUtils.isBlank(operatePath)){ + throw new CustomerException("操作全路径不能为空"); + } + Map pathParam = new HashMap<>(); + try { + CusOperateInterface cusInterfaceObj = getCusInterfaceObj(operatePath, CusOperateInterface.class, pathParam); + cusInterfaceObj.execute(whereParam,param,pathParam); + }catch (Exception e){ + logger.error("自定义处理类执行异常 ==>"+Util.getErrString(e)); + throw new CustomerException(e); + } + return true; + } + + /** + *

更新并执行自定义处理方法

+ * @param updateParam 更新参数 + * @param whereParam 条件参数 + * @param param 表参数 + * @return 执行结果 + */ + @MethodRuleNo(value = 3,desc = "插入并执行自定义操作") + public static boolean cusAndUpdate(Map updateParam, Map whereParam,Map param) { + return update(updateParam,whereParam,param) && cusOperate(updateParam,whereParam,param); + } + + /** + *

插入并执行自定义处理方法

+ * @param updateParam 更新参数 + * @param whereParam 条件参数 + * @param param 表参数 + * @return 执行结果 + */ + @MethodRuleNo(value = 4,desc = "插入并执行自定义操作") + public static boolean cusAndInsert(Map updateParam, Map whereParam,Map param) { + return insert(updateParam,whereParam,param) && cusOperate(updateParam,whereParam,param); + } + + /** + *

构建更新sql语句

+ * @param tableName 表名 + * @param updateParam 更新参数 + * @return 更新语句 + */ + public static String buildUpdateSql(String tableName, Map updateParam){ + StringBuilder updateBuilder = new StringBuilder("update "); + updateBuilder.append(tableName).append(" set "); + Set> updateEntries = updateParam.entrySet(); + for (Map.Entry updateEntry : updateEntries) { + if("cusSql".equals(updateEntry.getKey())){ + updateBuilder.append(updateEntry.getValue()); + continue; + } + updateBuilder.append(updateEntry.getKey()) + .append(" = ") + .append("#{updateParam.").append(updateEntry.getKey()).append("},"); + } + return updateBuilder.substring(0, updateBuilder.length() - 1) + " "; + } + + /** + *

构建条件sql语句

+ * @param whereParam 条件参数 + * @return 条件语句 + */ + public static String buildWhereSql(Map whereParam){ + StringBuilder whereBuilder = new StringBuilder(); + Set> whereEntries = whereParam.entrySet(); + for (Map.Entry whereEntry : whereEntries) { + if("cusSql".equals(whereEntry.getKey())){ + whereBuilder.append(" and ").append(whereEntry.getValue()); + continue; + } + whereBuilder.append(" and ") + .append(whereEntry.getKey()) + .append("#{whereParam.").append(whereEntry.getKey()).append("},"); + } + String fixStr = whereBuilder.toString(); + if(!"".equals(fixStr)){ + fixStr = fixStr.replaceFirst(" and "," where "); + } + return fixStr; + } + + /** + *

+ * @param path 全路径类名 + * @param clazz 父类接口 + * @param pathParamMap 路径参数 + * @return 接口实现类 + * @param 泛型 + */ + public static T getCusInterfaceObj(String path, Class clazz, Map pathParamMap) { + + path = Util.sbc2dbcCase(path); + String[] split = path.split("\\?"); + String classPath = split[0]; + Class aClass; + try { + aClass = Class.forName(classPath); + } catch (ClassNotFoundException e) { + throw new IllegalArgumentException("未能找到自定义接口:" + classPath); + } + if (!clazz.isAssignableFrom(aClass)) { + throw new IllegalArgumentException("自定义接口:" + classPath + " 不是" + + clazz.getName() + "的子类或实现类!"); + } + Constructor constructor; + try { + constructor = aClass.getConstructor(); + } catch (NoSuchMethodException e) { + throw new IllegalArgumentException(classPath + "没有空参构造方法,无法获取构造方法对象!"); + } + T o; + try { + o = (T) constructor.newInstance(); + } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { + throw new IllegalArgumentException("无法构造" + classPath + "对象!"); + } + pathParamMap.putAll(Util.parseCusInterfacePathParam(path)); + return o; + } +} diff --git a/src/main/java/weaver/bokang/xiao/zscq/config/process/ValueSelectProcess.java b/src/main/java/weaver/bokang/xiao/zscq/config/process/ValueSelectProcess.java new file mode 100644 index 0000000..e0a570c --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/zscq/config/process/ValueSelectProcess.java @@ -0,0 +1,107 @@ +package weaver.bokang.xiao.zscq.config.process; + +import aiyh.utils.Util; +import aiyh.utils.annotation.MethodRuleNo; +import aiyh.utils.excention.CustomerException; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import weaver.bokang.xiao.zscq.config.entity.AssignmentEntity; +import weaver.bokang.xiao.zscq.config.entity.ConditionEntity; +import weaver.bokang.xiao.zscq.config.mapper.UpdateModeMapper; +import weaver.general.TimeUtil; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; +import java.util.function.BiFunction; + +/** + * @ClassName ValueSelectProcess + * @Author 肖博亢 + * @Date 2023/4/6 12:42 + * @Description

赋值 - 取值类型相关处理

+ **/ +public class ValueSelectProcess { + + public static final Map, AssignmentEntity, String>> SOURCE_MODE_METHOD_MAP = new HashMap<>(); + + private static final UpdateModeMapper UPDATE_MODE_MAPPER = Util.getMapper(UpdateModeMapper.class); + + public static final Logger logger = Util.getLogger(); + + static { + try { + Class valueRuleMethodClass = ValueSelectProcess.class; + Method[] methods = valueRuleMethodClass.getDeclaredMethods(); + for (Method method : methods) { + if (method.isAnnotationPresent(MethodRuleNo.class)) { + MethodRuleNo annotation = method.getAnnotation(MethodRuleNo.class); + int value = annotation.value(); + SOURCE_MODE_METHOD_MAP.put(value, (modeMap, assignment) -> { + try { + return (String) method.invoke(null,modeMap, assignment); + } catch (IllegalAccessException | InvocationTargetException e) { + throw new RuntimeException(e); + } + }); + } + } + }catch (Exception exception){ + logger.error("ValueTypeProcess init error !!! "+Util.getErrString(exception)); + } + } + + /** + *

默认值处理方法

+ * @param modeMap 源建模值 + * @param assignment 赋值实体信息 + * @return 值信息 + */ + @MethodRuleNo(value = 0, desc = "默认值") + public static String defaultValue(Map modeMap,AssignmentEntity assignment) { + return assignment.getContext(); + } + + /** + *

建模字段处理方法

+ * @param modeMap 源建模值 + * @param assignment 赋值实体信息 + * @return 值信息 + */ + @MethodRuleNo(value = 1, desc = "建模字段") + public static String modeField(Map modeMap,AssignmentEntity assignment) { + return Util.null2String(modeMap.get(assignment.getSourceFieldName())); + } + + /** + *

自定义sql处理方法

+ * @param modeMap 源建模值 + * @param assignment 赋值实体信息 + * @return 值信息 + */ + @MethodRuleNo(value = 2, desc = "自定义sql") + public static String cusSql(Map modeMap,AssignmentEntity assignment) { + String cusSqlStr = Util.null2String(assignment.getContext()); + cusSqlStr = Util.dbc2sbcCase(cusSqlStr); + if(StringUtils.isBlank(cusSqlStr)){ + throw new CustomerException("选择自定义sql时,sql字符串不能为空"); + } + if(!cusSqlStr.startsWith("select ")){ + throw new CustomerException("选择自定义sql时,不允许执行除select之外的其他危险操作 !!!"); + } + return UPDATE_MODE_MAPPER.executeCusSql(cusSqlStr, modeMap,new HashMap<>()); + } + + /** + *

当前时间处理方法

+ * @param modeMap 源建模值 + * @param assignment 赋值实体信息 + * @return 值信息 + */ + @MethodRuleNo(value = 3, desc = "当前时间") + public static String currentTime(Map modeMap,AssignmentEntity assignment) { + return TimeUtil.getCurrentTimeString(); + } + +} diff --git a/src/main/java/weaver/bokang/xiao/zscq/config/process/ValueTypeProcess.java b/src/main/java/weaver/bokang/xiao/zscq/config/process/ValueTypeProcess.java new file mode 100644 index 0000000..eb71f0b --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/zscq/config/process/ValueTypeProcess.java @@ -0,0 +1,106 @@ +package weaver.bokang.xiao.zscq.config.process; + +import aiyh.utils.Util; +import aiyh.utils.annotation.MethodRuleNo; +import aiyh.utils.excention.CustomerException; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import weaver.bokang.xiao.zscq.config.entity.ConditionEntity; +import weaver.bokang.xiao.zscq.config.mapper.UpdateModeMapper; +import weaver.general.TimeUtil; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; +import java.util.function.BiFunction; + +/** + * @ClassName ValueTypeProcess + * @Author 肖博亢 + * @Date 2023/4/4 16:18 + * @Description

条件配置 - 取值类型相关处理

+ **/ +public class ValueTypeProcess { + + public static final Map, ConditionEntity, String>> SOURCE_MODE_METHOD_MAP = new HashMap<>(); + + private static final UpdateModeMapper UPDATE_MODE_MAPPER = Util.getMapper(UpdateModeMapper.class); + + public static final Logger logger = Util.getLogger(); + + static { + try { + Class valueRuleMethodClass = ValueTypeProcess.class; + Method[] methods = valueRuleMethodClass.getDeclaredMethods(); + for (Method method : methods) { + if (method.isAnnotationPresent(MethodRuleNo.class)) { + MethodRuleNo annotation = method.getAnnotation(MethodRuleNo.class); + int value = annotation.value(); + SOURCE_MODE_METHOD_MAP.put(value, (modeMap, condition) -> { + try { + return (String) method.invoke(null,modeMap, condition); + } catch (IllegalAccessException | InvocationTargetException e) { + throw new RuntimeException(e); + } + }); + } + } + }catch (Exception exception){ + logger.error("ValueTypeProcess init error !!! "+Util.getErrString(exception)); + } + } + + /** + *

默认值处理方法

+ * @param modeMap 源建模值 + * @param condition 条件实体信息 + * @return 值信息 + */ + @MethodRuleNo(value = 0, desc = "默认值") + public static String defaultValue(Map modeMap,ConditionEntity condition) { + return condition.getCusText(); + } + + /** + *

建模字段处理方法

+ * @param modeMap 源建模值 + * @param condition 条件实体信息 + * @return 值信息 + */ + @MethodRuleNo(value = 1, desc = "建模字段") + public static String modeField(Map modeMap,ConditionEntity condition) { + return Util.null2String(modeMap.get(condition.getConditionSourceFieldName())); + } + + /** + *

自定义sql处理方法

+ * @param modeMap 源建模值 + * @param condition 条件实体信息 + * @return 值信息 + */ + @MethodRuleNo(value = 2, desc = "自定义sql") + public static String cusSql(Map modeMap,ConditionEntity condition) { + String cusSqlStr = Util.null2String(condition.getCusText()); + cusSqlStr = Util.dbc2sbcCase(cusSqlStr); + if(StringUtils.isBlank(cusSqlStr)){ + throw new CustomerException("选择自定义sql时,sql字符串不能为空"); + } + if(!cusSqlStr.startsWith("select ")){ + throw new CustomerException("选择自定义sql时,不允许执行除select之外的其他危险操作 !!!"); + } + return UPDATE_MODE_MAPPER.executeCusSql(cusSqlStr, modeMap,new HashMap<>()); + } + + /** + *

当前时间处理方法

+ * @param modeMap 源建模值 + * @param condition 条件实体信息 + * @return 值信息 + */ + @MethodRuleNo(value = 3, desc = "当前时间") + public static String currentTime(Map modeMap,ConditionEntity condition) { + return TimeUtil.getCurrentTimeString(); + } + +} diff --git a/src/main/java/weaver/bokang/xiao/zscq/config/service/ModeChangeService.java b/src/main/java/weaver/bokang/xiao/zscq/config/service/ModeChangeService.java new file mode 100644 index 0000000..3d3e562 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/zscq/config/service/ModeChangeService.java @@ -0,0 +1,116 @@ +package weaver.bokang.xiao.zscq.config.service; + +import aiyh.utils.Util; +import com.alibaba.fastjson.JSON; +import org.apache.log4j.Logger; +import weaver.bokang.xiao.zscq.config.entity.AssignmentEntity; +import weaver.bokang.xiao.zscq.config.entity.ConditionEntity; +import weaver.bokang.xiao.zscq.config.entity.UpdateModeConf; +import weaver.bokang.xiao.zscq.config.function.ConditionFunction; +import weaver.bokang.xiao.zscq.config.mapper.UpdateModeMapper; +import weaver.bokang.xiao.zscq.config.process.*; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.function.BiFunction; +import java.util.stream.Collectors; + +/** + * @ClassName ModeChangeService + * @Author 肖博亢 + * @Date 2023/4/6 11:28 + * @Description

+ **/ +public class ModeChangeService { + + public final Logger logger = Util.getLogger(); + + private final UpdateModeMapper updateModeMapper = Util.getMapper(UpdateModeMapper.class); + + /** + *

更新其他建模信息

+ * @param modeMap 模块数据 + * @param formId 表单id + */ + public void changeOtherMode(Map modeMap, String formId){ + List updateModeConfList = updateModeMapper.queryUpdateModeConfByFormId(formId); + if(Objects.isNull(updateModeConfList) || updateModeConfList.isEmpty()){ + logger.error(String.format("此表单建模[%s] 未配置相关更新信息,请检查!!!",formId)); + return; + } + logger.info("配置信息 updateModeConfList==>"+ JSON.toJSONString(updateModeConfList)); + for (UpdateModeConf updateModeConf : updateModeConfList) { + List conditionList = updateModeConf.getConditionList(); + List assignmentList = updateModeConf.getAssignmentList(); + Integer dataInType = updateModeConf.getDataInType(); + Integer noRule = updateModeConf.getNoRule(); + if(noRule == 0 && conditionList.isEmpty()){ + logger.error(String.format("没有条件设置,不允许建模 %s 更新",updateModeConf.getTargetTableName())); + continue; + } + //条件sql + String whereSql = ""; + //条件数据 + Map whereParam = new HashMap<>(8); + //赋值数据 + Map assignmentMap = new HashMap<>(8); + if(Objects.nonNull(conditionList) && !conditionList.isEmpty()){ + Map> collect = conditionList.stream().collect(Collectors.groupingBy(ConditionEntity::getConditionType)); + //获取源建模数据判断条件配置列表 + List sourceConditions = collect.get(0); + //获取目标建模条件生成配置列表 + List targetConditions = collect.get(1); + boolean flag = false; + //判断源建模数据是否需要触发更新 + if(Objects.nonNull(sourceConditions) && !sourceConditions.isEmpty()) { + for (ConditionEntity sourceCondition : sourceConditions) { + BiFunction, ConditionEntity, String> valueFunction = ValueTypeProcess.SOURCE_MODE_METHOD_MAP.get(sourceCondition.getValueType()); + BiFunction conditionFunction = ConditionValueProcess.SOURCE_MODE_METHOD_MAP.get(sourceCondition.getConditionValue()); + String sourceValue = Util.null2String(modeMap.get(sourceCondition.getConditionSourceFieldName())); + String conditionValue = valueFunction.apply(modeMap, sourceCondition); + Boolean result = conditionFunction.apply(sourceValue, conditionValue); + if (result) { + flag = true; + break; + } + } + if (flag) { + continue; + } + } + //根据配置信息生成条件sql + if(Objects.nonNull(targetConditions) && !targetConditions.isEmpty()) { + for (ConditionEntity targetCondition : targetConditions) { + BiFunction, ConditionEntity, String> valueFunction = ValueTypeProcess.SOURCE_MODE_METHOD_MAP.get(targetCondition.getValueType()); + ConditionFunction, Map, String> conditionFunction = ConditionTargetProcess.TARGET_MODE_METHOD_MAP.get(targetCondition.getConditionValue()); + String sourceValue = Util.null2String(modeMap.get(targetCondition.getConditionSourceFieldName())); + String conditionValue = valueFunction.apply(modeMap, targetCondition); + Map param = new HashMap<>(8); + param.put("sourceValue", sourceValue); + param.put("conditionValue", conditionValue); + param.put("targetFieldName", targetCondition.getConditionTargetFieldName()); + whereSql = conditionFunction.apply(whereParam, param, whereSql); + } + } + } + //根据赋值配置组装数据 + if(Objects.nonNull(assignmentList) && !assignmentList.isEmpty()){ + for (AssignmentEntity assignmentEntity : assignmentList) { + BiFunction, AssignmentEntity, String> valueFunction = ValueSelectProcess.SOURCE_MODE_METHOD_MAP.get(assignmentEntity.getValueSelect()); + String assignmentValue = valueFunction.apply(modeMap, assignmentEntity); + assignmentMap.put(assignmentEntity.getAssignmentFieldName(),assignmentValue); + } + } + //执行数据操作 + ConditionFunction, Map, Map> dataInFunction = DataTypeProcess.SOURCE_MODE_METHOD_MAP.get(dataInType); + Map tableMap = new HashMap<>(8); + tableMap.put("tableName",updateModeConf.getTargetTableName()); + tableMap.put("whereSql",whereSql); + tableMap.put("operatePath",updateModeConf.getOperatePath()); + boolean executeFlag = dataInFunction.apply(assignmentMap, whereParam, tableMap); + logger.info("更新结果 executeFlag ==>"+executeFlag); + } + } +} diff --git a/src/main/java/weaver/bokang/xiao/zscq/expand/DataControlExpand.java b/src/main/java/weaver/bokang/xiao/zscq/expand/DataControlExpand.java new file mode 100644 index 0000000..32a541f --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/zscq/expand/DataControlExpand.java @@ -0,0 +1,144 @@ +package weaver.bokang.xiao.zscq.expand; + +import aiyh.utils.Util; +import com.alibaba.fastjson.JSON; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import weaver.bokang.xiao.common.mapper.ModeMapper; +import weaver.bokang.xiao.zscq.config.service.ModeChangeService; +import weaver.bokang.xiao.zscq.fun.DataControlFunction; +import weaver.bokang.xiao.zscq.store.TableNameStore; +import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew; +import weaver.hrm.User; +import weaver.soa.workflow.request.RequestInfo; + + +import java.util.*; + +/** + * @ClassName DataControlExpand + * @Author 肖博亢 + * @Date 2023/4/3 10:42 + * @Description

+ **/ +public class DataControlExpand extends AbstractModeExpandJavaCodeNew { + + private final Logger logger = Util.getLogger(); + + private final ModeMapper modeMapper = Util.getMapper(ModeMapper.class); + + private final TableNameStore tableNameStore = TableNameStore.getInstance(); + + private final ModeChangeService modeChangeService = new ModeChangeService(); + + private final Map> importTypeMap = new HashMap<>(); + + { + //手动新增处理方式 + importTypeMap.put(0,this::normalAdd); + //导入追加处理方式 + importTypeMap.put(1,this::importAddDeal); + //导入覆盖处理方式 + importTypeMap.put(2,this::importCoverDeal); + //导入更新处理方式 + importTypeMap.put(3,this::importUpdateDeal); + } + + /** + * 执行模块扩展动作 + * @param param + * param包含(但不限于)以下数据 + * user 当前用户 + * importtype 导入方式(仅在批量导入的接口动作会传输) 1 追加,2覆盖,3更新,获取方式(int)param.get("importtype") + * 导入链接中拼接的特殊参数(仅在批量导入的接口动作会传输),比如a=1,可通过param.get("a")获取参数值 + * 页面链接拼接的参数,比如b=2,可以通过param.get("b")来获取参数 + * @return 结果 + */ + @Override + public Map doModeExpand(Map param) { + Map result = new HashMap<>(8); + try { + User user = (User)param.get("user"); + int importType = Util.getIntValue(String.valueOf(param.get("importtype")),0); + RequestInfo requestInfo = (RequestInfo)param.get("RequestInfo"); + String formId = Util.null2String(param.get("formid")); + logger.info("requestInfo ==>"+JSON.toJSONString(requestInfo)); + if(Objects.nonNull(requestInfo)){ + DataControlFunction dataControlFunction = importTypeMap.get(importType); + if(Objects.nonNull(dataControlFunction)) { + dataControlFunction.deal(requestInfo, user, formId); + } + } + } catch (Exception e) { + logger.error("建模节点后附件操作执行失败==>"+Util.getErrString(e)); + result.put("errmsg",e.getMessage()); + result.put("flag", "false"); + } + return result; + } + + /** + *

普通处理逻辑

+ * @param requestInfo 建模数据 + * @param user 用户信息 + * @param formId 表单id + */ + public void normalDeal(RequestInfo requestInfo,User user,String formId){ + String modeId = requestInfo.getWorkflowid(); + String dataId = requestInfo.getRequestid(); + String tableName = Util.null2String(tableNameStore.getTableNameStore().get(formId)); + if(StringUtils.isBlank(tableName)){ + tableName = modeMapper.queryTableName(formId); + tableNameStore.getTableNameStore().put(formId,tableName); + } + logger.info(String.format("建模id [modeId:%s],[dataId:%s],[tableName:%s]",modeId,dataId,tableName)); + Map queryParam = new HashMap<>(); + queryParam.put("fieldName","id"); + queryParam.put("fieldValue",dataId); + Map modeData = modeMapper.queryModeDataInfo(tableName, queryParam); + if(Objects.nonNull(modeData)){ + modeChangeService.changeOtherMode(modeData,formId); + } + } + + + /** + *

普通新增,编辑处理

+ * @param requestInfo 建模数据 + * @param user 用户信息 + * @param formId 表单id + */ + public void normalAdd(RequestInfo requestInfo,User user,String formId){ + normalDeal(requestInfo,user,formId); + } + + /** + *

导入追加处理

+ * @param requestInfo 建模数据 + * @param user 用户信息 + * @param formId 表单id + */ + public void importAddDeal(RequestInfo requestInfo,User user,String formId){ + normalDeal(requestInfo,user,formId); + } + + /** + *

导入覆盖处理

+ * @param requestInfo 建模数据 + * @param user 用户信息 + * @param formId 表单id + */ + public void importCoverDeal(RequestInfo requestInfo,User user,String formId){ + normalDeal(requestInfo,user,formId); + } + + /** + *

导入更新处理

+ * @param requestInfo 建模数据 + * @param user 用户信息 + * @param formId 表单id + */ + public void importUpdateDeal(RequestInfo requestInfo,User user,String formId){ + normalDeal(requestInfo,user,formId); + } +} diff --git a/src/main/java/weaver/bokang/xiao/zscq/fun/DataControlFunction.java b/src/main/java/weaver/bokang/xiao/zscq/fun/DataControlFunction.java new file mode 100644 index 0000000..6c17dac --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/zscq/fun/DataControlFunction.java @@ -0,0 +1,19 @@ +package weaver.bokang.xiao.zscq.fun; + +/** + * @ClassName DataControlFunction + * @Author 肖博亢 + * @Date 2023/4/4 15:03 + * @Description

+ **/ +@FunctionalInterface +public interface DataControlFunction { + + /** + *

数据控制自定义处理方法

+ * @param p 参数 + * @param q 参数 + * @param t 参数 + */ + void deal(P p,Q q,T t); +} diff --git a/src/main/java/weaver/bokang/xiao/zscq/fun/WorkflowOverOperate.java b/src/main/java/weaver/bokang/xiao/zscq/fun/WorkflowOverOperate.java new file mode 100644 index 0000000..694534e --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/zscq/fun/WorkflowOverOperate.java @@ -0,0 +1,46 @@ +package weaver.bokang.xiao.zscq.fun; + +import aiyh.utils.Util; +import weaver.bokang.xiao.zscq.config.function.CusOperateInterface; +import weaver.bokang.xiao.zscq.config.mapper.UpdateModeMapper; +import weaver.hrm.User; +import weaver.workflow.workflow.WfForceOver; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * @ClassName WorkflowOverOperate + * @Author 肖博亢 + * @Date 2023/4/7 15:01 + * @Description

流程归档处理

+ **/ +public class WorkflowOverOperate implements CusOperateInterface { + + private final UpdateModeMapper updateModeMapper = Util.getMapper(UpdateModeMapper.class); + + @Override + public void execute(Map whereParam, Map param, Map pathParam) { + logger.info(String.format("WorkflowOverOperate 自定义处理 whereParam[%s],param:[%s],pathParam:[%s]",whereParam,param,pathParam)); + String tableName = Util.null2String(param.get("tableName")); + String whereSql = Util.null2String(param.get("whereSql")); + if(!"".equals(whereSql)){ + whereSql = whereSql.replaceFirst(" and "," where "); + } + String querySql = "select * from " + tableName +whereSql; + Map modeData = updateModeMapper.executeCusSqlMap(querySql, whereParam,new HashMap<>()); + logger.info("modeData ==>"+modeData); + if(Objects.nonNull(modeData)){ + String workflowField = Util.null2String(pathParam.get("workflowField")); + String requestId = Util.null2String(modeData.get(workflowField)); + logger.info("流程强制归档 ==>"+requestId); + //流程强制归档 + WfForceOver wfForceOver = new WfForceOver(); + ArrayList arrayList = new ArrayList(); + arrayList.add(requestId); + wfForceOver.doForceOver(arrayList,new User(1)); + } + } +} diff --git a/src/main/java/weaver/bokang/xiao/zscq/mapper/StatusMapper.java b/src/main/java/weaver/bokang/xiao/zscq/mapper/StatusMapper.java new file mode 100644 index 0000000..8e3616d --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/zscq/mapper/StatusMapper.java @@ -0,0 +1,26 @@ +package weaver.bokang.xiao.zscq.mapper; + +import aiyh.utils.annotation.recordset.ParamMapper; +import aiyh.utils.annotation.recordset.SqlMapper; +import aiyh.utils.annotation.recordset.Update; + +/** + * @ClassName StatusMapper + * @Author 肖博亢 + * @Date 2023/4/7 12:45 + * @Description

+ **/ +@SqlMapper +public interface StatusMapper { + + /** + *

更新抄送的流程为已读

+ * @param requestId 流程id + * @param userIds 用户id集合 + * @return 操作结果 + */ + @Update("update workflow_currentoperator set viewtype = -2,isremark = 2 " + + "where REQUESTID = #{requestId} and userid in ($t{userIds}) and isremark = 8") + boolean changeWorkflowStatus(@ParamMapper("requestId")String requestId,@ParamMapper("userIds") String userIds); + +} diff --git a/src/main/java/weaver/bokang/xiao/zscq/store/TableNameStore.java b/src/main/java/weaver/bokang/xiao/zscq/store/TableNameStore.java new file mode 100644 index 0000000..7e9e532 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/zscq/store/TableNameStore.java @@ -0,0 +1,47 @@ +package weaver.bokang.xiao.zscq.store; + +import aiyh.utils.Util; +import com.alibaba.fastjson.JSON; +import lombok.Getter; +import org.apache.log4j.Logger; +import weaver.bokang.xiao.xhny_report.entity.pojo.CompanyEntity; +import weaver.bokang.xiao.xhny_report.mapper.VendorMapper; +import weaver.general.StaticObj; +import weaver.interfaces.datasource.DataSource; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * @ClassName VendorStore + * @Author 肖博亢 + * @Date 2023/3/17 18:31 + * @Description

+ **/ + +@Getter +public class TableNameStore { + + private final Map tableNameStore = new HashMap<>(); + + private static final Logger logger = Util.getLogger(); + + private TableNameStore(){} + + public static TableNameStore getInstance(){ + return VendorStoreHolder.VENDOR_STORE; + } + + private static class VendorStoreHolder{ + private VendorStoreHolder(){ + + } + private static final TableNameStore VENDOR_STORE = new TableNameStore(); + } +} diff --git a/src/main/java/weaver/bokang/xiao/zxyh/RepeatSubmitAction.java b/src/main/java/weaver/bokang/xiao/zxyh/RepeatSubmitAction.java new file mode 100644 index 0000000..eaaae05 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/zxyh/RepeatSubmitAction.java @@ -0,0 +1,38 @@ +package weaver.bokang.xiao.zxyh; + +import aiyh.utils.Util; +import aiyh.utils.action.SafeCusBaseAction; +import aiyh.utils.annotation.ActionDesc; +import aiyh.utils.excention.CustomerException; +import lombok.Setter; +import weaver.bokang.xiao.zxyh.mapper.WorkflowMapper; +import weaver.hrm.User; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * @ClassName RepeatSubmitAction + * @Author 肖博亢 + * @Date 2023/4/17 9:57 + * @Description

+ **/ +@Setter +@ActionDesc(value = "同一流程提交限制",author = "bokang.xiao") +public class RepeatSubmitAction extends SafeCusBaseAction { + + private final WorkflowMapper workflowMapper = Util.getMapper(WorkflowMapper.class); + + @Override + public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) { + log.info(String.format("=================== {%s} {requestId : %s,userId: %s} begin ======================", this.getClass().getName(),requestId,user.getUID())); + List> maps = workflowMapper.queryNoCompleteCount(workflowId + "", user.getUID()); + if(Objects.nonNull(maps) && !maps.isEmpty()){ + Map workflowInfo = maps.get(0); + String errorMsg = "您发起的流程: "+Util.null2String(workflowInfo.get("requestname"))+" (requestId:"+Util.null2String(workflowInfo.get("requestid"))+") 未归档!不允许再次发起流程"; + throw new CustomerException(errorMsg); + } + } +} diff --git a/src/main/java/weaver/bokang/xiao/zxyh/mapper/WorkflowMapper.java b/src/main/java/weaver/bokang/xiao/zxyh/mapper/WorkflowMapper.java new file mode 100644 index 0000000..62eaa84 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/zxyh/mapper/WorkflowMapper.java @@ -0,0 +1,27 @@ +package weaver.bokang.xiao.zxyh.mapper; + +import aiyh.utils.annotation.recordset.ParamMapper; +import aiyh.utils.annotation.recordset.Select; +import aiyh.utils.annotation.recordset.SqlMapper; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName WorkflowMapper + * @Author 肖博亢 + * @Date 2023/4/17 10:02 + * @Description

+ **/ +@SqlMapper +public interface WorkflowMapper { + + /** + *

查询还未归档的流程数量

+ * @param workflowId 流程id + * @param userId 用户id + * @return 未归档流程总数 + */ + @Select("select requestid,requestname,currentnodeid from workflow_requestbase where workflowid = #{workflowId} and creater = #{userId} and currentnodetype <> 3") + List> queryNoCompleteCount(@ParamMapper("workflowId")String workflowId, @ParamMapper("userId") int userId); +} diff --git a/src/main/java/weaver/xiao/commons/config/service/DealWithMapping.java b/src/main/java/weaver/xiao/commons/config/service/DealWithMapping.java index e673c4d..01a10f9 100644 --- a/src/main/java/weaver/xiao/commons/config/service/DealWithMapping.java +++ b/src/main/java/weaver/xiao/commons/config/service/DealWithMapping.java @@ -123,7 +123,7 @@ public class DealWithMapping extends ToolUtil { continue; } if ("DOUBLE".equalsIgnoreCase(type)) { - map.put(key, rs.getDouble(i)); + map.put(key,Util.getDoubleValue(rs.getString(i))); continue; } if ("DECIMAL".equalsIgnoreCase(type) || "NUMERIC".equalsIgnoreCase(type)) { @@ -466,6 +466,9 @@ public class DealWithMapping extends ToolUtil { tempList.add(map); } } + else { + tempList.add(o); + } } // tempList.addAll(list); requestParam.put(paramName, tempList); @@ -557,6 +560,9 @@ public class DealWithMapping extends ToolUtil { tempList.add(map); } } + else{ + tempList.add(o); + } } // tempList.addAll(list); requestParam.put(paramName, tempList); diff --git a/src/test/java/bokang/xiao/NormalTest.java b/src/test/java/bokang/xiao/NormalTest.java index 54e5a24..7b03a1d 100644 --- a/src/test/java/bokang/xiao/NormalTest.java +++ b/src/test/java/bokang/xiao/NormalTest.java @@ -11,22 +11,32 @@ import bokang.xiao.entity.TeacherEntity; import cn.afterturn.easypoi.excel.ExcelExportUtil; import cn.afterturn.easypoi.excel.entity.ExportParams; import com.api.bokang.xiao.porsche_review.mapper.ReviewMapper; -import com.api.bokang.xiao.porsche_review.service.impl.ReviewServiceImpl; + import com.api.bokang.xiao.wx_report.mapper.ReportMapper; import com.api.bokang.xiao.wx_report.service.ReportService; import com.api.bokang.xiao.wx_report.service.impl.ReportServiceImpl; +import com.api.bokang.xiao.zscq.service.ReserveService; +import com.api.bokang.xiao.zscq.service.impl.ReserveServiceImpl; import org.apache.log4j.Logger; import org.apache.poi.ss.usermodel.Workbook; import org.junit.Test; +import weaver.bokang.xiao.common.mapper.ModeMapper; +import weaver.bokang.xiao.deg_repeat_check.action.RepeatCheckAction; +import weaver.bokang.xiao.xhny_mode.search.CustomSearchDepart; import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData; import weaver.bokang.xiao.xhny_report.schedule.GenerateReportSchedule; import weaver.bokang.xiao.xhny_report.service.chain.AbstractScoreChain; import weaver.bokang.xiao.xhny_report.service.ScoreChainPattern; +import weaver.bokang.xiao.zscq.action.OneNetComAction; +import weaver.bokang.xiao.zscq.action.StatusChangeAction; +import weaver.bokang.xiao.zscq.config.service.ModeChangeService; +import weaver.bokang.xiao.zxyh.RepeatSubmitAction; import weaver.conn.RecordSet; -import weaver.conn.RecordSetDataSource; import weaver.general.StaticObj; import weaver.hrm.User; +import weaver.integration.util.SessionUtil; import weaver.interfaces.datasource.DataSource; +import weaver.workflow.workflow.WfForceOver; import weaver.workflow.workflow.WorkflowVersion; import weaver.xiao.commons.utils.DocImageFileUtil; @@ -47,7 +57,9 @@ public class NormalTest extends BaseTest { @Test public void testWord(){ - GenerateFileUtil.createCronJobDocument(GenerateReportSchedule.class); + //GenerateFileUtil.createCronJobDocument(GenerateReportSchedule.class); + //GenerateFileUtil.createActionDocument(OneNetComAction.class); + GenerateFileUtil.createActionDocument(RepeatSubmitAction.class); } @Test @@ -73,6 +85,51 @@ public class NormalTest extends BaseTest { System.out.println(map); } + @Test + public void testReq() throws IOException { + OneNetComAction oneNetComAction = new OneNetComAction(); + oneNetComAction.setAcceptApiName("7aeef960-bd05-11eb-8742-b3a71c8ea78a"); + oneNetComAction.setAppId("47689022-11cc-43c9-a31a-212df7cf4188"); + oneNetComAction.setAppKey("4dd90db2a76042fc811715dc58e0f9b9"); + Map header = oneNetComAction.getHeader("7aeef960-bd05-11eb-8742-b3a71c8ea78a"); + HttpUtils httpUtils = new HttpUtils(); + Map param = new HashMap<>(); + param.put("applyNo","030244223000002"); + param.put("result","受理"); + ResponeVo responeVo1 = httpUtils.apiPost("http://183.194.243.82/clientgateway/", param, header); + System.out.println(responeVo1); + ResponeVo responeVo = httpUtils.apiPostObject("http://183.194.243.82/clientgateway/", "{" + + "\"applyNo\": \"030244223000002\"," + + "\"result\" : \"受理\"," + + "\"method\" : \"窗口受理\"," + + "\"suggestion\" : \"受理\"," + + "\"opDepartCode\" : \"SHZCSH\"," + + "\"opDepartName\" : \"上海市知识产权局\"," + + "\"opUserId\": \"229726\"," + + "\"opUsername\": \"李四\"," + + "\"opTime\": \"2018-09-09 23:31:22\"" + + "}", header); + System.out.println(responeVo); + } + + @Test + public void testFilter(){ + List> list = new ArrayList<>(); + for (int i = 0; i < 4; i++) { + Map map = new HashMap<>(); + map.put("id",1); + if(i == 3){ + map.put("id",-1); + } + list.add(map); + } + long id = list.stream().filter(item -> item.get("id") == 2).count(); + System.out.println(list); + list.sort(Comparator.comparingInt(o -> weaver.general.Util.getIntValue(o.get("id")))); + System.out.println(list); + + } + @Test public void testDataSource(){ DataSource ds = (DataSource) StaticObj.getServiceByFullname(("datasource.NCC"),DataSource.class); @@ -240,4 +297,48 @@ public class NormalTest extends BaseTest { GenerateFileUtil.createCronJobDocument(); } + @Test + public void testUpdateModeConf(){ + ModeChangeService modeChangeService = new ModeChangeService(); + Map queryParam = new HashMap<>(); + queryParam.put("fieldName","uuid"); + queryParam.put("fieldValue","mqErrorLogModelId"); + ModeMapper mapper = Util.getMapper(ModeMapper.class); + Map modeData = mapper.queryModeDataInfo("uf_systemconfig", queryParam); + modeChangeService.changeOtherMode(modeData,"-18"); + } + + @Test + public void testOver(){ + WfForceOver wfForceOver = new WfForceOver(); + ArrayList arrayList = new ArrayList(); + arrayList.add("342350"); + wfForceOver.doForceOver(arrayList,new User(1)); + + } + + @Test + public void testRes(){ + ReserveService reserveService = new ReserveServiceImpl(); + Map param = new HashMap<>(); + param.put("modeTableName","uf_contract_num_log"); + param.put("dateField","month"); + param.put("checkResultField","detail_id"); + param.put("workflowInfoField","workflow_info"); + param.put("checkResultValue","1"); + param.put("repossessedValue","0"); + param.put("applicationNoField","contract_num"); + param.put("datePicker","2023-04"); + reserveService.reserveSelect(param); + } + + @Test + public void testSqlCondition() throws Exception { + Map param = new HashMap<>(); + param.put("user",new User(45)); + param.put("customid",2); + CustomSearchDepart customSearchDepart = new CustomSearchDepart(); + String s = customSearchDepart.generateSqlCondition(param); + } + }