package com.example.springboot.component;
|
|
import java.time.LocalDateTime;
|
import java.util.ArrayList;
|
import java.util.List;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import com.example.springboot.service.JdbcConnections;
|
import com.example.springboot.service.SpianService;
|
import com.example.springboot.entity.north_glass_buffer1;
|
import com.example.springboot.entity.device.PlcParameterObject;
|
import com.example.springboot.mapper.AlarmMapper;
|
import com.example.springboot.mapper.AlbaniaMapper;
|
import com.example.springboot.mapper.SpianMapper;
|
|
public class PlcHoldNew extends Thread {
|
|
private AlarmMapper alarmMapper;
|
|
@Autowired
|
private JdbcConnections jdbcConnections;
|
private AlbaniaMapper albaniaMapper;
|
private SpianService spianService;
|
int aaa;
|
|
@Override
|
public void run() {
|
|
while (this != null) {
|
try {
|
|
Thread.sleep(100);
|
} catch (InterruptedException e) {
|
// \\ TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
|
// if (S7control.getinstance().CheckConnected() == false) {
|
spianService = WebSocketServer.applicationContext.getBean(SpianService.class);
|
albaniaMapper = WebSocketServer.applicationContext.getBean(AlbaniaMapper.class);
|
|
//读取DB105区文件
|
PlcParameterObject plcmes=PLCAutoMes.PlcMesObject;
|
//读106
|
PlcParameterObject plcread=PLCAutoMes.PlcReadObject;
|
//读103
|
|
String OutRequest=plcread.getPlcParameter("OutRequest").getValue();//出片请求一线
|
String OutActivate=plcmes.getPlcParameter("OutActivate").getValue();//出片请求二线
|
String AddRequest=plcmes.getPlcParameter("AddRequest").getValue();//进片请求
|
String CarRequest=plcmes.getPlcParameter("CatReque").getValue();//运送车请求
|
|
// 出片任务
|
|
if (OutActivate.equals("1") == false&&CarRequest.equals("0")==true) {
|
S7control.getinstance().WriteWord("DB105.18", (short)1);// 将大车的状态改为运输中
|
|
}
|
|
|
|
///////////// 进片任务
|
|
String B01backs = plcread.getPlcParameter("B01CompleteTheReport").getValue();// b01汇报
|
String B02backs = plcread.getPlcParameter("B02CompleteTheReport").getValue();// b02汇报
|
|
String B01glassid = plcstate.getPlcParameter("B01ID1").getValue();// BO1的玻璃id
|
String B02glassid = plcstate.getPlcParameter("B02ID1").getValue();// B02的玻璃id
|
|
// 当进片小车完成任务时
|
if (B01backs.equals("1") == true) {
|
// 判断是否汇报正确的id
|
int HB = spianMapper.SelectHB(B01glassid.toString());
|
if (HB > 0) {
|
// 恢复B01小车应答改为1
|
S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(plcmes.getPlcParameter("B01report").getAddressIndex()), (short) 1);
|
String yingda =plcmes.getPlcParameter("B01report").getValue();// b01汇报
|
if (yingda.equals("1")) {
|
spianService.overtask(B01glassid.toString());// 完成任务
|
}
|
}
|
|
}else{
|
// 恢复B01小车应答改为0
|
S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(plcmes.getPlcParameter("B01report").getAddressIndex()), (short) 0);
|
}
|
|
// 当出片小车完成任务时
|
if (B02backs.equals("1") == true) {
|
// 判断是否汇报正确的id
|
int HB = spianMapper.SelectHB(B02glassid);
|
if (HB > 0) {
|
// 恢复B02小车应答改为1
|
S7control.getinstance().WriteWord(plcmes.getPlcParameter("B02report").getAddress(plcmes.getPlcParameter("B02report").getAddressIndex()), (short) 1);
|
String yingda =plcmes.getPlcParameter("B01report").getValue();// b02应答
|
if (yingda.equals("1") == true) {
|
spianService.overtask(B02glassid);// 完成任务
|
}
|
}
|
}else{
|
S7control.getinstance().WriteWord(plcmes.getPlcParameter("B02report").getAddress(plcmes.getPlcParameter("B02report").getAddressIndex()), (short) 0);
|
}
|
|
|
// 获取DO1数据
|
String Do1ID=plcread.getPlcParameter("FeedID").getValue();// 获取请求的id跟DO1同时清
|
// 获取DO2数据
|
String Do2ID=plcread.getPlcParameter("FeedID").getValue();// 获取请求的id跟DO1同时清
|
|
|
int questate = spianMapper.Selectquecount(Do1ID.toString());// 判断扫码位是否有玻璃已确认
|
// queueid1.toString().isEmpty()
|
north_glass_buffer1 glass1 = spianMapper.selectGlass(Do1ID);// D01的玻璃信息
|
north_glass_buffer1 glass2 = spianMapper.selectGlass(Do2ID);// D02玻璃信息
|
// 当扫码位玻璃id为空时 宽度为0
|
if (Do1ID != null && questate == 0) {
|
// 写入D01的数据到上片队列表
|
if (glass1 == null) { // 当没有值时传空
|
spianMapper.Updatequeue(null, null, null, null, 0, null, null, null, null, 1);
|
} else {
|
spianMapper.Updatequeue(Do1ID.toString(), glass1.getordernumber(), glass1.getlistnumber(),
|
glass1.getboxnumber(), 0, glass1.getglasslengthmm().toString(), glass1.getglassheightmm().toString(),
|
glass1.getglasslength().toString(), glass1.getglassheight().toString(), 1);
|
}
|
|
}
|
|
if (Do2ID != null) {
|
// 写入D02的数据到上片队列表
|
if (glass2 == null) {
|
spianMapper.Updatequeue(null, null, null, null, 0, null, null, null, null, 2);
|
} else {
|
spianMapper.Updatequeue(Do2ID.toString(), glass2.getordernumber(), glass2.getlistnumber(),
|
glass2.getboxnumber(), 0, glass2.getglasslengthmm().toString(), glass2.getglassheightmm().toString(),
|
glass2.getglasslength().toString(), glass2.getglassheight().toString(), 2);
|
spianMapper.overqueue2(Do2ID.toString(), 0, 1);// 更改扫码位任务表的状态为0
|
S7control.getinstance().WriteWord("DB105.16", (short) 0);// 关闭任务启动
|
}
|
|
}
|
|
// 查询数据库
|
// 推送到前端
|
|
// }
|
}
|
}
|
|
}
|