Browse Source

재고실사 정보

hoseongs 2 years ago
parent
commit
49c1a974b5

+ 21 - 1
src/main/java/com/oqpo/api/entity/stockmng/StckCddMgntDtlEntity.java

@@ -14,11 +14,30 @@ public class StckCddMgntDtlEntity implements Serializable {
14 14
 
15 15
     @ApiModelProperty(value = "실사아이디")
16 16
     private String cddId;
17
+    @ApiModelProperty(value = "브랜드아이디")
18
+    private String brandId;
19
+    @ApiModelProperty(value = "브랜드명")
20
+    private String brandNm;
21
+    @ApiModelProperty(value = "매장아이디")
22
+    private String storeId;
23
+    @ApiModelProperty(value = "매장명")
24
+    private String storeNm;
25
+    @ApiModelProperty(value = "창고아이디")
26
+    private String whsId;
27
+    @ApiModelProperty(value = "창고명")
28
+    private String whsNm;
29
+    @ApiModelProperty(value = "LOCATION")
30
+    private String location;
31
+    @ApiModelProperty(value = "LOCATION명")
32
+    private String locationNm;
33
+
17 34
     @ApiModelProperty(value = "실사순번")
18 35
     private int cddSeq;
19 36
     @ApiModelProperty(value = "품목아이디")
20 37
     private String itemId;
21
-    @ApiModelProperty(value = "단위")
38
+    @ApiModelProperty(value = "품목명")
39
+    private String itemNm;
40
+    @ApiModelProperty(value = "단위(코드: DSTRBT_COST_UNIT)")
22 41
     private String unit;
23 42
     @ApiModelProperty(value = "전산기존수량")
24 43
     private int comExstQty;
@@ -26,6 +45,7 @@ public class StckCddMgntDtlEntity implements Serializable {
26 45
     private int cddQty;
27 46
     @ApiModelProperty(value = "변동수량")
28 47
     private int chgQty;
48
+
29 49
     @ApiModelProperty(value = "시스템등록일시")
30 50
     private String sysRegDttm;
31 51
     @ApiModelProperty(value = "시스템등록아이디")

+ 7 - 0
src/main/java/com/oqpo/api/mapper/stockmng/StockCddMapper.java

@@ -24,4 +24,11 @@ public interface StockCddMapper {
24 24
     int insertStckCddMgntInfo(@Param("userId") String userId, StckCddMgntInfoEntity entity) throws Exception;
25 25
 
26 26
     int insertStckCddMgntDtl(@Param("userId") String userId, StckCddMgntDtlEntity entity) throws Exception;
27
+
28
+    StckCddMgntInfoEntity selectStockCddMgntInfo(@Param("cddId") String cddId) throws Exception;
29
+
30
+    List<StckCddMgntDtlEntity> selectStockCddDtlGridList(@Param("cddId") String cddId, GridRequest gridRequest) throws Exception;
31
+
32
+    int selectStockCddDtlGridCnt(@Param("cddId") String cddId) throws Exception;
33
+
27 34
 }

+ 47 - 0
src/main/java/com/oqpo/api/service/stockmng/StockCddService.java

@@ -1,6 +1,8 @@
1 1
 package com.oqpo.api.service.stockmng;
2 2
 
3 3
 
4
+import com.oqpo.api.entity.oper.FileEntity;
5
+import com.oqpo.api.entity.stinfo.BrandEntity;
4 6
 import com.oqpo.api.entity.stockmng.StckCddMgntDtlEntity;
5 7
 import com.oqpo.api.entity.stockmng.StckCddMgntInfoEntity;
6 8
 import com.oqpo.api.entity.stockmng.StckMgntBaseInfoEntity;
@@ -17,6 +19,9 @@ import com.oqpo.api.util.StringUtil;
17 19
 import com.oqpo.api.web.dto.request.GridRequest;
18 20
 import com.oqpo.api.web.dto.request.stockmng.SaveStockCddRequest;
19 21
 import com.oqpo.api.web.dto.response.GridResponse;
22
+import com.oqpo.api.web.dto.response.stinfo.brand.BrandInfoResponse;
23
+import com.oqpo.api.web.dto.response.stockmng.StockCddDtlListResponse;
24
+import com.oqpo.api.web.dto.response.stockmng.StockCddInfoResponse;
20 25
 import com.oqpo.api.web.dto.response.stockmng.StockCddListResponse;
21 26
 import lombok.extern.slf4j.Slf4j;
22 27
 import org.apache.ibatis.annotations.Param;
@@ -25,6 +30,7 @@ import org.springframework.stereotype.Service;
25 30
 import org.springframework.transaction.annotation.Transactional;
26 31
 
27 32
 import java.math.BigDecimal;
33
+import java.util.ArrayList;
28 34
 import java.util.List;
29 35
 import java.util.stream.Collectors;
30 36
 
@@ -143,4 +149,45 @@ public class StockCddService extends CommonService {
143 149
             throw new RuntimeException();
144 150
         }
145 151
     }
152
+
153
+    /* 재고실사 정보 */
154
+    public StockCddInfoResponse selectStockCddInfo(String cddId) throws Exception {
155
+        StckCddMgntInfoEntity entity = stockCddMapper.selectStockCddMgntInfo(cddId);
156
+        return StockCddInfoResponse.toDTO(entity);
157
+    }
158
+
159
+    /*
160
+      재고실사 품목정보 그리드 리스트 조회
161
+     */
162
+    public GridResponse selectStockCddDtlGridList(String cddId, GridRequest gridRequest) throws Exception {
163
+
164
+        int gridPage = gridRequest.getGridPage();
165
+        int gridSize = gridRequest.getGridSize();
166
+
167
+        int gridRecords = stockCddMapper.selectStockCddDtlGridCnt(cddId);
168
+        int gridTotal = fnCalculateGridTotal(gridSize, gridRecords);
169
+        List<StckCddMgntDtlEntity> entities = stockCddMapper.selectStockCddDtlGridList(cddId, gridRequest);
170
+        List<Object> gridRows = entities.stream()
171
+                .map(m -> StockCddDtlListResponse.builder()
172
+                        .viewCd("R")
173
+                        .cddId(m.getCddId())
174
+                        .brandId(m.getBrandId())
175
+                        .brandNm(m.getBrandNm())
176
+                        .storeId(m.getStoreId())
177
+                        .storeNm(m.getStoreNm())
178
+                        .whsId(m.getWhsId())
179
+                        .whsNm(m.getWhsNm())
180
+                        .location(m.getLocation())
181
+                        .locationNm(m.getLocationNm())
182
+                        .cddSeq(m.getCddSeq())
183
+                        .itemId(m.getItemId())
184
+                        .itemNm(m.getItemNm())
185
+                        .unit(m.getUnit())
186
+                        .comExstQty(m.getComExstQty())
187
+                        .cddQty(m.getCddQty())
188
+                        .chgQty(m.getChgQty())
189
+                        .build())
190
+                .collect(Collectors.toList());
191
+        return GridResponse.toDTO(gridPage, gridTotal, gridRecords, gridRows);
192
+    }
146 193
 }

