Browse Source

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	hzims-service/inspect/pom.xml
zhongwei
Jone 1 year ago
parent
commit
a26bfc6054
  1. 23
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmTreeInspectClient.java
  2. 1
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/AccessTaskClientFallback.java
  3. 3
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/entity/WindEntity.java
  4. 6
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WindSubordinateVo.java
  5. 6
      hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/dto/PlanMsgRecordDto.java
  6. 2
      hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/dto/SmsImmediatelyPushDTO.java
  7. 4
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmDefinitionController.java
  8. 1
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmInfoController.java
  9. 31
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmTreeInspectClient.java
  10. 6
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeInspectMapper.java
  11. 12
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeInspectMapper.xml
  12. 9
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmTreeInspectService.java
  13. 14
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java
  14. 8
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmTreeInspectServiceImpl.java
  15. 1
      hzims-service/equipment/src/main/resources/db/1.0.1.sql
  16. 2
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/MachineryTicketProcessServiceImpl.java
  17. 22
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/config/RedisKeyConfig.java
  18. 30
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/config/ThreadPoolConfig.java
  19. 15
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/services/IContentDefinitionService.java
  20. 21
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/services/impl/ContentDefinitionServiceImpl.java
  21. 17
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/web/ContentDefinitionController.java
  22. 45
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/aspect/TaskGenerateAspect.java
  23. 123
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/TaskSchedule.java
  24. 11
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/XxlJobConstants.java
  25. 58
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskObjectProjectContentServiceImpl.java
  26. 14
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskObjectServiceImpl.java
  27. 10
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/vo/TaskObjectProjectContentVO.java
  28. 3
      hzims-service/inspect/src/main/resources/application-dev.yml
  29. 3
      hzims-service/inspect/src/main/resources/application-prod.yml
  30. 17
      hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java
  31. 2
      hzims-service/message/src/main/java/com/hnac/hzims/message/schedule/MessagePushSchedule.java
  32. 5
      hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessagePushRecordService.java
  33. 4
      hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java
  34. 20
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/controller/HzimsDataController.java
  35. 6
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/ecology/controller/EcologyController.java
  36. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/ecology/service/EcologyFlowStationService.java
  37. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/ecology/service/impl/EcologyFlowStationServiceImpl.java
  38. 12
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/WindServiceImpl.java
  39. 9
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomeServiceImpl.java
  40. 56
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WindHomeServiceImpl.java
  41. 7
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java

23
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmTreeInspectClient.java

@ -0,0 +1,23 @@
package com.hnac.hzims.equipment.feign;
import com.hnac.hzims.EquipmentConstants;
import org.springblade.core.tool.api.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import java.util.List;
@FeignClient(value = EquipmentConstants.APP_NAME)
public interface IEmTreeInspectClient {
String API_PREFIX = "/feign/em/tree/inspect";
String GET_EM_TREE_CONTENT_ID = API_PREFIX + "/getEmTreeContentId";
/**
* 获取设备信息中已绑定的巡检内容定义ID
* @return 巡检内容定义ID
*/
@GetMapping(GET_EM_TREE_CONTENT_ID)
R<List<Long>> getEmTreeContentId();
}

1
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/AccessTaskClientFallback.java

@ -2,7 +2,6 @@ package com.hnac.hzims.operational.access.feign;
import com.hnac.hzims.operational.access.dto.OperAccessTaskDTO; import com.hnac.hzims.operational.access.dto.OperAccessTaskDTO;
import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity; import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;

3
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/entity/WindEntity.java

