瀏覽代碼

采购暂存

yzc 11 月之前
父節點
當前提交
7a074d8d2d

+ 1 - 1
hx-sale/src/main/java/com/fjhx/sale/controller/purchase/EhsdPurchaseController.java

@@ -60,7 +60,7 @@ public class EhsdPurchaseController {
      */
     @PostMapping("/add")
     public void add(@RequestBody EhsdPurchaseDto ehsdPurchaseDto) {
-        ehsdPurchaseService.add(ehsdPurchaseDto);
+        ehsdPurchaseService.addOrEdit(ehsdPurchaseDto);
     }
 
 

+ 6 - 116
hx-sale/src/main/java/com/fjhx/sale/flow/EhsdPurchaseFlow.java

@@ -1,40 +1,28 @@
 package com.fjhx.sale.flow;
 
-import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.dynamic.datasource.annotation.DSTransactional;
-import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.fjhx.area.utils.CustomizeAreaUtil;
 import com.fjhx.common.entity.AvailableStockBo;
 import com.fjhx.common.enums.CodingRuleEnum;
 import com.fjhx.common.enums.FlowStatusEnum1;
 import com.fjhx.common.service.coding.CodingRuleService;
 import com.fjhx.common.utils.Assert;
-import com.fjhx.file.entity.ObsFile;
-import com.fjhx.file.utils.ObsFileUtil;
 import com.fjhx.flow.core.FlowDelegate;
 import com.fjhx.flow.enums.FlowStatusEnum;
 import com.fjhx.item.enums.ProductAvailableRecordType;
 import com.fjhx.item.service.product.ProductInfoService;
 import com.fjhx.purchase.entity.purchase.enums.PurchaseDataResourceEnum;
 import com.fjhx.purchase.entity.purchase.enums.PurchaseStatusEnum;
-import com.fjhx.purchase.service.subscribe.SubscribeDetailService;
 import com.fjhx.sale.entity.contract.po.Contract;
 import com.fjhx.sale.entity.purchase.dto.EhsdPurchaseDto;
 import com.fjhx.sale.entity.purchase.po.EhsdPurchase;
 import com.fjhx.sale.entity.purchase.po.EhsdPurchaseProduct;
-import com.fjhx.sale.entity.purchase.po.EhsdPurchaseProject;
-import com.fjhx.sale.entity.sample.po.Sample;
-import com.fjhx.sale.mapper.purchase.EhsdPurchaseProductMapper;
 import com.fjhx.sale.service.contract.ContractService;
 import com.fjhx.sale.service.purchase.EhsdPurchaseProductService;
-import com.fjhx.sale.service.purchase.EhsdPurchaseProjectService;
 import com.fjhx.sale.service.purchase.EhsdPurchaseService;
 import com.fjhx.sale.service.sample.SampleService;
-import com.fjhx.wms.service.stock.StockWaitDetailsService;
-import com.fjhx.wms.service.stock.StockWaitService;
 import com.ruoyi.common.annotation.LogicIgnore;
 import com.ruoyi.common.core.domain.BasePo;
 import com.ruoyi.common.exception.ServiceException;
@@ -58,13 +46,8 @@ public class EhsdPurchaseFlow extends FlowDelegate {
 
     @Autowired
     private EhsdPurchaseService purchaseService;
-
     @Autowired
     private EhsdPurchaseProductService purchaseProductService;
-
-    @Autowired
-    private EhsdPurchaseProjectService purchaseProjectService;
-
     @Autowired
     private CodingRuleService codingRuleService;
     @Autowired
@@ -73,14 +56,6 @@ public class EhsdPurchaseFlow extends FlowDelegate {
     private SampleService sampleService;
     @Autowired
     private ProductInfoService productInfoService;
-    @Autowired
-    private StockWaitService stockWaitService;
-    @Autowired
-    private StockWaitDetailsService stockWaitDetailsService;
-    @Autowired
-    private EhsdPurchaseProductMapper purchaseProductMapper;
-    @Autowired
-    private SubscribeDetailService subscribeDetailService;
 
     @Override
     public String getFlowKey() {
@@ -98,19 +73,9 @@ public class EhsdPurchaseFlow extends FlowDelegate {
     public Long start(Long flowId, JSONObject submitData) {
         EhsdPurchaseDto purchase = submitData.toJavaObject(EhsdPurchaseDto.class);
 
-        if (ObjectUtil.isEmpty(purchase.getCurrency())) {
-            purchase.setCurrency("CNY");
-        }
-
-        purchase.setId(null);//清空id防止前端误传
         purchase.setFlowId(flowId);//赋值流程id
         purchase.setProcessInstanceId(getFlowKey());//赋值流程key
-
-        //赋值产品归属公司
-        Long companyId = purchase.getCompanyId();
-        if (ObjectUtil.isEmpty(companyId)) {
-            purchase.setCompanyId(SecurityUtils.getCompanyId());
-        }
+        purchase.setStatus(PurchaseStatusEnum.UNDER_REVIEW.getKey());
 
         Integer dataResource = purchase.getDataResource();
         if (ObjectUtils.isEmpty(dataResource)) {
@@ -127,19 +92,12 @@ public class EhsdPurchaseFlow extends FlowDelegate {
             Assert.notEmpty(contract, "查询不到合同信息,无法生成编号");
             long count = purchaseService.count(q -> q.eq(EhsdPurchase::getDataResourceId, contract.getId()));
             purchase.setCode(contract.getCode() + "-" + (count + 1));
-        } else if (2 == dataResource) {
-            //样品单 编号规则
-            Sample sample = sampleService.getById(purchase.getDataResourceId());
-            Assert.notEmpty(sample, "查询不到样品单信息,无法生成编号");
-            long count = purchaseService.count(q -> q.eq(EhsdPurchase::getDataResourceId, sample.getId()));
-            purchase.setCode(sample.getCode() + "-" + (count + 1));
         } else {
             throw new ServiceException("未知数据来源类型");
         }
 
         //公共代码
-        purchase = connStart(purchase);
-
+        purchaseService.addOrEdit(purchase);
 
         //回传单号给流程引擎
         submitData.put("code", purchase.getCode());
@@ -148,51 +106,6 @@ public class EhsdPurchaseFlow extends FlowDelegate {
         return purchase.getId();
     }
 
-
-    /**
-     * 公共代码块--发起
-     */
-    public EhsdPurchaseDto connStart(EhsdPurchaseDto purchase) {
-        //赋值城市省份信息
-        CustomizeAreaUtil.setAreaId(purchase);
-        purchase.setSellCityId(purchase.getCityId());
-        purchase.setSellCountryId(purchase.getCountryId());
-        purchase.setSellProvinceId(purchase.getProvinceId());
-
-
-        purchase.setStatus(PurchaseStatusEnum.UNDER_REVIEW.getKey());
-        String nickName = SecurityUtils.getLoginUser().getUser().getNickName();
-        purchase.setUserName(nickName);
-        purchaseService.saveOrUpdate(purchase);
-
-        List<EhsdPurchaseProduct> purchaseProductList = purchase.getPurchaseProductList();
-        List<EhsdPurchaseProject> purchaseProjectList = purchase.getPurchaseProjectList();
-
-        //防止空指针
-        purchaseProjectList = (purchaseProjectList == null ? new ArrayList<>() : purchaseProjectList);
-        purchaseProductList = (purchaseProductList == null ? new ArrayList<>() : purchaseProductList);
-
-        //产品(采购明细)
-        for (EhsdPurchaseProduct s : purchaseProductList) {
-            s.setId(ObjectUtils.isNotEmpty(s.getId()) ? s.getId() : IdWorker.getId());
-            s.setPurchaseId(purchase.getId());
-        }
-        //修改或删除数据
-        purchaseProductService.editLinked(purchaseProductList, EhsdPurchaseProduct::getPurchaseId, purchase.getId());
-
-        //收费项目
-        for (EhsdPurchaseProject s : purchaseProjectList) {
-            s.setPurchaseId(purchase.getId());
-        }
-        purchaseProjectService.editLinked(purchaseProjectList, EhsdPurchaseProject::getPurchaseId, purchase.getId());
-
-        //采购附件
-        List<ObsFile> fileList = purchase.getFileList();
-        ObsFileUtil.editFile(fileList, purchase.getId());
-
-        return purchase;
-    }
-
     /**
      * 结束流程
      *
@@ -226,30 +139,6 @@ public class EhsdPurchaseFlow extends FlowDelegate {
                 inOutBo.setQuantity(purchaseProduct.getQuantity());
                 inOutBoList.add(inOutBo);
             }
-
-//            //数据来源是合同
-//            if (Objects.equals(purchaseProduct.getDataResource(), PurchaseDataResourceEnum.DATA_RESOURCE_1.getKey())) {
-//                //获取采购,待采购信息
-//                Long subscribeDetailId = purchaseProduct.getSubscribeDetailId();
-//                BigDecimal purchaseSumCount = purchaseProductMapper.getPurchaseQuantitySumBySubscribeDetailId(subscribeDetailId);
-//                SubscribeDetail subscribeDetail = subscribeDetailService.getById(subscribeDetailId);
-//                Assert.notEmpty(subscribeDetail, "查询不到待采购信息!");
-//
-//                //已采购数量>待采购 本次超采量=已采购数量-待采购量-((已采购-本次采购)-待采购量)
-//                if (purchaseSumCount.compareTo(subscribeDetail.getCount()) > 0) {
-//                    //计算超采量
-//                    BigDecimal oldPurchaseCount = purchaseSumCount.subtract(purchaseProduct.getQuantity());//(已采购-本次采购)
-//                    BigDecimal subtract = oldPurchaseCount.subtract(subscribeDetail.getCount());//((已采购-本次采购)-待采购量)
-//                    BigDecimal exceedQuantity = purchaseSumCount.subtract(subscribeDetail.getCount()).subtract(subtract);
-//
-//                    purchaseProduct.setExceedQuantity(exceedQuantity);
-//
-//                    AvailableStockBo inOutBo = new AvailableStockBo();
-//                    inOutBo.setProductId(purchaseProduct.getProductId());
-//                    inOutBo.setQuantity(exceedQuantity);
-//                    inOutBoList.add(inOutBo);
-//                }
-//            }
         }
         productInfoService.editAvailableQuantity(inOutBoList, businessId, ProductAvailableRecordType.PURCHASE_PASS, purchase.getCompanyId());
     }
@@ -267,7 +156,8 @@ public class EhsdPurchaseFlow extends FlowDelegate {
             throw new ServiceException("采购数据不能为空");
         }
         purchase.setFlowId(flowId);
-        connStart(purchase);
+
+        purchaseService.addOrEdit(purchase);
     }
 
     /**
@@ -295,8 +185,8 @@ public class EhsdPurchaseFlow extends FlowDelegate {
                 .set(EhsdPurchase::getStatus, FlowStatusEnum1.CANCELLATION.getKey())
                 .set(BasePo::getUpdateTime, new Date())
                 .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
-		);
-	}
+        );
+    }
 
 
 }

+ 3 - 45
hx-sale/src/main/java/com/fjhx/sale/flow/EhsdPurchaseUpdateFlow.java

@@ -21,8 +21,6 @@ import com.fjhx.sale.service.arrival.ArrivalService;
 import com.fjhx.sale.service.purchase.EhsdPurchaseProductService;
 import com.fjhx.sale.service.purchase.EhsdPurchaseProjectService;
 import com.fjhx.sale.service.purchase.EhsdPurchaseService;
-import com.fjhx.wms.service.stock.StockWaitDetailsService;
-import com.fjhx.wms.service.stock.StockWaitService;
 import com.ruoyi.common.core.domain.BasePo;
 import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.SecurityUtils;
@@ -43,18 +41,12 @@ public class EhsdPurchaseUpdateFlow extends FlowDelegate {
     @Autowired
     private EhsdPurchaseService ehsdPurchaseService;
     @Autowired
-    private EhsdPurchaseFlow ehsdPurchaseFlow;
-    @Autowired
     private EhsdPurchaseProductService ehsdPurchaseProductService;
     @Autowired
     private EhsdPurchaseProjectService ehsdPurchaseProjectService;
     @Autowired
     private ProductInfoService productInfoService;
     @Autowired
-    private StockWaitDetailsService stockWaitDetailsService;
-    @Autowired
-    private StockWaitService stockWaitService;
-    @Autowired
     private ArrivalService arrivalService;
 
     @Override
@@ -76,6 +68,7 @@ public class EhsdPurchaseUpdateFlow extends FlowDelegate {
 
         //赋值流程id
         purchase.setFlowId(flowId);
+        purchase.setStatus(PurchaseStatusEnum.UNDER_REVIEW.getKey());
 
         //获取原采购id
         Long oldPurchaseId = purchase.getOldPurchaseId();
@@ -109,7 +102,7 @@ public class EhsdPurchaseUpdateFlow extends FlowDelegate {
         purchaseProjectList.forEach(item -> item.setId(null));
 
         //调用采购发起公共代码块
-        purchase = ehsdPurchaseFlow.connStart(purchase);
+        ehsdPurchaseService.addOrEdit(purchase);
 
         //回传单号给流程引擎
         submitData.put("code", purchase.getCode());
@@ -153,9 +146,6 @@ public class EhsdPurchaseUpdateFlow extends FlowDelegate {
         for (EhsdPurchaseProduct oldPurchaseProduct : oldPurchaseProductList) {
             //新数量
             BigDecimal newQuantity = newQuantityMap.get(oldPurchaseProduct.getId());
-//            //已入库数量
-//            StockWaitDetails stockWaitDetails = stockWaitDetailsService.getOne(q -> q.eq(StockWaitDetails::getBusinessDetailsId, oldPurchaseProduct.getId()));
-//            stockWaitId = stockWaitDetails.getStockWaitId();
 
             //生成操作可用库存的实体
             AvailableStockBo availableStockBo = new AvailableStockBo();
@@ -165,24 +155,6 @@ public class EhsdPurchaseUpdateFlow extends FlowDelegate {
             availableStockBo.setInStockQuantity(BigDecimal.ZERO);
 
             availableStockBoList.add(availableStockBo);
-
-
-//            //操作待入库数据
-//            if (ObjectUtils.isEmpty(newQuantity)) {
-//                //原数据被删,检查已入库数量,>0禁止变更
-//                stockWaitDetailsService.removeById(stockWaitDetails);
-//            } else {
-//                stockWaitDetails.setQuantity(newQuantity);
-//                //计算状态
-//                int status = stockWaitDetails.getReceiptQuantity().compareTo(stockWaitDetails.getQuantity()) >= 0 ? 2 : 1;
-//                if (stockWaitDetails.getReceiptQuantity().compareTo(BigDecimal.ZERO) == 0) {
-//                    status = 0;
-//                }
-//                stockWaitDetails.setStatus(status);
-//                stockWaitDetailsService.updateById(stockWaitDetails);
-//
-//                stockWaitService.updateStatus(stockWaitDetails.getStockWaitId());
-//            }
         }
 
         //新添加的数据处理
@@ -198,20 +170,6 @@ public class EhsdPurchaseUpdateFlow extends FlowDelegate {
             availableStockBo.setNewQuantity(newPurchaseProduct.getQuantity());
             availableStockBo.setInStockQuantity(null);
             availableStockBoList.add(availableStockBo);
-
-//            //生成待入库
-//            Assert.notEmpty(stockWaitId, "查询不到待入库信息!");
-//            StockWaitDetails stockWaitDetails = new StockWaitDetails();
-//            stockWaitDetails.setStockWaitId(stockWaitId);
-//            stockWaitDetails.setBusinessDetailsId(newPurchaseProduct.getId());
-//            stockWaitDetails.setPurchaseDetailId(newPurchaseProduct.getId());
-//
-//            stockWaitDetails.setProductId(newPurchaseProduct.getProductId());
-//            stockWaitDetails.setQuantity(newPurchaseProduct.getQuantity());
-//            stockWaitDetails.setStatus(0);
-//            stockWaitDetailsService.save(stockWaitDetails);
-//
-//            stockWaitService.updateStatus(stockWaitDetails.getStockWaitId());
         }
 
 
@@ -269,7 +227,7 @@ public class EhsdPurchaseUpdateFlow extends FlowDelegate {
             throw new ServiceException("采购数据不能为空");
         }
         purchase.setFlowId(flowId);
-        ehsdPurchaseFlow.connStart(purchase);
+        ehsdPurchaseService.addOrEdit(purchase);
     }
 
     /**

+ 1 - 1
hx-sale/src/main/java/com/fjhx/sale/service/purchase/EhsdPurchaseService.java

@@ -41,7 +41,7 @@ public interface EhsdPurchaseService extends BaseService<EhsdPurchase> {
     /**
      * ehsd采购表新增
      */
-    void add(EhsdPurchaseDto ehsdPurchaseDto);
+    void addOrEdit(EhsdPurchaseDto ehsdPurchaseDto);
 
     /**
      * ehsd采购表编辑

+ 47 - 3
hx-sale/src/main/java/com/fjhx/sale/service/purchase/impl/EhsdPurchaseServiceImpl.java

@@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.dynamic.datasource.annotation.DSTransactional;
 import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -21,6 +22,8 @@ import com.fjhx.common.service.corporation.CorporationService;
 import com.fjhx.common.service.documentary.GetDocumentaryBusinessTemplate;
 import com.fjhx.common.utils.Assert;
 import com.fjhx.common.utils.excel.util.ExcelUtil;
+import com.fjhx.file.entity.ObsFile;
+import com.fjhx.file.utils.ObsFileUtil;
 import com.fjhx.flow.entity.flow.po.FlowExample;
 import com.fjhx.flow.enums.FlowStatusEnum;
 import com.fjhx.flow.service.flow.FlowExampleService;
@@ -160,6 +163,8 @@ public class EhsdPurchaseServiceImpl extends ServiceImpl<EhsdPurchaseMapper, Ehs
     private ISysDeptService sysDeptService;
     @Autowired
     private WarehouseService warehouseService;
+    @Autowired
+    private EhsdPurchaseProjectService purchaseProjectService;
 
     private void setPageWrapper(EhsdPurchaseSelectDto dto, IWrapper<EhsdPurchase> wrapper) {
         if (ObjectUtils.isNotEmpty(dto.getStatus())) {
@@ -503,13 +508,52 @@ public class EhsdPurchaseServiceImpl extends ServiceImpl<EhsdPurchaseMapper, Ehs
             result.setAccountManagementName(accountManagement.getName());
         }
 
-
         return result;
     }
 
     @Override
-    public void add(EhsdPurchaseDto ehsdPurchaseDto) {
-        this.save(ehsdPurchaseDto);
+    public void addOrEdit(EhsdPurchaseDto dto) {
+        if (ObjectUtil.isEmpty(dto.getCurrency())) {
+            dto.setCurrency("CNY");
+        }
+
+        //赋值产品归属公司
+        Long companyId = dto.getCompanyId();
+        if (ObjectUtil.isEmpty(companyId)) {
+            dto.setCompanyId(SecurityUtils.getCompanyId());
+        }
+
+        //赋值城市省份信息
+        CustomizeAreaUtil.setAreaId(dto);
+        dto.setSellCityId(dto.getCityId());
+        dto.setSellCountryId(dto.getCountryId());
+        dto.setSellProvinceId(dto.getProvinceId());
+
+
+        String nickName = SecurityUtils.getLoginUser().getUser().getNickName();
+        dto.setUserName(nickName);
+        this.saveOrUpdate(dto);
+
+
+        //产品(采购明细)
+        List<EhsdPurchaseProduct> purchaseProductList = ObjectUtil.defaultIfNull(dto.getPurchaseProductList(), new ArrayList<>());
+        for (EhsdPurchaseProduct s : purchaseProductList) {
+            s.setId(ObjectUtils.isNotEmpty(s.getId()) ? s.getId() : IdWorker.getId());
+            s.setPurchaseId(dto.getId());
+        }
+        //修改或删除数据
+        purchaseProductService.editLinked(purchaseProductList, EhsdPurchaseProduct::getPurchaseId, dto.getId());
+
+        //收费项目
+        List<EhsdPurchaseProject> purchaseProjectList = ObjectUtil.defaultIfNull(dto.getPurchaseProjectList(), new ArrayList<>());
+        for (EhsdPurchaseProject s : purchaseProjectList) {
+            s.setPurchaseId(dto.getId());
+        }
+        purchaseProjectService.editLinked(purchaseProjectList, EhsdPurchaseProject::getPurchaseId, dto.getId());
+
+        //采购附件
+        List<ObsFile> fileList = dto.getFileList();
+        ObsFileUtil.editFile(fileList, dto.getId());
     }
 
     @Override