|
@ -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) |
|
|