This commit is contained in:
huangzj
2023-06-20 14:21:15 +08:00
parent f7640d202c
commit c01a9d2c4b
13 changed files with 141 additions and 65 deletions

View File

@@ -3,6 +3,8 @@ package com.njcn.csdevice.pojo.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
*
* Description:
@@ -25,16 +27,19 @@ public class CsEquipmentTransferAddParm {
private String equipmentIds;
@ApiModelProperty(value = "发起人")
@NotBlank(message="发起人不能为空!")
private String promoter;
@ApiModelProperty(value = "移交人")
@NotBlank(message="移交人为空!")
private String transferor;
/**
* 事件类型(权限转移,数据恢复)
*/
@ApiModelProperty(value = "事件类型")
@NotBlank(message="事件类型不能为空!")
private String eventType;

View File

@@ -25,7 +25,7 @@ public class AppLineTopologyDiagramPO extends BaseEntity {
/**
* 拓扑图Id
*/
@TableId(value = "id", type = IdType.ASSIGN_UUID)
@TableField(value = "id")
private String id;
/**

View File

@@ -38,8 +38,8 @@ public class CslineController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryLineById")
@ApiOperation("项目查询通过id获取")
@ApiImplicitParam(name = "ids", value = "项目id集合", required = true)
@ApiOperation("监测点查询通过设备id获取")
@ApiImplicitParam(name = "ids", value = "设备id集合", required = true)
public HttpResult<List<CsLinePO>> queryLineById(@RequestParam List<String> ids){
String methodDescribe = getMethodDescribe("queryLineById");
List<CsLinePO> csLinePOS = csLinePOService.listByIds(ids);
@@ -48,7 +48,7 @@ public class CslineController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryLineByDevId")
@ApiOperation("项目查询通过设备id获取")
@ApiOperation("监测点查询通过设备id获取")
@ApiImplicitParam(name = "id", value = "设备id集合", required = true)
public HttpResult<List<CsLinePO>> queryLineByDevId(@RequestParam String id){
String methodDescribe = getMethodDescribe("queryLineByDevId");

View File

@@ -3,6 +3,7 @@ package com.njcn.csdevice.controller.project;
import com.njcn.csdevice.pojo.param.AppLineTopologyDiagramAddParm;
import com.njcn.csdevice.pojo.param.AppLineTopologyDiagramAuditParm;
import com.njcn.csdevice.pojo.po.AppLineTopologyDiagramPO;
import com.njcn.csdevice.pojo.vo.AppTopologyDiagramVO;
import com.njcn.csdevice.service.AppLineTopologyDiagramService;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
@@ -17,10 +18,7 @@ import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
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 org.springframework.web.bind.annotation.*;
/**
* Description:
@@ -64,4 +62,13 @@ public class LineTopologyDiagramController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryTopologyDiagram")
@ApiOperation("查询装置拓扑图")
public HttpResult<AppTopologyDiagramVO> queryTopologyDiagram(@RequestParam(value="devId") String devId){
String methodDescribe = getMethodDescribe("queryTopologyDiagram");
AppTopologyDiagramVO appTopologyDiagramVO = appLineTopologyDiagramService.query(devId);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, appTopologyDiagramVO, methodDescribe);
}
}

View File

@@ -2,7 +2,9 @@ package com.njcn.csdevice.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.csdevice.pojo.po.AppLineTopologyDiagramPO;
/**
import com.njcn.csdevice.pojo.vo.AppTopologyDiagramVO;
/**
*
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
@@ -14,4 +16,5 @@ import com.njcn.csdevice.pojo.po.AppLineTopologyDiagramPO;
public interface AppLineTopologyDiagramService extends IService<AppLineTopologyDiagramPO> {
}
AppTopologyDiagramVO query(String devId);
}

View File

@@ -1,11 +1,23 @@
package com.njcn.csdevice.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.csdevice.mapper.AppLineTopologyDiagramMapper;
import com.njcn.csdevice.pojo.param.AppTopologyDiagramQueryParm;
import com.njcn.csdevice.pojo.po.AppLineTopologyDiagramPO;
import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.pojo.vo.AppTopologyDiagramVO;
import com.njcn.csdevice.service.AppLineTopologyDiagramService;
import com.njcn.csdevice.service.AppTopologyDiagramService;
import com.njcn.csdevice.service.CsLinePOService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
/**
*
* Description:
@@ -16,6 +28,24 @@ import org.springframework.stereotype.Service;
* @version V1.0.0
*/
@Service
@RequiredArgsConstructor
public class AppLineTopologyDiagramServiceImpl extends ServiceImpl<AppLineTopologyDiagramMapper, AppLineTopologyDiagramPO> implements AppLineTopologyDiagramService {
private final CsLinePOService csLinePOService;
private final AppTopologyDiagramService appTopologyDiagramService;
@Override
public AppTopologyDiagramVO query(String devId) {
List<CsLinePO> csLinePOList = csLinePOService.queryByDevId(devId);
List<String> collect = csLinePOList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
if(CollectionUtil.isEmpty(collect)){
throw new BusinessException("设备下暂未绑定监测点,未找到拓扑图信息");
}
QueryWrapper<AppLineTopologyDiagramPO> queryWrap = new QueryWrapper<>();
queryWrap.select("distinct (id)").in("line_id",collect);
AppLineTopologyDiagramPO appLineTopologyDiagramPO = this.getBaseMapper().selectOne(queryWrap);
AppTopologyDiagramQueryParm appTopologyDiagramQueryParm = new AppTopologyDiagramQueryParm();
appTopologyDiagramQueryParm.setId(appLineTopologyDiagramPO.getId());
List<AppTopologyDiagramVO> appTopologyDiagramVOS = appTopologyDiagramService.queryAppTopologyDiagram(appTopologyDiagramQueryParm);
AppTopologyDiagramVO appTopologyDiagramVO = appTopologyDiagramVOS.get(0);
return appTopologyDiagramVO;
}
}

View File

@@ -25,6 +25,8 @@ public class CsConfigurationParm {
@NotBlank(message="组态项目名称不能为空")
private String name;
private String remark;
@Data

View File

@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.constraints.NotBlank;
@@ -26,11 +27,7 @@ public class CsPageParm {
@ApiModelProperty(value="组态项目id")
private String pid;
/**
* 组态页面名称
*/
@ApiModelProperty(value="组态页面名称")
private String name;
private MultipartFile multipartFile;
/**
* 组态页面文件路径

View File

@@ -31,6 +31,10 @@ public class CsConfigurationPO extends BaseEntity {
@TableField(value = "`name`")
private String name;
@TableField(value = "remark")
private String remark;
/**
* 状态 0:删除 1:正常
*/

View File

@@ -28,6 +28,9 @@ public class CsConfigurationVO extends BaseEntity {
@ApiModelProperty(value = "操作人")
private String operater;
@ApiModelProperty(value = "备注")
private String remark;
/**
* 状态 0:删除 1:正常
*/

View File

@@ -16,6 +16,8 @@ import org.springframework.validation.annotation.Validated;
import com.njcn.csharmonic.param.CsPageParm;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* (cs_page)表控制层
*
@@ -31,19 +33,18 @@ public class CsPagePOController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/add")
@ApiOperation("新增组态页面")
@ApiImplicitParam(name = "csPageParm", value = "新增组态项目参数", required = true)
public HttpResult<CsPageVO> add(@RequestBody @Validated CsPageParm csPageParm){
// @ApiImplicitParam(name = "csPageParm", value = "新增组态项目参数", required = true)
public HttpResult<Boolean> add( @Validated CsPageParm csPageParm){
String methodDescribe = getMethodDescribe("add");
CsPageVO csPageVO = csPagePOService.add (csPageParm);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, csPageVO, methodDescribe);
boolean flag = csPagePOService.add (csPageParm);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/audit")
@ApiOperation("修改组态页面")
@ApiImplicitParam(name = "auditParm", value = "修改组态项目参数", required = true)
public HttpResult<Boolean> audit(@RequestBody @Validated CsPageParm.CsPageParmAuditParam auditParm){
public HttpResult<Boolean> audit( @Validated CsPageParm.CsPageParmAuditParam auditParm){
String methodDescribe = getMethodDescribe("audit");
boolean save = csPagePOService.audit (auditParm);

View File

@@ -6,6 +6,8 @@ import com.njcn.csharmonic.param.CsPageParm;
import com.njcn.csharmonic.pojo.po.CsPagePO;
import com.njcn.csharmonic.pojo.vo.CsPageVO;
import java.util.List;
/**
*
* Description:
@@ -17,7 +19,7 @@ import com.njcn.csharmonic.pojo.vo.CsPageVO;
public interface CsPagePOService extends IService<CsPagePO>{
CsPageVO add(CsPageParm csPageParm);
boolean add(CsPageParm csPageParm);
boolean audit(CsPageParm.CsPageParmAuditParam auditParm);

View File

@@ -1,5 +1,7 @@
package com.njcn.csharmonic.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.Query;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -21,12 +23,11 @@ import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -48,39 +49,60 @@ public class CsPagePOServiceImpl extends ServiceImpl<CsPagePOMapper, CsPagePO> i
@Override
@Transactional(rollbackFor = {Exception.class})
public CsPageVO add(CsPageParm csPageParm) {
CsPagePO csPagePO = new CsPagePO();
CsPageVO csPageVO = new CsPageVO();
csPagePO.setPid(csPageParm.getPid());
csPagePO.setStatus("1");
csPagePO.setName(csPageParm.getName());
InputStream inputStream = this.writeJsonStringToInputStream(csPageParm.getJsonFile());
String s = fileStorageUtil.uploadStream(inputStream, HarmonicConstant.CONFIGURATIONPATH, HarmonicConstant.CONFIGURATIONNAME);
csPagePO.setPath(s);
this.save(csPagePO);
BeanUtils.copyProperties(csPagePO, csPageVO);
InputStream fileStream = fileStorageUtil.getFileStream(csPagePO.getPath());
String text = new BufferedReader(
new InputStreamReader(fileStream, StandardCharsets.UTF_8))
.lines()
.collect(Collectors.joining("\n"));
csPageVO.setPath(text);
return csPageVO;
public boolean add(CsPageParm csPageParm) {
List<CsPageVO> list = new ArrayList<>();
QueryWrapper<CsPagePO> csPagePOQueryWrapper = new QueryWrapper<>();
String pid = csPageParm.getPid();
csPagePOQueryWrapper.eq("pid",pid);
this.getBaseMapper().delete(csPagePOQueryWrapper);
InputStream inputStream = null;
MultipartFile multipartFile = csPageParm.getMultipartFile();
try {
inputStream = multipartFile.getInputStream(); // 获取文件的输入流
String text = new BufferedReader(
new InputStreamReader(inputStream, StandardCharsets.UTF_8))
.lines()
.collect(Collectors.joining("\n"));
List<CsPagePO> csPagePOS = JSON.parseArray(text, CsPagePO.class);
csPagePOS.forEach(temp->{
String s = fileStorageUtil.uploadStream(writeJsonStringToInputStream(temp.getPath()),HarmonicConstant.CONFIGURATIONPATH, HarmonicConstant.CONFIGURATIONNAME);
temp.setPid(pid);
temp.setStatus("1");
temp.setPath(s);
this.save(temp);
});
} catch (IOException e) {
throw new RuntimeException(e);
}
finally {
try {
inputStream.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return true;
}
@Override
@Transactional(rollbackFor = {Exception.class})
public boolean audit(CsPageParm.CsPageParmAuditParam auditParm) {
CsPagePO csPagePO = new CsPagePO();
CsPagePO byId = this.getById(auditParm.getId());
fileStorageUtil.deleteFile(byId.getPath());
BeanUtils.copyProperties(auditParm, csPagePO);
if(StringUtils.isNotBlank(auditParm.getJsonFile())){
InputStream inputStream = this.writeJsonStringToInputStream(auditParm.getJsonFile());
String s = fileStorageUtil.uploadStream(inputStream, HarmonicConstant.CONFIGURATIONPATH, HarmonicConstant.CONFIGURATIONNAME);
csPagePO.setPath(s);
}
return this.updateById(csPagePO);
// CsPagePO csPagePO = new CsPagePO();
// CsPagePO byId = this.getById(auditParm.getId());
// fileStorageUtil.deleteFile(byId.getPath());
// BeanUtils.copyProperties(auditParm, csPagePO);
// String s = fileStorageUtil.uploadMultipart(auditParm.getMultipartFile(), HarmonicConstant.CONFIGURATIONPATH);
//
// csPagePO.setPath(s);
//
// return this.updateById(csPagePO);
return true;
}
@Override
@@ -94,14 +116,14 @@ public class CsPagePOServiceImpl extends ServiceImpl<CsPagePOMapper, CsPagePO> i
IPage<CsPagePO> pageData = this.page(new Page<>(csPageParam.getPageNum(), csPageParam.getPageSize()), queryWrapper);
List<String> collect1 = pageData.getRecords().stream().map(CsPagePO::getCreateBy).collect(Collectors.toList());
Map<String, String> collect2;
if(!CollectionUtils.isEmpty(collect1)){
List<User> data = userFeignClient.getUserByIdList(collect1).getData();
collect2 = data.stream().collect(Collectors.toMap(User::getId, User::getName, (e1, e2) -> e1 + "," + e2));
} else {
collect2 = new HashMap<>();
}
// Map<String, String> collect2;
// if(!CollectionUtils.isEmpty(collect1)){
// List<User> data = userFeignClient.getUserByIdList(collect1).getData();
// collect2 = data.stream().collect(Collectors.toMap(User::getId, User::getName, (e1, e2) -> e1 + "," + e2));
//
// } else {
// collect2 = new HashMap<>();
// }
List<CsPageVO> collect = pageData.getRecords().stream().map(temp -> {
CsPageVO csPageVO = new CsPageVO();
CsConfigurationPO csConfigurationPO = csConfigurationMapper.selectById(temp.getPid());
@@ -113,7 +135,7 @@ public class CsPagePOServiceImpl extends ServiceImpl<CsPagePOMapper, CsPagePO> i
.lines()
.collect(Collectors.joining("\n"));
csPageVO.setPath(text);
csPageVO.setOperater(collect2.get(csPageVO.getCreateBy()));
// csPageVO.setOperater(collect2.get(csPageVO.getCreateBy()));
return csPageVO;
}).collect(Collectors.toList());
returnpage.setRecords(collect);