From 1dff070cc1402330b238066e7efee63a37fa6ef2 Mon Sep 17 00:00:00 2001 From: wangxuanran <3055088966@qq.com> Date: Wed, 19 Jul 2023 13:40:15 +0800 Subject: [PATCH 1/8] =?UTF-8?q?inser/update=20state=E4=B8=AD=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E5=9B=9E=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aiyh/utils/response_deal/state/InsertOrUpdateState.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/aiyh/utils/response_deal/state/InsertOrUpdateState.java b/src/main/java/aiyh/utils/response_deal/state/InsertOrUpdateState.java index 549969d..db7e023 100644 --- a/src/main/java/aiyh/utils/response_deal/state/InsertOrUpdateState.java +++ b/src/main/java/aiyh/utils/response_deal/state/InsertOrUpdateState.java @@ -22,9 +22,6 @@ public class InsertOrUpdateState extends State{ @Override public void handle() { - if(ResponseUtil.parameterIsNotNull(this.context.getTableDefinitionCallback())){ - this.context.getTableDefinitionCallback().tableHandle(this.context); - } List rowDefinitionList = this.context.getRowDefinitionList(); List updateRowList = new ArrayList<>(); List insertRowList = new ArrayList<>(); @@ -55,7 +52,6 @@ public class InsertOrUpdateState extends State{ BeanUtil.copyProperties(this.context,tableDefinition); tableDefinition.setState(null); tableDefinition.setRowDefinitionList(rowDefinitionList); - tableDefinition.setTableDefinitionCallback(null); tableDefinition.setAssignType(assignType); tableDefinition.setDefaultState(null); tableDefinition.dataProcess(); From 6cdae28cc480b9317b2021dec0e7ec365666330c Mon Sep 17 00:00:00 2001 From: ic_excellent <2570192571@qq.com> Date: Wed, 19 Jul 2023 14:01:33 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E4=B8=8A=E6=B5=B7=E5=A4=A7=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E4=B8=AD=E5=BF=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xiao/sh_bigdata/mapper/ReportMapper.java | 17 ++++++++++------- .../xiao/sh_bigdata/service/ReportService.java | 11 ++++++----- 2 files changed, 16 insertions(+), 12 deletions(-) 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 6ff3959..e1fd1d5 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,12 +37,15 @@ 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, ',', dw), '-') 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 dlsk1 ") + @Select("select main.* " + + " (select lastname from hrmresource where id = dyjbr) dyjbr_span," + + " (select lastname from hrmresource where id = djr) djr_span," + + " (select LISTAGG(concat(wb, ',', dw), '-') WITHIN GROUP (ORDER BY wb) from uf_zwfwdjjmb_dt1 where mainid = main.id) ysdx," + + " (select LISTAGG(concat(dwclwb,'(', dwcljsywb,')'), ',') WITHIN GROUP (ORDER BY wb) from uf_zwfwdjjmb_dt3 where mainid = main.id) car_people," + + " (select LISTAGG(concat(gzclwb,'(', gzcljsywb,')'), ',') WITHIN GROUP (ORDER BY wb) from uf_zwfwdjjmb_dt4 where mainid = main.id) work_people," + + " (select LISTAGG(concat(fjhwb,'(', ysdxwb,')'), ',') WITHIN GROUP (ORDER BY wb) from uf_zwfwdjjmb_dt2 where mainid = main.id) put_up" + + "from uf_zwfwdjjmb main $t{param.whereSql} " + + "order by dlsk1 ") @CaseConversion(value = false) List> queryReportData3(@ParamMapper("param") Map param,@ParamMapper("uid") int uid); @@ -60,7 +63,7 @@ public interface ReportMapper { * @param param 查询参数 * @return 当日值班人员 */ - @Select("select hrm.lastname today_welcome,ry.zbry,hrm1.lastname organ_watch,ry.zbry1,hrm2.lastname head_watch,ry.zbry2 " + + @Select("select hrm.lastname head_watch,ry.zbry,hrm1.lastname organ_watch,ry.zbry1,hrm2.lastname today_welcome,ry.zbry2 " + " from uf_ryzbjlbzjb_dt1 ry " + " inner join hrmresource hrm on ry.zbry = hrm.id " + " inner join hrmresource hrm1 on ry.zbry1 = hrm1.id " + 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 e83907c..ceffa97 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 @@ -41,12 +41,12 @@ public class ReportService { //开始日期 String beginDate = Util.null2String(param.get("beginDate")); //结束日期 - String endData = Util.null2String(param.get("endData")); + String endDate = Util.null2String(param.get("endDate")); //航班车次 String flightAndTrain = Util.null2String(param.get("flightAndTrain")); String whereSql = ""; - if(!"".equals(beginDate) && !"".equals(endData)){ - whereSql += " and (dlsk1 between #{param.beginDate} and #{param.endData} )"; + if(!"".equals(beginDate) && !"".equals(endDate)){ + whereSql += " and (dlsk1 between #{param.beginDate} and #{param.endDate} )"; }else { param.put("today", TimeUtil.getCurrentDateString()); whereSql += " and dlsk1 >= #{param.today} "; @@ -55,10 +55,11 @@ public class ReportService { whereSql += " and dyjbr = #{param.registrationPeople} "; } if(!"".equals(flightAndTrain)){ - whereSql += " and hbwb = #{param.flightAndTrain} "; + whereSql += " and hbcc = #{param.flightAndTrain} "; } if(!"".equals(project)){ - whereSql += " and exits (select 1 from uf_zwfwdjjmb_dt1 where mainid = main.id and ysdx = #{param.project}) "; + //whereSql += " and exits (select 1 from uf_zwfwdjjmb_dt1 where mainid = main.id and ysdx = #{param.project}) "; + whereSql += " and exits (select 1 from uf_zwfwdjjmb_dt1 where mainid = main.id and wb like '%$t{param.project}%') "; } whereSql = whereSql.replaceFirst(" and "," where "); return whereSql; From f042d058f0655a2dbe1026c94d4054288fce0e17 Mon Sep 17 00:00:00 2001 From: wangxuanran <3055088966@qq.com> Date: Wed, 19 Jul 2023 15:35:30 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E4=B8=8B=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E5=91=98/=E9=83=A8=E9=97=A8=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/aiyh/utils/Util.java | 45 ++++++++++++++--- .../XkHospitalCommonDefinition.java | 50 +++---------------- .../row/HrmDepartmentRowDefinition.java | 10 +++- .../table/HrmDepartmentTableDefinition.java | 35 ++++++++++--- .../mapper/XkHospitalDataAsyncMapper.java | 4 +- .../wang/xk_hospital/test/XkHospitalTest.java | 36 +++++++++++++ 6 files changed, 119 insertions(+), 61 deletions(-) diff --git a/src/main/java/aiyh/utils/Util.java b/src/main/java/aiyh/utils/Util.java index 136bd19..f0dd810 100644 --- a/src/main/java/aiyh/utils/Util.java +++ b/src/main/java/aiyh/utils/Util.java @@ -12,6 +12,7 @@ import aiyh.utils.mapUtil.UtilHashMap; import aiyh.utils.mapUtil.UtilLinkedHashMap; import aiyh.utils.mapper.UtilMapper; import aiyh.utils.recordset.RecordsetUtil; +import aiyh.utils.recordset.RsThreadLocalManager; import aiyh.utils.service.UtilService; import aiyh.utils.sqlUtil.builderSql.impl.BuilderSqlImpl; import aiyh.utils.sqlUtil.whereUtil.Where; @@ -106,6 +107,7 @@ public class Util extends weaver.general.Util { static ToolUtil toolUtil = new ToolUtil(); private static RecordSet rs; private static volatile Logger log = null; + private static final RsThreadLocalManager LOCAL_MANAGER = new RsThreadLocalManager(); static { try { @@ -4111,14 +4113,15 @@ public class Util extends weaver.general.Util { * @return 部门id **/ public static int getNextDepartmentId(int subId){ - RecordSet insertRs = new RecordSet(); char separator = weaver.general.Util.getSeparator(); String uuid = UUID.randomUUID().toString(); + String empty = ""; String para = uuid + separator +uuid + separator + - "" + separator + "" + separator + subId + separator + 1 + separator + ""; - insertRs.executeProc("HrmDepartment_Insert", para); - if(insertRs.next()){ - return insertRs.getInt(1); + empty + separator + empty + separator + subId + separator + 1 + separator + empty; + RecordSet procRs = getThreadRecord(); + procRs.executeProc("HrmDepartment_Insert", para); + if(procRs.next()){ + return procRs.getInt(1); } return -1; } @@ -4132,13 +4135,43 @@ public class Util extends weaver.general.Util { * @return 人员id **/ public static int getNextHrmId(){ - RecordSet procRs = new RecordSet(); + RecordSet procRs = getThreadRecord(); procRs.executeProc("HrmResourceMaxId_Get", ""); if (procRs.next()) { return procRs.getInt(1); } return -1; } + + /** + *

获取当前线程rs对象

+ * @author xuanran.wang + * @dateTime 2023/7/19 15:28 + * @return recordSet对象 + **/ + public static RecordSet getThreadRecord(){ + String name = Thread.currentThread().getId() + "_" + Thread.currentThread().getName(); + return getRecordFromRsManger(name); + } + + /** + *

通过名字获取rs池中rs对象

+ * @author xuanran.wang + * @dateTime 2023/7/19 15:29 + * @param name rs池中的key + * @return recordSet对象 + **/ + public static RecordSet getRecordFromRsManger(String name){ + RecordSet rs = LOCAL_MANAGER.getRs(name); + if(null == rs){ + LOCAL_MANAGER.setRecordSet(name); + rs = LOCAL_MANAGER.getRs(name); + if(null == rs){ + rs = new RecordSet(); + } + } + return rs; + } } diff --git a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/XkHospitalCommonDefinition.java b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/XkHospitalCommonDefinition.java index 477ed90..e447d77 100644 --- a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/XkHospitalCommonDefinition.java +++ b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/XkHospitalCommonDefinition.java @@ -8,10 +8,6 @@ import com.engine.common.service.impl.ThemeServiceImpl; import org.apache.log4j.Logger; import weaver.hrm.company.DepartmentComInfo; import weaver.hrm.resource.ResourceComInfo; -import weaver.matrix.MatrixUtil; - -import java.util.List; -import java.util.Map; import java.util.concurrent.ExecutorService; /** @@ -49,14 +45,16 @@ public class XkHospitalCommonDefinition { *

部门缓存

**/ protected static final DepartmentComInfo DEPARTMENT_COM_INFO = new DepartmentComInfo(); - /** - *

人员缓存

- **/ - protected static ResourceComInfo RESOURCE_COM_INFO = null; + /** *

系统主题接口

**/ protected static final ThemeServiceImpl THEME_SERVICE = new ThemeServiceImpl(); + /** + *

人员缓存

+ **/ + protected static ResourceComInfo RESOURCE_COM_INFO = null; + static { try { RESOURCE_COM_INFO = new ResourceComInfo(); @@ -66,40 +64,4 @@ public class XkHospitalCommonDefinition { } } - /** - * 同步系统缓存 - * @param table 表名 - * @param idList 数据id集合 - */ - protected void synCache(String table, List idList){ - if (DEPARTMENT.equals(table)) { - threadPoolInstance.execute(()->{ - try { - DEPARTMENT_COM_INFO.removeCache(); - MatrixUtil.sysDepartmentData(); - }catch (Exception e){ - log.error("同步系统部门缓存error : " + e.getMessage()); - Util.logErrorStr(e); - } - }); - }else if(HRM_RESOURCE.equals(table)){ - try { - List> hrmSubList = dataAsyncMapper.selectHrmSubByHrmIdList(idList); - hrmSubList.forEach(map->{ - THEME_SERVICE.createSubCompanyMenu(map.get("id"), map.get("sub")); - }); - RESOURCE_COM_INFO.removeCache(); - }catch (Exception e){ - log.error("同步系统人员缓存error : " + e.getMessage()); - Util.logErrorStr(e); - } - } - } - - - - - - - } diff --git a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/row/HrmDepartmentRowDefinition.java b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/row/HrmDepartmentRowDefinition.java index fa1c7c8..efbbedf 100644 --- a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/row/HrmDepartmentRowDefinition.java +++ b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/row/HrmDepartmentRowDefinition.java @@ -45,8 +45,14 @@ public class HrmDepartmentRowDefinition extends XkHospitalCommonDefinition imple throw new CustomerException("从 " + table + " 获取下一个id失败!"); } rowDefinition.setDataId(nextId); - rowDefinition.getWhereParam().put("id", nextId); - rowDefinition.setConditionScript(" id = #{whereItem.id}"); + if(HRM_RESOURCE.equals(table)){ + rowDefinition.getUpdateParam().put("id", nextId); + rowDefinition.setConditionScript(""); + return false; + }else { + rowDefinition.getWhereParam().put("id", nextId); + rowDefinition.setConditionScript(" id = #{whereItem.id}"); + } } return true; } diff --git a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/table/HrmDepartmentTableDefinition.java b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/table/HrmDepartmentTableDefinition.java index e36e021..bc637bf 100644 --- a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/table/HrmDepartmentTableDefinition.java +++ b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/table/HrmDepartmentTableDefinition.java @@ -9,6 +9,7 @@ import com.api.xuanran.wang.xk_hospital.data_async.definitions.XkHospitalCommonD import lombok.AllArgsConstructor; import lombok.NoArgsConstructor; import org.apache.commons.collections.CollectionUtils; +import weaver.matrix.MatrixUtil; import java.util.List; import java.util.Map; @@ -38,16 +39,36 @@ public class HrmDepartmentTableDefinition extends XkHospitalCommonDefinition imp .map(RowDefinition::getDataId) .filter(dataId -> dataId > 0) .collect(Collectors.toList()); - if(CollectionUtils.isEmpty(idList)){ - return; - } - if(!flag){ - if (!this.dataAsyncMapper.deleteHrmDepart(idList)) { + if (!flag) { + if (CollectionUtils.isNotEmpty(idList) && !this.dataAsyncMapper.deleteHrmDepart(idList)) { log.error("删除 " + table + " 表数据失败!"); } throw new CustomerException("同步 " + table + " 表数据失败!"); - }else { - synCache(table, idList); + } else { + if (HRM_RESOURCE.equals(table)) { + try { + if(CollectionUtils.isNotEmpty(idList)) { + List> hrmSubList = dataAsyncMapper.selectHrmSubByHrmIdList(idList); + hrmSubList.forEach(map -> { + THEME_SERVICE.createSubCompanyMenu(map.get("id"), map.get("sub")); + }); + } + RESOURCE_COM_INFO.removeCache(); + } catch (Exception e) { + log.error("同步系统人员缓存error : " + e.getMessage()); + Util.logErrorStr(e); + } + } else if (DEPARTMENT.equals(table)) { + threadPoolInstance.execute(() -> { + try { + DEPARTMENT_COM_INFO.removeCache(); + MatrixUtil.sysDepartmentData(); + } catch (Exception e) { + log.error("同步系统部门缓存error : " + e.getMessage()); + Util.logErrorStr(e); + } + }); + } } } } diff --git a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/mapper/XkHospitalDataAsyncMapper.java b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/mapper/XkHospitalDataAsyncMapper.java index 4b59630..0efd014 100644 --- a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/mapper/XkHospitalDataAsyncMapper.java +++ b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/mapper/XkHospitalDataAsyncMapper.java @@ -14,10 +14,10 @@ import java.util.Map; @SqlMapper public interface XkHospitalDataAsyncMapper { - @Delete("delete from hrmdepartment where id in $t{idList}") + @Delete("delete from hrmdepartment where id in ($t{idList})") boolean deleteHrmDepart(@ParamMapper("idList") List idList); - @Select("select id, subcompanyid1 as sub from hrmresource where id in $t{idList}") + @Select("select id, subcompanyid1 as sub from hrmresource where id in ($t{idList})") @ToLowerCase List> selectHrmSubByHrmIdList(@ParamMapper("idList") List idList); diff --git a/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalTest.java b/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalTest.java index 4f0f792..99171ed 100644 --- a/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalTest.java +++ b/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalTest.java @@ -1,6 +1,7 @@ package xuanran.wang.xk_hospital.test; +import aiyh.utils.Util; import basetest.BaseTest; import com.alibaba.fastjson.JSONObject; import com.api.xuanran.wang.xk_hospital.data_async.service.XkHospitalCommonDataAsyncService; @@ -34,4 +35,39 @@ public class XkHospitalTest extends BaseTest { Map map = JSONObject.parseObject(json, Map.class); service.async("4bce0693734a","dept",map); } + + @Test + public void testB(){ + String json2 = "{\n" + + "\t\"ID\":\"1\",\n" + + "\t\"DeptCode\":\"test3\",\n" + + "\t\"DeptName\":\"科室测试名称3\",\n" + + "\t\"DeptLevel\": null, \n" + + "\t\"ParentDeptCode\": \"test2\",\n" + + "\t\"IsDelete\": false, \n" + + "\t\"Remark\":\"备注\"\n" + + "}\n"; + + Map map2 = JSONObject.parseObject(json2, Map.class); + service.async("4bce0693734a","dept",map2); + + String json = "{\n" + + "\t\"ID\":\"1\",\n" + + "\t\"EmplCode\":\"TEST1\",\n" + + "\t\"EmplName\":\"测试人员1\",\n" + + "\t\"EmplType\":\"人员类型代码\",\n" + + "\t\"EmplTypeCaption\":\"人员类型名称\",\n" + + "\t\"Gender\":\"男\",\n" + + "\t\"DeptCode\":\"test3\",\n" + + "\t\"DeptName\":\"科室名称\",\n" + + "\t\"EmplTitle\":\"职称代码\",\n" + + "\t\"EmplTitleCaption\":\"职称名称\",\n" + + "\t\"EmplPosition\":\"职务代码\",\n" + + "\t\"EmplPositionCaption\":\"职务名称\",\n" + + "\t\"Remark\":\"备注\"\n" + + "}\n"; + Map map = JSONObject.parseObject(json, Map.class); + Util.null2DefaultStr(null,""); + service.async("4bce0693734c","hrm",map); + } } From 0d95cb574615d5c4aaac2f79405baf64fc59576a Mon Sep 17 00:00:00 2001 From: ic_excellent <2570192571@qq.com> Date: Wed, 19 Jul 2023 17:17:57 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=A4=84=E7=90=86?= =?UTF-8?q?=E6=98=8E=E7=BB=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aiyh/utils/response_deal/state/NoHandleState.java | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/main/java/aiyh/utils/response_deal/state/NoHandleState.java diff --git a/src/main/java/aiyh/utils/response_deal/state/NoHandleState.java b/src/main/java/aiyh/utils/response_deal/state/NoHandleState.java new file mode 100644 index 0000000..09b5348 --- /dev/null +++ b/src/main/java/aiyh/utils/response_deal/state/NoHandleState.java @@ -0,0 +1,8 @@ +package aiyh.utils.response_deal.state;/** + *@ClassName NoHandleState + *@Author 肖博亢 + *@Date 2023/7/19 16:51 + *@Description

+ **/ +public class NoHandleState { +} From fe37d194a39fc081868e5431a84665885f91e66f Mon Sep 17 00:00:00 2001 From: ic_excellent <2570192571@qq.com> Date: Wed, 19 Jul 2023 17:19:33 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=A4=84=E7=90=86?= =?UTF-8?q?=E6=98=8E=E7=BB=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../response_deal/ResponseMappingDeal.java | 1 + .../utils/response_deal/state/InsertSate.java | 18 ++++++---- .../response_deal/state/NoHandleState.java | 34 +++++++++++++++---- .../xiao/sh_bigdata/mapper/ReportMapper.java | 8 ++--- 4 files changed, 45 insertions(+), 16 deletions(-) diff --git a/src/main/java/aiyh/utils/response_deal/ResponseMappingDeal.java b/src/main/java/aiyh/utils/response_deal/ResponseMappingDeal.java index 81f6d36..0f1977c 100644 --- a/src/main/java/aiyh/utils/response_deal/ResponseMappingDeal.java +++ b/src/main/java/aiyh/utils/response_deal/ResponseMappingDeal.java @@ -117,6 +117,7 @@ public class ResponseMappingDeal { .tableDefinitionCallback(this.tableCallback) .tableType(responseConfig.getTableType()) .assignType(ResponseConfigConstant.NO_HANDLE) + .tableDefinitionCallback(tableCallback) .assignTable(responseConfig.getModelTableName()).build(); } // 做数据处理 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 e0965cc..5863560 100644 --- a/src/main/java/aiyh/utils/response_deal/state/InsertSate.java +++ b/src/main/java/aiyh/utils/response_deal/state/InsertSate.java @@ -65,17 +65,23 @@ public class InsertSate extends State{ flag = this.configMapper.executeUpdateBatchCusSql(updateSql, updateList, whereList); String modeId = Util.getModeIdByTableName(assignTable); Util.rebuildModeDataShareByAsyncList(1,modeId,dataIdList); - if(ResponseUtil.parameterIsNotNull(detailTableMap) && flag){ - detailTableMap.forEach((key,value)->{ - value.setDefaultState(null); - value.dataProcess(); - }); - } }else { String insertSql = MapperBuilderSql.builderInsertSql(assignTable, tempRowDefinition.getUpdateParam(),"item"); List> insertList = rowDefinitionList.stream().map(RowDefinition::getUpdateParam).collect(Collectors.toList()); + rowDefinitionList.forEach(item ->{ + if(mainOrDetail == ResponseConfigConstant.MAIN_TABLE){ + detailTableDeal(item,detailTableMap); + } + insertList.add(item.getUpdateParam()); + }); flag = this.configMapper.executeInsertBatchCusSql(insertSql, insertList); } + if(ResponseUtil.parameterIsNotNull(detailTableMap) && flag){ + detailTableMap.forEach((key,value)->{ + value.setDefaultState(null); + value.dataProcess(); + }); + } if(ResponseUtil.parameterIsNotNull(this.context.getTableDefinitionCallback())){ this.context.getTableDefinitionCallback().afterHandle(this.context,flag); } diff --git a/src/main/java/aiyh/utils/response_deal/state/NoHandleState.java b/src/main/java/aiyh/utils/response_deal/state/NoHandleState.java index 09b5348..537b4fd 100644 --- a/src/main/java/aiyh/utils/response_deal/state/NoHandleState.java +++ b/src/main/java/aiyh/utils/response_deal/state/NoHandleState.java @@ -1,8 +1,30 @@ -package aiyh.utils.response_deal.state;/** - *@ClassName NoHandleState - *@Author 肖博亢 - *@Date 2023/7/19 16:51 - *@Description

