Merge pull request 'master' (#9) from master into prod
All checks were successful
Build and Push to Target Registry / 构建并推送镜像到目标仓库 (push) Successful in 11m49s

合并代码
This commit is contained in:
lsm
2025-09-15 16:25:30 +08:00
10 changed files with 119 additions and 6 deletions

View File

@@ -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();
}

View File

@@ -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);
}

View File

@@ -120,4 +120,9 @@ public class ServiceWorkOrdersBo extends BaseEntity {
*/
private String isTimeOut;
/**
* 租户ID
*/
private String tenantId;
}

View File

@@ -112,5 +112,14 @@ public class TbMeterInfoBo extends BaseEntity {
*/
private String remark;
/**
* 白天预警阈值
*/
private BigDecimal dayWarning;
/**
* 夜间预警阈值
*/
private BigDecimal nightWarning;
}

View File

@@ -108,5 +108,15 @@ public class TbMeterInfo extends TenantEntity {
*/
private String hostIp;
/**
* 白天预警阈值
*/
private BigDecimal dayWarning;
/**
* 夜间预警阈值
*/
private BigDecimal nightWarning;
}

View File

@@ -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;
}
}

View File

@@ -144,5 +144,16 @@ public class TbMeterInfoVo implements Serializable {
@ExcelProperty(value = "备注")
private String remark;
/**
* 白天预警阈值
*/
@ExcelProperty(value = "白天预警阈值")
private BigDecimal dayWarning;
/**
* 夜间预警阈值
*/
@ExcelProperty(value = "夜间预警阈值")
private BigDecimal nightWarning;
}

View File

@@ -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("当前员工未审核");

View File

@@ -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);

View File

@@ -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);