1、大理片笼新增进笼规则,计算本工程下所有玻璃的虚拟格子信息,按照虚拟格子,匹配笼内的实际格子,进笼之后查看格子是否有到齐的,执行调度任务
2、卧理修改任务执行顺序,移除捕获异常操作
3、不覆盖原有逻辑,新增opc任务,避免任务重复执行报错
24个文件已修改
1 文件已重命名
24个文件已添加
1个文件已删除
| | |
| | | public static final Integer TEMPERING_START = 2; |
| | | public static final Integer TEMPERING_SUCCESS = 3; |
| | | public static final Integer TEMPERING_END = 4; |
| | | // public static final Integer TEMPERING_DAMAGE = 8; |
| | | // public static final Integer TEMPERING_TAKE = 9; |
| | | public static final Integer TEMPERING_DAMAGE = 8; |
| | | public static final Integer TEMPERING_TAKE = 9; |
| | | |
| | | /** |
| | | * 下片 |
| | |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.github.yulichang.base.MPJBaseMapper; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @DS("hangzhoumes") |
| | | public interface GlassInfoMapper extends MPJBaseMapper<GlassInfo> { |
| | | |
| | | List<GlassInfo> listBySize(@Param("engineerId") String engineerId); |
| | | } |
| | |
| | | List<Map<String, Object>> getFlowCardId(); |
| | | |
| | | |
| | | |
| | | |
| | | List<GlassInfo> listBySize(String engineerId); |
| | | } |
| | | |
| | |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public List<GlassInfo> listBySize(String engineerId) { |
| | | return baseMapper.listBySize(engineerId); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.mes.glassinfo.mapper.GlassInfoMapper"> |
| | | |
| | | <select id="listBySize" resultType="com.mes.glassinfo.entity.GlassInfo"> |
| | | with glass_list as ( |
| | | SELECT flow_card_id, |
| | | glass_type, |
| | | GREATEST(width, height) as width, |
| | | least(width, height) as height, |
| | | thickness, |
| | | filmsid, |
| | | total_layer, |
| | | layer, |
| | | ismultiple, |
| | | max_width, |
| | | max_height, |
| | | tempering_layout_id, |
| | | tempering_feed_sequence, |
| | | engineer_id, |
| | | glass_id |
| | | FROM glass_info |
| | | where engineer_id = #{engineerId} |
| | | ) |
| | | select * |
| | | from glass_list |
| | | order by flow_card_id, height desc, width desc, tempering_layout_id, tempering_feed_sequence |
| | | |
| | | </select> |
| | | </mapper> |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import com.mes.common.config.Const; |
| | | import com.mes.edgglasstaskqueueinfo.entity.EdgGlassTaskQueueInfo; |
| | | import com.mes.edgglasstaskqueueinfo.service.EdgGlassTaskQueueInfoService; |
| | | import com.mes.edgglasstask.entity.EdgGlassTaskInfo; |
| | | import com.mes.edgglasstask.service.EdgGlassTaskInfoService; |
| | | import com.mes.edgstoragecage.entity.EdgStorageCage; |
| | | import com.mes.edgstoragecage.entity.EdgStorageCageDetails; |
| | | import com.mes.edgstoragecage.service.EdgStorageCageDetailsService; |
| | |
| | | |
| | | @Resource |
| | | EdgStorageDeviceTaskService edgStorageDeviceTaskService; |
| | | @Resource |
| | | EdgGlassTaskQueueInfoService edgGlassTaskQueueInfoService; |
| | | // @Resource |
| | | // EdgGlassTaskQueueInfoService edgGlassTaskQueueInfoService; |
| | | @Autowired |
| | | EdgGlassTaskInfoService edgGlassTaskInfoService; |
| | | |
| | | @Resource |
| | | GlassInfoService glassInfoService; |
| | | @Resource |
| | |
| | | private int threshold; |
| | | @Value("${mes.cellLength}") |
| | | private int cellLength; |
| | | @Value("${mes.ratio}") |
| | | private int ratio; |
| | | |
| | | @Value("${mes.min.one.firstLength}") |
| | | private int minOneFirstLength; |
| | | |
| | | @Value("${mes.min.one.secondLength}") |
| | | private int minOneSecondLength; |
| | | |
| | | @Value("${mes.min.two.firstLength}") |
| | | private int minTwoFirstLength; |
| | | |
| | | @Value("${mes.min.two.secondLength}") |
| | | private int minTwoSecondLength; |
| | | |
| | | private String glassInIdOne = ""; |
| | | private String glassInIdTwo = ""; |
| | | private String glassIdOne = ""; |
| | | private String glassIdTwo = ""; |
| | | |
| | | // @Scheduled(fixedDelay = Long.MAX_VALUE) |
| | | // @Scheduled(fixedDelay = Long.MAX_VALUE) |
| | | // public void startOneOpcTask() throws Exception { |
| | | // miloService.subscriptionFromOpcUa(Arrays.asList("mes.WL1.edg_storage_device_one_task[1].task_state"), cacheGlassStartCallback); |
| | | // } |
| | |
| | | |
| | | private void startOneOpcTaskChild(String tableName, int device) { |
| | | EdgStorageDeviceTask task = edgStorageDeviceTaskService.queryTaskMessage(tableName); |
| | | try { |
| | | // try { |
| | | if (task == null) { |
| | | log.info("任务表基础数据录入失败,请检查数据是否录入成功"); |
| | | return; |
| | |
| | | //防止出片任务且笼前有玻璃的情况,将进片id置空,即出片仅考虑笼内的玻璃 |
| | | task.setGlassIdIn(""); |
| | | } |
| | | int request = task.getTaskState(); |
| | | int request = task.getTaskState(); |
| | | int taskRunning = task.getTaskRunning(); |
| | | log.info("开始执行任务,任务请信息为{}", task); |
| | | if (request == 0) { |
| | | log.info("未收到任务请求,结束本次任务"); |
| | | } else if (request == 1) { |
| | | //进片任务 |
| | | log.info("进片任务:进片玻璃id为:{}", task.getGlassIdIn()); |
| | | if (request == 0) { |
| | | log.info("设备:{}状态:{}", device, request); |
| | | log.info("未收到任务请求,结束本次任务"); |
| | | } else if (request == 1 && taskRunning == 0) { |
| | | //进片任务 |
| | | log.info("设备:{}状态:{}", device, request); |
| | | log.info("进片任务:进片玻璃id为:{}", task.getGlassIdIn()); |
| | | intoTask(task, tableName, device); |
| | | } else if (request == 2 && taskRunning == 0) { |
| | | //出片任务 |
| | | outTask(task, tableName, device); |
| | | } else if (request == 3 && taskRunning == 0) { |
| | | //直通任务 |
| | | log.info("设备:{}状态:{}", device, request); |
| | | if (!outTask(task, tableName, device)) { |
| | | intoTask(task, tableName, device); |
| | | } else if (request == 2) { |
| | | //出片任务 |
| | | outTask(task, tableName, device); |
| | | } else if (request == 3) { |
| | | //直通任务 |
| | | if (!outTask(task, tableName, device)) { |
| | | intoTask(task, tableName, device); |
| | | } |
| | | } else if (request == 4) { |
| | | log.info("将启动子改为0"); |
| | | task.setTaskRunning(Const.GLASS_CACHE_TYPE_RUNNING); |
| | | edgStorageDeviceTaskService.updateTaskMessage(tableName, task); |
| | | } else { |
| | | finishTask(task, tableName); |
| | | } |
| | | } catch (Exception e) { |
| | | log.info("执行任务过程中发生异常,任务字{},{}", task.getTaskState(), e.getMessage()); |
| | | log.info("将启动子改为0"); |
| | | task.setTaskState(Const.GLASS_CACHE_TYPE_EMPTY); |
| | | } else if (request == 4) { |
| | | log.info("设备:{}状态:{}", device, request); |
| | | log.info("将启动子改为4"); |
| | | task.setTaskRunning(Const.GLASS_CACHE_TYPE_RUNNING); |
| | | edgStorageDeviceTaskService.updateTaskMessage(tableName, task); |
| | | } else { |
| | | log.info("设备:{}状态:{}", device, request); |
| | | finishTask(task, tableName); |
| | | } |
| | | // } catch (Exception e) { |
| | | // log.info("执行任务过程中发生异常,任务字{},{}", task.getTaskState(), e.getMessage()); |
| | | // log.info("将启动字改为0"); |
| | | // task.setTaskRunning(Const.GLASS_CACHE_TYPE_EMPTY); |
| | | // edgStorageDeviceTaskService.updateTaskMessage(tableName, task); |
| | | // } |
| | | } |
| | | |
| | | |
| | |
| | | miloService.writeToOpcUa(list); |
| | | miloService.writeToOpcWord(generateReadWriteEntity("MB" + cell + ".MB" + cell + ".thickness", (int) glassInfo.getThickness() * 10)); |
| | | //修改磨边对列中的磨边线路及状态 |
| | | edgGlassTaskQueueInfoService.update(new LambdaUpdateWrapper<EdgGlassTaskQueueInfo>() |
| | | .set(EdgGlassTaskQueueInfo::getLine, cell) |
| | | .set(EdgGlassTaskQueueInfo::getState, Const.EDG_GLASS_START) |
| | | .eq(EdgGlassTaskQueueInfo::getGlassId, glassId) |
| | | .eq(EdgGlassTaskQueueInfo::getState, Const.EDG_GLASS_BEFORE)); |
| | | edgGlassTaskInfoService.update(new LambdaUpdateWrapper<EdgGlassTaskInfo>() |
| | | .set(EdgGlassTaskInfo::getLine, cell) |
| | | .set(EdgGlassTaskInfo::getState, Const.EDG_GLASS_START) |
| | | .set(EdgGlassTaskInfo::getUpdateTime, new Date()) |
| | | .eq(EdgGlassTaskInfo::getGlassId, glassId) |
| | | .eq(EdgGlassTaskInfo::getState, Const.EDG_GLASS_BEFORE)); |
| | | if (cell == 1) { |
| | | glassIdOne = glassId; |
| | | } else { |
| | |
| | | } |
| | | |
| | | private boolean intoTask(EdgStorageDeviceTask task, String tableName, int deviceId) { |
| | | Date startDate = new Date(); |
| | | log.info("开始执行进片任务,任务信息为:{},表名为:{},设备id:{},开始时间:{}", task, tableName, deviceId, startDate); |
| | | //获取玻璃的基本信息 |
| | | GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getGlassId, task.getGlassIdIn())); |
| | | if (null == glassInfo) { |
| | | log.info("进片玻璃信息不存在,玻璃id:{}", task.getGlassIdIn()); |
| | | Date endDate = new Date(); |
| | | log.info("结束进片任务设备为{},结束时间为:{},共耗时:{}ms", deviceId, endDate, endDate.getTime() - startDate.getTime()); |
| | | return Boolean.FALSE; |
| | | } |
| | | if (glassInIdOne.equals(task.getGlassIdIn()) || glassInIdTwo.equals(task.getGlassIdIn())) { |
| | | log.info("玻璃id与上次相同,禁止进片"); |
| | | Date endDate = new Date(); |
| | | log.info("结束进片任务设备为{},结束时间为:{},共耗时:{}ms", deviceId, endDate, endDate.getTime() - startDate.getTime()); |
| | | |
| | | return Boolean.FALSE; |
| | | } |
| | | int firstLength = minTwoFirstLength; |
| | | int secondLength = minTwoSecondLength; |
| | | if (deviceId == 1) { |
| | | firstLength = minOneFirstLength; |
| | | secondLength = minOneSecondLength; |
| | | } |
| | | if (Math.max(glassInfo.getWidth(), glassInfo.getHeight()) < firstLength || Math.min(glassInfo.getWidth(), glassInfo.getHeight()) < secondLength) { |
| | | log.info("进片玻璃尺寸小于{}*{},禁止进笼玻璃id:{},尺寸为{}、{}", firstLength, secondLength, task.getGlassIdIn(), glassInfo.getWidth(), glassInfo.getHeight()); |
| | | Date endDate = new Date(); |
| | | log.info("结束进片任务设备为{},结束时间为:{},共耗时:{}ms", deviceId, endDate, endDate.getTime() - startDate.getTime()); |
| | | return Boolean.FALSE; |
| | | } |
| | | //获取当前进片玻璃id和进片格子 相同尺寸可以放下的格子 |
| | |
| | | .ge(EdgStorageCage::getRemainWidth, Math.max(glassInfo.getWidth(), glassInfo.getHeight())).last("order by abs(slot - " + task.getCurrentCell() + ")")); |
| | | if (CollectionUtil.isEmpty(storageCageList) || storageCageList.size() == 1) { |
| | | log.info("没有多余的空格子"); |
| | | Date endDate = new Date(); |
| | | log.info("结束进片任务设备为{},结束时间为:{},共耗时:{}ms", deviceId, endDate, endDate.getTime() - startDate.getTime()); |
| | | return Boolean.FALSE; |
| | | } |
| | | edgStorageCage = storageCageList.get(0); |
| | |
| | | task.setTaskRunning(Const.GLASS_CACHE_TYPE_IN); |
| | | edgStorageDeviceTaskService.updateTaskMessage(tableName, task); |
| | | saveHistoryTask(task, deviceId); |
| | | //记录进片任务的玻璃id用于下次任务的比较,防止同一块玻璃重复执行 |
| | | if (deviceId == 1) { |
| | | glassInIdOne = task.getGlassIdIn(); |
| | | } else { |
| | | glassInIdTwo = task.getGlassIdIn(); |
| | | } |
| | | edgStorageCageService.update(new UpdateWrapper<EdgStorageCage>() |
| | | .setSql("remain_width = remain_width -" + (glassGap + Math.max(details.getWidth(), details.getHeight()))).eq("device_id", deviceId) |
| | | .eq("slot", task.getStartCell())); |
| | | Date endDate = new Date(); |
| | | log.info("结束进片任务设备为{},结束时间为:{},共耗时:{}ms", deviceId, endDate, endDate.getTime() - startDate.getTime()); |
| | | return Boolean.TRUE; |
| | | } |
| | | |
| | | private boolean outTask(EdgStorageDeviceTask task, String tableName, int deviceId) { |
| | | Date startDate = new Date(); |
| | | log.info("开始执行出片/直通任务,任务信息为:{},表名为:{},设备id:{},开始时间:{}", task, tableName, deviceId, startDate); |
| | | EdgStorageCageDetails edgStorageCageDetails = null; |
| | | //笼内是版图相差是否超过阈值 |
| | | boolean flag = queryMaxMinDiff(threshold); |
| | | boolean flag = queryMaxMinDiffByDevice(threshold, deviceId); |
| | | if (flag) { |
| | | EdgStorageCageDetails minEdgDetails = edgStorageCageDetailsService.getOne(new LambdaQueryWrapper<EdgStorageCageDetails>() |
| | | .inSql(EdgStorageCageDetails::getSlot, "select slot from edg_storage_cage where enable_state = " + Const.SLOT_ON) |
| | |
| | | } |
| | | if (edgStorageCageDetails == null && StringUtils.isNotBlank(task.getGlassIdIn())) { |
| | | //和上次任务不存在相同尺寸 |
| | | int firstLength = minTwoFirstLength; |
| | | int secondLength = minTwoSecondLength; |
| | | if (deviceId == 1) { |
| | | firstLength = minOneFirstLength; |
| | | secondLength = minOneSecondLength; |
| | | } |
| | | GlassInfo glassInInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getGlassId, task.getGlassIdIn())); |
| | | if (Math.max(glassInInfo.getWidth(), glassInInfo.getHeight()) < firstLength || Math.min(glassInInfo.getWidth(), glassInInfo.getHeight()) < secondLength) { |
| | | log.info("直通任务进片玻璃尺寸小于{}*{}", firstLength, secondLength); |
| | | return Boolean.FALSE; |
| | | } |
| | | edgStorageCageDetails = new EdgStorageCageDetails(); |
| | | BeanUtils.copyProperties(glassInInfo, edgStorageCageDetails); |
| | | } |
| | |
| | | return Boolean.FALSE; |
| | | } |
| | | log.info("5、直通任务,将玻璃信息插入卧式理片笼,当前玻璃信息:{}", edgStorageCageDetails); |
| | | if (glassInIdOne.equals(task.getGlassIdIn()) || glassInIdTwo.equals(task.getGlassIdIn())) { |
| | | log.info("玻璃id与上次相同,禁止进片"); |
| | | return Boolean.FALSE; |
| | | } |
| | | //玻璃信息替换 |
| | | String glassIdChange = queryAndChangeGlass(glassId); |
| | | //处理在卧理内的玻璃信息:笼内的数据处理 |
| | |
| | | |
| | | edgStorageDeviceTaskService.updateTaskMessage(tableName, task); |
| | | saveHistoryTask(task, deviceId); |
| | | //记录直通任务的玻璃id用于下次任务的比较,防止同一块玻璃重复执行 |
| | | if (3 == task.getTaskState()) { |
| | | if (deviceId == 1) { |
| | | glassInIdOne = edgStorageCageDetails.getGlassId(); |
| | | } else { |
| | | glassInIdTwo = edgStorageCageDetails.getGlassId(); |
| | | } |
| | | } |
| | | //更新详情表任务出片中 |
| | | edgStorageCageDetailsService.update(new LambdaUpdateWrapper<EdgStorageCageDetails>() |
| | | .set(EdgStorageCageDetails::getState, Const.GLASS_STATE_OUT) |
| | | .eq(EdgStorageCageDetails::getGlassId, edgStorageCageDetails.getGlassId())); |
| | | //磨边对列表新增一条数据 |
| | | EdgGlassTaskQueueInfo edgInfo = new EdgGlassTaskQueueInfo(); |
| | | BeanUtils.copyProperties(task, edgInfo); |
| | | edgInfo.setGlassId(edgStorageCageDetails.getGlassId()); |
| | | edgInfo.setCreateTime(new Date()); |
| | | edgInfo.setWidth((int) edgStorageCageDetails.getWidth()); |
| | | edgInfo.setHeight((int) edgStorageCageDetails.getHeight()); |
| | | edgInfo.setThickness((int) edgStorageCageDetails.getThickness()); |
| | | edgInfo.setState(Const.EDG_GLASS_BEFORE); |
| | | edgGlassTaskQueueInfoService.save(edgInfo); |
| | | saveGlassSize(edgStorageCageDetails); |
| | | // edgStorageCageService.update(new UpdateWrapper<EdgStorageCage>() |
| | | // .setSql("remain_width = remain_width +" + Math.max(edgStorageCageDetails.getWidth(), edgStorageCageDetails.getHeight())) |
| | | // .eq("device_id", deviceId) |
| | | // .eq("slot", task.getStartCell())); |
| | | Date endDate = new Date(); |
| | | log.info("结束出片/直通任务设备为{},结束时间为:{},共耗时:{}ms", deviceId, endDate, endDate.getTime() - startDate.getTime()); |
| | | return Boolean.TRUE; |
| | | } |
| | | |
| | | private boolean finishTask(EdgStorageDeviceTask task, String tableName) { |
| | | log.info("当前任务信息为:{}", task); |
| | | if (task.getTaskState() <= 4 && task.getTaskRunning() == 0) { |
| | | if (task.getTaskState() <= 4) { |
| | | log.info("有正在执行的任务或这任务已执行任务状态{},任务启动情况{},结束", task.getTaskState(), task.getTaskRunning()); |
| | | return Boolean.FALSE; |
| | | } |
| | | Date startDate = new Date(); |
| | | log.info("开始执行完成任务后清除动作,任务信息为:{},表名为:{},开始时间:{}", task, tableName, startDate); |
| | | Integer cell = task.getStartCell(); |
| | | Integer state = task.getTaskState(); |
| | | task.setTaskRunning(Const.GLASS_CACHE_TYPE_EMPTY); |
| | | String glassIdOut = task.getGlassIdOut(); |
| | | task.setGlassIdOut(""); |
| | | task.setStartCell(0); |
| | | edgStorageDeviceTaskService.updateTaskMessage(tableName, task); |
| | | |
| | | EdgStorageDeviceTaskHistory taskHistory = edgStorageDeviceTaskHistoryService.getOne(new LambdaQueryWrapper<EdgStorageDeviceTaskHistory>() |
| | | .eq(EdgStorageDeviceTaskHistory::getTaskState, Const.RAW_GLASS_TASK_NEW) |
| | | .orderByDesc(EdgStorageDeviceTaskHistory::getCreateTime).last("limit 1")); |
| | | int device = tableName.equals("edg_storage_device_one_task") ? 1 : 2; |
| | | updateCellRemainWidth(cell, device, taskHistory); |
| | | edgStorageDeviceTaskHistoryService.update(new LambdaUpdateWrapper<EdgStorageDeviceTaskHistory>() |
| | | .eq(EdgStorageDeviceTaskHistory::getTaskState, Const.RAW_GLASS_TASK_NEW) |
| | | .set(EdgStorageDeviceTaskHistory::getTaskState, |
| | | Const.GLASS_CACHE_TYPE_FINISH.equals(state) ? Const.RAW_GLASS_TASK_SUCCESS : Const.RAW_GLASS_TASK_FAILURE) |
| | | ); |
| | | int device = tableName.equals("edg_storage_device_one_task") ? 1 : 2; |
| | | updateCellRemainWidth(cell, device, taskHistory); |
| | | //最后更新任务,保证任务前的动作都做完 |
| | | edgStorageDeviceTaskService.updateTaskMessage(tableName, task); |
| | | Date endDate = new Date(); |
| | | log.info("结束完成任务后清除动作,表名为:{},结束时间为:{},共耗时:{}ms", tableName, endDate, endDate.getTime() - startDate.getTime()); |
| | | return Boolean.TRUE; |
| | | } |
| | | |
| | |
| | | * |
| | | * @return |
| | | */ |
| | | public boolean queryMaxMinDiff(int threshold) { |
| | | public boolean queryMaxMinDiffByDevice(int threshold, int deviceId) { |
| | | //获取笼子内最大版图id和最小版图id插值,判断是否大于阈值,大于阈值直接出最小版图玻璃 |
| | | QueryWrapper<EdgStorageCageDetails> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.select("max(tempering_layout_id)-min(tempering_layout_id) as diff") |
| | | .eq("state", Const.GLASS_STATE_IN) |
| | | .eq("device_id", deviceId) |
| | | .inSql("slot", "select slot from edg_storage_cage where enable_state = " + Const.SLOT_ON); |
| | | List<Object> list = edgStorageCageDetailsService.listObjs(queryWrapper); |
| | | //获取笼内玻璃版图差值是否大于阈值 |
| | |
| | | .eq(EdgStorageCage::getDeviceId, device).eq(EdgStorageCage::getSlot, slot)); |
| | | EdgStorageCageDetails bigDetails = list.stream().filter(e -> e.getGlassId().equals(taskHistory.getGlassIdIn())).findFirst().orElse(null); |
| | | remainWidth = storageCage.getRemainWidth() - glassGap - (int) Math.max(bigDetails.getWidth(), bigDetails.getHeight()); |
| | | if (remainWidth <= 0) { |
| | | remainWidth = 0; |
| | | } |
| | | } |
| | | } |
| | | edgStorageCageService.update(new LambdaUpdateWrapper<EdgStorageCage>(). |
| | |
| | | return Boolean.TRUE; |
| | | } |
| | | |
| | | private boolean saveGlassSize(EdgStorageCageDetails glassInfo) { |
| | | EdgGlassTaskInfo edgGlassTaskInfo = new EdgGlassTaskInfo(); |
| | | BeanUtils.copyProperties(glassInfo, edgGlassTaskInfo); |
| | | edgGlassTaskInfo.setHeight((int) (glassInfo.getHeight() * ratio)); |
| | | edgGlassTaskInfo.setWidth((int) (glassInfo.getWidth() * ratio)); |
| | | edgGlassTaskInfo.setThickness((int) (glassInfo.getThickness() * ratio)); |
| | | edgGlassTaskInfo.setState(Const.EDG_GLASS_BEFORE); |
| | | edgGlassTaskInfo.setCreateTime(new Date()); |
| | | edgGlassTaskInfo.setUpdateTime(new Date()); |
| | | //先将历史对列表中本玻璃的数据删除,重新新增一份最新的数据 |
| | | edgGlassTaskInfoService.remove(new LambdaQueryWrapper<EdgGlassTaskInfo>().eq(EdgGlassTaskInfo::getGlassId, glassInfo.getGlassId())); |
| | | return edgGlassTaskInfoService.save(edgGlassTaskInfo); |
| | | } |
| | | |
| | | private ReadWriteEntity generateReadWriteEntity(String identifier, Object value) { |
| | | return ReadWriteEntity.builder() |
| | | .identifier(identifier) |
| | |
| | | return Result.build(200, "查询成功", bigStorageCageDetailsService.selectTemperingGlass()); |
| | | } |
| | | |
| | | @ApiOperation("是否调度开关") |
| | | @PostMapping("/dispatchSwitch") |
| | | public Result dispatchSwitch(Boolean flag) { |
| | | bigStorageCageDetailsService.dispatchSwitch(flag); |
| | | return Result.build(200, "修改成功", redisUtil.getCacheObject("dispatchSwitch")); |
| | | } |
| | | |
| | | @ApiOperation("是否钢化开关") |
| | | @PostMapping("/temperingSwitch") |
| | | public Result temperingSwitch(Boolean flag) { |
New file |
| | |
| | | package com.mes.bigstorage.controller; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | | * (BigStorageGlassInfo)表控制层 |
| | | * |
| | | * @author makejava |
| | | * @since 2024-11-24 10:15:34 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("bigStorageGlassInfo") |
| | | public class BigStorageGlassInfoController { |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.mes.bigstorage.controller; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | | * (BigStorageGlassRelationInfo)表控制层 |
| | | * |
| | | * @author makejava |
| | | * @since 2024-11-24 10:17:42 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("bigStorageGlassRelationInfo") |
| | | public class BigStorageGlassRelationInfoController { |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.mes.bigstorage.entity; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * (BigStorageGlassInfo)表实体类 |
| | | * |
| | | * @author makejava |
| | | * @since 2024-11-24 10:15:35 |
| | | */ |
| | | @Data |
| | | public class BigStorageGlassInfo { |
| | | /** |
| | | * /*大理片笼信息表id |
| | | */ |
| | | private Long id; |
| | | /** |
| | | * /*玻璃id |
| | | */ |
| | | private String glassId; |
| | | /** |
| | | * /*流程卡号 |
| | | */ |
| | | private String flowCardId; |
| | | /** |
| | | * /*玻璃类型 |
| | | */ |
| | | private Integer glassType; |
| | | /** |
| | | * /*宽 |
| | | */ |
| | | private Double width; |
| | | /** |
| | | * /*高 |
| | | */ |
| | | private Double height; |
| | | /** |
| | | * /*厚度 |
| | | */ |
| | | private Double thickness; |
| | | /** |
| | | * /*钢化版图id |
| | | */ |
| | | private Integer temperingLayoutId; |
| | | /** |
| | | * /*钢化版图片序 |
| | | */ |
| | | private Integer temperingFeedSequence; |
| | | /** |
| | | * /*x坐标 |
| | | */ |
| | | private Integer xCoordinate; |
| | | /** |
| | | * /*y坐标 |
| | | */ |
| | | private Integer yCoordinate; |
| | | |
| | | private String engineerId; |
| | | /** |
| | | * /*层号 |
| | | */ |
| | | private Integer layer; |
| | | /** |
| | | * /*虚拟格子号 |
| | | */ |
| | | private Integer virtualSlot; |
| | | /** |
| | | * /*格子次序 |
| | | */ |
| | | private Integer slotSequence; |
| | | |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.mes.bigstorage.entity; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * (BigStorageGlassRelationInfo)表实体类 |
| | | * |
| | | * @author makejava |
| | | * @since 2024-11-24 10:17:43 |
| | | */ |
| | | @Data |
| | | public class BigStorageGlassRelationInfo { |
| | | /** |
| | | * /*钢化玻璃关系表id |
| | | */ |
| | | private Long id; |
| | | |
| | | private String engineerId; |
| | | /** |
| | | * /*玻璃id |
| | | */ |
| | | private String glassId; |
| | | /** |
| | | * /*钢化版图id |
| | | */ |
| | | private Integer temperingLayoutId; |
| | | /** |
| | | * /*钢化版图片序 |
| | | */ |
| | | private Integer temperingFeedSequence; |
| | | /** |
| | | * /*虚拟格子 |
| | | */ |
| | | private Integer virtualSlot; |
| | | /** |
| | | * /*格子内次序 |
| | | */ |
| | | private Integer slotSequence; |
| | | /** |
| | | * /*实际笼子号 |
| | | */ |
| | | private Integer deviceId; |
| | | /** |
| | | * /*实际格子号 |
| | | */ |
| | | private Integer slot; |
| | | |
| | | |
| | | } |
| | | |
File was renamed from hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/bigstorage/entity/BigStorageDTO.java |
| | |
| | | package com.mes.bigstorage.entity; |
| | | package com.mes.bigstorage.entity.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | |
| | | * 笼子号 |
| | | */ |
| | | private Integer deviceId; |
| | | /** |
| | | * 序号 |
| | | */ |
| | | private Integer slotSequence; |
| | | } |
New file |
| | |
| | | package com.mes.bigstorage.entity.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2024/11/25 18:53 |
| | | * @Description: |
| | | */ |
| | | @Data |
| | | public class BigStorageRelationDTO { |
| | | |
| | | |
| | | private String engineerId; |
| | | /** |
| | | * /*钢化版图id |
| | | */ |
| | | private Integer temperingLayoutId; |
| | | /** |
| | | * /*虚拟格子 |
| | | */ |
| | | private Integer virtualSlot; |
| | | |
| | | } |
New file |
| | |
| | | package com.mes.bigstorage.entity.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @Author : zhoush |
| | | * @Date: 2024/11/25 18:53 |
| | | * @Description: |
| | | */ |
| | | @Data |
| | | public class BigStorageSequenceDTO { |
| | | |
| | | private Integer slot; |
| | | private Integer maxSequence; |
| | | private Integer minSequence; |
| | | |
| | | } |
| | |
| | | |
| | | import com.github.yulichang.base.MPJBaseMapper; |
| | | import com.mes.bigstorage.entity.BigStorageCageDetails; |
| | | import com.mes.bigstorage.entity.dto.BigStorageRelationDTO; |
| | | import com.mes.bigstorage.entity.dto.BigStorageSequenceDTO; |
| | | import com.mes.bigstorage.entity.dto.SlotSequenceDTO; |
| | | import com.mes.bigstorage.entity.dto.TemperingLayoutDTO; |
| | | import com.mes.bigstoragetask.entity.UpdateBigStorageCageDTO; |
| | |
| | | void updateBySlot(@Param(value = "list") List<UpdateBigStorageCageDTO> glassList, @Param(value = "state") int state); |
| | | |
| | | List<Map<String, Object>> selectTemperingGlassCount(); |
| | | |
| | | List<BigStorageRelationDTO> queryIsAllNeedDispatchVirtualSlot(); |
| | | |
| | | List<BigStorageSequenceDTO> queryNeedDispatchSlot(BigStorageRelationDTO bigStorageRelationDTO); |
| | | } |
New file |
| | |
| | | package com.mes.bigstorage.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.mes.bigstorage.entity.BigStorageGlassInfo; |
| | | |
| | | /** |
| | | * (BigStorageGlassInfo)表数据库访问层 |
| | | * |
| | | * @author makejava |
| | | * @since 2024-11-24 10:15:34 |
| | | */ |
| | | public interface BigStorageGlassInfoMapper extends BaseMapper<BigStorageGlassInfo> { |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.mes.bigstorage.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.mes.bigstorage.entity.BigStorageGlassRelationInfo; |
| | | |
| | | /** |
| | | * (BigStorageGlassRelationInfo)表数据库访问层 |
| | | * |
| | | * @author makejava |
| | | * @since 2024-11-24 10:17:43 |
| | | */ |
| | | public interface BigStorageGlassRelationInfoMapper extends BaseMapper<BigStorageGlassRelationInfo> { |
| | | |
| | | } |
| | | |
| | |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.mes.bigstorage.entity.BigStorageCageDetails; |
| | | import com.mes.bigstorage.entity.BigStorageDTO; |
| | | import com.mes.bigstorage.entity.dto.SlotSequenceDTO; |
| | | import com.mes.bigstorage.entity.dto.TemperingLayoutDTO; |
| | | import com.mes.bigstorage.entity.dto.*; |
| | | import com.mes.bigstoragetask.entity.UpdateBigStorageCageDTO; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | | |
| | |
| | | String temperingSwitch(Boolean flag); |
| | | |
| | | void appointEngineerId(String engineerId); |
| | | |
| | | List<BigStorageRelationDTO> queryIsAllNeedDispatchVirtualSlot(); |
| | | |
| | | List<BigStorageSequenceDTO> dispatchBigStorageGlassInfo(BigStorageRelationDTO bigStorageRelationDTO); |
| | | |
| | | String dispatchSwitch(Boolean flag); |
| | | } |
New file |
| | |
| | | package com.mes.bigstorage.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.mes.bigstorage.entity.BigStorageGlassInfo; |
| | | import com.mes.bigstorage.entity.dto.BigStorageDTO; |
| | | |
| | | /** |
| | | * (BigStorageGlassInfo)表服务接口 |
| | | * |
| | | * @author makejava |
| | | * @since 2024-11-24 10:15:35 |
| | | */ |
| | | public interface BigStorageGlassInfoService extends IService<BigStorageGlassInfo> { |
| | | |
| | | /** |
| | | * 按照玻璃id获取中空目标格子 |
| | | * |
| | | * @return |
| | | */ |
| | | BigStorageDTO queryBigStorageTargetSlot(String glassId); |
| | | |
| | | /** |
| | | * 生成中空玻璃信息 |
| | | */ |
| | | void generateBigStorageGlassInfo(String glassId); |
| | | |
| | | /** |
| | | * 格子配对 |
| | | * |
| | | * @param bigStorageGlassInfo |
| | | * @return |
| | | */ |
| | | int bigStorageSlotPair(BigStorageGlassInfo bigStorageGlassInfo); |
| | | } |
| | | |
New file |
| | |
| | | package com.mes.bigstorage.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.mes.bigstorage.entity.BigStorageGlassRelationInfo; |
| | | |
| | | /** |
| | | * (BigStorageGlassRelationInfo)表服务接口 |
| | | * |
| | | * @author makejava |
| | | * @since 2024-11-24 10:17:43 |
| | | */ |
| | | public interface BigStorageGlassRelationInfoService extends IService<BigStorageGlassRelationInfo> { |
| | | |
| | | } |
| | | |
| | |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import com.mes.bigstorage.entity.BigStorageCage; |
| | | import com.mes.bigstorage.entity.BigStorageCageDetails; |
| | | import com.mes.bigstorage.entity.BigStorageDTO; |
| | | import com.mes.bigstorage.entity.dto.SlotSequenceDTO; |
| | | import com.mes.bigstorage.entity.dto.TemperingLayoutDTO; |
| | | import com.mes.bigstorage.entity.dto.*; |
| | | import com.mes.bigstorage.mapper.BigStorageCageDetailsMapper; |
| | | import com.mes.bigstorage.service.BigStorageCageDetailsService; |
| | | import com.mes.bigstorage.service.BigStorageCageService; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public String dispatchSwitch(Boolean flag) { |
| | | redisUtil.setCacheObject("dispatchSwitch", flag); |
| | | return "success"; |
| | | } |
| | | |
| | | @Override |
| | | public String temperingSwitch(Boolean flag) { |
| | | redisUtil.setCacheObject("temperingSwitch", flag); |
| | | return "success"; |
| | |
| | | public void appointEngineerId(String engineerId) { |
| | | redisUtil.setCacheObject("temperingengineerId", engineerId); |
| | | } |
| | | |
| | | @Override |
| | | public List<BigStorageRelationDTO> queryIsAllNeedDispatchVirtualSlot() { |
| | | return baseMapper.queryIsAllNeedDispatchVirtualSlot(); |
| | | } |
| | | |
| | | @Override |
| | | public List<BigStorageSequenceDTO> dispatchBigStorageGlassInfo(BigStorageRelationDTO bigStorageRelationDTO) { |
| | | return baseMapper.queryNeedDispatchSlot(bigStorageRelationDTO); |
| | | } |
| | | } |
New file |
| | |
| | | package com.mes.bigstorage.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.lang.Assert; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.mes.bigstorage.entity.BigStorageCage; |
| | | import com.mes.bigstorage.entity.BigStorageCageDetails; |
| | | import com.mes.bigstorage.entity.BigStorageGlassInfo; |
| | | import com.mes.bigstorage.entity.BigStorageGlassRelationInfo; |
| | | import com.mes.bigstorage.entity.dto.BigStorageDTO; |
| | | import com.mes.bigstorage.entity.dto.BigStorageRelationDTO; |
| | | import com.mes.bigstorage.entity.dto.BigStorageSequenceDTO; |
| | | import com.mes.bigstorage.mapper.BigStorageGlassInfoMapper; |
| | | import com.mes.bigstorage.service.BigStorageCageDetailsService; |
| | | import com.mes.bigstorage.service.BigStorageCageService; |
| | | import com.mes.bigstorage.service.BigStorageGlassInfoService; |
| | | import com.mes.bigstorage.service.BigStorageGlassRelationInfoService; |
| | | import com.mes.common.config.Const; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | | import com.mes.glassinfo.service.GlassInfoService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * (BigStorageGlassInfo)表服务实现类 |
| | | * |
| | | * @author makejava |
| | | * @since 2024-11-24 10:15:35 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class BigStorageGlassInfoServiceImpl extends ServiceImpl<BigStorageGlassInfoMapper, BigStorageGlassInfo> implements BigStorageGlassInfoService { |
| | | @Resource |
| | | GlassInfoService glassInfoService; |
| | | @Resource |
| | | BigStorageCageService bigStorageCageService; |
| | | @Resource |
| | | BigStorageCageDetailsService bigStorageCageDetailsService; |
| | | @Resource |
| | | BigStorageGlassRelationInfoService bigStorageGlassRelationInfoService; |
| | | @Value("${mes.slotWidth}") |
| | | private Integer slotWidth; |
| | | @Value("${mes.glassGap}") |
| | | private Integer glassGap; |
| | | |
| | | @Override |
| | | public BigStorageDTO queryBigStorageTargetSlot(String glassId) { |
| | | //按照玻璃信息获取关系表是否有对应的关系 |
| | | BigStorageGlassRelationInfo relationInfoOne = bigStorageGlassRelationInfoService.getOne(new LambdaQueryWrapper<BigStorageGlassRelationInfo>() |
| | | .eq(BigStorageGlassRelationInfo::getGlassId, glassId)); |
| | | if (relationInfoOne == null) { |
| | | //理片笼关系表中没有对应的数据,查看理片笼虚拟位置表是否有本工程下的所有玻璃虚拟信息 |
| | | BigStorageGlassInfo bigStorageGlassInfo = this.getOne(new LambdaQueryWrapper<BigStorageGlassInfo>().eq(BigStorageGlassInfo::getGlassId, glassId)); |
| | | if (null == bigStorageGlassInfo) { |
| | | //虚拟位置表没有本工程下的所有玻璃虚拟信息,按照玻璃id生成本工程下所有玻璃的虚拟信息 |
| | | generateBigStorageGlassInfo(glassId); |
| | | bigStorageGlassInfo = this.getOne(new LambdaQueryWrapper<BigStorageGlassInfo>().eq(BigStorageGlassInfo::getGlassId, glassId)); |
| | | } |
| | | //按照虚拟位置和大理片笼现有可用格子生成关系表 |
| | | bigStorageSlotPair(bigStorageGlassInfo); |
| | | //关系表获取实际位置 |
| | | relationInfoOne = bigStorageGlassRelationInfoService.getOne(new LambdaQueryWrapper<BigStorageGlassRelationInfo>() |
| | | .eq(BigStorageGlassRelationInfo::getGlassId, glassId)); |
| | | } |
| | | BigStorageCageDetails bigStorageCageDetails = bigStorageCageDetailsService.getOne(new LambdaQueryWrapper<BigStorageCageDetails>() |
| | | .eq(BigStorageCageDetails::getSlot, relationInfoOne.getSlot()).in(BigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL_ZERO) |
| | | .orderByDesc(BigStorageCageDetails::getSequence).last("limit 1")); |
| | | if (null == bigStorageCageDetails) { |
| | | BigStorageDTO storageDTO = new BigStorageDTO(); |
| | | storageDTO.setDeviceId(relationInfoOne.getDeviceId()); |
| | | storageDTO.setSlot(relationInfoOne.getSlot()); |
| | | storageDTO.setSlotSequence(relationInfoOne.getSlotSequence()); |
| | | storageDTO.setWidth(slotWidth); |
| | | return storageDTO; |
| | | } |
| | | BigStorageGlassRelationInfo relationInfoBefore = bigStorageGlassRelationInfoService.getOne(new LambdaQueryWrapper<BigStorageGlassRelationInfo>() |
| | | .eq(BigStorageGlassRelationInfo::getEngineerId, relationInfoOne.getEngineerId()) |
| | | .eq(BigStorageGlassRelationInfo::getTemperingLayoutId, relationInfoOne.getTemperingLayoutId()) |
| | | .eq(BigStorageGlassRelationInfo::getVirtualSlot, relationInfoOne.getVirtualSlot()) |
| | | .eq(BigStorageGlassRelationInfo::getSlotSequence, relationInfoOne.getSlotSequence() - 1)); |
| | | BigStorageCage storageCage = null; |
| | | if (null == relationInfoBefore) { |
| | | //表示序号没有或者 序号为1又不是第一块来的 新开一格 |
| | | storageCage = bigStorageCageService.getOne(new LambdaQueryWrapper<BigStorageCage>() |
| | | .eq(BigStorageCage::getEnableState, Const.SLOT_ON).eq(BigStorageCage::getRemainWidth, slotWidth).last("limit 1")); |
| | | } else { |
| | | BigStorageCageDetails beforeGlass = bigStorageCageDetailsService.getOne(new LambdaQueryWrapper<BigStorageCageDetails>() |
| | | .in(BigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL_ZERO).eq(BigStorageCageDetails::getGlassId, relationInfoBefore.getGlassId()) |
| | | ); |
| | | if (null == beforeGlass) { |
| | | storageCage = bigStorageCageService.getOne(new LambdaQueryWrapper<BigStorageCage>() |
| | | .eq(BigStorageCage::getEnableState, Const.SLOT_ON).eq(BigStorageCage::getRemainWidth, slotWidth).last("limit 1")); |
| | | } else { |
| | | storageCage = bigStorageCageService.getOne(new LambdaQueryWrapper<BigStorageCage>() |
| | | .eq(BigStorageCage::getEnableState, Const.SLOT_ON).eq(BigStorageCage::getSlot, beforeGlass.getSlot())); |
| | | } |
| | | } |
| | | Assert.isTrue(null != storageCage, "没有空余的笼子存放玻璃"); |
| | | BigStorageDTO storageDTO = new BigStorageDTO(); |
| | | storageDTO.setDeviceId(storageCage.getDeviceId()); |
| | | storageDTO.setSlotSequence(relationInfoOne.getSlotSequence()); |
| | | storageDTO.setSlot(storageCage.getSlot()); |
| | | storageDTO.setWidth(storageCage.getRemainWidth()); |
| | | return storageDTO; |
| | | } |
| | | |
| | | public void dispatchBigStorageSlot() { |
| | | //todo:获取笼内单格已经到齐的玻璃格子信息 |
| | | List<BigStorageRelationDTO> virtualList = bigStorageCageDetailsService.queryIsAllNeedDispatchVirtualSlot(); |
| | | if (CollectionUtil.isEmpty(virtualList)) { |
| | | log.info("没有需要调度的格子"); |
| | | } |
| | | for (BigStorageRelationDTO dto : virtualList) { |
| | | List<BigStorageSequenceDTO> sequenceDTOList = bigStorageCageDetailsService.dispatchBigStorageGlassInfo(dto); |
| | | if (CollectionUtil.isEmpty(sequenceDTOList) || sequenceDTOList.size() == 1) { |
| | | continue; |
| | | } |
| | | int sequence = 0; |
| | | int startSlot = 0; |
| | | int targetSlot = 0; |
| | | for (BigStorageSequenceDTO item : sequenceDTOList) { |
| | | if (item.getMinSequence() == sequence + 1) { |
| | | //生成调度任务 |
| | | startSlot = item.getSlot(); |
| | | break; |
| | | } |
| | | sequence = item.getMaxSequence(); |
| | | targetSlot = item.getSlot(); |
| | | } |
| | | } |
| | | // |
| | | } |
| | | |
| | | @Override |
| | | public void generateBigStorageGlassInfo(String glassId) { |
| | | GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getGlassId, glassId)); |
| | | List<BigStorageGlassInfo> list = this.list(new LambdaQueryWrapper<BigStorageGlassInfo>() |
| | | .eq(BigStorageGlassInfo::getEngineerId, glassInfo.getEngineerId()).eq(BigStorageGlassInfo::getTemperingLayoutId, glassInfo.getTemperingLayoutId())); |
| | | if (CollectionUtil.isNotEmpty(list)) { |
| | | return; |
| | | } |
| | | // Engineering engineering = engineeringMapper.selectOne(new LambdaQueryWrapper<Engineering>() |
| | | // .eq(Engineering::getEngineerId, glassInfo.getEngineerId())); |
| | | //获取玻璃的工程id,按照工程id获取工程下的所有玻璃信息 |
| | | List<GlassInfo> glassInfoList = glassInfoService.list(new LambdaQueryWrapper<GlassInfo>() |
| | | .eq(GlassInfo::getEngineerId, glassInfo.getEngineerId()) |
| | | .orderByAsc(GlassInfo::getTemperingLayoutId).orderByAsc(GlassInfo::getTemperingFeedSequence)); |
| | | Map<Integer, List<GlassInfo>> trmperingIdMap = glassInfoList.stream().collect(Collectors.groupingBy(GlassInfo::getTemperingLayoutId)); |
| | | List<BigStorageGlassInfo> bigStorageGlassInfoList = new ArrayList<>(); |
| | | //方式一:将玻璃按版图、版序 依次生成虚拟格子信息,格子一直往后累加 |
| | | trmperingIdMap.forEach((e, v) -> { |
| | | int remainWidth = slotWidth; |
| | | int slotNumber = 1; |
| | | int slotSequence = 1; |
| | | for (GlassInfo item : v) { |
| | | int maxLength = (int) Math.max(item.getWidth(), item.getHeight()); |
| | | if (remainWidth > maxLength) { |
| | | remainWidth = remainWidth - maxLength - glassGap; |
| | | } else { |
| | | slotNumber = slotNumber + 1; |
| | | slotSequence = 1; |
| | | remainWidth = slotWidth - maxLength - glassGap; |
| | | } |
| | | BigStorageGlassInfo bigStorage = new BigStorageGlassInfo(); |
| | | BeanUtils.copyProperties(item, bigStorage); |
| | | bigStorage.setVirtualSlot(slotNumber); |
| | | bigStorage.setSlotSequence(slotSequence++); |
| | | bigStorage.setId(null); |
| | | bigStorageGlassInfoList.add(bigStorage); |
| | | } |
| | | }); |
| | | this.saveBatch(bigStorageGlassInfoList); |
| | | log.info("分配完毕"); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public int bigStorageSlotPair(BigStorageGlassInfo bigStorageGlassInfo) { |
| | | //获取所有空闲可用的格子号 |
| | | BigStorageCage storageCage = bigStorageCageService.getOne(new LambdaQueryWrapper<BigStorageCage>() |
| | | .eq(BigStorageCage::getEnableState, Const.SLOT_ON).eq(BigStorageCage::getRemainWidth, slotWidth).last("limit 1")); |
| | | Assert.isTrue(null != storageCage, "没有空余的笼子存放玻璃"); |
| | | Integer slot = storageCage.getSlot(); |
| | | //获取该工程同一流程卡同一车的玻璃信息 |
| | | List<BigStorageGlassInfo> bigStorageGlassInfoList = this.list(new LambdaQueryWrapper<BigStorageGlassInfo>() |
| | | .eq(BigStorageGlassInfo::getEngineerId, bigStorageGlassInfo.getEngineerId()) |
| | | .eq(BigStorageGlassInfo::getTemperingLayoutId, bigStorageGlassInfo.getTemperingLayoutId()) |
| | | .eq(BigStorageGlassInfo::getVirtualSlot, bigStorageGlassInfo.getVirtualSlot())); |
| | | //设置关系表的实际格子号 |
| | | List<BigStorageGlassRelationInfo> relationInfoList = bigStorageGlassInfoList.stream().map(e -> { |
| | | BigStorageGlassRelationInfo info = new BigStorageGlassRelationInfo(); |
| | | BeanUtils.copyProperties(e, info); |
| | | info.setSlot(slot); |
| | | info.setDeviceId(storageCage.getDeviceId()); |
| | | return info; |
| | | }).collect(Collectors.toList()); |
| | | //保存关系表 |
| | | bigStorageGlassRelationInfoService.saveBatch(relationInfoList); |
| | | //返回格子信息 |
| | | return slot; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.mes.bigstorage.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.mes.bigstorage.entity.BigStorageGlassRelationInfo; |
| | | import com.mes.bigstorage.mapper.BigStorageGlassRelationInfoMapper; |
| | | import com.mes.bigstorage.service.BigStorageGlassRelationInfoService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * (BigStorageGlassRelationInfo)表服务实现类 |
| | | * |
| | | * @author makejava |
| | | * @since 2024-11-24 10:17:43 |
| | | */ |
| | | @Service |
| | | public class BigStorageGlassRelationInfoServiceImpl extends ServiceImpl<BigStorageGlassRelationInfoMapper, BigStorageGlassRelationInfo> implements BigStorageGlassRelationInfoService { |
| | | |
| | | } |
| | | |
| | |
| | | |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.github.yulichang.base.MPJBaseMapper; |
| | | import com.mes.bigstorage.entity.BigStorageDTO; |
| | | import com.mes.bigstorage.entity.dto.BigStorageDTO; |
| | | import com.mes.bigstoragetask.entity.BigStorageCageFeedTask; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | |
| | | package com.mes.bigstoragetask.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.github.yulichang.base.MPJBaseService; |
| | | import com.mes.bigstorage.entity.BigStorageCageDetails; |
| | | import com.mes.bigstorage.entity.BigStorageDTO; |
| | | import com.mes.bigstorage.entity.dto.BigStorageDTO; |
| | | import com.mes.bigstoragetask.entity.BigStorageCageFeedTask; |
| | | |
| | | import java.util.List; |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.mes.bigstorage.entity.BigStorageCageDetails; |
| | | import com.mes.bigstorage.entity.BigStorageDTO; |
| | | import com.mes.bigstorage.entity.dto.BigStorageDTO; |
| | | import com.mes.bigstoragetask.entity.BigStorageCageFeedTask; |
| | | import com.mes.bigstoragetask.mapper.BigStorageCageFeedTaskMapper; |
| | | import com.mes.bigstoragetask.service.BigStorageCageFeedTaskService; |
New file |
| | |
| | | package com.mes.hollow.controller; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | | * (HollowGlassRelationInfo)表控制层 |
| | | * |
| | | * @author makejava |
| | | * @since 2024-11-23 15:59:27 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("hollowGlassRelationInfo") |
| | | public class HollowGlassRelationInfoController { |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.mes.hollow.entity; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * (HollowGlassInfo)表实体类 |
| | | * |
| | | * @author makejava |
| | | * @since 2024-11-22 17:49:40 |
| | | */ |
| | | @Data |
| | | public class HollowGlassInfo { |
| | | /** |
| | | * /*玻璃信息表id |
| | | */ |
| | | private Long id; |
| | | /** |
| | | * /*流程卡 |
| | | */ |
| | | private String flowCardId; |
| | | /** |
| | | * /*流程卡玻璃类型 |
| | | */ |
| | | private Integer glassType; |
| | | /** |
| | | * /*宽 |
| | | */ |
| | | private Double width; |
| | | /** |
| | | * /*高 |
| | | */ |
| | | private Double height; |
| | | /** |
| | | * /*厚度 |
| | | */ |
| | | private Double thickness; |
| | | /** |
| | | * /*膜系 |
| | | */ |
| | | private String filmsid; |
| | | /** |
| | | * /*总层数 |
| | | */ |
| | | private Integer totalLayer; |
| | | /** |
| | | * /*层数 |
| | | */ |
| | | private Integer layer; |
| | | |
| | | /** |
| | | * /*是否配片 |
| | | */ |
| | | private Integer ismultiple; |
| | | /** |
| | | * /*配片最大宽 |
| | | */ |
| | | private Double maxWidth; |
| | | /** |
| | | * /*配片最大高 |
| | | */ |
| | | private Double maxHeight; |
| | | |
| | | /** |
| | | * /*钢化版图id |
| | | */ |
| | | private Integer temperingLayoutId; |
| | | /** |
| | | * /*钢化版图片序 |
| | | */ |
| | | private Integer temperingFeedSequence; |
| | | |
| | | /** |
| | | * /*工程号 |
| | | */ |
| | | private String engineerId; |
| | | |
| | | /** |
| | | * /*玻璃ID |
| | | */ |
| | | private String glassId; |
| | | |
| | | private Integer combine; |
| | | /** |
| | | * /*格子号 |
| | | */ |
| | | private Integer virtualSlot; |
| | | /** |
| | | * /*格子号 |
| | | */ |
| | | private Integer slotSequence; |
| | | |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.mes.hollow.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * (HollowGlassRelationInfo)表实体类 |
| | | * |
| | | * @author makejava |
| | | * @since 2024-11-23 15:59:29 |
| | | */ |
| | | @Data |
| | | public class HollowGlassRelationInfo { |
| | | /** |
| | | * /*中空玻璃关系表id |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | /** |
| | | * /*玻璃ID |
| | | */ |
| | | private String glassId; |
| | | /** |
| | | * /*流程卡 |
| | | */ |
| | | private String flowCardId; |
| | | /** |
| | | * /*总层数 |
| | | */ |
| | | private Integer totalLayer; |
| | | /** |
| | | * /*层数 |
| | | */ |
| | | private Integer layer; |
| | | /** |
| | | * /*虚拟格子号 |
| | | */ |
| | | private Integer virtualSlot; |
| | | /** |
| | | * /*中空格子次序 |
| | | */ |
| | | private Integer slotSequence; |
| | | /** |
| | | * /*格子号 |
| | | */ |
| | | private Integer slot; |
| | | |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.mes.hollow.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.mes.hollow.entity.HollowGlassInfo; |
| | | |
| | | /** |
| | | * (HollowGlassInfo)表数据库访问层 |
| | | * |
| | | * @author makejava |
| | | * @since 2024-11-22 17:49:40 |
| | | */ |
| | | public interface HollowGlassInfoMapper extends BaseMapper<HollowGlassInfo> { |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.mes.hollow.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.mes.hollow.entity.HollowGlassRelationInfo; |
| | | |
| | | /** |
| | | * (HollowGlassRelationInfo)表数据库访问层 |
| | | * |
| | | * @author makejava |
| | | * @since 2024-11-23 15:59:29 |
| | | */ |
| | | public interface HollowGlassRelationInfoMapper extends BaseMapper<HollowGlassRelationInfo> { |
| | | |
| | | } |
| | | |
| | |
| | | //package com.mes.hollow.service; |
| | | // |
| | | //import com.baomidou.mybatisplus.extension.service.IService; |
| | | //import com.mes.bigstorage.entity.BigStorageDTO; |
| | | //import com.mes.glassinfo.entity.GlassInfo; |
| | | //import com.mes.hollow.entity.BigStorageCageHollowDetails; |
| | | // |
| | | ///** |
| | | // * (BigStorageCageHollowDetails)表服务接口 |
| | | // * |
| | | // * @author makejava |
| | | // * @since 2024-11-21 09:23:12 |
| | | // */ |
| | | //public interface BigStorageCageHollowDetailsService extends IService<BigStorageCageHollowDetails> { |
| | | // |
| | | // BigStorageDTO queryTargetSlotByHollow(GlassInfo info); |
| | | //} |
| | | // |
| | | package com.mes.hollow.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.mes.bigstorage.entity.dto.BigStorageDTO; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | | import com.mes.hollow.entity.BigStorageCageHollowDetails; |
| | | |
| | | /** |
| | | * (BigStorageCageHollowDetails)表服务接口 |
| | | * |
| | | * @author makejava |
| | | * @since 2024-11-21 09:23:12 |
| | | */ |
| | | public interface BigStorageCageHollowDetailsService extends IService<BigStorageCageHollowDetails> { |
| | | |
| | | BigStorageDTO queryTargetSlotByHollow(GlassInfo info); |
| | | } |
| | | |
New file |
| | |
| | | package com.mes.hollow.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.mes.hollow.entity.HollowGlassInfo; |
| | | |
| | | /** |
| | | * (HollowGlassInfo)表服务接口 |
| | | * |
| | | * @author makejava |
| | | * @since 2024-11-22 17:49:41 |
| | | */ |
| | | public interface HollowGlassInfoService extends IService<HollowGlassInfo> { |
| | | |
| | | /** |
| | | * 按照玻璃id获取中空目标格子 |
| | | * |
| | | * @return |
| | | */ |
| | | int queryHollowTargetSlot(String glassId); |
| | | |
| | | /** |
| | | * 生成中空玻璃信息 |
| | | */ |
| | | void generateHollowGlassInfo(String glassId); |
| | | |
| | | /** |
| | | * 格子配对 |
| | | * |
| | | * @param hollowGlassInfo |
| | | * @return |
| | | */ |
| | | int hollowSlotPair(HollowGlassInfo hollowGlassInfo); |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.mes.hollow.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.mes.hollow.entity.HollowGlassRelationInfo; |
| | | |
| | | /** |
| | | * (HollowGlassRelationInfo)表服务接口 |
| | | * |
| | | * @author makejava |
| | | * @since 2024-11-23 15:59:30 |
| | | */ |
| | | public interface HollowGlassRelationInfoService extends IService<HollowGlassRelationInfo> { |
| | | |
| | | } |
| | | |
| | |
| | | //package com.mes.hollow.service.impl; |
| | | // |
| | | //import cn.hutool.core.lang.Assert; |
| | | //import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | //import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | //import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | //import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | //import com.mes.bigstorage.entity.BigStorageCage; |
| | | //import com.mes.bigstorage.entity.BigStorageCageDetails; |
| | | //import com.mes.bigstorage.entity.BigStorageDTO; |
| | | //import com.mes.common.config.Const; |
| | | //import com.mes.glassinfo.entity.GlassInfo; |
| | | //import com.mes.hollow.entity.BigStorageCageHollow; |
| | | //import com.mes.hollow.entity.BigStorageCageHollowDetails; |
| | | //import com.mes.hollow.mapper.BigStorageCageHollowDetailsMapper; |
| | | //import com.mes.hollow.service.BigStorageCageHollowDetailsService; |
| | | //import org.springframework.stereotype.Service; |
| | | // |
| | | //import java.util.List; |
| | | // |
| | | ///** |
| | | // * (BigStorageCageHollowDetails)表服务实现类 |
| | | // * |
| | | // * @author makejava |
| | | // * @since 2024-11-21 09:23:12 |
| | | // */ |
| | | //@Service |
| | | //public class BigStorageCageHollowDetailsServiceImpl extends ServiceImpl<BigStorageCageHollowDetailsMapper, BigStorageCageHollowDetails> implements BigStorageCageHollowDetailsService { |
| | | // |
| | | // @Override |
| | | // public BigStorageDTO queryTargetSlotByHollow(GlassInfo glassInfo) { |
| | | package com.mes.hollow.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.mes.bigstorage.entity.dto.BigStorageDTO; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | | import com.mes.hollow.entity.BigStorageCageHollowDetails; |
| | | import com.mes.hollow.mapper.BigStorageCageHollowDetailsMapper; |
| | | import com.mes.hollow.service.BigStorageCageHollowDetailsService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * (BigStorageCageHollowDetails)表服务实现类 |
| | | * |
| | | * @author makejava |
| | | * @since 2024-11-21 09:23:12 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class BigStorageCageHollowDetailsServiceImpl extends ServiceImpl<BigStorageCageHollowDetailsMapper, BigStorageCageHollowDetails> implements BigStorageCageHollowDetailsService { |
| | | |
| | | @Override |
| | | public BigStorageDTO queryTargetSlotByHollow(GlassInfo glassInfo) { |
| | | // BigStorageDTO bigStorageDTO = null; |
| | | // MPJLambdaWrapper<BigStorageCageHollow> wrapper = new MPJLambdaWrapper<>(BigStorageCageHollow.class) |
| | | // .selectAll(BigStorageCageHollow.class) |
| | | // .leftJoin(BigStorageCageHollowDetails.class, BigStorageCageHollowDetails::getSlot, BigStorageCageHollow::getSlot) |
| | | // .eq(BigStorageCage::getEnableState, Const.SLOT_ON) |
| | | // .in(BigStorageCageDetails::getState, Const.GLASS_STATE_NEW,Const.GLASS_STATE_IN) |
| | | // .in(BigStorageCageDetails::getState, Const.GLASS_STATE_NEW, Const.GLASS_STATE_IN) |
| | | // .eq(BigStorageCageDetails::getEngineerId, glassInfo.getEngineerId()) |
| | | // .eq(BigStorageCageDetails::getTemperingLayoutId, glassInfo.getTemperingLayoutId()) |
| | | // .gt(BigStorageCage::getRemainWidth, Math.max(glassInfo.getWidth(), glassInfo.getHeight())) |
| | |
| | | // return bigStorageDTO; |
| | | // } |
| | | // } |
| | | // |
| | | // //获取玻璃的厚度:重新选笼子需要按照笼子可放玻璃厚度进行选择 |
| | | //// List<Integer> deviceNotUsedList = bigStorageCageService.queryFreeDeviceByNotUsed(glassInfo.getThickness()); |
| | | //// for (Integer item : deviceNotUsedList) { |
| | | //// bigStorageCage = bigStorageCageService.getOne(new LambdaQueryWrapper<BigStorageCage>() |
| | | //// .eq(BigStorageCage::getRemainWidth, slotWidth) |
| | | //// .eq(BigStorageCage::getEnableState, Const.SLOT_ON) |
| | | //// .eq(BigStorageCage::getDeviceId, item) |
| | | //// .last("limit 1")); |
| | | //// if (null != bigStorageCage) { |
| | | //// log.info("按照存笼玻璃格子数剩余最多得方式获取信息版图id:{},格子:{},玻璃id:{}", glassInfo.getTemperingLayoutId(), bigStorageCage.getSlot(), glassInfo.getGlassId()); |
| | | //// bigStorageDTO = new BigStorageDTO(); |
| | | //// bigStorageDTO.setWidth(bigStorageCage.getRemainWidth()); |
| | | //// bigStorageDTO.setSlot(bigStorageCage.getSlot()); |
| | | //// bigStorageDTO.setDeviceId(bigStorageCage.getDeviceId()); |
| | | //// return bigStorageDTO; |
| | | //// } |
| | | //// } |
| | | |
| | | //获取玻璃的厚度:重新选笼子需要按照笼子可放玻璃厚度进行选择 |
| | | // List<Integer> deviceNotUsedList = bigStorageCageService.queryFreeDeviceByNotUsed(glassInfo.getThickness()); |
| | | // for (Integer item : deviceNotUsedList) { |
| | | // bigStorageCage = bigStorageCageService.getOne(new LambdaQueryWrapper<BigStorageCage>() |
| | | // .eq(BigStorageCage::getRemainWidth, slotWidth) |
| | | // .eq(BigStorageCage::getEnableState, Const.SLOT_ON) |
| | | // .eq(BigStorageCage::getDeviceId, item) |
| | | // .last("limit 1")); |
| | | // if (null != bigStorageCage) { |
| | | // log.info("按照存笼玻璃格子数剩余最多得方式获取信息版图id:{},格子:{},玻璃id:{}", glassInfo.getTemperingLayoutId(), bigStorageCage.getSlot(), glassInfo.getGlassId()); |
| | | // bigStorageDTO = new BigStorageDTO(); |
| | | // bigStorageDTO.setWidth(bigStorageCage.getRemainWidth()); |
| | | // bigStorageDTO.setSlot(bigStorageCage.getSlot()); |
| | | // bigStorageDTO.setDeviceId(bigStorageCage.getDeviceId()); |
| | | // return bigStorageDTO; |
| | | // } |
| | | // } |
| | | // Assert.isTrue(null != bigStorageCage, "没有空余的笼子存放玻璃"); |
| | | // return bigStorageDTO; |
| | | // } |
| | | //} |
| | | // |
| | | return null; |
| | | } |
| | | } |
| | | |
New file |
| | |
| | | package com.mes.hollow.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.mes.common.config.Const; |
| | | import com.mes.engineering.entity.Engineering; |
| | | import com.mes.engineering.mapper.EngineeringMapper; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | | import com.mes.glassinfo.service.GlassInfoService; |
| | | import com.mes.hollow.entity.BigStorageCageHollow; |
| | | import com.mes.hollow.entity.HollowGlassInfo; |
| | | import com.mes.hollow.entity.HollowGlassRelationInfo; |
| | | import com.mes.hollow.mapper.HollowGlassInfoMapper; |
| | | import com.mes.hollow.service.BigStorageCageHollowService; |
| | | import com.mes.hollow.service.HollowGlassInfoService; |
| | | import com.mes.hollow.service.HollowGlassRelationInfoService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * (HollowGlassInfo)表服务实现类 |
| | | * |
| | | * @author makejava |
| | | * @since 2024-11-22 17:49:41 |
| | | */ |
| | | |
| | | @Slf4j |
| | | @Service |
| | | public class HollowGlassInfoServiceImpl extends ServiceImpl<HollowGlassInfoMapper, HollowGlassInfo> implements HollowGlassInfoService { |
| | | |
| | | @Resource |
| | | GlassInfoService glassInfoService; |
| | | @Resource |
| | | EngineeringMapper engineeringMapper; |
| | | @Resource |
| | | BigStorageCageHollowService bigStorageCageHollowService; |
| | | @Resource |
| | | HollowGlassRelationInfoService hollowGlassRelationInfoService; |
| | | @Value("${mes.slotWidth}") |
| | | private Integer slotWidth; |
| | | @Value("${mes.glassGap}") |
| | | private Integer glassGap; |
| | | |
| | | @Override |
| | | public int queryHollowTargetSlot(String glassId) { |
| | | //按照玻璃信息获取关系表中对应的大理片笼格子号 |
| | | HollowGlassRelationInfo relationInfoOne = hollowGlassRelationInfoService.getOne(new LambdaQueryWrapper<HollowGlassRelationInfo>().eq(HollowGlassRelationInfo::getGlassId, glassId)); |
| | | if (relationInfoOne != null) { |
| | | return relationInfoOne.getSlot(); |
| | | } |
| | | //按照玻璃id获取中空信息表是否数据 |
| | | HollowGlassInfo hollowGlassInfo = this.getOne(new LambdaQueryWrapper<HollowGlassInfo>().eq(HollowGlassInfo::getGlassId, glassId)); |
| | | if (null == hollowGlassInfo) { |
| | | //按照玻璃id计算对应工程下所有玻璃的格子 |
| | | generateHollowGlassInfo(glassId); |
| | | hollowGlassInfo = this.getOne(new LambdaQueryWrapper<HollowGlassInfo>().eq(HollowGlassInfo::getGlassId, glassId)); |
| | | } |
| | | return hollowSlotPair(hollowGlassInfo); |
| | | } |
| | | |
| | | @Override |
| | | public void generateHollowGlassInfo(String glassId) { |
| | | GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getGlassId, glassId)); |
| | | List<HollowGlassInfo> list = this.list(new LambdaQueryWrapper<HollowGlassInfo>().eq(HollowGlassInfo::getFlowCardId, glassInfo.getFlowCardId())); |
| | | if (CollectionUtil.isNotEmpty(list)) { |
| | | return; |
| | | } |
| | | Engineering engineering = engineeringMapper.selectOne(new LambdaQueryWrapper<Engineering>() |
| | | .eq(Engineering::getEngineerId, glassInfo.getEngineerId())); |
| | | //获取玻璃的工程id,按照工程id获取工程下的所有玻璃信息 |
| | | List<GlassInfo> glassInfoList = glassInfoService.listBySize(engineering.getEngineerId()); |
| | | Map<String, List<GlassInfo>> flowCardIdMap = glassInfoList.stream().collect(Collectors.groupingBy(GlassInfo::getFlowCardId)); |
| | | List<HollowGlassInfo> hollowGlassInfoList = new ArrayList<>(); |
| | | //方式一:将玻璃按流程卡、尺寸、版图、版序 依次生成虚拟格子信息,格子一直往后累加 |
| | | // flowCardIdMap.forEach((e, v) -> { |
| | | // int remainWidth = slotWidth; |
| | | // int slotNumber = 1; |
| | | // for (GlassInfo item : v) { |
| | | // int maxLength = (int) Math.max(item.getWidth(), item.getHeight()); |
| | | // if (remainWidth > maxLength) { |
| | | // remainWidth = remainWidth - maxLength - glassGap; |
| | | // } else { |
| | | // slotNumber = slotNumber + 1; |
| | | // remainWidth = slotWidth - maxLength - glassGap; |
| | | // } |
| | | // HollowGlassInfo hollow = new HollowGlassInfo(); |
| | | // BeanUtils.copyProperties(item, hollow); |
| | | // hollow.setSlot(slotNumber); |
| | | // hollowGlassInfoList.add(hollow); |
| | | // } |
| | | // }); |
| | | // this.saveBatch(hollowGlassInfoList); |
| | | //获取中空大理片笼的所有空闲格子 |
| | | // List<BigStorageCageHollow> hollowSlotList = bigStorageCageHollowService.list(new LambdaQueryWrapper<BigStorageCageHollow>() |
| | | // .eq(BigStorageCageHollow::getEnableState, Const.SLOT_ON).eq(BigStorageCageHollow::getRemainWidth, slotWidth)); |
| | | //方式二:将玻璃按流程卡、尺寸、版图、版序 ,优先将格子全部补全后 依次计算后面的格子号 |
| | | flowCardIdMap.forEach((e, v) -> { |
| | | List<List<HollowGlassInfo>> tempHollowList = new ArrayList<>(); |
| | | int slotNumber = 1; |
| | | for (GlassInfo item : v) { |
| | | boolean flag = false; |
| | | for (List<HollowGlassInfo> temp : tempHollowList) { |
| | | int sum = 0; |
| | | for (HollowGlassInfo i : temp) { |
| | | sum = sum + (int) Math.max(i.getHeight(), i.getWidth()) + glassGap; |
| | | } |
| | | if (sum + (int) Math.max(item.getHeight(), item.getWidth()) <= slotWidth) { |
| | | HollowGlassInfo hollow = new HollowGlassInfo(); |
| | | BeanUtils.copyProperties(item, hollow); |
| | | hollow.setSlotSequence(temp.size() + 1); |
| | | hollow.setVirtualSlot(temp.get(0).getVirtualSlot()); |
| | | temp.add(hollow); |
| | | flag = true; |
| | | break; |
| | | } |
| | | } |
| | | if (!flag) { |
| | | List<HollowGlassInfo> newList = new ArrayList<>(); |
| | | HollowGlassInfo hollow = new HollowGlassInfo(); |
| | | BeanUtils.copyProperties(item, hollow); |
| | | hollow.setSlotSequence(1); |
| | | hollow.setVirtualSlot(slotNumber++); |
| | | newList.add(hollow); |
| | | tempHollowList.add(newList); |
| | | } |
| | | } |
| | | for (List<HollowGlassInfo> item : tempHollowList) { |
| | | hollowGlassInfoList.addAll(item); |
| | | } |
| | | |
| | | }); |
| | | log.info("分配完毕"); |
| | | this.saveBatch(hollowGlassInfoList); |
| | | } |
| | | |
| | | @Override |
| | | public int hollowSlotPair(HollowGlassInfo hollowGlassInfo) { |
| | | //获取所有空闲可用的格子号 |
| | | BigStorageCageHollow storageCageHollow = bigStorageCageHollowService.getOne(new LambdaQueryWrapper<BigStorageCageHollow>() |
| | | .eq(BigStorageCageHollow::getEnableState, Const.SLOT_ON).eq(BigStorageCageHollow::getRemainWidth, slotWidth).last("limit 1")); |
| | | Integer slot = storageCageHollow.getSlot(); |
| | | //获取该工程同一流程卡同一车的玻璃信息 |
| | | List<HollowGlassInfo> hollowGlassInfoList = this.list(new LambdaQueryWrapper<HollowGlassInfo>().eq(HollowGlassInfo::getFlowCardId, hollowGlassInfo.getFlowCardId()) |
| | | .eq(HollowGlassInfo::getVirtualSlot, hollowGlassInfo.getVirtualSlot())); |
| | | //设置关系表的实际格子号 |
| | | List<HollowGlassRelationInfo> relationInfoList = hollowGlassInfoList.stream().map(e -> { |
| | | HollowGlassRelationInfo info = new HollowGlassRelationInfo(); |
| | | BeanUtils.copyProperties(e, info); |
| | | info.setSlot(slot); |
| | | return info; |
| | | }).collect(Collectors.toList()); |
| | | //保存关系表 |
| | | hollowGlassRelationInfoService.saveBatch(relationInfoList); |
| | | //返回格子信息 |
| | | return slot; |
| | | } |
| | | } |
| | | |
New file |
| | |
| | | package com.mes.hollow.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.mes.hollow.entity.HollowGlassRelationInfo; |
| | | import com.mes.hollow.mapper.HollowGlassRelationInfoMapper; |
| | | import com.mes.hollow.service.HollowGlassRelationInfoService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * (HollowGlassRelationInfo)表服务实现类 |
| | | * |
| | | * @author makejava |
| | | * @since 2024-11-23 15:59:30 |
| | | */ |
| | | @Service |
| | | public class HollowGlassRelationInfoServiceImpl extends ServiceImpl<HollowGlassRelationInfoMapper, HollowGlassRelationInfo> implements HollowGlassRelationInfoService { |
| | | |
| | | } |
| | | |
New file |
| | |
| | | package com.mes.job; |
| | | |
| | | import cn.hutool.json.JSONObject; |
| | | import cn.smallbun.screw.core.util.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.mes.bigstorage.entity.BigStorageCageDetails; |
| | | import com.mes.bigstorage.service.BigStorageCageDetailsService; |
| | | import com.mes.bigstorage.service.BigStorageCageService; |
| | | import com.mes.bigstoragecagetask.entity.BigStorageCageTask; |
| | | import com.mes.bigstoragecagetask.service.BigStorageCageTaskService; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | | import com.mes.glassinfo.service.GlassInfoService; |
| | | import com.mes.temperingglass.entity.TemperingGlassInfo; |
| | | import com.mes.temperingglass.service.TemperingGlassInfoService; |
| | | import com.mes.tools.WebSocketServer; |
| | | import com.mes.utils.RedisUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.BufferedReader; |
| | | import java.io.InputStreamReader; |
| | | import java.net.Socket; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author SNG-015 |
| | | */ |
| | | @Component |
| | | @Slf4j |
| | | public class OPCPlcSlicecage { |
| | | |
| | | @Resource |
| | | private BigStorageCageService bigStorageCageService; |
| | | @Resource |
| | | private BigStorageCageDetailsService bigStorageCageDetailsService; |
| | | @Resource |
| | | private TemperingGlassInfoService temperingGlassInfoService; |
| | | @Resource |
| | | private RedisUtil redisUtil; |
| | | @Autowired |
| | | private GlassInfoService glassInfoService; |
| | | @Resource |
| | | private BigStorageCageTaskService bigStorageCageTaskService; |
| | | |
| | | @Value("${mes.scan.ip}") |
| | | private String scanIp; |
| | | |
| | | @Value("${mes.scan.port}") |
| | | private Integer scanPort; |
| | | |
| | | private JSONObject jsonObject = new JSONObject(); |
| | | |
| | | public void queryDataSource1() throws InterruptedException { |
| | | List<Double> carPostion = new ArrayList<>(); |
| | | carPostion.add(0.25); |
| | | carPostion.add(0.5); |
| | | jsonObject.append("carPostion", carPostion); |
| | | //界面展示笼子信息 |
| | | jsonObject.append("bigStorageCageInfos", bigStorageCageService.querybigStorageCageDetail()); |
| | | |
| | | //进片任务数据 |
| | | List<BigStorageCageTask> inTaskList = bigStorageCageTaskService.queryTaskMessage("big_storage_cage_in_one_task"); |
| | | jsonObject.append("bigStorageCageDetailsFeedTask", inTaskList); |
| | | |
| | | //出片任务数据 |
| | | List<BigStorageCageTask> outTaskList = bigStorageCageTaskService.queryTaskMessage("big_storage_cage_out_one_task"); |
| | | jsonObject.append("bigStorageCageDetailsOutTask", outTaskList); |
| | | |
| | | //理片笼使用情况 |
| | | List<Map<String, Object>> bigStorageCageUsage = bigStorageCageService.selectBigStorageCageUsage(); |
| | | jsonObject.append("bigStorageCageUsage", bigStorageCageUsage); |
| | | |
| | | //理片笼表格信息 |
| | | jsonObject.append("bigStorageCageInfo", bigStorageCageService.querybigStorageCageDetailAll()); |
| | | |
| | | //钢化开关 |
| | | boolean temperingSwitch = false; |
| | | if (redisUtil.getCacheObject("temperingSwitch") == null) { |
| | | redisUtil.setCacheObject("temperingSwitch", false); |
| | | } else { |
| | | temperingSwitch = redisUtil.getCacheObject("temperingSwitch"); |
| | | } |
| | | jsonObject.append("temperingSwitch", temperingSwitch); |
| | | //打印开关 |
| | | boolean autoPrint = false; |
| | | if (redisUtil.getCacheObject("autoPrint") == null) { |
| | | redisUtil.setCacheObject("autoPrint", false); |
| | | } else { |
| | | autoPrint = redisUtil.getCacheObject("autoPrint"); |
| | | } |
| | | jsonObject.append("autoPrint", autoPrint); |
| | | |
| | | //当前指定工程 |
| | | String temperingengineerId = ""; |
| | | if (redisUtil.getCacheObject("temperingengineerId") == null) { |
| | | redisUtil.setCacheObject("temperingengineerId", temperingengineerId); |
| | | } else { |
| | | temperingengineerId = redisUtil.getCacheObject("temperingengineerId"); |
| | | } |
| | | jsonObject.append("temperingengineerId", temperingengineerId); |
| | | |
| | | |
| | | } |
| | | |
| | | public void queryDataSource2() throws InterruptedException { |
| | | //出片队列 |
| | | List<TemperingGlassInfo> temperingGlassInfoList = temperingGlassInfoService.list( |
| | | new LambdaQueryWrapper<TemperingGlassInfo>() |
| | | .inSql(TemperingGlassInfo::getEngineerId, "select distinct engineer_id from tempering_glass_info where state<4") |
| | | ); |
| | | jsonObject.append("temperingGlassInfoList", temperingGlassInfoList); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * fixedRate : 上一个调用开始后再次调用的延时(不用等待上一次调用完成) |
| | | * fixedDelay : 上一个调用结束后再次调用的延时 |
| | | */ |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void plcStorageCageTask() throws InterruptedException { |
| | | jsonObject = new JSONObject(); |
| | | try { |
| | | //查询使用数据源1查询数据 |
| | | queryDataSource1(); |
| | | //查询使用数据源2查询数据 |
| | | queryDataSource2(); |
| | | |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("slicecage"); |
| | | if (sendwServer != null) { |
| | | for (WebSocketServer webserver : sendwServer) { |
| | | if (webserver != null) { |
| | | webserver.sendMessage(jsonObject.toString()); |
| | | List<String> messages = webserver.getMessages(); |
| | | if (!messages.isEmpty()) { |
| | | // // 将最后一个消息转换为整数类型的列表 |
| | | webserver.clearMessages(); |
| | | } |
| | | } else { |
| | | log.info("Home is closed"); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | // @Scheduled(fixedDelay = 1000) |
| | | public void temperingIsRun() { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | //进片任务数据 |
| | | List<BigStorageCageDetails> bigStorageCageDetailsFeedTask = bigStorageCageDetailsService.selectFeedTask(); |
| | | jsonObject.append("bigStorageCageDetailsFeedTask", bigStorageCageDetailsFeedTask); |
| | | //出片任务数据 |
| | | List<BigStorageCageDetails> bigStorageCageDetailsOutTask = bigStorageCageDetailsService.selectOutTask(); |
| | | jsonObject.append("bigStorageCageDetailsOutTask", bigStorageCageDetailsOutTask); |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("isRun"); |
| | | if (sendwServer != null) { |
| | | for (WebSocketServer webserver : sendwServer) { |
| | | if (webserver != null) { |
| | | webserver.sendMessage(jsonObject.toString()); |
| | | } else { |
| | | log.info("Home is closed"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // @Scheduled(fixedDelay = Long.MAX_VALUE) |
| | | public void scanCodeTask() { |
| | | log.info("扫描任务已启动"); |
| | | while (true) { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | try (Socket socket = new Socket(scanIp, scanPort); |
| | | BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()))) { |
| | | // 接收服务器响应 |
| | | log.info("等待扫码中......"); |
| | | String glassId = in.readLine(); |
| | | log.info("扫描到的玻璃id:{}", glassId); |
| | | List<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("slicecage"); |
| | | if (CollectionUtils.isNotEmpty(sendwServer)) { |
| | | //按照玻璃id获取玻璃信息返回给前端界面,具体需要哪些数据待确认 |
| | | GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>() |
| | | .eq(GlassInfo::getGlassId, glassId).last("limit 1")); |
| | | if (null == glassInfo) { |
| | | log.info("按照玻璃id:{},无法找到玻璃信息", glassId); |
| | | } else { |
| | | for (WebSocketServer webserver : sendwServer) { |
| | | jsonObject.append("scanGlass", glassInfo); |
| | | webserver.sendMessage(jsonObject.toString()); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception exception) { |
| | | log.info("读取异常,原因为{}", exception.getMessage()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.github.yulichang.toolkit.JoinWrappers; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import com.mes.base.entity.BigStorageCageBaseInfo; |
| | | import com.mes.bigstorage.entity.BigStorageCage; |
| | | import com.mes.bigstorage.entity.BigStorageCageDetails; |
| | | import com.mes.bigstorage.entity.BigStorageDTO; |
| | | import com.mes.bigstorage.entity.dto.BigStorageDTO; |
| | | import com.mes.bigstorage.entity.dto.SlotSequenceDTO; |
| | | import com.mes.bigstorage.entity.dto.TemperingLayoutDTO; |
| | | import com.mes.bigstorage.service.BigStorageCageDetailsService; |
| | | import com.mes.bigstorage.service.BigStorageCageService; |
| | | import com.mes.bigstorage.service.BigStorageGlassInfoService; |
| | | import com.mes.bigstoragecagetask.entity.BigStorageCageHistoryTask; |
| | | import com.mes.bigstoragecagetask.entity.BigStorageCageTask; |
| | | import com.mes.bigstoragecagetask.service.BigStorageCageHistoryTaskService; |
| | |
| | | import com.mes.damage.service.DamageService; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | | import com.mes.glassinfo.service.GlassInfoService; |
| | | import com.mes.hollow.service.BigStorageCageHollowDetailsService; |
| | | import com.mes.hollow.service.BigStorageCageHollowService; |
| | | import com.mes.temperingglass.entity.TemperingGlass; |
| | | import com.mes.temperingglass.entity.TemperingGlassInfo; |
| | | import com.mes.temperingglass.service.TemperingGlassService; |
| | | import com.mes.hollow.service.HollowGlassInfoService; |
| | | import com.mes.utils.RedisUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang.StringUtils; |
| | |
| | | |
| | | @Resource |
| | | private BigStorageCageHollowDetailsService bigStorageCageHollowDetailsService; |
| | | @Resource |
| | | private TemperingGlassService temperingGlassService; |
| | | // @Resource |
| | | // private TemperingGlassService temperingGlassService; |
| | | @Resource |
| | | private DamageService damageService; |
| | | @Resource |
| | |
| | | private BigStorageCageHollowService bigStorageCageHollowService; |
| | | @Resource |
| | | private BigStorageCageHistoryTaskService bigStorageCageHistoryTaskService; |
| | | @Resource |
| | | private BigStorageGlassInfoService bigStorageGlassInfoService; |
| | | @Resource |
| | | private BigStorageCageTaskService bigStorageCageTaskService; |
| | | @Autowired(required = false) |
| | |
| | | @Value("${mes.sequence.order}") |
| | | private boolean sequenceOrder; |
| | | |
| | | @Resource |
| | | HollowGlassInfoService hollowGlassInfoService; |
| | | |
| | | // @Scheduled(fixedDelay = 1000) |
| | | public void test() { |
| | | hollowGlassInfoService.queryHollowTargetSlot("P24111201|2|20"); |
| | | } |
| | | |
| | | // @Scheduled(fixedDelay = 1000) |
| | | public void test1() { |
| | | bigStorageGlassInfoService.queryBigStorageTargetSlot("P24111201|2|20"); |
| | | } |
| | | |
| | | public void inBigStorageTask() throws Exception { |
| | | ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP2A.DLP2A.mesControl"); |
| | |
| | | if (CollectionUtils.isEmpty(inTaskList)) { |
| | | log.info("当前大车无进片玻璃,结束进片任务"); |
| | | } |
| | | //todo:去中空队列表中查询玻璃信息是否存在 |
| | | GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getGlassId, inTaskList.get(0).getGlassId())); |
| | | //todo: |
| | | List<String> glassIdList = inTaskList.stream().map(BigStorageCageTask::getGlassId).collect(Collectors.toList()); |
| | | log.info("获取任务的玻璃id:{}", glassIdList); |
| | | List<GlassInfo> glassInfoList = glassInfoService.list(new LambdaQueryWrapper<GlassInfo>().in(GlassInfo::getGlassId, glassIdList)); |
| | |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP2A.DLP2A.MesReply", 1)); |
| | | } |
| | | |
| | | //@Scheduled(fixedDelay = 1000) |
| | | // @Scheduled(fixedDelay = 1000) |
| | | public void outBigStorageTask() throws Exception { |
| | | Date startDate = new Date(); |
| | | ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP2B.DLP2B.mesControl"); |
| | |
| | | } |
| | | //todo:是否允许钢化 |
| | | if (redisUtil.getCacheObject("temperingSwitch")) { |
| | | //是否有正在钢化的玻璃:钢化小片表关联历史任务表,筛选未出笼的玻璃信息 |
| | | List<TemperingGlass> temperingGlassList = temperingGlassService.selectJoinList(TemperingGlass.class, new MPJLambdaWrapper<TemperingGlass>() |
| | | .selectAll(TemperingGlass.class) |
| | | .leftJoin(BigStorageCageHistoryTask.class, BigStorageCageHistoryTask::getGlassId, TemperingGlass::getGlassId) |
| | | .eq(TemperingGlass::getState, Const.TEMPERING_NEW) |
| | | .eq(BigStorageCageHistoryTask::getTaskType, Const.BIG_STORAGE_BEFORE_OUT) |
| | | .isNull(BigStorageCageHistoryTask::getGlassId) |
| | | .orderBy(Boolean.TRUE, sequenceOrder, TemperingGlass::getTemperingFeedSequence)); |
| | | //todo:历史任务表 |
| | | if (CollectionUtils.isNotEmpty(temperingGlassList)) { |
| | | log.info("有正在出片的钢化任务"); |
| | | computeOutGlassInfo(temperingGlassList, "big_storage_cage_out_two_task", Const.TEMPERING_OUT_TARGET_POSITION, Const.GLASS_STATE_OUT_ING, Const.BIG_STORAGE_BEFORE_OUT); |
| | | Date endDate = new Date(); |
| | | log.info("大理片笼出片任务结束时间:{},共耗时:{}ms,结束扫码任务", endDate, endDate.getTime() - startDate.getTime()); |
| | | return; |
| | | } |
| | | //钢化优先:获取理片笼 玻璃小片 破损表 数量 判断笼内版图是否到齐 |
| | | List<TemperingLayoutDTO> temperingLayoutDTOList = bigStorageCageDetailsService.temperingIsAll(); |
| | | if (CollectionUtils.isNotEmpty(temperingLayoutDTOList)) { |
| | | //玻璃到齐包括已出片的 |
| | | //到齐,将玻璃小片数据存入钢化小片表,逻辑生成出片任务 结束 |
| | | for (TemperingLayoutDTO item : temperingLayoutDTOList) { |
| | | // if (item.getEngineerId().equals(redisUtil.getCacheObject("temperingengineerId"))) { |
| | | List<TemperingGlass> temperingGlassInfos = glassInfoService.selectJoinList(TemperingGlass.class, JoinWrappers.lambda(GlassInfo.class) |
| | | .selectAll(GlassInfo.class) |
| | | .select("-1 as state") |
| | | .selectAs(BigStorageCageDetails::getSlot, TemperingGlassInfo::getSlot) |
| | | .innerJoin(BigStorageCageDetails.class, BigStorageCageDetails::getGlassId, GlassInfo::getGlassId) |
| | | .eq(BigStorageCageDetails::getState, Const.GLASS_STATE_IN) |
| | | .eq(GlassInfo::getTemperingLayoutId, item.getTemperingLayoutId()) |
| | | .eq(GlassInfo::getEngineerId, item.getEngineerId()) |
| | | .orderBy(Boolean.TRUE, sequenceOrder, GlassInfo::getTemperingFeedSequence)); |
| | | if (CollectionUtils.isNotEmpty(temperingGlassInfos)) { |
| | | temperingGlassService.saveBatch(temperingGlassInfos); |
| | | computeOutGlassInfo(temperingGlassInfos, "big_storage_cage_out_two_task", Const.TEMPERING_OUT_TARGET_POSITION, Const.GLASS_STATE_OUT_ING, Const.BIG_STORAGE_BEFORE_OUT); |
| | | Date endDate = new Date(); |
| | | log.info("大理片笼出片任务结束时间:{},共耗时:{}ms,结束扫码任务", endDate, endDate.getTime() - startDate.getTime()); |
| | | return; |
| | | } |
| | | // } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | //是否有人工下片任务 有直接出 |
| | | List<BigStorageCageDetails> artificialList = bigStorageCageDetailsService.list(new LambdaQueryWrapper<BigStorageCageDetails>() |
| | | .eq(BigStorageCageDetails::getState, Const.GLASS_STATE_ARTIFICIAL) |
| | |
| | | log.info("大理片笼出片任务结束时间:{},共耗时:{}ms,结束扫码任务", endDate, endDate.getTime() - startDate.getTime()); |
| | | return; |
| | | } |
| | | |
| | | //是否存在需要内部调度的格子:执行内部调度任务 |
| | | List<TemperingLayoutDTO> temperingOccupySlotList = bigStorageCageDetailsService.queryTemperingOccupySlot(); |
| | | if (CollectionUtils.isNotEmpty(temperingOccupySlotList)) { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | Date endDate = new Date(); |
| | | log.info("大理片笼出片任务结束时间:{},共耗时:{}ms,结束扫码任务", endDate, endDate.getTime() - startDate.getTime()); |
| | | return; |
| | |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP2A.DLP2A.MesReply", 0)); |
| | | } |
| | | |
| | | //@Scheduled(fixedDelay = 1000) |
| | | // @Scheduled(fixedDelay = 1000) |
| | | public void finishOutBigStorageTask() throws Exception { |
| | | ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP2B.DLP2B.mesControl"); |
| | | if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
New file |
| | |
| | | package com.mes.job; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.lang.Assert; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.github.yulichang.toolkit.JoinWrappers; |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import com.mes.base.entity.BigStorageCageBaseInfo; |
| | | import com.mes.bigstorage.entity.BigStorageCage; |
| | | import com.mes.bigstorage.entity.BigStorageCageDetails; |
| | | import com.mes.bigstorage.entity.dto.BigStorageDTO; |
| | | import com.mes.bigstorage.entity.dto.BigStorageRelationDTO; |
| | | import com.mes.bigstorage.entity.dto.BigStorageSequenceDTO; |
| | | import com.mes.bigstorage.entity.dto.TemperingLayoutDTO; |
| | | import com.mes.bigstorage.service.BigStorageCageDetailsService; |
| | | import com.mes.bigstorage.service.BigStorageCageService; |
| | | import com.mes.bigstorage.service.BigStorageGlassInfoService; |
| | | import com.mes.bigstoragecagetask.entity.BigStorageCageHistoryTask; |
| | | import com.mes.bigstoragecagetask.entity.BigStorageCageTask; |
| | | import com.mes.bigstoragecagetask.service.BigStorageCageHistoryTaskService; |
| | | import com.mes.bigstoragecagetask.service.BigStorageCageTaskService; |
| | | import com.mes.bigstoragetask.entity.UpdateBigStorageCageDTO; |
| | | import com.mes.common.config.Const; |
| | | import com.mes.damage.entity.Damage; |
| | | import com.mes.damage.service.DamageService; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | | import com.mes.glassinfo.service.GlassInfoService; |
| | | import com.mes.temperingglass.entity.TemperingGlassInfo; |
| | | import com.mes.temperingglass.service.TemperingGlassInfoService; |
| | | import com.mes.utils.RedisUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author SNG-015 |
| | | */ |
| | | @Component |
| | | @Slf4j |
| | | public class OpcPlcStorageCageNewTask { |
| | | @Resource |
| | | private BigStorageCageDetailsService bigStorageCageDetailsService; |
| | | @Resource |
| | | private TemperingGlassInfoService temperingGlassInfoService; |
| | | @Resource |
| | | private DamageService damageService; |
| | | @Resource |
| | | private GlassInfoService glassInfoService; |
| | | @Resource |
| | | private BigStorageCageService bigStorageCageService; |
| | | @Resource |
| | | private BigStorageCageHistoryTaskService bigStorageCageHistoryTaskService; |
| | | @Resource |
| | | private BigStorageCageTaskService bigStorageCageTaskService; |
| | | @Resource |
| | | private BigStorageGlassInfoService bigStorageGlassInfoService; |
| | | |
| | | @Autowired(required = false) |
| | | MiloService miloService; |
| | | |
| | | @Resource |
| | | private RedisUtil redisUtil; |
| | | |
| | | @Value("${mes.slotWidth}") |
| | | private Integer slotWidth; |
| | | |
| | | @Value("${mes.glassGap}") |
| | | private Integer glassGap; |
| | | |
| | | @Value("${mes.carWidth}") |
| | | private Integer carWidth; |
| | | |
| | | @Value("${mes.outCarMaxSize}") |
| | | private Integer outCarMaxSize; |
| | | |
| | | @Value("${mes.sequence.order}") |
| | | private boolean sequenceOrder; |
| | | |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void inBigStorageTask() throws Exception { |
| | | ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1A.DLP1A.mesControl"); |
| | | if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | | log.info("当前为非联机状态,结束进片任务"); |
| | | return; |
| | | } |
| | | ReadWriteEntity requestEntity = miloService.readFromOpcUa("DLP1A.DLP1A.RequestMes"); |
| | | if (!"1".equals(requestEntity.getValue() + "")) { |
| | | log.info("当前未收到进片请求,结束进片任务"); |
| | | return; |
| | | } |
| | | ReadWriteEntity mesReplyEntity = miloService.readFromOpcUa("DLP1A.DLP1A.MesReply"); |
| | | if ("1".equals(mesReplyEntity.getValue() + "")) { |
| | | log.info("有正在执行的任务,结束进片任务"); |
| | | return; |
| | | } |
| | | //获取进片任务表 |
| | | List<BigStorageCageTask> inTaskList = bigStorageCageTaskService.queryTaskMessage("big_storage_cage_in_one_task"); |
| | | if (CollectionUtil.isEmpty(inTaskList)) { |
| | | log.info("当前大车无进片玻璃,结束进片任务"); |
| | | } |
| | | |
| | | List<String> glassIdList = inTaskList.stream().map(BigStorageCageTask::getGlassId).collect(Collectors.toList()); |
| | | log.info("获取任务的玻璃id:{}", glassIdList); |
| | | Map<String, Long> glassCountMap = glassIdList.stream().collect(Collectors.groupingBy(e -> e, Collectors.counting())); |
| | | for (Map.Entry<String, Long> entry : glassCountMap.entrySet()) { |
| | | if (entry.getValue() > 1) { |
| | | log.info("进片玻璃{}存在相同,结束本次任务", entry.getKey()); |
| | | //todo:向plc发送报警 |
| | | return; |
| | | } |
| | | } |
| | | List<BigStorageCageDetails> detailsList = bigStorageCageDetailsService.list(new LambdaQueryWrapper<BigStorageCageDetails>().in(BigStorageCageDetails::getGlassId, glassIdList) |
| | | .in(BigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL)); |
| | | if (CollectionUtil.isNotEmpty(detailsList)) { |
| | | log.info("理片笼存在相同的进片玻璃{},结束本次任务", detailsList); |
| | | //todo:向plc发送报警 |
| | | return; |
| | | } |
| | | List<GlassInfo> glassInfoList = glassInfoService.list(new LambdaQueryWrapper<GlassInfo>().in(GlassInfo::getGlassId, glassIdList)); |
| | | |
| | | Map<String, List<GlassInfo>> glassListMap = glassInfoList.stream().collect(Collectors.groupingBy(GlassInfo::getGlassId)); |
| | | |
| | | //计算目标格子 |
| | | List<BigStorageCageHistoryTask> historyTasks = new ArrayList<>(); |
| | | for (BigStorageCageTask task : inTaskList) { |
| | | GlassInfo info = glassListMap.get(task.getGlassId()).get(0); |
| | | BigStorageDTO bigStorageDTO = bigStorageGlassInfoService.queryBigStorageTargetSlot(info.getGlassId()); |
| | | //获取目标格子信息 |
| | | // BigStorageDTO bigStorageDTO = bigStorageCageDetailsService.queryTargetSlotByTempering(info); |
| | | // 临时更新格子的剩余尺寸:防止相邻玻璃进同一格子造成剩余尺寸不足,玻璃越界的情况,任务完成后再次更新大理片笼表剩余宽度(按照笼内玻璃数量更新大理片笼剩余尺寸) |
| | | bigStorageCageService.update(new LambdaUpdateWrapper<BigStorageCage>() |
| | | .set(BigStorageCage::getRemainWidth, bigStorageDTO.getWidth() - Math.max(info.getWidth(), info.getHeight()) - glassGap) |
| | | .eq(BigStorageCage::getSlot, bigStorageDTO.getSlot())); |
| | | task.setTargetSlot(bigStorageDTO.getSlot()); |
| | | task.setGlassId(info.getGlassId()); |
| | | bigStorageCageTaskService.updateTaskMessage("big_storage_cage_in_one_task", task); |
| | | //存放历史任务 |
| | | BigStorageCageHistoryTask historyTask = new BigStorageCageHistoryTask(); |
| | | BeanUtils.copyProperties(task, historyTask); |
| | | historyTask.setTaskType(Const.BIG_STORAGE_BEFORE_IN); |
| | | historyTask.setGlassCount(glassInfoList.size()); |
| | | historyTask.setTaskState(Const.ENGINEERING_NEW); |
| | | historyTasks.add(historyTask); |
| | | BigStorageCageDetails cageDetails = new BigStorageCageDetails(); |
| | | BeanUtils.copyProperties(info, cageDetails); |
| | | cageDetails.setSlot(bigStorageDTO.getSlot()); |
| | | cageDetails.setState(Const.GLASS_STATE_NEW); |
| | | cageDetails.setDeviceId(bigStorageDTO.getDeviceId()); |
| | | cageDetails.setSequence(bigStorageDTO.getSlotSequence()); |
| | | cageDetails.setGap(glassGap); |
| | | cageDetails.setId(null); |
| | | bigStorageCageDetailsService.save(cageDetails); |
| | | } |
| | | //历史数据入库 |
| | | bigStorageCageHistoryTaskService.saveBatch(historyTasks); |
| | | //向opc发送启动信号 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.MesReply", 1)); |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void outBigStorageTask() throws Exception { |
| | | Date startDate = new Date(); |
| | | ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1B.DLP1B.mesControl"); |
| | | if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | | log.info("当前为非联机状态,结束进片任务"); |
| | | return; |
| | | } |
| | | ReadWriteEntity requestEntity = miloService.readFromOpcUa("DLP1B.DLP1B.RequestMes"); |
| | | if (!"1".equals(requestEntity.getValue() + "")) { |
| | | log.info("当前未收到出片请求,结束出片任务"); |
| | | return; |
| | | } |
| | | //获取出片任务表 |
| | | List<BigStorageCageTask> outTaskList = bigStorageCageTaskService.queryTaskMessage("big_storage_cage_out_one_task"); |
| | | if (CollectionUtil.isNotEmpty(outTaskList)) { |
| | | log.info("有正在执行的出片任务,结束本次出片任务"); |
| | | return; |
| | | } |
| | | //todo:是否允许钢化 |
| | | if (redisUtil.getCacheObject("temperingSwitch")) { |
| | | //是否有正在钢化的玻璃:钢化小片表关联历史任务表,筛选未出笼的玻璃信息 |
| | | // 获取当前钢化任务未完成出片的玻璃信息 |
| | | List<TemperingGlassInfo> unFinishTemperingGlassInfoList = temperingGlassInfoService.list(new LambdaQueryWrapper<TemperingGlassInfo>().eq(TemperingGlassInfo::getState, Const.TEMPERING_NEW)); |
| | | if (CollectionUtil.isNotEmpty(unFinishTemperingGlassInfoList)) { |
| | | List<String> glassIdList = unFinishTemperingGlassInfoList.stream().map(TemperingGlassInfo::getGlassId).collect(Collectors.toList()); |
| | | List<BigStorageCageHistoryTask> historyTaskList = bigStorageCageHistoryTaskService.list(new LambdaQueryWrapper<BigStorageCageHistoryTask>() |
| | | .eq(BigStorageCageHistoryTask::getTaskType, Const.BIG_STORAGE_BEFORE_OUT) |
| | | .in(BigStorageCageHistoryTask::getGlassId, glassIdList)); |
| | | List<TemperingGlassInfo> temperingGlassList = unFinishTemperingGlassInfoList; |
| | | if (CollectionUtil.isNotEmpty(historyTaskList)) { |
| | | List<String> taskGlassList = historyTaskList.stream().map(BigStorageCageHistoryTask::getGlassId).collect(Collectors.toList()); |
| | | temperingGlassList = unFinishTemperingGlassInfoList.stream().filter(e -> !taskGlassList.contains(e.getGlassId())).collect(Collectors.toList()); |
| | | } |
| | | if (CollectionUtil.isNotEmpty(temperingGlassList)) { |
| | | log.info("有正在出片的钢化任务"); |
| | | computeOutGlassInfo(temperingGlassList, "big_storage_cage_out_one_task", Const.TEMPERING_OUT_TARGET_POSITION, Const.GLASS_STATE_OUT_ING, Const.BIG_STORAGE_BEFORE_OUT); |
| | | Date endDate = new Date(); |
| | | log.info("大理片笼出片任务结束时间:{},共耗时:{}ms,结束扫码任务", endDate, endDate.getTime() - startDate.getTime()); |
| | | return; |
| | | } |
| | | } |
| | | //钢化优先:获取理片笼 玻璃小片 破损表 数量 判断笼内版图是否到齐 |
| | | List<TemperingLayoutDTO> temperingLayoutDTOList = bigStorageCageDetailsService.temperingIsAll(); |
| | | if (CollectionUtil.isNotEmpty(temperingLayoutDTOList)) { |
| | | //玻璃到齐包括已出片的 |
| | | //到齐,将玻璃小片数据存入钢化小片表,逻辑生成出片任务 结束 |
| | | for (TemperingLayoutDTO item : temperingLayoutDTOList) { |
| | | // if (item.getEngineerId().equals(redisUtil.getCacheObject("temperingengineerId"))) { |
| | | List<TemperingGlassInfo> temperingGlassInfos = glassInfoService.selectJoinList(TemperingGlassInfo.class, JoinWrappers.lambda(GlassInfo.class) |
| | | .selectAll(GlassInfo.class) |
| | | .select("-1 as state") |
| | | .selectAs(BigStorageCageDetails::getSlot, TemperingGlassInfo::getSlot) |
| | | .innerJoin(BigStorageCageDetails.class, BigStorageCageDetails::getGlassId, GlassInfo::getGlassId) |
| | | .eq(BigStorageCageDetails::getState, Const.GLASS_STATE_IN) |
| | | .eq(GlassInfo::getTemperingLayoutId, item.getTemperingLayoutId()) |
| | | .eq(GlassInfo::getEngineerId, item.getEngineerId()) |
| | | .orderBy(Boolean.TRUE, sequenceOrder, GlassInfo::getTemperingFeedSequence)); |
| | | if (CollectionUtil.isNotEmpty(temperingGlassInfos)) { |
| | | temperingGlassInfoService.saveBatch(temperingGlassInfos); |
| | | computeOutGlassInfo(temperingGlassInfos, "big_storage_cage_out_one_task", Const.TEMPERING_OUT_TARGET_POSITION, Const.GLASS_STATE_OUT_ING, Const.BIG_STORAGE_BEFORE_OUT); |
| | | Date endDate = new Date(); |
| | | log.info("大理片笼出片任务结束时间:{},共耗时:{}ms,结束扫码任务", endDate, endDate.getTime() - startDate.getTime()); |
| | | return; |
| | | } |
| | | // } |
| | | } |
| | | } |
| | | } |
| | | //是否有人工下片任务 有直接出 |
| | | List<BigStorageCageDetails> artificialList = bigStorageCageDetailsService.list(new LambdaQueryWrapper<BigStorageCageDetails>() |
| | | .eq(BigStorageCageDetails::getState, Const.GLASS_STATE_ARTIFICIAL) |
| | | .orderByAsc(BigStorageCageDetails::getSlot) |
| | | .orderByAsc(BigStorageCageDetails::getId)); |
| | | if (CollectionUtil.isNotEmpty(artificialList)) { |
| | | computeOutGlassInfo(artificialList, "big_storage_cage_out_one_task", Const.ARTIFICIAL_OUT_TARGET_POSITION, Const.GLASS_STATE_OUT_ING, Const.BIG_STORAGE_BEFORE_OUT); |
| | | Date endDate = new Date(); |
| | | log.info("大理片笼出片任务结束时间:{},共耗时:{}ms,结束扫码任务", endDate, endDate.getTime() - startDate.getTime()); |
| | | return; |
| | | } |
| | | //是否存在需要内部调度的格子:执行内部调度任务 |
| | | if (redisUtil.getCacheObject("dispatchSwitch")) { |
| | | //todo:获取笼内单格已经到齐的玻璃格子信息 |
| | | List<BigStorageRelationDTO> virtualList = bigStorageCageDetailsService.queryIsAllNeedDispatchVirtualSlot(); |
| | | if (CollectionUtil.isEmpty(virtualList)) { |
| | | log.info("没有需要调度的格子"); |
| | | return; |
| | | } |
| | | List<BigStorageCageDetails> list = new ArrayList<>(); |
| | | for (BigStorageRelationDTO dto : virtualList) { |
| | | List<BigStorageSequenceDTO> sequenceDTOList = bigStorageCageDetailsService.dispatchBigStorageGlassInfo(dto); |
| | | if (CollectionUtil.isEmpty(sequenceDTOList) || sequenceDTOList.size() == 1) { |
| | | continue; |
| | | } |
| | | int sequence = -1; |
| | | int startSlot = -1; |
| | | for (BigStorageSequenceDTO item : sequenceDTOList) { |
| | | if (item.getMinSequence() == sequence + 1) { |
| | | //生成调度任务 |
| | | int targetSlot = item.getSlot(); |
| | | list = bigStorageCageDetailsService.list(new LambdaQueryWrapper<BigStorageCageDetails>() |
| | | .eq(BigStorageCageDetails::getState, Const.GLASS_STATE_IN).eq(BigStorageCageDetails::getSlot, startSlot)); |
| | | computeOutGlassInfo(list, "big_storage_cage_out_one_task", targetSlot, Const.GLASS_STATE_SCHEDULE_ING, Const.BIG_STORAGE_BEFORE_DISPATCH); |
| | | List<Integer> slotList = new ArrayList<>(); |
| | | slotList.add(targetSlot); |
| | | updateSlotRemainBySlots(slotList); |
| | | break; |
| | | } |
| | | sequence = item.getMaxSequence(); |
| | | startSlot = item.getSlot(); |
| | | } |
| | | } |
| | | } |
| | | Date endDate = new Date(); |
| | | log.info("大理片笼出片任务结束时间:{},共耗时:{}ms,结束扫码任务", endDate, endDate.getTime() - startDate.getTime()); |
| | | return; |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void finishInBigStorageTask() throws Exception { |
| | | ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1A.DLP1A.mesControl"); |
| | | if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | | log.info("当前为非联机状态,结束完成进片任务"); |
| | | return; |
| | | } |
| | | //获取进片任务表 |
| | | List<BigStorageCageTask> inTaskList = bigStorageCageTaskService.queryTaskMessage("big_storage_cage_in_one_task"); |
| | | if (CollectionUtil.isEmpty(inTaskList)) { |
| | | log.info("当前大车无进片玻璃,结束完成进片任务"); |
| | | return; |
| | | } |
| | | List<BigStorageCageTask> unFinishTaskList = inTaskList.stream().filter(e -> e.getTaskState() <= 1 || e.getStartSlot() == 0).collect(Collectors.toList()); |
| | | if (CollectionUtil.isNotEmpty(unFinishTaskList)) { |
| | | log.info("存在未完成的玻璃信息,玻璃:{}", unFinishTaskList); |
| | | return; |
| | | } |
| | | Map<Integer, List<BigStorageCageTask>> taskMap = inTaskList.stream().collect(Collectors.groupingBy(BigStorageCageTask::getTaskState)); |
| | | //按照任务状态修改大理片笼内的玻璃数据 |
| | | // 重新计算大理片笼内的剩余尺寸 |
| | | taskMap.forEach((e1, v) -> { |
| | | if (e1 == 2) { |
| | | //进片完成 |
| | | log.info("3、获取进片已完成的玻璃信息id:{}", v); |
| | | List<Integer> inSuccessGlassSlot = v.stream().map(BigStorageCageTask::getTargetSlot).collect(Collectors.toList()); |
| | | List<UpdateBigStorageCageDTO> storageCageDTOList = v.stream().map(e -> { |
| | | UpdateBigStorageCageDTO storageCageDTO = new UpdateBigStorageCageDTO(); |
| | | BeanUtils.copyProperties(e, storageCageDTO); |
| | | return storageCageDTO; |
| | | }).collect(Collectors.toList()); |
| | | bigStorageCageDetailsService.updateBySlot(storageCageDTOList, Const.GLASS_STATE_IN); |
| | | log.info("4、大理片笼进片状态已完成已完成的玻璃信息id:{}", v); |
| | | updateSlotRemainBySlots(inSuccessGlassSlot); |
| | | } else if (e1 == 3) { |
| | | //破损处理 |
| | | dealDamageInTask(v); |
| | | } else { |
| | | //清空理片笼空数据 |
| | | noDealInTask(v); |
| | | } |
| | | }); |
| | | for (BigStorageCageTask item : inTaskList) { |
| | | //更新历史任务表中的任务状态 |
| | | bigStorageCageHistoryTaskService.update(new LambdaUpdateWrapper<BigStorageCageHistoryTask>() |
| | | .set(BigStorageCageHistoryTask::getTaskState, item.getTaskState()) |
| | | .eq(BigStorageCageHistoryTask::getTaskType, Const.BIG_STORAGE_BEFORE_IN) |
| | | .eq(BigStorageCageHistoryTask::getTargetSlot, item.getTargetSlot()) |
| | | .eq(BigStorageCageHistoryTask::getGlassId, item.getGlassId())); |
| | | item.setTargetSlot(0); |
| | | //清空任务表数据 |
| | | bigStorageCageTaskService.updateTaskMessage("big_storage_cage_in_one_task", item); |
| | | } |
| | | //清空启动状态 |
| | | //向opc发送启动信号 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.MesReply", 0)); |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void finishOutBigStorageTask() throws Exception { |
| | | ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1B.DLP1B.mesControl"); |
| | | if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | | log.info("当前为非联机状态,结束完成出片任务"); |
| | | return; |
| | | } |
| | | //获取进片任务表 |
| | | List<BigStorageCageTask> outTaskList = bigStorageCageTaskService.queryTaskMessage("big_storage_cage_out_one_task"); |
| | | if (CollectionUtil.isEmpty(outTaskList)) { |
| | | log.info("当前大车无进片玻璃,结束完成进片任务"); |
| | | return; |
| | | } |
| | | List<BigStorageCageTask> unFinishTaskList = outTaskList.stream().filter(e -> e.getTaskState() <= 1 || e.getStartSlot() == 0).collect(Collectors.toList()); |
| | | if (CollectionUtil.isNotEmpty(unFinishTaskList)) { |
| | | log.info("存在未完成的玻璃信息,玻璃:{}", unFinishTaskList); |
| | | return; |
| | | } |
| | | Map<Integer, List<BigStorageCageTask>> taskMap = outTaskList.stream().collect(Collectors.groupingBy(BigStorageCageTask::getTaskState)); |
| | | int taskType = 0; |
| | | if (Const.OUT_TARGET_POSITION_ALL.contains(outTaskList.get(0).getTargetSlot())) { |
| | | taskType = Const.BIG_STORAGE_BEFORE_OUT; |
| | | } else { |
| | | taskType = Const.BIG_STORAGE_BEFORE_DISPATCH; |
| | | } |
| | | //按照任务状态修改大理片笼内的玻璃数据 |
| | | // 重新计算大理片笼内的剩余尺寸 |
| | | Integer finalTaskType = taskType; |
| | | taskMap.forEach((e1, v) -> { |
| | | if (e1 == 2) { |
| | | //进片完成 |
| | | log.info("3、获取进片已完成的玻璃信息id:{}", v); |
| | | List<Integer> outSuccessGlassSlot = new ArrayList<>(); |
| | | if (finalTaskType.equals(Const.BIG_STORAGE_BEFORE_OUT)) { |
| | | outSuccessGlassSlot = v.stream().map(BigStorageCageTask::getStartSlot).collect(Collectors.toList()); |
| | | } else { |
| | | outSuccessGlassSlot = v.stream().map(BigStorageCageTask::getTargetSlot).collect(Collectors.toList()); |
| | | } |
| | | List<UpdateBigStorageCageDTO> storageCageDTOList = v.stream().map(e -> { |
| | | UpdateBigStorageCageDTO storageCageDTO = new UpdateBigStorageCageDTO(); |
| | | storageCageDTO.setGlassId(e.getGlassId()); |
| | | if (finalTaskType.equals(Const.BIG_STORAGE_BEFORE_OUT)) { |
| | | storageCageDTO.setTargetSlot(e.getStartSlot()); |
| | | } else { |
| | | storageCageDTO.setTargetSlot(e.getTargetSlot()); |
| | | } |
| | | return storageCageDTO; |
| | | }).collect(Collectors.toList()); |
| | | if (finalTaskType.equals(Const.BIG_STORAGE_BEFORE_OUT)) { |
| | | bigStorageCageDetailsService.updateBySlot(storageCageDTOList, Const.GLASS_STATE_OUT); |
| | | } else { |
| | | bigStorageCageDetailsService.updateBySlot(storageCageDTOList, Const.GLASS_STATE_IN); |
| | | } |
| | | log.info("4、大理片笼进片状态已完成已完成的玻璃信息id:{}", v); |
| | | updateSlotRemainBySlots(outSuccessGlassSlot); |
| | | } else if (e1 == 3) { |
| | | //破损处理 |
| | | dealDamageOutTask(v); |
| | | } else { |
| | | //清空理片笼空数据 |
| | | noDealOutTask(v); |
| | | } |
| | | }); |
| | | for (BigStorageCageTask item : outTaskList) { |
| | | //更新历史任务表中的任务状态 |
| | | bigStorageCageHistoryTaskService.update(new LambdaUpdateWrapper<BigStorageCageHistoryTask>() |
| | | .set(BigStorageCageHistoryTask::getTaskState, item.getTaskState()) |
| | | .eq(BigStorageCageHistoryTask::getTaskType, taskType) |
| | | .eq(BigStorageCageHistoryTask::getGlassId, item.getGlassId())); |
| | | //更新钢化小片表 |
| | | Integer taskState = item.getTaskState(); |
| | | if (taskState == 2) { |
| | | temperingGlassInfoService.update(new LambdaUpdateWrapper<TemperingGlassInfo>() |
| | | .set(TemperingGlassInfo::getState, Const.TEMPERING_OUT).eq(TemperingGlassInfo::getGlassId, item.getGlassId())); |
| | | } else if (taskState == 3) { |
| | | // temperingGlassInfoService.remove(new LambdaQueryWrapper<TemperingGlassInfo>().eq(TemperingGlassInfo::getGlassId, item.getGlassId())); |
| | | temperingGlassInfoService.update(new LambdaUpdateWrapper<TemperingGlassInfo>() |
| | | .set(TemperingGlassInfo::getState, Const.TEMPERING_DAMAGE |
| | | ).eq(TemperingGlassInfo::getGlassId, item.getGlassId())); |
| | | |
| | | } else { |
| | | // 空执行 |
| | | } |
| | | } |
| | | // 重置任务表数据 |
| | | bigStorageCageTaskService.updateOutTaskMessage("big_storage_cage_out_one_task"); |
| | | //清空启动状态 |
| | | //向opc发送启动信号 |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP1B.DLP1B.MesReply", 0)); |
| | | } |
| | | |
| | | private void dealDamageInTask(List<BigStorageCageTask> damageTaskList) { |
| | | // 获取进片任务表中状态为破损的数据 |
| | | log.info("破损的玻璃信息有:{}", damageTaskList); |
| | | //移除理片笼详情表任务执行过程中破损的玻璃 |
| | | bigStorageCageDetailsService.remove(new LambdaQueryWrapper<BigStorageCageDetails>() |
| | | .eq(BigStorageCageDetails::getState, Const.GLASS_STATE_NEW) |
| | | .in(BigStorageCageDetails::getGlassId, damageTaskList.stream().map(BigStorageCageTask::getGlassId).collect(Collectors.toList()))); |
| | | //将破损信息新增入破损表 |
| | | List<Integer> slotList = new ArrayList<>(); |
| | | for (BigStorageCageTask item : damageTaskList) { |
| | | Damage damage = new Damage(); |
| | | damage.setGlassId(item.getGlassId()); |
| | | damage.setLine(item.getStartSlot()); |
| | | damage.setWorkingProcedure("磨边"); |
| | | damage.setRemark("进笼前卧转立"); |
| | | damage.setStatus(1); |
| | | damage.setType(item.getTaskState()); |
| | | damageService.insertDamage(damage); |
| | | slotList.add(item.getTargetSlot()); |
| | | } |
| | | //更新格子剩余宽度 |
| | | updateSlotRemainBySlots(slotList); |
| | | log.info("进片任务-破损任务执行完成"); |
| | | } |
| | | |
| | | private void dealDamageOutTask(List<BigStorageCageTask> damageTaskList) { |
| | | // 获取进片任务表中状态为破损的数据 |
| | | log.info("破损的玻璃信息有:{}", damageTaskList); |
| | | //移除理片笼详情表任务执行过程中破损的玻璃 |
| | | bigStorageCageDetailsService.remove(new LambdaQueryWrapper<BigStorageCageDetails>() |
| | | .in(BigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL_ZERO) |
| | | .in(BigStorageCageDetails::getGlassId, damageTaskList.stream().map(BigStorageCageTask::getGlassId).collect(Collectors.toList()))); |
| | | //将破损信息新增入破损表 |
| | | List<Integer> slotList = new ArrayList<>(); |
| | | for (BigStorageCageTask item : damageTaskList) { |
| | | Damage damage = new Damage(); |
| | | damage.setGlassId(item.getGlassId()); |
| | | damage.setLine(item.getStartSlot()); |
| | | damage.setWorkingProcedure("钢化前"); |
| | | damage.setRemark("进笼后卧转立"); |
| | | damage.setStatus(1); |
| | | damage.setType(item.getTaskState()); |
| | | damageService.insertDamage(damage); |
| | | slotList.add(item.getTargetSlot()); |
| | | slotList.add(item.getStartSlot()); |
| | | } |
| | | //更新格子剩余宽度 |
| | | updateSlotRemainBySlots(slotList); |
| | | log.info("出片任务-破损任务执行完成"); |
| | | } |
| | | |
| | | private void noDealInTask(List<BigStorageCageTask> noDealTaskList) { |
| | | // 获取进片任务表中状态为破损的数据 |
| | | log.info("破损的玻璃信息有:{}", noDealTaskList); |
| | | //移除理片笼详情表未执行任务的空记录信息 |
| | | bigStorageCageDetailsService.remove(new LambdaQueryWrapper<BigStorageCageDetails>() |
| | | .eq(BigStorageCageDetails::getState, Const.GLASS_STATE_NEW) |
| | | .in(BigStorageCageDetails::getGlassId, noDealTaskList.stream().map(BigStorageCageTask::getGlassId).collect(Collectors.toList()))); |
| | | //记录格子号,按格子号更新剩余尺寸 |
| | | List<Integer> slotList = new ArrayList<>(); |
| | | for (BigStorageCageTask item : noDealTaskList) { |
| | | slotList.add(item.getTargetSlot()); |
| | | slotList.add(item.getStartSlot()); |
| | | } |
| | | //更新格子剩余宽度 |
| | | updateSlotRemainBySlots(slotList); |
| | | log.info("进片任务-无动作执行完成"); |
| | | } |
| | | |
| | | private void noDealOutTask(List<BigStorageCageTask> noDealTaskList) { |
| | | // 获取进片任务表中状态为破损的数据 |
| | | log.info("破损的玻璃信息有:{}", noDealTaskList); |
| | | if (Const.OUT_TARGET_POSITION_ALL.contains(noDealTaskList.get(0).getTargetSlot())) { |
| | | //出片任务:将出片中状态恢复为在笼内 |
| | | List<String> glassList = noDealTaskList.stream().map(BigStorageCageTask::getGlassId).collect(Collectors.toList()); |
| | | bigStorageCageDetailsService.update(new LambdaUpdateWrapper<BigStorageCageDetails>() |
| | | .set(BigStorageCageDetails::getState, Const.GLASS_STATE_IN) |
| | | .in(BigStorageCageDetails::getGlassId, glassList)); |
| | | |
| | | } else { |
| | | //调度任务:将调度中状态改为在笼内,格子号恢复为调度前的格子 |
| | | for (BigStorageCageTask item : noDealTaskList) { |
| | | bigStorageCageDetailsService.update(new LambdaUpdateWrapper<BigStorageCageDetails>() |
| | | .set(BigStorageCageDetails::getSlot, item.getStartSlot()) |
| | | .set(BigStorageCageDetails::getState, Const.GLASS_STATE_IN) |
| | | .eq(BigStorageCageDetails::getGlassId, item.getGlassId())); |
| | | } |
| | | } |
| | | //将破损信息新增入破损表 |
| | | List<Integer> slotList = new ArrayList<>(); |
| | | for (BigStorageCageTask item : noDealTaskList) { |
| | | slotList.add(item.getTargetSlot()); |
| | | slotList.add(item.getStartSlot()); |
| | | } |
| | | //更新格子剩余宽度 |
| | | updateSlotRemainBySlots(slotList); |
| | | log.info("出片任务-无动作执行完成"); |
| | | } |
| | | |
| | | /** |
| | | * 出片一次仅生成一车玻璃 |
| | | * |
| | | * @param list |
| | | * @param <T> |
| | | * @return |
| | | */ |
| | | private <T extends BigStorageCageBaseInfo> Boolean computeOutGlassInfo(List<T> list, String tableName, int targetSlot, int state, int taskType) { |
| | | //任务数据:获取车子存放玻璃最大数量,玻璃间隔 |
| | | List<BigStorageCageTask> bigStorageCageTaskList = new ArrayList<>(); |
| | | //打车剩余尺寸 |
| | | Integer remainWidth = carWidth; |
| | | for (T e : list) { |
| | | if (bigStorageCageTaskList.size() >= outCarMaxSize || Math.max((int) e.getWidth(), (int) e.getHeight()) > remainWidth) { |
| | | break; |
| | | } |
| | | //计算当前出片车剩尺寸 |
| | | remainWidth = remainWidth - Math.max((int) e.getWidth(), (int) e.getHeight()) - glassGap; |
| | | bigStorageCageTaskList.add(new BigStorageCageTask(e.getGlassId(), e.getSlot(), targetSlot, |
| | | 0)); |
| | | } |
| | | Assert.isFalse(CollectionUtil.isEmpty(bigStorageCageTaskList), "未获取出片数据,结束出片任务"); |
| | | log.info("获取出片任务数据{}条,执行保存", bigStorageCageTaskList.size()); |
| | | List<String> glassIds = bigStorageCageTaskList.stream().map(BigStorageCageTask::getGlassId).collect(Collectors.toList()); |
| | | int glassCount = bigStorageCageTaskList.size(); |
| | | //生成出片任务条数不足6补全 |
| | | while (bigStorageCageTaskList.size() < 6) { |
| | | bigStorageCageTaskList.add(new BigStorageCageTask("", 0, 0, 0)); |
| | | } |
| | | //清空任务表数据 |
| | | bigStorageCageTaskService.removeAll("big_storage_cage_out_one_task"); |
| | | bigStorageCageTaskService.saveTaskMessage(tableName, bigStorageCageTaskList); |
| | | List<BigStorageCageHistoryTask> historyList = bigStorageCageTaskList.stream().filter(e -> StringUtils.isNotBlank(e.getGlassId())).map(e -> { |
| | | BigStorageCageHistoryTask history = new BigStorageCageHistoryTask(); |
| | | BeanUtils.copyProperties(e, history); |
| | | history.setGlassCount(glassCount); |
| | | history.setTaskType(taskType); |
| | | return history; |
| | | }).collect(Collectors.toList()); |
| | | bigStorageCageHistoryTaskService.saveBatch(historyList); |
| | | |
| | | log.info("将出片玻璃{}玻璃状态改为出片中", glassIds); |
| | | bigStorageCageDetailsService.update(new LambdaUpdateWrapper<BigStorageCageDetails>() |
| | | .set(BigStorageCageDetails::getState, state) |
| | | .set(Const.GLASS_STATE_SCHEDULE_ING.equals(state), BigStorageCageBaseInfo::getSlot, targetSlot) |
| | | .in(BigStorageCageDetails::getGlassId, glassIds)); |
| | | try { |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP1B.DLP1B.MesReply", 1)); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return Boolean.TRUE; |
| | | } |
| | | |
| | | |
| | | public void updateSlotRemainBySlots(List<Integer> slotList) { |
| | | //获取格子内所有的玻璃信息 |
| | | List<BigStorageCageDetails> inSlotGlassList = bigStorageCageDetailsService.list(new LambdaQueryWrapper<BigStorageCageDetails>() |
| | | .in(BigStorageCageDetails::getSlot, slotList).in(BigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL)); |
| | | Map<Integer, Double> slotRemainMap = new HashMap<>(); |
| | | //是否存在有格子非空的玻璃 |
| | | if (CollectionUtil.isNotEmpty(inSlotGlassList)) { |
| | | //存在 将格子内的玻璃分别进行更新 |
| | | slotRemainMap = inSlotGlassList.stream() |
| | | .collect(Collectors.groupingBy(BigStorageCageDetails::getSlot, Collectors.summingDouble(item -> Math.max(item.getWidth(), item.getHeight()) + glassGap))); |
| | | slotRemainMap.forEach((e, v) -> { |
| | | double remainWidth = slotWidth - v >= 0 ? slotWidth - v : 0; |
| | | bigStorageCageService.update(new LambdaUpdateWrapper<BigStorageCage>().set(BigStorageCage::getRemainWidth, remainWidth) |
| | | .eq(BigStorageCage::getSlot, e)); |
| | | }); |
| | | } |
| | | //过滤不存在玻璃的格子 将宽度重置为原始宽度5000 |
| | | Set<Integer> remainSlotList = slotRemainMap.keySet(); |
| | | slotList.removeAll(remainSlotList); |
| | | if (CollectionUtil.isNotEmpty(slotList)) { |
| | | bigStorageCageService.update(new LambdaUpdateWrapper<BigStorageCage>().set(BigStorageCage::getRemainWidth, slotWidth) |
| | | .in(BigStorageCage::getSlot, slotList)); |
| | | } |
| | | } |
| | | |
| | | private ReadWriteEntity generateReadWriteEntity(String identifier, Object value) { |
| | | return ReadWriteEntity.builder() |
| | | .identifier(identifier) |
| | | //Kep中是Long类型,即:Int32,Java中的int类型 |
| | | .value(value) |
| | | .build(); |
| | | } |
| | | } |
| | |
| | | import com.mes.base.entity.BigStorageCageBaseInfo; |
| | | import com.mes.bigstorage.entity.BigStorageCage; |
| | | import com.mes.bigstorage.entity.BigStorageCageDetails; |
| | | import com.mes.bigstorage.entity.BigStorageDTO; |
| | | import com.mes.bigstorage.entity.dto.BigStorageDTO; |
| | | import com.mes.bigstorage.entity.dto.SlotSequenceDTO; |
| | | import com.mes.bigstorage.entity.dto.TemperingLayoutDTO; |
| | | import com.mes.bigstorage.service.BigStorageCageDetailsService; |
| | |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | private boolean sequenceOrder; |
| | | |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | // @Scheduled(fixedDelay = 1000) |
| | | public void inBigStorageTask() throws Exception { |
| | | ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1A.DLP1A.mesControl"); |
| | | if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | |
| | | if (CollectionUtils.isEmpty(inTaskList)) { |
| | | log.info("当前大车无进片玻璃,结束进片任务"); |
| | | } |
| | | |
| | | List<String> glassIdList = inTaskList.stream().map(BigStorageCageTask::getGlassId).collect(Collectors.toList()); |
| | | log.info("获取任务的玻璃id:{}", glassIdList); |
| | | Map<String, Long> glassCountMap = glassIdList.stream().collect(Collectors.groupingBy(e -> e, Collectors.counting())); |
| | | for (Map.Entry<String, Long> entry : glassCountMap.entrySet()) { |
| | | if (entry.getValue() > 1) { |
| | | log.info("进片玻璃{}存在相同,结束本次任务", entry.getKey()); |
| | | //todo:向plc发送报警 |
| | | return; |
| | | } |
| | | } |
| | | List<BigStorageCageDetails> detailsList = bigStorageCageDetailsService.list(new LambdaQueryWrapper<BigStorageCageDetails>().in(BigStorageCageDetails::getGlassId, glassIdList) |
| | | .eq(BigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL)); |
| | | if (CollectionUtil.isNotEmpty(detailsList)) { |
| | | log.info("理片笼存在相同的进片玻璃{},结束本次任务", detailsList); |
| | | //todo:向plc发送报警 |
| | | return; |
| | | } |
| | | List<GlassInfo> glassInfoList = glassInfoService.list(new LambdaQueryWrapper<GlassInfo>().in(GlassInfo::getGlassId, glassIdList)); |
| | | |
| | | Map<String, List<GlassInfo>> glassListMap = glassInfoList.stream().collect(Collectors.groupingBy(GlassInfo::getGlassId)); |
| | |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.MesReply", 1)); |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | // @Scheduled(fixedDelay = 1000) |
| | | public void outBigStorageTask() throws Exception { |
| | | Date startDate = new Date(); |
| | | ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1B.DLP1B.mesControl"); |
| | |
| | | if (CollectionUtils.isNotEmpty(list)) { |
| | | computeOutGlassInfo(list, "big_storage_cage_out_one_task", second.getSlot(), Const.GLASS_STATE_SCHEDULE_ING, Const.BIG_STORAGE_BEFORE_DISPATCH); |
| | | } |
| | | updateSlotRemainBySlots(Arrays.asList(second.getSlot())); |
| | | //使用Arrays.asList() 使用removeAll报错,改为正常使用List |
| | | List<Integer> slotList = new ArrayList<>(); |
| | | slotList.add(second.getSlot()); |
| | | updateSlotRemainBySlots(slotList); |
| | | break loop; |
| | | } |
| | | } |
| | |
| | | return; |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | // @Scheduled(fixedDelay = 1000) |
| | | public void finishInBigStorageTask() throws Exception { |
| | | ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1A.DLP1A.mesControl"); |
| | | if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | |
| | | miloService.writeToOpcWord(generateReadWriteEntity("DLP1A.DLP1A.MesReply", 0)); |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | // @Scheduled(fixedDelay = 1000) |
| | | public void finishOutBigStorageTask() throws Exception { |
| | | ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP1B.DLP1B.mesControl"); |
| | | if (true != Boolean.parseBoolean(inkageEntity.getValue() + "")) { |
| | |
| | | .set(BigStorageCageHistoryTask::getTaskState, item.getTaskState()) |
| | | .eq(BigStorageCageHistoryTask::getTaskType, taskType) |
| | | .eq(BigStorageCageHistoryTask::getGlassId, item.getGlassId())); |
| | | //更新钢化小片表 |
| | | Integer taskState = item.getTaskState(); |
| | | if (taskState == 2) { |
| | | temperingGlassInfoService.update(new LambdaUpdateWrapper<TemperingGlassInfo>() |
| | | .set(TemperingGlassInfo::getState, Const.TEMPERING_OUT).eq(TemperingGlassInfo::getGlassId, item.getGlassId())); |
| | | } else if (taskState == 3) { |
| | | // temperingGlassInfoService.remove(new LambdaQueryWrapper<TemperingGlassInfo>().eq(TemperingGlassInfo::getGlassId, item.getGlassId())); |
| | | temperingGlassInfoService.update(new LambdaUpdateWrapper<TemperingGlassInfo>() |
| | | .set(TemperingGlassInfo::getState, Const.TEMPERING_DAMAGE |
| | | ).eq(TemperingGlassInfo::getGlassId, item.getGlassId())); |
| | | |
| | | } else { |
| | | // 空执行 |
| | | } |
| | | } |
| | | // 重置任务表数据 |
| | | bigStorageCageTaskService.updateOutTaskMessage("big_storage_cage_out_one_task"); |
| | |
| | | import com.mes.base.entity.BigStorageCageBaseInfo; |
| | | import com.mes.bigstorage.entity.BigStorageCage; |
| | | import com.mes.bigstorage.entity.BigStorageCageDetails; |
| | | import com.mes.bigstorage.entity.BigStorageDTO; |
| | | import com.mes.bigstorage.entity.dto.BigStorageDTO; |
| | | import com.mes.bigstorage.entity.dto.SlotSequenceDTO; |
| | | import com.mes.bigstorage.entity.dto.TemperingLayoutDTO; |
| | | import com.mes.bigstorage.service.BigStorageCageDetailsService; |
| | |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | private String d01GlassId = ""; |
| | | private String d04GlassId = ""; |
| | | |
| | | @Scheduled(fixedDelay = 300) |
| | | // @Scheduled(fixedDelay = 300) |
| | | public void plcToHomeEdgScan() { |
| | | Date startDate = new Date(); |
| | | log.info("大理片笼扫码任务开始执行时间:{}", startDate); |
| | |
| | | } |
| | | //按照线路及玻璃id获取相邻两块玻璃 卧转立上的玻璃: 状态为0不操作(D01送片,0不操作,1允许送片),请求字为1, (02玻璃id为空或者卧转立未启动) |
| | | if (!REQUEST_WORD.equals(mesD01Value) && REQUEST_WORD.equals(d01ToMES) && (StringUtils.isBlank(d02State) || !REQUEST_WORD.equals(d03State))) { |
| | | List<BigStorageCageFeedTask> bigStorageCageFeedTasks=bigStorageCageFeedTaskService.list( |
| | | new LambdaQueryWrapper<BigStorageCageFeedTask>() |
| | | .gt(BigStorageCageFeedTask::getTargetSlot,0) |
| | | .eq(BigStorageCageFeedTask::getLine,Const.A09_OUT_TARGET_POSITION) |
| | | .eq(BigStorageCageFeedTask::getTaskState,Const.BIG_STORAGE_IN_UP) |
| | | List<BigStorageCageFeedTask> bigStorageCageFeedTasks = bigStorageCageFeedTaskService.list( |
| | | new LambdaQueryWrapper<BigStorageCageFeedTask>() |
| | | .gt(BigStorageCageFeedTask::getTargetSlot, 0) |
| | | .eq(BigStorageCageFeedTask::getLine, Const.A09_OUT_TARGET_POSITION) |
| | | .eq(BigStorageCageFeedTask::getTaskState, Const.BIG_STORAGE_IN_UP) |
| | | ); |
| | | if(CollectionUtils.isEmpty(bigStorageCageFeedTasks)){ |
| | | if (CollectionUtils.isEmpty(bigStorageCageFeedTasks)) { |
| | | if (!d01GlassId.equals(d01Id)) { |
| | | judgeGlassTypeStatus(d01Id, Const.A09_OUT_TARGET_POSITION, mesD01Address); |
| | | edgGlassTaskInfoService.update(new LambdaUpdateWrapper<EdgGlassTaskInfo>() |
| | | .set(EdgGlassTaskInfo::getStatus, Const.EDG_GLASS_SUCCESS).eq(EdgGlassTaskInfo::getGlassId, d01Id)); |
| | | .set(EdgGlassTaskInfo::getState, Const.EDG_GLASS_SUCCESS).eq(EdgGlassTaskInfo::getGlassId, d01Id)); |
| | | // d01GlassId = d01Id; |
| | | } |
| | | } |
| | | } |
| | | // 状态为0不操作(D01送片,0不操作,1允许送片),请求字为1, 卧转立未启动 |
| | | if (!REQUEST_WORD.equals(mesD04Value) && REQUEST_WORD.equals(d04ToMES) && !REQUEST_WORD.equals(d05State)) { |
| | | List<BigStorageCageFeedTask> bigStorageCageFeedTasks=bigStorageCageFeedTaskService.list( |
| | | List<BigStorageCageFeedTask> bigStorageCageFeedTasks = bigStorageCageFeedTaskService.list( |
| | | new LambdaQueryWrapper<BigStorageCageFeedTask>() |
| | | .gt(BigStorageCageFeedTask::getTargetSlot,0) |
| | | .eq(BigStorageCageFeedTask::getLine,Const.A10_OUT_TARGET_POSITION) |
| | | .eq(BigStorageCageFeedTask::getTaskState,Const.BIG_STORAGE_IN_UP) |
| | | .gt(BigStorageCageFeedTask::getTargetSlot, 0) |
| | | .eq(BigStorageCageFeedTask::getLine, Const.A10_OUT_TARGET_POSITION) |
| | | .eq(BigStorageCageFeedTask::getTaskState, Const.BIG_STORAGE_IN_UP) |
| | | ); |
| | | if(CollectionUtils.isEmpty(bigStorageCageFeedTasks)){ |
| | | if (CollectionUtils.isEmpty(bigStorageCageFeedTasks)) { |
| | | if (!d04GlassId.equals(d04Id)) { |
| | | judgeGlassTypeStatus(d04Id, Const.A10_OUT_TARGET_POSITION, mesD04Address); |
| | | edgGlassTaskInfoService.update(new LambdaUpdateWrapper<EdgGlassTaskInfo>() |
| | | .set(EdgGlassTaskInfo::getStatus, Const.EDG_GLASS_SUCCESS).eq(EdgGlassTaskInfo::getGlassId, d04Id)); |
| | | .set(EdgGlassTaskInfo::getState, Const.EDG_GLASS_SUCCESS).eq(EdgGlassTaskInfo::getGlassId, d04Id)); |
| | | // d04GlassId = d04Id; |
| | | } |
| | | } |
| | |
| | | log.info("大理片笼扫码任务结束时间:{},共耗时:{}ms,结束扫码任务", endDate, endDate.getTime() - startDate.getTime()); |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 300) |
| | | // @Scheduled(fixedDelay = 300) |
| | | public void plcToHomeEdgFreeCarTask() { |
| | | Date startDate = new Date(); |
| | | log.info("大理片笼空车进片任务开始执行时间:{}", startDate); |
| | |
| | | //获取卧转立剩余宽度 |
| | | if (computeIsRun(lineFirst, lineGlassId)) { |
| | | computeTargetByLine(lineFirst); |
| | | }else{ |
| | | log.info("当前线路:{},有扫码玻璃:{}",lineFirst,lineGlassId); |
| | | } else { |
| | | log.info("当前线路:{},有扫码玻璃:{}", lineFirst, lineGlassId); |
| | | } |
| | | } |
| | | Date endDate = new Date(); |
| | |
| | | log.info("大理片笼空车进片任务结束时间:{},共耗时:{}ms,结束扫码任务", endDate, endDate.getTime() - startDate.getTime()); |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 10000) |
| | | // @Scheduled(fixedDelay = 10000) |
| | | public void plcToHomeEdgOutTask() { |
| | | Date startDate = new Date(); |
| | | log.info("大理片笼空车进片任务开始执行时间:{}", startDate); |
| | |
| | | } |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 300) |
| | | // @Scheduled(fixedDelay = 300) |
| | | public void updateInGlassStateTask() { |
| | | Date startDate = new Date(); |
| | | log.info("1、大理片笼进片完成后更新大理片笼数据任务开始执行时间:{}", startDate); |
| | |
| | | |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 300) |
| | | // @Scheduled(fixedDelay = 300) |
| | | public void updateOutGlassStateTask() { |
| | | Date startDate = new Date(); |
| | | log.info("1、大理片笼出片完成后更新大理片笼数据任务开始执行时间:{}", startDate); |
| | |
| | | |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 300) |
| | | // @Scheduled(fixedDelay = 300) |
| | | public void updateScheduleGlassStateTask() { |
| | | Date startDate = new Date(); |
| | | log.info("1、大理片笼调度完成后更新大理片笼数据任务开始执行时间:{}", startDate); |
| | |
| | | /** |
| | | * 处理破损表任务 |
| | | */ |
| | | @Scheduled(fixedDelay = 300) |
| | | // @Scheduled(fixedDelay = 300) |
| | | public void dealDamageTask() { |
| | | Date startDate = new Date(); |
| | | log.info("大理片笼破损玻璃清除任务开始执行时间:{}", startDate); |
| | |
| | | /** |
| | | * 确认字清空 |
| | | */ |
| | | @Scheduled(fixedDelay = 300) |
| | | // @Scheduled(fixedDelay = 300) |
| | | public void confirmClear() { |
| | | PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject; |
| | | String d01ToMES = plcParameterObject.getPlcParameter("D01ToMES").getValue(); |
| | |
| | | String mesD03Address = plcParameterObject.getPlcParameter("MESToD03").getAddress(); |
| | | String mesD05Address = plcParameterObject.getPlcParameter("MESToD05").getAddress(); |
| | | if (!REQUEST_WORD.equals(d01ToMES)) { |
| | | log.info("地址:{}写入0",mesD01Address); |
| | | log.info("地址:{}写入0", mesD01Address); |
| | | S7object.getinstance().plccontrol.writeWord(mesD01Address, 0); |
| | | } |
| | | if (!REQUEST_WORD.equals(d04ToMES)) { |
| | | log.info("地址:{}写入0",mesD04Address); |
| | | log.info("地址:{}写入0", mesD04Address); |
| | | S7object.getinstance().plccontrol.writeWord(mesD04Address, 0); |
| | | } |
| | | if (!REQUEST_WORD.equals(d03ToMES)) { |
| | | log.info("地址:{}写入0",mesD03Address); |
| | | log.info("地址:{}写入0", mesD03Address); |
| | | S7object.getinstance().plccontrol.writeWord(mesD03Address, 0); |
| | | } |
| | | if (!REQUEST_WORD.equals(d05ToMES)) { |
| | | log.info("地址:{}写入0",mesD05Address); |
| | | log.info("地址:{}写入0", mesD05Address); |
| | | S7object.getinstance().plccontrol.writeWord(mesD05Address, 0); |
| | | } |
| | | } |
| | |
| | | /** |
| | | * 进片状态修改 |
| | | */ |
| | | @Scheduled(fixedDelay = 300) |
| | | // @Scheduled(fixedDelay = 300) |
| | | public void feedStatusUpdate() { |
| | | PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject; |
| | | String mesD03Address = plcParameterObject.getPlcParameter("MESToD03").getAddress(); |
| | |
| | | .filter(glassIds1::contains) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | log.info("D3id{},匹配id:{}",glassIds1,matchingIds1); |
| | | if(CollectionUtils.isNotEmpty(matchingIds1)){ |
| | | log.info("D3id{},匹配id:{}", glassIds1, matchingIds1); |
| | | if (CollectionUtils.isNotEmpty(matchingIds1)) { |
| | | bigStorageCageFeedTaskService.update( |
| | | new LambdaUpdateWrapper<BigStorageCageFeedTask>() |
| | | .in(BigStorageCageFeedTask::getGlassId, matchingIds1) |
| | |
| | | .filter(glassIds2::contains) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | log.info("D5id{},匹配id:{}",glassIds2,matchingIds2); |
| | | if(CollectionUtils.isNotEmpty(matchingIds2)){ |
| | | log.info("D5id{},匹配id:{}", glassIds2, matchingIds2); |
| | | if (CollectionUtils.isNotEmpty(matchingIds2)) { |
| | | bigStorageCageFeedTaskService.update( |
| | | new LambdaUpdateWrapper<BigStorageCageFeedTask>() |
| | | .in(BigStorageCageFeedTask::getGlassId, matchingIds2) |
| | |
| | | } |
| | | if (CollectionUtils.isEmpty(glassIds1)) { |
| | | S7object.getinstance().plccontrol.writeWord(mesD03Address, 0); |
| | | log.info("{}线修改玻璃状态为3",Const.A09_OUT_TARGET_POSITION); |
| | | log.info("{}线修改玻璃状态为3", Const.A09_OUT_TARGET_POSITION); |
| | | bigStorageCageFeedTaskService.update( |
| | | new LambdaUpdateWrapper<BigStorageCageFeedTask>() |
| | | .eq(BigStorageCageFeedTask::getLine, Const.A09_OUT_TARGET_POSITION) |
| | |
| | | } |
| | | if (CollectionUtils.isEmpty(glassIds2)) { |
| | | S7object.getinstance().plccontrol.writeWord(mesD05Address, 0); |
| | | log.info("{}线修改玻璃状态为3",Const.A10_OUT_TARGET_POSITION); |
| | | log.info("{}线修改玻璃状态为3", Const.A10_OUT_TARGET_POSITION); |
| | | bigStorageCageFeedTaskService.update( |
| | | new LambdaUpdateWrapper<BigStorageCageFeedTask>() |
| | | .eq(BigStorageCageFeedTask::getLine, Const.A10_OUT_TARGET_POSITION) |
| | |
| | | edgGlassTaskInfoList = edgGlassTaskInfoService.list(new LambdaQueryWrapper<EdgGlassTaskInfo>() |
| | | .eq(EdgGlassTaskInfo::getLine, line) |
| | | .apply("time >= (select time from edg_glass_task_info where line='" + line + "' and glass_id = '" + glassId + "' and deleted = 0)") |
| | | .orderByAsc(EdgGlassTaskInfo::getTime)); |
| | | .orderByAsc(EdgGlassTaskInfo::getCreateTime)); |
| | | if (edgGlassTaskInfoList.size() == 0) { |
| | | edgGlassTaskInfoList = edgGlassTaskInfoService.list(new QueryWrapper<EdgGlassTaskInfo>() |
| | | .select("Top 1 *") |
| | |
| | | returnData = glassIds2; |
| | | } |
| | | // returnData = s7control.readWord(outLine, 1).get(0); |
| | | log.info("已向plc第{}次发送进片任务确认,地址为:{},写入的内容为{},读到的请求为{}", count++, outLine, 2,returnData); |
| | | log.info("已向plc第{}次发送进片任务确认,地址为:{},写入的内容为{},读到的请求为{}", count++, outLine, 2, returnData); |
| | | } |
| | | // while (returnData != 0) { |
| | | // s7control.writeWord(outLine, 2); |
| | |
| | | package com.mes.tools.service; |
| | | |
| | | import com.mes.bigstorage.entity.BigStorageDTO; |
| | | import com.mes.bigstorage.entity.dto.BigStorageDTO; |
| | | import com.mes.glassinfo.entity.GlassInfo; |
| | | |
| | | import java.util.List; |
| | |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.mes.bigstorage.entity.BigStorageCage; |
| | | import com.mes.bigstorage.entity.BigStorageCageDetails; |
| | | import com.mes.bigstorage.entity.BigStorageDTO; |
| | | import com.mes.bigstorage.entity.dto.BigStorageDTO; |
| | | import com.mes.bigstorage.service.BigStorageCageDetailsService; |
| | | import com.mes.bigstorage.service.BigStorageCageService; |
| | | import com.mes.bigstoragetask.entity.BigStorageCageFeedTask; |
| | |
| | | import com.mes.tools.service.BigStorageBaseService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | } |
| | | |
| | | |
| | | @Scheduled(fixedDelay = 300) |
| | | // @Scheduled(fixedDelay = 300) |
| | | public void querySizeByEngineerTask() { |
| | | log.info("查询结果:{}", querySizeByEngineer("P24072402", 1, 10, 8)); |
| | | log.info("查询结果:{}", querySizeByEngineer("P24072402", 1, 5, 8)); |
| | |
| | | username: root |
| | | password: beibo.123/ |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| | | salve_hangzhoumes: |
| | | url: jdbc:sqlserver://192.168.2.100:1433;databasename=mes |
| | | username: sa |
| | | password: beibo.123/ |
| | | driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver |
| | | cloud: |
| | | nacos: |
| | | discovery: |
| | |
| | | |
| | | spring: |
| | | profiles: |
| | | active: cz |
| | | active: yw |
| | | application: |
| | | name: cacheVerticalGlass |
| | | liquibase: |
| | |
| | | thread-name-prefix: task-cacheVertical |
| | | mybatis-plus: |
| | | mapper-locations: classpath*:mapper/*.xml |
| | | # configuration: |
| | | # log-impl: org.apache.ibatis.logging.stdout.StdOutImpl |
| | | configuration: |
| | | log-impl: org.apache.ibatis.logging.stdout.StdOutImpl |
| | | mes: |
| | | sequence: |
| | | order: false |
| | | minCount: 20 |
| | | carWidth: 5000 #大车宽度 |
| | | slotWidth: 5500 #大车宽度 |
| | | inCarMaxSize: 2 #进片大车最大存放玻璃数量 |
| | | order: true |
| | | minCount: 30 |
| | | carWidth: 6200 #大车宽度 |
| | | slotWidth: 6200 #大车宽度 |
| | | inCarMaxSize: 5 #进片大车最大存放玻璃数量 |
| | | outCarMaxSize: 3 #出片大车最大存放玻璃数量 |
| | | glassGap: 350 #玻璃间距 |
| | | glassGap: 250 #玻璃间距 |
| | | xMaxSize: 2800 |
| | | scan: |
| | | ip: 192.168.30.199 |
| | | port: 5000 |
| | | kangaroohy: |
| | | milo: |
| | | enabled: false |
| | | enabled: true |
| | | primary: default |
| | | config: |
| | | default: |
| | | endpoint: opc.tcp://192.168.2.100:49320 |
| | | security-policy: basic256sha256 |
| | | username: admin |
| | | password: 1qaz2wsx3edc4rfv |
| | |
| | | <result column="remain_width" property="remainWidth"/> |
| | | </resultMap> |
| | | |
| | | <resultMap id="virtualSlotSequenceDTO" type="com.mes.bigstorage.entity.dto.BigStorageRelationDTO"> |
| | | <result column="engineer_id" property="engineerId"/> |
| | | <result column="tempering_layout_id" property="temperingLayoutId"/> |
| | | <result column="virtual_slot" property="virtualSlot"/> |
| | | </resultMap> |
| | | <resultMap id="baseSlotSequenceDTO" type="com.mes.bigstorage.entity.dto.BigStorageSequenceDTO"> |
| | | <result column="slot" property="slot"/> |
| | | <result column="max_sequence" property="maxSequence"/> |
| | | <result column="min_sequence" property="minSequence"/> |
| | | </resultMap> |
| | | |
| | | <select id="temperingIsAll" resultMap="temperingLayoutDTO"> |
| | | SELECT T2.* |
| | | FROM ( |
| | | SELECT T.ENGINEER_ID, |
| | | T.TEMPERING_LAYOUT_ID, |
| | | COUNT(T.TEMPERING_FEED_SEQUENCE) AS COUNT |
| | | FROM |
| | | GLASS_INFO T |
| | | LEFT JOIN DAMAGE T1 |
| | | ON T.ENGINEER_ID = T1.ENGINEER_ID |
| | | AND T.GLASS_ID = T1.GLASS_ID |
| | | AND (T1.TYPE = 8 |
| | | OR T1.TYPE = 9 ) |
| | | WHERE |
| | | T1.GLASS_ID IS NULL |
| | | GROUP BY |
| | | T.ENGINEER_ID, |
| | | T.TEMPERING_LAYOUT_ID |
| | | FROM GLASS_INFO T |
| | | LEFT JOIN DAMAGE T1 |
| | | ON T.ENGINEER_ID = T1.ENGINEER_ID |
| | | AND T.GLASS_ID = T1.GLASS_ID |
| | | AND (T1.TYPE = 8 |
| | | OR T1.TYPE = 9) |
| | | WHERE T1.GLASS_ID IS NULL |
| | | GROUP BY T.ENGINEER_ID, |
| | | T.TEMPERING_LAYOUT_ID |
| | | ) T2 |
| | | INNER JOIN (SELECT ENGINEER_ID, TEMPERING_LAYOUT_ID, COUNT(TEMPERING_FEED_SEQUENCE) AS COUNT |
| | | FROM BIG_STORAGE_CAGE_DETAILS |
| | |
| | | GROUP BY ENGINEER_ID, TEMPERING_LAYOUT_ID) T3 ON T2.ENGINEER_ID = T3.ENGINEER_ID |
| | | AND T2.TEMPERING_LAYOUT_ID = T3.TEMPERING_LAYOUT_ID |
| | | AND T2.COUNT = T3.COUNT |
| | | INNER JOIN ENGINEERING T4 ON T2.ENGINEER_ID=T4.ENGINEER_ID |
| | | INNER JOIN ENGINEERING T4 ON T2.ENGINEER_ID = T4.ENGINEER_ID |
| | | ORDER BY T4.ID, T2.TEMPERING_LAYOUT_ID |
| | | </select> |
| | | |
| | |
| | | </update> |
| | | |
| | | <select id="selectTemperingGlassCount" resultType="java.util.Map"> |
| | | select a.engineer_id,a.tempering_layout_id,count2,count1,count2-count1 as count3,count(c.glass_id) as count4 from |
| | | (select engineer_id,tempering_layout_id,count(*) as count1 from big_storage_cage_details where state=100 group by engineer_id,tempering_layout_id) as a |
| | | left join |
| | | (select engineer_id,tempering_layout_id,count(*) as count2 from glass_info group by engineer_id,tempering_layout_id) as b |
| | | on a.engineer_id=b.engineer_id and a.tempering_layout_id=b.tempering_layout_id |
| | | left join damage as c on a.engineer_id=c.engineer_id and a.tempering_layout_id=c.tempering_layout_id and (type = 8 or type = 9) |
| | | group by a.engineer_id,a.tempering_layout_id |
| | | order by a.engineer_id,a.tempering_layout_id |
| | | select a.engineer_id, |
| | | a.tempering_layout_id, |
| | | count2, |
| | | count1, |
| | | count2 - count1 as count3, |
| | | count(c.glass_id) as count4 |
| | | from (select engineer_id, tempering_layout_id, count(*) as count1 |
| | | from big_storage_cage_details |
| | | where state = 100 |
| | | group by engineer_id, tempering_layout_id) as a |
| | | left join |
| | | (select engineer_id, tempering_layout_id, count(*) as count2 |
| | | from glass_info |
| | | group by engineer_id, tempering_layout_id) as b |
| | | on a.engineer_id = b.engineer_id and a.tempering_layout_id = b.tempering_layout_id |
| | | left join damage as c |
| | | on a.engineer_id = c.engineer_id and a.tempering_layout_id = c.tempering_layout_id and |
| | | (type = 8 or type = 9) |
| | | group by a.engineer_id, a.tempering_layout_id |
| | | order by a.engineer_id, a.tempering_layout_id |
| | | </select> |
| | | |
| | | <select id="queryIsAllNeedDispatchVirtualSlot" resultMap="virtualSlotSequenceDTO"> |
| | | with relation_temp as ( |
| | | select engineer_id, tempering_layout_id, virtual_slot, count(1) as slot_count |
| | | from big_storage_glass_relation_info |
| | | group by engineer_id, tempering_layout_id, virtual_slot |
| | | ), |
| | | details_temp as ( |
| | | select t.engineer_id, t.tempering_layout_id, t.virtual_slot, count(1) as slot_count |
| | | from big_storage_glass_relation_info t |
| | | left join big_storage_cage_details t1 on t.glass_id = t1.glass_id |
| | | where t1.state = 100 |
| | | group by t.engineer_id, t.tempering_layout_id, t.virtual_slot |
| | | ), |
| | | result_one as ( |
| | | select t.*, t1.slot_count as tslot_count |
| | | from relation_temp t |
| | | INNER JOIN details_temp t1 on t.engineer_id = t1.engineer_id and |
| | | t.tempering_layout_id = t1.tempering_layout_id and |
| | | t.virtual_slot = t1.virtual_slot |
| | | where t.slot_count = t1.slot_count |
| | | ) |
| | | select engineer_id, tempering_layout_id, virtual_slot |
| | | from result_one |
| | | order by engineer_id, tempering_layout_id |
| | | </select> |
| | | |
| | | <select id="queryNeedDispatchSlot" resultMap="baseSlotSequenceDTO"> |
| | | with glass_id_temp as ( |
| | | select glass_id |
| | | from big_storage_glass_relation_info |
| | | where (engineer_id, tempering_layout_id, virtual_slot) = |
| | | (#{engineerId}, #{temperingLayoutId}, #{virtualSlot}) |
| | | ) |
| | | select t.slot, max(t1.slot_sequence) as max_sequence, min(t1.slot_sequence) as min_sequence |
| | | from big_storage_cage_details t |
| | | inner join big_storage_glass_relation_info t1 on t.glass_id = t1.glass_id |
| | | where t.glass_id in (select * from glass_id_temp) |
| | | group by t.slot |
| | | order by max_sequence |
| | | </select> |
| | | </mapper> |
| | |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.mes.bigstoragetask.mapper.BigStorageCageFeedTaskMapper"> |
| | | |
| | | <resultMap id="bigStorageDTO" type="com.mes.bigstorage.entity.BigStorageDTO"> |
| | | <resultMap id="bigStorageDTO" type="com.mes.bigstorage.entity.dto.BigStorageDTO"> |
| | | <result column="REMAIN_WIDTH" property="width"/> |
| | | <result column="GLASS_COUNT" property="glassCount"/> |
| | | </resultMap> |
| | |
| | | INSERT INTO big_storage_cage_out_two_task(glass_id, start_slot, target_slot, task_state) |
| | | VALUES (NULL, 0, 0, 0); |
| | | |
| | | |
| | | -- changeset zsh:20241126001 |
| | | -- preconditions onFail:CONTINUE onError:CONTINUE |
| | | -- precondition-sql-check expectedResult:0 SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'big_storage_glass_info' and table_schema = 'hangzhoumes'; |
| | | CREATE TABLE big_storage_glass_info |
| | | ( |
| | | id bigint NOT NULL AUTO_INCREMENT COMMENT '大理片笼信息表id', |
| | | glass_id varchar(20) DEFAULT NULL COMMENT '玻璃id', |
| | | flow_card_id varchar(20) DEFAULT NULL COMMENT '流程卡号', |
| | | glass_type int DEFAULT NULL COMMENT '玻璃类型', |
| | | width double DEFAULT NULL COMMENT '宽', |
| | | height double DEFAULT NULL COMMENT '高', |
| | | thickness double DEFAULT NULL COMMENT '厚度', |
| | | tempering_layout_id int DEFAULT NULL COMMENT '钢化版图id', |
| | | tempering_feed_sequence int DEFAULT NULL COMMENT '钢化版图片序', |
| | | x_coordinate int DEFAULT NULL COMMENT 'x坐标', |
| | | y_coordinate int DEFAULT NULL COMMENT 'y坐标', |
| | | engineer_id varchar(50) DEFAULT NULL, |
| | | layer int DEFAULT NULL COMMENT '层号', |
| | | virtual_slot int DEFAULT NULL COMMENT '虚拟格子号', |
| | | slot_sequence int DEFAULT NULL COMMENT '格子次序', |
| | | PRIMARY KEY (id) USING BTREE |
| | | ); |
| | | -- rollback DROP TABLE big_storage_glass_info; |
| | | |
| | | -- changeset zsh:20241126002 |
| | | -- preconditions onFail:CONTINUE onError:CONTINUE |
| | | -- precondition-sql-check expectedResult:0 SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'big_storage_glass_relation_info' and table_schema = 'hangzhoumes'; |
| | | CREATE TABLE big_storage_glass_relation_info |
| | | ( |
| | | id bigint NOT NULL AUTO_INCREMENT COMMENT '钢化玻璃关系表id', |
| | | engineer_id varchar(50) DEFAULT NULL, |
| | | glass_id varchar(20) DEFAULT NULL COMMENT '玻璃id', |
| | | tempering_layout_id int DEFAULT NULL COMMENT '钢化版图id', |
| | | tempering_feed_sequence int DEFAULT NULL COMMENT '钢化版图片序', |
| | | virtual_slot int DEFAULT NULL COMMENT '虚拟格子', |
| | | slot_sequence int DEFAULT NULL COMMENT '格子内次序', |
| | | slot int DEFAULT NULL COMMENT '实际格子号', |
| | | device_id int DEFAULT NULL COMMENT '实际笼子号', |
| | | PRIMARY KEY (id) USING BTREE |
| | | ); |
| | | -- rollback DROP TABLE big_storage_glass_relation_info; |
| | | |