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. 81
      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);
}
/**
* 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);

8
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>
<select id="selectSrmPageWithInventory" resultType="org.nl.wms.database.eas.dao.EasOutInBillDetail">
SELECT
@ -19,7 +19,7 @@
DJZT = '未入库'
AND CJSJ >= DATE_SUB(
CURDATE(),
INTERVAL 15 DAY)
INTERVAL 8 DAY)
</select>
<select id="selectEasIds" resultType="org.nl.wms.database.eas.dao.EasOutInBillDetail">
SELECT
@ -27,13 +27,13 @@
FROM
EAS_NOBLE.V_UC_OUTINBILL
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 id="selectSrmIds" resultType="org.nl.wms.database.eas.dao.EasOutInBillDetail">
SELECT
FLID,DJID
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 id="selectByConditions" resultType="org.nl.wms.database.eas.dao.InventoryInfo">
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
DJID,FLID,XGSJ
DJID,FLID,XGSJ,CJSJ,DJZT
FROM
EAS_OUT_IN_BILL_DETAIL
</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.set("czsl", r.getSl());
updateWrapper.set("sysl", 0);
updateWrapper.set("kwbm", r.getKwbm());
//库位无需扫码,填充默认库位
//updateWrapper.set("kwbm", r.getKwbm());
updateWrapper.set("update_id", SecurityUtils.getCurrentUserId());
updateWrapper.set("update_name", SecurityUtils.getCurrentNickName());
updateWrapper.set("update_time", DateUtil.format(DateUtil.beginOfDay(DateUtil.date()), "yyyy-MM-dd"));

81
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 java.math.BigDecimal;
import java.text.ParseException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.CompletableFuture;
@ -176,23 +178,23 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
@Override
public void insertOrUpdateBills(List<EasOutInBillDetail> easOutInBillDetails, List<EasOutInBillDetail> 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<EasOutInBillMapper, Eas
//srm的未入库改为提交
bill.setDjzt("提交");
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());
@ -254,9 +258,7 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
bill.setBtbz(detail.getBtbz());
bill.setCksj(detail.getCksj());
bill.setLlr(detail.getLlr());
if (bill.getDjlx().equals("CGRKD")) {
bill.setDjly("2");
}
bill.setDjly(detail.getDjly());
return bill;
})
.collect(Collectors.toList());
@ -283,14 +285,13 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
}
private void updateBills(List<EasOutInBillDetail> easOutInBillDetails, List<EasOutInBillDetail> existingIds) {
Set<String> ids = existingIds.stream().map(EasOutInBillDetail::getFlid).collect(Collectors.toSet());
// 过滤出需要插入的新单据,并根据来源设置 ID
List<EasOutInBillDetail> insertEasBills = easOutInBillDetails.stream()
List<EasOutInBillDetail> 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<EasOutInBillMapper, Eas
.orElse(null);
if (existing != null) {
EasOutInBillDetail updateEntity = new EasOutInBillDetail();
updateEntity.setDjlx(entity.getDjlx());
updateEntity.setYwlx(entity.getYwlx());
updateEntity.setZzbm(entity.getZzbm());
updateEntity.setZzmc(entity.getZzmc());
updateEntity.setBmbm(entity.getBmbm());
updateEntity.setDjid(entity.getDjid());
updateEntity.setFlid(entity.getFlid());
updateEntity.setBmmc(entity.getBmmc());
updateEntity.setDjzt(entity.getDjzt());
updateEntity.setBtbz(entity.getBtbz());
updateEntity.setBmbm(entity.getBmbm());
updateEntity.setDjbh(entity.getDjbh());
updateEntity.setCjsj(entity.getCjsj());
updateEntity.setYwrq(entity.getYwrq());
updateEntity.setCjr(entity.getCjr());
@ -324,15 +322,24 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
updateEntity.setWlbm(entity.getWlbm());
updateEntity.setWlmc(entity.getWlmc());
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.setJbsl(entity.getJbsl());
updateEntity.setTjkwbm(entity.getTjkwbm());
updateEntity.setTjkwmc(entity.getTjkwmc());
updateEntity.setFzsl(entity.getFzsl());
updateEntity.setCkbm(entity.getCkbm());
updateEntity.setCkmc(entity.getCkmc());
updateEntity.setKwbm(entity.getKwbm());
updateEntity.setKwmc(entity.getKwmc());
updateEntity.setFlbz(entity.getFlbz());
updateEntity.setCode(entity.getCode());
updateEntity.setCksj(entity.getCksj());
updateEntity.setLlr(entity.getLlr());
updateEntity.setTrackno(entity.getTrackno());
updateEntity.setPc(entity.getPc());
updateEntity.setWlmc(entity.getWlmc());
updateEntity.setXgsj(entity.getXgsj());
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)
public void autoDeleteBill(List<EasOutInBillDetail> easOutInBillDetails, List<EasOutInBillDetail> 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<String> easFlidSet = easOutInBillDetails.stream()
.map(EasOutInBillDetail::getFlid)

4
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<EasOutInBillDetail> easOutInBillDetails = easOutInBillDetailMapper.selectPageWithInventory();
@ -70,8 +70,8 @@ public class EasBillSchedule {
easOutInBillDetails.addAll(srmOutInBillDetails);
//查询已存在的单据
List<EasOutInBillDetail> existingIds = easOutInBillService.queryExistBills();
//查询已存在的未提交的单据
easOutInBillService.insertOrUpdateBills(easOutInBillDetails, existingIds);
//autoDeleteBill(easOutInBillDetails, existingIds);
}
}
}

Loading…
Cancel
Save