瀏覽代碼

공급사 - 납품서생성 저장 및 매장단가관리 정보 수정

dwkim 2 年之前
父節點
當前提交
1a3a3c6aea

+ 2 - 1
src/main/java/com/oqpo/api/mapper/inoutmng/ShmtOdrMapper.java

@@ -35,5 +35,6 @@ public interface ShmtOdrMapper {
35 35
     List<PchOdrBaseInfoEntity> selectSpplyTargetOdrGridList(@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;
36 36
     int selectSpplyTargetOdrGridCnt(@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;
37 37
 
38
-
38
+    PchOdrBaseInfoEntity selectSpplyShmtOdrInfo(@Param("brandId") String brandId, @Param("spplyId") String spplyId, @Param("pchPodrUnqNo") String pchPodrUnqNo )throws Exception;
39
+    List<PchOdrDtlPtclEntity> selectSpplyShmtOdrList( @Param("pchPodrUnqNo") String pchPodrUnqNo )throws Exception;
39 40
 }

+ 131 - 4
src/main/java/com/oqpo/api/service/inoutmng/ShmtOdrService.java

@@ -28,11 +28,9 @@ import com.oqpo.api.service.CommonService;
28 28
 import com.oqpo.api.service.pomng.PchOrdService;
29 29
 import com.oqpo.api.web.dto.request.GridRequest;
30 30
 import com.oqpo.api.web.dto.request.inoutmng.InstShmtOdrRequest;
31
+import com.oqpo.api.web.dto.request.inoutmng.SaveSpplyDlvRequest;
31 32
 import com.oqpo.api.web.dto.response.GridResponse;
32
-import com.oqpo.api.web.dto.response.inoutmng.InvInfoResponse;
33
-import com.oqpo.api.web.dto.response.inoutmng.ShmtOdrSearchListResponse;
34
-import com.oqpo.api.web.dto.response.inoutmng.ShmtOutSearchListResponse;
35
-import com.oqpo.api.web.dto.response.inoutmng.SpplyTargerOdrSearchListResponse;
33
+import com.oqpo.api.web.dto.response.inoutmng.*;
36 34
 import com.oqpo.api.web.dto.response.pomng.pchOrd.SpplyPoOdrSearchListResponse;
37 35
 import lombok.extern.slf4j.Slf4j;
38 36
 import org.springframework.beans.factory.annotation.Autowired;
@@ -568,6 +566,135 @@ public class ShmtOdrService extends CommonService {
568 566
                 .collect(Collectors.toList());
569 567
         return GridResponse.toDTO(gridPage, gridTotal, gridRecords, gridRows);
570 568
     }
569
+
570
+
571
+    /* 공급사 납품서 생성 최기 정보 */
572
+    public SpplyInvInitResponse selectSpplyShmtOdrInfo(String brandId, String spplyId, String pchPodrUnqNo) throws Exception {
573
+        PchOdrBaseInfoEntity entity = shmtOdrMapper.selectSpplyShmtOdrInfo(brandId, spplyId, pchPodrUnqNo);
574
+        List<PchOdrDtlPtclEntity> dtlEntity = shmtOdrMapper.selectSpplyShmtOdrList(pchPodrUnqNo);
575
+
576
+        return SpplyInvInitResponse.toDTO(entity, dtlEntity);
577
+    }
578
+
579
+    /* 공급사 납품서 생성 저장 */
580
+    @Transactional
581
+    public void saveSpplyInv(String userId, SaveSpplyDlvRequest saveSpplyDlvRequest) throws Exception {
582
+        try {
583
+
584
+            List<PchOdrDtlPtclEntity> gridInsertData = saveSpplyDlvRequest.toCodeEntities(saveSpplyDlvRequest.getGridInsertData());
585
+            List<PchOdrBaseInfoEntity> jobList = shmtOdrMapper.selectShmtJobDataList(saveSpplyDlvRequest.getBrandId(), gridInsertData);
586
+            int shmtTotalAmt = 0;
587
+            String expryDate = "";
588
+            int shmtQty = 0;
589
+            String dlvSttmtUnqNo = "";
590
+
591
+            DeliInfoMgntEntity deliBaseEntity = new DeliInfoMgntEntity();
592
+            List<DeliDtlMgntEntity> deliDtlList = new ArrayList<DeliDtlMgntEntity>();
593
+
594
+            for (int i = 0; i < jobList.size(); i++) {
595
+                PchOdrBaseInfoEntity entity = jobList.get(i);
596
+
597
+                for (int j = 0; j < gridInsertData.size(); j++) {
598
+                    PchOdrDtlPtclEntity reqEntity = gridInsertData.get(j);
599
+                    if (entity.getPchPodrUnqNo().equals(reqEntity.getPchPodrUnqNo()) && entity.getPchOdrDtlInfo().getPchPodrDtlNo().equals(reqEntity.getPchPodrDtlNo())) {
600
+                        if (reqEntity.getShmtQty() > entity.getPchOdrDtlInfo().getPodrQty()) {
601
+                            // 발주수량보다 출고수량이 많을수 없습니다.
602
+                            throw new GlobalException(SystemMessageCode.ERR_POSHNONQTY);
603
+                        }
604
+
605
+                        if ("Y".equals(entity.getPchOdrDtlInfo().getExpryYn())) {
606
+                            if (reqEntity.getExpryDate() == null || "".equals(reqEntity.getExpryDate())) {
607
+                                // 유통기한을 입력해주세요!
608
+                                throw new GlobalException(SystemMessageCode.ERR_NONEXPRY);
609
+                            }
610
+                        }
611
+                        expryDate = reqEntity.getExpryDate().replaceAll("\\.", "");
612
+                        shmtQty = reqEntity.getShmtQty();
613
+
614
+                        break;
615
+                    }
616
+                }
617
+
618
+                shmtTotalAmt = shmtTotalAmt + (entity.getPchOdrDtlInfo().getUnitAmt() * shmtQty);
619
+                if (i == 0 ) {
620
+                    dlvSttmtUnqNo = fnGetDealNo(15, ""); // 납품서번호
621
+                    deliBaseEntity.setDlvSttmtUnqNo(dlvSttmtUnqNo);
622
+                    deliBaseEntity.setDlvSttmtUnqNo(dlvSttmtUnqNo);
623
+                    deliBaseEntity.setSpplyId(entity.getSpplyId());
624
+                    deliBaseEntity.setSpplyNm(entity.getSpplyNm());
625
+                    deliBaseEntity.setStoreId(entity.getStoreId());
626
+                    //deliBaseEntity.setDlvAmt(shmtTotalAmt);
627
+                    deliBaseEntity.setDlvMgrNm(saveSpplyDlvRequest.getDlvMgrNm());
628
+                    deliBaseEntity.setDlvMgrTelNo(saveSpplyDlvRequest.getDlvMgrTelNo().replaceAll("-", ""));
629
+                    deliBaseEntity.setDlvMgrEmal(null);
630
+                    deliBaseEntity.setDlvMgrMblNo(null);
631
+                    deliBaseEntity.setVndrTelNo(entity.getDeliTelNo().replaceAll("-", ""));
632
+                    deliBaseEntity.setDlvStCd("DLV0");
633
+                    deliBaseEntity.setPodrRegDt(entity.getPodrDt());
634
+                    deliBaseEntity.setDlvReqDt(entity.getDlvReqDt().replaceAll("\\.", ""));
635
+                    deliBaseEntity.setDlvSchDt(saveSpplyDlvRequest.getDlvSchDt().replaceAll("\\.", ""));
636
+                    deliBaseEntity.setDlvCmpltDt(null);
637
+                    deliBaseEntity.setWhsId(entity.getWhsId());
638
+                    deliBaseEntity.setLocation(entity.getLocation());
639
+                    if ("".equals(entity.getStoreId()) || entity.getStoreId() == null) {
640
+                        deliBaseEntity.setWhsDvsn("W01");
641
+                    } else {
642
+                        deliBaseEntity.setWhsDvsn("W02");
643
+                    }
644
+                    deliBaseEntity.setBrandId(saveSpplyDlvRequest.getBrandId());
645
+                }
646
+
647
+                int dtlNo = (i+1) * 10;
648
+
649
+                DeliDtlMgntEntity inaddDeliDtlEntity = new DeliDtlMgntEntity();
650
+                inaddDeliDtlEntity.setDlvSttmtUnqNo(dlvSttmtUnqNo);
651
+                inaddDeliDtlEntity.setDlvSttmtDtlNo(Integer.toString(dtlNo));
652
+                inaddDeliDtlEntity.setPchPodrUnqNo(entity.getPchPodrUnqNo());
653
+                inaddDeliDtlEntity.setPchPodrDtlNo(entity.getPchOdrDtlInfo().getPchPodrDtlNo());
654
+                inaddDeliDtlEntity.setPchReqUnqNo(entity.getPchOdrDtlInfo().getPchReqUnqNo());
655
+                inaddDeliDtlEntity.setPchReqDtlNo(entity.getPchOdrDtlInfo().getPchReqDtlNo());
656
+                inaddDeliDtlEntity.setItemId(entity.getPchOdrDtlInfo().getItemId());
657
+                inaddDeliDtlEntity.setItemNm(entity.getPchOdrDtlInfo().getItemNm());
658
+                inaddDeliDtlEntity.setUnit(entity.getPchOdrDtlInfo().getUnit());
659
+                inaddDeliDtlEntity.setUnitAmt(entity.getPchOdrDtlInfo().getUnitAmt());
660
+                inaddDeliDtlEntity.setPodrQty(entity.getPchOdrDtlInfo().getPodrQty());
661
+                inaddDeliDtlEntity.setDlvQty(shmtQty);
662
+                inaddDeliDtlEntity.setPodrAmt(entity.getPchOdrDtlInfo().getPodrAmt());
663
+                inaddDeliDtlEntity.setDlvAmt(shmtQty * entity.getPchOdrDtlInfo().getUnitAmt());
664
+                inaddDeliDtlEntity.setExpryDate(expryDate);
665
+
666
+                deliDtlList.add(inaddDeliDtlEntity);
667
+
668
+            }
669
+
670
+            deliBaseEntity.setDlvAmt(shmtTotalAmt);
671
+            shmtOdrMapper.insertDeliInfoMngt(userId, deliBaseEntity);
672
+            shmtOdrMapper.insertDeliDtlPtcl(userId, deliDtlList);
673
+
674
+            for (int poi = 0; poi < gridInsertData.size(); poi++) {
675
+                gridInsertData.get(poi).setPodrDtlStCd("POD3");
676
+            }
677
+            pchOrdMapper.updateChangeStPodrDtl(userId, gridInsertData);
678
+
679
+            // 발주 헤더 상태 처리  updateChgMultiPodrStCd
680
+            String pchPodrUnqNo = "";
681
+            for (int k = 0; k < gridInsertData.size(); k++) {
682
+                if (!pchPodrUnqNo.equals(gridInsertData.get(k).getPchPodrUnqNo())) {
683
+                    pchPodrUnqNo = gridInsertData.get(k).getPchPodrUnqNo();
684
+                    String pchOdrStCd = pchOrdService.selectOdrDtlStatusList(pchPodrUnqNo);
685
+                    pchOrdMapper.updateChgPodrStCd(userId, pchOdrStCd, pchPodrUnqNo);
686
+                }
687
+            }
688
+
689
+        } catch (GlobalException e) {
690
+            //e.getStackTrace();
691
+            e.printStackTrace();
692
+            throw new GlobalException(e.getSystemMessageCode());
693
+        } catch (Exception e) {
694
+            e.printStackTrace();
695
+            throw new RuntimeException();
696
+        }
697
+    }
571 698
 }
572 699
 
573 700
 

+ 8 - 2
src/main/java/com/oqpo/api/service/stinfo/ItemUnitService.java

@@ -266,8 +266,7 @@ public class ItemUnitService extends CommonService {
266 266
             StoreItemUnitEntity entity = new StoreItemUnitEntity();
267 267
             entity.setBrandId(saveStoreItemUnitInfolRequest.getBrandId());
268 268
             entity.setStoreId(saveStoreItemUnitInfolRequest.getStoreId());
269
-            entity.setContSttDt(saveStoreItemUnitInfolRequest.getContSttDt().replaceAll("\\.",""));
270
-            entity.setContEndDt(saveStoreItemUnitInfolRequest.getContEndDt().replaceAll("\\.",""));
269
+
271 270
 
272 271
             // 동일 단가계약일자 존재시
273 272
             String rcontEndDt = "";
@@ -284,6 +283,13 @@ public class ItemUnitService extends CommonService {
284 283
             List<StoreItemUnitEntity> gridUpdateData = saveStoreItemUnitInfolRequest.toCodeEntities(saveStoreItemUnitInfolRequest.getGridUpdateData());
285 284
             if (gridUpdateData.size() > 0) {
286 285
 
286
+                for (int k=0 ; k < gridUpdateData.size() ; k++ ) {
287
+                    String contSttDt =  gridUpdateData.get(k).getContSttDt().replaceAll("\\.","");
288
+                    String contEndDt =  gridUpdateData.get(k).getContEndDt().replaceAll("\\.","");
289
+                    gridUpdateData.get(k).setContSttDt( contSttDt );
290
+                    gridUpdateData.get(k).setContEndDt( contEndDt );
291
+                }
292
+
287 293
                 if (!"".equals(rcontEndDt)) {
288 294
                     for (int i = 0; i < gridUpdateData.size(); i++) {
289 295
                         gridUpdateData.get(i).setStoreUnitUnqNo("");

+ 41 - 4
src/main/java/com/oqpo/api/web/controller/inoutmng/ShmtOdrController.java

@@ -2,14 +2,12 @@ package com.oqpo.api.web.controller.inoutmng;
2 2
 
3 3
 import com.oqpo.api.enums.SystemMessageCode;
4 4
 import com.oqpo.api.service.inoutmng.ShmtOdrService;
5
-import com.oqpo.api.web.dto.request.inoutmng.InstShmtOdrRequest;
6
-import com.oqpo.api.web.dto.request.inoutmng.ShmtOdrTargetGridRequest;
7
-import com.oqpo.api.web.dto.request.inoutmng.ShmtOutSearchGridRequest;
8
-import com.oqpo.api.web.dto.request.inoutmng.SpplyOdrTargetGridRequest;
5
+import com.oqpo.api.web.dto.request.inoutmng.*;
9 6
 import com.oqpo.api.web.dto.request.pomng.pchOrd.SpplyOdrPoGridRequest;
10 7
 import com.oqpo.api.web.dto.response.GridResponse;
11 8
 import com.oqpo.api.web.dto.response.SaveResponse;
12 9
 import com.oqpo.api.web.dto.response.inoutmng.InvInfoResponse;
10
+import com.oqpo.api.web.dto.response.inoutmng.SpplyInvInitResponse;
13 11
 import io.swagger.annotations.Api;
14 12
 import io.swagger.annotations.ApiImplicitParam;
15 13
 import io.swagger.annotations.ApiImplicitParams;
@@ -120,4 +118,43 @@ public class ShmtOdrController {
120 118
         return ResponseEntity.ok(shmtOdrService.selectSpplyTargetOdrGridList(spplyOdrTargetGridRequest.getSBrandId(), spplyOdrTargetGridRequest.getFromDt(), spplyOdrTargetGridRequest.getToDt(), spplyOdrTargetGridRequest.getSSpplyId(), spplyOdrTargetGridRequest.getSWhsId(), spplyOdrTargetGridRequest.getSItemNm(),  spplyOdrTargetGridRequest.toDTO(spplyOdrTargetGridRequest)));
121 119
     }
122 120
 
121
+
122
+    /**
123
+     * 설명 : 공급사 발주데이타 납품서 생성 초기데이타
124
+     *
125
+     * @param brandId, dlvSttmtUnqNo
126
+     * @return
127
+     * @throws Exception
128
+     */
129
+    @ApiImplicitParams({
130
+            @ApiImplicitParam(name = "X-AUTH-TOKEN", value = "CONN-KEY", required = true, dataType = "String", paramType = "header"),
131
+            @ApiImplicitParam(name = "brandId", value = "브랜드번호", required = true, dataType = "String", paramType = "query"),
132
+            @ApiImplicitParam(name = "spplyId", value = "공급사아이디", required = true, dataType = "String", paramType = "query"),
133
+            @ApiImplicitParam(name = "pchPodrUnqNo", value = "구매발주번호", required = true, dataType = "String", paramType = "query")
134
+    })
135
+    @ApiOperation(value = "공급사 발주데이타 납품서 생성 초기데이타")
136
+    @GetMapping("/init-spply-inv")
137
+    public ResponseEntity<SpplyInvInitResponse> initSpplyInv(@RequestParam(value = "brandId") String brandId, @RequestParam(value = "spplyId") String spplyId, @RequestParam(value = "pchPodrUnqNo") String pchPodrUnqNo) throws Exception {
138
+        return ResponseEntity.ok(shmtOdrService.selectSpplyShmtOdrInfo(brandId,spplyId, pchPodrUnqNo));
139
+    }
140
+
141
+    /**
142
+     * 설명 : 공급사 납품서 생성 저장
143
+     *
144
+     * @param userId
145
+     * @param instShmtOdrRequest
146
+     * @return SaveResponse
147
+     * @throws Exception
148
+     */
149
+
150
+    @ApiImplicitParams({
151
+            @ApiImplicitParam(name = "X-AUTH-TOKEN", value = "CONN-KEY", required = true, dataType = "String", paramType = "header")
152
+    })
153
+    @ApiOperation(value = "공급사 납품서 생성 저장 저장")
154
+    @PostMapping("/save-spply-inv")
155
+    public ResponseEntity<SaveResponse> saveSpplyInv(@ApiIgnore String userId, @RequestBody @Valid SaveSpplyDlvRequest saveSpplyDlvRequest) throws Exception {
156
+        shmtOdrService.saveSpplyInv(userId,  saveSpplyDlvRequest);
157
+        return ResponseEntity.ok(SaveResponse.toDTO(SystemMessageCode.SAVE_OK));
158
+    }
159
+
123 160
 }

+ 74 - 0
src/main/java/com/oqpo/api/web/dto/request/inoutmng/SaveSpplyDlvRequest.java

@@ -0,0 +1,74 @@
1
+package com.oqpo.api.web.dto.request.inoutmng;
2
+
3
+import com.oqpo.api.entity.pomng.PchOdrDtlPtclEntity;
4
+import io.swagger.annotations.ApiModelProperty;
5
+import lombok.*;
6
+
7
+import javax.validation.constraints.NotBlank;
8
+import java.util.ArrayList;
9
+import java.util.List;
10
+
11
+@Getter
12
+@Setter
13
+public class SaveSpplyDlvRequest {
14
+    @NotBlank
15
+    @ApiModelProperty(value = "CRUD")
16
+    private String viewCd;
17
+
18
+    @NotBlank
19
+    @ApiModelProperty(value = "브랜드아이디") private String brandId;
20
+
21
+    @NotBlank
22
+    @ApiModelProperty(value = "공급사아이디") private String spplyId;
23
+
24
+    @NotBlank
25
+    @ApiModelProperty(value = "납품예정일") private String dlvSchDt;
26
+
27
+    @NotBlank
28
+    @ApiModelProperty(value = "납품담당자명") private String dlvMgrNm;
29
+
30
+    @NotBlank
31
+    @ApiModelProperty(value = "납품담당자연락처") private String dlvMgrTelNo;
32
+
33
+
34
+    @ApiModelProperty(value = "출하지시대상 리스트")
35
+    private List<InstShmtItemDataList> gridInsertData;
36
+
37
+
38
+    public List<PchOdrDtlPtclEntity> toCodeEntities(List<InstShmtItemDataList> gridData) {
39
+        List<PchOdrDtlPtclEntity> entities = new ArrayList<>();
40
+        if (gridData == null || gridData.size() == 0)
41
+            return entities;
42
+
43
+        gridData.forEach(x -> {
44
+            PchOdrDtlPtclEntity entity = new PchOdrDtlPtclEntity();
45
+            entity.setPchPodrUnqNo(x.getPchPodrUnqNo());
46
+            entity.setPchPodrDtlNo(x.getPchPodrDtlNo());
47
+            entity.setShmtQty(x.getShmtQty());
48
+            entity.setExpryDate(x.getExpryDate());
49
+            entities.add(entity);
50
+        });
51
+        return entities;
52
+    }
53
+
54
+    @Getter
55
+    @Builder
56
+    @AllArgsConstructor(access = AccessLevel.PROTECTED)
57
+    static class InstShmtItemDataList {
58
+
59
+        @NotBlank
60
+        @ApiModelProperty(value = "구매발주고유번호") private String pchPodrUnqNo;
61
+
62
+        @NotBlank
63
+        @ApiModelProperty(value = "구매발주항번") private String pchPodrDtlNo;
64
+
65
+        @NotBlank
66
+        @ApiModelProperty(value = "출하수량") private Integer shmtQty ;
67
+
68
+        @ApiModelProperty(value = "유통기한") private String  expryDate;
69
+
70
+        @ApiModelProperty(value = "비고") private String deliDesc ;
71
+
72
+
73
+    }
74
+}

+ 8 - 0
src/main/java/com/oqpo/api/web/dto/request/stinfo/itemUnit/SaveStoreItemUnitInfolRequest.java

@@ -53,6 +53,8 @@ public class SaveStoreItemUnitInfolRequest {
53 53
             entity.setItemId(x.getItemId());
54 54
             entity.setStddQty(x.getStddQty());
55 55
             entity.setBrandUnitUnqNo(x.getBrandUnitUnqNo());
56
+            entity.setContSttDt(x.getContSttDt());
57
+            entity.setContEndDt(x.getContEndDt());
56 58
             entities.add(entity);
57 59
         });
58 60
         return entities;
@@ -66,6 +68,12 @@ public class SaveStoreItemUnitInfolRequest {
66 68
         @ApiModelProperty(value = "매장단가고유번호")
67 69
         private String storeUnitUnqNo;
68 70
 
71
+        @ApiModelProperty(value = "계약시작일")
72
+        private String contSttDt;
73
+
74
+        @ApiModelProperty(value = "계약종료일")
75
+        private String contEndDt;
76
+
69 77
         @ApiModelProperty(value = "단위")
70 78
         private String unit;
71 79
 

+ 80 - 0
src/main/java/com/oqpo/api/web/dto/response/inoutmng/SpplyInvInitResponse.java

@@ -0,0 +1,80 @@
1
+package com.oqpo.api.web.dto.response.inoutmng;
2
+
3
+import com.fasterxml.jackson.annotation.JsonInclude;
4
+import com.oqpo.api.entity.inoutmng.DeliDtlMgntEntity;
5
+import com.oqpo.api.entity.inoutmng.DeliInfoMgntEntity;
6
+import com.oqpo.api.entity.oper.FileEntity;
7
+import com.oqpo.api.entity.pomng.PchOdrBaseInfoEntity;
8
+import com.oqpo.api.entity.pomng.PchOdrDtlPtclEntity;
9
+import io.swagger.annotations.ApiModelProperty;
10
+import lombok.*;
11
+
12
+import java.util.List;
13
+import java.util.stream.Collectors;
14
+
15
+
16
+@Getter
17
+@Setter
18
+@Builder
19
+@AllArgsConstructor(access = AccessLevel.PROTECTED)
20
+@JsonInclude(JsonInclude.Include.ALWAYS)
21
+public class SpplyInvInitResponse {
22
+
23
+    @ApiModelProperty(value = "브랜드아이디") private String brandId;
24
+    @ApiModelProperty(value = "브랜드명") private String brandNm;
25
+    @ApiModelProperty(value = "납품서생성일") private String dlvReqDt;
26
+    @ApiModelProperty(value = "납품총금액") private Integer podrTotalAmt;  // dlv_mgr_tel_no
27
+    @ApiModelProperty(value = "납품창고아이디") private String whsId;
28
+    @ApiModelProperty(value = "납품찿고명") private String whsNm;
29
+    @ApiModelProperty(value = "location") private String location;
30
+    @ApiModelProperty(value = "납품장소전화번호") private String deliTelNo;
31
+
32
+
33
+    @ApiModelProperty(value = "납품 품목 정보")
34
+    private List<InvPoDtlInfo> invPoInfoList;
35
+
36
+    public static SpplyInvInitResponse toDTO(PchOdrBaseInfoEntity entity, List<PchOdrDtlPtclEntity>  dtlList) {
37
+        if (entity == null) return null;
38
+        return SpplyInvInitResponse.builder()
39
+                .brandId(entity.getBrandId() == null ? "" : entity.getBrandId())
40
+                .brandNm(entity.getBrandNm() == null ? "" : entity.getBrandNm())
41
+                .dlvReqDt(entity.getDlvReqDt() == null ? "" : entity.getDlvReqDt())
42
+                .podrTotalAmt(entity.getPodrTotalAmt() == null ? 0  : entity.getPodrTotalAmt())
43
+                .whsId(entity.getWhsId() == null ? "" : entity.getWhsId())
44
+                .whsNm(entity.getWhsNm() == null ? "" : entity.getWhsNm() + "-" + entity.getLocationNm())
45
+                .location(entity.getLocation() == null ? "" : entity.getLocation())
46
+                .deliTelNo(entity.getDeliTelNo() == null ? "" : entity.getDeliTelNo())
47
+                .invPoInfoList(dtlList.stream()
48
+                        .map(m -> SpplyInvInitResponse.InvPoDtlInfo.builder()
49
+                                .pchPodrUnqNo(m.getPchPodrUnqNo() == null ? "" : m.getPchPodrUnqNo())
50
+                                .pchPodrDtlNo(m.getPchReqDtlNo() == null ? "" : m.getPchPodrDtlNo())
51
+                                .itemId(m.getItemId() == null ? "" :m.getItemId())
52
+                                .itemNm(m.getItemNm() == null ? "" :m.getItemNm())
53
+                                .unit(m.getUnit() == null ? "" : m.getUnit())
54
+                                .podrQty(m.getPodrQty() == null ? 0 :m.getPodrQty())
55
+                                .shmtQty(m.getShmtQty() == null ? 0 : m.getShmtQty())
56
+                                .expryYn(m.getExpryYn() == null ? "N" : m.getExpryYn())
57
+                                .expryPeriod(m.getExpryPeriod() == null ? 0 : m.getExpryPeriod())
58
+                                .expryDate(m.getExpryDate() == null ? "" : m.getExpryDate())
59
+                                .build())
60
+                        .collect(Collectors.toList()))
61
+                .build();
62
+    }
63
+
64
+    @Getter
65
+    @Builder
66
+    @AllArgsConstructor(access = AccessLevel.PROTECTED)
67
+    static class InvPoDtlInfo {
68
+        @ApiModelProperty(value = "구매발주번호") private String pchPodrUnqNo;
69
+        @ApiModelProperty(value = "구매발주항번") private String pchPodrDtlNo;
70
+        @ApiModelProperty(value = "품목아이디") private String itemId;
71
+        @ApiModelProperty(value = "품목명") private String itemNm;
72
+        @ApiModelProperty(value = "단위") private String unit;
73
+        @ApiModelProperty(value = "발주수량") private Integer podrQty;
74
+        @ApiModelProperty(value = "납품수량") private Integer shmtQty;
75
+        @ApiModelProperty(value = "유통기한여부") private String expryYn;
76
+        @ApiModelProperty(value = "유통기간") private Integer expryPeriod;
77
+        @ApiModelProperty(value = "유통일자") private String expryDate;
78
+    }
79
+
80
+}

+ 24 - 0
src/main/resources/mybatis/sqlmaps/inoutmng/ShmtOdr.xml

@@ -117,6 +117,7 @@
117 117
                 , base.store_id , base.podr_mgr_nm , base.podr_mgr_tel_no
118 118
                 , fn_get_telno((select tel_no from store_base_info where store_id = base.store_id )) as deli_tel_no
119 119
                 , date_format(base.podr_dt,'%Y%m%d') as podr_dt
120
+                , base.spply_id, fn_spply_nm(base.spply_id) as spply_nm
120 121
         from   pch_odr_base_info base
121 122
         join pch_odr_dtl_ptcl ptcl on base.pch_podr_unq_no = ptcl.pch_podr_unq_no and ptcl.podr_dtl_st_cd = 'POD0'
122 123
         join item_base_info itm on ptcl.item_id = itm.item_id
@@ -330,5 +331,28 @@
330 331
 
331 332
     </select>
332 333
 
334
+    <select id="selectSpplyShmtOdrInfo" resultType="com.oqpo.api.entity.pomng.PchOdrBaseInfoEntity">
335
+    select  base.brand_id, fn_brand_nm(base.brand_id) as brand_nm, base.pch_podr_unq_no, date_format(now(), '%Y.%m.%d') as dlv_req_dt
336
+        , (select sum(podr_amt) from  pch_odr_dtl_ptcl where pch_podr_unq_no = '22102500006015' and podr_dtl_st_cd = 'POD0' ) as podr_total_amt
337
+        , base.whs_id, fn_whs_nm(base.brand_id, base.whs_id) as whs_nm
338
+        , base.location, fn_whs_location_nm(brand_id, base.whs_id, base.location) as location_nm
339
+        , fn_get_telno((select tel_no from store_base_info where store_id = base.store_id )) as deli_tel_no
340
+    from    pch_odr_base_info base
341
+    where  1=1
342
+    and    base.brand_id = #{brandId}
343
+    and    base.spply_id = #{spplyId}
344
+    and    base.dlv_dvsn = 'DL02'
345
+    and    base.pch_podr_unq_no = #{pchPodrUnqNo}
346
+    </select>
347
+
348
+    <select id="selectSpplyShmtOdrList" resultType="com.oqpo.api.entity.pomng.PchOdrDtlPtclEntity">
349
+    select ptcl.pch_podr_unq_no, ptcl.pch_podr_dtl_no, ptcl.item_id, ptcl.item_nm, ptcl.unit, ptcl.podr_qty, ptcl.podr_qty as shmt_qty
350
+            ,itm.expry_yn as expry_yn, itm.expry_period as expry_period
351
+            , date_format(adddate(now(), interval itm.expry_period day),'%Y.%m.%d') as expry_date
352
+    from   pch_odr_dtl_ptcl ptcl
353
+    join   item_base_info itm on ptcl.item_id = itm.item_id
354
+    where  ptcl.pch_podr_unq_no = #{pchPodrUnqNo}
355
+    and    ptcl.podr_dtl_st_cd = 'POD0'
356
+    </select>
333 357
 
334 358
 </mapper>