修复bug
This commit is contained in:
parent
de9bc54ac4
commit
188c186bbc
@ -230,3 +230,7 @@ knife4j:
|
|||||||
yudao:
|
yudao:
|
||||||
info:
|
info:
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
|
|
||||||
|
spring:
|
||||||
|
codec:
|
||||||
|
max-in-memory-size: 20MB
|
||||||
|
@ -36,6 +36,7 @@ public class WareHouseLocationSaveReqVO {
|
|||||||
private String locationYaw;
|
private String locationYaw;
|
||||||
|
|
||||||
@Schema(description = "物料信息")
|
@Schema(description = "物料信息")
|
||||||
|
@Size(min = 0,max = 100 ,message = "物料信息长度超过限制")
|
||||||
private String skuInfo;
|
private String skuInfo;
|
||||||
|
|
||||||
@Schema(description = "物料批次号")
|
@Schema(description = "物料批次号")
|
||||||
|
@ -131,4 +131,13 @@ public class DeviceInformationController {
|
|||||||
List<DeviceInformationRespVO> list = informationService.getInformationList(pageReqVO);
|
List<DeviceInformationRespVO> list = informationService.getInformationList(pageReqVO);
|
||||||
return success(BeanUtils.toBean(list, DeviceInformationRespVO.class));
|
return success(BeanUtils.toBean(list, DeviceInformationRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/getMapImageUrl")
|
||||||
|
@Operation(summary = "获得设备图标URL")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('device:information:getMapImageUrl')")
|
||||||
|
public CommonResult<String> getMapImageUrl(@RequestParam("deviceType") Integer deviceType) {
|
||||||
|
String str = informationService.getMapImageUrl(deviceType);
|
||||||
|
return success(str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,4 +24,24 @@ public enum DeviceTypeEnum {
|
|||||||
* 说明
|
* 说明
|
||||||
*/
|
*/
|
||||||
private final String msg;
|
private final String msg;
|
||||||
|
|
||||||
|
public static Integer getConfigType (Integer type) {
|
||||||
|
if (CHARGING_STATION.type.equals(type)) {
|
||||||
|
return 5;
|
||||||
|
}if (CONVEYOR_LINE.type.equals(type)) {
|
||||||
|
return 6;
|
||||||
|
}if (PALLETIZER.type.equals(type)) {
|
||||||
|
return 7;
|
||||||
|
}if (AUTOMATIC_DOOR.type.equals(type)) {
|
||||||
|
return 8;
|
||||||
|
}if (HOIST.type.equals(type)) {
|
||||||
|
return 9;
|
||||||
|
}if (SIGNAL_LIGHT.type.equals(type)) {
|
||||||
|
return 10;
|
||||||
|
}if (BUTTON_BOX.type.equals(type)) {
|
||||||
|
return 11;
|
||||||
|
}else {
|
||||||
|
return 12;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ public class HouseLocationServiceImpl extends ServiceImpl<WareHouseLocationMappe
|
|||||||
public void updateHouseLocation(WareHouseLocationSaveReqVO updateReqVO) {
|
public void updateHouseLocation(WareHouseLocationSaveReqVO updateReqVO) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
validateHouseLocationExists(updateReqVO.getId());
|
validateHouseLocationExists(updateReqVO.getId());
|
||||||
String str = "";
|
String str = "修改库位信息 ";
|
||||||
WareHouseLocationDO wareHouseLocationDO = houseLocationMapper.selectById(updateReqVO.getId());
|
WareHouseLocationDO wareHouseLocationDO = houseLocationMapper.selectById(updateReqVO.getId());
|
||||||
if (!wareHouseLocationDO.getLocationEnable().equals(updateReqVO.getLocationEnable())) {
|
if (!wareHouseLocationDO.getLocationEnable().equals(updateReqVO.getLocationEnable())) {
|
||||||
if (LocationEnableEnum.YES.getType().equals(updateReqVO.getLocationEnable())) {
|
if (LocationEnableEnum.YES.getType().equals(updateReqVO.getLocationEnable())) {
|
||||||
|
@ -130,4 +130,11 @@ public interface DeviceInformationService extends IService<DeviceInformationDO>
|
|||||||
* @param deviceNo
|
* @param deviceNo
|
||||||
*/
|
*/
|
||||||
void chargeDeviceShrink(String deviceNo);
|
void chargeDeviceShrink(String deviceNo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取图标URL
|
||||||
|
* @param deviceType
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String getMapImageUrl(Integer deviceType);
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import cn.iocoder.yudao.module.system.controller.admin.information.vo.DeviceInfo
|
|||||||
import cn.iocoder.yudao.module.system.controller.admin.information.vo.DeviceInformationRespVO;
|
import cn.iocoder.yudao.module.system.controller.admin.information.vo.DeviceInformationRespVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.information.vo.DeviceInformationSaveReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.information.vo.DeviceInformationSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.log.vo.UserOperationLogSaveReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.log.vo.UserOperationLogSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.config.CommonConfigDO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.information.DeviceInformationDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.information.DeviceInformationDO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionMapDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionMapDO;
|
||||||
@ -22,6 +23,7 @@ import cn.iocoder.yudao.module.system.enums.device.DeviceAttributeEnum;
|
|||||||
import cn.iocoder.yudao.module.system.enums.device.DeviceStatusEnum;
|
import cn.iocoder.yudao.module.system.enums.device.DeviceStatusEnum;
|
||||||
import cn.iocoder.yudao.module.system.enums.device.DeviceTypeEnum;
|
import cn.iocoder.yudao.module.system.enums.device.DeviceTypeEnum;
|
||||||
import cn.iocoder.yudao.module.system.enums.device.PictureConfigEnum;
|
import cn.iocoder.yudao.module.system.enums.device.PictureConfigEnum;
|
||||||
|
import cn.iocoder.yudao.module.system.service.config.CommonConfigService;
|
||||||
import cn.iocoder.yudao.module.system.service.dict.DictDataService;
|
import cn.iocoder.yudao.module.system.service.dict.DictDataService;
|
||||||
import cn.iocoder.yudao.module.system.service.log.UserOperationLogService;
|
import cn.iocoder.yudao.module.system.service.log.UserOperationLogService;
|
||||||
import cn.iocoder.yudao.module.system.service.robot.RobotWarnMsgService;
|
import cn.iocoder.yudao.module.system.service.robot.RobotWarnMsgService;
|
||||||
@ -78,6 +80,9 @@ public class DeviceInformationServiceImpl extends ServiceImpl<DeviceInformationM
|
|||||||
@Resource
|
@Resource
|
||||||
private RobotWarnMsgService warnMsgService;
|
private RobotWarnMsgService warnMsgService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CommonConfigService configService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createInformation(DeviceInformationSaveReqVO createReqVO) {
|
public Long createInformation(DeviceInformationSaveReqVO createReqVO) {
|
||||||
// -- 先判断库里是否有相通的mac地址数据
|
// -- 先判断库里是否有相通的mac地址数据
|
||||||
@ -384,17 +389,35 @@ public class DeviceInformationServiceImpl extends ServiceImpl<DeviceInformationM
|
|||||||
shrink(deviceInformationDO.getDeviceIp(), Integer.parseInt(deviceInformationDO.getDevicePort()), deviceNo);
|
shrink(deviceInformationDO.getDeviceIp(), Integer.parseInt(deviceInformationDO.getDevicePort()), deviceNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMapImageUrl(Integer deviceType) {
|
||||||
|
Integer configType = DeviceTypeEnum.getConfigType(deviceType);
|
||||||
|
if (ObjectUtil.isEmpty(configType)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
CommonConfigDO config = configService.getConfig(configType.longValue());
|
||||||
|
if (ObjectUtil.isEmpty(config)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return config.getConfigStr();
|
||||||
|
}
|
||||||
|
|
||||||
public void shrink(String ip, int port, String deviceNo) {
|
public void shrink(String ip, int port, String deviceNo) {
|
||||||
boolean success = true;
|
boolean success = true;
|
||||||
short[] shrinkArr = {0};
|
short[] shrinkArr = {0};
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
|
ModbusMaster asciiMaster = null;
|
||||||
try {
|
try {
|
||||||
ModbusMaster asciiMaster = ModbusUtils.getMaster(ip, port);
|
asciiMaster = ModbusUtils.getMaster(ip, port);
|
||||||
ModbusUtils.writeHoldingRegisters(asciiMaster, 1, 0, shrinkArr);
|
ModbusUtils.writeHoldingRegisters(asciiMaster, 1, 0, shrinkArr);
|
||||||
} catch (ModbusInitException | ModbusTransportException e) {
|
} catch (ModbusInitException | ModbusTransportException e) {
|
||||||
log.info("充电设备缩回时,出现异常 :{}", ip);
|
log.info("充电设备缩回时,出现异常 :{}", ip);
|
||||||
warnMsgService.addWarnMsg(deviceNo + " 充电设备缩回失败");
|
warnMsgService.addWarnMsg(deviceNo + " 充电设备缩回失败");
|
||||||
success = false;
|
success = false;
|
||||||
|
}finally {
|
||||||
|
if (ObjectUtil.isNotEmpty(asciiMaster)) {
|
||||||
|
asciiMaster.destroy();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
@ -413,8 +436,9 @@ public class DeviceInformationServiceImpl extends ServiceImpl<DeviceInformationM
|
|||||||
short[] extendArr = {1};
|
short[] extendArr = {1};
|
||||||
short[] shrinkArr = {0};
|
short[] shrinkArr = {0};
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
|
ModbusMaster asciiMaster = null;
|
||||||
try {
|
try {
|
||||||
ModbusMaster asciiMaster = ModbusUtils.getMaster(ip, port);
|
asciiMaster = ModbusUtils.getMaster(ip, port);
|
||||||
ModbusUtils.writeHoldingRegisters(asciiMaster, 1, 0, shrinkArr);
|
ModbusUtils.writeHoldingRegisters(asciiMaster, 1, 0, shrinkArr);
|
||||||
Thread.sleep(2500);
|
Thread.sleep(2500);
|
||||||
ModbusUtils.writeHoldingRegisters(asciiMaster, 1, 0, extendArr);
|
ModbusUtils.writeHoldingRegisters(asciiMaster, 1, 0, extendArr);
|
||||||
@ -422,6 +446,10 @@ public class DeviceInformationServiceImpl extends ServiceImpl<DeviceInformationM
|
|||||||
log.info("充电设备伸出时,出现异常 :{}", ip);
|
log.info("充电设备伸出时,出现异常 :{}", ip);
|
||||||
warnMsgService.addWarnMsg(deviceNo + " 充电设备伸出失败");
|
warnMsgService.addWarnMsg(deviceNo + " 充电设备伸出失败");
|
||||||
success = false;
|
success = false;
|
||||||
|
}finally {
|
||||||
|
if (ObjectUtil.isNotEmpty(asciiMaster)) {
|
||||||
|
asciiMaster.destroy();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
|
@ -18,13 +18,13 @@ public class ModbusUtils {
|
|||||||
/**
|
/**
|
||||||
* 工厂。
|
* 工厂。
|
||||||
*/
|
*/
|
||||||
static ModbusFactory modbusFactory;
|
/*static ModbusFactory modbusFactory;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
if (modbusFactory == null) {
|
if (modbusFactory == null) {
|
||||||
modbusFactory = new ModbusFactory();
|
modbusFactory = new ModbusFactory();
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取master
|
* 获取master
|
||||||
@ -40,13 +40,14 @@ public class ModbusUtils {
|
|||||||
// modbusFactory.createRtuMaster(wapper); //RTU 协议
|
// modbusFactory.createRtuMaster(wapper); //RTU 协议
|
||||||
// modbusFactory.createUdpMaster(params);//UDP 协议
|
// modbusFactory.createUdpMaster(params);//UDP 协议
|
||||||
// modbusFactory.createAsciiMaster(wrapper);//ASCII 协议
|
// modbusFactory.createAsciiMaster(wrapper);//ASCII 协议
|
||||||
|
ModbusFactory modbusFactory = new ModbusFactory();
|
||||||
ModbusMaster master = modbusFactory.createTcpMaster(params, false);// TCP 协议
|
ModbusMaster master = modbusFactory.createTcpMaster(params, false);// TCP 协议
|
||||||
master.init();
|
master.init();
|
||||||
|
|
||||||
return master;
|
return master;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ModbusMaster getRtuIpMaster(String host, int port) throws ModbusInitException {
|
public static ModbusMaster getRtuIpMaster(ModbusFactory modbusFactory, String host, int port) throws ModbusInitException {
|
||||||
IpParameters params = new IpParameters();
|
IpParameters params = new IpParameters();
|
||||||
params.setHost(host);
|
params.setHost(host);
|
||||||
params.setPort(port);
|
params.setPort(port);
|
||||||
@ -75,7 +76,8 @@ public class ModbusUtils {
|
|||||||
* @return
|
* @return
|
||||||
* @throws ModbusInitException
|
* @throws ModbusInitException
|
||||||
*/
|
*/
|
||||||
public static ModbusMaster getSerialPortRtuMaster(String portName, Integer baudRate, Integer dataBits,
|
public static ModbusMaster getSerialPortRtuMaster(ModbusFactory modbusFactory,String portName, Integer baudRate,
|
||||||
|
Integer dataBits,
|
||||||
Integer stopBits, Integer parity){
|
Integer stopBits, Integer parity){
|
||||||
// 设置串口参数,串口是COM1,波特率是9600
|
// 设置串口参数,串口是COM1,波特率是9600
|
||||||
// SerialPortWrapperImpl wrapper = new SerialPortWrapperImpl("COM2", 9600,SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE, 0, 0);
|
// SerialPortWrapperImpl wrapper = new SerialPortWrapperImpl("COM2", 9600,SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE, 0, 0);
|
||||||
@ -106,7 +108,7 @@ public class ModbusUtils {
|
|||||||
* @throws ModbusInitException
|
* @throws ModbusInitException
|
||||||
*/
|
*/
|
||||||
public static ModbusMaster getSerialPortAsciiMaster(String portName, Integer baudRate, Integer dataBits,
|
public static ModbusMaster getSerialPortAsciiMaster(String portName, Integer baudRate, Integer dataBits,
|
||||||
Integer stopBits, Integer parity){
|
Integer stopBits, Integer parity,ModbusFactory modbusFactory){
|
||||||
// 设置串口参数,串口是COM1,波特率是9600
|
// 设置串口参数,串口是COM1,波特率是9600
|
||||||
// SerialPortWrapperImpl wrapper = new SerialPortWrapperImpl("COM2", 9600,SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE, 0, 0);
|
// SerialPortWrapperImpl wrapper = new SerialPortWrapperImpl("COM2", 9600,SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE, 0, 0);
|
||||||
SerialPortWrapperImpl wrapper = new SerialPortWrapperImpl(portName, baudRate,
|
SerialPortWrapperImpl wrapper = new SerialPortWrapperImpl(portName, baudRate,
|
||||||
|
Loading…
Reference in New Issue
Block a user