Browse Source

fix: 修改试运行期间bug;

test-20240527
龚宝雄 8 months ago
parent
commit
b34294d53c
  1. 15
      nlsso-server/src/main/java/org/nl/common/utils/DateUtil.java
  2. 8
      nlsso-server/src/main/java/org/nl/wms/database/eas/dao/xml/EasOutInBillDetailMapper.xml
  3. 2
      nlsso-server/src/main/java/org/nl/wms/database/eas/dao/xml/EasOutInBillMapper.xml
  4. 3
      nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/EasOutInBillDetailServiceImpl.java
  5. 77
      nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/EasOutInBillServiceImpl.java
  6. 4
      nlsso-server/src/main/java/org/nl/wms/schedule/EasBillSchedule.java

15
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); 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) public static Date getDate(String date)
throws ParseException { 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"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date format = dateFormat.parse(date); return dateFormat.parse(date);
return format;
} }
public static Date getDates(String date,String dateParseFormat ) public static Date getDates(String date,String dateParseFormat )
throws ParseException { throws ParseException {
SimpleDateFormat dateFormat = new SimpleDateFormat(dateParseFormat); SimpleDateFormat dateFormat = new SimpleDateFormat(dateParseFormat);

8
nlsso-server/src/main/java/org/nl/wms/database/eas/dao/xml/EasOutInBillDetailMapper.xml

@ -7,7 +7,7 @@
FROM FROM
EAS_NOBLE.V_UC_OUTINBILL EAS_NOBLE.V_UC_OUTINBILL
WHERE DJZT = '提交' 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> </select>
<select id="selectSrmPageWithInventory" resultType="org.nl.wms.database.eas.dao.EasOutInBillDetail"> <select id="selectSrmPageWithInventory" resultType="org.nl.wms.database.eas.dao.EasOutInBillDetail">
SELECT SELECT
@ -19,7 +19,7 @@
DJZT = '未入库' DJZT = '未入库'
AND CJSJ >= DATE_SUB( AND CJSJ >= DATE_SUB(
CURDATE(), CURDATE(),
INTERVAL 15 DAY) INTERVAL 8 DAY)
</select> </select>
<select id="selectEasIds" resultType="org.nl.wms.database.eas.dao.EasOutInBillDetail"> <select id="selectEasIds" resultType="org.nl.wms.database.eas.dao.EasOutInBillDetail">
SELECT SELECT
@ -27,13 +27,13 @@
FROM FROM
EAS_NOBLE.V_UC_OUTINBILL EAS_NOBLE.V_UC_OUTINBILL
WHERE DJZT = '提交' WHERE DJZT = '提交'
AND TO_DATE(cjsj, 'YYYY-MM-DD') >= TRUNC(SYSDATE) - INTERVAL '15' DAY(3) AND TO_DATE(cjsj, 'YYYY-MM-DD') >= TRUNC(SYSDATE) - INTERVAL '8' DAY(3)
</select> </select>
<select id="selectSrmIds" resultType="org.nl.wms.database.eas.dao.EasOutInBillDetail"> <select id="selectSrmIds" resultType="org.nl.wms.database.eas.dao.EasOutInBillDetail">
SELECT SELECT
FLID,DJID FLID,DJID
FROM V_WMS_INBILL_THIRD FROM V_WMS_INBILL_THIRD
WHERE DJZT='未入库' AND CJSJ >= DATE_SUB(CURDATE(), INTERVAL 15 DAY) WHERE DJZT='未入库' AND CJSJ >= DATE_SUB(CURDATE(), INTERVAL 8 DAY)
</select> </select>
<select id="selectByConditions" resultType="org.nl.wms.database.eas.dao.InventoryInfo"> <select id="selectByConditions" resultType="org.nl.wms.database.eas.dao.InventoryInfo">
SELECT SELECT

2
nlsso-server/src/main/java/org/nl/wms/database/eas/dao/xml/EasOutInBillMapper.xml

@ -33,7 +33,7 @@
<select id="queryExistBills" resultType="org.nl.wms.database.eas.dao.EasOutInBillDetail"> <select id="queryExistBills" resultType="org.nl.wms.database.eas.dao.EasOutInBillDetail">
SELECT SELECT
DJID,FLID,XGSJ DJID,FLID,XGSJ,CJSJ,DJZT
FROM FROM
EAS_OUT_IN_BILL_DETAIL EAS_OUT_IN_BILL_DETAIL
</select> </select>

3
nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/EasOutInBillDetailServiceImpl.java

@ -202,7 +202,8 @@ public class EasOutInBillDetailServiceImpl extends ServiceImpl<EasOutInBillDetai
updateWrapper.eq("flid", r.getFlid()); updateWrapper.eq("flid", r.getFlid());
updateWrapper.set("czsl", r.getSl()); updateWrapper.set("czsl", r.getSl());
updateWrapper.set("sysl", 0); updateWrapper.set("sysl", 0);
updateWrapper.set("kwbm", r.getKwbm()); //库位无需扫码,填充默认库位
//updateWrapper.set("kwbm", r.getKwbm());
updateWrapper.set("update_id", SecurityUtils.getCurrentUserId()); updateWrapper.set("update_id", SecurityUtils.getCurrentUserId());
updateWrapper.set("update_name", SecurityUtils.getCurrentNickName()); updateWrapper.set("update_name", SecurityUtils.getCurrentNickName());
updateWrapper.set("update_time", DateUtil.format(DateUtil.beginOfDay(DateUtil.date()), "yyyy-MM-dd")); updateWrapper.set("update_time", DateUtil.format(DateUtil.beginOfDay(DateUtil.date()), "yyyy-MM-dd"));

77
nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/EasOutInBillServiceImpl.java

@ -34,7 +34,9 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.ParseException; import java.text.ParseException;
import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -176,23 +178,23 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
@Override @Override
public void insertOrUpdateBills(List<EasOutInBillDetail> easOutInBillDetails, List<EasOutInBillDetail> existingIds) { public void insertOrUpdateBills(List<EasOutInBillDetail> easOutInBillDetails, List<EasOutInBillDetail> existingIds) {
CompletableFuture.runAsync(() -> { // CompletableFuture.runAsync(() -> {
try { // try {
insertBills(easOutInBillDetails, existingIds); insertBills(easOutInBillDetails, existingIds);
} catch (Exception e) { // } catch (Exception e) {
log.error("异常信息:" + e); // log.error("异常信息:" + e);
} // }
}, pool); // }, pool);
CompletableFuture.runAsync(() -> { // CompletableFuture.runAsync(() -> {
try { // try {
updateBills(easOutInBillDetails, existingIds); updateBills(easOutInBillDetails, existingIds);
} catch (Exception e) { // } catch (Exception e) {
log.error("异常信息:" + e); // log.error("异常信息:" + e);
} // }
}, pool); // }, pool);
// CompletableFuture.runAsync(() -> { // CompletableFuture.runAsync(() -> {
// //todo 检查事务是否会失效 // //todo 检查事务是否会失效
// autoDeleteBill(easOutInBillDetails, existingIds); autoDeleteBill(easOutInBillDetails, existingIds);
// }, pool); // }, pool);
} }
@ -219,6 +221,8 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
//srm的未入库改为提交 //srm的未入库改为提交
bill.setDjzt("提交"); bill.setDjzt("提交");
bill.setYwrq(LocalDateTime.parse(bill.getYwrq(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")).toLocalDate().toString()); bill.setYwrq(LocalDateTime.parse(bill.getYwrq(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")).toLocalDate().toString());
bill.setCjsj(LocalDateTime.parse(bill.getCjsj(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")).toLocalDate().toString());
bill.setDjly("2");
} }
}) })
.collect(Collectors.toList()); .collect(Collectors.toList());
@ -254,9 +258,7 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
bill.setBtbz(detail.getBtbz()); bill.setBtbz(detail.getBtbz());
bill.setCksj(detail.getCksj()); bill.setCksj(detail.getCksj());
bill.setLlr(detail.getLlr()); bill.setLlr(detail.getLlr());
if (bill.getDjlx().equals("CGRKD")) { bill.setDjly(detail.getDjly());
bill.setDjly("2");
}
return bill; return bill;
}) })
.collect(Collectors.toList()); .collect(Collectors.toList());
@ -283,14 +285,13 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
} }
private void updateBills(List<EasOutInBillDetail> easOutInBillDetails, List<EasOutInBillDetail> existingIds) { private void updateBills(List<EasOutInBillDetail> easOutInBillDetails, List<EasOutInBillDetail> existingIds) {
Set<String> ids = existingIds.stream().map(EasOutInBillDetail::getFlid).collect(Collectors.toSet());
// 过滤出需要插入的新单据,并根据来源设置 ID // 过滤出需要插入的新单据,并根据来源设置 ID
List<EasOutInBillDetail> insertEasBills = easOutInBillDetails.stream() List<EasOutInBillDetail> updateEasBills = easOutInBillDetails.stream()
.filter(r -> r.getXgsj() != null) .filter(r -> r.getXgsj() != null)
.collect(Collectors.toList()); .collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(insertEasBills)) { if (CollectionUtils.isNotEmpty(updateEasBills)) {
//比较insertEasBills与existingIds的修改时间进行按需更新 //比较insertEasBills与existingIds的修改时间进行按需更新
for (EasOutInBillDetail entity : insertEasBills) { for (EasOutInBillDetail entity : updateEasBills) {
EasOutInBillDetail existing = existingIds.stream() EasOutInBillDetail existing = existingIds.stream()
.filter(e -> { .filter(e -> {
boolean isUpdate = false; boolean isUpdate = false;
@ -309,14 +310,11 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
.orElse(null); .orElse(null);
if (existing != null) { if (existing != null) {
EasOutInBillDetail updateEntity = new EasOutInBillDetail(); EasOutInBillDetail updateEntity = new EasOutInBillDetail();
updateEntity.setDjlx(entity.getDjlx()); updateEntity.setDjid(entity.getDjid());
updateEntity.setYwlx(entity.getYwlx()); updateEntity.setFlid(entity.getFlid());
updateEntity.setZzbm(entity.getZzbm());
updateEntity.setZzmc(entity.getZzmc());
updateEntity.setBmbm(entity.getBmbm());
updateEntity.setBmmc(entity.getBmmc()); updateEntity.setBmmc(entity.getBmmc());
updateEntity.setDjzt(entity.getDjzt()); updateEntity.setBmbm(entity.getBmbm());
updateEntity.setBtbz(entity.getBtbz()); updateEntity.setDjbh(entity.getDjbh());
updateEntity.setCjsj(entity.getCjsj()); updateEntity.setCjsj(entity.getCjsj());
updateEntity.setYwrq(entity.getYwrq()); updateEntity.setYwrq(entity.getYwrq());
updateEntity.setCjr(entity.getCjr()); updateEntity.setCjr(entity.getCjr());
@ -324,15 +322,24 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
updateEntity.setWlbm(entity.getWlbm()); updateEntity.setWlbm(entity.getWlbm());
updateEntity.setWlmc(entity.getWlmc()); updateEntity.setWlmc(entity.getWlmc());
updateEntity.setGgxh(entity.getGgxh()); updateEntity.setGgxh(entity.getGgxh());
updateEntity.setPc(entity.getPc());
updateEntity.setJldw(entity.getJldw());
updateEntity.setJbjldw(entity.getJbjldw());
updateEntity.setFzjldw(entity.getFzjldw());
updateEntity.setSl(entity.getSl()); updateEntity.setSl(entity.getSl());
updateEntity.setJbsl(entity.getJbsl());
updateEntity.setTjkwbm(entity.getTjkwbm());
updateEntity.setTjkwmc(entity.getTjkwmc());
updateEntity.setFzsl(entity.getFzsl());
updateEntity.setCkbm(entity.getCkbm()); updateEntity.setCkbm(entity.getCkbm());
updateEntity.setCkmc(entity.getCkmc()); updateEntity.setCkmc(entity.getCkmc());
updateEntity.setKwbm(entity.getKwbm()); updateEntity.setKwbm(entity.getKwbm());
updateEntity.setKwmc(entity.getKwmc()); updateEntity.setKwmc(entity.getKwmc());
updateEntity.setFlbz(entity.getFlbz()); updateEntity.setFlbz(entity.getFlbz());
updateEntity.setCode(entity.getCode());
updateEntity.setCksj(entity.getCksj());
updateEntity.setLlr(entity.getLlr());
updateEntity.setTrackno(entity.getTrackno()); updateEntity.setTrackno(entity.getTrackno());
updateEntity.setPc(entity.getPc());
updateEntity.setWlmc(entity.getWlmc());
updateEntity.setXgsj(entity.getXgsj()); updateEntity.setXgsj(entity.getXgsj());
easOutInBillDetailMapper.update(updateEntity, new QueryWrapper<EasOutInBillDetail>().eq("flid", entity.getFlid())); easOutInBillDetailMapper.update(updateEntity, new QueryWrapper<EasOutInBillDetail>().eq("flid", entity.getFlid()));
} }
@ -348,6 +355,18 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void autoDeleteBill(List<EasOutInBillDetail> easOutInBillDetails, List<EasOutInBillDetail> existingIds) { public void autoDeleteBill(List<EasOutInBillDetail> easOutInBillDetails, List<EasOutInBillDetail> existingIds) {
try { 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字段的集合 // 获取easOutInBillDetails中flid字段的集合
Set<String> easFlidSet = easOutInBillDetails.stream() Set<String> easFlidSet = easOutInBillDetails.stream()
.map(EasOutInBillDetail::getFlid) .map(EasOutInBillDetail::getFlid)

4
nlsso-server/src/main/java/org/nl/wms/schedule/EasBillSchedule.java

@ -59,7 +59,7 @@ public class EasBillSchedule {
* eas单据数据同步 * eas单据数据同步
*/ */
@Async("taskExecutor") @Async("taskExecutor")
@Scheduled(cron = "0/60 * * * * *") @Scheduled(cron = "0/20 * * * * *")
public void getEasOutInBills() { public void getEasOutInBills() {
// 获取eas视图查询未提交的单据 // 获取eas视图查询未提交的单据
List<EasOutInBillDetail> easOutInBillDetails = easOutInBillDetailMapper.selectPageWithInventory(); List<EasOutInBillDetail> easOutInBillDetails = easOutInBillDetailMapper.selectPageWithInventory();
@ -70,8 +70,8 @@ public class EasBillSchedule {
easOutInBillDetails.addAll(srmOutInBillDetails); easOutInBillDetails.addAll(srmOutInBillDetails);
//查询已存在的单据 //查询已存在的单据
List<EasOutInBillDetail> existingIds = easOutInBillService.queryExistBills(); List<EasOutInBillDetail> existingIds = easOutInBillService.queryExistBills();
//查询已存在的未提交的单据
easOutInBillService.insertOrUpdateBills(easOutInBillDetails, existingIds); easOutInBillService.insertOrUpdateBills(easOutInBillDetails, existingIds);
//autoDeleteBill(easOutInBillDetails, existingIds);
} }
} }
} }

Loading…
Cancel
Save