|
|
|
@ -3,6 +3,7 @@ package com.glxp.api.service.sync;
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
@ -24,18 +25,23 @@ import com.glxp.api.entity.purchase.*;
|
|
|
|
|
import com.glxp.api.entity.sync.BasicDownloadStatusEntity;
|
|
|
|
|
import com.glxp.api.entity.sync.BasicExportStatusEntity;
|
|
|
|
|
import com.glxp.api.entity.sync.BasicExportStatusTimeEntity;
|
|
|
|
|
import com.glxp.api.entity.system.SyncDataSetEntity;
|
|
|
|
|
import com.glxp.api.entity.system.*;
|
|
|
|
|
import com.glxp.api.entity.thrsys.*;
|
|
|
|
|
import com.glxp.api.http.sync.SpGetHttpClient;
|
|
|
|
|
import com.glxp.api.idc.service.FileService;
|
|
|
|
|
import com.glxp.api.req.sync.SpsSyncDataRequest;
|
|
|
|
|
import com.glxp.api.res.sync.*;
|
|
|
|
|
import com.glxp.api.service.auth.*;
|
|
|
|
|
import com.glxp.api.service.basic.EntrustReceService;
|
|
|
|
|
import com.glxp.api.service.basic.IBasicBusTypeChangeService;
|
|
|
|
|
import com.glxp.api.service.basic.IBasicBusTypePreService;
|
|
|
|
|
import com.glxp.api.service.basic.IBasicBussinessTypeService;
|
|
|
|
|
import com.glxp.api.service.inout.*;
|
|
|
|
|
import com.glxp.api.service.system.*;
|
|
|
|
|
import com.glxp.api.service.thrsys.*;
|
|
|
|
|
import com.glxp.api.util.CustomUtil;
|
|
|
|
|
import com.glxp.api.util.DateUtil;
|
|
|
|
|
import com.glxp.api.util.JsonUtils;
|
|
|
|
|
import com.glxp.api.util.RedisUtil;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
@ -44,15 +50,22 @@ import org.apache.ibatis.session.SqlSession;
|
|
|
|
|
import org.apache.ibatis.session.SqlSessionFactory;
|
|
|
|
|
import org.apache.ibatis.session.TransactionIsolationLevel;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileWriter;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.function.Function;
|
|
|
|
|
|
|
|
|
|
import static com.glxp.api.constant.BasicProcessStatus.NEW_ALL_ORDER;
|
|
|
|
|
import static com.glxp.api.constant.BasicProcessStatus.NEW_ALL_UDIS;
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Service
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
@ -115,7 +128,7 @@ public class HeartService {
|
|
|
|
|
BasicExportStatusEntity orderStatusEntity = new BasicExportStatusEntity();
|
|
|
|
|
orderStatusEntity.setId(CustomUtil.getId());
|
|
|
|
|
orderStatusEntity.setIdDatas(ConstantStatus.SYNC_SCAN_ORDER);
|
|
|
|
|
orderStatusEntity.setType(BasicProcessStatus.NEW_ALL_ORDER);
|
|
|
|
|
orderStatusEntity.setType(NEW_ALL_ORDER);
|
|
|
|
|
orderStatusEntity.setUpdateTime(new Date());
|
|
|
|
|
orderStatusEntity.setStartTime(new Date());
|
|
|
|
|
orderStatusEntity.setStatus(ConstantStatus.SYNC_STATUS_WAIT);
|
|
|
|
@ -127,11 +140,12 @@ public class HeartService {
|
|
|
|
|
basicExportStatusTimeEntity.setLastUpdateTime(DateUtil.formatDate(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
basicExportStatusTimeEntity.setKey(ConstantStatus.SYNC_SCAN_ORDER);
|
|
|
|
|
spsSyncOrderResponse.setTaskId(basicExportStatusEntity1.getId());
|
|
|
|
|
spsSyncOrderResponse.setType(NEW_ALL_ORDER);
|
|
|
|
|
BaseResponse<String> baseResponse1 = spGetHttp.postAllOrder(spsSyncOrderResponse);
|
|
|
|
|
if (baseResponse1.getCode() == 20000) {
|
|
|
|
|
basicExportStatusEntity1.setStatus(ConstantStatus.SYNC_STATUS_SUCCESS);
|
|
|
|
|
basicExportStatusEntity1.setStatus(2);
|
|
|
|
|
} else {
|
|
|
|
|
basicExportStatusEntity1.setStatus(ConstantStatus.SYNC_STATUS_FAIL);
|
|
|
|
|
basicExportStatusEntity1.setStatus(1);
|
|
|
|
|
}
|
|
|
|
|
basicExportStatusEntity1.setEndTime(new Date());
|
|
|
|
|
basicExportTimeService.insertExportStatus(basicExportStatusTimeEntity);
|
|
|
|
@ -186,6 +200,7 @@ public class HeartService {
|
|
|
|
|
basicExportStatusTimeEntity.setLastUpdateTime(DateUtil.formatDate(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
basicExportStatusTimeEntity.setKey(ConstantStatus.SYNC_BUS_ORDER);
|
|
|
|
|
spsSyncOrderResponse.setTaskId(basicExportStatusEntity1.getId());
|
|
|
|
|
spsSyncOrderResponse.setType(BasicProcessStatus.ALL_BUS_ORDER);
|
|
|
|
|
BaseResponse<String> baseResponse1 = spGetHttp.postAllBusOrder(spsSyncOrderResponse);
|
|
|
|
|
if (baseResponse1.getCode() == 20000) {
|
|
|
|
|
basicExportStatusEntity1.setStatus(ConstantStatus.SYNC_STATUS_SUCCESS);
|
|
|
|
@ -232,7 +247,7 @@ public class HeartService {
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case USER_DATA:
|
|
|
|
|
if (needExec(info.getDepartment(), info.getWarehouseDict(), info.getUserData())) {
|
|
|
|
|
if (!needExec(info.getBasicDept(), info.getBasicInv(), info.getSysUser())) {
|
|
|
|
|
uploadData(exportType, taskId, x -> x.getUserData(info, taskId, now, syncTime));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
@ -241,11 +256,14 @@ public class HeartService {
|
|
|
|
|
uploadData(exportType, taskId, x -> x.getThirdData(info, taskId, now, syncTime));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case COUNTRY_DI_DATA:
|
|
|
|
|
case SYS_SET_DATA:
|
|
|
|
|
if (needExec(info.getSystemConfig(), info.getEntrustAction(), info.getPrintConfig(), info.getScanChangeConfig(), info.getBusChangeConfig())) {
|
|
|
|
|
uploadData(exportType, taskId, x -> x.getSysSettingData(info, taskId, now, syncTime));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取基础数据模块数据
|
|
|
|
|
*
|
|
|
|
@ -398,6 +416,7 @@ public class HeartService {
|
|
|
|
|
}
|
|
|
|
|
if (dataResponse != null) {
|
|
|
|
|
dataResponse.setTaskId(taskId);
|
|
|
|
|
dataResponse.setType(BasicExportTypeEnum.BASIC_DATA.getRemark());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return dataResponse;
|
|
|
|
@ -422,7 +441,7 @@ public class HeartService {
|
|
|
|
|
if (needExec(info.getUdiCodeLost())) {
|
|
|
|
|
Map<String, Object> map;
|
|
|
|
|
if (syncTime == null) {
|
|
|
|
|
map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.BASIC_PRODUCTS);
|
|
|
|
|
map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.IO_CODE_LOST);
|
|
|
|
|
} else {
|
|
|
|
|
map = syncTimeMap;
|
|
|
|
|
}
|
|
|
|
@ -458,11 +477,34 @@ public class HeartService {
|
|
|
|
|
}
|
|
|
|
|
if (dataResponse != null) {
|
|
|
|
|
dataResponse.setTaskId(taskId);
|
|
|
|
|
dataResponse.setType(BasicExportTypeEnum.OTHER_DATA.getRemark());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return dataResponse;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String writeFile(String filePath, String fileDesc, String content) throws IOException {
|
|
|
|
|
filePath = String.format("%s/%s", filePath, DateUtil.getDate());
|
|
|
|
|
String fileFullPath = String.format("%s/%s-%s.udi", filePath, fileDesc, IdUtil.fastSimpleUUID());
|
|
|
|
|
File file = new File(filePath);
|
|
|
|
|
if (!file.exists()) {
|
|
|
|
|
file.mkdirs();
|
|
|
|
|
}
|
|
|
|
|
file = new File(fileFullPath);
|
|
|
|
|
while (!file.createNewFile()) {
|
|
|
|
|
fileFullPath = String.format("%s/%s/%s-%s.udi", filePath, DateUtil.getDate(), fileDesc, IdUtil.fastSimpleUUID());
|
|
|
|
|
file = new File(fileFullPath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FileWriter fileWriter = new FileWriter(file);
|
|
|
|
|
fileWriter.write(content);
|
|
|
|
|
fileWriter.flush();
|
|
|
|
|
fileWriter.close();
|
|
|
|
|
return fileFullPath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final IBasicBussinessTypeService bussinessTypeService;
|
|
|
|
|
private final IBasicBusTypeChangeService busTypeChangeService;
|
|
|
|
|
private final IThrBusTypeOriginService thrBusTypeOriginService;
|
|
|
|
@ -544,6 +586,8 @@ public class HeartService {
|
|
|
|
|
|
|
|
|
|
if (dataResponse != null) {
|
|
|
|
|
dataResponse.setTaskId(taskId);
|
|
|
|
|
dataResponse.setType(BasicExportTypeEnum.DOCUMENT_TYPE_DATA.getRemark());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return dataResponse;
|
|
|
|
|
}
|
|
|
|
@ -572,7 +616,7 @@ public class HeartService {
|
|
|
|
|
syncTimeMap.put("oldDate", syncTime);
|
|
|
|
|
|
|
|
|
|
//确认有开启部门信息同步
|
|
|
|
|
if (needExec(info.getDepartment())) {
|
|
|
|
|
if (needExec(info.getBasicDept())) {
|
|
|
|
|
Map<String, Object> map;
|
|
|
|
|
if (syncTime == null) {
|
|
|
|
|
map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.DEPT_DATA);
|
|
|
|
@ -602,7 +646,7 @@ public class HeartService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//确认有开启仓库字典同步
|
|
|
|
|
if (needExec(info.getWarehouseDict())) {
|
|
|
|
|
if (needExec(info.getBasicInv())) {
|
|
|
|
|
Map<String, Object> map;
|
|
|
|
|
if (syncTime == null) {
|
|
|
|
|
map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.WAREHOUSE_DICT);
|
|
|
|
@ -656,7 +700,7 @@ public class HeartService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//确认有开启用户信息同步
|
|
|
|
|
if (needExec(info.getUserData())) {
|
|
|
|
|
if (needExec(info.getSysUser())) {
|
|
|
|
|
Map<String, Object> map;
|
|
|
|
|
if (syncTime == null) {
|
|
|
|
|
map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.USER_DATA);
|
|
|
|
@ -689,6 +733,7 @@ public class HeartService {
|
|
|
|
|
|
|
|
|
|
if (dataResponse != null) {
|
|
|
|
|
dataResponse.setTaskId(taskId);
|
|
|
|
|
dataResponse.setType(BasicExportTypeEnum.USER_DATA.getRemark());
|
|
|
|
|
}
|
|
|
|
|
return dataResponse;
|
|
|
|
|
}
|
|
|
|
@ -796,7 +841,209 @@ public class HeartService {
|
|
|
|
|
|
|
|
|
|
if (dataResponse != null) {
|
|
|
|
|
dataResponse.setTaskId(taskId);
|
|
|
|
|
dataResponse.setType(BasicExportTypeEnum.THIRD_DATA.getRemark());
|
|
|
|
|
}
|
|
|
|
|
return dataResponse;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final SystemParamConfigService systemParamConfigService;
|
|
|
|
|
private final EntrustReceService entrustReceService;
|
|
|
|
|
private final SystemPDFModuleService systemPDFModuleService;
|
|
|
|
|
private final SystemPDFTemplateService systemPDFTemplateService;
|
|
|
|
|
private final SystemPDFTemplateRelevanceCodeService systemPDFTemplateRelevanceCodeService;
|
|
|
|
|
private final SystemPDFTemplateRelevanceBizService systemPDFTemplateRelevanceBizService;
|
|
|
|
|
private final SystemPDFTemplateRelevanceLabelService systemPDFTemplateRelevanceLabelService;
|
|
|
|
|
private final SystemPDFTemplateRelevanceStatemenService systemPDFTemplateRelevanceStatemenService;
|
|
|
|
|
private final IBasicBusTypePreService iBasicBusTypePreService;
|
|
|
|
|
private final IBasicBusTypeChangeService iBasicBusTypeChangeService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取系统设置模块数据
|
|
|
|
|
*
|
|
|
|
|
* @param info 同步设置
|
|
|
|
|
* @param now 当前时间
|
|
|
|
|
* @param syncTime 同步时间 -- 传入时不操作exportTime表
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private SpsSyncSysSettingResponse getSysSettingData(SyncDataSetEntity info, String taskId, Date now, Date syncTime) {
|
|
|
|
|
SpsSyncSysSettingResponse dataResponse = null;
|
|
|
|
|
Map<String, Object> syncTimeMap = new WeakHashMap<>(3);
|
|
|
|
|
syncTimeMap.put("isNew", true);
|
|
|
|
|
syncTimeMap.put("oldDate", syncTime);
|
|
|
|
|
if (needExec(info.getSystemConfig())) {
|
|
|
|
|
Map<String, Object> map;
|
|
|
|
|
if (syncTime == null) {
|
|
|
|
|
map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.SYSTEM_PARAM_CONFIG);
|
|
|
|
|
} else {
|
|
|
|
|
map = syncTimeMap;
|
|
|
|
|
}
|
|
|
|
|
List<SystemParamConfigEntity> systemParamConfigEntities = systemParamConfigService.list(Wrappers.lambdaQuery(SystemParamConfigEntity.class)
|
|
|
|
|
.le((boolean) map.get("isNew"), SystemParamConfigEntity::getUpdateTime, now)
|
|
|
|
|
.between(!(boolean) map.get("isNew"), SystemParamConfigEntity::getUpdateTime
|
|
|
|
|
, map.get("oldDate"), now)
|
|
|
|
|
);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(systemParamConfigEntities)) {
|
|
|
|
|
dataResponse = new SpsSyncSysSettingResponse();
|
|
|
|
|
dataResponse.setSystemParamConfigEntities(systemParamConfigEntities);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (needExec(info.getEntrustAction())) {
|
|
|
|
|
Map<String, Object> map;
|
|
|
|
|
if (syncTime == null) {
|
|
|
|
|
map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.ENTRUST_ACCEPT);
|
|
|
|
|
} else {
|
|
|
|
|
map = syncTimeMap;
|
|
|
|
|
}
|
|
|
|
|
List<EntrustReceEntity> entrustReceEntities = entrustReceService.list(Wrappers.lambdaQuery(EntrustReceEntity.class)
|
|
|
|
|
.le((boolean) map.get("isNew"), EntrustReceEntity::getUpdateTime, now)
|
|
|
|
|
.between(!(boolean) map.get("isNew"), EntrustReceEntity::getUpdateTime
|
|
|
|
|
, map.get("oldDate"), now)
|
|
|
|
|
);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(entrustReceEntities)) {
|
|
|
|
|
if (dataResponse == null) {
|
|
|
|
|
dataResponse = new SpsSyncSysSettingResponse();
|
|
|
|
|
}
|
|
|
|
|
dataResponse.setEntrustReceEntities(entrustReceEntities);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (needExec(info.getPrintConfig())) {
|
|
|
|
|
Map<String, Object> map;
|
|
|
|
|
if (syncTime == null) {
|
|
|
|
|
map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.PRINT_CONFIG);
|
|
|
|
|
} else {
|
|
|
|
|
map = syncTimeMap;
|
|
|
|
|
}
|
|
|
|
|
List<SystemPDFModuleEntity> systemPDFModuleEntities = systemPDFModuleService.list(Wrappers.lambdaQuery(SystemPDFModuleEntity.class)
|
|
|
|
|
.le((boolean) map.get("isNew"), SystemPDFModuleEntity::getUpdate_time, now)
|
|
|
|
|
.between(!(boolean) map.get("isNew"), SystemPDFModuleEntity::getUpdate_time
|
|
|
|
|
, map.get("oldDate"), now)
|
|
|
|
|
);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(systemPDFModuleEntities)) {
|
|
|
|
|
if (dataResponse == null) {
|
|
|
|
|
dataResponse = new SpsSyncSysSettingResponse();
|
|
|
|
|
}
|
|
|
|
|
dataResponse.setSystemPDFModuleEntities(systemPDFModuleEntities);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<SystemPDFTemplateEntity> systemPDFTemplateEntities = systemPDFTemplateService.list(Wrappers.lambdaQuery(SystemPDFTemplateEntity.class)
|
|
|
|
|
.le((boolean) map.get("isNew"), SystemPDFTemplateEntity::getUpdate_time, now)
|
|
|
|
|
.between(!(boolean) map.get("isNew"), SystemPDFTemplateEntity::getUpdate_time
|
|
|
|
|
, map.get("oldDate"), now)
|
|
|
|
|
);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(systemPDFTemplateEntities)) {
|
|
|
|
|
if (dataResponse == null) {
|
|
|
|
|
dataResponse = new SpsSyncSysSettingResponse();
|
|
|
|
|
}
|
|
|
|
|
dataResponse.setSystemPDFTemplateEntities(systemPDFTemplateEntities);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<SysPdfTemplateRelevanceCodeEntity> sysPdfTemplateRelevanceCodeEntities = systemPDFTemplateRelevanceCodeService.list(Wrappers.lambdaQuery(SysPdfTemplateRelevanceCodeEntity.class)
|
|
|
|
|
.le((boolean) map.get("isNew"), SysPdfTemplateRelevanceCodeEntity::getUpdateTime, now)
|
|
|
|
|
.between(!(boolean) map.get("isNew"), SysPdfTemplateRelevanceCodeEntity::getUpdateTime
|
|
|
|
|
, map.get("oldDate"), now)
|
|
|
|
|
);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(sysPdfTemplateRelevanceCodeEntities)) {
|
|
|
|
|
if (dataResponse == null) {
|
|
|
|
|
dataResponse = new SpsSyncSysSettingResponse();
|
|
|
|
|
}
|
|
|
|
|
dataResponse.setSysPdfTemplateRelevanceCodeEntities(sysPdfTemplateRelevanceCodeEntities);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<SysPdfTemplateRelevanceBizEntity> sysPdfTemplateRelevanceBizEntities = systemPDFTemplateRelevanceBizService.list(Wrappers.lambdaQuery(SysPdfTemplateRelevanceBizEntity.class)
|
|
|
|
|
.le((boolean) map.get("isNew"), SysPdfTemplateRelevanceBizEntity::getUpdateTime, now)
|
|
|
|
|
.between(!(boolean) map.get("isNew"), SysPdfTemplateRelevanceBizEntity::getUpdateTime
|
|
|
|
|
, map.get("oldDate"), now)
|
|
|
|
|
);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(sysPdfTemplateRelevanceBizEntities)) {
|
|
|
|
|
if (dataResponse == null) {
|
|
|
|
|
dataResponse = new SpsSyncSysSettingResponse();
|
|
|
|
|
}
|
|
|
|
|
dataResponse.setSysPdfTemplateRelevanceBizEntities(sysPdfTemplateRelevanceBizEntities);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<SysPdfTemplateRelevanceLabelEntity> sysPdfTemplateRelevanceLabelEntities = systemPDFTemplateRelevanceLabelService.list(Wrappers.lambdaQuery(SysPdfTemplateRelevanceLabelEntity.class)
|
|
|
|
|
.le((boolean) map.get("isNew"), SysPdfTemplateRelevanceLabelEntity::getUpdateTime, now)
|
|
|
|
|
.between(!(boolean) map.get("isNew"), SysPdfTemplateRelevanceLabelEntity::getUpdateTime
|
|
|
|
|
, map.get("oldDate"), now)
|
|
|
|
|
);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(sysPdfTemplateRelevanceLabelEntities)) {
|
|
|
|
|
if (dataResponse == null) {
|
|
|
|
|
dataResponse = new SpsSyncSysSettingResponse();
|
|
|
|
|
}
|
|
|
|
|
dataResponse.setSysPdfTemplateRelevanceLabelEntities(sysPdfTemplateRelevanceLabelEntities);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<SysPdfTemplateRelevanceStatemenEntity> sysPdfTemplateRelevanceStatemenEntities = systemPDFTemplateRelevanceStatemenService.list(Wrappers.lambdaQuery(SysPdfTemplateRelevanceStatemenEntity.class)
|
|
|
|
|
.le((boolean) map.get("isNew"), SysPdfTemplateRelevanceStatemenEntity::getUpdateTime, now)
|
|
|
|
|
.between(!(boolean) map.get("isNew"), SysPdfTemplateRelevanceStatemenEntity::getUpdateTime
|
|
|
|
|
, map.get("oldDate"), now)
|
|
|
|
|
);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(sysPdfTemplateRelevanceStatemenEntities)) {
|
|
|
|
|
if (dataResponse == null) {
|
|
|
|
|
dataResponse = new SpsSyncSysSettingResponse();
|
|
|
|
|
}
|
|
|
|
|
dataResponse.setSysPdfTemplateRelevanceStatemenEntities(sysPdfTemplateRelevanceStatemenEntities);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (needExec(info.getScanChangeConfig())) {
|
|
|
|
|
Map<String, Object> map;
|
|
|
|
|
if (syncTime == null) {
|
|
|
|
|
map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.SCAN_CHANGE);
|
|
|
|
|
} else {
|
|
|
|
|
map = syncTimeMap;
|
|
|
|
|
}
|
|
|
|
|
List<BasicBusTypePreEntity> basicBusTypePreEntities = iBasicBusTypePreService.list(Wrappers.lambdaQuery(BasicBusTypePreEntity.class)
|
|
|
|
|
.le((boolean) map.get("isNew"), BasicBusTypePreEntity::getUpdateTime, now)
|
|
|
|
|
.between(!(boolean) map.get("isNew"), BasicBusTypePreEntity::getUpdateTime
|
|
|
|
|
, map.get("oldDate"), now)
|
|
|
|
|
);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(basicBusTypePreEntities)) {
|
|
|
|
|
dataResponse = new SpsSyncSysSettingResponse();
|
|
|
|
|
dataResponse.setBasicBusTypePreEntities(basicBusTypePreEntities);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (needExec(info.getBusChangeConfig())) {
|
|
|
|
|
Map<String, Object> map;
|
|
|
|
|
if (syncTime == null) {
|
|
|
|
|
map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.BUS_TYPE_CHANGE);
|
|
|
|
|
} else {
|
|
|
|
|
map = syncTimeMap;
|
|
|
|
|
}
|
|
|
|
|
List<BasicBusTypeChangeEntity> basicBusTypeChangeEntities = iBasicBusTypeChangeService.list(Wrappers.lambdaQuery(BasicBusTypeChangeEntity.class)
|
|
|
|
|
.le((boolean) map.get("isNew"), BasicBusTypeChangeEntity::getUpdateTime, now)
|
|
|
|
|
.between(!(boolean) map.get("isNew"), BasicBusTypeChangeEntity::getUpdateTime
|
|
|
|
|
, map.get("oldDate"), now)
|
|
|
|
|
);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(basicBusTypeChangeEntities)) {
|
|
|
|
|
dataResponse = new SpsSyncSysSettingResponse();
|
|
|
|
|
dataResponse.setBasicBusTypeChangeEntities(basicBusTypeChangeEntities);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dataResponse != null) {
|
|
|
|
|
dataResponse.setTaskId(taskId);
|
|
|
|
|
dataResponse.setType(BasicExportTypeEnum.SYS_SET_DATA.getRemark());
|
|
|
|
|
if (CollUtil.isNotEmpty(dataResponse.getSystemPDFTemplateEntities())) {
|
|
|
|
|
// List<Map<String, String>> list = new ArrayList<>(spsSyncSysSettingResponse.getSystemPDFTemplateEntities().size() * 2);
|
|
|
|
|
List<String> list = new ArrayList<>();
|
|
|
|
|
dataResponse.getSystemPDFTemplateEntities().forEach(systemPDFTemplateEntity -> {
|
|
|
|
|
list.add(systemPDFTemplateEntity.getPath());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
BaseResponse<String> response = spGetHttp.postTemplateFile(list);
|
|
|
|
|
if (response.getCode() == 20000) {
|
|
|
|
|
log.info("模板文件列表上传成功");
|
|
|
|
|
// uploadFileLog = "\n模板文件列表上传成功";
|
|
|
|
|
} else {
|
|
|
|
|
log.info("模板文件上传失败,响应信息:{}", response.getMessage());
|
|
|
|
|
// uploadFileLog = "\n模板文件列表上传失败,错误信息:" + response.getMessage();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return dataResponse;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -817,7 +1064,7 @@ public class HeartService {
|
|
|
|
|
if (data == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
BaseResponse<String> baseResponse = spGetHttp.postData(exportType, data);
|
|
|
|
|
BaseResponse<String> baseResponse = spGetHttp.postData(taskId, exportType, data);
|
|
|
|
|
if (baseResponse.getCode() != 20000) {
|
|
|
|
|
status = StatusEnum.FAILED.getCode();
|
|
|
|
|
}
|
|
|
|
@ -833,7 +1080,14 @@ public class HeartService {
|
|
|
|
|
.scheduleType(BasicProcessStatus.SCHEDULE_NORMAL)
|
|
|
|
|
.remark(baseResponse.getMessage())
|
|
|
|
|
.build();
|
|
|
|
|
applicationContext.getBean(this.getClass()).insertExportStatus(exportStatus);
|
|
|
|
|
try {
|
|
|
|
|
String fileFullPath = writeFile(filePrefix, exportType.getRemark(), JsonUtils.toJsonString(data));
|
|
|
|
|
exportStatus.setCacheFilePath(fileFullPath);
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
} finally {
|
|
|
|
|
applicationContext.getBean(this.getClass()).insertExportStatus(exportStatus);
|
|
|
|
|
}
|
|
|
|
|
if (baseResponse.getCode() != 20000) {
|
|
|
|
|
throw new RuntimeException(baseResponse.getMessage());
|
|
|
|
|
}
|
|
|
|
@ -1030,13 +1284,13 @@ public class HeartService {
|
|
|
|
|
//下载最近更新扫码单据--上级服务
|
|
|
|
|
@Transactional(propagation = Propagation.NESTED)
|
|
|
|
|
public void dlAllOrder() {
|
|
|
|
|
BaseResponse<List<BasicExportStatusEntity>> baseResponse = spGetHttp.getBasicStatus(BasicProcessStatus.NEW_ALL_ORDER + "");
|
|
|
|
|
BaseResponse<List<BasicExportStatusEntity>> baseResponse = spGetHttp.getBasicStatus(NEW_ALL_ORDER + "");
|
|
|
|
|
List<BasicExportStatusEntity> pageSimpleResponse = baseResponse != null ? baseResponse.getData() : new ArrayList<>();
|
|
|
|
|
if (pageSimpleResponse != null) {
|
|
|
|
|
List<BasicExportStatusEntity> basicExportStatusEntities = pageSimpleResponse;
|
|
|
|
|
if (basicExportStatusEntities != null && basicExportStatusEntities.size() > 0) {
|
|
|
|
|
for (BasicExportStatusEntity basicExportStatusEntity : basicExportStatusEntities) {
|
|
|
|
|
String datas = spGetHttp.getBasicData(basicExportStatusEntity.getId(), BasicProcessStatus.NEW_ALL_ORDER);
|
|
|
|
|
String datas = spGetHttp.getBasicData(basicExportStatusEntity.getId(), NEW_ALL_ORDER);
|
|
|
|
|
BaseResponse<String> response = JSONObject.parseObject(datas, new TypeReference<BaseResponse<String>>() {
|
|
|
|
|
});
|
|
|
|
|
if (response.getCode() == 20000 && response.getData() != null) {
|
|
|
|
@ -1049,7 +1303,7 @@ public class HeartService {
|
|
|
|
|
basicDownloadStatusEntity.setStartTime(new Date());
|
|
|
|
|
basicDownloadStatusEntity.setIdDatas(ConstantStatus.SYNC_DOWNLOAD_SCAN_ORDER);
|
|
|
|
|
basicDownloadStatusEntity.setStatus(ConstantStatus.SYNC_STATUS_WAIT); //下载中
|
|
|
|
|
basicDownloadStatusEntity.setType(BasicProcessStatus.NEW_ALL_ORDER);
|
|
|
|
|
basicDownloadStatusEntity.setType(NEW_ALL_ORDER);
|
|
|
|
|
basicDownloadStatusEntity.setScheduleType(1);
|
|
|
|
|
basicDownloadService.insertDownloadStatus(basicDownloadStatusEntity);
|
|
|
|
|
StringBuffer remark = new StringBuffer();
|
|
|
|
@ -1111,7 +1365,7 @@ public class HeartService {
|
|
|
|
|
// 下载最近更新国家库数据-上级服务
|
|
|
|
|
@Transactional(propagation = Propagation.NESTED)
|
|
|
|
|
public void dlAllDiProducts() {
|
|
|
|
|
BaseResponse<List<BasicExportStatusEntity>> baseResponse = spGetHttp.getBasicStatus(BasicProcessStatus.NEW_ALL_DI + "");
|
|
|
|
|
BaseResponse<List<BasicExportStatusEntity>> baseResponse = spGetHttp.getBasicStatus(NEW_ALL_UDIS);
|
|
|
|
|
List<BasicExportStatusEntity> pageSimpleResponse = baseResponse.getData();
|
|
|
|
|
if (pageSimpleResponse != null) {
|
|
|
|
|
List<BasicExportStatusEntity> basicExportStatusEntities = pageSimpleResponse;
|
|
|
|
@ -1119,7 +1373,7 @@ public class HeartService {
|
|
|
|
|
for (BasicExportStatusEntity basicExportStatusEntity : basicExportStatusEntities) {
|
|
|
|
|
long curTime = System.currentTimeMillis();
|
|
|
|
|
// log.info("--------等待时间------" + curTime);
|
|
|
|
|
String datas = spGetHttp.getBasicData(basicExportStatusEntity.getId(), BasicProcessStatus.NEW_ALL_DI);
|
|
|
|
|
String datas = spGetHttp.getBasicData(basicExportStatusEntity.getId(), BasicProcessStatus.NEW_ALL_UDIS);
|
|
|
|
|
// logger.info("--------等待时间1------" + (System.currentTimeMillis() - curTime) / 1000);
|
|
|
|
|
long curTime2 = System.currentTimeMillis();
|
|
|
|
|
BaseResponse<SpSyncUdiResponse> response = JSONObject.parseObject(datas, new TypeReference<BaseResponse<SpSyncUdiResponse>>() {
|
|
|
|
@ -1133,7 +1387,7 @@ public class HeartService {
|
|
|
|
|
basicDownloadStatusEntity.setStartTime(new Date());
|
|
|
|
|
basicDownloadStatusEntity.setIdDatas(ConstantStatus.SYNC_DOWNLOAD_DI_PRODUCTS);
|
|
|
|
|
basicDownloadStatusEntity.setStatus(ConstantStatus.SYNC_STATUS_WAIT); //下载中
|
|
|
|
|
basicDownloadStatusEntity.setType(BasicProcessStatus.NEW_ALL_DI);
|
|
|
|
|
basicDownloadStatusEntity.setType(BasicProcessStatus.NEW_ALL_UDIS);
|
|
|
|
|
basicDownloadStatusEntity.setScheduleType(1);
|
|
|
|
|
|
|
|
|
|
basicDownloadService.insertDownloadStatus(basicDownloadStatusEntity);
|
|
|
|
@ -1186,6 +1440,8 @@ public class HeartService {
|
|
|
|
|
private final SupManufacturerDao supManufacturerDao;
|
|
|
|
|
private final SupProductDao supProductDao;
|
|
|
|
|
|
|
|
|
|
@Value("${file_path}")
|
|
|
|
|
private String filePrefix;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 从UDI自助平台拉取 统一方法
|
|
|
|
@ -1216,8 +1472,6 @@ public class HeartService {
|
|
|
|
|
case DOCUMENT_TYPE_DATA:
|
|
|
|
|
this.insertDocumentTypeData(bean.getFileContent());
|
|
|
|
|
break;
|
|
|
|
|
case COUNTRY_DI_DATA:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
String taskId = bean.getTaskId();
|
|
|
|
|
if (StrUtil.isNotBlank(taskId)) {
|
|
|
|
@ -1232,6 +1486,12 @@ public class HeartService {
|
|
|
|
|
basicDownloadStatusEntity.setStatus(StatusEnum.SUCCESS.getCode()); //下载完成
|
|
|
|
|
basicDownloadStatusEntity.setType(exportType.getRemark());
|
|
|
|
|
basicDownloadStatusEntity.setScheduleType(1);
|
|
|
|
|
try {
|
|
|
|
|
String fileFullPath = writeFile(filePrefix, exportType.getRemark(), bean.getFileContent());
|
|
|
|
|
basicDownloadStatusEntity.setCacheFilePath(fileFullPath);
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
basicDownloadService.insertDownloadStatus(basicDownloadStatusEntity);
|
|
|
|
|
//通知自助平台任务已完成
|
|
|
|
|
spGetHttp.finishTask(taskId);
|
|
|
|
@ -1259,6 +1519,8 @@ public class HeartService {
|
|
|
|
|
List<SupManufacturerEntity> supManufacturerList = JSONUtil.toList(jsonObject.getJSONArray(SupManufacturerEntity.class.getSimpleName()), SupManufacturerEntity.class);
|
|
|
|
|
List<SupProductEntity> supProductList = JSONUtil.toList(jsonObject.getJSONArray(SupProductEntity.class.getSimpleName()), SupProductEntity.class);
|
|
|
|
|
|
|
|
|
|
List<String> syncFiles = JSONUtil.toList(jsonObject.getJSONArray("syncFiles"), String.class);
|
|
|
|
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(hospTypeList)) {
|
|
|
|
|
basicHospTypeDao.insertOrUpdateBatch(hospTypeList);
|
|
|
|
|
}
|
|
|
|
@ -1272,8 +1534,7 @@ public class HeartService {
|
|
|
|
|
relevanceDao.insertOrUpdateBatch(relevanceList);
|
|
|
|
|
}
|
|
|
|
|
if (CollectionUtil.isNotEmpty(corpList)) {
|
|
|
|
|
for (BasicCorpEntity basicCorpEntity : corpList)
|
|
|
|
|
corpDao.insertOrUpdate(basicCorpEntity);
|
|
|
|
|
corpDao.insertOrUpdateBatch(corpList);
|
|
|
|
|
}
|
|
|
|
|
if (CollectionUtil.isNotEmpty(supCertList)) {
|
|
|
|
|
supCertDao.insertOrUpdateBatch(supCertList);
|
|
|
|
@ -1290,8 +1551,14 @@ public class HeartService {
|
|
|
|
|
if (CollectionUtil.isNotEmpty(supProductList)) {
|
|
|
|
|
supProductDao.insertOrUpdateBatch(supProductList);
|
|
|
|
|
}
|
|
|
|
|
if (CollUtil.isNotEmpty(syncFiles)) {
|
|
|
|
|
fileService.download(syncFiles);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
FileService fileService;
|
|
|
|
|
|
|
|
|
|
private final IoCodeLostMapper ioCodeLostMapper;
|
|
|
|
|
private final IoCodeRelMapper ioCodeRelMapper;
|
|
|
|
|