121 lines
5.0 KiB
Java
121 lines
5.0 KiB
Java
package com.ruoyi.Dzp;
|
|
|
|
|
|
import com.ruoyi.Dzp.domain.basLed;
|
|
import com.ruoyi.Dzp.mapper.BasLedMapper;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import java.io.IOException;
|
|
import java.util.List;
|
|
|
|
@RestController
|
|
@RequestMapping("/api2dzp")
|
|
public class DzpSend {
|
|
@Autowired
|
|
private BasLedMapper mapper;
|
|
|
|
|
|
@Scheduled(fixedDelay = 1000)
|
|
public void InLed() throws IOException {
|
|
basLed basLed = new basLed();
|
|
basLed.setSendFlag("0");
|
|
basLed.setId(1);
|
|
List<com.ruoyi.Dzp.domain.basLed> basLeds = mapper.selectBasLedList(basLed);
|
|
if (basLeds != null && basLeds.size() > 0 && (basLeds.get(0).getModel().equals("1") || basLeds.get(0).getModel().equals("2"))) {
|
|
MyUdpSocket myUdpSocket = new MyUdpSocket(6666);
|
|
ProtocolDemo.my_udp = myUdpSocket;
|
|
String ip = basLeds.get(0).getIpAddress();
|
|
String msgProductTitle = "物资编码:";
|
|
String msgProduct = basLeds.get(0).getProduct_id();
|
|
String msgSpecTitle = "物资规格:";
|
|
String msgSpec = basLeds.get(0).getSpec();
|
|
String msg3 = "托盘条码:" + basLeds.get(0).getTrayCode();
|
|
String msg4 = null;
|
|
if (basLeds.get(0).getModel().equals("1")) {
|
|
msg4 = "入库数量:";
|
|
} else {
|
|
msg4 = "出库数量:";
|
|
}
|
|
String ms7 = "物资名称:";
|
|
String msg8 = basLeds.get(0).getProductName();
|
|
String msgQuantity = basLeds.get(0).getQuantity();
|
|
if (ProtocolDemo.demo_play_chapterschedule4(ip, msgProductTitle, msgSpecTitle, msg4, msg3, msgSpec, msgProduct, ms7, msg8, msgQuantity)) {
|
|
basLeds.get(0).setSendFlag("1");
|
|
mapper.updateBasLed(basLeds.get(0));
|
|
}
|
|
myUdpSocket.close();
|
|
|
|
}
|
|
basLed basLed2 = new basLed();
|
|
basLed2.setSendFlag("0");
|
|
basLed2.setId(2);
|
|
List<com.ruoyi.Dzp.domain.basLed> basLeds2 = mapper.selectBasLedList(basLed2);
|
|
if (basLeds2 != null && basLeds2.size() > 0 && (basLeds2.get(0).getModel().equals("1") || basLeds2.get(0).getModel().equals("2"))) {
|
|
MyUdpSocket myUdpSocket = new MyUdpSocket(6666);
|
|
ProtocolDemo.my_udp = myUdpSocket;
|
|
|
|
String ip = basLeds2.get(0).getIpAddress();
|
|
String msgProductTitle = "物资编码:";
|
|
String msgProduct = basLeds2.get(0).getProduct_id();
|
|
String msgSpecTitle = "物资规格:";
|
|
String msgSpec = basLeds2.get(0).getSpec();
|
|
String msg3 = "托盘条码:" + basLeds2.get(0).getTrayCode();
|
|
String msg4 = null;
|
|
if (basLeds2.get(0).getModel().equals("1")) {
|
|
msg4 = "入库数量:";
|
|
} else {
|
|
msg4 = "出库数量:";
|
|
}
|
|
String ms7 = "物资名称:";
|
|
String msg8 = basLeds2.get(0).getProductName();
|
|
String msgQuantity = basLeds2.get(0).getQuantity();
|
|
if (ProtocolDemo.demo_play_chapterschedule4(ip, msgProductTitle, msgSpecTitle, msg4, msg3, msgSpec, msgProduct, ms7, msg8, msgQuantity)) {
|
|
basLeds2.get(0).setSendFlag("1");
|
|
mapper.updateBasLed(basLeds2.get(0));
|
|
}
|
|
|
|
myUdpSocket.close();
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
@Scheduled(fixedDelay = 1000)
|
|
public void ErrorLed() throws IOException {
|
|
basLed basLed = new basLed();
|
|
basLed.setSendFlag("0");
|
|
basLed.setId(1);
|
|
List<com.ruoyi.Dzp.domain.basLed> basLeds = mapper.selectBasLedList(basLed);
|
|
if (basLeds != null && basLeds.size() > 0 && basLeds.get(0).getModel().equals("3")) {
|
|
MyUdpSocket myUdpSocket = new MyUdpSocket(6666);
|
|
ProtocolDemo.my_udp = myUdpSocket;
|
|
String ip = basLeds.get(0).getIpAddress();
|
|
if (ProtocolDemo.demo_play_chapterschedule2(ip, "报警信息", basLeds.get(0).getErrorMsg())) {
|
|
basLeds.get(0).setSendFlag("1");
|
|
mapper.updateBasLed(basLeds.get(0));
|
|
}
|
|
myUdpSocket.close();
|
|
|
|
}
|
|
basLed basLed2 = new basLed();
|
|
basLed2.setSendFlag("0");
|
|
basLed2.setId(2);
|
|
List<com.ruoyi.Dzp.domain.basLed> basLeds2 = mapper.selectBasLedList(basLed2);
|
|
if (basLeds2 != null && basLeds2.size() > 0 && basLeds2.get(0).getModel().equals("3")) {
|
|
MyUdpSocket myUdpSocket = new MyUdpSocket(6666);
|
|
ProtocolDemo.my_udp = myUdpSocket;
|
|
String ip = basLeds2.get(0).getIpAddress();
|
|
if (ProtocolDemo.demo_play_chapterschedule2(ip, "报警信息", basLeds2.get(0).getErrorMsg())) {
|
|
basLeds2.get(0).setSendFlag("1");
|
|
mapper.updateBasLed(basLeds2.get(0));
|
|
}
|
|
myUdpSocket.close();
|
|
}
|
|
}
|
|
}
|