1.分布式光伏台账相关
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
package com.njcn.pvdevice.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.device.pojo.param.pv.PvTerminalBaseQuery;
|
||||
import com.njcn.device.pojo.vo.pv.PvLineAllDetailVO;
|
||||
import com.njcn.pvdevice.service.PvTerminalBaseService;
|
||||
import com.njcn.user.pojo.vo.PvTerminalTreeVO;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
* 台账相关控制
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2022/7/11
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/pvTerminalBase")
|
||||
@Api(tags = "pv终端相关基础管理")
|
||||
@RequiredArgsConstructor
|
||||
public class PvTerminalBaseController extends BaseController {
|
||||
|
||||
private final PvTerminalBaseService pvTerminalBaseService;
|
||||
|
||||
|
||||
/**
|
||||
* 获取终端台账树
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2022/7/11
|
||||
*/
|
||||
@GetMapping("pvTree")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("获取终端台账树")
|
||||
public HttpResult<List<PvTerminalTreeVO>> pvTerminalTree() {
|
||||
String methodDescribe = getMethodDescribe("pvTerminalTree");
|
||||
List<PvTerminalTreeVO> tree = pvTerminalBaseService.pvTerminalTree();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, tree, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 点击变电站台区展示监测点详情
|
||||
* @param pvTerminalBaseQuery 传参
|
||||
* @author cdf
|
||||
* @date 2022/7/11
|
||||
*/
|
||||
@PostMapping("pvLineDetail")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("点击树节点获取监测点详情")
|
||||
@ApiImplicitParam(name = "pvTerminalBaseQuery",value = "参数",required = true)
|
||||
public HttpResult<Page<PvLineAllDetailVO>> lineDetailBySubId(@RequestBody @Validated PvTerminalBaseQuery pvTerminalBaseQuery) {
|
||||
String methodDescribe = getMethodDescribe("lineDetailBySubId");
|
||||
Page<PvLineAllDetailVO> all = pvTerminalBaseService.lineDetailBySubId(pvTerminalBaseQuery);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, all, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,7 +1,12 @@
|
||||
package com.njcn.pvdevice.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.device.pojo.po.pv.PvLineDetail;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.device.pojo.vo.pv.PvLineAllDetailVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -13,4 +18,16 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
*/
|
||||
public interface PvLineDetailMapper extends BaseMapper<PvLineDetail> {
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询监测点
|
||||
* @param subIds 变电站ids
|
||||
* @param subAreaIds 台区ids
|
||||
* @author cdf
|
||||
* @date 2022/7/5
|
||||
* @return Page<PvLineDetail>
|
||||
*/
|
||||
Page<PvLineAllDetailVO> getPvLineAllDetailMain(Page<PvLineAllDetailVO> page,@Param("subIds") List<String> subIds, @Param("subAreaIds")List<String> subAreaIds);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,8 +4,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.device.pojo.param.pv.SubAreaQueryParam;
|
||||
import com.njcn.device.pojo.po.pv.PvSubArea;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.user.pojo.vo.PvTerminalTreeVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
@@ -24,4 +27,10 @@ public interface PvSubAreaMapper extends BaseMapper<PvSubArea> {
|
||||
*/
|
||||
Page<PvSubArea> getPvSubAreaList(Page<PvSubArea> page,@Param("subsAreaQueryParam") SubAreaQueryParam subsAreaQueryParam);
|
||||
|
||||
/**
|
||||
* 查询所有台区
|
||||
* @author cdf
|
||||
* @date 2022/7/11
|
||||
*/
|
||||
List<PvTerminalTreeVO> getSubAreaTreeList();
|
||||
}
|
||||
|
||||
@@ -4,8 +4,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.device.pojo.param.pv.SubstationQueryParam;
|
||||
import com.njcn.device.pojo.po.pv.PvSubstation;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.user.pojo.vo.PvTerminalTreeVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
@@ -18,4 +21,10 @@ public interface PvSubstationMapper extends BaseMapper<PvSubstation> {
|
||||
|
||||
Page<PvSubstation> getPvSubstationList(Page<PvSubstation> page,@Param("substationQueryParam") SubstationQueryParam substationQueryParam);
|
||||
|
||||
/**
|
||||
* 终端树结构的变电站
|
||||
* @author cdf
|
||||
* @date 2022/7/11
|
||||
*/
|
||||
List<PvTerminalTreeVO> getSubstationTreeList();
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.njcn.pvdevice.mapper;
|
||||
import com.njcn.device.pojo.po.pv.PvUnit;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.device.pojo.vo.pv.UnitTreeVO;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import com.njcn.user.pojo.vo.PvTerminalTreeVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@@ -25,4 +25,8 @@ public interface PvUnitMapper extends BaseMapper<PvUnit> {
|
||||
*/
|
||||
List<UnitTreeVO> getPvUnitList(@Param("orderBy")String orderBy,@Param("sortBy")String sortBy);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,4 +2,132 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.pvdevice.mapper.PvLineDetailMapper">
|
||||
|
||||
<select id="getPvLineAllDetailMain" resultType="PvLineAllDetailVO">
|
||||
|
||||
<if test="subIds!=null and subIds.size!=0">
|
||||
SELECT
|
||||
line.id,
|
||||
line.NAME,
|
||||
line.CODE,
|
||||
dev.Dev_Code devName,
|
||||
dic.NAME type,
|
||||
dic1.NAME scale,
|
||||
sub.NAME substationName,
|
||||
v.NAME voltageName,
|
||||
subArea.NAME subAreaName,
|
||||
dis.NAME distributeName,
|
||||
lv.NAME lvUserName,
|
||||
line.num,
|
||||
line.pt1,
|
||||
line.pt2,
|
||||
line.ct1,
|
||||
line.ct2,
|
||||
line.dev_capacity,
|
||||
line.short_capacity,
|
||||
line.standard_capacity,
|
||||
line.deal_capacity,
|
||||
line.pt_Type,
|
||||
line.time_Interval,
|
||||
dic2.NAME loadType,
|
||||
dic3.NAME businessType,
|
||||
line.Monitor_Flag,
|
||||
line.Power_Flag,
|
||||
line.Monitor_Id,
|
||||
line.Obj_Name,
|
||||
line.Stat_flag,
|
||||
line.Remark,
|
||||
line.Tf_Type,
|
||||
line.Tf_Code,
|
||||
line.Ground_Type,
|
||||
line.Put_In,
|
||||
line.Access,
|
||||
line.Power_Supply
|
||||
FROM
|
||||
pv_line_detail line
|
||||
LEFT JOIN pv_device dev ON line.dev_id = dev.id
|
||||
LEFT JOIN sys_dict_data dic ON line.type = dic.id
|
||||
LEFT JOIN sys_dict_data dic1 ON line.scale = dic1.id
|
||||
LEFT JOIN pv_substation sub ON line.Substation_Id = sub.id
|
||||
LEFT JOIN pv_voltage v ON line.voltage_id = v.id
|
||||
LEFT JOIN pv_sub_area subArea ON line.sub_area_id = subArea.id
|
||||
LEFT JOIN Pv_Distributed dis ON line.user_code = dis.user_code
|
||||
LEFT JOIN Pv_Lv_User lv ON line.user_code = lv.user_code
|
||||
LEFT JOIN sys_dict_data dic2 ON line.load_type = dic2.id
|
||||
LEFT JOIN sys_dict_data dic3 ON line.Business_Type = dic3.id
|
||||
where line.state = 1
|
||||
<if test="subIds!=null and subIds.size!=0">
|
||||
and line.Substation_Id in
|
||||
<foreach collection="subIds" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</if>
|
||||
|
||||
<if test="subIds!=null and subIds.size!=0 and subAreaIds!=null and subAreaIds.size!=0">
|
||||
UNION ALL
|
||||
</if>
|
||||
|
||||
|
||||
<if test="subAreaIds!=null and subAreaIds.size!=0">
|
||||
SELECT
|
||||
line.id,
|
||||
line.NAME,
|
||||
line.CODE,
|
||||
dev.Dev_Code devName,
|
||||
dic.NAME type,
|
||||
dic1.NAME scale,
|
||||
sub.NAME substationName,
|
||||
v.NAME voltageName,
|
||||
subArea.NAME subAreaName,
|
||||
dis.NAME distributeName,
|
||||
lv.NAME lvUserName,
|
||||
line.num,
|
||||
line.pt1,
|
||||
line.pt2,
|
||||
line.ct1,
|
||||
line.ct2,
|
||||
line.dev_capacity,
|
||||
line.short_capacity,
|
||||
line.standard_capacity,
|
||||
line.deal_capacity,
|
||||
line.pt_Type,
|
||||
line.time_Interval,
|
||||
dic2.NAME loadType,
|
||||
dic3.NAME businessType,
|
||||
line.Monitor_Flag,
|
||||
line.Power_Flag,
|
||||
line.Monitor_Id,
|
||||
line.Obj_Name,
|
||||
line.Stat_flag,
|
||||
line.Remark,
|
||||
line.Tf_Type,
|
||||
line.Tf_Code,
|
||||
line.Ground_Type,
|
||||
line.Put_In,
|
||||
line.Access,
|
||||
line.Power_Supply
|
||||
FROM
|
||||
pv_line_detail line
|
||||
LEFT JOIN pv_device dev ON line.dev_id = dev.id
|
||||
LEFT JOIN sys_dict_data dic ON line.type = dic.id
|
||||
LEFT JOIN sys_dict_data dic1 ON line.scale = dic1.id
|
||||
LEFT JOIN pv_substation sub ON line.Substation_Id = sub.id
|
||||
LEFT JOIN pv_voltage v ON line.voltage_id = v.id
|
||||
LEFT JOIN pv_sub_area subArea ON line.sub_area_id = subArea.id
|
||||
LEFT JOIN Pv_Distributed dis ON line.user_code = dis.user_code
|
||||
LEFT JOIN Pv_Lv_User lv ON line.user_code = lv.user_code
|
||||
LEFT JOIN sys_dict_data dic2 ON line.load_type = dic2.id
|
||||
LEFT JOIN sys_dict_data dic3 ON line.Business_Type = dic3.id
|
||||
where line.state = 1
|
||||
<if test="subAreaIds!=null and subAreaIds.size!=0">
|
||||
and line.Sub_Area_Id in
|
||||
<foreach collection="subAreaIds" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</if>
|
||||
|
||||
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -46,4 +46,9 @@
|
||||
</where>
|
||||
order by ten.create_time asc
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getSubAreaTreeList" resultType="com.njcn.user.pojo.vo.PvTerminalTreeVO">
|
||||
select id,name,unit_id pid,2 as level from pv_sub_area where state = 1
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -36,4 +36,9 @@
|
||||
</where>
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getSubstationTreeList" resultType="com.njcn.user.pojo.vo.PvTerminalTreeVO">
|
||||
select id,unit_id pid,name,1 as level from pv_substation
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -9,4 +9,7 @@
|
||||
order by concat(#{sortBy},' ',#{orderBy})
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.njcn.device.pojo.param.pv.PvLineDetailParam;
|
||||
import com.njcn.device.pojo.po.pv.PvLineDetail;
|
||||
import com.njcn.device.pojo.po.pv.PvLineDetail;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.device.pojo.vo.pv.PvLineAllDetailVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -69,4 +70,17 @@ public interface IPvLineDetailService extends IService<PvLineDetail> {
|
||||
*/
|
||||
boolean delPvLineDetail(String id);
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询监测点
|
||||
* @param subIds 变电站ids
|
||||
* @param subAreaIds 台区ids
|
||||
* @author cdf
|
||||
* @date 2022/7/5
|
||||
* @return Page<PvLineDetail>
|
||||
*/
|
||||
Page<PvLineAllDetailVO> getPvLineAllDetailMain(Integer pageNum,Integer pageSize,List<String> subIds, List<String> subAreaIds);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.njcn.device.pojo.param.pv.PvUnitParam;
|
||||
import com.njcn.device.pojo.po.pv.PvUnit;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.device.pojo.vo.pv.UnitTreeVO;
|
||||
import com.njcn.user.pojo.vo.PvTerminalTreeVO;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
|
||||
import java.util.List;
|
||||
@@ -38,7 +39,7 @@ public interface IPvUnitService extends IService<PvUnit> {
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询单位
|
||||
* 查询树形结构单位
|
||||
* @param baseParam 单位实体
|
||||
* @author cdf
|
||||
* @date 2022/7/5
|
||||
@@ -47,6 +48,8 @@ public interface IPvUnitService extends IService<PvUnit> {
|
||||
List<UnitTreeVO> getPvUnitList(BaseParam baseParam);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据单位id查询单位
|
||||
* @param id 单位id
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.njcn.pvdevice.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.device.pojo.param.pv.PvTerminalBaseQuery;
|
||||
import com.njcn.device.pojo.vo.pv.PvLineAllDetailVO;
|
||||
import com.njcn.user.pojo.vo.PvTerminalTreeVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2022/7/11
|
||||
*/
|
||||
public interface PvTerminalBaseService {
|
||||
|
||||
/**
|
||||
* 获取设备树
|
||||
* @author cdf
|
||||
* @date 2022/7/11
|
||||
*/
|
||||
List<PvTerminalTreeVO> pvTerminalTree();
|
||||
|
||||
|
||||
/**
|
||||
* 点击变电站台区展示监测点详情
|
||||
* @author cdf
|
||||
* @date 2022/7/11
|
||||
*/
|
||||
Page<PvLineAllDetailVO> lineDetailBySubId(PvTerminalBaseQuery pvTerminalBaseQuery);
|
||||
}
|
||||
@@ -42,7 +42,6 @@ public class PvDeviceServiceImpl extends ServiceImpl<PvDeviceMapper, PvDevice> i
|
||||
@Override
|
||||
public boolean addDevice(PvDeviceParam pvDeviceParam) {
|
||||
checkNameAndParam(pvDeviceParam, false);
|
||||
|
||||
PvDevice pvDevice = new PvDevice();
|
||||
BeanUtils.copyProperties(pvDeviceParam, pvDevice);
|
||||
pvDevice.setState(DataStateEnum.ENABLE.getCode());
|
||||
@@ -54,7 +53,6 @@ public class PvDeviceServiceImpl extends ServiceImpl<PvDeviceMapper, PvDevice> i
|
||||
@Override
|
||||
public boolean updateDevice(PvDeviceParam.UpdatePvDeviceParam updatePvDeviceParam) {
|
||||
checkNameAndParam(updatePvDeviceParam, true);
|
||||
|
||||
PvDevice pvDevice = new PvDevice();
|
||||
BeanUtils.copyProperties(updatePvDeviceParam, pvDevice);
|
||||
pvDevice.setState(DataStateEnum.ENABLE.getCode());
|
||||
@@ -99,20 +97,24 @@ public class PvDeviceServiceImpl extends ServiceImpl<PvDeviceMapper, PvDevice> i
|
||||
}
|
||||
int count = this.count(lambdaQueryWrapper);
|
||||
if (count > 0) {
|
||||
throw new BusinessException(PvDeviceResponseEnum.SUB_AREA_REPEAT);
|
||||
throw new BusinessException(PvDeviceResponseEnum.DVE_CODE_REPEAT);
|
||||
}
|
||||
|
||||
/*校验终端类型*/
|
||||
if (Objects.isNull(dicDataFeignClient.getDicDataById(pvDeviceParam.getType()).getData())) {
|
||||
throw new BusinessException(SystemResponseEnum.DEV_VARIETY);
|
||||
}
|
||||
|
||||
/*校验设备型号*/
|
||||
if (StrUtil.isNotBlank(pvDeviceParam.getDevType())) {
|
||||
if (Objects.isNull(dicDataFeignClient.getDicDataById(pvDeviceParam.getDevType()))) {
|
||||
if (Objects.isNull(dicDataFeignClient.getDicDataById(pvDeviceParam.getDevType()).getData())) {
|
||||
throw new BusinessException(SystemResponseEnum.DEV_TYPE_EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
/*校验生产厂家*/
|
||||
|
||||
if (Objects.isNull(dicDataFeignClient.getDicDataById(pvDeviceParam.getManufacturer()))) {
|
||||
if (Objects.isNull(dicDataFeignClient.getDicDataById(pvDeviceParam.getManufacturer()).getData())) {
|
||||
throw new BusinessException(SystemResponseEnum.MANUFACTURER);
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ public class PvDistributedServiceImpl extends ServiceImpl<PvDistributedMapper, P
|
||||
private void checkNameAndParam(PvDistributedParam pvDistributedParam, boolean isUpdate) {
|
||||
|
||||
if(StrUtil.isNotBlank(pvDistributedParam.getScale())) {
|
||||
if (Objects.isNull(dicDataFeignClient.getDicDataById(pvDistributedParam.getScale()))) {
|
||||
if (Objects.isNull(dicDataFeignClient.getDicDataById(pvDistributedParam.getScale()).getData())) {
|
||||
throw new BusinessException(SystemResponseEnum.VOLTAGE_EMPTY);
|
||||
}
|
||||
}
|
||||
@@ -104,6 +104,19 @@ public class PvDistributedServiceImpl extends ServiceImpl<PvDistributedMapper, P
|
||||
if (count > 0) {
|
||||
throw new BusinessException(PvDeviceResponseEnum.SUB_AREA_REPEAT);
|
||||
}
|
||||
|
||||
lambdaQueryWrapper.clear();
|
||||
lambdaQueryWrapper.eq(PvDistributed::getUserCode, pvDistributedParam.getUserCode());
|
||||
if (isUpdate) {
|
||||
//更新操作
|
||||
if (pvDistributedParam instanceof PvDistributedParam.UpdatePvDistributedParam) {
|
||||
lambdaQueryWrapper.eq(PvDistributed::getId, ((PvDistributedParam.UpdatePvDistributedParam) pvDistributedParam).getId());
|
||||
}
|
||||
}
|
||||
int countUserCode = this.count(lambdaQueryWrapper);
|
||||
if (countUserCode > 0) {
|
||||
throw new BusinessException(PvDeviceResponseEnum.USER_CODE_REPEAT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,19 +1,25 @@
|
||||
package com.njcn.pvdevice.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.device.enums.PvDeviceResponseEnum;
|
||||
import com.njcn.device.pojo.param.pv.LineDetailQueryParam;
|
||||
import com.njcn.device.pojo.param.pv.PvLineDetailParam;
|
||||
import com.njcn.device.pojo.po.pv.PvLineDetail;
|
||||
import com.njcn.device.pojo.po.pv.PvLineDetail;
|
||||
import com.njcn.device.pojo.vo.pv.PvLineAllDetailVO;
|
||||
import com.njcn.pvdevice.mapper.PvLineDetailMapper;
|
||||
import com.njcn.pvdevice.service.IPvDeviceService;
|
||||
import com.njcn.pvdevice.service.IPvLineDetailService;
|
||||
import com.njcn.pvdevice.service.*;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.enums.SystemResponseEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.system.utils.SystemEnumUtil;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@@ -38,30 +44,74 @@ public class PvLineDetailServiceImpl extends ServiceImpl<PvLineDetailMapper, PvL
|
||||
|
||||
private final IPvDeviceService iPvDeviceService;
|
||||
|
||||
private final IPvSubstationService iPvSubstationService;
|
||||
|
||||
private final IPvVoltageService iPvVoltageService;
|
||||
|
||||
private final IPvSubAreaService iPvSubAreaService;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean addLineDetail(PvLineDetailParam pvLineDetailParam) {
|
||||
checkName(pvLineDetailParam,false);
|
||||
checkParam(pvLineDetailParam);
|
||||
PvLineDetail pvLineDetail = new PvLineDetail();
|
||||
BeanUtils.copyProperties(pvLineDetailParam,pvLineDetail);
|
||||
checkNameAndParam(pvLineDetailParam);
|
||||
//判断同一台装置是否出现监测点序号重复或超过x路序号
|
||||
lineNumIsExit(pvLineDetailParam,false);
|
||||
PvLineDetail pvLineDetail = commMonit(pvLineDetailParam);
|
||||
return this.save(pvLineDetail);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateLineDetail(PvLineDetailParam.UpdatePvLineDetailParam updatePvLineDetailParam) {
|
||||
checkName(updatePvLineDetailParam,true);
|
||||
checkParam(updatePvLineDetailParam);
|
||||
PvLineDetail pvLineDetail = new PvLineDetail();
|
||||
BeanUtils.copyProperties(updatePvLineDetailParam,pvLineDetail);
|
||||
checkNameAndParam(updatePvLineDetailParam);
|
||||
lineNumIsExit(updatePvLineDetailParam,true);
|
||||
PvLineDetail pvLineDetail = commMonit(updatePvLineDetailParam);
|
||||
return this.updateById(pvLineDetail);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 公共代码提取
|
||||
*/
|
||||
private PvLineDetail commMonit(PvLineDetailParam pvLineDetailParam){
|
||||
PvLineDetail pvLineDetail = new PvLineDetail();
|
||||
BeanUtils.copyProperties(pvLineDetailParam,pvLineDetail);
|
||||
pvLineDetail.setState(DataStateEnum.ENABLE.getCode());
|
||||
if(StrUtil.isNotBlank(pvLineDetailParam.getAccess())){
|
||||
pvLineDetail.setAccess(PubUtils.localDateFormat(pvLineDetailParam.getAccess()));
|
||||
}
|
||||
if(StrUtil.isNotBlank(pvLineDetailParam.getPutIn())){
|
||||
pvLineDetail.setAccess(PubUtils.localDateFormat(pvLineDetailParam.getPutIn()));
|
||||
}
|
||||
return pvLineDetail;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 监测点序号是否重复判断
|
||||
* @author cdf
|
||||
* @date 2022/7/11
|
||||
*/
|
||||
private void lineNumIsExit(PvLineDetailParam pvLineDetailParam,Boolean isUpdate){
|
||||
LambdaQueryWrapper<PvLineDetail> query = new LambdaQueryWrapper<>();
|
||||
query.eq(PvLineDetail::getDevId,pvLineDetailParam.getDevId())
|
||||
.eq(PvLineDetail::getNum,pvLineDetailParam.getNum())
|
||||
.eq(PvLineDetail::getState,DataStateEnum.ENABLE.getCode());
|
||||
if(isUpdate){
|
||||
if(pvLineDetailParam instanceof PvLineDetailParam.UpdatePvLineDetailParam){
|
||||
query.ne(PvLineDetail::getId,((PvLineDetailParam.UpdatePvLineDetailParam) pvLineDetailParam).getId());
|
||||
}
|
||||
}
|
||||
int count = this.count(query);
|
||||
if (count > 0) {
|
||||
throw new BusinessException(PvDeviceResponseEnum.DEV_NUM_NULL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<PvLineDetail> getPvLineDetailList(LineDetailQueryParam subsAreaQueryParam) {
|
||||
Page<PvLineDetail> page = new Page<>(PageFactory.getPageNum(subsAreaQueryParam),PageFactory.getPageSize(subsAreaQueryParam));
|
||||
LambdaQueryWrapper<PvLineDetail> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
return this.page(page,lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@@ -80,34 +130,99 @@ public class PvLineDetailServiceImpl extends ServiceImpl<PvLineDetailMapper, PvL
|
||||
return this.removeById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<PvLineAllDetailVO> getPvLineAllDetailMain(Integer pageNum,Integer pageSize,List<String> subIds, List<String> subAreaIds) {
|
||||
|
||||
Page<PvLineAllDetailVO> page = new Page<>(pageNum,pageSize);
|
||||
|
||||
return this.baseMapper.getPvLineAllDetailMain(page,subIds,subAreaIds);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 校验单位名称是否重复
|
||||
*/
|
||||
private void checkName(PvLineDetailParam pvLineDetailParam, boolean isUpdate) {
|
||||
LambdaQueryWrapper<PvLineDetail> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(PvLineDetail::getNum, pvLineDetailParam.getNum());
|
||||
if (isUpdate) {
|
||||
//更新操作
|
||||
if (pvLineDetailParam instanceof PvLineDetailParam.UpdatePvLineDetailParam) {
|
||||
lambdaQueryWrapper.eq(PvLineDetail::getId, ((PvLineDetailParam.UpdatePvLineDetailParam) pvLineDetailParam).getId());
|
||||
}
|
||||
}
|
||||
int count = this.count(lambdaQueryWrapper);
|
||||
if (count > 0) {
|
||||
throw new BusinessException(PvDeviceResponseEnum.SUB_AREA_REPEAT);
|
||||
}
|
||||
}
|
||||
private void checkNameAndParam(PvLineDetailParam pvLineDetailParam) {
|
||||
|
||||
/**
|
||||
* 校验参数是否违规
|
||||
*/
|
||||
private void checkParam(PvLineDetailParam pvLineDetailParam){
|
||||
if(Objects.isNull(dicDataFeignClient.getDicDataById(pvLineDetailParam.getLoadType()))){
|
||||
throw new BusinessException(SystemResponseEnum.INTERFERENCE_EMPTY);
|
||||
}
|
||||
if(Objects.isNull(iPvDeviceService.getPvDeviceById(pvLineDetailParam.getDevId()))){
|
||||
throw new BusinessException(PvDeviceResponseEnum.DEV_NULL);
|
||||
}
|
||||
|
||||
/*校验监测类型*/
|
||||
DictData lineType = dicDataFeignClient.getDicDataById(pvLineDetailParam.getType()).getData();
|
||||
if(Objects.isNull(lineType)){
|
||||
throw new BusinessException(SystemResponseEnum.LINE_TYPE_VARIETY_EMPTY);
|
||||
}
|
||||
if(DicDataEnum.ONE_LINE.getCode().equals(lineType.getCode())){
|
||||
if(StrUtil.hasBlank(pvLineDetailParam.getSubstationId(),pvLineDetailParam.getVoltageId())){
|
||||
throw new BusinessException(PvDeviceResponseEnum.ONE_SUB_VOLTAGE_EMPTY);
|
||||
}
|
||||
if(StrUtil.isNotBlank(pvLineDetailParam.getSubAreaId())){
|
||||
pvLineDetailParam.setSubAreaId("");
|
||||
}
|
||||
}else if(DicDataEnum.TWO_LINE.getCode().equals(lineType.getCode())){
|
||||
if(StrUtil.isNotBlank(pvLineDetailParam.getSubstationId()) ||StrUtil.isNotBlank(pvLineDetailParam.getVoltageId())){
|
||||
throw new BusinessException(PvDeviceResponseEnum.TWO_SUB_VOLTAGE_EMPTY_MUST);
|
||||
}
|
||||
|
||||
//2类3类监测点必须存在台区
|
||||
if(StrUtil.isBlank(pvLineDetailParam.getSubAreaId())){
|
||||
throw new BusinessException(PvDeviceResponseEnum.SUB_AREA_EMPTY);
|
||||
}
|
||||
|
||||
|
||||
}else if(DicDataEnum.THREE_LINE.getCode().equals(lineType.getCode())){
|
||||
if(StrUtil.isNotBlank(pvLineDetailParam.getSubstationId()) ||StrUtil.isNotBlank(pvLineDetailParam.getVoltageId())){
|
||||
throw new BusinessException(PvDeviceResponseEnum.TWO_SUB_VOLTAGE_EMPTY_MUST);
|
||||
}
|
||||
|
||||
//2类3类监测点必须存在台区
|
||||
if(StrUtil.isBlank(pvLineDetailParam.getSubAreaId())){
|
||||
throw new BusinessException(PvDeviceResponseEnum.SUB_AREA_EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(Objects.isNull(dicDataFeignClient.getDicDataById(pvLineDetailParam.getBusinessType()).getData())){
|
||||
throw new BusinessException(SystemResponseEnum.BUSINESS_EMPTY);
|
||||
}
|
||||
|
||||
if(StrUtil.isNotBlank(pvLineDetailParam.getScale())) {
|
||||
if (Objects.isNull(dicDataFeignClient.getDicDataById(pvLineDetailParam.getScale()).getData())) {
|
||||
throw new BusinessException(SystemResponseEnum.LINE_TYPE_VARIETY_EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
if(Objects.isNull(dicDataFeignClient.getDicDataById(pvLineDetailParam.getLoadType()).getData())){
|
||||
throw new BusinessException(SystemResponseEnum.INTERFERENCE_EMPTY);
|
||||
}
|
||||
|
||||
/*校验变电站*/
|
||||
if(StrUtil.isNotBlank(pvLineDetailParam.getSubstationId())) {
|
||||
if (Objects.isNull(iPvSubstationService.getPvSubstationById(pvLineDetailParam.getSubstationId()))) {
|
||||
throw new BusinessException(PvDeviceResponseEnum.SUBSTATION_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/*校验母线*/
|
||||
if(StrUtil.isNotBlank(pvLineDetailParam.getVoltageId())) {
|
||||
if (Objects.isNull(iPvVoltageService.getPvVoltageById(pvLineDetailParam.getVoltageId()))) {
|
||||
throw new BusinessException(PvDeviceResponseEnum.VOLTAGE_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/*校验台区*/
|
||||
if(StrUtil.isNotBlank(pvLineDetailParam.getSubAreaId())) {
|
||||
if (Objects.isNull(iPvSubAreaService.getPvSubAreaById(pvLineDetailParam.getSubAreaId()))) {
|
||||
throw new BusinessException(PvDeviceResponseEnum.SUB_AREA_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -7,7 +7,9 @@ import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.device.enums.PvDeviceResponseEnum;
|
||||
import com.njcn.device.pojo.param.pv.LvUserQueryParam;
|
||||
import com.njcn.device.pojo.param.pv.PvDistributedParam;
|
||||
import com.njcn.device.pojo.param.pv.PvLvUserParam;
|
||||
import com.njcn.device.pojo.po.pv.PvDistributed;
|
||||
import com.njcn.device.pojo.po.pv.PvLvUser;
|
||||
import com.njcn.device.pojo.po.pv.PvLvUser;
|
||||
import com.njcn.pvdevice.mapper.PvLvUserMapper;
|
||||
@@ -85,7 +87,7 @@ public class PvLvUserServiceImpl extends ServiceImpl<PvLvUserMapper, PvLvUser> i
|
||||
private void checkNameAndParam(PvLvUserParam pvLvUserParam, boolean isUpdate) {
|
||||
|
||||
if(StrUtil.isNotBlank(pvLvUserParam.getScale())) {
|
||||
if (Objects.isNull(dicDataFeignClient.getDicDataById(pvLvUserParam.getScale()))) {
|
||||
if (Objects.isNull(dicDataFeignClient.getDicDataById(pvLvUserParam.getScale()).getData())) {
|
||||
throw new BusinessException(SystemResponseEnum.VOLTAGE_EMPTY);
|
||||
}
|
||||
}
|
||||
@@ -102,6 +104,20 @@ public class PvLvUserServiceImpl extends ServiceImpl<PvLvUserMapper, PvLvUser> i
|
||||
if (count > 0) {
|
||||
throw new BusinessException(PvDeviceResponseEnum.SUB_AREA_REPEAT);
|
||||
}
|
||||
|
||||
|
||||
lambdaQueryWrapper.clear();
|
||||
lambdaQueryWrapper.eq(PvLvUser::getUserCode, pvLvUserParam.getUserCode());
|
||||
if (isUpdate) {
|
||||
//更新操作
|
||||
if (pvLvUserParam instanceof PvLvUserParam.UpdatePvLvUserParam) {
|
||||
lambdaQueryWrapper.eq(PvLvUser::getId, ((PvLvUserParam.UpdatePvLvUserParam) pvLvUserParam).getId());
|
||||
}
|
||||
}
|
||||
int countUserCode = this.count(lambdaQueryWrapper);
|
||||
if (countUserCode > 0) {
|
||||
throw new BusinessException(PvDeviceResponseEnum.USER_CODE_REPEAT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
package com.njcn.pvdevice.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.device.enums.LineBaseEnum;
|
||||
import com.njcn.device.pojo.param.pv.PvTerminalBaseQuery;
|
||||
import com.njcn.device.pojo.po.pv.PvSubArea;
|
||||
import com.njcn.device.pojo.po.pv.PvSubstation;
|
||||
import com.njcn.device.pojo.vo.pv.PvLineAllDetailVO;
|
||||
import com.njcn.pvdevice.mapper.PvLineDetailMapper;
|
||||
import com.njcn.pvdevice.mapper.PvSubAreaMapper;
|
||||
import com.njcn.pvdevice.mapper.PvSubstationMapper;
|
||||
import com.njcn.pvdevice.service.*;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.user.api.DeptFeignClient;
|
||||
import com.njcn.user.pojo.vo.PvTerminalTreeVO;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2022/7/11
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class PvTerminalBaseServiceImpl implements PvTerminalBaseService {
|
||||
|
||||
private final IPvUnitService iPvUnitService;
|
||||
|
||||
private final IPvSubstationService iPvSubstationService;
|
||||
|
||||
private final IPvSubAreaService iPvSubAreaService;
|
||||
|
||||
private final IPvLineDetailService iPvLineDetailService;
|
||||
|
||||
private final PvSubstationMapper pvSubstationMapper;
|
||||
|
||||
private final PvSubAreaMapper pvSubAreaMapper;
|
||||
|
||||
private final PvLineDetailMapper pvLineDetailMapper;
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
private final DeptFeignClient deptFeignClient;
|
||||
|
||||
@Override
|
||||
public List<PvTerminalTreeVO> pvTerminalTree() {
|
||||
List<PvTerminalTreeVO> unitTreeList = deptFeignClient.allDeptList().getData();
|
||||
List<PvTerminalTreeVO> subTreeList = pvSubstationMapper.getSubstationTreeList();
|
||||
List<PvTerminalTreeVO> subAreaTreeList = pvSubAreaMapper.getSubAreaTreeList();
|
||||
unitTreeList.addAll(subTreeList);
|
||||
unitTreeList.addAll(subAreaTreeList);
|
||||
List<PvTerminalTreeVO> newUnit = unitTreeList.stream().filter(item->item.getPid().equals("0")).peek(tem->tem.setChildren(getChildren(tem,unitTreeList))).collect(Collectors.toList());
|
||||
|
||||
return newUnit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<PvLineAllDetailVO> lineDetailBySubId(PvTerminalBaseQuery pvTerminalBaseQuery) {
|
||||
List<String> ids = pvTerminalBaseQuery.getId();
|
||||
Integer level = pvTerminalBaseQuery.getLevel();
|
||||
|
||||
if(level.equals(LineBaseEnum.PV_UNIT_LEVEL.getCode())){
|
||||
//点击的是单位节点
|
||||
LambdaQueryWrapper<PvSubstation> subQuery= new LambdaQueryWrapper<>();
|
||||
subQuery.in(PvSubstation::getUnitId,ids);
|
||||
List<PvSubstation> substationList = iPvSubstationService.list(subQuery);
|
||||
List<String> subIds = substationList.stream().map(PvSubstation::getId).collect(Collectors.toList());
|
||||
|
||||
LambdaQueryWrapper<PvSubArea> areaQuery= new LambdaQueryWrapper<>();
|
||||
areaQuery.in(PvSubArea::getUnitId,ids);
|
||||
List<PvSubArea> subAreaList = iPvSubAreaService.list(areaQuery);
|
||||
List<String> subAreaIds = subAreaList.stream().map(PvSubArea::getId).collect(Collectors.toList());
|
||||
return iPvLineDetailService.getPvLineAllDetailMain(1,10,subIds,subAreaIds);
|
||||
}else if(level.equals(LineBaseEnum.PV_SUB_LEVEL.getCode())){
|
||||
|
||||
return iPvLineDetailService.getPvLineAllDetailMain(1,10, ids,null);
|
||||
}else if(level.equals(LineBaseEnum.PV_SUB_AREA_LEVEL.getCode())){
|
||||
|
||||
return iPvLineDetailService.getPvLineAllDetailMain(1,10,null,ids);
|
||||
|
||||
}
|
||||
throw new BusinessException(CommonResponseEnum.FAIL);
|
||||
}
|
||||
|
||||
|
||||
private void diGui(List<PvTerminalTreeVO> unitTreeList,List<PvTerminalTreeVO> subTreeList,List<PvTerminalTreeVO> subAreaTreeList) {
|
||||
for (PvTerminalTreeVO unit : unitTreeList) {
|
||||
if (CollUtil.isNotEmpty(unit.getChildren())) {
|
||||
diGui(unit.getChildren(),subTreeList,subAreaTreeList);
|
||||
} else {
|
||||
unit.setChildren(getChildren(unit, subTreeList));
|
||||
unit.setChildren(getChildren(unit, subAreaTreeList));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private List<PvTerminalTreeVO> getChildren(PvTerminalTreeVO tem, List<PvTerminalTreeVO> children) {
|
||||
return children.stream().filter(item -> item.getPid().equals(tem.getId())).peek(t->t.setChildren(getChildren(t,children))).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import com.njcn.device.pojo.vo.pv.UnitTreeVO;
|
||||
import com.njcn.pvdevice.mapper.PvUnitMapper;
|
||||
import com.njcn.pvdevice.service.IPvUnitService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.user.pojo.vo.PvTerminalTreeVO;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -54,6 +55,8 @@ public class PvUnitServiceImpl extends ServiceImpl<PvUnitMapper, PvUnit> impleme
|
||||
return parentList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 递归查询子节点
|
||||
* @param root 根节点
|
||||
@@ -65,6 +68,11 @@ public class PvUnitServiceImpl extends ServiceImpl<PvUnitMapper, PvUnit> impleme
|
||||
.peek(m -> m.setChildren(getChildren(m, all))).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<PvTerminalTreeVO> getChildrens(PvTerminalTreeVO root, List<PvTerminalTreeVO> all) {
|
||||
return all.stream().filter(m -> Objects.equals(m.getPid(), root.getId()))
|
||||
.peek(m -> m.setChildren(getChildrens(m, all))).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PvUnit getPvUnitById(String id) {
|
||||
return this.getById(id);
|
||||
|
||||
Reference in New Issue
Block a user