Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
haungxing 6 months ago
parent
commit
37afd450b9
  1. 5
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/entity/AlarmEntity.java
  2. 15
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/feedback/constants/FeedbackConstant.java
  3. 34
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/feedback/entity/UserFeedbackEntity.java
  4. 29
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/feedback/vo/FeedbackQueryVo.java
  5. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java
  6. 3
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java
  7. 25
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/CarCheckTemplateDTO.java
  8. 39
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CarCheckTemplateDetailEntity.java
  9. 26
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CarCheckTemplateEntity.java
  10. 25
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarCheckTemplateDetailVO.java
  11. 11
      hzims-service/hzims-alarm/pom.xml
  12. 21
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java
  13. 3
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/DroolsMqttConsumer.java
  14. 3
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmHandleMapper.xml
  15. 2
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmHandleService.java
  16. 11
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/wrapper/HandleWrapper.java
  17. 16
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/DroolsAlarmServiceImpl.java
  18. 4
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java
  19. 10
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/VideoAlarmServiceImpl.java
  20. 1
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/AlarmScheduledTask.java
  21. 13
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java
  22. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/RealTargetService.java
  23. 118
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java
  24. 557
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java
  25. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/plate/DataService.java
  26. 53
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/plate/impl/DataServiceImpl.java
  27. 32
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/impl/ReportServiceImpl.java
  28. 10
      hzims-service/operational/pom.xml
  29. 72
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/feedback/controller/UserFeedbackController.java
  30. 11
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/feedback/mapper/UserFeedbackMapper.java
  31. 5
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/feedback/mapper/UserFeedbackMapper.xml
  32. 17
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/feedback/service/IUserFeedbackService.java
  33. 107
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/feedback/service/impl/UserFeedbackServiceImpl.java
  34. 145
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/UserFeedbackController.java
  35. 39
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/dto/UserFeedbackDTO.java
  36. 13
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/mapper/UserFeedbackMapper.java
  37. 26
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/mapper/UserFeedbackMapper.xml
  38. 15
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IUserFeedbackService.java
  39. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AnalyseDataServiceImpl.java
  40. 28
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/UserFeedbackServiceImpl.java
  41. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/vo/UserFeedbackVo.java
  42. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/wrapper/UserFeedbackWrapper.java
  43. 18
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/RunMonthController.java
  44. 13
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/mapper/RunMonReportMapper.java
  45. 11
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/RunMonthReportService.java
  46. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/RunMonthService.java
  47. 19
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonReportServiceImpl.java
  48. 595
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java
  49. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java
  50. 69
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/CarController.java
  51. 15
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarCheckTemplateDetailMapper.java
  52. 5
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarCheckTemplateDetailMapper.xml
  53. 20
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarCheckTemplateMapper.java
  54. 18
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarCheckTemplateMapper.xml
  55. 61
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarCheckTemplateService.java
  56. 67
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckRecordServiceImpl.java
  57. 37
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckTemplateDetailServiceImpl.java
  58. 161
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckTemplateServiceImpl.java
  59. 28
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ICarCheckTemplateDetailService.java
  60. 2
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java
  61. 34
      hzims-service/safeproduct/src/main/resources/db/2.0.1.sql
  62. 5
      pom.xml

5
hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/entity/AlarmEntity.java

@ -1,11 +1,14 @@
package com.hnac.hzims.alarm.config.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.tenant.mp.TenantEntity;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
@ -68,6 +71,8 @@ public class AlarmEntity extends TenantEntity {
private Integer alarmCount;
@ApiModelProperty(value = "告警时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss.sss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.sss")
private Date alarmTime;
@ApiModelProperty(value = "监测点")

15
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/feedback/constants/FeedbackConstant.java

@ -0,0 +1,15 @@
package com.hnac.hzims.operational.feedback.constants;
/**
* 应急抢修常量
* @Author: ysj
*/
public interface FeedbackConstant {
/**
* 问题回复角色别名
*/
String REPLY_ROLE_ALIAS = "feedback_reply";
}

34
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/entity/UserFeedbackEntity.java → hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/feedback/entity/UserFeedbackEntity.java

@ -1,38 +1,56 @@
package com.hnac.hzims.operational.main.entity;
package com.hnac.hzims.operational.feedback.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.tenant.mp.TenantEntity;
import java.io.Serializable;
import java.util.Date;
/**
* Created by Sam Huang 2022/5/24 11:03
* @author ysj
*/
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("hzims_user_feedback")
@ApiModel(value = "UserFeedbackEntity对象", description = "用户反馈表")
public class UserFeedbackEntity extends TenantEntity implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModel(value = "用户反馈信息", description = "用户反馈记录表")
public class UserFeedbackEntity extends TenantEntity {
@ApiModelProperty(value = "联系电话")
private String phone;
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "反馈内容")
private String content;
@ApiModelProperty(value = "联系电话")
private String phone;
@ApiModelProperty(value = "附件名称")
private String fileName;
@ApiModelProperty(value = "附件地址")
private String fileUrl;
@ApiModelProperty(value = "反馈人")
private Long feedbackUser;
@ApiModelProperty(value = "反馈人姓名")
private String feedbackUserName;
@ApiModelProperty(value = "反馈类型")
private String feedbackType;
@ApiModelProperty(value = "回复内容")
private String replyContent;
@ApiModelProperty(value = "回复人")
private Long replyUser;
@ApiModelProperty(value = "回复时间")
private Date replyTime;
@ApiModelProperty(value = "回复人姓名")
private String replyUserName;
}

29
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/feedback/vo/FeedbackQueryVo.java

@ -0,0 +1,29 @@
package com.hnac.hzims.operational.feedback.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author ysj
*/
@Data
@ApiModel(value = "用户反馈查询对象")
public class FeedbackQueryVo {
@ApiModelProperty(value = "反馈开始时间")
private String startTime;
@ApiModelProperty(value = "反馈结束时间")
private String endTime;
@ApiModelProperty(value = "反馈信息")
private String content;
@ApiModelProperty(value = "反馈类型")
private String feedbackType;
@ApiModelProperty(value = "问题状态: 1-未回复 2-已回复")
private Integer status;
}

2
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java

