Pārlūkot izejas kodu

반품구매요청

dwkim 2 gadi atpakaļ
vecāks
revīzija
d1545b4ad9

+ 43 - 0
src/main/java/com/oqpo/api/entity/rtnmng/RtnReqBaseInfoEntity.java

@@ -0,0 +1,43 @@
1
+package com.oqpo.api.entity.rtnmng;
2
+
3
+import io.swagger.annotations.ApiModelProperty;
4
+import lombok.Getter;
5
+import lombok.Setter;
6
+import lombok.ToString;
7
+
8
+import java.io.Serializable;
9
+
10
+@Getter
11
+@Setter
12
+@ToString
13
+public class RtnReqBaseInfoEntity implements Serializable {
14
+
15
+    @ApiModelProperty(value = "반품요청고유번호") private String rtnReqUnqNo;
16
+    @ApiModelProperty(value = "매장아이디") private String storeId;
17
+    @ApiModelProperty(value = "브랜드아이디") private String brandId;
18
+    @ApiModelProperty(value = "반품요청일자") private String rtnReqDt;
19
+    @ApiModelProperty(value = "반품요청시각") private String rtnReqTm;
20
+    @ApiModelProperty(value = "반품요청상태코드") private String rtnReqStCd;
21
+    @ApiModelProperty(value = "반품요청담당자아이디") private String rtnReqMgrId;
22
+    @ApiModelProperty(value = "반품요청담당자명") private String rtnReqMgrNm;
23
+    @ApiModelProperty(value = "반품요청담당자이메일") private String rtnReqMgrEmal;
24
+    @ApiModelProperty(value = "반품요청담당자전화번호") private String rtnReqMgrTelNo;
25
+    @ApiModelProperty(value = "반품요청담당자휴대전화번호") private String rtnReqMgrMblNo;
26
+    @ApiModelProperty(value = "창고구분") private String whsDvsn;
27
+    @ApiModelProperty(value = "수거요청일자") private String colReqDt;
28
+    @ApiModelProperty(value = "비고") private String note;
29
+    @ApiModelProperty(value = "반품반려일자") private String rtnRjctDt;
30
+    @ApiModelProperty(value = "반품반려자명") private String rtnRjctNm;
31
+    @ApiModelProperty(value = "반품반려자아이디") private String rtnRjctId;
32
+    @ApiModelProperty(value = "반품반려사유") private String rtnRjctRsn;
33
+    @ApiModelProperty(value = "반품요청금액") private Long rtnReqAmt;
34
+    @ApiModelProperty(value = "반품요청품목수") private Integer rtnReqItemQty;
35
+    @ApiModelProperty(value = "반품창고아이디") private String rtnWhsId;
36
+    @ApiModelProperty(value = "반품LOCATION") private String rtnLocation;
37
+    @ApiModelProperty(value = "시스템등록일시") private String sysRegDttm;
38
+    @ApiModelProperty(value = "시스템등록아이디") private String sysRegId;
39
+    @ApiModelProperty(value = "시스템변경일시") private String sysChgDttm;
40
+    @ApiModelProperty(value = "시스템변경아이디") private String sysChgId;
41
+
42
+
43
+}

+ 38 - 0
src/main/java/com/oqpo/api/entity/rtnmng/RtnReqDtlPtclEntity.java

@@ -0,0 +1,38 @@
1
+package com.oqpo.api.entity.rtnmng;
2
+
3
+import io.swagger.annotations.ApiModelProperty;
4
+import lombok.Getter;
5
+import lombok.Setter;
6
+import lombok.ToString;
7
+
8
+import java.io.Serializable;
9
+
10
+@Getter
11
+@Setter
12
+@ToString
13
+public class RtnReqDtlPtclEntity implements Serializable {
14
+
15
+    @ApiModelProperty(value = "반품요청고유번호") private String rtnReqUnqNo;
16
+    @ApiModelProperty(value = "반품요청상세번호") private String rtnReqDtlNo;
17
+    @ApiModelProperty(value = "품목아이디") private String itemId;
18
+    @ApiModelProperty(value = "품목명") private String itemNm;
19
+    @ApiModelProperty(value = "단위") private String unit;
20
+    @ApiModelProperty(value = "반품수량") private Integer rtnQty;
21
+    @ApiModelProperty(value = "반품금액") private Long rtnAmt;
22
+    @ApiModelProperty(value = "반품구분") private String rtnDvsn;
23
+    @ApiModelProperty(value = "반품사유") private String rtnRsn;
24
+    @ApiModelProperty(value = "공급사아이디") private String spplyId;
25
+    @ApiModelProperty(value = "단가금액") private Long unitAmt;
26
+    @ApiModelProperty(value = "매장단가고유번호") private String storeUnitUnqNo;
27
+    @ApiModelProperty(value = "반품예상금액") private Long rtnExpctAmt;
28
+    @ApiModelProperty(value = "반품사유구분") private String rtnRsnDvsn;
29
+    @ApiModelProperty(value = "시스템등록일시") private String sysRegDttm;
30
+    @ApiModelProperty(value = "시스템등록아이디") private String sysRegId;
31
+    @ApiModelProperty(value = "시스템변경일시") private String sysChgDttm;
32
+    @ApiModelProperty(value = "시스템변경아이디") private String sysChgId;
33
+    @ApiModelProperty(value = "브랜드단가고유번호") private String brandUnitUnqNo;
34
+    @ApiModelProperty(value = "단가구분") private String unitGubun;
35
+
36
+
37
+
38
+}

+ 58 - 0
src/main/java/com/oqpo/api/mapper/rtnmng/RtnReqMapper.java

