Browse Source

Merge remote-tracking branch 'origin/prod-20240506'

# Conflicts:
#	hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java
#	hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmHandleMapper.xml
#	hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmHandleService.java
#	hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java
#	hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java
#	hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateService.java
#	hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java
#	hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateServiceImpl.java
#	hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java
#	hzims-service/safeproduct/src/main/resources/db/2.0.1.sql
#	pom.xml
zhongwei
yang_shj 6 months ago
parent
commit
494257283a
  1. 5
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/entity/AlarmEntity.java
  2. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/OperationalConstants.java
  3. 15
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/feedback/constants/FeedbackConstant.java
  4. 34
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/feedback/entity/UserFeedbackEntity.java
  5. 29
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/feedback/vo/FeedbackQueryVo.java
  6. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java
  7. 3
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java
  8. 4
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneTemplateEntity.java
  9. 14
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java
  10. 3
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/DroolsMqttConsumer.java
  11. 3
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmHandleMapper.xml
  12. 2
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmHandleService.java
  13. 11
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/wrapper/HandleWrapper.java
  14. 16
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/DroolsAlarmServiceImpl.java
  15. 4
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java
  16. 10
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/VideoAlarmServiceImpl.java
  17. 1
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/AlarmScheduledTask.java
  18. 13
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java
  19. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/RealTargetService.java
  20. 118
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java
  21. 557
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java
  22. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/plate/DataService.java
  23. 53
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/plate/impl/DataServiceImpl.java
  24. 32
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/impl/ReportServiceImpl.java
  25. 10
      hzims-service/operational/pom.xml
  26. 72
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/feedback/controller/UserFeedbackController.java
  27. 11
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/feedback/mapper/UserFeedbackMapper.java
  28. 5
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/feedback/mapper/UserFeedbackMapper.xml
  29. 17
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/feedback/service/IUserFeedbackService.java
  30. 107
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/feedback/service/impl/UserFeedbackServiceImpl.java
  31. 145
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/UserFeedbackController.java
  32. 39
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/dto/UserFeedbackDTO.java
  33. 13
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/mapper/UserFeedbackMapper.java
  34. 26
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/mapper/UserFeedbackMapper.xml
  35. 15
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IUserFeedbackService.java
  36. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AnalyseDataServiceImpl.java
  37. 28
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/UserFeedbackServiceImpl.java
  38. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/vo/UserFeedbackVo.java
  39. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/wrapper/UserFeedbackWrapper.java
  40. 18
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/RunMonthController.java
  41. 13
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/mapper/RunMonReportMapper.java
  42. 11
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/RunMonthReportService.java
  43. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/RunMonthService.java
  44. 19
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonReportServiceImpl.java
  45. 595
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java
  46. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java
  47. 4
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java
  48. 1
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygienePlanMapper.java
  49. 10
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneTemplateMapper.java
  50. 13
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneTemplateMapper.xml
  51. 8
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneRecordService.java
  52. 12
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateService.java
  53. 103
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java
  54. 24
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java
  55. 77
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateServiceImpl.java
  56. 2
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java
  57. 6
      hzims-service/safeproduct/src/main/resources/db/2.0.1.sql
  58. 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; package com.hnac.hzims.alarm.config.entity;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.springblade.core.tenant.mp.TenantEntity; 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.io.Serializable;
