设备出厂调试记录功能
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package com.njcn.csdevice.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.fallback.ProcessFeignClientFallbackFactory;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentProcessPO;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/process", fallbackFactory = ProcessFeignClientFallbackFactory.class,contextId = "process")
|
||||
|
||||
public interface ProcessFeignClient {
|
||||
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增记录")
|
||||
HttpResult<String> add(@RequestBody @Validated CsEquipmentProcessPO csEquipmentProcess);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.njcn.csdevice.api.fallback;
|
||||
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.ProcessFeignClient;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentProcessPO;
|
||||
import com.njcn.csdevice.utils.CsDeviceEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/4/10 20:09
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ProcessFeignClientFallbackFactory implements FallbackFactory<ProcessFeignClient> {
|
||||
@Override
|
||||
public ProcessFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
exceptionEnum = CsDeviceEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new ProcessFeignClient() {
|
||||
|
||||
@Override
|
||||
public HttpResult<String> add(CsEquipmentProcessPO csEquipmentProcess) {
|
||||
log.error("{}异常,降级处理,异常为:{}","新增记录",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -4,12 +4,11 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
@@ -41,13 +40,13 @@ public class CsEquipmentProcessPO {
|
||||
* 起始时间
|
||||
*/
|
||||
@TableField(value = "start_time")
|
||||
private Date startTime;
|
||||
private LocalDateTime startTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@TableField(value = "end_time")
|
||||
private Date endTime;
|
||||
private LocalDateTime endTime;
|
||||
|
||||
|
||||
/**
|
||||
@@ -55,4 +54,11 @@ public class CsEquipmentProcessPO {
|
||||
*/
|
||||
@TableField(value = "`process`")
|
||||
private Integer process;
|
||||
|
||||
/**
|
||||
* 流程状态 0:取消 1:成功
|
||||
*/
|
||||
@TableField(value = "status")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.njcn.csdevice.controller.equipment;
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentProcessPO;
|
||||
import com.njcn.csdevice.service.CsEquipmentProcessPOService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 类的介绍:设备调试日志记录
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/9/14 10:01
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/process")
|
||||
@Api(tags = "设备调试日志")
|
||||
@AllArgsConstructor
|
||||
public class CsEquipmentProcessController extends BaseController {
|
||||
|
||||
private final CsEquipmentProcessPOService csEquipmentProcessPOService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增记录")
|
||||
@ApiImplicitParam(name = "clDev", value = "逻辑子设备标识", required = true)
|
||||
public HttpResult<String> add(@RequestBody @Validated CsEquipmentProcessPO csEquipmentProcess){
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
boolean result = csEquipmentProcessPOService.save(csEquipmentProcess);
|
||||
if (result){
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "success", methodDescribe);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "fail", methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,36 +1,27 @@
|
||||
package com.njcn.csdevice.controller.equipment;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.dto.DeviceLogDTO;
|
||||
import com.njcn.common.pojo.dto.LogInfoDTO;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csdevice.pojo.param.CsMarketDataParam;
|
||||
import com.njcn.csdevice.pojo.po.CsLogsPO;
|
||||
import com.njcn.csdevice.service.impl.CsLogsPOService;
|
||||
import com.njcn.user.enums.AppRoleEnum;
|
||||
import com.njcn.csdevice.service.CsLogsPOService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2023/8/7 14:21【需求编号】
|
||||
|
||||
@@ -224,12 +224,10 @@ public class EquipmentDeliveryController extends BaseController {
|
||||
@ResponseBody
|
||||
@ApiOperation("联调完成")
|
||||
@PostMapping(value = "testcompletion")
|
||||
public HttpResult<String> testCompletion(@RequestParam("deviceId") String deviceId){
|
||||
public HttpResult<String> testCompletion(@RequestParam("deviceId") String deviceId,@RequestParam("type") String type){
|
||||
String methodDescribe = getMethodDescribe("testCompletion");
|
||||
csEquipmentDeliveryService.testCompletion(deviceId);
|
||||
|
||||
csEquipmentDeliveryService.testCompletion(deviceId,type);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,25 +4,16 @@ package com.njcn.csdevice.handler;
|
||||
import com.github.tocrhz.mqtt.annotation.MqttSubscribe;
|
||||
|
||||
import com.github.tocrhz.mqtt.annotation.Payload;
|
||||
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||
import com.njcn.common.pojo.dto.DeviceLogDTO;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.csdevice.service.impl.CsLogsPOService;
|
||||
import com.njcn.csdevice.service.CsLogsPOService;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @author xuyang
|
||||
|
||||
@@ -97,5 +97,5 @@ public interface CsEquipmentDeliveryService extends IService<CsEquipmentDelivery
|
||||
|
||||
void delete(String devId);
|
||||
|
||||
void testCompletion(String deviceId);
|
||||
void testCompletion(String deviceId,String type);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
package com.njcn.csdevice.service;
|
||||
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentProcessPO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
package com.njcn.csdevice.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.njcn.common.pojo.dto.DeviceLogDTO;
|
||||
@@ -31,7 +31,6 @@ import com.njcn.csdevice.utils.ExcelStyleUtil;
|
||||
import com.njcn.db.constant.DbConstant;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.poi.util.PoiUtil;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.api.DictTreeFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
@@ -53,6 +52,7 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -104,11 +104,16 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
csEquipmentDeliveryPo.setStatus ("1");
|
||||
csEquipmentDeliveryPo.setRunStatus(1);
|
||||
csEquipmentDeliveryPo.setProcess(1);
|
||||
|
||||
//生成二维码文件
|
||||
String qr = this.createQr(csEquipmentDeliveryAddParm.getNdid());
|
||||
csEquipmentDeliveryPo.setQrPath(qr);
|
||||
|
||||
//记录设备调试日志表
|
||||
CsEquipmentProcessPO csEquipmentProcess = new CsEquipmentProcessPO();
|
||||
csEquipmentProcess.setDevId(csEquipmentDeliveryAddParm.getNdid());
|
||||
csEquipmentProcess.setOperator(RequestUtil.getUserIndex());
|
||||
csEquipmentProcess.setStartTime(LocalDateTime.now());
|
||||
csEquipmentProcess.setProcess(1);
|
||||
csEquipmentProcessPOService.save(csEquipmentProcess);
|
||||
return this.save (csEquipmentDeliveryPo);
|
||||
}
|
||||
|
||||
@@ -421,6 +426,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
* 6.删除cs_device_user
|
||||
* */
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(String devId) {
|
||||
QueryWrapper<CsLedger> csLedgerQueryWrapper = new QueryWrapper<>();
|
||||
/**
|
||||
@@ -442,7 +448,6 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
csDeviceUserPOQueryWrapper.clear();
|
||||
csDeviceUserPOQueryWrapper.eq("device_id",devId);
|
||||
csDeviceUserPOService.remove(csDeviceUserPOQueryWrapper);
|
||||
|
||||
if (!CollectionUtils.isEmpty(collect)) {
|
||||
QueryWrapper<CsLinePO> csLinePOQueryWrapper = new QueryWrapper<>();
|
||||
csLinePOQueryWrapper.clear();
|
||||
@@ -453,25 +458,21 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
csLinePOQueryWrapper.in("line_id",collect);
|
||||
appLineTopologyDiagramService.remove(appLineTopologyDiagramPOQueryWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testCompletion(String deviceId) {
|
||||
CsEquipmentDeliveryPO byId = this.getById(deviceId);
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void testCompletion(String deviceId,String type) {
|
||||
this.lambdaUpdate().eq(CsEquipmentDeliveryPO::getId,deviceId).
|
||||
set(CsEquipmentDeliveryPO::getStatus,0).
|
||||
set(CsEquipmentDeliveryPO::getRunStatus,1).
|
||||
set(CsEquipmentDeliveryPO::getProcess,byId.getProcess()+1).update();
|
||||
set(CsEquipmentDeliveryPO::getProcess,type+1).update();
|
||||
this.delete(deviceId);
|
||||
csEquipmentProcessPOService.lambdaUpdate().eq(CsEquipmentProcessPO::getDevId,deviceId).
|
||||
eq(CsEquipmentProcessPO::getProcess,byId.getProcess()).
|
||||
set(CsEquipmentProcessPO::getEndTime,new Date()).
|
||||
eq(CsEquipmentProcessPO::getProcess,type).
|
||||
eq(CsEquipmentProcessPO::getStatus,1).
|
||||
set(CsEquipmentProcessPO::getEndTime,LocalDateTime.now()).
|
||||
update();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package com.njcn.csdevice.service;
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.csdevice.mapper.CsEquipmentProcessPOMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentProcessPO;
|
||||
import com.njcn.csdevice.service.impl.CsEquipmentProcessPOService;
|
||||
import com.njcn.csdevice.service.CsEquipmentProcessPOService;
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
@@ -1,24 +1,22 @@
|
||||
package com.njcn.csdevice.service;
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.dto.DeviceLogDTO;
|
||||
import com.njcn.csdevice.pojo.vo.AppProjectVO;
|
||||
import com.njcn.csdevice.mapper.CsLogsPOMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsLogsPO;
|
||||
import com.njcn.csdevice.service.CsLogsPOService;
|
||||
import com.njcn.user.enums.AppRoleEnum;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.csdevice.mapper.CsLogsPOMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsLogsPO;
|
||||
import com.njcn.csdevice.service.impl.CsLogsPOService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
*
|
||||
Reference in New Issue
Block a user