代码调整
This commit is contained in:
@@ -4,8 +4,6 @@ import com.njcn.common.pojo.constant.ServerInfo;
|
|||||||
import com.njcn.common.pojo.response.HttpResult;
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
import com.njcn.csdevice.api.fallback.CsLineClientFallbackFactory;
|
import com.njcn.csdevice.api.fallback.CsLineClientFallbackFactory;
|
||||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.njcn.csdevice.pojo.po;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.njcn.db.bo.BaseEntity;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 工程用户关系表
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-05-29
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@TableName("cs_engineering_user")
|
||||||
|
public class CsEngineeringUserPO extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工程表id
|
||||||
|
*/
|
||||||
|
private String engineeringId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户id
|
||||||
|
*/
|
||||||
|
private String userId;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.njcn.csdevice.pojo.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2023/5/29 19:47
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class LedgerTreeVO implements Serializable {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String pid;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private List<LedgerTreeVO> children;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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.po.AppProjectPO;
|
||||||
import com.njcn.csdevice.pojo.vo.AppProjectVO;
|
import com.njcn.csdevice.pojo.vo.AppProjectVO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
@@ -43,4 +45,11 @@ public interface AppProjectService extends IService<AppProjectPO> {
|
|||||||
* @Date: 2023/3/28
|
* @Date: 2023/3/28
|
||||||
*/
|
*/
|
||||||
IPage<AppProjectVO> queryProject(AppProjectQueryParm appProjectQueryParm);
|
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
|
* @Date: 2023/4/12
|
||||||
*/
|
*/
|
||||||
IPage<CsEngineeringVO> queryEngineeringPage(CsEngineeringQueryPageParm csEngineeringQueryPageParm);
|
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>{
|
public interface CsLinePOService extends IService<CsLinePO>{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据装置id获取监测点
|
||||||
|
* @param list
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<CsLinePO> getLineByDev(List<String> list);
|
||||||
|
|
||||||
|
|
||||||
List<CsLinePO> queryByDevId(String devId);
|
List<CsLinePO> queryByDevId(String devId);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package com.njcn.csdevice.service;
|
|||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.njcn.csdevice.pojo.po.CsProjectEquipmentPO;
|
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>{
|
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.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.njcn.csdevice.mapper.AppProjectMapper;
|
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.po.AppProjectPO;
|
||||||
import com.njcn.csdevice.pojo.vo.AppProjectVO;
|
import com.njcn.csdevice.pojo.vo.AppProjectVO;
|
||||||
import com.njcn.csdevice.service.AppProjectService;
|
import com.njcn.csdevice.service.AppProjectService;
|
||||||
@@ -17,6 +20,8 @@ import org.springframework.beans.BeanUtils;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description:
|
* Description:
|
||||||
* 接口文档访问地址:http://serverIP:port/swagger-ui.html
|
* 接口文档访问地址:http://serverIP:port/swagger-ui.html
|
||||||
@@ -122,4 +127,9 @@ public class AppProjectServiceImpl extends ServiceImpl<AppProjectMapper, AppProj
|
|||||||
// ).collect (Collectors.toList ( ));
|
// ).collect (Collectors.toList ( ));
|
||||||
return returnpage;
|
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;
|
return returnPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CsEngineeringPO> getEngineerings(List<String> list) {
|
||||||
|
return this.lambdaQuery().in(CsEngineeringPO::getId,list).list();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getAreaById(String id){
|
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
|
@Service
|
||||||
public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> implements CsLinePOService{
|
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
|
@Override
|
||||||
public List<CsLinePO> queryByDevId(String devId) {
|
public List<CsLinePO> queryByDevId(String devId) {
|
||||||
QueryWrapper<CsLinePO> queryWrapper = new QueryWrapper();
|
QueryWrapper<CsLinePO> queryWrapper = new QueryWrapper();
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import com.njcn.csdevice.pojo.po.CsProjectEquipmentPO;
|
|||||||
import com.njcn.csdevice.service.CsProjectEquipmentService;
|
import com.njcn.csdevice.service.CsProjectEquipmentService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -19,4 +21,8 @@ import org.springframework.stereotype.Service;
|
|||||||
@Service
|
@Service
|
||||||
public class CsProjectEquipmentServiceImpl extends ServiceImpl<CsProjectEquipmentMapper, CsProjectEquipmentPO> implements CsProjectEquipmentService {
|
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配置信息
|
||||||
mybatis-plus:
|
mybatis-plus:
|
||||||
#别名扫描
|
#别名扫描
|
||||||
type-aliases-package: com.njcn.device.pojo
|
type-aliases-package: com.njcn.csdevice.pojo
|
||||||
|
|
||||||
mqtt:
|
mqtt:
|
||||||
client-id: @artifactId@${random.value}
|
client-id: @artifactId@${random.value}
|
||||||
@@ -45,7 +45,7 @@ logging:
|
|||||||
#mybatis配置信息
|
#mybatis配置信息
|
||||||
mybatis-plus:
|
mybatis-plus:
|
||||||
#别名扫描
|
#别名扫描
|
||||||
type-aliases-package: com.njcn.device.pojo
|
type-aliases-package: com.njcn.csdevice.pojo
|
||||||
|
|
||||||
mqtt:
|
mqtt:
|
||||||
client-id: cs-device-boot${random.value}
|
client-id: cs-device-boot${random.value}
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
package com.njcn.system.api;
|
|
||||||
|
|
||||||
import com.njcn.common.pojo.constant.ServerInfo;
|
|
||||||
import com.njcn.common.pojo.response.HttpResult;
|
|
||||||
import com.njcn.system.api.fallback.EpdFeignClientFallbackFactory;
|
|
||||||
import com.njcn.system.pojo.param.EleEpdPqdParam;
|
|
||||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
|
||||||
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.RequestParam;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author hongawen
|
|
||||||
* @version 1.0.0
|
|
||||||
* @date 2021年05月08日 15:11
|
|
||||||
*/
|
|
||||||
@FeignClient(value = ServerInfo.CS_SYSTEM_BOOT,path = "/csDictData",fallbackFactory = EpdFeignClientFallbackFactory.class,contextId = "csDictData")
|
|
||||||
public interface EpdFeignClient {
|
|
||||||
|
|
||||||
@PostMapping("/addByModel")
|
|
||||||
HttpResult<String> addByModel(@RequestBody List<EleEpdPqdParam> eleEpdPqdParam);
|
|
||||||
|
|
||||||
@PostMapping("/dictMarkByDataType")
|
|
||||||
HttpResult<List<EleEpdPqd>> dictMarkByDataType(@RequestParam("dataType") String dataType);
|
|
||||||
|
|
||||||
@PostMapping("/addEvt")
|
|
||||||
HttpResult<Map<String,String>> addEvt(@RequestBody List<EleEpdPqdParam> eleEpdPqdParam);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
package com.njcn.system.api.fallback;
|
|
||||||
|
|
||||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
|
||||||
import com.njcn.common.pojo.response.HttpResult;
|
|
||||||
import com.njcn.system.api.EpdFeignClient;
|
|
||||||
import com.njcn.system.pojo.param.EleEpdPqdParam;
|
|
||||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
|
||||||
import com.njcn.system.utils.CsSystemEnumUtil;
|
|
||||||
import feign.hystrix.FallbackFactory;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 类的介绍:
|
|
||||||
*
|
|
||||||
* @author xuyang
|
|
||||||
* @version 1.0.0
|
|
||||||
* @createTime 2023/5/24 18:46
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
|
||||||
public class EpdFeignClientFallbackFactory implements FallbackFactory<EpdFeignClient> {
|
|
||||||
@Override
|
|
||||||
public EpdFeignClient create(Throwable cause) {
|
|
||||||
//判断抛出异常是否为解码器抛出的业务异常
|
|
||||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
|
||||||
if(cause.getCause() instanceof BusinessException){
|
|
||||||
BusinessException businessException = (BusinessException) cause.getCause();
|
|
||||||
exceptionEnum = CsSystemEnumUtil.getExceptionEnum(businessException.getResult());
|
|
||||||
}
|
|
||||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
|
||||||
return new EpdFeignClient() {
|
|
||||||
@Override
|
|
||||||
public HttpResult<String> addByModel(List<EleEpdPqdParam> eleEpdPqdParam) {
|
|
||||||
log.error("{}异常,降级处理,异常为:{}","通过模板录入字典数据",cause.toString());
|
|
||||||
throw new BusinessException(finalExceptionEnum);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HttpResult<List<EleEpdPqd>> dictMarkByDataType(String dataType) {
|
|
||||||
log.error("{}异常,降级处理,异常为:{}","通过数据模型获取字典数据组装唯一标识",cause.toString());
|
|
||||||
throw new BusinessException(finalExceptionEnum);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HttpResult<Map<String, String>> addEvt(List<EleEpdPqdParam> eleEpdPqdParam) {
|
|
||||||
log.error("{}异常,降级处理,异常为:{}","录入事件字典",cause.toString());
|
|
||||||
throw new BusinessException(finalExceptionEnum);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,134 +0,0 @@
|
|||||||
package com.njcn.system.controller;
|
|
||||||
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
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.common.utils.LogUtil;
|
|
||||||
import com.njcn.system.pojo.param.EleEpdPqdParam;
|
|
||||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
|
||||||
import com.njcn.system.pojo.vo.EleEpdPqdVO;
|
|
||||||
import com.njcn.system.service.IEleEpdPqdService;
|
|
||||||
import com.njcn.web.controller.BaseController;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import jdk.nashorn.internal.ir.annotations.Ignore;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import springfox.documentation.annotations.ApiIgnore;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 前端控制器
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author xuyang
|
|
||||||
* @since 2023-05-24
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/csDictData")
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
@Api(tags = "数据字典")
|
|
||||||
@Validated
|
|
||||||
public class EleEpdPqdController extends BaseController {
|
|
||||||
|
|
||||||
private final IEleEpdPqdService eleEpdPqdService;
|
|
||||||
|
|
||||||
@PostMapping("/addByModel")
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
|
||||||
@ApiOperation("根据模板录入字典数据")
|
|
||||||
@ApiImplicitParam(name = "eleEpdPqdParam", value = "模板的字典数据", required = true)
|
|
||||||
@ApiIgnore
|
|
||||||
public HttpResult<String> addByModel(@RequestBody @Validated List<EleEpdPqdParam> eleEpdPqdParam){
|
|
||||||
log.info("根据模板录入字典数据");
|
|
||||||
String methodDescribe = getMethodDescribe("addByModel");
|
|
||||||
LogUtil.njcnDebug(log, "{},模板当前解析字典数据为:", methodDescribe);
|
|
||||||
eleEpdPqdService.saveData(eleEpdPqdParam);
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/add")
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
|
||||||
@ApiOperation("新增字典数据")
|
|
||||||
@ApiImplicitParam(name = "eleEpdPqdParam", value = "字典数据", required = true)
|
|
||||||
public HttpResult<String> add(@RequestBody @Validated EleEpdPqdParam eleEpdPqdParam){
|
|
||||||
log.info("录入字典数据");
|
|
||||||
String methodDescribe = getMethodDescribe("add");
|
|
||||||
LogUtil.njcnDebug(log, "{},模板当前解析字典数据为:", methodDescribe);
|
|
||||||
eleEpdPqdService.add(eleEpdPqdParam);
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/delete")
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
|
||||||
@ApiOperation("删除字典数据")
|
|
||||||
@ApiImplicitParam(name = "id", value = "字典数据id", required = true)
|
|
||||||
public HttpResult<String> delete(@RequestParam String id){
|
|
||||||
log.info("删除字典数据");
|
|
||||||
String methodDescribe = getMethodDescribe("delete");
|
|
||||||
LogUtil.njcnDebug(log, "{},字典id为:", methodDescribe);
|
|
||||||
eleEpdPqdService.delete(id);
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/update")
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
|
||||||
@ApiOperation("更新字典数据")
|
|
||||||
@ApiImplicitParam(name = "updateParam", value = "字典数据", required = true)
|
|
||||||
public HttpResult<String> update(@RequestBody @Validated EleEpdPqdParam.EleEpdPqdUpdateParam updateParam){
|
|
||||||
log.info("更新字典数据");
|
|
||||||
String methodDescribe = getMethodDescribe("update");
|
|
||||||
LogUtil.njcnDebug(log, "{},字典数据为:", updateParam);
|
|
||||||
eleEpdPqdService.update(updateParam);
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
|
||||||
@PostMapping("/list")
|
|
||||||
@ApiOperation("列表分页")
|
|
||||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
|
||||||
public HttpResult<Page<EleEpdPqdVO>> getList(@RequestBody @Validated EleEpdPqdParam.EleEpdPqdQueryParam queryParam) {
|
|
||||||
String methodDescribe = getMethodDescribe("getList");
|
|
||||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
|
||||||
Page<EleEpdPqdVO> list = eleEpdPqdService.eleEpdPqdList(queryParam);
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
|
||||||
@PostMapping("/dictMarkByDataType")
|
|
||||||
@ApiOperation("字典数据组装唯一标识")
|
|
||||||
@ApiImplicitParam(name = "dataType", value = "数据模型", required = true)
|
|
||||||
@ApiIgnore
|
|
||||||
public HttpResult<List<EleEpdPqd>> dictMarkByDataType(@RequestParam("dataType") @Validated String dataType) {
|
|
||||||
String methodDescribe = getMethodDescribe("dictMark");
|
|
||||||
List<EleEpdPqd> list = eleEpdPqdService.dictMarkByDataType(dataType);
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/addEvt")
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
|
||||||
@ApiOperation("事件录入字典数据")
|
|
||||||
@ApiImplicitParam(name = "eleEpdPqdParam", value = "模板的字典数据", required = true)
|
|
||||||
@ApiIgnore
|
|
||||||
public HttpResult<Map<String,String>> addEvt(@RequestBody @Validated List<EleEpdPqdParam> eleEpdPqdParam){
|
|
||||||
log.info("根据模板录入字典数据");
|
|
||||||
String methodDescribe = getMethodDescribe("addEvt");
|
|
||||||
LogUtil.njcnDebug(log, "{},模板当前解析字典数据为:", methodDescribe);
|
|
||||||
Map<String,String> map = eleEpdPqdService.saveEvt(eleEpdPqdParam);
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, map, methodDescribe);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
package com.njcn.system.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
|
||||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
|
||||||
import com.njcn.system.pojo.vo.EleEpdPqdVO;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* Mapper 接口
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author xuyang
|
|
||||||
* @since 2023-05-24
|
|
||||||
*/
|
|
||||||
public interface EleEpdPqdMapper extends MppBaseMapper<EleEpdPqd> {
|
|
||||||
|
|
||||||
Page<EleEpdPqdVO> page(@Param("page")Page<EleEpdPqdVO> page, @Param("ew") QueryWrapper<EleEpdPqdVO> queryWrapper);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,11 +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.system.mapper.EleEpdPqdMapper">
|
|
||||||
|
|
||||||
<select id="page" resultType="EleEpdPqdVO">
|
|
||||||
SELECT t0.*
|
|
||||||
FROM ele_epd_pqd t0
|
|
||||||
${ew.sqlSegment}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
</mapper>
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
package com.njcn.system.service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.njcn.system.pojo.param.EleEpdPqdParam;
|
|
||||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
|
||||||
import com.njcn.system.pojo.vo.EleEpdPqdVO;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 服务类
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author xuyang
|
|
||||||
* @since 2023-05-24
|
|
||||||
*/
|
|
||||||
public interface IEleEpdPqdService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 存储模板的字典数据
|
|
||||||
* @param eleEpdPqdParam
|
|
||||||
*/
|
|
||||||
void saveData(List<EleEpdPqdParam> eleEpdPqdParam);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 存储字典数据
|
|
||||||
* @param eleEpdPqdParam
|
|
||||||
*/
|
|
||||||
void add(EleEpdPqdParam eleEpdPqdParam);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除字典数据
|
|
||||||
* @param id
|
|
||||||
*/
|
|
||||||
void delete(String id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新字典数据
|
|
||||||
* @param updateParam
|
|
||||||
*/
|
|
||||||
void update(EleEpdPqdParam.EleEpdPqdUpdateParam updateParam);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询字典分页
|
|
||||||
* @param queryParam
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Page<EleEpdPqdVO> eleEpdPqdList(EleEpdPqdParam.EleEpdPqdQueryParam queryParam);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询所有字典数据组成唯一标识,用于验证字典是否重复
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<EleEpdPqd> dictMarkByDataType(String dataType);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 存储事件的字典数据
|
|
||||||
* @param eleEpdPqdParam
|
|
||||||
*/
|
|
||||||
Map<String,String> saveEvt(List<EleEpdPqdParam> eleEpdPqdParam);
|
|
||||||
}
|
|
||||||
@@ -1,146 +0,0 @@
|
|||||||
package com.njcn.system.service.impl;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
|
||||||
import com.njcn.db.constant.DbConstant;
|
|
||||||
import com.njcn.system.enums.CsSystemResponseEnum;
|
|
||||||
import com.njcn.system.mapper.EleEpdPqdMapper;
|
|
||||||
import com.njcn.system.pojo.param.EleEpdPqdParam;
|
|
||||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
|
||||||
import com.njcn.system.pojo.vo.EleEpdPqdVO;
|
|
||||||
import com.njcn.system.service.IEleEpdPqdService;
|
|
||||||
import com.njcn.web.factory.PageFactory;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.springframework.beans.BeanUtils;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 服务实现类
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author xuyang
|
|
||||||
* @since 2023-05-24
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class EleEpdPqdServiceImpl extends MppServiceImpl<EleEpdPqdMapper, EleEpdPqd> implements IEleEpdPqdService {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void saveData(List<EleEpdPqdParam> eleEpdPqdParam) {
|
|
||||||
List<EleEpdPqd> list = eleEpdPqdParam.stream().map(item->{
|
|
||||||
EleEpdPqd eleEpdPqd = new EleEpdPqd();
|
|
||||||
BeanUtils.copyProperties(item,eleEpdPqd);
|
|
||||||
if (StringUtils.isBlank(item.getType())){
|
|
||||||
eleEpdPqd.setType("");
|
|
||||||
}
|
|
||||||
return eleEpdPqd;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
this.saveBatch(list,1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void add(EleEpdPqdParam eleEpdPqdParam) {
|
|
||||||
checkEleEpdPqdParam(eleEpdPqdParam,false);
|
|
||||||
EleEpdPqd eleEpdPqd = new EleEpdPqd();
|
|
||||||
BeanUtils.copyProperties(eleEpdPqdParam,eleEpdPqd);
|
|
||||||
this.save(eleEpdPqd);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete(String id) {
|
|
||||||
this.baseMapper.deleteById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(EleEpdPqdParam.EleEpdPqdUpdateParam updateParam) {
|
|
||||||
checkEleEpdPqdParam(updateParam,true);
|
|
||||||
EleEpdPqd eleEpdPqd = new EleEpdPqd();
|
|
||||||
BeanUtils.copyProperties(updateParam,eleEpdPqd);
|
|
||||||
this.updateById(eleEpdPqd);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<EleEpdPqdVO> eleEpdPqdList(EleEpdPqdParam.EleEpdPqdQueryParam queryParam) {
|
|
||||||
QueryWrapper<EleEpdPqdVO> queryWrapper = new QueryWrapper<EleEpdPqdVO>();
|
|
||||||
if (ObjectUtil.isNotNull(queryParam)) {
|
|
||||||
//查询参数不为空,进行条件填充
|
|
||||||
if (StrUtil.isNotBlank(queryParam.getSearchValue())) {
|
|
||||||
//部门根据名称模糊查询
|
|
||||||
queryWrapper
|
|
||||||
.and(param -> param.like("ele_epd_pqd.Name", queryParam.getSearchValue())
|
|
||||||
.or().like("ele_epd_pqd.Other_Name", queryParam.getSearchValue())
|
|
||||||
.or().like("ele_epd_pqd.Show_Name", queryParam.getSearchValue()));
|
|
||||||
}
|
|
||||||
//排序
|
|
||||||
if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) {
|
|
||||||
queryWrapper.orderBy(true, queryParam.getOrderBy().equalsIgnoreCase(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy()));
|
|
||||||
} else {
|
|
||||||
//默认根据sort排序
|
|
||||||
queryWrapper.orderBy(true, true, "Sort");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this.baseMapper.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), queryWrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<EleEpdPqd> dictMarkByDataType(String dataType) {
|
|
||||||
LambdaQueryWrapper<EleEpdPqd> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
lambdaQueryWrapper.eq(EleEpdPqd::getDataType,dataType);
|
|
||||||
return this.baseMapper.selectList(lambdaQueryWrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, String> saveEvt(List<EleEpdPqdParam> eleEpdPqdParam) {
|
|
||||||
List<EleEpdPqd> list = eleEpdPqdParam.stream().map(item->{
|
|
||||||
EleEpdPqd eleEpdPqd = new EleEpdPqd();
|
|
||||||
BeanUtils.copyProperties(item,eleEpdPqd);
|
|
||||||
if (StringUtils.isBlank(item.getType())){
|
|
||||||
eleEpdPqd.setType("");
|
|
||||||
}
|
|
||||||
return eleEpdPqd;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
this.saveBatch(list,1000);
|
|
||||||
List<String> nameList = eleEpdPqdParam.stream().map(EleEpdPqdParam::getName).collect(Collectors.toList());
|
|
||||||
LambdaQueryWrapper<EleEpdPqd> lambdaQueryWrapper = new LambdaQueryWrapper<EleEpdPqd>();
|
|
||||||
lambdaQueryWrapper.in(EleEpdPqd::getName,nameList);
|
|
||||||
List<EleEpdPqd> list1 = this.baseMapper.selectList(lambdaQueryWrapper);
|
|
||||||
Map<String,String> map = new HashMap<>();
|
|
||||||
list1.forEach(item->{
|
|
||||||
map.put(item.getName(),item.getId());
|
|
||||||
});
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验参数,
|
|
||||||
* 1.检查是否存在相同名称的菜单
|
|
||||||
* 名称 && 路径做唯一判断
|
|
||||||
*/
|
|
||||||
private void checkEleEpdPqdParam(EleEpdPqdParam eleEpdPqdParam, boolean isExcludeSelf) {
|
|
||||||
LambdaQueryWrapper<EleEpdPqd> eleEpdPqdLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
eleEpdPqdLambdaQueryWrapper
|
|
||||||
.eq(EleEpdPqd::getName, eleEpdPqdParam.getName())
|
|
||||||
.eq(EleEpdPqd::getPhase, eleEpdPqdParam.getPhase())
|
|
||||||
.eq(EleEpdPqd::getClassId,eleEpdPqdParam.getClassId())
|
|
||||||
.eq(EleEpdPqd::getDataType, eleEpdPqdParam.getDataType());
|
|
||||||
//更新的时候,需排除当前记录
|
|
||||||
if (isExcludeSelf) {
|
|
||||||
if (eleEpdPqdParam instanceof EleEpdPqdParam.EleEpdPqdUpdateParam) {
|
|
||||||
eleEpdPqdLambdaQueryWrapper.ne(EleEpdPqd::getId, ((EleEpdPqdParam.EleEpdPqdUpdateParam) eleEpdPqdParam).getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int countByAccount = this.count(eleEpdPqdLambdaQueryWrapper);
|
|
||||||
//大于等于1个则表示重复
|
|
||||||
if (countByAccount >= 1) {
|
|
||||||
throw new BusinessException(CsSystemResponseEnum.DICT_REPEAT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user