@@ -0,0 +1,58 @@
1
+package com.oqpo.api.mapper.rtnmng;
2
+
3
+
4
+import com.oqpo.api.entity.pomng.PchReqBaseInfoEntity;
5
+import com.oqpo.api.entity.pomng.PchReqDtlPtclEntity;
6
+import com.oqpo.api.entity.rtnmng.RtnReqBaseInfoEntity;
7
+import com.oqpo.api.entity.rtnmng.RtnReqDtlPtclEntity;
8
+import com.oqpo.api.web.dto.request.GridRequest;
9
+import org.apache.ibatis.annotations.Mapper;
10
+import org.apache.ibatis.annotations.Param;
11
+
12
+import java.util.List;
13
+
14
+@Mapper
15
+public interface RtnReqMapper {
16
+
17
+
18
+    int insertRtnReqBaseInfo(@Param("userId") String userId,  RtnReqBaseInfoEntity entity) throws Exception;
19
+    int updateRtnReqBaseInfo(@Param("userId") String userId,  RtnReqBaseInfoEntity entity) throws Exception;
20
+    int insertRtnReqDtlPtcl(@Param("userId") String userId, List<RtnReqDtlPtclEntity> gridInsertData) throws Exception;
21
+    int updateRtnReqDtlPtcl(@Param("userId") String userId, List<RtnReqDtlPtclEntity> gridUpdateData) throws Exception;
22
+    int deleteRtnReqDtlPtcl(@Param("rtnReqUnqNo") String rtnReqUnqNo, List<RtnReqDtlPtclEntity> gridDeleteData) throws Exception;
23
+    int selectMaxRtnReqDtlNo(@Param("rtnReqUnqNo") String rtnReqUnqNo) throws Exception;
24
+    RtnReqBaseInfoEntity selectSumRtnAmt(@Param("rtnReqUnqNo") String rtnReqUnqNo) throws Exception;
25
+
26
+/*
27
+    List<PchReqBaseInfoEntity> selectPchReqGridList(@Param("sBrandId") String sBrandId, @Param("sStoreId") String sStoreId, @Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("sWhsId") String sWhsId, @Param("sPchReqStCd") String sPchReqStCd, @Param("sItemNm") String sItemNm, GridRequest gridRequest)throws Exception;
28
+    int selectPchReqGridCnt(@Param("sBrandId") String sBrandId, @Param("sStoreId") String sStoreId, @Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("sWhsId") String sWhsId, @Param("sPchReqStCd") String sPchReqStCd, @Param("sItemNm") String sItemNm)throws Exception;
29
+
30
+    PchReqBaseInfoEntity selectPchReqInfo(@Param("brandId") String brandId, @Param("pchReqUnqNo") String pchReqUnqNo)throws Exception;
31
+    List<PchReqDtlPtclEntity> selectPchReqDtlPtcl(@Param("brandId") String brandId, @Param("pchReqUnqNo") String pchReqUnqNo)throws Exception;
32
+
33
+
34
+    int insertPchReqBaseInfo(@Param("userId") String userId, @Param("userNm") String userNm, PchReqBaseInfoEntity entity) throws Exception;
35
+
36
+    int updateOrdPchReqBaseInfo(@Param("userId") String userId, @Param("userNm") String userNm, PchReqBaseInfoEntity entity) throws Exception;
37
+
38
+    int insertPchReqDtlPtcl(@Param("userId") String userId, List<PchReqDtlPtclEntity> gridInsertData) throws Exception;
39
+
40
+    int updateRejPchReqBaseInfo(@Param("userId") String userId, @Param("pchReqUnqNo") String pchReqUnqNo, @Param("pchReqRjctNm") String pchReqRjctNm, @Param("pchReqRjctRsn") String pchReqRjctRsn) throws Exception;
41
+
42
+    int updatePchReqDtlPtcl(@Param("userId") String userId, @Param("pchReqUnqNo") String pchReqUnqNo, List<PchReqDtlPtclEntity> gridUpdateData) throws Exception;
43
+
44
+    int deletePchReqDtlPtcl(@Param("pchReqUnqNo") String pchReqUnqNo, List<PchReqDtlPtclEntity> gridDeleteData) throws Exception;
45
+
46
+    int selectMaxPchReqDtlNo(@Param("pchReqUnqNo") String pchReqUnqNo) throws Exception;
47
+
48
+    PchReqBaseInfoEntity selectSumReqAmt(@Param("pchReqUnqNo") String pchReqUnqNo) throws Exception;
49
+
50
+    List<PchReqBaseInfoEntity> selectPchReqPoTargetGridList(@Param("sBrandId") String sBrandId, @Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("sSpplyId") String sSpplyId, @Param("sWhsId") String sWhsId, @Param("sItemNm") String sItemNm, GridRequest gridRequest)throws Exception;
51
+    int selectPchReqPoTargetGridCnt(@Param("sBrandId") String sBrandId, @Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("sSpplyId") String sSpplyId, @Param("sWhsId") String sWhsId, @Param("sItemNm") String sItemNm)throws Exception;
52
+
53
+    List<PchReqDtlPtclEntity> selectPchRejectPrTargetList(@Param("pchReqUnqNo") String pchReqUnqNo) ;
54
+
55
+    int updatePchReqStCd(@Param("userId") String userId, List<PchReqBaseInfoEntity> gridUpdateData) throws Exception;
56
+
57
+    */
58
+}

+ 167 - 0
src/main/java/com/oqpo/api/service/rtnmng/RtnReqService.java

