1
0

3 Ревизии dc8c316418 ... 1fb6dc22ab

Автор SHA1 Съобщение Дата
  qt5107 1fb6dc22ab 采购 преди 2 години
  qt5107 92b05589cd Merge remote-tracking branch 'origin/master' преди 2 години
  qt5107 a97f974f69 采购 преди 2 години
променени са 19 файла, в които са добавени 551 реда и са изтрити 14 реда
  1. 6 0
      hx-service-api/victoriatourist-api/src/main/java/com/fjhx/entity/apply/ApplyPurchase.java
  2. 1 2
      hx-service-api/victoriatourist-api/src/main/java/com/fjhx/entity/purchase/Purchase.java
  3. 81 0
      hx-service-api/victoriatourist-api/src/main/java/com/fjhx/enums/flow/FlowCodeEnum.java
  4. 85 0
      hx-service-api/victoriatourist-api/src/main/java/com/fjhx/enums/purchase/PurchaseStatusEnum.java
  5. 15 0
      hx-service-api/victoriatourist-api/src/main/java/com/fjhx/params/purchase/PurchaseVo.java
  6. 5 0
      hx-service/victoriatourist/pom.xml
  7. 18 6
      hx-service/victoriatourist/src/main/java/com/fjhx/controller/purchase/PurchaseController.java
  8. 51 0
      hx-service/victoriatourist/src/main/java/com/fjhx/controller/purchase/PurchaseFlowController.java
  9. 4 0
      hx-service/victoriatourist/src/main/java/com/fjhx/controller/supplier/SupplierPriceController.java
  10. 1 1
      hx-service/victoriatourist/src/main/java/com/fjhx/mapper/purchase/PurchaseMapper.java
  11. 7 0
      hx-service/victoriatourist/src/main/java/com/fjhx/service/apply/ApplyPurchaseService.java
  12. 73 1
      hx-service/victoriatourist/src/main/java/com/fjhx/service/apply/impl/ApplyPurchaseServiceImpl.java
  13. 31 0
      hx-service/victoriatourist/src/main/java/com/fjhx/service/purchase/PurchaseFlowService.java
  14. 10 2
      hx-service/victoriatourist/src/main/java/com/fjhx/service/purchase/PurchaseService.java
  15. 130 0
      hx-service/victoriatourist/src/main/java/com/fjhx/service/purchase/impl/PurchaseFlowServiceImpl.java
  16. 17 1
      hx-service/victoriatourist/src/main/java/com/fjhx/service/purchase/impl/PurchaseServiceImpl.java
  17. 2 0
      hx-service/victoriatourist/src/main/java/com/fjhx/service/supplier/SupplierPriceService.java
  18. 10 0
      hx-service/victoriatourist/src/main/java/com/fjhx/service/supplier/impl/SupplierPriceServiceImpl.java
  19. 4 1
      hx-service/victoriatourist/src/main/java/com/fjhx/uitl/code/CodeEnum.java

+ 6 - 0
hx-service-api/victoriatourist-api/src/main/java/com/fjhx/entity/apply/ApplyPurchase.java

@@ -138,4 +138,10 @@ public class ApplyPurchase extends BaseEntity {
      */
     @TableField(exist = false)
     private BigDecimal stockQuantity;
+
+    /**
+     * 出库数量
+     */
+    @TableField(exist = false)
+    private BigDecimal outStockQuantity;
 }

+ 1 - 2
hx-service-api/victoriatourist-api/src/main/java/com/fjhx/entity/purchase/Purchase.java

@@ -13,7 +13,7 @@ import lombok.EqualsAndHashCode;
 
 /**
  * <p>
- * 订单
+ * 采购
  * </p>
  *
  * @author ${author}
@@ -23,7 +23,6 @@ import lombok.EqualsAndHashCode;
 @EqualsAndHashCode(callSuper = true)
 public class Purchase extends BaseEntity {
 
-
     /**
      * 供应商ID
      */

+ 81 - 0
hx-service-api/victoriatourist-api/src/main/java/com/fjhx/enums/flow/FlowCodeEnum.java