+ 36 - 4
src/main/java/com/oqpo/api/web/controller/stockmng/StockCddController.java

@@ -5,16 +5,14 @@ import com.oqpo.api.service.stockmng.StockCddService;
5 5
 import com.oqpo.api.web.dto.request.stockmng.*;
6 6
 import com.oqpo.api.web.dto.response.GridResponse;
7 7
 import com.oqpo.api.web.dto.response.SaveResponse;
8
+import com.oqpo.api.web.dto.response.stockmng.StockCddInfoResponse;
8 9
 import io.swagger.annotations.ApiImplicitParam;
9 10
 import io.swagger.annotations.ApiImplicitParams;
10 11
 import io.swagger.annotations.ApiOperation;
11 12
 import lombok.extern.slf4j.Slf4j;
12 13
 import org.springframework.beans.factory.annotation.Autowired;
13 14
 import org.springframework.http.ResponseEntity;
14
-import org.springframework.web.bind.annotation.PostMapping;
15
-import org.springframework.web.bind.annotation.RequestBody;
16
-import org.springframework.web.bind.annotation.RequestMapping;
17
-import org.springframework.web.bind.annotation.RestController;
15
+import org.springframework.web.bind.annotation.*;
18 16
 import springfox.documentation.annotations.ApiIgnore;
19 17
 
20 18
 import javax.validation.Valid;
@@ -63,4 +61,38 @@ public class StockCddController {
63 61
         return ResponseEntity.ok(SaveResponse.toDTO(SystemMessageCode.SAVE_OK));
64 62
     }
65 63
 
64
+    /**
65
+     * 설명 : 재고실사 기본 정보
66
+     *
67
+     * @param cddId
68
+     * @return
69
+     * @throws Exception
70
+     */
71
+    @ApiImplicitParams({
72
+            @ApiImplicitParam(name = "X-AUTH-TOKEN", value = "CONN-KEY", required = true, dataType = "String", paramType = "header"),
73
+            @ApiImplicitParam(name = "cddId", value = "실사아이디", required = true, dataType = "String", paramType = "query")
74
+    })
75
+    @ApiOperation(value = "재고실사 기본 정보")
76
+    @GetMapping("/info-cdd")
77
+    public ResponseEntity<StockCddInfoResponse> infoCdd(@RequestParam(value = "cddId") String cddId) throws Exception {
78
+        return ResponseEntity.ok(stockCddService.selectStockCddInfo(cddId));
79
+    }
80
+
81
+    /**
82
+     * 설명 : 재고실사 품목정보 그리드 리스트
83
+     *
84
+     * @param stockCddDtlGridRequest
85
+     * @return
86
+     * @throws Exception
87
+     */
88
+    @ApiImplicitParams({
89
+            @ApiImplicitParam(name = "X-AUTH-TOKEN", value = "CONN-KEY", required = true, dataType = "String", paramType = "header")
90
+    })
91
+    @ApiOperation(value = "재고실사 품목정보 그리드 리스트")
92
+    @PostMapping("/cdd-detail-grid-list")
93
+    public ResponseEntity<GridResponse> cddDetailGridList(@RequestBody @Valid StockCddDtlGridRequest stockCddDtlGridRequest) throws Exception {
94
+        return ResponseEntity.ok(stockCddService.selectStockCddDtlGridList(stockCddDtlGridRequest.getCddId(),
95
+                stockCddDtlGridRequest.toDTO(stockCddDtlGridRequest)));
96
+    }
97
+
66 98
 }

+ 19 - 0
src/main/java/com/oqpo/api/web/dto/request/stockmng/StockCddDtlGridRequest.java

@@ -0,0 +1,19 @@
1
+package com.oqpo.api.web.dto.request.stockmng;
2
+
3
+import com.oqpo.api.web.dto.request.GridRequest;
4
+import io.swagger.annotations.ApiModelProperty;
5
+import lombok.Getter;
6
+import lombok.Setter;
7
+
8
+
9
+@Getter
10
+@Setter
11
+public class StockCddDtlGridRequest extends GridRequest {
12
+
13
+    @ApiModelProperty(value = "실사아이디")
14
+    private String cddId;
15
+
16
+    protected StockCddDtlGridRequest(Integer gridSize, Integer gridPage, String sidx, String sord, Boolean pagingYn, Integer gridFirst) {
17
+        super(gridSize, gridPage, sidx, sord, pagingYn, gridFirst);
18
+    }
19
+}

+ 51 - 0
src/main/java/com/oqpo/api/web/dto/response/stockmng/StockCddDtlListResponse.java

@@ -0,0 +1,51 @@
1
+package com.oqpo.api.web.dto.response.stockmng;
2
+
3
+import com.fasterxml.jackson.annotation.JsonInclude;
4
+import io.swagger.annotations.ApiModelProperty;
5
+import lombok.*;
6
+
7
+@Getter
8
+@Setter
9
+@Builder
10
+@AllArgsConstructor(access = AccessLevel.PROTECTED)
11
+@JsonInclude(JsonInclude.Include.ALWAYS)
12
+public class StockCddDtlListResponse {
13
+
14
+    @ApiModelProperty(value = "CRUD")
15
+    private String viewCd;
16
+
17
+    @ApiModelProperty(value = "실사아이디")
18
+    private String cddId;
19
+    @ApiModelProperty(value = "브랜드아이디")
20
+    private String brandId;
21
+    @ApiModelProperty(value = "브랜드명")
22
+    private String brandNm;
23
+    @ApiModelProperty(value = "매장아이디")
24
+    private String storeId;
25
+    @ApiModelProperty(value = "매장명")
26
+    private String storeNm;
27
+    @ApiModelProperty(value = "창고아이디")
28
+    private String whsId;
29
+    @ApiModelProperty(value = "창고명")
30
+    private String whsNm;
31
+    @ApiModelProperty(value = "LOCATION")
32
+    private String location;
33
+    @ApiModelProperty(value = "LOCATION명")
34
+    private String locationNm;
35
+
36
+    @ApiModelProperty(value = "실사순번")
37
+    private int cddSeq;
38
+    @ApiModelProperty(value = "품목아이디")
39
+    private String itemId;
40
+    @ApiModelProperty(value = "품목명")
41
+    private String itemNm;
42
+    @ApiModelProperty(value = "단위(코드: DSTRBT_COST_UNIT)")
43
+    private String unit;
44
+    @ApiModelProperty(value = "전산기존수량")
45
+    private int comExstQty;
46
+    @ApiModelProperty(value = "실사수량")
47
+    private int cddQty;
48
+    @ApiModelProperty(value = "변동수량")
49
+    private int chgQty;
50
+
51
+}

