Przeglądaj źródła

실사 저장 - 엑셀 업로드 버그 수정

marseyes 2 lat temu
rodzic
commit
f163da6b12

+ 4 - 1
src/main/java/com/oqpo/api/mapper/stockmng/StockMngMapper.java

@@ -38,6 +38,9 @@ public interface StockMngMapper {
38 38
     StckMgntBaseInfoEntity selectStckMgntBaseInfo(@Param("brandId") String brandId, @Param("whsId") String whsId,
39 39
                                                   @Param("location") String location, @Param("itemId") String itemId) throws Exception;
40 40
 
41
+    StckMgntBaseInfoEntity selectStckMgntBaseInfo4CddProc(@Param("brandId") String brandId, @Param("whsId") String whsId,
42
+                                                          @Param("location") String location, @Param("itemId") String itemId) throws Exception;
43
+
41 44
     int insertStckMgntBaseInfo(@Param("userId") String userId, StckMgntBaseInfoEntity entity) throws Exception;
42 45
 
43 46
     int updateStckMgntBaseInfo4StckProc(@Param("userId") String userId, StckMgntBaseInfoEntity entity) throws Exception;
@@ -49,6 +52,6 @@ public interface StockMngMapper {
49 52
     List<StckMgntBaseInfoEntity> selectStockCddGridList(@Param("brandId") String brandId, @Param("storeId") String storeId, @Param("whsId") String whsId, @Param("location") String location,
50 53
                                                         List<StockMngCddGridRequest.StockCddReqData> gridItemData) throws Exception;
51 54
 
52
-    int updateStckPoUseQty(@Param("userId") String userId, @Param("brandId") String brandId, @Param("whsId") String whsId,@Param("location") String location, List<StckMgntBaseInfoEntity> gridUpdateData ) throws Exception;
55
+    int updateStckPoUseQty(@Param("userId") String userId, @Param("brandId") String brandId, @Param("whsId") String whsId, @Param("location") String location, List<StckMgntBaseInfoEntity> gridUpdateData) throws Exception;
53 56
 
54 57
 }

+ 10 - 14
src/main/java/com/oqpo/api/service/stockmng/StockCddService.java

@@ -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()); // 재고실사

+ 12 - 0
src/main/resources/mybatis/sqlmaps/stockmng/StockMng.xml

@@ -139,6 +139,18 @@
139 139
         AND A.item_id = #{itemId}
140 140
     </select>
141 141
 
142
+    <select id="selectStckMgntBaseInfo4CddProc" resultType="com.oqpo.api.entity.stockmng.StckMgntBaseInfoEntity">
143
+        /* StockMngMapper.selectStckMgntBaseInfo4CddProc */
144
+        SELECT A.brand_id, A.whs_id, C.whs_nm, A.location, D.location_nm, A.item_id, IFNULL(A.unit, B.UNIT) AS unit, A.stck_qty, A.prp_stck_qty, A.sft_stck_rt, A.cur_stck_rt,
145
+            DATE_FORMAT(A.sys_reg_dttm,'%Y.%m.%d %H:%i:%s') AS sys_reg_dttm, A.sys_reg_id, DATE_FORMAT(A.sys_chg_dttm,'%Y.%m.%d %H:%i:%s') AS sys_chg_dttm, A.sys_chg_id,
146
+            B.item_nm
147
+        FROM item_base_info B
148
+        LEFT JOIN stck_mgnt_base_info A ON A.item_id = B.item_id AND A.brand_id = #{brandId} AND A.whs_id = #{whsId} AND A.location = #{location}
149
+        LEFT JOIN whs_mgnt_base_info C ON A.brand_id = C.brand_id AND A.whs_id = C.whs_id
150
+        LEFT JOIN whs_mgnt_base_loc D ON A.brand_id = D.brand_id AND A.whs_id = D.whs_id AND A.location = D.location
151
+        WHERE B.item_id = #{itemId}
152
+    </select>
153
+
142 154
     <insert id="insertStckMgntBaseInfo" >
143 155
         /* StockMngMapper.insertStckMgntBaseInfo */
144 156
         INSERT INTO stck_mgnt_base_info