@@ -0,0 +1,81 @@
+package com.fjhx.enums.flow;
+
+import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.StringPool;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * 流程类型枚举
+ */
+public enum FlowCodeEnum {
+    PURCHASE(1, "PURCHASE"), //采购审批
+    ;
+
+    private int key;
+
+    private String value;
+
+    private static Map<Integer, String> map = new LinkedHashMap<>();
+
+    private static final HashMap<Integer, FlowCodeEnum> classMap = new HashMap<>();
+
+    FlowCodeEnum(int key, String value) {
+        this.key = key;
+        this.value = value;
+    }
+
+
+    static {
+        for (FlowCodeEnum value : FlowCodeEnum.values()) {
+            classMap.put(value.getKey(), value);
+        }
+    }
+
+    /**
+     * 根据type获取枚举
+     */
+    public static FlowCodeEnum get(Integer type) {
+        return classMap.get(type);
+    }
+
+    /**
+     * 获取枚举map
+     *
+     * @return
+     */
+    public static Map<Integer, String> getMap() {
+        if (Func.isNotEmpty(map)) {
+            return map;
+        }
+        for (FlowCodeEnum ms : values()) {
+            map.put(ms.key, ms.value);
+        }
+        return map;
+    }
+
+    /**
+     * 通过key获取名称
+     *
+     * @param key
+     * @return
+     */
+    public static String getNameByKey(Integer key) {
+        if (key == null || key < 0) {
+            return StringPool.EMPTY;
+        }
+        Map<Integer, String> map = getMap();
+        return map.getOrDefault(key, StringPool.EMPTY);
+    }
+
+    public int getKey() {
+        return key;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+}

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

@@ -0,0 +1,85 @@
+package com.fjhx.enums.purchase;
+
+import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.StringPool;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * 采购状态枚举
+ */
+public enum PurchaseStatusEnum {
+    STATUS_10(10, "审批中"),
+    STATUS_20(20, "驳回"),
+    STATUS_30(30, "待发货"),
+    STATUS_40(40, "已发货"),
+    STATUS_50(50, "已完成"),
+    ;
+
+    private int key;
+
+    private String value;
+
+    private static Map<Integer, String> map = new LinkedHashMap<>();
+
+    private static final HashMap<Integer, PurchaseStatusEnum> classMap = new HashMap<>();
+
+    PurchaseStatusEnum(int key, String value) {
+        this.key = key;
+        this.value = value;
+    }
+
+
+    static {
+        for (PurchaseStatusEnum value : PurchaseStatusEnum.values()) {
+            classMap.put(value.getKey(), value);
+        }
+    }
+
+    /**
+     * 根据type获取枚举
+     */
+    public static PurchaseStatusEnum get(Integer type) {
+        return classMap.get(type);
+    }
+
+    /**
+     * 获取枚举map
+     *
+     * @return
+     */
+    public static Map<Integer, String> getMap() {
+        if (Func.isNotEmpty(map)) {
+            return map;
+        }
+        for (PurchaseStatusEnum ms : values()) {
+            map.put(ms.key, ms.value);
+        }
+        return map;
+    }
+
+    /**
+     * 通过key获取名称
+     *
+     * @param key
+     * @return
+     */
+    public static String getNameByKey(Integer key) {
+        if (key == null || key < 0) {
+            return StringPool.EMPTY;
+        }
+        Map<Integer, String> map = getMap();
+        return map.getOrDefault(key, StringPool.EMPTY);
+    }
+
+    public int getKey() {
+        return key;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+}

+ 15 - 0
hx-service-api/victoriatourist-api/src/main/java/com/fjhx/params/purchase/PurchaseVo.java

@@ -1,9 +1,13 @@
 package com.fjhx.params.purchase;
 
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.fjhx.entity.apply.ApplyPurchase;
 import com.fjhx.entity.purchase.Purchase;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
+import java.util.List;
+
 /**
  * 订单
  *
@@ -14,4 +18,15 @@ import lombok.EqualsAndHashCode;
 @EqualsAndHashCode(callSuper = true)
 public class PurchaseVo extends Purchase {
 
+    /**
+     * 办理说明
+     */
+    @TableField(exist = false)
+    private String flowRemark;
+
+    /**
+     * 物品集合
+     */
+    @TableField(exist = false)
+    private List<ApplyPurchase> goodsList;
 }

+ 5 - 0
hx-service/victoriatourist/pom.xml

@@ -33,6 +33,11 @@
             <artifactId>blade-system-api</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>com.fjhx</groupId>
+            <artifactId>service-flow-api</artifactId>
+        </dependency>
+
     </dependencies>
 
 </project>

+ 18 - 6
hx-service/victoriatourist/src/main/java/com/fjhx/controller/purchase/PurchaseController.java

@@ -1,10 +1,11 @@
 package com.fjhx.controller.purchase;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import org.springblade.core.tool.api.R;
+import com.fjhx.entity.apply.ApplyPurchase;
 import com.fjhx.entity.purchase.Purchase;
 import com.fjhx.params.purchase.PurchaseVo;
 import com.fjhx.service.purchase.PurchaseService;
+import org.springblade.core.tool.api.R;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -15,7 +16,7 @@ import java.util.Map;
 
 /**
  * <p>
- * 订单 前端控制器
+ * 采购 前端控制器
  * </p>
  *
  * @author ${author}
@@ -29,28 +30,39 @@ public class PurchaseController {
     private PurchaseService purchaseService;
 
     @PostMapping("/page")
-    public R page(@RequestBody Map<String, Object> condition){
+    public R page(@RequestBody Map<String, Object> condition) {
         Page<Purchase> result = purchaseService.getPage(condition);
         return R.success(result);
     }
 
     @PostMapping("/add")
-    public R add(@RequestBody PurchaseVo purchaseVo){
+    public R add(@RequestBody PurchaseVo purchaseVo) {
         purchaseService.add(purchaseVo);
         return R.success();
     }
 
     @PostMapping("/edit")
-    public R edit(@RequestBody PurchaseVo purchaseVo){
+    public R edit(@RequestBody PurchaseVo purchaseVo) {
         purchaseService.edit(purchaseVo);
         return R.success();
     }
 
     @PostMapping("/delete")
-    public R delete(@RequestBody PurchaseVo purchaseVo){
+    public R delete(@RequestBody PurchaseVo purchaseVo) {
         purchaseService.delete(purchaseVo);
         return R.success();
     }
 
+    /**
+     * 待采购列表
+     *
+     * @param condition 查询条件
+     * @return
+     */
+    @PostMapping("/stay/purchase/page")
+    public R stayPurchasePage(@RequestBody Map<String, Object> condition) {
+        Page<ApplyPurchase> result = purchaseService.stayPurchasePage(condition);
+        return R.success(result);
+    }
 }
 

