|
|
@ -40,6 +40,7 @@ import com.glxp.api.entity.system.SystemParamConfigEntity;
|
|
|
|
import com.glxp.api.idc.service.IdcService;
|
|
|
|
import com.glxp.api.idc.service.IdcService;
|
|
|
|
import com.glxp.api.idc.utils.DBAUtils;
|
|
|
|
import com.glxp.api.idc.utils.DBAUtils;
|
|
|
|
import com.glxp.api.idc.utils.IDCUtils;
|
|
|
|
import com.glxp.api.idc.utils.IDCUtils;
|
|
|
|
|
|
|
|
import com.glxp.api.idc.utils.TableUtils;
|
|
|
|
import com.glxp.api.req.system.ScheduledRequest;
|
|
|
|
import com.glxp.api.req.system.ScheduledRequest;
|
|
|
|
import com.glxp.api.service.system.SystemParamConfigService;
|
|
|
|
import com.glxp.api.service.system.SystemParamConfigService;
|
|
|
|
import com.glxp.api.util.CustomUtil;
|
|
|
|
import com.glxp.api.util.CustomUtil;
|
|
|
@ -54,7 +55,6 @@ import okhttp3.Request;
|
|
|
|
import okhttp3.RequestBody;
|
|
|
|
import okhttp3.RequestBody;
|
|
|
|
import okhttp3.Response;
|
|
|
|
import okhttp3.Response;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*数据中继数据中心(接收)*/
|
|
|
|
/*数据中继数据中心(接收)*/
|
|
|
|
@Slf4j
|
|
|
|
@Slf4j
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
@ -70,25 +70,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
@Value("${API_SECRET}")
|
|
|
|
@Value("${API_SECRET}")
|
|
|
|
private String apiSecret;
|
|
|
|
private String apiSecret;
|
|
|
|
|
|
|
|
|
|
|
|
/*同步表,格式:同步设置表列名/同步设置表列名(子表时设置,主表不设置)/主表唯一列(多列逗号分隔)/主表关联列/子表关联列/数据库实际表/时间列/图片或文件列/数据条件/说明*/
|
|
|
|
|
|
|
|
private final String[] SYNC_TABLES= {
|
|
|
|
|
|
|
|
"entrustAction//basic_entrust_accept/id///updateTime///委托验收","basicProducts//basic_udirel/id///updateTime///耗材字典","/basicProducts/basic_products/id/uuid/uuid////耗材字典信息详情",
|
|
|
|
|
|
|
|
"/companyCert/company_product_relevance/id/customerId/unitFk/updateTime///供应商关联信息",
|
|
|
|
|
|
|
|
"basicCorp//basic_corp/id///updateTime///往来单位","typeThird//thr_bustype_origin/id///updateTime///第三方单据类型",
|
|
|
|
|
|
|
|
"basicThirdCorp//thr_corp/id///updateTime///第三方往来单位","//thr_dept/id///updateTime///第三方部门",
|
|
|
|
|
|
|
|
"//thr_inv_products/id///updateTime///第三方库存","basicThirdInv//thr_inv_warehouse/id//////第三方仓库",
|
|
|
|
|
|
|
|
"basicThirdBusOrder//thr_order/id///updateTime///第三方业务单据","/basicThirdBusOrder/thr_order_detail/orderIdFk/id/orderIdFk/updateTime///第三方单据详情",
|
|
|
|
|
|
|
|
"basicThirdProducts//thr_products/id///updateTime///第三方产品信息",
|
|
|
|
|
|
|
|
"//sup_cert_set/id///updateTime///供应商资质证书设置","companyCert//sup_company/customerId///updateTime///配送企业",
|
|
|
|
|
|
|
|
"manufacturerCert//sup_manufacturer/id///updateTime///生产企业","productCert//sup_product/id///updateTime///产品资质信息",
|
|
|
|
|
|
|
|
"/companyCert/sup_cert/id/customerId/customerId/updateTime/filePath/type=1/配送企业资质证书信息",
|
|
|
|
|
|
|
|
"/manufacturerCert/sup_cert/id/manufacturerId/manufacturerIdFk/updateTime/filePath/type=2/生产企业资质证书信息",
|
|
|
|
|
|
|
|
"/productCert/sup_cert/id/productId/productIdFk/updateTime/filePath/type=3/产品资质证书信息",
|
|
|
|
|
|
|
|
"//udicompany/id///updateTime///国际库医疗器械注册人信息"};
|
|
|
|
|
|
|
|
//"dbDiProducts//productinfo/id///updateTime///DI产品信息",
|
|
|
|
|
|
|
|
//"basicInv/////////仓库字典",
|
|
|
|
|
|
|
|
//"typeBus/////////业务单据类型",
|
|
|
|
|
|
|
|
//"typeScan/////////扫码单据类型",
|
|
|
|
|
|
|
|
private int orderNum = 0;
|
|
|
|
private int orderNum = 0;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
@ -137,7 +119,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
BaseResponse response = JSON.parseObject(json, BaseResponse.class);
|
|
|
|
BaseResponse response = JSON.parseObject(json, BaseResponse.class);
|
|
|
|
return response;
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
logger.info("json-->" + json);
|
|
|
|
return ResultVOUtils.success(object);
|
|
|
|
return ResultVOUtils.success(object);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -148,6 +130,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
logger.info("UDI管理系统同步任务开始--------");
|
|
|
|
logger.info("UDI管理系统同步任务开始--------");
|
|
|
|
asyncDataTask(true);
|
|
|
|
asyncDataTask(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*自助平台生成任务,不上传*/
|
|
|
|
/*自助平台生成任务,不上传*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void asyncSpsTask() {
|
|
|
|
public void asyncSpsTask() {
|
|
|
@ -161,6 +144,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
public void asyncFetchUdiTask() {
|
|
|
|
public void asyncFetchUdiTask() {
|
|
|
|
fetchTask(false);
|
|
|
|
fetchTask(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Async
|
|
|
|
@Async
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void asyncFetchTask() {
|
|
|
|
public void asyncFetchTask() {
|
|
|
@ -222,14 +206,15 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for(int i=0;i<SYNC_TABLES.length;i++) {
|
|
|
|
String[] syncTables = TableUtils.syncTables();
|
|
|
|
String[] tnames = SYNC_TABLES[i].split("/");
|
|
|
|
for (int i = 0; i < syncTables.length; i++) {
|
|
|
|
|
|
|
|
String[] tnames = syncTables[i].split("/");
|
|
|
|
boolean sync = StringUtils.isEmpty(tnames[0]) ||
|
|
|
|
boolean sync = StringUtils.isEmpty(tnames[0]) ||
|
|
|
|
(!StringUtils.isEmpty(tnames[0]) && map != null && map.get(tnames[0]) != null && map.get(tnames[0]).toString().equals("1"));
|
|
|
|
(!StringUtils.isEmpty(tnames[0]) && map != null && map.get(tnames[0]) != null && map.get(tnames[0]).toString().equals("1"));
|
|
|
|
saveIdcLog("---","",map.get(tnames[0])+SYNC_TABLES[i],0,0);
|
|
|
|
saveIdcLog("---", "", map.get(tnames[0]) + syncTables[i], 0, 0);
|
|
|
|
if (sync) {
|
|
|
|
if (sync) {
|
|
|
|
String syncIp = map.get("syncIp") != null ? map.get("syncIp").toString() : "";
|
|
|
|
String syncIp = map.get("syncIp") != null ? map.get("syncIp").toString() : "";
|
|
|
|
syncData(SYNC_TABLES[i],isUpload,syncIp);
|
|
|
|
syncData(syncTables[i], isUpload, syncIp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -284,7 +269,6 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String fetchData(String host, Map<String, Object> params) {
|
|
|
|
private String fetchData(String host, Map<String, Object> params) {
|
|
|
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
|
|
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
@ -363,6 +347,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
dbDao.update(sql);
|
|
|
|
dbDao.update(sql);
|
|
|
|
return ResultVOUtils.success();
|
|
|
|
return ResultVOUtils.success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/****/
|
|
|
|
/****/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public BaseResponse receive(HttpServletRequest request,
|
|
|
|
public BaseResponse receive(HttpServletRequest request,
|
|
|
@ -445,6 +430,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public BaseResponse send(String messageType, String tableName, Map<String, Object> params) {
|
|
|
|
public BaseResponse send(String messageType, String tableName, Map<String, Object> params) {
|
|
|
|
|
|
|
|
|
|
|
@ -492,6 +478,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
|
|
|
|
|
|
|
dbDao.save(sql);
|
|
|
|
dbDao.save(sql);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void saveDownloadStatus(Map<String, Object> params) {
|
|
|
|
private void saveDownloadStatus(Map<String, Object> params) {
|
|
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
|
|
map.put("receiveStatus", "0");
|
|
|
|
map.put("receiveStatus", "0");
|
|
|
@ -502,6 +489,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
|
|
|
|
|
|
|
dbDao.save(sql);
|
|
|
|
dbDao.save(sql);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void saveIdcLog(String messageType, String taskId, String content, int offset, int total) {
|
|
|
|
private void saveIdcLog(String messageType, String taskId, String content, int offset, int total) {
|
|
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
|
|
map.put("id", CustomUtil.getId());
|
|
|
|
map.put("id", CustomUtil.getId());
|
|
|
@ -526,7 +514,8 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
String[] childs = new String[30];
|
|
|
|
String[] childs = new String[30];
|
|
|
|
int childNum = -1;
|
|
|
|
int childNum = -1;
|
|
|
|
/*子表*/
|
|
|
|
/*子表*/
|
|
|
|
for(String str:SYNC_TABLES) {
|
|
|
|
String[] syncTables = TableUtils.syncTables();
|
|
|
|
|
|
|
|
for (String str : syncTables) {
|
|
|
|
if (str.contains("/" + tableKey + "/")) {
|
|
|
|
if (str.contains("/" + tableKey + "/")) {
|
|
|
|
childNum++;
|
|
|
|
childNum++;
|
|
|
|
childs[childNum] = str;
|
|
|
|
childs[childNum] = str;
|
|
|
@ -661,8 +650,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
|
|
|
|
|
|
|
/*增加同步任务状态*/
|
|
|
|
/*增加同步任务状态*/
|
|
|
|
private void syncAddTaskStatus(Map<String, Object> json, int scheduleType, boolean success, Date startTime, boolean isEnd) {
|
|
|
|
private void syncAddTaskStatus(Map<String, Object> json, int scheduleType, boolean success, Date startTime, boolean isEnd) {
|
|
|
|
try
|
|
|
|
try {
|
|
|
|
{
|
|
|
|
|
|
|
|
String content = JSON.toJSONString(json);
|
|
|
|
String content = JSON.toJSONString(json);
|
|
|
|
String datePath = DateUtil.formatDate(new Date(), "yyyy-MM-dd");
|
|
|
|
String datePath = DateUtil.formatDate(new Date(), "yyyy-MM-dd");
|
|
|
|
String fileName = filePath + datePath + "/" + json.get("messageType") + "-" + json.get("messageId") + ".udi";
|
|
|
|
String fileName = filePath + datePath + "/" + json.get("messageType") + "-" + json.get("messageId") + ".udi";
|
|
|
@ -968,9 +956,11 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return success;
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private boolean signleDownloadFile(String syncIp, String fileName) {
|
|
|
|
private boolean signleDownloadFile(String syncIp, String fileName) {
|
|
|
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
|
|
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
|
|
|
.build();;
|
|
|
|
.build();
|
|
|
|
|
|
|
|
;
|
|
|
|
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
|
|
|
|
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
|
|
|
|
|
|
|
|
|
|
|
|
RequestBody body = RequestBody.create(mediaType, "fileName=" + fileName);
|
|
|
|
RequestBody body = RequestBody.create(mediaType, "fileName=" + fileName);
|
|
|
@ -1003,7 +993,6 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
outputStream.flush();
|
|
|
|
outputStream.flush();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1051,6 +1040,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
List<Map<String, Object>> list = dbDao.list(map);
|
|
|
|
List<Map<String, Object>> list = dbDao.list(map);
|
|
|
|
return list;
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*由表名获取数据*/
|
|
|
|
/*由表名获取数据*/
|
|
|
|
private Map<String, Object> getData(String messageType, String tableName, Map<String, Object> params, Map<String, Object> whereParams) {
|
|
|
|
private Map<String, Object> getData(String messageType, String tableName, Map<String, Object> params, Map<String, Object> whereParams) {
|
|
|
|
List<Map<String, Object>> list = getList(tableName, whereParams);
|
|
|
|
List<Map<String, Object>> list = getList(tableName, whereParams);
|
|
|
@ -1069,8 +1059,6 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private SystemParamConfigEntity getSystemParamConfig(String paramKey, String paramName, String defaultValue, String paramExplain) {
|
|
|
|
private SystemParamConfigEntity getSystemParamConfig(String paramKey, String paramName, String defaultValue, String paramExplain) {
|
|
|
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey(paramKey);
|
|
|
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey(paramKey);
|
|
|
|
if (systemParamConfigEntity == null || (systemParamConfigEntity != null && StringUtils.isEmpty(systemParamConfigEntity.getParamKey()))) {
|
|
|
|
if (systemParamConfigEntity == null || (systemParamConfigEntity != null && StringUtils.isEmpty(systemParamConfigEntity.getParamKey()))) {
|
|
|
@ -1086,6 +1074,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return systemParamConfigEntity;
|
|
|
|
return systemParamConfigEntity;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void writeFile(byte[] file, String filePath, String fileName) throws Exception {
|
|
|
|
private void writeFile(byte[] file, String filePath, String fileName) throws Exception {
|
|
|
|
File targetFile = new File(filePath);
|
|
|
|
File targetFile = new File(filePath);
|
|
|
|
if (!targetFile.exists()) {
|
|
|
|
if (!targetFile.exists()) {
|
|
|
@ -1110,7 +1099,8 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
for (int i = 0; i < columnList.size(); i++) {
|
|
|
|
for (int i = 0; i < columnList.size(); i++) {
|
|
|
|
Map<String, Object> column = new HashMap<String, Object>();
|
|
|
|
Map<String, Object> column = new HashMap<String, Object>();
|
|
|
|
String dataType = columnList.get(i).get("dataType").toLowerCase().contains("char") || columnList.get(i).get("dataType").toLowerCase().contains("text") ?
|
|
|
|
String dataType = columnList.get(i).get("dataType").toLowerCase().contains("char") || columnList.get(i).get("dataType").toLowerCase().contains("text") ?
|
|
|
|
"C" : columnList.get(i).get("dataType").toLowerCase().contains("date") ? "D" : "N" ;;
|
|
|
|
"C" : columnList.get(i).get("dataType").toLowerCase().contains("date") ? "D" : "N";
|
|
|
|
|
|
|
|
;
|
|
|
|
String attrName = columnList.get(i).get("columnName").toString();
|
|
|
|
String attrName = columnList.get(i).get("columnName").toString();
|
|
|
|
if (map.get(attrName) == null) {
|
|
|
|
if (map.get(attrName) == null) {
|
|
|
|
column.put("tableName", tname);
|
|
|
|
column.put("tableName", tname);
|
|
|
@ -1150,6 +1140,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return updateTime;
|
|
|
|
return updateTime;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private String setUpdateTime(String id, String updateTime) {
|
|
|
|
private String setUpdateTime(String id, String updateTime) {
|
|
|
|
String sql = "";
|
|
|
|
String sql = "";
|
|
|
|
Map<String, Object> map = dbDao.get("select * from idc_status where id='" + id + "'");
|
|
|
|
Map<String, Object> map = dbDao.get("select * from idc_status where id='" + id + "'");
|
|
|
@ -1162,6 +1153,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return updateTime;
|
|
|
|
return updateTime;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void initTable() {
|
|
|
|
private void initTable() {
|
|
|
|
alterTable("idc_var", "create table idc_var (code varchar(60),content varchar(200),PRIMARY KEY (code))");
|
|
|
|
alterTable("idc_var", "create table idc_var (code varchar(60),content varchar(200),PRIMARY KEY (code))");
|
|
|
|
alterTable("idc_status", "create table idc_status (id varchar(100),statusTime datetime,PRIMARY KEY (id))");
|
|
|
|
alterTable("idc_status", "create table idc_status (id varchar(100),statusTime datetime,PRIMARY KEY (id))");
|
|
|
@ -1177,6 +1169,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void alterTable(String tableName, String sql) {
|
|
|
|
private void alterTable(String tableName, String sql) {
|
|
|
|
Map<String, String> map = dbDao.getMysql(tableName);
|
|
|
|
Map<String, String> map = dbDao.getMysql(tableName);
|
|
|
|
if (!(map != null && map.get("tableName") != null)) {
|
|
|
|
if (!(map != null && map.get("tableName") != null)) {
|
|
|
|