Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
haungxing 11 months ago
parent
commit
23b32bc96b
  1. 7
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/entity/PowerEntity.java
  2. 40
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/VideoEnumConstants.java
  3. 24
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/VideoAlarmVO.java
  4. 41
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/VideoConfigEntity.java
  5. 95
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/RehearsalRecordDTO.java
  6. 23
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/RehearsalYearDTO.java
  7. 97
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/RehearsalRecordEntity.java
  8. 31
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/enums/RehearsalMethodEnum.java
  9. 32
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/enums/RehearsalStatusEnum.java
  10. 31
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalMonthVO.java
  11. 53
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalYearVO.java
  12. 7
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmInfoController.java
  13. 2
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java
  14. 11
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java
  15. 7
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/MonitorScheduledTask.java
  16. 4
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java
  17. 7
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/controller/CentralMonitorController.java
  18. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/CentralMonitorService.java
  19. 19
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/CentralMonitorServiceImpl.java
  20. 38
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/AiAlarmController.java
  21. 14
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/AiAlarmService.java
  22. 82
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AiAlarmServiceImpl.java
  23. 51
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java
  24. 12
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/VideoConfigMapper.java
  25. 20
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/VideoConfigMapper.xml
  26. 13
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/VideoConfigService.java
  27. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java
  28. 17
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/VideoConfigServiceImpl.java
  29. 108
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalRecordController.java
  30. 43
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/RehearsalJob.java
  31. 54
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalRecordMapper.java
  32. 65
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalRecordMapper.xml
  33. 66
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IRehearsalRecordService.java
  34. 308
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalRecordServiceImpl.java
  35. 28
      hzims-service/safeproduct/src/main/resources/db/1.0.1.sql

7
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/entity/PowerEntity.java

