Browse Source

재고 출고가능수량 체크 api

dwkim 2 years ago
parent
commit
e78cb5c285

+ 4 - 0
src/main/java/com/oqpo/api/entity/stockmng/StckMgntBaseInfoEntity.java

@@ -60,4 +60,8 @@ public class StckMgntBaseInfoEntity implements Serializable {
60 60
     @ApiModelProperty(value = "관련번호")
61 61
     private String relationNo;
62 62
 
63
+    @ApiModelProperty(value = "출고가능수량")
64
+    private Integer whsPassQty;
65
+
66
+
63 67
 }

+ 3 - 0
src/main/java/com/oqpo/api/mapper/stockmng/StockMngMapper.java

@@ -6,6 +6,7 @@ import com.oqpo.api.entity.stockmng.StckMgntBaseInfoEntity;
6 6
 import com.oqpo.api.entity.stockmng.StckMgntDtlHistEntity;
7 7
 import com.oqpo.api.web.dto.request.GridRequest;
8 8
 import com.oqpo.api.web.dto.request.stockmng.StockMngCddGridRequest;
9
+import com.oqpo.api.web.dto.request.stockmng.StockMngPassQtyGridRequest;
9 10
 import io.swagger.annotations.ApiModelProperty;
10 11
 import org.apache.ibatis.annotations.Mapper;
11 12
 import org.apache.ibatis.annotations.Param;
@@ -61,5 +62,7 @@ public interface StockMngMapper {
61 62
     /* 재고수량 증가 - 입고처리로 인함 */
62 63
     int updateWarehouseStockQty(@Param("userId") String userId, List<StckMgntBaseInfoEntity> gridUpdateData) throws Exception;
63 64
 
65
+    List<StckMgntBaseInfoEntity> selectWhsLocOutPassQty(@Param("brandId") String brandId, @Param("whsId") String whsId, @Param("location") String location,
66
+                                                        List<StckMgntBaseInfoEntity> gridItemData) throws Exception;
64 67
 
65 68
 }

+ 1 - 0
src/main/java/com/oqpo/api/service/pomng/PchReqService.java

@@ -118,6 +118,7 @@ public class PchReqService extends CommonService {
118 118
         fromDt = fromDt == null ? null : fromDt.replace(".", "");
119 119
         toDt = toDt == null ? null : toDt.replace(".", "");
120 120
 
121
+        System.out.println("================>" + sItemNm);
121 122
         int gridRecords = pchReqMapper.selectPchReqGridCnt( sBrandId,sStoreId,  fromDt, toDt, sWhsId,sPchReqStCd, sItemNm );
122 123
         int gridTotal = fnCalculateGridTotal(gridSize, gridRecords);
123 124
         List<PchReqBaseInfoEntity> entities = pchReqMapper.selectPchReqGridList( sBrandId, sStoreId, fromDt, toDt, sWhsId,sPchReqStCd, sItemNm, gridRequest);

+ 17 - 2
src/main/java/com/oqpo/api/service/stockmng/StockMngService.java

@@ -11,10 +11,13 @@ import com.oqpo.api.service.CommonService;
11 11
 import com.oqpo.api.web.dto.request.GridRequest;
12 12
 import com.oqpo.api.web.dto.request.stockmng.ProcStockRequest;
13 13
 import com.oqpo.api.web.dto.request.stockmng.StockMngCddGridRequest;
14
+import com.oqpo.api.web.dto.request.stockmng.StockMngPassQtyGridRequest;
14 15
 import com.oqpo.api.web.dto.response.GridResponse;
16
+import com.oqpo.api.web.dto.response.pomng.pchOrd.PchOrdInitInfoResponse;
15 17
 import com.oqpo.api.web.dto.response.stockmng.StockHistListResponse;
16 18
 import com.oqpo.api.web.dto.response.stockmng.StockMngInfoResponse;
17 19
 import com.oqpo.api.web.dto.response.stockmng.StockMngListResponse;
20
+import com.oqpo.api.web.dto.response.stockmng.StockMngPassQtyListResponse;
18 21
 import lombok.extern.slf4j.Slf4j;
19 22
 import org.springframework.beans.factory.annotation.Autowired;
20 23
 import org.springframework.stereotype.Service;
@@ -41,8 +44,7 @@ public class StockMngService extends CommonService {
41 44
         int gridPage = gridRequest.getGridPage();
42 45
         int gridSize = gridRequest.getGridSize();
43 46
 
44
-        // fromDt = fromDt == null ? null : fromDt.replace(".", "");
45
-        // toDt = toDt == null ? null : toDt.replace(".", "");
47
+
46 48
 
47 49
         int gridRecords = stockMngMapper.selectStockMngGridCnt(sBrandId, sStoreId, sWhsId, sLocation,
48 50
                 sItemStCd, sItemType, sItemGubun,
@@ -216,4 +218,17 @@ public class StockMngService extends CommonService {
216 218
         }
217 219
     }
218 220
 
221
+    /*
222
+      재고 출고가능수량
223
+     */
224
+    public StockMngPassQtyListResponse selectWhsLocOutPassQty(StockMngPassQtyGridRequest stockMngPassQtyGridRequest) throws Exception {
225
+
226
+        List<StckMgntBaseInfoEntity> gridItemData = stockMngPassQtyGridRequest.toCodeEntities(stockMngPassQtyGridRequest.getGridItemData());
227
+
228
+        List<StckMgntBaseInfoEntity> entities = stockMngMapper.selectWhsLocOutPassQty(stockMngPassQtyGridRequest.getBrandId(),
229
+                stockMngPassQtyGridRequest.getWhsId(), stockMngPassQtyGridRequest.getLocation(), gridItemData);
230
+
231
+
232
+        return StockMngPassQtyListResponse.toDTO(entities); // GridResponse.toDTO(gridPage, gridTotal, gridRecords, gridRows);
233
+    }
219 234
 }

+ 20 - 4
src/main/java/com/oqpo/api/web/controller/stockmng/StockMngController.java

@@ -2,13 +2,12 @@ package com.oqpo.api.web.controller.stockmng;
2 2
 
3 3
 import com.oqpo.api.enums.SystemMessageCode;
4 4
 import com.oqpo.api.service.stockmng.StockMngService;
5
-import com.oqpo.api.web.dto.request.stockmng.ProcStockRequest;
6
-import com.oqpo.api.web.dto.request.stockmng.StockHistGridRequest;
7
-import com.oqpo.api.web.dto.request.stockmng.StockMngCddGridRequest;
8
-import com.oqpo.api.web.dto.request.stockmng.StockMngGridRequest;
5
+import com.oqpo.api.web.dto.request.stockmng.*;
9 6
 import com.oqpo.api.web.dto.response.GridResponse;
10 7
 import com.oqpo.api.web.dto.response.SaveResponse;
8
+import com.oqpo.api.web.dto.response.stockmng.StockHistListResponse;
11 9
 import com.oqpo.api.web.dto.response.stockmng.StockMngInfoResponse;
10
+import com.oqpo.api.web.dto.response.stockmng.StockMngPassQtyListResponse;
12 11
 import io.swagger.annotations.Api;
13 12
 import io.swagger.annotations.ApiImplicitParam;
14 13
 import io.swagger.annotations.ApiImplicitParams;
@@ -125,4 +124,21 @@ public class StockMngController {
125 124
         return ResponseEntity.ok(SaveResponse.toDTO(SystemMessageCode.SAVE_OK));
126 125
     }
127 126
 
127
+    /**
128
+     * 설명 : 창고별 출고가능 수량 정보 출력
129
+     *
130
+     * @param stockMngCddGridRequest
131
+     * @return
132
+     * @throws Exception
133
+     */
134
+    @ApiImplicitParams({
135
+            @ApiImplicitParam(name = "X-AUTH-TOKEN", value = "CONN-KEY", required = true, dataType = "String", paramType = "header")
136
+    })
137
+    @ApiOperation(value = "창고별 출고가능 수량 정보 출력")
138
+    @PostMapping("/whs-passqty-list")
139
+    public ResponseEntity<StockMngPassQtyListResponse> whsPassQty(@RequestBody @Valid StockMngPassQtyGridRequest stockMngPassQtyGridRequest) throws Exception {
140
+        return ResponseEntity.ok(stockMngService.selectWhsLocOutPassQty(stockMngPassQtyGridRequest));
141
+    }
142
+
143
+//,  pchOrdSearchGridRequest.toDTO(pchOrdSearchGridRequest)
128 144
 }

