| | |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.R; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.mapper.TaskMapper; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Collections; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | |
| | | @Autowired |
| | | private TaskDetlLogService taskDetlLogService; |
| | | |
| | | @Resource |
| | | private BasStationService basStationService; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void completeWrkMast(String workNo, Long userId) { |
| | |
| | | if (Cools.isEmpty(wrkMast)) { |
| | | throw new CoolException(workNo + "工作档不存在"); |
| | | } |
| | | Date now = new Date(); |
| | | // 终点是接驳位 只能完成305 |
| | | if (wrkMast.getStaNo().startsWith("A")) { |
| | | if(wrkMast.getWrkSts() == 305) { |
| | | throw new CoolException("当前工作档已完成"); |
| | | } |
| | | wrkMast.setWrkSts(305L); |
| | | // 绑定站点 |
| | | BasStation basStation = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", wrkMast.getStaNo())); |
| | | if (basStation.getBarcode().equals(wrkMast.getBarcode())) { |
| | | basStation.setLocSts("F"); |
| | | basStation.setModiTime(now); |
| | | basStation.setModiUser(userId); |
| | | basStationService.updateById(basStation); |
| | | } |
| | | } else { |
| | | // 起点是接驳位 只能完成304 |
| | | if (wrkMast.getWrkSts() == 304) { |
| | | throw new CoolException("当前工作档已完成"); |
| | | } |
| | | |
| | | wrkMast.setWrkSts(304L); |
| | | // 解绑站点 |
| | | BasStation basStation = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", wrkMast.getSourceStaNo())); |
| | | if (basStation.getBarcode().equals(wrkMast.getBarcode())) { |
| | | basStation.setLocSts("O"); |
| | | basStation.setModiTime(now); |
| | | basStation.setModiUser(userId); |
| | | basStationService.updateById(basStation); |
| | | } |
| | | } |
| | | |
| | | Date now = new Date(); |
| | | wrkMast.setCrnStrTime(DateUtils.calculate(now, 1L, TimeUnit.SECONDS, true)); |
| | | wrkMast.setCrnEndTime(now); |
| | | wrkMast.setModiTime(now); |
| | |
| | | } |
| | | } |
| | | |
| | | @Resource |
| | | private MobileService mobileService; |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void pickWrkMast(String workNo, Long userId) { |
| | | Task wrkMast = this.selectById(workNo); |
| | | Task wrkMast = this.selectOne(new EntityWrapper<Task>().eq("wrk_no", workNo)); |
| | | if (Cools.isEmpty(wrkMast)) { |
| | | throw new CoolException(workNo + "工作档不存在"); |
| | | } |
| | | // 入出库类型判断 |
| | | if (wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104 && wrkMast.getIoType() != 107) { |
| | | throw new CoolException("当前入出库类型无法进行操作"); |
| | | R r = mobileService.djReturn(wrkMast.getBarcode()); |
| | | if(!r.get("code").equals(200)) { |
| | | throw new CoolException(""+r.get("msg")); |
| | | } |
| | | // 工作状态判断 |
| | | if (wrkMast.getWrkSts() < 11 || wrkMast.getWrkSts() == 15) { |
| | | throw new CoolException("当前工作状态无法进行操作"); |
| | | } |
| | | // 保存工作明细档历史档 |
| | | // if (!wrkDetlLogService.save(wrkMast.getWrkNo())) { |
| | | // throw new CoolException("保存工作明细档历史档失败"); |
| | | // // 入出库类型判断 |
| | | // if (wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104 && wrkMast.getIoType() != 107) { |
| | | // throw new CoolException("当前入出库类型无法进行操作"); |
| | | // } |
| | | // 保存工作主档历史档 |
| | | if (!taskLogService.save(wrkMast.getWrkNo())) { |
| | | throw new CoolException("保存工作主档历史档失败"); |
| | | } |
| | | // 获取目标站 |
| | | // Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() |
| | | // .eq("type_no", wrkMast.getIoType() - 50) |
| | | // .eq("stn_no", wrkMast.getStaNo()) // 作业站点 = 拣料出库的目标站 |
| | | // .eq("crn_no", wrkMast.getCrnNo()); // 堆垛机号 |
| | | // StaDesc staDesc = staDescService.selectOne(wrapper); |
| | | // if (Cools.isEmpty(staDesc)) { |
| | | // throw new CoolException("入库路径不存在"); |
| | | // // 工作状态判断 |
| | | // if (wrkMast.getWrkSts() < 11 || wrkMast.getWrkSts() == 15) { |
| | | // throw new CoolException("当前工作状态无法进行操作"); |
| | | // } |
| | | Date now = new Date(); |
| | | // 堆垛机站点(目标站) |
| | | // Integer staNo = staDesc.getCrnStn(); |
| | | // 更新工作档数据状态 |
| | | wrkMast.setIoType(wrkMast.getIoType() - 50); // 入出库类型: 103->53,104->54,107->57 |
| | | wrkMast.setWrkSts(2L); // 工作状态: 2.设备上走 |
| | | wrkMast.setSourceStaNo(wrkMast.getStaNo()); // 源站 |
| | | // wrkMast.setStaNo(staNo + ""); // 目标站 |
| | | wrkMast.setLocNo(wrkMast.getSourceLocNo()); // 目标库位 = 出库时的源库位 |
| | | wrkMast.setSourceLocNo(""); // 源库位清空 |
| | | wrkMast.setModiTime(now); |
| | | wrkMast.setModiUser(userId); |
| | | if (!this.updateById(wrkMast)) { |
| | | throw new CoolException("更新工作档数据状态失败"); |
| | | } |
| | | // 修改库位状态 Q.拣料/盘点/并板再入库 |
| | | LocCache locMast = locCacheService.selectOne(new EntityWrapper<LocCache>().eq("loc_no", wrkMast.getLocNo())); |
| | | locMast.setLocSts("Q"); |
| | | locMast.setModiTime(now); |
| | | locMast.setModiUser(userId); |
| | | if (!locCacheService.updateById(locMast)) { |
| | | throw new CoolException("修改库位状态失败"); |
| | | } |
| | | // // 保存工作明细档历史档 |
| | | //// if (!wrkDetlLogService.save(wrkMast.getWrkNo())) { |
| | | //// throw new CoolException("保存工作明细档历史档失败"); |
| | | //// } |
| | | // // 保存工作主档历史档 |
| | | // if (!taskLogService.save(wrkMast.getWrkNo())) { |
| | | // throw new CoolException("保存工作主档历史档失败"); |
| | | // } |
| | | // // 获取目标站 |
| | | //// Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() |
| | | //// .eq("type_no", wrkMast.getIoType() - 50) |
| | | //// .eq("stn_no", wrkMast.getStaNo()) // 作业站点 = 拣料出库的目标站 |
| | | //// .eq("crn_no", wrkMast.getCrnNo()); // 堆垛机号 |
| | | //// StaDesc staDesc = staDescService.selectOne(wrapper); |
| | | //// if (Cools.isEmpty(staDesc)) { |
| | | //// throw new CoolException("入库路径不存在"); |
| | | //// } |
| | | // Date now = new Date(); |
| | | // // 堆垛机站点(目标站) |
| | | //// Integer staNo = staDesc.getCrnStn(); |
| | | // // 更新工作档数据状态 |
| | | // wrkMast.setIoType(wrkMast.getIoType() - 50); // 入出库类型: 103->53,104->54,107->57 |
| | | // wrkMast.setWrkSts(2L); // 工作状态: 2.设备上走 |
| | | // wrkMast.setSourceStaNo(wrkMast.getStaNo()); // 源站 |
| | | //// wrkMast.setStaNo(staNo + ""); // 目标站 |
| | | // wrkMast.setLocNo(wrkMast.getSourceLocNo()); // 目标库位 = 出库时的源库位 |
| | | // wrkMast.setSourceLocNo(""); // 源库位清空 |
| | | // wrkMast.setModiTime(now); |
| | | // wrkMast.setModiUser(userId); |
| | | // if (!this.updateById(wrkMast)) { |
| | | // throw new CoolException("更新工作档数据状态失败"); |
| | | // } |
| | | // // 修改库位状态 Q.拣料/盘点/并板再入库 |
| | | // LocCache locMast = locCacheService.selectOne(new EntityWrapper<LocCache>().eq("loc_no", wrkMast.getLocNo())); |
| | | // locMast.setLocSts("Q"); |
| | | // locMast.setModiTime(now); |
| | | // locMast.setModiUser(userId); |
| | | // if (!locCacheService.updateById(locMast)) { |
| | | // throw new CoolException("修改库位状态失败"); |
| | | // } |
| | | } |
| | | |
| | | @Override |
| | |
| | | if (Cools.isEmpty(wrkMast)) { |
| | | throw new CoolException(workNo + "工作档不存在"); |
| | | } |
| | | if(wrkMast.getWrkSts() >= 304) { |
| | | throw new CoolException("工作状态已经完成:" + wrkMast.getWrkSts()); |
| | | // 终点是接驳位 |
| | | if (wrkMast.getStaNo().startsWith("A")) { |
| | | // if(wrkMast.getWrkSts() == 305) { |
| | | // throw new CoolException("当前工作档已完成"); |
| | | // } |
| | | // 解绑站点 |
| | | BasStation basStation = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", wrkMast.getStaNo())); |
| | | if (basStation.getBarcode().equals(wrkMast.getBarcode())) { |
| | | basStation.setLocSts("O"); |
| | | basStation.setBarcode(""); |
| | | basStation.setModiTime(now); |
| | | basStation.setModiUser(userId); |
| | | basStationService.updateById(basStation); |
| | | } |
| | | |
| | | } else { |
| | | // 起点是接驳位 只能完成304 |
| | | if (wrkMast.getWrkSts() == 304) { |
| | | throw new CoolException("当前工作档已完成"); |
| | | } |
| | | // 解绑站点 |
| | | BasStation basStation = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", wrkMast.getSourceStaNo())); |
| | | if (basStation.getBarcode().equals(wrkMast.getBarcode())) { |
| | | basStation.setLocSts("O"); |
| | | basStation.setBarcode(""); |
| | | basStation.setModiTime(now); |
| | | basStation.setModiUser(userId); |
| | | basStationService.updateById(basStation); |
| | | } |
| | | } |
| | | |
| | | // 取消操作人员记录 |