Merge branch 'master' of http://47.109.37.87:3000/by2025/SmartParks
All checks were successful
Build and Push to Target Registry / 构建并推送镜像到目标仓库 (push) Successful in 12m2s

This commit is contained in:
lxj
2025-09-14 22:13:54 +08:00
17 changed files with 280 additions and 112 deletions

View File

@@ -21,6 +21,17 @@ public interface RemoteWebSocketMessageService {
*/ */
void publishMessage(List<Long> sessionKey, WebSocketMsgType webSocketMsgType, String data); void publishMessage(List<Long> sessionKey, WebSocketMsgType webSocketMsgType, String data);
/**
* 推送移动端消息
*
* @param sessionKey session主键 一般为用户id
* @param webSocketMsgType webSocket消息类型
* @param title 推送title
* @param content 推送内容
* @param data 推送数据
*/
void pushMobileMessage(List<Long> sessionKey, WebSocketMsgType webSocketMsgType, String title, String content, String data);
/** /**
* 发布订阅的消息(群发) * 发布订阅的消息(群发)
* *

View File

@@ -7,21 +7,21 @@ package org.dromara.resource.api.domain;
*/ */
public enum WebSocketMsgType { public enum WebSocketMsgType {
ALARM_MSG(100), ALARM_MSG("100"),
MOBILE_QRCODE(200); MOBILE_QRCODE("qrcode");
/** /**
* 消息类型编码 * 消息类型编码
* 大类型 - 100,200,300,400 累加100 * 大类型 - 100,200,300,400 累加100
* 小类型 - 101 102 103 累加1 * 小类型 - 101 102 103 累加1
*/ */
private final Integer code; private final String code;
WebSocketMsgType(Integer code) { WebSocketMsgType(String code) {
this.code = code; this.code = code;
} }
public Integer getCode() { public String getCode() {
return code; return code;
} }
} }

View File

@@ -94,11 +94,11 @@ public class TbVisitorManagementController extends BaseController {
if (qrCodeInfo == null) { if (qrCodeInfo == null) {
return R.fail("二维码已过期"); return R.fail("二维码已过期");
} }
JSONObject jsonObject = new JSONObject(); // JSONObject jsonObject = new JSONObject();
jsonObject.put("type", "qrcode"); // jsonObject.put("type", "qrcode");
jsonObject.put("date", qrcode); // jsonObject.put("date", qrcode);
remoteWebSocketMessageService.publishMessage(List.of(qrCodeInfo.getUserid()), WebSocketMsgType.MOBILE_QRCODE, jsonObject.toString()); remoteWebSocketMessageService.publishMessage(List.of(qrCodeInfo.getUserid()), WebSocketMsgType.MOBILE_QRCODE, qrcode);
return R.ok("二维码可用"); return R.ok("二维码可用");
} }

View File

