|
@@ -30,7 +30,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
30
|
30
|
import org.springframework.stereotype.Service;
|
31
|
31
|
import org.springframework.transaction.annotation.Transactional;
|
32
|
32
|
|
|
33
|
+import java.lang.reflect.GenericDeclaration;
|
|
34
|
+import java.text.SimpleDateFormat;
|
33
|
35
|
import java.util.ArrayList;
|
|
36
|
+import java.util.Date;
|
34
|
37
|
import java.util.List;
|
35
|
38
|
import java.util.stream.Collectors;
|
36
|
39
|
|
|
@@ -174,10 +177,18 @@ public class ItemUnitService extends CommonService {
|
174
|
177
|
|
175
|
178
|
if ("C".equals(saveItemUnitInfolRequest.getViewCd())) {
|
176
|
179
|
//selectItemUnitDupContInfoNo 날짜 기준 계약 존재여부 파악
|
177
|
|
- ItemUnitEntity condtEntity = itemUnitMapper.selectItemUnitDupContInfoNo(entity.getBrandId(), entity.getSpplyId(), entity.getItemId(), entity.getContSttDt(), entity.getContEndDt());
|
|
180
|
+ int dupCnt = itemUnitMapper.selectItemUnitDupCnt(entity.getBrandId(), entity.getSpplyId(), entity.getItemId(), entity.getContSttDt());
|
178
|
181
|
|
179
|
|
- if (condtEntity != null && !"".equals(condtEntity.getBrandUnitUnqNo())) {
|
180
|
|
- itemUnitMapper.updateItemUnitContEnd(entity.getBrandId(), entity.getBrandUnitUnqNo(), entity.getContEndDt());
|
|
182
|
+ if (dupCnt != 0) {
|
|
183
|
+ // 이미 진행중인 계약단가가 있습니다.
|
|
184
|
+ throw new GlobalException(SystemMessageCode.ERR_EXISTUNIT);
|
|
185
|
+ }
|
|
186
|
+ } else {
|
|
187
|
+ String passChk = itemUnitMapper.selectItemUnitChaPass(entity.getBrandUnitUnqNo(),entity.getContSttDt());
|
|
188
|
+
|
|
189
|
+ if ("N".equals(passChk)) {
|
|
190
|
+ // 시작일은 변경 불가
|
|
191
|
+ throw new GlobalException(SystemMessageCode.ERR_NOTCHGDT);
|
181
|
192
|
}
|
182
|
193
|
}
|
183
|
194
|
|
|
@@ -288,12 +299,19 @@ public class ItemUnitService extends CommonService {
|
288
|
299
|
entity.setBrandId(saveStoreItemUnitInfolRequest.getBrandId());
|
289
|
300
|
entity.setStoreId(saveStoreItemUnitInfolRequest.getStoreId());
|
290
|
301
|
|
|
302
|
+ //신규
|
|
303
|
+ if ("C".toString().equals(saveStoreItemUnitInfolRequest.getViewCd())) {
|
|
304
|
+ entity.setContSttDt(saveStoreItemUnitInfolRequest.getContSttDt().replaceAll("\\.",""));
|
|
305
|
+ entity.setContEndDt(saveStoreItemUnitInfolRequest.getContEndDt().replaceAll("\\.",""));
|
|
306
|
+ }
|
|
307
|
+
|
291
|
308
|
List<StoreItemUnitEntity> gridUpdateData = saveStoreItemUnitInfolRequest.toCodeEntities(saveStoreItemUnitInfolRequest.getGridUpdateData());
|
292
|
309
|
List<StoreItemUnitEntity> gridInsertData = saveStoreItemUnitInfolRequest.toCodeEntities(saveStoreItemUnitInfolRequest.getGridInsertData());
|
293
|
310
|
|
294
|
|
- String contSttDt = "";
|
295
|
|
- String contEndDt = "";
|
|
311
|
+ //String contSttDt = "";
|
|
312
|
+ //String contEndDt = "";
|
296
|
313
|
|
|
314
|
+ /*
|
297
|
315
|
if (gridUpdateData.size() > 0) {
|
298
|
316
|
for (int k = 0; k < gridUpdateData.size(); k++) {
|
299
|
317
|
|
|
@@ -301,35 +319,53 @@ public class ItemUnitService extends CommonService {
|
301
|
319
|
contEndDt = gridUpdateData.get(k).getContEndDt().replaceAll("\\.", "");
|
302
|
320
|
gridUpdateData.get(k).setContSttDt(contSttDt);
|
303
|
321
|
gridUpdateData.get(k).setContEndDt(contEndDt);
|
304
|
|
-
|
305
|
322
|
entity.setContSttDt(contSttDt);
|
306
|
323
|
entity.setContEndDt(contEndDt);
|
307
|
324
|
}
|
308
|
325
|
}
|
|
326
|
+ */
|
|
327
|
+
|
|
328
|
+ if (gridInsertData.size() > 0) {
|
|
329
|
+ for (int k = 0; k < gridInsertData.size(); k++) {
|
|
330
|
+ if ("C".toString().equals(saveStoreItemUnitInfolRequest.getViewCd())) {
|
|
331
|
+ gridInsertData.get(k).setContSttDt(entity.getContSttDt());
|
|
332
|
+ gridInsertData.get(k).setContEndDt(entity.getContEndDt());
|
|
333
|
+ } else {
|
|
334
|
+ gridInsertData.get(k).setContSttDt(gridInsertData.get(k).getContSttDt().replaceAll("\\.",""));
|
|
335
|
+ gridInsertData.get(k).setContEndDt(gridInsertData.get(k).getContEndDt().replaceAll("\\.",""));
|
|
336
|
+ }
|
|
337
|
+ }
|
|
338
|
+ }
|
309
|
339
|
|
310
|
|
- if (gridInsertData.size() > 0) {
|
311
|
|
- for (int k = 0; k < gridInsertData.size(); k++) {
|
312
|
340
|
|
313
|
|
- contSttDt = gridInsertData.get(k).getContSttDt().replaceAll("\\.", "");
|
314
|
|
- contEndDt = gridInsertData.get(k).getContEndDt().replaceAll("\\.", "");
|
315
|
|
- gridInsertData.get(k).setContSttDt(contSttDt);
|
316
|
|
- gridInsertData.get(k).setContEndDt(contEndDt);
|
317
|
341
|
|
318
|
|
- entity.setContSttDt(contSttDt);
|
319
|
|
- entity.setContEndDt(contEndDt);
|
|
342
|
+ // 신규일경우 계약기간 날짜 체크함
|
|
343
|
+ if ("C".toString().equals(saveStoreItemUnitInfolRequest.getViewCd())) {
|
|
344
|
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
|
|
345
|
+ Date chkenddate = formatter.parse(entity.getContEndDt());
|
|
346
|
+ Date chksttdate = formatter.parse(entity.getContSttDt());
|
|
347
|
+ int result1 = chkenddate.compareTo(chksttdate);
|
|
348
|
+ // 시작일과 종료일이 반대기간으로 되어져있을 경우
|
|
349
|
+ if (result1 < 0) {
|
|
350
|
+ throw new GlobalException(SystemMessageCode.ERR_CHGDTOPP);
|
320
|
351
|
}
|
321
|
|
- }
|
|
352
|
+
|
|
353
|
+ StoreItemUnitEntity dtEntity = storeItemUnitMapper.selectStoreItemUnitContDtInfo(entity.getBrandId(), entity.getStoreId());
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+ if (dtEntity.getContSttDt() != null && !dtEntity.getContSttDt().equals("")) {
|
|
357
|
+ // 서로 상이하면 기존 종료일자는 전송시작일보다 클경우 오류
|
322
|
358
|
|
323
|
359
|
|
324
|
|
- // 동일 단가계약일자 존재시
|
325
|
|
- String rcontEndDt = "";
|
326
|
|
- String existYn = storeItemUnitMapper.selectStoreItemUnitExistYn(entity.getBrandId(), entity.getStoreId(), entity.getContSttDt(), entity.getContEndDt());
|
|
360
|
+ // 문자열 -> Date
|
|
361
|
+ Date dtEnddate = formatter.parse(dtEntity.getContEndDt());
|
|
362
|
+ Date sttdate = formatter.parse(entity.getContSttDt());
|
|
363
|
+ int result = dtEnddate.compareTo(sttdate);
|
327
|
364
|
|
328
|
|
- if ("N".equals(existYn)) {
|
329
|
|
- rcontEndDt = storeItemUnitMapper.selectStoreItemUnitContDateInfo(entity.getBrandId(), entity.getStoreId(), entity.getContSttDt(), entity.getContEndDt());
|
330
|
|
- if (!"".equals(rcontEndDt))
|
331
|
|
- {
|
332
|
|
- storeItemUnitMapper.updateStoreItemUnitContEnd(entity.getBrandId(), entity.getStoreId(), rcontEndDt, entity.getContSttDt());
|
|
365
|
+ if (result > 0) {
|
|
366
|
+ // 진행중 단가계약이 있습니다.
|
|
367
|
+ throw new GlobalException(SystemMessageCode.ERR_EXISTUNIT);
|
|
368
|
+ }
|
333
|
369
|
}
|
334
|
370
|
}
|
335
|
371
|
|