+package aiyh.utils.response_deal.state; + +import aiyh.utils.response_deal.constant.ResponseConfigConstant; +import aiyh.utils.response_deal.entity.TableDefinition; +import aiyh.utils.response_deal.util.ResponseUtil; + +import java.util.HashMap; +import java.util.Map; + +/** + * @ClassName NoHandleState + * @Author 肖博亢 + * @Date 2023/7/19 16:51 + * @Description

**/ -public class NoHandleState { +public class NoHandleState extends State{ + + @Override + public void handle() { + if(this.context.getMainOrDetail() == ResponseConfigConstant.MAIN_TABLE) { + Map detailTableMap = this.context.getDetailTableMap(); + if (ResponseUtil.parameterIsNotNull(detailTableMap)) { + detailTableMap.forEach((key, value) -> { + value.setDefaultState(null); + value.dataProcess(); + }); + } + } + } } 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 e1fd1d5..4cdc5df 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,13 +37,13 @@ public interface ReportMapper { @CaseConversion(value = false) List> queryReportData2(@ParamMapper("param") Map param,@ParamMapper("uid") int uid); - @Select("select main.* " + + @Select("select main.*," + " (select lastname from hrmresource where id = dyjbr) dyjbr_span," + " (select lastname from hrmresource where id = djr) djr_span," + " (select LISTAGG(concat(wb, ',', dw), '-') WITHIN GROUP (ORDER BY wb) from uf_zwfwdjjmb_dt1 where mainid = main.id) ysdx," + - " (select LISTAGG(concat(dwclwb,'(', dwcljsywb,')'), ',') WITHIN GROUP (ORDER BY wb) from uf_zwfwdjjmb_dt3 where mainid = main.id) car_people," + - " (select LISTAGG(concat(gzclwb,'(', gzcljsywb,')'), ',') WITHIN GROUP (ORDER BY wb) from uf_zwfwdjjmb_dt4 where mainid = main.id) work_people," + - " (select LISTAGG(concat(fjhwb,'(', ysdxwb,')'), ',') WITHIN GROUP (ORDER BY wb) from uf_zwfwdjjmb_dt2 where mainid = main.id) put_up" + + " (select LISTAGG(concat(dwclwb,'(', dwcljsywb,')'), ',') WITHIN GROUP (ORDER BY dwclwb) from uf_zwfwdjjmb_dt3 where mainid = main.id) car_people," + + " (select LISTAGG(concat(gzclwb,'(', gzcljsywb,')'), ',') WITHIN GROUP (ORDER BY gzclwb) from uf_zwfwdjjmb_dt4 where mainid = main.id) work_people," + + " (select LISTAGG(concat(fjhwb,'(', ysdxwb,')'), ',') WITHIN GROUP (ORDER BY fjhwb) from uf_zwfwdjjmb_dt2 where mainid = main.id) put_up " + "from uf_zwfwdjjmb main $t{param.whereSql} " + "order by dlsk1 ") @CaseConversion(value = false) From 9658ce154f9cdab03a7af0dcdebdf5ff8c2e74b0 Mon Sep 17 00:00:00 2001 From: wangxuanran <3055088966@qq.com> Date: Thu, 20 Jul 2023 10:32:08 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E5=93=8D=E5=BA=94=E5=9B=9E=E5=86=99?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../response_deal/ResponseMappingDeal.java | 10 +++++ .../state/InsertOrUpdateState.java | 3 +- .../utils/response_deal/state/InsertSate.java | 2 +- .../row/HrmDepartmentRowDefinition.java | 45 +++++++++++-------- .../wang/xk_hospital/test/XkHospitalTest.java | 24 +++++----- 5 files changed, 51 insertions(+), 33 deletions(-) diff --git a/src/main/java/aiyh/utils/response_deal/ResponseMappingDeal.java b/src/main/java/aiyh/utils/response_deal/ResponseMappingDeal.java index 0f1977c..4d8fd4d 100644 --- a/src/main/java/aiyh/utils/response_deal/ResponseMappingDeal.java +++ b/src/main/java/aiyh/utils/response_deal/ResponseMappingDeal.java @@ -68,6 +68,16 @@ public class ResponseMappingDeal { logger.info(String.format("%s 相关响应配置信息==> %s", uniqueCode, JSON.toJSONString(responseConfigList))); // 自定义校验 ResponseUtil.parameterJudgment(responseConfigList, "response config is empty please check!!! "); + // 将所有跟sql有关的字段全部全角转半角 + responseConfigList.forEach(item-> { + item.getResponseConfigAliasList().forEach(responseConfigAlias -> { + responseConfigAlias.setConditionScript(Util.sbc2dbcCase(responseConfigAlias.getConditionScript())); + responseConfigAlias.setJudgmentScript(Util.sbc2dbcCase(responseConfigAlias.getJudgmentScript())); + }); + item.getValueChangeList().forEach(responseConfigValueChange -> { + responseConfigValueChange.setCusText(Util.sbc2dbcCase(responseConfigValueChange.getCusText())); + }); + }); Map tableNameConfig; try { // 对查询到的多个配置进行整合,以同步表表名作为key 配置作为value diff --git a/src/main/java/aiyh/utils/response_deal/state/InsertOrUpdateState.java b/src/main/java/aiyh/utils/response_deal/state/InsertOrUpdateState.java index db7e023..c8d8361 100644 --- a/src/main/java/aiyh/utils/response_deal/state/InsertOrUpdateState.java +++ b/src/main/java/aiyh/utils/response_deal/state/InsertOrUpdateState.java @@ -1,5 +1,6 @@ package aiyh.utils.response_deal.state; +import aiyh.utils.Util; import aiyh.utils.response_deal.constant.ResponseConfigConstant; import aiyh.utils.response_deal.entity.RowDefinition; import aiyh.utils.response_deal.entity.TableDefinition; @@ -58,7 +59,7 @@ public class InsertOrUpdateState extends State{ } private boolean judgmentRepetition(RowDefinition rowDefinition){ - String conditionScript = rowDefinition.getConditionScript(); + String conditionScript = Util.sbc2dbcCase(rowDefinition.getConditionScript()); String cusQuerySql = "select id from " + rowDefinition.getAssignTable() + " where " + conditionScript; String dataId = this.configMapper.executeCusQuerySql(cusQuerySql, rowDefinition.getWhereParam(),new HashMap<>()); return StrUtil.isNotBlank(dataId); 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 5863560..3f8f98d 100644 --- a/src/main/java/aiyh/utils/response_deal/state/InsertSate.java +++ b/src/main/java/aiyh/utils/response_deal/state/InsertSate.java @@ -67,7 +67,7 @@ public class InsertSate extends State{ Util.rebuildModeDataShareByAsyncList(1,modeId,dataIdList); }else { String insertSql = MapperBuilderSql.builderInsertSql(assignTable, tempRowDefinition.getUpdateParam(),"item"); - List> insertList = rowDefinitionList.stream().map(RowDefinition::getUpdateParam).collect(Collectors.toList()); + List> insertList = new ArrayList<>(); rowDefinitionList.forEach(item ->{ if(mainOrDetail == ResponseConfigConstant.MAIN_TABLE){ detailTableDeal(item,detailTableMap); diff --git a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/row/HrmDepartmentRowDefinition.java b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/row/HrmDepartmentRowDefinition.java index efbbedf..50ac6fe 100644 --- a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/row/HrmDepartmentRowDefinition.java +++ b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/row/HrmDepartmentRowDefinition.java @@ -2,6 +2,7 @@ package com.api.xuanran.wang.xk_hospital.data_async.definitions.row; import aiyh.utils.Util; import aiyh.utils.excention.CustomerException; +import aiyh.utils.response_deal.constant.ResponseConfigConstant; import aiyh.utils.response_deal.entity.RowDefinition; import aiyh.utils.response_deal.intfaces.RowDefinitionCallback; import aiyh.utils.response_deal.mapper.ConfigMapper; @@ -9,6 +10,7 @@ import aiyh.utils.tool.cn.hutool.core.util.StrUtil; import com.api.xuanran.wang.xk_hospital.data_async.definitions.XkHospitalCommonDefinition; import lombok.AllArgsConstructor; import lombok.NoArgsConstructor; +import org.apache.commons.lang3.StringUtils; import weaver.conn.RecordSet; import java.util.HashMap; @@ -31,28 +33,33 @@ public class HrmDepartmentRowDefinition extends XkHospitalCommonDefinition imple @Override public boolean judgmentRepetition(RowDefinition rowDefinition) { - String conditionScript = rowDefinition.getConditionScript(); + int orDetail = rowDefinition.getMainOrDetail(); + String conditionScript = Util.sbc2dbcCase(rowDefinition.getConditionScript()); String cusQuerySql = "select id from " + rowDefinition.getAssignTable() + " where " + conditionScript; String dataId = configMapper.executeCusQuerySql(cusQuerySql, rowDefinition.getWhereParam(),new HashMap<>()); - if(StrUtil.isBlank(dataId)){ - int nextId = -1; - if(HRM_RESOURCE.equals(table)){ - nextId = Util.getNextHrmId(); - }else if(DEPARTMENT.equals(table)){ - nextId = Util.getNextDepartmentId(); - } - if(nextId < 0){ - throw new CustomerException("从 " + table + " 获取下一个id失败!"); - } - rowDefinition.setDataId(nextId); - if(HRM_RESOURCE.equals(table)){ - rowDefinition.getUpdateParam().put("id", nextId); - rowDefinition.setConditionScript(""); - return false; - }else { - rowDefinition.getWhereParam().put("id", nextId); - rowDefinition.setConditionScript(" id = #{whereItem.id}"); + if(ResponseConfigConstant.MAIN_TABLE == orDetail){ + if(StrUtil.isBlank(dataId)){ + int nextId = -1; + if(HRM_RESOURCE.equals(table)){ + nextId = Util.getNextHrmId(); + }else if(DEPARTMENT.equals(table)){ + nextId = Util.getNextDepartmentId(); + } + if(nextId < 0){ + throw new CustomerException("从 " + table + " 获取下一个id失败!"); + } + rowDefinition.setDataId(nextId); + if(HRM_RESOURCE.equals(table)){ + rowDefinition.getUpdateParam().put("id", nextId); + rowDefinition.setConditionScript(""); + return false; + }else { + rowDefinition.getWhereParam().put("id", nextId); + rowDefinition.setConditionScript(" id = #{whereItem.id}"); + } } + }else { + return StringUtils.isNotBlank(dataId); } return true; } diff --git a/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalTest.java b/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalTest.java index 99171ed..3572963 100644 --- a/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalTest.java +++ b/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalTest.java @@ -38,18 +38,18 @@ public class XkHospitalTest extends BaseTest { @Test public void testB(){ - String json2 = "{\n" + - "\t\"ID\":\"1\",\n" + - "\t\"DeptCode\":\"test3\",\n" + - "\t\"DeptName\":\"科室测试名称3\",\n" + - "\t\"DeptLevel\": null, \n" + - "\t\"ParentDeptCode\": \"test2\",\n" + - "\t\"IsDelete\": false, \n" + - "\t\"Remark\":\"备注\"\n" + - "}\n"; - - Map map2 = JSONObject.parseObject(json2, Map.class); - service.async("4bce0693734a","dept",map2); + // String json2 = "{\n" + + // "\t\"ID\":\"1\",\n" + + // "\t\"DeptCode\":\"test3\",\n" + + // "\t\"DeptName\":\"科室测试名称3\",\n" + + // "\t\"DeptLevel\": null, \n" + + // "\t\"ParentDeptCode\": \"test2\",\n" + + // "\t\"IsDelete\": false, \n" + + // "\t\"Remark\":\"备注\"\n" + + // "}\n"; + // + // Map map2 = JSONObject.parseObject(json2, Map.class); + // service.async("4bce0693734a","dept",map2); String json = "{\n" + "\t\"ID\":\"1\",\n" + From 0de7a593e9d10cf587a45a3aae3a2c5e8fcf6590 Mon Sep 17 00:00:00 2001 From: wangxuanran <3055088966@qq.com> Date: Thu, 20 Jul 2023 13:03:20 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../state/InsertOrUpdateState.java | 3 ++ .../utils/response_deal/state/InsertSate.java | 1 + .../aiyh/utils/response_deal/state/State.java | 2 +- .../response_deal/state/UpdateState.java | 6 +++ .../table/HrmDepartmentTableDefinition.java | 15 +++++- .../wang/xk_hospital/test/XkHospitalTest.java | 48 ++++++++++++++++++- 6 files changed, 71 insertions(+), 4 deletions(-) diff --git a/src/main/java/aiyh/utils/response_deal/state/InsertOrUpdateState.java b/src/main/java/aiyh/utils/response_deal/state/InsertOrUpdateState.java index c8d8361..1ec7952 100644 --- a/src/main/java/aiyh/utils/response_deal/state/InsertOrUpdateState.java +++ b/src/main/java/aiyh/utils/response_deal/state/InsertOrUpdateState.java @@ -62,6 +62,9 @@ public class InsertOrUpdateState extends State{ String conditionScript = Util.sbc2dbcCase(rowDefinition.getConditionScript()); String cusQuerySql = "select id from " + rowDefinition.getAssignTable() + " where " + conditionScript; String dataId = this.configMapper.executeCusQuerySql(cusQuerySql, rowDefinition.getWhereParam(),new HashMap<>()); + if(StrUtil.isNotBlank(dataId)){ + rowDefinition.setDataId(Util.getIntValue(dataId, -1)); + } return StrUtil.isNotBlank(dataId); } 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 3f8f98d..31cf7b7 100644 --- a/src/main/java/aiyh/utils/response_deal/state/InsertSate.java +++ b/src/main/java/aiyh/utils/response_deal/state/InsertSate.java @@ -97,6 +97,7 @@ public class InsertSate extends State{ } rowDefinitionList.forEach(item ->{ item.getUpdateParam().put("mainid",mainId); + item.getWhereParam().put("mainid",mainId); }); if(mainDetailMap.containsKey(key)){ TableDefinition tableDefinition = mainDetailMap.get(key); diff --git a/src/main/java/aiyh/utils/response_deal/state/State.java b/src/main/java/aiyh/utils/response_deal/state/State.java index 6bea1b3..29a0a3b 100644 --- a/src/main/java/aiyh/utils/response_deal/state/State.java +++ b/src/main/java/aiyh/utils/response_deal/state/State.java @@ -16,7 +16,7 @@ public abstract class State { protected final ConfigMapper configMapper = Util.getMapper(ConfigMapper.class); /** 日志对象 */ - protected final Logger logger = Util.getLogger(); + protected final Logger logger = Util.getLogger("json_util"); /** 上下文对象 */ protected TableDefinition context; diff --git a/src/main/java/aiyh/utils/response_deal/state/UpdateState.java b/src/main/java/aiyh/utils/response_deal/state/UpdateState.java index 2a64808..b7c4ebe 100644 --- a/src/main/java/aiyh/utils/response_deal/state/UpdateState.java +++ b/src/main/java/aiyh/utils/response_deal/state/UpdateState.java @@ -83,6 +83,12 @@ public class UpdateState extends State { return; } detailTableMap.forEach((key,value) ->{ + if(item.getDataId() > 0){ + for (RowDefinition rowDefinition : value.getRowDefinitionList()) { + rowDefinition.getUpdateParam().put("mainid", item.getDataId()); + rowDefinition.getWhereParam().put("mainid", item.getDataId()); + } + } if(mainDetailMap.containsKey(key)){ mainDetailMap.get(key).getRowDefinitionList().addAll(value.getRowDefinitionList()); }else { diff --git a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/table/HrmDepartmentTableDefinition.java b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/table/HrmDepartmentTableDefinition.java index bc637bf..8d7aac7 100644 --- a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/table/HrmDepartmentTableDefinition.java +++ b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/table/HrmDepartmentTableDefinition.java @@ -2,6 +2,7 @@ package com.api.xuanran.wang.xk_hospital.data_async.definitions.table; import aiyh.utils.Util; import aiyh.utils.excention.CustomerException; +import aiyh.utils.response_deal.constant.ResponseConfigConstant; import aiyh.utils.response_deal.entity.RowDefinition; import aiyh.utils.response_deal.entity.TableDefinition; import aiyh.utils.response_deal.intfaces.TableDefinitionCallback; @@ -13,6 +14,7 @@ import weaver.matrix.MatrixUtil; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.stream.Collectors; /** @@ -29,7 +31,18 @@ public class HrmDepartmentTableDefinition extends XkHospitalCommonDefinition imp @Override public void tableHandle(TableDefinition tableDefinition) { - + if(ResponseConfigConstant.DETAIL_TABLE == tableDefinition.getMainOrDetail()){ + List list = tableDefinition.getRowDefinitionList(); + if(CollectionUtils.isEmpty(list)){ + return; + } + for (RowDefinition rowDefinition : list) { + Object mainId = rowDefinition.getUpdateParam().remove("mainid"); + if(!Objects.isNull(mainId)){ + rowDefinition.getUpdateParam().put("id", mainId); + } + } + } } @Override diff --git a/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalTest.java b/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalTest.java index 3572963..1afaa31 100644 --- a/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalTest.java +++ b/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalTest.java @@ -53,8 +53,8 @@ public class XkHospitalTest extends BaseTest { String json = "{\n" + "\t\"ID\":\"1\",\n" + - "\t\"EmplCode\":\"TEST1\",\n" + - "\t\"EmplName\":\"测试人员1\",\n" + + "\t\"EmplCode\":\"TEST10\",\n" + + "\t\"EmplName\":\"测试人员10\",\n" + "\t\"EmplType\":\"人员类型代码\",\n" + "\t\"EmplTypeCaption\":\"人员类型名称\",\n" + "\t\"Gender\":\"男\",\n" + @@ -70,4 +70,48 @@ public class XkHospitalTest extends BaseTest { Util.null2DefaultStr(null,""); service.async("4bce0693734c","hrm",map); } + + @Test + public void testC(){ + String json = "{\n" + + "\t\"ID\":\"主键\",\n" + + "\t\"GroupID\":\"test_yl_01\",\n" + + "\t\"GroupCode\":\"test_yl_dm_03\",\n" + + "\t\"GroupName\":\"医疗组名称1\",\n" + + "\t\"DeptCode\":\"test03\",\n" + + "\t\"DeptName\":\"测试科室03\",\n" + + "\t\"WardCode\":\"病区代码\",\n" + + "\t\"WardName\":\"病区名称\",\n" + + "\t\"Ward_BedNumber\":\"病区床位数,int类型\",\n" + + "\t\"IsDelete\":\"是否停用,bool类型\",\n" + + "\t\"Remark\":\"备注\",\n" + + "\t\"Wards\":[\t\n" + + "\t\t{\t\t\t\n" + + "\t\t\t\"ID\":\"1\",\n" + + "\t\t\t\"WardCode\":\"bq_01\",\n" + + "\t\t\t\"WardName\":\"病区名称01_2_3\"\n" + + "\t\t},{\t\t\t\n" + + "\t\t\t\"ID\":\"2\",\n" + + "\t\t\t\"WardCode\":\"bq_03\",\n" + + "\t\t\t\"WardName\":\"病区名称02_1_3\"\n" + + "\t\t}\n" + + "\t],\n" + + "\t\"WardHeads\":[\n" + + "\t\t{\n" + + "\t\t\t\"ID\":\"1\",\n" + + "\t\t\t\"EmplCode\":\"TEST10\",\n" + + "\t\t\t\"EmplName\":\"傻逼01\",\n" + + "\t\t\t\"Category\":\"人员分组,当人员为主治和住院医师时使用\"\n" + + "\t\t},{\n" + + "\t\t\t\"ID\":\"2\",\n" + + "\t\t\t\"EmplCode\":\"TEST10\",\n" + + "\t\t\t\"EmplName\":\"傻逼02\",\n" + + "\t\t\t\"Category\":\"人员分组,当人员为主治和住院医师时使用\"\n" + + "\t\t}\n" + + "\t]\n" + + "}\n"; + Map map = JSONObject.parseObject(json, Map.class); + Util.null2DefaultStr(null,""); + service.async("4bce0693734d","common", map); + } } From 7970a2456bb9836a9cdb8e1ec0310821aacbb792 Mon Sep 17 00:00:00 2001 From: wangxuanran <3055088966@qq.com> Date: Thu, 20 Jul 2023 13:17:45 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../state/InsertOrUpdateState.java | 11 ++++++++++- .../utils/response_deal/state/InsertSate.java | 17 +++++++++++++++-- .../utils/response_deal/state/UpdateState.java | 12 +++++++++++- .../controller/CommonDataAsyncController.java | 6 ++++++ .../XkHospitalCommonDataAsyncServiceImpl.java | 2 +- 5 files changed, 43 insertions(+), 5 deletions(-) diff --git a/src/main/java/aiyh/utils/response_deal/state/InsertOrUpdateState.java b/src/main/java/aiyh/utils/response_deal/state/InsertOrUpdateState.java index 1ec7952..cd59460 100644 --- a/src/main/java/aiyh/utils/response_deal/state/InsertOrUpdateState.java +++ b/src/main/java/aiyh/utils/response_deal/state/InsertOrUpdateState.java @@ -1,6 +1,8 @@ package aiyh.utils.response_deal.state; import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; +import aiyh.utils.excention.ParseSqlException; import aiyh.utils.response_deal.constant.ResponseConfigConstant; import aiyh.utils.response_deal.entity.RowDefinition; import aiyh.utils.response_deal.entity.TableDefinition; @@ -8,6 +10,7 @@ import aiyh.utils.response_deal.intfaces.RowDefinitionCallback; import aiyh.utils.response_deal.util.ResponseUtil; import aiyh.utils.tool.cn.hutool.core.bean.BeanUtil; import aiyh.utils.tool.cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONObject; import java.util.ArrayList; import java.util.HashMap; @@ -61,7 +64,13 @@ public class InsertOrUpdateState extends State{ private boolean judgmentRepetition(RowDefinition rowDefinition){ String conditionScript = Util.sbc2dbcCase(rowDefinition.getConditionScript()); String cusQuerySql = "select id from " + rowDefinition.getAssignTable() + " where " + conditionScript; - String dataId = this.configMapper.executeCusQuerySql(cusQuerySql, rowDefinition.getWhereParam(),new HashMap<>()); + String dataId; + try { + dataId = this.configMapper.executeCusQuerySql(cusQuerySql, rowDefinition.getWhereParam(),new HashMap<>()); + }catch (ParseSqlException e){ + logger.error(Util.logStr("parse sql error, current sql : [{}], whereParam : [{}]", cusQuerySql, JSONObject.toJSONString(rowDefinition.getWhereParam()))); + throw new CustomerException(e); + } if(StrUtil.isNotBlank(dataId)){ rowDefinition.setDataId(Util.getIntValue(dataId, -1)); } 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 31cf7b7..7567239 100644 --- a/src/main/java/aiyh/utils/response_deal/state/InsertSate.java +++ b/src/main/java/aiyh/utils/response_deal/state/InsertSate.java @@ -1,12 +1,15 @@ package aiyh.utils.response_deal.state; import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; +import aiyh.utils.excention.ParseSqlException; import aiyh.utils.recordset.MapperBuilderSql; import aiyh.utils.response_deal.constant.ResponseConfigConstant; import aiyh.utils.response_deal.entity.RowDefinition; import aiyh.utils.response_deal.entity.TableDefinition; import aiyh.utils.response_deal.intfaces.RowDefinitionCallback; import aiyh.utils.response_deal.util.ResponseUtil; +import com.alibaba.fastjson.JSONObject; import java.util.ArrayList; import java.util.HashMap; @@ -62,7 +65,12 @@ public class InsertSate extends State{ } String updateSql = MapperBuilderSql.builderUpdateSql(assignTable, tempRowDefinition.getUpdateParam(),"upItem"); updateSql = updateSql + " where id = #{whereItem.id}"; - flag = this.configMapper.executeUpdateBatchCusSql(updateSql, updateList, whereList); + try { + flag = this.configMapper.executeUpdateBatchCusSql(updateSql, updateList, whereList); + }catch (ParseSqlException e){ + logger.error(Util.logStr("parse sql error, current sql : [{}], updateList : [{}], whereList : [{}]", updateSql, JSONObject.toJSONString(updateList), JSONObject.toJSONString(whereList))); + throw new CustomerException(e); + } String modeId = Util.getModeIdByTableName(assignTable); Util.rebuildModeDataShareByAsyncList(1,modeId,dataIdList); }else { @@ -74,7 +82,12 @@ public class InsertSate extends State{ } insertList.add(item.getUpdateParam()); }); - flag = this.configMapper.executeInsertBatchCusSql(insertSql, insertList); + try { + flag = this.configMapper.executeInsertBatchCusSql(insertSql, insertList); + }catch (ParseSqlException e){ + logger.error(Util.logStr("parse sql error, current sql : [{}], insertList : [{}]", insertSql, JSONObject.toJSONString(insertList))); + throw new CustomerException(e); + } } if(ResponseUtil.parameterIsNotNull(detailTableMap) && flag){ detailTableMap.forEach((key,value)->{ diff --git a/src/main/java/aiyh/utils/response_deal/state/UpdateState.java b/src/main/java/aiyh/utils/response_deal/state/UpdateState.java index b7c4ebe..446c194 100644 --- a/src/main/java/aiyh/utils/response_deal/state/UpdateState.java +++ b/src/main/java/aiyh/utils/response_deal/state/UpdateState.java @@ -1,12 +1,16 @@ package aiyh.utils.response_deal.state; import aiyh.utils.ScriptUtil; +import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; +import aiyh.utils.excention.ParseSqlException; import aiyh.utils.recordset.MapperBuilderSql; import aiyh.utils.response_deal.constant.ResponseConfigConstant; import aiyh.utils.response_deal.entity.RowDefinition; import aiyh.utils.response_deal.entity.TableDefinition; import aiyh.utils.response_deal.exception.ResponseException; import aiyh.utils.response_deal.util.ResponseUtil; +import com.alibaba.fastjson.JSONObject; import java.util.ArrayList; import java.util.HashMap; @@ -58,7 +62,13 @@ public class UpdateState extends State { String tempConditionScript = rowDefinition.getConditionScript(); String updateSql = MapperBuilderSql.builderUpdateSql(assignTable, rowDefinition.getUpdateParam(),"upItem"); updateSql = updateSql + " where " + tempConditionScript; - boolean flag = this.configMapper.executeUpdateBatchCusSql(updateSql, updateList, whereList); + boolean flag; + try { + flag = this.configMapper.executeUpdateBatchCusSql(updateSql, updateList, whereList); + }catch (ParseSqlException e){ + logger.error(Util.logStr("parse sql error, current sql : [{}], updateList : [{}], whereList : [{}]", updateSql, JSONObject.toJSONString(updateList), JSONObject.toJSONString(whereList))); + throw new CustomerException(e); + } logger.info("批量更新处理结果 ==>"+flag); if(ResponseUtil.parameterIsNotNull(this.context.getTableDefinitionCallback())){ this.context.getTableDefinitionCallback().afterHandle(this.context,flag); 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 index 024f20d..4f07883 100644 --- 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 @@ -2,6 +2,8 @@ package com.api.xuanran.wang.xk_hospital.data_async.controller; import aiyh.utils.ApiResult; import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; +import aiyh.utils.tool.cn.hutool.core.util.StrUtil; import com.api.xuanran.wang.xk_hospital.data_async.service.XkHospitalCommonDataAsyncService; import com.api.xuanran.wang.xk_hospital.data_async.service.impl.XkHospitalCommonDataAsyncServiceImpl; import io.swagger.v3.oas.annotations.parameters.RequestBody; @@ -37,6 +39,10 @@ public class CommonDataAsyncController { @PathParam("type") String type, @RequestBody Map params){ try { + if(StrUtil.isBlank(configId) || StrUtil.isBlank(type)){ + throw new CustomerException("configId or type can not be empty!"); + } + logger.info(Util.logStr("configId : {}, type : {}, params : {}", configId, type, params)); service.async(configId, type, params); return ApiResult.successNoData(); }catch (Exception e){ diff --git a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/service/impl/XkHospitalCommonDataAsyncServiceImpl.java b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/service/impl/XkHospitalCommonDataAsyncServiceImpl.java index d8e16cc..6dbebf9 100644 --- a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/service/impl/XkHospitalCommonDataAsyncServiceImpl.java +++ b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/service/impl/XkHospitalCommonDataAsyncServiceImpl.java @@ -13,7 +13,7 @@ import java.util.HashMap; import java.util.Map; /** - *

+ *

数据同步

* * @author xuanran.wang * @date 2023/7/18 11:15