自动化立体仓库 - WMS系统
skyouc
17 小时以前 40f7efd756605f20a25ea3d980bcd4cdcbdb9377
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package com.zy.asrs.service.impl;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
import com.core.common.R;
import com.core.exception.CoolException;
import com.zy.asrs.entity.BasAreas;
import com.zy.asrs.entity.BasWhsType;
import com.zy.asrs.entity.LocMast;
import com.zy.asrs.entity.param.LocMastInitParam;
import com.zy.asrs.mapper.LocCacheMapper;
import com.zy.asrs.entity.LocCache;
import com.zy.asrs.service.BasAreasService;
import com.zy.asrs.service.BasWhsTypeService;
import com.zy.asrs.service.LocCacheService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.zy.common.model.Shelves;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
@Slf4j
@Service("locCacheService")
public class LocCacheServiceImpl extends ServiceImpl<LocCacheMapper, LocCache> implements LocCacheService {
 
 
    @Autowired
    private BasAreasService basAreasService;
 
    /**
     * @author Ryan
     * @date 2025/9/18
     * @description: 初始化库区库位信息
     * @version 1.0
     */
    @Override
    public R initLocCache(LocMastInitParam param, Long userId) {
        try {
            List<LocCache> list = new ArrayList<>();
            BasAreas areas = basAreasService.selectById(param.getIdentifying());
            if (Cools.isEmpty(areas)) {
                return R.error("库区不存在!!!");
            }
            for (int r = param.getStartRow(); r <= param.getEndRow(); r++) {
                for (int b = param.getStartBay(); b <= param.getEndBay(); b++) {
                    for (int l = param.getStartLev(); l <= param.getEndLev(); l++) {
                        // 获取库位号
                        String locNo = String.format("CA") + String.format("%02d", r) + String.format("%03d", b) + String.format("%02d", l);
                        Date now = new Date();
                        LocCache locMast = new LocCache();
                        locMast.setLocNo(locNo);
                        locMast.setLocSts("O");
                        locMast.setRow1(r); // 排
                        locMast.setBay1(b); // 列
                        locMast.setLev1(l); // 层
                        locMast.setId(null);
                        locMast.setLocType1(!Cools.isEmpty(param.getLocType1()) ? param.getLocType1() : 1);
                        locMast.setLocType2(param.getLocType2());
                        locMast.setLocType3(param.getLocType3());
                        locMast.setAppeUser(userId);
                        locMast.setAppeTime(now);
                        locMast.setModiUser(userId);
                        locMast.setModiTime(now);
                        locMast.setAreaId(areas.getId());
                        locMast.setAreaName(areas.getName());
                        list.add(locMast);
                    }
                }
            }
            if (!Cools.isEmpty(param.getEnable()) && param.getEnable() == 1) {
                if (!this.delete(new EntityWrapper<>())) {
                    throw new CoolException("删除失败!!");
                }
            }
 
            if (!this.insertBatch(list)) {
                throw new CoolException("添加失败!!");
            }
            return R.ok("初始化成功");
        } catch (Exception e) {
            return R.error("初始化失败===>" + e.getMessage());
        }
    }
}