package com.mes.job.opccallback;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
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.kangaroohy.milo.runner.subscription.SubscriptionCallback;
|
import com.mes.common.config.Const;
|
import com.mes.edgglasstask.service.EdgGlassTaskInfoService;
|
import com.mes.edgstoragecage.entity.EdgStorageCageDetails;
|
import com.mes.edgstoragecage.service.EdgStorageCageDetailsService;
|
import com.mes.edgstoragecage.service.EdgStorageCageService;
|
import com.mes.glassinfo.entity.GlassInfo;
|
import com.mes.glassinfo.service.GlassInfoService;
|
import com.mes.opctask.entity.EdgStorageDeviceTask;
|
import com.mes.opctask.entity.EdgStorageDeviceTaskHistory;
|
import com.mes.opctask.service.EdgStorageDeviceTaskHistoryService;
|
import com.mes.opctask.service.EdgStorageDeviceTaskService;
|
import lombok.extern.slf4j.Slf4j;
|
import org.apache.commons.lang.StringUtils;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.util.Date;
|
import java.util.List;
|
|
/**
|
* @Author : zhoush
|
* @Date: 2024/10/10 14:13
|
* @Description:
|
*/
|
@Service
|
@Slf4j
|
public class CacheGlassStartCallback implements SubscriptionCallback {
|
|
private static final String EDG_STORAGE_DEVICE_ONE_TASK = "edg_storage_device_one_task";
|
|
private static final String EDG_STORAGE_DEVICE_TWO_TASK = "edg_storage_device_two_task";
|
|
@Resource
|
EdgStorageDeviceTaskService edgStorageDeviceTaskService;
|
@Resource
|
GlassInfoService glassInfoService;
|
@Resource
|
EdgStorageCageDetailsService edgStorageCageDetailsService;
|
@Resource
|
EdgStorageCageService edgStorageCageService;
|
@Resource
|
EdgStorageDeviceTaskHistoryService edgStorageDeviceTaskHistoryService;
|
|
@Resource
|
EdgGlassTaskInfoService edgGlassTaskInfoService;
|
|
// @Value("${mes.glassGap}")
|
// private int glassGap;
|
// @Value("${mes.threshold}")
|
// private int threshold;
|
// @Value("${mes.cellLength}")
|
// private int cellLength;
|
|
private Date startDate;
|
|
@Override
|
public void onSubscribe(String identifier, Object value) {
|
|
// log.info("当前正在执行的任务为{}", value);
|
// String tableName = identifier.contains("edg_storage_device_one_task") ? EDG_STORAGE_DEVICE_ONE_TASK : EDG_STORAGE_DEVICE_TWO_TASK;
|
// int device = tableName.equals("edg_storage_device_one_task") ? 1 : 2;
|
// EdgStorageDeviceTask task = edgStorageDeviceTaskService.queryTaskMessage(tableName);
|
// try {
|
// if (task == null) {
|
// log.info("任务表基础数据录入失败,请检查数据是否录入成功");
|
// return;
|
// }
|
// if (task.getTaskState() == 2) {
|
// //防止出片任务且笼前有玻璃的情况,将进片id置空,即出片仅考虑笼内的玻璃
|
// task.setGlassIdIn("");
|
// }
|
// int request = Integer.parseInt("" + value);
|
// log.info("开始执行任务,任务请信息为{}", task);
|
// if (request == 0) {
|
// log.info("未收到任务请求,结束本次任务");
|
// } else if (request == 1) {
|
// //进片任务
|
// log.info("进片任务:进片玻璃id为:{}", task.getGlassIdIn());
|
// 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);
|
// edgStorageDeviceTaskService.updateTaskMessage(tableName, task);
|
// }
|
}
|
|
private boolean intoTask(EdgStorageDeviceTask task, String tableName, int deviceId) {
|
// //获取玻璃的基本信息
|
// GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getGlassId, task.getGlassIdIn()));
|
// if (null == glassInfo) {
|
// log.info("进片玻璃信息不存在,玻璃id:{}", task.getGlassIdIn());
|
// return Boolean.FALSE;
|
// }
|
// //获取当前进片玻璃id和进片格子 相同尺寸可以放下的格子
|
// EdgStorageCage edgStorageCage = edgStorageCageService.getEdgStorageCageBySize(deviceId, glassInfo.getWidth(), glassInfo.getHeight(), task.getCurrentCell());
|
// if (edgStorageCage == null) {
|
// log.info("相同尺寸可以放下的格子未找到,格子id:{}", task.getCurrentCell());
|
//// SELECT * from edg_storage_cage where device_id = 1 and remain_width > 1000 order by abs(slot - 10)
|
// List<EdgStorageCage> storageCageList = edgStorageCageService.list(new LambdaQueryWrapper<EdgStorageCage>()
|
// .eq(EdgStorageCage::getDeviceId, deviceId)
|
// .eq(EdgStorageCage::getEnableState, Const.SLOT_ON)
|
// .ge(EdgStorageCage::getRemainWidth, Math.max(glassInfo.getWidth(), glassInfo.getHeight())).last("order by abs(slot - " + task.getCurrentCell() + ")"));
|
//// //直通任务
|
//// if (flag && CollectionUtil.isNotEmpty(emptyList)) {
|
//// return emptyList.get(0);
|
//// }
|
// if (CollectionUtil.isEmpty(storageCageList) || storageCageList.size() == 1) {
|
// log.info("没有多余的空格子");
|
// return Boolean.FALSE;
|
// }
|
// edgStorageCage = storageCageList.get(0);
|
// }
|
// log.info("4、将玻璃信息插入卧式理片笼,当前玻璃信息:{}", glassInfo);
|
// EdgStorageCageDetails details = new EdgStorageCageDetails();
|
// BeanUtils.copyProperties(glassInfo, details);
|
// details.setState(Const.GLASS_STATE_IN);
|
// details.setSlot(edgStorageCage.getSlot());
|
// details.setDeviceId(edgStorageCage.getDeviceId());
|
// edgStorageCageDetailsService.save(details);
|
//
|
// //更新任务信息
|
// task.setStartCell(edgStorageCage.getSlot());
|
// task.setTaskRunning(Const.GLASS_CACHE_TYPE_IN);
|
// edgStorageDeviceTaskService.updateTaskMessage(tableName, task);
|
// saveHistoryTask(task);
|
return Boolean.TRUE;
|
}
|
|
private boolean outTask(EdgStorageDeviceTask task, String tableName, int deviceId) {
|
// EdgStorageCageDetails edgStorageCageDetails = null;
|
// //笼内是版图相差是否超过阈值
|
// boolean flag = queryMaxMinDiff(threshold);
|
// if (flag) {
|
// EdgStorageCageDetails minEdgDetails = edgStorageCageDetailsService.getOne(new LambdaQueryWrapper<EdgStorageCageDetails>()
|
// .inSql(EdgStorageCageDetails::getSlot, "select slot from edg_storage_cage where enable_state = " + Const.SLOT_ON)
|
// .eq(EdgStorageCageDetails::getState, Const.GLASS_STATE_IN)
|
// .eq(EdgStorageCageDetails::getDeviceId, deviceId)
|
// .orderByAsc(EdgStorageCageDetails::getTemperingLayoutId)
|
// .orderBy(Boolean.TRUE, Boolean.TRUE, EdgStorageCageDetails::getTemperingFeedSequence)
|
// .last("limit 1"));
|
//// select * from edg_storage_cage_details where width = 551 and height = 1151 and id in (select min(id ) from edg_storage_cage_details where state = 100 group by slot )
|
// edgStorageCageDetails = edgStorageCageDetailsService.getOne(new LambdaQueryWrapper<EdgStorageCageDetails>()
|
// .eq(EdgStorageCageDetails::getWidth, minEdgDetails.getWidth())
|
// .eq(EdgStorageCageDetails::getHeight, minEdgDetails.getHeight())
|
// .eq(EdgStorageCageDetails::getDeviceId, deviceId)
|
// .inSql(EdgStorageCageDetails::getId, "select min(id) from edg_storage_cage_details where state = 100 group by slot ")
|
// .last("order by abs(slot - " + task.getCurrentCell() + ") asc limit 1")
|
// );
|
// //给直通任务
|
// if (null == edgStorageCageDetails && StringUtils.isNotBlank(task.getGlassIdIn())) {
|
// GlassInfo glassInInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>()
|
// .eq(GlassInfo::getGlassId, task.getGlassIdIn())
|
// .eq(GlassInfo::getWidth, minEdgDetails.getWidth())
|
// .eq(GlassInfo::getHeight, minEdgDetails.getHeight()));
|
// if (null != glassInInfo) {
|
// edgStorageCageDetails = new EdgStorageCageDetails();
|
// BeanUtils.copyProperties(glassInInfo, edgStorageCageDetails);
|
// }
|
// }
|
// if (null == edgStorageCageDetails) {
|
// edgStorageCageDetails = edgStorageCageDetailsService.getOne(new LambdaQueryWrapper<EdgStorageCageDetails>()
|
// .eq(EdgStorageCageDetails::getState, Const.GLASS_STATE_IN)
|
// .eq(EdgStorageCageDetails::getDeviceId, deviceId)
|
// .eq(EdgStorageCageDetails::getSlot, minEdgDetails.getSlot())
|
// .orderByAsc(EdgStorageCageDetails::getId)
|
// .last("limit 1")
|
// );
|
// }
|
// }
|
// if (null == edgStorageCageDetails) {
|
// // 获取上次任务
|
//// 获取历史表中上次任务最后一片尺寸
|
// EdgStorageDeviceTaskHistory edgeData = edgStorageDeviceTaskHistoryService.getOne(new LambdaQueryWrapper<EdgStorageDeviceTaskHistory>()
|
// .eq(EdgStorageDeviceTaskHistory::getTaskState, Const.RAW_GLASS_TASK_SUCCESS)
|
// .in(EdgStorageDeviceTaskHistory::getTaskType, Const.GLASS_CACHE_TYPE_OUT, Const.GLASS_CACHE_TYPE_THROUGH)
|
// .orderByDesc(EdgStorageDeviceTaskHistory::getId).last("limit 1"));
|
// if (null != edgeData) {
|
// GlassInfo glassOutInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getGlassId, edgeData.getGlassIdOut()));
|
// //笼内的玻璃的尺寸是否和上一次任务一致
|
// edgStorageCageDetails = edgStorageCageDetailsService.queryEdgStorageDetailsBySize(deviceId, task.getCurrentCell(), glassOutInfo.getWidth(), glassOutInfo.getHeight());
|
// if (null == edgStorageCageDetails && StringUtils.isNotBlank(task.getGlassIdIn())) {
|
// GlassInfo glassInInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>()
|
// .eq(GlassInfo::getGlassId, task.getGlassIdIn())
|
// .eq(GlassInfo::getWidth, glassOutInfo.getWidth())
|
// .eq(GlassInfo::getHeight, glassOutInfo.getHeight()));
|
// if (null != glassInInfo) {
|
// edgStorageCageDetails = new EdgStorageCageDetails();
|
// BeanUtils.copyProperties(glassInInfo, edgStorageCageDetails);
|
// }
|
// }
|
// }
|
// }
|
// if (null == edgStorageCageDetails) {
|
// edgStorageCageDetails = edgStorageCageDetailsService.queryEdgStorageDetailsBySize(deviceId, task.getCurrentCell(), 0, 0);
|
// }
|
// if (edgStorageCageDetails == null && StringUtils.isNotBlank(task.getGlassIdIn())) {
|
// //和上次任务不存在相同尺寸
|
// GlassInfo glassInInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getGlassId, task.getGlassIdIn()));
|
// edgStorageCageDetails = new EdgStorageCageDetails();
|
// BeanUtils.copyProperties(glassInInfo, edgStorageCageDetails);
|
// }
|
// if (edgStorageCageDetails == null) {
|
// //和上次任务不存在相同尺寸
|
// log.info("笼内没有玻璃了");
|
// return Boolean.FALSE;
|
// }
|
// int taskType = Const.GLASS_CACHE_TYPE_OUT;
|
// String glassId = edgStorageCageDetails.getGlassId();
|
// if (glassId.equals(task.getGlassIdIn())) {
|
// if (3 != task.getTaskState()) {
|
// return Boolean.FALSE;
|
// }
|
// log.info("5、直通任务,将玻璃信息插入卧式理片笼,当前玻璃信息:{}", edgStorageCageDetails);
|
// //玻璃信息替换
|
// String glassIdChange = queryAndChangeGlass(glassId);
|
// //处理在卧理内的玻璃信息:笼内的数据处理
|
// queryEdgAndChangeGlass(edgStorageCageDetails.getGlassId(), glassIdChange);
|
// if (StringUtils.isNotBlank(glassIdChange)) {
|
// edgStorageCageDetails = new EdgStorageCageDetails();
|
// GlassInfo one = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getGlassId, glassId));
|
// BeanUtils.copyProperties(one, edgStorageCageDetails);
|
// }
|
// EdgStorageCage storageCage = edgStorageCageService.getOne(new LambdaQueryWrapper<EdgStorageCage>()
|
// .eq(EdgStorageCage::getDeviceId, deviceId)
|
// .eq(EdgStorageCage::getEnableState, Const.SLOT_ON)
|
// .ge(EdgStorageCage::getRemainWidth, cellLength)
|
// .last("order by abs(slot - " + task.getCurrentCell() + ") limit 1"));
|
// Assert.isTrue(null != storageCage, "格子已满,无法执行直通任务");
|
// log.info("3、查询卧式理片笼里面的空格:{}", storageCage);
|
// edgStorageCageDetails.setSlot(storageCage.getSlot());
|
// edgStorageCageDetails.setDeviceId(storageCage.getDeviceId());
|
// edgStorageCageDetails.setState(Const.GLASS_STATE_OUT);
|
// edgStorageCageDetailsService.save(edgStorageCageDetails);
|
// taskType = Const.GLASS_CACHE_TYPE_THROUGH;
|
// } else {
|
// log.info("5、非直通任务,将玻璃信息插入卧式理片笼,当前玻璃信息:{}", edgStorageCageDetails);
|
// if (!edgStorageCageDetails.getSlot().equals(task.getCurrentCell())) {
|
// EdgStorageCageDetails currentGlass = edgStorageCageDetailsService.getOne(new LambdaQueryWrapper<EdgStorageCageDetails>()
|
// .eq(EdgStorageCageDetails::getState, Const.GLASS_STATE_IN)
|
// .eq(EdgStorageCageDetails::getDeviceId, deviceId)
|
// .eq(EdgStorageCageDetails::getSlot, task.getCurrentCell()).eq(EdgStorageCageDetails::getWidth, edgStorageCageDetails.getWidth())
|
// .eq(EdgStorageCageDetails::getHeight, edgStorageCageDetails.getHeight()).eq(EdgStorageCageDetails::getThickness, edgStorageCageDetails.getThickness())
|
// .orderByAsc(EdgStorageCageDetails::getId).last("limit 1")
|
// );
|
// if (null != currentGlass) {
|
// edgStorageCageDetails = currentGlass;
|
// }
|
// }
|
// //玻璃信息替换
|
// String glassIdChange = queryAndChangeGlass(edgStorageCageDetails.getGlassId());
|
// //处理在卧理内的玻璃信息:笼内的数据处理
|
// queryEdgAndChangeGlass(edgStorageCageDetails.getGlassId(), glassIdChange);
|
// LambdaUpdateWrapper<EdgStorageCageDetails> wrapper = new LambdaUpdateWrapper<>();
|
// wrapper.eq(EdgStorageCageDetails::getGlassId, edgStorageCageDetails.getGlassId()).set(EdgStorageCageDetails::getState, Const.GLASS_STATE_OUT);
|
// edgStorageCageDetailsService.update(wrapper);
|
// log.info("5、更新出片玻璃的状态为{}", Const.GLASS_STATE_OUT);
|
// }
|
// //生成出片任务
|
// task.setGlassIdOut(edgStorageCageDetails.getGlassId());
|
// task.setStartCell(edgStorageCageDetails.getSlot());
|
// task.setTaskRunning(taskType);
|
//
|
// edgStorageDeviceTaskService.updateTaskMessage(tableName, task);
|
// saveHistoryTask(task);
|
// //更新详情表任务出片中
|
// 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.setCreateTime(new Date());
|
// edgInfo.setWidth((int) edgStorageCageDetails.getWidth());
|
// edgInfo.setHeight((int) edgStorageCageDetails.getWidth());
|
// edgInfo.setThickness((int) edgStorageCageDetails.getWidth());
|
// edgInfo.setState(Const.GLASS_STATE_NEW);
|
// edgGlassTaskQueueInfoService.save(edgInfo);
|
return Boolean.TRUE;
|
}
|
|
private boolean finishTask(EdgStorageDeviceTask task, String tableName) {
|
// log.info("当前任务信息为:{}", task);
|
// if (task.getTaskState() <= 4) {
|
// log.info("有正在执行的任务,结束");
|
// return Boolean.FALSE;
|
// }
|
// Integer cell = task.getStartCell();
|
// Integer state = task.getTaskState();
|
// task.setTaskRunning(Const.GLASS_CACHE_TYPE_EMPTY);
|
// task.setGlassIdOut("");
|
// task.setStartCell(0);
|
// edgStorageDeviceTaskService.updateTaskMessage(tableName, task);
|
// 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);
|
return Boolean.TRUE;
|
}
|
|
/**
|
* 查询玻璃并进行交换
|
*
|
* @param glassId
|
* @return
|
*/
|
public String queryAndChangeGlass(String glassId) {
|
// GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getGlassId, glassId));
|
//// .inSql(GlassInfo::getEngineerId, "select engineer_id from engineering where state = 1"));
|
// Assert.isFalse(null == glassInfo, "玻璃信息不存在"); //按照玻璃尺寸
|
// LambdaQueryWrapper<GlassInfo> queryWrapper = new LambdaQueryWrapper<GlassInfo>()
|
// .eq(GlassInfo::getWidth, glassInfo.getWidth())
|
// .eq(GlassInfo::getHeight, glassInfo.getHeight())
|
// .eq(GlassInfo::getThickness, glassInfo.getThickness())
|
// .eq(GlassInfo::getFilmsid, glassInfo.getFilmsid())
|
// .eq(GlassInfo::getFlowCardId, glassInfo.getFlowCardId())
|
// .eq(GlassInfo::getTotalLayer, glassInfo.getTotalLayer())
|
// .eq(GlassInfo::getLayer, glassInfo.getLayer())
|
// .eq(GlassInfo::getEngineerId, glassInfo.getEngineerId())
|
// .notInSql(GlassInfo::getGlassId, "select distinct glass_id from edg_storage_cage_details " +
|
// "where engineer_id = '" + glassInfo.getEngineerId() + "' and width = " + glassInfo.getWidth() + " and height = " + glassInfo.getHeight()
|
// + " and state != 100")
|
// .orderByAsc(GlassInfo::getTemperingLayoutId)
|
// .orderBy(Boolean.TRUE, Boolean.TRUE, GlassInfo::getTemperingFeedSequence)
|
// .last("Limit 1");
|
// GlassInfo swapGlassInfo = glassInfoService.getOne(queryWrapper);
|
// if (swapGlassInfo != null && !glassInfo.getGlassId().equals(swapGlassInfo.getGlassId())) {
|
// String swapGlassId = swapGlassInfo.getGlassId();
|
// log.info("将玻璃{}和玻璃{},信息互换,进玻璃 {}", glassInfo, swapGlassInfo, swapGlassInfo);
|
// swapGlassInfo.setGlassId(glassId);
|
// glassInfo.setGlassId(swapGlassId);
|
// glassInfoService.updateById(swapGlassInfo);
|
// glassInfoService.updateById(glassInfo);
|
// return swapGlassId;
|
// }
|
return "";
|
}
|
|
|
/**
|
* 查询卧式理片玻璃并进行交换
|
*
|
* @param glassId
|
* @return
|
*/
|
public void queryEdgAndChangeGlass(String glassId, String swapGlassId) {
|
if (StringUtils.isBlank(swapGlassId)) {
|
log.info("当前出笼玻璃不存在需要替换的玻璃");
|
return;
|
}
|
//获取待出笼的玻璃
|
EdgStorageCageDetails glassInfo = edgStorageCageDetailsService.getOne(new LambdaQueryWrapper<EdgStorageCageDetails>()
|
.eq(EdgStorageCageDetails::getGlassId, glassId).eq(EdgStorageCageDetails::getState, Const.GLASS_STATE_IN));
|
// 获取待出笼的玻璃需要替换的玻璃信息
|
EdgStorageCageDetails swapGlassDetailInfo = edgStorageCageDetailsService.getOne(new LambdaQueryWrapper<EdgStorageCageDetails>()
|
.eq(EdgStorageCageDetails::getGlassId, swapGlassId).eq(EdgStorageCageDetails::getState, Const.GLASS_STATE_IN));
|
|
// 玻璃小片表中玻璃已经替换,更新卧理笼内现有的准备出笼的玻璃信息,
|
if (null == swapGlassDetailInfo) {
|
GlassInfo glassInfoBase = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>()
|
.eq(GlassInfo::getGlassId, glassId));
|
//需要替换的玻璃为存进卧理,仅需更新当前需要出笼的玻璃信息即可
|
edgStorageCageDetailsService.update(new LambdaUpdateWrapper<EdgStorageCageDetails>()
|
.eq(EdgStorageCageDetails::getGlassId, glassId)
|
.set(EdgStorageCageDetails::getTemperingLayoutId, glassInfoBase.getTemperingLayoutId())
|
.set(EdgStorageCageDetails::getTemperingFeedSequence, glassInfoBase.getTemperingFeedSequence()));
|
} else {
|
//需要替换的玻璃都在卧理内,按照玻璃id对调玻璃信息:对调玻璃id即可
|
edgStorageCageDetailsService.update(new LambdaUpdateWrapper<EdgStorageCageDetails>()
|
.eq(EdgStorageCageDetails::getId, glassInfo.getId())
|
.set(EdgStorageCageDetails::getTemperingLayoutId, swapGlassDetailInfo.getTemperingLayoutId())
|
.set(EdgStorageCageDetails::getTemperingFeedSequence, swapGlassDetailInfo.getTemperingFeedSequence())
|
);
|
edgStorageCageDetailsService.update(new LambdaUpdateWrapper<EdgStorageCageDetails>()
|
.eq(EdgStorageCageDetails::getId, swapGlassDetailInfo.getId())
|
.set(EdgStorageCageDetails::getTemperingLayoutId, glassInfo.getTemperingLayoutId())
|
.set(EdgStorageCageDetails::getTemperingFeedSequence, glassInfo.getTemperingFeedSequence())
|
);
|
}
|
}
|
|
/**
|
* 获取详情表内最大最小版图id的差值,判断是否出最小版图玻璃
|
*
|
* @return
|
*/
|
public boolean queryMaxMinDiff(int threshold) {
|
//获取笼子内最大版图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)
|
.inSql("slot", "select slot from edg_storage_cage where enable_state = " + Const.SLOT_ON);
|
List<Object> list = edgStorageCageDetailsService.listObjs(queryWrapper);
|
//获取笼内玻璃版图差值是否大于阈值
|
if (CollectionUtil.isNotEmpty(list)) {
|
Long diff = (Long) list.get(0);
|
return diff > threshold;
|
} else {
|
return Boolean.FALSE;
|
}
|
}
|
|
public boolean saveHistoryTask(EdgStorageDeviceTask task) {
|
EdgStorageDeviceTaskHistory taskHistory = new EdgStorageDeviceTaskHistory();
|
BeanUtils.copyProperties(task, taskHistory);
|
taskHistory.setTaskType(task.getTaskRunning());
|
taskHistory.setCreateTime(new Date());
|
taskHistory.setTaskState(Const.RAW_GLASS_TASK_NEW);
|
edgStorageDeviceTaskHistoryService.save(taskHistory);
|
return Boolean.TRUE;
|
}
|
|
private boolean updateCellRemainWidth(int slot, int device) {
|
// List<EdgStorageCageDetails> list = edgStorageCageDetailsService.list(new LambdaQueryWrapper<EdgStorageCageDetails>().eq(EdgStorageCageDetails::getSlot, slot)
|
// .eq(EdgStorageCageDetails::getState, Const.GLASS_STATE_IN));
|
// int remainWidth = cellLength;
|
// if (CollectionUtil.isNotEmpty(list)) {
|
// int widthTotal = (int) list.stream().map(e -> Math.max(e.getWidth(), e.getHeight()) + glassGap).mapToDouble(Double::intValue).sum();
|
// remainWidth = cellLength - widthTotal >= 0 ? cellLength - widthTotal : 0;
|
// }
|
// edgStorageCageService.update(new LambdaUpdateWrapper<EdgStorageCage>().
|
// set(EdgStorageCage::getRemainWidth, remainWidth).eq(EdgStorageCage::getSlot, slot).eq(EdgStorageCage::getDeviceId, device));
|
return Boolean.TRUE;
|
}
|
}
|