소스 검색

반품처리 임시작업저장

dwkim 2 년 전
부모
커밋
7f735c92d9

+ 1 - 0
src/main/java/com/oqpo/api/entity/inoutmng/PickDtlPtclEntity.java

@@ -42,6 +42,7 @@ public class PickDtlPtclEntity implements Serializable {
42 42
     private String rtnRsnDvsnNm;
43 43
     private String rtnRsn;
44 44
     private Long colReqAmt;
45
+    private Integer rtnReqQty;
45 46
 
46 47
 
47 48
 }

+ 4 - 2
src/main/java/com/oqpo/api/entity/rtnmng/RtnProcInfoPtclEntity.java

@@ -39,10 +39,12 @@ public class RtnProcInfoPtclEntity implements Serializable {
39 39
     private String unit;
40 40
     @ApiModelProperty(value = "단가금액")
41 41
     private long unitAmt;
42
-    @ApiModelProperty(value = "반품수량")
43
-    private int rtnQty;
42
+    @ApiModelProperty(value = "반품요청수량")
43
+    private int rtnReqQty;
44 44
     @ApiModelProperty(value = "반품발주수량")
45 45
     private int rtnOdrQty;
46
+    @ApiModelProperty(value = "반품수거요청수량")
47
+    private int colReqQty;
46 48
     @ApiModelProperty(value = "수거수량")
47 49
     private int colQty;
48 50
     @ApiModelProperty(value = "수거요청일자")

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

@@ -64,6 +64,8 @@ public enum SystemMessageCode {
64 64
     ERR_INGPOCNT (40032, "발주 진행중인건이 있어서 반품 반려 처리를 할 수 없습니다.", HttpStatus.BAD_REQUEST),
65 65
     ERR_INGCOLCNT (40033, "발주 진행중인건이 있어서 반품 취소처리를 할 수 없습니다.", HttpStatus.BAD_REQUEST),
66 66
     ERR_POPICKQTY (40034, "반품 발주 수량보다 수거 수량이 많습니다.", HttpStatus.BAD_REQUEST),
67
+    ERR_NOTRTNQTY (40035, "반품입고수량은 수거수량보다 적거나 같아야 합니다.", HttpStatus.BAD_REQUEST),
68
+    ERR_NOTRTNINWHS (40036, "반품입고창고가 수거서 반품입고창고와 상이합니다.", HttpStatus.BAD_REQUEST),
67 69
     ;
68 70
 
69 71
 

+ 3 - 0
src/main/java/com/oqpo/api/mapper/inoutmng/ColOdrMapper.java

@@ -55,8 +55,11 @@ public interface ColOdrMapper {
55 55
     List<PickInfoMgntEntity> selectColRtnInstResultGridList(@Param("sBrandId") String sBrandId, @Param("sStoreId") String sStoreId,  @Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("sSpplyId") String sSpplyId, @Param("sRtnWhsId") String sRtnWhsId, @Param("sWhsId") String sWhsId,  @Param("sItemNm") String sItemNm, GridRequest gridRequest)throws Exception;
56 56
     int selectColRtnInstResultGridCnt(@Param("sBrandId") String sBrandId, @Param("sStoreId") String sStoreId,  @Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("sSpplyId") String sSpplyId, @Param("sRtnWhsId") String sRtnWhsId, @Param("sWhsId") String sWhsId,  @Param("sItemNm") String sItemNm) throws Exception;
57 57
 
58
+    List<PickInfoMgntEntity> selectColRtnInstProcList(@Param("brandId") String brandId, @Param("whsId") String whsId,List<RtnProcInfoPtclEntity> gridUpdateData )throws Exception;
58 59
 
59 60
 
61
+    //int insertRtnProcInfoPtcl(@Param("userId") String userId, RtnProcInfoPtclEntity entity) throws Exception;
62
+
60 63
     /*
61 64
     List<PchOdrBaseInfoEntity> selectShmtTargetOdrGridList(@Param("sBrandId") String sBrandId, @Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("sShmtWhsId") String sShmtWhsId, @Param("sWhsId") String sWhsId, @Param("sItemNm") String sItemNm, GridRequest gridRequest)throws Exception;
62 65
     int selectShmtTargetOdrGridCnt(@Param("sBrandId") String sBrandId, @Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("sShmtWhsId") String sShmtWhsId, @Param("sWhsId") String sWhsId, @Param("sItemNm") String sItemNm)throws Exception;

+ 151 - 199
src/main/java/com/oqpo/api/service/inoutmng/ColOdrService.java

@@ -4,6 +4,7 @@ package com.oqpo.api.service.inoutmng;
4 4
 import com.oqpo.api.entity.inoutmng.*;
5 5
 import com.oqpo.api.entity.loanmng.LoanMgntBaseInfoEntity;
6 6
 import com.oqpo.api.entity.oper.FileEntity;
7
+import com.oqpo.api.entity.oper.UserMngEntity;
7 8
 import com.oqpo.api.entity.pomng.PchOdrBaseInfoEntity;
8 9
 import com.oqpo.api.entity.pomng.PchOdrDtlPtclEntity;
9 10
 import com.oqpo.api.entity.rtnmng.RtnOdrBaseInfoEntity;
@@ -23,6 +24,7 @@ import com.oqpo.api.mapper.FileMapper;
23 24
 import com.oqpo.api.mapper.inoutmng.ColOdrMapper;
24 25
 import com.oqpo.api.mapper.inoutmng.ShmtOdrMapper;
25 26
 import com.oqpo.api.mapper.loanmng.LoanStateMapper;
27
+import com.oqpo.api.mapper.oper.UserMngMapper;
26 28
 import com.oqpo.api.mapper.pomng.PchOrdMapper;
27 29
 import com.oqpo.api.mapper.rtnmng.RtnOdrMapper;
28 30
 import com.oqpo.api.mapper.stinfo.BrandMapper;
@@ -68,10 +70,12 @@ public class ColOdrService extends CommonService {
68 70
     private StoreBaseInfoMapper storeBaseInfoMapper;
69 71
 
70 72
     @Autowired
71
-    private LoanStateMapper loanStateMapper;
73
+    private FileMapper fileMapper;
72 74
 
73 75
     @Autowired
74
-    private FileMapper fileMapper;
76
+    private UserMngMapper userMngMapper;
77
+
78
+
75 79
 
76 80
     /*
77 81
       수거 대상 그리드 리스트 조회
@@ -769,189 +773,176 @@ public class ColOdrService extends CommonService {
769 773
     @Transactional
770 774
     public void saveRtnStockProc(String userId, SaveRtnStockProcRequest saveRtnStockProcRequest) throws Exception {
771 775
         try {
772
-
773 776
             List<RtnProcInfoPtclEntity> gridInsertData = saveRtnStockProcRequest.toCodeEntities(saveRtnStockProcRequest.getGridInsertData());
774 777
             List<RtnProcInfoPtclEntity> searchList = new ArrayList<RtnProcInfoPtclEntity>();
775 778
             if (gridInsertData.size() > 0) {
776
-                for (int i = 0 ; i < gridInsertData.size() ; i++) {
779
+                for (int i = 0; i < gridInsertData.size(); i++) {
777 780
                     RtnProcInfoPtclEntity targetData = gridInsertData.get(i);
778 781
                     RtnProcInfoPtclEntity procData = new RtnProcInfoPtclEntity();
779
-                    procData.setColPickUnqNo (targetData.getColPickUnqNo() + targetData.getColPickDtlNo());
782
+                    procData.setColPickUnqNo(targetData.getColPickUnqNo() + targetData.getColPickDtlNo());
780 783
                     searchList.add(procData);
781
-                }  ==> 여기까지
782
-
783
-                List<PickInfoMgntEntity> targetList  =   shmtOdrMapper.selectWarehouseProcList(saveWarehouseProcRequest.getBrandId(), saveWarehouseProcRequest.getWhsId(), serarchList);
784
-
785
-                List<WhsProcInfoPtclEntity> gridUpdateData = new ArrayList<WhsProcInfoPtclEntity>();
786
-                List<StckMgntBaseInfoEntity> wareGridUpdateData = new ArrayList<StckMgntBaseInfoEntity>();
787
-                List<DeliDtlMgntEntity> deliDtlGridUpdateData = new ArrayList<DeliDtlMgntEntity>();
788
-                List<ShmtOdrDtlEntity> shmtDtlGridUpdateData = new ArrayList<ShmtOdrDtlEntity>();
789
-                List<PchOdrDtlPtclEntity> PchOdrDtlGridUpdateData = new ArrayList<PchOdrDtlPtclEntity>();
790
-
791
-
792
-                // loan_mgnt_unq_no 매장납품일 경우
793
-                //selectStoreLoanMgntUnqNo
794
-                String loanMgntUnqNo = "";
795
-                long loanAmt = 0 ; // 여신차감할 금액 (사용금액 - 여신차감금액,   잔액금액 - 여신차감금액)
796
-                if (!"".equals(saveWarehouseProcRequest.getStoreId())) {
797
-                    loanMgntUnqNo = storeBaseInfoMapper.selectStoreLoanMgntUnqNo(saveWarehouseProcRequest.getStoreId());
798 784
                 }
799 785
 
800
-                // 우선 입고수량과 납품수량 비교를 처리함
801
-                for (int i = 0 ; i < gridInsertData.size() ; i++) {
802
-                    WhsProcInfoPtclEntity whsProcData = gridInsertData.get(i);
786
+                //로그인 사용자 정보
787
+                UserMngEntity uEntity = userMngMapper.selectGroupUserInfo(userId);
803 788
 
804
-                    for (int j = 0  ; j < targetList.size() ; j++) {
805
-                        DeliInfoMgntEntity targetData = targetList.get(j);
806
-                        //System.out.println("=whsProcData=======getDlvSttmtUnqNo============>" + i + "==" + j + "==>" + whsProcData.getDlvSttmtUnqNo() +  "==" +  targetData.getDlvSttmtUnqNo());
807
-                       // System.out.println("=whsProcData=======getDlvSttmtDtlNo============>" + i + "==" + j + "==>"  + whsProcData.getDlvSttmtDtlNo() +  "==" +   targetData.getDeliDtlMgntInfo().getDlvSttmtDtlNo());
808
-                        if (whsProcData.getDlvSttmtUnqNo().equals(targetData.getDlvSttmtUnqNo()) && whsProcData.getDlvSttmtDtlNo().equals(targetData.getDeliDtlMgntInfo().getDlvSttmtDtlNo())) {
809 789
 
810
-                            if (whsProcData.getWhsQty() > targetData.getDeliDtlMgntInfo().getDlvQty()) {
811
-                                 // 오류 처리
812
-                                throw new GlobalException(SystemMessageCode.ERR_NOTWAREHOUSE);
813
-                            }
790
+                // 반품처리를 위한 관련정보를 가져온다
791
+                List<PickInfoMgntEntity> targetList = colOdrMapper.selectColRtnInstProcList(saveRtnStockProcRequest.getBrandId(), saveRtnStockProcRequest.getWhsId(), searchList);
814 792
 
815
-                            // 입고번호 생성
816
-                            whsProcData.setWhsMgntUnqNo(fnGetDealNo(17,""));
817
-
818
-                            //System.out.println("=whsProcData=======setWhsMgntUnqNo============>" + i + "==" + j + "==>"  + whsProcData.getWhsMgntUnqNo());
819
-
820
-                            whsProcData.setDlvSttmtDtlNo(targetData.getDeliDtlMgntInfo().getDlvSttmtDtlNo());
821
-                            whsProcData.setDlvSttmtUnqNo(targetData.getDlvSttmtUnqNo());
822
-                            whsProcData.setBrandId(targetData.getBrandId());
823
-                            whsProcData.setStoreId(targetData.getStoreId());
824
-                            whsProcData.setWhsId(targetData.getWhsId());
825
-                            whsProcData.setLocation(targetData.getLocation());
826
-                            whsProcData.setSpplyId(targetData.getSpplyId());
827
-                            whsProcData.setSpplyNm(targetData.getSpplyNm());
828
-                            whsProcData.setWhsDvsn(targetData.getWhsDvsn());
829
-                            whsProcData.setPodrQty(targetData.getDeliDtlMgntInfo().getPodrQty());
830
-                            whsProcData.setDlvQty(targetData.getDeliDtlMgntInfo().getDlvQty());
831
-                            whsProcData.setUnit(targetData.getDeliDtlMgntInfo().getUnit());
832
-                            whsProcData.setUnitAmt(targetData.getDeliDtlMgntInfo().getUnitAmt());
833
-                            whsProcData.setDlvReqDt(targetData.getDlvReqDt());
834
-                            whsProcData.setDlvSchDt(targetData.getDlvSchDt());
835
-                            whsProcData.setWhsCnfmNm(userId);
836
-                            whsProcData.setDlvMgrNm(targetData.getDlvMgrNm());
837
-                            whsProcData.setDlvMgrTelNo(targetData.getDlvMgrTelNo());
838
-                            whsProcData.setDlvMgrEmal(targetData.getDlvMgrEmal());
839
-                            whsProcData.setDlvMgrMblNo(targetData.getDlvMgrMblNo());
840
-                            whsProcData.setItemId(targetData.getDeliDtlMgntInfo().getItemId());
841
-                            whsProcData.setItemNm(targetData.getDeliDtlMgntInfo().getItemNm());
842
-                            whsProcData.setWhsAmt(Long.valueOf(targetData.getDeliDtlMgntInfo().getUnitAmt() * whsProcData.getWhsQty()));
843
-                            whsProcData.setWhsDlvChrg(null);
844
-                            //whsProcData.setDlvMgrId(targetData.getdlvmgr);
845
-                            whsProcData.setDlvCnfmDocFileNo(whsProcData.getDlvCnfmDocFileNo());
846
-                            whsProcData.setSttlYn("N");
847
-                            whsProcData.setPchPodrUnqNo(targetData.getDeliDtlMgntInfo().getPchPodrUnqNo());
848
-                            whsProcData.setPchPodrDtlNo(targetData.getDeliDtlMgntInfo().getPchPodrDtlNo());
849
-                            whsProcData.setPchReqUnqNo(targetData.getDeliDtlMgntInfo().getPchReqUnqNo());
850
-                            whsProcData.setPchReqDtlNo(targetData.getDeliDtlMgntInfo().getPchReqDtlNo());
851
-                            whsProcData.setShmtReqUnqNo(targetData.getDeliDtlMgntInfo().getShmtReqUnqNo());
852
-                            whsProcData.setShmtReqDtlNo(targetData.getDeliDtlMgntInfo().getShmtReqDtlNo());
853
-
854
-                            gridUpdateData.add(whsProcData);
855
-
856
-                            // 정산할때 함 여신관련한 여신차감할 입고금액 세팅
857
-                            //loanAmt = loanAmt + (targetData.getDeliDtlMgntInfo().getUnitAmt() * whsProcData.getWhsQty());
858
-
859
-                            // 재고처리를 위한 작업업
860
-                            StckMgntBaseInfoEntity smbaseInfoEntity = new StckMgntBaseInfoEntity();
861
-                            smbaseInfoEntity.setBrandId(saveWarehouseProcRequest.getBrandId());
862
-                            smbaseInfoEntity.setWhsId(saveWarehouseProcRequest.getWhsId());
863
-                            smbaseInfoEntity.setLocation(whsProcData.getLocation());
864
-                            smbaseInfoEntity.setItemId(whsProcData.getItemId());
865
-                            smbaseInfoEntity.setStckQty(whsProcData.getWhsQty());
866
-                            wareGridUpdateData.add(smbaseInfoEntity);
867
-
868
-                            // 납품서 상태 정의  dlvSttmtUnqNo  dlvDtlStCd
869
-                            DeliDtlMgntEntity deliDtlEntity = new DeliDtlMgntEntity();
870
-                            deliDtlEntity.setDlvSttmtUnqNo(whsProcData.getDlvSttmtUnqNo());
871
-                            deliDtlEntity.setDlvSttmtDtlNo(whsProcData.getDlvSttmtDtlNo());
872
-                            if (whsProcData.getWhsQty() > 0 ) {
873
-                                deliDtlEntity.setDlvDtlStCd("DLD1");
874
-                            } else {
875
-                                deliDtlEntity.setDlvDtlStCd("DLD3");
876
-                            }
877
-                            deliDtlGridUpdateData.add(deliDtlEntity);
793
+                for (int i = 0; i < gridInsertData.size(); i++) {
794
+                    RtnProcInfoPtclEntity requestData = gridInsertData.get(i);
878 795
 
796
+                    for (int j = 0; j < targetList.size(); j++) {
797
+                        PickInfoMgntEntity targetData = targetList.get(j);
879 798
 
880
-                            // 출하지시 상태정의
881
-                            if (!"".equals(whsProcData.getShmtReqUnqNo()) && whsProcData.getShmtReqUnqNo() != null) {
882
-                                ShmtOdrDtlEntity shmtDtlData = new ShmtOdrDtlEntity();
883
-                                shmtDtlData.setShmtReqUnqNo(whsProcData.getShmtReqUnqNo());
884
-                                shmtDtlData.setShmtReqDtlNo(whsProcData.getPchReqDtlNo());
885
-                                if (whsProcData.getWhsQty() > 0 ) {
886
-                                    shmtDtlData.setShmtDtlStCd("SHMD2");
887
-                                } else {
888
-                                    shmtDtlData.setShmtDtlStCd("SHMD3");
889
-                                }
799
+                        RtnProcInfoPtclEntity rtnProcInfoEntity = new RtnProcInfoPtclEntity();
890 800
 
891
-                                shmtDtlGridUpdateData.add(shmtDtlData);
801
+                        if (requestData.getColPickDtlNo().equals(targetData.getColPickUnqNo()) && requestData.getColPickDtlNo().equals(targetData.getPickDtlInfo().getColPickDtlNo())) {
802
+                            if (requestData.getColQty() > targetData.getPickDtlInfo().getColReqQty()) {
803
+                                // 반품입고수량이 수거요청수량보다 클 수 없습니다.
804
+                                throw new GlobalException(SystemMessageCode.ERR_NOTRTNQTY);
892 805
                             }
893 806
 
894
-                            PchOdrDtlPtclEntity pchOdrDtlData = new PchOdrDtlPtclEntity();
895
-                            pchOdrDtlData.setPchPodrUnqNo(whsProcData.getPchPodrUnqNo());
896
-                            pchOdrDtlData.setPchPodrDtlNo(whsProcData.getPchPodrDtlNo());
897
-                            if (whsProcData.getWhsQty() > 0 ) {
898
-                                pchOdrDtlData.setPodrDtlStCd("POD4");
899
-                            } else {
900
-                                pchOdrDtlData.setPodrDtlStCd("POD2");
901
-
902
-                                if (!"".equals(loanMgntUnqNo)) {
903
-                                    loanAmt = loanAmt + ( targetData.getDeliDtlMgntInfo().getDlvQty() * targetData.getDeliDtlMgntInfo().getUnitAmt() ) ;
904
-                                }
807
+                            if (targetData.getColDvsn().equals("C001") && !saveRtnStockProcRequest.getWhsId().equals(targetData.getWhsId())) {
808
+                                // 본사 수거이변서 입고창고가 상이하면 오류
809
+                                throw new GlobalException(SystemMessageCode.ERR_NOTRTNINWHS);
905 810
                             }
906
-
907
-                            PchOdrDtlGridUpdateData.add(pchOdrDtlData);
908
-                            break;
909 811
                         }
910 812
 
813
+                        // 반품처리  진행 데이타생성
814
+
815
+                        String rtnMgntUnqNo = fnGetDealNo(37,"");
816
+                        rtnProcInfoEntity.setRtnMgntUnqNo(rtnMgntUnqNo);
817
+                        rtnProcInfoEntity.setBrandId(saveRtnStockProcRequest.getBrandId());
818
+                        rtnProcInfoEntity.setStoreId(saveRtnStockProcRequest.getStoreId());
819
+                        rtnProcInfoEntity.setItemId(requestData.getItemId());
820
+                        rtnProcInfoEntity.setItemNm(targetData.getPickDtlInfo().getItemNm());
821
+                        rtnProcInfoEntity.setWhsId(targetData.getRtnWhsId());
822
+                        rtnProcInfoEntity.setLocation(targetData.getRtnLocation());
823
+                        rtnProcInfoEntity.setUnit(targetData.getPickDtlInfo().getUnit());
824
+                        rtnProcInfoEntity.setUnitAmt(targetData.getPickDtlInfo().getUnitAmt());
825
+                        rtnProcInfoEntity.setRtnReqQty(targetData.getPickDtlInfo().getRtnReqQty());
826
+                        rtnProcInfoEntity.setRtnOdrQty(targetData.getPickDtlInfo().getRodrQty());
827
+                        rtnProcInfoEntity.setColReqQty(targetData.getPickDtlInfo().getColReqQty());
828
+                        rtnProcInfoEntity.setColQty(requestData.getColQty());
829
+                        rtnProcInfoEntity.setColReqDt(targetData.getColReqDt());
830
+                        rtnProcInfoEntity.setColSchDt(targetData.getColSchDt());
831
+                        rtnProcInfoEntity.setColCnfmNm(uEntity.getUserNm());
832
+                        rtnProcInfoEntity.setColMgrTelNo(targetData.getPickMgrTelNo());
833
+                        rtnProcInfoEntity.setColAmt(requestData.getColQty() * targetData.getPickDtlInfo().getUnitAmt());
834
+                        rtnProcInfoEntity.setColAgrYn("Y");
835
+                        // rtnProcInfoEntity.setColCnfmDocFileNo(saveRtnStockProcRequest.); 수거서 파일 첨부 제거
836
+                        rtnProcInfoEntity.setSttlYn("N");
837
+                        rtnProcInfoEntity.setSpplyId(targetData.getSpplyId());
838
+                        rtnProcInfoEntity.setSpplyNm(targetData.getSpplyNm());
839
+                        rtnProcInfoEntity.setColPickUnqNo(targetData.getColPickUnqNo());
840
+                        rtnProcInfoEntity.setColPickDtlNo(targetData.getPickDtlInfo().getColPickDtlNo());
841
+                        rtnProcInfoEntity.setColCmdUnqNo(targetData.getPickDtlInfo().getColCmdUnqNo());
842
+                        rtnProcInfoEntity.setColCmdDtlNo(targetData.getPickDtlInfo().getColCmdDtlNo());
843
+                        rtnProcInfoEntity.setRtnPodrUnqNo(targetData.getPickDtlInfo().getRtnPodrUnqNo());
844
+                        rtnProcInfoEntity.setRtnPodrDtlNo(targetData.getPickDtlInfo().getRtnPodrDtlNo());
845
+                        rtnProcInfoEntity.setRtnReqUnqNo(targetData.getPickDtlInfo().getRtnReqUnqNo());
846
+                        rtnProcInfoEntity.setRtnReqDtlNo(targetData.getPickDtlInfo().getRtnReqDtlNo());
847
+
848
+                        // 본사 수거 반품입고처리시
849
+                        if (targetData.getColDvsn().equals("C001") && requestData.getColQty() > 0) {
850
+                            //본사수거 .
851
+                            // 1. 매장재고참감처리, 본사재고 증가, 2. 반품처리테이블 생성, 3. 수거서 업데이타, 4, 반품발주건 업데이트
852
+                            // 매장재고 차감
853
+                            StckMgntBaseInfoEntity stckWEntity = new StckMgntBaseInfoEntity();
854
+                            stckWEntity.setBrandId(saveRtnStockProcRequest.getBrandId());
855
+                            stckWEntity.setWhsId(targetData.getRtnWhsId());
856
+                            stckWEntity.setLocation(targetData.getRtnLocation());
857
+                            stckWEntity.setItemId(requestData.getItemId());
858
+                            stckWEntity.setStckQty(requestData.getColQty() * (-1));
859
+                            stckWEntity.setUnit(targetData.getPickDtlInfo().getUnit());
860
+                            //StckBaseList.add(stckWEntity);
861
+
862
+                            // 재고 이력정보 등록
863
+                            StckMgntDtlHistEntity stckWHist = new StckMgntDtlHistEntity();
864
+                            stckWHist.setStckMgntDtlNo("");
865
+                            stckWHist.setBrandId(saveRtnStockProcRequest.getBrandId());
866
+                            stckWHist.setWhsId(targetData.getRtnWhsId());
867
+                            stckWHist.setLocation(targetData.getRtnLocation());
868
+                            stckWHist.setItemId(requestData.getItemId());
869
+                            stckWHist.setItemNm(targetData.getPickDtlInfo().getItemNm());
870
+                            stckWHist.setInoutCd("OUT");
871
+                            stckWHist.setInoutQty(requestData.getColQty());
872
+                            stckWHist.setChgDvsn("ROUT");
873
+                            stckWHist.setRelationNo(rtnMgntUnqNo);
874
+                            //StckHistList.add(stckWHist);
875
+
876
+                            //본사재고 증가
877
+                            StckMgntBaseInfoEntity stckW1Entity = new StckMgntBaseInfoEntity();
878
+                            stckW1Entity.setBrandId(saveRtnStockProcRequest.getBrandId());
879
+                            stckW1Entity.setWhsId(saveRtnStockProcRequest.getWhsId());
880
+                            stckW1Entity.setLocation(targetData.getLocation());
881
+                            stckW1Entity.setItemId(requestData.getItemId());
882
+                            stckW1Entity.setStckQty(requestData.getColQty());
883
+                            stckW1Entity.setUnit(targetData.getPickDtlInfo().getUnit());
884
+                            //StckBaseList.add(stckWEntity);
885
+
886
+                            // 재고 이력정보 등록
887
+                            StckMgntDtlHistEntity stckW1Hist = new StckMgntDtlHistEntity();
888
+                            stckW1Hist.setStckMgntDtlNo("");
889
+                            stckW1Hist.setBrandId(saveRtnStockProcRequest.getBrandId());
890
+                            stckW1Hist.setWhsId(saveRtnStockProcRequest.getWhsId());
891
+                            stckW1Hist.setLocation(targetData.getLocation());
892
+                            stckW1Hist.setItemId(requestData.getItemId());
893
+                            stckW1Hist.setItemNm(targetData.getPickDtlInfo().getItemNm());
894
+                            stckW1Hist.setInoutCd("OUT");
895
+                            stckW1Hist.setInoutQty(requestData.getColQty());
896
+                            stckW1Hist.setChgDvsn("ROUT");
897
+                            stckW1Hist.setRelationNo(rtnMgntUnqNo);  //======================================
898
+                            //StckHistList.add(stckWHist);
899
+
900
+                        } else if (targetData.getColDvsn().equals("C002") && requestData.getColQty() > 0) {
901
+                            //  공급사 수거일경우 - 본사창고 재고 차감 처리
902
+                            // 1. 참감처리 , 2. 반품처리테이블 생성, 3. 수거서 업데이타, 4, 반품발주건 업데이트
903
+                            // 본사재고 차감 처리  stck_mgnt_base_info  stck_mgnt_dtl_hist
904
+                            StckMgntBaseInfoEntity stckWEntity = new StckMgntBaseInfoEntity();
905
+                            stckWEntity.setBrandId(saveRtnStockProcRequest.getBrandId());
906
+                            stckWEntity.setWhsId(saveRtnStockProcRequest.getWhsId());
907
+                            stckWEntity.setLocation(targetData.getLocation());
908
+                            stckWEntity.setItemId(requestData.getItemId());
909
+                            stckWEntity.setStckQty(requestData.getColQty() * (-1));
910
+                            stckWEntity.setUnit(targetData.getPickDtlInfo().getUnit());
911
+                            //StckBaseList.add(stckWEntity);
912
+
913
+                            // 재고 이력정보 등록
914
+                            StckMgntDtlHistEntity stckWHist = new StckMgntDtlHistEntity();
915
+                            stckWHist.setStckMgntDtlNo("");
916
+                            stckWHist.setBrandId(saveRtnStockProcRequest.getBrandId());
917
+                            stckWHist.setWhsId(saveRtnStockProcRequest.getWhsId());
918
+                            stckWHist.setLocation(targetData.getLocation());
919
+                            stckWHist.setItemId(requestData.getItemId());
920
+                            stckWHist.setItemNm(targetData.getPickDtlInfo().getItemNm());
921
+                            stckWHist.setInoutCd("OUT");
922
+                            stckWHist.setInoutQty(requestData.getColQty());
923
+                            stckWHist.setChgDvsn("ROUT");
924
+                            stckWHist.setRelationNo(rtnMgntUnqNo);  //======================================
925
+                            //StckHistList.add(stckWHist);
926
+                        }
911 927
 
912
-                    }  // or문 종료
913
-                }
914
-
915
-                    // 입고데이타 저장
916
-                    shmtOdrMapper.insertWhsProcInfoPtcl(userId, gridUpdateData);
917
-
918
-                    // 재고관련 정리 필요
919
-                    stockMngMapper.updateWarehouseStockQty(userId, wareGridUpdateData);
920
-
921
-                    // 납품서 상세 처리
922
-                    shmtOdrMapper.updateDeliDtlStCd(userId, deliDtlGridUpdateData);
923
-
924
-                    // 납품서 헤더 상태 처리
925
-                    List<DeliInfoMgntEntity> deliInfoStList = shmtOdrMapper.selectDeliInfoStList(userId, deliDtlGridUpdateData);
926
-                    shmtOdrMapper.updateDeliInfoStCd(userId, deliInfoStList);
927
-
928
-                    // 출하지시서 상태 업데이트
929
-                    if (shmtDtlGridUpdateData.size() > 0) {
930
-                        shmtOdrMapper.updateShmtDtlStCd(userId,shmtDtlGridUpdateData );
931
-                        List<ShmtOdrBaseEntity> shmtInfoStList = shmtOdrMapper.selectShmtInfoStList(userId, shmtDtlGridUpdateData);
932
-                        shmtOdrMapper.updateShmtInfoStCd(userId, shmtInfoStList);
933
-                    }
934
-
935
-
936
-                    shmtOdrMapper.updatePchPodrDtlStCd(userId, PchOdrDtlGridUpdateData);
937
-
938
-                    String pchPodrUnqNo = "";
939
-                    for (int k = 0; k < PchOdrDtlGridUpdateData.size(); k++) {
940
-                        if (!pchPodrUnqNo.equals(PchOdrDtlGridUpdateData.get(k).getPchPodrUnqNo())) {
941
-                            pchPodrUnqNo = PchOdrDtlGridUpdateData.get(k).getPchPodrUnqNo();
942
-                            String pchOdrStCd = pchOrdService.selectOdrDtlStatusList(pchPodrUnqNo);
943
-                            pchOrdMapper.updateChgPodrStCd(userId, pchOdrStCd, pchPodrUnqNo);
928
+                        // 반품수거서 건별 업데이트
929
+                        ColOdrDtlPtclEntity colOdrDtlPtclEntity = new ColOdrDtlPtclEntity;
930
+                        colOdrDtlPtclEntity.setColCmdUnqNo(targetData.getPickDtlInfo().getColCmdUnqNo());
931
+                        colOdrDtlPtclEntity.setColCmdDtlNo(targetData.getPickDtlInfo().getColCmdDtlNo());
932
+                        if (requestData.getColQty() > 0) {
933
+                            colOdrDtlPtclEntity.setColCmdDtlStCd("CDLD2");
934
+                        } else {
935
+                            colOdrDtlPtclEntity.setColCmdDtlStCd("COLD3");
944 936
                         }
945
-                    }
946 937
 
947
-                    // 발주 헤더가 취소면 해당 발주건에 대한 사용금액을 원복 처리한다.
948
-                    if (!"".equals(loanMgntUnqNo) && loanAmt > 0) {
949
-                        // 여신관련 정리 필요 loanAmt 업데이트
950
-                        loanStateMapper.updateloanMinusInstProc(loanMgntUnqNo, saveWarehouseProcRequest.getStoreId(), loanAmt);
951
-                    }
938
+                        //저장된 정보 신규 등록 및 업데이트 처리함
939
+                        colOdrMapper.insertRtnProcInfoPtcl(userId,rtnProcInfoEntity );
940
+
941
+                    } //==> targetList db에서 가온 수거정보
952 942
 
953 943
 
954 944
 
945
+                } //==> request에서 가져온 전달받은 정보
955 946
             }
956 947
 
957 948
         } catch (GlobalException e) {
@@ -1010,46 +1001,7 @@ public class ColOdrService extends CommonService {
1010 1001
                 .collect(Collectors.toList());
1011 1002
         return GridResponse.toDTO(gridPage, gridTotal, gridRecords, gridRows);
1012 1003
     }
1013
-    /*
1014
-      입고 현황 그리드 리스트 조회  @Param("sBrandId") String sBrandId, @Param("sStoreId") String sStoreId,
1015
-      @Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("sPchPodrUnqNo") String sPchPodrUnqNo, @Param("sSpplyId") String sSpplyId, @Param("sWhsId") String sWhsId, @Param("sItemNm") String sItemNm
1016 1004
 
1017
-    public GridResponse selectWarehouseGridList(String sBrandId, String sStoreId,  String fromDt, String toDt, String sPchPodrUnqNo, String sSpplyId, String sWhsId, String sItemNm, GridRequest gridRequest) throws Exception {
1018
-        int gridPage = gridRequest.getGridPage();
1019
-        int gridSize = gridRequest.getGridSize();
1020
-
1021
-        fromDt = fromDt == null ? null : fromDt.replace(".", "");
1022
-        toDt = toDt == null ? null : toDt.replace(".", "");
1023
-
1024
-        int gridRecords = shmtOdrMapper.selectWarehouseCnt(sBrandId, sStoreId, fromDt, toDt, sPchPodrUnqNo, sSpplyId, sWhsId, sItemNm);
1025
-        int gridTotal = fnCalculateGridTotal(gridSize, gridRecords);
1026
-        List<WhsProcInfoPtclEntity> entities = shmtOdrMapper.selectWarehouseList(sBrandId, sStoreId, fromDt, toDt, sPchPodrUnqNo, sSpplyId, sWhsId, sItemNm, gridRequest);
1027
-        List<Object> gridRows = entities.stream()
1028
-                .map(m -> WarehouseSearchGridListResponse.builder()
1029
-                        .viewCd("R")
1030
-                        .pchPodrUnqNo(m.getPchPodrUnqNo() == null ? "" : m.getPchPodrUnqNo())
1031
-                        .pchPodrDtlNo(m.getPchPodrDtlNo() == null ? "" : m.getPchPodrDtlNo())
1032
-                        .dlvSttmtUnqNo(m.getDlvSttmtUnqNo() == null ? "" : m.getDlvSttmtUnqNo())
1033
-                        .dlvSttmtDtlNo(m.getDlvSttmtDtlNo() == null ? "" : m.getDlvSttmtDtlNo() )
1034
-                        .podrQty(m.getPodrQty() == null ? 0 : m.getPodrQty())
1035
-                        .dlvQty(m.getDlvQty() == null ? 0 : m.getDlvQty())
1036
-                        .whsQty(m.getWhsQty() == null ? 0 : m.getWhsQty())
1037
-                        .dlvReqDt(m.getDlvReqDt() == null ? "" : m.getDlvReqDt())
1038
-                        .dlvSchDt(m.getDlvSchDt() == null ? "" : m.getDlvSchDt())
1039
-                        .dlvCmpltDt(m.getDlvCmpltDt() == null ? "" : m.getDlvCmpltDt())
1040
-                        .whsCnfmNm(m.getWhsCnfmNm() == null ? "" : m.getWhsCnfmNm())
1041
-                        .dlvMgrNm(m.getDlvMgrNm() == null ? "" : m.getDlvMgrNm())
1042
-                        .dlvMgrTelNo(m.getDlvMgrTelNo() == null ? "" : m.getDlvMgrTelNo())
1043
-                        .itemId(m.getItemId() == null ? "" : m.getItemId())
1044
-                        .itemNm(m.getItemNm() == null ? "" : m.getItemNm())
1045
-                        .unit(m.getUnit() == null ? "" : m.getUnit())
1046
-                        .whsAmt(m.getWhsAmt() == null ? 0 : m.getWhsAmt())
1047
-                        .build())
1048
-                .collect(Collectors.toList());
1049
-        return GridResponse.toDTO(gridPage, gridTotal, gridRecords, gridRows);
1050
-    }
1051
-
1052
- */
1053 1005
 
1054 1006
 }
1055 1007
 

+ 1 - 1
src/main/java/com/oqpo/api/web/controller/inoutmng/ColOdrController.java

@@ -260,7 +260,7 @@ public class ColOdrController {
260 260
             @ApiImplicitParam(name = "X-AUTH-TOKEN", value = "CONN-KEY", required = true, dataType = "String", paramType = "header")
261 261
     })
262 262
     @ApiOperation(value = " 입고 현황 그리드 리스트")
263
-    @PostMapping("/warehouse-grid-list")
263
+    @PostMapping("/save-retstock")
264 264
     public ResponseEntity<GridResponse> selectWarehouseGridList(@RequestBody @Valid WarehouseGridRequest warehouseGridRequest) throws Exception {
265 265
         return ResponseEntity.ok(shmtOdrService.selectWarehouseGridList(warehouseGridRequest.getSBrandId(), warehouseGridRequest.getSStoreId(), warehouseGridRequest.getFromDt(), warehouseGridRequest.getToDt(), warehouseGridRequest.getSPchPodrUnqNo(),  warehouseGridRequest.getSSpplyId(), warehouseGridRequest.getSWhsId(), warehouseGridRequest.getSItemNm(),  warehouseGridRequest.toDTO(warehouseGridRequest)));
266 266
     }

+ 1 - 1
src/main/java/com/oqpo/api/web/dto/request/inoutmng/SaveRtnStockProcRequest.java

@@ -22,7 +22,7 @@ public class SaveRtnStockProcRequest {
22 22
     @NotBlank
23 23
     @ApiModelProperty(value = "입고창고아이디") private String whsId;
24 24
 
25
-    @ApiModelProperty(value = "매장창고 입고처리시 필수") private String storeId;
25
+    @ApiModelProperty(value = "매장창고 반품처리시 필수") private String storeId;
26 26
     //colCnfmDocFileNo
27 27
     @ApiModelProperty(value = "반품처리대상 리스트")
28 28
     private List<RtnStockProcDataList> gridInsertData;

+ 25 - 25
src/main/resources/mybatis/sqlmaps/inoutmng/ColOdr.xml

@@ -783,28 +783,28 @@
783 783
             #{item.colPickUnqNo}
784 784
         </foreach>
785 785
     </select>
786
-
787
-    <insert id="insertRtnProcInfoPtcl">
788
-        insert into rtn_proc_info_ptcl
789
-        (rtn_mgnt_unq_no, brand_id, store_id, item_id, item_nm
790
-        , whs_id, location, unit, unit_amt, rtn_req_qty
791
-        , rtn_odr_qty, col_req_qty, col_qty, col_req_dt, col_sch_dt
792
-        , col_dt, col_cnfm_nm, col_mgr_nm, col_mgr_tel_no, col_mgr_emal
793
-        , col_mgr_mbl_no, col_amt, col_agr_yn, col_cnfm_doc_file_no, sttl_yn
794
-        , spply_id, spply_nm, col_pick_unq_no, col_pick_dtl_no, col_cmd_unq_no
795
-        , col_cmd_dtl_no, rtn_podr_unq_no, rtn_podr_dtl_no, rtn_req_unq_no, rtn_req_dtl_no
796
-        , sttl_mgnt_unq_no, sttl_mgnt_dtl_no
797
-        , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
798
-        values
799
-        (#{entity.rtnMgntUnqNo}, #{entity.brandId}, #{entity.storeId}, #{entity.itemId}, #{entity.itemNm}
800
-        , #{entity.whsId}, #{entity.location}, #{entity.unit}, #{entity.unitAmt}, #{entity.rtnReqQty}
801
-        , #{entity.rtnOdrQty}, #{entity.colReqQty}, #{entity.colQty}, #{entity.colReqDt}, #{entity.colSchDt}
802
-        , date_fromat(now(),'%Y%m%d'), #{entity.colCnfmNm}, #{entity.colMgrNm}, #{entity.colMgrTelNo}, #{entity.colMgrEmal}
803
-        , #{entity.colMgrMblNo}, #{entity.colAmt}, #{entity.colAgrYn}, #{entity.colCnfmDocFileNo}, #{entity.sttlYn}
804
-        , #{entity.spplyId}, #{entity.spplyNm}, #{entity.colPickUnqNo}, #{entity.colPickDtlNo}, #{entity.colCmdUnqNo}
805
-        , #{entity.colCmdDtlNo}, #{entity.rtnPodrUnqNo}, #{entity.rtnPodrDtlNo}, #{entity.rtnReqUnqNo}, #{entity.rtnReqDtlNo}
806
-        , #{entity.sttlMgntUnqNo}, #{entity.sttlMgntDtlNo}
807
-        , now(), #{userId}, now(), #{userId})
808
-    </insert>
809
-
810
-</mapper>
786
+    <!--
787
+        <insert id="insertRtnProcInfoPtcl">
788
+            insert into rtn_proc_info_ptcl
789
+            (rtn_mgnt_unq_no, brand_id, store_id, item_id, item_nm
790
+            , whs_id, location, unit, unit_amt, rtn_req_qty
791
+            , rtn_odr_qty, col_req_qty, col_qty, col_req_dt, col_sch_dt
792
+            , col_dt, col_cnfm_nm, col_mgr_nm, col_mgr_tel_no, col_mgr_emal
793
+            , col_mgr_mbl_no, col_amt, col_agr_yn, col_cnfm_doc_file_no, sttl_yn
794
+            , spply_id, spply_nm, col_pick_unq_no, col_pick_dtl_no, col_cmd_unq_no
795
+            , col_cmd_dtl_no, rtn_podr_unq_no, rtn_podr_dtl_no, rtn_req_unq_no, rtn_req_dtl_no
796
+            , sttl_mgnt_unq_no, sttl_mgnt_dtl_no
797
+            , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
798
+            values
799
+            (#{entity.rtnMgntUnqNo}, #{entity.brandId}, #{entity.storeId}, #{entity.itemId}, #{entity.itemNm}
800
+            , #{entity.whsId}, #{entity.location}, #{entity.unit}, #{entity.unitAmt}, #{entity.rtnReqQty}
801
+            , #{entity.rtnOdrQty}, #{entity.colReqQty}, #{entity.colQty}, #{entity.colReqDt}, #{entity.colSchDt}
802
+            , date_fromat(now(),'%Y%m%d'), #{entity.colCnfmNm}, #{entity.colMgrNm}, #{entity.colMgrTelNo}, #{entity.colMgrEmal}
803
+            , #{entity.colMgrMblNo}, #{entity.colAmt}, #{entity.colAgrYn}, #{entity.colCnfmDocFileNo}, #{entity.sttlYn}
804
+            , #{entity.spplyId}, #{entity.spplyNm}, #{entity.colPickUnqNo}, #{entity.colPickDtlNo}, #{entity.colCmdUnqNo}
805
+            , #{entity.colCmdDtlNo}, #{entity.rtnPodrUnqNo}, #{entity.rtnPodrDtlNo}, #{entity.rtnReqUnqNo}, #{entity.rtnReqDtlNo}
806
+            , #{entity.sttlMgntUnqNo}, #{entity.sttlMgntDtlNo}
807
+            , now(), #{userId}, now(), #{userId})
808
+        </insert>
809
+    -->
810
+    </mapper>

+ 1 - 1
src/main/resources/mybatis/sqlmaps/sttlmng/SttlReq.xml

@@ -54,7 +54,7 @@
54 54
             rpip.store_id, FN_STORE_NM(rpip.brand_id, rpip.store_id) AS store_nm,
55 55
             smbi.sttl_st_cd, FN_CODE_NM('STTL_ST_CD', smbi.sttl_st_cd) AS sttl_st_nm,           /* 정산상태 */
56 56
             rpip.item_id, rpip.item_nm, rpip.unit, rpip.unit_amt,
57
-            rpip.rtn_qty, 0 as dlv_qty, rpip.col_qty, rpip.col_dt, rpip.col_amt,
57
+            rpip.col_req_qty as rtn_qty, 0 as dlv_qty, rpip.col_qty, rpip.col_dt, rpip.col_amt,
58 58
             IFNULL(smdp.sttl_dvsn, 'SC00') AS sttl_dvsn, FN_CODE_NM('STTL_DVSN', IFNULL(smdp.sttl_dvsn, 'SC00')) AS sttl_dvsn_nm, /* 정산구분 */
59 59
             rpip.rtn_podr_unq_no, rpip.rtn_podr_dtl_no,
60 60
             store.loan_mgnt_unq_no,     /* 여신관리고유번호 */