Commit b3c27a8f authored by 喻训浩's avatar 喻训浩

fix: avi修改

parent 13268530
...@@ -86,5 +86,6 @@ public class PaintshopStation { ...@@ -86,5 +86,6 @@ public class PaintshopStation {
@ApiModelProperty(notes = "旧状态",hidden = true) @ApiModelProperty(notes = "旧状态",hidden = true)
private StationState oldState; private StationState oldState;
@ApiModelProperty(notes = "平移车到位信号",hidden = true)
private Boolean arrive;
} }
...@@ -23,7 +23,8 @@ import javax.sql.DataSource; ...@@ -23,7 +23,8 @@ import javax.sql.DataSource;
"net.vtstar.zhongtong.avi.sqlserver.mapper", "net.vtstar.zhongtong.avi.sqlserver.mapper",
"net.vtstar.zhongtong.avi.access.mapper", "net.vtstar.zhongtong.avi.access.mapper",
"net.vtstar.zhongtong.avi.laboratory.mapper", "net.vtstar.zhongtong.avi.laboratory.mapper",
"net.vtstar.zhongtong.avi.gateway.parts.mapper" "net.vtstar.zhongtong.avi.gateway.parts.mapper",
"net.vtstar.zhongtong.avi.monitoring.mapper"
}, },
sqlSessionFactoryRef = "sqlSessionFactoryMySQL") sqlSessionFactoryRef = "sqlSessionFactoryMySQL")
public class MybatisMySQLConfig { public class MybatisMySQLConfig {
......
...@@ -24,6 +24,7 @@ public class PDAController { ...@@ -24,6 +24,7 @@ public class PDAController {
@PostMapping("/hanzhuang/bound") @PostMapping("/hanzhuang/bound")
private Return hanZhuangBound(@RequestBody JSONObject json) { private Return hanZhuangBound(@RequestBody JSONObject json) {
log.info(json.toJSONString());
ParamAssert.notNull(json.get("vehicleNo"),"param is null"); ParamAssert.notNull(json.get("vehicleNo"),"param is null");
ParamAssert.notNull(json.get("busNo"),"param is null"); ParamAssert.notNull(json.get("busNo"),"param is null");
return Return.success(); return Return.success();
...@@ -33,6 +34,7 @@ public class PDAController { ...@@ -33,6 +34,7 @@ public class PDAController {
@PostMapping("/change/skid") @PostMapping("/change/skid")
private Return changeSkid(@RequestBody JSONObject json) { private Return changeSkid(@RequestBody JSONObject json) {
log.info(json.toJSONString());
ParamAssert.notNull(json.get("sourceStation"),"param is null"); ParamAssert.notNull(json.get("sourceStation"),"param is null");
ParamAssert.notNull(json.get("sourceStation"),"param is null"); ParamAssert.notNull(json.get("sourceStation"),"param is null");
return Return.success(); return Return.success();
...@@ -42,6 +44,7 @@ public class PDAController { ...@@ -42,6 +44,7 @@ public class PDAController {
@PostMapping("/repair") @PostMapping("/repair")
private Return repair(@RequestBody JSONObject json) { private Return repair(@RequestBody JSONObject json) {
log.info(json.toJSONString());
ParamAssert.notNull(json.get("busNo"),"param is null"); ParamAssert.notNull(json.get("busNo"),"param is null");
return Return.success(); return Return.success();
} }
......
package net.vtstar.zhongtong.avi.monitoring.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Table;
@Data
@ApiModel("滑撬")
@Table(name = "skid")
public class Skid {
@Column(name = "id")
private Long id;
@Column(name = "rfid")
@ApiModelProperty(notes = "滑撬rfid")
private String rfid;
@Column(name = "State")
@ApiModelProperty(notes = "状态:1上车 0下车")
private Integer State;
@ApiModelProperty(notes = "绑定车身号")
private String busNo;
}
...@@ -10,7 +10,16 @@ public class Vehicle { ...@@ -10,7 +10,16 @@ public class Vehicle {
private Long id; private Long id;
@ApiModelProperty(notes = "平移车编号") @ApiModelProperty(notes = "别名(平移车号)")
private String alias;
@ApiModelProperty(notes = "所属平移车道(从东向西(1,2,3,4))")
private Integer lane;
@ApiModelProperty(notes = " 转动:正转(true),反转(false)")
private Boolean turn;
@ApiModelProperty(notes = "rfid信息")
private String code; private String code;
@ApiModelProperty(notes = "左侧有无车信号") @ApiModelProperty(notes = "左侧有无车信号")
...@@ -24,4 +33,10 @@ public class Vehicle { ...@@ -24,4 +33,10 @@ public class Vehicle {
@ApiModelProperty(notes = "当前右侧所在车道") @ApiModelProperty(notes = "当前右侧所在车道")
private String rightLane; private String rightLane;
@ApiModelProperty(notes = "Rfid上下车信号,上车 1, 下车0")
private Boolean state;
@ApiModelProperty(notes = "当前绑定滑撬")
private String currentRfid;
} }
package net.vtstar.zhongtong.avi.monitoring.job; package net.vtstar.zhongtong.avi.monitoring.job;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.vtstar.protocol.modbus.tcp.netty.packet.AbstractModbusResponse;
import net.vtstar.protocol.modbus.tcp.netty.packet.ReadCoilsResponse; import net.vtstar.protocol.modbus.tcp.netty.packet.ReadCoilsResponse;
import net.vtstar.protocol.modbus.tcp.netty.packet.ReadMultipleRegistersResponse; import net.vtstar.protocol.modbus.tcp.netty.packet.ReadMultipleRegistersResponse;
import net.vtstar.protocol.modbus.tcp.netty.utils.NettyUtils; import net.vtstar.protocol.modbus.tcp.netty.utils.NettyUtils;
...@@ -54,6 +55,9 @@ public class AVIMonitorJob extends GatherJob { ...@@ -54,6 +55,9 @@ public class AVIMonitorJob extends GatherJob {
if (CollectionUtils.isEmpty(equipInfoList)) { if (CollectionUtils.isEmpty(equipInfoList)) {
return; return;
} }
Map<String, PaintshopStation> stationMap = hashOperations.entries("station");
Map<String, Vehicle> vehicleMap = hashOperations.entries("vehicle_signal");
equipInfoList.forEach(equipInfo -> { equipInfoList.forEach(equipInfo -> {
List<EquipCommunication> commList = equipInfoService.getCommunicationList(equipInfo.getEquipCode(), 1); List<EquipCommunication> commList = equipInfoService.getCommunicationList(equipInfo.getEquipCode(), 1);
if (CollectionUtils.isEmpty(commList)) { if (CollectionUtils.isEmpty(commList)) {
...@@ -83,10 +87,22 @@ public class AVIMonitorJob extends GatherJob { ...@@ -83,10 +87,22 @@ public class AVIMonitorJob extends GatherJob {
Integer endAddress = itemList.get(itemList.size() - 1).getAddress(); Integer endAddress = itemList.get(itemList.size() - 1).getAddress();
Integer quantity = itemList.get(itemList.size() - 1).getLength(); Integer quantity = itemList.get(itemList.size() - 1).getLength();
Integer count = endAddress + quantity - startAddress; Integer count = endAddress + quantity - startAddress;
if (1 == startTemplate.getFunctionCode()) { AbstractModbusResponse response = null;
try { try {
ReadCoilsResponse response = modbusService.readCoilRegister(slaveId, poolKey, startAddress, count); if (1 == startTemplate.getFunctionCode()) {
Map<String, PaintshopStation> stationMap = stationCache.get("station", HashMap.class); response = modbusService.readCoilRegister(slaveId, poolKey, startAddress, count);
} else if (2 == startTemplate.getFunctionCode()) {
response = modbusService.readInputDiscretes(slaveId, poolKey, startAddress, count);
} else if (3 == startTemplate.getFunctionCode()) {
response = modbusService.readMultipleRegister(slaveId, poolKey, startAddress, count);
} else if (4 == startTemplate.getFunctionCode()) {
response = modbusService.readInputRegister(slaveId, poolKey, startAddress, count);
}
} catch (Exception e) {
log.info("读取失败。ip{},端口{},slave{},start{}", poolKey.getHost(), poolKey.getPort(), slaveId, startAddress);
continue;
}
for (EquipDataTemplateItem item : itemList) { for (EquipDataTemplateItem item : itemList) {
String fieldName = item.getFieldName(); String fieldName = item.getFieldName();
if (fieldName.startsWith("stationState")) { if (fieldName.startsWith("stationState")) {
...@@ -95,41 +111,24 @@ public class AVIMonitorJob extends GatherJob { ...@@ -95,41 +111,24 @@ public class AVIMonitorJob extends GatherJob {
byte state = response.getBody().readByte(); byte state = response.getBody().readByte();
station.setOldState(station.getState()); station.setOldState(station.getState());
station.setState(state == 0 ? StationState.FREE : StationState.USE); station.setState(state == 0 ? StationState.FREE : StationState.USE);
stationMap.put(stationCode, station); // stationMap.put(stationCode, station);
} }
if (fieldName.startsWith("vehicle_signal")) { if (fieldName.startsWith("station_vehicle_signal")) {
String[] split = fieldName.split("_"); String[] split = fieldName.split("_");
String vehicleCode = split[3]; String stationCode = split[3];
Map<String, Vehicle> map = hashOperations.entries("vehicle_signal"); PaintshopStation station = stationMap.get(stationCode);
Vehicle vehicle = map.get(vehicleCode);
byte state = response.getBody().readByte(); byte state = response.getBody().readByte();
if (split[2].equals("left")) { station.setArrive(state == 1 ? true : false);
vehicle.setLeftSignal(state == 0 ? true : false);
}
if (split[2].equals("right")) {
vehicle.setRightSignal(state == 0 ? true : false);
}
}
}
stationCache.put("station", stationMap);
} catch (Exception e) {
log.info("读取失败。ip{},端口{},slave{},start{}", poolKey.getHost(), poolKey.getPort(), slaveId, startAddress);
}
}
if (3 == startTemplate.getFunctionCode()) {
try {
ReadMultipleRegistersResponse response = modbusService.readMultipleRegister(slaveId, poolKey, startAddress, count);
} catch (Exception e) {
log.info("读取失败。ip{},端口{},slave{},start{}", poolKey.getHost(), poolKey.getPort(), slaveId, startAddress);
} }
} }
} }
} }
}); });
// stationCache.put("station", stationMap);
// hashOperations.putAll("station", stationMap);
} }
public Object handleValue(String fieldName, Object value) { public Object handleValue(String fieldName, Object value) {
if (fieldName.startsWith("stationState")) { if (fieldName.startsWith("stationState")) {
String stationCode = fieldName.split("_")[1]; String stationCode = fieldName.split("_")[1];
......
package net.vtstar.zhongtong.avi.monitoring.mapper;
import net.vtstar.user.mybatis.BaseMapper;
import net.vtstar.zhongtong.avi.monitoring.domain.Skid;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SkidMapper extends BaseMapper<Skid> {
}
...@@ -8,14 +8,19 @@ import net.vtstar.zhongtong.avi.equipment.domain.PaintshopArea; ...@@ -8,14 +8,19 @@ import net.vtstar.zhongtong.avi.equipment.domain.PaintshopArea;
import net.vtstar.zhongtong.avi.equipment.domain.PaintshopLane; import net.vtstar.zhongtong.avi.equipment.domain.PaintshopLane;
import net.vtstar.zhongtong.avi.equipment.domain.PaintshopStation; import net.vtstar.zhongtong.avi.equipment.domain.PaintshopStation;
import net.vtstar.zhongtong.avi.equipment.mapper.PaintshopStationMapper; import net.vtstar.zhongtong.avi.equipment.mapper.PaintshopStationMapper;
import net.vtstar.zhongtong.avi.monitoring.domain.Skid;
import net.vtstar.zhongtong.avi.monitoring.mapper.SkidMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.cache.Cache; import org.springframework.cache.Cache;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j @Slf4j
@Order(value = 1) @Order(value = 1)
...@@ -28,6 +33,12 @@ public class ReadStationToCacheRunner implements CommandLineRunner { ...@@ -28,6 +33,12 @@ public class ReadStationToCacheRunner implements CommandLineRunner {
private SearchService searchService; private SearchService searchService;
@Autowired @Autowired
private PaintshopStationMapper stationMapper; private PaintshopStationMapper stationMapper;
@Autowired
private SkidMapper skidMapper;
// @Resource(name = "redisTemplate")
// protected HashOperations hashOperations;
@Override @Override
public void run(String... args) throws Exception { public void run(String... args) throws Exception {
...@@ -38,11 +49,16 @@ public class ReadStationToCacheRunner implements CommandLineRunner { ...@@ -38,11 +49,16 @@ public class ReadStationToCacheRunner implements CommandLineRunner {
addOrderBy(PaintshopStation.class, "sequence", OrderBy.ASC); addOrderBy(PaintshopStation.class, "sequence", OrderBy.ASC);
}}, PaintshopStation.class); }}, PaintshopStation.class);
//
// Map<String, Skid> skidMap = hashOperations.entries("skid");
// if (null == skidMap) {
// List<Skid> skids = skidMapper.findList(null, Skid.class);
// Map<String, Skid> skid = skids.stream().collect(Collectors.toMap(Skid::getRfid, s -> s, (k1, k2) -> k1));
// hashOperations.putAll("skid", skid);
// }
for (PaintshopStation station : stations) { for (PaintshopStation station : stations) {
stationCache.put(station.getCode(),station); stationCache.put(station.getCode(), station);
} }
} }
} }
...@@ -2,6 +2,9 @@ package net.vtstar.zhongtong.avi.mqtt.handle; ...@@ -2,6 +2,9 @@ package net.vtstar.zhongtong.avi.mqtt.handle;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.vtstar.scada.base.mqtt.utils.MqttConstants; import net.vtstar.scada.base.mqtt.utils.MqttConstants;
import net.vtstar.zhongtong.avi.monitoring.domain.Skid;
import net.vtstar.zhongtong.avi.monitoring.domain.Vehicle;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.ListOperations; import org.springframework.data.redis.core.ListOperations;
import org.springframework.data.redis.core.ValueOperations; import org.springframework.data.redis.core.ValueOperations;
import org.springframework.messaging.Message; import org.springframework.messaging.Message;
...@@ -10,6 +13,7 @@ import org.springframework.messaging.MessagingException; ...@@ -10,6 +13,7 @@ import org.springframework.messaging.MessagingException;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Map;
@Slf4j @Slf4j
@Component @Component
...@@ -18,6 +22,8 @@ public class RfidMessageHandler extends AbstractTesterMessageHandler { ...@@ -18,6 +22,8 @@ public class RfidMessageHandler extends AbstractTesterMessageHandler {
@Resource(name = "redisTemplate") @Resource(name = "redisTemplate")
private ListOperations listOperations; private ListOperations listOperations;
@Resource(name = "redisTemplate") @Resource(name = "redisTemplate")
private HashOperations hashOperations;
@Resource(name = "redisTemplate")
private ValueOperations valueOperations; private ValueOperations valueOperations;
public RfidMessageHandler() { public RfidMessageHandler() {
...@@ -26,24 +32,15 @@ public class RfidMessageHandler extends AbstractTesterMessageHandler { ...@@ -26,24 +32,15 @@ public class RfidMessageHandler extends AbstractTesterMessageHandler {
@Override @Override
public void handleMessage(Message<?> message) throws MessagingException { public void handleMessage(Message<?> message) throws MessagingException {
String payload = (String) message.getPayload(); Skid skid = (Skid) message.getPayload();
System.out.println(payload); System.out.println(skid);
MessageHeaders headers = message.getHeaders(); MessageHeaders headers = message.getHeaders();
String equipmentNumber = headers.get(MqttConstants.MSG_HEADER_KEY_EQUIPMENTNUMBER, String.class); String code = headers.get(MqttConstants.MSG_HEADER_KEY_EQUIPMENTNUMBER, String.class);
/*try { Map<String, Vehicle> vehicleMap = hashOperations.entries("vehicle");
ChipCheckData data = new ChipCheckData();
data.setEquipCode(equipmentNumber);
data.setFangzuyi(new BigDecimal(payload).setScale(3, RoundingMode.HALF_UP));
data.setBeginTime(new Date());
log.info("方阻仪:" + data.getFangzuyi());
BaseKey baseKey = new BaseKey(ChipEquipType.FANGZUYI.getValue(), equipmentNumber);
listOperations.rightPush(baseKey.listKey(), data);
valueOperations.set(baseKey.lastKey(), data); Vehicle vehicle = vehicleMap.get(code);
} catch (Exception e) { vehicle.setState(skid.getState() == 1 ? true : false);
log.error("handleMessage error:", e); vehicle.setCurrentRfid(skid.getRfid());
}*/ valueOperations.set(code,vehicle);
} }
} }
...@@ -8,7 +8,7 @@ spring.profiles.include=mybatis,quartz,swagger,security,mqtt,ztip ...@@ -8,7 +8,7 @@ spring.profiles.include=mybatis,quartz,swagger,security,mqtt,ztip
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/zhongtong_dev?useSSL=false&useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai spring.datasource.url=jdbc:mysql://localhost:3306/zhongtong_dev?useSSL=false&useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
spring.datasource.username=root spring.datasource.username =root
spring.datasource.password=123456 spring.datasource.password=123456
# sql server(试交车间--检测线192.168.1.200) # sql server(试交车间--检测线192.168.1.200)
......
...@@ -31,7 +31,7 @@ quartz.job.taskInfos[1].jobGroup=CleanStatusDataJob ...@@ -31,7 +31,7 @@ quartz.job.taskInfos[1].jobGroup=CleanStatusDataJob
quartz.job.taskInfos[1].jobDescription=\u6E05\u6D17\u8BBE\u5907\u72B6\u6001Job quartz.job.taskInfos[1].jobDescription=\u6E05\u6D17\u8BBE\u5907\u72B6\u6001Job
#quartz.job.taskInfos[1].cronExpression=0 0 0 * * ? #quartz.job.taskInfos[1].cronExpression=0 0 0 * * ?
quartz.job.taskInfos[1].cronExpression=0/10 * * * * ? quartz.job.taskInfos[1].cronExpression=0/10 * * * * ?
quartz.job.taskInfos[1].start=true quartz.job.taskInfos[1].start=false
quartz.job.taskInfos[2].jobName=net.vtstar.zhongtong.avi.equipment.job.StatisticsTimeJob quartz.job.taskInfos[2].jobName=net.vtstar.zhongtong.avi.equipment.job.StatisticsTimeJob
quartz.job.taskInfos[2].jobGroup=StatisticsTimeJob quartz.job.taskInfos[2].jobGroup=StatisticsTimeJob
...@@ -192,6 +192,14 @@ quartz.job.taskInfos[20].jobDescription=\u5145\u7535\u6869Job ...@@ -192,6 +192,14 @@ quartz.job.taskInfos[20].jobDescription=\u5145\u7535\u6869Job
quartz.job.taskInfos[20].cronExpression=0 0/15 * * * ? quartz.job.taskInfos[20].cronExpression=0 0/15 * * * ?
quartz.job.taskInfos[20].start=false quartz.job.taskInfos[20].start=false
#AVI plc 采集
quartz.job.taskInfos[24].jobName=net.vtstar.zhongtong.avi.monitoring.job.AVIMonitorJob
quartz.job.taskInfos[24].jobGroup=AVIMonitorJob
quartz.job.taskInfos[24].jobDescription=\u76d1\u63a7\u0041\u0056\u0049Job
quartz.job.taskInfos[24].cronExpression=0/10 * * * * ?
quartz.job.taskInfos[24].start=false
#quartz.job.taskInfos[8].jobName=net.vtstar.scada.base.equipmgt.job.CleanEquipStatusJob #quartz.job.taskInfos[8].jobName=net.vtstar.scada.base.equipmgt.job.CleanEquipStatusJob
##quartz.job.taskInfos[8].jobGroup=CleanEquipStatusJob ##quartz.job.taskInfos[8].jobGroup=CleanEquipStatusJob
##quartz.job.taskInfos[8].jobDescription=\u6E05\u6D17\u8BBE\u5907\u72B6\u6001Job ##quartz.job.taskInfos[8].jobDescription=\u6E05\u6D17\u8BBE\u5907\u72B6\u6001Job
......
...@@ -22,7 +22,7 @@ zt.ip.wheelalignment2=10.1.25.86 ...@@ -22,7 +22,7 @@ zt.ip.wheelalignment2=10.1.25.86
#底盘车间--四轮定位3 #底盘车间--四轮定位3
zt.ip.wheelalignment3=10.1.25.87 zt.ip.wheelalignment3=10.1.25.87
#试交车间--检测线 #试交车间]====================--检测线
zt.ip.testlineresult=10.100.172.150 zt.ip.testlineresult=10.100.172.150
#试交车间--限速值 #试交车间--限速值
zt.ip.testspeedresult=10.1.25.134 zt.ip.testspeedresult=10.1.25.134
......
...@@ -9,7 +9,7 @@ spring.aop.auto=true ...@@ -9,7 +9,7 @@ spring.aop.auto=true
spring.main.allow-bean-definition-overriding=true spring.main.allow-bean-definition-overriding=true
# server # server
server.port=8086 server.port=8080
spring.servlet.multipart.max-file-size=1000MB spring.servlet.multipart.max-file-size=1000MB
spring.servlet.multipart.max-request-size=2000MB spring.servlet.multipart.max-request-size=2000MB
spring.servlet.multipart.enabled=true spring.servlet.multipart.enabled=true
......
package net.vtstar.zhongtong.avi;
import io.netty.buffer.ByteBuf;
import lombok.extern.slf4j.Slf4j;
import net.vtstar.protocol.modbus.tcp.netty.packet.ReadCoilsRequest;
import net.vtstar.protocol.modbus.tcp.netty.packet.ReadCoilsResponse;
import net.vtstar.protocol.modbus.tcp.netty.service.ModbusTemplate;
import net.vtstar.protocol.modbus.tcp.netty.utils.PoolKey;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class)
@ActiveProfiles("dev-yxh")
public class ModbusTest {
@Autowired
private ModbusTemplate modbusTemplate;
@Test
public void test() throws Exception {
ReadCoilsRequest readCoilsRequest = new ReadCoilsRequest(1,0,5);
PoolKey poolKey = new PoolKey("localhost",502);
ReadCoilsResponse response= modbusTemplate.execute(poolKey, readCoilsRequest, ReadCoilsResponse.class);
ByteBuf body = response.getBody();
byte b = body.readByte();
System.out.println("___" + b);
// byte[] array = body.array();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment