From b34294d53c9628e801465d9d68cf478de35e5e5a Mon Sep 17 00:00:00 2001 From: baoge <751575283@qq.com> Date: Mon, 13 May 2024 14:41:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E8=AF=95=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E6=9C=9F=E9=97=B4bug=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/nl/common/utils/DateUtil.java | 15 +++- .../eas/dao/xml/EasOutInBillDetailMapper.xml | 8 +- .../eas/dao/xml/EasOutInBillMapper.xml | 2 +- .../impl/EasOutInBillDetailServiceImpl.java | 3 +- .../service/impl/EasOutInBillServiceImpl.java | 81 ++++++++++++------- .../org/nl/wms/schedule/EasBillSchedule.java | 4 +- 6 files changed, 72 insertions(+), 41 deletions(-) diff --git a/nlsso-server/src/main/java/org/nl/common/utils/DateUtil.java b/nlsso-server/src/main/java/org/nl/common/utils/DateUtil.java index 7fbfcfa..cfdc596 100644 --- a/nlsso-server/src/main/java/org/nl/common/utils/DateUtil.java +++ b/nlsso-server/src/main/java/org/nl/common/utils/DateUtil.java @@ -446,13 +446,24 @@ public class DateUtil extends org.apache.commons.lang3.time.DateUtils { return dateTime.format(DFY_MD); } + /** + * date '2024/05/05 08:44:54' + * type 1 yyyy/MM/dd HH:mm:ss,2 yyyy-MM-dd HH:mm:ss + */ public static Date getDate(String date) throws ParseException { + SimpleDateFormat dateFormat = new SimpleDateFormat(date.contains("-")?"yyyy-MM-dd HH:mm:ss":"yyyy/MM/dd HH:mm:ss"); + return dateFormat.parse(date); + } + + public static Date getDateFormat(String date) + throws ParseException { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - Date format = dateFormat.parse(date); - return format; + return dateFormat.parse(date); } + + public static Date getDates(String date,String dateParseFormat ) throws ParseException { SimpleDateFormat dateFormat = new SimpleDateFormat(dateParseFormat); diff --git a/nlsso-server/src/main/java/org/nl/wms/database/eas/dao/xml/EasOutInBillDetailMapper.xml b/nlsso-server/src/main/java/org/nl/wms/database/eas/dao/xml/EasOutInBillDetailMapper.xml index e7aed95..7a9a6f7 100644 --- a/nlsso-server/src/main/java/org/nl/wms/database/eas/dao/xml/EasOutInBillDetailMapper.xml +++ b/nlsso-server/src/main/java/org/nl/wms/database/eas/dao/xml/EasOutInBillDetailMapper.xml @@ -7,7 +7,7 @@ FROM EAS_NOBLE.V_UC_OUTINBILL WHERE DJZT = '提交' - AND TO_DATE(cjsj, 'YYYY-MM-DD HH24:MI:SS') >= TRUNC(SYSDATE) - INTERVAL '15' DAY(3) + AND TO_DATE(cjsj, 'YYYY-MM-DD HH24:MI:SS') >= TRUNC(SYSDATE) - INTERVAL '8' DAY(3) SELECT - DJID,FLID,XGSJ + DJID,FLID,XGSJ,CJSJ,DJZT FROM EAS_OUT_IN_BILL_DETAIL diff --git a/nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/EasOutInBillDetailServiceImpl.java b/nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/EasOutInBillDetailServiceImpl.java index 0ac0632..3df97c7 100644 --- a/nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/EasOutInBillDetailServiceImpl.java +++ b/nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/EasOutInBillDetailServiceImpl.java @@ -202,7 +202,8 @@ public class EasOutInBillDetailServiceImpl extends ServiceImpl easOutInBillDetails, List existingIds) { - CompletableFuture.runAsync(() -> { - try { - insertBills(easOutInBillDetails, existingIds); - } catch (Exception e) { - log.error("异常信息:" + e); - } - }, pool); - CompletableFuture.runAsync(() -> { - try { - updateBills(easOutInBillDetails, existingIds); - } catch (Exception e) { - log.error("异常信息:" + e); - } - }, pool); +// CompletableFuture.runAsync(() -> { +// try { + insertBills(easOutInBillDetails, existingIds); +// } catch (Exception e) { +// log.error("异常信息:" + e); +// } +// }, pool); +// CompletableFuture.runAsync(() -> { +// try { + updateBills(easOutInBillDetails, existingIds); +// } catch (Exception e) { +// log.error("异常信息:" + e); +// } +// }, pool); // CompletableFuture.runAsync(() -> { // //todo 检查事务是否会失效 -// autoDeleteBill(easOutInBillDetails, existingIds); + autoDeleteBill(easOutInBillDetails, existingIds); // }, pool); } @@ -219,6 +221,8 @@ public class EasOutInBillServiceImpl extends ServiceImpl easOutInBillDetails, List existingIds) { - Set ids = existingIds.stream().map(EasOutInBillDetail::getFlid).collect(Collectors.toSet()); // 过滤出需要插入的新单据,并根据来源设置 ID - List insertEasBills = easOutInBillDetails.stream() + List updateEasBills = easOutInBillDetails.stream() .filter(r -> r.getXgsj() != null) .collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(insertEasBills)) { + if (CollectionUtils.isNotEmpty(updateEasBills)) { //比较insertEasBills与existingIds的修改时间进行按需更新 - for (EasOutInBillDetail entity : insertEasBills) { + for (EasOutInBillDetail entity : updateEasBills) { EasOutInBillDetail existing = existingIds.stream() .filter(e -> { boolean isUpdate = false; @@ -309,14 +310,11 @@ public class EasOutInBillServiceImpl extends ServiceImpl().eq("flid", entity.getFlid())); } @@ -348,6 +355,18 @@ public class EasOutInBillServiceImpl extends ServiceImpl easOutInBillDetails, List existingIds) { try { + // 获取距离今天8天前的日期 + LocalDate eightDaysAgo = LocalDate.now().minusDays(8); + existingIds = existingIds.stream() + .filter(e -> "提交".equals(e.getDjzt())||"未入库".equals(e.getDjzt())) + .filter(e -> { + try { + return org.nl.common.utils.DateUtil.getDateFormat(e.getCjsj()).toInstant().atZone(ZoneId.systemDefault()).toLocalDate().isAfter(eightDaysAgo); + } catch (ParseException ex) { + throw new RuntimeException(ex); + } + }) + .collect(Collectors.toList()); // 获取easOutInBillDetails中flid字段的集合 Set easFlidSet = easOutInBillDetails.stream() .map(EasOutInBillDetail::getFlid) diff --git a/nlsso-server/src/main/java/org/nl/wms/schedule/EasBillSchedule.java b/nlsso-server/src/main/java/org/nl/wms/schedule/EasBillSchedule.java index b293ec6..186a363 100644 --- a/nlsso-server/src/main/java/org/nl/wms/schedule/EasBillSchedule.java +++ b/nlsso-server/src/main/java/org/nl/wms/schedule/EasBillSchedule.java @@ -59,7 +59,7 @@ public class EasBillSchedule { * eas单据数据同步 */ @Async("taskExecutor") - @Scheduled(cron = "0/60 * * * * *") + @Scheduled(cron = "0/20 * * * * *") public void getEasOutInBills() { // 获取eas视图查询未提交的单据 List easOutInBillDetails = easOutInBillDetailMapper.selectPageWithInventory(); @@ -70,8 +70,8 @@ public class EasBillSchedule { easOutInBillDetails.addAll(srmOutInBillDetails); //查询已存在的单据 List existingIds = easOutInBillService.queryExistBills(); + //查询已存在的未提交的单据 easOutInBillService.insertOrUpdateBills(easOutInBillDetails, existingIds); - //autoDeleteBill(easOutInBillDetails, existingIds); } } }