@ -5,14 +5,19 @@ 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.io.Serializable;
/**
* @author ysj
*/
@EqualsAndHashCode(callSuper = true)
@Data @Data
@TableName("hzims_fill_power") @TableName("hzims_fill_power")
@ApiModel(value="PowerEntity对象", description="电站填报") @ApiModel(value="PowerEntity对象", description="光伏站填报")
public class PowerEntity extends TenantEntity implements Serializable { public class PowerEntity extends TenantEntity implements Serializable {
@ApiModelProperty("月份") @ApiModelProperty("月份")

40
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/VideoEnumConstants.java

@ -0,0 +1,40 @@
package com.hnac.hzims.operational.main.constant;
import lombok.Getter;
/**
* @author ysj
* @version 4.0.0
* @create 2023-11-07-14:31
*/
public interface VideoEnumConstants {
@Getter
enum SoeKindEnum{
/**
* 视频告警类型
*/
MOTION_DETECTION("131331","移动侦测"),
REGIONAL_INTRUSION("131588","区域入侵"),
CROSS_BORDER_DETECTION("131585","越界侦测"),
SMOKE_FIRE_DETECTION("192514","烟火检测"),
OTHER_FLOATING_OBJECTS("42200047146001","其他漂浮物"),
PLANT_FLOATING_OBJECTS("42200047146000","植物类漂浮物"),
PLASTIC_FLOATING_OBJECTS("42200047146002","塑料类漂浮物");
private final String instance;
private final String name;
SoeKindEnum(String instance,String name){
this.instance = instance;
this.name = name;
}
public static String getValueByKey(String key) {
for (SoeKindEnum kind : SoeKindEnum.values()) {
if (kind.instance.equals(key)) {
return kind.getName();
}
}
throw new IllegalArgumentException("Invalid key: " + key);
}
}
}

24
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/VideoAlarmVO.java

@ -0,0 +1,24 @@
package com.hnac.hzims.operational.main.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author ysj
*/
@Data
public class VideoAlarmVO {
@ApiModelProperty("设备编码")
private String deviceCode;
@ApiModelProperty("设备名称")
private String deviceName;
@ApiModelProperty("开始时间")
private String startTime;
@ApiModelProperty("结束时间")
private String endTime;
}

41
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/VideoConfigEntity.java

@ -0,0 +1,41 @@
package com.hnac.hzims.operational.station.entity;
import com.baomidou.mybatisplus.annotation.SqlCondition;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.support.QueryField;
import org.springblade.core.tenant.mp.TenantEntity;
@Data
@TableName("hzims_flv_video_config")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "视频配置对象", description = "视频配置表")
public class VideoConfigEntity extends TenantEntity {
private static final long serialVersionUID = 8694213320261034807L;
@QueryField(condition = SqlCondition.LIKE)
@ApiModelProperty("视频源配置名称")
private String name;
@QueryField(condition = SqlCondition.EQUAL)
@ApiModelProperty("时间间隔")
private String time;
@QueryField(condition = SqlCondition.LIKE)
@ApiModelProperty("配置json")
private String configEntity;
@QueryField(condition = SqlCondition.EQUAL)
@ApiModelProperty("视频类型")
private String type;
@QueryField(condition = SqlCondition.EQUAL)
@ApiModelProperty("保存人姓名")
private String savePeople;
}

95
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/RehearsalRecordDTO.java

@ -0,0 +1,95 @@
package com.hnac.hzims.safeproduct.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.Date;
/**
* @author liwen
* @date 2023-12-15
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "演练记录DTO类")
public class RehearsalRecordDTO extends BaseEntity {
@Size(max = 50, message = "编码字段长度不能超过50")
@ApiModelProperty("编码")
private String code;
@NotNull
@Size(max = 50, message = "单位字段长度不能超过50")
@ApiModelProperty("单位")
private String unit;
@NotNull
@Size(max = 50, message = "演练科目字段长度不能超过50")
@ApiModelProperty("演练科目")
private String subject;
@NotNull
@ApiModelProperty("演练计划开始时间")
private Date scheduledStartTime;
@NotNull
@ApiModelProperty("演练计划结束时间")
private Date scheduledEndTime;
@NotNull
@Size(max = 255, message = "演练地点字段长度不能超过255")
@ApiModelProperty("演练地点")
private String location;
@Min(value = 0, message = "参演人数不能小于0")
@Max(value = 1000, message = "参演人数字段长度超出限制范围")
@ApiModelProperty("参演人数")
private Integer peopleNum;
@Size(max = 5000, message = "参演人员字段长度超出限制范围")
@ApiModelProperty("参演人员")
private String[] people;
@NotNull
@Size(max = 10, message = "总指挥字段长度不能超过10")
@ApiModelProperty("总指挥")
private String commander;
@ApiModelProperty("演练实际开始时间")
private Date actualStartTime;
@ApiModelProperty("演练实际结束时间")
private Date actualEndTime;
@Size(max = 250, message = "演练记录字段长度不能超过250")
@ApiModelProperty("演练记录")
private String record;
@Size(max = 250, message = "演练评价字段长度不能超过250")
@ApiModelProperty("演练评价")
private String comment;
@Size(max = 20, message = "演练方式字段长度不能超过20")
@ApiModelProperty("演练方式")
private String rehearsalMethod;
@NotNull
@Size(max = 20, message = "演练状态字段长度不能超过20")
@ApiModelProperty("演练状态")
private String rehearsalStatus;
@Size(max = 1000, message = "演练图片字段长度不能超过1000")
@ApiModelProperty("演练图片")
private String[] images;
@Size(max = 1000, message = "演练附件字段长度不能超过1000")
@ApiModelProperty("演练附件")
private String[] files;
}

23
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/RehearsalYearDTO.java

@ -0,0 +1,23 @@
package com.hnac.hzims.safeproduct.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author liwen
* @date 2023-12-14
*/
@Data
@ApiModel(value = "演练年度统计DTO类")
public class RehearsalYearDTO {
@ApiModelProperty("单位")
private String unit;
@ApiModelProperty("日期")
private String dateTime;
@ApiModelProperty("完成数")
private Long finishedNum;
}

97
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/RehearsalRecordEntity.java

@ -0,0 +1,97 @@
package com.hnac.hzims.safeproduct.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.Date;
/**
* @author liwen
* @date 2023-12-13
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("hzims_rehearsal_record")
@ApiModel(value = "演练记录实体类")
public class RehearsalRecordEntity extends BaseEntity {
@Size(max = 50, message = "编码字段长度不能超过50")
@ApiModelProperty("编码")
private String code;
@NotNull
@Size(max = 50, message = "单位字段长度不能超过50")
@ApiModelProperty("单位")
private String unit;
@NotNull
@Size(max = 50, message = "演练科目字段长度不能超过50")
@ApiModelProperty("演练科目")
private String subject;
@NotNull
@ApiModelProperty("演练计划开始时间")
private Date scheduledStartTime;
@NotNull
@ApiModelProperty("演练计划结束时间")
private Date scheduledEndTime;
@NotNull
@Size(max = 255, message = "演练地点字段长度不能超过255")
@ApiModelProperty("演练地点")
private String location;
@Min(value = 0, message = "参演人数不能小于0")
@Max(value = 1000, message = "参演人数字段长度超出限制范围")
@ApiModelProperty("参演人数")
private Integer peopleNum;
@Size(max = 5000, message = "参演人员字段长度超出限制范围")
@ApiModelProperty("参演人员")
private String peopleName;
@NotNull
@Size(max = 10, message = "总指挥字段长度不能超过10")
@ApiModelProperty("总指挥")
private String commander;
@ApiModelProperty("演练实际开始时间")
private Date actualStartTime;
@ApiModelProperty("演练实际结束时间")
private Date actualEndTime;
@Size(max = 250, message = "演练记录字段长度不能超过250")
@ApiModelProperty("演练记录")
private String record;
@Size(max = 250, message = "演练评价字段长度不能超过250")
@ApiModelProperty("演练评价")
private String comment;
@Size(max = 20, message = "演练方式字段长度不能超过20")
@ApiModelProperty("演练方式")
private String rehearsalMethod;
@NotNull
@Size(max = 20, message = "演练状态字段长度不能超过20")
@ApiModelProperty("演练状态")
private String rehearsalStatus;
@Size(max = 1000, message = "演练图片字段长度不能超过1000")
@ApiModelProperty("演练图片")
private String imgPath;
@Size(max = 1000, message = "演练附件字段长度不能超过1000")
@ApiModelProperty("演练附件")
private String filePath;
}

31
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/enums/RehearsalMethodEnum.java

@ -0,0 +1,31 @@
package com.hnac.hzims.safeproduct.enums;
/**
* 演练方式枚举类
*
* @author liwen
* @date 2023-12-14
*/
public enum RehearsalMethodEnum {
ONLINE("ONLINE", "线上"),
OFFLINE("OFFLINE", "线下"),
MIXED("MIXED", "线上+线下");
private final String value;
private final String desc;
RehearsalMethodEnum(String value, String desc) {
this.value = value;
this.desc = desc;
}
public String getValue() {
return value;
}
public String getDesc() {
return desc;
}
}

32
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/enums/RehearsalStatusEnum.java

@ -0,0 +1,32 @@
package com.hnac.hzims.safeproduct.enums;
/**
* 演练状态枚举类
*
* @author liwen
* @date 2023-12-14
*/
public enum RehearsalStatusEnum {
WAITING("WAITING", "未开始"),
UNFINISHED("UNFINISHED", "未完成"),
FINISHED("FINISHED", "已完成");
private final String value;
private final String desc;
RehearsalStatusEnum(String value, String desc) {
this.value = value;
this.desc = desc;
}
public String getValue() {
return value;
}
public String getDesc() {
return desc;
}
}

31
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalMonthVO.java

@ -0,0 +1,31 @@
package com.hnac.hzims.safeproduct.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* @author liwen
* @date 2023-12-14
*/
@Data
@ApiModel(value = "演练月度统计VO类")
public class RehearsalMonthVO {
@ApiModelProperty("单位")
private String unit;
@ApiModelProperty("计划任务总数")
private Long scheduledTaskNum;
@ApiModelProperty("已完成任务/次")
private Long finishedTaskNum;
@ApiModelProperty("未完成任务/次")
private Long unfinishedTaskNum;
@ApiModelProperty("任务完成率")
private BigDecimal taskCompletionRate;
}

53
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalYearVO.java

@ -0,0 +1,53 @@
package com.hnac.hzims.safeproduct.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author liwen
* @date 2023-12-14
*/
@Data
@ApiModel(value = "演练年度统计VO类")
public class RehearsalYearVO {
@ApiModelProperty("单位")
private String unit;
@ApiModelProperty("1月完成数")
private Long januaryNum;
@ApiModelProperty("2月完成数")
private Long februaryNum;
@ApiModelProperty("3月完成数")
private Long marchNum;
@ApiModelProperty("4月完成数")
private Long aprilNum;
@ApiModelProperty("5月完成数")
private Long mayNum;
@ApiModelProperty("6月完成数")
private Long juneNum;
@ApiModelProperty("7月完成数")
private Long julyNum;
@ApiModelProperty("8月完成数")
private Long augustNum;
@ApiModelProperty("9月完成数")
private Long septemberNum;
@ApiModelProperty("10月完成数")
private Long octoberNum;
@ApiModelProperty("11月完成数")
private Long novemberNum;
@ApiModelProperty("12月完成数")
private Long decemberNum;
}

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

@ -413,4 +413,11 @@ public class EmInfoController extends BladeController {
public R<List<JSONObject>> getEmTreeByDeptAndParentCode(@ApiParam("机构ID") Long deptId, @ApiParam("父级设备编号") String parentCode) { public R<List<JSONObject>> getEmTreeByDeptAndParentCode(@ApiParam("机构ID") Long deptId, @ApiParam("父级设备编号") String parentCode) {
return R.data(em_infoService.getEmTreeByDeptAndParentCode(deptId,parentCode)); return R.data(em_infoService.getEmTreeByDeptAndParentCode(deptId,parentCode));
} }
@GetMapping("/hkVideoDevices")
@ApiOperationSupport(order = 12)
@ApiOperation(value = "海康视频设备获取")
public R<List<EmInfoEntity>> hkVideoDevices() {
return R.data(em_infoService.hkVideoDevices());
}
} }

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

