系统配置
This commit is contained in:
@@ -7,6 +7,7 @@ import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csdevice.pojo.param.CsEquipmentTransferAddParm;
|
||||
import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
|
||||
import com.njcn.csdevice.pojo.vo.DevCountVO;
|
||||
import com.njcn.csdevice.service.CsDeviceUserPOService;
|
||||
import com.njcn.csdevice.service.CsEquipmentTransferPOService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
@@ -64,5 +65,22 @@ public class DeviceUserController extends BaseController {
|
||||
csDeviceUserPOService.saveBatch(list);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
/**
|
||||
* @Description: 统计当前工程下的设备
|
||||
* @Param:
|
||||
* @return: com.njcn.common.pojo.response.HttpResult<java.lang.Boolean>
|
||||
* @Author: clam
|
||||
* @Date: 2023/7/5
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/devCount")
|
||||
@ApiOperation("设备统计")
|
||||
@ApiImplicitParam(name = "id", value = "工程id", required = true)
|
||||
public HttpResult<DevCountVO> devCount(@RequestParam("id") String id){
|
||||
String methodDescribe = getMethodDescribe("devCount");
|
||||
|
||||
DevCountVO result = csDeviceUserPOService.devCount (id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -116,11 +116,11 @@ public class EquipmentDeliveryController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/queryProjectById")
|
||||
@PostMapping("/queryEquipmentById")
|
||||
@ApiOperation("设备查询通过id获取")
|
||||
@ApiImplicitParam(name = "ids", value = "设备id集合", required = true)
|
||||
public HttpResult<List<CsEquipmentDeliveryPO>> queryDeviceById(@RequestParam List<String> ids){
|
||||
String methodDescribe = getMethodDescribe("queryDeviceById");
|
||||
public HttpResult<List<CsEquipmentDeliveryPO>> queryEquipmentById(@RequestParam List<String> ids){
|
||||
String methodDescribe = getMethodDescribe("queryEquipmentById");
|
||||
List<CsEquipmentDeliveryPO> csEquipmentDeliveryPOS = csEquipmentDeliveryService.listByIds(ids);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, csEquipmentDeliveryPOS, methodDescribe);
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.njcn.csdevice.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentAlarmPO;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2023/5/16 16:25【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
public interface CsEquipmentAlarmPOMapper extends BaseMapper<CsEquipmentAlarmPO> {
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.njcn.csdevice.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsLineTopologyTemplate;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2023/7/10 18:30【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
public interface CsLineTopologyTemplateMapper extends BaseMapper<CsLineTopologyTemplate> {
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.njcn.csdevice.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsTopologyDiagramTemplate;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2023/7/10 18:30【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
public interface CsTopologyDiagramTemplateMapper extends BaseMapper<CsTopologyDiagramTemplate> {
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
<?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.csdevice.mapper.CsEquipmentAlarmPOMapper">
|
||||
<resultMap id="BaseResultMap" type="com.njcn.csdevice.pojo.po.CsEquipmentAlarmPO">
|
||||
<!--@mbg.generated-->
|
||||
<!--@Table cs_equipment_alarm-->
|
||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||
<result column="project_id" jdbcType="VARCHAR" property="projectId" />
|
||||
<result column="equipment_id" jdbcType="VARCHAR" property="equipmentId" />
|
||||
<result column="alarm_msg" jdbcType="VARCHAR" property="alarmMsg" />
|
||||
<result column="alarm_level" jdbcType="VARCHAR" property="alarmLevel" />
|
||||
<result column="start_time" jdbcType="TIMESTAMP" property="startTime" />
|
||||
<result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
|
||||
<result column="status" jdbcType="BIT" property="status" />
|
||||
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
<result column="update_by" jdbcType="VARCHAR" property="updateBy" />
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
<!--@mbg.generated-->
|
||||
id, project_id, equipment_id, alarm_msg, alarm_level, start_time, end_time, `status`,
|
||||
create_by, create_time, update_by, update_time
|
||||
</sql>
|
||||
</mapper>
|
||||
@@ -2,7 +2,9 @@ package com.njcn.csdevice.service;
|
||||
|
||||
import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
/**
|
||||
import com.njcn.csdevice.pojo.vo.DevCountVO;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2023/6/27 9:40【需求编号】
|
||||
@@ -16,4 +18,6 @@ public interface CsDeviceUserPOService extends IService<CsDeviceUserPO>{
|
||||
Boolean add(String id);
|
||||
|
||||
Boolean share(String id);
|
||||
|
||||
DevCountVO devCount(String id);
|
||||
}
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.njcn.csdevice.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.njcn.csdevice.pojo.param.CsEquipmentAlarmAddParm;
|
||||
import com.njcn.csdevice.pojo.param.CsEquipmentAlarmPageParm;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentAlarmPO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.csdevice.pojo.vo.CsEquipmentAlarmVO;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2023/5/16 16:24【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
public interface CsEquipmentAlarmPOService extends IService<CsEquipmentAlarmPO>{
|
||||
|
||||
/**
|
||||
* @Description: 新增设备警告
|
||||
* @Param:
|
||||
* @return: com.njcn.algorithm.pojo.vo.CsEquipmentAlarmVO
|
||||
* @Author: clam
|
||||
* @Date: 2023/5/17
|
||||
*/
|
||||
CsEquipmentAlarmVO add(CsEquipmentAlarmAddParm csEquipmentAlarmAddParm);
|
||||
|
||||
IPage<CsEquipmentAlarmVO> queryPage(CsEquipmentAlarmPageParm csEquipmentAlarmPageParm);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.csdevice.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.csdevice.pojo.po.CsLineTopologyTemplate;
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2023/7/10 18:30【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
public interface CsLineTopologyTemplateService extends IService<CsLineTopologyTemplate>{
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.njcn.csdevice.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.csdevice.pojo.po.CsTopologyDiagramTemplate;
|
||||
import com.njcn.csdevice.pojo.vo.CsTopologyDiagramTemplateVO;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2023/7/10 18:30【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
public interface CsTopologyDiagramTemplateService extends IService<CsTopologyDiagramTemplate>{
|
||||
|
||||
|
||||
String uploadImage(MultipartFile issuesFile);
|
||||
|
||||
List<CsTopologyDiagramTemplateVO> queryImage();
|
||||
}
|
||||
@@ -39,6 +39,9 @@ public class RoleEngineerDevService {
|
||||
public List<String> getRoleengineer(){
|
||||
String role = RequestUtil.getUserRole();
|
||||
List<String> strings = JSONArray.parseArray(role, String.class);
|
||||
if(CollectionUtils.isEmpty(strings)){
|
||||
return new ArrayList<>();
|
||||
}
|
||||
role=strings.get(0);
|
||||
String userIndex = RequestUtil.getUserIndex();
|
||||
QueryWrapper<CsEngineeringUserPO> csEngineeringUserPOQueryWrapper = new QueryWrapper<> ();
|
||||
@@ -93,6 +96,9 @@ public class RoleEngineerDevService {
|
||||
public List<String> getDevice(){
|
||||
String role = RequestUtil.getUserRole();
|
||||
List<String> strings = JSONArray.parseArray(role, String.class);
|
||||
if(CollectionUtils.isEmpty(strings)){
|
||||
return new ArrayList<>();
|
||||
}
|
||||
role=strings.get(0);
|
||||
String userIndex = RequestUtil.getUserIndex();
|
||||
QueryWrapper<CsEngineeringUserPO> csEngineeringUserPOQueryWrapper = new QueryWrapper<> ();
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
||||
import com.njcn.csdevice.mapper.CsLedgerMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsDevModelPO;
|
||||
import com.njcn.csdevice.pojo.po.CsLedger;
|
||||
import com.njcn.csdevice.pojo.vo.DevCountVO;
|
||||
import com.njcn.cswarn.api.CsEquipmentAlarmFeignClient;
|
||||
import com.njcn.cswarn.pojo.parm.CsEquipmentAlarmParm;
|
||||
import com.njcn.cswarn.pojo.vo.CsEquipmentAlarmVO;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -16,6 +24,7 @@ import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -29,7 +38,8 @@ import java.util.Objects;
|
||||
@RequiredArgsConstructor
|
||||
public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper, CsDeviceUserPO> implements CsDeviceUserPOService{
|
||||
|
||||
|
||||
private final CsLedgerMapper csLedgerMapper;
|
||||
private final CsEquipmentAlarmFeignClient csEquipmentAlarmFeignClient;
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean add(String id) {
|
||||
@@ -66,4 +76,34 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
|
||||
|
||||
return save;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DevCountVO devCount(String id) {
|
||||
DevCountVO devCountVO = new DevCountVO();
|
||||
QueryWrapper<CsLedger> queryWrap = new QueryWrapper<>();
|
||||
queryWrap.eq("level",1).eq("state",1).
|
||||
like("pid",id);
|
||||
Integer integer = csLedgerMapper.selectCount(queryWrap);
|
||||
CsEquipmentAlarmParm csEquipmentAlarmPageParm = new CsEquipmentAlarmParm();
|
||||
csEquipmentAlarmPageParm.setEngineerId(id);
|
||||
|
||||
//未处理的
|
||||
csEquipmentAlarmPageParm.setDealFlag("0");
|
||||
//todo 后续添加时间条件
|
||||
// csEquipmentAlarmPageParm.setStartTime();
|
||||
// csEquipmentAlarmPageParam.setEndTime();
|
||||
List<CsEquipmentAlarmVO> data = csEquipmentAlarmFeignClient.queryList(csEquipmentAlarmPageParm).getData();
|
||||
List<String> devIds = data.stream().map(CsEquipmentAlarmVO::getEquipmentId).distinct().collect(Collectors.toList());
|
||||
devCountVO.setAlarmLineCount(devIds.size());
|
||||
devCountVO.setAlarmEventCount(data.size());
|
||||
|
||||
devCountVO.setId(id);
|
||||
devCountVO.setOnLineCount(integer);
|
||||
//
|
||||
devCountVO.setEventCount(0);
|
||||
//todo重寫 offLineCount AlarmLineCount
|
||||
devCountVO.setOffLineCount(0);
|
||||
|
||||
return devCountVO;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import com.alibaba.cloud.commons.lang.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.csdevice.mapper.AppProjectMapper;
|
||||
import com.njcn.csdevice.mapper.CsEquipmentAlarmPOMapper;
|
||||
import com.njcn.csdevice.mapper.CsEquipmentDeliveryMapper;
|
||||
import com.njcn.csdevice.pojo.param.CsEquipmentAlarmAddParm;
|
||||
import com.njcn.csdevice.pojo.param.CsEquipmentAlarmPageParm;
|
||||
import com.njcn.csdevice.pojo.po.AppProjectPO;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentAlarmPO;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.csdevice.pojo.vo.CsEquipmentAlarmVO;
|
||||
import com.njcn.csdevice.service.CsEquipmentAlarmPOService;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2023/5/16 16:24【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class CsEquipmentAlarmPOServiceImpl extends ServiceImpl<CsEquipmentAlarmPOMapper, CsEquipmentAlarmPO> implements CsEquipmentAlarmPOService{
|
||||
|
||||
private final CsEquipmentDeliveryMapper csEquipmentDeliveryMapper;
|
||||
private final AppProjectMapper appProjectMapper;
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public CsEquipmentAlarmVO add(CsEquipmentAlarmAddParm csEquipmentAlarmAddParm) {
|
||||
CsEquipmentAlarmPO csEquipmentAlarmPO = new CsEquipmentAlarmPO();
|
||||
BeanUtils.copyProperties(csEquipmentAlarmAddParm,csEquipmentAlarmPO);
|
||||
csEquipmentAlarmPO.setStatus("1");
|
||||
this.save(csEquipmentAlarmPO);
|
||||
|
||||
CsEquipmentAlarmVO csEquipmentAlarmVO = new CsEquipmentAlarmVO();
|
||||
this.poToVO(csEquipmentAlarmPO, csEquipmentAlarmVO);
|
||||
|
||||
log.info("新增设备警告:{}", csEquipmentAlarmVO.toString());
|
||||
return csEquipmentAlarmVO;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<CsEquipmentAlarmVO> queryPage(CsEquipmentAlarmPageParm csEquipmentAlarmPageParm) {
|
||||
Page<CsEquipmentAlarmVO> returnpage = new Page<> (csEquipmentAlarmPageParm.getPageNum ( ), csEquipmentAlarmPageParm.getPageSize ( ));
|
||||
Page<CsEquipmentAlarmPO> queryPage = new Page<> (csEquipmentAlarmPageParm.getPageNum ( ), csEquipmentAlarmPageParm.getPageSize ( ));
|
||||
QueryWrapper<CsEquipmentAlarmPO> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("status", "1");
|
||||
queryWrapper.eq(StringUtils.isNotBlank(csEquipmentAlarmPageParm.getProjectId()),CsEquipmentAlarmPO.COL_PROJECT_ID,csEquipmentAlarmPageParm.getProjectId());
|
||||
queryWrapper.eq(StringUtils.isNotBlank(csEquipmentAlarmPageParm.getEquipmentId()),CsEquipmentAlarmPO.COL_EQUIPMENT_ID,csEquipmentAlarmPageParm.getEquipmentId());
|
||||
queryWrapper.eq(StringUtils.isNotBlank(csEquipmentAlarmPageParm.getAlarmLevel()),CsEquipmentAlarmPO.COL_ALARM_LEVEL,csEquipmentAlarmPageParm.getAlarmLevel());
|
||||
queryWrapper.ge(Objects.nonNull(csEquipmentAlarmPageParm.getStartTime()),CsEquipmentAlarmPO.COL_START_TIME,csEquipmentAlarmPageParm.getStartTime());
|
||||
queryWrapper.le(Objects.nonNull(csEquipmentAlarmPageParm.getStartTime()),CsEquipmentAlarmPO.COL_START_TIME,csEquipmentAlarmPageParm.getEndTime());
|
||||
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
Page<CsEquipmentAlarmPO> csEquipmentAlarmPOPage = this.getBaseMapper().selectPage(queryPage, queryWrapper);
|
||||
List<CsEquipmentAlarmVO> collect = csEquipmentAlarmPOPage.getRecords().stream().map(temp -> {
|
||||
CsEquipmentAlarmVO csEquipmentAlarmVO = new CsEquipmentAlarmVO();
|
||||
this.poToVO(temp, csEquipmentAlarmVO);
|
||||
return csEquipmentAlarmVO;
|
||||
}).collect(Collectors.toList());
|
||||
returnpage.setRecords(collect);
|
||||
returnpage.setTotal(queryPage.getTotal());
|
||||
|
||||
return returnpage;
|
||||
}
|
||||
|
||||
private void poToVO(CsEquipmentAlarmPO csEquipmentAlarmPO, CsEquipmentAlarmVO csEquipmentAlarmVO) {
|
||||
BeanUtils.copyProperties(csEquipmentAlarmPO,csEquipmentAlarmVO);
|
||||
CsEquipmentDeliveryPO csEquipmentDeliveryPO = csEquipmentDeliveryMapper.selectById(csEquipmentAlarmPO.getEquipmentId());
|
||||
csEquipmentAlarmVO.setEquipmentName(csEquipmentDeliveryPO.getName());
|
||||
DictData data = dicDataFeignClient.getDicDataById(csEquipmentAlarmPO.getAlarmLevel()).getData();
|
||||
csEquipmentAlarmVO.setAlarmLevelName(data.getName());
|
||||
AppProjectPO appProjectPO = appProjectMapper.selectById(csEquipmentAlarmPO.getProjectId());
|
||||
csEquipmentAlarmVO.setProjectName(appProjectPO.getName());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.csdevice.mapper.CsLineTopologyTemplateMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsLineTopologyTemplate;
|
||||
import com.njcn.csdevice.service.CsLineTopologyTemplateService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2023/7/10 18:30【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Service
|
||||
public class CsLineTopologyTemplateServiceImpl extends ServiceImpl<CsLineTopologyTemplateMapper, CsLineTopologyTemplate> implements CsLineTopologyTemplateService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.constant.DataParam;
|
||||
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
||||
import com.njcn.csdevice.mapper.CsTopologyDiagramTemplateMapper;
|
||||
import com.njcn.csdevice.pojo.po.AppProjectPO;
|
||||
import com.njcn.csdevice.pojo.po.AppTopologyDiagramPO;
|
||||
import com.njcn.csdevice.pojo.po.CsTopologyDiagramTemplate;
|
||||
import com.njcn.csdevice.pojo.vo.AppTopologyDiagramVO;
|
||||
import com.njcn.csdevice.pojo.vo.CsTopologyDiagramTemplateVO;
|
||||
import com.njcn.csdevice.service.CsTopologyDiagramTemplateService;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2023/7/10 18:30【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class CsTopologyDiagramTemplateServiceImpl extends ServiceImpl<CsTopologyDiagramTemplateMapper, CsTopologyDiagramTemplate> implements CsTopologyDiagramTemplateService {
|
||||
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public String uploadImage(MultipartFile issuesFile) {
|
||||
CsTopologyDiagramTemplate csTopologyDiagramTemplate = new CsTopologyDiagramTemplate();
|
||||
|
||||
if (issuesFile.getSize() > DataParam.FILE_SIZE) {
|
||||
throw new BusinessException(AlgorithmResponseEnum.FILE_SIZE_ERROR);
|
||||
}
|
||||
String filePath = fileStorageUtil.uploadMultipart(issuesFile, OssPath.TOPOLOGY);
|
||||
csTopologyDiagramTemplate.setFilePath(filePath);
|
||||
csTopologyDiagramTemplate.setName(issuesFile.getOriginalFilename());
|
||||
csTopologyDiagramTemplate.setStatus("1");
|
||||
boolean save = this.save(csTopologyDiagramTemplate);
|
||||
AppTopologyDiagramVO vo = new AppTopologyDiagramVO();
|
||||
String fileUrl = fileStorageUtil.getFileUrl(filePath);
|
||||
return fileUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CsTopologyDiagramTemplateVO> queryImage() {
|
||||
List<CsTopologyDiagramTemplate> list = this.list(null);
|
||||
|
||||
List<CsTopologyDiagramTemplateVO> collect = list.stream().map(temp -> {
|
||||
CsTopologyDiagramTemplateVO vo = new CsTopologyDiagramTemplateVO();
|
||||
BeanUtils.copyProperties(temp, vo);
|
||||
|
||||
vo.setFilePath(fileStorageUtil.getFileUrl(vo.getFilePath()));
|
||||
return vo;
|
||||
}).collect(Collectors.toList());
|
||||
return collect;
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user