Browse Source

Merge remote-tracking branch 'origin/master'

home 2 years ago
parent
commit
dc8c316418

+ 1 - 1
hx-common/code-generator/src/main/java/com/fjhx/modular/Victoriatourist.java

@@ -12,7 +12,7 @@ public class Victoriatourist {
         CodeGenerator.MODULAR_NAME = "victoriatourist";
 
         // 需要生成的表名称,多表用,隔开
-        CodeGenerator.INCLUDE = "logistics_details";
+        CodeGenerator.INCLUDE = "purchase";
 
         // mysql连接
         CodeGenerator.MYSQL_URL = "36.134.91.96:17330";

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

@@ -23,7 +23,6 @@ import java.util.Date;
 @EqualsAndHashCode(callSuper = true)
 public class ApplyPurchase extends BaseEntity {
 
-
     /**
      * 申购单号
      */
@@ -134,7 +133,9 @@ public class ApplyPurchase extends BaseEntity {
     @TableField(exist = false)
     private String warehouseName;
 
-
-
-
+    /**
+     * 库存数量
+     */
+    @TableField(exist = false)
+    private BigDecimal stockQuantity;
 }

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

@@ -0,0 +1,70 @@
+package com.fjhx.entity.purchase;
+
+import java.math.BigDecimal;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.Version;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.fjhx.base.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableField;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ * 订单
+ * </p>
+ *
+ * @author ${author}
+ * @since 2022-12-01
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class Purchase extends BaseEntity {
+
+
+    /**
+     * 供应商ID
+     */
+    private Long supplierId;
+
+    /**
+     * 采购单号
+     */
+    private String code;
+
+    /**
+     * 订单金额
+     */
+    private BigDecimal price;
+
+    /**
+     * 状态:10、审批中;20、待发货;30、已发货;40、已完成
+     */
+    private Integer status;
+
+    /**
+     * 流程ID
+     */
+    private Long flowId;
+
+    /**
+     * 当前节点审批人ID
+     */
+    private Long flowApproverId;
+
+    /**
+     * 当前节点审批人名称
+     */
+    private String flowApproverName;
+
+    /**
+     * 逻辑删除 0未删除 1已删除
+     */
+    @TableField(fill = FieldFill.INSERT)
+    @TableLogic
+    private Integer delFlag;
+
+
+}

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

@@ -0,0 +1,17 @@
+package com.fjhx.params.purchase;
+
+import com.fjhx.entity.purchase.Purchase;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 订单
+ *
+ * @author ${author}
+ * @since 2022-12-01
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class PurchaseEx extends Purchase {
+
+}

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

@@ -0,0 +1,17 @@
+package com.fjhx.params.purchase;
+
+import com.fjhx.entity.purchase.Purchase;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 订单
+ *
+ * @author ${author}
+ * @since 2022-12-01
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class PurchaseVo extends Purchase {
+
+}

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

@@ -0,0 +1,56 @@
+package com.fjhx.controller.purchase;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.springblade.core.tool.api.R;
+import com.fjhx.entity.purchase.Purchase;
+import com.fjhx.params.purchase.PurchaseVo;
+import com.fjhx.service.purchase.PurchaseService;
+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;
+
+import java.util.Map;
+
+/**
+ * <p>
+ * 订单 前端控制器
+ * </p>
+ *
+ * @author ${author}
+ * @since 2022-12-01
+ */
+@RestController
+@RequestMapping("/purchase")
+public class PurchaseController {
+
+    @Autowired
+    private PurchaseService purchaseService;
+
+    @PostMapping("/page")
+    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){
+        purchaseService.add(purchaseVo);
+        return R.success();
+    }
+
+    @PostMapping("/edit")
+    public R edit(@RequestBody PurchaseVo purchaseVo){
+        purchaseService.edit(purchaseVo);
+        return R.success();
+    }
+
+    @PostMapping("/delete")
+    public R delete(@RequestBody PurchaseVo purchaseVo){
+        purchaseService.delete(purchaseVo);
+        return R.success();
+    }
+
+}
+

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

@@ -0,0 +1,16 @@
+package com.fjhx.mapper.purchase;
+
+import com.fjhx.entity.purchase.Purchase;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * 订单 Mapper 接口
+ * </p>
+ *
+ * @author ${author}
+ * @since 2022-12-01
+ */
+public interface PurchaseMapper extends BaseMapper<Purchase> {
+
+}

+ 5 - 0
hx-service/victoriatourist/src/main/java/com/fjhx/mapper/purchase/PurchaseMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fjhx.mapper.purchase.PurchaseMapper">
+
+</mapper>

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

@@ -5,10 +5,13 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fjhx.base.Condition;
 import com.fjhx.entity.apply.ApplyPurchase;
 import com.fjhx.entity.product.ProductInfo;
+import com.fjhx.entity.stock.Stock;
 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.StockService;
 import com.fjhx.uitl.code.CodeEnum;
 import com.fjhx.utils.UserClientUtil;
 import com.fjhx.utils.wrapperUtil.IWrapper;
@@ -19,6 +22,7 @@ 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.util.List;
 import java.util.Map;
 
@@ -36,6 +40,12 @@ public class ApplyPurchaseServiceImpl extends ServiceImpl<ApplyPurchaseMapper, A
     @Autowired
     private RedisLockClient redisLockClient;
 
+    @Autowired
+    private StockService stockService;
+
+    @Autowired
+    private ProductInfoService productInfoService;
+
     private final String REDIS_LOCK_CACHE_KEY = "seq:lock:" + AuthUtil.getTenantId() + ":material:";
 
     @Override
@@ -43,7 +53,16 @@ public class ApplyPurchaseServiceImpl extends ServiceImpl<ApplyPurchaseMapper, A
 
         IWrapper<ApplyPurchase> wrapper = IWrapper.getWrapper(condition);
 
-        wrapper.eq("t1", ApplyPurchase::getReceiptWarehouseId, condition.get("warehouseId")).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::getCreateTime);
+        wrapper.eq("t1", ApplyPurchase::getReceiptWarehouseId, condition.get("warehouseId"))
+                .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())) {
@@ -67,7 +86,10 @@ public class ApplyPurchaseServiceImpl extends ServiceImpl<ApplyPurchaseMapper, A
             if (!checkCodeIsExist(null, code)) {
                 throw new ServiceException("后台自增编码存在重复,请重试或联系管理员!编码:" + code);
             }
-            list.forEach(item -> item.setCode(code));
+            list.forEach(item -> {
+                item.setCode(code);
+                item.setStatus(ApplyPurchaseStatusEnum.STATUS_10.getKey());
+            });
             saveBatch(list);
             return true;
         })) {
@@ -97,16 +119,16 @@ public class ApplyPurchaseServiceImpl extends ServiceImpl<ApplyPurchaseMapper, A
     public Page<Map<String, Object>> applyInPage(Condition condition) {
         IWrapper<Object> wrapper = IWrapper.getWrapper(condition);
         wrapper.func(q -> {
-                    Integer status = condition.getStatus();
-                    if (status == null) {
-                        q.in("ap", ApplyPurchase::getStatus,
-                                ApplyPurchaseStatusEnum.STATUS_30.getKey(),
-                                ApplyPurchaseStatusEnum.STATUS_40.getKey(),
-                                ApplyPurchaseStatusEnum.STATUS_50.getKey());
-                    } else {
-                        q.eq("ap", ApplyPurchase::getStatus);
-                    }
-                })
+            Integer status = condition.getStatus();
+            if (status == null) {
+                q.in("ap", ApplyPurchase::getStatus,
+                        ApplyPurchaseStatusEnum.STATUS_30.getKey(),
+                        ApplyPurchaseStatusEnum.STATUS_40.getKey(),
+                        ApplyPurchaseStatusEnum.STATUS_50.getKey());
+            } else {
+                q.eq("ap", ApplyPurchase::getStatus);
+            }
+        })
                 .eq("ap", ApplyPurchase::getReceiptWarehouseId, condition.getLong("warehouseId"))
                 .like("ap", ApplyPurchase::getCode)
                 .like("pi", ProductInfo::getName, condition.getStr("productName"))
