Merge branch 'master' of http://47.109.37.87:3000/by2025/SmartParks
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -81,10 +82,9 @@ public class XResidentPersonController extends BaseController {
|
||||
/**
|
||||
* 新增入驻员工
|
||||
*/
|
||||
@SaCheckPermission("xcx:person:add")
|
||||
@Log(title = "入驻员工", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
@PostMapping("/add")
|
||||
@Log(title = "入驻员工", businessType = BusinessType.INSERT)
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody ResidentPersonBo bo) {
|
||||
return toAjax(residentPersonService.insertByBo(bo));
|
||||
}
|
||||
|
@@ -95,5 +95,7 @@ public class CostHouseChargeBo extends BaseEntity {
|
||||
private String remark;
|
||||
|
||||
|
||||
private String chargeTime;
|
||||
|
||||
|
||||
}
|
||||
|
@@ -120,4 +120,9 @@ public class ServiceWorkOrdersBo extends BaseEntity {
|
||||
*/
|
||||
private String isTimeOut;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
}
|
||||
|
@@ -112,5 +112,14 @@ public class TbMeterInfoBo extends BaseEntity {
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 白天预警阈值
|
||||
*/
|
||||
private BigDecimal dayWarning;
|
||||
|
||||
/**
|
||||
* 夜间预警阈值
|
||||
*/
|
||||
private BigDecimal nightWarning;
|
||||
|
||||
}
|
||||
|
@@ -108,5 +108,15 @@ public class TbMeterInfo extends TenantEntity {
|
||||
*/
|
||||
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 = "备注")
|
||||
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, () -> {
|
||||
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("当前员工未审核");
|
||||
|
@@ -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,9 +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")) {
|
||||
@@ -245,6 +256,49 @@ public class CostHouseChargeServiceImpl implements ICostHouseChargeService {
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 水电气费计算
|
||||
*/
|
||||
private BigDecimal meterCharge(String location, BigDecimal roomArea, Long meterType, CostHouseChargeBo bo) {
|
||||
if (StringUtils.isNotBlank(location)) {
|
||||
String[] roomIds = location.split(",");
|
||||
Map<Long, TbFloorVo> 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<Long, TbFloorVo> entry : floorData.entrySet()) {
|
||||
floorArea += entry.getValue().getArea();
|
||||
Map<String, Object> meterRecord = tbMeterRecordService.getEnergyTrend(entry.getKey().toString(), null, meterType, null, bo.getChargeTime(), null);
|
||||
Map<String, Object> 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 房屋退费
|
||||
*
|
||||
|
@@ -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);
|
||||
|
@@ -13,10 +13,13 @@ 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.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;
|
||||
@@ -27,9 +30,12 @@ import org.dromara.property.service.smartDevicesService.ITbMeterRecordService;
|
||||
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;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
/**
|
||||
* 抄记录Service业务层处理
|
||||
@@ -44,6 +50,7 @@ public class TbMeterRecordServiceImpl implements ITbMeterRecordService {
|
||||
|
||||
private final TbMeterRecordMapper baseMapper;
|
||||
private final ITbMeterInfoService tbMeterInfoService;
|
||||
private final IServiceWorkOrdersService serviceWorkOrdersService;
|
||||
|
||||
/**
|
||||
* 查询抄记录
|
||||
@@ -242,7 +249,36 @@ 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());
|
||||
ordersBo.setInitiatorName("超级管理员");
|
||||
|
||||
// 判断是白天还是夜间
|
||||
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);
|
||||
@@ -267,50 +303,75 @@ public class TbMeterRecordServiceImpl implements ITbMeterRecordService {
|
||||
public Map<String, Object> getEnergyTrend(String floorId, String meterId, Long meterType, String day, String month, String year) {
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
|
||||
String yesterday = DateUtil.format(DateUtil.offsetDay(DateUtil.parse(day), -1), "yyyy-MM-dd");
|
||||
// todayHour
|
||||
Map<String, Object> todayMap = trendHourData(floorId, meterId, meterType, day);
|
||||
// yesterdayHour
|
||||
Map<String, Object> 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<String, Object> todayMap = trendHourData(floorId, meterId, meterType, day);
|
||||
// yesterdayHour
|
||||
Map<String, Object> yesterdayMap = trendHourData(floorId, meterId, meterType, yesterday);
|
||||
|
||||
Map<String, Object> hourMap = new HashMap<>();
|
||||
hourMap.put("today", todayMap);
|
||||
hourMap.put("yesterday", yesterdayMap);
|
||||
Map<String, Object> 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<String, Object> nowMonthMap = trendDayData(floorId, meterId, meterType, monthArr[0], monthArr[1]);
|
||||
// lastMonth
|
||||
Map<String, Object> lastMonthMap = trendDayData(floorId, meterId, meterType, monthArr[0], lastMonth);
|
||||
|
||||
String[] monthArr = month.split("-");
|
||||
String lastMonth = Integer.parseInt(monthArr[1]) - 1 + "";
|
||||
// nowMonth
|
||||
Map<String, Object> nowMonthMap = trendDayData(floorId, meterId, meterType, monthArr[0], monthArr[1]);
|
||||
// lastMonth
|
||||
Map<String, Object> lastMonthMap = trendDayData(floorId, meterId, meterType, monthArr[0], lastMonth);
|
||||
Map<String, Object> dayMap = new HashMap<>();
|
||||
dayMap.put("nowMonth", nowMonthMap);
|
||||
dayMap.put("lastMonth", lastMonthMap);
|
||||
resultMap.put("day", dayMap);
|
||||
}
|
||||
|
||||
Map<String, Object> dayMap = new HashMap<>();
|
||||
dayMap.put("nowMonth", nowMonthMap);
|
||||
dayMap.put("lastMonth", lastMonthMap);
|
||||
if (!StrUtil.isBlank(year)) {
|
||||
String lastYear = Integer.parseInt(year) - 1 + "";
|
||||
// nowYear
|
||||
Map<String, Object> nowYearMap = trendMonthData(floorId, meterId, meterType, year);
|
||||
// lastYear
|
||||
Map<String, Object> lastYearMap = trendMonthData(floorId, meterId, meterType, lastYear);
|
||||
|
||||
String lastYear = Integer.parseInt(year) - 1 + "";
|
||||
// nowYear
|
||||
Map<String, Object> nowYearMap = trendMonthData(floorId, meterId, meterType, year);
|
||||
// lastYear
|
||||
Map<String, Object> lastYearMap = trendMonthData(floorId, meterId, meterType, lastYear);
|
||||
|
||||
Map<String, Object> monthMap = new HashMap<>();
|
||||
monthMap.put("nowYear", nowYearMap);
|
||||
monthMap.put("lastYear", lastYearMap);
|
||||
|
||||
resultMap.put("hour", hourMap);
|
||||
resultMap.put("day", dayMap);
|
||||
resultMap.put("month", monthMap);
|
||||
Map<String, Object> monthMap = new HashMap<>();
|
||||
monthMap.put("nowYear", nowYearMap);
|
||||
monthMap.put("lastYear", lastYearMap);
|
||||
resultMap.put("month", monthMap);
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
private Map<String, Object> trendHourData(String floorId, String meterId, Long meterType, String day) {
|
||||
Map<String, Object> hourMap = new HashMap<>();
|
||||
List<Map<String, Object>> hourList = baseMapper.getHourTrend(StrUtil.isBlank(floorId) ? null : Long.parseLong(floorId), StrUtil.isBlank(meterId) ? null : Long.parseLong(meterId), meterType, day);
|
||||
List<String[]> 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<Map<String, Object>> sqlList = baseMapper.getHourTrend(StrUtil.isBlank(floorId) ? null : Long.parseLong(floorId), StrUtil.isBlank(meterId) ? null : Long.parseLong(meterId), meterType, day);
|
||||
|
||||
// 创建小时--能耗的映射,缺失的小时自动补0
|
||||
List<String[]> hourData = IntStream.rangeClosed(0, 23)
|
||||
.mapToObj(hour -> {
|
||||
// 查找对应小时的数据
|
||||
Optional<Map<String, Object>> 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 +379,33 @@ public class TbMeterRecordServiceImpl implements ITbMeterRecordService {
|
||||
|
||||
private Map<String, Object> trendDayData(String floorId, String meterId, Long meterType, String year, String month) {
|
||||
Map<String, Object> dayMap = new HashMap<>();
|
||||
List<Map<String, Object>> dayList = baseMapper.getDayTrend(StrUtil.isBlank(floorId) ? null : Long.parseLong(floorId), StrUtil.isBlank(meterId) ? null : Long.parseLong(meterId), meterType, year, month);
|
||||
List<String[]> 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<Map<String, Object>> 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<String[]> dayData = IntStream.rangeClosed(1, yearMonth.lengthOfMonth())
|
||||
.mapToObj(day -> {
|
||||
// 查找对应月份的数据
|
||||
Optional<Map<String, Object>> 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 +413,32 @@ public class TbMeterRecordServiceImpl implements ITbMeterRecordService {
|
||||
|
||||
private Map<String, Object> trendMonthData(String floorId, String meterId, Long meterType, String year) {
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
List<Map<String, Object>> monthList = baseMapper.getMonthTrend(StrUtil.isBlank(floorId) ? null : Long.parseLong(floorId), StrUtil.isBlank(meterId) ? null : Long.parseLong(meterId), meterType, year);
|
||||
List<String[]> 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<Map<String, Object>> sqlList = baseMapper.getMonthTrend(StrUtil.isBlank(floorId) ? null : Long.parseLong(floorId), StrUtil.isBlank(meterId) ? null : Long.parseLong(meterId), meterType, year);
|
||||
|
||||
// 创建月份--能耗的映射,缺失的月份自动补0
|
||||
List<String[]> monthData = IntStream.rangeClosed(1, 12)
|
||||
.mapToObj(month -> {
|
||||
// 查找对应月份的数据
|
||||
Optional<Map<String, Object>> 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;
|
||||
|
@@ -14,7 +14,7 @@ import java.util.Map;
|
||||
* 抄记录Service接口
|
||||
*
|
||||
* @author lsm
|
||||
* @date 2025-07-19
|
||||
* @since 2025-07-19
|
||||
*/
|
||||
public interface ITbMeterRecordService {
|
||||
|
||||
|
@@ -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;
|
||||
|
||||
}
|
||||
|
@@ -99,6 +99,7 @@ public class SisAlarmEventsServiceImpl implements ISisAlarmEventsService {
|
||||
@Override
|
||||
public TableDataInfo<SisAlarmEventsVo> queryPageList(SisAlarmEventsBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<SisAlarmEvents> lqw = buildQueryWrapper(bo);
|
||||
|
||||
lqw.orderByDesc(SisAlarmEvents::getId);
|
||||
Page<SisAlarmEventsVo> 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;
|
||||
}
|
||||
|
||||
@@ -292,7 +311,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);
|
||||
|
Reference in New Issue
Block a user