dw 2 nedēļas atpakaļ
vecāks
revīzija
a60c5cccee

+ 60
- 6
src/main/java/com/th/demo/service/impl/ware/OutServiceImpl.java Parādīt failu

@@ -176,54 +176,105 @@ public class OutServiceImpl implements OutService {
176 176
             result = JSONTools.toString(ResponseCodeMsg.CODE_EX, "承运单位不可为空!");
177 177
             return result;
178 178
         }
179
+        
180
+        // ========== 添加:数据验证日志 ==========
181
+        System.out.println("========== 配车出库开始 ==========");
182
+        System.out.println("配车单ID: " + distribution.getId());
183
+        System.out.println("配车单号: " + distribution.getTruckNo());
184
+        
185
+        // 验证配车明细是否为空
186
+        if(distribution.getListDetail() == null || distribution.getListDetail().isEmpty()){
187
+            System.out.println("错误:配车明细为空!");
188
+            throw new Exception("配车明细为空,无法执行出库操作!");
189
+        }
190
+        System.out.println("配车明细数量: " + distribution.getListDetail().size());
191
+        // ========== 验证日志结束 ==========
192
+        
179 193
         num += distributionMapper.updateByPrimaryKey(distribution);
180 194
         List<String> listStoreId = new ArrayList<String>();
181 195
         for (int i = 0; i < distribution.getListDetail().size(); i++) {
182
-            listStoreId.add(distribution.getListDetail().get(i).getStore().getId());
196
+            Store store = distribution.getListDetail().get(i).getStore();
197
+            if(store != null && store.getId() != null){
198
+                listStoreId.add(store.getId());
199
+                System.out.println("板子ID: " + store.getId() + ", 板号: " + store.getPlateNo());
200
+            }
201
+        }
202
+        
203
+        // ========== 添加:验证 storeId 列表 ==========
204
+        if(listStoreId.isEmpty()){
205
+            System.out.println("错误:有效的板子ID列表为空!");
206
+            throw new Exception("配车明细中无有效的板子信息!");
183 207
         }
208
+        System.out.println("有效板子数量: " + listStoreId.size());
209
+        // ========== 验证结束 ==========
210
+        
184 211
         Map<String, Object> map = new HashMap<String, Object>();
185 212
         map.put("storeId", listStoreId);
186 213
         for(int i = 0 ;i < listStoreId.size();i++){
187
-            System.out.println(listStoreId.get(i));
214
+            System.out.println("查询的storeId: " + listStoreId.get(i));
188 215
         }
189 216
         List<StoreOfWareStack> listSows = storeMapper.selectWareStackByDistributionStore(map);
190 217
 
