haungxing
11 months ago
35 changed files with 1440 additions and 17 deletions
@ -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); |
||||
} |
||||
|
||||
} |
||||
} |
@ -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; |
||||
} |
@ -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; |
||||
} |
@ -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; |
||||
} |
@ -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; |
||||
} |
@ -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; |
||||
} |
@ -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; |
||||
} |
||||
} |
@ -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; |
||||
} |
||||
|
||||
} |
@ -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; |
||||
} |
@ -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; |
||||
} |
@ -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))); |
||||
} |
||||
} |
@ -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); |
||||
} |
@ -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(); |
||||
} |
||||
} |
@ -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> { |
||||
|
||||
} |
@ -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> |
@ -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> { |
||||
} |
@ -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 { |
||||
} |
@ -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); |
||||
} |
||||
} |
@ -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; |
||||
} |
||||
} |
@ -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); |
||||
} |
@ -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> |
@ -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); |
||||
} |
@ -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); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue