| | |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.controller.CrnController; |
| | | import com.zy.asrs.domain.enums.TaskStatusType; |
| | | import com.zy.asrs.domain.enums.WorkNoType; |
| | | import com.zy.asrs.domain.param.CrnOperatorParam; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.wms.StorageEscalationParam; |
| | | import com.zy.asrs.mapper.*; |
| | | import com.zy.asrs.mapper.BasCrnErrorMapper; |
| | | import com.zy.asrs.mapper.StaDescMapper; |
| | | import com.zy.asrs.mapper.TaskWrkMapper; |
| | | import com.zy.asrs.mapper.WrkMastMapper; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.task.core.ReturnT; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.core.CrnThread; |
| | | import com.zy.core.DevpThread; |
| | | import com.zy.core.cache.MessageQueue; |
| | |
| | | import com.zy.core.thread.SiemensDevpThread; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | |
| | | import java.io.IOException; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Random; |
| | | |
| | | /** |
| | | * 立体仓库WCS系统主流程业务 |
| | |
| | | @Autowired |
| | | private LocMastService locMastService; |
| | | @Autowired |
| | | private LocDetlService locDetlService; |
| | | @Autowired |
| | | private BasCrnpService basCrnpService; |
| | | @Autowired |
| | | private BasDevpService basDevpService; |
| | |
| | | private TaskWrkMapper taskWrkMapper; |
| | | |
| | | @Autowired |
| | | private DevpTaskMapper devpTaskMapper; |
| | | @Autowired |
| | | private TaskWrkService taskWrkService; |
| | | |
| | | @Autowired |
| | | private CommonService commonService; |
| | | @Autowired |
| | | private StaDescMapper staDescMapper; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private TransferTaskService transferTaskService; |
| | | |
| | | @Autowired |
| | | private WrkMastService wrkMastService; |
| | | |
| | | @Autowired |
| | | private WrkDetlService wrkDetlService; |
| | | |
| | | @Value("${loc-move.enable}") |
| | | private boolean enable; |
| | | @Value("${loc-move.crn1}") |
| | | private boolean crn1; |
| | | @Value("${loc-move.crn2}") |
| | | private boolean crn2; |
| | | @Value("${loc-move.crn3}") |
| | | private boolean crn3; |
| | | |
| | | |
| | | public void generateStoreWrkFile() throws IOException, InterruptedException { |
| | | try { |
| | |
| | | try { |
| | | // 根据输送线plc遍历 |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | if (devp.getId() == 2){ |
| | | if (devp.getId() == 2) { |
| | | continue; |
| | | } |
| | | SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | |
| | | /** |
| | | * 跑库程序 |
| | | */ |
| | | public void debug() { |
| | | //首先库位有一个在库的库位 |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_sts", "F")); |
| | | if (locMast != null) { |
| | | // 再生成一个移库任务 |
| | | LocMast mk = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_sts", "O").ne("mk", 1)); |
| | | |
| | | public void debug(String sts, Long modiUser, Integer loc_type1) { |
| | | if (!enable) { |
| | | return; |
| | | } |
| | | |
| | | List<BasCrnp> basCrnps = basCrnpService.selectList(new EntityWrapper<BasCrnp>()); |
| | | if (basCrnps.isEmpty()) { |
| | | return; |
| | | } |
| | | for (BasCrnp basCrnp : basCrnps) { |
| | | if (!basCrnp.getInEnable().equals("N") || !basCrnp.getOutEnable().equals("Y")) { |
| | | continue; |
| | | } |
| | | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("crn_no", basCrnp.getCrnNo()).eq("io_type", 11)); |
| | | if (Cools.isEmpty(wrkMasts) || wrkMasts.isEmpty()) { |
| | | int i = locMastService.selectCount(new EntityWrapper<LocMast>().eq("loc_sts", sts).eq("loc_type1", loc_type1).ne("modi_user", modiUser)); |
| | | LocMast locMastStart = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_sts", sts).eq("loc_type1", loc_type1).ne("modi_user", modiUser)); |
| | | if (locMastStart == null || i > 1) { |
| | | continue; |
| | | } |
| | | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("loc_sts", "O") |
| | | .eq("crn_no", basCrnp.getCrnNo()) |
| | | .eq("loc_type1", locMastStart.getLocType1()) |
| | | .ne("modi_user", 77)); |
| | | if (Cools.isEmpty(locMasts)) { |
| | | continue; |
| | | } |
| | | Random random = new Random(); |
| | | LocMast locMastEnd = locMasts.get(random.nextInt(locMasts.size())); |
| | | ReturnT<String> result = locMove(locMastStart, locMastEnd, basCrnp.getCrnNo()); |
| | | if (!result.isSuccess()) { |
| | | log.error("处理失败"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | public void locMove(LocMast sourceLoc, LocMast locNo, Long userId) { |
| | | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", sourceLoc.getLocNo())); |
| | | LocMast loc = locMastService.selectById(locNo); |
| | | if (!sourceLoc.getCrnNo().equals(loc.getCrnNo())) { |
| | | throw new CoolException("移转库位属于不同堆垛机"); |
| | | } |
| | | Date now = new Date(); |
| | | // 获取工作号 |
| | | int workNo = commonService.getWorkNo(WorkNoType.PICK.type); |
| | | // 保存工作档 |
| | | WrkMast wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setIoTime(now); |
| | | wrkMast.setWrkSts(11L); // 工作状态:11.生成出库ID |
| | | wrkMast.setIoType(11); // 入出库状态: 11.库格移载 |
| | | wrkMast.setIoPri(10D); |
| | | wrkMast.setCrnNo(sourceLoc.getCrnNo()); |
| | | wrkMast.setSourceLocNo(sourceLoc.getLocNo()); // 源库位 |
| | | wrkMast.setLocNo(locNo.getLocNo()); // 目标库位 |
| | | wrkMast.setFullPlt(Cools.isEmpty(locDetls) ? "N" : "Y"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk(sourceLoc.getLocSts().equals("D") ? "Y" : "N"); // 空板 |
| | | wrkMast.setBarcode(sourceLoc.getBarcode()); // 托盘码 |
| | | wrkMast.setLinkMis("N"); |
| | | wrkMast.setAppeUser(userId); |
| | | wrkMast.setAppeTime(now); |
| | | wrkMast.setModiUser(userId); |
| | | wrkMast.setModiTime(now); |
| | | boolean res = wrkMastService.insert(wrkMast); |
| | | if (!res) { |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | // 工作档明细保存 |
| | | for (LocDetl locDetl : locDetls) { |
| | | WrkDetl wrkDetl = new WrkDetl(); |
| | | wrkDetl.sync(locDetl); |
| | | wrkDetl.setWrkNo(workNo); |
| | | wrkDetl.setIoTime(now); |
| | | wrkDetl.setAnfme(locDetl.getAnfme()); |
| | | wrkDetl.setAppeTime(now); |
| | | wrkDetl.setAppeUser(userId); |
| | | wrkDetl.setModiTime(now); |
| | | wrkDetl.setModiUser(userId); |
| | | if (!wrkDetlService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | | } |
| | | } |
| | | // 修改源库位状态 |
| | | if (sourceLoc.getLocSts().equals("D") || sourceLoc.getLocSts().equals("F")) { |
| | | sourceLoc.setLocSts("R"); // R.出库预约 |
| | | sourceLoc.setModiUser(userId); |
| | | sourceLoc.setModiTime(now); |
| | | if (!locMastService.updateById(sourceLoc)) { |
| | | throw new CoolException("更新源库位状态失败"); |
| | | } |
| | | } else { |
| | | throw new CoolException("源库位出库失败,状态:" + sourceLoc.getLocSts$()); |
| | | } |
| | | // 修改目标库位状态 |
| | | if (loc.getLocSts().equals("O")) { |
| | | loc.setLocSts("S"); // S.入库预约 |
| | | loc.setModiTime(now); |
| | | loc.setModiUser(userId); |
| | | if (!locMastService.updateById(loc)) { |
| | | throw new CoolException("更新目标库位状态失败"); |
| | | } |
| | | } else { |
| | | throw new CoolException("移转失败,目标库位状态:" + loc.getLocSts$()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 转移任务下发 |
| | | */ |
| | | public void transferTaskStart() { |
| | | |
| | | for (DevpSlave.Sta sta : slaveProperties.getDevp().get(1).getInSta()) { |
| | | try { |
| | | // 获取入库站信息 |
| | |
| | | continue; |
| | | } |
| | | log.info("转移任务完成:transferTask:" + JSON.toJSONString(transferTask)); |
| | | transferTask.setStatus(5); |
| | | transferTask.setStatus(3); |
| | | transferTaskService.updateById(transferTask); |
| | | } |
| | | } catch (Exception e) { |