瀏覽代碼

구발 간소화 발주 처리

dwkim 2 年之前
父節點
當前提交
fdfd3b2e3a

+ 1 - 0
src/main/java/com/oqpo/api/enums/SystemMessageCode.java

@@ -73,6 +73,7 @@ public enum SystemMessageCode {
73 73
     ERR_BO_STORE (40039, "매장정보를 찿을 수 없습니다.", HttpStatus.BAD_REQUEST),
74 74
     ERR_PG_FAIL (40040, "PG 결제 처리중 에러가 발생하였습니다.", HttpStatus.BAD_REQUEST),
75 75
     ERR_PCH_JOB_FAIL (40041, "임시저장 상태가 아닙니다.", HttpStatus.BAD_REQUEST),
76
+    ERR_NON_BASE_WHS (40042, "창고관리에서 기본창고를 지정해주세요!", HttpStatus.BAD_REQUEST),
76 77
     ;
77 78
 
78 79
 

+ 4 - 0
src/main/java/com/oqpo/api/mapper/inoutmng/ShmtOdrMapper.java

@@ -67,4 +67,8 @@ public interface ShmtOdrMapper {
67 67
     List<WhsProcInfoPtclEntity> selectWarehouseList(@Param("sBrandId") String sBrandId, @Param("sStoreId") String sStoreId, @Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("sPchPodrUnqNo") String sPchPodrUnqNo, @Param("sSpplyId") String sSpplyId, @Param("sWhsId") String sWhsId, @Param("sItemNm") String sItemNm, GridRequest gridRequest  )throws Exception;
68 68
     int selectWarehouseCnt(@Param("sBrandId") String sBrandId, @Param("sStoreId") String sStoreId,@Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("sPchPodrUnqNo") String sPchPodrUnqNo, @Param("sSpplyId") String sSpplyId, @Param("sWhsId") String sWhsId, @Param("sItemNm") String sItemNm  )throws Exception;
69 69
 
70
+
71
+    int insertStreamListShmtOdrBase(@Param("userId") String userId, List<ShmtOdrBaseEntity> gridInsertData)throws Exception;
72
+    int insertStreamListDeliInfoMngt(@Param("userId") String userId, List<DeliInfoMgntEntity> gridInsertData)throws Exception;
73
+
70 74
 }

+ 5 - 1
src/main/java/com/oqpo/api/mapper/pomng/PchOrdMapper.java

@@ -44,7 +44,11 @@ public interface PchOrdMapper {
44 44
     PchOdrBaseInfoEntity selectSpplyPchOdrInfo(@Param("brandId") String brandId, @Param("pchPodrUnqNo") String pchPodrUnqNo, @Param("spplyId") String spplyId);
45 45
     List<PchOdrDtlPtclEntity> selectSpplyOdrDtlList(@Param("brandId") String brandId, @Param("pchPodrUnqNo") String pchPodrUnqNo, @Param("spplyId") String spplyId);
46 46
 
47
-    List<PchOdrBaseInfoEntity> selectPchPoStreamlineList(@Param("brandId") String brandId, List<PchReqBaseInfoEntity> gridUpdateData)throws Exception;
47
+    int selectPchPoStreamlineBrandDlvChk(@Param("brandId") String brandId, List<PchReqBaseInfoEntity> gridUpdateData)throws Exception;
48 48
 
49
+    List<PchOdrBaseInfoEntity> selectPchPoStreamlineList(@Param("brandId") String brandId, @Param("pchReqUnqNo") String pchReqUnqNo) throws Exception;
49 50
 
51
+
52
+    int insertStreamListPchOdrBaseInfo(@Param("userId") String userId, List<PchOdrBaseInfoEntity> gridInsertData)throws Exception;
53
+    int insertStreamListPchOdrDtlPtcl(@Param("userId") String userId, List<PchOdrDtlPtclEntity> gridInsertData)throws Exception;
50 54
 }

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

@@ -84,4 +84,8 @@ public interface PchReqMapper {
84 84
 
85 85
     String selectPchReqStatProcYn(@Param("brandId") String brandId, @Param("pchReqUnqNo") String pchReqUnqNo )throws Exception;
86 86
 
87
+
88
+    int updateStreamListPchReqDtlStCd(@Param("userId") String userId, List<PchReqBaseInfoEntity> gridUpdateData) throws Exception;
89
+    int updateStreamListPchReqStCd(@Param("userId") String userId, List<PchReqBaseInfoEntity> gridUpdateData) throws Exception;
90
+
87 91
 }

+ 428 - 3
src/main/java/com/oqpo/api/service/pomng/PchOrdService.java

@@ -1,6 +1,10 @@
1 1
 package com.oqpo.api.service.pomng;
2 2
 
3 3
 
4
+import com.oqpo.api.entity.inoutmng.DeliDtlMgntEntity;
5
+import com.oqpo.api.entity.inoutmng.DeliInfoMgntEntity;
6
+import com.oqpo.api.entity.inoutmng.ShmtOdrBaseEntity;
7
+import com.oqpo.api.entity.inoutmng.ShmtOdrDtlEntity;
4 8
 import com.oqpo.api.entity.loanmng.LoanMgntBaseInfoEntity;
5 9
 import com.oqpo.api.entity.oper.UserMngEntity;
6 10
 import com.oqpo.api.entity.pomng.PchOdrBaseInfoEntity;
@@ -9,14 +13,20 @@ import com.oqpo.api.entity.pomng.PchReqBaseInfoEntity;
9 13
 import com.oqpo.api.entity.pomng.PchReqDtlPtclEntity;
10 14
 import com.oqpo.api.entity.rtnmng.RtnReqBaseInfoEntity;
11 15
 import com.oqpo.api.entity.stockmng.StckMgntBaseInfoEntity;
16
+import com.oqpo.api.entity.stockmng.StckMgntDtlHistEntity;
17
+import com.oqpo.api.entity.stockmng.WhsMgntBaseInfoEntity;
18
+import com.oqpo.api.enums.ChgDvsn;
19
+import com.oqpo.api.enums.InOutCd;
12 20
 import com.oqpo.api.enums.SystemMessageCode;
13 21
 import com.oqpo.api.exception.GlobalException;
22
+import com.oqpo.api.mapper.inoutmng.ShmtOdrMapper;
14 23
 import com.oqpo.api.mapper.loanmng.LoanStateMapper;
15 24
 import com.oqpo.api.mapper.oper.UserMngMapper;
16 25
 import com.oqpo.api.mapper.pomng.PchOrdMapper;
17 26
 import com.oqpo.api.mapper.pomng.PchReqMapper;
18 27
 import com.oqpo.api.mapper.stinfo.StoreBaseInfoMapper;
19 28
 import com.oqpo.api.mapper.stockmng.StockMngMapper;
29
+import com.oqpo.api.mapper.stockmng.WhsMngMapper;
20 30
 import com.oqpo.api.service.CommonService;
21 31
 import com.oqpo.api.web.dto.request.GridRequest;
22 32
 import com.oqpo.api.web.dto.request.pomng.pchOrd.*;
@@ -29,6 +39,7 @@ import org.springframework.beans.factory.annotation.Autowired;
29 39
 import org.springframework.stereotype.Service;
30 40
 import org.springframework.transaction.annotation.Transactional;
31 41
 
42
+import java.lang.reflect.Array;
32 43
 import java.util.ArrayList;
33 44
 import java.util.List;
34 45
 import java.util.stream.Collectors;
@@ -57,6 +68,12 @@ public class PchOrdService extends CommonService {
57 68
     @Autowired
58 69
     private PchReqService pchReqService;
59 70
 
71
+    @Autowired
72
+    private WhsMngMapper whsMngMapper;
73
+
74
+    @Autowired
75
+    private ShmtOdrMapper shmtOdrMapper;
76
+
60 77
 
61 78
 
62 79
     /* 구매요청건 발주 가능 여부 체크 */
@@ -248,7 +265,7 @@ public class PchOrdService extends CommonService {
248 265
             pchOrdEntity.setDlvReqDt(savePchOrdRequest.getDlvReqDt().replaceAll("\\.",""));
249 266
             pchOrdEntity.setPodrMgrNm(uEntity.getUserNm());
250 267
             pchOrdEntity.setPodrDvsn("OD01");
251
-            pchOrdEntity.setPchOdrStCd("PO001");
268
+            pchOrdEntity.setPchOdrStCd("PO20");
252 269
             pchOrdEntity.setSpplyId(savePchOrdRequest.getSpplyId());
253 270
             pchOrdEntity.setPodrMgrId(uEntity.getUserId());
254 271
             pchOrdEntity.setPodrMgrTelNo(uEntity.getTelNo());
@@ -629,16 +646,424 @@ public class PchOrdService extends CommonService {
629 646
                 throw new GlobalException(SystemMessageCode.ERR_NOTITEM);
630 647
             }
631 648
 
649
+            // 기본창고 여부 확인 (본사배송 건 존재시 기본창고 여부 확인 하여 없을 경우 오류 처리 있으면 그냥 진행
650
+            int brandDlvCnt = pchOrdMapper.selectPchPoStreamlineBrandDlvChk(savePchSteamlineOrdRequest.getBrandId(), gridInsertData);
651
+            WhsMgntBaseInfoEntity whsEntity = null ;
652
+
653
+            if (brandDlvCnt > 0 ) {
654
+                // 기본창고 및 로케이션 있는지 여부 확인
655
+                int baseWhsCnt = whsMngMapper.selectBaseWhsLocationCnt(savePchSteamlineOrdRequest.getBrandId()) ;
656
+
657
+                if (baseWhsCnt > 0 ) {
658
+                    whsEntity = whsMngMapper.selectBaseWhsLocationInfo(savePchSteamlineOrdRequest.getBrandId()) ;
659
+                } else {
660
+                    //오류 처리 (창고관리에서 기본창고를 지정해주세요!)
661
+                    throw new GlobalException(SystemMessageCode.ERR_NON_BASE_WHS);
662
+                }
663
+            }
664
+
665
+            //처리 내역 저장 구분
666
+            PchOdrBaseInfoEntity tempTargetBase =  null ; //new PchOdrBaseInfoEntity();
667
+            List<PchOdrBaseInfoEntity> tempTargetBaseList = new ArrayList<PchOdrBaseInfoEntity>();
668
+            PchOdrDtlPtclEntity tempTargetPtcl = null ; //new PchOdrDtlPtclEntity();
669
+            List<PchOdrDtlPtclEntity> tempTargetPtclList = new ArrayList<PchOdrDtlPtclEntity>();
670
+
671
+            ShmtOdrBaseEntity shmtBaseEntity = null ; //new ShmtOdrBaseEntity();
672
+            List<ShmtOdrBaseEntity> shmtBaseList = new ArrayList<ShmtOdrBaseEntity>();
673
+            ShmtOdrDtlEntity shmtOdrDtlEntity = null ; //new shmtOdrDtlEntity();
674
+            List<ShmtOdrDtlEntity> shmtDtlList = new ArrayList<ShmtOdrDtlEntity>();
675
+
676
+            DeliInfoMgntEntity deliBaseEntity = null; //new DeliInfoMgntEntity();
677
+            List<DeliInfoMgntEntity> deliBaseList = new ArrayList<DeliInfoMgntEntity>();
678
+            DeliDtlMgntEntity deliDtlEntity = null ; //new DeliDtlMgntEntity();
679
+            List<DeliDtlMgntEntity> deliDtlList = new ArrayList<DeliDtlMgntEntity>();
680
+
681
+            StckMgntBaseInfoEntity stckEntity = null;
682
+            List<StckMgntBaseInfoEntity> stockList = new ArrayList<StckMgntBaseInfoEntity>();
683
+
632 684
             for (int i = 0 ; i < gridInsertData.size() ; i++) {
685
+                PchReqBaseInfoEntity pchReqEntity = gridInsertData.get(i);
633 686
                 // 구매요청번호로 구매요청 내역 가져오기
634
-               // PchOdrBaseInfoEntity pchOrdEntity =
687
+                List<PchOdrBaseInfoEntity> pchOrdList = pchOrdMapper.selectPchPoStreamlineList(savePchSteamlineOrdRequest.getBrandId(),pchReqEntity.getPchReqUnqNo());
688
+
689
+                // 구매발주번호, 출하번호, 납품서번호
690
+                String preDlvDvsn = "";
691
+                String preSpplyId = "";
692
+                String pchPodrUnqNo = "";
693
+                String shmtReqUnqNo = ""; // 출하지시번호
694
+                String dlvSttmtUnqNo = ""; // 납품서번호
695
+                int dtlRow = 0 ;
696
+                long poTotAmt = 0 ;
697
+                int poItemCnt = 0 ;
698
+
699
+                for (int j = 0 ; j < pchOrdList.size() ; j++) {
700
+                    // 구매요청건에 대한 개별 처리 방안
701
+                    PchOdrBaseInfoEntity  podrEntity = pchOrdList.get(j);
702
+
703
+                    if (preDlvDvsn.equals(podrEntity.getDlvDvsn())) {
704
+                        if ("DL01".equals(podrEntity.getDlvDvsn())) {
705
+                            //본사배송 기존거와 동일
706
+                            tempTargetPtcl = new PchOdrDtlPtclEntity();
707
+                            tempTargetPtcl.setPchPodrUnqNo(pchPodrUnqNo);
708
+                            dtlRow = dtlRow + 10;
709
+                            tempTargetPtcl.setPchPodrDtlNo(Integer.toString(dtlRow));
710
+                            tempTargetPtcl.setPchReqUnqNo(podrEntity.getPchOdrDtlInfo().getPchReqUnqNo());
711
+                            tempTargetPtcl.setPchReqDtlNo(podrEntity.getPchOdrDtlInfo().getPchReqDtlNo());
712
+                            tempTargetPtcl.setItemId(podrEntity.getPchOdrDtlInfo().getItemId());
713
+                            tempTargetPtcl.setItemNm(podrEntity.getPchOdrDtlInfo().getItemNm());
714
+                            tempTargetPtcl.setPodrQty(podrEntity.getPchOdrDtlInfo().getPodrQty());
715
+                            tempTargetPtcl.setPodrAmt(podrEntity.getPchOdrDtlInfo().getPodrAmt());
716
+                            tempTargetPtcl.setCurr(podrEntity.getPchOdrDtlInfo().getCurr());
717
+                            tempTargetPtcl.setUnit(podrEntity.getPchOdrDtlInfo().getUnit());
718
+                            tempTargetPtcl.setUnitAmt(podrEntity.getPchOdrDtlInfo().getUnitAmt());
719
+                            tempTargetPtcl.setDlvSchDt(podrEntity.getPchOdrDtlInfo().getDlvSchDt());
720
+                            tempTargetPtcl.setStoreUnitUnqNo(podrEntity.getPchOdrDtlInfo().getStoreUnitUnqNo());
721
+                            tempTargetPtcl.setBrandUnitUnqNo(podrEntity.getPchOdrDtlInfo().getBrandUnitUnqNo());
722
+                            tempTargetPtclList.add(tempTargetPtcl);
723
+
724
+                            poTotAmt = poTotAmt + podrEntity.getPchOdrDtlInfo().getPodrAmt();
725
+                            poItemCnt = poItemCnt + 1;
726
+
727
+                            shmtOdrDtlEntity.setShmtReqUnqNo(shmtReqUnqNo);
728
+                            shmtOdrDtlEntity.setShmtReqDtlNo(Integer.toString(dtlRow));
729
+                            shmtOdrDtlEntity.setItemId(podrEntity.getPchOdrDtlInfo().getItemId());
730
+                            shmtOdrDtlEntity.setItemNm(podrEntity.getPchOdrDtlInfo().getItemNm());
731
+                            shmtOdrDtlEntity.setUnitAmt(podrEntity.getPchOdrDtlInfo().getUnitAmt());
732
+                            shmtOdrDtlEntity.setUnit(podrEntity.getPchOdrDtlInfo().getUnit());
733
+                            shmtOdrDtlEntity.setPodrQty(podrEntity.getPchOdrDtlInfo().getPodrQty());
734
+                            shmtOdrDtlEntity.setPodrAmt(podrEntity.getPchOdrDtlInfo().getPodrAmt());
735
+                            shmtOdrDtlEntity.setShmtQty(podrEntity.getPchOdrDtlInfo().getPodrQty());
736
+                            shmtOdrDtlEntity.setShmtAmt(podrEntity.getPchOdrDtlInfo().getPodrAmt());
737
+                            shmtOdrDtlEntity.setExpryDate("");
738
+                            shmtOdrDtlEntity.setPchPodrUnqNo(pchPodrUnqNo);
739
+                            shmtOdrDtlEntity.setPchPodrDtlNo(Integer.toString(dtlRow));
740
+                            shmtOdrDtlEntity.setPchReqUnqNo(podrEntity.getPchOdrDtlInfo().getPchReqUnqNo());
741
+                            shmtOdrDtlEntity.setPchReqDtlNo(podrEntity.getPchOdrDtlInfo().getPchReqDtlNo());
742
+                            shmtDtlList.add(shmtOdrDtlEntity);
743
+
744
+                            stckEntity = new StckMgntBaseInfoEntity();
745
+                            stckEntity.setBrandId(savePchSteamlineOrdRequest.getBrandId());
746
+                            stckEntity.setWhsId(whsEntity.getWhsId());
747
+                            stckEntity.setLocation(whsEntity.getLocationInfo().getLocation());
748
+                            stckEntity.setItemId(podrEntity.getPchOdrDtlInfo().getItemId());
749
+                            stckEntity.setStckQty(podrEntity.getPchOdrDtlInfo().getPodrQty());
750
+                            stckEntity.setWaitQty(0);
751
+                            stckEntity.setRelationNo(shmtReqUnqNo);
752
+                            stockList.add(stckEntity);
753
+
754
+                            deliDtlEntity.setDlvSttmtUnqNo(dlvSttmtUnqNo);
755
+                            deliDtlEntity.setDlvSttmtDtlNo(Integer.toString(dtlRow));
756
+                            deliDtlEntity.setPchPodrUnqNo(pchPodrUnqNo);
757
+                            deliDtlEntity.setPchPodrDtlNo(Integer.toString(dtlRow));
758
+                            deliDtlEntity.setPchReqUnqNo(podrEntity.getPchOdrDtlInfo().getPchReqUnqNo());
759
+                            deliDtlEntity.setPchReqDtlNo(podrEntity.getPchOdrDtlInfo().getPchReqDtlNo());
760
+                            deliDtlEntity.setItemId(podrEntity.getPchOdrDtlInfo().getItemId());
761
+                            deliDtlEntity.setItemNm(podrEntity.getPchOdrDtlInfo().getItemNm());
762
+                            deliDtlEntity.setUnit(podrEntity.getPchOdrDtlInfo().getUnit());
763
+                            deliDtlEntity.setUnitAmt(podrEntity.getPchOdrDtlInfo().getUnitAmt());
764
+                            deliDtlEntity.setPodrQty(podrEntity.getPchOdrDtlInfo().getPodrQty());
765
+                            deliDtlEntity.setDlvQty(podrEntity.getPchOdrDtlInfo().getPodrQty());
766
+                            deliDtlEntity.setPodrAmt(podrEntity.getPchOdrDtlInfo().getPodrAmt());
767
+                            deliDtlEntity.setDlvAmt(podrEntity.getPchOdrDtlInfo().getPodrAmt());
768
+                            deliDtlEntity.setShmtReqUnqNo(shmtReqUnqNo);
769
+                            deliDtlEntity.setShmtReqDtlNo(Integer.toString(dtlRow));
770
+                            deliDtlEntity.setExpryDate(null);
771
+                            deliDtlList.add(deliDtlEntity);
772
+
773
+                        } else {
774
+                            if (preSpplyId.equals(podrEntity.getSpplyId())) {
775
+                                //기존거와 동일
776
+                                tempTargetPtcl = new PchOdrDtlPtclEntity();
777
+                                tempTargetPtcl.setPchPodrUnqNo(pchPodrUnqNo);
778
+                                dtlRow = dtlRow + 10;
779
+                                tempTargetPtcl.setPchPodrDtlNo(Integer.toString(dtlRow));
780
+                                tempTargetPtcl.setPchReqUnqNo(podrEntity.getPchOdrDtlInfo().getPchReqUnqNo());
781
+                                tempTargetPtcl.setPchReqDtlNo(podrEntity.getPchOdrDtlInfo().getPchReqDtlNo());
782
+                                tempTargetPtcl.setItemId(podrEntity.getPchOdrDtlInfo().getItemId());
783
+                                tempTargetPtcl.setItemNm(podrEntity.getPchOdrDtlInfo().getItemNm());
784
+                                tempTargetPtcl.setPodrQty(podrEntity.getPchOdrDtlInfo().getPodrQty());
785
+                                tempTargetPtcl.setPodrAmt(podrEntity.getPchOdrDtlInfo().getPodrAmt());
786
+                                tempTargetPtcl.setCurr(podrEntity.getPchOdrDtlInfo().getCurr());
787
+                                tempTargetPtcl.setUnit(podrEntity.getPchOdrDtlInfo().getUnit());
788
+                                tempTargetPtcl.setUnitAmt(podrEntity.getPchOdrDtlInfo().getUnitAmt());
789
+                                tempTargetPtcl.setDlvSchDt(podrEntity.getPchOdrDtlInfo().getDlvSchDt());
790
+                                tempTargetPtcl.setStoreUnitUnqNo(podrEntity.getPchOdrDtlInfo().getStoreUnitUnqNo());
791
+                                tempTargetPtcl.setBrandUnitUnqNo(podrEntity.getPchOdrDtlInfo().getBrandUnitUnqNo());
792
+                                tempTargetPtclList.add(tempTargetPtcl);
793
+
794
+                                poTotAmt = poTotAmt + podrEntity.getPchOdrDtlInfo().getPodrAmt();
795
+                                poItemCnt = poItemCnt + 1;
796
+                            } else {
797
+                                //기존거와 상이
798
+                                if (!"".toString().equals(preDlvDvsn)) {
799
+                                    tempTargetBase.setPodrTotalAmt(poTotAmt);
800
+                                    tempTargetBase.setPodrItemQty(poItemCnt);
801
+                                    tempTargetBaseList.add(tempTargetBase);
802
+
803
+                                    if ("DL01".equals(preDlvDvsn)) {
804
+                                        shmtBaseEntity.setShmtTotalAmt(poTotAmt);
805
+                                        shmtBaseEntity.setItemQty(poItemCnt);
806
+                                        shmtBaseList.add(shmtBaseEntity);
807
+                                        deliBaseList.add(deliBaseEntity);
808
+                                    }
809
+                                }
810
+
811
+                                poTotAmt = 0 ;
812
+                                poItemCnt = 0 ;
813
+                                tempTargetBase = new PchOdrBaseInfoEntity();
814
+                                tempTargetPtcl = new PchOdrDtlPtclEntity();
815
+
816
+                                pchPodrUnqNo = fnGetDealNo(14,"");
817
+                                tempTargetBase.setPchPodrUnqNo(pchPodrUnqNo);
818
+                                preDlvDvsn = podrEntity.getDlvDvsn();
819
+                                tempTargetBase.setBrandId(savePchSteamlineOrdRequest.getBrandId());
820
+                                tempTargetBase.setStoreId(podrEntity.getStoreId());
821
+                                tempTargetBase.setSpplyId(podrEntity.getSpplyId());
822
+                                tempTargetBase.setDlvDvsn(podrEntity.getDlvDvsn());
823
+                                tempTargetBase.setDlvReqDt(podrEntity.getDlvReqDt());
824
+                                tempTargetBase.setPodrMgrNm(uEntity.getUserNm());
825
+                                tempTargetBase.setPodrDvsn(podrEntity.getPodrDvsn());
826
+                                tempTargetBase.setPodrMgrId(uEntity.getUserId());
827
+                                tempTargetBase.setPodrMgrTelNo(uEntity.getTelNo());
828
+                                tempTargetBase.setWhsDvsn(podrEntity.getWhsDvsn());
829
+                                tempTargetBase.setWhsId(podrEntity.getWhsId());
830
+                                tempTargetBase.setLocation(podrEntity.getLocation());
831
+
832
+                                tempTargetPtcl.setPchPodrUnqNo(pchPodrUnqNo);
833
+                                dtlRow = 10;
834
+                                // String dtlNo = Integer.toString(dtlRow);
835
+                                tempTargetPtcl.setPchPodrDtlNo(Integer.toString(dtlRow));
836
+                                tempTargetPtcl.setPchReqUnqNo(podrEntity.getPchOdrDtlInfo().getPchReqUnqNo());
837
+                                tempTargetPtcl.setPchReqDtlNo(podrEntity.getPchOdrDtlInfo().getPchReqDtlNo());
838
+                                tempTargetPtcl.setItemId(podrEntity.getPchOdrDtlInfo().getItemId());
839
+                                tempTargetPtcl.setItemNm(podrEntity.getPchOdrDtlInfo().getItemNm());
840
+                                tempTargetPtcl.setPodrQty(podrEntity.getPchOdrDtlInfo().getPodrQty());
841
+                                tempTargetPtcl.setPodrAmt(podrEntity.getPchOdrDtlInfo().getPodrAmt());
842
+                                tempTargetPtcl.setCurr(podrEntity.getPchOdrDtlInfo().getCurr());
843
+                                tempTargetPtcl.setUnit(podrEntity.getPchOdrDtlInfo().getUnit());
844
+                                tempTargetPtcl.setUnitAmt(podrEntity.getPchOdrDtlInfo().getUnitAmt());
845
+                                tempTargetPtcl.setDlvSchDt(podrEntity.getPchOdrDtlInfo().getDlvSchDt());
846
+                                tempTargetPtcl.setStoreUnitUnqNo(podrEntity.getPchOdrDtlInfo().getStoreUnitUnqNo());
847
+                                tempTargetPtcl.setBrandUnitUnqNo(podrEntity.getPchOdrDtlInfo().getBrandUnitUnqNo());
848
+                                tempTargetPtclList.add(tempTargetPtcl);
849
+
850
+                                poTotAmt = poTotAmt + podrEntity.getPchOdrDtlInfo().getPodrAmt();
851
+                                poItemCnt = poItemCnt + 1;
852
+                            }
853
+                        }
854
+                    } else {
855
+                        // 서로 상이할경우
856
+                        if (!"".toString().equals(preDlvDvsn)) {
857
+                            tempTargetBase.setPodrTotalAmt(poTotAmt);
858
+                            tempTargetBase.setPodrItemQty(poItemCnt);
859
+                            tempTargetBaseList.add(tempTargetBase);
860
+
861
+                            if ("DL01".equals(preDlvDvsn)) {
862
+                                shmtBaseEntity.setShmtTotalAmt(poTotAmt);
863
+                                shmtBaseEntity.setItemQty(poItemCnt);
864
+                                shmtBaseList.add(shmtBaseEntity);
865
+                                deliBaseList.add(deliBaseEntity);
866
+                            }
867
+                        }
868
+
869
+                        poTotAmt = 0 ;
870
+                        poItemCnt = 0 ;
871
+                        tempTargetBase = new PchOdrBaseInfoEntity();
872
+                        tempTargetPtcl = new PchOdrDtlPtclEntity();
873
+
874
+
875
+                        // 이미등록건 업데이트 처리
876
+                        pchPodrUnqNo = fnGetDealNo(14,"");
877
+                        tempTargetBase.setPchPodrUnqNo(pchPodrUnqNo);
878
+                        preDlvDvsn = podrEntity.getDlvDvsn();
879
+                        tempTargetBase.setBrandId(savePchSteamlineOrdRequest.getBrandId());
880
+                        tempTargetBase.setStoreId(podrEntity.getStoreId());
881
+                        tempTargetBase.setSpplyId(podrEntity.getSpplyId());
882
+                        tempTargetBase.setDlvDvsn(podrEntity.getDlvDvsn());
883
+                        tempTargetBase.setDlvReqDt(podrEntity.getDlvReqDt());
884
+                        tempTargetBase.setPodrMgrNm(uEntity.getUserNm());
885
+                        tempTargetBase.setPodrDvsn(podrEntity.getPodrDvsn());
886
+                        tempTargetBase.setPodrMgrId(uEntity.getUserId());
887
+                        tempTargetBase.setPodrMgrTelNo(uEntity.getTelNo());
888
+                        tempTargetBase.setWhsDvsn(podrEntity.getWhsDvsn());
889
+                        tempTargetBase.setWhsId(podrEntity.getWhsId());
890
+                        tempTargetBase.setLocation(podrEntity.getLocation());
891
+
892
+                        tempTargetPtcl.setPchPodrUnqNo(pchPodrUnqNo);
893
+                        dtlRow = 10;
894
+                       // String dtlNo = Integer.toString(dtlRow);
895
+                        tempTargetPtcl.setPchPodrDtlNo(Integer.toString(dtlRow));
896
+                        tempTargetPtcl.setPchReqUnqNo(podrEntity.getPchOdrDtlInfo().getPchReqUnqNo());
897
+                        tempTargetPtcl.setPchReqDtlNo(podrEntity.getPchOdrDtlInfo().getPchReqDtlNo());
898
+                        tempTargetPtcl.setItemId(podrEntity.getPchOdrDtlInfo().getItemId());
899
+                        tempTargetPtcl.setItemNm(podrEntity.getPchOdrDtlInfo().getItemNm());
900
+                        tempTargetPtcl.setPodrQty(podrEntity.getPchOdrDtlInfo().getPodrQty());
901
+                        tempTargetPtcl.setPodrAmt(podrEntity.getPchOdrDtlInfo().getPodrAmt());
902
+                        tempTargetPtcl.setCurr(podrEntity.getPchOdrDtlInfo().getCurr());
903
+                        tempTargetPtcl.setUnit(podrEntity.getPchOdrDtlInfo().getUnit());
904
+                        tempTargetPtcl.setUnitAmt(podrEntity.getPchOdrDtlInfo().getUnitAmt());
905
+                        tempTargetPtcl.setDlvSchDt(podrEntity.getPchOdrDtlInfo().getDlvSchDt());
906
+                        tempTargetPtcl.setStoreUnitUnqNo(podrEntity.getPchOdrDtlInfo().getStoreUnitUnqNo());
907
+                        tempTargetPtcl.setBrandUnitUnqNo(podrEntity.getPchOdrDtlInfo().getBrandUnitUnqNo());
908
+                        tempTargetPtclList.add(tempTargetPtcl);
909
+
910
+                        poTotAmt = poTotAmt + podrEntity.getPchOdrDtlInfo().getPodrAmt();
911
+                        poItemCnt = poItemCnt + 1;
912
+
913
+                        //본사배송일경우 출하지시 , 납품서 생성 처리함
914
+                        if ("DL01".equals(podrEntity.getDlvDvsn())) {
915
+
916
+                            tempTargetBase.setPchOdrStCd("PO30");
917
+                            tempTargetPtcl.setPodrDtlStCd("POD3");
918
+
919
+                            shmtBaseEntity = new ShmtOdrBaseEntity();
920
+                            shmtOdrDtlEntity = new ShmtOdrDtlEntity();
921
+                            deliBaseEntity = new DeliInfoMgntEntity();
922
+                            deliDtlEntity = new DeliDtlMgntEntity();
923
+
924
+                            // 출하지시 처리
925
+                            shmtReqUnqNo = fnGetDealNo(16, "");  // 출하지시번호
926
+                            shmtBaseEntity.setShmtReqUnqNo(shmtReqUnqNo);
927
+                            shmtBaseEntity.setShmtReqStCd("SHM1");
928
+                            shmtBaseEntity.setShmtWhsId(whsEntity.getWhsId());
929
+                            shmtBaseEntity.setShmtLocation(whsEntity.getLocationInfo().getLocation());
930
+                            shmtBaseEntity.setWhsDvsn("W01");
931
+                            shmtBaseEntity.setBrandId(savePchSteamlineOrdRequest.getBrandId());
932
+                            shmtBaseEntity.setStoreId(podrEntity.getStoreId());
933
+                            shmtBaseEntity.setPodrDvsn("OD01");
934
+                            shmtBaseEntity.setPodrMgrNm(uEntity.getUserNm());
935
+                            shmtBaseEntity.setDlvReqDt(podrEntity.getDlvReqDt());
936
+                            shmtBaseEntity.setWhsId(podrEntity.getWhsId());
937
+                            shmtBaseEntity.setLocation(podrEntity.getLocation());
938
+
939
+                            shmtOdrDtlEntity.setShmtReqUnqNo(shmtReqUnqNo);
940
+                            shmtOdrDtlEntity.setShmtReqDtlNo(Integer.toString(dtlRow));
941
+                            shmtOdrDtlEntity.setItemId(podrEntity.getPchOdrDtlInfo().getItemId());
942
+                            shmtOdrDtlEntity.setItemNm(podrEntity.getPchOdrDtlInfo().getItemNm());
943
+                            shmtOdrDtlEntity.setUnitAmt(podrEntity.getPchOdrDtlInfo().getUnitAmt());
944
+                            shmtOdrDtlEntity.setUnit(podrEntity.getPchOdrDtlInfo().getUnit());
945
+                            shmtOdrDtlEntity.setPodrQty(podrEntity.getPchOdrDtlInfo().getPodrQty());
946
+                            shmtOdrDtlEntity.setPodrAmt(podrEntity.getPchOdrDtlInfo().getPodrAmt());
947
+                            shmtOdrDtlEntity.setShmtQty(podrEntity.getPchOdrDtlInfo().getPodrQty());
948
+                            shmtOdrDtlEntity.setShmtAmt(podrEntity.getPchOdrDtlInfo().getPodrAmt());
949
+                            shmtOdrDtlEntity.setExpryDate("");
950
+                            shmtOdrDtlEntity.setPchPodrUnqNo(pchPodrUnqNo);
951
+                            shmtOdrDtlEntity.setPchPodrDtlNo(Integer.toString(dtlRow));
952
+                            shmtOdrDtlEntity.setPchReqUnqNo(podrEntity.getPchOdrDtlInfo().getPchReqUnqNo());
953
+                            shmtOdrDtlEntity.setPchReqDtlNo(podrEntity.getPchOdrDtlInfo().getPchReqDtlNo());
954
+                            shmtDtlList.add(shmtOdrDtlEntity);
955
+
956
+                            stckEntity = new StckMgntBaseInfoEntity();
957
+                            stckEntity.setBrandId(savePchSteamlineOrdRequest.getBrandId());
958
+                            stckEntity.setWhsId(whsEntity.getWhsId());
959
+                            stckEntity.setLocation(whsEntity.getLocationInfo().getLocation());
960
+                            stckEntity.setItemId(podrEntity.getPchOdrDtlInfo().getItemId());
961
+                            stckEntity.setStckQty(podrEntity.getPchOdrDtlInfo().getPodrQty());
962
+                            stckEntity.setWaitQty(0);
963
+                            stckEntity.setRelationNo(shmtReqUnqNo);
964
+                            stockList.add(stckEntity);
965
+
966
+                            // 납품서 처리
967
+                            dlvSttmtUnqNo = fnGetDealNo(15, ""); // 납품서번호
968
+                            deliBaseEntity.setDlvSttmtUnqNo(dlvSttmtUnqNo);
969
+                            deliBaseEntity.setSpplyId(null);
970
+                            deliBaseEntity.setSpplyNm(null);
971
+                            deliBaseEntity.setStoreId(podrEntity.getStoreId());
972
+                            deliBaseEntity.setDlvMgrNm(uEntity.getUserNm());
973
+                            deliBaseEntity.setDlvMgrTelNo(uEntity.getTelNo());
974
+                            deliBaseEntity.setDlvMgrEmal(null);
975
+                            deliBaseEntity.setDlvMgrMblNo(uEntity.getTelNo());
976
+                            //deliBaseEntity.setVndrTelNo(entity.getDeliTelNo().replaceAll("-", ""));
977
+                            deliBaseEntity.setDlvStCd("DLV0");
978
+                            deliBaseEntity.setPodrRegDt(podrEntity.getPodrDt());
979
+                            deliBaseEntity.setDlvReqDt(podrEntity.getPodrDt());
980
+                            deliBaseEntity.setDlvSchDt(podrEntity.getPodrDt());
981
+                            deliBaseEntity.setDlvCmpltDt(null);
982
+                            deliBaseEntity.setWhsId(podrEntity.getWhsId());
983
+                            deliBaseEntity.setLocation(podrEntity.getLocation());
984
+                            deliBaseEntity.setWhsDvsn("W02");
985
+                            deliBaseEntity.setBrandId(savePchSteamlineOrdRequest.getBrandId());
986
+
987
+                            deliDtlEntity.setDlvSttmtUnqNo(dlvSttmtUnqNo);
988
+                            deliDtlEntity.setDlvSttmtDtlNo(Integer.toString(dtlRow));
989
+                            deliDtlEntity.setPchPodrUnqNo(pchPodrUnqNo);
990
+                            deliDtlEntity.setPchPodrDtlNo(Integer.toString(dtlRow));
991
+                            deliDtlEntity.setPchReqUnqNo(podrEntity.getPchOdrDtlInfo().getPchReqUnqNo());
992
+                            deliDtlEntity.setPchReqDtlNo(podrEntity.getPchOdrDtlInfo().getPchReqDtlNo());
993
+                            deliDtlEntity.setItemId(podrEntity.getPchOdrDtlInfo().getItemId());
994
+                            deliDtlEntity.setItemNm(podrEntity.getPchOdrDtlInfo().getItemNm());
995
+                            deliDtlEntity.setUnit(podrEntity.getPchOdrDtlInfo().getUnit());
996
+                            deliDtlEntity.setUnitAmt(podrEntity.getPchOdrDtlInfo().getUnitAmt());
997
+                            deliDtlEntity.setPodrQty(podrEntity.getPchOdrDtlInfo().getPodrQty());
998
+                            deliDtlEntity.setDlvQty(podrEntity.getPchOdrDtlInfo().getPodrQty());
999
+                            deliDtlEntity.setPodrAmt(podrEntity.getPchOdrDtlInfo().getPodrAmt());
1000
+                            deliDtlEntity.setDlvAmt(podrEntity.getPchOdrDtlInfo().getPodrAmt());
1001
+                            deliDtlEntity.setShmtReqUnqNo(shmtReqUnqNo);
1002
+                            deliDtlEntity.setShmtReqDtlNo(Integer.toString(dtlRow));
1003
+                            deliDtlEntity.setExpryDate(null);
1004
+                            deliDtlList.add(deliDtlEntity);
1005
+
1006
+                        } else {
1007
+                            tempTargetBase.setPchOdrStCd("PO20");
1008
+                            tempTargetPtcl.setPodrDtlStCd("POD1");
1009
+                        }
1010
+                    }
635 1011
 
1012
+                    //마지막 부분 추가 하기
1013
+                    if (j == pchOrdList.size()-1) {
1014
+                        tempTargetBase.setPodrTotalAmt(poTotAmt);
1015
+                        tempTargetBase.setPodrItemQty(poItemCnt);
1016
+                        tempTargetBaseList.add(tempTargetBase);
1017
+                        if ("DL01".equals(preDlvDvsn)) {
1018
+                            shmtBaseEntity.setShmtTotalAmt(poTotAmt);
1019
+                            shmtBaseEntity.setItemQty(poItemCnt);
1020
+                            shmtBaseList.add(shmtBaseEntity);
1021
+                            deliBaseList.add(deliBaseEntity);
1022
+                        }
1023
+                    }
1024
+
1025
+                }  // 구매요청건 개별 종료
636 1026
 
637 1027
             } // for문 종료
638 1028
 
1029
+            // 발주 생성
1030
+            pchOrdMapper.insertStreamListPchOdrBaseInfo(userId, tempTargetBaseList);
1031
+            pchOrdMapper.insertStreamListPchOdrDtlPtcl(userId, tempTargetPtclList);
1032
+            //구매요청 상태 업데이트
1033
+            pchReqMapper.updateStreamListPchReqDtlStCd(userId,gridInsertData );
1034
+            pchReqMapper.updateStreamListPchReqStCd(userId,gridInsertData );
1035
+
1036
+            // 출하지시생성
1037
+            if (shmtBaseList.size() > 0 ) {
1038
+                // 출하지시, 납품서 등록 및 재고 처리
1039
+                shmtOdrMapper.insertStreamListShmtOdrBase(userId, shmtBaseList);
1040
+                shmtOdrMapper.insertShmtOdrDtl(userId, shmtDtlList);
1041
+                shmtOdrMapper.insertStreamListDeliInfoMngt(userId, deliBaseList);
1042
+                shmtOdrMapper.insertDeliDtlPtcl(userId, deliDtlList);
1043
+
1044
+                stockMngMapper.updateMinStockQty(userId, stockList);
1045
+                List<StckMgntDtlHistEntity> stockHistList = new ArrayList<StckMgntDtlHistEntity>();
1046
+                for (int m = 0; m < stockList.size(); m++) {
1047
+                    StckMgntBaseInfoEntity baseEntity = stockList.get(m);
1048
+                    StckMgntDtlHistEntity sourceHist = new StckMgntDtlHistEntity();
1049
+                    sourceHist.setStckMgntDtlNo(fnGetDealNo(32, "")); // 재고관리상세번호
1050
+                    sourceHist.setBrandId(baseEntity.getBrandId());
1051
+                    sourceHist.setWhsId(baseEntity.getWhsId());
1052
+                    sourceHist.setLocation(baseEntity.getLocation());
1053
+                    sourceHist.setItemId(baseEntity.getItemId());
1054
+                    sourceHist.setItemNm(baseEntity.getItemNm());
1055
+                    sourceHist.setInoutCd(InOutCd.OUT.getCd()); // 출고
1056
+                    sourceHist.setInoutQty(baseEntity.getStckQty());
1057
+                    sourceHist.setChgDvsn(ChgDvsn.PURCHASE_OUT.getCd()); // 구매출고
1058
+                    sourceHist.setRelationNo(baseEntity.getRelationNo());
1059
+                    stockHistList.add(sourceHist);
1060
+                }
1061
+                stockMngMapper.insertMultiStckMgntDtlHist(userId, stockHistList);
1062
+            }
639 1063
 
640 1064
 
641
-        } catch (GlobalException e) {
1065
+
1066
+       } catch (GlobalException e) {
642 1067
             //e.getStackTrace();
643 1068
             e.printStackTrace();
644 1069
             throw new GlobalException(e.getSystemMessageCode());

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

@@ -848,4 +848,37 @@
848 848
             and (whs.item_id like concat('%', #{sItemNm}, '%') or whs.item_nm like concat('%', #{sItemNm}, '%'))
849 849
         </if>
850 850
     </select>
851
+
852
+
853
+    <insert id="insertStreamListShmtOdrBase">
854
+        insert into shmt_odr_base_info
855
+            (shmt_req_unq_no, shmt_req_st_cd, shmt_reg_dt, shmt_whs_id, shmt_location
856
+            , whs_dvsn, brand_id, store_id, podr_dvsn, item_qty
857
+            , shmt_total_amt,  podr_mgr_nm, dlv_req_dt, whs_id, location
858
+            , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
859
+        values
860
+        <foreach collection="gridInsertData" item="item" separator=",">
861
+            (#{item.shmtReqUnqNo}, #{item.shmtReqStCd}, date_format(now(),'%Y%m%d'), #{item.shmtWhsId}, #{item.shmtLocation}
862
+            , #{item.whsDvsn}, #{item.brandId}, #{item.storeId}, #{item.podrDvsn}, #{item.itemQty}
863
+            , #{item.shmtTotalAmt}, #{item.podrMgrNm}, #{item.dlvReqDt}, #{item.whsId}
864
+            , #{item.location}, NOW(), #{userId}, NOW(), #{userId})
865
+        </foreach>
866
+    </insert>
867
+
868
+    <insert id="insertStreamListDeliInfoMngt">
869
+        INSERT INTO deli_info_mgnt
870
+        (dlv_sttmt_unq_no, spply_id, spply_nm, dlv_reg_dt, dlv_amt
871
+        , dlv_mgr_nm, dlv_mgr_tel_no, dlv_mgr_emal, dlv_mgr_mbl_no, vndr_tel_no
872
+        , dlv_st_cd, podr_reg_dt, dlv_req_dt, dlv_sch_dt, dlv_cmplt_dt
873
+        , whs_id, location, whs_dvsn, brand_id,store_id
874
+        , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
875
+        VALUES
876
+        <foreach collection="gridInsertData" item="item" separator=",">
877
+        (#{item.dlvSttmtUnqNo}, #{item.spplyId}, #{item.spplyNm}, date_format(now(),'%Y%m%d'), #{item.dlvAmt}
878
+        , #{item.dlvMgrNm}, #{item.dlvMgrTelNo}, #{item.dlvMgrEmal}, #{item.dlvMgrMblNo}, #{item.vndrTelNo}
879
+        , #{item.dlvStCd}, #{item.podrRegDt}, #{item.dlvReqDt}, #{item.dlvSchDt}, #{item.dlvCmpltDt}
880
+        , #{item.whsId}, #{item.location}, #{item.whsDvsn}, #{item.brandId}, #{item.storeId}
881
+        , NOW(), #{userId}, NOW(), #{userId})
882
+        </foreach>
883
+    </insert>
851 884
 </mapper>

+ 68 - 10
src/main/resources/mybatis/sqlmaps/pomng/PchOrd.xml

@@ -415,13 +415,39 @@
415 415
         and base.spply_id = #{spplyId}
416 416
     </select>
417 417
 
418
+    <select id="selectPchPoStreamlineBrandDlvChk" resultType="int">
419
+        select count(*) as cnt
420
+        from (
421
+                 select  case when base.store_id is null or base.store_id = '' then 'DL02' else  case when item.store_deli_type = '10' then 'DL01' else 'DL02' end   end as dlv_dvsn
422
+                  from pch_req_base_info base
423
+                  join pch_req_dtl_ptcl ptcl on base.pch_req_unq_no = ptcl.pch_req_unq_no
424
+                  join brand_base_info brand on base.brand_id = brand.brand_id
425
+                  join item_base_info item on base.brand_id = item.brand_id and ptcl.item_id = item.item_id
426
+                  where 1 = 1
427
+                  and base.brand_id = #{brandId}
428
+                  and ptcl.pch_req_dtl_st_cd = 'PRD20'
429
+                  and brand.shmt_col_proc_type = '20'
430
+                  and base.pch_req_unq_no   in
431
+                    <foreach collection="gridUpdateData" item="item" separator="," open="(" close=")">
432
+                        concat(#{item.pchReqUnqNo})
433
+                    </foreach>
434
+              ) TCNT
435
+        where TCNT.dlv_dvsn = 'DL01'
436
+    </select>
437
+
438
+
439
+
418 440
     <select id="selectPchPoStreamlineList" resultType="com.oqpo.api.entity.pomng.PchOdrBaseInfoEntity">
419
-        select base.pch_req_unq_no, ptcl.pch_req_dtl_no as 'pchReqDtlInfo.pch_req_dtl_no'
420
-            , base.brand_id, base.store_id, base.whs_id, base.location
421
-            , ptcl.item_id as 'pchReqDtlInfo.item_id', ptcl.item_nm as 'pchReqDtlInfo.item_nm', ptcl.unit_amt as 'pchReqDtlInfo.unit_amt'
422
-            , bitem.unit_amt as 'itemUnitInfo.unit_amt' , ptcl.pch_req_qty as 'pchReqDtlInfo.pch_req_qty', base.dlv_req_dt
423
-            , ptcl.pch_req_amt as 'pchReqDtlInfo.pch_req_amt', bitem.unit_amt * ptcl.pch_req_qty as 'pchReqDtlInfo.pch_ord_amt'
424
-            , bitem.lead_time as 'itemUnitInfo.lead_time', bitem.spply_id as 'itemUnitInfo.spply_id'
441
+        select
442
+            base.brand_id, base.store_id,  bitem.spply_id,  base.dlv_req_dt, 'OD01' as podr_dvsn
443
+			,case when base.store_id is null or base.store_id = '' then 'W01' else 'W02' end as whs_dvsn
444
+			, base.whs_id, base.location
445
+            ,base.pch_req_unq_no as 'pchOdrDtlInfo.pch_req_unq_no', ptcl.pch_req_dtl_no as 'pchOdrDtlInfo.pch_req_dtl_no'
446
+            , ptcl.item_id as 'pchOdrDtlInfo.item_id', ptcl.item_nm as 'pchOdrDtlInfo.item_nm'
447
+			, ptcl.pch_req_qty as 'pchOdrDtlInfo.podr_qty', ptcl.pch_req_amt as 'pchOdrDtlInfo.podr_amt'
448
+			, bitem.curr as 'pchOdrDtlInfo.curr', bitem.unit  as 'pchOdrDtlInfo.unit'
449
+			, ptcl.unit_amt as 'pchOdrDtlInfo.unit_amt', base.dlv_req_dt as 'pchOdrDtlInfo.dlv_sch_dt'
450
+			, ptcl.brand_unit_unq_no  as 'pchOdrDtlInfo.brand_unit_unq_no', ptcl.store_unit_unq_no  as 'pchOdrDtlInfo.store_unit_unq_no'
425 451
             , case when base.store_id is null or base.store_id = '' then 'DL02' else  case when item.store_deli_type = '10' then 'DL01' else 'DL02' end   end as dlv_dvsn
426 452
             , fn_code_nm('DLV_DVSN',case when base.store_id is null or base.store_id = '' then 'DL02' else  case when item.store_deli_type = '10' then 'DL01' else 'DL02' end   end) as dlv_dvsn_nm
427 453
         from pch_req_base_info base
@@ -435,11 +461,43 @@
435 461
         and base.pch_req_st_cd = 'PR20'
436 462
         and ptcl.pch_req_dtl_st_cd = 'PRD20'
437 463
         and brand.shmt_col_proc_type = '20'
438
-        and base.pch_req_unq_no   in
439
-        <foreach collection="gridUpdateData" item="item" separator="," open="(" close=")">
440
-            concat(#{item.pchReqUnqNo})
441
-        </foreach>
464
+        and base.pch_req_unq_no   = #{pchReqUnqNo}
442 465
         order by base.pch_req_unq_no, dlv_dvsn, bitem.spply_id
443 466
     </select>
444 467
 
468
+    <insert id="insertStreamListPchOdrBaseInfo">
469
+        INSERT INTO pch_odr_base_info
470
+        (pch_podr_unq_no, brand_id, podr_total_amt
471
+        , dlv_dvsn, dlv_req_dt, podr_mgr_nm, podr_dvsn
472
+        , pch_odr_st_cd, note, spply_id, podr_mgr_id
473
+        , podr_dt, podr_mgr_tel_no, podr_item_qty, whs_dvsn, whs_id
474
+        , location, shmt_whs_id, shmt_location, store_id
475
+        , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
476
+        VALUES
477
+        <foreach collection="gridInsertData" item="item" separator=",">
478
+            (#{item.pchPodrUnqNo}, #{item.brandId}, #{item.podrTotalAmt}
479
+           , #{item.dlvDvsn}, #{item.dlvReqDt}, #{item.podrMgrNm}, #{item.podrDvsn}
480
+            , #{item.pchOdrStCd}, #{item.note}, #{item.spplyId}, #{userId}
481
+            , date_format(now(),'%Y%m%d') , #{item.podrMgrTelNo}, #{item.podrItemQty}, #{item.whsDvsn}, #{item.whsId}
482
+            , #{item.location}, #{item.shmtWhsId}, #{item.shmtLocation}, #{item.storeId}
483
+            , NOW(), #{userId}, NOW(), #{userId})
484
+        </foreach>
485
+
486
+    </insert>
487
+
488
+    <insert id="insertStreamListPchOdrDtlPtcl">
489
+        INSERT INTO pch_odr_dtl_ptcl
490
+        (pch_podr_unq_no, pch_podr_dtl_no, pch_req_unq_no, pch_req_dtl_no, item_id
491
+        , item_nm, podr_qty, podr_amt, curr, unit, podr_dtl_st_cd
492
+        , unit_amt, dlv_sch_dt, store_unit_unq_no, brand_unit_unq_no
493
+        , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
494
+        VALUES
495
+        <foreach collection="gridInsertData" item="item" separator=",">
496
+            (#{item.pchPodrUnqNo}, #{item.pchPodrDtlNo}, #{item.pchReqUnqNo}, #{item.pchReqDtlNo}, #{item.itemId}
497
+            , #{item.itemNm}, #{item.podrQty}, #{item.podrAmt}, #{item.curr}, #{item.unit}, #{item.podrDtlStCd}
498
+            , #{item.unitAmt}, #{item.dlvSchDt}, #{item.storeUnitUnqNo}, #{item.brandUnitUnqNo}
499
+            , NOW(), #{userId}, NOW(), #{userId})
500
+        </foreach>
501
+    </insert>
502
+
445 503
 </mapper>

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

@@ -497,4 +497,29 @@
497 497
         where  brand_id = #{brandId}
498 498
         and    pch_req_unq_no = #{pchReqUnqNo}
499 499
     </select>
500
+
501
+    <update id="updateStreamListPchReqDtlStCd">
502
+        <foreach collection="gridUpdateData" item="item" separator=";">
503
+            UPDATE /* PchReq.updateStreamListPchReqDtlStCd */
504
+            pch_req_dtl_ptcl SET
505
+            pch_req_dtl_st_cd = 'PRD30',
506
+            sys_chg_dttm = NOW(),
507
+            sys_chg_id = #{userId}
508
+            WHERE pch_req_unq_no = #{item.pchReqUnqNo}
509
+        </foreach>
510
+    </update>
511
+
512
+    <update id="updateStreamListPchReqStCd">
513
+        <foreach collection="gridUpdateData" item="item" separator=";">
514
+            UPDATE /* PchReq.updateStreamListPchReqStCd */
515
+            pch_req_base_info SET
516
+            pch_req_st_cd ='PR30',
517
+            sys_chg_dttm = NOW(),
518
+            sys_chg_id = #{userId}
519
+            WHERE pch_req_unq_no = #{item.pchReqUnqNo}
520
+        </foreach>
521
+    </update>
522
+
523
+
524
+
500 525
 </mapper>