|
|
|
@ -14,6 +14,8 @@ import com.glxp.api.controller.sync.SpsSyncWebSocket;
|
|
|
|
|
import com.glxp.api.constant.Constant;
|
|
|
|
|
import com.glxp.api.dao.basic.BasicProductsDao;
|
|
|
|
|
import com.glxp.api.entity.basic.*;
|
|
|
|
|
import com.glxp.api.entity.collect.RelCodeBatch;
|
|
|
|
|
import com.glxp.api.entity.collect.RelCodeDetail;
|
|
|
|
|
import com.glxp.api.entity.dev.*;
|
|
|
|
|
import com.glxp.api.entity.inout.*;
|
|
|
|
|
import com.glxp.api.entity.inv.DeviceInspectTaskDetailEntity;
|
|
|
|
@ -31,9 +33,12 @@ import com.glxp.api.req.inout.FilterOrderRequest;
|
|
|
|
|
import com.glxp.api.req.sync.SpsSyncDataRequest;
|
|
|
|
|
import com.glxp.api.res.sync.SpSyncUdiResponse;
|
|
|
|
|
import com.glxp.api.res.sync.SpsSyncDeviceTaskResponse;
|
|
|
|
|
import com.glxp.api.res.sync.SpsSyncDrugDataTaskResponse;
|
|
|
|
|
import com.glxp.api.res.sync.SpsSyncOrderResponse;
|
|
|
|
|
import com.glxp.api.res.system.SyncDataSetResponse;
|
|
|
|
|
import com.glxp.api.service.basic.*;
|
|
|
|
|
import com.glxp.api.service.collect.RelCodeBatchService;
|
|
|
|
|
import com.glxp.api.service.collect.RelCodeDetailService;
|
|
|
|
|
import com.glxp.api.service.dev.*;
|
|
|
|
|
import com.glxp.api.service.inout.*;
|
|
|
|
|
import com.glxp.api.service.inout.impl.IoCodeService;
|
|
|
|
@ -61,6 +66,7 @@ import java.io.FileWriter;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.function.Function;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import static com.glxp.api.constant.BasicProcessStatus.NEW_ALL_ORDER;
|
|
|
|
|
import static com.glxp.api.constant.BasicProcessStatus.NEW_ALL_UDIS;
|
|
|
|
@ -274,6 +280,11 @@ public class SpsSyncDownloadService {
|
|
|
|
|
, x -> x.generateProBusFile(info, now, false, syncTime)
|
|
|
|
|
,x -> x.generateProBusFile(info, now, true, syncTime));
|
|
|
|
|
break;
|
|
|
|
|
case DRUG_DATA_TASK:
|
|
|
|
|
basicExportInfoCreate(exportType,syncTime,now
|
|
|
|
|
, x -> x.generateDrugDataFile(info, now, false, syncTime)
|
|
|
|
|
,x -> x.generateDrugDataFile(info, now, true, syncTime));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1300,6 +1311,85 @@ public class SpsSyncDownloadService {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
RelCodeBatchService relCodeBatchService;
|
|
|
|
|
@Resource
|
|
|
|
|
RelCodeDetailService relCodeDetailService;
|
|
|
|
|
|
|
|
|
|
// 药品关联信息 generateDrugDataFile
|
|
|
|
|
protected boolean generateDrugDataFile(SyncDataSetResponse info, Date now, boolean createFile, Date syncTime) {
|
|
|
|
|
BasicExportTypeEnum exportType = BasicExportTypeEnum.DRUG_DATA_TASK;
|
|
|
|
|
//文件数据
|
|
|
|
|
Map<String, Object> jsonMap = new WeakHashMap<>(4);
|
|
|
|
|
List<String> syncFiles = new ArrayList<>();
|
|
|
|
|
Map<BasicExportStatusTimeEnum, Map<String, Object>> totalTimeMap = new WeakHashMap<>(10);
|
|
|
|
|
StringBuffer remark = new StringBuffer();
|
|
|
|
|
Map<String, Object> syncTimeMap = new WeakHashMap<>(3);
|
|
|
|
|
syncTimeMap.put("isNew", true);
|
|
|
|
|
boolean ge = false;
|
|
|
|
|
if (syncTime != null) {
|
|
|
|
|
ge = true;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
//确认有开启报修设备管理信息由外向内同步
|
|
|
|
|
if (needExec(info.getDrugDataTask())) {
|
|
|
|
|
Map<String, Object> map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.DRUG_DATA_TASK, createFile);
|
|
|
|
|
totalTimeMap.put(BasicExportStatusTimeEnum.DRUG_DATA_TASK, map);
|
|
|
|
|
SpsSyncDrugDataTaskResponse dataResponse = null;
|
|
|
|
|
|
|
|
|
|
List<RelCodeBatch> relCodeBatches = relCodeBatchService.list(Wrappers.lambdaQuery(RelCodeBatch.class)
|
|
|
|
|
.le(!ge && (boolean) map.get("isNew"), RelCodeBatch::getUpdateTime, now)
|
|
|
|
|
.between(ge, RelCodeBatch::getUpdateTime, syncTime, now)
|
|
|
|
|
.between(!ge && !(boolean) map.get("isNew"), RelCodeBatch::getUpdateTime
|
|
|
|
|
, map.get("oldDate"), now)
|
|
|
|
|
);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(relCodeBatches)) {
|
|
|
|
|
dataResponse = new SpsSyncDrugDataTaskResponse();
|
|
|
|
|
dataResponse.setRelCodeBatches(relCodeBatches);
|
|
|
|
|
|
|
|
|
|
//增加明细数据
|
|
|
|
|
List<Integer> batchIds = relCodeBatches.stream().map(RelCodeBatch::getId).collect(Collectors.toList());
|
|
|
|
|
List<RelCodeDetail> list = relCodeDetailService.list(Wrappers.lambdaQuery(RelCodeDetail.class)
|
|
|
|
|
.in(RelCodeDetail::getBatchIdFk,batchIds));
|
|
|
|
|
dataResponse.setRelCodeDetails(list);
|
|
|
|
|
|
|
|
|
|
jsonMap.put(SpsSyncDrugDataTaskResponse.class.getSimpleName(), dataResponse);
|
|
|
|
|
remark.append("药品关联信息任务:").append(relCodeBatches.size()).append("条\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (jsonMap.size() > 0) {
|
|
|
|
|
jsonMap.put(SYNC_REMARK, remark.toString());
|
|
|
|
|
if (!createFile) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
String fileFullPath = writeFile(filePath, exportType.getRemark(), JsonUtils.toJsonString(jsonMap));
|
|
|
|
|
try {
|
|
|
|
|
//修改任务数据
|
|
|
|
|
boolean update = updateExportStatus(exportType, fileFullPath, remark.toString());
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// 异常回滚
|
|
|
|
|
this.exportTimeRollback(totalTimeMap, exportType, fileFullPath);
|
|
|
|
|
}
|
|
|
|
|
// SocketMsgEntity socketMsgEntity = SocketMsgEntity.builder().type(SocketMsgType.STAT_DATA_REQUEST).remark("下载生产企业信息").build();
|
|
|
|
|
SocketMsgEntity socketMsgEntity = SocketMsgEntity.builder().type(SocketMsgType.DL_ALL_DATA).remark("下载药品关联信息").build();
|
|
|
|
|
spsSyncWebSocket.sendMessage(socketMsgEntity, "1:" + socketToken);
|
|
|
|
|
return true;
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
logger.error(String.format("syncIdcSps----process------------生成[%s]文件及更改库操作异常,异常信息<%s>"
|
|
|
|
|
, exportType.getRemark(), e.getMessage()));
|
|
|
|
|
// 异常回滚
|
|
|
|
|
this.exportTimeRollback(totalTimeMap, exportType, null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error(e.getMessage());
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 插入 basicExportStatusTime表
|
|
|
|
|
*
|
|
|
|
|