新增算法布点逻辑
This commit is contained in:
parent
4aff06ac8b
commit
fff3a6744a
@ -1,13 +1,23 @@
|
||||
package com.yfd.platform.modules.algorithm.controller;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.yfd.platform.config.ResponseResult;
|
||||
import com.yfd.platform.modules.algorithm.domain.AlgorithmArrange;
|
||||
import com.yfd.platform.modules.algorithm.service.IAlgorithmArrangeService;
|
||||
import com.yfd.platform.utils.SecurityUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author zhengsl
|
||||
@ -15,6 +25,51 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/algorithm/algorithm-arrange")
|
||||
@Api(value = "AlgorithmArrangeController", tags = "算法布点模块")
|
||||
public class AlgorithmArrangeController {
|
||||
|
||||
@Resource
|
||||
private IAlgorithmArrangeService algorithmArrangeService;
|
||||
|
||||
@GetMapping("/getAlgorithmArrangePage")
|
||||
@ApiOperation("查询算法布点")
|
||||
public ResponseResult getAlgorithmArrangePage(Page<AlgorithmArrange> page, String stationId, String stationCode,
|
||||
String arrangeName,
|
||||
String businessType) {
|
||||
LambdaQueryWrapper<AlgorithmArrange> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(StrUtil.isNotBlank(stationId), AlgorithmArrange::getStationId, stationId);
|
||||
queryWrapper.eq(StrUtil.isNotBlank(stationCode), AlgorithmArrange::getStationCode, stationCode);
|
||||
queryWrapper.like(StrUtil.isNotBlank(arrangeName), AlgorithmArrange::getArrangeName, arrangeName);
|
||||
queryWrapper.eq(StrUtil.isNotBlank(businessType), AlgorithmArrange::getBusinessType, businessType);
|
||||
queryWrapper.eq(AlgorithmArrange::getDatastatus, "1");
|
||||
Page<AlgorithmArrange> arrangePage = algorithmArrangeService.page(page, queryWrapper);
|
||||
return ResponseResult.successData(arrangePage);
|
||||
}
|
||||
|
||||
@PostMapping("/saveAlgorithmArrange")
|
||||
@ApiOperation("新增算法布点")
|
||||
public ResponseResult saveAlgorithmArrange(@RequestBody AlgorithmArrange algorithmArrange) {
|
||||
algorithmArrange.setLastmodifier(SecurityUtils.getCurrentUsername());
|
||||
algorithmArrange.setLastmodifydate(LocalDateTime.now());
|
||||
algorithmArrange.setDatastatus("1");
|
||||
String id = IdUtil.fastSimpleUUID();
|
||||
algorithmArrange.setId(id);
|
||||
boolean save = algorithmArrangeService.save(algorithmArrange);
|
||||
if (!save) {
|
||||
return ResponseResult.error();
|
||||
}
|
||||
return ResponseResult.successData(algorithmArrange);
|
||||
}
|
||||
|
||||
@PostMapping("/updateAlgorithmArrange")
|
||||
@ApiOperation("修改算法布点")
|
||||
public ResponseResult updateAlgorithmArrange(@RequestBody AlgorithmArrange algorithmArrange) {
|
||||
algorithmArrange.setLastmodifier(SecurityUtils.getCurrentUsername());
|
||||
algorithmArrange.setLastmodifydate(LocalDateTime.now());
|
||||
boolean save = algorithmArrangeService.updateById(algorithmArrange);
|
||||
if (!save) {
|
||||
return ResponseResult.error();
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,20 @@
|
||||
package com.yfd.platform.modules.algorithm.controller;
|
||||
|
||||
|
||||
import com.yfd.platform.config.ResponseResult;
|
||||
import com.yfd.platform.modules.algorithm.service.IAlgorithmArrangeDeviceService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author zhengsl
|
||||
@ -15,6 +22,16 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/algorithm/algorithm-arrange-device")
|
||||
@Api(value = "AlgorithmArrangeDeviceController", tags = "算法布点详情模块")
|
||||
public class AlgorithmArrangeDeviceController {
|
||||
|
||||
@Resource
|
||||
private IAlgorithmArrangeDeviceService algorithmArrangeDeviceService;
|
||||
|
||||
@GetMapping("/getArrangeDeviceInfo")
|
||||
@ApiOperation("查询当前布点的主设备数量")
|
||||
public ResponseResult getArrangeDeviceInfo(String arrangeId) {
|
||||
List<Map<String, Object>> maps = algorithmArrangeDeviceService.getArrangeDeviceInfo(arrangeId);
|
||||
return ResponseResult.successData(maps);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,9 @@ package com.yfd.platform.modules.algorithm.mapper;
|
||||
import com.yfd.platform.modules.algorithm.domain.AlgorithmArrangeDevice;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
@ -13,4 +16,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
*/
|
||||
public interface AlgorithmArrangeDeviceMapper extends BaseMapper<AlgorithmArrangeDevice> {
|
||||
|
||||
List<Map<String, Object>> getArrangeDeviceInfo(String arrangeId);
|
||||
}
|
||||
|
@ -3,6 +3,9 @@ package com.yfd.platform.modules.algorithm.service;
|
||||
import com.yfd.platform.modules.algorithm.domain.AlgorithmArrangeDevice;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
@ -13,4 +16,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
*/
|
||||
public interface IAlgorithmArrangeDeviceService extends IService<AlgorithmArrangeDevice> {
|
||||
|
||||
List<Map<String, Object>> getArrangeDeviceInfo(String arrangeId);
|
||||
}
|
||||
|
@ -6,15 +6,47 @@ import com.yfd.platform.modules.algorithm.service.IAlgorithmArrangeDeviceService
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author zhengsl
|
||||
* @since 2025-06-06
|
||||
*/
|
||||
@Service
|
||||
public class AlgorithmArrangeDeviceServiceImpl extends ServiceImpl<AlgorithmArrangeDeviceMapper, AlgorithmArrangeDevice> implements IAlgorithmArrangeDeviceService {
|
||||
public class AlgorithmArrangeDeviceServiceImpl extends ServiceImpl<AlgorithmArrangeDeviceMapper,
|
||||
AlgorithmArrangeDevice> implements IAlgorithmArrangeDeviceService {
|
||||
|
||||
@Resource
|
||||
private AlgorithmArrangeDeviceMapper algorithmArrangeDeviceMapper;
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getArrangeDeviceInfo(String arrangeId) {
|
||||
List<Map<String, Object>> rawData = algorithmArrangeDeviceMapper.getArrangeDeviceInfo(arrangeId);
|
||||
|
||||
// 使用 Map<主设备ID, 结果行> 来合并数据
|
||||
Map<String, Map<String, Object>> groupedData = new HashMap<>();
|
||||
|
||||
for (Map<String, Object> row : rawData) {
|
||||
String mainDeviceId = (String) row.get("mainDeviceId");
|
||||
String mainDeviceName = (String) row.get("mainDeviceName");
|
||||
String deviceTypeCode = (String) row.get("deviceTypeCode");
|
||||
Long count = (Long) row.get("deviceTypeCount");
|
||||
|
||||
groupedData.computeIfAbsent(mainDeviceId, k -> {
|
||||
Map<String, Object> newRow = new HashMap<>();
|
||||
newRow.put("mainDeviceId", mainDeviceId);
|
||||
newRow.put("mainDeviceName", mainDeviceName);
|
||||
return newRow;
|
||||
});
|
||||
// 设置具体类型的数量
|
||||
groupedData.get(mainDeviceId).put(deviceTypeCode, count);
|
||||
}
|
||||
|
||||
return new ArrayList<>(groupedData.values());
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ public class SubstationController {
|
||||
queryWrapper.eq(Substation::getIsStationFlag, flag);
|
||||
}
|
||||
queryWrapper.eq(Substation::getDatastatus, "1").select(Substation::getStationId, Substation::getStationCode,
|
||||
Substation::getStationName).orderByAsc(Substation::getCustom1);
|
||||
Substation::getStationName,Substation::getVoltLevel,Substation::getStationType).orderByAsc(Substation::getCustom1);
|
||||
List<Map<String, Object>> listMaps = substationService.listMaps(queryWrapper);
|
||||
return ResponseResult.successData(listMaps);
|
||||
}
|
||||
|
@ -109,13 +109,13 @@ public class SubstationMaindeviceController {
|
||||
|
||||
@GetMapping("/getMainDeviceByType")
|
||||
@ApiOperation("根据主设备类型获取主设备")
|
||||
public ResponseResult getMainDeviceByType(String stationCode, String deviceType) {
|
||||
if (StrUtil.isBlank(stationCode) || StrUtil.isBlank(deviceType)) {
|
||||
public ResponseResult getMainDeviceByType(String stationCode, String deviceTypeList) {
|
||||
if (StrUtil.isBlank(stationCode) || StrUtil.isBlank(deviceTypeList)) {
|
||||
return ResponseResult.successData(new ArrayList<>());
|
||||
}
|
||||
LambdaQueryWrapper<SubstationMaindevice> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(StrUtil.isNotBlank(stationCode), SubstationMaindevice::getStationCode, stationCode);
|
||||
queryWrapper.eq(StrUtil.isNotBlank(deviceType), SubstationMaindevice::getDeviceType, StrUtil.split(deviceType
|
||||
queryWrapper.eq(StrUtil.isNotBlank(deviceTypeList), SubstationMaindevice::getDeviceType, StrUtil.split(deviceTypeList
|
||||
, ","));
|
||||
queryWrapper.select(SubstationMaindevice::getMainDeviceId, SubstationMaindevice::getMainDeviceName,
|
||||
SubstationMaindevice::getDeviceType, SubstationMaindevice::getFileUrl);
|
||||
|
@ -36,12 +36,12 @@ public class SysDictionaryController {
|
||||
***********************************/
|
||||
@GetMapping("/dictList")
|
||||
@ApiOperation("获取数据字典列表")
|
||||
public ResponseResult getDictList(String dictType) {
|
||||
public ResponseResult getDictList(String dictType,String dictName) {
|
||||
if (StrUtil.isBlank(dictType)) {
|
||||
return ResponseResult.error("参数为空");
|
||||
}
|
||||
List<SysDictionary> sysDictionaries =
|
||||
sysDictionaryService.getDictList(dictType);
|
||||
sysDictionaryService.getDictList(dictType,dictName);
|
||||
return ResponseResult.successData(sysDictionaries);
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ public interface ISysDictionaryService extends IService<SysDictionary> {
|
||||
* 参数说明 dictType 字典类型
|
||||
* 返回值说明: com.yfd.platform.config.ResponseResult 返回分页查询结果
|
||||
***********************************/
|
||||
List<SysDictionary> getDictList(String dictType);
|
||||
List<SysDictionary> getDictList(String dictType,String dictName);
|
||||
|
||||
/**********************************
|
||||
* 用途说明: 新增字典
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.yfd.platform.system.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@ -38,10 +39,10 @@ public class SysDictionaryServiceImpl extends ServiceImpl<SysDictionaryMapper
|
||||
* 返回值说明: 返回字典列表集合
|
||||
***********************************/
|
||||
@Override
|
||||
public List<SysDictionary> getDictList(String dictType) {
|
||||
public List<SysDictionary> getDictList(String dictType,String dictName) {
|
||||
LambdaQueryWrapper<SysDictionary> queryWrapper =
|
||||
new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysDictionary::getDictType, dictType).orderByAsc(SysDictionary::getOrderNo);
|
||||
queryWrapper.eq(SysDictionary::getDictType, dictType).like(StrUtil.isNotBlank(dictName),SysDictionary::getDictName, dictName).orderByAsc(SysDictionary::getOrderNo);
|
||||
return sysDictionaryMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
|
@ -2,4 +2,35 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.yfd.platform.modules.algorithm.mapper.AlgorithmArrangeDeviceMapper">
|
||||
|
||||
<select id="getArrangeDeviceInfo" resultType="java.util.Map">
|
||||
SELECT
|
||||
d.main_device_id,
|
||||
d.main_device_name,
|
||||
t.device_type_code,
|
||||
t.device_type_name,
|
||||
COUNT(iis.id) AS device_type_count
|
||||
FROM
|
||||
(SELECT DISTINCT main_device_id, main_device_name FROM iis_algorithm_arrange_device) d
|
||||
CROSS JOIN
|
||||
(SELECT itemcode AS device_type_code, dictname AS device_type_name
|
||||
FROM sys_dictionary_items
|
||||
WHERE dictid = '953147a7bb8e0961c6d1cd4e23e7fddc'
|
||||
) t
|
||||
LEFT JOIN
|
||||
iis_algorithm_arrange_device iis
|
||||
ON iis.main_device_id = d.main_device_id
|
||||
AND iis.patroldevice_type = t.device_type_code
|
||||
<if test="arrangeId != null and arrangeId != ''">
|
||||
AND arrange_id = #{arrangeId}
|
||||
</if>
|
||||
GROUP BY
|
||||
d.main_device_id,
|
||||
d.main_device_name,
|
||||
t.device_type_code,
|
||||
t.device_type_name
|
||||
ORDER BY
|
||||
d.main_device_id,
|
||||
t.device_type_code;
|
||||
|
||||
</select>
|
||||
</mapper>
|
||||
|
Loading…
Reference in New Issue
Block a user