diff --git a/ruoyi-common/ruoyi-common-oss/src/main/java/org/dromara/common/oss/core/OssClient.java b/ruoyi-common/ruoyi-common-oss/src/main/java/org/dromara/common/oss/core/OssClient.java index f5d6d132..8d056673 100644 --- a/ruoyi-common/ruoyi-common-oss/src/main/java/org/dromara/common/oss/core/OssClient.java +++ b/ruoyi-common/ruoyi-common-oss/src/main/java/org/dromara/common/oss/core/OssClient.java @@ -452,8 +452,9 @@ public class OssClient { // MinIO 单独处理 if (StringUtils.isNotEmpty(domain)) { // 如果 domain 以 "https://" 或 "http://" 开头 - return (domain.startsWith(Constants.HTTPS) || domain.startsWith(Constants.HTTP)) ? - domain + StringUtils.SLASH + properties.getBucketName() : header + domain + StringUtils.SLASH + properties.getBucketName(); +// return (domain.startsWith(Constants.HTTPS) || domain.startsWith(Constants.HTTP)) ? +// domain + StringUtils.SLASH + properties.getBucketName() : header + domain + StringUtils.SLASH + properties.getBucketName(); + return StringUtils.SLASH + properties.getBucketName(); } return header + endpoint + StringUtils.SLASH + properties.getBucketName(); } diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/controller/xcx/XResidentPersonController.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/controller/xcx/XResidentPersonController.java index 7f9d496a..17c52272 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/controller/xcx/XResidentPersonController.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/controller/xcx/XResidentPersonController.java @@ -54,6 +54,7 @@ public class XResidentPersonController extends BaseController { vo.setUserRoles(loginUser.getUserRoles()); vo.setUnitId(loginUser.getUnitId()); vo.setUnitName(loginUser.getUnitName()); + vo.setTenantId(loginUser.getTenantId()); return R.ok(vo); } diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/bo/ServiceWorkOrdersBo.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/bo/ServiceWorkOrdersBo.java index f5ee41df..d56e33af 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/bo/ServiceWorkOrdersBo.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/bo/ServiceWorkOrdersBo.java @@ -120,4 +120,9 @@ public class ServiceWorkOrdersBo extends BaseEntity { */ private String isTimeOut; + /** + * 租户ID + */ + private String tenantId; + } diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/bo/smartDevicesBo/TbMeterInfoBo.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/bo/smartDevicesBo/TbMeterInfoBo.java index 73db1b9f..dffffffd 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/bo/smartDevicesBo/TbMeterInfoBo.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/bo/smartDevicesBo/TbMeterInfoBo.java @@ -112,5 +112,14 @@ public class TbMeterInfoBo extends BaseEntity { */ private String remark; + /** + * 白天预警阈值 + */ + private BigDecimal dayWarning; + + /** + * 夜间预警阈值 + */ + private BigDecimal nightWarning; } diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/entity/smartDevices/TbMeterInfo.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/entity/smartDevices/TbMeterInfo.java index f363203d..9401e141 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/entity/smartDevices/TbMeterInfo.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/entity/smartDevices/TbMeterInfo.java @@ -108,5 +108,15 @@ public class TbMeterInfo extends TenantEntity { */ private String hostIp; + /** + * 白天预警阈值 + */ + private BigDecimal dayWarning; + + /** + * 夜间预警阈值 + */ + private BigDecimal nightWarning; + } diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/enums/MeterTypeEnum.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/enums/MeterTypeEnum.java new file mode 100644 index 00000000..fd7b8da4 --- /dev/null +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/enums/MeterTypeEnum.java @@ -0,0 +1,35 @@ +package org.dromara.property.domain.enums; + +import lombok.Getter; + +/** + * @author lsm + * @apiNote MeterTypeEnum + * @since 2025/9/15 + */ +@Getter +public enum MeterTypeEnum { + + /** + * 电表 + */ + ELECTRIC_METER(1L, 1963167455478624257L), + + /** + * 水表 + */ + WATER_METER(2L, 1963167729677053953L), + + /** + * 气表 + */ + GAS_METER(3L, 0L); + + private final Long code; + private final Long orderType; + + MeterTypeEnum(Long code, Long orderType) { + this.code = code; + this.orderType = orderType; + } +} diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/vo/smartDevicesVo/TbMeterInfoVo.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/vo/smartDevicesVo/TbMeterInfoVo.java index 2ec7ef46..d48e52b3 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/vo/smartDevicesVo/TbMeterInfoVo.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/vo/smartDevicesVo/TbMeterInfoVo.java @@ -144,5 +144,16 @@ public class TbMeterInfoVo implements Serializable { @ExcelProperty(value = "备注") private String remark; + /** + * 白天预警阈值 + */ + @ExcelProperty(value = "白天预警阈值") + private BigDecimal dayWarning; + + /** + * 夜间预警阈值 + */ + @ExcelProperty(value = "夜间预警阈值") + private BigDecimal nightWarning; } diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/dubbo/RemoteResidentPersonServiceImpl.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/dubbo/RemoteResidentPersonServiceImpl.java index e6b60a87..499dda9d 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/dubbo/RemoteResidentPersonServiceImpl.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/dubbo/RemoteResidentPersonServiceImpl.java @@ -80,7 +80,7 @@ public class RemoteResidentPersonServiceImpl implements RemoteResidentPersonServ return TenantHelper.dynamic(tenantId, () -> { ResidentPersonVo vo = residentPersonService.queryByPhone(phone, tenantId); if (ObjectUtil.isEmpty(vo)) { - throw new ResidentPersonException("入驻员工"); + throw new ResidentPersonException("入驻员工不存在"); } if (vo.getIsAudit() == null || vo.getIsAudit() != 1) { throw new ResidentPersonException("当前员工未审核"); diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/ServiceWorkOrdersServiceImpl.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/ServiceWorkOrdersServiceImpl.java index c3df7575..e98e0777 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/ServiceWorkOrdersServiceImpl.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/ServiceWorkOrdersServiceImpl.java @@ -223,12 +223,19 @@ public class ServiceWorkOrdersServiceImpl implements IServiceWorkOrdersService { //查询工单类型 ServiceWorkOrdersType serviceWorkOrdersType = typesMapper.selectById(bo.getType()); ServiceWorkOrders add = MapstructUtils.convert(bo, ServiceWorkOrders.class); - LoginUser user = LoginHelper.getLoginUser(); + assert add != null; add.setOrderNo("GD" + IdUtil.getSnowflakeNextIdStr()); add.setStatus(WorkOrderStatusEnum.CREATE_ORDER.getValue()); - add.setInitiatorPeople(user.getNickname()); add.setProcessingWeight(serviceWorkOrdersType.getProcessingWeight()); add.setIsTimeOut("0"); + + // 传入用户名时,不使用token中的值,避免自动生成工单引发token报错 + if (!StringUtils.isNotBlank(bo.getInitiatorName())){ + LoginUser user = LoginHelper.getLoginUser(); + assert user != null; + add.setInitiatorPeople(user.getNickname()); + } + Date originalDate = new Date(); // 当前时间 Date newDate = DateUtil.offsetHour(originalDate, serviceWorkOrdersType.getCompletionNumber()); add.setPlanCompleTime(newDate); diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/smartDevicesImpl/TbMeterRecordServiceImpl.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/smartDevicesImpl/TbMeterRecordServiceImpl.java index 162962d1..733f7e83 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/smartDevicesImpl/TbMeterRecordServiceImpl.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/smartDevicesImpl/TbMeterRecordServiceImpl.java @@ -13,10 +13,14 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.dromara.property.domain.ServiceWorkOrders; +import org.dromara.property.domain.bo.ServiceWorkOrdersBo; import org.dromara.property.domain.bo.smartDevicesBo.TbMeterInfoBo; import org.dromara.property.domain.enums.MeterRecordTypeEnum; +import org.dromara.property.domain.enums.MeterTypeEnum; import org.dromara.property.domain.vo.smartDevicesVo.TbMeterInfoVo; import org.dromara.property.rocketmq.domain.MeterResult; +import org.dromara.property.service.IServiceWorkOrdersService; import org.dromara.property.service.smartDevicesService.ITbMeterInfoService; import org.springframework.stereotype.Service; import org.dromara.property.domain.bo.smartDevicesBo.TbMeterRecordBo; @@ -28,6 +32,7 @@ import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.time.YearMonth; +import java.time.ZoneId; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; @@ -46,6 +51,7 @@ public class TbMeterRecordServiceImpl implements ITbMeterRecordService { private final TbMeterRecordMapper baseMapper; private final ITbMeterInfoService tbMeterInfoService; + private final IServiceWorkOrdersService serviceWorkOrdersService; /** * 查询抄记录 @@ -244,7 +250,35 @@ public class TbMeterRecordServiceImpl implements ITbMeterRecordService { } else { bo.setCommunicationState(1L); } - tbMeterInfoService.updateByBo(bo); + boolean infoFlag = tbMeterInfoService.updateByBo(bo); + Assert.isTrue(infoFlag, "更新设备信息失败"); + + + // 当前读数超出阈值,自动上报工单 + int hour = record.getReadingTime().toInstant().atZone(ZoneId.systemDefault()).getHour(); + ServiceWorkOrdersBo ordersBo = new ServiceWorkOrdersBo(); + ordersBo.setTenantId(info.getTenantId()); + + // 判断是白天还是夜间 + boolean isDaytime = hour > 8 && hour <= 20; + BigDecimal threshold = isDaytime ? info.getDayWarning() : info.getNightWarning(); + // 如果阈值为0,则不处理(阈值不为0且读数大于阈值,自动上报) + if (threshold.compareTo(BigDecimal.ZERO) != 0 && record.getCurrentReading().compareTo(threshold) > 0) { + // 根据仪表类型设置工单名称和类型 + String orderName = "能耗异常"; + Long orderType = 0L; + if (Objects.equals(info.getMeterType(), MeterTypeEnum.ELECTRIC_METER.getCode())) { + orderName = isDaytime ? "电表日间阈值报警" : "电表夜间阈值报警"; + orderType = MeterTypeEnum.ELECTRIC_METER.getOrderType(); + } else if (Objects.equals(info.getMeterType(), MeterTypeEnum.WATER_METER.getCode())) { + orderName = isDaytime ? "水表日间阈值报警" : "水表夜间阈值报警"; + orderType = MeterTypeEnum.WATER_METER.getOrderType(); + } + ordersBo.setOrderName(orderName); + ordersBo.setType(orderType); + boolean orderFlag = serviceWorkOrdersService.insertByBo(ordersBo); + Assert.isTrue(orderFlag, "自动上报工单失败"); + } record.setReadingMethod(MeterRecordTypeEnum.AUTO_RECORD.getCode()); recordNew.add(record);