@@ -1,5 +1,6 @@
package org.dromara.property.controller.cockpit; package org.dromara.property.controller.cockpit;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.core.domain.R; import org.dromara.common.core.domain.R;
import org.dromara.common.redis.utils.RedisUtils; import org.dromara.common.redis.utils.RedisUtils;
import org.dromara.property.rocketmq.RocketMqConstants; import org.dromara.property.rocketmq.RocketMqConstants;
@@ -7,9 +8,13 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
/** /**
* 大屏流量接口 * 大屏流量接口
*/ */
@Slf4j
@RestController @RestController
@RequestMapping("/cockpit") @RequestMapping("/cockpit")
public class FlowController { public class FlowController {
@@ -22,7 +27,8 @@ public class FlowController {
@GetMapping("/personFlow/today") @GetMapping("/personFlow/today")
public R<?> getPersonFlowToday() { public R<?> getPersonFlowToday() {
if (RedisUtils.isExistsObject(RocketMqConstants.PASS_RECORD)) { if (RedisUtils.isExistsObject(RocketMqConstants.PASS_RECORD)) {
return R.ok(RedisUtils.getCacheObject(RocketMqConstants.PASS_RECORD)); List<String[]> result = new ArrayList<>(RedisUtils.getCacheObject(RocketMqConstants.PASS_RECORD));
return R.ok(result);
} else { } else {
return R.fail("数据不存在"); return R.fail("数据不存在");
} }

View File

@@ -81,10 +81,9 @@ public class XResidentPersonController extends BaseController {
/** /**
* 新增入驻员工 * 新增入驻员工
*/ */
@SaCheckPermission("xcx:person:add")
@Log(title = "入驻员工", businessType = BusinessType.INSERT)
@RepeatSubmit() @RepeatSubmit()
@PostMapping() @PostMapping()
@Log(title = "入驻员工", businessType = BusinessType.INSERT)
public R<Void> add(@Validated(AddGroup.class) @RequestBody ResidentPersonBo bo) { public R<Void> add(@Validated(AddGroup.class) @RequestBody ResidentPersonBo bo) {
return toAjax(residentPersonService.insertByBo(bo)); return toAjax(residentPersonService.insertByBo(bo));
} }

View File

@@ -102,6 +102,8 @@ public class Clean extends TenantEntity {
*/ */
private String searchValue; private String searchValue;
private Double area;
@TableField(exist = false) @TableField(exist = false)
private CleanRelation cleanRelation; private CleanRelation cleanRelation;

View File

@@ -29,7 +29,7 @@ public class CostItems extends TenantEntity {
private Long id; private Long id;
/** /**
* 费用类型 * 费用类型(0物业费1押金2停车费3维修费4.服务费5水费6电费7租金8其他)
*/ */
private String costType; private String costType;
/** /**

View File

@@ -75,13 +75,13 @@ public class CostItemsBo extends BaseEntity {
/** /**
* 进位方式 * 进位方式
*/ */
@NotBlank(message = "进位方式不能为空", groups = { AddGroup.class, EditGroup.class }) // @NotBlank(message = "进位方式不能为空", groups = { AddGroup.class, EditGroup.class })
private String roundingMode; private String roundingMode;
/** /**
* 保留小数 * 保留小数
*/ */
@NotBlank(message = "保留小数不能为空", groups = { AddGroup.class, EditGroup.class }) // @NotBlank(message = "保留小数不能为空", groups = { AddGroup.class, EditGroup.class })
private String currencyDecimals; private String currencyDecimals;
/** /**
@@ -92,13 +92,13 @@ public class CostItemsBo extends BaseEntity {
/** /**
* 计算公式 * 计算公式
*/ */
@NotBlank(message = "计算公式不能为空", groups = { AddGroup.class, EditGroup.class }) // @NotBlank(message = "计算公式不能为空", groups = { AddGroup.class, EditGroup.class })
private String formula; private String formula;
/** /**
* 计费单价 * 计费单价
*/ */
@NotNull(message = "计费单价不能为空", groups = { AddGroup.class, EditGroup.class }) // @NotNull(message = "计费单价不能为空", groups = { AddGroup.class, EditGroup.class })
@DecimalMin(value = "0.00", inclusive = false, message = "计费单价必须大于0") @DecimalMin(value = "0.00", inclusive = false, message = "计费单价必须大于0")
@ExcelProperty("计费单价") @ExcelProperty("计费单价")
private BigDecimal unitPrice; private BigDecimal unitPrice;

View File

@@ -151,5 +151,4 @@ public class CleanOrderBo extends BaseEntity {
private CleanOrderRecordBo cleanOrderRecord; private CleanOrderRecordBo cleanOrderRecord;
} }

View File

@@ -26,49 +26,49 @@ public class TbMeterRecordBo extends BaseEntity {
/** /**
* 记录ID * 记录ID
*/ */
@NotNull(message = "记录ID不能为空", groups = { EditGroup.class }) @NotNull(message = "记录ID不能为空", groups = {EditGroup.class})
private Long id; private Long id;
/** /**
* 仪表编号 * 仪表编号
*/ */
@NotNull(message = "仪表编号不能为空", groups = { AddGroup.class, EditGroup.class }) @NotNull(message = "仪表编号不能为空", groups = {AddGroup.class, EditGroup.class})
private Long meterId; private Long meterId;
/** /**
* 设备类型(1-电表2-水表3-气表) * 设备类型(1-电表2-水表3-气表)
*/ */
@NotNull(message = "仪表类型不能为空", groups = { AddGroup.class, EditGroup.class }) @NotNull(message = "仪表类型不能为空", groups = {AddGroup.class, EditGroup.class})
private Long meterType; private Long meterType;
/** /**
* 抄表员ID * 抄表员ID
*/ */
@NotNull(message = "抄表员ID不能为空", groups = { AddGroup.class, EditGroup.class }) @NotNull(message = "抄表员ID不能为空", groups = {AddGroup.class, EditGroup.class})
private Long readerId; private Long readerId;
/** /**
* 抄表时间 * 抄表时间
*/ */
@NotNull(message = "抄表时间不能为空", groups = { AddGroup.class, EditGroup.class }) @NotNull(message = "抄表时间不能为空", groups = {AddGroup.class, EditGroup.class})
private Date readingTime; private Date readingTime;
/** /**
* 当前读数 * 当前读数
*/ */
@NotNull(message = "当前读数不能为空", groups = { AddGroup.class, EditGroup.class }) @NotNull(message = "当前读数不能为空", groups = {AddGroup.class, EditGroup.class})
private BigDecimal currentReading; private BigDecimal currentReading;
/** /**
* 上次读数 * 上次读数
*/ */
@NotNull(message = "上次读数不能为空", groups = { AddGroup.class, EditGroup.class }) @NotNull(message = "上次读数不能为空", groups = {AddGroup.class, EditGroup.class})
private BigDecimal previousReading; private BigDecimal previousReading;
/** /**
* 抄表方式(1手动 2自动 3用户上报) * 抄表方式(1手动 2自动 3用户上报)
*/ */
@NotNull(message = "抄表方式(1手动 2自动 3用户上报)不能为空", groups = { AddGroup.class, EditGroup.class }) @NotNull(message = "抄表方式(1手动 2自动 3用户上报)不能为空", groups = {AddGroup.class, EditGroup.class})
private Long readingMethod; private Long readingMethod;
/** /**
@@ -76,5 +76,10 @@ public class TbMeterRecordBo extends BaseEntity {
*/ */
private Long imgOssId; private Long imgOssId;
/**
* 仪表楼层
*/
private Long floorId;
} }

View File

@@ -33,6 +33,12 @@ public class TbMeterRecordVo implements Serializable {
@ExcelProperty(value = "记录ID") @ExcelProperty(value = "记录ID")
private Long id; private Long id;
/**
* 仪表名称
*/
@ExcelProperty(value = "仪表名称")
private String meterName;
/** /**
* 仪表编号 * 仪表编号
*/ */
@@ -87,5 +93,4 @@ public class TbMeterRecordVo implements Serializable {
@ExcelProperty(value = "抄表照片") @ExcelProperty(value = "抄表照片")
private Long imgOssId; private Long imgOssId;
} }

View File

@@ -8,7 +8,6 @@ import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener; import org.apache.rocketmq.spring.core.RocketMQListener;
import org.dromara.common.redis.utils.RedisUtils; import org.dromara.common.redis.utils.RedisUtils;
import org.dromara.property.rocketmq.RocketMqConstants; import org.dromara.property.rocketmq.RocketMqConstants;
import org.dromara.property.rocketmq.domain.MeterResult;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List; import java.util.List;
@@ -32,8 +31,9 @@ public class PassRecordConsumer implements RocketMQListener<MessageExt> {
public void onMessage(MessageExt ext) { public void onMessage(MessageExt ext) {
log.info("消费通行记录上报数据,数据长度={}", ext.getBody().length); log.info("消费通行记录上报数据,数据长度={}", ext.getBody().length);
try { try {
List<Object[]> result = JSONUtil.toList(new String(ext.getBody()), Object[].class); List<String[]> result = JSONUtil.toList(new String(ext.getBody()), String[].class);
RedisUtils.setCacheObject(RocketMqConstants.PASS_RECORD, result); log.info("消费通行记录上报数据,数据={}", result);
RedisUtils.setCacheList(RocketMqConstants.PASS_RECORD, result);
} catch (Exception e) { } catch (Exception e) {
log.error("消费仪表上报数据处理失败,", e); log.error("消费仪表上报数据处理失败,", e);
} }

View File

@@ -6,6 +6,7 @@ import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.RandomUtil;
import org.apache.dubbo.config.annotation.DubboReference; import org.apache.dubbo.config.annotation.DubboReference;
import org.dromara.common.core.utils.DictUtils;
import org.dromara.common.core.utils.MapstructUtils; import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StringUtils; import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.common.mybatis.core.page.TableDataInfo;
@@ -24,7 +25,9 @@ import org.dromara.property.domain.vo.*;
import org.dromara.property.domain.vo.residentVo.ResidentPersonVo; import org.dromara.property.domain.vo.residentVo.ResidentPersonVo;
import org.dromara.property.domain.vo.residentVo.ResidentUnitVo; import org.dromara.property.domain.vo.residentVo.ResidentUnitVo;
import org.dromara.property.mapper.*; import org.dromara.property.mapper.*;
import org.dromara.system.api.RemoteDictService;
import org.dromara.system.api.RemoteUserService; import org.dromara.system.api.RemoteUserService;
import org.dromara.system.api.domain.vo.RemoteDictDataVo;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.dromara.property.domain.bo.CostHouseChargeBo; import org.dromara.property.domain.bo.CostHouseChargeBo;
import org.dromara.property.service.ICostHouseChargeService; import org.dromara.property.service.ICostHouseChargeService;
@@ -32,10 +35,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Collection;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@@ -59,6 +59,9 @@ public class CostHouseChargeServiceImpl implements ICostHouseChargeService {
@DubboReference @DubboReference
private RemoteUserService remoteUserService; private RemoteUserService remoteUserService;
@DubboReference
private RemoteDictService remoteDictService;
/** /**
* 查询房屋收费 * 查询房屋收费
* *
@@ -147,18 +150,18 @@ public class CostHouseChargeServiceImpl implements ICostHouseChargeService {
lqw.orderByDesc(CostHouseCharge::getCreateTime) lqw.orderByDesc(CostHouseCharge::getCreateTime)
.orderByDesc(CostHouseCharge::getUpdateTime); .orderByDesc(CostHouseCharge::getUpdateTime);
List<Long> itemIdList = new ArrayList<>(); List<Long> itemIdList = new ArrayList<>();
if(ObjectUtil.isNotEmpty(bo.getCostType())){ if (ObjectUtil.isNotEmpty(bo.getCostType())) {
List<CostItemsVo> costItemsVos = costItemsMapper.selectVoList( List<CostItemsVo> costItemsVos = costItemsMapper.selectVoList(
new LambdaQueryWrapper<CostItems>() new LambdaQueryWrapper<CostItems>()
.eq(CostItems::getCostType, bo.getCostType()) .eq(CostItems::getCostType, bo.getCostType())
); );
//收集项目id //收集项目id
itemIdList = costItemsVos.stream().map(vo -> vo.getId()).distinct().collect(Collectors.toList()); itemIdList = costItemsVos.stream().map(vo -> vo.getId()).distinct().collect(Collectors.toList());
} }
lqw.in(CollUtil.isNotEmpty(itemIdList), CostHouseCharge::getCostItemsId, itemIdList ); lqw.in(CollUtil.isNotEmpty(itemIdList), CostHouseCharge::getCostItemsId, itemIdList);
lqw.eq(bo.getResidentUnitId() != null, CostHouseCharge::getResidentUnitId, bo.getResidentUnitId()); lqw.eq(bo.getResidentUnitId() != null, CostHouseCharge::getResidentUnitId, bo.getResidentUnitId());
lqw.eq(bo.getCostItemsId() != null, CostHouseCharge::getCostItemsId, bo.getCostItemsId()); lqw.eq(bo.getCostItemsId() != null, CostHouseCharge::getCostItemsId, bo.getCostItemsId());
lqw.eq(bo.getType()!= null, CostHouseCharge::getType, bo.getType()); lqw.eq(bo.getType() != null, CostHouseCharge::getType, bo.getType());
lqw.eq(StringUtils.isNotBlank(bo.getChargeCycle()), CostHouseCharge::getChargeCycle, bo.getChargeCycle()); lqw.eq(StringUtils.isNotBlank(bo.getChargeCycle()), CostHouseCharge::getChargeCycle, bo.getChargeCycle());
lqw.eq(bo.getAmountReceivable() != null, CostHouseCharge::getAmountReceivable, bo.getAmountReceivable()); lqw.eq(bo.getAmountReceivable() != null, CostHouseCharge::getAmountReceivable, bo.getAmountReceivable());
lqw.eq(bo.getStartTime() != null, CostHouseCharge::getStartTime, bo.getStartTime()); lqw.eq(bo.getStartTime() != null, CostHouseCharge::getStartTime, bo.getStartTime());
@@ -185,18 +188,45 @@ public class CostHouseChargeServiceImpl implements ICostHouseChargeService {
BigDecimal area = new BigDecimal(add.getArea()); BigDecimal area = new BigDecimal(add.getArea());
CostItemsVo costItemsVo = costItemsMapper.selectVoById(add.getCostItemsId()); CostItemsVo costItemsVo = costItemsMapper.selectVoById(add.getCostItemsId());
BigDecimal unitPrice = costItemsVo.getUnitPrice(); BigDecimal unitPrice = costItemsVo.getUnitPrice();
//向上取整 // //向上取整
if (costItemsVo.getRoundingMode().equals("1")) { // if (costItemsVo.getRoundingMode().equals("1")) {
add.setAmountReceivable(area.multiply(unitPrice).add(costItemsVo.getSurcharge()).setScale(Integer.valueOf(costItemsVo.getCurrencyDecimals()), BigDecimal.ROUND_UP)); // add.setAmountReceivable(area.multiply(unitPrice).add(costItemsVo.getSurcharge()).setScale(Integer.valueOf(costItemsVo.getCurrencyDecimals()), BigDecimal.ROUND_UP));
} // }
//向下取整 // //向下取整
if (costItemsVo.getRoundingMode().equals("2")) { // if (costItemsVo.getRoundingMode().equals("2")) {
add.setAmountReceivable(area.multiply(unitPrice).add(costItemsVo.getSurcharge()).setScale(Integer.valueOf(costItemsVo.getCurrencyDecimals()), BigDecimal.ROUND_DOWN)); // add.setAmountReceivable(area.multiply(unitPrice).add(costItemsVo.getSurcharge()).setScale(Integer.valueOf(costItemsVo.getCurrencyDecimals()), BigDecimal.ROUND_DOWN));
} // }
//四舍五入 // //四舍五入
if (costItemsVo.getRoundingMode().equals("0")) { // if (costItemsVo.getRoundingMode().equals("0")) {
add.setAmountReceivable(area.multiply(unitPrice).add(costItemsVo.getSurcharge()).setScale(Integer.valueOf(costItemsVo.getCurrencyDecimals()), RoundingMode.HALF_UP)); // add.setAmountReceivable(area.multiply(unitPrice).add(costItemsVo.getSurcharge()).setScale(Integer.valueOf(costItemsVo.getCurrencyDecimals()), RoundingMode.HALF_UP));
// }
List<RemoteDictDataVo> proExpenseType = remoteDictService.selectDictDataByType("pro_expense_type");
//循环proExpenseType
for (RemoteDictDataVo remoteDictDataVo : proExpenseType) {
//类型为0则为物业管理费用设置收费为建筑面积*单价+附加费
if (Objects.equals(remoteDictDataVo.getDictValue(), "0")) {
add.setAmountReceivable(area.multiply(unitPrice).add(costItemsVo.getSurcharge().setScale(Integer.parseInt(costItemsVo.getCurrencyDecimals()), BigDecimal.ROUND_HALF_UP)));
}
//类型为2、7、9则为停车费用、租金、押金设置收费为固定收费
if (Objects.equals(remoteDictDataVo.getDictValue(), "2") || Objects.equals(remoteDictDataVo.getDictValue(), "7") || Objects.equals(remoteDictDataVo.getDictValue(), "9")) {
add.setAmountReceivable(costItemsVo.getSurcharge());
}
//类型为5则为水费
if (Objects.equals(remoteDictDataVo.getDictValue(), "5")) {
}
//类型为6则为电费
if (Objects.equals(remoteDictDataVo.getDictValue(), "6")) {
}
//类型为8则为气费
if (Objects.equals(remoteDictDataVo.getDictValue(), "8")) {
}
} }
add.setChargeStatus(ChargeStatusEnum.PAYMENT_IS_SUBJECT_TO_REVIEW.getValue()); add.setChargeStatus(ChargeStatusEnum.PAYMENT_IS_SUBJECT_TO_REVIEW.getValue());
//area //area
validEntityBeforeSave(add); validEntityBeforeSave(add);
@@ -217,6 +247,13 @@ public class CostHouseChargeServiceImpl implements ICostHouseChargeService {
return flag; return flag;
} }
/**
* 水电气费计算
*/
private void meterCharge(){
}
/** /**
* 房屋退费 * 房屋退费
* *
@@ -297,7 +334,7 @@ public class CostHouseChargeServiceImpl implements ICostHouseChargeService {
.setEndTime(bo.getEndTime()) .setEndTime(bo.getEndTime())
.setReceivableAmount(bo.getAmountReceivable()) .setReceivableAmount(bo.getAmountReceivable())
.setState("0"); .setState("0");
return costPayFeeAuditMapper.insert(CostPayFeeAudit)>0; return costPayFeeAuditMapper.insert(CostPayFeeAudit) > 0;
} }
return flag; return flag;
} }

View File

@@ -228,7 +228,7 @@ public class CleanOrderServiceImpl implements ICleanOrderService {
cleanRelation.setCleanserverOrderId(cleanserverOrderIds.get(i)); cleanRelation.setCleanserverOrderId(cleanserverOrderIds.get(i));
cleanRelation.setCleanId(clean.getId()); cleanRelation.setCleanId(clean.getId());
// cleanRelation.setAreas(clean.getArea()); // cleanRelation.setAreas(clean.getArea());
cleanRelation.setSumPrice(bo.getSumPeices()); cleanRelation.setSumPrice(bo.getCleanList().get(i).getArea() * bo.getCleanList().get(i).getPeices());
cleanRelationMapper.insert(cleanRelation); cleanRelationMapper.insert(cleanRelation);
i++; i++;
} }

View File

@@ -27,9 +27,11 @@ import org.dromara.property.service.smartDevicesService.ITbMeterRecordService;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.YearMonth;
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;
import java.util.stream.IntStream;
/** /**
* 抄记录Service业务层处理 * 抄记录Service业务层处理
@@ -66,7 +68,24 @@ public class TbMeterRecordServiceImpl implements ITbMeterRecordService {
@Override @Override
public TableDataInfo<TbMeterRecordVo> queryPageList(TbMeterRecordBo bo, PageQuery pageQuery) { public TableDataInfo<TbMeterRecordVo> queryPageList(TbMeterRecordBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<TbMeterRecord> lqw = buildQueryWrapper(bo); LambdaQueryWrapper<TbMeterRecord> lqw = buildQueryWrapper(bo);
// 楼层筛选
List<TbMeterInfoVo> infoList = tbMeterInfoService.queryList(new TbMeterInfoBo());
if (bo.getFloorId() != null) {
// 获取对应楼层的仪表ID
Collection<Long> meterIds = infoList.stream().filter(o -> o.getFloorId().equals(bo.getFloorId())).map(TbMeterInfoVo::getId).toList();
if (CollUtil.isNotEmpty(meterIds)) {
lqw.in(TbMeterRecord::getMeterId, meterIds);
} else {
// 添加恒假条件,确保返回空结果
lqw.apply("1 = 0");
}
}
Page<TbMeterRecordVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); Page<TbMeterRecordVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
result.getRecords().forEach(o -> o.setMeterName(infoList.stream().filter(s -> s.getId().equals(o.getMeterId())).findFirst().map(TbMeterInfoVo::getMeterName).orElse(null)));
return TableDataInfo.build(result); return TableDataInfo.build(result);
} }
@@ -83,17 +102,16 @@ public class TbMeterRecordServiceImpl implements ITbMeterRecordService {
} }
private LambdaQueryWrapper<TbMeterRecord> buildQueryWrapper(TbMeterRecordBo bo) { private LambdaQueryWrapper<TbMeterRecord> buildQueryWrapper(TbMeterRecordBo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<TbMeterRecord> lqw = Wrappers.lambdaQuery(); LambdaQueryWrapper<TbMeterRecord> lqw = Wrappers.lambdaQuery();
lqw.orderByAsc(TbMeterRecord::getId); lqw.orderByDesc(TbMeterRecord::getReadingTime);
lqw.eq(bo.getMeterId() != null, TbMeterRecord::getMeterId, bo.getMeterId()); lqw.eq(bo.getMeterId() != null, TbMeterRecord::getMeterId, bo.getMeterId());
lqw.eq(bo.getMeterType() != null, TbMeterRecord::getMeterType, bo.getMeterType());
lqw.eq(bo.getReaderId() != null, TbMeterRecord::getReaderId, bo.getReaderId()); lqw.eq(bo.getReaderId() != null, TbMeterRecord::getReaderId, bo.getReaderId());
lqw.eq(bo.getImgOssId() != null, TbMeterRecord::getImgOssId, bo.getImgOssId());
lqw.eq(bo.getMeterType() != null, TbMeterRecord::getMeterType, bo.getMeterType());
lqw.eq(bo.getReadingTime() != null, TbMeterRecord::getReadingTime, bo.getReadingTime()); lqw.eq(bo.getReadingTime() != null, TbMeterRecord::getReadingTime, bo.getReadingTime());
lqw.eq(bo.getReadingMethod() != null, TbMeterRecord::getReadingMethod, bo.getReadingMethod());
lqw.eq(bo.getCurrentReading() != null, TbMeterRecord::getCurrentReading, bo.getCurrentReading()); lqw.eq(bo.getCurrentReading() != null, TbMeterRecord::getCurrentReading, bo.getCurrentReading());
lqw.eq(bo.getPreviousReading() != null, TbMeterRecord::getPreviousReading, bo.getPreviousReading()); lqw.eq(bo.getPreviousReading() != null, TbMeterRecord::getPreviousReading, bo.getPreviousReading());
lqw.eq(bo.getReadingMethod() != null, TbMeterRecord::getReadingMethod, bo.getReadingMethod());
lqw.eq(bo.getImgOssId() != null, TbMeterRecord::getImgOssId, bo.getImgOssId());
return lqw; return lqw;
} }
@@ -107,11 +125,7 @@ public class TbMeterRecordServiceImpl implements ITbMeterRecordService {
public Boolean insertByBo(TbMeterRecordBo bo) { public Boolean insertByBo(TbMeterRecordBo bo) {
TbMeterRecord add = MapstructUtils.convert(bo, TbMeterRecord.class); TbMeterRecord add = MapstructUtils.convert(bo, TbMeterRecord.class);
validEntityBeforeSave(add); validEntityBeforeSave(add);
boolean flag = baseMapper.insert(add) > 0; return baseMapper.insert(add) > 0;
if (flag) {
bo.setId(add.getId());
}
return flag;
} }
/** /**
@@ -143,9 +157,6 @@ public class TbMeterRecordServiceImpl implements ITbMeterRecordService {
*/ */
@Override @Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if (isValid) {
//TODO 做一些业务上的校验,判断是否需要校验
}
return baseMapper.deleteByIds(ids) > 0; return baseMapper.deleteByIds(ids) > 0;
} }
@@ -203,9 +214,9 @@ public class TbMeterRecordServiceImpl implements ITbMeterRecordService {
// 获取当前读数 // 获取当前读数
int meterCode = Integer.parseInt(info.getMeterCode()); int meterCode = Integer.parseInt(info.getMeterCode());
if (meterCode + 1 <= result.getCollectionValue().size()){ if (meterCode + 1 <= result.getCollectionValue().size()) {
record.setCurrentReading(BigDecimal.valueOf(result.getCollectionValue().get(meterCode))); record.setCurrentReading(BigDecimal.valueOf(result.getCollectionValue().get(meterCode)));
}else { } else {
record.setCurrentReading(BigDecimal.ZERO); record.setCurrentReading(BigDecimal.ZERO);
} }
@@ -227,10 +238,10 @@ public class TbMeterRecordServiceImpl implements ITbMeterRecordService {
// 通信状态改为离线 // 通信状态改为离线
TbMeterInfoBo bo = new TbMeterInfoBo(); TbMeterInfoBo bo = new TbMeterInfoBo();
bo.setId(info.getId()); bo.setId(info.getId());
if (record.getCurrentReading().compareTo(BigDecimal.ZERO) == 0){ if (record.getCurrentReading().compareTo(BigDecimal.ZERO) == 0) {
bo.setCommunicationState(0L); bo.setCommunicationState(0L);
record.setCurrentReading(record.getPreviousReading()); record.setCurrentReading(record.getPreviousReading());
}else { } else {
bo.setCommunicationState(1L); bo.setCommunicationState(1L);
} }
tbMeterInfoService.updateByBo(bo); tbMeterInfoService.updateByBo(bo);
@@ -258,50 +269,75 @@ public class TbMeterRecordServiceImpl implements ITbMeterRecordService {
public Map<String, Object> getEnergyTrend(String floorId, String meterId, Long meterType, String day, String month, String year) { public Map<String, Object> getEnergyTrend(String floorId, String meterId, Long meterType, String day, String month, String year) {
Map<String, Object> resultMap = new HashMap<>(); Map<String, Object> resultMap = new HashMap<>();
String yesterday = DateUtil.format(DateUtil.offsetDay(DateUtil.parse(day), -1), "yyyy-MM-dd"); if (!StrUtil.isBlank(day)) {
// todayHour String yesterday = DateUtil.format(DateUtil.offsetDay(DateUtil.parse(day), -1), "yyyy-MM-dd");
Map<String, Object> todayMap = trendHourData(floorId, meterId, meterType, day); // todayHour
// yesterdayHour Map<String, Object> todayMap = trendHourData(floorId, meterId, meterType, day);
Map<String, Object> yesterdayMap = trendHourData(floorId, meterId, meterType, yesterday); // yesterdayHour
Map<String, Object> yesterdayMap = trendHourData(floorId, meterId, meterType, yesterday);
Map<String, Object> hourMap = new HashMap<>(); Map<String, Object> hourMap = new HashMap<>();
hourMap.put("today", todayMap); hourMap.put("today", todayMap);
hourMap.put("yesterday", yesterdayMap); 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("-"); Map<String, Object> dayMap = new HashMap<>();
String lastMonth = Integer.parseInt(monthArr[1]) - 1 + ""; dayMap.put("nowMonth", nowMonthMap);
// nowMonth dayMap.put("lastMonth", lastMonthMap);
Map<String, Object> nowMonthMap = trendDayData(floorId, meterId, meterType, monthArr[0], monthArr[1]); resultMap.put("day", dayMap);
// lastMonth }
Map<String, Object> lastMonthMap = trendDayData(floorId, meterId, meterType, monthArr[0], lastMonth);
Map<String, Object> dayMap = new HashMap<>(); if (!StrUtil.isBlank(year)) {
dayMap.put("nowMonth", nowMonthMap); String lastYear = Integer.parseInt(year) - 1 + "";
dayMap.put("lastMonth", lastMonthMap); // 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 + ""; Map<String, Object> monthMap = new HashMap<>();
// nowYear monthMap.put("nowYear", nowYearMap);
Map<String, Object> nowYearMap = trendMonthData(floorId, meterId, meterType, year); monthMap.put("lastYear", lastYearMap);
// lastYear resultMap.put("month", monthMap);
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);
return resultMap; return resultMap;
} }
private Map<String, Object> trendHourData(String floorId, String meterId, Long meterType, String day) { private Map<String, Object> trendHourData(String floorId, String meterId, Long meterType, String day) {
Map<String, Object> hourMap = new HashMap<>(); 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<Map<String, Object>> sqlList = 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()})); // 创建小时--能耗的映射缺失的小时自动补0
Float total = hourList.stream().map(map -> new BigDecimal(map.get("total_consumption").toString())).reduce(BigDecimal::add).orElse(BigDecimal.ZERO).floatValue(); 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("total", total);
hourMap.put("data", hourData); hourMap.put("data", hourData);
return hourMap; return hourMap;
@@ -309,10 +345,33 @@ public class TbMeterRecordServiceImpl implements ITbMeterRecordService {
private Map<String, Object> trendDayData(String floorId, String meterId, Long meterType, String year, String month) { private Map<String, Object> trendDayData(String floorId, String meterId, Long meterType, String year, String month) {
Map<String, Object> dayMap = new HashMap<>(); 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<Map<String, Object>> sqlList = 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()})); YearMonth yearMonth = YearMonth.of(Integer.parseInt(year), Integer.parseInt(month));
Float total = dayList.stream().map(map -> new BigDecimal(map.get("total_consumption").toString())).reduce(BigDecimal::add).orElse(BigDecimal.ZERO).floatValue(); // 创建月份--能耗的映射缺失的月份自动补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("total", total);
dayMap.put("data", dayData); dayMap.put("data", dayData);
return dayMap; return dayMap;
@@ -320,10 +379,32 @@ public class TbMeterRecordServiceImpl implements ITbMeterRecordService {
private Map<String, Object> trendMonthData(String floorId, String meterId, Long meterType, String year) { private Map<String, Object> trendMonthData(String floorId, String meterId, Long meterType, String year) {
Map<String, Object> resultMap = new HashMap<>(); 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<Map<String, Object>> sqlList = 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()})); // 创建月份--能耗的映射缺失的月份自动补0
Float total = monthList.stream().map(map -> new BigDecimal(map.get("total_consumption").toString())).reduce(BigDecimal::add).orElse(BigDecimal.ZERO).floatValue(); 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("total", total);
resultMap.put("data", monthData); resultMap.put("data", monthData);
return resultMap; return resultMap;

View File

@@ -310,7 +310,9 @@ public class SisAlarmEventsServiceImpl implements ISisAlarmEventsService {
Boolean insert = alarmEventProcessService.insert(process); Boolean insert = alarmEventProcessService.insert(process);
log.info("事件处理信息写入完成,result= {}", insert); log.info("事件处理信息写入完成,result= {}", insert);
// 进行消息推送 // 进行消息推送
webSocketMessageService.publishMessage(List.of(bo.getSolveId()), WebSocketMsgType.ALARM_MSG, JSONObject.toJSONString(sisAlarmEvents)); String title = "视频预警";
String content = "您有一条" + sisAlarmEvents.getSolveName() + "预警数据";
webSocketMessageService.pushMobileMessage(List.of(bo.getSolveId()), WebSocketMsgType.ALARM_MSG, title, content, JSONObject.toJSONString(sisAlarmEvents));
return true; return true;
} }

View File

@@ -33,6 +33,18 @@ public class RemoteWebSocketMessageServiceImpl implements RemoteWebSocketMessage
} }
} }
@Override
public void pushMobileMessage(List<Long> sessionKey, WebSocketMsgType webSocketMsgType, String title, String content, String data) {
WebSocketMessageDto dto = new WebSocketMessageDto();
dto.setSessionKeys(sessionKey);
dto.setMessage(createMsg(webSocketMsgType, title, content, data));
try {
WebSocketUtils.publishMessage(dto);
} catch (Exception e) {
log.error("发送分布式消息失败,error:{}", e.getMessage());
}
}
@Override @Override
public void publishAll(WebSocketMsgType webSocketMsgType, String data) { public void publishAll(WebSocketMsgType webSocketMsgType, String data) {
try { try {
@@ -55,7 +67,16 @@ public class RemoteWebSocketMessageServiceImpl implements RemoteWebSocketMessage
private String createMsg(WebSocketMsgType webSocketMsgType, Object data) { private String createMsg(WebSocketMsgType webSocketMsgType, Object data) {
JSONObject msg = new JSONObject(); JSONObject msg = new JSONObject();
msg.put("code", webSocketMsgType.getCode()); msg.put("type", webSocketMsgType.getCode());
msg.put("data", data);
return msg.toJSONString();
}
private String createMsg(WebSocketMsgType webSocketMsgType, String title, String content, Object data) {
JSONObject msg = new JSONObject();
msg.put("type", webSocketMsgType.getCode());
msg.put("title", title);
msg.put("content", content);
msg.put("data", data); msg.put("data", data);
return msg.toJSONString(); return msg.toJSONString();
} }