Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
yang_shj 1 year ago
parent
commit
53dd6b0828
  1. 6
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/vo/TaskStatisticsVo.java
  2. 3
      hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/fallback/ProcessDictFeignServiceFallback.java
  3. 4
      hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/feign/ProcessDictFeignService.java
  4. 4
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpTaskController.java
  5. 2
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/response/FaultStateResp.java
  6. 2
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/scheduled/ThreadTask.java
  7. 2
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpTaskService.java
  8. 61
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpMonitorServiceImpl.java
  9. 97
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpTaskServiceImpl.java
  10. 6
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/controller/ProcessDictController.java
  11. 2
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/OperationTicketServiceImpl.java
  12. 3
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java

6
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/vo/TaskStatisticsVo.java

@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import com.hnac.hzims.fdp.entity.FdpTaskEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@ -13,8 +14,9 @@ import java.util.Date;
* @created 2023-07-09
**/
@Data
@EqualsAndHashCode(callSuper = true)
public class TaskStatisticsVo extends FdpTaskEntity {
private static final long serialVersionUID = 1L;
/**
* 开始时间
*/
@ -43,7 +45,7 @@ public class TaskStatisticsVo extends FdpTaskEntity {
@ApiModelProperty(value = "几级菜单")
private Integer level;
@ApiModelProperty(value = "菜单名称")
private String name;
private String memuName;

3
hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/fallback/ProcessDictFeignServiceFallback.java

@ -21,11 +21,10 @@ public class ProcessDictFeignServiceFallback implements ProcessDictFeignService
*
* @param staff
* @param typeInstrument
* @param createTime
* @return
*/
@Override
public String getTicketByCode(String staff, String typeInstrument, LocalDateTime createTime) {
public String getTicketByCode(String staff, String typeInstrument) {
log.error("获取工作票工作票唯一ID 熔断措施");
return null;
}

4
hzims-service-api/middle-api/src/main/java/com/hnac/hzims/middle/process/feign/ProcessDictFeignService.java

@ -21,13 +21,11 @@ public interface ProcessDictFeignService {
*
* @param staff
* @param typeInstrument
* @param createTime
* @return
*/
@GetMapping("/process-dict/getTicketByCode")
public String getTicketByCode(@RequestParam("staff") String staff,
@RequestParam("typeInstrument") String typeInstrument,
@RequestParam("createTime") LocalDateTime createTime);
@RequestParam("typeInstrument") String typeInstrument);
/**

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

@ -145,7 +145,7 @@ public class FdpTaskController extends BladeController {
@PostMapping("/getTaskData")
@ApiOperationSupport(order = 90)
@ApiOperation(value = "获取统计详细数据")
public R getTaskData(TaskStatisticsVo statisticsVo){
return service.getTaskData(statisticsVo);
public R getTaskData(TaskStatisticsVo statisticsVo,Query query){
return service.getTaskData(statisticsVo,query);
}
}

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

@ -24,7 +24,7 @@ public class FaultStateResp {
// @JSONField(name = "NAME")
// private String name;
@ApiModelProperty("数据时间")
@JSONField(name = "NAME")
@JSONField(name = "ts")
private String ts;
@ApiModelProperty("状态")
@JSONField(name = "STATUS")

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

@ -208,7 +208,7 @@ public class ThreadTask {
diagnoseFaultReq.setTaskId(req.getId().toString());
diagnoseFaultReq.setFaultId(req.getFaultId());
diagnoseFaultReq.setConfidence(1.0);
diagnoseFaultReq.setLifeTime(1);
diagnoseFaultReq.setLifeTime(24*3);//设置有效期3天
diagnoseFaultReq.setPriority(2);
diagnoseFaultReq.setTenantId(fdpFaultEntity.getStationId());
diagnoseFaultReq.setCreateUser(ObjectUtil.isEmpty(AuthUtil.getUser()) ? "告警推送" : AuthUtil.getUser().getUserName());

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

@ -31,5 +31,5 @@ public interface IFdpTaskService extends BaseService<FdpTaskEntity> {
R getTaskStatistics(TaskStatisticsVo statisticsVo);
R getTaskData(TaskStatisticsVo statisticsVo);
R getTaskData(TaskStatisticsVo statisticsVo,Query query);
}

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

@ -76,6 +76,7 @@ import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
@ -127,7 +128,7 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl<FdpMonitorMapper, Fdp
public String updateFaultState;
private final static String JOINT_RELAY_SIGNAGE = "joint_relay";//合位继电器
private final static String KEY_FOR_FDP_TASK_ID = "fdp_task_id";//redis保存key
@Override
public List<MonitorBandingReq> getMonitorBanding() {
@ -461,11 +462,43 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl<FdpMonitorMapper, Fdp
// /**获取实时、历史数据**/
// FdpRealTimeAndHisDataVo pushResp = this.dataPushByPartition(fdpFaultEntity.getFdpPartition(), fdpFaultEntity.getCreateDept());
// String key = UUID.randomUUID().toString();
//拿到最近一次未完成的任务
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("诊断任务保存失败");
}
String key = taskDTO.getId().toString();
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);
}
// //异步处理 20230426 此接口弃用
ThreadTask.fdpTaskNew(taskDTO, fdpFaultEntity, key);
//获取数据成功-》 告知前端
@ -478,7 +511,8 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl<FdpMonitorMapper, Fdp
public R getNextstepData(String id) {
Object o = redisTemplate.opsForValue().get(fdpReturnValuePath + "_" + id);
if (ObjectUtil.isNotEmpty(o)) {
R r = JSONObject.parseObject(o.toString(), new TypeReference<R>() {{}});
R r = JSONObject.parseObject(o.toString(), new TypeReference<R>() {{
}});
return r;
}
return R.data("-1");
@ -495,18 +529,26 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl<FdpMonitorMapper, Fdp
if (ObjectUtil.isEmpty(fdpFaultEntity)) {
throw new ServiceException("获取对应故障对象失败");
}
/**推送数据**/
FdpRealTimeAndHisDataVo pushResp = this.dataPushByPartition(fdpFaultEntity.getFdpPartition(), fdpFaultEntity.getCreateDept());
Boolean hasKey = redisTemplate.hasKey(KEY_FOR_FDP_TASK_ID + "_" + diagnoseFaultReq.getTaskId().toString());
//Redis中不存在,该任务过期
if (!hasKey) {
return R.fail("该任务已过期,请重新生成任务");
}
/**更新故障状态**/
DiagnoseFaultAllReq faultAllReq = new DiagnoseFaultAllReq();
faultAllReq.setAutoData(pushResp);
/**推送数据**/
//20230710取消实时数据推送
// FdpRealTimeAndHisDataVo pushResp = this.dataPushByPartition(fdpFaultEntity.getFdpPartition(), fdpFaultEntity.getCreateDept());
// faultAllReq.setAutoData(pushResp);
faultAllReq.setStationId(fdpFaultEntity.getStationId());
diagnoseFaultReq.setTenantId(fdpFaultEntity.getStationId());
diagnoseFaultReq.setLifeTime(24*3);//一旦用户进行修改,智能诊断时效性刷新为3天
faultAllReq.setManualData(diagnoseFaultReq);
String jsonString = JSONObject.toJSONString(faultAllReq);
System.out.println(jsonString);
HttpResponse r = HttpClientUtils.post(updateFaultStateAll, JSONObject.toJSONString(faultAllReq));
redisTemplate.expire(KEY_FOR_FDP_TASK_ID + "_" + diagnoseFaultReq.getTaskId(), 3, TimeUnit.DAYS);
return JSONObject.parseObject(r.getData(), BaseResp.class).convert2R();
}
@ -809,15 +851,18 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl<FdpMonitorMapper, Fdp
}
return vo;
}
@Override
public R dataBackV2(String faultId) {
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("faultId", faultId);
String post = HttpRequestUtil.postCallObjectParam(resultMap, getRealByFault, "POST");
FdpHttpResponseVo fdpHttpResponseVo = JSONObject.parseObject(post, new TypeReference<FdpHttpResponseVo>() {});
FdpHttpResponseVo fdpHttpResponseVo = JSONObject.parseObject(post, new TypeReference<FdpHttpResponseVo>() {
});
if (1 == fdpHttpResponseVo.getSuccess()) {
if (Func.isNotEmpty(fdpHttpResponseVo.getData())) {
List<FdpFaultRealDataDTO> list = JSONObject.parseObject(fdpHttpResponseVo.getData(), new TypeReference<List<FdpFaultRealDataDTO>>() {});
List<FdpFaultRealDataDTO> list = JSONObject.parseObject(fdpHttpResponseVo.getData(), new TypeReference<List<FdpFaultRealDataDTO>>() {
});
if (CollectionUtil.isEmpty(list)) {
return R.success("暂无数据,请稍后重试");
}

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

@ -128,46 +128,75 @@ public class FdpTaskServiceImpl extends BaseServiceImpl<FdpTaskMapper, FdpTaskEn
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);
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())) {
collectByCreateDept.entrySet().forEach(s->{
Map<String, List<FdpTaskEntity>> collectByName = s.getValue().stream().collect(Collectors.groupingBy(FdpTaskEntity::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());
}
});
} 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.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())){
collectByCreateDept.entrySet().forEach(s->{
Map<String, List<FdpTaskEntity>> collectByName = s.getValue().stream().collect(Collectors.groupingBy(FdpTaskEntity::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())){
collectByCreateDept.entrySet().forEach(s->{
Map<String, List<FdpTaskEntity>> collectByName = s.getValue().stream().collect(Collectors.groupingBy(FdpTaskEntity::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);
}
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);
}
@Override
public R getTaskData(TaskStatisticsVo statisticsVo) {
public R getTaskData(TaskStatisticsVo statisticsVo,Query query) {
Wrapper<FdpTaskEntity> queryWrapper = getFdpTaskEntityWrapper(statisticsVo);
List<FdpTaskEntity> fdpTaskEntities = super.baseMapper.selectList(queryWrapper);
if (CollectionUtil.isEmpty(fdpTaskEntities)){
IPage pages = super.baseMapper.selectPage(Condition.getPage(query),queryWrapper);
if (CollectionUtil.isEmpty(pages.getRecords())){
return R.success("暂无数据,请稍后重试");
}
return R.data(fdpTaskEntities);
return R.data(pages);
}
private static Wrapper<FdpTaskEntity> getFdpTaskEntityWrapper(TaskStatisticsVo statisticsVo) {
@ -179,7 +208,7 @@ public class FdpTaskServiceImpl extends BaseServiceImpl<FdpTaskMapper, FdpTaskEn
le(FdpTaskEntity::getCreateTime, statisticsVo.getEndTime());
}
if (Func.isNotEmpty(statisticsVo.getCreateDept())) {
in(FdpTaskEntity::getCreateDept, statisticsVo.getCreateDept());
eq(FdpTaskEntity::getCreateDept, statisticsVo.getCreateDept());
}
if (Func.isNotEmpty(statisticsVo.getName())) {
like(FdpTaskEntity::getName, statisticsVo.getName());
@ -207,10 +236,30 @@ public class FdpTaskServiceImpl extends BaseServiceImpl<FdpTaskMapper, FdpTaskEn
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);
taskStatisticsVo.setName(key+"-"+s.getKey().toString());
R<String> deptNameCode = sysClient.getDeptName(s.getKey());
String deptName;
if (deptNameCode.isSuccess()){
deptName=deptNameCode.getData();
}else {
deptName="";
}
taskStatisticsVo.setMemuName(key+"-"+deptName);
res.add(taskStatisticsVo);
});
}

6
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/controller/ProcessDictController.java

@ -62,14 +62,12 @@ public class ProcessDictController {
*
* @param staff
* @param typeInstrument
* @param createTime
* @return
*/
@GetMapping("/getTicketByCode")
public String getTicketByCode(@RequestParam("staff") String staff,
@RequestParam("typeInstrument") String typeInstrument,
@RequestParam("createTime") LocalDateTime createTime) {
return processIdWorker.getTicketByCode(staff, typeInstrument, createTime);
@RequestParam("typeInstrument") String typeInstrument) {
return processIdWorker.getTicketByCode(staff, typeInstrument, LocalDateTime.now());
}

2
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/OperationTicketServiceImpl.java

@ -126,7 +126,7 @@ public class OperationTicketServiceImpl implements OperationTicketService {
standardTicketInfoVo.setSignage(signage);
standardTicketInfoVo.setSignageCode(station.getCode());
//2. 获取编码
String code = processDictFeignService.getTicketByCode(standardTicketInfoVo.getSignage(), this.getTicketWichCode(standardTicketInfoVo.getTicketType()), LocalDateTime.now());
String code = processDictFeignService.getTicketByCode(standardTicketInfoVo.getSignage(), this.getTicketWichCode(standardTicketInfoVo.getTicketType()));
log.info("获取编码: {}", code);
if (StringUtils.isBlank(code)) {
throw new ServiceException("服务器异常,请联系管理员");

3
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java

@ -191,8 +191,7 @@ public class TicketProcessServiceImpl implements TicketProcessService {
workTicketVo.getWorkTicket().setSignage(station.getSignage());
workTicketVo.getWorkTicket().setSignageCode(station.getCode());
//2. 获取编码
String code = processDictFeignService.getTicketByCode(signage, this.getTicketWichCode(workTicketVo.getWorkTicket().getType()),
LocalDateTime.now());
String code = processDictFeignService.getTicketByCode(signage, this.getTicketWichCode(workTicketVo.getWorkTicket().getType()));
log.info("获取编码: {}", code);
if (StringUtils.isBlank(code)) {
throw new ServiceException("服务器异常,请联系管理员");

Loading…
Cancel
Save