近电感应配置
This commit is contained in:
parent
40e6661688
commit
648af003aa
|
|
@ -0,0 +1,27 @@
|
|||
package com.bonus.system.api;
|
||||
|
||||
import com.bonus.common.core.constant.SecurityConstants;
|
||||
import com.bonus.common.core.constant.ServiceNameConstants;
|
||||
import com.bonus.common.core.domain.R;
|
||||
import com.bonus.system.api.domain.SysFile;
|
||||
import com.bonus.system.api.domain.SysTcpMessage;
|
||||
import com.bonus.system.api.factory.RemoteFileFallbackFactory;
|
||||
import com.bonus.system.api.factory.RemoteTcpFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* TCP服务
|
||||
*
|
||||
* @author bonus
|
||||
*/
|
||||
@FeignClient(contextId = "RemoteTcpService", value = ServiceNameConstants.TCP_SERVICE, fallbackFactory = RemoteTcpFallbackFactory.class)
|
||||
public interface RemoteTcpService {
|
||||
|
||||
@GetMapping(value = "/netty/setMessage")
|
||||
public R setMessage(@RequestBody SysTcpMessage sysTcpMessage, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.bonus.system.api.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 消息通知
|
||||
*/
|
||||
@Data
|
||||
public class SysTcpMessage {
|
||||
|
||||
private String devCode;
|
||||
|
||||
private float distance;
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package com.bonus.system.api.factory;
|
||||
|
||||
import com.bonus.common.core.domain.R;
|
||||
import com.bonus.system.api.RemoteTcpService;
|
||||
import com.bonus.system.api.domain.SysTcpMessage;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* tcp服务降级处理
|
||||
*
|
||||
* @author bonus
|
||||
*/
|
||||
@Component
|
||||
public class RemoteTcpFallbackFactory implements FallbackFactory<RemoteTcpService> {
|
||||
private static final Logger log = LoggerFactory.getLogger(RemoteTcpFallbackFactory.class);
|
||||
|
||||
@Override
|
||||
public RemoteTcpService create(Throwable throwable) {
|
||||
log.error("tcp服务调用失败:{}", throwable.getMessage());
|
||||
return new RemoteTcpService() {
|
||||
@Override
|
||||
public R setMessage(SysTcpMessage sysTcpMessage, String source) {
|
||||
return R.fail("近电感应设备设置失败:" + throwable.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -2,3 +2,4 @@ com.bonus.system.api.factory.RemoteUserFallbackFactory
|
|||
com.bonus.system.api.factory.RemoteLogFallbackFactory
|
||||
com.bonus.system.api.factory.RemoteFileFallbackFactory
|
||||
com.bonus.system.api.factory.RemoteSourceFallbackFactory
|
||||
com.bonus.system.api.factory.RemoteTcpFallbackFactory
|
||||
|
|
|
|||
|
|
@ -78,6 +78,10 @@ public class BusinessConstants {
|
|||
*/
|
||||
public final static String JD = "elec_induction";
|
||||
public final static String DL = "电量";
|
||||
/**
|
||||
* 近电感应设备电量编码
|
||||
*/
|
||||
public final static String JD_DL = "dl_code";
|
||||
|
||||
/**
|
||||
* 管理员角色
|
||||
|
|
@ -142,7 +146,7 @@ public class BusinessConstants {
|
|||
public static final String PNG = "image/png";
|
||||
public static final String JPG = "image/jpg";
|
||||
|
||||
|
||||
public final static String SET_MSG = "配置成功";
|
||||
|
||||
public final static Integer CELL_1 = 1;
|
||||
public final static Integer CELL_2 = 2;
|
||||
|
|
|
|||
|
|
@ -22,4 +22,9 @@ public class ServiceNameConstants
|
|||
*/
|
||||
public static final String FILE_SERVICE = "bonus-file";
|
||||
|
||||
/**
|
||||
* tcp服务的serviceid
|
||||
*/
|
||||
public static final String TCP_SERVICE = "bonus-tcp";
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,18 +23,19 @@ public class JdConfigVo {
|
|||
@NotNull(message = "设备ID不能为空")
|
||||
private Long devId;
|
||||
|
||||
@NotBlank(message = "设备编码不能为空")
|
||||
private String devCode;
|
||||
|
||||
@NotEmpty(message = "配置属性不能为空")
|
||||
private List<ConfigItems> configItems;
|
||||
|
||||
@Data
|
||||
public static class ConfigItems {
|
||||
/**线路属性*/
|
||||
@NotBlank(message = "线路属性不能为空", groups = {Query.class})
|
||||
private String configType;
|
||||
/**线路属性名称*/
|
||||
private String configTypeName;
|
||||
/**电压等级*/
|
||||
@NotBlank(message = "电压等级不能为空", groups = {Query.class})
|
||||
private String voltageLevel;
|
||||
/**电压等级名称*/
|
||||
private String voltageLevelName;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@ package com.bonus.app.service.impl;
|
|||
import com.bonus.app.mapper.CraneMonitorMapper;
|
||||
import com.bonus.app.service.ICraneMonitorService;
|
||||
import com.bonus.common.core.constant.BusinessConstants;
|
||||
import com.bonus.common.core.constant.HttpStatus;
|
||||
import com.bonus.common.core.constant.SecurityConstants;
|
||||
import com.bonus.common.core.domain.R;
|
||||
import com.bonus.common.core.utils.encryption.Sm4Utils;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.entity.app.AppParamsDto;
|
||||
|
|
@ -10,6 +13,8 @@ import com.bonus.common.entity.app.vo.DevInfoVo;
|
|||
import com.bonus.common.entity.app.vo.DevWarnVo;
|
||||
import com.bonus.common.entity.app.vo.JdConfigVo;
|
||||
import com.bonus.common.security.utils.ValidatorsUtils;
|
||||
import com.bonus.system.api.RemoteTcpService;
|
||||
import com.bonus.system.api.domain.SysTcpMessage;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
|
|
@ -18,10 +23,7 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @className:CraneMonitorServiceImpl
|
||||
|
|
@ -40,6 +42,9 @@ public class CraneMonitorServiceImpl implements ICraneMonitorService {
|
|||
@Resource(name = "ValidatorsUtils")
|
||||
private ValidatorsUtils validatorsUtils;
|
||||
|
||||
@Resource
|
||||
private RemoteTcpService remoteTcpService;
|
||||
|
||||
@Override
|
||||
public AjaxResult getDzWarnList(AppParamsDto dto) {
|
||||
List<DevInfoVo> list = new ArrayList<>();
|
||||
|
|
@ -105,8 +110,18 @@ public class CraneMonitorServiceImpl implements ICraneMonitorService {
|
|||
return AjaxResult.error(validResult);
|
||||
}
|
||||
}
|
||||
mapper.delJdConfig(vo);
|
||||
mapper.addJdConfigData(vo);
|
||||
SysTcpMessage sysTcpMessage = new SysTcpMessage();
|
||||
sysTcpMessage.setDevCode(vo.getDevCode());
|
||||
sysTcpMessage.setDistance(Float.parseFloat(configItems.get(0).getDistance()));
|
||||
R result = remoteTcpService.setMessage(sysTcpMessage, SecurityConstants.INNER);
|
||||
log.info("调用结果:code:{},msg:{}", result.getCode(),result.getMsg());
|
||||
if (result != null && result.getCode() == HttpStatus.SUCCESS && Objects.equals(result.getMsg(), BusinessConstants.SET_MSG)) {
|
||||
mapper.delJdConfig(vo);
|
||||
mapper.addJdConfigData(vo);
|
||||
return AjaxResult.success(result.getMsg());
|
||||
} else {
|
||||
return AjaxResult.error(result.getMsg());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,11 +6,10 @@ import com.bonus.common.core.text.Convert;
|
|||
import com.bonus.common.core.utils.ServletUtils;
|
||||
import com.bonus.common.core.web.controller.BaseController;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.core.web.page.TableDataInfo;
|
||||
import com.bonus.common.entity.app.vo.DevWarnVo;
|
||||
import com.bonus.common.entity.app.vo.JdConfigVo;
|
||||
import com.bonus.common.entity.bracelet.BraceletParamsDto;
|
||||
import com.bonus.common.entity.bracelet.vo.CheckConfigVo;
|
||||
import com.bonus.common.entity.bracelet.vo.EquipmentReqVo;
|
||||
import com.bonus.common.entity.bracelet.vo.WarnInfoVo;
|
||||
import com.bonus.common.log.annotation.SysLog;
|
||||
import com.bonus.common.log.enums.OperaType;
|
||||
|
|
@ -21,7 +20,6 @@ import org.springframework.validation.annotation.Validated;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @className:ConsControlController
|
||||
|
|
@ -184,7 +182,11 @@ public class ConsControlController extends BaseController {
|
|||
*/
|
||||
@GetMapping("getJdWarnList")
|
||||
public AjaxResult getJdWarnList(BraceletParamsDto dto){
|
||||
return service.getJdWarnList(dto);
|
||||
Integer pageNum = Convert.toInt(ServletUtils.getParameter(BusinessConstants.PAGE_NUM), 1);
|
||||
Integer pageSize = Convert.toInt(ServletUtils.getParameter(BusinessConstants.PAGE_SIZE), 10);
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
PageInfo<DevWarnVo> pageInfo = service.getJdWarnList(dto);
|
||||
return AjaxResult.success(pageInfo.getList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.bonus.bracelet.service;
|
||||
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.entity.app.vo.DevWarnVo;
|
||||
import com.bonus.common.entity.app.vo.JdConfigVo;
|
||||
import com.bonus.common.entity.bracelet.BraceletParamsDto;
|
||||
import com.bonus.common.entity.bracelet.vo.CheckConfigVo;
|
||||
|
|
@ -141,7 +142,7 @@ public interface IConsControlService {
|
|||
* @author cwchen
|
||||
* @date 2024/8/16 17:57
|
||||
*/
|
||||
AjaxResult getJdWarnList(BraceletParamsDto dto);
|
||||
PageInfo<DevWarnVo> getJdWarnList(BraceletParamsDto dto);
|
||||
|
||||
/**
|
||||
* 查询近电感应设备
|
||||
|
|
|
|||
|
|
@ -22,7 +22,9 @@ import com.bonus.common.core.utils.BuildTreeUtil;
|
|||
import com.bonus.common.entity.bracelet.vo.*;
|
||||
import com.bonus.common.security.utils.ValidatorsUtils;
|
||||
import com.bonus.system.api.RemoteFileService;
|
||||
import com.bonus.system.api.RemoteTcpService;
|
||||
import com.bonus.system.api.domain.SysFile;
|
||||
import com.bonus.system.api.domain.SysTcpMessage;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
|
|
@ -56,6 +58,9 @@ public class ConsControlServiceImpl implements IConsControlService {
|
|||
@Resource(name = "ValidatorsUtils")
|
||||
private ValidatorsUtils validatorsUtils;
|
||||
|
||||
@Resource
|
||||
private RemoteTcpService remoteTcpService;
|
||||
|
||||
@Override
|
||||
public AjaxResult getBallDeviceLists(BraceletParamsDto dto) {
|
||||
JSONArray resultTree = new JSONArray();
|
||||
|
|
@ -206,22 +211,6 @@ public class ConsControlServiceImpl implements IConsControlService {
|
|||
return AjaxResult.success(resultTree);
|
||||
}
|
||||
|
||||
public PersonTreeVo pruneTree(PersonTreeVo root) {
|
||||
if (root == null) {
|
||||
return null;
|
||||
}
|
||||
List<PersonTreeVo> nonEmptyChildren = new ArrayList<>();
|
||||
for (PersonTreeVo child : root.getChildren()) {
|
||||
PersonTreeVo prunedChild = pruneTree(child);
|
||||
if (prunedChild != null) {
|
||||
nonEmptyChildren.add(prunedChild);
|
||||
}
|
||||
}
|
||||
root.setChildren(nonEmptyChildren);
|
||||
|
||||
return root.getChildren().isEmpty() ? null : root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult getWorkInfo(BraceletParamsDto dto) {
|
||||
Map<String, Object> mapData = new HashMap<>();
|
||||
|
|
@ -537,7 +526,7 @@ public class ConsControlServiceImpl implements IConsControlService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult getJdWarnList(BraceletParamsDto dto) {
|
||||
public PageInfo<DevWarnVo> getJdWarnList(BraceletParamsDto dto) {
|
||||
List<DevWarnVo> list = new ArrayList<>();
|
||||
try {
|
||||
dto.setDevType(BusinessConstants.JD);
|
||||
|
|
@ -548,7 +537,8 @@ public class ConsControlServiceImpl implements IConsControlService {
|
|||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
return AjaxResult.success(list);
|
||||
PageInfo<DevWarnVo> pageInfo = new PageInfo<>(list);
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -558,7 +548,7 @@ public class ConsControlServiceImpl implements IConsControlService {
|
|||
dto.setDevType(BusinessConstants.JD);
|
||||
list = mapper.getJdList(dto);
|
||||
for (DevInfoVo vo : list) {
|
||||
String electricQuantity = mapper.getElectricQuantity(vo.getDevId(), BusinessConstants.DL);
|
||||
String electricQuantity = mapper.getElectricQuantity(vo.getDevId(), BusinessConstants.JD_DL);
|
||||
if (StringUtils.isNotBlank(electricQuantity) && isNumeric(electricQuantity)) {
|
||||
vo.setElectricQuantity(electricQuantity);
|
||||
} else {
|
||||
|
|
@ -591,8 +581,18 @@ public class ConsControlServiceImpl implements IConsControlService {
|
|||
return AjaxResult.error(validResult);
|
||||
}
|
||||
}
|
||||
mapper.delJdConfig(vo);
|
||||
mapper.addJdConfigData(vo);
|
||||
SysTcpMessage sysTcpMessage = new SysTcpMessage();
|
||||
sysTcpMessage.setDevCode(vo.getDevCode());
|
||||
sysTcpMessage.setDistance(Float.parseFloat(configItems.get(0).getDistance()));
|
||||
R result = remoteTcpService.setMessage(sysTcpMessage, SecurityConstants.INNER);
|
||||
log.info("调用结果:code:{},msg:{}", result.getCode(),result.getMsg());
|
||||
if (result != null && result.getCode() == HttpStatus.SUCCESS && Objects.equals(result.getMsg(), BusinessConstants.SET_MSG)) {
|
||||
mapper.delJdConfig(vo);
|
||||
mapper.addJdConfigData(vo);
|
||||
return AjaxResult.success(result.getMsg());
|
||||
} else {
|
||||
return AjaxResult.error(result.getMsg());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ public class BootNettyController {
|
|||
|
||||
@Autowired
|
||||
BootNettyServer nettyServer;
|
||||
@GetMapping("/setMessage")
|
||||
public AjaxResult setMessage(TcpMessage message) {
|
||||
@PostMapping("/setMessage")
|
||||
public AjaxResult setMessage(@RequestBody TcpMessage message) {
|
||||
try{
|
||||
Map<String,Object> map=new HashMap<>();
|
||||
if(StringUtils.isEmpty(message.getDevCode())){
|
||||
|
|
|
|||
Loading…
Reference in New Issue