浏览代码

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

FinalYu 2 年之前
父节点
当前提交
61fb472bf1

+ 16 - 0
chuanyi_server/src/main/java/com/judong/chuanyiserver/controller/ReportTableController.java

@@ -201,6 +201,22 @@ public class ReportTableController {
     }
 
     /**
+     * 给报表分配用户组
+     *
+     * @param id
+     * @param userGroupId
+     * @return
+     */
+    @PostMapping("/tableAssignUserById")
+    @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.REPORTTABLE, OperationEnum = OperationEnum.ASSIGN)
+    public Result tableAssignUserById(Integer id, Integer userGroupId) {
+        if (Blank.isEmpty(id, userGroupId)) {
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "报表id和用户组id不能为空");
+        }
+        return reportTableService.tableAssignUserById(id, userGroupId);
+    }
+
+    /**
      * 获取当前登录人的能查看的所有报表(包括自己创建的)
      *
      * @param page

+ 2 - 0
chuanyi_server/src/main/java/com/judong/chuanyiserver/dao/ReportTableDao.java

@@ -53,4 +53,6 @@ public interface ReportTableDao {
     List<ReportTable> getAllAutoReportTable(Integer autoReport);
 
     Integer tableExchangeAutoById(Integer id, Integer isAutoReport, String cronId, String cron);
+
+    Integer tableAssignUserById(Integer id, Integer userGroupId);
 }

+ 2 - 4
chuanyi_server/src/main/java/com/judong/chuanyiserver/dynamicSchedule/DynamicScheduleConfig.java

@@ -2,17 +2,15 @@ package com.judong.chuanyiserver.dynamicSchedule;
 
 import com.judong.chuanyiserver.dao.ReportTableDao;
 import com.judong.chuanyiserver.entity.ReportTable;
-import com.judong.chuanyiserver.task.TestTask;
+import com.judong.chuanyiserver.task.ReportTableTask;
 import com.judong.chuanyiserver.util.Blank;
 import com.judong.chuanyiserver.util.ConstantStr;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.scheduling.annotation.SchedulingConfigurer;
 import org.springframework.scheduling.config.ScheduledTaskRegistrar;
-import org.springframework.scheduling.support.CronTrigger;
 
 import javax.annotation.Resource;
-import java.time.LocalDateTime;
 import java.util.List;
 
 @Slf4j
@@ -37,7 +35,7 @@ public class DynamicScheduleConfig implements SchedulingConfigurer {
 //                        , triggerContext -> {
 //                            return new CronTrigger(reportTable.getCron()).nextExecutionTime(triggerContext);
 //                        });
-                cronTaskRegister.addCronTask(new SchedulingRunnable(TestTask.class, "test1", null), reportTable.getCronId(), reportTable.getCron());
+                cronTaskRegister.addCronTask(new SchedulingRunnable(ReportTableTask.class, "getTableData", new Object[]{reportTable.getId()}), reportTable.getCronId(), reportTable.getCron());
             }
         }
     }

+ 2 - 0
chuanyi_server/src/main/java/com/judong/chuanyiserver/service/ReportTableService.java

@@ -31,4 +31,6 @@ public interface ReportTableService {
     Result queryTableNum();
 
     Result getAllOkReportTable(Integer page, Integer limit);
+
+    Result tableAssignUserById(Integer id, Integer userGroupId);
 }

+ 31 - 3
chuanyi_server/src/main/java/com/judong/chuanyiserver/service/impl/ReportTableServiceImpl.java

@@ -1,17 +1,17 @@
 package com.judong.chuanyiserver.service.impl;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.judong.chuanyiserver.dao.ReportTableDao;
 import com.judong.chuanyiserver.dao.UserGroupDao;
 import com.judong.chuanyiserver.dynamicSchedule.CronTaskRegister;
-import com.judong.chuanyiserver.dynamicSchedule.ScheduledTask;
 import com.judong.chuanyiserver.dynamicSchedule.SchedulingRunnable;
 import com.judong.chuanyiserver.entity.ReportTable;
 import com.judong.chuanyiserver.entity.TableTemplate;
 import com.judong.chuanyiserver.entity.UserGroupUser;
 import com.judong.chuanyiserver.enums.ResultEnum;
 import com.judong.chuanyiserver.service.ReportTableService;
-import com.judong.chuanyiserver.task.TestTask;
+import com.judong.chuanyiserver.task.ReportTableTask;
 import com.judong.chuanyiserver.util.Blank;
 import com.judong.chuanyiserver.util.ConstantStr;
 import com.judong.chuanyiserver.util.Result;
@@ -108,6 +108,26 @@ public class ReportTableServiceImpl implements ReportTableService {
 
     @Override
     public Result getReportTableById(Integer id) {
+//        ReportTable reportTable = reportTableDao.getReportTableById(id);
+//        String reportTableData = reportTable.getReportTableData();
+//        JSONObject jsonObject = JSONObject.parseObject(reportTableData);
+//        String tables = jsonObject.getString("tables");
+//        JSONArray objects = JSONObject.parseArray(tables);
+//        String string = objects.getString(0);
+//        JSONObject jsonObject1 = JSONObject.parseObject(string);
+//        String item = jsonObject1.getString("item");
+//        JSONArray objects1 = JSONObject.parseArray(item);
+//        if (Blank.isNotEmpty(objects1)) {
+//            for (int i = 0; i < objects1.size(); i++) {
+//                objects1.getJSONObject(i);
+//                objects1.set(i, "");
+//            }
+//        }
+//        //通过报表的配置,获取相应的配置信息
+//
+//        //根据配置信息获取相应的数据
+//
+//        //根据相应的数据,将值返回到json里面,然后存储起来
         return Result.ok(reportTableDao.getReportTableById(id));
     }
 
@@ -139,7 +159,7 @@ public class ReportTableServiceImpl implements ReportTableService {
                 return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "此报表已经是自动报表");
             }
 //            SchedulingRunnable task = new SchedulingRunnable(Class.forName(""), "test1", null);
-            SchedulingRunnable task = new SchedulingRunnable(TestTask.class, "test1", null);
+            SchedulingRunnable task = new SchedulingRunnable(ReportTableTask.class, "getTableData", new Object[]{id});
 //            SchedulingRunnable task = new SchedulingRunnable(TestTask.class, "test1", new Object[]{id, cron});
             //新增定时器任务
             String cronId = "";
@@ -187,6 +207,14 @@ public class ReportTableServiceImpl implements ReportTableService {
     }
 
     @Override
+    public Result tableAssignUserById(Integer id, Integer userGroupId) {
+        if (reportTableDao.tableAssignUserById(id, userGroupId) <= 0) {
+            return Result.no(ResultEnum.SERVER_ERROR.getRespCode(), ResultEnum.SERVER_ERROR.getRespMsg());
+        }
+        return Result.ok("分配用户组成功");
+    }
+
+    @Override
     public Result getAllTableTemplate(Integer page, Integer limit, String userId) {
         JSONObject jsonObject = new JSONObject();
         if (Blank.isEmpty(userId)) {

+ 46 - 0
chuanyi_server/src/main/java/com/judong/chuanyiserver/task/ReportTableTask.java

@@ -0,0 +1,46 @@
+package com.judong.chuanyiserver.task;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.judong.chuanyiserver.dao.ReportTableDao;
+import com.judong.chuanyiserver.entity.ReportTable;
+import com.judong.chuanyiserver.util.Blank;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+
+@Component
+public class ReportTableTask {
+
+    @Resource
+    private ReportTableDao reportTableDao;
+
+    //    public void test1(Integer id, String cron) {
+//        System.out.println("我是id=" + id + "的定时器,我执行成功cron是:" + cron);
+//    }
+    public void test1() {
+        System.out.println("我是定时器,我执行了");
+    }
+
+    public void getTableData(Integer id) {
+        ReportTable reportTable = reportTableDao.getReportTableById(id);
+        String reportTableData = reportTable.getReportTableData();
+        JSONObject jsonObject = JSONObject.parseObject(reportTableData);
+        String tables = jsonObject.getString("tables");
+        JSONArray objects = JSONObject.parseArray(tables);
+        String string = objects.getString(0);
+        JSONObject jsonObject1 = JSONObject.parseObject(string);
+        String item = jsonObject1.getString("item");
+        JSONArray objects1 = JSONObject.parseArray(item);
+        if (Blank.isNotEmpty(objects1)){
+            for (Object xx: objects1) {
+                System.out.println(xx);
+            }
+        }
+        //通过报表的配置,获取相应的配置信息
+
+        //根据配置信息获取相应的数据
+
+        //根据相应的数据,将值返回到json里面,然后存储起来
+    }
+}

+ 0 - 14
chuanyi_server/src/main/java/com/judong/chuanyiserver/task/TestTask.java

@@ -1,14 +0,0 @@
-package com.judong.chuanyiserver.task;
-
-import org.springframework.stereotype.Component;
-
-@Component
-public class TestTask {
-
-    //    public void test1(Integer id, String cron) {
-//        System.out.println("我是id=" + id + "的定时器,我执行成功cron是:" + cron);
-//    }
-    public void test1() {
-        System.out.println("我是定时器,我执行了");
-    }
-}

+ 76 - 72
chuanyi_server/src/main/java/com/judong/chuanyiserver/util/Blank.java

@@ -103,6 +103,9 @@ public class Blank {
         if (obj == null) {
             return true;
         }
+        if (obj.equals("null")) {
+            return true;
+        }
         if ((obj instanceof String)) {
             return ((String) obj).trim().equals("");
         }
@@ -207,6 +210,7 @@ public class Blank {
 
     /**
      * 验证是否为手机号
+     *
      * @param phone
      * @return
      */
