diff --git a/.gitignore b/.gitignore index e4ee4f5..4be73d9 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ log /log/ .DS_Store /src/main/resources/WEB-INF/prop/weaver.properties +/src/main/resources/ajzx/ /file/ /src/test/resources/application.properties diff --git a/javascript/xuanran.wang/longgong/NewProductTest.js b/javascript/xuanran.wang/longgong/NewProductTest.js index b0f6285..ca63af7 100644 --- a/javascript/xuanran.wang/longgong/NewProductTest.js +++ b/javascript/xuanran.wang/longgong/NewProductTest.js @@ -8,8 +8,8 @@ const threeMonthIndex = 1; const submitWaitNode = WfForm.convertFieldNameToId("sftjddjd"); // 下次超时提醒日期 const timeoutRemindDateFiled = WfForm.convertFieldNameToId("cstxrq"); -// 跟踪天数 -const trackingDays = WfForm.getFieldValue(trackTimeField) <= 1 ? 15 : 30; +// 跟踪天数 <= 1 ? 15 : 30; +const trackingDaysField = WfForm.convertFieldNameToId("gzts") // 跟踪触发行数 const trackingLineField = WfForm.convertFieldNameToId("gzcfxs"); $(() => { @@ -44,6 +44,7 @@ function getNodeNum(){ let currentDate = getCurrentDate(); let dayDiff = getDaysDiff(firstSaleDate, currentDate); console.log('当前天数与首台销售日期相差天数 : ', dayDiff) + let trackingDays = WfForm.getFieldValue(trackingDaysField); return Math.floor(dayDiff / trackingDays) + 1; } @@ -52,6 +53,7 @@ function initTimeoutDate(){ let firstSaleDate = WfForm.getFieldValue(firstSaleDateField); const nodeNum = getNodeNum(); console.log('到达节点次数 ', nodeNum); + let trackingDays = WfForm.getFieldValue(trackingDaysField); console.log('跟踪天数 ', trackingDays); let computeTimeoutDate = addDays(firstSaleDate, nodeNum * trackingDays); console.log('计算下次超时日期 ', computeTimeoutDate); diff --git a/src/main/java/aiyh/utils/action/CusBaseCronJob.java b/src/main/java/aiyh/utils/action/CusBaseCronJob.java index 2ac99a4..87d82b1 100644 --- a/src/main/java/aiyh/utils/action/CusBaseCronJob.java +++ b/src/main/java/aiyh/utils/action/CusBaseCronJob.java @@ -5,6 +5,8 @@ import aiyh.utils.excention.CustomerException; import org.apache.log4j.Logger; import weaver.interfaces.schedule.BaseCronJob; +import java.io.IOException; + /** *

基础定时任务模板方法

* @@ -41,7 +43,7 @@ public abstract class CusBaseCronJob extends BaseCronJob { * * @author youHong.ai ****************************************** */ - public abstract void runCode(); + public abstract void runCode() throws IOException; /** diff --git a/src/main/java/aiyh/utils/recordset/ResultMapper.java b/src/main/java/aiyh/utils/recordset/ResultMapper.java index 1f1389d..c25e24e 100644 --- a/src/main/java/aiyh/utils/recordset/ResultMapper.java +++ b/src/main/java/aiyh/utils/recordset/ResultMapper.java @@ -586,7 +586,7 @@ public class ResultMapper { if (collectionMapping != null) { Object collection = collection(rs, collectionMapping, method); try { - if (Objects.nonNull(value)) { + if (Objects.nonNull(collection)) { propertyDescriptor.getWriteMethod().invoke(o, collection); } } catch (Exception e) { diff --git a/src/main/java/com/api/bokang/xiao/porsche_repush/controller/ContractRePushController.java b/src/main/java/com/api/bokang/xiao/porsche_repush/controller/ContractRePushController.java new file mode 100644 index 0000000..137ef38 --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/porsche_repush/controller/ContractRePushController.java @@ -0,0 +1,54 @@ +package com.api.bokang.xiao.porsche_repush.controller; + +import aiyh.utils.ApiResult; +import aiyh.utils.Util; +import com.api.bokang.xiao.porsche_repush.service.ContractRePushService; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import org.apache.log4j.Logger; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.List; +import java.util.Map; + +/** + * @ClassName ContractRePushController + * @Author 肖博亢 + * @Date 2023/5/10 10:47 + * @Description

+ **/ +@Path("/xbk/porsche_repush") +public class ContractRePushController { + + private final Logger log = Util.getLogger(); + + private final ContractRePushService contractRePushService = new ContractRePushService(); + + /** + *

获取流程的总数

+ * @param request 请求体 + * @param response 响应体 + * @param param 请求参数 + * @return 请求结果 + */ + @Path("/contractRePush") + @POST + @Produces(MediaType.APPLICATION_JSON) + public String contractRePush(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map param) { + try{ + log.info("into contractRePush success params ==> "+param); + User loginUser = HrmUserVarify.getUser(request, response); + List> result = contractRePushService.contractRePushService(param,loginUser); + return ApiResult.success(result); + }catch (Exception e){ + log.error("contractRePush error ==> "+ Util.getErrString(e)); + return ApiResult.error(e.getMessage()); + } + } + +} diff --git a/src/main/java/com/api/bokang/xiao/porsche_repush/mapper/QueryMapper.java b/src/main/java/com/api/bokang/xiao/porsche_repush/mapper/QueryMapper.java new file mode 100644 index 0000000..d161879 --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/porsche_repush/mapper/QueryMapper.java @@ -0,0 +1,24 @@ +package com.api.bokang.xiao.porsche_repush.mapper; + +import aiyh.utils.annotation.recordset.ParamMapper; +import aiyh.utils.annotation.recordset.Select; +import aiyh.utils.annotation.recordset.SqlMapper; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName QueryMapper + * @Author 肖博亢 + * @Date 2023/5/10 11:00 + * @Description

+ **/ +@SqlMapper +public interface QueryMapper { + + @Select("select * from uf_zcht where id in $t{ids}") + List> queryContractByIds(@ParamMapper("ids")String ids); + + @Select("select * from actionsettingdetail where ACTIONID = (select id from actionsetting where actionname = #{actionName})") + List> queryActionParam(@ParamMapper("actionName")String actionName); +} diff --git a/src/main/java/com/api/bokang/xiao/porsche_repush/service/ContractRePushService.java b/src/main/java/com/api/bokang/xiao/porsche_repush/service/ContractRePushService.java new file mode 100644 index 0000000..fbecbda --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/porsche_repush/service/ContractRePushService.java @@ -0,0 +1,91 @@ +package com.api.bokang.xiao.porsche_repush.service; + +import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; +import com.alibaba.fastjson.JSON; +import com.api.bokang.xiao.porsche_repush.mapper.QueryMapper; +import org.apache.log4j.Logger; +import weaver.aiyh_pcn.common_fadada.action.CommonContractRevocationAction; +import weaver.aiyh_pcn.common_fadada.action.CommonCreateContractAction; +import weaver.aiyh_pcn.common_fadada.action.CommonOneselfSignAction; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @ClassName ContractRePushService + * @Author 肖博亢 + * @Date 2023/5/10 10:48 + * @Description

+ **/ +public class ContractRePushService { + + private final Logger log = Util.getLogger(); + + private final QueryMapper queryMapper = Util.getMapper(QueryMapper.class); + + public List> contractRePushService(Map param, User loginUser) { + String ids = Util.null2String(param.get("ids")); + int labelId = Util.getIntValue(String.valueOf(param.get("labelId"))); + String contractCreateAction = Util.null2String(param.get("contractCreateAction")); + String signOtherAction = Util.null2String(param.get("signOtherAction")); + String contractRevocationAction = Util.null2String(param.get("ContractRevocationAction")); + String workflowField = Util.null2String(param.get("workflowField")); + List> createList = queryMapper.queryActionParam(contractCreateAction); + List> signOtherList = queryMapper.queryActionParam(signOtherAction); + List> contractRevocationList = queryMapper.queryActionParam(contractRevocationAction); + Map contractActionParam = createList.stream().collect(Collectors + .toMap( + item -> Util.null2String(item.get("attrname")), + item -> Util.null2String(item.get("attrvalue")) + ) + ); + Map signOtherActionParam = signOtherList.stream().collect(Collectors + .toMap( + item -> Util.null2String(item.get("attrname")), + item -> Util.null2String(item.get("attrvalue")) + ) + ); + Map contractRevocationParam = contractRevocationList.stream().collect(Collectors + .toMap( + item -> Util.null2String(item.get("attrname")), + item -> Util.null2String(item.get("attrvalue")) + ) + ); + log.info(String.format("contractCreateAction ==> param:%s signOtherAction ==> param:%s contractRevocationAction ==> param:%s", + JSON.toJSONString(contractRevocationParam), + JSON.toJSONString(contractActionParam), + JSON.toJSONString(signOtherActionParam) + )); + List> contractList = queryMapper.queryContractByIds(ids); + List> result = new ArrayList<>(); + for (Map contract : contractList) { + String signStatus = Util.null2String(contract.get("zcgsqszt")); + if("1".equals(signStatus)){ + throw new CustomerException(SystemEnv.getHtmlLabelName(labelId, loginUser.getLanguage())); + } + } + for (Map contract : contractList) { + Map info = new HashMap<>(); + int requestId = Util.getIntValue(String.valueOf(contract.get(workflowField))); + try{ + //合同撤回 + Util.actionTest(CommonContractRevocationAction.class,requestId,contractRevocationParam); + //合同创建 + Util.actionTest(CommonCreateContractAction.class,requestId,contractActionParam); + //对方签署 + Util.actionTest(CommonOneselfSignAction.class,requestId,signOtherActionParam); + }catch (CustomerException exception){ + info.put(String.valueOf(requestId),false); + } + info.put(String.valueOf(requestId),true); + result.add(info); + } + return result; + } +} diff --git a/src/main/java/com/api/bokang/xiao/sh_bigdata/controller/ReportController.java b/src/main/java/com/api/bokang/xiao/sh_bigdata/controller/ReportController.java new file mode 100644 index 0000000..854970b --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/sh_bigdata/controller/ReportController.java @@ -0,0 +1,55 @@ +package com.api.bokang.xiao.sh_bigdata.controller; + +import aiyh.utils.ApiResult; +import aiyh.utils.Util; +import com.api.bokang.xiao.sh_bigdata.service.ReportService; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import org.apache.log4j.Logger; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.List; +import java.util.Map; + +/** + * @ClassName YearReviewController + * @Author 肖博亢 + * @Date 2023/2/14 17:00 + * @Description

保时捷年终总结相关接口

+ **/ +@Path("/xbk/sh_bigdata") +public class ReportController { + + private final Logger log = Util.getLogger(); + ReportService reportService = new ReportService(); + + /** + *

获取创建或处理流程的总数

+ * @param request 请求体 + * @param response 响应体 + * @param param 请求参数 + * @return 请求结果 + */ + @Path("/getReportData") + @POST + @Produces(MediaType.APPLICATION_JSON) + public String getReportData(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map param) { + try{ + log.info("into getReportData success params ==> "+param); + User loginUser = HrmUserVarify.getUser(request, response); + List> reportData = reportService.queryReportData(param, loginUser); + return ApiResult.success(reportData); + }catch (Exception e){ + log.error("getReportData error ==> "+Util.getErrString(e)); + return ApiResult.error(e.getMessage()); + } + } + +} diff --git a/src/main/java/com/api/bokang/xiao/sh_bigdata/mapper/ReportMapper.java b/src/main/java/com/api/bokang/xiao/sh_bigdata/mapper/ReportMapper.java new file mode 100644 index 0000000..716dd9b --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/sh_bigdata/mapper/ReportMapper.java @@ -0,0 +1,39 @@ +package com.api.bokang.xiao.sh_bigdata.mapper; + +import aiyh.utils.annotation.recordset.*; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName ReviewMapper + * @Author 肖博亢 + * @Date 2023/2/14 17:02 + * @Description

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

查询日程报表信息

+ * @param uid 用户id + * @param param 参数信息 + * @return 前五条流程数据 + */ + @Select("select id, ysdx, hdlb, ysrq, ysclhjsy, hbcc, xcap, gzryhcl, zs, ykdhhgbs, " + + " dyjbr, (select lastname from hrmresource where id = dyjbr) dyjbr_span," + + " djr, (select lastname from hrmresource where id = djr) djr_span," + + " ldrlddw, rwzt, bz, ysjsy, ysrs, cfsj1, ddsj1, sfz, ddz, gzcl, gbs, lddw, lxr, lxrdh " + + " from $t{param.table} $t{param.whereSql} order by ysrq ") + @CaseConversion(value = false) + List> queryReportData(@ParamMapper("param") Map param,@ParamMapper("uid") int uid); + + @Select("select id,dlsk,yslx,hbcc,sfsj,ddsj,sfd,ddd,wdwcl,dwcljsy,wdwclqt,xcap,lxr,lxrdh,bz,gzcl,gzry,zs,dyjbr,djr,ldr,lddw,rwzt,ykdh,gbs, " + + " (select LISTAGG(wb, ',') WITHIN GROUP (ORDER BY wb) from uf_zwfwdjjmb_dt1 where mainid = main.id) ysdx, " + + " dyjbr, (select lastname from åhrmresource where id = dyjbr) dyjbr_span," + + " djr, (select lastname from hrmresource where id = djr) djr_span " + + " from uf_zwfwdjjmb main $t{param.whereSql} order by dlsk ") + @CaseConversion(value = false) + List> queryReportData2(@ParamMapper("param") Map param,@ParamMapper("uid") int uid); + +} diff --git a/src/main/java/com/api/bokang/xiao/sh_bigdata/service/ReportService.java b/src/main/java/com/api/bokang/xiao/sh_bigdata/service/ReportService.java new file mode 100644 index 0000000..4b70644 --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/sh_bigdata/service/ReportService.java @@ -0,0 +1,47 @@ +package com.api.bokang.xiao.sh_bigdata.service; + +import aiyh.utils.Util; +import com.api.bokang.xiao.sh_bigdata.mapper.ReportMapper; +import weaver.general.TimeUtil; +import weaver.hrm.User; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName ReviewService + * @Author 肖博亢 + * @Date 2023/2/14 17:01 + * @Description

+ **/ +public class ReportService { + + private final ReportMapper reportMapper = Util.getMapper(ReportMapper.class); + + /** + *

获取创建流程数量top5

+ * @param param 请求参数 + * @param user 用户信息 + * @return 前五条流程数据 + */ + public List> queryReportData(Map param, User user){ + String currentDate = Util.null2String(param.get("currentDate")); + String registrationPeople = Util.null2String(param.get("registrationPeople")); + String registrationPeopleSpan = Util.null2String(param.get("registrationPeopleSpan")); + param.put("whereSql",""); + String whereSql = ""; + if(!"".equals(currentDate)){ + whereSql += " and dlsk = #{param.currentDate} "; + }else { + param.put("today", TimeUtil.getCurrentDateString()); + whereSql += " and dlsk >= #{param.today} "; + } + if(!"".equals(registrationPeople)){ + whereSql += " and djr = #{param.registrationPeople} "; + } + whereSql = whereSql.replaceFirst(" and "," where "); + param.put("whereSql",whereSql); + return reportMapper.queryReportData2(param,user.getUID()); + } + +} diff --git a/src/main/java/com/api/bokang/xiao/zhenn/controller/BankController.java b/src/main/java/com/api/bokang/xiao/zhenn/controller/BankController.java new file mode 100644 index 0000000..142abea --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/zhenn/controller/BankController.java @@ -0,0 +1,80 @@ +package com.api.bokang.xiao.zhenn.controller; + +import aiyh.utils.ApiResult; +import aiyh.utils.Util; +import com.api.bokang.xiao.wx_report.service.ReportService; +import com.api.bokang.xiao.wx_report.service.impl.ReportServiceImpl; +import com.api.bokang.xiao.zhenn.service.BankService; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import org.apache.log4j.Logger; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.List; +import java.util.Map; + +/** + * @ClassName ContractController + * @Author 肖博亢 + * @Date 2023/5/8 16:16 + * @Description

+ **/ +@Path("/xbk/zhenn") +public class BankController { + + private final Logger log = Util.getLogger(); + + private final BankService bankService = new BankService(); + + /** + *

获取搜索组件信息

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

获取搜索组件信息

+ * @param request 请求体 + * @param response 响应体 + * @return 请求结果 + */ + @Path("/getCommonSelect") + @POST + @Produces(MediaType.APPLICATION_JSON) + public String getCommonSelect(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map param) { + try{ + log.info("====== into getCommonSelect success ======="); + log.info("param:"+param); + User loginUser = HrmUserVarify.getUser(request, response); + List> bankSelectInfo = bankService.getBankSelectInfo(loginUser, param); + return ApiResult.success(bankSelectInfo); + }catch (Exception e){ + log.error("getCommonSelect error ==> "+Util.getErrString(e)); + return ApiResult.error(e.getMessage()); + } + } + +} diff --git a/src/main/java/com/api/bokang/xiao/zhenn/mapper/BankMapper.java b/src/main/java/com/api/bokang/xiao/zhenn/mapper/BankMapper.java new file mode 100644 index 0000000..ef56c57 --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/zhenn/mapper/BankMapper.java @@ -0,0 +1,109 @@ +package com.api.bokang.xiao.zhenn.mapper; + +import aiyh.utils.annotation.recordset.Select; +import aiyh.utils.annotation.recordset.SqlMapper; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName ContractMapper + * @Author 肖博亢 + * @Date 2023/5/8 16:16 + * @Description

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

查询流程付款信息

+ * @param param 查询参数 + * @return 付款信息列表 + */ + @Select("SELECT t.requestid requestId,t.$t{amountField} amount,t.$t{amountField} outAmount," + + " $t{inCompany} inCompany,wb.lastoperatedate outDate," + + " (select top 1 xmlsend from workflowToFinanceUrl where wb.requestid = t.requestId and xmlsend IS NOT NULL order by id desc) xmlsend " + + "FROM $t{tableName} t " + + "INNER JOIN workflow_requestbase wb ON t.requestid = wb.requestid " + + "WHERE wb.currentnodetype = 3 " + + " AND wb.lastoperatedate BETWEEN #{beginDate} AND #{endDate} " + + " AND $t{currencyField} = #{currency}") + List> queryOaOutList(Map param); + + /** + *

查询流程付款信息

+ * @param param 查询参数 + * @return 付款信息列表 + */ + @Select("SELECT t.requestid requestId,t.$t{amountField} amount,t.$t{amountField} outAmount," + + " $t{inCompany} inCompany,wb.lastoperatedate outDate," + + " (select top 1 xmlsend from workflowToFinanceUrl where wb.requestid = t.requestId and xmlsend IS NOT NULL order by id desc) xmlsend " + + "FROM $t{tableName} t " + + "INNER JOIN workflow_requestbase wb ON t.requestid = wb.requestid " + + "WHERE wb.currentnodetype = 3 " + + " AND wb.lastoperatedate BETWEEN #{beginDate} AND #{endDate} " + + " AND $t{currencyField} = #{currency}" + + " AND t.$t{bankAccountField} = #{currentBankAccount}") + List> queryOaOutBank(Map param); + + /** + *

查询流程收款信息

+ * @param param 查询参数 + * @return 收款信息列表 + */ + @Select("SELECT t.requestid,t.$t{amountField} amount,t.$t{amountField} inAmount," + + " $t{inCompany} outCompany,wb.lastoperatedate inDate,wfu.xmlsend,t.$t{payInfoField} payInfo " + + "FROM $t{tableName} t " + + "INNER JOIN workflow_requestbase wb ON t.requestid = wb.requestid " + + "WHERE wb.currentnodetype = 3 " + + " AND wb.lastoperatedate BETWEEN #{beginDate} AND #{endDate} " + + " AND $t{currencyField} = #{currency}" + + " AND t.$t{bankAccountField} = #{currentBank}") + List> queryOaInBank(Map param); + + /** + *

查询银行付款信息

+ * @param param 查询参数 + * @return 付款信息列表 + */ + @Select("select id,txnamt amount,txnamt difAmount,txnamt outAmount,insid," + + " insid outFlowNo,txndate_time,actacn,tobank inCompany from uf_bank_trade_info " + + "where txndate_time BETWEEN #{beginDate} AND #{endDate} " + + " and trncur = #{currencySpan}" + + " and actacn = #{currentBankAccount}") + List> queryBankOutInfo(Map param); + + /** + *

查询银行收款信息

+ * @param param 查询参数 + * @return 收款信息列表 + */ + @Select("select id,id payInfo,txnamt amount,txnamt difAmount,txnamt inAmount,insid," + + " insid inFlowNo,txndate_time,actacn,ibkname outCompany from uf_bank_trade_info " + + "where txndate_time BETWEEN #{beginDate} AND #{endDate} " + + " and trncur = #{currencySpan}" + + " and actacn_receipt = #{currentBankAccount}") + List> queryBankInInfo(Map param); + + /** + *

银行存款日记账余额

+ * @param param 查询参数 + * @return 余额 + */ + @Select("select sum(avabal) from uf_bank_day_balance " + + "where actacn = #{currentBankAccount} and curcde = #{currencySpan} and baldat BETWEEN #{beginDate} AND #{endDate} ") + double queryBankDayAmount(Map param); + + /** + *

银行对账单余额

+ * @param param 查询参数 + * @return 余额 + */ + @Select("select sum(EvBalance) from uf_period_balance " + + "where glAccount = #{bankSubject} " + + " and EvCurrency = #{currencySpan} " + + " and IvFiscYear = YEAR(#{beginDate}) " + + " and IvFisPeriod = MONTH(#{beginDate})") + double queryBankStatementBalance(Map param); + +} diff --git a/src/main/java/com/api/bokang/xiao/zhenn/service/BankService.java b/src/main/java/com/api/bokang/xiao/zhenn/service/BankService.java new file mode 100644 index 0000000..4af3a11 --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/zhenn/service/BankService.java @@ -0,0 +1,168 @@ +package com.api.bokang.xiao.zhenn.service; + +import aiyh.utils.Util; +import com.alibaba.fastjson.JSON; +import com.api.bokang.xiao.zhenn.mapper.BankMapper; +import org.apache.log4j.Logger; +import weaver.bokang.xiao.common.CommonUtil; +import weaver.bokang.xiao.common.mapper.WorkflowMapper; +import weaver.hrm.User; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @ClassName ContractService + * @Author 肖博亢 + * @Date 2023/5/8 16:16 + * @Description

+ **/ +public class BankService { + + private final BankMapper bankMapper = Util.getMapper(BankMapper.class); + + private final WorkflowMapper workflowMapper = Util.getMapper(WorkflowMapper.class); + + private final Logger log = Util.getLogger(); + + /** + *

获取银行数据信息

+ * + *

+ * param{ + * currentBank:"当前银行下拉框索引", + * currentBankAccount:"当前银行下拉框账号", + * currentBankSpan:"当前银行名称", + * outParam:[{ + * table:"流程表名", + * workflowId:"流程id", + * amountField:"金额字段名", + * bankAccountField:"银行账号字段", + * queryTye:"1、付款账号固定;2、付款账号不固定" + * }]:"付款参数条件", + * inParam:[{ + * table:"流程表名", + * workflowId:"流程id", + * amountField:"金额字段名", + * bankAccountField:"银行账号字段", + * }]:"收款参数条件" + * } + *

> getBankData(User loginUser, Map param) { + Map> bankData = new HashMap<>(); + Map bankBaseInfo = new HashMap<>(); + String currentBankSpan = Util.null2String(param.get("currentBankSpan")); + String bankAccount = Util.null2String(param.get("currentBankAccount")); + List> outParam = (List>) param.get("outParam"); + List> inParam = (List>) param.get("inParam"); + //查询数据 + List> oaOutList = outParam.stream() + .flatMap(item -> { + String queryTye = Util.null2String(item.get("queryTye")); + item.put("currentBankAccount",bankAccount); + item.put("beginDate",Util.null2String(param.get("beginDate"))); + item.put("endDate",Util.null2String(param.get("endDate"))); + item.put("currency",Util.null2String(param.get("currency"))); + item.put("currencySpan",Util.null2String(param.get("endDate"))); + item.put("bankSubject",Util.null2String(param.get("bankSubject"))); + item.put("currentBank",Util.null2String(param.get("currentBank"))); + List> tempOutList = "1".equals(queryTye) ? bankMapper.queryOaOutList(item) : bankMapper.queryOaOutBank(item); + for (Map tempOut : tempOutList) { + String xmlSend = Util.null2String(tempOut.get("xmlsend")); + String insId = CommonUtil.getNodeValue(xmlSend, "insid"); + tempOut.put("insId",insId); + } + return tempOutList.stream(); + }) + .collect(Collectors.toList()); + List> oaInList = inParam.stream() + .flatMap(item -> { + item.put("currentBankAccount",bankAccount); + item.put("beginDate",Util.null2String(param.get("beginDate"))); + item.put("endDate",Util.null2String(param.get("endDate"))); + item.put("currency",Util.null2String(param.get("currency"))); + item.put("currencySpan",Util.null2String(param.get("endDate"))); + item.put("bankSubject",Util.null2String(param.get("bankSubject"))); + item.put("currentBank",Util.null2String(param.get("currentBank"))); + return bankMapper.queryOaInBank(item).stream(); + }) + .collect(Collectors.toList()); + List> bankOutList = bankMapper.queryBankOutInfo(param); + List> bankInList = bankMapper.queryBankInInfo(param); + //计算有差异的集合 + List> oaOutTable = CommonUtil.difference(oaOutList, bankOutList, map -> map.get("insid")); + List> bankOutTable = CommonUtil.difference(bankOutList,oaOutList, map -> map.get("insid")); + List> bankInTable = CommonUtil.difference(bankInList,oaInList, map -> map.get("payInfo")); + List> oaInTable = new ArrayList<>(); + //银行信息 + bankBaseInfo.put("bankName",currentBankSpan); + bankBaseInfo.put("bankAccount",bankAccount); + //求总和 + Map amountMap = new HashMap<>(); + double bankDayAmount = this.queryBankDayAmount(param); + double bankStatementBalance = this.queryBankStatementBalance(param); + double bankInDifference = bankInTable.stream().mapToDouble(item -> Double.parseDouble(item.get("amount").toString())).sum(); + double oaInDifference = 0; + double bankOutDifference = bankOutTable.stream().mapToDouble(item -> Double.parseDouble(item.get("amount").toString())).sum(); + double oaOutDifference = oaOutTable.stream().mapToDouble(item -> Double.parseDouble(item.get("amount").toString())).sum(); + double bankDayAmountUpdate = bankDayAmount + bankInDifference - bankOutDifference; + double bankStatementBalanceUpdate = bankStatementBalance + oaInDifference - oaOutDifference; + //返回数据组装 + amountMap.put("bankInDifference",bankInDifference); + amountMap.put("oaInDifference",oaInDifference); + amountMap.put("bankOutDifference",bankOutDifference); + amountMap.put("oaOutDifference",oaOutDifference); + amountMap.put("bankDayAmount",bankDayAmount); + amountMap.put("bankStatementBalance",bankStatementBalance); + amountMap.put("bankDayAmountUpdate",bankDayAmountUpdate); + amountMap.put("bankStatementBalanceUpdate",bankStatementBalanceUpdate); + Map bankTableListData = new HashMap<>(); + bankTableListData.put("oaOutTable",oaOutTable); + bankTableListData.put("bankOutTable",bankOutTable); + bankTableListData.put("bankInTable",bankInTable); + bankTableListData.put("oaInTable",oaInTable); + bankData.put("bankBaseData",bankBaseInfo); + bankData.put("bankAmountData",amountMap); + bankData.put("bankTableListData",bankTableListData); + log.info("getBankData bankData 对账单报表信息==>"+ JSON.toJSONString(bankData)); + return bankData; + } + + /** + *

获取银行下拉框信息

+ * @param loginUser 登录用户 + * @param param 参数信息 + * @return 下拉框信息 + */ + public List> getBankSelectInfo(User loginUser, Map param){ + String fieldName = Util.null2String(param.get("fieldName")); + return workflowMapper.queryCommonSelect(fieldName); + } + + /** + *

银行存款日记账余额

+ * @param param 查询参数 + * @return 余额< + */ + private double queryBankDayAmount(Map param){ + return bankMapper.queryBankDayAmount(param); + } + + /** + *

银行对账单余额

+ * @param param 查询参数 + * @return 余额< + */ + private double queryBankStatementBalance(Map param){ + return bankMapper.queryBankStatementBalance(param); + } + +} diff --git a/src/main/java/com/api/bokang/xiao/zscq/mapper/ReserveSelectMapper.java b/src/main/java/com/api/bokang/xiao/zscq/mapper/ReserveSelectMapper.java index d6619f8..2769f5a 100644 --- a/src/main/java/com/api/bokang/xiao/zscq/mapper/ReserveSelectMapper.java +++ b/src/main/java/com/api/bokang/xiao/zscq/mapper/ReserveSelectMapper.java @@ -38,7 +38,7 @@ public interface ReserveSelectMapper { * @param param 参数信息 * @return 建模数据 */ - @Select("select id, $t{applicationNoField}, $t{workflowInfoField}, $t{checkResultField} from $t{modeTableName} where concat(',',concat($t{dateField},',')) like #{datePicker} and ($t{markField} <> 0 or $t{markField} is not null)") + @Select("select id, $t{applicationNoField}, $t{workflowInfoField}, $t{checkResultField} from $t{modeTableName} where concat(',',concat($t{dateField},',')) like #{datePicker} and ($t{markField} <> 0 or $t{markField} is null)") @CaseConversion(value = false) List> queryModeList(Map param); diff --git a/src/main/java/com/api/bokang/xiao/zscq/service/impl/ReserveServiceImpl.java b/src/main/java/com/api/bokang/xiao/zscq/service/impl/ReserveServiceImpl.java index 855b5b2..4813c23 100644 --- a/src/main/java/com/api/bokang/xiao/zscq/service/impl/ReserveServiceImpl.java +++ b/src/main/java/com/api/bokang/xiao/zscq/service/impl/ReserveServiceImpl.java @@ -142,6 +142,7 @@ public class ReserveServiceImpl implements ReserveService { String workflowInfoField = Util.null2String(param.get("workflowInfoField")); String formId = Util.null2String(param.get("formId")); List> modeList = reserveSelectMapper.queryModeList(param); + log.info("triggerModeList ==>"+JSON.toJSONString(modeList)); if(Objects.nonNull(modeList) && !modeList.isEmpty()){ for (Map modeMap : modeList) { Map dealResult = new HashMap<>(); diff --git a/src/main/java/com/api/nonstandardext/zenner/job/SyncAccountTradeInfoJob.java b/src/main/java/com/api/nonstandardext/zenner/job/SyncAccountTradeInfoJob.java index 3d7106d..01f4496 100644 --- a/src/main/java/com/api/nonstandardext/zenner/job/SyncAccountTradeInfoJob.java +++ b/src/main/java/com/api/nonstandardext/zenner/job/SyncAccountTradeInfoJob.java @@ -100,10 +100,11 @@ public class SyncAccountTradeInfoJob extends BaseCronJob { xmlParams.put("type", "2002"); xmlParams.put("ibknum", ibknum); xmlParams.put("actacn", actacn); - xmlParams.put("from", "20220919"); + //xmlParams.put("from", "20220919"); Calendar cal = Calendar.getInstance(); cal.set(Calendar.DAY_OF_MONTH, -1); - xmlParams.put("to", ZennerUtil.parseToDateString(cal.getTime(), ZennerUtil.formatYYYYMMDD_NoSplit)); + xmlParams.put("from", ZennerUtil.parseToDateString(cal.getTime(), ZennerUtil.formatYYYYMMDD_NoSplit)); + xmlParams.put("to", ZennerUtil.parseToDateString(new Date(), ZennerUtil.formatYYYYMMDD_NoSplit)); xmlParams.put("amountFrom", "1"); xmlParams.put("amountTo", "100000"); xmlParams.put("begnum", start + ""); diff --git a/src/main/java/com/api/xuanran/wang/sh_bigdata/sso/controller/OtherSystemToOAController.java b/src/main/java/com/api/xuanran/wang/sh_bigdata/sso/controller/OtherSystemToOAController.java index 076bda2..668d3c6 100644 --- a/src/main/java/com/api/xuanran/wang/sh_bigdata/sso/controller/OtherSystemToOAController.java +++ b/src/main/java/com/api/xuanran/wang/sh_bigdata/sso/controller/OtherSystemToOAController.java @@ -45,12 +45,12 @@ public class OtherSystemToOAController { // 获取重定向地址和secret Map redirectUrlAndCorpsecret = service.getRedirectUrlAndCorpsecret(appId); String redirectUrl = Util.null2DefaultStr(redirectUrlAndCorpsecret.get("REDIRECTURL"),""); - log.info("successSendRedirectUrl : " + redirectUrl); if(StringUtils.isBlank(redirectUrl)){ throw new CustomerException("redirectUrl is null! " + JSONObject.toJSONString(redirectUrlAndCorpsecret)); } int userId = service.getUserFromOtherSys(code, redirectUrlAndCorpsecret); - SessionUtil.createSession(userId + "", request, response); + SessionUtil.createSession(String.valueOf(userId), request, response); + log.info("successSendRedirectUrl : " + redirectUrl); response.sendRedirect(redirectUrl); }catch (Exception e){ log.error("sso error : " + e.getMessage()); diff --git a/src/main/java/com/api/xuanran/wang/sh_bigdata/sso/mapper/OtherSystemToOAMapper.java b/src/main/java/com/api/xuanran/wang/sh_bigdata/sso/mapper/OtherSystemToOAMapper.java index f3c4884..c38b1b6 100644 --- a/src/main/java/com/api/xuanran/wang/sh_bigdata/sso/mapper/OtherSystemToOAMapper.java +++ b/src/main/java/com/api/xuanran/wang/sh_bigdata/sso/mapper/OtherSystemToOAMapper.java @@ -1,8 +1,11 @@ package com.api.xuanran.wang.sh_bigdata.sso.mapper; +import aiyh.utils.Util; import aiyh.utils.annotation.recordset.ParamMapper; import aiyh.utils.annotation.recordset.Select; import aiyh.utils.annotation.recordset.SqlMapper; +import aiyh.utils.annotation.recordset.SqlString; +import weaver.xuanran.wang.sh_bigdata.common.util.ShBigDataUtil; import java.util.Map; @@ -21,8 +24,8 @@ public interface OtherSystemToOAMapper { * @param outKey 外键id * @return oa ID **/ - @Select("select id from hrmresource where outkey = #{outKey}") - int selectUserIdByOutKey(@ParamMapper("outKey") String outKey); + @Select(custom = true) + int selectUserIdByOutKey(@SqlString String sql, @ParamMapper("outKey") String outKey); /** *

根据appId 查跳转的地址

* @author xuanran.wang diff --git a/src/main/java/com/api/xuanran/wang/sh_bigdata/sso/service/OtherSystemToOAService.java b/src/main/java/com/api/xuanran/wang/sh_bigdata/sso/service/OtherSystemToOAService.java index 7f736c4..69e69ec 100644 --- a/src/main/java/com/api/xuanran/wang/sh_bigdata/sso/service/OtherSystemToOAService.java +++ b/src/main/java/com/api/xuanran/wang/sh_bigdata/sso/service/OtherSystemToOAService.java @@ -21,7 +21,7 @@ public interface OtherSystemToOAService { * @param cusSuccess 自定义接口成功/失败标识 * @return 接口响应字段 **/ - int getUserIdByCode(String url, Map params, Map headers, CusSuccess cusSuccess, Map redirectUrlSecret); + Object getUserIdByCode(String url, Map params, Map headers, CusSuccess cusSuccess, Map redirectUrlSecret); /** *

根据第三方系统人员code匹配oa人员id

* @author xuanran.wang diff --git a/src/main/java/com/api/xuanran/wang/sh_bigdata/sso/service/impl/OtherSystemToOAServiceImpl.java b/src/main/java/com/api/xuanran/wang/sh_bigdata/sso/service/impl/OtherSystemToOAServiceImpl.java index 3e1581a..c07bd3c 100644 --- a/src/main/java/com/api/xuanran/wang/sh_bigdata/sso/service/impl/OtherSystemToOAServiceImpl.java +++ b/src/main/java/com/api/xuanran/wang/sh_bigdata/sso/service/impl/OtherSystemToOAServiceImpl.java @@ -28,12 +28,13 @@ public class OtherSystemToOAServiceImpl implements OtherSystemToOAService { .successField("code") .successValue(0) .errorMsg("msg") - .dataKey("data.id") + .dataKey("data." + Util.null2DefaultStr(ShBigDataUtil.getPropertiesValByKey("ssoInterfaceCompareField"), "id")) .build(); private final OtherSystemToOAMapper otherSystemToOAMapper = Util.getMapper(OtherSystemToOAMapper.class); private final Logger log = Util.getLogger(); + @Override - public int getUserIdByCode(String url, Map params, Map headers, CusSuccess cusSuccess, Map redirectUrlSecret) { + public Object getUserIdByCode(String url, Map params, Map headers, CusSuccess cusSuccess, Map redirectUrlSecret) { String secret = Util.null2DefaultStr(redirectUrlSecret.get("SECRET"), ""); log.info("secret : " + secret); if(StringUtils.isBlank(secret)){ @@ -48,7 +49,7 @@ public class OtherSystemToOAServiceImpl implements OtherSystemToOAService { params.put("code", code); // 获取第三方系统id String getUserInfoByCodeUrl = ShBigDataUtil.getPropertiesValByKey("getUserInfoByCodeUrl"); - int codeId; + Object codeId; try { codeId = getUserIdByCode(getUserInfoByCodeUrl, params, new HashMap<>(), cusSuccess, redirectUrlSecret); }catch (Exception e){ @@ -61,10 +62,12 @@ public class OtherSystemToOAServiceImpl implements OtherSystemToOAService { throw new CustomerException(e.getMessage()); } } - if(codeId < 0){ + String oaOutKey = Util.null2DefaultStr(codeId, ""); + if(StringUtils.isBlank(oaOutKey)){ throw new CustomerException(Util.logStr("code : {}, not found in {} .", code, getUserInfoByCodeUrl)); } - int id = otherSystemToOAMapper.selectUserIdByOutKey(codeId + ""); + String sql = "select id from hrmresource where " + Util.null2DefaultStr(ShBigDataUtil.getPropertiesValByKey("ssoOaCompareField"),"outkey") + " = #{outKey}"; + int id = otherSystemToOAMapper.selectUserIdByOutKey(sql, oaOutKey); if(id < 0){ throw new CustomerException(Util.logStr("code : {} not found in OA!", id)); } diff --git a/src/main/java/weaver/bokang/xiao/common/CommonUtil.java b/src/main/java/weaver/bokang/xiao/common/CommonUtil.java new file mode 100644 index 0000000..1fa38bd --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/common/CommonUtil.java @@ -0,0 +1,233 @@ +package weaver.bokang.xiao.common; + +import org.jdom.Document; +import org.jdom.Element; +import org.jdom.input.SAXBuilder; + +import java.io.StringReader; +import java.lang.reflect.Field; +import java.util.*; +import java.util.function.BiPredicate; +import java.util.function.Function; + +/** + * @ClassName CommonUtil + * @Author 肖博亢 + * @Date 2023/5/11 20:10 + * @Description

+ **/ +public class CommonUtil { + + /** + *

获取更新语句

+ * @param tableName 表名 + * @param updateParam 更新参数 + * @param whereParam 条件参数 + * @return sql语句 + */ + public static String getCusUpdateSql(String tableName, Map updateParam, Map whereParam){ + return buildUpdateSql(tableName,updateParam) + buildWhereSql(whereParam); + } + + /** + *

构建更新sql语句

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

构建条件sql语句

+ * @param whereParam 条件参数 + * @return 条件语句 + */ + public static String buildWhereSql(Map whereParam){ + StringBuilder whereBuilder = new StringBuilder(); + Set> whereEntries = whereParam.entrySet(); + for (Map.Entry whereEntry : whereEntries) { + if("cusSql".equals(whereEntry.getKey())){ + whereBuilder.append(" and ").append(whereEntry.getValue()); + continue; + } + whereBuilder.append(" and ") + .append(whereEntry.getKey()) + .append(" = ") + .append("#{whereParam.").append(whereEntry.getKey()).append("},"); + } + String fixStr = whereBuilder.toString(); + if(!"".equals(fixStr)){ + fixStr = fixStr.replaceFirst(" and "," where "); + } + return fixStr.substring(0, fixStr.length() - 1) + " "; + } + + /** + * 获取 XML 字符串中指定节点的值 + * @param xml XML 字符串 + * @param nodeName 要获取值的节点名称 + * @return 节点的值,如果节点不存在则返回空字符串 + */ + public static String getNodeValue(String xml, String nodeName) { + try { + // 创建 SAXBuilder 对象 + SAXBuilder builder = new SAXBuilder(); + // 创建 StringReader 对象,并将 XML 字符串作为参数传入 + StringReader reader = new StringReader(xml); + // 使用 SAXBuilder 对象解析 XML,得到 Document 对象 + Document doc = builder.build(reader); + // 获取根节点 + Element root = doc.getRootElement(); + // 调用递归方法获取节点值 + String nodeValue = getNodeValue(root, nodeName); + // 如果节点值为空,则返回空字符串 + return nodeValue == null ? "" : nodeValue; + } catch (Exception e) { + // 如果解析 XML 异常,则返回空字符串 + return ""; + } + } + + /** + * 递归获取节点值 + * @param element 当前节点 + * @param nodeName 要获取值的节点名称 + * @return 节点的值,如果节点不存在则返回 null + */ + private static String getNodeValue(Element element, String nodeName) { + // 获取当前节点的子节点 + Element node = element.getChild(nodeName); + // 如果子节点中存在指定的节点,则返回节点的值 + if (node != null) { + return node.getValue(); + } else { + // 否则遍历子节点,递归调用 getNodeValue 方法,直到找到指定节点为止 + List children = element.getChildren(); + if (Objects.nonNull(children) && children.size() > 0) { + for (Element child : children) { + String value = getNodeValue(child, nodeName); + if (value != null) { + return value; + } + } + } + // 如果遍历完所有子节点都没有找到指定节点,则返回 null + return null; + } + } + + /** + * 求两个List的交集 + * + * @param list1 第一个List + * @param list2 第二个List + * @param fieldName 比较元素的属性名 + * @param 元素类型 + * @return 交集 + * @throws NoSuchFieldException 如果指定的属性不存在 + * @throws IllegalAccessException 如果访问指定的属性被拒绝 + */ + public static List intersection(List list1, List list2, String fieldName) throws NoSuchFieldException, IllegalAccessException { + return CommonUtil.intersection(list1, list2, (t1, t2) -> { + try { + Object fieldValue1 = getFieldValue(t1, fieldName); + Object fieldValue2 = getFieldValue(t2, fieldName); + return fieldValue1 != null && fieldValue1.equals(fieldValue2); + } catch (NoSuchFieldException | IllegalAccessException e) { + return false; + } + }); + } + + /** + * 求两个List的交集 + * + * @param list1 第一个List + * @param list2 第二个List + * @param matcher 元素比较器,返回true表示两个元素相等,false表示不相等 + * @param 元素类型 + * @return 交集 + */ + public static List intersection(List list1, List list2, BiPredicate matcher) { + Set set = new HashSet<>(list1); + List result = new ArrayList<>(); + for (T t2 : list2) { + if (set.contains(t2) && matcher.test(set.iterator().next(), t2)) { + result.add(t2); + } + } + return result; + } + + /** + * 求两个List的差集,即在第一个List中出现但没有在第二个List中出现的元素 + * + * @param list1 第一个List + * @param list2 第二个List + * @param matcher 元素比较器,返回true表示两个元素相等,false表示不相等 + * @param 元素类型 + * @return 差集 + */ + public static List difference(List list1, List list2, BiPredicate matcher) { + Set set2 = new HashSet<>(list2); + List result = new ArrayList<>(); + for (T t1 : list1) { + if (!set2.contains(t1) || !matcher.test(t1, set2.iterator().next())) { + result.add(t1); + } + } + return result; + } + + /** + * 求两个List的差集,即在第一个List中出现但没有在第二个List中出现的元素 + * + * @param list1 第一个List + * @param list2 第二个List + * @param keyFunc 提取元素的Key的函数 + * @param 元素类型 + * @param Key类型 + * @return 差集 + */ + public static List difference(List list1, List list2, Function keyFunc) { + BiPredicate matcher = (t1, t2) -> Objects.equals(keyFunc.apply(t1), keyFunc.apply(t2)); + return difference(list1, list2, matcher); + } + + private static Object getFieldValue(Object obj, String fieldName) throws NoSuchFieldException, IllegalAccessException { + if (obj instanceof Map) { + // 如果对象是Map类型,则直接返回指定键的值 + Map map = (Map) obj; + return map.get(fieldName); + } else { + // 如果对象是JavaBean类型,则通过反射获取指定属性的值 + Class clazz = obj.getClass(); + while (clazz != null) { + try { + Field field = clazz.getDeclaredField(fieldName); + field.setAccessible(true); + return field.get(obj); + } catch (NoSuchFieldException e) { + // 如果当前类没有指定的属性,则向上查找父类 + clazz = clazz.getSuperclass(); + } + } + // 如果所有父类都没有指定的属性,则抛出异常 + throw new NoSuchFieldException(fieldName); + } + } +} diff --git a/src/main/java/weaver/bokang/xiao/common/mapper/WorkflowMapper.java b/src/main/java/weaver/bokang/xiao/common/mapper/WorkflowMapper.java index f151550..8a16306 100644 --- a/src/main/java/weaver/bokang/xiao/common/mapper/WorkflowMapper.java +++ b/src/main/java/weaver/bokang/xiao/common/mapper/WorkflowMapper.java @@ -1,11 +1,10 @@ package weaver.bokang.xiao.common.mapper; -import aiyh.utils.annotation.recordset.ParamMapper; -import aiyh.utils.annotation.recordset.Select; -import aiyh.utils.annotation.recordset.SqlMapper; -import aiyh.utils.annotation.recordset.Update; +import aiyh.utils.annotation.recordset.*; +import java.util.List; import java.util.Map; +import java.util.Set; /** * @ClassName WorkflowMapper @@ -38,4 +37,21 @@ public interface WorkflowMapper { @ParamMapper("fieldName") String fieldName, @ParamMapper("fieldValue") String fieldValue, @ParamMapper("requestId") String requestId); + + @Select("select detail.id as `key`,detail.name as showname " + + "from mode_selectitempage page " + + "inner join mode_selectitempagedetail detail on page.id = detail.mainid " + + "where page.selectitemname = #{fieldName}") + List> queryCommonSelect(@ParamMapper("fieldName")String fieldName); + + /** + *

执行自定义更新sql

+ * @param cusSql 自定义sql + * @param updateParam 更新参数信息 + * @param whereParam 条件参数信息 + * @return 查询结果 + */ + @Update(custom = true) + boolean executeUpdateCusSql(@SqlString String cusSql, @ParamMapper("updateParam")Map updateParam, @ParamMapper("whereParam")Map whereParam); + } diff --git a/src/main/java/weaver/bokang/xiao/common/model_update/entity/AssignmentEntity.java b/src/main/java/weaver/bokang/xiao/common/model_update/entity/AssignmentEntity.java new file mode 100644 index 0000000..5100772 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/common/model_update/entity/AssignmentEntity.java @@ -0,0 +1,38 @@ +package weaver.bokang.xiao.common.model_update.entity; + +import aiyh.utils.annotation.recordset.SqlOracleDbFieldAnn; +import lombok.Data; + +/** + * @ClassName AssignmentEntity + * @Author 肖博亢 + * @Date 2023/4/4 15:42 + * @Description

+ **/ +@Data +public class AssignmentEntity { + + /** 赋值字段 */ + @SqlOracleDbFieldAnn("ASSIGNMENT_FIELD") + private String assignmentField; + + /** 值选择 */ + @SqlOracleDbFieldAnn("VALUE_SELECT") + private Integer valueSelect; + + /** 源字段 */ + @SqlOracleDbFieldAnn("SOURCE_FIELD") + private String sourceField; + + /** 赋值字段名 */ + @SqlOracleDbFieldAnn("ASSIGNMENT_FIELD_NAME") + private String assignmentFieldName; + + /** 源字段名 */ + @SqlOracleDbFieldAnn("SOURCE_FIELD_NAME") + private String sourceFieldName; + + /** 文本框 */ + @SqlOracleDbFieldAnn("CUS_CONTEXT") + private String cusContext; +} diff --git a/src/main/java/weaver/bokang/xiao/common/model_update/entity/ConditionEntity.java b/src/main/java/weaver/bokang/xiao/common/model_update/entity/ConditionEntity.java new file mode 100644 index 0000000..12643a8 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/common/model_update/entity/ConditionEntity.java @@ -0,0 +1,46 @@ +package weaver.bokang.xiao.common.model_update.entity; + +import aiyh.utils.annotation.recordset.SqlOracleDbFieldAnn; +import lombok.Data; + +/** + * @ClassName ConditionEntity + * @Author 肖博亢 + * @Date 2023/4/4 15:39 + * @Description

+ **/ +@Data +public class ConditionEntity { + + /** 条件类型 */ + @SqlOracleDbFieldAnn("CONDITION_TYPE") + private Integer conditionType; + + /** 条件 */ + @SqlOracleDbFieldAnn("CONDITION_VALUE") + private Integer conditionValue; + + /** 源字段 */ + @SqlOracleDbFieldAnn("CONDITION_SOURCE_FIELD") + private String conditionSourceField; + + /** 值类型 */ + @SqlOracleDbFieldAnn("VALUE_TYPE") + private Integer valueType; + + /** 目标字段 */ + @SqlOracleDbFieldAnn("CONDITION_TARGET_FIELD") + private String conditionTargetField; + + /** 源字段名 */ + @SqlOracleDbFieldAnn("CONDITION_SOURCE_FIELD_NAME") + private String conditionSourceFieldName; + + /** 目标字段名 */ + @SqlOracleDbFieldAnn("CONDITION_TARGET_FIELD_NAME") + private String conditionTargetFieldName; + + /** 文本框 */ + @SqlOracleDbFieldAnn("CUS_TEXT") + private String cusText; +} diff --git a/src/main/java/weaver/bokang/xiao/common/model_update/entity/UpdateModeConf.java b/src/main/java/weaver/bokang/xiao/common/model_update/entity/UpdateModeConf.java new file mode 100644 index 0000000..61ffeb5 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/common/model_update/entity/UpdateModeConf.java @@ -0,0 +1,59 @@ +package weaver.bokang.xiao.common.model_update.entity; + +import aiyh.utils.annotation.recordset.SqlOracleDbFieldAnn; +import lombok.Data; + +import java.util.List; + +/** + * @ClassName UpdateModeConf + * @Author 肖博亢 + * @Date 2023/4/4 15:32 + * @Description

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

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

条件处理

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

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

自定义接口操作

+ * + *

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

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

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

通过formId查询相关配置信息

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

通过formId查询相关配置信息

+ * @return 配置列表 + */ + @Select("select * from uf_update_mode_conf") + @CollectionMappings({ + @CollectionMapping(property = "conditionList", column = "id", id = @Id(value = Integer.class, methodId = 1)), + @CollectionMapping(property = "assignmentList", column = "id", id = @Id(value = Integer.class, methodId = 2)), + }) + List queryUpdateModeConf(); + + /** + *

查询条件列表

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

查询赋值列表

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

执行自定义查询sql

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

执行自定义查询sql

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

执行自定义查询sql

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

执行自定义更新sql

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

目标建模条件sql生成处理

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

目标建模等于处理方法

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

目标建模不等于处理方法

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

目标建模不等于处理方法

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

目标建模不等于处理方法

+ * @param whereParam 条件参数 + * @param param 参数信息 + * @param whereSql 条件sql + * @return 条件sql + */ + @MethodRuleNo(value = 7, desc = "not in") + public static String notIn(Map whereParam,Map param,String whereSql) { + String conditionValue = Util.null2String(param.get("conditionValue")); + String targetFieldName = Util.null2String(param.get("targetFieldName")); + String targetStr = " and "+targetFieldName+" not in ( $t{whereParam."+targetFieldName+"})"; + whereSql += targetStr; + whereParam.put(targetFieldName,conditionValue); + return whereSql; + } + + /** + *

目标建模不等于处理方法

+ * @param whereParam 条件参数 + * @param param 参数信息 + * @param whereSql 条件sql + * @return 条件sql + */ + @MethodRuleNo(value = 8, desc = "自定义sql") + public static String cusSql(Map whereParam,Map param,String whereSql) { + String conditionValue = Util.null2String(param.get("conditionValue")); + String targetStr = " and "+Util.sbc2dbcCase(conditionValue); + whereSql += targetStr; + return whereSql; + } + +} diff --git a/src/main/java/weaver/bokang/xiao/common/model_update/process/ConditionValueProcess.java b/src/main/java/weaver/bokang/xiao/common/model_update/process/ConditionValueProcess.java new file mode 100644 index 0000000..d428a60 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/common/model_update/process/ConditionValueProcess.java @@ -0,0 +1,98 @@ +package weaver.bokang.xiao.common.model_update.process; + +import aiyh.utils.Util; +import aiyh.utils.annotation.MethodRuleNo; +import org.apache.log4j.Logger; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; +import java.util.function.BiFunction; + +/** + * @ClassName ConditionValueProcess + * @Author 肖博亢 + * @Date 2023/4/4 16:19 + * @Description

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

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

源建模等于处理方法

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

源建模不等于处理方法

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

源建模不等于处理方法

+ * @param sourceValue 源建模值 + * @param value 目标值 + * @return 是否符合 + */ + @MethodRuleNo(value = 6, desc = "in") + public static boolean in(String sourceValue, String value) { + if("".equals(sourceValue) || "".equals(value)){ + return false; + } + String tempStr = ","+value+","; + sourceValue = "," + sourceValue + ","; + return tempStr.contains(sourceValue); + } + + /** + *

源建模不等于处理方法

+ * @param sourceValue 源建模值 + * @param value 目标值 + * @return 是否符合 + */ + @MethodRuleNo(value = 7, desc = "not in") + public static boolean notIn(String sourceValue, String value) { + return !in(sourceValue, value); + } + + +} diff --git a/src/main/java/weaver/bokang/xiao/common/model_update/process/ConditionWhereProcess.java b/src/main/java/weaver/bokang/xiao/common/model_update/process/ConditionWhereProcess.java new file mode 100644 index 0000000..b383404 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/common/model_update/process/ConditionWhereProcess.java @@ -0,0 +1,130 @@ +package weaver.bokang.xiao.common.model_update.process; + +import aiyh.utils.Util; +import aiyh.utils.annotation.MethodRuleNo; +import org.apache.log4j.Logger; +import weaver.bokang.xiao.common.model_update.function.ConditionFunction; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; + +/** + * @ClassName ConditionWhereProcess + * @Author 肖博亢 + * @Date 2023/5/15 14:40 + * @Description

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

目标建模等于处理方法

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

目标建模不等于处理方法

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

目标建模不等于处理方法

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

目标建模不等于处理方法

+ * @param whereParam 条件参数 + * @param param 参数信息 + * @param whereSql 条件sql + * @return 条件sql + */ + @MethodRuleNo(value = 7, desc = "not in") + public static String notIn(Map whereParam,Map param,String whereSql) { + String conditionValue = Util.null2String(param.get("conditionValue")); + String targetFieldName = Util.null2String(param.get("targetFieldName")); + String targetStr = " and "+targetFieldName+" not in ( $t{whereParam."+targetFieldName+"})"; + whereSql += targetStr; + whereParam.put(targetFieldName,conditionValue); + return whereSql; + } + + /** + *

目标建模不等于处理方法

+ * @param whereParam 条件参数 + * @param param 参数信息 + * @param whereSql 条件sql + * @return 条件sql + */ + @MethodRuleNo(value = 8, desc = "自定义sql") + public static String cusSql(Map whereParam,Map param,String whereSql) { + String conditionValue = Util.null2String(param.get("conditionValue")); + String targetStr = " and "+Util.sbc2dbcCase(conditionValue); + whereSql += targetStr; + return whereSql; + } + +} diff --git a/src/main/java/weaver/bokang/xiao/common/model_update/process/DataTypeProcess.java b/src/main/java/weaver/bokang/xiao/common/model_update/process/DataTypeProcess.java new file mode 100644 index 0000000..fe860a5 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/common/model_update/process/DataTypeProcess.java @@ -0,0 +1,253 @@ +package weaver.bokang.xiao.common.model_update.process; + +import aiyh.utils.Util; +import aiyh.utils.annotation.MethodRuleNo; +import aiyh.utils.excention.CustomerException; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import weaver.bokang.xiao.common.model_update.function.ConditionFunction; +import weaver.bokang.xiao.common.model_update.function.CusOperateInterface; +import weaver.bokang.xiao.common.model_update.mapper.UpdateModeMapper; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + + +/** + * @ClassName DataTypeProcess + * @Author 肖博亢 + * @Date 2023/4/6 13:10 + * @Description

建模数据更新处理

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

更新处理方法

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

插入处理方法

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

执行自定义处理方法

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

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

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

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

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

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

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

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

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

构建更新sql语句

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

构建条件sql语句

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

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

赋值 - 取值类型相关处理

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

默认值处理方法

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

建模字段处理方法

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

自定义sql处理方法

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

当前时间处理方法

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

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

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

默认值处理方法

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

建模字段处理方法

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

自定义sql处理方法

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

当前时间处理方法

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

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

更新其他建模信息

+ * @param modeMap 模块数据 + * @param formId 表单id + * @param triggerType 触发方式 0:无条件触发; 1:建模更新触发; 2:其他触发 + */ + public void changeOtherMode(Map modeMap, String formId,int triggerType){ + Map> triggerStore = TableNameStore.getInstance().getTriggerStore(); + List updateModeConfList = triggerStore.get(formId); + if(Objects.isNull(updateModeConfList) || updateModeConfList.isEmpty()){ + logger.error(String.format("此表单建模[%s] 未配置相关更新信息,请检查!!!",formId)); + return; + } + List collect = updateModeConfList.stream().filter(item -> item.getNoRule() == triggerType).collect(Collectors.toList()); + if(collect.isEmpty()){ + logger.error(String.format("此表单建模[%s] 未配置相关更新信息,请检查!!!",formId)); + return; + } + doChange(modeMap,collect); + } + + /** + *

更新其他建模信息

+ * @param formId 原建模表单ID + */ + public void changeOtherMode(String formId){ + Map> triggerStore = TableNameStore.getInstance().getTriggerStore(); + List updateModeConfList = triggerStore.get(formId); + if(Objects.isNull(updateModeConfList) || updateModeConfList.isEmpty()){ + logger.error(String.format("此建模[%s] 未配置相关更新信息,请检查!!!",formId)); + return; + } + doChange(updateModeConfList); + } + + /** + *

更新其他表数据的具体方法

+ * @param updateModeConfList 配置参数列表 + */ + private void doChange(List updateModeConfList){ + for (UpdateModeConf updateModeConf : updateModeConfList) { + List conditionList = updateModeConf.getConditionList(); + Integer noRule = updateModeConf.getNoRule(); + String sourceTableName = updateModeConf.getSourceTableName(); + if(noRule == 1 && conditionList.isEmpty()){ + logger.error(String.format("没有条件设置,不允许建模 %s 更新",updateModeConf.getTargetTableName())); + continue; + } + logger.info(String.format("处理配置 deal config [%s - %s]",updateModeConf.getUniqueCode(),updateModeConf.getDescription())); + if(Objects.nonNull(conditionList) && !conditionList.isEmpty()){ + //条件数据 + Map whereParam = new HashMap<>(8); + Map> collect = conditionList.stream().collect(Collectors.groupingBy(ConditionEntity::getConditionType)); + //获取源建模数据判断条件配置列表 + List sourceConditions = collect.get(0); + //获取目标建模条件生成配置列表 + List targetConditions = collect.get(1); + //生成查询sql + if(Objects.nonNull(sourceConditions) && !sourceConditions.isEmpty()) { + String whereSql = getWhereSql(new HashMap<>(), sourceConditions, whereParam); + String querySql = "select * from " + sourceTableName + whereSql; + List> modeDataList = updateModeMapper.executeCusSqlList(querySql, whereParam, new HashMap<>()); + if(Objects.nonNull(modeDataList) && !modeDataList.isEmpty()){ + for (Map modeMap : modeDataList) { + updateOtherModel(modeMap,updateModeConf,targetConditions); + } + } + } + } + } + } + + /** + *

更新其他表的数据

+ * @param modeMap 原建模数据 + * @param updateModeConf 配置信息 + * @param targetConditions 条件判断 + */ + private void updateOtherModel(Map modeMap,UpdateModeConf updateModeConf,List targetConditions){ + List assignmentList = updateModeConf.getAssignmentList(); + Integer dataInType = updateModeConf.getDataInType(); + //赋值数据 + Map assignmentMap = new HashMap<>(8); + //条件sql + String whereSql = ""; + //条件数据 + Map whereParam = new HashMap<>(8); + //根据赋值配置组装数据 + if(Objects.nonNull(assignmentList) && !assignmentList.isEmpty()){ + //根据配置信息生成条件sql + if(Objects.nonNull(targetConditions) && !targetConditions.isEmpty()) { + getWhereSql(modeMap,targetConditions,whereParam); + } + for (AssignmentEntity assignmentEntity : assignmentList) { + BiFunction, AssignmentEntity, String> valueFunction = ValueSelectProcess.SOURCE_MODE_METHOD_MAP.get(assignmentEntity.getValueSelect()); + String assignmentValue = valueFunction.apply(modeMap, assignmentEntity); + assignmentMap.put(assignmentEntity.getAssignmentFieldName(),assignmentValue); + } + //执行数据操作 + ConditionFunction, Map, Map> dataInFunction = DataTypeProcess.SOURCE_MODE_METHOD_MAP.get(dataInType); + Map tableMap = new HashMap<>(8); + tableMap.put("tableName",updateModeConf.getTargetTableName()); + tableMap.put("whereSql",whereSql); + tableMap.put("operatePath",updateModeConf.getOperatePath()); + boolean executeFlag = dataInFunction.apply(assignmentMap, whereParam, tableMap); + logger.info("更新结果 executeFlag ==>"+executeFlag); + } + } + + /** + *

获取配置条件sql

+ * @param modeMap 原建模数据 + * @param conditions 条件参数 + * @param whereParam 返回的参数新 + * @return whereSql + */ + private String getWhereSql(Map modeMap,List conditions,Map whereParam){ + //条件sql + String whereSql = ""; + for (ConditionEntity targetCondition : conditions) { + BiFunction, ConditionEntity, String> valueFunction = ValueTypeProcess.SOURCE_MODE_METHOD_MAP.get(targetCondition.getValueType()); + ConditionFunction, Map, String> conditionFunction = ConditionTargetProcess.TARGET_MODE_METHOD_MAP.get(targetCondition.getConditionValue()); + String sourceValue = Util.null2String(modeMap.get(targetCondition.getConditionSourceFieldName())); + String conditionValue = valueFunction.apply(modeMap, targetCondition); + Map param = new HashMap<>(8); + param.put("sourceValue", sourceValue); + param.put("conditionValue", conditionValue); + param.put("targetFieldName", targetCondition.getConditionTargetFieldName()); + whereSql = conditionFunction.apply(whereParam, param, whereSql); + } + return whereSql; + } + + /** + *

更新其他表数据的具体方法

+ * @param modeMap 源建模数据 + * @param updateModeConfList 配置参数列表 + */ + private void doChange(Map modeMap,List updateModeConfList){ + for (UpdateModeConf updateModeConf : updateModeConfList) { + List conditionList = updateModeConf.getConditionList(); + List assignmentList = updateModeConf.getAssignmentList(); + Integer dataInType = updateModeConf.getDataInType(); + Integer noRule = updateModeConf.getNoRule(); + if(noRule == 1 && conditionList.isEmpty()){ + logger.error(String.format("没有条件设置,不允许建模 %s 更新",updateModeConf.getTargetTableName())); + continue; + } + logger.info(String.format("处理配置 deal config [%s - %s]",updateModeConf.getUniqueCode(),updateModeConf.getDescription())); + //条件sql + String whereSql = ""; + //条件数据 + Map whereParam = new HashMap<>(8); + //赋值数据 + Map assignmentMap = new HashMap<>(8); + if(Objects.nonNull(conditionList) && !conditionList.isEmpty()){ + Map> collect = conditionList.stream().collect(Collectors.groupingBy(ConditionEntity::getConditionType)); + //获取源建模数据判断条件配置列表 + List sourceConditions = collect.get(0); + //获取目标建模条件生成配置列表 + List targetConditions = collect.get(1); + boolean flag = false; + //判断源建模数据是否需要触发更新 + if(Objects.nonNull(sourceConditions) && !sourceConditions.isEmpty()) { + for (ConditionEntity sourceCondition : sourceConditions) { + BiFunction, ConditionEntity, String> valueFunction = ValueTypeProcess.SOURCE_MODE_METHOD_MAP.get(sourceCondition.getValueType()); + BiFunction conditionFunction = ConditionValueProcess.SOURCE_MODE_METHOD_MAP.get(sourceCondition.getConditionValue()); + String sourceValue = Util.null2String(modeMap.get(sourceCondition.getConditionSourceFieldName())); + String conditionValue = valueFunction.apply(modeMap, sourceCondition); + Boolean result = conditionFunction.apply(sourceValue, conditionValue); + if (!result) { + flag = true; + break; + } + } + if (flag) { + logger.info("源建模条件判断不通过,此条数据跳过 sourceMode condition fail !!! "+JSON.toJSONString(modeMap)); + continue; + } + } + //根据配置信息生成条件sql + if(Objects.nonNull(targetConditions) && !targetConditions.isEmpty()) { + for (ConditionEntity targetCondition : targetConditions) { + BiFunction, ConditionEntity, String> valueFunction = ValueTypeProcess.SOURCE_MODE_METHOD_MAP.get(targetCondition.getValueType()); + ConditionFunction, Map, String> conditionFunction = ConditionTargetProcess.TARGET_MODE_METHOD_MAP.get(targetCondition.getConditionValue()); + String sourceValue = Util.null2String(modeMap.get(targetCondition.getConditionSourceFieldName())); + String conditionValue = valueFunction.apply(modeMap, targetCondition); + Map param = new HashMap<>(8); + param.put("sourceValue", sourceValue); + param.put("conditionValue", conditionValue); + param.put("targetFieldName", targetCondition.getConditionTargetFieldName()); + whereSql = conditionFunction.apply(whereParam, param, whereSql); + } + } + } + //根据赋值配置组装数据 + if(Objects.nonNull(assignmentList) && !assignmentList.isEmpty()){ + for (AssignmentEntity assignmentEntity : assignmentList) { + BiFunction, AssignmentEntity, String> valueFunction = ValueSelectProcess.SOURCE_MODE_METHOD_MAP.get(assignmentEntity.getValueSelect()); + String assignmentValue = valueFunction.apply(modeMap, assignmentEntity); + assignmentMap.put(assignmentEntity.getAssignmentFieldName(),assignmentValue); + } + } + //执行数据操作 + ConditionFunction, Map, Map> dataInFunction = DataTypeProcess.SOURCE_MODE_METHOD_MAP.get(dataInType); + Map tableMap = new HashMap<>(8); + tableMap.put("tableName",updateModeConf.getTargetTableName()); + tableMap.put("whereSql",whereSql); + tableMap.put("operatePath",updateModeConf.getOperatePath()); + boolean executeFlag = dataInFunction.apply(assignmentMap, whereParam, tableMap); + logger.info("更新结果 executeFlag ==>"+executeFlag); + } + } + + +} diff --git a/src/main/java/weaver/bokang/xiao/common/model_update/store/TableNameStore.java b/src/main/java/weaver/bokang/xiao/common/model_update/store/TableNameStore.java new file mode 100644 index 0000000..425724e --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/common/model_update/store/TableNameStore.java @@ -0,0 +1,68 @@ +package weaver.bokang.xiao.common.model_update.store; + +import aiyh.utils.Util; +import com.alibaba.fastjson.JSON; +import lombok.Getter; +import org.apache.log4j.Logger; +import weaver.bokang.xiao.common.model_update.entity.UpdateModeConf; +import weaver.bokang.xiao.common.model_update.mapper.UpdateModeMapper; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * @ClassName VendorStore + * @Author 肖博亢 + * @Date 2023/3/17 18:31 + * @Description

+ **/ + +@Getter +public class TableNameStore { + + private final Map tableNameStore = new HashMap<>(); + + private final Map> triggerStore = new HashMap<>(); + + private final Map> uniqueTriggerStore = new HashMap<>(); + + private final UpdateModeMapper updateModeMapper = Util.getMapper(UpdateModeMapper.class); + + private static final Logger logger = Util.getLogger(); + + private TableNameStore(){init();} + + private void init(){ + try { + triggerStore.clear(); + List updateModeConfList = updateModeMapper.queryUpdateModeConf(); + if (Objects.nonNull(updateModeConfList) && !updateModeConfList.isEmpty()) { + Map> collect = updateModeConfList.stream().collect(Collectors.groupingBy(UpdateModeConf::getSourceMode)); + Map> configMap = updateModeConfList.stream().collect(Collectors.groupingBy(UpdateModeConf::getUniqueCode)); + triggerStore.putAll(collect); + uniqueTriggerStore.putAll(configMap); + } + logger.info(String.format("TableNameStore init success!!! triggerStore:%s \n uniqueTriggerStore: %s", JSON.toJSONString(triggerStore), JSON.toJSONString(uniqueTriggerStore))); + }catch (Exception e){ + logger.error("TableNameStore init error !!!"+Util.getErrString(e)); + } + } + + public void refresh(){ + this.init(); + } + + public static TableNameStore getInstance(){ + return VendorStoreHolder.VENDOR_STORE; + } + + private static class VendorStoreHolder{ + private VendorStoreHolder(){ + + } + private static final TableNameStore VENDOR_STORE = new TableNameStore(); + } +} diff --git a/src/main/java/weaver/bokang/xiao/deg_repeat_check/action/RepeatCheckAction.java b/src/main/java/weaver/bokang/xiao/deg_repeat_check/action/RepeatCheckAction.java index d0de9a7..4dcd95e 100644 --- a/src/main/java/weaver/bokang/xiao/deg_repeat_check/action/RepeatCheckAction.java +++ b/src/main/java/weaver/bokang/xiao/deg_repeat_check/action/RepeatCheckAction.java @@ -42,8 +42,8 @@ public class RepeatCheckAction extends SafeCusBaseAction { private final RepeatCheckMapper repeatCheckMapper = Util.getMapper(RepeatCheckMapper.class); @Override - public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) { - log.info(String.format("=================== {%s} {requestId : %s} begin ======================", this.getClass().getName(),requestId)); + public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) + {log.info(String.format("=================== {%s} {requestId : %s} begin ======================", this.getClass().getName(),requestId)); Map mainTable = this.getMainTableValue(requestInfo); String workflowNum = Util.null2String(mainTable.get(workflowNumField)); int workflowCount = repeatCheckMapper.getWorkflowCount(billTable,workflowNumField,requestId, workflowNum); diff --git a/src/main/java/weaver/bokang/xiao/porsche/action/DateFieldUpdateAction.java b/src/main/java/weaver/bokang/xiao/porsche/action/DateFieldUpdateAction.java new file mode 100644 index 0000000..0106e72 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/porsche/action/DateFieldUpdateAction.java @@ -0,0 +1,84 @@ +package weaver.bokang.xiao.porsche.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.JSON; +import lombok.Setter; +import weaver.bokang.xiao.common.CommonUtil; +import weaver.bokang.xiao.common.mapper.WorkflowMapper; +import weaver.hrm.User; +import weaver.soa.workflow.request.RequestInfo; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * @ClassName DateFieldUpdateAction + * @Author 肖博亢 + * @Date 2023/5/11 14:46 + * @Description

+ **/ +@Setter +@ActionDesc(value = "时间自定义格式化",author = "bokang.xiao") +public class DateFieldUpdateAction extends SafeCusBaseAction { + + @RequiredMark("原时间字段集合") + @PrintParamMark + private String sourceDateFields; + + @RequiredMark("修改时间字段结合") + @PrintParamMark + private String targetDateFields; + + @ActionOptionalParam(value = "MMMM d','yyyy",desc = "时间格式化字符串") + @PrintParamMark + private String formationString = "MMMM d','yyyy"; + + private final WorkflowMapper workflowMapper = Util.getMapper(WorkflowMapper.class); + + @Override + public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) { + log.info(String.format("=================== {%s} {requestId : %s} begin ======================", this.getClass().getName(), requestId)); + Map workflowData = workflowMapper.queryWorkflowByRequestId(requestId, billTable); + String[] sourceDateFieldArray = sourceDateFields.split(","); + String[] targetDateFieldArray = targetDateFields.split(","); + if(sourceDateFieldArray.length != targetDateFieldArray.length){ + throw new CustomerException("请确保需要格式化的字段数量与存储字段数量一致"); + } + log.info("workflowData ==>"+ JSON.toJSONString(workflowData)); + Map dateFormat = new HashMap<>(); + for (int i = 0; i < sourceDateFieldArray.length; i++) { + String sourceDateField = sourceDateFieldArray[i]; + String targetDateField = targetDateFieldArray[i]; + String sourceDate = Util.null2String(workflowData.get(sourceDateField)); + String targetDate = formatDate(sourceDate); + log.info(String.format("sourceDateField:[%s],targetDateField:[%s],sourceDate:[%s],targetDate:[%s]",sourceDateField,targetDateField,sourceDate,targetDate)); + dateFormat.put(targetDateField,targetDate); + } + Map whereParam = new HashMap<>(); + whereParam.put("requestid",requestId); + String updateSql = CommonUtil.getCusUpdateSql(billTable, dateFormat, whereParam); + log.info("DateFieldUpdateAction updateSql ==>"+updateSql+" updateParam =>"+dateFormat+" whereParam =>"+whereParam); + boolean flag = workflowMapper.executeUpdateCusSql(updateSql, dateFormat, whereParam); + log.info("更新格式化日期结果 ==>"+flag); + } + + private String formatDate(String dateStr){ + try { + SimpleDateFormat sourceFormat = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat targetFormat = new SimpleDateFormat(formationString, Locale.US); + Date parse = sourceFormat.parse(dateStr); + return targetFormat.format(parse); + }catch (ParseException parseException){ + log.error("时间格式化异常 format error!!!"+Util.getErrString(parseException)); + return ""; + } + } + +} diff --git a/src/main/java/weaver/bokang/xiao/porsche/mapper/PorscheMapper.java b/src/main/java/weaver/bokang/xiao/porsche/mapper/PorscheMapper.java new file mode 100644 index 0000000..383bb37 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/porsche/mapper/PorscheMapper.java @@ -0,0 +1,24 @@ +package weaver.bokang.xiao.porsche.mapper; + +import aiyh.utils.annotation.recordset.*; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName PorscheMapper + * @Author 肖博亢 + * @Date 2023/5/9 17:56 + * @Description

+ **/ +@SqlMapper +public interface PorscheMapper { + + @Select("select * from uf_zcgsxx where $t{statusField} = 0") + List> queryCompanyInfo(@ParamMapper("statusField")String statusField); + + @Update("update uf_zcgsxx set sfrz = #{authenticationStatus},fadadaid = #{contractId} where id = #{dataId}") + boolean updateAuthenticationStatus(@ParamMapper("authenticationStatus")String authenticationStatus, + @ParamMapper("contractId")String contractId, + @ParamMapper("dataId")int dataId); +} diff --git a/src/main/java/weaver/bokang/xiao/porsche/schedule/CompanyWriteBackSchedule.java b/src/main/java/weaver/bokang/xiao/porsche/schedule/CompanyWriteBackSchedule.java new file mode 100644 index 0000000..0354dd1 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/porsche/schedule/CompanyWriteBackSchedule.java @@ -0,0 +1,69 @@ +package weaver.bokang.xiao.porsche.schedule; + +import aiyh.utils.Util; +import aiyh.utils.action.CusBaseCronJob; +import aiyh.utils.annotation.ActionDesc; +import aiyh.utils.annotation.PrintParamMark; +import aiyh.utils.annotation.RequiredMark; +import aiyh.utils.httpUtil.ResponeVo; +import lombok.Data; +import lombok.Setter; +import weaver.aiyh_pcn.common_fadada.util.FaRequestUtils; +import weaver.bokang.xiao.porsche.mapper.PorscheMapper; +import weaver.xiao.commons.config.entity.RequestMappingConfig; +import weaver.xiao.commons.config.service.DealWithMapping; + +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * @ClassName CompanyWriteBackSchedule + * @Author 肖博亢 + * @Date 2023/5/9 17:50 + * @Description

+ **/ +@Setter +@ActionDesc(value = "公司认证信息同步", author = "bokang.xiao") +public class CompanyWriteBackSchedule extends CusBaseCronJob { + + @RequiredMark("请求唯一标识") + @PrintParamMark + private String requestMark; + + @RequiredMark("状态字段名") + @PrintParamMark + private String statusField; + + private final DealWithMapping dealWithMapping = new DealWithMapping(); + + private final PorscheMapper porscheMapper = Util.getMapper(PorscheMapper.class); + + @Override + public void runCode() throws IOException { + log.info("======= CompanyWriteBackSchedule execute ======"); + List> maps = porscheMapper.queryCompanyInfo(statusField); + if(Objects.nonNull(maps) && !maps.isEmpty()){ + log.info("company list info ==>"+maps.size()); + for (Map map : maps) { + RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(requestMark); + Map requestParam = dealWithMapping.getRequestParam(map, requestMappingConfig); + ResponeVo responeVo = FaRequestUtils.companyAuthentication(requestParam, requestMappingConfig.getRequestUrl()); + if(responeVo.getCode() == 200){ + Map result = responeVo.getResponseMap(); + String code = Util.null2String(result.get("code")); + if("200".equals(code)){ + List> data = (List>) result.get("data"); + Map companyInfo = data.get(0); + Map certificationStatusResource = (Map) companyInfo.get("certificationStatusResource"); + int dataId = Util.getIntValue(String.valueOf(map.get("id"))); + String authenticationStatus = Util.null2String(certificationStatusResource.get("verifiedStatus")); + String companyNo = Util.null2String(companyInfo.get("companyNo")); + porscheMapper.updateAuthenticationStatus(authenticationStatus,companyNo,dataId); + } + } + } + } + } +} diff --git a/src/main/java/weaver/bokang/xiao/porsche/schedule/SalaryUpdateSchedule.java b/src/main/java/weaver/bokang/xiao/porsche/schedule/SalaryUpdateSchedule.java new file mode 100644 index 0000000..e089a7e --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/porsche/schedule/SalaryUpdateSchedule.java @@ -0,0 +1,32 @@ +package weaver.bokang.xiao.porsche.schedule; + +import aiyh.utils.action.CusBaseCronJob; +import aiyh.utils.annotation.ActionDesc; +import aiyh.utils.annotation.PrintParamMark; +import aiyh.utils.annotation.RequiredMark; +import lombok.Setter; +import weaver.bokang.xiao.common.model_update.service.ModeChangeService; + +import java.io.IOException; + +/** + * @ClassName SalaryUpdateSchedule + * @Author 肖博亢 + * @Date 2023/5/11 17:59 + * @Description

+ **/ +@Setter +@ActionDesc(value = "定时更新薪酬信息", author = "bokang.xiao") +public class SalaryUpdateSchedule extends CusBaseCronJob { + + @RequiredMark("原建模表单ID") + @PrintParamMark + private String formId; + + private final ModeChangeService modeChangeService = new ModeChangeService(); + + @Override + public void runCode() throws IOException { + modeChangeService.changeOtherMode(formId); + } +} diff --git a/src/main/java/weaver/bokang/xiao/sh_bigdata/action/DataPushAction.java b/src/main/java/weaver/bokang/xiao/sh_bigdata/action/DataPushAction.java new file mode 100644 index 0000000..6af0026 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/sh_bigdata/action/DataPushAction.java @@ -0,0 +1,62 @@ +package weaver.bokang.xiao.sh_bigdata.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 com.alibaba.fastjson.JSON; +import lombok.Setter; +import weaver.bokang.xiao.common.mapper.WorkflowMapper; +import weaver.hrm.User; +import weaver.soa.workflow.request.RequestInfo; +import weaver.xiao.commons.config.entity.RequestMappingConfig; +import weaver.xiao.commons.config.service.DealWithMapping; +import weaver.xuanran.wang.sh_bigdata.common.entity.CusSuccess; +import weaver.xuanran.wang.sh_bigdata.common.util.RequestMasterPlate; +import weaver.xuanran.wang.sh_bigdata.common.util.ShBigDataUtil; + +import java.util.HashMap; +import java.util.Map; + +/** + * @ClassName DataPushAction + * @Author 肖博亢 + * @Date 2023/5/12 10:30 + * @Description

+ **/ +@Setter +@ActionDesc(value = "数据采集对接-数据推送action",author = "bokang.xiao") +public class DataPushAction extends SafeCusBaseAction { + + /** 数据推送接口唯一标识 */ + @PrintParamMark + @RequiredMark(value = "",desc = "数据推送接口唯一标识") + private String requestUnique; + + private final WorkflowMapper workflowMapper = Util.getMapper(WorkflowMapper.class); + + private final DealWithMapping dealWithMapping = new DealWithMapping(); + + private final RequestMasterPlate requestMasterPlate = new RequestMasterPlate(); + + @Override + public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) { + log.info(String.format("=================== {%s} {requestId : %s} begin ======================", this.getClass().getName(),requestId)); + Map workflowMessage = workflowMapper.queryWorkflowByRequestId(requestId, billTable); + dealWithMapping.setMainTable(billTable); + RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(requestUnique); + Map requestParam = dealWithMapping.getRequestParam(workflowMessage, requestMappingConfig); + Map header = new HashMap<>(); + header.put("Content-Type","application/json"); + CusSuccess cusSuccess = CusSuccess.builder() + .successField("code") + .successValue(0) + .errorMsg("msg") + .dataKey("data.data") + .build(); + Map result = requestMasterPlate.apiPost(ShBigDataUtil.addToken2Url(requestMappingConfig.getRequestUrl()), requestParam, header, cusSuccess); + log.info("DataPushAction push data result ==>"+ JSON.toJSONString(result)); + } +} diff --git a/src/main/java/weaver/bokang/xiao/xhny_report/schedule/GenerateReportSchedule.java b/src/main/java/weaver/bokang/xiao/xhny_report/schedule/GenerateReportSchedule.java index ecec69c..8b2ede5 100644 --- a/src/main/java/weaver/bokang/xiao/xhny_report/schedule/GenerateReportSchedule.java +++ b/src/main/java/weaver/bokang/xiao/xhny_report/schedule/GenerateReportSchedule.java @@ -26,8 +26,7 @@ import java.util.stream.Collectors; * @Date 2023/3/17 19:58 * @Description

生成报表定时任务

**/ -@Data -@ActionDesc(value = "生成报表信息", author = "bokang.xiao") + public class GenerateReportSchedule extends CusBaseCronJob { diff --git a/src/main/java/weaver/bokang/xiao/zscq/action/OneNetComAction.java b/src/main/java/weaver/bokang/xiao/zscq/action/OneNetComAction.java index 09e9820..2d6003c 100644 --- a/src/main/java/weaver/bokang/xiao/zscq/action/OneNetComAction.java +++ b/src/main/java/weaver/bokang/xiao/zscq/action/OneNetComAction.java @@ -33,7 +33,7 @@ import java.util.List; import java.util.Map; /** - * @ClassName OneNetcomAction + * @ClassName OneNetComAction * @Author 肖博亢 * @Date 2023/3/27 14:04 * @Description

一网通接口调用action

@@ -71,6 +71,9 @@ public class OneNetComAction extends SafeCusBaseAction { @ActionOptionalParam(value = "",desc = "网关调用办理接口的apiId") private String handleApiName; + @ActionOptionalParam(value = "已办结办件不允许修改",desc = "错误信息不阻止流程") + private String continueError = "已办结办件不允许修改"; + private final WorkflowMapper workflowMapper = Util.getMapper(WorkflowMapper.class); private final DealWithMapping dealWithMapping = new DealWithMapping(); @@ -82,8 +85,10 @@ public class OneNetComAction extends SafeCusBaseAction { @Override public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) { log.info(String.format("=================== {%s} {requestId : %s} begin ======================", this.getClass().getName(),requestId)); - Map workflowMessage = workflowMapper.queryWorkflowByRequestId(requestId, billTable); + //Map workflowMessage = workflowMapper.queryWorkflowByRequestId(requestId, billTable); + Map workflowMessage = this.getObjMainTableValue(requestInfo); dealWithMapping.setMainTable(billTable); + log.info("workflowMessage ==>"+JSON.toJSONString(workflowMessage)); try{ if(StringUtils.isNotBlank(acceptUnique) && StringUtils.isNotBlank(acceptApiName)) { requestHandle(workflowMessage,acceptUnique,acceptApiName,requestId,billTable,"受理请求"); @@ -128,6 +133,10 @@ public class OneNetComAction extends SafeCusBaseAction { whereParam.put("requestid",requestId); sqlUtil.updateMode(billTable, updateMsg, whereParam); }else { + if(continueError.equals(message)){ + log.info("The error message for this request is related to whitelist content and will not block the submission of the action message:"+message ); + return; + } throw new CustomerException(desc+"请求失败 ==>"+message); } }else { diff --git a/src/main/java/weaver/bokang/xiao/zscq/config/mapper/UpdateModeMapper.java b/src/main/java/weaver/bokang/xiao/zscq/config/mapper/UpdateModeMapper.java index bb68a40..2620fdd 100644 --- a/src/main/java/weaver/bokang/xiao/zscq/config/mapper/UpdateModeMapper.java +++ b/src/main/java/weaver/bokang/xiao/zscq/config/mapper/UpdateModeMapper.java @@ -76,7 +76,9 @@ public interface UpdateModeMapper { * @return 查询结果 */ @Select(custom = true) - Map executeCusSqlMap(@SqlString String cusSql, @ParamMapper("whereParam")Map whereParam,@ParamMapper("cusParam")Map cusParam); + Map executeCusSqlMap(@SqlString String cusSql, + @ParamMapper("whereParam")Map whereParam, + @ParamMapper("cusParam")Map cusParam); /** *

执行自定义更新sql

@@ -86,6 +88,8 @@ public interface UpdateModeMapper { * @return 查询结果 */ @Update(custom = true) - boolean executeUpdateCusSql(@SqlString String cusSql, @ParamMapper("updateParam")Map updateParam,@ParamMapper("whereParam")Map whereParam); + boolean executeUpdateCusSql(@SqlString String cusSql, + @ParamMapper("updateParam")Map updateParam, + @ParamMapper("whereParam")Map whereParam); } diff --git a/src/main/java/weaver/bokang/xiao/zscq/config/process/DataTypeProcess.java b/src/main/java/weaver/bokang/xiao/zscq/config/process/DataTypeProcess.java index cac75ee..658fbde 100644 --- a/src/main/java/weaver/bokang/xiao/zscq/config/process/DataTypeProcess.java +++ b/src/main/java/weaver/bokang/xiao/zscq/config/process/DataTypeProcess.java @@ -125,7 +125,7 @@ public class DataTypeProcess { * @param param 表参数 * @return 执行结果 */ - @MethodRuleNo(value = 3,desc = "插入并执行自定义操作") + @MethodRuleNo(value = 3,desc = "更新并执行自定义操作") public static boolean cusAndUpdate(Map updateParam, Map whereParam,Map param) { return update(updateParam,whereParam,param) && cusOperate(updateParam,whereParam,param); } diff --git a/src/main/java/weaver/bokang/xiao/zscq/fun/ODocUpdate.java b/src/main/java/weaver/bokang/xiao/zscq/fun/ODocUpdate.java new file mode 100644 index 0000000..8ccd4e4 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/zscq/fun/ODocUpdate.java @@ -0,0 +1,42 @@ +package weaver.bokang.xiao.zscq.fun; + +import aiyh.utils.Util; +import weaver.bokang.xiao.zscq.config.function.CusOperateInterface; +import weaver.bokang.xiao.zscq.config.mapper.UpdateModeMapper; +import weaver.bokang.xiao.zscq.mapper.StatusMapper; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * @ClassName OdocUpdate + * @Author 肖博亢 + * @Date 2023/5/9 15:24 + * @Description

+ **/ +public class ODocUpdate implements CusOperateInterface { + + private final UpdateModeMapper updateModeMapper = Util.getMapper(UpdateModeMapper.class); + + private final StatusMapper statusMapper = Util.getMapper(StatusMapper.class); + + @Override + public void execute(Map whereParam, Map param, Map pathParam) { + logger.info("==== ODocUpdate 自定义处理 ==== "); + String tableName = Util.null2String(param.get("tableName")); + String numField = Util.null2String(pathParam.get("numField")); + String querySql = "select * from " + tableName +" where "+ numField +"= #{whereParam."+numField+"}"; + Map modeData = updateModeMapper.executeCusSqlMap(querySql, whereParam,new HashMap<>()); + logger.info("modeData ==>"+modeData); + if(Objects.nonNull(modeData)){ + String oDocRequestField = Util.null2String(pathParam.get("oDocRequestField")); + String oDocTextField = Util.null2String(pathParam.get("oDocTextField")); + String workflowTextField = Util.null2String(pathParam.get("workflowTextField")); + String requestId = Util.null2String(modeData.get("requestid")); + String workflowText = Util.null2String(modeData.get(workflowTextField)); + boolean flag = statusMapper.updateODocField(oDocTextField, workflowText, oDocRequestField, requestId); + logger.info("更新odoc表数据结果 ==>"+flag); + } + } +} diff --git a/src/main/java/weaver/bokang/xiao/zscq/fun/WorkflowOverOperate.java b/src/main/java/weaver/bokang/xiao/zscq/fun/WorkflowOverOperate.java index a99f5d2..25542e6 100644 --- a/src/main/java/weaver/bokang/xiao/zscq/fun/WorkflowOverOperate.java +++ b/src/main/java/weaver/bokang/xiao/zscq/fun/WorkflowOverOperate.java @@ -26,7 +26,7 @@ public class WorkflowOverOperate implements CusOperateInterface { @Override public void execute(Map whereParam, Map param, Map pathParam) { - logger.info(String.format("WorkflowOverOperate 自定义处理 whereParam[%s],param:[%s],pathParam:[%s]",whereParam,param,pathParam)); + logger.info("===== WorkflowOverOperate 自定义处理 ===== "); String tableName = Util.null2String(param.get("tableName")); String whereSql = Util.null2String(param.get("whereSql")); if(!"".equals(whereSql)){ diff --git a/src/main/java/weaver/bokang/xiao/zscq/fun/WorkflowRepossessedSign.java b/src/main/java/weaver/bokang/xiao/zscq/fun/WorkflowRepossessedSign.java index dcec3ad..69c7bfb 100644 --- a/src/main/java/weaver/bokang/xiao/zscq/fun/WorkflowRepossessedSign.java +++ b/src/main/java/weaver/bokang/xiao/zscq/fun/WorkflowRepossessedSign.java @@ -29,7 +29,7 @@ public class WorkflowRepossessedSign implements CusOperateInterface { @Override public void execute(Map whereParam, Map param, Map pathParam) { - logger.info(String.format("WorkflowRepossessedSign 自定义处理 whereParam[%s],param:[%s],pathParam:[%s]",whereParam,param,pathParam)); + logger.info("==== WorkflowRepossessedSign 自定义处理 ===="); String tableName = Util.null2String(param.get("tableName")); String whereSql = Util.null2String(param.get("whereSql")); if(!"".equals(whereSql)){ diff --git a/src/main/java/weaver/bokang/xiao/zscq/mapper/StatusMapper.java b/src/main/java/weaver/bokang/xiao/zscq/mapper/StatusMapper.java index f424845..8ec189f 100644 --- a/src/main/java/weaver/bokang/xiao/zscq/mapper/StatusMapper.java +++ b/src/main/java/weaver/bokang/xiao/zscq/mapper/StatusMapper.java @@ -32,4 +32,10 @@ public interface StatusMapper { @Select("select currentnodetype from workflow_requestbase where requestid = #{requestId}") int queryWorkflowStatus(@ParamMapper("requestId")String requestId); + @Update("update odoc_requestdoc set $t{fieldName} = #{fieldValue} where $t{oDocRequestField} = #{requestId}") + boolean updateODocField(@ParamMapper("fieldName")String fieldName, + @ParamMapper("fieldValue")String fieldValue, + @ParamMapper("oDocRequestField")String oDocRequestField, + @ParamMapper("requestId")String requestId); + } diff --git a/src/main/java/weaver/xiao/commons/config/service/DealWithMapping.java b/src/main/java/weaver/xiao/commons/config/service/DealWithMapping.java index df1d46e..94b1c6a 100644 --- a/src/main/java/weaver/xiao/commons/config/service/DealWithMapping.java +++ b/src/main/java/weaver/xiao/commons/config/service/DealWithMapping.java @@ -680,6 +680,12 @@ public class DealWithMapping extends ToolUtil { } } } + // 自定义sql用{mainTable}代替当前表名 解决极兔ncc问题 + if(StringUtils.isNotBlank(mainTable)){ + valueContext = valueContext.replace("{mainTable}", mainTable); + }else { + logger.error("mainTable is null!"); + } String requestId = Util.null2String(mainMap.get("requestid")); tempValue = "'" + tempValue + "'"; value = this.getValueByChangeRule(valueContext, tempValue, requestId, detailId); @@ -1028,6 +1034,12 @@ public class DealWithMapping extends ToolUtil { tempValue = Util.null2String(tempRs.getString(fieldName)); } } + // 自定义sql用{mainTable}代替当前表名 解决极兔ncc问题 + if(StringUtils.isNotBlank(mainTable)){ + valueContext = valueContext.replace("{mainTable}", mainTable); + }else { + logger.error("mainTable is null!"); + } tempValue = "'" + tempValue + "'"; value = this.getValueByChangeRule(valueContext, tempValue, requestId, detailId); } diff --git a/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/action/WorkflowToSap.java b/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/action/WorkflowToSap.java index 46cc313..63443f3 100644 --- a/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/action/WorkflowToSap.java +++ b/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/action/WorkflowToSap.java @@ -1,17 +1,14 @@ package weaver.xuanran.wang.eighty_five_degreec.sap.action; -import aiyh.utils.ThreadPoolConfig; import aiyh.utils.action.SafeCusBaseAction; -import aiyh.utils.annotation.ActionDesc; -import aiyh.utils.annotation.PrintParamMark; -import aiyh.utils.annotation.RequiredMark; +import aiyh.utils.annotation.*; +import aiyh.utils.excention.CustomerException; import weaver.hrm.User; import weaver.soa.workflow.request.RequestInfo; import weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity.MainRequestConfig; import weaver.xuanran.wang.eighty_five_degreec.sap.service.WorkflowToSapService; import weaver.xuanran.wang.eighty_five_degreec.sap.service.impl.WorkflowToSapServiceImpl; -import java.util.concurrent.ExecutorService; /** *

将流程数据推送到sap中

@@ -23,31 +20,53 @@ import java.util.concurrent.ExecutorService; public class WorkflowToSap extends SafeCusBaseAction { private final WorkflowToSapService service = new WorkflowToSapServiceImpl(); - private final ExecutorService pool = ThreadPoolConfig.createThreadPoolInstance(); @PrintParamMark @RequiredMark("配置表唯一标识") + @ActionDefaultTestValue(value = "****") private String uniqueCode; @PrintParamMark @RequiredMark("日志表模块id") + @ActionDefaultTestValue(value = "11") private String modelId; + @PrintParamMark + @RequiredMark("成功失败/标识字段") + @ActionDefaultTestValue(value = "soap-env:Envelope.soap-env:Body.n0:ZFI_OA_DOC_POSTINGResponse.ES_OA_OUTPUT.TYPE") + private String successField; + @PrintParamMark + @RequiredMark("成功时候的值") + @ActionDefaultTestValue(value = "T") + private String successVal; + @PrintParamMark + @RequiredMark("消息提示字段") + @ActionDefaultTestValue(value = "soap-env:Envelope.soap-env:Body.n0:ZFI_OA_DOC_POSTINGResponse.ES_OA_OUTPUT.MESSAGE") + private String messageField; @Override public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) { + String xml = ""; + String response = ""; + String url = ""; + String error = ""; + boolean success = true; try { MainRequestConfig config = service.getRequestConfig(uniqueCode, billTable); - String xml = service.convertXml(config, requestId, billTable); - String response = service.sendToSap(); - pool.execute(()->{ - try { - service.logToOA(modelId, config.getRequestUrl(), requestId, xml, response); - }catch (Exception e){ - log.error("日志数据写入建模失败! " + e.getMessage()); - } - }); + url = config.getRequestUrl(); + xml = service.convertXml(config, requestId, billTable); + response = service.sendToSap(config.getRequestUrl(), xml); + service.parseResponse(response, successField, successVal, messageField); }catch (Exception e){ log.error("流程数据推送SAP error : " + e.getMessage()); + error = e.getMessage(); + success = false; + } + try { + service.logToOA(modelId, url, requestId, xml, response, error); + }catch (Exception e){ + log.error("日志数据写入建模失败! " + e.getMessage()); + } + if(!success){ + throw new CustomerException("WorkflowToSap Action execute error : " + error); } - } } diff --git a/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/entity/eneity/DetailRequestConfig.java b/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/entity/eneity/DetailRequestConfig.java index 5509ef1..ea5798f 100644 --- a/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/entity/eneity/DetailRequestConfig.java +++ b/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/entity/eneity/DetailRequestConfig.java @@ -11,6 +11,9 @@ import lombok.Data; */ @Data public class DetailRequestConfig { + @SqlDbFieldAnn("nodeType") + @SqlOracleDbFieldAnn("NODETYPE") + private String nodeType; @SqlDbFieldAnn("paramName") @SqlOracleDbFieldAnn("PARAMNAME") private String paramName; diff --git a/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/service/WorkflowToSapService.java b/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/service/WorkflowToSapService.java index 0498b63..7e1a14b 100644 --- a/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/service/WorkflowToSapService.java +++ b/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/service/WorkflowToSapService.java @@ -11,6 +11,7 @@ import weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity.MainRequestConf public interface WorkflowToSapService { MainRequestConfig getRequestConfig(String uniqueCode, String tableName); String convertXml(MainRequestConfig config, String requestId, String tableName); - String sendToSap(); - void logToOA(String modelId, String url, String requestId, String requestXml, String response); + String sendToSap(String url, String xml); + String parseResponse(String response, String responseField, String successField, String messageField); + void logToOA(String modelId, String url, String requestId, String requestXml, String response, String error); } diff --git a/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/service/impl/WorkflowToSapServiceImpl.java b/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/service/impl/WorkflowToSapServiceImpl.java index b0aa755..607f0dc 100644 --- a/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/service/impl/WorkflowToSapServiceImpl.java +++ b/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/service/impl/WorkflowToSapServiceImpl.java @@ -1,6 +1,11 @@ package weaver.xuanran.wang.eighty_five_degreec.sap.service.impl; import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; +import org.apache.log4j.Logger; +import org.json.JSONObject; +import org.json.XML; +import weaver.xuanran.wang.common.util.CusData2OA; import weaver.xuanran.wang.common.util.CusInfoToOAUtil; import weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity.MainRequestConfig; import weaver.xuanran.wang.eighty_five_degreec.sap.service.WorkflowToSapService; @@ -8,6 +13,7 @@ import weaver.xuanran.wang.eighty_five_degreec.sap.util.ReadConfigUtil; import java.util.Collections; import java.util.HashMap; +import java.util.Map; /** @@ -18,7 +24,7 @@ import java.util.HashMap; */ public class WorkflowToSapServiceImpl implements WorkflowToSapService { private final ReadConfigUtil configUtil = new ReadConfigUtil(); - + private final Logger log = Util.getLogger(); @Override public MainRequestConfig getRequestConfig(String uniqueCode, String tableName) { return configUtil.getConfigByUniqueCode(uniqueCode, tableName); @@ -30,20 +36,40 @@ public class WorkflowToSapServiceImpl implements WorkflowToSapService { } @Override - public String sendToSap() { - // TODO sap接口调用方式暂时搞不了 - return ""; + public String sendToSap(String url, String xml) { + return configUtil.callSap(url, xml); + } + + @Override + public String parseResponse(String response, String successField, String successVal, String messageField) { + String responseVal; + JSONObject xmlResponseObj; + try { + xmlResponseObj = XML.toJSONObject(response); + }catch (Exception e){ + throw new CustomerException("xml to jsonObj error : " + e.getMessage()); + } + Map responseMap = com.alibaba.fastjson.JSONObject.parseObject(xmlResponseObj.toString(), Map.class); + responseVal = configUtil.parseMap(responseMap, successField); + if(!successVal.equals(responseVal)){ + throw new CustomerException("successVal not equals responseVal! current responseVal is : " + + responseVal + ", the successVal is " + successVal + ", responseMsg is " + configUtil.parseMap(responseMap, messageField)); + } + return responseVal; } @Override public void logToOA(String modelId, String url, String requestId, - String requestXml, String response) { + String requestXml, String response, String error) { HashMap params = new HashMap<>(); - params.put("requestUrlAndFunName", url); + params.put("requestUrl", url); params.put("reqId", requestId); params.put("requestXml", requestXml); params.put("responseCode",""); - params.put("erpResponse", response); - CusInfoToOAUtil.getDataId(Util.getIntValue(modelId, -1), params, "select id from #{tableName} where reqId = ?", Collections.singletonList(requestId)); + params.put("sapResponse", response); + params.put("error", error); + log.info("写入日志参数 : " + com.alibaba.fastjson.JSONObject.toJSONString(params)); + CusData2OA.writeToModel(modelId, "select id from #{tableName} where reqId = " + requestId, params); } + } diff --git a/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/util/ReadConfigUtil.java b/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/util/ReadConfigUtil.java index d805dd1..bfe44cc 100644 --- a/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/util/ReadConfigUtil.java +++ b/src/main/java/weaver/xuanran/wang/eighty_five_degreec/sap/util/ReadConfigUtil.java @@ -1,5 +1,6 @@ package weaver.xuanran.wang.eighty_five_degreec.sap.util; +import aiyh.utils.excention.CustomerException; import com.google.common.base.Strings; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -12,11 +13,10 @@ import weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity.DetailRequestCo import weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity.MainRequestConfig; import weaver.zwl.common.ToolUtil; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStreamReader; +import java.io.*; import java.lang.reflect.Field; +import java.net.HttpURLConnection; +import java.net.URL; import java.nio.charset.StandardCharsets; import java.security.SecureRandom; import java.text.ParseException; @@ -55,7 +55,7 @@ public class ReadConfigUtil extends ToolUtil { } int mainId = Util.getIntValue(res.getId()); // 配置明细表 - sql = "select paramName,paramType,parentName,getValueType,workflowField,valueContext,fv.tableName," + + sql = "select nodeType,paramName,paramType,parentName,getValueType,workflowField,valueContext,fv.tableName," + " fv.id fieldId,fv.fieldname,fv.indexdesc " + " from uf_memsic_createXml_dt1 config " + " left join workflow_field_table_view fv on config.workflowField = fv.id " + @@ -88,7 +88,7 @@ public class ReadConfigUtil extends ToolUtil { * @return 返回类对象 **/ public static T getInstance(RecordSet queryRs, Class clazz) { - T res = null; + T res; try { res = clazz.newInstance(); Field[] fields = clazz.getDeclaredFields(); @@ -443,15 +443,35 @@ public class ReadConfigUtil extends ToolUtil { // 明细 String[] detailIdArr = detailIndex.split(","); StringBuilder detailSb = new StringBuilder(); + for (String detailId : detailIdArr) { + String nodeName; + List nodeList = requestConfigList.stream() + .filter(item -> "0".equals(item.getNodeType())).collect(Collectors.toList()); + if(CollectionUtils.isNotEmpty(nodeList)){ + nodeName = nodeList.get(0).getParamName(); + } else { + nodeName = ""; + } List detailCollect = requestConfigList.stream() - .filter(item -> "detailRecord".equals(item.getParentName()) - ).collect(Collectors.toList()); + .filter(item -> { + if(StringUtils.isNotBlank(nodeName)){ + return nodeName.equals(item.getParentName()); + }else { + return "detailRecord".equals(item.getParentName()); + } + }).collect(Collectors.toList()); String detailSql = "select * from " + tableName + "_dt" + detailId + " where mainid = ?"; if (detailRs.executeQuery(detailSql, mainId)) { int count = 1; while (detailRs.next()) { + if(StringUtils.isNotBlank(nodeName)){ + detailSb.append("<").append(nodeName).append(">\n"); + } appendXml(detailSb, detailCollect, mainRs, detailRs, count++); + if(StringUtils.isNotBlank(nodeName)){ + detailSb.append("\n"); + } } } } @@ -474,7 +494,7 @@ public class ReadConfigUtil extends ToolUtil { .append(paramName) .append(">") .append(getParamValue(requestConfig, mainRs, detailRs,count)) - .append("<") + .append("") .append("\n"); @@ -544,22 +564,80 @@ public class ReadConfigUtil extends ToolUtil { * @return 响应数据 */ public String parseMap(Map responseMap, String responseField){ - String[] strArr = responseField.split("\\."); - int i = 0; - while (i < strArr.length - 1){ - Object o = responseMap.get(strArr[i]); - if(o instanceof Map){ - responseMap = (Map) o; - }else if(o instanceof List){ - List> list = (List>) o; - if(CollectionUtils.isEmpty(list)){ - return ""; - } - responseMap = list.get(0); - } - i++; - } - return Util.null2String(responseMap.get(strArr[strArr.length - 1])); + try { + String[] strArr = responseField.split("\\."); + int i = 0; + while (i < strArr.length - 1){ + Object o = responseMap.get(strArr[i]); + if(o instanceof Map){ + responseMap = (Map) o; + }else if(o instanceof List){ + List> list = (List>) o; + if(CollectionUtils.isEmpty(list)){ + return ""; + } + responseMap = list.get(0); + } + i++; + } + return Util.null2String(responseMap.get(strArr[strArr.length - 1])); + }catch (Exception e){ + throw new CustomerException("parseMap error : " + e.getMessage()); + } } + /** + *

调用sap接口

+ * @author xuanran.wang + * @dateTime 2023/5/15 14:05 + * @param url 接口地址 + * @param xml 报文xml + * @return 接口响应 + **/ + public String callSap(String url, String xml){ + OutputStreamWriter writer = null; + BufferedReader reader = null; + try { + String userName = aiyh.utils.Util.null2DefaultStr(getSystemParamValue("sapUserName"),""); + String password = aiyh.utils.Util.null2DefaultStr(getSystemParamValue("sapPassword"),""); + log.info("callSap userName : [ " + userName + " ], password : [ " + password + " ]"); + String authString = userName + ":" + password; + byte[] authEncBytes = Base64.getEncoder().encode(authString.getBytes()); + String authStringEnc = new String(authEncBytes); + URL serviceUrl = new URL(url); + HttpURLConnection connection = (HttpURLConnection) serviceUrl.openConnection(); + connection.setRequestMethod("POST"); + connection.setRequestProperty("Content-Type", "text/xml; charset=utf-8"); + connection.setRequestProperty("Authorization", "Basic " + authStringEnc); + connection.setDoOutput(true); + writer = new OutputStreamWriter(connection.getOutputStream(), StandardCharsets.UTF_8); + writer.write(xml); + writer.close(); + reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)); + String line; + StringBuilder responseBuilder = new StringBuilder(); + while ((line = reader.readLine()) != null) { + responseBuilder.append(line); + } + reader.close(); + String response = responseBuilder.toString(); + if(StringUtils.isBlank(response)){ + throw new CustomerException("sap response is empty!"); + } + return response; + }catch (Exception e){ + throw new CustomerException("callSap error : " + e.getMessage()); + }finally { + try { + if(writer != null){ + writer.close(); + } + if(reader != null){ + reader.close(); + } + }catch (Exception e){ + log.error("关流异常 : " + e.getMessage()); + } + } + } } diff --git a/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/ShBigDataUtil.java b/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/ShBigDataUtil.java index bcf46c6..13de9f8 100644 --- a/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/ShBigDataUtil.java +++ b/src/main/java/weaver/xuanran/wang/sh_bigdata/common/util/ShBigDataUtil.java @@ -35,6 +35,8 @@ public class ShBigDataUtil { WHILTE_LIST.add("loginErrorSendRedirectUrl"); WHILTE_LIST.add("getUserIdDebug"); WHILTE_LIST.add("getUserIdDebugOutKey"); + WHILTE_LIST.add("ssoInterfaceCompareField"); + WHILTE_LIST.add("ssoOaCompareField"); } /** diff --git a/src/main/resources/WEB-INF/prop/prop2map/htmlLabelIndex.properties b/src/main/resources/WEB-INF/prop/prop2map/htmlLabelIndex.properties index aa1fb53..48b8541 100644 --- a/src/main/resources/WEB-INF/prop/prop2map/htmlLabelIndex.properties +++ b/src/main/resources/WEB-INF/prop/prop2map/htmlLabelIndex.properties @@ -3,4 +3,6 @@ aiyh.htmllabel.porsche.faddcontractcontroller.pusherr.defaultstr=邮件发送失 aiyh.htmllabel.porsche.faddcontractcontroller.pushsuccess.labelindex=-1 aiyh.htmllabel.porsche.faddcontractcontroller.pushsuccess.defaultstr=签署邮件发送成功! attachment_sort.annexsortaction.sorterr.labelindex=-1 -attachment_sort.annexsortaction.sorterr.defaultstr=文件排序失败,请联系系统管理员! \ No newline at end of file +attachment_sort.annexsortaction.sorterr.defaultstr=文件排序失败,请联系系统管理员! +xbk.contractRepush.errorMsg.labelindex=-83377 +xbk.contractRepush.errorMsg.defaultstr=我是傻狗 \ No newline at end of file diff --git a/src/main/resources/ajzx/ContractList.jsp b/src/main/resources/ajzx/ContractList.jsp new file mode 100644 index 0000000..7160658 --- /dev/null +++ b/src/main/resources/ajzx/ContractList.jsp @@ -0,0 +1,500 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<%@ include file="/systeminfo/init_wev8.jsp"%> +<%@ taglib uri="/WEB-INF/weaver.tld" prefix="wea"%> +<%@ taglib uri="/WEB-INF/tld/browser.tld" prefix="brow"%> + +<%@ page import="weaver.file.Prop" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="weaver.systeminfo.SystemEnv" %> + + + + + + + + + + + + + + + +<% + + String sqlwhere = " where 1=1 "; + + String subcompanyid1 = ResourceComInfo.getSubCompanyID(String.valueOf(user.getUID())); + + //是否采购部 + boolean isDep = false; + //是否是流程接收人 + boolean isShow = false; + //采购部的同事可以选择所有合同卡片;而本部门的人员(非采购部)只能选择本部门的合同卡片 + RecordSet_Dep.executeSql("select * from HrmDepartment where departmentname like '%采购%' and id="+user.getUserDepartment()); + if(RecordSet_Dep.next()) isDep = true; + + //是否合同流程接收人 + String sqlwhere_workflow = ""; + RecordSet_Dep.executeSql("select distinct requestId from workflow_currentoperator where workflowid in (79,148,133,128,118,108,98,153,167,316,470,514,532,543,600,717,719,739,832,927,929) and userid="+user.getUID()); + if(RecordSet_Dep.next()) isShow = true; + + if(!HrmUserVarify.checkUserRight("ContactInfo:Manager", user) && !HrmUserVarify.checkUserRight("ContactInfo:User", user) && !isShow && !isDep){ + response.sendRedirect("/notice/noright.jsp"); + } + + //如果是合同管理权限,则直接1=1 + if(HrmUserVarify.checkUserRight("ContactInfo:Manager", user)){ + sqlwhere += " and 1=1"; + }else if(isShow && HrmUserVarify.checkUserRight("ContactInfo:User", user)){ + //如果是流程接收人,并且有合同查看权限 + sqlwhere += " and (requestid in (select distinct requestId from workflow_currentoperator where workflowid in (79,148,133,128,118,108,98,153,167,316,470,514,532,543,600,717,719,739,832,927,929) and userid="+user.getUID()+") or reqDeptId = '"+user.getUserDepartment()+"')"; + + }else if(HrmUserVarify.checkUserRight("ContactInfo:User", user)){ + //如果只有合同查看权限 + sqlwhere += " and reqDeptId = '"+user.getUserDepartment()+"'"; + + }else if(isShow){ + //如果只是流程接收人 + sqlwhere += " and requestid in (select distinct requestId from workflow_currentoperator where workflowid in (79,148,133,128,118,108,98,153,167,316,470,514,532,543,600,717,719,739,832,927,929) and userid="+user.getUID()+")"; + } + + //如果没有查看全部的权限,加分部条件 + if(!HrmUserVarify.checkUserRight("ContactInfoList:ALL", user)){ + if (!subcompanyid1.equals("0")) {sqlwhere += " and CrmContractInfo.subcompanyid1 = '"+subcompanyid1+"' ";} + } + String imagefilename = "/images/hdReport.gif"; + String titlename = SystemEnv.getHtmlLabelName(614, user.getLanguage()) + SystemEnv.getHtmlLabelName(527, user.getLanguage()); + String needfav = "1"; + String needhelp = ""; +%> + + <%@ include file="/systeminfo/TopTitle_wev8.jsp"%> + <%@ include file="/systeminfo/RightClickMenuConent_wev8.jsp"%> + <% + RCMenu += "{" + SystemEnv.getHtmlLabelName(197, user.getLanguage()) + ",javascript:OnSearch(),_top} "; + RCMenuHeight += RCMenuHeightStep; + RCMenu += "{" + "Excel,javascript:ContractExport(),_top} "; + RCMenuHeight += RCMenuHeightStep; + RCMenu += "{" + SystemEnv.getHtmlLabelName(18363, user.getLanguage()) + ",javascript:_table.firstPage(),_self}"; + RCMenuHeight += RCMenuHeightStep; + RCMenu += "{" + SystemEnv.getHtmlLabelName(1258, user.getLanguage()) + ",javascript:_table.prePage(),_self}"; + RCMenuHeight += RCMenuHeightStep; + RCMenu += "{" + SystemEnv.getHtmlLabelName(1259, user.getLanguage()) + ",javascript:_table.nextPage(),_self}"; + RCMenuHeight += RCMenuHeightStep; + RCMenu += "{" + SystemEnv.getHtmlLabelName(18362, user.getLanguage()) + ",javascript:_table.lastPage(),_self}"; + RCMenuHeight += RCMenuHeightStep; + %> + <% + int pagenum = Util.getIntValue(request.getParameter("pagenum"), 1); + int perpage = Util.getPerpageLog(); + if (perpage <= 1) perpage = 10; + + String creator = Util.fromScreen(request.getParameter("creator"), user.getLanguage()); + String fromdate = Util.fromScreen(request.getParameter("fromdate"), user.getLanguage()); + String fromdate2 = Util.fromScreen(request.getParameter("fromdate2"), user.getLanguage()); + String enddate = Util.fromScreen(request.getParameter("enddate"), user.getLanguage()); + String enddate2 = Util.fromScreen(request.getParameter("enddate2"), user.getLanguage()); + String status_temp = Util.null2String(request.getParameter("status_temp")); + + String conNo = Util.fromScreen(request.getParameter("conNo"), user.getLanguage()); + String prNo = Util.fromScreen(request.getParameter("prNo"), user.getLanguage()); + String jpcNo = Util.fromScreen(request.getParameter("jpcNo"), user.getLanguage()); + String suppliersId = Util.fromScreen(request.getParameter("suppliersId"), user.getLanguage()); + String isOneSuppliers = Util.fromScreen(request.getParameter("isOneSuppliers"), user.getLanguage()); +// String reqDeptId = String.valueOf(user.getUserDepartment()); + String reqDeptId = Util.fromScreen(request.getParameter("reqDeptId"), user.getLanguage());; + //管理员组或采购部才能查询所有部门下合同,合同接收人查看接收的合同 +// if(HrmUserVarify.checkUserRight("ContactInfo:Manager", user) || isShow) reqDeptId = Util.fromScreen(request.getParameter("reqDeptId"), user.getLanguage()); + String isOverdue = Util.fromScreen(request.getParameter("isOverdue"), user.getLanguage()); + String status = Util.fromScreen(request.getParameter("status"), user.getLanguage()); + String isOverdueNext = Util.fromScreen(request.getParameter("isOverdueNext"), user.getLanguage()); + String conType = Util.fromScreen(request.getParameter("conType"), user.getLanguage()); + + String name = Util.fromScreen(request.getParameter("name"), user.getLanguage()); + String subCompanyId = Util.fromScreen(request.getParameter("subCompanyId"), user.getLanguage()); + String reNewStatus = Util.fromScreen(request.getParameter("reNewStatus"), user.getLanguage()); + String conStatus = Util.fromScreen(request.getParameter("conStatus"), user.getLanguage()); + String contractName = Util.fromScreen(request.getParameter("contractName"), user.getLanguage()); + String csstatus = Util.fromScreen(request.getParameter("csstatus"), user.getLanguage()); + + int opentype = Util.getIntValue(request.getParameter("opentype"),-1); + + //String sqlwhere = " where status = '' "; + //if(!"".equals(status_temp)) sqlwhere += " and status in ("+status_temp+") "; + + if (!fromdate.equals("")) sqlwhere += " and startDate>='" + fromdate + "'"; + if (!fromdate2.equals("")) sqlwhere += " and startDate<='" + fromdate2 + "'"; + if (!enddate.equals("")) sqlwhere += " and enddate>='" + enddate + "'"; + if (!enddate2.equals("")) sqlwhere += " and enddate<='" + enddate2 + "'"; + if (!conNo.equals("")) sqlwhere += " and conNo like '%" + conNo + "%'"; + if (!prNo.equals("")) sqlwhere += " and prNo='" + prNo + "'"; + if (!jpcNo.equals("")) sqlwhere += " and jpcNo='" + jpcNo + "'"; + if(!"".equals(suppliersId)) sqlwhere += " and suppliersId=" + suppliersId; + if (!isOneSuppliers.equals("")) sqlwhere += " and isOneSuppliers='" + isOneSuppliers + "'"; + if (!"".equals(creator) && !"0".equals(creator)) sqlwhere += " and CrmContractInfo.creator=" + creator; + if (!reqDeptId.equals("")) sqlwhere += " and reqDeptId=" + reqDeptId; + if (!isOverdue.equals("")) sqlwhere += " and isOverdue='" + isOverdue + "'"; + if (!status.equals("")) sqlwhere += " and CrmContractInfo.status='" + status + "'"; + if (!isOverdueNext.equals("")) sqlwhere += " and isOverdueNext='" + isOverdueNext + "'"; + if (!conType.equals("")) sqlwhere += " and conType='" + conType + "'"; + if (!csstatus.equals("")) sqlwhere += " and CrmSalesContractInfo.status='" + csstatus + "'"; + + if (!name.equals("")) sqlwhere += " and name like '%" + name + "%'"; + if (!subCompanyId.equals("")) sqlwhere += " and CrmContractInfo.subcompanyid1 = '" + subCompanyId + "'"; + if (!reNewStatus.equals("")) sqlwhere += " and conStatus = '" + reNewStatus + "'"; + + if (!contractName.equals("")) sqlwhere += " and contractName like '%" + contractName + "%'"; + + //if (reNewStatus2.equals("待续签")) sqlwhere += " and dbo.getReNewStatus2(2,CrmContractInfo.saleContract) > 0"; + //else if (reNewStatus2.equals("已续签")) sqlwhere += " and dbo.getReNewStatus2(1,CrmContractInfo.saleContract) > 0"; + //else if (reNewStatus2.equals("无需续签")) sqlwhere += " and dbo.getReNewStatus2(3,CrmContractInfo.saleContract) > 0"; + //System.out.println("sqlwhere:"+sqlwhere); + + + if(opentype > -1){ + sqlwhere += " and isnull(CrmContractInfo.opentype,0) = " + opentype; + } + + String orderStr = " order by startDate desc, CrmContractInfo.id desc "; + +// out.println("sqlwhere:" + sqlwhere); +// out.println("orderStr:" + orderStr); + +// session.setAttribute("sqlwhere", sqlwhere); +// session.setAttribute("orderStr", orderStr); + %> +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%if(HrmUserVarify.checkUserRight("ContactInfoList:ALL", user)){%> + + + <%}%> + + + + + + + + + + + + + + + + +
<%=SystemEnv.getHtmlLabelName(15774, user.getLanguage())%>
合同状态 + + <%=SystemEnv.getHtmlLabelName(1970, user.getLanguage())%> +   + <%=Util.toScreen(fromdate, user.getLanguage())%> -  +   + <%=Util.toScreen(fromdate2, user.getLanguage())%> + > + > + <%=SystemEnv.getHtmlLabelName(15236, user.getLanguage())%> +   + <%=Util.toScreen(enddate, user.getLanguage())%> -  +   + <%=Util.toScreen(enddate2, user.getLanguage())%> + > + > +
<%=SystemEnv.getHtmlLabelName(21282, user.getLanguage())%> + + PR<%=SystemEnv.getHtmlLabelName(403,user.getLanguage())%> + + JPC<%=SystemEnv.getHtmlLabelName(2171,user.getLanguage())%><%=SystemEnv.getHtmlLabelName(16992,user.getLanguage())%> + +
<%=SystemEnv.getHtmlLabelName(613002, user.getLanguage())%> + + + + + <%=SystemEnv.getHtmlLabelName(913, user.getLanguage())%> + + +
<%=SystemEnv.getHtmlLabelName(620002, user.getLanguage())%> + + + + +<%-- <%--%> +<%-- //管理员组才能查询所有部门下合同--%> +<%-- if(HrmUserVarify.checkUserRight("ContactInfo:Manager", user)){--%> +<%-- %>--%> +<%-- +<%-- id="reqDeptId"--%> +<%-- name="reqDeptId"--%> +<%-- browserValue="<%=reqDeptId %>"--%> +<%-- browserUrl="/systeminfo/BrowserMain.jsp?url=/hrm/company/DepartmentBrowser.jsp"--%> +<%-- hasInput="true"--%> +<%-- isSingle="true"--%> +<%-- hasBrowser = "true"--%> +<%-- isMustInput='1'--%> +<%-- width="165px"--%> +<%-- browserSpanValue="<%=Util.toScreen(DepartmentComInfo.getDepartmentname(reqDeptId),user.getLanguage())%>">--%> +<%-- --%> + +<%-- <%––%>--%> +<%-- <%}else{ %>--%> +<%-- <%=Util.toScreen(DepartmentComInfo.getDepartmentname(reqDeptId),user.getLanguage()) %>--%> +<%-- <%} %>--%> + 付款状态 + + <%=SystemEnv.getHtmlLabelName(620017, user.getLanguage())%> + +
<%=SystemEnv.getHtmlLabelName(15775, user.getLanguage())%> + + <%=SystemEnv.getHtmlLabelName(15142, user.getLanguage())%> + + <%=SystemEnv.getHtmlLabelName(141,user.getLanguage())%>: + + + "> + + + + <%-- + <%--_url="/systeminfo/BrowserMain.jsp?url=/hrm/company/SubcompanyBrowser.jsp"--%> + <%--_displayText="<%=SubCompanyComInfo.getSubCompanyname(subCompanyId+"")%>"--%> + <%-->--%> +
<%=SystemEnv.getHtmlLabelName(16404, user.getLanguage())%><%=SystemEnv.getHtmlLabelName(195, user.getLanguage())%> + + 销售合同状态 + + 开闭口类型 + +
+ +
+ +
+ + + + +
+ <% + + String tableString = ""; + String backfields = " CrmContractInfo.id,case CrmContractInfo.opentype when '0' then '闭口' when '1' then '开口' when '2' then '周期性' end opentype, reqDeptId, suppliersId, conNo, name, startDate, endDate, case isOverdue when 'Y' then '是' else '否' end as isOverdue, conAmount, content, ',' as str_temp, case isOverdueNext when 'Y' then '是' else '否' end as isOverdueNext, case CrmContractInfo.status when '0' then '执行中' when '1' then '已结清' end as status, CrmContractInfo.creator, CrmContractInfo.subcompanyid1, case conStatus when '0' then '执行' when '1' then '待续签' when '2' then '已续签' when '3' then '关闭' end as reNewStatus, contractName, saleContract, case when dbo.getReNewStatus2(1,CrmContractInfo.saleContract) > 0 then '已续签' when dbo.getReNewStatus2(2,CrmContractInfo.saleContract) > 0 then '待续签' when dbo.getReNewStatus2(3,CrmContractInfo.saleContract) > 0 then '无需续签' end as reNewStatus2,case CrmSalesContractInfo.status when '0' then '已签署' when '1' then '未签署' when '2' then '已续签' when '3' then '关闭' end as csstatus "; + String fromSql = " CrmContractInfo Left Join CrmSalesContractInfo On CrmSalesContractInfo.id=CrmContractInfo.saleContract "; + //out.print("select"+backfields+"from"+fromSql +sqlwhere); + String str_content = "content"+"str_temp"; + tableString = " " + "" + ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + //tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + //tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += ""; + tableString += "
"; + %> + + +
+
+ <%@ include file="/systeminfo/RightClickMenu_wev8.jsp"%> + + + + + + + \ No newline at end of file diff --git a/src/main/resources/ajzx/ContractReportExport.jsp b/src/main/resources/ajzx/ContractReportExport.jsp new file mode 100644 index 0000000..efe37c1 --- /dev/null +++ b/src/main/resources/ajzx/ContractReportExport.jsp @@ -0,0 +1,130 @@ +<%@ page language="java" contentType="text/html; charset=GBK" %> +<%@ include file="/systeminfo/init.jsp" %> +<%@ page import="weaver.general.Util, weaver.file.ExcelSheet, weaver.file.ExcelRow" %> +<%@ page import="lombok.val" %> +<%@ page import="weaver.zwl.common.logging.Logger" %> + + + + + + + + + + +<%! + public static String ToDBC(String input) { + char[] c = input.toCharArray(); + for (int i = 0; i < c.length; i++) { + if (c[i] == 12288) { + //ȫǿոΪ12288ǿոΪ32 + c[i] = (char) 32; + continue; + } + if (c[i] > 65280 && c[i] < 65375) + //ַ(33-126)ȫ(65281-65374)ĶӦϵǣ65248 + c[i] = (char) (c[i] - 65248); + } + return new String(c); + } + + +%> + +<% + // String sqlwhere=(String)session.getAttribute("sqlwhere"); +// String orderStr=(String)session.getAttribute("orderStr"); + + val logger = aiyh.utils.Util.getLogger(); + String sqlwhere = request.getParameter("sqlwhere"); + sqlwhere = ToDBC(sqlwhere); + String orderStr = request.getParameter("orderStr"); + orderStr = ToDBC(orderStr); + + String sqlstr = ""; + + if (RecordSet.getDBType().equals("oracle")) { + sqlstr = "select CrmContractInfo.id, reqDeptId, suppliersId, conNo, name, startDate, endDate, case isOverdue when 'Y' then '' else '' end as isOverdue, conAmount, content, case isOverdueNext when 'Y' then '' else '' end as isOverdueNext, case CrmContractInfo.status when '0' then 'ִ' when '1' then 'ѽ' end as status, case isOneSuppliers when 'Y' then '' when 'N' then '' else '' end as isOneSuppliers, prRequestId,jpcNo,jpcFile,prNo,prAmount,prAmountSum,conAmount,managerId,subject,giveDate,giveRemark,payRemark,content,CrmContractInfo.createDate,CrmContractInfo.creator,CrmContractInfo.subcompanyid1, case conStatus when '0' then 'ִ' when '1' then 'ǩ' when '2' then 'ǩ' when '3' then 'ر' end as reNewStatus,contractName, saleContract, case CrmSalesContractInfo.status when '0' then 'ǩ' when '1' then 'δǩ' when '2' then 'ǩ' when '3' then 'ر' end as reNewStatus2 from CrmContractInfo Left Join CrmSalesContractInfo On CrmSalesContractInfo.id=CrmContractInfo.saleContract" + sqlwhere + orderStr; + } else { + sqlstr = "select CrmContractInfo.id, reqDeptId, suppliersId, conNo, name, startDate, endDate, case isOverdue when 'Y' then '' else '' end as isOverdue, conAmount, content, case isOverdueNext when 'Y' then '' else '' end as isOverdueNext, case CrmContractInfo.status when '0' then 'ִ' when '1' then 'ѽ' end as status, case isOneSuppliers when 'Y' then '' when 'N' then '' else '' end as isOneSuppliers, prRequestId,jpcNo,jpcFile,prNo,prAmount,prAmountSum,conAmount,managerId,subject,giveDate,giveRemark,payRemark,content,CrmContractInfo.createDate,CrmContractInfo.creator,CrmContractInfo.subcompanyid1, case conStatus when '0' then 'ִ' when '1' then 'ǩ' when '2' then 'ǩ' when '3' then 'ر' end as reNewStatus,contractName, saleContract, case CrmSalesContractInfo.status when '0' then 'ǩ' when '1' then 'δǩ' when '2' then 'ǩ' when '3' then 'ر' end as reNewStatus2 from CrmContractInfo Left Join CrmSalesContractInfo On CrmSalesContractInfo.id=CrmContractInfo.saleContract" + sqlwhere + orderStr; + } + new BaseBean().writeLog(">>>>>>>>"+sqlstr); + RecordSet.executeQuery(sqlstr); + + ExcelSheet es = new ExcelSheet(); + + ExcelRow er = es.newExcelRow(); + er.addStringValue(SystemEnv.getHtmlLabelName(141,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620002,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(613002,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(21282,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(15142,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(1970,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(15236,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620016,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(6146,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620015,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620017,user.getLanguage())); + er.addStringValue("״̬"); + er.addStringValue(SystemEnv.getHtmlLabelName(913,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620009,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620003,user.getLanguage())); + er.addStringValue("JPC"+SystemEnv.getHtmlLabelName(16992,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620004,user.getLanguage())); + er.addStringValue("PR"+SystemEnv.getHtmlLabelName(403,user.getLanguage())); + er.addStringValue("PR"+SystemEnv.getHtmlLabelName(856,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620010,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620011,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620006,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620012,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620013,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620014,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(620015,user.getLanguage())); + er.addStringValue(SystemEnv.getHtmlLabelName(614,user.getLanguage())+SystemEnv.getHtmlLabelName(722,user.getLanguage())); + er.addStringValue("ͬ״̬"); + er.addStringValue("ۺͬ"); + er.addStringValue("ۺͬ״̬"); + + while (RecordSet.next()) { + ExcelRow erdetail = es.newExcelRow(); + erdetail.addStringValue(SubCompanyComInfo.getSubCompanyname(RecordSet.getString("subcompanyid1"))); + erdetail.addStringValue(DepartmentComInfo.getDepartmentname(RecordSet.getString("reqDeptId"))); + erdetail.addStringValue(CrmSupplierComInfo.getSuppliername(RecordSet.getString("suppliersId"))); + erdetail.addStringValue(RecordSet.getString("conNo")); + erdetail.addStringValue(RecordSet.getString("name")); + erdetail.addStringValue(RecordSet.getString("startDate")); + erdetail.addStringValue(RecordSet.getString("endDate")); + erdetail.addStringValue(RecordSet.getString("isOverdue")); + erdetail.addStringValue(RecordSet.getString("conAmount")); + erdetail.addStringValue(Util.toScreen(SptmForDoc.getDocName(RecordSet.getString("content")), user.getLanguage())); + erdetail.addStringValue(RecordSet.getString("isOverdueNext")); + erdetail.addStringValue(RecordSet.getString("status")); + erdetail.addStringValue(Util.toScreen(ResourceComInfo.getResourcename(RecordSet.getString("creator")), user.getLanguage())); + erdetail.addStringValue(RecordSet.getString("isOneSuppliers")); + erdetail.addStringValue(RequestComInfo.getRequestname(RecordSet.getString("prRequestId"))); + erdetail.addStringValue(RecordSet.getString("jpcNo")); + erdetail.addStringValue(DocComInfo.getDocname(RecordSet.getString("jpcFile"))); + erdetail.addStringValue(RecordSet.getString("prNo")); + erdetail.addStringValue(RecordSet.getString("prAmount")); + erdetail.addStringValue(RecordSet.getString("prAmountSum")); + erdetail.addStringValue(ResourceComInfo.getResourcename(RecordSet.getString("managerId"))); + erdetail.addStringValue(RecordSet.getString("subject")); + erdetail.addStringValue(RecordSet.getString("giveDate")); + erdetail.addStringValue(RecordSet.getString("giveRemark")); + erdetail.addStringValue(RecordSet.getString("payRemark")); + erdetail.addStringValue(DocComInfo.getDocname(RecordSet.getString("content"))); + erdetail.addStringValue(RecordSet.getString("createDate")); + erdetail.addStringValue(RecordSet.getString("reNewStatus")); + erdetail.addStringValue(RecordSet.getString("contractName")); + erdetail.addStringValue(RecordSet.getString("reNewStatus2")); + } + + ExcelFile.init(); + ExcelFile.setFilename("ͬ"); + ExcelFile.addSheet("ͬ", es); +%> +<%----%> + \ No newline at end of file diff --git a/src/main/youhong_ai_old_src/weaver/aiyh_pcn/common_fadada/util/FaRequestUtils.java b/src/main/youhong_ai_old_src/weaver/aiyh_pcn/common_fadada/util/FaRequestUtils.java index 63afb8a..da9be2d 100644 --- a/src/main/youhong_ai_old_src/weaver/aiyh_pcn/common_fadada/util/FaRequestUtils.java +++ b/src/main/youhong_ai_old_src/weaver/aiyh_pcn/common_fadada/util/FaRequestUtils.java @@ -119,6 +119,31 @@ public class FaRequestUtils { } return responeVo; } + + /** + * 公司认证状态同步方法 + * + * @param data 请求参数 + * @param url 请求地址 + * @return 请求结果 + */ + public static ResponeVo companyAuthentication(Map data, String url) { + log.info("公司认证状态同步"); + try { + HEADER.put("sign", builderSign(data)); + } catch (Exception e) { + throw new CustomerException("签名失败!", e); + } + HEADER.put("Content-Type", "application/json"); + ResponeVo responeVo = null; + try { + responeVo = HTTP_UTILS.apiPost(url, + data, null); + } catch (IOException e) { + e.printStackTrace(); + } + return responeVo; + } public static ResponeVo RevocationContract(Map data, String url) { log.info("撤销合同方法"); diff --git a/src/test/java/basetest/BaseTest.java b/src/test/java/basetest/BaseTest.java index 7fb47af..b394cb4 100644 --- a/src/test/java/basetest/BaseTest.java +++ b/src/test/java/basetest/BaseTest.java @@ -130,6 +130,7 @@ public class BaseTest { @Test public void with() { + Logger logger = Util.getLogger(); logger.info("aafasdf"); String sql = "select COMPANYNAME,LICENSE,EXPIREDATE,CVERSION from license "; diff --git a/src/test/java/bokang/xiao/NormalTest.java b/src/test/java/bokang/xiao/NormalTest.java index 7227bb1..86ca4e0 100644 --- a/src/test/java/bokang/xiao/NormalTest.java +++ b/src/test/java/bokang/xiao/NormalTest.java @@ -8,8 +8,10 @@ import basetest.BaseTest; import bokang.xiao.entity.CourseEntity; import bokang.xiao.entity.StudentEntity; import bokang.xiao.entity.TeacherEntity; +import bokang.xiao.util.XmlParser; import cn.afterturn.easypoi.excel.ExcelExportUtil; import cn.afterturn.easypoi.excel.entity.ExportParams; +import com.alibaba.fastjson.JSON; import com.api.bokang.xiao.porsche_review.mapper.ReviewMapper; import com.api.bokang.xiao.wx_report.mapper.ReportMapper; @@ -20,8 +22,14 @@ import com.api.bokang.xiao.zscq.service.impl.ReserveServiceImpl; import org.apache.log4j.Logger; import org.apache.poi.ss.usermodel.Workbook; import org.junit.Test; +import weaver.bokang.xiao.common.CommonUtil; import weaver.bokang.xiao.common.mapper.ModeMapper; +import weaver.bokang.xiao.common.mapper.WorkflowMapper; import weaver.bokang.xiao.deg_repeat_check.action.RepeatCheckAction; +import weaver.bokang.xiao.porsche.action.DateFieldUpdateAction; +import weaver.bokang.xiao.porsche.schedule.CompanyWriteBackSchedule; +import weaver.bokang.xiao.porsche.schedule.SalaryUpdateSchedule; +import weaver.bokang.xiao.sh_bigdata.action.DataPushAction; import weaver.bokang.xiao.xhny_mode.search.CustomSearchDepart; import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData; import weaver.bokang.xiao.xhny_report.schedule.GenerateReportSchedule; @@ -30,6 +38,7 @@ import weaver.bokang.xiao.xhny_report.service.ScoreChainPattern; import weaver.bokang.xiao.zscq.action.OneNetComAction; import weaver.bokang.xiao.zscq.action.StatusChangeAction; import weaver.bokang.xiao.zscq.config.service.ModeChangeService; +import weaver.bokang.xiao.zscq.store.TableNameStore; import weaver.bokang.xiao.zxyh.RepeatSubmitAction; import weaver.conn.RecordSet; import weaver.general.StaticObj; @@ -44,6 +53,7 @@ import java.io.*; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.sql.*; +import java.text.SimpleDateFormat; import java.util.*; import java.util.Date; @@ -57,16 +67,16 @@ public class NormalTest extends BaseTest { @Test public void testWord(){ - //GenerateFileUtil.createCronJobDocument(GenerateReportSchedule.class); - //GenerateFileUtil.createActionDocument(OneNetComAction.class); - GenerateFileUtil.createActionDocument(RepeatSubmitAction.class); + GenerateFileUtil.createCronJobDocument(SalaryUpdateSchedule.class); + //GenerateFileUtil.createActionDocument(DataPushAction.class); + //GenerateFileUtil.createActionDocument(DateFieldUpdateAction.class); } @Test public void testChain(){ GenerateReportSchedule generateReportSchedule = new GenerateReportSchedule(); - generateReportSchedule.setReportModelId("-2915"); - generateReportSchedule.setDataSource("NCC"); + //generateReportSchedule.setReportModelId("-2915"); + //generateReportSchedule.setDataSource("NCC"); generateReportSchedule.runCode(); } @@ -343,9 +353,52 @@ public class NormalTest extends BaseTest { @Test public void testSub(){ - String sourceStr = ",0,1,2,"; - String value = ",0,"; - System.out.println(sourceStr.contains(value)); + WorkflowMapper workflowMapper = Util.getMapper(WorkflowMapper.class); + List> maps = workflowMapper.queryCommonSelect("付款银行"); + System.out.println(maps); + } + + @Test + public void testDate(){ + Date date = new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("MMMM d','yyyy",Locale.US); + String formattedDate = sdf.format(date); + System.out.println("Formatted date: " + formattedDate); + } + + @Test + public void testXml() throws Exception { + //Map stringObjectMap = XmlParser.parseXml("\n" + + // "E192168000104220630083401387679060******b2e000922063008340100017220.02CNY0202206304559592253523132900300973101040160001226585上海昱锐科技有限公司杭州银行股份有限公司上海青浦支行"); + //System.out.println(JSON.toJSONString(stringObjectMap)); + String insid = XmlParser.getNodeValue("" + + "E192168000104220630083401387679060******b2e000922063008340100017220.02CNY0202206304559592253523132900300973101040160001226585上海昱锐科技有限公司杭州银行股份有限公司上海青浦支行","insid"); + System.out.println(insid); + } + + @Test + public void testDiffrentce() throws Exception { + Map map1 = new HashMap<>(); + map1.put("id", 1); + map1.put("name", "A"); + Map map2 = new HashMap<>(); + map2.put("id", 1); + map2.put("name", "B"); + Map map3 = new HashMap<>(); + map3.put("id", 2); + map3.put("name", "B"); + List> list1 = Arrays.asList(map1, map2); + List> list2 = Arrays.asList(map2, map3); + List> difference = CommonUtil.difference(list1, list2, map -> map.get("id")); + List> difference1 = CommonUtil.difference(list2, list1, map -> map.get("id")); + System.out.println(difference); // 输出 [{id=1, name=A}] + System.out.println(difference1); // 输出 [{id=1, name=A}] + + } + + @Test + public void testQuery1(){ + TableNameStore.getInstance().refresh(); } } diff --git a/src/test/java/bokang/xiao/util/XmlParser.java b/src/test/java/bokang/xiao/util/XmlParser.java new file mode 100644 index 0000000..357e3cf --- /dev/null +++ b/src/test/java/bokang/xiao/util/XmlParser.java @@ -0,0 +1,94 @@ +package bokang.xiao.util; + +import java.io.StringReader; +import java.util.*; + +import org.jdom.Document; +import org.jdom.Element; +import org.jdom.input.SAXBuilder; + +public class XmlParser { + + /** + * 将传入的 XML 字符串解析成 Map 对象 + * + * @param xml 要解析的 XML 字符串 + * @return 解析后的 Map 对象 + * @throws Exception 解析过程中出现的异常 + */ + public static Map parseXml(String xml) throws Exception { + Map map = new HashMap(); + // 创建 SAXBuilder 对象 + SAXBuilder builder = new SAXBuilder(); + // 解析 XML 字符串成 Document 对象 + Document document = builder.build(new StringReader(xml)); + // 获取根元素 + Element root = document.getRootElement(); + // 解析根元素 + parseElement(root, map); + return map; + } + + /** + * 解析指定的 Element 对象,并将解析结果存入指定的 Map 对象中 + * + * @param element 要解析的 Element 对象 + * @param map 存储解析结果的 Map 对象 + */ + private static void parseElement(Element element, Map map) { + // 获取子元素列表 + List childElements = element.getChildren(); + if (childElements.isEmpty()) { + // 如果没有子元素,则将当前元素的名称和值存入 Map 对象中 + map.put(element.getName(), element.getValue()); + } else { + Map childMap = new HashMap(); + for (Element childElement : childElements) { + // 如果有多个同名元素,则将这些元素解析成一个 List 对象,并将该 List 对象存入当前节点的 Map 对象中 + //if (childElement.getName().equals(childElements.get(0).getName())) { + // List> childList = new ArrayList>(); + // parseElement(childElement, childMap); + // childList.add(childMap); + // map.put(childElement.getName(), childList); + //} else { + // parseElement(childElement, childMap); + // map.put(childElement.getName(), childMap); + //} + parseElement(childElement, childMap); + map.put(childElement.getName(), childMap); + } + } + } + + public static String getNodeValue(String xml, String nodeName) throws Exception { + try { + SAXBuilder builder = new SAXBuilder(); + StringReader reader = new StringReader(xml); + Document doc = builder.build(reader); + Element root = doc.getRootElement(); + String nodeValue = getNodeValue(root, nodeName); + return nodeValue == null ? "" : nodeValue; + }catch (Exception e){ + return ""; + } + } + + private static String getNodeValue(Element element, String nodeName) { + Element node = element.getChild(nodeName); + if (node != null) { + return node.getValue(); + } else { + List children = element.getChildren(); + if(Objects.nonNull(children) && children.size() > 0){ + for (Element child : children) { + String value = getNodeValue(child, nodeName); + if (value != null) { + return value; + } + } + } + return null; + } + } + +} \ No newline at end of file diff --git a/src/test/java/xuanran/wang/NormalTest.java b/src/test/java/xuanran/wang/NormalTest.java new file mode 100644 index 0000000..0fc4fb5 --- /dev/null +++ b/src/test/java/xuanran/wang/NormalTest.java @@ -0,0 +1,21 @@ +package xuanran.wang; + +import aiyh.utils.GenerateFileUtil; +import basetest.BaseTest; +import org.junit.Test; +import weaver.xuanran.wang.eighty_five_degreec.sap.action.WorkflowToSap; + +/** + *

+ * + * @author xuanran.wang + * @date 2023/5/19 16:48 + */ +public class NormalTest extends BaseTest { + + + @Test + public void testWord(){ + GenerateFileUtil.createActionDocument(WorkflowToSap.class); + } +} diff --git a/src/test/java/xuanran/wang/big_data/BigDataTest.java b/src/test/java/xuanran/wang/big_data/BigDataTest.java index fb032cb..1639bc9 100644 --- a/src/test/java/xuanran/wang/big_data/BigDataTest.java +++ b/src/test/java/xuanran/wang/big_data/BigDataTest.java @@ -3,6 +3,7 @@ package xuanran.wang.big_data; import aiyh.utils.Util; import basetest.BaseTest; import com.alibaba.fastjson.JSONObject; +import com.api.xuanran.wang.sh_bigdata.sso.mapper.OtherSystemToOAMapper; import com.icbc.api.internal.apache.http.impl.cookie.S; import com.weaver.esb.server.cache.ResourceComInfo; import emo.macro.ob.OB; @@ -13,6 +14,7 @@ import weaver.email.EmailWorkRunnable; import weaver.general.TimeUtil; import weaver.xuanran.wang.common.util.CusInfoToOAUtil; import weaver.xuanran.wang.sh_bigdata.common.entity.CusSuccess; +import weaver.xuanran.wang.sh_bigdata.common.util.ShBigDataUtil; import weaver.xuanran.wang.sh_bigdata.org_hrm_async.OrganizationHrmSyncFromOtherSys; import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OrgHrmAsyncConfigMain; import weaver.xuanran.wang.sh_bigdata.org_hrm_async.entity.OtherSysDepartment; @@ -32,369 +34,366 @@ import java.util.stream.Collectors; * @date 2023/4/10 10:49 */ public class BigDataTest extends BaseTest { - private final OrgHrmAsyncServiceImpl orgHrmAsyncService = new OrgHrmAsyncServiceImpl(); - private final OrgHrmAsyncApiService orgHrmAsyncApiService = new OrgHrmAsyncApiServiceImpl(); - private final List departmentWhiteList; - private final List subCompanyWhiteList; - private final OrgHrmAsyncMapper orgHrmAsyncMapper = Util.getMapper(OrgHrmAsyncMapper.class); - - { - departmentWhiteList = orgHrmAsyncMapper.selectCusDepart(); - subCompanyWhiteList = orgHrmAsyncMapper.selectCusSubCompany(); - } - - @Test - public void testA() throws IOException { -// List rootDepList = departmentInfo -// .stream() -// .filter(item -> 1 == item.getHasChild()) -// .sorted(Comparator.comparing(OtherSysDepartment::getId)) -// .collect(Collectors.toList()); -// for (OtherSysDepartment department : rootDepList) { -// setChildList(department, departmentInfo); +// private final OrgHrmAsyncServiceImpl orgHrmAsyncService = new OrgHrmAsyncServiceImpl(); +// private final OrgHrmAsyncApiService orgHrmAsyncApiService = new OrgHrmAsyncApiServiceImpl(); +// private final List departmentWhiteList; +// private final List subCompanyWhiteList; +// private final OrgHrmAsyncMapper orgHrmAsyncMapper = Util.getMapper(OrgHrmAsyncMapper.class); +// +// { +// departmentWhiteList = orgHrmAsyncMapper.selectCusDepart(); +// subCompanyWhiteList = orgHrmAsyncMapper.selectCusSubCompany(); +// } +// +// @Test +// public void testA() throws IOException { +//// List rootDepList = departmentInfo +//// .stream() +//// .filter(item -> 1 == item.getHasChild()) +//// .sorted(Comparator.comparing(OtherSysDepartment::getId)) +//// .collect(Collectors.toList()); +//// for (OtherSysDepartment department : rootDepList) { +//// setChildList(department, departmentInfo); +//// } +//// List departmentInfo = orgHrmAsyncApiService.getDepartmentInfo(); +//// List convert = Util.listToTree(departmentInfo, +//// OtherSysDepartment::getId, OtherSysDepartment::getParentid, +//// OtherSysDepartment::getChildList, OtherSysDepartment::setChildList, +//// parentid -> parentid == -1); +//// System.out.println("convert => " + JSONObject.toJSONString(convert, SerializerFeature.DisableCircularReferenceDetect)); +//// List hrmSubCompany = new ArrayList<>(); +//// List hrmDepartment = new ArrayList<>(); +//// int maxLevel = Util.getIntValue(ShBigDataUtil.getPropertiesValByKey("maxLevel"), 3); +//// System.out.println(countNodes(convert.get(0))); +//// parseSubCompanyAndDepartment(convert, 0,maxLevel, hrmSubCompany, hrmDepartment); +//// parseSubCompanyAndDepartment(convert, hrmSubCompany); +//// System.out.println("hrmSubCompany => " + hrmSubCompany.size()); +//// System.out.println("convertLevel => " + JSONObject.toJSONString(convert, SerializerFeature.DisableCircularReferenceDetect)); +//// System.out.println("hrmSubCompany => " + JSONObject.toJSONString(hrmSubCompany)); +//// System.out.println("hrmDepartment => " + JSONObject.toJSONString(hrmDepartment)); +//// orgHrmAsyncService.asyncDepartment(); +// Map res = JSONObject.parseObject("{\n" + +// "\t\t\"code\":0,\n" + +// "\t\t\"msg\":\"ok\",\n" + +// "\t\t\"data\":{\n" + +// "\t\t\t\"UserId\":\"13800000000\",\n" + +// "\t\t\t\"errcode\":0,\n" + +// "\t\t\t\"errmsg\":\"ok\",\n" + +// "\t\t\t\"id\":109,\n" + +// "\t\t\t\"userid\":\"13800000000\",\n" + +// "\t\t\t\"name\":\"祝芳\",\n" + +// "\t\t\t\"mobile\":\"13800000000\",\n" + +// "\t\t\t\"gender\":1,\n" + +// "\t\t\t\"department\":[\n" + +// "\t\t\t\t539\n" + +// "\t\t\t],\n" + +// "\t\t\t\"order\":[\n" + +// "\t\t\t\t6\n" + +// "\t\t\t]\n" + +// "\t\t}\n" + +// "\t}", Map.class); +// System.out.println(getRes(res)); +// } +// +// public String getRes(Map res){ +// return (String) parseRes(res, cusSuccess); +// } +// +// private final CusSuccess cusSuccess = CusSuccess.builder() +// .successField("code") +// .successValue(0) +// .errorMsg("msg") +// .dataKey("data.id") +// .build(); +// +// public T parseRes(Map response, CusSuccess cusSuccess){ +// String[] split = Util.null2DefaultStr(cusSuccess.getDataKey(),"").split("\\."); +// int len = split.length; +// if(len == 0 || StringUtils.isBlank(cusSuccess.getDataKey())){ +// return (T)response; // } -// List departmentInfo = orgHrmAsyncApiService.getDepartmentInfo(); -// List convert = Util.listToTree(departmentInfo, -// OtherSysDepartment::getId, OtherSysDepartment::getParentid, -// OtherSysDepartment::getChildList, OtherSysDepartment::setChildList, -// parentid -> parentid == -1); -// System.out.println("convert => " + JSONObject.toJSONString(convert, SerializerFeature.DisableCircularReferenceDetect)); -// List hrmSubCompany = new ArrayList<>(); -// List hrmDepartment = new ArrayList<>(); -// int maxLevel = Util.getIntValue(ShBigDataUtil.getPropertiesValByKey("maxLevel"), 3); -// System.out.println(countNodes(convert.get(0))); -// parseSubCompanyAndDepartment(convert, 0,maxLevel, hrmSubCompany, hrmDepartment); -// parseSubCompanyAndDepartment(convert, hrmSubCompany); -// System.out.println("hrmSubCompany => " + hrmSubCompany.size()); -// System.out.println("convertLevel => " + JSONObject.toJSONString(convert, SerializerFeature.DisableCircularReferenceDetect)); -// System.out.println("hrmSubCompany => " + JSONObject.toJSONString(hrmSubCompany)); -// System.out.println("hrmDepartment => " + JSONObject.toJSONString(hrmDepartment)); -// orgHrmAsyncService.asyncDepartment(); - Map res = JSONObject.parseObject("{\n" + - "\t\t\"code\":0,\n" + - "\t\t\"msg\":\"ok\",\n" + - "\t\t\"data\":{\n" + - "\t\t\t\"UserId\":\"13800000000\",\n" + - "\t\t\t\"errcode\":0,\n" + - "\t\t\t\"errmsg\":\"ok\",\n" + - "\t\t\t\"id\":109,\n" + - "\t\t\t\"userid\":\"13800000000\",\n" + - "\t\t\t\"name\":\"祝芳\",\n" + - "\t\t\t\"mobile\":\"13800000000\",\n" + - "\t\t\t\"gender\":1,\n" + - "\t\t\t\"department\":[\n" + - "\t\t\t\t539\n" + - "\t\t\t],\n" + - "\t\t\t\"order\":[\n" + - "\t\t\t\t6\n" + - "\t\t\t]\n" + - "\t\t}\n" + - "\t}", Map.class); - System.out.println(getRes(res)); - } - - public String getRes(Map res){ - return (String) parseRes(res, cusSuccess); - } - - private final CusSuccess cusSuccess = CusSuccess.builder() - .successField("code") - .successValue(0) - .errorMsg("msg") - .dataKey("data.id") - .build(); - - public T parseRes(Map response, CusSuccess cusSuccess){ - String[] split = Util.null2DefaultStr(cusSuccess.getDataKey(),"").split("\\."); - int len = split.length; - if(len == 0 || StringUtils.isBlank(cusSuccess.getDataKey())){ - return (T)response; - } - for (int i = 0; i < len - 1; i++) { - response = (Map) response.get(split[i]); - } - return (T) response.get(split[len - 1]); - } - - @Test - public void testMap(){ - List> list = orgHrmAsyncApiService.getDepartmentInfoMap(); - // 将列表转换为以id为键的Map - List> tree = convertListToTree(list); - List> department = new ArrayList<>(); - List> subCompany = new ArrayList<>(); - orgHrmAsyncService.parseSubCompanyAndDepartmentMap(tree, 0, 3, department, subCompany); - System.out.println(JSONObject.toJSONString(department)); - System.out.println(JSONObject.toJSONString(subCompany)); - } - - @Test - public void testMapper(){ -// System.setProperty("_isDebug", "false"); -// System.out.println("分部执行结果 => " + JSONObject.toJSONString(orgHrmAsyncService.asyncOrgDep(0))); -// System.out.println("部门执行结果 => " + JSONObject.toJSONString(orgHrmAsyncService.asyncOrgDep(1))); -// List orgHrmAsyncConfigMains = orgHrmAsyncMapper.selectSubCompanyAsyncConfig(2); -// System.out.println(JSONObject.toJSONString(orgHrmAsyncConfigMains)); - ArrayList ids = new ArrayList<>(); - for (int i = 0; i < 100; i++) { - ids.add("'" + UUID.randomUUID().toString().replace("-","") + "'"); - } - String updateDelStatus = "update cus_fielddata set field0 = 1 where " + - weaver.general.Util.getSubINClause(StringUtils.join(ids,","),"field2","not in"); - System.out.println(updateDelStatus); - } - - @Test - public void testAsync(){ - System.out.println(TimeUtil.getCurrentTimeString()); - OrganizationHrmSyncFromOtherSys async = new OrganizationHrmSyncFromOtherSys(); - async.SynTimingToOASubCompany(); - async.SynTimingToOADepartment(); - HashMap synResult = async.getSynResult(); - System.out.println("res => \n" + JSONObject.toJSONString(synResult)); - System.out.println(TimeUtil.getCurrentTimeString()); - } - - @Test - public void testExtra(){ - orgHrmAsyncService.asyncHrm(); - } - - public List> convertListToTree(List> list){ - Map> map = new HashMap<>(); - for (Map item : list) { - map.put((Integer) item.get("id"), item); - } - - // 构建树形结构 - List> tree = new ArrayList<>(); - for (Map item : list) { - int parentId = (Integer) item.get("parentid"); - if (parentId == -1) { - // 添加根节点 - tree.add(item); - } else { - // 添加子节点 - Map parent = map.get(parentId); - if (parent != null) { - List> childList = (List>) parent.get("childList"); - if (childList == null) { - childList = new ArrayList<>(); - parent.put("childList", childList); - } - childList.add(item); - } - } - } - return tree; - } - public int countNodes(OtherSysDepartment node) { - int count = 1; // 当前节点也算一条数据 - List childList = node.getChildList(); - if (CollectionUtils.isNotEmpty(childList)) { - for (OtherSysDepartment otherSysDepartment : childList) { - count += countNodes(otherSysDepartment); - } - } - return count; - } - - public int countNodes(Map node) { - int count = 1; // 当前节点也算一条数据 - List> childList = (List>) node.get("childList"); - if (CollectionUtils.isNotEmpty(childList)) { - for (Map map : childList) { - count += countNodes(map); - } - } - return count; - } - - - /** - *

解析部门or分部

- * @author xuanran.wang - * @dateTime 2023/4/10 12:13 - * @param list 树形集合 - * @param hrmDepartment 部门 - **/ - public void parseSubCompanyAndDepartment(List list, List hrmDepartment){ - for (OtherSysDepartment department : list) { - List childList = department.getChildList(); - if(CollectionUtils.isNotEmpty(childList)){ - parseSubCompanyAndDepartment(childList,hrmDepartment); - department.setChildList(null); - } - hrmDepartment.add(department); - } - } - - - /** - *

解析部门or分部

- * @author xuanran.wang - * @dateTime 2023/4/10 12:13 - * @param list 树形集合 - * @param n 层级 - * @param hrmSubCompany 分部 - * @param hrmDepartment 部门 - **/ - public void parseSubCompanyAndDepartment(List list, int n, int maxLevel,List hrmSubCompany, List hrmDepartment){ - n++; - for (OtherSysDepartment department : list) { - department.setLevel(n); - List childList = department.getChildList(); - String departmentId = department.getId() + ""; - if(CollectionUtils.isNotEmpty(childList)){ - List collect = department.getChildList().stream().map(item -> Util.null2DefaultStr(item.getId(), "")).collect(Collectors.toList()); - if(departmentWhiteList.contains(departmentId)){ - departmentWhiteList.addAll(collect); - }else if(subCompanyWhiteList.contains(departmentId)){ - subCompanyWhiteList.addAll(collect); - } - parseSubCompanyAndDepartment(childList, n, maxLevel, hrmSubCompany, hrmDepartment); - department.setChildList(null); - } - if(n > maxLevel || departmentWhiteList.contains(departmentId)){ - hrmDepartment.add(department); - }else { - hrmSubCompany.add(department); - } - - } - } - - @Test - public void testParseObj(){ - String json = "{\n" + - " \"code\":0,\n" + - " \"msg\":\"ok\",\n" + - " \"data\":\n" + - " {\n" + - " \"errcode\": 0,\n" + - " \"errmsg\": \"ok\",\n" + - " \"id\": \"1\",\n" + - " \"userid\": \"superAdmin\",\n" + - " \"name\": \"超级管理员\",\n" + - " \"mobile\":\"12345678911\",\n" + - " \"email\":\"123@321.com\",\n" + - " \"gender\":0,\n" + - " \"position\":\"position\",\n" + - " \"avatarImg\":\"avatarImg\",\n" + - " \"workPhone\":\"workPhone\",\n" + - " \"fixedTelephone\":\"fixedTelephone\",\n" + - " \"extName\":\"extName\",\n" + - " \"userType\":0,\n" + - " \"department\": [\n" + - " 1\n" + - " ],\n" + - " \"order\": [\n" + - " 0\n" + - " ],\n" + - " \"rank\":\"rank\"\n" + - " }\n" + - "}"; - Map response = JSONObject.parseObject(json, Map.class); - String obj = Util.null2DefaultStr(getObj("data.id", response),""); - System.out.println("obj => " + obj); - } - - public T getObj(String dataKey, Map response){ - String[] split = Util.null2DefaultStr(dataKey,"").split("\\."); - int len = split.length; - if(len == 0 || StringUtils.isBlank(dataKey)){ - return (T)response; - } - for (int i = 0; i < len - 1; i++) { - response = (Map) response.get(split[i]); - } - return (T) response.get(split[len - 1]); - } - - @Test - public void testMsg(){ - String html = "\n" + - "\n" + - "\n" + - "\tInvestment Calculator\n" + - "\t\n" + - "\n" + - "\n" + - "\t\n" + - "\t\t\n" + - "\t\t\t\n" + - "\t\t\n" + - "\t\t\n" + - "\t\t\t\n" + - "\t\t\t\n" + - "\t\t\t\n" + - "\t\t\t\n" + - "\t\t\t\n" + - "\t\t\t\n" + - "\t\t\t\n" + - "\t\t\t\n" + - "\t\t\t\n" + - "\t\t\t\n" + - "\t\t\t\n" + - "\t\t\t\n" + - "\t\t\t\n" + - "\t\t\t\n" + - "\t\t\n" + - "\t\t\n" + - "\t\t\t\n" + - "\t\t\t\n" + - "\t\t\t\n" + - "\t\t\t\n" + - "\t\t\t\n" + - "\t\t\t\n" + - "\t\t\t\n" + - "\t\t\t\n" + - "\t\t\t\n" + - "\t\t\t\n" + - "\t\t\t\n" + - "\t\t\t\n" + - "\t\t\t\n" + - "\t\t\n" + - "\t\t\n" + - " \t
投资试算(场外基金)
ABCDEFGHIJKLM
Cell A1Cell B1Cell C1Cell D1Cell E1Cell F1Cell G1Cell H1Cell I1Cell J1Cell K1Cell L1Cell M1
\n" + - " \n" + - "\n"; - EmailWorkRunnable.threadModeReminder("3055088966@qq.com,xuanran.wang@weaver.com.cn", "test11", html); - - } +// for (int i = 0; i < len - 1; i++) { +// response = (Map) response.get(split[i]); +// } +// return (T) response.get(split[len - 1]); +// } +// +// @Test +// public void testMap(){ +// List> list = orgHrmAsyncApiService.getDepartmentInfoMap(); +// // 将列表转换为以id为键的Map +// List> tree = convertListToTree(list); +// List> department = new ArrayList<>(); +// List> subCompany = new ArrayList<>(); +// orgHrmAsyncService.parseSubCompanyAndDepartmentMap(tree, 0, 3, department, subCompany); +// System.out.println(JSONObject.toJSONString(department)); +// System.out.println(JSONObject.toJSONString(subCompany)); +// } +// +// @Test +// public void testMapper(){ +//// System.setProperty("_isDebug", "false"); +//// System.out.println("分部执行结果 => " + JSONObject.toJSONString(orgHrmAsyncService.asyncOrgDep(0))); +//// System.out.println("部门执行结果 => " + JSONObject.toJSONString(orgHrmAsyncService.asyncOrgDep(1))); +//// List orgHrmAsyncConfigMains = orgHrmAsyncMapper.selectSubCompanyAsyncConfig(2); +//// System.out.println(JSONObject.toJSONString(orgHrmAsyncConfigMains)); +// ArrayList ids = new ArrayList<>(); +// for (int i = 0; i < 100; i++) { +// ids.add("'" + UUID.randomUUID().toString().replace("-","") + "'"); +// } +// String updateDelStatus = "update cus_fielddata set field0 = 1 where " + +// weaver.general.Util.getSubINClause(StringUtils.join(ids,","),"field2","not in"); +// System.out.println(updateDelStatus); +// } +// +// @Test +// public void testAsync(){ +// System.out.println(TimeUtil.getCurrentTimeString()); +// OrganizationHrmSyncFromOtherSys async = new OrganizationHrmSyncFromOtherSys(); +// async.SynTimingToOASubCompany(); +// async.SynTimingToOADepartment(); +// HashMap synResult = async.getSynResult(); +// System.out.println("res => \n" + JSONObject.toJSONString(synResult)); +// System.out.println(TimeUtil.getCurrentTimeString()); +// } +// +// @Test +// public void testExtra(){ +// orgHrmAsyncService.asyncHrm(); +// } +// +// public List> convertListToTree(List> list){ +// Map> map = new HashMap<>(); +// for (Map item : list) { +// map.put((Integer) item.get("id"), item); +// } +// +// // 构建树形结构 +// List> tree = new ArrayList<>(); +// for (Map item : list) { +// int parentId = (Integer) item.get("parentid"); +// if (parentId == -1) { +// // 添加根节点 +// tree.add(item); +// } else { +// // 添加子节点 +// Map parent = map.get(parentId); +// if (parent != null) { +// List> childList = (List>) parent.get("childList"); +// if (childList == null) { +// childList = new ArrayList<>(); +// parent.put("childList", childList); +// } +// childList.add(item); +// } +// } +// } +// return tree; +// } +// public int countNodes(OtherSysDepartment node) { +// int count = 1; // 当前节点也算一条数据 +// List childList = node.getChildList(); +// if (CollectionUtils.isNotEmpty(childList)) { +// for (OtherSysDepartment otherSysDepartment : childList) { +// count += countNodes(otherSysDepartment); +// } +// } +// return count; +// } +// +// public int countNodes(Map node) { +// int count = 1; // 当前节点也算一条数据 +// List> childList = (List>) node.get("childList"); +// if (CollectionUtils.isNotEmpty(childList)) { +// for (Map map : childList) { +// count += countNodes(map); +// } +// } +// return count; +// } +// +// +// /** +// *

解析部门or分部

+// * @author xuanran.wang +// * @dateTime 2023/4/10 12:13 +// * @param list 树形集合 +// * @param hrmDepartment 部门 +// **/ +// public void parseSubCompanyAndDepartment(List list, List hrmDepartment){ +// for (OtherSysDepartment department : list) { +// List childList = department.getChildList(); +// if(CollectionUtils.isNotEmpty(childList)){ +// parseSubCompanyAndDepartment(childList,hrmDepartment); +// department.setChildList(null); +// } +// hrmDepartment.add(department); +// } +// } +// +// +// /** +// *

解析部门or分部

+// * @author xuanran.wang +// * @dateTime 2023/4/10 12:13 +// * @param list 树形集合 +// * @param n 层级 +// * @param hrmSubCompany 分部 +// * @param hrmDepartment 部门 +// **/ +// public void parseSubCompanyAndDepartment(List list, int n, int maxLevel,List hrmSubCompany, List hrmDepartment){ +// n++; +// for (OtherSysDepartment department : list) { +// department.setLevel(n); +// List childList = department.getChildList(); +// String departmentId = department.getId() + ""; +// if(CollectionUtils.isNotEmpty(childList)){ +// List collect = department.getChildList().stream().map(item -> Util.null2DefaultStr(item.getId(), "")).collect(Collectors.toList()); +// if(departmentWhiteList.contains(departmentId)){ +// departmentWhiteList.addAll(collect); +// }else if(subCompanyWhiteList.contains(departmentId)){ +// subCompanyWhiteList.addAll(collect); +// } +// parseSubCompanyAndDepartment(childList, n, maxLevel, hrmSubCompany, hrmDepartment); +// department.setChildList(null); +// } +// if(n > maxLevel || departmentWhiteList.contains(departmentId)){ +// hrmDepartment.add(department); +// }else { +// hrmSubCompany.add(department); +// } +// +// } +// } +// +// @Test +// public void testParseObj(){ +// String json = "{\n" + +// " \"code\":0,\n" + +// " \"msg\":\"ok\",\n" + +// " \"data\":\n" + +// " {\n" + +// " \"errcode\": 0,\n" + +// " \"errmsg\": \"ok\",\n" + +// " \"id\": \"1\",\n" + +// " \"userid\": \"superAdmin\",\n" + +// " \"name\": \"超级管理员\",\n" + +// " \"mobile\":\"12345678911\",\n" + +// " \"email\":\"123@321.com\",\n" + +// " \"gender\":0,\n" + +// " \"position\":\"position\",\n" + +// " \"avatarImg\":\"avatarImg\",\n" + +// " \"workPhone\":\"workPhone\",\n" + +// " \"fixedTelephone\":\"fixedTelephone\",\n" + +// " \"extName\":\"extName\",\n" + +// " \"userType\":0,\n" + +// " \"department\": [\n" + +// " 1\n" + +// " ],\n" + +// " \"order\": [\n" + +// " 0\n" + +// " ],\n" + +// " \"rank\":\"rank\"\n" + +// " }\n" + +// "}"; +// Map response = JSONObject.parseObject(json, Map.class); +// String obj = Util.null2DefaultStr(getObj("data.id", response),""); +// System.out.println("obj => " + obj); +// } +// +// public T getObj(String dataKey, Map response){ +// String[] split = Util.null2DefaultStr(dataKey,"").split("\\."); +// int len = split.length; +// if(len == 0 || StringUtils.isBlank(dataKey)){ +// return (T)response; +// } +// for (int i = 0; i < len - 1; i++) { +// response = (Map) response.get(split[i]); +// } +// return (T) response.get(split[len - 1]); +// } +// +// @Test +// public void testMsg(){ +// String html = "\n" + +// "\n" + +// "\n" + +// "\tInvestment Calculator\n" + +// "\t\n" + +// "\n" + +// "\n" + +// "\t\n" + +// "\t\t\n" + +// "\t\t\t\n" + +// "\t\t\n" + +// "\t\t\n" + +// "\t\t\t\n" + +// "\t\t\t\n" + +// "\t\t\t\n" + +// "\t\t\t\n" + +// "\t\t\t\n" + +// "\t\t\t\n" + +// "\t\t\t\n" + +// "\t\t\t\n" + +// "\t\t\t\n" + +// "\t\t\t\n" + +// "\t\t\t\n" + +// "\t\t\t\n" + +// "\t\t\t\n" + +// "\t\t\t\n" + +// "\t\t\n" + +// "\t\t\n" + +// "\t\t\t\n" + +// "\t\t\t\n" + +// "\t\t\t\n" + +// "\t\t\t\n" + +// "\t\t\t\n" + +// "\t\t\t\n" + +// "\t\t\t\n" + +// "\t\t\t\n" + +// "\t\t\t\n" + +// "\t\t\t\n" + +// "\t\t\t\n" + +// "\t\t\t\n" + +// "\t\t\t\n" + +// "\t\t\n" + +// "\t\t\n" + +// " \t
投资试算(场外基金)
ABCDEFGHIJKLM
Cell A1Cell B1Cell C1Cell D1Cell E1Cell F1Cell G1Cell H1Cell I1Cell J1Cell K1Cell L1Cell M1
\n" + +// " \n" + +// "\n"; +// EmailWorkRunnable.threadModeReminder("3055088966@qq.com,xuanran.wang@weaver.com.cn", "test11", html); +// +// } + private final OtherSystemToOAMapper otherSystemToOAMapper = Util.getMapper(OtherSystemToOAMapper.class); @Test public void testG(){ -// String sql =" select case '$t{test1}' when '03' then '场外基金' when '04' then '基金赎回' else '测试下' end"; -// HashMap param = new HashMap<>(); -// param.put("test1","04"); -// String s = orgHrmAsyncMapper.selectCustomerSql(sql, param); -// System.out.println("s => " + s); - HashMap map = new HashMap<>(); - map.put("tiem", new Date()); - System.out.println("map => " + JSONObject.toJSONString(map)); + String oaOutKey = "111"; + String sql = "select id from hrmresource where " + Util.null2DefaultStr(ShBigDataUtil.getPropertiesValByKey("ssoOaCompareField"),"outkey") + " = #{outKey}"; + int id = otherSystemToOAMapper.selectUserIdByOutKey(sql, oaOutKey); + log.info("id => " + id); } } diff --git a/src/test/java/xuanran/wang/cssc/FileTest.java b/src/test/java/xuanran/wang/cssc/FileTest.java index 4d558da..9fce4db 100644 --- a/src/test/java/xuanran/wang/cssc/FileTest.java +++ b/src/test/java/xuanran/wang/cssc/FileTest.java @@ -1,6 +1,7 @@ package xuanran.wang.cssc; import aiyh.utils.excention.CustomerException; +import aiyh.utils.httpUtil.util.HttpUtils; import basetest.BaseTest; import com.alibaba.fastjson.JSONObject; import org.apache.commons.codec.digest.DigestUtils; @@ -201,4 +202,9 @@ public class FileTest extends BaseTest { } } + @Test + public void testB(){ + HttpUtils httpUtils = new HttpUtils(); + } + } diff --git a/src/test/java/xuanran/wang/eighty_five_degreec/SAPTest.java b/src/test/java/xuanran/wang/eighty_five_degreec/SAPTest.java index da47043..6461041 100644 --- a/src/test/java/xuanran/wang/eighty_five_degreec/SAPTest.java +++ b/src/test/java/xuanran/wang/eighty_five_degreec/SAPTest.java @@ -1,12 +1,24 @@ package xuanran.wang.eighty_five_degreec; +import aiyh.utils.annotation.PrintParamMark; +import aiyh.utils.annotation.RequiredMark; +import aiyh.utils.excention.CustomerException; import aiyh.utils.tool.cn.hutool.core.lang.UUID; import basetest.BaseTest; +import com.alibaba.excel.util.CollectionUtils; +import org.json.JSONException; +import org.json.JSONObject; +import org.json.XML; import org.junit.Test; +import weaver.general.GCONST; +import weaver.general.Util; import weaver.xuanran.wang.common.util.CusData2OA; import weaver.xuanran.wang.eighty_five_degreec.sap.entity.eneity.MainRequestConfig; +import weaver.xuanran.wang.eighty_five_degreec.sap.service.WorkflowToSapService; +import weaver.xuanran.wang.eighty_five_degreec.sap.service.impl.WorkflowToSapServiceImpl; import weaver.xuanran.wang.eighty_five_degreec.sap.util.ReadConfigUtil; +import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -20,15 +32,116 @@ import java.util.Map; */ public class SAPTest extends BaseTest { + private final WorkflowToSapService service = new WorkflowToSapServiceImpl(); + @Test public void testXml(){ - ReadConfigUtil configUtil = new ReadConfigUtil(); String uniqueCode = "test1"; - String tableName = "formtable_main_161"; + String billTable = "formtable_main_161"; String requestId = "419420"; - MainRequestConfig config = configUtil.getConfigByUniqueCode(uniqueCode, tableName); - String xml = configUtil.getXml(config, requestId, tableName); - System.out.println("xml => \n " + xml); + + String response = ""; + String url = ""; + String error = ""; + String xml = ""; + boolean success = true; + String modelId = "119"; + String successField = "soap-env:Envelope.soap-env:Body.n0:ZFI_OA_DOC_POSTINGResponse.ES_OA_OUTPUT.TYPE"; + String successVal = "N"; + String messageField = "soap-env:Envelope.soap-env:Body.n0:ZFI_OA_DOC_POSTINGResponse.ES_OA_OUTPUT.MESSAGE"; + + try { + MainRequestConfig config = service.getRequestConfig(uniqueCode, billTable); + url = config.getRequestUrl(); + xml = service.convertXml(config, requestId, billTable); +// response = service.sendToSap(config.getRequestUrl(), xml); + response = "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " clbx000003\n" + + " \n" + + " 1200\n" + + " 2023-05-01\n" + + " t?·???????é??è????¨\n" + + " E\n" + + " 1000 上不存在成本中心 1200180001/2023/05/01 。\n" + + " 2023-05-15\n" + + " 13:46:11\n" + + " \n" + + " \n" + + " \n" + + " clbx000002\n" + + " 1\n" + + " item1\n" + + " CN07010001\n" + + " \n" + + " \n" + + " 123.23\n" + + " CNY\n" + + " H\n" + + " string..............\n" + + " string..............\n" + + " string..............\n" + + " string..............\n" + + " string..............\n" + + " string..............\n" + + " \n" + + " \n" + + " clbx000003\n" + + " 2\n" + + " item2\n" + + " \n" + + " 90010601\n" + + " 1200180001\n" + + " 100.23\n" + + " CNY\n" + + " S\n" + + " string..............\n" + + " string..............\n" + + " string..............\n" + + " string..............\n" + + " string..............\n" + + " string..............\n" + + " \n" + + " \n" + + " clbx000003\n" + + " 3\n" + + " item3\n" + + " \n" + + " 90010602\n" + + " 1200180001\n" + + " 23.0\n" + + " CNY\n" + + " S\n" + + " string..............\n" + + " string..............\n" + + " string..............\n" + + " string..............\n" + + " string..............\n" + + " string..............\n" + + " \n" + + " \n" + + " \n" + + " \n" + + ""; + response = service.parseResponse(response, successField, successVal, messageField); + }catch (Exception e){ + log.error("流程数据推送SAP error : " + e.getMessage()); + error = e.getMessage(); + success = false; + } + try { + service.logToOA(modelId, url, requestId, xml, response, error); + }catch (Exception e){ + log.error("日志数据写入建模失败! " + e.getMessage()); + } + if(!success){ + throw new CustomerException("WorkflowToSap Action execute error : " + error); + } } @Test @@ -49,4 +162,149 @@ public class SAPTest extends BaseTest { List strings = CusData2OA.batchWriteToModel(modelId, sql, list); System.out.println("data => " + strings); } + + @Test + public void testResponse() throws JSONException { + String response = "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " clbx000003\n" + + " \n" + + " 1200\n" + + " 2023-05-01\n" + + " t?·???????é??è????¨\n" + + " E\n" + + " 1000 上不存在成本中心 1200180001/2023/05/01 。\n" + + " 2023-05-15\n" + + " 13:46:11\n" + + " \n" + + " \n" + + " \n" + + " clbx000002\n" + + " 1\n" + + " item1\n" + + " CN07010001\n" + + " \n" + + " \n" + + " 123.23\n" + + " CNY\n" + + " H\n" + + " string..............\n" + + " string..............\n" + + " string..............\n" + + " string..............\n" + + " string..............\n" + + " string..............\n" + + " \n" + + " \n" + + " clbx000003\n" + + " 2\n" + + " item2\n" + + " \n" + + " 90010601\n" + + " 1200180001\n" + + " 100.23\n" + + " CNY\n" + + " S\n" + + " string..............\n" + + " string..............\n" + + " string..............\n" + + " string..............\n" + + " string..............\n" + + " string..............\n" + + " \n" + + " \n" + + " clbx000003\n" + + " 3\n" + + " item3\n" + + " \n" + + " 90010602\n" + + " 1200180001\n" + + " 23.0\n" + + " CNY\n" + + " S\n" + + " string..............\n" + + " string..............\n" + + " string..............\n" + + " string..............\n" + + " string..............\n" + + " string..............\n" + + " \n" + + " \n" + + " \n" + + " \n" + + ""; + JSONObject xmlResponseObj = XML.toJSONObject(response); + log.info("接口响应 : \n" + xmlResponseObj); + Map responseMap = com.alibaba.fastjson.JSONObject.parseObject(xmlResponseObj.toString(), Map.class); + System.out.println("responseMap : " + com.alibaba.fastjson.JSONObject.toJSONString(responseMap)); +// code = Util.null2String(parseMap(responseMap, RESPONSE_CODE)); +// if(!successCode.equals(code)){ +// throw new RuntimeException("推送erp接口失败! " + Util.null2String(readConfigUtil.parseMap(responseMap, RESPONSE_DESCRIPTION))); +// } + } + + /** + *

解析响应数据

+ * @param responseMap 响应map + * @param responseField 需要从map中获取指定字段的标识 Response.Execution + * @return 响应数据 + */ + public String parseMap(Map responseMap, String responseField){ + String[] strArr = responseField.split("\\."); + int i = 0; + while (i < strArr.length - 1){ + Object o = responseMap.get(strArr[i]); + if(o instanceof Map){ + responseMap = (Map) o; + }else if(o instanceof List){ + List> list = (List>) o; + if(CollectionUtils.isEmpty(list)){ + return ""; + } + responseMap = list.get(0); + } + i++; + } + return Util.null2String(responseMap.get(strArr[strArr.length - 1])); + } + + + @Test + public void testB(){ + String path = "sap.sap.xml"; + System.out.println(parseConfigPath(path)); + } + + /** + *

解析请求xml模板位置

+ * wxr.memsic.test.xml = /wxr/memsic/test.xml + * @param configFilePath 模板文件路径 + * @return 解析后的文件路径 + */ + public String parseConfigPath(String configFilePath){ + StringBuilder filePath = new StringBuilder(GCONST.getSysFilePath()); + int beginIndex = configFilePath.indexOf("."); + int endIndex = configFilePath.lastIndexOf("."); + if(beginIndex == endIndex){ + filePath.append(configFilePath); + }else { + String[] pathArr = configFilePath.split("\\."); + for (int i = 0; i < pathArr.length - 2; i++) { + if(i != 0){ + filePath.append(File.separator); + } + filePath.append(pathArr[i]); + } + filePath.append(File.separator) + .append(pathArr[pathArr.length - 2]) + .append(".") + .append(pathArr[pathArr.length - 1]); + } + return filePath.toString(); + } } diff --git a/src/test/java/xuanran/wang/http_test/annotations/CusJsonMappingConfig.java b/src/test/java/xuanran/wang/http_test/annotations/CusJsonMappingConfig.java new file mode 100644 index 0000000..802d261 --- /dev/null +++ b/src/test/java/xuanran/wang/http_test/annotations/CusJsonMappingConfig.java @@ -0,0 +1,19 @@ +package xuanran.wang.http_test.annotations; + + +import java.lang.annotation.*; + +/** + *

+ * + * @author xuanran.wang + * @date 2023/5/25 14:42 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD}) +@Documented +public @interface CusJsonMappingConfig { + String configCode() default ""; + String tableName() default ""; + +} diff --git a/src/test/java/xuanran/wang/http_test/annotations/handle/CusReqAfterHandleRegister.java b/src/test/java/xuanran/wang/http_test/annotations/handle/CusReqAfterHandleRegister.java index 172c5af..b2f8379 100644 --- a/src/test/java/xuanran/wang/http_test/annotations/handle/CusReqAfterHandleRegister.java +++ b/src/test/java/xuanran/wang/http_test/annotations/handle/CusReqAfterHandleRegister.java @@ -15,5 +15,5 @@ import java.lang.annotation.*; @Target({ElementType.METHOD, ElementType.TYPE}) @Documented public @interface CusReqAfterHandleRegister { - Class afterHandle(); + Class[] afterHandle(); } diff --git a/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestPost.java b/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestPost.java index 57f6806..2926c4a 100644 --- a/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestPost.java +++ b/src/test/java/xuanran/wang/http_test/annotations/request_type/CusRequestPost.java @@ -23,4 +23,6 @@ public @interface CusRequestPost { @AliasFor(annotation = CusRequestType.class, attribute = "requestType") int requestType() default CusRequestClientConstant.POST; + + String configCode() default ""; } diff --git a/src/test/java/xuanran/wang/http_test/entity/CusRequestEntity.java b/src/test/java/xuanran/wang/http_test/entity/CusRequestEntity.java index 67c06e9..b629ff7 100644 --- a/src/test/java/xuanran/wang/http_test/entity/CusRequestEntity.java +++ b/src/test/java/xuanran/wang/http_test/entity/CusRequestEntity.java @@ -7,7 +7,9 @@ import lombok.Setter; import xuanran.wang.http_test.annotations.handle.CusResponseSuccessHandle; import xuanran.wang.http_test.handle.CusRequestAfterHandle; +import java.lang.reflect.Type; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.function.Consumer; @@ -31,8 +33,8 @@ public class CusRequestEntity{ private boolean async = false; private String host = ""; private int port; - private Class returnType; - private CusRequestAfterHandle cusRequestAfter; + private Type returnType; + private List cusRequestAfter; private CusResponseSuccessHandle responseSuccessHandle; private Map responseMap; } diff --git a/src/test/java/xuanran/wang/http_test/handle/CusHandleCenter.java b/src/test/java/xuanran/wang/http_test/handle/CusHandleCenter.java index 4bcafaa..4b46176 100644 --- a/src/test/java/xuanran/wang/http_test/handle/CusHandleCenter.java +++ b/src/test/java/xuanran/wang/http_test/handle/CusHandleCenter.java @@ -7,6 +7,7 @@ import aiyh.utils.tool.cn.hutool.core.annotation.AnnotationUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import org.apache.commons.collections.CollectionUtils; import org.apache.log4j.Logger; import xuanran.wang.http_test.annotations.handle.CusReqAfterHandleRegister; import xuanran.wang.http_test.annotations.handle.CusResponseSuccessHandle; @@ -85,16 +86,17 @@ public class CusHandleCenter{ } public Object requestAfterHandle(Method method, CusRequestEntity cusRequest, ResponeVo responseVo){ - if(cusRequest.getCusRequestAfter() == null){ - CusReqAfterHandleRegister cusReqAfterHandleRegister = method.getDeclaredAnnotation(CusReqAfterHandleRegister.class); - if(cusReqAfterHandleRegister != null){ - RequestUtil.setCusRequestAfter(cusReqAfterHandleRegister, cusRequest); - } + CusReqAfterHandleRegister cusReqAfterHandleRegister = method.getDeclaredAnnotation(CusReqAfterHandleRegister.class); + if(cusReqAfterHandleRegister != null){ + RequestUtil.setCusRequestAfter(cusReqAfterHandleRegister, cusRequest); + }else { + List tempList = new ArrayList<>(); + tempList.add(new CusDefaultRequestAfterHandle()); + cusRequest.setCusRequestAfter(tempList); } -// Type genericReturnType = method.getGenericReturnType(); - cusRequest.setReturnType(method.getReturnType()); + cusRequest.setReturnType(method.getGenericReturnType()); CusResponseSuccessHandle cusResponseSuccessHandle = method.getDeclaredAnnotation(CusResponseSuccessHandle.class); - if(cusResponseSuccessHandle != null && cusRequest.getResponseSuccessHandle() == null){ + if(cusResponseSuccessHandle != null && cusRequest.getResponseSuccessHandle() != null){ cusRequest.setResponseSuccessHandle(cusResponseSuccessHandle); } return requestAfterHandle(cusRequest, responseVo); @@ -113,11 +115,19 @@ public class CusHandleCenter{ responseVo.getEntityString())); throw new CustomerException(Util.logStr("can not fetch [{}]", url)); // } - CusRequestAfterHandle handle = cusRequest.getCusRequestAfter() == null ? new CusDefaultRequestAfterHandle() : cusRequest.getCusRequestAfter(); - cusRequest.setCusRequestAfter(handle); + cusRequest.setResponseMap(responseVo.getResponseMap()); + List cusRequestAfter = cusRequest.getCusRequestAfter(); + Object res = null; log.info(Util.logStr("cusRequest: {}", JSONObject.toJSONString(cusRequest))); - Object res = handle.parseResponse(cusRequest, responseVo); - handle.service(cusRequest, responseVo); + for (CusRequestAfterHandle handle : cusRequestAfter) { + if(RequestUtil.isMethodOverridden(handle.getClass(), CusDefaultRequestAfterHandle.class, "parseResponse")){ + res = handle.parseResponse(cusRequest, responseVo); + }else { + CusDefaultRequestAfterHandle defaultRequestAfterHandle = new CusDefaultRequestAfterHandle(); + res = defaultRequestAfterHandle.parseResponse(cusRequest, responseVo); + } + handle.service(cusRequest, responseVo); + } return res; } diff --git a/src/test/java/xuanran/wang/http_test/handle/CusRequestHandle.java b/src/test/java/xuanran/wang/http_test/handle/CusRequestHandle.java index 06901f6..3dbb11b 100644 --- a/src/test/java/xuanran/wang/http_test/handle/CusRequestHandle.java +++ b/src/test/java/xuanran/wang/http_test/handle/CusRequestHandle.java @@ -25,11 +25,10 @@ public abstract class CusRequestHandle { realRequestUrl.append(url); }else { realRequestUrl.append(host); - if(!host.endsWith(":")){ - realRequestUrl.append(":"); + if(port > 0 && !host.endsWith(":")){ + realRequestUrl.append(":").append(port); } - realRequestUrl.append(port); - if(!url.endsWith("/")){ + if(!host.endsWith("/") && !url.startsWith("/")){ realRequestUrl.append("/"); } realRequestUrl.append(url); diff --git a/src/test/java/xuanran/wang/http_test/handle/header_handle/RequestHeaderHandle.java b/src/test/java/xuanran/wang/http_test/handle/header_handle/RequestHeaderHandle.java index 7baeadb..03c5a04 100644 --- a/src/test/java/xuanran/wang/http_test/handle/header_handle/RequestHeaderHandle.java +++ b/src/test/java/xuanran/wang/http_test/handle/header_handle/RequestHeaderHandle.java @@ -72,10 +72,14 @@ public class RequestHeaderHandle implements CusRequestBeforeHandle { Parameter parameter = parameters[i]; CusRequestHeader requestHeader = parameter.getAnnotation(CusRequestHeader.class); if(requestHeader != null){ - String val = Util.null2DefaultStr(args[i], "").trim(); - String key = requestHeader.value().trim(); - if(StringUtils.isNotBlank(key) && StringUtils.isNotBlank(val)){ - headers.put(key, val); + if(Map.class.isAssignableFrom(parameter.getType())){ + headers.putAll((Map) args[i]); + }else { + String val = Util.null2DefaultStr(args[i], "").trim(); + String key = requestHeader.value().trim(); + if(StringUtils.isNotBlank(key) && StringUtils.isNotBlank(val)){ + headers.put(key, val); + } } } } diff --git a/src/test/java/xuanran/wang/http_test/handle/request_handle/CusDefaultRequestAfterHandle.java b/src/test/java/xuanran/wang/http_test/handle/request_handle/CusDefaultRequestAfterHandle.java index 500e3c0..833fff6 100644 --- a/src/test/java/xuanran/wang/http_test/handle/request_handle/CusDefaultRequestAfterHandle.java +++ b/src/test/java/xuanran/wang/http_test/handle/request_handle/CusDefaultRequestAfterHandle.java @@ -10,6 +10,7 @@ import xuanran.wang.http_test.constant.CusRequestClientConstant; import xuanran.wang.http_test.entity.CusRequestEntity; import xuanran.wang.http_test.handle.CusRequestAfterHandle; +import java.lang.reflect.Type; import java.util.Map; /** @@ -22,12 +23,11 @@ public class CusDefaultRequestAfterHandle implements CusRequestAfterHandle { @Override public Object parseResponse(CusRequestEntity cusRequest, ResponeVo responseVo) { - Class returnType = cusRequest.getReturnType(); - if(ResponeVo.class.isAssignableFrom(returnType)) { + Type returnType = cusRequest.getReturnType(); + if(ResponeVo.class.isAssignableFrom(returnType.getClass())) { return responseVo; } String json = responseVo.getEntityString(); - cusRequest.setResponseMap(responseVo.getResponseMap()); CusResponseSuccessHandle responseSuccessHandle = cusRequest.getResponseSuccessHandle(); if(responseSuccessHandle != null){ String successCondition = responseSuccessHandle.successCondition(); diff --git a/src/test/java/xuanran/wang/http_test/handle/request_handle/CusUrlHandle.java b/src/test/java/xuanran/wang/http_test/handle/request_handle/CusUrlHandle.java index d5c9edb..43e5032 100644 --- a/src/test/java/xuanran/wang/http_test/handle/request_handle/CusUrlHandle.java +++ b/src/test/java/xuanran/wang/http_test/handle/request_handle/CusUrlHandle.java @@ -8,6 +8,8 @@ import xuanran.wang.http_test.entity.CusRequestEntity; import xuanran.wang.http_test.handle.CusRequestBeforeHandle; import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; /** *

方法路径拼接处理

@@ -23,7 +25,6 @@ public class CusUrlHandle implements CusRequestBeforeHandle { throw new CustomerException("method not found CusRequestUrl!"); } cusRequest.setUrl(requestUrl.url()); - Class returnType = method.getReturnType(); - cusRequest.setReturnType(returnType); + cusRequest.setReturnType(method.getGenericReturnType()); } } diff --git a/src/test/java/xuanran/wang/http_test/proxy/RequestUtil.java b/src/test/java/xuanran/wang/http_test/proxy/RequestUtil.java index 169237b..f380e26 100644 --- a/src/test/java/xuanran/wang/http_test/proxy/RequestUtil.java +++ b/src/test/java/xuanran/wang/http_test/proxy/RequestUtil.java @@ -17,6 +17,8 @@ import java.lang.annotation.Annotation; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; +import java.util.ArrayList; +import java.util.List; /** @@ -29,12 +31,13 @@ public class RequestUtil implements InvocationHandler { private CusRequestAddress cusRequestAddress = null; private final Logger log = Util.getLogger(); private final CusHandleCenter handleCenter = new CusHandleCenter(); - private final CusRequestEntity cusRequest = new CusRequestEntity(); + private CusRequestEntity cusRequest; public T getRequestClient(Class clazz){ Annotation annotation = clazz.getDeclaredAnnotation(CusRequestClient.class); if(annotation == null){ throw new CustomerException(Util.logStr(clazz.getName() + " not found CusRequestClient annotation!")); } + cusRequest = new CusRequestEntity(); // 请求后处理 CusReqAfterHandleRegister cusReqAfterHandleRegister = clazz.getDeclaredAnnotation(CusReqAfterHandleRegister.class); if(cusReqAfterHandleRegister != null){ @@ -62,7 +65,6 @@ public class RequestUtil implements InvocationHandler { cusRequest.setPort(port); } handleCenter.requestBeforeHandle(cusRequest, method, args); - log.info("requestHandle : \n" + JSONObject.toJSONString(cusRequest)); ResponeVo responeVo = handleCenter.requestHandle(cusRequest, method); return handleCenter.requestAfterHandle(method, cusRequest, responeVo); } @@ -70,16 +72,33 @@ public class RequestUtil implements InvocationHandler { public static void setCusRequestAfter(CusReqAfterHandleRegister cusReqAfterHandleRegister, CusRequestEntity cusRequest){ if(cusReqAfterHandleRegister != null){ - Class clazz = cusReqAfterHandleRegister.afterHandle(); - if (CusRequestAfterHandle.class.isAssignableFrom(clazz)) { - try { - Object cusRequestAfter = clazz.newInstance(); - cusRequest.setCusRequestAfter((CusRequestAfterHandle) cusRequestAfter); - }catch (Exception e){ - throw new CustomerException(Util.logStr("class : {}, newInstance error!", e.getMessage())); + Class[] clazz = cusReqAfterHandleRegister.afterHandle(); + List requestAfter = cusRequest.getCusRequestAfter(); + if(requestAfter == null){ + requestAfter = new ArrayList<>(); + } + cusRequest.setCusRequestAfter(requestAfter); + for (Class aClass : clazz) { + if (CusRequestAfterHandle.class.isAssignableFrom(aClass)) { + try { + CusRequestAfterHandle cusRequestAfter = (CusRequestAfterHandle) aClass.newInstance(); + requestAfter.add(cusRequestAfter); + }catch (Exception e){ + throw new CustomerException(Util.logStr("class : {}, newInstance error!", e.getMessage())); + } } } } } + public static boolean isMethodOverridden(Class subclass, Class superclass, String methodName) { + try { + Method method = subclass.getDeclaredMethod(methodName); + Method superMethod = superclass.getDeclaredMethod(methodName); + return !method.equals(superMethod); + } catch (NoSuchMethodException e) { + return false; + } + } + } diff --git a/src/test/java/xuanran/wang/http_test/service/EcTestService.java b/src/test/java/xuanran/wang/http_test/service/EcTestService.java new file mode 100644 index 0000000..855ed46 --- /dev/null +++ b/src/test/java/xuanran/wang/http_test/service/EcTestService.java @@ -0,0 +1,27 @@ +package xuanran.wang.http_test.service; + +import xuanran.wang.http_test.annotations.CusRequestClient; +import xuanran.wang.http_test.annotations.header.CusRequestHeader; +import xuanran.wang.http_test.annotations.request_type.CusRequestPost; + +import javax.ws.rs.core.MediaType; +import java.util.Map; + +/** + *

+ * + * @author xuanran.wang + * @date 2023/5/24 14:53 + */ +@CusRequestClient(host = "https://ecology.yeyaguitu.cn") +public interface EcTestService { + + @CusRequestPost(url = "/api/ec/dev/auth/regist") + @CusRequestHeader(cusHeaders = {"appid:JYZ", "loginid:sysadmin","Content-type:"+ MediaType.APPLICATION_JSON}) + Map register(); + + @CusRequestPost(url = "/api/ec/dev/auth/regist") + @CusRequestHeader(cusHeaders = {"Content-type:"+ MediaType.APPLICATION_JSON}) + Map register(@CusRequestHeader("appid") String appId, + @CusRequestHeader Map headers); +} diff --git a/src/test/java/xuanran/wang/http_test/service/TestService.java b/src/test/java/xuanran/wang/http_test/service/TestService.java index e74ea59..30dc0c4 100644 --- a/src/test/java/xuanran/wang/http_test/service/TestService.java +++ b/src/test/java/xuanran/wang/http_test/service/TestService.java @@ -2,12 +2,15 @@ package xuanran.wang.http_test.service; import xuanran.wang.http_test.annotations.*; import xuanran.wang.http_test.annotations.body.CusRequestBody; +import xuanran.wang.http_test.annotations.handle.CusReqAfterHandleRegister; import xuanran.wang.http_test.annotations.handle.CusResponseSuccessHandle; import xuanran.wang.http_test.annotations.header.CusRequestHeader; import xuanran.wang.http_test.annotations.request_path.CusPathQuery; import xuanran.wang.http_test.annotations.request_type.CusRequestGet; import xuanran.wang.http_test.annotations.request_type.CusRequestPost; import xuanran.wang.http_test.constant.CusRequestClientConstant; +import xuanran.wang.http_test.test.Student; +import xuanran.wang.http_test.test.TestRequestAfterHandle; import java.util.List; import java.util.Map; @@ -19,7 +22,6 @@ import java.util.Map; * @date 2023/3/10 12:39 */ @CusRequestClient(host = "http://114.115.168.220", port = 8191) -//@CusReqAfterHandleRegister(afterHandle = TestRequestAfterHandle.class) public interface TestService { @CusRequestGet(url = "educate-plat/api/v1/class/getClassList") @@ -30,8 +32,9 @@ public interface TestService { errorMsg = "msg", data = "data" ) - Map getStu(Map path, - @CusRequestBody Map body, - @CusRequestHeader("hsjhdsad") String test, - @CusPathQuery("test") String test1); + @CusReqAfterHandleRegister(afterHandle = {TestRequestAfterHandle.class}) + List getStu(Map path, + @CusRequestBody Map body, + @CusRequestHeader("hsjhdsad") String test, + @CusPathQuery("test") String test1); } diff --git a/src/test/java/xuanran/wang/http_test/test/RequestTest.java b/src/test/java/xuanran/wang/http_test/test/RequestTest.java index 7b3dccf..29d2937 100644 --- a/src/test/java/xuanran/wang/http_test/test/RequestTest.java +++ b/src/test/java/xuanran/wang/http_test/test/RequestTest.java @@ -2,6 +2,7 @@ package xuanran.wang.http_test.test; import basetest.BaseTest; import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; import com.api.doc.migrate.util.FtpUtil; import com.jcraft.jsch.ChannelSftp; import org.junit.Test; @@ -9,6 +10,7 @@ import weaver.backup.utils.ZipUtil; import xuanran.wang.http_test.entity.CusHandleEntity; import xuanran.wang.http_test.handle.util.HandleUtil; import xuanran.wang.http_test.proxy.CusUtil; +import xuanran.wang.http_test.service.EcTestService; import xuanran.wang.http_test.service.TestService; import java.util.*; @@ -23,6 +25,7 @@ import java.util.stream.Collectors; public class RequestTest extends BaseTest { private TestService requestClient = CusUtil.getRequestClient(TestService.class); + private EcTestService ecTestService = CusUtil.getRequestClient(EcTestService.class); @Test public void test(){ HashMap map = new HashMap<>(); @@ -36,9 +39,11 @@ public class RequestTest extends BaseTest { path.put("e","5"); path.put("f","6"); - Map stu = requestClient.getStu(map, body, "a", "test1111"); - log.info("stu : \n" + JSONObject.toJSONString(stu)); - +// List stu = requestClient.getStu(map, body, "a", "test1111"); + List stu = requestClient.getStu(map, body, "a", "test1111"); + for (Student student : stu) { + System.out.println("stu => " + student); + } // String json = "{\"xuanran.wang.http_test.requestBeforeHandle.path_handle\":[{\"handleClass\":\"xuanran.wang.http_test.requestBeforeHandle.path_handle.CusPathParseHandle\",\"order\":0,\"packageName\":\"xuanran.wang.http_test.requestBeforeHandle.path_handle\"},{\"handleClass\":\"xuanran.wang.http_test.requestBeforeHandle.path_handle.TestHandle\",\"order\":99,\"packageName\":\"xuanran.wang.http_test.requestBeforeHandle.path_handle\"}],\"xuanran.wang.http_test.requestBeforeHandle.header_handle\":[{\"handleClass\":\"xuanran.wang.http_test.requestBeforeHandle.header_handle.RequestHeaderHandle\",\"order\":0,\"packageName\":\"xuanran.wang.http_test.requestBeforeHandle.header_handle\"}]}"; // System.out.println(JSONObject.parseObject(JSONObject.toJSONString(json), Map.class)); // String stu1 = requestClient.getStu(body); @@ -61,4 +66,16 @@ public class RequestTest extends BaseTest { } } + + @Test + public void testB(){ + Map register = ecTestService.register(); + System.out.printf("register : " + JSONObject.toJSONString(register)); + + HashMap header = new HashMap<>(); + header.put("loginid","123"); + header.put("dadsada","sasas"); + Map register1 = ecTestService.register("JYZ1", header); + System.out.printf("register1 : " + JSONObject.toJSONString(register1)); + } } diff --git a/src/test/java/xuanran/wang/http_test/test/Student.java b/src/test/java/xuanran/wang/http_test/test/Student.java new file mode 100644 index 0000000..ef0a148 --- /dev/null +++ b/src/test/java/xuanran/wang/http_test/test/Student.java @@ -0,0 +1,49 @@ +package xuanran.wang.http_test.test; + +/** + *

+ * + * @author xuanran.wang + * @date 2023/5/23 11:40 + */ +public class Student { + private String teacherId; + private int belongYear; + private String classNo; + private String className; + private String id; + public void setTeacherId(String teacherId) { + this.teacherId = teacherId; + } + public String getTeacherId() { + return teacherId; + } + + public void setBelongYear(int belongYear) { + this.belongYear = belongYear; + } + public int getBelongYear() { + return belongYear; + } + + public void setClassNo(String classNo) { + this.classNo = classNo; + } + public String getClassNo() { + return classNo; + } + + public void setClassName(String className) { + this.className = className; + } + public String getClassName() { + return className; + } + + public void setId(String id) { + this.id = id; + } + public String getId() { + return id; + } +}