commit
c8dc531276
|
@ -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;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.api.xuanran.wang.xk_hospital.data_async.entity;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
*
|
||||
* @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;
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.api.xuanran.wang.xk_hospital.data_async.entity;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
*
|
||||
* @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;
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.api.xuanran.wang.xk_hospital.data_async.service;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
*
|
||||
* @author xuanran.wang
|
||||
* @date 2023/7/18 10:36
|
||||
*/
|
||||
public interface XkHospitalCommonDataAsyncService {
|
||||
void async(String configCode, String type, Map<String, Object> params);
|
||||
}
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
*
|
||||
* @author xuanran.wang
|
||||
* @date 2023/7/18 11:15
|
||||
*/
|
||||
public class XkHospitalCommonDataAsyncServiceImpl implements XkHospitalCommonDataAsyncService {
|
||||
|
||||
private static final Map<String, RowDefinitionCallback> 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<String, Object> 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);
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue