From 8f94eef5f3a6f302955b54481215a16a08ff6987 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=B5=B7=E8=88=AA?= <1344638791@qq.com> Date: Sun, 13 Aug 2023 09:01:10 +0800 Subject: [PATCH] update --- .../ReagentConsumableInventoryController.java | 10 +- .../service/PurchasingPlanService.java | 8 +- .../impl/CentralizedRequestServiceImpl.java | 12 +- .../impl/PurchasingPlanServiceImpl.java | 126 ++++++++++++++++-- .../platform/reagent/vo/OrgFullVO.java | 12 ++ .../laboratory/platform/reagent/vo/OrgVO.java | 15 +++ .../ReagentConsumableInventoryMapper.xml | 12 +- 7 files changed, 165 insertions(+), 30 deletions(-) create mode 100644 src/main/java/digital/laboratory/platform/reagent/vo/OrgFullVO.java create mode 100644 src/main/java/digital/laboratory/platform/reagent/vo/OrgVO.java diff --git a/src/main/java/digital/laboratory/platform/reagent/controller/ReagentConsumableInventoryController.java b/src/main/java/digital/laboratory/platform/reagent/controller/ReagentConsumableInventoryController.java index 8f8ac4d..207d235 100644 --- a/src/main/java/digital/laboratory/platform/reagent/controller/ReagentConsumableInventoryController.java +++ b/src/main/java/digital/laboratory/platform/reagent/controller/ReagentConsumableInventoryController.java @@ -146,32 +146,38 @@ public class ReagentConsumableInventoryController { @ApiOperation(value = "试剂耗材管理列表", notes = "试剂耗材管理列表") @GetMapping("/List") // @PreAuthorize("@pms.hasPermission('reagent_reagent_consumable_inventory_get')") - public R> getList(Page page, String reagentConsumableName, Integer warning, String remark, HttpServletRequest theHttpServletRequest) { + public R> getList(Page page, String reagentConsumableName, Integer warning, String remark, String category,HttpServletRequest theHttpServletRequest) { Principal principal = theHttpServletRequest.getUserPrincipal(); DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal(); IPage reagentConsumableInventoryRMVOList = reagentConsumableInventoryService.getReagentConsumableInventoryREVOList(page, Wrappers.query() .like(StrUtil.isNotBlank(reagentConsumableName), "reagent_consumable_name", reagentConsumableName) + .like(StrUtil.isNotBlank(category), "category", category) .like(warning != null && warning == 1, "warning_information", "库存不足") .eq("category", "试剂").or() .like(StrUtil.isNotBlank(reagentConsumableName), "remark", reagentConsumableName) + .like(StrUtil.isNotBlank(category), "category", category) .like(warning != null && warning == 1, "warning_information", "库存不足") .eq("category", "试剂").or() .like(StrUtil.isNotBlank(reagentConsumableName), "reagent_consumable_name", reagentConsumableName) + .like(StrUtil.isNotBlank(category), "category", category) .like(warning != null && warning == 1, "warning_information", "库存不足") .eq("category", "耗材").or() .like(StrUtil.isNotBlank(reagentConsumableName), "remark", reagentConsumableName) + .like(StrUtil.isNotBlank(category), "category", category) .like(warning != null && warning == 1, "warning_information", "库存不足") .eq("category", "耗材").or() .like(StrUtil.isNotBlank(reagentConsumableName), "reagent_consumable_name", reagentConsumableName) + .like(StrUtil.isNotBlank(category), "category", category) .like(warning != null && warning == 1, "species", "库存不足") .eq("category", "试剂").or() .like(StrUtil.isNotBlank(reagentConsumableName), "remark", reagentConsumableName) + .like(StrUtil.isNotBlank(category), "category", category) .like(warning != null && warning == 1, "species", "库存不足") .eq("category", "耗材").or(), warning); return R.ok(reagentConsumableInventoryRMVOList); @@ -276,8 +282,6 @@ public class ReagentConsumableInventoryController { public String getBarCodeImageBase64(String code, HttpServletResponse httpServletResponse) throws IOException { return reagentConsumableInventoryService.buildCodeLabelContent(code); - - } /** diff --git a/src/main/java/digital/laboratory/platform/reagent/service/PurchasingPlanService.java b/src/main/java/digital/laboratory/platform/reagent/service/PurchasingPlanService.java index ece5861..dd78990 100644 --- a/src/main/java/digital/laboratory/platform/reagent/service/PurchasingPlanService.java +++ b/src/main/java/digital/laboratory/platform/reagent/service/PurchasingPlanService.java @@ -31,10 +31,14 @@ public interface PurchasingPlanService extends IService { PurchasingPlanVO getPurchasingPlanVO (String purchasingPlanId); - @Transactional + PurchasingPlanVO addById(String[] idList, DLPUser user); + + //创建计划 PurchasingPlanVO addById(List purchasingPlanDTOList, DLPUser user); -// ProcurementContent addContent(PurchasingPlanDTO purchasingPlanDTO); + + + ProcurementContent addContent(PurchasingPlanDTO purchasingPlanDTO); ProcurementContent editById(PurchasingPlanDTO purchasingPlanDTO); diff --git a/src/main/java/digital/laboratory/platform/reagent/service/impl/CentralizedRequestServiceImpl.java b/src/main/java/digital/laboratory/platform/reagent/service/impl/CentralizedRequestServiceImpl.java index 2f6e1e7..2293ab0 100644 --- a/src/main/java/digital/laboratory/platform/reagent/service/impl/CentralizedRequestServiceImpl.java +++ b/src/main/java/digital/laboratory/platform/reagent/service/impl/CentralizedRequestServiceImpl.java @@ -252,12 +252,12 @@ public class CentralizedRequestServiceImpl extends ServiceImpl centralizedRequestVOArrayList = baseMapper.getVOList(qw); - for (CentralizedRequestVO centralizedRequestVO : centralizedRequestVOArrayList) { - - List detailsOfCentralizedVOList = detailsOfCentralizedService.getDetailsOfCentralizedVOList(centralizedRequestVO.getId()); - - centralizedRequestVO.setDetailsOfCentralizedVOList(detailsOfCentralizedVOList); - } +// for (CentralizedRequestVO centralizedRequestVO : centralizedRequestVOArrayList) { +// +// List detailsOfCentralizedVOList = detailsOfCentralizedService.getDetailsOfCentralizedVOList(centralizedRequestVO.getId()); +// +// centralizedRequestVO.setDetailsOfCentralizedVOList(detailsOfCentralizedVOList); +// } return centralizedRequestVOArrayList; } diff --git a/src/main/java/digital/laboratory/platform/reagent/service/impl/PurchasingPlanServiceImpl.java b/src/main/java/digital/laboratory/platform/reagent/service/impl/PurchasingPlanServiceImpl.java index 1f395f4..cb58d25 100644 --- a/src/main/java/digital/laboratory/platform/reagent/service/impl/PurchasingPlanServiceImpl.java +++ b/src/main/java/digital/laboratory/platform/reagent/service/impl/PurchasingPlanServiceImpl.java @@ -20,6 +20,7 @@ import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; + import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; @@ -80,6 +81,105 @@ public class PurchasingPlanServiceImpl extends ServiceImpl centralizedRequestList = requestService.list(Wrappers.query().in("id", idList)); + + List detailsOfCentralizedAllList = new ArrayList<>(); + + for (CentralizedRequest centralizedRequest : centralizedRequestList) { + List detailsOfCentralizedList = detailsOfCentralizedService.list(Wrappers.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 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); + 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)) { + calculatedAmount(purchasingPlan.getPurchasingPlanId());//计算经费预算 + PurchasingPlanVO purchasingPlanVO = this.getPurchasingPlanVO(purchasingPlan.getPurchasingPlanId());//获取VO + return purchasingPlanVO; + } else throw new RuntimeException(String.format("保存失败")); + } + @Transactional @Override//创建计划 public PurchasingPlanVO addById(List purchasingPlanDTOList, DLPUser user) { @@ -164,19 +264,19 @@ public class PurchasingPlanServiceImpl extends ServiceImpl -