@@ -0,0 +1,167 @@
1
+package com.oqpo.api.service.rtnmng;
2
+
3
+
4
+import com.oqpo.api.entity.loanmng.LoanMgntBaseInfoEntity;
5
+import com.oqpo.api.entity.oper.UserMngEntity;
6
+import com.oqpo.api.entity.pomng.PchReqBaseInfoEntity;
7
+import com.oqpo.api.entity.pomng.PchReqDtlPtclEntity;
8
+import com.oqpo.api.entity.rtnmng.RtnReqBaseInfoEntity;
9
+import com.oqpo.api.entity.rtnmng.RtnReqDtlPtclEntity;
10
+import com.oqpo.api.entity.stinfo.BrandEntity;
11
+import com.oqpo.api.entity.stockmng.WhsMgntBaseInfoEntity;
12
+import com.oqpo.api.enums.SystemMessageCode;
13
+import com.oqpo.api.exception.GlobalException;
14
+import com.oqpo.api.mapper.loanmng.LoanStateMapper;
15
+import com.oqpo.api.mapper.oper.UserMngMapper;
16
+import com.oqpo.api.mapper.pomng.PchReqMapper;
17
+import com.oqpo.api.mapper.rtnmng.RtnReqMapper;
18
+import com.oqpo.api.mapper.stinfo.BrandMapper;
19
+import com.oqpo.api.mapper.stockmng.WhsMngMapper;
20
+import com.oqpo.api.service.CommonService;
21
+import com.oqpo.api.util.DateUtil;
22
+import com.oqpo.api.web.dto.request.GridRequest;
23
+import com.oqpo.api.web.dto.request.pomng.pchReq.PchReqInitInfoRequest;
24
+import com.oqpo.api.web.dto.request.pomng.pchReq.SavePchReqlRequest;
25
+import com.oqpo.api.web.dto.request.rtnmng.SaveRtnReqlRequest;
26
+import com.oqpo.api.web.dto.response.GridResponse;
27
+import com.oqpo.api.web.dto.response.pomng.pchReq.*;
28
+import com.oqpo.api.web.dto.response.rtnmng.rtnReq.RtnReqInitInfoResponse;
29
+import lombok.extern.slf4j.Slf4j;
30
+import org.springframework.beans.factory.annotation.Autowired;
31
+import org.springframework.stereotype.Service;
32
+import org.springframework.transaction.annotation.Transactional;
33
+
34
+import java.util.ArrayList;
35
+import java.util.List;
36
+import java.util.stream.Collectors;
37
+
38
+@Service
39
+@Slf4j
40
+public class RtnReqService extends CommonService {
41
+    @Autowired
42
+    private RtnReqMapper rtnReqMapper;
43
+
44
+    @Autowired
45
+    private UserMngMapper userMngMapper;
46
+
47
+    @Autowired
48
+    private BrandMapper brandMapper;
49
+
50
+    @Autowired
51
+    private WhsMngMapper whsMngMapper;
52
+
53
+    /* 반품요청  초기 정보 */
54
+
55
+    public RtnReqInitInfoResponse selectRtnReqInitInfo(String userId, PchReqInitInfoRequest pchReqInitInfoRequest) throws Exception {
56
+
57
+        UserMngEntity uEntity = userMngMapper.selectGroupUserInfo(userId);
58
+        BrandEntity brandEntity = new BrandEntity();
59
+        List<WhsMgntBaseInfoEntity> whsMgntList = new ArrayList<WhsMgntBaseInfoEntity>();
60
+        WhsMgntBaseInfoEntity whsEntity = new WhsMgntBaseInfoEntity();
61
+
62
+        if ("30".equals(uEntity.getAuthTpCd())) {   // 가맹점
63
+            // 브랜드 정보 request 로 받아서 브랜드정보 가져와 넣어줌
64
+            brandEntity = brandMapper.selectBrandNmInfo(pchReqInitInfoRequest.getBrandId());
65
+            uEntity.setBrandId(pchReqInitInfoRequest.getBrandId());
66
+            uEntity.setBrandNm(brandEntity.getBrandNm());
67
+
68
+        } else if ("40".equals(uEntity.getAuthTpCd())) {  // 브랜드
69
+            // 무시
70
+        } else if ("50".equals(uEntity.getAuthTpCd())) {  // 매장
71
+            //납품창고 정보 가져오기  selectStoreWhsLocList
72
+            whsMgntList = whsMngMapper.selectStoreWhsLocList(pchReqInitInfoRequest.getBrandId(), pchReqInitInfoRequest.getStoreId());
73
+
74
+            if (whsMgntList.size() == 1) {
75
+                whsEntity = whsMgntList.get(0);
76
+            }
77
+
78
+        } else {
79
+            // 브랜드 정보 request 로 받아서 브랜드정보 가져와 넣어줌
80
+            brandEntity = brandMapper.selectBrandNmInfo(pchReqInitInfoRequest.getBrandId());
81
+            uEntity.setBrandId(pchReqInitInfoRequest.getBrandId());
82
+            uEntity.setBrandNm(brandEntity.getBrandNm());
83
+        }
84
+
85
+        return RtnReqInitInfoResponse.toDTO(uEntity,whsEntity);
86
+
87
+    }
88
+
89
+    /* 반품요청 저장 */
90
+    @Transactional
91
+    public void saveRtnReqInfo(String userId, SaveRtnReqlRequest saveRtnReqlRequest) throws Exception {
92
+        try {
93
+
94
+            // 로그인자 권한이 50 이면 매장 아이디 필수로 넘어와야함
95
+            UserMngEntity uEntity = userMngMapper.selectGroupUserInfo(userId);
96
+            String userNm = uEntity.getUserNm();
97
+
98
+            RtnReqBaseInfoEntity entity = new RtnReqBaseInfoEntity();
99
+
100
+            String rtnReqUnqNo = "";
101
+            if ("C".toString().equals(saveRtnReqlRequest.getViewCd())) {
102
+                // 신규번호 생성
103
+                entity.setRtnReqUnqNo(fnGetDealNo(18,""));
104
+            } else {
105
+                entity.setRtnReqUnqNo(saveRtnReqlRequest.getRtnReqUnqNo());
106
+            }
107
+
108
+            entity.setBrandId(saveRtnReqlRequest.getBrandId());
109
+            entity.setStoreId(saveRtnReqlRequest.getStoreId());
110
+            entity.setRtnReqStCd(saveRtnReqlRequest.getRtnReqStCd());
111
+            entity.setNote(saveRtnReqlRequest.getNote());
112
+            entity.setColReqDt(saveRtnReqlRequest.getColReqDt().replaceAll("\\.",""));
113
+            entity.setRtnWhsId(saveRtnReqlRequest.getRtnWhsId());
114
+            entity.setRtnLocation(saveRtnReqlRequest.getRtnLocation());
115
+            entity.setRtnReqMgrNm(userNm);
116
+            entity.setRtnReqMgrTelNo(uEntity.getTelNo());
117
+            entity.setWhsDvsn(saveRtnReqlRequest.getWhsDvsn());
118
+
119
+
120
+
121
+            // 품목 삭제 처리
122
+            List<RtnReqDtlPtclEntity> gridDeleteData = saveRtnReqlRequest.toCodeEntities(saveRtnReqlRequest.getGridDeleteData());
123
+            if (gridDeleteData.size() > 0) {
124
+                rtnReqMapper.deleteRtnReqDtlPtcl(entity.getRtnReqUnqNo(), gridDeleteData) ;
125
+            }
126
+
127
+            // 품목 수정 처리
128
+            List<RtnReqDtlPtclEntity> gridUpdateData = saveRtnReqlRequest.toCodeEntities(saveRtnReqlRequest.getGridUpdateData());
129
+            if (gridUpdateData.size() > 0) {
130
+                rtnReqMapper.updateRtnReqDtlPtcl(userId,  gridUpdateData) ;
131
+            }
132
+
133
+            // 품목 등록 처리
134
+            List<RtnReqDtlPtclEntity> gridInsertData = saveRtnReqlRequest.toCodeEntities(saveRtnReqlRequest.getGridInsertData());
135
+            if (gridInsertData.size() > 0) {
136
+
137
+                int maxDtlNo = rtnReqMapper.selectMaxRtnReqDtlNo(entity.getRtnReqUnqNo());
138
+
139
+                for (int i = 0 ; i < gridInsertData.size() ; i++) {
140
+                    maxDtlNo = maxDtlNo + 10 ;
141
+                    gridInsertData.get(i).setRtnReqUnqNo(entity.getRtnReqUnqNo());
142
+                    gridInsertData.get(i).setRtnReqDtlNo( Integer.toString(maxDtlNo));
143
+                }
144
+
145
+                rtnReqMapper.insertRtnReqDtlPtcl(userId, gridInsertData) ;
146
+            }
147
+
148
+            RtnReqBaseInfoEntity sumData = rtnReqMapper.selectSumRtnAmt(entity.getRtnReqUnqNo());
149
+            entity.setRtnReqAmt(sumData.getRtnReqAmt());
150
+            entity.setRtnReqItemQty(sumData.getRtnReqItemQty());
151
+
152
+            if ("C".toString().equals(saveRtnReqlRequest.getViewCd())) {
153
+                rtnReqMapper.insertRtnReqBaseInfo(userId, entity);
154
+            } else {
155
+                rtnReqMapper.updateRtnReqBaseInfo(userId, entity);
156
+            }
157
+
158
+        } catch (GlobalException e) {
159
+            e.getStackTrace();
160
+            throw new GlobalException(e.getSystemMessageCode());
161
+        } catch (Exception e) {
162
+            e.getStackTrace();
163
+            throw new RuntimeException();
164
+        }
165
+    }
166
+
167
+}

+ 79 - 0
src/main/java/com/oqpo/api/web/controller/rtnmng/RtnReqController.java

