|
|
@ -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<EasOutInBillDetailMapper, EasOutInBillDetail> implements IeasOutInBillDetailService { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
private IeasOutInBillService ieasOutInBillService; |
|
|
|
|
|
|
@ -70,31 +71,31 @@ public class EasOutInBillDetailServiceImpl extends ServiceImpl<EasOutInBillDetai |
|
|
|
List<InventoryInfo> 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<EasOutInBillDetai |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void update(List<EasOutInBillDetailVO> 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()); |
|
|
|
Set<String> 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<EasOutInBillDetail> 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<EasOutInBillDetail> 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<EasOutInBillDetai |
|
|
|
throw new BadRequestException("请检查库位和数量信息"); |
|
|
|
} |
|
|
|
UpdateWrapper<EasOutInBillDetail> 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<EasOutInBillDetai |
|
|
|
updateWrapper.set("update_time", DateUtil.format(DateUtil.beginOfDay(DateUtil.date()), "yyyy-MM-dd")); |
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|