bug修改和批次需求计划优化

This commit is contained in:
2025-09-13 18:03:14 +08:00
parent c277e5f80d
commit 4d2a2186c9
12 changed files with 108 additions and 45 deletions

View File

@ -1,7 +1,11 @@
package org.dromara.cailiaoshebei.controller; package org.dromara.cailiaoshebei.controller;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -16,8 +20,10 @@ import org.dromara.common.core.exception.ServiceException;
import org.dromara.design.domain.BusBillofquantities; import org.dromara.design.domain.BusBillofquantities;
import org.dromara.design.domain.BusBillofquantitiesVersions; import org.dromara.design.domain.BusBillofquantitiesVersions;
import org.dromara.design.domain.bo.CoryObtainTheListReq; import org.dromara.design.domain.bo.CoryObtainTheListReq;
import org.dromara.design.domain.vo.ObtainTheListRes;
import org.dromara.design.service.IBusBillofquantitiesService; import org.dromara.design.service.IBusBillofquantitiesService;
import org.dromara.design.service.IBusBillofquantitiesVersionsService; import org.dromara.design.service.IBusBillofquantitiesVersionsService;
import org.springframework.beans.BeanUtils;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -134,7 +140,7 @@ public class BusMrpBaseController extends BaseController {
* 获取剩余量 * 获取剩余量
*/ */
@GetMapping("/remaining") @GetMapping("/remaining")
public R<BigDecimal> remaining(Long suppliespriceId,Long mrpBaseId) { public R<Map<String,Object>> remaining(Long suppliespriceId,Long mrpBaseId) {
return R.ok(busMrpBaseService.remaining(suppliespriceId,mrpBaseId)); return R.ok(busMrpBaseService.remaining(suppliespriceId,mrpBaseId));
} }
@ -173,7 +179,7 @@ public class BusMrpBaseController extends BaseController {
*/ */
@SaCheckPermission("cailiaoshebei:purchaseDoc:coryEngineeringList") @SaCheckPermission("cailiaoshebei:purchaseDoc:coryEngineeringList")
@GetMapping("/coryEngineeringList") @GetMapping("/coryEngineeringList")
public R<List<BusBillofquantities>> obtainTheList(CoryObtainTheListReq req) { public R<List<ObtainTheListRes>> obtainTheList(CoryObtainTheListReq req) {
BusBillofquantitiesVersions one = busBillofquantitiesVersionsService.getOne(Wrappers.<BusBillofquantitiesVersions>lambdaQuery() BusBillofquantitiesVersions one = busBillofquantitiesVersionsService.getOne(Wrappers.<BusBillofquantitiesVersions>lambdaQuery()
.eq(BusBillofquantitiesVersions::getWorkOrderType, "3") //物资工程量清单 .eq(BusBillofquantitiesVersions::getWorkOrderType, "3") //物资工程量清单
.eq(BusBillofquantitiesVersions::getProjectId, req.getProjectId()) .eq(BusBillofquantitiesVersions::getProjectId, req.getProjectId())
@ -187,6 +193,36 @@ public class BusMrpBaseController extends BaseController {
List<BusBillofquantities> list = busBillofquantitiesService.list(Wrappers.<BusBillofquantities>lambdaQuery() List<BusBillofquantities> list = busBillofquantitiesService.list(Wrappers.<BusBillofquantities>lambdaQuery()
.eq(BusBillofquantities::getVersions, one.getVersions()) .eq(BusBillofquantities::getVersions, one.getVersions())
); );
return R.ok(list); List<ObtainTheListRes> obtainTheListRes = new ArrayList<>();
list.forEach(billofquantities -> {
ObtainTheListRes res = new ObtainTheListRes();
BeanUtils.copyProperties(billofquantities, res);
obtainTheListRes.add(res);
});
Map<String, List<ObtainTheListRes>> parentMap = obtainTheListRes.stream()
.collect(Collectors.groupingBy(ObtainTheListRes::getPid));
// 3. 递归组装树形结构从顶级节点pid=0开始
List<ObtainTheListRes> treeList = buildTree("0", parentMap);
return R.ok(treeList);
}
private List<ObtainTheListRes> buildTree(String parentId, Map<String, List<ObtainTheListRes>> parentMap) {
// 获取当前父节点的所有直接子节点
List<ObtainTheListRes> children = parentMap.getOrDefault(parentId, Collections.emptyList());
if (children.isEmpty()) {
return Collections.emptyList();
}
// 为每个子节点递归设置其下一级子节点
for (ObtainTheListRes child : children) {
// 递归查询当前子节点的子节点,设置为它的子树
List<ObtainTheListRes> subChildren = buildTree(child.getSid(), parentMap);
// 注意需要在Vo中添加子节点列表字段用于存储子树
child.setChildren(subChildren);
}
return children;
} }
} }

View File

@ -51,6 +51,8 @@ public class BusMaterialbatchdemandplan extends BaseEntity {
*/ */
private Long suppliespriceId; private Long suppliespriceId;
private Long suppliespricePid;
/** /**
* 基础信息ID * 基础信息ID
*/ */

View File

@ -120,4 +120,6 @@ public class BusMaterialbatchdemandplanBo extends BaseEntity {
* 供应商id * 供应商id
*/ */
private Long supplierId; private Long supplierId;
private Long suppliespricePid;
} }

View File

@ -72,6 +72,10 @@ public class BusMaterialbatchdemandplanVo implements Serializable {
@ExcelProperty(value = "物资清单ID") @ExcelProperty(value = "物资清单ID")
private Long suppliespriceId; private Long suppliespriceId;
private Long suppliespricePid;
private String suppliespricePname;
/** /**
* 物料编码 * 物料编码
*/ */

View File

@ -10,11 +10,10 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.mybatis.core.page.PageQuery; import org.dromara.common.mybatis.core.page.PageQuery;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.web.bind.annotation.RequestBody;
import java.math.BigDecimal;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 物资-批次需求计划基础信息Service接口 * 物资-批次需求计划基础信息Service接口
@ -87,5 +86,5 @@ public interface IBusMrpBaseService extends IService<BusMrpBase>{
/** /**
* 获取物资已有数量 * 获取物资已有数量
*/ */
BigDecimal remaining(Long suppliespriceId,Long mrpBaseId); Map<String, Object> remaining(Long suppliespriceId, Long mrpBaseId);
} }

View File

@ -22,6 +22,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.dromara.design.domain.BusBillofquantities;
import org.dromara.design.service.IBusBillofquantitiesService;
import org.dromara.tender.domain.bo.BusBiddingPlanBo; import org.dromara.tender.domain.bo.BusBiddingPlanBo;
import org.dromara.tender.domain.vo.BusBiddingPlanVo; import org.dromara.tender.domain.vo.BusBiddingPlanVo;
import org.dromara.tender.domain.vo.BusBillofquantitiesLimitListVo; import org.dromara.tender.domain.vo.BusBillofquantitiesLimitListVo;
@ -67,6 +69,10 @@ public class BusMaterialbatchdemandplanServiceImpl extends ServiceImpl<BusMateri
@Autowired @Autowired
private IBusBiddingPlanService busBiddingPlanService; private IBusBiddingPlanService busBiddingPlanService;
@Lazy
@Autowired
private IBusBillofquantitiesService busBillofquantitiesService;
/** /**
* 查询物资-批次需求计划 * 查询物资-批次需求计划
* *
@ -92,7 +98,7 @@ public class BusMaterialbatchdemandplanServiceImpl extends ServiceImpl<BusMateri
if (bo.getSupplierId()!=null){ if (bo.getSupplierId()!=null){
BusBiddingPlanBo bo1 = new BusBiddingPlanBo(); BusBiddingPlanBo bo1 = new BusBiddingPlanBo();
bo1.setProjectId(bo.getProjectId()); bo1.setProjectId(bo.getProjectId());
bo1.setType("2"); bo1.setType("3");
bo1.setWinningBidderId(bo.getSupplierId()); bo1.setWinningBidderId(bo.getSupplierId());
List<BusBillofquantitiesLimitListVo> busBiddingPlanVos = busBiddingPlanService.getBillofquantitiesLimitListVo(bo1); List<BusBillofquantitiesLimitListVo> busBiddingPlanVos = busBiddingPlanService.getBillofquantitiesLimitListVo(bo1);
if (busBiddingPlanVos == null || busBiddingPlanVos.isEmpty()) { if (busBiddingPlanVos == null || busBiddingPlanVos.isEmpty()) {
@ -108,6 +114,12 @@ public class BusMaterialbatchdemandplanServiceImpl extends ServiceImpl<BusMateri
}).toList(); }).toList();
result.setRecords(list); result.setRecords(list);
} }
result.getRecords().stream().forEach(vo -> {
if (vo.getSuppliespricePid() != null){
BusBillofquantities billofquantities = busBillofquantitiesService.getById(vo.getSuppliespricePid());
vo.setSuppliespricePname(billofquantities.getName());
}
});
return TableDataInfo.build(result); return TableDataInfo.build(result);
} }

View File

@ -28,7 +28,6 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.dromara.common.utils.excel.ExcelDynamicReader; import org.dromara.common.utils.excel.ExcelDynamicReader;
import org.dromara.design.domain.BusBillofquantities; import org.dromara.design.domain.BusBillofquantities;
import org.dromara.design.domain.DesCollect;
import org.dromara.design.service.IBusBillofquantitiesService; import org.dromara.design.service.IBusBillofquantitiesService;
import org.springframework.context.event.EventListener; import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -40,10 +39,7 @@ import org.dromara.cailiaoshebei.service.IBusMrpBaseService;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Collection;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -79,8 +75,8 @@ public class BusMrpBaseServiceImpl extends ServiceImpl<BusMrpBaseMapper, BusMrpB
planBo.setMrpBaseId(id); planBo.setMrpBaseId(id);
List<BusMaterialbatchdemandplanVo> voList = planservice.queryList(planBo); List<BusMaterialbatchdemandplanVo> voList = planservice.queryList(planBo);
for (BusMaterialbatchdemandplanVo vo : voList) { for (BusMaterialbatchdemandplanVo vo : voList) {
BigDecimal remaining = remaining(vo.getSuppliespriceId(), id); Map<String, Object> map = remaining(vo.getSuppliespriceId(), id);
vo.setRemaining(remaining); vo.setRemaining(Convert.toBigDecimal(map.get("remainingQuantity")));
} }
busMrpVo.setMrpBaseBo(busMrpBaseVo); busMrpVo.setMrpBaseBo(busMrpBaseVo);
busMrpVo.setPlanList(voList); busMrpVo.setPlanList(voList);
@ -236,6 +232,11 @@ public class BusMrpBaseServiceImpl extends ServiceImpl<BusMrpBaseMapper, BusMrpB
// 转换并保存数据 // 转换并保存数据
List<BusMaterialbatchdemandplan> plans = MapstructUtils.convert(dto.getPlanList(), BusMaterialbatchdemandplan.class); List<BusMaterialbatchdemandplan> plans = MapstructUtils.convert(dto.getPlanList(), BusMaterialbatchdemandplan.class);
plans.forEach(item -> { plans.forEach(item -> {
BusBillofquantities byId = busBillofquantitiesService.getById(item.getSuppliespriceId());
if (!"0".equals(byId.getPid())) {
BusBillofquantities one = busBillofquantitiesService.getOne(new LambdaQueryWrapper<BusBillofquantities>().eq(BusBillofquantities::getSid, byId.getPid()));
item.setSuppliespricePid(one.getId());
}
item.setMrpBaseId(convert.getId()); item.setMrpBaseId(convert.getId());
item.setProjectId(convert.getProjectId()); item.setProjectId(convert.getProjectId());
}); });
@ -271,7 +272,8 @@ public class BusMrpBaseServiceImpl extends ServiceImpl<BusMrpBaseMapper, BusMrpB
@Override @Override
public BigDecimal remaining(Long suppliespriceId,Long mrpBaseId) { public Map<String, Object> remaining(Long suppliespriceId, Long mrpBaseId) {
Map<String, Object> map = new HashMap<>();
BusBillofquantities byId = busBillofquantitiesService.getById(suppliespriceId); BusBillofquantities byId = busBillofquantitiesService.getById(suppliespriceId);
// 获取数据库中已有的数量 // 获取数据库中已有的数量
List<BusMaterialbatchdemandplan> existingList = planservice.list( List<BusMaterialbatchdemandplan> existingList = planservice.list(
@ -285,8 +287,12 @@ public class BusMrpBaseServiceImpl extends ServiceImpl<BusMrpBaseMapper, BusMrpB
.map(BusMaterialbatchdemandplan::getDemandQuantity) .map(BusMaterialbatchdemandplan::getDemandQuantity)
.reduce(BigDecimal.ZERO, BigDecimal::add); .reduce(BigDecimal.ZERO, BigDecimal::add);
} }
map.put("remainingQuantity",byId.getQuantity().subtract(reduce));
return byId.getQuantity().subtract(reduce); map.put("specification",byId.getSpecification());
map.put("unit",byId.getUnit());
map.put("remark",byId.getRemark());
map.put("name",byId.getName());
return map;
} }
/** /**

View File

@ -217,7 +217,7 @@ public class BusBillofquantitiesVersionsServiceImpl extends ServiceImpl<BusBillo
//1、获取到解析数据 //1、获取到解析数据
ExcelReader.ExcelData excelData = ExcelReader.readExcelFromMultipartFile(file); ExcelReader.ExcelData excelData = ExcelReader.readExcelFromMultipartFile(file);
//走正常的工程清单 //走正常的工程清单
if (!Objects.equals(bo.getWorkOrderType(), "3")) { // if (!Objects.equals(bo.getWorkOrderType(), "3")) {
// 2. 解析所有工作表转换为带父子关系的ExcelMaterial列表 解析所有Sheet数据按规则生成sid和pid // 2. 解析所有工作表转换为带父子关系的ExcelMaterial列表 解析所有Sheet数据按规则生成sid和pid
List<BusBillofquantities> allMaterials = new ArrayList<>(); List<BusBillofquantities> allMaterials = new ArrayList<>();
for (ExcelReader.SheetData sheetData : excelData.getSheetDataList()) { for (ExcelReader.SheetData sheetData : excelData.getSheetDataList()) {
@ -239,26 +239,26 @@ public class BusBillofquantitiesVersionsServiceImpl extends ServiceImpl<BusBillo
throw new RuntimeException("导入失败"); throw new RuntimeException("导入失败");
} }
return true; return true;
} else { // } else {
// 跳过1行表头读取0到6列共7列映射到ExcelData实体类 // // 跳过1行表头读取0到6列共7列映射到ExcelData实体类
List<MaterialsAndEquipmentExcelDto> dataList = ExcelDynamicReader.readExcel( // List<MaterialsAndEquipmentExcelDto> dataList = ExcelDynamicReader.readExcel(
file, // 上传的文件 // file, // 上传的文件
1, // 跳过1行表头 // 1, // 跳过1行表头
0, // 从第0列开始 // 0, // 从第0列开始
5, // 到第5列结束 // 5, // 到第5列结束
MaterialsAndEquipmentExcelDto.class // 目标实体类 // MaterialsAndEquipmentExcelDto.class // 目标实体类
); // );
List<BusBillofquantities> busBillofquantities = BeanUtil.copyToList(dataList, BusBillofquantities.class); // List<BusBillofquantities> busBillofquantities = BeanUtil.copyToList(dataList, BusBillofquantities.class);
for (BusBillofquantities busBillofquantity : busBillofquantities) { // for (BusBillofquantities busBillofquantity : busBillofquantities) {
busBillofquantity.setProjectId(bo.getProjectId()); // busBillofquantity.setProjectId(bo.getProjectId());
busBillofquantity.setVersions(banBen); // busBillofquantity.setVersions(banBen);
} // }
boolean b = busBillofquantitiesService.saveBatch(busBillofquantities); // boolean b = busBillofquantitiesService.saveBatch(busBillofquantities);
if (!b) { // if (!b) {
throw new RuntimeException("导入失败"); // throw new RuntimeException("导入失败");
} // }
return true; // return true;
} // }
} }
@ -270,9 +270,9 @@ public class BusBillofquantitiesVersionsServiceImpl extends ServiceImpl<BusBillo
return Collections.emptyList(); return Collections.emptyList();
} }
// sheet为空表示不走下面的代码 // sheet为空表示不走下面的代码
if (StringUtils.isBlank(bo.getSheet())) { // if (StringUtils.isBlank(bo.getSheet())) {
return flatList; // return flatList;
} // }
// 2. 构建父子映射key=父节点pidvalue=该父节点的所有子节点 // 2. 构建父子映射key=父节点pidvalue=该父节点的所有子节点
Map<String, List<ObtainTheListRes>> parentMap = flatList.stream() Map<String, List<ObtainTheListRes>> parentMap = flatList.stream()
.collect(Collectors.groupingBy(ObtainTheListRes::getPid)); .collect(Collectors.groupingBy(ObtainTheListRes::getPid));

View File

@ -93,6 +93,7 @@ public class TenderSupplierInputController extends BaseController {
TenderSupplierInput newTenderSupplierInput = new TenderSupplierInput(); TenderSupplierInput newTenderSupplierInput = new TenderSupplierInput();
BeanUtils.copyProperties(tenderSupplierInputVo, newTenderSupplierInput); BeanUtils.copyProperties(tenderSupplierInputVo, newTenderSupplierInput);
newTenderSupplierInput.setProjectId(projectId); newTenderSupplierInput.setProjectId(projectId);
newTenderSupplierInput.setState("draft");
tenderSupplierInputs.add(newTenderSupplierInput); tenderSupplierInputs.add(newTenderSupplierInput);
} }
return toAjax(tenderSupplierInputService.saveOrUpdateBatch(tenderSupplierInputs)); return toAjax(tenderSupplierInputService.saveOrUpdateBatch(tenderSupplierInputs));

View File

@ -235,7 +235,7 @@ public class TenderSupplierInputVo implements Serializable {
/** /**
* 审核状态 * 审核状态
*/ */
@ExcelProperty(value = "审核状态") // @ExcelProperty(value = "审核状态")
private String state; private String state;

View File

@ -203,9 +203,9 @@ public class BusBillofquantitiesLimitListServiceImpl extends ServiceImpl<BusBill
.forEach(item -> { .forEach(item -> {
item.setPrice(item.getUnitPrice().multiply(item.getQuantity()).setScale(4, RoundingMode.HALF_UP)); item.setPrice(item.getUnitPrice().multiply(item.getQuantity()).setScale(4, RoundingMode.HALF_UP));
}); });
if (bo.getType().equals(LimitListTypeEnum.SPECIAL.getCode())) { // if (bo.getType().equals(LimitListTypeEnum.SPECIAL.getCode())) {
return listVoList; // return listVoList;
} // }
//构建父子映射 //构建父子映射
Map<String, List<BusBillofquantitiesLimitListVo>> parentMap = listVoList.stream() Map<String, List<BusBillofquantitiesLimitListVo>> parentMap = listVoList.stream()

View File

@ -172,6 +172,7 @@ public class TenderSupplierInputServiceImpl extends ServiceImpl<TenderSupplierIn
@Override @Override
public List<TenderSupplierInputVo> getList(TenderSupplierInputBo bo) { public List<TenderSupplierInputVo> getList(TenderSupplierInputBo bo) {
bo.setState("finish");
LambdaQueryWrapper<TenderSupplierInput> lqw = buildQueryWrapper(bo); LambdaQueryWrapper<TenderSupplierInput> lqw = buildQueryWrapper(bo);
List<TenderSupplierInputVo> tenderSupplierInputVos = baseMapper.selectVoList(lqw); List<TenderSupplierInputVo> tenderSupplierInputVos = baseMapper.selectVoList(lqw);
List<TenderSupplierInputVo> list = new ArrayList<>(); List<TenderSupplierInputVo> list = new ArrayList<>();