zhoushihao
2024-10-11 d5d0d1c7a84b996b9bbcebfaf2c2c95f1a5a3678
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package com.mes.job;
 
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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;
import java.util.stream.Collectors;
 
/**
 * @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);
//    log.info("获取到的工位详情及任务信息为:{}", jsonObject);
 
    List<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("rawGlass");
    if (CollectionUtil.isNotEmpty(sendwServer)) {
      sendwServer.stream().forEach(e->{
        e.sendMessage(String.valueOf(jsonObject));
      });
    }
  }
 
  /** todo:入库任务:吊装位有玻璃,先去工位表查询空格子,生成入库任务从吊装位到目标格子 */
//  @Scheduled(fixedDelay = 1000)
//  public void sendRawGlassMessage() {
////    List<RawGlassStorageDetails> rawGlassStorageDetailsList = rawGlassStorageDetailsService.List(new RawGlassStorageDetails())
//    Wrapper<RawGlassStorageDetails> queryWrapper = null;
//    List<RawGlassStorageDetails> detailsList = rawGlassStorageDetailsService.list(null);
//    queryWrapper.eq(RawGlassStorageDetails::getState, 100);
//  if(detailsList.size() >0){
//    //查找格子表details空格子
//    List<String> slotIds = detailsList.stream()
//            .map(RawGlassStorageDetails::getSlotId)
//            .collect(Collectors.toList());
//    list(new LambdaQueryWrapper<RawGlassStorageTask>()
//            .in(CollectionUtil.isNotEmpty(request.getState()), RawGlassStorageTask::getState, request.getState())
//            .in(CollectionUtil.isNotEmpty(request.getSlotId()), RawGlassStorageTask::getSlotId, request.getSlotId())
//            .orderByDesc(RawGlassStorageTask::getCreateTime));
//  }if(slotIds.size()>0){
//      //生成入库任务
//    }
//
//  }
 
 
 
  /** todo:出库任务:1、点出库,立马生成出片任务 2、点出库修改工位详情内的状态为待出库,定时任务扫描生成出库任务 */
 
  /** todo:原片调度:1、查询工程原片表,按照顺序将原片放入上片1号位,后续原片放上片2号位,出现尺寸替换,判断原上片位是否有玻璃,有 先出后进,无 直接进片 */
}