+ 51 - 0
hx-service/victoriatourist/src/main/java/com/fjhx/controller/purchase/PurchaseFlowController.java

@@ -0,0 +1,51 @@
+package com.fjhx.controller.purchase;
+
+import com.fjhx.params.purchase.PurchaseVo;
+import com.fjhx.service.purchase.PurchaseFlowService;
+import org.springblade.core.tool.api.R;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ * 采购:流程 前端控制器
+ * </p>
+ *
+ * @author ${author}
+ * @since 2022-12-01
+ */
+@RestController
+@RequestMapping("/purchase/flow")
+public class PurchaseFlowController {
+
+    @Autowired
+    private PurchaseFlowService purchaseFlowService;
+
+    /**
+     * 发起
+     *
+     * @param entity
+     * @return
+     */
+    @PostMapping(value = "/start")
+    public R start(@RequestBody PurchaseVo entity) {
+        purchaseFlowService.start(entity);
+        return R.success();
+    }
+
+    /**
+     * 审批
+     *
+     * @param entity
+     * @return
+     */
+    @PostMapping(value = "/examine")
+    public R examine(@RequestBody PurchaseVo entity) {
+        purchaseFlowService.examine(entity);
+        return R.success();
+    }
+}
+

+ 4 - 0
hx-service/victoriatourist/src/main/java/com/fjhx/controller/supplier/SupplierPriceController.java

@@ -52,5 +52,9 @@ public class SupplierPriceController {
         return R.success();
     }
 
+    @PostMapping("/list")
+    public R list(@RequestBody Map<String, Object> condition) {
+        return R.success(supplierPriceService.getList(condition));
+    }
 }
 

