haungxing
2 months ago
52 changed files with 1045 additions and 526 deletions
@ -0,0 +1,36 @@
|
||||
package com.hnac.hzims.electric.feign; |
||||
|
||||
import com.hnac.hzims.EquipmentConstants; |
||||
import com.hnac.hzims.electric.entity.ThreeEntity; |
||||
import com.hnac.hzims.equipment.entity.ThreeGenerationEntity; |
||||
import com.hnac.hzims.monitor.feign.IMonitorClientBack; |
||||
import org.springframework.cloud.openfeign.FeignClient; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author ysj |
||||
*/ |
||||
@FeignClient( |
||||
value = EquipmentConstants.APP_NAME, |
||||
fallback = IMonitorClientBack.class |
||||
) |
||||
public interface IThreeElectricClient { |
||||
|
||||
String API_PREFIX = "/threeElectric"; |
||||
String ELECTRICS = API_PREFIX + "/electrics"; |
||||
|
||||
/** |
||||
* 设备运行时长 |
||||
* @param stationId |
||||
* @param startTime |
||||
* @param endTime |
||||
* @return |
||||
*/ |
||||
@GetMapping(ELECTRICS) |
||||
List<ThreeEntity> electrics(@RequestParam(value = "stationId") String stationId, |
||||
@RequestParam(value = "year") String year); |
||||
|
||||
} |
@ -0,0 +1,21 @@
|
||||
package com.hnac.hzims.electric.feign; |
||||
|
||||
import com.hnac.hzims.electric.entity.ThreeEntity; |
||||
import com.hnac.hzims.equipment.entity.ThreeGenerationEntity; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author ysj |
||||
*/ |
||||
@Component |
||||
public class IThreeElectricClientBack implements IThreeElectricClient { |
||||
|
||||
|
||||
@Override |
||||
public List<ThreeEntity> electrics(String stationId, String year) { |
||||
return new ArrayList<>(); |
||||
} |
||||
} |
@ -0,0 +1,28 @@
|
||||
package com.hnac.hzims.equipment.vo; |
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
||||
import com.fasterxml.jackson.databind.ser.std.NullSerializer; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
import java.util.List; |
||||
|
||||
|
||||
/** |
||||
* @author ysj |
||||
*/ |
||||
@Data |
||||
public class StartStopGenerateVO{ |
||||
|
||||
@ApiModelProperty(value = "站点编码集合") |
||||
@JsonSerialize(nullsUsing = NullSerializer.class) |
||||
private List<String> stations; |
||||
|
||||
@ApiModelProperty(value = "开始时间") |
||||
@JsonSerialize(nullsUsing = NullSerializer.class) |
||||
private String start; |
||||
|
||||
@ApiModelProperty(value = "结束时间") |
||||
@JsonSerialize(nullsUsing = NullSerializer.class) |
||||
private String end; |
||||
} |
@ -1,4 +1,4 @@
|
||||
package com.hnac.hzims.equipment.entity; |
||||
package com.hnac.hzims.startStop.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.annotations.ApiModel; |
@ -0,0 +1,33 @@
|
||||
package com.hnac.hzims.startStop.feign; |
||||
|
||||
import com.hnac.hzims.EquipmentConstants; |
||||
import com.hnac.hzims.monitor.feign.IMonitorClientBack; |
||||
import org.springframework.cloud.openfeign.FeignClient; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
|
||||
/** |
||||
* @author ysj |
||||
*/ |
||||
@FeignClient( |
||||
value = EquipmentConstants.APP_NAME, |
||||
fallback = IMonitorClientBack.class |
||||
) |
||||
public interface IStartStopClient { |
||||
|
||||
String API_PREFIX = "/startStop"; |
||||
String DEVICE_START_STOP_DURATION = API_PREFIX + "/deviceDuration"; |
||||
|
||||
/** |
||||
* 设备运行时长 |
||||
* @param deviceCode |
||||
* @param startTime |
||||
* @param endTime |
||||
* @return |
||||
*/ |
||||
@GetMapping(DEVICE_START_STOP_DURATION) |
||||
Double deviceDuration(@RequestParam(value = "deviceCode") String deviceCode, |
||||
@RequestParam(value = "startTime") String startTime, |
||||
@RequestParam(value = "endTime") String endTime); |
||||
|
||||
} |
@ -0,0 +1,15 @@
|
||||
package com.hnac.hzims.startStop.feign; |
||||
|
||||
import org.springframework.stereotype.Component; |
||||
|
||||
/** |
||||
* @author ysj |
||||
*/ |
||||
@Component |
||||
public class IStartStopClientBack implements IStartStopClient { |
||||
|
||||
@Override |
||||
public Double deviceDuration(String deviceCode, String startTime, String endTime) { |
||||
return 0.0; |
||||
} |
||||
} |
@ -0,0 +1,30 @@
|
||||
package com.hnac.hzims.electric.feign; |
||||
|
||||
import com.hnac.hzims.electric.entity.ThreeEntity; |
||||
import com.hnac.hzims.electric.service.ThreeService; |
||||
import com.hnac.hzims.equipment.entity.ThreeGenerationEntity; |
||||
import com.hnac.hzims.startStop.feign.IStartStopClient; |
||||
import com.hnac.hzims.startStop.service.IStartStopDurationService; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author ysj |
||||
*/ |
||||
@RestController |
||||
@AllArgsConstructor |
||||
public class ThreeElectricClient implements IThreeElectricClient { |
||||
|
||||
|
||||
private final ThreeService service; |
||||
|
||||
|
||||
@Override |
||||
@GetMapping(ELECTRICS) |
||||
public List<ThreeEntity> electrics(String stationId, String year) { |
||||
return service.electrics(stationId,year); |
||||
} |
||||
} |
@ -1,11 +1,15 @@
|
||||
package com.hnac.hzims.electric.service; |
||||
|
||||
import com.hnac.hzims.electric.entity.ThreeEntity; |
||||
import com.hnac.hzims.equipment.entity.ThreeGenerationEntity; |
||||
import org.springblade.core.mp.base.BaseService; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author ysj |
||||
*/ |
||||
public interface ThreeService extends BaseService<ThreeEntity> { |
||||
|
||||
List<ThreeEntity> electrics(String stationId, String year); |
||||
} |
@ -0,0 +1,24 @@
|
||||
package com.hnac.hzims.startStop.feign; |
||||
|
||||
import com.hnac.hzims.startStop.service.IStartStopDurationService; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
/** |
||||
* @author ysj |
||||
*/ |
||||
@RestController |
||||
@AllArgsConstructor |
||||
public class StartStopClient implements IStartStopClient { |
||||
|
||||
|
||||
private final IStartStopDurationService service; |
||||
|
||||
|
||||
@Override |
||||
@GetMapping(DEVICE_START_STOP_DURATION) |
||||
public Double deviceDuration(String deviceCode, String startTime, String endTime) { |
||||
return service.deviceDuration(deviceCode,startTime,endTime); |
||||
} |
||||
} |
@ -0,0 +1,13 @@
|
||||
package com.hnac.hzims.startStop.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.hnac.hzims.startStop.entity.StartStopDurationEntity; |
||||
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; |
||||
|
||||
|
||||
/** |
||||
* @author ysj |
||||
*/ |
||||
public interface StartStopDurationMapper extends BaseMapper<StartStopDurationEntity> { |
||||
|
||||
} |
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
||||
<mapper namespace="com.hnac.hzims.startStop.mapper.StartStopDurationMapper" > |
||||
|
||||
</mapper> |
@ -0,0 +1,13 @@
|
||||
package com.hnac.hzims.startStop.service; |
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.hnac.hzims.startStop.entity.StartStopDurationEntity; |
||||
|
||||
/** |
||||
* @author ysj |
||||
*/ |
||||
public interface IStartStopDurationService extends IService<StartStopDurationEntity> { |
||||
|
||||
Double deviceDuration(String deviceCode, String startTime, String endTime); |
||||
} |
@ -0,0 +1,44 @@
|
||||
package com.hnac.hzims.startStop.service.impl; |
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.hnac.hzims.startStop.entity.StartStopDurationEntity; |
||||
import com.hnac.hzims.startStop.mapper.StartStopDurationMapper; |
||||
import com.hnac.hzims.startStop.service.IStartStopDurationService; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springblade.core.tool.utils.CollectionUtil; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.List; |
||||
|
||||
|
||||
/** |
||||
* @author ysj |
||||
*/ |
||||
@Service |
||||
@AllArgsConstructor |
||||
@Slf4j |
||||
public class StartStopDurationServiceImpl extends ServiceImpl<StartStopDurationMapper, StartStopDurationEntity> implements IStartStopDurationService { |
||||
|
||||
/** |
||||
* 查询设备开停机时长 |
||||
* @param deviceCode |
||||
* @param startTime |
||||
* @param endTime |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public Double deviceDuration(String deviceCode, String startTime, String endTime) { |
||||
List<StartStopDurationEntity> durations = this.list(Wrappers.<StartStopDurationEntity>lambdaQuery() |
||||
.eq(StartStopDurationEntity::getDeviceCode,deviceCode) |
||||
.ge(StartStopDurationEntity::getStrDay,startTime) |
||||
.le(StartStopDurationEntity::getStrDay,endTime) |
||||
); |
||||
if(CollectionUtil.isEmpty(durations)){ |
||||
return 0.0; |
||||
} |
||||
return durations.stream().mapToDouble(StartStopDurationEntity::getStartDuration).sum(); |
||||
} |
||||
} |
@ -0,0 +1,34 @@
|
||||
package com.hnac.hzims.scheduled.controller; |
||||
|
||||
|
||||
import com.hnac.hzims.equipment.vo.StartStopGenerateVO; |
||||
import com.hnac.hzims.scheduled.service.equipment.StartStopDurationService; |
||||
import lombok.RequiredArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
|
||||
/** |
||||
* @author ysj |
||||
*/ |
||||
@Slf4j |
||||
@RequestMapping("/scheduled") |
||||
@RestController |
||||
@RequiredArgsConstructor |
||||
public class ScheduledController { |
||||
|
||||
private final StartStopDurationService service; |
||||
|
||||
/** |
||||
* 开停机时长统计接口 |
||||
* @param param |
||||
* @return |
||||
*/ |
||||
@PostMapping("/startStopGenerate") |
||||
public R startStopGenerate(@RequestBody StartStopGenerateVO param) { |
||||
return R.status(service.startStopGenerate(param)); |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,11 @@
|
||||
package com.hnac.hzims.scheduled.mapper.alarm; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.hnac.hzims.alarm.config.entity.AlarmConfigDetailEntity; |
||||
|
||||
/** |
||||
* @author ysj |
||||
*/ |
||||
public interface ConfigDetailMapper extends BaseMapper<AlarmConfigDetailEntity> { |
||||
|
||||
} |
@ -0,0 +1,11 @@
|
||||
package com.hnac.hzims.scheduled.mapper.alarm; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.hnac.hzims.alarm.config.entity.AlarmConfigEntity; |
||||
|
||||
/** |
||||
* @author ysj |
||||
*/ |
||||
public interface ConfigMapper extends BaseMapper<AlarmConfigEntity> { |
||||
|
||||
} |
@ -1,12 +0,0 @@
|
||||
package com.hnac.hzims.scheduled.service.alarm; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.hnac.hzims.alarm.config.entity.AlarmDefaultConfigEntity; |
||||
|
||||
|
||||
/** |
||||
* @author ysj |
||||
*/ |
||||
public interface AlarmDefaulConfigService extends IService<AlarmDefaultConfigEntity> { |
||||
|
||||
} |
@ -0,0 +1,16 @@
|
||||
package com.hnac.hzims.scheduled.service.alarm; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.hnac.hzims.alarm.config.entity.AlarmConfigDetailEntity; |
||||
import com.hnac.hzims.alarm.config.entity.AlarmConfigEntity; |
||||
import com.hnac.hzims.alarm.config.vo.AlarmConfigSourceVo; |
||||
import com.hnac.hzims.alarm.config.vo.AlarmHandleMarkVo; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author ysj |
||||
*/ |
||||
public interface ConfigDetailService extends IService<AlarmConfigDetailEntity> { |
||||
|
||||
} |
@ -0,0 +1,13 @@
|
||||
package com.hnac.hzims.scheduled.service.alarm; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.hnac.hzims.alarm.config.entity.AlarmConfigEntity; |
||||
import com.hnac.hzims.alarm.config.vo.AlarmHandleMarkVo; |
||||
|
||||
/** |
||||
* @author ysj |
||||
*/ |
||||
public interface ConfigService extends IService<AlarmConfigEntity> { |
||||
|
||||
AlarmHandleMarkVo mark(String code,Integer source,Integer type); |
||||
} |
@ -0,0 +1,14 @@
|
||||
package com.hnac.hzims.scheduled.service.alarm; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.hnac.hzims.alarm.config.entity.AlarmDefaultConfigEntity; |
||||
import com.hnac.hzims.alarm.config.vo.AlarmHandleMarkVo; |
||||
|
||||
|
||||
/** |
||||
* @author ysj |
||||
*/ |
||||
public interface DefaulConfigService extends IService<AlarmDefaultConfigEntity> { |
||||
|
||||
AlarmHandleMarkVo defaultMark(Integer source, Integer type); |
||||
} |
@ -0,0 +1,62 @@
|
||||
package com.hnac.hzims.scheduled.service.alarm.impl; |
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS; |
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.hnac.hzims.alarm.config.entity.AlarmConfigDetailEntity; |
||||
import com.hnac.hzims.alarm.config.entity.AlarmConfigEntity; |
||||
import com.hnac.hzims.alarm.config.vo.AlarmHandleMarkVo; |
||||
import com.hnac.hzims.scheduled.mapper.alarm.ConfigMapper; |
||||
import com.hnac.hzims.scheduled.service.alarm.ConfigDetailService; |
||||
import com.hnac.hzims.scheduled.service.alarm.ConfigService; |
||||
import com.hnac.hzims.scheduled.service.alarm.DefaulConfigService; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springblade.core.tool.utils.ObjectUtil; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* @author ysj |
||||
*/ |
||||
@AllArgsConstructor |
||||
@Service |
||||
@Slf4j |
||||
@DS("alarm") |
||||
public class ConfigServiceImpl extends ServiceImpl<ConfigMapper, AlarmConfigEntity> implements ConfigService { |
||||
|
||||
private final ConfigDetailService configDetailService; |
||||
|
||||
private final DefaulConfigService detailService; |
||||
|
||||
/** |
||||
* 查询站点告警标识 |
||||
* @param code |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public AlarmHandleMarkVo mark(String code, Integer source,Integer type) { |
||||
AlarmConfigEntity config = this.getOne(Wrappers.<AlarmConfigEntity>lambdaQuery() |
||||
.eq(AlarmConfigEntity::getStationId,code)); |
||||
if(ObjectUtil.isEmpty(config)){ |
||||
return detailService.defaultMark(source,type); |
||||
} |
||||
AlarmConfigDetailEntity detail = configDetailService.getOne(Wrappers.<AlarmConfigDetailEntity>lambdaQuery() |
||||
.eq(AlarmConfigDetailEntity::getStrategyId,config.getId()) |
||||
.eq(AlarmConfigDetailEntity::getAlarmType,source) |
||||
.eq(AlarmConfigDetailEntity::getAlarmChiledType,type) |
||||
); |
||||
if(ObjectUtil.isEmpty(detail)){ |
||||
return detailService.defaultMark(source,type); |
||||
} |
||||
AlarmHandleMarkVo mark = new AlarmHandleMarkVo(); |
||||
mark.setIsRightTabulation(detail.getIsRightTabulation()); |
||||
mark.setIsBroadcast(detail.getIsBroadcast()); |
||||
mark.setIsMask(detail.getIsMask()); |
||||
mark.setIsPlatformMessage(detail.getIsPlatformMessage()); |
||||
mark.setIsShowAlert(detail.getIsShowAlert()); |
||||
mark.setIsSmallBell(detail.getIsSmallBell()); |
||||
mark.setIsShortMessage(detail.getIsShortMessage()); |
||||
mark.setIsWxMessage(detail.getIsWxMessage()); |
||||
return mark; |
||||
} |
||||
} |
@ -0,0 +1,48 @@
|
||||
package com.hnac.hzims.scheduled.service.alarm.impl; |
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS; |
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.hnac.hzims.alarm.config.entity.AlarmDefaultConfigEntity; |
||||
import com.hnac.hzims.alarm.config.vo.AlarmHandleMarkVo; |
||||
import com.hnac.hzims.scheduled.mapper.alarm.AlarmDefaulConfigMapper; |
||||
import com.hnac.hzims.scheduled.service.alarm.DefaulConfigService; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.beans.BeanUtils; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* @author ysj |
||||
*/ |
||||
@AllArgsConstructor |
||||
@Service |
||||
@Slf4j |
||||
@DS("alarm") |
||||
public class DefaulConfigServiceImpl extends ServiceImpl<AlarmDefaulConfigMapper, AlarmDefaultConfigEntity> implements DefaulConfigService { |
||||
|
||||
private final AlarmDefaulConfigMapper alarmDefaulConfigMapper; |
||||
|
||||
@Override |
||||
public AlarmHandleMarkVo defaultMark(Integer source,Integer type) { |
||||
// 告警来源 : 0- HZ3000告警 1 -等级告警 2 -条件告警 3-FDP智能预警 4-视频预警 5-开关机告警
|
||||
// 子类告警
|
||||
// HZ3000告警 : 2-告警 3-故障 5-遥测越限 13-通讯中断 14-数据异常
|
||||
// 等级告警 : 21-一级告警 22-二级告警 23-三级告警
|
||||
// 智能预警 : 30-智能预警
|
||||
// 条件告警 : 40-条件告警
|
||||
// 开关机告警 : 50-开机告警 51-关机告警
|
||||
AlarmDefaultConfigEntity alarmDefaultConfigEntity = alarmDefaulConfigMapper.selectOne(new LambdaQueryWrapper<AlarmDefaultConfigEntity>() {{ |
||||
eq(AlarmDefaultConfigEntity::getSource, source); |
||||
eq(AlarmDefaultConfigEntity::getAlarmChiledType, type); |
||||
last("limit 1;"); |
||||
}}); |
||||
if (ObjectUtils.isNotEmpty(alarmDefaultConfigEntity)){ |
||||
AlarmHandleMarkVo alarmHandleMarkVo = new AlarmHandleMarkVo(); |
||||
BeanUtils.copyProperties(alarmDefaultConfigEntity,alarmHandleMarkVo); |
||||
return alarmHandleMarkVo; |
||||
} |
||||
return new AlarmHandleMarkVo(); |
||||
} |
||||
} |
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.hnac.hzims.scheduled.mapper.alarm.ConfigDetailMapper"> |
||||
|
||||
</mapper> |
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.hnac.hzims.scheduled.mapper.alarm.ConfigMapper"> |
||||
|
||||
</mapper> |
Loading…
Reference in new issue