dw 1 week ago
parent
commit
a60c5cccee

+ 60
- 6
src/main/java/com/th/demo/service/impl/ware/OutServiceImpl.java View File

176
             result = JSONTools.toString(ResponseCodeMsg.CODE_EX, "承运单位不可为空!");
176
             result = JSONTools.toString(ResponseCodeMsg.CODE_EX, "承运单位不可为空!");
177
             return result;
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
         num += distributionMapper.updateByPrimaryKey(distribution);
193
         num += distributionMapper.updateByPrimaryKey(distribution);
180
         List<String> listStoreId = new ArrayList<String>();
194
         List<String> listStoreId = new ArrayList<String>();
181
         for (int i = 0; i < distribution.getListDetail().size(); i++) {
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
         Map<String, Object> map = new HashMap<String, Object>();
211
         Map<String, Object> map = new HashMap<String, Object>();
185
         map.put("storeId", listStoreId);
212
         map.put("storeId", listStoreId);
186
         for(int i = 0 ;i < listStoreId.size();i++){
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
         List<StoreOfWareStack> listSows = storeMapper.selectWareStackByDistributionStore(map);
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
         for (int m = 0; m < listSows.size(); m++) {
226
         for (int m = 0; m < listSows.size(); m++) {
192
 
227
 
193
 
228
 
194
             Stack stack = stackMapper.selectByPrimaryKey(listSows.get(m).getStackId());
229
             Stack stack = stackMapper.selectByPrimaryKey(listSows.get(m).getStackId());
195
             Map<String, Object> mapParam = new HashMap<String, Object>();
230
             Map<String, Object> mapParam = new HashMap<String, Object>();
196
             mapParam.put("storeId", listStoreId);
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
             List<Store> listStore = storeMapper.selectByWareIdStackIdInStoreId(mapParam);
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
             if (stack.getIsLayer().equals("0") || stack.getIsLayer().equals("2")) {
249
             if (stack.getIsLayer().equals("0") || stack.getIsLayer().equals("2")) {
250
+                // 分层不严格的库房垛位
202
                 for (int i = 0; i < listStore.size(); i++) {
251
                 for (int i = 0; i < listStore.size(); i++) {
203
                     OutRecord outRecord = getOutRecord(listStore.get(i), distribution.getId(), "1", userId);
252
                     OutRecord outRecord = getOutRecord(listStore.get(i), distribution.getId(), "1", userId);
204
                     num += outRecordMapper.insert(outRecord);
253
                     num += outRecordMapper.insert(outRecord);
254
+                    System.out.println("创建出库记录成功,板号: " + listStore.get(i).getPlateNo());
205
                     AccountDetail accountDetail = getAccountDetail(listStore.get(i), distribution.getSumWeight(), distribution.getSuttle(), userId, belongId);
255
                     AccountDetail accountDetail = getAccountDetail(listStore.get(i), distribution.getSumWeight(), distribution.getSuttle(), userId, belongId);
206
                     num += accountDetailMapper.insert(accountDetail);
256
                     num += accountDetailMapper.insert(accountDetail);
207
                     listStore.get(i).setOutId(outRecord.getId());
257
                     listStore.get(i).setOutId(outRecord.getId());
208
                     listStore.get(i).setOutFlag("1");
258
                     listStore.get(i).setOutFlag("1");
209
                     num += storeMapper.updateByPrimaryKey(listStore.get(i));
259
                     num += storeMapper.updateByPrimaryKey(listStore.get(i));
260
+                    System.out.println("更新库存成功,板号: " + listStore.get(i).getPlateNo() + ", outFlag设为1");
210
                 }
261
                 }
211
                 result = Tools.moreThanZeroResultJSON(num);
262
                 result = Tools.moreThanZeroResultJSON(num);
212
             } else {
263
             } else {
264
+                // 分层严格的库房垛位 - 需要检查层数
213
                 Collections.sort(listStore);
265
                 Collections.sort(listStore);
214
                 int currentLayer = Integer.parseInt(storeMapper.selectLayerByStackId(listStore.get(0).getStack().getId(), belongId));
266
                 int currentLayer = Integer.parseInt(storeMapper.selectLayerByStackId(listStore.get(0).getStack().getId(), belongId));
215
                 int min = listStore.get(0).getLayer();
267
                 int min = listStore.get(0).getLayer();
216
                 int max = listStore.get(listStore.size() - 1).getLayer();
268
                 int max = listStore.get(listStore.size() - 1).getLayer();
217
                 if (currentLayer != max) {
269
                 if (currentLayer != max) {
218
                     throw new Exception("库房:" + listStore.get(m).getWare().getName() + ",垛位:" + listStore.get(m).getStack().getName() + ",出库物料不在最上层,无法出库!");
270
                     throw new Exception("库房:" + listStore.get(m).getWare().getName() + ",垛位:" + listStore.get(m).getStack().getName() + ",出库物料不在最上层,无法出库!");
219
-                    // result = JSONTools.toString(ResponseCodeMsg.CODE_EX, "必须选择最上层出库!");
220
                 } else if (!WareTools.checkOrder(listStore)) {
271
                 } else if (!WareTools.checkOrder(listStore)) {
221
                     throw new Exception("库房:" + listStore.get(m).getWare().getName() + ",垛位:" + listStore.get(m).getStack().getName() + ",出库物料不在最上层,无法出库!");
272
                     throw new Exception("库房:" + listStore.get(m).getWare().getName() + ",垛位:" + listStore.get(m).getStack().getName() + ",出库物料不在最上层,无法出库!");
222
-                    //  result = JSONTools.toString(ResponseCodeMsg.CODE_EX, "请选中连续数据移动!");
223
                 } else {
273
                 } else {
224
                     for (int i = 0; i < listStore.size(); i++) {
274
                     for (int i = 0; i < listStore.size(); i++) {
225
                         OutRecord outRecord = getOutRecord(listStore.get(i), distribution.getId(), "1", userId);
275
                         OutRecord outRecord = getOutRecord(listStore.get(i), distribution.getId(), "1", userId);
226
                         num += outRecordMapper.insert(outRecord);
276
                         num += outRecordMapper.insert(outRecord);
277
+                        System.out.println("创建出库记录成功,板号: " + listStore.get(i).getPlateNo());
227
 
278
 
228
                         AccountDetail accountDetail = getAccountDetail(listStore.get(i), distribution.getSumWeight(), distribution.getSuttle(), userId, belongId);
279
                         AccountDetail accountDetail = getAccountDetail(listStore.get(i), distribution.getSumWeight(), distribution.getSuttle(), userId, belongId);
229
                         num += accountDetailMapper.insert(accountDetail);
280
                         num += accountDetailMapper.insert(accountDetail);
231
                         listStore.get(i).setOutId(outRecord.getId());
282
                         listStore.get(i).setOutId(outRecord.getId());
232
                         listStore.get(i).setOutFlag("1");
283
                         listStore.get(i).setOutFlag("1");
233
                         num += storeMapper.updateByPrimaryKey(listStore.get(i));
284
                         num += storeMapper.updateByPrimaryKey(listStore.get(i));
285
+                        System.out.println("更新库存成功,板号: " + listStore.get(i).getPlateNo() + ", outFlag设为1");
234
 
286
 
235
                     }
287
                     }
236
                     result = Tools.moreThanZeroResultJSON(num);
288
                     result = Tools.moreThanZeroResultJSON(num);
237
                 }
289
                 }
238
             }
290
             }
239
         }
291
         }
292
+        System.out.println("========== 配车出库完成 ==========");
293
+        System.out.println("影响的记录数: " + num);
240
         return result;
294
         return result;
241
     }
295
     }
242
 
296
 

+ 6
- 2
src/main/resource/mapper/ware/StoreMapper.xml View File

480
              open="(" separator="," close=")">
480
              open="(" separator="," close=")">
481
       #{item}
481
       #{item}
482
     </foreach>
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
   </select>
489
   </select>
486
 
490
 
487
 
491
 

Loading…
Cancel
Save