Преглед на файлове

품목단가정보 api - sql작업

dwkim преди 2 години
родител
ревизия
225842d85e

+ 45 - 0
src/main/java/com/oqpo/api/entity/stinfo/ItemUnitEntity.java

@@ -0,0 +1,45 @@
1
+package com.oqpo.api.entity.stinfo;
2
+
3
+import com.oqpo.api.entity.oper.FileEntity;
4
+import lombok.Getter;
5
+import lombok.Setter;
6
+import lombok.ToString;
7
+
8
+import java.io.Serializable;
9
+import java.util.List;
10
+
11
+@Getter
12
+@Setter
13
+@ToString
14
+public class ItemUnitEntity implements Serializable {
15
+    private static final long serialVersionUID = -3590936033715917450L;
16
+
17
+    private String brandUnitUnqNo ;
18
+    private String brandId ;
19
+    private String itemId ;
20
+    private String itemNm ;
21
+    private String spplyId ;
22
+    private String spplyNm ;
23
+    private String contSttDt ;
24
+    private String contEndDt ;
25
+    private String curr ;
26
+    private String unit ;
27
+    private String unitNm ;
28
+    private Integer unitAmt ;
29
+    private Integer leadTime ;
30
+    private String dlvCndt ;
31
+    private String shortContFileNo ;
32
+    private String spplyItemId ;
33
+    private String unitStCd ;
34
+    private String unitStNm ;
35
+    private Integer stddQyt ;
36
+    private Integer storeSaleStddQty ;
37
+    private Integer storeSaleUnitAmt ;
38
+    private String sysRegDttm ;
39
+    private String sysRegId ;
40
+    private String sysChgDttm ;
41
+    private String sysChgId ;
42
+
43
+    private List<FileEntity> fileEntity ;
44
+
45
+}

+ 43 - 0
src/main/java/com/oqpo/api/entity/stinfo/StoreItemUnitEntity.java

@@ -0,0 +1,43 @@
1
+package com.oqpo.api.entity.stinfo;
2
+
3
+import com.oqpo.api.entity.oper.FileEntity;
4
+import lombok.Getter;
5
+import lombok.Setter;
6
+import lombok.ToString;
7
+
8
+import java.io.Serializable;
9
+import java.util.List;
10
+
11
+@Getter
12
+@Setter
13
+@ToString
14
+public class StoreItemUnitEntity implements Serializable {
15
+    private static final long serialVersionUID = -3590936033715917450L;
16
+
17
+    private String storeUnitUnqNo ;
18
+    private String itemId ;
19
+    private String itemNm ;
20
+    private String contSttDt ;
21
+    private String contEndDt ;
22
+    private String unit ;
23
+    private String unitNm ;
24
+    private String curr ;
25
+    private String currNm ;
26
+    private Integer unitAmt ;
27
+    private String storeId ;
28
+    private String brandId ;
29
+    private String shortContFileNo ;
30
+    private String spplyId ;
31
+    private String spplyNm ;
32
+    private String spplyItemId ;
33
+    private String unitStCd ;
34
+    private String unitStNm ;
35
+    private Integer stddQyt ;
36
+    private String brandUnitUnqNo ;
37
+    private String sysRegDttm ;
38
+    private String sysRegId ;
39
+    private String sysChgDttm ;
40
+    private String sysChgId ;
41
+
42
+    private List<FileEntity> fileEntity ;
43
+}

+ 21 - 0
src/main/java/com/oqpo/api/mapper/stinfo/ItemUnitMapper.java

