Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
yang_shj 1 year ago
parent
commit
7ff6764539
  1. 43
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/dto/FdpSubmitResultDTO.java
  2. 3
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/dto/FdpTaskDTO.java
  3. 3
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpMonitorController.java
  4. 2
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpTaskController.java
  5. 1
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpMonitorService.java
  6. 2
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpTaskService.java
  7. 66
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpMonitorServiceImpl.java
  8. 52
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpTaskServiceImpl.java
  9. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java

43
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/dto/FdpSubmitResultDTO.java

@ -0,0 +1,43 @@
package com.hnac.hzims.fdp.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 模型DTO
*
* @author xiashandong
* @created 2021-05-25 17:38
**/
@Data
public class FdpSubmitResultDTO {
private static final long serialVersionUID = 1L;
/**
* 站点ID
*/
@ApiModelProperty(value = "站点ID", required = true)
private String stationId;
/**
* 开始诊断的故障ID
*/
@ApiModelProperty(value = "开始诊断的故障ID", required = true)
private String faultId;
/**
* 本次诊断是否成功
*/
@ApiModelProperty(value = "本次诊断是否成功 1:成功,0:失败", required = true)
private Integer success;
/**
* 本次诊断出的根因
*/
@ApiModelProperty(value = "本次诊断出的根因;诊断失败可为空字符串", required = true)
private String rootCause;
/**
*诊断的补充说明
*/
@ApiModelProperty(value = "诊断的补充说明", required = true)
private String comment;
}

3
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/dto/FdpTaskDTO.java

@ -1,6 +1,7 @@
package com.hnac.hzims.fdp.dto; package com.hnac.hzims.fdp.dto;
import com.hnac.hzims.fdp.entity.FdpTaskEntity; import com.hnac.hzims.fdp.entity.FdpTaskEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -15,5 +16,7 @@ import lombok.EqualsAndHashCode;
public class FdpTaskDTO extends FdpTaskEntity { public class FdpTaskDTO extends FdpTaskEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "站点Id ")
private String station;
} }

3
hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpMonitorController.java

@ -258,10 +258,11 @@ public class FdpMonitorController extends BladeController {
return service.getMonitorFault(realId,stationId); return service.getMonitorFault(realId,stationId);
} }
//仅集中推送告警中诊断接口使用
@PostMapping("/updateFaultStateAll") @PostMapping("/updateFaultStateAll")
@ApiOperationSupport(order = 170) @ApiOperationSupport(order = 170)
public R updateFaultStateAll(@RequestBody FdpTaskDTO fdpTaskDTO) { public R updateFaultStateAll(@RequestBody FdpTaskDTO fdpTaskDTO) {
return service.updateFaultStateAll(fdpTaskDTO); return service.updateFaultStateAllV2(fdpTaskDTO);
} }
@PostMapping("/updateFaultState") @PostMapping("/updateFaultState")

2
hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpTaskController.java

