From ba9d530715bbc3b702c641be8278a2d2385c64d9 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Fri, 9 Aug 2024 17:24:55 +0800 Subject: [PATCH] =?UTF-8?q?#=E5=88=86=E6=9E=90=E6=95=B0=E6=8D=AE=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../history/entity/HistoryTemplateEntity.java | 53 ++++++++ .../hnac/hzims/history/vo/HistoryDataParamVo.java | 53 ++++++++ .../hzims/history/vo/HistoryTemplateParamVo.java | 17 +++ .../com/hnac/hzims/history/vo/MonitorPointVo.java | 17 +++ .../hnac/hzims/spare/aspect/LimitRemindAspect.java | 1 - .../controller/DeviceHistoryController.java | 54 ++++++++ .../controller/HistoryTemplateController.java | 43 ++++++ .../history/mapper/HistoryTemplateMapper.java | 11 ++ .../hzims/history/mapper/HistoryTemplateMapper.xml | 5 + .../history/service/IHistoryDeviceService.java | 20 +++ .../history/service/IHistoryTemplateService.java | 15 +++ .../service/impl/HistoryDeviceServiceImpl.java | 147 +++++++++++++++++++++ .../service/impl/HistoryTemplateServiceImpl.java | 39 ++++++ .../home/impl/ObtainGenerationServiceImpl.java | 2 +- .../operation/home/impl/RealTargetServiceImpl.java | 2 +- .../operation/home/impl/ShowServiceImpl.java | 2 +- .../operation/monitor/impl/MonitorServiceImpl.java | 19 ++- .../operation/report/impl/ReportServiceImpl.java | 2 +- .../service/impl/InspectOfflineServiceImpl.java | 21 ++- .../main/service/impl/HydropowerServiceImpl.java | 2 +- .../main/service/impl/WindHomeServiceImpl.java | 2 +- .../report/service/impl/RunMonthServiceImpl.java | 2 +- .../safeproduct/src/main/resources/dict/dict.sql | 12 +- 23 files changed, 527 insertions(+), 14 deletions(-) create mode 100644 hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/history/entity/HistoryTemplateEntity.java create mode 100644 hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/history/vo/HistoryDataParamVo.java create mode 100644 hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/history/vo/HistoryTemplateParamVo.java create mode 100644 hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/history/vo/MonitorPointVo.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/history/controller/DeviceHistoryController.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/history/controller/HistoryTemplateController.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/history/mapper/HistoryTemplateMapper.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/history/mapper/HistoryTemplateMapper.xml create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/IHistoryDeviceService.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/IHistoryTemplateService.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/impl/HistoryDeviceServiceImpl.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/impl/HistoryTemplateServiceImpl.java diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/history/entity/HistoryTemplateEntity.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/history/entity/HistoryTemplateEntity.java new file mode 100644 index 0000000..7f59f53 --- /dev/null +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/history/entity/HistoryTemplateEntity.java @@ -0,0 +1,53 @@ +package com.hnac.hzims.history.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.tenant.mp.TenantEntity; + +/** + * 设备树绑定巡检实体类 + * @author tanghaihao + * @date 2023年06月14日 16:46 + */ +@Data +@TableName("hzims_device_history_template") +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "设备历史数据模板") +public class HistoryTemplateEntity extends TenantEntity { + + @ApiModelProperty(value = "模板名称") + private Long templateName; + + @ApiModelProperty(value = "站点编码") + private String stationId; + + @ApiModelProperty(value = "站点名称") + private String stationName; + + @ApiModelProperty(value = "属性1") + private String realId1; + + @ApiModelProperty(value = "属性1名称") + private String realName1; + + @ApiModelProperty(value = "属性2") + private String realId2; + + @ApiModelProperty(value = "属性2名称") + private String realName2; + + @ApiModelProperty(value = "属性3") + private String realId3; + + @ApiModelProperty(value = "属性3名称") + private String realName3; + + @ApiModelProperty(value = "属性4") + private String realId4; + + @ApiModelProperty(value = "属性4名称") + private String realName4; +} \ No newline at end of file diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/history/vo/HistoryDataParamVo.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/history/vo/HistoryDataParamVo.java new file mode 100644 index 0000000..b54cbba --- /dev/null +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/history/vo/HistoryDataParamVo.java @@ -0,0 +1,53 @@ +package com.hnac.hzims.history.vo; + + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springblade.core.tool.utils.DateUtil; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDateTime; + +/** + * @author ysj + */ +@Data +@ApiModel(value = "设备历史查询参数") +public class HistoryDataParamVo { + + @ApiModelProperty(value = "第一个点位") + private String firstAttrId; + + @ApiModelProperty(value = "第二个点位") + private String secondAttrId; + + @ApiModelProperty(value = "第三个点位") + private String thirdlyAttrId; + + @ApiModelProperty(value = "第四个点位") + private String fourthAttrId; + + @ApiModelProperty(value = "第五个点位") + private String fifthAttrId; + + @ApiModelProperty(value = "开始时间") + @DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME) + @JsonFormat(pattern = DateUtil.PATTERN_DATETIME) + private LocalDateTime startTime; + + @ApiModelProperty(value = "结束时间") + @DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME) + @JsonFormat(pattern = DateUtil.PATTERN_DATETIME) + private LocalDateTime endTime; + + @ApiModelProperty(value = "是否分页") + private Boolean isPage; + + @ApiModelProperty(value = "页码") + private Integer current; + + @ApiModelProperty(value = "页码条数") + private Integer pageSize; +} \ No newline at end of file diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/history/vo/HistoryTemplateParamVo.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/history/vo/HistoryTemplateParamVo.java new file mode 100644 index 0000000..6749714 --- /dev/null +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/history/vo/HistoryTemplateParamVo.java @@ -0,0 +1,17 @@ +package com.hnac.hzims.history.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + */ +@Data +public class HistoryTemplateParamVo { + + @ApiModelProperty(value = "站点Id") + private String stationId; + + @ApiModelProperty(value = "用户Id") + private Long createUser; +} \ No newline at end of file diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/history/vo/MonitorPointVo.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/history/vo/MonitorPointVo.java new file mode 100644 index 0000000..43a9e7a --- /dev/null +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/history/vo/MonitorPointVo.java @@ -0,0 +1,17 @@ +package com.hnac.hzims.history.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + */ +@Data +public class MonitorPointVo { + + @ApiModelProperty(value = "站点Id") + private String monitorId; + + @ApiModelProperty(value = "用户Id") + private String monitorName; +} \ No newline at end of file diff --git a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/aspect/LimitRemindAspect.java b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/aspect/LimitRemindAspect.java index 30d32e5..61e2895 100644 --- a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/aspect/LimitRemindAspect.java +++ b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/aspect/LimitRemindAspect.java @@ -94,7 +94,6 @@ public class LimitRemindAspect { * @param spRecordEntityList 出入库备品备件列表 * @param warehouseId 仓库ID */ -// final static ExecutorService executorService = new ThreadPoolExecutor(5, 5, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); public void pushWarehouseThread(Long warehouseId, List spRecordEntityList) { try { Runnable runnable = new Runnable() { diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/history/controller/DeviceHistoryController.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/history/controller/DeviceHistoryController.java new file mode 100644 index 0000000..9d50bee --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/history/controller/DeviceHistoryController.java @@ -0,0 +1,54 @@ +package com.hnac.hzims.history.controller; + +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.history.service.IHistoryDeviceService; +import com.hnac.hzims.history.vo.HistoryDataParamVo; +import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; +import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceVO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + +/** + * @author ysj + */ +@RestController +@AllArgsConstructor +@RequestMapping("/history") +@Api(value = "设备历史数据", tags = "设备历史数据") +public class DeviceHistoryController extends BladeController { + + private final IHistoryDeviceService service; + + + @GetMapping ("/device") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "查询项目设备列表", notes = "传入TrainEntity") + public R> device(@RequestParam(value="projectId") String projectId) { + return R.data(service.device(projectId)); + } + + + @GetMapping ("/monitor_point") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "设备监测点查询", notes = "传入TrainEntity") + public R> monitor_point(@RequestParam(value="projectId",required = false) String projectId, + @RequestParam(value="deviceCode",required = false) String deviceCode, + @RequestParam(value="deviceName",required = false) String deviceName, + @RequestParam(value="attrName",required = false) String attrName) { + return R.data(service.monitor_point(projectId,deviceCode,deviceName,attrName)); + } + + @PostMapping("/history_curve") + @ApiOperationSupport(order = 5) + @ApiOperation(value = "设备历史数据曲线图", notes = "获取设备历史数据曲线图") + public R> historyCurve(@RequestBody HistoryDataParamVo param) { + return R.data(service.historyCurve(param)); + } +} \ No newline at end of file diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/history/controller/HistoryTemplateController.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/history/controller/HistoryTemplateController.java new file mode 100644 index 0000000..bda3317 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/history/controller/HistoryTemplateController.java @@ -0,0 +1,43 @@ +package com.hnac.hzims.history.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.history.entity.HistoryTemplateEntity; +import com.hnac.hzims.history.service.IHistoryTemplateService; +import com.hnac.hzims.history.vo.HistoryTemplateParamVo; +import com.hnac.hzims.safeproduct.train.entity.InstitutionalEntity; +import com.hnac.hzims.safeproduct.train.vo.InstitutionalParamVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.*; + +/** + * @author ysj + */ +@RestController +@AllArgsConstructor +@RequestMapping("/history/template") +@Api(value = "设备历史数据模板", tags = "设备历史数据模板") +public class HistoryTemplateController extends BladeController { + + private final IHistoryTemplateService service; + + @PostMapping("/save") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "新增历史数据模板", notes = "传入TrainEntity") + public R save(@RequestBody HistoryTemplateEntity entity) { + return R.status(service.save(entity)); + } + + @GetMapping("/pages") + @ApiOperationSupport(order = 5) + @ApiOperation(value = "分页历史数据模板", notes = "查询条件:entity") + public R> pageCondition(HistoryTemplateParamVo params, Query query) { + return R.data(service.pageCondition(params, Condition.getPage(query))); + } +} \ No newline at end of file diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/history/mapper/HistoryTemplateMapper.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/history/mapper/HistoryTemplateMapper.java new file mode 100644 index 0000000..83d1c02 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/history/mapper/HistoryTemplateMapper.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.history.mapper; + +import com.hnac.hzims.history.entity.HistoryTemplateEntity; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +/** + * @author ysj + */ +public interface HistoryTemplateMapper extends UserDataScopeBaseMapper { + +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/history/mapper/HistoryTemplateMapper.xml b/hzims-service/equipment/src/main/java/com/hnac/hzims/history/mapper/HistoryTemplateMapper.xml new file mode 100644 index 0000000..5667748 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/history/mapper/HistoryTemplateMapper.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/IHistoryDeviceService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/IHistoryDeviceService.java new file mode 100644 index 0000000..a4aaf67 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/IHistoryDeviceService.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.history.service; + +import com.hnac.hzims.history.vo.HistoryDataParamVo; +import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; +import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceVO; + +import java.util.List; +import java.util.Map; + +/** + * @author ysj + */ +public interface IHistoryDeviceService { + + List device(String projectId); + + List monitor_point(String projectId,String deviceCode,String deviceName, String attrName); + + Map historyCurve(HistoryDataParamVo param); +} \ No newline at end of file diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/IHistoryTemplateService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/IHistoryTemplateService.java new file mode 100644 index 0000000..1fa0427 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/IHistoryTemplateService.java @@ -0,0 +1,15 @@ +package com.hnac.hzims.history.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.hzims.history.entity.HistoryTemplateEntity; +import com.hnac.hzims.history.vo.HistoryTemplateParamVo; + +/** + * @author ysj + */ +public interface IHistoryTemplateService extends IService { + + + IPage pageCondition(HistoryTemplateParamVo params, IPage page); +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/impl/HistoryDeviceServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/impl/HistoryDeviceServiceImpl.java new file mode 100644 index 0000000..ce2ae6c --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/impl/HistoryDeviceServiceImpl.java @@ -0,0 +1,147 @@ +package com.hnac.hzims.history.service.impl; + +import com.hnac.hzims.history.service.IHistoryDeviceService; +import com.hnac.hzims.history.vo.HistoryDataParamVo; +import com.hnac.hzinfo.sdk.core.response.Result; +import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient; +import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; +import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; +import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceVO; +import lombok.AllArgsConstructor; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.StringUtil; +import org.springframework.stereotype.Service; + +import java.time.LocalDateTime; +import java.time.ZoneOffset; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author ysj + */ +@Service +@AllArgsConstructor +public class HistoryDeviceServiceImpl implements IHistoryDeviceService { + + + private final DeviceClient deviceClient; + + private final DeviceDataClient deviceDataClient; + + /** + * 项目设备列表 + * @param projectId + * @return + */ + @Override + public List device(String projectId) { + R> result = deviceClient.getOnlineDeviceInstanceSearchName(projectId,""); + if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ + return new ArrayList<>(); + } + return result.getData(); + } + + /** + * 设备点位列表 + * @param deviceCode + * @param attrName + * @return + */ + @Override + public List monitor_point(String projectId,String deviceCode,String deviceName, String attrName) { + List result = new ArrayList<>(); + // 查询所有 + if(StringUtil.isEmpty(deviceCode)){ + R> instances = deviceClient.getOnlineDeviceInstanceSearchName(projectId,""); + if(!instances.isSuccess() || CollectionUtil.isEmpty(instances.getData())){ + return result; + } + instances.getData().stream().sorted(Comparator.comparing(DeviceInstanceVO::getName)).forEach(instance->{ + Result> attrs = deviceClient.getDeviceAttrByName(instance.getCode(),""); + if(!attrs.isSuccess() || CollectionUtil.isEmpty(attrs.getData())){ + return; + } + result.addAll(attrs.getData().stream().filter(o-> StringUtil.isNotBlank(o.getFacDeviceAttrId())).peek(attr->{ + attr.setName(instance.getName() + "-" + attr.getName()); + }).collect(Collectors.toList())); + }); + } + // 根据设备查询 + Result> attrs = deviceClient.getDeviceAttrByName(deviceCode,attrName); + if(!attrs.isSuccess() || CollectionUtil.isEmpty(attrs.getData())){ + return result; + } + return attrs.getData().stream().filter(o-> StringUtil.isNotBlank(o.getFacDeviceAttrId())).peek(attr->{ + attr.setName(deviceName + "-" + attr.getName()); + }).collect(Collectors.toList()); + } + + /** + * 设备历史数据曲线图 + * @param param + * @return + */ + @Override + public Map historyCurve(HistoryDataParamVo param) { + // 计算查询数据维度 : 0-10秒 、 1-1分钟 、2-5分钟 ..... + Integer intervalType = this.computeInterval(param.getStartTime(),param.getEndTime()); + // 查询数据 + Result> result = deviceDataClient.getLineDataByRealId( + param.getFirstAttrId(), + param.getSecondAttrId(), + param.getThirdlyAttrId(), + param.getFourthAttrId(), + param.getFifthAttrId(), + param.getStartTime(), + param.getEndTime(), + // 默认查询设备 : 0-厂组点, 1-设备 + 1, + intervalType, + param.getIsPage(), + param.getCurrent(), + param.getPageSize() + ); + if(!result.isSuccess()){ + throw new ServiceException(result.getMsg()); + } + if(CollectionUtil.isEmpty(result.getData())){ + return new HashMap<>(); + } + return result.getData(); + } + + + /** + * 计算查询数据维度 + * @param startTime + * @param endTime + * @return + */ + private Integer computeInterval(LocalDateTime startTime, LocalDateTime endTime) { + long seconds = endTime.toEpochSecond(ZoneOffset.UTC) - startTime.toEpochSecond(ZoneOffset.UTC); + // 小于一天 : 10秒一条数据 + if(seconds < 60 * 60 * 24L){ + return 0; + // 小于5天 : 1分钟一条数据 + }else if(seconds < 60 * 60 * 24 * 5L){ + return 1; + // 小于15天 : 5分钟一条数据 + }else if(seconds < 60 * 60 * 24 * 15L){ + return 2; + // 小于30天 : 10分钟一条数据 + }else if(seconds < 60 * 60 * 24 * 30L){ + return 3; + // 小于90天 : 30分钟一条数据 + }else if(seconds < 60 * 60 * 24 * 90L){ + return 4; + // 小于180天 : 60分钟一条数据 + }else if(seconds < 60 * 60 * 24 * 180L){ + return 5; + } + return 5; + } +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/impl/HistoryTemplateServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/impl/HistoryTemplateServiceImpl.java new file mode 100644 index 0000000..6a0244e --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/impl/HistoryTemplateServiceImpl.java @@ -0,0 +1,39 @@ +package com.hnac.hzims.history.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.hzims.history.entity.HistoryTemplateEntity; +import com.hnac.hzims.history.mapper.HistoryTemplateMapper; +import com.hnac.hzims.history.service.IHistoryTemplateService; +import com.hnac.hzims.history.vo.HistoryTemplateParamVo; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springblade.core.tool.utils.StringUtil; +import org.springframework.stereotype.Service; + +/** + * @author ysj + */ +@Service +public class HistoryTemplateServiceImpl extends ServiceImpl implements IHistoryTemplateService { + + /** + * 分页历史数据模板 + * @param params + * @param page + * @return + */ + @Override + public IPage pageCondition(HistoryTemplateParamVo params, IPage page) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); + wrapper.orderByDesc(HistoryTemplateEntity::getCreateTime); + if(StringUtil.isNotBlank(params.getStationId())){ + wrapper.eq(HistoryTemplateEntity::getStationId,params.getStationId()); + } + if(ObjectUtil.isNotEmpty(params.getCreateUser())){ + wrapper.eq(HistoryTemplateEntity::getCreateUser,params.getCreateUser()); + } + + return super.page(page,wrapper); + } +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ObtainGenerationServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ObtainGenerationServiceImpl.java index de2d8f6..2403f12 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ObtainGenerationServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ObtainGenerationServiceImpl.java @@ -62,7 +62,7 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService { private final static String recent_year_power_data = "hzims:operation:key:power:data"; - private static final ExecutorService pool = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("obtain-generation-pool-%d").build() , new ThreadPoolExecutor.CallerRunsPolicy()); + private static final ExecutorService pool = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(256), new ThreadFactoryBuilder().setNameFormat("obtain-generation-pool-%d").build() , new ThreadPoolExecutor.CallerRunsPolicy()); /** diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java index b6db260..53e1ecc 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java @@ -132,7 +132,7 @@ public class RealTargetServiceImpl implements RealTargetService { private final static String load_photovoltaic_target_key = "hzims:operation:photovoltaic:target:key"; // 创建线程池 - private static final ExecutorService pool = new ThreadPoolExecutor(20, 20, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("load-power-data-pool-%d").build() , new ThreadPoolExecutor.CallerRunsPolicy()); + private static final ExecutorService pool = new ThreadPoolExecutor(20, 20, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(256), new ThreadFactoryBuilder().setNameFormat("load-power-data-pool-%d").build() , new ThreadPoolExecutor.CallerRunsPolicy()); @Override public void loadEmInfo(String param) { diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ShowServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ShowServiceImpl.java index e48a1a7..67b4407 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ShowServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ShowServiceImpl.java @@ -878,7 +878,7 @@ public class ShowServiceImpl implements ShowService { DutyTaskVo task = new DutyTaskVo(); //通过线程池异步获取月报各模块内容 主要分为五块内容 ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("duty-task-count-pool-%d").build(); - ExecutorService exe = new ThreadPoolExecutor(4, 4, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); + ExecutorService exe = new ThreadPoolExecutor(4, 4, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(256), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); //监控线程执行完后返回结果 CountDownLatch countDownLatch = new CountDownLatch(4); List list = Collections.singletonList(createDept); diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java index b76eeaa..78f3f4e 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java @@ -78,7 +78,7 @@ public class MonitorServiceImpl implements MonitorService { private final IAnalyseDataSearchClient analyseDataSearchClient; - private static final ExecutorService pool = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("load-monitoring-pool-%d").build(), new ThreadPoolExecutor.CallerRunsPolicy()); + private static final ExecutorService pool = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(256), new ThreadFactoryBuilder().setNameFormat("load-monitoring-pool-%d").build(), new ThreadPoolExecutor.CallerRunsPolicy()); @Value("${hzims.equipment.emInfo.emInfoList}") @@ -223,8 +223,13 @@ public class MonitorServiceImpl implements MonitorService { countDownLatch.countDown(); })); try { - // 等待所有线程执行完成 - countDownLatch.await(); + // 等待所有线程执行完成(至多等待三秒,超过三秒任务认为线程发生阻塞) + boolean flag = countDownLatch.await(3,TimeUnit.SECONDS); + if(!flag){ + // 清空线程任务 + pool.shutdownNow(); + log.error("实时数据调度发生阻塞 : {}" , DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME)); + } } catch (InterruptedException e) { e.printStackTrace(); Thread.currentThread().interrupt(); @@ -321,7 +326,13 @@ public class MonitorServiceImpl implements MonitorService { } // 等待所有线程执行完成 try { - countDownLatch.await(); + // 等待所有线程执行完成(至多等待二秒,超过二秒任务认为线程发生阻塞) + boolean flag = countDownLatch.await(2,TimeUnit.SECONDS); + if(!flag){ + // 清空线程任务 + pool.shutdownNow(); + log.error("集中监控数据调度发生阻塞 : {}" , DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME)); + } } catch (InterruptedException e) { e.printStackTrace(); Thread.currentThread().interrupt(); diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/impl/ReportServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/impl/ReportServiceImpl.java index 15dee24..f91da0e 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/impl/ReportServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/impl/ReportServiceImpl.java @@ -426,7 +426,7 @@ public class ReportServiceImpl implements ReportService { private void taskMonth(List areas, AreaMonthReportVo areaMonthReport, String startTime, String endTime) { //通过线程池异步获取月报各模块内容 主要分为五块内容 ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("area_month_report-pool-%d").build(); - ExecutorService exe = new ThreadPoolExecutor(4, 4, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); + ExecutorService exe = new ThreadPoolExecutor(4, 4, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(256), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); //监控线程执行完后返回结果 CountDownLatch countDownLatch = new CountDownLatch(4); // 日常维护 diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java index dc7cec6..1f01e92 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java @@ -57,6 +57,7 @@ import org.springblade.system.vo.CreateTableVO; import org.springblade.system.vo.TemplateVO; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Primary; +import org.springframework.http.MediaType; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -950,7 +951,6 @@ public class InspectOfflineServiceImpl implements IOfflineDataService { } R r; try { - r = putFile(file); if (!r.isSuccess()) { throw new RuntimeException("上传文件["+fileName+"]失败,bladex-resource报错" ); @@ -982,5 +982,24 @@ public class InspectOfflineServiceImpl implements IOfflineDataService { } return R.fail("shangc"); } + + + + // 将File 转换为 MultipartFile + public MultipartFile getMultipartFile(File file) { + FileItem item = new DiskFileItemFactory().createItem("file" + , MediaType.MULTIPART_FORM_DATA_VALUE + , true + , file.getName()); + try (InputStream input = Files.newInputStream(file.toPath()); + OutputStream os = item.getOutputStream()) { + // 流转移 + IOUtils.copy(input, os); + } catch (Exception e) { + throw new IllegalArgumentException("Invalid file: " + e, e); + } + + return new CommonsMultipartFile(item); + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java index 9a826da..e6642ea 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java @@ -1424,7 +1424,7 @@ public class HydropowerServiceImpl implements HydropowerService { List deptList = Collections.singletonList(duty.getCreateDept()); // 使用多线程处理数据 ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("duty_data-pool-%d").build(); - ExecutorService pool = new ThreadPoolExecutor(5, 5, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); + ExecutorService pool = new ThreadPoolExecutor(5, 5, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(256), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); CountDownLatch countDownLatch = new CountDownLatch(DUTY_POOL_QUANTITY); // 下一班组 pool.execute(()-> { diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WindHomeServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WindHomeServiceImpl.java index 768b730..11e4cfa 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WindHomeServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WindHomeServiceImpl.java @@ -458,7 +458,7 @@ public class WindHomeServiceImpl implements WindHomeService { // 使用多线程处理数据 ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("duty_data-pool-%d").build(); - ExecutorService pool = new ThreadPoolExecutor(4, 4, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); + ExecutorService pool = new ThreadPoolExecutor(4, 4, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(256), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); CountDownLatch countDownLatch = new CountDownLatch(4); // 缺陷 pool.execute(()-> { diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java index 00fd73f..88c4c0d 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java @@ -94,7 +94,7 @@ public class RunMonthServiceImpl extends ServiceImpl(1024), new ThreadFactoryBuilder().setNameFormat("generate-run-report-pool-%d").build() , new ThreadPoolExecutor.CallerRunsPolicy()); + private static final ExecutorService pool = new ThreadPoolExecutor(5, 5, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(256), new ThreadFactoryBuilder().setNameFormat("generate-run-report-pool-%d").build() , new ThreadPoolExecutor.CallerRunsPolicy()); /** * 查询站点月报运行数据 diff --git a/hzims-service/safeproduct/src/main/resources/dict/dict.sql b/hzims-service/safeproduct/src/main/resources/dict/dict.sql index 2830937..69e0412 100644 --- a/hzims-service/safeproduct/src/main/resources/dict/dict.sql +++ b/hzims-service/safeproduct/src/main/resources/dict/dict.sql @@ -54,4 +54,14 @@ INSERT INTO `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_ #整改状态 INSERT INTO `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) VALUES (1397731100361748201, 0, 'rectification_status', '-1', '整改状态', 1, '', 0, 0, 0, -1, 'hzims_safeproduct'); INSERT INTO `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) VALUES (1397731100361748202, 1397731100361748201, 'rectification_status', '0', '未整改', 1, '', 0, 0, 0, -1, 'hzims_safeproduct'); -INSERT INTO `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) VALUES (1397731100361748203, 1397731100361748201, 'rectification_status', '1', '已整改', 2, '', 0, 0, 0, -1, 'hzims_safeproduct'); \ No newline at end of file +INSERT INTO `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) VALUES (1397731100361748203, 1397731100361748201, 'rectification_status', '1', '已整改', 2, '', 0, 0, 0, -1, 'hzims_safeproduct'); + +#资料类型 +INSERT INTO `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) VALUES (1397731100361748301, 0, 'institutional_type', '-1', '资料类型', 1, '', 0, 0, 0, -1, 'hzims_safeproduct'); +INSERT INTO `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) VALUES (1397731100361748302, 1397731100361748301, 'institutional_type', '0', '制度', 1, '', 0, 0, 0, -1, 'hzims_safeproduct'); +INSERT INTO `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) VALUES (1397731100361748303, 1397731100361748301, 'institutional_type', '1', '资料', 2, '', 0, 0, 0, -1, 'hzims_safeproduct'); + +#文档权限范围 +INSERT INTO `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) VALUES (1397731100361748401, 0, 'file_purview', '-1', '文档权限范围', 1, '', 0, 0, 0, -1, 'hzims_safeproduct'); +INSERT INTO `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) VALUES (1397731100361748402, 1397731100361748401, 'file_purview', '0', '厂站', 1, '', 0, 0, 0, -1, 'hzims_safeproduct'); +INSERT INTO `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) VALUES (1397731100361748403, 1397731100361748401, 'file_purview', '1', '完全公开', 2, '', 0, 0, 0, -1, 'hzims_safeproduct'); \ No newline at end of file