feat(property):
- 添加仪表类型枚举并实现能耗异常自动上报工单功能 - 更新 XResidentPersonController,为用户信息添加租户ID
This commit is contained in:
@@ -54,6 +54,7 @@ public class XResidentPersonController extends BaseController {
|
|||||||
vo.setUserRoles(loginUser.getUserRoles());
|
vo.setUserRoles(loginUser.getUserRoles());
|
||||||
vo.setUnitId(loginUser.getUnitId());
|
vo.setUnitId(loginUser.getUnitId());
|
||||||
vo.setUnitName(loginUser.getUnitName());
|
vo.setUnitName(loginUser.getUnitName());
|
||||||
|
vo.setTenantId(loginUser.getTenantId());
|
||||||
return R.ok(vo);
|
return R.ok(vo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -120,4 +120,9 @@ public class ServiceWorkOrdersBo extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private String isTimeOut;
|
private String isTimeOut;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 租户ID
|
||||||
|
*/
|
||||||
|
private String tenantId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -112,5 +112,14 @@ public class TbMeterInfoBo extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 白天预警阈值
|
||||||
|
*/
|
||||||
|
private BigDecimal dayWarning;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 夜间预警阈值
|
||||||
|
*/
|
||||||
|
private BigDecimal nightWarning;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -108,5 +108,15 @@ public class TbMeterInfo extends TenantEntity {
|
|||||||
*/
|
*/
|
||||||
private String hostIp;
|
private String hostIp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 白天预警阈值
|
||||||
|
*/
|
||||||
|
private BigDecimal dayWarning;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 夜间预警阈值
|
||||||
|
*/
|
||||||
|
private BigDecimal nightWarning;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
@@ -144,5 +144,16 @@ public class TbMeterInfoVo implements Serializable {
|
|||||||
@ExcelProperty(value = "备注")
|
@ExcelProperty(value = "备注")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 白天预警阈值
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "白天预警阈值")
|
||||||
|
private BigDecimal dayWarning;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 夜间预警阈值
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "夜间预警阈值")
|
||||||
|
private BigDecimal nightWarning;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -80,7 +80,7 @@ public class RemoteResidentPersonServiceImpl implements RemoteResidentPersonServ
|
|||||||
return TenantHelper.dynamic(tenantId, () -> {
|
return TenantHelper.dynamic(tenantId, () -> {
|
||||||
ResidentPersonVo vo = residentPersonService.queryByPhone(phone, tenantId);
|
ResidentPersonVo vo = residentPersonService.queryByPhone(phone, tenantId);
|
||||||
if (ObjectUtil.isEmpty(vo)) {
|
if (ObjectUtil.isEmpty(vo)) {
|
||||||
throw new ResidentPersonException("入驻员工");
|
throw new ResidentPersonException("入驻员工不存在");
|
||||||
}
|
}
|
||||||
if (vo.getIsAudit() == null || vo.getIsAudit() != 1) {
|
if (vo.getIsAudit() == null || vo.getIsAudit() != 1) {
|
||||||
throw new ResidentPersonException("当前员工未审核");
|
throw new ResidentPersonException("当前员工未审核");
|
||||||
|
@@ -223,12 +223,19 @@ public class ServiceWorkOrdersServiceImpl implements IServiceWorkOrdersService {
|
|||||||
//查询工单类型
|
//查询工单类型
|
||||||
ServiceWorkOrdersType serviceWorkOrdersType = typesMapper.selectById(bo.getType());
|
ServiceWorkOrdersType serviceWorkOrdersType = typesMapper.selectById(bo.getType());
|
||||||
ServiceWorkOrders add = MapstructUtils.convert(bo, ServiceWorkOrders.class);
|
ServiceWorkOrders add = MapstructUtils.convert(bo, ServiceWorkOrders.class);
|
||||||
LoginUser user = LoginHelper.getLoginUser();
|
assert add != null;
|
||||||
add.setOrderNo("GD" + IdUtil.getSnowflakeNextIdStr());
|
add.setOrderNo("GD" + IdUtil.getSnowflakeNextIdStr());
|
||||||
add.setStatus(WorkOrderStatusEnum.CREATE_ORDER.getValue());
|
add.setStatus(WorkOrderStatusEnum.CREATE_ORDER.getValue());
|
||||||
add.setInitiatorPeople(user.getNickname());
|
|
||||||
add.setProcessingWeight(serviceWorkOrdersType.getProcessingWeight());
|
add.setProcessingWeight(serviceWorkOrdersType.getProcessingWeight());
|
||||||
add.setIsTimeOut("0");
|
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 originalDate = new Date(); // 当前时间
|
||||||
Date newDate = DateUtil.offsetHour(originalDate, serviceWorkOrdersType.getCompletionNumber());
|
Date newDate = DateUtil.offsetHour(originalDate, serviceWorkOrdersType.getCompletionNumber());
|
||||||
add.setPlanCompleTime(newDate);
|
add.setPlanCompleTime(newDate);
|
||||||
|
@@ -13,10 +13,14 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
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.bo.smartDevicesBo.TbMeterInfoBo;
|
||||||
import org.dromara.property.domain.enums.MeterRecordTypeEnum;
|
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.domain.vo.smartDevicesVo.TbMeterInfoVo;
|
||||||
import org.dromara.property.rocketmq.domain.MeterResult;
|
import org.dromara.property.rocketmq.domain.MeterResult;
|
||||||
|
import org.dromara.property.service.IServiceWorkOrdersService;
|
||||||
import org.dromara.property.service.smartDevicesService.ITbMeterInfoService;
|
import org.dromara.property.service.smartDevicesService.ITbMeterInfoService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.dromara.property.domain.bo.smartDevicesBo.TbMeterRecordBo;
|
import org.dromara.property.domain.bo.smartDevicesBo.TbMeterRecordBo;
|
||||||
@@ -28,6 +32,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.YearMonth;
|
import java.time.YearMonth;
|
||||||
|
import java.time.ZoneId;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -46,6 +51,7 @@ public class TbMeterRecordServiceImpl implements ITbMeterRecordService {
|
|||||||
|
|
||||||
private final TbMeterRecordMapper baseMapper;
|
private final TbMeterRecordMapper baseMapper;
|
||||||
private final ITbMeterInfoService tbMeterInfoService;
|
private final ITbMeterInfoService tbMeterInfoService;
|
||||||
|
private final IServiceWorkOrdersService serviceWorkOrdersService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询抄记录
|
* 查询抄记录
|
||||||
@@ -244,7 +250,35 @@ public class TbMeterRecordServiceImpl implements ITbMeterRecordService {
|
|||||||
} else {
|
} else {
|
||||||
bo.setCommunicationState(1L);
|
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());
|
record.setReadingMethod(MeterRecordTypeEnum.AUTO_RECORD.getCode());
|
||||||
recordNew.add(record);
|
recordNew.add(record);
|
||||||
|
Reference in New Issue
Block a user