浏览代码

维多利亚

24282 2 年之前
父节点
当前提交
acf6c208d2

+ 32 - 41
hx-service/victoriatourist/src/main/java/com/fjhx/service/purchase/impl/PurchaseFlowServiceImpl.java

@@ -118,65 +118,56 @@ public class PurchaseFlowServiceImpl implements PurchaseFlowService {
     /**
      * 发起
      *
-     * @param entity
+     * @param purchase
      * @return
      */
     @Transactional(rollbackFor = {Exception.class})
     @Override
-    public void start(Purchase entity) {
-        List<ApplyPurchase> goodsList = entity.getGoodsList();
+    public void start(Purchase purchase) {
+        List<ApplyPurchase> goodsList = purchase.getGoodsList();
         Assert.notEmpty(goodsList, "采购物品不能为空");
 
         if (!redisLockClient.lockFair(REDIS_LOCK_CACHE_KEY, () -> {
-            if (Func.isEmpty(entity.getId())) {
-                entity.setId(IdWorker.getId());
+            if (Func.isEmpty(purchase.getId())) {
+                purchase.setId(IdWorker.getId());
             }
 
-            if (Func.isBlank(entity.getCode())) {
+            if (Func.isBlank(purchase.getCode())) {
                 // 获取编码
-                entity.setCode(CodeEnum.APPLY_PURCHASE.getCode());
+                purchase.setCode(CodeEnum.PURCHASE.getCode());
                 // 查询编码是否已存在
-                if (!checkCodeIsExist(null, entity.getCode())) {
-                    throw new ServiceException("后台自增编码存在重复,请重试或联系管理员!编码:" + entity.getCode());
+                if (!checkCodeIsExist(null, purchase.getCode())) {
+                    throw new ServiceException("后台自增编码存在重复,请重试或联系管理员!编码:" + purchase.getCode());
                 }
             }
 
-            //流程标题
-            String title = AuthUtil.getUserName() + " 在" + LocalDate.now() + "日发起了 采购审批流程(单号:" + entity.getCode() + ")";
+            purchase.setStatus(PurchaseStatusEnum.STATUS_10.getKey());
+            // 采购金额
+            BigDecimal price = new BigDecimal(BigDecimal.ZERO.intValue());
+
+            for (ApplyPurchase goods : goodsList) {
+                goods.setPurchaseId(purchase.getId());
+                goods.setPurchaseCode(purchase.getCode());
+                goods.setStatus(ApplyPurchaseStatusEnum.STATUS_40.getKey());
+                price = price.add(BigDecimalUtil.multiply(goods.getQuantity(), goods.getUnitPrice(), 2));
+            }
+            purchase.setPrice(price);
+            purchaseService.saveOrUpdate(purchase);
+            applyPurchaseService.saveOrUpdateBatch(goodsList);
 
-            ExampleResult exampleResult;
-            if (Func.isEmpty(entity.getFlowId())) {
-                //启动流程
-                exampleResult = flowConstructor().create(entity.getId(), title, entity.getFlowRemark(), entity.getId());
+            // 流程标题
+            String title = AuthUtil.getUserName() + " 在" + LocalDate.now() + "日发起了 采购审批流程(单号:" + purchase.getCode() + ")";
+
+            if (Func.isEmpty(purchase.getFlowId())) {
+                // 启动流程
+                flowConstructor().create(purchase.getId(), title, purchase.getFlowRemark(), purchase.getId());
             } else {
-                //获取当前节点对应的按钮ID
-                Long buttonId = iFlowClient.getButtonIdByExampleInfoId(entity.getFlowId());
-                //审批操作(用于驳回后重新提交)
-                exampleResult = flowConstructor().jump(entity.getId(), buttonId, entity.getFlowRemark(), entity.getId());
+                // 获取当前节点对应的按钮ID
+                Long buttonId = iFlowClient.getButtonIdByExampleInfoId(purchase.getFlowId());
+                // 审批操作(用于驳回后重新提交)
+                flowConstructor().jump(purchase.getId(), buttonId, purchase.getFlowRemark(), purchase.getId());
             }
 
-            ExampleResult finalExampleResult = exampleResult;
-            exampleResult.after(() -> {
-                //处理下一节点处理人信息
-                JSONObject nextNodeHandleUserInfo = new JSONObject();
-                FlowUserUtil.getNextNodeHandleUserInfo(finalExampleResult, nextNodeHandleUserInfo);
-                entity.setFlowId(nextNodeHandleUserInfo.getLong("flowId"));
-                entity.setFlowApproverId(nextNodeHandleUserInfo.getLong("flowApproverId"));
-                entity.setFlowApproverName(nextNodeHandleUserInfo.getString("flowApproverName"));
-                entity.setStatus(PurchaseStatusEnum.STATUS_10.getKey());
-                //采购金额
-                BigDecimal price = new BigDecimal(BigDecimal.ZERO.intValue());
-
-                for (ApplyPurchase goods : goodsList) {
-                    goods.setPurchaseId(entity.getId());
-                    goods.setPurchaseCode(entity.getCode());
-                    goods.setStatus(ApplyPurchaseStatusEnum.STATUS_40.getKey());
-                    price = price.add(BigDecimalUtil.multiply(goods.getQuantity(), goods.getUnitPrice(), 2));
-                }
-                entity.setPrice(price);
-                purchaseService.saveOrUpdate(entity);
-                applyPurchaseService.saveOrUpdateBatch(goodsList);
-            });
             return true;
         })) {
             throw new ServiceException("当前系统繁忙,请稍后重试!");

+ 2 - 1
hx-service/victoriatourist/src/main/java/com/fjhx/service/purchase/impl/PurchaseServiceImpl.java

@@ -1,5 +1,6 @@
 package com.fjhx.service.purchase.impl;
 
+import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fjhx.entity.apply.ApplyPurchase;
@@ -64,7 +65,7 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase> i
 
         wrapper.ge(Purchase::getStatus, PurchaseStatusEnum.STATUS_30.getKey())
                 .eq(Purchase::getStatus)
-                .apply("instr(`code`, '" + condition.get("keyword") + "') > 0")
+                .apply(ObjectUtil.isNotEmpty(condition.get("keyword")), "instr(`code`, '" + condition.get("keyword") + "') > 0")
                 .orderByDesc(ApplyPurchase::getId);
 
         Page<Purchase> page = page(condition, wrapper);

+ 1 - 0
hx-service/victoriatourist/src/main/java/com/fjhx/uitl/code/CodeEnum.java

@@ -30,6 +30,7 @@ public enum CodeEnum {
     SPU("SPU", null, "code", 5, ProductSpuService.class),
     //申购单
     APPLY_PURCHASE("AP", "yyyyMM-", "code", 5, ApplyPurchaseService.class),
+
     // 产品_成品
     PRODUCT_FINISHED("PF", null, "code", 5, ProductInfoService.class),
     // 产品_半成品