Bläddra i källkod

출하지시 부분 작업

dwkim 2 år sedan
förälder
incheckning
eb0330f4e2
24 ändrade filer med 1144 tillägg och 12 borttagningar
  1. BIN
      doc/오더퀸_수발주ADMIN_API_스토리보드_V0.8_20221017.pptx
  2. 38 0
      src/main/java/com/oqpo/api/entity/inoutmng/DeliDtlMgntEntity.java
  3. 45 0
      src/main/java/com/oqpo/api/entity/inoutmng/DeliInfoMgntEntity.java
  4. 47 0
      src/main/java/com/oqpo/api/entity/inoutmng/ShmtOdrBaseEntity.java
  5. 36 0
      src/main/java/com/oqpo/api/entity/inoutmng/ShmtOdrDtlEntity.java
  6. 1 1
      src/main/java/com/oqpo/api/entity/pomng/PchOdrBaseInfoEntity.java
  7. 6 0
      src/main/java/com/oqpo/api/entity/pomng/PchOdrDtlPtclEntity.java
  8. 3 0
      src/main/java/com/oqpo/api/entity/stockmng/StckMgntBaseInfoEntity.java
  9. 3 1
      src/main/java/com/oqpo/api/enums/SystemMessageCode.java
  10. 51 0
      src/main/java/com/oqpo/api/mapper/inoutmng/ShmtOdrMapper.java
  11. 7 2
      src/main/java/com/oqpo/api/mapper/pomng/PchOrdMapper.java
  12. 3 0
      src/main/java/com/oqpo/api/mapper/stockmng/StockMngMapper.java
  13. 12 1
      src/main/java/com/oqpo/api/service/CommonService.java
  14. 439 0
      src/main/java/com/oqpo/api/service/inoutmng/ShmtOdrService.java
  15. 3 3
      src/main/java/com/oqpo/api/service/pomng/PchOrdService.java
  16. 67 0
      src/main/java/com/oqpo/api/web/controller/inoutmng/ShmtOdrController.java
  17. 2 2
      src/main/java/com/oqpo/api/web/controller/pomng/PchOrdController.java
  18. 72 0
      src/main/java/com/oqpo/api/web/dto/request/inoutmng/InstShmtOdrRequest.java
  19. 41 0
      src/main/java/com/oqpo/api/web/dto/request/inoutmng/ShmtOdrTargetGridRequest.java
  20. 4 0
      src/main/java/com/oqpo/api/web/dto/request/pomng/pchOrd/PchOrdSearchGridRequest.java
  21. 39 0
      src/main/java/com/oqpo/api/web/dto/response/inoutmng/ShmtOdrSearchListResponse.java
  22. 167 0
      src/main/resources/mybatis/sqlmaps/inoutmng/ShmtOdr.xml
  23. 27 0
      src/main/resources/mybatis/sqlmaps/pomng/PchOrd.xml
  24. 31 2
      src/main/resources/mybatis/sqlmaps/stockmng/StockMng.xml

BIN
doc/오더퀸_수발주ADMIN_API_스토리보드_V0.8_20221017.pptx


+ 38 - 0
src/main/java/com/oqpo/api/entity/inoutmng/DeliDtlMgntEntity.java

@@ -0,0 +1,38 @@
1
+package com.oqpo.api.entity.inoutmng;
2
+
3
+import lombok.Getter;
4
+import lombok.Setter;
5
+import lombok.ToString;
6
+
7
+import java.io.Serializable;
8
+
9
+@Getter
10
+@Setter
11
+@ToString
12
+public class DeliDtlMgntEntity implements Serializable {
13
+    private static final long serialVersionUID = -3590936033715917450L;
14
+
15
+    private String dlvSttmtUnqNo;
16
+    private String dlvSttmtDtlNo;
17
+    private String pchPodrUnqNo;
18
+    private String pchPodrDtlNo;
19
+    private String pchReqUnqNo;
20
+    private String pchReqDtlNo;
21
+    private String itemId;
22
+    private String itemNm;
23
+    private String unit;
24
+    private Integer unitAmt;
25
+    private String priceUnit;
26
+    private Integer podrQty;
27
+    private Integer dlvQty;
28
+    private Integer podrAmt;
29
+    private Integer dlvAmt;
30
+    private String expryDate;
31
+    private String delayYn;
32
+    private String delayRsn;
33
+    private String sysRegDttm;
34
+    private String sysRegId;
35
+    private String sysChgDttm;
36
+    private String sysChgId;
37
+
38
+}

+ 45 - 0
src/main/java/com/oqpo/api/entity/inoutmng/DeliInfoMgntEntity.java

@@ -0,0 +1,45 @@
1
+package com.oqpo.api.entity.inoutmng;
2
+
3
+import lombok.Getter;
4
+import lombok.Setter;
5
+import lombok.ToString;
6
+
7
+import java.io.Serializable;
8
+
9
+@Getter
10
+@Setter
11
+@ToString
12
+public class DeliInfoMgntEntity implements Serializable {
13
+    private static final long serialVersionUID = -3590936033715917450L;
14
+
15
+    private String dlvSttmtUnqNo;
16
+    private String spplyId;
17
+    private String spplyNm;
18
+    private String dlvRegDt;
19
+    private Integer dlvAmt;
20
+    private String dlvMgrNm;
21
+    private String dlvMgrTelNo;
22
+    private String dlvMgrEmal;
23
+    private String dlvMgrMblNo;
24
+    private String vndrTelNo;
25
+    private String dlvStCd;
26
+    private String dlvStNm;
27
+    private String podrRegDt;
28
+    private String dlvReqDt;
29
+    private String dlvSchDt;
30
+    private String dlvCmpltDt;
31
+    private String whsId;
32
+    private String whsNm;
33
+    private String location;
34
+    private String locationNm;
35
+    private String whsDvsn;
36
+    private String whsDvsnNm;
37
+    private String brandId;
38
+    private String brandNm;
39
+    private String sysRegDttm;
40
+    private String sysRegId;
41
+    private String sysChgDttm;
42
+    private String sysChgId;
43
+    private String dlvDesc;
44
+
45
+}

+ 47 - 0
src/main/java/com/oqpo/api/entity/inoutmng/ShmtOdrBaseEntity.java

@@ -0,0 +1,47 @@
1
+package com.oqpo.api.entity.inoutmng;
2
+
3
+import com.oqpo.api.entity.oper.AfflSaleInfoEntity;
4
+import com.oqpo.api.entity.oper.FileEntity;
5
+import lombok.Getter;
6
+import lombok.Setter;
7
+import lombok.ToString;
8
+
9
+import java.io.Serializable;
10
+import java.util.List;
11
+
12
+@Getter
13
+@Setter
14
+@ToString
15
+public class ShmtOdrBaseEntity implements Serializable {
16
+    private static final long serialVersionUID = -3590936033715917450L;
17
+
18
+    private String shmtReqUnqNo;
19
+    private String shmtReqStCd;
20
+    private String shmtReqStNm;
21
+    private String shmtRegDt;
22
+    private String shmtWhsId;
23
+    private String shmtWhsNm;
24
+    private String shmtLocation;
25
+    private String shmtLocationNm;
26
+    private String whsDvsn;
27
+    private String whsDvsnNm;
28
+    private String brandId;
29
+    private String brandNm;
30
+    private String storeId;
31
+    private String storeNm;
32
+    private String podrDvsn;
33
+    private String podrDvsnNm;
34
+    private Integer itemQty;
35
+    private Integer shmtTotalAmt;
36
+    private String podrMgrNm;
37
+    private String dlvReqDt;
38
+    private String whsId;
39
+    private String whsNm;
40
+    private String location;
41
+    private String locationNm;
42
+    private String sysRegDttm;
43
+    private String sysRegId;
44
+    private String sysChgDttm;
45
+    private String sysChgId;
46
+
47
+}

+ 36 - 0
src/main/java/com/oqpo/api/entity/inoutmng/ShmtOdrDtlEntity.java

@@ -0,0 +1,36 @@
1
+package com.oqpo.api.entity.inoutmng;
2
+
3
+import lombok.Getter;
4
+import lombok.Setter;
5
+import lombok.ToString;
6
+
7
+import java.io.Serializable;
8
+
9
+@Getter
10
+@Setter
11
+@ToString
12
+public class ShmtOdrDtlEntity implements Serializable {
13
+    private static final long serialVersionUID = -3590936033715917450L;
14
+
15
+    private String shmtReqUnqNo;
16
+    private String shmtReqDtlNo;
17
+    private String itemId;
18
+    private String itemNm;
19
+    private Integer unitAmt;
20
+    private String unit;
21
+    private String unitNm;
22
+    private Integer podrQty;
23
+    private Integer podrAmt;
24
+    private Integer shmtQty;
25
+    private Integer shmtAmt;
26
+    private String expryDate;
27
+    private String pchPodrUnqNo;
28
+    private String pchPodrDtlNo;
29
+    private String pchReqUnqNo;
30
+    private String pchReqDtlNo;
31
+    private String sysRegDttm;
32
+    private String sysRegId;
33
+    private String sysChgDttm;
34
+    private String sysChgId;
35
+
36
+}

+ 1 - 1
src/main/java/com/oqpo/api/entity/pomng/PchOdrBaseInfoEntity.java

@@ -52,7 +52,7 @@ public class PchOdrBaseInfoEntity implements Serializable {
52 52
     private String sysChgDttm;
53 53
     private String sysChgId;
54 54
     private String storeId;
55
-
55
+    private String deliTelNo;
56 56
     private PchOdrDtlPtclEntity pchOdrDtlInfo ;
57 57
 
58 58
 }

+ 6 - 0
src/main/java/com/oqpo/api/entity/pomng/PchOdrDtlPtclEntity.java

@@ -47,6 +47,12 @@ public class PchOdrDtlPtclEntity implements Serializable {
47 47
     private String podrDtlStNm;
48 48
     private Integer podrStatusCnt;
49 49
 
50
+    private Integer shmtQty;
51
+    private Integer stckQty;
52
+    private String expryYn;
53
+    private Integer expryPeriod;
54
+    private String expryDate;
55
+
50 56
 
51 57
 
52 58
 }

+ 3 - 0
src/main/java/com/oqpo/api/entity/stockmng/StckMgntBaseInfoEntity.java

@@ -57,4 +57,7 @@ public class StckMgntBaseInfoEntity implements Serializable {
57 57
     @ApiModelProperty(value = "매장명")
58 58
     private String storeNm;
59 59
 
60
+    @ApiModelProperty(value = "관련번호")
61
+    private String relationNo;
62
+
60 63
 }

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

