浏览代码

반품입고처리및 구매발주 입고처리시 재고이력 수정

dwkim 2 年之前
父节点
当前提交
4e482e47f1

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

@@ -29,6 +29,7 @@ public enum SystemMessageCode {
29 29
     RTN_REQ_OK (20023, "반품요청 되었습니다.", HttpStatus.OK),
30 30
     CANCEL_OK (20024, "취소 되었습니다.", HttpStatus.OK),
31 31
     COL_OK (20025, "수거지시 처리되었습니다.", HttpStatus.OK),
32
+    RTN_PROC_OK (20026, "반품처리 되었습니다.", HttpStatus.OK),
32 33
     ERR_PW(40001, "현재의 비밀번호가 틀립니다. ", HttpStatus.BAD_REQUEST),
33 34
     ERR_FIND_ID(40002, "입력하신  정보로 등록된 아이디가 없습니다.", HttpStatus.BAD_REQUEST),
34 35
     ERR_FIND_PW(40003, "입력하신  정보로 등록된 아이디가 없습니다.", HttpStatus.BAD_REQUEST),

+ 21 - 4
src/main/java/com/oqpo/api/mapper/inoutmng/ColOdrMapper.java

@@ -7,6 +7,8 @@ import com.oqpo.api.entity.pomng.PchOdrDtlPtclEntity;
7 7
 import com.oqpo.api.entity.rtnmng.RtnOdrBaseInfoEntity;
8 8
 import com.oqpo.api.entity.rtnmng.RtnOdrDtlPtclEntity;
9 9
 import com.oqpo.api.entity.rtnmng.RtnProcInfoPtclEntity;
10
+import com.oqpo.api.entity.stockmng.StckMgntBaseInfoEntity;
11
+import com.oqpo.api.entity.stockmng.StckMgntDtlHistEntity;
10 12
 import com.oqpo.api.entity.stockmng.WhsProcInfoPtclEntity;
11 13
 import com.oqpo.api.web.dto.request.GridRequest;
12 14
 import org.apache.ibatis.annotations.Mapper;
@@ -47,16 +49,31 @@ public interface ColOdrMapper {
47 49
     List<PickInfoMgntEntity> selectColSpplyPickGridList(@Param("sBrandId") String sBrandId, @Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("sSpplyId") String sSpplyId, @Param("sWhsId") String sWhsId,  @Param("sItemNm") String sItemNm, GridRequest gridRequest)throws Exception;
48 50
     int selectColSpplyPickGridCnt(@Param("sBrandId") String sBrandId, @Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("sSpplyId") String sSpplyId, @Param("sWhsId") String sWhsId,  @Param("sItemNm") String sItemNm)throws Exception;
49 51
 
50
-    List<PickInfoMgntEntity> selectColRtnInstGridList(@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;
51
-    int selectColRtnInstGridCnt(@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;
52
+    List<PickInfoMgntEntity> selectColRtnInstGridList(@Param("sBrandId") String sBrandId, @Param("sStoreId") String sStoreId,  @Param("sColPickUnqNo") String sColPickUnqNo, @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;
53
+    int selectColRtnInstGridCnt(@Param("sBrandId") String sBrandId, @Param("sStoreId") String sStoreId,  @Param("sColPickUnqNo") String sColPickUnqNo, @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;
52 54
 
53 55
     int insertRtnProcInfoPtcl(@Param("userId") String userId, List<RtnProcInfoPtclEntity> gridInsertData) throws Exception;
54 56
 
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
-    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
+    List<PickInfoMgntEntity> selectColRtnInstResultGridList(@Param("sBrandId") String sBrandId, @Param("sStoreId") String sStoreId, @Param("sColPickUnqNo") String sColPickUnqNo,  @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;
58
+    int selectColRtnInstResultGridCnt(@Param("sBrandId") String sBrandId, @Param("sStoreId") String sStoreId,  @Param("sColPickUnqNo") String sColPickUnqNo, @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 59
 
58 60
     List<PickInfoMgntEntity> selectColRtnInstProcList(@Param("brandId") String brandId, @Param("whsId") String whsId,List<RtnProcInfoPtclEntity> gridUpdateData )throws Exception;
59 61
 
62
+    int updateChgStckQtyStckMgnt(@Param("userId") String userId, List<StckMgntBaseInfoEntity> gridUpdateData) throws Exception;
63
+
64
+    int insertChgStckStckMgntDtlHist(@Param("userId") String userId, List<StckMgntDtlHistEntity> gridInsertData) throws Exception;
65
+
66
+    int updateChgStckCloDtlStCd(@Param("userId") String userId, List<ColOdrDtlPtclEntity> gridUpdateData) throws Exception;
67
+
68
+    int updateChgStckPickDtlStCd(@Param("userId") String userId, List<PickDtlPtclEntity> gridUpdateData) throws Exception;
69
+
70
+    List<ColOdrBaseEntity> selectColCmdStDtlList(@Param("userId") String userId, List<ColOdrBaseEntity> gridUpdateData ) throws Exception;
71
+
72
+    int updateChgStckColOdrStCd(@Param("userId") String userId, List<ColOdrBaseEntity> gridUpdateData) throws Exception;
73
+
74
+    List<PickInfoMgntEntity> selectColPickStList(@Param("userId") String userId, List<PickInfoMgntEntity> gridUpdateData ) throws Exception;
75
+
76
+    int updateChgStckPickStCd(@Param("userId") String userId, List<PickInfoMgntEntity> gridUpdateData) throws Exception;
60 77
 
61 78
     //int insertRtnProcInfoPtcl(@Param("userId") String userId, RtnProcInfoPtclEntity entity) throws Exception;
62 79
 

+ 198 - 134
src/main/java/com/oqpo/api/service/inoutmng/ColOdrService.java

@@ -724,16 +724,16 @@ public class ColOdrService extends CommonService {
724 724
   /*
725 725
       반품처리 그리드 리스트 조회
726 726
  */
727
-    public GridResponse selectRtnStockTargetList(String sBrandId, String sStoreId,  String fromDt, String toDt, String sRtnWhsId, String sSpplyId, String sWhsId, String sItemNm, GridRequest gridRequest) throws Exception {
727
+    public GridResponse selectRtnStockTargetList(String sBrandId, String sStoreId, String sColPickUnqNo ,String fromDt, String toDt, String sRtnWhsId, String sSpplyId, String sWhsId, String sItemNm, GridRequest gridRequest) throws Exception {
728 728
         int gridPage = gridRequest.getGridPage();
729 729
         int gridSize = gridRequest.getGridSize();
730 730
 
731 731
         fromDt = fromDt == null ? null : fromDt.replace(".", "");
732 732
         toDt = toDt == null ? null : toDt.replace(".", "");
733 733
 
734
-        int gridRecords = colOdrMapper.selectColRtnInstGridCnt(sBrandId, sStoreId, fromDt, toDt, sSpplyId, sRtnWhsId,  sWhsId,  sItemNm);
734
+        int gridRecords = colOdrMapper.selectColRtnInstGridCnt(sBrandId, sStoreId,sColPickUnqNo, fromDt, toDt, sSpplyId, sRtnWhsId,  sWhsId,  sItemNm);
735 735
         int gridTotal = fnCalculateGridTotal(gridSize, gridRecords);
736
-        List<PickInfoMgntEntity> entities = colOdrMapper.selectColRtnInstGridList(sBrandId, sStoreId, fromDt, toDt, sSpplyId, sRtnWhsId, sWhsId, sItemNm, gridRequest);
736
+        List<PickInfoMgntEntity> entities = colOdrMapper.selectColRtnInstGridList(sBrandId, sStoreId, sColPickUnqNo, fromDt, toDt, sSpplyId, sRtnWhsId, sWhsId, sItemNm, gridRequest);
737 737
         List<Object> gridRows = entities.stream()
738 738
                 .map(m -> RtnStockTargetResponse.builder()
739 739
                         .viewCd("R")
@@ -769,7 +769,7 @@ public class ColOdrService extends CommonService {
769 769
 
770 770
 
771 771
 
772
-    /* 입고처리 저장
772
+    /* 입고처리 저장 */
773 773
     @Transactional
774 774
     public void saveRtnStockProc(String userId, SaveRtnStockProcRequest saveRtnStockProcRequest) throws Exception {
775 775
         try {
@@ -786,9 +786,16 @@ public class ColOdrService extends CommonService {
786 786
                 //로그인 사용자 정보
787 787
                 UserMngEntity uEntity = userMngMapper.selectGroupUserInfo(userId);
788 788
 
789
+                List<RtnProcInfoPtclEntity> rtnProcInfoPtclList = new ArrayList<RtnProcInfoPtclEntity>();
790
+                List<StckMgntBaseInfoEntity> stckMgntBaseInfoList = new ArrayList<StckMgntBaseInfoEntity>();
791
+                List<StckMgntDtlHistEntity> stckMgntDtlHistList= new ArrayList<StckMgntDtlHistEntity>();
792
+                List<ColOdrDtlPtclEntity> colOdrDtlPtclList= new ArrayList<ColOdrDtlPtclEntity>();
793
+                List<PickDtlPtclEntity> pickDtlPtclList= new ArrayList<PickDtlPtclEntity>();
794
+                List<ColOdrBaseEntity> colOdrBaseList= new ArrayList<ColOdrBaseEntity>();
795
+                List<PickInfoMgntEntity> pickInfoMgntList = new ArrayList<PickInfoMgntEntity>();
789 796
 
790 797
                 // 반품처리를 위한 관련정보를 가져온다
791
-                List<PickInfoMgntEntity> targetList = colOdrMapper.selectColRtnInstProcList(saveRtnStockProcRequest.getBrandId(), saveRtnStockProcRequest.getWhsId(), searchList);
798
+                List<PickInfoMgntEntity> targetList = colOdrMapper.selectColRtnInstProcList(saveRtnStockProcRequest.getBrandId(), saveRtnStockProcRequest.getRtnWhsId(), searchList);
792 799
 
793 800
                 for (int i = 0; i < gridInsertData.size(); i++) {
794 801
                     RtnProcInfoPtclEntity requestData = gridInsertData.get(i);
@@ -798,7 +805,12 @@ public class ColOdrService extends CommonService {
798 805
 
799 806
                         RtnProcInfoPtclEntity rtnProcInfoEntity = new RtnProcInfoPtclEntity();
800 807
 
801
-                        if (requestData.getColPickDtlNo().equals(targetData.getColPickUnqNo()) && requestData.getColPickDtlNo().equals(targetData.getPickDtlInfo().getColPickDtlNo())) {
808
+                        if (requestData.getColPickUnqNo().equals(targetData.getColPickUnqNo()) && requestData.getColPickDtlNo().equals(targetData.getPickDtlInfo().getColPickDtlNo())) {
809
+
810
+                            if (targetData.getColDvsn().equals("C001") && "".equals(saveRtnStockProcRequest.getStoreId())) {
811
+                                throw new GlobalException(SystemMessageCode.ERR_NONSTOREID);
812
+                            }
813
+
802 814
                             if (requestData.getColQty() > targetData.getPickDtlInfo().getColReqQty()) {
803 815
                                 // 반품입고수량이 수거요청수량보다 클 수 없습니다.
804 816
                                 throw new GlobalException(SystemMessageCode.ERR_NOTRTNQTY);
@@ -811,138 +823,190 @@ public class ColOdrService extends CommonService {
811 823
                         }
812 824
 
813 825
                         // 반품처리  진행 데이타생성
826
+                        if (requestData.getColPickUnqNo().equals(targetData.getColPickUnqNo()) && requestData.getColPickDtlNo().equals(targetData.getPickDtlInfo().getColPickDtlNo())) {
827
+                            String rtnMgntUnqNo = fnGetDealNo(37, "");
828
+                            rtnProcInfoEntity.setRtnMgntUnqNo(rtnMgntUnqNo);
829
+                            rtnProcInfoEntity.setBrandId(saveRtnStockProcRequest.getBrandId());
830
+                            rtnProcInfoEntity.setStoreId(saveRtnStockProcRequest.getStoreId());
831
+                            rtnProcInfoEntity.setItemId(requestData.getItemId());
832
+                            rtnProcInfoEntity.setItemNm(targetData.getPickDtlInfo().getItemNm());
833
+                            rtnProcInfoEntity.setWhsId(saveRtnStockProcRequest.getRtnWhsId());
834
+                            rtnProcInfoEntity.setLocation(targetData.getRtnLocation());
835
+                            rtnProcInfoEntity.setUnit(targetData.getPickDtlInfo().getUnit());
836
+                            rtnProcInfoEntity.setUnitAmt(targetData.getPickDtlInfo().getUnitAmt());
837
+                            rtnProcInfoEntity.setRtnReqQty(targetData.getPickDtlInfo().getRtnReqQty());
838
+                            rtnProcInfoEntity.setRtnOdrQty(targetData.getPickDtlInfo().getRodrQty());
839
+                            rtnProcInfoEntity.setColReqQty(targetData.getPickDtlInfo().getColReqQty());
840
+                            rtnProcInfoEntity.setColQty(requestData.getColQty());
841
+                            rtnProcInfoEntity.setColReqDt(targetData.getColReqDt());
842
+                            rtnProcInfoEntity.setColSchDt(targetData.getColSchDt());
843
+                            rtnProcInfoEntity.setColCnfmNm(uEntity.getUserNm());
844
+                            rtnProcInfoEntity.setColMgrTelNo(targetData.getPickMgrTelNo());
845
+                            rtnProcInfoEntity.setColAmt(requestData.getColQty() * targetData.getPickDtlInfo().getUnitAmt());
846
+                            rtnProcInfoEntity.setColAgrYn("Y");
847
+                            // rtnProcInfoEntity.setColCnfmDocFileNo(saveRtnStockProcRequest.); 수거서 파일 첨부 제거
848
+                            rtnProcInfoEntity.setSttlYn("N");
849
+                            rtnProcInfoEntity.setSpplyId(targetData.getSpplyId());
850
+                            rtnProcInfoEntity.setSpplyNm(targetData.getSpplyNm());
851
+                            rtnProcInfoEntity.setColPickUnqNo(targetData.getColPickUnqNo());
852
+                            rtnProcInfoEntity.setColPickDtlNo(targetData.getPickDtlInfo().getColPickDtlNo());
853
+                            rtnProcInfoEntity.setColCmdUnqNo(targetData.getPickDtlInfo().getColCmdUnqNo());
854
+                            rtnProcInfoEntity.setColCmdDtlNo(targetData.getPickDtlInfo().getColCmdDtlNo());
855
+                            rtnProcInfoEntity.setRtnPodrUnqNo(targetData.getPickDtlInfo().getRtnPodrUnqNo());
856
+                            rtnProcInfoEntity.setRtnPodrDtlNo(targetData.getPickDtlInfo().getRtnPodrDtlNo());
857
+                            rtnProcInfoEntity.setRtnReqUnqNo(targetData.getPickDtlInfo().getRtnReqUnqNo());
858
+                            rtnProcInfoEntity.setRtnReqDtlNo(targetData.getPickDtlInfo().getRtnReqDtlNo());
859
+                            rtnProcInfoPtclList.add(rtnProcInfoEntity);
860
+
861
+                            // 본사 수거 반품입고처리시
862
+                            if (targetData.getColDvsn().equals("C001") && requestData.getColQty() > 0) {
863
+                                //본사수거 .
864
+                                // 1. 매장재고참감처리, 본사재고 증가, 2. 반품처리테이블 생성, 3. 수거서 업데이타, 4, 반품발주건 업데이트
865
+                                // 매장재고 차감
866
+                                StckMgntBaseInfoEntity stckWEntity = new StckMgntBaseInfoEntity();
867
+                                stckWEntity.setBrandId(saveRtnStockProcRequest.getBrandId());
868
+                                stckWEntity.setWhsId(saveRtnStockProcRequest.getRtnWhsId());
869
+                                stckWEntity.setLocation(targetData.getRtnLocation());
870
+                                stckWEntity.setItemId(requestData.getItemId());
871
+                                stckWEntity.setStckQty(requestData.getColQty() * (-1));
872
+                                stckWEntity.setUnit(targetData.getPickDtlInfo().getUnit());
873
+                                stckMgntBaseInfoList.add(stckWEntity);
874
+
875
+                                // 재고 이력정보 등록
876
+                                StckMgntDtlHistEntity stckWHist = new StckMgntDtlHistEntity();
877
+                                stckWHist.setStckMgntDtlNo(fnGetDealNo(37, ""));
878
+                                stckWHist.setBrandId(saveRtnStockProcRequest.getBrandId());
879
+                                stckWHist.setWhsId(saveRtnStockProcRequest.getRtnWhsId());
880
+                                stckWHist.setLocation(targetData.getRtnLocation());
881
+                                stckWHist.setItemId(requestData.getItemId());
882
+                                stckWHist.setItemNm(targetData.getPickDtlInfo().getItemNm());
883
+                                stckWHist.setInoutCd("OUT");
884
+                                stckWHist.setInoutQty(requestData.getColQty());
885
+                                stckWHist.setChgDvsn("ROUT");
886
+                                stckWHist.setRelationNo(rtnMgntUnqNo);
887
+                                stckMgntDtlHistList.add(stckWHist);
888
+
889
+                                //본사재고 증가
890
+                                StckMgntBaseInfoEntity stckW1Entity = new StckMgntBaseInfoEntity();
891
+                                stckW1Entity.setBrandId(saveRtnStockProcRequest.getBrandId());
892
+                                stckW1Entity.setWhsId(saveRtnStockProcRequest.getWhsId());
893
+                                stckW1Entity.setLocation(targetData.getLocation());
894
+                                stckW1Entity.setItemId(requestData.getItemId());
895
+                                stckW1Entity.setStckQty(requestData.getColQty());
896
+                                stckW1Entity.setUnit(targetData.getPickDtlInfo().getUnit());
897
+                                stckMgntBaseInfoList.add(stckW1Entity);
898
+
899
+                                // 재고 이력정보 등록
900
+                                StckMgntDtlHistEntity stckW1Hist = new StckMgntDtlHistEntity();
901
+                                stckW1Hist.setStckMgntDtlNo(fnGetDealNo(37, ""));
902
+                                stckW1Hist.setBrandId(saveRtnStockProcRequest.getBrandId());
903
+                                stckW1Hist.setWhsId(saveRtnStockProcRequest.getWhsId());
904
+                                stckW1Hist.setLocation(targetData.getLocation());
905
+                                stckW1Hist.setItemId(requestData.getItemId());
906
+                                stckW1Hist.setItemNm(targetData.getPickDtlInfo().getItemNm());
907
+                                stckW1Hist.setInoutCd("OUT");
908
+                                stckW1Hist.setInoutQty(requestData.getColQty());
909
+                                stckW1Hist.setChgDvsn("ROUT");
910
+                                stckW1Hist.setRelationNo(rtnMgntUnqNo);  //======================================
911
+                                stckMgntDtlHistList.add(stckW1Hist);
912
+
913
+                            } else if (targetData.getColDvsn().equals("C002") && requestData.getColQty() > 0) {
914
+                                //  공급사 수거일경우 - 본사창고 재고 차감 처리
915
+                                // 1. 참감처리 , 2. 반품처리테이블 생성, 3. 수거서 업데이타, 4, 반품발주건 업데이트
916
+                                // 본사재고 차감 처리  stck_mgnt_base_info  stck_mgnt_dtl_hist
917
+                                StckMgntBaseInfoEntity stckWEntity = new StckMgntBaseInfoEntity();
918
+                                stckWEntity.setBrandId(saveRtnStockProcRequest.getBrandId());
919
+                                stckWEntity.setWhsId(saveRtnStockProcRequest.getRtnWhsId());
920
+                                stckWEntity.setLocation(targetData.getRtnLocation());
921
+                                stckWEntity.setItemId(requestData.getItemId());
922
+                                stckWEntity.setStckQty(requestData.getColQty() * (-1));
923
+                                stckWEntity.setUnit(targetData.getPickDtlInfo().getUnit());
924
+                                stckMgntBaseInfoList.add(stckWEntity);
925
+
926
+                                // 재고 이력정보 등록
927
+                                StckMgntDtlHistEntity stckWHist = new StckMgntDtlHistEntity();
928
+                                stckWHist.setStckMgntDtlNo(fnGetDealNo(37, ""));
929
+                                stckWHist.setBrandId(saveRtnStockProcRequest.getBrandId());
930
+                                stckWHist.setWhsId(saveRtnStockProcRequest.getRtnWhsId());
931
+                                stckWHist.setLocation(targetData.getRtnLocation());
932
+                                stckWHist.setItemId(requestData.getItemId());
933
+                                stckWHist.setItemNm(targetData.getPickDtlInfo().getItemNm());
934
+                                stckWHist.setInoutCd("OUT");
935
+                                stckWHist.setInoutQty(requestData.getColQty());
936
+                                stckWHist.setChgDvsn("ROUT");
937
+                                stckWHist.setRelationNo(rtnMgntUnqNo);  //======================================
938
+                                stckMgntDtlHistList.add(stckWHist);
939
+                            }
814 940
 
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
-                        }
941
+                            if (targetData.getColDvsn().equals("C001")) {  // 본사수거지시 일 경우
942
+                                ColOdrDtlPtclEntity colOdrDtlPtclEntity = new ColOdrDtlPtclEntity();
943
+                                colOdrDtlPtclEntity.setColCmdUnqNo(targetData.getPickDtlInfo().getColCmdUnqNo());
944
+                                colOdrDtlPtclEntity.setColCmdDtlNo(targetData.getPickDtlInfo().getColCmdDtlNo());
945
+                                if (requestData.getColQty() > 0) {
946
+                                    colOdrDtlPtclEntity.setColCmdDtlStCd("CDLD2");
947
+                                } else {
948
+                                    colOdrDtlPtclEntity.setColCmdDtlStCd("COLD3");
949
+                                }
950
+                                colOdrDtlPtclList.add(colOdrDtlPtclEntity);
951
+
952
+                                ColOdrBaseEntity colOdrBase = new ColOdrBaseEntity();
953
+                                colOdrBase.setColCmdUnqNo(targetData.getPickDtlInfo().getColCmdUnqNo());
954
+                                colOdrBaseList.add(colOdrBase);
955
+                            }
927 956
 
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");
936
-                        }
957
+                            // 수거서 건별 업데이트
958
+                            PickDtlPtclEntity pickDtlPtclEntity = new PickDtlPtclEntity();
959
+                            pickDtlPtclEntity.setColPickUnqNo(targetData.getColPickUnqNo());
960
+                            pickDtlPtclEntity.setColPickDtlNo(targetData.getPickDtlInfo().getColPickDtlNo());
961
+                            pickDtlPtclEntity.setColQty(requestData.getColQty());
962
+                            pickDtlPtclEntity.setColAmt(requestData.getColQty() * targetData.getPickDtlInfo().getUnitAmt());
963
+                            if (requestData.getColQty() > 0) {
964
+                                pickDtlPtclEntity.setPickDtlStCd("PICKD1");
965
+                            } else {
966
+                                pickDtlPtclEntity.setPickDtlStCd("PICKD3");
967
+                            }
968
+                            pickDtlPtclList.add(pickDtlPtclEntity);
937 969
 
938
-                        //저장된 정보 신규 등록 및 업데이트 처리함
939
-                        colOdrMapper.insertRtnProcInfoPtcl(userId,rtnProcInfoEntity );
970
+                            PickInfoMgntEntity pickInfoEntity = new PickInfoMgntEntity();
971
+                            pickInfoEntity.setColPickUnqNo(targetData.getColPickUnqNo());
972
+                            pickInfoMgntList.add(pickInfoEntity);
973
+                        }
940 974
 
941 975
                     } //==> targetList db에서 가온 수거정보
976
+                } //==> request에서 가져온 전달받은 정보
977
+
978
+                //정보 저장함
979
+                if (rtnProcInfoPtclList.size() > 0 ) {
980
+                    colOdrMapper.insertRtnProcInfoPtcl(userId,rtnProcInfoPtclList );
981
+                }
942 982
 
983
+                if (stckMgntBaseInfoList.size() > 0 ) {
984
+                    colOdrMapper.updateChgStckQtyStckMgnt(userId, stckMgntBaseInfoList);
985
+                }
943 986
 
987
+                if (stckMgntDtlHistList.size() > 0 ) {
988
+                    colOdrMapper.insertChgStckStckMgntDtlHist(userId, stckMgntDtlHistList);
989
+                }
944 990
 
945
-                } //==> request에서 가져온 전달받은 정보
991
+                if (colOdrDtlPtclList.size() > 0 ) {
992
+                    colOdrMapper.updateChgStckCloDtlStCd(userId, colOdrDtlPtclList);
993
+                }
994
+
995
+                if (pickDtlPtclList.size() > 0 ) {
996
+                    colOdrMapper.updateChgStckPickDtlStCd(userId, pickDtlPtclList);
997
+                }
998
+
999
+                // 마스터성 수거지시 마스터  업데이트
1000
+                if (colOdrBaseList.size() > 0 ) {
1001
+                    List<ColOdrBaseEntity>  colOdrStList = colOdrMapper.selectColCmdStDtlList(userId, colOdrBaseList);
1002
+                    colOdrMapper.updateChgStckColOdrStCd(userId,colOdrStList );
1003
+                }
1004
+
1005
+                // 수거서 마스터 업데이트
1006
+                if (pickInfoMgntList.size() > 0 ) {
1007
+                    List<PickInfoMgntEntity>  pickInfoList = colOdrMapper.selectColPickStList(userId, pickInfoMgntList);
1008
+                    colOdrMapper.updateChgStckPickStCd(userId, pickInfoList);
1009
+                }
946 1010
             }
947 1011
 
948 1012
         } catch (GlobalException e) {
@@ -954,20 +1018,20 @@ public class ColOdrService extends CommonService {
954 1018
             throw new RuntimeException();
955 1019
         }
956 1020
     }
957
-*/
1021
+
958 1022
     /*
959 1023
       반품처리현황 그리드 리스트 조회
960 1024
  */
961
-    public GridResponse selectRtnStockResultList(String sBrandId, String sStoreId,  String fromDt, String toDt, String sRtnWhsId, String sSpplyId, String sWhsId, String sItemNm, GridRequest gridRequest) throws Exception {
1025
+    public GridResponse selectRtnStockResultList(String sBrandId, String sStoreId, String sColPickUnqNo, String fromDt, String toDt, String sRtnWhsId, String sSpplyId, String sWhsId, String sItemNm, GridRequest gridRequest) throws Exception {
962 1026
         int gridPage = gridRequest.getGridPage();
963 1027
         int gridSize = gridRequest.getGridSize();
964 1028
 
965 1029
         fromDt = fromDt == null ? null : fromDt.replace(".", "");
966 1030
         toDt = toDt == null ? null : toDt.replace(".", "");
967 1031
 
968
-        int gridRecords = colOdrMapper.selectColRtnInstResultGridCnt(sBrandId, sStoreId, fromDt, toDt, sSpplyId, sRtnWhsId,  sWhsId,  sItemNm);
1032
+        int gridRecords = colOdrMapper.selectColRtnInstResultGridCnt(sBrandId, sStoreId,sColPickUnqNo,  fromDt, toDt, sSpplyId, sRtnWhsId,  sWhsId,  sItemNm);
969 1033
         int gridTotal = fnCalculateGridTotal(gridSize, gridRecords);
970
-        List<PickInfoMgntEntity> entities = colOdrMapper.selectColRtnInstResultGridList(sBrandId, sStoreId, fromDt, toDt, sSpplyId, sRtnWhsId, sWhsId, sItemNm, gridRequest);
1034
+        List<PickInfoMgntEntity> entities = colOdrMapper.selectColRtnInstResultGridList(sBrandId, sStoreId, sColPickUnqNo, fromDt, toDt, sSpplyId, sRtnWhsId, sWhsId, sItemNm, gridRequest);
971 1035
         List<Object> gridRows = entities.stream()
972 1036
                 .map(m -> RtnColStockResultResponse.builder()
973 1037
                         .viewCd("R")

+ 18 - 1
src/main/java/com/oqpo/api/service/inoutmng/ShmtOdrService.java

@@ -935,7 +935,7 @@ public class ShmtOdrService extends CommonService {
935 935
                 List<DeliDtlMgntEntity> deliDtlGridUpdateData = new ArrayList<DeliDtlMgntEntity>();
936 936
                 List<ShmtOdrDtlEntity> shmtDtlGridUpdateData = new ArrayList<ShmtOdrDtlEntity>();
937 937
                 List<PchOdrDtlPtclEntity> PchOdrDtlGridUpdateData = new ArrayList<PchOdrDtlPtclEntity>();
938
-
938
+                List<StckMgntDtlHistEntity> stckMgntDtlHistList= new ArrayList<StckMgntDtlHistEntity>();
939 939
 
940 940
                 // loan_mgnt_unq_no 매장납품일 경우
941 941
                 //selectStoreLoanMgntUnqNo
@@ -1013,6 +1013,22 @@ public class ShmtOdrService extends CommonService {
1013 1013
                             smbaseInfoEntity.setStckQty(whsProcData.getWhsQty());
1014 1014
                             wareGridUpdateData.add(smbaseInfoEntity);
1015 1015
 
1016
+                            // 재고 이력정보 등록
1017
+                            StckMgntDtlHistEntity stckWHist = new StckMgntDtlHistEntity();
1018
+                            stckWHist.setStckMgntDtlNo(fnGetDealNo(37, ""));
1019
+                            stckWHist.setBrandId(saveWarehouseProcRequest.getBrandId());
1020
+                            stckWHist.setWhsId(saveWarehouseProcRequest.getWhsId());
1021
+                            stckWHist.setLocation(whsProcData.getLocation());
1022
+                            stckWHist.setItemId(whsProcData.getItemId());
1023
+                            stckWHist.setItemNm(targetData.getDeliDtlMgntInfo().getItemNm());
1024
+                            stckWHist.setInoutCd("IN");
1025
+                            stckWHist.setInoutQty(whsProcData.getWhsQty());
1026
+                            stckWHist.setChgDvsn("PIN");
1027
+                            stckWHist.setRelationNo(whsProcData.getWhsMgntUnqNo());
1028
+                            stckMgntDtlHistList.add(stckWHist);
1029
+
1030
+
1031
+
1016 1032
                             // 납품서 상태 정의  dlvSttmtUnqNo  dlvDtlStCd
1017 1033
                             DeliDtlMgntEntity deliDtlEntity = new DeliDtlMgntEntity();
1018 1034
                             deliDtlEntity.setDlvSttmtUnqNo(whsProcData.getDlvSttmtUnqNo());
@@ -1065,6 +1081,7 @@ public class ShmtOdrService extends CommonService {
1065 1081
 
1066 1082
                     // 재고관련 정리 필요
1067 1083
                     stockMngMapper.updateWarehouseStockQty(userId, wareGridUpdateData);
1084
+                    stockMngMapper.insertMultiStckMgntDtlHist(userId, stckMgntDtlHistList);
1068 1085
 
1069 1086
                     // 납품서 상세 처리
1070 1087
                     shmtOdrMapper.updateDeliDtlStCd(userId, deliDtlGridUpdateData);

文件差异内容过多而无法显示
+ 10 - 10
src/main/java/com/oqpo/api/web/controller/inoutmng/ColOdrController.java


+ 3 - 0
src/main/java/com/oqpo/api/web/dto/request/inoutmng/RtnStockTragetGridRequest.java

@@ -19,6 +19,9 @@ public class RtnStockTragetGridRequest extends GridRequest {
19 19
     @ApiModelProperty(value = "매장")
20 20
     private String sStoreId;
21 21
 
22
+    @ApiModelProperty(value = "수거서번호")
23
+    private String sColPickUnqNo;
24
+
22 25
     @NotBlank
23 26
     @ApiModelProperty(value = "시작일자")
24 27
     private String fromDt;

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

@@ -20,6 +20,8 @@ public class SaveRtnStockProcRequest {
20 20
     @ApiModelProperty(value = "브랜드아이디") private String brandId;
21 21
 
22 22
     @NotBlank
23
+    @ApiModelProperty(value = "반품창고아이디") private String rtnWhsId;
24
+
23 25
     @ApiModelProperty(value = "입고창고아이디") private String whsId;
24 26
 
25 27
     @ApiModelProperty(value = "매장창고 반품처리시 필수") private String storeId;

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

@@ -571,14 +571,17 @@
571 571
         <if test="sStoreId != null and sStoreId != ''">
572 572
             and   mgnt.store_id = #{sStoreId}
573 573
         </if>
574
+        <if test="sColPickUnqNo != null and sColPickUnqNo != ''">
575
+            and   mgnt.col_pick_unq_no = #{sColPickUnqNo}
576
+        </if>
574 577
         <if test="sRtnWhsId != null and sRtnWhsId != ''">
575
-        and   base.whs_id = #{sRtnWhsId}
578
+        and   mgnt.whs_id = #{sRtnWhsId}
576 579
         </if>
577 580
         <if test="sSpplyId != null and sSpplyId != ''">
578 581
         and   mgnt.spply_id = #{sSpplyId}
579 582
         </if>
580 583
         <if test="sWhsId != null and sWhsId != ''">
581
-        and   mgnt.whs_id = #{sWhsId}
584
+        and   base.whs_id = #{sWhsId}
582 585
         </if>
583 586
         <if test="sItemNm != null and sItemNm != ''">
584 587
         and   (mgnt.col_pick_unq_no like concat('%',#{sItemNm},'%') or dtl.item_id like concat('%',#{sItemNm},'%') or dtl.item_nm  like concat('%',#{sItemNm},'%') )
@@ -619,14 +622,17 @@
619 622
         <if test="sStoreId != null and sStoreId != ''">
620 623
             and   mgnt.store_id = #{sStoreId}
621 624
         </if>
625
+        <if test="sColPickUnqNo != null and sColPickUnqNo != ''">
626
+            and   mgnt.col_pick_unq_no = #{sColPickUnqNo}
627
+        </if>
622 628
         <if test="sRtnWhsId != null and sRtnWhsId != ''">
623
-            and   base.whs_id = #{sRtnWhsId}
629
+            and   mgnt.whs_id = #{sRtnWhsId}
624 630
         </if>
625 631
         <if test="sSpplyId != null and sSpplyId != ''">
626 632
             and   mgnt.spply_id = #{sSpplyId}
627 633
         </if>
628 634
         <if test="sWhsId != null and sWhsId != ''">
629
-            and   mgnt.whs_id = #{sWhsId}
635
+            and   base.whs_id = #{sWhsId}
630 636
         </if>
631 637
         <if test="sItemNm != null and sItemNm != ''">
632 638
             and   (mgnt.col_pick_unq_no like concat('%',#{sItemNm},'%') or dtl.item_id like concat('%',#{sItemNm},'%') or dtl.item_nm  like concat('%',#{sItemNm},'%') )
@@ -637,8 +643,8 @@
637 643
     <insert id="insertRtnProcInfoPtcl">
638 644
         insert into rtn_proc_info_ptcl
639 645
             (rtn_mgnt_unq_no, brand_id, store_id, item_id, item_nm
640
-            , whs_id, location, unit, unit_amt, rtn_qty
641
-            , rtn_odr_qty, col_qty, col_req_dt, col_sch_dt, col_dt
646
+            , whs_id, location, unit, unit_amt, rtn_req_qty
647
+            , rtn_odr_qty, col_qty, col_req_qty, col_req_dt, col_sch_dt, col_dt
642 648
             , col_cnfm_nm, col_mgr_nm, col_mgr_tel_no, col_mgr_emal, col_mgr_mbl_no
643 649
             , col_amt, col_agr_yn, col_cnfm_doc_file_no, sttl_yn, spply_id
644 650
             , spply_nm, col_pick_unq_no, col_pick_dtl_no, col_cmd_unq_no, col_cmd_dtl_no
@@ -647,8 +653,8 @@
647 653
         values
648 654
         <foreach collection="gridInsertData" item="item" separator=",">
649 655
             (#{item.rtnMgntUnqNo}, #{item.brandId}, #{item.storeId}, #{item.itemId}, #{item.itemNm}
650
-            , #{item.whsId}, #{item.location}, #{item.unit}, #{item.unitAmt}, #{item.rtnQty}
651
-            , #{item.rtnOdrQty}, #{item.colQty}, #{item.colReqDt}, #{item.colSchDt}, #{item.colDt}
656
+            , #{item.whsId}, #{item.location}, #{item.unit}, #{item.unitAmt}, #{item.rtnReqQty}
657
+            , #{item.rtnOdrQty}, #{item.colQty}, #{item.colReqQty}, #{item.colReqDt}, #{item.colSchDt}, #{item.colDt}
652 658
             , #{item.colCnfmNm}, #{item.colMgrNm}, #{item.colMgrTelNo}, #{item.colMgrEmal}, #{item.colMgrMblNo}
653 659
             , #{item.colAmt}, #{item.colAgrYn}, #{item.colCnfmDocFileNo}, #{item.sttlYn}, #{item.spplyId}
654 660
             , #{item.spplyNm}, #{item.colPickUnqNo}, #{item.colPickDtlNo}, #{item.colCmdUnqNo}, #{item.colCmdDtlNo}
@@ -687,14 +693,17 @@
687 693
         <if test="sStoreId != null and sStoreId != ''">
688 694
             and   mgnt.store_id = #{sStoreId}
689 695
         </if>
696
+        <if test="sColPickUnqNo != null and sColPickUnqNo != ''">
697
+            and   mgnt.col_pick_unq_no = #{sColPickUnqNo}
698
+        </if>
690 699
         <if test="sRtnWhsId != null and sRtnWhsId != ''">
691
-            and   base.whs_id = #{sRtnWhsId}
700
+            and   mgnt.whs_id = #{sRtnWhsId}
692 701
         </if>
693 702
         <if test="sSpplyId != null and sSpplyId != ''">
694 703
             and   mgnt.spply_id = #{sSpplyId}
695 704
         </if>
696 705
         <if test="sWhsId != null and sWhsId != ''">
697
-            and   mgnt.whs_id = #{sWhsId}
706
+            and   base.whs_id = #{sWhsId}
698 707
         </if>
699 708
         <if test="sItemNm != null and sItemNm != ''">
700 709
             and   (mgnt.col_pick_unq_no like concat('%',#{sItemNm},'%') or dtl.item_id like concat('%',#{sItemNm},'%') or dtl.item_nm  like concat('%',#{sItemNm},'%') )
@@ -734,14 +743,17 @@
734 743
         <if test="sStoreId != null and sStoreId != ''">
735 744
             and   mgnt.store_id = #{sStoreId}
736 745
         </if>
746
+        <if test="sColPickUnqNo != null and sColPickUnqNo != ''">
747
+            and   mgnt.col_pick_unq_no = #{sColPickUnqNo}
748
+        </if>
737 749
         <if test="sRtnWhsId != null and sRtnWhsId != ''">
738
-            and   base.whs_id = #{sRtnWhsId}
750
+            and   mgnt.whs_id = #{sRtnWhsId}
739 751
         </if>
740 752
         <if test="sSpplyId != null and sSpplyId != ''">
741 753
             and   mgnt.spply_id = #{sSpplyId}
742 754
         </if>
743 755
         <if test="sWhsId != null and sWhsId != ''">
744
-            and   mgnt.whs_id = #{sWhsId}
756
+            and   base.whs_id = #{sWhsId}
745 757
         </if>
746 758
         <if test="sItemNm != null and sItemNm != ''">
747 759
             and   (mgnt.col_pick_unq_no like concat('%',#{sItemNm},'%') or dtl.item_id like concat('%',#{sItemNm},'%') or dtl.item_nm  like concat('%',#{sItemNm},'%') )
@@ -754,12 +766,14 @@
754 766
             , mgnt.store_id,dtl.item_id as 'pickDtlInfo.item_id', dtl.item_nm as 'pickDtlInfo.item_nm'
755 767
             , base.whs_id, base.location
756 768
             , fn_whs_nm(base.brand_id, base.whs_id) as whs_nm, fn_whs_location_nm(base.brand_id, base.whs_id, base.location) as location_nm
769
+            , mgnt.whs_id as rtn_whs_id, mgnt.location as rtn_location
770
+            , fn_whs_nm(base.brand_id, mgnt.whs_id) as rtn_whs_nm, fn_whs_location_nm(base.brand_id, mgnt.whs_id, mgnt.location) as rtn_location_nm
757 771
             , dtl.unit as 'pickDtlInfo.unit' , dtl.unit_amt as 'pickDtlInfo.unit_amt'
758 772
             , ptcl.rtn_req_qty as  'pickDtlInfo.rtn_req_qty'   , dtl.rodr_qty as 'pickDtlInfo.rodr_qty'
759 773
             , dtl.col_req_qty as 'pickDtlInfo.col_req_qty'
760
-            , date_format(mgnt.col_req_dt,'%Y.%m.%d') as col_req_dt
761
-            , date_format(mgnt.col_sch_dt,'%Y.%m.%d') as col_sch_dt
762
-            , date_format(mgnt.col_cmplt_dt,'%Y.%m.%d') as col_cmplt_dt
774
+            , date_format(mgnt.col_req_dt,'%Y%m%d') as col_req_dt
775
+            , date_format(mgnt.col_sch_dt,'%Y%m%d') as col_sch_dt
776
+            , date_format(mgnt.col_cmplt_dt,'%Y%m%d') as col_cmplt_dt
763 777
             , mgnt.pick_mgr_nm, fn_get_telno(mgnt.pick_mgr_tel_no) as pick_mgr_tel_no
764 778
             , dtl.col_req_amt as 'pickDtlInfo.col_req_amt'
765 779
             , mgnt.spply_id, fn_spply_nm(mgnt.spply_id) as spply_nm
@@ -777,13 +791,120 @@
777 791
         and   dtl.rtn_podr_dtl_no = ptcl.rtn_podr_dtl_no
778 792
         and   ptcl.rtn_podr_unq_no = base.rtn_podr_unq_no
779 793
         and   mgnt.brand_id = #{brandId}
780
-        and   base.whs_id = #{whsId}
781
-        and    concat(base.col_pick_unq_no, ptcl.col_pick_dtl_no) in
794
+        and   mgnt.whs_id = #{whsId}
795
+        and    concat(mgnt.col_pick_unq_no, dtl.col_pick_dtl_no) in
782 796
         <foreach collection="gridUpdateData" item="item" separator="," open="(" close=")">
783 797
             #{item.colPickUnqNo}
784 798
         </foreach>
785 799
     </select>
800
+
801
+
802
+    <update id="updateChgStckQtyStckMgnt">
803
+        <foreach collection="gridUpdateData" item="item" separator=";">
804
+            update stck_mgnt_base_info
805
+            set    sys_chg_id = #{userId}
806
+                 , sys_chg_dttm = now()
807
+                 , stck_qty = stck_qty + #{item.stckQty}
808
+            where brand_id = #{item.brandId}
809
+            and   whs_id = #{item.whsId}
810
+            and   location = #{item.location}
811
+            and   item_id = #{item.itemId}
812
+        </foreach>
813
+    </update>
814
+
815
+    <insert id="insertChgStckStckMgntDtlHist" >
816
+        /* StockMngMapper.insertStckMgntDtlHist */
817
+        INSERT INTO stck_mgnt_dtl_hist
818
+            (stck_mgnt_dtl_no, brand_id, whs_id, location, item_id, item_nm, inout_cd, inout_qty, whs_mgnt_unq_no,
819
+             rtn_mgnt_unq_no, chg_dvsn, relation_no, sys_reg_dttm,
820
+             sys_reg_id, sys_chg_dttm, sys_chg_id)
821
+        VALUES
822
+        <foreach collection="gridInsertData" item="item" separator=",">
823
+            (#{item.stckMgntDtlNo}, #{item.brandId}, #{item.whsId}, #{item.location}, #{item.itemId},
824
+             #{item.itemNm}, #{item.inoutCd}, #{item.inoutQty}, #{item.whsMgntUnqNo}, #{item.rtnMgntUnqNo}, #{item.chgDvsn}, #{item.relationNo},
825
+             NOW(), #{userId}, NOW(), #{userId})
826
+        </foreach>
827
+    </insert>
828
+    <update id="updateChgStckCloDtlStCd">
829
+        <foreach collection="gridUpdateData" item="item" separator=";">
830
+            update col_odr_dtl_ptcl
831
+            set    sys_chg_id = #{userId}
832
+                , sys_chg_dttm = now()
833
+                , col_cmd_dtl_st_cd = #{item.colCmdDtlStCd}
834
+            where col_cmd_unq_no = #{item.colCmdUnqNo}
835
+            and   col_cmd_dtl_no = #{item.colCmdDtlNo}
836
+        </foreach>
837
+    </update>
838
+
839
+    <update id="updateChgStckPickDtlStCd">
840
+        <foreach collection="gridUpdateData" item="item" separator=";">
841
+            update pick_dtl_ptcl
842
+            set    sys_chg_id = #{userId}
843
+                , sys_chg_dttm = now()
844
+                , pick_dtl_st_cd = #{item.pickDtlStCd}
845
+            where col_pick_unq_no = #{item.colPickUnqNo}
846
+            and   col_pick_dtl_no = #{item.colPickDtlNo}
847
+        </foreach>
848
+    </update>
849
+
850
+    <select id="selectColCmdStDtlList" resultType="com.oqpo.api.entity.inoutmng.ColOdrBaseEntity">
851
+        select stData.col_cmd_unq_no , case when stData.cdld1 <![CDATA[>]]> 0 then 'COL1' when stData.cdld1 = 0 and stData.cdld2 <![CDATA[>]]> 0 then 'COL2' else 'COL3' end as col_cmd_st_cd
852
+        from  (
853
+                select col_cmd_unq_no
854
+                    , sum(case when col_cmd_dtl_st_cd = 'CDLD1' then 1 else 0 end)  as cdld1
855
+                    , sum(case when col_cmd_dtl_st_cd = 'CDLD2' then 1 else 0 end)  as cdld2
856
+                    , sum(case when col_cmd_dtl_st_cd = 'CDLD3' then 1 else 0 end)  as cdld3
857
+                from  col_odr_dtl_ptcl
858
+                where col_cmd_unq_no in
859
+                <foreach collection="gridUpdateData" item="item" separator="," open="(" close=")">
860
+                    #{item.colCmdUnqNo}
861
+                </foreach>
862
+                group by col_cmd_unq_no
863
+        ) stData
864
+    </select>
865
+
866
+    <update id="updateChgStckColOdrStCd">
867
+        <foreach collection="gridUpdateData" item="item" separator=";">
868
+            update col_odr_base_info
869
+            set    sys_chg_id = #{userId}
870
+                , sys_chg_dttm = now()
871
+                , col_cmd_st_cd = #{item.colCmdStCd}
872
+            where col_cmd_unq_no = #{item.colCmdUnqNo}
873
+        </foreach>
874
+    </update>
875
+
876
+    <select id="selectColPickStList" resultType="com.oqpo.api.entity.inoutmng.PickInfoMgntEntity">
877
+        select stData.col_pick_unq_no , case when stData.pickd0 <![CDATA[>]]> 0 then 'PICK0' when stData.pickd0 = 0 and stData.pickd1 <![CDATA[>]]> 0 then 'PICK1' else 'PICK3' end as pick_st_cd
878
+        from  (
879
+            select col_pick_unq_no
880
+                , sum(case when pick_dtl_st_cd = 'PICKD0' then 1 else 0 end)  as pickd0
881
+                , sum(case when pick_dtl_st_cd = 'PICKD1' then 1 else 0 end)  as pickd1
882
+                , sum(case when pick_dtl_st_cd = 'PICKD3' then 1 else 0 end)  as pickd3
883
+            from  pick_dtl_ptcl
884
+            where col_pick_unq_no in
885
+                <foreach collection="gridUpdateData" item="item" separator="," open="(" close=")">
886
+                    #{item.colPickUnqNo}
887
+                </foreach>
888
+            group by col_pick_unq_no
889
+        ) stData
890
+    </select>
891
+
892
+    <update id="updateChgStckPickStCd">
893
+        <foreach collection="gridUpdateData" item="item" separator=";">
894
+            update pick_info_mgnt
895
+            set    sys_chg_id = #{userId}
896
+                , sys_chg_dttm = now()
897
+                , pick_st_cd = #{item.pickStCd}
898
+            where col_pick_unq_no = #{item.colPickUnqNo}
899
+        </foreach>
900
+    </update>
786 901
     <!--
902
+
903
+
904
+    in
905
+        <foreach collection="gridUpdateData" item="item" separator="," open="(" close=")">
906
+            concat(#{item.rtnPodrUnqNo},#{item.rtnPodrDtlNo})
907
+        </foreach>
787 908
         <insert id="insertRtnProcInfoPtcl">
788 909
             insert into rtn_proc_info_ptcl
789 910
             (rtn_mgnt_unq_no, brand_id, store_id, item_id, item_nm