diff --git a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/HrmDepartmentDefinition.java b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/HrmDepartmentDefinition.java new file mode 100644 index 0000000..872ea51 --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/HrmDepartmentDefinition.java @@ -0,0 +1,51 @@ +package com.api.xuanran.wang.xk_hospital.data_async.definitions; + +import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; +import aiyh.utils.response_deal.entity.FieldDefinition; +import aiyh.utils.response_deal.entity.RowDefinition; +import aiyh.utils.response_deal.intfaces.RowDefinitionCallback; +import aiyh.utils.response_deal.mapper.ConfigMapper; +import aiyh.utils.tool.cn.hutool.core.util.StrUtil; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; + +import java.util.HashMap; +import java.util.List; + +/** + *

+ * + * @author xuanran.wang + * @date 2023/7/18 11:13 + */ +public class HrmDepartmentDefinition implements RowDefinitionCallback { + + protected final ConfigMapper configMapper = Util.getMapper(ConfigMapper.class); + + @Override + public void rowHandle(RowDefinition rowDefinition) { + + } + + @Override + public boolean judgmentRepetition(RowDefinition rowDefinition) { + String conditionScript = rowDefinition.getConditionScript(); + String cusQuerySql = "select id from " + rowDefinition.getAssignTable() + " where " + conditionScript; + String dataId = this.configMapper.executeCusQuerySql(cusQuerySql, rowDefinition.getWhereParam(),new HashMap<>()); + if(StrUtil.isBlank(dataId)){ + RecordSet insertRs = new RecordSet(); + char separator = weaver.general.Util.getSeparator(); + //使用存储过程新增分部 + String para = "" + separator + "" + separator + + "" + separator + "" + separator + "1" + separator + ""; + insertRs.executeProc("HrmDepartment_Insert", para); + if (insertRs.next()) { + int depId = insertRs.getInt(1); + rowDefinition.setDataId(depId); + rowDefinition.getWhereParam().put("id", depId); + } + } + return true; + } +} diff --git a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/HrmresourceDefinition.java b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/HrmresourceDefinition.java new file mode 100644 index 0000000..69a94cc --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/HrmresourceDefinition.java @@ -0,0 +1,22 @@ +package com.api.xuanran.wang.xk_hospital.data_async.definitions; + +import aiyh.utils.response_deal.entity.RowDefinition; +import aiyh.utils.response_deal.intfaces.RowDefinitionCallback; + +/** + *

+ * + * @author xuanran.wang + * @date 2023/7/18 11:13 + */ +public class HrmresourceDefinition implements RowDefinitionCallback { + @Override + public void rowHandle(RowDefinition rowDefinition) { + + } + + @Override + public boolean judgmentRepetition(RowDefinition rowDefinition) { + return false; + } +} diff --git a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/entity/XkDataAsyncConfig.java b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/entity/XkDataAsyncConfig.java new file mode 100644 index 0000000..33532de --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/entity/XkDataAsyncConfig.java @@ -0,0 +1,15 @@ +package com.api.xuanran.wang.xk_hospital.data_async.entity; + +/** + *

+ * + * @author xuanran.wang + * @date 2023/7/17 16:49 + */ +public class XkDataAsyncConfig { + private String modelTable; + private String configId; + private String tableType; + private String cusTable; + private String deleteInterface; +} diff --git a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/entity/XkDataAsyncConfigDetail.java b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/entity/XkDataAsyncConfigDetail.java new file mode 100644 index 0000000..e67634c --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/entity/XkDataAsyncConfigDetail.java @@ -0,0 +1,15 @@ +package com.api.xuanran.wang.xk_hospital.data_async.entity; + +/** + *

+ * + * @author xuanran.wang + * @date 2023/7/17 16:53 + */ +public class XkDataAsyncConfigDetail { + private String interfaceField; + private int interfaceFieldType; + private String modelField; + private String cusField; + private String oaFieldType; +} diff --git a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/service/XkHospitalCommonDataAsyncService.java b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/service/XkHospitalCommonDataAsyncService.java new file mode 100644 index 0000000..0599fdc --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/service/XkHospitalCommonDataAsyncService.java @@ -0,0 +1,14 @@ +package com.api.xuanran.wang.xk_hospital.data_async.service; + + +import java.util.Map; + +/** + *

+ * + * @author xuanran.wang + * @date 2023/7/18 10:36 + */ +public interface XkHospitalCommonDataAsyncService { + void async(String configCode, String type, Map params); +} 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 new file mode 100644 index 0000000..ff5f4ac --- /dev/null +++ b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/service/impl/XkHospitalCommonDataAsyncServiceImpl.java @@ -0,0 +1,39 @@ +package com.api.xuanran.wang.xk_hospital.data_async.service.impl; + +import aiyh.utils.response_deal.ResponseMappingDeal; +import aiyh.utils.response_deal.intfaces.RowDefinitionCallback; +import aiyh.utils.tool.cn.hutool.core.util.StrUtil; +import com.api.xuanran.wang.xk_hospital.data_async.definitions.HrmresourceDefinition; +import com.api.xuanran.wang.xk_hospital.data_async.service.XkHospitalCommonDataAsyncService; +import org.apache.commons.lang3.StringUtils; + +import java.util.HashMap; +import java.util.Map; + +/** + *

+ * + * @author xuanran.wang + * @date 2023/7/18 11:15 + */ +public class XkHospitalCommonDataAsyncServiceImpl implements XkHospitalCommonDataAsyncService { + + private static final Map CUS_DEFINITIONS = new HashMap<>(); + + static { + CUS_DEFINITIONS.put("hrm", new HrmresourceDefinition()); + CUS_DEFINITIONS.put("dept", new HrmresourceDefinition()); + } + + @Override + public void async(String configCode, String type, Map params){ + ResponseMappingDeal deal = new ResponseMappingDeal(); + if(StrUtil.isNotBlank(type)){ + RowDefinitionCallback callback = CUS_DEFINITIONS.get(type); + if(null != callback){ + deal.setRowCallback(callback); + } + } + deal.doResponseSync(configCode, params); + } +} diff --git a/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalTest.java b/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalTest.java new file mode 100644 index 0000000..0159c50 --- /dev/null +++ b/src/test/java/xuanran/wang/xk_hospital/test/XkHospitalTest.java @@ -0,0 +1,48 @@ +package xuanran.wang.xk_hospital.test; + + +import basetest.BaseTest; +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.impl.XkHospitalCommonDataAsyncServiceImpl; +import org.junit.Test; + +import java.util.Map; + +/** + *

+ * + * @author xuanran.wang + * @date 2023/7/18 14:31 + */ +public class XkHospitalTest extends BaseTest { + + private final XkHospitalCommonDataAsyncService service = new XkHospitalCommonDataAsyncServiceImpl(); + + @Test + public void testA(){ + String json = "{\n" + + "\t\"ID\":\"主键\",\n" + + "\t\"DeptCode\":\"科室代码\",\n" + + "\t\"DeptName\":\"科室名称\",\n" + + "\t\"DeptLevel\": \"科室级别,int类型,可为null\", \n" + + "\t\"ParentDeptCode\":\"上级科室代码\",\n" + + "\t\"IsDelete\": \"是否停用,bool类型\", \n" + + "\t\"Remark\":\"备注\",\n" + + "\t\"Mapping\": [\n" + + "\t\t{\n" + + "\t\t\t\"ID\":\"主键\",\n" + + "\t\t\t\"DeptID\":\"源科室主键\",\n" + + "\t\t\t\"SourceDeptName\":\"源科室名称\",\n" + + "\t\t\t\"SystemID\":\"第三方系统主键\",\n" + + "\t\t\t\"SystemName\":\"第三方系统名称\",\n" + + "\t\t\t\"DeptCode\":\"科室代码\",\n" + + "\t\t\t\"DeptName\":\"科室名称\",\n" + + "\t\t\t\"Remark\":\"备注\",\n" + + "\t\t}\n" + + "\t]\n" + + "}\n"; + Map map = JSONObject.parseObject(json, Map.class); + service.async("4bce0693734a","dept",map); + } +}