wuyouming666
2024-03-27 82e0ee9e39953af0b39e5471eb6a9be2d442fb7d
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
package com.mes.service;
 
import com.mes.entity.DownGlassInfo;
import com.mes.entity.DownStorageCageDetails;
import com.mes.entity.DownWorkstation;
import com.mes.entity.device.PlcParameterObject;
import com.mes.mapper.DownGlassInfoMapper;
import com.mes.mapper.DownWorkstationMapper;
import com.mes.tools.WebSocketServer;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.List;
@Data
@Service
public class PlcService {
 
    @Autowired
    private DownWorkstationMapper downWorkstationMapper;
    private DownGlassInfo downGlassInfo;
    private DownWorkstation downWorkstation;
    private DownGlassInfoMapper downGlassInfoMapper;
 
    private DownGlassInfoService downGlassInfoService;
 
 
 
 
 
    private List<DownGlassInfo> glassList; // 存放待处理的玻璃信息
    private List<DownStorageCageDetails> cageDetailsList; // 存放玻璃放置在缓存笼中的详细信息
    PlcParameterObject plcread=PLCAutoMes.PlcReadObject;
    String Robot1PLCrequestword=plcread.getPlcParameter("A01Position").getValue();// 机械手1PLC请求字
    String Robot2PLCrequestword=plcread.getPlcParameter("A01Position").getValue();// 机械手2PLC请求字
    String GlassID=plcread.getPlcParameter("A01Position").getValue();// 玻璃id
    String Glasswidth=plcread.getPlcParameter("A01Position").getValue();//玻璃宽度
    String Glassheight=plcread.getPlcParameter("A01Position").getValue();//玻璃高度
    String Glassthickness=plcread.getPlcParameter("A01Position").getValue();//厚度
    String PLCwancheng = plcread.getPlcParameter("A01Position").getValue();// plc完成字
 
 
    //当下片任务表状态为1时候将数据插入到下片玻璃信息表
    public void insertdownglassinfo() {
 
 
        downWorkstationMapper = WebSocketServer.applicationContext.getBean(DownWorkstationMapper.class);
        downGlassInfoService = WebSocketServer.applicationContext.getBean(DownGlassInfoService.class);
        downGlassInfoMapper = WebSocketServer.applicationContext.getBean(DownGlassInfoMapper.class);
        List<DownGlassInfo> taskdownGlassInf = downGlassInfoMapper.selectunloadingtaskstate();
//
        if (taskdownGlassInf != null && !taskdownGlassInf.isEmpty()) {
 
 
 
 
            for (DownGlassInfo downGlassInfo : taskdownGlassInf) {
                // 创建新的 DownGlassInfo 对象并设置相关属性
                DownGlassInfo newdownGlassInfo = new DownGlassInfo();
 
                newdownGlassInfo.setFlowCardId(downGlassInfo.getFlowCardId());
                Integer maxSequence = downGlassInfoMapper.getMaxSequenceByFlowCardId(downGlassInfo.getFlowCardId());
                int sequence = maxSequence != null ? maxSequence + 1 : 1; // 初始化顺序字段值
 
                newdownGlassInfo.setWidth(downGlassInfo.getWidth());
                newdownGlassInfo.setHeight(downGlassInfo.getHeight());
                newdownGlassInfo.setThickness(downGlassInfo.getThickness());
                newdownGlassInfo.setFilmsid(downGlassInfo.getFilmsid());
                newdownGlassInfo.setSequence(sequence); // 设置顺序字段值
 
                // 插入数据到下片玻璃信息表
                downGlassInfoMapper.insert(newdownGlassInfo);
                //插入数据到机械手任务表
                downWorkstationMapper.insertdownWorkstationtask(newdownGlassInfo);
                //更新任务表状态为0
                downGlassInfoMapper.updateTaskStateToZero(downGlassInfo.getFlowCardId());
 
                sequence++; // 递增顺序字段值
 
 
 
 
            }
        }
    }
 
 
    //当机械手任务表中状态为1,工位表流程卡绑定了架子 更新已经落架数量,并且把下片任务表的对应记录删掉
    public void down_workstation(){
 
        //downWorkstationMapper = WebSocketServer.applicationContext.getBean(DownWorkstationMapper.class);
        //downGlassInfoMapper = WebSocketServer.applicationContext.getBean(DownGlassInfoMapper.class);
        try {
            List<DownWorkstation> taskdownWorkstation = downWorkstationMapper.selectdownWorkstationstate();
            if (taskdownWorkstation != null && !taskdownWorkstation.isEmpty()) {
                //查询下片工位表中是否绑定了架子是否绑定了流程卡号,如果已经绑定则更新已落架数量,并且删除下片任务表中的记录
                for (DownWorkstation downWorkstation : taskdownWorkstation) {
                    downWorkstationMapper.update_racks_number(downWorkstation.getFlowCardId(),6 );
                    downGlassInfoMapper.deletetask(downWorkstation.getFlowCardId());
 
                }
            }
        } catch (Exception e) {
            // 打印异常信息
            e.printStackTrace();
            // 或者可以进行其他异常处理,比如记录日志或者返回特定的错误信息
        }
 
 
    }
 
 
 
    //绑定流程卡号架子
    public void bindingshelf(DownWorkstation downWorkstation){
 
        String FlowCardId=downWorkstation.getFlowCardId();
        int WorkstationId=downWorkstation.getWorkstationId();
 
 
 
    }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
}