@@ -118,4 +140,25 @@ public class ApplyPurchaseServiceImpl extends ServiceImpl<ApplyPurchaseMapper, A
         return page;
     }
 
+    @Override
+    public ApplyPurchase getById(Serializable id) {
+        ApplyPurchase purchase = super.getById(id);
+        if (Func.isNotEmpty(purchase)) {
+            //查询物品
+            ProductInfo info = productInfoService.getById(purchase.getGoodsId());
+            if (Func.isNotEmpty(info)) {
+                purchase.setGoodsCode(info.getCode());
+                purchase.setGoodsName(info.getName());
+                purchase.setGoodsType(info.getType());
+                purchase.setGoodsUnit(info.getUnit());
+            }
+
+            //查询库存
+            Stock stock = stockService.lambdaQuery().eq(Stock::getWarehouseId, purchase.getReceiptWarehouseId()).eq(Stock::getGoodsId, purchase.getGoodsId()).one();
+            if (Func.isNotEmpty(stock)) {
+                purchase.setStockQuantity(stock.getQuantity());
+            }
+        }
+        return purchase;
+    }
 }

+ 14 - 0
hx-service/victoriatourist/src/main/java/com/fjhx/service/material/impl/MaterialServiceImpl.java

@@ -126,6 +126,11 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
 
     @Override
     public void add(MaterialVo materialVo) {
+        //查询名称是否已存在
+        if (!checkNameIsExist(null, materialVo.getName())) {
+            throw new ServiceException("该物料名称已存在:" + materialVo.getName());
+        }
+
         if (
                 !redisLockClient.lockFair(REDIS_LOCK_CACHE_KEY, () -> {
                     //处理编码
@@ -138,8 +143,17 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
         }
     }
 
+    private Boolean checkNameIsExist(Long id, String name) {
+        List<Material> list = lambdaQuery().ne(Func.isNotEmpty(id), Material::getId, id).eq(Material::getName, name).list();
+        return !Func.isNotEmpty(list);
+    }
+
     @Override
     public void edit(MaterialVo materialVo) {
+        //查询名称是否已存在
+        if (!checkNameIsExist(materialVo.getId(), materialVo.getName())) {
+            throw new ServiceException("该物料名称已存在:" + materialVo.getName());
+        }
         updateById(materialVo);
     }
 

+ 28 - 0
hx-service/victoriatourist/src/main/java/com/fjhx/service/purchase/PurchaseService.java

@@ -0,0 +1,28 @@
+package com.fjhx.service.purchase;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+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}
+ * @since 2022-12-01
+ */
+public interface PurchaseService extends BaseService<Purchase> {
+
+    Page<Purchase> getPage(Map<String, Object> condition);
+
+    void add(PurchaseVo purchaseVo);
+
+    void edit(PurchaseVo purchaseVo);
+
+    void delete(PurchaseVo purchaseVo);
+
+}

+ 48 - 0
hx-service/victoriatourist/src/main/java/com/fjhx/service/purchase/impl/PurchaseServiceImpl.java

@@ -0,0 +1,48 @@
+package com.fjhx.service.purchase.impl;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.entity.purchase.Purchase;
+import com.fjhx.params.purchase.PurchaseVo;
+import com.fjhx.mapper.purchase.PurchaseMapper;
+import com.fjhx.service.purchase.PurchaseService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fjhx.utils.wrapperUtil.IWrapper;
+import org.springframework.stereotype.Service;
+
+import java.util.Map;
+
+/**
+ * <p>
+ * 订单 服务实现类
+ * </p>
+ *
+ * @author ${author}
+ * @since 2022-12-01
+ */
+@Service
+public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase> implements PurchaseService {
+
+    @Override
+    public Page<Purchase> getPage(Map<String, Object> condition) {
+
+        IWrapper<Purchase> wrapper = IWrapper.getWrapper(condition);
+
+        return page(condition, wrapper);
+    }
+
+    @Override
+    public void add(PurchaseVo purchaseVo) {
+        save(purchaseVo);
+    }
+
+    @Override
+    public void edit(PurchaseVo purchaseVo) {
+        updateById(purchaseVo);
+    }
+
+    @Override
+    public void delete(PurchaseVo purchaseVo) {
+        removeById(purchaseVo.getId());
+    }
+
+}