+ 1 - 1
hx-service/victoriatourist/src/main/java/com/fjhx/mapper/purchase/PurchaseMapper.java

@@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
 /**
  * <p>
- * 订单 Mapper 接口
+ * 采购 Mapper 接口
  * </p>
  *
  * @author ${author}

+ 7 - 0
hx-service/victoriatourist/src/main/java/com/fjhx/service/apply/ApplyPurchaseService.java

@@ -32,4 +32,11 @@ public interface ApplyPurchaseService extends BaseService<ApplyPurchase> {
      */
     Page<Map<String, Object>> applyInPage(Condition condition);
 
+    /**
+     * 待采购列表
+     *
+     * @param condition 查询条件
+     * @return
+     */
+    Page<ApplyPurchase> stayPurchasePage(Map<String, Object> condition);
 }

+ 73 - 1
hx-service/victoriatourist/src/main/java/com/fjhx/service/apply/impl/ApplyPurchaseServiceImpl.java

@@ -3,14 +3,17 @@ package com.fjhx.service.apply.impl;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fjhx.base.Condition;
+import com.fjhx.constants.StockJournalTypeConstant;
 import com.fjhx.entity.apply.ApplyPurchase;
 import com.fjhx.entity.product.ProductInfo;
 import com.fjhx.entity.stock.Stock;
+import com.fjhx.entity.stock.StockJournal;
 import com.fjhx.enums.apply.ApplyPurchaseStatusEnum;
 import com.fjhx.mapper.apply.ApplyPurchaseMapper;
 import com.fjhx.params.apply.ApplyPurchaseVo;
 import com.fjhx.service.apply.ApplyPurchaseService;
 import com.fjhx.service.product.ProductInfoService;
+import com.fjhx.service.stock.StockJournalService;
 import com.fjhx.service.stock.StockService;
 import com.fjhx.uitl.code.CodeEnum;
 import com.fjhx.utils.UserClientUtil;
@@ -18,13 +21,19 @@ import com.fjhx.utils.wrapperUtil.IWrapper;
 import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.redis.lock.RedisLockClient;
 import org.springblade.core.secure.utils.AuthUtil;
+import org.springblade.core.tool.utils.DateUtil;
 import org.springblade.core.tool.utils.Func;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.io.Serializable;
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -46,7 +55,10 @@ public class ApplyPurchaseServiceImpl extends ServiceImpl<ApplyPurchaseMapper, A
     @Autowired
     private ProductInfoService productInfoService;
 
-    private final String REDIS_LOCK_CACHE_KEY = "seq:lock:" + AuthUtil.getTenantId() + ":material:";
+    @Autowired
+    private StockJournalService stockJournalService;
+
+    private final String REDIS_LOCK_CACHE_KEY = "seq:lock:" + AuthUtil.getTenantId() + ":apply_purchase:";
 
     @Override
     public Page<ApplyPurchase> getPage(Map<String, Object> condition) {
@@ -161,4 +173,64 @@ public class ApplyPurchaseServiceImpl extends ServiceImpl<ApplyPurchaseMapper, A
         }
         return purchase;
     }
+
+    /**
+     * 待采购列表
+     *
+     * @param condition 查询条件
+     * @return
+     */
+    @Override
+    public Page<ApplyPurchase> stayPurchasePage(Map<String, Object> condition) {
+        IWrapper<ApplyPurchase> wrapper = IWrapper.getWrapper(condition);
+
+        wrapper.lt("t1", ApplyPurchase::getStatus, ApplyPurchaseStatusEnum.STATUS_20.getKey())
+                .eq("t1", ApplyPurchase::getStatus)
+                .apply(Func.isNotEmpty(condition.get("code")), "instr(t1.`code`, '" + condition.get("code") + "') > 0")
+                .apply(Func.isNotEmpty(condition.get("goodsCode")), "instr(t2.`code`, '" + condition.get("goodsCode") + "') > 0")
+                .apply(Func.isNotEmpty(condition.get("goodsName")), "instr(t2.`name`, '" + condition.get("goodsName") + "') > 0")
+                .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"))
+                .orderByDesc("t1", ApplyPurchase::getId);
+
+        Page<ApplyPurchase> page = baseMapper.getPage(createPage(condition), wrapper);
+        if (Func.isNotEmpty(page.getRecords())) {
+            //物品ID集合
+            List<Long> goodsIds = page.getRecords().stream().map(ApplyPurchase::getGoodsId).distinct().collect(Collectors.toList());
+            //结束时间
+            Date endTime = new Date();
+            //开始时间:往前推移30天
+            Date startTime = DateUtil.plusDays(endTime, -30l);
+            //物品出库信息map
+            Map<Long, BigDecimal> outStockMap = new HashMap<>();
+            //查询出库信息
+            List<StockJournal> stockJournals = stockJournalService.query()
+                    .select("goods_id, SUM(change_quantity) change_quantity")
+                    .eq("`type`", StockJournalTypeConstant.OUT)
+                    .in("goods_id", goodsIds)
+                    .apply("DATE_FORMAT(create_time, '%Y-%m-%d') >= '" + new SimpleDateFormat("yyyy-MM-dd").format(startTime) + "'")
+                    .apply("DATE_FORMAT(create_time, '%Y-%m-%d') <= '" + new SimpleDateFormat("yyyy-MM-dd").format(endTime) + "'")
+                    .groupBy("goods_id")
+                    .list();
+            if (Func.isNotEmpty(stockJournals)) {
+                outStockMap = stockJournals.stream().collect(Collectors.toMap(StockJournal::getGoodsId, StockJournal::getChangeQuantity, (key1, key2) -> key2));
+            }
+
+            //用户信息map
+            Map<Long, String> userNameMap = UserClientUtil.getUserNameMap(page.getRecords(), ApplyPurchase::getCreateUser);
+
+            for (ApplyPurchase record : page.getRecords()) {
+                if (Func.isNotEmpty(userNameMap) && Func.isNotEmpty(userNameMap.get(record.getCreateUser()))) {
+                    record.setCreateName(userNameMap.get(record.getCreateUser()));
+                }
+                if (Func.isNotEmpty(outStockMap) && Func.isNotEmpty(outStockMap.get(record.getGoodsId()))) {
+                    record.setOutStockQuantity(outStockMap.get(record.getGoodsId()));
+                }
+            }
+        }
+
+        return page;
+    }
 }

+ 31 - 0
hx-service/victoriatourist/src/main/java/com/fjhx/service/purchase/PurchaseFlowService.java

@@ -0,0 +1,31 @@
+package com.fjhx.service.purchase;
+
+import com.fjhx.params.purchase.PurchaseVo;
+
+/**
+ * <p>
+ * 采购:流程 服务类
+ * </p>
+ *
+ * @author ${author}
+ * @since 2022-12-01
+ */
+public interface PurchaseFlowService {
+
+    /**
+     * 发起
+     *
+     * @param entity
+     * @return
+     */
+    void start(PurchaseVo entity);
+
+    /**
+     * 审批
+     *
+     * @param entity
+     * @return
+     */
+    void examine(PurchaseVo entity);
+
+}

+ 10 - 2
hx-service/victoriatourist/src/main/java/com/fjhx/service/purchase/PurchaseService.java

@@ -1,15 +1,16 @@
 package com.fjhx.service.purchase;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.base.BaseService;
+import com.fjhx.entity.apply.ApplyPurchase;
 import com.fjhx.entity.purchase.Purchase;
 import com.fjhx.params.purchase.PurchaseVo;
-import com.fjhx.base.BaseService;
 
 import java.util.Map;
 
 /**
  * <p>
- * 订单 服务类
+ * 采购 服务类
  * </p>
  *
  * @author ${author}
@@ -25,4 +26,11 @@ public interface PurchaseService extends BaseService<Purchase> {
 
     void delete(PurchaseVo purchaseVo);
 
+    /**
+     * 待采购列表
+     *
+     * @param condition 查询条件
+     * @return
+     */
+    Page<ApplyPurchase> stayPurchasePage(Map<String, Object> condition);
 }

+ 130 - 0
hx-service/victoriatourist/src/main/java/com/fjhx/service/purchase/impl/PurchaseFlowServiceImpl.java

