Commit 2108191c56a0d708ecb6727f4f32ea66192ded89
Merge branch 'develop' of http://172.16.29.40:8010/wms/wms_guangzhouwanbao into develop
Showing
10 changed files
with
644 additions
and
25 deletions
lib/modbus4j-3.0.3.jar
0 → 100644
No preview for this file type
pom.xml
... | ... | @@ -86,7 +86,11 @@ |
86 | 86 | <artifactId>jimureport-spring-boot-starter</artifactId> |
87 | 87 | <version>1.5.2</version> |
88 | 88 | </dependency> |
89 | - | |
89 | + <dependency> | |
90 | + <groupId>com.intelligt.modbus</groupId> | |
91 | + <artifactId>jlibmodbus</artifactId> | |
92 | + <version>1.2.9.7</version> | |
93 | + </dependency> | |
90 | 94 | <!--qrcODE end--> |
91 | 95 | <!--对于web的依赖--> |
92 | 96 | <dependency> |
... | ... |
src/main/java/com/huaheng/api/acs/service/AcsServiceImpl.java
... | ... | @@ -382,13 +382,22 @@ public class AcsServiceImpl extends ServiceImpl<AcsMapper,AgvTask> implements Ac |
382 | 382 | if(StringUtils.isNull(o1)) { |
383 | 383 | return AjaxResult.error("任务号为空"); |
384 | 384 | } |
385 | + Integer taskNo=Integer.valueOf(o1.toString()); | |
386 | + List<AgvTask> list = list(new LambdaQueryWrapper<AgvTask>().eq(AgvTask::getId, taskNo)); | |
387 | + if(CollectionUtils.isNotEmpty(list)){ | |
388 | + AgvTask agvTask1 = list.get(0); | |
389 | + if(agvTask1.getStatus().equals(100)){ | |
390 | + return AjaxResult.success("任务已经是完成了的"); | |
391 | + } | |
392 | + }else { | |
393 | + return AjaxResult.success("任务不存在"); | |
394 | + } | |
385 | 395 | if(StringUtils.isNull(o2)) { |
386 | 396 | return AjaxResult.error("小车编号为空"); |
387 | 397 | } |
388 | 398 | if(StringUtils.isNull(o3)) { |
389 | 399 | return AjaxResult.error("任务状态为空"); |
390 | 400 | } |
391 | - Integer taskNo=Integer.valueOf(o1.toString()); | |
392 | 401 | String carNo=o2.toString(); |
393 | 402 | String status=o3.toString(); |
394 | 403 | agvTask.setId(taskNo); |
... | ... |
src/main/java/com/huaheng/api/dianqi/JLibModbusRead.java
0 → 100644
1 | +package com.huaheng.api.dianqi; | |
2 | + | |
3 | + | |
4 | +import java.net.InetAddress; | |
5 | + | |
6 | +import com.intelligt.modbus.jlibmodbus.Modbus; | |
7 | +import com.intelligt.modbus.jlibmodbus.exception.ModbusIOException; | |
8 | +import com.intelligt.modbus.jlibmodbus.exception.ModbusNumberException; | |
9 | +import com.intelligt.modbus.jlibmodbus.exception.ModbusProtocolException; | |
10 | +import com.intelligt.modbus.jlibmodbus.master.ModbusMaster; | |
11 | +import com.intelligt.modbus.jlibmodbus.master.ModbusMasterFactory; | |
12 | +import com.intelligt.modbus.jlibmodbus.tcp.TcpParameters; | |
13 | + | |
14 | + | |
15 | +/** | |
16 | + * Hello world! | |
17 | + * | |
18 | + */ | |
19 | +public class JLibModbusRead { | |
20 | + public static void main(String[] args) { | |
21 | + try { | |
22 | + // 设置主机TCP参数 | |
23 | + TcpParameters tcpParameters = new TcpParameters(); | |
24 | + | |
25 | + // 设置TCP的ip地址 | |
26 | + InetAddress adress = InetAddress.getByName("192.168.2.1"); | |
27 | + //InetAddress adress = InetAddress.getByName("127.0.0.1"); | |
28 | + | |
29 | + // TCP参数设置ip地址 | |
30 | + // tcpParameters.setHost(InetAddress.getLocalHost()); | |
31 | + tcpParameters.setHost(adress); | |
32 | + | |
33 | + // TCP设置长连接 | |
34 | + tcpParameters.setKeepAlive(true); | |
35 | + // TCP设置端口,这里设置是默认端口502 | |
36 | + tcpParameters.setPort(Modbus.TCP_PORT); | |
37 | + | |
38 | + // 创建一个主机 | |
39 | + ModbusMaster master = ModbusMasterFactory.createModbusMasterTCP(tcpParameters); | |
40 | + Modbus.setAutoIncrementTransactionId(true); | |
41 | + | |
42 | + int slaveId = 1;//从机地址 | |
43 | + int offset = 0;//寄存器读取开始地址 | |
44 | + int quantity = 10;//读取的寄存器数量 | |
45 | + | |
46 | + | |
47 | + try { | |
48 | + if (!master.isConnected()) { | |
49 | + master.connect();// 开启连接 | |
50 | + } | |
51 | +// * 读线圈: ON=1,OFF=0 | |
52 | +// * 读离散量 ON=1,OFF=0 | |
53 | +// * 读保存寄存器 指定数据类型(可以是Float) | |
54 | +// * 读输入寄存器 指定数据类型(可以是Float) | |
55 | + boolean[] readCoils = master.readCoils(slaveId, offset, quantity); | |
56 | + boolean[] discreteInputs = master.readDiscreteInputs(slaveId, offset, quantity); | |
57 | + int[] readHoldingRegisters = master.readHoldingRegisters(slaveId, offset, quantity); | |
58 | + // 读取对应从机的数据,readInputRegisters读取的写寄存器,功能码04 | |
59 | + int[] readInputRegisters = master.readInputRegisters(slaveId, offset, quantity); | |
60 | + | |
61 | + for (boolean value : readCoils) { | |
62 | + System.out.println("readCoils:Address: " + offset++ + ", Value: " + value); | |
63 | + } | |
64 | + | |
65 | + for (boolean value : discreteInputs) { | |
66 | + System.out.println("discreteInputs:Address: " + offset++ + ", Value: " + value); | |
67 | + } | |
68 | + | |
69 | + for (int value : readHoldingRegisters) { | |
70 | + System.out.println("readHoldingRegisters:Address: " + offset++ + ", Value: " + value); | |
71 | + } | |
72 | + | |
73 | + // 控制台输出 | |
74 | + for (int value : readInputRegisters) { | |
75 | + System.out.println("readInputRegisters:Address: " + offset++ + ", Value: " + value); | |
76 | + } | |
77 | + | |
78 | + } catch (ModbusProtocolException e) { | |
79 | + e.printStackTrace(); | |
80 | + } catch (ModbusNumberException e) { | |
81 | + e.printStackTrace(); | |
82 | + } catch (ModbusIOException e) { | |
83 | + e.printStackTrace(); | |
84 | + } finally { | |
85 | + try { | |
86 | + master.disconnect(); | |
87 | + } catch (ModbusIOException e) { | |
88 | + e.printStackTrace(); | |
89 | + } | |
90 | + } | |
91 | + } catch (RuntimeException e) { | |
92 | + throw e; | |
93 | + } catch (Exception e) { | |
94 | + e.printStackTrace(); | |
95 | + } | |
96 | + } | |
97 | +} | |
... | ... |
src/main/java/com/huaheng/api/dianqi/JLibModbusWrite.java
0 → 100644
1 | +package com.huaheng.api.dianqi; | |
2 | + | |
3 | +import com.intelligt.modbus.jlibmodbus.Modbus; | |
4 | +import com.intelligt.modbus.jlibmodbus.exception.ModbusIOException; | |
5 | +import com.intelligt.modbus.jlibmodbus.exception.ModbusNumberException; | |
6 | +import com.intelligt.modbus.jlibmodbus.exception.ModbusProtocolException; | |
7 | +import com.intelligt.modbus.jlibmodbus.master.ModbusMaster; | |
8 | +import com.intelligt.modbus.jlibmodbus.master.ModbusMasterFactory; | |
9 | +import com.intelligt.modbus.jlibmodbus.tcp.TcpParameters; | |
10 | + | |
11 | +import java.net.InetAddress; | |
12 | + | |
13 | +public class JLibModbusWrite { | |
14 | + public static void main(String[] args) { | |
15 | + try { | |
16 | + // 设置主机TCP参数 | |
17 | + TcpParameters tcpParameters = new TcpParameters(); | |
18 | + | |
19 | + // 设置TCP的ip地址 | |
20 | + InetAddress adress = InetAddress.getByName("192.168.2.1"); | |
21 | + // InetAddress adress = InetAddress.getByName("127.0.0.1"); | |
22 | + | |
23 | + // TCP参数设置ip地址 | |
24 | + // tcpParameters.setHost(InetAddress.getLocalHost()); | |
25 | + tcpParameters.setHost(adress); | |
26 | + | |
27 | + // TCP设置长连接 | |
28 | + tcpParameters.setKeepAlive(true); | |
29 | + // TCP设置端口,这里设置是默认端口502 | |
30 | + tcpParameters.setPort(Modbus.TCP_PORT); | |
31 | + | |
32 | + // 创建一个主机 | |
33 | + ModbusMaster master = ModbusMasterFactory.createModbusMasterTCP(tcpParameters); | |
34 | + Modbus.setAutoIncrementTransactionId(true); | |
35 | + | |
36 | + int slaveId = 1;//从机地址 | |
37 | + int offset = 6;//寄存器读取开始地址 | |
38 | + int quantity = 10;//读取的寄存器数量 | |
39 | + | |
40 | + | |
41 | + try { | |
42 | + if (!master.isConnected()) { | |
43 | + master.connect();// 开启连接 | |
44 | + } | |
45 | +// * 读线圈: ON=1,OFF=0 | |
46 | +// * 读离散量 ON=1,OFF=0 | |
47 | +// * 读保存寄存器 指定数据类型(可以是Float) | |
48 | +// * 读输入寄存器 指定数据类型(可以是Float) | |
49 | +// boolean[] readCoils = master.readCoils(slaveId, offset, 1); | |
50 | +// for (boolean readCoil : readCoils) { | |
51 | +// System.out.println(readCoil); | |
52 | +// } | |
53 | +// int[] readHoldingRegisters = master.readHoldingRegisters(slaveId, offset, 1); | |
54 | +// for (int readHoldingRegister : readHoldingRegisters) { | |
55 | +// System.out.println(readHoldingRegister); | |
56 | +// } | |
57 | + // master.writeSingleCoil(slaveId,0,true); | |
58 | + // boolean[] booleans=new boolean[]{true,true,true,true,true,true,true,true,true,true}; | |
59 | + // master.writeMultipleCoils(slaveId,0,booleans); | |
60 | + master.writeSingleRegister(slaveId,5,512); | |
61 | + //int[] register=new int[]{0,0,0,0,0,0,0,0,0,0}; | |
62 | + | |
63 | + | |
64 | + // master.writeMultipleRegisters(slaveId,0,register); | |
65 | + } catch (ModbusProtocolException e) { | |
66 | + e.printStackTrace(); | |
67 | + } catch (ModbusNumberException e) { | |
68 | + e.printStackTrace(); | |
69 | + } catch (ModbusIOException e) { | |
70 | + e.printStackTrace(); | |
71 | + } finally { | |
72 | + try { | |
73 | + master.disconnect(); | |
74 | + } catch (ModbusIOException e) { | |
75 | + e.printStackTrace(); | |
76 | + } | |
77 | + } | |
78 | + } catch (RuntimeException e) { | |
79 | + throw e; | |
80 | + } catch (Exception e) { | |
81 | + e.printStackTrace(); | |
82 | + } | |
83 | + } | |
84 | +} | |
... | ... |
src/main/java/com/huaheng/api/dianqi/Modbus4jUtils.java
0 → 100644
1 | +//package com.tcb.modbus; | |
2 | +// | |
3 | +//import com.serotonin.modbus4j.BatchRead; | |
4 | +//import com.serotonin.modbus4j.BatchResults; | |
5 | +//import com.serotonin.modbus4j.ModbusFactory; | |
6 | +//import com.serotonin.modbus4j.ModbusMaster; | |
7 | +//import com.serotonin.modbus4j.code.DataType; | |
8 | +//import com.serotonin.modbus4j.exception.ErrorResponseException; | |
9 | +//import com.serotonin.modbus4j.exception.ModbusInitException; | |
10 | +//import com.serotonin.modbus4j.exception.ModbusTransportException; | |
11 | +//import com.serotonin.modbus4j.ip.IpParameters; | |
12 | +//import com.serotonin.modbus4j.locator.BaseLocator; | |
13 | +// | |
14 | +///** | |
15 | +// * modbus通讯工具类,采用modbus4j实现 | |
16 | +// * | |
17 | +// * @author lxq | |
18 | +// * @dependencies modbus4j-3.0.3.jar | |
19 | +// * @website https://github.com/infiniteautomation/modbus4j | |
20 | +// */ | |
21 | +//public class Modbus4jUtils { | |
22 | +// /** | |
23 | +// * 工厂。 | |
24 | +// */ | |
25 | +// static ModbusFactory modbusFactory; | |
26 | +// static { | |
27 | +// if (modbusFactory == null) { | |
28 | +// modbusFactory = new ModbusFactory(); | |
29 | +// } | |
30 | +// } | |
31 | +// | |
32 | +// /** | |
33 | +// * 获取master | |
34 | +// * | |
35 | +// * @return | |
36 | +// * @throws ModbusInitException | |
37 | +// */ | |
38 | +// public static ModbusMaster getMaster() throws ModbusInitException { | |
39 | +// IpParameters params = new IpParameters(); | |
40 | +// params.setHost("192.168.2.1"); | |
41 | +// params.setPort(502); | |
42 | +// // | |
43 | +// // modbusFactory.createRtuMaster(wapper); //RTU 协议 | |
44 | +// // modbusFactory.createUdpMaster(params);//UDP 协议 | |
45 | +// // modbusFactory.createAsciiMaster(wrapper);//ASCII 协议 | |
46 | +// ModbusMaster master = modbusFactory.createTcpMaster(params, false);// TCP 协议 | |
47 | +// master.init(); | |
48 | +// | |
49 | +// return master; | |
50 | +// } | |
51 | +// | |
52 | +// /** | |
53 | +// * 读取[01 Coil Status 0x]类型 开关数据 | |
54 | +// * | |
55 | +// * @param slaveId | |
56 | +// * slaveId | |
57 | +// * @param offset | |
58 | +// * 位置 | |
59 | +// * @return 读取值 | |
60 | +// * @throws ModbusTransportException | |
61 | +// * 异常 | |
62 | +// * @throws ErrorResponseException | |
63 | +// * 异常 | |
64 | +// * @throws ModbusInitException | |
65 | +// * 异常 | |
66 | +// */ | |
67 | +// public static Boolean readCoilStatus(int slaveId, int offset) | |
68 | +// throws ModbusTransportException, ErrorResponseException, ModbusInitException { | |
69 | +// // 01 Coil Status | |
70 | +// BaseLocator<Boolean> loc = BaseLocator.coilStatus(slaveId, offset); | |
71 | +// Boolean value = getMaster().getValue(loc); | |
72 | +// return value; | |
73 | +// } | |
74 | +// | |
75 | +// /** | |
76 | +// * 读取[02 Input Status 1x]类型 开关数据 | |
77 | +// * | |
78 | +// * @param slaveId | |
79 | +// * @param offset | |
80 | +// * @return | |
81 | +// * @throws ModbusTransportException | |
82 | +// * @throws ErrorResponseException | |
83 | +// * @throws ModbusInitException | |
84 | +// */ | |
85 | +// public static Boolean readInputStatus(int slaveId, int offset) | |
86 | +// throws ModbusTransportException, ErrorResponseException, ModbusInitException { | |
87 | +// // 02 Input Status | |
88 | +// BaseLocator<Boolean> loc = BaseLocator.inputStatus(slaveId, offset); | |
89 | +// Boolean value = getMaster().getValue(loc); | |
90 | +// return value; | |
91 | +// } | |
92 | +// | |
93 | +// /** | |
94 | +// * 读取[03 Holding Register类型 2x]模拟量数据 | |
95 | +// * | |
96 | +// * @param slaveId | |
97 | +// * slave Id | |
98 | +// * @param offset | |
99 | +// * 位置 | |
100 | +// * @param dataType | |
101 | +// * 数据类型,来自com.serotonin.modbus4j.code.DataType | |
102 | +// * @return | |
103 | +// * @throws ModbusTransportException | |
104 | +// * 异常 | |
105 | +// * @throws ErrorResponseException | |
106 | +// * 异常 | |
107 | +// * @throws ModbusInitException | |
108 | +// * 异常 | |
109 | +// */ | |
110 | +// public static Number readHoldingRegister(int slaveId, int offset, int dataType) | |
111 | +// throws ModbusTransportException, ErrorResponseException, ModbusInitException { | |
112 | +// // 03 Holding Register类型数据读取 | |
113 | +// BaseLocator<Number> loc = BaseLocator.holdingRegister(slaveId, offset, dataType); | |
114 | +// Number value = getMaster().getValue(loc); | |
115 | +// return value; | |
116 | +// } | |
117 | +// | |
118 | +// /** | |
119 | +// * 读取[04 Input Registers 3x]类型 模拟量数据 | |
120 | +// * | |
121 | +// * @param slaveId | |
122 | +// * slaveId | |
123 | +// * @param offset | |
124 | +// * 位置 | |
125 | +// * @param dataType | |
126 | +// * 数据类型,来自com.serotonin.modbus4j.code.DataType | |
127 | +// * @return 返回结果 | |
128 | +// * @throws ModbusTransportException | |
129 | +// * 异常 | |
130 | +// * @throws ErrorResponseException | |
131 | +// * 异常 | |
132 | +// * @throws ModbusInitException | |
133 | +// * 异常 | |
134 | +// */ | |
135 | +// public static Number readInputRegisters(int slaveId, int offset, int dataType) | |
136 | +// throws ModbusTransportException, ErrorResponseException, ModbusInitException { | |
137 | +// // 04 Input Registers类型数据读取 | |
138 | +// BaseLocator<Number> loc = BaseLocator.inputRegister(slaveId, offset, dataType); | |
139 | +// Number value = getMaster().getValue(loc); | |
140 | +// return value; | |
141 | +// } | |
142 | +// | |
143 | +// /** | |
144 | +// * 批量读取使用方法 | |
145 | +// * | |
146 | +// * @throws ModbusTransportException | |
147 | +// * @throws ErrorResponseException | |
148 | +// * @throws ModbusInitException | |
149 | +// */ | |
150 | +// public static void batchRead() throws ModbusTransportException, ErrorResponseException, ModbusInitException { | |
151 | +// | |
152 | +// BatchRead<Integer> batch = new BatchRead<Integer>(); | |
153 | +// | |
154 | +// batch.addLocator(0, BaseLocator.holdingRegister(1, 1, DataType.FOUR_BYTE_FLOAT)); | |
155 | +// batch.addLocator(1, BaseLocator.inputStatus(1, 0)); | |
156 | +// | |
157 | +// ModbusMaster master = getMaster(); | |
158 | +// | |
159 | +// batch.setContiguousRequests(false); | |
160 | +// BatchResults<Integer> results = master.send(batch); | |
161 | +// System.out.println(results.getValue(0)); | |
162 | +// System.out.println(results.getValue(1)); | |
163 | +// } | |
164 | +// | |
165 | +// /** | |
166 | +// * 测试 | |
167 | +// * | |
168 | +// * @param args | |
169 | +// */ | |
170 | +// public static void main(String[] args) { | |
171 | +// try { | |
172 | +// // 01测试 | |
173 | +// Boolean v011 = readCoilStatus(1, 0); | |
174 | +// //Boolean v012 = readCoilStatus(1, 1); | |
175 | +// // Boolean v013 = readCoilStatus(1, 6); | |
176 | +// System.out.println("v011:" + v011); | |
177 | +// // System.out.println("v012:" + v012); | |
178 | +// // System.out.println("v013:" + v013); | |
179 | +// // 02测试 | |
180 | +// // Boolean v021 = readInputStatus(1, 0); | |
181 | +// // Boolean v022 = readInputStatus(1, 1); | |
182 | +// // Boolean v023 = readInputStatus(1, 2); | |
183 | +// // System.out.println("v021:" + v021); | |
184 | +// // System.out.println("v022:" + v022); | |
185 | +// // System.out.println("v023:" + v023); | |
186 | +// | |
187 | +// // 03测试 | |
188 | +// Number v031 = readHoldingRegister(1, 1, DataType.FOUR_BYTE_FLOAT);// 注意,float | |
189 | +// // Number v032 = readHoldingRegister(1, 3, DataType.FOUR_BYTE_FLOAT);// 同上 | |
190 | +// System.out.println("v031:" + v031); | |
191 | +// // System.out.println("v032:" + v032); | |
192 | +// | |
193 | +// // 04测试 | |
194 | +// Number v041 = readInputRegisters(1, 0, DataType.FOUR_BYTE_FLOAT);// | |
195 | +// // Number v042 = readInputRegisters(1, 2, DataType.FOUR_BYTE_FLOAT);// | |
196 | +// System.out.println("v041:" + v041); | |
197 | +// // System.out.println("v042:" + v042); | |
198 | +// // 批量读取 | |
199 | +// // batchRead(); | |
200 | +// | |
201 | +// } catch (Exception e) { | |
202 | +// e.printStackTrace(); | |
203 | +// } | |
204 | +// } | |
205 | +//} | |
206 | +// | |
... | ... |
src/main/java/com/huaheng/api/dianqi/Modbus4jWriteUtils.java
0 → 100644
1 | +//package com.tcb.modbus; | |
2 | +// | |
3 | +//import org.apache.commons.logging.Log; | |
4 | +//import org.apache.commons.logging.LogFactory; | |
5 | +// | |
6 | +//import com.serotonin.modbus4j.ModbusFactory; | |
7 | +//import com.serotonin.modbus4j.ModbusMaster; | |
8 | +//import com.serotonin.modbus4j.code.DataType; | |
9 | +//import com.serotonin.modbus4j.exception.ErrorResponseException; | |
10 | +//import com.serotonin.modbus4j.exception.ModbusInitException; | |
11 | +//import com.serotonin.modbus4j.exception.ModbusTransportException; | |
12 | +//import com.serotonin.modbus4j.ip.IpParameters; | |
13 | +//import com.serotonin.modbus4j.locator.BaseLocator; | |
14 | +//import com.serotonin.modbus4j.msg.ModbusResponse; | |
15 | +//import com.serotonin.modbus4j.msg.WriteCoilRequest; | |
16 | +//import com.serotonin.modbus4j.msg.WriteCoilResponse; | |
17 | +//import com.serotonin.modbus4j.msg.WriteCoilsRequest; | |
18 | +//import com.serotonin.modbus4j.msg.WriteCoilsResponse; | |
19 | +//import com.serotonin.modbus4j.msg.WriteRegisterRequest; | |
20 | +//import com.serotonin.modbus4j.msg.WriteRegisterResponse; | |
21 | +//import com.serotonin.modbus4j.msg.WriteRegistersRequest; | |
22 | +// | |
23 | +///** | |
24 | +// * modbus4j写入数据 | |
25 | +// * | |
26 | +// * @author xq | |
27 | +// * | |
28 | +// */ | |
29 | +//public class Modbus4jWriteUtils { | |
30 | +// static Log log = LogFactory.getLog(Modbus4jWriteUtils.class); | |
31 | +// /** | |
32 | +// * 工厂。 | |
33 | +// */ | |
34 | +// static ModbusFactory modbusFactory; | |
35 | +// static { | |
36 | +// if (modbusFactory == null) { | |
37 | +// modbusFactory = new ModbusFactory(); | |
38 | +// } | |
39 | +// } | |
40 | +// | |
41 | +// /** | |
42 | +// * 获取tcpMaster | |
43 | +// * | |
44 | +// * @return | |
45 | +// * @throws ModbusInitException | |
46 | +// */ | |
47 | +// public static ModbusMaster getMaster() throws ModbusInitException { | |
48 | +// IpParameters params = new IpParameters(); | |
49 | +// params.setHost("localhost"); | |
50 | +// params.setPort(502); | |
51 | +// | |
52 | +// ModbusMaster tcpMaster = modbusFactory.createTcpMaster(params, false); | |
53 | +// tcpMaster.init(); | |
54 | +// | |
55 | +// return tcpMaster; | |
56 | +// } | |
57 | +// | |
58 | +// /** | |
59 | +// * 写 [01 Coil Status(0x)]写一个 function ID = 5 | |
60 | +// * | |
61 | +// * @param slaveId | |
62 | +// * slave的ID | |
63 | +// * @param writeOffset | |
64 | +// * 位置 | |
65 | +// * @param writeValue | |
66 | +// * 值 | |
67 | +// * @return 是否写入成功 | |
68 | +// * @throws ModbusTransportException | |
69 | +// * @throws ModbusInitException | |
70 | +// */ | |
71 | +// public static boolean writeCoil(int slaveId, int writeOffset, boolean writeValue) | |
72 | +// throws ModbusTransportException, ModbusInitException { | |
73 | +// // 获取master | |
74 | +// ModbusMaster tcpMaster = getMaster(); | |
75 | +// // 创建请求 | |
76 | +// WriteCoilRequest request = new WriteCoilRequest(slaveId, writeOffset, writeValue); | |
77 | +// // 发送请求并获取响应对象 | |
78 | +// WriteCoilResponse response = (WriteCoilResponse) tcpMaster.send(request); | |
79 | +// if (response.isException()) { | |
80 | +// return false; | |
81 | +// } else { | |
82 | +// return true; | |
83 | +// } | |
84 | +// } | |
85 | +// | |
86 | +// /** | |
87 | +// * 写[01 Coil Status(0x)] 写多个 function ID = 15 | |
88 | +// * | |
89 | +// * @param slaveId | |
90 | +// * slaveId | |
91 | +// * @param startOffset | |
92 | +// * 开始位置 | |
93 | +// * @param bdata | |
94 | +// * 写入的数据 | |
95 | +// * @return 是否写入成功 | |
96 | +// * @throws ModbusTransportException | |
97 | +// * @throws ModbusInitException | |
98 | +// */ | |
99 | +// public static boolean writeCoils(int slaveId, int startOffset, boolean[] bdata) | |
100 | +// throws ModbusTransportException, ModbusInitException { | |
101 | +// // 获取master | |
102 | +// ModbusMaster tcpMaster = getMaster(); | |
103 | +// // 创建请求 | |
104 | +// WriteCoilsRequest request = new WriteCoilsRequest(slaveId, startOffset, bdata); | |
105 | +// // 发送请求并获取响应对象 | |
106 | +// WriteCoilsResponse response = (WriteCoilsResponse) tcpMaster.send(request); | |
107 | +// if (response.isException()) { | |
108 | +// return false; | |
109 | +// } else { | |
110 | +// return true; | |
111 | +// } | |
112 | +// | |
113 | +// } | |
114 | +// | |
115 | +// /*** | |
116 | +// * 写[03 Holding Register(4x)] 写一个 function ID = 6 | |
117 | +// * | |
118 | +// * @param slaveId | |
119 | +// * @param writeOffset | |
120 | +// * @param writeValue | |
121 | +// * @return | |
122 | +// * @throws ModbusTransportException | |
123 | +// * @throws ModbusInitException | |
124 | +// */ | |
125 | +// public static boolean writeRegister(int slaveId, int writeOffset, short writeValue) | |
126 | +// throws ModbusTransportException, ModbusInitException { | |
127 | +// // 获取master | |
128 | +// ModbusMaster tcpMaster = getMaster(); | |
129 | +// // 创建请求对象 | |
130 | +// WriteRegisterRequest request = new WriteRegisterRequest(slaveId, writeOffset, writeValue); | |
131 | +// WriteRegisterResponse response = (WriteRegisterResponse) tcpMaster.send(request); | |
132 | +// if (response.isException()) { | |
133 | +// log.error(response.getExceptionMessage()); | |
134 | +// return false; | |
135 | +// } else { | |
136 | +// return true; | |
137 | +// } | |
138 | +// | |
139 | +// } | |
140 | +// | |
141 | +// /** | |
142 | +// * | |
143 | +// * 写入[03 Holding Register(4x)]写多个 function ID=16 | |
144 | +// * | |
145 | +// * @param slaveId | |
146 | +// * modbus的slaveID | |
147 | +// * @param startOffset | |
148 | +// * 起始位置偏移量值 | |
149 | +// * @param sdata | |
150 | +// * 写入的数据 | |
151 | +// * @return 返回是否写入成功 | |
152 | +// * @throws ModbusTransportException | |
153 | +// * @throws ModbusInitException | |
154 | +// */ | |
155 | +// public static boolean writeRegisters(int slaveId, int startOffset, short[] sdata) | |
156 | +// throws ModbusTransportException, ModbusInitException { | |
157 | +// // 获取master | |
158 | +// ModbusMaster tcpMaster = getMaster(); | |
159 | +// // 创建请求对象 | |
160 | +// WriteRegistersRequest request = new WriteRegistersRequest(slaveId, startOffset, sdata); | |
161 | +// // 发送请求并获取响应对象 | |
162 | +// ModbusResponse response = tcpMaster.send(request); | |
163 | +// if (response.isException()) { | |
164 | +// log.error(response.getExceptionMessage()); | |
165 | +// return false; | |
166 | +// } else { | |
167 | +// return true; | |
168 | +// } | |
169 | +// } | |
170 | +// | |
171 | +// /** | |
172 | +// * 写入数字类型的模拟量(如:写入Float类型的模拟量、Double类型模拟量、整数类型Short、Integer、Long) | |
173 | +// * | |
174 | +// * @param slaveId | |
175 | +// * @param offset | |
176 | +// * @param value | |
177 | +// * 写入值,Number的子类,例如写入Float浮点类型,Double双精度类型,以及整型short,int,long | |
178 | +// * @param registerCount | |
179 | +// * ,com.serotonin.modbus4j.code.DataType | |
180 | +// * @throws ModbusTransportException | |
181 | +// * @throws ErrorResponseException | |
182 | +// * @throws ModbusInitException | |
183 | +// */ | |
184 | +// public static void writeHoldingRegister(int slaveId, int offset, Number value, int dataType) | |
185 | +// throws ModbusTransportException, ErrorResponseException, ModbusInitException { | |
186 | +// // 获取master | |
187 | +// ModbusMaster tcpMaster = getMaster(); | |
188 | +// // 类型 | |
189 | +// BaseLocator<Number> locator = BaseLocator.holdingRegister(slaveId, offset, dataType); | |
190 | +// tcpMaster.setValue(locator, value); | |
191 | +// } | |
192 | +// | |
193 | +// public static void main(String[] args) { | |
194 | +// try { | |
195 | +// //@formatter:off | |
196 | +// // 测试01 | |
197 | +//// boolean t01 = writeCoil(1, 0, true); | |
198 | +//// System.out.println("T01:" + t01); | |
199 | +// | |
200 | +// // 测试02 | |
201 | +//// boolean t02 = writeCoils(1, 0, new boolean[] { true, false, true }); | |
202 | +//// System.out.println("T02:" + t02); | |
203 | +// | |
204 | +// // 测试03 | |
205 | +//// short v = -3; | |
206 | +//// boolean t03 = writeRegister(1, 0, v); | |
207 | +//// System.out.println("T03:" + t03); | |
208 | +// // 测试04 | |
209 | +//// boolean t04 = writeRegisters(1, 0, new short[] { -3, 3, 9 }); | |
210 | +//// System.out.println("t04:" + t04); | |
211 | +// //写模拟量 | |
212 | +// writeHoldingRegister(1,0, 10.1f, DataType.FOUR_BYTE_FLOAT); | |
213 | +// | |
214 | +// //@formatter:on | |
215 | +// } catch (Exception e) { | |
216 | +// e.printStackTrace(); | |
217 | +// } | |
218 | +// | |
219 | +// } | |
220 | +// | |
221 | +//} | |
... | ... |
src/main/java/com/huaheng/api/wcs/service/warecellAllocation/WarecellAllocationServiceImpl.java
... | ... | @@ -194,7 +194,7 @@ public class WarecellAllocationServiceImpl implements WarecellAllocationService |
194 | 194 | for (TaskDetail taskDetail : taskDetailList) { |
195 | 195 | ReceiptContainerDetail receiptContainerDetail = receiptContainerDetailService. |
196 | 196 | getById(taskDetail.getAllocationId()); |
197 | - if (receiptContainerDetail != null) { | |
197 | + if (receiptContainerDetail != null&&taskHeader.getInternalTaskType().equals(100)) { | |
198 | 198 | receiptContainerDetailList.add(receiptContainerDetail); |
199 | 199 | } |
200 | 200 | } |
... | ... |
src/main/java/com/huaheng/pc/monitor/job/task/RyTask.java
... | ... | @@ -157,13 +157,20 @@ public class RyTask extends BaseController { |
157 | 157 | } |
158 | 158 | |
159 | 159 | public void autoExecuteAgvTask(){ |
160 | - List<AgvTask> agvTasks = acsService.list(new LambdaQueryWrapper<AgvTask>().eq(AgvTask::getStatus, 1) | |
161 | - .isNotNull(AgvTask::getContainerCode) | |
162 | - .isNotNull(AgvTask::getToPort) | |
163 | - .isNotNull(AgvTask::getFromPort)); | |
164 | - if(CollectionUtils.isNotEmpty(agvTasks)){ | |
165 | - AjaxResult ajaxResult = acsService.sendTaskToAGV(Convert.toIntArray(agvTasks.get(0).getId().toString().trim())); | |
166 | - } | |
160 | + handleMultiProcess(new BaseController.MultiProcessListener() { | |
161 | + @Override | |
162 | + public AjaxResult doProcess() { | |
163 | + AjaxResult ajaxResult=new AjaxResult(); | |
164 | + List<AgvTask> agvTasks = acsService.list(new LambdaQueryWrapper<AgvTask>().eq(AgvTask::getStatus, 1) | |
165 | + .isNotNull(AgvTask::getContainerCode) | |
166 | + .isNotNull(AgvTask::getToPort) | |
167 | + .isNotNull(AgvTask::getFromPort)); | |
168 | + if(CollectionUtils.isNotEmpty(agvTasks)){ | |
169 | + ajaxResult = acsService.sendTaskToAGV(Convert.toIntArray(agvTasks.get(0).getId().toString().trim())); | |
170 | + } | |
171 | + return ajaxResult; | |
172 | + } | |
173 | + }); | |
167 | 174 | } |
168 | 175 | |
169 | 176 | |
... | ... |
src/main/java/com/huaheng/pc/task/taskHeader/service/ShipmentTaskService.java
... | ... | @@ -426,28 +426,19 @@ public class ShipmentTaskService { |
426 | 426 | if (StringUtils.isNull(fromLocationRecord)) { |
427 | 427 | throw new ServiceException("系统没有" + fromLocation + "库位"); |
428 | 428 | } |
429 | - /* 如果目标库位与源库位不一样时,需要更新两个库位*/ | |
430 | - if (StringUtils.isNotEmpty(toLocation) | |
431 | - && !fromLocation.equals(toLocation)) { | |
429 | + if (taskType.equals(QuantityConstant.TASK_TYPE_WHOLESHIPMENT)) { | |
430 | + fromLocationRecord.setStatus(QuantityConstant.STATUS_LOCATION_EMPTY); | |
431 | + fromLocationRecord.setContainerCode(""); | |
432 | + locationService.updateById(fromLocationRecord); | |
433 | + }else { | |
432 | 434 | Location toLocationRecord = locationService.getLocationByCode(toLocation, warehouseCode); |
433 | 435 | if (StringUtils.isNull(fromLocationRecord)) { |
434 | 436 | throw new ServiceException("系统没有" + toLocation + "库位"); |
435 | 437 | } |
436 | 438 | toLocationRecord.setStatus(QuantityConstant.STATUS_LOCATION_EMPTY); |
437 | - if (taskType.equals(QuantityConstant.TASK_TYPE_WHOLESHIPMENT)) { | |
438 | - toLocationRecord.setContainerCode(""); | |
439 | - } else { | |
440 | - toLocationRecord.setContainerCode(containerCode); | |
441 | - } | |
439 | + toLocationRecord.setContainerCode(containerCode); | |
442 | 440 | locationService.updateById(toLocationRecord); |
443 | - fromLocationRecord.setContainerCode(""); | |
444 | 441 | } |
445 | - fromLocationRecord.setStatus(QuantityConstant.STATUS_LOCATION_EMPTY); | |
446 | - if (taskType.equals(QuantityConstant.TASK_TYPE_WHOLESHIPMENT)) { | |
447 | - fromLocationRecord.setContainerCode(""); | |
448 | - } | |
449 | - locationService.updateById(fromLocationRecord); | |
450 | - | |
451 | 442 | Container container = containerService.getContainerByCode(containerCode, warehouseCode); |
452 | 443 | if (StringUtils.isEmpty(containerCode)) { |
453 | 444 | throw new ServiceException("系统无"+container+"容器"); |
... | ... |