|
|
@@ -1,11 +1,15 @@
|
|
1
|
1
|
package com.shinsoft.sto.service.impl.ware;
|
|
2
|
2
|
|
|
3
|
3
|
import com.alibaba.cloud.commons.lang.StringUtils;
|
|
|
4
|
+import com.alibaba.fastjson.JSON;
|
|
|
5
|
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
4
|
6
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
7
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
5
|
8
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
6
|
9
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
7
|
10
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
8
|
11
|
import com.shinsoft.sto.mapper.ware.StoreChangeMapper;
|
|
|
12
|
+import com.shinsoft.sto.model.ware.ChangeRecord;
|
|
9
|
13
|
import com.shinsoft.sto.model.ware.StoreChange;
|
|
10
|
14
|
import com.shinsoft.sto.model.system.ResponseCodeMsg;
|
|
11
|
15
|
import com.shinsoft.sto.model.system.ResultJSON;
|
|
|
@@ -13,8 +17,10 @@ import com.shinsoft.sto.service.ware.StoreChangeService;
|
|
13
|
17
|
import org.springframework.stereotype.Service;
|
|
14
|
18
|
import org.springframework.transaction.annotation.Transactional;
|
|
15
|
19
|
|
|
|
20
|
+import java.util.Date;
|
|
16
|
21
|
import java.util.List;
|
|
17
|
22
|
import java.util.Map;
|
|
|
23
|
+import java.util.UUID;
|
|
18
|
24
|
|
|
19
|
25
|
@Service
|
|
20
|
26
|
public class StoreChangeServiceImpl extends ServiceImpl<StoreChangeMapper, StoreChange> implements StoreChangeService {
|
|
|
@@ -318,5 +324,52 @@ public class StoreChangeServiceImpl extends ServiceImpl<StoreChangeMapper, Store
|
|
318
|
324
|
}
|
|
319
|
325
|
}
|
|
320
|
326
|
|
|
|
327
|
+ @Override
|
|
|
328
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
329
|
+ public ResultJSON batchMove(String json, String wareId, String storeId, String userId, String belongId) {
|
|
|
330
|
+ try {
|
|
|
331
|
+ List<String> list = JSON.parseArray(json, String.class);
|
|
|
332
|
+
|
|
|
333
|
+ if (list == null || list.isEmpty()) {
|
|
|
334
|
+ return ResultJSON.error(ResponseCodeMsg.CODE_EX, "移动列表不能为空");
|
|
|
335
|
+ }
|
|
|
336
|
+
|
|
|
337
|
+ // 创建更新条件
|
|
|
338
|
+ UpdateWrapper<StoreChange> updateWrapper = new UpdateWrapper<>();
|
|
|
339
|
+ updateWrapper.in("STORE_ID", list) // 使用ID列表作为筛选条件
|
|
|
340
|
+ .eq("CANCEL_FLAG", "0") // 未作废的库存信息
|
|
|
341
|
+ .eq("belong_id", belongId) // 设置归属ID
|
|
|
342
|
+ .set("ware_id", wareId) // 设置新的仓库ID
|
|
|
343
|
+ .set("store_id", storeId) // 设置新的库位ID
|
|
|
344
|
+ .set("MODIFY_TIME", new Date())
|
|
|
345
|
+ .set("MODIFY_ID", userId);
|
|
|
346
|
+
|
|
|
347
|
+ // 执行批量更新
|
|
|
348
|
+ int result = baseMapper.update(updateWrapper);
|
|
|
349
|
+
|
|
|
350
|
+// 新增操作记录
|
|
|
351
|
+ ChangeRecord changeRecord = new ChangeRecord();
|
|
|
352
|
+ changeRecord.setId(UUID.randomUUID().toString());
|
|
|
353
|
+ changeRecord.setCntNum(1);
|
|
|
354
|
+ changeRecord.setAddTime(new Date());
|
|
|
355
|
+ changeRecord.setAddId(userId);
|
|
|
356
|
+ changeRecord.setChangeFlag("02");
|
|
|
357
|
+ changeRecord.setChangeNote("垛位转移");
|
|
|
358
|
+ changeRecord.setOldWareName(wareId);
|
|
|
359
|
+
|
|
|
360
|
+
|
|
|
361
|
+
|
|
|
362
|
+ if (result > 0) {
|
|
|
363
|
+ return ResultJSON.success("批量移动成功,影响记录数:" + result);
|
|
|
364
|
+ } else {
|
|
|
365
|
+ return ResultJSON.error(ResponseCodeMsg.CODE_EX, "批量移动失败,未更新任何记录");
|
|
|
366
|
+ }
|
|
|
367
|
+
|
|
|
368
|
+ } catch (Exception e) {
|
|
|
369
|
+ return ResultJSON.error(ResponseCodeMsg.CODE_EX, "批量移动异常: " + e.getMessage());
|
|
|
370
|
+ }
|
|
|
371
|
+ }
|
|
|
372
|
+
|
|
|
373
|
+
|
|
321
|
374
|
}
|
|
322
|
375
|
|