package com.mes.job;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.json.JSONObject;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.mes.common.config.Const;
|
import com.mes.rawglassdetails.entity.RawGlassStorageDetails;
|
import com.mes.rawglassdetails.service.RawGlassStorageDetailsService;
|
import com.mes.rawglassstation.service.RawGlassStorageStationService;
|
import com.mes.rawglasstask.entity.RawGlassStorageTask;
|
import com.mes.rawglasstask.service.RawGlassStorageTaskService;
|
import com.mes.tools.WebSocketServer;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.stereotype.Component;
|
|
import javax.annotation.Resource;
|
import java.util.List;
|
|
/**
|
* @author wangfei
|
*/
|
@Slf4j
|
@Component
|
public class RawGlassPushMessage {
|
|
@Resource
|
private RawGlassStorageStationService rawGlassStorageStationService;
|
|
@Resource
|
private RawGlassStorageTaskService rawGlassStorageTaskService;
|
|
@Resource
|
private RawGlassStorageDetailsService rawGlassStorageDetailsService;
|
|
@Scheduled(fixedDelay = 2000)
|
public void sendRawGlassMessage() {
|
log.info("发送任务信息和架子信息");
|
JSONObject jsonObject = new JSONObject();
|
List<RawGlassStorageDetails> rawStationDetailsList =
|
rawGlassStorageStationService.listRawGlassDetails();
|
List<RawGlassStorageTask> tasks = rawGlassStorageTaskService.listRawGlassTask();
|
jsonObject.append("rawStationDetailsList", rawStationDetailsList);
|
jsonObject.append("tasks", tasks);
|
List<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("rawGlass");
|
if (CollectionUtil.isNotEmpty(sendwServer)) {
|
sendwServer.stream().forEach(e -> {
|
e.sendMessage(String.valueOf(jsonObject));
|
});
|
}
|
}
|
|
@Scheduled(fixedDelay = 1000)
|
public void largenScreen() {
|
log.info("发送任务信息和架子信息");
|
JSONObject jsonObject = new JSONObject();
|
List<RawGlassStorageDetails> rawGlassStorageDetailList = rawGlassStorageDetailsService.list(
|
new LambdaUpdateWrapper<RawGlassStorageDetails>()
|
.eq(RawGlassStorageDetails::getState, Const.RAW_GLASS_STATE_IN)
|
);
|
jsonObject.append("rawGlassStorageDetailList", rawGlassStorageDetailList);
|
List<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("largenScreen");
|
if (CollectionUtil.isNotEmpty(sendwServer)) {
|
sendwServer.stream().forEach(e -> {
|
e.sendMessage(String.valueOf(jsonObject));
|
});
|
}
|
}
|
}
|