2025-09-28 09:54:42 +08:00
|
|
|
|
package com.klp.ems.controller;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
import java.util.Arrays;
|
2025-12-09 16:43:45 +08:00
|
|
|
|
import java.util.Map;
|
2025-12-07 17:23:47 +08:00
|
|
|
|
import java.io.IOException;
|
2025-09-28 09:54:42 +08:00
|
|
|
|
|
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import javax.validation.constraints.*;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
2025-12-07 17:23:47 +08:00
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
2025-09-28 09:54:42 +08:00
|
|
|
|
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.EmsMeterVo;
|
2025-12-09 16:43:45 +08:00
|
|
|
|
import com.klp.ems.domain.vo.EnergyLinkMatrixVo;
|
|
|
|
|
|
import com.klp.ems.domain.vo.EnergyLinkStatisticsVo;
|
2025-09-28 09:54:42 +08:00
|
|
|
|
import com.klp.ems.domain.bo.EmsMeterBo;
|
|
|
|
|
|
import com.klp.ems.service.IEmsMeterService;
|
|
|
|
|
|
import com.klp.common.core.page.TableDataInfo;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 计量设备(阈值移至此处)
|
|
|
|
|
|
*
|
|
|
|
|
|
* @author Joshi
|
|
|
|
|
|
* @date 2025-09-28
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Validated
|
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
|
@RestController
|
|
|
|
|
|
@RequestMapping("/mes/meter")
|
|
|
|
|
|
public class EmsMeterController extends BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
private final IEmsMeterService iEmsMeterService;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询计量设备(阈值移至此处)列表
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/list")
|
|
|
|
|
|
public TableDataInfo<EmsMeterVo> list(EmsMeterBo bo, PageQuery pageQuery) {
|
|
|
|
|
|
return iEmsMeterService.queryPageList(bo, pageQuery);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 导出计量设备(阈值移至此处)列表
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Log(title = "计量设备(阈值移至此处)", businessType = BusinessType.EXPORT)
|
|
|
|
|
|
@PostMapping("/export")
|
|
|
|
|
|
public void export(EmsMeterBo bo, HttpServletResponse response) {
|
|
|
|
|
|
List<EmsMeterVo> list = iEmsMeterService.queryList(bo);
|
|
|
|
|
|
ExcelUtil.exportExcel(list, "计量设备(阈值移至此处)", EmsMeterVo.class, response);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取计量设备(阈值移至此处)详细信息
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param meterId 主键
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/{meterId}")
|
|
|
|
|
|
public R<EmsMeterVo> getInfo(@NotNull(message = "主键不能为空")
|
|
|
|
|
|
@PathVariable Long meterId) {
|
|
|
|
|
|
return R.ok(iEmsMeterService.queryById(meterId));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 新增计量设备(阈值移至此处)
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Log(title = "计量设备(阈值移至此处)", businessType = BusinessType.INSERT)
|
|
|
|
|
|
@RepeatSubmit()
|
|
|
|
|
|
@PostMapping()
|
|
|
|
|
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody EmsMeterBo bo) {
|
|
|
|
|
|
return toAjax(iEmsMeterService.insertByBo(bo));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 修改计量设备(阈值移至此处)
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Log(title = "计量设备(阈值移至此处)", businessType = BusinessType.UPDATE)
|
|
|
|
|
|
@RepeatSubmit()
|
|
|
|
|
|
@PutMapping()
|
|
|
|
|
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody EmsMeterBo bo) {
|
|
|
|
|
|
return toAjax(iEmsMeterService.updateByBo(bo));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 删除计量设备(阈值移至此处)
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param meterIds 主键串
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Log(title = "计量设备(阈值移至此处)", businessType = BusinessType.DELETE)
|
|
|
|
|
|
@DeleteMapping("/{meterIds}")
|
|
|
|
|
|
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
|
|
|
|
|
@PathVariable Long[] meterIds) {
|
|
|
|
|
|
return toAjax(iEmsMeterService.deleteWithValidByIds(Arrays.asList(meterIds), true));
|
|
|
|
|
|
}
|
2025-12-07 17:23:47 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 下载设备导入模板
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/template")
|
|
|
|
|
|
public void downloadTemplate(HttpServletResponse response) {
|
|
|
|
|
|
iEmsMeterService.downloadTemplate(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 导入设备
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Log(title = "计量设备(阈值移至此处)", businessType = BusinessType.IMPORT)
|
|
|
|
|
|
@PostMapping("/import")
|
|
|
|
|
|
public R<Void> importMeters(@RequestParam("file") MultipartFile file) {
|
|
|
|
|
|
return toAjax(iEmsMeterService.importMeters(file));
|
|
|
|
|
|
}
|
2025-12-09 16:43:45 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询库区-设备绑定矩阵
|
|
|
|
|
|
* 按库区维度查询绑定的设备及其能源类型
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/matrix")
|
|
|
|
|
|
public R<List<EnergyLinkMatrixVo>> queryEnergyLinkMatrix() {
|
|
|
|
|
|
List<EnergyLinkMatrixVo> matrix = iEmsMeterService.queryEnergyLinkMatrix();
|
|
|
|
|
|
return R.ok(matrix);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询能源绑定统计信息
|
|
|
|
|
|
* 统计库区总数、设备总数、绑定总数、能源类型总数
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/statistics")
|
|
|
|
|
|
public R<EnergyLinkStatisticsVo> queryEnergyLinkStatistics() {
|
|
|
|
|
|
EnergyLinkStatisticsVo statistics = iEmsMeterService.queryEnergyLinkStatistics();
|
|
|
|
|
|
return R.ok(statistics);
|
|
|
|
|
|
}
|
2025-09-28 09:54:42 +08:00
|
|
|
|
}
|