增加行政区划树接口
This commit is contained in:
@@ -25,7 +25,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* 门禁管理
|
||||
* 前端访问路由地址为:/property/accessControl
|
||||
* 前端访问路由地址为:/iot/accessControl
|
||||
*
|
||||
* @author lxj
|
||||
* @date 2025-06-17
|
||||
|
@@ -24,7 +24,7 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 厂商管理
|
||||
* 前端访问路由地址为:/property/factory
|
||||
* 前端访问路由地址为:/iot/factory
|
||||
*
|
||||
* @author lxj
|
||||
* @date 2025-06-17
|
||||
|
@@ -24,7 +24,7 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 水电气配置
|
||||
* 前端访问路由地址为:/system/meterConfig
|
||||
* 前端访问路由地址为:/iot/meterConfig
|
||||
*
|
||||
* @author lxj
|
||||
* @date 2025-06-18
|
||||
|
@@ -1,38 +1,39 @@
|
||||
package org.dromara.iot.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.iot.domain.vo.TdMeterVo;
|
||||
import org.dromara.iot.domain.bo.TdMeterBo;
|
||||
import org.dromara.iot.service.ITdMeterService;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.iot.domain.bo.TdMeterBo;
|
||||
import org.dromara.iot.domain.vo.TdMeterVo;
|
||||
import org.dromara.iot.service.ITdMeterService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 水电气
|
||||
* 前端访问路由地址为:/system/ meter
|
||||
* 前端访问路由地址为:/iot/meter
|
||||
*
|
||||
* @author LionLi
|
||||
* @date 2025-06-18
|
||||
* @date 2025-06-19
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/ meter")
|
||||
@RequestMapping("/meter")
|
||||
public class TdMeterController extends BaseController {
|
||||
|
||||
private final ITdMeterService tdMeterService;
|
||||
@@ -40,17 +41,31 @@ public class TdMeterController extends BaseController {
|
||||
/**
|
||||
* 查询水电气列表
|
||||
*/
|
||||
@SaCheckPermission("system: meter:list")
|
||||
@SaCheckPermission("iot:meter:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<TdMeterVo> list(TdMeterBo bo, PageQuery pageQuery) {
|
||||
return tdMeterService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开或关闭表
|
||||
*
|
||||
* @param meterId 智能表id
|
||||
* @param onOff 0: 打开,2:关闭
|
||||
* @return 是否操作成功
|
||||
*/
|
||||
@SaCheckPermission("iot:meter:operate")
|
||||
@Log(title = "开/关智能表", businessType = BusinessType.OTHER)
|
||||
@GetMapping("/operate/{meterId}/{onOff}")
|
||||
public R<Boolean> operate(@PathVariable("meterId") Long meterId, @PathVariable("onOff") Integer onOff) {
|
||||
return R.ok(tdMeterService.operate(meterId, onOff));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出水电气列表
|
||||
*/
|
||||
@SaCheckPermission("system: meter:export")
|
||||
@Log(title = "水电气", businessType = BusinessType.EXPORT)
|
||||
@SaCheckPermission("iot:meter:export")
|
||||
@Log(title = "导出智能表信息", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(TdMeterBo bo, HttpServletResponse response) {
|
||||
List<TdMeterVo> list = tdMeterService.queryList(bo);
|
||||
@@ -62,7 +77,7 @@ public class TdMeterController extends BaseController {
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("system: meter:query")
|
||||
@SaCheckPermission("iot:meter:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<TdMeterVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable("id") Long id) {
|
||||
@@ -72,8 +87,8 @@ public class TdMeterController extends BaseController {
|
||||
/**
|
||||
* 新增水电气
|
||||
*/
|
||||
@SaCheckPermission("system: meter:add")
|
||||
@Log(title = "水电气", businessType = BusinessType.INSERT)
|
||||
@SaCheckPermission("iot:meter:add")
|
||||
@Log(title = "添加智能表信息", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody TdMeterBo bo) {
|
||||
@@ -83,8 +98,8 @@ public class TdMeterController extends BaseController {
|
||||
/**
|
||||
* 修改水电气
|
||||
*/
|
||||
@SaCheckPermission("system: meter:edit")
|
||||
@Log(title = "水电气", businessType = BusinessType.UPDATE)
|
||||
@SaCheckPermission("iot:meter:edit")
|
||||
@Log(title = "修改智能表信息", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody TdMeterBo bo) {
|
||||
@@ -96,8 +111,8 @@ public class TdMeterController extends BaseController {
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("system: meter:remove")
|
||||
@Log(title = "水电气", businessType = BusinessType.DELETE)
|
||||
@SaCheckPermission("iot:meter:remove")
|
||||
@Log(title = "删除智能表信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable("ids") Long[] ids) {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package org.dromara.system.controller;
|
||||
package org.dromara.iot.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 和房间的关联
|
||||
* 前端访问路由地址为:/system/meterRoom
|
||||
* 前端访问路由地址为:/iot/meterRoom
|
||||
*
|
||||
* @author lxj
|
||||
* @date 2025-06-18
|
||||
|
@@ -1,21 +1,22 @@
|
||||
package org.dromara.iot.domain;
|
||||
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 水电气对象 td_ meter
|
||||
* 水电气对象 td_meter
|
||||
*
|
||||
* @author LionLi
|
||||
* @date 2025-06-18
|
||||
* @date 2025-06-19
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("td_ meter")
|
||||
@TableName("td_meter")
|
||||
public class TdMeter extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
@@ -47,6 +48,21 @@ public class TdMeter extends BaseEntity {
|
||||
*/
|
||||
private Long meterType;
|
||||
|
||||
/**
|
||||
* 表用途(1-分表,2-总表,3-公摊表)
|
||||
*/
|
||||
private Long meterPurpose;
|
||||
|
||||
/**
|
||||
* 分摊类型
|
||||
* 1-不公摊
|
||||
* 2-按分表用量
|
||||
* 3-按租客面积
|
||||
* 4-按房源数量
|
||||
* 5-按固定比例
|
||||
*/
|
||||
private Long shareType;
|
||||
|
||||
/**
|
||||
* 付费类型(1-先付费,2-后付费)
|
||||
*/
|
||||
@@ -58,7 +74,17 @@ public class TdMeter extends BaseEntity {
|
||||
private Long display;
|
||||
|
||||
/**
|
||||
*
|
||||
* 最大表显读数(超过归0)
|
||||
*/
|
||||
private Long maxDisplay;
|
||||
|
||||
/**
|
||||
* 计费倍率
|
||||
*/
|
||||
private Float billingRate;
|
||||
|
||||
/**
|
||||
* 剩余量
|
||||
*/
|
||||
private Long surplus;
|
||||
|
||||
|
@@ -10,11 +10,13 @@ import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.iot.domain.TdMeter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 水电气业务对象 td_ meter
|
||||
* 水电气业务对象 td_meter
|
||||
*
|
||||
* @author lxj
|
||||
* @date 2025-06-18
|
||||
* @author LionLi
|
||||
* @date 2025-06-19
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@@ -36,7 +38,6 @@ public class TdMeterBo extends BaseEntity {
|
||||
/**
|
||||
* 设备编码
|
||||
*/
|
||||
@NotBlank(message = "设备编码不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String meterCode;
|
||||
|
||||
/**
|
||||
@@ -48,34 +49,37 @@ public class TdMeterBo extends BaseEntity {
|
||||
/**
|
||||
* 设备类型(1-电表,2-水表,3-气表)
|
||||
*/
|
||||
@NotNull(message = "设备类型(1-电表,2-水表,3-气表)不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private Long meterType;
|
||||
|
||||
/**
|
||||
* 表用途(1-分表,2-总表,3-公摊表)
|
||||
*/
|
||||
private Long meterPurpose;
|
||||
|
||||
/**
|
||||
* 分摊类型
|
||||
* 1-不公摊
|
||||
* 2-按分表用量
|
||||
* 3-按租客面积
|
||||
* 4-按房源数量
|
||||
* 5-按固定比例
|
||||
*/
|
||||
private Long shareType;
|
||||
|
||||
/**
|
||||
* 付费类型(1-先付费,2-后付费)
|
||||
*/
|
||||
@NotNull(message = "付费类型(1-先付费,2-后付费)不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private Long payType;
|
||||
|
||||
/**
|
||||
* 当前表显示读数
|
||||
* 最大表显读数(超过归0)
|
||||
*/
|
||||
private Long display;
|
||||
private Long maxDisplay;
|
||||
|
||||
/**
|
||||
*
|
||||
* 计费倍率
|
||||
*/
|
||||
private Long surplus;
|
||||
|
||||
/**
|
||||
* 通信状态
|
||||
*/
|
||||
private Long communicationState;
|
||||
|
||||
/**
|
||||
* 运行状态
|
||||
*/
|
||||
private Long runningState;
|
||||
private Float billingRate;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
@@ -83,4 +87,10 @@ public class TdMeterBo extends BaseEntity {
|
||||
private String remark;
|
||||
|
||||
|
||||
/**
|
||||
* 设备厂商
|
||||
*/
|
||||
@NotBlank(message = "表绑定的房间不能为空", groups = {AddGroup.class})
|
||||
private List<Long> roomIds;
|
||||
|
||||
}
|
||||
|
@@ -10,11 +10,12 @@ import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 水电气视图对象 td_ meter
|
||||
* 水电气视图对象 td_meter
|
||||
*
|
||||
* @author lxj
|
||||
* @date 2025-06-18
|
||||
* @author LionLi
|
||||
* @date 2025-06-19
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@@ -54,6 +55,23 @@ public class TdMeterVo implements Serializable {
|
||||
@ExcelProperty(value = "设备类型(1-电表,2-水表,3-气表)")
|
||||
private Long meterType;
|
||||
|
||||
/**
|
||||
* 表用途(1-分表,2-总表,3-公摊表)
|
||||
*/
|
||||
@ExcelProperty(value = "表用途(1-分表,2-总表,3-公摊表)")
|
||||
private Long meterPurpose;
|
||||
|
||||
/**
|
||||
* 分摊类型
|
||||
* 1-不公摊
|
||||
* 2-按分表用量
|
||||
* 3-按租客面积
|
||||
* 4-按房源数量
|
||||
* 5-按固定比例
|
||||
*/
|
||||
@ExcelProperty(value = "分摊类型 1-不公摊 2-按分表用量 3-按租客面积 4-按房源数量 5-按固定比例")
|
||||
private Long shareType;
|
||||
|
||||
/**
|
||||
* 付费类型(1-先付费,2-后付费)
|
||||
*/
|
||||
@@ -67,9 +85,9 @@ public class TdMeterVo implements Serializable {
|
||||
private Long display;
|
||||
|
||||
/**
|
||||
*
|
||||
* 剩余量
|
||||
*/
|
||||
@ExcelProperty(value = "")
|
||||
@ExcelProperty(value = "剩余量")
|
||||
private Long surplus;
|
||||
|
||||
/**
|
||||
|
@@ -8,7 +8,7 @@ import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
* 水电气Mapper接口
|
||||
*
|
||||
* @author LionLi
|
||||
* @date 2025-06-18
|
||||
* @date 2025-06-19
|
||||
*/
|
||||
public interface TdMeterMapper extends BaseMapperPlus<TdMeter, TdMeterVo> {
|
||||
|
||||
|
@@ -2,6 +2,7 @@ package org.dromara.iot.service;
|
||||
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.iot.domain.TdMeterRoom;
|
||||
import org.dromara.iot.domain.bo.TdMeterRoomBo;
|
||||
import org.dromara.iot.domain.vo.TdMeterRoomVo;
|
||||
|
||||
@@ -65,4 +66,20 @@ public interface ITdMeterRoomService {
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
/**
|
||||
* 批量写入表和房间的关联关系
|
||||
*
|
||||
* @param rels 写入数据
|
||||
* @return 是否写入成功
|
||||
*/
|
||||
Boolean insertBatch(List<TdMeterRoom> rels);
|
||||
|
||||
/**
|
||||
* 根据表id删除关联数据
|
||||
* @param meterId 表id
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Integer deleteByMeterId(Long meterId);
|
||||
|
||||
}
|
||||
|
@@ -1,9 +1,10 @@
|
||||
package org.dromara.iot.service;
|
||||
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.iot.domain.bo.TdMeterBo;
|
||||
import org.dromara.iot.domain.TdMeter;
|
||||
import org.dromara.iot.domain.vo.TdMeterVo;
|
||||
import org.dromara.iot.domain.bo.TdMeterBo;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -12,7 +13,7 @@ import java.util.List;
|
||||
* 水电气Service接口
|
||||
*
|
||||
* @author LionLi
|
||||
* @date 2025-06-18
|
||||
* @date 2025-06-19
|
||||
*/
|
||||
public interface ITdMeterService {
|
||||
|
||||
@@ -65,4 +66,13 @@ public interface ITdMeterService {
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
/**
|
||||
* 打开或关闭表
|
||||
*
|
||||
* @param meterId 智能表编码
|
||||
* @param onOff 0: 打开,2:关闭
|
||||
* @return 是否操作成功
|
||||
*/
|
||||
Boolean operate(Long meterId, Integer onOff);
|
||||
}
|
||||
|
@@ -1,24 +1,25 @@
|
||||
package org.dromara.iot.service.impl;
|
||||
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.iot.domain.TdMeterRoom;
|
||||
import org.dromara.iot.domain.bo.TdMeterRoomBo;
|
||||
import org.dromara.iot.domain.vo.TdMeterRoomVo;
|
||||
import org.dromara.iot.domain.TdMeterRoom;
|
||||
import org.dromara.iot.mapper.TdMeterRoomMapper;
|
||||
import org.dromara.iot.service.ITdMeterRoomService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 和房间的关联Service业务层处理
|
||||
@@ -130,4 +131,17 @@ public class TdMeterRoomServiceImpl implements ITdMeterRoomService {
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean insertBatch(List<TdMeterRoom> rels) {
|
||||
return baseMapper.insertBatch(rels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteByMeterId(Long meterId) {
|
||||
Assert.notNull(meterId, "表id不能为null");
|
||||
LambdaUpdateWrapper<TdMeterRoom> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(TdMeterRoom::getMeterId, meterId);
|
||||
return baseMapper.delete(updateWrapper);
|
||||
}
|
||||
}
|
||||
|
@@ -1,30 +1,36 @@
|
||||
package org.dromara.iot.service.impl;
|
||||
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.iot.domain.TdMeter;
|
||||
import org.dromara.iot.domain.TdMeterRoom;
|
||||
import org.dromara.iot.domain.bo.TdMeterBo;
|
||||
import org.dromara.iot.domain.vo.TdMeterVo;
|
||||
import org.dromara.iot.domain.TdMeter;
|
||||
import org.dromara.iot.mapper.TdMeterMapper;
|
||||
import org.dromara.iot.service.ITdMeterRoomService;
|
||||
import org.dromara.iot.service.ITdMeterService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 水电气Service业务层处理
|
||||
*
|
||||
* @author LionLi
|
||||
* @date 2025-06-18
|
||||
* @date 2025-06-19
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@@ -33,6 +39,8 @@ public class TdMeterServiceImpl implements ITdMeterService {
|
||||
|
||||
private final TdMeterMapper baseMapper;
|
||||
|
||||
private final ITdMeterRoomService meterRoomService;
|
||||
|
||||
/**
|
||||
* 查询水电气
|
||||
*
|
||||
@@ -78,11 +86,9 @@ public class TdMeterServiceImpl implements ITdMeterService {
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getMeterCode()), TdMeter::getMeterCode, bo.getMeterCode());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getFactoryNo()), TdMeter::getFactoryNo, bo.getFactoryNo());
|
||||
lqw.eq(bo.getMeterType() != null, TdMeter::getMeterType, bo.getMeterType());
|
||||
lqw.eq(bo.getMeterPurpose() != null, TdMeter::getMeterPurpose, bo.getMeterPurpose());
|
||||
lqw.eq(bo.getShareType() != null, TdMeter::getShareType, bo.getShareType());
|
||||
lqw.eq(bo.getPayType() != null, TdMeter::getPayType, bo.getPayType());
|
||||
lqw.eq(bo.getDisplay() != null, TdMeter::getDisplay, bo.getDisplay());
|
||||
lqw.eq(bo.getSurplus() != null, TdMeter::getSurplus, bo.getSurplus());
|
||||
lqw.eq(bo.getCommunicationState() != null, TdMeter::getCommunicationState, bo.getCommunicationState());
|
||||
lqw.eq(bo.getRunningState() != null, TdMeter::getRunningState, bo.getRunningState());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
@@ -93,14 +99,23 @@ public class TdMeterServiceImpl implements ITdMeterService {
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean insertByBo(TdMeterBo bo) {
|
||||
TdMeter add = MapstructUtils.convert(bo, TdMeter.class);
|
||||
validEntityBeforeSave(add);
|
||||
// 写入表信息
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
return flag;
|
||||
// 写入表和房间的关联信息
|
||||
List<TdMeterRoom> collect = bo.getRoomIds().stream().map(item -> {
|
||||
TdMeterRoom rel = new TdMeterRoom();
|
||||
rel.setMeterId(bo.getId());
|
||||
rel.setRoomId(item);
|
||||
return rel;
|
||||
}).collect(Collectors.toList());
|
||||
return meterRoomService.insertBatch(collect);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,10 +125,28 @@ public class TdMeterServiceImpl implements ITdMeterService {
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean updateByBo(TdMeterBo bo) {
|
||||
TdMeter update = MapstructUtils.convert(bo, TdMeter.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
boolean b = baseMapper.updateById(update) > 0;
|
||||
// 如果关联的房间列表没有发生变化,则不修改
|
||||
if (b && CollUtil.isNotEmpty(bo.getRoomIds())) {
|
||||
// 删除已有的关联关系
|
||||
int num = meterRoomService.deleteByMeterId(bo.getId());
|
||||
log.info("删除智能表和房间关联数据条数: {}", num);
|
||||
// 建立新的关系
|
||||
// 写入表和房间的关联信息
|
||||
List<TdMeterRoom> collect = bo.getRoomIds().stream().map(item -> {
|
||||
TdMeterRoom rel = new TdMeterRoom();
|
||||
rel.setMeterId(bo.getId());
|
||||
rel.setRoomId(item);
|
||||
return rel;
|
||||
}).collect(Collectors.toList());
|
||||
Boolean b1 = meterRoomService.insertBatch(collect);
|
||||
log.info("批量写入智能表和房间的关联关系,result={}", b1);
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,4 +170,17 @@ public class TdMeterServiceImpl implements ITdMeterService {
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean operate(Long meterId, Integer onOff) {
|
||||
// 校验当前表是否存在
|
||||
TdMeterVo tdMeterVo = queryById(meterId);
|
||||
if (tdMeterVo == null) {
|
||||
throw new ServiceException("只能表不存在");
|
||||
}
|
||||
// todo 下发表操作
|
||||
|
||||
// todo 如果同步的情况下还需要更新表信息
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -2,6 +2,6 @@
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.property.mapper.TbAccessControlMapper">
|
||||
<mapper namespace="org.dromara.iot.mapper.TbAccessControlMapper">
|
||||
|
||||
</mapper>
|
||||
|
@@ -2,6 +2,6 @@
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.property.mapper.TdFactoryMapper">
|
||||
<mapper namespace="org.dromara.iot.mapper.TdFactoryMapper">
|
||||
|
||||
</mapper>
|
||||
|
@@ -2,6 +2,6 @@
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.system.mapper.TdMeterConfigMapper">
|
||||
<mapper namespace="org.dromara.iot.mapper.TdMeterConfigMapper">
|
||||
|
||||
</mapper>
|
||||
|
@@ -2,6 +2,6 @@
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.system.mapper.TdMeterMapper">
|
||||
<mapper namespace="org.dromara.iot.mapper.TdMeterMapper">
|
||||
|
||||
</mapper>
|
||||
|
@@ -2,6 +2,6 @@
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.system.mapper.TdMeterRoomMapper">
|
||||
<mapper namespace="org.dromara.iot.mapper.TdMeterRoomMapper">
|
||||
|
||||
</mapper>
|
||||
|
Reference in New Issue
Block a user