@@ -0,0 +1,130 @@
+package com.fjhx.service.purchase.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
+import com.fjhx.entity.apply.ApplyPurchase;
+import com.fjhx.entity.purchase.Purchase;
+import com.fjhx.enums.flow.FlowCodeEnum;
+import com.fjhx.enums.purchase.PurchaseStatusEnum;
+import com.fjhx.params.ExampleResult;
+import com.fjhx.params.purchase.PurchaseVo;
+import com.fjhx.service.purchase.PurchaseFlowService;
+import com.fjhx.service.purchase.PurchaseService;
+import com.fjhx.uitl.code.CodeEnum;
+import com.fjhx.utils.ExampleAbstract;
+import com.fjhx.utils.FlowConstructor;
+import org.springblade.core.log.exception.ServiceException;
+import org.springblade.core.redis.lock.RedisLockClient;
+import org.springblade.core.secure.utils.AuthUtil;
+import org.springblade.core.tool.utils.Func;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.time.LocalDate;
+import java.util.List;
+
+/**
+ * <p>
+ * 采购:流程 服务实现类
+ * </p>
+ *
+ * @author ${author}
+ * @since 2022-12-01
+ */
+@Service
+public class PurchaseFlowServiceImpl implements PurchaseFlowService {
+
+    @Autowired
+    private PurchaseService purchaseService;
+
+    @Autowired
+    private RedisLockClient redisLockClient;
+
+    private final String REDIS_LOCK_CACHE_KEY = "seq:lock:" + AuthUtil.getTenantId() + ":purchase:";
+
+    /**
+     * 初始化流程
+     *
+     * @return
+     */
+    private FlowConstructor flowConstructor() {
+        return FlowConstructor.init(
+                new ExampleAbstract() {
+                    @Override
+                    public String getCode() {
+                        return FlowCodeEnum.PURCHASE.getValue();
+                    }
+
+                    /**
+                     * 结束
+                     *
+                     */
+                    @Transactional(rollbackFor = {Exception.class})
+                    @Override
+                    public void end() {
+                    }
+                }
+        );
+    }
+
+    /**
+     * 发起
+     *
+     * @param entity
+     * @return
+     */
+    @Transactional(rollbackFor = {Exception.class})
+    @Override
+    public void start(PurchaseVo entity) {
+        if (!redisLockClient.lockFair(REDIS_LOCK_CACHE_KEY, () -> {
+            entity.setId(IdWorker.getId());
+
+            //获取编码
+            String code = CodeEnum.APPLY_PURCHASE.getCode();
+            //查询编码是否已存在
+            if (!checkCodeIsExist(null, code)) {
+                throw new ServiceException("后台自增编码存在重复,请重试或联系管理员!编码:" + code);
+            }
+
+            //流程标题
+            String title = AuthUtil.getUserName() + " 在" + LocalDate.now() + "日发起了 采购审批流程(单号:" + code + ")";
+
+            ExampleResult exampleResult = flowConstructor().create(entity.getId(), title, entity.getFlowRemark(), entity.getId());
+
+            //事务回滚
+            exampleResult.after(() -> {
+//                //获取下一节点处理人信息
+//                JSONObject nextNodeHandleUserInfo = new JSONObject();
+//                getNextNodeHandleUserInfo(finalExampleResult, nextNodeHandleUserInfo);
+//
+//                //先删除旧数据
+//                applyPurchaseService.deleteByCode(finalApplyCode);
+//
+//                for (ApplyPurchase goods : entity.getGoodsList()) {
+//                    goods.setCode(finalApplyCode);
+//                    goods.setStatus(PurchaseStatusEnum.STATUS_10.getKey());
+//                }
+            });
+            return true;
+        })) {
+            throw new ServiceException("当前系统繁忙,请稍后重试!");
+        }
+    }
+
+    /**
+     * 审批
+     *
+     * @param entity
+     * @return
+     */
+    @Override
+    public void examine(PurchaseVo entity) {
+
+    }
+
+    private Boolean checkCodeIsExist(Long id, String code) {
+        List<Purchase> list = purchaseService.lambdaQuery().ne(Func.isNotEmpty(id), Purchase::getId, id).eq(Purchase::getCode, code).list();
+        return !Func.isNotEmpty(list);
+    }
+}

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

