From 7f5087a6ee996e585b0f0663fec0ee5b03911c76 Mon Sep 17 00:00:00 2001 From: wangxuanran <3055088966@qq.com> Date: Mon, 10 Jul 2023 15:56:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=9B=B4=E6=96=B0=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aiyh/utils/recordset/RecordsetUtil.java | 6 +- .../getlog/controller/GetLogController.java | 33 ++- .../common/getlog/service/GetLogService.java | 30 ++- .../common/getlog/util/GetLogUtil.java | 4 +- .../util/EyCusModelFieldValueRuleMethod.java | 5 +- .../shyl/service/UserUpdateToMQService.java | 2 +- .../shyl/service/impl/UpdateHrmInfoAop.java | 54 ++-- .../action/ChildWorkFlowSplitAction.java | 107 ++++++++ .../mapper/ChildWorkFlowSplitMapper.java | 52 ++++ .../common/entity/CusResponseSuccess.java | 38 +++ .../wang/common/mapper/CommonMapper.java | 24 ++ .../xuanran/wang/common/util/TokenUtil.java | 11 + .../xuanran/wang/cssc/cms/WorkflowToCms.java | 17 ++ .../wang/cssc/cms/entity/CusSuccess.java | 2 + .../cms/service/WorkflowToCmsService.java | 6 +- .../impl/WorkFlowToCmsServiceImpl.java | 42 ++- .../cssc/cms/util/RequestMasterPlate.java | 83 +++++- .../sh_bigdata/common/entity/CusSuccess.java | 2 +- .../common/util/SendTodoTaskUtil.java | 26 +- .../task_async/entity/CusDoneTask.java | 1 + .../task_async/entity/CusTodoLeaderTask.java | 17 -- .../task_async/entity/CusTodoTask.java | 1 + .../entity/CusTodoTaskToOADetail.java | 5 + .../task_async/mapper/SendTodoTaskMapper.java | 4 +- .../service/impl/SendTodoTaskServiceImpl.java | 6 +- .../wang/shyl_mq/mapper/ConsumerMapper.java | 11 + .../service/impl/PassWordServiceImpl.java | 14 +- src/test/java/xuanran/wang/ajx/TestA.java | 85 +++++++ .../xuanran/wang/big_data/BigDataTest.java | 6 - .../xuanran/wang/common/test/ServiceTest.java | 10 + .../http_test/rest_test/CusRestTemplate.java | 240 ++++++++++++++++++ .../xuanran/wang/http_test/rest_test/Stu.java | 19 ++ .../xuanran/wang/http_test/test/TestMain.java | 57 +++++ .../java/xuanran/wang/immc/Kafka/MQTest.java | 24 +- .../wang/shyl/dataasync/TestPassword.java | 56 +++- 35 files changed, 970 insertions(+), 130 deletions(-) create mode 100644 src/main/java/weaver/xuanran/wang/ajx/work_flow_split/action/ChildWorkFlowSplitAction.java create mode 100644 src/main/java/weaver/xuanran/wang/ajx/work_flow_split/mapper/ChildWorkFlowSplitMapper.java create mode 100644 src/main/java/weaver/xuanran/wang/common/entity/CusResponseSuccess.java delete mode 100644 src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/entity/CusTodoLeaderTask.java create mode 100644 src/test/java/xuanran/wang/ajx/TestA.java create mode 100644 src/test/java/xuanran/wang/http_test/rest_test/CusRestTemplate.java create mode 100644 src/test/java/xuanran/wang/http_test/rest_test/Stu.java create mode 100644 src/test/java/xuanran/wang/http_test/test/TestMain.java diff --git a/src/main/java/aiyh/utils/recordset/RecordsetUtil.java b/src/main/java/aiyh/utils/recordset/RecordsetUtil.java index e810df1..46a7653 100644 --- a/src/main/java/aiyh/utils/recordset/RecordsetUtil.java +++ b/src/main/java/aiyh/utils/recordset/RecordsetUtil.java @@ -14,6 +14,7 @@ import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; /** @@ -64,7 +65,10 @@ public class RecordsetUtil implements InvocationHandler { private Object invokeDefault(int type, String sql, boolean custom, RecordSet rs, Method method, Object[] args) { SqlHandler sqlHandler = new SqlHandler(); ResultMapper resultMapper = new ResultMapper(); - PrepSqlResultImpl handler = sqlHandler.handler(sql, custom, method, args); + PrepSqlResultImpl handler = null; + if(Arrays.asList(1,2,3,4).contains(type)){ + handler = sqlHandler.handler(sql, custom, method, args); + } String invokeMethod = method.getDeclaringClass().getName() + ":" + method.getName() + " : "; switch (type) { case 1: { diff --git a/src/main/java/com/api/ebu7dev1/common/getlog/controller/GetLogController.java b/src/main/java/com/api/ebu7dev1/common/getlog/controller/GetLogController.java index 094f782..1987755 100644 --- a/src/main/java/com/api/ebu7dev1/common/getlog/controller/GetLogController.java +++ b/src/main/java/com/api/ebu7dev1/common/getlog/controller/GetLogController.java @@ -2,9 +2,11 @@ package com.api.ebu7dev1.common.getlog.controller; import aiyh.utils.ApiResult; import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; import com.alibaba.fastjson.JSONObject; import com.api.ebu7dev1.common.getlog.service.GetLogService; import io.swagger.v3.oas.annotations.parameters.RequestBody; +import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; import weaver.hrm.HrmUserVarify; import weaver.hrm.User; @@ -12,13 +14,12 @@ import weaver.interfaces.schedule.IpSelectUtil; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; +import javax.ws.rs.*; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import java.io.*; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -52,6 +53,30 @@ public class GetLogController { return ApiResult.error("获取ip节点出错!"); } } + + @GET + @Path("/down") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response downloadZip(@Context HttpServletRequest request, + @Context HttpServletResponse response){ + try { + String zipPath = request.getParameter("zipPath"); + String fileName = request.getParameter("fileName"); + if(StringUtils.isBlank(zipPath) || StringUtils.isBlank(fileName)){ + throw new CustomerException("zipPath or fileName can not be null!"); + } + response.setHeader("Access-Control-Allow-Origin", "*"); + response.setHeader("Access-Control-Allow-Methods","GET, POST, PUT, DELETE"); + response.setHeader("Access-Control-Allow-Headers", "Content-Type"); + String ecPath = request.getRealPath("/"); + StreamingOutput output = service.downloadZip(ecPath + File.separator + zipPath); + return Response.ok(output, MediaType.APPLICATION_OCTET_STREAM).header("Content-Disposition", "attachment; filename*=UTF-8''" + fileName).build(); + }catch (Exception e){ + log.error("下载zip文件异常 : "); + log.error(Util.getErrString(e)); + return null; + } + } @GET @Path("get") diff --git a/src/main/java/com/api/ebu7dev1/common/getlog/service/GetLogService.java b/src/main/java/com/api/ebu7dev1/common/getlog/service/GetLogService.java index 02152c8..51d4d73 100644 --- a/src/main/java/com/api/ebu7dev1/common/getlog/service/GetLogService.java +++ b/src/main/java/com/api/ebu7dev1/common/getlog/service/GetLogService.java @@ -13,8 +13,8 @@ import weaver.hrm.User; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import java.io.File; -import java.io.FileNotFoundException; +import javax.ws.rs.core.StreamingOutput; +import java.io.*; import java.util.*; import static net.qiyuesuo.sdk.bean.template.MimeType.zip; @@ -78,6 +78,32 @@ public class GetLogService { return ipList; } + public StreamingOutput downloadZip(String zipPath){ + log.info("压缩文件路径 : [ " + zipPath + " ]"); + return outputStream -> { + FileInputStream inputStream = null; + BufferedInputStream bufferedInputStream = null; + try { + byte[] buffer = new byte[1024]; + int bytesRead; + inputStream = new FileInputStream(zipPath); + bufferedInputStream = new BufferedInputStream(inputStream); + while ((bytesRead = bufferedInputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, bytesRead); + } + }catch (IOException e){ + throw new IOException(e); + }finally { + if(bufferedInputStream != null){ + bufferedInputStream.close(); + } + if(inputStream != null){ + inputStream.close(); + } + } + }; + } + /** *

<收集全部节点日志/h1> * @author xuanran.wang diff --git a/src/main/java/com/api/ebu7dev1/common/getlog/util/GetLogUtil.java b/src/main/java/com/api/ebu7dev1/common/getlog/util/GetLogUtil.java index ca0b6fb..185545c 100644 --- a/src/main/java/com/api/ebu7dev1/common/getlog/util/GetLogUtil.java +++ b/src/main/java/com/api/ebu7dev1/common/getlog/util/GetLogUtil.java @@ -292,7 +292,8 @@ public class GetLogUtil { e.printStackTrace(); } String innerIp = getInnerIp(); - String zipFile = File.separator + innerIp + "_downLog.zip"; + String fileName = innerIp + "_downLog.zip"; + String zipFile = File.separator + fileName; String outLogPath = outFile + zipFile; res = res + zipFile; fos = new FileOutputStream(outLogPath); @@ -332,6 +333,7 @@ public class GetLogUtil { } result.put("ip", innerIp); result.put("zipPath", res); + result.put("fileName", fileName); return result; } diff --git a/src/main/java/com/api/nonstandardext/model_field_async/util/EyCusModelFieldValueRuleMethod.java b/src/main/java/com/api/nonstandardext/model_field_async/util/EyCusModelFieldValueRuleMethod.java index 857fba8..4f789f2 100644 --- a/src/main/java/com/api/nonstandardext/model_field_async/util/EyCusModelFieldValueRuleMethod.java +++ b/src/main/java/com/api/nonstandardext/model_field_async/util/EyCusModelFieldValueRuleMethod.java @@ -7,7 +7,6 @@ import com.api.nonstandardext.model_field_async.interfaces.TriFunction; import com.api.nonstandardext.model_field_async.mapper.ModelFieldAsyncMapper; import com.google.common.base.Strings; import org.apache.log4j.Logger; -import weaver.xuanran.wang.eny.data_async.service.convert.CusAsyncConvert; import com.api.nonstandardext.model_field_async.service.convert.CusModelFieldAsyncConvert; import java.lang.reflect.InvocationTargetException; @@ -84,8 +83,8 @@ public class EyCusModelFieldValueRuleMethod { } try { Class clazz = Class.forName(cusText); - if(!CusAsyncConvert.class.isAssignableFrom(clazz)){ - throw new CustomerException(cusText + " not implements getLogFilePath.api.nonstandardext.model_field_async.service.convert"); + if(!CusModelFieldAsyncConvert.class.isAssignableFrom(clazz)){ + throw new CustomerException(cusText + " not implements com.api.nonstandardext.model_field_async.service.convert.CusModelFieldAsyncConvert"); } CusModelFieldAsyncConvert o = (CusModelFieldAsyncConvert) clazz.newInstance(); Map pathParam = Util.parseCusInterfacePathParam(cusText); diff --git a/src/main/java/com/api/xuanran/wang/shyl/service/UserUpdateToMQService.java b/src/main/java/com/api/xuanran/wang/shyl/service/UserUpdateToMQService.java index 04556e1..51b9a65 100644 --- a/src/main/java/com/api/xuanran/wang/shyl/service/UserUpdateToMQService.java +++ b/src/main/java/com/api/xuanran/wang/shyl/service/UserUpdateToMQService.java @@ -80,7 +80,7 @@ public class UserUpdateToMQService { logger.error(Util.logStr("userId:{}, 生成json为空!",id)); return; } - if("1".equals(debug)){ + if(!"1".equals(debug)){ logger.info("update user json : \n" + JSONObject.toJSONString(param)); return; } diff --git a/src/main/java/com/customization/shyl/service/impl/UpdateHrmInfoAop.java b/src/main/java/com/customization/shyl/service/impl/UpdateHrmInfoAop.java index 1a21a89..faf2c94 100644 --- a/src/main/java/com/customization/shyl/service/impl/UpdateHrmInfoAop.java +++ b/src/main/java/com/customization/shyl/service/impl/UpdateHrmInfoAop.java @@ -38,22 +38,31 @@ public class UpdateHrmInfoAop { */ @WeaReplaceBefore(value = "/api/hrm/password/changePassword", order = 1, description = "人员信息修改前 进行拦截") public void passwordUpdateBefore(WeaBeforeReplaceParam weaBeforeReplaceParam) { - Map paramMap = weaBeforeReplaceParam.getParamMap(); - String newPassword = Util.null2DefaultStr(paramMap.get("passwordnew"),""); - if(StringUtils.isBlank(newPassword)){ - Util.getLogger().error("下发队列新密码不能为空!"); - return; + try { + Map paramMap = weaBeforeReplaceParam.getParamMap(); + HttpServletRequest request = weaBeforeReplaceParam.getRequest(); + String newPassword = Util.null2DefaultStr(paramMap.get("passwordnew"),""); + if(StringUtils.isBlank(newPassword)){ + Util.getLogger().error("下发队列新密码不能为空!"); + return; + } + if(service == null){ + service = new UserUpdateToMQService(); + } + HttpServletResponse response = weaBeforeReplaceParam.getResponse(); + User user = HrmUserVarify.getUser(request, response); + String loginId = user.getLoginid(); + Map configMap = getMQConfigMap(); + String oaPassWordOnlyMark = configMap.get("oaPassWordOnlyMark"); + String oaPassWordTopicConfigName = configMap.get("oaPassWordTopicConfigName"); + String decryPassword = RocketConsumerUtil.encryptContent(Util.null2DefaultStr(parsePassword(request, newPassword, newPassword, loginId),"")); + Map map = new HashMap<>(); + map.put("decryPassword", decryPassword); + service.toMQ(String.valueOf(user.getUID()),oaPassWordOnlyMark, oaPassWordTopicConfigName, configMap.get("sendMQ"), map); + }catch (Exception e){ + Util.getLogger().error("/api/hrm/password/changePassword 下发队列失败! " + e.getMessage()); + Util.getLogger().error(Util.getErrString(e)); } - Map configMap = getMQConfigMap(); - HttpServletRequest request = weaBeforeReplaceParam.getRequest(); - HttpServletResponse response = weaBeforeReplaceParam.getResponse(); - User user = HrmUserVarify.getUser(request, response); - String oaPassWordOnlyMark = configMap.get("oaPassWordOnlyMark"); - String oaPassWordTopicConfigName = configMap.get("oaPassWordTopicConfigName"); - String decryPassword = RocketConsumerUtil.encryptContent(newPassword); - Map map = new HashMap<>(); - map.put("decryPassword", decryPassword); - service.toMQ(String.valueOf(user.getUID()),oaPassWordOnlyMark, oaPassWordTopicConfigName, configMap.get("sendMQ"), map); } /** @@ -75,18 +84,22 @@ public class UpdateHrmInfoAop { Util.getLogger().error("从接口中获取人员id为空!"); return; } + String password = weaver.general.Util.null2String(request.getParameter("password")); + String password1 = weaver.general.Util.null2String(request.getParameter("password1")); + String loginId = weaver.general.Util.null2String(request.getParameter("loginid")); // 解密后的密码 - String decryPassword = RocketConsumerUtil.encryptContent(Util.null2DefaultStr(parsePassword(request),"")); + String decryPassword = RocketConsumerUtil.encryptContent(Util.null2DefaultStr(parsePassword(request, password, password1, loginId),"")); Map map = new HashMap<>(); map.put("decryPassword", decryPassword); if(StringUtils.isBlank(decryPassword)){ Util.getLogger().error("解密之后密码为空!"); return; } + Util.getLogger().info("decryPassword : " + decryPassword); service.toMQ(id,oaPassWordOnlyMark, oaPassWordTopicConfigName, configMap.get("sendMQ"), map); }catch (Exception e){ Util.getLogger().error("/api/hrm/systeminfo/save 拦截前置接口出错! " + e.getMessage()); - Util.getErrString(e); + Util.getLogger().error(Util.getErrString(e)); } } @@ -97,16 +110,15 @@ public class UpdateHrmInfoAop { * @param request 请求对象 * @return 解密后的数据 **/ - private String parsePassword(HttpServletRequest request){ - String password = weaver.general.Util.null2String(request.getParameter("password")); - String loginId = weaver.general.Util.null2String(request.getParameter("loginid")); + public String parsePassword(HttpServletRequest request, String password, String password1, String loginId){ boolean isRsa = "1".equals(Prop.getPropValue("openRSA", "isrsaopen")); ArrayList passwordList = new ArrayList<>(); if (isRsa) { passwordList.add(password); + passwordList.add(password1); RSA rsa = new RSA(); List list = rsa.decryptList(request, passwordList); - return Util.null2DefaultStr(list.get(0),""); + password = Util.null2DefaultStr(list.get(0),""); } Util.getLogger().info("loginId : [ " + loginId + " ], password : [ " + password + " ]"); return password; diff --git a/src/main/java/weaver/xuanran/wang/ajx/work_flow_split/action/ChildWorkFlowSplitAction.java b/src/main/java/weaver/xuanran/wang/ajx/work_flow_split/action/ChildWorkFlowSplitAction.java new file mode 100644 index 0000000..28cc18b --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/ajx/work_flow_split/action/ChildWorkFlowSplitAction.java @@ -0,0 +1,107 @@ +package weaver.xuanran.wang.ajx.work_flow_split.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 com.alibaba.fastjson.JSONObject; +import lombok.Setter; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.hrm.User; +import weaver.soa.workflow.request.RequestInfo; +import weaver.xuanran.wang.ajx.work_flow_split.mapper.ChildWorkFlowSplitMapper; + +import java.util.*; +import java.util.stream.Collectors; + +/** + *

主流程拆分

+ * + * @author xuanran.wang + * @date 2023/7/10 10:46 + */ +@Setter +@ActionDesc(author = "xuanran.wang", value = "子流程拆分明细") +public class ChildWorkFlowSplitAction extends SafeCusBaseAction { + + @RequiredMark(value = "zth", desc = "子流程查询明细帐套号字段名") + @PrintParamMark + private String selectAccountNumberField; + + @ActionOptionalParam(value = "zth", desc = "插入明细的帐套号字段名 默认与子流程查询明细帐套号字段名一致") + @PrintParamMark + private String insertAccountNumberField; + + @ActionOptionalParam(value = "0", desc = "查询明细下标 明细1传0, 明细2传1") + @PrintParamMark + private String selectDetailNo = "0"; + + @ActionOptionalParam(value = "2", desc = "插入明细下标 正常传 明细1就传1 明细2就传2") + @PrintParamMark + private String insertDetailNo = "2"; + + @RequiredMark(value = "sfcfzlc", desc = "是否包含多账套字段名") + @PrintParamMark + private String hasMoreAccountField; + + @RequiredMark(value = "1", desc = "包含多账套字段值 是/否 0:1") + @PrintParamMark + private String hasMoreAccountFieldValue; + + private final ChildWorkFlowSplitMapper mapper = Util.getMapper(ChildWorkFlowSplitMapper.class); + + @Override + public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) { + try { + Map mainMap = getMainTableValue(requestInfo); + String id = mainMap.get("id"); + if(StringUtils.isBlank(id)){ + throw new CustomerException("id is empty!"); + } + // 查明细数据 + List> detailInfo = getDetailTableValueByDetailNo(Util.getIntValue(selectDetailNo,0), requestInfo); + if(CollectionUtils.isEmpty(detailInfo)){ + log.error("detail " + selectDetailNo + " table info is empty!"); + return; + } + Set accountNumber = detailInfo.stream().map(item -> item.get(selectAccountNumberField)).collect(Collectors.toSet()); + if(CollectionUtils.isEmpty(accountNumber) || accountNumber.size() == 1){ + log.error("明细数据根据帐套号分组后为空, 或不存在多个帐套!"); + log.info("accountNumber : [ " + JSONObject.toJSONString(accountNumber) + " ]"); + // 如果不存在多帐套那么将主表数据hasMoreAccountField 更新为null + if (!mapper.updateMainTable(billTable, hasMoreAccountField, null, requestId)) { + throw new CustomerException("更新主表是否包含多账套字段失败!"); + } + return; + } + if (!mapper.updateMainTable(billTable, hasMoreAccountField, hasMoreAccountFieldValue, requestId)) { + throw new CustomerException("更新主表是否包含多账套字段失败!"); + } + List> insertList = accountNumber.stream() + .map(item -> { + Map map = new HashMap<>(); + map.put("mainId", id); + map.put("insertAccountNumber", item); + return map; + }).collect(Collectors.toList()); + // 如果插入表的帐套号字段名配置为空 那么与插入表的字段名保持一致 + if(StringUtils.isBlank(this.insertAccountNumberField)){ + this.insertAccountNumberField = selectAccountNumberField; + } + boolean delete = mapper.selectAccountNumber(mainMap.get("id"), billTable + "_dt" + insertDetailNo); + if(!delete){ + throw new CustomerException("删除明细表数据失败!"); + } + if (!mapper.insertDetailTable(billTable + "_dt" + insertDetailNo, this.insertAccountNumberField, insertList)) { + throw new CustomerException("批量插入明细数据失败!"); + } + }catch (Exception e){ + throw new CustomerException("子流程明细拆分action执行失败!",e); + } + } + +} diff --git a/src/main/java/weaver/xuanran/wang/ajx/work_flow_split/mapper/ChildWorkFlowSplitMapper.java b/src/main/java/weaver/xuanran/wang/ajx/work_flow_split/mapper/ChildWorkFlowSplitMapper.java new file mode 100644 index 0000000..c4720eb --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/ajx/work_flow_split/mapper/ChildWorkFlowSplitMapper.java @@ -0,0 +1,52 @@ +package weaver.xuanran.wang.ajx.work_flow_split.mapper; + +import aiyh.utils.annotation.recordset.*; + +import java.util.List; +import java.util.Map; + +/** + *

+ * + * @author xuanran.wang + * @date 2023/7/10 10:53 + */ +@SqlMapper +public interface ChildWorkFlowSplitMapper { + /** + *

更新主表是否包含多帐套

+ * @author xuanran.wang + * @dateTime 2023/7/10 11:48 + * @param tableName 主表表名 + * @param hasMoreAccountField 是否包含多帐套 + * @param hasMoreAccountFieldValue 包含多帐套 + * @param requestId 请求id + **/ + @Update("update $t{tableName} set $t{hasMoreAccountField} = #{hasMoreAccountFieldValue} where requestid = #{requestId}") + boolean updateMainTable(@ParamMapper("tableName") String tableName, + @ParamMapper("hasMoreAccountField") String hasMoreAccountField, + @ParamMapper("hasMoreAccountFieldValue") String hasMoreAccountFieldValue, + @ParamMapper("requestId") String requestId); + /** + *

删除明细表数据

+ * @author xuanran.wang + * @dateTime 2023/7/10 11:49 + * @param mainId 主表id + * @param detailTableName 明细下标 + **/ + @Delete("delete from $t{detailTableName} where mainid = #{mainId}") + boolean selectAccountNumber(@ParamMapper("mainId") String mainId, + @ParamMapper("detailTableName") String detailTableName); + /** + *

批量插入

+ * @author xuanran.wang + * @dateTime 2023/7/10 11:49 + * @param detailTableNo 明细下标 + * @param list 数据 + **/ + @BatchInsert("insert into $t{detailTableName} (mainid, $t{insertAccountNumberField}) " + + "values(#{item.mainId}, #{item.insertAccountNumber})") + boolean insertDetailTable(@ParamMapper("detailTableName") String detailTableNo, + @ParamMapper("insertAccountNumberField") String insertAccountNumberField, + @BatchSqlArgs List> list); +} diff --git a/src/main/java/weaver/xuanran/wang/common/entity/CusResponseSuccess.java b/src/main/java/weaver/xuanran/wang/common/entity/CusResponseSuccess.java new file mode 100644 index 0000000..304d682 --- /dev/null +++ b/src/main/java/weaver/xuanran/wang/common/entity/CusResponseSuccess.java @@ -0,0 +1,38 @@ +package weaver.xuanran.wang.common.entity; + +import aiyh.utils.httpUtil.ResponeVo; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import weaver.xuanran.wang.common.service.CusDataDecipher; + +import java.util.Map; +import java.util.function.Consumer; +import java.util.function.Function; + + +/** + *

自定义请求条件

+ * + * @author xuanran.wang + * @date 2023/4/6 19:34 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class CusResponseSuccess { + private ResponeVo vo; + private Object requestParam; + private String successField; + private Object successValue; + private String errorMsg; + private String dataKey; + private Map response; + private CusDataDecipher cusDataDecipher; + private String url; + private Exception e; + private boolean checkResponse = true; + private Consumer call; +} diff --git a/src/main/java/weaver/xuanran/wang/common/mapper/CommonMapper.java b/src/main/java/weaver/xuanran/wang/common/mapper/CommonMapper.java index d51b2b6..0fa8af6 100644 --- a/src/main/java/weaver/xuanran/wang/common/mapper/CommonMapper.java +++ b/src/main/java/weaver/xuanran/wang/common/mapper/CommonMapper.java @@ -1,6 +1,7 @@ package weaver.xuanran.wang.common.mapper; import aiyh.utils.annotation.recordset.*; +import emo.macro.ob.OB; import java.util.List; import java.util.Map; @@ -124,4 +125,27 @@ public interface CommonMapper { @BatchInsert(custom = true) boolean batchInsertModel(@SqlString String sql,@BatchSqlArgs List> collect); + + /** + *

通过requestId查询流程数据

+ * @param requestId requestId + * @param tableName 流程表名 + * @return 流程数据 + */ + @Select("select * from $t{tableName} where requestid = #{requestId}") + Map queryWorkflowByRequestId(@ParamMapper("requestId") String requestId, + @ParamMapper("tableName") String tableName); + + + /** + *

通过requestId查询流程数据

+ * @param requestId requestId + * @param tableName 流程表名 + * @return 流程数据 + */ + @Select("select * from $t{tableName} " + + "where mainid = #{mainId}") + List>queryWorkflowByMainId(@ParamMapper("mainId") String mainId,@ParamMapper("tableName") String tableName); + + } diff --git a/src/main/java/weaver/xuanran/wang/common/util/TokenUtil.java b/src/main/java/weaver/xuanran/wang/common/util/TokenUtil.java index 61c6045..973dc84 100644 --- a/src/main/java/weaver/xuanran/wang/common/util/TokenUtil.java +++ b/src/main/java/weaver/xuanran/wang/common/util/TokenUtil.java @@ -3,6 +3,7 @@ package weaver.xuanran.wang.common.util; import aiyh.utils.Util; import aiyh.utils.excention.CustomerException; import com.alibaba.fastjson.JSONObject; +import com.cloudstore.api.util.Util_Redis; import org.apache.log4j.Logger; import weaver.xuanran.wang.common.interfaces.CusAbstractTokenConf; @@ -18,6 +19,16 @@ import java.util.Objects; */ public class TokenUtil { private static final Map TOKEN_MAP = new HashMap<>(8); + private static Util_Redis instance = null; + private static boolean redis = false; + + { + try { + instance = Util_Redis.getInstance(); + redis = true; + }catch (Exception e){} + } + /** *

从本地缓存中获取token

* @author xuanran.wang diff --git a/src/main/java/weaver/xuanran/wang/cssc/cms/WorkflowToCms.java b/src/main/java/weaver/xuanran/wang/cssc/cms/WorkflowToCms.java index dba527a..c714809 100644 --- a/src/main/java/weaver/xuanran/wang/cssc/cms/WorkflowToCms.java +++ b/src/main/java/weaver/xuanran/wang/cssc/cms/WorkflowToCms.java @@ -7,6 +7,10 @@ import aiyh.utils.annotation.ActionOptionalParam; import aiyh.utils.annotation.PrintParamMark; import aiyh.utils.annotation.RequiredMark; import com.alibaba.fastjson.JSONObject; +import org.springframework.beans.BeanUtils; +import weaver.cssc.workflow.voucher.util.InterfaceLoggerDao; +import weaver.cssc.workflow.voucher.util.VoucherConstants; +import weaver.general.TimeUtil; import weaver.hrm.User; import weaver.soa.workflow.request.RequestInfo; import weaver.xuanran.wang.cssc.cms.entity.CusSuccess; @@ -53,6 +57,17 @@ public class WorkflowToCms extends SafeCusBaseAction { @Override public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) { log.info("-------------- " + requestId + " begin --------------"); + InterfaceLoggerDao tokenDao = workflowToCmsService.initLogDao(requestInfo); + tokenDao.setDealStatus(VoucherConstants.DEAL_STATUS_SUCCESS); + tokenDao.setDealMessage("接口调用成功!"); + // token类型 + tokenDao.setInterfaceType(2); + + InterfaceLoggerDao cmsInterfaceDao = new InterfaceLoggerDao(); + BeanUtils.copyProperties(tokenDao, cmsInterfaceDao); + // 档案集成接口 + cmsInterfaceDao.setInterfaceType(1); + CusSuccess cmsResponseVoField = CusSuccess .builder() .successField(Util.null2DefaultStr(successField, "success")) @@ -61,6 +76,7 @@ public class WorkflowToCms extends SafeCusBaseAction { .dataKey(Util.null2DefaultStr(dataKey, "")) .build(); log.info("cmsResponseVoField : " + JSONObject.toJSONString(cmsResponseVoField)); + cmsResponseVoField.setDao(cmsInterfaceDao); CusSuccess tokenSuccess = CusSuccess .builder() @@ -70,6 +86,7 @@ public class WorkflowToCms extends SafeCusBaseAction { .dataKey(Util.null2DefaultStr(tokenDataKey,"")) .build(); log.info("tokenSuccess : " + JSONObject.toJSONString(tokenSuccess)); + tokenSuccess.setDao(cmsInterfaceDao); workflowToCmsService.workflowToCms(onlyMark,tokenOnlyMark, billTable, requestId,cmsResponseVoField, tokenSuccess); } diff --git a/src/main/java/weaver/xuanran/wang/cssc/cms/entity/CusSuccess.java b/src/main/java/weaver/xuanran/wang/cssc/cms/entity/CusSuccess.java index 282ea57..972a5bf 100644 --- a/src/main/java/weaver/xuanran/wang/cssc/cms/entity/CusSuccess.java +++ b/src/main/java/weaver/xuanran/wang/cssc/cms/entity/CusSuccess.java @@ -4,6 +4,7 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import weaver.cssc.workflow.voucher.util.InterfaceLoggerDao; /** @@ -22,4 +23,5 @@ public class CusSuccess { private String errorMsg; private String dataKey; private Object response; + private InterfaceLoggerDao dao; } diff --git a/src/main/java/weaver/xuanran/wang/cssc/cms/service/WorkflowToCmsService.java b/src/main/java/weaver/xuanran/wang/cssc/cms/service/WorkflowToCmsService.java index b30454f..743d2ca 100644 --- a/src/main/java/weaver/xuanran/wang/cssc/cms/service/WorkflowToCmsService.java +++ b/src/main/java/weaver/xuanran/wang/cssc/cms/service/WorkflowToCmsService.java @@ -1,5 +1,7 @@ package weaver.xuanran.wang.cssc.cms.service; +import weaver.cssc.workflow.voucher.util.InterfaceLoggerDao; +import weaver.soa.workflow.request.RequestInfo; import weaver.xuanran.wang.cssc.cms.entity.CusSuccess; /** @@ -9,6 +11,8 @@ import weaver.xuanran.wang.cssc.cms.entity.CusSuccess; * @date 2023/4/26 10:53 */ public interface WorkflowToCmsService { + InterfaceLoggerDao initLogDao(RequestInfo requestInfo); String getToken(String onlyMark, String billTable, String requestId, CusSuccess cusSuccess); - void workflowToCms(String onlyMark,String tokenMark,String billTable, String requestId, CusSuccess cusSuccess, CusSuccess tokenSuccess); + void workflowToCms(String onlyMark,String tokenMark,String billTable, + String requestId, CusSuccess cusSuccess, CusSuccess tokenSuccess); } diff --git a/src/main/java/weaver/xuanran/wang/cssc/cms/service/impl/WorkFlowToCmsServiceImpl.java b/src/main/java/weaver/xuanran/wang/cssc/cms/service/impl/WorkFlowToCmsServiceImpl.java index bf7d5b2..fd5903e 100644 --- a/src/main/java/weaver/xuanran/wang/cssc/cms/service/impl/WorkFlowToCmsServiceImpl.java +++ b/src/main/java/weaver/xuanran/wang/cssc/cms/service/impl/WorkFlowToCmsServiceImpl.java @@ -1,13 +1,20 @@ package weaver.xuanran.wang.cssc.cms.service.impl; import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; +import sun.security.krb5.internal.PAData; import weaver.conn.RecordSet; +import weaver.conn.RecordSetTrans; +import weaver.cssc.workflow.voucher.util.InterfaceLoggerDao; +import weaver.cssc.workflow.voucher.util.VoucherConstants; +import weaver.general.TimeUtil; +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; @@ -32,6 +39,38 @@ public class WorkFlowToCmsServiceImpl implements WorkflowToCmsService { private final Logger log = Util.getLogger(); // 获取日志对象 private final RequestMasterPlate requestMasterPlate = new RequestMasterPlate(); private final SqlUtil sqlUtil = new SqlUtil(); + + @Override + public InterfaceLoggerDao initLogDao(RequestInfo requestInfo){ + InterfaceLoggerDao dao = new InterfaceLoggerDao(); + dao.setWorkflowId(Integer.parseInt(requestInfo.getWorkflowid())); + String requestId = requestInfo.getRequestid(); + dao.setSourceRequestId(requestId); + dao.setOperateDateTime(TimeUtil.getCurrentTimeString()); + //获取流程基础信息 + RecordSetTrans rsts = requestInfo.getRsTrans(); + + if(rsts == null){ + rsts = new RecordSetTrans(); + } + //流程请求编号 + String requestMark = ""; + try { + if(rsts.executeQuery("select requestMark from workflow_requestBase where requestId = ?",requestId)){ + if(rsts.next()){ + requestMark = Util.null2String(rsts.getString("requestMark")); + } + } + } catch (Exception e) { + Util.actionFailException(requestInfo.getRequestManager(),"获取流程基本信息异常,异常信息:[" + e.getMessage() + "]!"); + throw new RuntimeException(e); + } + + dao.setRequestNo(requestMark); + dao.setOperator(requestInfo.getRequestManager().getUser().getUID()); + return dao; + } + @Override public String getToken(String onlyMark,String billTable, String requestId, CusSuccess cusSuccess) { @@ -54,7 +93,8 @@ public class WorkFlowToCmsServiceImpl implements WorkflowToCmsService { **/ @Override public void workflowToCms(String onlyMark,String tokenMark, String billTable, - String requestId, CusSuccess cusSuccess, CusSuccess tokenSuccess) { + String requestId, CusSuccess cusSuccess, + CusSuccess tokenSuccess) { Map headers = new HashMap<>(); if(StringUtils.isNotBlank(tokenMark)) { String token = getToken(tokenMark, billTable, requestId, tokenSuccess); diff --git a/src/main/java/weaver/xuanran/wang/cssc/cms/util/RequestMasterPlate.java b/src/main/java/weaver/xuanran/wang/cssc/cms/util/RequestMasterPlate.java index eb479ac..00ea2a6 100644 --- a/src/main/java/weaver/xuanran/wang/cssc/cms/util/RequestMasterPlate.java +++ b/src/main/java/weaver/xuanran/wang/cssc/cms/util/RequestMasterPlate.java @@ -5,13 +5,18 @@ import aiyh.utils.excention.CustomerException; import aiyh.utils.httpUtil.ResponeVo; import aiyh.utils.httpUtil.util.HttpUtils; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; +import weaver.cssc.workflow.voucher.util.InterfaceLoggerDao; +import weaver.cssc.workflow.voucher.util.VoucherConstants; import weaver.xuanran.wang.cssc.cms.entity.CusSuccess; import javax.ws.rs.core.MediaType; import java.io.IOException; import java.util.Map; +import java.util.Objects; +import java.util.function.Function; /** *

请求模版方法

@@ -25,24 +30,30 @@ public class RequestMasterPlate { private static final int HTTP_SUCCESS_CODE = 200; public T apiGet(String url, Map params, Map headers, CusSuccess cusSuccess){ - ResponeVo responeVo; try { - responeVo = httpUtils.apiGet(url, params, headers); - } catch (IOException e) { - throw new CustomerException(Util.logStr("发送请求发生异常! : {}", e.getMessage())); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串 + setLogDao(cusSuccess, params, 0, null, false); + ResponeVo responeVo = httpUtils.apiGet(url, params, headers); + setLogDao(cusSuccess, responeVo.getResponseMap(), 1, null, false); + return parseResponse(url, responeVo, params, cusSuccess); + } catch (Exception e) { + setLogDao(cusSuccess, null, 2, e, true); + insertLog(cusSuccess); + throw new CustomerException(Util.logStr("发送请求发生异常! : {}", e.getMessage())); } - return parseResponse(url, responeVo, params, cusSuccess); } public T apiPost(String url, Object o, Map headers, CusSuccess cusSuccess){ - ResponeVo responeVo; try { headers.put("Content-Type", MediaType.APPLICATION_JSON); - responeVo = httpUtils.apiPostObject(url, o, headers); - } catch (IOException e) { + setLogDao(cusSuccess, o, 0, null, false); + ResponeVo responeVo = httpUtils.apiPostObject(url, o, headers); + setLogDao(cusSuccess, responeVo.getResponseMap(), 1, null, false); + return parseResponse(url, responeVo, o, cusSuccess); + } catch (Exception e) { + setLogDao(cusSuccess, null, 2, e, true); + insertLog(cusSuccess); throw new CustomerException(Util.logStr("发送请求发生异常! : {}", e.getMessage())); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串 } - return parseResponse(url, responeVo, o, cusSuccess); } public T parseResponse(String url, ResponeVo responseVo, Object o, CusSuccess cusSuccess){ @@ -61,15 +72,59 @@ public class RequestMasterPlate { } String[] split = Util.null2DefaultStr(cusSuccess.getDataKey(),"").split("\\."); int len = split.length; + T res; if(len == 0 || StringUtils.isBlank(cusSuccess.getDataKey())){ - return (T)response; + res = (T) response; + }else { + for (int i = 0; i < len - 1; i++) { + response = (Map) response.get(split[i]); + } + res = (T) response.get(split[len - 1]); } - for (int i = 0; i < len - 1; i++) { - response = (Map) response.get(split[i]); + insertLog(cusSuccess); + return res; + } + + public void insertLog(CusSuccess success){ + InterfaceLoggerDao dao = success.getDao(); + if(null != dao){ + try { + dao.insertInterfaceLog(dao); + }catch (Exception e){ + log.error("写入日志失败! 当前dao : " + JSONObject.toJSONString(dao)); + } + } + } + + /** + *

给自定义对象设置值

+ * @author xuanran.wang + * @dateTime 2023/7/6 18:22 + * @param cusSuccess 自定义对象 + * @param o 参数 + * @param type 类型 0 请求体 1 响应体 + * @param e 异常 + * @param error 是否失败 + **/ + public void setLogDao(CusSuccess cusSuccess, Object o, int type, Exception e, boolean error){ + InterfaceLoggerDao dao = cusSuccess.getDao(); + if(Objects.isNull(dao)){ + return; + } + if(type == 0){ + dao.setRequestBody(JSONObject.toJSONString(o)); + }else if(type == 1){ + dao.setResponseBody(JSONObject.toJSONString(o)); + }else if(type == 2){ + if(Objects.isNull(e)){ + return; + } + dao.setDealMessage(e.getMessage()); + } + if(error){ + dao.setDealStatus(VoucherConstants.DEAL_STATUS_SUCCESS); } - return (T) response.get(split[len - 1]); } - } diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/common/entity/CusSuccess.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/common/entity/CusSuccess.java index 29833ac..1750741 100644 --- a/src/main/java/weaver/xuanran/wang/sh_bigdata/common/entity/CusSuccess.java +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/common/entity/CusSuccess.java @@ -4,7 +4,7 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import weaver.xuanran.wang.common.service.CusDataDecipher; +import weaver.xuanran.wang.sh_bigdata.common.service.CusDataDecipher; /** diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/SendTodoTaskUtil.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/SendTodoTaskUtil.java index 87e1262..480eca0 100644 --- a/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/SendTodoTaskUtil.java +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/SendTodoTaskUtil.java @@ -1,18 +1,13 @@ package weaver.xuanran.wang.sh_bigdata.common.util; import aiyh.utils.Util; -import aiyh.utils.excention.CustomerException; -import com.alibaba.fastjson.JSONObject; -import com.icbc.api.internal.apache.http.impl.cookie.S; import lombok.Data; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; -import org.springframework.beans.BeanUtils; import weaver.workflow.request.todo.RequestStatusObj; import weaver.xuanran.wang.common.mapper.CommonMapper; import weaver.xuanran.wang.sh_bigdata.task_async.entity.CusDoneTask; -import weaver.xuanran.wang.sh_bigdata.task_async.entity.CusTodoLeaderTask; import weaver.xuanran.wang.sh_bigdata.task_async.entity.CusTodoTask; import weaver.xuanran.wang.sh_bigdata.task_async.mapper.SendTodoTaskMapper; @@ -66,8 +61,8 @@ public class SendTodoTaskUtil { * @param objs 任务对象 * @return 三方系统任务接收对象 **/ - public List getTodoTaskInfo(List objs){ - ArrayList res = new ArrayList<>(); + public List getTodoTaskInfo(List objs){ + List res = new ArrayList<>(); for (RequestStatusObj obj : objs) { String taskId = getTaskId(0, obj); CusTodoTask todoTask = new CusTodoTask(); @@ -76,7 +71,7 @@ public class SendTodoTaskUtil { todoTask.setTaskNum(taskId); todoTask.setAgentid(agentId); todoTask.setTaskName(obj.getRequestnamenew()); - todoTask.setTaskDesc(obj.getRequestnamenew()); + todoTask.setTaskDesc(""); String pcAgentId = ShBigDataUtil.getPropertiesValByKey("pcAgentId"); if(StringUtils.isBlank(pcAgentId)){ pcAgentId = agentId; @@ -98,14 +93,10 @@ public class SendTodoTaskUtil { // 是否领导待办逻辑处理 int nodeId = obj.getNodeid(); String nodeNme = obj.getNodename(); + todoTask.setLeader(""); if(strContainsKey(ShBigDataUtil.getPropertiesValByKey("taskAsyncLeaderNodeId"), String.valueOf(nodeId)) || strContainsKey(ShBigDataUtil.getPropertiesValByKey("taskAsyncLeaderNodeName"), nodeNme)){ - CusTodoLeaderTask leaderTask = new CusTodoLeaderTask(); - // 进行数据拷贝 - BeanUtils.copyProperties(todoTask, leaderTask); - leaderTask.setLeader(Util.null2DefaultStr(ShBigDataUtil.getPropertiesValByKey("taskAsyncLeaderValue"),"1")); - res.add(leaderTask); - continue; + todoTask.setLeader(Util.null2DefaultStr(ShBigDataUtil.getPropertiesValByKey("taskAsyncLeaderValue"),"1")); } res.add(todoTask); } @@ -152,12 +143,15 @@ public class SendTodoTaskUtil { ArrayList res = new ArrayList<>(); for (RequestStatusObj obj : objs) { String taskId = getTaskId(1, obj); - List list = mapper.queryUnSendTodoTaskList(taskId); - for (String num : list) { + List> list = mapper.queryUnSendTodoTaskList(taskId); + for (Map map : list) { + String num = Util.null2DefaultStr(map.get("TASKNUM"), Util.null2DefaultStr(map.get("tasknum"),"")); + String leader = Util.null2DefaultStr(map.get("LEADER"), Util.null2DefaultStr(map.get("leader"),"")); CusDoneTask doneTask = new CusDoneTask(); doneTask.setTaskNum(num); doneTask.setStatus(1); doneTask.setAgentid(agentId); + doneTask.setLeader(leader); res.add(doneTask); } } diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/entity/CusDoneTask.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/entity/CusDoneTask.java index 311a790..7becd14 100644 --- a/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/entity/CusDoneTask.java +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/entity/CusDoneTask.java @@ -20,4 +20,5 @@ public class CusDoneTask { private String taskNum; private int status; private String agentid; + private String leader; } diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/entity/CusTodoLeaderTask.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/entity/CusTodoLeaderTask.java deleted file mode 100644 index bb2c8db..0000000 --- a/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/entity/CusTodoLeaderTask.java +++ /dev/null @@ -1,17 +0,0 @@ -package weaver.xuanran.wang.sh_bigdata.task_async.entity; - -import lombok.*; - -/** - *

领导待办计划任务

- * - * @author xuanran.wang - * @date 2023/6/25 10:50 - */ -@EqualsAndHashCode(callSuper = true) -@Data -@AllArgsConstructor -@NoArgsConstructor -public class CusTodoLeaderTask extends CusTodoTask{ - private String leader; -} diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/entity/CusTodoTask.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/entity/CusTodoTask.java index 9ac3046..9b1e1b6 100644 --- a/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/entity/CusTodoTask.java +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/entity/CusTodoTask.java @@ -27,4 +27,5 @@ public class CusTodoTask { protected String receiver; protected String sender; protected String pcAgentId; + protected String leader; } diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/entity/CusTodoTaskToOADetail.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/entity/CusTodoTaskToOADetail.java index ab804ce..4a660b8 100644 --- a/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/entity/CusTodoTaskToOADetail.java +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/entity/CusTodoTaskToOADetail.java @@ -62,6 +62,11 @@ public class CusTodoTaskToOADetail extends CusTodoTask{ **/ @SqlFieldMapping private String error; + /** + *

领导

+ **/ + @SqlFieldMapping + private String leader; public CusTodoTaskToOADetail() { super(); } diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/mapper/SendTodoTaskMapper.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/mapper/SendTodoTaskMapper.java index 360a26a..3429318 100644 --- a/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/mapper/SendTodoTaskMapper.java +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/mapper/SendTodoTaskMapper.java @@ -18,9 +18,9 @@ public interface SendTodoTaskMapper { @Select("select oaaddress from systemset") String queryOAAddress(); - @Select("select taskNum from uf_todo_task_log " + + @Select("select taskNum, leader from uf_todo_task_log " + "where sourceTaskId = #{sourceTaskId} and taskType = 0 and status = 0 and success = 0") - List queryUnSendTodoTaskList(@ParamMapper("sourceTaskId") String sourceTaskId); + List> queryUnSendTodoTaskList(@ParamMapper("sourceTaskId") String sourceTaskId); @Update("update uf_todo_task_log set status = 1 where taskNum in (${taskNums})") boolean updateStatusByTaskNum(@ParamMapper("taskNums") List taskNums); diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/service/impl/SendTodoTaskServiceImpl.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/service/impl/SendTodoTaskServiceImpl.java index 9727bb5..8343055 100644 --- a/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/service/impl/SendTodoTaskServiceImpl.java +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/task_async/service/impl/SendTodoTaskServiceImpl.java @@ -61,7 +61,7 @@ public class SendTodoTaskServiceImpl implements SendTodoTaskService { .dataKey("") .build(); - List taskInfo = sendTodoTaskUtil.getTodoTaskInfo(todoList); + List taskInfo = sendTodoTaskUtil.getTodoTaskInfo(todoList); log.info("---------------- todoTaskInfo ---------------- \n" + JSONObject.toJSONString(taskInfo)); Map response = null; int success = 0; @@ -74,8 +74,7 @@ public class SendTodoTaskServiceImpl implements SendTodoTaskService { success = 1; } ArrayList details = new ArrayList<>(); - for (Object obj : taskInfo) { - CusTodoTask cusTodoTask = (CusTodoTask) obj; + for (CusTodoTask cusTodoTask : taskInfo) { CusTodoTaskToOADetail detail = new CusTodoTaskToOADetail(); detail.setTaskNum(cusTodoTask.getTaskNum()); detail.setRequestUrl(addTodoTaskUrl); @@ -89,6 +88,7 @@ public class SendTodoTaskServiceImpl implements SendTodoTaskService { detail.setSourceTaskId(sourceTaskId); detail.setSendTime(TimeUtil.getCurrentTimeString()); detail.setError(error); + detail.setLeader(cusTodoTask.getLeader()); details.add(detail); } CusInfoToOAUtil.executeBatchByEntity(modelId, details,""); diff --git a/src/main/java/weaver/xuanran/wang/shyl_mq/mapper/ConsumerMapper.java b/src/main/java/weaver/xuanran/wang/shyl_mq/mapper/ConsumerMapper.java index af8f3f8..69cb2dc 100644 --- a/src/main/java/weaver/xuanran/wang/shyl_mq/mapper/ConsumerMapper.java +++ b/src/main/java/weaver/xuanran/wang/shyl_mq/mapper/ConsumerMapper.java @@ -84,6 +84,17 @@ public interface ConsumerMapper { boolean updatePasswordById(@ParamMapper("id") String id, @ParamMapper("password") String password); + /** + *

通过outKey获取oa部门id

+ * @author xuanran.wang + * @dateTime 2022/12/30 14:33 + * @param id 外部系统id + * @return true/false + **/ + @Update("update hrmresource set password = #{password} where id = #{id}") + boolean updatePasswordAndSaltById(@ParamMapper("id") String id, + @ParamMapper("password") String password); + /** *

获取第一个分部id

* @author xuanran.wang diff --git a/src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/PassWordServiceImpl.java b/src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/PassWordServiceImpl.java index 2c572f4..50244d1 100644 --- a/src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/PassWordServiceImpl.java +++ b/src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/PassWordServiceImpl.java @@ -2,23 +2,16 @@ package weaver.xuanran.wang.shyl_mq.service.impl; import aiyh.utils.Util; import aiyh.utils.excention.CustomerException; -import aiyh.utils.httpUtil.util.HttpUtils; import com.alibaba.fastjson.JSONObject; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus; -import weaver.xuanran.wang.common.entity.CusSuccess; -import weaver.xuanran.wang.common.util.RequestMasterPlate; -import weaver.xuanran.wang.common.util.TokenUtil; +import weaver.general.PasswordUtil; import weaver.xuanran.wang.shyl_mq.entity.MQMessage; import weaver.xuanran.wang.shyl_mq.entity.ModifyPassWord; -import weaver.xuanran.wang.shyl_mq.entity.SentryLnesaTokenConf; import weaver.xuanran.wang.shyl_mq.service.CusInfoActionService; import weaver.xuanran.wang.shyl_mq.util.RocketConsumerUtil; -import javax.ws.rs.core.MediaType; -import java.util.HashMap; -import java.util.Map; /** *

密码修改业务方法

@@ -61,6 +54,11 @@ public class PassWordServiceImpl extends CusInfoActionService { if (!consumerMapper.updatePasswordById(hrmId, Util.getEncrypt(RocketConsumerUtil.decryptContent(passWord.getPassword())))) { throw new CustomerException("update user password error!"); } + try { + PasswordUtil.saveSign(hrmId); + } catch (Exception e) { + throw new CustomerException(" PasswordUtil.saveSign error!",e); + } writeInOA(message.getId()); return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; } catch (Exception e) { diff --git a/src/test/java/xuanran/wang/ajx/TestA.java b/src/test/java/xuanran/wang/ajx/TestA.java new file mode 100644 index 0000000..ddb5d30 --- /dev/null +++ b/src/test/java/xuanran/wang/ajx/TestA.java @@ -0,0 +1,85 @@ +package xuanran.wang.ajx; + +import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; +import basetest.BaseTest; +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.junit.Test; +import weaver.bokang.xiao.common.mapper.WorkflowMapper; +import weaver.xuanran.wang.ajx.work_flow_split.mapper.ChildWorkFlowSplitMapper; +import weaver.xuanran.wang.common.mapper.CommonMapper; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +/** + *

+ * + * @author xuanran.wang + * @date 2023/7/10 15:20 + */ +public class TestA extends BaseTest { + + private final CommonMapper workflowMapper = Util.getMapper(CommonMapper.class); + private final ChildWorkFlowSplitMapper mapper = Util.getMapper(ChildWorkFlowSplitMapper.class); + + private String insertAccountNumberField = ""; + + @Test + public void testA(){ + String selectDetailNo = "1"; + String billTable = "formtable_main_208"; + String requestId = "640646"; + String selectAccountNumberField = "zthm"; + String hasMoreAccountField = "sfbhdzt"; + String insertDetailNo = "2"; + String hasMoreAccountFieldValue = "0"; + Map mainMap = workflowMapper.queryWorkflowByRequestId("640646", "formtable_main_208"); + String id = Util.null2DefaultStr(mainMap.get("id"),""); + if(StringUtils.isBlank(id)){ + throw new CustomerException("id is empty!"); + } + // 查明细数据 + List> detailInfo = workflowMapper.queryWorkflowByMainId(id, "formtable_main_208_dt1"); + if(CollectionUtils.isEmpty(detailInfo)){ + log.error("detail " + selectDetailNo + " table info is empty!"); + return; + } + Set accountNumber = detailInfo.stream().map(item -> Util.null2DefaultStr(item.get(selectAccountNumberField),"")).filter(StringUtils::isNotBlank).collect(Collectors.toSet()); + if(CollectionUtils.isEmpty(accountNumber) || accountNumber.size() == 1){ + log.error("明细数据根据帐套号分组后为空, 或不存在多个帐套!"); + log.info("accountNumber : [ " + JSONObject.toJSONString(accountNumber) + " ]"); + // 如果不存在多帐套那么将主表数据hasMoreAccountField 更新为null + if (!mapper.updateMainTable(billTable, hasMoreAccountField, null, requestId)) { + throw new CustomerException("更新主表是否包含多账套字段失败!"); + } + return; + } + if (!mapper.updateMainTable(billTable, hasMoreAccountField, hasMoreAccountFieldValue, requestId)) { + throw new CustomerException("更新主表是否包含多账套字段失败!"); + } + // 如果插入表的帐套号字段名配置为空 那么与插入表的字段名保持一致 + if(StringUtils.isBlank(this.insertAccountNumberField)){ + this.insertAccountNumberField = selectAccountNumberField; + } + List> insertList = accountNumber.stream() + .map(item -> { + Map map = new HashMap<>(); + map.put("mainId", id); + map.put("insertAccountNumber", item); + return map; + }).collect(Collectors.toList()); + boolean delete = mapper.selectAccountNumber(id, billTable + "_dt" + insertDetailNo); + if(!delete){ + throw new CustomerException("删除明细表数据失败!"); + } + if (!mapper.insertDetailTable(billTable + "_dt" + insertDetailNo, this.insertAccountNumberField, insertList)) { + throw new CustomerException("批量插入明细数据失败!"); + } + } +} diff --git a/src/test/java/xuanran/wang/big_data/BigDataTest.java b/src/test/java/xuanran/wang/big_data/BigDataTest.java index b3a0bf0..0f7ba56 100644 --- a/src/test/java/xuanran/wang/big_data/BigDataTest.java +++ b/src/test/java/xuanran/wang/big_data/BigDataTest.java @@ -421,12 +421,6 @@ public class BigDataTest extends BaseTest { obj2.setCreator(new User(1)); requestStatusObjs.add(obj2); - List todoTaskInfo = taskUtil.getTodoTaskInfo(requestStatusObjs); - System.out.println("todoTaskInfo : " + JSONObject.toJSONString(todoTaskInfo)); - for (Object todo : todoTaskInfo) { - CusTodoTask cusTodoTask = (CusTodoTask) todo; - System.out.println("cusTodoTask : " + JSONObject.toJSONString(cusTodoTask)); - } } @Test public void testI(){ diff --git a/src/test/java/xuanran/wang/common/test/ServiceTest.java b/src/test/java/xuanran/wang/common/test/ServiceTest.java index d15673f..1b993a7 100644 --- a/src/test/java/xuanran/wang/common/test/ServiceTest.java +++ b/src/test/java/xuanran/wang/common/test/ServiceTest.java @@ -2,6 +2,9 @@ package xuanran.wang.common.test; import basetest.BaseTest; import org.junit.Test; +import weaver.xuanran.wang.common.util.CusInfoToOAUtil; + +import java.util.HashMap; /** *

@@ -19,4 +22,11 @@ public class ServiceTest extends BaseTest { service1.getA(); service2.getA(); } + + @Test + public void testB(){ + HashMap params = new HashMap<>(); + params.put("class_id","1"); + CusInfoToOAUtil.getDataId(97, params); + } } diff --git a/src/test/java/xuanran/wang/http_test/rest_test/CusRestTemplate.java b/src/test/java/xuanran/wang/http_test/rest_test/CusRestTemplate.java new file mode 100644 index 0000000..86ce1ef --- /dev/null +++ b/src/test/java/xuanran/wang/http_test/rest_test/CusRestTemplate.java @@ -0,0 +1,240 @@ +package xuanran.wang.http_test.rest_test; + +import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; +import aiyh.utils.httpUtil.ResponeVo; +import aiyh.utils.httpUtil.util.HttpUtils; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.type.TypeFactory; +import org.apache.commons.collections.MapUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import weaver.xuanran.wang.common.entity.CusResponseSuccess; + +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + *

+ * + * @author xuanran.wang + * @date 2023/7/7 10:56 + */ +public class CusRestTemplate { + private static final ObjectMapper objectMapper = new ObjectMapper(); + private final Logger log = Util.getLogger(); + private final HttpUtils httpUtils = new HttpUtils(); + private static final int HTTP_SUCCESS_CODE = 200; + + /** + *

get请求

+ * @author xuanran.wang + * @dateTime 2023/7/7 17:16 + * @param url 请求url + * @param params 请求参数 + * @param headers 请求头 + * @param cusSuccess 请求成功对象 + * @return 响应对象 + **/ + public ResponeVo apiGet(String url, Map params, + Map headers, + CusResponseSuccess cusSuccess) { + ResponeVo responeVo; + try { + requestBeforeInit(url, params, cusSuccess); + responeVo = httpUtils.apiGet(url, params, headers); + checkResponse(url, responeVo, params, cusSuccess); + return responeVo; + } catch (Exception e) { + callBack(e,cusSuccess); + throw new CustomerException(Util.logStr("发送请求发生异常! : {}", e.getMessage())); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串 + } + } + + + /** + *

post请求

+ * @author xuanran.wang + * @dateTime 2023/7/7 17:16 + * @param url 请求url + * @param params 请求参数 + * @param headers 请求头 + * @param cusSuccess 请求成功对象 + * @return 响应对象 + **/ + public ResponeVo apiPost(String url, Object params, Map headers, CusResponseSuccess cusSuccess) { + ResponeVo responeVo; + try { + requestBeforeInit(url, params, cusSuccess); + responeVo = httpUtils.apiPostObject(url, params, headers); + checkResponse(url, responeVo, params, cusSuccess); + return responeVo; + } catch (Exception e) { + callBack(e,cusSuccess); + throw new CustomerException(Util.logStr("发送请求发生异常! : {}", e.getMessage())); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串 + } + } + + /** + *

根据cusSuccess对象校验响应是否成功

+ * @author xuanran.wang + * @dateTime 2023/7/7 17:17 + * @param url 请求地址 + * @param responseVo 响应对象 + * @param o 参数 + * @param cusSuccess 请求成功对象 + **/ + private void checkResponse(String url, ResponeVo responseVo, Object o, CusResponseSuccess cusSuccess) { + if (Objects.isNull(cusSuccess) || !cusSuccess.isCheckResponse()) { + return; + } + cusSuccess.setVo(responseVo); + if (responseVo.getCode() != HTTP_SUCCESS_CODE) { // 相应状态码 + log.error(Util.logStr("can not fetch [{}],this request params is [{}]," + // 构建日志字符串 + "this request heard is [{}],but response status code is [{}]," + + "this response is [{}]", url, JSON.toJSON(o), JSON.toJSONString(httpUtils.getGlobalCache().header), responseVo.getCode(), // 相应状态码 + responseVo.getEntityString())); // 相应内容 + throw new CustomerException(Util.logStr("can not fetch [{}]", url)); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串 + } + Map response; + if (cusSuccess.getCusDataDecipher() != null) { + response = cusSuccess.getCusDataDecipher().decoder(responseVo); + } else { + response = responseVo.getResponseMap(); // 根据相应结果转化为map集合 + } + cusSuccess.setResponse(response); + String responseValue = Util.null2DefaultStr(response.get(cusSuccess.getSuccessField()), ""); + if (!responseValue.equals(Util.null2DefaultStr(cusSuccess.getSuccessValue(), ""))) { + throw new CustomerException(Util.logStr("接口地址:[{}], 接口响应码不为: [{}], 接口响应信息: {}", url, cusSuccess.getSuccessValue(), Util.null2DefaultStr(response.get(cusSuccess.getErrorMsg()), ""))); // 自定义异常类 create 2022/3/9 2:20 PM 构建日志字符串 + } + } + + /** + *

解析普通值

+ * @author xuanran.wang + * @dateTime 2023/7/7 17:18 + * @param map 响应map + * @param dataKey 值路径 + * @param clazz 值类型 + * @return 普通值 + **/ + public T parseCommon(Map map, String dataKey, Class clazz) { + if (MapUtils.isEmpty(map)) { + throw new CustomerException("map can not be null!"); + } + Object object = getDataObject(map, dataKey); + ObjectMapper objectMapper = new ObjectMapper(); + return objectMapper.convertValue(object, clazz); + } + + /** + *

解析对象

+ * @author xuanran.wang + * @dateTime 2023/7/7 17:18 + * @param map 响应map + * @param dataKey 值路径 + * @param clazz 值类型 + * @return 对象 + **/ + public T parseObj(Map map, String dataKey, Class clazz) { + if (MapUtils.isEmpty(map)) { + throw new CustomerException("map can not be null!"); + } + Object dataObject = getDataObject(map, dataKey); + if (Objects.isNull(dataObject)) { + throw new CustomerException("parse object error!"); + } + if (dataObject instanceof Map) { + return (T) JSONObject.parseObject(JSONObject.toJSONString(dataObject), clazz); + } + return null; + } + + /** + *

解析集合

+ * @author xuanran.wang + * @dateTime 2023/7/7 17:18 + * @param map 响应map + * @param dataKey 值路径 + * @param clazz 值类型 + * @return 集合 + **/ + public List parseList(Map map, String dataKey, Class clazz) { + if (MapUtils.isEmpty(map)) { + throw new CustomerException("map can not be null!"); + } + Object dataObject = getDataObject(map, dataKey); + if (Objects.isNull(dataObject)) { + throw new CustomerException("parse object error!"); + } + if (dataObject instanceof List) { + JavaType listType = TypeFactory.defaultInstance().constructParametricType(List.class, clazz); + try { + String jsonString = objectMapper.writeValueAsString(dataObject); + return objectMapper.readValue(jsonString, listType); + } catch (JsonProcessingException e) { + throw new CustomerException("JSON processing error!", e); + } + } + return null; + } + + /** + *

按照值路径解析对象

+ * @author xuanran.wang + * @dateTime 2023/7/7 17:19 + * @param map 响应map + * @param dataKey 值路径 + * @return 解析对象 + **/ + private Object getDataObject(Map map, String dataKey) { + if(StringUtils.isBlank(dataKey) || dataKey.split("\\.").length == 0){ + return map; + } + Object dataObject = map; + String[] keys = dataKey.split("\\."); + for (String key : keys) { + if (dataObject instanceof Map) { + dataObject = ((Map) dataObject).get(key); + } else { + return dataObject; + } + } + return dataObject; + } + + /** + *

请求前填充参数

+ * @author xuanran.wang + * @dateTime 2023/7/7 17:20 + * @param url url + * @param params 请求参数 + * @param cusSuccess 自定义成功对象 + **/ + private void requestBeforeInit(String url, Object params, CusResponseSuccess cusSuccess){ + if(!Objects.isNull(cusSuccess)){ + cusSuccess.setUrl(url); + cusSuccess.setRequestParam(params); + } + } + + /** + *

请求失败执行自定义回调

+ * @author xuanran.wang + * @dateTime 2023/7/7 17:21 + * @param e 异常 + * @param cusSuccess 自定义成功对象 + **/ + public void callBack(Exception e, CusResponseSuccess cusSuccess){ + if(!Objects.isNull(cusSuccess.getCall())){ + cusSuccess.setE(e); + cusSuccess.getCall().accept(e); + } + } + +} diff --git a/src/test/java/xuanran/wang/http_test/rest_test/Stu.java b/src/test/java/xuanran/wang/http_test/rest_test/Stu.java new file mode 100644 index 0000000..493b7f4 --- /dev/null +++ b/src/test/java/xuanran/wang/http_test/rest_test/Stu.java @@ -0,0 +1,19 @@ +package xuanran.wang.http_test.rest_test; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +/** + *

+ * + * @author xuanran.wang + * @date 2023/7/7 11:44 + */ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class Stu{ + private String blance; + private String name; + private String tel; + private String age; +} diff --git a/src/test/java/xuanran/wang/http_test/test/TestMain.java b/src/test/java/xuanran/wang/http_test/test/TestMain.java new file mode 100644 index 0000000..c2ee34c --- /dev/null +++ b/src/test/java/xuanran/wang/http_test/test/TestMain.java @@ -0,0 +1,57 @@ +package xuanran.wang.http_test.test; + +import aiyh.utils.httpUtil.ResponeVo; +import basetest.BaseTest; +import com.alibaba.fastjson.JSONObject; +import com.cloudstore.api.util.Util_Redis; +import com.fapiao.neon.client.base.impl.RedisClientImpl; +import com.weaver.base.cache.redis.RedisCache; +import org.docx4j.wml.R; +import org.junit.Test; +import weaver.session.util.RedisClient; +import weaver.session.util.RedisTemplate; +import weaver.xuanran.wang.common.entity.CusResponseSuccess; +import xuanran.wang.http_test.rest_test.CusRestTemplate; +import xuanran.wang.http_test.rest_test.Stu; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + *

+ * + * @author xuanran.wang + * @date 2023/7/7 15:46 + */ +public class TestMain extends BaseTest { + + @Test + public void testA(){ + CusResponseSuccess builder = + CusResponseSuccess.builder() + .checkResponse(true) + .successField("code") + .successValue(0) + .errorMsg("msg") + .build(); + CusRestTemplate restTemplate = new CusRestTemplate(); + Map map = new HashMap<>(); + builder.setCall(e->{ + map.put("msg", e.getMessage()); + map.put("status", false); + }); + try { + ResponeVo vo = restTemplate.apiGet("https://gl.shstx.cn:48002/auth/oauth/token?grant_type=client_credentials&client_id=fanwei&client_secret=b7c20b12cb124cbebb0b8833caac6b87", new HashMap<>(), new HashMap<>(), builder); + Map o = restTemplate.parseObj(vo.getResponseMap(), "", Map.class); + System.out.println("token : " + o); + }catch (Exception e){ + System.out.println("error : " + e.getMessage()); + System.out.println("e map : " + JSONObject.toJSONString(map)); + System.out.println("cusSuccess : " + JSONObject.toJSONString(builder)); + } + +// String json = "{\"code\":200,\"msg\":\"接口返回成功\",\"status\":true,\"data\":{\"name\":\"张三\",\"age\":21,\"tel\":\"1539324****\",\"class\":\"2020级计算机应用技术1122班\",\"blance\":\"100\"}}\n"; +// String json = "{\"code\":200,\"msg\":\"接口返回成功\",\"status\":true,\"data\":{\"arr\":[{\"name\":\"张三\",\"age\":21,\"tel\":\"1539324****\",\"class\":\"2020级计算机应用技术1122班\",\"blance\":\"100\"},{\"name\":\"李四\",\"age\":21,\"tel\":\"1539324****\",\"class\":\"2020级计算机应用技术1122班\",\"blance\":\"100\"}],\"obj\":{\"text\":\"111\"}}}\n"; + } +} diff --git a/src/test/java/xuanran/wang/immc/Kafka/MQTest.java b/src/test/java/xuanran/wang/immc/Kafka/MQTest.java index 76fc915..09aa47f 100644 --- a/src/test/java/xuanran/wang/immc/Kafka/MQTest.java +++ b/src/test/java/xuanran/wang/immc/Kafka/MQTest.java @@ -228,28 +228,10 @@ public class MQTest extends BaseTest { // CusInfoToOAUtil.executeBatchByEntity(111, details,""); ArrayList list = new ArrayList<>(); ArrayList successTaskIds = new ArrayList<>(); - List lists = mapper.queryUnSendTodoTaskList("14672332"); - for (String num : lists) { - int success = 0; - CusDoneTaskOA taskOA = new CusDoneTaskOA(); - taskOA.setTaskNum(num); - taskOA.setTaskType(1); - String sourceTaskId =num.substring(0, num.length() - 10); - taskOA.setSourceTaskId(sourceTaskId); - taskOA.setResponse("{\n" + - " \"code\": 200,\n" + - " \"msg\": \"操作成功\", //返回文字描述\n" + - " \"data\": null,\n" + - " \"total\": null,\n" + - " \"totalPage\": null,\n" + - " \"takeTime\": null\n" + - "}"); - taskOA.setRequestUrl("22222222"); - taskOA.setRequestJson(JSONObject.toJSONString(num)); - taskOA.setSuccess(success); - list.add(taskOA); - successTaskIds.add(num); + List> maps = mapper.queryUnSendTodoTaskList("14672332"); + for (Map map : maps) { } + CusInfoToOAUtil.executeBatchByEntity(111, list,""); mapper.updateStatusByTaskNum(successTaskIds); } diff --git a/src/test/java/xuanran/wang/shyl/dataasync/TestPassword.java b/src/test/java/xuanran/wang/shyl/dataasync/TestPassword.java index 8a641c4..20fc108 100644 --- a/src/test/java/xuanran/wang/shyl/dataasync/TestPassword.java +++ b/src/test/java/xuanran/wang/shyl/dataasync/TestPassword.java @@ -1,14 +1,23 @@ package xuanran.wang.shyl.dataasync; +import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; import basetest.BaseTest; import com.alibaba.fastjson.JSONObject; import com.api.xuanran.wang.shyl.service.UserUpdateToMQService; +import com.engine.hrm.util.face.HrmFaceCheckManager; +import com.weaver.formmodel.util.EncryptHelper; import org.junit.Test; +import weaver.conn.RecordSet; +import weaver.general.PasswordUtil; +import weaver.hrm.resource.ResourceComInfo; import weaver.xuanran.wang.common.interfaces.CusAbstractTokenConf; import weaver.xuanran.wang.common.util.TokenUtil; import weaver.xuanran.wang.shyl_mq.entity.SentryLnesaTokenConf; +import weaver.xuanran.wang.shyl_mq.mapper.ConsumerMapper; import weaver.xuanran.wang.shyl_mq.util.RocketConsumerUtil; +import java.util.HashMap; import java.util.Map; /** @@ -19,14 +28,47 @@ import java.util.Map; */ public class TestPassword extends BaseTest { private final UserUpdateToMQService service = new UserUpdateToMQService(); - @Test - public void testA() throws InterruptedException { - String encryptContent = RocketConsumerUtil.encryptContent("wxr12345435"); - System.out.println("encryptContent : " + encryptContent); + ConsumerMapper consumerMapper = Util.getMapper(ConsumerMapper.class); - Thread.sleep(60000); - String decryptContent = RocketConsumerUtil.decryptContent(encryptContent); - System.out.println("decryptContent : " + decryptContent ); + @Test + public void testA() throws Exception { + + String[] newEncrypts = PasswordUtil.encrypt(weaver.general.Util.null2String("123321")); + String encrypt = Util.getEncrypt("123321"); + + ResourceComInfo info = new ResourceComInfo(); + String passwordnew = newEncrypts[0]; + + String upperCase = EncryptHelper.encodeMd5("11111").toUpperCase(); + if (!consumerMapper.updatePasswordById("97",encrypt)) { + throw new CustomerException("更新密码失败!"); + } + try { + PasswordUtil.saveSign("97"); + } catch (Exception var80) { + System.out.println("e : " + var80.getMessage() ); + } +// String newSalt = newEncrypts[1]; +// PasswordUtil.updateResourceSalt("97", newSalt); +// String var30 = "123321"; +// String var17 = "97"; +// String var96 = ""; +// var96 = var30; +// String[] var40 = PasswordUtil.encrypt(var30); +// var30 = var40[0]; +// String var41 = var40[1]; +// RecordSet var42 = new RecordSet(); +// var42.executeUpdate("update hrmresource set password=?,salt=? where id=?", new Object[]{var30, var41, var17}); +// var42.executeUpdate("update hrmresourcemanager set password=?,salt=? where id=?", new Object[]{var30, var41, var17}); +// HrmFaceCheckManager.setUserPassowrd(var17, var96); } + + @Test + public void testB(){ + HashMap map = new HashMap<>(); + map.put("1",null); + map.put("2",""); + System.out.println(JSONObject.toJSONString(map)); + } }