Sfoglia il codice sorgente

Merge branch 'master' of http://git.dongkesoft.com:9001/iBOSS-2.0-Mini/iboss-server-mdm

于继渤 2 anni fa
parent
commit
4d467e477a

+ 13 - 5
src/main/java/com/dk/mdm/controller/report/ReportController.java

@@ -20,18 +20,26 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
 /**
 /**
- * @author : 周兴
- * @desc : 控件数据源API
- * @date : 2023/1/3 17:21
+ * @desc   : 报表数据源
+ * @author : 常皓宁
+ * @date   : 2024/4/11 8:49
  */
  */
-@Api(tags = "控件数据源API")
+@Api(tags = "报表数据源API")
 @RestController
 @RestController
-@RequestMapping("/mst/common")
+@RequestMapping("/mst/report")
 public class ReportController  {
 public class ReportController  {
 
 
     @Autowired
     @Autowired
     private ReportService reportService;
     private ReportService reportService;
 
 
+    @ApiOperation(
+            value = "获取库存",
+            notes = "获取库存"
+    )
+    @PostMapping("get_ivt_detail_report")
+    public ResponseResultVO<List<Map<String, Object>>> getIvtDetailReport(@RequestBody Map<String, Object> param) {
+        return reportService.getIvtDetailReport(param);
+    }
 
 
 }
 }
 
 

+ 55 - 27
src/main/java/com/dk/mdm/mapper/common/CommonMapper.xml

@@ -352,19 +352,29 @@
 
 
     <!-- 获取仓库 -->
     <!-- 获取仓库 -->
     <select id="getWarehouse" resultType="java.util.Map">
     <select id="getWarehouse" resultType="java.util.Map">
-        SELECT tmw.wh_id as "whId"
-        ,tmw.wh_id AS "id"
-        ,tmw.wh_name as "whName"
-        ,tmw.wh_code as "whCode"
-        ,tmw.flg_default as "flgDefault"
-        FROM dkic_b.t_mst_warehouse tmw
-        WHERE tmw.cp_id = #{cpId}
-        and tmw.flg_valid
+        SELECT t.wh_id       as "whId"
+             , t.wh_id       AS "id"
+             , t.wh_name     as "whName"
+             , t.wh_code     as "whCode"
+             , t.flg_default as "flgDefault"
+        FROM dkic_b.t_mst_warehouse t
+        WHERE t.cp_id = #{cpId}
+          and t.flg_valid
         <if test="whCode!=null and whCode!=''">
         <if test="whCode!=null and whCode!=''">
