Bladeren bron

Merge branch 'master' of http://116.63.33.55/git/read_opc

FinalYu 2 jaren geleden
bovenliggende
commit
4843a2b900

+ 39 - 0
chaunyi_opc/opc_common/src/main/java/com/example/opc_common/entity/SysTableTemplate.java

@@ -0,0 +1,39 @@
+package com.example.opc_common.entity;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+@Data
+public class SysTableTemplate implements Serializable {
+
+    /**
+     * id
+     */
+    private Integer id;
+
+    /**
+     * 字典id
+     */
+    private String dictId;
+    /**
+     * 模板名称
+     */
+    private String templateName;
+
+    /**
+     * 模板信息
+     */
+    private String templateData;
+
+    /**
+     * 图标
+     */
+    private String logo;
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+}

+ 16 - 0
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/controller/ReportTableController.java

@@ -54,6 +54,22 @@ public class ReportTableController {
     }
 
     /**
+     * 通过字段id查询相应的系统报表模板
+     *
+     * @param keyType
+     * @param dictId
+     * @return
+     */
+    @GetMapping("/getSysTableTemplate")
+    @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.TABLETEMPLATE, OperationEnum = OperationEnum.SELECT)
+    public Result getSysTableTemplate(String keyType, Integer dictId, String templateName) {
+        if (Blank.isEmpty(keyType)) {
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "系统报表模板参数不能为空");
+        }
+        return reportTableService.getSysTableTemplate(keyType, dictId, templateName);
+    }
+
+    /**
      * 如果userId为空,则获取当前登录人的所有报表模板;不为空,则查询对应的参数的报表模板
      *
      * @param page

+ 3 - 0
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/dao/ReportTableDao.java

@@ -1,6 +1,7 @@
 package com.example.opc_da.dao;
 
 import com.example.opc_common.entity.ReportTable;
+import com.example.opc_common.entity.SysTableTemplate;
 import com.example.opc_common.entity.TableTemplate;
 import com.example.opc_common.entity.UserGroupUser;
 import org.springframework.stereotype.Repository;
@@ -63,4 +64,6 @@ public interface ReportTableDao {
     List<ReportTable> getReportTableByUserGroupId(Integer userGroupId);
 
     Integer updateTableNameById(Integer id, String reportTableName);
+
+    List<SysTableTemplate> getSysTableTemplate(List<Integer> dictIdList, String templateName);
 }

+ 2 - 0
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/service/ReportTableService.java

@@ -35,4 +35,6 @@ public interface ReportTableService {
     Result tableAssignUserById(Integer id, Integer userGroupId);
 
     Result updateTableNameById(Integer id, String reportTableName);
+
+    Result getSysTableTemplate(String keyType, Integer dictId, String templateName);
 }

+ 31 - 9
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/service/impl/ReportTableServiceImpl.java

@@ -1,6 +1,7 @@
 package com.example.opc_da.service.impl;
 
 import com.alibaba.fastjson.JSONObject;
+import com.example.opc_common.entity.Dict;
 import com.example.opc_common.entity.ReportTable;
 import com.example.opc_common.entity.TableTemplate;
 import com.example.opc_common.entity.UserGroupUser;
@@ -8,20 +9,20 @@ import com.example.opc_common.enums.ResultEnum;
 import com.example.opc_common.util.Blank;
 import com.example.opc_common.util.ConstantStr;
 import com.example.opc_common.util.Result;
-import com.example.opc_da.dao.ItemGroupDao;
-import com.example.opc_da.dao.RawDataDao;
-import com.example.opc_da.dao.ReportTableDao;
-import com.example.opc_da.dao.UserGroupDao;
+import com.example.opc_da.dao.*;
 import com.example.opc_da.dynamicSchedule.CronTaskRegister;
 import com.example.opc_da.dynamicSchedule.SchedulingRunnable;
 import com.example.opc_da.service.ReportTableService;
 import com.example.opc_da.task.ReportTableTask;
 import com.example.opc_da.util.UserUtil;
 import org.quartz.CronExpression;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 import java.util.UUID;
 
@@ -42,11 +43,8 @@ public class ReportTableServiceImpl implements ReportTableService {
     @Resource
     CronTaskRegister cronTaskRegister;
 
-    @Resource
-    private ItemGroupDao itemGroupDao;
-
-    @Resource
-    private RawDataDao rawDataDao;
+    @Autowired
+    private DictDao dictDao;
 
     @Override
     public synchronized Result addTableTemplate(TableTemplate tableTemplate) {
@@ -231,6 +229,30 @@ public class ReportTableServiceImpl implements ReportTableService {
     }
 
     @Override
+    public Result getSysTableTemplate(String keyType, Integer dictId, String templateName) {
+        List<Integer> dictIdList = new ArrayList<>();
+        if (Blank.isNotEmpty(dictId)) {
+            //递归得到本身和下级的字典id
+            List<Dict> dictList = dictDao.queryByTypes(keyType);
+            dictIdList = gen(dictIdList, dictList, dictId);
+        }
+        return Result.ok(reportTableDao.getSysTableTemplate(dictIdList, templateName));
+    }
+
+    public List<Integer> gen(List<Integer> dictIdList, List<Dict> dictList, Integer dictId) {
+        dictIdList.add(dictId);
+        Iterator<Dict> iterator = dictList.iterator();
+        while (iterator.hasNext()) {
+            Dict dict = iterator.next();
+            if (dict.getParentId().equals(dictId)) {
+//                iterator.remove();
+                dictIdList = gen(dictIdList, dictList, dict.getId());
+            }
+        }
+        return dictIdList;
+    }
+
+    @Override
     public Result getAllTableTemplate(Integer page, Integer limit, String userId) {
         JSONObject jsonObject = new JSONObject();
         if (Blank.isEmpty(userId)) {

+ 22 - 1
chaunyi_opc/opc_da/src/main/resources/mapper/ReportTableDao.xml

@@ -7,6 +7,11 @@
         , user_id, template_name, template_data, create_time
     </sql>
 
+    <sql id="tableTemplateNoData">
+        id
+        , user_id, template_name , create_time
+    </sql>
+
     <sql id="reportTable">
         id
         , user_id, report_table_name, report_table_data, report_value_format, is_auto_report, user_group_id, create_time
@@ -111,7 +116,7 @@
 
     <select id="getAllTableTemplate" resultType="com.example.opc_common.entity.TableTemplate">
         select
-        <include refid="tableTemplate"/>
+        <include refid="tableTemplateNoData"/>
         from t_table_template
         where user_id = #{userId}
         limit #{startNum},#{limitNum}
@@ -307,4 +312,20 @@
         WHERE
         user_group_id=#{userGroupId}
     </select>
+
+    <select id="getSysTableTemplate" resultType="com.example.opc_common.entity.SysTableTemplate">
+        select
+        id,dict_id,template_name,logo,create_time
+        from t_sys_table_template
+        WHERE 1=1
+        <if test="dictIdList!= null and dictIdList.size() >0">
+            AND dict_id IN
+            <foreach collection="dictIdList" item="dictId" separator="," open="(" close=")">
+                #{dictId}
+            </foreach>
+        </if>
+        <if test="templateName != null">
+            AND template_name LIKE CONCAT('%', #{templateName}, '%')
+        </if>
+    </select>
 </mapper>