|
|
|
@ -11,6 +11,7 @@ import com.hnac.hzims.fdp.proxy.IDiagnoseProxy;
|
|
|
|
|
import com.hnac.hzims.fdp.request.DiagnoseFaultReq; |
|
|
|
|
import com.hnac.hzims.fdp.service.IFdpTaskService; |
|
|
|
|
import com.hnac.hzims.fdp.vo.FdpTaskVO; |
|
|
|
|
import com.hnac.hzims.fdp.vo.TaskStatisticsVo; |
|
|
|
|
import com.hnac.hzims.fdp.wrapper.FdpTaskWrapper; |
|
|
|
|
import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity; |
|
|
|
|
import com.hnac.hzims.operational.defect.feign.IOperPhenomenonClient; |
|
|
|
@ -21,11 +22,19 @@ import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
|
|
import org.springblade.core.mp.support.Condition; |
|
|
|
|
import org.springblade.core.mp.support.Query; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
|
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.stereotype.Service; |
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @author xiashandong |
|
|
|
|
* @created 2021-05-25 17:32 |
|
|
|
@ -110,4 +119,99 @@ public class FdpTaskServiceImpl extends BaseServiceImpl<FdpTaskMapper, FdpTaskEn
|
|
|
|
|
public R<OperPhenomenonVO> getOperPhenomenon(OperPhenomenonEntity phenomenon) { |
|
|
|
|
return operPhenomenonClient.detail(phenomenon); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@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<>(); |
|
|
|
|
TaskStatisticsVo taskStatisticsVo = new TaskStatisticsVo(); |
|
|
|
|
taskStatisticsVo.setCount(fdpTaskEntities.size()); |
|
|
|
|
taskStatisticsVo.setPercentage("1"); |
|
|
|
|
taskStatisticsVo.setLevel(0); |
|
|
|
|
taskStatisticsVo.setName("总计"); |
|
|
|
|
res.add(taskStatisticsVo); |
|
|
|
|
Map<String, List<FdpTaskEntity>> collectByCreateDept = fdpTaskEntities.stream().collect(Collectors.groupingBy(FdpTaskEntity::getFdpDeviceName)); |
|
|
|
|
getCount("",collectByCreateDept, fdpTaskEntities, res, 1); |
|
|
|
|
if (Func.isEmpty(statisticsVo.getName())) { |
|
|
|
|
collectByCreateDept.entrySet().forEach(s->{ |
|
|
|
|
Map<String, List<FdpTaskEntity>> collectByName = s.getValue().stream().collect(Collectors.groupingBy(FdpTaskEntity::getName)); |
|
|
|
|
getCount(s.getKey(),collectByName, s.getValue(), res, 2); |
|
|
|
|
}); |
|
|
|
|
} else if (Func.isEmpty(statisticsVo.getFdpDeviceName())){ |
|
|
|
|
collectByCreateDept.entrySet().forEach(s->{ |
|
|
|
|
Map<String, List<FdpTaskEntity>> collectByName = s.getValue().stream().collect(Collectors.groupingBy(FdpTaskEntity::getFdpDeviceName)); |
|
|
|
|
getCount(s.getKey(),collectByName, s.getValue(), res, 2); |
|
|
|
|
}); |
|
|
|
|
}else if (Func.isEmpty(statisticsVo.getFdpOrd())){ |
|
|
|
|
collectByCreateDept.entrySet().forEach(s->{ |
|
|
|
|
Map<String, List<FdpTaskEntity>> collectByName = s.getValue().stream().collect(Collectors.groupingBy(FdpTaskEntity::getFdpOrd)); |
|
|
|
|
getCount(s.getKey(),collectByName, s.getValue(), res, 2); |
|
|
|
|
}); |
|
|
|
|
}else if (Func.isEmpty(statisticsVo.getType())){ |
|
|
|
|
collectByCreateDept.entrySet().forEach(s->{ |
|
|
|
|
Map<String, List<FdpTaskEntity>> collectByName = s.getValue().stream().collect(Collectors.groupingBy(FdpTaskEntity::getType)); |
|
|
|
|
getCount(s.getKey(),collectByName, s.getValue(), res, 2); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
return R.data(res); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public R getTaskData(TaskStatisticsVo statisticsVo) { |
|
|
|
|
Wrapper<FdpTaskEntity> queryWrapper = getFdpTaskEntityWrapper(statisticsVo); |
|
|
|
|
List<FdpTaskEntity> fdpTaskEntities = super.baseMapper.selectList(queryWrapper); |
|
|
|
|
if (CollectionUtil.isEmpty(fdpTaskEntities)){ |
|
|
|
|
return R.success("暂无数据,请稍后重试"); |
|
|
|
|
} |
|
|
|
|
return R.data(fdpTaskEntities); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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())) { |
|
|
|
|
in(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())); |
|
|
|
|
taskStatisticsVo.setPercentage(bigDecimal.toString()); |
|
|
|
|
taskStatisticsVo.setLevel(level); |
|
|
|
|
taskStatisticsVo.setName(key+"-"+s.getKey().toString()); |
|
|
|
|
res.add(taskStatisticsVo); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|