| | |
| | | |
| | | import cn.hutool.json.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import com.mes.md.entity.*; |
| | | import com.mes.md.mapper.MachineMapper; |
| | | import com.mes.md.mapper.TaskingMapper; |
| | |
| | | import com.mes.service.PlcParameter; |
| | | import com.mes.tools.WebSocketServer; |
| | | import com.mes.utils.HexUtil; |
| | | import com.mes.utils.Result; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | |
| | | @Autowired |
| | | KBBTJPDrawingBPService kBBTJPDrawingBPService; |
| | | |
| | | //@Scheduled(fixedDelay = 30000) |
| | | public void AddTasks() { |
| | | projectService.insertProjectStandard(); |
| | | @Autowired |
| | | TaskingMapper taskingMapper; |
| | | @Autowired |
| | | TaskingLogService taskingLogService; |
| | | |
| | | @Scheduled(fixedDelay = 86400000) |
| | | public void deleteTasking() { |
| | | try { |
| | | //创建Calendar实例 |
| | | Calendar cal = Calendar.getInstance(); |
| | | //设置当前时间 |
| | | cal.setTime(new Date()); |
| | | cal.add(Calendar.DATE, -5); |
| | | int deleteCount=taskingMapper.deleteJoin(new MPJLambdaWrapper<Tasking>() |
| | | .selectAll(Tasking.class) |
| | | .le(Tasking::getOperationRecordTime,cal.getTime())); |
| | | log.info("定时清除多余数据{}",deleteCount); |
| | | |
| | | }catch (Exception e){ |
| | | log.info("定时清除多余数据失败"); |
| | | } |
| | | } |
| | | @Scheduled(fixedDelay = 100000) |
| | | public void reportForWork() { |
| | | try { |
| | | taskingLogService.reportTaskingLog(); |
| | | }catch (Exception e){ |
| | | log.info("定时汇报任务失败!"); |
| | | } |
| | | } |
| | | //@Scheduled(fixedDelay = 1000) |
| | | public void notReceive() { |
| | |
| | | if (sendwServer != null) { |
| | | for (WebSocketServer webserver : sendwServer) { |
| | | if (webserver != null) { |
| | | webserver.sendMessage(jsonObject.toString()); |
| | | List<String> messages = webserver.getMessages(); |
| | | if (!messages.isEmpty()) { |
| | | // // 将最后一个消息转换为整数类型的列表 |
| | | webserver.clearMessages(); |
| | | try { |
| | | webserver.sendMessage(jsonObject.toString()); |
| | | List<String> messages = webserver.getMessages(); |
| | | if (!messages.isEmpty()) { |
| | | // // 将最后一个消息转换为整数类型的列表 |
| | | webserver.clearMessages(); |
| | | } |
| | | }catch (Exception e) { |
| | | |
| | | } |
| | | } else { |
| | | log.info("Home is closed"); |