Sfoglia il codice sorgente

仓储费、BI大屏优化

Sun 3 anni fa
parent
commit
d8a99457d0
25 ha cambiato i file con 629 aggiunte e 66 eliminazioni
  1. 5 0
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java
  2. 32 20
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/warehouse/reportManagement/TWarehousebillsitemsSummaryController.java
  3. 12 1
      ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java
  4. 65 0
      ruoyi-system/src/main/java/com/ruoyi/system/domain/TWarehouseUser.java
  5. 94 0
      ruoyi-system/src/main/java/com/ruoyi/system/mapper/TWarehouseUserMapper.java
  6. 42 0
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
  7. 90 0
      ruoyi-system/src/main/resources/mapper/system/TWarehouseUserMapper.xml
  8. 1 1
      ruoyi-warehouse/src/main/java/com/ruoyi/basicData/mapper/TCorpsMapper.java
  9. 8 0
      ruoyi-warehouse/src/main/java/com/ruoyi/basicData/mapper/TWarehouseMapper.java
  10. 1 1
      ruoyi-warehouse/src/main/java/com/ruoyi/basicData/service/ITCorpsService.java
  11. 78 0
      ruoyi-warehouse/src/main/java/com/ruoyi/basicData/service/ITWarehouseUserService.java
  12. 2 2
      ruoyi-warehouse/src/main/java/com/ruoyi/basicData/service/impl/TCorpsServiceImpl.java
  13. 129 0
      ruoyi-warehouse/src/main/java/com/ruoyi/basicData/service/impl/TWarehouseUserServiceImpl.java
  14. 7 4
      ruoyi-warehouse/src/main/java/com/ruoyi/reportManagement/mapper/TWhgenlegMapper.java
  15. 5 5
      ruoyi-warehouse/src/main/java/com/ruoyi/reportManagement/service/ITWhgenlegService.java
  16. 16 16
      ruoyi-warehouse/src/main/java/com/ruoyi/reportManagement/service/impl/TWhgenlegServiceImpl.java
  17. 3 2
      ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/mapper/TWarehousebillsitemsMapper.java
  18. 2 2
      ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/ITWarehousebillsitemsService.java
  19. 11 4
      ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/impl/TWarehouseBillsServiceImpl.java
  20. 4 4
      ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/impl/TWarehousebillsitemsServiceImpl.java
  21. 5 2
      ruoyi-warehouse/src/main/resources/mapper/basicData/TCorpsMapper.xml
  22. 8 0
      ruoyi-warehouse/src/main/resources/mapper/basicData/TWarehouseMapper.xml
  23. 6 2
      ruoyi-warehouse/src/main/resources/mapper/reportManagement/TWhgenlegMapper.xml
  24. 1 0
      ruoyi-warehouse/src/main/resources/mapper/warehouseBusiness/TWarehousebillsMapper.xml
  25. 2 0
      ruoyi-warehouse/src/main/resources/mapper/warehouseBusiness/TWarehousebillsitemsMapper.xml

+ 5 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java

@@ -1,5 +1,6 @@
 package com.ruoyi.web.controller.system;
 
+import com.ruoyi.basicData.service.ITWarehouseUserService;
 import com.ruoyi.common.annotation.Log;
 import com.ruoyi.common.constant.UserConstants;
 import com.ruoyi.common.core.controller.BaseController;
