From 30383e16e21601ddf244b37a467b4e965d7a0dfb Mon Sep 17 00:00:00 2001 From: zcxlsm Date: Sun, 14 Sep 2025 21:45:56 +0800 Subject: [PATCH 01/10] refactor(Property): 1 --- .../xcx/XResidentPersonController.java | 3 +- .../impl/CostHouseChargeServiceImpl.java | 9 + .../TbMeterRecordServiceImpl.java | 156 +++++++++++++----- 3 files changed, 124 insertions(+), 44 deletions(-) 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 08163dac..89c177c6 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 @@ -81,10 +81,9 @@ public class XResidentPersonController extends BaseController { /** * 新增入驻员工 */ - @SaCheckPermission("xcx:person:add") - @Log(title = "入驻员工", businessType = BusinessType.INSERT) @RepeatSubmit() @PostMapping() + @Log(title = "入驻员工", businessType = BusinessType.INSERT) public R add(@Validated(AddGroup.class) @RequestBody ResidentPersonBo bo) { return toAjax(residentPersonService.insertByBo(bo)); } diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/CostHouseChargeServiceImpl.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/CostHouseChargeServiceImpl.java index 3c8d0e3e..e5e6e491 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/CostHouseChargeServiceImpl.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/CostHouseChargeServiceImpl.java @@ -214,6 +214,8 @@ public class CostHouseChargeServiceImpl implements ICostHouseChargeService { } //类型为5,则为水费 if (Objects.equals(remoteDictDataVo.getDictValue(), "5")) { + + } //类型为6,则为电费 if (Objects.equals(remoteDictDataVo.getDictValue(), "6")) { @@ -245,6 +247,13 @@ public class CostHouseChargeServiceImpl implements ICostHouseChargeService { return flag; } + /** + * 水电气费计算 + */ + private void meterCharge(){ + + } + /** * 房屋退费 * 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 f82f2fa4..162962d1 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 @@ -27,9 +27,11 @@ import org.dromara.property.service.smartDevicesService.ITbMeterRecordService; import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; +import java.time.YearMonth; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; +import java.util.stream.IntStream; /** * 抄记录Service业务层处理 @@ -267,50 +269,75 @@ public class TbMeterRecordServiceImpl implements ITbMeterRecordService { public Map getEnergyTrend(String floorId, String meterId, Long meterType, String day, String month, String year) { Map resultMap = new HashMap<>(); - String yesterday = DateUtil.format(DateUtil.offsetDay(DateUtil.parse(day), -1), "yyyy-MM-dd"); - // todayHour - Map todayMap = trendHourData(floorId, meterId, meterType, day); - // yesterdayHour - Map yesterdayMap = trendHourData(floorId, meterId, meterType, yesterday); + if (!StrUtil.isBlank(day)) { + String yesterday = DateUtil.format(DateUtil.offsetDay(DateUtil.parse(day), -1), "yyyy-MM-dd"); + // todayHour + Map todayMap = trendHourData(floorId, meterId, meterType, day); + // yesterdayHour + Map yesterdayMap = trendHourData(floorId, meterId, meterType, yesterday); - Map hourMap = new HashMap<>(); - hourMap.put("today", todayMap); - hourMap.put("yesterday", yesterdayMap); + Map hourMap = new HashMap<>(); + hourMap.put("today", todayMap); + hourMap.put("yesterday", yesterdayMap); + resultMap.put("hour", hourMap); + } + if (!StrUtil.isBlank(month)) { + String[] monthArr = month.split("-"); + String lastMonth = Integer.parseInt(monthArr[1]) - 1 + ""; + // nowMonth + Map nowMonthMap = trendDayData(floorId, meterId, meterType, monthArr[0], monthArr[1]); + // lastMonth + Map lastMonthMap = trendDayData(floorId, meterId, meterType, monthArr[0], lastMonth); - String[] monthArr = month.split("-"); - String lastMonth = Integer.parseInt(monthArr[1]) - 1 + ""; - // nowMonth - Map nowMonthMap = trendDayData(floorId, meterId, meterType, monthArr[0], monthArr[1]); - // lastMonth - Map lastMonthMap = trendDayData(floorId, meterId, meterType, monthArr[0], lastMonth); + Map dayMap = new HashMap<>(); + dayMap.put("nowMonth", nowMonthMap); + dayMap.put("lastMonth", lastMonthMap); + resultMap.put("day", dayMap); + } - Map dayMap = new HashMap<>(); - dayMap.put("nowMonth", nowMonthMap); - dayMap.put("lastMonth", lastMonthMap); + if (!StrUtil.isBlank(year)) { + String lastYear = Integer.parseInt(year) - 1 + ""; + // nowYear + Map nowYearMap = trendMonthData(floorId, meterId, meterType, year); + // lastYear + Map lastYearMap = trendMonthData(floorId, meterId, meterType, lastYear); - String lastYear = Integer.parseInt(year) - 1 + ""; - // nowYear - Map nowYearMap = trendMonthData(floorId, meterId, meterType, year); - // lastYear - Map lastYearMap = trendMonthData(floorId, meterId, meterType, lastYear); - - Map monthMap = new HashMap<>(); - monthMap.put("nowYear", nowYearMap); - monthMap.put("lastYear", lastYearMap); - - resultMap.put("hour", hourMap); - resultMap.put("day", dayMap); - resultMap.put("month", monthMap); + Map monthMap = new HashMap<>(); + monthMap.put("nowYear", nowYearMap); + monthMap.put("lastYear", lastYearMap); + resultMap.put("month", monthMap); + } return resultMap; } private Map trendHourData(String floorId, String meterId, Long meterType, String day) { Map hourMap = new HashMap<>(); - List> hourList = baseMapper.getHourTrend(StrUtil.isBlank(floorId) ? null : Long.parseLong(floorId), StrUtil.isBlank(meterId) ? null : Long.parseLong(meterId), meterType, day); - List hourData = new ArrayList<>(); - hourList.forEach(item -> hourData.add(new String[]{item.get("hour").toString(), item.get("total_consumption").toString()})); - Float total = hourList.stream().map(map -> new BigDecimal(map.get("total_consumption").toString())).reduce(BigDecimal::add).orElse(BigDecimal.ZERO).floatValue(); + List> sqlList = baseMapper.getHourTrend(StrUtil.isBlank(floorId) ? null : Long.parseLong(floorId), StrUtil.isBlank(meterId) ? null : Long.parseLong(meterId), meterType, day); + + // 创建小时--能耗的映射,缺失的小时自动补0 + List hourData = IntStream.rangeClosed(0, 23) + .mapToObj(hour -> { + // 查找对应小时的数据 + Optional> hourResult = sqlList.stream() + .filter(item -> Integer.parseInt(item.get("hour").toString().split(":")[0]) == hour) + .findFirst(); + + // 存在则使用实际值,否则使用0 + String consumption = hourResult + .map(item -> item.get("total_consumption").toString()) + .orElse(BigDecimal.ZERO.toString()); + + return new String[]{hour + ":00", consumption}; + }).collect(Collectors.toList()); + + // 计算总能耗(直接使用sqlList中的数据求和,避免二次计算) + Float total = sqlList.stream() + .map(item -> new BigDecimal(item.get("total_consumption").toString())) + .reduce(BigDecimal::add) + .orElse(BigDecimal.ZERO) + .floatValue(); + hourMap.put("total", total); hourMap.put("data", hourData); return hourMap; @@ -318,10 +345,33 @@ public class TbMeterRecordServiceImpl implements ITbMeterRecordService { private Map trendDayData(String floorId, String meterId, Long meterType, String year, String month) { Map dayMap = new HashMap<>(); - List> dayList = baseMapper.getDayTrend(StrUtil.isBlank(floorId) ? null : Long.parseLong(floorId), StrUtil.isBlank(meterId) ? null : Long.parseLong(meterId), meterType, year, month); - List dayData = new ArrayList<>(); - dayList.forEach(item -> dayData.add(new String[]{item.get("day").toString(), item.get("total_consumption").toString()})); - Float total = dayList.stream().map(map -> new BigDecimal(map.get("total_consumption").toString())).reduce(BigDecimal::add).orElse(BigDecimal.ZERO).floatValue(); + List> sqlList = baseMapper.getDayTrend(StrUtil.isBlank(floorId) ? null : Long.parseLong(floorId), StrUtil.isBlank(meterId) ? null : Long.parseLong(meterId), meterType, year, month); + + YearMonth yearMonth = YearMonth.of(Integer.parseInt(year), Integer.parseInt(month)); + // 创建月份--能耗的映射,缺失的月份自动补0 + List dayData = IntStream.rangeClosed(1, yearMonth.lengthOfMonth()) + .mapToObj(day -> { + // 查找对应月份的数据 + Optional> dayResult = sqlList.stream() + .filter(item -> Integer.parseInt(item.get("day").toString()) == day) + .findFirst(); + + // 存在则使用实际值,否则使用0 + String consumption = dayResult + .map(item -> item.get("total_consumption").toString()) + .orElse(BigDecimal.ZERO.toString()); + + return new String[]{String.valueOf(day), consumption}; + }) + .collect(Collectors.toList()); + + + // 计算总能耗(直接使用sqlList中的数据求和,避免二次计算) + Float total = sqlList.stream() + .map(item -> new BigDecimal(item.get("total_consumption").toString())) + .reduce(BigDecimal::add) + .orElse(BigDecimal.ZERO) + .floatValue(); dayMap.put("total", total); dayMap.put("data", dayData); return dayMap; @@ -329,10 +379,32 @@ public class TbMeterRecordServiceImpl implements ITbMeterRecordService { private Map trendMonthData(String floorId, String meterId, Long meterType, String year) { Map resultMap = new HashMap<>(); - List> monthList = baseMapper.getMonthTrend(StrUtil.isBlank(floorId) ? null : Long.parseLong(floorId), StrUtil.isBlank(meterId) ? null : Long.parseLong(meterId), meterType, year); - List monthData = new ArrayList<>(); - monthList.forEach(item -> monthData.add(new String[]{item.get("month").toString(), item.get("total_consumption").toString()})); - Float total = monthList.stream().map(map -> new BigDecimal(map.get("total_consumption").toString())).reduce(BigDecimal::add).orElse(BigDecimal.ZERO).floatValue(); + List> sqlList = baseMapper.getMonthTrend(StrUtil.isBlank(floorId) ? null : Long.parseLong(floorId), StrUtil.isBlank(meterId) ? null : Long.parseLong(meterId), meterType, year); + + // 创建月份--能耗的映射,缺失的月份自动补0 + List monthData = IntStream.rangeClosed(1, 12) + .mapToObj(month -> { + // 查找对应月份的数据 + Optional> monthResult = sqlList.stream() + .filter(item -> Integer.parseInt(item.get("month").toString()) == month) + .findFirst(); + + // 存在则使用实际值,否则使用0 + String consumption = monthResult + .map(item -> item.get("total_consumption").toString()) + .orElse(BigDecimal.ZERO.toString()); + + return new String[]{String.valueOf(month), consumption}; + }) + .collect(Collectors.toList()); + + // 计算总能耗(直接使用sqlList中的数据求和,避免二次计算) + Float total = sqlList.stream() + .map(item -> new BigDecimal(item.get("total_consumption").toString())) + .reduce(BigDecimal::add) + .orElse(BigDecimal.ZERO) + .floatValue(); + resultMap.put("total", total); resultMap.put("data", monthData); return resultMap; From 6fa6c5bf99cf2633144a2bf66ce0ed84793f098d Mon Sep 17 00:00:00 2001 From: lxj <15683799673@163.com> Date: Sun, 14 Sep 2025 22:13:13 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E6=8C=87=E6=B4=BE=E4=BA=BA=E5=91=98?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=83=A8=E9=97=A8=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/dromara/sis/service/impl/SisAlarmEventsServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisAlarmEventsServiceImpl.java b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisAlarmEventsServiceImpl.java index b03b1eeb..25119d44 100644 --- a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisAlarmEventsServiceImpl.java +++ b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisAlarmEventsServiceImpl.java @@ -292,7 +292,7 @@ public class SisAlarmEventsServiceImpl implements ISisAlarmEventsService { events.setSolvePhone(bo.getSolvePhone()); events.setSolveEmail(bo.getSolveEmail()); events.setSolveName(bo.getSolveName()); - events.setSolveDeptId(bo.getSolveDeptId()); + events.setSolveDeptId(attendInfo.getDeptId()); events.setSolveTime(now); events.setState(AlarmStatus.CONFIRMED.getCode()); int i = this.baseMapper.updateById(events); From df8c588ac3a98a3e9e68dfbc00960a5bdfca9c17 Mon Sep 17 00:00:00 2001 From: zcxlsm Date: Mon, 15 Sep 2025 11:36:59 +0800 Subject: [PATCH 03/10] refactor(Property): 1 --- .../property/controller/xcx/XResidentPersonController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 89c177c6..7f9d496a 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 @@ -82,7 +82,7 @@ public class XResidentPersonController extends BaseController { * 新增入驻员工 */ @RepeatSubmit() - @PostMapping() + @PostMapping("/add") @Log(title = "入驻员工", businessType = BusinessType.INSERT) public R add(@Validated(AddGroup.class) @RequestBody ResidentPersonBo bo) { return toAjax(residentPersonService.insertByBo(bo)); From c1ad311c73f058fcdd96737ff7fa6987ac2053e8 Mon Sep 17 00:00:00 2001 From: lxj <15683799673@163.com> Date: Mon, 15 Sep 2025 15:31:47 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E5=A4=84=E7=90=86=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E5=86=85=E5=A4=96=E7=BD=91=E5=90=8C=E6=97=B6?= =?UTF-8?q?=E8=AE=BF=E9=97=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/org/dromara/common/oss/core/OssClient.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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(); } From 3f52dd9091426d2bddce02783ab8df7f2c5ec6c3 Mon Sep 17 00:00:00 2001 From: zcxlsm Date: Mon, 15 Sep 2025 15:58:13 +0800 Subject: [PATCH 05/10] =?UTF-8?q?feat(property):=20-=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BB=AA=E8=A1=A8=E7=B1=BB=E5=9E=8B=E6=9E=9A=E4=B8=BE=E5=B9=B6?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E8=83=BD=E8=80=97=E5=BC=82=E5=B8=B8=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E4=B8=8A=E6=8A=A5=E5=B7=A5=E5=8D=95=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=20-=20=E6=9B=B4=E6=96=B0=20XResidentPersonController=EF=BC=8C?= =?UTF-8?q?=E4=B8=BA=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=A7=9F=E6=88=B7ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xcx/XResidentPersonController.java | 1 + .../domain/bo/ServiceWorkOrdersBo.java | 5 +++ .../bo/smartDevicesBo/TbMeterInfoBo.java | 9 +++++ .../entity/smartDevices/TbMeterInfo.java | 10 ++++++ .../property/domain/enums/MeterTypeEnum.java | 35 ++++++++++++++++++ .../vo/smartDevicesVo/TbMeterInfoVo.java | 11 ++++++ .../RemoteResidentPersonServiceImpl.java | 2 +- .../impl/ServiceWorkOrdersServiceImpl.java | 11 ++++-- .../TbMeterRecordServiceImpl.java | 36 ++++++++++++++++++- 9 files changed, 116 insertions(+), 4 deletions(-) create mode 100644 ruoyi-modules/Property/src/main/java/org/dromara/property/domain/enums/MeterTypeEnum.java 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..095d5ea9 --- /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); From 094d49ab6642b48782c221137bb9c42552aacc9d Mon Sep 17 00:00:00 2001 From: zcxlsm Date: Mon, 15 Sep 2025 16:14:07 +0800 Subject: [PATCH 06/10] feat(property): 1 --- .../java/org/dromara/property/domain/enums/MeterTypeEnum.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 index 095d5ea9..fd7b8da4 100644 --- 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 @@ -11,12 +11,12 @@ import lombok.Getter; public enum MeterTypeEnum { /** - * 水表 + * 电表 */ ELECTRIC_METER(1L, 1963167455478624257L), /** - * 电表 + * 水表 */ WATER_METER(2L, 1963167729677053953L), From 2a4579eb4d80bb84479d1ee4580081e1ae97fcff Mon Sep 17 00:00:00 2001 From: zcxlsm Date: Mon, 15 Sep 2025 17:03:08 +0800 Subject: [PATCH 07/10] feat(property): 1 --- .../service/impl/smartDevicesImpl/TbMeterRecordServiceImpl.java | 1 + 1 file changed, 1 insertion(+) 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 733f7e83..8cdcee3f 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 @@ -258,6 +258,7 @@ public class TbMeterRecordServiceImpl implements ITbMeterRecordService { int hour = record.getReadingTime().toInstant().atZone(ZoneId.systemDefault()).getHour(); ServiceWorkOrdersBo ordersBo = new ServiceWorkOrdersBo(); ordersBo.setTenantId(info.getTenantId()); + ordersBo.setInitiatorName("超级管理员"); // 判断是白天还是夜间 boolean isDaytime = hour > 8 && hour <= 20; From 899b90fde82d392e7d48fac717c0684078605948 Mon Sep 17 00:00:00 2001 From: zcxlsm Date: Mon, 15 Sep 2025 17:03:33 +0800 Subject: [PATCH 08/10] feat(property): 1 --- .../service/impl/smartDevicesImpl/TbMeterRecordServiceImpl.java | 1 - 1 file changed, 1 deletion(-) 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 8cdcee3f..ff396837 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,7 +13,6 @@ 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; From 8eb47ddb11d41522cd7543e6366f381bc5d6fbd2 Mon Sep 17 00:00:00 2001 From: lxj <15683799673@163.com> Date: Mon, 15 Sep 2025 17:20:54 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sis/domain/bo/SisAlarmEventsBo.java | 13 +++++++++++++ .../impl/SisAlarmEventsServiceImpl.java | 19 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/bo/SisAlarmEventsBo.java b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/bo/SisAlarmEventsBo.java index 22498858..9b7a9216 100644 --- a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/bo/SisAlarmEventsBo.java +++ b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/domain/bo/SisAlarmEventsBo.java @@ -126,4 +126,17 @@ public class SisAlarmEventsBo extends BaseEntity { private Date finishTime; private String description; + + /** + * 0: 按id降序 + * 1:按id升序 + * 2:按创建时间降序 + * 3:按创建时间升序 + * 4:按指派时间降序 + * 5 按指派时间升序 + * 6 按完成时间升序 + * 7 按完成时间升序 + */ + private Integer orderBy = 0; + } diff --git a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisAlarmEventsServiceImpl.java b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisAlarmEventsServiceImpl.java index ecf20b02..d6469be7 100644 --- a/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisAlarmEventsServiceImpl.java +++ b/ruoyi-modules/Sis/src/main/java/org/dromara/sis/service/impl/SisAlarmEventsServiceImpl.java @@ -99,6 +99,7 @@ public class SisAlarmEventsServiceImpl implements ISisAlarmEventsService { @Override public TableDataInfo queryPageList(SisAlarmEventsBo bo, PageQuery pageQuery) { LambdaQueryWrapper lqw = buildQueryWrapper(bo); + lqw.orderByDesc(SisAlarmEvents::getId); Page result = baseMapper.selectVoPage(pageQuery.build(), lqw); return TableDataInfo.build(result); @@ -137,6 +138,24 @@ public class SisAlarmEventsServiceImpl implements ISisAlarmEventsService { Date end = DateUtil.endOfDay(bo.getReportTime()); lqw.between(SisAlarmEvents::getReportTime, start, end); } + + if (bo.getOrderBy() == 0) { + lqw.orderByDesc(SisAlarmEvents::getId); + } else if (bo.getOrderBy() == 1) { + lqw.orderByAsc(SisAlarmEvents::getId); + } else if (bo.getOrderBy() == 2) { + lqw.orderByDesc(SisAlarmEvents::getCreateTime); + } else if (bo.getOrderBy() == 3) { + lqw.orderByAsc(SisAlarmEvents::getCreateTime); + } else if (bo.getOrderBy() == 4) { + lqw.orderByDesc(SisAlarmEvents::getSolveTime); + } else if (bo.getOrderBy() == 5) { + lqw.orderByAsc(SisAlarmEvents::getSolveTime); + } else if (bo.getOrderBy() == 6) { + lqw.orderByAsc(SisAlarmEvents::getFinishTime); + } else if (bo.getOrderBy() == 7) { + lqw.orderByAsc(SisAlarmEvents::getFinishTime); + } return lqw; } From b53f977e0b6f48d3c1f962faa5c2e3f5fbc48d09 Mon Sep 17 00:00:00 2001 From: zcxlsm Date: Mon, 15 Sep 2025 19:42:22 +0800 Subject: [PATCH 10/10] =?UTF-8?q?feat(Property):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=B0=B4=E7=94=B5=E6=B0=94=E8=B4=B9=E7=94=A8=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../property/domain/bo/CostHouseChargeBo.java | 2 + .../impl/CostHouseChargeServiceImpl.java | 53 +++++++++++++++++-- .../ITbMeterRecordService.java | 2 +- 3 files changed, 52 insertions(+), 5 deletions(-) diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/bo/CostHouseChargeBo.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/bo/CostHouseChargeBo.java index e1f3a3f9..cf0cf572 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/bo/CostHouseChargeBo.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/bo/CostHouseChargeBo.java @@ -95,5 +95,7 @@ public class CostHouseChargeBo extends BaseEntity { private String remark; + private String chargeTime; + } diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/CostHouseChargeServiceImpl.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/CostHouseChargeServiceImpl.java index e5e6e491..81662af3 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/CostHouseChargeServiceImpl.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/CostHouseChargeServiceImpl.java @@ -2,7 +2,9 @@ package org.dromara.property.service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.convert.Convert; import cn.hutool.core.lang.Assert; +import cn.hutool.core.lang.TypeReference; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.RandomUtil; import org.apache.dubbo.config.annotation.DubboReference; @@ -25,6 +27,9 @@ import org.dromara.property.domain.vo.*; import org.dromara.property.domain.vo.residentVo.ResidentPersonVo; import org.dromara.property.domain.vo.residentVo.ResidentUnitVo; import org.dromara.property.mapper.*; +import org.dromara.property.service.ITbFloorService; +import org.dromara.property.service.ITbRoomService; +import org.dromara.property.service.smartDevicesService.ITbMeterRecordService; import org.dromara.system.api.RemoteDictService; import org.dromara.system.api.RemoteUserService; import org.dromara.system.api.domain.vo.RemoteDictDataVo; @@ -62,6 +67,10 @@ public class CostHouseChargeServiceImpl implements ICostHouseChargeService { @DubboReference private RemoteDictService remoteDictService; + private final ITbRoomService tbRoomService; + private final ITbFloorService tbFloorService; + private final ITbMeterRecordService tbMeterRecordService; + /** * 查询房屋收费 * @@ -185,7 +194,7 @@ public class CostHouseChargeServiceImpl implements ICostHouseChargeService { ResidentUnitVo residentUnitVo = residentUnitMapper.selectVoById(add.getResidentUnitId()); add.setResidentUnitId(residentUnitVo.getId()); add.setArea(residentUnitVo.getArea()); - BigDecimal area = new BigDecimal(add.getArea()); + BigDecimal area = BigDecimal.valueOf(add.getArea()); CostItemsVo costItemsVo = costItemsMapper.selectVoById(add.getCostItemsId()); BigDecimal unitPrice = costItemsVo.getUnitPrice(); // //向上取整 @@ -214,11 +223,11 @@ public class CostHouseChargeServiceImpl implements ICostHouseChargeService { } //类型为5,则为水费 if (Objects.equals(remoteDictDataVo.getDictValue(), "5")) { - - + add.setAmountReceivable(meterCharge(residentUnitVo.getLocation(), area, 2L, bo)); } //类型为6,则为电费 if (Objects.equals(remoteDictDataVo.getDictValue(), "6")) { + add.setAmountReceivable(meterCharge(residentUnitVo.getLocation(), area, 1L, bo)); } //类型为8,则为气费 if (Objects.equals(remoteDictDataVo.getDictValue(), "8")) { @@ -250,8 +259,44 @@ public class CostHouseChargeServiceImpl implements ICostHouseChargeService { /** * 水电气费计算 */ - private void meterCharge(){ + private BigDecimal meterCharge(String location, BigDecimal roomArea, Long meterType, CostHouseChargeBo bo) { + if (StringUtils.isNotBlank(location)) { + String[] roomIds = location.split(","); + Map floorData = new HashMap<>(); // 存储去重的楼层数据 + for (String item : roomIds) { + TbRoomVo roomVo = tbRoomService.queryById(Long.valueOf(item)); + if (roomVo != null) { + Long floorId = roomVo.getFloorId(); + // 保存楼层数据(如果尚未存在) + if (!floorData.containsKey(floorId)) { + // 假设您有获取楼层信息的方法,这里需要根据实际情况调整 + TbFloorVo floorVo = tbFloorService.queryById(floorId); + if (floorVo != null) { + floorData.put(floorId, floorVo); + } + } + } + } + + Float floorArea = 0f; + Float meterEnergy = 0f; + for (Map.Entry entry : floorData.entrySet()) { + floorArea += entry.getValue().getArea(); + Map meterRecord = tbMeterRecordService.getEnergyTrend(entry.getKey().toString(), null, meterType, null, bo.getChargeTime(), null); + Map resultMap = Convert.convert(new TypeReference<>() { + }, meterRecord.get("nowMonth")); + meterEnergy += Convert.convert(Float.class, resultMap.get("total")); + } + + BigDecimal floorAreaBD = Convert.toBigDecimal(floorArea); + BigDecimal meterEnergyBD = Convert.toBigDecimal(meterEnergy); + + return roomArea.divide(floorAreaBD, 10, RoundingMode.HALF_UP) + .multiply(meterEnergyBD) + .multiply(Convert.toBigDecimal(0.9)); + } + return BigDecimal.ZERO; } /** diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/smartDevicesService/ITbMeterRecordService.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/smartDevicesService/ITbMeterRecordService.java index 795ee91e..7714d315 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/smartDevicesService/ITbMeterRecordService.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/smartDevicesService/ITbMeterRecordService.java @@ -14,7 +14,7 @@ import java.util.Map; * 抄记录Service接口 * * @author lsm - * @date 2025-07-19 + * @since 2025-07-19 */ public interface ITbMeterRecordService {