+ 65 - 0
src/main/java/com/oqpo/api/web/dto/response/stockmng/StockCddInfoResponse.java

@@ -0,0 +1,65 @@
1
+package com.oqpo.api.web.dto.response.stockmng;
2
+
3
+import com.fasterxml.jackson.annotation.JsonInclude;
4
+import com.oqpo.api.entity.stockmng.StckCddMgntInfoEntity;
5
+import io.swagger.annotations.ApiModelProperty;
6
+import lombok.*;
7
+
8
+
9
+@Getter
10
+@Setter
11
+@Builder
12
+@AllArgsConstructor(access = AccessLevel.PROTECTED)
13
+@JsonInclude(JsonInclude.Include.ALWAYS)
14
+public class StockCddInfoResponse {
15
+
16
+    @ApiModelProperty(value = "실사아이디")
17
+    private String cddId;
18
+    @ApiModelProperty(value = "실사일자")
19
+    private String cddDt;
20
+    @ApiModelProperty(value = "실사시각")
21
+    private String cddTm;
22
+    @ApiModelProperty(value = "실사구분")
23
+    private String cddDvsn;
24
+    @ApiModelProperty(value = "실사구분명")
25
+    private String cddDvsnNm;
26
+    @ApiModelProperty(value = "실사담당자명")
27
+    private String cddMgrNm;
28
+    @ApiModelProperty(value = "창고아이디")
29
+    private String whsId;
30
+    @ApiModelProperty(value = "창고명")
31
+    private String whsNm;
32
+    @ApiModelProperty(value = "LOCATION")
33
+    private String location;
34
+    @ApiModelProperty(value = "LOCATION명")
35
+    private String locationNm;
36
+    @ApiModelProperty(value = "브랜드아이디")
37
+    private String brandId;
38
+    @ApiModelProperty(value = "브랜드명")
39
+    private String brandNm;
40
+    @ApiModelProperty(value = "매장아이디")
41
+    private String storeId;
42
+    @ApiModelProperty(value = "매장명")
43
+    private String storeNm;
44
+
45
+    public static StockCddInfoResponse toDTO(StckCddMgntInfoEntity entity) {
46
+        if (entity == null) return null;
47
+        return StockCddInfoResponse.builder()
48
+                .cddId(entity.getCddId())
49
+                .cddDt(entity.getCddDt())
50
+                .cddTm(entity.getCddTm())
51
+                .cddDvsn(entity.getCddDvsn())
52
+                .cddDvsnNm(entity.getCddDvsnNm())
53
+                .cddMgrNm(entity.getCddMgrNm())
54
+                .brandId(entity.getBrandId())
55
+                .brandNm(entity.getBrandNm())
56
+                .storeId(entity.getStoreId())
57
+                .storeNm(entity.getStoreNm())
58
+                .whsId(entity.getWhsId())
59
+                .whsNm(entity.getWhsNm())
60
+                .location(entity.getLocation())
61
+                .locationNm(entity.getLocationNm())
62
+                .build();
63
+    }
64
+
65
+}

+ 57 - 0
src/main/resources/mybatis/sqlmaps/stockmng/StockCdd.xml

@@ -121,4 +121,61 @@
121 121
              NOW(), #{userId}, NOW(), #{userId})
122 122
     </insert>
123 123
 
124
+    <select id="selectStockCddMgntInfo" resultType="com.oqpo.api.entity.stockmng.StckCddMgntInfoEntity">
125
+        /* StockCddMapper.selectStockCddMgntInfo */
126
+        SELECT A.cdd_id, A.cdd_dt, A.cdd_tm, A.cdd_dvsn, A.cdd_mgr_nm,
127
+            A.brand_id, FN_BRAND_NM(A.brand_id) AS brand_nm,
128
+            A.store_id, FN_STORE_NM(A.brand_id, A.store_id) AS store_nm,
129
+            A.whs_id, B.whs_nm, A.location, C.location_nm,
130
+            DATE_FORMAT(A.sys_reg_dttm,'%Y.%m.%d %H:%i:%s') AS sys_reg_dttm, A.sys_reg_id,
131
+            DATE_FORMAT(A.sys_chg_dttm,'%Y.%m.%d %H:%i:%s') AS sys_chg_dttm, A.sys_chg_id
132
+        FROM stck_cdd_mgnt_info A
133
+        INNER JOIN whs_mgnt_base_info B ON A.brand_id = B.brand_id AND A.whs_id = B.whs_id
134
+        INNER JOIN whs_mgnt_base_loc C ON A.brand_id = C.brand_id AND A.whs_id = C.whs_id AND A.location = C.location
135
+        WHERE A.cdd_id = #{cddId}
136
+    </select>
137
+
138
+    <select id="selectStockCddDtlGridList" resultType="com.oqpo.api.entity.stockmng.StckCddMgntDtlEntity">
139
+        /* StockCddMapper.selectStockCddDtlGridList */
140
+        SELECT A.cdd_id, A.cdd_seq, A.item_id, E.item_nm, A.unit, A.com_exst_qty, A.cdd_qty, A.chg_qty,
141
+            B.brand_id, FN_BRAND_NM(B.brand_id) AS brand_nm,
142
+            B.store_id, FN_STORE_NM(B.brand_id, B.store_id) AS store_nm,
143
+            B.whs_id, C.whs_nm, B.location, D.location_nm
144
+        FROM stck_cdd_mgnt_dtl A
145
+        INNER JOIN stck_cdd_mgnt_info B ON A.cdd_id = B.cdd_id
146
+        INNER JOIN whs_mgnt_base_info C ON B.brand_id = C.brand_id AND B.whs_id = C.whs_id
147
+        INNER JOIN whs_mgnt_base_loc D ON B.brand_id = D.brand_id AND B.whs_id = D.whs_id AND B.location = D.location
148
+        INNER JOIN item_base_info E ON A.item_id = E.item_id
149
+        WHERE A.cdd_id = #{cddId}
150
+        <choose>
151
+            <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
152
+                <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
153
+                    <if test="gridRequest.sord == 'asc'.toString()">
154
+                        ORDER BY A.cdd_seq ASC
155
+                    </if>
156
+                    <if test="gridRequest.sord == 'desc'.toString()">
157
+                        ORDER BY A.cdd_seq DESC
158
+                    </if>
159
+                </if>
160
+            </when>
161
+            <otherwise>
162
+                ORDER BY A.cdd_seq ASC
163
+            </otherwise>
164
+        </choose>
165
+        <if test="gridRequest.pagingYn == true">
166
+            limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
167
+        </if>
168
+    </select>
169
+
170
+    <select id="selectStockCddDtlGridCnt" resultType="int">
171
+        /* StockCddMapper.selectStockCddDtlGridCnt */
172
+        SELECT COUNT(*)
173
+        FROM stck_cdd_mgnt_dtl A
174
+        INNER JOIN stck_cdd_mgnt_info B ON A.cdd_id = B.cdd_id
175
+        INNER JOIN whs_mgnt_base_info C ON B.brand_id = C.brand_id AND B.whs_id = C.whs_id
176
+        INNER JOIN whs_mgnt_base_loc D ON B.brand_id = D.brand_id AND B.whs_id = D.whs_id AND B.location = D.location
177
+        INNER JOIN item_base_info E ON A.item_id = E.item_id
178
+        WHERE A.cdd_id = #{cddId}
179
+    </select>
180
+
124 181
 </mapper>