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. 93
      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 com.hnac.hzims.fdp.entity.FdpTaskEntity;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date; import java.util.Date;
@ -13,8 +14,9 @@ import java.util.Date;
* @created 2023-07-09 * @created 2023-07-09
**/ **/
@Data @Data
@EqualsAndHashCode(callSuper = true)
public class TaskStatisticsVo extends FdpTaskEntity { public class TaskStatisticsVo extends FdpTaskEntity {
private static final long serialVersionUID = 1L;
/** /**
* 开始时间 * 开始时间
*/ */
@ -43,7 +45,7 @@ public class TaskStatisticsVo extends FdpTaskEntity {
@ApiModelProperty(value = "几级菜单") @ApiModelProperty(value = "几级菜单")
private Integer level; private Integer level;
@ApiModelProperty(value = "菜单名称") @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 staff
* @param typeInstrument * @param typeInstrument
* @param createTime
* @return * @return
*/ */
@Override @Override
public String getTicketByCode(String staff, String typeInstrument, LocalDateTime createTime) { public String getTicketByCode(String staff, String typeInstrument) {
log.error("获取工作票工作票唯一ID 熔断措施"); log.error("获取工作票工作票唯一ID 熔断措施");
return null; 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 staff
* @param typeInstrument * @param typeInstrument
* @param createTime
* @return * @return
*/ */
@GetMapping("/process-dict/getTicketByCode") @GetMapping("/process-dict/getTicketByCode")
public String getTicketByCode(@RequestParam("staff") String staff, public String getTicketByCode(@RequestParam("staff") String staff,
@RequestParam("typeInstrument") String typeInstrument, @RequestParam("typeInstrument") String typeInstrument);
@RequestParam("createTime") LocalDateTime createTime);
/** /**

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") @PostMapping("/getTaskData")
@ApiOperationSupport(order = 90) @ApiOperationSupport(order = 90)
@ApiOperation(value = "获取统计详细数据") @ApiOperation(value = "获取统计详细数据")
public R getTaskData(TaskStatisticsVo statisticsVo){ public R getTaskData(TaskStatisticsVo statisticsVo,Query query){
return service.getTaskData(statisticsVo); 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") // @JSONField(name = "NAME")
// private String name; // private String name;
@ApiModelProperty("数据时间") @ApiModelProperty("数据时间")
@JSONField(name = "NAME") @JSONField(name = "ts")
private String ts; private String ts;
@ApiModelProperty("状态") @ApiModelProperty("状态")
@JSONField(name = "STATUS") @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.setTaskId(req.getId().toString());
diagnoseFaultReq.setFaultId(req.getFaultId()); diagnoseFaultReq.setFaultId(req.getFaultId());
diagnoseFaultReq.setConfidence(1.0); diagnoseFaultReq.setConfidence(1.0);
diagnoseFaultReq.setLifeTime(1); diagnoseFaultReq.setLifeTime(24*3);//设置有效期3天
diagnoseFaultReq.setPriority(2); diagnoseFaultReq.setPriority(2);
diagnoseFaultReq.setTenantId(fdpFaultEntity.getStationId()); diagnoseFaultReq.setTenantId(fdpFaultEntity.getStationId());
diagnoseFaultReq.setCreateUser(ObjectUtil.isEmpty(AuthUtil.getUser()) ? "告警推送" : AuthUtil.getUser().getUserName()); 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 getTaskStatistics(TaskStatisticsVo statisticsVo);
R getTaskData(TaskStatisticsVo statisticsVo); R getTaskData(TaskStatisticsVo statisticsVo,Query query);
} }

93
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.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -127,7 +128,7 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl<FdpMonitorMapper, Fdp
public String updateFaultState; public String updateFaultState;
private final static String JOINT_RELAY_SIGNAGE = "joint_relay";//合位继电器 private final static String JOINT_RELAY_SIGNAGE = "joint_relay";//合位继电器
private final static String KEY_FOR_FDP_TASK_ID = "fdp_task_id";//redis保存key
@Override @Override
public List<MonitorBandingReq> getMonitorBanding() { public List<MonitorBandingReq> getMonitorBanding() {
@ -298,8 +299,8 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl<FdpMonitorMapper, Fdp
@Override @Override
public List<FdpMonitorEntity> list(FdpMonitorDTO req) { public List<FdpMonitorEntity> list(FdpMonitorDTO req) {
LambdaQueryWrapper<FdpMonitorEntity> qw = Wrappers.lambdaQuery(); LambdaQueryWrapper<FdpMonitorEntity> qw = Wrappers.lambdaQuery();
if(CollectionUtil.isNotEmpty(req.getMonitorIds())) { if (CollectionUtil.isNotEmpty(req.getMonitorIds())) {
qw.in(FdpMonitorEntity::getFdpId,req.getMonitorIds()); qw.in(FdpMonitorEntity::getFdpId, req.getMonitorIds());
} }
return this.list(qw); return this.list(qw);
} }
@ -461,11 +462,43 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl<FdpMonitorMapper, Fdp
// /**获取实时、历史数据**/ // /**获取实时、历史数据**/
// FdpRealTimeAndHisDataVo pushResp = this.dataPushByPartition(fdpFaultEntity.getFdpPartition(), fdpFaultEntity.getCreateDept()); // FdpRealTimeAndHisDataVo pushResp = this.dataPushByPartition(fdpFaultEntity.getFdpPartition(), fdpFaultEntity.getCreateDept());
// String key = UUID.randomUUID().toString(); // 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); boolean flag = fdpTaskService.save(taskDTO);
if (!flag) { if (!flag) {
return R.fail("诊断任务保存失败"); return R.fail("诊断任务保存失败");
} }
String key = taskDTO.getId().toString(); 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);
}
// //异步处理 20230426 此接口弃用 // //异步处理 20230426 此接口弃用
ThreadTask.fdpTaskNew(taskDTO, fdpFaultEntity, key); ThreadTask.fdpTaskNew(taskDTO, fdpFaultEntity, key);
//获取数据成功-》 告知前端 //获取数据成功-》 告知前端
@ -478,7 +511,8 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl<FdpMonitorMapper, Fdp
public R getNextstepData(String id) { public R getNextstepData(String id) {
Object o = redisTemplate.opsForValue().get(fdpReturnValuePath + "_" + id); Object o = redisTemplate.opsForValue().get(fdpReturnValuePath + "_" + id);
if (ObjectUtil.isNotEmpty(o)) { 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;
} }
return R.data("-1"); return R.data("-1");
@ -495,18 +529,26 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl<FdpMonitorMapper, Fdp
if (ObjectUtil.isEmpty(fdpFaultEntity)) { if (ObjectUtil.isEmpty(fdpFaultEntity)) {
throw new ServiceException("获取对应故障对象失败"); throw new ServiceException("获取对应故障对象失败");
} }
/**推送数据**/ Boolean hasKey = redisTemplate.hasKey(KEY_FOR_FDP_TASK_ID + "_" + diagnoseFaultReq.getTaskId().toString());
FdpRealTimeAndHisDataVo pushResp = this.dataPushByPartition(fdpFaultEntity.getFdpPartition(), fdpFaultEntity.getCreateDept()); //Redis中不存在,该任务过期
if (!hasKey) {
return R.fail("该任务已过期,请重新生成任务");
}
/**更新故障状态**/ /**更新故障状态**/
DiagnoseFaultAllReq faultAllReq = new DiagnoseFaultAllReq(); DiagnoseFaultAllReq faultAllReq = new DiagnoseFaultAllReq();
faultAllReq.setAutoData(pushResp); /**推送数据**/
//20230710取消实时数据推送
// FdpRealTimeAndHisDataVo pushResp = this.dataPushByPartition(fdpFaultEntity.getFdpPartition(), fdpFaultEntity.getCreateDept());
// faultAllReq.setAutoData(pushResp);
faultAllReq.setStationId(fdpFaultEntity.getStationId()); faultAllReq.setStationId(fdpFaultEntity.getStationId());
diagnoseFaultReq.setTenantId(fdpFaultEntity.getStationId()); diagnoseFaultReq.setTenantId(fdpFaultEntity.getStationId());
diagnoseFaultReq.setLifeTime(24*3);//一旦用户进行修改,智能诊断时效性刷新为3天
faultAllReq.setManualData(diagnoseFaultReq); faultAllReq.setManualData(diagnoseFaultReq);
String jsonString = JSONObject.toJSONString(faultAllReq); String jsonString = JSONObject.toJSONString(faultAllReq);
System.out.println(jsonString); System.out.println(jsonString);
HttpResponse r = HttpClientUtils.post(updateFaultStateAll, JSONObject.toJSONString(faultAllReq)); 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(); return JSONObject.parseObject(r.getData(), BaseResp.class).convert2R();
} }
@ -524,13 +566,13 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl<FdpMonitorMapper, Fdp
@Override @Override
public String getFaultList() { public String getFaultList() {
List<String> list = this.baseMapper.selectStationIds(); List<String> list = this.baseMapper.selectStationIds();
if(CollectionUtil.isEmpty(list)){ if (CollectionUtil.isEmpty(list)) {
return null; return null;
} }
Map<String, Object> paramMap = new HashMap<>(); Map<String, Object> paramMap = new HashMap<>();
paramMap.put("stationIds", list.toArray(new String[0])); paramMap.put("stationIds", list.toArray(new String[0]));
String result = HttpRequestUtil.postCall(paramMap, autoFaultPath, "POST"); String result = HttpRequestUtil.postCall(paramMap, autoFaultPath, "POST");
if(StringUtil.isBlank(result)){ if (StringUtil.isBlank(result)) {
return null; return null;
} }
return JSONObject.parseObject(result).get("data").toString(); return JSONObject.parseObject(result).get("data").toString();
@ -556,7 +598,7 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl<FdpMonitorMapper, Fdp
// 描述 // 描述
paramMap.put("info", state.getInfo()); paramMap.put("info", state.getInfo());
String result = HttpRequestUtil.postCall(paramMap, autoFaultPath, "POST"); String result = HttpRequestUtil.postCall(paramMap, autoFaultPath, "POST");
if(StringUtil.isBlank(result)){ if (StringUtil.isBlank(result)) {
return null; return null;
} }
return JSONObject.parseObject(result).get("data").toString(); return JSONObject.parseObject(result).get("data").toString();
@ -809,33 +851,36 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl<FdpMonitorMapper, Fdp
} }
return vo; return vo;
} }
@Override @Override
public R dataBackV2(String faultId) { public R dataBackV2(String faultId) {
Map<String, Object> resultMap = new HashMap<>(); Map<String, Object> resultMap = new HashMap<>();
resultMap.put("faultId", faultId); resultMap.put("faultId", faultId);
String post = HttpRequestUtil.postCallObjectParam(resultMap, getRealByFault, "POST"); 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 (1 == fdpHttpResponseVo.getSuccess()) {
if (Func.isNotEmpty(fdpHttpResponseVo.getData())) { 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)){ });
if (CollectionUtil.isEmpty(list)) {
return R.success("暂无数据,请稍后重试"); return R.success("暂无数据,请稍后重试");
} }
List<FdpFaultRealDataVO> res =new ArrayList<>(); List<FdpFaultRealDataVO> res = new ArrayList<>();
for (FdpFaultRealDataDTO fdpFaultRealDataDTO : list) { for (FdpFaultRealDataDTO fdpFaultRealDataDTO : list) {
if (null!=fdpFaultRealDataDTO.getReal()){ if (null != fdpFaultRealDataDTO.getReal()) {
for (int i = 0; i < fdpFaultRealDataDTO.getReal().size(); i++ ) { for (int i = 0; i < fdpFaultRealDataDTO.getReal().size(); i++) {
FdpFaultRealDataVO dataVO=new FdpFaultRealDataVO(); FdpFaultRealDataVO dataVO = new FdpFaultRealDataVO();
BeanUtils.copyProperties(fdpFaultRealDataDTO,dataVO); BeanUtils.copyProperties(fdpFaultRealDataDTO, dataVO);
dataVO.setReal(fdpFaultRealDataDTO.getReal().get(i)); dataVO.setReal(fdpFaultRealDataDTO.getReal().get(i));
dataVO.setRealTime(fdpFaultRealDataDTO.getRealTime().get(i)); dataVO.setRealTime(fdpFaultRealDataDTO.getRealTime().get(i));
dataVO.setRealName(fdpFaultRealDataDTO.getRealName().get(i)); dataVO.setRealName(fdpFaultRealDataDTO.getRealName().get(i));
dataVO.setRealIdentifier(fdpFaultRealDataDTO.getRealIdentifier().get(i)); dataVO.setRealIdentifier(fdpFaultRealDataDTO.getRealIdentifier().get(i));
res.add(dataVO); res.add(dataVO);
} }
}else { } else {
FdpFaultRealDataVO dataVO=new FdpFaultRealDataVO(); FdpFaultRealDataVO dataVO = new FdpFaultRealDataVO();
BeanUtils.copyProperties(fdpFaultRealDataDTO,dataVO); BeanUtils.copyProperties(fdpFaultRealDataDTO, dataVO);
res.add(dataVO); res.add(dataVO);
} }
} }
@ -1041,7 +1086,7 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl<FdpMonitorMapper, Fdp
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e.getMessage()); throw new RuntimeException(e.getMessage());
} }
XxlJobLogger.log(fdpDeviceCode+"实时数据返回:"+ JSON.toJSONString(realDataByAnalyzeCode)); XxlJobLogger.log(fdpDeviceCode + "实时数据返回:" + JSON.toJSONString(realDataByAnalyzeCode));
if (realDataByAnalyzeCode.isSuccess() && CollectionUtil.isNotEmpty(realDataByAnalyzeCode.getData())) { if (realDataByAnalyzeCode.isSuccess() && CollectionUtil.isNotEmpty(realDataByAnalyzeCode.getData())) {
FieldsData fieldsData = realDataByAnalyzeCode.getData().get(0); FieldsData fieldsData = realDataByAnalyzeCode.getData().get(0);
if (0 == fieldsData.getQ() && "1".equals(fieldsData.getValue())) { if (0 == fieldsData.getQ() && "1".equals(fieldsData.getValue())) {

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("暂无数据,请稍后重试"); return R.success("暂无数据,请稍后重试");
} }
ArrayList<TaskStatisticsVo> res = new ArrayList<>(); ArrayList<TaskStatisticsVo> res = new ArrayList<>();
TaskStatisticsVo taskStatisticsVo = new TaskStatisticsVo(); int size = fdpTaskEntities.size();
taskStatisticsVo.setCount(fdpTaskEntities.size()); //在第一层去掉为null值数据
taskStatisticsVo.setPercentage("1"); fdpTaskEntities=fdpTaskEntities.stream().filter(s->s.getFdpDeviceName()!=null).collect(Collectors.toList());
taskStatisticsVo.setLevel(0); extracted( res,0,"总计",size,size);
taskStatisticsVo.setName("总计"); Map<String, List<FdpTaskEntity>> collectByFdpDeviceName = fdpTaskEntities.stream().collect(Collectors.groupingBy(FdpTaskEntity::getFdpDeviceName));
res.add(taskStatisticsVo); getCount("",collectByFdpDeviceName, fdpTaskEntities, res, 1);
Map<String, List<FdpTaskEntity>> collectByCreateDept = fdpTaskEntities.stream().collect(Collectors.groupingBy(FdpTaskEntity::getFdpDeviceName));
getCount("",collectByCreateDept, fdpTaskEntities, res, 1);
if (Func.isEmpty(statisticsVo.getName())) { if (Func.isEmpty(statisticsVo.getName())) {
collectByCreateDept.entrySet().forEach(s->{ collectByFdpDeviceName.entrySet().forEach(s->{
Map<String, List<FdpTaskEntity>> collectByName = s.getValue().stream().collect(Collectors.groupingBy(FdpTaskEntity::getName)); 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); 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())){ } else if (Func.isEmpty(statisticsVo.getCreateDept())){
collectByCreateDept.entrySet().forEach(s->{ collectByFdpDeviceName.entrySet().forEach(s->{
Map<String, List<FdpTaskEntity>> collectByName = s.getValue().stream().collect(Collectors.groupingBy(FdpTaskEntity::getFdpDeviceName)); List<FdpTaskEntity> list=s.getValue().stream().filter(sig->sig.getCreateDept()!=null).collect(Collectors.toList());
getCount(s.getKey(),collectByName, s.getValue(), res, 2); 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())){ }else if (Func.isEmpty(statisticsVo.getFdpOrd())){
collectByCreateDept.entrySet().forEach(s->{ collectByFdpDeviceName.entrySet().forEach(s->{
Map<String, List<FdpTaskEntity>> collectByName = s.getValue().stream().collect(Collectors.groupingBy(FdpTaskEntity::getFdpOrd)); 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); 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())){ }else if (Func.isEmpty(statisticsVo.getType())){
collectByCreateDept.entrySet().forEach(s->{ collectByFdpDeviceName.entrySet().forEach(s->{
Map<String, List<FdpTaskEntity>> collectByName = s.getValue().stream().collect(Collectors.groupingBy(FdpTaskEntity::getType)); 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); 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); 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 @Override
public R getTaskData(TaskStatisticsVo statisticsVo) { public R getTaskData(TaskStatisticsVo statisticsVo,Query query) {
Wrapper<FdpTaskEntity> queryWrapper = getFdpTaskEntityWrapper(statisticsVo); Wrapper<FdpTaskEntity> queryWrapper = getFdpTaskEntityWrapper(statisticsVo);
List<FdpTaskEntity> fdpTaskEntities = super.baseMapper.selectList(queryWrapper); IPage pages = super.baseMapper.selectPage(Condition.getPage(query),queryWrapper);
if (CollectionUtil.isEmpty(fdpTaskEntities)){ if (CollectionUtil.isEmpty(pages.getRecords())){
return R.success("暂无数据,请稍后重试"); return R.success("暂无数据,请稍后重试");
} }
return R.data(fdpTaskEntities); return R.data(pages);
} }
private static Wrapper<FdpTaskEntity> getFdpTaskEntityWrapper(TaskStatisticsVo statisticsVo) { private static Wrapper<FdpTaskEntity> getFdpTaskEntityWrapper(TaskStatisticsVo statisticsVo) {
@ -179,7 +208,7 @@ public class FdpTaskServiceImpl extends BaseServiceImpl<FdpTaskMapper, FdpTaskEn
le(FdpTaskEntity::getCreateTime, statisticsVo.getEndTime()); le(FdpTaskEntity::getCreateTime, statisticsVo.getEndTime());
} }
if (Func.isNotEmpty(statisticsVo.getCreateDept())) { if (Func.isNotEmpty(statisticsVo.getCreateDept())) {
in(FdpTaskEntity::getCreateDept, statisticsVo.getCreateDept()); eq(FdpTaskEntity::getCreateDept, statisticsVo.getCreateDept());
} }
if (Func.isNotEmpty(statisticsVo.getName())) { if (Func.isNotEmpty(statisticsVo.getName())) {
like(FdpTaskEntity::getName, statisticsVo.getName()); like(FdpTaskEntity::getName, statisticsVo.getName());
@ -207,10 +236,30 @@ public class FdpTaskServiceImpl extends BaseServiceImpl<FdpTaskMapper, FdpTaskEn
collectByCreateDept.entrySet().forEach(s->{ collectByCreateDept.entrySet().forEach(s->{
TaskStatisticsVo taskStatisticsVo = new TaskStatisticsVo(); TaskStatisticsVo taskStatisticsVo = new TaskStatisticsVo();
taskStatisticsVo.setCount(s.getValue().size()); 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())); BigDecimal bigDecimal=BigDecimal.valueOf(s.getValue().size()).divide(BigDecimal.valueOf(fdpTaskEntities.size()));
taskStatisticsVo.setPercentage(bigDecimal.toString()); taskStatisticsVo.setPercentage(bigDecimal.toString());
taskStatisticsVo.setLevel(level); 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); 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 staff
* @param typeInstrument * @param typeInstrument
* @param createTime
* @return * @return
*/ */
@GetMapping("/getTicketByCode") @GetMapping("/getTicketByCode")
public String getTicketByCode(@RequestParam("staff") String staff, public String getTicketByCode(@RequestParam("staff") String staff,
@RequestParam("typeInstrument") String typeInstrument, @RequestParam("typeInstrument") String typeInstrument) {
@RequestParam("createTime") LocalDateTime createTime) { return processIdWorker.getTicketByCode(staff, typeInstrument, LocalDateTime.now());
return processIdWorker.getTicketByCode(staff, typeInstrument, createTime);
} }

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.setSignage(signage);
standardTicketInfoVo.setSignageCode(station.getCode()); standardTicketInfoVo.setSignageCode(station.getCode());
//2. 获取编码 //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); log.info("获取编码: {}", code);
if (StringUtils.isBlank(code)) { if (StringUtils.isBlank(code)) {
throw new ServiceException("服务器异常,请联系管理员"); 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().setSignage(station.getSignage());
workTicketVo.getWorkTicket().setSignageCode(station.getCode()); workTicketVo.getWorkTicket().setSignageCode(station.getCode());
//2. 获取编码 //2. 获取编码
String code = processDictFeignService.getTicketByCode(signage, this.getTicketWichCode(workTicketVo.getWorkTicket().getType()), String code = processDictFeignService.getTicketByCode(signage, this.getTicketWichCode(workTicketVo.getWorkTicket().getType()));
LocalDateTime.now());
log.info("获取编码: {}", code); log.info("获取编码: {}", code);
if (StringUtils.isBlank(code)) { if (StringUtils.isBlank(code)) {
throw new ServiceException("服务器异常,请联系管理员"); throw new ServiceException("服务器异常,请联系管理员");

Loading…
Cancel
Save