1.园区接口完成
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package com.njcn.device.pms.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2024/6/21
|
||||
*/
|
||||
@Getter
|
||||
public enum PmsEnum {
|
||||
|
||||
|
||||
NO_UPLOAD("未上送","0"),
|
||||
HAS_UPLOAD("以上送","1"),
|
||||
WAIT_RETURN_UPLOAD("待重新上送","2"),
|
||||
DELETE_UPLOAD("已删除","3"),
|
||||
|
||||
;
|
||||
|
||||
|
||||
private final String name;
|
||||
private final String code;
|
||||
|
||||
PmsEnum(String name, String code) {
|
||||
this.name = name;
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.njcn.device.pms.pojo.dto;
|
||||
|
||||
import com.njcn.device.pms.pojo.po.PmsParkPO;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2024/6/24
|
||||
*/
|
||||
@Data
|
||||
public class ParkDto {
|
||||
|
||||
private List<PmsParkPO> parkVoListt;
|
||||
|
||||
|
||||
private List<ParkSubstationRelVo> parkSubstationRelVoList;
|
||||
|
||||
|
||||
@Data
|
||||
public static class ParkSubstationRelVo{
|
||||
private String objId;
|
||||
private String parkId;
|
||||
private String substationId;
|
||||
private String substationProvinceOrg;
|
||||
private String substationProvinceOrgName;
|
||||
private String substationCityOrg;
|
||||
private String substationCityOrgName;
|
||||
private String substationMaintOrg;
|
||||
private String substationMaintOrgName;
|
||||
private String substationName;
|
||||
private String substationVoltageLevel;
|
||||
private String substationRunStatus;
|
||||
private String substationOperateDate;
|
||||
private String createTime;
|
||||
private String updateTime;
|
||||
private String isDelete;
|
||||
private String deleteTime;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package com.njcn.device.pms.pojo.param;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 园区表
|
||||
* </p>
|
||||
*
|
||||
* @author cdf
|
||||
* @since 2024-06-19
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class PmsParkParam {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
/**
|
||||
* 省单位
|
||||
*/
|
||||
private String provinceOrg;
|
||||
|
||||
/**
|
||||
* 省单位名称
|
||||
*/
|
||||
private String provinceName;
|
||||
|
||||
/**
|
||||
* 市单位
|
||||
*/
|
||||
private String cityOrg;
|
||||
|
||||
/**
|
||||
* 市单位名称
|
||||
*/
|
||||
private String cityOrgName;
|
||||
|
||||
/**
|
||||
* 运维单位
|
||||
*/
|
||||
private String maintOrg;
|
||||
|
||||
/**
|
||||
* 运维单位名称
|
||||
*/
|
||||
private String maintOrgName;
|
||||
|
||||
/**
|
||||
* 园区名称
|
||||
*/
|
||||
private String parkName;
|
||||
|
||||
/**
|
||||
* 园区性质
|
||||
*/
|
||||
private String parkNature;
|
||||
|
||||
/**
|
||||
* 园区级别
|
||||
*/
|
||||
private String parkLevel;
|
||||
|
||||
/**
|
||||
* 园区状态
|
||||
*/
|
||||
private String parkStatus;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 0.删除 1.正常
|
||||
*/
|
||||
private LocalDateTime deleteTime;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class UpdatePmsParkParam extends PmsParkParam{
|
||||
|
||||
private String objId;
|
||||
}
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class PmsParkQuery extends BaseParam {
|
||||
|
||||
private String objId;
|
||||
|
||||
private String maintOrg;
|
||||
|
||||
private String cityOrg;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.njcn.device.pms.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
@@ -28,6 +29,7 @@ public class PmsMidLedger extends BaseEntity {
|
||||
/**
|
||||
* Id
|
||||
*/
|
||||
@TableId
|
||||
private String id;
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.njcn.device.pms.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 园区表
|
||||
* </p>
|
||||
*
|
||||
* @author cdf
|
||||
* @since 2024-06-19
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("pms_park")
|
||||
public class PmsParkPO extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* uuid
|
||||
*/
|
||||
@TableId(value = "obj_id",type = IdType.ASSIGN_UUID)
|
||||
private String objId;
|
||||
|
||||
/**
|
||||
* 省单位
|
||||
*/
|
||||
private String provinceOrg;
|
||||
|
||||
/**
|
||||
* 省单位名称
|
||||
*/
|
||||
private String provinceName;
|
||||
|
||||
/**
|
||||
* 市单位
|
||||
*/
|
||||
private String cityOrg;
|
||||
|
||||
/**
|
||||
* 市单位名称
|
||||
*/
|
||||
private String cityOrgName;
|
||||
|
||||
/**
|
||||
* 运维单位
|
||||
*/
|
||||
private String maintOrg;
|
||||
|
||||
/**
|
||||
* 运维单位名称
|
||||
*/
|
||||
private String maintOrgName;
|
||||
|
||||
/**
|
||||
* 园区名称
|
||||
*/
|
||||
private String parkName;
|
||||
|
||||
/**
|
||||
* 园区性质
|
||||
*/
|
||||
private String parkNature;
|
||||
|
||||
/**
|
||||
* 园区级别
|
||||
*/
|
||||
private String parkLevel;
|
||||
|
||||
/**
|
||||
* 园区状态
|
||||
*/
|
||||
private String parkStatus;
|
||||
|
||||
|
||||
private String isDelete;
|
||||
|
||||
/**
|
||||
* 0.删除 1.正常
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime deleteTime;
|
||||
|
||||
private String uploadStatus;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.njcn.device.pms.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import java.io.Serializable;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author cdf
|
||||
* @since 2024-06-19
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("pms_park_station_ass")
|
||||
public class PmsParkStationAss {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId
|
||||
private String objId;
|
||||
|
||||
@NotBlank(message = "园区id不可为空")
|
||||
private String parkId;
|
||||
|
||||
/**
|
||||
* 园区所有电站id关联pms_mid_ledger
|
||||
*/
|
||||
@NotBlank(message = "电站不可为空")
|
||||
private String midStationId;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package com.njcn.device.pms.controller.ledgerManger;
|
||||
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.device.pms.pojo.param.PmsParkParam;
|
||||
import com.njcn.device.pms.pojo.po.PmsMidLedger;
|
||||
import com.njcn.device.pms.pojo.po.PmsParkPO;
|
||||
import com.njcn.device.pms.pojo.po.PmsParkStationAss;
|
||||
import com.njcn.device.pms.service.ledgerManger.IPmsParkService;
|
||||
import com.njcn.device.pms.service.ledgerManger.IPmsParkStationAssService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 园区表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author cdf
|
||||
* @since 2024-06-19
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/pmsPark")
|
||||
@RequiredArgsConstructor
|
||||
public class PmsParkController extends BaseController {
|
||||
|
||||
private final IPmsParkService iPmsParkService;
|
||||
|
||||
private final IPmsParkStationAssService iPmsParkStationAssService;
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
|
||||
@PostMapping("/addPark")
|
||||
@ApiOperation("新增园区")
|
||||
public HttpResult<Object> addPark(@RequestBody PmsParkParam param) {
|
||||
String methodDescribe = getMethodDescribe("addPark");
|
||||
Boolean result = iPmsParkService.addPark(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.UPDATE)
|
||||
@PostMapping("/updatePark")
|
||||
@ApiOperation("修改园区台账")
|
||||
public HttpResult<Object> updatePark(@RequestBody PmsParkParam.UpdatePmsParkParam param) {
|
||||
String methodDescribe = getMethodDescribe("updatePark");
|
||||
Boolean result = iPmsParkService.updatePark(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.DELETE)
|
||||
@PostMapping("/delPark")
|
||||
@ApiOperation("修改园区台账")
|
||||
public HttpResult<Object> delPark(@RequestBody List<String> ids) {
|
||||
String methodDescribe = getMethodDescribe("delPark");
|
||||
Boolean result = iPmsParkService.removeByIds(ids);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/pageList")
|
||||
@ApiOperation("分页查询园区台账")
|
||||
public HttpResult<Page<PmsParkPO>> pageList(@RequestBody PmsParkParam.PmsParkQuery param) {
|
||||
String methodDescribe = getMethodDescribe("pageList");
|
||||
Page<PmsParkPO> result = iPmsParkService.pageList(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/uploadParkGw")
|
||||
@ApiOperation("上送园区到国网")
|
||||
public HttpResult<Boolean> uploadParkGw(@RequestBody List<String> objIds) {
|
||||
String methodDescribe = getMethodDescribe("uploadParkGw");
|
||||
Boolean result = iPmsParkService.uploadParkGw(objIds);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/pageStationList")
|
||||
@ApiOperation("分页查询园区下面的电站")
|
||||
public HttpResult<Page<PmsMidLedger>> pageStationList(@RequestBody PmsParkParam.PmsParkQuery param) {
|
||||
String methodDescribe = getMethodDescribe("pageStationList");
|
||||
Page<PmsMidLedger> result = iPmsParkService.pageStationList(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/stationList")
|
||||
@ApiOperation("根据运行单位获取下面的电站")
|
||||
public HttpResult<List<PmsMidLedger>> stationList(@RequestBody PmsParkParam.PmsParkQuery param) {
|
||||
String methodDescribe = getMethodDescribe("stationList");
|
||||
List<PmsMidLedger> result = iPmsParkService.stationList(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
|
||||
@PostMapping("/addParkStationAss")
|
||||
@ApiOperation("新增园区电站")
|
||||
public HttpResult<Object> addParkStationAss(@RequestBody PmsParkStationAss param) {
|
||||
String methodDescribe = getMethodDescribe("addParkStationAss");
|
||||
|
||||
LambdaQueryWrapper<PmsParkStationAss> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(PmsParkStationAss::getParkId,param.getParkId()).eq(PmsParkStationAss::getMidStationId,param.getMidStationId());
|
||||
long count = iPmsParkStationAssService.count(lambdaQueryWrapper);
|
||||
if(count>0){
|
||||
throw new BusinessException(CommonResponseEnum.FAIL,"园区已经存在该电站");
|
||||
}
|
||||
PmsParkStationAss pmsParkStationAss = new PmsParkStationAss();
|
||||
BeanUtil.copyProperties(param,pmsParkStationAss);
|
||||
Boolean result = iPmsParkStationAssService.save(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.DELETE)
|
||||
@PostMapping("/delParkStationAss")
|
||||
@ApiOperation("删除园区电站")
|
||||
public HttpResult<Object> delParkStationAss(@RequestBody @Validated PmsParkStationAss param) {
|
||||
String methodDescribe = getMethodDescribe("delParkStationAss");
|
||||
LambdaQueryWrapper<PmsParkStationAss> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(PmsParkStationAss::getParkId,param.getParkId()).eq(PmsParkStationAss::getMidStationId,param.getMidStationId());
|
||||
Boolean result = iPmsParkStationAssService.remove(lambdaQueryWrapper);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.njcn.device.pms.mapper.majornetwork;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.device.pms.pojo.dto.ParkDto;
|
||||
import com.njcn.device.pms.pojo.po.PmsParkPO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 园区表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author cdf
|
||||
* @since 2024-06-19
|
||||
*/
|
||||
public interface PmsParkMapper extends BaseMapper<PmsParkPO> {
|
||||
|
||||
|
||||
List<ParkDto.ParkSubstationRelVo> getParkStationAss(@Param("parkIds")List<String> parkIds);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.njcn.device.pms.mapper.majornetwork;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.device.pms.pojo.po.PmsParkStationAss;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author cdf
|
||||
* @since 2024-06-19
|
||||
*/
|
||||
public interface PmsParkStationAssMapper extends BaseMapper<PmsParkStationAss> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.device.pms.mapper.majornetwork.PmsParkMapper">
|
||||
|
||||
<select id="getParkStationAss" resultType="com.njcn.device.pms.pojo.dto.ParkDto$ParkSubstationRelVo">
|
||||
select
|
||||
ass.obj_Id,
|
||||
park.obj_id parkId,
|
||||
mid.id substationId,
|
||||
park.province_Org substationProvinceOrg,
|
||||
park.province_Name substationProvinceOrgName,
|
||||
mid.cityOrg substationCityOrg,
|
||||
mid.cityOrgName substationCityOrgName,
|
||||
mid.Operation_Id substationMaintOrg,
|
||||
mid.Operation_Name substationMaintOrgName,
|
||||
mid.name substationName,
|
||||
LPAD(dic.Algo_Describe,2,0) substationVoltageLevel,
|
||||
dicRun.value substationRunStatus,
|
||||
mid.Operation_Date substationOperateDate
|
||||
|
||||
from pms_park park
|
||||
inner join pms_park_station_ass ass on park.obj_id = ass.park_id
|
||||
inner join pms_mid_ledger mid on ass.mid_station_id = mid.id
|
||||
left join sys_dict_data dic on mid.voltage_Level = dic.id
|
||||
left join sys_dict_data dicRun on mid.Run_Status = dicRun.id
|
||||
where park.obj_id in
|
||||
<foreach collection="parkIds" open="(" separator="," close=")" item="item">
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.njcn.device.pms.service.ledgerManger;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.device.pms.pojo.param.PmsParkParam;
|
||||
import com.njcn.device.pms.pojo.po.PmsMidLedger;
|
||||
import com.njcn.device.pms.pojo.po.PmsParkPO;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 园区表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author cdf
|
||||
* @since 2024-06-19
|
||||
*/
|
||||
public interface IPmsParkService extends IService<PmsParkPO> {
|
||||
|
||||
|
||||
Boolean addPark(PmsParkParam param);
|
||||
|
||||
|
||||
|
||||
Boolean updatePark(PmsParkParam.UpdatePmsParkParam updatePmsParkParam);
|
||||
|
||||
|
||||
|
||||
Page<PmsParkPO> pageList(PmsParkParam.PmsParkQuery parkQuery);
|
||||
|
||||
|
||||
|
||||
Boolean uploadParkGw(@RequestBody List<String> objIds);
|
||||
|
||||
|
||||
|
||||
Page<PmsMidLedger> pageStationList(PmsParkParam.PmsParkQuery param);
|
||||
|
||||
List<PmsMidLedger> stationList(PmsParkParam.PmsParkQuery param);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.njcn.device.pms.service.ledgerManger;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.device.pms.pojo.po.PmsParkStationAss;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author cdf
|
||||
* @since 2024-06-19
|
||||
*/
|
||||
public interface IPmsParkStationAssService extends IService<PmsParkStationAss> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
package com.njcn.device.pms.service.ledgerManger.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.device.pms.enums.PmsEnum;
|
||||
import com.njcn.device.pms.mapper.majornetwork.PmsMidLedgerMapper;
|
||||
import com.njcn.device.pms.mapper.majornetwork.PmsParkMapper;
|
||||
import com.njcn.device.pms.pojo.dto.ParkDto;
|
||||
import com.njcn.device.pms.pojo.param.PmsParkParam;
|
||||
import com.njcn.device.pms.pojo.po.PmsMidLedger;
|
||||
import com.njcn.device.pms.pojo.po.PmsParkPO;
|
||||
import com.njcn.device.pms.pojo.po.PmsParkStationAss;
|
||||
import com.njcn.device.pms.service.ledgerManger.IPmsParkService;
|
||||
import com.njcn.device.pms.service.ledgerManger.IPmsParkStationAssService;
|
||||
import com.njcn.user.api.DeptFeignClient;
|
||||
import com.njcn.user.pojo.vo.PvTerminalTreeVO;
|
||||
import com.njcn.web.enums.GWSendEnum;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import com.njcn.web.pojo.param.SendParam;
|
||||
import com.njcn.web.utils.GwSendUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 园区表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author cdf
|
||||
* @since 2024-06-19
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class PmsParkServiceImpl extends ServiceImpl<PmsParkMapper, PmsParkPO> implements IPmsParkService {
|
||||
|
||||
private final DeptFeignClient deptFeignClient;
|
||||
|
||||
private final IPmsParkStationAssService iPmsParkStationAssService;
|
||||
|
||||
private final PmsMidLedgerMapper pmsMidLedgerMapper;
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Boolean addPark(PmsParkParam param) {
|
||||
PmsParkPO pmsParkPO = new PmsParkPO();
|
||||
BeanUtil.copyProperties(param, pmsParkPO);
|
||||
pmsParkPO.setIsDelete(DataStateEnum.ENABLE.getCode().toString());
|
||||
pmsParkPO.setUploadStatus(PmsEnum.NO_UPLOAD.getCode());
|
||||
List<PvTerminalTreeVO> dept = deptFeignClient.allDeptList().getData();
|
||||
getOrgCode(dept,pmsParkPO);
|
||||
return this.save(pmsParkPO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updatePark(PmsParkParam.UpdatePmsParkParam updatePmsParkParam) {
|
||||
PmsParkPO result = this.getById(updatePmsParkParam.getObjId());
|
||||
PmsParkPO pmsParkPO = new PmsParkPO();
|
||||
BeanUtil.copyProperties(updatePmsParkParam, pmsParkPO);
|
||||
if(result.getUploadStatus().equals(PmsEnum.HAS_UPLOAD.getCode())){
|
||||
pmsParkPO.setUploadStatus(PmsEnum.WAIT_RETURN_UPLOAD.getCode());
|
||||
}
|
||||
List<PvTerminalTreeVO> dept = deptFeignClient.allDeptList().getData();
|
||||
getOrgCode(dept,pmsParkPO);
|
||||
return this.updateById(pmsParkPO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<PmsParkPO> pageList(PmsParkParam.PmsParkQuery parkQuery) {
|
||||
List<String> deptCodes = deptFeignClient.getDepSonSelfCodetByDeptId(parkQuery.getMaintOrg()).getData();
|
||||
LambdaQueryWrapper<PmsParkPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.in(PmsParkPO::getMaintOrg, deptCodes);
|
||||
return this.page(new Page<>(PageFactory.getPageNum(parkQuery), PageFactory.getPageSize(parkQuery)), lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean uploadParkGw(List<String> objIds) {
|
||||
List<PmsParkPO> pmsParkPOList;
|
||||
if(CollUtil.isEmpty(objIds)){
|
||||
LambdaQueryWrapper<PmsParkPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.in(PmsParkPO::getUploadStatus, Stream.of(PmsEnum.NO_UPLOAD.getCode(),PmsEnum.WAIT_RETURN_UPLOAD.getCode()).collect(Collectors.toList()));
|
||||
pmsParkPOList = this.list(lambdaQueryWrapper);
|
||||
}else {
|
||||
pmsParkPOList = this.listByIds(objIds);
|
||||
}
|
||||
List<String> ids = pmsParkPOList.stream().map(PmsParkPO::getObjId).collect(Collectors.toList());
|
||||
List<ParkDto.ParkSubstationRelVo> stationList = this.baseMapper.getParkStationAss(ids);
|
||||
|
||||
List<ParkDto> dtoList = new ArrayList<>();
|
||||
ParkDto parkDto = new ParkDto();
|
||||
parkDto.setParkVoListt(pmsParkPOList);
|
||||
if(CollUtil.isNotEmpty(stationList)){
|
||||
parkDto.setParkSubstationRelVoList(stationList);
|
||||
}
|
||||
dtoList.add(parkDto);
|
||||
|
||||
SendParam sendParam = new SendParam();
|
||||
sendParam.setStats(dtoList);
|
||||
Map<String,String> map = GwSendUtil.send(sendParam, GWSendEnum.PARK_AND_STATION);
|
||||
GwSendUtil.returnInfoMsg(objIds,map);
|
||||
|
||||
LambdaUpdateWrapper<PmsParkPO> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.set(PmsParkPO::getUploadStatus,PmsEnum.HAS_UPLOAD).eq(PmsParkPO::getObjId,objIds);
|
||||
this.update(updateWrapper);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<PmsMidLedger> pageStationList(PmsParkParam.PmsParkQuery param) {
|
||||
Page<PmsMidLedger> result = new Page<>(param.getPageNum(),param.getPageSize());
|
||||
List<PmsParkStationAss> pmsParkStationAssList = iPmsParkStationAssService.list(new LambdaQueryWrapper<PmsParkStationAss>().eq(PmsParkStationAss::getParkId,param.getObjId()));
|
||||
List<String> ids = pmsParkStationAssList.stream().map(PmsParkStationAss::getMidStationId).collect(Collectors.toList());
|
||||
if(CollUtil.isEmpty(ids)){
|
||||
return result;
|
||||
}
|
||||
LambdaQueryWrapper<PmsMidLedger> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.in(PmsMidLedger::getId,ids);
|
||||
result = pmsMidLedgerMapper.selectPage(new Page<>(PageFactory.getPageNum(param),PageFactory.getPageSize(param)),lambdaQueryWrapper);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PmsMidLedger> stationList(PmsParkParam.PmsParkQuery param) {
|
||||
List<String> ids = deptFeignClient.getDepSonSelfCodetByCode(param.getCityOrg()).getData();
|
||||
|
||||
LambdaQueryWrapper<PmsMidLedger> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.select(PmsMidLedger::getName,PmsMidLedger::getOperationName,PmsMidLedger::getId).in(PmsMidLedger::getOperationId,ids).eq(PmsMidLedger::getLevel,0);
|
||||
List<PmsMidLedger> pmsMidLedgerList = pmsMidLedgerMapper.selectList(lambdaQueryWrapper);
|
||||
return pmsMidLedgerList;
|
||||
}
|
||||
|
||||
|
||||
private void getOrgCode(List<PvTerminalTreeVO> dept,PmsParkPO pmsParkPO){
|
||||
PvTerminalTreeVO pvTerminalTreeVO = dept.stream().filter(it->it.getCode().equals(pmsParkPO.getMaintOrg())).findFirst().orElse(null);
|
||||
if(Objects.nonNull(pvTerminalTreeVO)){
|
||||
if(pvTerminalTreeVO.getLevel() == 1 || pvTerminalTreeVO.getLevel() == 2){
|
||||
throw new BusinessException("请选择省级以下单位");
|
||||
}else if(pvTerminalTreeVO.getLevel() == 3){
|
||||
PvTerminalTreeVO province = dept.stream().filter(it->it.getId().equals(pvTerminalTreeVO.getPid())).findFirst().orElse(null);
|
||||
pmsParkPO.setCityOrg(pvTerminalTreeVO.getCode());
|
||||
pmsParkPO.setCityOrgName(pvTerminalTreeVO.getName());
|
||||
|
||||
if(Objects.nonNull(province)){
|
||||
pmsParkPO.setProvinceOrg(province.getCode());
|
||||
pmsParkPO.setProvinceName(province.getName());
|
||||
}
|
||||
} else if(pvTerminalTreeVO.getLevel() == 4){
|
||||
PvTerminalTreeVO city = dept.stream().filter(it->it.getId().equals(pvTerminalTreeVO.getPid())).findFirst().orElse(null);
|
||||
if(Objects.nonNull(city)){
|
||||
pmsParkPO.setCityOrg(city.getCode());
|
||||
pmsParkPO.setCityOrgName(city.getName());
|
||||
|
||||
PvTerminalTreeVO province = dept.stream().filter(it->it.getId().equals(city.getPid())).findFirst().orElse(null);
|
||||
if(Objects.nonNull(province)){
|
||||
pmsParkPO.setProvinceOrg(province.getCode());
|
||||
pmsParkPO.setProvinceName(province.getName());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.njcn.device.pms.service.ledgerManger.impl;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.device.pms.mapper.majornetwork.PmsParkStationAssMapper;
|
||||
import com.njcn.device.pms.pojo.po.PmsParkStationAss;
|
||||
import com.njcn.device.pms.service.ledgerManger.IPmsParkStationAssService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author cdf
|
||||
* @since 2024-06-19
|
||||
*/
|
||||
@Service
|
||||
public class PmsParkStationAssServiceImpl extends ServiceImpl<PmsParkStationAssMapper, PmsParkStationAss> implements IPmsParkStationAssService {
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user