|
|
|
@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
import digital.laboratory.platform.common.mybatis.security.service.DLPUser; |
|
|
|
|
import digital.laboratory.platform.reagent.constans.ReagentStatusConstants; |
|
|
|
|
import digital.laboratory.platform.reagent.dto.AuditAndApproveDTO; |
|
|
|
|
import digital.laboratory.platform.reagent.dto.PurchasingPlanDTO; |
|
|
|
|
import digital.laboratory.platform.reagent.entity.*; |
|
|
|
@ -26,6 +27,8 @@ import javax.servlet.http.HttpServletResponse; |
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* (采购计划)服务实现类 |
|
|
|
@ -89,93 +92,131 @@ public class PurchasingPlanServiceImpl extends ServiceImpl<PurchasingPlanMapper, |
|
|
|
|
|
|
|
|
|
List<CentralizedRequest> centralizedRequestList = requestService.list(Wrappers.<CentralizedRequest>query().in("id", idList)); |
|
|
|
|
|
|
|
|
|
List<DetailsOfCentralized> detailsOfCentralizedAllList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
for (CentralizedRequest centralizedRequest : centralizedRequestList) { |
|
|
|
|
List<DetailsOfCentralized> detailsOfCentralizedList = detailsOfCentralizedService.list(Wrappers.<DetailsOfCentralized>query().eq("centralized_request_id", centralizedRequest.getId())); |
|
|
|
|
detailsOfCentralizedAllList.addAll(detailsOfCentralizedList); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PurchasingPlan purchasingPlan = new PurchasingPlan();//创建采购计划
|
|
|
|
|
purchasingPlan.setPurchasingPlanId(IdWorker.get32UUID().toUpperCase()); |
|
|
|
|
purchasingPlan.setCreateId(user.getId());//创建人ID
|
|
|
|
|
purchasingPlan.setStatus(0);//状态
|
|
|
|
|
purchasingPlan.setCreateName(user.getName());//创建人名称
|
|
|
|
|
List<ProcurementContent> list = new ArrayList<>();//需要整合的集合
|
|
|
|
|
boolean flag = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (DetailsOfCentralized detailsOfCentralized1 : detailsOfCentralizedAllList) { |
|
|
|
|
|
|
|
|
|
PurchasingPlanDTO purchasingPlanDTO = new PurchasingPlanDTO(); |
|
|
|
|
BeanUtils.copyProperties(detailsOfCentralized1, purchasingPlanDTO); |
|
|
|
|
purchasingPlanDTO.setDetailsOfCentralizedId(detailsOfCentralized1.getId()); |
|
|
|
|
//将列入计划的集中采购申请状态变为3
|
|
|
|
|
CentralizedRequest centralizedRequest = requestService.getById(detailsOfCentralizedService.getById(purchasingPlanDTO.getDetailsOfCentralizedId()).getCentralizedRequestId()); |
|
|
|
|
centralizedRequest.setStatus(3); |
|
|
|
|
List<String> requestIdList = new ArrayList<>(); |
|
|
|
|
List<DetailsOfCentralized> updateList = new ArrayList<>(); |
|
|
|
|
//更新采购申请信息
|
|
|
|
|
centralizedRequestList.forEach(centralizedRequest -> { |
|
|
|
|
requestIdList.add(centralizedRequest.getId()); |
|
|
|
|
centralizedRequest.setStatus(ReagentStatusConstants.CENTRALIZED_PURCHASING_TO_PLAN.getStatus()); |
|
|
|
|
centralizedRequest.setPurchasingPlanId(purchasingPlan.getPurchasingPlanId()); |
|
|
|
|
requestService.updateById(centralizedRequest); |
|
|
|
|
|
|
|
|
|
DetailsOfCentralized detailsOfCentralized = detailsOfCentralizedService.getById(purchasingPlanDTO.getDetailsOfCentralizedId());//集中采购申请明细
|
|
|
|
|
ReagentConsumables reagentConsumables = reagentConsumablesService.getById(detailsOfCentralized.getReagentConsumableId());//试剂耗材信息
|
|
|
|
|
|
|
|
|
|
flag = true; |
|
|
|
|
//合并相同的采购内容,若存在相同的采购物品,则无需创建计划明细,将采购申请明细与该计划明细关联即可
|
|
|
|
|
if (list.size() != 0) { |
|
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
|
if (list.get(i).getReagentConsumableId().equals(purchasingPlanDTO.getReagentConsumableId())) { |
|
|
|
|
list.get(i).setUnitPrice(reagentConsumables.getUnitPrice());//获取单价
|
|
|
|
|
//Set采购数量
|
|
|
|
|
list.get(i).setQuantityPurchased(list.get(i).getQuantityPurchased() + purchasingPlanDTO.getNumberOfApplications());//合并之前的数量加上被合并对象的数量
|
|
|
|
|
list.get(i).setSubtotal(list.get(i).getQuantityPurchased() * list.get(i).getUnitPrice());//计算小计
|
|
|
|
|
//添加采购申请明细的采购数量
|
|
|
|
|
detailsOfCentralized.setQuantityPurchased(detailsOfCentralized.getNumberOfApplications()); |
|
|
|
|
detailsOfCentralized.setProcurementContentId(list.get(i).getProcurementContentId()); |
|
|
|
|
detailsOfCentralizedService.updateById(detailsOfCentralized); |
|
|
|
|
//被合并后,改变flag,进入下一个循环
|
|
|
|
|
flag = false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//无需合并的采购计划明细
|
|
|
|
|
if (flag) { |
|
|
|
|
ProcurementContent procurementContent = new ProcurementContent();//新建计划明细
|
|
|
|
|
BeanUtils.copyProperties(purchasingPlanDTO, procurementContent);//拷贝
|
|
|
|
|
procurementContent.setProcurementContentId(IdWorker.get32UUID().toUpperCase()); |
|
|
|
|
procurementContent.setPurchasingPlanId(purchasingPlan.getPurchasingPlanId());//关联计划ID
|
|
|
|
|
procurementContent.setQuantityPurchased(purchasingPlanDTO.getNumberOfApplications());//赋值采购数量
|
|
|
|
|
detailsOfCentralized.setQuantityPurchased(detailsOfCentralized.getNumberOfApplications());//赋值采购数量
|
|
|
|
|
procurementContent.setUnitPrice(reagentConsumables.getUnitPrice());//单价
|
|
|
|
|
procurementContent.setSubtotal(procurementContent.getUnitPrice() * procurementContent.getQuantityPurchased());//小计
|
|
|
|
|
detailsOfCentralized.setProcurementContentId(procurementContent.getProcurementContentId());//采购申请明细关联采购计划明细
|
|
|
|
|
detailsOfCentralizedService.updateById(detailsOfCentralized); |
|
|
|
|
list.add(procurementContent);//将计划明细添加至集合
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} else {//对于首次循环,List一定为空,故执行下列语句,且只会执行一次
|
|
|
|
|
ProcurementContent procurementContent = new ProcurementContent(); |
|
|
|
|
BeanUtils.copyProperties(purchasingPlanDTO, procurementContent); |
|
|
|
|
DetailsOfCentralized byId = detailsOfCentralizedService.getById(purchasingPlanDTO.getDetailsOfCentralizedId()); |
|
|
|
|
byId.setQuantityPurchased(byId.getNumberOfApplications()); |
|
|
|
|
}); |
|
|
|
|
requestService.updateBatchById(centralizedRequestList); |
|
|
|
|
List<DetailsOfCentralized> detailsOfCentralizeds = detailsOfCentralizedService.list(Wrappers.<DetailsOfCentralized>lambdaQuery().in(DetailsOfCentralized::getCentralizedRequestId, requestIdList)); |
|
|
|
|
// boolean flag = true;
|
|
|
|
|
Map<String, List<DetailsOfCentralized>> map = detailsOfCentralizeds.stream().collect(Collectors.groupingBy(item -> item.getReagentConsumableId())); |
|
|
|
|
map.forEach((key, value) -> { |
|
|
|
|
//证明有重复购买的物品,需要合并
|
|
|
|
|
if (value.size() > 1) { |
|
|
|
|
ProcurementContent procurementContent = new ProcurementContent();//新建计划明细
|
|
|
|
|
fillData(procurementContent, value.get(0)); |
|
|
|
|
procurementContent.setProcurementContentId(IdWorker.get32UUID().toUpperCase()); |
|
|
|
|
procurementContent.setPurchasingPlanId(purchasingPlan.getPurchasingPlanId()); |
|
|
|
|
procurementContent.setPurchasingPlanId(purchasingPlan.getPurchasingPlanId());//关联计划ID
|
|
|
|
|
procurementContent.setQuantityPurchased(0); |
|
|
|
|
procurementContent.setNumberOfApplications(0); |
|
|
|
|
value.forEach(detailsOfCentralized -> { |
|
|
|
|
detailsOfCentralized.setProcurementContentId(procurementContent.getProcurementContentId()); |
|
|
|
|
detailsOfCentralized.setQuantityPurchased(detailsOfCentralized.getNumberOfApplications()); |
|
|
|
|
updateList.add(detailsOfCentralized); |
|
|
|
|
procurementContent.setQuantityPurchased(procurementContent.getQuantityPurchased() + detailsOfCentralized.getQuantityPurchased()); |
|
|
|
|
}); |
|
|
|
|
procurementContent.setNumberOfApplications(procurementContent.getQuantityPurchased()); |
|
|
|
|
procurementContent.setSubtotal(procurementContent.getUnitPrice() * procurementContent.getQuantityPurchased()); |
|
|
|
|
list.add(procurementContent);//将计划明细添加至集合
|
|
|
|
|
} else { |
|
|
|
|
DetailsOfCentralized detailsOfCentralized = value.get(0); |
|
|
|
|
ProcurementContent procurementContent = new ProcurementContent();//新建计划明细
|
|
|
|
|
procurementContent.setProcurementContentId(IdWorker.get32UUID().toUpperCase()); |
|
|
|
|
procurementContent.setPurchasingPlanId(purchasingPlan.getPurchasingPlanId());//关联计划ID
|
|
|
|
|
fillData(procurementContent, detailsOfCentralized); |
|
|
|
|
procurementContent.setQuantityPurchased(procurementContent.getNumberOfApplications()); |
|
|
|
|
procurementContent.setUnitPrice(reagentConsumables.getUnitPrice()); |
|
|
|
|
procurementContent.setSubtotal(procurementContent.getQuantityPurchased() * procurementContent.getUnitPrice()); |
|
|
|
|
byId.setProcurementContentId(procurementContent.getProcurementContentId()); |
|
|
|
|
detailsOfCentralizedService.updateById(byId); |
|
|
|
|
list.add(procurementContent); |
|
|
|
|
detailsOfCentralized.setProcurementContentId(procurementContent.getProcurementContentId()); |
|
|
|
|
detailsOfCentralized.setQuantityPurchased(detailsOfCentralized.getNumberOfApplications()); |
|
|
|
|
procurementContent.setSubtotal(procurementContent.getUnitPrice() * procurementContent.getQuantityPurchased()); |
|
|
|
|
list.add(procurementContent);//将计划明细添加至集合
|
|
|
|
|
updateList.add(detailsOfCentralized); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (this.save(purchasingPlan) & procurementContentService.saveBatch(list)) { |
|
|
|
|
calculatedAmount(purchasingPlan.getPurchasingPlanId());//计算经费预算
|
|
|
|
|
}); |
|
|
|
|
// for (DetailsOfCentralized detailsOfCentralized1 : detailsOfCentralizedAllList) {
|
|
|
|
|
// PurchasingPlanDTO purchasingPlanDTO = new PurchasingPlanDTO();
|
|
|
|
|
// BeanUtils.copyProperties(detailsOfCentralized1, purchasingPlanDTO);
|
|
|
|
|
// purchasingPlanDTO.setDetailsOfCentralizedId(detailsOfCentralized1.getId());
|
|
|
|
|
// //将列入计划的集中采购申请状态变为3
|
|
|
|
|
// CentralizedRequest centralizedRequest = requestService.getById(detailsOfCentralizedService.getById(purchasingPlanDTO.getDetailsOfCentralizedId()).getCentralizedRequestId());
|
|
|
|
|
// centralizedRequest.setStatus(3);
|
|
|
|
|
// centralizedRequest.setPurchasingPlanId(purchasingPlan.getPurchasingPlanId());
|
|
|
|
|
// requestService.updateById(centralizedRequest);
|
|
|
|
|
//
|
|
|
|
|
// DetailsOfCentralized detailsOfCentralized = detailsOfCentralizedService.getById(purchasingPlanDTO.getDetailsOfCentralizedId());//集中采购申请明细
|
|
|
|
|
// ReagentConsumables reagentConsumables = reagentConsumablesService.getById(detailsOfCentralized.getReagentConsumableId());//试剂耗材信息
|
|
|
|
|
//
|
|
|
|
|
// flag = true;
|
|
|
|
|
// //合并相同的采购内容,若存在相同的采购物品,则无需创建计划明细,将采购申请明细与该计划明细关联即可
|
|
|
|
|
// if (list.size() != 0) {
|
|
|
|
|
// for (int i = 0; i < list.size(); i++) {
|
|
|
|
|
// if (list.get(i).getReagentConsumableId().equals(purchasingPlanDTO.getReagentConsumableId())) {
|
|
|
|
|
// list.get(i).setUnitPrice(reagentConsumables.getUnitPrice());//获取单价
|
|
|
|
|
// //Set采购数量
|
|
|
|
|
// list.get(i).setQuantityPurchased(list.get(i).getQuantityPurchased() + purchasingPlanDTO.getNumberOfApplications());//合并之前的数量加上被合并对象的数量
|
|
|
|
|
// list.get(i).setSubtotal(list.get(i).getQuantityPurchased() * list.get(i).getUnitPrice());//计算小计
|
|
|
|
|
// //添加采购申请明细的采购数量
|
|
|
|
|
// detailsOfCentralized.setQuantityPurchased(detailsOfCentralized.getNumberOfApplications());
|
|
|
|
|
// detailsOfCentralized.setProcurementContentId(list.get(i).getProcurementContentId());
|
|
|
|
|
// detailsOfCentralizedService.updateById(detailsOfCentralized);
|
|
|
|
|
// //被合并后,改变flag,进入下一个循环
|
|
|
|
|
// flag = false;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// //无需合并的采购计划明细
|
|
|
|
|
// if (flag) {
|
|
|
|
|
// ProcurementContent procurementContent = new ProcurementContent();//新建计划明细
|
|
|
|
|
// BeanUtils.copyProperties(purchasingPlanDTO, procurementContent);//拷贝
|
|
|
|
|
// procurementContent.setProcurementContentId(IdWorker.get32UUID().toUpperCase());
|
|
|
|
|
// procurementContent.setPurchasingPlanId(purchasingPlan.getPurchasingPlanId());//关联计划ID
|
|
|
|
|
// procurementContent.setQuantityPurchased(purchasingPlanDTO.getNumberOfApplications());//赋值采购数量
|
|
|
|
|
// detailsOfCentralized.setQuantityPurchased(detailsOfCentralized.getNumberOfApplications());//赋值采购数量
|
|
|
|
|
// procurementContent.setUnitPrice(reagentConsumables.getUnitPrice());//单价
|
|
|
|
|
// procurementContent.setSubtotal(procurementContent.getUnitPrice() * procurementContent.getQuantityPurchased());//小计
|
|
|
|
|
// detailsOfCentralized.setProcurementContentId(procurementContent.getProcurementContentId());//采购申请明细关联采购计划明细
|
|
|
|
|
// detailsOfCentralizedService.updateById(detailsOfCentralized);
|
|
|
|
|
// list.add(procurementContent);//将计划明细添加至集合
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// } else {//对于首次循环,List一定为空,故执行下列语句,且只会执行一次
|
|
|
|
|
// ProcurementContent procurementContent = new ProcurementContent();
|
|
|
|
|
// BeanUtils.copyProperties(purchasingPlanDTO, procurementContent);
|
|
|
|
|
// DetailsOfCentralized byId = detailsOfCentralizedService.getById(purchasingPlanDTO.getDetailsOfCentralizedId());
|
|
|
|
|
// byId.setQuantityPurchased(byId.getNumberOfApplications());
|
|
|
|
|
// procurementContent.setProcurementContentId(IdWorker.get32UUID().toUpperCase());
|
|
|
|
|
// procurementContent.setPurchasingPlanId(purchasingPlan.getPurchasingPlanId());
|
|
|
|
|
// procurementContent.setQuantityPurchased(procurementContent.getNumberOfApplications());
|
|
|
|
|
// procurementContent.setUnitPrice(reagentConsumables.getUnitPrice());
|
|
|
|
|
// procurementContent.setSubtotal(procurementContent.getQuantityPurchased() * procurementContent.getUnitPrice());
|
|
|
|
|
// byId.setProcurementContentId(procurementContent.getProcurementContentId());
|
|
|
|
|
// detailsOfCentralizedService.updateById(byId);
|
|
|
|
|
// list.add(procurementContent);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
if (this.save(purchasingPlan) & procurementContentService.saveBatch(list) && detailsOfCentralizedService.updateBatchById(updateList)) { |
|
|
|
|
calculatedAmount(purchasingPlan, list);//计算经费预算
|
|
|
|
|
PurchasingPlanVO purchasingPlanVO = this.getPurchasingPlanVO(purchasingPlan.getPurchasingPlanId());//获取VO
|
|
|
|
|
return purchasingPlanVO; |
|
|
|
|
} else throw new RuntimeException(String.format("保存失败")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void fillData(ProcurementContent procurementContent, DetailsOfCentralized detailsOfCentralized) { |
|
|
|
|
BeanUtils.copyProperties(detailsOfCentralized, procurementContent); |
|
|
|
|
ReagentConsumables reagentConsumables = reagentConsumablesService.getById(detailsOfCentralized.getReagentConsumableId()); |
|
|
|
|
procurementContent.setUnitPrice(reagentConsumables.getUnitPrice()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Transactional |
|
|
|
|
@Override//创建计划
|
|
|
|
|
public PurchasingPlanVO addById(List<PurchasingPlanDTO> purchasingPlanDTOList, DLPUser user) { |
|
|
|
@ -254,7 +295,7 @@ public class PurchasingPlanServiceImpl extends ServiceImpl<PurchasingPlanMapper, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (this.save(purchasingPlan) & procurementContentService.saveBatch(list)) { |
|
|
|
|
calculatedAmount(purchasingPlan.getPurchasingPlanId());//计算经费预算
|
|
|
|
|
calculatedAmount(purchasingPlan, list);//计算经费预算
|
|
|
|
|
PurchasingPlanVO purchasingPlanVO = this.getPurchasingPlanVO(purchasingPlan.getPurchasingPlanId());//获取VO
|
|
|
|
|
return purchasingPlanVO; |
|
|
|
|
} else throw new RuntimeException(String.format("保存失败")); |
|
|
|
@ -277,28 +318,19 @@ public class PurchasingPlanServiceImpl extends ServiceImpl<PurchasingPlanMapper, |
|
|
|
|
@Override |
|
|
|
|
@Transactional//修改采购计划明细(已废弃)
|
|
|
|
|
public ProcurementContent editById(PurchasingPlanDTO purchasingPlanDTO) { |
|
|
|
|
|
|
|
|
|
ProcurementContent byId = procurementContentService.getById(purchasingPlanDTO.getProcurementContentId()); |
|
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(purchasingPlanDTO, byId); |
|
|
|
|
|
|
|
|
|
byId.setSubtotal(byId.getUnitPrice() * byId.getQuantityPurchased()); |
|
|
|
|
|
|
|
|
|
LambdaQueryWrapper<DetailsOfCentralized> detailsOfCentralizedLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
|
|
|
|
|
detailsOfCentralizedLambdaQueryWrapper.eq(DetailsOfCentralized::getId, byId.getDetailsOfCentralizedId()); |
|
|
|
|
|
|
|
|
|
DetailsOfCentralized detailsOfCentralized = detailsOfCentralizedService.getOne(detailsOfCentralizedLambdaQueryWrapper); |
|
|
|
|
|
|
|
|
|
detailsOfCentralized.setQuantityPurchased(byId.getQuantityPurchased()); |
|
|
|
|
|
|
|
|
|
procurementContentService.updateById(byId); |
|
|
|
|
|
|
|
|
|
//进行修改
|
|
|
|
|
ProcurementContent procurementContent = procurementContentService.getById(purchasingPlanDTO.getProcurementContentId()); |
|
|
|
|
PurchasingPlan purchasingPlan = this.getById(procurementContent.getPurchasingPlanId()); |
|
|
|
|
BeanUtils.copyProperties(purchasingPlanDTO, procurementContent); |
|
|
|
|
procurementContent.setSubtotal(procurementContent.getUnitPrice() * procurementContent.getQuantityPurchased()); |
|
|
|
|
//需要修改采购申请的实际采购数量
|
|
|
|
|
DetailsOfCentralized detailsOfCentralized = detailsOfCentralizedService.getOne(Wrappers.<DetailsOfCentralized>lambdaQuery().eq(DetailsOfCentralized::getProcurementContentId, procurementContent.getProcurementContentId())); |
|
|
|
|
detailsOfCentralized.setQuantityPurchased(procurementContent.getQuantityPurchased()); |
|
|
|
|
procurementContentService.updateById(procurementContent); |
|
|
|
|
detailsOfCentralizedService.updateById(detailsOfCentralized); |
|
|
|
|
|
|
|
|
|
calculatedAmount(byId.getPurchasingPlanId()); |
|
|
|
|
|
|
|
|
|
return byId; |
|
|
|
|
//计算修改后的经费
|
|
|
|
|
calculatedAmount(purchasingPlan,procurementContentService.list(Wrappers.<ProcurementContent>lambdaQuery().eq(ProcurementContent::getPurchasingPlanId, purchasingPlan.getPurchasingPlanId()))); |
|
|
|
|
return procurementContent; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -308,17 +340,12 @@ public class PurchasingPlanServiceImpl extends ServiceImpl<PurchasingPlanMapper, |
|
|
|
|
public ProcurementContent editDetails(PurchasingPlanDTO purchasingPlanDTO) { |
|
|
|
|
|
|
|
|
|
ProcurementContent procurementContent = procurementContentService.getById(purchasingPlanDTO.getProcurementContentId());//得到计划明细
|
|
|
|
|
|
|
|
|
|
procurementContent.setUnitPrice(purchasingPlanDTO.getUnitPrice());//得到修改的明细单价
|
|
|
|
|
|
|
|
|
|
PurchasingPlan purchasingPlan = this.getById(procurementContent.getPurchasingPlanId());//查询出采购计划
|
|
|
|
|
|
|
|
|
|
DetailsOfCentralized detailsOfCentralized = detailsOfCentralizedService.getById(purchasingPlanDTO.getDetailsOfCentralizedId());//获取修改的对应的采购申请明细
|
|
|
|
|
|
|
|
|
|
if (detailsOfCentralized.getQuantityPurchased() == null) { |
|
|
|
|
//原本合并总数量-采购申请明细数量+采购申请明细修改后的数量
|
|
|
|
|
procurementContent.setQuantityPurchased(procurementContent.getQuantityPurchased() - detailsOfCentralized.getNumberOfApplications() + purchasingPlanDTO.getQuantityPurchased()); |
|
|
|
|
|
|
|
|
|
} else {//原本合并总数量-采购申请修改后的采购数量+修改数量
|
|
|
|
|
procurementContent.setQuantityPurchased(procurementContent.getQuantityPurchased() - detailsOfCentralized.getQuantityPurchased() + purchasingPlanDTO.getQuantityPurchased()); |
|
|
|
|
} |
|
|
|
@ -327,7 +354,8 @@ public class PurchasingPlanServiceImpl extends ServiceImpl<PurchasingPlanMapper, |
|
|
|
|
detailsOfCentralized.setDetailsRemark(purchasingPlanDTO.getPlanRemark());//修改备注
|
|
|
|
|
|
|
|
|
|
if (procurementContentService.updateById(procurementContent) && detailsOfCentralizedService.updateById(detailsOfCentralized)) { |
|
|
|
|
calculatedAmount(procurementContent.getPurchasingPlanId());//计算经费预算
|
|
|
|
|
//计算经费
|
|
|
|
|
calculatedAmount(purchasingPlan,procurementContentService.list(Wrappers.<ProcurementContent>lambdaQuery().eq(ProcurementContent::getPurchasingPlanId, purchasingPlan.getPurchasingPlanId()))); |
|
|
|
|
return procurementContent; |
|
|
|
|
} else throw new RuntimeException(String.format("修改失败")); |
|
|
|
|
} |
|
|
|
@ -347,14 +375,13 @@ public class PurchasingPlanServiceImpl extends ServiceImpl<PurchasingPlanMapper, |
|
|
|
|
|
|
|
|
|
if (this.getById(procurementContent.getPurchasingPlanId()).getStatus() == 0 |
|
|
|
|
&& detailsOfCentralizedService.updateBatchById(list) && procurementContentService.removeById(procurementContentId)) { |
|
|
|
|
|
|
|
|
|
List<ProcurementContent> procurementContentList = procurementContentService.list(Wrappers.<ProcurementContent>query().eq("purchasing_plan_id", purchasingPlan.getPurchasingPlanId())); |
|
|
|
|
//如果采购计划的明细全部被删除,则自动删除这个采购计划
|
|
|
|
|
if (procurementContentList.size() == 0) { |
|
|
|
|
this.removeById(purchasingPlan); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
calculatedAmount(procurementContent.getPurchasingPlanId());//计算经费预算
|
|
|
|
|
calculatedAmount(purchasingPlan,procurementContentService.list(Wrappers.<ProcurementContent>lambdaQuery().eq(ProcurementContent::getPurchasingPlanId, purchasingPlan.getPurchasingPlanId()))); |
|
|
|
|
return true; |
|
|
|
|
} else { |
|
|
|
|
return null; |
|
|
|
@ -446,7 +473,7 @@ public class PurchasingPlanServiceImpl extends ServiceImpl<PurchasingPlanMapper, |
|
|
|
|
purchasingPlan.setStatus(1); |
|
|
|
|
purchasingPlan.setCommitTime(LocalDateTime.now());//
|
|
|
|
|
if (this.updateById(purchasingPlan)) { |
|
|
|
|
calculatedAmount(purchasingPlan.getPurchasingPlanId()); |
|
|
|
|
calculatedAmount(purchasingPlan,procurementContentService.list(Wrappers.<ProcurementContent>lambdaQuery().eq(ProcurementContent::getPurchasingPlanId, purchasingPlan.getPurchasingPlanId()))); |
|
|
|
|
return purchasingPlan; |
|
|
|
|
} else throw new RuntimeException(String.format("提交失败")); |
|
|
|
|
|
|
|
|
@ -508,21 +535,13 @@ public class PurchasingPlanServiceImpl extends ServiceImpl<PurchasingPlanMapper, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//计算经费预算方法
|
|
|
|
|
public PurchasingPlan calculatedAmount(String purchasingPlanId) { |
|
|
|
|
|
|
|
|
|
PurchasingPlan purchasingPlan = this.getById(purchasingPlanId);//采购计划
|
|
|
|
|
|
|
|
|
|
LambdaQueryWrapper<ProcurementContent> procurementContentLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
procurementContentLambdaQueryWrapper.eq(ProcurementContent::getPurchasingPlanId, purchasingPlan.getPurchasingPlanId()); |
|
|
|
|
List<ProcurementContent> list = procurementContentService.list(procurementContentLambdaQueryWrapper);//这个采购计划内的所有采购计划明细
|
|
|
|
|
double x = 0; |
|
|
|
|
public PurchasingPlan calculatedAmount(PurchasingPlan purchasingPlan, List<ProcurementContent> procurementContentList) { |
|
|
|
|
double appropriationBudget = 0d; |
|
|
|
|
//计算每个采购计划明细的小计(单价*采购数量)
|
|
|
|
|
for ( |
|
|
|
|
ProcurementContent procurementContent : list) { |
|
|
|
|
x = x + procurementContent.getQuantityPurchased() * procurementContent.getUnitPrice(); |
|
|
|
|
for (ProcurementContent procurementContent : procurementContentList) { |
|
|
|
|
appropriationBudget = appropriationBudget + procurementContent.getQuantityPurchased() * procurementContent.getUnitPrice(); |
|
|
|
|
} |
|
|
|
|
purchasingPlan.setAppropriationBudget(x);//经费预算
|
|
|
|
|
|
|
|
|
|
purchasingPlan.setAppropriationBudget(appropriationBudget);//经费预算
|
|
|
|
|
if (this.updateById(purchasingPlan)) { |
|
|
|
|
return purchasingPlan; |
|
|
|
|
} else throw new RuntimeException(String.format("计算失败")); |
|
|
|
|