-树设备挂载 在 EmsLocation 实体及其相关 BO、VO 中新增 x、y 坐标字段 - 更新 Mapper XML 配置以支持新字段映射 - 新增 LocationTreeNodeVo 类用于表示区域树节点结构 - 在 EmsLocationController 中增加 /treeWithDevices 接口 - 在 EmsLocationServiceImpl 中实现 treeWithDevices 方法, 构建带路径的区域树并在叶子节点挂载设备信息 - 注入 IEmsAlarmDeviceService 服务以查询设备数据 - 修改生产环境数据库端口号与密码配置
110 lines
3.2 KiB
Java
110 lines
3.2 KiB
Java
package com.klp.ems.controller;
|
|
|
|
import java.util.List;
|
|
import java.util.Arrays;
|
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.validation.constraints.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import com.klp.common.annotation.RepeatSubmit;
|
|
import com.klp.common.annotation.Log;
|
|
import com.klp.common.core.controller.BaseController;
|
|
import com.klp.common.core.domain.PageQuery;
|
|
import com.klp.common.core.domain.R;
|
|
import com.klp.common.core.validate.AddGroup;
|
|
import com.klp.common.core.validate.EditGroup;
|
|
import com.klp.common.enums.BusinessType;
|
|
import com.klp.common.utils.poi.ExcelUtil;
|
|
import com.klp.ems.domain.vo.EmsLocationVo;
|
|
import com.klp.ems.domain.bo.EmsLocationBo;
|
|
import com.klp.ems.service.IEmsLocationService;
|
|
import com.klp.ems.domain.vo.LocationTreeNodeVo;
|
|
|
|
/**
|
|
* 位置
|
|
*
|
|
* @author Joshi
|
|
* @date 2025-09-28
|
|
*/
|
|
@Validated
|
|
@RequiredArgsConstructor
|
|
@RestController
|
|
@RequestMapping("/ems/location")
|
|
public class EmsLocationController extends BaseController {
|
|
|
|
private final IEmsLocationService iEmsLocationService;
|
|
|
|
/**
|
|
* 查询位置列表
|
|
*/
|
|
@GetMapping("/list")
|
|
public R<List<EmsLocationVo>> list(EmsLocationBo bo) {
|
|
List<EmsLocationVo> list = iEmsLocationService.queryList(bo);
|
|
return R.ok(list);
|
|
}
|
|
|
|
/**
|
|
* 导出位置列表
|
|
*/
|
|
@Log(title = "位置", businessType = BusinessType.EXPORT)
|
|
@PostMapping("/export")
|
|
public void export(EmsLocationBo bo, HttpServletResponse response) {
|
|
List<EmsLocationVo> list = iEmsLocationService.queryList(bo);
|
|
ExcelUtil.exportExcel(list, "位置", EmsLocationVo.class, response);
|
|
}
|
|
|
|
/**
|
|
* 获取位置详细信息
|
|
*
|
|
* @param locationId 主键
|
|
*/
|
|
@GetMapping("/{locationId}")
|
|
public R<EmsLocationVo> getInfo(@NotNull(message = "主键不能为空")
|
|
@PathVariable Long locationId) {
|
|
return R.ok(iEmsLocationService.queryById(locationId));
|
|
}
|
|
|
|
/**
|
|
* 新增位置
|
|
*/
|
|
@Log(title = "位置", businessType = BusinessType.INSERT)
|
|
@RepeatSubmit()
|
|
@PostMapping()
|
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody EmsLocationBo bo) {
|
|
return toAjax(iEmsLocationService.insertByBo(bo));
|
|
}
|
|
|
|
/**
|
|
* 修改位置
|
|
*/
|
|
@Log(title = "位置", businessType = BusinessType.UPDATE)
|
|
@RepeatSubmit()
|
|
@PutMapping()
|
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody EmsLocationBo bo) {
|
|
return toAjax(iEmsLocationService.updateByBo(bo));
|
|
}
|
|
|
|
/**
|
|
* 删除位置
|
|
*
|
|
* @param locationIds 主键串
|
|
*/
|
|
@Log(title = "位置", businessType = BusinessType.DELETE)
|
|
@DeleteMapping("/{locationIds}")
|
|
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
|
@PathVariable Long[] locationIds) {
|
|
return toAjax(iEmsLocationService.deleteWithValidByIds(Arrays.asList(locationIds), true));
|
|
}
|
|
|
|
/**
|
|
* 查询全量区域树,并在叶子节点挂载设备
|
|
*/
|
|
@GetMapping("/treeWithDevices")
|
|
public R<List<LocationTreeNodeVo>> treeWithDevices() {
|
|
return R.ok(iEmsLocationService.treeWithDevices());
|
|
}
|
|
}
|