Browse Source

구매요청 부분 API 작업진행중

dwkim 2 years ago
parent
commit
3b8f02cb60

+ 50 - 0
src/main/java/com/oqpo/api/entity/pomng/PchReqBaseInfoEntity.java

@@ -0,0 +1,50 @@
1
+package com.oqpo.api.entity.pomng;
2
+
3
+import com.oqpo.api.entity.oper.FileEntity;
4
+import lombok.Getter;
5
+import lombok.Setter;
6
+import lombok.ToString;
7
+
8
+import java.io.Serializable;
9
+import java.util.List;
10
+
11
+@Getter
12
+@Setter
13
+@ToString
14
+public class PchReqBaseInfoEntity implements Serializable {
15
+    private static final long serialVersionUID = -3590936033715917450L;
16
+
17
+    private String pchReqUnqNo;
18
+    private String brandId;
19
+    private String brandNm;
20
+    private String storeId;
21
+    private String pchReqNm;
22
+    private String pchReqDept;
23
+    private String pchReqMgrNm;
24
+    private String pchReqDt;
25
+    private String pchReqTm;
26
+    private String pchReqStCd;
27
+    private String pchReqStNm;
28
+    private String pchReqDvsn;
29
+    private String pchReqDvsnNm;
30
+    private String note;
31
+    private Integer pchReqItemQty;
32
+    private Integer pchReqTotalAmt;
33
+    private String pchReqRjctDt;
34
+    private String pchReqRjctNm;
35
+    private String pchReqRjctRsn;
36
+    private String pchReqMgrId;
37
+    private String pchReqRjctId;
38
+    private String dlvReqDt;
39
+    private String whsId;
40
+    private String whsNm;
41
+    private String location;
42
+    private String locationNm;
43
+    private String sysRegDttm;
44
+    private String sysRegId;
45
+    private String sysChgDttm;
46
+    private String sysChgId;
47
+
48
+    private List<PchReqDtlPtclEntity> pchReqDtlInfo ;
49
+
50
+}

+ 30 - 0
src/main/java/com/oqpo/api/entity/pomng/PchReqDtlPtclEntity.java

@@ -0,0 +1,30 @@
1
+package com.oqpo.api.entity.pomng;
2
+
3
+import lombok.Getter;
4
+import lombok.Setter;
5
+import lombok.ToString;
6
+
7
+import java.io.Serializable;
8
+
9
+@Getter
10
+@Setter
11
+@ToString
12
+public class PchReqDtlPtclEntity implements Serializable {
13
+    private static final long serialVersionUID = -3590936033715917450L;
14
+
15
+    private String pchReqUnqNo;
16
+    private String pchReqDtlNo;
17
+    private String itemNm;
18
+    private String unit;
19
+    private String unitNm;
20
+    private Integer pchReqQty;
21
+    private Integer pchReqAmt;
22
+    private Integer unitAmt;
23
+    private String itemId;
24
+    private String sysRegDttm;
25
+    private String sysRegId;
26
+    private String sysChgDttm;
27
+    private String sysChgId;
28
+
29
+
30
+}

+ 40 - 0
src/main/java/com/oqpo/api/mapper/pomng/PchReqMapper.java

@@ -0,0 +1,40 @@
1
+package com.oqpo.api.mapper.pomng;
2
+
3
+
4
+import com.oqpo.api.entity.oper.AfflSaleInfoEntity;
5
+import com.oqpo.api.entity.pomng.PchReqBaseInfoEntity;
6
+import com.oqpo.api.entity.pomng.PchReqDtlPtclEntity;
7
+import com.oqpo.api.web.dto.request.GridRequest;
8
+import org.apache.ibatis.annotations.Mapper;
9
+import org.apache.ibatis.annotations.Param;
10
+
11
+import java.util.List;
12
+
13
+@Mapper
14
+public interface PchReqMapper {
15
+
16
+    List<PchReqBaseInfoEntity> selectPchReqGridList(@Param("sBrandId") String sBrandId, @Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("sWhsId") String sWhsId , @Param("sPchReqStCd") String sPchReqStCd , @Param("sItemNm") String sItemNm ,  GridRequest gridRequest)throws Exception;
17
+    int selectPchReqGridCnt(@Param("sBrandId") String sBrandId, @Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("sWhsId") String sWhsId , @Param("sPchReqStCd") String sPchReqStCd , @Param("sItemNm") String sItemNm )throws Exception;
18
+
19
+    PchReqBaseInfoEntity selectPchReqInfo(@Param("brandId") String brandId, @Param("pchReqUnqNo") String pchReqUnqNo)throws Exception;
20
+    List<PchReqDtlPtclEntity> selectPchReqDtlPtcl(@Param("brandId") String brandId, @Param("pchReqUnqNo") String pchReqUnqNo)throws Exception;
21
+
22
+
23
+    int insertPchReqBaseInfo(@Param("userId") String userId, @Param("userNm") String userNm, PchReqBaseInfoEntity entity) throws Exception;
24
+
25
+    int updateOrdPchReqBaseInfo(@Param("userId") String userId, @Param("userNm") String userNm, PchReqBaseInfoEntity entity) throws Exception;
26
+
27
+    int insertPchReqDtlPtcl(@Param("userId") String userId, List<PchReqDtlPtclEntity> gridInsertData) throws Exception;
28
+
29
+    int updateRejPchReqBaseInfo(@Param("userId") String userId, PchReqBaseInfoEntity entity) throws Exception;
30
+
31
+    int updatePchReqDtlPtcl(@Param("userId") String userId, @Param("pchReqUnqNo") String pchReqUnqNo, List<PchReqDtlPtclEntity> gridUpdateData) throws Exception;
32
+
33
+    int deletePchReqDtlPtcl(@Param("pchReqUnqNo") String pchReqUnqNo, List<PchReqDtlPtclEntity> gridDeleteData ) throws Exception;
34
+
35
+    int selectMaxPchReqDtlNo( @Param("pchReqUnqNo") String pchReqUnqNo) throws Exception;
36
+
37
+    int selectSumReqAmt(@Param("pchReqUnqNo") String pchReqUnqNo) throws Exception;
38
+
39
+
40
+}

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