@@ -1,19 +1,22 @@
 package com.fjhx.service.purchase.impl;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.entity.apply.ApplyPurchase;
 import com.fjhx.entity.purchase.Purchase;
 import com.fjhx.params.purchase.PurchaseVo;
 import com.fjhx.mapper.purchase.PurchaseMapper;
+import com.fjhx.service.apply.ApplyPurchaseService;
 import com.fjhx.service.purchase.PurchaseService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fjhx.utils.wrapperUtil.IWrapper;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.Map;
 
 /**
  * <p>
- * 订单 服务实现类
+ * 采购 服务实现类
  * </p>
  *
  * @author ${author}
@@ -22,6 +25,9 @@ import java.util.Map;
 @Service
 public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase> implements PurchaseService {
 
+    @Autowired
+    private ApplyPurchaseService applyPurchaseService;
+
     @Override
     public Page<Purchase> getPage(Map<String, Object> condition) {
 
@@ -45,4 +51,14 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase> i
         removeById(purchaseVo.getId());
     }
 
+    /**
+     * 待采购列表
+     *
+     * @param condition 查询条件
+     * @return
+     */
+    @Override
+    public Page<ApplyPurchase> stayPurchasePage(Map<String, Object> condition) {
+        return applyPurchaseService.stayPurchasePage(condition);
+    }
 }

+ 2 - 0
hx-service/victoriatourist/src/main/java/com/fjhx/service/supplier/SupplierPriceService.java

@@ -5,6 +5,7 @@ import com.fjhx.entity.supplier.SupplierPrice;
 import com.fjhx.params.supplier.SupplierPriceVo;
 import com.fjhx.base.BaseService;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -25,4 +26,5 @@ public interface SupplierPriceService extends BaseService<SupplierPrice> {
 
     void delete(SupplierPriceVo supplierPriceVo);
 
+    List<SupplierPrice> getList(Map<String, Object> condition);
 }

+ 10 - 0
hx-service/victoriatourist/src/main/java/com/fjhx/service/supplier/impl/SupplierPriceServiceImpl.java

@@ -1,5 +1,6 @@
 package com.fjhx.service.supplier.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fjhx.entity.material.Material;
@@ -11,9 +12,11 @@ import com.fjhx.service.supplier.SupplierPriceService;
 import com.fjhx.utils.Assert;
 import com.fjhx.utils.wrapperUtil.IWrapper;
 import com.fjhx.utils.wrapperUtil.KeywordData;
+import org.springblade.core.tool.utils.Func;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -71,4 +74,11 @@ public class SupplierPriceServiceImpl extends ServiceImpl<SupplierPriceMapper, S
         removeById(supplierPriceVo.getId());
     }
 
+    @Override
+    public List<SupplierPrice> getList(Map<String, Object> condition) {
+        return lambdaQuery().
+                eq(SupplierPrice::getSupplierId, condition.get("supplierId"))
+                .in(Func.isNotEmpty(condition.get("goodsIds")), SupplierPrice::getMaterialId, JSONObject.parseArray(JSONObject.toJSONString(condition.get("goodsIds")), Long.class))
+                .list();
+    }
 }

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

@@ -9,6 +9,7 @@ import com.fjhx.service.apply.ApplyPurchaseService;
 import com.fjhx.service.material.MaterialService;
 import com.fjhx.service.product.ProductInfoService;
 import com.fjhx.service.product.ProductSpuService;
+import com.fjhx.service.purchase.PurchaseService;
 import com.fjhx.service.supplier.SupplierService;
 import com.fjhx.utils.Assert;
 import lombok.Getter;
@@ -27,8 +28,10 @@ public enum CodeEnum {
     SPU("SPU", null, "code", 5, ProductSpuService.class),
     //申购单
     APPLY_PURCHASE("AP", "yyyyMM-", "code", 5, ApplyPurchaseService.class),
-    // 产品
+    // 产品,
     PRODUCT("P", null, "code", 5, ProductInfoService.class),
+    //采购
+    PURCHASE("PO", "yyyyMM-", "code", 5, PurchaseService.class),
 
     ;