Commit 2675577c2053f785189834d785bfd381349d2a79

Authored by 陈杰
1 parent a2a3d070
Exists in master

翼学云 增量接口

Showing 27 changed files with 1935 additions and 817 deletions   Show diff stats
cloud/quartz/pom.xml
... ... @@ -30,6 +30,11 @@
30 30 </dependency>
31 31 <dependency>
32 32 <groupId>org.springframework.boot</groupId>
  33 + <artifactId>spring-boot-starter-web</artifactId>
  34 + <version>2.2.5.RELEASE</version>
  35 + </dependency>
  36 + <dependency>
  37 + <groupId>org.springframework.boot</groupId>
33 38 <artifactId>spring-boot-starter-test</artifactId>
34 39 <scope>test</scope>
35 40 </dependency>
... ...
cloud/quartz/src/main/java/com/sincere/quartz/QuartzApplication.java
... ... @@ -15,12 +15,12 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
15 15 * @version 1.0
16 16 * @date 2019/11/27 0027 14:24
17 17 */
  18 +@EnableEurekaClient
18 19 @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
19 20 @EnableTransactionManagement(order = 2) //设置事务执行顺序(需要在切换数据源之后,否则只走主库)
20 21 @EnableCaching
21 22 @EnableScheduling
22 23 @EnableFeignClients(basePackages = "com.sincere.quartz.feign")
23   -@EnableEurekaClient
24 24 @MapperScan("com.sincere.quartz.mapper")
25 25 public class QuartzApplication {
26 26  
... ...
cloud/quartz/src/main/java/com/sincere/quartz/Swagger2.java 0 → 100644
... ... @@ -0,0 +1,39 @@
  1 +package com.sincere.quartz;
  2 +
  3 +import org.springframework.context.annotation.Bean;
  4 +import org.springframework.context.annotation.Configuration;
  5 +import springfox.documentation.builders.ApiInfoBuilder;
  6 +import springfox.documentation.builders.ParameterBuilder;
  7 +import springfox.documentation.builders.PathSelectors;
  8 +import springfox.documentation.builders.RequestHandlerSelectors;
  9 +import springfox.documentation.service.ApiInfo;
  10 +import springfox.documentation.spi.DocumentationType;
  11 +import springfox.documentation.spring.web.plugins.Docket;
  12 +import springfox.documentation.swagger2.annotations.EnableSwagger2;
  13 +
  14 +@EnableSwagger2
  15 +@Configuration //让Spring来加载该类配置
  16 +public class Swagger2 {
  17 +
  18 + @Bean
  19 + public Docket createRestApi() {
  20 + return new Docket(DocumentationType.SWAGGER_2)
  21 + .apiInfo(apiInfo())
  22 + .enableUrlTemplating(false)
  23 + .select()
  24 + // 扫描所有有注解的api,用这种方式更灵活
  25 + .apis(RequestHandlerSelectors.basePackage("com.sincere.quartz.controller"))
  26 + .paths(PathSelectors.any())
  27 + .build();
  28 +
  29 + }
  30 +
  31 + private ApiInfo apiInfo() {
  32 + return new ApiInfoBuilder()
  33 + .title("Spring Boot中使用Swagger2构建RESTful APIs")
  34 + .description("接口文档")
  35 + .termsOfServiceUrl("")
  36 + .version("1.0")
  37 + .build();
  38 + }
  39 +}
... ...
cloud/quartz/src/main/java/com/sincere/quartz/controller/YxyController.java 0 → 100644
... ... @@ -0,0 +1,74 @@
  1 +package com.sincere.quartz.controller;
  2 +
  3 +import com.sincere.common.dto.smartCampus.SyncSchoolDto;
  4 +import com.sincere.common.dto.smartCampus.SyncUserDto;
  5 +import com.sincere.quartz.dto.BaseDto;
  6 +import com.sincere.quartz.feign.ScFeign;
  7 +import com.sincere.quartz.service.YxyService;
  8 +import com.sincere.quartz.third.yixueyun.YXYAddReadService;
  9 +import com.sincere.quartz.third.yixueyun.YXYReadService;
  10 +import com.sincere.quartz.third.yixueyun.YXYWriteService;
  11 +import io.swagger.annotations.Api;
  12 +import io.swagger.annotations.ApiOperation;
  13 +import org.springframework.beans.factory.annotation.Autowired;
  14 +import org.springframework.web.bind.annotation.RequestMapping;
  15 +import org.springframework.web.bind.annotation.RequestMethod;
  16 +import org.springframework.web.bind.annotation.RestController;
  17 +
  18 +import java.util.List;
  19 +
  20 +@RestController
  21 +@RequestMapping("/sync")
  22 +@Api(value = "同步")
  23 +public class YxyController {
  24 +
  25 + @Autowired
  26 + YXYReadService readService ;
  27 +
  28 + @Autowired
  29 + YXYWriteService writeService ;
  30 +
  31 + @Autowired
  32 + ScFeign scFeign;
  33 +
  34 + @Autowired
  35 + YXYAddReadService addReadService ;
  36 +
  37 + @Autowired
  38 + YxyService yxyService ;
  39 +
  40 + @ApiOperation(value = "test")
  41 + @RequestMapping(value = "test",method = RequestMethod.GET)
  42 + public void test(){
  43 + addReadService.sync();
  44 + }
  45 +
  46 + @ApiOperation(value = "syncTeacher")
  47 + @RequestMapping(value = "syncTeacher",method = RequestMethod.GET)
  48 + public BaseDto syncTeacher(String schoolId){
  49 + yxyService.updateTeacherBySchool(schoolId);
  50 + readService.syncTeacher(schoolId);
  51 + return new BaseDto() ;
  52 + }
  53 +
  54 + @ApiOperation(value = "syncStudent")
  55 + @RequestMapping(value = "syncStudent",method = RequestMethod.GET)
  56 + public BaseDto syncStudent(String schoolId){
  57 + yxyService.updateStudentBySchool(schoolId);
  58 + readService.syncStudent(schoolId);
  59 + return new BaseDto() ;
  60 + }
  61 +
  62 + @ApiOperation(value = "syncWrite")
  63 + @RequestMapping(value = "syncWrite",method = RequestMethod.GET)
  64 + public BaseDto syncWrite(int hxyId){
  65 + List<SyncSchoolDto> schoolList = scFeign.selectSyncSchool();
  66 + for (SyncSchoolDto school : schoolList) {
  67 + if(school.getSchoolId() == hxyId){
  68 + List<SyncUserDto> userList = scFeign.selectUser(school.getSchoolId());
  69 + writeService.syncUser(school, userList);
  70 + }
  71 + }
  72 + return new BaseDto();
  73 + }
  74 +}
... ...
cloud/quartz/src/main/java/com/sincere/quartz/datasource/DataSourceConfig.java
... ... @@ -12,45 +12,53 @@ import java.util.Map;
12 12  
13 13 /**
14 14 * 数据源配置
  15 + *
15 16 */
16 17 @Configuration
17 18 public class DataSourceConfig {
18 19  
19   - @Bean(name = "master")
20   - @ConfigurationProperties(prefix = "datasource.master")
21   - public DataSource dataSource1() {
22   - return DataSourceBuilder.create().build();
23   - }
24   -
25   - @Bean(name = "slave")
26   - @ConfigurationProperties(prefix = "datasource.slave")
27   - public DataSource dataSource2() {
28   - return DataSourceBuilder.create().build();
29   - }
30   -
31   - @Bean(name = "yxy")
32   - @ConfigurationProperties(prefix = "datasource.yxy")
33   - public DataSource dataSource3() {
34   - return DataSourceBuilder.create().build();
35   - }
36   -
37   -
38   - @Bean(name = "dynamicDataSource")
39   - @Primary //优先使用,多数据源
40   - public DataSource dataSource() {
41   - DynamicDataSource dynamicDataSource = new DynamicDataSource();
42   - DataSource master = dataSource1();
43   - DataSource slave = dataSource2();
44   - DataSource yxy = dataSource3();
45   - //设置默认数据源
46   - dynamicDataSource.setDefaultTargetDataSource(master);
47   - //配置多数据源
48   - Map<Object, Object> map = new HashMap<>();
49   - map.put(DataSourceType.Master.getName(), master); //key需要跟ThreadLocal中的值对应
50   - map.put(DataSourceType.Slave.getName(), slave);
51   - map.put(DataSourceType.Yxy.getName(), yxy);
52   - dynamicDataSource.setTargetDataSources(map);
53   - return dynamicDataSource;
54   - }
  20 + @Bean(name = "master")
  21 + @ConfigurationProperties(prefix = "datasource.master")
  22 + public DataSource dataSource1() {
  23 + return DataSourceBuilder.create().build();
  24 + }
55 25  
  26 + @Bean(name = "slave")
  27 + @ConfigurationProperties(prefix = "datasource.slave")
  28 + public DataSource dataSource2() {
  29 + return DataSourceBuilder.create().build();
  30 + }
  31 +
  32 + @Bean(name = "yxy")
  33 + @ConfigurationProperties(prefix = "datasource.yxy")
  34 + public DataSource dataSource3() {
  35 + return DataSourceBuilder.create().build();
  36 + }
  37 +
  38 + @Bean(name = "update")
  39 + @ConfigurationProperties(prefix = "datasource.update")
  40 + public DataSource dataSource4() {
  41 + return DataSourceBuilder.create().build();
  42 + }
  43 +
  44 + @Bean(name="dynamicDataSource")
  45 + @Primary //优先使用,多数据源
  46 + public DataSource dataSource() {
  47 + DynamicDataSource dynamicDataSource = new DynamicDataSource();
  48 + DataSource master = dataSource1();
  49 + DataSource slave = dataSource2();
  50 + DataSource yxy = dataSource3();
  51 + DataSource update = dataSource4();
  52 + //设置默认数据源
  53 + dynamicDataSource.setDefaultTargetDataSource(master);
  54 + //配置多数据源
  55 + Map<Object,Object> map = new HashMap<>();
  56 + map.put(DataSourceType.Master.getName(), master); //key需要跟ThreadLocal中的值对应
  57 + map.put(DataSourceType.Slave.getName(), slave);
  58 + map.put(DataSourceType.Yxy.getName(), yxy);
  59 + map.put(DataSourceType.Update.getName(), update);
  60 + dynamicDataSource.setTargetDataSources(map);
  61 + return dynamicDataSource;
  62 + }
  63 +
56 64 }
... ...
cloud/quartz/src/main/java/com/sincere/quartz/datasource/DataSourceType.java
... ... @@ -2,24 +2,26 @@ package com.sincere.quartz.datasource;
2 2  
3 3 public enum DataSourceType {
4 4  
5   - Master("master"),
  5 + Master("master"),
6 6  
7   - Slave("slave"),
  7 + Slave("slave"),
8 8  
9   - Yxy("yxy");
  9 + Yxy("yxy"),
10 10  
  11 + Update("update");
11 12  
12   - private String name;
13 13  
14   - private DataSourceType(String name) {
15   - this.name = name;
16   - }
  14 + private String name;
17 15  
18   - public String getName() {
19   - return name;
20   - }
  16 + private DataSourceType(String name) {
  17 + this.name = name;
  18 + }
21 19  
22   - public void setName(String name) {
23   - this.name = name;
24   - }
  20 + public String getName() {
  21 + return name;
  22 + }
  23 +
  24 + public void setName(String name) {
  25 + this.name = name;
  26 + }
25 27 }
... ...
cloud/quartz/src/main/java/com/sincere/quartz/dto/AddStudentDto.java 0 → 100644
... ... @@ -0,0 +1,51 @@
  1 +package com.sincere.quartz.dto;
  2 +
  3 +public class AddStudentDto {
  4 +
  5 + private int appId ;
  6 + private String userId ;
  7 + private int schoolId ;
  8 + private String xml ;
  9 + private String Err;
  10 +
  11 + public String getErr() {
  12 + return Err;
  13 + }
  14 +
  15 + public void setErr(String err) {
  16 + Err = err;
  17 + }
  18 +
  19 + public int getAppId() {
  20 + return appId;
  21 + }
  22 +
  23 + public void setAppId(int appId) {
  24 + this.appId = appId;
  25 + }
  26 +
  27 + public String getUserId() {
  28 + return userId;
  29 + }
  30 +
  31 + public void setUserId(String userId) {
  32 + this.userId = userId;
  33 + }
  34 +
  35 + public int getSchoolId() {
  36 + return schoolId;
  37 + }
  38 +
  39 + public void setSchoolId(int schoolId) {
  40 + this.schoolId = schoolId;
  41 + }
  42 +
  43 + public String getXml() {
  44 + return xml;
  45 + }
  46 +
  47 + public void setXml(String xml) {
  48 + this.xml = xml;
  49 + }
  50 +
  51 +}
... ...
cloud/quartz/src/main/java/com/sincere/quartz/dto/AddTeacherDto.java 0 → 100644
... ... @@ -0,0 +1,69 @@
  1 +package com.sincere.quartz.dto;
  2 +
  3 +public class AddTeacherDto {
  4 +
  5 + private int appId ;
  6 + private String userId ;
  7 + private int schoolId ;
  8 + private String xml ;
  9 +
  10 + private String Err;
  11 + private String YongHuId;
  12 + private String LaoShiId ;
  13 +
  14 + public String getErr() {
  15 + return Err;
  16 + }
  17 +
  18 + public void setErr(String err) {
  19 + Err = err;
  20 + }
  21 +
  22 + public String getYongHuId() {
  23 + return YongHuId;
  24 + }
  25 +
  26 + public void setYongHuId(String yongHuId) {
  27 + YongHuId = yongHuId;
  28 + }
  29 +
  30 + public String getLaoShiId() {
  31 + return LaoShiId;
  32 + }
  33 +
  34 + public void setLaoShiId(String laoShiId) {
  35 + LaoShiId = laoShiId;
  36 + }
  37 +
  38 + public int getAppId() {
  39 + return appId;
  40 + }
  41 +
  42 + public void setAppId(int appId) {
  43 + this.appId = appId;
  44 + }
  45 +
  46 + public String getUserId() {
  47 + return userId;
  48 + }
  49 +
  50 + public void setUserId(String userId) {
  51 + this.userId = userId;
  52 + }
  53 +
  54 + public int getSchoolId() {
  55 + return schoolId;
  56 + }
  57 +
  58 + public void setSchoolId(int schoolId) {
  59 + this.schoolId = schoolId;
  60 + }
  61 +
  62 + public String getXml() {
  63 + return xml;
  64 + }
  65 +
  66 + public void setXml(String xml) {
  67 + this.xml = xml;
  68 + }
  69 +}
... ...
cloud/quartz/src/main/java/com/sincere/quartz/dto/BaseDto.java 0 → 100644
... ... @@ -0,0 +1,43 @@
  1 +package com.sincere.quartz.dto;
  2 +
  3 +import io.swagger.annotations.ApiModel;
  4 +import io.swagger.annotations.ApiModelProperty;
  5 +
  6 +@ApiModel
  7 +public class BaseDto<T> {
  8 +
  9 + @ApiModelProperty(value = "接口成功与否")
  10 + private boolean success ;
  11 + @ApiModelProperty(value = "错误信息")
  12 + private String message ;
  13 + @ApiModelProperty(value = "数据")
  14 + private T data ;
  15 +
  16 + public boolean isSuccess() {
  17 + return success;
  18 + }
  19 +
  20 + public void setSuccess(boolean success) {
  21 + this.success = success;
  22 + }
  23 +
  24 + public String getMessage() {
  25 + return message;
  26 + }
  27 +
  28 + public void setMessage(String message) {
  29 + this.message = message;
  30 + }
  31 +
  32 + public T getData() {
  33 + return data;
  34 + }
  35 +
  36 + public void setData(T data) {
  37 + this.data = data;
  38 + }
  39 +
  40 + public BaseDto() {
  41 + this.success = true ;
  42 + }
  43 +}
... ...
cloud/quartz/src/main/java/com/sincere/quartz/dto/EditStudentDto.java 0 → 100644
... ... @@ -0,0 +1,77 @@
  1 +package com.sincere.quartz.dto;
  2 +
  3 +public class EditStudentDto {
  4 +
  5 + private int appId ;
  6 + private String userId ;
  7 + private String studentUserId ;
  8 + private String parentUserId ;
  9 + private int studentId ;
  10 + private int parentId ;
  11 + private String xml ;
  12 + private String Err;
  13 +
  14 + public String getErr() {
  15 + return Err;
  16 + }
  17 +
  18 + public void setErr(String err) {
  19 + Err = err;
  20 + }
  21 +
  22 + public int getAppId() {
  23 + return appId;
  24 + }
  25 +
  26 + public void setAppId(int appId) {
  27 + this.appId = appId;
  28 + }
  29 +
  30 + public String getUserId() {
  31 + return userId;
  32 + }
  33 +
  34 + public void setUserId(String userId) {
  35 + this.userId = userId;
  36 + }
  37 +
  38 + public String getStudentUserId() {
  39 + return studentUserId;
  40 + }
  41 +
  42 + public void setStudentUserId(String studentUserId) {
  43 + this.studentUserId = studentUserId;
  44 + }
  45 +
  46 + public String getParentUserId() {
  47 + return parentUserId;
  48 + }
  49 +
  50 + public void setParentUserId(String parentUserId) {
  51 + this.parentUserId = parentUserId;
  52 + }
  53 +
  54 + public int getStudentId() {
  55 + return studentId;
  56 + }
  57 +
  58 + public void setStudentId(int studentId) {
  59 + this.studentId = studentId;
  60 + }
  61 +
  62 + public int getParentId() {
  63 + return parentId;
  64 + }
  65 +
  66 + public void setParentId(int parentId) {
  67 + this.parentId = parentId;
  68 + }
  69 +
  70 + public String getXml() {
  71 + return xml;
  72 + }
  73 +
  74 + public void setXml(String xml) {
  75 + this.xml = xml;
  76 + }
  77 +}
... ...
cloud/quartz/src/main/java/com/sincere/quartz/dto/EditTeacherDto.java 0 → 100644
... ... @@ -0,0 +1,41 @@
  1 +package com.sincere.quartz.dto;
  2 +
  3 +public class EditTeacherDto {
  4 +
  5 + private int appId ;
  6 + private String userId ;
  7 + private String xml ;
  8 + private String Err;
  9 +
  10 + public String getErr() {
  11 + return Err;
  12 + }
  13 +
  14 + public void setErr(String err) {
  15 + Err = err;
  16 + }
  17 +
  18 + public int getAppId() {
  19 + return appId;
  20 + }
  21 +
  22 + public void setAppId(int appId) {
  23 + this.appId = appId;
  24 + }
  25 +
  26 + public String getUserId() {
  27 + return userId;
  28 + }
  29 +
  30 + public void setUserId(String userId) {
  31 + this.userId = userId;
  32 + }
  33 +
  34 + public String getXml() {
  35 + return xml;
  36 + }
  37 +
  38 + public void setXml(String xml) {
  39 + this.xml = xml;
  40 + }
  41 +}
... ...
cloud/quartz/src/main/java/com/sincere/quartz/dto/StudentView.java 0 → 100644
... ... @@ -0,0 +1,32 @@
  1 +package com.sincere.quartz.dto;
  2 +
  3 +public class StudentView {
  4 +
  5 + private int studentId ;
  6 + private String userId ;
  7 + private String name ;
  8 +
  9 + public int getStudentId() {
  10 + return studentId;
  11 + }
  12 +
  13 + public void setStudentId(int studentId) {
  14 + this.studentId = studentId;
  15 + }
  16 +
  17 + public String getUserId() {
  18 + return userId;
  19 + }
  20 +
  21 + public void setUserId(String userId) {
  22 + this.userId = userId;
  23 + }
  24 +
  25 + public String getName() {
  26 + return name;
  27 + }
  28 +
  29 + public void setName(String name) {
  30 + this.name = name;
  31 + }
  32 +}
... ...
cloud/quartz/src/main/java/com/sincere/quartz/dto/TeacherView.java 0 → 100644
... ... @@ -0,0 +1,32 @@
  1 +package com.sincere.quartz.dto;
  2 +
  3 +public class TeacherView {
  4 +
  5 + private int teacherId ;
  6 + private String userId ;
  7 + private String name ;
  8 +
  9 + public int getTeacherId() {
  10 + return teacherId;
  11 + }
  12 +
  13 + public void setTeacherId(int teacherId) {
  14 + this.teacherId = teacherId;
  15 + }
  16 +
  17 + public String getUserId() {
  18 + return userId;
  19 + }
  20 +
  21 + public void setUserId(String userId) {
  22 + this.userId = userId;
  23 + }
  24 +
  25 + public String getName() {
  26 + return name;
  27 + }
  28 +
  29 + public void setName(String name) {
  30 + this.name = name;
  31 + }
  32 +}
... ...
cloud/quartz/src/main/java/com/sincere/quartz/job/AddYxyJob.java 0 → 100644
... ... @@ -0,0 +1,18 @@
  1 +//package com.sincere.quartz.job;
  2 +//
  3 +//import com.sincere.quartz.third.yixueyun.YXYAddReadService;
  4 +//import org.springframework.beans.factory.annotation.Autowired;
  5 +//import org.springframework.scheduling.annotation.Scheduled;
  6 +//import org.springframework.stereotype.Service;
  7 +//
  8 +//@Service
  9 +//public class AddYxyJob {
  10 +//
  11 +// @Autowired
  12 +// YXYAddReadService yxyAddReadService ;
  13 +//
  14 +// @Scheduled(cron = "30 * * * * ? ")
  15 +// public void Sync(){
  16 +// yxyAddReadService.sync();
  17 +// }
  18 +//}
... ...
cloud/quartz/src/main/java/com/sincere/quartz/job/BindPushJob.java
1   -package com.sincere.quartz.job;
2   -
3   -import com.sincere.common.dto.smartCampus.BindPushDto;
4   -import com.sincere.common.dto.smartCampus.ParentDto;
5   -import com.sincere.common.enums.PushTypeEnums;
6   -import com.sincere.common.util.DateUtils;
7   -import com.sincere.quartz.feign.ScFeign;
8   -import com.sincere.quartz.model.ShortMsg;
9   -import com.sincere.quartz.service.SmsService;
10   -import org.apache.commons.lang3.StringUtils;
11   -import org.slf4j.Logger;
12   -import org.slf4j.LoggerFactory;
13   -import org.springframework.beans.factory.annotation.Autowired;
14   -import org.springframework.scheduling.annotation.Scheduled;
15   -import org.springframework.stereotype.Service;
16   -
17   -import java.util.Date;
18   -import java.util.HashMap;
19   -import java.util.List;
20   -import java.util.Map;
21   -
22   -/**
23   - * 用户注册激活提醒
24   - *
25   - * @author chen
26   - * @version 1.0
27   - * @date 2019/12/10 0010 8:31
28   - */
29   -@Service
30   -public class BindPushJob {
31   -
32   - private Logger logger = LoggerFactory.getLogger(BindPushJob.class);
33   -
34   -
35   - @Autowired
36   - ScFeign scFeign;
37   -
38   - @Autowired
39   - SmsService smsService;
40   -
41   - private static Map<String, String> intervalDaysMap = new HashMap<>(); //redis 持久化 替换 可避免重启导致间隔的错误
42   -
43   - @Scheduled(cron = "0 0-59 * * * ? ")
44   - public void bindPush() {
45   - Date nowDate = new Date();
46   - List<BindPushDto> schoolList = scFeign.selectBindPushSchool();
47   - for (BindPushDto school : schoolList) {
48   - if (school.getBeginDate().compareTo(nowDate) <= 0 && school.getEndDate().compareTo(nowDate) >= 0) {
49   - String lastDate = intervalDaysMap.get(school.getSchoolId() + "_" + school.getType());
50   - if (StringUtils.isBlank(lastDate)) {
51   - //下发推送
52   - bindPush(school, nowDate);
53   - } else {
54   - int day = DateUtils.getDateDifference(nowDate, DateUtils.string2Date(lastDate, DateUtils.format1), "day");
55   - if (day == school.getIntervalDays() + 1) {
56   - //下发推送
57   - bindPush(school, nowDate);
58   - }
59   - }
60   - }
61   - }
62   - }
63   -
64   - private void bindPush(BindPushDto bindPushDto, Date nowDate) {
65   - if (bindPushDto.getPushTime().equals(DateUtils.date2String(nowDate, DateUtils.format4))) {
66   - intervalDaysMap.put(bindPushDto.getSchoolId() + "_" + bindPushDto.getType(), DateUtils.date2String(nowDate, DateUtils.format1));
67   - //未关注
68   - List<ParentDto> unFollowList = scFeign.selectNotFollow(bindPushDto.getSchoolId());
69   - logger.info(bindPushDto.getSchoolName() + "未关注人数" + unFollowList.size());
70   - for (ParentDto parentDto : unFollowList) {
71   - sendMessage(parentDto, bindPushDto.getMsg());
72   - }
73   - //未绑定
74   - List<ParentDto> unBindList = scFeign.selectNotBind(bindPushDto.getSchoolId(), getThirdType(bindPushDto.getType()));
75   - logger.info(bindPushDto.getSchoolName() + "未绑定人数" + unBindList.size());
76   - for (ParentDto parentDto : unBindList) {
77   - sendMessage(parentDto, bindPushDto.getMsg());
78   - }
79   - }
80   - }
81   -
82   - private void sendMessage(ParentDto parentDto, String message) {
83   - //手机号为空
84   - if (StringUtils.isNotBlank(parentDto.getMobile())) {
85   - String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format);
86   - ShortMsg shortMsg = new ShortMsg();
87   - shortMsg.setTableName("smsNew" + tableSuffix);
88   - shortMsg.setSchoolId(parentDto.getSchoolId());
89   - shortMsg.setMobile(parentDto.getMobile());
90   - shortMsg.setMsg(message);
91   - smsService.insertSMS(shortMsg);
92   - logger.info("----学校Id---" + parentDto.getSchoolId() + "----手机号----" + parentDto.getMobile() + "---" + message);
93   - }
94   - }
95   -
96   - // 0是企业号,1是钉钉
97   - private int getThirdType(int type) {
98   - if (type == 0) {
99   - return PushTypeEnums.QIYEHAO.getType();
100   - } else {
101   - return PushTypeEnums.DING.getType();
102   - }
103   - }
104   -
105   -}
  1 +//package com.sincere.quartz.job;
  2 +//
  3 +//import com.sincere.common.dto.smartCampus.BindPushDto;
  4 +//import com.sincere.common.dto.smartCampus.ParentDto;
  5 +//import com.sincere.common.enums.PushTypeEnums;
  6 +//import com.sincere.common.util.DateUtils;
  7 +//import com.sincere.quartz.feign.ScFeign;
  8 +//import com.sincere.quartz.model.ShortMsg;
  9 +//import com.sincere.quartz.service.SmsService;
  10 +//import org.apache.commons.lang3.StringUtils;
  11 +//import org.slf4j.Logger;
  12 +//import org.slf4j.LoggerFactory;
  13 +//import org.springframework.beans.factory.annotation.Autowired;
  14 +//import org.springframework.scheduling.annotation.Scheduled;
  15 +//import org.springframework.stereotype.Service;
  16 +//
  17 +//import java.util.Date;
  18 +//import java.util.HashMap;
  19 +//import java.util.List;
  20 +//import java.util.Map;
  21 +//
  22 +///**
  23 +// * 用户注册激活提醒
  24 +// * @author chen
  25 +// * @version 1.0
  26 +// * @date 2019/12/10 0010 8:31
  27 +// */
  28 +//@Service
  29 +//public class BindPushJob {
  30 +//
  31 +// private Logger logger = LoggerFactory.getLogger(BindPushJob.class);
  32 +//
  33 +//
  34 +// @Autowired
  35 +// ScFeign scFeign;
  36 +//
  37 +// @Autowired
  38 +// SmsService smsService;
  39 +//
  40 +// private static Map<String , String> intervalDaysMap = new HashMap<>(); //redis 持久化 替换 可避免重启导致间隔的错误
  41 +//
  42 +// @Scheduled(cron = "0 0-59 * * * ? ")
  43 +// public void bindPush(){
  44 +// Date nowDate = new Date();
  45 +// List<BindPushDto> schoolList = scFeign.selectBindPushSchool();
  46 +// for(BindPushDto school : schoolList){
  47 +// if(school.getBeginDate().compareTo(nowDate) <= 0 && school.getEndDate().compareTo(nowDate) >= 0){
  48 +// String lastDate = intervalDaysMap.get(school.getSchoolId()+"_"+school.getType());
  49 +// if(StringUtils.isBlank(lastDate)){
  50 +// //下发推送
  51 +// bindPush(school,nowDate);
  52 +// }else {
  53 +// int day = DateUtils.getDateDifference(nowDate,DateUtils.string2Date(lastDate,DateUtils.format1),"day") ;
  54 +// if(day == school.getIntervalDays() + 1) {
  55 +// //下发推送
  56 +// bindPush(school,nowDate);
  57 +// }
  58 +// }
  59 +// }
  60 +// }
  61 +// }
  62 +//
  63 +// private void bindPush(BindPushDto bindPushDto , Date nowDate){
  64 +// if(bindPushDto.getPushTime().equals(DateUtils.date2String(nowDate,DateUtils.format4))){
  65 +// intervalDaysMap.put(bindPushDto.getSchoolId()+"_"+bindPushDto.getType(),DateUtils.date2String(nowDate,DateUtils.format1));
  66 +// //未关注
  67 +// List<ParentDto> unFollowList = scFeign.selectNotFollow(bindPushDto.getSchoolId());
  68 +// logger.info(bindPushDto.getSchoolName()+"未关注人数"+unFollowList.size());
  69 +// for(ParentDto parentDto : unFollowList){
  70 +// sendMessage(parentDto,bindPushDto.getMsg());
  71 +// }
  72 +// //未绑定
  73 +// List<ParentDto> unBindList =scFeign.selectNotBind(bindPushDto.getSchoolId(),getThirdType(bindPushDto.getType()));
  74 +// logger.info(bindPushDto.getSchoolName()+"未绑定人数"+unBindList.size());
  75 +// for(ParentDto parentDto : unBindList){
  76 +// sendMessage(parentDto,bindPushDto.getMsg());
  77 +// }
  78 +// }
  79 +// }
  80 +//
  81 +// private void sendMessage(ParentDto parentDto , String message){
  82 +// //手机号为空
  83 +// if(StringUtils.isNotBlank(parentDto.getMobile())){
  84 +// String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format);
  85 +// ShortMsg shortMsg = new ShortMsg();
  86 +// shortMsg.setTableName("smsNew"+tableSuffix);
  87 +// shortMsg.setSchoolId(parentDto.getSchoolId());
  88 +// shortMsg.setMobile(parentDto.getMobile());
  89 +// shortMsg.setMsg(message);
  90 +// smsService.insertSMS(shortMsg);
  91 +// logger.info("----学校Id---"+parentDto.getSchoolId() + "----手机号----"+parentDto.getMobile()+"---"+message);
  92 +// }
  93 +// }
  94 +//
  95 +// // 0是企业号,1是钉钉
  96 +// private int getThirdType(int type){
  97 +// if(type == 0){
  98 +// return PushTypeEnums.QIYEHAO.getType() ;
  99 +// }else {
  100 +// return PushTypeEnums.DING.getType() ;
  101 +// }
  102 +// }
  103 +//
  104 +//}