@@ -0,0 +1,79 @@
1
+package com.oqpo.api.web.controller.rtnmng;
2
+
3
+import com.oqpo.api.enums.SystemMessageCode;
4
+import com.oqpo.api.service.pomng.PchReqService;
5
+import com.oqpo.api.service.rtnmng.RtnReqService;
6
+import com.oqpo.api.web.dto.request.pomng.pchReq.PchReqInitInfoRequest;
7
+import com.oqpo.api.web.dto.request.pomng.pchReq.PchReqPoTargetSearchGridRequest;
8
+import com.oqpo.api.web.dto.request.pomng.pchReq.PchReqSearchGridRequest;
9
+import com.oqpo.api.web.dto.request.pomng.pchReq.SavePchReqlRequest;
10
+import com.oqpo.api.web.dto.request.rtnmng.SaveRtnReqlRequest;
11
+import com.oqpo.api.web.dto.response.GridResponse;
12
+import com.oqpo.api.web.dto.response.SaveResponse;
13
+import com.oqpo.api.web.dto.response.pomng.pchReq.PchReqInfoResponse;
14
+import com.oqpo.api.web.dto.response.pomng.pchReq.PchReqInitInfoResponse;
15
+import com.oqpo.api.web.dto.response.pomng.pchReq.PchReqRejectTargetResponse;
16
+import com.oqpo.api.web.dto.response.rtnmng.rtnReq.RtnReqInitInfoResponse;
17
+import io.swagger.annotations.Api;
18
+import io.swagger.annotations.ApiImplicitParam;
19
+import io.swagger.annotations.ApiImplicitParams;
20
+import io.swagger.annotations.ApiOperation;
21
+import lombok.extern.slf4j.Slf4j;
22
+import org.springframework.beans.factory.annotation.Autowired;
23
+import org.springframework.http.ResponseEntity;
24
+import org.springframework.web.bind.annotation.*;
25
+import springfox.documentation.annotations.ApiIgnore;
26
+
27
+import javax.validation.Valid;
28
+
29
+@Slf4j
30
+@RestController
31
+@RequestMapping("/api/rtnmng")
32
+@Api(tags = {"반품요청 관리 (RtnReqController) -- 진행중"})
33
+public class RtnReqController {
34
+    @Autowired
35
+    private RtnReqService rtnReqService;
36
+
37
+
38
+    /**
39
+     * 설명 : 반품요청 초기 정보
40
+     *
41
+     * @param userId
42
+     * @return
43
+     * @throws Exception
44
+     */
45
+    @ApiImplicitParams({
46
+            @ApiImplicitParam(name = "X-AUTH-TOKEN", value = "CONN-KEY", required = true, dataType = "String", paramType = "header")
47
+    })
48
+    @ApiOperation(value = "반품요청 초기 정보")
49
+    @GetMapping("/init-rtnReq")
50
+    public ResponseEntity<RtnReqInitInfoResponse> selectRtnReqInitInfo(@ApiIgnore String userId, PchReqInitInfoRequest pchReqInitInfoRequest) throws Exception {
51
+        return ResponseEntity.ok(rtnReqService.selectRtnReqInitInfo(userId, pchReqInitInfoRequest));
52
+    }
53
+
54
+
55
+    /**
56
+     * 설명 : 반품요청 정보 저장
57
+     *
58
+     * @param userId
59
+     * @param SaveRtnReqlRequest
60
+     * @return SaveResponse
61
+     * @throws Exception
62
+     */
63
+    @ApiImplicitParams({
64
+            @ApiImplicitParam(name = "X-AUTH-TOKEN", value = "CONN-KEY", required = true, dataType = "String", paramType = "header")
65
+    })
66
+    @ApiOperation(value = "반품요청 정보 저장")
67
+    @PostMapping("/save-rtnReq")
68
+    public ResponseEntity<SaveResponse> savePchReq(@ApiIgnore String userId, @RequestBody @Valid SaveRtnReqlRequest saveRtnReqlRequest) throws Exception {
69
+        rtnReqService.saveRtnReqInfo(userId,  saveRtnReqlRequest);
70
+
71
+        if ("RR00".equals(saveRtnReqlRequest.getRtnReqStCd())) {
72
+            return ResponseEntity.ok(SaveResponse.toDTO(SystemMessageCode.SAVE_OK));
73
+        } else {
74
+            return ResponseEntity.ok(SaveResponse.toDTO(SystemMessageCode.REQ_OK));
75
+        }
76
+
77
+    }
78
+
79
+}

+ 145 - 0
src/main/java/com/oqpo/api/web/dto/request/rtnmng/SaveRtnReqlRequest.java

@@ -0,0 +1,145 @@
1
+package com.oqpo.api.web.dto.request.rtnmng;
2
+
3
+import com.oqpo.api.entity.pomng.PchReqDtlPtclEntity;
4
+import com.oqpo.api.entity.rtnmng.RtnReqDtlPtclEntity;
5
+import io.swagger.annotations.ApiModelProperty;
6
+import lombok.*;
7
+
8
+import javax.validation.constraints.NotBlank;
9
+import java.util.ArrayList;
10
+import java.util.List;
11
+
12
+@Getter
13
+@Setter
14
+public class SaveRtnReqlRequest {
15
+    @NotBlank
16
+    @ApiModelProperty(value = "CRUD")
17
+    private String viewCd;
18
+
19
+    @ApiModelProperty(value = "반품요청고유번호")
20
+    private String rtnReqUnqNo;
21
+
22
+    @NotBlank
23
+    @NotBlank @ApiModelProperty(value = "브랜드아이디")
24
+    private String brandId;
25
+
26
+    @ApiModelProperty(value = "매장아이디")
27
+    private String storeId;
28
+
29
+    @ApiModelProperty(value = "구매요청상태")
30
+    private String rtnReqStCd;  // RR00  임시저장, RR20 구매요청
31
+
32
+    @ApiModelProperty(value = "비고")
33
+    private String note;
34
+
35
+    @NotBlank
36
+    @ApiModelProperty(value = "수거요청일")
37
+    private String colReqDt ;
38
+
39
+    @ApiModelProperty(value = "반품 창고구분")
40
+    private String whsDvsn;
41
+
42
+    @NotBlank
43
+    @ApiModelProperty(value = "반품 창고아이디")
44
+    private String rtnWhsId;
45
+
46
+    @NotBlank
47
+    @ApiModelProperty(value = "반품 창고상세위치정보")
48
+    private String rtnLocation;
49
+
50
+
51
+    @ApiModelProperty(value = "등록 품목리스트")
52
+    private List<SaveRtnReqlRequest.SaveRtnItemList> gridInsertData;
53
+
54
+    @ApiModelProperty(value = "수정 품목리스트")
55
+    private List<SaveRtnReqlRequest.SaveRtnItemList> gridUpdateData;
56
+
57
+    @ApiModelProperty(value = "삭제 품목리스트")
58
+    private List<SaveRtnReqlRequest.SaveRtnItemList> gridDeleteData;
59
+
60
+
61
+    public List<RtnReqDtlPtclEntity> toCodeEntities(List<SaveRtnReqlRequest.SaveRtnItemList> gridData) {
62
+        List<RtnReqDtlPtclEntity> entities = new ArrayList<>();
63
+        if (gridData == null || gridData.size() == 0)
64
+            return entities;
65
+
66
+        gridData.forEach(x -> {
67
+            RtnReqDtlPtclEntity entity = new RtnReqDtlPtclEntity();
68
+            entity.setRtnReqUnqNo(x.getRtnReqUnqNo());
69
+            entity.setRtnReqDtlNo(x.getRtnReqDtlNo());
70
+            entity.setItemId(x.getItemId());
71
+            entity.setItemNm(x.getItemNm());
72
+            entity.setUnit(x.getUnit());
73
+            entity.setRtnQty(x.getRtnQty());
74
+            entity.setRtnAmt(x.getRtnAmt());
75
+            entity.setUnitAmt(x.getUnitAmt());
76
+            entity.setRtnDvsn(x.getRtnDvsn());
77
+            entity.setRtnRsn(x.getRtnRsn());
78
+            entity.setRtnRsnDvsn(x.getRtnRsnDvsn());
79
+            entity.setSpplyId(x.getSpplyId());
80
+            entity.setBrandUnitUnqNo(x.getBrandUnitUnqNo());
81
+            entity.setStoreUnitUnqNo(x.getStoreUnitUnqNo());
82
+            entity.setUnitGubun(x.getUnitGubun());
83
+            entities.add(entity);
84
+        });
85
+        return entities;
86
+    }
87
+
88
+    @Getter
89
+    @Builder
90
+    @AllArgsConstructor(access = AccessLevel.PROTECTED)
91
+    static class SaveRtnItemList {
92
+
93
+        @ApiModelProperty(value = "반품요청번호")
94
+        private String rtnReqUnqNo;
95
+
96
+        @ApiModelProperty(value = "반품품청상세번호")
97
+        private String rtnReqDtlNo;
98
+
99
+        @NotBlank
100
+        @ApiModelProperty(value = "품목아이디")
101
+        private String itemId;
102
+
103
+        @NotBlank
104
+        @ApiModelProperty(value = "품목명")
105
+        private String itemNm;
106
+
107
+        @NotBlank
108
+        @ApiModelProperty(value = "단위")
109
+        private String unit;
110
+
111
+        @NotBlank
112
+        @ApiModelProperty(value = "반품요청수량")
113
+        private Integer rtnQty;
114
+
115
+        @NotBlank
116
+        @ApiModelProperty(value = "반품요청금액")
117
+        private Long rtnAmt;
118
+
119
+        @NotBlank
120
+        @ApiModelProperty(value = "단가")
121
+        private Long unitAmt;
122
+
123
+        @NotBlank
124
+        @ApiModelProperty(value = "반품구분")
125
+        private String rtnDvsn;
126
+
127
+        @ApiModelProperty(value = "반품사유")
128
+        private String rtnRsn;
129
+
130
+        @ApiModelProperty(value = "반품사유구분")
131
+        private String rtnRsnDvsn;
132
+
133
+        @ApiModelProperty(value = "공급사아이디")
134
+        private String spplyId;
135
+
136
+        @ApiModelProperty(value = "브랜드단가고유번호")
137
+        private String brandUnitUnqNo;
138
+
139
+        @ApiModelProperty(value = "매장단가고유번호")
140
+        private String storeUnitUnqNo;
141
+
142
+        @ApiModelProperty(value = "단가구분")
143
+        private String unitGubun;
144
+    }
145
+}