+ 54 - 0
src/main/java/com/oqpo/api/web/dto/request/stockmng/StockMngPassQtyGridRequest.java

@@ -0,0 +1,54 @@
1
+package com.oqpo.api.web.dto.request.stockmng;
2
+
3
+import com.oqpo.api.entity.pomng.PchReqDtlPtclEntity;
4
+import com.oqpo.api.entity.stockmng.StckMgntBaseInfoEntity;
5
+import com.oqpo.api.web.dto.request.GridRequest;
6
+import com.oqpo.api.web.dto.request.pomng.pchReq.SavePchReqlRequest;
7
+import io.swagger.annotations.ApiModelProperty;
8
+import lombok.*;
9
+
10
+import java.util.ArrayList;
11
+import java.util.List;
12
+
13
+
14
+@Getter
15
+@Setter
16
+public class StockMngPassQtyGridRequest {
17
+
18
+    @ApiModelProperty(value = "브랜드아이디")
19
+    private String brandId;
20
+    @ApiModelProperty(value = "창고아이디")
21
+    private String whsId;
22
+    @ApiModelProperty(value = "LOCATION")
23
+    private String location;
24
+
25
+    @ApiModelProperty(value = "품목별 출고가능수량 리스트")
26
+    private List<StockMngPassQtyGridRequest.StockPassItemData> gridItemData;
27
+
28
+
29
+    public List<StckMgntBaseInfoEntity> toCodeEntities(List<StockMngPassQtyGridRequest.StockPassItemData> gridData) {
30
+        List<StckMgntBaseInfoEntity> entities = new ArrayList<>();
31
+        if (gridData == null || gridData.size() == 0)
32
+            return entities;
33
+
34
+        gridData.forEach(x -> {
35
+            StckMgntBaseInfoEntity entity = new StckMgntBaseInfoEntity();
36
+            entity.setItemId(x.getItemId());
37
+            entities.add(entity);
38
+        });
39
+        return entities;
40
+    }
41
+
42
+
43
+
44
+    @Getter
45
+    @Builder
46
+    @AllArgsConstructor(access = AccessLevel.PROTECTED)
47
+    public static class StockPassItemData {
48
+
49
+        @ApiModelProperty(value = "품목아이디")
50
+        private String itemId;
51
+    }
52
+
53
+
54
+}

+ 1 - 0
src/main/java/com/oqpo/api/web/dto/response/pomng/pchOrd/PchOrdInitInfoResponse.java

