bug修改和批次需求计划优化
This commit is contained in:
@ -1,7 +1,11 @@
|
||||
package org.dromara.cailiaoshebei.controller;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
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.BusBillofquantitiesVersions;
|
||||
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.IBusBillofquantitiesVersionsService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -134,7 +140,7 @@ public class BusMrpBaseController extends BaseController {
|
||||
* 获取剩余量
|
||||
*/
|
||||
@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));
|
||||
}
|
||||
|
||||
@ -173,7 +179,7 @@ public class BusMrpBaseController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("cailiaoshebei:purchaseDoc:coryEngineeringList")
|
||||
@GetMapping("/coryEngineeringList")
|
||||
public R<List<BusBillofquantities>> obtainTheList(CoryObtainTheListReq req) {
|
||||
public R<List<ObtainTheListRes>> obtainTheList(CoryObtainTheListReq req) {
|
||||
BusBillofquantitiesVersions one = busBillofquantitiesVersionsService.getOne(Wrappers.<BusBillofquantitiesVersions>lambdaQuery()
|
||||
.eq(BusBillofquantitiesVersions::getWorkOrderType, "3") //物资工程量清单
|
||||
.eq(BusBillofquantitiesVersions::getProjectId, req.getProjectId())
|
||||
@ -187,6 +193,36 @@ public class BusMrpBaseController extends BaseController {
|
||||
List<BusBillofquantities> list = busBillofquantitiesService.list(Wrappers.<BusBillofquantities>lambdaQuery()
|
||||
.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;
|
||||
}
|
||||
}
|
||||
|
@ -51,6 +51,8 @@ public class BusMaterialbatchdemandplan extends BaseEntity {
|
||||
*/
|
||||
private Long suppliespriceId;
|
||||
|
||||
private Long suppliespricePid;
|
||||
|
||||
/**
|
||||
* 基础信息ID
|
||||
*/
|
||||
|
@ -120,4 +120,6 @@ public class BusMaterialbatchdemandplanBo extends BaseEntity {
|
||||
* 供应商id
|
||||
*/
|
||||
private Long supplierId;
|
||||
|
||||
private Long suppliespricePid;
|
||||
}
|
||||
|
@ -72,6 +72,10 @@ public class BusMaterialbatchdemandplanVo implements Serializable {
|
||||
@ExcelProperty(value = "物资清单ID")
|
||||
private Long suppliespriceId;
|
||||
|
||||
private Long suppliespricePid;
|
||||
|
||||
private String suppliespricePname;
|
||||
|
||||
/**
|
||||
* 物料编码
|
||||
*/
|
||||
|
@ -10,11 +10,10 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
|
||||
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.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 物资-批次需求计划基础信息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);
|
||||
}
|
||||
|
@ -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.toolkit.Wrappers;
|
||||
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.vo.BusBiddingPlanVo;
|
||||
import org.dromara.tender.domain.vo.BusBillofquantitiesLimitListVo;
|
||||
@ -67,6 +69,10 @@ public class BusMaterialbatchdemandplanServiceImpl extends ServiceImpl<BusMateri
|
||||
@Autowired
|
||||
private IBusBiddingPlanService busBiddingPlanService;
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IBusBillofquantitiesService busBillofquantitiesService;
|
||||
|
||||
/**
|
||||
* 查询物资-批次需求计划
|
||||
*
|
||||
@ -92,7 +98,7 @@ public class BusMaterialbatchdemandplanServiceImpl extends ServiceImpl<BusMateri
|
||||
if (bo.getSupplierId()!=null){
|
||||
BusBiddingPlanBo bo1 = new BusBiddingPlanBo();
|
||||
bo1.setProjectId(bo.getProjectId());
|
||||
bo1.setType("2");
|
||||
bo1.setType("3");
|
||||
bo1.setWinningBidderId(bo.getSupplierId());
|
||||
List<BusBillofquantitiesLimitListVo> busBiddingPlanVos = busBiddingPlanService.getBillofquantitiesLimitListVo(bo1);
|
||||
if (busBiddingPlanVos == null || busBiddingPlanVos.isEmpty()) {
|
||||
@ -108,6 +114,12 @@ public class BusMaterialbatchdemandplanServiceImpl extends ServiceImpl<BusMateri
|
||||
}).toList();
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,6 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.utils.excel.ExcelDynamicReader;
|
||||
import org.dromara.design.domain.BusBillofquantities;
|
||||
import org.dromara.design.domain.DesCollect;
|
||||
import org.dromara.design.service.IBusBillofquantitiesService;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -40,10 +39,7 @@ import org.dromara.cailiaoshebei.service.IBusMrpBaseService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -79,8 +75,8 @@ public class BusMrpBaseServiceImpl extends ServiceImpl<BusMrpBaseMapper, BusMrpB
|
||||
planBo.setMrpBaseId(id);
|
||||
List<BusMaterialbatchdemandplanVo> voList = planservice.queryList(planBo);
|
||||
for (BusMaterialbatchdemandplanVo vo : voList) {
|
||||
BigDecimal remaining = remaining(vo.getSuppliespriceId(), id);
|
||||
vo.setRemaining(remaining);
|
||||
Map<String, Object> map = remaining(vo.getSuppliespriceId(), id);
|
||||
vo.setRemaining(Convert.toBigDecimal(map.get("remainingQuantity")));
|
||||
}
|
||||
busMrpVo.setMrpBaseBo(busMrpBaseVo);
|
||||
busMrpVo.setPlanList(voList);
|
||||
@ -236,6 +232,11 @@ public class BusMrpBaseServiceImpl extends ServiceImpl<BusMrpBaseMapper, BusMrpB
|
||||
// 转换并保存数据
|
||||
List<BusMaterialbatchdemandplan> plans = MapstructUtils.convert(dto.getPlanList(), BusMaterialbatchdemandplan.class);
|
||||
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.setProjectId(convert.getProjectId());
|
||||
});
|
||||
@ -271,7 +272,8 @@ public class BusMrpBaseServiceImpl extends ServiceImpl<BusMrpBaseMapper, BusMrpB
|
||||
|
||||
|
||||
@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);
|
||||
// 获取数据库中已有的数量
|
||||
List<BusMaterialbatchdemandplan> existingList = planservice.list(
|
||||
@ -285,8 +287,12 @@ public class BusMrpBaseServiceImpl extends ServiceImpl<BusMrpBaseMapper, BusMrpB
|
||||
.map(BusMaterialbatchdemandplan::getDemandQuantity)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
}
|
||||
|
||||
return byId.getQuantity().subtract(reduce);
|
||||
map.put("remainingQuantity",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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -217,7 +217,7 @@ public class BusBillofquantitiesVersionsServiceImpl extends ServiceImpl<BusBillo
|
||||
//1、获取到解析数据
|
||||
ExcelReader.ExcelData excelData = ExcelReader.readExcelFromMultipartFile(file);
|
||||
//走正常的工程清单
|
||||
if (!Objects.equals(bo.getWorkOrderType(), "3")) {
|
||||
// if (!Objects.equals(bo.getWorkOrderType(), "3")) {
|
||||
// 2. 解析所有工作表,转换为带父子关系的ExcelMaterial列表 解析所有Sheet数据,按规则生成sid和pid
|
||||
List<BusBillofquantities> allMaterials = new ArrayList<>();
|
||||
for (ExcelReader.SheetData sheetData : excelData.getSheetDataList()) {
|
||||
@ -239,26 +239,26 @@ public class BusBillofquantitiesVersionsServiceImpl extends ServiceImpl<BusBillo
|
||||
throw new RuntimeException("导入失败");
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
// 跳过1行(表头),读取0到6列(共7列),映射到ExcelData实体类
|
||||
List<MaterialsAndEquipmentExcelDto> dataList = ExcelDynamicReader.readExcel(
|
||||
file, // 上传的文件
|
||||
1, // 跳过1行(表头)
|
||||
0, // 从第0列开始
|
||||
5, // 到第5列结束
|
||||
MaterialsAndEquipmentExcelDto.class // 目标实体类
|
||||
);
|
||||
List<BusBillofquantities> busBillofquantities = BeanUtil.copyToList(dataList, BusBillofquantities.class);
|
||||
for (BusBillofquantities busBillofquantity : busBillofquantities) {
|
||||
busBillofquantity.setProjectId(bo.getProjectId());
|
||||
busBillofquantity.setVersions(banBen);
|
||||
}
|
||||
boolean b = busBillofquantitiesService.saveBatch(busBillofquantities);
|
||||
if (!b) {
|
||||
throw new RuntimeException("导入失败");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// } else {
|
||||
// // 跳过1行(表头),读取0到6列(共7列),映射到ExcelData实体类
|
||||
// List<MaterialsAndEquipmentExcelDto> dataList = ExcelDynamicReader.readExcel(
|
||||
// file, // 上传的文件
|
||||
// 1, // 跳过1行(表头)
|
||||
// 0, // 从第0列开始
|
||||
// 5, // 到第5列结束
|
||||
// MaterialsAndEquipmentExcelDto.class // 目标实体类
|
||||
// );
|
||||
// List<BusBillofquantities> busBillofquantities = BeanUtil.copyToList(dataList, BusBillofquantities.class);
|
||||
// for (BusBillofquantities busBillofquantity : busBillofquantities) {
|
||||
// busBillofquantity.setProjectId(bo.getProjectId());
|
||||
// busBillofquantity.setVersions(banBen);
|
||||
// }
|
||||
// boolean b = busBillofquantitiesService.saveBatch(busBillofquantities);
|
||||
// if (!b) {
|
||||
// throw new RuntimeException("导入失败");
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@ -270,9 +270,9 @@ public class BusBillofquantitiesVersionsServiceImpl extends ServiceImpl<BusBillo
|
||||
return Collections.emptyList();
|
||||
}
|
||||
// sheet为空表示不走下面的代码
|
||||
if (StringUtils.isBlank(bo.getSheet())) {
|
||||
return flatList;
|
||||
}
|
||||
// if (StringUtils.isBlank(bo.getSheet())) {
|
||||
// return flatList;
|
||||
// }
|
||||
// 2. 构建父子映射:key=父节点pid,value=该父节点的所有子节点
|
||||
Map<String, List<ObtainTheListRes>> parentMap = flatList.stream()
|
||||
.collect(Collectors.groupingBy(ObtainTheListRes::getPid));
|
||||
|
@ -93,6 +93,7 @@ public class TenderSupplierInputController extends BaseController {
|
||||
TenderSupplierInput newTenderSupplierInput = new TenderSupplierInput();
|
||||
BeanUtils.copyProperties(tenderSupplierInputVo, newTenderSupplierInput);
|
||||
newTenderSupplierInput.setProjectId(projectId);
|
||||
newTenderSupplierInput.setState("draft");
|
||||
tenderSupplierInputs.add(newTenderSupplierInput);
|
||||
}
|
||||
return toAjax(tenderSupplierInputService.saveOrUpdateBatch(tenderSupplierInputs));
|
||||
|
@ -235,7 +235,7 @@ public class TenderSupplierInputVo implements Serializable {
|
||||
/**
|
||||
* 审核状态
|
||||
*/
|
||||
@ExcelProperty(value = "审核状态")
|
||||
// @ExcelProperty(value = "审核状态")
|
||||
private String state;
|
||||
|
||||
|
||||
|
@ -203,9 +203,9 @@ public class BusBillofquantitiesLimitListServiceImpl extends ServiceImpl<BusBill
|
||||
.forEach(item -> {
|
||||
item.setPrice(item.getUnitPrice().multiply(item.getQuantity()).setScale(4, RoundingMode.HALF_UP));
|
||||
});
|
||||
if (bo.getType().equals(LimitListTypeEnum.SPECIAL.getCode())) {
|
||||
return listVoList;
|
||||
}
|
||||
// if (bo.getType().equals(LimitListTypeEnum.SPECIAL.getCode())) {
|
||||
// return listVoList;
|
||||
// }
|
||||
|
||||
//构建父子映射
|
||||
Map<String, List<BusBillofquantitiesLimitListVo>> parentMap = listVoList.stream()
|
||||
|
@ -172,6 +172,7 @@ public class TenderSupplierInputServiceImpl extends ServiceImpl<TenderSupplierIn
|
||||
|
||||
@Override
|
||||
public List<TenderSupplierInputVo> getList(TenderSupplierInputBo bo) {
|
||||
bo.setState("finish");
|
||||
LambdaQueryWrapper<TenderSupplierInput> lqw = buildQueryWrapper(bo);
|
||||
List<TenderSupplierInputVo> tenderSupplierInputVos = baseMapper.selectVoList(lqw);
|
||||
List<TenderSupplierInputVo> list = new ArrayList<>();
|
||||
|
Reference in New Issue
Block a user