diff --git a/src/main/java/aiyh/utils/ScriptUtil.java b/src/main/java/aiyh/utils/ScriptUtil.java index 9e59a3d..fac478f 100644 --- a/src/main/java/aiyh/utils/ScriptUtil.java +++ b/src/main/java/aiyh/utils/ScriptUtil.java @@ -1,7 +1,9 @@ package aiyh.utils; +import aiyh.utils.excention.CustomerException; import aiyh.utils.interfaces.script_util.CusScriptFunInterface; import aiyh.utils.tool.org.apache.commons.jexl3.*; +import com.alibaba.fastjson.JSONObject; import java.util.Map; @@ -20,14 +22,20 @@ public class ScriptUtil { } public static Object invokeScript(String script, Map params, CusScriptFunInterface scriptFunInterface) { - JexlContext jc = new MapContext(); - if(null != scriptFunInterface){ - jc.set(scriptFunInterface.getClass().getSimpleName(), scriptFunInterface); + try { + JexlContext jc = new MapContext(); + if(null != scriptFunInterface){ + jc.set(scriptFunInterface.getClass().getSimpleName(), scriptFunInterface); + } + for (Map.Entry entry : params.entrySet()) { + jc.set(entry.getKey(), entry.getValue()); + } + JexlExpression expression = JEXL.createExpression(script); + return expression.evaluate(jc); + }catch (Exception e){ + Util.getLogger().error(Util.logStr("script expression evaluate error! current script : {}, current params : {}", script, JSONObject.toJSONString(params))); + Util.logErrorStr(e); + throw new CustomerException(e); } - for (Map.Entry entry : params.entrySet()) { - jc.set(entry.getKey(), entry.getValue()); - } - JexlExpression expression = JEXL.createExpression(script); - return expression.evaluate(jc); } } diff --git a/src/test/java/xuanran/wang/log/cus_api_log/CusApiLogUtil.java b/src/main/java/aiyh/utils/api_log/cus_api_log/CusApiLogUtil.java similarity index 80% rename from src/test/java/xuanran/wang/log/cus_api_log/CusApiLogUtil.java rename to src/main/java/aiyh/utils/api_log/cus_api_log/CusApiLogUtil.java index 80f6763..04c75af 100644 --- a/src/test/java/xuanran/wang/log/cus_api_log/CusApiLogUtil.java +++ b/src/main/java/aiyh/utils/api_log/cus_api_log/CusApiLogUtil.java @@ -1,16 +1,16 @@ -package xuanran.wang.log.cus_api_log; +package aiyh.utils.api_log.cus_api_log; import aiyh.utils.Util; import aiyh.utils.annotation.recordset.SqlDbFieldAnn; +import aiyh.utils.api_log.cus_api_log.annotations.CusApiLogTable; +import aiyh.utils.api_log.cus_api_log.dto.CusApiLogBaseDto; +import aiyh.utils.api_log.cus_api_log.mapper.CusApiLogMapper; +import aiyh.utils.api_log.cus_api_log.pojo.CusApiLogPojo; import aiyh.utils.excention.CustomerException; import aiyh.utils.recordset.MapperBuilderSql; import org.apache.commons.lang3.StringUtils; import weaver.soa.workflow.request.RequestInfo; -import xuanran.wang.log.cus_api_log.annotations.CusApiLogTable; -import xuanran.wang.log.cus_api_log.dto.CusApiLogBaseDto; -import xuanran.wang.log.cus_api_log.mapper.CusApiLogMapper; -import xuanran.wang.log.cus_api_log.pojo.CusApiLogPojo; import java.lang.reflect.Field; import java.util.*; @@ -28,6 +28,13 @@ public class CusApiLogUtil { insertApiLog(dto, -1); } + /** + *

向建模中写日志

+ * @author xuanran.wang + * @dateTime 2023/7/31 15:33 + * @param dto 日志实体类 + * @param modelId 模块id + **/ public static void insertApiLog(CusApiLogBaseDto dto, int modelId){ CusApiLogPojo pojo = parseDto(dto); String tableName = pojo.getTableName(); @@ -51,6 +58,14 @@ public class CusApiLogUtil { Util.rebuildModeDataShare(modeDataId, modelId, 1); } + /** + *

初始化日志类对象

+ * @author xuanran.wang + * @dateTime 2023/7/31 15:34 + * @param requestInfo 流程requestInfo + * @param clazz 日志类对象 + * @return 日志类对象 + **/ public static T initCusApiLogDto(RequestInfo requestInfo, Class clazz){ T obj; try { @@ -70,6 +85,12 @@ public class CusApiLogUtil { return obj; } + /** + *

解析实体类

+ * @author xuanran.wang + * @dateTime 2023/7/31 15:35 + * @param dto 日志类对象 + **/ private static CusApiLogPojo parseDto(CusApiLogBaseDto dto){ String tableName = null; Class childClass = dto.getClass(); @@ -99,6 +120,13 @@ public class CusApiLogUtil { return CusApiLogPojo.builder().tableName(tableName).params(params).build(); } + /** + *

解析实体类上的表名

+ * @author xuanran.wang + * @dateTime 2023/7/31 15:35 + * @param clazz 实体类class + * @return 表名 + **/ private static String parseTableName(Class clazz){ CusApiLogTable apiLogTable = clazz.getAnnotation(CusApiLogTable.class); if(apiLogTable != null){ diff --git a/src/test/java/xuanran/wang/log/cus_api_log/annotations/CusApiLogTable.java b/src/main/java/aiyh/utils/api_log/cus_api_log/annotations/CusApiLogTable.java similarity index 82% rename from src/test/java/xuanran/wang/log/cus_api_log/annotations/CusApiLogTable.java rename to src/main/java/aiyh/utils/api_log/cus_api_log/annotations/CusApiLogTable.java index 4c04866..36d94c6 100644 --- a/src/test/java/xuanran/wang/log/cus_api_log/annotations/CusApiLogTable.java +++ b/src/main/java/aiyh/utils/api_log/cus_api_log/annotations/CusApiLogTable.java @@ -1,4 +1,4 @@ -package xuanran.wang.log.cus_api_log.annotations; +package aiyh.utils.api_log.cus_api_log.annotations; import java.lang.annotation.*; diff --git a/src/test/java/xuanran/wang/log/cus_api_log/dto/CusApiLogBaseDto.java b/src/main/java/aiyh/utils/api_log/cus_api_log/dto/CusApiLogBaseDto.java similarity index 94% rename from src/test/java/xuanran/wang/log/cus_api_log/dto/CusApiLogBaseDto.java rename to src/main/java/aiyh/utils/api_log/cus_api_log/dto/CusApiLogBaseDto.java index 903b7ce..30f70c6 100644 --- a/src/test/java/xuanran/wang/log/cus_api_log/dto/CusApiLogBaseDto.java +++ b/src/main/java/aiyh/utils/api_log/cus_api_log/dto/CusApiLogBaseDto.java @@ -1,10 +1,10 @@ -package xuanran.wang.log.cus_api_log.dto; +package aiyh.utils.api_log.cus_api_log.dto; import aiyh.utils.annotation.recordset.SqlDbFieldAnn; +import aiyh.utils.api_log.cus_api_log.annotations.CusApiLogTable; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; -import xuanran.wang.log.cus_api_log.annotations.CusApiLogTable; /** *

接口日志实体类

diff --git a/src/test/java/xuanran/wang/log/cus_api_log/dto/DemoDto.java b/src/main/java/aiyh/utils/api_log/cus_api_log/dto/DemoDto.java similarity index 56% rename from src/test/java/xuanran/wang/log/cus_api_log/dto/DemoDto.java rename to src/main/java/aiyh/utils/api_log/cus_api_log/dto/DemoDto.java index 4633993..5cddf24 100644 --- a/src/test/java/xuanran/wang/log/cus_api_log/dto/DemoDto.java +++ b/src/main/java/aiyh/utils/api_log/cus_api_log/dto/DemoDto.java @@ -1,8 +1,10 @@ -package xuanran.wang.log.cus_api_log.dto; +package aiyh.utils.api_log.cus_api_log.dto; import aiyh.utils.annotation.recordset.SqlDbFieldAnn; -import lombok.*; -import xuanran.wang.log.cus_api_log.annotations.CusApiLogTable; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; /** *

@@ -14,7 +16,7 @@ import xuanran.wang.log.cus_api_log.annotations.CusApiLogTable; @Data @NoArgsConstructor @AllArgsConstructor -public class DemoDto extends CusApiLogBaseDto{ +public class DemoDto extends CusApiLogBaseDto { @SqlDbFieldAnn(value = "ext") private String ext; } diff --git a/src/test/java/xuanran/wang/log/cus_api_log/interfaces/CusLogDtoInterface.java b/src/main/java/aiyh/utils/api_log/cus_api_log/interfaces/CusLogDtoInterface.java similarity index 69% rename from src/test/java/xuanran/wang/log/cus_api_log/interfaces/CusLogDtoInterface.java rename to src/main/java/aiyh/utils/api_log/cus_api_log/interfaces/CusLogDtoInterface.java index a2fd472..a200892 100644 --- a/src/test/java/xuanran/wang/log/cus_api_log/interfaces/CusLogDtoInterface.java +++ b/src/main/java/aiyh/utils/api_log/cus_api_log/interfaces/CusLogDtoInterface.java @@ -1,4 +1,4 @@ -package xuanran.wang.log.cus_api_log.interfaces; +package aiyh.utils.api_log.cus_api_log.interfaces; /** *

diff --git a/src/test/java/xuanran/wang/log/cus_api_log/mapper/CusApiLogMapper.java b/src/main/java/aiyh/utils/api_log/cus_api_log/mapper/CusApiLogMapper.java similarity index 93% rename from src/test/java/xuanran/wang/log/cus_api_log/mapper/CusApiLogMapper.java rename to src/main/java/aiyh/utils/api_log/cus_api_log/mapper/CusApiLogMapper.java index 21897c5..83e1157 100644 --- a/src/test/java/xuanran/wang/log/cus_api_log/mapper/CusApiLogMapper.java +++ b/src/main/java/aiyh/utils/api_log/cus_api_log/mapper/CusApiLogMapper.java @@ -1,6 +1,7 @@ -package xuanran.wang.log.cus_api_log.mapper; +package aiyh.utils.api_log.cus_api_log.mapper; import aiyh.utils.annotation.recordset.*; + import java.util.Map; /** diff --git a/src/test/java/xuanran/wang/log/cus_api_log/pojo/CusApiLogPojo.java b/src/main/java/aiyh/utils/api_log/cus_api_log/pojo/CusApiLogPojo.java similarity index 62% rename from src/test/java/xuanran/wang/log/cus_api_log/pojo/CusApiLogPojo.java rename to src/main/java/aiyh/utils/api_log/cus_api_log/pojo/CusApiLogPojo.java index 7102fcd..b720296 100644 --- a/src/test/java/xuanran/wang/log/cus_api_log/pojo/CusApiLogPojo.java +++ b/src/main/java/aiyh/utils/api_log/cus_api_log/pojo/CusApiLogPojo.java @@ -1,6 +1,9 @@ -package xuanran.wang.log.cus_api_log.pojo; +package aiyh.utils.api_log.cus_api_log.pojo; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; import java.util.Map; diff --git a/src/test/java/xuanran/wang/rest_test/AbstractCusRestTemplate.java b/src/main/java/aiyh/utils/cus_rest/AbstractCusRestTemplate.java similarity index 95% rename from src/test/java/xuanran/wang/rest_test/AbstractCusRestTemplate.java rename to src/main/java/aiyh/utils/cus_rest/AbstractCusRestTemplate.java index 231f66a..085980d 100644 --- a/src/test/java/xuanran/wang/rest_test/AbstractCusRestTemplate.java +++ b/src/main/java/aiyh/utils/cus_rest/AbstractCusRestTemplate.java @@ -1,19 +1,19 @@ -package xuanran.wang.rest_test; +package aiyh.utils.cus_rest; import aiyh.utils.ThreadPoolConfig; import aiyh.utils.Util; +import aiyh.utils.api_log.cus_api_log.CusApiLogUtil; +import aiyh.utils.api_log.cus_api_log.dto.CusApiLogBaseDto; +import aiyh.utils.cus_rest.impl.CusGetRequest; +import aiyh.utils.cus_rest.impl.CusPostRequest; +import aiyh.utils.cus_rest.interfaces.CusApiRequestInterface; +import aiyh.utils.cus_rest.pojo.CusRestTemplateResponse; import aiyh.utils.excention.CustomerException; import aiyh.utils.httpUtil.ResponeVo; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import org.apache.commons.collections.MapUtils; import org.apache.log4j.Logger; -import xuanran.wang.rest_test.pojo.CusRestTemplateResponse; -import xuanran.wang.log.cus_api_log.CusApiLogUtil; -import xuanran.wang.log.cus_api_log.dto.CusApiLogBaseDto; -import xuanran.wang.rest_test.impl.CusGetRequest; -import xuanran.wang.rest_test.impl.CusPostRequest; -import xuanran.wang.rest_test.interfaces.CusApiRequestInterface; import java.util.HashMap; import java.util.Map; diff --git a/src/test/java/xuanran/wang/rest_test/CusRestTemplate.java b/src/main/java/aiyh/utils/cus_rest/CusRestTemplate.java similarity index 96% rename from src/test/java/xuanran/wang/rest_test/CusRestTemplate.java rename to src/main/java/aiyh/utils/cus_rest/CusRestTemplate.java index 0b358ae..577f6c1 100644 --- a/src/test/java/xuanran/wang/rest_test/CusRestTemplate.java +++ b/src/main/java/aiyh/utils/cus_rest/CusRestTemplate.java @@ -1,5 +1,6 @@ -package xuanran.wang.rest_test; +package aiyh.utils.cus_rest; +import aiyh.utils.cus_rest.pojo.CusRestTemplateResponse; import aiyh.utils.excention.CustomerException; import aiyh.utils.httpUtil.ResponeVo; import com.alibaba.fastjson.JSONObject; @@ -9,7 +10,6 @@ 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 xuanran.wang.rest_test.pojo.CusRestTemplateResponse; import java.util.List; import java.util.Map; @@ -21,7 +21,7 @@ import java.util.Objects; * @author xuanran.wang * @date 2023/7/7 10:56 */ -public class CusRestTemplate extends AbstractCusRestTemplate{ +public class CusRestTemplate extends AbstractCusRestTemplate { private static final ObjectMapper objectMapper = new ObjectMapper(); /** diff --git a/src/test/java/xuanran/wang/rest_test/impl/CusGetRequest.java b/src/main/java/aiyh/utils/cus_rest/impl/CusGetRequest.java similarity index 77% rename from src/test/java/xuanran/wang/rest_test/impl/CusGetRequest.java rename to src/main/java/aiyh/utils/cus_rest/impl/CusGetRequest.java index 3c0cbaa..cc0b087 100644 --- a/src/test/java/xuanran/wang/rest_test/impl/CusGetRequest.java +++ b/src/main/java/aiyh/utils/cus_rest/impl/CusGetRequest.java @@ -1,9 +1,9 @@ -package xuanran.wang.rest_test.impl; +package aiyh.utils.cus_rest.impl; +import aiyh.utils.cus_rest.interfaces.CusApiRequestInterface; +import aiyh.utils.cus_rest.pojo.CusRestTemplateResponse; import aiyh.utils.httpUtil.ResponeVo; import aiyh.utils.httpUtil.util.HttpUtils; -import xuanran.wang.rest_test.pojo.CusRestTemplateResponse; -import xuanran.wang.rest_test.interfaces.CusApiRequestInterface; import java.io.IOException; import java.util.Map; diff --git a/src/test/java/xuanran/wang/rest_test/impl/CusPostRequest.java b/src/main/java/aiyh/utils/cus_rest/impl/CusPostRequest.java similarity index 77% rename from src/test/java/xuanran/wang/rest_test/impl/CusPostRequest.java rename to src/main/java/aiyh/utils/cus_rest/impl/CusPostRequest.java index 0383fcb..97fac3f 100644 --- a/src/test/java/xuanran/wang/rest_test/impl/CusPostRequest.java +++ b/src/main/java/aiyh/utils/cus_rest/impl/CusPostRequest.java @@ -1,9 +1,10 @@ -package xuanran.wang.rest_test.impl; +package aiyh.utils.cus_rest.impl; +import aiyh.utils.cus_rest.interfaces.CusApiRequestInterface; +import aiyh.utils.cus_rest.pojo.CusRestTemplateResponse; import aiyh.utils.httpUtil.ResponeVo; import aiyh.utils.httpUtil.util.HttpUtils; -import xuanran.wang.rest_test.pojo.CusRestTemplateResponse; -import xuanran.wang.rest_test.interfaces.CusApiRequestInterface; + import java.io.IOException; import java.util.Map; @@ -21,4 +22,5 @@ public class CusPostRequest implements CusApiRequestInterface { public ResponeVo execute(String url, Object params, Map headers, CusRestTemplateResponse cusSuccess) throws IOException { return httpUtils.apiPostObject(url, params, headers); } + } diff --git a/src/test/java/xuanran/wang/rest_test/interfaces/CusApiRequestInterface.java b/src/main/java/aiyh/utils/cus_rest/interfaces/CusApiRequestInterface.java similarity index 78% rename from src/test/java/xuanran/wang/rest_test/interfaces/CusApiRequestInterface.java rename to src/main/java/aiyh/utils/cus_rest/interfaces/CusApiRequestInterface.java index ccd9beb..a67fc44 100644 --- a/src/test/java/xuanran/wang/rest_test/interfaces/CusApiRequestInterface.java +++ b/src/main/java/aiyh/utils/cus_rest/interfaces/CusApiRequestInterface.java @@ -1,7 +1,7 @@ -package xuanran.wang.rest_test.interfaces; +package aiyh.utils.cus_rest.interfaces; +import aiyh.utils.cus_rest.pojo.CusRestTemplateResponse; import aiyh.utils.httpUtil.ResponeVo; -import xuanran.wang.rest_test.pojo.CusRestTemplateResponse; import java.io.IOException; import java.util.Map; diff --git a/src/main/java/aiyh/utils/cus_rest/interfaces/CusDataDecipher.java b/src/main/java/aiyh/utils/cus_rest/interfaces/CusDataDecipher.java new file mode 100644 index 0000000..040e144 --- /dev/null +++ b/src/main/java/aiyh/utils/cus_rest/interfaces/CusDataDecipher.java @@ -0,0 +1,15 @@ +package aiyh.utils.cus_rest.interfaces; + +import aiyh.utils.httpUtil.ResponeVo; + +import java.util.Map; + +/** + *

自定义解密类

+ * + * @author xuanran.wang + * @date 2023/4/10 13:20 + */ +public interface CusDataDecipher { + Map decoder(ResponeVo responeVo); +} diff --git a/src/main/java/aiyh/utils/cus_rest/pojo/CusRestTemplateResponse.java b/src/main/java/aiyh/utils/cus_rest/pojo/CusRestTemplateResponse.java new file mode 100644 index 0000000..ce9dc6f --- /dev/null +++ b/src/main/java/aiyh/utils/cus_rest/pojo/CusRestTemplateResponse.java @@ -0,0 +1,104 @@ +package aiyh.utils.cus_rest.pojo; + +import aiyh.utils.api_log.cus_api_log.dto.CusApiLogBaseDto; +import aiyh.utils.cus_rest.interfaces.CusDataDecipher; +import aiyh.utils.httpUtil.ResponeVo; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; +import java.util.function.BiConsumer; +import java.util.function.Consumer; + + +/** + *

自定义请求

+ * + * @author xuanran.wang + * @date 2023/4/6 19:34 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class CusRestTemplateResponse { + /** + *

响应对象

+ **/ + private ResponeVo vo; + /** + *

请求参数

+ **/ + private Object requestParam; + /** + *

接口成功字段标识

+ **/ + private String successField; + /** + *

接口请求成功时响应值

+ **/ + private Object successValue; + /** + *

接口响应错误字段名

+ **/ + private String errorMsg; + /** + *

data字段路径

+ **/ + private String dataKey; + /** + *

接口响应信息

+ **/ + private String msg; + /** + *

接口响应map

+ **/ + private Map response; + /** + *

解密接口 如果接口有加密可自行实现解密接口

+ **/ + private CusDataDecipher cusDataDecipher; + /** + *

请求url

+ **/ + private String url; + /** + *

运行异常

+ **/ + private Exception exception; + /** + *

请求完是否执行响应验证 默认做校验

+ **/ + @Builder.Default + private boolean checkResponse = true; + /** + *

错误回调

+ **/ + private BiConsumer errorCallBack; + /** + *

是否将日志写入建模 默认不写入

+ **/ + @Builder.Default + private boolean writeLog = false; + /** + *

日志实体类

+ **/ + private CusApiLogBaseDto logDto; + /** + *

日志模块id

+ **/ + private String logModelId; + /** + *

成功回调

+ **/ + private Consumer successCallBack; + /** + *

是否异步写日志 默认异步

+ **/ + @Builder.Default + private boolean asyncWriteLog = true; + + +} diff --git a/src/main/java/com/engine/kq/wfset/action/KqDeductionVacationAction.java b/src/main/java/com/engine/kq/wfset/action/KqDeductionVacationAction.java new file mode 100755 index 0000000..93322dc --- /dev/null +++ b/src/main/java/com/engine/kq/wfset/action/KqDeductionVacationAction.java @@ -0,0 +1,107 @@ +package com.engine.kq.wfset.action; + +import com.engine.kq.biz.KQAttProcSetComInfo; +import com.engine.kq.biz.KQFlowActiontBiz; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.log.KQLog; +import com.engine.kq.wfset.bean.SplitBean; +import com.engine.kq.wfset.util.KQFlowLeaveUtil; +import com.engine.kq.wfset.util.SplitActionUtil; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.resource.ResourceComInfo; +import weaver.interfaces.workflow.action.Action; +import weaver.interfaces.workflow.action.RollBackAction; +import weaver.soa.workflow.request.RequestInfo; +import weaver.workflow.workflow.WorkflowComInfo; + +/** + * 兼容E8的请假扣减action + */ +public class KqDeductionVacationAction extends BaseBean implements Action, RollBackAction { + private KQLog kqLog = new KQLog(); + + @Override + public String execute(RequestInfo request) { + //e8 的状态标识 + int DEDUCTION = 0; + int FREEZE = 1; + int RELEASE = 2; + this.writeLog("KqDeductionVacationAction", "do action on request:" + request.getRequestid()); + String requestid = request.getRequestid(); + kqLog.info("do KqDeductionVacationAction on requestid:"+requestid); + int requestidInt = Util.getIntValue(requestid, 0); + + String workflowid = request.getWorkflowid(); + String formid = new WorkflowComInfo().getFormId(workflowid); + KQAttProcSetComInfo kqAttProcSetComInfo = new KQAttProcSetComInfo(); + int cur_kqtype = Util.getIntValue(kqAttProcSetComInfo.getkqType(workflowid),-1); + + if(cur_kqtype != KqSplitFlowTypeEnum.LEAVE.getFlowtype()){ + return Action.SUCCESS; + } + + try { + + KQFlowLeaveUtil kqFlowLeaveUtil = new KQFlowLeaveUtil(); + KQFlowActiontBiz kqFlowActiontBiz = new KQFlowActiontBiz(); + ResourceComInfo rci = new ResourceComInfo(); + + List splitBeans = new ArrayList(); + DateTimeFormatter datetimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); + RecordSet rs = new RecordSet(); + String proc_set_sql = "select * from kq_att_proc_set where field001 = ? and field002 = ? "; + rs.executeQuery(proc_set_sql, workflowid,formid); + if(rs.next()){ + String proc_set_id = rs.getString("id"); + //得到这个考勤流程设置是否使用明细 + String usedetails = rs.getString("usedetail"); + int kqtype = Util.getIntValue(rs.getString("field006")); + Map map = new HashMap<>(); + if(requestidInt > 0){ + map.put("requestId", "and t.requestId = " + requestidInt); + } + + Map sqlMap = kqFlowActiontBiz.handleSql(proc_set_id, usedetails, requestidInt,kqtype,map); + Map result = kqFlowLeaveUtil.handleKQLeaveAction(sqlMap, splitBeans, datetimeFormatter, Util.getIntValue(workflowid), requestidInt, rci); + if(!result.isEmpty()){ + String error = Util.null2String(result.get("message")); + request.getRequestManager().setMessageid("666" + request.getRequestid() + "999"); + request.getRequestManager().setMessagecontent(error); + return Action.FAILURE_AND_CONTINUE; + } + + } + + //先在这里执行扣减动作 + SplitActionUtil.handleLeaveAction(splitBeans,requestid); + //然后再把扣减的了数据更新下KQ_ATT_VACATION表 + String updateFreezeSql = "update KQ_ATT_VACATION set status=? where requestId=? and workflowId = ? "; + boolean isUpdate = rs.executeUpdate(updateFreezeSql,DEDUCTION,requestid,workflowid); + if(!isUpdate){ + request.getRequestManager().setMessageid("666" + request.getRequestid() + "999"); + request.getRequestManager().setMessagecontent(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(82823,weaver.general.ThreadVarLanguage.getLang())+"action"+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005361,weaver.general.ThreadVarLanguage.getLang())+""+updateFreezeSql+"("+DEDUCTION+","+requestid+","+workflowid+")"); + return Action.FAILURE_AND_CONTINUE; + } + } catch (Exception e) { + writeLog(e); + request.getRequestManager().setMessageid("11111" + request.getRequestid() + "22222"); + request.getRequestManager().setMessagecontent("请假流程【扣减action】报错,请联系管理员!"); + return Action.FAILURE_AND_CONTINUE; + } + + return Action.SUCCESS; + + } + + @Override + public String executeRollBack(RequestInfo request) { + return null; + } +} diff --git a/src/main/java/com/engine/kq/wfset/action/KqFreezeVacationAction.java b/src/main/java/com/engine/kq/wfset/action/KqFreezeVacationAction.java new file mode 100755 index 0000000..b06633f --- /dev/null +++ b/src/main/java/com/engine/kq/wfset/action/KqFreezeVacationAction.java @@ -0,0 +1,183 @@ +package com.engine.kq.wfset.action; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.biz.KQAttProcSetComInfo; +import com.engine.kq.biz.KQFlowActiontBiz; +import com.engine.kq.biz.KQLeaveRulesBiz; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.log.KQLog; +import com.engine.kq.wfset.bean.SplitBean; +import com.engine.kq.wfset.util.KQFlowLeaveUtil; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.resource.ResourceComInfo; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.workflow.workflow.WorkflowComInfo; + +/** + * 兼容E8的请假冻结action + */ +public class KqFreezeVacationAction extends BaseBean implements Action { + private KQLog kqLog = new KQLog(); + + @Override + public String execute(RequestInfo request) { + //e8 的状态标识 + int DEDUCTION = 0; + int FREEZE = 1; + int RELEASE = 2; + this.writeLog("KqFreezeVacationAction", "do action on request:" + request.getRequestid()); + String requestid = request.getRequestid(); + kqLog.info("do KqFreezeVacationAction on requestid:"+requestid); + int requestidInt = Util.getIntValue(requestid, 0); + + String workflowid = request.getWorkflowid(); + String formid = new WorkflowComInfo().getFormId(workflowid); + KQAttProcSetComInfo kqAttProcSetComInfo = new KQAttProcSetComInfo(); + int cur_kqtype = Util.getIntValue(kqAttProcSetComInfo.getkqType(workflowid),-1); + + if(cur_kqtype != KqSplitFlowTypeEnum.LEAVE.getFlowtype()){ + return Action.SUCCESS; + } + + try { + List splitBeans = new ArrayList(); + + KQFlowLeaveUtil kqFlowLeaveUtil = new KQFlowLeaveUtil(); + KQFlowActiontBiz kqFlowActiontBiz = new KQFlowActiontBiz(); + ResourceComInfo rci = new ResourceComInfo(); + DateTimeFormatter datetimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + String proc_set_sql = "select * from kq_att_proc_set where field001 = ? and field002 = ? "; + rs.executeQuery(proc_set_sql, workflowid,formid); + if(rs.next()){ + String proc_set_id = rs.getString("id"); + //得到这个考勤流程设置是否使用明细 + String usedetails = rs.getString("usedetail"); + int kqtype = Util.getIntValue(rs.getString("field006")); + Map map = new HashMap<>(); + if(requestidInt > 0){ + map.put("requestId", "and t.requestId = " + requestidInt); + } + + Map sqlMap = kqFlowActiontBiz.handleSql(proc_set_id, usedetails, requestidInt,kqtype,map); + Map result = kqFlowLeaveUtil.handleKQLeaveAction(sqlMap, splitBeans, datetimeFormatter, Util.getIntValue(workflowid), requestidInt, rci); + if(!result.isEmpty()){ + String error = Util.null2String(result.get("message")); + request.getRequestManager().setMessageid("666" + request.getRequestid() + "999"); + request.getRequestManager().setMessagecontent(error); + return Action.FAILURE_AND_CONTINUE; + } + + } + /** + * add by xuanran.Wang + */ + this.handlerSplitBean(splitBeans, request.getRequestManager().getBillTableName(), requestid); + kqLog.info("KqFreezeVacationAction splitBeans:"+ JSON.toJSONString(splitBeans)); + String batchSql = "insert into KQ_ATT_VACATION (requestId,workflowId,dataid,detailid,resourceId,fromDate,fromTime,toDate,toTime,duration,newLeaveType,durationrule,status)"+ + " values(?,?,?,?,?,?,?,?,?,?,?,?,?) "; + List params = new ArrayList(); + + String delSql = "delete from KQ_ATT_VACATION where requestId=?"; + List delparams = new ArrayList(); + + for(SplitBean bean : splitBeans){ + List beanParams = new ArrayList(); + String newLeaveType = bean.getNewLeaveType(); + //这个表里只存储含有假期余额的 + boolean balanceEnable = KQLeaveRulesBiz.getBalanceEnable(newLeaveType); + kqLog.info("KqFreezeVacationAction newLeaveType:"+ newLeaveType+":balanceEnable:"+balanceEnable); + if(!balanceEnable) { + continue; + } + beanParams.add(bean.getRequestId()); + beanParams.add(bean.getWorkflowId()); + beanParams.add(bean.getDataId()); + beanParams.add(bean.getDetailId()); + beanParams.add(bean.getResourceId()); + beanParams.add(bean.getFromDate()); + beanParams.add(bean.getFromTime()); + beanParams.add(bean.getToDate()); + beanParams.add(bean.getToTime()); + beanParams.add(bean.getDuration()); + beanParams.add(bean.getNewLeaveType()); + beanParams.add(bean.getDurationrule()); + beanParams.add(FREEZE); + params.add(beanParams); + + List delParam = new ArrayList(); + delParam.add(bean.getRequestId()); + delparams.add(delParam); + } + if(!params.isEmpty()){ + boolean delOk = rs1.executeBatchSql(delSql, delparams); + if(!delOk){ + request.getRequestManager().setMessageid("666" + request.getRequestid() + "999"); + request.getRequestManager().setMessagecontent(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(1232,weaver.general.ThreadVarLanguage.getLang())+"action"+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005361,weaver.general.ThreadVarLanguage.getLang())+""+params); + kqLog.info("KqFreezeVacationAction删除数据失败:"+requestid); + return Action.FAILURE_AND_CONTINUE; + } + + boolean isOk = rs1.executeBatchSql(batchSql, params); + if(!isOk){ + request.getRequestManager().setMessageid("666" + request.getRequestid() + "999"); + request.getRequestManager().setMessagecontent(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(1232,weaver.general.ThreadVarLanguage.getLang())+"action"+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005361,weaver.general.ThreadVarLanguage.getLang())+""+params); + return Action.FAILURE_AND_CONTINUE; + } + }else{ + kqLog.info("KqFreezeVacationAction没有冻结数据:"+requestid); + } + } catch (Exception e) { + kqLog.info("KqFreezeVacationAction:"+e); + request.getRequestManager().setMessageid("11111" + request.getRequestid() + "22222"); + request.getRequestManager().setMessagecontent("请假流程【冻结action】报错,请联系管理员!"); + return Action.FAILURE_AND_CONTINUE; + } + + return Action.SUCCESS; + + } + + /** + *

对考勤实体类做修改

+ * @author xuanran.wang + * @dateTime 2023/7/31 15:13 + * @param splitBeans 考勤实体类 + * @param billTable 表名 + * @param requestId 请求id + **/ + public void handlerSplitBean(List splitBeans, String billTable, String requestId){ + try { + RecordSet tempRs = new RecordSet(); + String sql = "select duration from " + billTable + " where requestid = ?"; + if(CollectionUtils.isNotEmpty(splitBeans)){ + if (tempRs.executeQuery(sql, requestId) && tempRs.next()) { + for (SplitBean splitBean : splitBeans) { + String workflowDuration = Util.null2String(tempRs.getString("duration")); + if(StringUtils.isBlank(workflowDuration)){ + continue; + } + splitBean.setDuration(workflowDuration); + } + }else { + kqLog.info("handlerSplitBean sql execute error! sql : " + sql); + } + } + }catch (Exception e){ + kqLog.info("handlerSplitBean error!: " + e.getMessage()); + } + } + +} diff --git a/src/main/java/com/engine/kq/wfset/action/KqPaidLeaveAction.java b/src/main/java/com/engine/kq/wfset/action/KqPaidLeaveAction.java new file mode 100755 index 0000000..a6ba377 --- /dev/null +++ b/src/main/java/com/engine/kq/wfset/action/KqPaidLeaveAction.java @@ -0,0 +1,100 @@ +package com.engine.kq.wfset.action; + +import com.engine.kq.biz.KQFLowEventLogBiz; +import com.engine.kq.biz.KQFlowActiontBiz; +import com.engine.kq.biz.KQOvertimeLogBiz; +import com.engine.kq.log.KQLog; +import com.engine.kq.wfset.bean.SplitBean; +import com.engine.kq.wfset.util.KQFlowOvertimeUtil; +import com.engine.kq.wfset.util.SplitActionUtil; +import com.google.common.collect.Maps; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.resource.ResourceComInfo; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.workflow.workflow.WorkflowComInfo; + +/** + * 兼容E8的加班生成调休action + */ +public class KqPaidLeaveAction extends BaseBean implements Action { + private KQLog kqLog = new KQLog(); + + @Override + public String execute(RequestInfo request) { + this.writeLog("KqPaidLeaveAction", "do action on request:" + request.getRequestid()); + String requestid = request.getRequestid(); + kqLog.info("do KqPaidLeaveAction on requestid:"+requestid); + int requestidInt = Util.getIntValue(requestid, 0); + + String workflowid = request.getWorkflowid(); + String formid = new WorkflowComInfo().getFormId(workflowid); + KQFLowEventLogBiz kqfLowEventLogBiz = new KQFLowEventLogBiz(); + String logKey = "|key|requestid|"+requestid; + + try { + List splitBeans = new ArrayList(); + + KQFlowActiontBiz kqFlowActiontBiz = new KQFlowActiontBiz(); + KQFlowOvertimeUtil kqFlowOvertimeUtil = new KQFlowOvertimeUtil(); + ResourceComInfo rci = new ResourceComInfo(); + DateTimeFormatter datetimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); + RecordSet rs = new RecordSet(); + String proc_set_sql = "select * from kq_att_proc_set where field001 = ? and field002 = ? "; + rs.executeQuery(proc_set_sql, workflowid,formid); + + Map eventLogMap = Maps.newHashMap(); + eventLogMap.put("proc_set_sql", proc_set_sql); + eventLogMap.put("workflowid", workflowid); + eventLogMap.put("formid", formid); + + String uuid = ""; + if(rs.next()){ + String proc_set_id = rs.getString("id"); + //得到这个考勤流程设置是否使用明细 + String usedetails = rs.getString("usedetail"); + int kqtype = Util.getIntValue(rs.getString("field006")); + Map map = new HashMap<>(); + if(requestidInt > 0){ + map.put("requestId", "and t.requestId = " + requestidInt); + } + Map sqlMap = kqFlowActiontBiz.handleSql(proc_set_id, usedetails, requestidInt,kqtype,map); + + uuid = kqfLowEventLogBiz.logEvent("request|Creatorid|"+request.getCreatorid(),eventLogMap,"KqPaidLeaveAction|触发生成调休action"+logKey); + Map result = kqFlowOvertimeUtil.handleKQOvertimeAction(sqlMap, splitBeans, datetimeFormatter, Util.getIntValue(workflowid), requestidInt, rci,uuid); + if(!result.isEmpty()){ + String error = Util.null2String(result.get("message")); + request.getRequestManager().setMessageid("666" + request.getRequestid() + "999"); + request.getRequestManager().setMessagecontent(error); + return Action.FAILURE_AND_CONTINUE; + } + } + // 生成调休 在归档的时候再单独处理下加班规则第二种情况 + SplitActionUtil.handleOverTimeAction(splitBeans, requestid,false,uuid); + } catch (Exception e) { + writeLog(e); + request.getRequestManager().setMessageid("11111" + request.getRequestid() + "22222"); + request.getRequestManager().setMessagecontent("加班流程【加班时间转为可调休时间action】报错,请联系管理员!"); + StringWriter errorsWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(errorsWriter)); + kqLog.info("加班流程【加班时间转为可调休时间action】报错,请联系管理员!"+errorsWriter.toString()); + Map eventLogMap = Maps.newHashMap(); + eventLogMap.put("action_error", errorsWriter.toString()); + String uuid = kqfLowEventLogBiz.logEvent("request|Creatorid|"+request.getCreatorid(),eventLogMap,"KqPaidLeaveAction|触发生成调休action"+logKey); + return Action.FAILURE_AND_CONTINUE; + } + + return Action.SUCCESS; + + } + +} diff --git a/src/main/java/com/engine/kq/wfset/action/KqReleaseVacationAction.java b/src/main/java/com/engine/kq/wfset/action/KqReleaseVacationAction.java new file mode 100755 index 0000000..eab7693 --- /dev/null +++ b/src/main/java/com/engine/kq/wfset/action/KqReleaseVacationAction.java @@ -0,0 +1,56 @@ +package com.engine.kq.wfset.action; + +import com.engine.kq.biz.KQAttProcSetComInfo; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.log.KQLog; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; + +/** + * 兼容E8的请假释放action + */ +public class KqReleaseVacationAction extends BaseBean implements Action { + private KQLog kqLog = new KQLog(); + + @Override + public String execute(RequestInfo request) { + //e8 的状态标识 + int RELEASE = 2; + this.writeLog("KqReleaseVacationAction", "do action on request:" + request.getRequestid()); + String requestid = request.getRequestid(); + kqLog.info("do KqReleaseVacationAction on requestid:"+requestid); + int requestidInt = Util.getIntValue(requestid, 0); + String workflowid = request.getWorkflowid(); + KQAttProcSetComInfo kqAttProcSetComInfo = new KQAttProcSetComInfo(); + int cur_kqtype = Util.getIntValue(kqAttProcSetComInfo.getkqType(workflowid),-1); + + if(cur_kqtype != KqSplitFlowTypeEnum.LEAVE.getFlowtype()){ + return Action.SUCCESS; + } + + try { + + RecordSet rs = new RecordSet(); + String updateFreezeSql = "update KQ_ATT_VACATION set status=2 where requestId=? and workflowId = ? "; + boolean isUpdate = rs.executeUpdate(updateFreezeSql,requestidInt,workflowid); + if(!isUpdate){ + request.getRequestManager().setMessageid("666" + request.getRequestid() + "999"); + request.getRequestManager().setMessagecontent(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(82824,weaver.general.ThreadVarLanguage.getLang())+"action"+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005361,weaver.general.ThreadVarLanguage.getLang())+"("+RELEASE+","+requestid+","+workflowid+")"); + return Action.FAILURE_AND_CONTINUE; + } + + } catch (Exception e) { + writeLog(e); + request.getRequestManager().setMessageid("11111" + request.getRequestid() + "22222"); + request.getRequestManager().setMessagecontent("请假流程【释放action】报错,请联系管理员!"); + return Action.FAILURE_AND_CONTINUE; + } + + return Action.SUCCESS; + + } + +} diff --git a/src/main/java/com/engine/kq/wfset/action/KqSplitAction.java b/src/main/java/com/engine/kq/wfset/action/KqSplitAction.java new file mode 100755 index 0000000..8ab67a6 --- /dev/null +++ b/src/main/java/com/engine/kq/wfset/action/KqSplitAction.java @@ -0,0 +1,72 @@ +package com.engine.kq.wfset.action; + +import com.engine.kq.biz.KQFlowActiontBiz; +import com.engine.kq.log.KQLog; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.HashMap; +import java.util.Map; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.workflow.workflow.WorkflowComInfo; + +/** + * 考勤流程数据拆分action + */ +public class KqSplitAction extends BaseBean implements Action { + private KQLog kqLog = new KQLog(); + + @Override + public String execute(RequestInfo request) { + this.writeLog("KqSplitAction", "do action on request:" + request.getRequestid()); + String requestid = request.getRequestid(); + kqLog.info("do KqSplitAction on requestid:"+requestid); + int requestidInt = Util.getIntValue(requestid, 0); + + String workflowid = request.getWorkflowid(); + String formid = new WorkflowComInfo().getFormId(workflowid); + + try { + KQFlowActiontBiz kqFlowActiontBiz = new KQFlowActiontBiz(); + RecordSet rs = new RecordSet(); + String proc_set_sql = "select * from kq_att_proc_set where field001 = ? and field002 = ? "; + rs.executeQuery(proc_set_sql, workflowid,formid); + if(rs.next()){ + String proc_set_id = rs.getString("id"); + //得到这个考勤流程设置是否使用明细 + String usedetails = rs.getString("usedetail"); + + int kqtype = Util.getIntValue(rs.getString("field006")); + kqLog.info("do action on kqtype:" + kqtype+":requestidInt:"+requestidInt); + Map map = new HashMap(); + if(requestidInt > 0){ + map.put("requestId", "and t.requestId = " + requestidInt); + } + + Map result = kqFlowActiontBiz.handleKQFlowAction(proc_set_id, usedetails, requestidInt, kqtype, Util.getIntValue(workflowid), false,false,map); + + if(!result.isEmpty()){ + String error = Util.null2String(result.get("message")); + request.getRequestManager().setMessageid("666" + request.getRequestid() + "999"); + request.getRequestManager().setMessagecontent(error); + return Action.FAILURE_AND_CONTINUE; + } + } + } catch (Exception e) { + kqLog.info("流程数据报错:KqSplitAction:"); + StringWriter errorsWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(errorsWriter)); + kqLog.info(errorsWriter.toString()); + request.getRequestManager().setMessageid("11111" + request.getRequestid() + "22222"); + request.getRequestManager().setMessagecontent("【考勤报表统计action】报错,请联系管理员!"); + return Action.FAILURE_AND_CONTINUE; + } + + return Action.SUCCESS; + + } + +} diff --git a/src/main/java/weaver/xuanran/wang/xk_hospital/model_check/entity/CheckErrorInfo.java b/src/main/java/weaver/xuanran/wang/xk_hospital/model_check/entity/CheckErrorFieldInfo.java similarity index 74% rename from src/main/java/weaver/xuanran/wang/xk_hospital/model_check/entity/CheckErrorInfo.java rename to src/main/java/weaver/xuanran/wang/xk_hospital/model_check/entity/CheckErrorFieldInfo.java index 57c997c..fea74e4 100644 --- a/src/main/java/weaver/xuanran/wang/xk_hospital/model_check/entity/CheckErrorInfo.java +++ b/src/main/java/weaver/xuanran/wang/xk_hospital/model_check/entity/CheckErrorFieldInfo.java @@ -5,6 +5,8 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import java.util.Map; + /** *

* @@ -15,11 +17,14 @@ import lombok.NoArgsConstructor; @Builder @AllArgsConstructor @NoArgsConstructor -public class CheckErrorInfo { +public class CheckErrorFieldInfo { private String tableName; private String dataId; private String errorFieldName; private String errorMsg; private Object currentValue; private String mainId; + private String url; + private Map mainMap; + private Map detailMap; } diff --git a/src/main/java/weaver/xuanran/wang/xk_hospital/model_check/entity/XkModelCusCheckFiledConfig.java b/src/main/java/weaver/xuanran/wang/xk_hospital/model_check/entity/XkModelCusCheckFiledConfig.java index c013272..121b44e 100644 --- a/src/main/java/weaver/xuanran/wang/xk_hospital/model_check/entity/XkModelCusCheckFiledConfig.java +++ b/src/main/java/weaver/xuanran/wang/xk_hospital/model_check/entity/XkModelCusCheckFiledConfig.java @@ -1,5 +1,6 @@ package weaver.xuanran.wang.xk_hospital.model_check.entity; +import aiyh.utils.Util; import lombok.Data; import java.util.List; @@ -24,4 +25,5 @@ public class XkModelCusCheckFiledConfig { private String modelTableName; private List modelFieldNameList; private String cusWhere; + private String noCheckExpression; } diff --git a/src/main/java/weaver/xuanran/wang/xk_hospital/model_check/mapper/XkModelCusCheckMapper.java b/src/main/java/weaver/xuanran/wang/xk_hospital/model_check/mapper/XkModelCusCheckMapper.java index f270ea0..0c41810 100644 --- a/src/main/java/weaver/xuanran/wang/xk_hospital/model_check/mapper/XkModelCusCheckMapper.java +++ b/src/main/java/weaver/xuanran/wang/xk_hospital/model_check/mapper/XkModelCusCheckMapper.java @@ -2,7 +2,6 @@ package weaver.xuanran.wang.xk_hospital.model_check.mapper; import aiyh.utils.annotation.recordset.*; import weaver.xuanran.wang.xk_hospital.model_check.entity.ModelFieldInfo; -import weaver.xuanran.wang.xk_hospital.model_check.entity.XkModelCusCheckConfig; import weaver.xuanran.wang.xk_hospital.model_check.entity.XkModelCusCheckFiledConfig; import weaver.xuanran.wang.xk_hospital.model_check.entity.XkModelCusCheckFiledGroupConfig; @@ -25,7 +24,7 @@ public interface XkModelCusCheckMapper { "from $t{modelTableName}_dt2 a " + "left join workflow_mode_table_view b " + "on a.model_table = b.id " + - "where enable = 0") + "where enable = 0 or enable is null") @Associations( @Association(property = "modelFieldNameList", column = "model_field", id = @Id(value = String.class,methodId = 1))) List queryConditionList(@ParamMapper("modelTableName")String modelTableName); @@ -76,4 +75,9 @@ public interface XkModelCusCheckMapper { String queryCusSqlDate(@SqlString String sql, @ParamMapper("mainMap") Map mainMap, @ParamMapper("detailMap") Map detailMap); + + @Select(custom = true) + String select(@SqlString String sql, + @ParamMapper("main") Map param1, + @ParamMapper("detail") Map param); } diff --git a/src/main/java/weaver/xuanran/wang/xk_hospital/model_check/service/XkModelCusCheckService.java b/src/main/java/weaver/xuanran/wang/xk_hospital/model_check/service/XkModelCusCheckService.java index b726622..9b0cf34 100644 --- a/src/main/java/weaver/xuanran/wang/xk_hospital/model_check/service/XkModelCusCheckService.java +++ b/src/main/java/weaver/xuanran/wang/xk_hospital/model_check/service/XkModelCusCheckService.java @@ -2,12 +2,13 @@ package weaver.xuanran.wang.xk_hospital.model_check.service; import aiyh.utils.Util; import aiyh.utils.function.Bi4Function; -import aiyh.utils.tool.Assert; +import aiyh.utils.response_deal.ResponseMappingDeal; +import aiyh.utils.tool.cn.hutool.core.map.MapUtil; import aiyh.utils.tool.cn.hutool.core.util.StrUtil; import aiyh.utils.zwl.common.ToolUtil; import com.alibaba.fastjson.JSONObject; +import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang3.StringUtils; import weaver.xuanran.wang.xk_hospital.model_check.entity.*; import weaver.xuanran.wang.xk_hospital.model_check.mapper.XkModelCusCheckMapper; import weaver.xuanran.wang.xk_hospital.model_check.util.CheckRuleMethodUtil; @@ -28,32 +29,48 @@ import java.util.stream.Collectors; public class XkModelCusCheckService { private final XkModelCusCheckMapper mapper = Util.getMapper(XkModelCusCheckMapper.class); - private final ToolUtil toolUtil = new ToolUtil(); + private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); + /** + *

获取建模自定义校验配置

+ * @author xuanran.wang + * @dateTime 2023/7/31 13:17 + **/ public List getFieldCheckRuleConfigList(){ String configTableName = Util.null2DefaultStr(toolUtil.getSystemParamValue("checkRuleConfigTableName"), "uf_yyhcfxgz"); return mapper.queryConditionList(configTableName); } + + /** + *

校验所有数据

+ * @author xuanran.wang + * @dateTime 2023/7/31 13:18 + * @param configList 所有配置 + **/ public void checkModelData(List configList){ // 根据建模表名进行分组 查找出每个表对应有哪些校验规则事项 Map> map = configList.stream().collect(Collectors.groupingBy(XkModelCusCheckFiledConfig::getModelTableName)); - List result = new ArrayList<>(); + if(MapUtil.isEmpty(map)){ + return; + } + List result = new ArrayList<>(); for (Map.Entry> entry : map.entrySet()) { // 在对每个表的第一个字段做分组 找出主表和明细表 List filedConfigs = entry.getValue(); Map> configMap = filedConfigs.stream() .collect(Collectors.groupingBy(item->item.getModelFieldNameList().get(0).getTableName())); - System.out.println("configMap : \n" + JSONObject.toJSONString(configMap)); + Util.getLogger().info("configMap : \n" + JSONObject.toJSONString(configMap)); // 主表表名 String mainTableName = entry.getKey(); + String modelId = Util.getModeIdByTableName(mainTableName); // 主表数据 - List> modelList = mapper.queryModelMain(mainTableName,""); + List> modelMainList = mapper.queryModelMain(mainTableName,""); // 主表校验规则配置 List mainTableConfig = configMap.remove(mainTableName); // 先处理主表数据 - checkModel(mainTableName, new HashMap<>(), modelList, mainTableConfig, result); + this.checkModel(mainTableName, new ArrayList<>(), modelMainList, mainTableConfig, result, modelId, 0); // 明细数据 for (Map.Entry> detailEntry : configMap.entrySet()) { String detailTable = detailEntry.getKey(); @@ -61,27 +78,36 @@ public class XkModelCusCheckService { if(CollectionUtils.isEmpty(detailModel)){ continue; } - // 主表的mainId - String detailMainId = Util.null2DefaultStr(detailModel.get(0).get("mainid"), ""); - if(StrUtil.isBlank(detailMainId)){ - continue; - } - List> mainList = modelList.stream().filter(item -> { - String id = Util.null2DefaultStr(item.get("id"), ""); - return StrUtil.isNotBlank(id) && detailMainId.equals(id); - }).collect(Collectors.toList()); - if(CollectionUtils.isEmpty(mainList)){ - Util.getLogger() - .error(Util.logStr("当前明细表: {}, detailMainId: {} 在主表数据集合中没找到对应的主表数据! 当前主表数据集合: {}", detailTable, detailMainId, JSONObject.toJSONString(modelList))); - continue; - } List detailConfig = detailEntry.getValue(); - checkModel(detailTable, mainList.get(0), detailModel, detailConfig, result); + this.checkModel(detailTable, modelMainList, detailModel, detailConfig, result, modelId, 1); } } - System.out.println("result : \n" + JSONObject.toJSONString(result)); + String checkErrorDataDel = Util.null2DefaultStr(toolUtil.getSystemParamValue("checkErrorDataDel"),"checkErrorDataDel"); + if(CollectionUtils.isEmpty(result)){ + return; + } + ResponseMappingDeal deal = new ResponseMappingDeal(); + Util.getLogger().info("校验不符合规则数据: \n" + JSONObject.toJSONString(result)); + List> list = convertListEntityToListMap(result); + Map data = new HashMap<>(); + data.put("data", list); + deal.doResponseSync(checkErrorDataDel, data); } + /** + *

将实体类集合转成map集合

+ * @author xuanran.wang + * @dateTime 2023/7/31 13:21 + * @param entities 实体类集合 + * @return List + **/ + public static List> convertListEntityToListMap(List entities) { + return entities.stream() + .map(entity -> (Map) OBJECT_MAPPER.convertValue(entity, Map.class)) + .collect(Collectors.toList()); + } + + public String buildWhereSql(String modelWhereSql, boolean joinQuery){ StringBuilder sb = new StringBuilder(); modelWhereSql = Util.sbc2dbcCase(modelWhereSql); @@ -97,40 +123,137 @@ public class XkModelCusCheckService { return sb.toString(); } + /** + *

按照规则校验数据

+ * @author xuanran.wang + * @dateTime 2023/7/31 13:21 + * @param tableName 当前表名 + * @param mainMapList 主表map集合 + * @param modelList 建模数据集合 + * @param configs 配置对象 + * @param result 不符合校验规则的对象集合 + * @param modelId 建模模块id + * @param type 类型 0: 主表, 1: 明细表 + **/ public void checkModel(String tableName, - Map mainMap, + List> mainMapList, List> modelList, List configs, - List result){ + List result, + String modelId, + int type){ if(CollectionUtils.isEmpty(configs) || CollectionUtils.isEmpty(modelList)){ return; } Map tempMainMap; for (Map map : modelList) { + boolean isMain = type == 0; + tempMainMap = isMain ? map : parseMainMap(mainMapList, map, tableName); for (XkModelCusCheckFiledConfig config : configs) { - int viewType = config.getModelFieldNameList().get(0).getViewType(); - boolean isMain = viewType == 0; - tempMainMap = isMain ? map : mainMap; - Bi4Function, Map, Boolean> function = CheckRuleMethodUtil.CHECK_RULE_MAP.get(config.getCheckRule()); - if(function == null){ + if(noCheckHandler(config, tempMainMap, map)){ continue; } - Boolean check = function.apply(config, null, tempMainMap, map); + Bi4Function, Map, Boolean> function = CheckRuleMethodUtil.CHECK_RULE_MAP.get(config.getCheckRule()); + if(function == null){ + Util.getLogger().error("获取执行函数为null! current rule : [ " + config.getCheckRule() + " ]"); + continue; + } + boolean check; + try { + check = function.apply(config, null, tempMainMap, map); + }catch (Exception e){ + Util.getLogger().error("执行校验失败!" + e.getMessage()); + check = false; + } if(!check){ - String fieldName = config.getModelFieldNameList().get(0).getFieldName(); - String mainId = Util.null2DefaultStr(tempMainMap.get("id"), ""); - String itemId = Util.null2DefaultStr(map.get("id"), ""); - CheckErrorInfo errorInfo = CheckErrorInfo.builder() - .errorMsg(config.getErrorMsg()) - .errorFieldName(fieldName) - .tableName(tableName) - .dataId(isMain ? mainId : itemId) - .currentValue(map.get(fieldName)) - .mainId(mainId) - .build(); - result.add(errorInfo); + result.add(buildCheckErrorFieldInfo(config, tempMainMap, map, tableName, isMain, modelId)); } } } } + + /** + *

跳过校验

+ * @author xuanran.wang + * @dateTime 2023/7/31 14:16 + * @param config 配置对象 + * @param tempMainMap 临时主表 + * @param map 建模map + * @return 是否符合跳过 + **/ + public boolean noCheckHandler(XkModelCusCheckFiledConfig config, + Map tempMainMap, + Map map){ + try { + String expression = config.getNoCheckExpression(); + if(StrUtil.isNotBlank(expression)){ + Bi4Function, Map, Boolean> function = + CheckRuleMethodUtil.CHECK_RULE_MAP.get(99); + if(function != null){ + return function.apply(config, null, tempMainMap, map); + } + } + }catch (Exception e){ + Util.getLogger().error("noCheckHandler error!" + e.getMessage()); + return false; + } + return false; + } + + /** + *

构造不合规对象

+ * @author xuanran.wang + * @dateTime 2023/7/31 13:24 + * @param config 配置对象 + * @param tempMainMap 主表对象 + * @param map 当前数据map + * @param tableName 表名 + * @param isMain 是否主表 + * @param modelId 模块id + * @return 错误信息对象 + **/ + public CheckErrorFieldInfo buildCheckErrorFieldInfo(XkModelCusCheckFiledConfig config, + Map tempMainMap, + Map map, + String tableName, + boolean isMain, + String modelId){ + String fieldName = config.getModelFieldNameList().get(0).getFieldName(); + String mainId = Util.null2DefaultStr(tempMainMap.get("id"), ""); + String itemId = Util.null2DefaultStr(map.get("id"), ""); + return CheckErrorFieldInfo.builder() + .errorMsg(config.getErrorMsg()) + .errorFieldName(fieldName) + .tableName(tableName) + .dataId(isMain ? mainId : itemId) + .currentValue(map.get(fieldName)) + .mainMap(tempMainMap) + .detailMap(map) + .mainId(mainId) + .url("/spa/cube/index.html#/main/cube/card?billid="+mainId+"&type=0&modeId="+modelId+"&formId="+config.getModelTable()) + .build(); + } + + /** + *

解析明细对应的主表对象

+ * @author xuanran.wang + * @dateTime 2023/7/27 17:31 + * @param modelMainList 主表集合 + * @param detailMap 明细对象 + * @param detailTable 明细表名 + * @return 主表对象 + **/ + public Map parseMainMap(List> modelMainList, + Map detailMap, + String detailTable){ + List> mainList = modelMainList.stream().filter(item -> { + String id = Util.null2DefaultStr(item.get("id"), ""); + return StrUtil.isNotBlank(id) && Util.null2DefaultStr(detailMap.get("mainid"),"").equals(id); + }).collect(Collectors.toList()); + if(CollectionUtils.isEmpty(mainList)){ + Util.getLogger() + .error(Util.logStr("当前明细表: {}, detailMainId: {} 在主表数据集合中没找到对应的主表数据! 当前主表数据集合: {}", detailTable, detailMap.get("mainid"), JSONObject.toJSONString(modelMainList))); + } + return mainList.get(0); + } } diff --git a/src/main/java/weaver/xuanran/wang/xk_hospital/model_check/util/CheckRuleMethodUtil.java b/src/main/java/weaver/xuanran/wang/xk_hospital/model_check/util/CheckRuleMethodUtil.java index d84ca8c..1ac6f90 100644 --- a/src/main/java/weaver/xuanran/wang/xk_hospital/model_check/util/CheckRuleMethodUtil.java +++ b/src/main/java/weaver/xuanran/wang/xk_hospital/model_check/util/CheckRuleMethodUtil.java @@ -3,7 +3,7 @@ package weaver.xuanran.wang.xk_hospital.model_check.util; import aiyh.utils.ScriptUtil; import aiyh.utils.Util; import aiyh.utils.annotation.MethodRuleNo; -import aiyh.utils.excention.CustomerException; + import aiyh.utils.function.Bi4Function; import aiyh.utils.tool.cn.hutool.core.util.StrUtil; import org.apache.commons.collections.CollectionUtils; @@ -16,6 +16,8 @@ import weaver.xuanran.wang.xk_hospital.model_check.mapper.XkModelCusCheckMapper; import java.lang.reflect.Method; import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; /** *

检查方法校验工具

@@ -63,12 +65,7 @@ public class CheckRuleMethodUtil { Map detailMap) { boolean check = true; for (ModelFieldInfo fieldInfo : filedConfig.getModelFieldNameList()) { - int mainOrDetail = fieldInfo.getViewType(); - if(mainOrDetail == 0){ - check = StrUtil.isNotBlank(Util.null2DefaultStr(mainMap.get(fieldInfo.getFieldName()),"")); - }else { - check = StrUtil.isNotBlank(Util.null2DefaultStr(detailMap.get(fieldInfo.getFieldName()),"")); - } + check = StrUtil.isNotBlank(parseFieldValue(fieldInfo, mainMap, detailMap)); } return check; } @@ -80,12 +77,7 @@ public class CheckRuleMethodUtil { Map detailMap) { try { for (ModelFieldInfo fieldInfo : filedConfig.getModelFieldNameList()) { - int mainOrDetail = fieldInfo.getViewType(); - if(mainOrDetail == 0) { - Integer.parseInt(Util.null2DefaultStr(mainMap.get(fieldInfo.getFieldName()), "")); - }else { - Integer.parseInt(Util.null2DefaultStr(detailMap.get(fieldInfo.getFieldName()), "")); - } + Integer.valueOf(parseFieldValue(fieldInfo, mainMap, detailMap)); } return true; } catch (Exception e) { @@ -165,27 +157,26 @@ public class CheckRuleMethodUtil { } - // @MethodRuleNo(value = 6, desc = "自定义表达式") + @MethodRuleNo(value = 99, desc = "自定义表达式") private static boolean checkCustomerExpression(XkModelCusCheckFiledConfig filedConfig, XkModelCusCheckFiledGroupConfig groupConfig, Map mainMap, Map detailMap) { - // String expression = Util.sbc2dbcCase(filedConfig.getCheckExpression()); - // if(StrUtil.isBlank(expression)){ - // return true; - // } - // try { - // if(filedConfig.getMainOrDetail() == 0){ - // return (Boolean)ScriptUtil.invokeScript(expression, mainMap, CUS_SCRIPT_FUN); - // } else { - // return (Boolean)ScriptUtil.invokeScript(expression, detailMap, CUS_SCRIPT_FUN); - // } - // }catch (Exception e){ - // log.error("自定义表达式执行失败! " + e.getMessage()); - // Util.logErrorStr(e); - // return false; - // } - return true; + String expression = Util.sbc2dbcCase(filedConfig.getCheckExpression()); + if(StrUtil.isBlank(expression)){ + return true; + } + try { + Map appentDtMap = detailMap.entrySet() + .stream() + .collect(Collectors.toMap(entry -> "dt." + entry.getKey(), Map.Entry::getValue)); + mainMap.putAll(appentDtMap); + return (Boolean)ScriptUtil.invokeScript(expression, mainMap, CUS_SCRIPT_FUN); + }catch (Exception e){ + log.error("自定义表达式执行失败! " + e.getMessage()); + Util.logErrorStr(e); + return false; + } } @MethodRuleNo(value = 4, desc = "两个日期相差月数") @@ -194,12 +185,12 @@ public class CheckRuleMethodUtil { Map mainMap, Map detailMap) { List fieldNameList = filedConfig.getModelFieldNameList(); - if(!checkFieldConf(fieldNameList)){ + if(checkFieldConf(fieldNameList)){ return false; } Map dateMap = parse2DateMap(filedConfig, fieldNameList, mainMap, detailMap); - String scriptStr = "CusJexlFunctions.twoDateSubNoFormat(beginDate,endDate, 1) " + filedConfig.getCheckExpression(); - return (boolean) ScriptUtil.invokeScript(scriptStr, dateMap); + String scriptStr = "CusJexlFunctions.twoDateSubNoFormat(beginDate,endDate,1) " + filedConfig.getCheckExpression(); + return (boolean) ScriptUtil.invokeScript(scriptStr, dateMap, CUS_SCRIPT_FUN); } @@ -231,12 +222,12 @@ public class CheckRuleMethodUtil { Map mainMap, Map detailMap) { List fieldNameList = filedConfig.getModelFieldNameList(); - if(!checkFieldConf(fieldNameList)){ + if(checkFieldConf(fieldNameList)){ return false; } Map dateMap = parse2DateMap(filedConfig, fieldNameList, mainMap, detailMap); - String scriptStr = "CusJexlFunctions.compare2Date(beginDate,endDate) " + filedConfig.getCheckExpression(); - return (boolean) ScriptUtil.invokeScript(scriptStr, dateMap); + String scriptStr = "CusJexlFunctions.compare2Date(beginDate,endDate)"; + return (boolean) ScriptUtil.invokeScript(scriptStr, dateMap, CUS_SCRIPT_FUN); } public static String sqlHandle(String cusSql){ @@ -253,49 +244,45 @@ public class CheckRuleMethodUtil { public static boolean checkFieldConf(List fieldNameList) { if (CollectionUtils.isEmpty(fieldNameList) || fieldNameList.size() > 2) { Util.getLogger().error("校验规则选择日期相差月数时, 表单字段不能超过2个!"); - return false; + return true; } - return true; + return false; } public static Map parse2DateMap(XkModelCusCheckFiledConfig filedConfig, - List fieldNameList, - Map mainMap, - Map detailMap){ - String beginDate = ""; - String endDate = ""; + List fieldNameList, + Map mainMap, + Map detailMap) { Map dateMap = new HashMap<>(); - // 如果只勾选了一个字段 - if(fieldNameList.size() == 1){ - String cusWhere = filedConfig.getCusWhere(); - if(StrUtil.isNotBlank(cusWhere)){ - String sql = sqlHandle(cusWhere); - endDate = mapper.queryCusSqlDate(sql, mainMap, detailMap); - if(StrUtil.isBlank(endDate)){ - endDate = TimeUtil.getCurrentDateString(); - } - }else { - endDate = TimeUtil.getCurrentDateString(); - } - }else { - for (int i = 0; i < fieldNameList.size(); i++) { - ModelFieldInfo fieldInfo = fieldNameList.get(i); - String date; - if (fieldInfo.getViewType() == 0) { - date = Util.null2DefaultStr(mainMap.get(fieldInfo.getFieldName()),""); - }else { - date = Util.null2DefaultStr(detailMap.get(fieldInfo.getFieldName()),""); - } - if(i == 0){ - beginDate = date; - }else { - endDate = date; - } - } + String beginDate; + String endDate; + if (fieldNameList.size() == 1) { + String customerValue = filedConfig.getCustomerValue(); + endDate = StrUtil.isNotBlank(customerValue) + ? mapper.queryCusSqlDate(sqlHandle(customerValue), mainMap, detailMap) + : TimeUtil.getCurrentDateString(); + beginDate = parseFieldValue(fieldNameList.get(0), mainMap, detailMap); + } else { + List dates = fieldNameList.stream() + .map(fieldInfo -> parseFieldValue(fieldInfo, mainMap, detailMap)) + .collect(Collectors.toList()); + beginDate = dates.get(0); + endDate = dates.size() > 1 ? dates.get(1) : TimeUtil.getCurrentDateString(); } dateMap.put("endDate", endDate); dateMap.put("beginDate", beginDate); return dateMap; } + + + public static String parseFieldValue(ModelFieldInfo fieldInfo, + Map mainMap, + Map detailMap){ + if (fieldInfo.getViewType() == 0) { + return Util.null2DefaultStr(mainMap.get(fieldInfo.getFieldName()),""); + }else { + return Util.null2DefaultStr(detailMap.get(fieldInfo.getFieldName()),""); + } + } } diff --git a/src/main/java/weaver/xuanran/wang/xk_hospital/model_check/util/CusJexlFunctions.java b/src/main/java/weaver/xuanran/wang/xk_hospital/model_check/util/CusJexlFunctions.java index bacab09..3d7b572 100644 --- a/src/main/java/weaver/xuanran/wang/xk_hospital/model_check/util/CusJexlFunctions.java +++ b/src/main/java/weaver/xuanran/wang/xk_hospital/model_check/util/CusJexlFunctions.java @@ -214,22 +214,22 @@ public class CusJexlFunctions implements CusScriptFunInterface { LocalDate secondLocalDate = parseDateStr2LocalDate(secondDate, secondDateFormat); switch (type){ case 0:{ - return ChronoUnit.YEARS.between(firstLocalDate, secondLocalDate); + return Math.abs(ChronoUnit.YEARS.between(firstLocalDate, secondLocalDate)); } case 1:{ - return ChronoUnit.MONTHS.between(firstLocalDate, secondLocalDate); + return Math.abs(ChronoUnit.MONTHS.between(firstLocalDate, secondLocalDate)); } case 2:{ - return ChronoUnit.DAYS.between(firstLocalDate, secondLocalDate); + return Math.abs(ChronoUnit.DAYS.between(firstLocalDate, secondLocalDate)); } case 3:{ - return ChronoUnit.HOURS.between(firstLocalDate, secondLocalDate); + return Math.abs(ChronoUnit.HOURS.between(firstLocalDate, secondLocalDate)); } case 4:{ - return ChronoUnit.MINUTES.between(firstLocalDate, secondLocalDate); + return Math.abs(ChronoUnit.MINUTES.between(firstLocalDate, secondLocalDate)); } case 5:{ - return ChronoUnit.SECONDS.between(firstLocalDate, secondLocalDate); + return Math.abs(ChronoUnit.SECONDS.between(firstLocalDate, secondLocalDate)); } default: { return 0; diff --git a/src/test/java/xuanran/wang/http_test/test/TestMain.java b/src/test/java/xuanran/wang/http_test/test/TestMain.java index f6be11f..b04454a 100644 --- a/src/test/java/xuanran/wang/http_test/test/TestMain.java +++ b/src/test/java/xuanran/wang/http_test/test/TestMain.java @@ -1,11 +1,11 @@ package xuanran.wang.http_test.test; +import aiyh.utils.cus_rest.CusRestTemplate; +import aiyh.utils.cus_rest.pojo.CusRestTemplateResponse; import aiyh.utils.httpUtil.ResponeVo; import basetest.BaseTest; import com.alibaba.fastjson.JSONObject; import org.junit.Test; -import xuanran.wang.rest_test.pojo.CusRestTemplateResponse; -import xuanran.wang.rest_test.CusRestTemplate; import java.util.HashMap; import java.util.Map; diff --git a/src/test/java/xuanran/wang/log/cus_api_log/test/CusApiLogUtilTest.java b/src/test/java/xuanran/wang/log/test/CusApiLogUtilTest.java similarity index 86% rename from src/test/java/xuanran/wang/log/cus_api_log/test/CusApiLogUtilTest.java rename to src/test/java/xuanran/wang/log/test/CusApiLogUtilTest.java index ae4e744..f2987a2 100644 --- a/src/test/java/xuanran/wang/log/cus_api_log/test/CusApiLogUtilTest.java +++ b/src/test/java/xuanran/wang/log/test/CusApiLogUtilTest.java @@ -1,15 +1,15 @@ -package xuanran.wang.log.cus_api_log.test; +package xuanran.wang.log.test; +import aiyh.utils.api_log.cus_api_log.CusApiLogUtil; +import aiyh.utils.api_log.cus_api_log.dto.DemoDto; +import aiyh.utils.cus_rest.CusRestTemplate; +import aiyh.utils.cus_rest.pojo.CusRestTemplateResponse; import aiyh.utils.httpUtil.ResponeVo; import basetest.BaseTest; import org.junit.Test; import weaver.hrm.User; import weaver.soa.workflow.request.RequestInfo; import weaver.workflow.request.RequestManager; -import xuanran.wang.rest_test.pojo.CusRestTemplateResponse; -import xuanran.wang.log.cus_api_log.CusApiLogUtil; -import xuanran.wang.log.cus_api_log.dto.DemoDto; -import xuanran.wang.rest_test.CusRestTemplate; import java.util.HashMap; import java.util.Map; @@ -43,6 +43,8 @@ public class CusApiLogUtilTest extends BaseTest { .successField("code") .successValue(0) .errorMsg("msg") + .writeLog(true) + .asyncWriteLog(false) .logDto(demoDto) .build(); diff --git a/src/test/java/xuanran/wang/rest_test/Stu.java b/src/test/java/xuanran/wang/rest_test/Stu.java deleted file mode 100644 index 8a0f5a6..0000000 --- a/src/test/java/xuanran/wang/rest_test/Stu.java +++ /dev/null @@ -1,19 +0,0 @@ -package xuanran.wang.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/rest_test/pojo/CusRestTemplateResponse.java b/src/test/java/xuanran/wang/rest_test/pojo/CusRestTemplateResponse.java deleted file mode 100644 index dc15850..0000000 --- a/src/test/java/xuanran/wang/rest_test/pojo/CusRestTemplateResponse.java +++ /dev/null @@ -1,50 +0,0 @@ -package xuanran.wang.rest_test.pojo; - -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 xuanran.wang.log.cus_api_log.dto.CusApiLogBaseDto; - -import java.util.Map; -import java.util.function.BiConsumer; -import java.util.function.Consumer; - - -/** - *

自定义请求条件

- * - * @author xuanran.wang - * @date 2023/4/6 19:34 - */ -@Data -@Builder -@AllArgsConstructor -@NoArgsConstructor -public class CusRestTemplateResponse { - private ResponeVo vo; - private Object requestParam; - private String successField; - private Object successValue; - private String errorMsg; - private String dataKey; - private String msg; - private Map response; - private CusDataDecipher cusDataDecipher; - private String url; - private Exception exception; - @Builder.Default - private boolean checkResponse = true; - private BiConsumer errorCallBack; - @Builder.Default - private boolean writeLog = false; - private CusApiLogBaseDto logDto; - private String logModelId; - private Consumer successCallBack; - @Builder.Default - private boolean asyncWriteLog = true; - - -} diff --git a/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalCheckModelTest.java b/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalCheckModelTest.java index c78da15..10d84da 100644 --- a/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalCheckModelTest.java +++ b/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalCheckModelTest.java @@ -1,14 +1,20 @@ package xuanran.wang.xk_hospital.test; import aiyh.utils.ScriptUtil; +import aiyh.utils.Util; import aiyh.utils.tool.org.apache.commons.jexl3.*; import basetest.BaseTest; import com.alibaba.fastjson.JSONObject; +import com.engine.core.cfg.EngineConfigurationImpl; import org.apache.commons.collections.CollectionUtils; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import weaver.conn.RecordSet; import weaver.general.TimeUtil; import weaver.xuanran.wang.xk_hospital.model_check.entity.XkModelCusCheckConfig; import weaver.xuanran.wang.xk_hospital.model_check.entity.XkModelCusCheckFiledConfig; +import weaver.xuanran.wang.xk_hospital.model_check.mapper.XkModelCusCheckMapper; import weaver.xuanran.wang.xk_hospital.model_check.service.XkModelCusCheckService; import weaver.xuanran.wang.xk_hospital.model_check.util.CusJexlFunctions; @@ -29,6 +35,8 @@ public class XkHospitalCheckModelTest extends BaseTest { private final XkModelCusCheckService service = new XkModelCusCheckService(); private static final CusJexlFunctions FUN = new CusJexlFunctions(); + private final XkModelCusCheckMapper mapper = Util.getMapper(XkModelCusCheckMapper.class); + @Test public void testA(){ @@ -61,6 +69,19 @@ public class XkHospitalCheckModelTest extends BaseTest { public void testC(){ System.out.println(FUN.compare2Date("2023-07-26", "2023-07-27")); System.out.println(FUN.normalDateStrSubCurrentMonthAbs("2023-08-01")); - System.out.println(FUN.twoDateSubNoFormat("2023-08-01", "2023-09-01", 2)); + HashMap map = new HashMap<>(); + map.put("beginDate","2023-04-26" ); + map.put("endDate", "2023-07-27"); + String scriptStr = "CusJexlFunctions.twoDateSubNoFormat(beginDate,endDate,1) " + " >= 3"; + boolean b = (boolean) ScriptUtil.invokeScript(scriptStr, map, FUN); + System.out.println("b => " + b); + System.out.println(FUN.twoDateSubNoFormat("2023-04-26", "2023-07-27", 1)); + } + + @Test + public void testD(){ + Logger log = LoggerFactory.getLogger(XkHospitalCheckModelTest.class); + log.info("test log"); + log.info("this is format : 参数1: {}, 参数2: {}","a", "b"); } }