Compare commits
2 Commits
17b028c6cd
...
d6903acf64
Author | SHA1 | Date | |
---|---|---|---|
d6903acf64 | |||
fabb2d8abc |
@ -0,0 +1,15 @@
|
||||
package org.dromara.common.core.domain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 通用tree构建工具类
|
||||
* @param <E>
|
||||
*/
|
||||
public interface TreeEntity<E, T> {
|
||||
T getId();
|
||||
|
||||
T getParentId();
|
||||
|
||||
void setChildren(List<E> children);
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package org.dromara.common.core.utils;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import org.dromara.common.core.domain.TreeEntity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* *解析树形数据工具类
|
||||
*/
|
||||
public class TreeUtils {
|
||||
|
||||
/**
|
||||
* 将列表数据构建成树结构
|
||||
*
|
||||
* @param entityList 列表数据
|
||||
* @param rootCode 根节点编码
|
||||
* @return 构建树状
|
||||
*/
|
||||
public static <T extends TreeEntity<T, ?>> List<T> getTreeList(List<T> entityList, Object rootCode) {
|
||||
if (CollectionUtil.isEmpty(entityList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
//第一次循环 数据分组
|
||||
Map<Object, List<T>> groupData = new HashMap<>();
|
||||
for (T entity : entityList) {
|
||||
groupData.computeIfAbsent(entity.getParentId(), (k) -> new ArrayList<>()).add(entity);
|
||||
}
|
||||
// 第二次循环 生成树结构
|
||||
for (TreeEntity<T, ?> entity : entityList) {
|
||||
List<T> children = groupData.get(entity.getId());
|
||||
if (children != null) {
|
||||
entity.setChildren(children);
|
||||
} else {
|
||||
entity.setChildren(new ArrayList<>());
|
||||
}
|
||||
}
|
||||
return groupData.get(rootCode);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import java.util.List;
|
||||
* 水电气Service接口
|
||||
*
|
||||
* @author LionLi
|
||||
* @date 2025-06-18
|
||||
* @date 2025-06-19
|
||||
*/
|
||||
public interface ITdMeterService {
|
||||
|
||||
@ -65,4 +65,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>
|
||||
|
@ -1,26 +1,31 @@
|
||||
package org.dromara.property.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 com.alibaba.fastjson2.JSONObject;
|
||||
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.property.domain.vo.TbCityAreaVo;
|
||||
import org.dromara.property.domain.bo.TbCityAreaBo;
|
||||
import org.dromara.property.service.ITbCityAreaService;
|
||||
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.property.domain.bo.SysCityAreaBo;
|
||||
import org.dromara.property.domain.vo.CityAreaTreeVo;
|
||||
import org.dromara.property.domain.vo.SysCityAreaVo;
|
||||
import org.dromara.property.service.ISysCityAreaService;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 行政区划
|
||||
@ -34,9 +39,9 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/cityArea")
|
||||
public class TbCityAreaController extends BaseController {
|
||||
public class SysCityAreaController extends BaseController implements ApplicationRunner {
|
||||
|
||||
private final ITbCityAreaService tbCityAreaService;
|
||||
private final ISysCityAreaService SysCityAreaService;
|
||||
|
||||
/**
|
||||
* 查询行政区划
|
||||
@ -44,8 +49,8 @@ public class TbCityAreaController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("property:cityArea:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<TbCityAreaVo> list(TbCityAreaBo bo, PageQuery pageQuery) {
|
||||
return tbCityAreaService.queryPageList(bo, pageQuery);
|
||||
public TableDataInfo<SysCityAreaVo> list(SysCityAreaBo bo, PageQuery pageQuery) {
|
||||
return SysCityAreaService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,22 +60,20 @@ public class TbCityAreaController extends BaseController {
|
||||
@SaCheckPermission("property:cityArea:export")
|
||||
@Log(title = "行政区划", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(TbCityAreaBo bo, HttpServletResponse response) {
|
||||
List<TbCityAreaVo> list = tbCityAreaService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "行政区划", TbCityAreaVo.class, response);
|
||||
public void export(SysCityAreaBo bo, HttpServletResponse response) {
|
||||
List<SysCityAreaVo> list = SysCityAreaService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "行政区划", SysCityAreaVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取行政区划
|
||||
详细信息
|
||||
*
|
||||
* 获取行政区划详细信息
|
||||
* @param areaCode 主键
|
||||
*/
|
||||
@SaCheckPermission("property:cityArea:query")
|
||||
@GetMapping("/{areaCode}")
|
||||
public R<TbCityAreaVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
public R<SysCityAreaVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable("areaCode") String areaCode) {
|
||||
return R.ok(tbCityAreaService.queryById(areaCode));
|
||||
return R.ok(SysCityAreaService.queryById(areaCode));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -81,8 +84,8 @@ public class TbCityAreaController extends BaseController {
|
||||
@Log(title = "行政区划", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody TbCityAreaBo bo) {
|
||||
return toAjax(tbCityAreaService.insertByBo(bo));
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody SysCityAreaBo bo) {
|
||||
return toAjax(SysCityAreaService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -93,8 +96,8 @@ public class TbCityAreaController extends BaseController {
|
||||
@Log(title = "行政区划", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody TbCityAreaBo bo) {
|
||||
return toAjax(tbCityAreaService.updateByBo(bo));
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysCityAreaBo bo) {
|
||||
return toAjax(SysCityAreaService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -108,6 +111,25 @@ public class TbCityAreaController extends BaseController {
|
||||
@DeleteMapping("/{areaCodes}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable("areaCodes") String[] areaCodes) {
|
||||
return toAjax(tbCityAreaService.deleteWithValidByIds(List.of(areaCodes), true));
|
||||
return toAjax(SysCityAreaService.deleteWithValidByIds(List.of(areaCodes), true));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询行政区划树结构
|
||||
*
|
||||
* @return 返回行政区划树结构
|
||||
*/
|
||||
@GetMapping("/treeList")
|
||||
public R<List<CityAreaTreeVo>> queryTreeList() {
|
||||
List<CityAreaTreeVo> list = SysCityAreaService.queryTreeList();
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
R<List<CityAreaTreeVo>> listR = queryTreeList();
|
||||
System.out.println(JSONObject.toJSONString(listR));
|
||||
}
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
package org.dromara.property.domain;
|
||||
|
||||
import org.dromara.common.tenant.core.TenantEntity;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 行政区划
|
||||
@ -15,9 +15,8 @@ import java.io.Serial;
|
||||
* @date 2025-06-18
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("tb_city_area")
|
||||
public class TbCityArea extends TenantEntity {
|
||||
@TableName("sys_city_area")
|
||||
public class SysCityArea implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ -68,10 +67,4 @@ public class TbCityArea extends TenantEntity {
|
||||
*/
|
||||
private Long dataState;
|
||||
|
||||
/**
|
||||
* 搜索值
|
||||
*/
|
||||
private String searchValue;
|
||||
|
||||
|
||||
}
|
@ -1,13 +1,14 @@
|
||||
package org.dromara.property.domain.bo;
|
||||
|
||||
import org.dromara.property.domain.TbCityArea;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.property.domain.SysCityArea;
|
||||
|
||||
/**
|
||||
* 行政区划
|
||||
@ -18,8 +19,8 @@ import jakarta.validation.constraints.*;
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = TbCityArea.class, reverseConvertGenerate = false)
|
||||
public class TbCityAreaBo extends BaseEntity {
|
||||
@AutoMapper(target = SysCityArea.class, reverseConvertGenerate = false)
|
||||
public class SysCityAreaBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键ID
|
@ -0,0 +1,24 @@
|
||||
package org.dromara.property.domain.convert;
|
||||
|
||||
import org.dromara.property.domain.SysCityArea;
|
||||
import org.dromara.property.domain.vo.CityAreaTreeVo;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.MappingConstants;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 客户端数据转换器
|
||||
*
|
||||
* @author Michelle.Chung
|
||||
*/
|
||||
@Mapper(componentModel = MappingConstants.ComponentModel.SPRING, unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface SysCityAreaCovert {
|
||||
|
||||
SysCityAreaCovert INSTANCE = Mappers.getMapper(SysCityAreaCovert.class);
|
||||
|
||||
List<CityAreaTreeVo> entity2Vo(List<SysCityArea> cityAreas);
|
||||
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package org.dromara.property.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.TreeEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class CityAreaTreeVo implements TreeEntity<CityAreaTreeVo, String> {
|
||||
|
||||
/**
|
||||
* 城市编码
|
||||
*/
|
||||
private String areaCode;
|
||||
|
||||
/**
|
||||
* 城市名称
|
||||
*/
|
||||
private String areaName;
|
||||
|
||||
/**
|
||||
* 101 省级 202 市州 303 区县
|
||||
*/
|
||||
private String areaLevel;
|
||||
|
||||
/**
|
||||
* 父级城市编码
|
||||
*/
|
||||
private String parentAreaCode;
|
||||
|
||||
/**
|
||||
* 父级城市名称
|
||||
*/
|
||||
private String parentAreaName;
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
private String lon;
|
||||
|
||||
/**
|
||||
* 维度
|
||||
*/
|
||||
private String lat;
|
||||
|
||||
private List<CityAreaTreeVo> children;
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return getAreaCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParentId() {
|
||||
return getParentAreaCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChildren(List<CityAreaTreeVo> children) {
|
||||
this.children = children;
|
||||
}
|
||||
}
|
@ -1,16 +1,15 @@
|
||||
package org.dromara.property.domain.vo;
|
||||
|
||||
import org.dromara.property.domain.TbCityArea;
|
||||
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||
import org.dromara.common.excel.convert.ExcelDictConvert;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||
import org.dromara.common.excel.convert.ExcelDictConvert;
|
||||
import org.dromara.property.domain.SysCityArea;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
|
||||
@ -23,8 +22,8 @@ import java.util.Date;
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = TbCityArea.class)
|
||||
public class TbCityAreaVo implements Serializable {
|
||||
@AutoMapper(target = SysCityArea.class)
|
||||
public class SysCityAreaVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
@ -0,0 +1,16 @@
|
||||
package org.dromara.property.mapper;
|
||||
|
||||
import org.dromara.property.domain.SysCityArea;
|
||||
import org.dromara.property.domain.vo.SysCityAreaVo;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
|
||||
/**
|
||||
* 行政区划
|
||||
Mapper接口
|
||||
*
|
||||
* @author mocheng
|
||||
* @date 2025-06-18
|
||||
*/
|
||||
public interface SysCityAreaMapper extends BaseMapperPlus<SysCityArea, SysCityAreaVo> {
|
||||
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package org.dromara.property.mapper;
|
||||
|
||||
import org.dromara.property.domain.TbCityArea;
|
||||
import org.dromara.property.domain.vo.TbCityAreaVo;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
|
||||
/**
|
||||
* 行政区划
|
||||
Mapper接口
|
||||
*
|
||||
* @author mocheng
|
||||
* @date 2025-06-18
|
||||
*/
|
||||
public interface TbCityAreaMapper extends BaseMapperPlus<TbCityArea, TbCityAreaVo> {
|
||||
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
package org.dromara.property.service;
|
||||
|
||||
import org.dromara.property.domain.TbCityArea;
|
||||
import org.dromara.property.domain.vo.TbCityAreaVo;
|
||||
import org.dromara.property.domain.bo.TbCityAreaBo;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.property.domain.bo.SysCityAreaBo;
|
||||
import org.dromara.property.domain.vo.CityAreaTreeVo;
|
||||
import org.dromara.property.domain.vo.SysCityAreaVo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@ -16,7 +16,7 @@ Service接口
|
||||
* @author mocheng
|
||||
* @date 2025-06-18
|
||||
*/
|
||||
public interface ITbCityAreaService {
|
||||
public interface ISysCityAreaService {
|
||||
|
||||
/**
|
||||
* 查询行政区划
|
||||
@ -26,7 +26,7 @@ public interface ITbCityAreaService {
|
||||
* @return 行政区划
|
||||
|
||||
*/
|
||||
TbCityAreaVo queryById(String areaCode);
|
||||
SysCityAreaVo queryById(String areaCode);
|
||||
|
||||
/**
|
||||
* 分页查询行政区划
|
||||
@ -37,7 +37,7 @@ public interface ITbCityAreaService {
|
||||
* @return 行政区划
|
||||
分页列表
|
||||
*/
|
||||
TableDataInfo<TbCityAreaVo> queryPageList(TbCityAreaBo bo, PageQuery pageQuery);
|
||||
TableDataInfo<SysCityAreaVo> queryPageList(SysCityAreaBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的行政区划
|
||||
@ -47,7 +47,7 @@ public interface ITbCityAreaService {
|
||||
* @return 行政区划
|
||||
列表
|
||||
*/
|
||||
List<TbCityAreaVo> queryList(TbCityAreaBo bo);
|
||||
List<SysCityAreaVo> queryList(SysCityAreaBo bo);
|
||||
|
||||
/**
|
||||
* 新增行政区划
|
||||
@ -57,7 +57,7 @@ public interface ITbCityAreaService {
|
||||
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(TbCityAreaBo bo);
|
||||
Boolean insertByBo(SysCityAreaBo bo);
|
||||
|
||||
/**
|
||||
* 修改行政区划
|
||||
@ -67,7 +67,7 @@ public interface ITbCityAreaService {
|
||||
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(TbCityAreaBo bo);
|
||||
Boolean updateByBo(SysCityAreaBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除行政区划
|
||||
@ -78,4 +78,11 @@ public interface ITbCityAreaService {
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid);
|
||||
|
||||
/**
|
||||
* 生成行政区划树结构
|
||||
*
|
||||
* @return 返回行政区划树结构
|
||||
*/
|
||||
List<CityAreaTreeVo> queryTreeList();
|
||||
}
|
@ -0,0 +1,161 @@
|
||||
package org.dromara.property.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
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.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.core.utils.TreeUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.property.domain.SysCityArea;
|
||||
import org.dromara.property.domain.bo.SysCityAreaBo;
|
||||
import org.dromara.property.domain.convert.SysCityAreaCovert;
|
||||
import org.dromara.property.domain.vo.CityAreaTreeVo;
|
||||
import org.dromara.property.domain.vo.SysCityAreaVo;
|
||||
import org.dromara.property.mapper.SysCityAreaMapper;
|
||||
import org.dromara.property.service.ISysCityAreaService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 行政区划
|
||||
* Service业务层处理
|
||||
*
|
||||
* @author mocheng
|
||||
* @date 2025-06-18
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class SysCityAreaServiceImpl implements ISysCityAreaService {
|
||||
|
||||
private final SysCityAreaMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询行政区划
|
||||
*
|
||||
* @param areaCode 主键
|
||||
* @return 行政区划
|
||||
*/
|
||||
@Override
|
||||
public SysCityAreaVo queryById(String areaCode) {
|
||||
return baseMapper.selectVoById(areaCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询行政区划
|
||||
* 列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 行政区划
|
||||
* 分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<SysCityAreaVo> queryPageList(SysCityAreaBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<SysCityArea> lqw = buildQueryWrapper(bo);
|
||||
Page<SysCityAreaVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的行政区划
|
||||
* 列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 行政区划
|
||||
* 列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysCityAreaVo> queryList(SysCityAreaBo bo) {
|
||||
LambdaQueryWrapper<SysCityArea> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<SysCityArea> buildQueryWrapper(SysCityAreaBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<SysCityArea> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getAreaCode()), SysCityArea::getAreaCode, bo.getAreaCode());
|
||||
lqw.orderByAsc(SysCityArea::getAreaCode);
|
||||
lqw.like(StringUtils.isNotBlank(bo.getAreaName()), SysCityArea::getAreaName, bo.getAreaName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getAreaLevel()), SysCityArea::getAreaLevel, bo.getAreaLevel());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getParentAreaCode()), SysCityArea::getParentAreaCode, bo.getParentAreaCode());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getParentAreaName()), SysCityArea::getParentAreaName, bo.getParentAreaName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getLon()), SysCityArea::getLon, bo.getLon());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getLat()), SysCityArea::getLat, bo.getLat());
|
||||
lqw.eq(bo.getDataState() != null, SysCityArea::getDataState, bo.getDataState());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增行政区划
|
||||
*
|
||||
* @param bo 行政区划
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(SysCityAreaBo bo) {
|
||||
SysCityArea add = MapstructUtils.convert(bo, SysCityArea.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setAreaCode(add.getAreaCode());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改行政区划
|
||||
*
|
||||
* @param bo 行政区划
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(SysCityAreaBo bo) {
|
||||
SysCityArea update = MapstructUtils.convert(bo, SysCityArea.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(SysCityArea entity) {
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除行政区划
|
||||
* 信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid) {
|
||||
if (isValid) {
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CityAreaTreeVo> queryTreeList() {
|
||||
// 查询所有的行政区划数据
|
||||
List<SysCityArea> cityAreas = baseMapper.selectList(null);
|
||||
if (CollectionUtil.isEmpty(cityAreas)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<CityAreaTreeVo> vo = SysCityAreaCovert.INSTANCE.entity2Vo(cityAreas);
|
||||
return TreeUtils.getTreeList(vo, "0");
|
||||
}
|
||||
}
|
@ -1,151 +0,0 @@
|
||||
package org.dromara.property.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 com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.property.domain.bo.TbCityAreaBo;
|
||||
import org.dromara.property.domain.vo.TbCityAreaVo;
|
||||
import org.dromara.property.domain.TbCityArea;
|
||||
import org.dromara.property.mapper.TbCityAreaMapper;
|
||||
import org.dromara.property.service.ITbCityAreaService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 行政区划
|
||||
Service业务层处理
|
||||
*
|
||||
* @author mocheng
|
||||
* @date 2025-06-18
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class TbCityAreaServiceImpl implements ITbCityAreaService {
|
||||
|
||||
private final TbCityAreaMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询行政区划
|
||||
|
||||
*
|
||||
* @param areaCode 主键
|
||||
* @return 行政区划
|
||||
|
||||
*/
|
||||
@Override
|
||||
public TbCityAreaVo queryById(String areaCode){
|
||||
return baseMapper.selectVoById(areaCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询行政区划
|
||||
列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 行政区划
|
||||
分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<TbCityAreaVo> queryPageList(TbCityAreaBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<TbCityArea> lqw = buildQueryWrapper(bo);
|
||||
Page<TbCityAreaVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的行政区划
|
||||
列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 行政区划
|
||||
列表
|
||||
*/
|
||||
@Override
|
||||
public List<TbCityAreaVo> queryList(TbCityAreaBo bo) {
|
||||
LambdaQueryWrapper<TbCityArea> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<TbCityArea> buildQueryWrapper(TbCityAreaBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<TbCityArea> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getAreaCode()), TbCityArea::getAreaCode, bo.getAreaCode());
|
||||
lqw.orderByAsc(TbCityArea::getAreaCode);
|
||||
lqw.like(StringUtils.isNotBlank(bo.getAreaName()), TbCityArea::getAreaName, bo.getAreaName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getAreaLevel()), TbCityArea::getAreaLevel, bo.getAreaLevel());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getParentAreaCode()), TbCityArea::getParentAreaCode, bo.getParentAreaCode());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getParentAreaName()), TbCityArea::getParentAreaName, bo.getParentAreaName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getLon()), TbCityArea::getLon, bo.getLon());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getLat()), TbCityArea::getLat, bo.getLat());
|
||||
lqw.eq(bo.getDataState() != null, TbCityArea::getDataState, bo.getDataState());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增行政区划
|
||||
|
||||
*
|
||||
* @param bo 行政区划
|
||||
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(TbCityAreaBo bo) {
|
||||
TbCityArea add = MapstructUtils.convert(bo, TbCityArea.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setAreaCode(add.getAreaCode());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改行政区划
|
||||
|
||||
*
|
||||
* @param bo 行政区划
|
||||
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(TbCityAreaBo bo) {
|
||||
TbCityArea update = MapstructUtils.convert(bo, TbCityArea.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(TbCityArea entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除行政区划
|
||||
信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
}
|
@ -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.TbCityAreaMapper">
|
||||
<mapper namespace="org.dromara.property.mapper.SysCityAreaMapper">
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user