| | |
| | | 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 { |
| | | 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("绑定库位成功"); |
| | | } |
| | | |
| | | } |