浏览代码

维多利亚

24282 2 年之前
父节点
当前提交
69c6dcd6bb

+ 12 - 21
hx-service-api/victoriatourist-api/src/main/java/com/fjhx/enums/apply/ApplyPurchaseStatusEnum.java

@@ -1,5 +1,6 @@
 package com.fjhx.enums.apply;
 
+import lombok.Getter;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.StringPool;
 
@@ -10,19 +11,22 @@ import java.util.Map;
 /**
  * 申购状态枚举
  */
+@Getter
 public enum ApplyPurchaseStatusEnum {
-    STATUS_10(10, "待采购"),
-    STATUS_20(20, "采购审批中"),
-    STATUS_30(30, "已驳回"),
-    STATUS_40(40, "已采购"),
-    STATUS_50(50, "已完成"),
+    STATUS_10(10, "申购审批中"),
+    STATUS_20(20, "申购审批已驳回"),
+    STATUS_30(30, "申购审批已通过"),
+    STATUS_40(40, "采购审批中"),
+    STATUS_50(50, "采购审批已驳回"),
+    STATUS_60(60, "采购审批已通过"),
+    STATUS_70(70, "已完成"),
     ;
 
-    private int key;
+    private final int key;
 
-    private String value;
+    private final String value;
 
-    private static Map<Integer, String> map = new LinkedHashMap<>();
+    private static final Map<Integer, String> map = new LinkedHashMap<>();
 
     private static final HashMap<Integer, ApplyPurchaseStatusEnum> classMap = new HashMap<>();
 
@@ -47,8 +51,6 @@ public enum ApplyPurchaseStatusEnum {
 
     /**
      * 获取枚举map
-     *
-     * @return
      */
     public static Map<Integer, String> getMap() {
         if (Func.isNotEmpty(map)) {
@@ -62,9 +64,6 @@ public enum ApplyPurchaseStatusEnum {
 
     /**
      * 通过key获取名称
-     *
-     * @param key
-     * @return
      */
     public static String getNameByKey(Integer key) {
         if (key == null || key < 0) {
@@ -74,12 +73,4 @@ public enum ApplyPurchaseStatusEnum {
         return map.getOrDefault(key, StringPool.EMPTY);
     }
 
-    public int getKey() {
-        return key;
-    }
-
-    public String getValue() {
-        return value;
-    }
-
 }

+ 5 - 14
hx-service-api/victoriatourist-api/src/main/java/com/fjhx/enums/purchase/PurchaseStatusEnum.java

@@ -1,5 +1,6 @@
 package com.fjhx.enums.purchase;
 
+import lombok.Getter;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.StringPool;
 
@@ -10,6 +11,7 @@ import java.util.Map;
 /**
  * 采购状态枚举
  */
+@Getter
 public enum PurchaseStatusEnum {
     STATUS_10(10, "审批中"),
     STATUS_20(20, "驳回"),
@@ -19,11 +21,11 @@ public enum PurchaseStatusEnum {
     STATUS_99(99, "已取消"),
     ;
 
-    private int key;
+    private final int key;
 
-    private String value;
+    private final String value;
 
-    private static Map<Integer, String> map = new LinkedHashMap<>();
+    private static final Map<Integer, String> map = new LinkedHashMap<>();
 
     private static final HashMap<Integer, PurchaseStatusEnum> classMap = new HashMap<>();
 
@@ -63,9 +65,6 @@ public enum PurchaseStatusEnum {
 
     /**
      * 通过key获取名称
-     *
-     * @param key
-     * @return
      */
     public static String getNameByKey(Integer key) {
         if (key == null || key < 0) {
@@ -75,12 +74,4 @@ public enum PurchaseStatusEnum {
         return map.getOrDefault(key, StringPool.EMPTY);
     }
 
-    public int getKey() {
-        return key;
-    }
-
-    public String getValue() {
-        return value;
-    }
-
 }

+ 1 - 0
hx-service/victoriatourist/src/main/java/com/fjhx/controller/purchase/PurchaseController.java

@@ -76,5 +76,6 @@ public class PurchaseController {
         purchaseService.cancelOrEnd(entity.getId(), PurchaseStatusEnum.STATUS_50.getKey());
         return R.success();
     }
+
 }
 

+ 12 - 14
hx-service/victoriatourist/src/main/java/com/fjhx/service/apply/impl/ApplyPurchaseServiceImpl.java

@@ -29,12 +29,7 @@ import org.springframework.stereotype.Service;
 import java.io.Serializable;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
+import java.util.*;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
@@ -76,7 +71,10 @@ public class ApplyPurchaseServiceImpl extends ServiceImpl<ApplyPurchaseMapper, A
                 .eq("t1", ApplyPurchase::getCreateUser, condition.get("applyUserId"))
                 .ge("t1", ApplyPurchase::getCreateTime, condition.get("startTime"))
                 .le("t1", ApplyPurchase::getCreateTime, condition.get("endTime"))
-                .and(Func.isNotEmpty(condition.get("keyword")), o -> o.apply("instr(t1.`code`, '" + condition.get("keyword") + "') > 0").or().apply("instr(t2.`code`, '" + condition.get("keyword") + "') > 0").or().apply("instr(t2.`name`, '" + condition.get("keyword") + "') > 0"))
+                .and(Func.isNotEmpty(condition.get("keyword")),
+                        o -> o.apply("instr(t1.`code`, '" + condition.get("keyword") + "') > 0").or()
+                                .apply("instr(t2.`code`, '" + condition.get("keyword") + "') > 0").or()
+                                .apply("instr(t2.`name`, '" + condition.get("keyword") + "') > 0"))
                 .orderByDesc("t1", ApplyPurchase::getId);
 
         Page<ApplyPurchase> page = baseMapper.getPage(createPage(condition), wrapper);
@@ -95,15 +93,15 @@ public class ApplyPurchaseServiceImpl extends ServiceImpl<ApplyPurchaseMapper, A
     @Override
     public void add(List<ApplyPurchase> list) {
         if (!redisLockClient.lockFair(REDIS_LOCK_CACHE_KEY, () -> {
-            //获取编码
+            // 获取编码
             String code = CodeEnum.APPLY_PURCHASE.getCode();
-            //查询编码是否已存在
-            if (!checkCodeIsExist(null, code)) {
-                throw new ServiceException("后台自增编码存在重复,请重试或联系管理员!编码:" + code);
-            }
+            // 查询编码是否已存在
+            // if (!checkCodeIsExist(null, code)) {
+            //     throw new ServiceException("后台自增编码存在重复,请重试或联系管理员!编码:" + code);
+            // }
             list.forEach(item -> {
                 item.setCode(code);
-                item.setStatus(ApplyPurchaseStatusEnum.STATUS_10.getKey());
+                item.setStatus(ApplyPurchaseStatusEnum.STATUS_30.getKey());
             });
             saveBatch(list);
             return true;
@@ -163,7 +161,7 @@ public class ApplyPurchaseServiceImpl extends ServiceImpl<ApplyPurchaseMapper, A
     public Page<ApplyPurchase> stayPurchasePage(Map<String, Object> condition) {
         IWrapper<ApplyPurchase> wrapper = IWrapper.getWrapper(condition);
 
-        wrapper.le("t1", ApplyPurchase::getStatus, ApplyPurchaseStatusEnum.STATUS_20.getKey())
+        wrapper.between("t1", ApplyPurchase::getStatus, ApplyPurchaseStatusEnum.STATUS_30.getKey(), ApplyPurchaseStatusEnum.STATUS_50.getKey())
                 .eq("t1", ApplyPurchase::getStatus)
                 .eq("t2", ProductInfo::getType, condition.get("goodsType"))
                 .eq("t3", Warehouse::getId, condition.get("warehouseId"))

+ 31 - 33
hx-service/victoriatourist/src/main/java/com/fjhx/service/purchase/impl/PurchaseFlowServiceImpl.java

@@ -2,7 +2,6 @@ package com.fjhx.service.purchase.impl;
 
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
-import com.fjhx.constants.common.CommonConstant;
 import com.fjhx.entity.apply.ApplyPurchase;
 import com.fjhx.entity.purchase.Purchase;
 import com.fjhx.enums.apply.ApplyPurchaseStatusEnum;
@@ -15,6 +14,7 @@ import com.fjhx.service.purchase.PurchaseFlowService;
 import com.fjhx.service.purchase.PurchaseService;
 import com.fjhx.uitl.code.CodeEnum;
 import com.fjhx.uitl.flow.FlowUserUtil;
+import com.fjhx.utils.Assert;
 import com.fjhx.utils.BigDecimalUtil;
 import com.fjhx.utils.ExampleAbstract;
 import com.fjhx.utils.FlowConstructor;
@@ -76,10 +76,18 @@ public class PurchaseFlowServiceImpl implements PurchaseFlowService {
                     @Override
                     public void end() {
                         Long id = getCacheData(Long.class);
-                        //修改采购状态
-                        purchaseService.lambdaUpdate().set(Purchase::getStatus, PurchaseStatusEnum.STATUS_30.getKey()).eq(Purchase::getId, id).update();
-                        //修改申购状态
-                        applyPurchaseService.lambdaUpdate().set(ApplyPurchase::getStatus, ApplyPurchaseStatusEnum.STATUS_40.getKey()).eq(ApplyPurchase::getPurchaseId, id).update();
+
+                        // 修改采购状态
+                        purchaseService.lambdaUpdate()
+                                .set(Purchase::getStatus, PurchaseStatusEnum.STATUS_30.getKey())
+                                .eq(Purchase::getId, id)
+                                .update();
+
+                        // 修改申购状态
+                        applyPurchaseService.lambdaUpdate()
+                                .set(ApplyPurchase::getStatus, ApplyPurchaseStatusEnum.STATUS_60.getKey())
+                                .eq(ApplyPurchase::getPurchaseId, id)
+                                .update();
                     }
 
                     /**
@@ -89,31 +97,20 @@ public class PurchaseFlowServiceImpl implements PurchaseFlowService {
                     @Transactional(rollbackFor = {Exception.class})
                     @Override
                     public void reject() {
-                        Purchase purchase = purchaseService.getById(getCacheData(Long.class));
-                        flowConstructor().deleteLogic(purchase.getFlowId());
-                    }
-
-                    /**
-                     * 删除流程
-                     *
-                     * @return
-                     */
-                    @Transactional(rollbackFor = {Exception.class})
-                    @Override
-                    public boolean deleteLogic() {
                         Long id = getCacheData(Long.class);
-                        //修改采购状态
-                        purchaseService.lambdaUpdate().set(Purchase::getStatus, PurchaseStatusEnum.STATUS_20.getKey()).set(Purchase::getDelFlag, CommonConstant.YesOrNo.YES).eq(Purchase::getId, id).update();
-                        //修改申购状态
+                        // 修改采购状态
+                        purchaseService.lambdaUpdate()
+                                .set(Purchase::getStatus, PurchaseStatusEnum.STATUS_20.getKey())
+                                .eq(Purchase::getId, id)
+                                .update();
+
+                        // 修改申购状态为已驳回
                         applyPurchaseService.lambdaUpdate()
-                                .set(ApplyPurchase::getStatus, ApplyPurchaseStatusEnum.STATUS_30.getKey())
-//                                .set(ApplyPurchase::getUnitPrice, null)
-//                                .set(ApplyPurchase::getPurchaseId, null)
-//                                .set(ApplyPurchase::getPurchaseCode, null)
+                                .set(ApplyPurchase::getStatus, ApplyPurchaseStatusEnum.STATUS_50.getKey())
                                 .eq(ApplyPurchase::getPurchaseId, id)
                                 .update();
-                        return true;
                     }
+
                 }
         );
     }
@@ -127,15 +124,18 @@ public class PurchaseFlowServiceImpl implements PurchaseFlowService {
     @Transactional(rollbackFor = {Exception.class})
     @Override
     public void start(Purchase entity) {
+        List<ApplyPurchase> goodsList = entity.getGoodsList();
+        Assert.notEmpty(goodsList, "采购物品不能为空");
+
         if (!redisLockClient.lockFair(REDIS_LOCK_CACHE_KEY, () -> {
             if (Func.isEmpty(entity.getId())) {
                 entity.setId(IdWorker.getId());
             }
 
             if (Func.isBlank(entity.getCode())) {
-                //获取编码
+                // 获取编码
                 entity.setCode(CodeEnum.APPLY_PURCHASE.getCode());
-                //查询编码是否已存在
+                // 查询编码是否已存在
                 if (!checkCodeIsExist(null, entity.getCode())) {
                     throw new ServiceException("后台自增编码存在重复,请重试或联系管理员!编码:" + entity.getCode());
                 }
@@ -144,7 +144,7 @@ public class PurchaseFlowServiceImpl implements PurchaseFlowService {
             //流程标题
             String title = AuthUtil.getUserName() + " 在" + LocalDate.now() + "日发起了 采购审批流程(单号:" + entity.getCode() + ")";
 
-            ExampleResult exampleResult = null;
+            ExampleResult exampleResult;
             if (Func.isEmpty(entity.getFlowId())) {
                 //启动流程
                 exampleResult = flowConstructor().create(entity.getId(), title, entity.getFlowRemark(), entity.getId());
@@ -155,7 +155,6 @@ public class PurchaseFlowServiceImpl implements PurchaseFlowService {
                 exampleResult = flowConstructor().jump(entity.getId(), buttonId, entity.getFlowRemark(), entity.getId());
             }
 
-            //事务回滚
             ExampleResult finalExampleResult = exampleResult;
             exampleResult.after(() -> {
                 //处理下一节点处理人信息
@@ -168,16 +167,15 @@ public class PurchaseFlowServiceImpl implements PurchaseFlowService {
                 //采购金额
                 BigDecimal price = new BigDecimal(BigDecimal.ZERO.intValue());
 
-                for (ApplyPurchase goods : entity.getGoodsList()) {
+                for (ApplyPurchase goods : goodsList) {
                     goods.setPurchaseId(entity.getId());
                     goods.setPurchaseCode(entity.getCode());
-                    goods.setStatus(ApplyPurchaseStatusEnum.STATUS_20.getKey());
+                    goods.setStatus(ApplyPurchaseStatusEnum.STATUS_40.getKey());
                     price = price.add(BigDecimalUtil.multiply(goods.getQuantity(), goods.getUnitPrice(), 2));
                 }
                 entity.setPrice(price);
                 purchaseService.saveOrUpdate(entity);
-
-                applyPurchaseService.saveOrUpdateBatch(entity.getGoodsList());
+                applyPurchaseService.saveOrUpdateBatch(goodsList);
             });
             return true;
         })) {

+ 11 - 4
hx-service/victoriatourist/src/main/java/com/fjhx/service/purchase/impl/PurchaseServiceImpl.java

@@ -120,9 +120,16 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase> i
     @Transactional(rollbackFor = {Exception.class})
     @Override
     public void cancelOrEnd(Long id, Integer status) {
-        //修改采购状态
-        lambdaUpdate().set(Purchase::getStatus, status).eq(Purchase::getId, id).update();
-        //修改申购状态
-        applyPurchaseService.lambdaUpdate().set(ApplyPurchase::getStatus, ApplyPurchaseStatusEnum.STATUS_50.getKey()).eq(ApplyPurchase::getPurchaseId, id).update();
+        // 修改采购状态
+        lambdaUpdate()
+                .set(Purchase::getStatus, status)
+                .eq(Purchase::getId, id)
+                .update();
+
+        // 修改申购状态
+        applyPurchaseService.lambdaUpdate()
+                .set(ApplyPurchase::getStatus, ApplyPurchaseStatusEnum.STATUS_70.getKey())
+                .eq(ApplyPurchase::getPurchaseId, id).update();
     }
+
 }