@ -29,9 +29,6 @@ public class WindEntity extends TenantEntity implements Serializable {
@ApiModelProperty("填报日期") @ApiModelProperty("填报日期")
private String fillDate; private String fillDate;
@ApiModelProperty("计划发电量")
private Double plan;
@ApiModelProperty("发电量") @ApiModelProperty("发电量")
private Double power; private Double power;

6
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WindSubordinateVo.java

@ -27,6 +27,7 @@ public class WindSubordinateVo {
@ApiModelProperty(value = "地市名称") @ApiModelProperty(value = "地市名称")
private String areaName; private String areaName;
@ApiModelProperty(value = "经度(东经)") @ApiModelProperty(value = "经度(东经)")
@JsonSerialize(nullsUsing = NullSerializer.class) @JsonSerialize(nullsUsing = NullSerializer.class)
@ -43,17 +44,22 @@ public class WindSubordinateVo {
private List<Daily> weather; private List<Daily> weather;
@ApiModelProperty(value = "发电量") @ApiModelProperty(value = "发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generation; private Double generation;
@ApiModelProperty(value = "集团/区域发电占比") @ApiModelProperty(value = "集团/区域发电占比")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generationRate; private Double generationRate;
@ApiModelProperty(value = "发电完成率") @ApiModelProperty(value = "发电完成率")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generationComplete; private Double generationComplete;
@ApiModelProperty(value = "风机利用率") @ApiModelProperty(value = "风机利用率")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double fanUse; private Double fanUse;
@ApiModelProperty(value = "厂用电率") @ApiModelProperty(value = "厂用电率")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double factoryUse; private Double factoryUse;
} }

6
hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/dto/PlanMsgRecordDto.java

@ -5,8 +5,8 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer; import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.*;
import lombok.EqualsAndHashCode; import lombok.experimental.Accessors;
import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.DateUtil;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
@ -24,6 +24,7 @@ import java.time.LocalDateTime;
@Data @Data
@ApiModel("计划推送消息请求对象") @ApiModel("计划推送消息请求对象")
@EqualsAndHashCode @EqualsAndHashCode
@Accessors(chain = true)
public class PlanMsgRecordDto implements Serializable { public class PlanMsgRecordDto implements Serializable {
@ApiModelProperty("机构ID") @ApiModelProperty("机构ID")
@ -33,7 +34,6 @@ public class PlanMsgRecordDto implements Serializable {
@ApiModelProperty("消息模板Id") @ApiModelProperty("消息模板Id")
@JsonSerialize(nullsUsing = NullSerializer.class) @JsonSerialize(nullsUsing = NullSerializer.class)
@NotNull
private Long templateId; private Long templateId;
@ApiModelProperty("业务任务Id") @ApiModelProperty("业务任务Id")

2
hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/dto/SmsImmediatelyPushDTO.java

@ -2,6 +2,7 @@ package com.hnac.hzims.message.dto;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.springblade.core.mp.support.QueryField; import org.springblade.core.mp.support.QueryField;
@ -21,6 +22,7 @@ import java.util.Map;
@Data @Data
@EqualsAndHashCode @EqualsAndHashCode
@ApiModel("短信即时推送请求内容") @ApiModel("短信即时推送请求内容")
@Builder
public class SmsImmediatelyPushDTO implements Serializable { public class SmsImmediatelyPushDTO implements Serializable {
@ApiModelProperty(value = "机构ID",required = true) @ApiModelProperty(value = "机构ID",required = true)

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

@ -26,6 +26,7 @@ import org.springframework.web.bind.annotation.*;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.List; import java.util.List;
import java.util.Optional;
/** /**
* 设备定义控制层 * 设备定义控制层
@ -75,8 +76,7 @@ public class EmDefinitionController extends BladeController {
wrapper.orderByDesc(EmDefinitionEntity::getCreateTime); wrapper.orderByDesc(EmDefinitionEntity::getCreateTime);
IPage<EmDefinitionEntity> pages = emDefinitionService.page(Condition.getPage(query), wrapper); IPage<EmDefinitionEntity> pages = emDefinitionService.page(Condition.getPage(query), wrapper);
for (EmDefinitionEntity definition : pages.getRecords()) { for (EmDefinitionEntity definition : pages.getRecords()) {
User createUser = UserCache.getUser(definition.getCreateUser()); definition.setCreateUserName(Optional.ofNullable(UserCache.getUser(definition.getCreateUser())).map(User::getName).orElse(String.valueOf(definition.getCreateUser())));
definition.setCreateUserName(createUser.getName());
} }
return R.data(pages); return R.data(pages);

1
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmInfoController.java

@ -93,6 +93,7 @@ public class EmInfoController extends BladeController {
public R<IPage<EmInfoEntity>> list(@ApiIgnore @RequestParam Map<String, Object> em_info, Query query) { public R<IPage<EmInfoEntity>> list(@ApiIgnore @RequestParam Map<String, Object> em_info, Query query) {
QueryWrapper<EmInfoEntity> queryWrapper = Condition.getQueryWrapper(em_info, EmInfoEntity.class); QueryWrapper<EmInfoEntity> queryWrapper = Condition.getQueryWrapper(em_info, EmInfoEntity.class);
queryWrapper.lambda().eq(EmInfoEntity::getGpid, 0); queryWrapper.lambda().eq(EmInfoEntity::getGpid, 0);
queryWrapper.orderByDesc("create_time");
IPage<EmInfoEntity> pages = em_infoService.page(Condition.getPage(query), queryWrapper); IPage<EmInfoEntity> pages = em_infoService.page(Condition.getPage(query), queryWrapper);
// 获取站点列表 - 填充站点编码、站点类型、站点名称 // 获取站点列表 - 填充站点编码、站点类型、站点名称
R<List<StationEntity>> stationListR = stationClient.list(new StationEntity()); R<List<StationEntity>> stationListR = stationClient.list(new StationEntity());

31
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmTreeInspectClient.java

@ -0,0 +1,31 @@
package com.hnac.hzims.equipment.feign;
import com.hnac.hzims.equipment.service.IEmTreeInspectService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @ClassName EmTreeInspectClient
* @description: 设备树与巡检内容定义关联关系client
* @author: hx
* @create: 2023-08-11 17:31
* @Version 4.0
**/
@RestController
@AllArgsConstructor
@Slf4j
public class EmTreeInspectClient implements IEmTreeInspectClient {
private final IEmTreeInspectService emTreeInspectService;
@Override
@GetMapping(GET_EM_TREE_CONTENT_ID)
public R<List<Long>> getEmTreeContentId() {
return R.data(emTreeInspectService.selectEmTreeContentId());
}
}

6
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeInspectMapper.java

@ -4,5 +4,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzims.equipment.entity.EmTreeInspectEntity; import com.hnac.hzims.equipment.entity.EmTreeInspectEntity;
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
import java.util.List;
import java.util.Map;
public interface EmTreeInspectMapper extends BaseMapper<EmTreeInspectEntity> { public interface EmTreeInspectMapper extends BaseMapper<EmTreeInspectEntity> {
List<Long> selectEmTreeContentId();
} }

12
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeInspectMapper.xml

@ -1,5 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnac.hzims.equipment.mapper.EmTreeInspectMapper"> <mapper namespace="com.hnac.hzims.equipment.mapper.EmTreeInspectMapper">
<select id="selectEmTreeContentId" resultType="java.lang.Long">
select distinct content_id
from hzims_em_definition ed,
hzims_em_tree et,
hzims_em_tree_inspect ti
where ed.id = et.definition_id
and et.id = ti.tree_id
and ed.IS_DELETED = 0
and ti.IS_DELETED = 0
and et.IS_DELETED = 0
</select>
</mapper> </mapper>

9
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmTreeInspectService.java

@ -3,5 +3,14 @@ package com.hnac.hzims.equipment.service;
import com.hnac.hzims.equipment.entity.EmTreeInspectEntity; import com.hnac.hzims.equipment.entity.EmTreeInspectEntity;
import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.base.BaseService;
import java.util.List;
public interface IEmTreeInspectService extends BaseService<EmTreeInspectEntity> { public interface IEmTreeInspectService extends BaseService<EmTreeInspectEntity> {
/**
* 获取
* @return 巡检内容定义ID列表
*/
List<Long> selectEmTreeContentId();
} }

14
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java

@ -91,6 +91,8 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
@Autowired @Autowired
private IEmTreeInspectService emTreeInspectService; private IEmTreeInspectService emTreeInspectService;
@Autowired @Autowired
private IEmDefinitionService emDefinitionService;
@Autowired
private IStationClient stationClient; private IStationClient stationClient;
@Autowired @Autowired
private IAnalyseDataSearchClient searchClient; private IAnalyseDataSearchClient searchClient;
@ -493,7 +495,8 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
if (Func.isEmpty(station)) { if (Func.isEmpty(station)) {
throw new ServiceException("站点不存在"); throw new ServiceException("站点不存在");
} }
copyDeviceTree(station, 0L,deviceTreeDTO.getDefinitionId() , deviceTreeDTO.getTreeIds()); EmDefinitionEntity emDefinition = emDefinitionService.getById(deviceTreeDTO.getDefinitionId());
copyDeviceTree(station, 0L, deviceTreeDTO.getDefinitionId(), emDefinition.getModelSignage(), deviceTreeDTO.getTreeIds());
return true; return true;
} }
@ -508,8 +511,8 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
throw new ServiceException("设备负责部门未绑定站点"); throw new ServiceException("设备负责部门未绑定站点");
} }
EmTreeEntity emTree = emTreeService.getById(emInfo.getTreeId()); EmTreeEntity emTree = emTreeService.getById(emInfo.getTreeId());
EmDefinitionEntity emDefinition = emDefinitionService.getById(deviceTreeDTO.getDefinitionId());
copyDeviceTree(station, deviceTreeDTO.getInfoId(), emTree.getDefinitionId(), deviceTreeDTO.getTreeIds()); copyDeviceTree(station, deviceTreeDTO.getInfoId(), emTree.getDefinitionId(), emDefinition.getModelSignage(), deviceTreeDTO.getTreeIds());
return true; return true;
} }
@ -781,7 +784,7 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
return resultList; return resultList;
} }
private void copyDeviceTree(StationEntity station, Long pid, Long definitionId, List<EmTreeIdsDTO> treeIds) { private void copyDeviceTree(StationEntity station, Long pid, Long definitionId, String modelSignage, List<EmTreeIdsDTO> treeIds) {
List<ProjectDTO> projectDTOList = new ArrayList<>(); List<ProjectDTO> projectDTOList = new ArrayList<>();
LambdaQueryWrapper<EmTreeEntity> wrapper = new LambdaQueryWrapper(); LambdaQueryWrapper<EmTreeEntity> wrapper = new LambdaQueryWrapper();
wrapper.eq(EmTreeEntity::getDefinitionId, definitionId); wrapper.eq(EmTreeEntity::getDefinitionId, definitionId);
@ -814,6 +817,7 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
emInfo.setRunStatus("1"); emInfo.setRunStatus("1");
emInfo.setStatus(1); emInfo.setStatus(1);
emInfo.setHomePageDisplay("1"); emInfo.setHomePageDisplay("1");
emInfo.setModelSignage(modelSignage);
emInfo.setRunDate(new Date()); emInfo.setRunDate(new Date());
emInfo.setCreateDept(station.getRefDept()); emInfo.setCreateDept(station.getRefDept());
emInfo.setCreateTime(new Date()); emInfo.setCreateTime(new Date());
@ -883,7 +887,7 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
projectDTOList.add(projectDTO); projectDTOList.add(projectDTO);
if (Func.isNotEmpty(emTreeIdsDTO.getChildren())) { if (Func.isNotEmpty(emTreeIdsDTO.getChildren())) {
copyDeviceTree(station, infoId, definitionId, emTreeIdsDTO.getChildren()); copyDeviceTree(station, infoId, definitionId, modelSignage, emTreeIdsDTO.getChildren());
} }
} }
if (Func.isNotEmpty(projectDTOList)) { if (Func.isNotEmpty(projectDTOList)) {

8
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmTreeInspectServiceImpl.java

@ -7,6 +7,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
/** /**
* @author tanghaihao * @author tanghaihao
* @date 2023年06月15日 9:08 * @date 2023年06月15日 9:08
@ -14,4 +16,10 @@ import org.springframework.stereotype.Service;
@Service @Service
@Slf4j @Slf4j
public class EmTreeInspectServiceImpl extends BaseServiceImpl<EmTreeInspectMapper, EmTreeInspectEntity> implements IEmTreeInspectService { public class EmTreeInspectServiceImpl extends BaseServiceImpl<EmTreeInspectMapper, EmTreeInspectEntity> implements IEmTreeInspectService {
@Override
public List<Long> selectEmTreeContentId() {
return this.baseMapper.selectEmTreeContentId();
}
} }

1
hzims-service/equipment/src/main/resources/db/1.0.1.sql

@ -0,0 +1 @@
alter table hzims_em_param add COLUMN NAME VARCHAR(100) comment '参数名称';

2
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/MachineryTicketProcessServiceImpl.java

@ -45,7 +45,7 @@ public class MachineryTicketProcessServiceImpl extends ProcessAbstractService {
@Override @Override
public Boolean isWorkflowProcess(WorkflowQueue flowQueue) { public Boolean isWorkflowProcess(WorkflowQueue flowQueue) {
log.info("是否执行水力机械工作票流程环节操作~~~~,流程ticket: {}", flowQueue); log.info("是否执行水力机械工作票流程环节操作~~~~,流程ticket: {}", flowQueue);
String dictValue = processDictService.selectDictValueByKey(MACHINERY_TICKET_KEY); String dictValue = processDictService.selectDictValueByKey(flowQueue.getProcessDefinitionKey());
if (dictValue.equals(flowQueue.getProcessDefinitionKey())) { if (dictValue.equals(flowQueue.getProcessDefinitionKey())) {
log.info("已执行水力机械工作票流程环节操作~~~~"); log.info("已执行水力机械工作票流程环节操作~~~~");
return true; return true;

22
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/config/RedisKeyConfig.java

@ -0,0 +1,22 @@
package com.hnac.hzinfo.inspect.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* @ClassName RedisKeyConfig
* @description: 巡检模块redis-key配置
* @author: hx
* @create: 2023-08-02 09:23
* @Version 4.0
**/
@Component
@ConfigurationProperties("hzims.redis.key")
@Data
public class RedisKeyConfig {
/**巡检任务结束提醒**/
private String taskEndRemind;
}

30
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/config/ThreadPoolConfig.java

@ -0,0 +1,30 @@
package com.hnac.hzinfo.inspect.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* @ClassName ThreadPoolConfig
* @description:
* @author: hx
* @create: 2023-08-02 09:42
* @Version 4.0
**/
@Configuration
public class ThreadPoolConfig {
/**
* 巡检任务推送消息管理线程池
* @return
*/
@Bean
public ExecutorService taskPushMsgExecutor() {
return new ThreadPoolExecutor(1, 6, 5L, TimeUnit.SECONDS,new LinkedBlockingQueue<Runnable>());
}
}

15
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/services/IContentDefinitionService.java

@ -2,18 +2,22 @@ package com.hnac.hzinfo.inspect.obj.services;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hnac.hzims.common.utils.Condition;
import com.hnac.hzinfo.inspect.obj.dto.ContentDefinitionDTO; import com.hnac.hzinfo.inspect.obj.dto.ContentDefinitionDTO;
import com.hnac.hzinfo.inspect.obj.entity.ContentDefinitionEntity; import com.hnac.hzinfo.inspect.obj.entity.ContentDefinitionEntity;
import com.hnac.hzinfo.inspect.obj.vo.ContentDefinitionVO; import com.hnac.hzinfo.inspect.obj.vo.ContentDefinitionVO;
import net.bytebuddy.matcher.BooleanMatcher;
import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.base.BaseService;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List; import java.util.List;
public interface IContentDefinitionService extends BaseService<ContentDefinitionEntity> { public interface IContentDefinitionService extends BaseService<ContentDefinitionEntity> {
Boolean removeByIds(String ids);
/** /**
* 根据筛选条件获取列表 * 根据筛选条件获取列表
* @param request 筛选条件 * @param request 筛选条件
@ -22,12 +26,11 @@ public interface IContentDefinitionService extends BaseService<ContentDefinition
List<ContentDefinitionVO> list(ContentDefinitionDTO request); List<ContentDefinitionVO> list(ContentDefinitionDTO request);
default LambdaQueryWrapper<ContentDefinitionEntity> getQueryWrapper(ContentDefinitionEntity entity) { default LambdaQueryWrapper<ContentDefinitionEntity> getQueryWrapper(ContentDefinitionEntity entity) {
QueryWrapper<ContentDefinitionEntity> queryWrapper = Condition.getQueryWrapper(entity); LambdaQueryWrapper<ContentDefinitionEntity> queryWrapper = Condition.getQueryWrapper(entity,ContentDefinitionEntity.class);
LambdaQueryWrapper<ContentDefinitionEntity> lambda = queryWrapper.lambda() queryWrapper.eq(Func.isNotEmpty(entity.getCreateDept()), ContentDefinitionEntity::getCreateDept, entity.getCreateDept())
.eq(Func.isNotEmpty(entity.getCreateDept()), ContentDefinitionEntity::getCreateDept, entity.getCreateDept())
.eq(Func.isNotEmpty(entity.getCreateUser()), ContentDefinitionEntity::getCreateUser, entity.getCreateUser()) .eq(Func.isNotEmpty(entity.getCreateUser()), ContentDefinitionEntity::getCreateUser, entity.getCreateUser())
.eq(Func.isNotEmpty(entity.getStatus()), ContentDefinitionEntity::getStatus, entity.getStatus()); .eq(Func.isNotEmpty(entity.getStatus()), ContentDefinitionEntity::getStatus, entity.getStatus()).orderByDesc(ContentDefinitionEntity::getCreateTime);
return lambda; return queryWrapper;
} }
} }

21
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/services/impl/ContentDefinitionServiceImpl.java

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hnac.hzims.equipment.feign.IEmTreeInspectClient;
import com.hnac.hzinfo.inspect.obj.dto.ContentDefinitionDTO; import com.hnac.hzinfo.inspect.obj.dto.ContentDefinitionDTO;
import com.hnac.hzinfo.inspect.obj.entity.ContentDefinitionEntity; import com.hnac.hzinfo.inspect.obj.entity.ContentDefinitionEntity;
import com.hnac.hzinfo.inspect.obj.mapper.ContentDefinitionMapper; import com.hnac.hzinfo.inspect.obj.mapper.ContentDefinitionMapper;
@ -12,16 +13,21 @@ import com.hnac.hzinfo.inspect.obj.vo.ContentDefinitionVO;
import com.hnac.hzinfo.inspect.obj.wrapper.ContentDefinitionWrapper; import com.hnac.hzinfo.inspect.obj.wrapper.ContentDefinitionWrapper;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.base.BaseService;
import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Condition;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil; import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Optional;
/** /**
* @ClassName ContentDefinitionServiceImpl * @ClassName ContentDefinitionServiceImpl
@ -37,6 +43,21 @@ import java.util.List;
public class ContentDefinitionServiceImpl extends BaseServiceImpl<ContentDefinitionMapper, ContentDefinitionEntity> public class ContentDefinitionServiceImpl extends BaseServiceImpl<ContentDefinitionMapper, ContentDefinitionEntity>
implements IContentDefinitionService { implements IContentDefinitionService {
private final IEmTreeInspectClient emTreeInspectClient;
@Override
public Boolean removeByIds(String ids) {
R<List<Long>> contentIdR = emTreeInspectClient.getEmTreeContentId();
Assert.isTrue(contentIdR.isSuccess(),() -> {
throw new ServiceException("查询设备定义绑定内容失败");
});
Optional<Long> optional = Func.toLongList(",",ids).stream().filter(id -> contentIdR.getData().contains(id)).findFirst();
if(optional.isPresent()) {
throw new ServiceException("删除失败,【"+this.getById(optional.get()).getName()+"】内容定义已与设备定义绑定");
}
return this.removeByIds(Func.toLongList(",",ids));
}
@Override @Override
public List<ContentDefinitionVO> list(ContentDefinitionDTO request) { public List<ContentDefinitionVO> list(ContentDefinitionDTO request) {
QueryWrapper<ContentDefinitionEntity> queryWrapper = Condition.getQueryWrapper(BeanUtil.copy(request, ContentDefinitionEntity.class)); QueryWrapper<ContentDefinitionEntity> queryWrapper = Condition.getQueryWrapper(BeanUtil.copy(request, ContentDefinitionEntity.class));

17
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/web/ContentDefinitionController.java

@ -7,6 +7,7 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzinfo.inspect.obj.dto.ContentDefinitionDTO; import com.hnac.hzinfo.inspect.obj.dto.ContentDefinitionDTO;
import com.hnac.hzinfo.inspect.obj.entity.ContentDefinitionEntity; import com.hnac.hzinfo.inspect.obj.entity.ContentDefinitionEntity;
import com.hnac.hzinfo.inspect.obj.services.IContentDefinitionService; import com.hnac.hzinfo.inspect.obj.services.IContentDefinitionService;
import com.hnac.hzinfo.inspect.obj.utils.CodeUtils;
import com.hnac.hzinfo.inspect.obj.vo.ContentDefinitionVO; import com.hnac.hzinfo.inspect.obj.vo.ContentDefinitionVO;
import com.hnac.hzinfo.inspect.obj.wrapper.ContentDefinitionWrapper; import com.hnac.hzinfo.inspect.obj.wrapper.ContentDefinitionWrapper;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -56,10 +57,13 @@ public class ContentDefinitionController extends BladeController {
return R.data(ContentDefinitionWrapper.build().listVO(contentDefinitionService.list(lambda))); return R.data(ContentDefinitionWrapper.build().listVO(contentDefinitionService.list(lambda)));
} }
@GetMapping("/save") @PostMapping("/save")
@ApiOperation("保存巡检内容定义") @ApiOperation("保存巡检内容定义")
@ApiOperationSupport(order = 3) @ApiOperationSupport(order = 3)
public R save(@RequestBody @Valid ContentDefinitionDTO content) { public R save(@RequestBody @Valid ContentDefinitionDTO content) {
if(content.getId()==null && Func.isBlank(content.getCode())){
content.setCode(CodeUtils.randomCode());
}
return R.status(contentDefinitionService.save(BeanUtil.copy(content,ContentDefinitionEntity.class))); return R.status(contentDefinitionService.save(BeanUtil.copy(content,ContentDefinitionEntity.class)));
} }
@ -74,6 +78,15 @@ public class ContentDefinitionController extends BladeController {
@ApiOperation("根据ID删除") @ApiOperation("根据ID删除")
@ApiOperationSupport(order = 5) @ApiOperationSupport(order = 5)
public R removeByIds(@RequestParam String ids) { public R removeByIds(@RequestParam String ids) {
return R.status(contentDefinitionService.removeByIds(Func.toLongList(",",ids))); return R.status(contentDefinitionService.removeByIds(ids));
}
@GetMapping("/detail")
@ApiOperation("查看详情")
@ApiOperationSupport(order = 6)
public R<ContentDefinitionVO> detail(@RequestParam Long id) {
ContentDefinitionEntity definition = contentDefinitionService.getById(id);
return R.data(ContentDefinitionWrapper.build().entityVO(definition));
} }
} }

45
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/aspect/TaskGenerateAspect.java

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.message.dto.PlanMsgRecordDto; import com.hnac.hzims.message.dto.PlanMsgRecordDto;
import com.hnac.hzims.message.fegin.IMessageClient; import com.hnac.hzims.message.fegin.IMessageClient;
import com.hnac.hzinfo.inspect.config.RedisKeyConfig;
import com.hnac.hzinfo.inspect.plan.entity.PlanEntity; import com.hnac.hzinfo.inspect.plan.entity.PlanEntity;
import com.hnac.hzinfo.inspect.task.entity.TaskEntity; import com.hnac.hzinfo.inspect.task.entity.TaskEntity;
import com.hnac.hzinfo.inspect.task.entity.TaskUserEntity; import com.hnac.hzinfo.inspect.task.entity.TaskUserEntity;
@ -19,15 +20,20 @@ import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut; import org.aspectj.lang.annotation.Pointcut;
import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.ObjectUtil;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
/** /**
* @ClassName TaskGenerateAspect * @ClassName TaskGenerateAspect
@ -45,6 +51,8 @@ public class TaskGenerateAspect {
private final IMessageClient messageClient; private final IMessageClient messageClient;
private final ITaskService taskService; private final ITaskService taskService;
private final ITaskUserService taskUserService; private final ITaskUserService taskUserService;
private final RedisTemplate redisTemplate;
private final RedisKeyConfig redisKeyConfig;
/** /**
* 巡检任务开始前发送短信信息阿里云模板 * 巡检任务开始前发送短信信息阿里云模板
@ -95,36 +103,25 @@ public class TaskGenerateAspect {
*/ */
private void pushMessageByTask(TaskEntity taskEntity) { private void pushMessageByTask(TaskEntity taskEntity) {
log.info("======================进入消息推送======================"); log.info("======================进入消息推送======================");
PlanMsgRecordDto recordDto = new PlanMsgRecordDto();
recordDto.setDeptId(taskEntity.getCreateDept());
recordDto.setTemplateId(taskEntity.getMessageTemplateId());
recordDto.setTaskId(taskEntity.getId());
if(Func.isEmpty(AuthUtil.getUserId())) {
recordDto.setTenantId(taskEntity.getTenantId());
}
// 获取巡检任务的消息推送人 // 获取巡检任务的消息推送人
LambdaQueryWrapper<TaskUserEntity> eq = Wrappers.<TaskUserEntity>lambdaQuery().eq(TaskUserEntity::getTaskId, taskEntity.getId()); LambdaQueryWrapper<TaskUserEntity> eq = Wrappers.<TaskUserEntity>lambdaQuery().eq(TaskUserEntity::getTaskId, taskEntity.getId());
List<TaskUserEntity> taskUserList = taskUserService.list(eq); List<TaskUserEntity> taskUserList = taskUserService.list(eq);
if(CollectionUtil.isNotEmpty(taskUserList)) { if(CollectionUtil.isNotEmpty(taskUserList)) {
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
taskUserList.stream().map(TaskUserEntity::getUserId).filter(Func::isNotEmpty).forEach(userId -> { taskUserList.stream().map(TaskUserEntity::getUserId).filter(Func::isNotEmpty).forEach(userId -> {
recordDto.setReceiver(userId); PlanMsgRecordDto recordDto = new PlanMsgRecordDto()
recordDto.setCreateUser(userId); .setDeptId(taskEntity.getCreateDept())
Map<String,String> smsMap = new HashMap<>(2); .setTemplateId(taskEntity.getMessageTemplateId())
// 消息开始前提醒 .setTaskId(taskEntity.getId())
recordDto.setResourceCode(taskBeginTemplateCodeV2); .setTenantId(Optional.ofNullable(AuthUtil.getTenantId()).orElse(taskEntity.getTenantId()))
smsMap.put("one",taskEntity.getPlanName()); .setReceiver(userId)
smsMap.put("two",df.format(taskEntity.getPlanStartTime())); .setCreateUser(userId)
recordDto.setPlanTime(taskEntity.getPlanStartTime()); .setResourceCode(taskBeginTemplateCodeV2)
recordDto.setSmsParam(JSON.toJSONString(smsMap)); .setPlanTime(taskEntity.getPlanStartTime())
recordDto.setContent("任务“"+ taskEntity.getPlanName() + "”的计划执行时间是:" + df.format(taskEntity.getPlanStartTime())+ " —— " + df.format(taskEntity.getPlanEndTime())); .setContent("您在"+ DateUtil.format(taskEntity.getPlanStartTime(),DateUtil.PATTERN_DATETIME) +"时间有一条巡检任务——【"+taskEntity.getPlanName()+"】待执行,请及时处理!");
log.info("巡检任务开始,推送对象:{}",JSON.toJSONString(recordDto)); // 任务开始提醒 - 集中提送
messageClient.planSendMessage(recordDto);
// 消息结束前提醒
smsMap.put("two",df.format(taskEntity.getPlanEndTime()));
recordDto.setPlanTime(taskEntity.getPlanEndTime());
recordDto.setSmsParam(JSON.toJSONString(smsMap));
messageClient.planSendMessage(recordDto); messageClient.planSendMessage(recordDto);
// 任务结束提醒 - 提醒存入redis 定时任务调用即时推送完成消息推送
redisTemplate.opsForZSet().add(redisKeyConfig.getTaskEndRemind(),taskEntity,taskEntity.getEndRemindTime().toEpochSecond(ZoneOffset.of("+8")));
}); });
} }
} }

123
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/TaskSchedule.java

@ -0,0 +1,123 @@
package com.hnac.hzinfo.inspect.task.schedule;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.hnac.hzims.message.MessageConstants;
import com.hnac.hzims.message.dto.BusinessMessageDTO;
import com.hnac.hzims.message.dto.SmsImmediatelyPushDTO;
import com.hnac.hzims.message.fegin.IMessageClient;
import com.hnac.hzinfo.inspect.config.RedisKeyConfig;
import com.hnac.hzinfo.inspect.task.TaskContants;
import com.hnac.hzinfo.inspect.task.entity.TaskEntity;
import com.hnac.hzinfo.inspect.task.entity.TaskUserEntity;
import com.hnac.hzinfo.inspect.task.service.ITaskService;
import com.hnac.hzinfo.inspect.task.service.ITaskUserService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cglib.core.Local;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneOffset;
import java.util.*;
import java.util.stream.Collectors;
import static com.hnac.hzinfo.inspect.task.schedule.XxlJobConstants.*;
/**
* @ClassName TaskSchedule
* @description: 巡检任务定时任务
* @author: hx
* @create: 2023-08-10 14:21
* @Version 4.0
**/
@Component
@RequiredArgsConstructor
@Slf4j
public class TaskSchedule {
private final RedisTemplate redisTemplate;
private final ITaskService taskService;
private final ITaskUserService taskUserService;
private final RedisKeyConfig redisKeyConfig;
private final IMessageClient messageClient;
@Value("${hzims.inspect.task.templateCode.taskEnd}")
private String taskEndTemplateCode;
@XxlJob(TASK_END_REMIND)
public ReturnT<String> sendTaskEndMessage(String params) {
Set<TaskEntity> remindTasks = redisTemplate.opsForZSet().rangeByScore(redisKeyConfig.getTaskEndRemind(),
LocalDateTime.of(LocalDate.now(), LocalTime.MIN).toEpochSecond(ZoneOffset.of("+8")),
LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8")));
if(CollectionUtil.isEmpty(remindTasks)) {
return new ReturnT(ReturnT.SUCCESS_CODE,"当前无待发送消息的任务");
}
// 获取redis待推送巡检任务中状态为进行中的任务
List<Long> idList = remindTasks.stream().map(TaskEntity::getId).collect(Collectors.toList());
List<TaskEntity> taskList = taskService.list(
Wrappers.<TaskEntity>lambdaQuery()
.in(TaskEntity::getId, idList)
.in(TaskEntity::getStatus, Lists.newArrayList(TaskContants.TaskStatusEnum.UNDERWAY_STATUS.getStatus(),TaskContants.TaskStatusEnum.INIT_STATUS.getStatus()))
);
Map<Long, List<TaskUserEntity>> taskUserMap = taskUserService.list(Wrappers.<TaskUserEntity>lambdaQuery().in(TaskUserEntity::getTaskId,idList)).stream().collect(Collectors.groupingBy(TaskUserEntity::getTaskId));
taskList.stream().filter(task -> taskUserMap.containsKey(task.getId())).flatMap(task ->
taskUserMap.get(task.getId()).stream().filter(taskUser -> Func.isNotEmpty(taskUser.getUserId())).map(taskUser -> {
task.setUserId(taskUser.getUserId());
return task;
})
).forEach(this::sendTaskEndMessage);
redisTemplate.opsForZSet().remove(redisKeyConfig.getTaskEndRemind(),remindTasks.toArray(new TaskEntity[remindTasks.size()]));
return ReturnT.SUCCESS;
}
/**
* 推送消息
* @param taskEntity 巡检任务
*/
private void sendTaskEndMessage(TaskEntity taskEntity) {
// 短信推送
SmsImmediatelyPushDTO smsPush = SmsImmediatelyPushDTO.builder()
.deptId(taskEntity.getCreateDept())
.taskId(taskEntity.getId())
.businessKey("巡检任务结束提醒")
.businessClassify(MessageConstants.BusinessClassifyEnum.INSPECT.getKey())
.content("您有一条未执行的任务【"+taskEntity.getPlanName()+"】将于"+ DateUtil.format(taskEntity.getPlanEndTime(),DateUtil.PATTERN_DATETIME)+"截止,请及时处理!")
.subject("巡检任务结束提醒")
.pusher(taskEntity.getUserId().toString())
.createUser(taskEntity.getCreateUser())
.tenantId(taskEntity.getTenantId())
.resourceCode(taskEndTemplateCode)
.params(new HashMap<String,String>(){{
put("one",taskEntity.getPlanName());
put("two",DateUtil.format(taskEntity.getPlanEndTime(),DateUtil.PATTERN_DATETIME));
}})
.build();
messageClient.sendSmsImmediatelyMsg(smsPush);
// app推送
BusinessMessageDTO appMessage = new BusinessMessageDTO();
appMessage.setDeptId(taskEntity.getCreateDept());
appMessage.setBusinessKey("巡检任务结束提醒");
appMessage.setBusinessClassify(MessageConstants.BusinessClassifyEnum.INSPECT.getKey());
appMessage.setContent("您有一条未执行的任务【"+taskEntity.getPlanName()+"】将于"+ DateUtil.format(taskEntity.getPlanEndTime(),DateUtil.PATTERN_DATETIME)+"截止,请及时处理!");
appMessage.setTaskId(taskEntity.getId());
appMessage.setSubject("巡检任务结束提醒");
appMessage.setUserIds(taskEntity.getUserId().toString());
appMessage.setCreateUser(taskEntity.getCreateUser());
appMessage.setTenantId(taskEntity.getTenantId());
messageClient.sendAppAndWsMsgByUsers(appMessage);
taskService.update(Wrappers.<TaskEntity>lambdaUpdate().set(TaskEntity::getEndRemindFlag,true).eq(TaskEntity::getId,taskEntity.getId()));
}
}

11
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/XxlJobConstants.java

@ -0,0 +1,11 @@
package com.hnac.hzinfo.inspect.task.schedule;
/**
* XxlJob常量池
*/
public interface XxlJobConstants {
/**巡检任务结束提醒**/
String TASK_END_REMIND = "taskEndRemind";
}

58
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskObjectProjectContentServiceImpl.java

@ -5,6 +5,9 @@ import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.feign.IStationClient; import com.hnac.hzims.operational.station.feign.IStationClient;
import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient;
import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData;
import com.hnac.hzinfo.datasearch.real.po.RealDataSearchPO;
import com.hnac.hzinfo.inspect.obj.entity.ContentEntity; import com.hnac.hzinfo.inspect.obj.entity.ContentEntity;
import com.hnac.hzinfo.inspect.obj.services.ContentService; import com.hnac.hzinfo.inspect.obj.services.ContentService;
import com.hnac.hzinfo.inspect.task.vo.TaskObjectProjectContentVO; import com.hnac.hzinfo.inspect.task.vo.TaskObjectProjectContentVO;
@ -16,6 +19,7 @@ import com.hnac.hzinfo.inspect.task.entity.TaskObjectProjectContentEntity;
import com.hnac.hzinfo.inspect.task.mapper.TaskObjectProjectContentMapper; import com.hnac.hzinfo.inspect.task.mapper.TaskObjectProjectContentMapper;
import com.hnac.hzinfo.inspect.task.service.ITaskObjectProjectContentService; import com.hnac.hzinfo.inspect.task.service.ITaskObjectProjectContentService;
import org.springblade.core.tool.api.R; 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.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;
@ -38,6 +42,7 @@ import java.util.Optional;
public class TaskObjectProjectContentServiceImpl extends BaseServiceImpl<TaskObjectProjectContentMapper, TaskObjectProjectContentEntity> implements ITaskObjectProjectContentService { public class TaskObjectProjectContentServiceImpl extends BaseServiceImpl<TaskObjectProjectContentMapper, TaskObjectProjectContentEntity> implements ITaskObjectProjectContentService {
private final ContentService contentService; private final ContentService contentService;
private final IAnalyseDataSearchClient analyseDataSearchClient;
private final IStationClient stationClient; private final IStationClient stationClient;
private final RedisClient redisClient; private final RedisClient redisClient;
@ -50,25 +55,46 @@ public class TaskObjectProjectContentServiceImpl extends BaseServiceImpl<TaskObj
public void fillRealData(TaskObjectProjectContentVO contentVO) { public void fillRealData(TaskObjectProjectContentVO contentVO) {
if(Func.isNotEmpty(contentVO.getContentId())) { if(Func.isNotEmpty(contentVO.getContentId())) {
ContentEntity content = contentService.getById(contentVO.getContentId()); ContentEntity content = contentService.getById(contentVO.getContentId());
if(ObjectUtil.isNotEmpty(content) && Func.isNotEmpty(content.getFacDeviceId())) { // 若内容中不存在模型的属性标识 则不获取实时数据
// 获取该项内容站点信息 if(Func.isNotEmpty(content.getAttrSignage()) && Func.isNotEmpty(contentVO.getEmCode())) {
StationEntity station = new StationEntity(); RealDataSearchPO po = new RealDataSearchPO();
station.setRefDept(content.getCreateDept()); po.setAnalyzeCode(contentVO.getEmCode());
R<StationEntity> stationR = stationClient.getOne(station); po.setSignages(Lists.newArrayList(content.getAttrSignage()));
if(stationR.isSuccess() && ObjectUtil.isNotEmpty(stationR.getData())) { R<List<FieldsData>> realDataByAnalyzeCode = analyseDataSearchClient.getRealDataByAnalyzeCode(po);
// 获取任务巡检内容实时数据 if(realDataByAnalyzeCode.isSuccess() && CollectionUtil.isNotEmpty(realDataByAnalyzeCode.getData()) && realDataByAnalyzeCode.getData().get(0).getQ() == 0) {
List<String> realDate = redisClient.getBatchRealDataByRealId(stationR.getData().getCode(), Lists.newArrayList(content.getFacDeviceId())); FieldsData realData = realDataByAnalyzeCode.getData().get(0);
log.info("station:{},facDeviceId:{},实时数据:{}",stationR.getData().getCode(),content.getFacDeviceId(), JSON.toJSONString(realDate)); contentVO.setRealData(realData.getValue());
JSONObject realDataObject = Optional.ofNullable(realDate).map(list -> list.get(0)).filter(StringUtil::isNotBlank).map(JSONObject::parseObject).orElse(null);
// q值为0时为有效值
if(ObjectUtil.isNotEmpty(realDataObject) && realDataObject.getIntValue("q") == 0) {
contentVO.setRealData(realDataObject.getDoubleValue("v"));
contentVO.setGatherTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(realDataObject.getLongValue("ts")), ZoneId.systemDefault()));
contentVO.setAttrSignage(content.getAttrSignage());
contentVO.setAttrName(content.getAttrName()); contentVO.setAttrName(content.getAttrName());
contentVO.setAttrSignage(content.getAttrSignage());
contentVO.setGatherTime(realData.getTime());
} }
} }
} }
} }
}
// @Override
// public void fillRealData(TaskObjectProjectContentVO contentVO) {
// if(Func.isNotEmpty(contentVO.getContentId())) {
// ContentEntity content = contentService.getById(contentVO.getContentId());
// if(ObjectUtil.isNotEmpty(content) && Func.isNotEmpty(content.getFacDeviceId())) {
// // 获取该项内容站点信息
// StationEntity station = new StationEntity();
// station.setRefDept(content.getCreateDept());
// R<StationEntity> stationR = stationClient.getOne(station);
// if(stationR.isSuccess() && ObjectUtil.isNotEmpty(stationR.getData())) {
// // 获取任务巡检内容实时数据
// List<String> realDate = redisClient.getBatchRealDataByRealId(stationR.getData().getCode(), Lists.newArrayList(content.getFacDeviceId()));
// log.info("station:{},facDeviceId:{},实时数据:{}",stationR.getData().getCode(),content.getFacDeviceId(), JSON.toJSONString(realDate));
// JSONObject realDataObject = Optional.ofNullable(realDate).map(list -> list.get(0)).filter(StringUtil::isNotBlank).map(JSONObject::parseObject).orElse(null);
// // q值为0时为有效值
// if(ObjectUtil.isNotEmpty(realDataObject) && realDataObject.getIntValue("q") == 0) {
// contentVO.setRealData(realDataObject.getDoubleValue("v"));
// contentVO.setGatherTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(realDataObject.getLongValue("ts")), ZoneId.systemDefault()));
// contentVO.setAttrSignage(content.getAttrSignage());
// contentVO.setAttrName(content.getAttrName());
// }
// }
// }
// }
// }
} }

14
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskObjectServiceImpl.java

@ -1,5 +1,7 @@
package com.hnac.hzinfo.inspect.task.service.impl; package com.hnac.hzinfo.inspect.task.service.impl;
import com.hnac.hzinfo.inspect.obj.entity.ProjectEntity;
import com.hnac.hzinfo.inspect.obj.services.ProjectService;
import com.hnac.hzinfo.inspect.task.entity.TaskObjectEntity; import com.hnac.hzinfo.inspect.task.entity.TaskObjectEntity;
import com.hnac.hzinfo.inspect.task.mapper.TaskObjectMapper; import com.hnac.hzinfo.inspect.task.mapper.TaskObjectMapper;
import com.hnac.hzinfo.inspect.task.service.ITaskObjectProjectContentService; import com.hnac.hzinfo.inspect.task.service.ITaskObjectProjectContentService;
@ -25,6 +27,7 @@ import java.util.List;
public class TaskObjectServiceImpl extends BaseServiceImpl<TaskObjectMapper, TaskObjectEntity> implements ITaskObjectService { public class TaskObjectServiceImpl extends BaseServiceImpl<TaskObjectMapper, TaskObjectEntity> implements ITaskObjectService {
private final ITaskObjectProjectContentService taskContentService; private final ITaskObjectProjectContentService taskContentService;
private final ProjectService projectService;
@Override @Override
public List<TaskObjectEntity> getTaskObjectList(TaskObjectEntity taskObjectEntity) { public List<TaskObjectEntity> getTaskObjectList(TaskObjectEntity taskObjectEntity) {
@ -38,9 +41,14 @@ public class TaskObjectServiceImpl extends BaseServiceImpl<TaskObjectMapper, Tas
taskObjectVOList.stream() taskObjectVOList.stream()
.filter(taskObjectVO -> CollectionUtil.isNotEmpty(taskObjectVO.getProjects())) .filter(taskObjectVO -> CollectionUtil.isNotEmpty(taskObjectVO.getProjects()))
.flatMap(taskObjectVO -> taskObjectVO.getProjects().stream()) .flatMap(taskObjectVO -> taskObjectVO.getProjects().stream())
.filter(project -> CollectionUtil.isNotEmpty(project.getContents())) .filter(taskObjectVO -> Func.isNotEmpty(taskObjectVO.getProjectId()) && CollectionUtil.isNotEmpty(taskObjectVO.getContents()))
.flatMap(project -> project.getContents().stream()) .flatMap(project -> {
.forEach(contentVO -> taskContentService.fillRealData(contentVO)); ProjectEntity projectEntity = projectService.getById(project.getProjectId());
if(Func.isEmpty(projectEntity) && Func.isNotEmpty(projectEntity.getEmCode())) {
return null;
}
return project.getContents().stream().peek(contentVO -> contentVO.setEmCode(projectEntity.getEmCode()));
}).filter(Func::isNotEmpty).forEach(contentVO -> taskContentService.fillRealData(contentVO));
} }
return taskObjectVOList; return taskObjectVOList;
} }

10
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/vo/TaskObjectProjectContentVO.java

@ -121,16 +121,18 @@ public class TaskObjectProjectContentVO implements Serializable {
private String dictType; private String dictType;
@ApiModelProperty(value = "实时数据") @ApiModelProperty(value = "实时数据")
private Double realData; private String realData;
@ApiModelProperty(value = "实时数据采集时间") @ApiModelProperty(value = "实时数据采集时间")
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME) private String gatherTime;
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
private LocalDateTime gatherTime;
@ApiModelProperty(value = "绑定物模型属性标识") @ApiModelProperty(value = "绑定物模型属性标识")
private String attrSignage; private String attrSignage;
@ApiModelProperty(value = "绑定物模型属性名称") @ApiModelProperty(value = "绑定物模型属性名称")
private String attrName; private String attrName;
@ApiModelProperty(value = "设备编号")
private String emCode;
} }

