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
All checks were successful
Build and Push to Target Registry / 构建并推送镜像到目标仓库 (push) Successful in 12m2s
This commit is contained in:
@@ -21,6 +21,17 @@ public interface RemoteWebSocketMessageService {
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* 发布订阅的消息(群发)
|
||||
*
|
||||
|
@@ -7,21 +7,21 @@ package org.dromara.resource.api.domain;
|
||||
*/
|
||||
public enum WebSocketMsgType {
|
||||
|
||||
ALARM_MSG(100),
|
||||
ALARM_MSG("100"),
|
||||
|
||||
MOBILE_QRCODE(200);
|
||||
MOBILE_QRCODE("qrcode");
|
||||
/**
|
||||
* 消息类型编码
|
||||
* 大类型 - 100,200,300,400 累加100
|
||||
* 小类型 - 101, 102, 103 累加1
|
||||
*/
|
||||
private final Integer code;
|
||||
private final String code;
|
||||
|
||||
WebSocketMsgType(Integer code) {
|
||||
WebSocketMsgType(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
@@ -94,11 +94,11 @@ public class TbVisitorManagementController extends BaseController {
|
||||
if (qrCodeInfo == null) {
|
||||
return R.fail("二维码已过期");
|
||||
}
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("type", "qrcode");
|
||||
jsonObject.put("date", qrcode);
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// jsonObject.put("type", "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("二维码可用");
|
||||
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package org.dromara.property.controller.cockpit;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.redis.utils.RedisUtils;
|
||||
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.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 大屏流量接口
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/cockpit")
|
||||
public class FlowController {
|
||||
@@ -22,7 +27,8 @@ public class FlowController {
|
||||
@GetMapping("/personFlow/today")
|
||||
public R<?> getPersonFlowToday() {
|
||||
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 {
|
||||
return R.fail("数据不存在");
|
||||
}
|
||||
|
@@ -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<Void> add(@Validated(AddGroup.class) @RequestBody ResidentPersonBo bo) {
|
||||
return toAjax(residentPersonService.insertByBo(bo));
|
||||
}
|
||||
|
@@ -102,6 +102,8 @@ public class Clean extends TenantEntity {
|
||||
*/
|
||||
private String searchValue;
|
||||
|
||||
private Double area;
|
||||
|
||||
@TableField(exist = false)
|
||||
private CleanRelation cleanRelation;
|
||||
|
||||
|
@@ -29,7 +29,7 @@ public class CostItems extends TenantEntity {
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 费用类型
|
||||
* 费用类型(0物业费1押金2停车费3维修费4.服务费5水费6电费7租金8其他)
|
||||
*/
|
||||
private String costType;
|
||||
/**
|
||||
|
@@ -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;
|
||||
|
||||
/**
|
||||
* 保留小数
|
||||
*/
|
||||
@NotBlank(message = "保留小数不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
// @NotBlank(message = "保留小数不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
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;
|
||||
|
||||
/**
|
||||
* 计费单价
|
||||
*/
|
||||
@NotNull(message = "计费单价不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
// @NotNull(message = "计费单价不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
@DecimalMin(value = "0.00", inclusive = false, message = "计费单价必须大于0")
|
||||
@ExcelProperty("计费单价")
|
||||
private BigDecimal unitPrice;
|
||||
|
@@ -151,5 +151,4 @@ public class CleanOrderBo extends BaseEntity {
|
||||
|
||||
private CleanOrderRecordBo cleanOrderRecord;
|
||||
|
||||
|
||||
}
|
||||
|
@@ -26,49 +26,49 @@ public class TbMeterRecordBo extends BaseEntity {
|
||||
/**
|
||||
* 记录ID
|
||||
*/
|
||||
@NotNull(message = "记录ID不能为空", groups = { EditGroup.class })
|
||||
@NotNull(message = "记录ID不能为空", groups = {EditGroup.class})
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 仪表编号
|
||||
*/
|
||||
@NotNull(message = "仪表编号不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
@NotNull(message = "仪表编号不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private Long meterId;
|
||||
|
||||
/**
|
||||
* 设备类型(1-电表,2-水表,3-气表)
|
||||
*/
|
||||
@NotNull(message = "仪表类型不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
@NotNull(message = "仪表类型不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private Long meterType;
|
||||
|
||||
/**
|
||||
* 抄表员ID
|
||||
*/
|
||||
@NotNull(message = "抄表员ID不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
@NotNull(message = "抄表员ID不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private Long readerId;
|
||||
|
||||
/**
|
||||
* 抄表时间
|
||||
*/
|
||||
@NotNull(message = "抄表时间不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
@NotNull(message = "抄表时间不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private Date readingTime;
|
||||
|
||||
/**
|
||||
* 当前读数
|
||||
*/
|
||||
@NotNull(message = "当前读数不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
@NotNull(message = "当前读数不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private BigDecimal currentReading;
|
||||
|
||||
/**
|
||||
* 上次读数
|
||||
*/
|
||||
@NotNull(message = "上次读数不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
@NotNull(message = "上次读数不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private BigDecimal previousReading;
|
||||
|
||||
/**
|
||||
* 抄表方式(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;
|
||||
|
||||
/**
|
||||
@@ -76,5 +76,10 @@ public class TbMeterRecordBo extends BaseEntity {
|
||||
*/
|
||||
private Long imgOssId;
|
||||
|
||||
/**
|
||||
* 仪表楼层
|
||||
*/
|
||||
private Long floorId;
|
||||
|
||||
|
||||
}
|
||||
|
@@ -33,6 +33,12 @@ public class TbMeterRecordVo implements Serializable {
|
||||
@ExcelProperty(value = "记录ID")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 仪表名称
|
||||
*/
|
||||
@ExcelProperty(value = "仪表名称")
|
||||
private String meterName;
|
||||
|
||||
/**
|
||||
* 仪表编号
|
||||
*/
|
||||
@@ -87,5 +93,4 @@ public class TbMeterRecordVo implements Serializable {
|
||||
@ExcelProperty(value = "抄表照片")
|
||||
private Long imgOssId;
|
||||
|
||||
|
||||
}
|
||||
|
@@ -8,7 +8,6 @@ import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
||||
import org.apache.rocketmq.spring.core.RocketMQListener;
|
||||
import org.dromara.common.redis.utils.RedisUtils;
|
||||
import org.dromara.property.rocketmq.RocketMqConstants;
|
||||
import org.dromara.property.rocketmq.domain.MeterResult;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
@@ -32,8 +31,9 @@ public class PassRecordConsumer implements RocketMQListener<MessageExt> {
|
||||
public void onMessage(MessageExt ext) {
|
||||
log.info("消费通行记录上报数据,数据长度={}", ext.getBody().length);
|
||||
try {
|
||||
List<Object[]> result = JSONUtil.toList(new String(ext.getBody()), Object[].class);
|
||||
RedisUtils.setCacheObject(RocketMqConstants.PASS_RECORD, result);
|
||||
List<String[]> result = JSONUtil.toList(new String(ext.getBody()), String[].class);
|
||||
log.info("消费通行记录上报数据,数据={}", result);
|
||||
RedisUtils.setCacheList(RocketMqConstants.PASS_RECORD, result);
|
||||
} catch (Exception e) {
|
||||
log.error("消费仪表上报数据处理失败,", e);
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@ import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
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.StringUtils;
|
||||
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.ResidentUnitVo;
|
||||
import org.dromara.property.mapper.*;
|
||||
import org.dromara.system.api.RemoteDictService;
|
||||
import org.dromara.system.api.RemoteUserService;
|
||||
import org.dromara.system.api.domain.vo.RemoteDictDataVo;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.property.domain.bo.CostHouseChargeBo;
|
||||
import org.dromara.property.service.ICostHouseChargeService;
|
||||
@@ -32,10 +35,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -59,6 +59,9 @@ public class CostHouseChargeServiceImpl implements ICostHouseChargeService {
|
||||
@DubboReference
|
||||
private RemoteUserService remoteUserService;
|
||||
|
||||
@DubboReference
|
||||
private RemoteDictService remoteDictService;
|
||||
|
||||
/**
|
||||
* 查询房屋收费
|
||||
*
|
||||
@@ -147,18 +150,18 @@ public class CostHouseChargeServiceImpl implements ICostHouseChargeService {
|
||||
lqw.orderByDesc(CostHouseCharge::getCreateTime)
|
||||
.orderByDesc(CostHouseCharge::getUpdateTime);
|
||||
List<Long> itemIdList = new ArrayList<>();
|
||||
if(ObjectUtil.isNotEmpty(bo.getCostType())){
|
||||
if (ObjectUtil.isNotEmpty(bo.getCostType())) {
|
||||
List<CostItemsVo> costItemsVos = costItemsMapper.selectVoList(
|
||||
new LambdaQueryWrapper<CostItems>()
|
||||
.eq(CostItems::getCostType, bo.getCostType())
|
||||
);
|
||||
//收集项目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.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(bo.getAmountReceivable() != null, CostHouseCharge::getAmountReceivable, bo.getAmountReceivable());
|
||||
lqw.eq(bo.getStartTime() != null, CostHouseCharge::getStartTime, bo.getStartTime());
|
||||
@@ -185,18 +188,45 @@ public class CostHouseChargeServiceImpl implements ICostHouseChargeService {
|
||||
BigDecimal area = new BigDecimal(add.getArea());
|
||||
CostItemsVo costItemsVo = costItemsMapper.selectVoById(add.getCostItemsId());
|
||||
BigDecimal unitPrice = costItemsVo.getUnitPrice();
|
||||
//向上取整
|
||||
if (costItemsVo.getRoundingMode().equals("1")) {
|
||||
add.setAmountReceivable(area.multiply(unitPrice).add(costItemsVo.getSurcharge()).setScale(Integer.valueOf(costItemsVo.getCurrencyDecimals()), BigDecimal.ROUND_UP));
|
||||
}
|
||||
//向下取整
|
||||
if (costItemsVo.getRoundingMode().equals("2")) {
|
||||
add.setAmountReceivable(area.multiply(unitPrice).add(costItemsVo.getSurcharge()).setScale(Integer.valueOf(costItemsVo.getCurrencyDecimals()), BigDecimal.ROUND_DOWN));
|
||||
}
|
||||
//四舍五入
|
||||
if (costItemsVo.getRoundingMode().equals("0")) {
|
||||
add.setAmountReceivable(area.multiply(unitPrice).add(costItemsVo.getSurcharge()).setScale(Integer.valueOf(costItemsVo.getCurrencyDecimals()), RoundingMode.HALF_UP));
|
||||
// //向上取整
|
||||
// if (costItemsVo.getRoundingMode().equals("1")) {
|
||||
// add.setAmountReceivable(area.multiply(unitPrice).add(costItemsVo.getSurcharge()).setScale(Integer.valueOf(costItemsVo.getCurrencyDecimals()), BigDecimal.ROUND_UP));
|
||||
// }
|
||||
// //向下取整
|
||||
// if (costItemsVo.getRoundingMode().equals("2")) {
|
||||
// add.setAmountReceivable(area.multiply(unitPrice).add(costItemsVo.getSurcharge()).setScale(Integer.valueOf(costItemsVo.getCurrencyDecimals()), BigDecimal.ROUND_DOWN));
|
||||
// }
|
||||
// //四舍五入
|
||||
// if (costItemsVo.getRoundingMode().equals("0")) {
|
||||
// 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());
|
||||
//area
|
||||
validEntityBeforeSave(add);
|
||||
@@ -217,6 +247,13 @@ public class CostHouseChargeServiceImpl implements ICostHouseChargeService {
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 水电气费计算
|
||||
*/
|
||||
private void meterCharge(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 房屋退费
|
||||
*
|
||||
@@ -297,7 +334,7 @@ public class CostHouseChargeServiceImpl implements ICostHouseChargeService {
|
||||
.setEndTime(bo.getEndTime())
|
||||
.setReceivableAmount(bo.getAmountReceivable())
|
||||
.setState("0");
|
||||
return costPayFeeAuditMapper.insert(CostPayFeeAudit)>0;
|
||||
return costPayFeeAuditMapper.insert(CostPayFeeAudit) > 0;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
@@ -228,7 +228,7 @@ public class CleanOrderServiceImpl implements ICleanOrderService {
|
||||
cleanRelation.setCleanserverOrderId(cleanserverOrderIds.get(i));
|
||||
cleanRelation.setCleanId(clean.getId());
|
||||
// cleanRelation.setAreas(clean.getArea());
|
||||
cleanRelation.setSumPrice(bo.getSumPeices());
|
||||
cleanRelation.setSumPrice(bo.getCleanList().get(i).getArea() * bo.getCleanList().get(i).getPeices());
|
||||
cleanRelationMapper.insert(cleanRelation);
|
||||
i++;
|
||||
}
|
||||
|
@@ -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业务层处理
|
||||
@@ -66,7 +68,24 @@ public class TbMeterRecordServiceImpl implements ITbMeterRecordService {
|
||||
@Override
|
||||
public TableDataInfo<TbMeterRecordVo> queryPageList(TbMeterRecordBo bo, PageQuery pageQuery) {
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -83,17 +102,16 @@ public class TbMeterRecordServiceImpl implements ITbMeterRecordService {
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<TbMeterRecord> buildQueryWrapper(TbMeterRecordBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
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.getMeterType() != null, TbMeterRecord::getMeterType, bo.getMeterType());
|
||||
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.getReadingMethod() != null, TbMeterRecord::getReadingMethod, bo.getReadingMethod());
|
||||
lqw.eq(bo.getCurrentReading() != null, TbMeterRecord::getCurrentReading, bo.getCurrentReading());
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -107,11 +125,7 @@ public class TbMeterRecordServiceImpl implements ITbMeterRecordService {
|
||||
public Boolean insertByBo(TbMeterRecordBo bo) {
|
||||
TbMeterRecord add = MapstructUtils.convert(bo, TbMeterRecord.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
return flag;
|
||||
return baseMapper.insert(add) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,9 +157,6 @@ public class TbMeterRecordServiceImpl implements ITbMeterRecordService {
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if (isValid) {
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
|
||||
@@ -203,9 +214,9 @@ public class TbMeterRecordServiceImpl implements ITbMeterRecordService {
|
||||
|
||||
// 获取当前读数
|
||||
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)));
|
||||
}else {
|
||||
} else {
|
||||
record.setCurrentReading(BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
@@ -227,10 +238,10 @@ public class TbMeterRecordServiceImpl implements ITbMeterRecordService {
|
||||
// 通信状态改为离线
|
||||
TbMeterInfoBo bo = new TbMeterInfoBo();
|
||||
bo.setId(info.getId());
|
||||
if (record.getCurrentReading().compareTo(BigDecimal.ZERO) == 0){
|
||||
if (record.getCurrentReading().compareTo(BigDecimal.ZERO) == 0) {
|
||||
bo.setCommunicationState(0L);
|
||||
record.setCurrentReading(record.getPreviousReading());
|
||||
}else {
|
||||
} else {
|
||||
bo.setCommunicationState(1L);
|
||||
}
|
||||
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) {
|
||||
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;
|
||||
@@ -309,10 +345,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;
|
||||
@@ -320,10 +379,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;
|
||||
|
@@ -310,7 +310,9 @@ public class SisAlarmEventsServiceImpl implements ISisAlarmEventsService {
|
||||
Boolean insert = alarmEventProcessService.insert(process);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
public void publishAll(WebSocketMsgType webSocketMsgType, String data) {
|
||||
try {
|
||||
@@ -55,7 +67,16 @@ public class RemoteWebSocketMessageServiceImpl implements RemoteWebSocketMessage
|
||||
|
||||
private String createMsg(WebSocketMsgType webSocketMsgType, Object data) {
|
||||
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);
|
||||
return msg.toJSONString();
|
||||
}
|
||||
|
Reference in New Issue
Block a user