自动化立体仓库 - WMS系统
skyouc
3 天以前 5a77719594f0a2c9ef17b3a6d5c1e2f4e5d4e092
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
package com.zy.asrs.service.impl;
 
import com.zy.asrs.mapper.LocAroundBindMapper;
import com.zy.asrs.entity.BasDevice;
import com.zy.asrs.entity.LocAroundBind;
import com.zy.asrs.entity.LocMast;
import com.zy.asrs.entity.param.InitDeviceLocParams;
import com.zy.asrs.enums.LocStsType;
import com.zy.asrs.service.BasDeviceService;
import com.zy.asrs.service.LocAroundBindService;
import com.zy.asrs.service.LocMastService;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.core.common.Cools;
import com.core.common.R;
import com.core.exception.CoolException;
 
import java.util.List;
import java.util.Objects;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
@Service("locAroundBindService")
public class LocAroundBindServiceImpl extends ServiceImpl<LocAroundBindMapper, LocAroundBind>
        implements LocAroundBindService {
 
    @Autowired
    private LocMastService locMastService;
    @Autowired
    private BasDeviceService basDeviceService;
 
    /**
     * 绑定作业库位
     * 
     * @param params
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R bindLocs(InitDeviceLocParams params) {
        // 校验参数
        if (Cools.isEmpty(params.getStartRow()) || Cools.isEmpty(params.getEndRow()) ||
                Cools.isEmpty(params.getStartBay()) || Cools.isEmpty(params.getEndBay()) ||
                Cools.isEmpty(params.getStartLev()) || Cools.isEmpty(params.getEndLev())) {
            return R.error("参数错误");
        }
        BasDevice basDevice = basDeviceService.selectOne(new EntityWrapper<BasDevice>()
                .eq("dev_no", params.getDevNo()));
        if (Objects.isNull(basDevice)) {
            return R.error("未查询到该设备");
        }
 
        List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
                .between("row1", params.getStartRow(), params.getEndRow())
                .between("bay1", params.getStartBay(), params.getEndBay())
                .between("lev1", params.getStartLev(), params.getEndLev())
                .ne("loc_sts", LocStsType.LOC_STS_TYPE_X.type));
        if (Cools.isEmpty(locMasts)) {
            return R.error("未查询到符合条件的库位");
        }
 
        // 校验库位是否已绑定
        for (LocMast mast : locMasts) {
            LocAroundBind aroundBind = this.selectOne(new EntityWrapper<LocAroundBind>()
                    .eq("dev_no", params.getDevNo())
                    .eq("b_loc_no", mast.getLocNo()));
            if (!Objects.isNull(aroundBind)) {
                continue;
            }
            LocAroundBind bind = new LocAroundBind();
            bind.setDevNo(params.getDevNo());
            bind.setBLocNo(mast.getLocNo());
            bind.setDevId(basDevice.getId());
            if (!this.insert(bind)) {
                throw new CoolException("绑定库位失败");
            }
        }
        return R.ok("绑定库位成功");
    }
 
}