浏览代码

数据源,数据组,报表数据策略添加用户id认证

zhoupeng 1 年之前
父节点
当前提交
af0a5dce75

+ 2 - 0
industry-system/cqcy-ei-common/src/main/java/com/example/opc_common/entity/DataSource.java

@@ -14,6 +14,8 @@ public class DataSource implements Serializable {
     private Integer id;
     //数据源类型id
     private Integer typeId;
+    //用户id
+    private String userId;
     //数据源名称
     private String dataSourceName;
     //数据源描述

+ 2 - 0
industry-system/cqcy-ei-common/src/main/java/com/example/opc_common/entity/ItemGroup.java

@@ -14,6 +14,8 @@ public class ItemGroup implements Serializable {
      * id
      */
     private Integer id;
+    //用户id
+    private String userId;
     /**
      * 组名称
      */

+ 2 - 0
industry-system/cqcy-ei-common/src/main/java/com/example/opc_common/entity/ReportDataPolicy.java

@@ -13,6 +13,8 @@ public class ReportDataPolicy extends BaseSchedule implements Serializable {
 
     //id
     private Integer id;
+    //用户id
+    private String userId;
     //报表数据策略名称
     @NotBlank(message = "策略名称不能为空")
     private String reportDataPolicyName;

+ 1 - 1
industry-system/industry-da/src/main/java/com/example/opc_da/alarmConfig/AlarmRun.java

@@ -29,7 +29,7 @@ public class AlarmRun implements ApplicationRunner {
     public void run(ApplicationArguments args) throws Exception {
         //初始化将所有数据项启动的报警配置,注册到报警任务中
         //获取到所有数据源
-        List<DataSource> dataSourceList = dataSourceDao.getAllDataSource(null, null);
+        List<DataSource> dataSourceList = dataSourceDao.getAllDataSource(null, null, null);
         if (Blank.isNotEmpty(dataSourceList)) {
             dataSourceList.forEach(dataSource -> {
                 //获取数据源下所有启动了的报警数据项

+ 4 - 4
industry-system/industry-da/src/main/java/com/example/opc_da/dao/DataSourceDao.java

@@ -14,21 +14,21 @@ public interface DataSourceDao {
 
     List<DataSourceType> getAllDataSourceType();
 
-    DataSource getDataSourceByName(String dataSourceName);
+    DataSource getDataSourceByName(String userId, String dataSourceName);
 
     Integer addDataSource(DataSource dataSource);
 
     DataSourceType getDataSourceTypeById(Integer id);
 
-    Integer getDataSourceCount();
+    Integer getDataSourceCount(String userId);
 
-    List<DataSource> getAllDataSource(Integer startNum, Integer limitNum);
+    List<DataSource> getAllDataSource(String userId, Integer startNum, Integer limitNum);
 
     DataSource getDataSourceById(Integer id);
 
     Integer delDataSourceById(Integer id);
 
-    DataSource getDataSourceByNameNoId(Integer id, String dataSourceName);
+    DataSource getDataSourceByNameNoId(Integer id, String userId, String dataSourceName);
 
     Integer updateDataSource(DataSource dataSource);
 

+ 6 - 4
industry-system/industry-da/src/main/java/com/example/opc_da/dao/ItemGroupDao.java

@@ -12,17 +12,17 @@ import java.util.List;
 @Repository
 public interface ItemGroupDao {
 
-    ItemGroup getItemGroupByName(String groupName);
+    ItemGroup getItemGroupByName(String userId, String groupName);
 
     Integer addItemGroup(ItemGroup itemGroup);
 
     ItemGroup getItemGroupById(Integer id);
 
-    Integer getItemGroupCount(Integer readMode);
+    Integer getItemGroupCount(String userId, Integer readMode);
 
-    List<ItemGroup> getAllItemGroup(Integer startNum, Integer limitNum, Integer readMode);
+    List<ItemGroup> getAllItemGroup(String userId, Integer startNum, Integer limitNum, Integer readMode);
 
-    ItemGroup getItemGroupByNameNoId(Integer id, String groupName);
+    ItemGroup getItemGroupByNameNoId(Integer id,String userId, String groupName);
 
     Integer updateItemGroup(ItemGroup itemGroup);
 
@@ -87,6 +87,7 @@ public interface ItemGroupDao {
 
     /**
      * 通过数据项id集合,获取数据项信息,并转换为ItemsParent
+     *
      * @param idList
      * @return
      */
@@ -94,6 +95,7 @@ public interface ItemGroupDao {
 
     /**
      * 通过泛型集合且泛型是ItemParent子类,获取数据项信息,并转换为ItemsParent
+     *
      * @param tList
      * @return
      */

+ 4 - 4
industry-system/industry-da/src/main/java/com/example/opc_da/dao/ReportDataPolicyDao.java

@@ -15,7 +15,7 @@ public interface ReportDataPolicyDao {
      * @param reportDataPolicyName
      * @return
      */
-    ReportDataPolicy getReportDataPolicyByName(String reportDataPolicyName);
+    ReportDataPolicy getReportDataPolicyByName(String userId, String reportDataPolicyName);
 
     /**
      * 添加报表数据策略
@@ -41,7 +41,7 @@ public interface ReportDataPolicyDao {
      * @param reportDataPolicyName
      * @return
      */
-    ReportDataPolicy getReportDataPolicyByNameNoId(Integer id, String reportDataPolicyName);
+    ReportDataPolicy getReportDataPolicyByNameNoId(Integer id,String userId, String reportDataPolicyName);
 
     /**
      * 修改报表数据策略
@@ -56,7 +56,7 @@ public interface ReportDataPolicyDao {
      *
      * @return
      */
-    Integer getReportDataPolicyCount();
+    Integer getReportDataPolicyCount(String userId);
 
     /**
      * 获取报表数据策略
@@ -66,7 +66,7 @@ public interface ReportDataPolicyDao {
      */
     List<ReportDataPolicy> getAllReportDataPolicy(List<Integer> readModeList);
 
-    List<ReportDataPolicy> getReportDataPolicyPage(Integer startNum, Integer limitNum);
+    List<ReportDataPolicy> getReportDataPolicyPage(String userId, Integer startNum, Integer limitNum);
 
     List<ReportDataPolicy> getAllStateReportPolicy(Integer runState);
 

+ 11 - 4
industry-system/industry-da/src/main/java/com/example/opc_da/service/impl/DataSourceServiceImpl.java

@@ -12,6 +12,7 @@ import com.example.opc_da.dao.DataSourceDao;
 import com.example.opc_da.dao.ItemGroupDao;
 import com.example.opc_da.service.DataSourceService;
 import com.example.opc_da.util.OpcDaUtil;
+import com.example.opc_da.util.UserUtil;
 import com.example.opc_da.validate.dataSource.DataSourceValidate;
 import com.example.opc_da.validate.dataSource.DataSourceValidateFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -30,6 +31,9 @@ public class DataSourceServiceImpl implements DataSourceService {
     @Autowired
     private ItemGroupDao itemGroupDao;
 
+    @Autowired
+    private UserUtil userUtil;
+
     @Override
     public Result getDataSourceTree() {
         List<DataSourceType> dataSourceTypeList = dataSourceDao.getAllDataSourceType();
@@ -42,9 +46,11 @@ public class DataSourceServiceImpl implements DataSourceService {
     @Override
     public Result addDataSource(DataSource dataSource) {
         DataSourceValidateFactory.getDataSourceValidate(dataSource.getTypeId()).Validate(dataSource);
+        String currentUserId = userUtil.getCurrentUserId();
+        dataSource.setUserId(currentUserId);
         synchronized (this) {
             if (Blank.isEmpty(dataSource.getId())) {
-                DataSource isExistDataSource = dataSourceDao.getDataSourceByName(dataSource.getDataSourceName());
+                DataSource isExistDataSource = dataSourceDao.getDataSourceByName(currentUserId, dataSource.getDataSourceName());
                 if (Blank.isNotEmpty(isExistDataSource)) {
                     return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "已经存在此名称的数据源配置了,请更改名称");
                 }
@@ -53,7 +59,7 @@ public class DataSourceServiceImpl implements DataSourceService {
                 }
                 return Result.ok("添加数据源配置成功");
             } else {
-                DataSource isExistDataSource = dataSourceDao.getDataSourceByNameNoId(dataSource.getId(), dataSource.getDataSourceName());
+                DataSource isExistDataSource = dataSourceDao.getDataSourceByNameNoId(dataSource.getId(), currentUserId, dataSource.getDataSourceName());
                 if (Blank.isNotEmpty(isExistDataSource)) {
                     return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "已经存在此名称的数据源配置了,请更改名称");
                 }
@@ -82,9 +88,10 @@ public class DataSourceServiceImpl implements DataSourceService {
     @Override
     public Result getAllDataSource(Integer page, Integer limit) {
         JSONObject jsonObject = new JSONObject();
-        Integer count = dataSourceDao.getDataSourceCount();
+        String currentUserId = userUtil.getCurrentUserId();
+        Integer count = dataSourceDao.getDataSourceCount(currentUserId);
         Integer startNum = (page - 1) * limit;
-        List<DataSource> dataSourceList = dataSourceDao.getAllDataSource(startNum, limit);
+        List<DataSource> dataSourceList = dataSourceDao.getAllDataSource(currentUserId, startNum, limit);
         jsonObject.put("count", count);
         jsonObject.put("dataSourceList", dataSourceList);
         return Result.ok(jsonObject);

+ 7 - 4
industry-system/industry-da/src/main/java/com/example/opc_da/service/impl/ItemGroupServiceImpl.java

@@ -58,12 +58,14 @@ public class ItemGroupServiceImpl implements ItemGroupService {
 
     @Override
     public synchronized Result addItemGroup(ItemGroup itemGroup) {
+        String currentUserId = userUtil.getCurrentUserId();
         Integer dataSourceId = itemGroup.getDataSourceId();
         DataSource dataSource = dataSourceDao.getDataSourceById(dataSourceId);
         DataSourceType dataSourceType = dataSourceDao.getDataSourceTypeById(dataSource.getTypeId());
         Boolean isOpcDa = OpcUtil.isOpcDa(dataSourceType.getDataSourceTypeKey());
+        itemGroup.setUserId(currentUserId);
         if (Blank.isEmpty(itemGroup.getId())) {
-            ItemGroup isExistItemGroup = itemGroupDao.getItemGroupByName(itemGroup.getGroupName());
+            ItemGroup isExistItemGroup = itemGroupDao.getItemGroupByName(currentUserId, itemGroup.getGroupName());
             if (Blank.isNotEmpty(isExistItemGroup)) {
                 return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "已经存在此数据组的名称了,请更改名称");
             }
@@ -83,7 +85,7 @@ public class ItemGroupServiceImpl implements ItemGroupService {
         } else {
             Integer id = itemGroup.getId();
             ItemGroup itemGroup1 = itemGroupDao.getItemGroupById(id);
-            ItemGroup isExistItemGroup = itemGroupDao.getItemGroupByNameNoId(itemGroup.getId(), itemGroup.getGroupName());
+            ItemGroup isExistItemGroup = itemGroupDao.getItemGroupByNameNoId(itemGroup.getId(), currentUserId, itemGroup.getGroupName());
             if (Blank.isNotEmpty(isExistItemGroup)) {
                 return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "已经存在此数据组的名称了,请更改名称");
             }
@@ -175,9 +177,10 @@ public class ItemGroupServiceImpl implements ItemGroupService {
     @Override
     public Result getAllItemGroup(Integer page, Integer limit, Integer readMode) {
         JSONObject jsonObject = new JSONObject();
-        Integer count = itemGroupDao.getItemGroupCount(readMode);
+        String currentUserId = userUtil.getCurrentUserId();
+        Integer count = itemGroupDao.getItemGroupCount(currentUserId, readMode);
         Integer startNum = (page - 1) * limit;
-        List<ItemGroup> itemGroupList = itemGroupDao.getAllItemGroup(startNum, limit, readMode);
+        List<ItemGroup> itemGroupList = itemGroupDao.getAllItemGroup(currentUserId, startNum, limit, readMode);
         jsonObject.put("count", count);
         jsonObject.put("itemGroupList", itemGroupList);
         return Result.ok(jsonObject);

+ 21 - 22
industry-system/industry-da/src/main/java/com/example/opc_da/service/impl/ReportDataPolicyServiceImpl.java

@@ -22,10 +22,11 @@ import com.example.opc_da.timer.QuartzTimerFactory;
 import com.example.opc_da.util.InFluxDBServiceUtil;
 import com.example.opc_da.util.QueryServiceUtil;
 import com.example.opc_da.util.RedisUtil;
+import com.example.opc_da.util.UserUtil;
 import com.example.opc_da.util.bucketType.BucketTypeFactory;
 import com.example.opc_da.util.calculate.CalculateDataFactory;
 import com.example.opc_da.validate.reportDataPolicy.ReportDataPolicyValidateFactory;
-import org.springframework.beans.factory.annotation.Autowired;
+import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -35,43 +36,39 @@ import java.util.*;
 
 @Service
 @Transactional
+@AllArgsConstructor
 public class ReportDataPolicyServiceImpl implements ReportDataPolicyService {
 
     private final String timePattern = "yyyy-MM-dd HH:mm:ss";
     private final String timeStampPattern = "yyyy-MM-dd HH:mm:ss.SSS";
 
-    @Autowired
-    private ReportDataPolicyDao reportDataPolicyDao;
+    private final ReportDataPolicyDao reportDataPolicyDao;
 
-    @Autowired
-    private QueryServiceUtil queryServiceUtil;
+    private final QueryServiceUtil queryServiceUtil;
 
-    @Autowired
-    private InFluxDBServiceUtil inFluxDBServiceUtil;
+    private final InFluxDBServiceUtil inFluxDBServiceUtil;
 
-    @Autowired
-    private ReportTableDao reportTableDao;
+    private final ReportTableDao reportTableDao;
 
-    @Autowired
-    private RedisUtil redisUtil;
+    private final RedisUtil redisUtil;
 
-    @Autowired
-    private FreReportDataPolicyTaskRegister freReportDataPolicyTaskRegister;
+    private final UserUtil userUtil;
 
-    @Autowired
-    private ChangeReportDataPolicyTaskRegister changeReportDataPolicyTaskRegister;
+    private final FreReportDataPolicyTaskRegister freReportDataPolicyTaskRegister;
 
-    @Autowired
-    private EventReportDataPolicyTaskRegister eventReportDataPolicyTaskRegister;
+    private final ChangeReportDataPolicyTaskRegister changeReportDataPolicyTaskRegister;
+
+    private final EventReportDataPolicyTaskRegister eventReportDataPolicyTaskRegister;
 
     @Override
     public synchronized Result addReportDataPolicy(ReportDataPolicy reportDataPolicy) {
-        ReportDataPolicy oldReportDataPolicy = reportDataPolicyDao.getReportDataPolicyByName(reportDataPolicy.getReportDataPolicyName());
+        String currentUserId = userUtil.getCurrentUserId();
+        ReportDataPolicy oldReportDataPolicy = reportDataPolicyDao.getReportDataPolicyByName(currentUserId, reportDataPolicy.getReportDataPolicyName());
 
         Integer readMode = reportDataPolicy.getReadMode();
         //使用策略模式加工厂模式,验证传入的报表策略是否正确
         ReportDataPolicyValidateFactory.getReportDataPolicyValidate(readMode).Validate(reportDataPolicy);
-
+        reportDataPolicy.setUserId(currentUserId);
         if (Blank.isNotEmpty(oldReportDataPolicy)) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "已经存在策略名称了,请更改名称");
         }
@@ -121,8 +118,9 @@ public class ReportDataPolicyServiceImpl implements ReportDataPolicyService {
         if (reportDataPolicy1.getRunState() == ConstantStr.START_UP) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "此报表数据策略现在处于运行中,不允许修改");
         }
+        String currentUserId = userUtil.getCurrentUserId();
         ReportDataPolicy oldReportDataPolicy = reportDataPolicyDao.getReportDataPolicyByNameNoId(
-                reportDataPolicy.getId(), reportDataPolicy.getReportDataPolicyName());
+                reportDataPolicy.getId(), currentUserId, reportDataPolicy.getReportDataPolicyName());
 
         ReportDataPolicyValidateFactory.getReportDataPolicyValidate(reportDataPolicy.getReadMode()).Validate(reportDataPolicy);
         if (Blank.isNotEmpty(oldReportDataPolicy)) {
@@ -167,9 +165,10 @@ public class ReportDataPolicyServiceImpl implements ReportDataPolicyService {
     @Override
     public Result getReportDataPolicyPage(Integer page, Integer limit) {
         JSONObject jsonObject = new JSONObject();
-        Integer count = reportDataPolicyDao.getReportDataPolicyCount();
+        String currentUserId = userUtil.getCurrentUserId();
+        Integer count = reportDataPolicyDao.getReportDataPolicyCount(currentUserId);
         Integer statNum = (page - 1) * limit;
-        List<ReportDataPolicy> reportDataPolicyList = reportDataPolicyDao.getReportDataPolicyPage(statNum, limit);
+        List<ReportDataPolicy> reportDataPolicyList = reportDataPolicyDao.getReportDataPolicyPage(currentUserId, statNum, limit);
         jsonObject.put("count", count);
         jsonObject.put("reportDataPolicyList", reportDataPolicyList);
         return Result.ok(jsonObject);

+ 13 - 6
industry-system/industry-da/src/main/resources/mapper/DataSourceDao.xml

@@ -4,7 +4,7 @@
 
     <sql id="dataSource">
         id
-        , type_id, data_source_name, data_source_describe, ip_address, ip_port, ip_user_name, ip_password,
+        , type_id, user_id, data_source_name, data_source_describe, ip_address, ip_port, ip_user_name, ip_password,
         security_mode, security_policy, identity_provider, certificate_dir, certificate_key, cls_id, prog_id, driver_describe, create_time
     </sql>
 
@@ -24,12 +24,12 @@
     </sql>
 
     <insert id="addDataSource">
-        insert into t_data_source(type_id, data_source_name, data_source_describe, ip_address, ip_port,
+        insert into t_data_source(type_id, user_id, data_source_name, data_source_describe, ip_address, ip_port,
                                   ip_user_name,
                                   ip_password, security_mode, security_policy, identity_provider, certificate_dir,
                                   certificate_key, cls_id,
                                   prog_id, driver_describe, create_time, slave_id)
-            VALUE (#{typeId}, #{dataSourceName}, #{dataSourceDescribe},
+            VALUE (#{typeId},#{userId}, #{dataSourceName}, #{dataSourceDescribe},
             #{ipAddress}, #{ipPort},
             #{ipUserName}, #{ipPassword},#{securityMode},#{securityPolicy},#{identityProvider},#{certificateDir},
             #{certificateKey},#{clsId},#{progId},#{driverDescribe}, now(), #{slaveId})
@@ -111,7 +111,8 @@
         select
         <include refid="dataSource"/>
         from t_data_source
-        where data_source_name = #{dataSourceName}
+        where user_id=#{userId}
+        AND data_source_name = #{dataSourceName}
     </select>
 
     <select id="getDataSourceTypeById" resultType="com.example.opc_common.entity.DataSourceType">
@@ -124,6 +125,7 @@
     <select id="getAllDataSource" resultType="com.example.opc_common.entity.DataSource">
         select tds.id,
         tds.type_id,
+        tds.user_id,
         tds.data_source_name,
         tds.data_source_describe,
         tds.ip_address,
@@ -145,6 +147,9 @@
         tds.slave_id
         from t_data_source tds
         LEFT JOIN t_data_source_type tdst ON tds.type_id = tdst.id
+        <if test=" userId!=null and userId !=null">
+            WHERE tds.user_id= #{userId}
+        </if>
         order by create_time
         <if test=" startNum!=null and limitNum !=null">
             limit #{startNum}, #{limitNum}
@@ -162,7 +167,8 @@
         select
         <include refid="dataSource"/>
         from t_data_source
-        where data_source_name = #{dataSourceName}
+        where user_id=#{userId}
+        AND data_source_name = #{dataSourceName}
         and id != #{id}
     </select>
 
@@ -254,6 +260,7 @@
 
     <select id="getDataSourceCount" resultType="java.lang.Integer">
         select count(*)
-        from t_data_source;
+        from t_data_source
+        where user_id=#{userId}
     </select>
 </mapper>

+ 10 - 8
industry-system/industry-da/src/main/resources/mapper/ItemGroupDao.xml

@@ -4,7 +4,7 @@
 
     <sql id="itemGroup">
         id
-        , group_name, group_describe, data_source_id, create_time
+        , user_id, group_name, group_describe, data_source_id, create_time
     </sql>
 
     <sql id="item">
@@ -14,8 +14,8 @@
 
     <insert id="addItemGroup" parameterType="com.example.opc_common.entity.ItemGroup" useGeneratedKeys="true"
             keyProperty="id">
-        insert into t_item_group(group_name, group_describe, data_source_id, create_time)
-        values (#{groupName}, #{groupDescribe}, #{dataSourceId}, now())
+        insert into t_item_group(user_id, group_name, group_describe, data_source_id, create_time)
+        values (#{userId}, #{groupName}, #{groupDescribe}, #{dataSourceId}, now())
     </insert>
 
     <insert id="addItem">
@@ -133,7 +133,8 @@
         select
         <include refid="itemGroup"/>
         from t_item_group
-        where group_name = #{groupName}
+        where user_id=#{userId}
+        AND group_name = #{groupName}
     </select>
 
     <select id="getItemGroupById" resultType="com.example.opc_common.entity.ItemGroup">
@@ -146,7 +147,7 @@
     <select id="getItemGroupCount" resultType="java.lang.Integer">
         select count(*)
         from t_item_group
-        where 1=1
+        where user_id=#{userId}
         <if test="readMode != null and readMode != ''">
             AND read_mode = #{readMode}
         </if>
@@ -157,11 +158,11 @@
         g.*,s.data_source_name dataSourceName,st.data_source_type_name dataSourceTypeName
         from t_item_group g left outer join t_data_source s on s.id=g.data_source_id
         left outer join t_data_source_type st on st.id=s.type_id
-        where 1=1
+        where g.user_id=#{userId}
         <if test="readMode != null and readMode != ''">
-            AND read_mode = #{readMode}
+            AND g.read_mode = #{readMode}
         </if>
-        order by create_time
+        order by g.create_time
         limit #{startNum}, #{limitNum}
     </select>
 
@@ -170,6 +171,7 @@
         <include refid="itemGroup"/>
         from t_item_group
         where id != #{id}
+        AND user_id=#{userId}
         AND group_name = #{groupName}
     </select>
 

+ 13 - 6
industry-system/industry-da/src/main/resources/mapper/ReportDataPolicyDao.xml

@@ -4,7 +4,7 @@
 
     <sql id="reportDataPolicy">
         id
-        ,report_data_policy_name,policy_remake,item_group_id,read_mode,
+        , user_id,report_data_policy_name,policy_remake,item_group_id,read_mode,
             read_mode_type,mode_value,event_item_id,read_week,start_read_time,end_read_time,run_state,cron_id,create_time
     </sql>
 
@@ -16,11 +16,11 @@
     <insert id="addReportDataPolicy" parameterType="com.example.opc_common.entity.ReportDataPolicy"
             useGeneratedKeys="true"
             keyProperty="id">
-        insert into t_report_data_policy(report_data_policy_name, policy_remake, item_group_id, read_mode,
+        insert into t_report_data_policy(user_id, report_data_policy_name, policy_remake, item_group_id, read_mode,
                                          read_mode_type, mode_value, event_item_id, read_week, start_read_time,
                                          end_read_time,
                                          create_time)
-            value (#{reportDataPolicyName},#{policyRemake},#{itemGroupId},#{readMode},
+            value (#{userId},#{reportDataPolicyName},#{policyRemake},#{itemGroupId},#{readMode},
             #{readModeType},#{modeValue},#{eventItemId},#{readWeek},#{startReadTime},#{endReadTime},now())
     </insert>
 
@@ -96,20 +96,22 @@
         select
         <include refid="reportDataPolicy"/>
         from t_report_data_policy
-        where report_data_policy_name=#{reportDataPolicyName}
+        where user_id=#{userId}
+        AND report_data_policy_name=#{reportDataPolicyName}
     </select>
 
     <select id="getReportDataPolicyByNameNoId" resultType="com.example.opc_common.entity.ReportDataPolicy">
         select
         <include refid="reportDataPolicy"/>
         from t_report_data_policy
-        where report_data_policy_name=#{reportDataPolicyName}
+        where user_id=#{userId} AND report_data_policy_name=#{reportDataPolicyName}
         and id!=#{id}
     </select>
 
     <select id="getReportDataPolicyCount" resultType="java.lang.Integer">
         select count(*)
         from t_report_data_policy
+        where user_id=#{userId}
     </select>
 
     <select id="getAllReportDataPolicy" resultType="com.example.opc_common.entity.ReportDataPolicy">
@@ -126,6 +128,7 @@
 
     <select id="getReportDataPolicyPage" resultType="com.example.opc_common.entity.ReportDataPolicy">
         select a.id,
+               a.user_id,
                a.report_data_policy_name,
                a.policy_remake,
                a.item_group_id,
@@ -140,7 +143,10 @@
                a.run_state,
                a.cron_id,
                a.create_time
-        from t_report_data_policy a left join t_item_group b on a.item_group_id=b.id limit #{startNum},#{limitNum}
+        from t_report_data_policy a
+                 left join t_item_group b on a.item_group_id = b.id
+        where a.user_id = #{userId}
+            limit #{startNum}, #{limitNum}
     </select>
 
     <select id="getAllStateReportPolicy" resultType="com.example.opc_common.entity.ReportDataPolicy">
@@ -152,6 +158,7 @@
 
     <select id="getReportDataPolicyById" resultType="com.example.opc_common.entity.ReportDataPolicy">
         select a.id,
+               a.user_id,
                a.report_data_policy_name,
                a.policy_remake,
                a.item_group_id,