소스 검색

창고관리

hoseongs 2 년 전
부모
커밋
6eab12daf2

+ 6 - 0
src/main/java/com/oqpo/api/entity/stockmng/WhsMgntBaseInfoEntity.java

@@ -14,12 +14,16 @@ public class WhsMgntBaseInfoEntity implements Serializable {
14 14
 
15 15
     @ApiModelProperty(value = "브랜드아이디")
16 16
     private String brandId;
17
+    @ApiModelProperty(value = "브랜드명")
18
+    private String brandNm;
17 19
     @ApiModelProperty(value = "창고아이디")
18 20
     private String whsId;
19 21
     @ApiModelProperty(value = "창고명")
20 22
     private String whsNm;
21 23
     @ApiModelProperty(value = "창고관리구분(본사,매장)")
22 24
     private String whsDvsn;
25
+    @ApiModelProperty(value = "창고관리명")
26
+    private String whsDvsnNm;
23 27
     @ApiModelProperty(value = "담당자명")
24 28
     private String mgrNm;
25 29
     @ApiModelProperty(value = "담당자전화번호")
@@ -32,6 +36,8 @@ public class WhsMgntBaseInfoEntity implements Serializable {
32 36
     private String addr2;
33 37
     @ApiModelProperty(value = "창고상태코드")
34 38
     private String whsStCd;
39
+    @ApiModelProperty(value = "창고상태명")
40
+    private String whsStNm;
35 41
     @ApiModelProperty(value = "매장아이디")
36 42
     private String storeId;
37 43
     @ApiModelProperty(value = "매장명")

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

@@ -22,8 +22,12 @@ public class WhsMgntBaseLocEntity implements Serializable {
22 22
     private String locationNm;
23 23
     @ApiModelProperty(value = "재고상태구분")
24 24
     private String stckDvsn;
25
+    @ApiModelProperty(value = "재고상태구분")
26
+    private String stckDvsnNm;
25 27
     @ApiModelProperty(value = "창고상태코드")
26 28
     private String locStCd;
29
+    @ApiModelProperty(value = "창고상태코드")
30
+    private String locStNm;
27 31
     @ApiModelProperty(value = "시스템등록일시")
28 32
     private String sysRegDttm;
29 33
     @ApiModelProperty(value = "시스템등록아이디")

+ 39 - 0
src/main/java/com/oqpo/api/mapper/stockmng/WhsMngMapper.java

@@ -0,0 +1,39 @@
1
+package com.oqpo.api.mapper.stockmng;
2
+
3
+
4
+import com.oqpo.api.entity.stockmng.WhsMgntBaseInfoEntity;
5
+import com.oqpo.api.entity.stockmng.WhsMgntBaseLocEntity;
6
+import com.oqpo.api.web.dto.request.GridRequest;
7
+import org.apache.ibatis.annotations.Mapper;
8
+import org.apache.ibatis.annotations.Param;
9
+
10
+import java.util.List;
11
+
12
+@Mapper
13
+public interface WhsMngMapper {
14
+
15
+    List<WhsMgntBaseInfoEntity> selectWhsMngGridList(@Param("sBrandId") String sBrandId, @Param("sStoreId") String sStoreId, @Param("sWhsDvsn") String sWhsDvsn, @Param("sWhsStCd") String sWhsStCd,
16
+                                                     @Param("sWhsNm") String sWhsNm, GridRequest gridRequest) throws Exception;
17
+
18
+    int selectWhsMngGridCnt(@Param("sBrandId") String sBrandId, @Param("sStoreId") String sStoreId, @Param("sWhsDvsn") String sWhsDvsn, @Param("sWhsStCd") String sWhsStCd,
19
+                            @Param("sWhsNm") String sWhsNm) throws Exception;
20
+
21
+    WhsMgntBaseInfoEntity selectWhsMgntBaseInfo(@Param("brandId") String brandId, @Param("whsId") String whsId) throws Exception;
22
+
23
+    List<WhsMgntBaseLocEntity> selectWhsLocGridList(@Param("brandId") String brandId, @Param("whsId") String whsId) throws Exception;
24
+
25
+    int insertWhsMgntBaseInfo(@Param("userId") String userId, WhsMgntBaseInfoEntity entity) throws Exception;
26
+
27
+    int updateWhsMgntBaseInfo(@Param("userId") String userId, WhsMgntBaseInfoEntity entity) throws Exception;
28
+
29
+    int deleteWhsMgntBaseInfo(@Param("userId") String userId, WhsMgntBaseInfoEntity entity) throws Exception;
30
+
31
+    int deleteWhsMgntBaseLoc4Info(@Param("userId") String userId, WhsMgntBaseInfoEntity entity) throws Exception;
32
+
33
+    int insertWhsMgntBaseLoc(@Param("userId") String userId, WhsMgntBaseLocEntity entity) throws Exception;
34
+
35
+    int updateWhsMgntBaseLoc(@Param("userId") String userId, WhsMgntBaseLocEntity entity) throws Exception;
36
+
37
+    int deleteWhsMgntBaseLoc(@Param("userId") String userId, WhsMgntBaseLocEntity entity) throws Exception;
38
+
39
+}

+ 164 - 0
src/main/java/com/oqpo/api/service/stockmng/WhsMngService.java

@@ -0,0 +1,164 @@
1
+package com.oqpo.api.service.stockmng;
2
+
3
+
4
+import com.oqpo.api.entity.stockmng.*;
5
+import com.oqpo.api.exception.GlobalException;
6
+import com.oqpo.api.mapper.stockmng.WhsMngMapper;
7
+import com.oqpo.api.service.CommonService;
8
+import com.oqpo.api.web.dto.request.GridRequest;
9
+import com.oqpo.api.web.dto.request.stockmng.SaveWhsInfoRequest;
10
+import com.oqpo.api.web.dto.response.GridResponse;
11
+import com.oqpo.api.web.dto.response.stockmng.*;
12
+import lombok.extern.slf4j.Slf4j;
13
+import org.springframework.beans.factory.annotation.Autowired;
14
+import org.springframework.stereotype.Service;
15
+import org.springframework.transaction.annotation.Transactional;
16
+
17
+import java.math.BigDecimal;
18
+import java.util.List;
19
+import java.util.stream.Collectors;
20
+
21
+@Service
22
+@Slf4j
23
+public class WhsMngService extends CommonService {
24
+
25
+    @Autowired
26
+    private WhsMngMapper whsMngMapper;
27
+
28
+    /*
29
+      창고관리 그리드 리스트 조회
30
+     */
31
+    public GridResponse selectWhsMngGridList(String sBrandId, String sStoreId, String sWhsDvsn, String sWhsStCd,
32
+                                             String sWhsNm, GridRequest gridRequest) throws Exception {
33
+        int gridPage = gridRequest.getGridPage();
34
+        int gridSize = gridRequest.getGridSize();
35
+
36
+        int gridRecords = whsMngMapper.selectWhsMngGridCnt(sBrandId, sStoreId, sWhsDvsn, sWhsStCd, sWhsNm);
37
+        int gridTotal = fnCalculateGridTotal(gridSize, gridRecords);
38
+        List<WhsMgntBaseInfoEntity> entities = whsMngMapper.selectWhsMngGridList(sBrandId, sStoreId, sWhsDvsn, sWhsStCd, sWhsNm, gridRequest);
39
+        List<Object> gridRows = entities.stream()
40
+                .map(m -> WhsMngListResponse.builder()
41
+                        .viewCd("R")
42
+                        .brandId(m.getBrandId())
43
+                        .brandNm(m.getBrandNm())
44
+                        .whsId(m.getWhsId())
45
+                        .whsNm(m.getWhsNm())
46
+                        .whsDvsn(m.getWhsDvsn())
47
+                        .whsDvsnNm(m.getWhsDvsnNm())
48
+                        .mgrNm(m.getMgrNm())
49
+                        .mgrTelNo(m.getMgrTelNo())
50
+                        .whsStCd(m.getWhsStCd())
51
+                        .whsStNm(m.getWhsStNm())
52
+                        .storeId(m.getStoreId())
53
+                        .storeNm(m.getStoreNm())
54
+                        .build())
55
+                .collect(Collectors.toList());
56
+        return GridResponse.toDTO(gridPage, gridTotal, gridRecords, gridRows);
57
+    }
58
+
59
+    /* 창고관리 정보 조회 */
60
+    public WhsMngInfoResponse selectWhsMngInfo(String brandId, String whsId) throws Exception {
61
+        WhsMgntBaseInfoEntity entity = whsMngMapper.selectWhsMgntBaseInfo(brandId, whsId);
62
+        List<WhsMgntBaseLocEntity> locEntityList = whsMngMapper.selectWhsLocGridList(brandId, whsId);
63
+        return WhsMngInfoResponse.toDTO(entity, locEntityList);
64
+    }
65
+
66
+    /* 창고정보 등록 */
67
+    @Transactional
68
+    public void addWhsInfo(String userId, SaveWhsInfoRequest saveWhsInfoRequest) throws Exception {
69
+        try {
70
+            // 창고관리기본정보
71
+            WhsMgntBaseInfoEntity entity = new WhsMgntBaseInfoEntity();
72
+            entity.setBrandId(saveWhsInfoRequest.getBrandId());
73
+            entity.setWhsId(fnGetDealNo(28, "")); // 창고아이디 채번
74
+            entity.setWhsNm(saveWhsInfoRequest.getWhsNm());
75
+            entity.setWhsDvsn(saveWhsInfoRequest.getWhsDvsn());
76
+            entity.setMgrNm(saveWhsInfoRequest.getMgrNm());
77
+            entity.setMgrTelNo(saveWhsInfoRequest.getMgrTelNo());
78
+            entity.setZipNo(saveWhsInfoRequest.getZipNo());
79
+            entity.setAddr1(saveWhsInfoRequest.getAddr1());
80
+            entity.setAddr2(saveWhsInfoRequest.getAddr2());
81
+            entity.setWhsStCd(saveWhsInfoRequest.getWhsStCd());
82
+            entity.setStoreId(saveWhsInfoRequest.getStoreId());
83
+            whsMngMapper.insertWhsMgntBaseInfo(userId, entity);
84
+
85
+            // 창고로케이션정보
86
+            List<WhsMgntBaseLocEntity> locEntities = saveWhsInfoRequest.toEntities(saveWhsInfoRequest.getGridInsertData());
87
+            for (WhsMgntBaseLocEntity locEntity : locEntities) {
88
+                whsMngMapper.insertWhsMgntBaseLoc(userId, locEntity);
89
+            }
90
+        } catch (GlobalException e) {
91
+            e.getStackTrace();
92
+            throw new GlobalException(e.getSystemMessageCode());
93
+        } catch (Exception e) {
94
+            e.getStackTrace();
95
+            throw new RuntimeException();
96
+        }
97
+    }
98
+
99
+    /* 창고정보 수정 */
100
+    @Transactional
101
+    public void modifyWhsInfo(String userId, SaveWhsInfoRequest saveWhsInfoRequest) throws Exception {
102
+        try {
103
+            // 창고관리기본정보
104
+            WhsMgntBaseInfoEntity entity = new WhsMgntBaseInfoEntity();
105
+            entity.setBrandId(saveWhsInfoRequest.getBrandId());
106
+            entity.setWhsId(saveWhsInfoRequest.getWhsId());
107
+            entity.setWhsNm(saveWhsInfoRequest.getWhsNm());
108
+            entity.setWhsDvsn(saveWhsInfoRequest.getWhsDvsn());
109
+            entity.setMgrNm(saveWhsInfoRequest.getMgrNm());
110
+            entity.setMgrTelNo(saveWhsInfoRequest.getMgrTelNo());
111
+            entity.setZipNo(saveWhsInfoRequest.getZipNo());
112
+            entity.setAddr1(saveWhsInfoRequest.getAddr1());
113
+            entity.setAddr2(saveWhsInfoRequest.getAddr2());
114
+            entity.setWhsStCd(saveWhsInfoRequest.getWhsStCd());
115
+            entity.setStoreId(saveWhsInfoRequest.getStoreId());
116
+            whsMngMapper.updateWhsMgntBaseInfo(userId, entity);
117
+
118
+            // 창고로케이션정보
119
+            // 삭제
120
+            List<WhsMgntBaseLocEntity> locEntities = saveWhsInfoRequest.toEntities(saveWhsInfoRequest.getGridDeleteData());
121
+            for (WhsMgntBaseLocEntity locEntity : locEntities) {
122
+                whsMngMapper.deleteWhsMgntBaseLoc(userId, locEntity);
123
+            }
124
+            // 수정
125
+            locEntities = saveWhsInfoRequest.toEntities(saveWhsInfoRequest.getGridUpdateData());
126
+            for (WhsMgntBaseLocEntity locEntity : locEntities) {
127
+                whsMngMapper.updateWhsMgntBaseLoc(userId, locEntity);
128
+            }
129
+            // 등록
130
+            locEntities = saveWhsInfoRequest.toEntities(saveWhsInfoRequest.getGridInsertData());
131
+            for (WhsMgntBaseLocEntity locEntity : locEntities) {
132
+                whsMngMapper.insertWhsMgntBaseLoc(userId, locEntity);
133
+            }
134
+        } catch (GlobalException e) {
135
+            e.getStackTrace();
136
+            throw new GlobalException(e.getSystemMessageCode());
137
+        } catch (Exception e) {
138
+            e.getStackTrace();
139
+            throw new RuntimeException();
140
+        }
141
+    }
142
+
143
+    /* 창고정보 삭제 */
144
+    @Transactional
145
+    public void removeWhsInfo(String userId, SaveWhsInfoRequest saveWhsInfoRequest) throws Exception {
146
+        try {
147
+            // 창고관리기본정보
148
+            WhsMgntBaseInfoEntity entity = new WhsMgntBaseInfoEntity();
149
+            entity.setBrandId(saveWhsInfoRequest.getBrandId());
150
+            entity.setWhsId(saveWhsInfoRequest.getWhsId());
151
+            whsMngMapper.deleteWhsMgntBaseInfo(userId, entity);
152
+
153
+            // 창고로케이션정보
154
+            whsMngMapper.deleteWhsMgntBaseLoc4Info(userId, entity);
155
+        } catch (GlobalException e) {
156
+            e.getStackTrace();
157
+            throw new GlobalException(e.getSystemMessageCode());
158
+        } catch (Exception e) {
159
+            e.getStackTrace();
160
+            throw new RuntimeException();
161
+        }
162
+    }
163
+
164
+}

+ 119 - 0
src/main/java/com/oqpo/api/web/controller/stockmng/BrandWhsMngController.java

@@ -0,0 +1,119 @@
1
+package com.oqpo.api.web.controller.stockmng;
2
+
3
+import com.oqpo.api.enums.SystemMessageCode;
4
+import com.oqpo.api.service.stockmng.WhsMngService;
5
+import com.oqpo.api.web.dto.request.stockmng.*;
6
+import com.oqpo.api.web.dto.response.GridResponse;
7
+import com.oqpo.api.web.dto.response.SaveResponse;
8
+import com.oqpo.api.web.dto.response.stockmng.WhsMngInfoResponse;
9
+import io.swagger.annotations.ApiImplicitParam;
10
+import io.swagger.annotations.ApiImplicitParams;
11
+import io.swagger.annotations.ApiOperation;
12
+import lombok.extern.slf4j.Slf4j;
13
+import org.springframework.beans.factory.annotation.Autowired;
14
+import org.springframework.http.ResponseEntity;
15
+import org.springframework.web.bind.annotation.*;
16
+import springfox.documentation.annotations.ApiIgnore;
17
+
18
+import javax.validation.Valid;
19
+
20
+@Slf4j
21
+@RestController
22
+@RequestMapping("/api/brand/whs/mng")
23
+public class BrandWhsMngController {
24
+
25
+    @Autowired
26
+    private WhsMngService whsMngService;
27
+
28
+    /**
29
+     * 설명 : 창고관리 그리드 리스트
30
+     *
31
+     * @param brandWhsMngGridRequest
32
+     * @return
33
+     * @throws Exception
34
+     */
35
+    @ApiImplicitParams({
36
+            @ApiImplicitParam(name = "X-AUTH-TOKEN", value = "CONN-KEY", required = true, dataType = "String", paramType = "header")
37
+    })
38
+    @ApiOperation(value = "창고관리 그리드 리스트")
39
+    @PostMapping("/detail-grid-list")
40
+    public ResponseEntity<GridResponse> detailGridList(@RequestBody @Valid BrandWhsMngGridRequest brandWhsMngGridRequest) throws Exception {
41
+        return ResponseEntity.ok(whsMngService.selectWhsMngGridList(brandWhsMngGridRequest.getSBrandId(), brandWhsMngGridRequest.getSStoreId(),
42
+                brandWhsMngGridRequest.getSWhsDvsn(), brandWhsMngGridRequest.getSWhsStCd(),
43
+                brandWhsMngGridRequest.getSWhsNm(), brandWhsMngGridRequest.toDTO(brandWhsMngGridRequest)));
44
+    }
45
+
46
+    /**
47
+     * 설명 : 창고 정보
48
+     *
49
+     * @param brandId
50
+     * @param whsId
51
+     * @return
52
+     * @throws Exception
53
+     */
54
+    @ApiImplicitParams({
55
+            @ApiImplicitParam(name = "X-AUTH-TOKEN", value = "CONN-KEY", required = true, dataType = "String", paramType = "header"),
56
+            @ApiImplicitParam(name = "brandId", value = "브랜드아이디", required = true, dataType = "String", paramType = "query"),
57
+            @ApiImplicitParam(name = "whsId", value = "창고아이디", required = true, dataType = "String", paramType = "query")
58
+    })
59
+    @ApiOperation(value = "창고 정보")
60
+    @GetMapping("/info-whs")
61
+    public ResponseEntity<WhsMngInfoResponse> infoWhs(@RequestParam(value = "brandId") String brandId, @RequestParam(value = "whsId") String whsId) throws Exception {
62
+        return ResponseEntity.ok(whsMngService.selectWhsMngInfo(brandId, whsId));
63
+    }
64
+
65
+    /**
66
+     * 설명 : 창고 신규등록
67
+     *
68
+     * @param userId
69
+     * @param saveWhsInfoRequest
70
+     * @return SaveResponse
71
+     * @throws Exception
72
+     */
73
+    @ApiImplicitParams({
74
+            @ApiImplicitParam(name = "X-AUTH-TOKEN", value = "CONN-KEY", required = true, dataType = "String", paramType = "header")
75
+    })
76
+    @ApiOperation(value = "창고 신규등록")
77
+    @PostMapping("/add-whs")
78
+    public ResponseEntity<SaveResponse> addWhs(@ApiIgnore String userId, @RequestBody @Valid SaveWhsInfoRequest saveWhsInfoRequest) throws Exception {
79
+        whsMngService.addWhsInfo(userId, saveWhsInfoRequest);
80
+        return ResponseEntity.ok(SaveResponse.toDTO(SystemMessageCode.SAVE_OK));
81
+    }
82
+
83
+    /**
84
+     * 설명 : 창고 정보 수정
85
+     *
86
+     * @param userId
87
+     * @param saveWhsInfoRequest
88
+     * @return SaveResponse
89
+     * @throws Exception
90
+     */
91
+    @ApiImplicitParams({
92
+            @ApiImplicitParam(name = "X-AUTH-TOKEN", value = "CONN-KEY", required = true, dataType = "String", paramType = "header")
93
+    })
94
+    @ApiOperation(value = "창고 정보 수정")
95
+    @PostMapping("/modify-whs")
96
+    public ResponseEntity<SaveResponse> modifyWhs(@ApiIgnore String userId, @RequestBody @Valid SaveWhsInfoRequest saveWhsInfoRequest) throws Exception {
97
+        whsMngService.modifyWhsInfo(userId, saveWhsInfoRequest);
98
+        return ResponseEntity.ok(SaveResponse.toDTO(SystemMessageCode.SAVE_OK));
99
+    }
100
+
101
+    /**
102
+     * 설명 : 창고 삭제
103
+     *
104
+     * @param userId
105
+     * @param saveWhsInfoRequest
106
+     * @return SaveResponse
107
+     * @throws Exception
108
+     */
109
+    @ApiImplicitParams({
110
+            @ApiImplicitParam(name = "X-AUTH-TOKEN", value = "CONN-KEY", required = true, dataType = "String", paramType = "header")
111
+    })
112
+    @ApiOperation(value = "창고 삭제")
113
+    @PostMapping("/remove-whs")
114
+    public ResponseEntity<SaveResponse> removeWhs(@ApiIgnore String userId, @RequestBody @Valid SaveWhsInfoRequest saveWhsInfoRequest) throws Exception {
115
+        whsMngService.removeWhsInfo(userId, saveWhsInfoRequest);
116
+        return ResponseEntity.ok(SaveResponse.toDTO(SystemMessageCode.SAVE_OK));
117
+    }
118
+
119
+}

+ 28 - 0
src/main/java/com/oqpo/api/web/dto/request/stockmng/BrandWhsMngGridRequest.java

@@ -0,0 +1,28 @@
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 BrandWhsMngGridRequest extends GridRequest {
12
+
13
+    @ApiModelProperty(value = "브랜드아이디")
14
+    private String sBrandId;
15
+    @ApiModelProperty(value = "매장아이디")
16
+    private String sStoreId;
17
+
18
+    @ApiModelProperty(value = "창고관리구분(본사,매장)")
19
+    private String sWhsDvsn;
20
+    @ApiModelProperty(value = "창고상태코드")
21
+    private String sWhsStCd;
22
+    @ApiModelProperty(value = "창고명")
23
+    private String sWhsNm;
24
+
25
+    protected BrandWhsMngGridRequest(Integer gridSize, Integer gridPage, String sidx, String sord, Boolean pagingYn, Integer gridFirst) {
26
+        super(gridSize, gridPage, sidx, sord, pagingYn, gridFirst);
27
+    }
28
+}

+ 77 - 0
src/main/java/com/oqpo/api/web/dto/request/stockmng/SaveWhsInfoRequest.java

@@ -0,0 +1,77 @@
1
+package com.oqpo.api.web.dto.request.stockmng;
2
+
3
+import com.oqpo.api.entity.stockmng.WhsMgntBaseLocEntity;
4
+import io.swagger.annotations.ApiModelProperty;
5
+import lombok.*;
6
+
7
+import java.util.ArrayList;
8
+import java.util.List;
9
+
10
+@Getter
11
+@Setter
12
+public class SaveWhsInfoRequest {
13
+
14
+    @ApiModelProperty(value = "브랜드아이디")
15
+    private String brandId;
16
+    @ApiModelProperty(value = "창고아이디")
17
+    private String whsId;
18
+    @ApiModelProperty(value = "창고명")
19
+    private String whsNm;
20
+    @ApiModelProperty(value = "창고관리구분(본사,매장)")
21
+    private String whsDvsn;
22
+    @ApiModelProperty(value = "담당자명")
23
+    private String mgrNm;
24
+    @ApiModelProperty(value = "담당자전화번호")
25
+    private String mgrTelNo;
26
+    @ApiModelProperty(value = "우편번호")
27
+    private String zipNo;
28
+    @ApiModelProperty(value = "주소1")
29
+    private String addr1;
30
+    @ApiModelProperty(value = "주소2")
31
+    private String addr2;
32
+    @ApiModelProperty(value = "창고상태코드")
33
+    private String whsStCd;
34
+    @ApiModelProperty(value = "매장아이디")
35
+    private String storeId;
36
+
37
+    @ApiModelProperty(value = "위치정보 리스트")
38
+    private List<SaveWhsInfoRequest.LocationReqData> gridInsertData;
39
+    @ApiModelProperty(value = "위치정보 리스트")
40
+    private List<SaveWhsInfoRequest.LocationReqData> gridUpdateData;
41
+    @ApiModelProperty(value = "위치정보 리스트")
42
+    private List<SaveWhsInfoRequest.LocationReqData> gridDeleteData;
43
+
44
+    public List<WhsMgntBaseLocEntity> toEntities(List<SaveWhsInfoRequest.LocationReqData> gridData) {
45
+        List<WhsMgntBaseLocEntity> entities = new ArrayList<>();
46
+        if (gridData == null || gridData.size() == 0)
47
+            return entities;
48
+
49
+        gridData.forEach(x -> {
50
+            WhsMgntBaseLocEntity entity = new WhsMgntBaseLocEntity();
51
+            entity.setBrandId(brandId);
52
+            entity.setWhsId(whsId);
53
+            entity.setLocation(x.getLocation());
54
+            entity.setLocationNm(x.getLocationNm());
55
+            entity.setStckDvsn(x.getStckDvsn());
56
+            entity.setLocStCd(x.getLocStCd());
57
+            entities.add(entity);
58
+        });
59
+        return entities;
60
+    }
61
+
62
+    @Getter
63
+    @Builder
64
+    @AllArgsConstructor(access = AccessLevel.PROTECTED)
65
+    static class LocationReqData {
66
+
67
+        @ApiModelProperty(value = "LOCATION")
68
+        private String location;
69
+        @ApiModelProperty(value = "로케이션명")
70
+        private String locationNm;
71
+        @ApiModelProperty(value = "재고상태구분")
72
+        private String stckDvsn;
73
+        @ApiModelProperty(value = "창고상태코드")
74
+        private String locStCd;
75
+
76
+    }
77
+}

+ 115 - 0
src/main/java/com/oqpo/api/web/dto/response/stockmng/WhsMngInfoResponse.java

@@ -0,0 +1,115 @@
1
+package com.oqpo.api.web.dto.response.stockmng;
2
+
3
+import com.fasterxml.jackson.annotation.JsonInclude;
4
+import com.oqpo.api.entity.stockmng.WhsMgntBaseInfoEntity;
5
+import com.oqpo.api.entity.stockmng.WhsMgntBaseLocEntity;
6
+import io.swagger.annotations.ApiModelProperty;
7
+import lombok.*;
8
+
9
+import java.util.List;
10
+import java.util.stream.Collectors;
11
+
12
+
13
+@Getter
14
+@Setter
15
+@Builder
16
+@AllArgsConstructor(access = AccessLevel.PROTECTED)
17
+@JsonInclude(JsonInclude.Include.ALWAYS)
18
+public class WhsMngInfoResponse {
19
+
20
+    @ApiModelProperty(value = "브랜드아이디")
21
+    private String brandId;
22
+    @ApiModelProperty(value = "브랜드명")
23
+    private String brandNm;
24
+    @ApiModelProperty(value = "창고아이디")
25
+    private String whsId;
26
+    @ApiModelProperty(value = "창고명")
27
+    private String whsNm;
28
+    @ApiModelProperty(value = "창고관리구분(본사,매장)")
29
+    private String whsDvsn;
30
+    @ApiModelProperty(value = "창고관리명")
31
+    private String whsDvsnNm;
32
+    @ApiModelProperty(value = "담당자명")
33
+    private String mgrNm;
34
+    @ApiModelProperty(value = "담당자전화번호")
35
+    private String mgrTelNo;
36
+    @ApiModelProperty(value = "우편번호")
37
+    private String zipNo;
38
+    @ApiModelProperty(value = "주소1")
39
+    private String addr1;
40
+    @ApiModelProperty(value = "주소2")
41
+    private String addr2;
42
+    @ApiModelProperty(value = "창고상태코드")
43
+    private String whsStCd;
44
+    @ApiModelProperty(value = "창고상태명")
45
+    private String whsStNm;
46
+    @ApiModelProperty(value = "매장아이디")
47
+    private String storeId;
48
+    @ApiModelProperty(value = "매장명")
49
+    private String storeNm;
50
+    @ApiModelProperty(value = "시스템등록일시")
51
+    private String sysRegDttm;
52
+    @ApiModelProperty(value = "시스템등록아이디")
53
+    private String sysRegId;
54
+    @ApiModelProperty(value = "시스템변경일시")
55
+    private String sysChgDttm;
56
+    @ApiModelProperty(value = "시스템변경아이디")
57
+    private String sysChgId;
58
+
59
+    @ApiModelProperty(value = "위치정보 리스트")
60
+    private List<LocationInfo> locationInfoList;
61
+
62
+    public static WhsMngInfoResponse toDTO(WhsMgntBaseInfoEntity entity, List<WhsMgntBaseLocEntity> locationInfoList) {
63
+        if (entity == null) return null;
64
+        return WhsMngInfoResponse.builder()
65
+                .brandId(entity.getBrandId())
66
+                .brandNm(entity.getBrandNm())
67
+                .whsId(entity.getWhsId())
68
+                .whsNm(entity.getWhsNm())
69
+                .whsDvsn(entity.getWhsDvsn())
70
+                .whsDvsnNm(entity.getWhsDvsnNm())
71
+                .mgrNm(entity.getMgrNm())
72
+                .mgrTelNo(entity.getMgrTelNo())
73
+                .zipNo(entity.getZipNo())
74
+                .addr1(entity.getAddr1())
75
+                .addr2(entity.getAddr2())
76
+                .whsStCd(entity.getWhsStCd())
77
+                .whsStNm(entity.getWhsStNm())
78
+                .storeId(entity.getStoreId())
79
+                .storeNm(entity.getStoreNm())
80
+                .sysRegDttm(entity.getSysRegDttm())
81
+                .sysRegId(entity.getSysRegId())
82
+                .sysChgDttm(entity.getSysChgDttm())
83
+                .sysChgId(entity.getSysChgId())
84
+                .locationInfoList(locationInfoList.stream()
85
+                        .map(m -> LocationInfo.builder()
86
+                                .location(m.getLocation())
87
+                                .locationNm(m.getLocationNm())
88
+                                .stckDvsn(m.getStckDvsn())
89
+                                .stckDvsnNm(m.getStckDvsnNm())
90
+                                .locStCd(m.getLocStCd())
91
+                                .locStNm(m.getLocStNm())
92
+                                .build())
93
+                        .collect(Collectors.toList()))
94
+                .build();
95
+    }
96
+
97
+    @Getter
98
+    @Builder
99
+    @AllArgsConstructor(access = AccessLevel.PROTECTED)
100
+    static class LocationInfo {
101
+        @ApiModelProperty(value = "LOCATION")
102
+        private String location;
103
+        @ApiModelProperty(value = "로케이션명")
104
+        private String locationNm;
105
+        @ApiModelProperty(value = "재고상태구분")
106
+        private String stckDvsn;
107
+        @ApiModelProperty(value = "재고상태구분명")
108
+        private String stckDvsnNm;
109
+        @ApiModelProperty(value = "창고상태코드")
110
+        private String locStCd;
111
+        @ApiModelProperty(value = "창고상태명")
112
+        private String locStNm;
113
+    }
114
+
115
+}

+ 45 - 0
src/main/java/com/oqpo/api/web/dto/response/stockmng/WhsMngListResponse.java

@@ -0,0 +1,45 @@
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
+import java.math.BigDecimal;
8
+
9
+@Getter
10
+@Setter
11
+@Builder
12
+@AllArgsConstructor(access = AccessLevel.PROTECTED)
13
+@JsonInclude(JsonInclude.Include.ALWAYS)
14
+public class WhsMngListResponse {
15
+
16
+    @ApiModelProperty(value = "CRUD")
17
+    private String viewCd;
18
+
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 = "창고관리구분(본사,매장)")
32
+    private String whsDvsn;
33
+    @ApiModelProperty(value = "창고관리구분명")
34
+    private String whsDvsnNm;
35
+    @ApiModelProperty(value = "창고상태코드")
36
+    private String whsStCd;
37
+    @ApiModelProperty(value = "창고상태명")
38
+    private String whsStNm;
39
+    @ApiModelProperty(value = "담당자명")
40
+    private String mgrNm;
41
+    @ApiModelProperty(value = "담당자전화번호")
42
+    private String mgrTelNo;
43
+
44
+
45
+}

+ 226 - 0
src/main/resources/mybatis/sqlmaps/stockmng/WhsMng.xml

@@ -0,0 +1,226 @@
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.stockmng.WhsMngMapper">
5
+
6
+    <select id="selectWhsMngGridList" resultType="com.oqpo.api.entity.stockmng.WhsMgntBaseInfoEntity">
7
+        /* StockMngMapper.selectWhsMngGridList */
8
+        SELECT A.brand_id, FN_BRAND_NM(A.brand_id) AS brand_nm,
9
+            A.whs_id, A.whs_nm, A.whs_dvsn, A.mgr_nm, A.mgr_tel_no, A.zip_no,
10
+            A.addr1, A.addr2, A.whs_st_cd, A.store_id,
11
+            DATE_FORMAT(A.sys_reg_dttm,'%Y.%m.%d %H:%i:%s') AS sys_reg_dttm, A.sys_reg_id, DATE_FORMAT(A.sys_chg_dttm,'%Y.%m.%d %H:%i:%s') AS sys_chg_dttm, A.sys_chg_id
12
+        FROM whs_mgnt_base_info A
13
+        WHERE A.brand_id = #{sBrandId}
14
+        AND A.whs_id = #{entity.whsId}
15
+
16
+        SELECT A.brand_id, FN_BRAND_NM(A.brand_id) AS brand_nm,
17
+            C.store_id, FN_STORE_NM(A.brand_id, C.store_id) AS store_nm,
18
+            A.whs_id, C.whs_nm, A.location, D.location_nm, A.item_id, E.item_nm, A.unit, A.stck_qty, A.prp_stck_qty,
19
+            A.sft_stck_rt, A.cur_stck_rt
20
+        FROM stck_mgnt_base_info A
21
+        INNER JOIN whs_mgnt_base_info C ON A.brand_id = C.brand_id AND A.whs_id = C.whs_id
22
+        INNER JOIN whs_mgnt_base_loc D ON A.brand_id = D.brand_id AND A.whs_id = D.whs_id AND A.location = D.location
23
+        INNER JOIN item_base_info E ON A.item_id = E.item_id
24
+        <if test="sItemClass1 != null and sItemClass1 != ''">
25
+        INNER JOIN item_class_ptcl B ON A.item_id = B.item_id
26
+            AND B.item_class1 = #{sItemClass1}
27
+            <if test="sItemClass2 != null and sItemClass2 != ''">
28
+            AND B.item_class2 = #{sItemClass2}
29
+                <if test="sItemClass3 != null and sItemClass3 != ''">
30
+                AND B.item_class3 = #{sItemClass3}
31
+                    <if test="sItemClass4 != null and sItemClass4 != ''">
32
+                    AND B.item_class4 = #{sItemClass4}
33
+                    </if>
34
+                </if>
35
+            </if>
36
+        </if>
37
+        WHERE A.brand_id = #{sBrandId}
38
+        <if test="sStoreId != null and sStoreId != ''">
39
+        AND C.store_id = #{sStoreId}
40
+        </if>
41
+        <if test="sWhsId != null and sWhsId != ''">
42
+        AND A.whs_id = #{sWhsId}
43
+        </if>
44
+        <if test="sLocation != null and sLocation != ''">
45
+        AND A.location = #{sLocation}
46
+        </if>
47
+        <if test="sItemId != null and sItemId != ''">
48
+        AND A.item_id = #{sItemId}
49
+        </if>
50
+        <if test="sItemNm != null and sItemNm != ''">
51
+        AND A.item_nm LIKE CONCAT('%',#{sItemNm},'%')
52
+        </if>
53
+        <choose>
54
+            <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
55
+                <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
56
+                    <if test="gridRequest.sord == 'asc'.toString()">
57
+                        ORDER BY A.item_id ASC
58
+                    </if>
59
+                    <if test="gridRequest.sord == 'desc'.toString()">
60
+                        ORDER BY A.item_id DESC
61
+                    </if>
62
+                </if>
63
+            </when>
64
+            <otherwise>
65
+                ORDER BY A.item_id ASC
66
+            </otherwise>
67
+        </choose>
68
+        <if test="gridRequest.pagingYn == true">
69
+            limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
70
+        </if>
71
+    </select>
72
+
73
+    <select id="selectStockMngGridCnt" resultType="int">
74
+        /* StockMngMapper.selectStockMngGridCnt */
75
+        SELECT COUNT(*)
76
+        FROM stck_mgnt_base_info A
77
+        INNER JOIN whs_mgnt_base_info C ON A.brand_id = C.brand_id AND A.whs_id = C.whs_id
78
+        INNER JOIN whs_mgnt_base_loc D ON A.brand_id = D.brand_id AND A.whs_id = D.whs_id AND A.location = D.location
79
+        INNER JOIN item_base_info E ON A.item_id = E.item_id
80
+        <if test="sItemClass1 != null and sItemClass1 != ''">
81
+            INNER JOIN item_class_ptcl B ON A.item_id = B.item_id
82
+            AND B.item_class1 = #{sItemClass1}
83
+            <if test="sItemClass2 != null and sItemClass2 != ''">
84
+                AND B.item_class2 = #{sItemClass2}
85
+                <if test="sItemClass3 != null and sItemClass3 != ''">
86
+                    AND B.item_class3 = #{sItemClass3}
87
+                    <if test="sItemClass4 != null and sItemClass4 != ''">
88
+                        AND B.item_class4 = #{sItemClass4}
89
+                    </if>
90
+                </if>
91
+            </if>
92
+        </if>
93
+        WHERE A.brand_id = #{sBrandId}
94
+        <if test="sStoreId != null and sStoreId != ''">
95
+            AND C.store_id = #{sStoreId}
96
+        </if>
97
+        <if test="sWhsId != null and sWhsId != ''">
98
+            AND A.whs_id = #{sWhsId}
99
+        </if>
100
+        <if test="sLocation != null and sLocation != ''">
101
+            AND A.location = #{sLocation}
102
+        </if>
103
+        <if test="sItemId != null and sItemId != ''">
104
+            AND A.item_id = #{sItemId}
105
+        </if>
106
+        <if test="sItemNm != null and sItemNm != ''">
107
+            AND A.item_nm LIKE CONCAT('%',#{sItemNm},'%')
108
+        </if>
109
+    </select>
110
+
111
+    <select id="selectStckMgntBaseInfo" resultType="com.oqpo.api.entity.stockmng.StckMgntBaseInfoEntity">
112
+        /* StockMngMapper.selectStckMgntBaseInfo */
113
+        SELECT A.brand_id, A.whs_id, A.location, A.item_id, A.unit, A.stck_qty, A.prp_stck_qty, A.sft_stck_rt, A.cur_stck_rt,
114
+            DATE_FORMAT(A.sys_reg_dttm,'%Y.%m.%d %H:%i:%s') AS sys_reg_dttm, A.sys_reg_id, DATE_FORMAT(A.sys_chg_dttm,'%Y.%m.%d %H:%i:%s') AS sys_chg_dttm, A.sys_chg_id,
115
+            B.item_nm
116
+        FROM stck_mgnt_base_info A
117
+        LEFT JOIN item_base_info B ON A.item_id = B.item_id
118
+        WHERE A.brand_id = #{brandId}
119
+        AND A.whs_id = #{whsId}
120
+        AND A.location = #{location}
121
+        AND A.item_id = #{itemId}
122
+    </select>
123
+
124
+    <insert id="insertStckMgntBaseInfo" >
125
+        /* StockMngMapper.insertStckMgntBaseInfo */
126
+        INSERT INTO stck_mgnt_base_info
127
+            (brand_id, whs_id, location, item_id, unit, stck_qty, prp_stck_qty, sft_stck_rt, cur_stck_rt,
128
+             sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
129
+        VALUES
130
+            (#{entity.brandId}, #{entity.whsId}, #{entity.location}, #{entity.itemId}, #{entity.unit}, #{entity.stckQty},
131
+             #{entity.prpStckQty}, #{entity.sftStckRt}, #{entity.curStckRt},
132
+             NOW(), #{userId}, NOW(), #{userId})
133
+    </insert>
134
+
135
+    <update id="updateStckMgntBaseInfo4StckProc" >
136
+        /* StockMngMapper.updateStckMgntBaseInfo4StckProc */
137
+        UPDATE stck_mgnt_base_info SET
138
+            stck_qty = #{entity.stckQty},       /* 재고수량 */
139
+            cur_stck_rt = #{entity.curStckRt},  /* 현재고비율 */
140
+            sys_chg_dttm = NOW(),
141
+            sys_chg_id = #{userId}
142
+        WHERE brand_id = #{entity.brandId}
143
+        AND whs_id = #{entity.whsId}
144
+        AND location = #{entity.location}
145
+        AND item_id = #{entity.itemId}
146
+    </update>
147
+
148
+    <update id="updateStckMgntBaseInfo4BaseChg" >
149
+        /* StockMngMapper.updateStckMgntBaseInfo4BaseChg */
150
+        UPDATE stck_mgnt_base_info SET
151
+            prp_stck_qty = #{entity.prpStckQty},    /* 적정재고수량 */
152
+            sft_stck_rt = #{entity.sftStckRt},      /* 안전재고비율 */
153
+            sys_chg_dttm = NOW(),
154
+            sys_chg_id = #{userId}
155
+        WHERE brand_id = #{entity.brandId}
156
+        AND whs_id = #{entity.whsId}
157
+        AND location = #{entity.location}
158
+        AND item_id = #{entity.itemId}
159
+    </update>
160
+
161
+    <insert id="insertStckMgntDtlHist" >
162
+        /* StockMngMapper.insertStckMgntDtlHist */
163
+        INSERT INTO stck_mgnt_dtl_hist
164
+            (stck_mgnt_dtl_no, brand_id, whs_id, location, item_id, item_nm, inout_cd, inout_qty, whs_mgnt_unq_no,
165
+             rtn_mgnt_unq_no, chg_dvsn, sys_reg_dttm,
166
+             sys_reg_id, sys_chg_dttm, sys_chg_id)
167
+        VALUES
168
+            (#{entity.stckMgntDtlNo}, #{entity.brandId}, #{entity.whsId}, #{entity.location}, #{entity.itemId},
169
+             #{entity.itemNm}, #{entity.inoutCd}, #{entity.inoutQty}, #{entity.whsMgntUnqNo}, #{entity.rtnMgntUnqNo}, #{entity.chgDvsn},
170
+             NOW(), #{userId}, NOW(), #{userId})
171
+    </insert>
172
+
173
+    <select id="selectStockHistGridList" resultType="com.oqpo.api.entity.stockmng.StckMgntDtlHistEntity">
174
+        /* StockMngMapper.selectStockHistGridList */
175
+        SELECT A.stck_mgnt_dtl_no,
176
+            A.inout_cd, FN_CODE_NM('INOUT_CD', A.inout_cd) AS inout_nm, A.inout_qty,
177
+            IFNULL(A.whs_mgnt_unq_no, A.rtn_mgnt_unq_no) AS relation_no,    /* 관련번호 */
178
+            A.chg_dvsn, FN_CODE_NM('CHG_DVSN', A.chg_dvsn) AS chg_dvsn_nm, DATE_FORMAT(A.sys_reg_dttm,'%Y.%m.%d') AS sys_reg_dttm
179
+        FROM stck_mgnt_dtl_hist A
180
+        WHERE A.brand_id = #{sBrandId}
181
+        AND A.whs_id = #{sWhsId}
182
+        AND A.location = #{sLocation}
183
+        AND A.item_id = #{sItemId}
184
+        <if test="sInoutCd != null and sInoutCd != ''">
185
+            AND A.inout_cd = #{sInoutCd}
186
+        </if>
187
+        <if test="fromDt != null and fromDt != '' and toDt != null and toDt != '' ">
188
+            AND A.sys_reg_dttm BETWEEN STR_TO_DATE(CONCAT(#{fromDt},'000000'),'%Y%m%d%H%i%S') AND STR_TO_DATE(CONCAT(#{toDt},'000000'),'%Y%m%d%H%i%S')
189
+        </if>
190
+        <choose>
191
+            <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
192
+                <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
193
+                    <if test="gridRequest.sord == 'asc'.toString()">
194
+                        ORDER BY A.stck_mgnt_dtl_no ASC
195
+                    </if>
196
+                    <if test="gridRequest.sord == 'desc'.toString()">
197
+                        ORDER BY A.stck_mgnt_dtl_no DESC
198
+                    </if>
199
+                </if>
200
+            </when>
201
+            <otherwise>
202
+                ORDER BY A.stck_mgnt_dtl_no ASC
203
+            </otherwise>
204
+        </choose>
205
+        <if test="gridRequest.pagingYn == true">
206
+            limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
207
+        </if>
208
+    </select>
209
+
210
+    <select id="selectStockHistGridCnt" resultType="int">
211
+        /* StockMngMapper.selectStockHistGridCnt */
212
+        SELECT COUNT(*)
213
+        FROM stck_mgnt_dtl_hist A
214
+        WHERE A.brand_id = #{sBrandId}
215
+        AND A.whs_id = #{sWhsId}
216
+        AND A.location = #{sLocation}
217
+        AND A.item_id = #{sItemId}
218
+        <if test="sInoutCd != null and sInoutCd != ''">
219
+            AND A.inout_cd = #{sInoutCd}
220
+        </if>
221
+        <if test="fromDt != null and fromDt != '' and toDt != null and toDt != '' ">
222
+            AND A.sys_reg_dttm BETWEEN STR_TO_DATE(CONCAT(#{fromDt},'000000'),'%Y%m%d%H%i%S') AND STR_TO_DATE(CONCAT(#{toDt},'000000'),'%Y%m%d%H%i%S')
223
+        </if>
224
+    </select>
225
+
226
+</mapper>