|
@@ -0,0 +1,439 @@
|
|
1
|
+package com.oqpo.api.service.inoutmng;
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+import com.oqpo.api.entity.inoutmng.DeliDtlMgntEntity;
|
|
5
|
+import com.oqpo.api.entity.inoutmng.DeliInfoMgntEntity;
|
|
6
|
+import com.oqpo.api.entity.inoutmng.ShmtOdrBaseEntity;
|
|
7
|
+import com.oqpo.api.entity.inoutmng.ShmtOdrDtlEntity;
|
|
8
|
+import com.oqpo.api.entity.pomng.PchOdrBaseInfoEntity;
|
|
9
|
+import com.oqpo.api.entity.pomng.PchOdrDtlPtclEntity;
|
|
10
|
+import com.oqpo.api.entity.stockmng.StckMgntBaseInfoEntity;
|
|
11
|
+import com.oqpo.api.entity.stockmng.StckMgntDtlHistEntity;
|
|
12
|
+import com.oqpo.api.enums.ChgDvsn;
|
|
13
|
+import com.oqpo.api.enums.InOutCd;
|
|
14
|
+import com.oqpo.api.enums.SystemMessageCode;
|
|
15
|
+import com.oqpo.api.exception.GlobalException;
|
|
16
|
+import com.oqpo.api.mapper.CommonMapper;
|
|
17
|
+import com.oqpo.api.mapper.inoutmng.ShmtOdrMapper;
|
|
18
|
+import com.oqpo.api.mapper.pomng.PchOrdMapper;
|
|
19
|
+import com.oqpo.api.mapper.stockmng.StockMngMapper;
|
|
20
|
+import com.oqpo.api.service.CommonService;
|
|
21
|
+import com.oqpo.api.service.pomng.PchOrdService;
|
|
22
|
+import com.oqpo.api.web.dto.request.GridRequest;
|
|
23
|
+import com.oqpo.api.web.dto.request.inoutmng.InstShmtOdrRequest;
|
|
24
|
+import com.oqpo.api.web.dto.response.GridResponse;
|
|
25
|
+import com.oqpo.api.web.dto.response.inoutmng.ShmtOdrSearchListResponse;
|
|
26
|
+import lombok.extern.slf4j.Slf4j;
|
|
27
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
28
|
+import org.springframework.stereotype.Service;
|
|
29
|
+import org.springframework.transaction.annotation.Transactional;
|
|
30
|
+
|
|
31
|
+import java.util.ArrayList;
|
|
32
|
+import java.util.List;
|
|
33
|
+import java.util.stream.Collectors;
|
|
34
|
+
|
|
35
|
+@Service
|
|
36
|
+@Slf4j
|
|
37
|
+public class ShmtOdrService extends CommonService {
|
|
38
|
+ @Autowired
|
|
39
|
+ private ShmtOdrMapper shmtOdrMapper;
|
|
40
|
+
|
|
41
|
+ @Autowired
|
|
42
|
+ private StockMngMapper stockMngMapper;
|
|
43
|
+
|
|
44
|
+ @Autowired
|
|
45
|
+ private PchOrdMapper pchOrdMapper;
|
|
46
|
+
|
|
47
|
+ @Autowired
|
|
48
|
+ private PchOrdService pchOrdService;
|
|
49
|
+
|
|
50
|
+ @Autowired
|
|
51
|
+ private CommonMapper commonMapper;
|
|
52
|
+
|
|
53
|
+ /*
|
|
54
|
+ @Autowired
|
|
55
|
+ private UserMngMapper userMngMapper;
|
|
56
|
+
|
|
57
|
+ @Autowired
|
|
58
|
+ private StockMngMapper stockMngMapper;
|
|
59
|
+
|
|
60
|
+ @Autowired
|
|
61
|
+ private PchReqMapper pchReqMapper;
|
|
62
|
+
|
|
63
|
+ @Autowired
|
|
64
|
+ private StoreBaseInfoMapper storeBaseInfoMapper;
|
|
65
|
+
|
|
66
|
+ @Autowired
|
|
67
|
+ private LoanStateMapper loanStateMapper;
|
|
68
|
+
|
|
69
|
+*/
|
|
70
|
+ /*
|
|
71
|
+ 출하 대상 그리드 리스트 조회
|
|
72
|
+ */
|
|
73
|
+ public GridResponse selectShmtTargetOdrGridList(String sBrandId, String fromDt, String toDt, String sShmtWhsId, String sWhsId, String sItemNm, GridRequest gridRequest) throws Exception {
|
|
74
|
+ int gridPage = gridRequest.getGridPage();
|
|
75
|
+ int gridSize = gridRequest.getGridSize();
|
|
76
|
+
|
|
77
|
+ fromDt = fromDt == null ? null : fromDt.replace(".", "");
|
|
78
|
+ toDt = toDt == null ? null : toDt.replace(".", "");
|
|
79
|
+
|
|
80
|
+ int gridRecords = shmtOdrMapper.selectShmtTargetOdrGridCnt( sBrandId, fromDt, toDt, sShmtWhsId, sWhsId, sItemNm );
|
|
81
|
+ int gridTotal = fnCalculateGridTotal(gridSize, gridRecords);
|
|
82
|
+ List<PchOdrBaseInfoEntity> entities = shmtOdrMapper.selectShmtTargetOdrGridList(sBrandId, fromDt, toDt, sShmtWhsId, sWhsId, sItemNm, gridRequest);
|
|
83
|
+ List<Object> gridRows = entities.stream()
|
|
84
|
+ .map(m -> ShmtOdrSearchListResponse.builder()
|
|
85
|
+ .viewCd("R")
|
|
86
|
+ .brandId(m.getBrandId() == null ? "" : m.getBrandId())
|
|
87
|
+ .brandNm(m.getBrandNm() == null ? "" : m.getBrandNm())
|
|
88
|
+ .pchPodrUnqNo(m.getPchPodrUnqNo() == null ? "" : m.getPchPodrUnqNo())
|
|
89
|
+ .pchPodrDtlNo(m.getPchOdrDtlInfo() == null ? "" : m.getPchOdrDtlInfo().getPchPodrDtlNo() == null ? "" : m.getPchOdrDtlInfo().getPchPodrDtlNo() )
|
|
90
|
+ .itemId(m.getPchOdrDtlInfo() == null ? "" : m.getPchOdrDtlInfo().getItemId() == null ? "" : m.getPchOdrDtlInfo().getItemId())
|
|
91
|
+ .itemNm(m.getPchOdrDtlInfo() == null ? "" : m.getPchOdrDtlInfo().getItemNm() == null ? "" : m.getPchOdrDtlInfo().getItemNm())
|
|
92
|
+ .whsId(m.getWhsId() == null ? "" : m.getWhsId())
|
|
93
|
+ .whsNm(m.getWhsNm() == null ? "" : m.getWhsNm() + " - " + m.getLocationNm())
|
|
94
|
+ .location(m.getLocation() == null ? "" : m.getLocation())
|
|
95
|
+ .unitAmt(m.getPchOdrDtlInfo() == null ? 0 : m.getPchOdrDtlInfo().getUnitAmt() == null ? 0 : m.getPchOdrDtlInfo().getUnitAmt())
|
|
96
|
+ .podrQty(m.getPchOdrDtlInfo() == null ? 0 : m.getPchOdrDtlInfo().getPodrQty() == null ? 0 : m.getPchOdrDtlInfo().getPodrQty())
|
|
97
|
+ .shmtQty(m.getPchOdrDtlInfo() == null ? 0 : m.getPchOdrDtlInfo().getShmtQty() == null ? 0 : m.getPchOdrDtlInfo().getShmtQty())
|
|
98
|
+ .stckQty(m.getPchOdrDtlInfo() == null ? 0 : m.getPchOdrDtlInfo().getStckQty() == null ? 0 : m.getPchOdrDtlInfo().getStckQty())
|
|
99
|
+ .expryYn(m.getPchOdrDtlInfo() == null ? "" : m.getPchOdrDtlInfo().getExpryYn() == null ? "" : m.getPchOdrDtlInfo().getExpryYn() )
|
|
100
|
+ .expryPeriod(m.getPchOdrDtlInfo() == null ? 0 : m.getPchOdrDtlInfo().getExpryPeriod() == null ? 0 : m.getPchOdrDtlInfo().getExpryPeriod())
|
|
101
|
+ .expryDate(m.getPchOdrDtlInfo() == null ? "" : m.getPchOdrDtlInfo().getExpryDate() == null ? "" : m.getPchOdrDtlInfo().getExpryDate())
|
|
102
|
+ .podrAmt(m.getPchOdrDtlInfo() == null ? 0 : m.getPchOdrDtlInfo().getPodrAmt() == null ? 0 : m.getPchOdrDtlInfo().getPodrAmt())
|
|
103
|
+ .dlvReqDt(m.getDlvReqDt() == null ? "" : m.getDlvReqDt())
|
|
104
|
+ .shmtWhsId(m.getShmtWhsId() == null ? "" : m.getShmtWhsId())
|
|
105
|
+ .shmtLocation(m.getShmtLocation() == null ? "" : m.getShmtLocation())
|
|
106
|
+ .shmtWhsNm(m.getShmtWhsNm() == null ? "" : m.getShmtWhsNm() + " - " + m.getShmtLocationNm())
|
|
107
|
+ .build())
|
|
108
|
+ .collect(Collectors.toList());
|
|
109
|
+ return GridResponse.toDTO(gridPage, gridTotal, gridRecords, gridRows);
|
|
110
|
+ }
|
|
111
|
+
|
|
112
|
+ /*
|
|
113
|
+ 출하지시 저장
|
|
114
|
+ */
|
|
115
|
+ @Transactional
|
|
116
|
+ public void instShmtOdr(String userId, InstShmtOdrRequest instShmtOdrRequest) throws Exception {
|
|
117
|
+ try {
|
|
118
|
+ // 출하창고 + 납품장소 동일여부 체크
|
|
119
|
+ // 출하창고의 재고 와 출하수량 비교처리
|
|
120
|
+ // 발주수량은 출하수량보다 크거나 같아야함
|
|
121
|
+ // 유통기한 품목에 대해서는 유통기한일자 기입 필수
|
|
122
|
+
|
|
123
|
+ // 출하 헤더 생성
|
|
124
|
+ // 출하 상세 생성
|
|
125
|
+ // 납품서 헤더 생성
|
|
126
|
+ // 납품서 상세 생성성
|
|
127
|
+ List<PchOdrDtlPtclEntity> gridInsertData = instShmtOdrRequest.toCodeEntities(instShmtOdrRequest.getGridInsertData());
|
|
128
|
+ List<PchOdrBaseInfoEntity> jobList = shmtOdrMapper.selectShmtJobDataList(instShmtOdrRequest.getBrandId(), gridInsertData) ;
|
|
129
|
+ List<StckMgntBaseInfoEntity> stockList = new ArrayList<StckMgntBaseInfoEntity>();
|
|
130
|
+ String whsId = "";
|
|
131
|
+ String location = "";
|
|
132
|
+ String shmtWhsId = "";
|
|
133
|
+ String shmtLocation = "";
|
|
134
|
+ int itemQty = 0 ;
|
|
135
|
+ int shmtTotalAmt = 0 ;
|
|
136
|
+ String expryDate = "";
|
|
137
|
+ int shmtQty = 0 ;
|
|
138
|
+ String shmtReqUnqNo = "";
|
|
139
|
+ String dlvSttmtUnqNo = "";
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+ ShmtOdrBaseEntity shmtBaseEntity = new ShmtOdrBaseEntity();
|
|
143
|
+ List<ShmtOdrDtlEntity> shmtDtlList = new ArrayList<ShmtOdrDtlEntity>() ;
|
|
144
|
+
|
|
145
|
+ DeliInfoMgntEntity deliBaseEntity = new DeliInfoMgntEntity();
|
|
146
|
+ List<DeliDtlMgntEntity> deliDtlList = new ArrayList<DeliDtlMgntEntity>() ;
|
|
147
|
+
|
|
148
|
+ for (int i = 0 ; i < jobList.size() ; i++) {
|
|
149
|
+ PchOdrBaseInfoEntity entity = jobList.get(i);
|
|
150
|
+
|
|
151
|
+ for (int j = 0 ; j < gridInsertData.size() ; j++) {
|
|
152
|
+ PchOdrDtlPtclEntity reqEntity = gridInsertData.get(j);
|
|
153
|
+
|
|
154
|
+ if (entity.getPchPodrUnqNo().equals(reqEntity.getPchPodrUnqNo()) && entity.getPchOdrDtlInfo().getPchPodrDtlNo().equals(reqEntity.getPchPodrDtlNo()))
|
|
155
|
+ {
|
|
156
|
+ if (reqEntity.getShmtQty() > entity.getPchOdrDtlInfo().getPodrQty()) {
|
|
157
|
+ // 발주수량보다 출고수량이 많을수 없습니다.
|
|
158
|
+ throw new GlobalException(SystemMessageCode.ERR_POSHNONQTY);
|
|
159
|
+ }
|
|
160
|
+
|
|
161
|
+ if ("Y".equals(entity.getPchOdrDtlInfo().getExpryYn())) {
|
|
162
|
+ if (reqEntity.getExpryDate() == null || "".equals(reqEntity.getExpryDate())) {
|
|
163
|
+ // 유통기한을 입력해주세요!
|
|
164
|
+ throw new GlobalException(SystemMessageCode.ERR_NONEXPRY);
|
|
165
|
+ }
|
|
166
|
+ }
|
|
167
|
+ expryDate = reqEntity.getExpryDate().replaceAll("\\.","");
|
|
168
|
+ shmtQty = reqEntity.getShmtQty();
|
|
169
|
+
|
|
170
|
+ break;
|
|
171
|
+ }
|
|
172
|
+ }
|
|
173
|
+
|
|
174
|
+ if (shmtWhsId.equals(entity.getShmtWhsId()) && shmtLocation.equals(entity.getShmtLocation()) && whsId.equals(entity.getWhsId()) && location.equals(entity.getLocation())) {
|
|
175
|
+ // 추가 작업
|
|
176
|
+ itemQty = itemQty + 1 ;
|
|
177
|
+ shmtTotalAmt = shmtTotalAmt + (entity.getPchOdrDtlInfo().getUnitAmt() * shmtQty);
|
|
178
|
+ shmtBaseEntity.setItemQty(itemQty);
|
|
179
|
+ shmtBaseEntity.setShmtTotalAmt(shmtTotalAmt);
|
|
180
|
+ deliBaseEntity.setDlvAmt(shmtTotalAmt);
|
|
181
|
+
|
|
182
|
+ ShmtOdrDtlEntity inaddDtlEntity = new ShmtOdrDtlEntity();
|
|
183
|
+ inaddDtlEntity.setShmtReqUnqNo(shmtReqUnqNo);
|
|
184
|
+ int dtlNo = itemQty * 10 ;
|
|
185
|
+ inaddDtlEntity.setShmtReqDtlNo( Integer.toString(dtlNo));
|
|
186
|
+ inaddDtlEntity.setItemId(entity.getPchOdrDtlInfo().getItemId());
|
|
187
|
+ inaddDtlEntity.setItemNm(entity.getPchOdrDtlInfo().getItemNm());
|
|
188
|
+ inaddDtlEntity.setUnitAmt(entity.getPchOdrDtlInfo().getUnitAmt());
|
|
189
|
+ inaddDtlEntity.setUnit(entity.getPchOdrDtlInfo().getUnit());
|
|
190
|
+ inaddDtlEntity.setPodrQty(entity.getPchOdrDtlInfo().getPodrQty());
|
|
191
|
+ inaddDtlEntity.setPodrAmt(entity.getPchOdrDtlInfo().getPodrAmt());
|
|
192
|
+ inaddDtlEntity.setShmtQty(shmtQty);
|
|
193
|
+ inaddDtlEntity.setShmtAmt(shmtQty * entity.getPchOdrDtlInfo().getUnitAmt());
|
|
194
|
+ inaddDtlEntity.setExpryDate(expryDate);
|
|
195
|
+ inaddDtlEntity.setPchPodrUnqNo(entity.getPchPodrUnqNo());
|
|
196
|
+ inaddDtlEntity.setPchPodrDtlNo(entity.getPchOdrDtlInfo().getPchPodrDtlNo());
|
|
197
|
+ inaddDtlEntity.setPchReqUnqNo(entity.getPchOdrDtlInfo().getPchReqUnqNo());
|
|
198
|
+ inaddDtlEntity.setPchReqDtlNo(entity.getPchOdrDtlInfo().getPchReqDtlNo());
|
|
199
|
+
|
|
200
|
+ shmtDtlList.add(inaddDtlEntity);
|
|
201
|
+
|
|
202
|
+ //재고 수량정보 기입
|
|
203
|
+ StckMgntBaseInfoEntity stckEntity = new StckMgntBaseInfoEntity();
|
|
204
|
+ /*
|
|
205
|
+ String dupYn = "N";
|
|
206
|
+ for (int ski = 0 ; ski < stockList.size() ; ski++) {
|
|
207
|
+ StckMgntBaseInfoEntity tmpEntity = stockList.get(ski);
|
|
208
|
+ if (entity.getBrandId().equals(tmpEntity.getBrandId()) && entity.getShmtWhsId().equals(tmpEntity.getWhsId())
|
|
209
|
+ && entity.getShmtLocation().equals(tmpEntity.getLocation()) && entity.getPchOdrDtlInfo().getItemId().equals(tmpEntity.getItemId())) {
|
|
210
|
+ int tmpStckQty = tmpEntity.getStckQty() ;
|
|
211
|
+ stockList.get(ski).setStckQty(tmpStckQty + shmtQty);
|
|
212
|
+ dupYn = "Y";
|
|
213
|
+ System.out.println("for============================" + Integer.toString(ski) + stockList.get(ski).getStckQty());
|
|
214
|
+ break;
|
|
215
|
+ }
|
|
216
|
+ }
|
|
217
|
+ if ("N".equals(dupYn)) {
|
|
218
|
+ */
|
|
219
|
+ stckEntity.setBrandId(entity.getBrandId());
|
|
220
|
+ stckEntity.setWhsId(entity.getShmtWhsId());
|
|
221
|
+ stckEntity.setLocation(entity.getShmtLocation());
|
|
222
|
+ stckEntity.setItemId(entity.getPchOdrDtlInfo().getItemId());
|
|
223
|
+ stckEntity.setStckQty(shmtQty);
|
|
224
|
+ stckEntity.setRelationNo(shmtReqUnqNo);
|
|
225
|
+ stockList.add(stckEntity);
|
|
226
|
+ // }
|
|
227
|
+
|
|
228
|
+ //납품서 상세 생성
|
|
229
|
+ DeliDtlMgntEntity inaddDeliDtlEntity = new DeliDtlMgntEntity();
|
|
230
|
+ inaddDeliDtlEntity.setDlvSttmtUnqNo(dlvSttmtUnqNo);
|
|
231
|
+ inaddDeliDtlEntity.setDlvSttmtDtlNo(Integer.toString(dtlNo));
|
|
232
|
+ inaddDeliDtlEntity.setPchPodrUnqNo(entity.getPchPodrUnqNo());
|
|
233
|
+ inaddDeliDtlEntity.setPchPodrDtlNo(entity.getPchOdrDtlInfo().getPchPodrDtlNo());
|
|
234
|
+ inaddDeliDtlEntity.setPchReqUnqNo(entity.getPchOdrDtlInfo().getPchReqUnqNo());
|
|
235
|
+ inaddDeliDtlEntity.setPchReqDtlNo(entity.getPchOdrDtlInfo().getPchReqDtlNo());
|
|
236
|
+ inaddDeliDtlEntity.setItemId(entity.getPchOdrDtlInfo().getItemId());
|
|
237
|
+ inaddDeliDtlEntity.setItemNm(entity.getPchOdrDtlInfo().getItemNm());
|
|
238
|
+ inaddDeliDtlEntity.setUnit(entity.getPchOdrDtlInfo().getUnit());
|
|
239
|
+ inaddDeliDtlEntity.setUnitAmt(entity.getPchOdrDtlInfo().getUnitAmt());
|
|
240
|
+ inaddDeliDtlEntity.setPodrQty(entity.getPchOdrDtlInfo().getPodrQty());
|
|
241
|
+ inaddDeliDtlEntity.setDlvQty(shmtQty);
|
|
242
|
+ inaddDeliDtlEntity.setPodrAmt(entity.getPchOdrDtlInfo().getPodrAmt());
|
|
243
|
+ inaddDeliDtlEntity.setDlvAmt(shmtQty * entity.getPchOdrDtlInfo().getUnitAmt());
|
|
244
|
+ inaddDeliDtlEntity.setExpryDate(expryDate);
|
|
245
|
+
|
|
246
|
+ deliDtlList.add(inaddDeliDtlEntity);
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+ } else {
|
|
250
|
+ // 신규로 출하건 생성함 //select fn_get_dealno(16, '') as col_cmd_unq_no
|
|
251
|
+ if (shmtDtlList.size() > 0) {
|
|
252
|
+ shmtOdrMapper.insertShmtOdrBase(userId,shmtBaseEntity );
|
|
253
|
+ shmtOdrMapper.insertShmtOdrDtl(userId, shmtDtlList) ;
|
|
254
|
+
|
|
255
|
+ shmtOdrMapper.insertDeliInfoMngt(userId,deliBaseEntity );
|
|
256
|
+ shmtOdrMapper.insertDeliDtlPtcl(userId, deliDtlList) ;
|
|
257
|
+ itemQty = 0 ;
|
|
258
|
+ shmtTotalAmt = 0 ;
|
|
259
|
+ }
|
|
260
|
+ itemQty = 1 ;
|
|
261
|
+ shmtTotalAmt = entity.getPchOdrDtlInfo().getUnitAmt() * shmtQty;
|
|
262
|
+
|
|
263
|
+ whsId = entity.getWhsId();
|
|
264
|
+ location = entity.getLocation();
|
|
265
|
+ shmtWhsId = entity.getShmtWhsId();
|
|
266
|
+ shmtLocation = entity.getShmtLocation();
|
|
267
|
+
|
|
268
|
+ shmtReqUnqNo = fnGetDealNo(16,""); // 출하지시번호
|
|
269
|
+ dlvSttmtUnqNo = fnGetDealNo(15,""); // 납품서번호
|
|
270
|
+
|
|
271
|
+ // 출하지시
|
|
272
|
+ shmtBaseEntity = new ShmtOdrBaseEntity();
|
|
273
|
+ shmtDtlList = new ArrayList<ShmtOdrDtlEntity>() ;
|
|
274
|
+ ShmtOdrDtlEntity inDtlEntity = new ShmtOdrDtlEntity();
|
|
275
|
+
|
|
276
|
+ //납품서정보
|
|
277
|
+ deliBaseEntity = new DeliInfoMgntEntity();
|
|
278
|
+ deliDtlList = new ArrayList<DeliDtlMgntEntity>() ;
|
|
279
|
+ DeliDtlMgntEntity deliDtlEntity = new DeliDtlMgntEntity();
|
|
280
|
+
|
|
281
|
+ shmtBaseEntity.setShmtReqUnqNo(shmtReqUnqNo);
|
|
282
|
+ shmtBaseEntity.setShmtReqStCd("SHM1");
|
|
283
|
+ shmtBaseEntity.setShmtWhsId(entity.getShmtWhsId());
|
|
284
|
+ shmtBaseEntity.setShmtLocation(entity.getShmtLocation());
|
|
285
|
+ shmtBaseEntity.setWhsDvsn("W01");
|
|
286
|
+ shmtBaseEntity.setBrandId(entity.getBrandId());
|
|
287
|
+ shmtBaseEntity.setStoreId(entity.getStoreId());
|
|
288
|
+ shmtBaseEntity.setPodrDvsn("OD01");
|
|
289
|
+ shmtBaseEntity.setItemQty(itemQty);
|
|
290
|
+ shmtBaseEntity.setShmtTotalAmt(shmtTotalAmt);
|
|
291
|
+ shmtBaseEntity.setPodrMgrNm(entity.getPodrMgrNm());
|
|
292
|
+ shmtBaseEntity.setDlvReqDt(entity.getDlvReqDt().replaceAll("\\.",""));
|
|
293
|
+ shmtBaseEntity.setWhsId(entity.getWhsId());
|
|
294
|
+ shmtBaseEntity.setLocation(entity.getLocation());
|
|
295
|
+
|
|
296
|
+ //납품서 데이타 생성
|
|
297
|
+ deliBaseEntity.setDlvSttmtUnqNo(dlvSttmtUnqNo);
|
|
298
|
+ deliBaseEntity.setSpplyId(null);
|
|
299
|
+ deliBaseEntity.setSpplyNm(null);
|
|
300
|
+ //deliBaseEntity.setDlvRegDt();
|
|
301
|
+ deliBaseEntity.setDlvAmt(shmtTotalAmt);
|
|
302
|
+ deliBaseEntity.setDlvMgrNm(instShmtOdrRequest.getDlvMgrNm());
|
|
303
|
+ deliBaseEntity.setDlvMgrTelNo(instShmtOdrRequest.getDlvMgrTelNo().replaceAll("-",""));
|
|
304
|
+ deliBaseEntity.setDlvMgrEmal(null);
|
|
305
|
+ deliBaseEntity.setDlvMgrMblNo(null);
|
|
306
|
+ deliBaseEntity.setVndrTelNo(entity.getDeliTelNo().replaceAll("-",""));
|
|
307
|
+ deliBaseEntity.setDlvStCd("DLV0");
|
|
308
|
+ deliBaseEntity.setPodrRegDt(entity.getPodrDt());
|
|
309
|
+ deliBaseEntity.setDlvReqDt(entity.getDlvReqDt().replaceAll("\\.",""));
|
|
310
|
+ deliBaseEntity.setDlvSchDt(instShmtOdrRequest.getDlvSchDt().replaceAll("\\.",""));
|
|
311
|
+ deliBaseEntity.setDlvCmpltDt(null);
|
|
312
|
+ deliBaseEntity.setWhsId(entity.getWhsId());
|
|
313
|
+ deliBaseEntity.setLocation(entity.getLocation());
|
|
314
|
+ deliBaseEntity.setWhsDvsn("W01");
|
|
315
|
+ deliBaseEntity.setBrandId(instShmtOdrRequest.getBrandId());
|
|
316
|
+
|
|
317
|
+ //출하지시 상세 생성
|
|
318
|
+ ShmtOdrDtlEntity inaddDtlEntity = new ShmtOdrDtlEntity();
|
|
319
|
+ inaddDtlEntity.setShmtReqUnqNo(shmtReqUnqNo);
|
|
320
|
+ inaddDtlEntity.setShmtReqDtlNo("10");
|
|
321
|
+ inaddDtlEntity.setItemId(entity.getPchOdrDtlInfo().getItemId());
|
|
322
|
+ inaddDtlEntity.setItemNm(entity.getPchOdrDtlInfo().getItemNm());
|
|
323
|
+ inaddDtlEntity.setUnitAmt(entity.getPchOdrDtlInfo().getUnitAmt());
|
|
324
|
+ inaddDtlEntity.setUnit(entity.getPchOdrDtlInfo().getUnit());
|
|
325
|
+ inaddDtlEntity.setPodrQty(entity.getPchOdrDtlInfo().getPodrQty());
|
|
326
|
+ inaddDtlEntity.setPodrAmt(entity.getPchOdrDtlInfo().getPodrAmt());
|
|
327
|
+ inaddDtlEntity.setShmtQty(shmtQty);
|
|
328
|
+ inaddDtlEntity.setShmtAmt(shmtQty * entity.getPchOdrDtlInfo().getUnitAmt());
|
|
329
|
+ inaddDtlEntity.setExpryDate(expryDate);
|
|
330
|
+ inaddDtlEntity.setPchPodrUnqNo(entity.getPchPodrUnqNo());
|
|
331
|
+ inaddDtlEntity.setPchPodrDtlNo(entity.getPchOdrDtlInfo().getPchPodrDtlNo());
|
|
332
|
+ inaddDtlEntity.setPchReqUnqNo(entity.getPchOdrDtlInfo().getPchReqUnqNo());
|
|
333
|
+ inaddDtlEntity.setPchReqDtlNo(entity.getPchOdrDtlInfo().getPchReqDtlNo());
|
|
334
|
+
|
|
335
|
+ shmtDtlList.add(inaddDtlEntity);
|
|
336
|
+
|
|
337
|
+ StckMgntBaseInfoEntity stckEntity = new StckMgntBaseInfoEntity();
|
|
338
|
+ stckEntity.setBrandId(entity.getBrandId());
|
|
339
|
+ stckEntity.setWhsId(entity.getShmtWhsId());
|
|
340
|
+ stckEntity.setLocation(entity.getShmtLocation());
|
|
341
|
+ stckEntity.setItemId(entity.getPchOdrDtlInfo().getItemId());
|
|
342
|
+ stckEntity.setStckQty(shmtQty);
|
|
343
|
+ stckEntity.setRelationNo(shmtReqUnqNo);
|
|
344
|
+ stockList.add(stckEntity);
|
|
345
|
+
|
|
346
|
+ //납품서 상세 생성
|
|
347
|
+ DeliDtlMgntEntity inaddDeliDtlEntity = new DeliDtlMgntEntity();
|
|
348
|
+ inaddDeliDtlEntity.setDlvSttmtUnqNo(dlvSttmtUnqNo);
|
|
349
|
+ inaddDeliDtlEntity.setDlvSttmtDtlNo("10");
|
|
350
|
+ inaddDeliDtlEntity.setPchPodrUnqNo(entity.getPchPodrUnqNo());
|
|
351
|
+ inaddDeliDtlEntity.setPchPodrDtlNo(entity.getPchOdrDtlInfo().getPchPodrDtlNo());
|
|
352
|
+ inaddDeliDtlEntity.setPchReqUnqNo(entity.getPchOdrDtlInfo().getPchReqUnqNo());
|
|
353
|
+ inaddDeliDtlEntity.setPchReqDtlNo(entity.getPchOdrDtlInfo().getPchReqDtlNo());
|
|
354
|
+ inaddDeliDtlEntity.setItemId(entity.getPchOdrDtlInfo().getItemId());
|
|
355
|
+ inaddDeliDtlEntity.setItemNm(entity.getPchOdrDtlInfo().getItemNm());
|
|
356
|
+ inaddDeliDtlEntity.setUnit(entity.getPchOdrDtlInfo().getUnit());
|
|
357
|
+ inaddDeliDtlEntity.setUnitAmt(entity.getPchOdrDtlInfo().getUnitAmt());
|
|
358
|
+ inaddDeliDtlEntity.setPodrQty(entity.getPchOdrDtlInfo().getPodrQty());
|
|
359
|
+ inaddDeliDtlEntity.setDlvQty(shmtQty);
|
|
360
|
+ inaddDeliDtlEntity.setPodrAmt(entity.getPchOdrDtlInfo().getPodrAmt());
|
|
361
|
+ inaddDeliDtlEntity.setDlvAmt(shmtQty * entity.getPchOdrDtlInfo().getUnitAmt());
|
|
362
|
+ inaddDeliDtlEntity.setExpryDate(expryDate);
|
|
363
|
+
|
|
364
|
+ deliDtlList.add(inaddDeliDtlEntity);
|
|
365
|
+
|
|
366
|
+ }
|
|
367
|
+
|
|
368
|
+ // 마지막 부분일 경우
|
|
369
|
+ if (i == jobList.size()-1) {
|
|
370
|
+ if (shmtDtlList.size() > 0) {
|
|
371
|
+ shmtOdrMapper.insertShmtOdrBase(userId,shmtBaseEntity );
|
|
372
|
+ shmtOdrMapper.insertShmtOdrDtl(userId, shmtDtlList) ;
|
|
373
|
+ shmtOdrMapper.insertDeliInfoMngt(userId,deliBaseEntity );
|
|
374
|
+ shmtOdrMapper.insertDeliDtlPtcl(userId, deliDtlList) ;
|
|
375
|
+ }
|
|
376
|
+ }
|
|
377
|
+
|
|
378
|
+ System.out.println("============================" + stockList.size());
|
|
379
|
+
|
|
380
|
+ System.out.println("============================" + "end");
|
|
381
|
+
|
|
382
|
+ // 재고수량 변동 및 안전비율계산(없애기로함) 처리후 저장함함
|
|
383
|
+ stockMngMapper.updateMinStockQty(userId,stockList );
|
|
384
|
+ //재고 이력 테이블에 데이타 생성 insertMultiStckMgntDtlHist
|
|
385
|
+ List<StckMgntDtlHistEntity> stockHistList = new ArrayList<StckMgntDtlHistEntity>();
|
|
386
|
+ for ( int m = 0 ; m < stockList.size() ; m++) {
|
|
387
|
+ StckMgntBaseInfoEntity baseEntity = stockList.get(m);
|
|
388
|
+ StckMgntDtlHistEntity sourceHist = new StckMgntDtlHistEntity();
|
|
389
|
+ //String stckMgntDtlNo = fnGetDealNo(32,"");
|
|
390
|
+ String stckMgntDtlNo = commonMapper.selectDealNo(32, "");
|
|
391
|
+ //String stckMgntDtlNo1 = commonMapper.selectDealNo(33, "");
|
|
392
|
+
|
|
393
|
+ sourceHist.setStckMgntDtlNo(stckMgntDtlNo); // 재고관리상세번호
|
|
394
|
+ // System.out.println("seqno =========>" +sourceHist.getStckMgntDtlNo() + "===" + stckMgntDtlNo + "==" + stckMgntDtlNo1);
|
|
395
|
+ sourceHist.setBrandId(baseEntity.getBrandId());
|
|
396
|
+ sourceHist.setWhsId(baseEntity.getWhsId());
|
|
397
|
+ sourceHist.setLocation(baseEntity.getLocation());
|
|
398
|
+ sourceHist.setItemId(baseEntity.getItemId());
|
|
399
|
+ sourceHist.setItemNm(baseEntity.getItemNm());
|
|
400
|
+ sourceHist.setInoutCd(InOutCd.OUT.getCd()); // 출고
|
|
401
|
+ sourceHist.setInoutQty(baseEntity.getStckQty());
|
|
402
|
+ sourceHist.setChgDvsn(ChgDvsn.PURCHASE_OUT.getCd()); // 구매출고
|
|
403
|
+ sourceHist.setRelationNo(baseEntity.getRelationNo());
|
|
404
|
+ stockHistList.add(sourceHist);
|
|
405
|
+ }
|
|
406
|
+ stockMngMapper.insertMultiStckMgntDtlHist(userId, stockHistList);
|
|
407
|
+
|
|
408
|
+ // 발주상태 변경처리
|
|
409
|
+ // 1. 발주상세정보 상태 없데이트 한후 pchOrdMapper
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+ for (int poi = 0 ; poi < gridInsertData.size() ; poi++) {
|
|
413
|
+ gridInsertData.get(poi).setPodrDtlStCd("POD3");
|
|
414
|
+ }
|
|
415
|
+ pchOrdMapper.updateChangeStPodrDtl(userId,gridInsertData );
|
|
416
|
+
|
|
417
|
+ // 발주 헤더 상태 처리 updateChgMultiPodrStCd
|
|
418
|
+ String pchPodrUnqNo = "";
|
|
419
|
+ for (int k = 0 ; k < gridInsertData.size() ; k++) {
|
|
420
|
+ if (!pchPodrUnqNo.equals(gridInsertData.get(k).getPchPodrUnqNo())) {
|
|
421
|
+ pchPodrUnqNo = gridInsertData.get(k).getPchPodrUnqNo();
|
|
422
|
+ String pchOdrStCd = pchOrdService.selectOdrDtlStatusList(pchPodrUnqNo);
|
|
423
|
+ pchOrdMapper.updateChgPodrStCd(userId, pchOdrStCd, pchPodrUnqNo );
|
|
424
|
+ }
|
|
425
|
+ }
|
|
426
|
+ }
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+ } catch (GlobalException e) {
|
|
430
|
+ //e.getStackTrace();
|
|
431
|
+ e.printStackTrace();
|
|
432
|
+ throw new GlobalException(e.getSystemMessageCode());
|
|
433
|
+ } catch (Exception e) {
|
|
434
|
+ e.printStackTrace();
|
|
435
|
+ throw new RuntimeException();
|
|
436
|
+ }
|
|
437
|
+ }
|
|
438
|
+
|
|
439
|
+}
|