|
@@ -1,26 +1,29 @@
|
1
|
1
|
package com.oqpo.api.service.stinfo;
|
2
|
2
|
|
3
|
3
|
|
|
4
|
+import com.oqpo.api.entity.CodeEntity;
|
4
|
5
|
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;
|
|
6
|
+import com.oqpo.api.entity.stinfo.*;
|
9
|
7
|
import com.oqpo.api.enums.SystemMessageCode;
|
10
|
8
|
import com.oqpo.api.exception.GlobalException;
|
11
|
9
|
import com.oqpo.api.mapper.FileMapper;
|
12
|
10
|
import com.oqpo.api.mapper.stinfo.ItemMapper;
|
13
|
11
|
import com.oqpo.api.mapper.stinfo.ItemUnitMapper;
|
|
12
|
+import com.oqpo.api.mapper.stinfo.StoreItemUnitMapper;
|
14
|
13
|
import com.oqpo.api.service.CommonService;
|
15
|
14
|
import com.oqpo.api.web.dto.request.GridRequest;
|
16
|
15
|
import com.oqpo.api.web.dto.request.stinfo.item.DelItemInfolRequest;
|
17
|
16
|
import com.oqpo.api.web.dto.request.stinfo.item.SaveItemClassMngInfolRequest;
|
18
|
17
|
import com.oqpo.api.web.dto.request.stinfo.item.SaveItemInfolRequest;
|
19
|
18
|
import com.oqpo.api.web.dto.request.stinfo.itemUnit.SaveItemUnitInfolRequest;
|
|
19
|
+import com.oqpo.api.web.dto.request.stinfo.itemUnit.SaveStoreItemUnitInfolRequest;
|
20
|
20
|
import com.oqpo.api.web.dto.response.GridResponse;
|
|
21
|
+import com.oqpo.api.web.dto.response.code.CodeSearchListResponse;
|
21
|
22
|
import com.oqpo.api.web.dto.response.stinfo.item.*;
|
22
|
23
|
import com.oqpo.api.web.dto.response.stinfo.itemUnit.ItemUnitInfoResponse;
|
23
|
24
|
import com.oqpo.api.web.dto.response.stinfo.itemUnit.ItemUnitSearchResponse;
|
|
25
|
+import com.oqpo.api.web.dto.response.stinfo.itemUnit.StoreItemUnitInfoResponse;
|
|
26
|
+import com.oqpo.api.web.dto.response.stinfo.itemUnit.StoreItemUnitSearchResponse;
|
24
|
27
|
import lombok.extern.slf4j.Slf4j;
|
25
|
28
|
import org.springframework.beans.factory.annotation.Autowired;
|
26
|
29
|
import org.springframework.stereotype.Service;
|
|
@@ -36,6 +39,10 @@ public class ItemUnitService extends CommonService {
|
36
|
39
|
@Autowired
|
37
|
40
|
private ItemUnitMapper itemUnitMapper;
|
38
|
41
|
|
|
42
|
+ @Autowired
|
|
43
|
+ private StoreItemUnitMapper storeItemUnitMapper;
|
|
44
|
+
|
|
45
|
+
|
39
|
46
|
@Autowired
|
40
|
47
|
private FileMapper fileMapper;
|
41
|
48
|
|
|
@@ -101,7 +108,7 @@ public class ItemUnitService extends CommonService {
|
101
|
108
|
public void saveItemUnitInfo(String userId, SaveItemUnitInfolRequest saveItemUnitInfolRequest) throws Exception {
|
102
|
109
|
try {
|
103
|
110
|
|
104
|
|
- ItemUnitEntity entity = new ItemEntity();
|
|
111
|
+ ItemUnitEntity entity = new ItemUnitEntity();
|
105
|
112
|
entity.setBrandUnitUnqNo(saveItemUnitInfolRequest.getBrandUnitUnqNo());
|
106
|
113
|
entity.setBrandId(saveItemUnitInfolRequest.getBrandId());
|
107
|
114
|
entity.setBrandNm(saveItemUnitInfolRequest.getBrandNm());
|
|
@@ -144,5 +151,74 @@ public class ItemUnitService extends CommonService {
|
144
|
151
|
}
|
145
|
152
|
|
146
|
153
|
|
|
154
|
+ /*
|
|
155
|
+ 브랜드 매장 단가 리스트 조회
|
|
156
|
+ */
|
|
157
|
+ public GridResponse selectStoreItemUnitGridList(String sBrandId, String sStoreId, GridRequest gridRequest) throws Exception {
|
|
158
|
+ int gridPage = gridRequest.getGridPage();
|
|
159
|
+ int gridSize = gridRequest.getGridSize();
|
|
160
|
+
|
|
161
|
+ int gridRecords = storeItemUnitMapper.selectStoreItemUnitGridCnt( sBrandId, sStoreId );
|
|
162
|
+ int gridTotal = fnCalculateGridTotal(gridSize, gridRecords);
|
|
163
|
+ List<StoreItemUnitEntity> entities = storeItemUnitMapper.selectStoreItemUnitGridList(sBrandId, sStoreId, gridRequest);
|
|
164
|
+ List<Object> gridRows = entities.stream()
|
|
165
|
+ .map(m -> StoreItemUnitSearchResponse.builder()
|
|
166
|
+ .viewCd("R")
|
|
167
|
+ .brandId(m.getBrandId())
|
|
168
|
+ .brandNm(m.getBrandNm())
|
|
169
|
+ .storeId(m.getStoreId())
|
|
170
|
+ .storeNm(m.getStoreNm())
|
|
171
|
+ .contSttDt(m.getContSttDt())
|
|
172
|
+ .contEndDt(m.getContEndDt())
|
|
173
|
+ .sysRegDttm(m.getSysRegDttm())
|
|
174
|
+ .itemCnt(m.getItemCnt())
|
|
175
|
+ .build())
|
|
176
|
+ .collect(Collectors.toList());
|
|
177
|
+ return GridResponse.toDTO(gridPage, gridTotal, gridRecords, gridRows);
|
|
178
|
+ }
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+ /* 매장 단가 정보 */
|
|
182
|
+ public StoreItemUnitInfoResponse selectStoreItemUnitInfo(String brandId, String storeId, String contSttDt, String contEndDt) throws Exception {
|
|
183
|
+
|
|
184
|
+ List<StoreItemUnitEntity> entities = storeItemUnitMapper.selectStoreItemUnitInfo( brandId, storeId, contSttDt, contEndDt);
|
|
185
|
+ return StoreItemUnitInfoResponse.toDTO(entities);
|
|
186
|
+
|
|
187
|
+ }
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+ /* 매장 단가 저장 */
|
|
191
|
+ @Transactional
|
|
192
|
+ public void saveStroeItemUnitInfo(String userId, SaveStoreItemUnitInfolRequest saveStoreItemUnitInfolRequest) throws Exception {
|
|
193
|
+ try {
|
|
194
|
+
|
|
195
|
+ StoreItemUnitEntity entity = new StoreItemUnitEntity();
|
|
196
|
+ entity.setBrandId(saveStoreItemUnitInfolRequest.getBrandId());
|
|
197
|
+ entity.setStoreId(saveStoreItemUnitInfolRequest.getStoreId());
|
|
198
|
+ entity.setContSttDt(saveStoreItemUnitInfolRequest.getContSttDt());
|
|
199
|
+ entity.setContEndDt(saveStoreItemUnitInfolRequest.getContEndDt());
|
|
200
|
+
|
|
201
|
+ StoreItemUnitEntity chkDataEnity = storeItemUnitMapper.selectStoreItemUnitContDateInfo(entity.getBrandId(), entity.getStoreId(), entity.getContSttDt(), entity.getContEndDt());
|
|
202
|
+
|
|
203
|
+ if (chkDataEnity != null) {
|
|
204
|
+ if ("".equals(chkDataEnity.getContEndDt()))
|
|
205
|
+ {
|
|
206
|
+ storeItemUnitMapper.updateStoreItemUnitContEnd(entity.getBrandId(), entity.getStoreId(), chkDataEnity.getContEndDt());
|
|
207
|
+ }
|
|
208
|
+ }
|
|
209
|
+
|
|
210
|
+ List<StoreItemUnitEntity> gridUpdateData = saveStoreItemUnitInfolRequest.toCodeEntities(saveStoreItemUnitInfolRequest.getGridUpdateData());
|
|
211
|
+ if (gridUpdateData.size() > 0) {
|
|
212
|
+ storeItemUnitMapper.insertMergStoreItemUnitInfo(userId, entity.getBrandId(), entity.getStoreId(), entity.getContSttDt(),entity.getContEndDt(), gridUpdateData) ;
|
|
213
|
+ }
|
|
214
|
+
|
|
215
|
+ } catch (GlobalException e) {
|
|
216
|
+ e.getStackTrace();
|
|
217
|
+ throw new GlobalException(e.getSystemMessageCode());
|
|
218
|
+ } catch (Exception e) {
|
|
219
|
+ e.getStackTrace();
|
|
220
|
+ throw new RuntimeException();
|
|
221
|
+ }
|
|
222
|
+ }
|
147
|
223
|
|
148
|
224
|
}
|