import java.util.Date; import java.util.Date;
@ -68,6 +71,8 @@ public class AlarmEntity extends TenantEntity {
private Integer alarmCount; private Integer alarmCount;
@ApiModelProperty(value = "告警时间") @ApiModelProperty(value = "告警时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss.sss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.sss")
private Date alarmTime; private Date alarmTime;
@ApiModelProperty(value = "监测点") @ApiModelProperty(value = "监测点")

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

@ -4,7 +4,7 @@ import lombok.Getter;
public class OperationalConstants { public class OperationalConstants {
public final static String APP_NAME = "hzims-operational"; public final static String APP_NAME = "hzims-operational-ysj";

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 com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.tenant.mp.TenantEntity; 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 @Data
@TableName("hzims_user_feedback") @TableName("hzims_user_feedback")
@ApiModel(value = "UserFeedbackEntity对象", description = "用户反馈表") @ApiModel(value = "用户反馈信息", description = "用户反馈记录表")
public class UserFeedbackEntity extends TenantEntity implements Serializable { public class UserFeedbackEntity extends TenantEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "联系电话") private static final long serialVersionUID = 1L;
private String phone;
@ApiModelProperty(value = "反馈内容") @ApiModelProperty(value = "反馈内容")
private String content; private String content;
@ApiModelProperty(value = "联系电话")
private String phone;
@ApiModelProperty(value = "附件名称") @ApiModelProperty(value = "附件名称")
private String fileName; private String fileName;
@ApiModelProperty(value = "附件地址") @ApiModelProperty(value = "附件地址")
private String fileUrl; private String fileUrl;
@ApiModelProperty(value = "反馈人")
private Long feedbackUser;
@ApiModelProperty(value = "反馈人姓名")
private String feedbackUserName;
@ApiModelProperty(value = "反馈类型")
private String feedbackType;
@ApiModelProperty(value = "回复内容") @ApiModelProperty(value = "回复内容")
private String replyContent; private String replyContent;
@ApiModelProperty(value = "回复人") @ApiModelProperty(value = "回复人")
private Long replyUser; 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; 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_HYDROPOWER_UNIT_TARGET = "loadHydropowerUnitTarget";
// 近年发电量 // 近年发电量
String LOAD_POWER_DATA_NEW = "loadPowerDataNew";
String ELECTRICITY_GENERATION_RECENT_YEAR = "electricityGenerationRecentYear"; String ELECTRICITY_GENERATION_RECENT_YEAR = "electricityGenerationRecentYear";
// 風電儲能近年发电量 // 風電儲能近年发电量
String WIND_POWER_GENERATION_RECENT_YEAR = "windPowerGenerationRecentYear"; String WIND_POWER_GENERATION_RECENT_YEAR = "windPowerGenerationRecentYear";

4
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneTemplateEntity.java

@ -1,5 +1,6 @@
package com.hnac.hzims.safeproduct.entity; package com.hnac.hzims.safeproduct.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@ -18,4 +19,7 @@ public class HygieneTemplateEntity extends BaseEntity {
@ApiModelProperty("模板名称") @ApiModelProperty("模板名称")
private String templateName; private String templateName;
@TableField(exist = false)
private String createDeptName;
} }

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

@ -69,7 +69,7 @@ public class AlarmSaveServiceImpl implements AlarmSaveService {
// 未匹配到站点 // 未匹配到站点
Optional<StationEntity> optional = stations.getData().stream().filter(o->o.getCode().equals(alarm.getStationId())).findFirst(); Optional<StationEntity> optional = stations.getData().stream().filter(o->o.getCode().equals(alarm.getStationId())).findFirst();
if(!optional.isPresent()){ if(!optional.isPresent()){
return; return;
} }
// 告警已处理 // 告警已处理
if(CollectionUtil.isNotEmpty(handlers) && handlers.contains(alarm.getAlarmContext())){ if(CollectionUtil.isNotEmpty(handlers) && handlers.contains(alarm.getAlarmContext())){
@ -88,22 +88,22 @@ public class AlarmSaveServiceImpl implements AlarmSaveService {
} }
} }
} }
// fpd告警拼接站点名称 // fpd告警拼接
if(AlarmConstants.EARLY_WARNING.equals(alarm.getAlarmSource())){ if(AlarmConstants.EARLY_WARNING.equals(alarm.getAlarmSource())){
alarm.setAlarmContext(optional.get().getName() + "." + alarm.getAlarmContext()); alarm.setAlarmContext(optional.get().getName() + "." + alarm.getAlarmContext());
} }
// 站点参数设置 // 步骤3.站点参数设置
alarm.setCreateDept(optional.get().getCreateDept()); alarm.setCreateDept(optional.get().getCreateDept());
alarm.setStationName(optional.get().getName()); alarm.setStationName(optional.get().getName());
alarm.setTenantId(optional.get().getTenantId()); alarm.setTenantId(optional.get().getTenantId());
alarm.setStatus(0); alarm.setStatus(0);
// 根据站点查询配置标识 // 步骤4.根据站点查询配置标识
AlarmHandleMarkVo mark = alarmConfigService.mark(alarm.getStationId(),alarm.getAlarmSource(),alarm.getAlarmType()); AlarmHandleMarkVo mark = alarmConfigService.mark(alarm.getStationId(),alarm.getAlarmSource(),alarm.getAlarmType());
if(ObjectUtil.isEmpty(mark)){ if(ObjectUtil.isEmpty(mark)){
log.error("alarm_obtain_mark_is_null : {}",alarm.getAlarmId()); log.error("alarm_obtain_mark_is_null : {}",alarm.getAlarmId());
return; return;
} }
// 告警处理标识赋值 // 步骤5.告警处理标识赋值
alarm.setIsRightTabulation(mark.getIsRightTabulation()); alarm.setIsRightTabulation(mark.getIsRightTabulation());
alarm.setIsBroadcast(mark.getIsBroadcast()); alarm.setIsBroadcast(mark.getIsBroadcast());
alarm.setIsMask(mark.getIsMask()); alarm.setIsMask(mark.getIsMask());
@ -112,7 +112,7 @@ public class AlarmSaveServiceImpl implements AlarmSaveService {
alarm.setIsSmallBell(mark.getIsSmallBell()); alarm.setIsSmallBell(mark.getIsSmallBell());
alarm.setIsShortMessage(mark.getIsShortMessage()); alarm.setIsShortMessage(mark.getIsShortMessage());
alarm.setIsWxMessage(mark.getIsWxMessage()); alarm.setIsWxMessage(mark.getIsWxMessage());
// 保存告警 // 步骤6.保存当日告警数据
boolean isSave = alarmService.save(alarm); boolean isSave = alarmService.save(alarm);
if(!isSave){ if(!isSave){
log.error("alarm_save_fail : {}",alarm.getAlarmId()); log.error("alarm_save_fail : {}",alarm.getAlarmId());
@ -121,7 +121,7 @@ public class AlarmSaveServiceImpl implements AlarmSaveService {
String key="hzims:queue:filter:alarm"+alarm.getAlarmId(); String key="hzims:queue:filter:alarm"+alarm.getAlarmId();
stringRedisTemplate.opsForValue().set(key,optional.get().getName()+alarm.getAlarmContext()); stringRedisTemplate.opsForValue().set(key,optional.get().getName()+alarm.getAlarmContext());
stringRedisTemplate.expire(key,5, TimeUnit.MINUTES); stringRedisTemplate.expire(key,5, TimeUnit.MINUTES);
// 发送告警数据进行消息推送队列 // 步骤7.发生数据至redis告警队列
stringRedisTemplate.opsForList().rightPush("hzims:queue:alarm", JSON.toJSONString(alarm)); stringRedisTemplate.opsForList().rightPush("hzims:queue:alarm", JSON.toJSONString(alarm));
}); });
return true; 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.config.entity.AlarmEntity;
import com.hnac.hzims.alarm.source.service.DroolsAlarmService; import com.hnac.hzims.alarm.source.service.DroolsAlarmService;
import com.hnac.hzims.alarm.monitor.service.AlarmSaveService; import com.hnac.hzims.alarm.monitor.service.AlarmSaveService;
import com.hnac.hzims.common.utils.DateUtil;
import com.hnac.hzinfo.subscribe.SubscribeCallBack; import com.hnac.hzinfo.subscribe.SubscribeCallBack;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import oracle.sql.DATE;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; 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 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 FROM HZIMS_ALARM_HANDLE H
LEFT JOIN HZIMS_OPERATION.HZIMS_STATION S ON H.STATION_CODE = S.CODE 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 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) AND (HANDLER.DELAY_TIME &gt; #{end} OR HANDLER.DELAY_TIME IS NULL)
</where> </where>
</select> </select>
<select id="sameDayContent" resultType="java.lang.String"> <select id="sameDayContent" resultType="java.lang.String">
SELECT HANDLER.ALARM_CONTENT SELECT HANDLER.ALARM_CONTENT
FROM HZIMS_ALARM_HANDLE HANDLER 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> handles();
List<String> sameDayContent(); List<String> sameDayContent();
List<String> incompleteContent(); 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; package com.hnac.hzims.alarm.show.wrapper;
import com.hnac.hzims.alarm.config.vo.AlarmHandleVo; 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.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.cache.UserCache;
@ -17,11 +18,13 @@ public class HandleWrapper extends BaseEntityWrapper<AlarmHandleVo,AlarmHandleVo
@Override @Override
public AlarmHandleVo entityVO(AlarmHandleVo entity) { public AlarmHandleVo entityVO(AlarmHandleVo entity) {
User createUser = UserCache.getUser(entity.getCreateUser()); if (1==entity.getHandleWay()|| StringUtils.isNotEmpty(entity.getUserName())) {
if(ObjectUtil.isEmpty(createUser)){ User createUser = UserCache.getUser(entity.getCreateUser());
return entity; if (ObjectUtil.isEmpty(createUser)) {
return entity;
}
entity.setUserName(createUser.getRealName());
} }
entity.setUserName(createUser.getRealName());
return entity; 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.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.hnac.hzims.alarm.config.entity.AlarmEntity; 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.config.vo.DroolsAlarmVo;
import com.hnac.hzims.alarm.show.service.AlarmService; import com.hnac.hzims.alarm.show.service.AlarmService;
import com.hnac.hzims.alarm.source.service.DroolsAlarmService; 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.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.Collections;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -52,15 +49,8 @@ public class DroolsAlarmServiceImpl implements DroolsAlarmService {
public List<AlarmEntity> receiveMessage(String message) { public List<AlarmEntity> receiveMessage(String message) {
// 对象转换 // 对象转换
DroolsAlarmVo parseObject= JSONObject.parseObject(message, DroolsAlarmVo.class); DroolsAlarmVo parseObject= JSONObject.parseObject(message, DroolsAlarmVo.class);
List<DroolsAlarmVo> alarms = Arrays.asList(parseObject); List<DroolsAlarmVo> alarms = Collections.singletonList(parseObject);
if (CollectionUtil.isEmpty(alarms)) { return alarms.stream().map(this::getAlarmEntity).collect(Collectors.toList());
return new ArrayList<>();
}
List<AlarmEntity> res = alarms.stream().map(s -> {
AlarmEntity entity = getAlarmEntity(s);
return entity;
}).collect(Collectors.toList());
return res;
} }
private AlarmEntity getAlarmEntity(DroolsAlarmVo item) { 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()); message.setTaskId(entity.getId());
// 微信参数键值对 // 微信参数键值对
HashMap<String,Object> map = new HashMap<>(); 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("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("time2",entity.getAlarmTime());
map.put("thing14", DictCache.getValue("alarm_source", entity.getAlarmSource())); map.put("thing14", DictCache.getValue("alarm_source", entity.getAlarmSource()));
message.setMap(map); 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;
} }
return records; return records;
}).filter(s -> CollectionUtil.isNotEmpty(s)).collect(Collectors.toList()); }).filter(CollectionUtil::isNotEmpty).collect(Collectors.toList());
List<DeviceSoeVO> res =new ArrayList<>(); List<DeviceSoeVO> res =new ArrayList<>();
if (CollectionUtil.isNotEmpty(collect)) { if (CollectionUtil.isNotEmpty(collect)) {
res= collect.stream().flatMap(List::stream).collect(Collectors.toList()); res= collect.stream().flatMap(List::stream).collect(Collectors.toList());
@ -78,7 +78,7 @@ public class VideoAlarmServiceImpl implements VideoAlarmService {
// 转换平台视频预警信息 // 转换平台视频预警信息
List<AlarmEntity> alarmEntities =new ArrayList<>(); List<AlarmEntity> alarmEntities =new ArrayList<>();
if (CollectionUtil.isNotEmpty(res)) { 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; return alarmEntities;
} }
@ -95,11 +95,7 @@ public class VideoAlarmServiceImpl implements VideoAlarmService {
if (CollectionUtil.isEmpty(alarms)) { if (CollectionUtil.isEmpty(alarms)) {
return new ArrayList<>(); return new ArrayList<>();
} }
List<AlarmEntity> res = alarms.stream().map(s -> { return alarms.stream().map(this::getAlarmEntity).collect(Collectors.toList());
AlarmEntity entity = getAlarmEntity(s);
return entity;
}).collect(Collectors.toList());
return res;
} }
private AlarmEntity getAlarmEntity(DeviceSoeVO item) { 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); alarmService.interruption(param);
return new ReturnT<>("SUCCESS"); 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"); 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) @XxlJob(WIND_POWER_GENERATION_RECENT_YEAR)
//@Scheduled(cron = "0/40 * * * * ? ") //@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 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); 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 = "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_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 load_hydropower_unit_target_key = "hzims:operation:loadhydropowerunit:target:key";
private final static String loadwaterpump_target_key = "hzims:operation:loadwaterpump:target:key"; private final static String loadwaterpump_target_key = "hzims:operation:loadwaterpump:target:key";
@ -1275,72 +1278,87 @@ public class RealTargetServiceImpl implements RealTargetService {
} }
@Override @Override
public void loadPowerDataNew(String param, List<Integer> types, Integer serveType, int year) {
public void loadPowerDataNew(List<Integer> types, Integer serveType, int year) {
// 站点查询 // 站点查询
List<StationEntity> stationList = stationService.list(new LambdaQueryWrapper<StationEntity>() {{ List<StationEntity> stations = stationService.list(new LambdaQueryWrapper<StationEntity>() {{
eq(StationEntity::getDataOrigin,"0");
if (ObjectUtil.isNotEmpty(serveType)) {
eq(StationEntity::getServeType, serveType);
}
if (CollectionUtil.isNotEmpty(types)) { if (CollectionUtil.isNotEmpty(types)) {
in(StationEntity::getType, types); in(StationEntity::getType, types);
} }
}}); }});
// 设备信息 // 设备信息
List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_cofig_final).toString(), List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_cofig_final).toString(), new TypeReference<List<EminfoAndEmParamVo>>() {
new TypeReference<List<EminfoAndEmParamVo>>() {}); });
// 结束时间 // 开始时间
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH) + 12); calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH) + 12);
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1);
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00"; 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.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - year);
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH));
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00"; String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00";
LocalDateTime startTime = LocalDateTime.parse(end); // 存储数据map :<站点id,<月份,发电量>>
// 存储数据map:<站点id, <月份, 发电量>> Map<Long, Map<String, Float>> powerMap = new CopyOnWriteMap<>();
Map<Long, Map<String, Float>> powerMap = new HashMap<>(); // 将站点切割
stationList.forEach(station -> { int limit = countStep(stations.size());
List<PowerMonthVo> datas = new ArrayList<>(); 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());
List<EminfoAndEmParamVo> stationDevices = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); for(List<StationEntity> item : limits){
log.info("load_power_data station :" + station.getCode() + "==== device :" + stationDevices); pool.submit(()->{
if (CollectionUtil.isNotEmpty(devices)) { item.forEach(station->{
stationDevices.forEach(device -> { // 站点设备集合
ReductionDataDTO reductionDataDTO = new ReductionDataDTO(); List<EminfoAndEmParamVo> stationDevices = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList());
reductionDataDTO.setDeviceCode(device.getEmCode()); Map<String, Float> generateMap = this.lastReduceFirst(station,stationDevices,start,end);
reductionDataDTO.setSaveTimeType(5); if(MapUtils.isEmpty(generateMap)){
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())) {
return; return;
} }
List<Map<String, String>> dataList = reductionDataVOResult.getData().getDataList(); powerMap.put(station.getId(),generateMap);
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()));
}); });
} countDownLatch.countDown();
// 补充填报数据 log.error("pool_item_execute_complete: {}" ,item.stream().map(StationEntity::getName).collect(Collectors.toList()));
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)); try {
powerMap.put(station.getId(), map); countDownLatch.await();
}); } catch (InterruptedException e) {
redisTemplate.opsForValue().set(recent_year_power_data, powerMap); 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.google.common.util.concurrent.ThreadFactoryBuilder;
import com.hnac.hzims.equipment.entity.WorkshopInfoEntity; import com.hnac.hzims.equipment.entity.WorkshopInfoEntity;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; 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.enume.ConfigStatus;
import com.hnac.hzims.operational.config.vo.StationRealVo; import com.hnac.hzims.operational.config.vo.StationRealVo;
import com.hnac.hzims.operational.main.constant.HomePageConstant; 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.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*; import java.util.*;
import java.util.concurrent.*; import java.util.concurrent.*;
import java.util.function.Function; import java.util.function.Function;
@ -207,9 +207,7 @@ public class MonitorServiceImpl implements MonitorService {
log.error("real_time_data: {},{}",stationReal.getStation(),realIds); log.error("real_time_data: {},{}",stationReal.getStation(),realIds);
List<String> objects = redisClient.getBatchRealDataByRealId(stationReal.getStation(),realIds); List<String> objects = redisClient.getBatchRealDataByRealId(stationReal.getStation(),realIds);
for(int i = 0; i < realIds.size() ;i++){ for(int i = 0; i < realIds.size() ;i++){
if(ObjectUtil.isEmpty(objects.get(i))){ if(ObjectUtil.isNotEmpty(objects.get(i))){
// log.error(realIds.get(i) + "is null");
}else{
Map<String,String> attribute = (Map<String, String>) JSONObject.parse(objects.get(i)); Map<String,String> attribute = (Map<String, String>) JSONObject.parse(objects.get(i));
attribute.put("realId",attribute.get("k")); attribute.put("realId",attribute.get("k"));
attribute.put("value",attribute.get("v")); attribute.put("value",attribute.get("v"));
@ -272,86 +270,51 @@ public class MonitorServiceImpl implements MonitorService {
*/ */
@Override @Override
public void loadMonitoring(String param) { public void loadMonitoring(String param) {
Thread thread = Thread.currentThread(); // 集中监控属性配置
Object json = redisTemplate.opsForValue().get(real_data_cache_final); Map<String,List<StationAttributeEntity>> attributes = this.attributes();
if (ObjectUtil.isEmpty(json)) { // realId对应实时数据
Map<String,Map<String,String>> realTimeData = this.realTimeData();
if(MapUtils.isEmpty(attributes) || MapUtils.isEmpty(realTimeData)){
return; return;
} }
Map<String, Map<String, String>> map = JSONObject.parseObject(json.toString(), new TypeReference<Map<String, Map<String, String>>>() { // 集中监控站点
}); List<StationEntity> stations = this.monitorStations(new ArrayList<>(attributes.keySet()));
if (MapUtils.isEmpty(map)) { if(CollectionUtil.isEmpty(stations)){
return; return;
} }
// 获取所有设备重点属性 // 机构(取排序字段)
List<StationAttributeEntity> list = attbtService.list(new LambdaQueryWrapper<StationAttributeEntity>() {{ Map<Long,Integer> sorts = this.monitorDeptSorts();
isNotNull(StationAttributeEntity::getStationId); List<String> operations = stations.stream().filter(o->HomePageConstant.HYDROPOWER_SERVETYPE_STRING.equals(o.getServeType())).map(StationEntity::getCode).collect(Collectors.toList());
eq(StationAttributeEntity::getIsDeleted, "0"); // 告警铃铛(代运维)
orderByAsc(StationAttributeEntity::getSort); List<String> bells = alarmQueryService.bells(operations);
}}); // 数据中断(代运维)
if (CollectionUtil.isEmpty(list)) { List<String> aborts = interruptionAlarmService.aborts(operations);
return; // 设备状态分类
}
// 获取所有告警记录
List<StAlarmRecordEntity> alertList = alertService.list(new LambdaQueryWrapper<StAlarmRecordEntity>() {{
orderByDesc(StAlarmRecordEntity::getCreateTime);
}});
// 获取所有故障记录
List<FdpFaultStatusVo> faultList = this.getFdpFaultAll();
// 所有设备分类
Map<String, List<String>> deviceClassifyMap = (Map<String, List<String>>) redisTemplate.opsForValue().get(device_classify_cache_final); Map<String, List<String>> deviceClassifyMap = (Map<String, List<String>>) redisTemplate.opsForValue().get(device_classify_cache_final);
// 所有设备 // 按10个站点一组分割属性配置
List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_final).toString(),new TypeReference<List<EminfoAndEmParamVo>>() {}); List<Map<String, List<StationAttributeEntity>>> limit = this.limitMapChunk(attributes);
// 根据站点分组 // 线程执行次数
Map<String, List<StationAttributeEntity>> stationAttbtMap = list.stream().collect(Collectors.groupingBy(StationAttributeEntity::getStationId)); CountDownLatch countDownLatch = new CountDownLatch(limit.size());
// 获取站点列表
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();
// 存储数据节点 // 存储数据节点
List<RealStationVo> stationList = new CopyOnWriteArrayList<>(); List<RealStationVo> realStations = new CopyOnWriteArrayList<>();
// 线程处理数据 // 切割数据遍历
for(Map<String, List<StationAttributeEntity>> item : handleList){ for(Map<String, List<StationAttributeEntity>> item : limit){
// 提交线程任务
pool.submit(()->{ pool.submit(()->{
item.forEach((key,value)->{ item.forEach((key,value)->{
RealStationVo station = new RealStationVo(); RealStationVo realStation = new RealStationVo();
// 站点编码 // 设备信息
station.setStationCode(key); List<RealDeviceVo> devices = this.monitorRealDevice(value,realTimeData);
// 名称、限制水位、服务类型、机构、排序
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);
});
// 设备状态 // 设备状态
this.getDeviceParam(devices, deviceClassifyMap, deviceList); this.deviceStatus(devices,deviceClassifyMap);
// 运行设备状态设置 realStation.setDeviceList(devices.stream().sorted(Comparator.comparing(RealDeviceVo::getDeviceName)).collect(Collectors.toList()));
this.deviceState(deviceList); // 站点基础信息: 编码、名称、限制水位、服务类型、机构、排序
// 设置站点状态:数据中断 this.stationBaseInfo(stations.stream().filter(station->key.equals(station.getCode())).findFirst(),sorts,realStation);
this.setStationStatus(aborts,station,key,deviceList); // 站点总功率计算
// 铃铛 this.stationActivePower(devices,realStation);
this.stationBell(station,bells); // 站点铃铛、数据中断状态
station.setDeviceList(deviceList.stream().sorted(Comparator.comparing((RealDeviceVo::getDeviceName))).collect(Collectors.toList())); this.stationStatus(aborts,bells,realStation);
stationList.add(station); realStations.add(realStation);
}); });
countDownLatch.countDown(); countDownLatch.countDown();
}); });
@ -363,24 +326,190 @@ public class MonitorServiceImpl implements MonitorService {
e.printStackTrace(); e.printStackTrace();
Thread.currentThread().interrupt(); 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 bells
* @param realStation
*/ */
private void stationBell(RealStationVo station, List<String> bells) { private void stationStatus(List<String> aborts, List<String> bells, RealStationVo realStation) {
station.setBell(0); realStation.setBell(0);
if(CollectionUtil.isEmpty(bells)){ 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; return;
} }
if(bells.contains(station.getStationCode())){ realStation.setStationCode(optional.get().getCode());
station.setBell(1); 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 map
* @param device * @param device
*/ */
private void handleDevice(List<StationAttributeEntity> list, Map<String, Map<String, String>> map, private void handleDevice(List<StationAttributeEntity> list, Map<String, Map<String, String>> map,RealDeviceVo device) {
RealDeviceVo device, List<StAlarmRecordEntity> alertList,
List<FdpFaultStatusVo> faultList) {
if (CollectionUtil.isEmpty(list) || MapUtils.isEmpty(map)) { if (CollectionUtil.isEmpty(list) || MapUtils.isEmpty(map)) {
return; return;
} }
@ -410,7 +537,7 @@ public class MonitorServiceImpl implements MonitorService {
attbtList.add(realAttributeVo); attbtList.add(realAttributeVo);
return; return;
} }
realAttributeVo = handleAttbt(item, real, alertList, faultList); realAttributeVo = handleAttbt(item, real);
if (ObjectUtil.isEmpty(realAttributeVo)) { if (ObjectUtil.isEmpty(realAttributeVo)) {
return; 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 item
* @param real * @param real
* @return * @return
*/ */
private RealAttributeVo handleAttbt(StationAttributeEntity item, Map<String, String> real, private RealAttributeVo handleAttbt(StationAttributeEntity item, Map<String, String> real) {
List<StAlarmRecordEntity> alertList, List<FdpFaultStatusVo> faultList) {
RealAttributeVo attest = new RealAttributeVo(); RealAttributeVo attest = new RealAttributeVo();
this.setAttbtParam(attest, real); this.setAttbtParam(attest, real);
attest.setRealId(item.getMonitorId()); attest.setRealId(item.getMonitorId());
@ -546,7 +563,7 @@ public class MonitorServiceImpl implements MonitorService {
String value = Optional.ofNullable(attest.getValue()).orElse("-"); String value = Optional.ofNullable(attest.getValue()).orElse("-");
// 正常状态 // 正常状态
attest.setStatus(ConfigStatus.ConfigStatusEnum.NORMAL.getStatus()); 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(""); String time = Optional.ofNullable(attest.getTime()).orElse("");
// 延时状态 :质量为空 && 时间为空 // 延时状态 :质量为空 && 时间为空
if (-1 == quality && StringUtil.isEmpty(time)) { if (-1 == quality && StringUtil.isEmpty(time)) {
@ -554,21 +571,21 @@ public class MonitorServiceImpl implements MonitorService {
} }
int type = item.getAttributeType(); int type = item.getAttributeType();
switch (type) { switch (type) {
case 1://遥测 //遥测
case 1:
// 预警状态 :value值为"1" && quality值为0 // 预警状态 :value值为"1" && quality值为0
if ("1".equals(value) && 0 == quality) { if ("1".equals(value) && 0 == quality) {
attest.setStatus(ConfigStatus.ConfigStatusEnum.RED.getStatus()); attest.setStatus(ConfigStatus.ConfigStatusEnum.RED.getStatus());
} }
break; break;
case 2://遥信 //遥信
signalyRemote(item, attest, quality, value, alertList); case 2:
signalyRemote(item, attest, quality, value);
//处理 //处理
break; break;
default: default:
throw new IllegalStateException("Unexpected type: " + type); throw new IllegalStateException("Unexpected type: " + type);
} }
// 故障信息设置
accidentDetails(attest, faultList, value);
return attest; 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 * @param attest
*/ */
private void signalyRemote(StationAttributeEntity item, RealAttributeVo attest, int quality, String strValue, List<StAlarmRecordEntity> alertList) { private void signalyRemote(StationAttributeEntity attribute, RealAttributeVo attest, int quality, String strValue) {
//需要所有值的数据不为null,并且满足条件才会进去添加数据返回id // 需要所有限制不为null,并且满足条件才会设置设备状态标识
if (null == item.getUpUpLimit() || null == item.getDownDownLimit() || null == item.getUpLimit() || null == item.getDownLimit()) { if (null == attribute.getUpUpLimit() || null == attribute.getDownDownLimit() || null == attribute.getUpLimit() || null == attribute.getDownLimit()) {
return; return;
} }
if (-1 == quality) { if (-1 == quality) {
@ -652,99 +641,17 @@ public class MonitorServiceImpl implements MonitorService {
if ("-".equals(strValue)) { if ("-".equals(strValue)) {
return; return;
} }
double upup = item.getUpUpLimit(); double upup = attribute.getUpUpLimit();
double lwlw = item.getDownDownLimit(); double lwlw = attribute.getDownDownLimit();
double up = item.getUpLimit(); double up = attribute.getUpLimit();
double lw = item.getDownLimit(); double lw = attribute.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());
long past = 0L; long past = 0L;
double value = Double.parseDouble(strValue); double value = Double.parseDouble(strValue);
if (value > upup || value < lwlw) { if (value > upup || value < lwlw) {
if (CollectionUtil.isNotEmpty(handleList)) { attest.setStatus(ConfigStatus.ConfigStatusEnum.RED.getStatus());
// 现在时间 - 处理时间
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());
}
}
} else if (value > up && value < upup || value < lw && value > lwlw) { } else if (value > up && value < upup || value < lw && value > lwlw) {
if (CollectionUtil.isNotEmpty(handleList)) { attest.setStatus(ConfigStatus.ConfigStatusEnum.YELLOW.getStatus());
// 现在时间 - 处理时间
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<>();
} }
return (List<FdpFaultStatusVo>) json;
} }
/** /**
@ -755,7 +662,7 @@ public class MonitorServiceImpl implements MonitorService {
* @param chunkMap * @param chunkMap
* @return * @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) { if (chunkMap == null) {
return Lists.newArrayList(); 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); 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); 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 @Override
public List<Map<String, String>> lastFirstBySignage(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, String signage) { public List<Map<String, String>> lastFirstBySignage(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, String signage) {
ReductionDataDTO reduction = new ReductionDataDTO(); ReductionDataDTO reduction = new ReductionDataDTO();
reduction.setFull(1); reduction.setFull(0);
reduction.setDeviceCode(deviceCode); reduction.setDeviceCode(deviceCode);
reduction.setSaveTimeType(cycleType); reduction.setSaveTimeType(cycleType);
reduction.setTimeInterval(1); reduction.setTimeInterval(1);
@ -201,6 +201,57 @@ public class DataServiceImpl implements DataService {
* @param cycleType 间隔周期 : 0-> 1-> 2-> 小时 3-> 4-> 5-> 6-> * @param cycleType 间隔周期 : 0-> 1-> 2-> 小时 3-> 4-> 5-> 6->
* @param deviceCode 设备编号 * @param deviceCode 设备编号
* @param ride 配电比 * @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 指标 * @param signages 指标
* @return * @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)){ if(CollectionUtil.isEmpty(stations)){
return; return;
} }
// 删除上个月手动生成月报记录
this.deleteGenerateReport(stations);
// 计划发电量 // 计划发电量
List<PlanGenerationEntity> plans = planService.planGeneration(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), null ,DateUtil.format(new Date(),"yyyy")); 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.setStationCode(station.getCode());
run.setStationName(station.getName()); run.setStationName(station.getName());
Calendar calendar = Calendar.getInstance(); 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); calendar.add(Calendar.DAY_OF_MONTH,-1);
run.setMonth(DateUtil.format(calendar.getTime(),"yyyy-MM")); run.setMonth(DateUtil.format(calendar.getTime(),"yyyy-MM"));
List<RideDeviceVo> stationDevices = devices.stream().filter(device->device.getDepartment().equals(station.getRefDept())).collect(Collectors.toList()); 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 * @param devices
* @return * @return
@ -699,7 +720,7 @@ public class ReportServiceImpl implements ReportService {
*/ */
private Double generate(int type,String deviceCode,double ride) { private Double generate(int type,String deviceCode,double ride) {
Calendar calendar = Calendar.getInstance(); 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; String end = null,start = null;
int cycleType = 5; int cycleType = 5;
switch (type){ switch (type){
@ -773,7 +794,7 @@ public class ReportServiceImpl implements ReportService {
// 确定查询时间范围: 年、月 // 确定查询时间范围: 年、月
Date startDate,endDate; Date startDate,endDate;
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse("2024-05-01 00:00:00",DateUtil.PATTERN_DATETIME)); calendar.setTime(new Date());
endDate = calendar.getTime(); endDate = calendar.getTime();
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH));
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1);
@ -846,7 +867,7 @@ public class ReportServiceImpl implements ReportService {
*/ */
private String alarmData(String code) { private String alarmData(String code) {
Calendar calendar = Calendar.getInstance(); 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); calendar.add(Calendar.DAY_OF_MONTH,-1);
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
calendar.add(Calendar.MONTH,-1); calendar.add(Calendar.MONTH,-1);
@ -952,8 +973,7 @@ public class ReportServiceImpl implements ReportService {
*/ */
private List<EchartVo> curve(List<AttributeVo> attributes, String deviceCode) { private List<EchartVo> curve(List<AttributeVo> attributes, String deviceCode) {
Calendar calendar = Calendar.getInstance(); 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); calendar.add(Calendar.DAY_OF_MONTH,-1);
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
calendar.add(Calendar.MONTH,-1); calendar.add(Calendar.MONTH,-1);

10
hzims-service/operational/pom.xml

@ -240,6 +240,10 @@
<groupId>com.hnac.hzinfo.data</groupId> <groupId>com.hnac.hzinfo.data</groupId>
<artifactId>hzinfo-data-sdk</artifactId> <artifactId>hzinfo-data-sdk</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.hnac.hzims</groupId>
<artifactId>alarm-api</artifactId>
</dependency>
@ -255,6 +259,12 @@
<version>3.9.1</version> <version>3.9.1</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>com.hnac.hzims</groupId>
<artifactId>alarm-api</artifactId>
<version>4.0.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<build> <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; package com.hnac.hzims.operational.main.service.impl;
import com.google.common.collect.Lists; 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.hzims.operational.main.service.IAnalyseDataService;
import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient;
import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO; 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; 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 io.swagger.annotations.ApiModelProperty;
import lombok.Data; 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; 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 com.hnac.hzims.operational.main.vo.UserFeedbackVo;
import org.springblade.core.mp.support.BaseEntityWrapper; import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil; 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; 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") @GetMapping("/data")
@ApiOperation(value = "查询站点月报数据",notes = "查询站点月报数据") @ApiOperation(value = "查询站点月报数据",notes = "查询站点月报数据")
@ApiOperationSupport(order = 3) @ApiOperationSupport(order = 3)
@ -33,7 +49,7 @@ public class RunMonthController {
@GetMapping("/export") @GetMapping("/export")
@ApiOperation(value = "导出站点运行月报",notes = "导出站点运行月报") @ApiOperation(value = "导出站点运行月报",notes = "导出站点运行月报")
@ApiOperationSupport(order = 3) @ApiOperationSupport(order = 4)
public void export(@RequestParam("mon") String mon, public void export(@RequestParam("mon") String mon,
@RequestParam("stationCode") String stationCode){ @RequestParam("stationCode") String stationCode){
runMonthService.export(mon,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); RunMonthEntity data(String mon, String stationCode);
void export(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.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; 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.entity.RunMonthEntity;
import com.hnac.hzims.operational.report.mapper.RunMonthMapper; 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.service.RunMonthService;
import com.hnac.hzims.operational.report.vo.*; 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.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.poi.hssf.usermodel.HSSFFont; 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.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.*;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
@ -31,19 +60,39 @@ import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.ArrayList; import java.time.LocalDateTime;
import java.util.Comparator; import java.util.*;
import java.util.List; import java.util.concurrent.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
* @author ysj * @author ysj
*/ */
@SuppressWarnings("ALL")
@Service @Service
@AllArgsConstructor @AllArgsConstructor
@Slf4j @Slf4j
public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMonthEntity> implements RunMonthService { 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 * @param mon
@ -57,23 +106,34 @@ public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMont
.eq(RunMonthEntity::getMonth,mon) .eq(RunMonthEntity::getMonth,mon)
); );
if(ObjectUtil.isEmpty(entity)){ if(ObjectUtil.isEmpty(entity)){
throw new ServiceException("站点" + mon + "月份未生成运行月报,请联系管理员进行处理!"); throw new ServiceException("站点" + mon + "月份未生成运行月报,请先点击【生成】按钮生成月报!");
} }
RunDataShowVo data = new RunDataShowVo(); RunDataShowVo data = new RunDataShowVo();
BeanUtil.copyProperties(entity,data); BeanUtil.copyProperties(entity,data);
List<RunDataVo> run = JSONObject.parseObject(entity.getRunData(),new TypeReference<List<RunDataVo>>(){}); List<RunDataVo> runs = JSONObject.parseObject(entity.getRunData(),new TypeReference<List<RunDataVo>>(){});
if(CollectionUtil.isEmpty(run)){ if(CollectionUtil.isEmpty(runs)){
return data; 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.setMonSumGenerate(monSumGenerate);
data.setMonSumPlan(monSumPlan); data.setMonSumPlan(monSumPlan);
if(Math.abs(monSumGenerate) > 0 && Math.abs(monSumPlan) > 0){ if(Math.abs(monSumGenerate) > 0 && Math.abs(monSumPlan) > 0){
data.setMonRate(BigDecimal.valueOf(monSumGenerate / monSumPlan * 100L).setScale(2, RoundingMode.HALF_UP).doubleValue()); 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.setYearSumGenerate(yearSumGenerate);
data.setYearSumPlan(yearSumPlan); data.setYearSumPlan(yearSumPlan);
if(Math.abs(yearSumGenerate) > 0 && Math.abs(yearSumPlan) > 0){ if(Math.abs(yearSumGenerate) > 0 && Math.abs(yearSumPlan) > 0){
@ -82,7 +142,6 @@ public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMont
return data; return data;
} }
/** /**
* 导出站点月报文件 * 导出站点月报文件
* @param mon * @param mon
@ -100,6 +159,17 @@ public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMont
if(ObjectUtil.isEmpty(data)){ if(ObjectUtil.isEmpty(data)){
throw new ServiceException("站点" + mon + "月份未生成运行月报数据!"); 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文件 // 创建Excel文件
// 表头、sheet页、文件名 // 表头、sheet页、文件名
String headerName = data.getStationName() + "运行月报(" + mon + ")"; 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 * @return
*/ */
@ -280,16 +827,14 @@ public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMont
*/ */
private List<CurveYArrayVo> curveToArray(List<EchartVo> curves) { private List<CurveYArrayVo> curveToArray(List<EchartVo> curves) {
List<CurveAttrValueVo> attrValues = new ArrayList<>(); List<CurveAttrValueVo> attrValues = new ArrayList<>();
curves.forEach(curve->{ curves.forEach(curve-> attrValues.addAll(curve.getValues().stream().map(value->{
attrValues.addAll(curve.getValues().stream().map(value->{ CurveAttrValueVo attrValue = new CurveAttrValueVo();
CurveAttrValueVo attrValue = new CurveAttrValueVo(); attrValue.setAttribute(value.getAttribute());
attrValue.setAttribute(value.getAttribute()); attrValue.setAttributeName(value.getAttributeName());
attrValue.setAttributeName(value.getAttributeName()); attrValue.setTime(curve.getTime());
attrValue.setTime(curve.getTime()); attrValue.setValue(value.getValue());
attrValue.setValue(value.getValue()); return attrValue;
return attrValue; }).collect(Collectors.toList())));
}).collect(Collectors.toList()));
});
return attrValues.stream().collect(Collectors.groupingBy(CurveAttrValueVo::getAttribute)).entrySet().stream().map(entry->{ return attrValues.stream().collect(Collectors.groupingBy(CurveAttrValueVo::getAttribute)).entrySet().stream().map(entry->{
CurveYArrayVo yArray = new CurveYArrayVo(); CurveYArrayVo yArray = new CurveYArrayVo();
yArray.setAttribute(entry.getKey()); 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.weather(nowWeather,weekWeather,item);
// 前池水位 // 前池水位
this.waterLevel(levelList,item); this.waterLevel(levelList,item);
// 总有功率
this.activePower(item);
}); });
log.info("步骤4站点数据处理 耗时 : {}",System.currentTimeMillis() - beginTime); log.info("步骤4站点数据处理 耗时 : {}",System.currentTimeMillis() - beginTime);
return new TextMessage(JSONObject.toJSONString(validList.stream().peek(o->{ return new TextMessage(JSONObject.toJSONString(validList.stream().peek(o->{

4
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java

@ -2,7 +2,6 @@ package com.hnac.hzims.safeproduct.controller;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; 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.Constants;
import com.hnac.hzims.safeproduct.dto.HygienePlanDTO; import com.hnac.hzims.safeproduct.dto.HygienePlanDTO;
import com.hnac.hzims.safeproduct.dto.HygieneRecordDTO; import com.hnac.hzims.safeproduct.dto.HygieneRecordDTO;
@ -228,8 +227,7 @@ public class HygieneController extends BladeController {
@ApiOperationSupport(order = 19) @ApiOperationSupport(order = 19)
@Operate(label = "卫生自查模板分页", type = BusinessType.QUERY, ignore = false) @Operate(label = "卫生自查模板分页", type = BusinessType.QUERY, ignore = false)
public R<IPage<HygieneTemplateEntity>> hygieneTemplatePage(@ApiIgnore @RequestParam Map<String, Object> param, Query query) { public R<IPage<HygieneTemplateEntity>> hygieneTemplatePage(@ApiIgnore @RequestParam Map<String, Object> param, Query query) {
IPage<HygieneTemplateEntity> page = hygieneTemplateService.page(Condition.getPage(query), Condition.getQueryWrapper( IPage<HygieneTemplateEntity> page = hygieneTemplateService.getHygieneTemplatePage(param, query);
param, HygieneTemplateEntity.class));
return R.data(page); return R.data(page);
} }
} }

1
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygienePlanMapper.java

@ -7,7 +7,6 @@ import org.apache.ibatis.annotations.Mapper;
import org.springblade.core.datascope.annotation.UserDataAuth; import org.springblade.core.datascope.annotation.UserDataAuth;
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
/** /**
* 卫生自查计划Mapper类 * 卫生自查计划Mapper类
* *

10
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneTemplateMapper.java

@ -1,9 +1,12 @@
package com.hnac.hzims.safeproduct.mapper; package com.hnac.hzims.safeproduct.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.safeproduct.entity.HygieneTemplateEntity; import com.hnac.hzims.safeproduct.entity.HygieneTemplateEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import java.util.Map;
/** /**
* 卫生自查模板Mapper类 * 卫生自查模板Mapper类
* *
@ -12,4 +15,11 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface HygieneTemplateMapper extends BaseMapper<HygieneTemplateEntity> { public interface HygieneTemplateMapper extends BaseMapper<HygieneTemplateEntity> {
/**
* 卫生自查页面
* @param param 参数
* @param page 分页类
* @return 页面
*/
IPage<HygieneTemplateEntity> getHygieneTemplatePage(IPage<HygieneTemplateEntity> page, Map<String, Object> param);
} }

13
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneTemplateMapper.xml

@ -1,4 +1,17 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnac.hzims.safeproduct.mapper.HygieneTemplateMapper"> <mapper namespace="com.hnac.hzims.safeproduct.mapper.HygieneTemplateMapper">
<select id="getHygieneTemplatePage" resultType="com.hnac.hzims.safeproduct.entity.HygieneTemplateEntity">
SELECT
*
FROM
hzims_hygiene_template
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> </mapper>

8
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneRecordService.java

@ -10,6 +10,7 @@ import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -62,4 +63,11 @@ public interface IHygieneRecordService extends IService<HygieneRecordEntity> {
* @param response 响应类 * @param response 响应类
*/ */
void exportHygieneRecordData(Long id, HttpServletResponse response); void exportHygieneRecordData(Long id, HttpServletResponse response);
/**
* 查询关联卫生自查记录
* @param planId 计划id
* @return 记录列表
*/
List<HygieneRecordEntity> getReferenceRecord(Long planId);
} }

12
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateService.java

@ -1,9 +1,13 @@
package com.hnac.hzims.safeproduct.service; package com.hnac.hzims.safeproduct.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.safeproduct.dto.HygieneTemplateDTO; import com.hnac.hzims.safeproduct.dto.HygieneTemplateDTO;
import com.hnac.hzims.safeproduct.entity.HygieneTemplateEntity; import com.hnac.hzims.safeproduct.entity.HygieneTemplateEntity;
import com.hnac.hzims.safeproduct.vo.HygieneTemplateDetailVO; import com.hnac.hzims.safeproduct.vo.HygieneTemplateDetailVO;
import org.springblade.core.mp.support.Query;
import java.util.Map;
/** /**
* 卫生自查模板服务类 * 卫生自查模板服务类
@ -46,4 +50,12 @@ public interface IHygieneTemplateService extends IService<HygieneTemplateEntity>
* @return 模板实体类 * @return 模板实体类
*/ */
HygieneTemplateEntity getHygieneTemplateByName(String name); HygieneTemplateEntity getHygieneTemplateByName(String name);
/**
* 卫生自查页面
* @param param 参数
* @param query 分页类
* @return 页面
*/
IPage<HygieneTemplateEntity> getHygieneTemplatePage(Map<String, Object> param, Query query);
} }

103
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java

@ -7,11 +7,13 @@ import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy; import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.common.utils.Condition; import com.hnac.hzims.common.utils.Condition;
import com.hnac.hzims.safeproduct.dto.HygienePlanDTO; import com.hnac.hzims.safeproduct.dto.HygienePlanDTO;
import com.hnac.hzims.safeproduct.entity.HygienePlanEntity; import com.hnac.hzims.safeproduct.entity.HygienePlanEntity;
import com.hnac.hzims.safeproduct.entity.HygieneRecordEntity;
import com.hnac.hzims.safeproduct.entity.HygieneZoneEntity; import com.hnac.hzims.safeproduct.entity.HygieneZoneEntity;
import com.hnac.hzims.safeproduct.enums.HygieneStatusEnum; import com.hnac.hzims.safeproduct.enums.HygieneStatusEnum;
import com.hnac.hzims.safeproduct.mapper.HygienePlanMapper; import com.hnac.hzims.safeproduct.mapper.HygienePlanMapper;
@ -39,6 +41,7 @@ import java.net.URLEncoder;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors;
/** /**
* 卫生自查计划服务实现类 * 卫生自查计划服务实现类
@ -63,15 +66,16 @@ public class HygienePlanServiceImpl extends ServiceImpl<HygienePlanMapper, Hygie
public boolean removePlan(Long id) { public boolean removePlan(Long id) {
// 删除计划数据 // 删除计划数据
boolean remove = this.removeById(id); boolean remove = this.removeById(id);
if (remove) { if (!remove) {
// 删除记录数据 throw new ServiceException("删除卫生自查计划失败");
boolean removeRecord = hygieneRecordService.removeReferenceRecord(id); }
if (removeRecord) { // 删除记录数据
// 删除责任区数据 boolean removeRecord = hygieneRecordService.removeReferenceRecord(id);
return hygieneZoneService.removeReferenceZone(id); if (!removeRecord) {
} throw new ServiceException("删除卫生自查记录失败");
} }
return false; // 删除责任区数据
return hygieneZoneService.removeReferenceZone(id);
} }
/** /**
@ -116,23 +120,20 @@ public class HygienePlanServiceImpl extends ServiceImpl<HygienePlanMapper, Hygie
BeanUtils.copyProperties(hygienePlanDTO, hygienePlanEntity); BeanUtils.copyProperties(hygienePlanDTO, hygienePlanEntity);
hygienePlanDTO.setStandardScore(100); hygienePlanDTO.setStandardScore(100);
boolean savePlan = this.save(hygienePlanEntity); boolean savePlan = this.save(hygienePlanEntity);
if (!savePlan) {
throw new ServiceException("卫生自查计划新增失败");
}
// 新增关联责任区数据
List<HygieneZoneEntity> zoneList = hygienePlanDTO.getZoneList(); List<HygieneZoneEntity> zoneList = hygienePlanDTO.getZoneList();
// 若计划新增成功,新增关联责任区数据 hygienePlan = getPlanByName(hygienePlanDTO.getName());
if (savePlan) { for (HygieneZoneEntity zone : zoneList) {
hygienePlan = getPlanByName(hygienePlanDTO.getName()); zone.setHygienePlanId(hygienePlan.getId());
for (HygieneZoneEntity zone : zoneList) { String[] scores = zone.getCheckItemScore().split(",|,");
// 传计划id // 校验检查项总成绩是否为标准总成绩
if (hygienePlan != null) { BaseUtil.getSumScore(scores, hygienePlanDTO.getStandardScore());
zone.setHygienePlanId(hygienePlan.getId());
}
String[] scores = zone.getCheckItemScore().split(",|,");
// 校验检查项总成绩是否为标准总成绩
BaseUtil.getSumScore(scores, hygienePlanDTO.getStandardScore());
}
// 校验通过则批量新增责任区数据
return R.status(hygieneZoneService.saveBatch(zoneList));
} }
return R.status(Boolean.FALSE); // 校验通过则批量新增责任区数据
return R.status(hygieneZoneService.saveBatch(zoneList));
} }
/** /**
@ -141,9 +142,10 @@ public class HygienePlanServiceImpl extends ServiceImpl<HygienePlanMapper, Hygie
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public R updatePlan(HygienePlanDTO hygienePlanDTO) { public R updatePlan(HygienePlanDTO hygienePlanDTO) {
Long planId = hygienePlanDTO.getId();
// 重名校验 // 重名校验
QueryWrapper<HygienePlanEntity> queryWrapper = new QueryWrapper<>(); QueryWrapper<HygienePlanEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().ne(HygienePlanEntity::getId, hygienePlanDTO.getId()); queryWrapper.lambda().ne(HygienePlanEntity::getId, planId);
queryWrapper.lambda().eq(HygienePlanEntity::getName, hygienePlanDTO.getName()); queryWrapper.lambda().eq(HygienePlanEntity::getName, hygienePlanDTO.getName());
HygienePlanEntity hygienePlan = this.getOne(queryWrapper); HygienePlanEntity hygienePlan = this.getOne(queryWrapper);
if (hygienePlan != null) { if (hygienePlan != null) {
@ -153,28 +155,45 @@ public class HygienePlanServiceImpl extends ServiceImpl<HygienePlanMapper, Hygie
HygienePlanEntity hygienePlanEntity = new HygienePlanEntity(); HygienePlanEntity hygienePlanEntity = new HygienePlanEntity();
BeanUtils.copyProperties(hygienePlanDTO, hygienePlanEntity); BeanUtils.copyProperties(hygienePlanDTO, hygienePlanEntity);
boolean updatePlan = this.updateById(hygienePlanEntity); boolean updatePlan = this.updateById(hygienePlanEntity);
if (!updatePlan) {
throw new ServiceException("卫生自查计划修改失败");
}
// 修改关联责任区数据
List<HygieneZoneEntity> zoneList = hygienePlanDTO.getZoneList(); List<HygieneZoneEntity> zoneList = hygienePlanDTO.getZoneList();
// 若计划修改成功,修改关联责任区数据 // 删除旧的责任区数据
if (updatePlan) { boolean removeZone = hygieneZoneService.removeReferenceZone(planId);
// 删除旧数据 if (!removeZone) {
boolean removeZone = hygieneZoneService.removeReferenceZone(hygienePlanDTO.getId()); throw new ServiceException("删除旧的责任区数据失败");
if (removeZone) { }
hygienePlan = getPlanByName(hygienePlanDTO.getName()); // 新增新的责任区数据
// 增加新数据 hygienePlan = getPlanByName(hygienePlanDTO.getName());
for (HygieneZoneEntity zone : zoneList) { for (HygieneZoneEntity zone : zoneList) {
// 传计划id zone.setHygienePlanId(hygienePlan.getId());
if (hygienePlan != null) { String[] scores = zone.getCheckItemScore().split(",|,");
zone.setHygienePlanId(hygienePlan.getId()); // 校验检查项总成绩是否为标准总成绩
} BaseUtil.getSumScore(scores, hygienePlanDTO.getStandardScore());
String[] scores = zone.getCheckItemScore().split(",|,"); }
// 校验检查项总成绩是否为标准总成绩 // 校验通过则批量修改责任区数据
BaseUtil.getSumScore(scores, hygienePlanDTO.getStandardScore()); boolean saveZone = hygieneZoneService.saveBatch(zoneList);
if (!saveZone) {
throw new ServiceException("新增新的责任区数据失败");
}
// 修改卫生自查记录的责任区id
List<HygieneRecordEntity> recordList = hygieneRecordService.getReferenceRecord(planId);
if (CollectionUtils.isNotEmpty(recordList)) {
List<HygieneZoneEntity> zones = hygieneZoneService.getReferenceZone(planId);
List<Long> ids = zones.stream().map(HygieneZoneEntity::getId).collect(Collectors.toList());
StringBuilder zoneIds = new StringBuilder();
for (int i = 0; i < ids.size(); i++) {
zoneIds.append(ids.get(i));
if (i != ids.size() - 1) {
zoneIds.append(",");
} }
// 校验通过则批量修改责任区数据
return R.status(hygieneZoneService.saveBatch(zoneList));
} }
recordList.forEach(record -> record.setHygieneZoneIds(zoneIds.toString()));
return R.status(hygieneRecordService.updateBatchById(recordList));
} }
return R.status(Boolean.FALSE); return R.status(Boolean.TRUE);
} }
/** /**

24
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java

@ -84,9 +84,9 @@ public class HygieneRecordServiceImpl extends ServiceImpl<HygieneRecordMapper, H
// 获取当月时间 // 获取当月时间
String currentNormMonth = DatePattern.NORM_MONTH_FORMAT.format(new Date()); String currentNormMonth = DatePattern.NORM_MONTH_FORMAT.format(new Date());
String currentSimpleMonth = DatePattern.SIMPLE_MONTH_FORMAT.format(new Date()); String currentSimpleMonth = DatePattern.SIMPLE_MONTH_FORMAT.format(new Date());
// 查询是否存在同月编号 // 查询同月的最新编号
String lastCode = getLastCode(currentNormMonth); String lastCode = getLastCode(currentNormMonth);
// 若不存在,新增编号 // 生成编号
String code = BaseUtil.getUniqueCode("WSZC", lastCode, currentSimpleMonth); String code = BaseUtil.getUniqueCode("WSZC", lastCode, currentSimpleMonth);
hygieneRecordEntity.setCode(code); hygieneRecordEntity.setCode(code);
// 周数计算 // 周数计算
@ -102,12 +102,12 @@ public class HygieneRecordServiceImpl extends ServiceImpl<HygieneRecordMapper, H
} }
} }
boolean save = this.save(hygieneRecordEntity); boolean save = this.save(hygieneRecordEntity);
// 若自查记录新增成功,修改自查计划状态为已完成 if (!save) {
if (save) { throw new ServiceException("卫生自查记录新增失败");
hygienePlanEntity.setHygienePlanStatus(RehearsalStatusEnum.FINISHED.getValue());
return R.status(hygienePlanMapper.updateById(hygienePlanEntity) == SafeProductConstant.SUCCESS);
} }
return R.fail("新增失败"); // 修改自查计划状态为已完成
hygienePlanEntity.setHygienePlanStatus(RehearsalStatusEnum.FINISHED.getValue());
return R.status(hygienePlanMapper.updateById(hygienePlanEntity) == SafeProductConstant.SUCCESS);
} }
/** /**
@ -200,6 +200,16 @@ public class HygieneRecordServiceImpl extends ServiceImpl<HygieneRecordMapper, H
} }
/** /**
* 查询关联卫生自查记录
*/
@Override
public List<HygieneRecordEntity> getReferenceRecord(Long planId) {
QueryWrapper<HygieneRecordEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(HygieneRecordEntity::getHygienePlanId, planId);
return this.list(queryWrapper);
}
/**
* 查询是否存在同月编号 * 查询是否存在同月编号
* @param currentMonth 当月 * @param currentMonth 当月
* @return 存在则返回上一编号否则返回null * @return 存在则返回上一编号否则返回null

77
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateServiceImpl.java

@ -1,6 +1,8 @@
package com.hnac.hzims.safeproduct.service.impl; package com.hnac.hzims.safeproduct.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.safeproduct.dto.HygieneTemplateDTO; import com.hnac.hzims.safeproduct.dto.HygieneTemplateDTO;
import com.hnac.hzims.safeproduct.entity.HygieneTemplateDetailEntity; import com.hnac.hzims.safeproduct.entity.HygieneTemplateDetailEntity;
@ -11,13 +13,17 @@ import com.hnac.hzims.safeproduct.service.IHygieneTemplateService;
import com.hnac.hzims.safeproduct.utils.BaseUtil; import com.hnac.hzims.safeproduct.utils.BaseUtil;
import com.hnac.hzims.safeproduct.vo.HygieneTemplateDetailVO; import com.hnac.hzims.safeproduct.vo.HygieneTemplateDetailVO;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.system.feign.ISysClient;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -31,6 +37,12 @@ public class HygieneTemplateServiceImpl extends ServiceImpl<HygieneTemplateMappe
@Autowired @Autowired
IHygieneTemplateDetailService hygieneTemplateDetailService; IHygieneTemplateDetailService hygieneTemplateDetailService;
@Resource
HygieneTemplateMapper hygieneTemplateMapper;
@Autowired
ISysClient sysClient;
/** /**
* 新增卫生自查模板 * 新增卫生自查模板
*/ */
@ -38,28 +50,28 @@ public class HygieneTemplateServiceImpl extends ServiceImpl<HygieneTemplateMappe
@Override @Override
public boolean saveHygieneTemplate(HygieneTemplateDTO hygieneTemplateDTO) { public boolean saveHygieneTemplate(HygieneTemplateDTO hygieneTemplateDTO) {
String templateName = hygieneTemplateDTO.getTemplateName(); String templateName = hygieneTemplateDTO.getTemplateName();
QueryWrapper<HygieneTemplateEntity> queryWrapper = new QueryWrapper<>(); // 重名校验
queryWrapper.lambda().eq(HygieneTemplateEntity::getTemplateName, templateName); HygieneTemplateEntity hygieneTemplate = getHygieneTemplateByName(templateName);
List<HygieneTemplateEntity> list = this.list(queryWrapper); if (hygieneTemplate != null) {
if (CollectionUtil.isNotEmpty(list)) {
throw new ServiceException("模板名不可重复"); throw new ServiceException("模板名不可重复");
} }
HygieneTemplateEntity hygieneTemplate = new HygieneTemplateEntity(); // 新增模板
hygieneTemplate.setTemplateName(templateName); HygieneTemplateEntity hygieneTemplateEntity = new HygieneTemplateEntity();
boolean saveTemplate = this.save(hygieneTemplate); hygieneTemplateEntity.setTemplateName(templateName);
boolean saveTemplate = this.save(hygieneTemplateEntity);
if (!saveTemplate) { if (!saveTemplate) {
throw new ServiceException("卫生自查模板新增失败"); throw new ServiceException("卫生自查模板新增失败");
} }
// 传模板id // 新增模板详情
HygieneTemplateEntity hygieneTemplateEntity = getHygieneTemplateByName(templateName); hygieneTemplate = getHygieneTemplateByName(templateName);
List<HygieneTemplateDetailEntity> detailList = hygieneTemplateDTO.getTemplateDetailList(); List<HygieneTemplateDetailEntity> detailList = hygieneTemplateDTO.getTemplateDetailList();
detailList.forEach(detail -> { for (HygieneTemplateDetailEntity detail : detailList) {
detail.setTemplateId(hygieneTemplateEntity.getId()); detail.setTemplateId(hygieneTemplate.getId());
String[] scores = detail.getCheckItemScore().split(",|,"); String[] scores = detail.getCheckItemScore().split(",|,");
// 校验检查项总成绩是否为标准总成绩 // 校验检查项总成绩是否为标准总成绩
BaseUtil.getSumScore(scores, 100); BaseUtil.getSumScore(scores, 100);
}); }
return hygieneTemplateDetailService.saveBatch(hygieneTemplateDTO.getTemplateDetailList()); return hygieneTemplateDetailService.saveBatch(detailList);
} }
/** /**
@ -70,26 +82,33 @@ public class HygieneTemplateServiceImpl extends ServiceImpl<HygieneTemplateMappe
public boolean updateHygieneTemplate(HygieneTemplateDTO hygieneTemplateDTO) { public boolean updateHygieneTemplate(HygieneTemplateDTO hygieneTemplateDTO) {
String templateName = hygieneTemplateDTO.getTemplateName(); String templateName = hygieneTemplateDTO.getTemplateName();
Long templateId = hygieneTemplateDTO.getTemplateId(); Long templateId = hygieneTemplateDTO.getTemplateId();
// 重名校验
QueryWrapper<HygieneTemplateEntity> queryWrapper = new QueryWrapper<>(); QueryWrapper<HygieneTemplateEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(HygieneTemplateEntity::getTemplateName, templateName); queryWrapper.lambda().eq(HygieneTemplateEntity::getTemplateName, templateName);
queryWrapper.lambda().ne(HygieneTemplateEntity::getId, templateId); queryWrapper.lambda().ne(HygieneTemplateEntity::getId, templateId);
List<HygieneTemplateEntity> list = this.list(queryWrapper); HygieneTemplateEntity hygieneTemplate = this.getOne(queryWrapper);
if (CollectionUtil.isNotEmpty(list)) { if (hygieneTemplate != null) {
throw new ServiceException("模板名不可重复"); throw new ServiceException("模板名不可重复");
} }
HygieneTemplateEntity hygieneTemplate = new HygieneTemplateEntity(); // 更新模板
hygieneTemplate.setId(templateId); HygieneTemplateEntity hygieneTemplateEntity = new HygieneTemplateEntity();
hygieneTemplate.setTemplateName(templateName); hygieneTemplateEntity.setId(templateId);
boolean updateTemplate = this.updateById(hygieneTemplate); hygieneTemplateEntity.setTemplateName(templateName);
boolean updateTemplate = this.updateById(hygieneTemplateEntity);
if (!updateTemplate) { if (!updateTemplate) {
throw new ServiceException("卫生自查模板更新失败"); throw new ServiceException("卫生自查模板更新失败");
} }
// 更新模板详情
// 删除旧的模板详情数据
boolean removeDetail = hygieneTemplateDetailService.removeReferenceDetail(templateId); boolean removeDetail = hygieneTemplateDetailService.removeReferenceDetail(templateId);
if (!removeDetail) { if (!removeDetail) {
throw new ServiceException("卫生自查模板详情数据删除失败"); throw new ServiceException("卫生自查模板详情数据删除失败");
} }
// 新增新的模板详情数据
hygieneTemplate = getHygieneTemplateByName(templateName);
List<HygieneTemplateDetailEntity> detailList = hygieneTemplateDTO.getTemplateDetailList(); List<HygieneTemplateDetailEntity> detailList = hygieneTemplateDTO.getTemplateDetailList();
for (HygieneTemplateDetailEntity detail : detailList) { for (HygieneTemplateDetailEntity detail : detailList) {
detail.setTemplateId(hygieneTemplate.getId());
String[] scores = detail.getCheckItemScore().split(",|,"); String[] scores = detail.getCheckItemScore().split(",|,");
BaseUtil.getSumScore(scores, 100); BaseUtil.getSumScore(scores, 100);
} }
@ -133,4 +152,22 @@ public class HygieneTemplateServiceImpl extends ServiceImpl<HygieneTemplateMappe
queryWrapper.lambda().eq(HygieneTemplateEntity::getTemplateName, name); queryWrapper.lambda().eq(HygieneTemplateEntity::getTemplateName, name);
return this.getOne(queryWrapper); return this.getOne(queryWrapper);
} }
/**
* 卫生自查页面
*/
@Override
public IPage<HygieneTemplateEntity> getHygieneTemplatePage(Map<String, Object> param, Query query) {
IPage<HygieneTemplateEntity> page = new Page<>(query.getCurrent(), query.getSize());
IPage<HygieneTemplateEntity> templatePage = hygieneTemplateMapper.getHygieneTemplatePage(page, param);
List<HygieneTemplateEntity> 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;
}
} }

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()); list= list.stream().filter(s -> s.getScore() != null).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(list)) { if (CollectionUtils.isNotEmpty(list)) {
testScoreSumVO.setActualPeopleNum(list.size()); 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)) { if (CollectionUtils.isNotEmpty(list)&&CollectionUtils.isNotEmpty(passCollect)) {
double result = BigDecimal.valueOf(passCollect.size()).divide(BigDecimal.valueOf(list.size()),2, RoundingMode.UP).doubleValue(); double result = BigDecimal.valueOf(passCollect.size()).divide(BigDecimal.valueOf(list.size()),2, RoundingMode.UP).doubleValue();
testScoreSumVO.setPercentage(result); testScoreSumVO.setPercentage(result);

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

@ -31,9 +31,9 @@ CREATE TABLE IF NOT EXISTS `hzims_hygiene_template_detail` (
`id` bigint(20) NOT NULL COMMENT '主键ID', `id` bigint(20) NOT NULL COMMENT '主键ID',
`template_id` bigint(20) NOT NULL COMMENT '模板id', `template_id` bigint(20) NOT NULL COMMENT '模板id',
`zone` varchar(50) NOT NULL COMMENT '责任区', `zone` varchar(50) NOT NULL COMMENT '责任区',
`PRINCIPAL` VARCHAR(20) NOT NULL COMMENT '责任人', `principal` varchar(20) NOT NULL COMMENT '责任人',
`CHECK_ITEM` MEDIUMTEXT NOT NULL COMMENT '检查项', `check_item` mediumtext NOT NULL COMMENT '检查项',
`CHECK_ITEM_SCORE` VARCHAR(255) NOT NULL COMMENT '检查项分值', `check_item_score` varchar(255) NOT NULL COMMENT '检查项分值',
`create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人', `create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人',
`create_dept` 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 '创建时间', `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',

5
pom.xml

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

Loading…
Cancel
Save