diff --git a/src/main/java/com/glxp/api/service/inout/impl/IoOrderServiceImpl.java b/src/main/java/com/glxp/api/service/inout/impl/IoOrderServiceImpl.java index 428fc6ec..f2470cf4 100644 --- a/src/main/java/com/glxp/api/service/inout/impl/IoOrderServiceImpl.java +++ b/src/main/java/com/glxp/api/service/inout/impl/IoOrderServiceImpl.java @@ -8,6 +8,7 @@ import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONUtil; import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.github.pagehelper.PageHelper; import com.glxp.api.common.res.BaseResponse; import com.glxp.api.common.util.ResultVOUtils; @@ -140,7 +141,8 @@ public class IoOrderServiceImpl implements IoOrderService { @Override public List findByStatus(String action, Integer status, Date lastUpdateTime) { - return orderDao.selectList(new QueryWrapper().eq("action", action).eq("status", status).le(lastUpdateTime != null, "updateTime", lastUpdateTime)); + return orderDao.selectList(Wrappers.lambdaQuery(IoOrderEntity.class).eq(IoOrderEntity::getAction, action).eq(IoOrderEntity::getStatus, status) + .between(IoOrderEntity::getUpdateTime, lastUpdateTime, cn.hutool.core.date.DateUtil.date())); } 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 75dc6e39..8d62dbcb 100644 --- a/src/main/java/com/glxp/api/service/sync/SpsSyncDownloadService.java +++ b/src/main/java/com/glxp/api/service/sync/SpsSyncDownloadService.java @@ -286,20 +286,19 @@ public class SpsSyncDownloadService { StringBuffer remark = new StringBuffer(); Map syncTimeMap = new WeakHashMap<>(3); syncTimeMap.put("isNew", true); + boolean ge = false; + if (syncTime != null) { + ge = true; + } try { //确认有开启物资字典由外向内同步 if (needExec(info.getBasicProducts())) { - Map map; - if (syncTime == null) { - map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.BASIC_PRODUCTS, createFile); - } else { - map = syncTimeMap; - now = syncTime; - } + Map map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.BASIC_PRODUCTS, createFile); totalTimeMap.put(BasicExportStatusTimeEnum.BASIC_PRODUCTS, map); List hospTypeList = hospTypeService.list(Wrappers.lambdaQuery(BasicHospTypeEntity.class) - .le((boolean) map.get("isNew"), BasicHospTypeEntity::getUpdateTime, now) - .between(!(boolean) map.get("isNew"), BasicHospTypeEntity::getUpdateTime + .le(!ge && (boolean) map.get("isNew"), BasicHospTypeEntity::getUpdateTime, now) + .between(ge, BasicHospTypeEntity::getUpdateTime, syncTime, now) + .between(!ge && !(boolean) map.get("isNew"), BasicHospTypeEntity::getUpdateTime , map.get("oldDate"), now) ); if (CollectionUtil.isNotEmpty(hospTypeList)) { @@ -307,8 +306,9 @@ public class SpsSyncDownloadService { remark.append("物资字典分类信息:").append(hospTypeList.size()).append("条\n"); } List udiRelevanceList = udiRelevanceService.list(Wrappers.lambdaQuery(UdiRelevanceEntity.class) - .le((boolean) map.get("isNew"), UdiRelevanceEntity::getUpdateTime, now) - .between(!(boolean) map.get("isNew"), UdiRelevanceEntity::getUpdateTime + .le(!ge && (boolean) map.get("isNew"), UdiRelevanceEntity::getUpdateTime, now) + .between(ge, UdiRelevanceEntity::getUpdateTime, syncTime, now) + .between(!ge && !(boolean) map.get("isNew"), UdiRelevanceEntity::getUpdateTime , map.get("oldDate"), now) ); if (CollectionUtil.isNotEmpty(udiRelevanceList)) { @@ -316,8 +316,9 @@ public class SpsSyncDownloadService { remark.append("物资字典主表信息:").append(udiRelevanceList.size()).append("条\n"); } List productsList = basicProductsDao.selectList(Wrappers.lambdaQuery(BasicProductsEntity.class) - .le((boolean) map.get("isNew"), BasicProductsEntity::getUpdateTime, now) - .between(!(boolean) map.get("isNew"), BasicProductsEntity::getUpdateTime + .le(!ge && (boolean) map.get("isNew"), BasicProductsEntity::getUpdateTime, now) + .between(ge, BasicProductsEntity::getUpdateTime, syncTime, now) + .between(!ge && !(boolean) map.get("isNew"), BasicProductsEntity::getUpdateTime , map.get("oldDate"), now) ); if (CollectionUtil.isNotEmpty(productsList)) { @@ -325,8 +326,9 @@ public class SpsSyncDownloadService { jsonMap.put(BasicProductsEntity.class.getSimpleName(), productsList); } List relevanceList = relevanceService.list(Wrappers.lambdaQuery(CompanyProductRelevanceEntity.class) - .le((boolean) map.get("isNew"), CompanyProductRelevanceEntity::getUpdateTime, now) - .between(!(boolean) map.get("isNew"), CompanyProductRelevanceEntity::getUpdateTime + .le(!ge && (boolean) map.get("isNew"), CompanyProductRelevanceEntity::getUpdateTime, now) + .between(ge, CompanyProductRelevanceEntity::getUpdateTime, syncTime, now) + .between(!ge && !(boolean) map.get("isNew"), CompanyProductRelevanceEntity::getUpdateTime , map.get("oldDate"), now) ); if (CollectionUtil.isNotEmpty(relevanceList)) { @@ -336,17 +338,12 @@ public class SpsSyncDownloadService { } //确认有开启往来单位字典同步 if (needExec(info.getBasicCorp())) { - Map map; - if (syncTime == null) { - map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.BASIC_CORP, createFile); - } else { - map = syncTimeMap; - now = syncTime; - } + Map map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.BASIC_CORP, createFile); totalTimeMap.put(BasicExportStatusTimeEnum.BASIC_CORP, map); List corpList = corpService.list(Wrappers.lambdaQuery(BasicCorpEntity.class) - .le((boolean) map.get("isNew"), BasicCorpEntity::getUpdateTime, now) - .between(!(boolean) map.get("isNew"), BasicCorpEntity::getUpdateTime + .le(!ge && (boolean) map.get("isNew"), BasicCorpEntity::getUpdateTime, now) + .between(ge, BasicCorpEntity::getUpdateTime, syncTime, now) + .between(!ge && !(boolean) map.get("isNew"), BasicCorpEntity::getUpdateTime , map.get("oldDate"), now) ); if (CollectionUtil.isNotEmpty(corpList)) { @@ -357,18 +354,13 @@ public class SpsSyncDownloadService { //确认有开启首营资质同步 if (needExec(info.getSupCert())) { - Map map; - if (syncTime == null) { - map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.SUP_CERT, createFile); - } else { - map = syncTimeMap; - now = syncTime; - } + Map map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.SUP_CERT, createFile); totalTimeMap.put(BasicExportStatusTimeEnum.SUP_CERT, map); List supCertList = supCertService.list(Wrappers.lambdaQuery(SupCertEntity.class) - .le((boolean) map.get("isNew"), SupCertEntity::getUpdateTime, now) .eq(SupCertEntity::getAuditStatus, ConstantStatus.AUDIT_PASS) - .between(!(boolean) map.get("isNew"), SupCertEntity::getUpdateTime + .le(!ge && (boolean) map.get("isNew"), SupCertEntity::getUpdateTime, now) + .between(ge, SupCertEntity::getUpdateTime, syncTime, now) + .between(!ge && !(boolean) map.get("isNew"), SupCertEntity::getUpdateTime , map.get("oldDate"), now) ); if (CollectionUtil.isNotEmpty(supCertList)) { @@ -383,8 +375,9 @@ public class SpsSyncDownloadService { } } List supCertSetList = supCertSetService.list(Wrappers.lambdaQuery(SupCertSetEntity.class) - .le((boolean) map.get("isNew"), SupCertSetEntity::getUpdateTime, now) - .between(!(boolean) map.get("isNew"), SupCertSetEntity::getUpdateTime + .le(!ge && (boolean) map.get("isNew"), SupCertSetEntity::getUpdateTime, now) + .between(ge, SupCertSetEntity::getUpdateTime, syncTime, now) + .between(!ge && !(boolean) map.get("isNew"), SupCertSetEntity::getUpdateTime , map.get("oldDate"), now) ); if (CollectionUtil.isNotEmpty(supCertSetList)) { @@ -392,9 +385,10 @@ public class SpsSyncDownloadService { jsonMap.put(SupCertSetEntity.class.getSimpleName(), supCertSetList); } List supCompanyList = supCompanyService.list(Wrappers.lambdaQuery(SupCompanyEntity.class) - .le((boolean) map.get("isNew"), SupCompanyEntity::getUpdateTime, now) .eq(SupCompanyEntity::getAuditStatus, ConstantStatus.AUDIT_PASS) - .between(!(boolean) map.get("isNew"), SupCompanyEntity::getUpdateTime + .le(!ge && (boolean) map.get("isNew"), SupCompanyEntity::getUpdateTime, now) + .between(ge, SupCompanyEntity::getUpdateTime, syncTime, now) + .between(!ge && !(boolean) map.get("isNew"), SupCompanyEntity::getUpdateTime , map.get("oldDate"), now) ); if (CollectionUtil.isNotEmpty(supCompanyList)) { @@ -403,7 +397,9 @@ public class SpsSyncDownloadService { } List supManufacturerList = supManufacturerService.list(Wrappers.lambdaQuery(SupManufacturerEntity.class) .eq(SupManufacturerEntity::getAuditStatus, ConstantStatus.AUDIT_PASS) - .between(!(boolean) map.get("isNew"), SupManufacturerEntity::getUpdateTime + .le(!ge && (boolean) map.get("isNew"), SupManufacturerEntity::getUpdateTime, now) + .between(ge, SupManufacturerEntity::getUpdateTime, syncTime, now) + .between(!ge && !(boolean) map.get("isNew"), SupManufacturerEntity::getUpdateTime , map.get("oldDate"), now) ); if (CollectionUtil.isNotEmpty(supManufacturerList)) { @@ -412,8 +408,9 @@ public class SpsSyncDownloadService { } List supProductList = supProductService.list(Wrappers.lambdaQuery(SupProductEntity.class) .eq(SupProductEntity::getAuditStatus, ConstantStatus.AUDIT_PASS) - .le((boolean) map.get("isNew"), SupProductEntity::getUpdateTime, now) - .between(!(boolean) map.get("isNew"), SupProductEntity::getUpdateTime + .le(!ge && (boolean) map.get("isNew"), SupProductEntity::getUpdateTime, now) + .between(ge, SupProductEntity::getUpdateTime, syncTime, now) + .between(!ge && !(boolean) map.get("isNew"), SupProductEntity::getUpdateTime , map.get("oldDate"), now) ); if (CollectionUtil.isNotEmpty(supProductList)) { @@ -479,20 +476,19 @@ public class SpsSyncDownloadService { Map> totalTimeMap = new WeakHashMap<>(10); Map syncTimeMap = new WeakHashMap<>(3); syncTimeMap.put("isNew", true); + boolean ge = false; + if (syncTime != null) { + ge = true; + } try { //确认有开启物资字典由外向内同步 if (info.getUdiCodeLost() == 2) { - Map map; - if (syncTime == null) { - map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.IO_CODE_LOST, createFile); - } else { - map = syncTimeMap; - now = syncTime; - } + Map map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.IO_CODE_LOST, createFile); totalTimeMap.put(BasicExportStatusTimeEnum.IO_CODE_LOST, map); List ioCodeLostList = ioCodeLostService.list(Wrappers.lambdaQuery(IoCodeLostEntity.class) - .le((boolean) map.get("isNew"), IoCodeLostEntity::getUpdateTime, now) - .between(!(boolean) map.get("isNew"), IoCodeLostEntity::getUpdateTime + .le(!ge && (boolean) map.get("isNew"), IoCodeLostEntity::getUpdateTime, now) + .between(ge, IoCodeLostEntity::getUpdateTime, syncTime, now) + .between(!ge && !(boolean) map.get("isNew"), IoCodeLostEntity::getUpdateTime , map.get("oldDate"), now) ); if (CollectionUtil.isNotEmpty(ioCodeLostList)) { @@ -502,17 +498,12 @@ public class SpsSyncDownloadService { } //确认有开启udi关联关系同步 if (info.getUdiCodeRel() == 2) { - Map map; - if (syncTime == null) { - map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.IO_CODE_REL, createFile); - } else { - map = syncTimeMap; - now = syncTime; - } + Map map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.IO_CODE_REL, createFile); totalTimeMap.put(BasicExportStatusTimeEnum.IO_CODE_REL, map); List ioCodeRelList = ioCodeRelService.list(Wrappers.lambdaQuery(IoCodeRelEntity.class) - .le((boolean) map.get("isNew"), IoCodeRelEntity::getUpdateTime, now) - .between(!(boolean) map.get("isNew"), IoCodeRelEntity::getUpdateTime + .le(!ge && (boolean) map.get("isNew"), IoCodeRelEntity::getUpdateTime, now) + .between(ge, IoCodeRelEntity::getUpdateTime, syncTime, now) + .between(!ge && !(boolean) map.get("isNew"), IoCodeRelEntity::getUpdateTime , map.get("oldDate"), now) ); if (CollectionUtil.isNotEmpty(ioCodeRelList)) { @@ -525,8 +516,9 @@ public class SpsSyncDownloadService { Map map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.ORDER_INVOICE, createFile); totalTimeMap.put(BasicExportStatusTimeEnum.ORDER_INVOICE, map); List orderInvoiceEntities = orderInvoiceService.list(Wrappers.lambdaQuery(IoOrderInvoiceEntity.class) - .le((boolean) map.get("isNew"), IoOrderInvoiceEntity::getUpdateTime, now) - .between(!(boolean) map.get("isNew"), IoOrderInvoiceEntity::getUpdateTime + .le(!ge && (boolean) map.get("isNew"), IoOrderInvoiceEntity::getUpdateTime, now) + .between(ge, IoOrderInvoiceEntity::getUpdateTime, syncTime, now) + .between(!ge && !(boolean) map.get("isNew"), IoOrderInvoiceEntity::getUpdateTime , map.get("oldDate"), now) ); if (CollectionUtil.isNotEmpty(orderInvoiceEntities)) { @@ -600,20 +592,19 @@ public class SpsSyncDownloadService { Map> totalTimeMap = new WeakHashMap<>(10); Map syncTimeMap = new WeakHashMap<>(3); syncTimeMap.put("isNew", true); + boolean ge = false; + if (syncTime != null) { + ge = true; + } try { //确认有开启业务单据类型同步 if (needExec(info.getTypeBus())) { - Map map; - if (syncTime == null) { - map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.BASIC_BUSSINESS_TYPE, createFile); - } else { - map = syncTimeMap; - now = syncTime; - } + Map map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.BASIC_BUSSINESS_TYPE, createFile); totalTimeMap.put(BasicExportStatusTimeEnum.BASIC_BUSSINESS_TYPE, map); List bussinessTypeEntities = bussinessTypeService.list(Wrappers.lambdaQuery(BasicBussinessTypeEntity.class) - .le((boolean) map.get("isNew"), BasicBussinessTypeEntity::getUpdateTime, now) - .between(!(boolean) map.get("isNew"), BasicBussinessTypeEntity::getUpdateTime + .le(!ge && (boolean) map.get("isNew"), BasicBussinessTypeEntity::getUpdateTime, now) + .between(ge, BasicBussinessTypeEntity::getUpdateTime, syncTime, now) + .between(!ge && !(boolean) map.get("isNew"), BasicBussinessTypeEntity::getUpdateTime , map.get("oldDate"), now) ); if (CollectionUtil.isNotEmpty(bussinessTypeEntities)) { @@ -623,17 +614,12 @@ public class SpsSyncDownloadService { } //确认有开启扫码单据类型同步 if (needExec(info.getTypeScan())) { - Map map; - if (syncTime == null) { - map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.BASIC_BUSTYPE_CHANGE, createFile); - } else { - map = syncTimeMap; - now = syncTime; - } + Map map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.BASIC_BUSTYPE_CHANGE, createFile); totalTimeMap.put(BasicExportStatusTimeEnum.BASIC_BUSTYPE_CHANGE, map); List busTypeChangeEntities = busTypeChangeService.list(Wrappers.lambdaQuery(BasicBusTypeChangeEntity.class) - .le((boolean) map.get("isNew"), BasicBusTypeChangeEntity::getUpdateTime, now) - .between(!(boolean) map.get("isNew"), BasicBusTypeChangeEntity::getUpdateTime + .le(!ge && (boolean) map.get("isNew"), BasicBusTypeChangeEntity::getUpdateTime, now) + .between(ge, BasicBusTypeChangeEntity::getUpdateTime, syncTime, now) + .between(!ge && !(boolean) map.get("isNew"), BasicBusTypeChangeEntity::getUpdateTime , map.get("oldDate"), now) ); if (CollectionUtil.isNotEmpty(busTypeChangeEntities)) { @@ -643,17 +629,12 @@ public class SpsSyncDownloadService { } //确认有开启第三方单据类型同步 if (needExec(info.getTypeThird())) { - Map map; - if (syncTime == null) { - map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.THR_BUSTYPE_ORIGIN, createFile); - } else { - map = syncTimeMap; - now = syncTime; - } + Map map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.THR_BUSTYPE_ORIGIN, createFile); totalTimeMap.put(BasicExportStatusTimeEnum.THR_BUSTYPE_ORIGIN, map); List thrBusTypeOriginEntities = thrBusTypeOriginService.list(Wrappers.lambdaQuery(ThrBusTypeOriginEntity.class) - .le((boolean) map.get("isNew"), ThrBusTypeOriginEntity::getUpdateTime, now) - .between(!(boolean) map.get("isNew"), ThrBusTypeOriginEntity::getUpdateTime + .le(!ge && (boolean) map.get("isNew"), ThrBusTypeOriginEntity::getUpdateTime, now) + .between(ge, ThrBusTypeOriginEntity::getUpdateTime, syncTime, now) + .between(!ge && !(boolean) map.get("isNew"), ThrBusTypeOriginEntity::getUpdateTime , map.get("oldDate"), now) ); if (CollectionUtil.isNotEmpty(thrBusTypeOriginEntities)) { @@ -719,12 +700,12 @@ public class SpsSyncDownloadService { BasicExportStatusTimeEntity timeInfo = basicExportTimeService.getOne(Wrappers.lambdaQuery(BasicExportStatusTimeEntity.class) .eq(BasicExportStatusTimeEntity::getKey, exportStatusTimeEnum.getKey())); if (timeInfo == null) { - timeInfo = BasicExportStatusTimeEntity.builder() - .key(exportStatusTimeEnum.getKey()) - .lastUpdateTime(DateUtil.formatDateTime(date)) - .remark(exportStatusTimeEnum.getRemark()) - .build(); if (createFile) { + timeInfo = BasicExportStatusTimeEntity.builder() + .key(exportStatusTimeEnum.getKey()) + .lastUpdateTime(DateUtil.formatDateTime(date)) + .remark(exportStatusTimeEnum.getRemark()) + .build(); basicExportTimeService.save(timeInfo); } } else {