+ 50 - 0
src/main/java/com/oqpo/api/web/dto/response/rtnmng/rtnReq/RtnReqInitInfoResponse.java

@@ -0,0 +1,50 @@
1
+package com.oqpo.api.web.dto.response.rtnmng.rtnReq;
2
+
3
+import com.fasterxml.jackson.annotation.JsonInclude;
4
+import com.oqpo.api.entity.loanmng.LoanMgntBaseInfoEntity;
5
+import com.oqpo.api.entity.oper.UserMngEntity;
6
+import com.oqpo.api.entity.stockmng.WhsMgntBaseInfoEntity;
7
+import io.swagger.annotations.ApiModelProperty;
8
+import lombok.*;
9
+
10
+
11
+@Getter
12
+@Setter
13
+@Builder
14
+@AllArgsConstructor(access = AccessLevel.PROTECTED)
15
+@JsonInclude(JsonInclude.Include.ALWAYS)
16
+public class RtnReqInitInfoResponse {
17
+
18
+    @ApiModelProperty(value = "로그인 소속 브랜드아이디") private String brandId;
19
+    @ApiModelProperty(value = "로그인 소속 브랜드명") private String brandNm;
20
+    @ApiModelProperty(value = "로그인 소속 매장아이디") private String storeId;
21
+    @ApiModelProperty(value = "로그인 소속 매장명") private String storeNm;
22
+    @ApiModelProperty(value = "소속") private String reqDept;
23
+    @ApiModelProperty(value = "사용자명") private String userNm;
24
+    @ApiModelProperty(value = "권한타입코드") private String authTpCd;
25
+    @ApiModelProperty(value = "창고구분") private String whsDvsn;
26
+    @ApiModelProperty(value = "창고아이디") private String whsId;
27
+    @ApiModelProperty(value = "창고명") private String whsNm;
28
+    @ApiModelProperty(value = "location") private String location;
29
+    @ApiModelProperty(value = "location명") private String locationNm;
30
+
31
+
32
+    public static RtnReqInitInfoResponse toDTO(UserMngEntity uEntity,  WhsMgntBaseInfoEntity whsEntity) {
33
+        if (uEntity == null) return null;
34
+        return RtnReqInitInfoResponse.builder()
35
+                .brandId(uEntity.getBrandId() == null ? "" :uEntity.getBrandId())
36
+                .brandNm(uEntity.getBrandNm() == null ? "" :uEntity.getBrandNm())
37
+                .storeId(uEntity.getStoreId() == null ? "" :uEntity.getStoreId())
38
+                .storeNm(uEntity.getStoreNm() == null ? "" :uEntity.getStoreNm())
39
+                .reqDept(uEntity.getStoreId() == null ? "브랜드" : "매장")
40
+                .userNm(uEntity.getUserNm() == null ? "" : uEntity.getUserNm())
41
+                .authTpCd(uEntity.getAuthTpCd() == null ? "" : uEntity.getAuthTpCd())
42
+                .whsDvsn(uEntity.getStoreId() == null ? "W01" : "W02")
43
+                .whsId(whsEntity == null ? "" : whsEntity.getWhsId() == null ? "" : whsEntity.getWhsId())
44
+                .whsNm(whsEntity == null ? "" : whsEntity.getWhsNm() == null ? "" : whsEntity.getWhsNm())
45
+                .location(whsEntity == null ? "" : whsEntity.getLocationInfo() == null ? "" : whsEntity.getLocationInfo().getLocation() == null ? "" : whsEntity.getLocationInfo().getLocation())
46
+                .locationNm(whsEntity == null ? "" : whsEntity.getLocationInfo() == null ? "" : whsEntity.getLocationInfo().getLocationNm() == null ? "" : whsEntity.getLocationInfo().getLocationNm())
47
+                .build();
48
+    }
49
+
50
+}

+ 377 - 0
src/main/resources/mybatis/sqlmaps/rtnmng/RtnReq.xml