@ -89,4 +89,6 @@ public interface IEmInfoService extends BaseService<EmInfoEntity> {
List<JSONObject> getEmTreeByDeptAndParentCode(Long deptId, String parentCode); List<JSONObject> getEmTreeByDeptAndParentCode(Long deptId, String parentCode);
List<EmInfoEntity> getVideoDeviceByEmCode(EmInfoEntity emInfo); List<EmInfoEntity> getVideoDeviceByEmCode(EmInfoEntity emInfo);
List<EmInfoEntity> hkVideoDevices();
} }

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

@ -900,4 +900,15 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
projectClient.addProjectAndContent(projectDTOList); projectClient.addProjectAndContent(projectDTOList);
} }
} }
/**
* 海康视频获取接口
* @return
*/
@Override
public List<EmInfoEntity> hkVideoDevices() {
return this.list(Wrappers.<EmInfoEntity>lambdaQuery()
.eq(EmInfoEntity::getEmType,4));
}
} }

7
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/MonitorScheduledTask.java

@ -55,10 +55,9 @@ public class MonitorScheduledTask {
* 集中监控数据处理 * 集中监控数据处理
* @return ReturnT<String> * @return ReturnT<String>
*/ */
//@XxlJob(CENTRALIZED_MONITORING) @XxlJob(CENTRALIZED_MONITORING)
@Scheduled(cron = "0/40 * * * * ? ") //@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> loadMonitoring() { public ReturnT<String> loadMonitoring(String param) {
String param = "";
if (Func.isBlank(param)) { if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM"); param = DateUtil.format(new Date(), "yyyy-MM");
} }

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

@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.hnac.hzims.alarm.entity.AlarmEntity;
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.fdp.vo.FdpFaultStatusVo;
@ -452,9 +451,10 @@ public class MonitorServiceImpl implements MonitorService {
return; return;
} }
item.setStationName(station.getName()); item.setStationName(station.getName());
item.setWaterLevelMax(station.getLimitWaterLevel()); item.setWaterLevelMax(Optional.ofNullable(station.getLimitWaterLevel()).orElse(0.0));
item.setServerType(station.getServeType()); item.setServerType(station.getServeType());
item.setStationDeptId(station.getRefDept()); item.setStationDeptId(station.getRefDept());
item.setSort(9999);
// 排序 // 排序
List<Dept> list = deptAll.stream().filter(o-> station.getRefDept().equals(o.getId())).collect(Collectors.toList()); List<Dept> list = deptAll.stream().filter(o-> station.getRefDept().equals(o.getId())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(list)){ if(CollectionUtil.isEmpty(list)){

7
hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/controller/CentralMonitorController.java

@ -15,6 +15,7 @@ import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List; import java.util.List;
@ -58,8 +59,10 @@ public class CentralMonitorController extends BladeController {
@GetMapping("/selectCommunication/{page}/{size}") @GetMapping("/selectCommunication/{page}/{size}")
public R selectCommunication(@PathVariable Integer page, public R selectCommunication(@PathVariable Integer page,
@PathVariable Integer size, @PathVariable Integer size,
String roleId){ String roleId,
IPage<PointDataVo> result = monitorService.selectOriginalDataByRealIds(page, size, roleId); Date start,
Date end){
IPage<PointDataVo> result = monitorService.selectOriginalDataByRealIds(page, size, roleId,start,end);
return R.data(result); return R.data(result);
} }
} }

3
hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/CentralMonitorService.java

@ -7,6 +7,7 @@ import com.hnac.hzims.operational.main.vo.RealStationVo;
import com.hnac.hzinfo.datasearch.PointData; import com.hnac.hzinfo.datasearch.PointData;
import com.hnac.hzinfo.sdk.core.response.HzPage; import com.hnac.hzinfo.sdk.core.response.HzPage;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -28,6 +29,6 @@ public interface CentralMonitorService{
* @param roleId * @param roleId
* @return * @return
*/ */
IPage<PointDataVo> selectOriginalDataByRealIds(Integer page, Integer size, String roleId); IPage<PointDataVo> selectOriginalDataByRealIds(Integer page, Integer size, String roleId, Date start, Date end);
} }

19
hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/CentralMonitorServiceImpl.java