@@ -222,92 +226,92 @@ public class Blank {
 
         return true;
     }
-    
+
     public static void main(String[] args) {
-    	Map<String, String> params = new HashMap<>();
-    	params.put("区市场监管局", "区市场监督管理局");
-    	params.put("区文化和旅游发展委员会", "区文化旅游委");
-    	params.put("区教育委员会", "区教委");
-    	params.put("区应急管理局", "区应急局");
-    	params.put("区民族宗教事务委员会", "区民宗委");
-    	params.put("区住房和城乡建设委员会", "区住房城乡建委");
-    	params.put("区农业农村委员会", "区农业农村委");
-    	
-    	ExcelReader reader = cn.hutool.poi.excel.ExcelUtil.getReader("D:/cqf/nanan.xlsx");
-    	List<Map<String,Object>> readAll = reader.readAll();
-    	JSONArray array = new JSONArray();
-    	JSONObject obj;
-    	String sql = "INSERT INTO question_article (\r\n" + 
-    			"	dataId,\r\n" + 
-    			"	title,\r\n" + 
-    			"	content,\r\n" + 
-    			"	publishTime,\r\n" + 
-    			"	departmentName,\r\n" + 
-    			"	createTime,\r\n" + 
-    			"	e_top\r\n" + 
-    			")\r\n" + 
-    			"VALUES";
-    	int ii = 10000;
-    	for (int i = 0; i < readAll.size(); i++) {
-    		Map<String,Object> map = readAll.get(i);
-    		obj = new JSONObject();
-    		String name = String.valueOf(map.get("name")).substring(5);
-			obj.put("name", Blank.notBlank(params.get(name)) ? params.get(name) : name);
-			String remark = String.valueOf(map.get("remark"));
-			String[] str = remark.split("\n");
-			if (str.length == 3) {
-				if (str[1].indexOf("常见问题问题:") == 0) {
-					obj.put("title", str[1].substring(7));
-				} else if (str[1].indexOf("问题:") == 0) {
-					obj.put("title", str[1].substring(3));
-				}
-				if (str[2].indexOf("解答:答") == 0) {
-					obj.put("content", str[2].substring(5));
-				} else if (str[2].indexOf("解答:") == 0) {
-					obj.put("content", str[2].substring(3));
-				}
-			} else {
-				if (str[0].indexOf("常见问题问题:") == 0) {
-					obj.put("title", str[0].substring(7));
-				} else if (str[0].indexOf("问题:") == 0) {
-					obj.put("title", str[0].substring(3));
-				}
-				if (str[1].indexOf("解答:答") == 0) {
-					obj.put("content", str[1].substring(5));
-				} else if (str[1].indexOf("解答:") == 0) {
-					obj.put("content", str[1].substring(3));
-				}
-			}
-    		array.add(obj);
-    		sql += "("+ (ii+i) +", '"+ obj.get("title") +"', '"+ obj.get("content") +"', '"+ randomDate("2021-01-01","2021-12-13") +"', '"
-    		+ obj.get("name") +"', now(), 0),";
-		}
-    	System.err.println(array);
-    	System.err.println(sql);
-	}
+        Map<String, String> params = new HashMap<>();
+        params.put("区市场监管局", "区市场监督管理局");
+        params.put("区文化和旅游发展委员会", "区文化旅游委");
+        params.put("区教育委员会", "区教委");
+        params.put("区应急管理局", "区应急局");
+        params.put("区民族宗教事务委员会", "区民宗委");
+        params.put("区住房和城乡建设委员会", "区住房城乡建委");
+        params.put("区农业农村委员会", "区农业农村委");
 