... ...
cloud/quartz/src/main/java/com/sincere/quartz/job/KQJob.java
1   -package com.sincere.quartz.job;
2   -
3   -import com.alibaba.fastjson.JSONArray;
4   -import com.alibaba.fastjson.JSONObject;
5   -import com.sincere.common.dto.smartCampus.*;
6   -import com.sincere.common.enums.PushTypeEnums;
7   -import com.sincere.common.util.DateUtils;
8   -import com.sincere.common.util.HttpClientUtils;
9   -import com.sincere.quartz.enums.KqTypeEnums;
10   -import com.sincere.quartz.enums.TypeEnums;
11   -import com.sincere.quartz.feign.ScFeign;
12   -import com.sincere.quartz.model.DingSms;
13   -import com.sincere.quartz.model.ShortMsg;
14   -import com.sincere.quartz.model.WeChatSms;
15   -import com.sincere.quartz.service.ManagerService;
16   -import com.sincere.quartz.service.SmsService;
17   -import org.apache.commons.lang3.StringUtils;
18   -import org.slf4j.Logger;
19   -import org.slf4j.LoggerFactory;
20   -import org.springframework.beans.factory.annotation.Autowired;
21   -import org.springframework.scheduling.annotation.Scheduled;
22   -import org.springframework.stereotype.Service;
23   -
24   -import java.math.BigDecimal;
25   -import java.util.*;
26   -
27   -/**
28   - * 考勤任务推送调用
29   - * 主要推送盯盯以及企业号
30   - *
31   - * @author chen
32   - * @version 1.0
33   - * @date 2019/11/27 0027 17:05
34   - */
35   -@Service
36   -public class KQJob {
37   -
38   - private Logger logger = LoggerFactory.getLogger(KQJob.class);
39   -
40   - @Autowired
41   - ScFeign scFeign;
42   -
43   - @Autowired
44   - SmsService smsService;
45   -
46   - @Autowired
47   - ManagerService managerService;
48   -
49   - private static String iotUrl = "http://60.190.202.57:8035";
50   -
51   - private static String date;
52   - private static Map<String, String> map = new HashMap<>(); //学校 考勤推送map
53   -
54   - private static String alarmDate;
55   - private static Map<String, String> alarmMap = new HashMap<>(); //考勤告警推送map
56   - private static Map<String, BigDecimal> templateMap = new HashMap<>(); // 考勤比例
57   -
58   - private static List<String> opexList;
59   - private static String integration;
60   -
61   - static {
62   - opexList = new ArrayList<>();
63   - opexList.add("15857566147"); //王汉栋
64   - opexList.add("13858485977"); //王楠彬
65   -
66   - integration = "18767117554"; //林炜
67   - }
68   -
69   - @Scheduled(cron = "0 0-59 * * * ? ")
70   - public void kaoQing() {
71   - String now = DateUtils.date2String(new Date(), DateUtils.format1);
72   - if (StringUtils.isBlank(date)) {
73   - initMap();
74   - date = now;
75   - }
76   - if (!DateUtils.date2String(new Date(), DateUtils.format1).equals(date)) {
77   - initMap();
78   - date = DateUtils.date2String(new Date(), DateUtils.format1);
79   - }
80   - //开始过滤数据 推送
81   - List<String> keyList = new ArrayList<>();
82   - for (Map.Entry<String, String> entity : map.entrySet()) {
83   - String endTime = entity.getValue().split("_")[1];
84   - if (DateUtils.getDateDifference(new Date(), DateUtils.string2Date(now + " " + endTime + ":00", DateUtils.format2), "m") >= 2
85   - && DateUtils.getDateDifference(new Date(), DateUtils.string2Date(now + " " + endTime + ":00", DateUtils.format2), "m") < 5) {
86   - String key = entity.getKey();
87   - String[] messageArray = key.split("_");
88   - if (messageArray[2].contains(PushTypeEnums.QIYEHAO.getType() + "")) {
89   - logger.info("企业号推送:" + messageArray[0] + "__" + messageArray[1]);
90   - weChatBatchPush(messageArray[0], Integer.valueOf(messageArray[1]), entity.getValue());
91   - }
92   - if (messageArray[2].contains(PushTypeEnums.DING.getType() + "")) {
93   - logger.info(("盯盯推送:" + messageArray[0] + "__" + messageArray[1]));
94   - dingBatchPush(messageArray[0], Integer.valueOf(messageArray[1]), entity.getValue());
95   - }
96   - keyList.add(key);
97   - }
98   - }
99   - for (String key : keyList) {
100   - map.remove(key);
101   - }
102   - }
103   -
104   - @Scheduled(cron = "0 0-59 * * * ? ")
105   - public void alarmKaoQing() {
106   - String now = DateUtils.date2String(new Date(), DateUtils.format1);
107   - if (StringUtils.isBlank(alarmDate)) {
108   - initAlarmMap();
109   - alarmDate = now;
110   - }
111   - if (!DateUtils.date2String(new Date(), DateUtils.format1).equals(alarmDate)) {
112   - initAlarmMap();
113   - alarmDate = DateUtils.date2String(new Date(), DateUtils.format1);
114   - }
115   - //开始过滤数据 推送
116   - List<String> keyList = new ArrayList<>();
117   - for (Map.Entry<String, String> entity : alarmMap.entrySet()) {
118   - String endTime = entity.getValue().split("_")[1];
119   - if (DateUtils.getDateDifference(new Date(), DateUtils.string2Date(now + " " + endTime + ":00", DateUtils.format2), "m") >= 2
120   - ) {
121   - String key = entity.getKey();
122   - keyList.add(key);
123   - //alarm(entity); //告警
124   - //insertIOT(entity); //iot
125   - }
126   - }
127   - for (String key : keyList) {
128   - map.remove(key);
129   - }
130   - }
131   -
132   - private void initAlarmMap() {
133   - alarmMap = new HashMap<>();
134   - List<TemplateDto> list = scFeign.getAllTemplateAlarm();
135   - logger.info(("------考勤告警模板------"));
136   - for (TemplateDto templateDto : list) {
137   - String config = templateDto.getConfig();
138   - String[] array = config.split("<Template");
139   - for (int i = 1; i < array.length; i++) {
140   - try {
141   - String msg = array[i];
142   - String beginTime = msg.substring(msg.indexOf("BeginTime") + 11, msg.indexOf("BeginTime") + 16);
143   - String endTime = msg.substring(msg.indexOf("EndTime") + 9, msg.indexOf("EndTime") + 14);
144   - String templateId = msg.substring(msg.indexOf("TemplateID") + 12, msg.indexOf("TemplateID") + 22);
145   - String Week = msg.substring(msg.indexOf("Week") + 6, msg.indexOf("Week") + 19);
146   - String type = msg.substring(msg.indexOf("Type") + 6, msg.indexOf("Type") + 8);
147   - type = type.replace("\"", "");
148   - int nowWeek = DateUtils.getWeek();
149   - if (Week.contains(nowWeek + "") && nowWeek != 6 && nowWeek != 0) { //周末不告警
150   - logger.info((templateId + "_" + templateDto.getSchoolId() + "------" + beginTime + "_" + endTime));
151   - alarmMap.put(templateId + "_" + templateDto.getSchoolId() + "_" + templateDto.getTitle(), beginTime + "_" + endTime + "_" + type + "_" + templateDto.getId());
152   - }
153   - } catch (Exception e) {
154   - e.printStackTrace();
155   - }
156   - }
157   - }
158   - }
159   -
160   - //告警推送
161   - private void alarm(Map.Entry<String, String> entry) {
162   - String templateId = entry.getKey().split("_")[0];
163   - String schoolId = entry.getKey().split("_")[1];
164   - String id = entry.getValue().split("_")[3];
165   - String type = entry.getValue().split("_")[2];
166   -
167   - if (DateUtils.getWeek() == 2 || DateUtils.getWeek() == 5) {
168   - //可以相差40%
169   - BigDecimal percent = getAlarmCensus(Integer.valueOf(id), templateId, Integer.valueOf(schoolId), Integer.valueOf(type));
170   - if (templateMap.get(templateId) != null) {
171   - if (percent.subtract(templateMap.get(templateId)).compareTo(new BigDecimal(0.4)) > 0
172   - || templateMap.get(templateId).subtract(percent).compareTo(new BigDecimal(0.4)) > 0) {
173   - alarmPush(Integer.valueOf(schoolId));
174   - }
175   - }
176   - templateMap.put(templateId, percent);
177   - } else {
178   - //相差30%
179   - BigDecimal percent = getAlarmCensus(Integer.valueOf(id), templateId, Integer.valueOf(schoolId), Integer.valueOf(type));
180   - if (templateMap.get(templateId) != null) {
181   - if (percent.subtract(templateMap.get(templateId)).compareTo(new BigDecimal(0.3)) > 0
182   - || templateMap.get(templateId).subtract(percent).compareTo(new BigDecimal(0.3)) > 0) {
183   - alarmPush(Integer.valueOf(schoolId));
184   - }
185   - }
186   - templateMap.put(templateId, percent);
187   - }
188   - }
189   -
190   - private void insertIOT(Map.Entry<String, String> entry) {
191   - String templateId = entry.getKey().split("_")[0];
192   - String schoolId = entry.getKey().split("_")[1];
193   - String title = entry.getKey().split("_")[2];
194   - String id = entry.getValue().split("_")[3];
195   - String type = entry.getValue().split("_")[2];
196   - String beginTime = entry.getValue().split("_")[0];
197   - String endTime = entry.getValue().split("_")[1];
198   -
199   - List<Integer> list = getIOTCensus(Integer.valueOf(id), templateId, Integer.valueOf(schoolId), Integer.valueOf(type));
200   - JSONObject object = new JSONObject();
201   - object.put("strTime", beginTime);
202   - object.put("endTime", endTime);
203   - object.put("inTime", DateUtils.date2String(new Date(), DateUtils.format1));
204   - object.put("noAttendanceCount", list.get(1));
205   - object.put("attendanceCount", list.get(0));
206   - object.put("leaveCount", list.get(2));
207   - object.put("templateName", title);
208   - object.put("qianDaoIdId", id);
209   - object.put("schoolId", schoolId);
210   - object.put("templateId", templateId);
211   - HttpClientUtils.httpPostJson(iotUrl + "/api/Association/addIntelligenceAttendance", object.toJSONString());
212   - }
213   -
214   - //初始化要推送的模板
215   - private void initMap() {
216   - map = new HashMap<>();
217   - List<TemplateDto> list = scFeign.getAllTemplate();
218   - logger.info(("------需要推送的考勤模板------"));
219   - for (TemplateDto templateDto : list) {
220   - String config = templateDto.getConfig();
221   - String[] array = config.split("<Template");
222   - for (int i = 1; i < array.length; i++) {
223   - try {
224   - String msg = array[i];
225   - String beginTime = msg.substring(msg.indexOf("BeginTime") + 11, msg.indexOf("BeginTime") + 16);
226   - String endTime = msg.substring(msg.indexOf("EndTime") + 9, msg.indexOf("EndTime") + 14);
227   - String templateId = msg.substring(msg.indexOf("TemplateID") + 12, msg.indexOf("TemplateID") + 22);
228   - String Week = msg.substring(msg.indexOf("Week") + 6, msg.indexOf("Week") + 19);
229   - String type = msg.substring(msg.indexOf("Type") + 6, msg.indexOf("Type") + 8);
230   - type = type.replace("\"", "");
231   - int nowWeek = DateUtils.getWeek();
232   - if (Week.contains(nowWeek + "")) {
233   - logger.info((templateId + "_" + templateDto.getSchoolId() + "_" + templateDto.getType() + "------" + beginTime + "_" + endTime));
234   - map.put(templateId + "_" + templateDto.getSchoolId() + "_" + templateDto.getType(), beginTime + "_" + endTime + "_" + type + "_" + templateDto.getId());
235   - }
236   - } catch (Exception e) {
237   - e.printStackTrace();
238   - }
239   - }
240   - }
241   - }
242   -
243   - //盯盯批量推送
244   - private void dingBatchPush(String templateId, int schoolId, String key) {
245   - String[] times = key.split("_");
246   - AppDto appDto = scFeign.getApp(schoolId, 1);
247   - if (Integer.valueOf(times[2]) < 7) {
248   - //出入校 推班主任
249   - List<KqTeacherDto> list = scFeign.getTeacherList(schoolId);
250   - for (KqTeacherDto teacher : list) {
251   - dingSchoolPush(templateId, teacher, key, appDto, 0);
252   - }
253   - } else {
254   - //出入寝 推班主任
255   - List<KqTeacherDto> list = scFeign.getTeacherList(schoolId);
256   - for (KqTeacherDto teacher : list) {
257   - dingSchoolPush(templateId, teacher, key, appDto, 1);
258   - }
259   - //推宿管
260   - List<KqTeacherDto> chamberList = scFeign.selectChamberTeacher(schoolId);
261   - for (KqTeacherDto teacher : chamberList) {
262   - dingChamberPush(templateId, teacher, key, appDto);
263   - }
264   - }
265   - }
266   -
267   - //企业号批量推送
268   - private void weChatBatchPush(String templateId, int schoolId, String key) {
269   - String[] times = key.split("_");
270   - AppDto appDto = scFeign.getApp(schoolId, 0);
271   - if (Integer.valueOf(times[2]) < 7) {
272   - //出入校 推班主任
273   - List<KqTeacherDto> list = scFeign.getTeacherList(schoolId);
274   - for (KqTeacherDto teacher : list) {
275   - weChatSchoolPush(templateId, teacher, key, appDto, 0);
276   - }
277   - } else {
278   - //出入寝 推班主任
279   - List<KqTeacherDto> list = scFeign.getTeacherList(schoolId);
280   - for (KqTeacherDto teacher : list) {
281   - weChatSchoolPush(templateId, teacher, key, appDto, 1);
282   - }
283   - //推宿管
284   - List<KqTeacherDto> chamberList = scFeign.selectChamberTeacher(schoolId);
285   - for (KqTeacherDto teacher : chamberList) {
286   - weChatChamberPush(templateId, teacher, key, appDto);
287   - }
288   - }
289   - }
290   -
291   - //盯盯推送班主任
292   - private void dingSchoolPush(String templateId, KqTeacherDto teacher, String key, AppDto appDto, int type) {
293   - String[] times = key.split("_");
294   - String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format);
295   - String thirdOpenId = scFeign.getThirdId(teacher.getUserId(), 0);
296   - if (StringUtils.isNotBlank(thirdOpenId)) {
297   - List<CensusKqDto> censusKqDtos = getCensus(Integer.valueOf(times[3]), templateId, teacher.getSchoolId(), teacher.getUserId(), type);
298   - if (censusKqDtos != null && censusKqDtos.size() > 0) {
299   - String message = "";
300   - for (CensusKqDto censusKqDto : censusKqDtos) {
301   - message += "[" + censusKqDto.getTargetName() + "]未考勤" + censusKqDto.getNotAttendCount() + "人,请假" + censusKqDto.getLeaveCount() + "人;";
302   - }
303   - DingSms dingSms = new DingSms();
304   - dingSms.setName(teacher.getName());
305   - dingSms.setTableName("DingSmsNew" + tableSuffix);
306   - dingSms.setMsg("报告类型:" + KqTypeEnums.getName(Integer.valueOf(times[2])) + "出勤报告 \n - " +
307   - "签到日期:" + DateUtils.date2String(new Date(), DateUtils.format1) + "(" + DateUtils.getWeekName() + ") \n - " +
308   - "签到时间:" + times[0] + "-" + times[1] + " \n - " +
309   - "整体数据:" + message);
310   - String wapUrl = "http://campus.myjxt.com/studentRecord/znxwwebapp/index.html?" +
311   - "schoolid=" + teacher.getSchoolId() + "&userId=" + teacher.getUserId() + "&name=" + teacher.getName() + "&TemplateId=" + templateId +
312   - "&data=" + thirdOpenId + "&type=1&stype=4&mobile=" + teacher.getMobile() + "&pass=" + teacher.getPass() +
313   - "&face=&sourcetype=16&soutype=3&timestamp=" + DateUtils.getDate() + "&time=" + DateUtils.date2String(new Date(), DateUtils.format1);
314   - dingSms.setSchoolId(teacher.getSchoolId());
315   - dingSms.setDingUserId(thirdOpenId);
316   - dingSms.setAgentId(appDto.getAgentId());
317   - dingSms.setWapUrl(wapUrl);
318   - dingSms.setReceiveUserId(teacher.getUserId());
319   - dingSms.setTdType(TypeEnums.kaoqing.getType());
320   - this.insertDing(dingSms);
321   - logger.info("盯盯推送班主任—————" + templateId + "--------" + teacher.getName());
322   - }
323   - }
324   - }
325   -
326   - //盯盯推送宿管
327   - private void dingChamberPush(String templateId, KqTeacherDto teacher, String key, AppDto appDto) {
328   - String[] times = key.split("_");
329   - String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format);
330   - String thirdOpenId = scFeign.getThirdId(teacher.getUserId(), 0);
331   - if (StringUtils.isNotBlank(thirdOpenId)) {
332   - List<CensusKqDto> censusKqDtos = getCensus(Integer.valueOf(times[3]), templateId, teacher.getSchoolId(), teacher.getUserId(), 1);
333   - if (censusKqDtos != null && censusKqDtos.size() > 0) {
334   - String message = "";
335   - for (CensusKqDto censusKqDto : censusKqDtos) {
336   - message += "[" + censusKqDto.getTargetName() + "]未考勤" + censusKqDto.getNotAttendCount() + "人,请假" + censusKqDto.getLeaveCount() + "人;";
337   - }
338   - DingSms dingSms = new DingSms();
339   - dingSms.setName(teacher.getName());
340   - dingSms.setTableName("DingSmsNew" + tableSuffix);
341   - dingSms.setMsg("报告类型:" + KqTypeEnums.getName(Integer.valueOf(times[2])) + "出勤报告 \n - " +
342   - "签到日期:" + DateUtils.date2String(new Date(), DateUtils.format1) + "(" + DateUtils.getWeekName() + ") \n - " +
343   - "签到时间:" + times[0] + "-" + times[1] + " \n - " +
344   - "整体数据:" + message);
345   - String msgUrl = "http://campus.myjxt.com/studentRecord/znxwwebapp/index.html?" +
346   - "schoolid=" + teacher.getSchoolId() + "&userId=" + teacher.getUserId() + "&name=" + teacher.getName() + "&TemplateId=" + templateId +
347   - "&pass=" + teacher.getPass() + "&type=4&soutype=3&time=" + DateUtils.date2String(new Date(), DateUtils.format1);
348   - dingSms.setSchoolId(teacher.getSchoolId());
349   - dingSms.setDingUserId(thirdOpenId);
350   - dingSms.setAgentId(appDto.getAgentId());
351   - dingSms.setWapUrl(msgUrl);
352   - dingSms.setReceiveUserId(teacher.getUserId());
353   - dingSms.setTdType(TypeEnums.kaoqing.getType());
354   - this.insertDing(dingSms);
355   - logger.info("盯盯推送宿管—————" + templateId + "--------" + teacher.getName());
356   - }
357   - }
358   - }
359   -
360   - //企业号推送班主任
361   - private void weChatSchoolPush(String templateId, KqTeacherDto teacher, String key, AppDto appDto, int type) {
362   - String[] times = key.split("_");
363   - String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format);
364   - String thirdOpenId = scFeign.getThirdId(teacher.getUserId(), 1);
365   - if (StringUtils.isNotBlank(thirdOpenId)) {
366   - List<CensusKqDto> censusKqDtos = getCensus(Integer.valueOf(times[3]), templateId, teacher.getSchoolId(), teacher.getUserId(), type);
367   - if (censusKqDtos != null && censusKqDtos.size() > 0) {
368   - String message = "";
369   - for (CensusKqDto censusKqDto : censusKqDtos) {
370   - message += "[" + censusKqDto.getTargetName() + "]未考勤" + censusKqDto.getNotAttendCount() + "人,请假" + censusKqDto.getLeaveCount() + "人;";
371   - }
372   - WeChatSms weChatSms = new WeChatSms();
373   - weChatSms.setTableName("qyhSmsNew" + tableSuffix);
374   - weChatSms.setMsg("报告类型:" + KqTypeEnums.getName(Integer.valueOf(times[2])) + "出勤报告 \n - " +
375   - "签到日期:" + DateUtils.date2String(new Date(), DateUtils.format1) + "(" + DateUtils.getWeekName() + ") \n - " +
376   - "签到时间:" + times[0] + "-" + times[1] + " \n - " +
377   - "整体数据:" + message);
378   - weChatSms.setSchoolId(teacher.getSchoolId());
379   - weChatSms.setName(teacher.getName());
380   - weChatSms.setQiYeHaoUserId(thirdOpenId);
381   - weChatSms.setReceiveUserId(teacher.getUserId());
382   - weChatSms.setAppId(appDto.getAgentId());
383   - weChatSms.setSecret(appDto.getAgentSecret());
384   - String msgUrl = "http://campus.myjxt.com/studentRecord/znxwwebapp/index.html?" +
385   - "schoolid=" + teacher.getSchoolId() + "&userId=" + teacher.getUserId() + "&name=" + teacher.getName() + "&TemplateId=" + templateId +
386   - "&data=" + thirdOpenId + "&type=1&stype=3&mobile=" + teacher.getMobile() + "&pass=" + teacher.getPass() +
387   - "&face=" + teacher.getFace() + "&sourcetype=16&soutype=2&timestamp=" + DateUtils.getDate() + "&time=" + DateUtils.date2String(new Date(), DateUtils.format1) + "&";
388   - weChatSms.setMsgUrl(msgUrl);
389   - weChatSms.setTdType(TypeEnums.kaoqing.getType());
390   - this.insertQYH(weChatSms);
391   - logger.info("企业号推送班主任—————" + templateId + "--------" + teacher.getName());
392   - }
393   - }
394   - }
395   -
396   - //企业号推送宿管
397   - private void weChatChamberPush(String templateId, KqTeacherDto teacher, String key, AppDto appDto) {
398   - String[] times = key.split("_");
399   - String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format);
400   - String thirdOpenId = scFeign.getThirdId(teacher.getUserId(), 1);
401   - if (StringUtils.isNotBlank(thirdOpenId)) {
402   - List<CensusKqDto> censusKqDtos = getCensus(Integer.valueOf(times[3]), templateId, teacher.getSchoolId(), teacher.getUserId(), 1);
403   - if (censusKqDtos != null && censusKqDtos.size() > 0) {
404   - String message = "";
405   - for (CensusKqDto censusKqDto : censusKqDtos) {
406   - message += "[" + censusKqDto.getTargetName() + "]未考勤" + censusKqDto.getNotAttendCount() + "人,请假" + censusKqDto.getLeaveCount() + "人;";
407   - }
408   - WeChatSms weChatSms = new WeChatSms();
409   - weChatSms.setTableName("qyhSmsNew" + tableSuffix);
410   - weChatSms.setMsg("报告类型:" + KqTypeEnums.getName(Integer.valueOf(times[2])) + "出勤报告 \n - " +
411   - "签到日期:" + DateUtils.date2String(new Date(), DateUtils.format1) + "(" + DateUtils.getWeekName() + ") \n - " +
412   - "签到时间:" + times[0] + "-" + times[1] + " \n - " +
413   - "整体数据:" + message);
414   - weChatSms.setSchoolId(teacher.getSchoolId());
415   - weChatSms.setName(teacher.getName());
416   - weChatSms.setQiYeHaoUserId(thirdOpenId);
417   - weChatSms.setReceiveUserId(teacher.getUserId());
418   - weChatSms.setAppId(appDto.getAgentId());
419   - weChatSms.setSecret(appDto.getAgentSecret());
420   - String msgUrl = "http://campus.myjxt.com/studentRecord/znxwwebapp/index.html?" +
421   - "schoolid=" + teacher.getSchoolId() + "&userId=" + teacher.getUserId() + "&name=" + teacher.getName() + "&TemplateId=" + templateId +
422   - "&pass=" + teacher.getPass() + "&type=4&soutype=2&time=" + DateUtils.date2String(new Date(), DateUtils.format1) + "&";
423   - weChatSms.setMsgUrl(msgUrl);
424   - weChatSms.setTdType(TypeEnums.kaoqing.getType());
425   - this.insertQYH(weChatSms);
426   - logger.info("企业号推送宿管—————" + templateId + "--------" + teacher.getName());
427   - }
428   - }
429   - }
430   -
431   - //type 0 出入校 1 出入寝
432   - private List<CensusKqDto> getCensus(int id, String templateId, int schoolId, String userId, int type) {
433   - List<CensusKqDto> list = new ArrayList<>();
434   - String url = "http://campus.myjxt.com/api/EasyN/GeAttendDetailNew?schoolId=" + schoolId +
435   - "&id=" + id + "&templateID=" + templateId + "&type=" + type + "&userId=" + userId + "&time=" + DateUtils.date2String(new Date(), DateUtils.format1);
436   - JSONObject jsonObject = HttpClientUtils.httpGet(url);
437   - try {
438   - JSONArray data = (JSONArray) jsonObject.get("data");
439   - for (int i = 0; i < data.size(); i++) {
440   - CensusKqDto censusKqDto = new CensusKqDto();
441   - JSONObject object = data.getJSONObject(i);
442   - censusKqDto.setLeaveCount((Integer) object.get("leaveCount"));
443   - censusKqDto.setNotAttendCount((Integer) object.get("noAttendCount"));
444   - censusKqDto.setTargetName((String) object.get("name"));
445   - list.add(censusKqDto);
446   - }
447   - } catch (Exception e) {
448   -
449   - }
450   - return list;
451   - }
452   -
453   - private BigDecimal getAlarmCensus(int id, String templateId, int schoolId, int type) {
454   - int allNumber = 0, attendNumber = 0;
455   - List<Integer> list = scFeign.selectClassBySchoolId(schoolId);
456   - for (Integer classId : list) {
457   - String url = "http://campus.myjxt.com/api/EasyN/GeAttendDetail?classId=" + classId +
458   - "&id=" + id + "&templateID=" + templateId + "&type=" + type + "&time=" + DateUtils.date2String(new Date(), DateUtils.format1);
459   - JSONObject jsonObject = HttpClientUtils.httpGet(url);
460   - try {
461   - JSONObject data = (JSONObject) jsonObject.get("data");
462   - attendNumber = attendNumber + (Integer) data.get("stuAttendCount");
463   - allNumber = allNumber + (Integer) data.get("stuCount");
464   - } catch (Exception e) {
465   - e.printStackTrace();
466   - }
467   - }
468   - if (allNumber != 0) {
469   - BigDecimal pecrent = new BigDecimal(attendNumber).divide(new BigDecimal(allNumber), 10, BigDecimal.ROUND_HALF_DOWN);
470   - return pecrent;
471   - } else {
472   - return BigDecimal.ZERO;
473   - }
474   -
475   - }
476   -
477   - /**
478   - * @param id
479   - * @param templateId
480   - * @param schoolId
481   - * @param type
482   - * @return list(0) 出勤 list(1) 未出勤 List(2) 请假
483   - */
484   - private List<Integer> getIOTCensus(int id, String templateId, int schoolId, int type) {
485   - List<Integer> result = new ArrayList<>();
486   - int attend = 0, unattend = 0, leave = 0;
487   - List<Integer> list = scFeign.selectClassBySchoolId(schoolId);
488   - for (Integer classId : list) {
489   - String url = "http://campus.myjxt.com/api/EasyN/GeAttendDetail?classId=" + classId +
490   - "&id=" + id + "&templateID=" + templateId + "&type=" + type + "&time=" + DateUtils.date2String(new Date(), DateUtils.format1);
491   - JSONObject jsonObject = HttpClientUtils.httpGet(url);
492   - try {
493   - JSONObject data = (JSONObject) jsonObject.get("data");
494   - attend = attend + (Integer) data.get("stuAttendCount");
495   - unattend = unattend + (Integer) data.get("noAttendCount");
496   - leave = leave + (Integer) data.get("leaveCount");
497   - } catch (Exception e) {
498   - e.printStackTrace();
499   - }
500   - }
501   - result.add(attend);
502   - result.add(unattend);
503   - result.add(leave);
504   - return result;
505   - }
506   -
507   -
508   - private void insertDing(DingSms dingSms) {
509   - try {
510   - smsService.insertDing(dingSms);
511   - } catch (Exception e) {
512   - logger.info(e.toString());
513   - }
514   - }
515   -
516   - private void insertQYH(WeChatSms weChatSms) {
517   - try {
518   - smsService.insertWeChat(weChatSms);
519   - } catch (Exception e) {
520   - logger.info(e.toString());
521   - }
522   - }
523   -
524   - private void alarmPush(int schoolId) {
525   - String msg = "【考勤异动】";
526   - try {
527   - SchoolDto schoolDto = scFeign.selectSchoolBySchoolId(schoolId);
528   - msg += schoolDto.getSchoolName() + "考勤有异动,请关注!";
529   - sendMessage(schoolDto.getSchoolId(), opexList.get(0), msg);
530   - sendMessage(schoolDto.getSchoolId(), opexList.get(1), msg);
531   - sendMessage(schoolDto.getSchoolId(), integration, msg);
532   - String managerPhone = managerService.selectManagerById(schoolDto.getManagerUserId());
533   - if (StringUtils.isNotBlank(managerPhone)) {
534   - sendMessage(schoolDto.getSchoolId(), managerPhone, msg);
535   - }
536   - } catch (Exception e) {
537   - e.printStackTrace();
538   - }
539   -
540   - }
541   -
542   - private void sendMessage(int schoolId, String mobile, String msg) {
543   - String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format);
544   - ShortMsg shortMsg = new ShortMsg();
545   - shortMsg.setTableName("smsNew" + tableSuffix);
546   - shortMsg.setSchoolId(schoolId);
547   - shortMsg.setMobile(mobile);
548   - shortMsg.setMsg(msg);
549   - smsService.insertSMS(shortMsg);
550   - }
551   -}
  1 +//package com.sincere.quartz.job;
  2 +//
  3 +//import com.alibaba.fastjson.JSONArray;
  4 +//import com.alibaba.fastjson.JSONObject;
  5 +//import com.sincere.common.dto.smartCampus.*;
  6 +//import com.sincere.common.enums.PushTypeEnums;
  7 +//import com.sincere.common.util.DateUtils;
  8 +//import com.sincere.common.util.HttpClientUtils;
  9 +//import com.sincere.quartz.enums.KqTypeEnums;
  10 +//import com.sincere.quartz.enums.TypeEnums;
  11 +//import com.sincere.quartz.feign.ScFeign;
  12 +//import com.sincere.quartz.model.DingSms;
  13 +//import com.sincere.quartz.model.ShortMsg;
  14 +//import com.sincere.quartz.model.WeChatSms;
  15 +//import com.sincere.quartz.service.ManagerService;
  16 +//import com.sincere.quartz.service.SmsService;
  17 +//import org.apache.commons.lang3.StringUtils;
  18 +//import org.slf4j.Logger;
  19 +//import org.slf4j.LoggerFactory;
  20 +//import org.springframework.beans.factory.annotation.Autowired;
  21 +//import org.springframework.scheduling.annotation.Scheduled;
  22 +//import org.springframework.stereotype.Service;
  23 +//
  24 +//import java.math.BigDecimal;
  25 +//import java.util.*;
  26 +//
  27 +///**
  28 +// * 考勤任务推送调用
  29 +// * 主要推送盯盯以及企业号
  30 +// * @author chen
  31 +// * @version 1.0
  32 +// * @date 2019/11/27 0027 17:05
  33 +// */
  34 +//@Service
  35 +//public class KQJob {
  36 +//
  37 +// private Logger logger = LoggerFactory.getLogger(KQJob.class);
  38 +//
  39 +// @Autowired
  40 +// ScFeign scFeign ;
  41 +//
  42 +// @Autowired
  43 +// SmsService smsService;
  44 +//
  45 +// @Autowired
  46 +// ManagerService managerService ;
  47 +//
  48 +// private static String iotUrl = "http://60.190.202.57:8035";
  49 +//
  50 +// private static String date ;
  51 +// private static Map<String , String> map = new HashMap<>(); //学校 考勤推送map
  52 +//
  53 +// private static String alarmDate ;
  54 +// private static Map<String , String> alarmMap = new HashMap<>(); //考勤告警推送map
  55 +// private static Map<String , BigDecimal> templateMap = new HashMap<>(); // 考勤比例
  56 +//
  57 +// private static List<String> opexList ;
  58 +// private static String integration ;
  59 +//
  60 +// static{
  61 +// opexList = new ArrayList<>();
  62 +// opexList.add("15857566147"); //王汉栋
  63 +// opexList.add("13858485977"); //王楠彬
  64 +//
  65 +// integration = "18767117554" ; //林炜
  66 +// }
  67 +//
  68 +// @Scheduled(cron = "0 0-59 * * * ? ")
  69 +// public void kaoQing() {
  70 +// String now = DateUtils.date2String(new Date(),DateUtils.format1) ;
  71 +// if(StringUtils.isBlank(date)){
  72 +// initMap();
  73 +// date = now ;
  74 +// }
  75 +// if(!DateUtils.date2String(new Date(),DateUtils.format1).equals(date)){
  76 +// initMap();
  77 +// date = DateUtils.date2String(new Date(),DateUtils.format1) ;
  78 +// }
  79 +// //开始过滤数据 推送
  80 +// List<String> keyList = new ArrayList<>();
  81 +// for(Map.Entry<String, String> entity : map.entrySet()){
  82 +// String endTime = entity.getValue().split("_")[1];
  83 +// if(DateUtils.getDateDifference(new Date(),DateUtils.string2Date(now+" "+endTime+":00",DateUtils.format2),"m")>=2
  84 +// && DateUtils.getDateDifference(new Date(),DateUtils.string2Date(now+" "+endTime+":00",DateUtils.format2),"m")<5){
  85 +// String key = entity.getKey();
  86 +// String[] messageArray = key.split("_");
  87 +// if(messageArray[2].contains(PushTypeEnums.QIYEHAO.getType()+"")){
  88 +// logger.info("企业号推送:" + messageArray[0] + "__" + messageArray[1]);
  89 +// weChatBatchPush(messageArray[0],Integer.valueOf(messageArray[1]),entity.getValue());
  90 +// }
  91 +// if(messageArray[2].contains(PushTypeEnums.DING.getType()+"")){
  92 +// logger.info(("盯盯推送:" + messageArray[0] + "__" + messageArray[1]));
  93 +// dingBatchPush(messageArray[0],Integer.valueOf(messageArray[1]),entity.getValue());
  94 +// }
  95 +// keyList.add(key);
  96 +// }
  97 +// }
  98 +// for(String key : keyList){
  99 +// map.remove(key);
  100 +// }
  101 +// }
  102 +//
  103 +// @Scheduled(cron = "0 0-59 * * * ? ")
  104 +// public void alarmKaoQing() {
  105 +// String now = DateUtils.date2String(new Date(),DateUtils.format1) ;
  106 +// if(StringUtils.isBlank(alarmDate)){
  107 +// initAlarmMap();
  108 +// alarmDate = now ;
  109 +// }
  110 +// if(!DateUtils.date2String(new Date(),DateUtils.format1).equals(alarmDate)){
  111 +// initAlarmMap();
  112 +// alarmDate = DateUtils.date2String(new Date(),DateUtils.format1) ;
  113 +// }
  114 +// //开始过滤数据 推送
  115 +// List<String> keyList = new ArrayList<>();
  116 +// for(Map.Entry<String, String> entity : alarmMap.entrySet()){
  117 +// String endTime = entity.getValue().split("_")[1];
  118 +// if(DateUtils.getDateDifference(new Date(),DateUtils.string2Date(now+" "+endTime+":00",DateUtils.format2),"m")>=2
  119 +// ){
  120 +// String key = entity.getKey();
  121 +// keyList.add(key);
  122 +// //alarm(entity); //告警
  123 +// //insertIOT(entity); //iot
  124 +// }
  125 +// }
  126 +// for(String key : keyList){
  127 +// map.remove(key);
  128 +// }
  129 +// }
  130 +//
  131 +// private void initAlarmMap(){
  132 +// alarmMap = new HashMap<>();
  133 +// List<TemplateDto> list = scFeign.getAllTemplateAlarm();
  134 +// logger.info(("------考勤告警模板------"));
  135 +// for(TemplateDto templateDto : list){
  136 +// String config = templateDto.getConfig();
  137 +// String[] array = config.split("<Template");
  138 +// for(int i = 1 ; i<array.length ;i++){
  139 +// try{
  140 +// String msg = array[i];
  141 +// String beginTime = msg.substring(msg.indexOf("BeginTime")+11,msg.indexOf("BeginTime")+16);
  142 +// String endTime = msg.substring(msg.indexOf("EndTime")+9,msg.indexOf("EndTime")+14);
  143 +// String templateId = msg.substring(msg.indexOf("TemplateID")+12,msg.indexOf("TemplateID")+22);
  144 +// String Week = msg.substring(msg.indexOf("Week")+6,msg.indexOf("Week")+19);
  145 +// String type = msg.substring(msg.indexOf("Type")+6,msg.indexOf("Type")+8);
  146 +// type = type.replace("\"","");
  147 +// int nowWeek = DateUtils.getWeek() ;
  148 +// if(Week.contains(nowWeek+"") && nowWeek != 6 && nowWeek != 0 ){ //周末不告警
  149 +// logger.info((templateId+"_"+templateDto.getSchoolId()+"------"+beginTime+"_"+endTime));
  150 +// alarmMap.put(templateId+"_"+templateDto.getSchoolId()+"_"+templateDto.getTitle() , beginTime+"_"+endTime+"_"+type+"_"+templateDto.getId());
  151 +// }
  152 +// }catch (Exception e){
  153 +// e.printStackTrace();
  154 +// }
  155 +// }
  156 +// }
  157 +// }
  158 +//
  159 +// //告警推送
  160 +// private void alarm(Map.Entry<String,String> entry){
  161 +// String templateId = entry.getKey().split("_")[0] ;
  162 +// String schoolId = entry.getKey().split("_")[1] ;
  163 +// String id = entry.getValue().split("_")[3];
  164 +// String type = entry.getValue().split("_")[2] ;
  165 +//
  166 +// if(DateUtils.getWeek() == 2 || DateUtils.getWeek() == 5){
  167 +// //可以相差40%
  168 +// BigDecimal percent = getAlarmCensus(Integer.valueOf(id),templateId,Integer.valueOf(schoolId),Integer.valueOf(type));
  169 +// if(templateMap.get(templateId) != null){
  170 +// if(percent.subtract(templateMap.get(templateId)).compareTo(new BigDecimal(0.4)) > 0
  171 +// || templateMap.get(templateId).subtract(percent).compareTo(new BigDecimal(0.4)) > 0) {
  172 +// alarmPush(Integer.valueOf(schoolId));
  173 +// }
  174 +// }
  175 +// templateMap.put(templateId,percent);
  176 +// }else {
  177 +// //相差30%
  178 +// BigDecimal percent = getAlarmCensus(Integer.valueOf(id),templateId,Integer.valueOf(schoolId),Integer.valueOf(type));
  179 +// if(templateMap.get(templateId) != null){
  180 +// if(percent.subtract(templateMap.get(templateId)).compareTo(new BigDecimal(0.3)) > 0
  181 +// || templateMap.get(templateId).subtract(percent).compareTo(new BigDecimal(0.3)) > 0) {
  182 +// alarmPush(Integer.valueOf(schoolId));
  183 +// }
  184 +// }
  185 +// templateMap.put(templateId,percent);
  186 +// }
  187 +// }
  188 +//
  189 +// private void insertIOT(Map.Entry<String,String> entry){
  190 +// String templateId = entry.getKey().split("_")[0] ;
  191 +// String schoolId = entry.getKey().split("_")[1] ;
  192 +// String title = entry.getKey().split("_")[2] ;
  193 +// String id = entry.getValue().split("_")[3];
  194 +// String type = entry.getValue().split("_")[2] ;
  195 +// String beginTime = entry.getValue().split("_")[0] ;
  196 +// String endTime = entry.getValue().split("_")[1] ;
  197 +//
  198 +// List<Integer> list = getIOTCensus(Integer.valueOf(id),templateId,Integer.valueOf(schoolId),Integer.valueOf(type)) ;
  199 +// JSONObject object = new JSONObject();
  200 +// object.put("strTime",beginTime);
  201 +// object.put("endTime",endTime);
  202 +// object.put("inTime",DateUtils.date2String(new Date(),DateUtils.format1));
  203 +// object.put("noAttendanceCount",list.get(1));
  204 +// object.put("attendanceCount",list.get(0));
  205 +// object.put("leaveCount",list.get(2));
  206 +// object.put("templateName",title);
  207 +// object.put("qianDaoIdId",id);
  208 +// object.put("schoolId",schoolId);
  209 +// object.put("templateId",templateId);
  210 +// HttpClientUtils.httpPostJson(iotUrl+"/api/Association/addIntelligenceAttendance",object.toJSONString());
  211 +// }
  212 +//
  213 +// //初始化要推送的模板
  214 +// private void initMap(){
  215 +// map = new HashMap<>();
  216 +// List<TemplateDto> list = scFeign.getAllTemplate();
  217 +// logger.info(("------需要推送的考勤模板------"));
  218 +// for(TemplateDto templateDto : list){
  219 +// String config = templateDto.getConfig();
  220 +// String[] array = config.split("<Template");
  221 +// for(int i = 1 ; i<array.length ;i++){
  222 +// try{
  223 +// String msg = array[i];
  224 +// String beginTime = msg.substring(msg.indexOf("BeginTime")+11,msg.indexOf("BeginTime")+16);
  225 +// String endTime = msg.substring(msg.indexOf("EndTime")+9,msg.indexOf("EndTime")+14);
  226 +// String templateId = msg.substring(msg.indexOf("TemplateID")+12,msg.indexOf("TemplateID")+22);
  227 +// String Week = msg.substring(msg.indexOf("Week")+6,msg.indexOf("Week")+19);
  228 +// String type = msg.substring(msg.indexOf("Type")+6,msg.indexOf("Type")+8);
  229 +// type = type.replace("\"","");
  230 +// int nowWeek = DateUtils.getWeek() ;
  231 +// if(Week.contains(nowWeek+"")){
  232 +// logger.info((templateId+"_"+templateDto.getSchoolId()+"_"+templateDto.getType()+"------"+beginTime+"_"+endTime));
  233 +// map.put(templateId+"_"+templateDto.getSchoolId()+"_"+templateDto.getType() , beginTime+"_"+endTime+"_"+type+"_"+templateDto.getId());
  234 +// }
  235 +// }catch (Exception e){
  236 +// e.printStackTrace();
  237 +// }
  238 +// }
  239 +// }
  240 +// }
  241 +//
  242 +// //盯盯批量推送
  243 +// private void dingBatchPush(String templateId , int schoolId , String key){
  244 +// String[] times = key.split("_");
  245 +// AppDto appDto = scFeign.getApp(schoolId,1);
  246 +// if(Integer.valueOf(times[2]) < 7){
  247 +// //出入校 推班主任
  248 +// List<KqTeacherDto> list = scFeign.getTeacherList(schoolId);
  249 +// for(KqTeacherDto teacher : list){
  250 +// dingSchoolPush(templateId,teacher,key,appDto,0);
  251 +// }
  252 +// }else {
  253 +// //出入寝 推班主任
  254 +// List<KqTeacherDto> list = scFeign.getTeacherList(schoolId);
  255 +// for(KqTeacherDto teacher : list){
  256 +// dingSchoolPush(templateId,teacher, key, appDto,1);
  257 +// }
  258 +// //推宿管
  259 +// List<KqTeacherDto> chamberList = scFeign.selectChamberTeacher(schoolId);
  260 +// for(KqTeacherDto teacher : chamberList){
  261 +// dingChamberPush(templateId,teacher, key, appDto);
  262 +// }
  263 +// }
  264 +// }
  265 +//
  266 +// //企业号批量推送
  267 +// private void weChatBatchPush(String templateId , int schoolId , String key){
  268 +// String[] times = key.split("_");
  269 +// AppDto appDto = scFeign.getApp(schoolId, 0);
  270 +// if(Integer.valueOf(times[2]) < 7) {
  271 +// //出入校 推班主任
  272 +// List<KqTeacherDto> list = scFeign.getTeacherList(schoolId);
  273 +// for (KqTeacherDto teacher : list) {
  274 +// weChatSchoolPush(templateId,teacher, key, appDto,0);
  275 +// }
  276 +// }else {
  277 +// //出入寝 推班主任
  278 +// List<KqTeacherDto> list = scFeign.getTeacherList(schoolId);
  279 +// for (KqTeacherDto teacher : list) {
  280 +// weChatSchoolPush(templateId,teacher, key, appDto,1);
  281 +// }
  282 +// //推宿管
  283 +// List<KqTeacherDto> chamberList = scFeign.selectChamberTeacher(schoolId);
  284 +// for(KqTeacherDto teacher : chamberList){
  285 +// weChatChamberPush(templateId,teacher, key, appDto);
  286 +// }
  287 +// }
  288 +// }
  289 +//
  290 +// //盯盯推送班主任
  291 +// private void dingSchoolPush(String templateId ,KqTeacherDto teacher , String key , AppDto appDto , int type){
  292 +// String[] times = key.split("_");
  293 +// String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format);
  294 +// String thirdOpenId = scFeign.getThirdId(teacher.getUserId(),0);
  295 +// if(StringUtils.isNotBlank(thirdOpenId)){
  296 +// List<CensusKqDto> censusKqDtos = getCensus(Integer.valueOf(times[3]),templateId,teacher.getSchoolId(),teacher.getUserId(),type);
  297 +// if(censusKqDtos != null &&censusKqDtos.size() > 0){
  298 +// String message = "";
  299 +// for(CensusKqDto censusKqDto : censusKqDtos){
  300 +// message += "[" + censusKqDto.getTargetName() + "]未考勤" + censusKqDto.getNotAttendCount() + "人,请假"+censusKqDto.getLeaveCount()+"人;";
  301 +// }
  302 +// DingSms dingSms = new DingSms();
  303 +// dingSms.setName(teacher.getName());
  304 +// dingSms.setTableName("DingSmsNew"+tableSuffix);
  305 +// dingSms.setMsg("报告类型:"+KqTypeEnums.getName(Integer.valueOf(times[2])) + "出勤报告 \n - "+
  306 +// "签到日期:"+DateUtils.date2String(new Date(),DateUtils.format1)+ "("+DateUtils.getWeekName()+") \n - "+
  307 +// "签到时间:"+times[0]+"-"+ times[1] +" \n - "+
  308 +// "整体数据:" + message);
  309 +// String wapUrl = "http://campus.myjxt.com/studentRecord/znxwwebapp/index.html?" +
  310 +// "schoolid="+teacher.getSchoolId()+"&userId="+teacher.getUserId()+"&name="+teacher.getName()+ "&TemplateId=" + templateId+
  311 +// "&data="+thirdOpenId+"&type=1&stype=4&mobile="+teacher.getMobile()+"&pass="+teacher.getPass()+
  312 +// "&face=&sourcetype=16&soutype=3&timestamp="+ DateUtils.getDate()+"&time="+DateUtils.date2String(new Date(),DateUtils.format1) ;
  313 +// dingSms.setSchoolId(teacher.getSchoolId());
  314 +// dingSms.setDingUserId(thirdOpenId);
  315 +// dingSms.setAgentId(appDto.getAgentId());
  316 +// dingSms.setWapUrl(wapUrl);
  317 +// dingSms.setReceiveUserId(teacher.getUserId());
  318 +// dingSms.setTdType(TypeEnums.kaoqing.getType());
  319 +// this.insertDing(dingSms);
  320 +// logger.info("盯盯推送班主任—————" + templateId + "--------" + teacher.getName());
  321 +// }
  322 +// }
  323 +// }
  324 +//
  325 +// //盯盯推送宿管
  326 +// private void dingChamberPush(String templateId, KqTeacherDto teacher , String key , AppDto appDto){
  327 +// String[] times = key.split("_");
  328 +// String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format);
  329 +// String thirdOpenId = scFeign.getThirdId(teacher.getUserId(),0);
  330 +// if(StringUtils.isNotBlank(thirdOpenId)){
  331 +// List<CensusKqDto> censusKqDtos = getCensus(Integer.valueOf(times[3]),templateId,teacher.getSchoolId(),teacher.getUserId(),1);
  332 +// if(censusKqDtos != null &&censusKqDtos.size() > 0){
  333 +// String message = "";
  334 +// for(CensusKqDto censusKqDto : censusKqDtos){
  335 +// message += "[" + censusKqDto.getTargetName() + "]未考勤" + censusKqDto.getNotAttendCount() + "人,请假"+censusKqDto.getLeaveCount()+"人;";
  336 +// }
  337 +// DingSms dingSms = new DingSms();
  338 +// dingSms.setName(teacher.getName());
  339 +// dingSms.setTableName("DingSmsNew"+tableSuffix);
  340 +// dingSms.setMsg("报告类型:"+KqTypeEnums.getName(Integer.valueOf(times[2])) + "出勤报告 \n - "+
  341 +// "签到日期:"+DateUtils.date2String(new Date(),DateUtils.format1)+ "("+DateUtils.getWeekName()+") \n - "+
  342 +// "签到时间:"+times[0]+"-"+ times[1] +" \n - "+
  343 +// "整体数据:" + message);
  344 +// String msgUrl = "http://campus.myjxt.com/studentRecord/znxwwebapp/index.html?" +
  345 +// "schoolid=" + teacher.getSchoolId() + "&userId=" + teacher.getUserId() + "&name=" + teacher.getName() +"&TemplateId=" + templateId+
  346 +// "&pass=" + teacher.getPass() + "&type=4&soutype=3&time="+DateUtils.date2String(new Date(),DateUtils.format1);
  347 +// dingSms.setSchoolId(teacher.getSchoolId());
  348 +// dingSms.setDingUserId(thirdOpenId);
  349 +// dingSms.setAgentId(appDto.getAgentId());
  350 +// dingSms.setWapUrl(msgUrl);
  351 +// dingSms.setReceiveUserId(teacher.getUserId());
  352 +// dingSms.setTdType(TypeEnums.kaoqing.getType());
  353 +// this.insertDing(dingSms);
  354 +// logger.info("盯盯推送宿管—————" + templateId + "--------" + teacher.getName());
  355 +// }
  356 +// }
  357 +// }
  358 +//
  359 +// //企业号推送班主任
  360 +// private void weChatSchoolPush(String templateId, KqTeacherDto teacher , String key , AppDto appDto , int type){
  361 +// String[] times = key.split("_");
  362 +// String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format);
  363 +// String thirdOpenId = scFeign.getThirdId(teacher.getUserId(),1);
  364 +// if (StringUtils.isNotBlank(thirdOpenId)) {
  365 +// List<CensusKqDto> censusKqDtos = getCensus(Integer.valueOf(times[3]),templateId,teacher.getSchoolId(),teacher.getUserId(),type);
  366 +// if (censusKqDtos != null && censusKqDtos.size() > 0) {
  367 +// String message = "";
  368 +// for (CensusKqDto censusKqDto : censusKqDtos) {
  369 +// message += "[" + censusKqDto.getTargetName() + "]未考勤" + censusKqDto.getNotAttendCount() + "人,请假"+censusKqDto.getLeaveCount()+"人;";
  370 +// }
  371 +// WeChatSms weChatSms = new WeChatSms();
  372 +// weChatSms.setTableName("qyhSmsNew" + tableSuffix);
  373 +// weChatSms.setMsg("报告类型:" + KqTypeEnums.getName(Integer.valueOf(times[2])) + "出勤报告 \n - " +
  374 +// "签到日期:" + DateUtils.date2String(new Date(), DateUtils.format1) + "(" + DateUtils.getWeekName() + ") \n - " +
  375 +// "签到时间:" + times[0] + "-" + times[1] + " \n - " +
  376 +// "整体数据:" + message);
  377 +// weChatSms.setSchoolId(teacher.getSchoolId());
  378 +// weChatSms.setName(teacher.getName());
  379 +// weChatSms.setQiYeHaoUserId(thirdOpenId);
  380 +// weChatSms.setReceiveUserId(teacher.getUserId());
  381 +// weChatSms.setAppId(appDto.getAgentId());
  382 +// weChatSms.setSecret(appDto.getAgentSecret());
  383 +// String msgUrl = "http://campus.myjxt.com/studentRecord/znxwwebapp/index.html?" +
  384 +// "schoolid=" + teacher.getSchoolId() + "&userId=" + teacher.getUserId() + "&name=" + teacher.getName() +"&TemplateId=" + templateId+
  385 +// "&data=" + thirdOpenId + "&type=1&stype=3&mobile=" + teacher.getMobile() + "&pass=" + teacher.getPass() +
  386 +// "&face=" + teacher.getFace() + "&sourcetype=16&soutype=2&timestamp=" + DateUtils.getDate()+"&time="+DateUtils.date2String(new Date(),DateUtils.format1)+"&";
  387 +// weChatSms.setMsgUrl(msgUrl);
  388 +// weChatSms.setTdType(TypeEnums.kaoqing.getType());
  389 +// this.insertQYH(weChatSms);
  390 +// logger.info("企业号推送班主任—————" + templateId + "--------" + teacher.getName());
  391 +// }
  392 +// }
  393 +// }
  394 +//
  395 +// //企业号推送宿管
  396 +// private void weChatChamberPush(String templateId, KqTeacherDto teacher , String key , AppDto appDto){
  397 +// String[] times = key.split("_");
  398 +// String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format);
  399 +// String thirdOpenId = scFeign.getThirdId(teacher.getUserId(),1);
  400 +// if (StringUtils.isNotBlank(thirdOpenId)) {
  401 +// List<CensusKqDto> censusKqDtos = getCensus(Integer.valueOf(times[3]),templateId,teacher.getSchoolId(),teacher.getUserId(),1);
  402 +// if (censusKqDtos != null && censusKqDtos.size() > 0) {
  403 +// String message = "";
  404 +// for (CensusKqDto censusKqDto : censusKqDtos) {
  405 +// message += "[" + censusKqDto.getTargetName() + "]未考勤" + censusKqDto.getNotAttendCount() + "人,请假"+censusKqDto.getLeaveCount()+"人;";
  406 +// }
  407 +// WeChatSms weChatSms = new WeChatSms();
  408 +// weChatSms.setTableName("qyhSmsNew" + tableSuffix);
  409 +// weChatSms.setMsg("报告类型:" + KqTypeEnums.getName(Integer.valueOf(times[2])) + "出勤报告 \n - " +
  410 +// "签到日期:" + DateUtils.date2String(new Date(), DateUtils.format1) + "(" + DateUtils.getWeekName() + ") \n - " +
  411 +// "签到时间:" + times[0] + "-" + times[1] + " \n - " +
  412 +// "整体数据:" + message);
  413 +// weChatSms.setSchoolId(teacher.getSchoolId());
  414 +// weChatSms.setName(teacher.getName());
  415 +// weChatSms.setQiYeHaoUserId(thirdOpenId);
  416 +// weChatSms.setReceiveUserId(teacher.getUserId());
  417 +// weChatSms.setAppId(appDto.getAgentId());
  418 +// weChatSms.setSecret(appDto.getAgentSecret());
  419 +// String msgUrl = "http://campus.myjxt.com/studentRecord/znxwwebapp/index.html?" +
  420 +// "schoolid=" + teacher.getSchoolId() + "&userId=" + teacher.getUserId() + "&name=" + teacher.getName() +"&TemplateId=" + templateId+
  421 +// "&pass=" + teacher.getPass() + "&type=4&soutype=2&time="+DateUtils.date2String(new Date(),DateUtils.format1)+"&";
  422 +// weChatSms.setMsgUrl(msgUrl);
  423 +// weChatSms.setTdType(TypeEnums.kaoqing.getType());
  424 +// this.insertQYH(weChatSms);
  425 +// logger.info("企业号推送宿管—————" + templateId + "--------" + teacher.getName());
  426 +// }
  427 +// }
  428 +// }
  429 +//
  430 +// //type 0 出入校 1 出入寝
  431 +// private List<CensusKqDto> getCensus(int id , String templateId ,int schoolId , String userId ,int type){
  432 +// List<CensusKqDto> list = new ArrayList<>();
  433 +// String url = "http://campus.myjxt.com/api/EasyN/GeAttendDetailNew?schoolId="+schoolId+
  434 +// "&id="+id+"&templateID="+templateId+"&type="+type+"&userId="+userId+"&time=" + DateUtils.date2String(new Date(),DateUtils.format1);
  435 +// JSONObject jsonObject = HttpClientUtils.httpGet(url);
  436 +// try{
  437 +// JSONArray data = (JSONArray)jsonObject.get("data");
  438 +// for(int i = 0 ; i < data.size() ; i++){
  439 +// CensusKqDto censusKqDto = new CensusKqDto();
  440 +// JSONObject object = data.getJSONObject(i);
  441 +// censusKqDto.setLeaveCount((Integer) object.get("leaveCount"));
  442 +// censusKqDto.setNotAttendCount((Integer) object.get("noAttendCount"));
  443 +// censusKqDto.setTargetName((String)object.get("name"));
  444 +// list.add(censusKqDto);
  445 +// }
  446 +// }catch (Exception e){
  447 +//
  448 +// }
  449 +// return list ;
  450 +// }
  451 +//
  452 +// private BigDecimal getAlarmCensus(int id , String templateId ,int schoolId , int type){
  453 +// int allNumber = 0 , attendNumber = 0 ;
  454 +// List<Integer> list = scFeign.selectClassBySchoolId(schoolId);
  455 +// for(Integer classId : list){
  456 +// String url = "http://campus.myjxt.com/api/EasyN/GeAttendDetail?classId="+classId+
  457 +// "&id="+id+"&templateID="+templateId+"&type="+type+"&time=" + DateUtils.date2String(new Date(),DateUtils.format1);
  458 +// JSONObject jsonObject = HttpClientUtils.httpGet(url);
  459 +// try{
  460 +// JSONObject data = (JSONObject) jsonObject.get("data");
  461 +// attendNumber = attendNumber + (Integer) data.get("stuAttendCount");
  462 +// allNumber = allNumber + (Integer) data.get("stuCount");
  463 +// }catch (Exception e){
  464 +// e.printStackTrace();
  465 +// }
  466 +// }
  467 +// if(allNumber != 0){
  468 +// BigDecimal pecrent = new BigDecimal(attendNumber).divide(new BigDecimal(allNumber),10, BigDecimal.ROUND_HALF_DOWN) ;
  469 +// return pecrent ;
  470 +// }else {
  471 +// return BigDecimal.ZERO ;
  472 +// }
  473 +//
  474 +// }
  475 +//
  476 +// /**
  477 +// *
  478 +// * @param id
  479 +// * @param templateId
  480 +// * @param schoolId
  481 +// * @param type
  482 +// * @return list(0) 出勤 list(1) 未出勤 List(2) 请假
  483 +// */
  484 +// private List<Integer> getIOTCensus(int id , String templateId ,int schoolId , int type){
  485 +// List<Integer> result = new ArrayList<>();
  486 +// int attend = 0 , unattend = 0 , leave = 0;
  487 +// List<Integer> list = scFeign.selectClassBySchoolId(schoolId);
  488 +// for(Integer classId : list){
  489 +// String url = "http://campus.myjxt.com/api/EasyN/GeAttendDetail?classId="+classId+
  490 +// "&id="+id+"&templateID="+templateId+"&type="+type+"&time=" + DateUtils.date2String(new Date(),DateUtils.format1);
  491 +// JSONObject jsonObject = HttpClientUtils.httpGet(url);
  492 +// try{
  493 +// JSONObject data = (JSONObject) jsonObject.get("data");
  494 +// attend = attend + (Integer) data.get("stuAttendCount");
  495 +// unattend = unattend + (Integer) data.get("noAttendCount");
  496 +// leave = leave + (Integer) data.get("leaveCount");
  497 +// }catch (Exception e){
  498 +// e.printStackTrace();
  499 +// }
  500 +// }
  501 +// result.add(attend);
  502 +// result.add(unattend);
  503 +// result.add(leave);
  504 +// return result ;
  505 +// }
  506 +//
  507 +//
  508 +// private void insertDing(DingSms dingSms){
  509 +// try{
  510 +// smsService.insertDing(dingSms);
  511 +// }catch (Exception e){
  512 +// logger.info(e.toString());
  513 +// }
  514 +// }
  515 +//
  516 +// private void insertQYH(WeChatSms weChatSms){
  517 +// try{
  518 +// smsService.insertWeChat(weChatSms);
  519 +// }catch (Exception e){
  520 +// logger.info(e.toString());
  521 +// }
  522 +// }
  523 +//
  524 +// private void alarmPush(int schoolId){
  525 +// String msg = "【考勤异动】" ;
  526 +// try{
  527 +// SchoolDto schoolDto = scFeign.selectSchoolBySchoolId(schoolId);
  528 +// msg += schoolDto.getSchoolName() + "考勤有异动,请关注!" ;
  529 +// sendMessage(schoolDto.getSchoolId(),opexList.get(0),msg);
  530 +// sendMessage(schoolDto.getSchoolId(),opexList.get(1),msg);
  531 +// sendMessage(schoolDto.getSchoolId(),integration,msg);
  532 +// String managerPhone = managerService.selectManagerById(schoolDto.getManagerUserId()) ;
  533 +// if(StringUtils.isNotBlank(managerPhone)){
  534 +// sendMessage(schoolDto.getSchoolId(),managerPhone,msg);
  535 +// }
  536 +// }catch (Exception e){
  537 +// e.printStackTrace();
  538 +// }
  539 +//
  540 +// }
  541 +//
  542 +// private void sendMessage(int schoolId , String mobile , String msg){
  543 +// String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format);
  544 +// ShortMsg shortMsg = new ShortMsg();
  545 +// shortMsg.setTableName("smsNew"+tableSuffix);
  546 +// shortMsg.setSchoolId(schoolId);
  547 +// shortMsg.setMobile(mobile);
  548 +// shortMsg.setMsg(msg);
  549 +// smsService.insertSMS(shortMsg);
  550 +// }
  551 +//}
... ...
cloud/quartz/src/main/java/com/sincere/quartz/job/SyncJob.java
1   -package com.sincere.quartz.job;
2   -
3   -import com.sincere.quartz.third.yixueyun.YXYReadService;
4   -import com.sincere.quartz.third.yixueyun.YXYWriteService;
5   -import org.springframework.beans.factory.annotation.Autowired;
6   -import org.springframework.scheduling.annotation.Scheduled;
7   -import org.springframework.stereotype.Service;
8   -
9   -/**
10   - * @author chen
11   - * @version 1.0
12   - * @date 2019/12/24 0024 10:54
13   - */
14   -@Service
15   -public class SyncJob {
16   -
17   - @Autowired
18   - YXYWriteService yxyWriteService;
19   -
20   - @Autowired
21   - YXYReadService yxyReadService;
22   -
23   - @Scheduled(cron = "30 1 22 * * ? ")
24   - public void Sync(){
25   - //翼校通的同步 之后还有钉钉的同步等等
26   - yxyReadService.sync();
27   - yxyWriteService.sync();
28   - }
29   -}
  1 +//package com.sincere.quartz.job;
  2 +//
  3 +//import com.sincere.quartz.third.yixueyun.YXYReadService;
  4 +//import com.sincere.quartz.third.yixueyun.YXYWriteService;
  5 +//import org.springframework.beans.factory.annotation.Autowired;
  6 +//import org.springframework.scheduling.annotation.Scheduled;
  7 +//import org.springframework.stereotype.Service;
  8 +//
  9 +///**
  10 +// * @author chen
  11 +// * @version 1.0
  12 +// * @date 2019/12/24 0024 10:54
  13 +// */
  14 +//@Service
  15 +//public class SyncJob {
  16 +//
  17 +// @Autowired
  18 +// YXYWriteService yxyWriteService ;
  19 +//
  20 +// @Autowired
  21 +// YXYReadService yxyReadService ;
  22 +//
  23 +// @Scheduled(cron = "30 1 22 * * ? ")
  24 +// public void Sync(){
  25 +// //翼校通的同步 之后还有钉钉的同步等等
  26 +// yxyReadService.sync();
  27 +// yxyWriteService.sync();
  28 +// }
  29 +//}
... ...
cloud/quartz/src/main/java/com/sincere/quartz/mapper/YxyMapper.java
1 1 package com.sincere.quartz.mapper;
2 2  
  3 +import com.sincere.quartz.dto.*;
3 4 import com.sincere.quartz.model.YxyAgency;
4 5 import com.sincere.quartz.model.YxyStudent;
5 6 import com.sincere.quartz.model.YxyTeacher;
  7 +import org.apache.ibatis.annotations.Param;
  8 +
  9 +import java.util.List;
6 10  
7 11 public interface YxyMapper {
8 12  
  13 + List<TeacherView> getTeacherView(@Param("schoolId") int schoolId , @Param("name")String name);
  14 +
  15 + List<StudentView> getStudentView(@Param("classId") int classId , @Param("name") String name );
  16 +
  17 + int getGradeId(@Param("schoolId")int schoolId , @Param("grade")String grade);
  18 +
  19 + int getClassId(@Param("schoolId")int schoolId , @Param("className")String className);
  20 +
  21 + String getDeptName(String deptId);
  22 +
  23 + String getSuperDeptName(String deptId);
  24 +
  25 + void addStudent(AddStudentDto addStudentDto);
  26 +
  27 + void editStudent(EditStudentDto editStudentDto);
  28 +
  29 + void addTeacher(AddTeacherDto addTeacherDto);
  30 +
  31 + void editTeacher(EditTeacherDto editTeacherDto);
  32 +
9 33 int selectCount(String date);
10 34  
11 35 int deleteWeekBefore();
... ... @@ -21,4 +45,8 @@ public interface YxyMapper {
21 45 int insertTeacher(YxyTeacher teacher) ;
22 46  
23 47 int insertStudent(YxyStudent student) ;
  48 +
  49 + int updateTeacherBySchool(@Param("deptId") String deptId);
  50 +
  51 + int updateStudentBySchool(@Param("classId") String classId);
24 52 }
... ...
cloud/quartz/src/main/java/com/sincere/quartz/model/YxyStudent.java
... ... @@ -2,13 +2,22 @@ package com.sincere.quartz.model;
2 2  
3 3 public class YxyStudent {
4 4  
5   - private String userId;
6   - private String classId;
7   - private String name;
8   - private String account;
9   - private String cardID;
  5 + private String userId ;
  6 + private String classId ;
  7 + private String name ;
  8 + private String account ;
  9 + private String cardID ;
10 10 private String cardID2;
11   - private String cardID3;
  11 + private String cardID3 ;
  12 + private int type ;
  13 +
  14 + public int getType() {
  15 + return type;
  16 + }
  17 +
  18 + public void setType(int type) {
  19 + this.type = type;
  20 + }
12 21  
13 22 public String getCardID() {
14 23 return cardID;
... ... @@ -65,4 +74,18 @@ public class YxyStudent {
65 74 public void setAccount(String account) {
66 75 this.account = account;
67 76 }
  77 +
  78 + @Override
  79 + public String toString() {
  80 + return "YxyStudent{" +
  81 + "userId='" + userId + '\'' +
  82 + ", classId='" + classId + '\'' +
  83 + ", name='" + name + '\'' +
  84 + ", account='" + account + '\'' +
  85 + ", cardID='" + cardID + '\'' +
  86 + ", cardID2='" + cardID2 + '\'' +
  87 + ", cardID3='" + cardID3 + '\'' +
  88 + ", type=" + type +
  89 + '}';
  90 + }
68 91 }
... ...
cloud/quartz/src/main/java/com/sincere/quartz/model/YxyTeacher.java
... ... @@ -2,10 +2,19 @@ package com.sincere.quartz.model;
2 2  
3 3 public class YxyTeacher {
4 4  
5   - private String userId;
6   - private String account;
7   - private String name;
8   - private String deptId;
  5 + private String userId ;
  6 + private String account ;
  7 + private String name ;
  8 + private String deptId ;
  9 + private int type ;
  10 +
  11 + public int getType() {
  12 + return type;
  13 + }
  14 +
  15 + public void setType(int type) {
  16 + this.type = type;
  17 + }
9 18  
10 19 public String getUserId() {
11 20 return userId;
... ... @@ -38,4 +47,15 @@ public class YxyTeacher {
38 47 public void setDeptId(String deptId) {
39 48 this.deptId = deptId;
40 49 }
  50 +
  51 + @Override
  52 + public String toString() {
  53 + return "YxyTeacher{" +
  54 + "userId='" + userId + '\'' +
  55 + ", account='" + account + '\'' +
  56 + ", name='" + name + '\'' +
  57 + ", deptId='" + deptId + '\'' +
  58 + ", type=" + type +
  59 + '}';
  60 + }
41 61 }
... ...
cloud/quartz/src/main/java/com/sincere/quartz/service/YxyService.java
1 1 package com.sincere.quartz.service;
2 2  
  3 +import com.sincere.quartz.dto.*;
3 4 import com.sincere.quartz.model.YxyAgency;
4 5 import com.sincere.quartz.model.YxyStudent;
5 6 import com.sincere.quartz.model.YxyTeacher;
  7 +import org.apache.ibatis.annotations.Param;
  8 +
  9 +import java.util.List;
6 10  
7 11 public interface YxyService {
8 12  
  13 + List<TeacherView> getTeacherView( int schoolId , String name);
  14 +
  15 + List<StudentView> getStudentView(int classId ,String name );
  16 +
  17 + int getGradeId(int schoolId , String grade);
  18 +
  19 + int getClassId(int schoolId , String className);
  20 +
  21 + void addStudent(AddStudentDto addStudentDto);
  22 +
  23 + void editStudent(EditStudentDto editStudentDto);
  24 +
  25 + void addTeacher(AddTeacherDto addTeacherDto);
  26 +
  27 + void editTeacher(EditTeacherDto editTeacherDto);
  28 +
  29 + String getDeptName(String deptId);
  30 +
  31 + String getSuperDeptName(String deptId);
  32 +
9 33 int selectCount(String date);
10 34  
11 35 int deleteWeekBefore();
... ... @@ -21,4 +45,8 @@ public interface YxyService {
21 45 int insertTeacher(YxyTeacher teacher) ;
22 46  
23 47 int insertStudent(YxyStudent student) ;
  48 +
  49 + int updateTeacherBySchool(String deptId);
  50 +
  51 + int updateStudentBySchool(String classId);
24 52 }
... ...
cloud/quartz/src/main/java/com/sincere/quartz/service/impl/YxyServiceImpl.java
... ... @@ -2,6 +2,7 @@ package com.sincere.quartz.service.impl;
2 2  
3 3 import com.sincere.quartz.datasource.DataSourceType;
4 4 import com.sincere.quartz.datasource.MyDataSource;
  5 +import com.sincere.quartz.dto.*;
5 6 import com.sincere.quartz.mapper.YxyMapper;
6 7 import com.sincere.quartz.model.YxyAgency;
7 8 import com.sincere.quartz.model.YxyStudent;
... ... @@ -10,6 +11,8 @@ import com.sincere.quartz.service.YxyService;
10 11 import org.springframework.beans.factory.annotation.Autowired;
11 12 import org.springframework.stereotype.Service;
12 13  
  14 +import java.util.List;
  15 +
13 16 @Service
14 17 public class YxyServiceImpl implements YxyService {
15 18  
... ... @@ -17,6 +20,66 @@ public class YxyServiceImpl implements YxyService {
17 20 YxyMapper yxyMapper;
18 21  
19 22 @Override
  23 + @MyDataSource(DataSourceType.Update)
  24 + public List<TeacherView> getTeacherView(int schoolId, String name) {
  25 + return yxyMapper.getTeacherView(schoolId,name);
  26 + }
  27 +
  28 + @Override
  29 + @MyDataSource(DataSourceType.Update)
  30 + public List<StudentView> getStudentView(int classId, String name) {
  31 + return yxyMapper.getStudentView(classId,name);
  32 + }
  33 +
  34 + @Override
  35 + @MyDataSource(DataSourceType.Update)
  36 + public int getGradeId(int schoolId, String grade) {
  37 + return yxyMapper.getGradeId(schoolId,grade);
  38 + }
  39 +
  40 + @Override
  41 + @MyDataSource(DataSourceType.Update)
  42 + public int getClassId(int schoolId, String className) {
  43 + return yxyMapper.getClassId(schoolId,className);
  44 + }
  45 +
  46 + @Override
  47 + @MyDataSource(DataSourceType.Update)
  48 + public void addStudent(AddStudentDto addStudentDto) {
  49 + yxyMapper.addStudent(addStudentDto);
  50 + }
  51 +
  52 + @Override
  53 + @MyDataSource(DataSourceType.Update)
  54 + public void editStudent(EditStudentDto editStudentDto) {
  55 + yxyMapper.editStudent(editStudentDto);
  56 + }
  57 +
  58 + @Override
  59 + @MyDataSource(DataSourceType.Update)
  60 + public void addTeacher(AddTeacherDto addTeacherDto) {
  61 + yxyMapper.addTeacher(addTeacherDto);
  62 + }
  63 +
  64 + @Override
  65 + @MyDataSource(DataSourceType.Update)
  66 + public void editTeacher(EditTeacherDto editTeacherDto) {
  67 + yxyMapper.editTeacher(editTeacherDto);
  68 + }
  69 +
  70 + @Override
  71 + @MyDataSource(DataSourceType.Yxy)
  72 + public String getDeptName(String deptId) {
  73 + return yxyMapper.getDeptName(deptId);
  74 + }
  75 +
  76 + @Override
  77 + @MyDataSource(DataSourceType.Yxy)
  78 + public String getSuperDeptName(String deptId) {
  79 + return yxyMapper.getSuperDeptName(deptId);
  80 + }
  81 +
  82 + @Override
20 83 @MyDataSource(DataSourceType.Yxy)
21 84 public int selectCount(String date) {
22 85 return yxyMapper.selectCount(date);
... ... @@ -63,4 +126,16 @@ public class YxyServiceImpl implements YxyService {
63 126 public int insertStudent(YxyStudent student) {
64 127 return yxyMapper.insertStudent(student);
65 128 }
  129 +
  130 + @Override
  131 + @MyDataSource(DataSourceType.Yxy)
  132 + public int updateTeacherBySchool(String deptId) {
  133 + return yxyMapper.updateTeacherBySchool(deptId);
  134 + }
  135 +
  136 + @Override
  137 + @MyDataSource(DataSourceType.Yxy)
  138 + public int updateStudentBySchool(String classId) {
  139 + return yxyMapper.updateStudentBySchool(classId);
  140 + }
66 141 }
... ...
cloud/quartz/src/main/java/com/sincere/quartz/third/qiyehao/QYHUtils.java
1   -package com.sincere.quartz.third.qiyehao;
2   -
3   -import com.alibaba.fastjson.JSONObject;
4   -import com.sincere.common.util.HttpClientUtils;
5   -
6   -/**
7   - * @author chen
8   - * @version 1.0
9   - * @date 2019/12/11 0011 15:28
10   - */
11   -public class QYHUtils {
12   -
13   - public static void main(String[] args) {
14   - getToken("wx51b3acc9a06f0bb0", "pb5P1feSHnWYYLPAfN4QBMk-nPFaF4RGW5Lq1ceyfhk");
15   - }
16   -
17   - public static String getToken(String id, String secret) {
18   - String url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=" + id + "&corpsecret=" + secret;
19   - JSONObject json = HttpClientUtils.httpGet(url);
20   - return json.get("access_token").toString();
21   - }
22   -
23   - public static void getDept(String accessToken) {
24   - String url = "https://qyapi.weixin.qq.com/cgi-bin/department/list?access_token=" + accessToken;
25   - JSONObject json = HttpClientUtils.httpGet(url);
26   - }
27   -
28   - public static void getUser(String accessToken) {
29   - String url = "https://qyapi.weixin.qq.com/cgi-bin/user/list?access_token=" + accessToken + "&department_id=" + 1 + "&fetch_child=1&status=0";
30   - JSONObject json = HttpClientUtils.httpGet(url);
31   - }
32   -}
  1 +//package com.sincere.quartz.third.qiyehao;
  2 +//
  3 +//import com.alibaba.fastjson.JSONObject;
  4 +//import com.sincere.common.util.HttpClientUtils;
  5 +//
  6 +///**
  7 +// * @author chen
  8 +// * @version 1.0
  9 +// * @date 2019/12/11 0011 15:28
  10 +// */
  11 +//public class QYHUtils {
  12 +//
  13 +// public static void main(String[] args) {
  14 +// getToken("wx51b3acc9a06f0bb0", "pb5P1feSHnWYYLPAfN4QBMk-nPFaF4RGW5Lq1ceyfhk");
  15 +// }
  16 +//
  17 +// public static String getToken(String id, String secret) {
  18 +// String url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=" + id + "&corpsecret=" + secret;
  19 +// JSONObject json = HttpClientUtils.httpGet(url);
  20 +// return json.get("access_token").toString();
  21 +// }
  22 +//
  23 +// public static void getDept(String accessToken) {
  24 +// String url = "https://qyapi.weixin.qq.com/cgi-bin/department/list?access_token=" + accessToken;
  25 +// JSONObject json = HttpClientUtils.httpGet(url);
  26 +// }
  27 +//
  28 +// public static void getUser(String accessToken) {
  29 +// String url = "https://qyapi.weixin.qq.com/cgi-bin/user/list?access_token=" + accessToken + "&department_id=" + 1 + "&fetch_child=1&status=0";
  30 +// JSONObject json = HttpClientUtils.httpGet(url);
  31 +// }
  32 +//}
... ...
cloud/quartz/src/main/java/com/sincere/quartz/third/yixueyun/YXYAddReadService.java 0 → 100644
... ... @@ -0,0 +1,413 @@
  1 +package com.sincere.quartz.third.yixueyun;
  2 +
  3 +import com.alibaba.fastjson.JSONArray;
  4 +import com.alibaba.fastjson.JSONObject;
  5 +import com.sincere.common.dto.smartCampus.SyncSchoolDto;
  6 +import com.sincere.common.util.DateUtils;
  7 +import com.sincere.common.util.HttpClientUtils;
  8 +import com.sincere.common.util.Xml2JsonUtils;
  9 +import com.sincere.quartz.dto.*;
  10 +import com.sincere.quartz.feign.ScFeign;
  11 +import com.sincere.quartz.model.YxyAgency;
  12 +import com.sincere.quartz.model.YxyStudent;
  13 +import com.sincere.quartz.model.YxyTeacher;
  14 +import com.sincere.quartz.service.YxyService;
  15 +import com.sincere.quartz.utils.ThreadUtils;
  16 +import org.apache.commons.lang3.StringUtils;
  17 +import org.slf4j.Logger;
  18 +import org.slf4j.LoggerFactory;
  19 +import org.springframework.beans.factory.annotation.Autowired;
  20 +import org.springframework.stereotype.Service;
  21 +
  22 +import java.math.BigInteger;
  23 +import java.security.MessageDigest;
  24 +import java.util.ArrayList;
  25 +import java.util.Date;
  26 +import java.util.List;
  27 +import java.util.concurrent.ExecutorService;
  28 +
  29 +@Service
  30 +public class YXYAddReadService {
  31 +
  32 + private static String SI = "SZ" ;
  33 + private static int SI_CODE = 12345678 ;
  34 +
  35 + private static String nameSpace = "http://service.pubinfo.com.cn" ;
  36 +
  37 + private static String getAllTeacher = "http://122.229.30.149:8282/DataSynService/GetTeacherInfo";
  38 + private static String getAllTeacher_method = "getTeacherInfo" ;
  39 + private static String getAddTeacher = "http://122.229.30.149:8282/DataSynService/GetIncrementTeacherInfo" ;
  40 + private static String getAddTeacher_method = "getIncrementTeacherInfo" ;
  41 +
  42 + private static String getAllStudent = "http://122.229.30.149:8282/DataSynService/GetStudentInfo" ;
  43 + private static String getALlStudent_method = "getStudentInfo";
  44 + private static String getAddStudent = "http://122.229.30.149:8282/DataSynService/GetIncrementStudentInfo" ;
  45 + private static String getAddStudent_method = "getIncrementStudentInfo" ;
  46 +
  47 + @Autowired
  48 + ScFeign scFeign ;
  49 +
  50 + @Autowired
  51 + YxyService yxyService ;
  52 +
  53 + private Logger logger = LoggerFactory.getLogger(YXYAddReadService.class);
  54 +
  55 + public void sync(){
  56 + logger.info("翼学云增量同步服务开始");
  57 + List<SyncSchoolDto> schoolList = scFeign.selectSyncSchool();
  58 + for(SyncSchoolDto syncSchoolDto : schoolList){
  59 + if(syncSchoolDto.getSchoolId() == 32){
  60 + logger.info(syncSchoolDto.getSchoolName()+"开始同步");
  61 + syncSchool(syncSchoolDto.getYxtId(),syncSchoolDto.getSchoolId());
  62 + }
  63 + }
  64 + }
  65 +
  66 + public void syncSchool(String yxtId , int hxyId){
  67 + List<YxyStudent> studentList = new ArrayList<>(); //syncStudent(yxtId);
  68 + List<YxyTeacher> teacherList = syncTeacher(yxtId);
  69 + logger.info("学生同步");
  70 + for(YxyStudent student : studentList){
  71 + logger.info(student.toString());
  72 + if(student.getType() == 1){
  73 + //新增
  74 + try{
  75 + String className = yxyService.getDeptName(student.getClassId());
  76 + String gradeName = yxyService.getSuperDeptName(student.getClassId());
  77 + int gradeId = yxyService.getGradeId(hxyId,gradeName);
  78 + int classId = yxyService.getClassId(hxyId,className);
  79 + if(gradeId != 0 && classId != 0){
  80 + AddStudentDto addStudentDto = new AddStudentDto();
  81 + addStudentDto.setAppId(0);
  82 + addStudentDto.setUserId("");
  83 + addStudentDto.setSchoolId(hxyId);
  84 + addStudentDto.setXml(initAddStudentXML(student.getName(),classId,gradeId,student.getAccount(),student.getUserId()));
  85 + yxyService.addStudent(addStudentDto);
  86 + logger.info("操作结果:"+addStudentDto.getErr());
  87 + }
  88 + }catch (Exception e){
  89 + logger.info("操作结果失败:"+e.toString());
  90 + }
  91 + }
  92 + if(student.getType() == 2){
  93 + //修改
  94 + try{
  95 + String className = yxyService.getDeptName(student.getClassId());
  96 + String gradeName = yxyService.getSuperDeptName(student.getClassId());
  97 + int gradeId = yxyService.getGradeId(hxyId,gradeName);
  98 + int classId = yxyService.getClassId(hxyId,className);
  99 + if(gradeId != 0 && classId != 0){
  100 + EditStudentDto editStudentDto = new EditStudentDto();
  101 + editStudentDto.setAppId(0);
  102 + editStudentDto.setUserId("");
  103 + editStudentDto.setParentId(0);
  104 + editStudentDto.setParentUserId("");
  105 + List<StudentView> list = yxyService.getStudentView(classId,student.getName());
  106 + if(list != null && list.size() == 1){
  107 + editStudentDto.setStudentId(list.get(0).getStudentId());
  108 + editStudentDto.setStudentUserId(list.get(0).getUserId());
  109 + editStudentDto.setXml(initEditStudentXML(student.getName(),classId,gradeId,student.getUserId()));
  110 + yxyService.editStudent(editStudentDto);
  111 + logger.info("操作结果:"+editStudentDto.getErr());
  112 + }else {
  113 + throw new Exception("同一个班级同一姓名返回数据两条");
  114 + }
  115 +
  116 + }
  117 + }catch (Exception e){
  118 + logger.info("操作结果失败:"+e.toString());
  119 + }
  120 + }
  121 + if(student.getType() == 3){
  122 + //删除 暂不操作
  123 + }
  124 + }
  125 + logger.info("教师同步");
  126 + for(YxyTeacher teacher : teacherList){
  127 + logger.info(teacher.toString());
  128 + if(teacher.getType() == 0){
  129 + //新增
  130 + try{
  131 + AddTeacherDto addTeacherDto = new AddTeacherDto();
  132 + addTeacherDto.setAppId(0);
  133 + addTeacherDto.setUserId("");
  134 + addTeacherDto.setSchoolId(hxyId);
  135 + addTeacherDto.setXml(initAddTeacherXML(teacher.getName(),teacher.getAccount()));
  136 + yxyService.addTeacher(addTeacherDto);
  137 + logger.info("操作结果:"+addTeacherDto.getErr());
  138 + }catch (Exception e){
  139 + logger.info("操作结果失败:"+e.toString());
  140 + }
  141 + }
  142 + if(teacher.getType() == 2){
  143 + //修改
  144 + try{
  145 + EditTeacherDto editTeacherDto = new EditTeacherDto();
  146 + editTeacherDto.setAppId(0);
  147 + editTeacherDto.setUserId("");
  148 + List<TeacherView> list = yxyService.getTeacherView(hxyId,teacher.getName());
  149 + if(list != null && list.size() == 1){
  150 + editTeacherDto.setXml(initEditTeacherXML(teacher.getName(),teacher.getAccount(),hxyId,list.get(0).getTeacherId()));
  151 + yxyService.editTeacher(editTeacherDto);
  152 + logger.info("操作结果:"+editTeacherDto.getErr());
  153 + }else {
  154 + throw new Exception("同一个班级同一姓名返回数据两条");
  155 + }
  156 +
  157 + }catch (Exception e){
  158 + logger.info("操作结果失败:"+e.toString());
  159 + }
  160 + }
  161 + if(teacher.getType() == 3){
  162 + //删除 暂不操作
  163 + }
  164 + }
  165 + }
  166 +
  167 + private String initAddStudentXML(String name , int classId , int gradeId , String phone , String userId){
  168 + String xml = "<region>" +
  169 + "<row>" +
  170 + "<name>"+name+"</name>" +
  171 + "<studentcode>"+userId+"</studentcode>" +
  172 + "<schoolyear></schoolyear>" +
  173 + "<student_num></student_num>" +
  174 + "<eduid></eduid>" +
  175 + "<nstudentcode></nstudentcode>" +
  176 + "<examid></examid>" +
  177 + "<period></period>" +
  178 + "<student_type></student_type>" +
  179 + "<studytype></studytype>" +
  180 + "<gender></gender>" +
  181 + "<class_id>"+classId+"</class_id>" +
  182 + "<gradeid>"+gradeId+"</gradeid>" +
  183 + "<parent_name></parent_name>" +
  184 + "<mobile>"+phone+"</mobile>" +
  185 + "<parent_gender></parent_gender>" +
  186 + "<relation_type></relation_type>" +
  187 + "<isguardian></isguardian>" +
  188 + "<islive></islive>" +
  189 + "<native></native>" +
  190 + "<ParentMobile></ParentMobile>" +
  191 + "<RelationType></RelationType>" +
  192 + "<ReceivePhone></ReceivePhone>" +
  193 + "<smobile></smobile>" +
  194 + "</row>" +
  195 + "</region>" ;
  196 + return xml ;
  197 + }
  198 +
  199 + private String initEditStudentXML(String name , int classId , int gradeId , String userId){
  200 + String xml = "<region>" +
  201 + "<row>" +
  202 + "<name>"+name+"</name>" +
  203 + "<studentcode>"+userId+"</studentcode>" +
  204 + "<schoolyear></schoolyear>" +
  205 + "<student_num></student_num>" +
  206 + "<eduid></eduid>" +
  207 + "<nstudentcode></nstudentcode>" +
  208 + "<examid></examid>" +
  209 + "<period></period>" +
  210 + "<student_type></student_type>" +
  211 + "<studytype></studytype>" +
  212 + "<gender></gender>" +
  213 + "<class_id>"+classId+"</class_id>" +
  214 + "<gradeid>"+gradeId+"</gradeid>" +
  215 + "<parent_name></parent_name>" +
  216 + "<mobile></mobile>" +
  217 + "<parent_gender></parent_gender>" +
  218 + "<relation_type></relation_type>" +
  219 + "<isguardian></isguardian>" +
  220 + "<islive></islive>" +
  221 + "<native></native>" +
  222 + "</row>" +
  223 + "</region>" ;
  224 + return xml ;
  225 + }
  226 +
  227 + private String initAddTeacherXML(String name, String phone){
  228 + String xml = "<region>" +
  229 + "<row>" +
  230 + "<name>"+name+"</name>" +
  231 + "<id_card></id_card>" +
  232 + "<pass></pass>" +
  233 + "<face></face>" +
  234 + "<sex></sex>" +
  235 + "<birthday></birthday>" +
  236 + "<address></address>" +
  237 + "<email></email>" +
  238 + "<mobile>"+phone+"</mobile>" +
  239 + "<num></num>" +
  240 + "<native></native>" +
  241 + "<nation></nation> " +
  242 + "<polityface></polityface>" +
  243 + "<lengthyear></lengthyear>" +
  244 + "<nationality></nationality>" +
  245 + "</row>" +
  246 + "</region>";
  247 + return xml ;
  248 + }
  249 +
  250 + private String initEditTeacherXML(String name , String phone , int schoolId , int teacherId){
  251 + String xml = "<region>" +
  252 + "<school_id>"+schoolId+"</school_id>" +
  253 + "<user_id></user_id>" +
  254 + "<name>"+name+"</name>" +
  255 + "<id_card></id_card>" +
  256 + "<pass></pass>" +
  257 + "<face></face>" +
  258 + "<sex></sex>" +
  259 + "<birthday></birthday>" +
  260 + "<address></address>" +
  261 + "<email></email>" +
  262 + "<mobile>"+phone+"</mobile>" +
  263 + "<teacher_id>"+teacherId+"</teacher_id>" +
  264 + "<num></num>" +
  265 + "<native></native>" +
  266 + "<nation></nation> " +
  267 + "<polityface></polityface>" +
  268 + "<lengthyear></lengthyear>" +
  269 + "<nationality></nationality>" +
  270 + "</region>";
  271 + return xml ;
  272 + }
  273 +
  274 + private List<YxyStudent> syncStudent(String schoolId){
  275 + List<YxyStudent> students = new ArrayList<>();
  276 + try{
  277 + List list = new ArrayList();
  278 + list.add(SI);
  279 + list.add(getPassword(SI_CODE));
  280 + list.add(schoolId);
  281 + String wsdl =getAddStudent ;
  282 + String ns = nameSpace;
  283 + String method = getAddStudent_method;
  284 + JSONArray jsonArray = getMessage(wsdl, ns, method, list);
  285 + if(jsonArray != null){
  286 + for(int i = 0 ; i < jsonArray.size() ; i++){
  287 + JSONObject object = (JSONObject) jsonArray.get(i) ;
  288 + YxyStudent student = new YxyStudent();
  289 + try{
  290 + student.setClassId(object.get("classID").toString());
  291 + student.setAccount(object.get("account").toString());
  292 + student.setName(object.get("name").toString());
  293 + student.setUserId(object.get("userID").toString());
  294 + student.setType(Integer.valueOf(object.get("type").toString()));
  295 + }catch (Exception e){
  296 + }
  297 + try{
  298 + student.setCardID(object.get("cardID").toString());
  299 + }catch (Exception e){
  300 + }
  301 + try{
  302 + student.setCardID2(object.get("cardID2").toString());
  303 + }catch (Exception e){
  304 + }
  305 + try{
  306 + student.setCardID3(object.get("cardID3").toString());
  307 + }catch (Exception e){
  308 + }
  309 + students.add(student);
  310 + }
  311 + }
  312 + }catch (Exception e){
  313 + logger.info(e.toString());
  314 + logger.info("学校ID为:"+schoolId + "学生数据没返回");
  315 + }
  316 + return students;
  317 + }
  318 +
  319 + private List<YxyTeacher> syncTeacher(String schoolId){
  320 + List<YxyTeacher> teachers = new ArrayList<>();
  321 + try{
  322 + List list = new ArrayList();
  323 + list.add(SI);
  324 + list.add(getPassword(SI_CODE));
  325 + list.add(schoolId);
  326 + String wsdl =getAddTeacher ;
  327 + String ns = nameSpace;
  328 + String method = getAddTeacher_method;
  329 + JSONArray jsonArray = getMessage(wsdl, ns, method, list);
  330 + if(jsonArray != null){
  331 + for(int i = 0 ; i < jsonArray.size() ; i++){
  332 + JSONObject object = (JSONObject) jsonArray.get(i) ;
  333 + YxyTeacher teacher = new YxyTeacher();
  334 + try {
  335 + teacher.setDeptId(object.get("classID").toString());
  336 + teacher.setAccount(object.get("account").toString());
  337 + teacher.setName(object.get("name").toString());
  338 + teacher.setUserId(object.get("userID").toString());
  339 + teacher.setType(Integer.valueOf(object.get("type").toString()));
  340 +
  341 + }catch (Exception e){
  342 + }
  343 + teachers.add(teacher);
  344 + }
  345 + }
  346 + }catch (Exception e){
  347 + logger.info(e.toString());
  348 + logger.info("学校ID为:"+schoolId + "老师数据没返回");
  349 + }
  350 + return teachers;
  351 + }
  352 +
  353 + private JSONArray getMessage(String wsdl, String ns, String method, List<String> list){
  354 + try {
  355 + String resultXml = HttpClientUtils.invoiceWebService(wsdl,ns,method,list);
  356 + if (StringUtils.isNotBlank(resultXml)) {
  357 + resultXml = resultXml.replaceAll("&lt;", "<");
  358 + resultXml = resultXml.replaceAll("&gt;", ">");
  359 + int begin = resultXml.indexOf("<JXT");
  360 + int end = resultXml.indexOf("</JXT");
  361 + String str = resultXml.substring(begin, end + 6);
  362 + JSONObject json = Xml2JsonUtils.xml2Json(str);
  363 + if(str.split("resultInfo").length <= 3){
  364 + if (json != null) {
  365 + JSONObject user = (JSONObject) json.get("resultInfo");
  366 + JSONArray jsonArray = new JSONArray();
  367 + jsonArray.add(user);
  368 + return jsonArray;
  369 + }
  370 + }else {
  371 + if (json != null) {
  372 + return (JSONArray) json.get("resultInfo");
  373 + }
  374 + }
  375 + }
  376 + }catch (Exception e){
  377 + logger.info("获取信息报错"+e.getMessage());
  378 + }
  379 + return null ;
  380 + }
  381 +
  382 + private String getPassword(int si){
  383 + int date = Integer.valueOf(DateUtils.date2String(new Date(),DateUtils.format5));
  384 + String pwd = String.valueOf(si&date) ;
  385 + while (pwd.length() < 6){
  386 + pwd = "0" + pwd ;
  387 + }
  388 + pwd = pwd.substring(pwd.length() - 6);
  389 + return EncodeByMD5(pwd);
  390 + }
  391 +
  392 + private String EncodeByMD5(String str) {
  393 + try {
  394 + // 生成一个MD5加密计算摘要
  395 + MessageDigest md = MessageDigest.getInstance("MD5");
  396 + // 计算md5函数
  397 + md.update(str.getBytes("UTF-8"));
  398 + // digest()最后确定返回md5 hash值,返回值为8为字符串。因为md5 hash值是16位的hex值,实际上就是8位的字符
  399 + // BigInteger函数则将8位的字符串转换成16位hex值,用字符串来表示;得到字符串形式的hash值
  400 + String md5 = new BigInteger(1, md.digest()).toString(16);
  401 + //BigInteger会把0省略掉,需补全至32位
  402 + return fillMD5(md5);
  403 + } catch (Exception e) {
  404 + throw new RuntimeException("MD5加密错误:" + e.getMessage(), e);
  405 + }
  406 + }
  407 +
  408 + private String fillMD5(String md5){
  409 + //如果不够32位则回调自身补零,最后返回32位长度的签名
  410 + return md5.length()==32?md5:fillMD5("0"+md5);
  411 + }
  412 +
  413 +}
0 414 \ No newline at end of file
... ...
cloud/quartz/src/main/java/com/sincere/quartz/third/yixueyun/YXYWriteService.java
... ... @@ -71,7 +71,7 @@ public class YXYWriteService {
71 71 }
72 72 }
73 73  
74   - private void syncUser(SyncSchoolDto school, List<SyncUserDto> userList) {
  74 + public void syncUser(SyncSchoolDto school, List<SyncUserDto> userList) {
75 75 List<SyncUserDto> addStudentList = new ArrayList<>();
76 76 List<SyncUserDto> updateStudentList = new ArrayList<>();
77 77 List<SyncUserDto> deleteStudentList = new ArrayList<>();
... ...
cloud/quartz/src/main/resources/mapper/YxyMapper.xml
... ... @@ -2,6 +2,78 @@
2 2 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
3 3 <mapper namespace="com.sincere.quartz.mapper.YxyMapper">
4 4  
  5 + <select id="getTeacherView" resultType="com.sincere.quartz.dto.TeacherView">
  6 + select teacher_id as teacherId , user_id as userId , name
  7 + from SZ_V_School_Teacher where school_id = #{schoolId} and name = #{name}
  8 + </select>
  9 +
  10 + <select id="getStudentView" resultType="com.sincere.quartz.dto.StudentView">
  11 + select student_id as studentId , user_id as userId , name
  12 + from SZ_V_School_Student
  13 + where class_id = #{classId} and name = #{name}
  14 + </select>
  15 +
  16 + <select id="getGradeId" resultType="java.lang.Integer">
  17 + select id from SZ_Grade where status=1 and schoolid=#{schoolId} and grade = #{grade}
  18 + </select>
  19 +
  20 + <select id="getClassId" resultType="java.lang.Integer">
  21 + select class_id from SZ_Class where is_finish=0 and state=1 and school_id = #{schoolId} and class_name = #{className}
  22 + </select>
  23 +
  24 + <select id="getDeptName" parameterType="java.lang.String" resultType="java.lang.String">
  25 + select deptName from Agency where deptID = #{deptId}
  26 + </select>
  27 +
  28 + <select id="getSuperDeptName" parameterType="java.lang.String" resultType="java.lang.String">
  29 + select deptName from Agency where deptID =
  30 + (select superDeptID from Agency where deptID = #{deptId})
  31 + </select>
  32 +
  33 + <resultMap id="AddStudentMap" type="com.sincere.quartz.dto.AddStudentDto">
  34 + <result column="Err" property="err" jdbcType="VARCHAR" />
  35 + </resultMap>
  36 + <insert id="addStudent" parameterType="com.sincere.quartz.dto.AddStudentDto" statementType="CALLABLE">
  37 + {call Student_Add(
  38 + #{appId,mode=IN} , #{userId,mode=IN} , #{schoolId,mode=IN}, #{xml,mode=IN},
  39 + #{Err,mode=OUT,jdbcType=VARCHAR,resultMap=AddStudentMap}
  40 + )}
  41 + </insert>
  42 +
  43 + <resultMap id="EditStudentMap" type="com.sincere.quartz.dto.EditStudentDto">
  44 + <result column="Err" property="err" jdbcType="VARCHAR" />
  45 + </resultMap>
  46 + <insert id="editStudent" parameterType="com.sincere.quartz.dto.EditStudentDto" statementType="CALLABLE">
  47 + {call Student_Edit(
  48 + #{appId,mode=IN} , #{userId,mode=IN} , #{studentUserId,mode=IN},#{parentUserId,mode=IN},
  49 + #{studentId,mode=IN},#{parentId,mode=IN},#{xml,mode=IN},
  50 + #{Err,mode=OUT,jdbcType=VARCHAR,resultMap=EditStudentMap}
  51 + )}
  52 + </insert>
  53 +
  54 + <resultMap id="AddTeacherMap" type="com.sincere.quartz.dto.AddTeacherDto">
  55 + <result column="Err" property="err" jdbcType="VARCHAR" />
  56 + <result column="YongHuId" property="YongHuId" jdbcType="VARCHAR" />
  57 + <result column="LaoShiId" property="LaoShiId" jdbcType="VARCHAR" />
  58 + </resultMap>
  59 + <insert id="addTeacher" parameterType="com.sincere.quartz.dto.AddTeacherDto" statementType="CALLABLE">
  60 + {call Teachers_Add(
  61 + #{appId,mode=IN} , #{userId,mode=IN} , #{schoolId,mode=IN}, #{xml,mode=IN},
  62 + #{Err,mode=OUT,jdbcType=VARCHAR,resultMap=AddTeacherMap},
  63 + #{YongHuId,mode=OUT,jdbcType=VARCHAR,resultMap=AddTeacherMap},
  64 + #{LaoShiId,mode=OUT,jdbcType=VARCHAR,resultMap=AddTeacherMap}
  65 + )}
  66 + </insert>
  67 +
  68 + <resultMap id="EditTeacherMap" type="com.sincere.quartz.dto.EditTeacherDto">
  69 + <result column="Err" property="err" jdbcType="VARCHAR" />
  70 + </resultMap>
  71 + <insert id="editTeacher" parameterType="com.sincere.quartz.dto.EditTeacherDto" statementType="CALLABLE">
  72 + {call Teacher_Edit(
  73 + #{appId,mode=IN} , #{userId,mode=IN} , #{xml,mode=IN},
  74 + #{Err,mode=OUT,jdbcType=VARCHAR,resultMap=EditTeacherMap}
  75 + )}
  76 + </insert>
5 77  
6 78 <delete id="deleteWeekBefore" >
7 79 delete Agency where DATEDIFF(d,intime,GETDATE())>7;
... ... @@ -17,10 +89,18 @@
17 89 update Teacher set state = 0 where DATEDIFF(n , intime, getdate()) > 240
18 90 </update>
19 91  
  92 + <update id="updateTeacherBySchool" >
  93 + update Teacher set state = 0 where deptID like '%${deptId}%'
  94 + </update>
  95 +
20 96 <update id="updateStudent">
21 97 update Student set state = 0 where DATEDIFF(n , intime, getdate()) > 240
22 98 </update>
23 99  
  100 + <update id="updateStudentBySchool">
  101 + update Student set state = 0 where classID like '%${classId}%'
  102 + </update>
  103 +
24 104 <select id="selectCount" parameterType="java.lang.String" resultType="java.lang.Integer">
25 105 select count(0) from Student where intime > #{date}
26 106 </select>
... ...
cloud/weigeng/src/main/java/com/sincere/weigeng/Swagger2.java
... ... @@ -1,39 +0,0 @@
1   -package com.sincere.weigeng;
2   -
3   -import io.swagger.annotations.ApiOperation;
4   -import org.springframework.context.annotation.Bean;
5   -import org.springframework.context.annotation.Configuration;
6   -import springfox.documentation.builders.ApiInfoBuilder;
7   -import springfox.documentation.builders.PathSelectors;
8   -import springfox.documentation.builders.RequestHandlerSelectors;
9   -import springfox.documentation.service.ApiInfo;
10   -import springfox.documentation.spi.DocumentationType;
11   -import springfox.documentation.spring.web.plugins.Docket;
12   -import springfox.documentation.swagger2.annotations.EnableSwagger2;
13   -
14   -@EnableSwagger2
15   -@Configuration //让Spring来加载该类配置
16   -public class Swagger2 {
17   -
18   - @Bean
19   - public Docket createRestApi() {
20   - return new Docket(DocumentationType.SWAGGER_2)
21   - .apiInfo(apiInfo())
22   - .enableUrlTemplating(true)
23   - .select()
24   - // 扫描所有有注解的api,用这种方式更灵活
25   - .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
26   - .paths(PathSelectors.any())
27   - .build();
28   -
29   - }
30   -
31   - private ApiInfo apiInfo() {
32   - return new ApiInfoBuilder()
33   - .title("Spring Boot中使用Swagger2构建RESTful APIs")
34   - .description("接口文档")
35   - .termsOfServiceUrl("")
36   - .version("1.0")
37   - .build();
38   - }
39   -}