|
|
|
@ -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.utils.DBAUtils;
|
|
|
|
|
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.service.param.SystemParamConfigService;
|
|
|
|
|
import com.glxp.sale.admin.util.CustomUtil;
|
|
|
|
@ -54,7 +55,6 @@ import okhttp3.Request;
|
|
|
|
|
import okhttp3.RequestBody;
|
|
|
|
|
import okhttp3.Response;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*数据中继数据中心(接收)*/
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Service
|
|
|
|
@ -70,25 +70,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
@Value("${API_SECRET}")
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@ -103,6 +85,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
@Resource
|
|
|
|
|
private ScheduledDao scheduledDao;
|
|
|
|
|
|
|
|
|
|
/*获取拉取任务列表*/
|
|
|
|
|
@Override
|
|
|
|
|
public BaseResponse taskList(HttpServletRequest request, Map<String, Object> params) {
|
|
|
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
|
|
@ -111,18 +94,28 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
return ResultVOUtils.success(list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*下载任务*/
|
|
|
|
|
@Override
|
|
|
|
|
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)
|
|
|
|
|
ResultVOUtils.error(9000, "下载任务不存在");
|
|
|
|
|
if(!FileUtils.isFileExist(map.get("cacheFilePath").toString()))
|
|
|
|
|
ResultVOUtils.error(9000, "下载文件不存在");
|
|
|
|
|
return ResultVOUtils.error(9000, "下载任务不存在");
|
|
|
|
|
if (!(map.get("cacheFilePath") != null && FileUtils.isFileExist(map.get("cacheFilePath").toString())))
|
|
|
|
|
return ResultVOUtils.error(9000, "下载文件不存在");
|
|
|
|
|
String json = FileUtils.readFileAll(map.get("cacheFilePath").toString());
|
|
|
|
|
|
|
|
|
|
JSONObject object = JSON.parseObject(json);
|
|
|
|
|
if (object == null)
|
|
|
|
|
ResultVOUtils.error(9000, "任务下载失败");
|
|
|
|
|
return ResultVOUtils.error(9000, "任务下载失败");
|
|
|
|
|
if (object != null && object.getInteger("code") != null) {
|
|
|
|
|
BaseResponse response = JSON.parseObject(json, BaseResponse.class);
|
|
|
|
|
return response;
|
|
|
|
@ -138,6 +131,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
logger.info("UDI管理系统同步任务开始--------");
|
|
|
|
|
asyncDataTask(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*自助平台生成任务,不上传*/
|
|
|
|
|
@Override
|
|
|
|
|
public void asyncSpsTask() {
|
|
|
|
@ -145,12 +139,14 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
asyncDataTask(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*拉取前一级中继服务数据*/
|
|
|
|
|
/*UDI系统拉取前一级中继服务或自助平台数据*/
|
|
|
|
|
@Async
|
|
|
|
|
@Override
|
|
|
|
|
public void asyncFetchUdiTask() {
|
|
|
|
|
fetchTask(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*中继服务拉取任务*/
|
|
|
|
|
@Async
|
|
|
|
|
@Override
|
|
|
|
|
public void asyncFetchTask() {
|
|
|
|
@ -163,6 +159,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*任务拉取,isIdc 是否中继服务*/
|
|
|
|
|
private void fetchTask(boolean isIdc) {
|
|
|
|
|
|
|
|
|
|
String host = getNextHost();
|
|
|
|
@ -171,10 +168,8 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
if (map != null && map.get("syncIp") != null)
|
|
|
|
|
host = map.get("syncIp").toString();
|
|
|
|
|
}
|
|
|
|
|
logger.info("fetch from ip:"+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)) {
|
|
|
|
|
JSONObject json = JSON.parseObject(result);
|
|
|
|
|
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) {
|
|
|
|
|
initTable();
|
|
|
|
@ -212,14 +197,15 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for(int i=0;i<SYNC_TABLES.length;i++) {
|
|
|
|
|
String[] tnames = SYNC_TABLES[i].split("/");
|
|
|
|
|
String[] syncTables = TableUtils.syncTables();
|
|
|
|
|
for (int i = 0; i < syncTables.length; i++) {
|
|
|
|
|
String[] tnames = syncTables[i].split("/");
|
|
|
|
|
boolean sync = StringUtils.isEmpty(tnames[0]) ||
|
|
|
|
|
(!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) {
|
|
|
|
|
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) {
|
|
|
|
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
|
|
|
|
.build();
|
|
|
|
@ -312,7 +297,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
@ -353,6 +316,18 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
dbDao.update(sql);
|
|
|
|
|
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
|
|
|
|
|
public BaseResponse receive(HttpServletRequest request,
|
|
|
|
@ -402,7 +377,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
boolean success = false;
|
|
|
|
|
if (isLastLevel()) {
|
|
|
|
|
success = analyMiddle("", json, files, true, true);
|
|
|
|
|
syncAddTaskStatus(json,2,success,startTime,true);
|
|
|
|
|
syncAddTaskStatus(json, 3, success, startTime, true);
|
|
|
|
|
if (!success) {
|
|
|
|
|
|
|
|
|
|
return ResultVOUtils.error(9000, "解析失败");
|
|
|
|
@ -413,11 +388,11 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
String host = getNextHost();
|
|
|
|
|
String result = relay(request.getHeader("reqNo"), content, saveFiles, host);
|
|
|
|
|
if (IDCUtils.isJson(result)) {
|
|
|
|
|
syncAddTaskStatus(json,1,true,startTime,true);
|
|
|
|
|
syncAddTaskStatus(json, 2, true, startTime, true);
|
|
|
|
|
BaseResponse object = JSON.parseObject(result, BaseResponse.class);
|
|
|
|
|
return object;
|
|
|
|
|
} else {
|
|
|
|
|
syncAddTaskStatus(json,1,false,startTime,false);
|
|
|
|
|
syncAddTaskStatus(json, 2, false, startTime, false);
|
|
|
|
|
return ResultVOUtils.error(9000, "转发失败");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -435,6 +410,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public BaseResponse send(String messageType, String tableName, Map<String, Object> params) {
|
|
|
|
|
|
|
|
|
@ -482,6 +458,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
|
|
|
|
|
dbDao.save(sql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void saveDownloadStatus(Map<String, Object> params) {
|
|
|
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
|
|
|
map.put("receiveStatus", "0");
|
|
|
|
@ -492,6 +469,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
|
|
|
|
|
dbDao.save(sql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void saveIdcLog(String messageType, String taskId, String content, int offset, int total) {
|
|
|
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
|
|
|
map.put("id", CustomUtil.getId());
|
|
|
|
@ -516,7 +494,8 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
String[] childs = new String[30];
|
|
|
|
|
int childNum = -1;
|
|
|
|
|
/*子表*/
|
|
|
|
|
for(String str:SYNC_TABLES) {
|
|
|
|
|
String[] syncTables = TableUtils.syncTables();
|
|
|
|
|
for (String str : syncTables) {
|
|
|
|
|
if (str.contains("/" + tableKey + "/")) {
|
|
|
|
|
childNum++;
|
|
|
|
|
childs[childNum] = str;
|
|
|
|
@ -574,7 +553,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
String fileNames = list.get(m).get(filePathColumn).toString();
|
|
|
|
|
String[] str = fileNames.split(",");
|
|
|
|
|
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]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -597,6 +576,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
if (childList.get(i).get(chidTnames[7]) != null) {
|
|
|
|
|
String[] str = childList.get(i).get(chidTnames[7]).toString().split(",");
|
|
|
|
|
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]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -651,8 +631,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
|
|
|
|
|
/*增加同步任务状态*/
|
|
|
|
|
private void syncAddTaskStatus(Map<String, Object> json, int scheduleType, boolean success, Date startTime, boolean isEnd) {
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
String content = JSON.toJSONString(json);
|
|
|
|
|
String datePath = DateUtil.formatDate(new Date(), "yyyy-MM-dd");
|
|
|
|
|
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.put("type", json.get("messageType"));
|
|
|
|
|
map.put("id", json.get("messageId"));
|
|
|
|
|
if(json.get("id")==null)
|
|
|
|
|
if (json.get("messageId") == null)
|
|
|
|
|
map.put("id", CustomUtil.getId());
|
|
|
|
|
map.put("transportType", scheduleType == 0 ? "1" : "2");
|
|
|
|
|
map.put("scheduleType", scheduleType);
|
|
|
|
@ -678,6 +657,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
map.put("status", success ? "1" : "0");
|
|
|
|
|
map.put("startTime", startTime != null ? startTime : new Date());
|
|
|
|
|
map.put("updateTime", new Date());
|
|
|
|
|
map.put("remark", json.get("messageType") + ": " + json.get("total") + "条");
|
|
|
|
|
if (isEnd)
|
|
|
|
|
map.put("endTime", new Date());
|
|
|
|
|
if (scheduleType == 2) {
|
|
|
|
@ -928,7 +908,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
try {
|
|
|
|
|
Response response = client.newCall(req).execute();
|
|
|
|
|
result = response.body().string();
|
|
|
|
|
log.debug("result--->"+result);
|
|
|
|
|
log.info("result--->" + result);
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
e.printStackTrace();
|
|
|
|
@ -957,9 +937,11 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
}
|
|
|
|
|
return success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean signleDownloadFile(String syncIp, String fileName) {
|
|
|
|
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
|
|
|
|
.build();;
|
|
|
|
|
.build();
|
|
|
|
|
;
|
|
|
|
|
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
|
|
|
|
|
|
|
|
|
|
RequestBody body = RequestBody.create(mediaType, "fileName=" + fileName);
|
|
|
|
@ -992,7 +974,6 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
outputStream.flush();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1040,6 +1021,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
List<Map<String, Object>> list = dbDao.list(map);
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*由表名获取数据*/
|
|
|
|
|
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);
|
|
|
|
@ -1058,8 +1040,6 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private SystemParamConfigEntity getSystemParamConfig(String paramKey, String paramName, String defaultValue, String paramExplain) {
|
|
|
|
|
SystemParamConfigEntity systemParamConfigEntity = systemParamConfigService.selectByParamKey(paramKey);
|
|
|
|
|
if (systemParamConfigEntity == null || (systemParamConfigEntity != null && StringUtils.isEmpty(systemParamConfigEntity.getParamKey()))) {
|
|
|
|
@ -1075,6 +1055,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
}
|
|
|
|
|
return systemParamConfigEntity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void writeFile(byte[] file, String filePath, String fileName) throws Exception {
|
|
|
|
|
File targetFile = new File(filePath);
|
|
|
|
|
if (!targetFile.exists()) {
|
|
|
|
@ -1099,7 +1080,8 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
for (int i = 0; i < columnList.size(); i++) {
|
|
|
|
|
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") ?
|
|
|
|
|
"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();
|
|
|
|
|
if (map.get(attrName) == null) {
|
|
|
|
|
column.put("tableName", tname);
|
|
|
|
@ -1139,6 +1121,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
}
|
|
|
|
|
return updateTime;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String setUpdateTime(String id, String updateTime) {
|
|
|
|
|
String sql = "";
|
|
|
|
|
Map<String, Object> map = dbDao.get("select * from idc_status where id='" + id + "'");
|
|
|
|
@ -1151,6 +1134,7 @@ public class IdcServiceImpl implements IdcService {
|
|
|
|
|
}
|
|
|
|
|
return updateTime;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void initTable() {
|
|
|
|
|
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))");
|
|
|
|
@ -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))");
|
|
|
|
|
dbDao.delete("delete from idc_record where createTime<date_sub(now(),interval 2 day) and isEnd='0'");
|
|
|
|
|
try {
|
|
|
|
|
jdbcTemplate.execute("alter table basic_export_status add column cacheFilePath varchar(255)");
|
|
|
|
|
jdbcTemplate.execute("alter table basic_upload_status add column cacheFilePath varchar(255)");
|
|
|
|
|
jdbcTemplate.execute("alter table idc_status modify column id varchar(100)");
|
|
|
|
|
jdbcTemplate.execute("delete from idc_log where createTime<date_sub(now(),interval 3 day)");
|
|
|
|
|
executeSql("alter table basic_export_status add column cacheFilePath varchar(255)");
|
|
|
|
|
executeSql("alter table basic_upload_status add column cacheFilePath varchar(255)");
|
|
|
|
|
executeSql("alter table idc_status modify column id varchar(100)");
|
|
|
|
|
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) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void alterTable(String tableName, String sql) {
|
|
|
|
|
Map<String, String> map = dbDao.getMysql(tableName);
|
|
|
|
|
if (!(map != null && map.get("tableName") != null)) {
|
|
|
|
|
jdbcTemplate.execute(sql);
|
|
|
|
|
executeSql(sql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void executeSql(String sql) {
|
|
|
|
|
try {
|
|
|
|
|
jdbcTemplate.execute(sql);
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|