From 3c2812ee611a51c6486c89b0971e8b04efdd5885 Mon Sep 17 00:00:00 2001 From: anthonywj Date: Mon, 1 May 2023 15:02:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AD=E7=BB=A7=E5=90=8C=E6=AD=A5=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4=E5=A4=87=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/glxp/api/constant/Constant.java | 2 + .../com/glxp/api/constant/ConstantStatus.java | 4 +- .../auth/InvWarehouseController.java | 2 +- .../sync/SpsSyncDownloadController.java | 83 +++++++++++------ .../sync/SpsSyncExportStatusController.java | 2 +- .../glxp/api/res/sync/BaseSyncResponse.java | 1 + .../service/sync/SpsSyncDownloadService.java | 90 +++++++++++++------ .../mybatis/mapper/sync/BasicDownloadDao.xml | 4 + .../mybatis/mapper/sync/BasicExportDao.xml | 3 + 9 files changed, 131 insertions(+), 60 deletions(-) diff --git a/src/main/java/com/glxp/api/constant/Constant.java b/src/main/java/com/glxp/api/constant/Constant.java index 349e2309..a8298246 100644 --- a/src/main/java/com/glxp/api/constant/Constant.java +++ b/src/main/java/com/glxp/api/constant/Constant.java @@ -259,4 +259,6 @@ public class Constant { public static final String ORDER_ACTION_SUP_PREIN = "preInOrder"; + public static final String SYNC_REMARK = "syncRemark"; + } diff --git a/src/main/java/com/glxp/api/constant/ConstantStatus.java b/src/main/java/com/glxp/api/constant/ConstantStatus.java index cb15c4ac..517bf383 100644 --- a/src/main/java/com/glxp/api/constant/ConstantStatus.java +++ b/src/main/java/com/glxp/api/constant/ConstantStatus.java @@ -247,8 +247,8 @@ public class ConstantStatus { //自动下载DI数据 public static final String SYNC_DOWNLOAD_DI_PRODUCTS = "AutoDownloadDiProducts"; - public static final int SYNC_STATUS_SUCCESS = 1; //处理成功 - public static final int SYNC_STATUS_FAIL = 2; //处理失败 + public static final int SYNC_STATUS_SUCCESS = 2; //处理成功 + public static final int SYNC_STATUS_FAIL = 1; //处理失败 public static final int SYNC_STATUS_WAIT = 0; //等待处理 public static final int THIRD_ORDER_UPLOAD = 1; //业务单据上传至第三方 diff --git a/src/main/java/com/glxp/api/controller/auth/InvWarehouseController.java b/src/main/java/com/glxp/api/controller/auth/InvWarehouseController.java index 6ae0d8ed..b6a555e9 100644 --- a/src/main/java/com/glxp/api/controller/auth/InvWarehouseController.java +++ b/src/main/java/com/glxp/api/controller/auth/InvWarehouseController.java @@ -238,7 +238,7 @@ public class InvWarehouseController extends BaseController { } InvWarehouseEntity originEntity = invWarehouseService.findByInvSubByCode(invWarehouseEntity.getCode()); - if (!originEntity.getParentId().equals(invWarehouseEntity.getParentId()) || !originEntity.getParentCode().equals(invWarehouseEntity.getParentCode())) { + if (!originEntity.getParentId().equals(invWarehouseEntity.getParentId()) || (originEntity.getParentCode() != null && !originEntity.getParentCode().equals(invWarehouseEntity.getParentCode()))) { Integer userCount = warehouseUserService.countUserBySubInvCode(invWarehouseEntity.getCode()); if (userCount > 0) { return ResultVOUtils.error(500, "修改部门或上级仓库时,请先移除该仓库关联用户!"); diff --git a/src/main/java/com/glxp/api/controller/sync/SpsSyncDownloadController.java b/src/main/java/com/glxp/api/controller/sync/SpsSyncDownloadController.java index bda287de..2cf91d82 100644 --- a/src/main/java/com/glxp/api/controller/sync/SpsSyncDownloadController.java +++ b/src/main/java/com/glxp/api/controller/sync/SpsSyncDownloadController.java @@ -42,6 +42,7 @@ import com.glxp.api.service.sync.BasicExportService; import com.glxp.api.service.sync.SpsSyncDownloadService; import com.glxp.api.util.CustomUtil; import com.glxp.api.util.DateUtil; +import com.glxp.api.util.FileUtils; import com.glxp.api.util.JsonUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -113,16 +114,17 @@ public class SpsSyncDownloadController { @GetMapping("sps/sync/order") public BaseResponse getOrder(SpsSyncDataRequest spsSyncDataRequest) { BaseResponse baseResponse = spsSyncDownloadService.findOrder(spsSyncDataRequest); - BasicExportStatusEntity basicExportStatusEntity = basicExportService.findByData(ConstantStatus.SYNC_SCAN_ORDER, 0); + BasicExportStatusEntity basicExportStatusEntity = basicExportService.findByData(ConstantStatus.SYNC_SCAN_ORDER, 3); String logs = ""; if (basicExportStatusEntity != null) { - logs = logs + "单据:" + baseResponse.getData().getOrderEntities().size() + "条\n"; - if (CollUtil.isNotEmpty(baseResponse.getData().getOrderDetailBizEntities())) - logs = logs + "单据详情:" + baseResponse.getData().getOrderDetailBizEntities().size() + "条\n"; - if (CollUtil.isNotEmpty(baseResponse.getData().getCodeEntities())) - logs = logs + "单据条码信息:" + baseResponse.getData().getCodeEntities().size() + "条\n"; - - basicExportStatusEntity.setRemark(logs); + String fileFullPath = null; + try { + fileFullPath = writeFile(filePrefix, BasicProcessStatus.NEW_ALL_BUS_ORDER, JSONUtil.toJsonStr(baseResponse.getData())); + } catch (IOException e) { + e.printStackTrace(); + } + basicExportStatusEntity.setCacheFilePath(fileFullPath); + basicExportStatusEntity.setRemark(baseResponse.getData().getSyncRemark()); basicExportService.updateExportStatus(basicExportStatusEntity); SpsSyncOrderResponse spsSyncOrderResponse = baseResponse.getData(); spsSyncOrderResponse.setTaskId(basicExportStatusEntity.getId()); @@ -138,15 +140,15 @@ public class SpsSyncDownloadController { public BaseResponse getDiProducts(SpsSyncDataRequest spsSyncDataRequest) { BaseResponse baseResponse = spsSyncDownloadService.syncUdi(spsSyncDataRequest); - BasicExportStatusEntity basicExportStatusEntity = basicExportService.findByData(ConstantStatus.SYNC_DI_PRODUCTS, 0); + BasicExportStatusEntity basicExportStatusEntity = basicExportService.findByData(ConstantStatus.SYNC_DI_PRODUCTS, 3); String logs = ""; if (basicExportStatusEntity != null) { - if (CollUtil.isNotEmpty(baseResponse.getData().getProductInfoEntityList())) - logs = logs + "DI信息:" + baseResponse.getData().getProductInfoEntityList().size() + "条\n"; - if (CollUtil.isNotEmpty(baseResponse.getData().getUdiCompanyEntities())) - logs = logs + "医疗器械注册人:" + baseResponse.getData().getUdiCompanyEntities().size() + "条\n"; - basicExportStatusEntity.setRemark(logs); - basicExportService.updateExportStatus(basicExportStatusEntity); +// if (CollUtil.isNotEmpty(baseResponse.getData().getProductInfoEntityList())) +// logs = logs + "DI信息:" + baseResponse.getData().getProductInfoEntityList().size() + "条\n"; +// if (CollUtil.isNotEmpty(baseResponse.getData().getUdiCompanyEntities())) +// logs = logs + "医疗器械注册人:" + baseResponse.getData().getUdiCompanyEntities().size() + "条\n"; +// basicExportStatusEntity.setRemark(logs); +// basicExportService.updateExportStatus(basicExportStatusEntity); SpSyncUdiResponse spSyncUdiResponse = baseResponse.getData(); spSyncUdiResponse.setTaskId(basicExportStatusEntity.getId()); @@ -256,6 +258,7 @@ public class SpsSyncDownloadController { spsSyncBasicDataResponse.setSupCompanyList((List) map.get(SupCompanyEntity.class.getSimpleName())); spsSyncBasicDataResponse.setSupManufacturerList((List) map.get(SupManufacturerEntity.class.getSimpleName())); spsSyncBasicDataResponse.setSupProductList((List) map.get(SupProductEntity.class.getSimpleName())); + spsSyncBasicDataResponse.setSyncRemark(map.getStr(Constant.SYNC_REMARK)); } catch (FileNotFoundException e) { throw new RuntimeException("系统异常,未找到对应数据文件"); } catch (IOException e) { @@ -312,7 +315,7 @@ public class SpsSyncDownloadController { spsSyncOtherDataResponse.setTaskId(one.getId()); spsSyncOtherDataResponse.setIoCodeLostList((List) map.get(IoCodeLostEntity.class.getSimpleName())); spsSyncOtherDataResponse.setIoCodeRelList((List) map.get(IoCodeRelEntity.class.getSimpleName())); - + spsSyncOtherDataResponse.setSyncRemark(map.getStr(Constant.SYNC_REMARK)); } catch (FileNotFoundException e) { throw new RuntimeException("系统异常,未找到对应数据文件"); } catch (IOException e) { @@ -588,6 +591,19 @@ public class SpsSyncDownloadController { } } + @Resource + IoOrderDao orderDao; + @Resource + IoCodeTempDao codeMappert; + @Resource + IoOrderDetailBizDao orderDetailBizDao; + @Resource + IoOrderDetailCodeDao orderDetailCodeDao; + @Resource + IoOrderDetailResultDao orderDetailResultDao; + @Resource + IoOrderInvoiceMapper orderInvoiceMapper; + //接收中继服务、UDI管理系统上传单据 @AuthRuleAnnotation("sps/sync/order/upload") @PostMapping("/sps/sync/order/upload") @@ -602,23 +618,21 @@ public class SpsSyncDownloadController { basicDownloadStatusEntity.setScheduleType(1); basicDownloadService.insertDownloadStatus(basicDownloadStatusEntity); StringBuffer remark = new StringBuffer(); - SqlSession batchSession = sqlSessionFactory.openSession(ExecutorType.BATCH, TransactionIsolationLevel.READ_COMMITTED); if (CollUtil.isNotEmpty(syncDataResponse.getOrderEntities())) { try { List orderEntities = syncDataResponse.getOrderEntities(); - IoOrderDao mapper = batchSession.getMapper(IoOrderDao.class); for (IoOrderEntity orderEntity : orderEntities) { orderEntity.setUpdateTime(null); orderEntity.setFromType(ConstantStatus.FROM_UDISP); + orderEntity.setProcessStatus(ConstantStatus.ORDER_DEAL_POST); orderEntity.setStatus(ConstantStatus.ORDER_STATUS_PROCESS); IoOrderEntity temp = orderService.findById(orderEntity.getBillNo()); if (temp == null) { orderEntity.setId(null); - mapper.insert(orderEntity); + orderDao.insert(orderEntity); //更新码详情 if (CollUtil.isNotEmpty(syncDataResponse.getOrderDetailCodeEntities())) { - IoCodeTempDao codeMappert = batchSession.getMapper(IoCodeTempDao.class); List warehouseEntityList = syncDataResponse.getCodeEntities(); for (IoCodeEntity warehouseEntity : warehouseEntityList) { if (warehouseEntity.getOrderId().equals(orderEntity.getBillNo())) { @@ -632,10 +646,10 @@ public class SpsSyncDownloadController { //更新业务详情 if (CollUtil.isNotEmpty(syncDataResponse.getOrderDetailBizEntities())) { - IoOrderDetailBizDao orderDetailBizDao = batchSession.getMapper(IoOrderDetailBizDao.class); List orderDetailBizEntities = syncDataResponse.getOrderDetailBizEntities(); for (IoOrderDetailBizEntity bizEntity : orderDetailBizEntities) { if (bizEntity.getOrderIdFk().equals(orderEntity.getBillNo())) { + bizEntity.setId(null); orderDetailBizDao.insert(bizEntity); } } @@ -643,10 +657,10 @@ public class SpsSyncDownloadController { //更新码详情 if (CollUtil.isNotEmpty(syncDataResponse.getOrderDetailCodeEntities())) { - IoOrderDetailCodeDao orderDetailCodeDao = batchSession.getMapper(IoOrderDetailCodeDao.class); List orderDetailCodeEntities = syncDataResponse.getOrderDetailCodeEntities(); for (IoOrderDetailCodeEntity codeEntity : orderDetailCodeEntities) { if (codeEntity.getOrderIdFk().equals(orderEntity.getBillNo())) { + codeEntity.setId(null); orderDetailCodeDao.insert(codeEntity); } } @@ -655,10 +669,10 @@ public class SpsSyncDownloadController { //更新结果详情 if (CollUtil.isNotEmpty(syncDataResponse.getOrderDetailResultEntities())) { - IoOrderDetailResultDao orderDetailResultDao = batchSession.getMapper(IoOrderDetailResultDao.class); List orderDetailResultEntities = syncDataResponse.getOrderDetailResultEntities(); for (IoOrderDetailResultEntity detailResultEntity : orderDetailResultEntities) { if (detailResultEntity.getOrderIdFk().equals(orderEntity.getBillNo())) { + detailResultEntity.setId(null); orderDetailResultDao.insert(detailResultEntity); } } @@ -667,16 +681,15 @@ public class SpsSyncDownloadController { //更新发票信息 if (CollUtil.isNotEmpty(syncDataResponse.getOrderInvoiceEntities())) { - IoOrderInvoiceMapper orderInvoiceMapper = batchSession.getMapper(IoOrderInvoiceMapper.class); List orderInvoiceEntities = syncDataResponse.getOrderInvoiceEntities(); for (IoOrderInvoiceEntity orderInvoiceEntity : orderInvoiceEntities) { if (orderInvoiceEntity.getOrderIdFk().equals(orderEntity.getBillNo())) { + orderInvoiceEntity.setId(null); orderInvoiceMapper.insert(orderInvoiceEntity); } } } - batchSession.commit(); orderEntity = orderService.findByBillNo(orderEntity.getBillNo()); addInoutService.dealProcess(orderEntity); orderEntity = orderService.findByBillNo(orderEntity.getBillNo()); @@ -685,7 +698,6 @@ public class SpsSyncDownloadController { } } } - batchSession.commit(); String logs = ""; if (CollUtil.isNotEmpty(syncDataResponse.getOrderEntities())) @@ -703,7 +715,13 @@ public class SpsSyncDownloadController { e.printStackTrace(); } } - batchSession.close(); + String fileFullPath = null; + try { + fileFullPath = writeFile(filePrefix, BasicProcessStatus.NEW_ALL_BUS_ORDER, JSONUtil.toJsonStr(syncDataResponse)); + } catch (IOException e) { + e.printStackTrace(); + } + basicDownloadStatusEntity.setCacheFilePath(fileFullPath); basicDownloadStatusEntity.setUpdateTime(new Date()); basicDownloadStatusEntity.setEndTime(new Date()); basicDownloadStatusEntity.setRemark(remark.toString()); @@ -766,6 +784,15 @@ public class SpsSyncDownloadController { basicDownloadStatusEntity.setEndTime(new Date()); basicDownloadStatusEntity.setRemark(remark.toString()); basicDownloadStatusEntity.setStatus(ConstantStatus.SYNC_STATUS_SUCCESS); + + String fileFullPath = null; + try { + fileFullPath = writeFile(filePrefix, BasicProcessStatus.NEW_ALL_BUS_ORDER, JSONUtil.toJsonStr(spsSyncBusOrderResponse)); + } catch (IOException e) { + e.printStackTrace(); + } + basicDownloadStatusEntity.setCacheFilePath(fileFullPath); + basicDownloadService.updateDownloadStatus(basicDownloadStatusEntity); return ResultVOUtils.success("上传成功!"); @@ -1144,7 +1171,7 @@ public class SpsSyncDownloadController { } @GetMapping("/sps/sync/download/info/file") - public void downloadFile(HttpServletResponse response,String id){ + public void downloadFile(HttpServletResponse response, String id) { if (StrUtil.isBlank(id)) { throw new RuntimeException("缺少唯一标识"); } diff --git a/src/main/java/com/glxp/api/controller/sync/SpsSyncExportStatusController.java b/src/main/java/com/glxp/api/controller/sync/SpsSyncExportStatusController.java index 14dc7bbe..0b82e298 100644 --- a/src/main/java/com/glxp/api/controller/sync/SpsSyncExportStatusController.java +++ b/src/main/java/com/glxp/api/controller/sync/SpsSyncExportStatusController.java @@ -166,7 +166,7 @@ public class SpsSyncExportStatusController { .set(BasicExportStatusEntity::getStatus, BasicExportStatusEnum.COMPLETED.getCode()) .set(BasicExportStatusEntity::getEndTime, new Date()) .set(BasicExportStatusEntity::getUpdateTime, new Date()) - .set(BasicExportStatusEntity::getReceiveStatus, 1) + .set(BasicExportStatusEntity::getReceiveStatus, 0) .eq(BasicExportStatusEntity::getId, basicExportStatusEntity.getId()) .eq(BasicExportStatusEntity::getStatus, BasicExportStatusEnum.WAIT_SYNC.getCode()) ); diff --git a/src/main/java/com/glxp/api/res/sync/BaseSyncResponse.java b/src/main/java/com/glxp/api/res/sync/BaseSyncResponse.java index 3b10bc1c..2bef4a99 100644 --- a/src/main/java/com/glxp/api/res/sync/BaseSyncResponse.java +++ b/src/main/java/com/glxp/api/res/sync/BaseSyncResponse.java @@ -10,5 +10,6 @@ public class BaseSyncResponse { private String taskId; private List syncFiles; private String updateTime; + private String syncRemark; } diff --git a/src/main/java/com/glxp/api/service/sync/SpsSyncDownloadService.java b/src/main/java/com/glxp/api/service/sync/SpsSyncDownloadService.java index 5a948f45..f3a2acfb 100644 --- a/src/main/java/com/glxp/api/service/sync/SpsSyncDownloadService.java +++ b/src/main/java/com/glxp/api/service/sync/SpsSyncDownloadService.java @@ -47,7 +47,9 @@ 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; +import static com.glxp.api.constant.Constant.SYNC_REMARK; @Slf4j @Service @@ -88,10 +90,15 @@ public class SpsSyncDownloadService { log.info("创建单据同步任务"); //自动创建要求被下载已完成单据任务. // 1.判断是否同步任务已存在 - BasicExportStatusEntity basicExportStatusEntity1 = basicExportService.findByData(ConstantStatus.SYNC_SCAN_ORDER, 1); - if (basicExportStatusEntity1 == null) { + BasicExportStatusEntity basicExportStatusEntity1 = basicExportService.getOne(Wrappers.lambdaQuery(BasicExportStatusEntity.class) + .eq(BasicExportStatusEntity::getType, NEW_ALL_ORDER) + .orderByDesc(BasicExportStatusEntity::getStartTime) + .last("limit 1") + ); - BaseResponse baseResponse = findOrder(getRequest(ConstantStatus.SYNC_SCAN_ORDER)); + //首次任务or上次任务结束 + if (basicExportStatusEntity1 == null || BasicExportStatusEnum.COMPLETED.getCode().equals(basicExportStatusEntity1.getStatus())) { + BaseResponse baseResponse = findOrder(getRequest(ConstantStatus.SYNC_DOWNLOAD_SCAN_ORDER)); SpsSyncOrderResponse syncOrderResponse = baseResponse.getData(); // 2.查看是否有需要更新的数据 if (CollUtil.isNotEmpty(syncOrderResponse.getOrderEntities())) { @@ -99,9 +106,9 @@ public class SpsSyncDownloadService { 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.setStatus(BasicExportStatusEnum.WAIT_BUILT.getCode()); + orderStatusEntity.setStatus(BasicExportStatusEnum.WAIT_SYNC.getCode()); orderStatusEntity.setStartTime(new Date()); orderStatusEntity.setScheduleType(BasicProcessStatus.SCHEDULE_NORMAL); basicExportService.insertExportStatus(orderStatusEntity); @@ -131,7 +138,7 @@ public class SpsSyncDownloadService { basicExportStatusEntity.setType(NEW_ALL_UDIS); basicExportStatusEntity.setUpdateTime(new Date()); basicExportStatusEntity.setStartTime(new Date()); - basicExportStatusEntity.setStatus(BasicExportStatusEnum.WAIT_TRIGGERED.getCode()); + basicExportStatusEntity.setStatus(BasicExportStatusEnum.WAIT_SYNC.getCode()); basicExportStatusEntity.setScheduleType(BasicProcessStatus.SCHEDULE_NORMAL); basicExportService.insertExportStatus(basicExportStatusEntity); } @@ -311,9 +318,10 @@ public class SpsSyncDownloadService { protected boolean generateBasicDataFile(SyncDataSetResponse info, Date now, boolean createFile) { BasicExportTypeEnum exportType = BasicExportTypeEnum.BASIC_DATA; //文件数据 - Map jsonMap = new WeakHashMap<>(4); + Map jsonMap = new WeakHashMap<>(4); List syncFiles = new ArrayList<>(); Map> totalTimeMap = new WeakHashMap<>(10); + StringBuffer remark = new StringBuffer(); try { //确认有开启物资字典由外向内同步 if (needExec(info.getBasicProducts())) { @@ -326,6 +334,7 @@ public class SpsSyncDownloadService { ); if (CollectionUtil.isNotEmpty(hospTypeList)) { jsonMap.put(BasicHospTypeEntity.class.getSimpleName(), hospTypeList); + remark.append("物资字典分类信息:").append(hospTypeList.size()).append("条\n"); } List udiRelevanceList = udiRelevanceService.list(Wrappers.lambdaQuery(UdiRelevanceEntity.class) .le((boolean) map.get("isNew"), UdiRelevanceEntity::getUpdateTime, now) @@ -334,6 +343,7 @@ public class SpsSyncDownloadService { ); if (CollectionUtil.isNotEmpty(udiRelevanceList)) { jsonMap.put(UdiRelevanceEntity.class.getSimpleName(), udiRelevanceList); + remark.append("物资字典主表信息:").append(udiRelevanceList.size()).append("条\n"); } List productsList = basicProductsDao.selectList(Wrappers.lambdaQuery(BasicProductsEntity.class) .le((boolean) map.get("isNew"), BasicProductsEntity::getUpdateTime, now) @@ -341,6 +351,7 @@ public class SpsSyncDownloadService { , map.get("oldDate"), now) ); if (CollectionUtil.isNotEmpty(productsList)) { + remark.append("物资字典字表信息:").append(productsList.size()).append("条\n"); jsonMap.put(BasicProductsEntity.class.getSimpleName(), productsList); } List relevanceList = relevanceService.list(Wrappers.lambdaQuery(CompanyProductRelevanceEntity.class) @@ -349,6 +360,7 @@ public class SpsSyncDownloadService { , map.get("oldDate"), now) ); if (CollectionUtil.isNotEmpty(relevanceList)) { + remark.append("供应商关联物资字典表:").append(relevanceList.size()).append("条\n"); jsonMap.put(CompanyProductRelevanceEntity.class.getSimpleName(), relevanceList); } } @@ -362,6 +374,7 @@ public class SpsSyncDownloadService { , map.get("oldDate"), now) ); if (CollectionUtil.isNotEmpty(corpList)) { + remark.append("往来单位字典信息:").append(corpList.size()).append("条\n"); jsonMap.put(BasicCorpEntity.class.getSimpleName(), corpList); } } @@ -393,6 +406,7 @@ public class SpsSyncDownloadService { , map.get("oldDate"), now) ); if (CollectionUtil.isNotEmpty(supCertSetList)) { + remark.append("资质填报设置信息:").append(supCertSetList.size()).append("条\n"); jsonMap.put(SupCertSetEntity.class.getSimpleName(), supCertSetList); } List supCompanyList = supCompanyService.list(Wrappers.lambdaQuery(SupCompanyEntity.class) @@ -402,6 +416,7 @@ public class SpsSyncDownloadService { , map.get("oldDate"), now) ); if (CollectionUtil.isNotEmpty(supCompanyList)) { + remark.append("供应商资质信息:").append(supCompanyList.size()).append("条\n"); jsonMap.put(SupCompanyEntity.class.getSimpleName(), supCompanyList); } List supManufacturerList = supManufacturerService.list(Wrappers.lambdaQuery(SupManufacturerEntity.class) @@ -410,6 +425,7 @@ public class SpsSyncDownloadService { , map.get("oldDate"), now) ); if (CollectionUtil.isNotEmpty(supManufacturerList)) { + remark.append("生产企业资质信息:").append(supManufacturerList.size()).append("条\n"); jsonMap.put(SupManufacturerEntity.class.getSimpleName(), supManufacturerList); } List supProductList = supProductService.list(Wrappers.lambdaQuery(SupProductEntity.class) @@ -419,25 +435,27 @@ public class SpsSyncDownloadService { , map.get("oldDate"), now) ); if (CollectionUtil.isNotEmpty(supProductList)) { + remark.append("配送产品资质信息:").append(supProductList.size()).append("条\n"); jsonMap.put(SupProductEntity.class.getSimpleName(), supProductList); } } if (jsonMap.size() > 0) { + jsonMap.put(SYNC_REMARK, remark.toString()); if (!createFile) { return true; } try { String fileFullPath = writeFile(filePath, exportType.getRemark(), JsonUtils.toJsonString(jsonMap)); //计算总数 - int total = 0; - for (List l : jsonMap.values()) { - total += l.size(); - } +// int total = 0; +// for (List l : jsonMap.values()) { +// total += l.size(); +// } try { //修改任务数据 - boolean update = updateExportStatus(exportType, fileFullPath, total); + boolean update = updateExportStatus(exportType, fileFullPath, remark.toString()); } catch (Exception e) { // 异常回滚 this.exportTimeRollback(totalTimeMap, exportType, fileFullPath); @@ -471,9 +489,10 @@ public class SpsSyncDownloadService { * @return 是否有数据 true/false 有新数据/无新数据 */ protected boolean generateOtherDataFile(SyncDataSetResponse info, Date now, boolean createFile) { + StringBuffer remark = new StringBuffer(); BasicExportTypeEnum exportType = BasicExportTypeEnum.OTHER_DATA; //文件数据 - Map jsonMap = new WeakHashMap<>(4); + Map jsonMap = new WeakHashMap<>(4); Map> totalTimeMap = new WeakHashMap<>(10); try { //确认有开启物资字典由外向内同步 @@ -486,6 +505,7 @@ public class SpsSyncDownloadService { , map.get("oldDate"), now) ); if (CollectionUtil.isNotEmpty(ioCodeLostList)) { + remark.append("UDI缺失码:").append(ioCodeLostList.size()).append("条\n"); jsonMap.put(BasicExportStatusTimeEntity.class.getSimpleName(), ioCodeLostList); } } @@ -499,25 +519,27 @@ public class SpsSyncDownloadService { , map.get("oldDate"), now) ); if (CollectionUtil.isNotEmpty(ioCodeRelList)) { + remark.append("UDI码关联关系:").append(ioCodeRelList.size()).append("条\n"); jsonMap.put(IoCodeRelEntity.class.getSimpleName(), ioCodeRelList); } } if (jsonMap.size() > 0) { + jsonMap.put(SYNC_REMARK, remark.toString()); if (!createFile) { return true; } try { String fileFullPath = writeFile(filePath, exportType.getRemark(), JsonUtils.toJsonString(jsonMap)); //计算总数 - int total = 0; - for (List l : jsonMap.values()) { - total += l.size(); - } +// int total = 0; +// for (List l : jsonMap.values()) { +// total += l.size(); +// } try { //修改任务数据 - boolean update = updateExportStatus(exportType, fileFullPath, total); + boolean update = updateExportStatus(exportType, fileFullPath, remark.toString()); } catch (Exception e) { // 异常回滚 this.exportTimeRollback(totalTimeMap, exportType, fileFullPath); @@ -551,9 +573,10 @@ public class SpsSyncDownloadService { * @return 是否有数据 true/false 有新数据/无新数据 */ protected boolean generateDocumentTypeDataFile(SyncDataSetResponse info, Date now, boolean createFile) { + StringBuffer remark = new StringBuffer(); BasicExportTypeEnum exportType = BasicExportTypeEnum.DOCUMENT_TYPE_DATA; //文件数据 - Map jsonMap = new WeakHashMap<>(4); + Map jsonMap = new WeakHashMap<>(4); Map> totalTimeMap = new WeakHashMap<>(10); try { //确认有开启业务单据类型同步 @@ -566,6 +589,7 @@ public class SpsSyncDownloadService { , map.get("oldDate"), now) ); if (CollectionUtil.isNotEmpty(bussinessTypeEntities)) { + remark.append("扫码单据类型:").append(bussinessTypeEntities.size()).append("条\n"); jsonMap.put(BasicBussinessTypeEntity.class.getSimpleName(), bussinessTypeEntities); } } @@ -579,6 +603,7 @@ public class SpsSyncDownloadService { , map.get("oldDate"), now) ); if (CollectionUtil.isNotEmpty(busTypeChangeEntities)) { + remark.append("业务单据类型:").append(busTypeChangeEntities.size()).append("条\n"); jsonMap.put(BasicBusTypeChangeEntity.class.getSimpleName(), busTypeChangeEntities); } } @@ -592,25 +617,27 @@ public class SpsSyncDownloadService { , map.get("oldDate"), now) ); if (CollectionUtil.isNotEmpty(thrBusTypeOriginEntities)) { + remark.append("第三方单据类型:").append(thrBusTypeOriginEntities.size()).append("条\n"); jsonMap.put(ThrBusTypeOriginEntity.class.getSimpleName(), thrBusTypeOriginEntities); } } if (jsonMap.size() > 0) { + jsonMap.put(SYNC_REMARK, remark.toString()); if (!createFile) { return true; } try { String fileFullPath = writeFile(filePath, exportType.getRemark(), JsonUtils.toJsonString(jsonMap)); //计算总数 - int total = 0; - for (List l : jsonMap.values()) { - total += l.size(); - } +// int total = 0; +// for (List l : jsonMap.values()) { +// total += l.size(); +// } try { //修改任务数据 - boolean update = updateExportStatus(exportType, fileFullPath, total); + boolean update = updateExportStatus(exportType, fileFullPath, remark.toString()); } catch (Exception e) { // 异常回滚 this.exportTimeRollback(totalTimeMap, exportType, fileFullPath); @@ -686,15 +713,14 @@ public class SpsSyncDownloadService { * * @param exportType 任务类型 * @param fileFullPath 文件地址 - * @param total 总条数 * @return 更新结果 true/false */ - private boolean updateExportStatus(BasicExportTypeEnum exportType, String fileFullPath, Integer total) { + private boolean updateExportStatus(BasicExportTypeEnum exportType, String fileFullPath, String remark) { return basicExportService.update(Wrappers.lambdaUpdate(BasicExportStatusEntity.class) .set(BasicExportStatusEntity::getStatus, BasicExportStatusEnum.WAIT_SYNC.getCode()) .set(BasicExportStatusEntity::getUpdateTime, new Date()) .set(BasicExportStatusEntity::getCacheFilePath, fileFullPath) - .set(total != null, BasicExportStatusEntity::getRemark, String.format("%s: %s条", exportType.getRemark(), total)) + .set(BasicExportStatusEntity::getRemark, remark) .eq(BasicExportStatusEntity::getType, exportType.getRemark()) .eq(BasicExportStatusEntity::getStatus, BasicExportStatusEnum.WAIT_BUILT.getCode()) .isNull(BasicExportStatusEntity::getCacheFilePath) @@ -831,11 +857,19 @@ public class SpsSyncDownloadService { orderInvoiceEntities.addAll(invoiceEntities); - } } } + + String logs = ""; + logs = logs + "扫码单据信息:" + orderEntities.size() + "条\n"; + logs = logs + "单据业务详情信息:" + orderDetailBizEntities.size() + "条\n"; + logs = logs + "单据扫码详情信息:" + orderDetailCodeEntities.size() + "条\n"; + logs = logs + "单据校验结果信息:" + orderDetailResultEntities.size() + "条\n"; + logs = logs + "发票信息:" + orderInvoiceEntities.size() + "条\n"; + logs = logs + "扫码信息:" + codeEntities.size() + "条\n"; + syncOrderResponse.setSyncRemark(logs); syncOrderResponse.setSyncFiles(syncFiles); syncOrderResponse.setCodeEntities(codeEntities); syncOrderResponse.setOrderDetailBizEntities(orderDetailBizEntities); diff --git a/src/main/resources/mybatis/mapper/sync/BasicDownloadDao.xml b/src/main/resources/mybatis/mapper/sync/BasicDownloadDao.xml index 4541d96f..b5eed47a 100644 --- a/src/main/resources/mybatis/mapper/sync/BasicDownloadDao.xml +++ b/src/main/resources/mybatis/mapper/sync/BasicDownloadDao.xml @@ -73,6 +73,10 @@ remark=#{remark}, + + cacheFilePath=#{cacheFilePath}, + + WHERE id = #{id} diff --git a/src/main/resources/mybatis/mapper/sync/BasicExportDao.xml b/src/main/resources/mybatis/mapper/sync/BasicExportDao.xml index 7b4d86a1..da08b1d1 100644 --- a/src/main/resources/mybatis/mapper/sync/BasicExportDao.xml +++ b/src/main/resources/mybatis/mapper/sync/BasicExportDao.xml @@ -81,6 +81,9 @@ receiveStatus=#{receiveStatus}, + + cacheFilePath=#{cacheFilePath}, + WHERE id = #{id}