@ -88,6 +88,8 @@ public interface HomePageConstant {
*/
Integer HYDROPOWER_SERVETYPE = 2;
String HYDROPOWER_SERVETYPE_STRING = "2";
/**
* 站点接入方式 数据采集
*/

3
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java

@ -50,7 +50,10 @@ public interface MainConstants {
String LOAD_HYDROPOWER_UNIT_TARGET = "loadHydropowerUnitTarget";
// 近年发电量
String LOAD_POWER_DATA_NEW = "loadPowerDataNew";
String ELECTRICITY_GENERATION_RECENT_YEAR = "electricityGenerationRecentYear";
// 風電儲能近年发电量
String WIND_POWER_GENERATION_RECENT_YEAR = "windPowerGenerationRecentYear";

25
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/CarCheckTemplateDTO.java

@ -0,0 +1,25 @@
package com.hnac.hzims.safeproduct.dto;
import com.hnac.hzims.safeproduct.entity.CarCheckTemplateDetailEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @date 2024-05-30
*/
@Data
@ApiModel(value = "车检记录模板DTO类")
public class CarCheckTemplateDTO {
@ApiModelProperty("模板id")
private Long id;
@ApiModelProperty("模板名称")
private String templateName;
@ApiModelProperty("模板详情列表")
private List<CarCheckTemplateDetailEntity> detailList;
}

39
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CarCheckTemplateDetailEntity.java

@ -0,0 +1,39 @@
package com.hnac.hzims.safeproduct.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
/**
* 车检模板详情服务类
*
* @date 2024-05-30
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("hzims_car_check_template_detail")
@ApiModel(value = "车检模板详情实体类")
public class CarCheckTemplateDetailEntity extends BaseEntity {
@ApiModelProperty("车检记录id")
private Long templateId;
@NotNull
@Size(max = 500, message = "检查项目长度不能超过50")
@ApiModelProperty("检查项目")
private String checkItem;
@NotNull
@ApiModelProperty("检查内容")
private String checkContent;
@NotNull
@ApiModelProperty("检查结果")
private String checkResult;
}

26
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CarCheckTemplateEntity.java

@ -0,0 +1,26 @@
package com.hnac.hzims.safeproduct.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
/**
* @date 2024-05-28
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("hzims_car_check_template")
@ApiModel(value = "车检模板实体类")
public class CarCheckTemplateEntity extends BaseEntity {
@ApiModelProperty("模板名称")
private String templateName;
@TableField(exist = false)
@ApiModelProperty("创建机构名称")
private String createDeptName;
}

25
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/CarCheckTemplateDetailVO.java

@ -0,0 +1,25 @@
package com.hnac.hzims.safeproduct.vo;
import com.hnac.hzims.safeproduct.entity.CarCheckTemplateDetailEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @date 2024-05-30
*/
@Data
@ApiModel(value = "车检模板详情VO类")
public class CarCheckTemplateDetailVO {
@ApiModelProperty("模板id")
private Long id;
@ApiModelProperty("模板名称")
private String templateName;
@ApiModelProperty("模板详情列表")
private List<CarCheckTemplateDetailEntity> templateDetailList;
}

11
hzims-service/hzims-alarm/pom.xml

@ -118,12 +118,6 @@
</dependency>
<dependency>
<groupId>com.hnac.hzims</groupId>
<artifactId>alarm-api</artifactId>
<version>4.0.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.hnac.hzims</groupId>
<artifactId>equipment-api</artifactId>
</dependency>
<dependency>
@ -142,6 +136,11 @@
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
</dependency>
<dependency>
<groupId>com.hnac.hzims</groupId>
<artifactId>alarm-api</artifactId>
<version>4.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>

21
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java

@ -1,18 +1,15 @@
package com.hnac.hzims.alarm.monitor.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.hnac.hzims.alarm.config.constants.AlarmConstants;
import com.hnac.hzims.alarm.config.service.AlarmConfigService;
import com.hnac.hzims.alarm.config.entity.AlarmEntity;
import com.hnac.hzims.alarm.config.service.AlarmConfigService;
import com.hnac.hzims.alarm.config.vo.AlarmHandleMarkVo;
import com.hnac.hzims.alarm.monitor.service.AlarmSaveService;
import com.hnac.hzims.alarm.show.service.AlarmHandleService;
import com.hnac.hzims.alarm.show.service.AlarmService;
import com.hnac.hzims.alarm.config.vo.AlarmHandleMarkVo;
import com.hnac.hzims.message.entity.MessagePushRecordEntity;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.feign.IStationClient;
import com.hnac.hzims.safeproduct.constants.RedisConstants;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R;
@ -69,7 +66,7 @@ public class AlarmSaveServiceImpl implements AlarmSaveService {
// 未匹配到站点
Optional<StationEntity> optional = stations.getData().stream().filter(o->o.getCode().equals(alarm.getStationId())).findFirst();
if(!optional.isPresent()){
return;
return;
}
// 告警已处理
if(CollectionUtil.isNotEmpty(handlers) && handlers.contains(alarm.getAlarmContext())){
@ -88,22 +85,22 @@ public class AlarmSaveServiceImpl implements AlarmSaveService {
}
}
}
// fpd告警拼接站点名称
// fpd告警拼接
if(AlarmConstants.EARLY_WARNING.equals(alarm.getAlarmSource())){
alarm.setAlarmContext(optional.get().getName() + "." + alarm.getAlarmContext());
}
// 站点参数设置
// 步骤3.站点参数设置
alarm.setCreateDept(optional.get().getCreateDept());
alarm.setStationName(optional.get().getName());
alarm.setTenantId(optional.get().getTenantId());
alarm.setStatus(0);
// 根据站点查询配置标识
// 步骤4.根据站点查询配置标识
AlarmHandleMarkVo mark = alarmConfigService.mark(alarm.getStationId(),alarm.getAlarmSource(),alarm.getAlarmType());
if(ObjectUtil.isEmpty(mark)){
log.error("alarm_obtain_mark_is_null : {}",alarm.getAlarmId());
return;
}
// 告警处理标识赋值
// 步骤5.告警处理标识赋值
alarm.setIsRightTabulation(mark.getIsRightTabulation());
alarm.setIsBroadcast(mark.getIsBroadcast());
alarm.setIsMask(mark.getIsMask());
@ -112,7 +109,7 @@ public class AlarmSaveServiceImpl implements AlarmSaveService {
alarm.setIsSmallBell(mark.getIsSmallBell());
alarm.setIsShortMessage(mark.getIsShortMessage());
alarm.setIsWxMessage(mark.getIsWxMessage());
// 保存告警
// 步骤6.保存当日告警数据
boolean isSave = alarmService.save(alarm);
if(!isSave){
log.error("alarm_save_fail : {}",alarm.getAlarmId());
@ -121,7 +118,7 @@ public class AlarmSaveServiceImpl implements AlarmSaveService {
String key="hzims:queue:filter:alarm"+alarm.getAlarmId();
stringRedisTemplate.opsForValue().set(key,optional.get().getName()+alarm.getAlarmContext());
stringRedisTemplate.expire(key,5, TimeUnit.MINUTES);
// 发送告警数据进行消息推送队列
// 步骤7.发生数据至redis告警队列
stringRedisTemplate.opsForList().rightPush("hzims:queue:alarm", JSON.toJSONString(alarm));
});
return true;

3
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/DroolsMqttConsumer.java

@ -4,11 +4,14 @@ import com.alibaba.fastjson.JSONObject;
import com.hnac.hzims.alarm.config.entity.AlarmEntity;
import com.hnac.hzims.alarm.source.service.DroolsAlarmService;
import com.hnac.hzims.alarm.monitor.service.AlarmSaveService;
import com.hnac.hzims.common.utils.DateUtil;
import com.hnac.hzinfo.subscribe.SubscribeCallBack;
import lombok.extern.slf4j.Slf4j;
import oracle.sql.DATE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;

3
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmHandleMapper.xml

@ -4,7 +4,7 @@
<select id="selectHandlePage" resultType="com.hnac.hzims.alarm.config.vo.AlarmHandleVo">
SELECT H.*,S.NAME AS STATION_NAME,F.PROCESS_INSTANCE_ID
SELECT H.*,S.NAME AS STATION_NAME,F.PROCESS_INSTANCE_ID,F.HANDLE_USER_NAME as userName
FROM HZIMS_ALARM_HANDLE H
LEFT JOIN HZIMS_OPERATION.HZIMS_STATION S ON H.STATION_CODE = S.CODE
LEFT JOIN HZIMS_ALARM_HANDLE_FLOW F ON H.ALARM_ID = F.ALARM_ID
@ -40,6 +40,7 @@
AND (HANDLER.DELAY_TIME &gt; #{end} OR HANDLER.DELAY_TIME IS NULL)
</where>
</select>
<select id="sameDayContent" resultType="java.lang.String">
SELECT HANDLER.ALARM_CONTENT
FROM HZIMS_ALARM_HANDLE HANDLER

2
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmHandleService.java

@ -26,7 +26,7 @@ public interface AlarmHandleService extends BaseService<AlarmHandleEntity> {
List<String> handles();
List<String> sameDayContent();
List<String> sameDayContent();
List<String> incompleteContent();
}

11
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/wrapper/HandleWrapper.java

@ -1,6 +1,7 @@
package com.hnac.hzims.alarm.show.wrapper;
import com.hnac.hzims.alarm.config.vo.AlarmHandleVo;
import com.hnac.hzims.common.logs.utils.StringUtils;
import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.system.user.cache.UserCache;
@ -17,11 +18,13 @@ public class HandleWrapper extends BaseEntityWrapper<AlarmHandleVo,AlarmHandleVo
@Override
public AlarmHandleVo entityVO(AlarmHandleVo entity) {
User createUser = UserCache.getUser(entity.getCreateUser());
if(ObjectUtil.isEmpty(createUser)){
return entity;
if (1==entity.getHandleWay()|| StringUtils.isNotEmpty(entity.getUserName())) {
User createUser = UserCache.getUser(entity.getCreateUser());
if (ObjectUtil.isEmpty(createUser)) {
return entity;
}
entity.setUserName(createUser.getRealName());
}
entity.setUserName(createUser.getRealName());
return entity;
}
}

16
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/DroolsAlarmServiceImpl.java

@ -3,7 +3,6 @@ package com.hnac.hzims.alarm.source.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.hnac.hzims.alarm.config.entity.AlarmEntity;
import com.hnac.hzims.alarm.config.vo.ConditionAlarmVo;
import com.hnac.hzims.alarm.config.vo.DroolsAlarmVo;
import com.hnac.hzims.alarm.show.service.AlarmService;
import com.hnac.hzims.alarm.source.service.DroolsAlarmService;
@ -14,12 +13,10 @@ import com.hnac.hzims.operational.station.feign.IStationClient;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@ -52,15 +49,8 @@ public class DroolsAlarmServiceImpl implements DroolsAlarmService {
public List<AlarmEntity> receiveMessage(String message) {
// 对象转换
DroolsAlarmVo parseObject= JSONObject.parseObject(message, DroolsAlarmVo.class);
List<DroolsAlarmVo> alarms = Arrays.asList(parseObject);
if (CollectionUtil.isEmpty(alarms)) {
return new ArrayList<>();
}
List<AlarmEntity> res = alarms.stream().map(s -> {
AlarmEntity entity = getAlarmEntity(s);
return entity;
}).collect(Collectors.toList());
return res;
List<DroolsAlarmVo> alarms = Collections.singletonList(parseObject);
return alarms.stream().map(this::getAlarmEntity).collect(Collectors.toList());
}
private AlarmEntity getAlarmEntity(DroolsAlarmVo item) {

4
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java

@ -203,9 +203,9 @@ public class MessageServiceImpl implements MessageService {
message.setTaskId(entity.getId());
// 微信参数键值对
HashMap<String,Object> map = new HashMap<>();
map.put("thing18",getTruncateString(entity.getStationName(), 17));
map.put("thing18",getTruncateString(entity.getStationName(), 20));
// map.put("thing5",Optional.ofNullable(entity.getDeviceCode()).orElse("未知设备"));
map.put("thing11",getTruncateString(entity.getAlarmContext(), 17));
map.put("thing11",getTruncateString(entity.getAlarmContext(), 20));
map.put("time2",entity.getAlarmTime());
map.put("thing14", DictCache.getValue("alarm_source", entity.getAlarmSource()));
message.setMap(map);

10
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/VideoAlarmServiceImpl.java

@ -70,7 +70,7 @@ public class VideoAlarmServiceImpl implements VideoAlarmService {
return records;
}
return records;
}).filter(s -> CollectionUtil.isNotEmpty(s)).collect(Collectors.toList());
}).filter(CollectionUtil::isNotEmpty).collect(Collectors.toList());
List<DeviceSoeVO> res =new ArrayList<>();
if (CollectionUtil.isNotEmpty(collect)) {
res= collect.stream().flatMap(List::stream).collect(Collectors.toList());
@ -78,7 +78,7 @@ public class VideoAlarmServiceImpl implements VideoAlarmService {
// 转换平台视频预警信息
List<AlarmEntity> alarmEntities =new ArrayList<>();
if (CollectionUtil.isNotEmpty(res)) {
alarmEntities= res.stream().filter(s->ObjectUtils.isNotEmpty(s)).map(s -> getAlarmEntity(s)).collect(Collectors.toList());
alarmEntities= res.stream().filter(ObjectUtils::isNotEmpty).map(this::getAlarmEntity).collect(Collectors.toList());
}
return alarmEntities;
}
@ -95,11 +95,7 @@ public class VideoAlarmServiceImpl implements VideoAlarmService {
if (CollectionUtil.isEmpty(alarms)) {
return new ArrayList<>();
}
List<AlarmEntity> res = alarms.stream().map(s -> {
AlarmEntity entity = getAlarmEntity(s);
return entity;
}).collect(Collectors.toList());
return res;
return alarms.stream().map(this::getAlarmEntity).collect(Collectors.toList());
}
private AlarmEntity getAlarmEntity(DeviceSoeVO item) {

1
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/AlarmScheduledTask.java

@ -69,4 +69,5 @@ public class AlarmScheduledTask {
alarmService.interruption(param);
return new ReturnT<>("SUCCESS");
}
}

13
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java

@ -157,6 +157,19 @@ public class RealTargetScheduledTask {
return new ReturnT<>("SUCCESS");
}
/**
* 获取站点近3年发电量数据
*/
@XxlJob(LOAD_POWER_DATA_NEW)
//@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> loadPowerDataNew(String param) {
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM");
}
service.loadPowerDataNew(param, Arrays.asList(HomePageConstant.HYDROPOWER,HomePageConstant.PHOTOVOLTAIC),2,3);
return new ReturnT<>("SUCCESS");
}
@XxlJob(WIND_POWER_GENERATION_RECENT_YEAR)
//@Scheduled(cron = "0/40 * * * * ? ")

2
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/RealTargetService.java

@ -28,7 +28,7 @@ public interface RealTargetService {
void loadPowerData(String param, List<Integer> types, Integer serveType, int year);
void loadPowerDataNew(List<Integer> types, Integer serveType, int year);
void loadPowerDataNew(String param, List<Integer> types, Integer serveType, int year);
void loadPowerDataByWindEnergy(String param, List<Integer> types, Integer serveType, int year,String key);
}

118
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java

@ -114,6 +114,9 @@ public class RealTargetServiceImpl implements RealTargetService {
private final static String recent_year_power_data = "hzims:operation:key:power:data";
private final static String recent_year_power_data_test = "hzims:operation:key:power:data:test";
private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key";
private final static String load_hydropower_unit_target_key = "hzims:operation:loadhydropowerunit:target:key";
private final static String loadwaterpump_target_key = "hzims:operation:loadwaterpump:target:key";
@ -1275,72 +1278,87 @@ public class RealTargetServiceImpl implements RealTargetService {
}
@Override
public void loadPowerDataNew(List<Integer> types, Integer serveType, int year) {
public void loadPowerDataNew(String param, List<Integer> types, Integer serveType, int year) {
// 站点查询
List<StationEntity> stationList = stationService.list(new LambdaQueryWrapper<StationEntity>() {{
eq(StationEntity::getDataOrigin,"0");
if (ObjectUtil.isNotEmpty(serveType)) {
eq(StationEntity::getServeType, serveType);
}
List<StationEntity> stations = stationService.list(new LambdaQueryWrapper<StationEntity>() {{
if (CollectionUtil.isNotEmpty(types)) {
in(StationEntity::getType, types);
}
}});
// 设备信息
List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_cofig_final).toString(),
new TypeReference<List<EminfoAndEmParamVo>>() {});
// 结束时间
List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_cofig_final).toString(), new TypeReference<List<EminfoAndEmParamVo>>() {
});
// 开始时间
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH) + 12);
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1);
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00";
LocalDateTime endTime = LocalDateTime.parse(end);
// 开始时间
// 结束日期
calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - year);
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH));
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00";
LocalDateTime startTime = LocalDateTime.parse(end);
// 存储数据map:<站点id, <月份, 发电量>>
Map<Long, Map<String, Float>> powerMap = new HashMap<>();
stationList.forEach(station -> {
List<PowerMonthVo> datas = new ArrayList<>();
// 站点设备集合
List<EminfoAndEmParamVo> stationDevices = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList());
log.info("load_power_data station :" + station.getCode() + "==== device :" + stationDevices);
if (CollectionUtil.isNotEmpty(devices)) {
stationDevices.forEach(device -> {
ReductionDataDTO reductionDataDTO = new ReductionDataDTO();
reductionDataDTO.setDeviceCode(device.getEmCode());
reductionDataDTO.setSaveTimeType(5);
reductionDataDTO.setTimeInterval(1);
reductionDataDTO.setBeginTime(startTime);
reductionDataDTO.setEndTime(endTime);
reductionDataDTO.setNeedPage(false);
Result<ReductionDataVO> reductionDataVOResult = deviceDataClient.pageDeviceCodeAndSignages(reductionDataDTO);
if (!reductionDataVOResult.isSuccess() || CollectionUtil.isEmpty(reductionDataVOResult.getData().getDataList())) {
// 存储数据map :<站点id,<月份,发电量>>
Map<Long, Map<String, Float>> powerMap = new CopyOnWriteMap<>();
// 将站点切割
int limit = countStep(stations.size());
List<List<StationEntity>> limits = Stream.iterate(0, n -> n + 1).limit(limit).parallel().map(a -> stations.stream().skip((long) a * 3).limit(3).parallel().collect(Collectors.toList())).collect(Collectors.toList());
CountDownLatch countDownLatch = new CountDownLatch(limits.size());
for(List<StationEntity> item : limits){
pool.submit(()->{
item.forEach(station->{
// 站点设备集合
List<EminfoAndEmParamVo> stationDevices = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList());
Map<String, Float> generateMap = this.lastReduceFirst(station,stationDevices,start,end);
if(MapUtils.isEmpty(generateMap)){
return;
}
List<Map<String, String>> dataList = reductionDataVOResult.getData().getDataList();
datas.addAll(dataList.stream().map(data -> {
PowerMonthVo generate = new PowerMonthVo();
Date time = DateUtil.parse(data.get("ts"), "yyyy-MM-dd HH:mm:ss.s");
generate.setStrMonth(DateUtil.format(time,DateUtil.PATTERN_DATE));
// generate.setPower(Float.parseFloat(Optional.ofNullable(data.get(HomePageConstant.HYDROPOWER_GENERATE_POWER))
// .orElse("0")) * device.getRideCount());
return generate;
}).collect(Collectors.toList()));
powerMap.put(station.getId(),generateMap);
});
}
// 补充填报数据
datas.addAll(this.generateFill(station,start,end));
if (CollectionUtil.isEmpty(datas)) {
return;
}
Map<String, Float> map = datas.stream().collect(Collectors.toMap(PowerMonthVo::getStrMonth, PowerMonthVo::getPower, Float::sum));
powerMap.put(station.getId(), map);
});
redisTemplate.opsForValue().set(recent_year_power_data, powerMap);
countDownLatch.countDown();
log.error("pool_item_execute_complete: {}" ,item.stream().map(StationEntity::getName).collect(Collectors.toList()));
});
}
//所有模板数据获取完成后释放锁
try {
countDownLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
}
redisTemplate.opsForValue().set(recent_year_power_data_test, JSONObject.toJSONString(powerMap));
}
private Map<String, Float> lastReduceFirst(StationEntity station, List<EminfoAndEmParamVo> devices, String start, String end) {
List<PowerMonthVo> datas = new ArrayList<>();
// 设备采集发电量
if(CollectionUtil.isNotEmpty(devices)){
devices.forEach(device->{
List<Map<String, String>> records = dataService.lastFirstBySignage(start,end,7,5,device.getEmCode(),HomePageConstant.HYDROPOWER_GENERATE_POWER);
if(CollectionUtil.isEmpty(records)){
return;
}
datas.addAll(records.stream().map(record -> {
PowerMonthVo generate = new PowerMonthVo();
Date time = DateUtil.parse(record.get("ts"), "yyyy-MM-dd HH:mm:ss.s");
generate.setStrMonth(DateUtil.format(time,DateUtil.PATTERN_DATE));
String val = record.get(HomePageConstant.HYDROPOWER_GENERATE_POWER);
if(StringUtil.isEmpty(val)){
generate.setPower(0f);
}else{
generate.setPower(Float.parseFloat(String.valueOf(Double.parseDouble(val) * device.getRideCount())));
}
return generate;
}).collect(Collectors.toList()));
});
}
// 补充填报数据
datas.addAll(this.generateFill(station,start,end));
if(CollectionUtil.isEmpty(datas)){
return null;
}
return datas.stream().collect(Collectors.toMap(PowerMonthVo::getStrMonth, PowerMonthVo::getPower, Float::sum));
}
/**

557
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java

@ -8,8 +8,6 @@ import com.google.common.collect.Lists;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.hnac.hzims.equipment.entity.WorkshopInfoEntity;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.fdp.vo.FdpFaultStatusVo;
import com.hnac.hzims.operational.config.entity.StAlarmRecordEntity;
import com.hnac.hzims.operational.config.enume.ConfigStatus;
import com.hnac.hzims.operational.config.vo.StationRealVo;
import com.hnac.hzims.operational.main.constant.HomePageConstant;
@ -41,6 +39,8 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.Function;
@ -207,9 +207,7 @@ public class MonitorServiceImpl implements MonitorService {
log.error("real_time_data: {},{}",stationReal.getStation(),realIds);
List<String> objects = redisClient.getBatchRealDataByRealId(stationReal.getStation(),realIds);
for(int i = 0; i < realIds.size() ;i++){
if(ObjectUtil.isEmpty(objects.get(i))){
// log.error(realIds.get(i) + "is null");
}else{
if(ObjectUtil.isNotEmpty(objects.get(i))){
Map<String,String> attribute = (Map<String, String>) JSONObject.parse(objects.get(i));
attribute.put("realId",attribute.get("k"));
attribute.put("value",attribute.get("v"));
@ -272,86 +270,51 @@ public class MonitorServiceImpl implements MonitorService {
*/
@Override
public void loadMonitoring(String param) {
Thread thread = Thread.currentThread();
Object json = redisTemplate.opsForValue().get(real_data_cache_final);
if (ObjectUtil.isEmpty(json)) {
// 集中监控属性配置
Map<String,List<StationAttributeEntity>> attributes = this.attributes();
// realId对应实时数据
Map<String,Map<String,String>> realTimeData = this.realTimeData();
if(MapUtils.isEmpty(attributes) || MapUtils.isEmpty(realTimeData)){
return;
}
Map<String, Map<String, String>> map = JSONObject.parseObject(json.toString(), new TypeReference<Map<String, Map<String, String>>>() {
});
if (MapUtils.isEmpty(map)) {
// 集中监控站点
List<StationEntity> stations = this.monitorStations(new ArrayList<>(attributes.keySet()));
if(CollectionUtil.isEmpty(stations)){
return;
}
// 获取所有设备重点属性
List<StationAttributeEntity> list = attbtService.list(new LambdaQueryWrapper<StationAttributeEntity>() {{
isNotNull(StationAttributeEntity::getStationId);
eq(StationAttributeEntity::getIsDeleted, "0");
orderByAsc(StationAttributeEntity::getSort);
}});
if (CollectionUtil.isEmpty(list)) {
return;
}
// 获取所有告警记录
List<StAlarmRecordEntity> alertList = alertService.list(new LambdaQueryWrapper<StAlarmRecordEntity>() {{
orderByDesc(StAlarmRecordEntity::getCreateTime);
}});
// 获取所有故障记录
List<FdpFaultStatusVo> faultList = this.getFdpFaultAll();
// 所有设备分类
// 机构(取排序字段)
Map<Long,Integer> sorts = this.monitorDeptSorts();
List<String> operations = stations.stream().filter(o->HomePageConstant.HYDROPOWER_SERVETYPE_STRING.equals(o.getServeType())).map(StationEntity::getCode).collect(Collectors.toList());
// 告警铃铛(代运维)
List<String> bells = alarmQueryService.bells(operations);
// 数据中断(代运维)
List<String> aborts = interruptionAlarmService.aborts(operations);
// 设备状态分类
Map<String, List<String>> deviceClassifyMap = (Map<String, List<String>>) redisTemplate.opsForValue().get(device_classify_cache_final);
// 所有设备
List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_final).toString(),new TypeReference<List<EminfoAndEmParamVo>>() {});
// 根据站点分组
Map<String, List<StationAttributeEntity>> stationAttbtMap = list.stream().collect(Collectors.groupingBy(StationAttributeEntity::getStationId));
// 获取站点列表
List<StationEntity> stationEntityList = stationService.list(Wrappers.<StationEntity>lambdaQuery()
.in(StationEntity::getCode,new ArrayList<>(stationAttbtMap.keySet())));
// 铃铛
List<String> bells = alarmQueryService.bells(stationEntityList.stream().map(StationEntity::getCode).collect(Collectors.toList()));
// 数据中断
List<String> aborts = interruptionAlarmService.aborts(stationEntityList.stream().map(StationEntity::getCode).collect(Collectors.toList()));
// 隐藏设备列表
List<String> hideList = attrConfigService.getHideList();
// 分割,每个map限制10个长度
List<Map<String, List<StationAttributeEntity>>> handleList = this.mapChunk(stationAttbtMap);
// 创建线程池
CountDownLatch countDownLatch = new CountDownLatch(handleList.size());
// 所有机构
R<List<Dept>> deptAll = sysClient.getDeptList();
// 按10个站点一组分割属性配置
List<Map<String, List<StationAttributeEntity>>> limit = this.limitMapChunk(attributes);
// 线程执行次数
CountDownLatch countDownLatch = new CountDownLatch(limit.size());
// 存储数据节点
List<RealStationVo> stationList = new CopyOnWriteArrayList<>();
// 线程处理数据
for(Map<String, List<StationAttributeEntity>> item : handleList){
List<RealStationVo> realStations = new CopyOnWriteArrayList<>();
// 切割数据遍历
for(Map<String, List<StationAttributeEntity>> item : limit){
// 提交线程任务
pool.submit(()->{
item.forEach((key,value)->{
RealStationVo station = new RealStationVo();
// 站点编码
station.setStationCode(key);
// 名称、限制水位、服务类型、机构、排序
this.stationParam(stationEntityList,station,deptAll.getData());
// 根据设备名称分组
Map<String, List<StationAttributeEntity>> deviceAttbtMap = value.stream().filter(o -> !StringUtil.isEmpty(o.getEmName()) && !hideList.contains(o.getEmName())).collect(Collectors.groupingBy(StationAttributeEntity::getEmName));
List<RealDeviceVo> deviceList = new ArrayList<>();
// device - 设备,arrbt - 设备重点属性
deviceAttbtMap.forEach((device, attbt) -> {
RealDeviceVo deviceVo = new RealDeviceVo();
// 设备名称
deviceVo.setDeviceName(device);
deviceVo.setDeviceCode(attbt.get(0).getEmCode());
// 设备处理
this.handleDevice(attbt, map, deviceVo, alertList, faultList);
deviceList.add(deviceVo);
});
RealStationVo realStation = new RealStationVo();
// 设备信息
List<RealDeviceVo> devices = this.monitorRealDevice(value,realTimeData);
// 设备状态
this.getDeviceParam(devices, deviceClassifyMap, deviceList);
// 运行设备状态设置
this.deviceState(deviceList);
// 设置站点状态:数据中断
this.setStationStatus(aborts,station,key,deviceList);
// 铃铛
this.stationBell(station,bells);
station.setDeviceList(deviceList.stream().sorted(Comparator.comparing((RealDeviceVo::getDeviceName))).collect(Collectors.toList()));
stationList.add(station);
this.deviceStatus(devices,deviceClassifyMap);
realStation.setDeviceList(devices.stream().sorted(Comparator.comparing(RealDeviceVo::getDeviceName)).collect(Collectors.toList()));
// 站点基础信息: 编码、名称、限制水位、服务类型、机构、排序
this.stationBaseInfo(stations.stream().filter(station->key.equals(station.getCode())).findFirst(),sorts,realStation);
// 站点总功率计算
this.stationActivePower(devices,realStation);
// 站点铃铛、数据中断状态
this.stationStatus(aborts,bells,realStation);
realStations.add(realStation);
});
countDownLatch.countDown();
});
@ -363,24 +326,190 @@ public class MonitorServiceImpl implements MonitorService {
e.printStackTrace();
Thread.currentThread().interrupt();
}
redisTemplate.opsForValue().set(moniter_station_cache_final, stationList);
redisTemplate.opsForValue().set(moniter_station_cache_final, realStations);
}
/**
* 设置设备状态
* @param devices
* @param deviceClassifyMap
*/
private void deviceStatus(List<RealDeviceVo> devices, Map<String, List<String>> deviceClassifyMap) {
if (CollectionUtil.isEmpty(devices) || MapUtils.isEmpty(deviceClassifyMap)) {
return;
}
List<String> faults = deviceClassifyMap.get(HomePageConstant.FAULT);
List<String> overhaults = deviceClassifyMap.get(HomePageConstant.OVERHAUL);
devices.forEach(device -> {
int state = -1;
if(StringUtil.isNotBlank(device.getDeviceCode())){
// 故障
if (CollectionUtil.isNotEmpty(faults) && faults.contains(device.getDeviceCode())) {
state = 4;
// 检修
} else if (CollectionUtil.isNotEmpty(overhaults) && overhaults.contains(device.getDeviceCode())) {
state = 0;
}
}
if(state >= 0){
device.setState(state);
}else{
List<RealAttributeVo> attbts = device.getAttbtList();
// 功率属性记录
List<RealAttributeVo> powers = attbts.stream().filter(att-> HomePageConstant.powerList.contains(att.getName())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(powers)){
device.setState(-1);
return;
}
if("0.000000".equals(powers.get(0).getValue()) || "-".equals(powers.get(0).getValue()) || HomePageConstant.ON.equals(powers.get(0).getValue())){
device.setState(-1);
return;
}
device.setState(1);
}
});
}
/**
* 站点总功率计算
* @param devices
* @param realStation
*/
private void stationActivePower(List<RealDeviceVo> devices, RealStationVo realStation) {
realStation.setPowerSum(0.0);
if (CollectionUtil.isEmpty(devices)) {
return;
}
double powerSum = 0.0;
// 遍历设备
for (RealDeviceVo item : devices) {
List<RealAttributeVo> attributes = item.getAttbtList();
if (CollectionUtil.isEmpty(attributes)) {
continue;
}
List<RealAttributeVo> powerList = attributes.stream().filter(o -> StringUtil.isNoneBlank(o.getValue()) && !"-".equals(o.getValue()) && HomePageConstant.powerList.contains(o.getName())).collect(Collectors.toList());
if (CollectionUtil.isEmpty(powerList)) {
continue;
}
// 获取设备中属性为P/p的value值总和
powerSum += BigDecimal.valueOf(powerList.stream().mapToDouble(m -> Double.parseDouble(m.getValue())).sum()).setScale(2, RoundingMode.HALF_UP).doubleValue();
}
realStation.setPowerSum(powerSum);
}
/**
* 站点铃铛设置
* @param station
* 站点铃铛数据中断状态
* @param aborts
* @param bells
* @param realStation
*/
private void stationBell(RealStationVo station, List<String> bells) {
station.setBell(0);
if(CollectionUtil.isEmpty(bells)){
private void stationStatus(List<String> aborts, List<String> bells, RealStationVo realStation) {
realStation.setBell(0);
realStation.setStatus(0);
// 铃铛
if(bells.contains(realStation.getStationCode())){
realStation.setBell(1);
}
// 数据中断
if(realStation.getPowerSum() <= 0 && aborts.contains(realStation.getStationCode())){
realStation.setStatus(1);
}
}
/**
* 监控设备实时信息
* @param attributes
* @param realTimeData
* @return
*/
private List<RealDeviceVo> monitorRealDevice(List<StationAttributeEntity> attributes,Map<String,Map<String,String>> realTimeData) {
if(CollectionUtil.isEmpty(attributes)){
return new ArrayList<>();
}
// 根据设备名称分组
return attributes.stream().filter(o -> !StringUtil.isEmpty(o.getEmName())).collect(Collectors.groupingBy(StationAttributeEntity::getEmName)).entrySet().stream().map(entry->{
RealDeviceVo device = new RealDeviceVo();
device.setDeviceName(entry.getKey());
device.setDeviceCode(entry.getValue().get(0).getEmCode());
// 设备处理
this.handleDevice(entry.getValue(), realTimeData, device);
return device;
}).collect(Collectors.toList());
}
/**
* 获取缓存中实时数据
* @return
*/
private Map<String, Map<String, String>> realTimeData() {
Object json = redisTemplate.opsForValue().get(real_data_cache_final);
if (ObjectUtil.isEmpty(json)) {
return new HashMap<>();
}
return JSONObject.parseObject(json.toString(), new TypeReference<Map<String, Map<String, String>>>() {
});
}
/**
* 查询集中监控属性配置
* @return
*/
private Map<String,List<StationAttributeEntity>> attributes() {
List<StationAttributeEntity> attributes = attbtService.list(new LambdaQueryWrapper<StationAttributeEntity>() {{
isNotNull(StationAttributeEntity::getStationId);
orderByAsc(StationAttributeEntity::getSort);
}});
if(CollectionUtil.isEmpty(attributes)){
return new HashMap<>();
}
return attributes.stream().collect(Collectors.groupingBy(StationAttributeEntity::getStationId));
}
/**
* 集中监控站点
* @param codes
* @return
*/
private List<StationEntity> monitorStations(ArrayList<String> codes) {
return stationService.list(Wrappers.<StationEntity>lambdaQuery()
.in(StationEntity::getCode,codes)
);
}
/**
* 机构排序
* @return
*/
private Map<Long, Integer> monitorDeptSorts() {
R<List<Dept>> depts = sysClient.getDeptList();
if (!depts.isSuccess() || CollectionUtil.isEmpty(depts.getData())) {
new HashMap<>();
}
return depts.getData().stream().collect(Collectors.toMap(Dept::getId,Dept::getSort));
}
/**
* 站点基础信息
* @param realStation
*/
private void stationBaseInfo(Optional<StationEntity> optional, Map<Long, Integer> sorts, RealStationVo realStation) {
realStation.setSort(999);
if(!optional.isPresent()){
return;
}
if(bells.contains(station.getStationCode())){
station.setBell(1);
realStation.setStationCode(optional.get().getCode());
realStation.setStationName(optional.get().getName());
realStation.setWaterLevelMax(Optional.ofNullable(optional.get().getLimitWaterLevel()).orElse(0.0));
realStation.setServerType(optional.get().getServeType());
realStation.setStationDeptId(optional.get().getRefDept());
if(sorts.containsKey(optional.get().getRefDept())){
realStation.setSort(sorts.get(optional.get().getRefDept()));
}
}
/**
* 设备处理
*
@ -388,9 +517,7 @@ public class MonitorServiceImpl implements MonitorService {
* @param map
* @param device
*/
private void handleDevice(List<StationAttributeEntity> list, Map<String, Map<String, String>> map,
RealDeviceVo device, List<StAlarmRecordEntity> alertList,
List<FdpFaultStatusVo> faultList) {
private void handleDevice(List<StationAttributeEntity> list, Map<String, Map<String, String>> map,RealDeviceVo device) {
if (CollectionUtil.isEmpty(list) || MapUtils.isEmpty(map)) {
return;
}
@ -410,7 +537,7 @@ public class MonitorServiceImpl implements MonitorService {
attbtList.add(realAttributeVo);
return;
}
realAttributeVo = handleAttbt(item, real, alertList, faultList);
realAttributeVo = handleAttbt(item, real);
if (ObjectUtil.isEmpty(realAttributeVo)) {
return;
}
@ -420,123 +547,13 @@ public class MonitorServiceImpl implements MonitorService {
}
/**
* 设备状态
* @param deviceList
*/
private void deviceState(List<RealDeviceVo> deviceList) {
deviceList.forEach(device->{
// 设备属性列表
List<RealAttributeVo> attbts = device.getAttbtList();
if(CollectionUtil.isEmpty(attbts)){
device.setState(-1);
return;
}
// 功率属性记录
List<RealAttributeVo> powers = attbts.stream().filter(att-> HomePageConstant.powerList.contains(att.getName())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(powers)){
device.setState(-1);
return;
}
if("0.000000".equals(powers.get(0).getValue()) || "-".equals(powers.get(0).getValue()) || HomePageConstant.ON.equals(powers.get(0).getValue())){
device.setState(-1);
return;
}
device.setState(1);
});
}
/**
* 获取站点属性
* @param stationEntityList
* @param item
*/
private void stationParam(List<StationEntity> stationEntityList, RealStationVo item,List<Dept> deptAll) {
item.setSort(9999);
if(CollectionUtil.isEmpty(stationEntityList)){
return;
}
List<StationEntity> filterList = stationEntityList.stream().filter(o->item.getStationCode().equals(o.getCode())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(filterList)){
return;
}
StationEntity station = filterList.get(0);
if(ObjectUtil.isEmpty(station)){
return;
}
item.setStationName(station.getName());
item.setWaterLevelMax(Optional.ofNullable(station.getLimitWaterLevel()).orElse(0.0));
item.setServerType(station.getServeType());
item.setStationDeptId(station.getRefDept());
// 排序
List<Dept> list = deptAll.stream().filter(o-> station.getRefDept().equals(o.getId())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(list)){
return;
}
item.setSort(list.get(0).getSort());
}
/**
* 设备参数设置
*
* @param devices
* @param deviceClassifyMap
* @param deviceList
*/
private void getDeviceParam(List<EminfoAndEmParamVo> devices, Map<String, List<String>> deviceClassifyMap, List<RealDeviceVo> deviceList) {
if (CollectionUtil.isEmpty(devices) || CollectionUtil.isEmpty(deviceList) || MapUtils.isEmpty(deviceClassifyMap)) {
return;
}
List<String> faultList = deviceClassifyMap.get(HomePageConstant.FAULT);
List<String> maintaintList = deviceClassifyMap.get(HomePageConstant.MAINTAIN);
List<String> overhaultList = deviceClassifyMap.get(HomePageConstant.OVERHAUL);
List<String> runtList = deviceClassifyMap.get(HomePageConstant.RUN);
List<String> sparetList = deviceClassifyMap.get(HomePageConstant.SPARE);
deviceList.forEach(device -> {
if (StringUtil.isBlank(device.getDeviceCode())) {
device.setState(-1);
return;
}
List<EminfoAndEmParamVo> list = devices.stream().filter(o -> null != o.getId() && o.getId().toString().equals(device.getDeviceCode())).collect(Collectors.toList());
if (CollectionUtil.isEmpty(list)) {
device.setState(-1);
return;
}
String deviceCode = list.get(0).getEmCode();
if (StringUtil.isBlank(deviceCode)) {
device.setState(-1);
return;
}
// 故障
if (CollectionUtil.isNotEmpty(faultList) && faultList.contains(deviceCode)) {
device.setState(4);
// 保养
} else if (CollectionUtil.isNotEmpty(maintaintList) && maintaintList.contains(deviceCode)) {
device.setState(3);
// 备用
} else if (CollectionUtil.isNotEmpty(sparetList) && sparetList.contains(deviceCode)) {
device.setState(2);
// 运行
} else if (CollectionUtil.isNotEmpty(runtList) && runtList.contains(deviceCode)) {
device.setState(1);
// 检修
} else if (CollectionUtil.isNotEmpty(overhaultList) && overhaultList.contains(deviceCode)) {
device.setState(0);
// 未知
} else {
device.setState(-1);
}
});
}
/**
* 设备单条重点属性处理
*
* @param item
* @param real
* @return
*/
private RealAttributeVo handleAttbt(StationAttributeEntity item, Map<String, String> real,
List<StAlarmRecordEntity> alertList, List<FdpFaultStatusVo> faultList) {
private RealAttributeVo handleAttbt(StationAttributeEntity item, Map<String, String> real) {
RealAttributeVo attest = new RealAttributeVo();
this.setAttbtParam(attest, real);
attest.setRealId(item.getMonitorId());
@ -546,7 +563,7 @@ public class MonitorServiceImpl implements MonitorService {
String value = Optional.ofNullable(attest.getValue()).orElse("-");
// 正常状态
attest.setStatus(ConfigStatus.ConfigStatusEnum.NORMAL.getStatus());
int quality = Optional.ofNullable(attest.getQuality()).orElse(-1);
int quality = Optional.of(attest.getQuality()).orElse(-1);
String time = Optional.ofNullable(attest.getTime()).orElse("");
// 延时状态 :质量为空 && 时间为空
if (-1 == quality && StringUtil.isEmpty(time)) {
@ -554,21 +571,21 @@ public class MonitorServiceImpl implements MonitorService {
}
int type = item.getAttributeType();
switch (type) {
case 1://遥测
//遥测
case 1:
// 预警状态 :value值为"1" && quality值为0
if ("1".equals(value) && 0 == quality) {
attest.setStatus(ConfigStatus.ConfigStatusEnum.RED.getStatus());
}
break;
case 2://遥信
signalyRemote(item, attest, quality, value, alertList);
//遥信
case 2:
signalyRemote(item, attest, quality, value);
//处理
break;
default:
throw new IllegalStateException("Unexpected type: " + type);
}
// 故障信息设置
accidentDetails(attest, faultList, value);
return attest;
}
@ -606,41 +623,13 @@ public class MonitorServiceImpl implements MonitorService {
}
/**
* 故障信息设置
*
* @param attest
* @param faultList
* @param value
*/
private void accidentDetails(RealAttributeVo attest, List<FdpFaultStatusVo> faultList, String value) {
if (CollectionUtil.isEmpty(faultList) || "-".equals(value)) {
return;
}
List<FdpFaultStatusVo> fault = faultList.stream().filter(o -> o.getRealId().equals(attest.getRealId())).collect(Collectors.toList());
if (CollectionUtil.isEmpty(fault)) {
return;
}
FdpFaultStatusVo fdpFaultStatusVo = fault.get(0);
// 黄色
if (fdpFaultStatusVo.getValue() > greater_than_cache_final && fdpFaultStatusVo.getValue() < less_than_cache_final) {
attest.setStatus(ConfigStatus.ConfigStatusEnum.YELLOW.getStatus());
// 橙色
} else if (fdpFaultStatusVo.getValue() >= be_equa_cache_final) {
attest.setStatus(ConfigStatus.ConfigStatusEnum.ORANGE.getStatus());
}
attest.setFdpRate(fdpFaultStatusVo.getValue());
attest.setFdpFaultId(fdpFaultStatusVo.getFaultId());
attest.setFdpMonitorId(fdpFaultStatusVo.getMonitorId());
}
/**
* 重点属性类型-遥信 数据逻辑处理
*
* @param attest
*/
private void signalyRemote(StationAttributeEntity item, RealAttributeVo attest, int quality, String strValue, List<StAlarmRecordEntity> alertList) {
//需要所有值的数据不为null,并且满足条件才会进去添加数据返回id
if (null == item.getUpUpLimit() || null == item.getDownDownLimit() || null == item.getUpLimit() || null == item.getDownLimit()) {
private void signalyRemote(StationAttributeEntity attribute, RealAttributeVo attest, int quality, String strValue) {
// 需要所有限制不为null,并且满足条件才会设置设备状态标识
if (null == attribute.getUpUpLimit() || null == attribute.getDownDownLimit() || null == attribute.getUpLimit() || null == attribute.getDownLimit()) {
return;
}
if (-1 == quality) {
@ -652,99 +641,17 @@ public class MonitorServiceImpl implements MonitorService {
if ("-".equals(strValue)) {
return;
}
double upup = item.getUpUpLimit();
double lwlw = item.getDownDownLimit();
double up = item.getUpLimit();
double lw = item.getDownLimit();
//查询出来已处理告警记录
List<StAlarmRecordEntity> handleList = alertList.stream().filter(o -> o.getStationId().equals(item.getStationId()) && o.getRealId().equals(attest.getRealId()) && o.getStatus() == 1).collect(Collectors.toList());
//查询出来未处理告警记录
List<StAlarmRecordEntity> recordList = alertList.stream().filter(o -> o.getStationId().equals(item.getStationId()) && o.getRealId().equals(attest.getRealId()) && o.getStatus() == 0).collect(Collectors.toList());
double upup = attribute.getUpUpLimit();
double lwlw = attribute.getDownDownLimit();
double up = attribute.getUpLimit();
double lw = attribute.getDownLimit();
long past = 0L;
double value = Double.parseDouble(strValue);
if (value > upup || value < lwlw) {
if (CollectionUtil.isNotEmpty(handleList)) {
// 现在时间 - 处理时间
past = System.currentTimeMillis() - handleList.get(0).getProcessTime().getTime();
}
boolean isOverrun = ((CollectionUtil.isEmpty(handleList) && CollectionUtil.isEmpty(recordList)) || (past / 1000 / 60 > 30 && CollectionUtil.isEmpty(recordList)));
if (isOverrun) {
Long alertId = alertService.insertAlert(item.getStationId(), item.getMonitorId());
attest.setId(alertId);
attest.setStatus(ConfigStatus.ConfigStatusEnum.YELLOW.getStatus());
} else if (CollectionUtil.isNotEmpty(recordList)) {
StAlarmRecordEntity record = recordList.get(0);
attest.setId(record.getId());
// 告警处理完成
if (record.getProcessTime() != null && record.getStatus() == (byte) 1) {
attest.setStatus(ConfigStatus.ConfigStatusEnum.NORMAL.getStatus());
// 告警未处理
} else if (record.getProcessTime() == null && record.getStatus() == (byte) 0) {
attest.setStatus(ConfigStatus.ConfigStatusEnum.HAND_DELAY_STATUS.getStatus());
}
}
attest.setStatus(ConfigStatus.ConfigStatusEnum.RED.getStatus());
} else if (value > up && value < upup || value < lw && value > lwlw) {
if (CollectionUtil.isNotEmpty(handleList)) {
// 现在时间 - 处理时间
past = System.currentTimeMillis() - handleList.get(0).getProcessTime().getTime();
}
boolean exist = ((CollectionUtil.isEmpty(handleList) && CollectionUtil.isEmpty(recordList)) || (past / 1000 / 60 > 30 && CollectionUtil.isEmpty(recordList)));
if (exist){
Long alertId = alertService.insertAlert(item.getStationId(), item.getMonitorId());
attest.setId(alertId);
attest.setStatus(ConfigStatus.ConfigStatusEnum.YELLOW.getStatus());
// 存在告警记录
} else if (CollectionUtil.isNotEmpty(recordList)) {
StAlarmRecordEntity record = recordList.get(0);
if (recordList.get(0).getStatus() == (byte) 0 && recordList.get(0).getCreateTime() != null) {
attest.setId(record.getId());
attest.setStatus(ConfigStatus.ConfigStatusEnum.RED.getStatus());
} else {
attest.setId(recordList.get(0).getId());
attest.setStatus(ConfigStatus.ConfigStatusEnum.NORMAL.getStatus());
}
}
}
}
/**
* 设置站点状态
* @param station
* @param key
*/
private void setStationStatus(List<String> aborts,RealStationVo station, String key,List<RealDeviceVo> deviceList) {
// 站点功率大于0为正常上送数据
for(RealDeviceVo item : deviceList){
if(!CollectionUtil.isEmpty(item.getAttbtList())){
List<RealAttributeVo> powers = item.getAttbtList().stream().filter(att-> HomePageConstant.powerList.contains(att.getName())).collect(Collectors.toList());
if(!CollectionUtil.isEmpty(powers)){
for(RealAttributeVo attr : powers){
if(!"-".equals(attr.getValue())){
if(attr.getQuality() == 0 && Double.parseDouble(attr.getValue()) > 0){
station.setStatus(0);
return;
}
}
}
}
}
}
if(aborts.contains(key)){
station.setStatus(1);
}
}
/**
* 获取所有告警记录
*
* @return
*/
private List<FdpFaultStatusVo> getFdpFaultAll() {
Object json = redisTemplate.opsForValue().get(fdp_fault_cache_final);
if (ObjectUtil.isEmpty(json)) {
return new ArrayList<>();
attest.setStatus(ConfigStatus.ConfigStatusEnum.YELLOW.getStatus());
}
return (List<FdpFaultStatusVo>) json;
}
/**
@ -755,7 +662,7 @@ public class MonitorServiceImpl implements MonitorService {
* @param chunkMap
* @return
*/
private <k, v> List<Map<k, v>> mapChunk(Map<k, v> chunkMap) {
private <k, v> List<Map<k, v>> limitMapChunk(Map<k, v> chunkMap) {
if (chunkMap == null) {
return Lists.newArrayList();
}

2
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/plate/DataService.java

@ -29,5 +29,7 @@ public interface DataService {
List<Map<String, String>> lastFirstBySignage(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, String signages);
Float lastFirstByFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, Double ride ,String signages);
Float periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, Double ride ,String signages);
}

53
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/plate/impl/DataServiceImpl.java

@ -168,7 +168,7 @@ public class DataServiceImpl implements DataService {
@Override
public List<Map<String, String>> lastFirstBySignage(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, String signage) {
ReductionDataDTO reduction = new ReductionDataDTO();
reduction.setFull(1);
reduction.setFull(0);
reduction.setDeviceCode(deviceCode);
reduction.setSaveTimeType(cycleType);
reduction.setTimeInterval(1);
@ -201,6 +201,57 @@ public class DataServiceImpl implements DataService {
* @param cycleType 间隔周期 : 0-> 1-> 2-> 小时 3-> 4-> 5-> 6->
* @param deviceCode 设备编号
* @param ride 配电比
* @param signage 指标
* @return
*/
@Override
public Float lastFirstByFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode,Double ride,String signage) {
ReductionDataDTO reduction = new ReductionDataDTO();
reduction.setFull(0);
reduction.setDeviceCode(deviceCode);
reduction.setSaveTimeType(cycleType);
reduction.setTimeInterval(1);
reduction.setNeedPage(false);
reduction.setBeginTime(LocalDateTime.parse(DateUtil.format(new Date(), startTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME)));
reduction.setEndTime(LocalDateTime.parse(DateUtil.format(new Date(), endTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME)));
// 属性列表
List<ReductionAttrDataDTO> atts = new ArrayList<>();
ReductionAttrDataDTO attr = new ReductionAttrDataDTO();
attr.setAccessRules(accessRules);
attr.setKeepFigures(4);
attr.setSignage(signage);
atts.add(attr);
reduction.setDtos(atts);
Result<ReductionDataVO> result = deviceDataClient.pageDeviceCodeAndSignages(reduction);
if (!result.isSuccess() || ObjectUtil.isEmpty(result.getData())) {
return 0f;
}
if(MapUtils.isEmpty(result.getData().getFieldMap()) || CollectionUtil.isEmpty(result.getData().getDataList())){
return 0f;
}
List<Map<String, String>> dataList = result.getData().getDataList();
if (CollectionUtil.isEmpty(dataList)) {
return 0f;
}
Map<String, String> data = dataList.get(0);
if(MapUtils.isEmpty(data)){
return 0f;
}
String val = data.get(signage);
if(StringUtil.isEmpty(val)){
return 0f;
}
return Float.parseFloat(String.valueOf(Double.parseDouble(val) * ride));
}
/***
* 指标数据列表查询
* @param startTime 开始时间
* @param endTime 结束时间
* @param accessRules 取数规则 : 0=最早值 1=最大值 2=最小值 3=平均值 4=和值 5=差值 6=最新值
* @param cycleType 间隔周期 : 0-> 1-> 2-> 小时 3-> 4-> 5-> 6->
* @param deviceCode 设备编号
* @param ride 配电比
* @param signages 指标
* @return
*/

32
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/impl/ReportServiceImpl.java

@ -620,6 +620,9 @@ public class ReportServiceImpl implements ReportService {
if(CollectionUtil.isEmpty(stations)){
return;
}
// 删除上个月手动生成月报记录
this.deleteGenerateReport(stations);
// 计划发电量
List<PlanGenerationEntity> plans = planService.planGeneration(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), null ,DateUtil.format(new Date(),"yyyy"));
// 查询站点设备
@ -633,7 +636,7 @@ public class ReportServiceImpl implements ReportService {
run.setStationCode(station.getCode());
run.setStationName(station.getName());
Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse("2024-05-01 00:00:00",DateUtil.PATTERN_DATETIME));
calendar.setTime(new Date());
calendar.add(Calendar.DAY_OF_MONTH,-1);
run.setMonth(DateUtil.format(calendar.getTime(),"yyyy-MM"));
List<RideDeviceVo> stationDevices = devices.stream().filter(device->device.getDepartment().equals(station.getRefDept())).collect(Collectors.toList());
@ -654,6 +657,24 @@ public class ReportServiceImpl implements ReportService {
}
/**
* 删除上月手动生成月报记录
* @param stations
*/
private void deleteGenerateReport(List<StationEntity> stations) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.add(Calendar.MONTH,-1);
List<RunMonthEntity> runs = runMonService.list(Wrappers.<RunMonthEntity>lambdaQuery()
.eq(RunMonthEntity::getMonth,DateUtil.format(calendar.getTime(),"yyyy-MM"))
.in(RunMonthEntity::getStationCode,stations.stream().map(StationEntity::getCode).collect(Collectors.toList()))
);
if(CollectionUtil.isEmpty(runs)){
return;
}
runMonService.deleteLogic(runs.stream().map(RunMonthEntity::getId).collect(Collectors.toList()));
}
/**
* 运行数据
* @param devices
* @return
@ -699,7 +720,7 @@ public class ReportServiceImpl implements ReportService {
*/
private Double generate(int type,String deviceCode,double ride) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse("2024-05-01 00:00:00",DateUtil.PATTERN_DATETIME));
calendar.setTime(new Date());
String end = null,start = null;
int cycleType = 5;
switch (type){
@ -773,7 +794,7 @@ public class ReportServiceImpl implements ReportService {
// 确定查询时间范围: 年、月
Date startDate,endDate;
Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse("2024-05-01 00:00:00",DateUtil.PATTERN_DATETIME));
calendar.setTime(new Date());
endDate = calendar.getTime();
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH));
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1);
@ -846,7 +867,7 @@ public class ReportServiceImpl implements ReportService {
*/
private String alarmData(String code) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse("2024-05-01 00:00:00",DateUtil.PATTERN_DATETIME));
calendar.setTime(new Date());
calendar.add(Calendar.DAY_OF_MONTH,-1);
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
calendar.add(Calendar.MONTH,-1);
@ -952,8 +973,7 @@ public class ReportServiceImpl implements ReportService {
*/
private List<EchartVo> curve(List<AttributeVo> attributes, String deviceCode) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse("2024-05-01 00:00:00",DateUtil.PATTERN_DATETIME));
//calendar.setTime(DateUtil.parse(DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 23:59:59",DateUtil.PATTERN_DATETIME));
calendar.setTime(DateUtil.parse(DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 23:59:59",DateUtil.PATTERN_DATETIME));
calendar.add(Calendar.DAY_OF_MONTH,-1);
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
calendar.add(Calendar.MONTH,-1);

10
hzims-service/operational/pom.xml

@ -240,6 +240,10 @@
<groupId>com.hnac.hzinfo.data</groupId>
<artifactId>hzinfo-data-sdk</artifactId>
</dependency>
<dependency>
<groupId>com.hnac.hzims</groupId>
<artifactId>alarm-api</artifactId>
</dependency>
@ -255,6 +259,12 @@
<version>3.9.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.hnac.hzims</groupId>
<artifactId>alarm-api</artifactId>
<version>4.0.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

72
hzims-service/operational/src/main/java/com/hnac/hzims/operational/feedback/controller/UserFeedbackController.java

@ -0,0 +1,72 @@
package com.hnac.hzims.operational.feedback.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.operational.feedback.entity.UserFeedbackEntity;
import com.hnac.hzims.operational.feedback.service.IUserFeedbackService;
import com.hnac.hzims.operational.feedback.vo.FeedbackQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
/**
* @author ysj
*/
@RestController
@RequestMapping("/feedback")
@AllArgsConstructor
@Api(value = "用户反馈", tags = "用户反馈管理")
public class UserFeedbackController extends BladeController {
private final IUserFeedbackService service;
@PostMapping("/save")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "保存反馈信息", notes = "传入用户反馈对象")
public R save(@RequestBody UserFeedbackEntity entity) {
BladeUser user = AuthUtil.getUser();
entity.setFeedbackUser(user.getUserId());
entity.setFeedbackUserName(user.getNickName());
return R.status(service.save(entity));
}
@PostMapping("/update")
@ApiOperationSupport(order = 2)
@ApiOperation(value = "修改反馈信息", notes = "传入用户反馈对象")
public R update(@RequestBody UserFeedbackEntity entity) {
BladeUser user = AuthUtil.getUser();
entity.setFeedbackUser(user.getUserId());
entity.setFeedbackUserName(user.getNickName());
return R.status(service.updateById(entity));
}
@PostMapping("/remove")
@ApiOperationSupport(order = 3)
@ApiOperation(value = "删除反馈信息", notes = "传入ids")
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
return R.status(service.deleteLogic(Func.toLongList(ids)));
}
@PostMapping("/reply")
@ApiOperationSupport(order = 4)
@ApiOperation(value = "回复反馈信息", notes = "传入用户反馈对象")
public R reply(@RequestBody UserFeedbackEntity entity) {
return R.status(service.reply(entity));
}
@PostMapping("/page")
@ApiOperationSupport(order = 5)
@ApiOperation(value = "反馈列表查询", notes = "传入ids")
public R<IPage<UserFeedbackEntity>> pageCondition(FeedbackQueryVo param, Query query) {
return R.data(service.pageCondition(param, Condition.getPage(query)));
}
}

11
hzims-service/operational/src/main/java/com/hnac/hzims/operational/feedback/mapper/UserFeedbackMapper.java

@ -0,0 +1,11 @@
package com.hnac.hzims.operational.feedback.mapper;
import com.hnac.hzims.operational.feedback.entity.UserFeedbackEntity;
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
/**
* @author ysj
*/
public interface UserFeedbackMapper extends UserDataScopeBaseMapper<UserFeedbackEntity> {
}

5
hzims-service/operational/src/main/java/com/hnac/hzims/operational/feedback/mapper/UserFeedbackMapper.xml

@ -0,0 +1,5 @@
<?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">
<mapper namespace="com.hnac.hzims.operational.feedback.mapper.UserFeedbackMapper">
</mapper>

17
hzims-service/operational/src/main/java/com/hnac/hzims/operational/feedback/service/IUserFeedbackService.java

@ -0,0 +1,17 @@
package com.hnac.hzims.operational.feedback.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.operational.feedback.entity.UserFeedbackEntity;
import com.hnac.hzims.operational.feedback.vo.FeedbackQueryVo;
import org.springblade.core.mp.base.BaseService;
/**
* @author ysj
*/
public interface IUserFeedbackService extends BaseService<UserFeedbackEntity> {
IPage<UserFeedbackEntity> pageCondition(FeedbackQueryVo query,IPage<UserFeedbackEntity> page);
boolean reply(UserFeedbackEntity entity);
}

107
hzims-service/operational/src/main/java/com/hnac/hzims/operational/feedback/service/impl/UserFeedbackServiceImpl.java

@ -0,0 +1,107 @@
package com.hnac.hzims.operational.feedback.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.operational.feedback.constants.FeedbackConstant;
import com.hnac.hzims.operational.feedback.mapper.UserFeedbackMapper;
import com.hnac.hzims.operational.feedback.service.IUserFeedbackService;
import com.hnac.hzims.operational.feedback.entity.UserFeedbackEntity;
import com.hnac.hzims.operational.feedback.vo.FeedbackQueryVo;
import com.hnac.hzims.operational.station.entity.StationEntity;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.system.user.entity.User;
import org.springblade.system.user.feign.IUserClient;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author ysj
*/
@Service
@Slf4j
@AllArgsConstructor
public class UserFeedbackServiceImpl extends BaseServiceImpl<UserFeedbackMapper, UserFeedbackEntity> implements IUserFeedbackService {
private final IUserClient userClient;
/**
* 用户反馈列表查询
* @param query
* @return
*/
@Override
public IPage<UserFeedbackEntity> pageCondition(FeedbackQueryVo query,IPage<UserFeedbackEntity> page) {
// 用户角色查询
boolean isHaveReplyRole = this.isHaveReplyRole();
// 定义查询表达式
LambdaQueryWrapper<UserFeedbackEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.orderByDesc(UserFeedbackEntity::getCreateTime);
if(ObjectUtil.isNotEmpty(query)){
if(StringUtil.isNotBlank(query.getStartTime())){
wrapper.ge(UserFeedbackEntity::getCreateTime,query.getStartTime());
}
if(StringUtil.isNotBlank(query.getEndTime())){
wrapper.le(UserFeedbackEntity::getCreateTime,query.getEndTime());
}
if(StringUtil.isNotBlank(query.getFeedbackType())){
wrapper.eq(UserFeedbackEntity::getFeedbackType,query.getFeedbackType());
}
if(ObjectUtil.isNotEmpty(query.getStatus())){
wrapper.eq(UserFeedbackEntity::getStatus,query.getStatus());
}
if(ObjectUtil.isNotEmpty(query.getContent())){
wrapper.like(UserFeedbackEntity::getContent,query.getContent());
}
}
if(isHaveReplyRole){
wrapper.eq(UserFeedbackEntity::getFeedbackUser,AuthUtil.getUserId());
}
return this.page(page,wrapper);
}
/**
* 反馈回复
* @param entity
* @return
*/
@Override
public boolean reply(UserFeedbackEntity entity) {
// 更新保存回复内容
BladeUser user = AuthUtil.getUser();
entity.setReplyUser(user.getUserId());
entity.setReplyUserName(user.getNickName());
entity.setReplyTime(new Date());
entity.setStatus(2);
this.updateById(entity);
// TODO 推送回复信息至提问人
return true;
}
/**
* 用户是否拥有问题回复角色
* @return
*/
private boolean isHaveReplyRole() {
// 当前用户
BladeUser user = AuthUtil.getUser();
// 查询用户回复角色用户
R<List<User>> haveUsers = userClient.userListByRoleAlias(user.getTenantId(), FeedbackConstant.REPLY_ROLE_ALIAS);
if(!haveUsers.isSuccess() || CollectionUtil.isEmpty(haveUsers.getData())){
return true;
}
return !haveUsers.getData().stream().map(User::getId).collect(Collectors.toList()).contains(user.getUserId());
}
}

145
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/UserFeedbackController.java

@ -1,145 +0,0 @@
package com.hnac.hzims.operational.main.controller;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.operational.main.dto.UserFeedbackDTO;
import com.hnac.hzims.operational.main.entity.UserFeedbackEntity;
import com.hnac.hzims.operational.main.service.IUserFeedbackService;
import com.hnac.hzims.operational.main.vo.UserFeedbackVo;
import com.hnac.hzims.operational.main.wrapper.UserFeedbackWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.log.annotation.ApiLog;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.system.user.feign.IUserClient;
import org.springframework.web.bind.annotation.*;
/**
* Created by Sam Huang 2022/5/24 11:21
*/
@RestController
@RequestMapping("/feedback")
@Api(value = "用户反馈", tags = "用户反馈管理")
@AllArgsConstructor
public class UserFeedbackController extends BladeController {
private final IUserFeedbackService userFeedbackService;
private final IUserClient userClient;
/**
* 新增
*/
@PostMapping("/save")
@ApiOperationSupport(order = 20)
@ApiOperation(value = "新增", notes = "传入UserFeedbackDTO")
public R save(@RequestBody UserFeedbackDTO req) {
/*R<User> userR = userClient.userInfoById(AuthUtil.getUserId());
if (userR.isSuccess()) {
req.setPhone(Optional.ofNullable(userR.getData()).map(User::getPhone).orElse(null));
}*/
return R.status(userFeedbackService.save(req));
}
/**
* 修改
*/
@PostMapping("/update")
@ApiOperationSupport(order = 30)
@ApiOperation(value = "修改", notes = "传入UserFeedbackDTO")
public R update(@RequestBody UserFeedbackDTO req) {
return R.status(userFeedbackService.updateById(req));
}
/**
* 回复
*/
@PostMapping("/reply")
@ApiOperationSupport(order = 30)
@ApiOperation(value = "回复", notes = "传入UserFeedbackDTO")
public R reply(@RequestBody UserFeedbackDTO req) {
req.setReplyUser(AuthUtil.getUserId());
//已回复
req.setStatus(2);
return R.status(userFeedbackService.updateById(req));
}
/**
* 删除
*/
@PostMapping("/remove")
@ApiOperationSupport(order = 10)
@ApiOperation(value = "逻辑删除", notes = "传入ids")
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
return R.status(userFeedbackService.deleteLogic(Func.toLongList(ids)));
}
/**
* 详情
*/
@ApiLog
@GetMapping("/detail")
@ApiOperationSupport(order = 40)
@ApiOperation(value = "详情", notes = "传入id")
public R<UserFeedbackVo> detail(@RequestParam Long id) {
UserFeedbackVo vo = UserFeedbackWrapper.build().entityVO(userFeedbackService.getById(id));
return R.data(vo);
}
/**
* 分页
*/
@ApiLog
@GetMapping("/list")
@ApiOperationSupport(order = 50)
@ApiOperation(value = "分页", notes = "查询条件:startTime,endTime,content,createUser,status")
public R<IPage<UserFeedbackVo>> list(UserFeedbackDTO req, Query query) {
Wrapper<UserFeedbackEntity> queryWrapper = new LambdaQueryWrapper<UserFeedbackEntity>() {{
orderByDesc(UserFeedbackEntity::getCreateTime);
if (ObjectUtil.isNotEmpty(req.getStartTime())) {
ge(UserFeedbackEntity::getCreateTime, req.getStartTime());
}
if (StringUtil.isNotBlank(req.getEndTime())) {
le(UserFeedbackEntity::getCreateTime, req.getEndTime());
}
if (ObjectUtil.isNotEmpty(req.getContent())) {
like(UserFeedbackEntity::getContent, req.getContent());
}
if (ObjectUtil.isNotEmpty(req.getCreateUser())) {
eq(UserFeedbackEntity::getCreateUser, req.getCreateUser());
}
if (ObjectUtil.isNotEmpty(req.getStatus())) {
eq(UserFeedbackEntity::getStatus, req.getStatus());
}
}};
IPage page = userFeedbackService.page(Condition.getPage(query), queryWrapper);
page.setRecords(UserFeedbackWrapper.build().listVO(page.getRecords()));
return R.data(page);
}
/**
* 分页 - 无数据权限控制
*/
@GetMapping("/listNotDataScope")
@ApiOperationSupport(order = 50)
@ApiOperation(value = "分页-无数据权限控制", notes = "查询条件:startTime,endTime,content,createUser,status")
public R<IPage<UserFeedbackVo>> listNotDataScope(UserFeedbackDTO req, Query query) {
IPage iPage = userFeedbackService.pageNotDataScope(Condition.getPage(query), req);
iPage.setRecords(UserFeedbackWrapper.build().listVO(iPage.getRecords()));
return R.data(iPage);
}
}

39
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/dto/UserFeedbackDTO.java

@ -1,39 +0,0 @@
package com.hnac.hzims.operational.main.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.hnac.hzims.operational.main.entity.UserFeedbackEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;
/**
* Created by Sam Huang 2022/5/24 11:09
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class UserFeedbackDTO extends UserFeedbackEntity {
private static final long serialVersionUID = 1L;
@DateTimeFormat(
pattern = "yyyy-MM-dd HH:mm:ss"
)
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss"
)
@ApiModelProperty("查询开始时间")
private String startTime;
@DateTimeFormat(
pattern = "yyyy-MM-dd HH:mm:ss"
)
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss"
)
@ApiModelProperty("查询结束时间")
private String endTime;
}

13
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/mapper/UserFeedbackMapper.java

@ -1,13 +0,0 @@
package com.hnac.hzims.operational.main.mapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.operational.main.dto.UserFeedbackDTO;
import com.hnac.hzims.operational.main.entity.UserFeedbackEntity;
import org.apache.ibatis.annotations.Param;
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
public interface UserFeedbackMapper extends UserDataScopeBaseMapper<UserFeedbackEntity> {
IPage<UserFeedbackEntity> pageNotDataScope(IPage page, @Param("req") UserFeedbackDTO req);
}

26
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/mapper/UserFeedbackMapper.xml

@ -1,26 +0,0 @@
<?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">
<mapper namespace="com.hnac.hzims.operational.main.mapper.UserFeedbackMapper">
<select id="pageNotDataScope" resultType="com.hnac.hzims.operational.main.entity.UserFeedbackEntity">
select * from hzims_user_feedback where IS_DELETED = 0
<if test="req.content!=null and req.content!=''">
AND CONTENT like concat('%',#{req.content},'%')
</if>
<if test="req.status!=null">
AND STATUS = #{req.status}
</if>
<if test="req.startTime!=null">
AND CREATE_TIME <![CDATA[ >= ]]> #{req.startTime}
</if>
<if test="req.endTime!=null">
AND CREATE_TIME <![CDATA[ <= ]]> #{req.endTime}
</if>
<if test="req.createUser!=null">
AND CREATE_USER = #{req.createUser}
</if>
order by CREATE_TIME desc
</select>
</mapper>

15
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IUserFeedbackService.java

@ -1,15 +0,0 @@
package com.hnac.hzims.operational.main.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.operational.main.dto.UserFeedbackDTO;
import com.hnac.hzims.operational.main.entity.UserFeedbackEntity;
import org.springblade.core.mp.base.BaseService;
/**
* Created by Sam Huang 2022/5/24 11:18
*/
public interface IUserFeedbackService extends BaseService<UserFeedbackEntity> {
IPage<UserFeedbackEntity> pageNotDataScope(IPage page, UserFeedbackDTO req);
}

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

@ -1,8 +1,6 @@
package com.hnac.hzims.operational.main.service.impl;
import com.google.common.collect.Lists;
import com.hnac.hzims.EquipmentConstants;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.operational.main.service.IAnalyseDataService;
import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient;
import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO;

28
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/UserFeedbackServiceImpl.java

@ -1,28 +0,0 @@
package com.hnac.hzims.operational.main.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.operational.main.dto.UserFeedbackDTO;
import com.hnac.hzims.operational.main.entity.UserFeedbackEntity;
import com.hnac.hzims.operational.main.mapper.UserFeedbackMapper;
import com.hnac.hzims.operational.main.service.IUserFeedbackService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
/**
* Created by Sam Huang 2022/5/24 11:19
*/
@Service
@Slf4j
@AllArgsConstructor
public class UserFeedbackServiceImpl extends BaseServiceImpl<UserFeedbackMapper, UserFeedbackEntity> implements IUserFeedbackService {
private final UserFeedbackMapper userFeedbackMapper;
@Override
public IPage<UserFeedbackEntity> pageNotDataScope(IPage page, UserFeedbackDTO req) {
return userFeedbackMapper.pageNotDataScope(page, req);
}
}

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/vo/UserFeedbackVo.java

@ -1,6 +1,6 @@
package com.hnac.hzims.operational.main.vo;
import com.hnac.hzims.operational.main.entity.UserFeedbackEntity;
import com.hnac.hzims.operational.feedback.entity.UserFeedbackEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/wrapper/UserFeedbackWrapper.java

@ -1,6 +1,6 @@
package com.hnac.hzims.operational.main.wrapper;
import com.hnac.hzims.operational.main.entity.UserFeedbackEntity;
import com.hnac.hzims.operational.feedback.entity.UserFeedbackEntity;
import com.hnac.hzims.operational.main.vo.UserFeedbackVo;
import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;

18
hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/RunMonthController.java

@ -23,6 +23,22 @@ public class RunMonthController {
private final RunMonthService runMonthService;
@GetMapping("/generate")
@ApiOperation(value = "生成站点月报",notes = "生成站点月报")
@ApiOperationSupport(order = 1)
public R<Boolean> generate(@RequestParam("mon") String mon,
@RequestParam("stationCode") String stationCode){
return R.data(runMonthService.generate(mon,stationCode));
}
@GetMapping("/check")
@ApiOperation(value = "查询站点月报数据",notes = "查询站点月报数据")
@ApiOperationSupport(order = 2)
public R<Boolean> check(@RequestParam("stationCode") String stationCode){
return R.data(runMonthService.check(stationCode));
}
@GetMapping("/data")
@ApiOperation(value = "查询站点月报数据",notes = "查询站点月报数据")
@ApiOperationSupport(order = 3)
@ -33,7 +49,7 @@ public class RunMonthController {
@GetMapping("/export")
@ApiOperation(value = "导出站点运行月报",notes = "导出站点运行月报")
@ApiOperationSupport(order = 3)
@ApiOperationSupport(order = 4)
public void export(@RequestParam("mon") String mon,
@RequestParam("stationCode") String stationCode){
runMonthService.export(mon,stationCode);

13
hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/mapper/RunMonReportMapper.java

@ -0,0 +1,13 @@
package com.hnac.hzims.operational.report.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzims.operational.report.entity.RunMonthEntity;
/**
* @author ysj
* @date 2023/04/10 11:22:14
* @version 4.0.0
*/
public interface RunMonReportMapper extends BaseMapper<RunMonthEntity> {
}

11
hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/RunMonthReportService.java

@ -0,0 +1,11 @@
package com.hnac.hzims.operational.report.service;
import com.hnac.hzims.operational.report.entity.RunMonthEntity;
import org.springblade.core.mp.base.BaseService;
/**
* @author ysj
*/
public interface RunMonthReportService extends BaseService<RunMonthEntity> {
}

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/RunMonthService.java

@ -11,4 +11,8 @@ public interface RunMonthService extends BaseService<RunMonthEntity> {
RunMonthEntity data(String mon, String stationCode);
void export(String mon, String stationCode);
Boolean generate(String mon, String stationCode);
Boolean check(String stationCode);
}

19
hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonReportServiceImpl.java

@ -0,0 +1,19 @@
package com.hnac.hzims.operational.report.service.impl;
import com.hnac.hzims.operational.report.entity.RunMonthEntity;
import com.hnac.hzims.operational.report.mapper.RunMonReportMapper;
import com.hnac.hzims.operational.report.service.RunMonthReportService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
/**
* @author ysj
*/
@Service
@RequiredArgsConstructor
@Slf4j
public class RunMonReportServiceImpl extends BaseServiceImpl<RunMonReportMapper, RunMonthEntity> implements RunMonthReportService {
}

595
hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java

@ -3,10 +3,40 @@ package com.hnac.hzims.operational.report.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.hnac.hzims.alarm.config.constants.AlarmConstants;
import com.hnac.hzims.alarm.config.constants.AlarmHandleConstant;
import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzims.equipment.entity.EmInfoEntity;
import com.hnac.hzims.equipment.entity.PlanGenerationEntity;
import com.hnac.hzims.equipment.feign.IEmInfoClient;
import com.hnac.hzims.equipment.feign.IPlanGenertionClient;
import com.hnac.hzims.equipment.vo.RideDeviceVo;
import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.service.IAnalyseDataService;
import com.hnac.hzims.operational.report.entity.RunMonthEntity;
import com.hnac.hzims.operational.report.mapper.RunMonthMapper;
import com.hnac.hzims.operational.report.service.RunMonthReportService;
import com.hnac.hzims.operational.report.service.RunMonthService;
import com.hnac.hzims.operational.report.vo.*;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IStationService;
import com.hnac.hzims.operational.station.vo.StationVO;
import com.hnac.hzinfo.datasearch.PointData;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO;
import com.hnac.hzinfo.datasearch.history.IHistoryDataSearchClient;
import com.hnac.hzinfo.datasearch.history.OriginalDataQuery;
import com.hnac.hzinfo.datasearch.soe.ISoeClient;
import com.hnac.hzinfo.datasearch.soe.domian.SoeData;
import com.hnac.hzinfo.datasearch.soe.domian.SoeQueryConditionByStation;
import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO;
import com.hnac.hzinfo.sdk.core.response.HzPage;
import com.hnac.hzinfo.sdk.core.response.Result;
import com.hnac.hzinfo.sdk.v5.soe.SoeDataClient;
import com.hnac.hzinfo.sdk.v5.soe.dto.StbAnalysisDTO;
import com.hnac.hzinfo.sdk.v5.soe.vo.StbAnalysisVO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.hssf.usermodel.HSSFFont;
@ -17,10 +47,9 @@ import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.*;
import org.springframework.stereotype.Service;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
@ -31,19 +60,39 @@ import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.*;
import java.util.stream.Collectors;
/**
* @author ysj
*/
@SuppressWarnings("ALL")
@Service
@AllArgsConstructor
@Slf4j
public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMonthEntity> implements RunMonthService {
private final IStationService stationService;
private final IAnalyseDataService dataService;
private final RunMonthReportService runMonthReportService;
private final ISoeClient soeClient;
private final IEmInfoClient deivceClient;
private final SoeDataClient soeDataClient;
private final IPlanGenertionClient planClient;
private final IHistoryDataSearchClient historyDataSearchClient;
// 创建线程池
private static final ExecutorService pool = new ThreadPoolExecutor(5, 5, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("generate-run-report-pool-%d").build() , new ThreadPoolExecutor.CallerRunsPolicy());
/**
* 查询站点月报运行数据
* @param mon
@ -57,23 +106,34 @@ public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMont
.eq(RunMonthEntity::getMonth,mon)
);
if(ObjectUtil.isEmpty(entity)){
throw new ServiceException("站点" + mon + "月份未生成运行月报,请联系管理员进行处理!");
throw new ServiceException("站点" + mon + "月份未生成运行月报,请先点击【生成】按钮生成月报!");
}
RunDataShowVo data = new RunDataShowVo();
BeanUtil.copyProperties(entity,data);
List<RunDataVo> run = JSONObject.parseObject(entity.getRunData(),new TypeReference<List<RunDataVo>>(){});
if(CollectionUtil.isEmpty(run)){
List<RunDataVo> runs = JSONObject.parseObject(entity.getRunData(),new TypeReference<List<RunDataVo>>(){});
if(CollectionUtil.isEmpty(runs)){
return data;
}
double monSumGenerate = run.stream().mapToDouble(RunDataVo::getGenerate).sum();
double monSumPlan = run.stream().mapToDouble(RunDataVo::getPlan).sum();
// 保留两位小数
data.setRunData(JSONObject.toJSONString(runs.stream().map(run->{
// 月发电量
run.setGenerate(BigDecimal.valueOf(run.getGenerate()).setScale(2, RoundingMode.HALF_UP).doubleValue());
// 年发电量
run.setGenerateYear(BigDecimal.valueOf(run.getGenerateYear()).setScale(2, RoundingMode.HALF_UP).doubleValue());
return run;
}).collect(Collectors.toList())));
// 月发电量完成率
double monSumGenerate = runs.stream().mapToDouble(RunDataVo::getGenerate).sum();
double monSumPlan = runs.stream().mapToDouble(RunDataVo::getPlan).sum();
data.setMonSumGenerate(monSumGenerate);
data.setMonSumPlan(monSumPlan);
if(Math.abs(monSumGenerate) > 0 && Math.abs(monSumPlan) > 0){
data.setMonRate(BigDecimal.valueOf(monSumGenerate / monSumPlan * 100L).setScale(2, RoundingMode.HALF_UP).doubleValue());
}
double yearSumGenerate = run.stream().mapToDouble(RunDataVo::getGenerateYear).sum();
double yearSumPlan = run.stream().mapToDouble(RunDataVo::getPlanYear).sum();
// 年发电量完成率
double yearSumGenerate = runs.stream().mapToDouble(RunDataVo::getGenerateYear).sum();
double yearSumPlan = runs.stream().mapToDouble(RunDataVo::getPlanYear).sum();
data.setYearSumGenerate(yearSumGenerate);
data.setYearSumPlan(yearSumPlan);
if(Math.abs(yearSumGenerate) > 0 && Math.abs(yearSumPlan) > 0){
@ -82,7 +142,6 @@ public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMont
return data;
}
/**
* 导出站点月报文件
* @param mon
@ -100,6 +159,17 @@ public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMont
if(ObjectUtil.isEmpty(data)){
throw new ServiceException("站点" + mon + "月份未生成运行月报数据!");
}
List<RunDataVo> runs = JSONObject.parseObject(data.getRunData(),new TypeReference<List<RunDataVo>>(){});
if(CollectionUtil.isNotEmpty(runs)){
// 保留两位小数
data.setRunData(JSONObject.toJSONString(runs.stream().map(run->{
// 月发电量
run.setGenerate(BigDecimal.valueOf(run.getGenerate()).setScale(2, RoundingMode.HALF_UP).doubleValue());
// 年发电量
run.setGenerateYear(BigDecimal.valueOf(run.getGenerateYear()).setScale(2, RoundingMode.HALF_UP).doubleValue());
return run;
}).collect(Collectors.toList())));
}
// 创建Excel文件
// 表头、sheet页、文件名
String headerName = data.getStationName() + "运行月报(" + mon + ")";
@ -124,6 +194,483 @@ public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMont
}
/**
* 生成站点月报
* @param mon
* @param stationCode
* @return
*/
@Override
public Boolean generate(String mon, String stationCode) {
// 步骤2.查询站点
StationEntity station = stationService.getOne(Wrappers.<StationEntity>lambdaQuery()
.eq(StationEntity::getDataOrigin, HomePageConstant.DATA_ORIGIN)
.eq(StationEntity::getType,HomePageConstant.HYDROPOWER)
.eq(StationEntity::getCode,stationCode)
);
if(ObjectUtil.isEmpty(station)){
throw new ServiceException("未查询到站点信息!");
}
// 查询站点设备
List<RideDeviceVo> devices = deivceClient.rideDevices(Collections.singletonList(station.getRefDept()));
if(CollectionUtil.isEmpty(devices)){
throw new ServiceException("站点未配置机组设备信息、请先为站点添加设备,绑定设备实例,再进行月报查询!");
}
// 计划发电量
List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(Collections.singletonList(stationCode), null , DateUtil.format(new Date(),"yyyy"));
RunMonthEntity run = new RunMonthEntity();
run.setTenantId(station.getTenantId());
run.setCreateDept(station.getRefDept());
run.setCreateUser(station.getCreateUser());
run.setUpdateUser(station.getUpdateUser());
run.setStationCode(station.getCode());
run.setStationName(station.getName());
run.setMonth(mon);
Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse(mon,"yyyy-MM"));
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
calendar.add(Calendar.MONTH,1);
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
// 告警数据
run.setAlarmData(this.alarmData(station.getCode(),start,end));
List<RunDataVo> runDatas = new ArrayList<>();
List<CurveEchartVo> curveEcharts = new ArrayList<>();
for (RideDeviceVo device : devices){
// 运行数据
runDatas.add(this.runData(station.getCode(),device,plans,start,end));
// 月度运行曲线
curveEcharts.add(this.curveData(device,start,end));
}
/*CountDownLatch countDownLatch = new CountDownLatch(devices.size());
List<RunDataVo> runDatas = new CopyOnWriteArrayList<>();
List<CurveEchartVo> curveEcharts = new CopyOnWriteArrayList<>();
for (RideDeviceVo device : devices){
pool.submit(()->{
// 运行数据
runDatas.add(this.runData(station.getCode(),device,plans,start,end));
// 月度运行曲线
curveEcharts.add(this.curveData(device,start,end));
countDownLatch.countDown();
});
}
//所有模板数据获取完成后释放锁
try {
countDownLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
}*/
if(!CollectionUtil.isEmpty(runDatas)){
run.setRunData(JSONObject.toJSONString(runDatas));
}
if(!CollectionUtil.isEmpty(curveEcharts)){
run.setCurveData(JSONObject.toJSONString(curveEcharts));
}
// TODO 运行数据分析
// TODO 运行建议及其他
// 先删除原先月报数据
this.deleteRunReport(mon,stationCode);
// 保存生成月报数据
return runMonthReportService.save(run);
}
/**
* 先删除原先月报数据
* @param mon
* @param stationCode
*/
private void deleteRunReport(String mon, String stationCode) {
List<RunMonthEntity> runs = runMonthReportService.list(Wrappers.<RunMonthEntity>lambdaQuery()
.eq(RunMonthEntity::getMonth,mon)
.eq(RunMonthEntity::getStationCode,stationCode)
);
if(CollectionUtil.isEmpty(runs)){
return;
}
this.runMonthReportService.deleteLogic(runs.stream().map(RunMonthEntity::getId).collect(Collectors.toList()));
}
/**
* 运行数据
* @param devices
* @return
*/
private RunDataVo runData(String stationCode,RideDeviceVo device,List<PlanGenerationEntity> plans,String start,String end) {
RunDataVo run = new RunDataVo();
run.setDeviceCode(device.getNumber());
run.setDeviceName(device.getName());
// 运行时长
run.setRunHours(this.runHours(device,DateUtil.parse(start,DateUtil.PATTERN_DATETIME), DateUtil.parse(end,DateUtil.PATTERN_DATETIME)));
// 月发电量
Double day = this.generates(0,device.getNumber(),device.getRide(),start,end);
if(ObjectUtil.isEmpty(day)){
run.setGenerate(0.0);
}else{
run.setGenerate(day/10000);
}
// 年发电量
Double year = this.generates(1,device.getNumber(),device.getRide(),start,end);
if(ObjectUtil.isEmpty(day)){
run.setGenerateYear(0.0);
}else{
run.setGenerateYear(year/10000);
}
// 计划发电量
run.setPlan(this.planGenerate(0,stationCode,plans)/10000);
// 年计划发电量
run.setPlanYear(this.planGenerate(1,stationCode,plans)/10000);
return run;
}
/**
* 实际发电量
* @param type
* @param deviceCode
* @param ride
* @return
*/
private Double generates(int type,String deviceCode,double ride,String start,String end) {
if(type == 0){
return Double.valueOf(dataService.periodTargetFloat(start,end,5,5,deviceCode,ride,HomePageConstant.HYDROPOWER_GENERATE_POWER));
}
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MONTH,-calendar.get(Calendar.MONTH));
calendar.add(Calendar.DAY_OF_MONTH,-calendar.get(Calendar.DAY_OF_MONTH));
calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY));
calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE));
calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND));
calendar.add(Calendar.DAY_OF_MONTH,1);
return Double.valueOf(dataService.periodTargetFloat(DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME),end,5,6,deviceCode,ride,HomePageConstant.HYDROPOWER_GENERATE_POWER));
}
/**
* 计划发电量
* @param type
* @param stationCode
* @param plans
* @return
*/
private Double planGenerate(int type, String stationCode,List<PlanGenerationEntity> plans) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse("2024-05-01 00:00:00",DateUtil.PATTERN_DATETIME));
if(type == 0){
calendar.add(Calendar.DAY_OF_MONTH,-1);
calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY) + 1);
calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE));
calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND));
String time = DateUtil.format(calendar.getTime(),"yyyy-MM");
return plans.stream().filter(plan -> plan.getStationId().equals(stationCode) && plan.getDateTime().contains(time))
.mapToDouble(PlanGenerationEntity::getPlanGeneration).sum();
}
String time = DateUtil.format(calendar.getTime(),"yyyy");
return plans.stream().filter(plan -> plan.getStationId().equals(stationCode) && plan.getDateTime().contains(time))
.mapToDouble(PlanGenerationEntity::getPlanGeneration).sum();
}
/**
* 获取运行数据
* @param device
* @return
*/
private Double runHours(RideDeviceVo device,Date startDate,Date endDate) {
MultiAnalyzeCodePO analyze = new MultiAnalyzeCodePO();
analyze.setDeviceCode(device.getNumber());
analyze.setSignages(Collections.singletonList(HomePageConstant.ACTIVE_POWER));
List<AnalyzeCodeBySignagesVO> signages = dataService.analyzeCodeBySignages(Collections.singletonList(analyze));
if(CollectionUtil.isEmpty(signages)){
return 0.0;
}
// 监测点
String realId = signages.get(0).getRealId();
if(StringUtils.isEmpty(realId)){
return 0.0;
}
return this.getRunConvertData(realId,startDate,endDate);
}
/**
* 获取时间范围内运行时长
* @param realId
* @param startDate
* @param endDate
* @return
*/
private Double getRunConvertData(String realId, Date startDate, Date endDate) {
OriginalDataQuery originalDataQuery = new OriginalDataQuery();
originalDataQuery.setRealId(realId);
originalDataQuery.setBeginTime(startDate);
originalDataQuery.setEndTime(endDate);
originalDataQuery.setLimit(100000);
originalDataQuery.setPage(1);
// 查询时间范围开关机监测点历史数据
Result<HzPage<PointData>> result = historyDataSearchClient.getOriginalDataByRealIds(originalDataQuery);
if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData())){
return 0.0;
}
// 开机运行时长
long time = this.getRunTime(result.getData().getRecords(),startDate,endDate);
return BigDecimal.valueOf(time / (1000 * 60 * 60.00)).setScale(2, RoundingMode.HALF_UP).doubleValue();
}
/**
* 获取运行时长
* @param result
* @return
*/
private long getRunTime(List<PointData> result,Date startDate,Date endDate) {
if(result.size() == 1){
// 一直开机
if(Double.parseDouble(result.get(0).getValue()) > 0){
return endDate.getTime() - startDate.getTime();
}
// 一直关机
return 0;
}
long time=0;
// 遍历累计开机时长
for(int i = 0; i< result.size() ; i++){
// 记录为开机状态 就计算到下次关机的时间差
if(Double.parseDouble(result.get(i).getValue()) <= 0){
continue;
}
Date endTime,startTime = DateUtil.parse(result.get(i).getTime(), DateUtil.PATTERN_DATETIME);
// 遍历至最后一条数据,累计至当前时间
if(i == result.size() - 1){
endTime = endDate;
}else {
endTime = DateUtil.parse(result.get(i+1).getTime(), DateUtil.PATTERN_DATETIME);
}
time += endTime.getTime() - startTime.getTime();
}
return time;
}
/**
* 告警数据
* @param code
* @return
*/
private String alarmData(String code,String start,String end) {
// HZ3000:故障告警
List<RunAlarmVo> alarms = this.hz3000Alarm(code,start,end);
// FDP智能预警
alarms.addAll(this.intelligentEarly(code,start,end));
return JSONObject.toJSONString(alarms);
}
/**
* 查询hz3000告警
* @param code
*/
private List<RunAlarmVo> hz3000Alarm(String code,String start,String end) {
SoeQueryConditionByStation query = new SoeQueryConditionByStation();
query.setStationIds(Collections.singletonList(code));
query.setTypes(Collections.singletonList(AlarmHandleConstant.FAULT));
query.setBeginTime(LocalDateTime.parse(start,DateUtil.DATETIME_FORMATTER));
query.setEndTime(LocalDateTime.parse(end,DateUtil.DATETIME_FORMATTER));
query.setNeedPage(false);
Result<HzPage<SoeData>> result = soeClient.getByStationsAndTime(query);
if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData()) || CollectionUtil.isEmpty(result.getData().getRecords())){
return new ArrayList<>();
}
return result.getData().getRecords().stream().collect(Collectors.groupingBy(SoeData::getSoeExplain)).entrySet().stream().map(entry->{
RunAlarmVo alarm = new RunAlarmVo();
alarm.setAlarmTime(DateUtil.format(entry.getValue().stream().sorted(Comparator.comparing(SoeData::getTs)).collect(Collectors.toList()).get(0).getTs(),DateUtil.PATTERN_DATETIME));
alarm.setDeviceName(entry.getValue().get(0).getDeviceName());
alarm.setContent(entry.getKey());
alarm.setType(String.valueOf(AlarmConstants.FAULT));
alarm.setTypeName("故障");
alarm.setCount(Math.max(entry.getValue().stream().filter(o->StringUtil.isNotBlank(o.getTraceCount())).mapToInt(soe->Integer.parseInt(soe.getTraceCount())).sum(), 1));
return alarm;
}).collect(Collectors.toList());
}
/**
* 智能预警
* @param code
* @param start
* @param end
* @return
*/
private List<RunAlarmVo> intelligentEarly(String code, String start, String end) {
StbAnalysisDTO param = new StbAnalysisDTO();
param.setStartTime(LocalDateTime.parse(start,DateUtil.DATETIME_FORMATTER));
param.setEndTime(LocalDateTime.parse(end, DateUtil.DATETIME_FORMATTER));
param.setStations(Collections.singletonList(code));
param.setNeedPage(false);
Result<HzPage<StbAnalysisVO>> result = soeDataClient.pageStbAnalysis(param);
if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData()) || CollectionUtil.isEmpty(result.getData().getRecords())){
return new ArrayList<>();
}
return result.getData().getRecords().stream().collect(Collectors.groupingBy(StbAnalysisVO::getName)).entrySet().stream().map(entry->{
RunAlarmVo alarm = new RunAlarmVo();
alarm.setAlarmTime(entry.getValue().stream().sorted(Comparator.comparing(StbAnalysisVO::getTs)).collect(Collectors.toList()).get(0).getTs());
alarm.setDeviceName(entry.getValue().get(0).getOrd());
alarm.setContent(entry.getKey());
alarm.setType(String.valueOf(AlarmConstants.EARLY));
alarm.setTypeName("智能预警");
alarm.setReason(entry.getValue().get(0).getFinfo());
alarm.setMemo(entry.getValue().get(0).getInfo());
alarm.setCount(entry.getValue().size());
return alarm;
}).collect(Collectors.toList());
}
/**
* 运行曲线
* @param devices
* @return
*/
private CurveEchartVo curveData(RideDeviceVo device,String start,String end) {
CurveEchartVo curveData = new CurveEchartVo();
curveData.setDeviceCode(device.getNumber());
curveData.setDeviceName(device.getName());
// 负荷曲线
curveData.setLoadCurve(this.curve(this.attribute(0),start,end, device.getNumber()));
// 轴承温度曲线
curveData.setBearingTempCurve(this.curve(this.attribute(1),start,end, device.getNumber()));
// 定子温度曲线
curveData.setStatorTempCurve(this.curve(this.attribute(2),start,end, device.getNumber()));
return curveData;
}
/**
* 获取曲线数据
* @param attributes
* @param deviceCode
* @return
*
*
*/
private List<EchartVo> curve(List<AttributeVo> attributes,String start,String end, String deviceCode) {
List<AnalyzeDataConditionVO> datas = dataService.periodTargetSignages(start,end,3,3,deviceCode,attributes.stream().map(AttributeVo::getSignage).collect(Collectors.toList()));
if(CollectionUtil.isEmpty(datas)){
return new ArrayList<>();
}
List<AnalyseDataTaosVO> analyseDatas = new ArrayList<>();
Calendar day = Calendar.getInstance();
datas.forEach(data->{
if(CollectionUtil.isEmpty(data.getList())){
return;
}
analyseDatas.addAll(data.getList().stream().peek(item->{
item.setSignage(data.getSignage());
Date date = DateUtil.parse(item.getTs(), "yyyy-MM-dd HH:mm:ss.s");
day.setTime(date);
item.setTs(String.valueOf(day.get(Calendar.DAY_OF_MONTH)));
}).collect(Collectors.toList()));
});
if(CollectionUtil.isEmpty(analyseDatas)){
return new ArrayList<>();
}
Map<String,List<AnalyseDataTaosVO>> map = analyseDatas.stream().collect(Collectors.groupingBy(AnalyseDataTaosVO::getTs));
return map.entrySet().stream().map(entry->{
EchartVo echart = new EchartVo();
echart.setTime(Integer.valueOf(entry.getKey()));
echart.setValues(entry.getValue().stream().map(value->{
EchartValueVo echartValue = new EchartValueVo();
echartValue.setAttribute(value.getSignage());
echartValue.setAttributeName(attributes.stream().filter(o->o.getSignage().equals(value.getSignage())).collect(Collectors.toList()).get(0).getSignageName());
if(StringUtil.isEmpty(value.getVal())){
echartValue.setValue(0.0);
}else{
echartValue.setValue(Double.parseDouble(value.getVal()));
}
return echartValue;
}).collect(Collectors.toList()));
return echart;
}).sorted(Comparator.comparing(EchartVo::getTime)).collect(Collectors.toList());
}
/**
* 曲线属性获取
* @param attributeType
* @return
*/
private List<AttributeVo> attribute(int attributeType) {
List<AttributeVo> attributes = new ArrayList<>();
switch (attributeType){
case 0:
AttributeVo attribute = new AttributeVo();
attribute.setSignage(HomePageConstant.ACTIVE_POWER);
attribute.setSignageName("负荷");
attributes.add(attribute);
break;
case 1:
AttributeVo upper_temp = new AttributeVo();
upper_temp.setSignage(HomePageConstant.UPPER_GUIDE_BEARING_TEMP);
upper_temp.setSignageName("上导轴承瓦温1");
attributes.add(upper_temp);
AttributeVo oil_tem = new AttributeVo();
oil_tem.setSignage(HomePageConstant.UPPER_GUIDE_BEARING_OIL_GROOVE_TEMP);
oil_tem.setSignageName("上导轴承油槽温度");
attributes.add(oil_tem);
AttributeVo thrust_tem = new AttributeVo();
thrust_tem.setSignage(HomePageConstant.THRUST_BEARING_TEMP);
thrust_tem.setSignageName("推力轴瓦温度1");
attributes.add(thrust_tem);
AttributeVo lower_tem = new AttributeVo();
lower_tem.setSignage(HomePageConstant.LOWER_GUIDE_BEARING_TEMP);
lower_tem.setSignageName("下导轴承瓦温1");
attributes.add(lower_tem);
AttributeVo tank_tem = new AttributeVo();
tank_tem.setSignage(HomePageConstant.LOWER_GUIDE_OIL_TANK_TEMP);
tank_tem.setSignageName("下导油槽温度");
attributes.add(tank_tem);
AttributeVo tile_tem = new AttributeVo();
tile_tem.setSignage(HomePageConstant.WATER_GUIDE_TILE_TEMP);
tile_tem.setSignageName("水导瓦温");
attributes.add(tile_tem);
AttributeVo water_tem = new AttributeVo();
water_tem.setSignage(HomePageConstant.WATER_GUIDE_OIL_TANK_TEMP);
water_tem.setSignageName("水导油槽温度");
attributes.add(water_tem);
break;
case 2:
AttributeVo A_tem = new AttributeVo();
A_tem.setSignage(HomePageConstant.A_PHASE_IRON_CORE_TEMP);
A_tem.setSignageName("A相铁芯温度1");
attributes.add(A_tem);
AttributeVo B_tem = new AttributeVo();
B_tem.setSignage(HomePageConstant.B_PHASE_IRON_CORE_TEMP);
B_tem.setSignageName("B相铁芯温度1");
attributes.add(B_tem);
AttributeVo C_tem = new AttributeVo();
C_tem.setSignage(HomePageConstant.C_PHASE_IRON_CORE_TEMP);
C_tem.setSignageName("C相铁芯温度1");
attributes.add(C_tem);
break;
}
return attributes;
}
/**
* 检查站点是否存在设备信息
* @param stationCode
* @return
*/
@Override
public Boolean check(String stationCode) {
// 查询站点
StationVO station = stationService.getStationByCode(stationCode);
if(ObjectUtil.isEmpty(station)){
throw new ServiceException("未查询到站点信息!");
}
// 查询设备
R<List<EmInfoEntity>> emInfos = deivceClient.getEmInfoByDept(Collections.singletonList(station.getRefDept()));
if(!emInfos.isSuccess() || CollectionUtil.isEmpty(emInfos.getData())){
throw new ServiceException("站点未配置机组设备信息、请先为站点添加设备,绑定设备实例,再进行月报查询!");
}
List<EmInfoEntity> devices = emInfos.getData().stream().filter(o->"2".equals(o.getEmType())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(devices)){
throw new ServiceException("站点未配置机组设备信息、请先为站点添加设备,绑定设备实例,再进行月报查询!");
}
return true;
}
/**
* 手绘运行数据表格
* @return
*/
@ -280,16 +827,14 @@ public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMont
*/
private List<CurveYArrayVo> curveToArray(List<EchartVo> curves) {
List<CurveAttrValueVo> attrValues = new ArrayList<>();
curves.forEach(curve->{
attrValues.addAll(curve.getValues().stream().map(value->{
CurveAttrValueVo attrValue = new CurveAttrValueVo();
attrValue.setAttribute(value.getAttribute());
attrValue.setAttributeName(value.getAttributeName());
attrValue.setTime(curve.getTime());
attrValue.setValue(value.getValue());
return attrValue;
}).collect(Collectors.toList()));
});
curves.forEach(curve-> attrValues.addAll(curve.getValues().stream().map(value->{
CurveAttrValueVo attrValue = new CurveAttrValueVo();
attrValue.setAttribute(value.getAttribute());
attrValue.setAttributeName(value.getAttributeName());
attrValue.setTime(curve.getTime());
attrValue.setValue(value.getValue());
return attrValue;
}).collect(Collectors.toList())));
return attrValues.stream().collect(Collectors.groupingBy(CurveAttrValueVo::getAttribute)).entrySet().stream().map(entry->{
CurveYArrayVo yArray = new CurveYArrayVo();
yArray.setAttribute(entry.getKey());

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java

@ -252,8 +252,6 @@ public class RealMonitorServiceImpl implements IRealMonitorService {
this.weather(nowWeather,weekWeather,item);
// 前池水位
this.waterLevel(levelList,item);
// 总有功率
this.activePower(item);
});
log.info("步骤4站点数据处理 耗时 : {}",System.currentTimeMillis() - beginTime);
return new TextMessage(JSONObject.toJSONString(validList.stream().peek(o->{

69
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/CarController.java

@ -5,6 +5,7 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.common.utils.Condition;
import com.hnac.hzims.safeproduct.Constants;
import com.hnac.hzims.safeproduct.dto.CarCheckRecordDTO;
import com.hnac.hzims.safeproduct.dto.CarCheckTemplateDTO;
import com.hnac.hzims.safeproduct.dto.CarMaintenanceConfirmationDTO;
import com.hnac.hzims.safeproduct.dto.CarUsedRecordConfirmationDTO;
import com.hnac.hzims.safeproduct.entity.*;
@ -54,6 +55,8 @@ public class CarController extends BladeController {
private final ICarInsuranceService carInsuranceService;
private final ICarCheckTemplateService carCheckTemplateService;
@PostMapping("/saveCar")
@ApiOperation(value = "新增车辆")
@ApiOperationSupport(order = 1)
@ -269,31 +272,47 @@ public class CarController extends BladeController {
return R.data(page);
}
// @ApiOperation(value = "新增车检记录模板")
// @ApiOperationSupport(order = 39)
// public R saveCarCheckRecordTemplate() {
//
// }
//
// @ApiOperationSupport(order = 40)
// public R updateCarCheckRecordTemplate() {
//
// }
//
// @ApiOperationSupport(order = 41)
// public R removeCarCheckRecordTemplate() {
//
// }
//
// @ApiOperationSupport(order = 42)
// public R carCheckRecordTemplateDetail() {
//
// }
//
// @ApiOperationSupport(order = 43)
// public R carCheckRecordTemplatePage() {
//
// }
@PostMapping("/saveCarCheckTemplate")
@ApiOperation(value = "新增车检模板")
@ApiOperationSupport(order = 39)
@Operate(label = "新增车检模板", type = BusinessType.INSERT, ignore = false)
public R saveCarCheckTemplate(@RequestBody CarCheckTemplateDTO dto) {
return R.status(carCheckTemplateService.saveCarCheckTemplate(dto));
}
@PostMapping("/updateCarCheckTemplate")
@ApiOperation(value = "修改车检模板")
@ApiOperationSupport(order = 40)
@Operate(label = "修改车检模板", type = BusinessType.UPDATE, ignore = false)
public R updateCarCheckTemplate(@RequestBody CarCheckTemplateDTO dto) {
return R.status(carCheckTemplateService.updateCarCheckTemplate(dto));
}
@GetMapping("/removeCarCheckTemplate")
@ApiOperation(value = "删除车检模板")
@ApiOperationSupport(order = 41)
@Operate(label = "删除车检模板", type = BusinessType.DELETE, ignore = false)
public R removeCarCheckTemplate(@RequestParam Long id) {
return R.status(carCheckTemplateService.removeCarCheckTemplate(id));
}
@GetMapping("/carCheckTemplateDetail")
@ApiOperation(value = "车检模板详情")
@ApiOperationSupport(order = 42)
@Operate(label = "车检模板详情", type = BusinessType.QUERY, ignore = false)
public R<CarCheckTemplateDetailVO> carCheckTemplateDetail(@RequestParam Long id) {
CarCheckTemplateDetailVO vo = carCheckTemplateService.getCarCheckTemplateDetail(id);
return R.data(vo);
}
@GetMapping("/carCheckTemplatePage")
@ApiOperation(value = "车检模板分页")
@ApiOperationSupport(order = 43)
@Operate(label = "车检模板分页", type = BusinessType.QUERY, ignore = false)
public R<IPage<CarCheckTemplateEntity>> carCheckTemplatePage(@ApiIgnore @RequestParam Map<String, Object> param, Query query) {
IPage<CarCheckTemplateEntity> page = carCheckTemplateService.getCarCheckTemplatePage(query, param);
return R.data(page);
}
@GetMapping("/exportCarMaintenanceData")
@ApiOperation(value = "导出车辆维保记录单")

15
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarCheckTemplateDetailMapper.java

@ -0,0 +1,15 @@
package com.hnac.hzims.safeproduct.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzims.safeproduct.entity.CarCheckTemplateDetailEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 车检模板详情Mapper类
*
* @date 2024-05-30
*/
@Mapper
public interface CarCheckTemplateDetailMapper extends BaseMapper<CarCheckTemplateDetailEntity> {
}

5
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarCheckTemplateDetailMapper.xml

@ -0,0 +1,5 @@
<?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">
<mapper namespace="com.hnac.hzims.safeproduct.mapper.CarCheckTemplateDetailMapper">
</mapper>

20
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarCheckTemplateMapper.java

@ -0,0 +1,20 @@
package com.hnac.hzims.safeproduct.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.safeproduct.entity.CarCheckTemplateEntity;
import org.apache.ibatis.annotations.Mapper;
import java.util.Map;
@Mapper
public interface CarCheckTemplateMapper extends BaseMapper<CarCheckTemplateEntity> {
/**
* 车检分页
* @param page 分页类
* @param param 参数
* @return 分页
*/
IPage<CarCheckTemplateEntity> getCarCheckTemplatePage(IPage<CarCheckTemplateEntity> page, Map<String, Object> param);
}

18
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarCheckTemplateMapper.xml

@ -0,0 +1,18 @@
<?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">
<mapper namespace="com.hnac.hzims.safeproduct.mapper.CarCheckTemplateMapper">
<select id="getCarCheckTemplatePage" resultType="com.hnac.hzims.safeproduct.entity.CarCheckTemplateEntity">
SELECT
*
FROM
car_check_template_detail
WHERE
is_deleted = 0
<if test="param.templateName != null and param.templateName != ''">
AND template_name like concate('%', #{param.templateName}, '%')
</if>
ORDER BY
create_time DESC
</select>
</mapper>

61
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarCheckTemplateService.java

@ -0,0 +1,61 @@
package com.hnac.hzims.safeproduct.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.safeproduct.dto.CarCheckTemplateDTO;
import com.hnac.hzims.safeproduct.entity.CarCheckTemplateEntity;
import com.hnac.hzims.safeproduct.vo.CarCheckTemplateDetailVO;
import org.springblade.core.mp.support.Query;
import java.util.Map;
/**
* 车检模板服务类
*
* @date 2024-05-28
*/
public interface ICarCheckTemplateService extends IService<CarCheckTemplateEntity> {
/**
* 新增车检模板
* @param dto 车检模板dto类
* @return true-成功false-失败
*/
boolean saveCarCheckTemplate(CarCheckTemplateDTO dto);
/**
* 根据名称获取车检模板
* @param name 模板名称
* @return 车检模板实体类
*/
CarCheckTemplateEntity getCarCheckTemplateByName(String name);
/**
* 修改车检模板
* @param dto 车检模板dto类
* @return true-成功false-失败
*/
boolean updateCarCheckTemplate(CarCheckTemplateDTO dto);
/**
* 删除车检模板
* @param id 模板id
* @return true-成功false-失败
*/
boolean removeCarCheckTemplate(Long id);
/**
* 车检模板详情
* @param id 模板id
* @return 模板详情VO类
*/
CarCheckTemplateDetailVO getCarCheckTemplateDetail(Long id);
/**
* 车检分页
* @param query 分页类
* @param param 参数
* @return 分页
*/
IPage<CarCheckTemplateEntity> getCarCheckTemplatePage(Query query, Map<String, Object> param);
}

67
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckRecordServiceImpl.java

@ -18,6 +18,7 @@ import com.hnac.hzims.safeproduct.service.ICarCheckRecordService;
import com.hnac.hzims.safeproduct.utils.BaseUtil;
import com.hnac.hzims.safeproduct.vo.CarCheckRecordDetailVO;
import com.hnac.hzims.safeproduct.vo.CarCheckRecordPageVO;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.utils.BeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
@ -68,15 +69,16 @@ public class CarCheckRecordServiceImpl extends ServiceImpl<CarCheckRecordMapper,
String lastCode = getLastCode(currentNormMonth);
String code = BaseUtil.getUniqueCode("CLJC", lastCode, currentSimpleMonth);
carCheckRecordEntity.setCode(code);
// 新增车检记录成功,新增相关检查项数据
// 新增车检记录
boolean saveRecord = this.save(carCheckRecordEntity);
if (saveRecord) {
CarCheckRecordEntity recordEntity = getCarCheckRecordByCode(code);
List<CarCheckItemEntity> itemList = carCheckRecordDTO.getItemList();
itemList.forEach(x -> x.setCarCheckRecordId(recordEntity.getId()));
return carCheckItemService.saveBatch(itemList);
if (!saveRecord) {
throw new ServiceException("车检记录新增失败");
}
return false;
// 新增车检项
CarCheckRecordEntity recordEntity = getCarCheckRecordByCode(code);
List<CarCheckItemEntity> itemList = carCheckRecordDTO.getItemList();
itemList.forEach(x -> x.setCarCheckRecordId(recordEntity.getId()));
return carCheckItemService.saveBatch(itemList);
}
/**
@ -104,7 +106,19 @@ public class CarCheckRecordServiceImpl extends ServiceImpl<CarCheckRecordMapper,
}
// 拼装检查列表
List<CarCheckItemEntity> itemList = carCheckItemService.getListByCarCheckRecordId(id);
carCheckRecordDetailVO.setCheckItemList(itemList);
List<CarCheckItemEntity> checkItemList = new ArrayList<>();
itemList.forEach(item -> {
String[] contents = item.getCheckContent().split(",|,");
String[] results = item.getCheckResult().split(",|,");
for (int i = 0; i < contents.length; i++) {
CarCheckItemEntity carCheckItemEntity = new CarCheckItemEntity();
carCheckItemEntity.setCheckItem(item.getCheckItem());
carCheckItemEntity.setCheckContent(contents[i]);
carCheckItemEntity.setCheckResult(results[i]);
checkItemList.add(carCheckItemEntity);
}
});
carCheckRecordDetailVO.setCheckItemList(checkItemList);
return carCheckRecordDetailVO;
}
return null;
@ -157,22 +171,25 @@ public class CarCheckRecordServiceImpl extends ServiceImpl<CarCheckRecordMapper,
@Transactional(rollbackFor = Exception.class)
@Override
public boolean updateCarCheckRecord(CarCheckRecordDTO carCheckRecordDTO) {
boolean deleteFlag = carCheckItemService.removeRelativeCarCheckItem(carCheckRecordDTO.getId());
if (!deleteFlag){
return false;
// 修改车检记录
CarCheckRecordEntity carCheckRecordEntity = new CarCheckRecordEntity();
BeanUtil.copyProperties(carCheckRecordDTO, carCheckRecordEntity);
boolean updateRecord = this.updateById(carCheckRecordEntity);
if (!updateRecord) {
throw new ServiceException("车检记录更新失败");
}
// 更新检查项
List<CarCheckItemEntity> itemList = carCheckRecordDTO.getItemList();
itemList.forEach(x -> {x.setCarCheckRecordId(carCheckRecordDTO.getId());
x.setId(null);});
boolean b = carCheckItemService.saveBatch(itemList);
if (b) {
// 若更新检查项成功,则更新车检记录
CarCheckRecordEntity carCheckRecordEntity = new CarCheckRecordEntity();
BeanUtil.copyProperties(carCheckRecordDTO, carCheckRecordEntity);
return this.updateById(carCheckRecordEntity);
// 删除旧的检查项
boolean deleteItem = carCheckItemService.removeRelativeCarCheckItem(carCheckRecordDTO.getId());
if (!deleteItem) {
throw new ServiceException("旧的车检记录检查项删除失败");
}
return false;
// 新增新的检查项
List<CarCheckItemEntity> itemList = carCheckRecordDTO.getItemList();
itemList.forEach(x -> {
x.setCarCheckRecordId(carCheckRecordDTO.getId());
// x.setId(null);
});
return carCheckItemService.saveBatch(itemList);
}
/**
@ -182,10 +199,10 @@ public class CarCheckRecordServiceImpl extends ServiceImpl<CarCheckRecordMapper,
@Override
public boolean removeCarCheckRecord(Long id) {
boolean remove = this.removeById(id);
if (remove) {
return carCheckItemService.removeRelativeCarCheckItem(id);
if (!remove) {
throw new ServiceException("车检记录删除失败");
}
return false;
return carCheckItemService.removeRelativeCarCheckItem(id);
}
/**

37
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckTemplateDetailServiceImpl.java

@ -0,0 +1,37 @@
package com.hnac.hzims.safeproduct.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.safeproduct.entity.CarCheckTemplateDetailEntity;
import com.hnac.hzims.safeproduct.mapper.CarCheckTemplateDetailMapper;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
/**
* 车检模板详情服务实现类
*
* @date 2024-05-30
*/
@Service
public class CarCheckTemplateDetailServiceImpl extends ServiceImpl<CarCheckTemplateDetailMapper, CarCheckTemplateDetailEntity>
implements ICarCheckTemplateDetailService {
/**
* 删除关联的模板详情数据
*/
@Override
public boolean removeReferenceDetail(Long templateId) {
List<CarCheckTemplateDetailEntity> list = this.getReferenceDetail(templateId);
List<Long> ids = list.stream().map(CarCheckTemplateDetailEntity::getId).collect(Collectors.toList());
return this.removeByIds(ids);
}
@Override
public List<CarCheckTemplateDetailEntity> getReferenceDetail(Long templateId) {
QueryWrapper<CarCheckTemplateDetailEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(CarCheckTemplateDetailEntity::getTemplateId, templateId);
return this.list(queryWrapper);
}
}

161
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckTemplateServiceImpl.java

@ -0,0 +1,161 @@
package com.hnac.hzims.safeproduct.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.safeproduct.dto.CarCheckTemplateDTO;
import com.hnac.hzims.safeproduct.entity.*;
import com.hnac.hzims.safeproduct.mapper.CarCheckTemplateMapper;
import com.hnac.hzims.safeproduct.service.ICarCheckTemplateService;
import com.hnac.hzims.safeproduct.vo.CarCheckTemplateDetailVO;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.system.feign.ISysClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
* 车检模板服务实现类
*
* @date 2024-05-28
*/
@Service
public class CarCheckTemplateServiceImpl extends ServiceImpl<CarCheckTemplateMapper, CarCheckTemplateEntity> implements ICarCheckTemplateService {
@Autowired
ICarCheckTemplateDetailService carCheckTemplateDetailService;
@Resource
CarCheckTemplateMapper carCheckTemplateMapper;
@Autowired
ISysClient sysClient;
/**
* 新增车检模板
*/
@Override
@Transactional(rollbackFor = Exception.class)
public boolean saveCarCheckTemplate(CarCheckTemplateDTO dto) {
String templateName = dto.getTemplateName();
// 重名校验
CarCheckTemplateEntity template = getCarCheckTemplateByName(templateName);
if (template != null) {
throw new ServiceException("模板名不可重复");
}
// 新增车检模板
CarCheckTemplateEntity templateEntity = new CarCheckTemplateEntity();
templateEntity.setTemplateName(templateName);
boolean saveTemplate = this.save(templateEntity);
if (!saveTemplate) {
throw new ServiceException("车检模板新增失败");
}
// 新增模板详情
template = getCarCheckTemplateByName(templateName);
List<CarCheckTemplateDetailEntity> details = dto.getDetailList();
for (CarCheckTemplateDetailEntity detail : details) {
detail.setTemplateId(template.getId());
}
return carCheckTemplateDetailService.saveBatch(details);
}
/**
* 根据名称获取车检模板
*/
public CarCheckTemplateEntity getCarCheckTemplateByName(String name) {
QueryWrapper<CarCheckTemplateEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(CarCheckTemplateEntity::getTemplateName, name);
return this.getOne(queryWrapper);
}
/**
* 修改车检模板
*/
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updateCarCheckTemplate(CarCheckTemplateDTO dto) {
String templateName = dto.getTemplateName();
Long templateId = dto.getId();
// 重名校验
QueryWrapper<CarCheckTemplateEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(CarCheckTemplateEntity::getTemplateName, templateName);
queryWrapper.lambda().ne(CarCheckTemplateEntity::getId, templateId);
CarCheckTemplateEntity template = this.getOne(queryWrapper);
if (template != null) {
throw new ServiceException("模板名不可重复");
}
// 更新模板
CarCheckTemplateEntity templateEntity = new CarCheckTemplateEntity();
templateEntity.setId(templateId);
templateEntity.setTemplateName(templateName);
boolean updateTemplate = this.updateById(templateEntity);
if (!updateTemplate) {
throw new ServiceException("车检模板更新失败");
}
// 更新模板详情
// 删除旧的模板详情数据
boolean removeDetail = carCheckTemplateDetailService.removeReferenceDetail(templateId);
if (!removeDetail) {
throw new ServiceException("车检模板详情数据删除失败");
}
// 新增新的模板详情数据
List<CarCheckTemplateDetailEntity> detailList = dto.getDetailList();
for (CarCheckTemplateDetailEntity detail : detailList) {
detail.setTemplateId(templateId);
}
return carCheckTemplateDetailService.saveBatch(detailList);
}
/**
* 删除车检模板
*/
@Override
@Transactional(rollbackFor = Exception.class)
public boolean removeCarCheckTemplate(Long id) {
boolean removeTemplate = this.removeById(id);
if (!removeTemplate) {
throw new ServiceException("车检模板删除失败");
}
return carCheckTemplateDetailService.removeReferenceDetail(id);
}
/**
* 车检模板详情
*/
@Override
public CarCheckTemplateDetailVO getCarCheckTemplateDetail(Long id) {
CarCheckTemplateEntity templateEntity = this.getById(id);
CarCheckTemplateDetailVO vo = new CarCheckTemplateDetailVO();
vo.setId(templateEntity.getId());
vo.setTemplateName(templateEntity.getTemplateName());
List<CarCheckTemplateDetailEntity> list = carCheckTemplateDetailService.getReferenceDetail(id);
vo.setTemplateDetailList(list);
return vo;
}
/**
* 车检分页
*/
@Override
public IPage<CarCheckTemplateEntity> getCarCheckTemplatePage(Query query, Map<String, Object> param) {
IPage<CarCheckTemplateEntity> page = new Page<>(query.getCurrent(), query.getSize());
IPage<CarCheckTemplateEntity> templatePage = carCheckTemplateMapper.getCarCheckTemplatePage(page, param);
List<CarCheckTemplateEntity> templateList = templatePage.getRecords();
// 获取机构名
templateList.forEach(template -> {
R<String> deptName = sysClient.getDeptName(template.getCreateDept());
if (deptName.isSuccess()) {
template.setCreateDeptName(deptName.getData());
}
});
templatePage.setRecords(templateList);
return templatePage;
}
}

28
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ICarCheckTemplateDetailService.java

@ -0,0 +1,28 @@
package com.hnac.hzims.safeproduct.service.impl;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.safeproduct.entity.CarCheckTemplateDetailEntity;
import java.util.List;
/**
* 车检模板详情服务类
*
* @date 2024-05-30
*/
public interface ICarCheckTemplateDetailService extends IService<CarCheckTemplateDetailEntity> {
/**
* 删除关联的模板详情数据
* @param templateId 模板id
* @return true-成功false-失败
*/
boolean removeReferenceDetail(Long templateId);
/**
* 查询关联的模板详情列表
* @param templateId 模板id
* @return 模板详情列表
*/
List<CarCheckTemplateDetailEntity> getReferenceDetail(Long templateId);
}

2
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java

@ -138,7 +138,7 @@ public class TestScoreServiceImpl extends ServiceImpl<TestScoreMapper, TestScore
list= list.stream().filter(s -> s.getScore() != null).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(list)) {
testScoreSumVO.setActualPeopleNum(list.size());
List<TestScoreEntity> passCollect = list.stream().filter(s -> s.getScore() > testScoreSumVO.getPassingScore()).collect(Collectors.toList());
List<TestScoreEntity> passCollect = list.stream().filter(s -> s.getScore() > testEntity.getPassingScore()).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(list)&&CollectionUtils.isNotEmpty(passCollect)) {
double result = BigDecimal.valueOf(passCollect.size()).divide(BigDecimal.valueOf(list.size()),2, RoundingMode.UP).doubleValue();
testScoreSumVO.setPercentage(result);

34
hzims-service/safeproduct/src/main/resources/db/2.0.1.sql

@ -31,7 +31,7 @@ CREATE TABLE IF NOT EXISTS `hzims_hygiene_template_detail` (
`id` bigint(20) NOT NULL COMMENT '主键ID',
`template_id` bigint(20) NOT NULL COMMENT '模板id',
`zone` varchar(50) NOT NULL COMMENT '责任区',
`prinicipal` varchar(20) NOT NULL COMMENT '责任人',
`principal` varchar(20) NOT NULL COMMENT '责任人',
`check_item` mediumtext NOT NULL COMMENT '检查项',
`check_item_score` varchar(255) NOT NULL COMMENT '检查项分值',
`create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人',
@ -46,4 +46,34 @@ CREATE TABLE IF NOT EXISTS `hzims_hygiene_template_detail` (
-- 添加考试及格分字段
ALTER TABLE hzims_test
ADD COLUMN passing_score int(10) NOT NULL DEFAULT 60 COMMENT '考试及格分';
ADD COLUMN passing_score int(10) NOT NULL DEFAULT 60 COMMENT '考试及格分';
-- 新增车检模板表
CREATE TABLE IF NOT EXISTS `hzims_hygiene_template` (
`id` bigint(20) NOT NULL COMMENT '主键ID',
`template_name` varchar(50) NOT NULL COMMENT '模板名称',
`create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人',
`create_dept` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建部门',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_user` bigint(20) DEFAULT '-1' COMMENT '更新人',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间',
`status` int(2) NOT NULL DEFAULT '1' COMMENT '状态',
`is_deleted` int(2) NOT NULL DEFAULT '0' COMMENT '逻辑删除状态:0-未删除,1-删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='车检模板表';
-- 新增车检模板详情表
CREATE TABLE IF NOT EXISTS `hzims_hygiene_template_detail` (
`id` bigint(20) NOT NULL COMMENT '主键ID',
`template_id` bigint(20) NOT NULL COMMENT '模板id',
`check_item` varchar(500) NOT NULL COMMENT '检查项目',
`check_content` mediumtext NOT NULL COMMENT '检查内容',
`create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人',
`create_dept` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建部门',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_user` bigint(20) DEFAULT '-1' COMMENT '更新人',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间',
`status` int(2) NOT NULL DEFAULT '1' COMMENT '状态',
`is_deleted` int(2) NOT NULL DEFAULT '0' COMMENT '逻辑删除状态:0-未删除,1-删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='车检模板详情表';

5
pom.xml

@ -49,8 +49,7 @@
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-system-api</artifactId>
<!-- <version>${bladex.project.version}</version>-->
<version>5.1.1.RELEASE.fix.4</version>
<version>${bladex.project.version}</version>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
@ -77,7 +76,7 @@
<groupId>com.hnac.hzinfo.data</groupId>
<artifactId>hzinfo-data-sdk</artifactId>
<!-- <version>${bladex.project.version}</version>-->
<version>5.1.1.RELEASE.fix.5</version>
<version>5.1.1.RELEASE.fix.4</version>
</dependency>
<dependency>
<groupId>com.xuxueli</groupId>

Loading…
Cancel
Save