qt5107 2 年之前
父节点
当前提交
4a604987d4

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

@@ -1,17 +1,16 @@
 package com.fjhx.entity.apply;
 
-import java.math.BigDecimal;
-import com.baomidou.mybatisplus.annotation.IdType;
-import java.util.Date;
-import com.baomidou.mybatisplus.annotation.Version;
-import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.Version;
 import com.fjhx.base.BaseEntity;
-import com.baomidou.mybatisplus.annotation.TableField;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
+import java.math.BigDecimal;
+import java.util.Date;
+
 /**
  * <p>
  * 申购单
@@ -51,11 +50,26 @@ public class ApplyPurchase extends BaseEntity {
     private BigDecimal quantity;
 
     /**
+     * 到货数量
+     */
+    private BigDecimal arrivalQuantity;
+
+    /**
      * 单价
      */
     private BigDecimal unitPrice;
 
     /**
+     * 申购金额
+     */
+    private BigDecimal applyPrice;
+
+    /**
+     * 到货金额
+     */
+    private BigDecimal arrivalPrice;
+
+    /**
      * 要求到货时间
      */
     private Date planArrivalTime;
@@ -89,5 +103,39 @@ public class ApplyPurchase extends BaseEntity {
     @TableLogic
     private Integer delFlag;
 
+    /**
+     * 申购人名称
+     */
+    @TableField(exist = false)
+    private String createName;
+
+    /**
+     * 物品类型
+     */
+    @TableField(exist = false)
+    private Integer goodsType;
+
+    /**
+     * 物品编码
+     */
+    @TableField(exist = false)
+    private String goodsCode;
 
+    /**
+     * 物品名称
+     */
+    @TableField(exist = false)
+    private String goodsName;
+
+    /**
+     * 物品单位
+     */
+    @TableField(exist = false)
+    private String goodsUnit;
+
+    /**
+     * 收货仓库名称
+     */
+    @TableField(exist = false)
+    private String warehouseName;
 }

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

@@ -0,0 +1,85 @@
+package com.fjhx.enums.apply;
+
+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 ApplyPurchaseStatusEnum {
+    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, ApplyPurchaseStatusEnum> classMap = new HashMap<>();
+
+    ApplyPurchaseStatusEnum(int key, String value) {
+        this.key = key;
+        this.value = value;
+    }
+
+
+    static {
+        for (ApplyPurchaseStatusEnum value : ApplyPurchaseStatusEnum.values()) {
+            classMap.put(value.getKey(), value);
+        }
+    }
+
+    /**
+     * 根据type获取枚举
+     */
+    public static ApplyPurchaseStatusEnum get(Integer type) {
+        return classMap.get(type);
+    }
+
+    /**
+     * 获取枚举map
+     *
+     * @return
+     */
+    public static Map<Integer, String> getMap() {
+        if (Func.isNotEmpty(map)) {
+            return map;
+        }
+        for (ApplyPurchaseStatusEnum 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;
+    }
+
+}

+ 5 - 0
hx-service/victoriatourist/src/main/java/com/fjhx/mapper/apply/ApplyPurchaseMapper.java

@@ -1,7 +1,11 @@
 package com.fjhx.mapper.apply;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fjhx.entity.apply.ApplyPurchase;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.fjhx.entity.supplier.SupplierPrice;
+import com.fjhx.utils.wrapperUtil.IWrapper;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * <p>
@@ -13,4 +17,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface ApplyPurchaseMapper extends BaseMapper<ApplyPurchase> {
 
+    Page<ApplyPurchase> getPage(@Param("page") Page<ApplyPurchase> page, @Param("ew") IWrapper<ApplyPurchase> wrapper);
 }

+ 29 - 0
hx-service/victoriatourist/src/main/java/com/fjhx/mapper/apply/ApplyPurchaseMapper.xml

@@ -2,4 +2,33 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.fjhx.mapper.apply.ApplyPurchaseMapper">
 
+    <select id="getPage" resultType="com.fjhx.entity.apply.ApplyPurchase">
+        SELECT
+            t1.id,
+            t1.`code`,
+            t1.purchase_id,
+            t1.purchase_code,
+            t1.goods_id,
+            t1.quantity,
+            t1.arrival_quantity,
+            t1.unit_price,
+            t1.apply_price,
+            t1.arrival_price,
+            t1.plan_arrival_time,
+            t1.receipt_warehouse_id,
+            t1.`status`,
+            t1.cause,
+            t1.create_user,
+            t1.create_time,
+            t2.`type` goodsType,
+            t2.`code` goodsCode,
+            t2.`name` goodsName,
+            t2.unit goodsUnit,
+	        t3.`name` warehouseName
+        FROM
+            apply_purchase t1
+            LEFT JOIN material t2 ON t1.goods_id = t2.id
+	        LEFT JOIN warehouse t3 ON t1.receipt_warehouse_id = t3.id
+        ${ew.customSqlSegment}
+    </select>
 </mapper>

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

@@ -7,6 +7,7 @@ import com.fjhx.mapper.apply.ApplyPurchaseMapper;
 import com.fjhx.params.apply.ApplyPurchaseVo;
 import com.fjhx.service.apply.ApplyPurchaseService;
 import com.fjhx.uitl.code.CodeEnum;
+import com.fjhx.utils.UserClientUtil;
 import com.fjhx.utils.wrapperUtil.IWrapper;
 import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.redis.lock.RedisLockClient;
@@ -39,7 +40,28 @@ public class ApplyPurchaseServiceImpl extends ServiceImpl<ApplyPurchaseMapper, A
 
         IWrapper<ApplyPurchase> wrapper = IWrapper.getWrapper(condition);
 
-        return page(condition, wrapper);
+        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);
+
+        Page<ApplyPurchase> page = baseMapper.getPage(createPage(condition), wrapper);
+        if (Func.isNotEmpty(page.getRecords())) {
+            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()));
+                }
+            }
+        }
+
+        return page;
     }
 
     @Override

+ 17 - 1
hx-service/victoriatourist/src/main/java/com/fjhx/service/warehouse/WarehouseService.java

@@ -1,9 +1,9 @@
 package com.fjhx.service.warehouse;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.base.BaseService;
 import com.fjhx.entity.warehouse.Warehouse;
 import com.fjhx.params.warehouse.WarehouseVo;
-import com.fjhx.base.BaseService;
 
 import java.util.List;
 import java.util.Map;
@@ -27,4 +27,20 @@ public interface WarehouseService extends BaseService<Warehouse> {
     void delete(WarehouseVo warehouseVo);
 
     List<Warehouse> select();
+
+    /**
+     * 根据ID查询
+     *
+     * @param ids 仓库ID集合
+     * @return
+     */
+    List<Warehouse> getByIds(List<Long> ids);
+
+    /**
+     * 根据ID查询
+     *
+     * @param ids 仓库ID集合
+     * @return
+     */
+    Map<Long, Warehouse> getByIdsToMap(List<Long> ids);
 }

+ 33 - 0
hx-service/victoriatourist/src/main/java/com/fjhx/service/warehouse/impl/WarehouseServiceImpl.java

@@ -18,8 +18,12 @@ import org.springblade.core.tool.utils.Func;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -89,4 +93,33 @@ public class WarehouseServiceImpl extends ServiceImpl<WarehouseMapper, Warehouse
     public List<Warehouse> select() {
         return lambdaQuery().ne(Warehouse::getType, WarehouseTypeEnum.WAREHOUSE_TYPE_100.getKey()).list();
     }
+
+    /**
+     * 根据ID查询
+     *
+     * @param ids 仓库ID集合
+     * @return
+     */
+    @Override
+    public List<Warehouse> getByIds(List<Long> ids) {
+        if (Func.isEmpty(ids)) {
+            return new ArrayList<>();
+        }
+        return lambdaQuery().in(Warehouse::getId, ids).list();
+    }
+
+    /**
+     * 根据ID查询
+     *
+     * @param ids 仓库ID集合
+     * @return
+     */
+    @Override
+    public Map<Long, Warehouse> getByIdsToMap(List<Long> ids) {
+        List<Warehouse> list = getByIds(ids);
+        if (Func.isEmpty(list)) {
+            return new HashMap<>();
+        }
+        return list.stream().collect(Collectors.toMap(Warehouse::getId, Function.identity(), (key1, key2) -> key2));
+    }
 }