浏览代码

生产年度sql修改

hanqingsong 4 年之前
父节点
当前提交
7b57408c04

+ 57 - 33
src/main/java/com/chinaitop/depot/intelligent/basicdata/mapper/WareHouseBasicInfoMapper.xml

@@ -2,39 +2,63 @@
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
3 3
 <mapper namespace="com.chinaitop.depot.intelligent.basicdata.mapper.WareHouseBasicInfoMapper" >
4 4
     <select id="getStorehouseInfo" parameterType="java.util.Map" resultType="java.util.Map">
5
-      SELECT
6
-        t2.storehouse_type,
7
-        t2.storehouse_code,
8
-        t2.storehouse_name,
9
-        t2.design_capacity,
10
-        t2.house_doot_position,
11
-        t2.storehouse_state,
12
-        t2.dutyStoreman,
13
-        t1.lkmc,
14
-        t1.pz,
15
-        t1.hwxz,
16
-        t1.dj,
17
-        t1.kcsl,
18
-        DATE_FORMAT(t1.rq,'%Y') AS rq,
19
-        DATE_FORMAT(t1.rq,'%Y-%m-%d') AS rcrq,
20
-        DATE_FORMAT(t1.cjsj,'%Y-%m-%d') AS cjsj,
21
-        t1.UnitID
22
-      FROM
23
-        `lsreport_ts`.data_kcgl_kcsw_default AS t1
24
-      LEFT JOIN `depot`.`basic_storehouse` t2 ON t1.UnitID = t2.org_id AND t1.ch = t2.storehouse_id AND del_flag = 1
25
-      <where>
26
-          <if test="org_id != null">
27
-              t2.org_id = #{org_id}
28
-          </if>
29
-          <if test="library_type != null">
30
-              AND t2.library_type = #{library_type}
31
-          </if>
32
-          <if test="cfCdoe != null">
33
-              AND t2.storehouse_code = #{cfCdoe}
34
-          </if>
35
-      </where>
36
-      GROUP BY
37
-        t2.storehouse_code
5
+        SELECT
6
+          t.*
7
+        FROM
8
+        (
9
+            SELECT
10
+                t2.storehouse_type,
11
+                t2.storehouse_code,
12
+                t2.storehouse_name,
13
+                t2.design_capacity,
14
+                t2.house_doot_position,
15
+                t2.storehouse_state,
16
+                t2.dutyStoreman,
17
+                t1.lkmc,
18
+                t1.pz,
19
+                t1.hwxz,
20
+                t1.dj,
21
+                t1.kcsl,
22
+                t5.EnumItemName rq,
23
+                t1.rq AS rcrq,
24
+                t1.cjsj AS cjsj,
25
+                t1.UnitID
26
+            FROM
27
+            `lsreport_ts`.data_kcgl_kcsw_default AS t1
28
+            LEFT JOIN basic_storehouse t2 ON t1.UnitID = t2.org_id
29
+            AND t1.ch = t2.storehouse_id
30
+            LEFT JOIN (
31
+                SELECT
32
+                    t4.EnumItemId,
33
+                    t4.EnumItemName,
34
+                    MAX(t4.EnumItemName) scnf,
35
+                    t3.UnitID,
36
+                    t3.ch,
37
+                    t3.scnf scnfEnumId
38
+                FROM
39
+                `lsreport_ts`.data_kcgl_fcbgz_default t3
40
+                INNER JOIN `lsreport_ts`.enumitem t4 ON t3.scnf = t4.EnumItemId
41
+                AND t3.srsl > 0
42
+                AND t3.UnitID = #{org_id}
43
+                GROUP BY
44
+                t3.ch
45
+            ) t5 ON t2.org_id = t5.UnitID
46
+        AND t2.storehouse_id = t5.ch
47
+        <where>
48
+            t2.del_flag = 1
49
+            <if test="org_id != null">
50
+                AND t2.org_id = #{org_id}
51
+            </if>
52
+            <if test="library_type != null">
53
+                AND t2.library_type = #{library_type}
54
+            </if>
55
+            <if test="cfCdoe != null">
56
+                AND t2.storehouse_code = #{cfCdoe}
57
+            </if>
58
+        </where>
59
+        ) t
60
+        GROUP BY
61
+        t.storehouse_code
38 62
     </select>
39 63
 
40 64
     <select id="getColumn1Max" parameterType="java.util.Map" resultType="java.util.Map">