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 3df97c7..21c02c9 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 @@ -1,6 +1,7 @@ package org.nl.wms.database.eas.service.impl; 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.update.UpdateWrapper; 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.service.impl.ServiceImpl; import org.nl.wms.database.eas.service.IeasOutInBillService; +import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import cn.hutool.core.util.ObjectUtil; import org.springframework.beans.BeanUtils; @@ -44,7 +46,6 @@ import java.util.stream.Collectors; public class EasOutInBillDetailServiceImpl extends ServiceImpl implements IeasOutInBillDetailService { - @Resource private IeasOutInBillService ieasOutInBillService; @@ -70,31 +71,31 @@ public class EasOutInBillDetailServiceImpl extends ServiceImpl matchedInventory = inventoryInfoList.stream() .filter(inventory -> { boolean isMatched = true; - //去向部门 - if (bill.getZzbm() != null && !bill.getZzbm().isEmpty()) { - isMatched = Objects.equals(inventory.getZzbm(), bill.getZzbm()); - } - //仓库编码 - if (bill.getCkbm() != null && !bill.getCkbm().isEmpty()) { - isMatched = Objects.equals(inventory.getCkbm(), bill.getCkbm()); - } - //库位编码 - if (bill.getTjkwbm() != null && !bill.getTjkwbm().isEmpty()) { - isMatched = Objects.equals(inventory.getTjkwbm(), bill.getTjkwbm()); - } + //去向部门 + if (bill.getZzbm() != null && !bill.getZzbm().isEmpty()) { + isMatched = Objects.equals(inventory.getZzbm(), bill.getZzbm()); + } + //仓库编码 + if (bill.getCkbm() != null && !bill.getCkbm().isEmpty()) { + isMatched = Objects.equals(inventory.getCkbm(), bill.getCkbm()); + } + //库位编码 + if (bill.getTjkwbm() != null && !bill.getTjkwbm().isEmpty()) { + isMatched = Objects.equals(inventory.getTjkwbm(), bill.getTjkwbm()); + } - //物料编码 - if (bill.getWlbm() != null && !bill.getWlbm().isEmpty()) { - isMatched = Objects.equals(inventory.getWlbm(), bill.getWlbm()); - } - // 批次 - if (bill.getPc() != null && !bill.getPc().isEmpty()) { - isMatched = Objects.equals(inventory.getPc(), bill.getPc()); - } - // 跟踪号 - if (bill.getTrackno() != null && !bill.getTrackno().isEmpty()) { - isMatched = Objects.equals(inventory.getTrackno(), bill.getTrackno()); - } + //物料编码 + if (bill.getWlbm() != null && !bill.getWlbm().isEmpty()) { + isMatched = Objects.equals(inventory.getWlbm(), bill.getWlbm()); + } + // 批次 + if (bill.getPc() != null && !bill.getPc().isEmpty()) { + isMatched = Objects.equals(inventory.getPc(), bill.getPc()); + } + // 跟踪号 + if (bill.getTrackno() != null && !bill.getTrackno().isEmpty()) { + isMatched = Objects.equals(inventory.getTrackno(), bill.getTrackno()); + } return isMatched; }) .collect(Collectors.toList()); @@ -189,28 +190,32 @@ public class EasOutInBillDetailServiceImpl extends ServiceImpl entityList) { if (CollectionUtils.isNotEmpty(entityList)) { + Set ids = entityList.stream().map(EasOutInBillDetailVO::getFlid).collect(Collectors.toSet()); List entityLists = entityList.stream().filter(r -> StringUtils.isNotEmpty(r.getKwbm())).collect(Collectors.toList()); - Set ids = entityLists.stream().map(EasOutInBillDetailVO::getFlid).collect(Collectors.toSet()); - //需求变更为不可多次审核,否则EAS库存不准确 - //ieasOutInBillService.audit(ids,false); - //单据明细为相同规格相同物料批量出入库 - if (ids.size() == entityList.size() && ids.size() > 1) { - entityList.forEach(r -> { - UpdateWrapper updateWrapper = new UpdateWrapper<>(); - //批量待审核 - updateWrapper.set("djzt", "2"); - updateWrapper.eq("flid", r.getFlid()); - updateWrapper.set("czsl", r.getSl()); - updateWrapper.set("sysl", 0); - //库位无需扫码,填充默认库位 - //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")); - easOutInBillDetailMapper.update(null, updateWrapper); - //ieasOutInBillService.audit(ids,false); - }); + if (entityLists.size() > 1 || ids.size() > 1) { + //分录单据多选 + if (ids.size() > 1) { + if (entityList.stream().anyMatch(r -> StringUtils.isEmpty(r.getKwbm()))) { + throw new BadRequestException("请检查是否有单据未分配库位"); + } + entityList.forEach(r -> { + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + //待审核状态 + updateWrapper.set("djzt", "1"); + updateWrapper.eq("flid", r.getFlid()); + updateWrapper.set("czsl", r.getSl()); + updateWrapper.set("sysl", 0); + //库位无需扫码,填充默认库位 + 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")); + easOutInBillDetailMapper.update(null, updateWrapper); + }); + } else { + //todo 一个分录物料对应多个库位逻辑 + } } else { + //单个分录物料操作 boolean isValid = entityList.stream() .filter(r -> StringUtils.isNotEmpty(r.getKwbm())) .map(EasOutInBillDetailVO::getSysl) @@ -229,8 +234,8 @@ public class EasOutInBillDetailServiceImpl extends ServiceImpl updateWrapper = new UpdateWrapper<>(); - if(sysl.compareTo(BigDecimal.ZERO)==0) { - //待审核 + //出入库操作数量达到目标数量 + if (sysl.compareTo(BigDecimal.ZERO) == 0) { updateWrapper.set("djzt", "1"); } updateWrapper.eq("flid", entityList.get(0).getFlid()); @@ -242,7 +247,24 @@ public class EasOutInBillDetailServiceImpl extends ServiceImpl easOutInBillDetailList = easOutInBillDetailMapper + .selectList(new LambdaQueryWrapper().eq(EasOutInBillDetail::getDjid, id)); + if (!easOutInBillDetailList.isEmpty()) { + List detailList = easOutInBillDetailList.stream().filter(r -> "1".equals(r.getDjzt())).collect(Collectors.toList()); + if (detailList.size() == easOutInBillDetailList.size()) { + List ids = easOutInBillDetailList.stream().map(EasOutInBillDetail::getFlid).collect(Collectors.toList()); + //单据审核 + ieasOutInBillService.audit(ids, false); + } } } diff --git a/nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/EasOutInBillServiceImpl.java b/nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/EasOutInBillServiceImpl.java index dc451b0..4e432df 100644 --- a/nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/EasOutInBillServiceImpl.java +++ b/nlsso-server/src/main/java/org/nl/wms/database/eas/service/impl/EasOutInBillServiceImpl.java @@ -500,14 +500,11 @@ public class EasOutInBillServiceImpl extends ServiceImpl queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.lt(EasOutInBill::getCjsj, days); + List oldBills = easOutInBillService.list(queryWrapper); + if (CollectionUtils.isNotEmpty(oldBills)) { + Set 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 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单据自动审核 */ @@ -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 queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.lt(EasOutInBill::getCjsj, days); - List oldBills = easOutInBillService.list(queryWrapper); - if (CollectionUtils.isNotEmpty(oldBills)) { - Set 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 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") + //@Scheduled(cron = "0/180 * * * * *") @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class) public void autoDeleteBill(List easOutInBillDetails, List existingIds) { // 获取easOutInBillDetails中flid字段的集合