Merge remote-tracking branch 'origin/dev' into dev

dev
weilin.zhu 2023-07-20 13:24:04 +08:00
commit d54194caf3
16 changed files with 321 additions and 103 deletions

View File

@ -12,6 +12,7 @@ import aiyh.utils.mapUtil.UtilHashMap;
import aiyh.utils.mapUtil.UtilLinkedHashMap; import aiyh.utils.mapUtil.UtilLinkedHashMap;
import aiyh.utils.mapper.UtilMapper; import aiyh.utils.mapper.UtilMapper;
import aiyh.utils.recordset.RecordsetUtil; import aiyh.utils.recordset.RecordsetUtil;
import aiyh.utils.recordset.RsThreadLocalManager;
import aiyh.utils.service.UtilService; import aiyh.utils.service.UtilService;
import aiyh.utils.sqlUtil.builderSql.impl.BuilderSqlImpl; import aiyh.utils.sqlUtil.builderSql.impl.BuilderSqlImpl;
import aiyh.utils.sqlUtil.whereUtil.Where; import aiyh.utils.sqlUtil.whereUtil.Where;
@ -106,6 +107,7 @@ public class Util extends weaver.general.Util {
static ToolUtil toolUtil = new ToolUtil(); static ToolUtil toolUtil = new ToolUtil();
private static RecordSet rs; private static RecordSet rs;
private static volatile Logger log = null; private static volatile Logger log = null;
private static final RsThreadLocalManager LOCAL_MANAGER = new RsThreadLocalManager();
static { static {
try { try {
@ -4111,14 +4113,15 @@ public class Util extends weaver.general.Util {
* @return id * @return id
**/ **/
public static int getNextDepartmentId(int subId){ public static int getNextDepartmentId(int subId){
RecordSet insertRs = new RecordSet();
char separator = weaver.general.Util.getSeparator(); char separator = weaver.general.Util.getSeparator();
String uuid = UUID.randomUUID().toString(); String uuid = UUID.randomUUID().toString();
String empty = "";
String para = uuid + separator +uuid + separator + String para = uuid + separator +uuid + separator +
"" + separator + "" + separator + subId + separator + 1 + separator + ""; empty + separator + empty + separator + subId + separator + 1 + separator + empty;
insertRs.executeProc("HrmDepartment_Insert", para); RecordSet procRs = getThreadRecord();
if(insertRs.next()){ procRs.executeProc("HrmDepartment_Insert", para);
return insertRs.getInt(1); if(procRs.next()){
return procRs.getInt(1);
} }
return -1; return -1;
} }
@ -4132,7 +4135,7 @@ public class Util extends weaver.general.Util {
* @return id * @return id
**/ **/
public static int getNextHrmId(){ public static int getNextHrmId(){
RecordSet procRs = new RecordSet(); RecordSet procRs = getThreadRecord();
procRs.executeProc("HrmResourceMaxId_Get", ""); procRs.executeProc("HrmResourceMaxId_Get", "");
if (procRs.next()) { if (procRs.next()) {
return procRs.getInt(1); return procRs.getInt(1);
@ -4140,5 +4143,35 @@ public class Util extends weaver.general.Util {
return -1; return -1;
} }
/**
* <h1>线rs</h1>
* @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);
}
/**
* <h1>rsrs</h1>
* @author xuanran.wang
* @dateTime 2023/7/19 15:29
* @param name rskey
* @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;
}
} }

View File

@ -68,6 +68,16 @@ public class ResponseMappingDeal {
logger.info(String.format("%s 相关响应配置信息==> %s", uniqueCode, JSON.toJSONString(responseConfigList))); logger.info(String.format("%s 相关响应配置信息==> %s", uniqueCode, JSON.toJSONString(responseConfigList)));
// 自定义校验 // 自定义校验
ResponseUtil.parameterJudgment(responseConfigList, "response config is empty please check!!! "); 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<String, ResponseConfig> tableNameConfig; Map<String, ResponseConfig> tableNameConfig;
try { try {
// 对查询到的多个配置进行整合以同步表表名作为key 配置作为value // 对查询到的多个配置进行整合以同步表表名作为key 配置作为value
@ -117,6 +127,7 @@ public class ResponseMappingDeal {
.tableDefinitionCallback(this.tableCallback) .tableDefinitionCallback(this.tableCallback)
.tableType(responseConfig.getTableType()) .tableType(responseConfig.getTableType())
.assignType(ResponseConfigConstant.NO_HANDLE) .assignType(ResponseConfigConstant.NO_HANDLE)
.tableDefinitionCallback(tableCallback)
.assignTable(responseConfig.getModelTableName()).build(); .assignTable(responseConfig.getModelTableName()).build();
} }
// 做数据处理 // 做数据处理

View File

@ -1,5 +1,8 @@
package aiyh.utils.response_deal.state; 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.constant.ResponseConfigConstant;
import aiyh.utils.response_deal.entity.RowDefinition; import aiyh.utils.response_deal.entity.RowDefinition;
import aiyh.utils.response_deal.entity.TableDefinition; import aiyh.utils.response_deal.entity.TableDefinition;
@ -7,6 +10,7 @@ import aiyh.utils.response_deal.intfaces.RowDefinitionCallback;
import aiyh.utils.response_deal.util.ResponseUtil; import aiyh.utils.response_deal.util.ResponseUtil;
import aiyh.utils.tool.cn.hutool.core.bean.BeanUtil; import aiyh.utils.tool.cn.hutool.core.bean.BeanUtil;
import aiyh.utils.tool.cn.hutool.core.util.StrUtil; import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -22,9 +26,6 @@ public class InsertOrUpdateState extends State{
@Override @Override
public void handle() { public void handle() {
if(ResponseUtil.parameterIsNotNull(this.context.getTableDefinitionCallback())){
this.context.getTableDefinitionCallback().tableHandle(this.context);
}
List<RowDefinition> rowDefinitionList = this.context.getRowDefinitionList(); List<RowDefinition> rowDefinitionList = this.context.getRowDefinitionList();
List<RowDefinition> updateRowList = new ArrayList<>(); List<RowDefinition> updateRowList = new ArrayList<>();
List<RowDefinition> insertRowList = new ArrayList<>(); List<RowDefinition> insertRowList = new ArrayList<>();
@ -55,16 +56,24 @@ public class InsertOrUpdateState extends State{
BeanUtil.copyProperties(this.context,tableDefinition); BeanUtil.copyProperties(this.context,tableDefinition);
tableDefinition.setState(null); tableDefinition.setState(null);
tableDefinition.setRowDefinitionList(rowDefinitionList); tableDefinition.setRowDefinitionList(rowDefinitionList);
tableDefinition.setTableDefinitionCallback(null);
tableDefinition.setAssignType(assignType); tableDefinition.setAssignType(assignType);
tableDefinition.setDefaultState(null); tableDefinition.setDefaultState(null);
tableDefinition.dataProcess(); tableDefinition.dataProcess();
} }
private boolean judgmentRepetition(RowDefinition rowDefinition){ 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 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));
}
return StrUtil.isNotBlank(dataId); return StrUtil.isNotBlank(dataId);
} }

View File

@ -1,12 +1,15 @@
package aiyh.utils.response_deal.state; package aiyh.utils.response_deal.state;
import aiyh.utils.Util; import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException;
import aiyh.utils.excention.ParseSqlException;
import aiyh.utils.recordset.MapperBuilderSql; import aiyh.utils.recordset.MapperBuilderSql;
import aiyh.utils.response_deal.constant.ResponseConfigConstant; import aiyh.utils.response_deal.constant.ResponseConfigConstant;
import aiyh.utils.response_deal.entity.RowDefinition; import aiyh.utils.response_deal.entity.RowDefinition;
import aiyh.utils.response_deal.entity.TableDefinition; import aiyh.utils.response_deal.entity.TableDefinition;
import aiyh.utils.response_deal.intfaces.RowDefinitionCallback; import aiyh.utils.response_deal.intfaces.RowDefinitionCallback;
import aiyh.utils.response_deal.util.ResponseUtil; import aiyh.utils.response_deal.util.ResponseUtil;
import com.alibaba.fastjson.JSONObject;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -62,19 +65,35 @@ public class InsertSate extends State{
} }
String updateSql = MapperBuilderSql.builderUpdateSql(assignTable, tempRowDefinition.getUpdateParam(),"upItem"); String updateSql = MapperBuilderSql.builderUpdateSql(assignTable, tempRowDefinition.getUpdateParam(),"upItem");
updateSql = updateSql + " where id = #{whereItem.id}"; 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); String modeId = Util.getModeIdByTableName(assignTable);
Util.rebuildModeDataShareByAsyncList(1,modeId,dataIdList); Util.rebuildModeDataShareByAsyncList(1,modeId,dataIdList);
if(ResponseUtil.parameterIsNotNull(detailTableMap) && flag){
detailTableMap.forEach((key,value)->{
value.setDefaultState(null);
value.dataProcess();
});
}
}else { }else {
String insertSql = MapperBuilderSql.builderInsertSql(assignTable, tempRowDefinition.getUpdateParam(),"item"); String insertSql = MapperBuilderSql.builderInsertSql(assignTable, tempRowDefinition.getUpdateParam(),"item");
List<Map<String, Object>> insertList = rowDefinitionList.stream().map(RowDefinition::getUpdateParam).collect(Collectors.toList()); List<Map<String, Object>> insertList = new ArrayList<>();
flag = this.configMapper.executeInsertBatchCusSql(insertSql, insertList); rowDefinitionList.forEach(item ->{
if(mainOrDetail == ResponseConfigConstant.MAIN_TABLE){
detailTableDeal(item,detailTableMap);
}
insertList.add(item.getUpdateParam());
});
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)->{
value.setDefaultState(null);
value.dataProcess();
});
} }
if(ResponseUtil.parameterIsNotNull(this.context.getTableDefinitionCallback())){ if(ResponseUtil.parameterIsNotNull(this.context.getTableDefinitionCallback())){
this.context.getTableDefinitionCallback().afterHandle(this.context,flag); this.context.getTableDefinitionCallback().afterHandle(this.context,flag);
@ -91,6 +110,7 @@ public class InsertSate extends State{
} }
rowDefinitionList.forEach(item ->{ rowDefinitionList.forEach(item ->{
item.getUpdateParam().put("mainid",mainId); item.getUpdateParam().put("mainid",mainId);
item.getWhereParam().put("mainid",mainId);
}); });
if(mainDetailMap.containsKey(key)){ if(mainDetailMap.containsKey(key)){
TableDefinition tableDefinition = mainDetailMap.get(key); TableDefinition tableDefinition = mainDetailMap.get(key);

View File

@ -0,0 +1,30 @@
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 <h1></h1>
**/
public class NoHandleState extends State{
@Override
public void handle() {
if(this.context.getMainOrDetail() == ResponseConfigConstant.MAIN_TABLE) {
Map<String, TableDefinition> detailTableMap = this.context.getDetailTableMap();
if (ResponseUtil.parameterIsNotNull(detailTableMap)) {
detailTableMap.forEach((key, value) -> {
value.setDefaultState(null);
value.dataProcess();
});
}
}
}
}

View File

@ -16,7 +16,7 @@ public abstract class State {
protected final ConfigMapper configMapper = Util.getMapper(ConfigMapper.class); 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; protected TableDefinition context;

View File

@ -1,12 +1,16 @@
package aiyh.utils.response_deal.state; package aiyh.utils.response_deal.state;
import aiyh.utils.ScriptUtil; 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.recordset.MapperBuilderSql;
import aiyh.utils.response_deal.constant.ResponseConfigConstant; import aiyh.utils.response_deal.constant.ResponseConfigConstant;
import aiyh.utils.response_deal.entity.RowDefinition; import aiyh.utils.response_deal.entity.RowDefinition;
import aiyh.utils.response_deal.entity.TableDefinition; import aiyh.utils.response_deal.entity.TableDefinition;
import aiyh.utils.response_deal.exception.ResponseException; import aiyh.utils.response_deal.exception.ResponseException;
import aiyh.utils.response_deal.util.ResponseUtil; import aiyh.utils.response_deal.util.ResponseUtil;
import com.alibaba.fastjson.JSONObject;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -58,7 +62,13 @@ public class UpdateState extends State {
String tempConditionScript = rowDefinition.getConditionScript(); String tempConditionScript = rowDefinition.getConditionScript();
String updateSql = MapperBuilderSql.builderUpdateSql(assignTable, rowDefinition.getUpdateParam(),"upItem"); String updateSql = MapperBuilderSql.builderUpdateSql(assignTable, rowDefinition.getUpdateParam(),"upItem");
updateSql = updateSql + " where " + tempConditionScript; 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); logger.info("批量更新处理结果 ==>"+flag);
if(ResponseUtil.parameterIsNotNull(this.context.getTableDefinitionCallback())){ if(ResponseUtil.parameterIsNotNull(this.context.getTableDefinitionCallback())){
this.context.getTableDefinitionCallback().afterHandle(this.context,flag); this.context.getTableDefinitionCallback().afterHandle(this.context,flag);
@ -83,6 +93,12 @@ public class UpdateState extends State {
return; return;
} }
detailTableMap.forEach((key,value) ->{ 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)){ if(mainDetailMap.containsKey(key)){
mainDetailMap.get(key).getRowDefinitionList().addAll(value.getRowDefinitionList()); mainDetailMap.get(key).getRowDefinitionList().addAll(value.getRowDefinitionList());
}else { }else {

View File

@ -37,12 +37,15 @@ public interface ReportMapper {
@CaseConversion(value = false) @CaseConversion(value = false)
List<Map<String, Object>> queryReportData2(@ParamMapper("param") Map<String,Object> param,@ParamMapper("uid") int uid); List<Map<String, Object>> queryReportData2(@ParamMapper("param") Map<String,Object> 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," + @Select("select main.*," +
" lxrdh,bz,gzcl,gzry,zs,dyjbr,djr,ldr,lddw,rwzt,ykdh,gbs, " + " (select lastname from hrmresource where id = dyjbr) dyjbr_span," +
" (select LISTAGG(concat(wb, ',', dw), '-') WITHIN GROUP (ORDER BY wb) from uf_zwfwdjjmb_dt1 where mainid = main.id) ysdx, " + " (select lastname from hrmresource where id = djr) djr_span," +
" dyjbr, (select lastname from hrmresource where id = dyjbr) dyjbr_span," + " (select LISTAGG(concat(wb, ',', dw), '-') WITHIN GROUP (ORDER BY wb) from uf_zwfwdjjmb_dt1 where mainid = main.id) ysdx," +
" djr, (select lastname from hrmresource where id = djr) djr_span " + " (select LISTAGG(concat(dwclwb,'(', dwcljsywb,')'), ',') WITHIN GROUP (ORDER BY dwclwb) from uf_zwfwdjjmb_dt3 where mainid = main.id) car_people," +
" from uf_zwfwdjjmb main $t{param.whereSql} order by dlsk1 ") " (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) @CaseConversion(value = false)
List<Map<String, Object>> queryReportData3(@ParamMapper("param") Map<String,Object> param,@ParamMapper("uid") int uid); List<Map<String, Object>> queryReportData3(@ParamMapper("param") Map<String,Object> param,@ParamMapper("uid") int uid);
@ -60,7 +63,7 @@ public interface ReportMapper {
* @param param * @param param
* @return * @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 " + " from uf_ryzbjlbzjb_dt1 ry " +
" inner join hrmresource hrm on ry.zbry = hrm.id " + " inner join hrmresource hrm on ry.zbry = hrm.id " +
" inner join hrmresource hrm1 on ry.zbry1 = hrm1.id " + " inner join hrmresource hrm1 on ry.zbry1 = hrm1.id " +

View File

@ -41,12 +41,12 @@ public class ReportService {
//开始日期 //开始日期
String beginDate = Util.null2String(param.get("beginDate")); 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 flightAndTrain = Util.null2String(param.get("flightAndTrain"));
String whereSql = ""; String whereSql = "";
if(!"".equals(beginDate) && !"".equals(endData)){ if(!"".equals(beginDate) && !"".equals(endDate)){
whereSql += " and (dlsk1 between #{param.beginDate} and #{param.endData} )"; whereSql += " and (dlsk1 between #{param.beginDate} and #{param.endDate} )";
}else { }else {
param.put("today", TimeUtil.getCurrentDateString()); param.put("today", TimeUtil.getCurrentDateString());
whereSql += " and dlsk1 >= #{param.today} "; whereSql += " and dlsk1 >= #{param.today} ";
@ -55,10 +55,11 @@ public class ReportService {
whereSql += " and dyjbr = #{param.registrationPeople} "; whereSql += " and dyjbr = #{param.registrationPeople} ";
} }
if(!"".equals(flightAndTrain)){ if(!"".equals(flightAndTrain)){
whereSql += " and hbwb = #{param.flightAndTrain} "; whereSql += " and hbcc = #{param.flightAndTrain} ";
} }
if(!"".equals(project)){ 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 "); whereSql = whereSql.replaceFirst(" and "," where ");
return whereSql; return whereSql;

View File

@ -2,6 +2,8 @@ package com.api.xuanran.wang.xk_hospital.data_async.controller;
import aiyh.utils.ApiResult; import aiyh.utils.ApiResult;
import aiyh.utils.Util; 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.XkHospitalCommonDataAsyncService;
import com.api.xuanran.wang.xk_hospital.data_async.service.impl.XkHospitalCommonDataAsyncServiceImpl; import com.api.xuanran.wang.xk_hospital.data_async.service.impl.XkHospitalCommonDataAsyncServiceImpl;
import io.swagger.v3.oas.annotations.parameters.RequestBody; import io.swagger.v3.oas.annotations.parameters.RequestBody;
@ -37,6 +39,10 @@ public class CommonDataAsyncController {
@PathParam("type") String type, @PathParam("type") String type,
@RequestBody Map<String, Object> params){ @RequestBody Map<String, Object> params){
try { 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); service.async(configId, type, params);
return ApiResult.successNoData(); return ApiResult.successNoData();
}catch (Exception e){ }catch (Exception e){

View File

@ -8,10 +8,6 @@ import com.engine.common.service.impl.ThemeServiceImpl;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import weaver.hrm.company.DepartmentComInfo; import weaver.hrm.company.DepartmentComInfo;
import weaver.hrm.resource.ResourceComInfo; import weaver.hrm.resource.ResourceComInfo;
import weaver.matrix.MatrixUtil;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
/** /**
@ -49,14 +45,16 @@ public class XkHospitalCommonDefinition {
* <h2></h2> * <h2></h2>
**/ **/
protected static final DepartmentComInfo DEPARTMENT_COM_INFO = new DepartmentComInfo(); protected static final DepartmentComInfo DEPARTMENT_COM_INFO = new DepartmentComInfo();
/**
* <h2></h2>
**/
protected static ResourceComInfo RESOURCE_COM_INFO = null;
/** /**
* <h2></h2> * <h2></h2>
**/ **/
protected static final ThemeServiceImpl THEME_SERVICE = new ThemeServiceImpl(); protected static final ThemeServiceImpl THEME_SERVICE = new ThemeServiceImpl();
/**
* <h2></h2>
**/
protected static ResourceComInfo RESOURCE_COM_INFO = null;
static { static {
try { try {
RESOURCE_COM_INFO = new ResourceComInfo(); RESOURCE_COM_INFO = new ResourceComInfo();
@ -66,40 +64,4 @@ public class XkHospitalCommonDefinition {
} }
} }
/**
*
* @param table
* @param idList id
*/
protected void synCache(String table, List<Integer> 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<Map<String, Integer>> 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);
}
}
}
} }

View File

@ -2,6 +2,7 @@ package com.api.xuanran.wang.xk_hospital.data_async.definitions.row;
import aiyh.utils.Util; import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException; 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.RowDefinition;
import aiyh.utils.response_deal.intfaces.RowDefinitionCallback; import aiyh.utils.response_deal.intfaces.RowDefinitionCallback;
import aiyh.utils.response_deal.mapper.ConfigMapper; 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 com.api.xuanran.wang.xk_hospital.data_async.definitions.XkHospitalCommonDefinition;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSet; import weaver.conn.RecordSet;
import java.util.HashMap; import java.util.HashMap;
@ -31,22 +33,33 @@ public class HrmDepartmentRowDefinition extends XkHospitalCommonDefinition imple
@Override @Override
public boolean judgmentRepetition(RowDefinition rowDefinition) { 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 cusQuerySql = "select id from " + rowDefinition.getAssignTable() + " where " + conditionScript;
String dataId = configMapper.executeCusQuerySql(cusQuerySql, rowDefinition.getWhereParam(),new HashMap<>()); String dataId = configMapper.executeCusQuerySql(cusQuerySql, rowDefinition.getWhereParam(),new HashMap<>());
if(StrUtil.isBlank(dataId)){ if(ResponseConfigConstant.MAIN_TABLE == orDetail){
int nextId = -1; if(StrUtil.isBlank(dataId)){
if(HRM_RESOURCE.equals(table)){ int nextId = -1;
nextId = Util.getNextHrmId(); if(HRM_RESOURCE.equals(table)){
}else if(DEPARTMENT.equals(table)){ nextId = Util.getNextHrmId();
nextId = Util.getNextDepartmentId(); }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(nextId < 0){ }else {
throw new CustomerException("从 " + table + " 获取下一个id失败!"); return StringUtils.isNotBlank(dataId);
}
rowDefinition.setDataId(nextId);
rowDefinition.getWhereParam().put("id", nextId);
rowDefinition.setConditionScript(" id = #{whereItem.id}");
} }
return true; return true;
} }

View File

@ -2,6 +2,7 @@ package com.api.xuanran.wang.xk_hospital.data_async.definitions.table;
import aiyh.utils.Util; import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException; 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.RowDefinition;
import aiyh.utils.response_deal.entity.TableDefinition; import aiyh.utils.response_deal.entity.TableDefinition;
import aiyh.utils.response_deal.intfaces.TableDefinitionCallback; import aiyh.utils.response_deal.intfaces.TableDefinitionCallback;
@ -9,9 +10,11 @@ import com.api.xuanran.wang.xk_hospital.data_async.definitions.XkHospitalCommonD
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import weaver.matrix.MatrixUtil;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -28,7 +31,18 @@ public class HrmDepartmentTableDefinition extends XkHospitalCommonDefinition imp
@Override @Override
public void tableHandle(TableDefinition tableDefinition) { public void tableHandle(TableDefinition tableDefinition) {
if(ResponseConfigConstant.DETAIL_TABLE == tableDefinition.getMainOrDetail()){
List<RowDefinition> 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 @Override
@ -38,16 +52,36 @@ public class HrmDepartmentTableDefinition extends XkHospitalCommonDefinition imp
.map(RowDefinition::getDataId) .map(RowDefinition::getDataId)
.filter(dataId -> dataId > 0) .filter(dataId -> dataId > 0)
.collect(Collectors.toList()); .collect(Collectors.toList());
if(CollectionUtils.isEmpty(idList)){ if (!flag) {
return; if (CollectionUtils.isNotEmpty(idList) && !this.dataAsyncMapper.deleteHrmDepart(idList)) {
}
if(!flag){
if (!this.dataAsyncMapper.deleteHrmDepart(idList)) {
log.error("删除 " + table + " 表数据失败!"); log.error("删除 " + table + " 表数据失败!");
} }
throw new CustomerException("同步 " + table + " 表数据失败!"); throw new CustomerException("同步 " + table + " 表数据失败!");
}else { } else {
synCache(table, idList); if (HRM_RESOURCE.equals(table)) {
try {
if(CollectionUtils.isNotEmpty(idList)) {
List<Map<String, Integer>> 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);
}
});
}
} }
} }
} }

View File

@ -14,10 +14,10 @@ import java.util.Map;
@SqlMapper @SqlMapper
public interface XkHospitalDataAsyncMapper { 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<Integer> idList); boolean deleteHrmDepart(@ParamMapper("idList") List<Integer> 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 @ToLowerCase
List<Map<String, Integer>> selectHrmSubByHrmIdList(@ParamMapper("idList") List<Integer> idList); List<Map<String, Integer>> selectHrmSubByHrmIdList(@ParamMapper("idList") List<Integer> idList);

View File

@ -13,7 +13,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
* <h1></h1> * <h1></h1>
* *
* @author xuanran.wang * @author xuanran.wang
* @date 2023/7/18 11:15 * @date 2023/7/18 11:15

View File

@ -1,6 +1,7 @@
package xuanran.wang.xk_hospital.test; package xuanran.wang.xk_hospital.test;
import aiyh.utils.Util;
import basetest.BaseTest; import basetest.BaseTest;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.api.xuanran.wang.xk_hospital.data_async.service.XkHospitalCommonDataAsyncService; import com.api.xuanran.wang.xk_hospital.data_async.service.XkHospitalCommonDataAsyncService;
@ -34,4 +35,83 @@ public class XkHospitalTest extends BaseTest {
Map map = JSONObject.parseObject(json, Map.class); Map map = JSONObject.parseObject(json, Map.class);
service.async("4bce0693734a","dept",map); 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\":\"TEST10\",\n" +
"\t\"EmplName\":\"测试人员10\",\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);
}
@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);
}
} }