@@ -0,0 +1,156 @@
1
+package com.oqpo.api.service.pomng;
2
+
3
+
4
+import com.oqpo.api.entity.oper.AfflSaleInfoEntity;
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.stinfo.BrandEntity;
9
+import com.oqpo.api.exception.GlobalException;
10
+import com.oqpo.api.mapper.pomng.PchReqMapper;
11
+import com.oqpo.api.service.CommonService;
12
+import com.oqpo.api.util.DateUtil;
13
+import com.oqpo.api.web.dto.request.GridRequest;
14
+import com.oqpo.api.web.dto.request.pomng.pchReq.SavePchReqlRequest;
15
+import com.oqpo.api.web.dto.request.stinfo.brand.SaveBrandInfolRequest;
16
+import com.oqpo.api.web.dto.response.GridResponse;
17
+import com.oqpo.api.web.dto.response.pomng.pchReq.PchReqInfoResponse;
18
+import com.oqpo.api.web.dto.response.pomng.pchReq.PchReqSearchListResponse;
19
+import com.oqpo.api.web.dto.response.stinfo.brand.BrandInfoResponse;
20
+import lombok.extern.slf4j.Slf4j;
21
+import org.springframework.beans.factory.annotation.Autowired;
22
+import org.springframework.stereotype.Service;
23
+import org.springframework.transaction.annotation.Transactional;
24
+
25
+import java.util.List;
26
+import java.util.stream.Collectors;
27
+
28
+@Service
29
+@Slf4j
30
+public class PchReqService extends CommonService {
31
+    @Autowired
32
+    private PchReqMapper pchReqMapper;
33
+
34
+    /*
35
+      구매요청 그리드 리스트 조회
36
+     */
37
+    public GridResponse selectPchReqGridList( String sBrandId, String fromDt, String toDt, String sWhsId, String sPchReqStCd, String sItemNm, GridRequest gridRequest) throws Exception {
38
+        int gridPage = gridRequest.getGridPage();
39
+        int gridSize = gridRequest.getGridSize();
40
+
41
+        fromDt = fromDt == null ? null : fromDt.replace(".", "");
42
+        toDt = toDt == null ? null : toDt.replace(".", "");
43
+
44
+        int gridRecords = pchReqMapper.selectPchReqGridCnt( sBrandId, fromDt, toDt, sWhsId,sPchReqStCd, sItemNm );
45
+        int gridTotal = fnCalculateGridTotal(gridSize, gridRecords);
46
+        List<PchReqBaseInfoEntity> entities = pchReqMapper.selectPchReqGridList( sBrandId, fromDt, toDt, sWhsId,sPchReqStCd, sItemNm, gridRequest);
47
+        List<Object> gridRows = entities.stream()
48
+                .map(m -> PchReqSearchListResponse.builder()
49
+                        .viewCd("R")
50
+                        .pchReqUnqNo(m.getPchReqUnqNo())
51
+                        .brandId(m.getBrandId())
52
+                        .brandNm(m.getBrandNm())
53
+                        .storeId(m.getStoreId()  == null ? "" : m.getStoreId())
54
+                        .pchReqNm(m.getPchReqNm() == null ? "" :m.getPchReqNm() )
55
+                        .pchReqStCd(m.getPchReqStCd() == null ? "" : m.getPchReqStCd())
56
+                        .pchReqStNm(m.getPchReqStNm() == null ? "" : m.getPchReqStNm())
57
+                        .pchReqItemQty(m.getPchReqItemQty() == null ? 0 : m.getPchReqItemQty())
58
+                        .pchReqTotalAmt(m.getPchReqTotalAmt() == null ? 0 : m.getPchReqTotalAmt())
59
+                        .pchReqRjctDt(m.getPchReqRjctDt() == null ? "" :m.getPchReqRjctDt() )
60
+                        .pchReqRjctNm(m.getPchReqRjctNm() == null ? "" : m.getPchReqRjctNm())
61
+                        .pchReqMgrNm(m.getPchReqMgrNm() == null ? "" :m.getPchReqMgrNm() )
62
+                        .dlvReqDt(m.getDlvReqDt() == null ? "" :m.getDlvReqDt() )
63
+                        .whsLocationNm(m.getWhsNm() == null ? "" : m.getWhsNm()  + "-" + m.getLocationNm())
64
+                        .build())
65
+                .collect(Collectors.toList());
66
+        return GridResponse.toDTO(gridPage, gridTotal, gridRecords, gridRows);
67
+    }
68
+
69
+    /* 구매요청 정보 */
70
+    public PchReqInfoResponse selectPchReqInfo(String brandId, String  pchReqUnqNo) throws Exception {
71
+
72
+        PchReqBaseInfoEntity entity = pchReqMapper.selectPchReqInfo(brandId, pchReqUnqNo);
73
+        List<PchReqDtlPtclEntity> dtlEntity = pchReqMapper.selectPchReqDtlPtcl(brandId, pchReqUnqNo);
74
+        return PchReqInfoResponse.toDTO(entity,dtlEntity );
75
+    }
76
+
77
+    /* 구매요청 저장 */
78
+    @Transactional
79
+    public void savePchReqInfo(String userId, String userNm, SavePchReqlRequest savePchReqlRequest) throws Exception {
80
+        try {
81
+
82
+            PchReqBaseInfoEntity entity = new PchReqBaseInfoEntity();
83
+            entity.setPchReqUnqNo(savePchReqlRequest.getPchReqUnqNo());
84
+            entity.setBrandId(savePchReqlRequest.getBrandId());
85
+            entity.setStoreId(savePchReqlRequest.getStoreId());
86
+            entity.setPchReqNm(savePchReqlRequest.getPchReqNm());
87
+            entity.setNote(savePchReqlRequest.getNote());
88
+            entity.setDlvReqDt(savePchReqlRequest.getDlvReqDt().replaceAll("\\.",""));
89
+            entity.setWhsId(savePchReqlRequest.getWhsId());
90
+            entity.setPchReqStCd(savePchReqlRequest.getPchReqStCd());
91
+            entity.setLocation(savePchReqlRequest.getLocation());
92
+
93
+            if ("C".equals(savePchReqlRequest.getViewCd())) {
94
+                // 구매요청 아이디 부여
95
+                entity.setPchReqUnqNo(fnGetDealNo(1,""));  // 구매요청번호 생성
96
+            }
97
+            // 품목 삭제 처리
98
+            List<PchReqDtlPtclEntity> gridDeleteData = savePchReqlRequest.toCodeEntities(savePchReqlRequest.getGridDeleteData());
99
+            if (gridDeleteData.size() > 0) {
100
+                pchReqMapper.deletePchReqDtlPtcl(entity.getPchReqUnqNo(), gridDeleteData) ;
101
+            }
102
+
103
+            // 품목 수정 처리
104
+            List<PchReqDtlPtclEntity> gridUpdateData = savePchReqlRequest.toCodeEntities(savePchReqlRequest.getGridUpdateData());
105
+            if (gridUpdateData.size() > 0) {
106
+                pchReqMapper.deletePchReqDtlPtcl(entity.getPchReqUnqNo(), gridUpdateData) ;
107
+            }
108
+
109
+            // 품목 등록 처리
110
+            List<PchReqDtlPtclEntity> gridInsertData = savePchReqlRequest.toCodeEntities(savePchReqlRequest.getGridInsertData());
111
+            if (gridInsertData.size() > 0) {
112
+
113
+                int maxDtlNo = pchReqMapper.selectMaxPchReqDtlNo(entity.getPchReqUnqNo());
114
+
115
+                for (int i = 0 ; i < gridInsertData.size() ; i++) {
116
+                    gridInsertData.get(i).setPchReqUnqNo(entity.getPchReqUnqNo());
117
+                    gridInsertData.get(i).setPchReqDtlNo( Integer.toString(maxDtlNo + 10 ));
118
+                }
119
+
120
+                pchReqMapper.insertPchReqDtlPtcl(userId, gridInsertData) ;
121
+            }
122
+
123
+            int itemtotalAmt = pchReqMapper.selectSumReqAmt(entity.getPchReqUnqNo());
124
+
125
+            if ("PR20".equals(entity.getPchReqStCd())) {
126
+                //구매요청
127
+                entity.setPchReqDt(DateUtil.getCurrentDate());
128
+            }
129
+
130
+            entity.setPchReqItemQty(gridInsertData.size());
131
+            entity.setPchReqTotalAmt(itemtotalAmt);
132
+
133
+            if ("C".equals(savePchReqlRequest.getViewCd())) {
134
+                if ("".equals(entity.getPchReqNm())) {
135
+                    entity.setPchReqNm(userNm + " " + DateUtil.getCurrentDate() + DateUtil.getCurrentTime() + " " + gridInsertData.size());
136
+                }
137
+                entity.setPchReqMgrId(userId);
138
+                entity.setPchReqMgrNm(userNm);
139
+
140
+                pchReqMapper.insertPchReqBaseInfo(userId, userNm, entity);
141
+            } else if ("U".equals(savePchReqlRequest.getViewCd())) {
142
+
143
+                pchReqMapper.updateOrdPchReqBaseInfo(userId, userNm,  entity);
144
+            }
145
+
146
+        } catch (GlobalException e) {
147
+            e.getStackTrace();
148
+            throw new GlobalException(e.getSystemMessageCode());
149
+        } catch (Exception e) {
150
+            e.getStackTrace();
151
+            throw new RuntimeException();
152
+        }
153
+    }
154
+
155
+
156
+}