@@ -54,6 +55,9 @@ public class SysUserController extends BaseController {
     @Autowired
     private ISysDeptService deptService;
 
+    @Autowired
+    private ITWarehouseUserService itWarehouseUserService;
+
     /**
      * 查询 当前登录用户
      * @return
@@ -120,6 +124,7 @@ public class SysUserController extends BaseController {
             ajax.put(AjaxResult.DATA_TAG, userService.selectUserById(userId));
             ajax.put("postIds", postService.selectPostListByUserId(userId));
             ajax.put("roleIds", roleService.selectRoleListByUserId(userId));
+            ajax.put("warehouseIds", itWarehouseUserService.selectWarehouseListByUserId(userId));
         }
         return ajax;
     }

+ 32 - 20
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warehouse/reportManagement/TWarehousebillsitemsSummaryController.java

@@ -1,6 +1,7 @@
 package com.ruoyi.web.controller.warehouse.reportManagement;
 
 import com.ruoyi.basicData.service.ITCorpsService;
+import com.ruoyi.basicData.service.ITWarehouseUserService;
 import com.ruoyi.common.annotation.DataScope;
 import com.ruoyi.common.annotation.Log;
 import com.ruoyi.common.core.controller.BaseController;
@@ -48,6 +49,9 @@ public class TWarehousebillsitemsSummaryController extends BaseController {
     @Autowired
     private ITWarehouseAgreementService itWarehouseAgreementService;
 
+    @Autowired
+    private ITWarehouseUserService itWarehouseUserService;
+
     /**
      * 查询库存总账列表
      */
@@ -106,43 +110,51 @@ public class TWarehousebillsitemsSummaryController extends BaseController {
     }
 
     /**
+     * bi大屏仓库列表
+     */
+    @GetMapping("/biWarehouseList")
+    public AjaxResult biWarehouseList() {
+        return AjaxResult.success(itWarehouseUserService.biWarehouseList());
+    }
+
+    /**
      * bi大屏客户数量
      */
     @GetMapping("/biCustomerCount")
-    public AjaxResult biCustomerCount() {
-        return AjaxResult.success(itCorpsService.biCustomerCount());
+    public AjaxResult biCustomerCount(Long warehouseId) {
+        return AjaxResult.success(itCorpsService.biCustomerCount(warehouseId));
     }
 
     /**
      * bi大屏客户概况
      */
     @GetMapping("/biCustomerInfo")
-    public AjaxResult biCustomerInfo() {
-        return AjaxResult.success(itWhgenlegService.biCustomerInfo());
+    public AjaxResult biCustomerInfo(Long warehouseId) {
+        return AjaxResult.success(itWhgenlegService.biCustomerInfo(warehouseId));
     }
 
     /**
      * bi当日入库量
      */
     @GetMapping("/biTodayInStockCount")
-    public AjaxResult biTodayInStockCount() {
-        return AjaxResult.success(itWarehousebillsitemsService.biTodayInAndOutStockCount("SJRK"));
+    public AjaxResult biTodayInStockCount(Long warehouseId) {
+        return AjaxResult.success(itWarehousebillsitemsService.biTodayInAndOutStockCount("SJRK", warehouseId));
     }
 
     /**
      * bi当日出库量
      */
     @GetMapping("/biTodayOutStockCount")
-    public AjaxResult biTodayOutStockCount() {
-        return AjaxResult.success(itWarehousebillsitemsService.biTodayInAndOutStockCount("SJCK"));
+    public AjaxResult biTodayOutStockCount(Long warehouseId) {
+        return AjaxResult.success(itWarehousebillsitemsService.biTodayInAndOutStockCount("SJCK", warehouseId));
     }
 
     /**
      * bi库存数量
      */
     @GetMapping("/biStockCount")
-    public AjaxResult biStockCount() {
-        return AjaxResult.success(itWhgenlegService.biStockCount());
+    public AjaxResult biStockCount(Long warehouseId) {
+        return AjaxResult.success(itWhgenlegService.biStockCount(warehouseId));
     }
 
     /**
@@ -157,42 +169,42 @@ public class TWarehousebillsitemsSummaryController extends BaseController {
      * bi大屏商品概况
      */
     @GetMapping("/biGoodsInfo")
-    public AjaxResult biGoodsInfo() {
-        return AjaxResult.success(itWhgenlegService.biGoodsInfo());
+    public AjaxResult biGoodsInfo(Long warehouseId) {
+        return AjaxResult.success(itWhgenlegService.biGoodsInfo(warehouseId));
     }
 
     /**
      * bi大屏最大库龄
      */
     @GetMapping("/biMaxStockDays")
-    public AjaxResult biMaxStockDays() {
-        return AjaxResult.success(itWhgenlegService.biMaxStockDays());
+    public AjaxResult biMaxStockDays(Long warehouseId) {
+        return AjaxResult.success(itWhgenlegService.biMaxStockDays(warehouseId));
     }
 
     /**
      * bi大屏库龄概况
      */
     @GetMapping("/biStockDaysInfo")
-    public AjaxResult biStockDaysInfo() {
-        return AjaxResult.success(itWhgenlegService.biStockDaysInfo());
+    public AjaxResult biStockDaysInfo(Long warehouseId) {
+        return AjaxResult.success(itWhgenlegService.biStockDaysInfo(warehouseId));
     }
 
     /**
      * bi大屏入库列表
      */
     @GetMapping("/biInStockList")
-    public TableDataInfo biInStockList() {
+    public TableDataInfo biInStockList(Long warehouseId) {
         startPage();
-        return getDataTable(itWarehousebillsitemsService.biInAndOutStockList("SJRK"));
+        return getDataTable(itWarehousebillsitemsService.biInAndOutStockList("SJRK", warehouseId));
     }
 
     /**
      * bi大屏出库列表
      */
     @GetMapping("/biOutStockList")
-    public TableDataInfo biOutStockList() {
+    public TableDataInfo biOutStockList(Long warehouseId) {
         startPage();
-        return getDataTable(itWarehousebillsitemsService.biInAndOutStockList("SJCK"));
+        return getDataTable(itWarehousebillsitemsService.biInAndOutStockList("SJCK", warehouseId));
     }
 
     /**

+ 12 - 1
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java

@@ -3,6 +3,7 @@ package com.ruoyi.common.core.domain.entity;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 import javax.validation.constraints.Email;
 import javax.validation.constraints.NotBlank;
 import javax.validation.constraints.Size;
@@ -18,7 +19,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
 
 /**
  * 用户对象 sys_user
- * 
+ *
  * @author ruoyi
  */
 public class SysUser extends BaseEntity
@@ -115,6 +116,8 @@ public class SysUser extends BaseEntity
     /** 岗位组 */
     private Long[] postIds;
 
+    private Long[] warehouseIds;
+
     public String getUserSystem() {
         return userSystem;
     }
@@ -397,6 +400,14 @@ public class SysUser extends BaseEntity
         this.postIds = postIds;
     }
 
+    public Long[] getWarehouseIds() {
+        return warehouseIds;
+    }
+
+    public void setWarehouseIds(Long[] warehouseIds) {
+        this.warehouseIds = warehouseIds;
+    }
+
     @Override
     public String toString() {
         return "SysUser{" +

+ 65 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/TWarehouseUser.java

@@ -0,0 +1,65 @@
+package com.ruoyi.system.domain;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.core.domain.BaseEntity;
+
+/**
+ * 仓库和用户关联对象 t_warehouse_user
+ *
+ * @author ruoyi
+ * @date 2022-01-05
+ */
+public class TWarehouseUser extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 用户ID
+     */
+    private Long userId;
+
+    /**
+     * 仓库ID
+     */
+    private Long warehouseId;
+
+    /**
+     * 仓库名称
+     */
+    @Excel(name = "仓库名称")
+    private String warehouseName;
+
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
+    public Long getUserId() {
+        return userId;
+    }
+
+    public void setWarehouseId(Long warehouseId) {
+        this.warehouseId = warehouseId;
+    }
+
+    public Long getWarehouseId() {
+        return warehouseId;
+    }
+
+    public void setWarehouseName(String warehouseName) {
+        this.warehouseName = warehouseName;
+    }
+
+    public String getWarehouseName() {
+        return warehouseName;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+                .append("userId", getUserId())
+                .append("warehouseId", getWarehouseId())
+                .append("warehouseName", getWarehouseName())
+                .toString();
+    }
+}

+ 94 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TWarehouseUserMapper.java

@@ -0,0 +1,94 @@
+package com.ruoyi.system.mapper;
+
+import com.ruoyi.system.domain.TWarehouseUser;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 仓库和用户关联Mapper接口
+ *
+ * @author ruoyi
+ * @date 2022-01-05
+ */
+public interface TWarehouseUserMapper {
+    /**
+     * 查询仓库和用户关联
+     *
+     * @param userId 仓库和用户关联ID
+     * @return 仓库和用户关联
+     */
+    public TWarehouseUser selectTWarehouseUserById(Long userId);
+
+    /**
+     * 查询仓库和用户关联列表
+     *
+     * @param tWarehouseUser 仓库和用户关联
+     * @return 仓库和用户关联集合
+     */
+    public List<TWarehouseUser> selectTWarehouseUserList(TWarehouseUser tWarehouseUser);
+
+    /**
+     * 根据用户ID获取仓库选择框列表
+     *
+     * @param userId 用户ID
+     * @return 选中仓库ID列表
+     */
+    public List<Long> selectWarehouseListByUserId(Long userId);
+
+    /**
+     * 新增仓库和用户关联
+     *
+     * @param tWarehouseUser 仓库和用户关联
+     * @return 结果
+     */
+    public int insertTWarehouseUser(TWarehouseUser tWarehouseUser);
+
+    /**
+     * 修改仓库和用户关联
+     *
+     * @param tWarehouseUser 仓库和用户关联
+     * @return 结果
+     */
+    public int updateTWarehouseUser(TWarehouseUser tWarehouseUser);
+
+    /**
+     * 删除仓库和用户关联
+     *
+     * @param userId 仓库和用户关联ID
+     * @return 结果
+     */
+    public int deleteTWarehouseUserById(Long userId);
+
+    /**
+     * 批量删除仓库和用户关联
+     *
+     * @param userIds 需要删除的数据ID
+     * @return 结果
+     */
+    public int deleteTWarehouseUserByIds(Long[] userIds);
+
+    /**
+     * 批量新增用户岗位信息
+     *
+     * @param warehouseUserList 用户仓库列表
+     * @return 结果
+     */
+    public int batchWarehouseUser(List<TWarehouseUser> warehouseUserList);
+
+    /**
+     * 批量新增用户岗位信息
+     *
+     * @param warehouseId 仓库ID
+     * @return 结果
+     */
+    public Map<String, Object> getWarehouseName(Long warehouseId);
+
+    /**
+     * bi大屏仓库列表
+     *
+     * @return 仓库集合
+     */
+    public List<Map<String, Object>> biWarehouseList(Long userId);
+
+}

+ 42 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java

@@ -15,6 +15,7 @@ import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.system.domain.SysPost;
 import com.ruoyi.system.domain.SysUserPost;
 import com.ruoyi.system.domain.SysUserRole;
+import com.ruoyi.system.domain.TWarehouseUser;
 import com.ruoyi.system.mapper.*;
 import com.ruoyi.system.service.ISysConfigService;
 import com.ruoyi.system.service.ISysUserService;
@@ -64,6 +65,9 @@ public class SysUserServiceImpl implements ISysUserService {
     @Autowired
     private SysUserPostMapper userPostMapper;
 
+    @Autowired
+    private TWarehouseUserMapper warehouseUserMapper;
+
 
     // 微信小程序应用id
     @Value("${wechatProgram.appId}")
@@ -236,6 +240,8 @@ public class SysUserServiceImpl implements ISysUserService {
         insertUserPost(user);
         // 新增用户与角色管理
         insertUserRole(user);
+        // 新增用户与仓库关联
+        insertUserWarehouse(user);
         return rows;
     }
 
@@ -257,6 +263,10 @@ public class SysUserServiceImpl implements ISysUserService {
         userPostMapper.deleteUserPostByUserId(userId);
         // 新增用户与岗位管理
         insertUserPost(user);
+        // 删除用户与仓库关联
+        warehouseUserMapper.deleteTWarehouseUserById(userId);
+        // 新增用户与仓库管理
+        insertUserWarehouse(user);
         userMapper.updateCarsDriverNamePhone(userId);
         return userMapper.updateUser(user);
     }
@@ -363,6 +373,38 @@ public class SysUserServiceImpl implements ISysUserService {
     }
 
     /**
+     * 新增用户仓库信息
+     *
+     * @param user 用户对象
+     */
+    public void insertUserWarehouse(SysUser user) {
+        Long[] warehouseIds = user.getWarehouseIds();
+        if (StringUtils.isNotNull(warehouseIds)) {
+            // 新增用户与仓库信息
+            List<TWarehouseUser> list = new ArrayList<>();
+            for (Long warehouseId : warehouseIds) {
+                TWarehouseUser ws = new TWarehouseUser();
+                ws.setUserId(user.getUserId());
+
+                if (warehouseId == 0) {
+                    ws.setWarehouseId(warehouseId);
+                    ws.setWarehouseName("0");
+                    list.clear();
+                    list.add(ws);
+                    break;
+                }
+
+                ws.setWarehouseId(warehouseId);
+                ws.setWarehouseName(String.valueOf(warehouseUserMapper.getWarehouseName(warehouseId).get("warehouseName")));
+                list.add(ws);
+            }
+            if (list.size() > 0) {
+                warehouseUserMapper.batchWarehouseUser(list);
+            }
+        }
+    }
+
+    /**
      * 通过用户ID删除用户
      *
      * @param userId 用户ID

+ 90 - 0
ruoyi-system/src/main/resources/mapper/system/TWarehouseUserMapper.xml

@@ -0,0 +1,90 @@
+<?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.ruoyi.system.mapper.TWarehouseUserMapper">
+
+    <resultMap type="TWarehouseUser" id="TWarehouseUserResult">
+        <result property="userId"    column="user_id"    />
+        <result property="warehouseId"    column="warehouse_id"    />
+        <result property="warehouseName"    column="warehouse_name"    />
+    </resultMap>
+
+    <sql id="selectTWarehouseUserVo">
+        select user_id, warehouse_id, warehouse_name from t_warehouse_user
+    </sql>
+
+    <select id="selectTWarehouseUserList" parameterType="TWarehouseUser" resultMap="TWarehouseUserResult">
+        <include refid="selectTWarehouseUserVo"/>
+        <where>
+            <if test="warehouseName != null  and warehouseName != ''"> and warehouse_name like concat('%', #{warehouseName}, '%')</if>
+        </where>
+    </select>
+
+    <select id="selectWarehouseListByUserId" parameterType="Long" resultType="Long">
+        select warehouse_id
+        from t_warehouse_user
+        where user_id = #{userId}
+    </select>
+
+    <select id="selectTWarehouseUserById" parameterType="Long" resultMap="TWarehouseUserResult">
+        <include refid="selectTWarehouseUserVo"/>
+        where user_id = #{userId}
+    </select>
+
+    <insert id="insertTWarehouseUser" parameterType="TWarehouseUser">
+        insert into t_warehouse_user
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="userId != null">user_id,</if>
+            <if test="warehouseId != null">warehouse_id,</if>
+            <if test="warehouseName != null and warehouseName != ''">warehouse_name,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="userId != null">#{userId},</if>
+            <if test="warehouseId != null">#{warehouseId},</if>
+            <if test="warehouseName != null and warehouseName != ''">#{warehouseName},</if>
+         </trim>
+    </insert>
+
+    <update id="updateTWarehouseUser" parameterType="TWarehouseUser">
+        update t_warehouse_user
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="warehouseId != null">warehouse_id = #{warehouseId},</if>
+            <if test="warehouseName != null and warehouseName != ''">warehouse_name = #{warehouseName},</if>
+        </trim>
+        where user_id = #{userId}
+    </update>
+
+    <delete id="deleteTWarehouseUserById" parameterType="Long">
+        delete from t_warehouse_user where user_id = #{userId}
+    </delete>
+
+    <delete id="deleteTWarehouseUserByIds" parameterType="String">
+        delete from t_warehouse_user where user_id in
+        <foreach item="userId" collection="array" open="(" separator="," close=")">
+            #{userId}
+        </foreach>
+    </delete>
+
+    <insert id="batchWarehouseUser">
+        insert into t_warehouse_user(user_id, warehouse_id, warehouse_name) values
+        <foreach item="item" index="index" collection="list" separator=",">
+            (#{item.userId}, #{item.warehouseId}, #{item.warehouseName})
+        </foreach>
+    </insert>
+
+    <select id="getWarehouseName" parameterType="Long" resultType="map">
+        select f_name as warehouseName
+        from t_warehouse
+        where f_id = #{warehouseId}
+    </select>
+
+    <select id="biWarehouseList" parameterType="Long" resultType="map">
+        select
+            warehouse_id as warehouseId,
+            warehouse_name as warehouseName
+        from t_warehouse_user
+        where user_id = #{userId}
+    </select>
+
+</mapper>

+ 1 - 1
ruoyi-warehouse/src/main/java/com/ruoyi/basicData/mapper/TCorpsMapper.java

@@ -160,6 +160,6 @@ public interface TCorpsMapper extends BaseMapper<TCorps> {
      *
      * @return
      */
-    public Map<String, Object> biCustomerCount();
+    public Map<String, Object> biCustomerCount(Long warehouseId);
 
 }

+ 8 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/basicData/mapper/TWarehouseMapper.java

@@ -171,4 +171,12 @@ public interface TWarehouseMapper {
      * @return
      */
     List<TWarehouse> lazyList(TWarehouse tWarehouse);
+
+    /**
+     * bi大屏仓库列表
+     *
+     * @return 仓库集合
+     */
+    public List<Map<String, Object>> biWarehouseList();
+
 }

+ 1 - 1
ruoyi-warehouse/src/main/java/com/ruoyi/basicData/service/ITCorpsService.java

@@ -119,6 +119,6 @@ public interface ITCorpsService {
      *
      * @return
      */
-    public Map<String, Object> biCustomerCount();
+    public Map<String, Object> biCustomerCount(Long warehouseId);
 
 }

+ 78 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/basicData/service/ITWarehouseUserService.java

@@ -0,0 +1,78 @@
+package com.ruoyi.basicData.service;
+
+import java.util.List;
+import java.util.Map;
+
+import com.ruoyi.system.domain.TWarehouseUser;
+
+/**
+ * 仓库和用户关联Service接口
+ *
+ * @author ruoyi
+ * @date 2022-01-05
+ */
+public interface ITWarehouseUserService {
+    /**
+     * 查询仓库和用户关联
+     *
+     * @param userId 仓库和用户关联ID
+     * @return 仓库和用户关联
+     */
+    public TWarehouseUser selectTWarehouseUserById(Long userId);
+
+    /**
+     * 查询仓库和用户关联列表
+     *
+     * @param tWarehouseUser 仓库和用户关联
+     * @return 仓库和用户关联集合
+     */
+    public List<TWarehouseUser> selectTWarehouseUserList(TWarehouseUser tWarehouseUser);
+
+    /**
+     * 根据用户ID获取仓库选择框列表
+     *
+     * @param userId 用户ID
+     * @return 选中仓库ID列表
+     */
+    public List<Long> selectWarehouseListByUserId(Long userId);
+
+    /**
+     * 新增仓库和用户关联
+     *
+     * @param tWarehouseUser 仓库和用户关联
+     * @return 结果
+     */
+    public int insertTWarehouseUser(TWarehouseUser tWarehouseUser);
+
+    /**
+     * 修改仓库和用户关联
+     *
+     * @param tWarehouseUser 仓库和用户关联
+     * @return 结果
+     */
+    public int updateTWarehouseUser(TWarehouseUser tWarehouseUser);
+
+    /**
+     * 批量删除仓库和用户关联
+     *
+     * @param userIds 需要删除的仓库和用户关联ID
+     * @return 结果
+     */
+    public int deleteTWarehouseUserByIds(Long[] userIds);
+
+    /**
+     * 删除仓库和用户关联信息
+     *
+     * @param userId 仓库和用户关联ID
+     * @return 结果
+     */
+    public int deleteTWarehouseUserById(Long userId);
+
+    /**
+     * bi大屏仓库列表
+     *
+     * @return 仓库集合
+     */
+    public List<Map<String, Object>> biWarehouseList();
+
+}

+ 2 - 2
ruoyi-warehouse/src/main/java/com/ruoyi/basicData/service/impl/TCorpsServiceImpl.java

@@ -383,8 +383,8 @@ public class TCorpsServiceImpl implements ITCorpsService {
      * @return
      */
     @Override
-    public Map<String, Object> biCustomerCount() {
-        return tCorpsMapper.biCustomerCount();
+    public Map<String, Object> biCustomerCount(Long warehouseId) {
+        return tCorpsMapper.biCustomerCount(warehouseId);
     }
 
 }

+ 129 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/basicData/service/impl/TWarehouseUserServiceImpl.java

@@ -0,0 +1,129 @@
+package com.ruoyi.basicData.service.impl;
+
+import java.util.List;
+import java.util.Map;
+
+import com.ruoyi.basicData.mapper.TWarehouseMapper;
+import com.ruoyi.common.core.domain.entity.SysUser;
+import com.ruoyi.common.utils.SecurityUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.ruoyi.system.mapper.TWarehouseUserMapper;
+import com.ruoyi.system.domain.TWarehouseUser;
+import com.ruoyi.basicData.service.ITWarehouseUserService;
+
+/**
+ * 仓库和用户关联Service业务层处理
+ *
+ * @author ruoyi
+ * @date 2022-01-05
+ */
+@Service
+public class TWarehouseUserServiceImpl implements ITWarehouseUserService {
+    @Autowired
+    private TWarehouseUserMapper tWarehouseUserMapper;
+
+    @Autowired
+    private TWarehouseMapper tWarehouseMapper;
+
+    /**
+     * 查询仓库和用户关联
+     *
+     * @param userId 仓库和用户关联ID
+     * @return 仓库和用户关联
+     */
+    @Override
+    public TWarehouseUser selectTWarehouseUserById(Long userId) {
+        return tWarehouseUserMapper.selectTWarehouseUserById(userId);
+    }
+
+    /**
+     * 查询仓库和用户关联列表
+     *
+     * @param tWarehouseUser 仓库和用户关联
+     * @return 仓库和用户关联
+     */
+    @Override
+    public List<TWarehouseUser> selectTWarehouseUserList(TWarehouseUser tWarehouseUser) {
+        return tWarehouseUserMapper.selectTWarehouseUserList(tWarehouseUser);
+    }
+
+    /**
+     * 根据用户ID获取仓库选择框列表
+     *
+     * @param userId 用户ID
+     * @return 选中仓库ID列表
+     */
+    @Override
+    public List<Long> selectWarehouseListByUserId(Long userId) {
+        return tWarehouseUserMapper.selectWarehouseListByUserId(userId);
+    }
+
+    /**
+     * 新增仓库和用户关联
+     *
+     * @param tWarehouseUser 仓库和用户关联
+     * @return 结果
+     */
+    @Override
+    public int insertTWarehouseUser(TWarehouseUser tWarehouseUser) {
+        return tWarehouseUserMapper.insertTWarehouseUser(tWarehouseUser);
+    }
+
+    /**
+     * 修改仓库和用户关联
+     *
+     * @param tWarehouseUser 仓库和用户关联
+     * @return 结果
+     */
+    @Override
+    public int updateTWarehouseUser(TWarehouseUser tWarehouseUser) {
+        return tWarehouseUserMapper.updateTWarehouseUser(tWarehouseUser);
+    }
+
+    /**
+     * 批量删除仓库和用户关联
+     *
+     * @param userIds 需要删除的仓库和用户关联ID
+     * @return 结果
+     */
+    @Override
+    public int deleteTWarehouseUserByIds(Long[] userIds) {
+        return tWarehouseUserMapper.deleteTWarehouseUserByIds(userIds);
+    }
+
+    /**
+     * 删除仓库和用户关联信息
+     *
+     * @param userId 仓库和用户关联ID
+     * @return 结果
+     */
+    @Override
+    public int deleteTWarehouseUserById(Long userId) {
+        return tWarehouseUserMapper.deleteTWarehouseUserById(userId);
+    }
+
+    /**
+     * bi大屏仓库列表
+     *
+     * @return 仓库集合
+     */
+    @Override
+    public List<Map<String, Object>> biWarehouseList() {
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        if (user.isAdmin()) {
+            return tWarehouseMapper.biWarehouseList();
+        }
+
+        List<Map<String, Object>> warehouseList = tWarehouseUserMapper.biWarehouseList(user.getUserId());
+        if (warehouseList.size() == 1) {
+            Long warehouseId = (Long) warehouseList.get(0).get("warehouseId");
+            if (warehouseId == 0) {
+                return tWarehouseMapper.biWarehouseList();
+            }
+        }
+
+        return warehouseList;
+    }
+
+}

+ 7 - 4
ruoyi-warehouse/src/main/java/com/ruoyi/reportManagement/mapper/TWhgenlegMapper.java

@@ -173,14 +173,17 @@ public interface TWhgenlegMapper {
      * @param external 外部用户
      * @return
      */
-    public Map<String, Object> stockStatistics(@Param("beginDate") String beginDate, @Param("endDate") String endDate, @Param("external") String external);
+    public Map<String, Object> stockStatistics(@Param("beginDate") String beginDate,
+                                               @Param("endDate") String endDate,
+                                               @Param("external") String external,
+                                               @Param("warehouseId") Long warehouseId);
 
     /**
      * 库龄
      * @param external 外部用户
      * @return
      */
-    public Map<String, Object> stockDays(@Param("external") String external);
+    public Map<String, Object> stockDays(@Param("external") String external, @Param("warehouseId") Long warehouseId);
 
     /**
      * 库龄超过60天的库存列表
@@ -194,13 +197,13 @@ public interface TWhgenlegMapper {
      *
      * @return
      */
-    public List<Map<String, Object>> biCustomerInfo();
+    public List<Map<String, Object>> biCustomerInfo(Long warehouseId);
 
     /**
      * bi大屏商品概况
      *
      * @return
      */
-    public List<Map<String, Object>> biGoodsInfo();
+    public List<Map<String, Object>> biGoodsInfo(Long warehouseId);
 
 }

+ 5 - 5
ruoyi-warehouse/src/main/java/com/ruoyi/reportManagement/service/ITWhgenlegService.java

@@ -171,34 +171,34 @@ public interface ITWhgenlegService {
      *
      * @return
      */
-    public List<Map<String, Object>> biCustomerInfo();
+    public List<Map<String, Object>> biCustomerInfo(Long warehouseId);
 
     /**
      * bi库存数量
      *
      * @return
      */
-    public Map<String, Object> biStockCount();
+    public Map<String, Object> biStockCount(Long warehouseId);
 
     /**
      * bi大屏商品概况
      *
      * @return
      */
-    public List<Map<String, Object>> biGoodsInfo();
+    public List<Map<String, Object>> biGoodsInfo(Long warehouseId);
 
     /**
      * bi大屏最大库龄
      *
      * @return
      */
-    public Map<String, Object> biMaxStockDays();
+    public Map<String, Object> biMaxStockDays(Long warehouseId);
 
     /**
      * bi大屏库龄概况
      *
      * @return
      */
-    public List<Map<String, Object>> biStockDaysInfo();
+    public List<Map<String, Object>> biStockDaysInfo(Long warehouseId);
 
 }

+ 16 - 16
ruoyi-warehouse/src/main/java/com/ruoyi/reportManagement/service/impl/TWhgenlegServiceImpl.java

@@ -637,8 +637,8 @@ public class TWhgenlegServiceImpl implements ITWhgenlegService {
      * @return
      */
     @Override
-    public List<Map<String, Object>> biCustomerInfo() {
-        return tWhgenlegMapper.biCustomerInfo();
+    public List<Map<String, Object>> biCustomerInfo(Long warehouseId) {
+        return tWhgenlegMapper.biCustomerInfo(warehouseId);
     }
 
     /**
@@ -647,8 +647,8 @@ public class TWhgenlegServiceImpl implements ITWhgenlegService {
      * @return
      */
     @Override
-    public Map<String, Object> biStockCount() {
-        return tWhgenlegMapper.stockStatistics(null, null, null);
+    public Map<String, Object> biStockCount(Long warehouseId) {
+        return tWhgenlegMapper.stockStatistics(null, null, null, warehouseId);
     }
 
     /**
@@ -657,8 +657,8 @@ public class TWhgenlegServiceImpl implements ITWhgenlegService {
      * @return
      */
     @Override
-    public List<Map<String, Object>> biGoodsInfo() {
-        return tWhgenlegMapper.biGoodsInfo();
+    public List<Map<String, Object>> biGoodsInfo(Long warehouseId) {
+        return tWhgenlegMapper.biGoodsInfo(warehouseId);
     }
 
     /**
@@ -667,8 +667,8 @@ public class TWhgenlegServiceImpl implements ITWhgenlegService {
      * @return
      */
     @Override
-    public Map<String, Object> biMaxStockDays() {
-        return tWhgenlegMapper.stockDays(null);
+    public Map<String, Object> biMaxStockDays(Long warehouseId) {
+        return tWhgenlegMapper.stockDays(null, warehouseId);
     }
 
     /**
@@ -677,42 +677,42 @@ public class TWhgenlegServiceImpl implements ITWhgenlegService {
      * @return
      */
     @Override
-    public List<Map<String, Object>> biStockDaysInfo() {
+    public List<Map<String, Object>> biStockDaysInfo(Long warehouseId) {
         List<Map<String, Object>> data = new ArrayList<>();
         Map<String, Object> item;
 
         item = tWhgenlegMapper.stockStatistics(DateUtils.offsetDate(-6) + " 00:00:00",
-                null, null);
+                null, null, warehouseId);
         item.put("name", "7天以内");
         data.add(item);
 
         item = tWhgenlegMapper.stockStatistics(DateUtils.offsetDate(-14) + " 00:00:00",
-                DateUtils.offsetDate(-6) + " 00:00:00", null);
+                DateUtils.offsetDate(-6) + " 00:00:00", null, warehouseId);
         item.put("name", "7~15天");
         data.add(item);
 
         item = tWhgenlegMapper.stockStatistics(DateUtils.offsetDate(-29) + " 00:00:00",
-                DateUtils.offsetDate(-14) + " 00:00:00", null);
+                DateUtils.offsetDate(-14) + " 00:00:00", null, warehouseId);
         item.put("name", "15~30天");
         data.add(item);
 
         item = tWhgenlegMapper.stockStatistics(DateUtils.offsetDate(-59) + " 00:00:00",
-                DateUtils.offsetDate(-29) + " 00:00:00", null);
+                DateUtils.offsetDate(-29) + " 00:00:00", null, warehouseId);
         item.put("name", "30~60天");
         data.add(item);
 
         item = tWhgenlegMapper.stockStatistics(DateUtils.offsetDate(-89) + " 00:00:00",
-                DateUtils.offsetDate(-59) + " 00:00:00", null);
+                DateUtils.offsetDate(-59) + " 00:00:00", null, warehouseId);
         item.put("name", "60~90天");
         data.add(item);
 
         item = tWhgenlegMapper.stockStatistics(DateUtils.offsetDate(-179) + " 00:00:00",
-                DateUtils.offsetDate(-89) + " 00:00:00", null);
+                DateUtils.offsetDate(-89) + " 00:00:00", null, warehouseId);
         item.put("name", "90~180天");
         data.add(item);
 
         item = tWhgenlegMapper.stockStatistics(null,
-                DateUtils.offsetDate(-179) + " 00:00:00", null);
+                DateUtils.offsetDate(-179) + " 00:00:00", null, warehouseId);
         item.put("name", "超过180天");
         data.add(item);
 

+ 3 - 2
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/mapper/TWarehousebillsitemsMapper.java

@@ -298,7 +298,8 @@ public interface TWarehousebillsitemsMapper extends BaseMapper<TWarehousebillsit
     public Map<String, Object> inAndOutStockStatistics(@Param("billType") String billType,
                                                        @Param("beginDate") String beginDate,
                                                        @Param("endDate") String endDate,
-                                                       @Param("external") String external);
+                                                       @Param("external") String external,
+                                                       @Param("warehouseId") Long warehouseId);
 
     /**
      * bi出入库列表
@@ -306,6 +307,6 @@ public interface TWarehousebillsitemsMapper extends BaseMapper<TWarehousebillsit
      * @param billType 单据类型
      * @return
      */
-    public List<Map<String,Object>> biInAndOutStockList(@Param("billType") String billType);
+    public List<Map<String,Object>> biInAndOutStockList(@Param("billType") String billType, @Param("warehouseId") Long warehouseId);
 
 }

+ 2 - 2
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/ITWarehousebillsitemsService.java

@@ -90,7 +90,7 @@ public interface ITWarehousebillsitemsService {
      * @param billType 单据类型
      * @return
      */
-    public Map<String,Object> biTodayInAndOutStockCount(String billType);
+    public Map<String,Object> biTodayInAndOutStockCount(String billType, Long warehouseId);
 
     /**
      * bi出入库列表
@@ -98,6 +98,6 @@ public interface ITWarehousebillsitemsService {
      * @param billType 单据类型
      * @return
      */
-    public List<Map<String,Object>> biInAndOutStockList(String billType);
+    public List<Map<String,Object>> biInAndOutStockList(String billType, Long warehouseId);
 
 }

+ 11 - 4
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/impl/TWarehouseBillsServiceImpl.java

@@ -4058,7 +4058,7 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
             if (Objects.equals(item.getFChargedate().getTime(), item.getFOriginalbilldate().getTime())) {
                 storageFeesDto.setEarlySumDays(0L);
             } else {
-                storageFeesDto.setEarlySumDays(DateUtils.getDateDay(item.getFChargedate(), item.getFOriginalbilldate()));
+                storageFeesDto.setEarlySumDays(DateUtils.getDateDay(item.getFChargedate(), item.getFOriginalbilldate()) - 1);
             }
             // 库存天数
             long fInventoryDays;
@@ -5994,6 +5994,13 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
                     if (wb.getfIsInventory().equals(0L)) {
                         if (StringUtils.isNotNull(tWhgenle) && (wb.getfQty() <= tWhgenle.getfQtyblc())) { // 非空 且 撤销数 <= 结余数
                             updateTWhgenlegData(wb, tWhgenle.getfId(), billsType);
+                            TWhgenleg whgenleg = tWhgenlegMapper.selectTWhgenlegById(tWhgenle.getfId());
+                            Long qtyblc = whgenleg.getfQtyblc();
+                            BigDecimal grossweightblc = whgenleg.getfGrossweightblc();
+                            BigDecimal netweightblc = whgenleg.getfNetweightblc();
+                            if (qtyblc == 0 && grossweightblc.compareTo(BigDecimal.ZERO) == 0 && netweightblc.compareTo(BigDecimal.ZERO) == 0) {
+                                tWhgenlegMapper.deleteTWhgenlegById(whgenleg.getfId());
+                            }
                         } else { // 撤销数>结余数
                             throw new WarehouseException("第" + i + "行撤销数大于库存结余数");
                         }
@@ -7737,7 +7744,7 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
 
         Map<String, String> data = new HashMap<>();
         // 库龄
-        data.put("stockDays", String.valueOf(tWhgenlegMapper.stockDays(external).get("stockDays")));
+        data.put("stockDays", String.valueOf(tWhgenlegMapper.stockDays(external, null).get("stockDays")));
         // 7天
         data.put("stockTotalA", stockStatistics(DateUtils.offsetDate(-6), null, external));
         // 15天
@@ -7758,7 +7765,7 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
     private String inAndOutStockStatistics(String billType, String beginDate, String endDate, String external) {
         beginDate += " 00:00:00";
         endDate += " 23:59:59";
-        Map<String, Object> statistics = tWarehousebillsitemsMapper.inAndOutStockStatistics(billType, beginDate, endDate, external);
+        Map<String, Object> statistics = tWarehousebillsitemsMapper.inAndOutStockStatistics(billType, beginDate, endDate, external, null);
         return String.valueOf(statistics.get("total"));
     }
 
@@ -7769,7 +7776,7 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
         if (StringUtils.isNotEmpty(endDate)) {
             endDate += " 00:00:00";
         }
-        Map<String, Object> statistics = tWhgenlegMapper.stockStatistics(beginDate, endDate, external);
+        Map<String, Object> statistics = tWhgenlegMapper.stockStatistics(beginDate, endDate, external, null);
         return String.valueOf(statistics.get("quantity"));
     }
 

+ 4 - 4
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/impl/TWarehousebillsitemsServiceImpl.java

@@ -238,11 +238,11 @@ public class TWarehousebillsitemsServiceImpl implements ITWarehousebillsitemsSer
      * @return
      */
     @Override
-    public Map<String,Object> biTodayInAndOutStockCount(String billType){
+    public Map<String,Object> biTodayInAndOutStockCount(String billType, Long warehouseId){
         String beginDate = DateUtils.today() + " 00:00:00";
         String endDate = DateUtils.today() + " 23:59:59";
 
-        return tWarehousebillsitemsMapper.inAndOutStockStatistics(billType, beginDate, endDate, null);
+        return tWarehousebillsitemsMapper.inAndOutStockStatistics(billType, beginDate, endDate, null, warehouseId);
     }
 
     /**
@@ -252,8 +252,8 @@ public class TWarehousebillsitemsServiceImpl implements ITWarehousebillsitemsSer
      * @return
      */
     @Override
-    public List<Map<String,Object>> biInAndOutStockList(String billType) {
-        return tWarehousebillsitemsMapper.biInAndOutStockList(billType);
+    public List<Map<String,Object>> biInAndOutStockList(String billType, Long warehouseId) {
+        return tWarehousebillsitemsMapper.biInAndOutStockList(billType, warehouseId);
     }
 
 }

+ 5 - 2
ruoyi-warehouse/src/main/resources/mapper/basicData/TCorpsMapper.xml

@@ -458,10 +458,13 @@
             </foreach>
     </select>
 
-    <select id="biCustomerCount" resultType="map">
+    <select id="biCustomerCount" parameterType="long" resultType="map">
         select count(f_id) as customerCount
         from t_corps
-        where f_id in (select distinct f_corpid from t_whgenleg where f_qtyD != 0 and f_qtyblc != 0);
+        where f_id in (
+            select distinct f_corpid from t_whgenleg where f_qtyD != 0 and f_qtyblc != 0
+                <if test="warehouseId != null"> and f_warehouseid = #{warehouseId}</if>
+        );
     </select>
 
 </mapper>

+ 8 - 0
ruoyi-warehouse/src/main/resources/mapper/basicData/TWarehouseMapper.xml

@@ -319,4 +319,12 @@
             #{id}
         </foreach>
     </select>
+
+    <select id="biWarehouseList" resultType="map">
+        select
+            f_id as warehouseId,
+            f_name as warehouseName
+        from t_warehouse
+        where parent_id = 100
+    </select>
 </mapper>

+ 6 - 2
ruoyi-warehouse/src/main/resources/mapper/reportManagement/TWhgenlegMapper.xml

@@ -1180,6 +1180,7 @@
             <if test="external != null and external != ''">
                 and f_corpid = (select f_pid from t_customer_contact where f_tel = #{external})
             </if>
+            <if test="warehouseId != null"> and f_warehouseid = #{warehouseId}</if>
         </where>
     </select>
 
@@ -1192,6 +1193,7 @@
             <if test="external != null and external != ''">
                 and f_corpid = (select f_pid from t_customer_contact where f_tel = #{external})
             </if>
+            <if test="warehouseId != null"> and f_warehouseid = #{warehouseId}</if>
     </select>
 
     <select id="stockAfterMonthList" resultType="map">
@@ -1216,17 +1218,18 @@
 
     <select id="biCustomerInfo" resultType="map">
         select
-            tc.f_name as customerName,
+            tc.f_cname as customerName,
             round(sum(tw.f_grossweightblc) / 1000, 2) as quantity
         from t_whgenleg tw left join t_corps tc on tw.f_corpid = tc.f_id
         where
             tw.f_qtyD != 0
             and tw.f_qtyblc != 0
+            <if test="warehouseId != null"> and f_warehouseid = #{warehouseId}</if>
         group by tc.f_name
         order by quantity desc limit 10
     </select>
 
-    <select id="biGoodsInfo" resultType="map">
+    <select id="biGoodsInfo" parameterType="long" resultType="map">
         select
             tg.f_name as goodsName,
             round(sum(tw.f_grossweightblc) / 1000, 2) as quantity
@@ -1234,6 +1237,7 @@
         where
             tw.f_qtyD != 0
             and tw.f_qtyblc != 0
+            <if test="warehouseId != null"> and tw.f_warehouseid = #{warehouseId}</if>
         group by tg.f_name
         order by quantity desc limit 10
     </select>

+ 1 - 0
ruoyi-warehouse/src/main/resources/mapper/warehouseBusiness/TWarehousebillsMapper.xml

@@ -2846,6 +2846,7 @@
             </if>
             <if test="fBillno != null and fBillno != ''">and w.f_billno like concat('%', #{fBillno}, '%')</if>
             <if test="fMblno != null and fMblno != ''">and w.f_mblno like concat('%', #{fMblno}, '%')</if>
+            <if test="fCorpid != null and fCorpid != ''">and w.f_corpid = #{fCorpid}</if>
         </where>
             ${params.dataScope}
             ORDER BY w.f_bsdate DESC, w.f_bstime DESC,w.f_id DESC,w.f_billstatus

+ 2 - 0
ruoyi-warehouse/src/main/resources/mapper/warehouseBusiness/TWarehousebillsitemsMapper.xml

@@ -964,6 +964,7 @@
             <if test="external != null and external != ''">
                 and tb.f_corpid = (select f_pid from t_customer_contact where f_tel = #{external})
             </if>
+            <if test="warehouseId != null"> and tb.f_warehouseid = #{warehouseId}</if>
     </select>
 
     <select id="biInAndOutStockList" resultType="map">
@@ -980,6 +981,7 @@
         where
             ts.f_billstatus = '40'
             <if test="billType != null and billType != ''">and ts.f_billtype = #{billType}</if>
+            <if test="warehouseId != null"> and tb.f_warehouseid = #{warehouseId}</if>
         order by ts.f_bsdate desc
     </select>