|
@@ -3,6 +3,7 @@ package com.oqpo.api.service.stockmng;
|
3
|
3
|
|
4
|
4
|
import com.oqpo.api.entity.oper.FileEntity;
|
5
|
5
|
import com.oqpo.api.entity.stinfo.BrandEntity;
|
|
6
|
+import com.oqpo.api.entity.stinfo.ItemEntity;
|
6
|
7
|
import com.oqpo.api.entity.stockmng.StckCddMgntDtlEntity;
|
7
|
8
|
import com.oqpo.api.entity.stockmng.StckCddMgntInfoEntity;
|
8
|
9
|
import com.oqpo.api.entity.stockmng.StckMgntBaseInfoEntity;
|
|
@@ -11,6 +12,7 @@ import com.oqpo.api.enums.ChgDvsn;
|
11
|
12
|
import com.oqpo.api.enums.InOutCd;
|
12
|
13
|
import com.oqpo.api.exception.GlobalException;
|
13
|
14
|
import com.oqpo.api.mapper.CommonMapper;
|
|
15
|
+import com.oqpo.api.mapper.stinfo.ItemMapper;
|
14
|
16
|
import com.oqpo.api.mapper.stockmng.StockCddMapper;
|
15
|
17
|
import com.oqpo.api.mapper.stockmng.StockMngMapper;
|
16
|
18
|
import com.oqpo.api.service.CommonService;
|
|
@@ -44,6 +46,9 @@ public class StockCddService extends CommonService {
|
44
|
46
|
@Autowired
|
45
|
47
|
private StockMngMapper stockMngMapper;
|
46
|
48
|
|
|
49
|
+ @Autowired
|
|
50
|
+ private ItemMapper itemMapper;
|
|
51
|
+
|
47
|
52
|
/*
|
48
|
53
|
재고실사 그리드 리스트 조회
|
49
|
54
|
*/
|
|
@@ -107,12 +112,17 @@ public class StockCddService extends CommonService {
|
107
|
112
|
StckMgntBaseInfoEntity baseInfo = stockMngMapper.selectStckMgntBaseInfo(saveStockCddRequest.getBrandId(), saveStockCddRequest.getWhsId(),
|
108
|
113
|
saveStockCddRequest.getLocation(), dtlEntity.getItemId());
|
109
|
114
|
|
|
115
|
+ // 재고관리기본정보가 없는 경우
|
|
116
|
+ ItemEntity itemEntity = null;
|
|
117
|
+ if (baseInfo == null) {
|
|
118
|
+ itemEntity = itemMapper.selectItemInfo(saveStockCddRequest.getBrandId(), dtlEntity.getItemId());
|
|
119
|
+ }
|
110
|
120
|
// 재고실사상세정보 등록
|
111
|
121
|
dtlEntity.setCddId(infoEntity.getCddId());
|
112
|
122
|
dtlEntity.setCddSeq(idx);
|
113
|
|
- dtlEntity.setUnit(baseInfo.getUnit());
|
114
|
|
- dtlEntity.setComExstQty(baseInfo.getStckQty()); // 기존재고수량
|
115
|
|
- dtlEntity.setChgQty(dtlEntity.getCddQty() - baseInfo.getStckQty()); // 변동수량 = 실사수량 - 기존재고수량
|
|
123
|
+ dtlEntity.setUnit(baseInfo == null ? itemEntity.getUnit() : baseInfo.getUnit());
|
|
124
|
+ dtlEntity.setComExstQty(baseInfo == null ? 0 : baseInfo.getStckQty()); // 기존재고수량
|
|
125
|
+ dtlEntity.setChgQty(dtlEntity.getCddQty() - dtlEntity.getComExstQty()); // 변동수량 = 실사수량 - 기존재고수량
|
116
|
126
|
stockCddMapper.insertStckCddMgntDtl(userId, dtlEntity);
|
117
|
127
|
|
118
|
128
|
// 재고관리기본정보(stck_mgnt_base_info) 업데이트
|
|
@@ -124,19 +134,23 @@ public class StockCddService extends CommonService {
|
124
|
134
|
stckEntity.setStckQty(dtlEntity.getCddQty()); // 재고수량 : 실사수량
|
125
|
135
|
double curStckRt = Math.round(stckEntity.getStckQty() * 100 / baseInfo.getPrpStckQty() * 100) / 100.0;
|
126
|
136
|
stckEntity.setCurStckRt(BigDecimal.valueOf(curStckRt)); // 현재고비율((재고수량 * 100) / 적정재고)
|
127
|
|
- stockMngMapper.updateStckMgntBaseInfo4StckProc(userId, stckEntity);
|
|
137
|
+ if (baseInfo == null) {
|
|
138
|
+ stockMngMapper.insertStckMgntBaseInfo(userId, stckEntity);
|
|
139
|
+ } else {
|
|
140
|
+ stockMngMapper.updateStckMgntBaseInfo4StckProc(userId, stckEntity);
|
|
141
|
+ }
|
128
|
142
|
|
129
|
143
|
// 재고관리상세이력(stck_mgnt_dtl_hist) 등록
|
130
|
|
- int inoutQty = dtlEntity.getCddQty() - baseInfo.getStckQty(); // 입출고수량
|
|
144
|
+ // int inoutQty = dtlEntity.getCddQty() - baseInfo.getStckQty(); // 입출고수량
|
131
|
145
|
StckMgntDtlHistEntity sourceHist = new StckMgntDtlHistEntity();
|
132
|
146
|
sourceHist.setStckMgntDtlNo(fnGetDealNo(32, "")); // 재고관리상세번호
|
133
|
147
|
sourceHist.setBrandId(stckEntity.getBrandId());
|
134
|
148
|
sourceHist.setWhsId(stckEntity.getWhsId());
|
135
|
149
|
sourceHist.setLocation(stckEntity.getLocation());
|
136
|
150
|
sourceHist.setItemId(stckEntity.getItemId());
|
137
|
|
- sourceHist.setItemNm(baseInfo.getItemNm());
|
138
|
|
- sourceHist.setInoutCd(inoutQty >= 0 ? InOutCd.IN.getCd() : InOutCd.OUT.getCd()); // 입출고구분
|
139
|
|
- sourceHist.setInoutQty(inoutQty); // 입출고수량
|
|
151
|
+ sourceHist.setItemNm(baseInfo == null ? itemEntity.getItemNm() : baseInfo.getItemNm());
|
|
152
|
+ sourceHist.setInoutCd(dtlEntity.getChgQty() >= 0 ? InOutCd.IN.getCd() : InOutCd.OUT.getCd()); // 입출고구분
|
|
153
|
+ sourceHist.setInoutQty(dtlEntity.getChgQty()); // 입출고수량
|
140
|
154
|
sourceHist.setChgDvsn(ChgDvsn.STOCK_CDD.getCd()); // 재고실사
|
141
|
155
|
stockMngMapper.insertStckMgntDtlHist(userId, sourceHist);
|
142
|
156
|
|