| | |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | @Service("mainService") |
| | | @Transactional |
| | | public class MainServiceImpl { |
| | | |
| | | @Autowired |
| | | private RowLastnoService rowLastnoService; |
| | | |
| | | public void test(){ |
| | | try { |
| | | // 工作号 |
| | | int workNo = commonService.getWorkNo(0); |
| | | System.out.println(workNo); |
| | | if (workNo > 0) { |
| | | throw new CoolException("21321"); |
| | | } |
| | | RowLastno rowLastno = rowLastnoService.selectById(1); |
| | | rowLastno.setCurrentRow(rowLastno.getCurrentRow() + 1); |
| | | rowLastnoService.updateById(rowLastno); |
| | | System.out.println(rowLastno.getCurrentRow()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | } |
| | | } |
| | | |
| | | @Autowired |
| | | private CommonService commonService; |
| | |
| | | private JdbcTemplate jdbcTemplate; |
| | | |
| | | /** |
| | | * 组托 |
| | | * 入库站,根据条码扫描生成入库工作档,工作状态 2 |
| | | */ |
| | | @Async |
| | |
| | | log.error("无此入库条码数据。条码号={}", barcode); |
| | | continue; |
| | | } |
| | | // 工作号 |
| | | int workNo = commonService.getWorkNo(0); |
| | | // 检索库位 |
| | | List<String> matNos = waitPakins.stream().map(WaitPakin::getMatnr).distinct().collect(Collectors.toList()); |
| | | StartupDto startupDto = commonService.getLocNo(1, 1, inSta.getStaNo(), matNos); |
| | | // 插入工作明细档 |
| | | wrkDetlService.createWorkDetail(workNo, waitPakins, barcode); |
| | | |
| | | // 插入工作主档 |
| | | wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setIoTime(new Date()); |
| | | wrkMast.setWrkSts(2L); // 工作状态:2.设备上走 |
| | | wrkMast.setIoType(1); // 入出库状态:1.入库 |
| | | wrkMast.setIoPri(10D); // 优先级:10 |
| | | wrkMast.setCrnNo(startupDto.getCrnNo()); |
| | | wrkMast.setSourceStaNo(startupDto.getSourceStaNo()); |
| | | wrkMast.setStaNo(startupDto.getStaNo()); |
| | | wrkMast.setLocNo(startupDto.getLocNo()); |
| | | wrkMast.setBarcode(barcode); // 托盘码 |
| | | wrkMast.setFullPlt("Y"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk("N"); // 空板 |
| | | wrkMast.setLinkMis("N"); |
| | | try { |
| | | // 工作号 |
| | | int workNo = commonService.getWorkNo(0); |
| | | // 检索库位 |
| | | List<String> matNos = waitPakins.stream().map(WaitPakin::getMatnr).distinct().collect(Collectors.toList()); |
| | | StartupDto startupDto = commonService.getLocNo(1, 1, inSta.getStaNo(), matNos); |
| | | // 插入工作明细档 |
| | | wrkDetlService.createWorkDetail(workNo, waitPakins, barcode); |
| | | |
| | | // 插入工作主档 |
| | | wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setIoTime(new Date()); |
| | | wrkMast.setWrkSts(2L); // 工作状态:2.设备上走 |
| | | wrkMast.setIoType(1); // 入出库状态:1.入库 |
| | | wrkMast.setIoPri(10D); // 优先级:10 |
| | | wrkMast.setCrnNo(startupDto.getCrnNo()); |
| | | wrkMast.setSourceStaNo(startupDto.getSourceStaNo()); |
| | | wrkMast.setStaNo(startupDto.getStaNo()); |
| | | wrkMast.setLocNo(startupDto.getLocNo()); |
| | | wrkMast.setBarcode(barcode); // 托盘码 |
| | | wrkMast.setFullPlt("Y"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk("N"); // 空板 |
| | | wrkMast.setLinkMis("N"); |
| | | // wrkMast.setCtnType(sourceStaNo.getCtnType()); // 容器类型 |
| | | // 操作人员数据 |
| | | wrkMast.setAppeTime(new Date()); |
| | | wrkMast.setModiTime(new Date()); |
| | | Integer insert = wrkMastMapper.insert(wrkMast); |
| | | if (insert == 0) { |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | // 更新目标库位状态 |
| | | LocMast locMast = locMastService.selectById(startupDto.getLocNo()); |
| | | locMast.setLocSts("S"); // S.入库预约 |
| | | locMast.setModiTime(new Date()); |
| | | if (!locMastService.updateById(locMast)){ |
| | | throw new CoolException("改变库位状态失败"); |
| | | } |
| | | // 将入库通知档修改为已启动 |
| | | if (wrkMastMapper.updateWaitPakInStep1(barcode) == 0) { |
| | | throw new CoolException("修改入库通知档状态为已启动失败"); |
| | | } |
| | | // 操作人员数据 |
| | | wrkMast.setAppeTime(new Date()); |
| | | wrkMast.setModiTime(new Date()); |
| | | Integer insert = wrkMastMapper.insert(wrkMast); |
| | | if (insert == 0) { |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | // 更新目标库位状态 |
| | | LocMast locMast = locMastService.selectById(startupDto.getLocNo()); |
| | | locMast.setLocSts("S"); // S.入库预约 |
| | | locMast.setModiTime(new Date()); |
| | | if (!locMastService.updateById(locMast)){ |
| | | throw new CoolException("改变库位状态失败"); |
| | | } |
| | | // 将入库通知档修改为已启动 |
| | | if (wrkMastMapper.updateWaitPakInStep1(barcode) == 0) { |
| | | throw new CoolException("修改入库通知档状态为已启动失败"); |
| | | } |
| | | |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | |
| | | // 更新站点信息 且 下发plc命令 |
| | | barcodeThread.setBarcode(""); |
| | | staProtocol.setWorkNo((short) workNo); |
| | | staProtocol.setStaNo(startupDto.getStaNo().shortValue()); |
| | | staProtocol.setPakMk(false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | if (!result) { |
| | | throw new CoolException("更新plc站点信息失败"); |
| | | // 更新站点信息 且 下发plc命令 |
| | | barcodeThread.setBarcode(""); |
| | | staProtocol.setWorkNo((short) workNo); |
| | | staProtocol.setStaNo(startupDto.getStaNo().shortValue()); |
| | | staProtocol.setPakMk(false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | if (!result) { |
| | | throw new CoolException("更新plc站点信息失败"); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | } |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * wms入库 |
| | | * 入库站,根据条码扫描生成入库工作档,工作状态 1 ==>> 2 |
| | | */ |
| | | @Async |
| | | public void generateStoreWrkFile2() { |
| | | public void generateStoreWrkFile0() { |
| | | // 根据输送线plc遍历 |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | // 遍历入库口 |
| | |
| | | continue; |
| | | } |
| | | |
| | | // todo:luxiaotao |
| | | try { |
| | | // 保存工作明细档历史档 |
| | | if (wrkMastMapper.saveWrkDetlLog(wrkMast.getWrkNo()) == 0) { |
| | | throw new CoolException("保存工作明细档历史档失败"); |
| | | } |
| | | // 保存工作主档历史档 |
| | | if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) { |
| | | throw new CoolException("保存工作主档历史档失败"); |
| | | } |
| | | |
| | | // 保存工作明细档历史档 |
| | | if (wrkMastMapper.saveWrkDetlLog(wrkMast.getWrkNo()) == 0) { |
| | | throw new CoolException("保存工作明细档历史档失败"); |
| | | // 堆垛机站点(目标站) |
| | | 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(new Date()); |
| | | if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | throw new CoolException("更新工作档数据状态失败"); |
| | | } |
| | | // 修改库位状态 Q.拣料/盘点/并板再入库 |
| | | LocMast locMast = locMastService.selectById(wrkMast.getLocNo()); |
| | | locMast.setLocSts("Q"); |
| | | locMast.setModiTime(new Date()); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("修改库位状态失败"); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | } |
| | | // 保存工作主档历史档 |
| | | if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) { |
| | | throw new CoolException("保存工作主档历史档失败"); |
| | | } |
| | | |
| | | // 堆垛机站点(目标站) |
| | | 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(new Date()); |
| | | if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | throw new CoolException("更新工作档数据状态失败"); |
| | | } |
| | | // 修改库位状态 Q.拣料/盘点/并板再入库 |
| | | LocMast locMast = locMastService.selectById(wrkMast.getLocNo()); |
| | | locMast.setLocSts("Q"); |
| | | locMast.setModiTime(new Date()); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("修改库位状态失败"); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | // 入库 + 库位转移 ==> 4.入库完成 |
| | | if (wrkMast.getWrkSts() == 3 || (wrkMast.getWrkSts() == 12 && wrkMast.getIoType() == 11)){ |
| | | wrkMast.setWrkSts(4L); |
| | | // 出库 + 拣料/盘点/并板出库中:12.吊车出库中 ==> 14.出库完成 |
| | | // todo:luxiaotao |
| | | // } else if (wrkMast.getWrkSts() == 12) { |
| | | // wrkMast.setWrkSts(14L); |
| | | } else { |
| | | continue; |
| | | } |
| | |
| | | // 检索库位 |
| | | StartupDto startupDto = commonService.getLocNo(1, 10, emptyInSta.getStaNo(), null); |
| | | |
| | | // todo:luxiaotao |
| | | |
| | | // 插入工作主档 |
| | | WrkMast wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setIoTime(new Date()); |
| | | wrkMast.setWrkSts(2L); // 工作状态:2.设备上走 |
| | | wrkMast.setIoType(10); // 入出库状态:10.空板入库 |
| | | wrkMast.setIoPri(10D); // 优先级:10 |
| | | wrkMast.setCrnNo(startupDto.getCrnNo()); |
| | | wrkMast.setSourceStaNo(startupDto.getSourceStaNo()); |
| | | wrkMast.setStaNo(startupDto.getStaNo()); |
| | | wrkMast.setLocNo(startupDto.getLocNo()); |
| | | wrkMast.setFullPlt("N"); // 满板 |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk("Y"); // 空板 |
| | | wrkMast.setLinkMis("N"); |
| | | try { |
| | | // 插入工作主档 |
| | | WrkMast wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setIoTime(new Date()); |
| | | wrkMast.setWrkSts(2L); // 工作状态:2.设备上走 |
| | | wrkMast.setIoType(10); // 入出库状态:10.空板入库 |
| | | wrkMast.setIoPri(10D); // 优先级:10 |
| | | wrkMast.setCrnNo(startupDto.getCrnNo()); |
| | | wrkMast.setSourceStaNo(startupDto.getSourceStaNo()); |
| | | wrkMast.setStaNo(startupDto.getStaNo()); |
| | | wrkMast.setLocNo(startupDto.getLocNo()); |
| | | wrkMast.setFullPlt("N"); // 满板 |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk("Y"); // 空板 |
| | | wrkMast.setLinkMis("N"); |
| | | // wrkMast.setCtnType(sourceStaNo.getCtnType()); // 容器类型 |
| | | // 操作人员数据 |
| | | wrkMast.setAppeTime(new Date()); |
| | | wrkMast.setModiTime(new Date()); |
| | | Integer insert = wrkMastMapper.insert(wrkMast); |
| | | if (insert == 0) { |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | // 更新目标库位状态 |
| | | LocMast locMast = locMastService.selectById(startupDto.getLocNo()); |
| | | locMast.setLocSts("S"); // S.入库预约 |
| | | locMast.setModiTime(new Date()); |
| | | if (!locMastService.updateById(locMast)){ |
| | | throw new CoolException("改变库位状态失败"); |
| | | } |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | // 操作人员数据 |
| | | wrkMast.setAppeTime(new Date()); |
| | | wrkMast.setModiTime(new Date()); |
| | | Integer insert = wrkMastMapper.insert(wrkMast); |
| | | if (insert == 0) { |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | // 更新目标库位状态 |
| | | LocMast locMast = locMastService.selectById(startupDto.getLocNo()); |
| | | locMast.setLocSts("S"); // S.入库预约 |
| | | locMast.setModiTime(new Date()); |
| | | if (!locMastService.updateById(locMast)){ |
| | | throw new CoolException("改变库位状态失败"); |
| | | } |
| | | // 命令下发区 -------------------------------------------------------------------------- |
| | | |
| | | // 更新站点信息 且 下发plc命令 |
| | | staProtocol.setWorkNo((short) workNo); |
| | | staProtocol.setStaNo(startupDto.getStaNo().shortValue()); |
| | | staProtocol.setPakMk(false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | if (!result) { |
| | | throw new CoolException("更新plc站点信息失败"); |
| | | // 更新站点信息 且 下发plc命令 |
| | | staProtocol.setWorkNo((short) workNo); |
| | | staProtocol.setStaNo(startupDto.getStaNo().shortValue()); |
| | | staProtocol.setPakMk(false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | if (!result) { |
| | | throw new CoolException("更新plc站点信息失败"); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | // todo:luxiaotao |
| | | |
| | | // 修改主档led标记 |
| | | for (WrkMast wrkMast : wrkMasts) { |
| | | wrkMast.setOveMk("Y"); |
| | | wrkMast.setModiTime(new Date()); |
| | | if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | throw new CoolException("更新工作档失败"); |
| | | try { |
| | | // 修改主档led标记 |
| | | for (WrkMast wrkMast : wrkMasts) { |
| | | wrkMast.setOveMk("Y"); |
| | | wrkMast.setModiTime(new Date()); |
| | | if (wrkMastMapper.updateById(wrkMast) == 0) { |
| | | throw new CoolException("更新工作档失败"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 更新线程当前工作号集合 |
| | | ledThread.setWorkNos(workNos); |
| | | // 更新线程当前工作号集合 |
| | | ledThread.setWorkNos(workNos); |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | for (Integer staNo : led.getStaArr()) { |
| | | // 获取叉车站点 |
| | | StaProtocol staProtocol = devpThread.getStation().get(staNo); |
| | | if (staProtocol == null) {continue;} |
| | | if (staProtocol.getWorkNo() != 0) { |
| | | reset = false; |
| | | break; |