diff --git a/src/main/java/com/glxp/api/constant/BasicExportStatusTimeEnum.java b/src/main/java/com/glxp/api/constant/BasicExportStatusTimeEnum.java index 351079102..434b8ffe5 100644 --- a/src/main/java/com/glxp/api/constant/BasicExportStatusTimeEnum.java +++ b/src/main/java/com/glxp/api/constant/BasicExportStatusTimeEnum.java @@ -131,6 +131,11 @@ public enum BasicExportStatusTimeEnum { DEV_REPAIR("device_repair","设备维修单数据"), PRODUCE_BUSINESS_DATA("thr_manufacturer", "生产企业数据"), + /** + * 药品关联信息任务同步 + */ + DRUG_DATA_TASK("drug_data_task", "药品关联信息任"), + ; @EnumValue private String key; diff --git a/src/main/java/com/glxp/api/constant/BasicExportTypeEnum.java b/src/main/java/com/glxp/api/constant/BasicExportTypeEnum.java index 581bc2799..1b301f29e 100644 --- a/src/main/java/com/glxp/api/constant/BasicExportTypeEnum.java +++ b/src/main/java/com/glxp/api/constant/BasicExportTypeEnum.java @@ -64,6 +64,11 @@ public enum BasicExportTypeEnum { DEVICE_UPKEEP_DATA("device__upkeep", "设备保养数据"), PRODUCE_BUSINESS_DATA("thr_manufacturer", "生产企业数据"), + + /** + * 药品关联信息任务同步 + */ + DRUG_DATA_TASK("drug_data_task", "药品关联信息任"), // // NEW_ALL_ORDER("all_order", "出入库扫码单据"), // ALL_BUS_ORDER("all_bus_order", "业务单据"), diff --git a/src/main/java/com/glxp/api/entity/system/SyncDataSetEntity.java b/src/main/java/com/glxp/api/entity/system/SyncDataSetEntity.java index b0b38dab4..e6bc67e84 100644 --- a/src/main/java/com/glxp/api/entity/system/SyncDataSetEntity.java +++ b/src/main/java/com/glxp/api/entity/system/SyncDataSetEntity.java @@ -83,4 +83,9 @@ public class SyncDataSetEntity { private int deviceUpkeep;//保养单 private int produceBusiness;//生产企业 PRODUCE_BUSINESS_DATA + /** + * 设备任务 + */ + private int drugDataTask; + } diff --git a/src/main/java/com/glxp/api/res/sync/SpsSyncDrugDataTaskResponse.java b/src/main/java/com/glxp/api/res/sync/SpsSyncDrugDataTaskResponse.java new file mode 100644 index 000000000..d44b33d2e --- /dev/null +++ b/src/main/java/com/glxp/api/res/sync/SpsSyncDrugDataTaskResponse.java @@ -0,0 +1,16 @@ +package com.glxp.api.res.sync; + +import com.glxp.api.entity.collect.RelCodeBatch; +import com.glxp.api.entity.collect.RelCodeDetail; +import lombok.Data; + +import java.util.List; + +@Data +public class SpsSyncDrugDataTaskResponse extends BaseSyncResponse { + + public List relCodeBatches; + + public List relCodeDetails; + +} diff --git a/src/main/java/com/glxp/api/service/sync/HeartService.java b/src/main/java/com/glxp/api/service/sync/HeartService.java index 5b29286ab..b15ee12ac 100644 --- a/src/main/java/com/glxp/api/service/sync/HeartService.java +++ b/src/main/java/com/glxp/api/service/sync/HeartService.java @@ -3,8 +3,12 @@ package com.glxp.api.service.sync; import cn.hutool.core.bean.BeanUtil; import com.glxp.api.dao.dev.*; import com.glxp.api.dao.thrsys.ThrManufacturerMapper; +import com.glxp.api.entity.collect.RelCodeBatch; +import com.glxp.api.entity.collect.RelCodeDetail; import com.glxp.api.entity.dev.*; import com.glxp.api.res.inv.InnerOrderPrintResponse; +import com.glxp.api.service.collect.RelCodeBatchService; +import com.glxp.api.service.collect.RelCodeDetailService; import com.glxp.api.service.dev.*; import org.junit.Test; import org.springframework.beans.BeanUtils; @@ -69,6 +73,7 @@ import java.io.IOException; import java.time.LocalDateTime; 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; @@ -305,6 +310,12 @@ public class HeartService { // if (needExec(info.getDeviceTask())) { //默认开启 uploadData(exportType, taskId, x -> x.getDeviceTaskData(info, taskId, now, syncTime)); +// } + break; + case DRUG_DATA_TASK: +// if (needExec(info.getDeviceTask())) { + //默认开启 + uploadData(exportType, taskId, x -> x.getDrugDataTaskData(info, taskId, now, syncTime)); // } break; } @@ -1108,6 +1119,10 @@ public class HeartService { @Resource DeviceInspectTaskService deviceInspectTaskService; @Resource + RelCodeDetailService relCodeDetailService; + @Resource + RelCodeBatchService relCodeBatchService; + @Resource DeviceInspectTaskDetailService deviceInspectTaskDetailService; @Value("${file_path}") private String filePath; @@ -1164,6 +1179,50 @@ public class HeartService { } return dataResponse; } + /** + * @param info + * @param taskId + * @param now + * @param syncTime + * @return + */ + private SpsSyncDrugDataTaskResponse getDrugDataTaskData(SyncDataSetEntity info, String taskId, Date now, Date syncTime) { + SpsSyncDrugDataTaskResponse dataResponse = null; + Map syncTimeMap = new WeakHashMap<>(3); + syncTimeMap.put("isNew", true); + boolean ge = false; + if (syncTime != null) { + ge = true; + } + StringBuffer remark = new StringBuffer(); + if (needExec(info.getDrugDataTask())) { + Map map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.DRUG_DATA_TASK); + List 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 batchIds = relCodeBatches.stream().map(RelCodeBatch::getId).collect(Collectors.toList()); + List list = relCodeDetailService.list(Wrappers.lambdaQuery(RelCodeDetail.class) + .in(RelCodeDetail::getBatchIdFk,batchIds)); + dataResponse.setRelCodeDetails(list); + + remark.append("药品关联信息任务:").append(relCodeBatches.size()).append("条\n"); + } + } + if (dataResponse != null) { + dataResponse.setTaskId(taskId); + dataResponse.setType(BasicExportTypeEnum.DRUG_DATA_TASK.getRemark()); + dataResponse.setSyncRemark(remark.toString()); + } + return dataResponse; + } /**