Merge remote-tracking branch 'origin/master'

version1
anthonywj 2 years ago
commit 4c54d831a9

@ -57,6 +57,20 @@ public class IdcController {
return idcService.receive(request, content, files); return idcService.receive(request, content, files);
} }
@RequestMapping(value = "/spssync/common/uploadJson")
@ResponseBody
public BaseResponse uploadJson(HttpServletRequest request,@RequestBody Map<String, Object> params) {
//
return idcService.receiveJson(request, params);
}
@RequestMapping(value = "/spssync/common/uploadFile")
public BaseResponse uploadFile(HttpServletRequest request,
@RequestParam("content") String content,
@RequestParam(value = "files", required = false) MultipartFile[] files) {
//
return idcService.receive(request, content, files);
}
//@Log("数据同步测试") //@Log("数据同步测试")
@RequestMapping(value = "/spssync/common/test") @RequestMapping(value = "/spssync/common/test")

@ -16,7 +16,9 @@ public interface IdcService {
BaseResponse receive(HttpServletRequest request, BaseResponse receive(HttpServletRequest request,
String content,MultipartFile[] files); String content,MultipartFile[] files);
BaseResponse receiveJson(HttpServletRequest request,Map<String, Object> params);
BaseResponse uploadFile(HttpServletRequest request,
String content,MultipartFile[] files);
BaseResponse send(Map<String,Object> params); BaseResponse send(Map<String,Object> params);
BaseResponse send(String messageType,String tableName,Map<String,Object> params); BaseResponse send(String messageType,String tableName,Map<String,Object> params);
@ -29,7 +31,6 @@ public interface IdcService {
BaseResponse downlaodSuccess(HttpServletRequest request,Map<String,Object> params); BaseResponse downlaodSuccess(HttpServletRequest request,Map<String,Object> params);
public void asyncIdcTask();
void asyncUdiTask(); void asyncUdiTask();
void asyncSpsTask(); void asyncSpsTask();

@ -38,6 +38,7 @@ import com.glxp.sale.admin.idc.dao.DbDao;
import com.glxp.sale.admin.idc.service.IdcService; import com.glxp.sale.admin.idc.service.IdcService;
import com.glxp.sale.admin.idc.utils.DBAUtils; import com.glxp.sale.admin.idc.utils.DBAUtils;
import com.glxp.sale.admin.idc.utils.IDCUtils; import com.glxp.sale.admin.idc.utils.IDCUtils;
import com.glxp.sale.admin.idc.utils.TableUtils;
import com.glxp.sale.admin.req.info.ScheduledRequest; import com.glxp.sale.admin.req.info.ScheduledRequest;
import com.glxp.sale.admin.service.param.SystemParamConfigService; import com.glxp.sale.admin.service.param.SystemParamConfigService;
import com.glxp.sale.admin.util.CustomUtil; import com.glxp.sale.admin.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
@ -103,6 +85,7 @@ public class IdcServiceImpl implements IdcService {
@Resource @Resource
private ScheduledDao scheduledDao; private ScheduledDao scheduledDao;
/*获取拉取任务列表*/
@Override @Override
public BaseResponse taskList(HttpServletRequest request, Map<String, Object> params) { public BaseResponse taskList(HttpServletRequest request, Map<String, Object> params) {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
@ -111,18 +94,28 @@ public class IdcServiceImpl implements IdcService {
return ResultVOUtils.success(list); return ResultVOUtils.success(list);
} }
/*下载任务*/
@Override @Override
public BaseResponse download(HttpServletRequest request, Map<String, Object> params) { public BaseResponse download(HttpServletRequest request, Map<String, Object> params) {
Map<String,Object> map = dbDao.get("select * from basic_export_status where id='"+params.get("taskId")+"'"); String id = "";
String tableName = params.get("scheduleType") != null && params.get("scheduleType").equals("3") ? "basic_export_status" : "basic_export_status";
if (params.containsKey("taskId") && params.get("taskId") != null) {
id = params.get("taskId").toString();
} else {
id = params.get("id").toString();
}
Map<String, Object> map = map = dbDao.get("select * from " + tableName + " where id='" + id + "'");
if (map == null) if (map == null)
ResultVOUtils.error(9000, "下载任务不存在"); return ResultVOUtils.error(9000, "下载任务不存在");
if(!FileUtils.isFileExist(map.get("cacheFilePath").toString())) if (!(map.get("cacheFilePath") != null && FileUtils.isFileExist(map.get("cacheFilePath").toString())))
ResultVOUtils.error(9000, "下载文件不存在"); return ResultVOUtils.error(9000, "下载文件不存在");
String json = FileUtils.readFileAll(map.get("cacheFilePath").toString()); String json = FileUtils.readFileAll(map.get("cacheFilePath").toString());
JSONObject object = JSON.parseObject(json); JSONObject object = JSON.parseObject(json);
if (object == null) if (object == null)
ResultVOUtils.error(9000, "任务下载失败"); return ResultVOUtils.error(9000, "任务下载失败");
if (object != null && object.getInteger("code") != null) { if (object != null && object.getInteger("code") != null) {
BaseResponse response = JSON.parseObject(json, BaseResponse.class); BaseResponse response = JSON.parseObject(json, BaseResponse.class);
return response; return response;
@ -138,6 +131,7 @@ public class IdcServiceImpl implements IdcService {
logger.info("UDI管理系统同步任务开始--------"); logger.info("UDI管理系统同步任务开始--------");
asyncDataTask(true); asyncDataTask(true);
} }
/*自助平台生成任务,不上传*/ /*自助平台生成任务,不上传*/
@Override @Override
public void asyncSpsTask() { public void asyncSpsTask() {
@ -145,12 +139,14 @@ public class IdcServiceImpl implements IdcService {
asyncDataTask(false); asyncDataTask(false);
} }
/*拉取前一级中继服务数据*/ /*UDI系统拉取前一级中继服务或自助平台数据*/
@Async @Async
@Override @Override
public void asyncFetchUdiTask() { public void asyncFetchUdiTask() {
fetchTask(false); fetchTask(false);
} }
/*中继服务拉取任务*/
@Async @Async
@Override @Override
public void asyncFetchTask() { public void asyncFetchTask() {
@ -163,6 +159,7 @@ public class IdcServiceImpl implements IdcService {
} }
/*任务拉取,isIdc 是否中继服务*/
private void fetchTask(boolean isIdc) { private void fetchTask(boolean isIdc) {
String host = getNextHost(); String host = getNextHost();
@ -171,10 +168,8 @@ public class IdcServiceImpl implements IdcService {
if (map != null && map.get("syncIp") != null) if (map != null && map.get("syncIp") != null)
host = map.get("syncIp").toString(); host = map.get("syncIp").toString();
} }
logger.info("fetch from ip:"+host);
if (!StringUtils.isEmpty(host)) { if (!StringUtils.isEmpty(host)) {
String result = post(host+"/spssync/common/list",null); String result = IDCUtils.post(host + "/spssync/common/list", null);
if (IDCUtils.isJson(result)) { if (IDCUtils.isJson(result)) {
JSONObject json = JSON.parseObject(result); JSONObject json = JSON.parseObject(result);
if (json != null && json.getInteger("code") == 20000 && json.getString("data") != null) { if (json != null && json.getInteger("code") == 20000 && json.getString("data") != null) {
@ -191,16 +186,6 @@ public class IdcServiceImpl implements IdcService {
} }
} }
@Async
@Override
public void asyncIdcTask() {
initTable();
Map<String,Object> map = dbDao.get("select * from idc_var where code='system_type'");
if(map==null) {
dbDao.save("insert into idc_var (code,content) values ('system_type','IDC')");
}
}
private void asyncDataTask(boolean isUpload) { private void asyncDataTask(boolean isUpload) {
initTable(); initTable();
@ -212,14 +197,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);
} }
} }
} }
@ -274,7 +260,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();
@ -312,7 +297,7 @@ public class IdcServiceImpl implements IdcService {
} }
if (success) { if (success) {
String ret = post(host+"/spssync/common/success",params); String ret = IDCUtils.post(host + "/spssync/common/success", params);
} }
@ -324,28 +309,6 @@ public class IdcServiceImpl implements IdcService {
return result; return result;
} }
private String post(String url,Map<String,Object> params) {
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "");
if(params!=null)
body = RequestBody.create(mediaType,JSON.toJSONString(params));
Request request = new Request.Builder()
.url(url)
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
String result = "";
try {
Response response = client.newCall(request).execute();
result = response.body().string();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
public BaseResponse downlaodSuccess(HttpServletRequest request, Map<String, Object> params) { public BaseResponse downlaodSuccess(HttpServletRequest request, Map<String, Object> params) {
@ -353,6 +316,18 @@ public class IdcServiceImpl implements IdcService {
dbDao.update(sql); dbDao.update(sql);
return ResultVOUtils.success(); return ResultVOUtils.success();
} }
@Override
public BaseResponse receiveJson(HttpServletRequest request,Map<String, Object> params) {
return ResultVOUtils.success();
}
@Override
public BaseResponse uploadFile(HttpServletRequest request,
String content,MultipartFile[] files) {
return ResultVOUtils.success();
}
/****/ /****/
@Override @Override
public BaseResponse receive(HttpServletRequest request, public BaseResponse receive(HttpServletRequest request,
@ -402,7 +377,7 @@ public class IdcServiceImpl implements IdcService {
boolean success = false; boolean success = false;
if (isLastLevel()) { if (isLastLevel()) {
success = analyMiddle("", json, files, true, true); success = analyMiddle("", json, files, true, true);
syncAddTaskStatus(json,2,success,startTime,true); syncAddTaskStatus(json, 3, success, startTime, true);
if (!success) { if (!success) {
return ResultVOUtils.error(9000, "解析失败"); return ResultVOUtils.error(9000, "解析失败");
@ -413,11 +388,11 @@ public class IdcServiceImpl implements IdcService {
String host = getNextHost(); String host = getNextHost();
String result = relay(request.getHeader("reqNo"), content, saveFiles, host); String result = relay(request.getHeader("reqNo"), content, saveFiles, host);
if (IDCUtils.isJson(result)) { if (IDCUtils.isJson(result)) {
syncAddTaskStatus(json,1,true,startTime,true); syncAddTaskStatus(json, 2, true, startTime, true);
BaseResponse object = JSON.parseObject(result, BaseResponse.class); BaseResponse object = JSON.parseObject(result, BaseResponse.class);
return object; return object;
} else { } else {
syncAddTaskStatus(json,1,false,startTime,false); syncAddTaskStatus(json, 2, false, startTime, false);
return ResultVOUtils.error(9000, "转发失败"); return ResultVOUtils.error(9000, "转发失败");
} }
@ -435,6 +410,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) {
@ -482,6 +458,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");
@ -492,6 +469,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());
@ -516,7 +494,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;
@ -574,7 +553,7 @@ public class IdcServiceImpl implements IdcService {
String fileNames = list.get(m).get(filePathColumn).toString(); String fileNames = list.get(m).get(filePathColumn).toString();
String[] str = fileNames.split(","); String[] str = fileNames.split(",");
for (int r = 0; r < str.length; r++) { for (int r = 0; r < str.length; r++) {
if(!StringUtils.isEmpty(str[r])) if (!StringUtils.isEmpty(str[r])&&FileUtils.isFileExist(filePath + filePathSlash + "register/file/image2/" + str[r]))
files.add(filePath + filePathSlash + "register/file/image2/" + str[r]); files.add(filePath + filePathSlash + "register/file/image2/" + str[r]);
} }
} }
@ -597,6 +576,7 @@ public class IdcServiceImpl implements IdcService {
if (childList.get(i).get(chidTnames[7]) != null) { if (childList.get(i).get(chidTnames[7]) != null) {
String[] str = childList.get(i).get(chidTnames[7]).toString().split(","); String[] str = childList.get(i).get(chidTnames[7]).toString().split(",");
for (int s = 0; s < str.length; s++) { for (int s = 0; s < str.length; s++) {
if (!StringUtils.isEmpty(str[s])&&FileUtils.isFileExist(filePath + filePathSlash + "register/file/image2/" + str[s]))
files.add(filePath + filePathSlash + "register/file/image2/" + str[s]); files.add(filePath + filePathSlash + "register/file/image2/" + str[s]);
} }
} }
@ -651,8 +631,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";
@ -669,7 +648,7 @@ public class IdcServiceImpl implements IdcService {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("type", json.get("messageType")); map.put("type", json.get("messageType"));
map.put("id", json.get("messageId")); map.put("id", json.get("messageId"));
if(json.get("id")==null) if (json.get("messageId") == null)
map.put("id", CustomUtil.getId()); map.put("id", CustomUtil.getId());
map.put("transportType", scheduleType == 0 ? "1" : "2"); map.put("transportType", scheduleType == 0 ? "1" : "2");
map.put("scheduleType", scheduleType); map.put("scheduleType", scheduleType);
@ -678,6 +657,7 @@ public class IdcServiceImpl implements IdcService {
map.put("status", success ? "1" : "0"); map.put("status", success ? "1" : "0");
map.put("startTime", startTime != null ? startTime : new Date()); map.put("startTime", startTime != null ? startTime : new Date());
map.put("updateTime", new Date()); map.put("updateTime", new Date());
map.put("remark", json.get("messageType") + ": " + json.get("total") + "条");
if (isEnd) if (isEnd)
map.put("endTime", new Date()); map.put("endTime", new Date());
if (scheduleType == 2) { if (scheduleType == 2) {
@ -928,7 +908,7 @@ public class IdcServiceImpl implements IdcService {
try { try {
Response response = client.newCall(req).execute(); Response response = client.newCall(req).execute();
result = response.body().string(); result = response.body().string();
log.debug("result--->"+result); log.info("result--->" + result);
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
@ -957,9 +937,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);
@ -992,7 +974,6 @@ public class IdcServiceImpl implements IdcService {
outputStream.flush(); outputStream.flush();
} catch (Exception e) { } catch (Exception e) {
@ -1040,6 +1021,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);
@ -1058,8 +1040,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()))) {
@ -1075,6 +1055,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()) {
@ -1099,7 +1080,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);
@ -1139,6 +1121,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 + "'");
@ -1151,6 +1134,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))");
@ -1158,21 +1142,34 @@ public class IdcServiceImpl implements IdcService {
alterTable("idc_log", "create table idc_log (id varchar(36),orderNum int,taskId varchar(60),type varchar(60),content varchar(2000),offset int,total int,createTime datetime,PRIMARY KEY (id))"); alterTable("idc_log", "create table idc_log (id varchar(36),orderNum int,taskId varchar(60),type varchar(60),content varchar(2000),offset int,total int,createTime datetime,PRIMARY KEY (id))");
dbDao.delete("delete from idc_record where createTime<date_sub(now(),interval 2 day) and isEnd='0'"); dbDao.delete("delete from idc_record where createTime<date_sub(now(),interval 2 day) and isEnd='0'");
try { try {
jdbcTemplate.execute("alter table basic_export_status add column cacheFilePath varchar(255)"); executeSql("alter table basic_export_status add column cacheFilePath varchar(255)");
jdbcTemplate.execute("alter table basic_upload_status add column cacheFilePath varchar(255)"); executeSql("alter table basic_upload_status add column cacheFilePath varchar(255)");
jdbcTemplate.execute("alter table idc_status modify column id varchar(100)"); executeSql("alter table idc_status modify column id varchar(100)");
jdbcTemplate.execute("delete from idc_log where createTime<date_sub(now(),interval 3 day)"); executeSql("delete from idc_log where createTime<date_sub(now(),interval 3 day)");
executeSql("alter table basic_export_status add column msg varchar(255)");
executeSql("alter table basic_upload_status add column msg varchar(255)");
executeSql("alter table basic_download_status add column msg varchar(255)");
} catch (Exception e) { } catch (Exception e) {
} }
} }
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)) {
jdbcTemplate.execute(sql); executeSql(sql);
} }
} }
private void executeSql(String sql) {
try {
jdbcTemplate.execute(sql);
} catch (Exception e) {
}
}
} }

@ -1,14 +1,24 @@
package com.glxp.sale.admin.idc.utils; package com.glxp.sale.admin.idc.utils;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.Map;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSON;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
@ -130,4 +140,28 @@ public class IDCUtils {
} }
} }
public static String post(String url, Map<String, Object> params) {
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "");
if (params != null)
body = RequestBody.create(mediaType, JSON.toJSONString(params));
Request request = new Request.Builder()
.url(url)
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
String result = "";
try {
Response response = client.newCall(request).execute();
result = response.body().string();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
} }

@ -0,0 +1,42 @@
package com.glxp.sale.admin.idc.utils;
/**
* @author chenqf
*/
public class TableUtils {
/*同步表,格式:同步设置表列名/同步设置表列名(子表时设置,主表不设置)/主表唯一列(多列逗号分隔)/主表关联列/子表关联列/数据库实际表/时间列/图片或文件列/数据条件/说明*/
private static final String[] SYNC_TABLES = {
"entrustAction//basic_entrust_accept/id///updateTime///委托验收",
"basicProducts//basic_udirel/id///updateTime///耗材字典",
"/basicProducts/basic_products/id/uuid/uuid////耗材字典信息详情",
"basicCorp//basic_corp/id///updateTime///往来单位",
"//company_product_relevance/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///国际库医疗器械注册人信息",
"basicType//basic_hosp_type/id///updateTime///物资字典分类",
"basicDept//auth_dept/id///updateTime///部门信息",
"basicInv//auth_warehouse/id///updateTime///仓库信息",
};
//"dbDiProducts//productinfo/id///updateTime///DI产品信息",
//"basicInv/////////仓库字典",
//"typeBus/////////业务单据类型",
//"typeScan/////////扫码单据类型",
public static String[] syncTables() {
return SYNC_TABLES;
}
}

@ -6,3 +6,10 @@ mybatis.config-location=classpath:mybatis/mybatis-config.xml
mybatis.mapper-locations=classpath:mybatis/mapper/*/*.xml mybatis.mapper-locations=classpath:mybatis/mapper/*/*.xml
spring.jmx.enabled=false spring.jmx.enabled=false
server.tomcat.max-http-form-post-size=100MB
server.tomcat.max-http-post-size=100MB
server.max-http-header-size=100MB
#\u6700\u5927\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F(10MB)
spring.servlet.multipart.max-file-size=200MB
spring.servlet.multipart.max-request-size=200MB
Loading…
Cancel
Save