批次需求计划优化
This commit is contained in:
@ -26,7 +26,7 @@ public class WebSocketTopicListener implements ApplicationRunner, Ordered {
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
// 订阅WebSocket消息
|
||||
WebSocketUtils.subscribeMessage((message) -> {
|
||||
log.info("WebSocket主题订阅收到消息session keys={} message={}", message.getSessionKeys(), message.getMessage());
|
||||
// log.info("WebSocket主题订阅收到消息session keys={} message={}", message.getSessionKeys(), message.getMessage());
|
||||
// 如果key不为空就按照key发消息 如果为空就群发
|
||||
if (CollUtil.isNotEmpty(message.getSessionKeys())) {
|
||||
message.getSessionKeys().forEach(key -> {
|
||||
|
||||
@ -13,6 +13,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.dromara.cailiaoshebei.domain.bo.RemainingReq;
|
||||
import org.dromara.cailiaoshebei.domain.dto.BusMrpDto;
|
||||
import org.dromara.cailiaoshebei.domain.dto.BusMrpExportDto;
|
||||
import org.dromara.cailiaoshebei.domain.vo.BusMrpVo;
|
||||
@ -24,6 +25,10 @@ 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.dromara.tender.domain.bo.BusBiddingPlanBo;
|
||||
import org.dromara.tender.domain.vo.BusBiddingPlanVo;
|
||||
import org.dromara.tender.domain.vo.BusBillofquantitiesLimitListVo;
|
||||
import org.dromara.tender.service.IBusBiddingPlanService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -59,6 +64,7 @@ public class BusMrpBaseController extends BaseController {
|
||||
private final IBusBillofquantitiesVersionsService busBillofquantitiesVersionsService;
|
||||
|
||||
private final IBusBillofquantitiesService busBillofquantitiesService;
|
||||
private final IBusBiddingPlanService busBiddingPlanService;
|
||||
|
||||
/**
|
||||
* 查询物资-批次需求计划基础信息列表
|
||||
@ -141,8 +147,14 @@ public class BusMrpBaseController extends BaseController {
|
||||
* 获取剩余量
|
||||
*/
|
||||
@GetMapping("/remaining")
|
||||
public R<Map<String,Object>> remaining(Long projectId, String suppliespriceName,String specification,Long mrpBaseId) {
|
||||
return R.ok(busMrpBaseService.remaining(projectId,suppliespriceName,specification,mrpBaseId));
|
||||
public R<List<Map<String,Object>>> remaining( RemainingReq req) {
|
||||
String[] split = req.getLimitListId().split(",");
|
||||
List<Map<String, Object>> maps = new ArrayList<>();
|
||||
for (String id : split) {
|
||||
Map<String, Object> remaining = busMrpBaseService.remaining(req.getProjectId(), Long.valueOf(id), req.getMrpBaseId());
|
||||
maps.add(remaining);
|
||||
}
|
||||
return R.ok(maps);
|
||||
}
|
||||
|
||||
|
||||
@ -175,6 +187,35 @@ public class BusMrpBaseController extends BaseController {
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取工程量清单列表
|
||||
*/
|
||||
@SaCheckPermission("cailiaoshebei:mrpBase:getZhaoBiaoList")
|
||||
@GetMapping("/getZhaoBiaoList")
|
||||
public R<List<BusBiddingPlanVo>> getZhaoBiaoList(CoryObtainTheListReq req) {
|
||||
BusBiddingPlanBo bo = new BusBiddingPlanBo();
|
||||
bo.setProjectId(req.getProjectId());
|
||||
bo.setType("3");
|
||||
bo.setBidStatus(1);
|
||||
List<BusBiddingPlanVo> busBiddingPlanVos = busBiddingPlanService.queryList(bo);
|
||||
return R.ok(busBiddingPlanVos);
|
||||
}
|
||||
|
||||
/**
|
||||
* 招标计划数据详情
|
||||
* @param bo
|
||||
* @return
|
||||
*/
|
||||
@SaCheckPermission("cailiaoshebei:mrpBase:getMore")
|
||||
@GetMapping("/getMore")
|
||||
public R<List<BusBillofquantitiesLimitListVo>> getMore(BusBiddingPlanBo bo) {
|
||||
if (bo.getId() == null) {
|
||||
throw new ServiceException("id不能为空");
|
||||
}
|
||||
return R.ok(busBiddingPlanService.getMore(bo));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取工程量清单列表
|
||||
*/
|
||||
|
||||
@ -106,8 +106,8 @@ public class BusMrpBaseAppController extends BaseController {
|
||||
* 获取剩余量
|
||||
*/
|
||||
@GetMapping("/remaining")
|
||||
public R<Map<String,Object>> remaining(Long projectId, String suppliespriceName,String specification,Long mrpBaseId) {
|
||||
return R.ok(busMrpBaseService.remaining(projectId,suppliespriceName,specification,mrpBaseId));
|
||||
public R<Map<String,Object>> remaining(Long projectId,Long limitListId,Long mrpBaseId) {
|
||||
return R.ok(busMrpBaseService.remaining(projectId,limitListId,mrpBaseId));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -42,6 +42,10 @@ public class BusPlanDocAssociationBo extends BaseEntity {
|
||||
* 采购联系单id
|
||||
*/
|
||||
private Long docId;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long suppliespriceId;
|
||||
|
||||
/**
|
||||
* 需求数量
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
package org.dromara.cailiaoshebei.domain.bo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class RemainingReq implements Serializable {
|
||||
|
||||
private Long projectId;
|
||||
|
||||
private String limitListId;
|
||||
|
||||
private Long mrpBaseId;
|
||||
}
|
||||
@ -140,4 +140,12 @@ public class BusMaterialbatchdemandplanVo implements Serializable {
|
||||
*/
|
||||
private BigDecimal remaining;
|
||||
|
||||
|
||||
/**
|
||||
* 供应商提供数量
|
||||
*/
|
||||
private BigDecimal tenderQuantity;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -86,5 +86,5 @@ public interface IBusMrpBaseService extends IService<BusMrpBase>{
|
||||
/**
|
||||
* 获取物资已有数量
|
||||
*/
|
||||
Map<String, Object> remaining(Long projectId, String suppliespriceName, String specification, Long mrpBaseId);
|
||||
Map<String, Object> remaining(Long projectId,Long limitListId,Long mrpBaseId);
|
||||
}
|
||||
|
||||
@ -24,10 +24,13 @@ 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.BusBillofquantitiesLimitList;
|
||||
import org.dromara.tender.domain.bo.BusBiddingPlanBo;
|
||||
import org.dromara.tender.domain.vo.BusBiddingPlanVo;
|
||||
import org.dromara.tender.domain.vo.BusBillofquantitiesLimitListVo;
|
||||
import org.dromara.tender.domain.vo.BusTenderPlanningLimitListVo;
|
||||
import org.dromara.tender.service.IBusBiddingPlanService;
|
||||
import org.dromara.tender.service.IBusBillofquantitiesLimitListService;
|
||||
import org.dromara.tender.service.ITenderSupplierInputService;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -41,6 +44,7 @@ import org.dromara.cailiaoshebei.mapper.BusMaterialbatchdemandplanMapper;
|
||||
import org.dromara.cailiaoshebei.service.IBusMaterialbatchdemandplanService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@ -72,6 +76,9 @@ public class BusMaterialbatchdemandplanServiceImpl extends ServiceImpl<BusMateri
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IBusBillofquantitiesService busBillofquantitiesService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IBusBillofquantitiesLimitListService busBillofquantitiesLimitListService;
|
||||
|
||||
/**
|
||||
* 查询物资-批次需求计划
|
||||
@ -101,22 +108,26 @@ public class BusMaterialbatchdemandplanServiceImpl extends ServiceImpl<BusMateri
|
||||
bo1.setType("3");
|
||||
bo1.setWinningBidderId(bo.getSupplierId());
|
||||
List<BusBillofquantitiesLimitListVo> busBiddingPlanVos = busBiddingPlanService.getBillofquantitiesLimitListVo(bo1);
|
||||
Map<Long, BigDecimal> map = busBiddingPlanService.getCailiaoCount(bo1);
|
||||
if (busBiddingPlanVos == null || busBiddingPlanVos.isEmpty()) {
|
||||
throw new ServiceException("该供应商暂无材料");
|
||||
}
|
||||
Set<String> hashSet = new HashSet<>();
|
||||
busBiddingPlanVos.stream().forEach(vo -> {
|
||||
hashSet.add(vo.getName()+"+"+vo.getSpecification());
|
||||
Set<Long> hashSet = new HashSet<>();
|
||||
busBiddingPlanVos.forEach(vo -> {
|
||||
hashSet.add(vo.getId());
|
||||
});
|
||||
List<BusMaterialbatchdemandplanVo> list = result.getRecords().stream().filter(vo -> {
|
||||
String key = vo.getName() + "+" + vo.getSpecification(); // 拼接字符串(需与 Set 中格式一致)
|
||||
return hashSet.contains(key); // 仅保留 Set 中存在的数据
|
||||
}).toList();
|
||||
result.setRecords(list);
|
||||
result.getRecords().stream().filter(vo -> {
|
||||
return hashSet.contains(vo.getSuppliespriceId()); // 仅保留 Set 中存在的数据
|
||||
}).forEach(item->{
|
||||
if (map.containsKey(item.getId())) {
|
||||
item.setTenderQuantity(map.get(item.getId()));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
result.getRecords().stream().forEach(vo -> {
|
||||
result.getRecords().forEach(vo -> {
|
||||
if (vo.getSuppliespricePid() != null){
|
||||
BusBillofquantities billofquantities = busBillofquantitiesService.getById(vo.getSuppliespricePid());
|
||||
BusBillofquantitiesLimitList billofquantities = busBillofquantitiesLimitListService.getById(vo.getSuppliespricePid());
|
||||
vo.setSuppliespricePname(billofquantities.getName());
|
||||
}
|
||||
});
|
||||
|
||||
@ -29,6 +29,10 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.utils.excel.ExcelDynamicReader;
|
||||
import org.dromara.design.domain.BusBillofquantities;
|
||||
import org.dromara.design.service.IBusBillofquantitiesService;
|
||||
import org.dromara.tender.domain.BusBillofquantitiesLimitList;
|
||||
import org.dromara.tender.domain.BusTenderPlanningLimitList;
|
||||
import org.dromara.tender.service.IBusBillofquantitiesLimitListService;
|
||||
import org.dromara.tender.service.IBusTenderPlanningLimitListService;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.cailiaoshebei.domain.bo.BusMrpBaseBo;
|
||||
@ -57,7 +61,10 @@ public class BusMrpBaseServiceImpl extends ServiceImpl<BusMrpBaseMapper, BusMrpB
|
||||
|
||||
private final IBusMaterialbatchdemandplanService planservice;
|
||||
|
||||
private final IBusBillofquantitiesService busBillofquantitiesService;
|
||||
private final IBusBillofquantitiesLimitListService busBillofquantitiesService;
|
||||
|
||||
private final IBusTenderPlanningLimitListService tenderPlanningLimitListService;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@ -75,7 +82,7 @@ public class BusMrpBaseServiceImpl extends ServiceImpl<BusMrpBaseMapper, BusMrpB
|
||||
planBo.setMrpBaseId(id);
|
||||
List<BusMaterialbatchdemandplanVo> voList = planservice.queryList(planBo);
|
||||
for (BusMaterialbatchdemandplanVo vo : voList) {
|
||||
Map<String, Object> map = remaining(vo.getProjectId(),vo.getName(), vo.getSpecification(), id);
|
||||
Map<String, Object> map = remaining(vo.getProjectId(), vo.getSuppliespriceId(), id);
|
||||
vo.setRemaining(Convert.toBigDecimal(map.get("remainingQuantity")));
|
||||
}
|
||||
busMrpVo.setMrpBaseBo(busMrpBaseVo);
|
||||
@ -190,14 +197,13 @@ public class BusMrpBaseServiceImpl extends ServiceImpl<BusMrpBaseMapper, BusMrpB
|
||||
|
||||
if (CollectionUtil.isNotEmpty(dto.getPlanList())) {
|
||||
// 按 suppliespriceId 分组统计本次提交的数量
|
||||
Map<String, BigDecimal> batchSumMap = dto.getPlanList().stream()
|
||||
// String name = item.getName() != null ? item.getName() : "";
|
||||
// String spec = item.getSpecification() != null ? item.getSpecification() : "";
|
||||
// return name + "&&&" + spec;
|
||||
Map<Long, BigDecimal> batchSumMap = dto.getPlanList().stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
// 关键修改:使用 name + specification 拼接作为分组键
|
||||
item -> {
|
||||
String name = item.getName() != null ? item.getName() : "";
|
||||
String spec = item.getSpecification() != null ? item.getSpecification() : "";
|
||||
return name + "&&&" + spec;
|
||||
},
|
||||
BusMaterialbatchdemandplanBo::getSuppliespriceId,
|
||||
Collectors.reducing(
|
||||
BigDecimal.ZERO,
|
||||
item -> {
|
||||
@ -209,45 +215,36 @@ public class BusMrpBaseServiceImpl extends ServiceImpl<BusMrpBaseMapper, BusMrpB
|
||||
));
|
||||
|
||||
// 检查每种物料是否超出数量限制
|
||||
for (Map.Entry<String, BigDecimal> entry : batchSumMap.entrySet()) {
|
||||
String biaoshi = entry.getKey();
|
||||
for (Map.Entry<Long, BigDecimal> entry : batchSumMap.entrySet()) {
|
||||
Long biaoshi = entry.getKey();
|
||||
BigDecimal batchSum = entry.getValue();
|
||||
String[] split = biaoshi.split("&&&");
|
||||
// 获取数据库中已有的数量
|
||||
List<BusMaterialbatchdemandplan> existingList = planservice.list(
|
||||
Wrappers.lambdaQuery(BusMaterialbatchdemandplan.class)
|
||||
.eq(BusMaterialbatchdemandplan::getName, split[0])
|
||||
.eq(BusMaterialbatchdemandplan::getSpecification,split[1])
|
||||
.eq(BusMaterialbatchdemandplan::getSuppliespriceId, biaoshi)
|
||||
.ne(BusMaterialbatchdemandplan::getMrpBaseId, convert.getId()) // 排除当前批次
|
||||
);
|
||||
|
||||
//计算数据库保存数量
|
||||
BigDecimal existingSum = existingList.stream()
|
||||
.map(BusMaterialbatchdemandplan::getDemandQuantity)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
|
||||
// 检查总数量是否超出限制
|
||||
List<BusBillofquantities> busBillofquantities = busBillofquantitiesService.getBaseMapper().selectList(new LambdaQueryWrapper<BusBillofquantities>()
|
||||
.eq(BusBillofquantities::getProjectId, dto.getMrpBaseBo().getProjectId())
|
||||
.eq(BusBillofquantities::getName, split[0])
|
||||
.eq(BusBillofquantities::getSpecification, split[1]));
|
||||
BigDecimal quantity = busBillofquantities.stream()
|
||||
.map(BusBillofquantities::getQuantity)
|
||||
List<BusTenderPlanningLimitList> busTenderPlanningLimitLists = tenderPlanningLimitListService.getBaseMapper()
|
||||
.selectList(new LambdaQueryWrapper<BusTenderPlanningLimitList>()
|
||||
.eq(BusTenderPlanningLimitList::getLimitListId, biaoshi));
|
||||
BigDecimal quantity = busTenderPlanningLimitLists.stream()
|
||||
.map(BusTenderPlanningLimitList::getNum)
|
||||
.filter(Objects::nonNull)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
if (existingSum.add(batchSum).compareTo(quantity) > 0) {
|
||||
// 找到超出限制的物料名称用于提示
|
||||
String itemName = dto.getPlanList().stream()
|
||||
.filter(item -> {
|
||||
String name = item.getName() != null ? item.getName() : "";
|
||||
String spec = item.getSpecification() != null ? item.getSpecification() : "";
|
||||
return (name + "&&&" + spec).equals(biaoshi);
|
||||
|
||||
})
|
||||
.filter(item -> Objects.equals(biaoshi, item.getSuppliespriceId()))
|
||||
.findFirst()
|
||||
.map(item -> {
|
||||
String name = item.getName() != null ? item.getName() : "";
|
||||
String spec = item.getSpecification() != null ? item.getSpecification() : "";
|
||||
return "名称:“"+name + "”,规格:“" + spec+"”";
|
||||
return "名称:“"+name + "”";
|
||||
})
|
||||
.orElse("未知物料");
|
||||
throw new ServiceException(itemName + "超出数量");
|
||||
@ -257,11 +254,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());
|
||||
// }
|
||||
BusBillofquantitiesLimitList byId = busBillofquantitiesService.getById(item.getSuppliespriceId());
|
||||
if (!"0".equals(byId.getPid())) {
|
||||
BusBillofquantitiesLimitList one = busBillofquantitiesService.getOne(new LambdaQueryWrapper<BusBillofquantitiesLimitList>().eq(BusBillofquantitiesLimitList::getSid, byId.getPid()));
|
||||
item.setSuppliespricePid(one.getId());
|
||||
}
|
||||
item.setMrpBaseId(convert.getId());
|
||||
item.setProjectId(convert.getProjectId());
|
||||
});
|
||||
@ -297,23 +294,21 @@ public class BusMrpBaseServiceImpl extends ServiceImpl<BusMrpBaseMapper, BusMrpB
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> remaining(Long projectId, String suppliespriceName, String specification, Long mrpBaseId) {
|
||||
public Map<String, Object> remaining(Long projectId, Long limitListId,Long mrpBaseId) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
List<BusBillofquantities> busBillofquantities = busBillofquantitiesService.getBaseMapper()
|
||||
.selectList(new LambdaQueryWrapper<BusBillofquantities>()
|
||||
.eq(BusBillofquantities::getProjectId, projectId)
|
||||
.eq(BusBillofquantities::getName, suppliespriceName)
|
||||
.eq(BusBillofquantities::getSpecification,specification));
|
||||
BigDecimal quantity = busBillofquantities.stream()
|
||||
.map(BusBillofquantities::getQuantity)
|
||||
List<BusTenderPlanningLimitList> busTenderPlanningLimitLists = tenderPlanningLimitListService.getBaseMapper()
|
||||
.selectList(new LambdaQueryWrapper<BusTenderPlanningLimitList>()
|
||||
.eq(BusTenderPlanningLimitList::getLimitListId, limitListId));
|
||||
BigDecimal quantity = busTenderPlanningLimitLists.stream()
|
||||
.map(BusTenderPlanningLimitList::getNum)
|
||||
.filter(Objects::nonNull)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
// BusBillofquantities byId = busBillofquantitiesService.getById(suppliespriceId);
|
||||
|
||||
BusBillofquantitiesLimitList busBillofquantities = busBillofquantitiesService.getById(limitListId);
|
||||
// 获取数据库中已有的数量
|
||||
List<BusMaterialbatchdemandplan> existingList = planservice.list(
|
||||
Wrappers.lambdaQuery(BusMaterialbatchdemandplan.class)
|
||||
.eq(BusMaterialbatchdemandplan::getName, suppliespriceName)
|
||||
.eq(BusMaterialbatchdemandplan::getSpecification ,specification)
|
||||
.eq(BusMaterialbatchdemandplan::getSuppliespriceId ,limitListId)
|
||||
.ne(mrpBaseId!=null,BusMaterialbatchdemandplan::getMrpBaseId, mrpBaseId)// 排除当前批次
|
||||
);
|
||||
BigDecimal reduce = BigDecimal.ZERO;
|
||||
@ -323,10 +318,11 @@ public class BusMrpBaseServiceImpl extends ServiceImpl<BusMrpBaseMapper, BusMrpB
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
}
|
||||
map.put("remainingQuantity",quantity.subtract(reduce));
|
||||
map.put("specification",busBillofquantities.getFirst().getSpecification());
|
||||
map.put("unit",busBillofquantities.getFirst().getUnit());
|
||||
map.put("remark",busBillofquantities.getFirst().getRemark());
|
||||
map.put("name",busBillofquantities.getFirst().getName());
|
||||
map.put("specification",busBillofquantities.getSpecification());
|
||||
map.put("suppliespriceId",limitListId);
|
||||
map.put("unit",busBillofquantities.getUnit());
|
||||
map.put("remark",busBillofquantities.getRemark());
|
||||
map.put("name",busBillofquantities.getName());
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
@ -51,6 +51,8 @@ import org.dromara.project.domain.BusProject;
|
||||
import org.dromara.project.service.IBusProjectService;
|
||||
import org.dromara.system.domain.vo.SysOssVo;
|
||||
import org.dromara.system.service.ISysOssService;
|
||||
import org.dromara.tender.domain.BusTenderPlanningLimitList;
|
||||
import org.dromara.tender.service.IBusTenderPlanningLimitListService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
@ -98,6 +100,8 @@ public class BusPurchaseDocServiceImpl extends ServiceImpl<BusPurchaseDocMapper,
|
||||
|
||||
private final ISysOssService ossService;
|
||||
|
||||
private final IBusTenderPlanningLimitListService tenderPlanningLimitListService;
|
||||
|
||||
/**
|
||||
* 查询物资-采购联系单
|
||||
*
|
||||
@ -187,7 +191,7 @@ public class BusPurchaseDocServiceImpl extends ServiceImpl<BusPurchaseDocMapper,
|
||||
|
||||
BusPurchaseDoc add = MapstructUtils.convert(bo, BusPurchaseDoc.class);
|
||||
validEntityBeforeSave(add);
|
||||
validNum(bo.getAssociationList());
|
||||
validNum(bo.getAssociationList(),add.getSupplierId());
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
@ -204,20 +208,60 @@ public class BusPurchaseDocServiceImpl extends ServiceImpl<BusPurchaseDocMapper,
|
||||
}
|
||||
|
||||
|
||||
public void validNum(List<BusPlanDocAssociationBo> associationList) {
|
||||
public void validNum(List<BusPlanDocAssociationBo> associationList, Long supplierId) {
|
||||
|
||||
for (BusPlanDocAssociationBo association : associationList) {
|
||||
|
||||
//获取批次需求计划
|
||||
BusMaterialbatchdemandplan byId = materialbatchdemandplanService.getById(association.getPlanId());
|
||||
|
||||
List<String> statuss = new ArrayList<>();
|
||||
statuss.add(BusinessStatusEnum.DRAFT.getStatus());
|
||||
statuss.add(BusinessStatusEnum.FINISH.getStatus());
|
||||
statuss.add(BusinessStatusEnum.WAITING.getStatus());
|
||||
//查询处于草稿、待审核、已审核状态的联系单
|
||||
List<Long> ids = new ArrayList<>();
|
||||
//该供应商的联系单
|
||||
List<Long> ids1 = new ArrayList<>();
|
||||
for (BusPurchaseDoc busPurchaseDoc : baseMapper.selectList(new LambdaQueryWrapper<BusPurchaseDoc>().in(BusPurchaseDoc::getStatus, statuss))) {
|
||||
ids.add(busPurchaseDoc.getId());
|
||||
if (busPurchaseDoc.getSupplierId().equals(supplierId)) {
|
||||
ids1.add(busPurchaseDoc.getId());
|
||||
}
|
||||
}
|
||||
List<BusTenderPlanningLimitList> busTenderPlanningLimitLists = tenderPlanningLimitListService.getBaseMapper()
|
||||
.selectList(new LambdaQueryWrapper<BusTenderPlanningLimitList>()
|
||||
.eq(BusTenderPlanningLimitList::getLimitListId, association.getSuppliespriceId()));
|
||||
BigDecimal quantity = busTenderPlanningLimitLists.stream()
|
||||
.map(BusTenderPlanningLimitList::getNum)
|
||||
.filter(Objects::nonNull)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
//查询处于这些采购联系单
|
||||
List<BusPlanDocAssociation> list = planDocAssociationService.list(Wrappers.lambdaQuery(BusPlanDocAssociation.class)
|
||||
.eq(BusPlanDocAssociation::getPlanId, association.getPlanId()));
|
||||
.eq(BusPlanDocAssociation::getPlanId, association.getPlanId())
|
||||
.in(BusPlanDocAssociation::getDocId, ids));
|
||||
List<BusMaterialbatchdemandplan> busMaterialbatchdemandplans = materialbatchdemandplanService.getBaseMapper().selectList(new LambdaQueryWrapper<BusMaterialbatchdemandplan>()
|
||||
.eq(BusMaterialbatchdemandplan::getSuppliespriceId, association.getSuppliespriceId()));
|
||||
Set<Long> planids = new HashSet<>();
|
||||
busMaterialbatchdemandplans.forEach(busMaterialbatchdemandplan -> {
|
||||
planids.add(busMaterialbatchdemandplan.getId());
|
||||
});
|
||||
if (!ids1.isEmpty()){
|
||||
List<BusPlanDocAssociation> list1 = planDocAssociationService.list(Wrappers.lambdaQuery(BusPlanDocAssociation.class)
|
||||
.in(BusPlanDocAssociation::getDocId, ids1));
|
||||
//计算材料已存在的数量
|
||||
BigDecimal cltotal = list1.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(item->planids.contains(item.getPlanId()))
|
||||
.map(BusPlanDocAssociation::getDemandQuantity)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
if (cltotal.add(association.getDemandQuantity()).compareTo(quantity) > 0) {
|
||||
throw new ServiceException("材料:" + byId.getName() + "已超出供应商提供数量");
|
||||
}
|
||||
}
|
||||
//计算采购已存在的数量
|
||||
BigDecimal total = list.stream()
|
||||
.map(BusPlanDocAssociation::getDemandQuantity)
|
||||
.filter(Objects::nonNull)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
|
||||
|
||||
if (total.add(association.getDemandQuantity()).compareTo(byId.getDemandQuantity()) > 0) {
|
||||
throw new ServiceException("材料:" + byId.getName() + "已超出计划单的物料批次需求计划数量");
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
@ -84,6 +85,15 @@ public class BusTenderPlanLimitListController extends BaseController {
|
||||
return R.ok(busBillofquantitiesLimitListService.sheetList(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定版本的全部大类
|
||||
*/
|
||||
@SaCheckPermission("tender:tenderPlanLimitList:pList")
|
||||
@GetMapping("/pList")
|
||||
public R<List<BusBillofquantitiesLimitListVo>> pList(BusBillofquantitiesLimitListBo bo) {
|
||||
return R.ok(busBillofquantitiesLimitListService.pList(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出限价一览列表
|
||||
*/
|
||||
|
||||
@ -1,20 +1,19 @@
|
||||
package org.dromara.tender.service;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.dromara.tender.domain.vo.BusBiddingPlanAnnexVo;
|
||||
import org.dromara.tender.domain.vo.BusBiddingPlanDetailVo;
|
||||
import org.dromara.tender.domain.vo.BusBiddingPlanVo;
|
||||
import org.dromara.tender.domain.vo.*;
|
||||
import org.dromara.tender.domain.bo.BusBiddingPlanBo;
|
||||
import org.dromara.tender.domain.BusBiddingPlan;
|
||||
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.dromara.tender.domain.vo.BusBillofquantitiesLimitListVo;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 招标计划Service接口
|
||||
@ -106,4 +105,6 @@ public interface IBusBiddingPlanService extends IService<BusBiddingPlan>{
|
||||
* @return
|
||||
*/
|
||||
List<BusBillofquantitiesLimitListVo> getBillofquantitiesLimitListVo(BusBiddingPlanBo bo1);
|
||||
|
||||
Map<Long, BigDecimal> getCailiaoCount(BusBiddingPlanBo bo1);
|
||||
}
|
||||
|
||||
@ -112,4 +112,6 @@ public interface IBusBillofquantitiesLimitListService extends IService<BusBillof
|
||||
List<BusBillofquantitiesLimitListVo> queryVoByIds(List<Long> ids);
|
||||
|
||||
List<BusBillofquantitiesLimitListWuZiVo> queryVoList(BusBillofquantitiesLimitListBo bo);
|
||||
|
||||
List<BusBillofquantitiesLimitListVo> pList(BusBillofquantitiesLimitListBo bo);
|
||||
}
|
||||
|
||||
@ -17,9 +17,7 @@ import org.dromara.system.service.ISysOssService;
|
||||
import org.dromara.tender.domain.*;
|
||||
import org.dromara.tender.domain.bo.BusBiddingPlanAnnexBo;
|
||||
import org.dromara.tender.domain.bo.BusTenderPlanningLimitListBo;
|
||||
import org.dromara.tender.domain.vo.BusBiddingPlanAnnexVo;
|
||||
import org.dromara.tender.domain.vo.BusBiddingPlanDetailVo;
|
||||
import org.dromara.tender.domain.vo.BusBillofquantitiesLimitListVo;
|
||||
import org.dromara.tender.domain.vo.*;
|
||||
import org.dromara.tender.mapper.BusTenderPlanningLimitListMapper;
|
||||
import org.dromara.tender.service.IBusBiddingPlanAnnexService;
|
||||
import org.dromara.tender.service.IBusBillofquantitiesLimitListService;
|
||||
@ -27,7 +25,6 @@ import org.dromara.tender.service.ITenderSupplierInputService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.tender.domain.bo.BusBiddingPlanBo;
|
||||
import org.dromara.tender.domain.vo.BusBiddingPlanVo;
|
||||
import org.dromara.tender.mapper.BusBiddingPlanMapper;
|
||||
import org.dromara.tender.service.IBusBiddingPlanService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -375,6 +372,30 @@ public class BusBiddingPlanServiceImpl extends ServiceImpl<BusBiddingPlanMapper,
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, BigDecimal> getCailiaoCount(BusBiddingPlanBo bo1) {
|
||||
//查询属于该供应商的招标计划
|
||||
List<BusBiddingPlanVo> busBiddingPlanVos = baseMapper.selectVoList(new LambdaQueryWrapper<BusBiddingPlan>()
|
||||
.eq(BusBiddingPlan::getProjectId, bo1.getProjectId())
|
||||
.eq(BusBiddingPlan::getWinningBidderId, bo1.getWinningBidderId())
|
||||
.eq(BusBiddingPlan::getBidStatus,"1"));
|
||||
List<Long> bplanIdds = new ArrayList<>();
|
||||
for (BusBiddingPlanVo busBiddingPlanVo : busBiddingPlanVos) {
|
||||
bplanIdds.add(busBiddingPlanVo.getId());
|
||||
}
|
||||
Map<Long, BigDecimal> map = new HashMap<>();
|
||||
//获取该供应商的所有材料
|
||||
List<BusTenderPlanningLimitList> busTenderPlanningLimitLists = busTenderPlanningLimitListMapper.selectList(new LambdaQueryWrapper<BusTenderPlanningLimitList>().in(BusTenderPlanningLimitList::getBiddingPlanId, bplanIdds));
|
||||
for (BusTenderPlanningLimitList v : busTenderPlanningLimitLists) {
|
||||
if (!map.containsKey(v.getId())) {
|
||||
map.put(v.getId(), v.getNum());
|
||||
}else {
|
||||
map.put(v.getId(), map.get(v.getId()).add(v.getNum()));
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归构建树形结构
|
||||
* @param parentId 父节点ID(顶级节点为0)
|
||||
|
||||
@ -14,6 +14,7 @@ import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.utils.BatchNumberGenerator;
|
||||
import org.dromara.common.utils.excel.ExcelDynamicReader;
|
||||
import org.dromara.tender.domain.BusBLimitListVersions;
|
||||
import org.dromara.tender.domain.BusBillofquantitiesLimitList;
|
||||
@ -124,6 +125,9 @@ public class BusBillofquantitiesLimitListServiceImpl extends ServiceImpl<BusBill
|
||||
@Override
|
||||
public Boolean insertByBo(BusBillofquantitiesLimitListBo bo) {
|
||||
BusBillofquantitiesLimitList add = MapstructUtils.convert(bo, BusBillofquantitiesLimitList.class);
|
||||
String banBen = BatchNumberGenerator.generateBatchNumber("GCLBB-");
|
||||
add.setSid(banBen);
|
||||
add.setType("3");
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
@ -152,7 +156,14 @@ public class BusBillofquantitiesLimitListServiceImpl extends ServiceImpl<BusBill
|
||||
if (bo.getVersions() == null) {
|
||||
throw new ServiceException("版本号不能为空");
|
||||
}
|
||||
|
||||
// BusBillofquantitiesLimitList limitList = baseMapper.selectById(bo.getId());
|
||||
// BusBLimitListVersionsVo vo = busBLimitListVersionsService.queryByVersion(limitList.getVersions());
|
||||
// if (limitList == null) {
|
||||
// throw new ServiceException("修改数据不存在");
|
||||
// }
|
||||
// if (!BusinessStatusEnum.DRAFT.getStatus().equals(vo.getStatus()) && !(bo.getQuantity().compareTo(limitList.getQuantity()) > 0)) {
|
||||
// throw new ServiceException("数量只能增加不能减少");
|
||||
// }
|
||||
BusBillofquantitiesLimitList update = MapstructUtils.convert(bo, BusBillofquantitiesLimitList.class);
|
||||
if (bo.getUnitPrice() == null){
|
||||
update.setUnitPrice(null);
|
||||
@ -171,6 +182,19 @@ public class BusBillofquantitiesLimitListServiceImpl extends ServiceImpl<BusBill
|
||||
*/
|
||||
private void validEntityBeforeSave(BusBillofquantitiesLimitList entity) {
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
// Long count = baseMapper.selectCount(new LambdaQueryWrapper<BusBillofquantitiesLimitList>()
|
||||
// .eq(BusBillofquantitiesLimitList::getVersions,entity.getVersions())
|
||||
// .eq(BusBillofquantitiesLimitList::getName, entity.getName())
|
||||
// .eq(BusBillofquantitiesLimitList::getSpecification, entity.getSpecification())
|
||||
// .eq(BusBillofquantitiesLimitList::getUnit, entity.getUnit())
|
||||
// .eq(BusBillofquantitiesLimitList::getSupplier, entity.getSupplier())
|
||||
// .eq(BusBillofquantitiesLimitList::getContractNumber, entity.getContractNumber())
|
||||
// .eq(BusBillofquantitiesLimitList::getProjectId, entity.getProjectId())
|
||||
// .ne(entity.getId() != null, BusBillofquantitiesLimitList::getId, entity.getId()));
|
||||
// if (count > 0) {
|
||||
// throw new ServiceException("该名称-规格-单位-供应商-合同编号的数据以存在!!!");
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -184,6 +208,17 @@ public class BusBillofquantitiesLimitListServiceImpl extends ServiceImpl<BusBill
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if (isValid) {
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
// List<BusBillofquantitiesLimitListVo> listVoList = baseMapper.selectVoByIds(ids);
|
||||
// Set<String> vlist = new HashSet<>();
|
||||
// for (BusBillofquantitiesLimitListVo vo : listVoList) {
|
||||
// vlist.add(vo.getVersions());
|
||||
// }
|
||||
// for (String v : vlist) {
|
||||
// BusBLimitListVersionsVo vo = busBLimitListVersionsService.queryByVersion(v);
|
||||
// if (vo != null && !BusinessStatusEnum.DRAFT.getStatus().equals(vo.getStatus())) {
|
||||
// throw new ServiceException("该版本已经进入审核不允许再删除");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
@ -323,6 +358,16 @@ public class BusBillofquantitiesLimitListServiceImpl extends ServiceImpl<BusBill
|
||||
return wuZiVoArrayList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BusBillofquantitiesLimitListVo> pList(BusBillofquantitiesLimitListBo bo) {
|
||||
List<BusBillofquantitiesLimitListVo> listVoList = baseMapper.selectVoList(new LambdaQueryWrapper<BusBillofquantitiesLimitList>()
|
||||
.eq(BusBillofquantitiesLimitList::getPid, "0")
|
||||
.eq(BusBillofquantitiesLimitList::getProjectId, bo.getProjectId())
|
||||
.eq(BusBillofquantitiesLimitList::getType, bo.getType())
|
||||
.eq(BusBillofquantitiesLimitList::getVersions, bo.getVersions()));
|
||||
return listVoList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归构建树形结构
|
||||
*
|
||||
|
||||
@ -34,6 +34,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
WHEN #{item.id} THEN #{item.taxRate}
|
||||
</foreach>
|
||||
ELSE tax_rate
|
||||
END,
|
||||
quantity = CASE id
|
||||
<foreach collection="list" item="item">
|
||||
WHEN #{item.id} THEN #{item.quantity}
|
||||
</foreach>
|
||||
ELSE quantity
|
||||
END
|
||||
WHERE id IN
|
||||
<foreach collection="list" item="item" open="(" separator="," close=")">
|
||||
|
||||
Reference in New Issue
Block a user