代码调整
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
package com.njcn.csdevice.controller.Equipment;
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csdevice.pojo.vo.LedgerTreeVO;
|
||||
import com.njcn.csdevice.service.IDeviceService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/5/29 19:43
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/device")
|
||||
@Api(tags = "终端台账")
|
||||
@AllArgsConstructor
|
||||
public class DeviceController extends BaseController {
|
||||
|
||||
private final IDeviceService deviceService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/ledgerTree")
|
||||
@ApiOperation("台账树")
|
||||
public HttpResult<LedgerTreeVO> getLedgerTree(){
|
||||
String methodDescribe = getMethodDescribe("getLedgerTree");
|
||||
LedgerTreeVO ledgerTree = deviceService.getLedgerTree();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, ledgerTree, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.njcn.csdevice.controller.project;
|
||||
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csdevice.pojo.po.CsEngineeringPO;
|
||||
import com.njcn.csdevice.service.ICsEngineeringUserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.njcn.web.controller.BaseController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 工程用户关系表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-29
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/csEngineeringUser")
|
||||
@Slf4j
|
||||
@Api(tags = " 项目管理")
|
||||
@AllArgsConstructor
|
||||
public class CsEngineeringUserController extends BaseController {
|
||||
|
||||
private final ICsEngineeringUserService csEngineeringUserService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getEngineeringByUser")
|
||||
@ApiOperation("根据用户获取工程")
|
||||
@ApiImplicitParam(name = "userIndex", value = "用户id", required = true)
|
||||
public HttpResult<List<CsEngineeringPO>> getEngineeringByUser(@RequestParam String userIndex){
|
||||
String methodDescribe = getMethodDescribe("getEngineeringByUser");
|
||||
List<CsEngineeringPO> list = csEngineeringUserService.getEngineeringByUser(userIndex);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.csdevice.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsEngineeringUserPO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 工程用户关系表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-29
|
||||
*/
|
||||
public interface CsEngineeringUserMapper extends BaseMapper<CsEngineeringUserPO> {
|
||||
|
||||
}
|
||||
@@ -8,6 +8,8 @@ import com.njcn.csdevice.pojo.param.AppProjectQueryParm;
|
||||
import com.njcn.csdevice.pojo.po.AppProjectPO;
|
||||
import com.njcn.csdevice.pojo.vo.AppProjectVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
@@ -43,4 +45,11 @@ public interface AppProjectService extends IService<AppProjectPO> {
|
||||
* @Date: 2023/3/28
|
||||
*/
|
||||
IPage<AppProjectVO> queryProject(AppProjectQueryParm appProjectQueryParm);
|
||||
|
||||
/**
|
||||
* 根据工程获取项目
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
List<AppProjectPO> getProjectByEngineering(List<String> list);
|
||||
}
|
||||
|
||||
@@ -48,4 +48,11 @@ public interface CsEngineeringService extends IService<CsEngineeringPO>{
|
||||
* @Date: 2023/4/12
|
||||
*/
|
||||
IPage<CsEngineeringVO> queryEngineeringPage(CsEngineeringQueryPageParm csEngineeringQueryPageParm);
|
||||
|
||||
/**
|
||||
* 根据工程id获取工程信息
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
List<CsEngineeringPO> getEngineerings(List<String> list);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,15 @@ import java.util.List;
|
||||
*/
|
||||
public interface CsLinePOService extends IService<CsLinePO>{
|
||||
|
||||
/**
|
||||
* 根据装置id获取监测点
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
List<CsLinePO> getLineByDev(List<String> list);
|
||||
|
||||
|
||||
List<CsLinePO> queryByDevId(String devId);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.njcn.csdevice.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.csdevice.pojo.po.CsProjectEquipmentPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -15,5 +17,11 @@ import com.njcn.csdevice.pojo.po.CsProjectEquipmentPO;
|
||||
*/
|
||||
public interface CsProjectEquipmentService extends IService<CsProjectEquipmentPO>{
|
||||
|
||||
/**
|
||||
* 根据项目获取装置
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
List<CsProjectEquipmentPO> getDeviceByProject(List<String> list);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.njcn.csdevice.service;
|
||||
|
||||
import com.njcn.csdevice.pojo.po.CsEngineeringPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 工程用户关系表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-29
|
||||
*/
|
||||
public interface ICsEngineeringUserService {
|
||||
|
||||
List<CsEngineeringPO> getEngineeringByUser(String userIndex);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.njcn.csdevice.service;
|
||||
|
||||
import com.njcn.csdevice.pojo.vo.LedgerTreeVO;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/5/29 19:53
|
||||
*/
|
||||
|
||||
public interface IDeviceService {
|
||||
|
||||
LedgerTreeVO getLedgerTree();
|
||||
|
||||
}
|
||||
@@ -6,7 +6,10 @@ 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.pojo.param.*;
|
||||
import com.njcn.csdevice.pojo.param.AppProjectAddParm;
|
||||
import com.njcn.csdevice.pojo.param.AppProjectAuditParm;
|
||||
import com.njcn.csdevice.pojo.param.AppProjectQueryParm;
|
||||
import com.njcn.csdevice.pojo.param.AppTopologyDiagramAddParm;
|
||||
import com.njcn.csdevice.pojo.po.AppProjectPO;
|
||||
import com.njcn.csdevice.pojo.vo.AppProjectVO;
|
||||
import com.njcn.csdevice.service.AppProjectService;
|
||||
@@ -17,6 +20,8 @@ import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* 接口文档访问地址:http://serverIP:port/swagger-ui.html
|
||||
@@ -122,4 +127,9 @@ public class AppProjectServiceImpl extends ServiceImpl<AppProjectMapper, AppProj
|
||||
// ).collect (Collectors.toList ( ));
|
||||
return returnpage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AppProjectPO> getProjectByEngineering(List<String> list) {
|
||||
return this.lambdaQuery().in(AppProjectPO::getEngineeringId,list).list();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,6 +105,11 @@ public class CsEngineeringServiceImpl extends ServiceImpl<CsEngineeringMapper, C
|
||||
return returnPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CsEngineeringPO> getEngineerings(List<String> list) {
|
||||
return this.lambdaQuery().in(CsEngineeringPO::getId,list).list();
|
||||
}
|
||||
|
||||
|
||||
public String getAreaById(String id){
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.csdevice.mapper.CsEngineeringUserMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsEngineeringPO;
|
||||
import com.njcn.csdevice.pojo.po.CsEngineeringUserPO;
|
||||
import com.njcn.csdevice.service.CsEngineeringService;
|
||||
import com.njcn.csdevice.service.ICsEngineeringUserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 工程用户关系表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-05-29
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class CsEngineeringUserServiceImpl extends ServiceImpl<CsEngineeringUserMapper, CsEngineeringUserPO> implements ICsEngineeringUserService {
|
||||
|
||||
private final CsEngineeringService csEngineeringService;
|
||||
|
||||
@Override
|
||||
public List<CsEngineeringPO> getEngineeringByUser(String userIndex) {
|
||||
List<CsEngineeringPO> result = new ArrayList<>();
|
||||
List<CsEngineeringUserPO> list = this.lambdaQuery().eq(CsEngineeringUserPO::getUserId, userIndex).list();
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
List<String> engineering = list.stream().map(CsEngineeringUserPO::getEngineeringId).collect(Collectors.toList());
|
||||
result = csEngineeringService.getEngineerings(engineering);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,11 @@ import java.util.List;
|
||||
@Service
|
||||
public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> implements CsLinePOService{
|
||||
|
||||
@Override
|
||||
public List<CsLinePO> getLineByDev(List<String> list) {
|
||||
return this.lambdaQuery().eq(CsLinePO::getDevId,list).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CsLinePO> queryByDevId(String devId) {
|
||||
QueryWrapper<CsLinePO> queryWrapper = new QueryWrapper();
|
||||
|
||||
@@ -6,6 +6,8 @@ import com.njcn.csdevice.pojo.po.CsProjectEquipmentPO;
|
||||
import com.njcn.csdevice.service.CsProjectEquipmentService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -19,4 +21,8 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class CsProjectEquipmentServiceImpl extends ServiceImpl<CsProjectEquipmentMapper, CsProjectEquipmentPO> implements CsProjectEquipmentService {
|
||||
|
||||
@Override
|
||||
public List<CsProjectEquipmentPO> getDeviceByProject(List<String> list) {
|
||||
return this.lambdaQuery().in(CsProjectEquipmentPO::getProjectId,list).list();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import com.njcn.csdevice.pojo.po.AppProjectPO;
|
||||
import com.njcn.csdevice.pojo.po.CsEngineeringPO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.csdevice.pojo.po.CsProjectEquipmentPO;
|
||||
import com.njcn.csdevice.pojo.vo.LedgerTreeVO;
|
||||
import com.njcn.csdevice.service.*;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/5/29 19:53
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class DeviceServiceImpl implements IDeviceService {
|
||||
|
||||
private final ICsEngineeringUserService csEngineeringUserService;
|
||||
|
||||
private final AppProjectService appProjectService;
|
||||
|
||||
private final CsProjectEquipmentService csProjectEquipmentService;
|
||||
|
||||
private final CsLinePOService csLinePOService;
|
||||
|
||||
|
||||
@Override
|
||||
public LedgerTreeVO getLedgerTree() {
|
||||
List<AppProjectPO> list1;
|
||||
List<CsProjectEquipmentPO> list2;
|
||||
List<CsLinePO> list3;
|
||||
List<LedgerTreeVO> children = new ArrayList<>();
|
||||
LedgerTreeVO ledgerTreeVo = new LedgerTreeVO();
|
||||
ledgerTreeVo.setId("0");
|
||||
ledgerTreeVo.setName("台账管理");
|
||||
String userIndex = RequestUtil.getUserIndex();
|
||||
//获取工程
|
||||
List<CsEngineeringPO> list = csEngineeringUserService.getEngineeringByUser(userIndex);
|
||||
if (!CollectionUtils.isEmpty(list)){
|
||||
list.forEach(item->{
|
||||
LedgerTreeVO vo = new LedgerTreeVO();
|
||||
BeanUtils.copyProperties(item,vo);
|
||||
children.add(vo);
|
||||
});
|
||||
ledgerTreeVo.setChildren(children);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// if (!CollectionUtils.isEmpty(list)){
|
||||
// List<String> engineeringList = list.stream().map(CsEngineeringPO::getId).collect(Collectors.toList());
|
||||
// //获取项目
|
||||
// list1 = appProjectService.getProjectByEngineering(engineeringList);
|
||||
// if (!CollectionUtils.isEmpty(list1)){
|
||||
// List<String> projectList = list1.stream().map(AppProjectPO::getId).collect(Collectors.toList());
|
||||
// //获取装置
|
||||
// list2 = csProjectEquipmentService.getDeviceByProject(projectList);
|
||||
// if (!CollectionUtils.isEmpty(list2)){
|
||||
// List<String> deviceList = list2.stream().map(CsProjectEquipmentPO::getId).collect(Collectors.toList());
|
||||
// //获取监测点
|
||||
// list3 = csLinePOService.getLineByDev(deviceList);
|
||||
// list2.stream().map(l2 -> list3.stream().filter(l3 -> Objects.equals(l2.getEquipmentId(), l3.getDevId())).findAny().map(m -> {
|
||||
// LedgerTreeVO vo1 = new LedgerTreeVO();
|
||||
// vo1.setId(m.getLineId());
|
||||
// vo1.setPid(m.getDevId());
|
||||
// vo1.setName(m.getName());
|
||||
// test.add(vo1);
|
||||
// LedgerTreeVO vo = new LedgerTreeVO();
|
||||
// vo.setId(l2.getEquipmentId());
|
||||
// vo.setPid(l2.getProjectId());
|
||||
// vo.setName(l2.getEquipmentId());
|
||||
// vo.setChildren(test);
|
||||
// return vo;
|
||||
// })).collect(Collectors.toList());
|
||||
//
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
return ledgerTreeVo;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -45,7 +45,7 @@ logging:
|
||||
#mybatis配置信息
|
||||
mybatis-plus:
|
||||
#别名扫描
|
||||
type-aliases-package: com.njcn.device.pojo
|
||||
type-aliases-package: com.njcn.csdevice.pojo
|
||||
|
||||
mqtt:
|
||||
client-id: @artifactId@${random.value}
|
||||
@@ -45,7 +45,7 @@ logging:
|
||||
#mybatis配置信息
|
||||
mybatis-plus:
|
||||
#别名扫描
|
||||
type-aliases-package: com.njcn.device.pojo
|
||||
type-aliases-package: com.njcn.csdevice.pojo
|
||||
|
||||
mqtt:
|
||||
client-id: cs-device-boot${random.value}
|
||||
Reference in New Issue
Block a user