|
@@ -5,6 +5,7 @@ import com.oqpo.api.entity.inoutmng.DeliDtlMgntEntity;
|
5
|
5
|
import com.oqpo.api.entity.inoutmng.DeliInfoMgntEntity;
|
6
|
6
|
import com.oqpo.api.entity.inoutmng.ShmtOdrBaseEntity;
|
7
|
7
|
import com.oqpo.api.entity.inoutmng.ShmtOdrDtlEntity;
|
|
8
|
+import com.oqpo.api.entity.loanmng.LoanMgntBaseInfoEntity;
|
8
|
9
|
import com.oqpo.api.entity.oper.FileEntity;
|
9
|
10
|
import com.oqpo.api.entity.pomng.PchOdrBaseInfoEntity;
|
10
|
11
|
import com.oqpo.api.entity.pomng.PchOdrDtlPtclEntity;
|
|
@@ -134,6 +135,10 @@ public class ShmtOdrService extends CommonService {
|
134
|
135
|
List<PchOdrDtlPtclEntity> gridInsertData = instShmtOdrRequest.toCodeEntities(instShmtOdrRequest.getGridInsertData());
|
135
|
136
|
List<PchOdrBaseInfoEntity> jobList = shmtOdrMapper.selectShmtJobDataList(instShmtOdrRequest.getBrandId(), gridInsertData);
|
136
|
137
|
List<StckMgntBaseInfoEntity> stockList = new ArrayList<StckMgntBaseInfoEntity>();
|
|
138
|
+
|
|
139
|
+ //여신관련하여 출하지시시 납품수량이 발주수량보다 적을 경우 사용금액을 차액만큼 원복처리를 위한 데이타
|
|
140
|
+ List<LoanMgntBaseInfoEntity> loanList = new ArrayList<LoanMgntBaseInfoEntity>();
|
|
141
|
+
|
137
|
142
|
String whsId = "";
|
138
|
143
|
String location = "";
|
139
|
144
|
String shmtWhsId = "";
|
|
@@ -170,6 +175,40 @@ public class ShmtOdrService extends CommonService {
|
170
|
175
|
throw new GlobalException(SystemMessageCode.ERR_NONEXPRY);
|
171
|
176
|
}
|
172
|
177
|
}
|
|
178
|
+
|
|
179
|
+ if (reqEntity.getShmtQty() < entity.getPchOdrDtlInfo().getPodrQty()) {
|
|
180
|
+ // 출고수량보다 발주수량클경우 구매금액을 차감 처리.
|
|
181
|
+ String loanMgntUnqNo = storeBaseInfoMapper.selectStoreLoanMgntUnqNo(entity.getStoreId());
|
|
182
|
+
|
|
183
|
+ if (loanList.size() > 0) {
|
|
184
|
+ String exchk = "N";
|
|
185
|
+ for (int la = 0 ; la < loanList.size() ; la++ ) {
|
|
186
|
+ if (loanMgntUnqNo.equals(loanList.get(la).getLoanMgntUnqNo())) {
|
|
187
|
+ long sumAmt = loanList.get(la).getUseAmtTotal();
|
|
188
|
+ sumAmt = sumAmt + ((entity.getPchOdrDtlInfo().getPodrQty() - reqEntity.getShmtQty()) * entity.getPchOdrDtlInfo().getUnitAmt());
|
|
189
|
+ loanList.get(la).setUseAmtTotal(sumAmt);
|
|
190
|
+ exchk = "Y";
|
|
191
|
+ break;
|
|
192
|
+ }
|
|
193
|
+ }
|
|
194
|
+
|
|
195
|
+ if ("N".equals(exchk)) {
|
|
196
|
+ LoanMgntBaseInfoEntity loanEntity = new LoanMgntBaseInfoEntity();
|
|
197
|
+ loanEntity.setLoanMgntUnqNo(loanMgntUnqNo);
|
|
198
|
+ loanEntity.setStoreId(entity.getStoreId());
|
|
199
|
+ loanEntity.setUseAmtTotal((entity.getPchOdrDtlInfo().getPodrQty() - reqEntity.getShmtQty()) * entity.getPchOdrDtlInfo().getUnitAmt());
|
|
200
|
+ loanList.add(loanEntity);
|
|
201
|
+ }
|
|
202
|
+ } else {
|
|
203
|
+ LoanMgntBaseInfoEntity loanEntity = new LoanMgntBaseInfoEntity();
|
|
204
|
+ loanEntity.setLoanMgntUnqNo(loanMgntUnqNo);
|
|
205
|
+ loanEntity.setStoreId(entity.getStoreId());
|
|
206
|
+ loanEntity.setUseAmtTotal((entity.getPchOdrDtlInfo().getPodrQty() - reqEntity.getShmtQty()) * entity.getPchOdrDtlInfo().getUnitAmt());
|
|
207
|
+
|
|
208
|
+ loanList.add(loanEntity);
|
|
209
|
+ }
|
|
210
|
+ }
|
|
211
|
+
|
173
|
212
|
expryDate = reqEntity.getExpryDate().replaceAll("\\.", "");
|
174
|
213
|
shmtQty = reqEntity.getShmtQty();
|
175
|
214
|
|
|
@@ -185,6 +224,7 @@ public class ShmtOdrService extends CommonService {
|
185
|
224
|
shmtBaseEntity.setShmtTotalAmt(shmtTotalAmt);
|
186
|
225
|
deliBaseEntity.setDlvAmt(shmtTotalAmt);
|
187
|
226
|
|
|
227
|
+
|
188
|
228
|
ShmtOdrDtlEntity inaddDtlEntity = new ShmtOdrDtlEntity();
|
189
|
229
|
inaddDtlEntity.setShmtReqUnqNo(shmtReqUnqNo);
|
190
|
230
|
int dtlNo = itemQty * 10;
|
|
@@ -388,6 +428,11 @@ public class ShmtOdrService extends CommonService {
|
388
|
428
|
System.out.println("============================" + stockList.size());
|
389
|
429
|
|
390
|
430
|
System.out.println("============================" + "end");
|
|
431
|
+ // 납품수량 변동발생시 처리
|
|
432
|
+ if (loanList.size() > 0) {
|
|
433
|
+ loanStateMapper.updateListLoanMinusProc(userId, loanList);
|
|
434
|
+ }
|
|
435
|
+
|
391
|
436
|
|
392
|
437
|
// 재고수량 변동 및 안전비율계산(없애기로함) 처리후 저장함함
|
393
|
438
|
stockMngMapper.updateMinStockQty(userId, stockList);
|
|
@@ -578,7 +623,7 @@ public class ShmtOdrService extends CommonService {
|
578
|
623
|
}
|
579
|
624
|
|
580
|
625
|
|
581
|
|
- /* 공급사 납품서 생성 최기 정보 */
|
|
626
|
+ /* 공급사 납품서 생성 초기 정보 */
|
582
|
627
|
public SpplyInvInitResponse selectSpplyShmtOdrInfo(String brandId, String spplyId, String pchPodrUnqNo) throws Exception {
|
583
|
628
|
PchOdrBaseInfoEntity entity = shmtOdrMapper.selectSpplyShmtOdrInfo(brandId, spplyId, pchPodrUnqNo);
|
584
|
629
|
List<PchOdrDtlPtclEntity> dtlEntity = shmtOdrMapper.selectSpplyShmtOdrList(pchPodrUnqNo);
|
|
@@ -597,13 +642,18 @@ public class ShmtOdrService extends CommonService {
|
597
|
642
|
String expryDate = "";
|
598
|
643
|
int shmtQty = 0;
|
599
|
644
|
String dlvSttmtUnqNo = "";
|
|
645
|
+ String storeId = "" ;
|
|
646
|
+ int chgLoanAmt = 0 ;
|
600
|
647
|
|
601
|
648
|
DeliInfoMgntEntity deliBaseEntity = new DeliInfoMgntEntity();
|
602
|
649
|
List<DeliDtlMgntEntity> deliDtlList = new ArrayList<DeliDtlMgntEntity>();
|
603
|
650
|
|
|
651
|
+
|
604
|
652
|
for (int i = 0; i < jobList.size(); i++) {
|
605
|
653
|
PchOdrBaseInfoEntity entity = jobList.get(i);
|
606
|
654
|
|
|
655
|
+
|
|
656
|
+
|
607
|
657
|
for (int j = 0; j < gridInsertData.size(); j++) {
|
608
|
658
|
PchOdrDtlPtclEntity reqEntity = gridInsertData.get(j);
|
609
|
659
|
if (entity.getPchPodrUnqNo().equals(reqEntity.getPchPodrUnqNo()) && entity.getPchOdrDtlInfo().getPchPodrDtlNo().equals(reqEntity.getPchPodrDtlNo())) {
|
|
@@ -618,6 +668,17 @@ public class ShmtOdrService extends CommonService {
|
618
|
668
|
throw new GlobalException(SystemMessageCode.ERR_NONEXPRY);
|
619
|
669
|
}
|
620
|
670
|
}
|
|
671
|
+
|
|
672
|
+ // 동일 납품처가 아니면 오류 처리
|
|
673
|
+ if (!"".equals(storeId) && !storeId.equals(entity.getStoreId())) {
|
|
674
|
+ throw new GlobalException(SystemMessageCode.ERR_NEQWHSID);
|
|
675
|
+ }
|
|
676
|
+
|
|
677
|
+ if (reqEntity.getShmtQty() < entity.getPchOdrDtlInfo().getPodrQty()) {
|
|
678
|
+
|
|
679
|
+ chgLoanAmt = chgLoanAmt + (entity.getPchOdrDtlInfo().getPodrQty() - reqEntity.getShmtQty()) * entity.getPchOdrDtlInfo().getUnitAmt();
|
|
680
|
+ }
|
|
681
|
+
|
621
|
682
|
expryDate = reqEntity.getExpryDate().replaceAll("\\.", "");
|
622
|
683
|
shmtQty = reqEntity.getShmtQty();
|
623
|
684
|
|
|
@@ -681,6 +742,13 @@ public class ShmtOdrService extends CommonService {
|
681
|
742
|
shmtOdrMapper.insertDeliInfoMngt(userId, deliBaseEntity);
|
682
|
743
|
shmtOdrMapper.insertDeliDtlPtcl(userId, deliDtlList);
|
683
|
744
|
|
|
745
|
+ // 변동금액 시 여신수정
|
|
746
|
+ if (chgLoanAmt > 0 ) {
|
|
747
|
+ String loanMgntUnqNo = storeBaseInfoMapper.selectStoreLoanMgntUnqNo(storeId);
|
|
748
|
+ loanStateMapper.updateloanMinusInstProc(loanMgntUnqNo, storeId, chgLoanAmt);
|
|
749
|
+ }
|
|
750
|
+
|
|
751
|
+
|
684
|
752
|
for (int poi = 0; poi < gridInsertData.size(); poi++) {
|
685
|
753
|
gridInsertData.get(poi).setPodrDtlStCd("POD3");
|
686
|
754
|
}
|
|
@@ -912,7 +980,7 @@ public class ShmtOdrService extends CommonService {
|
912
|
980
|
whsProcData.setDlvMgrMblNo(targetData.getDlvMgrMblNo());
|
913
|
981
|
whsProcData.setItemId(targetData.getDeliDtlMgntInfo().getItemId());
|
914
|
982
|
whsProcData.setItemNm(targetData.getDeliDtlMgntInfo().getItemNm());
|
915
|
|
- whsProcData.setWhsAmt(targetData.getDeliDtlMgntInfo().getUnitAmt() * whsProcData.getWhsQty());
|
|
983
|
+ whsProcData.setWhsAmt(Long.valueOf(targetData.getDeliDtlMgntInfo().getUnitAmt() * whsProcData.getWhsQty()));
|
916
|
984
|
whsProcData.setWhsDlvChrg(null);
|
917
|
985
|
//whsProcData.setDlvMgrId(targetData.getdlvmgr);
|
918
|
986
|
whsProcData.setDlvCnfmDocFileNo(whsProcData.getDlvCnfmDocFileNo());
|
|
@@ -1023,15 +1091,8 @@ public class ShmtOdrService extends CommonService {
|
1023
|
1091
|
|
1024
|
1092
|
}
|
1025
|
1093
|
|
1026
|
|
-
|
1027
|
|
-
|
1028
|
|
-
|
1029
|
1094
|
}
|
1030
|
1095
|
|
1031
|
|
-
|
1032
|
|
-
|
1033
|
|
-
|
1034
|
|
-
|
1035
|
1096
|
} catch (GlobalException e) {
|
1036
|
1097
|
//e.getStackTrace();
|
1037
|
1098
|
e.printStackTrace();
|
|
@@ -1042,6 +1103,48 @@ public class ShmtOdrService extends CommonService {
|
1042
|
1103
|
}
|
1043
|
1104
|
}
|
1044
|
1105
|
|
|
1106
|
+
|
|
1107
|
+ /*
|
|
1108
|
+ 입고 현황 그리드 리스트 조회 @Param("sBrandId") String sBrandId, @Param("sStoreId") String sStoreId,
|
|
1109
|
+ @Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("sPchPodrUnqNo") String sPchPodrUnqNo, @Param("sSpplyId") String sSpplyId, @Param("sWhsId") String sWhsId, @Param("sItemNm") String sItemNm
|
|
1110
|
+ */
|
|
1111
|
+ public GridResponse selectWarehouseGridList(String sBrandId, String sStoreId, String fromDt, String toDt, String sPchPodrUnqNo, String sSpplyId, String sWhsId, String sItemNm, GridRequest gridRequest) throws Exception {
|
|
1112
|
+ int gridPage = gridRequest.getGridPage();
|
|
1113
|
+ int gridSize = gridRequest.getGridSize();
|
|
1114
|
+
|
|
1115
|
+ fromDt = fromDt == null ? null : fromDt.replace(".", "");
|
|
1116
|
+ toDt = toDt == null ? null : toDt.replace(".", "");
|
|
1117
|
+
|
|
1118
|
+ int gridRecords = shmtOdrMapper.selectWarehouseCnt(sBrandId, sStoreId, fromDt, toDt, sPchPodrUnqNo, sSpplyId, sWhsId, sItemNm);
|
|
1119
|
+ int gridTotal = fnCalculateGridTotal(gridSize, gridRecords);
|
|
1120
|
+ List<WhsProcInfoPtclEntity> entities = shmtOdrMapper.selectWarehouseList(sBrandId, sStoreId, fromDt, toDt, sPchPodrUnqNo, sSpplyId, sWhsId, sItemNm, gridRequest);
|
|
1121
|
+ List<Object> gridRows = entities.stream()
|
|
1122
|
+ .map(m -> WarehouseSearchGridListResponse.builder()
|
|
1123
|
+ .viewCd("R")
|
|
1124
|
+ .pchPodrUnqNo(m.getPchPodrUnqNo() == null ? "" : m.getPchPodrUnqNo())
|
|
1125
|
+ .pchPodrDtlNo(m.getPchPodrDtlNo() == null ? "" : m.getPchPodrDtlNo())
|
|
1126
|
+ .dlvSttmtUnqNo(m.getDlvSttmtUnqNo() == null ? "" : m.getDlvSttmtUnqNo())
|
|
1127
|
+ .dlvSttmtDtlNo(m.getDlvSttmtDtlNo() == null ? "" : m.getDlvSttmtDtlNo() )
|
|
1128
|
+ .podrQty(m.getPodrQty() == null ? 0 : m.getPodrQty())
|
|
1129
|
+ .dlvQty(m.getDlvQty() == null ? 0 : m.getDlvQty())
|
|
1130
|
+ .whsQty(m.getWhsQty() == null ? 0 : m.getWhsQty())
|
|
1131
|
+ .dlvReqDt(m.getDlvReqDt() == null ? "" : m.getDlvReqDt())
|
|
1132
|
+ .dlvSchDt(m.getDlvSchDt() == null ? "" : m.getDlvSchDt())
|
|
1133
|
+ .dlvCmpltDt(m.getDlvCmpltDt() == null ? "" : m.getDlvCmpltDt())
|
|
1134
|
+ .whsCnfmNm(m.getWhsCnfmNm() == null ? "" : m.getWhsCnfmNm())
|
|
1135
|
+ .dlvMgrNm(m.getDlvMgrNm() == null ? "" : m.getDlvMgrNm())
|
|
1136
|
+ .dlvMgrTelNo(m.getDlvMgrTelNo() == null ? "" : m.getDlvMgrTelNo())
|
|
1137
|
+ .itemId(m.getItemId() == null ? "" : m.getItemId())
|
|
1138
|
+ .itemNm(m.getItemNm() == null ? "" : m.getItemNm())
|
|
1139
|
+ .unit(m.getUnit() == null ? "" : m.getUnit())
|
|
1140
|
+ .whsAmt(m.getWhsAmt() == null ? 0 : m.getWhsAmt())
|
|
1141
|
+ .build())
|
|
1142
|
+ .collect(Collectors.toList());
|
|
1143
|
+ return GridResponse.toDTO(gridPage, gridTotal, gridRecords, gridRows);
|
|
1144
|
+ }
|
|
1145
|
+
|
|
1146
|
+
|
|
1147
|
+
|
1045
|
1148
|
}
|
1046
|
1149
|
|
1047
|
1150
|
|