@ -71,7 +71,7 @@ public class FdpTaskController extends BladeController {
@ApiOperationSupport(order = 30) @ApiOperationSupport(order = 30)
@ApiOperation(value = "修改") @ApiOperation(value = "修改")
public R update(@Valid @RequestBody FdpTaskDTO req) { public R update(@Valid @RequestBody FdpTaskDTO req) {
return R.status(service.updateById(req)); return service.submitResult(req);
} }
/** /**

1
hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpMonitorService.java

@ -144,6 +144,7 @@ public interface IFdpMonitorService extends BaseService<FdpMonitorEntity> {
List<FdpMonitorEntity> getFdpMonitorList(List<String> stationIdList,List<String> fdpDeviceCodeList); List<FdpMonitorEntity> getFdpMonitorList(List<String> stationIdList,List<String> fdpDeviceCodeList);
R updateFaultStateAll(FdpTaskDTO taskDTO); R updateFaultStateAll(FdpTaskDTO taskDTO);
R updateFaultStateAllV2(FdpTaskDTO taskDTO);
R updateFaultState(@RequestBody DiagnoseFaultReq diagnoseFaultReq); R updateFaultState(@RequestBody DiagnoseFaultReq diagnoseFaultReq);

2
hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpTaskService.java

@ -32,4 +32,6 @@ public interface IFdpTaskService extends BaseService<FdpTaskEntity> {
R getTaskStatistics(TaskStatisticsVo statisticsVo); R getTaskStatistics(TaskStatisticsVo statisticsVo);
R getTaskData(TaskStatisticsVo statisticsVo,Query query); R getTaskData(TaskStatisticsVo statisticsVo,Query query);
R submitResult(FdpTaskDTO req);
} }

66
hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpMonitorServiceImpl.java

@ -12,6 +12,7 @@ import com.google.common.collect.Lists;
import com.hnac.hzims.EquipmentConstants; import com.hnac.hzims.EquipmentConstants;
import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.entity.EmInfoEntity;
import com.hnac.hzims.equipment.service.IEmInfoService; import com.hnac.hzims.equipment.service.IEmInfoService;
import com.hnac.hzims.equipment.vo.DiagnoseStatusVo;
import com.hnac.hzims.fdp.constants.DeviceInstanceTypeConstant; import com.hnac.hzims.fdp.constants.DeviceInstanceTypeConstant;
import com.hnac.hzims.fdp.dto.FdpFaultRealDataDTO; import com.hnac.hzims.fdp.dto.FdpFaultRealDataDTO;
import com.hnac.hzims.fdp.dto.FdpMonitorDTO; import com.hnac.hzims.fdp.dto.FdpMonitorDTO;
@ -385,7 +386,70 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl<FdpMonitorMapper, Fdp
List<FdpMonitorEntity> fdpMonitorEntityRealTimeList = this.baseMapper.getFdpMonitorEntityRealTimeList(null, null, null, stationIdList, fdpDeviceCodeList); List<FdpMonitorEntity> fdpMonitorEntityRealTimeList = this.baseMapper.getFdpMonitorEntityRealTimeList(null, null, null, stationIdList, fdpDeviceCodeList);
return fdpMonitorEntityRealTimeList; return fdpMonitorEntityRealTimeList;
} }
@Override
public R updateFaultStateAllV2(FdpTaskDTO taskDTO) {
if (StringUtil.isEmpty(taskDTO.getFaultId())) {
return R.fail("未传入faultId参数");
}
/**获取故障对象**/
LambdaQueryWrapper<FdpFaultEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(FdpFaultEntity::getFdpId, taskDTO.getFaultId()).last("limit 1");
FdpFaultEntity fdpFaultEntity = fdpFaultService.getOne(wrapper);
if (ObjectUtil.isEmpty(fdpFaultEntity)) {
throw new ServiceException("获取对应故障对象失败");
}
//拿到最近一次未完成的任务
FdpTaskEntity fdpTaskEntity = fdpTaskService.getOne(new LambdaQueryWrapper<FdpTaskEntity>() {{
eq(FdpTaskEntity::getFaultId, taskDTO.getFaultId());
eq(FdpTaskEntity::getIsDeleted, 0);
in(FdpTaskEntity::getStatus, 1, 2);//未开始或者未完成
orderByDesc(FdpTaskEntity::getCreateTime);
last("limit 1");
}});
String key;
if (Func.isNotEmpty(fdpTaskEntity)) {
Boolean hasKey = redisTemplate.hasKey(KEY_FOR_FDP_TASK_ID + "_" + fdpTaskEntity.getId().toString());
//Redis中存在,该任务没过期。用该任务Id
if (hasKey) {
key = fdpTaskEntity.getId().toString();
} else {
//该任务过期,更改状态为过期,新增一个任务
fdpTaskEntity.setStatus(4);
fdpTaskService.updateById(fdpTaskEntity);
boolean flag = fdpTaskService.save(taskDTO);
if (!flag) {
return R.fail("诊断任务保存失败");
}
key = taskDTO.getId().toString();
redisTemplate.opsForValue().set(KEY_FOR_FDP_TASK_ID + "_" + key, key);
Boolean expire = redisTemplate.expire(KEY_FOR_FDP_TASK_ID + "_" + key,3, TimeUnit.DAYS);
System.out.println(expire);
}
} else {
//没有未完成的任务,新增一个任务
boolean flag = fdpTaskService.save(taskDTO);
if (!flag) {
return R.fail("诊断任务保存失败");
}
key = taskDTO.getId().toString();
redisTemplate.opsForValue().set(KEY_FOR_FDP_TASK_ID + "_" + key, key);
redisTemplate.expire(KEY_FOR_FDP_TASK_ID + "_" + key, 3, TimeUnit.DAYS);
}
R r2 = new R();
r2.setCode(200);
r2.setSuccess(true);
r2.setMsg("获取信息成功");
DiagnoseStatusVo diagnoseStatusVo = new DiagnoseStatusVo();
R nextstep = fdpFaultService.getNextStepWithTree(fdpFaultEntity.getFdpId(), fdpFaultEntity.getStationId());
diagnoseStatusVo.setStatus(4);
diagnoseStatusVo.setMessage("诊断成功");
diagnoseStatusVo.setData(nextstep.getData());
r2.setData(diagnoseStatusVo);
key = taskDTO.getId().toString();
redisTemplate.opsForValue().set(fdpReturnValuePath + "_" + key, JSONObject.toJSONString(r2));
redisTemplate.expire(fdpReturnValuePath + "_" + key, 30, TimeUnit.MINUTES);
return nextstep;
}
@Override @Override
public R updateFaultStateAll(FdpTaskDTO taskDTO) { public R updateFaultStateAll(FdpTaskDTO taskDTO) {
if (StringUtil.isEmpty(taskDTO.getFaultId())) { if (StringUtil.isEmpty(taskDTO.getFaultId())) {

52
hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpTaskServiceImpl.java

@ -1,9 +1,11 @@
package com.hnac.hzims.fdp.service.impl; package com.hnac.hzims.fdp.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.aliyun.oss.ServiceException; import com.aliyun.oss.ServiceException;
import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.fdp.dto.FdpSubmitResultDTO;
import com.hnac.hzims.fdp.dto.FdpTaskDTO; import com.hnac.hzims.fdp.dto.FdpTaskDTO;
import com.hnac.hzims.fdp.entity.FdpTaskEntity; import com.hnac.hzims.fdp.entity.FdpTaskEntity;
import com.hnac.hzims.fdp.mapper.FdpTaskMapper; import com.hnac.hzims.fdp.mapper.FdpTaskMapper;
@ -16,6 +18,8 @@ import com.hnac.hzims.fdp.wrapper.FdpTaskWrapper;
import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity; import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity;
import com.hnac.hzims.operational.defect.feign.IOperPhenomenonClient; import com.hnac.hzims.operational.defect.feign.IOperPhenomenonClient;
import com.hnac.hzims.operational.defect.vo.OperPhenomenonVO; import com.hnac.hzims.operational.defect.vo.OperPhenomenonVO;
import com.hnac.hzims.util.HttpClientUtils;
import com.hnac.hzims.util.pojo.HttpResponse;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.base.BaseServiceImpl;
@ -27,6 +31,7 @@ import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil; import org.springblade.core.tool.utils.StringUtil;
import org.springblade.system.feign.ISysClient; import org.springblade.system.feign.ISysClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -47,6 +52,9 @@ public class FdpTaskServiceImpl extends BaseServiceImpl<FdpTaskMapper, FdpTaskEn
private final ISysClient sysClient; private final ISysClient sysClient;
private IDiagnoseProxy diagnoseProxy; private IDiagnoseProxy diagnoseProxy;
@Value("${url.submitResult}")
public String submitResult;
@Override @Override
public R doSave(FdpTaskDTO req) { public R doSave(FdpTaskDTO req) {
boolean flag = super.save(req); boolean flag = super.save(req);
@ -76,8 +84,7 @@ public class FdpTaskServiceImpl extends BaseServiceImpl<FdpTaskMapper, FdpTaskEn
detail.setStatus(1); detail.setStatus(1);
boolean flag = super.saveOrUpdate(detail); boolean flag = super.saveOrUpdate(detail);
return flag; return flag;
} } catch (NullPointerException e) {
catch (NullPointerException e){
throw new ServiceException("该id无法获取到智能诊断任务记录!"); throw new ServiceException("该id无法获取到智能诊断任务记录!");
} }
} }
@ -199,6 +206,46 @@ public class FdpTaskServiceImpl extends BaseServiceImpl<FdpTaskMapper, FdpTaskEn
return R.data(pages); return R.data(pages);
} }
@Override
public R submitResult(FdpTaskDTO req) {
FdpSubmitResultDTO fdpSubmitResultDTO = new FdpSubmitResultDTO();
if (4 == req.getStatus()) {
fdpSubmitResultDTO.setSuccess(0);
}
//诊断成功
if (3 == req.getStatus()) {
fdpSubmitResultDTO.setSuccess(1);
} else if (Func.isNotEmpty(req.getReasonId())) {
fdpSubmitResultDTO.setRootCause(req.getReasonId());
} else {
return R.fail("诊断传送状态异常");
}
if (Func.isNotEmpty(req.getReasonId())) {
fdpSubmitResultDTO.setRootCause(req.getReasonId());
}
if (Func.isNotEmpty(req.getFaultId())) {
fdpSubmitResultDTO.setFaultId(req.getFaultId());
} else {
return R.fail("数据异常");
}
if (Func.isNotEmpty(req.getComment())) {
fdpSubmitResultDTO.setComment(req.getComment());
}
if (Func.isNotEmpty(req.getStation())) {
fdpSubmitResultDTO.setStationId(req.getStation());
}
HttpResponse r = HttpClientUtils.post(submitResult, JSONObject.toJSONString(fdpSubmitResultDTO));
if (200 != r.getCode()) {
throw new ServiceException("智能诊断回传失败");
}
boolean b = this.updateById(req);
if (b) {
return R.success("保存成功");
} else {
return R.fail("保存失败,请稍后重试");
}
}
private static Wrapper<FdpTaskEntity> getFdpTaskEntityWrapper(TaskStatisticsVo statisticsVo) { private static Wrapper<FdpTaskEntity> getFdpTaskEntityWrapper(TaskStatisticsVo statisticsVo) {
Wrapper<FdpTaskEntity> queryWrapper = new LambdaQueryWrapper<FdpTaskEntity>() {{ Wrapper<FdpTaskEntity> queryWrapper = new LambdaQueryWrapper<FdpTaskEntity>() {{
if (Func.isNotEmpty(statisticsVo.getStartTime())) { if (Func.isNotEmpty(statisticsVo.getStartTime())) {
@ -243,6 +290,7 @@ public class FdpTaskServiceImpl extends BaseServiceImpl<FdpTaskMapper, FdpTaskEn
res.add(taskStatisticsVo); res.add(taskStatisticsVo);
}); });
} }
//获取对应层级占比和数量 //获取对应层级占比和数量
//机构类型需要转换ID为名称 //机构类型需要转换ID为名称
private void getCount2(String key, Map<Long, List<FdpTaskEntity>> collectByCreateDept, List<FdpTaskEntity> fdpTaskEntities, ArrayList<TaskStatisticsVo> res, Integer level) { private void getCount2(String key, Map<Long, List<FdpTaskEntity>> collectByCreateDept, List<FdpTaskEntity> fdpTaskEntities, ArrayList<TaskStatisticsVo> res, Integer level) {

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java

@ -124,6 +124,10 @@ public class OperMaintenanceTaskServiceImpl extends BaseServiceImpl<OperMaintena
if (!CollectionUtils.isEmpty(req.getDeptIds())) { if (!CollectionUtils.isEmpty(req.getDeptIds())) {
in(OperMaintenanceTaskEntity::getCreateDept, req.getDeptIds()); in(OperMaintenanceTaskEntity::getCreateDept, req.getDeptIds());
} }
if (StringUtil.isNoneBlank(req.getFlowTaskName())) {
eq(OperMaintenanceTaskEntity::getFlowTaskName,req.getFlowTaskName());
}
}}; }};
IPage pages = super.page(Condition.getPage(query), queryWrapper); IPage pages = super.page(Condition.getPage(query), queryWrapper);

Loading…
Cancel
Save