Selaa lähdekoodia

공급사 단가 api 일부 작업 커밋

dwkim 2 vuotta sitten
vanhempi
commit
b1b853280f

+ 4 - 1
src/main/java/com/oqpo/api/entity/stinfo/ItemUnitEntity.java

@@ -16,6 +16,7 @@ public class ItemUnitEntity implements Serializable {
16 16
 
17 17
     private String brandUnitUnqNo ;
18 18
     private String brandId ;
19
+    private String brandNm ;
19 20
     private String itemId ;
20 21
     private String itemNm ;
21 22
     private String spplyId ;
@@ -23,16 +24,18 @@ public class ItemUnitEntity implements Serializable {
23 24
     private String contSttDt ;
24 25
     private String contEndDt ;
25 26
     private String curr ;
27
+    private String currNm ;
26 28
     private String unit ;
27 29
     private String unitNm ;
28 30
     private Integer unitAmt ;
29 31
     private Integer leadTime ;
30 32
     private String dlvCndt ;
33
+    private String dlvCndtNm ;
31 34
     private String shortContFileNo ;
32 35
     private String spplyItemId ;
33 36
     private String unitStCd ;
34 37
     private String unitStNm ;
35
-    private Integer stddQyt ;
38
+    private Integer stddQty ;
36 39
     private Integer storeSaleStddQty ;
37 40
     private Integer storeSaleUnitAmt ;
38 41
     private String sysRegDttm ;

+ 2 - 3
src/main/java/com/oqpo/api/entity/stinfo/StoreItemUnitEntity.java

@@ -25,11 +25,10 @@ public class StoreItemUnitEntity implements Serializable {
25 25
     private String currNm ;
26 26
     private Integer unitAmt ;
27 27
     private String storeId ;
28
+    private String storeNm ;
28 29
     private String brandId ;
30
+    private String brandNm ;
29 31
     private String shortContFileNo ;
30
-    private String spplyId ;
31
-    private String spplyNm ;
32
-    private String spplyItemId ;
33 32
     private String unitStCd ;
34 33
     private String unitStNm ;
35 34
     private Integer stddQyt ;

+ 4 - 2
src/main/java/com/oqpo/api/mapper/stinfo/ItemUnitMapper.java

@@ -14,8 +14,10 @@ public interface ItemUnitMapper {
14 14
     int selectItemUnitGridCnt(@Param("sBrandId") String sBrandId, @Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("sUnitStCd") String sUnitStCd, @Param("sSpplyId") String sSpplyId, @Param("sClass1") String sClass1, @Param("sClass2") String sClass2, @Param("sClass3") String sClass3, @Param("sClass") String sClass4, @Param("sItemNm") String sItemNm)throws Exception;
15 15
 
16 16
     ItemUnitEntity selectItemUnitInfo(@Param("brandId") String brandId, @Param("brandUnitUnqNo") String brandUnitUnqNo)throws Exception;
17
+    ItemUnitEntity selectItemUnitDupContInfoNo(@Param("brandId") String brandId, @Param("spplyId") String spplyId, @Param("itemId") String itemId, @Param("contSttDt") String contSttDt, @Param("contEndDt") String contEndDt)throws Exception;
18
+    int updateItemUnitContEnd(@Param("brandId") String brandId, @Param("brandUnitUnqNo") String brandUnitUnqNo, @Param("contEndDt") String contEndDt) throws Exception;
19
+
20
+    int insertMergItemUnitInfo(@Param("userId") String userId, ItemUnitEntity entity) throws Exception;
17 21
 
18
-    int insertItemUnitInfo(@Param("userId") String userId, ItemUnitEntity entity) throws Exception;
19
-    int updateItemUnitInfo(@Param("userId") String userId, ItemUnitEntity entity) throws Exception;
20 22
 
21 23
 }

+ 13 - 8
src/main/java/com/oqpo/api/mapper/stinfo/StoreItemUnitMapper.java

@@ -1,19 +1,24 @@
1 1
 package com.oqpo.api.mapper.stinfo;
2 2
 
3 3
 
4
+import com.oqpo.api.entity.stinfo.StoreItemUnitEntity;
5
+import com.oqpo.api.web.dto.request.GridRequest;
4 6
 import org.apache.ibatis.annotations.Mapper;
7
+import org.apache.ibatis.annotations.Param;
8
+
9
+import java.util.List;
5 10
 
6 11
 @Mapper
7 12
 public interface StoreItemUnitMapper {
8
-/*
9
-    List<BrandEntity> selectBrandGridList(@Param("sBrandNm") String sBrandNm, @Param("sBrandType") String sBrandType, @Param("sStCd") String sStCd, GridRequest gridRequest)throws Exception;
10
-    int selectBrandGridCnt(@Param("sBrandNm") String sBrandNm, @Param("sBrandType") String sBrandType, @Param("sStCd") String sStCd)throws Exception;
11 13
 
12
-    BrandEntity selectBrandInfo(@Param("brandId") String brandId)throws Exception;
14
+    List<StoreItemUnitEntity> selectStoreItemUnitGridList(@Param("sBrandId") String sBrandId, @Param("sStoreId") String sStoreId , GridRequest gridRequest)throws Exception;
15
+    int selectStoreItemUnitGridCnt(@Param("sBrandId") String sBrandId, @Param("sStoreId") String sStoreId )throws Exception;
16
+
17
+    StoreItemUnitEntity selectStoreItemUnitInfo(@Param("brandId") String brandId, @Param("storeId") String storeId, @Param("contSttDt") String contSttDt, @Param("contEndDt") String contEndDt)throws Exception;
18
+
19
+    StoreItemUnitEntity selectStoreItemUnitContDateInfo(@Param("brandId") String brandId, @Param("storeId") String storeId, @Param("contSttDt") String contSttDt,  @Param("contEndDt") String contEndDt)throws Exception;
20
+    int updateStoreItemUnitContEnd(@Param("brandId") String brandId, @Param("storeId") String storeId, @Param("contEndDt") String contEndDt) throws Exception;
13 21
 
14
-    int insertBrandInfo(@Param("userId") String userId, BrandEntity entity) throws Exception;
15
-    int updateBrandInfo(@Param("userId") String userId, BrandEntity entity) throws Exception;
22
+    int insertMergStoreItemUnitInfo(@Param("userId") String userId, List<StoreItemUnitEntity> gridUpdateData) throws Exception;
16 23
 
17
-    String selectBrandInitPw(@Param("brandId") String brandId)throws Exception;
18
-*/
19 24
 }

+ 148 - 0
src/main/java/com/oqpo/api/service/stinfo/ItemUnitService.java

@@ -0,0 +1,148 @@
1
+package com.oqpo.api.service.stinfo;
2
+
3
+
4
+import com.oqpo.api.entity.oper.FileEntity;
5
+import com.oqpo.api.entity.stinfo.ItemClassEntity;
6
+import com.oqpo.api.entity.stinfo.ItemClassMngEntity;
7
+import com.oqpo.api.entity.stinfo.ItemEntity;
8
+import com.oqpo.api.entity.stinfo.ItemUnitEntity;
9
+import com.oqpo.api.enums.SystemMessageCode;
10
+import com.oqpo.api.exception.GlobalException;
11
+import com.oqpo.api.mapper.FileMapper;
12
+import com.oqpo.api.mapper.stinfo.ItemMapper;
13
+import com.oqpo.api.mapper.stinfo.ItemUnitMapper;
14
+import com.oqpo.api.service.CommonService;
15
+import com.oqpo.api.web.dto.request.GridRequest;
16
+import com.oqpo.api.web.dto.request.stinfo.item.DelItemInfolRequest;
17
+import com.oqpo.api.web.dto.request.stinfo.item.SaveItemClassMngInfolRequest;
18
+import com.oqpo.api.web.dto.request.stinfo.item.SaveItemInfolRequest;
19
+import com.oqpo.api.web.dto.request.stinfo.itemUnit.SaveItemUnitInfolRequest;
20
+import com.oqpo.api.web.dto.response.GridResponse;
21
+import com.oqpo.api.web.dto.response.stinfo.item.*;
22
+import com.oqpo.api.web.dto.response.stinfo.itemUnit.ItemUnitInfoResponse;
23
+import com.oqpo.api.web.dto.response.stinfo.itemUnit.ItemUnitSearchResponse;
24
+import lombok.extern.slf4j.Slf4j;
25
+import org.springframework.beans.factory.annotation.Autowired;
26
+import org.springframework.stereotype.Service;
27
+import org.springframework.transaction.annotation.Transactional;
28
+
29
+import java.util.ArrayList;
30
+import java.util.List;
31
+import java.util.stream.Collectors;
32
+
33
+@Service
34
+@Slf4j
35
+public class ItemUnitService extends CommonService {
36
+    @Autowired
37
+    private ItemUnitMapper itemUnitMapper;
38
+
39
+    @Autowired
40
+    private FileMapper fileMapper;
41
+
42
+    /*
43
+      브랜드 공급사 단가 리스트 조회
44
+
45
+     */
46
+    public GridResponse selectItemUnitGridList(String sBrandId, String fromDt, String toDt,String sUnitStCd, String sSpplyId, String sClass1, String sClass2, String sClass3, String sClass4, String sItemNm,   GridRequest gridRequest) throws Exception {
47
+        int gridPage = gridRequest.getGridPage();
48
+        int gridSize = gridRequest.getGridSize();
49
+
50
+        fromDt = fromDt == null ? null : fromDt.replace(".", "");
51
+        toDt = toDt == null ? null : toDt.replace(".", "");
52
+
53
+        int gridRecords = itemUnitMapper.selectItemUnitGridCnt( sBrandId, fromDt,  toDt, sUnitStCd, sSpplyId, sClass1, sClass2, sClass3, sClass4,sItemNm );
54
+        int gridTotal = fnCalculateGridTotal(gridSize, gridRecords);
55
+        List<ItemUnitEntity> entities = itemUnitMapper.selectItemUnitGridList(sBrandId, fromDt,  toDt, sUnitStCd, sSpplyId, sClass1, sClass2, sClass3, sClass4,sItemNm, gridRequest);
56
+        List<Object> gridRows = entities.stream()
57
+                .map(m -> ItemUnitSearchResponse.builder()
58
+                        .viewCd("R")
59
+                        .brandUnitUnqNo(m.getBrandUnitUnqNo())
60
+                        .brandId(m.getBrandId())
61
+                        .itemId(m.getItemId())
62
+                        .itemNm(m.getItemNm())
63
+                        .spplyId(m.getSpplyId())
64
+                        .spplyNm(m.getSpplyNm())
65
+                        .contSttDt(m.getContSttDt())
66
+                        .contEndDt(m.getContEndDt())
67
+                        .curr(m.getCurr())
68
+                        .currNm(m.getCurrNm())
69
+                        .unit(m.getUnit())
70
+                        .unitNm(m.getUnitNm())
71
+                        .unitAmt(m.getUnitAmt())
72
+                        .leadTime(m.getLeadTime())
73
+                        .spplyItemId(m.getSpplyItemId())
74
+                        .unitStCd(m.getUnitStCd())
75
+                        .stddQty(m.getStddQty())
76
+                        .build())
77
+                .collect(Collectors.toList());
78
+        return GridResponse.toDTO(gridPage, gridTotal, gridRecords, gridRows);
79
+    }
80
+
81
+
82
+
83
+    /* 공급사 단가 정보 */
84
+    public ItemUnitInfoResponse selectItemUnitInfo(String brandId, String brandUnitUnqNo) throws Exception {
85
+
86
+        ItemUnitEntity entity = itemUnitMapper.selectItemUnitInfo( brandId, brandUnitUnqNo);
87
+        List<FileEntity> fileContInfoList = null;
88
+
89
+        if (!"".equals(entity.getShortContFileNo())) {
90
+            fileContInfoList = fileMapper.selectFileList(entity.getShortContFileNo()) ;
91
+        } else {
92
+            fileContInfoList = new ArrayList<FileEntity>();
93
+        }
94
+
95
+        return ItemUnitInfoResponse.toDTO(entity,fileContInfoList );
96
+
97
+    }
98
+
99
+    /* 공급사 단가 저장 */
100
+    @Transactional
101
+    public void saveItemUnitInfo(String userId, SaveItemUnitInfolRequest saveItemUnitInfolRequest) throws Exception {
102
+        try {
103
+
104
+            ItemUnitEntity entity = new ItemEntity();
105
+            entity.setBrandUnitUnqNo(saveItemUnitInfolRequest.getBrandUnitUnqNo());
106
+            entity.setBrandId(saveItemUnitInfolRequest.getBrandId());
107
+            entity.setBrandNm(saveItemUnitInfolRequest.getBrandNm());
108
+            entity.setItemId(saveItemUnitInfolRequest.getItemId());
109
+            entity.setItemNm(saveItemUnitInfolRequest.getItemNm());
110
+            entity.setSpplyId(saveItemUnitInfolRequest.getSpplyId());
111
+            entity.setSpplyNm(saveItemUnitInfolRequest.getSpplyNm());
112
+            entity.setContSttDt(saveItemUnitInfolRequest.getContSttDt().replaceAll("\\.",""));
113
+            entity.setContEndDt(saveItemUnitInfolRequest.getContEndDt().replaceAll("\\.",""));
114
+            entity.setCurr(saveItemUnitInfolRequest.getCurr());
115
+            entity.setUnit(saveItemUnitInfolRequest.getUnit());
116
+            entity.setUnitAmt(saveItemUnitInfolRequest.getUnitAmt());
117
+            entity.setLeadTime(saveItemUnitInfolRequest.getLeadTime());
118
+            entity.setDlvCndt(saveItemUnitInfolRequest.getDlvCndt());
119
+            entity.setShortContFileNo(saveItemUnitInfolRequest.getShortContFileNo());
120
+            entity.setSpplyItemId(saveItemUnitInfolRequest.getSpplyItemId());
121
+            entity.setUnitStCd(saveItemUnitInfolRequest.getUnitStCd());
122
+            entity.setStddQty(saveItemUnitInfolRequest.getStddQty());
123
+            entity.setStoreSaleStddQty(saveItemUnitInfolRequest.getStoreSaleStddQty());
124
+            entity.setStoreSaleUnitAmt(saveItemUnitInfolRequest.getStoreSaleUnitAmt());
125
+
126
+            if ("C".equals(saveItemUnitInfolRequest.getViewCd())) {
127
+                //selectItemUnitDupContInfoNo  날짜 기준 계약 존재여부 파악
128
+                ItemUnitEntity condtEntity = itemUnitMapper.selectItemUnitDupContInfoNo(entity.getBrandId(), entity.getSpplyId(), entity.getItemId(), entity.getContSttDt(), entity.getContEndDt());
129
+
130
+                if (condtEntity != null && !"".equals(condtEntity.getBrandUnitUnqNo())) {
131
+                    itemUnitMapper.updateItemUnitContEnd(entity.getBrandId(), entity.getBrandUnitUnqNo(), entity.getContEndDt());
132
+                }
133
+            }
134
+            itemUnitMapper.insertMergItemUnitInfo(userId, entity);
135
+
136
+
137
+        } catch (GlobalException e) {
138
+            e.getStackTrace();
139
+            throw new GlobalException(e.getSystemMessageCode());
140
+        } catch (Exception e) {
141
+            e.getStackTrace();
142
+            throw new RuntimeException();
143
+        }
144
+    }
145
+
146
+
147
+
148
+}

+ 75 - 0
src/main/java/com/oqpo/api/web/dto/request/stinfo/itemUnit/SaveItemUnitInfolRequest.java

@@ -0,0 +1,75 @@
1
+package com.oqpo.api.web.dto.request.stinfo.itemUnit;
2
+
3
+import io.swagger.annotations.ApiModelProperty;
4
+import lombok.Getter;
5
+import lombok.Setter;
6
+
7
+import javax.validation.constraints.NotBlank;
8
+
9
+@Getter
10
+@Setter
11
+public class SaveItemUnitInfolRequest {
12
+    @NotBlank
13
+    @ApiModelProperty(value = "CRUD")
14
+    private String viewCd;
15
+
16
+    @ApiModelProperty(value = "브랜드단가고유번호")
17
+    private String brandUnitUnqNo;
18
+
19
+    @ApiModelProperty(value = "브랜드아이디")
20
+    private String brandId;
21
+
22
+    @ApiModelProperty(value = "브랜드명")
23
+    private String brandNm;
24
+
25
+    @ApiModelProperty(value = "품목아이디")
26
+    private String itemId;
27
+
28
+    @ApiModelProperty(value = "품목명")
29
+    private String itemNm;
30
+
31
+    @ApiModelProperty(value = "공급사아이디")
32
+    private String spplyId;
33
+
34
+    @ApiModelProperty(value = "공급사명")
35
+    private String spplyNm;
36
+
37
+    @ApiModelProperty(value = "계약시작일자")
38
+    private String contSttDt;
39
+
40
+    @ApiModelProperty(value = "계약종료일자")
41
+    private String contEndDt;
42
+
43
+    @ApiModelProperty(value = "통화")
44
+    private String curr;
45
+
46
+    @ApiModelProperty(value = "단위")
47
+    private String unit;
48
+
49
+    @ApiModelProperty(value = "단가금액")
50
+    private Integer unitAmt;
51
+
52
+    @ApiModelProperty(value = "리드타임")
53
+    private Integer leadTime;
54
+
55
+    @ApiModelProperty(value = "배송조건")
56
+    private String dlvCndt;
57
+
58
+    @ApiModelProperty(value = "단기계약서파일번호")
59
+    private String shortContFileNo;
60
+
61
+    @ApiModelProperty(value = "공급사품목아이디")
62
+    private String spplyItemId;
63
+
64
+    @ApiModelProperty(value = "단가상태코드")
65
+    private String unitStCd;
66
+
67
+    @ApiModelProperty(value = "기준수량")
68
+    private Integer stddQty;
69
+
70
+    @ApiModelProperty(value = "매장판매기준수량")
71
+    private Integer storeSaleStddQty;
72
+
73
+    @ApiModelProperty(value = "매장판매단가금액")
74
+    private Integer storeSaleUnitAmt;
75
+}

+ 170 - 0
src/main/java/com/oqpo/api/web/dto/response/stinfo/itemUnit/ItemUnitInfoResponse.java

@@ -0,0 +1,170 @@
1
+package com.oqpo.api.web.dto.response.stinfo.itemUnit;
2
+
3
+import com.fasterxml.jackson.annotation.JsonInclude;
4
+import com.oqpo.api.entity.oper.FileEntity;
5
+import com.oqpo.api.entity.stinfo.ItemEntity;
6
+import com.oqpo.api.entity.stinfo.ItemUnitEntity;
7
+import io.swagger.annotations.ApiModelProperty;
8
+import lombok.*;
9
+
10
+import java.util.List;
11
+import java.util.stream.Collectors;
12
+
13
+
14
+@Getter
15
+@Setter
16
+@Builder
17
+@AllArgsConstructor(access = AccessLevel.PROTECTED)
18
+@JsonInclude(JsonInclude.Include.ALWAYS)
19
+public class ItemUnitInfoResponse {
20
+
21
+    @ApiModelProperty(value = "브랜드단가고유번호")
22
+    private String brandUnitUnqNo;
23
+
24
+    @ApiModelProperty(value = "브랜드아이디")
25
+    private String brandId;
26
+
27
+    @ApiModelProperty(value = "브랜드명")
28
+    private String brandNm;
29
+
30
+    @ApiModelProperty(value = "품목아이디")
31
+    private String itemId;
32
+
33
+    @ApiModelProperty(value = "품목명")
34
+    private String itemNm;
35
+
36
+    @ApiModelProperty(value = "공급사아이디")
37
+    private String spplyId;
38
+
39
+    @ApiModelProperty(value = "공급사명")
40
+    private String spplyNm;
41
+
42
+    @ApiModelProperty(value = "계약시작일자")
43
+    private String contSttDt;
44
+
45
+    @ApiModelProperty(value = "계약종료일자")
46
+    private String contEndDt;
47
+
48
+    @ApiModelProperty(value = "통화")
49
+    private String curr;
50
+
51
+    @ApiModelProperty(value = "통화명")
52
+    private String currNm;
53
+
54
+    @ApiModelProperty(value = "단위")
55
+    private String unit;
56
+
57
+    @ApiModelProperty(value = "단위명")
58
+    private String unitNm;
59
+
60
+    @ApiModelProperty(value = "단가금액")
61
+    private Integer unitAmt;
62
+
63
+    @ApiModelProperty(value = "리드타임")
64
+    private Integer leadTime;
65
+
66
+    @ApiModelProperty(value = "배송조건")
67
+    private String dlvCndt;
68
+
69
+    @ApiModelProperty(value = "배송조건명")
70
+    private String dlvCndtNm;
71
+
72
+    @ApiModelProperty(value = "단기계약서파일번호")
73
+    private String shortContFileNo;
74
+
75
+    @ApiModelProperty(value = "공급사품목아이디")
76
+    private String spplyItemId;
77
+
78
+    @ApiModelProperty(value = "단가상태코드")
79
+    private String unitStCd;
80
+
81
+    @ApiModelProperty(value = "단가상태코드명")
82
+    private String unitStNm;
83
+
84
+    @ApiModelProperty(value = "기준수량")
85
+    private Integer stddQty;
86
+
87
+    @ApiModelProperty(value = "매장판매기준수량")
88
+    private Integer storeSaleStddQty;
89
+
90
+    @ApiModelProperty(value = "매장판매단가금액")
91
+    private Integer storeSaleUnitAmt;
92
+
93
+    @ApiModelProperty(value = "시스템등록일시")
94
+    private String sysRegDttm;
95
+
96
+    @ApiModelProperty(value = "시스템등록아이디")
97
+    private String sysRegId;
98
+
99
+    @ApiModelProperty(value = "시스템변경일시")
100
+    private String sysChgDttm;
101
+
102
+    @ApiModelProperty(value = "시스템변경아이디")
103
+    private String sysChgId;
104
+
105
+
106
+    @ApiModelProperty(value = "품목이지미 파일 정보")
107
+    private List<ItemUnitInfoResponse.FileContInfo> imageFileNoList;
108
+
109
+    public static ItemUnitInfoResponse toDTO(ItemUnitEntity entity, List<FileEntity>  fileImageInfoList) {
110
+        if (entity == null) return null;
111
+        return ItemUnitInfoResponse.builder()
112
+                .brandUnitUnqNo(entity.getBrandUnitUnqNo())
113
+                .brandId(entity.getBrandId())
114
+                .itemId(entity.getItemId())
115
+                .itemNm(entity.getItemNm())
116
+                .spplyId(entity.getSpplyId())
117
+                .spplyNm(entity.getSpplyNm())
118
+                .contSttDt(entity.getContSttDt() == null ? "" :entity.getContSttDt())
119
+                .contEndDt(entity.getContEndDt() == null ? "" :entity.getContEndDt())
120
+                .curr(entity.getCurr() == null ? "" :entity.getCurr())
121
+                .currNm(entity.getCurrNm() == null ? "" :entity.getCurrNm())
122
+                .unit(entity.getUnit() == null ? "" :entity.getUnit())
123
+                .unitNm(entity.getUnitNm() == null ? "" :entity.getUnitNm())
124
+                .unitAmt(entity.getUnitAmt() == null ? 0 :entity.getUnitAmt())
125
+                .leadTime(entity.getLeadTime() == null ? 0 :entity.getLeadTime())
126
+                .dlvCndt(entity.getDlvCndt() == null ? "" :entity.getDlvCndt())
127
+                .dlvCndtNm(entity.getDlvCndtNm() == null ? "" :entity.getDlvCndtNm())
128
+                .shortContFileNo(entity.getShortContFileNo() == null ? "" :entity.getShortContFileNo())
129
+                .imageFileNoList(fileImageInfoList.stream()
130
+                        .map(m -> FileContInfo.builder()
131
+                                .fileNo(m.getFileNo())
132
+                                .fileSeq(m.getFileSeq())
133
+                                .filePath(m.getFilePath())
134
+                                .fileNm(m.getFileNm())
135
+                                .fileOrgNm(m.getFileOrgNm())
136
+                                .build())
137
+                        .collect(Collectors.toList()))
138
+                .spplyItemId(entity.getSpplyItemId() == null ? "" :entity.getSpplyItemId())
139
+                .unitStCd(entity.getUnitStCd() == null ? "" :entity.getUnitStCd())
140
+                .unitStNm(entity.getUnitStNm() == null ? "" :entity.getUnitStNm())
141
+                .stddQty(entity.getStddQty() == null ? 0 :entity.getStddQty())
142
+                .storeSaleStddQty(entity.getStoreSaleStddQty() == null ? 0 :entity.getStoreSaleStddQty())
143
+                .storeSaleUnitAmt(entity.getStoreSaleUnitAmt() == null ? 0 :entity.getStoreSaleUnitAmt())
144
+                .sysRegDttm(entity.getSysRegDttm())
145
+                .sysRegId(entity.getSysRegId())
146
+                .sysChgDttm(entity.getSysChgDttm())
147
+                .sysChgId(entity.getSysChgId())
148
+                .build();
149
+    }
150
+
151
+    @Getter
152
+    @Builder
153
+    @AllArgsConstructor(access = AccessLevel.PROTECTED)
154
+    static class FileContInfo {
155
+        @ApiModelProperty(value = "파일번호")
156
+        private String fileNo;
157
+
158
+        @ApiModelProperty(value = "파일순번")
159
+        private Integer fileSeq;
160
+
161
+        @ApiModelProperty(value = "파일경로")
162
+        private String filePath;
163
+
164
+        @ApiModelProperty(value = "파일명")
165
+        private String fileNm;
166
+
167
+        @ApiModelProperty(value = "원파일명")
168
+        private String fileOrgNm;
169
+    }
170
+}

+ 71 - 0
src/main/java/com/oqpo/api/web/dto/response/stinfo/itemUnit/ItemUnitSearchResponse.java

@@ -0,0 +1,71 @@
1
+package com.oqpo.api.web.dto.response.stinfo.itemUnit;
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 ItemUnitSearchResponse {
13
+
14
+    @ApiModelProperty(value = "CRUD")
15
+    private String viewCd;
16
+
17
+    @ApiModelProperty(value = "브랜드단가고유번호")
18
+    private String brandUnitUnqNo;
19
+
20
+    @ApiModelProperty(value = "브랜드아이디")
21
+    private String brandId;
22
+
23
+    @ApiModelProperty(value = "품목아이디")
24
+    private String itemId;
25
+
26
+    @ApiModelProperty(value = "품목명")
27
+    private String itemNm;
28
+
29
+    @ApiModelProperty(value = "공급사아이디")
30
+    private String spplyId;
31
+
32
+    @ApiModelProperty(value = "공급사명")
33
+    private String spplyNm;
34
+
35
+    @ApiModelProperty(value = "계약시작일자")
36
+    private String contSttDt;
37
+
38
+    @ApiModelProperty(value = "계약종료일자")
39
+    private String contEndDt;
40
+
41
+    @ApiModelProperty(value = "통화")
42
+    private String curr;
43
+
44
+    @ApiModelProperty(value = "통화명")
45
+    private String currNm;
46
+
47
+    @ApiModelProperty(value = "단위")
48
+    private String unit;
49
+
50
+    @ApiModelProperty(value = "단위명명")
51
+   private String unitNm;
52
+
53
+    @ApiModelProperty(value = "단가금액")
54
+    private Integer unitAmt;
55
+
56
+    @ApiModelProperty(value = "리드타임")
57
+    private Integer leadTime;
58
+
59
+    @ApiModelProperty(value = "공급사품목아이디")
60
+    private String spplyItemId;
61
+
62
+    @ApiModelProperty(value = "단가상태코드")
63
+    private String unitStCd;
64
+
65
+    @ApiModelProperty(value = "단가상태명")
66
+    private String unitStNm;
67
+
68
+    @ApiModelProperty(value = "기준수량")
69
+    private Integer stddQty;
70
+
71
+}

+ 52 - 31
src/main/resources/mybatis/sqlmaps/stinfo/ItemUnit.xml

@@ -37,7 +37,7 @@
37 37
         <if test="sClass4 != null and sClass4 != ''">
38 38
             and  iclas.item_class4 = #{sClass4}
39 39
         </if>
40
-        <if test="sClass4 != null and sClass4 != ''">
40
+        <if test="sItemNm != null and sItemNm != ''">
41 41
         and   iunit.item_id like concat('%',#{sItemNm},'%') or iunit.item_nm like concat('%',#{sItemNm},'%')
42 42
         </if>
43 43
         <choose>
@@ -90,7 +90,7 @@
90 90
         <if test="sClass4 != null and sClass4 != ''">
91 91
             and  iclas.item_class4 = #{sClass4}
92 92
         </if>
93
-        <if test="sClass4 != null and sClass4 != ''">
93
+        <if test="sItemNm != null and sItemNm != ''">
94 94
             and   iunit.item_id like concat('%',#{sItemNm},'%') or iunit.item_nm like concat('%',#{sItemNm},'%')
95 95
         </if>
96 96
     </select>
@@ -101,46 +101,67 @@
101 101
                 iunit.spply_nm, date_format(iunit.cont_stt_dt,'%Y.%m.%d') as cont_stt_dt, date_format(iunit.cont_end_dt,'%Y.%m.%d') as cont_end_dt,
102 102
                 iunit.curr, fn_code_nm('CURR', iunit.curr) as curr_nm, iunit.unit, fn_code_nm('DSTRBT_COST_UNIT', iunit.unit) as unit,
103 103
                 iunit.unit_amt, iunit.lead_time, iunit.spply_item_id,
104
+                iunit.dlv_cndt, fn_code_nm('DLV_CNDT', iunit.dlv_cndt) as dlv_cndt_nm,
104 105
                 iunit.unit_st_cd, fn_code_nm('UNIT_ST_CD', iunit.unit_st_cd) as unit_st_nm, iunit.stdd_qyt,
105 106
                 iunit.store_sale_stdd_qty, iunit.store_sale_unit_amt, iunit.short_cont_file_no
107
+                date_format(iunit.sys_reg_dttm,'%Y.%m.%d %H:%i:%s') as sys_reg_dttm. iunit.sys_reg_id, date_format(iunit.sys_chg_dttm,'%Y.%m.%d %H:%i:%s') as  sys_chg_dttm, iunit.sys_chg_id
106 108
         from  brand_item_unit_info iunit
107
-        where iunit.brand_id = #{brandId}
108
-        and   iunit.brand_unit_unq_no = #{brandUnitUnqNo}
109
+        where iunit.brand_unit_unq_no = #{brandUnitUnqNo}
110
+        and   iunit.brand_id = #{brandId}
109 111
     </select>
110 112
 
111
-    <insert id="insertItemUnitInfo" >
112
-        insert into brand_item_unit_info
113
-            (brand_unit_unq_no, brand_id, item_id, item_nm, spply_id,
114
-             spply_nm, cont_stt_dt, cont_end_dt, curr, unit,
115
-             unit_amt, lead_time, dlv_cndt, short_cont_file_no, spply_item_id,
116
-             unit_st_cd, stdd_qyt, store_sale_stdd_qty, store_sale_unit_amt,
117
-             sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
113
+    <select id="selectItemUnitDupContInfoNo" resultType="com.oqpo.api.entity.stinfo.StoreItemUnitEntity">
114
+        select /* selectItemUnitDupContInfoNo */
115
+               brand_unit_unq_no
116
+        from   store_item_unit_info
117
+        where  brand_id = #{brandId}
118
+        and    spply_id = #{spplyId}
119
+        and    item_id  = #{itemId}
120
+        and    cont_end_dt between #{contSttDt} and #{contEndDt}
121
+    </select>
122
+
123
+    <update id="updateItemUnitContEnd" >
124
+        update /* updateItemUnitContEnd */
125
+                store_item_unit_info
126
+        set    cont_end_dt =  DATE_SUB(date_format(#{contEndDt},'%Y%m%d'), INTERVAL 1 DAY)
127
+        where  brand_id = #{brandId}
128
+        and    brand_unit_unq_no = #{brandUnitUnqNo}
129
+
130
+    </update>
131
+
132
+
133
+    <insert id="insertMergItemUnitInfo" >
134
+        insert into  /** Merge insertMergItemUnitInfo */
135
+        brand_item_unit_info
136
+        (brand_unit_unq_no, brand_id, item_id, item_nm, spply_id,
137
+        spply_nm, cont_stt_dt, cont_end_dt, curr, unit,
138
+        unit_amt, lead_time, dlv_cndt, short_cont_file_no, spply_item_id,
139
+        unit_st_cd, stdd_qyt, store_sale_stdd_qty, store_sale_unit_amt,
140
+        sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
118 141
         values
119
-            (#{entity.brandUnitUnqNo}, #{entity.brandId}, #{entity.itemId}, #{entity.itemNm}, #{entity.spplyId},
142
+            ( fn_get_dealno(33,''), #{entity.brandId}, #{entity.itemId}, #{entity.itemNm}, #{entity.spplyId},
120 143
             #{entity.spplyNm}, #{entity.contSttDt}, #{entity.contEndDt}, #{entity.curr}, #{entity.unit},
121 144
             #{entity.unitAmt}, #{entity.leadTime}, #{entity.dlvCndt}, #{entity.shortContFileNo}, #{entity.spplyItemId},
122 145
             #{entity.unitStCd}, #{entity.stddQyt}, #{entity.storeSaleStddQty}, #{entity.storeSaleUnitAmt},
123 146
             now(), #{userId}, now(), #{userId})
147
+        on duplicate key
148
+        update
149
+            sys_chg_dttm    = now(),
150
+            ,sys_chg_id      = #{userId},
151
+            ,cont_stt_dt     = VALUES(cont_stt_dt)
152
+            ,cont_end_dt     = VALUES(cont_end_dt)
153
+            ,curr            = VALUES(curr)
154
+            ,unit            = VALUES(unit)
155
+            ,unit_amt        = VALUES(unit_amt)
156
+            ,lead_time       = VALUES(lead_time)
157
+            ,dlv_cndt        = VALUES(dlv_cndt)
158
+            ,short_cont_file_no = VALUES(short_cont_file_no)
159
+            ,unit_st_cd      = VALUES(unit_st_cd)
160
+            ,stdd_qyt        = VALUES(stdd_qyt)
161
+            ,store_sale_stdd_qty =VALUES(store_sale_stdd_qty)
162
+            ,store_sale_unit_amt = VALUES(store_sale_unit_amt)
124 163
     </insert>
125 164
 
126
-    <update id="updateItemUnitInfo">
127
-        update brand_item_unit_info
128
-        set     cont_stt_dt = #{entity.contSttDt},
129
-                cont_end_dt = #{entity.contEndDt},
130
-                curr = #{entity.curr},
131
-                unit = #{entity.unit},
132
-                unit_amt = #{entity.unitAmt},
133
-                lead_time = #{entity.leadTime},
134
-                dlv_cndt = #{entity.dlvCndt},
135
-                short_cont_file_no = #{entity.shortContFileNo},
136
-                unit_st_cd = #{entity.unitStCd},
137
-                stdd_qyt = #{entity.stddQyt},
138
-                store_sale_stdd_qty = #{entity.storeSaleStddQty},
139
-                store_sale_unit_amt = #{entity.storeSaleUnitAmt},
140
-                sys_chg_dttm = now(),
141
-                sys_chg_id = #{userId}
142
-        where   brand_id = #{entity.brandId}
143
-        and     brand_unit_unq_no = #{entity.brandUnitUnqNo}
144
-    </update>
165
+
145 166
 
146 167
 </mapper>

+ 123 - 0
src/main/resources/mybatis/sqlmaps/stinfo/StoreItemUnit.xml

@@ -0,0 +1,123 @@
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.stinfo.ItemUnitMapper">
5
+
6
+    <select id="selectStoreItemUnitGridList" resultType="com.oqpo.api.entity.stinfo.StoreItemUnitEntity">
7
+        select  /* selectStoreItemUnitGridList */
8
+                iunit.brand_id, fn_brand_nm(iunit.brand_id) as brand_nm, iunit.store_id, fn_store_nm(iunit.store_id) as store_nm,
9
+                date_format(iunit.cont_stt_dt,'%Y.%m.%d') as cont_stt_dt, date_format(iunit.cont_end_dt,'%Y.%m.%d') as cont_end_dt,
10
+                date_format(iunit.sys_reg_dttm,'%Y.%m.%d') as sys_reg_dttm, iunit.item_cnt
11
+        from (
12
+        select  brand_id, store_id, cont_stt_dt, cont_end_dt, min(sys_reg_dttm) as sys_reg_dttm, count(*) as item_cnt
13
+        from    store_item_unit_info
14
+        where   brand_id = #{sBrandId}
15
+        <if test="sStoreId != null and sStoreId != ''">
16
+            and     store_id = #{sStoreId}
17
+        </if>
18
+        and     unit_target_cd = 'Y'
19
+        group by brand_id, store_id, cont_stt_dt, cont_end_dt
20
+        ) iunit
21
+        <choose>
22
+            <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
23
+                <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
24
+                    <if test="gridRequest.sord == 'asc'.toString()">
25
+                        order by iunit.store_nm asc
26
+                    </if>
27
+                    <if test="gridRequest.sord == 'desc'.toString()">
28
+                        order by iunit.store_nm desc
29
+                    </if>
30
+                </if>
31
+            </when>
32
+            <otherwise>
33
+                order by iunit.store_nm asc
34
+            </otherwise>
35
+        </choose>
36
+        <if test="gridRequest.pagingYn == true">
37
+            limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
38
+        </if>
39
+    </select>
40
+
41
+    <select id="selectStoreItemUnitGridCnt" resultType="int">
42
+        select /*selectStoreItemUnitGridCnt*/
43
+        count(*)
44
+        from (
45
+        select  distinct brand_id, store_id, cont_stt_dt, cont_end_dt
46
+        from    store_item_unit_info
47
+        where   brand_id = #{sBrandId}
48
+        <if test="sStoreId != null and sStoreId != ''">
49
+            and     store_id = #{sStoreId}
50
+        </if>
51
+        and     unit_target_cd = 'Y'
52
+        ) iunit
53
+    </select>
54
+
55
+    <select id="selectStoreItemUnitInfo" resultType="com.oqpo.api.entity.stinfo.StoreItemUnitEntity">
56
+        select /*selectStoreItemUnitInfo*/
57
+                item.brand_id, item.item_id, item.item_nm,
58
+                case when unit.cont_stt_dt is null or unit.cont_stt_dt = '' then #{contSttDt} else date_format(unit.cont_stt_dt,'%Y.%m.%d') end as cont_stt_dt,
59
+                case when unit.cont_end_dt is null or unit.cont_end_dt = '' then #{contEndDt} else date_format(unit.cont_end_dt,'%Y.%m.%d') end as cont_end_dt,
60
+                case when unit.unit is null or  unit.unit = '' then item.unit else unit.unit end as unit   ,
61
+                case when unit.unit is null or  unit.unit = '' then fn_code_nm('DSTRBT_COST_UNIT',item.unit) else fn_code_nm('DSTRBT_COST_UNIT',unit.unit) end as unit_nm   ,
62
+                case when nvl(unit.stdd_qty,0) = 0 then item.store_sale_stdd_qty else unit.stdd_qty end as stdd_qty  ,
63
+                case when unit.curr is null or  unit.curr = '' then item.curr else unit.curr end as curr,
64
+                case when unit.curr is null or  unit.curr = '' then fn_code_nm('CURR',item.curr) else fn_code_nm('CURR',unit.curr) end as curr_nm,
65
+                case when unit.unit_amt is null or  unit.unit_amt = 0 then item.store_sale_unit_amt else unit.unit_amt end as unit_amt,
66
+                case when unit.unit_target_cd is null or unit.unit_target_cd = '' then 'Y' else unit.unit_target_cd end as unit_target_cd,
67
+                case when unit.unit_target_cd is null or unit.unit_target_cd = '' then fn_code_nm('DSTRBT_COST_UNIT','Y') else  fn_code_nm('DSTRBT_COST_UNIT',unit.unit_target_cd)  end as unit_target_nm,
68
+                nvl(unit.unit_amt,0) as supply_unit_amt
69
+        from   brand_item_unit_info item
70
+        left outer join store_item_unit_info unit on  item.brand_unit_unq_no = unit.brand_unit_unq_no and  item.brand_id = unit.brand_id and item.item_id = unit.item_id and unit.store_id = #{storeId}
71
+        where item.brand_id = #{brandId}
72
+    </select>
73
+
74
+    <select id="selectStoreItemUnitContDateInfo" resultType="com.oqpo.api.entity.stinfo.StoreItemUnitEntity">
75
+        select /* selectStoreItemUnitContDateInfo */
76
+                max(cont_end_dt) as cont_end_dt
77
+        from   store_item_unit_info
78
+        where  brand_id = #{brandId}
79
+        and    store_id = #{storeId}
80
+        and    cont_end_dt between #{contSttDt} and #{contEndDt}
81
+    </select>
82
+
83
+    <update id="updateStoreItemUnitContEnd" >
84
+        update /* updateStoreItemUnitContEnd */
85
+                store_item_unit_info
86
+        set    cont_end_dt =  DATE_SUB(date_format(#{contEndDt},'%Y%m%d'), INTERVAL 1 DAY)
87
+        where  brand_id = #{brandId}
88
+        and    store_id = #{storeId}
89
+        and    cont_end_dt = #{contEndDt}
90
+
91
+    </update>
92
+
93
+
94
+    <insert id="insertMergStoreItemUnitInfo" >
95
+            insert into  /** Merge insertMergStoreItemUnitInfo */
96
+                store_item_unit_info
97
+                (store_unit_unq_no, cont_stt_dt, cont_end_dt, unit,
98
+                 curr, unit_amt, store_id, brand_id, short_cont_file_no,
99
+                 unit_target_cd, item_id, stdd_qty, brand_unit_unq_no,
100
+                 sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
101
+            values
102
+            <foreach collection="gridUpdateData" item="item" separator=",">
103
+                ( fn_get_dealno(34,''), #{item.contSttDt}, #{item.contEndDt}, #{item.unit},
104
+                  #{item.curr}, #{item.unitAmt}, #{item.storeId}, #{item.brandId}, #{item.shortContFileNo},
105
+                  #{item.unitTargetCd}, #{item.itemId}, #{item.stddQty}, #{item.brandUnitUnqNo},
106
+                  NOW(), #{userId}, NOW(), #{userId})
107
+            </foreach>
108
+            on duplicate key
109
+            update
110
+              sys_chg_dttm          = now()
111
+            , sys_chg_id            = #{userId}
112
+            , cont_stt_dt       = VALUES(cont_stt_dt)
113
+            , cont_end_dt       = VALUES(cont_end_dt)
114
+            , unit              = VALUES(unit)
115
+            , curr              = VALUES(curr)
116
+            , unit_amt          = VALUES(unit_amt)
117
+            , unit_target_cd    = VALUES(unit_target_cd)
118
+            , stdd_qty          = VALUES(stdd_qty)
119
+    </insert>
120
+
121
+
122
+
123
+</mapper>