| | |
| | | package com.mes.job; |
| | | |
| | | import cn.hutool.json.JSONObject; |
| | | import com.mes.temperingglass.service.TemperingGlassInfoService; |
| | | 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.mes.common.config.Const; |
| | | import com.mes.damage.service.DamageService; |
| | | import com.mes.largenscreen.entity.PieChartVO; |
| | | import com.mes.temperingglass.entity.TemperingGlassInfo; |
| | | import com.mes.temperingglass.service.TemperingGlassInfoService; |
| | | import com.mes.tools.WebSocketServer; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.ZoneId; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | |
| | | @Autowired |
| | | private TemperingGlassInfoService temperingAgoService; |
| | | @Autowired |
| | | private DamageService damageService; |
| | | |
| | | /** |
| | | * fixedRate : 上一个调用开始后再次调用的延时(不用等待上一次调用完成) |
| | | * fixedDelay : 上一个调用结束后再次调用的延时 |
| | | */ |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void temperingGlassHome(){ |
| | | public void temperingGlassHome() { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | //正在等待进片的玻璃 |
| | | List<TemperingGlassInfo> waitingGlass = temperingAgoService.selectWaitingGlass(); |
| | | jsonObject.append("waitingGlass", waitingGlass); |
| | | List<TemperingGlassInfo> waitingGlass = temperingAgoService.selectWaitingGlassByOpc(); |
| | | if (waitingGlass != null) { |
| | | jsonObject.append("waitingGlass", waitingGlass); |
| | | } |
| | | |
| | | //获取整在炉中的两个版图id |
| | | List<TemperingGlassInfo> layoutId = temperingAgoService.selectLayoutId(); |
| | | //进炉中的玻璃 |
| | | if(!layoutId.isEmpty()) { |
| | | if (!layoutId.isEmpty()) { |
| | | List<TemperingGlassInfo> intoGlass = temperingAgoService.selectIntoGlass(layoutId.get(0)); |
| | | jsonObject.append("intoGlass", intoGlass); |
| | | //进炉中的第二个版图 |
| | |
| | | } |
| | | //出炉后的玻璃 |
| | | List<TemperingGlassInfo> outGlass = temperingAgoService.selectOutGlass(); |
| | | jsonObject.append("outGlass", outGlass); |
| | | if (outGlass != null) { |
| | | jsonObject.append("outGlass", outGlass); |
| | | } |
| | | |
| | | //过旋转台钢化后的玻璃 |
| | | List<TemperingGlassInfo> overGlass = temperingAgoService.selectOverGlass(); |
| | | if (outGlass != null) { |
| | | jsonObject.append("overGlass", overGlass); |
| | | } |
| | | |
| | | jsonObject.append("overGlass", overGlass); |
| | | |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("temperingGlass"); |
| | | if (sendwServer != null) { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void temperingIsRun(){ |
| | | public void temperingIsRun() { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | //正在进行的任务 |
| | | List<TemperingGlassInfo>temperingTaskType=temperingAgoService.selectTaskType(); |
| | | List<TemperingGlassInfo> temperingTaskType = temperingAgoService.selectTaskType(); |
| | | jsonObject.append("temperingTaskType", temperingTaskType); |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("isRun"); |
| | | |
| | | |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("temperingIsRun"); |
| | | if (sendwServer != null) { |
| | | for (WebSocketServer webserver : sendwServer) { |
| | | if (webserver != null) { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 1000) |
| | | public void largenScreen() { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | //大屏钢化信息 |
| | | Date startOfToday = new Date(LocalDate.now().atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli()); |
| | | |
| | | Integer putGlass = temperingAgoService.count( |
| | | new QueryWrapper<TemperingGlassInfo>() |
| | | .eq("state", Const.TEMPERING_NEW) |
| | | .gt("create_time", startOfToday) |
| | | ); |
| | | jsonObject.append("temperingTaskType", putGlass); |
| | | //大屏钢化信息 |
| | | List<TemperingGlassInfo> temperingGlassInfoList = temperingAgoService.list( |
| | | new QueryWrapper<TemperingGlassInfo>() |
| | | .select("engineer_id" ,"tempering_layout_id") |
| | | .eq("state", Const.TEMPERING_START) |
| | | .gt("create_time", startOfToday) |
| | | .groupBy("engineer_id" ,"tempering_layout_id") |
| | | ); |
| | | jsonObject.append("temperingGlassInfoList", temperingGlassInfoList.size()); |
| | | //大屏钢化信息 |
| | | List<TemperingGlassInfo> temperingGlassInfoInList = temperingAgoService.list( |
| | | new LambdaQueryWrapper<TemperingGlassInfo>() |
| | | .select(TemperingGlassInfo::getEngineerId, TemperingGlassInfo::getTemperingLayoutId) // 选择要去重的字段 |
| | | .eq(TemperingGlassInfo::getState, Const.TEMPERING_DROP) |
| | | .groupBy(TemperingGlassInfo::getEngineerId, TemperingGlassInfo::getTemperingLayoutId) // 按 engineerId 和 temperingLayoutId 分组 |
| | | ); |
| | | jsonObject.append("temperingGlassInfoInList", temperingGlassInfoInList.size()); |
| | | //钢化饼图数据 |
| | | List<PieChartVO> pieChartVOS = temperingAgoService.queryPieChart(); |
| | | jsonObject.append("pieChartVOS", pieChartVOS); |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("largenScreen"); |
| | | 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("largenScreen is closed"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |