This commit is contained in:
zt
2025-09-08 11:42:36 +08:00
parent da0dd8f78f
commit 78829ef5e7
2 changed files with 26 additions and 5 deletions

View File

@ -1,6 +1,7 @@
package org.dromara.cailiaoshebei.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotEmpty;
@ -33,8 +34,12 @@ import org.dromara.design.service.IBusBillofquantitiesVersionsService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 物资-采购联系单
@ -159,13 +164,23 @@ public class BusPurchaseDocController extends BaseController {
@PathVariable("id") Long id) {
List<BusPlanDocAssociation> list = planDocAssociationService.list(Wrappers.lambdaQuery(BusPlanDocAssociation.class)
.eq(BusPlanDocAssociation::getDocId, id));
List<Long> list1 = list.stream().map(BusPlanDocAssociation::getPlanId).toList();
if (list1.isEmpty()) {
if (CollectionUtil.isEmpty(list)) {
return R.ok(new ArrayList<>());
}
Map<Long, BigDecimal> collect = list.stream()
.filter(Objects::nonNull) // 过滤空对象
.collect(Collectors.toMap(
BusPlanDocAssociation::getPlanId,
BusPlanDocAssociation::getDemandQuantity,
(existing, replacement) -> existing // 保留第一个遇到的重复键
));
BusMaterialbatchdemandplanBo bo = new BusMaterialbatchdemandplanBo();
bo.setIds(list1);
return R.ok(materialbatchdemandplanService.queryList(bo));
bo.setIds(new ArrayList<>(collect.keySet()));
List<BusMaterialbatchdemandplanVo> busMaterialbatchdemandplanVos = materialbatchdemandplanService.queryList(bo);
for (BusMaterialbatchdemandplanVo busMaterialbatchdemandplanVo : busMaterialbatchdemandplanVos) {
busMaterialbatchdemandplanVo.setDemandQuantity(collect.get(busMaterialbatchdemandplanVo.getId()).longValue());
}
return R.ok(busMaterialbatchdemandplanVos);
}
//

View File

@ -315,17 +315,23 @@ public class OutMonthPlanServiceImpl extends ServiceImpl<OutMonthPlanMapper, Out
outMonthPlanAudit.setProjectId(outMonthPlan.getProjectId());
outMonthPlanAudit.setPlanMonth(outMonthPlan.getPlanMonth());
BigDecimal designValue = BigDecimal.ZERO;
BigDecimal purchaseValue = BigDecimal.ZERO;
BigDecimal constructionValue = BigDecimal.ZERO;
if(outMonthPlan.getValueType().equals("1")){
outMonthPlanAudit.setDesignValue(outMonthPlan.getPlanValue());
designValue = outMonthPlan.getPlanValue();
}
if(outMonthPlan.getValueType().equals("2")){
outMonthPlanAudit.setPurchaseValue(outMonthPlan.getPlanValue());
purchaseValue = outMonthPlan.getPlanValue();
}
if(outMonthPlan.getValueType().equals("3")){
outMonthPlanAudit.setConstructionValue(outMonthPlan.getPlanValue());
constructionValue = outMonthPlan.getPlanValue();
}
outMonthPlanAudit.setTotalValue(outMonthPlanAudit.getDesignValue().add(outMonthPlanAudit.getPurchaseValue()).add(outMonthPlanAudit.getConstructionValue()));
outMonthPlanAudit.setTotalValue(designValue.add(purchaseValue).add(constructionValue));
return outMonthPlanAudit;
}