@@ -0,0 +1,377 @@
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.rtnmng.RtnReqMapper">
5
+
6
+    <insert id="insertRtnReqBaseInfo" >
7
+       INSERT INTO rtn_req_base_info  /* RtnReqMapper.insertRtnReqBaseInfo */
8
+        (rtn_req_unq_no, store_id, brand_id, rtn_req_dt, rtn_req_tm
9
+        , rtn_req_st_cd, rtn_req_mgr_id, rtn_req_mgr_nm,  rtn_req_mgr_tel_no
10
+        , whs_dvsn, col_req_dt, note, rtn_rjct_dt, rtn_rjct_nm
11
+        , rtn_rjct_id, rtn_rjct_rsn, rtn_req_amt, rtn_req_item_qty, rtn_whs_id, rtn_location
12
+        , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
13
+        VALUES
14
+        (#{entity.rtnReqUnqNo}, #{entity.storeId}, #{entity.brandId}, #{entity.rtnReqDt}, #{entity.rtnReqTm}
15
+        , #{entity.rtnReqStCd}, #{entity.rtnReqMgrId}, #{entity.rtnReqMgrNm}, #{entity.rtnReqMgrTelNo}
16
+        , #{entity.whsDvsn}, #{entity.colReqDt}, #{entity.note}, #{entity.rtnRjctDt}, #{entity.rtnRjctNm}
17
+        , #{entity.rtnRjctId}, #{entity.rtnRjctRsn}, #{entity.rtnReqAmt}, #{entity.rtnReqItemQty}, #{entity.rtnWhsId}, #{entity.rtnLocation}
18
+        , NOW(), #{userId}, NOW(), #{userId})
19
+
20
+    </insert>
21
+
22
+    <update id="updateRtnReqBaseInfo">
23
+        UPDATE rtn_req_base_info SET   /* RtnReqMapper.updateRtnReqBaseInfo */
24
+                rtn_req_dt = #{entity.rtnReqDt},
25
+                rtn_req_tm = #{entity.rtnReqTm},
26
+                rtn_req_st_cd = #{entity.rtnReqStCd},
27
+                whs_dvsn = #{entity.whsDvsn},
28
+                col_req_dt = #{entity.colReqDt},
29
+                note = #{entity.note},
30
+                rtn_req_amt = #{entity.rtnReqAmt},
31
+                rtn_req_item_qty = #{entity.rtnReqItemQty},
32
+                rtn_whs_id = #{entity.rtnWhsId},
33
+                rtn_location = #{entity.rtnLocation},
34
+                sys_chg_dttm = NOW(),
35
+                sys_chg_id = #{userId}
36
+        WHERE rtn_req_unq_no = #{entity.rtnReqUnqNo}
37
+        AND   brand_id = #{entity.brandId}
38
+    </update>
39
+
40
+
41
+    <insert id="insertRtnReqDtlPtcl" >
42
+        INSERT INTO rtn_req_dtl_ptcl  /* RtnReqMapper.insertRtnReqDtlPtcl */
43
+        (rtn_req_unq_no, rtn_req_dtl_no, item_id, item_nm, unit
44
+        , rtn_qty, rtn_amt, rtn_dvsn, rtn_rsn
45
+        , spply_id, unit_amt, store_unit_unq_no, brand_unit_unq_no, rtn_rsn_dvsn
46
+        , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
47
+        VALUES
48
+        <foreach collection="gridInsertData" item="item" separator=",">
49
+        (#{item.rtnReqUnqNo}, #{item.rtnReqDtlNo}, #{item.itemId}, #{item.itemNm}, #{item.unit}
50
+        , #{item.rtnQty}, #{item.rtnAmt}, #{item.rtnDvsn}, #{item.rtnRsn}
51
+        , #{item.spplyId}, #{item.unitAmt}, #{item.storeUnitUnqNo}, #{item.brandUnitUnqNo}, #{item.rtnRsnDvsn}
52
+        , NOW(), #{userId}, NOW(), #{userId})
53
+        </foreach>
54
+    </insert>
55
+
56
+    <update id="updateRtnReqDtlPtcl">
57
+        <foreach collection="gridUpdateData" item="item" separator=";">
58
+            UPDATE rtn_req_dtl_ptcl SET    /* RtnReqMapper.updateRtnReqDtlPtcl */
59
+                    rtn_qty = #{item.rtnQty},
60
+                    rtn_amt = #{item.rtnAmt},
61
+                    rtn_dvsn = #{item.rtnDvsn},
62
+                    rtn_rsn = #{item.rtnRsn},
63
+                    rtn_rsn_dvsn = #{item.rtnRsnDvsn},
64
+                    sys_chg_dttm = NOW(),
65
+                    sys_chg_id = #{userId}
66
+            WHERE rtn_req_unq_no = #{item.rtnReqUnqNo}
67
+            AND rtn_req_dtl_no  = #{item.rtnReqDtlNo}
68
+        </foreach>
69
+    </update>
70
+
71
+    <delete id="deleteRtnReqDtlPtcl">
72
+        DELETE FROM rtn_req_dtl_ptcl  /* RtnReqMapper.deleteRtnReqDtlPtcl */
73
+        WHERE rtn_req_unq_no = #{rtnReqUnqNo}
74
+        AND rtn_req_dtl_no in
75
+        <foreach collection="gridDeleteData" item="item" separator="," open="(" close=")">
76
+            #{item.rtnReqDtlNo}
77
+        </foreach>
78
+    </delete>
79
+
80
+    <select id="selectMaxRtnReqDtlNo" resultType="int">
81
+            SELECT nvl(Max(convert(rtn_req_dtl_no,int)),0)
82
+            FROM rtn_req_dtl_ptcl
83
+            WHERE  rtn_req_unq_no = #{rtnReqUnqNo}
84
+    </select>
85
+
86
+    <select id="selectSumRtnAmt" resultType="com.oqpo.api.entity.rtnmng.RtnReqBaseInfoEntity">
87
+            select count(*) as rtn_req_item_qty,  nvl(sum(rtn_amt),0) as rtn_req_amt
88
+            from  rtn_req_dtl_ptcl
89
+            where rtn_req_unq_no = #{rtnReqUnqNo}
90
+    </select>
91
+
92
+<!--
93
+    <select id="selectPchReqGridList" resultType="com.oqpo.api.entity.pomng.PchReqBaseInfoEntity">
94
+        select  /* PchReq.selectPchReqGridList */
95
+                pch_req_unq_no, brand_id, fn_brand_nm(brand_id) as brand_nm,  pch_req_nm
96
+                ,pch_req_st_cd, fn_code_nm('PCH_REQ_ST_Cd',pch_req_st_cd) as pch_req_st_nm
97
+                , pch_req_mgr_nm, date_format(dlv_req_dt,'%Y.%m.%d') as dlv_req_dt, pch_req_total_amt
98
+                ,pch_req_item_qty, date_format(pch_req_rjct_dt,'%Y.%m.%d') as pch_req_rjct_dt, pch_req_rjct_nm
99
+                ,whs_id, fn_whs_nm(brand_id, whs_id) as whs_nm
100
+                ,location, fn_whs_location_nm(brand_id, whs_id, location) as location_nm
101
+                ,date_format(pch_req_dt,'%Y.%m.%d') as pch_req_dt
102
+        from   pch_req_base_info
103
+        where  brand_id = #{sBrandId}
104
+        <if test="sStoreId != null and sStoreId != ''">
105
+        and    store_id = #{sStoreId}
106
+        </if>
107
+        and    date_format(sys_reg_dttm,'%Y%m%d') between #{fromDt} and #{toDt}
108
+        <if test="sWhsId != null and sWhsId != ''">
109
+            and    whs_id = #{sWhsId}
110
+        </if>
111
+        <if test="sPchReqStCd != null and sPchReqStCd != ''">
112
+            and    pch_req_st_cd = #{sPchReqStCd}
113
+        </if>
114
+        <if test="sItemNm != null and sItemNm != ''">
115
+            and    pch_req_unq_no in ( select pch_req_unq_no from pch_req_dtl_ptcl
116
+            where date_format(sys_reg_dttm,'%Y%m%d') between #{fromDt} and #{toDt})
117
+            and  item_id like concat('%',#{sItemNm},'%') or item_nm like concat('%',#{sItemNm},'%')
118
+        </if>
119
+        <choose>
120
+            <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
121
+                <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
122
+                    <if test="gridRequest.sord == 'asc'.toString()">
123
+                        order by pch_req_unq_no asc
124
+                    </if>
125
+                    <if test="gridRequest.sord == 'desc'.toString()">
126
+                        order by pch_req_unq_no desc
127
+                    </if>
128
+                </if>
129
+            </when>
130
+            <otherwise>
131
+                order by pch_req_unq_no desc
132
+            </otherwise>
133
+        </choose>
134
+        <if test="gridRequest.pagingYn == true">
135
+            limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
136
+        </if>
137
+    </select>
138
+
139
+    <select id="selectPchReqGridCnt" resultType="int">
140
+            select count(*) as cnt
141
+            from   pch_req_base_info
142
+            where  brand_id = #{sBrandId}
143
+            <if test="sStoreId != null and sStoreId != ''">
144
+                and    store_id = #{sStoreId}
145
+            </if>
146
+            and    date_format(sys_reg_dttm,'%Y%m%d') between #{fromDt} and #{toDt}
147
+            <if test="sWhsId != null and sWhsId != ''">
148
+                and    whs_id = #{sWhsId}
149
+            </if>
150
+            <if test="sPchReqStCd != null and sPchReqStCd != ''">
151
+                and    pch_req_st_cd = #{sPchReqStCd}
152
+            </if>
153
+            <if test="sItemNm != null and sItemNm != ''">
154
+                and    pch_req_unq_no in ( select pch_req_unq_no from pch_req_dtl_ptcl
155
+                where date_format(sys_reg_dttm,'%Y%m%d') between #{fromDt} and #{toDt})
156
+                and  item_id like concat('%',#{sItemNm},'%') or item_nm like concat('%',#{sItemNm},'%')
157
+            </if>
158
+    </select>
159
+
160
+    <select id="selectPchReqInfo" resultType="com.oqpo.api.entity.pomng.PchReqBaseInfoEntity">
161
+        SELECT pch_req_unq_no, brand_id, fn_brand_nm(brand_id) as brand_nm, store_id, pch_req_nm, pch_req_dept
162
+            , pch_req_mgr_nm, DATE_FORMAT(pch_req_dt,'%Y.%m.%d') as pch_req_dt, pch_req_st_cd, fn_code_nm('PCH_REQ_ST_CD', pch_req_st_cd ) AS pch_req_st_nm, pch_req_dvsn
163
+            , note, pch_req_item_qty, pch_req_total_amt,   DATE_FORMAT(pch_req_rjct_dt,'%Y.%m.%d') as  pch_req_rjct_dt, pch_req_rjct_nm
164
+            , pch_req_rjct_rsn, pch_req_mgr_id, pch_req_rjct_id
165
+            ,whs_id, fn_whs_nm(brand_id, whs_id) as whs_nm
166
+            ,location, fn_whs_location_nm(brand_id, whs_id, location) as location_nm
167
+            , DATE_FORMAT(dlv_req_dt ,'%Y.%m.%d')  as dlv_req_dt
168
+            , DATE_FORMAT(sys_reg_dttm,'%Y.%m.%d %H:%i:%s') AS sys_reg_dttm, sys_reg_id, DATE_FORMAT(sys_chg_dttm,'%Y.%m.%d %H:%i:%s') AS sys_chg_dttm, sys_chg_id
169
+            , nvl(pch_appr_amt,0) as pch_appr_amt, case when pch_req_total_amt = pch_appr_amt then 'Y' else 'N' end pch_appr_yn
170
+        FROM pch_req_base_info
171
+        WHERE brand_id = #{brandId}
172
+        and   pch_req_unq_no = #{pchReqUnqNo}
173
+    </select>
174
+
175
+    <select id="selectPchReqDtlPtcl" resultType="com.oqpo.api.entity.pomng.PchReqDtlPtclEntity">
176
+            SELECT ptcl.pch_req_unq_no, ptcl.pch_req_dtl_no, ptcl.item_id, ptcl.item_nm, ptcl.unit, fn_code_nm('DSTRBT_COST_UNIT',ptcl.unit) AS unit_nm
177
+                  , ptcl.pch_req_qty, ptcl.pch_req_amt, ptcl.unit_amt, ptcl.brand_unit_unq_no, ptcl.store_unit_unq_no, ptcl.unit_gubun
178
+                  , odr.podr_dtl_st_cd, fn_code_nm(upper('podr_dtl_st_cd'), odr.podr_dtl_st_cd) as podr_dtl_st_nm
179
+            FROM pch_req_dtl_ptcl ptcl
180
+            left outer join pch_odr_dtl_ptcl odr on odr.pch_req_unq_no = ptcl.pch_req_unq_no and odr.pch_req_dtl_no = ptcl.pch_req_dtl_no
181
+            WHERE ptcl.pch_req_unq_no = #{pchReqUnqNo}
182
+    </select>
183
+
184
+
185
+    <insert id="insertPchReqBaseInfo" >
186
+        INSERT INTO /* PchReq.insertPchReqBaseInfo */ pch_req_base_info
187
+            (pch_req_unq_no, brand_id, store_id, pch_req_nm, pch_req_dept
188
+            , pch_req_mgr_nm, pch_req_dt, pch_req_tm, pch_req_st_cd, pch_req_dvsn
189
+            , note, pch_req_item_qty, pch_req_total_amt, pch_req_rjct_dt, pch_req_rjct_nm
190
+            , pch_req_rjct_rsn, pch_req_mgr_id, pch_req_rjct_id
191
+            , whs_id, location,dlv_req_dt
192
+            , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
193
+        VALUES
194
+            (#{entity.pchReqUnqNo}, #{entity.brandId}, #{entity.storeId}, #{entity.pchReqNm}, #{entity.pchReqDept}
195
+            , #{entity.pchReqMgrNm}, case when  #{entity.pchReqStCd} = 'PR20' then   date_format(now(),'%Y%m%d') else null end, null, #{entity.pchReqStCd}, #{entity.pchReqDvsn}
196
+            , #{entity.note}, #{entity.pchReqItemQty}, #{entity.pchReqTotalAmt}, null, null
197
+            , null, #{userId}, null
198
+            , #{entity.whsId}, #{entity.location}, #{entity.dlvReqDt}
199
+            , NOW(), #{userId}, NOW(), #{userId})
200
+    </insert>
201
+
202
+    <update id="updateOrdPchReqBaseInfo">
203
+        UPDATE /* PchReq.updateOrdPchReqBaseInfo */
204
+            pch_req_base_info SET
205
+                pch_req_dt = case when  #{entity.pchReqStCd} = 'PR20' then  date_format(now(),'%Y%m%d') else null end ,
206
+                pch_req_st_cd = #{entity.pchReqStCd},
207
+                note = #{entity.note},
208
+                pch_req_item_qty = #{entity.pchReqItemQty},
209
+                pch_req_total_amt = #{entity.pchReqTotalAmt},
210
+                whs_id = #{entity.whsId},
211
+                location = #{entity.location},
212
+                dlv_req_dt = #{entity.dlvReqDt},
213
+                sys_chg_dttm = NOW(),
214
+                sys_chg_id = #{userId}
215
+            WHERE brand_id = #{entity.brandId}
216
+            and   pch_req_unq_no = #{entity.pchReqUnqNo}
217
+    </update>
218
+
219
+    <update id="updateRejPchReqBaseInfo">
220
+        UPDATE /* PchReq.updateRejPchReqBaseInfo */
221
+            pch_req_base_info SET
222
+                pch_req_rjct_nm = #{pchReqRjctNm},
223
+                pch_req_rjct_dt = date_format(now(),'%Y%m%d'),
224
+                pch_req_rjct_rsn = #{pchReqRjctRsn},
225
+                pch_req_rjct_id = #{userId},
226
+                sys_chg_dttm = NOW(),
227
+                sys_chg_id = #{userId}
228
+            WHERE pch_req_unq_no = #{pchReqUnqNo}
229
+    </update>
230
+
231
+
232
+    <insert id="insertPchReqDtlPtcl" >
233
+        INSERT INTO /* PchReq.insertPchReqDtlPtcl */   pch_req_dtl_ptcl
234
+            (pch_req_unq_no, pch_req_dtl_no, item_nm, unit, pch_req_qty
235
+            , pch_req_amt, unit_amt, unit_gubun, brand_unit_unq_no, store_unit_unq_no
236
+            , item_id, sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
237
+        VALUES
238
+        <foreach collection="gridInsertData" item="item" separator=",">
239
+            (#{item.pchReqUnqNo}, #{item.pchReqDtlNo}, #{item.itemNm}, #{item.unit}, #{item.pchReqQty}
240
+            , #{item.pchReqAmt}, #{item.unitAmt}, #{item.unitGubun} , #{item.brandUnitUnqNo} , #{item.storeUnitUnqNo}
241
+            , #{item.itemId} , NOW(), #{userId}, NOW(), #{userId})
242
+        </foreach>
243
+
244
+    </insert>
245
+
246
+    <update id="updatePchReqDtlPtcl">
247
+        <foreach collection="gridUpdateData" item="item" separator=";">
248
+            UPDATE /* PchReq.updatePchReqDtlPtcl */
249
+                pch_req_dtl_ptcl SET
250
+                    unit = #{item.unit},
251
+                    pch_req_qty = #{item.pchReqQty},
252
+                    pch_req_amt = #{item.pchReqAmt},
253
+                    unit_amt = #{item.unitAmt},
254
+                    sys_chg_dttm = NOW(),
255
+                    sys_chg_id = #{userId}
256
+            WHERE pch_req_unq_no = #{pchReqUnqNo}
257
+            AND pch_req_dtl_no = #{item.pchReqDtlNo}
258
+        </foreach>
259
+    </update>
260
+
261
+    <delete id="deletePchReqDtlPtcl">
262
+        DELETE  /* PchReq.deletePchReqDtlPtcl */
263
+            FROM pch_req_dtl_ptcl
264
+        WHERE pch_req_unq_no = #{pchReqUnqNo}
265
+        and    pch_req_dtl_no   in
266
+        <foreach collection="gridDeleteData" item="item" separator="," open="(" close=")">
267
+            #{item.pchReqDtlNo}
268
+        </foreach>
269
+
270
+    </delete>
271
+
272
+    <select id="selectMaxPchReqDtlNo" resultType="int">
273
+            SELECT nvl(Max(convert(pch_req_dtl_no,int)),0)
274
+            FROM pch_req_dtl_ptcl
275
+            WHERE  pch_req_unq_no = #{pchReqUnqNo}
276
+    </select>
277
+
278
+    <select id="selectSumReqAmt" resultType="com.oqpo.api.entity.pomng.PchReqBaseInfoEntity">
279
+            select count(*) as pch_req_item_qty,  nvl(sum(pch_req_amt),0) as pch_req_total_amt
280
+            from  pch_req_dtl_ptcl
281
+            where pch_req_unq_no = #{pchReqUnqNo}
282
+    </select>
283
+
284
+    <select id="selectPchReqPoTargetGridList" resultType="com.oqpo.api.entity.pomng.PchReqBaseInfoEntity">
285
+        select base.pch_req_unq_no, ptcl.pch_req_dtl_no as 'pchReqDtlInfo.pch_req_dtl_no', base.brand_id, fn_brand_nm(base.brand_id) as brand_nm
286
+            , base.store_id, store.store_nm
287
+            , bitem.spply_nm as 'itemUnitInfo.spply_nm'
288
+            , fn_whs_nm(base.brand_id, base.whs_id) as whs_nm, fn_whs_location_nm(base.brand_id, base.whs_id, base.location) as location_nm
289
+            , ptcl.item_id as 'pchReqDtlInfo.item_id', ptcl.item_nm as 'pchReqDtlInfo.item_nm', ptcl.unit_amt as 'pchReqDtlInfo.unit_amt'
290
+            , bitem.unit_amt as 'itemUnitInfo.unit_amt' , ptcl.pch_req_qty as 'pchReqDtlInfo.pch_req_qty', date_format(base.dlv_req_dt, '%Y.%m.%d') as dlv_req_dt
291
+            , ptcl.pch_req_amt as 'pchReqDtlInfo.pch_req_amt', bitem.unit_amt * ptcl.pch_req_qty as 'pchReqDtlInfo.pch_ord_amt'
292
+            , bitem.lead_time as 'itemUnitInfo.lead_time', bitem.spply_id as 'itemUnitInfo.spply_id', base.whs_id, base.location
293
+        from pch_req_base_info base
294
+        join pch_req_dtl_ptcl ptcl on base.pch_req_unq_no = ptcl.pch_req_unq_no
295
+        join brand_item_unit_info bitem on ptcl.brand_unit_unq_no = bitem.brand_unit_unq_no
296
+        left outer join store_base_info store on base.brand_id = store.brand_id and base.store_id = store.store_id
297
+        where 1 = 1
298
+        and base.brand_id = #{sBrandId}
299
+        and base.pch_req_st_cd = 'PR20'
300
+        and base.dlv_req_dt between #{fromDt} and #{toDt}
301
+        <if test="sSpplyId != null and sSpplyId != ''">
302
+        and bitem.spply_id = #{sSpplyId}
303
+        </if>
304
+        <if test="sWhsId != null and sWhsId != ''">
305
+        and base.whs_id = #{sWhsId}
306
+        </if>
307
+        <if test="sItemNm != null and sItemNm != ''">
308
+        and (ptcl.item_id like concat('%', #{sItemNm}, '%') or ptcl.item_nm like concat('%', #{sItemNm}, '%'))
309
+        </if>
310
+        <choose>
311
+            <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
312
+                <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
313
+                    <if test="gridRequest.sord == 'asc'.toString()">
314
+                        order by base.dlv_req_dt asc, base.whs_id, base.location, bitem.spply_id, base.pch_req_unq_no, ptcl.pch_req_dtl_no
315
+                    </if>
316
+                    <if test="gridRequest.sord == 'desc'.toString()">
317
+                        order by base.dlv_req_dt desc, base.whs_id, base.location, bitem.spply_id, base.pch_req_unq_no, ptcl.pch_req_dtl_no
318
+                    </if>
319
+                </if>
320
+            </when>
321
+            <otherwise>
322
+                order by base.dlv_req_dt asc, base.whs_id, base.location, bitem.spply_id, base.pch_req_unq_no, ptcl.pch_req_dtl_no
323
+            </otherwise>
324
+        </choose>
325
+        <if test="gridRequest.pagingYn == true">
326
+            limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
327
+        </if>
328
+
329
+    </select>
330
+
331
+    <select id="selectPchReqPoTargetGridCnt" resultType="int">
332
+        select count(*)
333
+        from pch_req_base_info base
334
+        join pch_req_dtl_ptcl ptcl on base.pch_req_unq_no = ptcl.pch_req_unq_no
335
+        join brand_item_unit_info bitem on ptcl.brand_unit_unq_no = bitem.brand_unit_unq_no
336
+        left outer join store_base_info store on base.brand_id = store.brand_id and base.store_id = store.store_id
337
+        where 1 = 1
338
+        and base.brand_id = #{sBrandId}
339
+        and base.pch_req_st_cd = 'PR20'
340
+        and base.dlv_req_dt between #{fromDt} and #{toDt}
341
+        <if test="sSpplyId != null and sSpplyId != ''">
342
+            and bitem.spply_id = #{sSpplyId}
343
+        </if>
344
+        <if test="sWhsId != null and sWhsId != ''">
345
+            and base.whs_id = #{sWhsId}
346
+        </if>
347
+        <if test="sItemNm != null and sItemNm != ''">
348
+            and (ptcl.item_id like concat('%', #{sItemNm}, '%') or ptcl.item_nm like concat('%', #{sItemNm}, '%'))
349
+        </if>
350
+    </select>
351
+
352
+    <select id="selectPchRejectPrTargetList" resultType="com.oqpo.api.entity.pomng.PchReqDtlPtclEntity">
353
+        select  /* PchReq.selectPchRejectPrTargetList */
354
+              base.pch_req_unq_no, ptcl.pch_req_dtl_no
355
+            , ptcl.item_id, ptcl.item_nm
356
+            , ptcl.pch_req_qty, ptcl.pch_req_amt
357
+        from pch_req_base_info base
358
+            , pch_req_dtl_ptcl ptcl
359
+        where 1 = 1
360
+        and base.pch_req_unq_no = ptcl.pch_req_unq_no
361
+        and base.pch_req_st_cd = 'PR20'
362
+        and base.pch_req_unq_no  = #{pchReqUnqNo}
363
+    </select>
364
+
365
+    <update id="updatePchReqStCd">
366
+        <foreach collection="gridUpdateData" item="item" separator=";">
367
+            UPDATE /* PchReq.updatePchReqDtlPtcl */
368
+            pch_req_base_info SET
369
+                pch_req_st_cd = #{item.pchReqStCd},
370
+                sys_chg_dttm = NOW(),
371
+                sys_chg_id = #{userId}
372
+            WHERE pch_req_unq_no = #{item.pchReqUnqNo}
373
+        </foreach>
374
+    </update>
375
+-->
376
+
377
+</mapper>