提交代码,工程,设备权限,设备数据
This commit is contained in:
@@ -28,4 +28,7 @@ public interface DataArrayFeignClient {
|
||||
|
||||
@PostMapping("/getDataArrayById")
|
||||
HttpResult<List<CsDataArray>> getDataArrayById(@RequestParam("pid") String pid, @RequestParam("name") String name);
|
||||
}
|
||||
@PostMapping("/getDataArrayByIds")
|
||||
HttpResult<List<CsDataArray>> getDataArrayByIds(@RequestParam("ids") List<String> ids);
|
||||
|
||||
}
|
||||
|
||||
@@ -51,6 +51,12 @@ public class DataArrayFeignClientFallbackFactory implements FallbackFactory<Data
|
||||
log.error("{}异常,降级处理,异常为:{}","根据数据集id和名称获取详细数据",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<CsDataArray>> getDataArrayByIds(List<String> ids) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据id集合称获取详细数据",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.njcn.csdevice.pojo.param;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2023/6/27 15:50【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class CsTouristDataParm {
|
||||
@ApiModelProperty(value="工程id")
|
||||
private String enginerId;
|
||||
|
||||
@ApiModelProperty(value="项目id")
|
||||
private String projectId;
|
||||
|
||||
@ApiModelProperty(value="设备id")
|
||||
private String deviceId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.njcn.csdevice.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2023/6/27 9:40【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@ApiModel(description="")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@TableName(value = "cs_device_user")
|
||||
public class CsDeviceUserPO {
|
||||
/**
|
||||
* 主用户id
|
||||
*/
|
||||
@TableField(value = "primary_user_id")
|
||||
@ApiModelProperty(value="主用户id")
|
||||
private String primaryUserId;
|
||||
|
||||
/**
|
||||
* 子用户id
|
||||
*/
|
||||
@TableField(value = "sub_user_id")
|
||||
@ApiModelProperty(value="子用户id")
|
||||
private String subUserId;
|
||||
|
||||
/**
|
||||
* 装置Id
|
||||
*/
|
||||
@TableField(value = "device_id")
|
||||
@ApiModelProperty(value="装置Id")
|
||||
private String deviceId;
|
||||
|
||||
@TableField(value = "create_by")
|
||||
@ApiModelProperty(value="")
|
||||
private String createBy;
|
||||
|
||||
@TableField(value = "create_time")
|
||||
@ApiModelProperty(value="")
|
||||
private Date createTime;
|
||||
|
||||
@TableField(value = "update_by")
|
||||
@ApiModelProperty(value="")
|
||||
private String updateBy;
|
||||
|
||||
@TableField(value = "update_time")
|
||||
@ApiModelProperty(value="")
|
||||
private Date updateTime;
|
||||
|
||||
public static final String COL_PRIMARY_USER_ID = "primary_user_id";
|
||||
|
||||
public static final String COL_SUB_USER_ID = "sub_user_id";
|
||||
|
||||
public static final String COL_DEVICE_ID = "device_id";
|
||||
|
||||
public static final String COL_CREATE_BY = "create_by";
|
||||
|
||||
public static final String COL_CREATE_TIME = "create_time";
|
||||
|
||||
public static final String COL_UPDATE_BY = "update_by";
|
||||
|
||||
public static final String COL_UPDATE_TIME = "update_time";
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.njcn.csdevice.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2023/6/27 15:50【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@TableName(value = "cs_tourist_data")
|
||||
public class CsTouristDataPO {
|
||||
@TableField(value = "enginer_id")
|
||||
private String enginerId;
|
||||
|
||||
@TableField(value = "project_id")
|
||||
private String projectId;
|
||||
|
||||
@TableField(value = "device_id")
|
||||
private String deviceId;
|
||||
|
||||
public static final String COL_ENGINER_ID = "enginer_id";
|
||||
|
||||
public static final String COL_PROJECT_ID = "project_id";
|
||||
|
||||
public static final String COL_DEVICE_ID = "device_id";
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.njcn.csdevice.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2023/6/27 15:50【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class CsTouristDataParmVO {
|
||||
@ApiModelProperty(value="工程id")
|
||||
private String enginerId;
|
||||
@ApiModelProperty(value="工程名称")
|
||||
private String enginerName;
|
||||
|
||||
@ApiModelProperty(value="项目id")
|
||||
private String projectId;
|
||||
@ApiModelProperty(value="项目名称")
|
||||
private String projectName;
|
||||
|
||||
@ApiModelProperty(value="设备id")
|
||||
private String deviceId;
|
||||
|
||||
@ApiModelProperty(value="设备名称")
|
||||
private String deviceName;
|
||||
|
||||
}
|
||||
@@ -83,5 +83,18 @@ public class CsDataArrayController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getDataArrayByIds")
|
||||
@ApiOperation("获取详细数据(id)")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "ids", value = "数据集id", required = true),
|
||||
})
|
||||
@Deprecated
|
||||
public HttpResult<List<CsDataArray>> getDataArrayByIds(@RequestParam("ids") List<String> ids){
|
||||
String methodDescribe = getMethodDescribe("getDataArrayByIds");
|
||||
List<CsDataArray> list = csDataArrayService.getDataArrayByIds(ids);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
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.param.CsTouristDataParm;
|
||||
import com.njcn.csdevice.pojo.vo.CsTouristDataParmVO;
|
||||
import com.njcn.csdevice.service.CsTouristDataPOService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
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.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (cs_tourist_data)表控制层
|
||||
*
|
||||
* @author xxxxx
|
||||
*/
|
||||
@RestController
|
||||
@Slf4j
|
||||
@Api(tags = "游客数据配置")
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/csTouristData")
|
||||
public class CsTouristDataPOController extends BaseController {
|
||||
|
||||
private final CsTouristDataPOService csTouristDataPOService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增游客数据")
|
||||
@ApiImplicitParam(name = "csTouristDataParm", value = "新增工程参数", required = true)
|
||||
public HttpResult<Boolean> add(@Validated @RequestBody List<CsTouristDataParm> csTouristDataParms){
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
|
||||
Boolean flag = csTouristDataPOService.add(csTouristDataParms);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
|
||||
}
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/queryAll")
|
||||
@ApiOperation("查询游客数据")
|
||||
public HttpResult<List<CsTouristDataParmVO>> queryAll(){
|
||||
String methodDescribe = getMethodDescribe("query");
|
||||
|
||||
List<CsTouristDataParmVO> list = csTouristDataPOService.queryAll();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.njcn.csdevice.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2023/6/27 9:40【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
public interface CsDeviceUserPOMapper extends BaseMapper<CsDeviceUserPO> {
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.njcn.csdevice.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsTouristDataPO;
|
||||
import com.njcn.csdevice.pojo.vo.CsTouristDataParmVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2023/6/27 15:50【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
public interface CsTouristDataPOMapper extends BaseMapper<CsTouristDataPO> {
|
||||
List<CsTouristDataParmVO> queryAll();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?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.CsDeviceUserPOMapper">
|
||||
<resultMap id="BaseResultMap" type="com.njcn.csdevice.pojo.po.CsDeviceUserPO">
|
||||
<!--@mbg.generated-->
|
||||
<!--@Table cs_device_user-->
|
||||
<result column="primary_user_id" jdbcType="VARCHAR" property="primaryUserId" />
|
||||
<result column="sub_user_id" jdbcType="VARCHAR" property="subUserId" />
|
||||
<result column="device_id" jdbcType="VARCHAR" property="deviceId" />
|
||||
<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-->
|
||||
primary_user_id, sub_user_id, device_id, create_by, create_time, update_by, update_time
|
||||
</sql>
|
||||
</mapper>
|
||||
@@ -0,0 +1,30 @@
|
||||
<?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.CsTouristDataPOMapper">
|
||||
<resultMap id="BaseResultMap" type="com.njcn.csdevice.pojo.po.CsTouristDataPO">
|
||||
<!--@mbg.generated-->
|
||||
<!--@Table cs_tourist_data-->
|
||||
<result column="enginer_id" jdbcType="VARCHAR" property="enginerId" />
|
||||
<result column="project_id" jdbcType="VARCHAR" property="projectId" />
|
||||
<result column="device_id" jdbcType="VARCHAR" property="deviceId" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
<!--@mbg.generated-->
|
||||
enginer_id, project_id, device_id
|
||||
</sql>
|
||||
|
||||
<select id="queryAll" resultType="com.njcn.csdevice.pojo.vo.CsTouristDataParmVO">
|
||||
SELECT
|
||||
a.device_id,
|
||||
a.enginer_id,
|
||||
a.project_id,
|
||||
b. NAME deviceName,
|
||||
c. NAME projectName,
|
||||
d. NAME enginerName
|
||||
FROM
|
||||
cs_tourist_data a
|
||||
LEFT JOIN cs_ledger b ON a.device_id = b.id
|
||||
LEFT JOIN cs_ledger c ON a.project_id = c.id
|
||||
LEFT JOIN cs_ledger d ON a.enginer_id = d.id;
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.csdevice.service;
|
||||
|
||||
import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2023/6/27 9:40【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
public interface CsDeviceUserPOService extends IService<CsDeviceUserPO>{
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.njcn.csdevice.service;
|
||||
|
||||
import com.njcn.csdevice.pojo.param.CsTouristDataParm;
|
||||
import com.njcn.csdevice.pojo.po.CsTouristDataPO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.csdevice.pojo.vo.CsTouristDataParmVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2023/6/27 15:50【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
public interface CsTouristDataPOService extends IService<CsTouristDataPO>{
|
||||
|
||||
|
||||
Boolean add(List<CsTouristDataParm> csTouristDataParms);
|
||||
|
||||
List<CsTouristDataParmVO> queryAll();
|
||||
}
|
||||
@@ -44,4 +44,5 @@ public interface ICsDataArrayService extends IService<CsDataArray> {
|
||||
|
||||
List<CsDataArray> getDataArrayById(String pid, String name);
|
||||
|
||||
List<CsDataArray> getDataArrayByIds(List<String> ids);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
package com.njcn.csdevice.service;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.JsonArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.njcn.csdevice.mapper.*;
|
||||
import com.njcn.csdevice.pojo.po.*;
|
||||
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
|
||||
import com.njcn.user.enums.AppRoleEnum;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2023/6/27 9:28【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class RoleEngineerDevService {
|
||||
|
||||
private final CsEngineeringUserMapper csEngineeringUserMapper;
|
||||
private final CsDeviceUserPOMapper csDeviceUserPOMapper;
|
||||
private final CsLedgerMapper csLedgerMapper;
|
||||
private final CsEngineeringMapper csEngineeringMapper;
|
||||
private final CsTouristDataPOMapper csTouristDataPOMapper;
|
||||
|
||||
public List<String> getRoleengineer(){
|
||||
String role = RequestUtil.getUserRole();
|
||||
List<String> strings = JSONArray.parseArray(role, String.class);
|
||||
role=strings.get(0);
|
||||
String userIndex = RequestUtil.getUserIndex();
|
||||
QueryWrapper<CsEngineeringUserPO> csEngineeringUserPOQueryWrapper = new QueryWrapper<> ();
|
||||
QueryWrapper<CsDeviceUserPO> csDeviceUserPOQueryWrapper = new QueryWrapper<>();
|
||||
QueryWrapper<CsLedger> csLedgerQueryWrapper = new QueryWrapper<>();
|
||||
|
||||
List<String> collect = new ArrayList<>();
|
||||
if(Objects.equals(role, AppRoleEnum.ENGINEERING_USER.getCode())||
|
||||
Objects.equals(role,AppRoleEnum.MARKET_USER.getCode())||
|
||||
Objects.equals(role,AppRoleEnum.APP_VIP_USER.getCode())){
|
||||
csDeviceUserPOQueryWrapper.clear();
|
||||
csEngineeringUserPOQueryWrapper.clear();
|
||||
csLedgerQueryWrapper.clear();
|
||||
csEngineeringUserPOQueryWrapper.lambda().eq(CsEngineeringUserPO::getUserId,userIndex);
|
||||
List<CsEngineeringUserPO> csEngineeringUserPOS = csEngineeringUserMapper.selectList(csEngineeringUserPOQueryWrapper);
|
||||
collect = csEngineeringUserPOS.stream().map(CsEngineeringUserPO::getEngineeringId).collect(Collectors.toList());
|
||||
csDeviceUserPOQueryWrapper.and(wq -> {
|
||||
wq.eq("primary_user_id", userIndex)
|
||||
.or()
|
||||
.eq("sub_user_id",userIndex);
|
||||
});
|
||||
List<CsDeviceUserPO> csDeviceUserPOS = csDeviceUserPOMapper.selectList(csDeviceUserPOQueryWrapper);
|
||||
List<String> collect1 = csDeviceUserPOS.stream().map(CsDeviceUserPO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
if(CollectionUtils.isEmpty(collect1)){
|
||||
return collect;
|
||||
}else{
|
||||
csLedgerQueryWrapper.in("id",collect1);
|
||||
List<CsLedger> csLedgers = csLedgerMapper.selectList(csLedgerQueryWrapper);
|
||||
List<String> collect2 = csLedgers.stream().map(CsLedger::getPid).distinct().collect(Collectors.toList());
|
||||
csLedgerQueryWrapper.clear();
|
||||
csLedgerQueryWrapper.in("id",collect2);
|
||||
csLedgers = csLedgerMapper.selectList(csLedgerQueryWrapper);
|
||||
List<String> collect3 = csLedgers.stream().map(CsLedger::getPid).distinct().collect(Collectors.toList());
|
||||
collect.addAll(collect3);
|
||||
collect = collect.stream().distinct().collect(Collectors.toList());
|
||||
return collect;
|
||||
}
|
||||
|
||||
}
|
||||
else if (Objects.equals(role,AppRoleEnum.TOURIST.getCode())) {
|
||||
//todo查询配置的游客工程
|
||||
List<CsTouristDataPO> csTouristDataPOS = csTouristDataPOMapper.selectList(null);
|
||||
collect = csTouristDataPOS.stream().map(CsTouristDataPO::getEnginerId).distinct().collect(Collectors.toList());
|
||||
|
||||
}else{
|
||||
List<CsEngineeringPO> csEngineeringPOS = csEngineeringMapper.selectList(null);
|
||||
collect =csEngineeringPOS.stream().map(CsEngineeringPO::getId).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
return collect;
|
||||
}
|
||||
public List<String> getDevice(){
|
||||
String role = RequestUtil.getUserRole();
|
||||
String userIndex = RequestUtil.getUserIndex();
|
||||
QueryWrapper<CsEngineeringUserPO> csEngineeringUserPOQueryWrapper = new QueryWrapper<> ();
|
||||
QueryWrapper<CsDeviceUserPO> csDeviceUserPOQueryWrapper = new QueryWrapper<>();
|
||||
QueryWrapper<CsLedger> csLedgerQueryWrapper = new QueryWrapper<>();
|
||||
|
||||
List<String> collect = new ArrayList<>();
|
||||
if(Objects.equals(role, AppRoleEnum.ENGINEERING_USER.getCode())||
|
||||
Objects.equals(role,AppRoleEnum.MARKET_USER.getCode())||
|
||||
Objects.equals(role,AppRoleEnum.APP_VIP_USER.getCode())){
|
||||
csDeviceUserPOQueryWrapper.clear();
|
||||
csEngineeringUserPOQueryWrapper.clear();
|
||||
csEngineeringUserPOQueryWrapper.lambda().eq(CsEngineeringUserPO::getUserId,userIndex);
|
||||
List<CsEngineeringUserPO> csEngineeringUserPOS = csEngineeringUserMapper.selectList(csEngineeringUserPOQueryWrapper);
|
||||
collect = csEngineeringUserPOS.stream().map(CsEngineeringUserPO::getEngineeringId).collect(Collectors.toList());
|
||||
csDeviceUserPOQueryWrapper.and(wq -> {
|
||||
wq.eq("primary_user_id", userIndex)
|
||||
.or()
|
||||
.eq("sub_user_id",userIndex);
|
||||
});
|
||||
List<CsDeviceUserPO> csDeviceUserPOS = csDeviceUserPOMapper.selectList(csDeviceUserPOQueryWrapper);
|
||||
List<String> collect1 = csDeviceUserPOS.stream().map(CsDeviceUserPO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
return collect1;
|
||||
|
||||
}
|
||||
else if (Objects.equals(role,AppRoleEnum.TOURIST.getCode())) {
|
||||
|
||||
List<CsTouristDataPO> csTouristDataPOS = csTouristDataPOMapper.selectList(null);
|
||||
collect = csTouristDataPOS.stream().map(CsTouristDataPO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
|
||||
}else{
|
||||
csLedgerQueryWrapper.clear();
|
||||
csLedgerQueryWrapper.eq("level",2).eq("state",1);
|
||||
List<CsLedger> csLedgers = csLedgerMapper.selectList(csLedgerQueryWrapper);
|
||||
collect = csLedgers.stream().map(CsLedger::getId).distinct().collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
return collect;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import com.njcn.system.api.EpdFeignClient;
|
||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -125,5 +126,13 @@ public class CsDataArrayServiceImpl extends ServiceImpl<CsDataArrayMapper, CsDat
|
||||
return this.lambdaQuery().eq(CsDataArray::getPid,pid).eq(CsDataArray::getName,name).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CsDataArray> getDataArrayByIds(List<String> ids) {
|
||||
if(CollectionUtils.isEmpty(ids)){
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return this.lambdaQuery().in(CsDataArray::getId,ids).list();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
|
||||
import com.njcn.csdevice.mapper.CsDeviceUserPOMapper;
|
||||
import com.njcn.csdevice.service.CsDeviceUserPOService;
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2023/6/27 9:40【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Service
|
||||
public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper, CsDeviceUserPO> implements CsDeviceUserPOService{
|
||||
|
||||
}
|
||||
@@ -17,10 +17,13 @@ import com.njcn.csdevice.pojo.po.CsEngineeringUserPO;
|
||||
import com.njcn.csdevice.pojo.po.CsLedger;
|
||||
import com.njcn.csdevice.pojo.vo.CsEngineeringVO;
|
||||
import com.njcn.csdevice.service.CsEngineeringService;
|
||||
import com.njcn.csdevice.service.RoleEngineerDevService;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.system.api.AreaFeignClient;
|
||||
import com.njcn.system.pojo.po.Area;
|
||||
import com.njcn.user.enums.AppRoleEnum;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import com.sun.org.apache.bcel.internal.generic.SWITCH;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@@ -50,6 +53,7 @@ public class CsEngineeringServiceImpl extends ServiceImpl<CsEngineeringMapper, C
|
||||
private final RedisUtil redisUtil;
|
||||
private final CsLedgerMapper csLedgerMapper;
|
||||
private final CsEngineeringUserMapper csEngineeringUserMapper;
|
||||
private final RoleEngineerDevService roleEngineerDevService;
|
||||
|
||||
|
||||
|
||||
@@ -109,17 +113,14 @@ public class CsEngineeringServiceImpl extends ServiceImpl<CsEngineeringMapper, C
|
||||
QueryWrapper<CsEngineeringPO> queryWrapper = new QueryWrapper<> ();
|
||||
|
||||
QueryWrapper<CsEngineeringUserPO> csEngineeringUserPOQueryWrapper = new QueryWrapper<> ();
|
||||
//todo 后期修改
|
||||
String userIndex = RequestUtil.getUserIndex();
|
||||
if(!Objects.equals(RequestUtil.getUsername(),"root")){
|
||||
csEngineeringUserPOQueryWrapper.lambda().eq(CsEngineeringUserPO::getUserId,userIndex);
|
||||
List<CsEngineeringUserPO> csEngineeringUserPOS = csEngineeringUserMapper.selectList(csEngineeringUserPOQueryWrapper);
|
||||
List<String> collect = csEngineeringUserPOS.stream().map(CsEngineeringUserPO::getEngineeringId).collect(Collectors.toList());
|
||||
if(CollectionUtil.isEmpty(collect)){
|
||||
/*获取用户下的工程id*/
|
||||
List<String> roleengineer = roleEngineerDevService.getRoleengineer();
|
||||
|
||||
if(CollectionUtil.isEmpty(roleengineer)){
|
||||
return csEngineeringVOList;
|
||||
}
|
||||
queryWrapper.in("id",collect);
|
||||
}
|
||||
queryWrapper.in("id",roleengineer);
|
||||
|
||||
|
||||
|
||||
queryWrapper.eq (StringUtils.isNotBlank (csEngineeringQueryParm.getProvince ()),"province",csEngineeringQueryParm.getProvince ()).
|
||||
@@ -145,17 +146,13 @@ public class CsEngineeringServiceImpl extends ServiceImpl<CsEngineeringMapper, C
|
||||
|
||||
QueryWrapper<CsEngineeringPO> queryWrapper = new QueryWrapper<> ();
|
||||
QueryWrapper<CsEngineeringUserPO> csEngineeringUserPOQueryWrapper = new QueryWrapper<> ();
|
||||
//todo 后期修改
|
||||
String userIndex = RequestUtil.getUserIndex();
|
||||
if(!Objects.equals(RequestUtil.getUsername(),"root")){
|
||||
csEngineeringUserPOQueryWrapper.lambda().eq(CsEngineeringUserPO::getUserId,userIndex);
|
||||
List<CsEngineeringUserPO> csEngineeringUserPOS = csEngineeringUserMapper.selectList(csEngineeringUserPOQueryWrapper);
|
||||
List<String> collect = csEngineeringUserPOS.stream().map(CsEngineeringUserPO::getEngineeringId).collect(Collectors.toList());
|
||||
if(CollectionUtil.isEmpty(collect)){
|
||||
return returnPage;
|
||||
}
|
||||
queryWrapper.in("id",collect);
|
||||
/*获取用户下的工程id*/
|
||||
List<String> roleengineer = roleEngineerDevService.getRoleengineer();
|
||||
|
||||
if(CollectionUtil.isEmpty(roleengineer)){
|
||||
return returnPage;
|
||||
}
|
||||
queryWrapper.in("id",roleengineer);
|
||||
|
||||
queryWrapper.eq (StringUtils.isNotBlank (csEngineeringQueryPageParm.getProvince ()),"province",csEngineeringQueryPageParm.getProvince ()).
|
||||
eq (StringUtils.isNotBlank (csEngineeringQueryPageParm.getCity ()),"city",csEngineeringQueryPageParm.getCity ()).
|
||||
@@ -193,4 +190,6 @@ public class CsEngineeringServiceImpl extends ServiceImpl<CsEngineeringMapper, C
|
||||
return areaName;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.njcn.csdevice.pojo.po.CsLedger;
|
||||
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
|
||||
import com.njcn.csdevice.service.ICsEngineeringUserService;
|
||||
import com.njcn.csdevice.service.ICsLedgerService;
|
||||
import com.njcn.csdevice.service.RoleEngineerDevService;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.system.api.AreaFeignClient;
|
||||
@@ -49,6 +50,8 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
private final CsEngineeringMapper csEngineeringMapper;
|
||||
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
private final RoleEngineerDevService roleEngineerDevService;
|
||||
|
||||
|
||||
@Override
|
||||
public List<CsLedgerVO> getLedgerTree() {
|
||||
@@ -70,14 +73,21 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
List<CsLedgerVO> engineeringList = new ArrayList<>();
|
||||
List<CsLedgerVO> allList = this.baseMapper.getAll();
|
||||
//fixme 这边先根据登录的用户名称来区分是否展示所有的台账信息
|
||||
if (Objects.equals(RequestUtil.getUsername(),"root") || Objects.equals(RequestUtil.getUsername(),"njcnser")){
|
||||
engineeringList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.ENGINEERING_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
|
||||
} else {
|
||||
List<CsEngineeringPO> engineering = csEngineeringUserService.getEngineeringByUser();
|
||||
engineeringList = allList.stream().filter(item->engineering.stream().map(CsEngineeringPO::getId).collect(Collectors.toList()).contains(item.getId())).collect(Collectors.toList());
|
||||
}
|
||||
/*获取用户工程,设备信息过滤*/
|
||||
List<String> roleengineer = roleEngineerDevService.getRoleengineer();
|
||||
List<String> device = roleEngineerDevService.getDevice();
|
||||
engineeringList = allList.stream().filter(item->roleengineer.contains(item.getId())).collect(Collectors.toList());
|
||||
|
||||
// if (Objects.equals(RequestUtil.getUsername(),"root") || Objects.equals(RequestUtil.getUsername(),"njcnser")){
|
||||
// engineeringList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.ENGINEERING_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
|
||||
// } else {
|
||||
// List<CsEngineeringPO> engineering = csEngineeringUserService.getEngineeringByUser();
|
||||
// engineeringList = allList.stream().filter(item->engineering.stream().map(CsEngineeringPO::getId).collect(Collectors.toList()).contains(item.getId())).collect(Collectors.toList());
|
||||
// }
|
||||
List<CsLedgerVO> projectList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
|
||||
List<CsLedgerVO> deviceList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.DEVICE_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
|
||||
// List<CsLedgerVO> deviceList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.DEVICE_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
|
||||
List<CsLedgerVO> deviceList = allList.stream().filter(item -> device.contains(item.getId())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
|
||||
|
||||
List<CsLedgerVO> lineList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.LINE_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
|
||||
deviceList.forEach(dev -> dev.setChildren(getChildren(dev, lineList)));
|
||||
projectList.forEach(pro -> pro.setChildren(getChildren(pro, deviceList)));
|
||||
@@ -89,15 +99,21 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
public List<CsLedgerVO> getDeviceTree() {
|
||||
List<CsLedgerVO> engineeringList = new ArrayList<>();
|
||||
List<CsLedgerVO> allList = this.baseMapper.getAll();
|
||||
/*获取用户工程,设备信息过滤*/
|
||||
List<String> roleengineer = roleEngineerDevService.getRoleengineer();
|
||||
List<String> device = roleEngineerDevService.getDevice();
|
||||
engineeringList = allList.stream().filter(item->roleengineer.contains(item.getId())).collect(Collectors.toList());
|
||||
//fixme 这边先根据登录的用户名称来区分是否展示所有的台账信息
|
||||
if (Objects.equals(RequestUtil.getUsername(),"root")){
|
||||
engineeringList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.ENGINEERING_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
|
||||
} else {
|
||||
List<CsEngineeringPO> engineering = csEngineeringUserService.getEngineeringByUser();
|
||||
engineeringList = allList.stream().filter(item->engineering.stream().map(CsEngineeringPO::getId).collect(Collectors.toList()).contains(item.getId())).collect(Collectors.toList());
|
||||
}
|
||||
// if (Objects.equals(RequestUtil.getUsername(),"root")){
|
||||
// engineeringList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.ENGINEERING_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
|
||||
// } else {
|
||||
// List<CsEngineeringPO> engineering = csEngineeringUserService.getEngineeringByUser();
|
||||
// engineeringList = allList.stream().filter(item->engineering.stream().map(CsEngineeringPO::getId).collect(Collectors.toList()).contains(item.getId())).collect(Collectors.toList());
|
||||
// }
|
||||
List<CsLedgerVO> projectList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
|
||||
List<CsLedgerVO> deviceList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.DEVICE_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
|
||||
// List<CsLedgerVO> deviceList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.DEVICE_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
|
||||
List<CsLedgerVO> deviceList = allList.stream().filter(item -> device.contains(item.getId())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
|
||||
|
||||
projectList.forEach(pro -> pro.setChildren(getChildren(pro, deviceList)));
|
||||
engineeringList.forEach(eng -> eng.setChildren(getChildren(eng, projectList)));
|
||||
return engineeringList;
|
||||
@@ -152,12 +168,14 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
List<CsLedgerVO> engineeringList = new ArrayList<>();
|
||||
List<CsLedgerVO> allList = this.baseMapper.getAll();
|
||||
//fixme 这边先根据登录的用户名称来区分是否展示所有的台账信息
|
||||
if (Objects.equals(RequestUtil.getUsername(),"root") || Objects.equals(RequestUtil.getUsername(),"njcnser")){
|
||||
engineeringList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.ENGINEERING_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
|
||||
} else {
|
||||
List<CsEngineeringPO> engineering = csEngineeringUserService.getEngineeringByUser();
|
||||
engineeringList = allList.stream().filter(item->engineering.stream().map(CsEngineeringPO::getId).collect(Collectors.toList()).contains(item.getId())).collect(Collectors.toList());
|
||||
}
|
||||
// if (Objects.equals(RequestUtil.getUsername(),"root") || Objects.equals(RequestUtil.getUsername(),"njcnser")){
|
||||
// engineeringList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.ENGINEERING_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
|
||||
// } else {
|
||||
// List<CsEngineeringPO> engineering = csEngineeringUserService.getEngineeringByUser();
|
||||
// engineeringList = allList.stream().filter(item->engineering.stream().map(CsEngineeringPO::getId).collect(Collectors.toList()).contains(item.getId())).collect(Collectors.toList());
|
||||
// }
|
||||
List<String> roleengineer = roleEngineerDevService.getRoleengineer();
|
||||
engineeringList = allList.stream().filter(item->roleengineer.contains(item.getId())).collect(Collectors.toList());
|
||||
List<CsLedgerVO> projectList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
|
||||
QueryWrapper<AppTopologyDiagramPO> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("status","1");
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.njcn.csdevice.pojo.param.CsTouristDataParm;
|
||||
import com.njcn.csdevice.pojo.vo.CsTouristDataParmVO;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.csdevice.pojo.po.CsTouristDataPO;
|
||||
import com.njcn.csdevice.mapper.CsTouristDataPOMapper;
|
||||
import com.njcn.csdevice.service.CsTouristDataPOService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2023/6/27 15:50【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Service
|
||||
public class CsTouristDataPOServiceImpl extends ServiceImpl<CsTouristDataPOMapper, CsTouristDataPO> implements CsTouristDataPOService{
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public Boolean add(List<CsTouristDataParm> csTouristDataParms) {
|
||||
QueryWrapper<CsTouristDataPO> QueryWrapper = new QueryWrapper<>();
|
||||
List<CsTouristDataPO> list = new ArrayList<>();
|
||||
csTouristDataParms.forEach(temp->{
|
||||
QueryWrapper.clear();
|
||||
QueryWrapper.eq(CsTouristDataPO.COL_DEVICE_ID,temp.getDeviceId());
|
||||
CsTouristDataPO csTouristDataPO = this.getBaseMapper().selectOne(QueryWrapper);
|
||||
if(Objects.isNull(csTouristDataPO)){
|
||||
return;
|
||||
}
|
||||
CsTouristDataPO csTouristDataPO1 = new CsTouristDataPO();
|
||||
BeanUtils.copyProperties(temp, csTouristDataPO1);
|
||||
list.add(csTouristDataPO1);
|
||||
|
||||
});
|
||||
boolean b = this.saveBatch(list);
|
||||
return b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CsTouristDataParmVO> queryAll() {
|
||||
List<CsTouristDataParmVO> result = this.getBaseMapper().queryAll();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,12 @@
|
||||
<artifactId>common-microservice</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>pqs-influx</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.njcn.csharmonic.param;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2023/6/14 15:09【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Data
|
||||
public class DevicDataTrendQueryParam {
|
||||
@ApiModelProperty(value = "监测点id")
|
||||
@NotBlank(message="监测点id不能为空")
|
||||
private String lineId;
|
||||
@ApiModelProperty(value = "查询指标集合")
|
||||
@NotBlank(message="查询指标不能为空")
|
||||
private List<StatisticalParam> statisticalParams;
|
||||
|
||||
@ApiModelProperty(value = "开始时间")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
@NotNull(message="开始时间不能为空!")
|
||||
private String startTime;
|
||||
|
||||
@ApiModelProperty(value = "结束时间")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
@NotNull(message="结束时间不能为空!")
|
||||
private String endTime;
|
||||
@Data
|
||||
public static class StatisticalParam{
|
||||
private String classId;
|
||||
private String dataId;
|
||||
private String name;
|
||||
private String phase;
|
||||
private String statMethod;
|
||||
private String anotherName;
|
||||
private String unit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -26,6 +26,8 @@ public class ThdDataVO {
|
||||
|
||||
private String statisticalIndex;
|
||||
private String statisticalName;
|
||||
private String unit;
|
||||
private String anotherName;
|
||||
|
||||
|
||||
private Double statisticalData;
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.njcn.csharmonic.controller;
|
||||
|
||||
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.csharmonic.param.CommonStatisticalQueryParam;
|
||||
import com.njcn.csharmonic.param.DevicDataTrendQueryParam;
|
||||
import com.njcn.csharmonic.pojo.vo.ThdDataVO;
|
||||
import com.njcn.csharmonic.service.DeviceDataTrendService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
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.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2023/6/26 9:07【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/datatrend")
|
||||
@Api(tags = "设备数据趋势")
|
||||
@AllArgsConstructor
|
||||
public class DeviceDataTrendController extends BaseController {
|
||||
|
||||
|
||||
private final DeviceDataTrendService deviceDataTrendService;
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/querydatatrend")
|
||||
@ApiOperation("查询设备数据趋势")
|
||||
@ApiImplicitParam(name = "devicDataTrendQueryParam", value = "设备数据趋势参数", required = true)
|
||||
public HttpResult< List<List<ThdDataVO>>> queryDataTrend(@RequestBody DevicDataTrendQueryParam devicDataTrendQueryParam) {
|
||||
String methodDescribe = getMethodDescribe("queryDataTrend");
|
||||
List<List<ThdDataVO>> result = deviceDataTrendService.queryDataTrend(devicDataTrendQueryParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.njcn.csharmonic.service;
|
||||
|
||||
import com.njcn.csharmonic.param.DevicDataTrendQueryParam;
|
||||
import com.njcn.csharmonic.pojo.vo.ThdDataVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2023/6/26 9:14【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
public interface DeviceDataTrendService {
|
||||
List<List<ThdDataVO>> queryDataTrend(DevicDataTrendQueryParam devicDataTrendQueryParam);
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.njcn.csharmonic.service.impl;
|
||||
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.api.DataArrayFeignClient;
|
||||
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
||||
import com.njcn.csdevice.pojo.po.CsDataArray;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.csharmonic.param.DevicDataTrendQueryParam;
|
||||
import com.njcn.csharmonic.pojo.vo.ThdDataVO;
|
||||
import com.njcn.csharmonic.service.DeviceDataTrendService;
|
||||
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
|
||||
import com.njcn.influx.service.CommonService;
|
||||
import com.njcn.system.api.EpdFeignClient;
|
||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2023/6/26 9:14【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DeviceDataTrendServiceImpl implements DeviceDataTrendService {
|
||||
private final EpdFeignClient epdFeignClient;
|
||||
private final CommonService commonService;
|
||||
private final DataArrayFeignClient dataArrayFeignClient;
|
||||
@Override
|
||||
public List<List<ThdDataVO>> queryDataTrend(DevicDataTrendQueryParam devicDataTrendQueryParam) {
|
||||
List<List<ThdDataVO>> result = new ArrayList<>();
|
||||
|
||||
if(CollectionUtils.isEmpty(devicDataTrendQueryParam.getStatisticalParams())){
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
devicDataTrendQueryParam.getStatisticalParams().forEach(temp->{
|
||||
|
||||
List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtDataByTime(Stream.of(devicDataTrendQueryParam.getLineId()).collect(Collectors.toList()),
|
||||
temp.getClassId(),
|
||||
temp.getName(), temp.getPhase(),
|
||||
temp.getStatMethod(),
|
||||
devicDataTrendQueryParam.getStartTime(),
|
||||
devicDataTrendQueryParam.getEndTime());
|
||||
List<ThdDataVO> collect1 = deviceRtData.stream().map(statisticalDataDTO -> {
|
||||
ThdDataVO vo = new ThdDataVO();
|
||||
vo.setLineId(statisticalDataDTO.getLineId());
|
||||
vo.setPhase(statisticalDataDTO.getPhaseType());
|
||||
|
||||
vo.setTime(statisticalDataDTO.getTime().atZone(ZoneId.systemDefault()).toLocalDateTime());
|
||||
vo.setStatMethod(statisticalDataDTO.getValueType());
|
||||
vo.setStatisticalData(BigDecimal.valueOf(statisticalDataDTO.getValue()).setScale(4, RoundingMode.UP).doubleValue());
|
||||
vo.setStatisticalIndex(temp.getDataId());
|
||||
vo.setStatisticalName(temp.getName());
|
||||
vo.setUnit(temp.getUnit());
|
||||
vo.setAnotherName(temp.getAnotherName());
|
||||
return vo;
|
||||
}).collect(Collectors.toList());
|
||||
result.add(collect1);
|
||||
});
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user