@@ -38,7 +38,9 @@ public enum SystemMessageCode {
38 38
     ERR_NOEQSTORE (40012, "구매요청건의 납품매장과 발주요청은 납품매장이 서로 다릅니다.", HttpStatus.BAD_REQUEST),
39 39
     ERR_NOEQSPPLY (40013, "구매요청건의 납품공급업체와 발주요청한 공급업체가 서로 다릅니다.", HttpStatus.BAD_REQUEST),
40 40
     ERR_DLV001 (40014, "배송구분은 공급사 배송이되야 합니다.", HttpStatus.BAD_REQUEST),
41
-    ERR_OUTWHS (40015, "출고창고 정보가 없습니다.", HttpStatus.BAD_REQUEST)
41
+    ERR_OUTWHS (40015, "출고창고 정보가 없습니다.", HttpStatus.BAD_REQUEST),
42
+    ERR_POSHNONQTY (40016, "발주 수량보다 출고 수량이 많습니다.", HttpStatus.BAD_REQUEST),
43
+    ERR_NONEXPRY (40017, "유통기한을 입력해주세요!", HttpStatus.BAD_REQUEST)
42 44
     ;
43 45
 
44 46
 

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

@@ -0,0 +1,51 @@
1
+package com.oqpo.api.mapper.inoutmng;
2
+
3
+
4
+import com.oqpo.api.entity.inoutmng.DeliDtlMgntEntity;
5
+import com.oqpo.api.entity.inoutmng.DeliInfoMgntEntity;
6
+import com.oqpo.api.entity.inoutmng.ShmtOdrBaseEntity;
7
+import com.oqpo.api.entity.inoutmng.ShmtOdrDtlEntity;
8
+import com.oqpo.api.entity.pomng.PchOdrBaseInfoEntity;
9
+import com.oqpo.api.entity.pomng.PchOdrDtlPtclEntity;
10
+import com.oqpo.api.web.dto.request.GridRequest;
11
+import org.apache.ibatis.annotations.Mapper;
12
+import org.apache.ibatis.annotations.Param;
13
+
14
+import java.util.List;
15
+
16
+@Mapper
17
+public interface ShmtOdrMapper {
18
+    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;
19
+    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;
20
+
21
+    int insertShmtOdrBase(@Param("userId") String userId, ShmtOdrBaseEntity entity)throws Exception;
22
+    int insertShmtOdrDtl(@Param("userId") String userId, List<ShmtOdrDtlEntity> gridInsertData)throws Exception;
23
+
24
+    List<PchOdrBaseInfoEntity> selectShmtJobDataList(@Param("brandId") String brandId, List<PchOdrDtlPtclEntity> gridInsertData )throws Exception;
25
+
26
+    int insertDeliInfoMngt(@Param("userId") String userId, DeliInfoMgntEntity entity)throws Exception;
27
+    int insertDeliDtlPtcl(@Param("userId") String userId, List<DeliDtlMgntEntity> gridInsertData)throws Exception;
28
+
29
+    /*
30
+    List<PchOdrBaseInfoEntity> selectRecPchInitInfo(@Param("brandId") String brandId, List<PchOdrDtlPtclEntity> gridUpdateData)throws Exception;
31
+    List<PchOdrDtlPtclEntity> selectRecPchDtlInitInfo(@Param("brandId") String brandId, List<PchOdrDtlPtclEntity> gridUpdateData)throws Exception;
32
+    PchOdrBaseInfoEntity selectPoInitInfo(@Param("brandId") String brandId)throws Exception;
33
+    PchOdrDtlPtclEntity selectPoPchDtlSaveInfo(@Param("pchReqUnqNo") String pchReqUnqNo, @Param("pchReqDtlNo") String pchReqDtlNo)throws Exception;
34
+    PchOdrDtlPtclEntity selectPoItemDtlSaveInfo(@Param("brandId") String brandId, @Param("itemId") String itemId, @Param("brandUnitUnqNo") String brandUnitUnqNo)throws Exception;
35
+
36
+    int insertPchOdrBaseInfo(@Param("userId") String userId, PchOdrBaseInfoEntity entity)throws Exception;
37
+    int insertPchOdrDtlPtcl(@Param("userId") String userId, List<PchOdrDtlPtclEntity> gridInsertData)throws Exception;
38
+
39
+    List<PchOdrBaseInfoEntity>  selectPchOdrGridList(@Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("sPchOdrStCd") String sPchOdrStCd, @Param("sSpplyId") String sSpplyId, @Param("sWhsId") String sWhsId, @Param("sItemNm") String sItemNm, GridRequest gridRequest);
40
+    int selectPchOdrGridCnt(@Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("sPchOdrStCd") String sPchOdrStCd, @Param("sSpplyId") String sSpplyId, @Param("sWhsId") String sWhsId, @Param("sItemNm") String sItemNm);
41
+
42
+    PchOdrBaseInfoEntity selectPchOdrInfo(@Param("pchPodrUnqNo") String pchPodrUnqNo);
43
+    List<PchOdrDtlPtclEntity> selectOdrDtlList(@Param("pchPodrUnqNo") String pchPodrUnqNo);
44
+
45
+    List<PchOdrDtlPtclEntity> selectOdrDtlStatusList(@Param("pchPodrUnqNo") String pchPodrUnqNo);
46
+
47
+    int updateCancelPodrDtl(@Param("userId") String userId, List<PchOdrDtlPtclEntity> gridUpdateData) throws Exception;
48
+    int updateChgPodrStCd(@Param("userId") String userId, @Param("pchOdrStCd") String pchOdrStCd, @Param("pchPodrUnqNo") String pchPodrUnqNo) throws Exception;
49
+
50
+*/
51
+}

+ 7 - 2
src/main/java/com/oqpo/api/mapper/pomng/PchOrdMapper.java

@@ -22,8 +22,8 @@ public interface PchOrdMapper {
22 22
     int insertPchOdrBaseInfo(@Param("userId") String userId, PchOdrBaseInfoEntity entity)throws Exception;
23 23
     int insertPchOdrDtlPtcl(@Param("userId") String userId, List<PchOdrDtlPtclEntity> gridInsertData)throws Exception;
24 24
 
25
-    List<PchOdrBaseInfoEntity>  selectPchOdrGridList(@Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("sPchOdrStCd") String sPchOdrStCd, @Param("sSpplyId") String sSpplyId, @Param("sWhsId") String sWhsId, @Param("sItemNm") String sItemNm, GridRequest gridRequest);
26
-    int selectPchOdrGridCnt(@Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("sPchOdrStCd") String sPchOdrStCd, @Param("sSpplyId") String sSpplyId, @Param("sWhsId") String sWhsId, @Param("sItemNm") String sItemNm);
25
+    List<PchOdrBaseInfoEntity>  selectPchOdrGridList(@Param("brandId") String brandId, @Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("sPchOdrStCd") String sPchOdrStCd, @Param("sSpplyId") String sSpplyId, @Param("sWhsId") String sWhsId, @Param("sItemNm") String sItemNm, GridRequest gridRequest);
26
+    int selectPchOdrGridCnt(@Param("brandId") String brandId, @Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("sPchOdrStCd") String sPchOdrStCd, @Param("sSpplyId") String sSpplyId, @Param("sWhsId") String sWhsId, @Param("sItemNm") String sItemNm);
27 27
 
28 28
     PchOdrBaseInfoEntity selectPchOdrInfo(@Param("pchPodrUnqNo") String pchPodrUnqNo);
29 29
     List<PchOdrDtlPtclEntity> selectOdrDtlList(@Param("pchPodrUnqNo") String pchPodrUnqNo);
@@ -33,5 +33,10 @@ public interface PchOrdMapper {
33 33
     int updateCancelPodrDtl(@Param("userId") String userId, List<PchOdrDtlPtclEntity> gridUpdateData) throws Exception;
34 34
     int updateChgPodrStCd(@Param("userId") String userId, @Param("pchOdrStCd") String pchOdrStCd, @Param("pchPodrUnqNo") String pchPodrUnqNo) throws Exception;
35 35
 
36
+    int updateChangeStPodrDtl(@Param("userId") String userId, List<PchOdrDtlPtclEntity> gridUpdateData) throws Exception;
37
+    int updateChgMultiPodrStCd(@Param("userId") String userId, List<PchOdrBaseInfoEntity> gridUpdateData) throws Exception;
38
+
39
+
40
+
36 41
 
37 42
 }

+ 3 - 0
src/main/java/com/oqpo/api/mapper/stockmng/StockMngMapper.java

@@ -54,5 +54,8 @@ public interface StockMngMapper {
54 54
 
55 55
     int updateStckPoUseQty(@Param("userId") String userId, @Param("brandId") String brandId, @Param("whsId") String whsId, @Param("location") String location, List<StckMgntBaseInfoEntity> gridUpdateData) throws Exception;
56 56
     int updateMinusStckPoUseQty(@Param("userId") String userId, @Param("brandId") String brandId, @Param("whsId") String whsId, @Param("location") String location, List<StckMgntBaseInfoEntity> gridUpdateData) throws Exception;
57
+    int updateMinStockQty(@Param("userId") String userId, List<StckMgntBaseInfoEntity> gridUpdateData) throws Exception;
58
+
59
+    int insertMultiStckMgntDtlHist(@Param("userId") String userId, List<StckMgntDtlHistEntity> gridInsertData) throws Exception;
57 60
 
58 61
 }

+ 12 - 1
src/main/java/com/oqpo/api/service/CommonService.java

@@ -4,6 +4,8 @@ import com.oqpo.api.mapper.CommonMapper;
4 4
 import lombok.extern.slf4j.Slf4j;
5 5
 import org.springframework.beans.factory.annotation.Autowired;
6 6
 import org.springframework.stereotype.Service;
7
+import org.springframework.transaction.annotation.Propagation;
8
+import org.springframework.transaction.annotation.Transactional;
7 9
 
8 10
 @Service
9 11
 @Slf4j
@@ -11,12 +13,21 @@ public class CommonService {
11 13
     @Autowired
12 14
     private CommonMapper commonMapper;
13 15
 
16
+    @Transactional(propagation = Propagation.REQUIRES_NEW)
14 17
     public String fnGetKeyNo(Integer numNo) {
15 18
         return commonMapper.selectKeyNo(numNo);
16 19
     }
17 20
 
21
+    @Transactional(propagation = Propagation.REQUIRES_NEW)
18 22
     public String fnGetDealNo(Integer numNo, String afflAbbr) {
19
-        return commonMapper.selectDealNo(numNo, afflAbbr);
23
+        //System.out.println("fnGetDealNo==numNo===============================" + Integer.toString(numNo));
24
+            String searNo = commonMapper.selectDealNo(numNo, afflAbbr);
25
+            //String searNo1 = commonMapper.selectDealNo(numNo, afflAbbr);
26
+            //String searNo2 = commonMapper.selectDealNo(numNo, afflAbbr);
27
+        //System.out.println("fnGetDealNo======searNo===========================" + searNo);
28
+        //System.out.println("fnGetDealNo======searNo===========================" + searNo1);
29
+        //System.out.println("fnGetDealNo======searNo===========================" + searNo2);
30
+        return searNo;
20 31
     }
21 32
 
22 33
     public int fnCalculateGridTotal(int gridSize, int gridRecords) {

+ 439 - 0
src/main/java/com/oqpo/api/service/inoutmng/ShmtOdrService.java

@@ -0,0 +1,439 @@
1
+package com.oqpo.api.service.inoutmng;
2
+
3
+
4
+import com.oqpo.api.entity.inoutmng.DeliDtlMgntEntity;
5
+import com.oqpo.api.entity.inoutmng.DeliInfoMgntEntity;
6
+import com.oqpo.api.entity.inoutmng.ShmtOdrBaseEntity;
7
+import com.oqpo.api.entity.inoutmng.ShmtOdrDtlEntity;
8
+import com.oqpo.api.entity.pomng.PchOdrBaseInfoEntity;
9
+import com.oqpo.api.entity.pomng.PchOdrDtlPtclEntity;
10
+import com.oqpo.api.entity.stockmng.StckMgntBaseInfoEntity;
11
+import com.oqpo.api.entity.stockmng.StckMgntDtlHistEntity;
12
+import com.oqpo.api.enums.ChgDvsn;
13
+import com.oqpo.api.enums.InOutCd;
14
+import com.oqpo.api.enums.SystemMessageCode;
15
+import com.oqpo.api.exception.GlobalException;
16
+import com.oqpo.api.mapper.CommonMapper;
17
+import com.oqpo.api.mapper.inoutmng.ShmtOdrMapper;
18
+import com.oqpo.api.mapper.pomng.PchOrdMapper;
19
+import com.oqpo.api.mapper.stockmng.StockMngMapper;
20
+import com.oqpo.api.service.CommonService;
21
+import com.oqpo.api.service.pomng.PchOrdService;
22
+import com.oqpo.api.web.dto.request.GridRequest;
23
+import com.oqpo.api.web.dto.request.inoutmng.InstShmtOdrRequest;
24
+import com.oqpo.api.web.dto.response.GridResponse;
25
+import com.oqpo.api.web.dto.response.inoutmng.ShmtOdrSearchListResponse;
26
+import lombok.extern.slf4j.Slf4j;
27
+import org.springframework.beans.factory.annotation.Autowired;
28
+import org.springframework.stereotype.Service;
29
+import org.springframework.transaction.annotation.Transactional;
30
+
31
+import java.util.ArrayList;
32
+import java.util.List;
33
+import java.util.stream.Collectors;
34
+
35
+@Service
36
+@Slf4j
37
+public class ShmtOdrService extends CommonService {
38
+    @Autowired
39
+    private ShmtOdrMapper shmtOdrMapper;
40
+
41
+    @Autowired
42
+    private StockMngMapper stockMngMapper;
43
+
44
+    @Autowired
45
+    private PchOrdMapper pchOrdMapper;
46
+
47
+    @Autowired
48
+    private PchOrdService pchOrdService;
49
+
50
+    @Autowired
51
+    private CommonMapper commonMapper;
52
+
53
+    /*
54
+    @Autowired
55
+    private UserMngMapper userMngMapper;
56
+
57
+    @Autowired
58
+    private StockMngMapper stockMngMapper;
59
+
60
+    @Autowired
61
+    private PchReqMapper pchReqMapper;
62
+
63
+    @Autowired
64
+    private StoreBaseInfoMapper storeBaseInfoMapper;
65
+
66
+    @Autowired
67
+    private LoanStateMapper loanStateMapper;
68
+
69
+*/
70
+    /*
71
+      출하 대상 그리드 리스트 조회
72
+     */
73
+    public GridResponse selectShmtTargetOdrGridList(String sBrandId, String fromDt, String toDt, String sShmtWhsId, String sWhsId, String sItemNm, GridRequest gridRequest) throws Exception {
74
+        int gridPage = gridRequest.getGridPage();
75
+        int gridSize = gridRequest.getGridSize();
76
+
77
+        fromDt = fromDt == null ? null : fromDt.replace(".", "");
78
+        toDt = toDt == null ? null : toDt.replace(".", "");
79
+
80
+        int gridRecords = shmtOdrMapper.selectShmtTargetOdrGridCnt( sBrandId, fromDt, toDt, sShmtWhsId, sWhsId, sItemNm );
81
+        int gridTotal = fnCalculateGridTotal(gridSize, gridRecords);
82
+        List<PchOdrBaseInfoEntity> entities = shmtOdrMapper.selectShmtTargetOdrGridList(sBrandId, fromDt, toDt, sShmtWhsId, sWhsId, sItemNm, gridRequest);
83
+        List<Object> gridRows = entities.stream()
84
+                .map(m -> ShmtOdrSearchListResponse.builder()
85
+                        .viewCd("R")
86
+                        .brandId(m.getBrandId() == null ? "" : m.getBrandId())
87
+                        .brandNm(m.getBrandNm() == null ? "" : m.getBrandNm())
88
+                        .pchPodrUnqNo(m.getPchPodrUnqNo() == null ? "" : m.getPchPodrUnqNo())
89
+                        .pchPodrDtlNo(m.getPchOdrDtlInfo() == null ? "" : m.getPchOdrDtlInfo().getPchPodrDtlNo() == null ? "" :  m.getPchOdrDtlInfo().getPchPodrDtlNo() )
90
+                        .itemId(m.getPchOdrDtlInfo() == null ? "" : m.getPchOdrDtlInfo().getItemId() == null  ? "" : m.getPchOdrDtlInfo().getItemId())
91
+                        .itemNm(m.getPchOdrDtlInfo() == null ? "" : m.getPchOdrDtlInfo().getItemNm() == null ? "" : m.getPchOdrDtlInfo().getItemNm())
92
+                        .whsId(m.getWhsId() == null ? "" : m.getWhsId())
93
+                        .whsNm(m.getWhsNm() == null ? "" : m.getWhsNm() + " - " + m.getLocationNm())
94
+                        .location(m.getLocation() == null ? "" : m.getLocation())
95
+                        .unitAmt(m.getPchOdrDtlInfo() == null ? 0 : m.getPchOdrDtlInfo().getUnitAmt() == null ? 0 : m.getPchOdrDtlInfo().getUnitAmt())
96
+                        .podrQty(m.getPchOdrDtlInfo() == null ? 0 : m.getPchOdrDtlInfo().getPodrQty() == null ? 0 : m.getPchOdrDtlInfo().getPodrQty())
97
+                        .shmtQty(m.getPchOdrDtlInfo() == null ? 0 : m.getPchOdrDtlInfo().getShmtQty() == null ? 0 : m.getPchOdrDtlInfo().getShmtQty())
98
+                        .stckQty(m.getPchOdrDtlInfo() == null ? 0 : m.getPchOdrDtlInfo().getStckQty() == null ? 0 : m.getPchOdrDtlInfo().getStckQty())
99
+                        .expryYn(m.getPchOdrDtlInfo() == null ? "" : m.getPchOdrDtlInfo().getExpryYn() == null ? "" :  m.getPchOdrDtlInfo().getExpryYn() )
100
+                        .expryPeriod(m.getPchOdrDtlInfo() == null ? 0 : m.getPchOdrDtlInfo().getExpryPeriod() == null ? 0 : m.getPchOdrDtlInfo().getExpryPeriod())
101
+                        .expryDate(m.getPchOdrDtlInfo() == null ? "" : m.getPchOdrDtlInfo().getExpryDate() == null ? "" : m.getPchOdrDtlInfo().getExpryDate())
102
+                        .podrAmt(m.getPchOdrDtlInfo() == null ? 0 : m.getPchOdrDtlInfo().getPodrAmt() == null ? 0 : m.getPchOdrDtlInfo().getPodrAmt())
103
+                        .dlvReqDt(m.getDlvReqDt() == null ? "" : m.getDlvReqDt())
104
+                        .shmtWhsId(m.getShmtWhsId() == null ? "" : m.getShmtWhsId())
105
+                        .shmtLocation(m.getShmtLocation() == null ? "" : m.getShmtLocation())
106
+                        .shmtWhsNm(m.getShmtWhsNm() == null ? "" : m.getShmtWhsNm() + " - " + m.getShmtLocationNm())
107
+                        .build())
108
+                .collect(Collectors.toList());
109
+        return GridResponse.toDTO(gridPage, gridTotal, gridRecords, gridRows);
110
+    }
111
+
112
+    /*
113
+      출하지시 저장
114
+     */
115
+    @Transactional
116
+    public void instShmtOdr(String userId, InstShmtOdrRequest instShmtOdrRequest) throws Exception {
117
+        try {
118
+                // 출하창고 + 납품장소 동일여부 체크
119
+                // 출하창고의 재고 와 출하수량 비교처리
120
+                // 발주수량은 출하수량보다 크거나 같아야함
121
+                // 유통기한 품목에 대해서는 유통기한일자 기입 필수
122
+
123
+                // 출하 헤더 생성
124
+                // 출하 상세 생성
125
+                // 납품서 헤더 생성
126
+                // 납품서 상세 생성성
127
+            List<PchOdrDtlPtclEntity> gridInsertData = instShmtOdrRequest.toCodeEntities(instShmtOdrRequest.getGridInsertData());
128
+            List<PchOdrBaseInfoEntity> jobList = shmtOdrMapper.selectShmtJobDataList(instShmtOdrRequest.getBrandId(), gridInsertData) ;
129
+            List<StckMgntBaseInfoEntity> stockList = new ArrayList<StckMgntBaseInfoEntity>();
130
+            String whsId = "";
131
+            String location = "";
132
+            String shmtWhsId = "";
133
+            String shmtLocation = "";
134
+            int itemQty = 0 ;
135
+            int shmtTotalAmt = 0 ;
136
+            String expryDate = "";
137
+            int shmtQty = 0 ;
138
+            String shmtReqUnqNo = "";
139
+            String dlvSttmtUnqNo = "";
140
+
141
+
142
+            ShmtOdrBaseEntity shmtBaseEntity = new ShmtOdrBaseEntity();
143
+            List<ShmtOdrDtlEntity> shmtDtlList = new ArrayList<ShmtOdrDtlEntity>() ;
144
+
145
+            DeliInfoMgntEntity deliBaseEntity = new DeliInfoMgntEntity();
146
+            List<DeliDtlMgntEntity> deliDtlList = new ArrayList<DeliDtlMgntEntity>() ;
147
+
148
+            for (int i = 0 ; i < jobList.size() ; i++) {
149
+                PchOdrBaseInfoEntity entity = jobList.get(i);
150
+
151
+                for (int j = 0 ; j < gridInsertData.size() ; j++) {
152
+                    PchOdrDtlPtclEntity reqEntity = gridInsertData.get(j);
153
+
154
+                    if (entity.getPchPodrUnqNo().equals(reqEntity.getPchPodrUnqNo())  &&  entity.getPchOdrDtlInfo().getPchPodrDtlNo().equals(reqEntity.getPchPodrDtlNo()))
155
+                    {
156
+                        if (reqEntity.getShmtQty() > entity.getPchOdrDtlInfo().getPodrQty()) {
157
+                            // 발주수량보다 출고수량이 많을수 없습니다.
158
+                            throw new GlobalException(SystemMessageCode.ERR_POSHNONQTY);
159
+                        }
160
+
161
+                        if ("Y".equals(entity.getPchOdrDtlInfo().getExpryYn())) {
162
+                            if (reqEntity.getExpryDate() == null || "".equals(reqEntity.getExpryDate())) {
163
+                                // 유통기한을 입력해주세요!
164
+                                throw new GlobalException(SystemMessageCode.ERR_NONEXPRY);
165
+                            }
166
+                        }
167
+                        expryDate = reqEntity.getExpryDate().replaceAll("\\.","");
168
+                        shmtQty = reqEntity.getShmtQty();
169
+
170
+                        break;
171
+                    }
172
+                }
173
+
174
+                if (shmtWhsId.equals(entity.getShmtWhsId()) && shmtLocation.equals(entity.getShmtLocation()) && whsId.equals(entity.getWhsId()) &&  location.equals(entity.getLocation())) {
175
+                    // 추가 작업
176
+                    itemQty = itemQty + 1 ;
177
+                    shmtTotalAmt = shmtTotalAmt + (entity.getPchOdrDtlInfo().getUnitAmt() * shmtQty);
178
+                    shmtBaseEntity.setItemQty(itemQty);
179
+                    shmtBaseEntity.setShmtTotalAmt(shmtTotalAmt);
180
+                    deliBaseEntity.setDlvAmt(shmtTotalAmt);
181
+
182
+                    ShmtOdrDtlEntity inaddDtlEntity = new ShmtOdrDtlEntity();
183
+                    inaddDtlEntity.setShmtReqUnqNo(shmtReqUnqNo);
184
+                    int dtlNo = itemQty * 10 ;
185
+                    inaddDtlEntity.setShmtReqDtlNo( Integer.toString(dtlNo));
186
+                    inaddDtlEntity.setItemId(entity.getPchOdrDtlInfo().getItemId());
187
+                    inaddDtlEntity.setItemNm(entity.getPchOdrDtlInfo().getItemNm());
188
+                    inaddDtlEntity.setUnitAmt(entity.getPchOdrDtlInfo().getUnitAmt());
189
+                    inaddDtlEntity.setUnit(entity.getPchOdrDtlInfo().getUnit());
190
+                    inaddDtlEntity.setPodrQty(entity.getPchOdrDtlInfo().getPodrQty());
191
+                    inaddDtlEntity.setPodrAmt(entity.getPchOdrDtlInfo().getPodrAmt());
192
+                    inaddDtlEntity.setShmtQty(shmtQty);
193
+                    inaddDtlEntity.setShmtAmt(shmtQty * entity.getPchOdrDtlInfo().getUnitAmt());
194
+                    inaddDtlEntity.setExpryDate(expryDate);
195
+                    inaddDtlEntity.setPchPodrUnqNo(entity.getPchPodrUnqNo());
196
+                    inaddDtlEntity.setPchPodrDtlNo(entity.getPchOdrDtlInfo().getPchPodrDtlNo());
197
+                    inaddDtlEntity.setPchReqUnqNo(entity.getPchOdrDtlInfo().getPchReqUnqNo());
198
+                    inaddDtlEntity.setPchReqDtlNo(entity.getPchOdrDtlInfo().getPchReqDtlNo());
199
+
200
+                    shmtDtlList.add(inaddDtlEntity);
201
+
202
+                    //재고 수량정보 기입
203
+                    StckMgntBaseInfoEntity stckEntity = new StckMgntBaseInfoEntity();
204
+                    /*
205
+                    String dupYn = "N";
206
+                    for (int ski = 0 ; ski < stockList.size() ; ski++) {
207
+                        StckMgntBaseInfoEntity tmpEntity = stockList.get(ski);
208
+                        if (entity.getBrandId().equals(tmpEntity.getBrandId()) && entity.getShmtWhsId().equals(tmpEntity.getWhsId())
209
+                                 && entity.getShmtLocation().equals(tmpEntity.getLocation()) && entity.getPchOdrDtlInfo().getItemId().equals(tmpEntity.getItemId())) {
210
+                            int tmpStckQty = tmpEntity.getStckQty() ;
211
+                            stockList.get(ski).setStckQty(tmpStckQty + shmtQty);
212
+                            dupYn = "Y";
213
+                            System.out.println("for============================" + Integer.toString(ski) + stockList.get(ski).getStckQty());
214
+                            break;
215
+                        }
216
+                    }
217
+                    if ("N".equals(dupYn)) {
218
+                    */
219
+                        stckEntity.setBrandId(entity.getBrandId());
220
+                        stckEntity.setWhsId(entity.getShmtWhsId());
221
+                        stckEntity.setLocation(entity.getShmtLocation());
222
+                        stckEntity.setItemId(entity.getPchOdrDtlInfo().getItemId());
223
+                        stckEntity.setStckQty(shmtQty);
224
+                        stckEntity.setRelationNo(shmtReqUnqNo);
225
+                        stockList.add(stckEntity);
226
+                  //  }
227
+
228
+                    //납품서 상세 생성
229
+                    DeliDtlMgntEntity inaddDeliDtlEntity = new DeliDtlMgntEntity();
230
+                    inaddDeliDtlEntity.setDlvSttmtUnqNo(dlvSttmtUnqNo);
231
+                    inaddDeliDtlEntity.setDlvSttmtDtlNo(Integer.toString(dtlNo));
232
+                    inaddDeliDtlEntity.setPchPodrUnqNo(entity.getPchPodrUnqNo());
233
+                    inaddDeliDtlEntity.setPchPodrDtlNo(entity.getPchOdrDtlInfo().getPchPodrDtlNo());
234
+                    inaddDeliDtlEntity.setPchReqUnqNo(entity.getPchOdrDtlInfo().getPchReqUnqNo());
235
+                    inaddDeliDtlEntity.setPchReqDtlNo(entity.getPchOdrDtlInfo().getPchReqDtlNo());
236
+                    inaddDeliDtlEntity.setItemId(entity.getPchOdrDtlInfo().getItemId());
237
+                    inaddDeliDtlEntity.setItemNm(entity.getPchOdrDtlInfo().getItemNm());
238
+                    inaddDeliDtlEntity.setUnit(entity.getPchOdrDtlInfo().getUnit());
239
+                    inaddDeliDtlEntity.setUnitAmt(entity.getPchOdrDtlInfo().getUnitAmt());
240
+                    inaddDeliDtlEntity.setPodrQty(entity.getPchOdrDtlInfo().getPodrQty());
241
+                    inaddDeliDtlEntity.setDlvQty(shmtQty);
242
+                    inaddDeliDtlEntity.setPodrAmt(entity.getPchOdrDtlInfo().getPodrAmt());
243
+                    inaddDeliDtlEntity.setDlvAmt(shmtQty * entity.getPchOdrDtlInfo().getUnitAmt());
244
+                    inaddDeliDtlEntity.setExpryDate(expryDate);
245
+
246
+                    deliDtlList.add(inaddDeliDtlEntity);
247
+
248
+
249
+                } else {
250
+                    // 신규로 출하건 생성함  //select fn_get_dealno(16, '') as col_cmd_unq_no
251
+                    if (shmtDtlList.size() > 0) {
252
+                        shmtOdrMapper.insertShmtOdrBase(userId,shmtBaseEntity );
253
+                        shmtOdrMapper.insertShmtOdrDtl(userId, shmtDtlList) ;
254
+
255
+                        shmtOdrMapper.insertDeliInfoMngt(userId,deliBaseEntity );
256
+                        shmtOdrMapper.insertDeliDtlPtcl(userId, deliDtlList) ;
257
+                        itemQty = 0 ;
258
+                        shmtTotalAmt = 0 ;
259
+                    }
260
+                    itemQty = 1 ;
261
+                    shmtTotalAmt = entity.getPchOdrDtlInfo().getUnitAmt() * shmtQty;
262
+
263
+                    whsId = entity.getWhsId();
264
+                    location = entity.getLocation();
265
+                    shmtWhsId = entity.getShmtWhsId();
266
+                    shmtLocation = entity.getShmtLocation();
267
+
268
+                    shmtReqUnqNo = fnGetDealNo(16,"");  // 출하지시번호
269
+                    dlvSttmtUnqNo = fnGetDealNo(15,""); // 납품서번호
270
+
271
+                    // 출하지시
272
+                    shmtBaseEntity = new ShmtOdrBaseEntity();
273
+                    shmtDtlList = new ArrayList<ShmtOdrDtlEntity>() ;
274
+                    ShmtOdrDtlEntity inDtlEntity = new ShmtOdrDtlEntity();
275
+
276
+                    //납품서정보
277
+                    deliBaseEntity = new DeliInfoMgntEntity();
278
+                    deliDtlList = new ArrayList<DeliDtlMgntEntity>() ;
279
+                    DeliDtlMgntEntity deliDtlEntity = new DeliDtlMgntEntity();
280
+
281
+                    shmtBaseEntity.setShmtReqUnqNo(shmtReqUnqNo);
282
+                    shmtBaseEntity.setShmtReqStCd("SHM1");
283
+                    shmtBaseEntity.setShmtWhsId(entity.getShmtWhsId());
284
+                    shmtBaseEntity.setShmtLocation(entity.getShmtLocation());
285
+                    shmtBaseEntity.setWhsDvsn("W01");
286
+                    shmtBaseEntity.setBrandId(entity.getBrandId());
287
+                    shmtBaseEntity.setStoreId(entity.getStoreId());
288
+                    shmtBaseEntity.setPodrDvsn("OD01");
289
+                    shmtBaseEntity.setItemQty(itemQty);
290
+                    shmtBaseEntity.setShmtTotalAmt(shmtTotalAmt);
291
+                    shmtBaseEntity.setPodrMgrNm(entity.getPodrMgrNm());
292
+                    shmtBaseEntity.setDlvReqDt(entity.getDlvReqDt().replaceAll("\\.",""));
293
+                    shmtBaseEntity.setWhsId(entity.getWhsId());
294
+                    shmtBaseEntity.setLocation(entity.getLocation());
295
+
296
+                    //납품서 데이타 생성
297
+                    deliBaseEntity.setDlvSttmtUnqNo(dlvSttmtUnqNo);
298
+                    deliBaseEntity.setSpplyId(null);
299
+                    deliBaseEntity.setSpplyNm(null);
300
+                    //deliBaseEntity.setDlvRegDt();
301
+                    deliBaseEntity.setDlvAmt(shmtTotalAmt);
302
+                    deliBaseEntity.setDlvMgrNm(instShmtOdrRequest.getDlvMgrNm());
303
+                    deliBaseEntity.setDlvMgrTelNo(instShmtOdrRequest.getDlvMgrTelNo().replaceAll("-",""));
304
+                    deliBaseEntity.setDlvMgrEmal(null);
305
+                    deliBaseEntity.setDlvMgrMblNo(null);
306
+                    deliBaseEntity.setVndrTelNo(entity.getDeliTelNo().replaceAll("-",""));
307
+                    deliBaseEntity.setDlvStCd("DLV0");
308
+                    deliBaseEntity.setPodrRegDt(entity.getPodrDt());
309
+                    deliBaseEntity.setDlvReqDt(entity.getDlvReqDt().replaceAll("\\.",""));
310
+                    deliBaseEntity.setDlvSchDt(instShmtOdrRequest.getDlvSchDt().replaceAll("\\.",""));
311
+                    deliBaseEntity.setDlvCmpltDt(null);
312
+                    deliBaseEntity.setWhsId(entity.getWhsId());
313
+                    deliBaseEntity.setLocation(entity.getLocation());
314
+                    deliBaseEntity.setWhsDvsn("W01");
315
+                    deliBaseEntity.setBrandId(instShmtOdrRequest.getBrandId());
316
+
317
+                    //출하지시 상세 생성
318
+                    ShmtOdrDtlEntity inaddDtlEntity = new ShmtOdrDtlEntity();
319
+                    inaddDtlEntity.setShmtReqUnqNo(shmtReqUnqNo);
320
+                    inaddDtlEntity.setShmtReqDtlNo("10");
321
+                    inaddDtlEntity.setItemId(entity.getPchOdrDtlInfo().getItemId());
322
+                    inaddDtlEntity.setItemNm(entity.getPchOdrDtlInfo().getItemNm());
323
+                    inaddDtlEntity.setUnitAmt(entity.getPchOdrDtlInfo().getUnitAmt());
324
+                    inaddDtlEntity.setUnit(entity.getPchOdrDtlInfo().getUnit());
325
+                    inaddDtlEntity.setPodrQty(entity.getPchOdrDtlInfo().getPodrQty());
326
+                    inaddDtlEntity.setPodrAmt(entity.getPchOdrDtlInfo().getPodrAmt());
327
+                    inaddDtlEntity.setShmtQty(shmtQty);
328
+                    inaddDtlEntity.setShmtAmt(shmtQty * entity.getPchOdrDtlInfo().getUnitAmt());
329
+                    inaddDtlEntity.setExpryDate(expryDate);
330
+                    inaddDtlEntity.setPchPodrUnqNo(entity.getPchPodrUnqNo());
331
+                    inaddDtlEntity.setPchPodrDtlNo(entity.getPchOdrDtlInfo().getPchPodrDtlNo());
332
+                    inaddDtlEntity.setPchReqUnqNo(entity.getPchOdrDtlInfo().getPchReqUnqNo());
333
+                    inaddDtlEntity.setPchReqDtlNo(entity.getPchOdrDtlInfo().getPchReqDtlNo());
334
+
335
+                    shmtDtlList.add(inaddDtlEntity);
336
+
337
+                    StckMgntBaseInfoEntity stckEntity = new StckMgntBaseInfoEntity();
338
+                    stckEntity.setBrandId(entity.getBrandId());
339
+                    stckEntity.setWhsId(entity.getShmtWhsId());
340
+                    stckEntity.setLocation(entity.getShmtLocation());
341
+                    stckEntity.setItemId(entity.getPchOdrDtlInfo().getItemId());
342
+                    stckEntity.setStckQty(shmtQty);
343
+                    stckEntity.setRelationNo(shmtReqUnqNo);
344
+                    stockList.add(stckEntity);
345
+
346
+                    //납품서 상세 생성
347
+                    DeliDtlMgntEntity inaddDeliDtlEntity = new DeliDtlMgntEntity();
348
+                    inaddDeliDtlEntity.setDlvSttmtUnqNo(dlvSttmtUnqNo);
349
+                    inaddDeliDtlEntity.setDlvSttmtDtlNo("10");
350
+                    inaddDeliDtlEntity.setPchPodrUnqNo(entity.getPchPodrUnqNo());
351
+                    inaddDeliDtlEntity.setPchPodrDtlNo(entity.getPchOdrDtlInfo().getPchPodrDtlNo());
352
+                    inaddDeliDtlEntity.setPchReqUnqNo(entity.getPchOdrDtlInfo().getPchReqUnqNo());
353
+                    inaddDeliDtlEntity.setPchReqDtlNo(entity.getPchOdrDtlInfo().getPchReqDtlNo());
354
+                    inaddDeliDtlEntity.setItemId(entity.getPchOdrDtlInfo().getItemId());
355
+                    inaddDeliDtlEntity.setItemNm(entity.getPchOdrDtlInfo().getItemNm());
356
+                    inaddDeliDtlEntity.setUnit(entity.getPchOdrDtlInfo().getUnit());
357
+                    inaddDeliDtlEntity.setUnitAmt(entity.getPchOdrDtlInfo().getUnitAmt());
358
+                    inaddDeliDtlEntity.setPodrQty(entity.getPchOdrDtlInfo().getPodrQty());
359
+                    inaddDeliDtlEntity.setDlvQty(shmtQty);
360
+                    inaddDeliDtlEntity.setPodrAmt(entity.getPchOdrDtlInfo().getPodrAmt());
361
+                    inaddDeliDtlEntity.setDlvAmt(shmtQty * entity.getPchOdrDtlInfo().getUnitAmt());
362
+                    inaddDeliDtlEntity.setExpryDate(expryDate);
363
+
364
+                    deliDtlList.add(inaddDeliDtlEntity);
365
+
366
+                }
367
+
368
+                // 마지막 부분일 경우 
369
+                if (i == jobList.size()-1) {
370
+                    if (shmtDtlList.size() > 0) {
371
+                        shmtOdrMapper.insertShmtOdrBase(userId,shmtBaseEntity );
372
+                        shmtOdrMapper.insertShmtOdrDtl(userId, shmtDtlList) ;
373
+                        shmtOdrMapper.insertDeliInfoMngt(userId,deliBaseEntity );
374
+                        shmtOdrMapper.insertDeliDtlPtcl(userId, deliDtlList) ;
375
+                    }
376
+                }
377
+
378
+                System.out.println("============================" + stockList.size());
379
+
380
+                System.out.println("============================" + "end");
381
+
382
+                // 재고수량 변동 및 안전비율계산(없애기로함) 처리후 저장함함
383
+                stockMngMapper.updateMinStockQty(userId,stockList );
384
+                //재고 이력 테이블에 데이타 생성  insertMultiStckMgntDtlHist
385
+                List<StckMgntDtlHistEntity> stockHistList = new ArrayList<StckMgntDtlHistEntity>();
386
+                for ( int m = 0 ; m < stockList.size() ; m++) {
387
+                    StckMgntBaseInfoEntity baseEntity = stockList.get(m);
388
+                    StckMgntDtlHistEntity sourceHist = new StckMgntDtlHistEntity();
389
+                    //String stckMgntDtlNo = fnGetDealNo(32,"");
390
+                    String stckMgntDtlNo =  commonMapper.selectDealNo(32, "");
391
+                    //String stckMgntDtlNo1 =  commonMapper.selectDealNo(33, "");
392
+
393
+                    sourceHist.setStckMgntDtlNo(stckMgntDtlNo); // 재고관리상세번호
394
+                   // System.out.println("seqno =========>" +sourceHist.getStckMgntDtlNo() + "===" + stckMgntDtlNo + "==" + stckMgntDtlNo1);
395
+                    sourceHist.setBrandId(baseEntity.getBrandId());
396
+                    sourceHist.setWhsId(baseEntity.getWhsId());
397
+                    sourceHist.setLocation(baseEntity.getLocation());
398
+                    sourceHist.setItemId(baseEntity.getItemId());
399
+                    sourceHist.setItemNm(baseEntity.getItemNm());
400
+                    sourceHist.setInoutCd(InOutCd.OUT.getCd()); // 출고
401
+                    sourceHist.setInoutQty(baseEntity.getStckQty());
402
+                    sourceHist.setChgDvsn(ChgDvsn.PURCHASE_OUT.getCd()); // 구매출고
403
+                    sourceHist.setRelationNo(baseEntity.getRelationNo());
404
+                    stockHistList.add(sourceHist);
405
+                }
406
+                stockMngMapper.insertMultiStckMgntDtlHist(userId, stockHistList);
407
+
408
+                // 발주상태 변경처리
409
+                // 1. 발주상세정보 상태 없데이트 한후  pchOrdMapper
410
+
411
+
412
+                for (int poi = 0 ; poi < gridInsertData.size() ; poi++) {
413
+                    gridInsertData.get(poi).setPodrDtlStCd("POD3");
414
+                }
415
+                pchOrdMapper.updateChangeStPodrDtl(userId,gridInsertData );
416
+
417
+                // 발주 헤더 상태 처리  updateChgMultiPodrStCd
418
+                String pchPodrUnqNo = "";
419
+                for (int k = 0 ; k < gridInsertData.size() ; k++) {
420
+                    if (!pchPodrUnqNo.equals(gridInsertData.get(k).getPchPodrUnqNo())) {
421
+                        pchPodrUnqNo = gridInsertData.get(k).getPchPodrUnqNo();
422
+                        String pchOdrStCd = pchOrdService.selectOdrDtlStatusList(pchPodrUnqNo);
423
+                        pchOrdMapper.updateChgPodrStCd(userId, pchOdrStCd, pchPodrUnqNo );
424
+                    }
425
+                }
426
+            }
427
+
428
+
429
+        } catch (GlobalException e) {
430
+            //e.getStackTrace();
431
+            e.printStackTrace();
432
+            throw new GlobalException(e.getSystemMessageCode());
433
+        } catch (Exception e) {
434
+            e.printStackTrace();
435
+            throw new RuntimeException();
436
+        }
437
+    }
438
+
439
+}

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

@@ -380,16 +380,16 @@ public class PchOrdService extends CommonService {
380 380
     /*
381 381
       구매요청 그리드 리스트 조회
382 382
      */
383
-    public GridResponse selectPchOdrGridList(String fromDt, String toDt, String sPchOdrStCd, String sSpplyId, String sWhsId, String sItemNm, GridRequest gridRequest) throws Exception {
383
+    public GridResponse selectPchOdrGridList(String sBrandId, String fromDt, String toDt, String sPchOdrStCd, String sSpplyId, String sWhsId, String sItemNm, GridRequest gridRequest) throws Exception {
384 384
         int gridPage = gridRequest.getGridPage();
385 385
         int gridSize = gridRequest.getGridSize();
386 386
 
387 387
         fromDt = fromDt == null ? null : fromDt.replace(".", "");
388 388
         toDt = toDt == null ? null : toDt.replace(".", "");
389 389
 
390
-        int gridRecords = pchOrdMapper.selectPchOdrGridCnt( fromDt, toDt, sPchOdrStCd,sSpplyId,sWhsId,  sItemNm );
390
+        int gridRecords = pchOrdMapper.selectPchOdrGridCnt(sBrandId, fromDt, toDt, sPchOdrStCd,sSpplyId,sWhsId,  sItemNm );
391 391
         int gridTotal = fnCalculateGridTotal(gridSize, gridRecords);
392
-        List<PchOdrBaseInfoEntity> entities = pchOrdMapper.selectPchOdrGridList( fromDt, toDt, sPchOdrStCd,sSpplyId,sWhsId,  sItemNm, gridRequest);
392
+        List<PchOdrBaseInfoEntity> entities = pchOrdMapper.selectPchOdrGridList(sBrandId, fromDt, toDt, sPchOdrStCd,sSpplyId,sWhsId,  sItemNm, gridRequest);
393 393
         List<Object> gridRows = entities.stream()
394 394
                 .map(m -> PchOdrSearchListResponse.builder()
395 395
                         .viewCd("R")

+ 67 - 0
src/main/java/com/oqpo/api/web/controller/inoutmng/ShmtOdrController.java

@@ -0,0 +1,67 @@
1
+package com.oqpo.api.web.controller.inoutmng;
2
+
3
+import com.oqpo.api.enums.SystemMessageCode;
4
+import com.oqpo.api.service.inoutmng.ShmtOdrService;
5
+import com.oqpo.api.web.dto.request.inoutmng.InstShmtOdrRequest;
6
+import com.oqpo.api.web.dto.request.inoutmng.ShmtOdrTargetGridRequest;
7
+import com.oqpo.api.web.dto.request.pomng.pchOrd.SavePchOrdRequest;
8
+import com.oqpo.api.web.dto.response.GridResponse;
9
+import com.oqpo.api.web.dto.response.SaveResponse;
10
+import io.swagger.annotations.Api;
11
+import io.swagger.annotations.ApiImplicitParam;
12
+import io.swagger.annotations.ApiImplicitParams;
13
+import io.swagger.annotations.ApiOperation;
14
+import lombok.extern.slf4j.Slf4j;
15
+import org.springframework.beans.factory.annotation.Autowired;
16
+import org.springframework.http.ResponseEntity;
17
+import org.springframework.web.bind.annotation.*;
18
+import springfox.documentation.annotations.ApiIgnore;
19
+
20
+import javax.validation.Valid;
21
+
22
+@Slf4j
23
+@RestController
24
+@RequestMapping("/api/pomng/inoutmng")
25
+@Api(tags = {"출하지시 관리 (ShmtOdrController) -- 진행중"})
26
+public class ShmtOdrController {
27
+    @Autowired
28
+    private ShmtOdrService shmtOdrService;
29
+
30
+
31
+    /**
32
+     * 설명 : 출하지시 대상리스트트 그리 리스트
33
+     *
34
+     * @param ShmtOdrTargetGridRequest
35
+     * @return
36
+     * @throws Exception
37
+     */
38
+
39
+    @ApiImplicitParams({
40
+            @ApiImplicitParam(name = "X-AUTH-TOKEN", value = "CONN-KEY", required = true, dataType = "String", paramType = "header")
41
+    })
42
+    @ApiOperation(value = " 출하지시 대상리스트트 그리 리스트")
43
+    @PostMapping("/target-grid-list")
44
+    public ResponseEntity<GridResponse> selectShmtTargetOdrGridList(@RequestBody @Valid ShmtOdrTargetGridRequest shmtOdrTargetGridRequest) throws Exception {
45
+        return ResponseEntity.ok(shmtOdrService.selectShmtTargetOdrGridList(shmtOdrTargetGridRequest.getSBrandId(), shmtOdrTargetGridRequest.getFromDt(), shmtOdrTargetGridRequest.getToDt(), shmtOdrTargetGridRequest.getSShmtWhsId(), shmtOdrTargetGridRequest.getSWhsId(), shmtOdrTargetGridRequest.getSItemNm(),  shmtOdrTargetGridRequest.toDTO(shmtOdrTargetGridRequest)));
46
+    }
47
+
48
+    /**
49
+     * 설명 : 출하지시 정보 저장
50
+     *
51
+     * @param userId
52
+     * @param instShmtOdrRequest
53
+     * @return SaveResponse
54
+     * @throws Exception
55
+     */
56
+
57
+    @ApiImplicitParams({
58
+            @ApiImplicitParam(name = "X-AUTH-TOKEN", value = "CONN-KEY", required = true, dataType = "String", paramType = "header")
59
+    })
60
+    @ApiOperation(value = "출하지시 정보 저장")
61
+    @PostMapping("/save-inst-shmt")
62
+    public ResponseEntity<SaveResponse> instShmtOdr(@ApiIgnore String userId, @RequestBody @Valid InstShmtOdrRequest instShmtOdrRequest) throws Exception {
63
+        shmtOdrService.instShmtOdr(userId,  instShmtOdrRequest);
64
+        return ResponseEntity.ok(SaveResponse.toDTO(SystemMessageCode.SAVE_OK));
65
+    }
66
+
67
+}

+ 2 - 2
src/main/java/com/oqpo/api/web/controller/pomng/PchOrdController.java

@@ -124,13 +124,13 @@ public class PchOrdController {
124 124
     @ApiOperation(value = " 구매발주 그리드 리스트")
125 125
     @PostMapping("/detail-grid-list")
126 126
     public ResponseEntity<GridResponse> detailPoSearchGridList(@RequestBody @Valid PchOrdSearchGridRequest pchOrdSearchGridRequest) throws Exception {
127
-        return ResponseEntity.ok(pchOrdService.selectPchOdrGridList(pchOrdSearchGridRequest.getFromDt(), pchOrdSearchGridRequest.getToDt(), pchOrdSearchGridRequest.getSPchOdrStCd(), pchOrdSearchGridRequest.getSSpplyId(), pchOrdSearchGridRequest.getSWhsId(), pchOrdSearchGridRequest.getSItemNm(),  pchOrdSearchGridRequest.toDTO(pchOrdSearchGridRequest)));
127
+        return ResponseEntity.ok(pchOrdService.selectPchOdrGridList(pchOrdSearchGridRequest.getSBrandId(), pchOrdSearchGridRequest.getFromDt(), pchOrdSearchGridRequest.getToDt(), pchOrdSearchGridRequest.getSPchOdrStCd(), pchOrdSearchGridRequest.getSSpplyId(), pchOrdSearchGridRequest.getSWhsId(), pchOrdSearchGridRequest.getSItemNm(),  pchOrdSearchGridRequest.toDTO(pchOrdSearchGridRequest)));
128 128
     }
129 129
 
130 130
     /**
131 131
      * 설명 : 구매발주 정보
132 132
      *
133
-     * @param pchReqUnqNo
133
+     * @param
134 134
      * @return
135 135
      * @throws Exception
136 136
      */

+ 72 - 0
src/main/java/com/oqpo/api/web/dto/request/inoutmng/InstShmtOdrRequest.java

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

+ 41 - 0
src/main/java/com/oqpo/api/web/dto/request/inoutmng/ShmtOdrTargetGridRequest.java

@@ -0,0 +1,41 @@
1
+package com.oqpo.api.web.dto.request.inoutmng;
2
+
3
+import com.oqpo.api.web.dto.request.GridRequest;
4
+import io.swagger.annotations.ApiModelProperty;
5
+import lombok.Getter;
6
+import lombok.Setter;
7
+
8
+import javax.validation.constraints.NotBlank;
9
+
10
+
11
+@Getter
12
+@Setter
13
+public class ShmtOdrTargetGridRequest extends GridRequest {
14
+
15
+    @NotBlank
16
+    @ApiModelProperty(value = "시작일자")
17
+    private String fromDt;
18
+
19
+    @NotBlank
20
+    @ApiModelProperty(value = "종료일자")
21
+    private String toDt;
22
+
23
+    @NotBlank
24
+    @ApiModelProperty(value = "브랜드아이디")
25
+    private String sBrandId;
26
+
27
+    @ApiModelProperty(value = "출고창고아이디")
28
+    private String sShmtWhsId;
29
+
30
+    @ApiModelProperty(value = "납품창고아이디")
31
+    private String sWhsId;
32
+
33
+    @ApiModelProperty(value = "품목명")
34
+    private String sItemNm;
35
+
36
+
37
+
38
+    protected ShmtOdrTargetGridRequest(Integer gridSize, Integer gridPage, String sidx, String sord, Boolean pagingYn, Integer gridFirst) {
39
+        super(gridSize, gridPage, sidx, sord, pagingYn, gridFirst);
40
+    }
41
+}

+ 4 - 0
src/main/java/com/oqpo/api/web/dto/request/pomng/pchOrd/PchOrdSearchGridRequest.java

@@ -20,6 +20,10 @@ public class PchOrdSearchGridRequest extends GridRequest {
20 20
     @ApiModelProperty(value = "종료일자")
21 21
     private String toDt;
22 22
 
23
+    @NotBlank
24
+    @ApiModelProperty(value = "브랜드아이디")
25
+    private String sBrandId;
26
+
23 27
     @ApiModelProperty(value = "구매발주상태")
24 28
     private String sPchOdrStCd;
25 29
 

+ 39 - 0
src/main/java/com/oqpo/api/web/dto/response/inoutmng/ShmtOdrSearchListResponse.java

@@ -0,0 +1,39 @@
1
+package com.oqpo.api.web.dto.response.inoutmng;
2
+
3
+import com.fasterxml.jackson.annotation.JsonInclude;
4
+import io.swagger.annotations.ApiModelProperty;
5
+import lombok.*;
6
+
7
+@Getter
8
+@Setter
9
+@Builder
10
+@AllArgsConstructor(access = AccessLevel.PROTECTED)
11
+@JsonInclude(JsonInclude.Include.ALWAYS)
12
+public class ShmtOdrSearchListResponse {
13
+
14
+    @ApiModelProperty(value = "CRUD")
15
+    private String viewCd;
16
+
17
+    @ApiModelProperty(value = "브랜드아이디") private String brandId;
18
+    @ApiModelProperty(value = "브랜드명") private String brandNm;
19
+    @ApiModelProperty(value = "구매발주번호") private String pchPodrUnqNo;
20
+    @ApiModelProperty(value = "구매발주항번") private String pchPodrDtlNo;
21
+    @ApiModelProperty(value = "품목아이디") private String itemId;
22
+    @ApiModelProperty(value = "품목명") private String itemNm;
23
+    @ApiModelProperty(value = "납품창고아이디") private String whsId;
24
+    @ApiModelProperty(value = "납품창고명") private String whsNm;
25
+    @ApiModelProperty(value = "납품LOCATION") private String location;
26
+    @ApiModelProperty(value = "단가") private Integer unitAmt;
27
+    @ApiModelProperty(value = "발주수량") private Integer podrQty;
28
+    @ApiModelProperty(value = "출고수량") private Integer shmtQty;
29
+    @ApiModelProperty(value = "현 재고") private Integer stckQty;
30
+    @ApiModelProperty(value = "유통기한여부") private String expryYn;
31
+    @ApiModelProperty(value = "유통기한기간") private Integer expryPeriod;
32
+    @ApiModelProperty(value = "유통일자") private String expryDate;
33
+    @ApiModelProperty(value = "발주금액") private Integer podrAmt;
34
+    @ApiModelProperty(value = "납품요청일") private String dlvReqDt;
35
+    @ApiModelProperty(value = "출고창고아이디") private String shmtWhsId;
36
+    @ApiModelProperty(value = "출고LOCATION") private String shmtLocation;
37
+    @ApiModelProperty(value = "출고창고명") private String shmtWhsNm;
38
+
39
+}

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

@@ -0,0 +1,167 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+
4
+<mapper namespace="com.oqpo.api.mapper.inoutmng.ShmtOdrMapper">
5
+
6
+    <select id="selectShmtTargetOdrGridList" resultType="com.oqpo.api.entity.pomng.PchOdrBaseInfoEntity">
7
+        select base.brand_id, fn_brand_nm(base.brand_id) as brand_nm, base.pch_podr_unq_no
8
+               , ptcl.pch_podr_dtl_no as 'pchOdrDtlInfo.pch_podr_dtl_no'
9
+                ,ptcl.item_id as 'pchOdrDtlInfo.item_id' , ptcl.item_nm as 'pchOdrDtlInfo.item_nm', base.whs_id, fn_whs_nm(base.brand_id, base.whs_id) as whs_nm
10
+                ,base.location, fn_whs_location_nm(base.brand_id, base.whs_id, base.location) as location_nm
11
+                ,ptcl.unit_amt as 'pchOdrDtlInfo.unit_amt', ptcl.podr_qty as 'pchOdrDtlInfo.podr_qty'
12
+                , ptcl.podr_qty as 'pchOdrDtlInfo.shmt_qty', nvl(stck.stck_qty,0) as 'pchOdrDtlInfo.stck_qty'
13
+                ,itm.expry_yn as 'pchOdrDtlInfo.expry_yn', itm.expry_period as 'pchOdrDtlInfo.expry_period'
14
+                , date_format(adddate(now(), interval itm.expry_period day),'%Y.%m.%d') as 'pchOdrDtlInfo.expry_date'
15
+                ,ptcl.podr_amt as 'pchOdrDtlInfo.podr_amt', date_format(base.dlv_req_dt,'%Y.%m.%d') as dlv_req_dt, base.shmt_whs_id, base.shmt_location
16
+                ,fn_whs_nm(base.brand_id, base.shmt_whs_id) as shmt_whs_nm
17
+                ,fn_whs_location_nm(base.brand_id, base.shmt_whs_id, base.shmt_location) as shmt_location_nm
18
+        from   pch_odr_base_info base
19
+        join pch_odr_dtl_ptcl ptcl on base.pch_podr_unq_no = ptcl.pch_podr_unq_no and ptcl.podr_dtl_st_cd = 'POD0'
20
+        <if test="sItemNm != null and sItemNm != ''">
21
+                and (ptcl.item_id like concat('%',#{sItemNm},'%') or ptcl.item_nm like concat('%',#{sItemNm},'%'))
22
+        </if>
23
+        join item_base_info itm on ptcl.item_id = itm.item_id
24
+        left outer join stck_mgnt_base_info stck on base.brand_id = stck.brand_id and base.shmt_whs_id = stck.whs_id and base.shmt_location = stck.location
25
+        and ptcl.item_id = stck.item_id
26
+        where  1=1
27
+        and    base.brand_id = #{sBrandId}
28
+        and    base.dlv_req_dt between #{fromDt} and #{toDt}
29
+        and    base.dlv_dvsn = 'DL01'  -- 본사배송구분
30
+        and    base.whs_dvsn = 'W02'  -- 납품매장창고구분
31
+        <if test="sShmtWhsId != null and sShmtWhsId != ''">
32
+        and    base.shmt_whs_id = #{sShmtWhsId}
33
+        </if>
34
+        <if test="sWhsId != null and sWhsId != ''">
35
+        and    base.whs_id = #{sWhsId}
36
+        </if>
37
+        <choose>
38
+            <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
39
+                <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
40
+                    <if test="gridRequest.sord == 'asc'.toString()">
41
+                        order by pch_req_unq_no asc
42
+                    </if>
43
+                    <if test="gridRequest.sord == 'desc'.toString()">
44
+                        order by pch_req_unq_no desc
45
+                    </if>
46
+                </if>
47
+            </when>
48
+            <otherwise>
49
+                order by pch_req_unq_no desc
50
+            </otherwise>
51
+        </choose>
52
+        <if test="gridRequest.pagingYn == true">
53
+            limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
54
+        </if>
55
+    </select>
56
+
57
+    <select id="selectShmtTargetOdrGridCnt" resultType="int">
58
+        select count(*) as cnt
59
+        from   pch_odr_base_info base
60
+        join pch_odr_dtl_ptcl ptcl on base.pch_podr_unq_no = ptcl.pch_podr_unq_no and ptcl.podr_dtl_st_cd = 'POD0'
61
+        <if test="sItemNm != null and sItemNm != ''">
62
+            and (ptcl.item_id like concat('%',#{sItemNm},'%') or ptcl.item_nm like concat('%',#{sItemNm},'%'))
63
+        </if>
64
+        join item_base_info itm on ptcl.item_id = itm.item_id
65
+        left outer join stck_mgnt_base_info stck on base.brand_id = stck.brand_id and base.shmt_whs_id = stck.whs_id and base.shmt_location = stck.location
66
+        and ptcl.item_id = stck.item_id
67
+        where  1=1
68
+        and    base.brand_id = #{sBrandId}
69
+        and    base.dlv_req_dt between #{fromDt} and #{toDt}
70
+        and    base.dlv_dvsn = 'DL01'  -- 본사배송구분
71
+        and    base.whs_dvsn = 'W02'  -- 납품매장창고구분
72
+        <if test="sShmtWhsId != null and sShmtWhsId != ''">
73
+            and    base.shmt_whs_id = #{sShmtWhsId}
74
+        </if>
75
+        <if test="sWhsId != null and sWhsId != ''">
76
+            and    base.whs_id = #{sWhsId}
77
+        </if>
78
+
79
+    </select>
80
+
81
+    <insert id="insertShmtOdrBase">
82
+        insert into shmt_odr_base_info
83
+            (shmt_req_unq_no, shmt_req_st_cd, shmt_reg_dt, shmt_whs_id, shmt_location
84
+            , whs_dvsn, brand_id, store_id, podr_dvsn, item_qty
85
+            , shmt_total_amt,  podr_mgr_nm, dlv_req_dt, whs_id, location
86
+            , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
87
+        values
88
+            (#{entity.shmtReqUnqNo}, #{entity.shmtReqStCd}, date_format(now(),'%Y%m%d'), #{entity.shmtWhsId}, #{entity.shmtLocation}
89
+            , #{entity.whsDvsn}, #{entity.brandId}, #{entity.storeId}, #{entity.podrDvsn}, #{entity.itemQty}
90
+            , #{entity.shmtTotalAmt}, #{entity.podrMgrNm}, #{entity.dlvReqDt}, #{entity.whsId}
91
+            , #{entity.location}, NOW(), #{userId}, NOW(), #{userId})
92
+    </insert>
93
+
94
+    <insert id="insertShmtOdrDtl">
95
+        insert into shmt_odr_dtl_ptcl
96
+            (shmt_req_unq_no, shmt_req_dtl_no, item_id, item_nm, unit_amt
97
+            , unit, podr_qty, podr_amt, shmt_qty, shmt_amt, expry_date
98
+            , pch_podr_unq_no, pch_podr_dtl_no, pch_req_unq_no, pch_req_dtl_no
99
+            , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
100
+        values
101
+        <foreach collection="gridInsertData" item="item" separator=",">
102
+            (#{item.shmtReqUnqNo}, #{item.shmtReqDtlNo}, #{item.itemId}, #{item.itemNm}, #{item.unitAmt}
103
+            , #{item.unit}, #{item.podrQty}, #{item.podrAmt}, #{item.shmtQty}, #{item.shmtAmt}, #{item.expryDate}
104
+            , #{item.pchPodrUnqNo}, #{item.pchPodrDtlNo}, #{item.pchReqUnqNo}, #{item.pchReqDtlNo}
105
+            , NOW(), #{userId}, NOW(), #{userId})
106
+        </foreach>
107
+    </insert>
108
+
109
+    <select id="selectShmtJobDataList" resultType="com.oqpo.api.entity.pomng.PchOdrBaseInfoEntity">
110
+        select base.brand_id,base.pch_podr_unq_no, ptcl.pch_podr_dtl_no as 'pchOdrDtlInfo.pch_podr_dtl_no'
111
+                ,ptcl.item_id as 'pchOdrDtlInfo.item_id' , ptcl.item_nm as 'pchOdrDtlInfo.item_nm', base.whs_id
112
+                ,base.location, ptcl.unit_amt as 'pchOdrDtlInfo.unit_amt', ptcl.podr_qty as 'pchOdrDtlInfo.podr_qty'
113
+                ,nvl(stck.stck_qty,0) as 'pchOdrDtlInfo.stck_qty'
114
+                ,itm.expry_yn as 'pchOdrDtlInfo.expry_yn', nvl(itm.expry_period,0) as 'pchOdrDtlInfo.expry_period'
115
+                ,ptcl.podr_amt as 'pchOdrDtlInfo.podr_amt', date_format(base.dlv_req_dt,'%Y.%m.%d') as dlv_req_dt
116
+                , base.shmt_whs_id, base.shmt_location, ptcl.pch_req_unq_no as 'pchOdrDtlInfo.pch_req_unq_no' , ptcl.pch_req_dtl_no as 'pchOdrDtlInfo.pch_req_dtl_no'
117
+                , base.store_id , base.podr_mgr_nm , base.podr_mgr_tel_no
118
+                , fn_get_telno((select tel_no from store_base_info where store_id = base.store_id )) as deli_tel_no
119
+                , date_format(base.podr_dt,'%Y%m%d') as podr_dt
120
+        from   pch_odr_base_info base
121
+        join pch_odr_dtl_ptcl ptcl on base.pch_podr_unq_no = ptcl.pch_podr_unq_no and ptcl.podr_dtl_st_cd = 'POD0'
122
+        join item_base_info itm on ptcl.item_id = itm.item_id
123
+        left outer join stck_mgnt_base_info stck on base.brand_id = stck.brand_id and base.shmt_whs_id = stck.whs_id and base.shmt_location = stck.location
124
+        and ptcl.item_id = stck.item_id
125
+        where  1=1
126
+        and    base.brand_id = #{brandId}
127
+        and    concat(base.pch_podr_unq_no,ptcl.pch_podr_dtl_no) in
128
+        <foreach collection="gridInsertData" item="item" separator="," open="(" close=")">
129
+            concat(#{item.pchPodrUnqNo},#{item.pchPodrDtlNo})
130
+        </foreach>
131
+        order by  base.brand_id, base.shmt_whs_id, base.shmt_location, base.whs_id,base.location
132
+    </select>
133
+
134
+    <insert id="insertDeliInfoMngt">
135
+        INSERT INTO deli_info_mgnt
136
+        (dlv_sttmt_unq_no, spply_id, spply_nm, dlv_reg_dt, dlv_amt
137
+        , dlv_mgr_nm, dlv_mgr_tel_no, dlv_mgr_emal, dlv_mgr_mbl_no, vndr_tel_no
138
+        , dlv_st_cd, podr_reg_dt, dlv_req_dt, dlv_sch_dt, dlv_cmplt_dt
139
+        , whs_id, location, whs_dvsn, brand_id
140
+        , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
141
+        VALUES
142
+        (#{entity.dlvSttmtUnqNo}, #{entity.spplyId}, #{entity.spplyNm}, date_format(now(),'%Y%m%d'), #{entity.dlvAmt}
143
+        , #{entity.dlvMgrNm}, #{entity.dlvMgrTelNo}, #{entity.dlvMgrEmal}, #{entity.dlvMgrMblNo}, #{entity.vndrTelNo}
144
+        , #{entity.dlvStCd}, #{entity.podrRegDt}, #{entity.dlvReqDt}, #{entity.dlvSchDt}, #{entity.dlvCmpltDt}
145
+        , #{entity.whsId}, #{entity.location}, #{entity.whsDvsn}, #{entity.brandId}
146
+        , NOW(), #{userId}, NOW(), #{userId})
147
+    </insert>
148
+
149
+    <insert id="insertDeliDtlPtcl" >
150
+        INSERT INTO deli_dtl_ptcl
151
+        (dlv_sttmt_unq_no, dlv_sttmt_dtl_no, pch_podr_unq_no, pch_podr_dtl_no, pch_req_unq_no
152
+        , pch_req_dtl_no, item_id, item_nm, unit, unit_amt
153
+        , price_unit, podr_qty, dlv_qty, podr_amt, dlv_amt
154
+        , expry_date, delay_yn, delay_rsn
155
+        , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
156
+        VALUES
157
+        <foreach collection="gridInsertData" item="item" separator=",">
158
+        (#{item.dlvSttmtUnqNo}, #{item.dlvSttmtDtlNo}, #{item.pchPodrUnqNo}, #{item.pchPodrDtlNo}, #{item.pchReqUnqNo}
159
+        , #{item.pchReqDtlNo}, #{item.itemId}, #{item.itemNm}, #{item.unit}, #{item.unitAmt}
160
+        , #{item.priceUnit}, #{item.podrQty}, #{item.dlvQty}, #{item.podrAmt}, #{item.dlvAmt}
161
+        , #{item.expryDate}, #{item.delayYn}, #{item.delayRsn}
162
+        , NOW(), #{userId}, NOW(), #{userId})
163
+        </foreach>
164
+    </insert>
165
+
166
+
167
+</mapper>

+ 27 - 0
src/main/resources/mybatis/sqlmaps/pomng/PchOrd.xml

@@ -117,6 +117,7 @@
117 117
             , fn_whs_location_nm(base.brand_id, base.shmt_whs_id, base.shmt_location) as shmt_location_nm
118 118
         from pch_odr_base_info base
119 119
         where 1 = 1
120
+        and base.brand_id = #{sBrandId}
120 121
         and base.podr_dt between #{fromDt} and  #{toDt}
121 122
         <if test="sPchOdrStCd != null and sPchOdrStCd != ''">
122 123
         and base.pch_odr_st_cd = #{sPchOdrStCd}
@@ -133,6 +134,7 @@
133 134
                                         from pch_odr_base_info base
134 135
                                         , pch_odr_dtl_ptcl ptcl
135 136
                                         where 1 = 1
137
+                                        and base.brand_id = #{sBrandId}
136 138
                                         and base.pch_podr_unq_no = ptcl.pch_podr_unq_no
137 139
                                         and base.podr_dt between #{fromDt} and  #{toDt}
138 140
                                         <if test="sPchOdrStCd != null and sPchOdrStCd != ''">
@@ -170,6 +172,7 @@
170 172
         select count(*) as cnt
171 173
         from pch_odr_base_info base
172 174
         where 1 = 1
175
+        and base.brand_id = #{sBrandId}
173 176
         and base.podr_dt between #{fromDt} and  #{toDt}
174 177
         <if test="sPchOdrStCd != null and sPchOdrStCd != ''">
175 178
             and base.pch_odr_st_cd = #{sPchOdrStCd}
@@ -250,6 +253,7 @@
250 253
         </foreach>
251 254
     </update>
252 255
 
256
+
253 257
     <update id="updateChgPodrStCd">
254 258
             UPDATE /* PchOrd.updateChgPodrStCd */
255 259
             pch_odr_base_info SET
@@ -258,4 +262,27 @@
258 262
             sys_chg_id = #{userId}
259 263
             WHERE pch_podr_unq_no = #{pchPodrUnqNo}
260 264
     </update>
265
+
266
+    <update id="updateChangeStPodrDtl">
267
+        <foreach collection="gridUpdateData" item="item" separator=";">
268
+            UPDATE /* PchOrd.updateChangeStPodrDtl */
269
+            pch_odr_dtl_ptcl SET
270
+            podr_dtl_st_cd = #{item.podrDtlStCd},
271
+            sys_chg_dttm = NOW(),
272
+            sys_chg_id = #{userId}
273
+            WHERE pch_podr_unq_no = #{item.pchPodrUnqNo}
274
+            AND pch_podr_dtl_no = #{item.pchPodrDtlNo}
275
+        </foreach>
276
+    </update>
277
+
278
+    <update id="updateChgMultiPodrStCd">
279
+        <foreach collection="gridUpdateData" item="item" separator=";">
280
+            UPDATE /* PchOrd.updateChgPodrStCd */
281
+            pch_odr_base_info SET
282
+            pch_odr_st_cd = #{item.pchOdrStCd},
283
+            sys_chg_dttm = NOW(),
284
+            sys_chg_id = #{userId}
285
+            WHERE pch_podr_unq_no = #{item.pchPodrUnqNo}
286
+        </foreach>
287
+    </update>
261 288
 </mapper>

+ 31 - 2
src/main/resources/mybatis/sqlmaps/stockmng/StockMng.xml

@@ -192,11 +192,11 @@
192 192
         /* StockMngMapper.insertStckMgntDtlHist */
193 193
         INSERT INTO stck_mgnt_dtl_hist
194 194
             (stck_mgnt_dtl_no, brand_id, whs_id, location, item_id, item_nm, inout_cd, inout_qty, whs_mgnt_unq_no,
195
-             rtn_mgnt_unq_no, chg_dvsn, sys_reg_dttm,
195
+             rtn_mgnt_unq_no, chg_dvsn, relation_no, sys_reg_dttm,
196 196
              sys_reg_id, sys_chg_dttm, sys_chg_id)
197 197
         VALUES
198 198
             (#{entity.stckMgntDtlNo}, #{entity.brandId}, #{entity.whsId}, #{entity.location}, #{entity.itemId},
199
-             #{entity.itemNm}, #{entity.inoutCd}, #{entity.inoutQty}, #{entity.whsMgntUnqNo}, #{entity.rtnMgntUnqNo}, #{entity.chgDvsn},
199
+             #{entity.itemNm}, #{entity.inoutCd}, #{entity.inoutQty}, #{entity.whsMgntUnqNo}, #{entity.rtnMgntUnqNo}, #{entity.chgDvsn}, #{entity.relationNo},
200 200
              NOW(), #{userId}, NOW(), #{userId})
201 201
     </insert>
202 202
 
@@ -293,4 +293,33 @@
293 293
         </foreach>
294 294
     </update>
295 295
 
296
+    <update id="updateMinStockQty" >
297
+        /* StockMngMapper.updateMinStockQty */
298
+        <foreach collection="gridUpdateData" item="item" separator=";">
299
+        UPDATE stck_mgnt_base_info SET
300
+            stck_qty = stck_qty - #{item.stckQty},       /* 재고수량 */
301
+            wait_qty = wait_qty - #{item.stckQty},       /* 대기수량 */
302
+            sys_chg_dttm = NOW(),
303
+            sys_chg_id = #{userId}
304
+        WHERE brand_id = #{item.brandId}
305
+        AND whs_id = #{item.whsId}
306
+        AND location = #{item.location}
307
+        AND item_id = #{item.itemId}
308
+        </foreach>
309
+    </update>
310
+
311
+    <insert id="insertMultiStckMgntDtlHist" >
312
+        /* StockMngMapper.insertMultiStckMgntDtlHist */
313
+        INSERT INTO stck_mgnt_dtl_hist
314
+            (stck_mgnt_dtl_no, brand_id, whs_id, location, item_id, item_nm, inout_cd, inout_qty, whs_mgnt_unq_no,
315
+             rtn_mgnt_unq_no, chg_dvsn, relation_no, sys_reg_dttm,
316
+             sys_reg_id, sys_chg_dttm, sys_chg_id)
317
+        VALUES
318
+        <foreach collection="gridInsertData" item="item" separator=";">
319
+            (#{item.stckMgntDtlNo}, #{item.brandId}, #{item.whsId}, #{item.location}, #{item.itemId},
320
+             #{item.itemNm}, #{item.inoutCd}, #{item.inoutQty}, #{item.whsMgntUnqNo}, #{item.rtnMgntUnqNo}, #{item.chgDvsn}, #{item.relationNo},
321
+             NOW(), #{userId}, NOW(), #{userId})
322
+        </foreach>
323
+    </insert>
324
+
296 325
 </mapper>