fix: 修改试运行期间bug;
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package org.nl.wms.database.eas.service.impl;
|
package org.nl.wms.database.eas.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
@@ -18,6 +19,7 @@ import org.nl.wms.database.eas.service.IeasOutInBillDetailService;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.nl.wms.database.eas.service.IeasOutInBillService;
|
import org.nl.wms.database.eas.service.IeasOutInBillService;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
@@ -44,7 +46,6 @@ import java.util.stream.Collectors;
|
|||||||
public class EasOutInBillDetailServiceImpl extends ServiceImpl<EasOutInBillDetailMapper, EasOutInBillDetail> implements IeasOutInBillDetailService {
|
public class EasOutInBillDetailServiceImpl extends ServiceImpl<EasOutInBillDetailMapper, EasOutInBillDetail> implements IeasOutInBillDetailService {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private IeasOutInBillService ieasOutInBillService;
|
private IeasOutInBillService ieasOutInBillService;
|
||||||
|
|
||||||
@@ -70,31 +71,31 @@ public class EasOutInBillDetailServiceImpl extends ServiceImpl<EasOutInBillDetai
|
|||||||
List<InventoryInfo> matchedInventory = inventoryInfoList.stream()
|
List<InventoryInfo> matchedInventory = inventoryInfoList.stream()
|
||||||
.filter(inventory -> {
|
.filter(inventory -> {
|
||||||
boolean isMatched = true;
|
boolean isMatched = true;
|
||||||
//去向部门
|
//去向部门
|
||||||
if (bill.getZzbm() != null && !bill.getZzbm().isEmpty()) {
|
if (bill.getZzbm() != null && !bill.getZzbm().isEmpty()) {
|
||||||
isMatched = Objects.equals(inventory.getZzbm(), bill.getZzbm());
|
isMatched = Objects.equals(inventory.getZzbm(), bill.getZzbm());
|
||||||
}
|
}
|
||||||
//仓库编码
|
//仓库编码
|
||||||
if (bill.getCkbm() != null && !bill.getCkbm().isEmpty()) {
|
if (bill.getCkbm() != null && !bill.getCkbm().isEmpty()) {
|
||||||
isMatched = Objects.equals(inventory.getCkbm(), bill.getCkbm());
|
isMatched = Objects.equals(inventory.getCkbm(), bill.getCkbm());
|
||||||
}
|
}
|
||||||
//库位编码
|
//库位编码
|
||||||
if (bill.getTjkwbm() != null && !bill.getTjkwbm().isEmpty()) {
|
if (bill.getTjkwbm() != null && !bill.getTjkwbm().isEmpty()) {
|
||||||
isMatched = Objects.equals(inventory.getTjkwbm(), bill.getTjkwbm());
|
isMatched = Objects.equals(inventory.getTjkwbm(), bill.getTjkwbm());
|
||||||
}
|
}
|
||||||
|
|
||||||
//物料编码
|
//物料编码
|
||||||
if (bill.getWlbm() != null && !bill.getWlbm().isEmpty()) {
|
if (bill.getWlbm() != null && !bill.getWlbm().isEmpty()) {
|
||||||
isMatched = Objects.equals(inventory.getWlbm(), bill.getWlbm());
|
isMatched = Objects.equals(inventory.getWlbm(), bill.getWlbm());
|
||||||
}
|
}
|
||||||
// 批次
|
// 批次
|
||||||
if (bill.getPc() != null && !bill.getPc().isEmpty()) {
|
if (bill.getPc() != null && !bill.getPc().isEmpty()) {
|
||||||
isMatched = Objects.equals(inventory.getPc(), bill.getPc());
|
isMatched = Objects.equals(inventory.getPc(), bill.getPc());
|
||||||
}
|
}
|
||||||
// 跟踪号
|
// 跟踪号
|
||||||
if (bill.getTrackno() != null && !bill.getTrackno().isEmpty()) {
|
if (bill.getTrackno() != null && !bill.getTrackno().isEmpty()) {
|
||||||
isMatched = Objects.equals(inventory.getTrackno(), bill.getTrackno());
|
isMatched = Objects.equals(inventory.getTrackno(), bill.getTrackno());
|
||||||
}
|
}
|
||||||
return isMatched;
|
return isMatched;
|
||||||
})
|
})
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
@@ -189,28 +190,32 @@ public class EasOutInBillDetailServiceImpl extends ServiceImpl<EasOutInBillDetai
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void update(List<EasOutInBillDetailVO> entityList) {
|
public void update(List<EasOutInBillDetailVO> entityList) {
|
||||||
if (CollectionUtils.isNotEmpty(entityList)) {
|
if (CollectionUtils.isNotEmpty(entityList)) {
|
||||||
|
Set<String> ids = entityList.stream().map(EasOutInBillDetailVO::getFlid).collect(Collectors.toSet());
|
||||||
List<EasOutInBillDetailVO> entityLists = entityList.stream().filter(r -> StringUtils.isNotEmpty(r.getKwbm())).collect(Collectors.toList());
|
List<EasOutInBillDetailVO> entityLists = entityList.stream().filter(r -> StringUtils.isNotEmpty(r.getKwbm())).collect(Collectors.toList());
|
||||||
Set<String> ids = entityLists.stream().map(EasOutInBillDetailVO::getFlid).collect(Collectors.toSet());
|
if (entityLists.size() > 1 || ids.size() > 1) {
|
||||||
//需求变更为不可多次审核,否则EAS库存不准确
|
//分录单据多选
|
||||||
//ieasOutInBillService.audit(ids,false);
|
if (ids.size() > 1) {
|
||||||
//单据明细为相同规格相同物料批量出入库
|
if (entityList.stream().anyMatch(r -> StringUtils.isEmpty(r.getKwbm()))) {
|
||||||
if (ids.size() == entityList.size() && ids.size() > 1) {
|
throw new BadRequestException("请检查是否有单据未分配库位");
|
||||||
entityList.forEach(r -> {
|
}
|
||||||
UpdateWrapper<EasOutInBillDetail> updateWrapper = new UpdateWrapper<>();
|
entityList.forEach(r -> {
|
||||||
//批量待审核
|
UpdateWrapper<EasOutInBillDetail> updateWrapper = new UpdateWrapper<>();
|
||||||
updateWrapper.set("djzt", "2");
|
//待审核状态
|
||||||
updateWrapper.eq("flid", r.getFlid());
|
updateWrapper.set("djzt", "1");
|
||||||
updateWrapper.set("czsl", r.getSl());
|
updateWrapper.eq("flid", r.getFlid());
|
||||||
updateWrapper.set("sysl", 0);
|
updateWrapper.set("czsl", r.getSl());
|
||||||
//库位无需扫码,填充默认库位
|
updateWrapper.set("sysl", 0);
|
||||||
//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"));
|
||||||
easOutInBillDetailMapper.update(null, updateWrapper);
|
easOutInBillDetailMapper.update(null, updateWrapper);
|
||||||
//ieasOutInBillService.audit(ids,false);
|
});
|
||||||
});
|
} else {
|
||||||
|
//todo 一个分录物料对应多个库位逻辑
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
//单个分录物料操作
|
||||||
boolean isValid = entityList.stream()
|
boolean isValid = entityList.stream()
|
||||||
.filter(r -> StringUtils.isNotEmpty(r.getKwbm()))
|
.filter(r -> StringUtils.isNotEmpty(r.getKwbm()))
|
||||||
.map(EasOutInBillDetailVO::getSysl)
|
.map(EasOutInBillDetailVO::getSysl)
|
||||||
@@ -229,8 +234,8 @@ public class EasOutInBillDetailServiceImpl extends ServiceImpl<EasOutInBillDetai
|
|||||||
throw new BadRequestException("请检查库位和数量信息");
|
throw new BadRequestException("请检查库位和数量信息");
|
||||||
}
|
}
|
||||||
UpdateWrapper<EasOutInBillDetail> updateWrapper = new UpdateWrapper<>();
|
UpdateWrapper<EasOutInBillDetail> updateWrapper = new UpdateWrapper<>();
|
||||||
if(sysl.compareTo(BigDecimal.ZERO)==0) {
|
//出入库操作数量达到目标数量
|
||||||
//待审核
|
if (sysl.compareTo(BigDecimal.ZERO) == 0) {
|
||||||
updateWrapper.set("djzt", "1");
|
updateWrapper.set("djzt", "1");
|
||||||
}
|
}
|
||||||
updateWrapper.eq("flid", entityList.get(0).getFlid());
|
updateWrapper.eq("flid", entityList.get(0).getFlid());
|
||||||
@@ -242,7 +247,24 @@ public class EasOutInBillDetailServiceImpl extends ServiceImpl<EasOutInBillDetai
|
|||||||
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"));
|
||||||
easOutInBillDetailMapper.update(null, updateWrapper);
|
easOutInBillDetailMapper.update(null, updateWrapper);
|
||||||
}
|
}
|
||||||
|
auditBills(entityList.get(0).getDjid());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自动审核
|
||||||
|
*/
|
||||||
|
@Async("taskExecutor")
|
||||||
|
public void auditBills(String id) {
|
||||||
|
List<EasOutInBillDetail> easOutInBillDetailList = easOutInBillDetailMapper
|
||||||
|
.selectList(new LambdaQueryWrapper<EasOutInBillDetail>().eq(EasOutInBillDetail::getDjid, id));
|
||||||
|
if (!easOutInBillDetailList.isEmpty()) {
|
||||||
|
List<EasOutInBillDetail> detailList = easOutInBillDetailList.stream().filter(r -> "1".equals(r.getDjzt())).collect(Collectors.toList());
|
||||||
|
if (detailList.size() == easOutInBillDetailList.size()) {
|
||||||
|
List<String> ids = easOutInBillDetailList.stream().map(EasOutInBillDetail::getFlid).collect(Collectors.toList());
|
||||||
|
//单据审核
|
||||||
|
ieasOutInBillService.audit(ids, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -500,14 +500,11 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
|
|||||||
}, pool);
|
}, pool);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//eas单据推送
|
easBills.addAll(srmBills);
|
||||||
|
//单个单据推送
|
||||||
if (CollectionUtils.isNotEmpty(easBills)) {
|
if (CollectionUtils.isNotEmpty(easBills)) {
|
||||||
asyncAuditBill(easBills.get(0));
|
asyncAuditBill(easBills.get(0));
|
||||||
}
|
}
|
||||||
//srm单据推送
|
|
||||||
if (CollectionUtils.isNotEmpty(srmBills)) {
|
|
||||||
asyncAuditBill(srmBills.get(0));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -516,7 +513,7 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
|
|||||||
*/
|
*/
|
||||||
public void asyncAuditBill(EasOutInBillDto bill) {
|
public void asyncAuditBill(EasOutInBillDto bill) {
|
||||||
try {
|
try {
|
||||||
if (bill.getDjly().equals("1")) {
|
if ("1".equals(bill.getDjly())) {
|
||||||
MsgDto msgDto;
|
MsgDto msgDto;
|
||||||
EasData easData = new EasData();
|
EasData easData = new EasData();
|
||||||
easData.setData(bill);
|
easData.setData(bill);
|
||||||
|
|||||||
@@ -77,6 +77,48 @@ public class EasBillSchedule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定时清空单据
|
||||||
|
*/
|
||||||
|
@Async("taskExecutor")
|
||||||
|
@Scheduled(cron = "0/86400 * * * * *")
|
||||||
|
public void autoDeleteTask() {
|
||||||
|
LocalDate threeMonthsAgo = LocalDate.now().minusMonths(3);
|
||||||
|
String days = threeMonthsAgo.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||||
|
//查询三个月前的数据
|
||||||
|
LambdaQueryWrapper<EasOutInBill> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.lt(EasOutInBill::getCjsj, days);
|
||||||
|
List<EasOutInBill> oldBills = easOutInBillService.list(queryWrapper);
|
||||||
|
if (CollectionUtils.isNotEmpty(oldBills)) {
|
||||||
|
Set<String> ids = oldBills.stream().map(EasOutInBill::getDjid).collect(Collectors.toSet());
|
||||||
|
if (CollectionUtils.isNotEmpty(ids)) {
|
||||||
|
easOutInBillDetailMapper.deleteDetail(ids);
|
||||||
|
}
|
||||||
|
easOutInBillDetailMapper.deleteInfo(days);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 首页信息推送
|
||||||
|
*/
|
||||||
|
@Async("taskExecutor")
|
||||||
|
//@Scheduled(cron = "0/4 * * * * *")
|
||||||
|
public void sendHomeInfoTask() {
|
||||||
|
//StopWatch stopWatch = new StopWatch();
|
||||||
|
//stopWatch.start();
|
||||||
|
CopyOnWriteArraySet<SendHomeWebSocketServer> webSocketSet =
|
||||||
|
SendHomeWebSocketServer.getWebSocketSet();
|
||||||
|
if (webSocketSet.size() > 0) {
|
||||||
|
webSocketSet.forEach(c -> {
|
||||||
|
c.sendDataToClient(easOutInBillService.getBillsCount());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//stopWatch.stop();
|
||||||
|
//System.out.println("1task-首页及头部信息推送-sendHomeInfoTask-花费时间----------------------------------------------------------------****************************************************************= totalTime = " + stopWatch.getTotalTimeMillis());
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* eas单据自动审核
|
* eas单据自动审核
|
||||||
*/
|
*/
|
||||||
@@ -132,52 +174,11 @@ public class EasBillSchedule {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 定时清空单据
|
|
||||||
*/
|
|
||||||
@Async("taskExecutor")
|
|
||||||
@Scheduled(cron = "0/86400 * * * * *")
|
|
||||||
public void autoDeleteTask() {
|
|
||||||
LocalDate threeMonthsAgo = LocalDate.now().minusMonths(3);
|
|
||||||
String days = threeMonthsAgo.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
||||||
//查询三个月前的数据
|
|
||||||
LambdaQueryWrapper<EasOutInBill> queryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
queryWrapper.lt(EasOutInBill::getCjsj, days);
|
|
||||||
List<EasOutInBill> oldBills = easOutInBillService.list(queryWrapper);
|
|
||||||
if (CollectionUtils.isNotEmpty(oldBills)) {
|
|
||||||
Set<String> ids = oldBills.stream().map(EasOutInBill::getDjid).collect(Collectors.toSet());
|
|
||||||
if (CollectionUtils.isNotEmpty(ids)) {
|
|
||||||
easOutInBillDetailMapper.deleteDetail(ids);
|
|
||||||
}
|
|
||||||
easOutInBillDetailMapper.deleteInfo(days);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 首页信息推送
|
|
||||||
*/
|
|
||||||
@Async("taskExecutor")
|
|
||||||
//@Scheduled(cron = "0/4 * * * * *")
|
|
||||||
public void sendHomeInfoTask() {
|
|
||||||
//StopWatch stopWatch = new StopWatch();
|
|
||||||
//stopWatch.start();
|
|
||||||
CopyOnWriteArraySet<SendHomeWebSocketServer> webSocketSet =
|
|
||||||
SendHomeWebSocketServer.getWebSocketSet();
|
|
||||||
if (webSocketSet.size() > 0) {
|
|
||||||
webSocketSet.forEach(c -> {
|
|
||||||
c.sendDataToClient(easOutInBillService.getBillsCount());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
//stopWatch.stop();
|
|
||||||
//System.out.println("1task-首页及头部信息推送-sendHomeInfoTask-花费时间----------------------------------------------------------------****************************************************************= totalTime = " + stopWatch.getTotalTimeMillis());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 定时删除源头已删除单据
|
* 定时删除源头已删除单据
|
||||||
*/
|
*/
|
||||||
@Async("taskExecutor")
|
@Async("taskExecutor")
|
||||||
|
//@Scheduled(cron = "0/180 * * * * *")
|
||||||
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
|
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
|
||||||
public void autoDeleteBill(List<EasOutInBillDetail> easOutInBillDetails, List<EasOutInBillDetail> existingIds) {
|
public void autoDeleteBill(List<EasOutInBillDetail> easOutInBillDetails, List<EasOutInBillDetail> existingIds) {
|
||||||
// 获取easOutInBillDetails中flid字段的集合
|
// 获取easOutInBillDetails中flid字段的集合
|
||||||
|
|||||||
Reference in New Issue
Block a user