新能源场站增删改查接口
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
package com.njcn.device.pq.pojo.param;
|
||||
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 新能源场站高低电压穿越表查询类
|
||||
* </p>
|
||||
*
|
||||
* @author guofeihu
|
||||
* @since 2024-08-14
|
||||
*/
|
||||
@Data
|
||||
@ApiModel
|
||||
public class NewStationQueryParam extends BaseParam {
|
||||
|
||||
@ApiModelProperty(name = "id")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(name = "新能源场站名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(name = "新能源场站类型")
|
||||
private String stationType;
|
||||
|
||||
@ApiModelProperty(name = "电压等级Guid")
|
||||
private String scale;
|
||||
|
||||
@ApiModelProperty(name = "额定有功功率")
|
||||
private String ratedPower;
|
||||
|
||||
@ApiModelProperty(name = "经度")
|
||||
private String longitude;
|
||||
|
||||
@ApiModelProperty(name = "维度")
|
||||
private String latitude;
|
||||
|
||||
@Data
|
||||
public static class NewStationEdit{
|
||||
@ApiModelProperty(name = "id")
|
||||
private String id;
|
||||
|
||||
@NotBlank(message = "新能源场站名称不能为空")
|
||||
@ApiModelProperty(name = "新能源场站名称")
|
||||
private String name;
|
||||
|
||||
@NotBlank(message = "新能源场站类型不能为空")
|
||||
@ApiModelProperty(name = "新能源场站类型")
|
||||
private String stationType;
|
||||
|
||||
@ApiModelProperty(name = "电压等级Guid")
|
||||
private String scale;
|
||||
|
||||
@NotBlank(message = "额定有功功率不能为空")
|
||||
@ApiModelProperty(name = "额定有功功率")
|
||||
private String ratedPower;
|
||||
|
||||
@NotBlank(message = "经度不能为空")
|
||||
@ApiModelProperty(name = "经度")
|
||||
private String longitude;
|
||||
|
||||
@NotBlank(message = "维度不能为空")
|
||||
@ApiModelProperty(name = "维度")
|
||||
private String latitude;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.njcn.device.pq.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 新能源场站高低电压穿越表实体类
|
||||
* </p>
|
||||
*
|
||||
* @author guofeihu
|
||||
* @since 2024-08-14
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("pq_new_station")
|
||||
public class NewStation extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 新能源场站名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* (关联sys_dict_type字典表)新能源场站类型(风电场、光伏电站)
|
||||
*/
|
||||
private String stationType;
|
||||
|
||||
/**
|
||||
* (关联sys_dict_type字典表)电压等级Guid
|
||||
*/
|
||||
private String scale;
|
||||
|
||||
/**
|
||||
* 额定有功功率
|
||||
*/
|
||||
private String ratedPower;
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
private String longitude;
|
||||
|
||||
/**
|
||||
* 维度
|
||||
*/
|
||||
private String latitude;
|
||||
|
||||
/**
|
||||
* 状态:0-删除 1-正常
|
||||
*/
|
||||
private Integer state;
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.njcn.device.pq.controller;
|
||||
|
||||
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.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.device.pq.pojo.param.NewStationQueryParam;
|
||||
import com.njcn.device.pq.pojo.po.NewStation;
|
||||
import com.njcn.device.pq.service.INewStationService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 新能源场站高低电压穿越表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author guofeihu
|
||||
* @since 2024-08-14
|
||||
*/
|
||||
@Api(tags = "新能源场站高低电压穿越表管理")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/newStation")
|
||||
@RequiredArgsConstructor
|
||||
public class NewStationController extends BaseController {
|
||||
|
||||
private final INewStationService iNewStationService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.QUERY)
|
||||
@PostMapping("/queryPage")
|
||||
@ApiOperation("新能源场站高低电压穿越表分页查询")
|
||||
public HttpResult<Page<NewStation>> queryPage(@RequestBody @Validated NewStationQueryParam newStationQueryParam){
|
||||
String methodDescribe = getMethodDescribe("queryPage");
|
||||
Page<NewStation> page = iNewStationService.queryPage(newStationQueryParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
|
||||
@PostMapping("/editNewStation")
|
||||
@ApiOperation("新能源场站高低电压穿越信息更新")
|
||||
public HttpResult<Boolean> editNewStation(@RequestBody @Validated NewStationQueryParam.NewStationEdit newStationEdit) {
|
||||
String methodDescribe = getMethodDescribe("editNewStation");
|
||||
LogUtil.njcnDebug(log, "{},更新对象为:{}", methodDescribe, newStationEdit);
|
||||
iNewStationService.editNewStation(newStationEdit);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.DELETE)
|
||||
@DeleteMapping("/delNewStation")
|
||||
@ApiOperation("新能源场站高低电压穿越信息删除")
|
||||
public HttpResult<Boolean> delNewStation(@RequestParam(name = "ids") String ids) {
|
||||
String methodDescribe = getMethodDescribe("delNewStation");
|
||||
LogUtil.njcnDebug(log, "{},删除的Id的集合为:{}", methodDescribe, ids);
|
||||
iNewStationService.delNewStation(ids);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.njcn.device.pq.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.device.pq.pojo.param.NewStationQueryParam;
|
||||
import com.njcn.device.pq.pojo.po.NewStation;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 新能源场站高低电压穿越表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author guofeihu
|
||||
* @since 2024-08-14
|
||||
*/
|
||||
public interface NewStationMapper extends BaseMapper<NewStation> {
|
||||
|
||||
Page<NewStation> queryPage(IPage<NewStation> page, @Param("newStationQueryParam") NewStationQueryParam newStationQueryParam);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?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.pq.mapper.NewStationMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.njcn.device.pq.pojo.po.NewStation">
|
||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||
<result column="name" jdbcType="VARCHAR" property="name" />
|
||||
<result column="station_type" jdbcType="VARCHAR" property="stationType"/>
|
||||
<result column="scale" jdbcType="VARCHAR" property="scale" />
|
||||
<result column="rated_power" jdbcType="VARCHAR" property="ratedPower" />
|
||||
<result column="longitude" jdbcType="VARCHAR" property="longitude" />
|
||||
<result column="latitude" jdbcType="INTEGER" property="latitude" />
|
||||
<result column="state" jdbcType="INTEGER" property="state" />
|
||||
</resultMap>
|
||||
|
||||
<select id="queryPage" resultMap="BaseResultMap">
|
||||
select * from pq_new_station ns
|
||||
where ns.state = 1
|
||||
<if test="newStationQueryParam.name != null and newStationQueryParam.name !=''">
|
||||
and ns.name like concat('%',#{newStationQueryParam.name},'%')
|
||||
</if>
|
||||
<if test="newStationQueryParam.stationType != null and newStationQueryParam.stationType !=''">
|
||||
and ns.station_type = #{newStationQueryParam.stationType}
|
||||
</if>
|
||||
<if test="newStationQueryParam.scale != null and newStationQueryParam.scale !=''">
|
||||
and ns.scale = #{newStationQueryParam.scale}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.njcn.device.pq.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.device.pq.pojo.param.NewStationQueryParam;
|
||||
import com.njcn.device.pq.pojo.po.NewStation;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 新能源场站高低电压穿越表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author guofeihu
|
||||
* @since 2024-08-14
|
||||
*/
|
||||
public interface INewStationService extends IService<NewStation> {
|
||||
|
||||
/**
|
||||
* 新能源场站高低电压穿越表分页查询
|
||||
* @param newStationQueryParam
|
||||
* @return
|
||||
*/
|
||||
Page<NewStation> queryPage(NewStationQueryParam newStationQueryParam);
|
||||
|
||||
/***
|
||||
* 新能源场站高低电压穿越表更新
|
||||
* @param newStationEdit
|
||||
* @return Boolean
|
||||
*/
|
||||
Boolean editNewStation(NewStationQueryParam.NewStationEdit newStationEdit) ;
|
||||
|
||||
/***
|
||||
* 新能源场站高低电压穿越表删除
|
||||
* @author wr
|
||||
* @param ids
|
||||
* @return Boolean
|
||||
*/
|
||||
Boolean delNewStation(String ids);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.njcn.device.pq.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.device.pq.mapper.NewStationMapper;
|
||||
import com.njcn.device.pq.pojo.param.NewStationQueryParam;
|
||||
import com.njcn.device.pq.pojo.po.NewStation;
|
||||
import com.njcn.device.pq.service.INewStationService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 新能源场站高低电压穿越表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author guofeihu
|
||||
* @since 2024-08-14
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class NewStationServiceImpl extends ServiceImpl<NewStationMapper, NewStation> implements INewStationService {
|
||||
|
||||
@Override
|
||||
public Page<NewStation> queryPage(NewStationQueryParam newStationQueryParam) {
|
||||
Page<NewStation> returnpage = new Page<> (newStationQueryParam.getPageNum(),newStationQueryParam.getPageSize());
|
||||
returnpage = this.getBaseMapper().queryPage(returnpage,newStationQueryParam);
|
||||
return returnpage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean editNewStation(NewStationQueryParam.NewStationEdit newStationEdit) {
|
||||
NewStation newStation = new NewStation();
|
||||
BeanUtil.copyProperties(newStationEdit, newStation);
|
||||
newStation.setState(1);
|
||||
boolean result ;
|
||||
if(newStation.getId() != null){
|
||||
result = this.updateById(newStation);
|
||||
}else{
|
||||
newStation.setId(IdUtil.simpleUUID());
|
||||
result = this.save(newStation);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean delNewStation(String ids) {
|
||||
LambdaUpdateWrapper<NewStation> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
||||
lambdaUpdateWrapper.set(NewStation::getState,0)
|
||||
.in(NewStation::getId, Arrays.asList(ids.split(",")));
|
||||
boolean update = this.update(lambdaUpdateWrapper);
|
||||
return update;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user