入库查询优化,装配派工单新增允许删除
This commit is contained in:
parent
38a424ae9b
commit
a91cb9af0a
@ -22,6 +22,8 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.chanko.yunxi.mes.module.heli.controller.admin.storagelog.vo.*;
|
||||
import com.chanko.yunxi.mes.module.heli.dal.dataobject.storagelog.StorageLogDO;
|
||||
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
|
||||
@ -126,20 +128,28 @@ public class StorageLogServiceImpl implements StorageLogService {
|
||||
public PageResult<StorageMaterialDO> getStorageNowPageGroupMaterial(StorageLogPageReqVO pageReqVO) {
|
||||
PageResult<StorageMaterialDO> pageResult = storageMaterialMapper.selectMaterialGroupNow(pageReqVO);
|
||||
if (ObjectUtil.isNotEmpty(pageReqVO.getWhId())){
|
||||
for (StorageMaterialDO storageMaterialDO : pageResult.getList()) {
|
||||
LambdaQueryWrapper<StorageLogNowDO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(StorageLogNowDO::getWhId,pageReqVO.getWhId());
|
||||
wrapper.eq(StorageLogNowDO::getMatCode,storageMaterialDO.getMatCode());
|
||||
List<StorageLogNowDO> list = storageLogNowMapper.selectList(wrapper);
|
||||
if (list!=null&&list.size()>0){
|
||||
storageMaterialDO.setMatRest(list.stream()
|
||||
.map(StorageLogNowDO::getStorageOkQty)
|
||||
.filter(Objects::nonNull) // 确保过滤掉 null 值
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
}else {
|
||||
storageMaterialDO.setMatRest(BigDecimal.ZERO);
|
||||
// 获取所有物料编码
|
||||
List<String> matCodes = pageResult.getList().stream()
|
||||
.map(StorageMaterialDO::getMatCode)
|
||||
.collect(Collectors.toList());
|
||||
// 批量查询库存日志
|
||||
LambdaQueryWrapper<StorageLogNowDO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(StorageLogNowDO::getWhId, pageReqVO.getWhId())
|
||||
.in(StorageLogNowDO::getMatCode, matCodes);
|
||||
List<StorageLogNowDO> logList = storageLogNowMapper.selectList(wrapper);
|
||||
|
||||
}
|
||||
// 将库存日志按物料编码分组
|
||||
Map<String, List<StorageLogNowDO>> logMap = logList.stream()
|
||||
.collect(Collectors.groupingBy(StorageLogNowDO::getMatCode));
|
||||
|
||||
// 计算每个物料的剩余数量并设置到对应的 StorageMaterialDO 对象中
|
||||
for (StorageMaterialDO storageMaterialDO : pageResult.getList()) {
|
||||
List<StorageLogNowDO> logs = logMap.getOrDefault(storageMaterialDO.getMatCode(), Collections.emptyList());
|
||||
BigDecimal matRest = logs.stream()
|
||||
.map(StorageLogNowDO::getStorageOkQty)
|
||||
.filter(Objects::nonNull) // 确保过滤掉 null 值
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
storageMaterialDO.setMatRest(matRest);
|
||||
}
|
||||
}
|
||||
return pageResult;
|
||||
|
@ -378,9 +378,7 @@ const handleSelectionChange = (row: any) => {
|
||||
}
|
||||
}else if (row.length== bomDetails.length) {
|
||||
for (let i = 0; i < bomDetails.length; i++) {
|
||||
if ( bomDetails[i].owner=='' ||bomDetails[i].owner==null){
|
||||
bomDetails[i].chkboxEnable=true
|
||||
}
|
||||
}
|
||||
}else {
|
||||
for (let i = 0; i < bomDetails.length; i++) {
|
||||
|
@ -933,8 +933,6 @@ const submitForm = async (operate) => {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
for (let i = 0; i < formData.value.taskDispatchDetails.length-1; i++) {
|
||||
for (let j = i+1; j < formData.value.taskDispatchDetails.length; j++) {
|
||||
@ -943,6 +941,12 @@ const submitForm = async (operate) => {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < formData.value.taskDispatchDetails.length; i++) {
|
||||
if (formData.value.taskDispatchDetails[i].sort!=i+1){
|
||||
message.error("派工工序的顺序号不允许跳数字,请确认!")
|
||||
return
|
||||
}
|
||||
}
|
||||
const data = formData.value as unknown as TaskDispatchApi.TaskDispatchVO
|
||||
let dataId = await TaskDispatchApi.operateTaskDispatch(data)
|
||||
@ -988,6 +992,7 @@ const onAddItem = () => {
|
||||
summary: undefined,
|
||||
status: 1,
|
||||
procedureStatus: 0,
|
||||
beginProduce: 0,
|
||||
dispatchId: undefined,
|
||||
}
|
||||
row.amount = formData.value.projectSubAmount
|
||||
|
Loading…
Reference in New Issue
Block a user