diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/vo/SystemAlarmVo.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/vo/SystemAlarmVo.java index 833d0ef..ab422d0 100644 --- a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/vo/SystemAlarmVo.java +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/vo/SystemAlarmVo.java @@ -3,44 +3,45 @@ package com.hnac.hzims.alarm.config.vo; import io.swagger.annotations.ApiModel; import lombok.Data; +import java.io.Serializable; + /** * @author ysj */ @Data @ApiModel(value = "华自3000告警对象", description = "华自3000告警对象") -public class SystemAlarmVo { +public class SystemAlarmVo implements Serializable { private static final long serialVersionUID = 1L; - /** - * 告警时间 - */ - private String ts; - /** - * 告警ID,由平台生成,具有唯一性 - */ - private String id; - /** - * 告警内容 - */ - private String soeExplain; - /** - * 告警类型,对应数据字典 soe_alarm_type - */ - private Integer soeType; - private Integer soeStatus; - /** - * 告警动作,对应HZ3000的告警,如 {"分", "合"}, {"复归", "动作"} - */ - private Integer soeAlarmType; - /** - * 动作值 - */ - private String optionvals; - /** - * 站点id - */ + private Long ts; + private String station; + private String sid; + + private String id; + + private String realId; + + private Integer type; + + private String kind; + + private String level; + + private Integer state; + + private String stateLabel; + + private String context; + + private String opvalue; + + private String duration; + + private Boolean trace; + + private Integer traceCount; } \ No newline at end of file diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneRecordEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneRecordEntity.java index 933ecb9..493f646 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneRecordEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneRecordEntity.java @@ -39,7 +39,7 @@ public class HygieneRecordEntity extends BaseEntity { @ApiModelProperty("实际结束时间") private Date actualEndTime; - @Size(max = 20, message = "检查人字段长度不能超过20") + @Size(max = 100, message = "检查人字段长度不能超过100") @ApiModelProperty("检查人") private String checkUser; diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpTaskServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpTaskServiceImpl.java index 0e993d1..957d210 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpTaskServiceImpl.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpTaskServiceImpl.java @@ -234,11 +234,12 @@ public class FdpTaskServiceImpl extends BaseServiceImpl{ - // 步骤3.根据站点查询配置标识 + List stations = result.getData().stream().filter(o->o.getCode().equals(alarm.getStationId())).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(stations)){ + return; + } + // 步骤3.站点参数设置 + alarm.setCreateDept(stations.get(0).getCreateDept()); + alarm.setStationName(stations.get(0).getName()); + alarm.setTenantId(stations.get(0).getTenantId()); + alarm.setStatus(0); + // 步骤4.根据站点查询配置标识 AlarmHandleMarkVo mark = alarmConfigService.mark(alarm.getStationId(),alarm.getAlarmSource(),alarm.getAlarmType()); if(ObjectUtil.isEmpty(mark)){ log.error("alarm obtain mark is null : {}",alarm.getAlarmId()); return; } - // 步骤4.告警处理标识赋值 + // 步骤5.告警处理标识赋值 alarm.setIsRightTabulation(mark.getIsRightTabulation()); alarm.setIsBroadcast(mark.getIsBroadcast()); alarm.setIsMask(mark.getIsMask()); @@ -68,14 +78,14 @@ public class AlarmSaveServiceImpl implements AlarmSaveService { alarm.setIsShortMessage(mark.getIsShortMessage()); alarm.setIsWxMessage(mark.getIsWxMessage()); - // 步骤5.保存当日告警数据 + // 步骤6.保存当日告警数据 boolean isSave = alarmService.save(alarm); if(!isSave){ log.error("alarm save fail : {}",alarm.getAlarmId()); return; } - // 步骤6.发生数据至redis告警队列 + // 步骤7.发生数据至redis告警队列 stringRedisTemplate.opsForList().rightPush("hzims:queue:alarm", JSON.toJSONString(alarm)); }); return true; diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/HZ300MqttConsumer.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/HZ300MqttConsumer.java index 313583d..67c4895 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/HZ300MqttConsumer.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/HZ300MqttConsumer.java @@ -6,9 +6,11 @@ import com.hnac.hzims.alarm.source.service.SystemAlarmService; import com.hnac.hzims.alarm.monitor.service.AlarmSaveService; import com.hnac.hzinfo.subscribe.SubscribeCallBack; import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.DateUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.Date; import java.util.List; import java.util.Map; @@ -26,10 +28,9 @@ public class HZ300MqttConsumer implements SubscribeCallBack { private AlarmSaveService alarmSaveService; @Override public void onMessage(Map data) { - System.out.println("监听到消息"+data.toString()); - String s = JSONObject.toJSONString(data); + log.error("HZ3000队列监听到消息 : {}",data); //消费代码 - List alarmEntities = systemAlarmService.receiveMessage(s); + List alarmEntities = systemAlarmService.receiveMessage(JSONObject.toJSONString(data)); //统一数据处理 try { alarmSaveService.save(alarmEntities); @@ -37,4 +38,4 @@ public class HZ300MqttConsumer implements SubscribeCallBack { log.error("HZ3000告警数据处理报错(HZ300Alarm):"+e); } } -} +} \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java index 01e2a01..9e8c483 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/MqttConfig.java @@ -30,6 +30,7 @@ public class MqttConfig { HZ300MqttConsumer hz300MqttConsumer; @Autowired VideoMqttConsumer videoMqttConsumer; + @Value("${hzims.mqtt.url}") private String mqtt_fdp_url; @Value("${hzims.mqtt.group}") diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/SystemAlarmService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/SystemAlarmService.java index fa6264c..87f5782 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/SystemAlarmService.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/SystemAlarmService.java @@ -3,6 +3,7 @@ package com.hnac.hzims.alarm.source.service; import com.hnac.hzims.alarm.config.entity.AlarmEntity; import java.util.List; +import java.util.Map; /** * 告警处理接口 diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/FdpAlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/FdpAlarmServiceImpl.java index 2216534..930e4fa 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/FdpAlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/FdpAlarmServiceImpl.java @@ -74,10 +74,6 @@ public class FdpAlarmServiceImpl implements FdpAlarmService { return new ArrayList<>(); } AlarmEntity entity = getAlarmEntity(alarms); -// List res = alarms.stream().map(s -> { -// AlarmEntity entity = getAlarmEntity(s); -// return entity; -// }).collect(Collectors.toList()); return Collections.singletonList(entity); } @@ -87,6 +83,7 @@ public class FdpAlarmServiceImpl implements FdpAlarmService { entity.setRealId(item.getFaultId()); entity.setAlarmTime(item.getCreateTime()); entity.setAlarmContext(item.getFinfo()); + entity.setAlarmSource(EARLY_WARNING); entity.setAlarmType(EARLY); entity.setDeviceCode(item.getDeviceId()); entity.setDeviceName(item.getDeviceName()); @@ -95,13 +92,6 @@ public class FdpAlarmServiceImpl implements FdpAlarmService { entity.setStationId(item.getStation()); entity.setDiagReason(item.getDiagReason()); entity.setDiagSolution(item.getDiagSolution()); - entity.setAlarmSource(EARLY_WARNING); - entity.setTenantId("200000"); - R stationByCode = stationClient.getStationByCode(item.getStation()); - if (stationByCode.isSuccess()&& ObjectUtils.isNotEmpty(stationByCode.getData())){ - entity.setCreateDept(stationByCode.getData().getCreateDept()); - entity.setStationName(stationByCode.getData().getName()); - } return entity; } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SystemAlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SystemAlarmServiceImpl.java index a1f5c48..b8f14b2 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SystemAlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/SystemAlarmServiceImpl.java @@ -1,6 +1,7 @@ package com.hnac.hzims.alarm.source.service.impl; import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.hnac.hzims.alarm.config.constants.AlarmConstants; import com.hnac.hzims.alarm.config.entity.AlarmEntity; @@ -14,6 +15,7 @@ import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.feign.IStationClient; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.MapUtils; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; @@ -22,9 +24,7 @@ import org.springblade.system.feign.ISysClient; import org.springblade.system.user.feign.IUserClient; import org.springframework.stereotype.Service; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; @@ -73,33 +73,28 @@ public class SystemAlarmServiceImpl implements SystemAlarmService { @Override public List receiveMessage(String message) { // 对象转换 - List alarms = JSONObject.parseArray(message, SystemAlarmVo.class); - if (CollectionUtil.isEmpty(alarms)) { + SystemAlarmVo systemAlarm = JSONObject.parseObject(message, SystemAlarmVo.class); + log.error("HZ3000告警对象转换后:{}",systemAlarm); + if (ObjectUtils.isEmpty(systemAlarm)) { return new ArrayList<>(); } - List res = alarms.stream().map(s -> { - AlarmEntity entity = getAlarmEntity(s); - return entity; - }).collect(Collectors.toList()); - return res; + return Collections.singletonList(this.getAlarmEntity(systemAlarm)); } private AlarmEntity getAlarmEntity(SystemAlarmVo item) { AlarmEntity entity = new AlarmEntity(); entity.setAlarmId(item.getId()); - entity.setAlarmTime(DateUtil.parse(item.getTs(), "yyyy-MM-dd HH:mm:ss.s")); - entity.setAlarmContext(item.getSoeExplain()); - entity.setAlarmType(item.getSoeAlarmType()); - entity.setAlarmStatus(item.getSoeStatus()); - entity.setAlarmValue(item.getOptionvals()); + Date date = new Date(); + date.setTime(item.getTs()); + entity.setAlarmTime(DateUtil.parse(DateUtil.format(date,DateUtil.PATTERN_DATETIME),DateUtil.PATTERN_DATETIME)); + entity.setAlarmContext(item.getContext()); + entity.setAlarmType(item.getType()); + entity.setAlarmStatus(item.getState()); + entity.setAlarmValue(item.getOpvalue()); entity.setStationId(item.getStation()); + entity.setAlarmCount(item.getTraceCount()); + entity.setRealId(item.getRealId()); entity.setAlarmSource(AlarmConstants.HZ3000_ALARM); - entity.setTenantId("200000"); - R stationByCode = stationClient.getStationByCode(item.getStation()); - if (stationByCode.isSuccess() && ObjectUtils.isNotEmpty(stationByCode.getData())) { - entity.setCreateDept(stationByCode.getData().getCreateDept()); - entity.setStationName(stationByCode.getData().getName()); - } return entity; } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperPhenomenonServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperPhenomenonServiceImpl.java index 4032dff..bf8224d 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperPhenomenonServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperPhenomenonServiceImpl.java @@ -609,9 +609,6 @@ public class OperPhenomenonServiceImpl extends BaseServiceImpl res = new ArrayList<>(); if (CollectionUtil.isNotEmpty(operPhenomenonEntities)) { - CheckVoteChartVo all = getCheckVoteChartVo(operPhenomenonEntities); - all.setName("总计"); - res.add(all); Map> collect = Optional.ofNullable(operPhenomenonEntities).orElse(new ArrayList<>()).stream().collect(Collectors.groupingBy(OperPhenomenonEntity::getCreateDept)); for (Map.Entry> longListEntry : collect.entrySet()) { CheckVoteChartVo chartVo= getCheckVoteChartVo(longListEntry.getValue()); @@ -619,6 +616,9 @@ public class OperPhenomenonServiceImpl extends BaseServiceImpl itemList = carCheckRecordDTO.getItemList(); - boolean updateItem = carCheckItemService.updateBatchById(itemList); - // 若更新检查项成功,则更新车检记录 - if (updateItem) { + itemList.forEach(x -> {x.setCarCheckRecordId(carCheckRecordDTO.getId()); + x.setId(null);}); + boolean b = carCheckItemService.saveBatch(itemList); + if (b) { + // 若更新检查项成功,则更新车检记录 CarCheckRecordEntity carCheckRecordEntity = new CarCheckRecordEntity(); BeanUtil.copyProperties(carCheckRecordDTO, carCheckRecordEntity); return this.updateById(carCheckRecordEntity); diff --git a/hzims-service/safeproduct/src/main/resources/db/2.0.0.sql.1 b/hzims-service/safeproduct/src/main/resources/db/2.0.0.sql.1 index 778d870..d54fb2a 100644 --- a/hzims-service/safeproduct/src/main/resources/db/2.0.0.sql.1 +++ b/hzims-service/safeproduct/src/main/resources/db/2.0.0.sql.1 @@ -222,7 +222,7 @@ CREATE TABLE `HZIMS_HYGIENE_RECORD` ( `ACTUAL_START_TIME` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '实际开始时间', `ACTUAL_END_TIME` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '实际结束时间', `CHECK_TIME` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '检查时间', - `CHECK_USER` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '检查人', + `CHECK_USER` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '检查人', `HYGIENE_ZONE_IDS` VARCHAR(1000) NOT NULL COMMENT '卫生自查区域ID', `CHECK_RESULT` MEDIUMTEXT NOT NULL COMMENT '检查结果', `COMPREHENSIVE_SCORE` VARCHAR(500) NOT NULL COMMENT '综合评分',