@@ -93,6 +93,7 @@ public class PchOrdInitInfoResponse {
93 93
     @Builder
94 94
     @AllArgsConstructor(access = AccessLevel.PROTECTED)
95 95
     static class PchOrdDtlInfo {
96
+
96 97
         @ApiModelProperty(value = "구매요청번호")
97 98
         private String pchReqUnqNo;
98 99
 

+ 4 - 3
src/main/java/com/oqpo/api/web/dto/response/pomng/pchReq/PchReqInfoResponse.java

@@ -96,14 +96,15 @@ public class PchReqInfoResponse {
96 96
                 .storeNm(uEntity.getStoreNm() == null ? "" :uEntity.getStoreNm())
97 97
                 .authTpCd(uEntity.getAuthTpCd() == null ? "" : uEntity.getAuthTpCd())
98 98
                 .ordUseAmt(loanEntity == null ? 0 : loanEntity.getOrdUseAmt() == null ? 0 : loanEntity.getOrdUseAmt())
99
-                .loanDvsn(loanEntity == null ?  "" : loanEntity.getLoanDvsn() == null ? "" : loanEntity.getLoanDvsn())
100
-                .loanDvsnNm(loanEntity == null ?  "" : loanEntity.getLoanDvsnNm() == null ? "" : loanEntity.getLoanDvsnNm())
99
+                .loanDvsn(loanEntity == null ?  "" : loanEntity.getLoanDvsn() == null ? "LD03" : loanEntity.getLoanDvsn())
100
+                .loanDvsnNm(loanEntity == null ?  "" : loanEntity.getLoanDvsnNm() == null ? "무정산" : loanEntity.getLoanDvsnNm())
101 101
                 .loanMgntUnqNo(loanEntity == null ?  "" : loanEntity.getLoanMgntUnqNo() == null ? "" : loanEntity.getLoanMgntUnqNo())
102 102
                 .pchApprAmt(entity.getPchApprAmt())
103 103
                 .pchApprYn(entity.getPchApprYn())
104 104
                 .pchApprNm(entity.getPchApprYn() == "Y" ? "선결재" : "미납")
105 105
                 .pchReqDtlList(dtlEntityList.stream()
106 106
                         .map(m -> PchReqDtlInfo.builder()
107
+                                .viewCd("R")
107 108
                                 .pchReqUnqNo(m.getPchReqUnqNo())
108 109
                                 .pchReqDtlNo(m.getPchReqDtlNo())
109 110
                                 .itemId(m.getItemId() == null ? "" :m.getItemId())
@@ -127,7 +128,7 @@ public class PchReqInfoResponse {
127 128
     @Builder
128 129
     @AllArgsConstructor(access = AccessLevel.PROTECTED)
129 130
     static class PchReqDtlInfo {
130
-
131
+        @ApiModelProperty(value = "작업상태") private String viewCd;
131 132
         @ApiModelProperty(value = "구매요청고유번호") private String pchReqUnqNo;
132 133
         @ApiModelProperty(value = "구매요청상세번호") private String pchReqDtlNo;
133 134
         @ApiModelProperty(value = "품목아이디") private String itemId;

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

@@ -0,0 +1,51 @@
1
+package com.oqpo.api.web.dto.response.stockmng;
2
+
3
+import com.fasterxml.jackson.annotation.JsonInclude;
4
+import com.oqpo.api.entity.ActionEntity;
5
+import com.oqpo.api.entity.CodeEntity;
6
+import com.oqpo.api.entity.oper.MemberEntity;
7
+import com.oqpo.api.entity.oper.MenuEntity;
8
+import com.oqpo.api.entity.stockmng.StckMgntBaseInfoEntity;
9
+import com.oqpo.api.web.dto.response.session.SessionResponse;
10
+import io.swagger.annotations.ApiModelProperty;
11
+import lombok.*;
12
+import org.apache.commons.lang3.StringUtils;
13
+
14
+import java.math.BigDecimal;
15
+import java.util.List;
16
+import java.util.stream.Collectors;
17
+
18
+@Getter
19
+@Setter
20
+@Builder
21
+@AllArgsConstructor(access = AccessLevel.PROTECTED)
22
+@JsonInclude(JsonInclude.Include.ALWAYS)
23
+public class StockMngPassQtyListResponse {
24
+
25
+    @ApiModelProperty(value = "출고가능수량 리스트")
26
+    private List<StockMngPassQtyListResponse.WhsPassOtyInfo> whsPassList;
27
+
28
+
29
+    public static StockMngPassQtyListResponse toDTO(List<StckMgntBaseInfoEntity> whsStockList) {
30
+        if (whsStockList == null) return null;
31
+        return StockMngPassQtyListResponse.builder()
32
+                .whsPassList(whsStockList.stream()
33
+                        .map(m -> StockMngPassQtyListResponse.WhsPassOtyInfo.builder()
34
+                                .itemId(m.getItemId())
35
+                                .whsPassQty(m.getWhsPassQty() == null ? 0 : m.getWhsPassQty())
36
+                                .build())
37
+                        .collect(Collectors.toList()))
38
+                .build();
39
+    }
40
+
41
+    @Getter
42
+    @Builder
43
+    @AllArgsConstructor(access = AccessLevel.PROTECTED)
44
+    static class WhsPassOtyInfo {
45
+        @ApiModelProperty(value = "품목아이디")
46
+        private String itemId;
47
+        @ApiModelProperty(value = "출고가능수량")
48
+        private Integer whsPassQty;
49
+    }
50
+
51
+}

+ 4 - 4
src/main/resources/mybatis/sqlmaps/pomng/PchReq.xml

@@ -26,8 +26,8 @@
26 26
         </if>
27 27
         <if test="sItemNm != null and sItemNm != ''">
28 28
             and    pch_req_unq_no in ( select pch_req_unq_no from pch_req_dtl_ptcl
29
-            where date_format(sys_reg_dttm,'%Y%m%d') between #{fromDt} and #{toDt})
30
-            and  item_id like concat('%',#{sItemNm},'%') or item_nm like concat('%',#{sItemNm},'%')
29
+            where date_format(sys_reg_dttm,'%Y%m%d') between #{fromDt} and #{toDt}
30
+            and  item_id like concat('%',#{sItemNm},'%') or item_nm like concat('%',#{sItemNm},'%'))
31 31
         </if>
32 32
         <choose>
33 33
             <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
@@ -65,8 +65,8 @@
65 65
             </if>
66 66
             <if test="sItemNm != null and sItemNm != ''">
67 67
                 and    pch_req_unq_no in ( select pch_req_unq_no from pch_req_dtl_ptcl
68
-                where date_format(sys_reg_dttm,'%Y%m%d') between #{fromDt} and #{toDt})
69
-                and  item_id like concat('%',#{sItemNm},'%') or item_nm like concat('%',#{sItemNm},'%')
68
+                where date_format(sys_reg_dttm,'%Y%m%d') between #{fromDt} and #{toDt}
69
+                and  item_id like concat('%',#{sItemNm},'%') or item_nm like concat('%',#{sItemNm},'%') )
70 70
             </if>
71 71
     </select>
72 72
 

+ 12 - 0
src/main/resources/mybatis/sqlmaps/stockmng/StockMng.xml

@@ -336,4 +336,16 @@
336 336
             AND item_id = #{item.itemId}
337 337
         </foreach>
338 338
     </update>
339
+
340
+    <select id="selectWhsLocOutPassQty" resultType="com.oqpo.api.entity.stockmng.StckMgntBaseInfoEntity">
341
+        /* StockMngMapper.selectWhsLocOutPassQty */
342
+        SELECT A.item_id, A.item_nm, IFNULL(B.unit, A.unit) AS unit, ( B.stck_qty - B.wait_qty ) as whs_pass_qty
343
+        FROM item_base_info A
344
+        LEFT JOIN stck_mgnt_base_info B ON A.item_id = B.item_id AND B.brand_id = #{brandId} AND B.whs_id = #{whsId} AND B.location = #{location}
345
+        WHERE A.brand_id = #{brandId}
346
+        AND A.item_id IN
347
+        <foreach collection="gridItemData" item="item" separator="," open="(" close=")">
348
+            #{item.itemId}
349
+        </foreach>
350
+    </select>
339 351
 </mapper>