+ 1 - 1
src/main/java/com/oqpo/api/service/stinfo/StoreBaseInfoService.java

@@ -240,7 +240,7 @@ public class StoreBaseInfoService extends CommonService {
240 240
 
241 241
                 //창고 로케이션 정보
242 242
                 WhsMgntBaseLocEntity locEntity = new WhsMgntBaseLocEntity();
243
-                locEntity.setLocation("0100");
243
+                locEntity.setLocation("1001");
244 244
                 locEntity.setLocationNm(entity.getStoreNm());
245 245
                 locEntity.setBrandId(entity.getBrandId());
246 246
                 locEntity.setStckDvsn("SD01");

+ 116 - 0
src/main/java/com/oqpo/api/web/dto/request/pomng/pchReq/SavePchReqlRequest.java

@@ -0,0 +1,116 @@
1
+package com.oqpo.api.web.dto.request.pomng.pchReq;
2
+
3
+import com.oqpo.api.entity.oper.AfflSaleInfoEntity;
4
+import com.oqpo.api.entity.pomng.PchReqDtlPtclEntity;
5
+import com.oqpo.api.web.dto.request.oper.affl.SaveAfflRequest;
6
+import io.swagger.annotations.ApiModelProperty;
7
+import lombok.*;
8
+
9
+import javax.validation.constraints.NotBlank;
10
+import java.util.ArrayList;
11
+import java.util.List;
12
+
13
+@Getter
14
+@Setter
15
+public class SavePchReqlRequest {
16
+    @NotBlank
17
+    @ApiModelProperty(value = "CRUD")
18
+    private String viewCd;
19
+
20
+    @ApiModelProperty(value = "구매요청고유번호")
21
+    private String pchReqUnqNo;
22
+
23
+    @NotBlank
24
+    @NotBlank @ApiModelProperty(value = "브랜드아이디")
25
+    private String brandId;
26
+
27
+    @ApiModelProperty(value = "매장아이디")
28
+    private String storeId;
29
+
30
+    @ApiModelProperty(value = "구매요청명")
31
+    private String pchReqNm;
32
+
33
+    @ApiModelProperty(value = "구매요청상태")
34
+    private String pchReqStCd;  // PR00  임시저장, PR20 구매요청
35
+
36
+    @ApiModelProperty(value = "비고")
37
+    private String note;
38
+
39
+    @NotBlank
40
+    @ApiModelProperty(value = "납기요청일")
41
+    private String dlvReqDt;
42
+
43
+    @NotBlank
44
+    @ApiModelProperty(value = "창고아이디")
45
+    private String whsId;
46
+
47
+    @NotBlank
48
+    @ApiModelProperty(value = "창고상세위치정보")
49
+    private String location;
50
+
51
+    @ApiModelProperty(value = "등록 품목리스트")
52
+    private List<SavePchReqlRequest.SaveItemList> gridInsertData;
53
+
54
+    @ApiModelProperty(value = "수정 품목리스트")
55
+    private List<SavePchReqlRequest.SaveItemList> gridUpdateData;
56
+
57
+    @ApiModelProperty(value = "삭제 품목리스트")
58
+    private List<SavePchReqlRequest.SaveItemList> gridDeleteData;
59
+
60
+
61
+    public List<PchReqDtlPtclEntity> toCodeEntities(List<SavePchReqlRequest.SaveItemList> gridData) {
62
+        List<PchReqDtlPtclEntity> entities = new ArrayList<>();
63
+        if (gridData == null || gridData.size() == 0)
64
+            return entities;
65
+
66
+        gridData.forEach(x -> {
67
+            PchReqDtlPtclEntity entity = new PchReqDtlPtclEntity();
68
+            entity.setPchReqUnqNo(x.getPchReqUnqNo());
69
+            entity.setPchReqDtlNo(x.getPchReqDtlNo());
70
+            entity.setItemId(x.getItemId());
71
+            entity.setItemNm(x.getItemNm());
72
+            entity.setUnit(x.getUnit());
73
+            entity.setPchReqQty(x.getPchReqQty());
74
+            entity.setPchReqAmt(x.getPchReqAmt());
75
+            entity.setUnitAmt(x.getUnitAmt());
76
+            entities.add(entity);
77
+        });
78
+        return entities;
79
+    }
80
+
81
+    @Getter
82
+    @Builder
83
+    @AllArgsConstructor(access = AccessLevel.PROTECTED)
84
+    static class SaveItemList {
85
+
86
+        @ApiModelProperty(value = "구매요청번호")
87
+        private String pchReqUnqNo;
88
+
89
+        @ApiModelProperty(value = "구매요청상세번호")
90
+        private String pchReqDtlNo;
91
+
92
+        @NotBlank
93
+        @ApiModelProperty(value = "품목아이디")
94
+        private String itemId;
95
+
96
+        @NotBlank
97
+        @ApiModelProperty(value = "품목명")
98
+        private String itemNm;
99
+
100
+        @NotBlank
101
+        @ApiModelProperty(value = "단위")
102
+        private String unit;
103
+
104
+        @NotBlank
105
+        @ApiModelProperty(value = "구매요청수량")
106
+        private Integer pchReqQty;
107
+
108
+        @NotBlank
109
+        @ApiModelProperty(value = "구매요청금액")
110
+        private Integer pchReqAmt;
111
+
112
+        @NotBlank
113
+        @ApiModelProperty(value = "단가")
114
+        private Integer unitAmt;
115
+    }
116
+}

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

@@ -0,0 +1,118 @@
1
+package com.oqpo.api.web.dto.response.pomng.pchReq;
2
+
3
+import com.fasterxml.jackson.annotation.JsonInclude;
4
+import com.oqpo.api.entity.oper.FileEntity;
5
+import com.oqpo.api.entity.pomng.PchReqBaseInfoEntity;
6
+import com.oqpo.api.entity.pomng.PchReqDtlPtclEntity;
7
+import com.oqpo.api.entity.stinfo.BrandEntity;
8
+import io.swagger.annotations.ApiModelProperty;
9
+import lombok.*;
10
+
11
+import java.util.List;
12
+import java.util.stream.Collectors;
13
+
14
+
15
+@Getter
16
+@Setter
17
+@Builder
18
+@AllArgsConstructor(access = AccessLevel.PROTECTED)
19
+@JsonInclude(JsonInclude.Include.ALWAYS)
20
+public class PchReqInfoResponse {
21
+
22
+    @ApiModelProperty(value = "구매요청고유번호") private String pchReqUnqNo;
23
+    @ApiModelProperty(value = "브랜드아이디") private String brandId;
24
+    @ApiModelProperty(value = "브랜드명") private String brandNm;
25
+    @ApiModelProperty(value = "매장아이디") private String storeId;
26
+    @ApiModelProperty(value = "구매요청명") private String pchReqNm;
27
+    @ApiModelProperty(value = "구매요청부서") private String pchReqDept;
28
+    @ApiModelProperty(value = "구매요청자명") private String pchReqMgrNm;
29
+    @ApiModelProperty(value = "구매요청일자") private String pchReqDt;
30
+    @ApiModelProperty(value = "구매요청상태코드") private String pchReqStCd;
31
+    @ApiModelProperty(value = "구매요청상태명") private String pchReqStNm;
32
+    @ApiModelProperty(value = "구매요청구분") private String pchReqDvsn;
33
+    @ApiModelProperty(value = "비고") private String note;
34
+    @ApiModelProperty(value = "구매요청품목수량") private Integer pchReqItemQty;
35
+    @ApiModelProperty(value = "구매요청합계금액") private Integer pchReqTotalAmt;
36
+    @ApiModelProperty(value = "구매요청반려일자") private String pchReqRjctDt;
37
+    @ApiModelProperty(value = "구매요청반려자명") private String pchReqRjctNm;
38
+    @ApiModelProperty(value = "구매요청반려사유") private String pchReqRjctRsn;
39
+    @ApiModelProperty(value = "구매요청자아이디") private String pchReqMgrId;
40
+    @ApiModelProperty(value = "구매요청반려자아이디") private String pchReqRjctId;
41
+    @ApiModelProperty(value = "납기요청일") private String dlvReqDt;
42
+    @ApiModelProperty(value = "창고아이디") private String whsId;
43
+    @ApiModelProperty(value = "창고명") private String whsNm;
44
+    @ApiModelProperty(value = "창고상세위치") private String location;
45
+    @ApiModelProperty(value = "창고상세위치명") private String locationNm;
46
+    @ApiModelProperty(value = "시스템등록일시") private String sysRegDttm;
47
+    @ApiModelProperty(value = "시스템등록아이디") private String sysRegId;
48
+    @ApiModelProperty(value = "시스템변경일시") private String sysChgDttm;
49
+    @ApiModelProperty(value = "시스템변경아이디") private String sysChgId;
50
+
51
+
52
+    @ApiModelProperty(value = "구매요청 품목 정보")
53
+    private List<PchReqInfoResponse.PchReqDtlInfo> pchReqDtlList;
54
+
55
+    public static PchReqInfoResponse toDTO(PchReqBaseInfoEntity entity, List<PchReqDtlPtclEntity>  dtlEntityList) {
56
+        if (entity == null) return null;
57
+        return PchReqInfoResponse.builder()
58
+                .pchReqUnqNo(entity.getPchReqUnqNo())
59
+                .brandId(entity.getBrandId() == null ? "" :entity.getBrandId())
60
+                .brandNm(entity.getBrandNm() == null ? "" :entity.getBrandNm())
61
+                .storeId(entity.getStoreId() == null ? "" :entity.getStoreId())
62
+                .pchReqNm(entity.getPchReqNm() == null ? "" :entity.getPchReqNm())
63
+                .pchReqDept(entity.getPchReqDept() == null ? "" :entity.getPchReqDept())
64
+                .pchReqMgrNm(entity.getPchReqMgrNm() == null ? "" :entity.getPchReqMgrNm())
65
+                .pchReqDt(entity.getPchReqDt() == null ? "" :entity.getPchReqDt())
66
+                .pchReqStCd(entity.getPchReqStCd() == null ? "" :entity.getPchReqStCd())
67
+                .pchReqStNm(entity.getPchReqStNm() == null ? "" :entity.getPchReqStNm())
68
+                .pchReqDvsn(entity.getPchReqDvsn() == null ? "" :entity.getPchReqDvsn())
69
+                .note(entity.getNote() == null ? "" :entity.getNote())
70
+                .pchReqItemQty(entity.getPchReqItemQty() == null ? 0 :entity.getPchReqItemQty())
71
+                .pchReqTotalAmt(entity.getPchReqTotalAmt() == null ? 0 :entity.getPchReqTotalAmt())
72
+                .pchReqRjctDt(entity.getPchReqRjctDt() == null ? "" :entity.getPchReqRjctDt())
73
+                .pchReqRjctNm(entity.getPchReqRjctNm() == null ? "" :entity.getPchReqRjctNm())
74
+                .pchReqRjctRsn(entity.getPchReqRjctRsn() == null ? "" :entity.getPchReqRjctRsn() )
75
+                .pchReqMgrId(entity.getPchReqMgrId() == null ? "" :entity.getPchReqMgrId())
76
+                .pchReqRjctId(entity.getPchReqRjctId() == null ? "" :entity.getPchReqRjctId())
77
+                .dlvReqDt(entity.getDlvReqDt() == null ? "" :entity.getDlvReqDt())
78
+                .whsId(entity.getWhsId() == null ? "" :entity.getWhsId())
79
+                .whsNm(entity.getWhsNm() == null ? "" :entity.getWhsNm())
80
+                .location(entity.getLocation() == null ? "" :entity.getLocation())
81
+                .locationNm(entity.getLocationNm() == null ? "" :entity.getLocationNm())
82
+                .sysRegDttm(entity.getSysRegDttm() == null ? "" :entity.getSysRegDttm())
83
+                .sysRegId(entity.getSysRegId() == null ? "" :entity.getSysRegId())
84
+                .sysChgDttm(entity.getSysChgDttm() == null ? "" :entity.getSysChgDttm())
85
+                .sysChgId(entity.getSysChgId() == null ? "" :entity.getSysChgId())
86
+                .pchReqDtlList(dtlEntityList.stream()
87
+                        .map(m -> PchReqInfoResponse.PchReqDtlInfo.builder()
88
+                                .pchReqUnqNo(m.getPchReqUnqNo())
89
+                                .pchReqDtlNo(m.getPchReqDtlNo())
90
+                                .itemId(m.getItemId() == null ? "" :m.getItemId())
91
+                                .itemNm(m.getItemNm() == null ? "" :m.getItemNm())
92
+                                .unit(m.getUnit() == null ? "" :m.getUnit())
93
+                                .unitNm(m.getUnitNm() == null ? "" :m.getUnitNm())
94
+                                .pchReqQty(m.getPchReqQty() == null ? 0 :m.getPchReqQty())
95
+                                .pchReqAmt(m.getPchReqAmt() == null ? 0 :m.getPchReqAmt())
96
+                                .unitAmt(m.getUnitAmt() == null ? 0 :m.getUnitAmt())
97
+                                .build())
98
+                        .collect(Collectors.toList()))
99
+                .build();
100
+    }
101
+
102
+    @Getter
103
+    @Builder
104
+    @AllArgsConstructor(access = AccessLevel.PROTECTED)
105
+    static class PchReqDtlInfo {
106
+
107
+        @ApiModelProperty(value = "구매요청고유번호") private String pchReqUnqNo;
108
+        @ApiModelProperty(value = "구매요청상세번호") private String pchReqDtlNo;
109
+        @ApiModelProperty(value = "품목아이디") private String itemId;
110
+        @ApiModelProperty(value = "품목명") private String itemNm;
111
+        @ApiModelProperty(value = "단위") private String unit;
112
+        @ApiModelProperty(value = "단위명") private String unitNm;
113
+        @ApiModelProperty(value = "구매요청수량") private Integer pchReqQty;
114
+        @ApiModelProperty(value = "구매요청금액") private Integer pchReqAmt;
115
+        @ApiModelProperty(value = "단가금액") private Integer unitAmt;
116
+
117
+    }
118
+}

+ 62 - 0
src/main/java/com/oqpo/api/web/dto/response/pomng/pchReq/PchReqSearchListResponse.java

@@ -0,0 +1,62 @@
1
+package com.oqpo.api.web.dto.response.pomng.pchReq;
2
+
3
+import com.fasterxml.jackson.annotation.JsonInclude;
4
+import io.swagger.annotations.ApiModelProperty;
5
+import lombok.*;
6
+
7
+@Getter
8
+@Setter
9
+@Builder
10
+@AllArgsConstructor(access = AccessLevel.PROTECTED)
11
+@JsonInclude(JsonInclude.Include.ALWAYS)
12
+public class PchReqSearchListResponse {
13
+
14
+    @ApiModelProperty(value = "CRUD")
15
+    private String viewCd;
16
+
17
+    @ApiModelProperty(value = "구매요청고유번호")
18
+    private String pchReqUnqNo;
19
+
20
+    @ApiModelProperty(value = "브랜드아이디")
21
+    private String brandId;
22
+
23
+    @ApiModelProperty(value = "브랜드명")
24
+    private String brandNm;
25
+
26
+    @ApiModelProperty(value = "매장아이디")
27
+    private String storeId;
28
+
29
+    @ApiModelProperty(value = "구매요청명")
30
+    private String pchReqNm;
31
+
32
+    @ApiModelProperty(value = "구매요청일자")
33
+    private String pchReqDt;
34
+
35
+    @ApiModelProperty(value = "구매요청상태코드")
36
+    private String pchReqStCd;
37
+
38
+    @ApiModelProperty(value = "구매요청상태명")
39
+    private String pchReqStNm;
40
+
41
+    @ApiModelProperty(value = "구매요청품목수량")
42
+    private Integer pchReqItemQty;
43
+
44
+    @ApiModelProperty(value = "구매요청합계금액")
45
+    private Integer pchReqTotalAmt;
46
+
47
+    @ApiModelProperty(value = "구매요청반려일자")
48
+    private String pchReqRjctDt;
49
+
50
+    @ApiModelProperty(value = "구매요청반려자명")
51
+    private String pchReqRjctNm;
52
+
53
+    @ApiModelProperty(value = "구매요청자명")
54
+    private String pchReqMgrNm;
55
+
56
+    @ApiModelProperty(value = "납기요청일")
57
+    private String dlvReqDt;
58
+
59
+    @ApiModelProperty(value = "납품장소")
60
+    private String whsLocationNm;
61
+
62
+}

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

@@ -0,0 +1,188 @@
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.pomng.PchReqMapper">
5
+
6
+    <select id="selectPchReqGridList" resultType="com.oqpo.api.entity.pomng.PchReqBaseInfoEntity">
7
+        select  /* PchReq.selectPchReqGridList */
8
+                pch_req_unq_no, brand_id, fn_brand_nm(brand_id) as brand_nm,  pch_req_nm
9
+                ,pch_req_st_cd, fn_code_nm('PCH_REQ_ST_Cd',pch_req_st_cd) as pch_req_st_nm
10
+                , pch_req_mgr_nm, date_format(dlv_req_dt,'%Y.%m.%d') as dlv_req_dt, pch_req_total_amt
11
+                ,pch_req_item_qty, date_format(pch_req_rjct_dt,'%Y.%m.%d') as pch_req_rjct_dt, pch_req_rjct_nm
12
+                ,whs_id, fn_whs_nm(brand_id, whs_id) as whs_nm
13
+                ,location, fn_whs_location_nm(brand_id, whs_id, location) as location_nm
14
+        from   pch_req_base_info
15
+        where  brand_id = #{sBrandId}
16
+        and    date_format(sys_reg_dttm,'%Y%m%d') between #{fromDt} and #{toDt}
17
+        <if test="sWhsId != null and sWhsId != ''">
18
+            and    whs_id = #{sWhsId}
19
+        </if>
20
+        <if test="sPchReqStCd != null and sPchReqStCd != ''">
21
+            and    pch_req_st_cd = #{sPchReqStCd}
22
+        </if>
23
+        <if test="sItemNm != null and sItemNm != ''">
24
+            and    pch_req_unq_no in ( select pch_req_unq_no from pch_req_dtl_ptcl
25
+            where date_format(sys_reg_dttm,'%Y%m%d') between #{fromDt} and #{toDt})
26
+            and  item_id like concat('%',#{sItemNm},'%') or item_nm like concat('%',#{sItemNm},'%')
27
+        </if>
28
+        <choose>
29
+            <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
30
+                <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
31
+                    <if test="gridRequest.sord == 'asc'.toString()">
32
+                        order by pch_req_unq_no asc
33
+                    </if>
34
+                    <if test="gridRequest.sord == 'desc'.toString()">
35
+                        order by pch_req_unq_no desc
36
+                    </if>
37
+                </if>
38
+            </when>
39
+            <otherwise>
40
+                order by pch_req_unq_no desc
41
+            </otherwise>
42
+        </choose>
43
+        <if test="gridRequest.pagingYn == true">
44
+            limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
45
+        </if>
46
+    </select>
47
+
48
+    <select id="selectPchReqGridCnt" resultType="int">
49
+            select count(*) as cnt
50
+            from   pch_req_base_info
51
+            where  brand_id = #{sBrandId}
52
+            and    date_format(sys_reg_dttm,'%Y%m%d') between #{fromDt} and #{toDt}
53
+            <if test="sWhsId != null and sWhsId != ''">
54
+                and    whs_id = #{sWhsId}
55
+            </if>
56
+            <if test="sPchReqStCd != null and sPchReqStCd != ''">
57
+                and    pch_req_st_cd = #{sPchReqStCd}
58
+            </if>
59
+            <if test="sItemNm != null and sItemNm != ''">
60
+                and    pch_req_unq_no in ( select pch_req_unq_no from pch_req_dtl_ptcl
61
+                where date_format(sys_reg_dttm,'%Y%m%d') between #{fromDt} and #{toDt})
62
+                and  item_id like concat('%',#{sItemNm},'%') or item_nm like concat('%',#{sItemNm},'%')
63
+            </if>
64
+    </select>
65
+
66
+    <select id="selectPchReqInfo" resultType="com.oqpo.api.entity.pomng.PchReqBaseInfoEntity">
67
+        SELECT pch_req_unq_no, brand_id, fn_brand_nm(brand_id) as brand_nm, store_id, pch_req_nm, pch_req_dept
68
+            , 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
69
+            , 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
70
+            , pch_req_rjct_rsn, pch_req_mgr_id, pch_req_rjct_id
71
+            ,whs_id, fn_whs_nm(brand_id, whs_id) as whs_nm
72
+            ,location, fn_whs_location_nm(brand_id, whs_id, location) as location_nm
73
+            , DATE_FORMAT(dlv_req_dt ,'%Y.%m.%d')  as dlv_req_dt
74
+            , 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
75
+        FROM pch_req_base_info
76
+        WHERE brand_id = #{brandId}
77
+        and   pch_req_unq_no = #{pchReqUnqNo}
78
+    </select>
79
+
80
+    <select id="selectPchReqDtlPtcl" resultType="com.oqpo.api.entity.pomng.PchReqDtlPtclEntity">
81
+            SELECT pch_req_unq_no, pch_req_dtl_no, item_id, item_nm, unit, fn_code_nm('DSTRBT_COST_UNIT',unit) AS unit_nm
82
+                  , pch_req_qty, pch_req_amt, unit_amt
83
+            FROM pch_req_dtl_ptcl
84
+            WHERE pch_req_unq_no = #{pchReqUnqNo}
85
+    </select>
86
+
87
+
88
+    <insert id="insertPchReqBaseInfo" >
89
+        INSERT INTO /* PchReq.insertPchReqBaseInfo */ pch_req_base_info
90
+            (pch_req_unq_no, brand_id, store_id, pch_req_nm, pch_req_dept
91
+            , pch_req_mgr_nm, pch_req_dt, pch_req_tm, pch_req_st_cd, pch_req_dvsn
92
+            , note, pch_req_item_qty, pch_req_total_amt, pch_req_rjct_dt, pch_req_rjct_nm
93
+            , pch_req_rjct_rsn, pch_req_mgr_id, pch_req_rjct_id
94
+            , whs_id, location,dlv_req_dt
95
+            , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
96
+        VALUES
97
+            (#{entity.pchReqUnqNo}, #{entity.brandId}, #{entity.storeId}, #{entity.pchReqNm}, null
98
+            , #{userNm}, #{entity.pchReqDt}, null, #{entity.pchReqStCd}, null
99
+            , #{entity.note}, #{entity.pchReqItemQty}, #{entity.pchReqTotalAmt}, null, null
100
+            , null, #{userId}, null
101
+            , #{entity.whsId}, #{entity.location}, #{entity.dlvReqDt}
102
+            , NOW(), #{userId}, NOW(), #{userId})
103
+    </insert>
104
+
105
+    <update id="updateOrdPchReqBaseInfo">
106
+        UPDATE /* PchReq.updateOrdPchReqBaseInfo */
107
+            pch_req_base_info SET
108
+                pch_req_dt = #{entity.pchReqDt},
109
+                pch_req_st_cd = #{entity.pchReqStCd},
110
+                note = #{entity.note},
111
+                pch_req_item_qty = #{entity.pchReqItemQty},
112
+                pch_req_total_amt = #{entity.pchReqTotalAmt},
113
+                whs_id = #{entity.whsId},
114
+                location = #{entity.location},
115
+                dlv_req_dt = #{entity.dlvReqDt},
116
+                sys_chg_dttm = NOW(),
117
+                sys_chg_id = #{userId}
118
+            WHERE brand_id = #{entity.brandId}
119
+            and   pch_req_unq_no = #{entity.pchReqUnqNo}
120
+    </update>
121
+
122
+    <update id="updateRejPchReqBaseInfo">
123
+        UPDATE /* PchReq.updateOrdPchReqBaseInfo */
124
+            pch_req_base_info SET
125
+                pch_req_rjct_nm = #{entity.pchReqRjctNm},
126
+                pch_req_rjct_dt = date_format(noew(),'%Y%m%d'),
127
+                pch_req_rjct_rsn = #{entity.pchReqRjctRsn},
128
+                pch_req_rjct_id = #{userId},
129
+                sys_chg_dttm = NOW(),
130
+                sys_chg_id = #{userId}
131
+            WHERE pch_req_unq_no = #{entity.pchReqUnqNo}
132
+    </update>
133
+
134
+
135
+    <insert id="insertPchReqDtlPtcl" >
136
+        INSERT INTO /* PchReq.insertPchReqDtlPtcl */   pch_req_dtl_ptcl
137
+            (pch_req_unq_no, pch_req_dtl_no, item_nm, unit, pch_req_qty
138
+            , pch_req_amt, unit_amt
139
+            , item_id, sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
140
+        VALUES
141
+        <foreach collection="gridInsertData" item="item" separator=",">
142
+            (#{item.pchReqUnqNo}, #{item.pchReqDtlNo}, #{item.itemNm}, #{item.unit}, #{item.pchReqQty}
143
+            , #{item.pchReqAmt}, #{item.unitAmt}
144
+            , #{item.itemId} , NOW(), #{userId}, NOW(), #{userId})
145
+        </foreach>
146
+
147
+    </insert>
148
+
149
+    <update id="updatePchReqDtlPtcl">
150
+        <foreach collection="gridUpdateData" item="item" separator=";">
151
+            UPDATE /* PchReq.updatePchReqDtlPtcl */
152
+                pch_req_dtl_ptcl SET
153
+                    unit = #{item.unit},
154
+                    pch_req_qty = #{item.pchReqQty},
155
+                    pch_req_amt = #{item.pchReqAmt},
156
+                    unit_amt = #{item.unitAmt},
157
+                    sys_chg_dttm = NOW(),
158
+                    sys_chg_id = #{userId}
159
+            WHERE pch_req_unq_no = #{pchReqUnqNo}
160
+            AND pch_req_dtl_no = #{item.pchReqDtlNo}
161
+        </foreach>
162
+    </update>
163
+
164
+    <delete id="deletePchReqDtlPtcl">
165
+        DELETE  /* PchReq.deletePchReqDtlPtcl */
166
+            FROM pch_req_dtl_ptcl
167
+        WHERE pch_req_unq_no = #{pchReqUnqNo}
168
+        and    pch_req_dtl_no   in
169
+        <foreach collection="gridDeleteData" item="item" separator="," open="(" close=")">
170
+            #{item.pchReqDtlNo}
171
+        </foreach>
172
+
173
+    </delete>
174
+
175
+    <select id="selectMaxPchReqDtlNo" resultType="int">
176
+            SELECT nvl(Max(convert(conpch_req_dtl_no,int)),10)
177
+            FROM pch_req_dtl_ptcl
178
+            WHERE  pch_req_unq_no = #{pchReqUnqNo}
179
+    </select>
180
+
181
+    <select id="selectSumReqAmt" resultType="int">
182
+            select nvl(sum(pch_req_amt),0) as pch_req_amt
183
+            from  pch_req_dtl_ptcl
184
+            where pch_req_unq_no = #{pchReqUnqNo}
185
+    </select>
186
+
187
+
188
+</mapper>