diff --git a/hzims-biz-common/src/main/java/com/hnac/hzims/common/enums/ExceptionEnum.java b/hzims-biz-common/src/main/java/com/hnac/hzims/common/enums/ExceptionEnum.java new file mode 100644 index 0000000..9bb7532 --- /dev/null +++ b/hzims-biz-common/src/main/java/com/hnac/hzims/common/enums/ExceptionEnum.java @@ -0,0 +1,102 @@ +package com.hnac.hzims.common.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.springblade.core.tool.api.IResultCode; + +import javax.servlet.http.HttpServletResponse; + +/** + * 异常码枚举类 + */ +@Getter +@AllArgsConstructor +public enum ExceptionEnum implements IResultCode { + + /** + * 操作成功 + */ + SUCCESS(HttpServletResponse.SC_OK, "操作成功"), + + /** + * 业务异常 + */ + FAILURE(HttpServletResponse.SC_BAD_REQUEST, "业务异常"), + + /** + * 请求未授权 + */ + UN_AUTHORIZED(HttpServletResponse.SC_UNAUTHORIZED, "请求未授权"), + + /** + * 客户端请求未授权 + */ + CLIENT_UN_AUTHORIZED(HttpServletResponse.SC_UNAUTHORIZED, "客户端请求未授权"), + + /** + * 404 没找到请求 + */ + NOT_FOUND(HttpServletResponse.SC_NOT_FOUND, "404 没找到请求"), + + /** + * 消息不能读取 + */ + MSG_NOT_READABLE(HttpServletResponse.SC_BAD_REQUEST, "消息不能读取"), + + /** + * 不支持当前请求方法 + */ + METHOD_NOT_SUPPORTED(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "不支持当前请求方法"), + + /** + * 不支持当前媒体类型 + */ + MEDIA_TYPE_NOT_SUPPORTED(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE, "不支持当前媒体类型"), + + /** + * 请求被拒绝 + */ + REQ_REJECT(HttpServletResponse.SC_FORBIDDEN, "请求被拒绝"), + + /** + * 服务器异常 + */ + INTERNAL_SERVER_ERROR(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "服务器异常"), + + /** + * 缺少必要的请求参数 + */ + PARAM_MISS(HttpServletResponse.SC_BAD_REQUEST, "缺少必要的请求参数"), + + /** + * 请求参数类型错误 + */ + PARAM_TYPE_ERROR(HttpServletResponse.SC_BAD_REQUEST, "请求参数类型错误"), + + /** + * 请求参数绑定错误 + */ + PARAM_BIND_ERROR(HttpServletResponse.SC_BAD_REQUEST, "请求参数绑定错误"), + + /** + * 参数校验失败 + */ + PARAM_VALID_ERROR(HttpServletResponse.SC_BAD_REQUEST, "参数校验失败"), + + + /** + * 模拟数据失败 + */ + SIMULATE_ERROR(400, "模拟数据失败"), + + ; + + /** + * code编码 + */ + final int code; + /** + * 中文信息描述 + */ + final String message; +} \ No newline at end of file diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java index 2cbeb99..b60f2ae 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java @@ -87,6 +87,8 @@ public interface IEmInfoClient { String RIDE_DEVICES = API_PREFIX + "/rideDevices"; + String CREWS_DEVICES = API_PREFIX + "/crewsDevices"; + @PostMapping(DETAIL) EmInfoEntity getByCode(@RequestParam("code") String id); @@ -176,4 +178,7 @@ public interface IEmInfoClient { @GetMapping(RIDE_DEVICES) List rideDevices(@RequestParam("deptIds") List deptIds); + + @GetMapping(CREWS_DEVICES) + List crewsDevices(@RequestParam("refDept") Long refDept); } diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java index 104d494..c84c6eb 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java @@ -120,4 +120,9 @@ public class IEmInfoClientBack implements IEmInfoClient { public List rideDevices(List longs) { return new ArrayList<>(); } + + @Override + public List crewsDevices(Long refDept) { + return new ArrayList<>(); + } } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/GenerationDeviceVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/GenerationDeviceVo.java new file mode 100644 index 0000000..736f7ce --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/GenerationDeviceVo.java @@ -0,0 +1,24 @@ +package com.hnac.hzims.operational.report.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author ysj + */ +@Data +@ApiModel("发电量报表") +public class GenerationDeviceVo { + + @ApiModelProperty("设备编号") + private String deviceCode; + + @ApiModelProperty("设备名称") + private String deviceName; + + @ApiModelProperty("属性时间范围统计数据") + private List attributes; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/GenerationReportTimeVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/GenerationReportTimeVo.java new file mode 100644 index 0000000..1540fae --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/GenerationReportTimeVo.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.operational.report.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + */ +@Data +@ApiModel("发电量报表") +public class GenerationReportTimeVo { + + @ApiModelProperty("时间") + private String time; + + @ApiModelProperty("值") + private Double value; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/GenerationReportVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/GenerationReportVo.java new file mode 100644 index 0000000..13847b5 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/GenerationReportVo.java @@ -0,0 +1,24 @@ +package com.hnac.hzims.operational.report.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author ysj + */ +@Data +@ApiModel("发电量报表") +public class GenerationReportVo { + + @ApiModelProperty("属性") + private String attribute; + + @ApiModelProperty("属性名称") + private String attributeName; + + @ApiModelProperty("属性时间范围统计数据") + private List times; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationRelation.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationRelation.java new file mode 100644 index 0000000..509ca22 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationRelation.java @@ -0,0 +1,130 @@ +package com.hnac.hzims.operational.station.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; +import okhttp3.internal.annotations.EverythingIsNonNull; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.math.BigDecimal; +import java.time.LocalDateTime; + +/** + * 站点和霍山生态流量电站的关联关系表 + * @author tanghaihao + * @date 2023年10月08日 13:58 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("station_relation") +public class StationRelation implements Serializable { + private static final long serialVersionUID=1L; + + /** + * ID + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 站点编码 + */ + @TableField("station_code") + private String stationCode; + + /** + * 站点名称 + */ + @TableField(exist = false) + private String stationName; + + /** + * 设备编码 + */ + @TableField("device_code") + private String deviceCode; + + /** + * 设备名称 + */ + @TableField(exist = false) + private String deviceName; + + /** + * 核定流量 + */ + @TableField("flow_value") + private String flowValue; + + /** + * 低级告警负责人id + */ + @TableField("low_soe_user_id") + private String lowSoeUserId; + + /** + * 低级告警电话号码 + */ + @TableField("low_soe_phone") + private String lowSoePhone; + + /** + * 中级告警负责人id + */ + @TableField("middle_soe_user_id") + private String middleSoeUserId; + + /** + * 中级告警电话号码 + */ + @TableField("middle_soe_phone") + private String middleSoePhone; + + /** + * 高级告警负责人id + */ + @TableField("high_soe_user_id") + private String highSoeUserId; + + /** + * 高级告警电话号码 + */ + @TableField("high_soe_phone") + private String highSoePhone; + + /** + * 当日是否发送预警 + */ + @TableField("send_warning") + private Integer sendWarning; + + /** + * 当日是否发送告警 + */ + @TableField("send_soe") + private Integer sendSoe; + + /** + * 创建时间 + */ + @TableField("create_time") + private LocalDateTime createTime; + + /** + * 更新时间 + */ + @TableField("update_time") + private LocalDateTime updateTime; + + /** + * 逻辑删除 + */ + @TableField("is_deleted") + private Integer isDeleted; +} diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/ai/vo/RemoteControlDTO.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/ai/vo/RemoteControlDTO.java new file mode 100644 index 0000000..4c5cc15 --- /dev/null +++ b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/ai/vo/RemoteControlDTO.java @@ -0,0 +1,31 @@ +package com.hnac.hzinfo.inspect.ai.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.util.Map; + +@Data +public class RemoteControlDTO { + + @ApiModelProperty("站点编号") + @NotBlank + private String stationCode; + + @ApiModelProperty("设备编码") + @NotBlank + private String deviceCode; + + @ApiModelProperty("功能标识") + @NotBlank + private String signage; + + @ApiModelProperty("参数列表") + @NotBlank + private Map params; + + @ApiModelProperty("机器码") + @NotBlank + private String machineCode; +} diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/entity/TaskEntity.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/entity/TaskEntity.java index df18dbe..6cd2907 100644 --- a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/entity/TaskEntity.java +++ b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/entity/TaskEntity.java @@ -48,6 +48,14 @@ public class TaskEntity extends TenantEntity { @ApiModelProperty(value = "计划名称") @QueryField(condition = SqlCondition.LIKE) private String planName; + + /** + * 路线名称 + */ + @ApiModelProperty(value = "路线名称") + @QueryField(condition = SqlCondition.LIKE) + private String routeName; + /** * 任务批次号 */ diff --git a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/entity/StandardTicketInfoEntity.java b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/entity/StandardTicketInfoEntity.java index 95f329b..0312ece 100644 --- a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/entity/StandardTicketInfoEntity.java +++ b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/entity/StandardTicketInfoEntity.java @@ -168,4 +168,14 @@ public class StandardTicketInfoEntity extends TenantEntity implements Serializab @TableField(exist = false) @ApiModelProperty("监护人确认结果:approved-确认,rejected-作废") private String verifyResult; + + @ApiModelProperty("是否线下 : 1-线下,0-线上") + @QueryField(condition = SqlCondition.EQUAL) + private Boolean isOffline; + + @ApiModelProperty("是否审核通过,0为通过,1为未通过") + private Boolean isApproved; + + @ApiModelProperty("图片附件") + private String picture; } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java index de29497..adfc78e 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java @@ -162,6 +162,12 @@ public class EmInfoClient implements IEmInfoClient { return service.rideDevices(deptIds); } + @Override + @GetMapping(CREWS_DEVICES) + public List crewsDevices(@RequestParam("refDept") Long refDept) { + return service.list(Wrappers.lambdaQuery().eq(EmInfoEntity::getEmType,2).eq(EmInfoEntity::getCreateDept,refDept)); + } + @PostMapping(GET_EM_CREATE_TABLE) @Override public List getEmCreateTable(List tableNames) { diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java index a105d13..14f7b9f 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java @@ -230,7 +230,7 @@ public class AlarmHandleServiceImpl extends ServiceImpl sameDayContent(List stations) { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.HOUR_OF_DAY,-1); - String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00"; + String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); String end = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME); return this.baseMapper.sameDayContent(start,end,stations); } diff --git a/hzims-service/hzims-big-model/pom.xml b/hzims-service/hzims-big-model/pom.xml index 03090ac..783e410 100644 --- a/hzims-service/hzims-big-model/pom.xml +++ b/hzims-service/hzims-big-model/pom.xml @@ -59,6 +59,25 @@ com.hnac.hzims hzims-operational-api + + + com.hnac.hzims + hzims-operational-api + 4.0.0-SNAPSHOT + + + com.hnac.hzinfo.data + hzinfo-data-sdk + + + com.hnac.hzims + equipment-api + + + com.baomidou + dynamic-datasource-spring-boot-starter + 2.5.6 + diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OfflineOperationTicketProcessServiceImpl.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OfflineOperationTicketProcessServiceImpl.java new file mode 100644 index 0000000..f0a346e --- /dev/null +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OfflineOperationTicketProcessServiceImpl.java @@ -0,0 +1,72 @@ +package com.hnac.hzims.middle.processflow.strategy.serviceimpl; + +import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; +import com.hnac.hzims.middle.processflow.service.ProcessDictService; +import com.hnac.hzims.middle.processflow.strategy.abstracts.ProcessAbstractService; +import com.hnac.hzims.middle.processflow.strategy.entity.WorkflowQueue; +import com.hnac.hzims.ticket.ticketprocess.feign.OperationTicketFeignClient; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.log.exception.ServiceException; +import org.springframework.stereotype.Service; + +import static com.hnac.hzims.middle.process.constant.TicketProcessConstant.OFFLINE_OPERATION_TICKET; + + +/** + * 操作票流程实现类 + * + * @Author dfy + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/3/28 8:47 + */ +@Slf4j +@Service +@RequiredArgsConstructor +public class OfflineOperationTicketProcessServiceImpl extends ProcessAbstractService { + + + + private final OperationTicketFeignClient operationTicketFeignClient; + + + + private final ProcessDictService processDictService; + + + + /** + * 设置执行那种实现类 + * + * @param flowQueue + * @return + */ + @Override + public Boolean isWorkflowProcess(WorkflowQueue flowQueue) { + log.info("是否执行操作票流程环节操作~~~~,流程flowQueue: {}", flowQueue); + String dictValue = processDictService.selectDictValueByKey(OFFLINE_OPERATION_TICKET); + if (dictValue.equals(flowQueue.getProcessDefinitionKey())) { + log.info("已执行操作票流程环节操作~~~~"); + return true; + } + log.error("未执行操作票流程环节操作,请联系管理员~~~~"); + return false; + } + + /** + * 两票管理业务方法 + * + * @param response + */ + @Override + public void calculate(ProcessWorkFlowResponse response) { + log.info("操作票流程消费调用fein接口开始---param",response); + Boolean pending = operationTicketFeignClient.findPending(response); + if (!pending) { + log.info("操作票流程调用fein接口异常---param",response); + throw new ServiceException("操作票流程出现异常呢"); + } + log.info("操作票流程消费调用fein接口结束---param",response); + } +} diff --git a/hzims-service/hzims-middle/src/main/resources/db/3.0.0.sql b/hzims-service/hzims-middle/src/main/resources/db/3.0.0.sql new file mode 100644 index 0000000..c1ebcf4 --- /dev/null +++ b/hzims-service/hzims-middle/src/main/resources/db/3.0.0.sql @@ -0,0 +1 @@ +INSERT INTO `process_dict`(`dict_code`, `dict_sort`, `dict_key`, `dict_value`, `dict_label`, `dict_type`, `is_default`, `status`, `create_dept`, `create_time`, `update_time`, `remark`) VALUES (15, 15, 'OperationTicketOffline', 'OperationTicketOffline', '线下操作票', '线下操作票', 'Y', 0, NULL, '2023-07-25 18:35:01', '2024-05-24 11:22:14', '线下操作票流程'); diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/MonitorScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/MonitorScheduledTask.java index 15e3cf7..bdaa7dd 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/MonitorScheduledTask.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/MonitorScheduledTask.java @@ -58,7 +58,7 @@ public class MonitorScheduledTask { * @return ReturnT */ @XxlJob(CENTRALIZED_MONITORING) - //@Scheduled(cron = "0/40 * * * * ? ") + // @Scheduled(cron = "0/40 * * * * ? ") public ReturnT loadMonitoring(String param) { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java index 6d92b14..486a396 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java @@ -27,7 +27,6 @@ import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.ObjectUtil; -import org.springblade.mqtt.producer.IMqttSender; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; @@ -56,7 +55,7 @@ public class AlarmServiceImpl implements AlarmService { private final RedisTemplate redisTemplate; - private final IMqttSender mqttSender; + //private final IMqttSender mqttSender; private final static String start_stop_cache_final = "hzims:operation:start:stop:key"; private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key"; @@ -280,7 +279,7 @@ public class AlarmServiceImpl implements AlarmService { alarm.setContext(entity.getSoeExplain()); alarm.setState(entity.getStatus()); log.error("send_interruption_msg : {}",JsonUtil.toJson(alarm)); - mqttSender.sendToMqtt(InterruptionConstants.HZ3000_TOPIC_PREFIX + entity.getStationId(), JsonUtil.toJson(alarm)); + //mqttSender.sendToMqtt(InterruptionConstants.HZ3000_TOPIC_PREFIX + entity.getStationId(), JsonUtil.toJson(alarm)); }); } diff --git a/hzims-service/hzims-simulate/pom.xml b/hzims-service/hzims-simulate/pom.xml new file mode 100644 index 0000000..72cbbb0 --- /dev/null +++ b/hzims-service/hzims-simulate/pom.xml @@ -0,0 +1,129 @@ + + + + com.hnac.hzims + hzims-service + 4.0.0-SNAPSHOT + + + 4.0.0 + hzims-simulate + jar + + + 8 + 8 + UTF-8 + + + + + + com.xuxueli + xxl-job-core + + + com.google.guava + failureaccess + 1.0.1 + + + org.springblade + blade-common + + + org.springblade + blade-core-boot + + + org.springblade + blade-core-cloud + + + + + org.springblade + blade-starter-http + + + org.springblade + blade-core-cloud + compile + + + + org.springblade + blade-starter-datascope + compile + + + org.projectlombok + lombok + + + + com.hnac.hzims + equipment-api + 4.0.0-SNAPSHOT + + + + com.hnac.hzims + weather-api + 4.0.0-SNAPSHOT + + + + com.hzinfo.framework + hnac-framework-mqtt-starters + + + + dom4j + dom4j + 1.6.1 + compile + + + org.springblade + blade-core-cloud + 5.1.1.RELEASE.fix.1 + compile + + + + + + + ${project.name}-${project.version} + + + src/main/java + + **/*.xml + + false + + + + + org.springframework.boot + spring-boot-maven-plugin + 2.6.6 + + + + repackage + + + exec + + + + + + + + \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/SimulateApplication.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/SimulateApplication.java new file mode 100644 index 0000000..59981d0 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/SimulateApplication.java @@ -0,0 +1,28 @@ +package com.hnac.hzims.simulate; + +import org.mybatis.spring.annotation.MapperScan; +import org.springblade.core.cloud.feign.EnableBladeFeign; +import org.springblade.core.launch.BladeApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; +import org.springframework.cloud.client.SpringCloudApplication; + + +/** + * @author admin + */ +@EnableBladeFeign +@SpringCloudApplication +@MapperScan(basePackages={"com.hnac.hzims.**.mapper"}) +//@ComponentScan(basePackages = {"com.hnac.hzinfo.simulate"}) +public class SimulateApplication extends SpringBootServletInitializer { + static String APPLICATION_NAME="hzims-simulate"; + public static void main(String[] args) { + BladeApplication.run(APPLICATION_NAME, SimulateApplication.class, args); + } + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { + return BladeApplication.createSpringApplicationBuilder(builder, APPLICATION_NAME, SimulateApplication.class); + } +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/constants/WriteRealDataConstant.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/constants/WriteRealDataConstant.java new file mode 100644 index 0000000..bd48066 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/constants/WriteRealDataConstant.java @@ -0,0 +1,43 @@ +package com.hnac.hzims.simulate.constants; + +/** + * @author ysj + * @describe 实时数据写入常量 + */ +public interface WriteRealDataConstant { + + String REAL_DATA_V3 = "3"; + + String REAL_DATA_V4 = "4"; + + String GATE_FLOW = "过闸流量(m³/s)"; + + String OPENING_DEGREE = "开度(m)"; + + String GATE_STATUS = "闸门状态"; + + String WRITE_REAL_GATE_DATA = "writeRealGateData"; + + String WRITE_REAL_RAIN_DATA = "writeRealRainData"; + + Long OPEN = 0L; + + Long CLOSE = 1L; + + String WRITE_GATE = "1"; + + String WRITE_RAIN = "2"; + + // 降雨站属性标识 + String ATTR_RAIN = "attr_rain"; + String ATTR_WIND360 = "wind360"; + String ATTR_WIND_SCALE = "wind_scale"; + String ATTR_WIND_SPEED = "wind_speed "; + String ATTR_HUMIDITY = "humidity"; + String ATTR_PRESSURE = "pressure"; + String ATTR_VIS = "vis"; + String ATTR_CLOUD = "cloud"; + String ATTR_DEW = "dew"; + String ATTR_FEELS_LIKE = "feels_like"; + String ATTR_TEMP = "temp"; +} \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/controller/GageController.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/controller/GageController.java new file mode 100644 index 0000000..08ec0a8 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/controller/GageController.java @@ -0,0 +1,31 @@ +package com.hnac.hzims.simulate.controller; + +import com.hnac.hzims.simulate.service.WriteRealDataService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +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.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author ysj + */ +@RestController +@AllArgsConstructor +@RequestMapping("/gate") +@Api(value = "闸门开关机模拟服务", tags = "闸门开关机模拟服务") +public class GageController { + + private final WriteRealDataService writeRealDataService; + + @GetMapping("/isOpen") + @ApiOperation(value = "枢纽天气情况") + public R weather(@RequestParam("deviceCode") String deviceCode, + @RequestParam("isOpen") Long isOpen){ + return R.data(writeRealDataService.isOpen(deviceCode,isOpen)); + } +} \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/controller/SimulationDataController.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/controller/SimulationDataController.java new file mode 100644 index 0000000..8d6d85c --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/controller/SimulationDataController.java @@ -0,0 +1,195 @@ +package com.hnac.hzims.simulate.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.google.common.collect.Maps; +import com.hnac.hzims.common.enums.ExceptionEnum; +import com.hnac.hzims.simulate.entity.DataModel; +import com.hnac.hzims.simulate.entity.Device; +import com.hnac.hzims.simulate.entity.DeviceField; +import com.hnac.hzims.simulate.entity.DeviceFieldGap; +import com.hnac.hzims.simulate.service.DeviceFieldGapService; +import com.hnac.hzims.simulate.service.DeviceFieldService; +import com.hnac.hzims.simulate.service.SimulationService; +import com.hnac.hzims.simulate.util.ParseFacUtils; +import com.hnac.hzims.simulate.util.TopicConstant; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.jackson.JsonUtil; +import org.springblade.core.tool.utils.Func; +import org.springblade.mqtt.producer.IMqttSender; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.*; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@RestController +@RequestMapping("/simulationData") +@Api(value = "数据模拟服务", tags = "数据模拟服务") +@Slf4j +public class SimulationDataController { + + @Autowired + private SimulationService simulationService; + + @Autowired + private DeviceFieldService deviceFieldService; + + @Autowired + private DeviceFieldGapService deviceFieldGapService; + + @Autowired + private IMqttSender mqttSender; + + @Value("fac.path") + private String facPath; + + public static Map cacheMap = Maps.newHashMap(); + + @ApiOperation(value = "解析v3.0场信息文件", notes = "解析场信息文件") + @GetMapping("/readFac") + public R readFac() { + InputStream inputStream = null; + try { + inputStream = new FileInputStream(new File(facPath+File.separator+"factory.fac")); + List list = ParseFacUtils.parsePoint(inputStream); + list.forEach(entity -> { + mqttSender.sendToMqtt(TopicConstant.TOPIC_DEVICE_MODEL, JsonUtil.toJson(entity)); + }); + return R.success("解析场信息文件成功"); + } catch (Exception e) { + log.error(e.getMessage(), e); + return R.fail("解析场信息文件失败"); + } finally { + if (inputStream != null) { + try { + inputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + @ApiOperation(value = "分页范围配置", notes = "分页范围配置") + @GetMapping("/pageGap") + public R> pageGap(String stationId, Query query) { + List list=simulationService.getDeviceListByStationId(stationId); + List ids=list.stream().map(Device::getId).collect(Collectors.toList()); + LambdaQueryWrapper lambdaQueryWrapper=new LambdaQueryWrapper(); + lambdaQueryWrapper.in(DeviceFieldGap::getFacDeviceId,ids); + IPage pageList=deviceFieldGapService.page(Condition.getPage(query),lambdaQueryWrapper); + return R.data(pageList); + } + + @ApiOperation(value = "更新设备属性范围配置", notes = "更新设备属性范围配置") + @PostMapping("/updateGap") + public R updateGap(@RequestBody DeviceFieldGap deviceFieldGap) { + deviceFieldGapService.updateById(deviceFieldGap); + return R.status(true); + } + + @ApiOperation(value = "第一次同步设备属性", notes = "第一次同步设备属性") + @GetMapping("/syncOneGap") + public R syncGap() { + //存在表 + int count=deviceFieldService.existGapTable(); + if(count<=0){//建表 + deviceFieldService.createGapTable(); + } + //同步 + List list=deviceFieldService.list(); + List gaps=list.stream().map(result -> new DeviceFieldGap(result.getId(), result.getFacDeviceId(), + result.getSignage(),result.getName(), BigDecimal.ZERO,BigDecimal.ZERO)) + .collect(Collectors.toList()); + deviceFieldGapService.saveOrUpdateBatch(gaps); + + return R.status(true); + } + + @ApiOperation(value = "第二次同步设备属性", notes = "第二次同步设备属性") + @GetMapping("/syncTwoGap") + public R syncTwoGap() { + //同步 + List list=deviceFieldService.queryNewInsert(); + if(list!=null && !list.isEmpty()) { + List gaps = list.stream().map(result -> new DeviceFieldGap(result.getId(), result.getFacDeviceId(), + result.getSignage(), result.getName(), BigDecimal.ZERO, BigDecimal.ZERO)) + .collect(Collectors.toList()); + deviceFieldGapService.saveBatch(gaps); + } + return R.status(true); + } + + + @ApiOperation(value = "模拟单站的数据(循环,每隔sleepTime时长发送一次整站数据)", notes = "模拟单站的数据") + @GetMapping("/simulationMultiple") + public R simulationMultipleV3(String stationId, Long sleepTime) { + String key = "simulation:" + stationId; + String hasExc = cacheMap.get(key); + if (Func.isNotBlank(hasExc)) { + return R.fail("该站已经在模拟数据了"); + } + try { + simulationService.simulationMultiple(stationId, sleepTime); + }catch (Exception e) { + throw new ServiceException(ExceptionEnum.SIMULATE_ERROR); + } + cacheMap.put(key, "true"); + return R.status(true); + + } + + @ApiOperation(value = "模拟单站的数据(循环,每隔sleepTime时长发送一次整站数据)", notes = "模拟单站的数据") + @GetMapping("/simulationMultipleV4") + public R simulationMultipleV4(String stationId, Long sleepTime) { + String key = "simulation:" + stationId; + String hasExc = cacheMap.get(key); + if (Func.isNotBlank(hasExc)) { + return R.fail("该站已经在模拟数据了"); + } + try { + simulationService.simulationMultipleV4(stationId, sleepTime); + }catch (Exception e) { + throw new ServiceException(ExceptionEnum.SIMULATE_ERROR); + } + cacheMap.put(key, "true"); + return R.status(true); + } + +// @ApiOperation(value = "模拟单站的数据(循环,每隔sleepTime时长发送一次整站数据)", notes = "模拟单站的数据") +// @GetMapping("/simulationMultipleFlow") +// public R simulationMultipleInFlow() { +// String key = "simulationMultipleInFlow"; +// String hasExc = cacheMap.get(key); +// if (Func.isNotBlank(hasExc)) { +// return R.fail("该站已经在模拟数据了"); +// } +// simulationService.simulationMultipleInFlow(); +// cacheMap.put(key, "true"); +// return R.status(true); +// } + + + @ApiOperation(value = "停止模拟", notes = "停止模拟") + @GetMapping("/stopStart") + public R stopStart() { + simulationService.stopStart(); + return R.status(true); + + } + +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DataItem.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DataItem.java new file mode 100644 index 0000000..633cbb8 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DataItem.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.simulate.entity; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class DataItem { + + private String id; + private String signage;//hz3000定义的id + private String name; + private String type; + private String soeType; + private String eventType; +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DataModel.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DataModel.java new file mode 100644 index 0000000..7771e95 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DataModel.java @@ -0,0 +1,46 @@ +package com.hnac.hzims.simulate.entity; + +import lombok.Data; + +import java.util.List; + +/** + * { + * "station": "4543", + * "structType": "dataGroup", + * "id": "5016387599_0", + * "pid": "5016387585", + * "name": "温度传感器", + * "children": [{ + * "id": "5016387607", + * "name": "温度", + * "type": "YC" + * },{ + * "id": "5016387617", + * "name": "高度", + * "type": "YC" + * },{ + * "id": "5016387608", + * "name": "工作状态", + * "type": "YX" + * },{ + * "id": "5016387609", + * "name": "工作状态", + * "type": "SOE", + * "eventType": "" + * }] + * } + * 数据组 + * @author ninglong + */ +@Data +public class DataModel { + private String station; + private String structType; + private String id; + private String signage;//hz3000定义的id + private String pid; + private String name; + private List children; +} + diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/Device.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/Device.java new file mode 100644 index 0000000..b3ed590 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/Device.java @@ -0,0 +1,66 @@ +package com.hnac.hzims.simulate.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.format.annotation.DateTimeFormat; + +import java.io.Serializable; +import java.util.Date; + +/** + * 数据组 + * + * @author ninglong + */ +@TableName(value = "hzinfo_fac_device") +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class Device implements Serializable { + + @ApiModelProperty(value = "id") + @TableId(type = IdType.INPUT) + private String id; + + @ApiModelProperty(value = "名称") + private String name; + + @ApiModelProperty(value = "0-云端cms,1-站端直传") + private Integer source; + + @ApiModelProperty("hz3000定义的id,如果定义的是大id则值与id字段值相同") + private String sid; + + @ApiModelProperty("version=v3,version=v4") + private String modelKind; + + @DateTimeFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + @JsonFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + @ApiModelProperty("创建时间") + private Date createTime; + + @JsonSerialize( + using = ToStringSerializer.class + ) + + @ApiModelProperty("项目id") + private String projectId; + + + @ApiModelProperty("写入方式") + private String isWrite; +} \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceData.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceData.java new file mode 100644 index 0000000..411609c --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceData.java @@ -0,0 +1,22 @@ +package com.hnac.hzims.simulate.entity; + +import com.google.common.collect.Lists; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 设备数据 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class DeviceData { + private String station; + private String time; + private List children = Lists.newArrayList(); +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceDataV4.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceDataV4.java new file mode 100644 index 0000000..6b6023d --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceDataV4.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.simulate.entity; + +import com.google.common.collect.Lists; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class DeviceDataV4 { + private String stationId; + private String time; + private List children = Lists.newArrayList(); +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceFacConfig.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceFacConfig.java new file mode 100644 index 0000000..80c449e --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceFacConfig.java @@ -0,0 +1,38 @@ +package com.hnac.hzims.simulate.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author ysj + */ +@TableName("hzinfo_fac_device_config") +@Data +public class DeviceFacConfig implements Serializable { + @ApiModelProperty("id") + @TableId(type = IdType.INPUT) + private String id; + + @ApiModelProperty("设备id") + private String deviceCode; + + @ApiModelProperty("字段标识") + private String facDeviceId; + + @ApiModelProperty("站点Id") + private String stationId; + + @ApiModelProperty("站点类型") + private String modelKind; + + @ApiModelProperty("sid") + private String sid; + + @ApiModelProperty("数据写入方式: 1-闸门,2-天气") + private String writeMethod; +} \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceField.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceField.java new file mode 100644 index 0000000..c9660e2 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceField.java @@ -0,0 +1,42 @@ +package com.hnac.hzims.simulate.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.io.Serializable; +import java.util.Date; + +@TableName("hzinfo_fac_device_attr") +@Data +public class DeviceField implements Serializable { + @ApiModelProperty("id") + @TableId(type = IdType.INPUT) + private String id; + @ApiModelProperty("设备id") + private String facDeviceId; + @ApiModelProperty("字段标识") + private String signage; + @ApiModelProperty("字段名称") + private String name; + @ApiModelProperty("最大值") + private String projectId; + + @DateTimeFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + @JsonFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + @ApiModelProperty("创建时间") + private Date createTime; + + private Long modelClassifyId; + private String alarmType; + + +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceFieldGap.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceFieldGap.java new file mode 100644 index 0000000..d3efad5 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceFieldGap.java @@ -0,0 +1,30 @@ +package com.hnac.hzims.simulate.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +@TableName("hzinfo_fac_device_attr_gap") +@Data +@AllArgsConstructor +public class DeviceFieldGap implements Serializable { + @ApiModelProperty("id") + @TableId(type = IdType.INPUT) + private String id; + @ApiModelProperty("设备id") + private String facDeviceId; + @ApiModelProperty("字段标识") + private String signage; + @ApiModelProperty("字段名称") + private String name; + @ApiModelProperty("最大值") + private BigDecimal maxVal; + @ApiModelProperty("最小值") + private BigDecimal minVal; +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceRainGap.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceRainGap.java new file mode 100644 index 0000000..5363edd --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/DeviceRainGap.java @@ -0,0 +1,33 @@ +package com.hnac.hzims.simulate.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author ysj + */ +@TableName("hzinfo_fac_device_rain_gap") +@Data +public class DeviceRainGap implements Serializable { + + @ApiModelProperty("id") + @TableId(type = IdType.INPUT) + private String id; + + @ApiModelProperty("设备id") + private String facDeviceId; + + @ApiModelProperty("属性标识名称") + private String name; + + @ApiModelProperty("属性标识") + private String attribute; + + @ApiModelProperty("字段标识") + private String signage; +} \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/Kvtq.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/Kvtq.java new file mode 100644 index 0000000..4a6c839 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/Kvtq.java @@ -0,0 +1,18 @@ +package com.hnac.hzims.simulate.entity; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class Kvtq { + + private String k; + private String v; + private String t; + private Integer q; +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/KvtqV4.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/KvtqV4.java new file mode 100644 index 0000000..a5a8b0e --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/entity/KvtqV4.java @@ -0,0 +1,18 @@ +package com.hnac.hzims.simulate.entity; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class KvtqV4 { + private String sid; + private String k; + private String v; + private String t; + private Integer q; +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFacConfigMapper.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFacConfigMapper.java new file mode 100644 index 0000000..ad70ac9 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFacConfigMapper.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.simulate.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.simulate.entity.DeviceFacConfig; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author ysj + */ +@Mapper +public interface DeviceFacConfigMapper extends BaseMapper { + + List queryConfigDevice(@Param("method") String method); + + DeviceFacConfig configByDeviceCode(@Param("deviceCode") String deviceCode); +} \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFacConfigMapper.xml b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFacConfigMapper.xml new file mode 100644 index 0000000..1dda78c --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFacConfigMapper.xml @@ -0,0 +1,13 @@ + + + + + + + diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldGapMapper.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldGapMapper.java new file mode 100644 index 0000000..d3e85d4 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldGapMapper.java @@ -0,0 +1,16 @@ +package com.hnac.hzims.simulate.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.simulate.entity.DeviceFieldGap; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.math.BigDecimal; +import java.util.List; + +@Mapper +public interface DeviceFieldGapMapper extends BaseMapper { + List queryDeviceLimits(@Param("signages") List signages); + + void updateLimitById(@Param("maxValue") BigDecimal maxValue, @Param("minValue") BigDecimal minValue,@Param("id") String id); +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldMapper.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldMapper.java new file mode 100644 index 0000000..e44fc5d --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldMapper.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.simulate.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.simulate.entity.DeviceField; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +@Mapper +public interface DeviceFieldMapper extends BaseMapper { + int existGapTable(); + int createGapTable(); + List queryNewInsert(); + + List queryDeviceFields(@Param("devices") List devices); + + List querySignages(@Param("facDeviceId") String facDeviceId); +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldMapper.xml b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldMapper.xml new file mode 100644 index 0000000..477ff69 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceFieldMapper.xml @@ -0,0 +1,34 @@ + + + + + + CREATE TABLE hzinfo_device_field_gap ( + id varchar(64) COLLATE utf8mb4_bin NOT NULL COMMENT '字段类型', + fac_device_id varchar(50) COLLATE utf8mb4_bin NOT NULL COMMENT '设备实例id', + signage varchar(25) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '字段标识', + name varchar(100) COLLATE utf8mb4_bin NOT NULL COMMENT '字段名称', + max_val decimal(9,3) DEFAULT NULL, + min_val decimal(9,3) DEFAULT NULL, + PRIMARY KEY (id) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='设备字段' + + + + + + + diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceMapper.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceMapper.java new file mode 100644 index 0000000..4edccd1 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceMapper.java @@ -0,0 +1,15 @@ +package com.hnac.hzims.simulate.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.simulate.entity.Device; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +@Mapper +public interface DeviceMapper extends BaseMapper { + String getSid(@Param("stationId") String stationId); + +// List selectStcd(); +// +// int insertData(@Param("param") Map param); +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceMapper.xml b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceMapper.xml new file mode 100644 index 0000000..19587cf --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceMapper.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceRainGapMapper.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceRainGapMapper.java new file mode 100644 index 0000000..5438aca --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceRainGapMapper.java @@ -0,0 +1,17 @@ +package com.hnac.hzims.simulate.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.simulate.entity.DeviceRainGap; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author ysj + */ +@Mapper +public interface DeviceRainGapMapper extends BaseMapper { + + List RainGapByFacDeviceId(@Param("facDeviceId") String facDeviceId); +} \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceRainGapMapper.xml b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceRainGapMapper.xml new file mode 100644 index 0000000..95d531a --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/DeviceRainGapMapper.xml @@ -0,0 +1,9 @@ + + + + + + diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/IHzllmInteractiveService.xml b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/IHzllmInteractiveService.xml new file mode 100644 index 0000000..7a4fff8 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/mapper/IHzllmInteractiveService.xml @@ -0,0 +1,18 @@ + + + + + + + UPDATE HZINFO_FAC_DEVICE_ATTR_GAP + SET max_val = #{maxValue}, + min_val = #{minValue} + WHERE id = #{id} + + diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/scheduled/WriteRealDataTask.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/scheduled/WriteRealDataTask.java new file mode 100644 index 0000000..3032379 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/scheduled/WriteRealDataTask.java @@ -0,0 +1,53 @@ +package com.hnac.hzims.simulate.scheduled; + +import com.hnac.hzims.simulate.constants.WriteRealDataConstant; +import com.hnac.hzims.simulate.service.WriteRealDataService; +import com.xxl.job.core.biz.model.ReturnT; +import com.xxl.job.core.handler.annotation.XxlJob; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.Func; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import java.util.Date; + + +/** + * @author ysj + * @describe 实时数据写入定时任务 + */ +@Slf4j +@Component +public class WriteRealDataTask { + + @Autowired + private WriteRealDataService writeRealDataService; + + /** + * 设备模型信息 + */ + @XxlJob(WriteRealDataConstant.WRITE_REAL_GATE_DATA) + //@Scheduled(cron = "0/40 * * * * ? ") + public ReturnT writeRealGateData(String param) { + if (Func.isBlank(param)) { + param = DateUtil.format(new Date(), "yyyy-MM"); + } + writeRealDataService.writeRealGateData(param); + return new ReturnT<>("SUCCESS"); + } + + /** + * 设备模型信息 + */ + @XxlJob(WriteRealDataConstant.WRITE_REAL_RAIN_DATA) + //@Scheduled(cron = "0/40 * * * * ? ") + public ReturnT writeRealRainData(String param) { + if (Func.isBlank(param)) { + param = DateUtil.format(new Date(), "yyyy-MM"); + } + writeRealDataService.writeRealRainData(param); + return new ReturnT<>("SUCCESS"); + } +} \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceFieldGapService.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceFieldGapService.java new file mode 100644 index 0000000..99868bb --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceFieldGapService.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.simulate.service; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.hzims.simulate.entity.DeviceFieldGap; +import com.hnac.hzims.simulate.mapper.DeviceFieldGapMapper; +import org.springframework.stereotype.Service; + +@Service +public class DeviceFieldGapService extends ServiceImpl { + +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceFieldService.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceFieldService.java new file mode 100644 index 0000000..c97b7e9 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceFieldService.java @@ -0,0 +1,24 @@ +package com.hnac.hzims.simulate.service; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.hzims.simulate.entity.DeviceField; +import com.hnac.hzims.simulate.mapper.DeviceFieldMapper; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class DeviceFieldService extends ServiceImpl { + + public int existGapTable(){ + return this.baseMapper.existGapTable(); + } + + public int createGapTable(){ + return this.baseMapper.createGapTable(); + } + + public List queryNewInsert(){ + return this.baseMapper.queryNewInsert(); + } +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceService.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceService.java new file mode 100644 index 0000000..494b1e5 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/DeviceService.java @@ -0,0 +1,21 @@ +package com.hnac.hzims.simulate.service; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.hzims.simulate.entity.Device; +import com.hnac.hzims.simulate.mapper.DeviceMapper; +import org.springframework.stereotype.Service; + +@Service +public class DeviceService extends ServiceImpl { + public String getSid(String stationId){ + return this.baseMapper.getSid(stationId); + } + +// public List selectStcd(){ +// return this.baseMapper.selectStcd(); +// } +// +// public int insertData(Map param){ +// return this.baseMapper.insertData(param); +// } +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/SimulationService.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/SimulationService.java new file mode 100644 index 0000000..31903f9 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/SimulationService.java @@ -0,0 +1,280 @@ +package com.hnac.hzims.simulate.service; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.hnac.hzims.simulate.entity.*; +import com.hnac.hzims.simulate.util.DataConstants; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.jackson.JsonUtil; +import org.springblade.core.tool.utils.DateTimeUtil; +import org.springblade.core.tool.utils.ThreadUtil; +import org.springblade.mqtt.producer.IMqttSender; +import com.hnac.hzims.simulate.util.TopicConstant; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; + +@Service +@Slf4j +public class SimulationService { + @Autowired + IMqttSender mqttSender; + + @Autowired + DeviceService deviceService; + + @Autowired + DeviceFieldService deviceFieldService; + + @Autowired + DeviceFieldGapService deviceFieldGapService; + + public List getDeviceListByStationId(String projectId){ + LambdaQueryWrapper lambdaQueryWrapper=new LambdaQueryWrapper(); + lambdaQueryWrapper.eq(Device::getProjectId,projectId); + lambdaQueryWrapper.eq(Device::getIsWrite,"0"); + List list = deviceService.list(lambdaQueryWrapper); + return list; + } + + String getSid(String stationId){ + return deviceService.getSid(stationId); + } + + //模拟启停标识 + private volatile boolean flag=true; + + public void stopStart(){ + flag = !flag; + } + + @Async + public void simulationMultiple(String stationId, Long sleepTime) { + + List list = getDeviceListByStationId(stationId); + //查询所有属性 + List fieldList = deviceFieldService.list(); + List gapList = deviceFieldGapService.list(); + + log.info("本站{}有{}个设备实例,每{}毫秒发送{}条数据", stationId, list.size(), sleepTime, list.size()); + while (true) { + if (flag) {//启动或关闭模拟 + for (Device device : list) { + Map map = simulation(stationId, device,fieldList,gapList); +// log.info("map data: "+ JsonUtil.toJson(map)); + if (map.get("yc") != null && map.get("yc").getChildren().size() > 0) { + log.info("模拟推送遥测,主题:topic_hzinfo_props:{}", JsonUtil.toJson(map.get("yc"))); + mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_PROPS, JsonUtil.toJson(map.get("yc"))); + } +// if (map.get("dd") != null && map.get("dd").getChildren().size() > 0) { +// mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_DD, JsonUtil.toJson(map.get("dd"))); +// } + if (map.get("yx") != null && map.get("yx").getChildren().size() > 0) { + mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_YX, JsonUtil.toJson(map.get("yx"))); + } + } + //最小10毫秒 + if (sleepTime == null || sleepTime == 0) { + sleepTime = 10L; + } + ThreadUtil.sleep(sleepTime); + } + } + } + + +// @Async +// public void simulationMultipleInFlow(){ +// List list=deviceService.selectStcd(); +// while (true) { +// List> datas = simulationFlow(list); +// for(Map param:datas){ +// deviceService.insertData(param); +// } +// ThreadUtil.sleep(3600000); +// } +// } + + private List> simulationFlow(List list){ + List> datas =new ArrayList<>(); + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String dt=sdf.format(new Date()); + for(String stcd:list){ + Map data=new HashMap<>(); + String value = getRandomRedPacketBetweenMinAndMax(new BigDecimal("0"), new BigDecimal("20")).toString(); + data.put("stcd",stcd); + data.put("dt",dt); + data.put("inflow",value); + datas.add(data); + } + return datas; + } + + + @Async + public void simulationMultipleV4(String stationId, Long sleepTime){ + String sid=getSid(stationId); + List list = getDeviceListByStationId(stationId); + //查询所有属性 + List fieldList = deviceFieldService.list(); + List gapList = deviceFieldGapService.list(); + + log.info("本站{}有{}个设备实例,每{}毫秒发送{}条数据", stationId, list.size(), sleepTime, list.size()); + while (true) { + if (flag) {//启动或关闭模拟 + for (Device device : list) { + Map map = simulationV4(stationId,sid, device,fieldList,gapList); + //log.info("map data: "+ JsonUtil.toJson(map)); + if (map.get("yc") != null && map.get("yc").getChildren().size() > 0) { + mqttSender.sendToMqtt("hzinfo_v4_yc", JsonUtil.toJson(map.get("yc"))); + } +// if (map.get("dd") != null && map.get("dd").getChildren().size() > 0) { +// mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_DD, JsonUtil.toJson(map.get("dd"))); +// } + if (map.get("yx") != null && map.get("yx").getChildren().size() > 0) { + mqttSender.sendToMqtt("hzinfo_v4_yx", JsonUtil.toJson(map.get("yx"))); + } + } + //最小10毫秒 + if (sleepTime == null || sleepTime == 0) { + sleepTime = 10L; + } + ThreadUtil.sleep(sleepTime); + } + } + } + + public static BigDecimal getRandomRedPacketBetweenMinAndMax(BigDecimal min, BigDecimal max){ + float minF = min.floatValue(); + float maxF = max.floatValue(); + //生成随机数 + BigDecimal db = new BigDecimal(Math.random() * (maxF - minF) + minF); + //返回保留两位小数的随机数。不进行四舍五入 + return db.setScale(3,BigDecimal.ROUND_DOWN); + } + + public static int getIntBetweenMinAndMax(int min, int max){ + //生成随机数 + int randomNum = min + (int)(Math.random() * ((max - min) + 1)); + //返回保留两位小数的随机数。不进行四舍五入 + return randomNum; + } + + /** + * 模拟一条数据 + */ + private Map simulation(String stationId, Device device,List fieldListAll,List gapListAll) { +// List fieldList = getListByDeviceId(device.getId()); +// List gapList = getListByDeviceGapId(device.getId()); + List fieldList =fieldListAll.stream().filter(e->e.getFacDeviceId().equals(device.getId())).collect(Collectors.toList()); + List gapList =gapListAll.stream().filter(e->e.getFacDeviceId().equals(device.getId())).collect(Collectors.toList()); +// log.info("fieldList data: "+ JsonUtil.toJson(fieldList)); +// log.info("gapList data: "+ JsonUtil.toJson(gapList)); + List ycList = Lists.newArrayList(); + List yxList = Lists.newArrayList(); + //List ddList = Lists.newArrayList(); + for (DeviceField field : fieldList) { + Optional gapOpt=gapList.stream().filter(e->e.getSignage().equals(field.getSignage())).findFirst(); + + if (DataConstants.DeviceDataType.YC.ordinal()== field.getModelClassifyId().intValue()) { + if(gapOpt!=null) { + DeviceFieldGap gap=gapOpt.get(); + String value = getRandomRedPacketBetweenMinAndMax(gap.getMinVal(), gap.getMaxVal()).toString(); + Kvtq kvtq = Kvtq.builder().k(field.getSignage()).v(value).t(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).q(0).build(); + ycList.add(kvtq); + } + } +// if (DataConstants.DeviceDataType.DD.name().equals(field.getType())) { +// String value = Func.random(1, RandomType.INT) + "." + Func.random(1, RandomType.INT); +// Kvtq kvtq = Kvtq.builder().k(field.getId()).v(value).t(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).q(0).build(); +// ddList.add(kvtq); +// } + if (DataConstants.DeviceDataType.YX.ordinal()== field.getModelClassifyId().intValue()) { + if(gapOpt!=null) { + DeviceFieldGap gap=gapOpt.get(); + int value = getIntBetweenMinAndMax(gap.getMinVal().intValue(), gap.getMaxVal().intValue()); + Kvtq kvtq = Kvtq.builder().k(field.getSignage()).v(String.valueOf(value)).t(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).q(0).build(); + yxList.add(kvtq); + } + } + } + Map map = Maps.newHashMap(); + if (ycList.size() > 0) { + map.put("yc", DeviceData.builder().station(stationId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(ycList).build()); + } +// if (ddList.size() > 0) { +// map.put("dd", DeviceData.builder().station(stationId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(ddList).build()); +// } + if (yxList.size() > 0) { + map.put("yx", DeviceData.builder().station(stationId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(yxList).build()); + } + return map; + } + + + private Map simulationV4(String stationId,String sid, Device device,List fieldListAll,List gapListAll) { + +// List fieldList = getListByDeviceId(device.getId()); +// List gapList = getListByDeviceGapId(device.getId()); + List fieldList =fieldListAll.stream().filter(e->e.getFacDeviceId().equals(device.getId())).collect(Collectors.toList()); + List gapList =gapListAll.stream().filter(e->e.getFacDeviceId().equals(device.getId())).collect(Collectors.toList()); +// log.info("fieldList data: "+ JsonUtil.toJson(fieldList)); +// log.info("gapList data: "+ JsonUtil.toJson(gapList)); + List ycList = Lists.newArrayList(); + List yxList = Lists.newArrayList(); + //List ddList = Lists.newArrayList(); + for (DeviceField field : fieldList) { + Optional gapOpt=gapList.stream().filter(e->e.getSignage().equals(field.getSignage())).findFirst(); + + if (DataConstants.DeviceDataType.YC.ordinal()== field.getModelClassifyId().intValue()) { + if(gapOpt!=null) { + DeviceFieldGap gap=gapOpt.get(); + String value = getRandomRedPacketBetweenMinAndMax(gap.getMinVal(), gap.getMaxVal()).toString(); + KvtqV4 kvtq = KvtqV4.builder().sid(sid).k(field.getSignage()).v(value).t(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).q(0).build(); + ycList.add(kvtq); + } + } +// if (DataConstants.DeviceDataType.DD.name().equals(field.getType())) { +// String value = Func.random(1, RandomType.INT) + "." + Func.random(1, RandomType.INT); +// Kvtq kvtq = Kvtq.builder().k(field.getId()).v(value).t(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).q(0).build(); +// ddList.add(kvtq); +// } + if (DataConstants.DeviceDataType.YX.ordinal()== field.getModelClassifyId().intValue()) { + if(gapOpt!=null) { + DeviceFieldGap gap=gapOpt.get(); + int value = getIntBetweenMinAndMax(gap.getMinVal().intValue(), gap.getMaxVal().intValue()); + KvtqV4 kvtq = KvtqV4.builder().sid(sid).k(field.getSignage()).v(String.valueOf(value)).t(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).q(0).build(); + yxList.add(kvtq); + } + } + } + Map map = Maps.newHashMap(); + if (ycList.size() > 0) { + map.put("yc", DeviceDataV4.builder().stationId(stationId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(ycList).build()); + } +// if (ddList.size() > 0) { +// map.put("dd", DeviceData.builder().station(stationId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(ddList).build()); +// } + if (yxList.size() > 0) { + map.put("yx", DeviceDataV4.builder().stationId(stationId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(yxList).build()); + } + return map; + } + + private List getListByDeviceId(String deviceId) { + return deviceFieldService.list(Wrappers.lambdaQuery().ne(DeviceField::getModelClassifyId, DataConstants.DeviceDataType.SOE.name()).eq(DeviceField::getFacDeviceId, deviceId)); + } + + private List getListByDeviceGapId(String deviceId){ + return deviceFieldGapService.list(Wrappers.lambdaQuery().eq(DeviceFieldGap::getFacDeviceId, deviceId)); + } + +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/WriteRealDataService.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/WriteRealDataService.java new file mode 100644 index 0000000..ed500f3 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/WriteRealDataService.java @@ -0,0 +1,13 @@ +package com.hnac.hzims.simulate.service; + +/** + * @author ysj + */ +public interface WriteRealDataService { + + void writeRealGateData(String param); + + void writeRealRainData(String param); + + Boolean isOpen(String deviceCode, Long isOpen); +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/impl/WriteRealDataServiceImpl.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/impl/WriteRealDataServiceImpl.java new file mode 100644 index 0000000..4a49938 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/service/impl/WriteRealDataServiceImpl.java @@ -0,0 +1,304 @@ +package com.hnac.hzims.simulate.service.impl; + +import com.hnac.hzims.equipment.entity.EmInfoEntity; +import com.hnac.hzims.equipment.feign.IEmInfoClient; +import com.hnac.hzims.hzimsweather.feign.IHeWeatherWeatherClient; +import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherNowResponse; +import com.hnac.hzims.simulate.constants.WriteRealDataConstant; +import com.hnac.hzims.simulate.entity.*; +import com.hnac.hzims.simulate.mapper.DeviceFacConfigMapper; +import com.hnac.hzims.simulate.mapper.DeviceFieldGapMapper; +import com.hnac.hzims.simulate.mapper.DeviceFieldMapper; +import com.hnac.hzims.simulate.mapper.DeviceRainGapMapper; +import com.hnac.hzims.simulate.service.WriteRealDataService; +import com.hnac.hzims.simulate.util.DataConstants; +import com.hnac.hzims.simulate.util.TopicConstant; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.jackson.JsonUtil; +import org.springblade.core.tool.utils.*; +import org.springblade.mqtt.producer.IMqttSender; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.text.DecimalFormat; +import java.time.LocalDateTime; +import java.util.Date; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +import static com.hnac.hzims.simulate.constants.WriteRealDataConstant.REAL_DATA_V3; +import static com.hnac.hzims.simulate.constants.WriteRealDataConstant.REAL_DATA_V4; + +/** + * @author ysj + */ +@Service +@Slf4j +@RequiredArgsConstructor +public class WriteRealDataServiceImpl implements WriteRealDataService { + + private final IEmInfoClient deviceClient; + + private final IHeWeatherWeatherClient weatherClient; + + private final IMqttSender mqttSender; + + private final DeviceFieldMapper fieldMapper; + + private final DeviceFieldGapMapper limitMapper; + + private final DeviceFacConfigMapper configMapper; + + private final DeviceRainGapMapper deviceRainGapMapper; + + /** + * 实时数据写入 + * @param param + */ + @Override + public void writeRealGateData(String param) { + // 查询设备配置 + List configs = configMapper.queryConfigDevice(WriteRealDataConstant.WRITE_GATE); + if(CollectionUtil.isEmpty(configs)){ + return; + } + //#.000 表示三位小数 + DecimalFormat df = new DecimalFormat("#0.000"); + // 遍历发送mqtt实时数据 + configs.stream().collect(Collectors.groupingBy(DeviceFacConfig::getModelKind)).forEach((modeKind,groups)->{ + // 查询设备属性 + List fields = fieldMapper.queryDeviceFields(groups.stream().map(DeviceFacConfig::getFacDeviceId).collect(Collectors.toList())); + if(CollectionUtil.isEmpty(fields)){ + return; + } + // 查询设备限制 + List limits = limitMapper.queryDeviceLimits(fields.stream().map(DeviceField::getSignage).collect(Collectors.toList())); + if(CollectionUtil.isEmpty(limits)){ + return; + } + // v3 + if(REAL_DATA_V3.equals(modeKind)){ + fields.stream().collect(Collectors.groupingBy(DeviceField::getModelClassifyId)).forEach((key, models) -> models.stream().collect(Collectors.groupingBy(DeviceField::getProjectId)).forEach((projectId, value)-> { + // 遥测实时数据对象 + List ycs = value.stream().filter(o -> DataConstants.DeviceDataType.YC.ordinal() == o.getModelClassifyId()).map(field -> { + List limit = limits.stream().filter(e -> e.getSignage().equals(field.getSignage())).collect(Collectors.toList()); + if (CollectionUtil.isEmpty(limit)) { + return new Kvtq(); + } + Kvtq real = new Kvtq(); + double random = Math.random() * limit.get(0).getMaxVal().subtract(limit.get(0).getMinVal()).doubleValue() + limit.get(0).getMinVal().doubleValue(); + real.setK(field.getSignage()); + real.setV(df.format(random)); + real.setT(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS")); + real.setQ(0); + return real; + }).filter(ObjectUtil::isNotEmpty).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(ycs)) { + log.error("yc_real_data_v3 : {}", JsonUtil.toJson(DeviceData.builder().station(projectId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(ycs).build())); + mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_PROPS, JsonUtil.toJson(DeviceData.builder().station(projectId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(ycs).build())); + } + // 遥信实时数据对象 + List yxs = value.stream().filter(o -> DataConstants.DeviceDataType.YX.ordinal() == o.getModelClassifyId()).map(field -> { + List limit = limits.stream().filter(e -> e.getSignage().equals(field.getSignage())).collect(Collectors.toList()); + if (CollectionUtil.isEmpty(limit)) { + return new Kvtq(); + } + Kvtq real = new Kvtq(); + double random = limit.get(0).getMaxVal().subtract(limit.get(0).getMinVal()).doubleValue() + limit.get(0).getMinVal().doubleValue(); + real.setK(field.getSignage()); + real.setV(df.format(random)); + real.setT(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS")); + real.setQ(0); + return real; + }).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(yxs)) { + log.error("yx_real_data_v3 : {}", JsonUtil.toJson(DeviceData.builder().station(projectId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(yxs).build())); + mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_YX, JsonUtil.toJson(DeviceData.builder().station(projectId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(yxs).build())); + } + })); + } + // v4 + if(REAL_DATA_V4.equals(modeKind)){ + fields.stream().collect(Collectors.groupingBy(DeviceField::getModelClassifyId)).forEach((key, models) -> models.stream().collect(Collectors.groupingBy(DeviceField::getProjectId)).forEach((projectId, value)->{ + // 遥测实时数据对象 + List ycs = value.stream().filter(o -> DataConstants.DeviceDataType.YC.ordinal() == o.getModelClassifyId()).map(field -> { + List limit = limits.stream().filter(e -> e.getSignage().equals(field.getSignage())).collect(Collectors.toList()); + if (CollectionUtil.isEmpty(limit)) { + return new KvtqV4(); + } + // 查找sid + Optional sid = groups.stream().filter(group->field.getFacDeviceId().equals(group.getFacDeviceId())).findFirst(); + if(!sid.isPresent()){ + return new KvtqV4(); + } + KvtqV4 real = new KvtqV4(); + double random = Math.random() * limit.get(0).getMaxVal().subtract(limit.get(0).getMinVal()).doubleValue() + limit.get(0).getMinVal().doubleValue(); + real.setSid(sid.get().getSid()); + real.setK(field.getSignage()); + real.setV(df.format(random)); + real.setT(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS")); + real.setQ(0); + return real; + }).filter(ObjectUtil::isNotEmpty).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(ycs)) { + log.error("yc_real_data_v4 : {}",JsonUtil.toJson(DeviceDataV4.builder().stationId(projectId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(ycs).build())); + mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_V4_YC,JsonUtil.toJson(DeviceDataV4.builder().stationId(projectId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(ycs).build())); + } + // 遥信实时数据对象 + List yxs = value.stream().filter(o -> DataConstants.DeviceDataType.YX.ordinal() == o.getModelClassifyId()).map(field -> { + List limit = limits.stream().filter(e -> e.getSignage().equals(field.getSignage())).collect(Collectors.toList()); + if (CollectionUtil.isEmpty(limit)) { + return new KvtqV4(); + } + // 查找sid + Optional sid = groups.stream().filter(group->field.getFacDeviceId().equals(group.getFacDeviceId())).findFirst(); + if(!sid.isPresent()){ + return new KvtqV4(); + } + KvtqV4 real = new KvtqV4(); + double random = limit.get(0).getMaxVal().subtract(limit.get(0).getMinVal()).doubleValue() + limit.get(0).getMinVal().doubleValue(); + real.setSid(sid.get().getSid()); + real.setK(field.getSignage()); + real.setV(df.format(random)); + real.setT(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS")); + real.setQ(0); + return real; + }).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(yxs)) { + log.error("yx_real_data_v4 : {}",JsonUtil.toJson(DeviceDataV4.builder().stationId(projectId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(yxs).build())); + mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_V4_YX,JsonUtil.toJson(DeviceDataV4.builder().stationId(projectId).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(yxs).build())); + } + })); + } + }); + } + + /** + * 雨量站实时数据写入 + * @param param + */ + @Override + public void writeRealRainData(String param) { + // 查询设备配置 + List configs = configMapper.queryConfigDevice(WriteRealDataConstant.WRITE_RAIN); + if(CollectionUtil.isEmpty(configs)){ + return; + } + R> devices = deviceClient.getEmInfoByEmCodes(configs.stream().map(DeviceFacConfig::getDeviceCode).collect(Collectors.toList())); + if(!devices.isSuccess() || CollectionUtil.isEmpty(devices.getData())){ + return; + } + devices.getData().forEach(device->{ + if(ObjectUtil.isEmpty(device.getLgtd()) || ObjectUtil.isEmpty(device.getLttd())){ + return; + } + // 查询设备经纬度 + String location = device.getLgtd() + "," + device.getLttd(); + R weather = weatherClient.getWeatherNowWithCache(location); + if(!weather.isSuccess() || ObjectUtil.isEmpty(weather.getData()) || ObjectUtil.isEmpty(weather.getData().getNow())){ + return; + } + Optional optional = configs.stream().filter(o->o.getDeviceCode().equals(device.getNumber())).findFirst(); + if(!optional.isPresent()){ + return; + } + List deviceRainGap = deviceRainGapMapper.RainGapByFacDeviceId(optional.get().getFacDeviceId()); + if(CollectionUtil.isEmpty(deviceRainGap)){ + return; + } + List yxs = deviceRainGap.stream().map(o->{ + KvtqV4 real = new KvtqV4(); + real.setSid(optional.get().getSid()); + real.setK(o.getSignage()); + real.setT(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS")); + real.setQ(0); + if(WriteRealDataConstant.ATTR_RAIN.equals(o.getAttribute())){ + real.setV(weather.getData().getNow().getPrecip()); + }else if(WriteRealDataConstant.ATTR_WIND360.equals(o.getAttribute())){ + real.setV(weather.getData().getNow().getWind360()); + }else if(WriteRealDataConstant.ATTR_WIND_SCALE.equals(o.getAttribute())){ + real.setV(weather.getData().getNow().getWindScale()); + }else if(WriteRealDataConstant.ATTR_WIND_SPEED.equals(o.getAttribute())){ + real.setV(weather.getData().getNow().getWindSpeed()); + }else if(WriteRealDataConstant.ATTR_HUMIDITY.equals(o.getAttribute())){ + real.setV(weather.getData().getNow().getHumidity()); + }else if(WriteRealDataConstant.ATTR_PRESSURE.equals(o.getAttribute())){ + real.setV(weather.getData().getNow().getPressure()); + }else if(WriteRealDataConstant.ATTR_VIS.equals(o.getAttribute())){ + real.setV(weather.getData().getNow().getVis()); + }else if(WriteRealDataConstant.ATTR_CLOUD.equals(o.getAttribute())){ + real.setV(weather.getData().getNow().getCloud()); + }else if(WriteRealDataConstant.ATTR_DEW.equals(o.getAttribute())){ + real.setV(weather.getData().getNow().getDew()); + }else if(WriteRealDataConstant.ATTR_FEELS_LIKE.equals(o.getAttribute())){ + real.setV(weather.getData().getNow().getFeelsLike()); + }else if(WriteRealDataConstant.ATTR_TEMP.equals(o.getAttribute())){ + real.setV(weather.getData().getNow().getTemp()); + } + if(StringUtil.isEmpty(real.getV())){ + real.setV("0.0"); + } + return real; + }).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(yxs)) { + log.error("yx_real_data_v4 : {}",JsonUtil.toJson(DeviceDataV4.builder().stationId(optional.get().getStationId()).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(yxs).build())); + mqttSender.sendToMqtt(TopicConstant.TOPIC_HZINFO_V4_YX,JsonUtil.toJson(DeviceDataV4.builder().stationId(optional.get().getStationId()).time(DateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss.SSS")).children(yxs).build())); + } + }); + } + + /** + * 开启/关闭闸门数据 + * @param deviceCode + * @param isOpen + * @return + */ + @Override + public Boolean isOpen(String deviceCode, Long isOpen) { + // 查询写入设备配置 + DeviceFacConfig config = configMapper.configByDeviceCode(deviceCode); + if(ObjectUtil.isEmpty(config)){ + return false; + } + // 查询设备属性 + List fields = fieldMapper.querySignages(config.getFacDeviceId()); + if(CollectionUtil.isEmpty(fields)){ + return false; + } + // 查询属性限制 + List limits = limitMapper.queryDeviceLimits(fields.stream().map(DeviceField::getSignage).collect(Collectors.toList())); + if(CollectionUtil.isEmpty(limits)){ + return false; + } + limits.forEach(limit->{ + Optional optional = fields.stream().filter(o->o.getSignage().equals(limit.getSignage())).findFirst(); + if(!optional.isPresent()){ + return; + } + String signage = optional.get().getName(); + if(WriteRealDataConstant.GATE_STATUS.equals(signage)){ + if(WriteRealDataConstant.OPEN.equals(isOpen)){ + limitMapper.updateLimitById(BigDecimal.ONE,BigDecimal.ZERO,limit.getId()); + }else{ + limitMapper.updateLimitById(BigDecimal.ZERO,BigDecimal.ZERO,limit.getId()); + } + }else if(WriteRealDataConstant.GATE_FLOW.equals(signage)){ + if(WriteRealDataConstant.OPEN.equals(isOpen)){ + limitMapper.updateLimitById(BigDecimal.valueOf(3560.000),BigDecimal.valueOf(0.000),limit.getId()); + }else{ + limitMapper.updateLimitById(BigDecimal.ZERO,BigDecimal.ZERO,limit.getId()); + } + }else if(WriteRealDataConstant.OPENING_DEGREE.equals(signage)){ + if(WriteRealDataConstant.OPEN.equals(isOpen)){ + limitMapper.updateLimitById(BigDecimal.valueOf(10),BigDecimal.valueOf(0.000),limit.getId()); + }else{ + limitMapper.updateLimitById(BigDecimal.ZERO,BigDecimal.ZERO,limit.getId()); + } + } + }); + return true; + } +} \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/DataConstants.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/DataConstants.java new file mode 100644 index 0000000..a4873df --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/DataConstants.java @@ -0,0 +1,357 @@ +package com.hnac.hzims.simulate.util; + +public interface DataConstants { + String REDIS_MESSAGE_TOPIC = "hzinfo_config_message_topic"; + String TIME_COLUMN = "ts"; + String VALUE_COLUMN = "val"; + String Q_COLUMN = "q"; + String REAL_ID_COLUMN = "realid"; + String TBNAME = "tbname"; + String YC_TABLE_PREFIX = "yc_"; + String YX_TABLE_PREFIX = "yx_"; + String SOE_TABLE_PREFIX = "soe_"; + String SOE_ALARM_TABLE_PREFIX = "soe_alarm_"; + String YC = "YC"; + String YX = "YX"; + String SOE = "SOE"; + String YK_RETURN_PREFIX = "ykfj:"; + String REALID_CALCULATE = "16777215"; + String DEVICE_SUPER_TABLE_PREFIX = "hz_"; + String DEVICE_TABLE_PREFIX = "d_"; + + public static enum DataStructTypeEnum { + struct, + dataGroup; + + private DataStructTypeEnum() { + } + } + + public static enum EYkRetStatus { + yrsSuccess, + yrsServerErr, + yrsChannelErr, + yrsModuleErr, + yrsDeviceTimeOut, + yrsDeviceFail, + yrsExpired; + + private EYkRetStatus() { + } + } + + public static enum SoeType { + skNone(0, "0", "默认"), + skSys(1, "1", "系统"), + skAlarm(2, "2", "报警"), + skAct(3, "3", "事故"), + skOperate(4, "4", "用户操作"), + skYcOut(5, "5,11,12", "遥测越限"), + skYxChange(6, "6,10", "遥信变位"), + skReg(7, "7", "注册信息"), + skHint(8, "8", "信息提示"), + skInspect(9, "9", "设备巡检"), + skMonitorOperate(10, "13,14", "遥控操作"), + skRDSYcOutOfLimitResume(11, "15", "遥测越限恢复"), + skUndefine(12, "16,17,18", "未定义"), + skNetworkAnomaly(13, "-1", "通讯异常"), + skCommunicateAnomaly(14, "-2", "数据异常"); + + private Integer index; + private String soeKind; + private String name; + + private SoeType(Integer index, String soeKind, String name) { + this.index = index; + this.soeKind = soeKind; + this.name = name; + } + + public static String getName(Integer id) { + SoeType[] values = values(); + + for (int i = 0; i < values.length; ++i) { + if (values[i].index.equals(id)) { + return values[i].getName(); + } + } + + return null; + } + + public static Integer getIndexBySoeKind(String soeType) { + SoeType[] values = values(); + SoeType[] var2 = values; + int var3 = values.length; + + for (int var4 = 0; var4 < var3; ++var4) { + SoeType type = var2[var4]; + if (type.getSoeKind().contains(soeType)) { + return type.getIndex(); + } + } + + return skUndefine.getIndex(); + } + + public static String getSoeKindByIndex(Integer index) { + SoeType[] values = values(); + SoeType[] var2 = values; + int var3 = values.length; + + for (int var4 = 0; var4 < var3; ++var4) { + SoeType type = var2[var4]; + if (type.getIndex().equals(index)) { + return type.getSoeKind(); + } + } + + return ""; + } + + public Integer getIndex() { + return this.index; + } + + public String getSoeKind() { + return this.soeKind; + } + + public String getName() { + return this.name; + } + } + + public static enum SoeKind { + skNone(0, "默认"), + skSys(1, "系统"), + skAlarm(2, "报警"), + skAct(3, "事故"), + skOperate(4, "操作"), + skYcOut(5, "遥测越限(告警)"), + skYxChange(6, "遥信变位(告警)"), + skReg(7, "注册信息"), + skHint(8, "信息提示"), + skInspect(9, "设备巡检"), + skRDSYxChange(10, "遥信变位(数据)"), + skRDSYcOutOfLimit(11, "遥测越上/下限(数据)"), + skRDSYcOutOfLimit2(12, "遥测越上上/下下限(数据)"), + skMonitorOperate(13, "操作记录(遥控)"), + skMonitorOperateII(14, "操作记录(写定值)"), + skRDSYcOutOfLimitResume(15, "越限恢复"), + bak_7(16, "备用7"), + bak_8(17, "备用8"), + skUndefine(18, "未定义"); + + private Integer index; + private String name; + + private SoeKind(Integer index, String name) { + this.index = index; + this.name = name; + } + + public static String getName(Integer id) { + SoeKind[] values = values(); + + for (int i = 0; i < values.length; ++i) { + if (values[i].index.equals(id)) { + return values[i].getName(); + } + } + + return null; + } + + public Integer getIndex() { + return this.index; + } + + public String getName() { + return this.name; + } + } + + public static enum DeviceDataType { + YC("遥测"), + YX("遥信"), + DD("电渡"), + YK("遥控"), + YT("遥调"), + SOE("事件"), + STR("字符串"), + OTHER("其它"); + + private String displayName; + + private DeviceDataType(String displayName) { + this.displayName = displayName; + } + + public static String getDisplayName(String name) { + DeviceDataType type = valueOf(name); + return type.getDisplayName(); + } + + public String getDisplayName() { + return this.displayName; + } + } + + public static enum YkDelayType { + none_store, + store, + delay_store; + + private YkDelayType() { + } + } + + public static enum RedisGroupMessageTypeEnum { + NOTICE_CLEAN_LOCAL_CACHE_DEVICE("clean.local.cache.device"), + NOTICE_CLEAN_LOCAL_CACHE_DEVICE_GROUP("clean.local.cache.group"), + NOTICE_CLEAN_LOCAL_CACHE_ALARM("clean.local.cache.alarm"), + NOTICE_CLEAN_LOCAL_CACHE_YK("clean.local.cache.yk"); + + private String value; + + private RedisGroupMessageTypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return this.value; + } + } + + public static enum DataStatusEnum { + offline, + online; + + private DataStatusEnum() { + } + } + + public static enum StatisticsType { + avg("AVG"), + max("MAX"), + min("MIN"); + + private String computeStrategy; + + private StatisticsType(String fun) { + this.computeStrategy = fun; + } + + public static StatisticsType getStatisticsType(int index) { + StatisticsType[] values = values(); + StatisticsType[] var2 = values; + int var3 = values.length; + + for (int var4 = 0; var4 < var3; ++var4) { + StatisticsType value = var2[var4]; + if (index == value.ordinal()) { + return value; + } + } + + return null; + } + + public String getComputeStrategy() { + return this.computeStrategy; + } + + public void setComputeStrategy(final String computeStrategy) { + this.computeStrategy = computeStrategy; + } + } + + public static enum AnalyzeInstanceAlarmConfType { + changeAlarm("变化告警"), + supassAlarm("越限告警"); + + private String name; + + private AnalyzeInstanceAlarmConfType(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + } + + public static enum StatisticsAnalyEnum { + Hour("h"), + Day("d"), + Month("n"), + Year("h"); + + private String type; + + private StatisticsAnalyEnum(String fun) { + this.type = fun; + } + + public static StatisticsAnalyEnum getStatisticsAnalyEnum(int index) { + StatisticsAnalyEnum[] values = values(); + StatisticsAnalyEnum[] var2 = values; + int var3 = values.length; + + for (int var4 = 0; var4 < var3; ++var4) { + StatisticsAnalyEnum value = var2[var4]; + if (value.ordinal() == index) { + return value; + } + } + + return null; + } + + public String getType() { + return this.type; + } + } + + public static enum StationFromSouceEnum { + cloud, + station; + + private StationFromSouceEnum() { + } + } + + public static enum AnalyzeInstanceDataResoureEnum { + deviceUp("设备上报"), + hz3000Up("华自网关上报"); + + private String name; + + private AnalyzeInstanceDataResoureEnum(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + } + + public static enum ThresholdLevelEnum { + one, + two, + three; + + private ThresholdLevelEnum() { + } + } + + public static enum Hz3000VersionEnum { + v3, + v4; + + private Hz3000VersionEnum() { + } + } + +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/ParseFacUtils.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/ParseFacUtils.java new file mode 100644 index 0000000..34d7437 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/ParseFacUtils.java @@ -0,0 +1,105 @@ +package com.hnac.hzims.simulate.util; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.google.common.collect.Lists; +import com.hnac.hzims.simulate.entity.DataItem; +import com.hnac.hzims.simulate.entity.DataModel; +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.Element; +import org.dom4j.io.SAXReader; +import org.xml.sax.SAXException; + +import java.io.InputStream; +import java.math.BigInteger; +import java.util.List; + +/** + * 解析厂信息工具类 + * @author ninglong + */ +public class ParseFacUtils { + + public static List parsePoint(InputStream inputStream) throws SAXException, DocumentException, JsonProcessingException { + SAXReader saxReader = new SAXReader(); + Document document = saxReader.read(inputStream); + List groupElements = document.selectNodes("/Factorys/Factory/Group"); + List list = parseDataGroup(groupElements); + List ycElements = document.selectNodes("/Factorys/Factory/Group/AIS/AI"); + list = pastePointElement(ycElements, DataConstants.DeviceDataType.YC.name(),list); + + List yxElements = document.selectNodes("/Factorys/Factory/Group/DIS/DI"); + list = pastePointElement(yxElements, DataConstants.DeviceDataType.YX.name(),list); + + List ddElements = document.selectNodes("/Factorys/Factory/Group/DDS/DD"); + list = pastePointElement(ddElements, DataConstants.DeviceDataType.DD.name(),list); + + List soeElements = document.selectNodes("/Factorys/Factory/Group/SOES/SOE"); + list = pastePointElement(soeElements, DataConstants.DeviceDataType.SOE.name(),list); + + List ykElements = document.selectNodes("/Factorys/Factory/Group/DOS/DO"); + list = pastePointElement(ykElements, DataConstants.DeviceDataType.YK.name(),list); + return list; + } + + /** + * 解析数据组 + */ + private static List parseDataGroup(List elements){ + List list = Lists.newArrayList(); + for (Element element : (List) elements) { + DataModel model = new DataModel(); + model.setStructType(DataConstants.DataStructTypeEnum.dataGroup.name()); + model.setId(element.attribute("ID").getValue()); + model.setSignage(bigId2SmallId(element.attribute("ID").getValue())); + model.setName(element.attribute("Name").getValue()); + String stationNumStr = element.getParent().attribute("StationNum").getValue(); + model.setStation(stationNumStr); + list.add(model); + } + return list; + } + + /** + * 将大id转换成小id + */ + public static String bigId2SmallId(String realId){ + BigInteger bigRealId = new BigInteger(realId); + return bigRealId.and(new BigInteger(DataConstants.REALID_CALCULATE)).toString(); + } + /** + * 解析数据点 + */ + private static List pastePointElement(List elements, String type, List list) throws JsonProcessingException { + for (Element element : (List) elements) { + String groupId = element.getParent().getParent().attribute("ID").getValue(); + for(DataModel dm:list){ + if(!groupId.equals(dm.getId())){ + continue; + } + DataItem dataItem = DataItem.builder() + .id(element.attribute("ID").getValue()) + .signage(bigId2SmallId(element.attribute("ID").getValue())) + .name(element.attribute("Name").getValue()) + .type(type) + .build(); + if(DataConstants.DeviceDataType.SOE.name().equals(type)){ + dataItem.setEventType(element.attribute("SOEAlarmType").getValue()); + dataItem.setSoeType(element.attribute("SOEType").getValue()); + } + if(DataConstants.DeviceDataType.YX.name().equals(type)){ + dataItem.setEventType(element.attribute("YXAlarmType").getValue()); + dataItem.setSoeType(element.attribute("SOEType").getValue()); + } + List childrens = dm.getChildren(); + if(childrens==null){ + childrens = Lists.newArrayList(); + } + childrens.add(dataItem); + dm.setChildren(childrens); + } + } + return list; + } +} + diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/RealIdConvertUtils.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/RealIdConvertUtils.java new file mode 100644 index 0000000..f5d3282 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/RealIdConvertUtils.java @@ -0,0 +1,52 @@ +package com.hnac.hzims.simulate.util; + + +import java.math.BigInteger; + +public class RealIdConvertUtils { + + private void demo() { + BigInteger ss = new BigInteger("16777215"); + BigInteger s = new BigInteger("15122982502953650999"); + BigInteger stationId = s.shiftRight(24); + System.out.println(stationId.toString()); + BigInteger realId = s.and(ss); + System.out.println(realId.toString()); + + BigInteger xxx = stationId.shiftLeft(24); + BigInteger yyy = xxx.or(realId); + System.out.println(s.toString()); + System.out.println(yyy.toString()); + } + + /** + * 将大id转换成小id + */ + public static String bigId2SmallId(String realId) { + BigInteger bigRealId = new BigInteger(realId); + return bigRealId.and(new BigInteger(DataConstants.REALID_CALCULATE)).toString(); + } + + /** + * 将小id转换成大id + */ + public static String smallId2BigId(String station, String realId) { + BigInteger stationId = new BigInteger(station); + BigInteger BigRealId = stationId.shiftLeft(24).or(new BigInteger(realId)); + return BigRealId.toString(); + } + +// public static void main(String[] args) { +// System.out.println(RealIdConvertUtils.getStationId("262952509021093892")); +// System.out.println(RealIdConvertUtils.bigId2SmallId("262952509021093892")); +// System.out.println(smallId2BigId("15673190893", "32")); +// } + + /** + * 获取站点id + */ + public static String getStationId(String realId) { + BigInteger bigRealId = new BigInteger(realId); + return bigRealId.shiftRight(24).toString(); + } +} diff --git a/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/TopicConstant.java b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/TopicConstant.java new file mode 100644 index 0000000..1d4a8ca --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/java/com/hnac/hzims/simulate/util/TopicConstant.java @@ -0,0 +1,18 @@ +package com.hnac.hzims.simulate.util; + +public interface TopicConstant { + String TOPIC_DEVICE_MODEL = "topic_device_model"; + String TOPIC_HZINFO_PROPS = "topic_hzinfo_props"; + String TOPIC_HZINFO_V4_YC = "hzinfo_v4_yc"; + + String TOPIC_HZINFO_V4_YX = "hzinfo_v4_yx"; + + String TOPIC_HZINFO_YX = "topic_hzinfo_yx"; + String TOPIC_HZINFO_DD = "topic_hzinfo_dd"; + String TOPIC_HZINFO_EVENTS = "topic_hzinfo_events"; + String TOPIC_HZINFO_EVENTS_ALARM = "topic_hzinfo_events_alarm"; + String TOPIC_HZINFO_CONTROL_RETURN = "topic_hzinfo_control_return"; + String TOPIC_HZINFO_HEART_BEAT = "topic_hzinfo_heart_beat"; + String TOPIC_HZINFO_BROADCAST = "topic_hzinfo_broadcast"; + String TOPIC_HZINFO_DATA = "topic_hzinfo_data"; +} diff --git a/hzims-service/hzims-simulate/src/main/resources/application-dev.yml b/hzims-service/hzims-simulate/src/main/resources/application-dev.yml new file mode 100644 index 0000000..0abb9d3 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/resources/application-dev.yml @@ -0,0 +1,13 @@ +#服务器端口 +server: + port: 8211 + +#数据源配置 +spring: + datasource: + url: ${blade.datasource.dev.url} + username: ${blade.datasource.dev.username} + password: ${blade.datasource.dev.password} + cloud: + inetutils: + preferred-networks: 192.168.65 diff --git a/hzims-service/hzims-simulate/src/main/resources/application-prod.yml b/hzims-service/hzims-simulate/src/main/resources/application-prod.yml new file mode 100644 index 0000000..a96da50 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/resources/application-prod.yml @@ -0,0 +1,6 @@ +#数据源配置 +spring: + datasource: + url: ${blade.datasource.prod.url} + username: ${blade.datasource.prod.username} + password: ${blade.datasource.prod.password} \ No newline at end of file diff --git a/hzims-service/hzims-simulate/src/main/resources/application.yml b/hzims-service/hzims-simulate/src/main/resources/application.yml new file mode 100644 index 0000000..61e8ff7 --- /dev/null +++ b/hzims-service/hzims-simulate/src/main/resources/application.yml @@ -0,0 +1,15 @@ +spring: + application: + name: lewa-simulate + +#mybatis-plus配置 +mybatis-plus: + mapper-locations: classpath:org/springbalde/**/mapper/*Mapper.xml,classpath:com/hnac/hzinfo/**/mapper/*Mapper.xml + #实体扫描,多个package用逗号或者分号分隔 + typeAliasesPackage: org.springbalde.**.entity,com.hnac.hzinfo.**.entity + +#swagger扫描路径配置 +swagger: + base-packages: + - org.springbalde + - com.hnac.hzinfo \ No newline at end of file diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/controller/RobotController.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/controller/RobotController.java index 73f8e2a..d7f3a3b 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/controller/RobotController.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/controller/RobotController.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzinfo.inspect.Constants; import com.hnac.hzinfo.inspect.ai.dto.robot.RobotInstanceDTO; +import com.hnac.hzinfo.inspect.ai.vo.RemoteControlDTO; import com.hnac.hzinfo.inspect.ai.vo.robot.RobotAiReturnData; import com.hnac.hzinfo.inspect.ai.vo.robot.RobotRealDataVO; import com.hnac.hzinfo.inspect.ai.vo.robot.RobotServerTaskParam; @@ -69,6 +70,8 @@ public class RobotController extends BladeController { @Operate(label = "查看机器人详情",type = BusinessType.QUERY,ignore = false) public R detail(RobotEntity st_robot) { RobotEntity detail = st_robotService.getOne(Condition.getQueryWrapper(st_robot)); + User user = UserCache.getUser(detail.getUserId()); + detail.setUserName(Optional.ofNullable(user).map(User::getName).orElse(null)); return R.data(detail); } @@ -197,4 +200,13 @@ public class RobotController extends BladeController { @RequestParam @ApiParam("结束时间") String endTime, Query query) { return R.data(st_robotService.getRobotSoeData(robotCode,startTime,endTime,query)); } + + + @PostMapping("/remoteControl") + @ApiOperationSupport(order = 13) + @ApiOperation(value = "机器人远程控制", notes = "机器人远程控制") + @Operate(label = "机器人远程控制",type = BusinessType.UPDATE,risk = Risk.HIGH,ignore = false) + public R sendToDevice(@RequestBody RemoteControlDTO dto) { + return R.data(st_robotService.remoteControl(dto)); + } } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/IRobotService.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/IRobotService.java index 629d91c..9539e9e 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/IRobotService.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/IRobotService.java @@ -1,9 +1,11 @@ package com.hnac.hzinfo.inspect.ai.service; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; import com.hnac.hzinfo.inspect.ai.dto.robot.RobotInstanceDTO; +import com.hnac.hzinfo.inspect.ai.vo.RemoteControlDTO; import com.hnac.hzinfo.inspect.ai.vo.RobotVO; import com.hnac.hzinfo.inspect.ai.vo.robot.RobotRealDataVO; import com.hnac.hzinfo.sdk.v5.device.vo.VirtualDeviceDTO; @@ -43,4 +45,8 @@ public interface IRobotService extends IService { Map> getRealDataByRobotCode(String robotCode); IPage getRobotSoeData(String robotCode, String startTime, String endTime, Query query); + + Object remoteControl(RemoteControlDTO dto); + + } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotTaskServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotTaskServiceImpl.java index 9cbb33a..0a149ef 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotTaskServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotTaskServiceImpl.java @@ -233,6 +233,7 @@ public class RobotTaskServiceImpl extends ServiceImpl + + diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/ITaskService.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/ITaskService.java index d8e1755..d59e86c 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/ITaskService.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/ITaskService.java @@ -193,4 +193,6 @@ public interface ITaskService extends IService { List getTaskListStatistics(String startTime, String endTime,Long deptId); List exportTaskList(TaskDTO task); + + List getListByUserIdAndStatus(Long userId, List taskStatus,String time); } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java index 60a9e55..63450d1 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java @@ -1198,4 +1198,9 @@ public class TaskServiceImpl extends ServiceImpl impleme return voteChartVo; } + @Override + public List getListByUserIdAndStatus(Long userId, List taskStatus,String time) { + return this.baseMapper.getListByUserIdAndStatus(userId, PlanContants.InspectTypeEnum.ROBOT.getVal(),taskStatus,time); + } + } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/controller/GenerateController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/controller/GenerateController.java index a957527..3e2672f 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/controller/GenerateController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/controller/GenerateController.java @@ -80,4 +80,13 @@ public class GenerateController extends BladeController { return service.pageCondition(filter, query); } + /** + * 新增 + */ + @PostMapping("/test") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "测试发电量保存", notes = "传入InsertPowerEntity对象") + public R test(@RequestBody GenerateEntity entity) { + return R.status(service.test(entity)); + } } \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/GenerateService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/GenerateService.java index 4a0e71b..e31d0b1 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/GenerateService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/GenerateService.java @@ -38,4 +38,6 @@ public interface GenerateService extends IService { List generateThreeYear(String start, String end, String station); List fillPowerMon(String code); + + boolean test(GenerateEntity entity); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java index ae353d2..a7b95e2 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java @@ -26,10 +26,7 @@ import org.springblade.core.tool.utils.StringUtil; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; /** @@ -60,7 +57,7 @@ public class GenerateServiceImpl extends ServiceImpl 0){ + entity.setId(null); + entity.setFillDate(DateUtil.format(start,DateUtil.PATTERN_DATE)); + entity.setGenerate((random.nextDouble() * 1360) + 19000); + this.save(entity); + calendar.add(Calendar.DAY_OF_MONTH,1); + start = calendar.getTime(); + } + return true; + } + /** * 获取近年月份集合 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 97b7e41..7c7d3b2 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 @@ -619,6 +619,8 @@ public class HydropowerServiceImpl implements HydropowerService { // 年发电量 kpi.setGenerateYear(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum()); // 月发电量 + + kpi.setGenerateMon(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerMon).sum()); // 日发电量 kpi.setGenerateDay(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerDay).sum()); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/GenerationReportController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/GenerationReportController.java new file mode 100644 index 0000000..b462792 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/GenerationReportController.java @@ -0,0 +1,34 @@ +package com.hnac.hzims.operational.report.controller; + +import com.hnac.hzims.operational.report.service.IGenerationReportService; +import com.hnac.hzims.operational.report.vo.GenerationDeviceVo; +import com.hnac.hzims.operational.report.vo.GenerationReportTimeVo; +import com.hnac.hzims.operational.report.vo.GenerationReportVo; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.boot.ctrl.BladeController; +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.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @author ysj + */ +@Slf4j +@AllArgsConstructor +@RestController +@RequestMapping("/generation/report") +public class GenerationReportController extends BladeController { + + private final IGenerationReportService service; + + @GetMapping("/sameDayReport") + public R> sameDayReport(@RequestParam("stationId") String stationId){ + return R.data(service.sameDayReport(stationId)); + } + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/IGenerationReportService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/IGenerationReportService.java new file mode 100644 index 0000000..ec40e5a --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/IGenerationReportService.java @@ -0,0 +1,14 @@ +package com.hnac.hzims.operational.report.service; + +import com.hnac.hzims.operational.report.vo.GenerationDeviceVo; +import com.hnac.hzims.operational.report.vo.GenerationReportVo; + +import java.util.List; + +/** + * @author ysj + */ +public interface IGenerationReportService { + + List sameDayReport(String stationId); +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/GenerationReportServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/GenerationReportServiceImpl.java new file mode 100644 index 0000000..8433cb1 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/GenerationReportServiceImpl.java @@ -0,0 +1,100 @@ +package com.hnac.hzims.operational.report.service.impl; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.equipment.entity.EmInfoEntity; +import com.hnac.hzims.equipment.feign.IEmInfoClient; +import com.hnac.hzims.operational.report.service.IGenerationReportService; +import com.hnac.hzims.operational.report.vo.GenerationDeviceVo; +import com.hnac.hzims.operational.report.vo.GenerationReportTimeVo; +import com.hnac.hzims.operational.report.vo.GenerationReportVo; +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.service.IStationService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author ysj + */ +@Service +@Slf4j +@RequiredArgsConstructor +public class GenerationReportServiceImpl implements IGenerationReportService { + + private final IStationService stationService; + + private final IEmInfoClient deviceClient; + + /** + * 当天报表 + * @param stationId + * @return + */ + @Override + public List sameDayReport(String stationId) { + // 查询站点 + StationEntity station = stationService.getOne(Wrappers.lambdaQuery().eq(StationEntity::getCode,stationId)); + if(ObjectUtil.isEmpty(station)){ + throw new ServiceException("未查询到站点信息!"); + } + // 查询站点机组设备 + List devices = deviceClient.crewsDevices(station.getRefDept()); + if(CollectionUtil.isEmpty(devices)){ + throw new ServiceException("未查询到站点机组类型设备!"); + } + // FIXME 属性标识 + Map signages = new HashMap<>(); + signages.put("active_power","有功功率"); + signages.put("reactive_power","无功功率"); + signages.put("generation_capacity","正向有功电量"); + signages.put("reactive_generation_capacity","正向无功电量"); + List times = this.sameDayValues(); + Random random = new Random(); + return devices.stream().map(device->{ + GenerationDeviceVo item = new GenerationDeviceVo(); + item.setDeviceCode(device.getNumber()); + item.setDeviceName(device.getName()); + item.setAttributes(signages.entrySet().stream().map(entry->{ + GenerationReportVo attribute = new GenerationReportVo(); + attribute.setAttribute(entry.getKey()); + attribute.setAttributeName(entry.getValue()); + // FIXME : 使用随机数 + attribute.setTimes(times.stream().map(time->{ + GenerationReportTimeVo generation = new GenerationReportTimeVo(); + generation.setTime(time); + generation.setValue(random.nextDouble() * 1000); + return generation; + }).collect(Collectors.toList())); + return attribute; + }).collect(Collectors.toList())); + return item; + }).collect(Collectors.toList()); + } + + /** + * 当天数据值 + * @return + */ + private List sameDayValues() { + Calendar calendar = Calendar.getInstance(); + Date end = calendar.getTime(); + calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY)); + calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE)); + calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND)); + calendar.add(Calendar.MILLISECOND,-calendar.get(Calendar.MILLISECOND)); + Date start = calendar.getTime(); + List times = new ArrayList<>(); + while (start.compareTo(end) <= 0){ + calendar.add(Calendar.HOUR_OF_DAY,1); + times.add(start.getHours() + "时"); + start = calendar.getTime(); + } + return times; + } +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/RunReportConstant.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/RunReportConstant.java index 90d534b..2fae440 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/RunReportConstant.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/RunReportConstant.java @@ -5,4 +5,9 @@ public interface RunReportConstant { * 运行月报定时任务 */ String TASK_VALUE_RUN_REPORT_CREATE = "runReportCreateHandler"; + + /** + * 数据平台霍山生态流量监测模型标识 + */ + String HS_MODEL_SIGNAGE = "hs_ecological_flow_model"; } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/HikVideoController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/HikVideoController.java index 4dc814a..bba9770 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/HikVideoController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/HikVideoController.java @@ -28,8 +28,8 @@ public class HikVideoController extends BladeController { @ApiOperation("查询区域列表") @ApiOperationSupport(order = 1) @GetMapping("/nodesByParams") - public R> nodesByParams(@ApiParam("区域父级编号")@RequestParam(required = false) String parentIndexCode) { - return R.data(hikVideoService.nodesByParams(parentIndexCode)); + public R> nodesByParams(@RequestParam(value = "platformId",required = false) Long platformId,@ApiParam("区域父级编号")@RequestParam(value = "parentIndexCode",required = false) String parentIndexCode) { + return R.data(hikVideoService.nodesByParams(platformId,parentIndexCode)); } @ApiOperation("根据区域获取下级编码设备列表") diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationRelationController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationRelationController.java new file mode 100644 index 0000000..0241dbd --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationRelationController.java @@ -0,0 +1,134 @@ +package com.hnac.hzims.operational.station.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzims.operational.station.RunReportConstant; +import com.hnac.hzims.operational.station.entity.StationRelation; +import com.hnac.hzims.operational.station.service.IStationRelationService; +import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; +import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceVO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiOperationSupport; +import lombok.AllArgsConstructor; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.util.List; + +/** + * @author tanghaihao + * @date 2023年10月08日 15:04 + */ + +@RestController +@RequestMapping("/station/station-relation") +@AllArgsConstructor +@Api(value = "站点和霍山生态流量电站的关联关系管理",tags = "站点和霍山生态流量电站的关联关系管理") +public class StationRelationController { + private final IStationRelationService stationRelationService; + private final DeviceClient deviceClient; + + @GetMapping("/list") + @ApiOperation("查询列表") + @ApiOperationSupport(order = 1) + public R> list(StationRelation stationRelation) { + + return R.data(stationRelationService.getStationRelationList(stationRelation)); + } + + @GetMapping("/page") + @ApiOperation("分页查询列表") + @ApiOperationSupport(order = 2) + public R> page(StationRelation stationRelation, Query query) { + + return R.data(stationRelationService.getStationRelationPageList(stationRelation, query)); + } + + @PostMapping("/save") + @ApiOperation("保存") + @ApiOperationSupport(order = 3) + public R save(@RequestBody @Valid StationRelation stationRelation) { + if (Func.isEmpty(stationRelation.getStationCode())) { + return R.fail("站点编码不能为空"); + } + if (Func.isEmpty(stationRelation.getDeviceCode())) { + return R.fail("设备编码不能为空"); + } + if (Func.isEmpty(stationRelation.getLowSoeUserId())) { + return R.fail("低级告警负责人不能为空"); + } + if (Func.isEmpty(stationRelation.getLowSoePhone())) { + return R.fail("低级告警电话号码不能为空"); + } + if (Func.isEmpty(stationRelation.getMiddleSoeUserId())) { + return R.fail("中级告警负责人不能为空"); + } + if (Func.isEmpty(stationRelation.getMiddleSoePhone())) { + return R.fail("中级告警电话号码不能为空"); + } + if (Func.isEmpty(stationRelation.getHighSoeUserId())) { + return R.fail("高级告警负责人不能为空"); + } + if (Func.isEmpty(stationRelation.getHighSoePhone())) { + return R.fail("高级告警电话号码不能为空"); + } + if (Func.isEmpty(stationRelation.getFlowValue())) { + return R.fail("核定流量不能为空"); + } + LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); + wrapper.and(item -> item.eq(StationRelation::getStationCode, stationRelation.getStationCode()) + .or().eq(StationRelation::getDeviceCode, stationRelation.getDeviceCode())); + wrapper.eq(StationRelation::getIsDeleted, 0); + int count = stationRelationService.count(wrapper); + if (count > 0) { + return R.fail("站点关联关系已存在"); + } + return R.status(stationRelationService.save(stationRelation)); + } + + @PostMapping("/update") + @ApiOperation("编辑") + @ApiOperationSupport(order = 4) + public R update(@RequestBody @Valid StationRelation stationRelation) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); + wrapper.and(item -> item.eq(StationRelation::getStationCode, stationRelation.getStationCode()) + .or().eq(StationRelation::getDeviceCode, stationRelation.getDeviceCode())); + wrapper.eq(StationRelation::getIsDeleted, 0); + wrapper.ne(StationRelation::getId, stationRelation.getId()); + int count = stationRelationService.count(wrapper); + if (count > 0) { + return R.fail("站点关联关系已存在"); + } + return R.status(stationRelationService.updateById(stationRelation)); + } + + @GetMapping("/remove") + @ApiOperation("删除") + @ApiOperationSupport(order = 5) + public R remove(Long id) { + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.set(StationRelation::getIsDeleted, 1); + wrapper.eq(StationRelation::getId, id); + stationRelationService.update(wrapper); + return R.success("操作成功"); + } + + @GetMapping("/getDevice") + @ApiOperation("获取生态流量模型的设备信息") + @ApiOperationSupport(order = 6) + public R> getDevice() { + R> rData = deviceClient.getDeviceByModelSignage(RunReportConstant.HS_MODEL_SIGNAGE); + if (rData.getCode() == 200) { + List data = rData.getData(); + return R.data(data); + } else { + return R.fail("获取设备信息失败"); + } + } + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java index 8a94948..a4ed69d 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java @@ -347,8 +347,8 @@ public class StationVideoTypeController extends BladeController { @GetMapping("/getHikVideoAreaTree") @ApiOperationSupport(order = 150) @ApiOperation(value = "获取海康区域树", notes = "获取海康区域树") - public R> getHikVideoAreaTree() { - return R.data(stationVideoTypeService.getHikVideoAreaTree()); + public R> getHikVideoAreaTree(@RequestParam(value = "platformId",required = false)Long platformId) { + return R.data(stationVideoTypeService.getHikVideoAreaTree(platformId)); } @GetMapping("/getVideoPointByRegion") @@ -382,4 +382,10 @@ public class StationVideoTypeController extends BladeController { return R.data(false); } + @GetMapping ("/getVideoByPointCodes") + @ApiOperationSupport(order = 190) + @ApiOperation(value = "通过视频编号获取视频") + public R> getVideoByPointCodes(@RequestParam @ApiParam("视频设备编号") String pointCodes) { + return R.data(stationVideoTypeService.getVideoByPointCodes(pointCodes)); + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationRelationMapper.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationRelationMapper.java new file mode 100644 index 0000000..e08e69e --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationRelationMapper.java @@ -0,0 +1,8 @@ +package com.hnac.hzims.operational.station.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.operational.station.entity.StationRelation; + +public interface StationRelationMapper extends BaseMapper { + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationRelationMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationRelationMapper.xml new file mode 100644 index 0000000..e1cfa29 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationRelationMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IHikVideoService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IHikVideoService.java index 48d874b..e680dcd 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IHikVideoService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IHikVideoService.java @@ -15,7 +15,7 @@ public interface IHikVideoService { * 查询区域列表 * @return 区域列表 */ - List nodesByParams(String parentIndexCode); + List nodesByParams(Long platformId,String parentIndexCode); List subResources(String regionIndexCode); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationRelationService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationRelationService.java new file mode 100644 index 0000000..e8e9964 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationRelationService.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.operational.station.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.hzims.operational.station.entity.StationRelation; +import org.springblade.core.mp.support.Query; + +import java.util.List; + +/** + * @author tanghaihao + * @date 2023年10月08日 15:04 + */ +public interface IStationRelationService extends IService { + + List getStationRelationList(StationRelation stationRelation); + + IPage getStationRelationPageList(StationRelation stationRelation, Query query); +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/HikVideoServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/HikVideoServiceImpl.java index 3c8795f..f3fd0ea 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/HikVideoServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/HikVideoServiceImpl.java @@ -7,15 +7,20 @@ import com.hikvision.artemis.sdk.ArtemisHttpUtil; import com.hikvision.artemis.sdk.config.ArtemisConfig; import com.hnac.hzims.operational.station.service.IHikVideoService; import com.hnac.hzims.operational.station.vo.HikVideoAreaVO; +import com.hnac.hzims.operational.video.entity.VideoPlatformEntity; +import com.hnac.hzims.operational.video.service.IVideoPlatformService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.util.Assert; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -27,6 +32,8 @@ import static com.hnac.hzims.operational.station.constants.HikApiConstants.*; @Service public class HikVideoServiceImpl implements IHikVideoService { + private final IVideoPlatformService videoPlatformService; + @Value("${hzims.videoProperties.appKey}") private String videoAppKey; @@ -53,8 +60,20 @@ public class HikVideoServiceImpl implements IHikVideoService { } @Override - public List nodesByParams(String parentIndexCode) { - init(); + public List nodesByParams(Long platformId,String parentIndexCode) { + if(ObjectUtil.isEmpty(platformId)){ + init(); + }else{ + // 查询多平台配置 + VideoPlatformEntity platform = videoPlatformService.getById(platformId); + if(ObjectUtil.isEmpty(platform)){ + return new ArrayList<>(); + } + ArtemisConfig.host = platform.getVideoHost(); + ArtemisConfig.appKey = platform.getAppKey(); + ArtemisConfig.appSecret = platform.getAppSecret(); + } + Map path = new HashMap<>(); path.put("https://", ARTEMIS_PATH + NODE_BY_PARAMS); HashMap body = new HashMap() {{ diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationRelationServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationRelationServiceImpl.java new file mode 100644 index 0000000..6e02935 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationRelationServiceImpl.java @@ -0,0 +1,47 @@ +package com.hnac.hzims.operational.station.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.operational.station.entity.StationRelation; +import com.hnac.hzims.operational.station.mapper.StationRelationMapper; +import com.hnac.hzims.operational.station.service.IStationRelationService; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.utils.Func; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @author tanghaihao + * @date 2023年10月08日 14:37 + */ +@Service +public class StationRelationServiceImpl extends ServiceImpl implements IStationRelationService { + @Override + public List getStationRelationList(StationRelation stationRelation) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); + if (Func.isNotEmpty(stationRelation.getStationCode())) { + wrapper.eq(StationRelation::getStationCode, stationRelation.getStationCode()); + } + if (Func.isNotEmpty(stationRelation.getDeviceCode())) { + wrapper.eq(StationRelation::getDeviceCode, stationRelation.getDeviceCode()); + } + wrapper.eq(StationRelation::getIsDeleted, 0); + return this.list(wrapper); + } + + @Override + public IPage getStationRelationPageList(StationRelation stationRelation, Query query) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); + if (Func.isNotEmpty(stationRelation.getStationCode())) { + wrapper.eq(StationRelation::getStationCode, stationRelation.getStationCode()); + } + if (Func.isNotEmpty(stationRelation.getDeviceCode())) { + wrapper.eq(StationRelation::getDeviceCode, stationRelation.getDeviceCode()); + } + wrapper.eq(StationRelation::getIsDeleted, 0); + return this.page(Condition.getPage(query), wrapper); + } +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java index 7c89565..89d40ad 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java @@ -688,6 +688,14 @@ public class StationServiceImpl extends ServiceImpl wq = Wrappers.lambdaQuery().eq(StationEntity::getCode, entity.getCode()); + List stations = this.getBaseMapper().listWithOutAuth(wq); + Assert.isTrue(CollectionUtil.isEmpty(stations),() -> { + throw new ServiceException("站点编号平台已存在,请检查后重新填入!"); + }); + } Integer maxSort = this.baseMapper.getMaxSort(); entity.setSort(Optional.ofNullable(maxSort).map(sort -> sort + 1).orElse(1)); // 创建站点机构 diff --git a/hzims-service/safeproduct/src/main/resources/template/SafeToolTemplate.html b/hzims-service/safeproduct/src/main/resources/template/SafeToolTemplate.html new file mode 100644 index 0000000..8e377ea --- /dev/null +++ b/hzims-service/safeproduct/src/main/resources/template/SafeToolTemplate.html @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + +
工器具名称${data_1}
创建日期${data_2}
+ +
+ + diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/FirstWorkTicketServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/FirstWorkTicketServiceImpl.java index 243e010..15eeb51 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/FirstWorkTicketServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/FirstWorkTicketServiceImpl.java @@ -22,9 +22,12 @@ import com.hnac.hzims.ticket.allTicket.vo.TicketInfoStatisticVO; import com.hnac.hzims.ticket.constants.TicketConstants; import com.hnac.hzims.ticket.constants.WorkTicketConstants; import com.hnac.hzims.ticket.twoTicket.constant.TicketConstant; +import com.hnac.hzims.ticket.twoTicket.entity.TicketInfoDanger; import com.hnac.hzims.ticket.twoTicket.entity.WorkTicketFinish; +import com.hnac.hzims.ticket.twoTicket.mapper.TicketInfoDangerMapper; import com.hnac.hzims.ticket.twoTicket.service.IFirstWorkTicketService; import com.hnac.hzims.ticket.twoTicket.service.IWorkTicketFinishService; +import com.hnac.hzims.ticket.twoTicket.service.TicketInfoDangerService; import com.hnac.hzims.ticket.utils.*; import com.hnac.hzims.ticket.workTicket.dto.*; import com.hnac.hzims.ticket.workTicket.entity.*; @@ -95,6 +98,7 @@ public class FirstWorkTicketServiceImpl extends ServiceImpl qw = Wrappers.lambdaQuery().eq(TicketInfoDanger::getTicketId, ticketId); + List ticketInfoDangerList = dangerService.list(qw); + List dangerList = IntStream.iterate(0, index -> index + 1).limit(ticketInfoDangerList.size()).mapToObj(index -> { + Map result = ObjectUtils.obj2Map(ticketInfoDangerList.get(index)); + result.put("index",index + 1); + return result; + }).collect(Collectors.toList()); + params.put("ticketInfoDangers", dangerList); params.put("isSafety",workTicketInfoEntity.getIsSafety() ? "☑" : "□"); params.put("isHazard",workTicketInfoEntity.getIsHazard() ? "☑" : "□"); params.put("isRailway",workTicketInfoEntity.getIsRailway() ? "☑" : "□"); diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/operation/StandardTicketInfoVo.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/operation/StandardTicketInfoVo.java index 083aeb3..1c58a20 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/operation/StandardTicketInfoVo.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/operation/StandardTicketInfoVo.java @@ -5,6 +5,8 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; +import org.springblade.core.mp.support.QueryField; +import org.springblade.core.mp.support.SqlCondition; import org.springblade.core.tenant.mp.TenantEntity; import org.springframework.format.annotation.DateTimeFormat; @@ -155,4 +157,14 @@ public class StandardTicketInfoVo extends TenantEntity { @ApiModelProperty("安全措施") private List standardTicketMeasureVos; + + @ApiModelProperty("是否线下 : 1-线下,0-线上") + @QueryField(condition = SqlCondition.EQUAL) + private Boolean isOffline; + + @ApiModelProperty("是否审核通过 : 1-通过,0-未通过") + private Boolean isApproved; + + @ApiModelProperty("图片附件") + private String picture; } diff --git a/hzims-service/ticket/src/main/resources/db/2.0.3.sql b/hzims-service/ticket/src/main/resources/db/2.0.3.sql new file mode 100644 index 0000000..755f8ce --- /dev/null +++ b/hzims-service/ticket/src/main/resources/db/2.0.3.sql @@ -0,0 +1,6 @@ +alter table `hzims_standard_ticket_info` add column `is_offline` tinyint(2) default 0 comment '是否线下 : 1-线下,0-线上'; +alter table `hzims_standard_ticket_info` add column `is_approved` tinyint(2) default NULL comment '是否审核通过 : 1-通过,0-未通过'; +alter table `hzims_standard_ticket_info` ADD COLUMN `picture` varchar(600) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '图片附件' ; +ALTER TABLE `hzims_standard_ticket_info` + MODIFY COLUMN `issue_order_person` bigint(20) NULL COMMENT '发令人' AFTER `code`, + MODIFY COLUMN `access_order_person` bigint(20) NULL COMMENT '受令人' AFTER `issue_order_person`; \ No newline at end of file