浏览代码

加入数据对接模块

wangliang 1 周之前
父节点
当前提交
a90a90f3a9

+ 117 - 0
data-docking/init/data-docking-2.0.2.sql

@@ -0,0 +1,117 @@
+USE data-docking;
+-- ----------------------------
+-- Table structure for basic_school
+-- ----------------------------
+DROP TABLE IF EXISTS `basic_school`;
+CREATE TABLE `basic_school` (
+                                `id` bigint NOT NULL COMMENT '主键',
+                                `code` varchar(20) NOT NULL COMMENT '学校编码',
+                                `name` varchar(100) DEFAULT NULL COMMENT '学校名称',
+                                `enable` tinyint NOT NULL DEFAULT '1' COMMENT '是否启用,false:停用,true:启用',
+                                `access_key` varchar(50) DEFAULT NULL COMMENT '访问key',
+                                `access_secret` varchar(50) DEFAULT NULL COMMENT '访问秘钥',
+                                `remark` text COMMENT '备注',
+                                `create_id` bigint DEFAULT NULL COMMENT '创建人',
+                                `create_time` bigint DEFAULT NULL COMMENT '创建时间',
+                                `update_id` bigint DEFAULT NULL COMMENT '更新人',
+                                `update_time` bigint DEFAULT NULL COMMENT '更新时间',
+                                `logo` varchar(500) DEFAULT NULL COMMENT '学校logo',
+                                PRIMARY KEY (`id`) USING BTREE,
+                                UNIQUE KEY `code` (`code`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='学校表';
+
+-- ----------------------------
+-- Table structure for sys_setting
+-- ----------------------------
+DROP TABLE IF EXISTS `sys_setting`;
+CREATE TABLE `sys_setting` (
+                               `id` bigint NOT NULL,
+                               `school_id` bigint NOT NULL COMMENT '学校Id',
+                               `parameter_object` mediumtext NOT NULL COMMENT '参数对象(json)',
+                               `create_id` bigint DEFAULT NULL COMMENT '创建人',
+                               `create_time` bigint DEFAULT NULL COMMENT '创建时间',
+                               `update_id` bigint DEFAULT NULL COMMENT '更新人',
+                               `update_time` bigint DEFAULT NULL COMMENT '更新时间',
+                               PRIMARY KEY (`id`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='系统设置';
+
+-- ----------------------------
+-- Table structure for t_s_auth
+-- ----------------------------
+DROP TABLE IF EXISTS `t_s_auth`;
+CREATE TABLE `t_s_auth` (
+                            `id` bigint NOT NULL COMMENT '主键',
+                            `school_id` bigint NOT NULL COMMENT '学校id',
+                            `access_key` varchar(255) DEFAULT NULL COMMENT 'accessKey',
+                            `access_secret` varchar(255) DEFAULT NULL COMMENT 'accessSecret',
+                            `description` text COMMENT '离线授权证书',
+                            `type` varchar(16) NOT NULL COMMENT '授权类型',
+                            `create_id` bigint DEFAULT NULL COMMENT '创建人',
+                            `create_time` bigint DEFAULT NULL COMMENT '创建时间',
+                            `update_id` bigint DEFAULT NULL COMMENT '更新人',
+                            `update_time` bigint DEFAULT NULL COMMENT '更新时间',
+                            `expire_time` bigint DEFAULT NULL COMMENT '过期时间',
+                            `file` mediumblob COMMENT '文件数据',
+                            PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='激活授权配置表';
+
+-- ----------------------------
+-- Table structure for t_s_token
+-- ----------------------------
+DROP TABLE IF EXISTS `t_s_token`;
+CREATE TABLE `t_s_token` (
+                             `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
+                             `code` varchar(100) NOT NULL COMMENT '学校编码',
+                             `access_token` varchar(100) NOT NULL COMMENT 'token',
+                             `token_type` varchar(50) DEFAULT NULL COMMENT 'token类型',
+                             `refresh_token` varchar(100) DEFAULT NULL COMMENT '刷新token',
+                             `expires_in` int DEFAULT NULL COMMENT '有效时间',
+                             `scope` varchar(50) DEFAULT NULL COMMENT '范围',
+                             `license` varchar(100) DEFAULT NULL COMMENT '许可证',
+                             `create_time` bigint NOT NULL COMMENT '创建时间',
+                             `update_time` bigint DEFAULT NULL COMMENT '更新时间',
+                             PRIMARY KEY (`id`),
+                             UNIQUE KEY `t_s_token_unique` (`code`) USING BTREE
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='token表';
+
+-- ----------------------------
+-- Table structure for YJXT_KCXX
+-- ----------------------------
+DROP TABLE IF EXISTS `YJXT_KCXX`;
+CREATE TABLE `YJXT_KCXX` (
+                             `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
+                             `code` varchar(100) NOT NULL COMMENT '课程代码',
+                             `name` varchar(100) NOT NULL COMMENT '课程名称',
+                             `collegeName` varchar(200) NOT NULL COMMENT '机构名称(二级学院)',
+                             PRIMARY KEY (`id`),
+                             UNIQUE KEY `YJXT_KCXX_UNIQUE` (`code`,`collegeName`) USING BTREE
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='课程信息表';
+
+-- ----------------------------
+-- Table structure for YJXT_KSXX
+-- ----------------------------
+DROP TABLE IF EXISTS `YJXT_KSXX`;
+CREATE TABLE `YJXT_KSXX` (
+                             `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
+                             `xnm` varchar(100) NOT NULL COMMENT '学年名',
+                             `xqm` varchar(100) DEFAULT NULL COMMENT '学期名',
+                             `courseCode` varchar(100) NOT NULL COMMENT '课程编号',
+                             `courseName` varchar(100) NOT NULL COMMENT '课程名称',
+                             `courseCollegeName` varchar(200) DEFAULT NULL COMMENT '课程开课学院',
+                             `paperNumber` varchar(100) NOT NULL COMMENT '试卷编号',
+                             `studentName` varchar(100) NOT NULL COMMENT '姓名',
+                             `studentCode` varchar(100) NOT NULL COMMENT '学号',
+                             `siteNumber` varchar(100) DEFAULT NULL COMMENT '座位号',
+                             `studentCollegeName` varchar(100) DEFAULT NULL COMMENT '学生学院',
+                             `majorName` varchar(100) DEFAULT NULL COMMENT '专业',
+                             `teachClassName` varchar(100) NOT NULL COMMENT '教学班',
+                             `className` varchar(100) DEFAULT NULL COMMENT '行政班',
+                             `examDate` varchar(100) NOT NULL COMMENT '考试日期',
+                             `examTime` varchar(100) NOT NULL COMMENT '考试时间',
+                             `examPlace` varchar(100) NOT NULL COMMENT '考点',
+                             `examRoom` varchar(100) DEFAULT NULL COMMENT '考场',
+                             `teacherCode` varchar(100) DEFAULT NULL COMMENT '命题老师工号',
+                             `teacherName` varchar(100) DEFAULT NULL COMMENT '命题老师姓名',
+                             PRIMARY KEY (`id`),
+                             UNIQUE KEY `YJXT_KSXX_UNIQUE` (`xnm`,`xqm`,`courseCode`,`paperNumber`,`studentCode`) USING BTREE
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='考生数据表';

+ 2 - 0
data-docking/src/main/java/com/qmth/data/docking/DataDockingApplication.java

@@ -7,6 +7,7 @@ import org.springframework.boot.autoconfigure.domain.EntityScan;
 import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
 import org.springframework.cache.annotation.EnableCaching;
 import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.transaction.annotation.EnableTransactionManagement;
 
 @SpringBootApplication(scanBasePackages = "com.qmth.*", exclude = {SecurityAutoConfiguration.class})
@@ -17,6 +18,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
 @EnableTransactionManagement // spring开启事务支持
 @EnableAsync // 开启异步任务
 @EnableCaching // 开启缓存注解
+@EnableScheduling
 public class DataDockingApplication {
 
     public static void main(String[] args) {

+ 3 - 1
data-docking/src/main/java/com/qmth/data/docking/entity/TSToken.java

@@ -1,5 +1,7 @@
 package com.qmth.data.docking.entity;
 
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.qmth.data.docking.bean.result.ZufeLoginResult;
@@ -24,6 +26,7 @@ public class TSToken implements Serializable {
 
     @JsonSerialize(using = ToStringSerializer.class)
     @ApiModelProperty(value = "主键")
+    @TableId(value = "id",type = IdType.AUTO)
     private Long id;
 
     @ApiModelProperty(value = "学校编码")
@@ -58,7 +61,6 @@ public class TSToken implements Serializable {
     }
 
     public TSToken(ZufeLoginResult zufeLoginResult, String code) {
-        this.id = SystemConstant.getDbUuid();
         this.code = code;
         this.accessToken = zufeLoginResult.getAccess_token();
         this.tokenType = zufeLoginResult.getToken_type();

+ 3 - 1
data-docking/src/main/java/com/qmth/data/docking/entity/YjxtKcxx.java

@@ -1,6 +1,8 @@
 package com.qmth.data.docking.entity;
 
+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 com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
@@ -28,6 +30,7 @@ public class YjxtKcxx implements Serializable {
 
     @JsonSerialize(using = ToStringSerializer.class)
     @ApiModelProperty(value = "主键")
+    @TableId(value = "id",type = IdType.AUTO)
     private Long id;
 
     @ApiModelProperty(value = "课程代码")
@@ -45,7 +48,6 @@ public class YjxtKcxx implements Serializable {
     }
 
     public YjxtKcxx(ZufeCourseResult zufeCourseResult) {
-        this.id = SystemConstant.getDbUuid();
         this.code = zufeCourseResult.getKCH();
         this.name = zufeCourseResult.getKCMC();
         this.collegeName = zufeCourseResult.getKKXY();

+ 3 - 1
data-docking/src/main/java/com/qmth/data/docking/entity/YjxtKsxx.java

@@ -1,6 +1,8 @@
 package com.qmth.data.docking.entity;
 
+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 com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
@@ -29,6 +31,7 @@ public class YjxtKsxx implements Serializable {
 
     @JsonSerialize(using = ToStringSerializer.class)
     @ApiModelProperty(value = "主键")
+    @TableId(value = "id",type = IdType.AUTO)
     private Long id;
 
     @ApiModelProperty(value = "学年名")
@@ -110,7 +113,6 @@ public class YjxtKsxx implements Serializable {
     }
 
     public YjxtKsxx(ZufeExamResult zufeExamResult) {
-        this.id = SystemConstant.getDbUuid();
         this.xnm = zufeExamResult.getXNM();
         this.xqm = zufeExamResult.getXQM();
         this.courseCode = zufeExamResult.getKCH();

+ 38 - 0
data-docking/src/main/java/com/qmth/data/docking/quartz/ScheduledTask.java

@@ -0,0 +1,38 @@
+package com.qmth.data.docking.quartz;
+
+import com.qmth.data.docking.service.JobService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.io.IOException;
+
+/**
+ * @Description: 定时任务
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2021/9/1
+ */
+@Component
+public class ScheduledTask implements InitializingBean {
+    private final static Logger log = LoggerFactory.getLogger(ScheduledTask.class);
+
+    @Resource
+    JobService jobService;
+
+    @Scheduled(cron = "0 0 4 * * ?")
+//    @Scheduled(cron = "0/15 * * * * ?")
+    public void syncZufeData() throws IOException {
+        log.info("syncZufeData is come in");
+        jobService.syncZufeData();
+    }
+
+    @Override
+    public void afterPropertiesSet() throws Exception {
+        this.syncZufeData();
+    }
+}

+ 18 - 0
data-docking/src/main/java/com/qmth/data/docking/service/JobService.java

@@ -0,0 +1,18 @@
+package com.qmth.data.docking.service;
+
+import java.io.IOException;
+
+/**
+ * @Description: job service
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2021/3/31
+ */
+public interface JobService {
+
+    /**
+     * 同步浙财教务数据
+     */
+    void syncZufeData() throws IOException;
+}

+ 39 - 0
data-docking/src/main/java/com/qmth/data/docking/service/impl/JobServiceImpl.java

@@ -0,0 +1,39 @@
+package com.qmth.data.docking.service.impl;
+
+import com.qmth.data.docking.entity.TSToken;
+import com.qmth.data.docking.service.JobService;
+import com.qmth.data.docking.util.zufe.ZufeDataDockingUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.io.IOException;
+import java.util.Objects;
+
+/**
+ * @Description: job service impl
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2021/3/31
+ */
+@Service
+public class JobServiceImpl implements JobService {
+    private final static Logger log = LoggerFactory.getLogger(JobServiceImpl.class);
+
+    @Resource
+    ZufeDataDockingUtil zufeDataDockingUtil;
+
+    /**
+     * 同步浙财教务数据
+     */
+    @Override
+    public void syncZufeData() throws IOException {
+        TSToken tsToken = zufeDataDockingUtil.login(com.qmth.data.docking.util.zufe.Constants.KEY, com.qmth.data.docking.util.zufe.Constants.SECRET);
+        if (Objects.nonNull(tsToken) && Objects.nonNull(tsToken.getAccessToken())) {
+            zufeDataDockingUtil.course(tsToken.getAccessToken());
+            zufeDataDockingUtil.exam(tsToken.getAccessToken());
+        }
+    }
+}

+ 4 - 0
data-docking/src/main/java/com/qmth/data/docking/util/zufe/Constants.java

@@ -13,4 +13,8 @@ public interface Constants {
 
     // 数据同步考试地址
     String EXAM_API_URI = CAS_BASE_PATH + "/open_api/customization/tgxjxbkskssjxx/full";
+
+    String KEY = "20250218273918917382066474926082282";
+
+    String SECRET = "a33fc034ddce1e398f325b391b65fead3ef9fa5c";
 }

文件差异内容过多而无法显示
+ 1 - 1
data-docking/src/main/java/com/qmth/data/docking/util/zufe/ZufeDataDockingUtil.java


部分文件因为文件数量过多而无法显示