@@ -0,0 +1,21 @@
1
+package com.oqpo.api.mapper.stinfo;
2
+
3
+import com.oqpo.api.entity.stinfo.ItemUnitEntity;
4
+import com.oqpo.api.web.dto.request.GridRequest;
5
+import org.apache.ibatis.annotations.Mapper;
6
+import org.apache.ibatis.annotations.Param;
7
+
8
+import java.util.List;
9
+
10
+@Mapper
11
+public interface ItemUnitMapper {
12
+
13
+    List<ItemUnitEntity> selectItemUnitGridList(@Param("sBrandId") String sBrandId, @Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("sUnitStCd") String sUnitStCd, @Param("sSpplyId") String sSpplyId, @Param("sClass1") String sClass1, @Param("sClass2") String sClass2, @Param("sClass3") String sClass3, @Param("sClass") String sClass4, @Param("sItemNm") String sItemNm , GridRequest gridRequest)throws Exception;
14
+    int selectItemUnitGridCnt(@Param("sBrandId") String sBrandId, @Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("sUnitStCd") String sUnitStCd, @Param("sSpplyId") String sSpplyId, @Param("sClass1") String sClass1, @Param("sClass2") String sClass2, @Param("sClass3") String sClass3, @Param("sClass") String sClass4, @Param("sItemNm") String sItemNm)throws Exception;
15
+
16
+    ItemUnitEntity selectItemUnitInfo(@Param("brandId") String brandId, @Param("brandUnitUnqNo") String brandUnitUnqNo)throws Exception;
17
+
18
+    int insertItemUnitInfo(@Param("userId") String userId, ItemUnitEntity entity) throws Exception;
19
+    int updateItemUnitInfo(@Param("userId") String userId, ItemUnitEntity entity) throws Exception;
20
+
21
+}

+ 19 - 0
src/main/java/com/oqpo/api/mapper/stinfo/StoreItemUnitMapper.java

@@ -0,0 +1,19 @@
1
+package com.oqpo.api.mapper.stinfo;
2
+
3
+
4
+import org.apache.ibatis.annotations.Mapper;
5
+
6
+@Mapper
7
+public interface StoreItemUnitMapper {
8
+/*
9
+    List<BrandEntity> selectBrandGridList(@Param("sBrandNm") String sBrandNm, @Param("sBrandType") String sBrandType, @Param("sStCd") String sStCd, GridRequest gridRequest)throws Exception;
10
+    int selectBrandGridCnt(@Param("sBrandNm") String sBrandNm, @Param("sBrandType") String sBrandType, @Param("sStCd") String sStCd)throws Exception;
11
+
12
+    BrandEntity selectBrandInfo(@Param("brandId") String brandId)throws Exception;
13
+
14
+    int insertBrandInfo(@Param("userId") String userId, BrandEntity entity) throws Exception;
15
+    int updateBrandInfo(@Param("userId") String userId, BrandEntity entity) throws Exception;
16
+
17
+    String selectBrandInitPw(@Param("brandId") String brandId)throws Exception;
18
+*/
19
+}

+ 146 - 0
src/main/resources/mybatis/sqlmaps/stinfo/ItemUnit.xml

@@ -0,0 +1,146 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+
4
+<mapper namespace="com.oqpo.api.mapper.stinfo.ItemUnitMapper">
5
+
6
+    <select id="selectItemUnitGridList" resultType="com.oqpo.api.entity.stinfo.ItemUnitEntity">
7
+        select  /*selectItemUnitGridList*/
8
+                iunit.brand_unit_unq_no, iunit.brand_id, iunit.item_id, iunit.item_nm, iunit.spply_id,
9
+                iunit.spply_nm, date_format(iunit.cont_stt_dt,'%Y.%m.%d') as cont_stt_dt, date_format(iunit.cont_end_dt,'%Y.%m.%d') as cont_end_dt,
10
+                iunit.curr, fn_code_nm('CURR', iunit.curr) as curr_nm, iunit.unit, fn_code_nm('DSTRBT_COST_UNIT', iunit.unit) as unit,
11
+                iunit.unit_amt, iunit.lead_time, iunit.spply_item_id,
12
+                iunit.unit_st_cd, fn_code_nm('UNIT_ST_CD', iunit.unit_st_cd) as unit_st_nm, iunit.stdd_qyt
13
+        from  brand_item_unit_info iunit
14
+        join  item_base_info item on iunit.brand_id = item.brand_id and iunit.item_id = item.item_id
15
+        left outer join item_class_ptcl iclas on item.item_id = iclas.item_id
16
+        join item_class_mgnt mclas on iclas.item_class_mgnt_no = mclas.item_class_mgnt_no
17
+        where iunit.brand_id = #{sBrandId}
18
+        <if test="fromDt != null and fromDt != '' and toDt != null and toDt != ''">
19
+        and   iunit.cont_stt_dt <![CDATA[ >= ]]>  #{fromDt}
20
+        and   iunit.cont_end_dt <![CDATA[ <= ]]>  #{toDt}
21
+        </if>
22
+        <if test="sUnitStCd != null and sUnitStCd != ''">
23
+        and   iunit.unit_st_cd = #{sUnitStCd}
24
+        </if>
25
+        <if test="sBrandNm != null and sSpplyId != ''">
26
+        and   iunit.spply_id = #{sSpplyId}
27
+        </if>
28
+        <if test="sClass1 != null and sClass1 != ''">
29
+            and  iclas.item_class1 = #{sClass1}
30
+        </if>
31
+        <if test="sClass2 != null and sClass2 != ''">
32
+            and  iclas.item_class2 = #{sClass2}
33
+        </if>
34
+        <if test="sClass3 != null and sClass3 != ''">
35
+            and  iclas.item_class3 = #{sClass3}
36
+        </if>
37
+        <if test="sClass4 != null and sClass4 != ''">
38
+            and  iclas.item_class4 = #{sClass4}
39
+        </if>
40
+        <if test="sClass4 != null and sClass4 != ''">
41
+        and   iunit.item_id like concat('%',#{sItemNm},'%') or iunit.item_nm like concat('%',#{sItemNm},'%')
42
+        </if>
43
+        <choose>
44
+            <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
45
+                <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
46
+                    <if test="gridRequest.sord == 'asc'.toString()">
47
+                        order by iunit.item_nm asc
48
+                    </if>
49
+                    <if test="gridRequest.sord == 'desc'.toString()">
50
+                        order by iunit.item_nm desc
51
+                    </if>
52
+                </if>
53
+            </when>
54
+            <otherwise>
55
+                order by iunit.item_nm asc
56
+            </otherwise>
57
+        </choose>
58
+        <if test="gridRequest.pagingYn == true">
59
+            limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
60
+        </if>
61
+    </select>
62
+
63
+    <select id="selectItemUnitGridCnt" resultType="int">
64
+        select /*selectBrandGridCnt*/
65
+                count(*)
66
+        from  brand_item_unit_info iunit
67
+        join  item_base_info item on iunit.brand_id = item.brand_id and iunit.item_id = item.item_id
68
+        left outer join item_class_ptcl iclas on item.item_id = iclas.item_id
69
+        join item_class_mgnt mclas on iclas.item_class_mgnt_no = mclas.item_class_mgnt_no
70
+        where iunit.brand_id = #{sBrandId}
71
+        <if test="fromDt != null and fromDt != '' and toDt != null and toDt != ''">
72
+            and   iunit.cont_stt_dt <![CDATA[ >= ]]>  #{fromDt}
73
+            and   iunit.cont_end_dt <![CDATA[ <= ]]>  #{toDt}
74
+        </if>
75
+        <if test="sUnitStCd != null and sUnitStCd != ''">
76
+            and   iunit.unit_st_cd = #{sUnitStCd}
77
+        </if>
78
+        <if test="sBrandNm != null and sSpplyId != ''">
79
+            and   iunit.spply_id = #{sSpplyId}
80
+        </if>
81
+        <if test="sClass1 != null and sClass1 != ''">
82
+            and  iclas.item_class1 = #{sClass1}
83
+        </if>
84
+        <if test="sClass2 != null and sClass2 != ''">
85
+            and  iclas.item_class2 = #{sClass2}
86
+        </if>
87
+        <if test="sClass3 != null and sClass3 != ''">
88
+            and  iclas.item_class3 = #{sClass3}
89
+        </if>
90
+        <if test="sClass4 != null and sClass4 != ''">
91
+            and  iclas.item_class4 = #{sClass4}
92
+        </if>
93
+        <if test="sClass4 != null and sClass4 != ''">
94
+            and   iunit.item_id like concat('%',#{sItemNm},'%') or iunit.item_nm like concat('%',#{sItemNm},'%')
95
+        </if>
96
+    </select>
97
+
98
+    <select id="selectItemUnitInfo" resultType="com.oqpo.api.entity.stinfo.ItemUnitEntity">
99
+        select  /*selectItemUnitInfo*/
100
+                iunit.brand_unit_unq_no, iunit.brand_id, fn_brand_nm(iunit.brand_id) as  brand_nm,  iunit.item_id, iunit.item_nm, iunit.spply_id,
101
+                iunit.spply_nm, date_format(iunit.cont_stt_dt,'%Y.%m.%d') as cont_stt_dt, date_format(iunit.cont_end_dt,'%Y.%m.%d') as cont_end_dt,
102
+                iunit.curr, fn_code_nm('CURR', iunit.curr) as curr_nm, iunit.unit, fn_code_nm('DSTRBT_COST_UNIT', iunit.unit) as unit,
103
+                iunit.unit_amt, iunit.lead_time, iunit.spply_item_id,
104
+                iunit.unit_st_cd, fn_code_nm('UNIT_ST_CD', iunit.unit_st_cd) as unit_st_nm, iunit.stdd_qyt,
105
+                iunit.store_sale_stdd_qty, iunit.store_sale_unit_amt, iunit.short_cont_file_no
106
+        from  brand_item_unit_info iunit
107
+        where iunit.brand_id = #{brandId}
108
+        and   iunit.brand_unit_unq_no = #{brandUnitUnqNo}
109
+    </select>
110
+
111
+    <insert id="insertItemUnitInfo" >
112
+        insert into brand_item_unit_info
113
+            (brand_unit_unq_no, brand_id, item_id, item_nm, spply_id,
114
+             spply_nm, cont_stt_dt, cont_end_dt, curr, unit,
115
+             unit_amt, lead_time, dlv_cndt, short_cont_file_no, spply_item_id,
116
+             unit_st_cd, stdd_qyt, store_sale_stdd_qty, store_sale_unit_amt,
117
+             sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
118
+        values
119
+            (#{entity.brandUnitUnqNo}, #{entity.brandId}, #{entity.itemId}, #{entity.itemNm}, #{entity.spplyId},
120
+            #{entity.spplyNm}, #{entity.contSttDt}, #{entity.contEndDt}, #{entity.curr}, #{entity.unit},
121
+            #{entity.unitAmt}, #{entity.leadTime}, #{entity.dlvCndt}, #{entity.shortContFileNo}, #{entity.spplyItemId},
122
+            #{entity.unitStCd}, #{entity.stddQyt}, #{entity.storeSaleStddQty}, #{entity.storeSaleUnitAmt},
123
+            now(), #{userId}, now(), #{userId})
124
+    </insert>
125
+
126
+    <update id="updateItemUnitInfo">
127
+        update brand_item_unit_info
128
+        set     cont_stt_dt = #{entity.contSttDt},
129
+                cont_end_dt = #{entity.contEndDt},
130
+                curr = #{entity.curr},
131
+                unit = #{entity.unit},
132
+                unit_amt = #{entity.unitAmt},
133
+                lead_time = #{entity.leadTime},
134
+                dlv_cndt = #{entity.dlvCndt},
135
+                short_cont_file_no = #{entity.shortContFileNo},
136
+                unit_st_cd = #{entity.unitStCd},
137
+                stdd_qyt = #{entity.stddQyt},
138
+                store_sale_stdd_qty = #{entity.storeSaleStddQty},
139
+                store_sale_unit_amt = #{entity.storeSaleUnitAmt},
140
+                sys_chg_dttm = now(),
141
+                sys_chg_id = #{userId}
142
+        where   brand_id = #{entity.brandId}
143
+        and     brand_unit_unq_no = #{entity.brandUnitUnqNo}
144
+    </update>
145
+
146
+</mapper>