3
hzims-service/inspect/src/main/resources/application-dev.yml

@ -50,6 +50,9 @@ hzinfo:
hzims: hzims:
redis:
key:
taskEndRemind: 200000:hzims:inspect:task:end:remind
tasks: tasks:
flag: 1 flag: 1
inspect: inspect:

3
hzims-service/inspect/src/main/resources/application-prod.yml

@ -25,6 +25,9 @@ oss:
secret-key: fjcR2RoQxZ4eTmOaB54rkITZjn/YVJhJZlckHxy/ secret-key: fjcR2RoQxZ4eTmOaB54rkITZjn/YVJhJZlckHxy/
hzims: hzims:
redis:
key:
taskEndRemind: hzims:inspect:task:end:remind
tasks: tasks:
flag: 1 flag: 1
inspect: inspect:

17
hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java

@ -22,6 +22,8 @@ import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.*; import org.springblade.core.tool.utils.*;
import org.springblade.system.entity.Dept;
import org.springblade.system.feign.ISysClient;
import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.cache.UserCache;
import org.springblade.system.user.entity.User; import org.springblade.system.user.entity.User;
import org.springframework.util.Assert; import org.springframework.util.Assert;
@ -46,6 +48,7 @@ public class MessageClient extends BladeController implements IMessageClient{
private final IMessagePushRecordService recordService; private final IMessagePushRecordService recordService;
private final IMessageTemplateService messageTemplateService; private final IMessageTemplateService messageTemplateService;
private final ISysClient sysClient;
@Override @Override
@PostMapping(SEND_SMS_MESSAGE) @PostMapping(SEND_SMS_MESSAGE)
@ -61,6 +64,7 @@ public class MessageClient extends BladeController implements IMessageClient{
// 可能存在多种推送类型 // 可能存在多种推送类型
request.getTypes().forEach(type -> { request.getTypes().forEach(type -> {
MessagePushRecordEntity entity = BeanUtil.copy(request,MessagePushRecordEntity.class); MessagePushRecordEntity entity = BeanUtil.copy(request,MessagePushRecordEntity.class);
entity.setDeptName(Func.isNotEmpty(entity.getDeptName()) ? entity.getDeptName() : this.getDeptNameById(entity.getDeptId()));
entity.setType(type); entity.setType(type);
if(Func.isEmpty(AuthUtil.getUserId())) { if(Func.isEmpty(AuthUtil.getUserId())) {
entity.setCreateUser(request.getCreateUser()); entity.setCreateUser(request.getCreateUser());
@ -83,6 +87,7 @@ public class MessageClient extends BladeController implements IMessageClient{
// 微信消息推送记录保存 // 微信消息推送记录保存
List<MessagePushRecordEntity> messages = Func.toLongList(request.getUserIds()).stream().map(userId -> { List<MessagePushRecordEntity> messages = Func.toLongList(request.getUserIds()).stream().map(userId -> {
MessagePushRecordEntity entity = BeanUtil.copy(request, MessagePushRecordEntity.class); MessagePushRecordEntity entity = BeanUtil.copy(request, MessagePushRecordEntity.class);
entity.setDeptName(Func.isNotEmpty(entity.getDeptName()) ? entity.getDeptName() : this.getDeptNameById(entity.getDeptId()));
entity.setMessageId(IdWorker.getId()); entity.setMessageId(IdWorker.getId());
entity.setPusher(userId.toString()); entity.setPusher(userId.toString());
entity.setPusherName(Optional.ofNullable(UserCache.getUser(userId)).map(User::getName).orElse(null)); entity.setPusherName(Optional.ofNullable(UserCache.getUser(userId)).map(User::getName).orElse(null));
@ -111,6 +116,7 @@ public class MessageClient extends BladeController implements IMessageClient{
if(Func.isNotEmpty(template.getType())) { if(Func.isNotEmpty(template.getType())) {
Func.toStrList(",",template.getType()).forEach(type -> { Func.toStrList(",",template.getType()).forEach(type -> {
MessagePushRecordEntity entity = BeanUtil.copy(template,MessagePushRecordEntity.class); MessagePushRecordEntity entity = BeanUtil.copy(template,MessagePushRecordEntity.class);
entity.setDeptName(Func.isNotEmpty(entity.getDeptName()) ? entity.getDeptName() : this.getDeptNameById(entity.getDeptId()));
entity.setId(null); entity.setId(null);
entity.setType(type); entity.setType(type);
entity.setTaskId(request.getTaskId()); entity.setTaskId(request.getTaskId());
@ -146,6 +152,7 @@ public class MessageClient extends BladeController implements IMessageClient{
long messageId = IdWorker.getId(); long messageId = IdWorker.getId();
return Lists.newArrayList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH).stream().map(messageType -> { return Lists.newArrayList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH).stream().map(messageType -> {
MessagePushRecordEntity record = BeanUtil.copy(request, MessagePushRecordEntity.class); MessagePushRecordEntity record = BeanUtil.copy(request, MessagePushRecordEntity.class);
record.setDeptName(Func.isNotEmpty(record.getDeptName()) ? record.getDeptName() : this.getDeptNameById(record.getDeptId()));
record.setMessageId(messageId); record.setMessageId(messageId);
record.setPusher(userId.toString()); record.setPusher(userId.toString());
record.setPusherName(Optional.ofNullable(UserCache.getUser(userId)).map(User::getName).orElse(null)); record.setPusherName(Optional.ofNullable(UserCache.getUser(userId)).map(User::getName).orElse(null));
@ -180,6 +187,7 @@ public class MessageClient extends BladeController implements IMessageClient{
String pusherName = Optional.ofNullable(smsImmediatelyPushDTO.getPusher()).map(Func::toLong).map(UserCache::getUser).map(User::getName).orElse(null); String pusherName = Optional.ofNullable(smsImmediatelyPushDTO.getPusher()).map(Func::toLong).map(UserCache::getUser).map(User::getName).orElse(null);
record.setPusherName(pusherName); record.setPusherName(pusherName);
record.setPushType(MessageConstants.IMMEDIATELY); record.setPushType(MessageConstants.IMMEDIATELY);
record.setDeptName(Func.isNotEmpty(record.getDeptName()) ? record.getDeptName() : this.getDeptNameById(record.getDeptId()));
record.setPlanTime(LocalDateTime.now()); record.setPlanTime(LocalDateTime.now());
record.setType(MessageConstants.SMS_PUSH); record.setType(MessageConstants.SMS_PUSH);
record.setCreateDept(record.getDeptId()); record.setCreateDept(record.getDeptId());
@ -189,4 +197,13 @@ public class MessageClient extends BladeController implements IMessageClient{
return R.data(recordService.sendSmsImmediatelyMsg(record)); return R.data(recordService.sendSmsImmediatelyMsg(record));
} }
/**
* 根据机构ID获取机构名称
* @param deptId 机构ID
* @return 机构名称
*/
private String getDeptNameById(Long deptId) {
return Optional.ofNullable(sysClient.getDeptName(deptId)).filter(r -> r.isSuccess()).map(R::getData).orElse(null);
}
} }

2
hzims-service/message/src/main/java/com/hnac/hzims/message/schedule/MessagePushSchedule.java

@ -111,7 +111,7 @@ public class MessagePushSchedule {
} }
}); });
} }
// redisTemplate.opsForList().remove(appPushKey,0,records); records.forEach(record -> redisTemplate.opsForList().remove(appPushKey,0,record));
} }
}); });
return ReturnT.SUCCESS; return ReturnT.SUCCESS;

5
hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessagePushRecordService.java

@ -128,5 +128,10 @@ public interface IMessagePushRecordService extends BaseService<MessagePushRecord
*/ */
UserPushStatTypeResponseVo newUserPushStat(MessagePushRecordEntityVo vo); UserPushStatTypeResponseVo newUserPushStat(MessagePushRecordEntityVo vo);
/**
* 推送即时短信
* @param record 短信内容
* @return 推送结果
*/
Boolean sendSmsImmediatelyMsg(MessagePushRecordEntity record); Boolean sendSmsImmediatelyMsg(MessagePushRecordEntity record);
} }

4
hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java

@ -365,7 +365,7 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl<MessagePushRec
public List<UnreadMessageVO> getPersonalUnreadMessage() { public List<UnreadMessageVO> getPersonalUnreadMessage() {
QueryWrapper<MessagePushRecordEntity> query = Wrappers.query(); QueryWrapper<MessagePushRecordEntity> query = Wrappers.query();
query.select("business_classify businessClassify,count(0) todoNum"); query.select("business_classify businessClassify,count(0) todoNum");
query.eq("account", AuthUtil.getUserId()); query.eq("pusher", AuthUtil.getUserId());
query.in("status", Lists.newArrayList(MessageConstants.PUSH_SUCCESS)); query.in("status", Lists.newArrayList(MessageConstants.PUSH_SUCCESS));
query.groupBy("business_classify"); query.groupBy("business_classify");
List<Map<String, Object>> list = noAurhScopeMapper.selectMaps(query); List<Map<String, Object>> list = noAurhScopeMapper.selectMaps(query);
@ -380,7 +380,7 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl<MessagePushRec
public List<UnreadMessageVO> getPersonalAppUnreadMessage() { public List<UnreadMessageVO> getPersonalAppUnreadMessage() {
QueryWrapper<MessagePushRecordEntity> query = Wrappers.query(); QueryWrapper<MessagePushRecordEntity> query = Wrappers.query();
query.select("business_classify businessClassify,count(0) todoNum"); query.select("business_classify businessClassify,count(0) todoNum");
query.eq("account", AuthUtil.getUserId()); query.eq("pusher", AuthUtil.getUserId());
query.eq("type", MessageConstants.APP_PUSH); query.eq("type", MessageConstants.APP_PUSH);
query.in("status", Lists.newArrayList(MessageConstants.PUSH_SUCCESS)); query.in("status", Lists.newArrayList(MessageConstants.PUSH_SUCCESS));
query.groupBy("business_classify"); query.groupBy("business_classify");

20
hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/controller/HzimsDataController.java

@ -5,11 +5,12 @@ import com.hnac.hzims.operational.data.service.HzimsDataService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.annotation.ApiLog; import org.springblade.core.log.annotation.ApiLog;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import java.util.Map;
/** /**
@ -19,6 +20,7 @@ import org.springframework.web.bind.annotation.RestController;
@AllArgsConstructor @AllArgsConstructor
@RequestMapping("/hzims_data") @RequestMapping("/hzims_data")
@Api(value = "hzims_data", tags = "hzims数据获取") @Api(value = "hzims_data", tags = "hzims数据获取")
@Slf4j
public class HzimsDataController { public class HzimsDataController {
private final HzimsDataService service; private final HzimsDataService service;
@ -44,4 +46,16 @@ public class HzimsDataController {
public R saveStation() { public R saveStation() {
return R.data(service.saveStation()); return R.data(service.saveStation());
} }
/**
* 测试动作模板回调接口
*/
@ApiLog
@PostMapping("/test")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "测试动作模板回调接口", notes = "map接收参数")
public R test(@RequestBody Map<String, Object> params) {
log.error("动作模板回调接口参数: {}",params.toString());
return R.data(params);
}
} }

6
hzims-service/operational/src/main/java/com/hnac/hzims/operational/ecology/controller/EcologyController.java

@ -54,8 +54,8 @@ public class EcologyController extends BladeController {
@PostMapping("/station_top") @PostMapping("/station_top")
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 1)
@ApiOperation(value = "站点数据及达标率排行", notes = "站点数据及达标率排行") @ApiOperation(value = "站点数据及达标率排行", notes = "站点数据及达标率排行")
public R station_top(@RequestParam Long deptId) { public R station_top() {
return R.data(stationService.station_top(deptId)); return R.data(stationService.station_top());
} }
/** /**
@ -65,7 +65,7 @@ public class EcologyController extends BladeController {
@PostMapping("/trend_chart") @PostMapping("/trend_chart")
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 1)
@ApiOperation(value = "指标趋势图", notes = "指标趋势图") @ApiOperation(value = "指标趋势图", notes = "指标趋势图")
public R trend_chart(@RequestParam Long deptId,@RequestParam String type) { public R trend_chart(@RequestParam String type) {
return R.data(stationService.trend_chart(type)); return R.data(stationService.trend_chart(type));
} }

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/ecology/service/EcologyFlowStationService.java

@ -14,7 +14,7 @@ import java.util.List;
*/ */
public interface EcologyFlowStationService extends BaseService<EcologyFlowStationEntity> { public interface EcologyFlowStationService extends BaseService<EcologyFlowStationEntity> {
EcologFlowStationVo station_top(Long deptId); EcologFlowStationVo station_top();
Boolean generate(Long mon,String year); Boolean generate(Long mon,String year);

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/ecology/service/impl/EcologyFlowStationServiceImpl.java

@ -96,7 +96,7 @@ public class EcologyFlowStationServiceImpl extends BaseServiceImpl<EcologyFlowSt
* @return * @return
*/ */
@Override @Override
public EcologFlowStationVo station_top(Long deptId) { public EcologFlowStationVo station_top() {
List<EcologyFlowStationEntity> stations = this.list(); List<EcologyFlowStationEntity> stations = this.list();
if(CollectionUtil.isEmpty(stations)){ if(CollectionUtil.isEmpty(stations)){
return new EcologFlowStationVo(); return new EcologFlowStationVo();

12
hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/WindServiceImpl.java

@ -17,6 +17,8 @@ import com.hnac.hzims.operational.fill.wrapper.GenerateWrapper;
import com.hnac.hzims.operational.fill.wrapper.WindWrapper; import com.hnac.hzims.operational.fill.wrapper.WindWrapper;
import com.hnac.hzims.operational.main.vo.GenerationPowerVo; import com.hnac.hzims.operational.main.vo.GenerationPowerVo;
import com.hnac.hzims.operational.main.vo.PowerMonthVo; import com.hnac.hzims.operational.main.vo.PowerMonthVo;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IStationService;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
@ -45,6 +47,8 @@ import java.util.stream.Collectors;
@AllArgsConstructor @AllArgsConstructor
public class WindServiceImpl extends BaseServiceImpl<WindMapper, WindEntity> implements WindService { public class WindServiceImpl extends BaseServiceImpl<WindMapper, WindEntity> implements WindService {
private final IStationService stationService;
/** /**
* 分页查询风电填报数据 * 分页查询风电填报数据
* @param filter * @param filter
@ -77,6 +81,14 @@ public class WindServiceImpl extends BaseServiceImpl<WindMapper, WindEntity> imp
*/ */
@Override @Override
public boolean saveUpdate(WindEntity entity) { public boolean saveUpdate(WindEntity entity) {
// 查询站点所属机构
StationEntity station = stationService.getOne(new LambdaQueryWrapper<StationEntity>(){{
eq(StationEntity::getCode, entity.getStationCode());
}});
if(ObjectUtil.isEmpty(station)){
throw new ServiceException("风电站点不存在!");
}
entity.setCreateDept(station.getRefDept());
// 查询是否存在历史记录 // 查询是否存在历史记录
WindEntity query = this.getOne(new LambdaQueryWrapper<WindEntity>(){{ WindEntity query = this.getOne(new LambdaQueryWrapper<WindEntity>(){{
eq(WindEntity::getStationCode, entity.getStationCode()); eq(WindEntity::getStationCode, entity.getStationCode());

9
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomeServiceImpl.java

@ -79,6 +79,8 @@ public class HomeServiceImpl implements HomeService {
private final ITicketInfoAllClient ticketClient; private final ITicketInfoAllClient ticketClient;
private final IPlanGenertionClient planClient;
private final RedisTemplate redisTemplate; private final RedisTemplate redisTemplate;
private final static String charge = "hzims:operation:key:charge"; private final static String charge = "hzims:operation:key:charge";
@ -139,7 +141,7 @@ public class HomeServiceImpl implements HomeService {
@Override @Override
public List<StationCountVo> count(boolean make) { public List<StationCountVo> count(boolean make) {
// 查询全部站点 // 查询全部站点
LambdaQueryWrapper<StationEntity> wrapper = Wrappers.<StationEntity>lambdaQuery(); LambdaQueryWrapper<StationEntity> wrapper = Wrappers.lambdaQuery();
if(make){ if(make){
wrapper.ne(StationEntity::getStatus,2); wrapper.ne(StationEntity::getStatus,2);
} }
@ -244,13 +246,16 @@ public class HomeServiceImpl implements HomeService {
if(CollectionUtil.isEmpty(stations)){ if(CollectionUtil.isEmpty(stations)){
return target; return target;
} }
// 计划发电量
List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()),null, DateUtil.format(new Date(),"yyyy"));
// 填报信息
List<WindEntity> winds = windService.list(Wrappers.<WindEntity>lambdaQuery() List<WindEntity> winds = windService.list(Wrappers.<WindEntity>lambdaQuery()
.in(WindEntity::getStationCode, stations.stream().map(StationEntity::getCode).collect(Collectors.toList())) .in(WindEntity::getStationCode, stations.stream().map(StationEntity::getCode).collect(Collectors.toList()))
.likeRight(WindEntity::getFillDate, DateUtil.format(new Date(),"yyyy"))); .likeRight(WindEntity::getFillDate, DateUtil.format(new Date(),"yyyy")));
if(CollectionUtil.isEmpty(winds)){ if(CollectionUtil.isEmpty(winds)){
return target; return target;
} }
double plan = winds.stream().mapToDouble(WindEntity::getPlan).sum(); double plan = plans.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum();
double power = winds.stream().mapToDouble(WindEntity::getPower).sum(); double power = winds.stream().mapToDouble(WindEntity::getPower).sum();
List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_final).toString(), new TypeReference<List<EminfoAndEmParamVo>>() {}); List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_final).toString(), new TypeReference<List<EminfoAndEmParamVo>>() {});
// 装机容量 // 装机容量

56
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WindHomeServiceImpl.java

@ -5,6 +5,8 @@ import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.hnac.hzims.equipment.entity.PlanGenerationEntity;
import com.hnac.hzims.equipment.feign.IPlanGenertionClient;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.hzimsweather.response.weather.Daily; import com.hnac.hzims.hzimsweather.response.weather.Daily;
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse; import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse;
@ -92,6 +94,7 @@ public class WindHomeServiceImpl implements WindHomeService {
private final ITicketInfoClient ticketInfoClient; private final ITicketInfoClient ticketInfoClient;
private final IPlanGenertionClient planClient;
private final IInspectTaskReportClient inspectTaskReportClient; private final IInspectTaskReportClient inspectTaskReportClient;
@ -130,7 +133,8 @@ public class WindHomeServiceImpl implements WindHomeService {
// 年发电量 // 年发电量
score.setGenerateYear(winds.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy"))).mapToDouble(WindEntity::getPower).sum()); score.setGenerateYear(winds.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy"))).mapToDouble(WindEntity::getPower).sum());
// 年计划发电量 // 年计划发电量
score.setPlanYear(winds.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy"))).mapToDouble(WindEntity::getPlan).sum()); List<PlanGenerationEntity> yearPlans = planClient.getPlanGenerationByParam(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()),null,DateUtil.format(new Date(),"yyyy"));
score.setPlanYear(yearPlans.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum());
// 年发电完成率 // 年发电完成率
if(Math.abs(score.getGenerateYear()) > 0 && Math.abs(score.getPlanYear()) > 0){ if(Math.abs(score.getGenerateYear()) > 0 && Math.abs(score.getPlanYear()) > 0){
score.setCompleteRate(BigDecimal.valueOf(score.getGenerateYear() / score.getPlanYear() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); score.setCompleteRate(BigDecimal.valueOf(score.getGenerateYear() / score.getPlanYear() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
@ -138,7 +142,7 @@ public class WindHomeServiceImpl implements WindHomeService {
// 月发电量 // 月发电量
score.setGenerateMon(winds.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(WindEntity::getPower).sum()); score.setGenerateMon(winds.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(WindEntity::getPower).sum());
// 月计划发电量 // 月计划发电量
score.setPlanMon(winds.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(WindEntity::getPlan).sum()); score.setPlanMon(yearPlans.stream().filter(o->o.getDateTime().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum());
// 月发电量完成率 // 月发电量完成率
if(Math.abs(score.getGenerateMon()) > 0 && Math.abs(score.getPlanMon()) > 0){ if(Math.abs(score.getGenerateMon()) > 0 && Math.abs(score.getPlanMon()) > 0){
score.setCompleteMonRate(BigDecimal.valueOf(score.getGenerateMon() / score.getPlanMon() * 100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue()); score.setCompleteMonRate(BigDecimal.valueOf(score.getGenerateMon() / score.getPlanMon() * 100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
@ -191,12 +195,13 @@ public class WindHomeServiceImpl implements WindHomeService {
*/ */
private List<PowerMonthVo> currentGenerateCurve(List<WindEntity> winds) { private List<PowerMonthVo> currentGenerateCurve(List<WindEntity> winds) {
List<String> mons = this.mons(0,12,false); List<String> mons = this.mons(0,12,false);
List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(winds.stream().map(WindEntity::getStationCode).distinct().collect(Collectors.toList()), null,DateUtil.format(new Date(),"yyyy"));
return mons.stream().map(mon->{ return mons.stream().map(mon->{
PowerMonthVo power = new PowerMonthVo(); PowerMonthVo power = new PowerMonthVo();
LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), mon), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), mon), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE));
power.setYear(localDate.getYear()); power.setYear(localDate.getYear());
power.setStrMonth(localDate.getMonthValue() > 9 ? String.valueOf(localDate.getMonthValue()) : "0" + localDate.getMonthValue()); power.setStrMonth(localDate.getMonthValue() > 9 ? String.valueOf(localDate.getMonthValue()) : "0" + localDate.getMonthValue());
power.setPlanPower((float) winds.stream().filter(o->o.getFillDate().contains(localDate.getYear() + "-" + power.getStrMonth())).mapToDouble(WindEntity::getPlan).sum()); power.setPlanPower((float) plans.stream().filter(o->o.getDateTime().contains(power.getYear() + "-" + power.getStrMonth())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum());
power.setPower((float) winds.stream().filter(o->o.getFillDate().contains(localDate.getYear() + "-" + power.getStrMonth())).mapToDouble(WindEntity::getPower).sum()); power.setPower((float) winds.stream().filter(o->o.getFillDate().contains(localDate.getYear() + "-" + power.getStrMonth())).mapToDouble(WindEntity::getPower).sum());
return power; return power;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
@ -256,23 +261,33 @@ public class WindHomeServiceImpl implements WindHomeService {
// 集团发电占比 // 集团发电占比
if(Math.abs(subordinate.getGeneration()) > 0 && Math.abs(winds.stream().mapToDouble(WindEntity::getPower).sum()) > 0){ if(Math.abs(subordinate.getGeneration()) > 0 && Math.abs(winds.stream().mapToDouble(WindEntity::getPower).sum()) > 0){
subordinate.setGenerationRate(BigDecimal.valueOf(subordinate.getGeneration() / winds.stream().mapToDouble(WindEntity::getPower).sum() * 100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue()); subordinate.setGenerationRate(BigDecimal.valueOf(subordinate.getGeneration() / winds.stream().mapToDouble(WindEntity::getPower).sum() * 100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
}else{
subordinate.setGenerationRate(0.0);
} }
// 计划发电量查询
List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(entry.getValue().stream().map(StationEntity::getCode).collect(Collectors.toList()), null,DateUtil.format(new Date(),"yyyy"));
double plan = plans.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum();
// 发电完成率 // 发电完成率
double plan = piece.stream().mapToDouble(WindEntity::getPlan).sum();
if(Math.abs(subordinate.getGeneration()) > 0 && Math.abs(plan) > 0){ if(Math.abs(subordinate.getGeneration()) > 0 && Math.abs(plan) > 0){
subordinate.setGenerationComplete(BigDecimal.valueOf(subordinate.getGeneration() / plan * 100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue()); subordinate.setGenerationComplete(BigDecimal.valueOf(subordinate.getGeneration() / plan * 100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
}else{
subordinate.setGenerationComplete(0.0);
} }
// 风机利用率 : (总时间 - 故障时间) / 总时间 // 风机利用率 : (总时间 - 故障时间) / 总时间
double fault = piece.stream().mapToDouble(WindEntity::getFaultHours).sum(); double fault = piece.stream().mapToDouble(WindEntity::getFaultHours).sum();
double use = piece.stream().mapToDouble(WindEntity::getAvailable).sum(); double use = piece.stream().mapToDouble(WindEntity::getAvailable).sum();
if(Math.abs(fault) > 0 ){ if(Math.abs(fault) > 0 ){
subordinate.setFanUse(BigDecimal.valueOf(use / (use + fault) * 100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue()); subordinate.setFanUse(BigDecimal.valueOf(use / (use + fault) * 100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
}else{
subordinate.setFanUse(0.0);
} }
// 厂用电率 : (发电量-上网电量+下网电量)/发电量 // 厂用电率 : (发电量-上网电量+下网电量)/发电量
double surf = piece.stream().mapToDouble(WindEntity::getSurfPower).sum(); double surf = piece.stream().mapToDouble(WindEntity::getSurfPower).sum();
double below = piece.stream().mapToDouble(WindEntity::getBelowPower).sum(); double below = piece.stream().mapToDouble(WindEntity::getBelowPower).sum();
if(Math.abs(subordinate.getGeneration()) > 0 && Math.abs(surf + below) > 0){ if(Math.abs(subordinate.getGeneration()) > 0 && Math.abs(surf + below) > 0){
subordinate.setFactoryUse(BigDecimal.valueOf((subordinate.getGeneration() - surf + below) / subordinate.getGeneration() * 100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue()); subordinate.setFactoryUse(BigDecimal.valueOf((subordinate.getGeneration() - surf + below) / subordinate.getGeneration() * 100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
}else{
subordinate.setFactoryUse(0.0);
} }
} }
return subordinate; return subordinate;
@ -311,9 +326,9 @@ public class WindHomeServiceImpl implements WindHomeService {
} }
// 装机容量 // 装机容量
kpi.setCapacity(devices.stream().filter(o->stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(o.getCreateDept())).mapToDouble(EminfoAndEmParamVo::getInstalledCapacity).sum()); kpi.setCapacity(devices.stream().filter(o->stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(o.getCreateDept())).mapToDouble(EminfoAndEmParamVo::getInstalledCapacity).sum());
// 计划发电量 // 计划发电量
kpi.setPlan(winds.stream().mapToDouble(WindEntity::getPlan).sum()); List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), null,DateUtil.format(new Date(),"yyyy"));
kpi.setPlan(plans.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum());
// 实际发电量 // 实际发电量
kpi.setGenerate(winds.stream().mapToDouble(WindEntity::getPower).sum()); kpi.setGenerate(winds.stream().mapToDouble(WindEntity::getPower).sum());
// 发电量完成率 // 发电量完成率
@ -366,12 +381,14 @@ public class WindHomeServiceImpl implements WindHomeService {
in(WindEntity::getStationCode,codes) in(WindEntity::getStationCode,codes)
.like(WindEntity::getFillDate,DateUtil.format(new Date(),"yyyy")); .like(WindEntity::getFillDate,DateUtil.format(new Date(),"yyyy"));
}}); }});
// 计划发电量
List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(codes, null,DateUtil.format(new Date(),"yyyy"));
return areas.entrySet().stream().map(entry -> { return areas.entrySet().stream().map(entry -> {
WindAreaVo area = new WindAreaVo(); WindAreaVo area = new WindAreaVo();
area.setDeptId(entry.getKey().getId()); area.setDeptId(entry.getKey().getId());
area.setDeptName(entry.getKey().getDeptName()); area.setDeptName(entry.getKey().getDeptName());
List<String> stationCodes = entry.getValue().stream().map(StationEntity::getCode).collect(Collectors.toList()); List<String> stationCodes = entry.getValue().stream().map(StationEntity::getCode).collect(Collectors.toList());
area.setPlan(winds.stream().filter(o-> stationCodes.contains(o.getStationCode())).mapToDouble(WindEntity::getPlan).sum()); area.setPlan(plans.stream().filter(o-> stationCodes.contains(o.getStationId())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum());
area.setGenerate(winds.stream().filter(o-> stationCodes.contains(o.getStationCode())).mapToDouble(WindEntity::getPower).sum()); area.setGenerate(winds.stream().filter(o-> stationCodes.contains(o.getStationCode())).mapToDouble(WindEntity::getPower).sum());
if(Math.abs(area.getPlan()) > 0 && Math.abs(area.getGenerate()) > 0){ if(Math.abs(area.getPlan()) > 0 && Math.abs(area.getGenerate()) > 0){
area.setGenerateComplete(BigDecimal.valueOf(area.getGenerate() / area.getPlan() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); area.setGenerateComplete(BigDecimal.valueOf(area.getGenerate() / area.getPlan() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
@ -495,24 +512,27 @@ public class WindHomeServiceImpl implements WindHomeService {
areaDuty.setSpeed(winds.stream().mapToDouble(WindEntity::getSpeed).average().orElse(0.0)); areaDuty.setSpeed(winds.stream().mapToDouble(WindEntity::getSpeed).average().orElse(0.0));
areaDuty.setSurfPower(winds.stream().mapToDouble(WindEntity::getSurfPower).sum()); areaDuty.setSurfPower(winds.stream().mapToDouble(WindEntity::getSurfPower).sum());
areaDuty.setBelowPower(winds.stream().mapToDouble(WindEntity::getBelowPower).sum()); areaDuty.setBelowPower(winds.stream().mapToDouble(WindEntity::getBelowPower).sum());
areaDuty.setAvailable(winds.stream().mapToDouble(WindEntity::getAvailable).average().orElse(0.0)); areaDuty.setAvailable(winds.stream().mapToDouble(WindEntity::getAvailable).sum());
areaDuty.setComprehensivePower(winds.stream().mapToDouble(WindEntity::getComprehensivePower).sum()); areaDuty.setComprehensivePower(winds.stream().mapToDouble(WindEntity::getComprehensivePower).sum());
areaDuty.setPeakPower(winds.stream().mapToDouble(WindEntity::getPeakPower).average().orElse(0.0)); areaDuty.setPeakPower(winds.stream().mapToDouble(WindEntity::getPeakPower).average().orElse(0.0));
areaDuty.setFaultHours(winds.stream().mapToDouble(WindEntity::getFaultHours).average().orElse(0.0)); areaDuty.setFaultHours(winds.stream().mapToDouble(WindEntity::getFaultHours).average().orElse(0.0));
} }
// 填报发电量
List<WindEntity> windMons = windService.list(new LambdaQueryWrapper<WindEntity>() {{ List<WindEntity> windMons = windService.list(new LambdaQueryWrapper<WindEntity>() {{
in(WindEntity::getStationCode,stations.stream().map(StationEntity::getCode).collect(Collectors.toList())) in(WindEntity::getStationCode,stations.stream().map(StationEntity::getCode).collect(Collectors.toList()))
.like(WindEntity::getFillDate,DateUtil.format(new Date(),"yyyy-MM")); .like(WindEntity::getFillDate,DateUtil.format(new Date(),"yyyy-MM"));
}}); }});
// 计划发电量
List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), null,DateUtil.format(new Date(),"yyyy-MM"));
if(CollectionUtil.isNotEmpty(windMons)){ if(CollectionUtil.isNotEmpty(windMons)){
areaDuty.setGenerateMon(windMons.stream().mapToDouble(WindEntity::getPower).sum()); areaDuty.setGenerateMon(windMons.stream().mapToDouble(WindEntity::getPower).sum());
// 月计划发电量 // 月计划发电量
areaDuty.setPlanMon(windMons.stream().mapToDouble(WindEntity::getPlan).sum()); areaDuty.setPlanMon(plans.stream().filter(o->o.getDateTime().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum());
// 月发电量完成率 // 月发电量完成率
if(Math.abs(areaDuty.getGenerateMon()) > 0 && Math.abs(areaDuty.getPlanMon()) > 0){ if(Math.abs(areaDuty.getGenerateMon()) > 0 && Math.abs(areaDuty.getPlanMon()) > 0){
areaDuty.setCompleteMonRate(BigDecimal.valueOf(areaDuty.getGenerateMon() / areaDuty.getPlanMon() * 100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue()); areaDuty.setCompleteMonRate(BigDecimal.valueOf(areaDuty.getGenerateMon() / areaDuty.getPlanMon() * 100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
} }
areaDuty.setAvailable(windMons.stream().mapToDouble(WindEntity::getAvailable).average().getAsDouble()); areaDuty.setAvailableMon(windMons.stream().mapToDouble(WindEntity::getAvailable).sum());
} }
List<WindEntity> windYears = windService.list(new LambdaQueryWrapper<WindEntity>() {{ List<WindEntity> windYears = windService.list(new LambdaQueryWrapper<WindEntity>() {{
in(WindEntity::getStationCode,stations.stream().map(StationEntity::getCode).collect(Collectors.toList())) in(WindEntity::getStationCode,stations.stream().map(StationEntity::getCode).collect(Collectors.toList()))
@ -521,7 +541,7 @@ public class WindHomeServiceImpl implements WindHomeService {
if(CollectionUtil.isEmpty(windYears)){ if(CollectionUtil.isEmpty(windYears)){
return; return;
} }
areaDuty.setPlan(windYears.stream().mapToDouble(WindEntity::getPlan).sum()); areaDuty.setPlan(plans.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum());
areaDuty.setGenerate(windYears.stream().mapToDouble(WindEntity::getPower).sum()); areaDuty.setGenerate(windYears.stream().mapToDouble(WindEntity::getPower).sum());
// 发电量完成率 // 发电量完成率
if(Math.abs(areaDuty.getPlan()) > 0 && Math.abs(areaDuty.getGenerate()) > 0){ if(Math.abs(areaDuty.getPlan()) > 0 && Math.abs(areaDuty.getGenerate()) > 0){
@ -806,13 +826,15 @@ public class WindHomeServiceImpl implements WindHomeService {
in(WindEntity::getStationCode,stations.stream().map(StationEntity::getCode).collect(Collectors.toList())) in(WindEntity::getStationCode,stations.stream().map(StationEntity::getCode).collect(Collectors.toList()))
.like(WindEntity::getFillDate,DateUtil.format(new Date(),"yyyy")); .like(WindEntity::getFillDate,DateUtil.format(new Date(),"yyyy"));
}}); }});
// 计划发电量
List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), null,DateUtil.format(new Date(),"yyyy"));
// 设备 // 设备
List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_final).toString(), new TypeReference<List<EminfoAndEmParamVo>>() {}); List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_final).toString(), new TypeReference<List<EminfoAndEmParamVo>>() {});
subordinate.setStations(stations.stream().map(station -> { subordinate.setStations(stations.stream().map(station -> {
WindStationGenerateVo generate = new WindStationGenerateVo(); WindStationGenerateVo generate = new WindStationGenerateVo();
generate.setDeptId(station.getRefDept()); generate.setDeptId(station.getRefDept());
generate.setDeptName(station.getName()); generate.setDeptName(station.getName());
generate.setPlan(winds.stream().filter(o-> o.getStationCode().equals(station.getCode())).mapToDouble(WindEntity::getPlan).sum()); generate.setPlan(plans.stream().filter(o-> o.getStationId().equals(station.getCode())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum());
generate.setGenerate(winds.stream().filter(o-> o.getStationCode().equals(station.getCode())).mapToDouble(WindEntity::getPower).sum()); generate.setGenerate(winds.stream().filter(o-> o.getStationCode().equals(station.getCode())).mapToDouble(WindEntity::getPower).sum());
// 发电量完成率 // 发电量完成率
if(Math.abs(generate.getPlan()) > 0 && Math.abs(generate.getGenerate()) > 0){ if(Math.abs(generate.getPlan()) > 0 && Math.abs(generate.getGenerate()) > 0){
@ -918,11 +940,13 @@ public class WindHomeServiceImpl implements WindHomeService {
List<WindEntity> all = windService.list(Wrappers.<WindEntity>lambdaQuery() List<WindEntity> all = windService.list(Wrappers.<WindEntity>lambdaQuery()
.eq(WindEntity::getStationCode,station.getCode()) .eq(WindEntity::getStationCode,station.getCode())
); );
// 计划发电量
List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(Collections.singletonList(station.getCode()), null,DateUtil.format(new Date(),"yyyy"));
if(CollectionUtil.isNotEmpty(all)){ if(CollectionUtil.isNotEmpty(all)){
// 年计划发电量 // 年计划发电量
wind.setPlanYear(all.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy"))).mapToDouble(WindEntity::getPlan).sum()); wind.setPlanYear(plans.stream().filter(o->o.getDateTime().contains(DateUtil.format(new Date(),"yyyy"))).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum());
// 月计划发电量 // 月计划发电量
wind.setPlanMon(all.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(WindEntity::getPlan).sum()); wind.setPlanMon(plans.stream().filter(o->o.getDateTime().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum());
// 总发电量 // 总发电量
wind.setGeneration(all.stream().mapToDouble(WindEntity::getPower).sum()); wind.setGeneration(all.stream().mapToDouble(WindEntity::getPower).sum());
// 日上网电量 // 日上网电量
@ -960,12 +984,14 @@ public class WindHomeServiceImpl implements WindHomeService {
return new ArrayList<>(); return new ArrayList<>();
} }
List<String> monList = this.mons(1,12,false); List<String> monList = this.mons(1,12,false);
// 计划发电量查询
List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(Collections.singletonList(station.getCode()), null,DateUtil.format(new Date(),"yyyy"));
return monList.stream().map(mon->{ return monList.stream().map(mon->{
LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), mon), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), mon), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE));
WindGenerationVo generation = new WindGenerationVo(); WindGenerationVo generation = new WindGenerationVo();
generation.setYear(localDate.getYear()); generation.setYear(localDate.getYear());
generation.setMon(localDate.getMonthValue() > 9 ? String.valueOf(localDate.getMonthValue()) : "0" + localDate.getMonthValue()); generation.setMon(localDate.getMonthValue() > 9 ? String.valueOf(localDate.getMonthValue()) : "0" + localDate.getMonthValue());
generation.setPlan(winds.stream().filter(o->o.getFillDate().contains(generation.getYear() + "-" + generation.getMon())).mapToDouble(WindEntity::getPlan).sum()); generation.setPlan(plans.stream().filter(o->o.getDateTime().contains(generation.getYear() + "-" + generation.getMon())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum());
generation.setGeneration(winds.stream().filter(o->o.getFillDate().contains(generation.getYear() + "-" + generation.getMon())).mapToDouble(WindEntity::getPower).sum()); generation.setGeneration(winds.stream().filter(o->o.getFillDate().contains(generation.getYear() + "-" + generation.getMon())).mapToDouble(WindEntity::getPower).sum());
return generation; return generation;
}).collect(Collectors.toList()); }).collect(Collectors.toList());

7
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java

@ -153,10 +153,9 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
if (saveFlag) { if (saveFlag) {
// 删除数据平台项目 // 删除数据平台项目
Result dataDelete = projectClient.delete(stationEntity.getCode()); Result dataDelete = projectClient.delete(stationEntity.getCode());
Assert.isTrue(dataDelete.isSuccess(), () -> { if(dataDelete.isSuccess()) {
logger.error("hzims-operational:station:removeStation", stationEntity.getCode() + "删除失败,报错信息为:" + dataDelete.getMsg()); logger.error("hzims-operational:station:removeStation", stationEntity.getCode() + "删除失败,报错信息为:" + dataDelete.getMsg());
throw new ServiceException("数据平台删除项目失败!"); }
});
// 删除所属机构 // 删除所属机构
R<Dept> deptResult = sysClient.getDept(stationEntity.getRefDept()); R<Dept> deptResult = sysClient.getDept(stationEntity.getRefDept());
if (deptResult.isSuccess() && ObjectUtil.isNotEmpty(deptResult.getData())) { if (deptResult.isSuccess() && ObjectUtil.isNotEmpty(deptResult.getData())) {
@ -165,8 +164,6 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
logger.info("hzims-operational:station:removeStation", stationEntity.getRefDept() + "所属机构删除失败,报错信息为:" + projectResult.getMsg()); logger.info("hzims-operational:station:removeStation", stationEntity.getRefDept() + "所属机构删除失败,报错信息为:" + projectResult.getMsg());
} }
} }
// 清空
} }
new Thread(() -> { new Thread(() -> {
// 删除站点下集中监控属性配置 // 删除站点下集中监控属性配置

Loading…
Cancel
Save