feat: 增加区域,主设备的相关接口
parent
f2eae6c235
commit
d9f50ce115
@ -0,0 +1,72 @@
|
|||||||
|
package com.xydl.cac.controller;
|
||||||
|
|
||||||
|
import com.xydl.cac.entity.Jg;
|
||||||
|
import com.xydl.cac.model.Response;
|
||||||
|
import com.xydl.cac.service.JgService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Api(tags = {"区域间隔相关接口"})
|
||||||
|
@RequestMapping("area")
|
||||||
|
@Slf4j
|
||||||
|
public class JgController extends BasicController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
JgService service;
|
||||||
|
|
||||||
|
@GetMapping("listAll")
|
||||||
|
@ApiOperation("查询列表")
|
||||||
|
public Response<List<Jg>> listAll(Integer bdzid) {
|
||||||
|
try {
|
||||||
|
List<Jg> result = service.listAll(bdzid);
|
||||||
|
return Response.success(result);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return Response.fail(ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("add")
|
||||||
|
@ApiOperation("新增")
|
||||||
|
public Response<Jg> add(@Validated @RequestBody Jg item) {
|
||||||
|
try {
|
||||||
|
Jg result = service.add(item);
|
||||||
|
return Response.success(result);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return Response.fail(ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("update")
|
||||||
|
@ApiOperation("更新")
|
||||||
|
public Response<String> update(@Validated @RequestBody Jg item) {
|
||||||
|
try {
|
||||||
|
if (item.getId() == null) {
|
||||||
|
throw new Exception("ID不能为空!");
|
||||||
|
}
|
||||||
|
service.update(item);
|
||||||
|
return Response.success("OK");
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return Response.fail(ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("delete")
|
||||||
|
@ApiOperation("删除")
|
||||||
|
public Response<String> delete(@Validated @NotNull(message = "ID不能为空!") Integer id) {
|
||||||
|
try {
|
||||||
|
service.delete(id);
|
||||||
|
return Response.success("OK");
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return Response.fail(ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
package com.xydl.cac.controller;
|
||||||
|
|
||||||
|
import com.xydl.cac.entity.Zsb;
|
||||||
|
import com.xydl.cac.model.Response;
|
||||||
|
import com.xydl.cac.service.ZsbService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Api(tags = {"主设备相关接口"})
|
||||||
|
@RequestMapping("zsb")
|
||||||
|
@Slf4j
|
||||||
|
public class ZsbController extends BasicController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
ZsbService service;
|
||||||
|
|
||||||
|
@GetMapping("listAll")
|
||||||
|
@ApiOperation("查询全部列表")
|
||||||
|
public Response<List<Zsb>> listAll(Integer jgid) {
|
||||||
|
try {
|
||||||
|
List<Zsb> result = service.listAll(jgid);
|
||||||
|
return Response.success(result);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return Response.fail(ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("add")
|
||||||
|
@ApiOperation("新增")
|
||||||
|
public Response<Zsb> add(@Validated @RequestBody Zsb item) {
|
||||||
|
try {
|
||||||
|
Zsb result = service.add(item);
|
||||||
|
return Response.success(result);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return Response.fail(ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("update")
|
||||||
|
@ApiOperation("更新")
|
||||||
|
public Response<String> update(@Validated @RequestBody Zsb item) {
|
||||||
|
try {
|
||||||
|
if (item.getId() == null) {
|
||||||
|
throw new Exception("ID不能为空!");
|
||||||
|
}
|
||||||
|
service.update(item);
|
||||||
|
return Response.success("OK");
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return Response.fail(ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("delete")
|
||||||
|
@ApiOperation("删除")
|
||||||
|
public Response<String> delete(@Validated @NotNull(message = "ID不能为空!") Integer id) {
|
||||||
|
try {
|
||||||
|
service.delete(id);
|
||||||
|
return Response.success("OK");
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return Response.fail(ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
package com.xydl.cac.entity;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Entity
|
||||||
|
@Table(name = "jg")
|
||||||
|
@ApiModel("区域间隔表")
|
||||||
|
public class Jg {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Column(name = "id")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@NotEmpty(message = "名称不能为空")
|
||||||
|
@Column(name = "mc")
|
||||||
|
private String mc;
|
||||||
|
|
||||||
|
@NotNull(message = "变电站id不能为空")
|
||||||
|
@Column(name = "bdzid")
|
||||||
|
private Integer bdzid;
|
||||||
|
|
||||||
|
@Column(name = "ls")
|
||||||
|
private BigDecimal ls;
|
||||||
|
|
||||||
|
@Column(name = "areaid")
|
||||||
|
private String areaid;
|
||||||
|
|
||||||
|
@Column(name = "xh")
|
||||||
|
private BigDecimal xh;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,201 @@
|
|||||||
|
package com.xydl.cac.entity;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Entity
|
||||||
|
@Table(name = "zsb")
|
||||||
|
@ApiModel("主设备表")
|
||||||
|
public class Zsb {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Column(name = "id")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@NotEmpty(message = "名称不能为空")
|
||||||
|
@Column(name = "mc")
|
||||||
|
private String mc;
|
||||||
|
|
||||||
|
@NotNull(message = "区域id不能为空")
|
||||||
|
@Column(name = "jgid")
|
||||||
|
private Integer jgid;
|
||||||
|
|
||||||
|
@Column(name = "lxid")
|
||||||
|
private Integer lxid;
|
||||||
|
|
||||||
|
@Column(name = "deviceip")
|
||||||
|
private String deviceip;
|
||||||
|
|
||||||
|
@Column(name = "deviceport")
|
||||||
|
private String deviceport;
|
||||||
|
|
||||||
|
@Column(name = "deviceusername")
|
||||||
|
private String deviceusername;
|
||||||
|
|
||||||
|
@Column(name = "devicepasswd")
|
||||||
|
private String devicepasswd;
|
||||||
|
|
||||||
|
@Column(name = "bdzid")
|
||||||
|
private Integer bdzid;
|
||||||
|
|
||||||
|
@Column(name = "address")
|
||||||
|
private BigDecimal address;
|
||||||
|
|
||||||
|
@Column(name = "frequency")
|
||||||
|
private BigDecimal frequency;
|
||||||
|
|
||||||
|
@Column(name = "portname")
|
||||||
|
private String portname;
|
||||||
|
|
||||||
|
@Column(name = "venderid")
|
||||||
|
private String venderid;
|
||||||
|
|
||||||
|
@Column(name = "transcount")
|
||||||
|
private BigDecimal transcount;
|
||||||
|
|
||||||
|
@Column(name = "vendercode")
|
||||||
|
private String vendercode;
|
||||||
|
|
||||||
|
@Column(name = "xh")
|
||||||
|
private BigDecimal xh;
|
||||||
|
|
||||||
|
@Column(name = "enable")
|
||||||
|
private BigDecimal enable;
|
||||||
|
|
||||||
|
@Column(name = "sbbm")
|
||||||
|
private String sbbm;
|
||||||
|
|
||||||
|
@Column(name = "yxbh")
|
||||||
|
private String yxbh;
|
||||||
|
|
||||||
|
@Column(name = "zcxz")
|
||||||
|
private String zcxz;
|
||||||
|
|
||||||
|
@Column(name = "zcdw")
|
||||||
|
private String zcdw;
|
||||||
|
|
||||||
|
@Column(name = "xs")
|
||||||
|
private String xs;
|
||||||
|
|
||||||
|
@Column(name = "jb")
|
||||||
|
private String jb;
|
||||||
|
|
||||||
|
@Column(name = "xb")
|
||||||
|
private String xb;
|
||||||
|
|
||||||
|
@Column(name = "eddy")
|
||||||
|
private String eddy;
|
||||||
|
|
||||||
|
@Column(name = "eddl")
|
||||||
|
private String eddl;
|
||||||
|
|
||||||
|
@Column(name = "edpl")
|
||||||
|
private String edpl;
|
||||||
|
|
||||||
|
@Column(name = "edxh")
|
||||||
|
private String edxh;
|
||||||
|
|
||||||
|
@Column(name = "sccj")
|
||||||
|
private String sccj;
|
||||||
|
|
||||||
|
@Column(name = "ccbh")
|
||||||
|
private String ccbh;
|
||||||
|
|
||||||
|
@Column(name = "ccdh")
|
||||||
|
private String ccdh;
|
||||||
|
|
||||||
|
@Column(name = "zzgj")
|
||||||
|
private String zzgj;
|
||||||
|
|
||||||
|
@Column(name = "ccrq")
|
||||||
|
private String ccrq;
|
||||||
|
|
||||||
|
@Column(name = "tcrq")
|
||||||
|
private String tcrq;
|
||||||
|
|
||||||
|
@Column(name = "syhj")
|
||||||
|
private String syhj;
|
||||||
|
|
||||||
|
@Column(name = "fwdj")
|
||||||
|
private String fwdj;
|
||||||
|
|
||||||
|
@Column(name = "zcbh")
|
||||||
|
private String zcbh;
|
||||||
|
|
||||||
|
@Column(name = "yt")
|
||||||
|
private BigDecimal yt;
|
||||||
|
|
||||||
|
@Column(name = "whbz")
|
||||||
|
private String whbz;
|
||||||
|
|
||||||
|
@Column(name = "sbzr")
|
||||||
|
private String sbzr;
|
||||||
|
|
||||||
|
@Column(name = "ywdw")
|
||||||
|
private String ywdw;
|
||||||
|
|
||||||
|
@Column(name = "gcbh")
|
||||||
|
private String gcbh;
|
||||||
|
|
||||||
|
@Column(name = "gcmc")
|
||||||
|
private String gcmc;
|
||||||
|
|
||||||
|
@Column(name = "sbid")
|
||||||
|
private String sbid;
|
||||||
|
|
||||||
|
@Column(name = "zxmc")
|
||||||
|
private String zxmc;
|
||||||
|
|
||||||
|
@Column(name = "sbcz")
|
||||||
|
private String sbcz;
|
||||||
|
|
||||||
|
@Column(name = "zyfl")
|
||||||
|
private String zyfl;
|
||||||
|
|
||||||
|
@Column(name = "pmbm")
|
||||||
|
private String pmbm;
|
||||||
|
|
||||||
|
@Column(name = "gnwz")
|
||||||
|
private String gnwz;
|
||||||
|
|
||||||
|
@Column(name = "sblxbm")
|
||||||
|
private String sblxbm;
|
||||||
|
|
||||||
|
@Column(name = "zfid")
|
||||||
|
private String zfid;
|
||||||
|
|
||||||
|
@Column(name = "zjtyrq")
|
||||||
|
private String zjtyrq;
|
||||||
|
|
||||||
|
@Column(name = "sbzjfs")
|
||||||
|
private String sbzjfs;
|
||||||
|
|
||||||
|
@Column(name = "zcyjqcid")
|
||||||
|
private String zcyjqcid;
|
||||||
|
|
||||||
|
@Column(name = "dqmpyxkid")
|
||||||
|
private String dqmpyxkid;
|
||||||
|
|
||||||
|
@Column(name = "ssdzdydj")
|
||||||
|
private String ssdzdydj;
|
||||||
|
|
||||||
|
@Column(name = "djsj")
|
||||||
|
private String djsj;
|
||||||
|
|
||||||
|
@Column(name = "sssj")
|
||||||
|
private String sssj;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package com.xydl.cac.exception;
|
||||||
|
|
||||||
|
import com.xydl.cac.model.Response;
|
||||||
|
import org.springframework.validation.FieldError;
|
||||||
|
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||||
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||||
|
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@RestControllerAdvice
|
||||||
|
public class GlobalExceptionHandler {
|
||||||
|
|
||||||
|
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||||
|
public Response<String> handleValidationExceptions(MethodArgumentNotValidException ex) {
|
||||||
|
String message = ex.getBindingResult().getFieldErrors().stream()
|
||||||
|
.map(FieldError::getDefaultMessage)
|
||||||
|
.collect(Collectors.joining(","));
|
||||||
|
return Response.fail(message);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.xydl.cac.repository;
|
||||||
|
|
||||||
|
import com.xydl.cac.entity.Jg;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface JgRepository extends JpaRepository<Jg, Integer>, JpaSpecificationExecutor<Jg> {
|
||||||
|
List<Jg> findByBdzid(Integer bdzId);
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.xydl.cac.repository;
|
||||||
|
|
||||||
|
import com.xydl.cac.entity.Zsb;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface ZsbRepository extends JpaRepository<Zsb, Integer>, JpaSpecificationExecutor<Zsb> {
|
||||||
|
List<Zsb> findByJgid(Integer jgid);
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.xydl.cac.service;
|
||||||
|
|
||||||
|
import com.xydl.cac.entity.Jg;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface JgService {
|
||||||
|
|
||||||
|
List<Jg> listAll(Integer bdzid);
|
||||||
|
|
||||||
|
Jg add(Jg item);
|
||||||
|
|
||||||
|
void update(Jg item);
|
||||||
|
|
||||||
|
void delete(Integer id);
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.xydl.cac.service;
|
||||||
|
|
||||||
|
import com.xydl.cac.entity.Zsb;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface ZsbService {
|
||||||
|
|
||||||
|
List<Zsb> listAll(Integer jgid);
|
||||||
|
|
||||||
|
Zsb add(Zsb item);
|
||||||
|
|
||||||
|
void update(Zsb item);
|
||||||
|
|
||||||
|
void delete(Integer id);
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
package com.xydl.cac.service.impl;
|
||||||
|
|
||||||
|
import com.xydl.cac.entity.Jg;
|
||||||
|
import com.xydl.cac.repository.JgRepository;
|
||||||
|
import com.xydl.cac.service.JgService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public class JgServiceImpl implements JgService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
JgRepository repository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Jg> listAll(Integer bdzid) {
|
||||||
|
if (bdzid == null) {
|
||||||
|
return repository.findAll();
|
||||||
|
} else {
|
||||||
|
return repository.findByBdzid(bdzid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Jg add(Jg item) {
|
||||||
|
item.setId(null);
|
||||||
|
return repository.save(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Jg item) {
|
||||||
|
repository.save(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(Integer id) {
|
||||||
|
repository.deleteById(id);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
package com.xydl.cac.service.impl;
|
||||||
|
|
||||||
|
import com.xydl.cac.entity.Zsb;
|
||||||
|
import com.xydl.cac.repository.ZsbRepository;
|
||||||
|
import com.xydl.cac.service.ZsbService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public class ZsbServiceImpl implements ZsbService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
ZsbRepository repository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Zsb> listAll(Integer jgid) {
|
||||||
|
if (jgid == null) {
|
||||||
|
return repository.findAll();
|
||||||
|
} else {
|
||||||
|
return repository.findByJgid(jgid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Zsb add(Zsb item) {
|
||||||
|
item.setId(null);
|
||||||
|
return repository.save(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Zsb item) {
|
||||||
|
repository.save(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(Integer id) {
|
||||||
|
repository.deleteById(id);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue