| | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.LocDetl; |
| | | import com.zy.asrs.entity.LocMast; |
| | | import com.zy.asrs.entity.WrkDetl; |
| | | import com.zy.asrs.entity.WrkMast; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.mapper.*; |
| | | import com.zy.asrs.service.ApiLogService; |
| | | import com.zy.asrs.service.WorkService; |
| | | import com.zy.asrs.service.WrkDetlService; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.constant.MesConstant; |
| | | import com.zy.common.properties.SlaveProperties; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.system.entity.Config; |
| | | import com.zy.system.mapper.ConfigMapper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | @Resource |
| | | private WorkService workService; |
| | | |
| | | @Resource |
| | | private ConfigMapper configMapper; |
| | | |
| | | @Autowired |
| | | private SlaveProperties slaveProperties; |
| | | |
| | | @Transactional |
| | | public void startCkrwPushGwcs(WrkMast wrkMast) { |
| | | |
| | |
| | | } else if (wrkMast.getIoType() == 3) { |
| | | // 修改工作主档状态 |
| | | wrkMast.setWrkSts(15L); |
| | | wrkMast.setModiTime(new Date()); |
| | | } else if(wrkMast.getIoType() == 12) { // 跨巷道转移 |
| | | wrkMast.setWrkSts(1L); // 状态改为1.生成入库id |
| | | wrkMast.setModiTime(new Date()); |
| | | } |
| | | wrkMastMapper.updateById(wrkMast); |
| | |
| | | /** |
| | | * 自动备货处理 |
| | | */ |
| | | @Transactional |
| | | public void autoStockUpHandler(List<String> list,int columnNum) { |
| | | |
| | | // 根据包装组号获取所在库位 |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | @Transactional |
| | | public void autoMoveLoc(List<OrderDetl> orderDetlList) { |
| | | |
| | | // 判断是否已经有执行的移库任务 |
| | | Integer count = wrkMastMapper.selectCount(new EntityWrapper<WrkMast>().in("io_type", 11, 12)); |
| | | if (count > 0) { |
| | | return; |
| | | } |
| | | |
| | | OrderDetl detl = null; // 要移库的明细 |
| | | String staLoc = null; // 移库目标库位 |
| | | |
| | | // 从待移库位列表中先浅后深获取一个待移库位 |
| | | Optional<OrderDetl> any = orderDetlList.stream().filter(orderDetl -> Utils.isShallowLoc(slaveProperties,orderDetl.getSpecs())).findAny(); |
| | | |
| | | if (any.isPresent()){ |
| | | detl = any.get(); |
| | | } |
| | | // 剩下的应该都是深库位,获取第一个 |
| | | if (detl == null) { |
| | | detl = orderDetlList.get(0); |
| | | // 对应浅库位有货,在堆垛机出库的时候会检测到,在那里生成移库任务 |
| | | } |
| | | |
| | | // 获取备货区配置 |
| | | Config config = configMapper.selectConfigByCode("auto_stock_up"); |
| | | if (config == null) { |
| | | return; |
| | | } |
| | | // 备货取是前几列 |
| | | int bay1 = Integer.parseInt(config.getValue()); |
| | | // 指定的目标库位 |
| | | String model = detl.getModel(); |
| | | |
| | | // 指定目标库位 |
| | | if (!Cools.isEmpty(model)) { |
| | | // 目标库位是深库位 |
| | | if (Utils.isDeepLoc(slaveProperties,model)) { |
| | | // 目标库位 |
| | | LocMast locMast2 = locMastMapper.selectById(model); |
| | | if (locMast2 == null || !locMast2.getLocSts().equals("O")) { |
| | | log.error("指定的目标库位【{}】状不为空", model); |
| | | return; |
| | | } |
| | | // 获取到对应浅库位 |
| | | String shallowLoc = Utils.getShallowLoc(slaveProperties, model); |
| | | LocMast locMast = locMastMapper.selectById(shallowLoc); |
| | | // 浅库位有货 |
| | | if (locMast.getLocSts().equals("F") || locMast.getLocSts().equals("D")) { |
| | | log.error("选择的深库位【{}】,但是浅库位【{}】有货", model, locMast.getLocNo()); |
| | | return; |
| | | } |
| | | // 避开备货区 |
| | | if (Utils.getBay(model) <= bay1) { |
| | | log.error("指定的目标库位【{}】在备货区,不能转移", model); |
| | | return; |
| | | } |
| | | } |
| | | // 深库位检测通过,或者是浅库位 |
| | | staLoc = model; |
| | | } else if ( detl.getBeBatch() != null) { // 指定目标巷道 |
| | | // 目标巷道 |
| | | Integer beBatch = detl.getBeBatch(); |
| | | // 从巷道里面先深后浅取一个空库位,不要占用备货区 |
| | | List<LocMast> locMasts = locMastMapper.selectList(new EntityWrapper<LocMast>().eq("crn_no", beBatch).eq("loc_sts", "O").gt("bay1", bay1)); |
| | | if (locMasts.isEmpty()) { |
| | | log.error("指定巷道【{}】没有能移库的空库位了",beBatch); |
| | | return; |
| | | } |
| | | // 先过滤出深库位 |
| | | Optional<LocMast> a = locMasts.stream().filter(locMast -> Utils.isDeepLoc(slaveProperties,locMast.getLocNo())).findAny(); |
| | | if (a.isPresent()){ |
| | | staLoc = a.get().getLocNo(); |
| | | // 获取到对应浅库位 |
| | | String shallowLoc = Utils.getShallowLoc(slaveProperties, staLoc); |
| | | LocMast locMast = locMastMapper.selectById(shallowLoc); |
| | | // 浅库位有货 |
| | | if (locMast.getLocSts().equals("F") || locMast.getLocSts().equals("D")) { |
| | | log.error("指定的目标巷道深库位【{}】,但是浅库位【{}】有货",staLoc,locMast.getLocNo()); |
| | | return; |
| | | } |
| | | } |
| | | // 深库位没有则取浅库位 |
| | | if (staLoc == null) { |
| | | staLoc = locMasts.get(0).getLocNo(); |
| | | } |
| | | } else { |
| | | log.error("目标库位或目标巷道有误:{}",detl); |
| | | return; |
| | | } |
| | | |
| | | // 生成跨巷道移库任务 |
| | | workService.autoLocMove(detl.getOrderNo(),detl.getSpecs(),staLoc,29L); |
| | | |
| | | // 更新单据明细移库状态为移库中 |
| | | detl.setDanger(1); |
| | | if (detl.getBeBatch() != null) { |
| | | detl.setModel(staLoc); // 补充目标库位 |
| | | } |
| | | orderDetlMapper.updateById(detl); |
| | | // 更新单据状态为2处理中 |
| | | orderMapper.updatePendingSettleByOrderNo(detl.getOrderNo(),2L); |
| | | } |
| | | |
| | | } |