|
@@ -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());
|