-    private static String randomDate(String beginDate,String endDate){
+        ExcelReader reader = cn.hutool.poi.excel.ExcelUtil.getReader("D:/cqf/nanan.xlsx");
+        List<Map<String, Object>> readAll = reader.readAll();
+        JSONArray array = new JSONArray();
+        JSONObject obj;
+        String sql = "INSERT INTO question_article (\r\n" +
+                "	dataId,\r\n" +
+                "	title,\r\n" +
+                "	content,\r\n" +
+                "	publishTime,\r\n" +
+                "	departmentName,\r\n" +
+                "	createTime,\r\n" +
+                "	e_top\r\n" +
+                ")\r\n" +
+                "VALUES";
+        int ii = 10000;
+        for (int i = 0; i < readAll.size(); i++) {
+            Map<String, Object> map = readAll.get(i);
+            obj = new JSONObject();
+            String name = String.valueOf(map.get("name")).substring(5);
+            obj.put("name", Blank.notBlank(params.get(name)) ? params.get(name) : name);
+            String remark = String.valueOf(map.get("remark"));
+            String[] str = remark.split("\n");
+            if (str.length == 3) {
+                if (str[1].indexOf("常见问题问题:") == 0) {
+                    obj.put("title", str[1].substring(7));
+                } else if (str[1].indexOf("问题:") == 0) {
+                    obj.put("title", str[1].substring(3));
+                }
+                if (str[2].indexOf("解答:答") == 0) {
+                    obj.put("content", str[2].substring(5));
+                } else if (str[2].indexOf("解答:") == 0) {
+                    obj.put("content", str[2].substring(3));
+                }
+            } else {
+                if (str[0].indexOf("常见问题问题:") == 0) {
+                    obj.put("title", str[0].substring(7));
+                } else if (str[0].indexOf("问题:") == 0) {
+                    obj.put("title", str[0].substring(3));
+                }
+                if (str[1].indexOf("解答:答") == 0) {
+                    obj.put("content", str[1].substring(5));
+                } else if (str[1].indexOf("解答:") == 0) {
+                    obj.put("content", str[1].substring(3));
+                }
+            }
+            array.add(obj);
+            sql += "(" + (ii + i) + ", '" + obj.get("title") + "', '" + obj.get("content") + "', '" + randomDate("2021-01-01", "2021-12-13") + "', '"
+                    + obj.get("name") + "', now(), 0),";
+        }
+        System.err.println(array);
+        System.err.println(sql);
+    }
+
+    private static String randomDate(String beginDate, String endDate) {
         try {
             SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
             Date start = format.parse(beginDate);
             Date end = format.parse(endDate);
- 
-            if(start.getTime() >= end.getTime()){
+
+            if (start.getTime() >= end.getTime()) {
                 return null;
             }
-            long date = random(start.getTime(),end.getTime());
+            long date = random(start.getTime(), end.getTime());
             format.format(new Date(date));
-            return  format.format(new Date(date));
+            return format.format(new Date(date));
         } catch (Exception e) {
             e.printStackTrace();
         }
         return null;
     }
- 
-    private static long random(long begin,long end){
-        long rtn = begin + (long)(Math.random() * (end - begin));
-        if(rtn == begin || rtn == end){
-            return random(begin,end);
+
+    private static long random(long begin, long end) {
+        long rtn = begin + (long) (Math.random() * (end - begin));
+        if (rtn == begin || rtn == end) {
+            return random(begin, end);
         }
         return rtn;
     }

+ 6 - 0
chuanyi_server/src/main/resources/mapper/ReportTableDao.xml

@@ -58,6 +58,12 @@
         where id = #{id}
     </update>
 
+    <update id="tableAssignUserById">
+        update t_report_table
+        set user_group_id=#{userGroupId}
+        where id = #{id}
+    </update>
+
     <delete id="delTableTemplateById">
         delete
         from t_table_template