From 2f3d783999935f06228705e75fac26ebf099bf87 Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期五, 15 四月 2022 18:02:14 +0800
Subject: [PATCH] fix
---
dao/src/main/resources/mapper/LightMapper.xml | 2
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightTaskService.java | 12 ++-
dao/src/main/resources/mapper/LightTaskMapper.xml | 1
dao/src/main/java/com/sandu/ximon/dao/domain/LightTask.java | 14 +++-
dao/src/main/resources/mapper/LightReportErrorMapper.xml | 7 ++
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportDataService.java | 34 ++++++++++-
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportErrorService.java | 14 +++-
dao/src/main/java/com/sandu/ximon/dao/mapper/LightReportErrorMapper.java | 2
dao/src/main/java/com/sandu/ximon/dao/mapper/LightReportDataMapper.java | 14 ++++
dao/src/main/resources/mapper/LightReportDataMapper.xml | 65 +++++++++++++++------
10 files changed, 128 insertions(+), 37 deletions(-)
diff --git a/dao/src/main/java/com/sandu/ximon/dao/domain/LightTask.java b/dao/src/main/java/com/sandu/ximon/dao/domain/LightTask.java
index 660b7ef..f271cf8 100644
--- a/dao/src/main/java/com/sandu/ximon/dao/domain/LightTask.java
+++ b/dao/src/main/java/com/sandu/ximon/dao/domain/LightTask.java
@@ -4,22 +4,30 @@
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
+
import java.io.Serializable;
import java.time.LocalDateTime;
+
import lombok.Data;
/**
* 璺伅浠诲姟琛�
+ *
* @TableName light_task
*/
-@TableName(value ="light_task")
+@TableName(value = "light_task")
@Data
public class LightTask implements Serializable {
/**
- *
+ *
*/
@TableId(type = IdType.AUTO)
private Long taskId;
+
+ /**
+ * 鐢ㄦ埛id
+ */
+ private Long userId;
/**
* 瀹㈡埛id
@@ -72,7 +80,7 @@
private LocalDateTime createTime;
/**
- *
+ *
*/
private LocalDateTime updateTime;
diff --git a/dao/src/main/java/com/sandu/ximon/dao/mapper/LightReportDataMapper.java b/dao/src/main/java/com/sandu/ximon/dao/mapper/LightReportDataMapper.java
index 40ea701..45d0245 100644
--- a/dao/src/main/java/com/sandu/ximon/dao/mapper/LightReportDataMapper.java
+++ b/dao/src/main/java/com/sandu/ximon/dao/mapper/LightReportDataMapper.java
@@ -15,6 +15,7 @@
/**
* 鑾峰彇鎸囧畾璁惧鍚楁渶鏂颁笂鎶ョ殑涓�鏉℃暟鎹�
+ *
* @param deviceCodeList 鎸囧畾璁惧鐮�
* @return 涓婃姤鏁版嵁
*/
@@ -23,11 +24,22 @@
/**
* 鑾峰彇涓婃姤鏁版嵁鍒楄〃
- * @param keyword 鍏抽敭璇�
+ *
+ * @param keyword 鍏抽敭璇�
* @param deviceCode 璁惧鐮�
* @return 涓婃姤鏁版嵁
*/
List<LightReportDataBo> listReportData(String keyword, String deviceCode);
+
+ /**
+ * 甯︾敤鎴稩D鏌ヨ
+ *
+ * @param keyword
+ * @param deviceCode
+ * @param userid
+ * @return
+ */
+ List<LightReportDataBo> listReportDataByUserid(String keyword, String deviceCode, Long userid);
}
diff --git a/dao/src/main/java/com/sandu/ximon/dao/mapper/LightReportErrorMapper.java b/dao/src/main/java/com/sandu/ximon/dao/mapper/LightReportErrorMapper.java
index e451d0c..40965de 100644
--- a/dao/src/main/java/com/sandu/ximon/dao/mapper/LightReportErrorMapper.java
+++ b/dao/src/main/java/com/sandu/ximon/dao/mapper/LightReportErrorMapper.java
@@ -18,7 +18,7 @@
* @param keyword 鍏抽敭璇�
* @return 鏁呴殰鐮佸垪琛�
*/
- List<LightReportErrorBo> listReportError(String keyword);
+ List<LightReportErrorBo> listReportError(String keyword, Long userid);
}
diff --git a/dao/src/main/resources/mapper/LightMapper.xml b/dao/src/main/resources/mapper/LightMapper.xml
index ccc88cc..98dae03 100644
--- a/dao/src/main/resources/mapper/LightMapper.xml
+++ b/dao/src/main/resources/mapper/LightMapper.xml
@@ -36,7 +36,7 @@
LEFT JOIN light_task t4 ON t3.task_id = t4.task_id
<where>
<if test="clientId != null">
- AND t2.client_id = #{clientId}
+ AND (t2.user_id = #{clientId} OR t2.client_id = #{clientId})
</if>
<if test="keyword != null and keyword != ''">
AND (
diff --git a/dao/src/main/resources/mapper/LightReportDataMapper.xml b/dao/src/main/resources/mapper/LightReportDataMapper.xml
index b1456bd..97db43a 100644
--- a/dao/src/main/resources/mapper/LightReportDataMapper.xml
+++ b/dao/src/main/resources/mapper/LightReportDataMapper.xml
@@ -5,22 +5,22 @@
<mapper namespace="com.sandu.ximon.dao.mapper.LightReportDataMapper">
<resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.LightReportData">
- <id property="lightReportDataId" column="light_report_data_id" jdbcType="BIGINT"/>
- <result property="deviceCode" column="device_code" jdbcType="VARCHAR"/>
- <result property="voltage" column="voltage" jdbcType="FLOAT"/>
- <result property="electricCurrent" column="electric_current" jdbcType="FLOAT"/>
- <result property="deviceTemperature" column="device_temperature" jdbcType="FLOAT"/>
- <result property="powerFactor" column="power_factor" jdbcType="FLOAT"/>
- <result property="activePower" column="active_power" jdbcType="FLOAT"/>
- <result property="reactivePower" column="reactive_power" jdbcType="FLOAT"/>
- <result property="lightPercent" column="light_percent" jdbcType="INTEGER"/>
- <result property="light2Percent" column="light2_percent" jdbcType="INTEGER"/>
- <result property="recentlyLightSec" column="recently_light_sec" jdbcType="BIGINT"/>
- <result property="totalLightSec" column="total_light_sec" jdbcType="BIGINT"/>
- <result property="recentlyUsingPower" column="recently_using_power" jdbcType="DOUBLE"/>
- <result property="totalUsingPower" column="total_using_power" jdbcType="DOUBLE"/>
- <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
- <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
+ <id property="lightReportDataId" column="light_report_data_id" jdbcType="BIGINT"/>
+ <result property="deviceCode" column="device_code" jdbcType="VARCHAR"/>
+ <result property="voltage" column="voltage" jdbcType="FLOAT"/>
+ <result property="electricCurrent" column="electric_current" jdbcType="FLOAT"/>
+ <result property="deviceTemperature" column="device_temperature" jdbcType="FLOAT"/>
+ <result property="powerFactor" column="power_factor" jdbcType="FLOAT"/>
+ <result property="activePower" column="active_power" jdbcType="FLOAT"/>
+ <result property="reactivePower" column="reactive_power" jdbcType="FLOAT"/>
+ <result property="lightPercent" column="light_percent" jdbcType="INTEGER"/>
+ <result property="light2Percent" column="light2_percent" jdbcType="INTEGER"/>
+ <result property="recentlyLightSec" column="recently_light_sec" jdbcType="BIGINT"/>
+ <result property="totalLightSec" column="total_light_sec" jdbcType="BIGINT"/>
+ <result property="recentlyUsingPower" column="recently_using_power" jdbcType="DOUBLE"/>
+ <result property="totalUsingPower" column="total_using_power" jdbcType="DOUBLE"/>
+ <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
+ <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<resultMap id="listReportData" type="com.sandu.ximon.dao.bo.LightReportDataBo" extends="BaseResultMap">
@@ -46,10 +46,10 @@
</select>
<select id="listReportData" resultMap="listReportData">
SELECT
- t1.* ,t2.pole_name
+ t1.* ,t2.pole_name
FROM
- light_report_data t1
- LEFT JOIN pole t2 USING ( device_code )
+ light_report_data t1
+ LEFT JOIN pole t2 USING ( device_code )
<where>
1 = 1
@@ -66,4 +66,31 @@
</where>
ORDER BY t1.light_report_data_id DESC
</select>
+ <select id="listReportDataByUserid" resultType="com.sandu.ximon.dao.bo.LightReportDataBo">
+ SELECT
+ t1.* ,t2.pole_name
+ FROM
+ light_report_data t1
+ LEFT JOIN pole_binding t2 ON t1.device_code = t2.device_code
+ AND t2.device_type = 0
+ LEFT JOIN pole t3 ON t3.id = t2.pole_id
+ <where>
+ 1 = 1
+
+ <if test="deviceCode != null and deviceCode != ''">
+ AND t1.device_code = #{deviceCode}
+ </if>
+ <if test="keyword != null and keyword != ''">
+ AND (
+ t1.device_code LIKE CONCAT('%', #{keyword},'%')
+ OR t2.pole_name LIKE CONCAT('%', #{keyword},'%')
+ )
+ </if>
+ <if test="userid != null">
+ AND (t3.user_id = #{userid} OR t3.client_id = #{userid})
+ </if>
+
+ </where>
+ ORDER BY t1.light_report_data_id DESC
+ </select>
</mapper>
diff --git a/dao/src/main/resources/mapper/LightReportErrorMapper.xml b/dao/src/main/resources/mapper/LightReportErrorMapper.xml
index c578b23..a9dff15 100644
--- a/dao/src/main/resources/mapper/LightReportErrorMapper.xml
+++ b/dao/src/main/resources/mapper/LightReportErrorMapper.xml
@@ -21,7 +21,9 @@
t2.pole_name
FROM
light_report_error t1
- LEFT JOIN pole t2 USING ( device_code )
+ LEFT JOIN pole_binding t2 ON t1.device_code = t2.device_code
+ AND t2.device_type = 0
+ LEFT JOIN pole t3 ON t3.id = t2.pole_id
<where>
<if test="keyword != null and keyword != ''">
AND (
@@ -29,6 +31,9 @@
OR t2.pole_name LIKE CONCAT('%', #{keyword},'%')
)
</if>
+ <if test="userid != null">
+ AND (t3.user_id = #{userid} OR t3.client_id = #{userid})
+ </if>
</where>
ORDER BY t1.light_report_error_id DESC
</select>
diff --git a/dao/src/main/resources/mapper/LightTaskMapper.xml b/dao/src/main/resources/mapper/LightTaskMapper.xml
index a6744f4..b89949d 100644
--- a/dao/src/main/resources/mapper/LightTaskMapper.xml
+++ b/dao/src/main/resources/mapper/LightTaskMapper.xml
@@ -7,6 +7,7 @@
<resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.LightTask">
<id property="taskId" column="task_id" jdbcType="BIGINT"/>
<result property="clientId" column="client_id" jdbcType="BIGINT"/>
+ <result property="userId" column="user_id" jdbcType="BIGINT"/>
<result property="taskName" column="task_name" jdbcType="VARCHAR"/>
<result property="pause" column="pause" jdbcType="TINYINT"/>
<result property="week" column="week" jdbcType="TINYINT"/>
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportDataService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportDataService.java
index 54b4d4e..f26d49c 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportDataService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportDataService.java
@@ -5,15 +5,21 @@
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageHelper;
+import com.sandu.common.execption.BusinessException;
import com.sandu.common.file.FileUploadDto;
import com.sandu.common.file.config.FileProperties;
import com.sandu.common.file.impl.AliOssFileServiceImpl;
import com.sandu.common.service.impl.BaseServiceImpl;
import com.sandu.common.util.ResUtils;
+import com.sandu.common.util.SpringContextHolder;
import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5LightHeartbeatReportInnerFrame;
+import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.dao.bo.LightReportDataBo;
import com.sandu.ximon.dao.domain.LightReportData;
+import com.sandu.ximon.dao.domain.Pole;
+import com.sandu.ximon.dao.domain.PoleBinding;
import com.sandu.ximon.dao.mapper.LightReportDataMapper;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
@@ -23,6 +29,7 @@
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
+import java.sql.Wrapper;
import java.util.List;
/**
@@ -68,11 +75,32 @@
*/
public List<LightReportDataBo> listReportData(int pageNo, int pageSize, String keyword, String deviceCode) {
PageHelper.startPage(pageNo, pageSize);
- return baseMapper.listReportData(keyword, deviceCode);
+ //涓簄ull鐨勮瘽鏄秴绠�
+ if (SecurityUtils.getClientId() == null) {
+ return baseMapper.listReportData(keyword, deviceCode);
+ } else {
+ return baseMapper.listReportDataByUserid(keyword, deviceCode, SecurityUtils.getUserId());
+ }
}
@SneakyThrows
public String exportList(int pageNo, int pageSize, String keyword, String deviceCode) {
+
+ if (SecurityUtils.getClientId() != null) {
+ PoleBinding one = SpringContextHolder.getBean(PoleBindingService.class).getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, deviceCode)
+ .eq(PoleBinding::getDeviceType, 0));
+ if (one == null) {
+ throw new BusinessException("鏈壘鍒扮粦瀹氬叧绯伙紒");
+ } else {
+ Pole pole = SpringContextHolder.getBean(PoleService.class).getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getUserId, SecurityUtils.getUserId()).or(w -> {
+ w.eq(Pole::getClientId, SecurityUtils.getUserId());
+ }));
+ if (pole == null) {
+ throw new BusinessException("缁戝畾鍏崇郴涓嶆纭紒");
+ }
+ }
+ }
+
PageHelper.startPage(pageNo, pageSize);
List<LightReportDataBo> list = baseMapper.listReportData(keyword, deviceCode);
@@ -92,8 +120,8 @@
// String url = file.getPath().replace(properties.getUploadRootPath(), "");
String url = fileUploadDto.getFileUrl();
file.delete();
- return url;
+ return url;
- // return list;
+ // return list;
}
}
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportErrorService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportErrorService.java
index 73c5b22..b38cff0 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportErrorService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportErrorService.java
@@ -4,6 +4,7 @@
import com.sandu.common.service.impl.BaseServiceImpl;
import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5LightErrorCodeReportInnerFrame;
import com.sandu.ximon.admin.manager.iot.rrpc.enums.LightErrorEnum;
+import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.dao.bo.LightReportErrorBo;
import com.sandu.ximon.dao.domain.LightReportError;
import com.sandu.ximon.dao.mapper.LightReportErrorMapper;
@@ -26,14 +27,21 @@
}
public List<LightReportErrorBo> listReportError(int pageNo, int pageSize, String keyword) {
- PageHelper.startPage(pageNo,pageSize);
- List<LightReportErrorBo> lightReportErrorBos = baseMapper.listReportError(keyword);
+ PageHelper.startPage(pageNo, pageSize);
+ List<LightReportErrorBo> lightReportErrorBos;
+ //涓簄ull鐨勮瘽鏄秴绠�
+ if (SecurityUtils.getClientId() == null) {
+ lightReportErrorBos = baseMapper.listReportError(keyword, null);
+ }else{
+ lightReportErrorBos = baseMapper.listReportError(keyword, SecurityUtils.getUserId());
+ }
+
for (LightReportErrorBo lightReportErrorBo : lightReportErrorBos) {
Integer errorCode = lightReportErrorBo.getErrorCode();
StringBuilder sb = new StringBuilder();
LightErrorEnum[] values = LightErrorEnum.values();
for (LightErrorEnum value : values) {
- if((value.getCode() & errorCode) > 0){
+ if ((value.getCode() & errorCode) > 0) {
sb.append(value.getMessage());
}
}
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightTaskService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightTaskService.java
index 1433673..09dbb61 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightTaskService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightTaskService.java
@@ -161,9 +161,11 @@
if (StrUtil.isNotBlank(keyword)) {
wrapper.like(LightTask::getTaskName, keyword);
}
- Long clientId = SecurityUtils.getClientId();
- if (clientId != null) {
- wrapper.eq(LightTask::getClientId, clientId);
+ //涓嶆槸瓒呯闇�瑕佺瓫閫�
+ if (SecurityUtils.getClientId() != null) {
+ wrapper.eq(LightTask::getClientId, SecurityUtils.getUserId()).or(w -> {
+ w.eq(LightTask::getUserId, SecurityUtils.getUserId());
+ });
}
PageHelper.startPage(pageNo, pageSize);
@@ -229,8 +231,8 @@
// }
// lightTaskPoleRelationService.remove(Wrappers.lambdaQuery(LightTaskPoleRelation.class).in(LightTaskPoleRelation::getTaskId, taskIdList));
taskIdList.forEach(
- taskId->{
- lightTaskPoleRelationService.remove(Wrappers.lambdaQuery(LightTaskPoleRelation.class).eq(LightTaskPoleRelation::getTaskId,taskId));
+ taskId -> {
+ lightTaskPoleRelationService.remove(Wrappers.lambdaQuery(LightTaskPoleRelation.class).eq(LightTaskPoleRelation::getTaskId, taskId));
}
);
--
Gitblit v1.9.3