218
+        // ========== 添加:查询结果验证 ==========
219
+        System.out.println("查询到的库房垛位组合数: " + (listSows == null ? 0 : listSows.size()));
220
+        if(listSows == null || listSows.isEmpty()){
221
+            System.out.println("错误:根据storeId未查询到任何库房垛位记录!");
222
+            throw new Exception("根据板子ID未查询到库存记录,请检查板子是否存在或状态是否正常!");
223
+        }
224
+        // ========== 验证结束 ==========
225
+
191 226
         for (int m = 0; m < listSows.size(); m++) {
192 227
 
193 228
 
194 229
             Stack stack = stackMapper.selectByPrimaryKey(listSows.get(m).getStackId());
195 230
             Map<String, Object> mapParam = new HashMap<String, Object>();
196 231
             mapParam.put("storeId", listStoreId);
197
-            mapParam.put("wareId", listSows.get(m).getWareId());
198
-            mapParam.put("stackId", listSows.get(m).getStackId());
232
+            // ========== 修复:改为精确匹配,避免 null 值模糊匹配失败 ==========
233
+            mapParam.put("wareId", listSows.get(m).getWareId() == null ? "" : listSows.get(m).getWareId());
234
+            mapParam.put("stackId", listSows.get(m).getStackId() == null ? "" : listSows.get(m).getStackId());
235
+            // ========== 修复结束 ==========
199 236
 
200 237
             List<Store> listStore = storeMapper.selectByWareIdStackIdInStoreId(mapParam);
238
+            
239
+            // ========== 添加:每个垛位查询结果日志 ==========
240
+            System.out.println("库房ID: " + listSows.get(m).getWareId() + ", 垛位ID: " + listSows.get(m).getStackId() 
241
+                + ", 查询到板子数: " + (listStore == null ? 0 : listStore.size()));
242
+            
243
+            if(listStore == null || listStore.isEmpty()){
244
+                System.out.println("警告:该库房垛位下无有效板子,跳过处理");
245
+                continue;
246
+            }
247
+            // ========== 日志结束 ==========
248
+            
201 249
             if (stack.getIsLayer().equals("0") || stack.getIsLayer().equals("2")) {
250
+                // 分层不严格的库房垛位
202 251
                 for (int i = 0; i < listStore.size(); i++) {
203 252
                     OutRecord outRecord = getOutRecord(listStore.get(i), distribution.getId(), "1", userId);
204 253
                     num += outRecordMapper.insert(outRecord);
254
+                    System.out.println("创建出库记录成功,板号: " + listStore.get(i).getPlateNo());
205 255
                     AccountDetail accountDetail = getAccountDetail(listStore.get(i), distribution.getSumWeight(), distribution.getSuttle(), userId, belongId);
206 256
                     num += accountDetailMapper.insert(accountDetail);
207 257
                     listStore.get(i).setOutId(outRecord.getId());
208 258
                     listStore.get(i).setOutFlag("1");
209 259
                     num += storeMapper.updateByPrimaryKey(listStore.get(i));
260
+                    System.out.println("更新库存成功,板号: " + listStore.get(i).getPlateNo() + ", outFlag设为1");
210 261
                 }
211 262
                 result = Tools.moreThanZeroResultJSON(num);
212 263
             } else {
264
+                // 分层严格的库房垛位 - 需要检查层数
213 265
                 Collections.sort(listStore);
214 266
                 int currentLayer = Integer.parseInt(storeMapper.selectLayerByStackId(listStore.get(0).getStack().getId(), belongId));
215 267
                 int min = listStore.get(0).getLayer();
216 268
                 int max = listStore.get(listStore.size() - 1).getLayer();
217 269
                 if (currentLayer != max) {
218 270
                     throw new Exception("库房:" + listStore.get(m).getWare().getName() + ",垛位:" + listStore.get(m).getStack().getName() + ",出库物料不在最上层,无法出库!");
219
-                    // result = JSONTools.toString(ResponseCodeMsg.CODE_EX, "必须选择最上层出库!");
220 271
                 } else if (!WareTools.checkOrder(listStore)) {
221 272
                     throw new Exception("库房:" + listStore.get(m).getWare().getName() + ",垛位:" + listStore.get(m).getStack().getName() + ",出库物料不在最上层,无法出库!");
222
-                    //  result = JSONTools.toString(ResponseCodeMsg.CODE_EX, "请选中连续数据移动!");
223 273
                 } else {
224 274
                     for (int i = 0; i < listStore.size(); i++) {
225 275
                         OutRecord outRecord = getOutRecord(listStore.get(i), distribution.getId(), "1", userId);
226 276
                         num += outRecordMapper.insert(outRecord);
277
+                        System.out.println("创建出库记录成功,板号: " + listStore.get(i).getPlateNo());
227 278
 
228 279
                         AccountDetail accountDetail = getAccountDetail(listStore.get(i), distribution.getSumWeight(), distribution.getSuttle(), userId, belongId);
229 280
                         num += accountDetailMapper.insert(accountDetail);
@@ -231,12 +282,15 @@ public class OutServiceImpl implements OutService {
231 282
                         listStore.get(i).setOutId(outRecord.getId());
232 283
                         listStore.get(i).setOutFlag("1");
233 284
                         num += storeMapper.updateByPrimaryKey(listStore.get(i));
285
+                        System.out.println("更新库存成功,板号: " + listStore.get(i).getPlateNo() + ", outFlag设为1");
234 286
 
235 287
                     }
236 288
                     result = Tools.moreThanZeroResultJSON(num);
237 289
                 }
238 290
             }
239 291
         }
292
+        System.out.println("========== 配车出库完成 ==========");
293
+        System.out.println("影响的记录数: " + num);
240 294
         return result;
241 295
     }
242 296
 

+ 6
- 2
src/main/resource/mapper/ware/StoreMapper.xml Parādīt failu

@@ -480,8 +480,12 @@ update t_ware_store t set t.layer =   #{param7,jdbcType=INTEGER}
480 480
              open="(" separator="," close=")">
481 481
       #{item}
482 482
     </foreach>
483
-    and t.ware_id like concat('%',#{wareId,jdbcType=VARCHAR},'%')
484
-    and t.stack_id like concat('%',#{stackId,jdbcType=VARCHAR},'%')
483
+    <if test="wareId != null and wareId != ''">
484
+      and t.ware_id like concat('%',#{wareId,jdbcType=VARCHAR},'%')
485
+    </if>
486
+    <if test="stackId != null and stackId != ''">
487
+      and t.stack_id like concat('%',#{stackId,jdbcType=VARCHAR},'%')
488
+    </if>
485 489
   </select>
486 490
 
487 491
 

Notiek ielāde…
Atcelt
Saglabāt