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. 464
      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;
import com.hnac.hzims.fdp.entity.FdpTaskEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -15,5 +16,7 @@ import lombok.EqualsAndHashCode;
public class FdpTaskDTO extends FdpTaskEntity {
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);
}
//仅集中推送告警中诊断接口使用
@PostMapping("/updateFaultStateAll")
@ApiOperationSupport(order = 170)
public R updateFaultStateAll(@RequestBody FdpTaskDTO fdpTaskDTO) {
return service.updateFaultStateAll(fdpTaskDTO);
return service.updateFaultStateAllV2(fdpTaskDTO);
}
@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)
@ApiOperation(value = "修改")
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);
R updateFaultStateAll(FdpTaskDTO taskDTO);
R updateFaultStateAllV2(FdpTaskDTO taskDTO);
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 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.equipment.entity.EmInfoEntity;
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.dto.FdpFaultRealDataDTO;
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);
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
public R updateFaultStateAll(FdpTaskDTO taskDTO) {
if (StringUtil.isEmpty(taskDTO.getFaultId())) {

464
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;
import com.alibaba.fastjson.JSONObject;
import com.aliyun.oss.ServiceException;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.entity.FdpTaskEntity;
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.feign.IOperPhenomenonClient;
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.extern.slf4j.Slf4j;
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.StringUtil;
import org.springblade.system.feign.ISysClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
@ -43,224 +48,267 @@ import java.util.stream.Collectors;
@AllArgsConstructor
@Slf4j
public class FdpTaskServiceImpl extends BaseServiceImpl<FdpTaskMapper, FdpTaskEntity> implements IFdpTaskService {
private final IOperPhenomenonClient operPhenomenonClient;
private final ISysClient sysClient;
private IDiagnoseProxy diagnoseProxy;
private final IOperPhenomenonClient operPhenomenonClient;
private final ISysClient sysClient;
private IDiagnoseProxy diagnoseProxy;
@Override
public R doSave(FdpTaskDTO req) {
boolean flag = super.save(req);
if(flag){
DiagnoseFaultReq diagnoseFaultReq = new DiagnoseFaultReq();
diagnoseFaultReq.setTaskId(req.getId().toString());
log.info("存入taskId为:{}",req.getId().toString());
diagnoseFaultReq.setFaultId(req.getFaultId());
diagnoseFaultReq.setConfidence(1.0);
diagnoseFaultReq.setLifeTime(1);
diagnoseFaultReq.setPriority(2);
diagnoseProxy.updateFaultState(diagnoseFaultReq);
}
return flag ? R.data(req.getId()) : R.fail("FAIL");
}
@Value("${url.submitResult}")
public String submitResult;
@Override
public R<FdpTaskVO> detail(Long id) {
FdpTaskEntity detail = super.getById(id);
return R.data(FdpTaskWrapper.build().entityVO(detail));
}
@Override
public R doSave(FdpTaskDTO req) {
boolean flag = super.save(req);
if (flag) {
DiagnoseFaultReq diagnoseFaultReq = new DiagnoseFaultReq();
diagnoseFaultReq.setTaskId(req.getId().toString());
log.info("存入taskId为:{}", req.getId().toString());
diagnoseFaultReq.setFaultId(req.getFaultId());
diagnoseFaultReq.setConfidence(1.0);
diagnoseFaultReq.setLifeTime(1);
diagnoseFaultReq.setPriority(2);
diagnoseProxy.updateFaultState(diagnoseFaultReq);
}
return flag ? R.data(req.getId()) : R.fail("FAIL");
}
@Override
public boolean updateTaskStatus(Long id) {
FdpTaskEntity detail = super.getById(id);
try{
detail.setStatus(1);
boolean flag = super.saveOrUpdate(detail);
return flag;
}
catch (NullPointerException e){
throw new ServiceException("该id无法获取到智能诊断任务记录!");
}
}
@Override
public R<FdpTaskVO> detail(Long id) {
FdpTaskEntity detail = super.getById(id);
return R.data(FdpTaskWrapper.build().entityVO(detail));
}
@Override
public R<IPage<FdpTaskVO>> list(FdpTaskDTO req, Query query) {
Wrapper<FdpTaskEntity> queryWrapper = new LambdaQueryWrapper<FdpTaskEntity>() {{
orderByDesc(FdpTaskEntity::getId);
//name,emId,faultId,reasonId,satisfaction
if (StringUtil.isNotBlank(req.getName())) {
like(FdpTaskEntity::getName, req.getName());
}
if (req.getEmCode() != null) {
eq(FdpTaskEntity::getEmCode, req.getEmCode());
}
if (StringUtil.isNotBlank(req.getFaultId())) {
eq(FdpTaskEntity::getFaultId, req.getFaultId());
}
if (StringUtil.isNotBlank(req.getReasonId())) {
eq(FdpTaskEntity::getReasonId, req.getReasonId());
}
if (req.getSatisfaction() != null) {
eq(FdpTaskEntity::getSatisfaction, req.getSatisfaction());
}
if(ObjectUtil.isNotEmpty(req.getStatus())){
eq(FdpTaskEntity::getStatus, req.getStatus());
}
if(StringUtil.isNotBlank(req.getFdpDeviceName())){
like(FdpTaskEntity::getFdpDeviceName,req.getFdpDeviceName());
}
}};
@Override
public boolean updateTaskStatus(Long id) {
FdpTaskEntity detail = super.getById(id);
try {
detail.setStatus(1);
boolean flag = super.saveOrUpdate(detail);
return flag;
} catch (NullPointerException e) {
throw new ServiceException("该id无法获取到智能诊断任务记录!");
}
}
IPage pages = super.page(Condition.getPage(query), queryWrapper);
pages.setRecords(FdpTaskWrapper.build().listVO(pages.getRecords()));
return R.data(pages);
}
@Override
public R<IPage<FdpTaskVO>> list(FdpTaskDTO req, Query query) {
Wrapper<FdpTaskEntity> queryWrapper = new LambdaQueryWrapper<FdpTaskEntity>() {{
orderByDesc(FdpTaskEntity::getId);
//name,emId,faultId,reasonId,satisfaction
if (StringUtil.isNotBlank(req.getName())) {
like(FdpTaskEntity::getName, req.getName());
}
if (req.getEmCode() != null) {
eq(FdpTaskEntity::getEmCode, req.getEmCode());
}
if (StringUtil.isNotBlank(req.getFaultId())) {
eq(FdpTaskEntity::getFaultId, req.getFaultId());
}
if (StringUtil.isNotBlank(req.getReasonId())) {
eq(FdpTaskEntity::getReasonId, req.getReasonId());
}
if (req.getSatisfaction() != null) {
eq(FdpTaskEntity::getSatisfaction, req.getSatisfaction());
}
if (ObjectUtil.isNotEmpty(req.getStatus())) {
eq(FdpTaskEntity::getStatus, req.getStatus());
}
if (StringUtil.isNotBlank(req.getFdpDeviceName())) {
like(FdpTaskEntity::getFdpDeviceName, req.getFdpDeviceName());
}
}};
@Override
public R<OperPhenomenonVO> getOperPhenomenon(OperPhenomenonEntity phenomenon) {
return operPhenomenonClient.detail(phenomenon);
}
IPage pages = super.page(Condition.getPage(query), queryWrapper);
pages.setRecords(FdpTaskWrapper.build().listVO(pages.getRecords()));
return R.data(pages);
}
@Override
public R getTaskStatistics(TaskStatisticsVo statisticsVo) {
Wrapper<FdpTaskEntity> queryWrapper = getFdpTaskEntityWrapper(statisticsVo);
List<FdpTaskEntity> fdpTaskEntities = super.baseMapper.selectList(queryWrapper);
if (CollectionUtil.isEmpty(fdpTaskEntities)){
return R.success("暂无数据,请稍后重试");
}
ArrayList<TaskStatisticsVo> res = new ArrayList<>();
int size = fdpTaskEntities.size();
//在第一层去掉为null值数据
fdpTaskEntities=fdpTaskEntities.stream().filter(s->s.getFdpDeviceName()!=null).collect(Collectors.toList());
extracted( res,0,"总计",size,size);
Map<String, List<FdpTaskEntity>> collectByFdpDeviceName = fdpTaskEntities.stream().collect(Collectors.groupingBy(FdpTaskEntity::getFdpDeviceName));
getCount("",collectByFdpDeviceName, fdpTaskEntities, res, 1);
if (Func.isEmpty(statisticsVo.getName())) {
collectByFdpDeviceName.entrySet().forEach(s->{
List<FdpTaskEntity> list=s.getValue().stream().filter(sig->sig.getName()!=null).collect(Collectors.toList());
Map<String, List<FdpTaskEntity>> collectByName = list.stream().collect(Collectors.groupingBy(FdpTaskEntity::getName));
getCount(s.getKey(),collectByName, s.getValue(), res, 2);
if (list.size()!=s.getValue().size()) {
//值为空单独加进来
extracted( res,1,s.getKey()+"-空",s.getValue().size()-list.size(),s.getValue().size());
}
@Override
public R<OperPhenomenonVO> getOperPhenomenon(OperPhenomenonEntity phenomenon) {
return operPhenomenonClient.detail(phenomenon);
}
});
} else if (Func.isEmpty(statisticsVo.getCreateDept())){
collectByFdpDeviceName.entrySet().forEach(s->{
List<FdpTaskEntity> list=s.getValue().stream().filter(sig->sig.getCreateDept()!=null).collect(Collectors.toList());
Map<Long, List<FdpTaskEntity>> collectByName = list.stream().collect(Collectors.groupingBy(FdpTaskEntity::getCreateDept));
getCount2(s.getKey(),collectByName, s.getValue(), res, 2);
if (list.size()!=s.getValue().size()) {
//值为空单独加进来
extracted( res,1,s.getKey()+"-空",s.getValue().size()-list.size(),s.getValue().size());
}
});
}else if (Func.isEmpty(statisticsVo.getFdpOrd())){
collectByFdpDeviceName.entrySet().forEach(s->{
List<FdpTaskEntity> list=s.getValue().stream().filter(sig->sig.getFdpOrd()!=null).collect(Collectors.toList());
Map<String, List<FdpTaskEntity>> collectByName = list.stream().collect(Collectors.groupingBy(FdpTaskEntity::getFdpOrd));
getCount(s.getKey(),collectByName, s.getValue(), res, 2);
if (list.size()!=s.getValue().size()) {
//值为空单独加进来
extracted( res,1,s.getKey()+"-空",s.getValue().size()-list.size(),s.getValue().size());
}
});
}else if (Func.isEmpty(statisticsVo.getType())){
collectByFdpDeviceName.entrySet().forEach(s->{
List<FdpTaskEntity> list=s.getValue().stream().filter(sig->sig.getFdpOrd()!=null).collect(Collectors.toList());
Map<String, List<FdpTaskEntity>> collectByName = list.stream().collect(Collectors.groupingBy(FdpTaskEntity::getType));
getCount(s.getKey(),collectByName, s.getValue(), res, 2);
if (list.size()!=s.getValue().size()) {
//值为空单独加进来
extracted( res,1,s.getKey()+"-空",s.getValue().size()-list.size(),s.getValue().size());
}
});
}
return R.data(res);
}
@Override
public R getTaskStatistics(TaskStatisticsVo statisticsVo) {
Wrapper<FdpTaskEntity> queryWrapper = getFdpTaskEntityWrapper(statisticsVo);
List<FdpTaskEntity> fdpTaskEntities = super.baseMapper.selectList(queryWrapper);
if (CollectionUtil.isEmpty(fdpTaskEntities)) {
return R.success("暂无数据,请稍后重试");
}
ArrayList<TaskStatisticsVo> res = new ArrayList<>();
int size = fdpTaskEntities.size();
//在第一层去掉为null值数据
fdpTaskEntities = fdpTaskEntities.stream().filter(s -> s.getFdpDeviceName() != null).collect(Collectors.toList());
extracted(res, 0, "总计", size, size);
Map<String, List<FdpTaskEntity>> collectByFdpDeviceName = fdpTaskEntities.stream().collect(Collectors.groupingBy(FdpTaskEntity::getFdpDeviceName));
getCount("", collectByFdpDeviceName, fdpTaskEntities, res, 1);
if (Func.isEmpty(statisticsVo.getName())) {
collectByFdpDeviceName.entrySet().forEach(s -> {
List<FdpTaskEntity> list = s.getValue().stream().filter(sig -> sig.getName() != null).collect(Collectors.toList());
Map<String, List<FdpTaskEntity>> collectByName = list.stream().collect(Collectors.groupingBy(FdpTaskEntity::getName));
getCount(s.getKey(), collectByName, s.getValue(), res, 2);
if (list.size() != s.getValue().size()) {
//值为空单独加进来
extracted(res, 1, s.getKey() + "-空", s.getValue().size() - list.size(), s.getValue().size());
}
private static void extracted( ArrayList<TaskStatisticsVo> res,Integer level,String name,Integer size,Integer all) {
TaskStatisticsVo taskStatisticsByDeviceName = new TaskStatisticsVo();
taskStatisticsByDeviceName.setCount(size);
BigDecimal bigDecimal=BigDecimal.valueOf(all).divide(BigDecimal.valueOf(size),2,BigDecimal.ROUND_UP);
taskStatisticsByDeviceName.setPercentage(bigDecimal.toString());
taskStatisticsByDeviceName.setLevel(level);
taskStatisticsByDeviceName.setMemuName(name);
res.add(taskStatisticsByDeviceName);
}
});
} else if (Func.isEmpty(statisticsVo.getCreateDept())) {
collectByFdpDeviceName.entrySet().forEach(s -> {
List<FdpTaskEntity> list = s.getValue().stream().filter(sig -> sig.getCreateDept() != null).collect(Collectors.toList());
Map<Long, List<FdpTaskEntity>> collectByName = list.stream().collect(Collectors.groupingBy(FdpTaskEntity::getCreateDept));
getCount2(s.getKey(), collectByName, s.getValue(), res, 2);
if (list.size() != s.getValue().size()) {
//值为空单独加进来
extracted(res, 1, s.getKey() + "-空", s.getValue().size() - list.size(), s.getValue().size());
}
});
} else if (Func.isEmpty(statisticsVo.getFdpOrd())) {
collectByFdpDeviceName.entrySet().forEach(s -> {
List<FdpTaskEntity> list = s.getValue().stream().filter(sig -> sig.getFdpOrd() != null).collect(Collectors.toList());
Map<String, List<FdpTaskEntity>> collectByName = list.stream().collect(Collectors.groupingBy(FdpTaskEntity::getFdpOrd));
getCount(s.getKey(), collectByName, s.getValue(), res, 2);
if (list.size() != s.getValue().size()) {
//值为空单独加进来
extracted(res, 1, s.getKey() + "-空", s.getValue().size() - list.size(), s.getValue().size());
}
});
} else if (Func.isEmpty(statisticsVo.getType())) {
collectByFdpDeviceName.entrySet().forEach(s -> {
List<FdpTaskEntity> list = s.getValue().stream().filter(sig -> sig.getFdpOrd() != null).collect(Collectors.toList());
Map<String, List<FdpTaskEntity>> collectByName = list.stream().collect(Collectors.groupingBy(FdpTaskEntity::getType));
getCount(s.getKey(), collectByName, s.getValue(), res, 2);
if (list.size() != s.getValue().size()) {
//值为空单独加进来
extracted(res, 1, s.getKey() + "-空", s.getValue().size() - list.size(), s.getValue().size());
}
});
}
return R.data(res);
}
@Override
public R getTaskData(TaskStatisticsVo statisticsVo,Query query) {
Wrapper<FdpTaskEntity> queryWrapper = getFdpTaskEntityWrapper(statisticsVo);
IPage pages = super.baseMapper.selectPage(Condition.getPage(query),queryWrapper);
if (CollectionUtil.isEmpty(pages.getRecords())){
return R.success("暂无数据,请稍后重试");
}
return R.data(pages);
}
private static void extracted(ArrayList<TaskStatisticsVo> res, Integer level, String name, Integer size, Integer all) {
TaskStatisticsVo taskStatisticsByDeviceName = new TaskStatisticsVo();
taskStatisticsByDeviceName.setCount(size);
BigDecimal bigDecimal = BigDecimal.valueOf(all).divide(BigDecimal.valueOf(size), 2, BigDecimal.ROUND_UP);
taskStatisticsByDeviceName.setPercentage(bigDecimal.toString());
taskStatisticsByDeviceName.setLevel(level);
taskStatisticsByDeviceName.setMemuName(name);
res.add(taskStatisticsByDeviceName);
}
private static Wrapper<FdpTaskEntity> getFdpTaskEntityWrapper(TaskStatisticsVo statisticsVo) {
Wrapper<FdpTaskEntity> queryWrapper = new LambdaQueryWrapper<FdpTaskEntity>() {{
if (Func.isNotEmpty(statisticsVo.getStartTime())) {
ge(FdpTaskEntity::getCreateTime, statisticsVo.getStartTime());
}
if (Func.isNotEmpty(statisticsVo.getEndTime())) {
le(FdpTaskEntity::getCreateTime, statisticsVo.getEndTime());
}
if (Func.isNotEmpty(statisticsVo.getCreateDept())) {
eq(FdpTaskEntity::getCreateDept, statisticsVo.getCreateDept());
}
if (Func.isNotEmpty(statisticsVo.getName())) {
like(FdpTaskEntity::getName, statisticsVo.getName());
}
if (Func.isNotEmpty(statisticsVo.getFdpDeviceName())) {
like(FdpTaskEntity::getFdpDeviceName, statisticsVo.getFdpDeviceName());
}
if (Func.isNotEmpty(statisticsVo.getFdpOrd())) {
like(FdpTaskEntity::getFdpOrd, statisticsVo.getFdpOrd());
}
if (Func.isNotEmpty(statisticsVo.getType())) {
eq(FdpTaskEntity::getType, statisticsVo.getType());
}
if (Func.isNotEmpty(statisticsVo.getStatus())) {
eq(FdpTaskEntity::getStatus, statisticsVo.getStatus());
}
eq(FdpTaskEntity::getIsDeleted,0);
orderByDesc(FdpTaskEntity::getCreateTime);
}};
return queryWrapper;
}
@Override
public R getTaskData(TaskStatisticsVo statisticsVo, Query query) {
Wrapper<FdpTaskEntity> queryWrapper = getFdpTaskEntityWrapper(statisticsVo);
IPage pages = super.baseMapper.selectPage(Condition.getPage(query), queryWrapper);
if (CollectionUtil.isEmpty(pages.getRecords())) {
return R.success("暂无数据,请稍后重试");
}
return R.data(pages);
}
//获取对应层级占比和数量
private static void getCount(String key,Map<String, List<FdpTaskEntity>> collectByCreateDept, List<FdpTaskEntity> fdpTaskEntities, ArrayList<TaskStatisticsVo> res,Integer level) {
collectByCreateDept.entrySet().forEach(s->{
TaskStatisticsVo taskStatisticsVo = new TaskStatisticsVo();
taskStatisticsVo.setCount(s.getValue().size());
BigDecimal bigDecimal=BigDecimal.valueOf(s.getValue().size()).divide(BigDecimal.valueOf(fdpTaskEntities.size()),2,BigDecimal.ROUND_UP);
taskStatisticsVo.setPercentage(bigDecimal.toString());
taskStatisticsVo.setLevel(level);
taskStatisticsVo.setMemuName(key+"-"+s.getKey().toString());
res.add(taskStatisticsVo);
});
}
//获取对应层级占比和数量
//机构类型需要转换ID为名称
private void getCount2(String key,Map<Long, List<FdpTaskEntity>> collectByCreateDept, List<FdpTaskEntity> fdpTaskEntities, ArrayList<TaskStatisticsVo> res,Integer level) {
collectByCreateDept.entrySet().forEach(s->{
TaskStatisticsVo taskStatisticsVo = new TaskStatisticsVo();
taskStatisticsVo.setCount(s.getValue().size());
BigDecimal bigDecimal=BigDecimal.valueOf(s.getValue().size()).divide(BigDecimal.valueOf(fdpTaskEntities.size()));
taskStatisticsVo.setPercentage(bigDecimal.toString());
taskStatisticsVo.setLevel(level);
R<String> deptNameCode = sysClient.getDeptName(s.getKey());
String deptName;
if (deptNameCode.isSuccess()){
deptName=deptNameCode.getData();
}else {
deptName="";
}
taskStatisticsVo.setMemuName(key+"-"+deptName);
res.add(taskStatisticsVo);
});
}
@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) {
Wrapper<FdpTaskEntity> queryWrapper = new LambdaQueryWrapper<FdpTaskEntity>() {{
if (Func.isNotEmpty(statisticsVo.getStartTime())) {
ge(FdpTaskEntity::getCreateTime, statisticsVo.getStartTime());
}
if (Func.isNotEmpty(statisticsVo.getEndTime())) {
le(FdpTaskEntity::getCreateTime, statisticsVo.getEndTime());
}
if (Func.isNotEmpty(statisticsVo.getCreateDept())) {
eq(FdpTaskEntity::getCreateDept, statisticsVo.getCreateDept());
}
if (Func.isNotEmpty(statisticsVo.getName())) {
like(FdpTaskEntity::getName, statisticsVo.getName());
}
if (Func.isNotEmpty(statisticsVo.getFdpDeviceName())) {
like(FdpTaskEntity::getFdpDeviceName, statisticsVo.getFdpDeviceName());
}
if (Func.isNotEmpty(statisticsVo.getFdpOrd())) {
like(FdpTaskEntity::getFdpOrd, statisticsVo.getFdpOrd());
}
if (Func.isNotEmpty(statisticsVo.getType())) {
eq(FdpTaskEntity::getType, statisticsVo.getType());
}
if (Func.isNotEmpty(statisticsVo.getStatus())) {
eq(FdpTaskEntity::getStatus, statisticsVo.getStatus());
}
eq(FdpTaskEntity::getIsDeleted, 0);
orderByDesc(FdpTaskEntity::getCreateTime);
}};
return queryWrapper;
}
//获取对应层级占比和数量
private static void getCount(String key, Map<String, List<FdpTaskEntity>> collectByCreateDept, List<FdpTaskEntity> fdpTaskEntities, ArrayList<TaskStatisticsVo> res, Integer level) {
collectByCreateDept.entrySet().forEach(s -> {
TaskStatisticsVo taskStatisticsVo = new TaskStatisticsVo();
taskStatisticsVo.setCount(s.getValue().size());
BigDecimal bigDecimal = BigDecimal.valueOf(s.getValue().size()).divide(BigDecimal.valueOf(fdpTaskEntities.size()), 2, BigDecimal.ROUND_UP);
taskStatisticsVo.setPercentage(bigDecimal.toString());
taskStatisticsVo.setLevel(level);
taskStatisticsVo.setMemuName(key + "-" + s.getKey().toString());
res.add(taskStatisticsVo);
});
}
//获取对应层级占比和数量
//机构类型需要转换ID为名称
private void getCount2(String key, Map<Long, List<FdpTaskEntity>> collectByCreateDept, List<FdpTaskEntity> fdpTaskEntities, ArrayList<TaskStatisticsVo> res, Integer level) {
collectByCreateDept.entrySet().forEach(s -> {
TaskStatisticsVo taskStatisticsVo = new TaskStatisticsVo();
taskStatisticsVo.setCount(s.getValue().size());
BigDecimal bigDecimal = BigDecimal.valueOf(s.getValue().size()).divide(BigDecimal.valueOf(fdpTaskEntities.size()));
taskStatisticsVo.setPercentage(bigDecimal.toString());
taskStatisticsVo.setLevel(level);
R<String> deptNameCode = sysClient.getDeptName(s.getKey());
String deptName;
if (deptNameCode.isSuccess()) {
deptName = deptNameCode.getData();
} else {
deptName = "";
}
taskStatisticsVo.setMemuName(key + "-" + deptName);
res.add(taskStatisticsVo);
});
}
}

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())) {
in(OperMaintenanceTaskEntity::getCreateDept, req.getDeptIds());
}
if (StringUtil.isNoneBlank(req.getFlowTaskName())) {
eq(OperMaintenanceTaskEntity::getFlowTaskName,req.getFlowTaskName());
}
}};
IPage pages = super.page(Condition.getPage(query), queryWrapper);

Loading…
Cancel
Save