diff --git a/src/main/java/aiyh/utils/Util.java b/src/main/java/aiyh/utils/Util.java index b1ff738..16c18ea 100644 --- a/src/main/java/aiyh/utils/Util.java +++ b/src/main/java/aiyh/utils/Util.java @@ -4067,6 +4067,31 @@ public class Util extends weaver.general.Util { } } } + + /** + *

将线程错误信息输出

+ * @author xuanran.wang + * @dateTime 2023/7/17 16:43 + * @param e 线程异常对象 + **/ + public static void logErrorStr(Throwable e){ + logErrorStr(e, null); + } + + /** + *

将线程错误信息输出

+ * @author xuanran.wang + * @dateTime 2023/7/17 16:43 + * @param e 线程异常对象 + * @param logger 日志对象 + **/ + public static void logErrorStr(Throwable e, Logger logger){ + if(null != logger){ + logger.error(getErrString(e)); + }else { + Util.getLogger().error(getErrString(e)); + } + } } diff --git a/src/main/java/aiyh/utils/response_deal/ResponseMappingDeal.java b/src/main/java/aiyh/utils/response_deal/ResponseMappingDeal.java index ed63911..d4d6ea0 100644 --- a/src/main/java/aiyh/utils/response_deal/ResponseMappingDeal.java +++ b/src/main/java/aiyh/utils/response_deal/ResponseMappingDeal.java @@ -57,60 +57,60 @@ public class ResponseMappingDeal { } /** - *

响应同步 note by youhong.ai

+ *

响应同步

* * @param uniqueCode 唯一表示 * @param responseMap 响应map */ public void doResponseSync(String uniqueCode, Map responseMap) { - // note by youhong.ai 查询配置表 + // 查询配置表 List responseConfigList = configMapper.queryResponseConfigByUnique(uniqueCode); logger.info(String.format("%s 相关响应配置信息==> %s", uniqueCode, JSON.toJSONString(responseConfigList))); - // note by youhong.ai 自定义校验 + // 自定义校验 ResponseUtil.parameterJudgment(responseConfigList, "response config is empty please check!!! "); Map tableNameConfig; try { - // note by youhong.ai 对查询到的多个配置进行整合,以同步表表名作为key 配置作为value + // 对查询到的多个配置进行整合,以同步表表名作为key 配置作为value tableNameConfig = responseConfigList.stream().collect(Collectors.toMap(ResponseConfig::getModelTableName, v -> v)); } catch (Exception e) { logger.error("response config error please check!!! " + Util.getErrString(e)); throw new ResponseException("response config error please check!!! "); } ResponseUtil.parameterJudgment(responseMap, "接口返回都为空 你处理个勾"); - // note by youhong.ai 循环同步每一个表 + // 循环同步每一个表 tableNameConfig.forEach((key, value) -> doResponseSync(value, responseMap)); } /** - *

note by youhong.ai 同步数据

+ *

同步数据

* * @param responseConfig 配置表 * @param responseMap 响应结果 */ public void doResponseSync(ResponseConfig responseConfig, Map responseMap) { - // note by youhong.ai 获取别名配置明细数据 + // 获取别名配置明细数据 List responseConfigAliasList = responseConfig.getResponseConfigAliasList(); ResponseUtil.parameterJudgment(responseConfigAliasList, "responseConfigAliasList config is empty please check!!!"); - // note by youhong.ai 获取转换值配置明细 + // 获取转换值配置明细 List valueChangeList = responseConfig.getValueChangeList(); ResponseUtil.parameterJudgment(valueChangeList, "valueChangeList config is empty please check!!!"); // 数据信息按是否主表分组 Map> aliasMap = responseConfigAliasList.stream().collect(Collectors.groupingBy(ResponseConfigAlias::getTableType)); - // note by youhong.ai 获取主表别名配置数据 + // 获取主表别名配置数据 List mainConfigList = aliasMap.get(ResponseConfigConstant.MAIN_TABLE); - // note by youhong.ai 按照表类型分组 + // 按照表类型分组 Map> mainOrDetail = valueChangeList.stream().collect(Collectors.groupingBy(ResponseConfigValueChange::getTableType)); - // note by youhong.ai 获取主表值配置 + // 获取主表值配置 List mainValueChangeList = mainOrDetail.get(ResponseConfigConstant.MAIN_TABLE); TableDefinition tableDefinition; - // note by youhong.ai 如果有主表配置 + // 如果有主表配置 if (ResponseUtil.parameterIsNotNull(mainConfigList)) { - // note by youhong.ai 解析json为表描述对象 + // 解析json为表描述对象 tableDefinition = this.parsingJsonToTable(responseConfig.getModelTableName(), responseConfig, mainConfigList, mainValueChangeList, responseMap, true, this::detailTableDeal); } else { - // note by youhong.ai 如果没有主表配置,纯配置明细同步 + // 如果没有主表配置,纯配置明细同步 Map detailTable = new HashMap<>(); - // note by youhong.ai 处理明细表 + // 处理明细表 this.detailTableDeal(responseConfig, responseMap, detailTable); tableDefinition = TableDefinition.builder() .detailTableMap(detailTable) @@ -123,9 +123,10 @@ public class ResponseMappingDeal { tableDefinition.setDefaultState(stateClassKey); tableDefinition.dataProcess(); } + /** - *

note by youhon.ai 解析json为表描述对象

+ *

note by youhong.ai 解析json为表描述对象

* * @param tableName 表名 * @param responseConfig 响应配置 @@ -144,9 +145,9 @@ public class ResponseMappingDeal { Map responseMap, boolean isMainTable, Bi3Function, Map, String> detailCallBack) { - // note by youhong.ai 过滤出主表别名主数据配置 + // 过滤出主表别名主数据配置 List mainAliasList = responseConfigAliasList.stream().filter(item -> item.getMainData() == ResponseConfigConstant.MAIN_DATA).collect(Collectors.toList()); - // note by youhong.ai 主表别名有且只能有一个主数据 + // 主表别名有且只能有一个主数据 if (responseConfigAliasList.size() > 1) { throw new ResponseException("The master data cannot be multiple please check !!! "); } @@ -158,13 +159,11 @@ public class ResponseMappingDeal { responseConfigAliasList.forEach(item -> { String dataPath = item.getDataPath(); String dataAlias = item.getDataAlias(); - // node by youhong.ai 通过路径获取对应的值 - Object parsingData = Util.getValueByKeyStr(dataPath, responseMap); - // node by youhong.ai 别名->值 + // 通过路径获取对应的值 + Object parsingData = "rootNode".equalsIgnoreCase(dataPath) ? responseMap : Util.getValueByKeyStr(dataPath, responseMap); + // 别名->值 aliasData.put(dataAlias, parsingData); }); - // Map> mainOrDetail = valueChangeList.stream().collect(Collectors.groupingBy(ResponseConfigValueChange::getTableType)); - // List mainValueChangeList = mainOrDetail.get(ResponseConfigConstant.MAIN_TABLE); ResponseUtil.parameterJudgment(valueChangeList, "main table valueChangeList config is empty please check!!!"); // 获取主表的主数据信息 ResponseConfigAlias mainDataAlias = mainAliasList.get(0); @@ -180,7 +179,7 @@ public class ResponseMappingDeal { String dataPath = mainDataAlias.getDataPath(); List rowDefinitionList = new ArrayList<>(); Map detailTable = isMainTable ? new HashMap<>() : null; - // note by youhong.ai 如果是json数组 + // 如果是json数组 if (mainDataAlias.getDataType() == ResponseConfigConstant.JSON_ARRAY) { List> mainList = (List>) Util.getValueByKeyStr(dataPath, aliasData); for (Map mainItem : mainList) { diff --git a/src/main/java/aiyh/utils/response_deal/mapper/ConfigMapper.java b/src/main/java/aiyh/utils/response_deal/mapper/ConfigMapper.java index 927d986..c7e9bc4 100644 --- a/src/main/java/aiyh/utils/response_deal/mapper/ConfigMapper.java +++ b/src/main/java/aiyh/utils/response_deal/mapper/ConfigMapper.java @@ -45,7 +45,7 @@ public interface ConfigMapper { * @param mainId 主数据id * @return 响应数据别名配置信息列表 */ - @Select("select * from uf_response_config_dt1 where mainid = #{mainId}") + @Select("select * from uf_response_config_dt1 where mainid = #{mainId} and enable = 0") @CollectionMethod(1) List queryResponseConfigAlias(@ParamMapper("mainId")int mainId); @@ -54,7 +54,7 @@ public interface ConfigMapper { * @param mainId 主数据id * @return 响应数据转换配置信息列表 */ - @Select("select * from uf_response_config_dt3 where mainid = #{mainId}") + @Select("select * from uf_response_config_dt3 where mainid = #{mainId} and enable = 0") @CollectionMethod(2) List queryResponseConfigValueChange(@ParamMapper("mainId")int mainId); diff --git a/src/main/java/aiyh/utils/response_deal/state/InsertSate.java b/src/main/java/aiyh/utils/response_deal/state/InsertSate.java index 5d8aba1..8d2ceb5 100644 --- a/src/main/java/aiyh/utils/response_deal/state/InsertSate.java +++ b/src/main/java/aiyh/utils/response_deal/state/InsertSate.java @@ -21,6 +21,7 @@ import java.util.stream.Collectors; * @Description

**/ public class InsertSate extends State{ + @Override public void handle() { int tableType = this.context.getTableType(); 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 index 854970b..5fc7b30 100644 --- 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 @@ -15,6 +15,7 @@ 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.HashMap; import java.util.List; import java.util.Map; @@ -45,7 +46,11 @@ public class ReportController { log.info("into getReportData success params ==> "+param); User loginUser = HrmUserVarify.getUser(request, response); List> reportData = reportService.queryReportData(param, loginUser); - return ApiResult.success(reportData); + Map titleData = reportService.queryTitleData(param); + Map res = new HashMap<>(); + res.put("titleData",titleData); + res.put("reportData",reportData); + return ApiResult.success(res); }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 index b8a308c..6a136ae 100644 --- 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 @@ -37,4 +37,46 @@ public interface ReportMapper { @CaseConversion(value = false) List> queryReportData2(@ParamMapper("param") Map param,@ParamMapper("uid") int uid); + @Select("select id,hbwb,ysclwb,gzrywb,gzclwb,ldrwb,sfsjyc,ddsjyc,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(concat(wb, ',', zw), '-') 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> queryReportData3(@ParamMapper("param") Map param,@ParamMapper("uid") int uid); + + /** + * 查询限行信息 + * @param param 查询参数 + * @return 今日限行信息 + */ + @Select("select xxhm from uf_bjxxjmbd_dt1 where xxrq = #{currentDate}") + @CaseConversion(value = false) + List queryTrafficControl(@ParamMapper("param") Map param); + + /** + * 查询当日值班人员 + * @param param 查询参数 + * @return 当日值班人员 + */ + @Select("select hrm.lastname,ry.zblx,ry.zbry " + + " from uf_ryzbjlbzjb_dt1 ry " + + " inner join hrmresource hrm on ry.zbry = hrm.id" + + " where #{currentDate} >= ry.zbksrq and #{currentDate} <= ry.zbjsrq }") + @CaseConversion(value = false) + List> queryDutyData(@ParamMapper("param") Map param); + + /** + * 查询车队排班信息 + * @param param 查询参数 + * @return 值班人员 + */ + @Select("select hrm.lastname " + + " from uf_jsyzbap_dt1 jsy " + + " inner join hrmresource hrm on jsy.zbry = hrm.id" + + " where jsy.zblx = #{dutyType} and #{currentDate} >= jsy.zbksrq and #{currentDate} <= jsy.zbjsrq }") + @CaseConversion(value = false) + List queryCarSchedule(@ParamMapper("param") Map param); + } 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 index 4b70644..a18b245 100644 --- 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 @@ -5,8 +5,11 @@ import com.api.bokang.xiao.sh_bigdata.mapper.ReportMapper; import weaver.general.TimeUtil; import weaver.hrm.User; +import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; /** * @ClassName ReviewService @@ -25,23 +28,88 @@ public class ReportService { * @return 前五条流程数据 */ public List> queryReportData(Map param, User user){ + param.put("whereSql",getWhereSql(param)); + return reportMapper.queryReportData3(param,user.getUID()); + } + + private String getWhereSql(Map param){ 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 project = Util.null2String(param.get("project")); + //开始日期 + String beginDate = Util.null2String(param.get("beginDate")); + //结束日期 + String endData = Util.null2String(param.get("endData")); + //航班车次 + String flightAndTrain = Util.null2String(param.get("flightAndTrain")); String whereSql = ""; - if(!"".equals(currentDate)){ - whereSql += " and dlsk = #{param.currentDate} "; + if(!"".equals(beginDate) && !"".equals(endData)){ + whereSql += " and (dlsk between #{param.beginDate} and #{param.endData} )"; }else { param.put("today", TimeUtil.getCurrentDateString()); whereSql += " and dlsk >= #{param.today} "; } if(!"".equals(registrationPeople)){ - whereSql += " and djr = #{param.registrationPeople} "; + whereSql += " and dyjbr = #{param.registrationPeople} "; + } + if(!"".equals(flightAndTrain)){ + whereSql += " and hbwb = #{param.flightAndTrain} "; + } + if(!"".equals(project)){ + whereSql += " and exits (select 1 from uf_zwfwdjjmb_dt1 where mainid = main.id and ysdx = #{param.project}) "; } whereSql = whereSql.replaceFirst(" and "," where "); - param.put("whereSql",whereSql); - return reportMapper.queryReportData2(param,user.getUID()); + return whereSql; + } + + public Map queryTitleData(Map param){ + Map titleData = new HashMap<>(); + //查询限行信息 + List trafficControlList = reportMapper.queryTrafficControl(param); + judgeEmptyAndPut(trafficControlList,titleData,"trafficControl"); + //查询值班信息 + List> dutyData = reportMapper.queryDutyData(param); + if(Objects.nonNull(dutyData) && !dutyData.isEmpty()) { + Map>> dutyTypeMap = dutyData.stream().collect(Collectors.groupingBy(item -> Util.null2String(item.get("zblx")))); + //带班值班员 + filterAndPut(dutyTypeMap.get("0"),titleData,"headWatch"); + //机关值班员 + filterAndPut(dutyTypeMap.get("1"),titleData,"organWatch"); + //今日迎送人员 + filterAndPut(dutyTypeMap.get("2"),titleData,"todayWelcome"); + } + titleData.put("dutyData",dutyData); + //查询当日送报人员 + param.put("dutyType",1); + List strings = reportMapper.queryCarSchedule(param); + judgeEmptyAndPut(strings,titleData,"currentNewsboy"); + //查询驾驶值班员 + param.put("dutyType",0); + List pilots = reportMapper.queryCarSchedule(param); + judgeEmptyAndPut(pilots,titleData,"pilot"); + //查询明日送报人员 + param.put("dutyType",1); + String currentDate = Util.null2String(param.get("currentDate")); + currentDate = TimeUtil.dateAdd(currentDate,-1); + param.put("currentDate",currentDate); + List tomorrowNewsboys = reportMapper.queryCarSchedule(param); + judgeEmptyAndPut(tomorrowNewsboys,titleData,"currentNewsboy"); + return titleData; + } + + private void filterAndPut(List> data,Map map,String key){ + if(Objects.nonNull(data) && !data.isEmpty()){ + List lastname = data.stream().map(item -> Util.null2String(item.get("lastname"))).collect(Collectors.toList()); + judgeEmptyAndPut(lastname,map,key); + } + } + + private void judgeEmptyAndPut(List list,Map map,String key){ + if(Objects.nonNull(list) && !list.isEmpty()) { + map.put(key,String.join(",", list)); + } } } 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 index 9a03898..d5f83a2 100644 --- a/src/main/java/com/api/bokang/xiao/zhenn/controller/BankController.java +++ b/src/main/java/com/api/bokang/xiao/zhenn/controller/BankController.java @@ -104,4 +104,20 @@ public class BankController { } } + @GET + @Path("/getBudge") + @Produces(MediaType.APPLICATION_JSON) + public String getBudge(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try{ + log.info("====== into getBudge success ======="); + String budgeDetailType = request.getParameter("budgeDetailType"); + log.info("budgeDetailType:"+budgeDetailType); + String budgeType = bankService.getBudgeType(budgeDetailType); + return ApiResult.success(budgeType); + }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 index 8bbed02..bbea146 100644 --- a/src/main/java/com/api/bokang/xiao/zhenn/mapper/BankMapper.java +++ b/src/main/java/com/api/bokang/xiao/zhenn/mapper/BankMapper.java @@ -1,8 +1,10 @@ package com.api.bokang.xiao.zhenn.mapper; +import aiyh.utils.annotation.recordset.ParamMapper; import aiyh.utils.annotation.recordset.Select; import aiyh.utils.annotation.recordset.SqlMapper; +import java.sql.Struct; import java.util.List; import java.util.Map; @@ -145,4 +147,7 @@ public interface BankMapper { "WHERE wb.currentnodetype = 3 " + " AND wb.lastoperatedate BETWEEN #{beginDate} AND #{endDate} ") List> queryOaOtherDetailList(Map param); + + @Select("select string_agg(budgettypeid,',') from BudgetUserInfoView where keyId in ($split{budgeDetailType})") + String queryBudgeType(@ParamMapper("budgeDetailType")String budgeDetailType); } 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 index b9835a9..dfd4da3 100644 --- a/src/main/java/com/api/bokang/xiao/zhenn/service/BankService.java +++ b/src/main/java/com/api/bokang/xiao/zhenn/service/BankService.java @@ -254,4 +254,8 @@ public class BankService { log.info("excel List ==>"+objects.size()); EasyExcel.write(outputStream, aClass).sheet("Sheet1").doWrite(objects); } + + public String getBudgeType(String budgeDetailType) { + return bankMapper.queryBudgeType(budgeDetailType); + } } diff --git a/src/main/java/com/api/bokang/xiao/zscq/controller/ReserveSelectController.java b/src/main/java/com/api/bokang/xiao/zscq/controller/ReserveSelectController.java index ee75f63..acb15d7 100644 --- a/src/main/java/com/api/bokang/xiao/zscq/controller/ReserveSelectController.java +++ b/src/main/java/com/api/bokang/xiao/zscq/controller/ReserveSelectController.java @@ -8,6 +8,7 @@ import io.swagger.v3.oas.annotations.parameters.RequestBody; import org.apache.log4j.Logger; import weaver.bokang.xiao.zscq.store.TableNameStore; import weaver.file.ImageFileManager; +import weaver.general.GCONST; import weaver.hrm.HrmUserVarify; import weaver.hrm.User; import weaver.xiao.commons.config.entity.WeaverFile; @@ -19,6 +20,10 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.StreamingOutput; +import java.io.File; +import java.io.FileOutputStream; +import java.io.OutputStream; +import java.nio.file.Files; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -67,13 +72,15 @@ public class ReserveSelectController { @Produces(MediaType.APPLICATION_OCTET_STREAM) public Response downloadBatchFiles(@QueryParam("datePicker") String datePicker, @QueryParam("checkResult") String checkResult, - @QueryParam("checkResultShow") String checkResultShow) { + @QueryParam("checkResultShow") String checkResultShow, + @QueryParam("region") String region) { log.info("====== into downloadBatchFiles success ======="); - log.info(String.format("====== datePicker:[%s] checkResult:[%s] checkResultShow:[%s] =======",datePicker,checkResult,checkResultShow)); + log.info(String.format("====== datePicker:[%s] checkResult:[%s] checkResultShow:[%s] region:[%s] =======",datePicker,checkResult,checkResultShow,region)); Map param = new HashMap<>(8); param.put("datePicker",datePicker); param.put("checkResult",checkResult); param.put("checkResultShow",checkResultShow); + param.put("region",region); String zipFileName = reserveService.getFileName(param) + ".zip"; StreamingOutput streamingOutput = outputStream -> { try { @@ -88,6 +95,33 @@ public class ReserveSelectController { .build(); } + @GET + @Path("/batchDownloadTemp") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public String batchDownloadTemp(@QueryParam("datePicker") String datePicker, + @QueryParam("checkResult") String checkResult, + @QueryParam("checkResultShow") String checkResultShow, + @QueryParam("region") String region) { + log.info("====== into batchDownloadTemp success ======="); + log.info(String.format("====== datePicker:[%s] checkResult:[%s] checkResultShow:[%s] region:[%s] =======",datePicker,checkResult,checkResultShow,region)); + Map param = new HashMap<>(8); + param.put("datePicker",datePicker); + param.put("checkResult",checkResult); + param.put("checkResultShow",checkResultShow); + param.put("region",region); + String zipFileName = reserveService.getFileName(param) + ".zip"; + try { + String filePath = "/data/filesystem"; + String fileFullPath = filePath + File.separator + zipFileName; + OutputStream outputStream = Files.newOutputStream(new File(fileFullPath).toPath()); + reserveService.batchDownload(param, outputStream); + }catch (Exception e){ + log.error("下载文件异常 ==>"+Util.getErrString(e)); + } + return ApiResult.successNoData(); + } + + @GET @Path("/refreshStore") public String refreshStore(@Context HttpServletRequest request, @Context HttpServletResponse response){ diff --git a/src/main/java/com/api/bokang/xiao/zscq/mapper/QueryMapper.java b/src/main/java/com/api/bokang/xiao/zscq/mapper/QueryMapper.java index ab2d464..866ecfc 100644 --- a/src/main/java/com/api/bokang/xiao/zscq/mapper/QueryMapper.java +++ b/src/main/java/com/api/bokang/xiao/zscq/mapper/QueryMapper.java @@ -25,7 +25,7 @@ public interface QueryMapper { " from uf_gjjtb gjj " + " inner join hrmdepartment depart on gjj.xfqj = depart.id " + " where concat(',',concat(sjpcdxk,',')) like concat('%,',concat(#{datePicker},',%')) " + - " and hcqkdx = #{checkResult} and gjj.xgfj is not null ") + " and hcqkdx = #{checkResult} and gjj.xgfj is not null $t{cusWhere} ") @Associations( @Association(property = "weaverFile",column = "xgfj",id = @Id(value = Integer.class,methodId = 1))) List queryDownloadList(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 4813c23..7c5d649 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 @@ -7,6 +7,7 @@ import com.api.bokang.xiao.zscq.entity.WeaverFile; import com.api.bokang.xiao.zscq.mapper.QueryMapper; import com.api.bokang.xiao.zscq.mapper.ReserveSelectMapper; import com.api.bokang.xiao.zscq.service.ReserveService; +import com.icbc.api.internal.apache.http.impl.cookie.S; import weaver.bokang.xiao.zscq.config.service.ModeChangeService; import weaver.conn.RecordSet; import weaver.file.ImageFileManager; @@ -162,17 +163,24 @@ public class ReserveServiceImpl implements ReserveService { @Override public void batchDownload(Map param, OutputStream outputStream) throws IOException { + String region = Util.null2String(param.get("region")); + String cusWhere = ""; + if(!"".equals(region)){ + cusWhere = " and gjj.xfqj in ("+region+")"; + } + param.put("cusWhere",cusWhere); List sendList = queryMapper.queryDownloadList(param); if(Objects.isNull(sendList) || sendList.isEmpty()){ log.info("附件列表为空 attachment empty !!!"); //throw new CustomerException("附件列表查询为空"); return; } - log.info("查询到的附件信息 query fileList ==>"+ JSON.toJSONString(sendList)); + log.info("查询到的附件信息 query fileList ==>"+ sendList.size()); // 1. 将 SendFileEntity 按照 departName 分组 Map> sendMap = sendList.stream().collect(Collectors.groupingBy(SendFileEntity::getDepartName)); // 2. 创建 ZipOutputStream ZipOutputStream zipOutputStream = new ZipOutputStream(new BufferedOutputStream(outputStream)); + String defaultFileType = ".txt"; // 3. 遍历 SendFileEntity for (Map.Entry> entry : sendMap.entrySet()) { String departName = entry.getKey(); @@ -185,7 +193,17 @@ public class ReserveServiceImpl implements ReserveService { WeaverFile fileMsg = sendFileEntity.getWeaverFile(); int imageFileId = fileMsg.getImageFileId(); String fileName = fileMsg.getFileName(); - String fileType = fileName.substring(fileName.lastIndexOf(".")); + int index = fileName.lastIndexOf("."); + String fileType = ""; + if(fileMsg.getFileSize() > 1048576){ + log.info("文件大于 10M ==>"+JSON.toJSONString(sendFileEntity)); + } + if(index == -1){ + fileType = defaultFileType; + log.info("文件名有误 ==>"+JSON.toJSONString(sendFileEntity)); + }else { + fileType = fileName.substring(index); + } String tempFileName = sendFileEntity.getRequestNumber() + fileType; InputStream inputStream = ImageFileManager.getInputStreamById(imageFileId); // 6. 将单个附件写入 ZipOutputStream diff --git a/src/main/java/com/api/bokang/xiao/zxyh/generate_code/mapper/GenerateMapper.java b/src/main/java/com/api/bokang/xiao/zxyh/generate_code/mapper/GenerateMapper.java index 30c312f..a9873c6 100644 --- a/src/main/java/com/api/bokang/xiao/zxyh/generate_code/mapper/GenerateMapper.java +++ b/src/main/java/com/api/bokang/xiao/zxyh/generate_code/mapper/GenerateMapper.java @@ -1,9 +1,6 @@ package com.api.bokang.xiao.zxyh.generate_code.mapper; -import aiyh.utils.annotation.recordset.Delete; -import aiyh.utils.annotation.recordset.Select; -import aiyh.utils.annotation.recordset.SqlMapper; -import aiyh.utils.annotation.recordset.Update; +import aiyh.utils.annotation.recordset.*; import java.util.Map; @@ -23,7 +20,7 @@ public interface GenerateMapper { * @return 更新结果 */ @Update("update uf_contract_num_log set workflow_info = #{workflowInfo},file_info = #{fileInfo},detail_id = #{detailId}," + - "row_id = #{rowId},contract_name = #{contractName},contract_num = #{contractNum},flow_num = #{flowNum} where id = #{dataId}") + "row_id = #{rowId},contract_name = #{contractName},contract_num = #{contractNum},flow_num = #{flowNum},contract_month = #{contractMonth} where id = #{dataId}") boolean updateContractLog(Map param); /** @@ -33,6 +30,13 @@ public interface GenerateMapper { @Select("select max(flow_num) from uf_contract_num_log") int getMaxFlow(); + /** + *

查询最大的流水号

+ * @return 最大的流水号 + */ + @Select("select max(flow_num) from uf_contract_num_log where contract_month = #{month}") + int getMaxFlowByMonth(@ParamMapper("month")int month); + /** *

删除编号信息

* @param param 参数信息 diff --git a/src/main/java/com/api/bokang/xiao/zxyh/generate_code/service/GenerateContractNoService.java b/src/main/java/com/api/bokang/xiao/zxyh/generate_code/service/GenerateContractNoService.java index f9dc06d..fe7953f 100644 --- a/src/main/java/com/api/bokang/xiao/zxyh/generate_code/service/GenerateContractNoService.java +++ b/src/main/java/com/api/bokang/xiao/zxyh/generate_code/service/GenerateContractNoService.java @@ -5,6 +5,7 @@ import com.api.bokang.xiao.zxyh.generate_code.mapper.GenerateMapper; import org.apache.log4j.Logger; import java.text.SimpleDateFormat; +import java.util.Calendar; import java.util.Date; import java.util.Map; @@ -29,7 +30,10 @@ public class GenerateContractNoService { private final static Integer FLOW_LENGTH = 3; public String generateCode(Map param){ - int maxFlow = generateMapper.getMaxFlow(); + Calendar calendar = Calendar.getInstance(); + int month = calendar.get(Calendar.MONTH); + //int maxFlow = generateMapper.getMaxFlow(); + int maxFlow = generateMapper.getMaxFlowByMonth(month); maxFlow = Math.max(maxFlow,0); maxFlow++; String contractNo = ""; @@ -47,6 +51,7 @@ public class GenerateContractNoService { param.put("dataId",dataId); param.put("contractNum",contractNo); param.put("flowNum",maxFlow); + param.put("contractMonth",month); boolean updateFlag = generateMapper.updateContractLog(param); Util.rebuildModeDataShareByAsync(1,TABLE_NAME,dataId); if(updateFlag){ diff --git a/src/main/java/com/api/xuanran/wang/eny/workflow/controller/GetExchangeRate.java b/src/main/java/com/api/xuanran/wang/eny/workflow/controller/GetExchangeRate.java index 2bac670..6a7f2c3 100644 --- a/src/main/java/com/api/xuanran/wang/eny/workflow/controller/GetExchangeRate.java +++ b/src/main/java/com/api/xuanran/wang/eny/workflow/controller/GetExchangeRate.java @@ -6,50 +6,98 @@ import aiyh.utils.excention.CustomerException; import com.alibaba.fastjson.JSONObject; import com.api.xuanran.wang.eny.workflow.mapper.ExchangeRateMapper; import io.swagger.v3.oas.annotations.parameters.RequestBody; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; +import weaver.seconddev.ey.zhangm.util.EYSeconddevUtil; 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.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; import java.util.Map; /** - *

+ *

根据接口币种数据以及流程币种转成对应的汇率

* * @author xuanran.wang * @date 2023/7/14 15:02 */ -@Path("/wxr/eny/workflow/rate") +@Path("/wxr/ey/workflow/rate") public class GetExchangeRate { private final Logger log = Util.getLogger(); private final ExchangeRateMapper mapper = Util.getMapper(ExchangeRateMapper.class); + private EYSeconddevUtil eySeconddevUtil = null; @POST @Path("/exchange") - @Produces(MediaType.APPLICATION_OCTET_STREAM) + @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public String exchangeRate(@Context HttpServletRequest request, @Context HttpServletResponse response, - @RequestBody Map params){ + @RequestBody Map params){ try { + if(eySeconddevUtil == null){ + eySeconddevUtil = new EYSeconddevUtil(); + } // 地区 - String area = Util.null2DefaultStr(params.get("area"),""); + String date = Util.null2DefaultStr(params.get("date"),""); // 本位币 String baseCurrency = Util.null2DefaultStr(params.get("baseCurrency"),""); // 接口币种 String interfaceCurrency = Util.null2DefaultStr(params.get("interfaceCurrency"),""); - if(StringUtils.isBlank(area) || StringUtils.isBlank(baseCurrency) || StringUtils.isBlank(interfaceCurrency)){ + // 是否打印参数 + String printParams = Util.null2DefaultStr(params.get("printParams"),""); + // rateType + String rateType = Util.null2DefaultStr(params.get("rateType"),"5"); + // 字段名 + List> fieldList = (List>) params.get("fieldList"); + boolean print = "1".equals(printParams); + if(print){ + log.info("params : " + JSONObject.toJSONString(params)); + } + if(StringUtils.isBlank(date) || StringUtils.isBlank(baseCurrency) + || StringUtils.isBlank(interfaceCurrency) || CollectionUtils.isEmpty(fieldList)){ log.error("params : " + JSONObject.toJSONString(params)); throw new CustomerException("参数不可为空!"); } - String interfac = mapper.selectCurrencyIdByCurrencyName(interfaceCurrency); - return ""; + // 接口币种名称转OA数据id + String baseCurrencyName = mapper.selectCurrencyNameById(baseCurrency); + if(StringUtils.isBlank(baseCurrencyName)){ + throw new CustomerException("当前币种id : " + interfaceCurrency + " 在oa表中没有找到对应的name!"); + } + Map res = new HashMap<>(); + for (Map map : fieldList) { + if(print){ + log.info("map : " + JSONObject.toJSONString(map)); + } + String money = Util.null2DefaultStr(map.get("money"), ""); + String field = Util.null2DefaultStr(map.get("field"),""); + if(print){ + log.info("field : " + field + " ,money : " + money + " ,baseCurrencyName : " + + baseCurrencyName + " ,interfaceCurrency : " + interfaceCurrency + " ,rateType : " + rateType + " ,date : " + date); + } + if(StringUtils.isBlank(money) || StringUtils.isBlank(field)){ + continue; + } + Map rate = eySeconddevUtil.getExchargeRate(new BigDecimal(money), baseCurrencyName, interfaceCurrency, rateType, date); + if(print){ + log.info("field : " + field + " ,rate : " + JSONObject.toJSONString(rate)); + } + res.put(field, rate); + } + // 调方法获取汇率 + return ApiResult.success(res); }catch (Exception e){ - return ApiResult.error("汇率转换error : " + e.getMessage()); + log.error("exchangeRate error : " + e.getMessage()); + log.error(Util.getErrString(e)); + return ApiResult.error("汇率转换接口error : [ " + e.getMessage() + " ]"); } } diff --git a/src/main/java/com/api/xuanran/wang/eny/workflow/mapper/ExchangeRateMapper.java b/src/main/java/com/api/xuanran/wang/eny/workflow/mapper/ExchangeRateMapper.java index 8fe3999..7769f1d 100644 --- a/src/main/java/com/api/xuanran/wang/eny/workflow/mapper/ExchangeRateMapper.java +++ b/src/main/java/com/api/xuanran/wang/eny/workflow/mapper/ExchangeRateMapper.java @@ -12,6 +12,6 @@ import aiyh.utils.annotation.recordset.SqlMapper; */ @SqlMapper public interface ExchangeRateMapper { - @Select("select id from fnacurrency where currencyname = #{currencyName}") - String selectCurrencyIdByCurrencyName(@ParamMapper("currencyName") String currencyName); + @Select("select currencyname from fnacurrency where id = #{id}") + String selectCurrencyNameById(@ParamMapper("id") String id); } diff --git a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/controller/CommonDataAsyncController.java b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/controller/CommonDataAsyncController.java new file mode 100644 index 0000000..4e23cda --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/controller/CommonDataAsyncController.java @@ -0,0 +1,42 @@ +package com.api.xuanran.wang.xk_hospital.data_async.controller; + +import aiyh.utils.ApiResult; +import aiyh.utils.Util; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import org.apache.log4j.Logger; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.Map; + +/** + *

胸科医院数据同步

+ * + * @author xuanran.wang + * @date 2023/7/17 16:38 + */ +@Path("/wxr/xk_hospital/common") +public class CommonDataAsyncController { + + private final Logger logger = Util.getLogger(); + + @POST + @Path("/{configId}}") + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + public String async(@Context HttpServletRequest request, + @Context HttpServletResponse response, + @PathParam("configId") String configId, + @RequestBody Map params){ + try { + return ""; + }catch (Exception e){ + logger.error("CommonDataAsyncController error : " + e.getMessage()); + Util.logErrorStr(e, logger); + return ApiResult.error("数据同步失败! [ " + e.getMessage() + " ]"); + } + } +} diff --git a/src/main/java/weaver/cssc/schedule/util/PushModeDataUtil.java b/src/main/java/weaver/cssc/schedule/util/PushModeDataUtil.java index 279df99..d9ee681 100644 --- a/src/main/java/weaver/cssc/schedule/util/PushModeDataUtil.java +++ b/src/main/java/weaver/cssc/schedule/util/PushModeDataUtil.java @@ -32,15 +32,7 @@ public class PushModeDataUtil { public Map getConfigurationByKeyId(String keyId){ Map configMap = sqlMapper.getPushDataConfiguration(keyId); - if(configMap != null && configMap.size() > 0){ - int mainKeyId = (int) configMap.get("id"); - - List> fieldList = sqlMapper.getPushDataDetailConfiguration(mainKeyId); - - configMap.put("fieldList",fieldList); - } - - return configMap; + return getConfiguration(configMap); } /** @@ -51,6 +43,15 @@ public class PushModeDataUtil { public Map getConfigurationByModeId(int modeId){ Map configMap = sqlMapper.getPushDataConfigurationByModeId(modeId); + return getConfiguration(configMap); + } + + /** + * 获取配置信息 + * @param configMap 配置信息结果 + * @return 返回配置信息 + */ + private Map getConfiguration(Map configMap) { if(configMap != null && configMap.size() > 0){ int mainKeyId = (int) configMap.get("id"); diff --git a/src/main/java/weaver/formmode/customjavacode/modeexpand/ey/jiahx/UpdateStatusAchargeTwo.java b/src/main/java/weaver/formmode/customjavacode/modeexpand/ey/jiahx/UpdateStatusAchargeTwo.java new file mode 100644 index 0000000..e82739f --- /dev/null +++ b/src/main/java/weaver/formmode/customjavacode/modeexpand/ey/jiahx/UpdateStatusAchargeTwo.java @@ -0,0 +1,212 @@ +package weaver.formmode.customjavacode.modeexpand.ey.jiahx; + + +import com.api.nonstandardext.model_field_async.service.ModelFieldAsyncServiceImpl; +import weaver.conn.RecordSet; +import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.HashMap; +import java.util.Map; + +/** + * @Description + * @Author 贾寒旭 + * @Date 2023/4/24 + * @Other + * @Version + */ +public class UpdateStatusAchargeTwo extends AbstractModeExpandJavaCodeNew { + @Override + public Map doModeExpand(Map param) { + BaseBean baseBean = new BaseBean(); + +// src/weaver/formmode/customjavacode/modeexpand/getKmmb.java + baseBean.writeLog("保存自定义接口开始UpdateStatusAchargeTwo"); + Map result = new HashMap(); + try { + User user = (User) param.get("user"); + int billid = -1;//数据id + int modeid = -1;//模块id + RequestInfo requestInfo = (RequestInfo) param.get("RequestInfo"); + if (requestInfo != null) { + billid = Util.getIntValue(requestInfo.getRequestid()); + modeid = Util.getIntValue(requestInfo.getWorkflowid()); + RecordSet rs = new RecordSet(); + if (billid > 0 && modeid > 0) { +// 撤销账单规则,当requestTypewb = (BillingReversal账单)根据原账单号oriInvoiceNo文本字段找到原账单主表和子表数据更新数据 + String sql = "select m.id id,m.finishedTime finishedTime,m.requestTypewb requestTypewb,d.engCodewb engCodewb,m.invoiceNo invoiceNo,d.subInvoiceNo subInvoiceNo," + + "d.totalAmount totalAmount,m.oriInvoiceNo oriInvoiceNo,d.wskje wskje," + + "d.subTotal subTotalZeo,d.totalAmount totalAmountZeo,d.localTotalAmount as localTotalAmountlAmountZeo," + + "d.rmbTotalAmount as rmbTotalAmountZeo,d.balanceAmount as balanceAmountZeo from uf_zdjmbd_dt1 d left join uf_zdjmbd m on m.id = d.mainid where m.id = ?"; + rs.executeQuery(sql, billid); + String mid = ""; + while (rs.next()) { + mid = rs.getString("id"); + String requestTypewb = rs.getString("requestTypewb"); + if (requestTypewb.equals("credit_request")) { + String engCode = rs.getString("engCodewb"); + String invoiceNo = rs.getString("invoiceNo"); + String subInvoiceNo = rs.getString("subInvoiceNo"); + String totalAmount = rs.getString("totalAmount"); + String finishedTime = rs.getString("finishedTime"); + double wskje = Util.getDoubleValue(rs.getString("wskje"), 0f); + String oriInvoiceNo = rs.getString("oriInvoiceNo");//原账单号 + String sqls = "select d.mainid mainid,d.engCodewb engCodewb,d.wskje wskje from uf_zdjmbd_dt1 d left join uf_zdjmbd m on m.id = d.mainid where m.invoiceStatus='0' and m.invoiceNo = ?"; + RecordSet rss = new RecordSet(); + rss.executeQuery(sqls, oriInvoiceNo); + while (rss.next()) { + String orengCode = rss.getString("engCodewb"); + String mainid = rss.getString("mainid"); + double wskjeY = Util.getDoubleValue(rss.getString("wskje"), 0f); + if (orengCode.equals(engCode) && (Math.abs(Util.getDoubleValue(totalAmount, 0f)) < wskjeY)) { +// 1、插入撤销账单号的明细5冲销明细,生成对应新数据 +// 冲销金额cxje=账单.冲销金额cxje + |撤销账单子表.项目代码一致的totalAmount|(绝对值) + String insertsql = "insert into uf_zdjmbd_dt5 (cxzdh,cxzzdh,zdh,zzdh,cxje,cxrq,engCodewb,mainid) values(?,?,?,?,?,?,?,?)"; + RecordSet insertRs = new RecordSet(); + insertRs.executeUpdate(insertsql, invoiceNo, subInvoiceNo, oriInvoiceNo, oriInvoiceNo, totalAmount, finishedTime, engCode, mainid); + String Qusql = "select cxje from uf_zdjmbd_dt1 where engCodewb = ? and mainid = ?"; + RecordSet recordSet1 = new RecordSet(); + recordSet1.executeQuery(Qusql, engCode, mainid); + while (recordSet1.next()) { + double cxje = Util.getDoubleValue(recordSet1.getString("cxje"), 0f); + cxje += Math.abs(Util.getDoubleValue(totalAmount)); + String UpSql = "update uf_zdjmbd_dt1 set cxje = ? where engCodewb = ? and mainid = ?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeUpdate(UpSql, cxje, engCode, mainid); + } + // 未收款金额wskje(需要先执行冲销金额的更新) + // 未收款金额wskje=uf_zdjmbd_dt1中的总金额totalAmount-已收款金额yskje-冲销金额cxje + String Upsql1 = "update uf_zdjmbd_dt1 set wskje = totalAmount-yskje-cxje-hxje where engCodewb = ? and mainid = ?"; + RecordSet recordSet = new RecordSet(); + recordSet.executeUpdate(Upsql1, engCode, mainid); + // 收款状态skzt + // 如果账单明细.未收款金额wskje > 0 则改为1,部分收款 + // 如果账单明细.未收款金额wskje = 0 则改为2,全部收款 + String Qsql1 = "select wskje from uf_zdjmbd_dt1 where engCodewb = ? and mainid = ? "; + recordSet.executeQuery(Qsql1, engCode, mainid); + String skzt = ""; + while (recordSet.next()) { + double wskje1 = Util.getDoubleValue(recordSet.getString("wskje"), 0f); + if (wskje1 > 0) { + skzt = "1"; + } else if (wskje == 0) { + skzt = "2"; + } else { + skzt = "9"; + } + } + String Upsql2 = "update uf_zdjmbd_dt1 set skzt = ? where engCodewb = ? and mainid = ?"; + RecordSet recordSet2 = new RecordSet(); + recordSet2.executeUpdate(Upsql2, skzt, engCode, mainid); + + // 2、更新账单uf_zdjmbd的主表中冲销金额cxje: + // 冲销金额cxje + // 冲销金额cxje=uf_zdjmbd_dt1中的冲销金额cxje合计 + // 未收款金额wskje + // 未收款金额wskje=uf_zdjmbd_dt1中的未收款金额wskje合计 + // 收款状态skzt + // 如果账单明细1.未收款金额合计wskje > 0 则改为1,部分收款 + // 如果账单明细1.未收款金额合计wskje = 0 则改为2,全部收款 + // 账单状态invoiceStatus + // 如果账单明细1.未收款金额合计wskje = 0 则改为2,close + RecordSet Mrs = new RecordSet(); + String Msql = "select * from uf_zdjmbd_dt1 where mainid = ?"; + double cxje1 = 0; + double wskje1 = 0; + String M_skzt = ""; + String invoiceStatus = ""; + Mrs.executeQuery(Msql, mainid); + while (Mrs.next()) { + cxje1 += Util.getDoubleValue(Mrs.getString("cxje"), 0f); + wskje1 += Util.getDoubleValue(Mrs.getString("wskje"), 0f); + if (wskje1 > 0) { + M_skzt = "1"; + invoiceStatus = "0"; + } else if (wskje1 == 0) { + M_skzt = "2"; + invoiceStatus = "1"; + } else { + M_skzt = "1"; + invoiceStatus = "0"; + } + String mainidC = Mrs.getString("mainid"); + String Mupsql = "update uf_zdjmbd set cxje =?,wskje = ?,skzt = ?,invoiceStatus = ? where id = ?"; + baseBean.writeLog("Mupsql=====" + Mupsql); + recordSet2.executeUpdate(Mupsql, cxje1, wskje1, M_skzt, invoiceStatus, mainidC); + } + } + + /** + * 通过配置同步字段 + * @author xuanran.wang + * @date 2023-06-27 + */ + new ModelFieldAsyncServiceImpl().asyncDataByClassName(this.getClass().getSimpleName(), String.valueOf(billid)); + } + String Usql = "update uf_zdjmbd set invoiceStatus = '1' where id = ?"; + RecordSet Urs = new RecordSet(); + Urs.executeUpdate(Usql, billid); + } else if ("zb_request".equals(requestTypewb)) { +// baseBean.writeLog("零账单处理>>>>>>>>>>>>>"); +// String engCode = rs.getString("engCodewb"); +// String invoiceNo = rs.getString("invoiceNo"); +// String subInvoiceNo = rs.getString("subInvoiceNo"); +// //2023年6月1日 新增零账单数据处理 --cds +// String querySql = "select m.id mainid,d.id id,d.engCodewb engCodewb,d.subInvoiceNo as subInvoiceNo from uf_zdjmbd_dt1 d left join uf_zdjmbd m on m.id = d.mainid where m.invoiceStatus='0' and m.invoiceNo = ?"; +// RecordSet rs1 = new RecordSet(); +// rs1.executeQuery(querySql, invoiceNo); +// while (rs1.next()) { +// String engCodewb = Util.null2String(rs1.getString("engCodewb")); +// String subInvoiceNo_dt = Util.null2String(rs1.getString("subInvoiceNo")); +// String dtid = Util.null2String(rs1.getString("id")); +// if (engCodewb.equals(engCode) && subInvoiceNo_dt.equals(subInvoiceNo)) { +// /*1、更新正数账单uf_zdjmbd_dt1子表的字段 +// subTotal +// subTotal = 正数账单中的subTotal+零账单子表.subTotal +// totalAmount +// totalAmount = 正数账单中的totalAmount+零账单子表.totalAmount +// localTotalAmount +// localTotalAmountlAmount = 正数账单中的localTotalAmountlAmount+零账单子表.localTotalAmountlAmount +// rmbTotalAmount +// rmbTotalAmount = 正数账单中的rmbTotalAmount+零账单子表.rmbTotalAmount +// balanceAmount +// balanceAmount = 正数账单中的balanceAmount+零账单子表.balanceAmount +// */ +// double subTotal = Util.getDoubleValue(rs.getString("subTotalZeo"), 0f); +// double totalAmount = Util.getDoubleValue(rs.getString("totalAmountZeo"), 0f); +// double localTotalAmountlAmount = Util.getDoubleValue(rs.getString("localTotalAmountlAmountZeo"), 0f); +// double rmbTotalAmount = Util.getDoubleValue(rs.getString("rmbTotalAmountZeo"), 0f); +// double balanceAmount = Util.getDoubleValue(rs.getString("balanceAmountZeo"), 0f); +// +// String updateSql = "update uf_zdjmbd_dt1 set subTotal=ifnull(subTotal,0)+" + subTotal + ",totalAmount=ifnull(totalAmount,0)+" + totalAmount + ",localTotalAmount=ifnull(localTotalAmount,0)+" + localTotalAmountlAmount + ",rmbTotalAmount=ifnull(rmbTotalAmount,0)+" + rmbTotalAmount + ",balanceAmount=ifnull(balanceAmount,0)+" + balanceAmount + " where id=" + dtid; +// baseBean.writeLog("更新零账单updateSql: " + updateSql); +// RecordSet updateRs = new RecordSet(); +// boolean updateFlag = updateRs.executeUpdate(updateSql); +// baseBean.writeLog("更新零账单updateFlag: " + updateFlag); +// } +// } + } + + } + +// //更新零账单主表的账单状态invoiceStatus改为1,close +// if (!"".equals(mid)) { +// String updateSql = "update uf_zdjmbd set invoiceStatus='1' where id=" + mid; +// baseBean.writeLog("更新零账单主表账单状态Sql:" + updateSql); +// boolean flag = rs.executeUpdate(updateSql); +// baseBean.writeLog("更新零账单主表账单状态flag:" + flag); +// } + } + } + } catch (Exception e) { + baseBean.writeLog("UpdateStatusAchargeTwo catch exception:" + e); + result.put("errmsg", "自定义出错信息"); + result.put("flag", "false"); + } + return result; + } +} diff --git a/src/main/java/weaver/formmode/interfaces/impl/ey/zhang/ImportExtValidateTemplate.java b/src/main/java/weaver/formmode/interfaces/impl/ey/zhang/ImportExtValidateTemplate.java deleted file mode 100644 index 81b2124..0000000 --- a/src/main/java/weaver/formmode/interfaces/impl/ey/zhang/ImportExtValidateTemplate.java +++ /dev/null @@ -1,342 +0,0 @@ -package weaver.formmode.interfaces.impl.ey.zhang; - -import com.alibaba.fastjson.JSON; -import org.apache.commons.lang.StringUtils; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; -import weaver.conn.RecordSet; -import weaver.file.ExcelParseForPOI; -import weaver.formmode.interfaces.ImportPreInterfaceForPOIAction; -import weaver.general.BaseBean; -import weaver.general.Util; -import weaver.hrm.User; -import weaver.seconddev.ey.zhangm.didi.util.DaoUtils; -import weaver.seconddev.ey.zhangm.util.EYSeconddevUtil; - -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Pattern; - - -/** - * @Description - * @Author miao.zhang - * @Version V1.0.0 - * @Since 1.0 - * @Date 6/22/23 - */ -public class ImportExtValidateTemplate implements ImportPreInterfaceForPOIAction { - - @Override - public String checkImportData(Map param, User user, ExcelParseForPOI excelParse) { - - EYSeconddevUtil eySeconddevUtil = new EYSeconddevUtil(); - String ssids="ey_clentid_col,budget_version_col,plan_source_col,ey_bucode_col,ey_oucode_col,ey_mucode_col,ey_smucode_col,ey_engagementname_col,ey_ep_col,ey_em_col,ey_pfma_col,"; - ssids=ssids+"ey_local_service_code_col,ey_mercury_code_col,ey_pycode_col,ey_pacelink_col,ey_oppr_code_col,ey_blocking_level_col,opencheckcustom,"; - ssids=ssids+"opencheckbudget,opencheckcodeblock,opencheckgpn,opencheckengagementname,opencheckpycode,opencheckcodeblockByBcp,openchecklocalservicecode,"; - ssids=ssids+"opencheckconfidential,opencheckopprCode,opencheckmercury,opencheckblocklevel"; - Map ey_params_map =eySeconddevUtil.getSystemParamValues(ssids); - - int ey_clentid_col = Util.getIntValue(ey_params_map.get("ey_clentid_col")); - int budget_version_col = Util.getIntValue(ey_params_map.get("budget_version_col")); - int plan_source_col = Util.getIntValue(ey_params_map.get("plan_source_col")); - int ey_bucode_col = Util.getIntValue(ey_params_map.get("ey_bucode_col")); - int ey_oucode_col = Util.getIntValue(ey_params_map.get("ey_oucode_col")); - int ey_mucode_col = Util.getIntValue(ey_params_map.get("ey_mucode_col")); - int ey_smucode_col = Util.getIntValue(ey_params_map.get("ey_smucode_col")); - int ey_engagementname_col = Util.getIntValue(ey_params_map.get("ey_engagementname_col")); - int ey_ep_col = Util.getIntValue(ey_params_map.get("ey_ep_col")); - int ey_em_col = Util.getIntValue(ey_params_map.get("ey_em_col")); - int ey_pfma_col = Util.getIntValue(ey_params_map.get("ey_pfma_col")); - int ey_local_service_code_col = Util.getIntValue(ey_params_map.get("ey_local_service_code_col")); - int ey_mercury_code_col = Util.getIntValue(ey_params_map.get("ey_mercury_code_col")); - int ey_pycode_col = Util.getIntValue(ey_params_map.get("ey_pycode_col")); - int ey_pacelink_col = Util.getIntValue(ey_params_map.get("ey_pacelink_col")); - int ey_oppr_code_col = Util.getIntValue(ey_params_map.get("ey_oppr_code_col")); - int ey_blocking_level_col = Util.getIntValue(ey_params_map.get("ey_blocking_level_col")); - String opencheckcustom = Util.null2String(ey_params_map.get("opencheckcustom")); - String opencheckbudget = Util.null2String(ey_params_map.get("opencheckbudget")); - String opencheckcodeblock = Util.null2String(ey_params_map.get("opencheckcodeblock")); - String opencheckgpn = Util.null2String(ey_params_map.get("opencheckgpn")); - String opencheckengagementname = Util.null2String(ey_params_map.get("opencheckengagementname")); - String opencheckpycode = Util.null2String(ey_params_map.get("opencheckpycode")); - String opencheckcodeblockByBcp = Util.null2String(ey_params_map.get("opencheckcodeblockByBcp")); - String openchecklocalservicecode = Util.null2String(ey_params_map.get("openchecklocalservicecode")); - String opencheckconfidential = Util.null2String(ey_params_map.get("opencheckconfidential")); - String opencheckopprCode =Util.null2String(ey_params_map.get("opencheckopprCode")); - String opencheckmercury =Util.null2String(ey_params_map.get("opencheckmercury")); - String opencheckblocklevel =Util.null2String(ey_params_map.get("opencheckblocklevel")); - - new BaseBean().writeLog("opencheckcustom==>" + opencheckcustom+",opencheckbudget==>"+opencheckbudget+",opencheckcodeblock==>"+opencheckcodeblock); - new BaseBean().writeLog("opencheckgpn==>" + opencheckgpn+",opencheckengagementname==>"+opencheckengagementname+",opencheckpycode==>"+opencheckpycode); - new BaseBean().writeLog("opencheckcodeblockByBcp==>" + opencheckcodeblockByBcp+",openchecklocalservicecode==>"+openchecklocalservicecode+",opencheckconfidential==>"+opencheckconfidential); - new BaseBean().writeLog("opencheckopprCode==>" + opencheckopprCode+",opencheckmercury==>"+opencheckmercury); - - - // 获取模块ID - Integer modeId = Util.getIntValue(param.get("modeid").toString()); - //表单id - Integer formId = Util.getIntValue(param.get("formid").toString()); - // 获取当前登录人员ID - Integer userId = user.getUID(); - String sheetname = "1"; - //获取第 sheetindex 个sheet的第row行第col列的单元格的值 (下标都是从1开始) - //String value = excelParse.getValue("1", 2, 2); - Workbook wb = excelParse.getWb(); - Sheet sheet = wb.getSheetAt(Util.getIntValue(sheetname) - 1); - StringBuilder error = new StringBuilder(); - Pattern DATE_PATTERN = Pattern.compile("^\\d{4}-\\d{2}$"); - if (sheet != null) { - int rowSum = sheet.getPhysicalNumberOfRows(); - new BaseBean().writeLog("rowSum==>" + rowSum); - int current_row = 0; - for (int i = 2; i <= rowSum; i++) { - current_row = i - 1; - String client_id = Util.null2String(excelParse.getValue("1", i, ey_clentid_col)); - String budget_version_id = Util.null2String(excelParse.getValue("1", i, budget_version_col)); - String bucode = Util.null2String(excelParse.getValue("1", i, ey_bucode_col)); - String oucode = Util.null2String(excelParse.getValue("1", i, ey_oucode_col)); - String mucode = Util.null2String(excelParse.getValue("1", i, ey_mucode_col)); - String plan_source = Util.null2String(excelParse.getValue("1", i, plan_source_col)); - String smucode = Util.null2String(excelParse.getValue("1", i, ey_smucode_col)); - String engagement_name = Util.null2String(excelParse.getValue("1", i, ey_engagementname_col)).trim(); - String ep = Util.null2String(excelParse.getValue("1", i, ey_ep_col)); - String em = Util.null2String(excelParse.getValue("1", i, ey_em_col)); - String pfma = Util.null2String(excelParse.getValue("1", i, ey_pfma_col)); - String pycode = Util.null2String(excelParse.getValue("1", i, ey_pycode_col)).trim(); - String blocking_level= Util.null2String(excelParse.getValue("1", i, ey_blocking_level_col)).trim(); - new BaseBean().writeLog("pycode==>"+pycode); - - - String pace_link = Util.null2String(excelParse.getValue("1", i, ey_pacelink_col)).trim(); - String local_service_code =Util.null2String(excelParse.getValue("1", i, ey_local_service_code_col)).trim(); - String opprCode =Util.null2String(excelParse.getValue("1", i, ey_oppr_code_col)).trim(); - String mercury_code =Util.null2String(excelParse.getValue("1", i, ey_mercury_code_col)).trim(); - String countryregioncode =Util.null2String(DaoUtils.querySingleVal("select countryregioncode from uf_Codeblockjcdab where bucode=? and oucode=? and mucode=? and smucode=?",bucode, oucode, mucode, smucode)); - String local_global_service_code =DaoUtils.querySingleVal("select global_service_code from uf_service_code where Servicecode=?",local_service_code); - new BaseBean().writeLog("====1、mercury_code===="+mercury_code ); - String mercury_global_service_code =DaoUtils.querySingleVal("select global_service_code from uf_msc_gsc where mercury_service_code=?",mercury_code); - - //1、Excel模版 BU 、OU、MU、SMU校验:是否存在对应codeblock Done - if (opencheckcodeblock.equals("1")) { - new BaseBean().writeLog("====1、opencheckcodeblock.start====" ); - RecordSet recordSet = DaoUtils.executeQuery("select " + - " count(1) as rowcount " + - " from uf_Codeblockjcdab where bucode=? and oucode=? and mucode=? and smucode=?", bucode, oucode, mucode, smucode); - if (recordSet.next()) { - int rowcount = recordSet.getInt("rowcount"); - if (rowcount > 1) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认codeblock是否唯一!").append("
"); - } else if (rowcount == 0) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,未匹配到对应codeblock数据!").append("
"); - } - } - - new BaseBean().writeLog("====1、opencheckcodeblock.end====" ); - } - - //2、Excel模版 BU 、OU、MU、SMU校验:调用业务核心接口 Done - if (opencheckcodeblockByBcp.equals("1")) { - new BaseBean().writeLog("====2、opencheckcodeblockByBcp.start====" ); - boolean flag =eySeconddevUtil.getLegalEffective(bucode,oucode,mucode,smucode); - new BaseBean().writeLog("getLegalEffective===>"+flag); - if(!flag){ - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认Bu,Ou,Mu,Smu有效性! ").append("
"); - } - new BaseBean().writeLog("====2、opencheckcodeblockByBcp.end====" ); - } - - //3、Excel模版商机校验:国家编号不是MNG,商机id必填 Done - if (opencheckopprCode.equals("1") ) { - new BaseBean().writeLog("====3、opencheckopprCode.start====" ); - new BaseBean().writeLog("====3、countryregioncode===="+countryregioncode ); - if(StringUtils.isNotBlank(countryregioncode)){ - if( !countryregioncode.equals("MNG") && opprCode.equals("")){ - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,商机id必填! ").append("
"); - } - } - - new BaseBean().writeLog("====3、opencheckopprCode.end====" ); - } - - //4、Excel模版Client_id校验 Done - if (opencheckcustom.equals("1")) { - new BaseBean().writeLog("====4、opencheckcustom.start====" ); - Map custominfo = eySeconddevUtil.getCustomInfo(client_id); - String code = Util.null2String((String)custominfo.get("code")); - new BaseBean().writeLog("getCustomInfo===>"+code); - if (!code.equals("100")) { - //return "数据验证失败:第一个sheet第"+current_row+"行数据的,请确认客户中心系统中已存在该客户!"; - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认客户中心系统中已存在该客户! ") - .append("
"); - } - new BaseBean().writeLog("====4、opencheckcustom.end====" ); - } - - //5、Excel模版Client_id,商机id,PACE_ID(截取PACE_link) 校验项 :前置条件:国家编号不是MNG, - // 调用商机接口传入Client_id,商机id,PACE_ID 是否有效,有效返回IsConfidential Done - if (opencheckconfidential.equals("1")) { - new BaseBean().writeLog("====5、opencheckconfidential.start====" ); - String pace_id =""; - if(StringUtils.isNotBlank(pace_link)){ - int beginindex =pace_link.lastIndexOf("Assessment/")+11; - String endstr =pace_link.substring(beginindex,pace_link.length()); - int endindex = endstr.lastIndexOf("/"); - pace_id =pace_link.substring(beginindex,beginindex+endindex); - new BaseBean().writeLog("ModeExpandForExtCodeImport,pace_id==>"+pace_id); - } - Map result =eySeconddevUtil.getConfidentialInfo(opprCode,pace_id,client_id); - String errstr =Util.null2String(result.get("errorstr")); - if(StringUtils.isNotBlank(errstr)){ - error.append("数据验证失败:第一个sheet第" + current_row + "行数据,请确认"+errstr.substring(0,errstr.length()-1)+"等问题! ") - .append("
"); - } - new BaseBean().writeLog("====5、opencheckconfidential.end====" ); - } - - //6、Excel模版”PY_Code” 校验: PY code 历史上是否存在对应的.engagement_code Done - if (opencheckpycode.equals("1")) { - new BaseBean().writeLog("====6、opencheckpycode.start====" ); - new BaseBean().writeLog("====6、opencheckpycode.pycode===="+pycode ); - if(StringUtils.isNotBlank(pycode)){ - RecordSet rs2 = new RecordSet(); - rs2.executeQuery("select id from uf_xmjbxxjmbd where engagement_code=?", pycode); - if (!rs2.next()) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,该项目PY_CODE未关联! ").append("
"); - } - } - new BaseBean().writeLog("====6、opencheckpycode.end====" ); - } - - //7、Excel模版“本地服务编码”校验:uf_service_code.Servicecode 是否存在 Done - if (openchecklocalservicecode.equals("1")) { - new BaseBean().writeLog("====7、openchecklocalservicecode.start====" ); - RecordSet rs2 = new RecordSet(); - new BaseBean().writeLog("====7、openchecklocalservicecode.local_service_code====" +local_service_code); - rs2.executeQuery("select id from uf_service_code where Servicecode=? ",local_service_code); - if(!rs2.next()){ - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认本地服务编码是否有效! ").append("
"); - } - new BaseBean().writeLog("====7、openchecklocalservicecode.end====" ); - } - - //8、Excel模版“计划编号”校验项 ,根据“计划来源”,调用CCT&MMT或者SmartHub接口是否存在 Done - if (opencheckbudget.equals("1")) { - new BaseBean().writeLog("==8、opencheckbudget。start=="); - Map budgetinfo = new HashMap (); - new BaseBean().writeLog("==plan_source=="+plan_source); - if(!(plan_source.equals("CCT") || plan_source.equals("MMT") || plan_source.equals("SmartHub") )){ - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,计划来源填写错误只允许填写CCT、MMT、SmartHub!").append("
"); - } - if (plan_source.equals("CCT") || plan_source.equals("MMT")) { - budgetinfo = eySeconddevUtil.getBudgetInfo("mmtplandetail", budget_version_id); - } else { - budgetinfo = eySeconddevUtil.getBudgetInfo("smarthubbudgetdetail", budget_version_id); - } - new BaseBean().writeLog("==budgetinfo=="+ JSON.toJSONString(budgetinfo)); - if (budgetinfo.isEmpty() || budgetinfo==null) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认预算系统中是否存在该预算!").append("
"); - } - new BaseBean().writeLog("==8、opencheckbudget。end=="); - } - - //9、Excel模版GPN是否存在 Done - if (opencheckgpn.equals("1")) { - - new BaseBean().writeLog("==9、opencheckgpn。start=="); - new BaseBean().writeLog("em==>"+em); - new BaseBean().writeLog("ep==>"+ep); - new BaseBean().writeLog("pfma==>"+pfma); - - if (StringUtils.isNotBlank(ep)) { - RecordSet recordSet=new RecordSet(); - recordSet.executeQuery("select id from hrmresource where workcode=?",ep); - if(!recordSet.next()){ - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认EP的GPN不存在系统中!").append("
"); - } - } - - if (StringUtils.isNotBlank(em)) { - RecordSet recordSet=new RecordSet(); - recordSet.executeQuery("select id from hrmresource where workcode=?",em); - if(!recordSet.next()){ - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认EP的GPN不存在系统中!").append("
"); - } - } - - if (StringUtils.isNotBlank(pfma)) { - RecordSet recordSet=new RecordSet(); - recordSet.executeQuery("select id from hrmresource where workcode=?",pfma); - if(!recordSet.next()){ - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认PFMA的GPN不存在系统中!").append("
"); - } - } - new BaseBean().writeLog("==9、opencheckgpn。end=="); - } - - //10、mercury_service_code校验 Done - if(opencheckmercury.equals("1")){ - new BaseBean().writeLog("==10、opencheckmercury。start=="); - new BaseBean().writeLog("====10、mercury_global_service_code===="+mercury_global_service_code ); - new BaseBean().writeLog("====10、local_global_service_code===="+local_global_service_code ); - if(!mercury_global_service_code.equals(local_global_service_code)){ - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认MercuryCode与global_service_code不匹配!").append("
"); - } - new BaseBean().writeLog("==10、opencheckmercury。end=="); - } - - - //11、Excel的项目名称 Done - if (opencheckengagementname.equals("1")) { - new BaseBean().writeLog("==11、opencheckengagementname。start=="); - new BaseBean().writeLog("==11、opencheckengagementname。engagement_name=="+engagement_name); - RecordSet recordSet = new RecordSet(); - recordSet.executeQuery("select " + - " servicelinecode, subservicelinecode " + - " from uf_Codeblockjcdab where bucode=? and oucode=? and mucode=? and smucode=?", bucode, oucode, mucode, smucode); - if(recordSet.next()){ - String servicelinecode =Util.null2String(recordSet.getString("servicelinecode")); - String subservicelinecode =Util.null2String(recordSet.getString("subservicelinecode")); - if(servicelinecode.equals("01") && subservicelinecode.equals("0101")){ //serviceline=01和subserviceline=0101时,触发项目名称校验 - //检验 :0~3位 必须是AUT 或者 INT - boolean flag = EYSeconddevUtil.vaildateImportEnagementName(engagement_name,local_global_service_code); - String datestr = engagement_name.substring(3, 10); - if(!flag){ - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认前3位是否合规! ").append("
"); - }else if(!DATE_PATTERN.matcher(datestr).matches()){ //检验:4~10位 必须是YYYY-MM - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认4到10位是否日期字段,如:2001-01! ").append("
"); - - } - } - } - new BaseBean().writeLog("==11、opencheckengagementname。end=="); - } - - //12、BlockLevel Done - if(opencheckblocklevel.equals("1")){ - new BaseBean().writeLog("==12、opencheckblocklevel.start=="); - if (StringUtils.isNotBlank(ep)) { - RecordSet recordSet=new RecordSet(); - recordSet.executeQuery("select id from uf_bl where engblocklevel =?",blocking_level); - if(!recordSet.next()){ - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,blocking_level填写有误请检查!").append("
"); - } - } - new BaseBean().writeLog("==12、opencheckblocklevel.end=="); - } - // 12、校验项目EP Rank - if (!"".equals(ep) && !eySeconddevUtil.validateEngagementRoleRank(ep,"1","0")) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,EP填写有误请检查!").append("
"); - } - // 13、校验项目EM Rank - if (!"".equals(em) && !eySeconddevUtil.validateEngagementRoleRank(em,"1","0")) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,EM填写有误请检查!").append("
"); - } - } - } - - String returnstr =error.toString(); - new BaseBean().writeLog("returnstr===>"+returnstr); - return returnstr; - } -} diff --git a/src/main/java/weaver/formmode/interfaces/impl/ey/zhang/ImportNtoOValidateTemplate.java b/src/main/java/weaver/formmode/interfaces/impl/ey/zhang/ImportNtoOValidateTemplate.java deleted file mode 100644 index cf859ba..0000000 --- a/src/main/java/weaver/formmode/interfaces/impl/ey/zhang/ImportNtoOValidateTemplate.java +++ /dev/null @@ -1,307 +0,0 @@ -package weaver.formmode.interfaces.impl.ey.zhang; - -import org.apache.commons.lang.StringUtils; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; -import weaver.conn.RecordSet; -import weaver.file.ExcelParseForPOI; -import weaver.formmode.interfaces.ImportPreInterfaceForPOIAction; -import weaver.general.BaseBean; -import weaver.general.Util; -import weaver.hrm.User; -import weaver.seconddev.ey.zhangm.didi.util.DaoUtils; -import weaver.seconddev.ey.zhangm.util.EYSeconddevUtil; - -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Pattern; - - -/** - * @Description - * @Author miao.zhang - * @Version V1.0.0 - * @Since 1.0 - * @Date 6/22/23 - */ -public class ImportNtoOValidateTemplate implements ImportPreInterfaceForPOIAction { - - - @Override - public String checkImportData(Map param, User user, ExcelParseForPOI excelParse) { - - EYSeconddevUtil eySeconddevUtil = new EYSeconddevUtil(); - - - String ssids="ey_nto_clentid_col,ey_nto_budget_version_col,ey_nto_bucode_col,ey_nto_oucode_col,ey_nto_mucode_col,ey_nto_smucode_col,ey_nto_engagementname_col,ey_nto_ep_col,ey_nto_em_col,ey_nto_pfma_col,"; - ssids=ssids+"ey_nto_engagementcode_col,ey_nto_mercurycode_col,ey_nto_pacelink_col,opencheckntooengagementstatus,"; - ssids=ssids+"opencheckntooservicecode,opencheckntooserviceline,opencheckntopycode,opencheckntoengagementname,opencheckntocustom,opencheckntocodeblock,opencheckntogpn,"; - ssids=ssids+"opencheckntobudget,opencheckntomercury,opencheckntopaceid"; - Map ey_params_map =eySeconddevUtil.getSystemParamValues(ssids); - - - int ey_clentid_col = Util.getIntValue(ey_params_map.get("ey_nto_clentid_col")); - int budget_version_col = Util.getIntValue(ey_params_map.get("ey_nto_budget_version_col")); - int ey_bucode_col = Util.getIntValue(ey_params_map.get("ey_nto_bucode_col")); - int ey_oucode_col = Util.getIntValue(ey_params_map.get("ey_nto_oucode_col")); - int ey_mucode_col = Util.getIntValue(ey_params_map.get("ey_nto_mucode_col")); - int ey_smucode_col = Util.getIntValue(ey_params_map.get("ey_nto_smucode_col")); - int ey_engagementname_col = Util.getIntValue(ey_params_map.get("ey_nto_engagementname_col")); - int ey_ep_col = Util.getIntValue(ey_params_map.get("ey_nto_ep_col")); - int ey_em_col = Util.getIntValue(ey_params_map.get("ey_nto_em_col")); - int ey_pfma_col = Util.getIntValue(ey_params_map.get("ey_nto_pfma_col")); - int ey_engagementcode_col = Util.getIntValue(ey_params_map.get("ey_nto_engagementcode_col")); - int ey_mercurycode_col = Util.getIntValue(ey_params_map.get("ey_nto_mercurycode_col")); - int ey_pacelink_col = Util.getIntValue(ey_params_map.get("ey_nto_pacelink_col")); - - String opencheckntooengagementstatus = Util.null2String(ey_params_map.get("opencheckntooengagementstatus")); - String opencheckntoservicecode = Util.null2String(ey_params_map.get("opencheckntooservicecode")); - String opencheckntoserviceline = Util.null2String(ey_params_map.get("opencheckntooserviceline")); - String opencheckntopycode = Util.null2String(ey_params_map.get("opencheckntopycode")); - String opencheckntoengagementname = Util.null2String(ey_params_map.get("opencheckntoengagementname")); - String opencheckntocustom = Util.null2String(ey_params_map.get("opencheckntocustom")); - String opencheckntocodeblock= Util.null2String(ey_params_map.get("opencheckntocodeblock")); - String opencheckntogpn= Util.null2String(ey_params_map.get("opencheckntogpn")); - String opencheckntobudget = Util.null2String(ey_params_map.get("opencheckntobudget")); - String opencheckntomercury= Util.null2String(ey_params_map.get("opencheckntomercury")); - String opencheckntopaceid = Util.null2String(ey_params_map.get("opencheckntopaceid")); - - new BaseBean().writeLog("opencheckntooengagementstatus==>" + opencheckntooengagementstatus+",opencheckntoservicecode==>"+opencheckntoservicecode+",opencheckntoserviceline==>"+opencheckntoserviceline); - new BaseBean().writeLog("opencheckntopycode==>" + opencheckntopycode+",opencheckntoengagementname==>"+opencheckntoengagementname+",opencheckntocustom==>"+opencheckntocustom); - new BaseBean().writeLog("opencheckntocodeblock==>" + opencheckntocodeblock+",opencheckntogpn==>"+opencheckntogpn+",opencheckntobudget==>"+opencheckntobudget); - new BaseBean().writeLog("opencheckntomercury==>" + opencheckntomercury+",opencheckntopaceid==>"+opencheckntopaceid); - - - // 获取模块ID - Integer modeId = Util.getIntValue(param.get("modeid").toString()); - //表单id - Integer formId = Util.getIntValue(param.get("formid").toString()); - // 获取当前登录人员ID - Integer userId = user.getUID(); - String sheetname = "1"; - //获取第 sheetindex 个sheet的第row行第col列的单元格的值 (下标都是从1开始) - //String value = excelParse.getValue("1", 2, 2); - Workbook wb = excelParse.getWb(); - Sheet sheet = wb.getSheetAt(Util.getIntValue(sheetname) - 1); - StringBuilder error = new StringBuilder(); - Pattern DATE_PATTERN = Pattern.compile("^\\d{4}-\\d{2}$"); - if (sheet != null) { - int rowSum = sheet.getPhysicalNumberOfRows(); - new BaseBean().writeLog("rowSum==>" + rowSum); - int current_row = 0; - for (int i = 2; i <= rowSum; i++) { - current_row = i - 1; - String client_id = Util.null2String(excelParse.getValue("1", i, ey_clentid_col)); - String budget_version_id = Util.null2String(excelParse.getValue("1", i, budget_version_col)); - String bucode = Util.null2String(excelParse.getValue("1", i, ey_bucode_col)); - String oucode = Util.null2String(excelParse.getValue("1", i, ey_oucode_col)); - String mucode = Util.null2String(excelParse.getValue("1", i, ey_mucode_col)); - String smucode = Util.null2String(excelParse.getValue("1", i, ey_smucode_col)); - String engagement_name = Util.null2String(excelParse.getValue("1", i, ey_engagementname_col)).trim(); - String ep = Util.null2String(excelParse.getValue("1", i, ey_ep_col)); - String em = Util.null2String(excelParse.getValue("1", i, ey_em_col)); - String pfma = Util.null2String(excelParse.getValue("1", i, ey_pfma_col)); - String engagement_code = Util.null2String(excelParse.getValue("1", i, ey_engagementcode_col)).trim(); - String mercury_code = Util.null2String(excelParse.getValue("1", i, ey_mercurycode_col)).trim(); - String pace_link = Util.null2String(excelParse.getValue("1", i, ey_pacelink_col)).trim(); - - RecordSet rs2 = new RecordSet(); - rs2.executeQuery("select engagement_status,local_service_code,global_service_code,service_line,sub_service_line,py_code from uf_xmjbxxjmbd where engagement_code=? ", engagement_code); - if(rs2.next()) { - String local_service_code = Util.null2String(rs2.getString("local_service_code")); - String service_line = Util.null2String(rs2.getString("service_line")); - String global_service_code = Util.null2String(rs2.getString("global_service_code")); - String sub_service_line = Util.null2String(rs2.getString("sub_service_line")); - String temp_py_code = Util.null2String(rs2.getString("py_code")); - String engagement_status = Util.null2String(rs2.getString("engagement_status")); - //String local_global_service_code =DaoUtils.querySingleVal("select global_service_code from uf_service_code where Servicecode=?",local_service_code); - String mercury_global_service_code = DaoUtils.querySingleVal("select global_service_code from uf_msc_gsc where mercury_service_code=?", mercury_code); - String old_pace_id = DaoUtils.querySingleVal("select pace_id from uf_xmjbxxjmbd where engagement_code=?", temp_py_code); - String py_engagement_name = DaoUtils.querySingleVal("select engagement_name from uf_xmjbxxjmbd where engagement_code=?", temp_py_code); - - //1、校验该项目编号在项目档案中的 通过engcode查询,项目状态为N - if (opencheckntooengagementstatus.equals("1")) { - new BaseBean().writeLog("====1、opencheckntooengagementstatus.start===="); - new BaseBean().writeLog("engagement_status==>" + engagement_status); - if (!engagement_status.equals("N")) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,原项目状态不为N! ").append("
"); - } - new BaseBean().writeLog("====1、opencheckntooengagementstatus.end===="); - } - - //2、校验GSC为031、035。通过engcode查询,GSC为GSC =031、GSC=035 ,local_serivce_code=03500 or local_serivce_code=03100 - if (opencheckntoservicecode.equals("1")) { - new BaseBean().writeLog("====2、opencheckntoservicecode.start===="); - new BaseBean().writeLog("local_service_code==>" + local_service_code); - if (!local_service_code.equals("03500") && !local_service_code.equals("03100")) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,原项目本地服务编码是03500或03100! ").append("
"); - } - new BaseBean().writeLog("====2、opencheckntoservicecode.end===="); - } - //3、原项目业务线必须是ASU! - if (opencheckntoserviceline.equals("1")) { - new BaseBean().writeLog("====3、opencheckntoserviceline.start===="); - new BaseBean().writeLog("====3、service_line====" + service_line); - new BaseBean().writeLog("====3、sub_service_line====" + sub_service_line); - if (!(service_line.equals("01") && sub_service_line.equals("0101"))) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,原项目业务线必须是ASU,子业务线是Audit! ").append("
"); - } - new BaseBean().writeLog("====3、opencheckntoserviceline.end===="); - } - - //4、校该项目编号在项目档案中关联的PY Code不能为空 - if (opencheckntopycode.equals("1")) { - new BaseBean().writeLog("====4、opencheckntopycode.start===="); - new BaseBean().writeLog("====4、opencheckntopycode.temp_py_code====" + temp_py_code); - if (temp_py_code.equals("")) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,项目原PY_CODE不能为空! ").append("
"); - } - new BaseBean().writeLog("====4、opencheckntopycode.end===="); - } - - //5、Excel的项目名称 Done - if (opencheckntoengagementname.equals("1")) { - new BaseBean().writeLog("====5、opencheckntoengagementname.start===="); - if (engagement_name.equals(py_engagement_name)) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,项目名称不合规,请确认项目名称是否重复或名称格式是否错误,正确格式如:AUD2023-01XXXXX! ").append("
"); - }else if(engagement_name.length()<=10){ - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,项目名称不合规,请确认项目名称是否重复或名称格式是否错误,正确格式如:AUD2023-01XXXXX! ").append("
"); - }else if (engagement_name.length()>10 ){ - String datestr = engagement_name.substring(3, 10); - //String perfix = engagement_name.substring(0, 3); - boolean flag = EYSeconddevUtil.vaildateImportEnagementName(engagement_name,global_service_code); - //检验:4~10位 必须是YYYY-MM - if (!DATE_PATTERN.matcher(datestr).matches()) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,项目名称不合规,请确认项目名称是否重复或名称格式是否错误,正确格式如:AUD2023-01XXXXX! ").append("
"); - }else if(!flag) { //检验 :0~3位 必须是AUT 或者 INT - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,项目名称不合规,请确认项目名称是否重复或名称格式是否错误,正确格式如:AUD2023-01XXXXX! ").append("
"); - } - }else if (engagement_name.length()<=10){ - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,项目名称不合规,请确认项目名称是否重复或名称格式是否错误,正确格式如:AUD2023-01XXXXX! ").append("
"); - } - - new BaseBean().writeLog("====5、opencheckntoengagementname.end===="); - } - - //6、客户信息 Done - if (opencheckntocustom.equals("1")) { - new BaseBean().writeLog("====6、opencheckntocustom.start===="); - Map custominfo = eySeconddevUtil.getCustomInfo(client_id); - String code = Util.null2String(custominfo.get("code")); - if (!code.equals("100")) { - //return "数据验证失败:第一个sheet第"+current_row+"行数据的,请确认客户中心系统中已存在该客户!"; - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认客户中心系统中已存在该客户! ") - .append("
"); - } - new BaseBean().writeLog("====6、opencheckntocustom.end===="); - } - - //7、pace_id校验 - if (opencheckntopaceid.equals("1")) { - new BaseBean().writeLog("====7、opencheckntopaceid.start===="); - String pace_id = ""; - if (StringUtils.isNotBlank(pace_link)) { - int beginindex = pace_link.lastIndexOf("Assessment/") + 11; - String endstr = pace_link.substring(beginindex, pace_link.length()); - int endindex = endstr.lastIndexOf("/"); - pace_id = pace_link.substring(beginindex, beginindex + endindex); - new BaseBean().writeLog("ModeExpandForExtCodeImport,pace_id==>" + pace_id); - } - if (pace_id.equals(old_pace_id)) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,未创建新的PACE!").append("
"); - } - - new BaseBean().writeLog("====7、opencheckntopaceid.end===="); - } - - //8、CodeBlock信息 Done - if (opencheckntocodeblock.equals("1")) { - new BaseBean().writeLog("====8、opencheckntocodeblock.start===="); - RecordSet recordSet = DaoUtils.executeQuery("select " + - " id " + - " from uf_Codeblockjcdab where bucode=? and oucode=? and mucode=? and smucode=?", bucode, oucode, mucode, smucode); - if (!recordSet.next()) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,未匹配到对应codeblock数据!").append("
"); - } - new BaseBean().writeLog("====8、opencheckntocodeblock.end===="); - } - - //9、GPN是否存在 Done - if (opencheckntogpn.equals("1")) { - new BaseBean().writeLog("====9、opencheckntogpn.start===="); - new BaseBean().writeLog("em==>" + em); - new BaseBean().writeLog("ep==>" + ep); - new BaseBean().writeLog("pfma==>" + pfma); - - if (StringUtils.isNotBlank(ep)) { - RecordSet recordSet = new RecordSet(); - recordSet.executeQuery("select id from hrmresource where workcode=?", ep); - if (!recordSet.next()) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认EP的GPN不存在系统中!").append("
"); - } - } - - if (StringUtils.isNotBlank(em)) { - RecordSet recordSet = new RecordSet(); - recordSet.executeQuery("select id from hrmresource where workcode=?", em); - if (!recordSet.next()) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认EP的GPN不存在系统中!").append("
"); - } - } - - if (StringUtils.isNotBlank(pfma)) { - RecordSet recordSet = new RecordSet(); - recordSet.executeQuery("select id from hrmresource where workcode=?", pfma); - if (!recordSet.next()) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认PFMA的GPN不存在系统中!").append("
"); - } - } - new BaseBean().writeLog("====9、opencheckntogpn.end===="); - } - - // 10、SmartHub检查 - if (opencheckntobudget.equals("1")) { - new BaseBean().writeLog("====10、opencheckntobudget.start===="); - Map budgetinfo = new HashMap (); - budgetinfo = eySeconddevUtil.getBudgetInfo("smarthubbudgetdetail", budget_version_id); - //} - if (budgetinfo.size() == 0) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认预算系统中已存在该预算!").append("
"); - } - new BaseBean().writeLog("====10、opencheckntobudget.end===="); - } - -// 11、mercury_service_code校验 Done - if (opencheckntomercury.equals("1")) { - new BaseBean().writeLog("====11、opencheckntomercury.start===="); - new BaseBean().writeLog("global_service_code==>" + global_service_code); - new BaseBean().writeLog("mercury_global_service_code==>" + mercury_global_service_code); - if (!(mercury_global_service_code.equals(global_service_code))) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认Mercury Service Code与Global Service Code不匹配!").append("
"); - } - new BaseBean().writeLog("====11、opencheckntomercury.end===="); - } - - }else{ - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,请确认Engagement Code不存在!").append("
"); - - } - // 12、校验项目EP Rank - if (!"".equals(ep) && !eySeconddevUtil.validateEngagementRoleRank(ep,"1","0")) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,EP填写有误请检查!").append("
"); - } - // 13、校验项目EM Rank - if (!"".equals(em) && !eySeconddevUtil.validateEngagementRoleRank(em,"1","0")) { - error.append("数据验证失败:第一个sheet第" + current_row + "行数据的,EM填写有误请检查!").append("
"); - } - } - } - if (error.toString().equals("")) { - return ""; - } else { - return error.toString(); - } - - - } -} diff --git a/src/main/java/weaver/seconddev/ey/zhangm/didi/util/EYSeconddevUtil.java b/src/main/java/weaver/seconddev/ey/zhangm/didi/util/EYSeconddevUtil.java new file mode 100644 index 0000000..13e24d3 --- /dev/null +++ b/src/main/java/weaver/seconddev/ey/zhangm/didi/util/EYSeconddevUtil.java @@ -0,0 +1,773 @@ +package weaver.seconddev.ey.zhangm.didi.util; + + +import com.alibaba.fastjson.JSON; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.wbi.util.StringUtil; +import com.weaver.esb.client.EsbClient; +import com.weaver.esb.spi.EsbService; +import okhttp3.*; + +import org.apache.commons.lang.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.resource.ResourceComInfo; +import weaver.seconddev.ey.zhangm.didi.entity.Result; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.util.*; + +public class EYSeconddevUtil extends BaseBean { + /** + * 获取汇率相关信息 + * @param amount 转换前金额 + * @param fromCurrency 本位币 + * @param toCurrency 目标币种 + * @param rateType 汇率类型 0 CN日汇率 6 日汇率global CN周汇率 1 周汇率global 2 + * @param date + * @return {"rateType":"rateType","date","2023-10-11","formCurrency":"CNY","toCurrency":"USD","exchargeRate":"8.000000","tronferBeforeAmount":"1000.00","tronferAfterAmount":"8000.00"} + */ + public Map getExchargeRate(BigDecimal amount,String fromCurrency,String toCurrency,String rateType,String date){ + RecordSet rs = new RecordSet(); + //rs.executeQuery(""); + return null; + } + /** + * 校验用户是否存在 + * @param workcode + * @return + */ + public boolean validateUser(String workcode){ + RecordSet rs = new RecordSet(); + rs.executeQuery("select id from hrmresource where workcode=?,workcode"); + return rs.getCounts()>0; + } + /** + * 校验EM、EP rank + * @param gpn + * @param mark 内部项目、外部项目标识 0 内部、1外部 + * @param role 项目角色标识标识 0 EP、1 EM + * @return + */ + public boolean validateEngagementRoleRank(String gpn,String mark,String role){ + RecordSet rs=new RecordSet(); + rs.executeQuery("select id from hrmresource where workcode=?",gpn); + String userId=""; + if(rs.next()){ + userId=Util.null2String(rs.getString(1)); + } + writeLog("validateEngagementRoleRank>>>>gpn:"+gpn); + // 查询rank + String rank=""; + rs.executeQuery("select concat(field2,field24) from cus_fielddata scope='HrmCustomFieldByInfoType' and scopeid=-1 and id=?",userId); + if(rs.next()){ + rank=Util.null2String(rs.getString(1)); + } + writeLog("validateEngagementRoleRank>>>>rank:"+rank); + // 校验rank + rs.executeQuery("select id from uf_xmjsrankjyb where rankcode=? and mark=? and role=?",rank,mark,role); + return rs.getCounts()>0; + } + + public String getSystemParamValue(String ssid){ + String paramvalue =""; + if(!"".equals(ssid)){ + String select_sql="select paramvalue from uf_dd_prmt where ssid ='"+ssid+"'"; + RecordSet rs =new RecordSet(); + rs.executeSql(select_sql); + if(rs.next()){ + paramvalue = Util.null2String(rs.getString("paramvalue")); + } + } + return paramvalue; + } + + public Map getSystemParamValues(String ssids){ + + HashMap paramvalues=new HashMap(); + String ssidsstr=""; + if(!"".equals(ssids)){ + String [] ssidsArray = ssids.split(","); + for (String s:ssidsArray){ + if(!"".equals(s)) { + ssidsstr = ssidsstr + "'" + s + "',"; + } + } + if(!"".equals(ssidsstr)) { + ssidsstr = ssidsstr.substring(0, ssidsstr.length() - 1); + String select_sql="select ssid,paramvalue from uf_dd_prmt where ssid in("+ssidsstr+")"; + RecordSet rs =new RecordSet(); + rs.executeSql(select_sql); + while (rs.next()){ + paramvalues.put(rs.getString("ssid"),rs.getString("paramvalue")); + } + } + } + return paramvalues; + } + + public String getUserAllRole(Integer userid){ + String returnStr = ""; + RecordSet rs = new RecordSet(); + rs.executeSql("select roleid from hrmrolemembers where resourceid=" + userid); + while (rs.next()) { + returnStr = returnStr + Util.null2String(rs.getString("roleid")) + ","; + } + if (!"".equals(returnStr)) { + returnStr = returnStr.substring(0, returnStr.length() - 1); + } + if ("".equals(returnStr)) { + returnStr = "0"; + } + return returnStr; + } + + public String getMD5Str(String plainText){ + //定义一个字节数组 + byte[] secretBytes = null; + try { + // 生成一个MD5加密计算摘要 + MessageDigest md = MessageDigest.getInstance("MD5"); + //对字符串进行加密 + md.update(plainText.getBytes()); + //获得加密后的数据 + secretBytes = md.digest(); + } catch (NoSuchAlgorithmException e) { + //throw new RuntimeException("没有md5这个算法!"); + //throw new RuntimeException(SystemEnv.getHtmlLabelName(517545,userLanguage)); + } + //将加密后的数据转换为16进制数字 + String md5code = new BigInteger(1, secretBytes).toString(16); + // 如果生成数字未满32位,需要前面补0 + // 不能把变量放到循环条件,值改变之后会导致条件变化。如果生成30位 只能生成31位md5 + int tempIndex = 32 - md5code.length(); + for (int i = 0; i < tempIndex; i++) { + md5code = "0" + md5code; + } + return md5code; + } + + public static String getCurrentTime() { + Date newdate = new Date(); + long datetime = newdate.getTime(); + Timestamp timestamp = new Timestamp(datetime); + String currenttime = (timestamp.toString()).substring(11, 13) + ":" + (timestamp.toString()).substring(14, 16) + ":" + + (timestamp.toString()).substring(17, 19); + return currenttime; + } + + public static String getCurrentDate() { + Date newdate = new Date(); + long datetime = newdate.getTime(); + Timestamp timestamp = new Timestamp(datetime); + String currentdate = (timestamp.toString()).substring(0, 4) + "-" + (timestamp.toString()).substring(5, 7) + "-" + + (timestamp.toString()).substring(8, 10); + return currentdate; + } + + /** + * 获取当前日期时间。 YYYY-MM-DD HH:MM:SS + * @return 当前日期时间 + */ + public static String getCurDateTime() { + Date newdate = new Date(); + long datetime = newdate.getTime(); + Timestamp timestamp = new Timestamp(datetime); + return (timestamp.toString()).substring(0, 19); + } + + /** + * 获取时间戳 格式如:19990101235959 + * @return + */ + public static String getTimestamp(){ + return getCurDateTime().replace("-", "").replace(":", "").replace(" ", ""); + } + + public static String doAction(Map paramDatajson,String url,String method){ + String resultstr=""; + try{ + OkHttpClient client = new OkHttpClient().newBuilder() + .build(); + MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); + new BaseBean().writeLog("json==>"+ JSON.toJSONString(paramDatajson)); + + RequestBody body = RequestBody.create(mediaType, "datajson="+ JSON.toJSONString(paramDatajson)); + + Request request = new Request.Builder() + .url(url) + .method(method, body) + .addHeader("Content-Type", "application/x-www-form-urlencoded") + .build(); + Response result = client.newCall(request).execute(); + resultstr = result.body().string(); + + }catch (Exception e){ + new BaseBean().writeLog("请求失败"+getCurrentDate()+" "+getCurrentDate()+"====errormsg:"+e.getMessage()); + } + return resultstr; + } + + /** + * 传入两个时间范围,返回这两个时间范围内的所有日期,并保存在一个集合中 + * + * @param beginTime + * @param endTime + * @return + * @throws Exception + */ + public static List findEveryDay(String beginTime, String endTime) + throws Exception { + //创建一个放所有日期的集合 + List dates = new ArrayList(); + + //创建时间解析对象规定解析格式 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + + //将传入的时间解析成Date类型,相当于格式化 + Date dBegin = sdf.parse(beginTime); + Date dEnd = sdf.parse(endTime); + + //将格式化后的第一天添加进集合 + dates.add(sdf.format(dBegin)); + + //使用本地的时区和区域获取日历 + Calendar calBegin = Calendar.getInstance(); + + //传入起始时间将此日历设置为起始日历 + calBegin.setTime(dBegin); + + //判断结束日期前一天是否在起始日历的日期之后 + while (dEnd.after(calBegin.getTime())) { + + //根据日历的规则:月份中的每一天,为起始日历加一天 + calBegin.add(Calendar.DAY_OF_MONTH, 1); + + //得到的每一天就添加进集合 + dates.add(sdf.format(calBegin.getTime())); + //如果当前的起始日历超过结束日期后,就结束循环 + } + return dates; + } + + public String createHrToken() throws Exception{ + String accessToken=""; + OkHttpClient client = new OkHttpClient().newBuilder().build(); + String clientId =getSystemParamValue("eyhrclientId"); + String appId =getSystemParamValue("eyhrappId"); + String appSecret =getSystemParamValue("eyhrappSecret"); + String hrsynccreatetokenurl =getSystemParamValue("hrsynccreatetokenurl"); + String hrsyncaddress =getSystemParamValue("hrsyncaddress"); + Mapparams =new HashMap (); + params.put("clientId",clientId); + params.put("appId",appId); + params.put("appSecret",appSecret); + MediaType mediaType = MediaType.parse("application/json"); + RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(params)); + Request request = new Request.Builder() + .url(hrsyncaddress+hrsynccreatetokenurl) + .method("POST", body) + .addHeader("Content-Type", "application/json") + .build(); + Response response = client.newCall(request).execute(); + if (response.isSuccessful()) { + Result result = Result.success(Objects.requireNonNull(response.body()).string()); + if (result.isOk()) { + JSONObject data = JSON.parseObject(result.getContent()); + String code = Objects.requireNonNull(data).getString("code"); + String msg = Objects.requireNonNull(data).getString("msg"); + if(code.equals("0")){ + // 将组织机构数据封装至List + accessToken = Objects.requireNonNull(data).getJSONObject("data").getString("accessToken"); + //new BaseBean().writeLog("Token授权==>"+accessToken); + }else{ + //new BaseBean().writeLog("Token授权异常,code==>"+code+",msg==>"+msg); + } + } + } + //new BaseBean().writeLog("Token授权,accessToken==>"+accessToken); + return accessToken; + } + + public String createToken(String clientId,String appId,String appSecret,String address,String tokenurl) throws Exception{ + String accessToken=""; + OkHttpClient client = new OkHttpClient().newBuilder().build(); + Mapparams =new HashMap (); + params.put("clientId",clientId); + params.put("appId",appId); + params.put("appSecret",appSecret); + MediaType mediaType = MediaType.parse("application/json"); + RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(params)); + Request request = new Request.Builder() + .url(address+tokenurl) + .method("POST", body) + .addHeader("Content-Type", "application/json") + .build(); + Response response = client.newCall(request).execute(); + if (response.isSuccessful()) { + Result result = Result.success(Objects.requireNonNull(response.body()).string()); + if (result.isOk()) { + JSONObject data = JSON.parseObject(result.getContent()); + String code = Objects.requireNonNull(data).getString("code"); + String msg = Objects.requireNonNull(data).getString("msg"); + if(code.equals("0")){ + // 将组织机构数据封装至List + accessToken = Objects.requireNonNull(data).getJSONObject("data").getString("accessToken"); + //new BaseBean().writeLog("Token授权==>"+accessToken); + }else{ + //new BaseBean().writeLog("Token授权异常,code==>"+code+",msg==>"+msg); + } + } + } + //new BaseBean().writeLog("Token授权,accessToken==>"+accessToken); + return accessToken; + } + + /** + * 获取当前人所能看到所有数据 + */ + public String getEyCustomRigthSql(int userid,String tablename){ + String returnStr = " select id from "+tablename+" where "; + String matchsql ="select * from uf_stand_match_conf where tablename=?"; + RecordSet recordSet=new RecordSet(); + recordSet.executeQuery(matchsql,tablename); + if(recordSet.next()){ + try { + ResourceComInfo resourceComInfo=new ResourceComInfo(); + String workcode=resourceComInfo.getWorkcode(userid+"");//员工工号 + String currentroleids =getUserAllRole(userid);//获取当前人员所有角色id + String georegion_fieldname =Util.null2String(recordSet.getString("georegion_fieldname")); + String legalentity_fieldname =Util.null2String(recordSet.getString("legalentity_fieldname")); + String type_fieldname =Util.null2String(recordSet.getString("type_fieldname")); + String codeblock_fieldname =Util.null2String(recordSet.getString("codeblock_fieldname")); + String engagementcode_fieldname =Util.null2String(recordSet.getString("engagementcode_fieldname")); + //业务维度 + if(StringUtil.isNotBlank(codeblock_fieldname)){ + String codeblocksql = getEyCodeBlockRightSql(workcode,codeblock_fieldname); + if(StringUtil.isNotBlank(codeblocksql)){ + returnStr =returnStr+codeblocksql; + } + } + //3.1先查询中间匹配表-firm + //判断台账中间表是否配置完全 + if(StringUtil.isNotBlank(georegion_fieldname)&&StringUtil.isNotBlank(legalentity_fieldname)) { + String firmsql = getEyfirmRightSql(type_fieldname,georegion_fieldname, legalentity_fieldname, currentroleids); + if (StringUtil.isNotBlank(firmsql)) { + returnStr = returnStr + firmsql; + } + } + //3.2先查询中间匹配表-gds + if(StringUtil.isNotBlank(type_fieldname)) { + String typesql =getEyGdsRightSql(type_fieldname,currentroleids); + if(StringUtil.isNotBlank(typesql)){ + returnStr = returnStr + typesql; + } + } + writeLog("getEyCustomRigthSql,returnStr==>"+returnStr); + } catch (Exception e) { + e.printStackTrace(); + } + } + + return returnStr; + } + + /** + *业务维度权限 + */ + public String getEyCodeBlockRightSql(String workcode,String codeblock_fieldname){ + String result=""; + //1、项目卡片中所有成员 + String codeblocksql ="select codeblock from uf_xmjbxxjmbd where id in (" + + "select mainid from uf_xmjbxxjmbd_dt2 where role_gpn='"+workcode+"' " + + ")"; + //2、通过第三接口获取公司高层维护的codeblock + codeblocksql = codeblocksql +" union " + + " select codeblock from uf_permisson_conf_business where gpn='"+workcode+"' "; + result = " ( "+codeblock_fieldname+" in ("+codeblocksql+") ) or"; + writeLog("codeblocksql==>"+codeblocksql); + return result; + } + + /** + *FIRM财务维度权限 + */ + public String getEyfirmRightSql(String type_fieldname,String georegion_fieldname,String legalentity_fieldname,String currentroleids) { + String result=""; + RecordSet rs =new RecordSet(); + String firmrolesql =" select legalentity,georegion,roleids from uf_permissionconfig where isopen=0"; + rs.executeQuery(firmrolesql,new Object[0]); + List> firmmatchlist =new ArrayList >(); + while(rs.next()){ + String roleids =Util.null2String(rs.getString("roleids")); + String legalentity =Util.null2String(rs.getString("legalentity")); + String georegion =Util.null2String(rs.getString("georegion")); + //判断规则中间表是否配置完全 + if(!legalentity.equals("")&&!georegion.equals("")){ + String[] currentroleidarry =currentroleids.split(","); + //判断当前用户所有角色与规则表的角色是否匹配 + for(String roleid:currentroleidarry){ + if((","+roleid+",").indexOf(","+roleids+",")>=0){ + //legalentity和georegion封装 + HashMap rolematch =new HashMap (); + rolematch.put("legalentity",legalentity); + rolematch.put("georegion",georegion); + firmmatchlist.add(rolematch); + break; + } + } + } + } + //遍历legalentity和georegion封装的map 转换sql + if(firmmatchlist.size()>0){ + for(Map match:firmmatchlist){ + String type =Util.null2String(match.get("type")); + String legalentity =Util.null2String(match.get("legalentity")); + String georegion =Util.null2String(match.get("georegion")); + if(StringUtil.isNotBlank(type)){ + String firmsql =""; + String lesql = legalentity_fieldname + " in ("; + String geosql = georegion_fieldname + " in ("; + String[] typearry =type.split(","); + for(String t:typearry){ + firmsql =firmsql+type_fieldname+"='"+t+"' and"; + if(StringUtil.isNotBlank(legalentity)){ + String[] legalentityarry =legalentity.split(","); + for(String le:legalentityarry){ + lesql =lesql+"'"+le+"',"; + } + lesql=lesql.substring(0,lesql.length()-1)+")"; + firmsql =firmsql+lesql+" and"; + } + + if(StringUtil.isNotBlank(georegion)){ + String[] georegionarry =georegion.split(","); + for(String geo:georegionarry){ + geosql =geosql+"'"+geo+"',"; + } + geosql=geosql.substring(0,geosql.length()-1)+")"; + firmsql =firmsql+geosql+" and"; + } + } + result =result+"("+firmsql.substring(0,firmsql.length()-3)+")or"; + } + } + } + writeLog("result==>"+result); + return result; + } + + /** + *GDS财务维度权限 + */ + public String getEyGdsRightSql(String type_fieldname,String currentroleids){ + String result =""; + List> gdsmatchlist =new ArrayList >(); + RecordSet rs =new RecordSet(); + String gdsrolesql =" select type,legalentity,roleids from uf_permisson_conf_gds where isopen=0 "; + rs.executeQuery(gdsrolesql,new Object[0]); + while(rs.next()){ + String roleids =Util.null2String(rs.getString("roleids")); + String type =Util.null2String(rs.getString("type")); + if(!type.equals("")){ + String[] currentroleidarry =currentroleids.split(","); + //判断当前用户所有角色与规则表的角色是否匹配 + for(String roleid:currentroleidarry){ + if((","+roleid+",").indexOf(","+roleids+",")>=0){ + //legalentity和georegion封装 + HashMap rolematch =new HashMap (); + rolematch.put("type",type); + gdsmatchlist.add(rolematch); + break; + } + } + } + } + if(gdsmatchlist.size()>0){ + Set typeset =new HashSet(); + for(Map match:gdsmatchlist){ + String type =Util.null2String(match.get("type")); + String[] typearry =type.split(","); + for(String value:typearry){ + typeset.add(value); + } + } + for(String s:typeset){ + result =result + "("+type_fieldname+"='"+s+"') or"; + } + } + return result; + } + + public Map getConfidentialInfo(String opprCode,String paceFolderId,String clientId){ + Map result =new HashMap <>(); + String eventKey = "checkopportunitypaceandclient"; //事件标识 + Map body =new HashMap (); + Map params =new HashMap (); + List> reqdata =new ArrayList <>(); + params.put("opprCode",opprCode); + params.put("paceFolderId",paceFolderId); + params.put("clientId",clientId); + reqdata.add(params); + body.put("body",reqdata); + String paramsstr = JSON.toJSONString(body); //事件请求参数 + //EsbService其他方法及说明见ESB API接口说明文档 + EsbService service = EsbClient.getService(); //获取 ESB 服务 + String clientdetailjsonstr = service.execute(eventKey, paramsstr); + new BaseBean().writeLog("getConfidentialInfo,JsonStr==>"+clientdetailjsonstr); + if(StringUtils.isNotBlank(clientdetailjsonstr)){ + JSONObject jsonObject=JSON.parseObject(clientdetailjsonstr); + JSONArray resultdata =jsonObject.getJSONObject("data").getJSONArray("data"); + String errorStr =""; + String isConfidential ="1"; + for(int i=0;i0) { + for (int j = 0; j < opprsIsConfidential.size(); j++) { + String isConfidentialflag =Util.null2String(opprsIsConfidential.getJSONObject(j).getString("isConfidential")); + if (isConfidentialflag.equals("true")) { + isConfidential = "0"; + } + } + } + } + result.put("errorstr",errorStr); + result.put("isConfidential",isConfidential); + } + return result; + } + + public boolean getLegalEffective(String bucode,String oucode,String mucode,String smucode){ + boolean result =false; + String eventKey = "getLegalEffective"; //事件标识 + Map params =new HashMap (); + params.put("buCode",bucode); + params.put("ouCode",oucode); + params.put("muCode",mucode); + params.put("smuCode",smucode); + String paramsstr = JSON.toJSONString(params); //事件请求参数 + //EsbService其他方法及说明见ESB API接口说明文档 + EsbService service = EsbClient.getService(); //获取 ESB 服务 + String clientdetailjsonstr = service.execute(eventKey, paramsstr); + new BaseBean().writeLog("clientdetailjsonstr,getLegalEffective==>"+clientdetailjsonstr); + + if (StringUtils.isNotBlank(clientdetailjsonstr)) { + JSONObject jsonObject = JSON.parseObject(clientdetailjsonstr); + JSONObject resultdata = jsonObject.getJSONObject("data").getJSONObject("data"); + result = resultdata.getBoolean("isLegal"); + } + + return result; + } + + /** + * 获取预算信息 + * @param eventKey 事件key + * @param eventKey primaryKey + */ + public Map getBudgetInfo(String eventKey,String primaryKey){ + Map result =new HashMap <>(); + //事件标识 + Map params_mmt =new HashMap (); + params_mmt.put("PrimaryKey",primaryKey); + String paramsstr_mmt = JSON.toJSONString(params_mmt); //事件请求参数 + //EsbService其他方法及说明见ESB API接口说明文档 + EsbService service = EsbClient.getService(); //获取 ESB 服务 + String mmtdetailjsonstr = service.execute(eventKey, paramsstr_mmt); + new BaseBean().writeLog("getBudgetInfo===>"+mmtdetailjsonstr); + if(StringUtils.isNotBlank(mmtdetailjsonstr)){ + JSONObject jsonObject=JSON.parseObject(mmtdetailjsonstr); + if(jsonObject.getJSONObject("data").getJSONArray("list")!=null) { + JSONObject resultdata = jsonObject.getJSONObject("data").getJSONArray("list").getJSONObject(0); + if (eventKey.equals("smarthubbudgetdetail")) { + String startDate =Util.null2String(resultdata.getString("startDate")); + String closeDate =Util.null2String(resultdata.getString("closeDate")); + if(!startDate.equals("")){ + result.put("estimated_start_date", startDate.substring(0,10)); + }else{ + result.put("estimated_start_date", ""); + } + if(!closeDate.equals("")){ + result.put("estimated_close_date", closeDate.substring(0,10)); + }else{ + result.put("estimated_close_date", ""); + } + + } else { + result.put("estimated_start_date", formatDate(resultdata.getString("estimatedStartDate"))); + result.put("estimated_close_date", formatDate(resultdata.getString("estimatedEndDate"))); + } + if (eventKey.equals("smarthubbudgetdetail")) { + result.put("eaf", formatDouble(Util.null2String(resultdata.getString("eaf")))); + } else { + result.put("eaf", formatDouble(Util.null2String(resultdata.getString("engagementAdjustedFactor")))); + } + result.put("standard_engagement_revenue", resultdata.getString("ser")); + result.put("net_engagement_revenue", resultdata.getString("ner")); + if (eventKey.equals("smarthubbudgetdetail")) { + result.put("current_year_total_revenue", formatDouble(Util.null2String(resultdata.getString("ter")))); + } else { + result.put("current_year_total_revenue", Util.null2String(resultdata.getString("currentFyTer"))); + } + result.put("total_revenue", Util.null2String(resultdata.getString("ter"))); + if (eventKey.equals("smarthubbudgetdetail")) { + result.put("margin", "0.00"); + } else { + result.put("margin", formatDouble(Util.null2String(resultdata.getString("marginPercent")))); + } + if (eventKey.equals("smarthubbudgetdetail")) { + result.put("partner_involvement", formatDouble(Util.null2String(resultdata.getString("partnerInvolvement")))); + } else { + result.put("partner_involvement", formatDouble(Util.null2String(resultdata.getString("partnerLeverage")))); + } + result.put("erp1", formatDouble(Util.null2String(resultdata.getString("erp")))); + result.put("realization", formatDouble(Util.null2String(resultdata.getString("erp")))); + + String expenses =Util.null2String(resultdata.getString("totalExpense")); + if(expenses.equals("")){ + expenses ="0.00"; + } + result.put("expenses",expenses); + if (eventKey.equals("smarthubbudgetdetail")) { + result.put("margin1", "0.00"); + } else { + result.put("margin1", resultdata.getString("margin")); + } + if (eventKey.equals("smarthubbudgetdetail")) { + result.put("total_cost", "0.00"); + } else { + result.put("total_cost", Util.null2String(resultdata.getString("stdCost"))); + } + String hours =Util.null2String(resultdata.getString("totalHours")); + if(hours.equals("")){ + hours ="0.00"; + } + + result.put("hours",hours ); + } + new BaseBean().writeLog(JSON.toJSONString(result)); + } + return result; + } + + /** + * 获取客户信息 + * @param clientId 客户id + */ + public Map getCustomInfo(String clientId){ + Map result =new HashMap <>(); + String eventKey = "clientdetail"; //事件标识 + Map params =new HashMap (); + params.put("clientId",clientId); + String paramsstr = JSON.toJSONString(params); //事件请求参数 + //EsbService其他方法及说明见ESB API接口说明文档 + EsbService service = EsbClient.getService(); //获取 ESB 服务 + String clientdetailjsonstr = service.execute(eventKey, paramsstr); + + + String clientScope =""; + String chineseName =""; + new BaseBean().writeLog("clientdetailjsonstr,getCustomInfo==>"+clientdetailjsonstr); + if(StringUtils.isNotBlank(clientdetailjsonstr)){ + JSONObject jsonObject=JSON.parseObject(clientdetailjsonstr); + String returncode =jsonObject.getString("code"); + if(returncode.equals("100")){ + JSONObject resultdata =jsonObject.getJSONObject("data").getJSONObject("result"); + clientScope =Util.null2String(resultdata.getString("clientScope")); + //chineseName =Util.null2String(resultdata.getString("chineseName")); + chineseName =Util.null2String(resultdata.getString("englishName")); + result.put("client_name",chineseName); + if(clientScope.equals("100")){ + result.put("client_type","0"); + }else if (clientScope.equals("101")){ + result.put("client_type","1"); + }else if (clientScope.equals("102")){ + result.put("client_type","2"); + } + } + result.put("code",returncode); + }else{ + result.put("code","-1"); + result.put("client_name",""); + result.put("client_type",""); + } + new BaseBean().writeLog("getCustomInfo,returnmap==>"+JSON.toJSONString(result)); + return result; + } + + private static String formatDouble(String value){ + String result=""; + if(value.equals("")){ + result ="0.00"; + }else{ + BigDecimal bigDecimal =new BigDecimal(value); + result = bigDecimal.divide(new BigDecimal(100)).toString(); + + } + return result; + } + + private static String formatDate(String datestr){ + long time = Long.parseLong(datestr); + Date date = new Date(time); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + String str = dateFormat.format(date); + return str; + } + + public static boolean vaildateImportEnagementName(String engagementname,String global_service_code){ + boolean flag=false; + if(engagementname.equals("")||global_service_code.equals("")){ + return flag; + } + RecordSet recordSet1=new RecordSet(); + String perfix = engagementname.substring(0, 3); + recordSet1.executeQuery("select id from uf_mcgzb where global_service_code=? and mcgz=?",global_service_code,perfix); + if(recordSet1.next()){ + flag =true; + } + return flag; + } + + public static String removespace(String resource) + { + char ch=' '; + return remove(resource,ch); + } + + public static String remove(String resource,char ch) + { + StringBuffer buffer=new StringBuffer(); + int position=0; + char currentChar; + while(position getExchargeRate(BigDecimal decimal, String fromCurrency,String toCurrency,String codeblock, String a){ + RecordSet rs = new RecordSet(); + //rs.executeQuery(""); + return new HashMap<>(); + } + /** + * 校验用户是否存在 + * @param workcode + * @return + */ + public boolean validateUser(String workcode){ + RecordSet rs = new RecordSet(); + rs.executeQuery("select id from hrmresource where workcode=?,workcode"); + return rs.getCounts()>0; + } /** * 校验EM、EP rank * @param gpn @@ -40,12 +55,14 @@ public class EYSeconddevUtil extends BaseBean { if(rs.next()){ userId=Util.null2String(rs.getString(1)); } + writeLog("validateEngagementRoleRank>>>>gpn:"+gpn); // 查询rank String rank=""; rs.executeQuery("select concat(field2,field24) from cus_fielddata scope='HrmCustomFieldByInfoType' and scopeid=-1 and id=?",userId); if(rs.next()){ rank=Util.null2String(rs.getString(1)); } + writeLog("validateEngagementRoleRank>>>>rank:"+rank); // 校验rank rs.executeQuery("select id from uf_xmjsrankjyb where rankcode=? and mark=? and role=?",rank,mark,role); return rs.getCounts()>0; diff --git a/src/main/java/weaver/weilin/zhu/asc/workflow/VoucherPushAction.java b/src/main/java/weaver/weilin/zhu/asc/workflow/VoucherPushAction.java new file mode 100644 index 0000000..685b620 --- /dev/null +++ b/src/main/java/weaver/weilin/zhu/asc/workflow/VoucherPushAction.java @@ -0,0 +1,104 @@ +package weaver.weilin.zhu.asc.workflow; + +import aiyh.utils.Util; +import aiyh.utils.httpUtil.HttpArgsType; +import aiyh.utils.httpUtil.ResponeVo; +import aiyh.utils.httpUtil.util.HttpUtils; +import com.alibaba.fastjson.JSONObject; +import org.apache.log4j.Logger; +import weaver.file.Prop; +import weaver.weilin.zhu.common.util.CommonUtil; +import weaver.weilin.zhu.common.voucher.action.CusActionPostInterface; +import weaver.weilin.zhu.common.voucher.action.ResultMessageUtil; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +/** + * ASC 精品酒店 + * JSON数据推送 NC 接口操作,通用凭证Action后置方法 + * @author bleach + * @version v1.0 2023-07-10 + */ +public class VoucherPushAction implements CusActionPostInterface { + + /** + * 日志操作类 + */ + private final Logger logger = Util.getLogger(); + + + + /** + * 后置处理方法 + * + * @param params 后置处理器参数 + * @return 处理后返回值 + */ + @SuppressWarnings("unchecked") + @Override + public ResultMessageUtil postProcessor(Map params) { + ResultMessageUtil resultMessageUtil = new ResultMessageUtil(); + + JSONObject postObj = (JSONObject) params.get("pushJsonObject"); + Map workflowBaseMap = (Map) params.get("workflowBaseMap"); + Map pathParam = (Map) params.get("pathParam"); + + + Map logMap = new HashMap<>(); + logMap.put("rid",workflowBaseMap.get("requestId")); + logMap.put("interface_name",Util.null2String(pathParam.get("pathParam"))); + logMap.put("system_name",Util.null2String(pathParam.get("system_name"))); + logMap.put("systemCode",Util.null2String(pathParam.get("systemCode"))); + + + //获取接口请求地址 + String requestURL = Util.null2String(Prop.getPropValue("AscVoucher", "url")); + + Map headerMap = new HashMap<>(); + headerMap.put("Content-Type", HttpArgsType.APPLICATION_JSON); + + HttpUtils httpUtils = new HttpUtils(); + + try { + //进行接口数据推送 + ResponeVo responeVo = httpUtils.apiPostObject(requestURL, postObj, headerMap); + + if(responeVo != null && responeVo.getCode() == 200){ + logMap.put("message",responeVo.getEntityString()); + + //接口返回所有信息 + resultMessageUtil.setResponseBody(responeVo.getEntityString()); + + Map resultMap = responeVo.getResponseMap(); + + if(resultMap != null){ + String state = Util.null2String(resultMap.get("state")); + + resultMessageUtil.setSuccess("1".equals(state)); + + logMap.put("result","1".equals(state) ? 0 : 1); + + } else { + logMap.put("result",1); + logMap.put("message","接口返回信息为空!"); + } + } else { + logMap.put("result",1); + logMap.put("message","接口返回信息为空或者请求失败!"); + } + } catch (IOException e) { + logger.error("接口请求异常,异常信息:[" + e.getMessage() + "]"); + logMap.put("result",1); + logMap.put("message","接口请求异常,异常信息:[" + e.getMessage() + "]!"); + throw new RuntimeException(e); + } + + int modeid = Util.getIntValue(Prop.getPropValue("global", "interfacelog_modeid")); + + CommonUtil.insertNewDataToMode(modeid,"uf_interface_log",logMap); + + return resultMessageUtil; + } +} diff --git a/src/main/java/weaver/weilin/zhu/common/util/CommonUtil.java b/src/main/java/weaver/weilin/zhu/common/util/CommonUtil.java new file mode 100644 index 0000000..df75aa8 --- /dev/null +++ b/src/main/java/weaver/weilin/zhu/common/util/CommonUtil.java @@ -0,0 +1,100 @@ +package weaver.weilin.zhu.common.util; + +import aiyh.utils.Util; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.weilin.zhu.common.util.mapper.CommonSqlMapper; + +import java.util.Map; + +/** + * 通用的工具类型 + */ +public class CommonUtil { + + + /** + * 获取数据库操作接口 + */ + private static final CommonSqlMapper sqlMapper = Util.getMapper(CommonSqlMapper.class); + + /** + * 获取字段详细信息 + * @param fieldId 字段ID + * @return 字段详细信息 + */ + public static FieldDetailInfo getFieldDetailInfo(int fieldId){ + FieldDetailInfo fieldDetailInfo = new FieldDetailInfo(); + + if(fieldId != 0) { + RecordSet rs = new RecordSet(); + + String selectSQL = "select id,fieldName,viewType,detailTable,fieldDbType from workflow_billField where id = ?"; + + if (rs.executeQuery(selectSQL, fieldId) && rs.next()) { + //字段数据库名称 + String fieldName = Util.null2String(rs.getString("fieldName")); + //字段所属 + int viewType = Util.getIntValue(rs.getString("viewType"),0); + //字段明细表名称 + String detailTable = Util.null2String(rs.getString("detailTable")); + //字段数据库类型 + String fieldDbType = Util.null2String(rs.getString("fieldDbType")); + + + fieldDetailInfo.setId(fieldId); + fieldDetailInfo.setFieldName(fieldName); + fieldDetailInfo.setDetailTable(detailTable); + fieldDetailInfo.setDbType(fieldDbType); + + if(viewType == 1 && !"".equals(detailTable)){ + int detailIndex = Util.getIntValue(detailTable.substring(detailTable.indexOf("_dt") + 3),-1); + + fieldDetailInfo.setDetailIndex(detailIndex); + } else { + fieldDetailInfo.setDetailIndex(0); + } + } + } + + return fieldDetailInfo; + } + + + /** + * 根据模块表名称 获取其对应的模块ID (可以预见的BUG:若一个表被多个模块引用,则会出问题) + * @param modeTableName 模块表名称 + * @return 模块ID + */ + public static int getModeIdByTableName(String modeTableName) { + return sqlMapper.getModeIdByTableName(modeTableName); + } + + /** + * 往建模中写入新的记录 + * @param modeId 模块ID + * @param modeTableName 模块表名称 + * @param dataMap 数据集 + */ + public static void insertNewDataToMode(int modeId,String modeTableName, Map dataMap){ + //获取新的记录ID + int newDataId = Util.getModeDataId(modeTableName,modeId,1); + + if(newDataId > 0){ + StringBuilder updateSql = new StringBuilder(); + updateSql.append("update ").append(modeTableName).append(" set modeDataModifyDatetime = '").append(TimeUtil.getCurrentTimeString()).append("'"); + + for(String key : dataMap.keySet()){ + updateSql.append(",").append(key).append("=?"); + } + + updateSql.append(" where id = #{id}"); + + dataMap.put("id",newDataId); + + if(sqlMapper.insertModeData(updateSql.toString(),dataMap)){ + sqlMapper.deleteRedundancyData(modeTableName,newDataId); + } + } + } +} diff --git a/src/main/java/weaver/weilin/zhu/common/util/FieldDetailInfo.java b/src/main/java/weaver/weilin/zhu/common/util/FieldDetailInfo.java new file mode 100644 index 0000000..9437abd --- /dev/null +++ b/src/main/java/weaver/weilin/zhu/common/util/FieldDetailInfo.java @@ -0,0 +1,42 @@ +package weaver.weilin.zhu.common.util; + +import lombok.Data; + +/** + * 字段详细信息实体类 + * @author bleach + * @version 2023-07-10 + */ +@Data +public class FieldDetailInfo { + + /** + * 字段ID + */ + private int id; + + /** + * 字段名称 + */ + private String fieldName; + + /** + * 字段所属 0-主表 1-明细表 + */ + private int viewType; + + /** + * 明细表名称 + */ + private String detailTable; + + /** + * 字段存储数据库类型 + */ + private String dbType; + + /** + * 所属明细表下标 + */ + private int detailIndex; +} diff --git a/src/main/java/weaver/weilin/zhu/common/util/mapper/CommonSqlMapper.java b/src/main/java/weaver/weilin/zhu/common/util/mapper/CommonSqlMapper.java new file mode 100644 index 0000000..750e8a8 --- /dev/null +++ b/src/main/java/weaver/weilin/zhu/common/util/mapper/CommonSqlMapper.java @@ -0,0 +1,42 @@ +package weaver.weilin.zhu.common.util.mapper; + +import aiyh.utils.annotation.recordset.*; + +import java.util.Map; + +/** + * 通用工具类 操作数据库接口 + * @author bleach + * @version 2023-07-12 + */ +public interface CommonSqlMapper { + + /** + * 根据模块表名称 获取其对应的模块ID (可以预见的BUG:若一个表被多个模块引用,则会出问题) + * @param tableName 模块表名称 + * @return 模块ID + */ + @Select("select m.id from modeInfo m inner join workflow_bill wb on m.formId = wb.id where lower(wb.tableName) = #{tableName}") + int getModeIdByTableName(@ParamMapper("tableName") String tableName); + + + /** + * 更新建模数据 + * @param updateSql 更新的SQL语句 + * @param dataMap 数据集 + * @return 更新结果 + */ + @Update(custom = true) + boolean insertModeData(@SqlString String updateSql, Map dataMap); + + + + /** + * 删除建模数据 + * @param tableName 表单名称 + * @param dataId 数据ID + * @return 更新结果 + */ + @Delete("delete from $t{tableName} where id = #{dataId}") + boolean deleteRedundancyData(@ParamMapper("tableName") String tableName, @ParamMapper("dataId") int dataId); +} diff --git a/src/main/java/weaver/weilin/zhu/common/voucher/action/CommonVoucherAction.java b/src/main/java/weaver/weilin/zhu/common/voucher/action/CommonVoucherAction.java new file mode 100644 index 0000000..7c6c3b0 --- /dev/null +++ b/src/main/java/weaver/weilin/zhu/common/voucher/action/CommonVoucherAction.java @@ -0,0 +1,230 @@ +package weaver.weilin.zhu.common.voucher.action; + +import aiyh.utils.Util; +import aiyh.utils.action.SafeCusBaseAction; +import aiyh.utils.annotation.ActionDefaultTestValue; +import aiyh.utils.annotation.PrintParamMark; +import aiyh.utils.annotation.RequiredMark; +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetTrans; +import weaver.hrm.User; +import weaver.soa.workflow.request.RequestInfo; +import weaver.weilin.zhu.common.voucher.entity.BaseConfigDao; +import weaver.weilin.zhu.common.voucher.util.CommonVoucherUtil; +import weaver.weilin.zhu.common.voucher.mapper.CommVoucherSqlMapper; +import weaver.zwl.common.ToolUtilNew; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; +import java.util.Map; + +/** + * 通用凭证Action入口 + * @author bleach + * @version 2023-07-10 + */ +public class CommonVoucherAction extends SafeCusBaseAction { + + /** + * 日志操作类 + */ + private final Logger logger = Util.getLogger(); + + /** + * SQL接口 + */ + private final CommVoucherSqlMapper sqlMapper = Util.getMapper(CommVoucherSqlMapper.class); + + /** + * 自定义参数值 + */ + private String cusParamValue; + + /** + * 后置实现类接口路径 + */ + @RequiredMark("具体接口请求实现接口类路径!") + @ActionDefaultTestValue("weaver.weilin.zhu.asc.workflow.VoucherPushAction") + @PrintParamMark + private String implementorPath; + + + + /** + *

action 提交流程业务处理方法

+ *

具体业务逻辑实现 + * 全局存在log成员变量,用于日志的输出 Util.actionFailException(requestManager,"error msg"); 用于提示action执行失败 + *

+ * + * @param requestId 流程请求ID + * @param billTable 流程对应主表名称 + * @param workflowId 流程对应流程ID + * @param user 当前节点操作者用户 + * @param requestInfo 请求管理对象 + */ + @Override + public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) { + logger.info("--------------- CommonVoucherAction Begin ---------------"); + + Map workflowBaseMap = getWorkflowBaseInfo(requestInfo.getRsTrans(),requestId); + + CommonVoucherUtil voucherUtil = new CommonVoucherUtil(); + + voucherUtil.setWorkflowBaseMap(workflowBaseMap); + + //自定义配置 + BaseConfigDao baseConfigDao = voucherUtil.getConfigurationByWorkflowId(String.valueOf(workflowId), cusParamValue); + + assert baseConfigDao != null; + + voucherUtil.setThisUser(user); + voucherUtil.setObjectMappingDaoList(baseConfigDao.getObjectMappingDaoList()); + voucherUtil.setNodeFieldMappingDaoList(baseConfigDao.getNodeFieldMappingDaoList()); + + RecordSet rs ; + + String dataCondition = baseConfigDao.getDataCondition(); + + if(StringUtils.isNotBlank(dataCondition)){ + rs = sqlMapper.getWorkflowMainTableInfoAndCondition(billTable,requestId, ToolUtilNew.staticToDBC(dataCondition)); + } else { + rs = sqlMapper.getWorkflowMainTableInfo(billTable,requestId); + } + + if(!rs.next()){ + logger.info("当前流程不满足自定义条件!"); + } + + workflowBaseMap.put("mainId",Util.null2String(rs.getString("id"))); + + //推送的报文 + JSONObject postJsonObj = new JSONObject(); + + StringBuilder postXmlObj = new StringBuilder(); + + if(baseConfigDao.getDataFormat() == 1){ + postXmlObj = voucherUtil.recursionGenerateXML("",null,null,0,0,0); + } else { + //推送的报文 + postJsonObj = voucherUtil.recursionGenerateJsonObject("",null,null,0,0,0); + } + + if(postJsonObj != null || postXmlObj.length() > 0){ + + if(StringUtils.isNotBlank(implementorPath)){ + Map pathParam = Util.parseCusInterfacePathParam(implementorPath); + String className = pathParam.remove("_ClassPath"); + + Map paramsMap = new HashMap<>(); + paramsMap.put("pushJsonObject",postJsonObj); + paramsMap.put("pushXmlObject",postXmlObj); + paramsMap.put("pathParam",pathParam); + paramsMap.put("requestInfo",requestInfo); + paramsMap.put("workflowBaseMap",workflowBaseMap); + paramsMap.put("userInfo",user); + + ResultMessageUtil resultMessageUtil = executePostProcessor(className,paramsMap); + + if(resultMessageUtil.isSuccess()){ + String backFieldname = baseConfigDao.getBackFieldname(); + + String backFieldValue = resultMessageUtil.getBackFieldValue(); + + sqlMapper.resultBackToWorkflowBill(billTable,backFieldname,backFieldValue,requestId); + } else { + //获取失败的错误提示 + String tipMessage = resultMessageUtil.getTipMessage(); + + if(baseConfigDao.getExceptionContinue() == 0){ + //阻止流程提交 + Util.actionFail(requestInfo.getRequestManager(),tipMessage); + } + } + } + } + + logger.info("--------------- CommonVoucherAction End ---------------"); + } + + /** + * 获取流程基础信息 + * @param trans 当前事务 + * @param requestId 流程请求ID + * @return 当前流程信息 + */ + private Map getWorkflowBaseInfo(RecordSetTrans trans,String requestId){ + Map baseInfo = new HashMap<>(); + + if(trans == null){ + trans = new RecordSetTrans(); + } + + String selectSQL = "select requestName,requestMark from workflow_requestBase where requestId = ?"; + + try { + if(trans.executeQuery(selectSQL,requestId) && trans.next()){ + baseInfo.put("requestName",Util.null2String(trans.getString(1))); + baseInfo.put("requestMark",Util.null2String(trans.getString(2))); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + + return baseInfo; + } + + + /** + * 执行自定义后置处理方法 + * + * @param className 全路径类名 + * @param params 参数 + * @return 返回值 + */ + private ResultMessageUtil executePostProcessor(String className, Map params) { + Class aClass; + try { + aClass = Class.forName(className); + } catch (ClassNotFoundException e) { + throw new IllegalArgumentException("未能找到自定义action接口处理方法:" + className); + } + Constructor constructor; + try { + constructor = aClass.getConstructor(); + } catch (NoSuchMethodException e) { + throw new IllegalArgumentException(className + "没有空参构造方法,无法获取构造方法对象!"); + } + if (!CusActionPostInterface.class.isAssignableFrom(aClass)) { + throw new IllegalArgumentException("自定义后置处理接口:" + className + " 不是" + + CusActionPostInterface.class.getName() + "的子类或实现类!"); + } + CusActionPostInterface o; + try { + o = (CusActionPostInterface) constructor.newInstance(); + } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { + throw new IllegalArgumentException("无法构造" + className + "对象!"); + } + return o.postProcessor(params); + } + + + public String getCusParamValue() { + return cusParamValue; + } + + public void setCusParamValue(String cusParamValue) { + this.cusParamValue = cusParamValue; + } + + public String getImplementorPath() { + return implementorPath; + } + + public void setImplementorPath(String implementorPath) { + this.implementorPath = implementorPath; + } +} diff --git a/src/main/java/weaver/weilin/zhu/common/voucher/action/CusActionPostInterface.java b/src/main/java/weaver/weilin/zhu/common/voucher/action/CusActionPostInterface.java new file mode 100644 index 0000000..762cdeb --- /dev/null +++ b/src/main/java/weaver/weilin/zhu/common/voucher/action/CusActionPostInterface.java @@ -0,0 +1,22 @@ +package weaver.weilin.zhu.common.voucher.action; + +import java.util.Map; + +/** + * 自定义接口操作 + * 通过配置动态生成了JSONObject或者XML信息 + * 该接口中拿到对应的信息进行后续操作 + * + * @author bleach + */ + +public interface CusActionPostInterface { + + /** + * 后置处理方法 + * + * @param params 后置处理器参数 + * @return 处理后返回值 + */ + ResultMessageUtil postProcessor(Map params); +} diff --git a/src/main/java/weaver/weilin/zhu/common/voucher/action/ResultMessageUtil.java b/src/main/java/weaver/weilin/zhu/common/voucher/action/ResultMessageUtil.java new file mode 100644 index 0000000..6d7f7dd --- /dev/null +++ b/src/main/java/weaver/weilin/zhu/common/voucher/action/ResultMessageUtil.java @@ -0,0 +1,32 @@ +package weaver.weilin.zhu.common.voucher.action; + +import lombok.Data; + +/** + * 自定义接口操作 + * 返回信息实体类 + */ +@Data +public class ResultMessageUtil { + + /** + * 是否调用成功 + */ + private boolean isSuccess; + + /** + * 提示消息说明 + */ + private String tipMessage; + + /** + * 接口返回信息 + */ + private String responseBody; + + /** + * 回写的字段值 + */ + private String backFieldValue; + +} diff --git a/src/main/java/weaver/weilin/zhu/common/voucher/convert/CusAsyncConvert.java b/src/main/java/weaver/weilin/zhu/common/voucher/convert/CusAsyncConvert.java new file mode 100644 index 0000000..99aa139 --- /dev/null +++ b/src/main/java/weaver/weilin/zhu/common/voucher/convert/CusAsyncConvert.java @@ -0,0 +1,21 @@ +package weaver.weilin.zhu.common.voucher.convert; + + +import weaver.weilin.zhu.common.voucher.entity.NodeFieldMappingDao; + +import java.util.Map; + +/** + * 自定义转换规则接口 + * @author bleach + */ +public interface CusAsyncConvert { + /** + * 自定义转换接口 + * @param dao 配置信息 + * @param param 自定义转换规则参数 + * @param pathParam 自定义接口路径 + * @return 转换后的值 + */ + String cusConvert(NodeFieldMappingDao dao, RuleMethodParam param, Map pathParam); +} diff --git a/src/main/java/weaver/weilin/zhu/common/voucher/convert/FieldChangeRuleMethod.java b/src/main/java/weaver/weilin/zhu/common/voucher/convert/FieldChangeRuleMethod.java new file mode 100644 index 0000000..15a6b83 --- /dev/null +++ b/src/main/java/weaver/weilin/zhu/common/voucher/convert/FieldChangeRuleMethod.java @@ -0,0 +1,213 @@ +package weaver.weilin.zhu.common.voucher.convert; + +import aiyh.utils.Util; +import aiyh.utils.annotation.MethodRuleNo; +import aiyh.utils.excention.CustomerException; +import com.google.common.base.Strings; +import org.apache.commons.lang3.StringUtils; +import weaver.general.TimeUtil; +import weaver.weilin.zhu.common.util.FieldDetailInfo; +import weaver.weilin.zhu.common.voucher.entity.NodeFieldMappingDao; +import weaver.zwl.common.ToolUtilNew; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; +import java.util.function.BiFunction; + +/** + * 流程字段转换规则处理 + * @author bleach + * @version 2023-07-04 + */ +public class FieldChangeRuleMethod { + + public static final Map> VALUE_RULE_FUNCTION = new HashMap<>(); + + static { + Class valueRuleMethodClass = FieldChangeRuleMethod.class; + Method[] methods = valueRuleMethodClass.getMethods(); + for (Method method : methods) { + if (method.isAnnotationPresent(MethodRuleNo.class)) { + MethodRuleNo annotation = method.getAnnotation(MethodRuleNo.class); + int value = annotation.value();//规则标识 + VALUE_RULE_FUNCTION.put(value, (config, map) -> { + try { + FieldChangeRuleMethod valueRuleMethod = new FieldChangeRuleMethod(); + return method.invoke(valueRuleMethod, config, map).toString(); + } catch (IllegalAccessException | InvocationTargetException e) { + throw new RuntimeException(e); + } + }); + } + } + } + + + /** + * 不转换 + * @param dao 流程字段配置信息 + * @param param 转换规则参数集合 + * @return 返回转换后的值 + */ + @MethodRuleNo(value = 0, desc = "不转换") + public String noChange(NodeFieldMappingDao dao, RuleMethodParam param) { + String fieldValue = ""; + FieldDetailInfo fieldInfo = dao.getWfField(); + + if(fieldInfo != null){ + String fieldName = fieldInfo.getFieldName();//字段名称 + + if(StringUtils.isNotBlank(fieldName)){ + int viewType = fieldInfo.getViewType(); + + if(viewType == 0){ + fieldValue = Util.null2String(param.getRs().getString(fieldName)); + } else if(viewType == 1 && param.getRs_detail() != null){ + fieldValue = Util.null2String(param.getRs_detail().getString(fieldName)); + } + + } + } + return fieldValue; + } + + /** + * 流程请求ID + * @param dao 明细配置 + * @param param 转换规则参数集合 + * @return 返回转换后的值 + */ + @MethodRuleNo(value = 1, desc = "流程请求ID") + public String workflowRequestId(NodeFieldMappingDao dao,RuleMethodParam param) { + return Util.null2String(param.getWorkflowBaseMap().get("requestId")); + } + + /** + * 流程请求标题 + * @param dao 明细配置 + * @param param 转换规则参数集合 + * @return 返回转换后的值 + */ + @MethodRuleNo(value = 2, desc = "流程请求标题") + public String workflowRequestTitle(NodeFieldMappingDao dao,RuleMethodParam param) { + return Util.null2String(param.getWorkflowBaseMap().get("requestName")); + } + + /** + * 流程请求编号 + * @param dao 明细配置 + * @param param 转换规则参数集合 + * @return 返回转换后的值 + */ + @MethodRuleNo(value = 3, desc = "流程请求编号") + public String workflowRequestMark(NodeFieldMappingDao dao,RuleMethodParam param) { + return Util.null2String(param.getWorkflowBaseMap().get("requestMark")); + } + + /** + * 系统日期 + * @param dao 明细配置 + * @param param 转换规则参数集合 + * @return 返回转换后的值 + */ + @MethodRuleNo(value = 4, desc = "系统日期") + public String systemDate(NodeFieldMappingDao dao,RuleMethodParam param) { + return TimeUtil.getCurrentDateString(); + } + + /** + * 系统日期时间 + * @param dao 明细配置 + * @param param 转换规则参数集合 + * @return 返回转换后的值 + */ + @MethodRuleNo(value = 5, desc = "系统日期时间") + public String systemDateTime(NodeFieldMappingDao dao,RuleMethodParam param) { + return TimeUtil.getCurrentTimeString(); + } + + /** + * 固定值 + * @param dao 明细配置 + * @param param 转换规则参数集合 + * @return 返回转换后的值 + */ + @MethodRuleNo(value = 6, desc = "固定值") + public String fixValue(NodeFieldMappingDao dao,RuleMethodParam param) { + return Util.null2String(dao.getCusSQL()); + } + + /** + * 明细序列 + * @param dao 明细配置 + * @param param 转换规则参数集合 + * @return 返回转换后的值 + */ + @MethodRuleNo(value = 7, desc = "明细序列") + public String getDetailRowNum(NodeFieldMappingDao dao,RuleMethodParam param) { + return Util.null2String(param.getRowNum()); + } + + + /** + * 自定义SQL转换 + * @param dao 明细配置 + * @param param 转换规则参数集合 + * @return 返回转换后的值 + */ + @MethodRuleNo(value = 8, desc = "自定义SQL") + public String customizeSQL(NodeFieldMappingDao dao,RuleMethodParam param) { + String fieldName = dao.getNodeName();//字段名称 + + //字段值 + String fieldValue = noChange(dao,param); + + String cusSQL = dao.getCusSQL(); + + int detailKeyId = -1; + if(StringUtils.isNotBlank(cusSQL)){ + if( cusSQL.contains("{dt.id}") && param.getRs_detail() != null) { + detailKeyId = Util.getIntValue(param.getRs_detail().getString("id"), -1); + } + + if(param.getThisUser() != null){ + cusSQL = cusSQL.replace("{userId}", String.valueOf(param.getThisUser().getUID())); + + cusSQL = cusSQL.replace("{departmentId}", String.valueOf(param.getThisUser().getUserDepartment())); + + cusSQL = cusSQL.replace("{subCompanyId}", String.valueOf(param.getThisUser().getUserSubCompany1())); + } + } + + fieldValue = ToolUtilNew.getStaticValueByChangeRule(cusSQL,fieldValue,Util.null2String(param.getWorkflowBaseMap().get("requestId")),detailKeyId); + + return fieldValue; + } + + /** + * 自定义转换接口 + * @param dao 明细配置 + * @param param 转换规则参数集合 + * @return 返回转换后的值 + */ + @MethodRuleNo(value = 9, desc = "自定义接口") + public String getCusConvertInterface(NodeFieldMappingDao dao, RuleMethodParam param) { + String cusText = dao.getCusSQL(); + if(Strings.isNullOrEmpty(cusText)){ + return null; + } + try { + Class clazz = Class.forName(cusText); + if(!CusAsyncConvert.class.isAssignableFrom(clazz)){ + throw new CustomerException(cusText + " 接口不存在或者未实现 weaver.weilin.zhu.common.voucher.convert.CusAsyncConvert类!"); + } + CusAsyncConvert o = (CusAsyncConvert) clazz.newInstance(); + Map pathParam = Util.parseCusInterfacePathParam(cusText); + return o.cusConvert(dao, param, pathParam); + }catch (Exception e){ + return null; + } + } +} diff --git a/src/main/java/weaver/weilin/zhu/common/voucher/convert/RuleMethodParam.java b/src/main/java/weaver/weilin/zhu/common/voucher/convert/RuleMethodParam.java new file mode 100644 index 0000000..f75a93a --- /dev/null +++ b/src/main/java/weaver/weilin/zhu/common/voucher/convert/RuleMethodParam.java @@ -0,0 +1,43 @@ +package weaver.weilin.zhu.common.voucher.convert; + +import lombok.Getter; +import lombok.Setter; +import weaver.conn.RecordSet; +import weaver.hrm.User; + +import java.util.Map; + +/** + * 转换规则方法需要的参数类 + * @author bleach + * @version 2023-07-04 + */ +@Getter +@Setter +public class RuleMethodParam { + /** + * 流程主表数据集 + */ + private RecordSet rs ; + + /** + * 流程明细表某一行数据集 + */ + private RecordSet rs_detail; + + /** + * 流程基础信息数组 + */ + private Map workflowBaseMap; + + /** + * 明细序列 + */ + private int rowNum; + + /** + * 当前用户 + */ + private User thisUser; + +} diff --git a/src/main/java/weaver/weilin/zhu/common/voucher/entity/BaseConfigDao.java b/src/main/java/weaver/weilin/zhu/common/voucher/entity/BaseConfigDao.java new file mode 100644 index 0000000..045b90e --- /dev/null +++ b/src/main/java/weaver/weilin/zhu/common/voucher/entity/BaseConfigDao.java @@ -0,0 +1,60 @@ +package weaver.weilin.zhu.common.voucher.entity; + +import lombok.Data; + +import java.util.List; + +/** + * 凭证通用功能 + * 基础配置 + * @author bleach + * @version 2023-07-10 + */ +@Data +public class BaseConfigDao { + + /** + * 配置ID + */ + private int id; + + /** + * 流程类型ID + */ + private String workflowId; + + /** + * 自定义参数值 + */ + private String cusParamValue; + + /** + * 数据条件 + */ + private String dataCondition; + + /** + * 异常是否继续 + */ + private int exceptionContinue; + + /** + * 数据格式 0-JSON 1-XML + */ + private int dataFormat; + + /** + * 回写字段名称 + */ + private String backFieldname; + + /** + * 对象与流程明细映射关系配置 + */ + private List objectMappingDaoList; + + /** + * 节点与流程字段详细配置 + */ + private List nodeFieldMappingDaoList; +} diff --git a/src/main/java/weaver/weilin/zhu/common/voucher/entity/NodeFieldMappingDao.java b/src/main/java/weaver/weilin/zhu/common/voucher/entity/NodeFieldMappingDao.java new file mode 100644 index 0000000..41b246c --- /dev/null +++ b/src/main/java/weaver/weilin/zhu/common/voucher/entity/NodeFieldMappingDao.java @@ -0,0 +1,59 @@ +package weaver.weilin.zhu.common.voucher.entity; + +import lombok.Data; +import weaver.weilin.zhu.common.util.FieldDetailInfo; + +/** + * 凭证通用功能 + * 节点与流程字段配置详细 + * @author bleach + * @version 2023-07-10 + */ +@Data +public class NodeFieldMappingDao { + + /** + * 配置的数据ID + */ + private int id; + + /** + * 节点名称 + */ + private String nodeName; + + /** + * 父节点名称 + */ + private String parentNode; + + /** + * 节点类型 0-普通文本 1-普通对象 2-数组文本 3-数组对象 + */ + private int nodeType; + + /** + * 流程字段信息 + */ + private FieldDetailInfo wfField; + + /** + * 借贷方向 + */ + private String entriesDirection; + + /** + * 转换规则 + */ + private int changeRule; + + /** + * 自定义规则 + */ + private String cusSQL; + + /** + * 特殊属性 0-普通字段 1-金额控制字段 2-科目字段 + */ + private int specialAttr; +} diff --git a/src/main/java/weaver/weilin/zhu/common/voucher/entity/ObjectMappingDao.java b/src/main/java/weaver/weilin/zhu/common/voucher/entity/ObjectMappingDao.java new file mode 100644 index 0000000..2c4db1f --- /dev/null +++ b/src/main/java/weaver/weilin/zhu/common/voucher/entity/ObjectMappingDao.java @@ -0,0 +1,43 @@ +package weaver.weilin.zhu.common.voucher.entity; + +import lombok.Data; + +/** + * 凭证通用功能 + * 对象与流程明细映射关系配置 + * @author bleach + * @version 2023-07-10 + */ +@Data +public class ObjectMappingDao { + + /** + * 数据ID + */ + private int id; + + /** + * 对象名称 + */ + private String objectName; + + /** + * 流程明细 + */ + private int dtIndex; + + /** + * 别名 + */ + private String alias; + + /** + * 借贷方向 + */ + private String entriesDirection; + + /** + * 数据条件 + */ + private String dtCondition; +} diff --git a/src/main/java/weaver/weilin/zhu/common/voucher/entity/VoucherConstants.java b/src/main/java/weaver/weilin/zhu/common/voucher/entity/VoucherConstants.java new file mode 100644 index 0000000..2521903 --- /dev/null +++ b/src/main/java/weaver/weilin/zhu/common/voucher/entity/VoucherConstants.java @@ -0,0 +1,62 @@ +package weaver.weilin.zhu.common.voucher.entity; + +/** + * 凭证通过功能 + * 常量配置 + */ +public class VoucherConstants { + + + /** + * 借贷方向 - 非凭证分录 + */ + public static final int EntriesDirection_NoVoucher = 0; + + /** + * 借贷方向 - 普通借方 + */ + public static final int EntriesDirection_Comm_Debit = 1; + + + /** + * 借贷方向 - 税额借方 + */ + public static final int EntriesDirection_Tax_Debit = 2; + + + + /** + * 借贷方向 - 普通贷方 + */ + public static final int EntriesDirection_Comm_Credit = 3; + + + /** + * 借贷方向 - 冲销贷方 + */ + public static final int EntriesDirection_WriteOff_Credit = 4; + + + /** + * 节点类型 - 普通文本 + */ + public static final int Node_Type_Comm_Text = 0; + + + /** + * 节点类型 - 普通对象 + */ + public static final int Node_Type_Comm_Object = 1; + + + /** + * 节点类型 - 数组文本 + */ + public static final int Node_Type_Array_Text = 2; + + + /** + * 节点类型 - 数组对象 + */ + public static final int Node_Type_Array_Object = 3; +} diff --git a/src/main/java/weaver/weilin/zhu/common/voucher/mapper/CommVoucherSqlMapper.java b/src/main/java/weaver/weilin/zhu/common/voucher/mapper/CommVoucherSqlMapper.java new file mode 100644 index 0000000..ce813f9 --- /dev/null +++ b/src/main/java/weaver/weilin/zhu/common/voucher/mapper/CommVoucherSqlMapper.java @@ -0,0 +1,143 @@ +package weaver.weilin.zhu.common.voucher.mapper; + +import aiyh.utils.annotation.recordset.*; +import weaver.conn.RecordSet; +import weaver.weilin.zhu.common.voucher.entity.BaseConfigDao; +import weaver.weilin.zhu.common.voucher.entity.NodeFieldMappingDao; +import weaver.weilin.zhu.common.voucher.entity.ObjectMappingDao; + +import java.util.List; + +/** + * 凭证通用功能 + * 凭证相关数据操作接口 + * @author bleach + */ +@SqlMapper +public interface CommVoucherSqlMapper { + + /** + * 根据流程类型ID获取其对应的配置信息 + * @param workflowIds 流程类型ID + * @return 配置信息 + */ + @Select("select * from uf_comm_voucher where wfId in ($t{workflowIds})") + @CollectionMappings({ + @CollectionMapping( + property = "objectMappingDaoList", + column = "id", + id = @Id(value = Integer.class, methodId = 1) + ), + @CollectionMapping( + property = "nodeFieldMappingDaoList", + column = "id", + id = @Id(value = Integer.class,methodId = 2) + ) + }) + BaseConfigDao getConfigurationByWorkflowId(@ParamMapper("workflowIds") String workflowIds); + + + + /** + * 根据流程类型ID获取其对应的配置信息 + * @param workflowIds 流程类型ID + * @return 配置信息 + */ + @Select("select * from uf_comm_voucher where wfId in ($t{workflowIds}) and cusParamValue = #{cusParamValue}") + @CollectionMappings({ + @CollectionMapping( + property = "objectMappingDaoList", + column = "id", + id = @Id(value = Integer.class, methodId = 1) + ), + @CollectionMapping( + property = "nodeFieldMappingDaoList", + column = "id", + id = @Id(value = Integer.class,methodId = 2) + ) + }) + BaseConfigDao getConfigurationByWorkflowIdAndCondition(@ParamMapper("workflowIds") String workflowIds,@ParamMapper("cusParamValue") String cusParamValue); + + + + /** + * 获取对象与流程明细表映射配置信息 + * @param mainId 主表主键ID + * @return 映射详细信息 + */ + @Select("select * from uf_comm_voucher_dt1 where mainId = #{mainId}") + @CollectionMethod(value = 1,desc = "获取对象与流程明细表映射配置信息") + List getObjectMappingByMainKeyId(@ParamMapper("mainId") int mainId); + + + + /** + * 获取对象与流程明细表映射配置信息 + * @param mainId 主表主键ID + * @return 映射详细信息 + */ + @Select("select * from uf_comm_voucher_dt2 where mainId = #{mainId}") + @Associations({ + @Association( + property = "wfField", + column = "wfField", + select = "weaver.weilin.zhu.common.util.CommonUtil.getFieldDetailInfo", + id = @Id(Integer.class) + ) + }) + @CaseConversion(value = false) + @CollectionMethod(value = 2,desc = "获取节点名称与字段详细配置信息") + List getNodeFieldMappingByMainKeyId(@ParamMapper("mainId") int mainId); + + + + /** + * 查询流程主表的信息 + * @param billTableMain 明细表名称 + * @param requestId 流程请求D值 + * @return 查询结果数据集 + */ + @Select("select * from $t{billTableMain} where requestId = #{requestId}") + RecordSet getWorkflowMainTableInfo(@ParamMapper("billTableMain") String billTableMain,@ParamMapper("requestId") String requestId); + + + /** + * 查询流程主表的信息 + * @param billTableMain 明细表名称 + * @param requestId 流程请求D值 + * @return 查询结果数据集 + */ + @Select("select * from $t{billTableMain} where requestId = #{requestId} and $t{condition}") + RecordSet getWorkflowMainTableInfoAndCondition(@ParamMapper("billTableMain") String billTableMain,@ParamMapper("requestId") String requestId,@ParamMapper("condition") String condition); + + + + /** + * 查询流程某个明细表的信息 + * @param detailTableName 明细表名称 + * @param mainId 流程主表主键ID值 + * @return 查询结果数据集 + */ + @Select("select * from $t{detailTableName} where mainId = #{mainId}") + RecordSet getWorkflowDetailTableInfo(@ParamMapper("detailTableName") String detailTableName,@ParamMapper("mainId") String mainId); + + + /** + * 查询流程某个明细表的信息 + * @param detailTableName 明细表名称 + * @param mainId 流程主表主键ID值 + * @return 查询结果数据集 + */ + @Select("select * from $t{detailTableName} where mainId = #{mainId} and $t{condition}") + RecordSet getWorkflowDetailTableInfoAndCondition(@ParamMapper("detailTableName") String detailTableName,@ParamMapper("mainId") String mainId,@ParamMapper("condition") String condition); + + /** + * 更新流程表单字段信息 + * @param billTable 表单名称 + * @param backFieldName 回写字段名称 + * @param backFieldValue 回写字段值 + * @param requestId 流程请求ID + */ + @Update("update $t{billTable} set $t{backFieldName} = #{backFieldValue} where requestId = #{requestId}") + void resultBackToWorkflowBill(@ParamMapper("billTable") String billTable,@ParamMapper("backFieldName") String backFieldName,@ParamMapper("backFieldValue") String backFieldValue,@ParamMapper("requestId") String requestId); +} diff --git a/src/main/java/weaver/weilin/zhu/common/voucher/util/CommonVoucherUtil.java b/src/main/java/weaver/weilin/zhu/common/voucher/util/CommonVoucherUtil.java new file mode 100644 index 0000000..190076d --- /dev/null +++ b/src/main/java/weaver/weilin/zhu/common/voucher/util/CommonVoucherUtil.java @@ -0,0 +1,416 @@ +package weaver.weilin.zhu.common.voucher.util; + +import aiyh.utils.Util; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.hrm.User; +import weaver.weilin.zhu.common.util.FieldDetailInfo; +import weaver.weilin.zhu.common.voucher.convert.FieldChangeRuleMethod; +import weaver.weilin.zhu.common.voucher.convert.RuleMethodParam; +import weaver.weilin.zhu.common.voucher.entity.BaseConfigDao; +import weaver.weilin.zhu.common.voucher.entity.NodeFieldMappingDao; +import weaver.weilin.zhu.common.voucher.entity.ObjectMappingDao; +import weaver.weilin.zhu.common.voucher.mapper.CommVoucherSqlMapper; +import weaver.workflow.workflow.WorkflowVersion; +import weaver.weilin.zhu.common.voucher.entity.VoucherConstants; +import weaver.zwl.common.ToolUtilNew; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 凭证通用功能 + * 凭证操作工具类 + * @author bleach + * @version 2023-07-10 + */ +public class CommonVoucherUtil { + + /** + * 数据操作接口 + */ + private final CommVoucherSqlMapper sqlMapper = Util.getMapper(CommVoucherSqlMapper.class); + + + /** + * 流程基础信息 + */ + private Map workflowBaseMap; + + /** + * 当前用户 + */ + private User thisUser; + + /** + * 对象与流程明细映射关系配置集合 + */ + private List objectMappingDaoList; + + /** + * 节点与流程字段配置集合 + */ + private List nodeFieldMappingDaoList; + + public CommonVoucherUtil() { + } + + /** + * 根据流程类型ID和自定义参数值,获取其对应的配置信息 + * @param workflowId 流程类型ID + * @param cusParamValue 自定义参数值 + * @return 配置信息 + */ + public BaseConfigDao getConfigurationByWorkflowId(String workflowId,String cusParamValue){ + BaseConfigDao dao = new BaseConfigDao(); + + //获取该流程类型对应的所有版本ID + String allWorkflowIds = WorkflowVersion.getAllVersionStringByWFIDs(workflowId); + + if(StringUtils.isNotBlank(cusParamValue)){ + dao = sqlMapper.getConfigurationByWorkflowIdAndCondition(allWorkflowIds,cusParamValue); + } else { + dao = sqlMapper.getConfigurationByWorkflowId(allWorkflowIds); + } + + return dao; + } + + /** + * 递归生成JSON对象 + * @param parentNode 父节点名称 + * @param rs 流程主表数据集 + * @param rs_detail 流程某个明细表某行数据集 + * @param dtIndex 明细序列 + * @param itemDirection 借贷方向 + * @param rowNum 明细序号 + * @return JSON对象 + */ + public JSONObject recursionGenerateJsonObject(String parentNode, RecordSet rs,RecordSet rs_detail, int dtIndex, int itemDirection,int rowNum){ + JSONObject jsonObject = new JSONObject(); + + for(NodeFieldMappingDao nodeFieldMappingDao : nodeFieldMappingDaoList){ + //节点名称 + String _nodeName = nodeFieldMappingDao.getNodeName(); + + if(StringUtils.isBlank(_nodeName)){ + continue; + } + + /* 父节点名称 */ + String _parentNode = nodeFieldMappingDao.getParentNode(); + + if(!_parentNode.equals(parentNode)){ + continue; + } + + int _nodeType = nodeFieldMappingDao.getNodeType(); + + if(itemDirection > 0){//说明为会计分录 + String _entriesDirection = nodeFieldMappingDao.getEntriesDirection(); + + if(!_entriesDirection.contains(String.valueOf(itemDirection))){//传进来的会计分录方向与当前不一致 + continue; + } + } + + //流程字段新 + FieldDetailInfo workflowField = nodeFieldMappingDao.getWfField(); + + if(workflowField != null){ + int _viewType = workflowField.getViewType(); + + int _detailIndex = workflowField.getDetailIndex(); + if(_viewType == 1 && _detailIndex != dtIndex){ + continue; + } + } + + RuleMethodParam param = new RuleMethodParam(); + param.setRs(rs); + param.setRs_detail(rs_detail); + param.setWorkflowBaseMap(workflowBaseMap); + param.setRowNum(rowNum); + param.setThisUser(thisUser); + + switch (_nodeType){ + case VoucherConstants.Node_Type_Comm_Text: + String nodeValue = FieldChangeRuleMethod.VALUE_RULE_FUNCTION.get(nodeFieldMappingDao.getChangeRule()).apply(nodeFieldMappingDao, param); + + if(nodeFieldMappingDao.getSpecialAttr() == 1 && Util.getDoubleValue(nodeValue,0.0) == 0){ + return null; + } + + jsonObject.put(_nodeName,nodeValue); + + break; + case VoucherConstants.Node_Type_Comm_Object: + JSONObject commObj = recursionGenerateJsonObject(_nodeName,rs,rs_detail,dtIndex,itemDirection,rowNum); + + jsonObject.put(_nodeName,commObj); + break; + case VoucherConstants.Node_Type_Array_Text: + JSONArray arrayText = new JSONArray(); + + String arrayTextValue = FieldChangeRuleMethod.VALUE_RULE_FUNCTION.get(nodeFieldMappingDao.getChangeRule()).apply(nodeFieldMappingDao,param); + + if(StringUtils.isNotBlank(arrayTextValue)){ + arrayText.addAll(Arrays.asList(Util.TokenizerString2(arrayTextValue, ","))); + } + + jsonObject.put(_nodeName,arrayText); + break; + case VoucherConstants.Node_Type_Array_Object: + + JSONArray itemArray = new JSONArray(); + + int _rowNum = 1; + + for(ObjectMappingDao objectMappingDao : objectMappingDaoList){ + String _objectName = objectMappingDao.getObjectName(); + + //别名 + String alias = objectMappingDao.getAlias(); + + if(!_objectName.equals(_nodeName) || (StringUtils.isNotBlank(alias) && !alias.equals(_nodeName))){//对象节点名称 与当前节点不一致 + continue; + } + + int _dtIndex = objectMappingDao.getDtIndex(); + + String _entriesDirection = objectMappingDao.getEntriesDirection(); + + //父节点名称 + String tmpParentNode = StringUtils.isNotBlank(alias) ? alias : _objectName; + + if(_dtIndex > 0){ + String dtCondition = objectMappingDao.getDtCondition(); + + RecordSet _rs_detail; + + //流程明细表名称 + String detailTable = Util.null2String(workflowBaseMap.get("billTableName")) + "_dt" + _dtIndex; + + if(StringUtils.isNotBlank(dtCondition)){ + dtCondition = ToolUtilNew.staticToDBC(dtCondition); + + _rs_detail = sqlMapper.getWorkflowDetailTableInfoAndCondition(detailTable,Util.null2String(workflowBaseMap.get("mainId")),dtCondition); + } else { + _rs_detail = sqlMapper.getWorkflowDetailTableInfo(detailTable,Util.null2String(workflowBaseMap.get("mainId"))); + } + + while(_rs_detail.next()){ + for(String direction : Util.TokenizerString2(_entriesDirection,",")) { + JSONObject itemObj = recursionGenerateJsonObject(tmpParentNode, rs, _rs_detail, _dtIndex, Util.getIntValue(direction), _rowNum++); + + if(itemObj == null || itemObj.isEmpty()){ + _rowNum--; + } else { + itemArray.add(itemObj); + } + } + } + } else {//说明信息来自主表 + for(String direction : Util.TokenizerString2(_entriesDirection,",")){ + JSONObject itemObj = recursionGenerateJsonObject(tmpParentNode,rs,null,0,Util.getIntValue(direction),_rowNum++); + + if(itemObj == null || itemObj.isEmpty()){ + _rowNum--; + } else { + itemArray.add(itemObj); + } + } + } + } + + jsonObject.put(_nodeName,itemArray); + + break; + } + } + + return jsonObject; + } + + /** + * 递归生成XML字符串 + * @param parentNode 父节点名称 + * @param rs 流程主表数据集 + * @param rs_detail 流程某个明细表某行数据集 + * @param dtIndex 明细序列 + * @param itemDirection 借贷方向 + * @param rowNum 明细序号 + * @return XML字符串 + */ + public StringBuilder recursionGenerateXML(String parentNode, RecordSet rs,RecordSet rs_detail, int dtIndex, int itemDirection,int rowNum){ + StringBuilder xmlBuilder = new StringBuilder(); + for(NodeFieldMappingDao nodeFieldMappingDao : nodeFieldMappingDaoList) { + //节点名称 + String _nodeName = nodeFieldMappingDao.getNodeName(); + + if (StringUtils.isBlank(_nodeName)) { + continue; + } + + //父节点名称 + String _parentNode = nodeFieldMappingDao.getParentNode(); + + if (!_parentNode.equals(parentNode)) { + continue; + } + + int _nodeType = nodeFieldMappingDao.getNodeType(); + + if (itemDirection > 0) {//说明为会计分录 + String _entriesDirection = nodeFieldMappingDao.getEntriesDirection(); + + if (!_entriesDirection.contains(String.valueOf(itemDirection))) {//传进来的会计分录方向与当前不一致 + continue; + } + } + + //流程字段新 + FieldDetailInfo workflowField = nodeFieldMappingDao.getWfField(); + + if (workflowField != null) { + int _viewType = workflowField.getViewType(); + + int _detailIndex = workflowField.getDetailIndex(); + if (_viewType == 1 && _detailIndex != dtIndex) { + continue; + } + } + + RuleMethodParam param = new RuleMethodParam(); + param.setRs(rs); + param.setRs_detail(rs_detail); + param.setWorkflowBaseMap(workflowBaseMap); + param.setRowNum(rowNum); + param.setThisUser(thisUser); + + switch (_nodeType) { + case VoucherConstants.Node_Type_Comm_Text: + String nodeValue = FieldChangeRuleMethod.VALUE_RULE_FUNCTION.get(nodeFieldMappingDao.getChangeRule()).apply(nodeFieldMappingDao, param); + + if (nodeFieldMappingDao.getSpecialAttr() == 1 && Util.getDoubleValue(nodeValue, 0.0) == 0) { + return null; + } + xmlBuilder.append("<").append(_nodeName).append(">"); + xmlBuilder.append(nodeValue); + xmlBuilder.append("\n"); + break; + case VoucherConstants.Node_Type_Array_Text: + break; + + case VoucherConstants.Node_Type_Comm_Object: + StringBuilder innerXML = recursionGenerateXML(_nodeName,rs,rs_detail,dtIndex,itemDirection,rowNum); + xmlBuilder.append("<").append(_nodeName).append(">"); + xmlBuilder.append(innerXML); + xmlBuilder.append("\n"); + break; + + case VoucherConstants.Node_Type_Array_Object: + int _rowNum = 1; + + for(ObjectMappingDao objectMappingDao : objectMappingDaoList) { + String _objectName = objectMappingDao.getObjectName(); + + //别名 + String alias = objectMappingDao.getAlias(); + + if (!_objectName.equals(_nodeName) || (StringUtils.isNotBlank(alias) && !alias.equals(_nodeName))) {//对象节点名称 与当前节点不一致 + continue; + } + + int _dtIndex = objectMappingDao.getDtIndex(); + + String _entriesDirection = objectMappingDao.getEntriesDirection(); + + //父节点名称 + String tmpParentNode = StringUtils.isNotBlank(alias) ? alias : _objectName; + + if (_dtIndex > 0) { + String dtCondition = objectMappingDao.getDtCondition(); + + RecordSet _rs_detail; + + //流程明细表名称 + String detailTable = Util.null2String(workflowBaseMap.get("billTableName")) + "_dt" + _dtIndex; + + if (StringUtils.isNotBlank(dtCondition)) { + dtCondition = ToolUtilNew.staticToDBC(dtCondition); + + _rs_detail = sqlMapper.getWorkflowDetailTableInfoAndCondition(detailTable, Util.null2String(workflowBaseMap.get("mainId")), dtCondition); + } else { + _rs_detail = sqlMapper.getWorkflowDetailTableInfo(detailTable, Util.null2String(workflowBaseMap.get("mainId"))); + } + + while (_rs_detail.next()) { + for (String direction : Util.TokenizerString2(_entriesDirection, ",")) { + StringBuilder innerItem = recursionGenerateXML(tmpParentNode,rs,_rs_detail,_dtIndex,Util.getIntValue(direction),_rowNum); + + if(innerItem != null && innerItem.length() > 0){ + xmlBuilder.append("<").append(_nodeName).append(">"); + xmlBuilder.append(innerItem); + xmlBuilder.append("\n"); + } else { + _rowNum--; + } + } + } + } else { //说明数据来自主表 + for(String direction : Util.TokenizerString2(_entriesDirection,",")){ + StringBuilder innerItem = recursionGenerateXML(tmpParentNode,rs,null,0,Util.getIntValue(direction),_rowNum++); + + if(innerItem != null && innerItem.length() > 0){ + xmlBuilder.append("<").append(_nodeName).append(">"); + xmlBuilder.append(innerItem); + xmlBuilder.append("\n"); + } else { + _rowNum--; + } + } + } + } + + break; + } + } + return xmlBuilder; + } + + public User getThisUser() { + return thisUser; + } + + public void setThisUser(User thisUser) { + this.thisUser = thisUser; + } + + public Map getWorkflowBaseMap() { + return workflowBaseMap; + } + + public void setWorkflowBaseMap(Map workflowBaseMap) { + this.workflowBaseMap = workflowBaseMap; + } + + public List getObjectMappingDaoList() { + return objectMappingDaoList; + } + + public void setObjectMappingDaoList(List objectMappingDaoList) { + this.objectMappingDaoList = objectMappingDaoList; + } + + public List getNodeFieldMappingDaoList() { + return nodeFieldMappingDaoList; + } + + public void setNodeFieldMappingDaoList(List nodeFieldMappingDaoList) { + this.nodeFieldMappingDaoList = nodeFieldMappingDaoList; + } +} diff --git a/src/main/java/weaver/weilin/zhu/xyzq/scheduled/sqlmapper/OrganizationSyncSqlMapper.java b/src/main/java/weaver/weilin/zhu/xyzq/scheduled/sqlmapper/OrganizationSyncSqlMapper.java index b75d680..f3ade99 100644 --- a/src/main/java/weaver/weilin/zhu/xyzq/scheduled/sqlmapper/OrganizationSyncSqlMapper.java +++ b/src/main/java/weaver/weilin/zhu/xyzq/scheduled/sqlmapper/OrganizationSyncSqlMapper.java @@ -48,7 +48,7 @@ public interface OrganizationSyncSqlMapper { @Association( property = "modeField", column = "modeField", - select = "weaver.common.util.CommonUtil.getFieldInfo", + select = "weaver.weilin.zhu.common.util.CommonUtil.getFieldDetailInfo", id = @Id(Integer.class) ) }) diff --git a/src/main/java/weaver/weilin/zhu/xyzq/scheduled/task/SyncOrgDataTask.java b/src/main/java/weaver/weilin/zhu/xyzq/scheduled/task/SyncOrgDataTask.java index a6e2c5a..b424c23 100644 --- a/src/main/java/weaver/weilin/zhu/xyzq/scheduled/task/SyncOrgDataTask.java +++ b/src/main/java/weaver/weilin/zhu/xyzq/scheduled/task/SyncOrgDataTask.java @@ -22,7 +22,6 @@ public class SyncOrgDataTask extends BaseCronJob { public void execute() { if(StringUtils.isNotBlank(keyId)){ OrganizationSyncUtil syncUtil = new OrganizationSyncUtil(); - syncUtil.syncData(Util.getIntValue(keyId,0)); } } diff --git a/src/main/jinwei_tao_old_src/com/api/taojw/common/action/RequestDataToApiAction.java b/src/main/jinwei_tao_old_src/com/api/taojw/common/action/RequestDataToApiAction.java index a9d2b8e..8fcdd87 100644 --- a/src/main/jinwei_tao_old_src/com/api/taojw/common/action/RequestDataToApiAction.java +++ b/src/main/jinwei_tao_old_src/com/api/taojw/common/action/RequestDataToApiAction.java @@ -67,7 +67,7 @@ public class RequestDataToApiAction implements Action { } catch (Exception e) { requestInfo.getRequestManager().setMessageid("2022052791002"); requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +",请联系管理员!"); - logger.error("VoucherAction.select * from workflow_requestBase error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + logger.error("CommonVoucherAction.select * from workflow_requestBase error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); return Action.FAILURE_AND_CONTINUE; } //获取当前流程信息 diff --git a/src/main/jinwei_tao_old_src/weaver/taojw/common/action/RequestDataToApiAction.java b/src/main/jinwei_tao_old_src/weaver/taojw/common/action/RequestDataToApiAction.java index 68fa61b..c527a91 100644 --- a/src/main/jinwei_tao_old_src/weaver/taojw/common/action/RequestDataToApiAction.java +++ b/src/main/jinwei_tao_old_src/weaver/taojw/common/action/RequestDataToApiAction.java @@ -66,7 +66,7 @@ public class RequestDataToApiAction implements Action { } catch (Exception e) { requestInfo.getRequestManager().setMessageid("2022052791002"); requestInfo.getRequestManager().setMessagecontent("Action接口发生异常,requestId:"+ requestId +",请联系管理员!"); - logger.error("VoucherAction.select * from workflow_requestBase error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); + logger.error("CommonVoucherAction.select * from workflow_requestBase error;requestId:" + requestId + "exception:" + e.getMessage() + ";e:" + e); return Action.FAILURE_AND_CONTINUE; } //获取当前流程信息 diff --git a/src/test/java/bokang/xiao/NormalTest.java b/src/test/java/bokang/xiao/NormalTest.java index 1803b34..bd19a33 100644 --- a/src/test/java/bokang/xiao/NormalTest.java +++ b/src/test/java/bokang/xiao/NormalTest.java @@ -45,6 +45,7 @@ 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.shtx.schedule.ExamineSchedule; +import weaver.bokang.xiao.shtx.schedule.SyncTeachDataSchedule; import weaver.bokang.xiao.xhny_mode.search.CustomSearchDepart; import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData; import weaver.bokang.xiao.xhny_report.schedule.GenerateReportSchedule; @@ -84,7 +85,7 @@ public class NormalTest extends BaseTest { @Test public void testWord(){ - GenerateFileUtil.createCronJobDocument(ExamineSchedule.class); + GenerateFileUtil.createCronJobDocument(SyncTeachDataSchedule.class); //GenerateFileUtil.createActionDocument(DataPushAction.class); //GenerateFileUtil.createActionDocument(DateFieldUpdateAction.class); } @@ -126,8 +127,8 @@ public class NormalTest extends BaseTest { ParseTest parseTest = new ParseTest(); Map resultData = parseTest.getResultData(); System.out.println(JSON.toJSONString(resultData)); - ResponseMappingDeal responseMappingDeal = new ResponseMappingDeal(); - responseMappingDeal.doResponseSync("test1",resultData); + //ResponseMappingDeal responseMappingDeal = new ResponseMappingDeal(); + //responseMappingDeal.doResponseSync("test1",resultData); } @Test diff --git a/src/test/java/xuanran/wang/eny/ModelFieldAsyncTest.java b/src/test/java/xuanran/wang/eny/ModelFieldAsyncTest.java index cf1698c..1810c2f 100644 --- a/src/test/java/xuanran/wang/eny/ModelFieldAsyncTest.java +++ b/src/test/java/xuanran/wang/eny/ModelFieldAsyncTest.java @@ -9,6 +9,7 @@ import aiyh.utils.tool.org.apache.commons.jexl3.MapContext; import basetest.BaseTest; import com.alibaba.fastjson.JSONObject; import com.api.nonstandardext.model_field_async.entity.ModelFieldAsyncConfigClass; +import com.api.xuanran.wang.eny.workflow.mapper.ExchangeRateMapper; import org.apache.commons.lang3.StringUtils; import org.junit.Test; import com.api.nonstandardext.model_field_async.entity.ModelFieldAsyncConfig; @@ -89,6 +90,22 @@ public class ModelFieldAsyncTest extends BaseTest { return (T) response.get(split[len - 1]); } + private final ExchangeRateMapper mapper = Util.getMapper(ExchangeRateMapper.class); + @Test + public void testE(){ + String json ="{\"date\":\"2021-04-07\",\"interfaceCurrency\":\"CNY\",\"printParams\":1,\"fieldList\":[{\"field\":\"field11111\",\"money\":12920295.96}],\"baseCurrency\":\"1\"} "; + Map map = JSONObject.parseObject(json, Map.class); + List> fieldList = (List>) map.get("fieldList"); + System.out.println("list : " + fieldList); + for (Map objectMap : fieldList) { + double money = Util.getDoubleValue(Util.null2DefaultStr(objectMap.get("money"), ""), 0); + if(money == 0){ + break; + } + System.out.println("money : " + money); + } + } + } diff --git a/src/test/java/youhong/ai/utiltest/resultjsonparase/ParseTest.java b/src/test/java/youhong/ai/utiltest/resultjsonparase/ParseTest.java index b7620a4..7694a0e 100644 --- a/src/test/java/youhong/ai/utiltest/resultjsonparase/ParseTest.java +++ b/src/test/java/youhong/ai/utiltest/resultjsonparase/ParseTest.java @@ -97,7 +97,7 @@ public class ParseTest extends BaseTest { Map data = new HashMap<>(); data.put("name", "肖博亢"); data.put("age", 18); - data.put("sex", "女"); + data.put("sex", "男"); List> friends = new ArrayList<>(); for (int i = 0; i < 5; i++) { Map friend = new HashMap<>();