|
|
|
@ -4,6 +4,7 @@ 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.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
|
|
|
import com.glxp.api.common.util.ResultVOUtils;
|
|
|
|
@ -115,6 +116,17 @@ public class SpsSyncDownloadService {
|
|
|
|
|
orderStatusEntity.setStatus(BasicExportStatusEnum.WAIT_SYNC.getCode());
|
|
|
|
|
orderStatusEntity.setStartTime(new Date());
|
|
|
|
|
orderStatusEntity.setScheduleType(BasicProcessStatus.SCHEDULE_NORMAL);
|
|
|
|
|
|
|
|
|
|
if (lastUpdateTime != null) {
|
|
|
|
|
String fileFullPath = null;
|
|
|
|
|
try {
|
|
|
|
|
fileFullPath = writeFile(filePath, BasicProcessStatus.NEW_ALL_BUS_ORDER, JSONUtil.toJsonStr(baseResponse.getData()));
|
|
|
|
|
orderStatusEntity.setCacheFilePath(fileFullPath);
|
|
|
|
|
orderStatusEntity.setRemark(baseResponse.getData().getSyncRemark());
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
basicExportService.insertExportStatus(orderStatusEntity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -187,21 +199,21 @@ public class SpsSyncDownloadService {
|
|
|
|
|
switch (exportType) {
|
|
|
|
|
case BASIC_DATA:
|
|
|
|
|
if (needExec(info.getBasicProducts(), info.getBasicCorp(), info.getSupCert())) {
|
|
|
|
|
basicExportInfoCreate(exportType, now
|
|
|
|
|
basicExportInfoCreate(exportType, syncTime, now
|
|
|
|
|
, x -> x.generateBasicDataFile(info, now, false, syncTime)
|
|
|
|
|
, x -> x.generateBasicDataFile(info, now, true, syncTime));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case OTHER_DATA:
|
|
|
|
|
if (needExec(info.getUdiCodeLost(), info.getUdiCodeRel())) {
|
|
|
|
|
basicExportInfoCreate(exportType, now
|
|
|
|
|
basicExportInfoCreate(exportType, syncTime, now
|
|
|
|
|
, x -> x.generateOtherDataFile(info, now, false, syncTime)
|
|
|
|
|
, x -> x.generateOtherDataFile(info, now, true, syncTime));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DOCUMENT_TYPE_DATA:
|
|
|
|
|
// if (needExec(info.getTypeBus(), info.getTypeScan(), info.getTypeThird())) {
|
|
|
|
|
// basicExportInfoCreate(exportType, now
|
|
|
|
|
// basicExportInfoCreate(exportType, syncTime, now
|
|
|
|
|
// , x -> x.generateDocumentTypeDataFile(info, now, false, syncTime)
|
|
|
|
|
// , x -> x.generateDocumentTypeDataFile(info, now, true, syncTime));
|
|
|
|
|
// }
|
|
|
|
@ -230,7 +242,7 @@ public class SpsSyncDownloadService {
|
|
|
|
|
* @param hasDataMethod 判断时候有无数据方法
|
|
|
|
|
* @param createFileMethod 执行文件生成方法
|
|
|
|
|
*/
|
|
|
|
|
private void basicExportInfoCreate(BasicExportTypeEnum exportEnum, Date now, Function<SpsSyncDownloadService, Boolean> hasDataMethod, Function<SpsSyncDownloadService, Boolean> createFileMethod) {
|
|
|
|
|
private void basicExportInfoCreate(BasicExportTypeEnum exportEnum, Date syncTime, Date now, Function<SpsSyncDownloadService, Boolean> hasDataMethod, Function<SpsSyncDownloadService, Boolean> createFileMethod) {
|
|
|
|
|
//防止出现同时调用问题
|
|
|
|
|
String redisKey = String.format("spsm-sync-create:%s", exportEnum.getKey());
|
|
|
|
|
boolean result = redisUtil.setIfAbsent(redisKey, 1, 10);
|
|
|
|
@ -256,13 +268,16 @@ public class SpsSyncDownloadService {
|
|
|
|
|
}
|
|
|
|
|
exportStatus = BasicExportStatusEntity.builder()
|
|
|
|
|
.id(CustomUtil.getId())
|
|
|
|
|
.status(BasicExportStatusEnum.WAIT_TRIGGERED.getCode())
|
|
|
|
|
.status(syncTime == null ? BasicExportStatusEnum.WAIT_TRIGGERED.getCode() : BasicExportStatusEnum.WAIT_BUILT.getCode())
|
|
|
|
|
.idDatas(exportEnum.getKey())
|
|
|
|
|
.type(exportEnum.getRemark())
|
|
|
|
|
.scheduleType(0)
|
|
|
|
|
.updateTime(cn.hutool.core.date.DateUtil.date())
|
|
|
|
|
.startTime(now)
|
|
|
|
|
.build();
|
|
|
|
|
if (syncTime != null) {
|
|
|
|
|
createFileMethod.apply(applicationContext.getBean(this.getClass()));
|
|
|
|
|
}
|
|
|
|
|
basicExportService.save(exportStatus);
|
|
|
|
|
} else if (exportStatus.getStatus().equals(BasicExportStatusEnum.WAIT_BUILT.getCode())) {//文件待生成
|
|
|
|
|
createFileMethod.apply(applicationContext.getBean(this.getClass()));
|
|
|
|
@ -723,7 +738,9 @@ public class SpsSyncDownloadService {
|
|
|
|
|
WeakHashMap<String, Object> returnMap = new WeakHashMap<>(10);
|
|
|
|
|
returnMap.put("isNew", isNew);
|
|
|
|
|
returnMap.put("oldDate", isNew ? null : timeInfo.getLastUpdateTime());
|
|
|
|
|
if (createFile) {
|
|
|
|
|
returnMap.put("id", timeInfo.getId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return returnMap;
|
|
|
|
|
}
|
|
|
|
|