|
@@ -28,11 +28,9 @@ import com.oqpo.api.service.CommonService;
|
28
|
28
|
import com.oqpo.api.service.pomng.PchOrdService;
|
29
|
29
|
import com.oqpo.api.web.dto.request.GridRequest;
|
30
|
30
|
import com.oqpo.api.web.dto.request.inoutmng.InstShmtOdrRequest;
|
|
31
|
+import com.oqpo.api.web.dto.request.inoutmng.SaveSpplyDlvRequest;
|
31
|
32
|
import com.oqpo.api.web.dto.response.GridResponse;
|
32
|
|
-import com.oqpo.api.web.dto.response.inoutmng.InvInfoResponse;
|
33
|
|
-import com.oqpo.api.web.dto.response.inoutmng.ShmtOdrSearchListResponse;
|
34
|
|
-import com.oqpo.api.web.dto.response.inoutmng.ShmtOutSearchListResponse;
|
35
|
|
-import com.oqpo.api.web.dto.response.inoutmng.SpplyTargerOdrSearchListResponse;
|
|
33
|
+import com.oqpo.api.web.dto.response.inoutmng.*;
|
36
|
34
|
import com.oqpo.api.web.dto.response.pomng.pchOrd.SpplyPoOdrSearchListResponse;
|
37
|
35
|
import lombok.extern.slf4j.Slf4j;
|
38
|
36
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -568,6 +566,135 @@ public class ShmtOdrService extends CommonService {
|
568
|
566
|
.collect(Collectors.toList());
|
569
|
567
|
return GridResponse.toDTO(gridPage, gridTotal, gridRecords, gridRows);
|
570
|
568
|
}
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+ /* 공급사 납품서 생성 최기 정보 */
|
|
572
|
+ public SpplyInvInitResponse selectSpplyShmtOdrInfo(String brandId, String spplyId, String pchPodrUnqNo) throws Exception {
|
|
573
|
+ PchOdrBaseInfoEntity entity = shmtOdrMapper.selectSpplyShmtOdrInfo(brandId, spplyId, pchPodrUnqNo);
|
|
574
|
+ List<PchOdrDtlPtclEntity> dtlEntity = shmtOdrMapper.selectSpplyShmtOdrList(pchPodrUnqNo);
|
|
575
|
+
|
|
576
|
+ return SpplyInvInitResponse.toDTO(entity, dtlEntity);
|
|
577
|
+ }
|
|
578
|
+
|
|
579
|
+ /* 공급사 납품서 생성 저장 */
|
|
580
|
+ @Transactional
|
|
581
|
+ public void saveSpplyInv(String userId, SaveSpplyDlvRequest saveSpplyDlvRequest) throws Exception {
|
|
582
|
+ try {
|
|
583
|
+
|
|
584
|
+ List<PchOdrDtlPtclEntity> gridInsertData = saveSpplyDlvRequest.toCodeEntities(saveSpplyDlvRequest.getGridInsertData());
|
|
585
|
+ List<PchOdrBaseInfoEntity> jobList = shmtOdrMapper.selectShmtJobDataList(saveSpplyDlvRequest.getBrandId(), gridInsertData);
|
|
586
|
+ int shmtTotalAmt = 0;
|
|
587
|
+ String expryDate = "";
|
|
588
|
+ int shmtQty = 0;
|
|
589
|
+ String dlvSttmtUnqNo = "";
|
|
590
|
+
|
|
591
|
+ DeliInfoMgntEntity deliBaseEntity = new DeliInfoMgntEntity();
|
|
592
|
+ List<DeliDtlMgntEntity> deliDtlList = new ArrayList<DeliDtlMgntEntity>();
|
|
593
|
+
|
|
594
|
+ for (int i = 0; i < jobList.size(); i++) {
|
|
595
|
+ PchOdrBaseInfoEntity entity = jobList.get(i);
|
|
596
|
+
|
|
597
|
+ for (int j = 0; j < gridInsertData.size(); j++) {
|
|
598
|
+ PchOdrDtlPtclEntity reqEntity = gridInsertData.get(j);
|
|
599
|
+ if (entity.getPchPodrUnqNo().equals(reqEntity.getPchPodrUnqNo()) && entity.getPchOdrDtlInfo().getPchPodrDtlNo().equals(reqEntity.getPchPodrDtlNo())) {
|
|
600
|
+ if (reqEntity.getShmtQty() > entity.getPchOdrDtlInfo().getPodrQty()) {
|
|
601
|
+ // 발주수량보다 출고수량이 많을수 없습니다.
|
|
602
|
+ throw new GlobalException(SystemMessageCode.ERR_POSHNONQTY);
|
|
603
|
+ }
|
|
604
|
+
|
|
605
|
+ if ("Y".equals(entity.getPchOdrDtlInfo().getExpryYn())) {
|
|
606
|
+ if (reqEntity.getExpryDate() == null || "".equals(reqEntity.getExpryDate())) {
|
|
607
|
+ // 유통기한을 입력해주세요!
|
|
608
|
+ throw new GlobalException(SystemMessageCode.ERR_NONEXPRY);
|
|
609
|
+ }
|
|
610
|
+ }
|
|
611
|
+ expryDate = reqEntity.getExpryDate().replaceAll("\\.", "");
|
|
612
|
+ shmtQty = reqEntity.getShmtQty();
|
|
613
|
+
|
|
614
|
+ break;
|
|
615
|
+ }
|
|
616
|
+ }
|
|
617
|
+
|
|
618
|
+ shmtTotalAmt = shmtTotalAmt + (entity.getPchOdrDtlInfo().getUnitAmt() * shmtQty);
|
|
619
|
+ if (i == 0 ) {
|
|
620
|
+ dlvSttmtUnqNo = fnGetDealNo(15, ""); // 납품서번호
|
|
621
|
+ deliBaseEntity.setDlvSttmtUnqNo(dlvSttmtUnqNo);
|
|
622
|
+ deliBaseEntity.setDlvSttmtUnqNo(dlvSttmtUnqNo);
|
|
623
|
+ deliBaseEntity.setSpplyId(entity.getSpplyId());
|
|
624
|
+ deliBaseEntity.setSpplyNm(entity.getSpplyNm());
|
|
625
|
+ deliBaseEntity.setStoreId(entity.getStoreId());
|
|
626
|
+ //deliBaseEntity.setDlvAmt(shmtTotalAmt);
|
|
627
|
+ deliBaseEntity.setDlvMgrNm(saveSpplyDlvRequest.getDlvMgrNm());
|
|
628
|
+ deliBaseEntity.setDlvMgrTelNo(saveSpplyDlvRequest.getDlvMgrTelNo().replaceAll("-", ""));
|
|
629
|
+ deliBaseEntity.setDlvMgrEmal(null);
|
|
630
|
+ deliBaseEntity.setDlvMgrMblNo(null);
|
|
631
|
+ deliBaseEntity.setVndrTelNo(entity.getDeliTelNo().replaceAll("-", ""));
|
|
632
|
+ deliBaseEntity.setDlvStCd("DLV0");
|
|
633
|
+ deliBaseEntity.setPodrRegDt(entity.getPodrDt());
|
|
634
|
+ deliBaseEntity.setDlvReqDt(entity.getDlvReqDt().replaceAll("\\.", ""));
|
|
635
|
+ deliBaseEntity.setDlvSchDt(saveSpplyDlvRequest.getDlvSchDt().replaceAll("\\.", ""));
|
|
636
|
+ deliBaseEntity.setDlvCmpltDt(null);
|
|
637
|
+ deliBaseEntity.setWhsId(entity.getWhsId());
|
|
638
|
+ deliBaseEntity.setLocation(entity.getLocation());
|
|
639
|
+ if ("".equals(entity.getStoreId()) || entity.getStoreId() == null) {
|
|
640
|
+ deliBaseEntity.setWhsDvsn("W01");
|
|
641
|
+ } else {
|
|
642
|
+ deliBaseEntity.setWhsDvsn("W02");
|
|
643
|
+ }
|
|
644
|
+ deliBaseEntity.setBrandId(saveSpplyDlvRequest.getBrandId());
|
|
645
|
+ }
|
|
646
|
+
|
|
647
|
+ int dtlNo = (i+1) * 10;
|
|
648
|
+
|
|
649
|
+ DeliDtlMgntEntity inaddDeliDtlEntity = new DeliDtlMgntEntity();
|
|
650
|
+ inaddDeliDtlEntity.setDlvSttmtUnqNo(dlvSttmtUnqNo);
|
|
651
|
+ inaddDeliDtlEntity.setDlvSttmtDtlNo(Integer.toString(dtlNo));
|
|
652
|
+ inaddDeliDtlEntity.setPchPodrUnqNo(entity.getPchPodrUnqNo());
|
|
653
|
+ inaddDeliDtlEntity.setPchPodrDtlNo(entity.getPchOdrDtlInfo().getPchPodrDtlNo());
|
|
654
|
+ inaddDeliDtlEntity.setPchReqUnqNo(entity.getPchOdrDtlInfo().getPchReqUnqNo());
|
|
655
|
+ inaddDeliDtlEntity.setPchReqDtlNo(entity.getPchOdrDtlInfo().getPchReqDtlNo());
|
|
656
|
+ inaddDeliDtlEntity.setItemId(entity.getPchOdrDtlInfo().getItemId());
|
|
657
|
+ inaddDeliDtlEntity.setItemNm(entity.getPchOdrDtlInfo().getItemNm());
|
|
658
|
+ inaddDeliDtlEntity.setUnit(entity.getPchOdrDtlInfo().getUnit());
|
|
659
|
+ inaddDeliDtlEntity.setUnitAmt(entity.getPchOdrDtlInfo().getUnitAmt());
|
|
660
|
+ inaddDeliDtlEntity.setPodrQty(entity.getPchOdrDtlInfo().getPodrQty());
|
|
661
|
+ inaddDeliDtlEntity.setDlvQty(shmtQty);
|
|
662
|
+ inaddDeliDtlEntity.setPodrAmt(entity.getPchOdrDtlInfo().getPodrAmt());
|
|
663
|
+ inaddDeliDtlEntity.setDlvAmt(shmtQty * entity.getPchOdrDtlInfo().getUnitAmt());
|
|
664
|
+ inaddDeliDtlEntity.setExpryDate(expryDate);
|
|
665
|
+
|
|
666
|
+ deliDtlList.add(inaddDeliDtlEntity);
|
|
667
|
+
|
|
668
|
+ }
|
|
669
|
+
|
|
670
|
+ deliBaseEntity.setDlvAmt(shmtTotalAmt);
|
|
671
|
+ shmtOdrMapper.insertDeliInfoMngt(userId, deliBaseEntity);
|
|
672
|
+ shmtOdrMapper.insertDeliDtlPtcl(userId, deliDtlList);
|
|
673
|
+
|
|
674
|
+ for (int poi = 0; poi < gridInsertData.size(); poi++) {
|
|
675
|
+ gridInsertData.get(poi).setPodrDtlStCd("POD3");
|
|
676
|
+ }
|
|
677
|
+ pchOrdMapper.updateChangeStPodrDtl(userId, gridInsertData);
|
|
678
|
+
|
|
679
|
+ // 발주 헤더 상태 처리 updateChgMultiPodrStCd
|
|
680
|
+ String pchPodrUnqNo = "";
|
|
681
|
+ for (int k = 0; k < gridInsertData.size(); k++) {
|
|
682
|
+ if (!pchPodrUnqNo.equals(gridInsertData.get(k).getPchPodrUnqNo())) {
|
|
683
|
+ pchPodrUnqNo = gridInsertData.get(k).getPchPodrUnqNo();
|
|
684
|
+ String pchOdrStCd = pchOrdService.selectOdrDtlStatusList(pchPodrUnqNo);
|
|
685
|
+ pchOrdMapper.updateChgPodrStCd(userId, pchOdrStCd, pchPodrUnqNo);
|
|
686
|
+ }
|
|
687
|
+ }
|
|
688
|
+
|
|
689
|
+ } catch (GlobalException e) {
|
|
690
|
+ //e.getStackTrace();
|
|
691
|
+ e.printStackTrace();
|
|
692
|
+ throw new GlobalException(e.getSystemMessageCode());
|
|
693
|
+ } catch (Exception e) {
|
|
694
|
+ e.printStackTrace();
|
|
695
|
+ throw new RuntimeException();
|
|
696
|
+ }
|
|
697
|
+ }
|
571
|
698
|
}
|
572
|
699
|
|
573
|
700
|
|