@ -91,14 +91,23 @@ public class CentralMonitorServiceImpl implements CentralMonitorService {
* @return * @return
*/ */
@Override @Override
public IPage<PointDataVo> selectOriginalDataByRealIds(Integer page, Integer size, String roleId) { public IPage<PointDataVo> selectOriginalDataByRealIds(Integer page, Integer size, String roleId,Date start,Date end) {
OriginalDataQuery originalDataQuery = new OriginalDataQuery(); OriginalDataQuery originalDataQuery = new OriginalDataQuery();
originalDataQuery.setRealId(roleId); originalDataQuery.setRealId(roleId);
originalDataQuery.setLimit(size); originalDataQuery.setLimit(size);
Calendar calendar = Calendar.getInstance(); // 当日
originalDataQuery.setEndTime(calendar.getTime()); if(ObjectUtil.isEmpty(start) && ObjectUtil.isEmpty(end)){
calendar.add(Calendar.HOUR_OF_DAY,-1); Calendar calendar = Calendar.getInstance();
originalDataQuery.setBeginTime(calendar.getTime()); originalDataQuery.setEndTime(calendar.getTime());
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.MILLISECOND,-calendar.get(Calendar.MILLISECOND));
originalDataQuery.setBeginTime(calendar.getTime());
}else{
originalDataQuery.setBeginTime(start);
originalDataQuery.setEndTime(end);
}
Result<HzPage<PointData>> originalDataByRealIds = historyDataSearchClient.getOriginalDataByRealIds(originalDataQuery); Result<HzPage<PointData>> originalDataByRealIds = historyDataSearchClient.getOriginalDataByRealIds(originalDataQuery);
if (!originalDataByRealIds.isSuccess()) { if (!originalDataByRealIds.isSuccess()) {
throw new ServiceException("数据不存在"); throw new ServiceException("数据不存在");

38
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/AiAlarmController.java

@ -0,0 +1,38 @@
package com.hnac.hzims.operational.main.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.operational.main.service.AiAlarmService;
import com.hnac.hzims.operational.main.vo.VideoAlarmVO;
import com.hnac.hzinfo.datasearch.soe.vo.DeviceSoeVO;
import com.hnac.hzinfo.sdk.core.response.HzPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.tool.api.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author ysj
*/
@RestController
@RequestMapping("/ai")
@Api(value = "ai视频告警", tags = "ai视频告警")
@AllArgsConstructor
public class AiAlarmController extends BladeController {
private final AiAlarmService aiAlarmService;
@ApiLog
@GetMapping("/video/alarm_page")
@ApiOperationSupport(order = 15)
@ApiOperation(value = "视频告警数据查询接口", notes = "station")
public R<HzPage<DeviceSoeVO>> alarmPage(VideoAlarmVO videoAlarm, Query query) {
return R.data(aiAlarmService.alarmPage(videoAlarm, Condition.getPage(query)));
}
}

14
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/AiAlarmService.java

@ -0,0 +1,14 @@
package com.hnac.hzims.operational.main.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.operational.main.vo.VideoAlarmVO;
import com.hnac.hzinfo.datasearch.soe.vo.DeviceSoeVO;
import com.hnac.hzinfo.sdk.core.response.HzPage;
/**
* @author ysj
*/
public interface AiAlarmService {
HzPage<DeviceSoeVO> alarmPage(VideoAlarmVO videoAlarm, IPage<DeviceSoeVO> page);
}

82
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AiAlarmServiceImpl.java

@ -0,0 +1,82 @@
package com.hnac.hzims.operational.main.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.operational.main.constant.VideoEnumConstants;
import com.hnac.hzims.operational.main.service.AiAlarmService;
import com.hnac.hzims.operational.main.vo.VideoAlarmVO;
import com.hnac.hzinfo.datasearch.soe.ISoeClient;
import com.hnac.hzinfo.datasearch.soe.vo.DeviceSoeVO;
import com.hnac.hzinfo.sdk.core.response.HzPage;
import com.hnac.hzinfo.sdk.core.response.Result;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Service;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author ysj
*/
@Slf4j
@RequiredArgsConstructor
@Service
public class AiAlarmServiceImpl implements AiAlarmService {
private final ISoeClient alarmClient;
/**
* 设备告警列表查询
* @param videoAlarm
* @param page
* @return
*/
@Override
public HzPage<DeviceSoeVO> alarmPage(VideoAlarmVO videoAlarm, IPage<DeviceSoeVO> page) {
String startTime,endTime;
if(StringUtils.isEmpty(videoAlarm.getStartTime())){
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_MONTH,-calendar.get(Calendar.DAY_OF_MONTH));
startTime = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00";
}else{
startTime = videoAlarm.getStartTime();
}
if(StringUtils.isEmpty(videoAlarm.getEndTime())){
endTime = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME);
}else{
endTime = videoAlarm.getEndTime();
}
// 查询视频告警数据
Result<HzPage<DeviceSoeVO>> soe = alarmClient.getDeviceCodeByTaosSoe(startTime,endTime,videoAlarm.getDeviceCode(),(int) page.getCurrent(), String.valueOf(page.getSize()));
if(!soe.isSuccess() || CollectionUtil.isEmpty(soe.getData().getRecords())){
return new HzPage<>();
}
List<DeviceSoeVO> records = soe.getData().getRecords();
soe.getData().setRecords(records.stream().peek(record -> {
record.setSoeType(videoAlarm.getDeviceName() + "_" + VideoEnumConstants.SoeKindEnum.getValueByKey(record.getInstanceFieldName()) + "_触发告警");
if(!StringUtil.isEmpty(record.getSoeExplain())) {
String soeExplain = StringUtils.strip(record.getSoeExplain(), "[]");
StringBuilder sb = new StringBuilder();
if(record.getSoeExplain().contains("http")){
String[] imgs = soeExplain.split(",");
for (String img : imgs){
sb.append(img).append(",");
}
}else{
String[] imgs = soeExplain.split(",");
for (String img : imgs){
sb.append("https://172.30.100.204").append(img).append(",");
}
}
record.setSoeAlarmType(sb.substring(0, sb.length() - 1).replace("\"", ""));
}
}).collect(Collectors.toList()));
return soe.getData();
}
}

51
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java

@ -3,6 +3,7 @@ package com.hnac.hzims.operational.station.controller;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.common.logs.annotation.OperationAnnotation; import com.hnac.hzims.common.logs.annotation.OperationAnnotation;
@ -11,10 +12,12 @@ import com.hnac.hzims.common.logs.enums.OperatorType;
import com.hnac.hzims.operational.station.dto.StationVideoTypeDTO; import com.hnac.hzims.operational.station.dto.StationVideoTypeDTO;
import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity;
import com.hnac.hzims.operational.station.entity.VideoConfigEntity;
import com.hnac.hzims.operational.station.response.HikDeviceResp; import com.hnac.hzims.operational.station.response.HikDeviceResp;
import com.hnac.hzims.operational.station.response.HikMonitorResp; import com.hnac.hzims.operational.station.response.HikMonitorResp;
import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzims.operational.station.service.IStationService;
import com.hnac.hzims.operational.station.service.IStationVideoTypeService; import com.hnac.hzims.operational.station.service.IStationVideoTypeService;
import com.hnac.hzims.operational.station.service.VideoConfigService;
import com.hnac.hzims.operational.station.utils.ArtemisPostUtils; import com.hnac.hzims.operational.station.utils.ArtemisPostUtils;
import com.hnac.hzims.operational.station.vo.StationVO; import com.hnac.hzims.operational.station.vo.StationVO;
import com.hnac.hzims.operational.station.vo.StationVideoTypeVO; import com.hnac.hzims.operational.station.vo.StationVideoTypeVO;
@ -28,9 +31,13 @@ import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.log.annotation.ApiLog; import org.springblade.core.log.annotation.ApiLog;
import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query; 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.api.R;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.system.entity.AuthClient;
import org.springblade.system.entity.Dept; import org.springblade.system.entity.Dept;
import org.springblade.system.feign.ISysClient; import org.springblade.system.feign.ISysClient;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@ -56,6 +63,7 @@ public class StationVideoTypeController extends BladeController {
private final ISysClient sysClient; private final ISysClient sysClient;
private final IStationService stationService; private final IStationService stationService;
private final VideoConfigService videoConfigService;
/** 秘钥appKey **/ /** 秘钥appKey **/
@Value("${hzims.videoProperties.appKey}") @Value("${hzims.videoProperties.appKey}")
@ -233,6 +241,49 @@ public class StationVideoTypeController extends BladeController {
page.getRecords().forEach(getFlvVideo); page.getRecords().forEach(getFlvVideo);
return R.data(page); return R.data(page);
} }
@ApiLog
@GetMapping("/getFlvVideoConfig")
@ApiOperationSupport(order = 120)
@ApiOperation(value = "获取Flv配置列表", notes = "获取Flv配置列表")
public R getFlvVideoConfig(VideoConfigEntity req,Query query) {
LambdaQueryWrapper<VideoConfigEntity> queryWrapper = com.hnac.hzims.common.utils.Condition.getQueryWrapper(VideoConfigEntity.class, req);
IPage<VideoConfigEntity> page = videoConfigService.page(com.hnac.hzims.common.utils.Condition.getPage(query), queryWrapper);
return R.data(page);
}
@ApiLog
@PostMapping ("/updateFlvVideoConfig")
@ApiOperationSupport(order = 120)
@ApiOperation(value = "更新Flv配置列表", notes = "更新Flv配置列表")
public R updateFlvVideoConfig(@RequestBody VideoConfigEntity req) {
if (ObjectUtil.isNotEmpty(req)) {
if(StringUtil.isBlank(req.getSavePeople())){
String userName = AuthUtil.getNickName();
if (StringUtil.isNotBlank(userName)){
req.setSavePeople(userName);
}
}
boolean b = videoConfigService.saveOrUpdate(req);
if (b) {
return R.success("更新视频配置成功");
}
}
return R.fail("更新视频配置失败");
}
@ApiLog
@PostMapping("/deleteFlvVideoConfig")
@ApiOperationSupport(order = 120)
@ApiOperation(value = "删除Flv配置列表", notes = "删除Flv配置列表")
public R deleteFlvVideoConfig(@RequestBody List<String> ids) {
if (CollectionUtils.isNotEmpty(ids)) {
boolean flag = videoConfigService.removeByIds(ids);
if (flag) {
return R.success("删除成功");
}
}
return R.fail("删除失败");
}
@ApiLog @ApiLog
@GetMapping("/getMonitorsByStation") @GetMapping("/getMonitorsByStation")
@ApiOperationSupport(order = 130) @ApiOperationSupport(order = 130)

12
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/VideoConfigMapper.java

@ -0,0 +1,12 @@
package com.hnac.hzims.operational.station.mapper;
import com.hnac.hzims.operational.station.entity.VideoConfigEntity;
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
/**
* @author ty
*/
public interface VideoConfigMapper extends UserDataScopeBaseMapper<VideoConfigEntity> {
}

20
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/VideoConfigMapper.xml

@ -0,0 +1,20 @@
<?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.station.mapper.VideoConfigMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.hnac.hzims.operational.station.entity.HzimsAnalyzeModelStationEntity">
<id column="ID" property="id" />
<result column="TENANT_ID" property="tenantId" />
<result column="STATION_ID" property="stationId" />
<result column="INSTANCE_CODE" property="instanceCode" />
<result column="REMARK" property="remark" />
<result column="CREATE_TIME" property="createTime" />
<result column="UPDATE_TIME" property="updateTime" />
<result column="CREATE_USER" property="createUser" />
<result column="UPDATE_USER" property="updateUser" />
<result column="IS_DELETED" property="isDeleted" />
<result column="STATUS" property="status" />
<result column="CREATE_DEPT" property="createDept" />
</resultMap>
</mapper>

13
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/VideoConfigService.java

@ -0,0 +1,13 @@
package com.hnac.hzims.operational.station.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.operational.station.entity.VideoConfigEntity;
/**
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/8/8 16:14
*/
public interface VideoConfigService extends IService<VideoConfigEntity> {
}

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

@ -965,7 +965,7 @@ public class RealMonitorServiceImpl implements IRealMonitorService {
return; return;
} }
station.setWaterLevel(levelList.get(0)); station.setWaterLevel(levelList.get(0));
if(station.getWaterLevelMax() <= 0 || station.getWaterLevel() <= 0){ if(ObjectUtil.isEmpty(station.getWaterLevelMax()) || ObjectUtil.isEmpty(station.getWaterLevel()) || station.getWaterLevelMax() <= 0 || station.getWaterLevel() <= 0){
return; return;
} }
if(station.getWaterLevelMax() < station.getWaterLevel()){ if(station.getWaterLevelMax() < station.getWaterLevel()){

17
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/VideoConfigServiceImpl.java

@ -0,0 +1,17 @@
package com.hnac.hzims.operational.station.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.operational.station.entity.VideoConfigEntity;
import com.hnac.hzims.operational.station.mapper.VideoConfigMapper;
import com.hnac.hzims.operational.station.service.VideoConfigService;
import org.springframework.stereotype.Service;
/**
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/8/8 16:17
*/
@Service
public class VideoConfigServiceImpl extends ServiceImpl<VideoConfigMapper, VideoConfigEntity> implements VideoConfigService {
}

108
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalRecordController.java

@ -0,0 +1,108 @@
package com.hnac.hzims.safeproduct.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.common.utils.Condition;
import com.hnac.hzims.safeproduct.entity.RehearsalRecordEntity;
import com.hnac.hzims.safeproduct.service.IRehearsalRecordService;
import com.hnac.hzims.safeproduct.vo.RehearsalMonthVO;
import com.hnac.hzims.safeproduct.vo.RehearsalYearVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.Map;
/**
* 演练记录接口类
*
* @author liwen
* @date 2023-12-13
*/
@RestController
@AllArgsConstructor
@RequestMapping("/rehearsal")
@Api(value = "演练记录", tags = "演练记录接口")
public class RehearsalRecordController extends BladeController {
private final IRehearsalRecordService rehearsalRecordService;
@PostMapping("/save")
@ApiOperation(value = "新增")
@ApiOperationSupport(order = 1)
public R save(@Valid @RequestBody RehearsalRecordEntity rehearsalRecord) {
return R.status(rehearsalRecordService.saveRehearsal(rehearsalRecord));
}
@PostMapping("/update")
@ApiOperation(value = "修改")
@ApiOperationSupport(order = 2)
public R update(@Valid @RequestBody RehearsalRecordEntity rehearsalRecord) {
return R.status(rehearsalRecordService.updateRehearsal(rehearsalRecord));
}
@PostMapping("/remove")
@ApiOperation(value = "删除")
@ApiOperationSupport(order = 3)
public R remove(@RequestParam Long id) {
return R.status(rehearsalRecordService.removeById(id));
}
@GetMapping("/detail")
@ApiOperation(value = "详情")
@ApiOperationSupport(order = 4)
public R<RehearsalRecordEntity> detail(@RequestParam Long id) {
return R.data(rehearsalRecordService.getById(id));
}
@GetMapping("/page")
@ApiImplicitParams({
@ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string"),
@ApiImplicitParam(name = "scheduledStartTime", value = "计划开始时间", dataType = "query", paramType = "string"),
@ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string")
})
@ApiOperation(value = "分页")
@ApiOperationSupport(order = 5)
public R<IPage<RehearsalRecordEntity>> page(@ApiIgnore @RequestParam Map<String, Object> param, Query query) {
IPage<RehearsalRecordEntity> page = rehearsalRecordService.page(Condition.getPage(query),
Condition.getQueryWrapper(param, RehearsalRecordEntity.class));
return R.data(page);
}
@GetMapping("/dataByMonth")
@ApiOperation(value = "月度统计表")
@ApiOperationSupport(order = 6)
public R<IPage<RehearsalMonthVO>> dataByMonth(@RequestParam String month, Query query) {
IPage<RehearsalMonthVO> page = rehearsalRecordService.dataByMonth(month, query);
return R.data(page);
}
@GetMapping("/dataByYear")
@ApiOperation(value = "年度统计表")
@ApiOperationSupport(order = 7)
public R<IPage<RehearsalYearVO>> dataByYear(@RequestParam String year, Query query) {
IPage<RehearsalYearVO> page = rehearsalRecordService.dataByYear(year, query);
return R.data(page);
}
@GetMapping("/exportRehearsalData")
@ApiImplicitParams({
@ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string"),
@ApiImplicitParam(name = "scheduledStartTime", value = "计划开始时间", dataType = "query", paramType = "string"),
@ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string")
})
@ApiOperation(value = "演练数据导出")
@ApiOperationSupport(order = 8)
public void exportRehearsalData(@ApiIgnore @RequestParam Map<String, Object> param, HttpServletResponse response) {
rehearsalRecordService.exportRehearsalData(param, response);
}
}

43
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/RehearsalJob.java

@ -0,0 +1,43 @@
package com.hnac.hzims.safeproduct.jobs;
import com.hnac.hzims.safeproduct.entity.RehearsalRecordEntity;
import com.hnac.hzims.safeproduct.enums.RehearsalStatusEnum;
import com.hnac.hzims.safeproduct.service.IRehearsalRecordService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
/**
* 演练模块定时任务
*
* @author liwen
* @date 2023-12-15
*/
@Component
public class RehearsalJob {
@Autowired
IRehearsalRecordService rehearsalRecordService;
@XxlJob("autoChangeRehearsalStatus")
public ReturnT<String> autoChangeRehearsalStatus(String param) {
// 获取时间范围
Date current = DateUtil.now();
Date before = DateUtil.minusDays(current, 1);
String today = DateUtil.format(current, "yyyy-mm-dd hh:MM:ss");
String yesterday = DateUtil.format(before, "yyyy-mm-dd hh:MM:ss");
// 查询前一天的超时未完成演练记录
List<RehearsalRecordEntity> list = rehearsalRecordService.getWaitingRehearsalInTimeRange(yesterday, today);
list.forEach(x -> {
x.setRehearsalStatus(RehearsalStatusEnum.UNFINISHED.getValue());
});
// 将状态置为未完成
boolean flag = rehearsalRecordService.updateBatchById(list);
return flag ? ReturnT.SUCCESS : ReturnT.FAIL;
}
}

54
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalRecordMapper.java

@ -0,0 +1,54 @@
package com.hnac.hzims.safeproduct.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.safeproduct.dto.RehearsalYearDTO;
import com.hnac.hzims.safeproduct.entity.RehearsalRecordEntity;
import com.hnac.hzims.safeproduct.vo.RehearsalMonthVO;
import com.hnac.hzims.safeproduct.vo.RehearsalYearVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 演练记录Mapper类
*
* @author liwen
* @date 2023-12-13
*/
@Mapper
public interface RehearsalRecordMapper extends BaseMapper<RehearsalRecordEntity> {
/**
* 查询当月各单位的演练总数
* @param page 分页类
* @param month 月份
* @return 当月的演练总数据
*/
IPage<RehearsalMonthVO> selectByMonth(IPage<RehearsalMonthVO> page, @Param("month") String month);
/**
* 查询当月各单位已完成的演练数据
* @param page 分页类
* @param month 月份
* @return 当月的已完成数据
*/
IPage<RehearsalMonthVO> selectFinishedDataByMonth(IPage<RehearsalMonthVO> page, @Param("month") String month);
/**
* 查询当年的所有单位
* @param page 分页类
* @param year 年份
* @return 年度单位数据
*/
IPage<RehearsalYearVO> selectUnitByYear(IPage<RehearsalYearVO> page, @Param("year") String year);
/**
* 查询各单位全年已完成的演练数据
* @param unitList 单元列表
* @param year 年份
* @return 单位各月的数据列表
*/
List<RehearsalYearDTO> selectFinishedDataByUnit(@Param("unitList") List<String> unitList, @Param("year") String year);
}

65
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalRecordMapper.xml

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnac.hzims.safeproduct.mapper.RehearsalRecordMapper">
<select id="selectByMonth" resultType="com.hnac.hzims.safeproduct.vo.RehearsalMonthVO">
SELECT
unit, count(1) as scheduled_task_num
FROM
hzims_rehearsal_record
WHERE
is_deleted = 0
AND scheduled_end_time like concat('%', #{month}, '%')
GROUP BY
unit
ORDER BY
unit
</select>
<select id="selectFinishedDataByMonth" resultType="com.hnac.hzims.safeproduct.vo.RehearsalMonthVO">
SELECT
unit, count(1) as finished_task_num
FROM
hzims_rehearsal_record
WHERE
is_deleted = 0
AND scheduled_end_time like concat('%', #{month}, '%')
AND rehearsal_status = 'FINISHED'
GROUP BY
unit
ORDER BY
unit
</select>
<select id="selectUnitByYear" resultType="com.hnac.hzims.safeproduct.vo.RehearsalYearVO">
SELECT
distinct unit
FROM
hzims_rehearsal_record
WHERE
is_deleted = 0
AND actual_end_time like concat('%', #{year}, '%')
ORDER BY
unit
</select>
<select id="selectFinishedDataByUnit" resultType="com.hnac.hzims.safeproduct.dto.RehearsalYearDTO">
SELECT
unit, DATE_FORMAT(actual_end_time, '%m') as dateTime, count(1) as finished_num
FROM
hzims_rehearsal_record
WHERE
is_deleted = 0
AND actual_end_time like concat('%', #{year}, '%')
AND rehearsal_status = 'FINISHED'
AND unit in
<foreach collection="unitList" item="unit" open="(" close=")" separator=",">
#{unit}
</foreach>
GROUP BY
unit, DATE_FORMAT(actual_end_time, '%m')
ORDER BY
unit
</select>
</mapper>

66
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IRehearsalRecordService.java

@ -0,0 +1,66 @@
package com.hnac.hzims.safeproduct.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.safeproduct.entity.RehearsalRecordEntity;
import com.hnac.hzims.safeproduct.vo.RehearsalMonthVO;
import com.hnac.hzims.safeproduct.vo.RehearsalYearVO;
import org.springblade.core.mp.support.Query;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
* 演练记录服务类
*
* @author liwen
* @date 2023-12-13
*/
public interface IRehearsalRecordService extends IService<RehearsalRecordEntity> {
/**
* 演练月度数据
* @param month 月份
* @param query 分页类
* @return 月度统计分页
*/
IPage<RehearsalMonthVO> dataByMonth(String month, Query query);
/**
* 演练年度数据
* @param year 年份
* @param query 分页类
* @return 年度统计分页
*/
IPage<RehearsalYearVO> dataByYear(String year, Query query);
/**
* 新增演练
* @param rehearsalRecord 演练记录DTO类
* @return 新增是否成功
*/
boolean saveRehearsal(RehearsalRecordEntity rehearsalRecord);
/**
* 修改演练
* @param rehearsalRecord 演练记录DTO类
* @return 更新是否成功
*/
boolean updateRehearsal(RehearsalRecordEntity rehearsalRecord);
/**
* 演练数据导出
* @param param 入参
* @param response 响应类
*/
void exportRehearsalData(Map<String, Object> param, HttpServletResponse response);
/**
* 查询时间范围内未开始的演练数据
* @param startTime 开始时间
* @param endTime 结束时间
* @return 演练数据
*/
List<RehearsalRecordEntity> getWaitingRehearsalInTimeRange(String startTime, String endTime);
}

308
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalRecordServiceImpl.java

@ -0,0 +1,308 @@
package com.hnac.hzims.safeproduct.service.impl;
import cn.hutool.core.date.DatePattern;
import com.alibaba.druid.support.json.JSONUtils;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.converters.longconverter.LongStringConverter;
import com.alibaba.excel.util.CollectionUtils;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzims.safeproduct.dto.RehearsalYearDTO;
import com.hnac.hzims.safeproduct.entity.RehearsalRecordEntity;
import com.hnac.hzims.safeproduct.enums.RehearsalStatusEnum;
import com.hnac.hzims.safeproduct.mapper.RehearsalRecordMapper;
import com.hnac.hzims.safeproduct.service.IRehearsalRecordService;
import com.hnac.hzims.safeproduct.vo.RehearsalMonthVO;
import com.hnac.hzims.safeproduct.vo.RehearsalYearVO;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.support.Query;
import org.springframework.stereotype.Service;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.URLEncoder;
import java.util.*;
import java.util.stream.Collectors;
/**
* 演练记录服务实现类
*
* @author liwen
* @date 2023-12-13
*/
@Service
@Slf4j
public class RehearsalRecordServiceImpl extends ServiceImpl<RehearsalRecordMapper, RehearsalRecordEntity> implements IRehearsalRecordService {
/**
* 演练月度数据
*/
@Override
public IPage<RehearsalMonthVO> dataByMonth(String month, Query query) {
// 查询当月各单位的演练总数
IPage<RehearsalMonthVO> page = new Page<>(query.getCurrent(), query.getSize());
IPage<RehearsalMonthVO> unitPage = baseMapper.selectByMonth(page, month);
List<RehearsalMonthVO> unitList = unitPage.getRecords();
// 查询当月各单位已完成的演练数据
IPage<RehearsalMonthVO> page1 = new Page<>(query.getCurrent(), query.getSize());
IPage<RehearsalMonthVO> finishedPage = baseMapper.selectFinishedDataByMonth(page1, month);
List<RehearsalMonthVO> finishedList = finishedPage.getRecords();
// 处理统计数据
for (RehearsalMonthVO unit : unitList) {
Long taskNum = unit.getScheduledTaskNum();
Optional<RehearsalMonthVO> finishedRehearsal = finishedList.stream().filter(x -> x.getUnit().equals(unit.getUnit())).findFirst();
Long finishedTaskNum = finishedRehearsal.isPresent() ? finishedRehearsal.get().getFinishedTaskNum() : 0L;
unit.setFinishedTaskNum(finishedTaskNum);
unit.setUnfinishedTaskNum(taskNum - finishedTaskNum);
BigDecimal taskDecimal = new BigDecimal(taskNum);
BigDecimal finishedDecimal = new BigDecimal(finishedTaskNum);
unit.setTaskCompletionRate(finishedDecimal.divide(taskDecimal, RoundingMode.HALF_UP).multiply(new BigDecimal("100"))
.setScale(2, RoundingMode.HALF_UP));
}
unitPage.setRecords(unitList);
return unitPage;
}
/**
* 演练年度数据
*/
@Override
public IPage<RehearsalYearVO> dataByYear(String year, Query query) {
IPage<RehearsalYearVO> page = new Page<>(query.getCurrent(), query.getSize());
// 查询当年的所有单位
IPage<RehearsalYearVO> unitPage = baseMapper.selectUnitByYear(page, year);
List<RehearsalYearVO> records = unitPage.getRecords();
List<String> unitList = records.stream().map(RehearsalYearVO::getUnit).collect(Collectors.toList());
// 查询各单位全年已完成的演练数据
List<RehearsalYearDTO> unitMonthDataList = baseMapper.selectFinishedDataByUnit(unitList, year);
// 将各单位每个月的演练数据写入统计列表
unitMonthDataList.forEach(data -> {
RehearsalYearVO rehearsalYearVO = records.stream().filter(x -> x.getUnit().equals(data.getUnit()))
.collect(Collectors.toList()).get(0);
// 根据月份匹配写入对应字段
switch (data.getDateTime()) {
case "01":
rehearsalYearVO.setJanuaryNum(data.getFinishedNum());
break;
case "02":
rehearsalYearVO.setFebruaryNum(data.getFinishedNum());
break;
case "03":
rehearsalYearVO.setMarchNum(data.getFinishedNum());
break;
case "04":
rehearsalYearVO.setAprilNum(data.getFinishedNum());
break;
case "05":
rehearsalYearVO.setMayNum(data.getFinishedNum());
break;
case "06":
rehearsalYearVO.setJuneNum(data.getFinishedNum());
break;
case "07":
rehearsalYearVO.setJulyNum(data.getFinishedNum());
break;
case "08":
rehearsalYearVO.setAugustNum(data.getFinishedNum());
break;
case "09":
rehearsalYearVO.setSeptemberNum(data.getFinishedNum());
break;
case "10":
rehearsalYearVO.setOctoberNum(data.getFinishedNum());
break;
case "11":
rehearsalYearVO.setNovemberNum(data.getFinishedNum());
break;
case "12":
rehearsalYearVO.setDecemberNum(data.getFinishedNum());
}
});
unitPage.setRecords(records);
return unitPage;
}
/**
* 新增演练
*/
@Override
public boolean saveRehearsal(RehearsalRecordEntity rehearsalRecord) {
// 获取当月时间(yyyymm)
String currentMonth = DatePattern.SIMPLE_MONTH_FORMAT.format(new Date());
// 查询是否存在同月编号
String lastCode = getLastCode(currentMonth);
// 若不存在,新增编号
String code;
if (StringUtils.isNull(lastCode)) {
code = "YLJL" + currentMonth + "001";
} else { // 若存在,编号递增
String oldNum = lastCode.substring(lastCode.length() - 3);
int value = Integer.parseInt(oldNum) + 1;
// 根据数位拼接编号
if (value < 10) {
code = "YLJL" + currentMonth + "00" + value;
} else if (value < 100) {
code = "YLJL" + currentMonth + "0" + value;
} else {
code = "YLJL" + currentMonth + value;
}
}
rehearsalRecord.setCode(code);
// 参演人数
String peopleName = rehearsalRecord.getPeopleName();
if (StringUtils.isNotEmpty(peopleName)) {
int peopleNum = peopleName.split(",").length;
rehearsalRecord.setPeopleNum(peopleNum);
}
return this.save(rehearsalRecord);
}
/**
* 修改演练
*/
@Override
public boolean updateRehearsal(RehearsalRecordEntity rehearsalRecord) {
// 参演人数
String peopleName = rehearsalRecord.getPeopleName();
if (StringUtils.isNotEmpty(peopleName)) {
int peopleNum = peopleName.split(",").length;
rehearsalRecord.setPeopleNum(peopleNum);
}
return this.updateById(rehearsalRecord);
}
/**
* 演练数据导出
*/
@Override
public void exportRehearsalData(Map<String, Object> param, HttpServletResponse response) {
ServletOutputStream outputStream = null;
try {
outputStream = response.getOutputStream();
String unit = String.valueOf(param.get("unit"));
String startTime = String.valueOf(param.get("scheduledStartTime"));
String endTime = String.valueOf(param.get("scheduledEndTime"));
List<RehearsalRecordEntity> rehearsalRecordList = getRehearsalByUnitAndDate(unit, startTime, endTime);
// 设置响应头
// URLEncoder.encode防止中文乱码
String fileName = URLEncoder.encode("演练记录表", "UTF-8");
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("UTF-8");
// ExcelWriter初始化
ExcelWriter excelWriter = EasyExcel
.write(response.getOutputStream())
.autoCloseStream(Boolean.TRUE)
.registerConverter(new LongStringConverter())
.registerWriteHandler(new SimpleColumnWidthStyleStrategy(25))
.build();
Set<String> excludeColumnFiledNames = new HashSet<>();
excludeColumnFiledNames.add("peopleName");
excludeColumnFiledNames.add("commander");
excludeColumnFiledNames.add("record");
excludeColumnFiledNames.add("comment");
excludeColumnFiledNames.add("rehearsalMethod");
excludeColumnFiledNames.add("imgPath");
excludeColumnFiledNames.add("filePath");
excludeColumnFiledNames.add("id");
excludeColumnFiledNames.add("createUser");
excludeColumnFiledNames.add("createDept");
excludeColumnFiledNames.add("createTime");
excludeColumnFiledNames.add("updateUser");
excludeColumnFiledNames.add("updateTime");
excludeColumnFiledNames.add("status");
excludeColumnFiledNames.add("isDeleted");
WriteSheet writeSheet = EasyExcel.writerSheet(1, "演练记录表").head(RehearsalRecordEntity.class)
.excludeColumnFiledNames(excludeColumnFiledNames)
.build();
excelWriter.write(rehearsalRecordList, writeSheet);
excelWriter.finish();
} catch (Exception e) {
// 重置response
response.reset();
response.setContentType("application/json");
response.setCharacterEncoding("utf-8");
throw new ServiceException("演练数据导出异常: " + e.getMessage());
} finally {
if (outputStream != null) {
try {
outputStream.close();
} catch (IOException e) {
log.error("演练导出响应头输出流关闭异常: " + e.getMessage());
}
}
}
}
/**
* 查询是否存在同月编号
* @param currentMonth 当月
* @return 存在则返回上一编号否则返回null
*/
private String getLastCode(String currentMonth) {
String month = currentMonth.substring(currentMonth.length() - 2);
List<RehearsalRecordEntity> list = getRehearsalByMonth(month);
if (CollectionUtils.isEmpty(list)) {
return null;
}
return list.get(0).getCode();
}
/**
* 查询当月演练记录
* @param month 当月
* @return 当月演练数据表
*/
public List<RehearsalRecordEntity> getRehearsalByMonth(String month) {
QueryWrapper<RehearsalRecordEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().like(RehearsalRecordEntity::getCreateTime, month)
.orderByDesc(RehearsalRecordEntity::getCode);
return this.list(queryWrapper);
}
/**
* 根据单位和计划时间查询演练记录
* @param unit 单位
* @param startTime 计划开始时间
* @param endTime 计划结束时间
* @return 演练记录列表
*/
public List<RehearsalRecordEntity> getRehearsalByUnitAndDate(String unit, String startTime, String endTime) {
LambdaQueryWrapper<RehearsalRecordEntity> queryWrapper = new LambdaQueryWrapper<>();
if (!unit.equals("null")) {
queryWrapper.eq(RehearsalRecordEntity::getUnit, unit);
}
if (!startTime.equals("null")) {
queryWrapper.ge(RehearsalRecordEntity::getScheduledStartTime, startTime);
}
if (!endTime.equals("null")) {
queryWrapper.le(RehearsalRecordEntity::getScheduledEndTime, endTime);
}
queryWrapper.orderByDesc(RehearsalRecordEntity::getScheduledEndTime);
return this.list(queryWrapper);
}
/**
* 查询时间范围内未开始的演练数据
*/
@Override
public List<RehearsalRecordEntity> getWaitingRehearsalInTimeRange(String startTime, String endTime) {
QueryWrapper<RehearsalRecordEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(RehearsalRecordEntity::getRehearsalStatus, RehearsalStatusEnum.WAITING.getValue())
.ge(RehearsalRecordEntity::getScheduledEndTime, startTime)
.lt(RehearsalRecordEntity::getScheduledEndTime, endTime);
return this.list(queryWrapper);
}
}

28
hzims-service/safeproduct/src/main/resources/db/1.0.1.sql

@ -10,3 +10,31 @@ create table document_management
is_deleted tinyint default 0 comment '逻辑删除' is_deleted tinyint default 0 comment '逻辑删除'
) comment '文档管理'; ) comment '文档管理';
CREATE TABLE `hzims`.`hzims_rehearsal_record` (
`id` bigint(20) NOT NULL COMMENT '主键id',
`code` varchar(50) NOT NULL COMMENT '编号',
`unit` varchar(50) NOT NULL COMMENT '单位',
`subject` varchar(50) NOT NULL COMMENT '演练科目',
`scheduled_start_time` datetime NOT NULL COMMENT '演练计划开始时间',
`scheduled_end_time` datetime NOT NULL COMMENT '演练计划结束时间',
`location` varchar(255) NOT NULL COMMENT '演练地点',
`people_num` int(10) NOT NULL DEFAULT '0' COMMENT '参演人数',
`commander` varchar(10) NOT NULL COMMENT '总指挥',
`actual_start_time` datetime DEFAULT NULL COMMENT '演练实际开始时间',
`actual_end_time` datetime DEFAULT NULL COMMENT '演练实际结束时间',
`record` varchar(250) DEFAULT '' COMMENT '演练记录',
`comment` varchar(250) DEFAULT '' DEFAULT '' COMMENT '演练评价',
`rehearsal_method` varchar(20) DEFAULT '' COMMENT '演练方式',
`rehearsal_status` varchar(20) NOT NULL DEFAULT 'WAITING' COMMENT '演练状态',
`img_path` varchar(1000) NOT NULL DEFAULT '' COMMENT '演练图片',
`file_path` varchar(1000) NOT NULL DEFAULT '' COMMENT '演练附件',
`create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人',
`create_dept` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建部门',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_user` bigint(20) DEFAULT '-1' COMMENT '更新人',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间',
`status` int(2) NOT NULL DEFAULT '1' COMMENT '状态',
`is_deleted` int(2) NOT NULL DEFAULT '0' COMMENT '逻辑删除状态:0-未删除,1-删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=INNODB CHARACTER SET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='演练记录表' ROW_FORMAT=Dynamic;
Loading…
Cancel
Save