|
@@ -109,19 +109,13 @@ public class StockCddService extends CommonService {
|
109
|
109
|
int idx = 1;
|
110
|
110
|
for (StckCddMgntDtlEntity dtlEntity : dtlList) {
|
111
|
111
|
// 기존수량 조회
|
112
|
|
- StckMgntBaseInfoEntity baseInfo = stockMngMapper.selectStckMgntBaseInfo(saveStockCddRequest.getBrandId(), saveStockCddRequest.getWhsId(),
|
|
112
|
+ StckMgntBaseInfoEntity baseInfo = stockMngMapper.selectStckMgntBaseInfo4CddProc(saveStockCddRequest.getBrandId(), saveStockCddRequest.getWhsId(),
|
113
|
113
|
saveStockCddRequest.getLocation(), dtlEntity.getItemId());
|
114
|
|
-
|
115
|
|
- // 재고관리기본정보가 없는 경우
|
116
|
|
- ItemEntity itemEntity = null;
|
117
|
|
- if (baseInfo == null) {
|
118
|
|
- itemEntity = itemMapper.selectItemInfo(saveStockCddRequest.getBrandId(), dtlEntity.getItemId());
|
119
|
|
- }
|
120
|
114
|
// 재고실사상세정보 등록
|
121
|
115
|
dtlEntity.setCddId(infoEntity.getCddId());
|
122
|
116
|
dtlEntity.setCddSeq(idx);
|
123
|
|
- dtlEntity.setUnit(baseInfo == null ? itemEntity.getUnit() : baseInfo.getUnit());
|
124
|
|
- dtlEntity.setComExstQty(baseInfo == null ? 0 : baseInfo.getStckQty()); // 기존재고수량
|
|
117
|
+ dtlEntity.setUnit(baseInfo.getUnit());
|
|
118
|
+ dtlEntity.setComExstQty(baseInfo.getStckQty()); // 기존재고수량
|
125
|
119
|
dtlEntity.setChgQty(dtlEntity.getCddQty() - dtlEntity.getComExstQty()); // 변동수량 = 실사수량 - 기존재고수량
|
126
|
120
|
stockCddMapper.insertStckCddMgntDtl(userId, dtlEntity);
|
127
|
121
|
|
|
@@ -132,12 +126,14 @@ public class StockCddService extends CommonService {
|
132
|
126
|
stckEntity.setLocation(saveStockCddRequest.getLocation());
|
133
|
127
|
stckEntity.setItemId(dtlEntity.getItemId());
|
134
|
128
|
stckEntity.setStckQty(dtlEntity.getCddQty()); // 재고수량 : 실사수량
|
135
|
|
- double curStckRt = Math.round(stckEntity.getStckQty() * 100 / baseInfo.getPrpStckQty() * 100) / 100.0;
|
|
129
|
+ double curStckRt = 0;
|
|
130
|
+ if (baseInfo.getPrpStckQty() > 0) {
|
|
131
|
+ curStckRt = Math.round(stckEntity.getStckQty() * 100 / baseInfo.getPrpStckQty() * 100) / 100.0;
|
|
132
|
+ }
|
136
|
133
|
stckEntity.setCurStckRt(BigDecimal.valueOf(curStckRt)); // 현재고비율((재고수량 * 100) / 적정재고)
|
137
|
|
- if (baseInfo == null) {
|
|
134
|
+ int result = stockMngMapper.updateStckMgntBaseInfo4StckProc(userId, stckEntity);
|
|
135
|
+ if (result < 1) {
|
138
|
136
|
stockMngMapper.insertStckMgntBaseInfo(userId, stckEntity);
|
139
|
|
- } else {
|
140
|
|
- stockMngMapper.updateStckMgntBaseInfo4StckProc(userId, stckEntity);
|
141
|
137
|
}
|
142
|
138
|
|
143
|
139
|
// 재고관리상세이력(stck_mgnt_dtl_hist) 등록
|
|
@@ -148,7 +144,7 @@ public class StockCddService extends CommonService {
|
148
|
144
|
sourceHist.setWhsId(stckEntity.getWhsId());
|
149
|
145
|
sourceHist.setLocation(stckEntity.getLocation());
|
150
|
146
|
sourceHist.setItemId(stckEntity.getItemId());
|
151
|
|
- sourceHist.setItemNm(baseInfo == null ? itemEntity.getItemNm() : baseInfo.getItemNm());
|
|
147
|
+ sourceHist.setItemNm(baseInfo.getItemNm());
|
152
|
148
|
sourceHist.setInoutCd(dtlEntity.getChgQty() >= 0 ? InOutCd.IN.getCd() : InOutCd.OUT.getCd()); // 입출고구분
|
153
|
149
|
sourceHist.setInoutQty(dtlEntity.getChgQty()); // 입출고수량
|
154
|
150
|
sourceHist.setChgDvsn(ChgDvsn.STOCK_CDD.getCd()); // 재고실사
|