liuguijing 1 year ago
commit 4b84f77cf4

@ -25,48 +25,32 @@ public class BdzController extends BasicController {
@GetMapping("listAll")
@ApiOperation("查询全部列表")
public Response<List<Bdz>> listAll() {
try {
List<Bdz> result = service.listAll();
return Response.success(result);
} catch (Exception ex) {
return Response.fail(ex.getMessage());
}
}
@PostMapping("add")
@ApiOperation("新增")
public Response<Bdz> add(@Validated @RequestBody Bdz item) {
try {
public Response<Bdz> add(@Validated @RequestBody Bdz item) throws Exception {
Bdz 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 Bdz item) {
try {
public Response<String> update(@Validated @RequestBody Bdz item) throws Exception {
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 {
public Response<String> delete(@Validated @NotNull(message = "ID不能为空!") Integer id) throws Exception {
service.delete(id);
return Response.success("OK");
} catch (Exception ex) {
return Response.fail(ex.getMessage());
}
}
}

@ -1,6 +1,8 @@
package com.xydl.cac.controller;
import com.xydl.cac.entity.IcdFileConfig;
import com.xydl.cac.entity.IcdConfigType;
import com.xydl.cac.entity.IcdConfigTypeAtt;
import com.xydl.cac.model.ColumnModel;
import com.xydl.cac.model.Response;
import com.xydl.cac.service.DataService;
import com.xydl.cac.service.IcdFileConfigService;
@ -42,68 +44,51 @@ public class IcdConfigController extends BasicController {
@GetMapping("list")
@ApiOperation("查询全部类型列表")
public Response<List<IcdFileConfig>> list(String iedName) {
try {
List<IcdFileConfig> result = configService.list(iedName);
public Response<List<IcdConfigType>> list(String iedName) throws Exception {
List<IcdConfigType> result = configService.list(iedName);
return Response.success(result);
} catch (Exception ex) {
return Response.fail(ex.getMessage());
}
}
@GetMapping("iedList")
@ApiOperation("查询IED列表")
public Response<List<String>> iedList() {
try {
List<String> result = configService.iedList();
return Response.success(result);
} catch (Exception ex) {
return Response.fail(ex.getMessage());
}
}
@PostMapping("update")
@ApiOperation("更新ICD类型配置")
public Response<String> update(@RequestBody IcdFileConfig item) {
try {
public Response<String> update(@RequestBody IcdConfigType item) throws Exception {
configService.update(item);
return Response.success("OK");
} catch (Exception ex) {
return Response.fail(ex.getMessage());
}
@PostMapping("updateAtt")
@ApiOperation("更新ICD类型属性配置")
public Response<String> updateAtt(@RequestBody IcdConfigTypeAtt item) throws Exception {
configService.updateAtt(item);
return Response.success("OK");
}
@PostMapping("delete")
@ApiOperation("删除ICD类型配置")
public Response<String> delete(@Validated @NotNull(message = "ID不能为空!") Integer id) {
try {
configService.delete(id);
return Response.success("OK");
} catch (Exception ex) {
return Response.fail(ex.getMessage());
}
}
@GetMapping("tableList")
@ApiOperation("查询data表名")
public Response<List<String>> tableList() {
try {
public Response<List<String>> tableList() throws Exception {
List<String> result = dataService.getDataTables();
return Response.success(result);
} catch (Exception ex) {
return Response.fail(ex.getMessage());
}
}
@GetMapping("colList")
@ApiOperation("查询data表字段名")
public Response<List<String>> colList(String tableName) {
try {
List<String> result = dataService.getDataTableColumns(tableName);
public Response<List<ColumnModel>> colList(String tableName) throws Exception {
List<ColumnModel> result = dataService.getDataTableColumns(tableName);
return Response.success(result);
} catch (Exception ex) {
return Response.fail(ex.getMessage());
}
}
}

@ -25,48 +25,32 @@ public class JgController extends BasicController {
@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 {
public Response<Jg> add(@Validated @RequestBody Jg item) throws Exception {
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 {
public Response<String> update(@Validated @RequestBody Jg item) throws Exception {
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 {
public Response<String> delete(@Validated @NotNull(message = "ID不能为空!") Integer id) throws Exception {
service.delete(id);
return Response.success("OK");
} catch (Exception ex) {
return Response.fail(ex.getMessage());
}
}
}

@ -25,48 +25,32 @@ public class LxController extends BasicController {
@GetMapping("listAll")
@ApiOperation("查询全部列表")
public Response<List<Lx>> listAll() {
try {
List<Lx> result = service.listAll();
return Response.success(result);
} catch (Exception ex) {
return Response.fail(ex.getMessage());
}
}
@PostMapping("add")
@ApiOperation("新增")
public Response<Lx> add(@Validated @RequestBody Lx item) {
try {
public Response<Lx> add(@Validated @RequestBody Lx item) throws Exception {
Lx 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 Lx item) {
try {
public Response<String> update(@Validated @RequestBody Lx item) throws Exception {
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());
}
}
}

@ -28,59 +28,39 @@ public class ModevController extends BasicController {
@GetMapping("listAll")
@ApiOperation("查询列表")
public Response<List<Modev>> listAll(@NotNull(message = "主设备编号不能缺少") @Param("zsbid") Integer zsbid) {
try {
List<Modev> result = service.listAll(zsbid);
return Response.success(result);
} catch (Exception ex) {
return Response.fail(ex.getMessage());
}
}
@PostMapping("add")
@ApiOperation("新增")
public Response<Modev> add(@Validated @RequestBody Modev item) {
try {
public Response<Modev> add(@Validated @RequestBody Modev item) throws Exception {
Modev 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 Modev item) {
try {
public Response<String> update(@Validated @RequestBody Modev item) throws Exception {
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不能为空!") @Param("id") Integer id) {
try {
service.delete(id);
return Response.success("OK");
} catch (Exception ex) {
return Response.fail(ex.getMessage());
}
}
@PostMapping("detail")
@ApiOperation("详情")
public Response<Modev> detail(@Validated @NotNull(message = "ID不能为空!") Integer id) {
try {
public Response<Modev> detail(@Validated @NotNull(message = "ID不能为空!") Integer id) throws Exception {
Modev detail = service.detail(id);
return Response.success(detail);
} catch (Exception ex) {
return Response.fail(ex.getMessage());
}
}
@PostMapping("bindicd")

@ -25,59 +25,39 @@ public class ModevTypeController extends BasicController {
@GetMapping("listAll")
@ApiOperation("查询列表")
public Response<List<ModevType>> listAll() {
try {
List<ModevType> result = service.listAll();
return Response.success(result);
} catch (Exception ex) {
return Response.fail(ex.getMessage());
}
}
@PostMapping("add")
@ApiOperation("新增")
public Response<ModevType> add(@Validated @RequestBody ModevType item) {
try {
public Response<ModevType> add(@Validated @RequestBody ModevType item) throws Exception {
ModevType 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 ModevType item) {
try {
public Response<String> update(@Validated @RequestBody ModevType item) throws Exception {
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());
}
}
@PostMapping("detail")
@ApiOperation("详情")
public Response<ModevType> detail(@Validated @NotNull(message = "ID不能为空!") Integer id) {
try {
public Response<ModevType> detail(@Validated @NotNull(message = "ID不能为空!") Integer id) throws Exception {
ModevType detail = service.detail(id);
return Response.success(detail);
} catch (Exception ex) {
return Response.fail(ex.getMessage());
}
}
}

@ -40,57 +40,38 @@ public class NiecSensorController extends BasicController {
@ApiParam("每页数量") @RequestParam(value = "pageSize", required = false) Integer pageSize) {
pageNum = this.initPageNum(pageNum);
pageSize = this.initPageSize(pageSize);
try {
Page<NiecSensor> result = service.list(pageNum, pageSize);
return Response.success(result);
} catch (Exception ex) {
return Response.fail(ex.getMessage());
}
}
@GetMapping("listAll")
@ApiOperation("查询全部列表")
public Response<List<NiecSensor>> listAll() {
try {
List<NiecSensor> result = service.listAll();
return Response.success(result);
} catch (Exception ex) {
return Response.fail(ex.getMessage());
}
}
@GetMapping("getTree")
@ApiOperation("查询树")
public Response<List<NiecSensor>> getTree() {
try {
List<NiecSensor> result = service.getTree();
return Response.success(result);
} catch (Exception ex) {
log.error("getTree Exception.", ex);
return Response.fail(ex.getMessage());
}
}
@GetMapping("detail")
@ApiOperation("查询单个装置采集到的数据")
public Response<SensorDetail> getDetail(@Validated ConditionModel model) {
try {
public Response<SensorDetail> getDetail(@Validated ConditionModel model) throws Exception {
if (model.getPageNum() != null || model.getPageSize() != null) {
model.setPageNum(this.initPageNum(model.getPageNum()));
model.setPageSize(this.initPageSize(model.getPageSize()));
}
SensorDetail result = service.getDetail(model);
return Response.success(result);
} catch (Exception ex) {
log.error("getDetail Exception.", ex);
return Response.fail(ex.getMessage());
}
}
@GetMapping("export")
@ApiOperation("导出单个装置采集到的数据")
public void export(@Validated ConditionModel model, HttpServletResponse response) {
try {
public void export(@Validated ConditionModel model, HttpServletResponse response) throws Exception {
if (model.getPageNum() != null || model.getPageSize() != null) {
model.setPageNum(this.initPageNum(model.getPageNum()));
model.setPageSize(this.initPageSize(model.getPageSize()));
@ -101,9 +82,6 @@ public class NiecSensorController extends BasicController {
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
reportService.exportSensor(detail, response.getOutputStream());
} catch (Exception ex) {
log.error("exportDetail Exception.", ex);
}
}
}

@ -1,14 +1,20 @@
package com.xydl.cac.controller;
import com.xydl.cac.entity.Bdz;
import com.xydl.cac.entity.IcdConfigTypeInst;
import com.xydl.cac.entity.Rptparamindex;
import com.xydl.cac.model.BindingModel;
import com.xydl.cac.model.Response;
import com.xydl.cac.service.ParamBindService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.repository.query.Param;
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
@ -27,4 +33,18 @@ public class ParamBindController extends BasicController {
return Response.success(result);
}
@GetMapping("instList")
@ApiOperation("查询逻辑设备实例列表")
public Response<List<IcdConfigTypeInst>> instList(@Validated @NotNull(message = "iedName不能为空!") @Param("iedName") String iedName) throws Exception {
List<IcdConfigTypeInst> result = bindService.instList(iedName);
return Response.success(result);
}
@PostMapping("preview")
@ApiOperation("预览")
public Response<List<Rptparamindex>> preview(@Validated @RequestBody BindingModel item) throws Exception {
List<Rptparamindex> result = bindService.preview(item);
return Response.success(result);
}
}

@ -24,49 +24,33 @@ public class ZsbController extends BasicController {
@GetMapping("listAll")
@ApiOperation("查询全部列表")
public Response<List<Zsb>> listAll(Integer jgid) {
try {
public Response<List<Zsb>> listAll(Integer jgid) throws Exception {
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 {
public Response<Zsb> add(@Validated @RequestBody Zsb item) throws Exception {
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 {
public Response<String> update(@Validated @RequestBody Zsb item) throws Exception {
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 {
public Response<String> delete(@Validated @NotNull(message = "ID不能为空!") Integer id) throws Exception {
service.delete(id);
return Response.success("OK");
} catch (Exception ex) {
return Response.fail(ex.getMessage());
}
}
}

@ -0,0 +1,74 @@
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 java.util.LinkedHashMap;
import java.util.List;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "icd_config_type")
@ApiModel("ICD配置类型表")
public class IcdConfigType {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Integer id;
@Column(name = "ied_name")
private String iedName;
@Column(name = "ldevice_inst")
private String ldeviceInst;
@Column(name = "ln_class")
private String lnClass;
@Column(name = "table_name")
private String tableName;
@Transient
private LinkedHashMap<String, IcdConfigTypeAtt> attMap;
@Transient
private List<IcdConfigTypeAtt> attList;
@Transient
private LinkedHashMap<String, IcdConfigTypeInst> instMap;
@Transient
private List<IcdConfigTypeInst> instList;
public void addAtt(String doName, String lastname) {
if (attMap == null) {
attMap = new LinkedHashMap<>();
}
if (!attMap.containsKey(doName)) {
IcdConfigTypeAtt item = IcdConfigTypeAtt.builder()
.doName(doName)
.lastName(lastname)
.build();
attMap.put(doName, item);
}
}
public void addInst(String inst) {
if (instMap == null) {
instMap = new LinkedHashMap<>();
}
if (!instMap.containsKey(inst)) {
IcdConfigTypeInst item = IcdConfigTypeInst.builder()
.inst(inst)
.build();
instMap.put(inst, item);
}
}
}

@ -0,0 +1,39 @@
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 java.util.ArrayList;
import java.util.List;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "icd_config_type_att")
@ApiModel("ICD配置类型属性表")
public class IcdConfigTypeAtt {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Integer id;
@Column(name = "icd_config_type_id")
private Integer icdConfigTypeId;
@Column(name = "do_name")
private String doName;
@Column(name = "last_name")
private String lastName;
@Column(name = "col_name")
private String colName;
}

@ -13,22 +13,22 @@ import javax.persistence.*;
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "icd_file_config_inst")
@ApiModel("ICD文件实例表")
public class IcdFileConfigInst {
@Table(name = "icd_config_type_inst")
@ApiModel("ICD配置类型实例表")
public class IcdConfigTypeInst {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Integer id;
@Column(name = "config_id")
private Integer configId;
@Column(name = "icd_config_type_id")
private Integer icdConfigTypeId;
@Column(name = "inst")
private String inst;
@Column(name = "paramindex")
private String paramindex;
@Transient
private String paramIndex;
}

@ -1,66 +0,0 @@
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 java.util.ArrayList;
import java.util.List;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "icd_file_config")
@ApiModel("ICD文件配置表")
public class IcdFileConfig {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Integer id;
@Column(name = "ied_name")
private String iedName;
@Column(name = "ldevice_inst")
private String ldeviceInst;
@Column(name = "ln_class")
private String lnClass;
@Column(name = "do_name")
private String doName;
@Column(name = "last_name")
private String lastName;
@Column(name = "table_name")
private String tableName;
@Column(name = "col_name")
private String colName;
@Transient
private List<IcdFileConfigInst> instList;
public void addInst(String inst, String paramindex) {
if (instList == null) {
instList = new ArrayList<>();
}
IcdFileConfigInst item = IcdFileConfigInst.builder()
.inst(inst)
.paramindex(paramindex)
.build();
instList.add(item);
}
public String buildParamIndex(IcdFileConfigInst inst) {
String param = iedName + ldeviceInst + "/" + lnClass + inst.getInst() + "$" + inst.getParamindex();
return param;
}
}

@ -0,0 +1,46 @@
package com.xydl.cac.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "rptparamindex")
@ApiModel("绑定关系表")
public class Rptparamindex {
@Id
@ApiModelProperty("61850对象参引")
@Column(name = "paramindex")
private String paramindex;
@ApiModelProperty("61850对象id")
@Column(name = "objid")
private Integer objid;
@ApiModelProperty("监测设备id")
@Column(name = "eqmid")
private Integer eqmid;
@Column(name = "tablename")
private String tablename;
@Column(name = "colname")
private String colname;
@Column(name = "phase")
private String phase;
}

@ -1,6 +1,7 @@
package com.xydl.cac.exception;
import com.xydl.cac.model.Response;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
@ -9,6 +10,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
import java.util.stream.Collectors;
@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {
@ExceptionHandler(MethodArgumentNotValidException.class)
@ -21,6 +23,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler(Exception.class)
public Response<String> handleException(Exception ex) {
log.error("", ex);
String message = ex.getMessage();
return Response.fail(message);
}

@ -0,0 +1,16 @@
package com.xydl.cac.model;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
@Data
public class BindingModel {
@NotNull(message = "eqmid不能为空")
@ApiModelProperty("eqmid")
Integer eqmid;
@NotNull(message = "逻辑设备实例的Id不能为空")
@ApiModelProperty("逻辑设备实例的Id")
Integer bindingId;
}

@ -0,0 +1,9 @@
package com.xydl.cac.model;
import lombok.Data;
@Data
public class ColumnModel {
private String name;
private String comment;
}

@ -0,0 +1,17 @@
package com.xydl.cac.repository;
import com.xydl.cac.entity.IcdConfigTypeAtt;
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 IcdConfigTypeAttRepository extends JpaRepository<IcdConfigTypeAtt, Integer>, JpaSpecificationExecutor<IcdConfigTypeAtt> {
List<IcdConfigTypeAtt> findByIcdConfigTypeId(Integer icdConfigTypeId);
void deleteByIcdConfigTypeId(Integer icdConfigTypeId);
}

@ -0,0 +1,17 @@
package com.xydl.cac.repository;
import com.xydl.cac.entity.IcdConfigTypeInst;
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 IcdConfigTypeInstRepository extends JpaRepository<IcdConfigTypeInst, Integer>, JpaSpecificationExecutor<IcdConfigTypeInst> {
List<IcdConfigTypeInst> findByIcdConfigTypeId(Integer icdConfigTypeId);
void deleteByIcdConfigTypeId(Integer icdConfigTypeId);
}

@ -0,0 +1,18 @@
package com.xydl.cac.repository;
import com.xydl.cac.entity.IcdConfigType;
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 IcdConfigTypeRepository extends JpaRepository<IcdConfigType, Integer>, JpaSpecificationExecutor<IcdConfigType> {
List<IcdConfigType> findByIedName(String iedName);
List<IcdConfigType> findByIedNameAndLdeviceInstAndLnClass(String iedName, String ldeviceInst, String lnClass);
}

@ -1,18 +0,0 @@
package com.xydl.cac.repository;
import com.xydl.cac.entity.IcdFileConfigInst;
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 IcdFileConfigInstRepository extends JpaRepository<IcdFileConfigInst, Integer>, JpaSpecificationExecutor<IcdFileConfigInst> {
List<IcdFileConfigInst> findByConfigId(Integer configId);
void deleteByConfigId(Integer configId);
}

@ -1,17 +0,0 @@
package com.xydl.cac.repository;
import com.xydl.cac.entity.IcdFileConfig;
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 IcdFileConfigRepository extends JpaRepository<IcdFileConfig, Integer>, JpaSpecificationExecutor<IcdFileConfig> {
List<IcdFileConfig> findByIedName(String iedName);
List<IcdFileConfig> findByIedNameAndLdeviceInstAndLnClassAndDoName(String iedName, String ldeviceInst, String lnClass, String doName);
}

@ -5,8 +5,13 @@ 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 LxRepository extends JpaRepository<Lx, Integer>, JpaSpecificationExecutor<Lx> {
List<Lx> findByMc(String mc);
List<Lx> findByMcAndIdIsNot(String mc, Integer id);
}

@ -0,0 +1,12 @@
package com.xydl.cac.repository;
import com.xydl.cac.entity.Rptparamindex;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;
@Repository
public interface RptparamindexRepository extends JpaRepository<Rptparamindex, String>, JpaSpecificationExecutor<Rptparamindex> {
}

@ -11,7 +11,7 @@ public interface DataService {
List<String> getDataTables() throws Exception;
List<String> getDataTableColumns(String tableName) throws Exception;
List<ColumnModel> getDataTableColumns(String tableName) throws Exception;
OnePage<Map<String, Object>> getDate(NiecSensor sensor, List<NiecPoint> points, ConditionModel model);
}

@ -1,6 +1,7 @@
package com.xydl.cac.service;
import com.xydl.cac.entity.IcdFileConfig;
import com.xydl.cac.entity.IcdConfigType;
import com.xydl.cac.entity.IcdConfigTypeAtt;
import java.util.List;
@ -10,9 +11,11 @@ public interface IcdFileConfigService {
List<String> iedList();
List<IcdFileConfig> list(String iedName) throws Exception;
List<IcdConfigType> list(String iedName) throws Exception;
void update(IcdFileConfig item);
void update(IcdConfigType item) throws Exception;
void updateAtt(IcdConfigTypeAtt item) throws Exception;
void delete(Integer id);
}

@ -8,9 +8,9 @@ public interface LxService {
List<Lx> listAll();
Lx add(Lx item);
Lx add(Lx item) throws Exception;
void update(Lx item);
void update(Lx item) throws Exception;
void delete(Integer id);
}

@ -1,10 +1,17 @@
package com.xydl.cac.service;
import com.xydl.cac.entity.Bdz;
import com.xydl.cac.entity.IcdConfigTypeInst;
import com.xydl.cac.entity.Rptparamindex;
import com.xydl.cac.model.BindingModel;
import java.util.List;
public interface ParamBindService {
List<Bdz> getTree() throws Exception;
List<IcdConfigTypeInst> instList(String iedName);
List<Rptparamindex> preview(BindingModel item) throws Exception;
}

@ -2,12 +2,14 @@ package com.xydl.cac.service.impl;
import com.xydl.cac.entity.NiecPoint;
import com.xydl.cac.entity.NiecSensor;
import com.xydl.cac.model.ColumnModel;
import com.xydl.cac.model.ConditionModel;
import com.xydl.cac.model.OnePage;
import com.xydl.cac.service.DataService;
import com.xydl.cac.util.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -22,6 +24,8 @@ import java.util.Map;
@Transactional(rollbackFor = Exception.class)
public class DataServiceImpl implements DataService {
private String schema;
@Resource
private JdbcTemplate jdbcTemplate;
@ -39,19 +43,31 @@ public class DataServiceImpl implements DataService {
}
@Override
public List<String> getDataTableColumns(String tableName) throws Exception {
List<String> cols = new ArrayList<>();
String sql = "SELECT COLUMN_NAME FROM information_schema.columns WHERE TABLE_NAME='" + tableName + "'";
List<String> list = jdbcTemplate.queryForList(sql, String.class);
for (String col : list) {
public List<ColumnModel> getDataTableColumns(String tableName) throws Exception {
if (StringUtils.isBlank(schema)) {
this.getDatabase();
}
List<ColumnModel> result = new ArrayList<>();
String sql = "SELECT COLUMN_NAME name, COLUMN_COMMENT comment FROM information_schema.columns WHERE TABLE_NAME='"
+ tableName + "' AND TABLE_SCHEMA='" + schema + "'";
List<ColumnModel> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ColumnModel.class));
for (ColumnModel item : list) {
String col = item.getName();
if (!col.equals("id") && !col.equals("eqmid")
&& !col.equals("acquisitionTime") && !col.equals("d_time")
&& !col.equals("create_time") && !col.equals("update_time")
&& !col.equals("isupload")) {
cols.add(col);
result.add(item);
}
}
return cols;
return result;
}
private void getDatabase() {
String sql = "select database()";
List<String> list = jdbcTemplate.queryForList(sql, String.class);
schema = list.get(0);
}
@Override

@ -1,9 +1,7 @@
package com.xydl.cac.service.impl;
import com.xydl.cac.entity.IcdFileConfig;
import com.xydl.cac.entity.IcdFileConfigInst;
import com.xydl.cac.repository.IcdFileConfigInstRepository;
import com.xydl.cac.repository.IcdFileConfigRepository;
import com.xydl.cac.entity.*;
import com.xydl.cac.repository.*;
import com.xydl.cac.service.IcdFileConfigService;
import com.xydl.cac.util.IcdXmlUtil;
import lombok.extern.slf4j.Slf4j;
@ -17,6 +15,7 @@ import javax.annotation.Resource;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Optional;
@Service
@Slf4j
@ -24,60 +23,98 @@ import java.util.List;
public class IcdFileConfigServiceImpl implements IcdFileConfigService {
@Resource
IcdFileConfigRepository repository;
IcdConfigTypeRepository repository;
@Resource
IcdFileConfigInstRepository instRepository;
IcdConfigTypeAttRepository attRepository;
@Resource
IcdConfigTypeInstRepository instRepository;
@Resource
private JdbcTemplate jdbcTemplate;
@Override
public void upload(String xml) throws Exception {
LinkedHashMap<String, IcdFileConfig> result = IcdXmlUtil.loadIcdType(xml);
Collection<IcdFileConfig> configList = result.values();
for (IcdFileConfig config : configList) {
List<IcdFileConfig> list = repository.findByIedNameAndLdeviceInstAndLnClassAndDoName(
config.getIedName(), config.getLdeviceInst(), config.getLnClass(), config.getDoName());
LinkedHashMap<String, IcdConfigType> result = IcdXmlUtil.loadIcdType(xml);
Collection<IcdConfigType> configList = result.values();
for (IcdConfigType config : configList) {
List<IcdConfigType> list = repository.findByIedNameAndLdeviceInstAndLnClass(
config.getIedName(), config.getLdeviceInst(), config.getLnClass());
if (CollectionUtils.isEmpty(list)) {
repository.save(config);
List<IcdFileConfigInst> instList = config.getInstList();
for (IcdFileConfigInst item : instList) {
item.setConfigId(config.getId());
if (config.getAttMap() != null) {
Collection<IcdConfigTypeAtt> attList = config.getAttMap().values();
for (IcdConfigTypeAtt item : attList) {
item.setIcdConfigTypeId(config.getId());
}
attRepository.saveAll(attList);
}
if (config.getInstMap() != null) {
Collection<IcdConfigTypeInst> instList = config.getInstMap().values();
for (IcdConfigTypeInst item : instList) {
item.setIcdConfigTypeId(config.getId());
}
instRepository.saveAll(instList);
}
}
}
}
@Override
public List<String> iedList() {
String sql = "SELECT DISTINCT ied_name FROM icd_file_config";
String sql = "SELECT DISTINCT ied_name FROM icd_config_type";
List<String> list = jdbcTemplate.queryForList(sql, String.class);
return list;
}
@Override
public List<IcdFileConfig> list(String iedName) throws Exception {
List<IcdFileConfig> result;
public List<IcdConfigType> list(String iedName) throws Exception {
List<IcdConfigType> result;
if (StringUtils.isNotBlank(iedName)) {
result = repository.findByIedName(iedName);
} else {
result = repository.findAll();
}
for (IcdFileConfig item : result) {
List<IcdFileConfigInst> list = instRepository.findByConfigId(item.getId());
item.setInstList(list);
for (IcdConfigType item : result) {
List<IcdConfigTypeAtt> atts = attRepository.findByIcdConfigTypeId(item.getId());
item.setAttList(atts);
List<IcdConfigTypeInst> insts = instRepository.findByIcdConfigTypeId(item.getId());
item.setInstList(insts);
for (IcdConfigTypeInst inst : insts) {
String param = item.getIedName() + item.getLdeviceInst() + "/" + item.getLnClass()
+ inst.getInst();
inst.setParamIndex(param);
}
}
return result;
}
@Override
public void update(IcdFileConfig item) {
repository.save(item);
public void update(IcdConfigType item) throws Exception {
Optional<IcdConfigType> optional = repository.findById(item.getId());
if (!optional.isPresent()) {
throw new Exception("未找到该项");
}
IcdConfigType r = optional.get();
r.setTableName(item.getTableName());
repository.save(r);
}
@Override
public void updateAtt(IcdConfigTypeAtt item) throws Exception {
Optional<IcdConfigTypeAtt> optional = attRepository.findById(item.getId());
if (!optional.isPresent()) {
throw new Exception("未找到该项");
}
IcdConfigTypeAtt r = optional.get();
r.setColName(item.getColName());
attRepository.save(r);
}
@Override
public void delete(Integer id) {
instRepository.deleteByConfigId(id);
instRepository.deleteByIcdConfigTypeId(id);
attRepository.deleteByIcdConfigTypeId(id);
repository.deleteById(id);
}

@ -6,6 +6,7 @@ import com.xydl.cac.service.LxService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.List;
@ -24,13 +25,21 @@ public class LxServiceImpl implements LxService {
}
@Override
public Lx add(Lx item) {
public Lx add(Lx item) throws Exception {
item.setId(null);
List<Lx> list = repository.findByMc(item.getMc());
if (!CollectionUtils.isEmpty(list)) {
throw new Exception("该名称已被使用");
}
return repository.save(item);
}
@Override
public void update(Lx item) {
public void update(Lx item) throws Exception {
List<Lx> list = repository.findByMcAndIdIsNot(item.getMc(), item.getId());
if (!CollectionUtils.isEmpty(list)) {
throw new Exception("该名称已被使用");
}
repository.save(item);
}

@ -1,13 +1,8 @@
package com.xydl.cac.service.impl;
import com.xydl.cac.entity.Bdz;
import com.xydl.cac.entity.Jg;
import com.xydl.cac.entity.Modev;
import com.xydl.cac.entity.Zsb;
import com.xydl.cac.repository.BdzRepository;
import com.xydl.cac.repository.JgRepository;
import com.xydl.cac.repository.ModevRepository;
import com.xydl.cac.repository.ZsbRepository;
import com.xydl.cac.entity.*;
import com.xydl.cac.model.BindingModel;
import com.xydl.cac.repository.*;
import com.xydl.cac.service.ParamBindService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@ -15,7 +10,9 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
@Service
@Slf4j
@ -30,6 +27,14 @@ public class ParamBindServiceImpl implements ParamBindService {
ZsbRepository zsbRepository;
@Resource
ModevRepository modevRepository;
@Resource
IcdConfigTypeRepository typeRepository;
@Resource
IcdConfigTypeInstRepository instRepository;
@Resource
IcdConfigTypeAttRepository attRepository;
@Resource
RptparamindexRepository rptparamindexRepository;
@Override
public List<Bdz> getTree() throws Exception {
@ -51,4 +56,80 @@ public class ParamBindServiceImpl implements ParamBindService {
}
return bdzList;
}
@Override
public List<IcdConfigTypeInst> instList(String iedName) {
List<IcdConfigTypeInst> result = new ArrayList<>();
List<IcdConfigType> typeList = typeRepository.findByIedName(iedName);
for (IcdConfigType type : typeList) {
List<IcdConfigTypeInst> instList = instRepository.findByIcdConfigTypeId(type.getId());
for (IcdConfigTypeInst inst : instList) {
String param = type.getIedName() + type.getLdeviceInst() + "/" + type.getLnClass()
+ inst.getInst();
inst.setParamIndex(param);
}
result.addAll(instList);
}
return result;
}
@Override
public List<Rptparamindex> preview(BindingModel item) throws Exception {
Optional<IcdConfigTypeInst> optionalInst = instRepository.findById(item.getBindingId());
if (!optionalInst.isPresent()) {
throw new Exception("未找到该ICD配置类型实例, eqmid=" + item.getEqmid() + ", bindingId=" + item.getBindingId());
}
IcdConfigTypeInst inst = optionalInst.get();
Optional<IcdConfigType> optionalType = typeRepository.findById(inst.getIcdConfigTypeId());
if (!optionalType.isPresent()) {
throw new Exception("未找到该实例对应的ICD配置类型, bindingId=" + item.getBindingId());
}
IcdConfigType type = optionalType.get();
List<Rptparamindex> result = new ArrayList<>();
String param = type.getIedName() + type.getLdeviceInst() + "/" + type.getLnClass()
+ inst.getInst();
List<IcdConfigTypeAtt> attList = attRepository.findByIcdConfigTypeId(type.getId());
for (IcdConfigTypeAtt att : attList) {
String paramindex = param + "$" + att.getLastName();
Optional<Rptparamindex> optionalRpt = rptparamindexRepository.findById(paramindex);
if (!optionalRpt.isPresent()) {
throw new Exception("未找到该Rptparamindex对象参引=" + paramindex);
}
Rptparamindex rpt = optionalRpt.get();
rpt.setTablename(type.getTableName());
rpt.setColname(att.getColName());
rpt.setEqmid(item.getEqmid());
result.add(rpt);
}
return result;
}
private void bindOne(Integer eqmid, Integer bindingId) throws Exception {
Optional<IcdConfigTypeInst> optionalInst = instRepository.findById(bindingId);
if (!optionalInst.isPresent()) {
throw new Exception("未找到该ICD配置类型实例, eqmid=" + eqmid + ", bindingId=" + bindingId);
}
IcdConfigTypeInst inst = optionalInst.get();
Optional<IcdConfigType> optionalType = typeRepository.findById(inst.getIcdConfigTypeId());
if (!optionalType.isPresent()) {
throw new Exception("未找到该实例对应的ICD配置类型, bindingId=" + bindingId);
}
IcdConfigType type = optionalType.get();
String param = type.getIedName() + type.getLdeviceInst() + "/" + type.getLnClass()
+ inst.getInst();
List<IcdConfigTypeAtt> attList = attRepository.findByIcdConfigTypeId(type.getId());
for (IcdConfigTypeAtt att : attList) {
String paramindex = param + "$" + att.getLastName();
Optional<Rptparamindex> optionalRpt = rptparamindexRepository.findById(paramindex);
if (!optionalRpt.isPresent()) {
throw new Exception("未找到该Rptparamindex对象参引=" + paramindex);
}
Rptparamindex rpt = optionalRpt.get();
rpt.setTablename(type.getTableName());
rpt.setColname(att.getColName());
rpt.setEqmid(eqmid);
rptparamindexRepository.save(rpt);
}
}
}

@ -4,23 +4,23 @@ import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.xydl.cac.entity.IcdFileConfig;
import com.xydl.cac.entity.IcdConfigType;
import org.apache.commons.lang3.StringUtils;
import java.util.*;
public class IcdXmlUtil {
public static LinkedHashMap<String, IcdFileConfig> loadIcdType(String xml) throws Exception {
public static LinkedHashMap<String, IcdConfigType> loadIcdType(String xml) throws Exception {
XmlMapper xmlMapper = XmlMapper.builder()
.build();
JsonNode root = xmlMapper.readTree(xml);
LinkedHashMap<String, IcdFileConfig> result = processTypeRoot(root);
LinkedHashMap<String, IcdConfigType> result = processTypeRoot(root);
return result;
}
private static LinkedHashMap<String, IcdFileConfig> processTypeRoot(JsonNode root) {
LinkedHashMap<String, IcdFileConfig> result = new LinkedHashMap<>();
private static LinkedHashMap<String, IcdConfigType> processTypeRoot(JsonNode root) {
LinkedHashMap<String, IcdConfigType> result = new LinkedHashMap<>();
List<JsonNode> iedList = findNodes(root, "IED");
for (JsonNode iedNode : iedList) {
@ -29,7 +29,7 @@ public class IcdXmlUtil {
return result;
}
private static void processIEDNode(JsonNode iedNode, LinkedHashMap<String, IcdFileConfig> result) {
private static void processIEDNode(JsonNode iedNode, LinkedHashMap<String, IcdConfigType> result) {
String iedName = iedNode.get("name").asText();
List<JsonNode> devList = findNodes(iedNode, "LDevice");
@ -38,8 +38,8 @@ public class IcdXmlUtil {
}
}
private static void processTypeDeviceNode(JsonNode deviceNode, String iedName, LinkedHashMap<String, IcdFileConfig> result) {
String ldInst = deviceNode.get("inst").asText();
private static void processTypeDeviceNode(JsonNode deviceNode, String iedName, LinkedHashMap<String, IcdConfigType> result) {
String ldeviceInst = deviceNode.get("inst").asText();
Map<String, JsonNode> lnMap = buildLNMap(deviceNode);
List<JsonNode> fcdaList = findNodes(deviceNode, "FCDA");
@ -52,21 +52,20 @@ public class IcdXmlUtil {
JsonNode lnNode = lnMap.get(lnClass + lnInst);
String dai = findLN_DOI_DAI(lnNode, doName);
String key = iedName + ldInst + "/" + lnClass + "/" + doName;
String key = iedName + ldeviceInst + "/" + lnClass;
String param = fc + "$" + doName + "$" + dai;
if ("MX".equals(fc)) {
IcdFileConfig config = result.get(key);
IcdConfigType config = result.get(key);
if (config == null) {
config = IcdFileConfig.builder()
config = IcdConfigType.builder()
.iedName(iedName)
.ldeviceInst(ldInst)
.ldeviceInst(ldeviceInst)
.lnClass(lnClass)
.doName(doName)
.lastName(dai)
.build();
result.put(key, config);
}
config.addInst(lnInst, param);
config.addInst(lnInst);
config.addAtt(doName, param);
}
}
}

Loading…
Cancel
Save