-            and position(#{whCode} in tmw.wh_code) > 0
+            and position(#{whCode} in t.wh_code) > 0
         </if>
         </if>
         <if test="whName!=null and whName!=''">
         <if test="whName!=null and whName!=''">
-            and position(#{whName} in tmw.wh_name) > 0
+            and position(#{whName} in t.wh_name) > 0
+        </if>
+        <!-- 部门上有仓库,只能选部门上的仓库;部门上没有仓库,可选所有仓库 -->
+        <if test="orgId != null">
+                and (select count(1)
+                     from dkic_b.t_mst_org_wh as tmow
+                     where tmow.org_id = #{orgId}::uuid) = 0
+               or (exists(select 1
+                          from dkic_b.t_mst_org_wh as tmow
+                          where tmow.org_id = #{orgId}::uuid
+                            and tmow.wh_id = t.wh_id))
         </if>
         </if>
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
             limit #{end} offset #{start}
             limit #{end} offset #{start}
@@ -837,21 +847,30 @@
 
 
     <!--获取仓库档案-->
     <!--获取仓库档案-->
     <select id="getWarehouseByPage" resultType="java.util.Map">
     <select id="getWarehouseByPage" resultType="java.util.Map">
-        SELECT
-        wh_id AS "whId",
-        wh_code AS "whCode",
-        wh_name AS "whName",
-        supervisor AS "supervisor",
-        contact_phone AS "contactPhone",
-        flg_valid AS "flgValid"
-        FROM  dkic_b.t_mst_warehouse
+        SELECT t.wh_id         AS "whId",
+               t.wh_code       AS "whCode",
+               t.wh_name       AS "whName",
+               t.supervisor    AS "supervisor",
+               t.contact_phone AS "contactPhone",
+               t.flg_valid     AS "flgValid"
+        FROM dkic_b.t_mst_warehouse as t
         <where>
         <where>
             <if test="searchText !=null">
             <if test="searchText !=null">
-                AND ( wh_name LIKE concat('%', my_ex.likequery(#{searchText}), '%')
-                or  remarks LIKE concat('%', my_ex.likequery(#{searchText}), '%'))
+                AND ( t.wh_name LIKE concat('%', my_ex.likequery(#{searchText}), '%')
+                or  t.remarks LIKE concat('%', my_ex.likequery(#{searchText}), '%'))
             </if>
             </if>
             <if test="cpId != null">
             <if test="cpId != null">
-                AND cp_id = #{cpId}
+                AND t.cp_id = #{cpId}
+            </if>
+            <!-- 部门上有仓库,只能选部门上的仓库;部门上没有仓库,可选所有仓库 -->
+            <if test="orgId != null">
+                and (select count(1)
+                     from dkic_b.t_mst_org_wh as tmow
+                     where tmow.org_id = #{orgId}::uuid) = 0
+               or (exists(select 1
+                          from dkic_b.t_mst_org_wh as tmow
+                          where tmow.org_id = #{orgId}::uuid
+                            and tmow.wh_id = t.wh_id))
             </if>
             </if>
         </where>
         </where>
         order by display_no asc
         order by display_no asc
@@ -862,16 +881,25 @@
 
 
     <!--获取仓库档案个数-->
     <!--获取仓库档案个数-->
     <select id="countWarehouseByPage" resultType="Long">
     <select id="countWarehouseByPage" resultType="Long">
-        SELECT
-        count(1)
-        FROM  dkic_b.t_mst_warehouse
+        SELECT count(1)
+        FROM  dkic_b.t_mst_warehouse as t
         <where>
         <where>
             <if test="searchText !=null">
             <if test="searchText !=null">
-                AND ( wh_name LIKE concat('%', my_ex.likequery(#{searchText}), '%')
-                or  remarks LIKE concat('%', my_ex.likequery(#{searchText}), '%'))
+                AND ( t.wh_name LIKE concat('%', my_ex.likequery(#{searchText}), '%')
+                or  t.remarks LIKE concat('%', my_ex.likequery(#{searchText}), '%'))
             </if>
             </if>
             <if test="cpId != null">
             <if test="cpId != null">
-                AND cp_id = #{cpId}
+                AND t.cp_id = #{cpId}
+            </if>
+            <!-- 部门上有仓库,只能选部门上的仓库;部门上没有仓库,可选所有仓库 -->
+            <if test="orgId != null">
+                and (select count(1)
+                     from dkic_b.t_mst_org_wh as tmow
+                     where tmow.org_id = #{orgId}::uuid) = 0
+               or (exists(select 1
+                          from dkic_b.t_mst_org_wh as tmow
+                          where tmow.org_id = #{orgId}::uuid
+                            and tmow.wh_id = t.wh_id))
             </if>
             </if>
         </where>
         </where>
     </select>
     </select>

+ 10 - 3
src/main/java/com/dk/mdm/mapper/report/ReportMapper.java

@@ -9,11 +9,18 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
 /**
 /**
- * @author : 周兴
- * @desc : 报表Mapper
- * @date : 2023/1/3 17:21
+ * @desc   : 报表数据源
+ * @author : 常皓宁
+ * @date   : 2024/4/11 8:49
  */
  */
 @Repository
 @Repository
 public interface ReportMapper extends BaseMapper<JSONObject> {
 public interface ReportMapper extends BaseMapper<JSONObject> {
 
 
+    /**
+     * @desc   : 查询库存
+     * @author : 常皓宁
+     * @date   : 2024/4/11 8:52
+     */
+    List<Map<String, Object>> getIvtDetailReport(Map param);
+
 }
 }

+ 60 - 0
src/main/java/com/dk/mdm/mapper/report/ReportMapper.xml

@@ -2,5 +2,65 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.dk.mdm.mapper.report.ReportMapper">
 <mapper namespace="com.dk.mdm.mapper.report.ReportMapper">
 
 
+    <!--库存查询-->
+    <select id="getIvtDetailReport" resultType="java.util.Map">
+        select tpi.inv_id             as "invId",
+        tpi.sku_id             as "skuId",
+        tmgs.sku_code          as "skuCode",
+        tmgs.sku_name          as "skuName",
+        tmgs.sku_model         as "skuModel",
+        tmgs.brand_id          as "brandId",
+        tmgb.brand_name        as "brandName",
+        tmgs.category_id       as "categoryId",
+        tmgc.cat_name          as "categoryName",
+        tmgs.unit_id           as "unitId",
+        tmgu.unit_name         as "unitName",
+        tmgs.sub_unit_id       as "subUnitId",
+        tmgs.conversion_factor as "conversionFactor",
+        tmgs.series_id         as "seriesId",
+        tmgseries.series_name  as "seriesName",
+        tmgs.sku_spec          as "skuSpec",
+        tmgs.price_purchase    as "pricePurchase",
+        tmgs.price_standard    as "priceStandard",
+        tmgs.price_wholesale   as "priceWholesale",
+        tmgs.price_limited     as "priceLimited",
+        tmgs.sku_images        as "skuImages",
+        tpi.non_std_code       as "nonStdCode",
+        tpi.inv_qty            as "invQty",
+        tpi.outing_qty         as "outingQty",
+        tpi.usable_qty         as "usableQty",
+        tpi.wh_id              as "whId",
+        tmw.wh_code            as "whCode",
+        tmw.wh_name            as "whName",
+        dkic_b.f_get_last_ivt_price(tpi.inv_id,null,null,null) as "priceInto",
+        tpi.remarks
+        from dkic_b.t_psi_inventory as tpi
+        inner join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = tpi.wh_id
+        inner join dkic_b.t_mst_goods_sku as tmgs on tmgs.sku_id = tpi.sku_id
+        left join dkic_b.t_mst_goods_brand as tmgb on tmgs.brand_id = tmgb.brand_id
+        left join dkic_b.t_mst_goods_category as tmgc on tmgs.category_id = tmgc.cat_id
+        left join dkic_b.t_mst_goods_series as tmgseries on tmgs.series_id = tmgseries.series_id
+        left join dkic_b.t_mst_unit as tmgu on tmgs.unit_id = tmgu.unit_id
+        where tpi.flg_valid
+        AND tpi.cp_id = #{cpId}
+        <if test="skuId != null">
+            AND tpi.sku_id = #{skuId} ::uuid
+        </if>
+        <if test="nonStdCode != null">
+            AND tpi.non_std_code = #{nonStdCode}
+        </if>
+        <if test="skuCode != null">
+            AND tmgs.sku_code LIKE concat('%',my_ex.likequery(#{skuCode}),'%')
+        </if>
+        <if test="skuName != null">
+            AND tmgs.sku_name LIKE concat('%',my_ex.likequery(#{skuName}),'%')
+        </if>
+        <if test="whName != null">
+            AND tmgs.wh_name LIKE concat('%',my_ex.likequery(#{whName}),'%')
+        </if>
+        <if test="whId != null">
+            AND tpi.wh_id = #{whId} ::uuid
+        </if>
+    </select>
 
 
 </mapper>
 </mapper>

+ 13 - 3
src/main/java/com/dk/mdm/service/report/ReportService.java

@@ -23,9 +23,9 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
 /**
 /**
- * @author : 周兴
- * @desc : 控件数据源API
- * @date : 2023/1/3 17:21
+ * @desc   : 报表数据源
+ * @author : 常皓宁
+ * @date   : 2024/4/11 8:49
  */
  */
 @Service
 @Service
 @Slf4j
 @Slf4j
@@ -34,5 +34,15 @@ public class ReportService {
     @Autowired
     @Autowired
     private ReportMapper reportMapper;
     private ReportMapper reportMapper;
 
 
+    /**
+     * @desc   : 查询库存
+     * @author : 常皓宁
+     * @date   : 2024/4/11 8:52
+     */
+    public ResponseResultVO<List<Map<String, Object>>> getIvtDetailReport(Map<String, Object> param) {
+        // 获取系统基础数据
+        List<Map<String, Object>> list = reportMapper.getIvtDetailReport(param);
+        return ResponseResultUtil.success(list);
+    }
 
 
 }
 }