Commit d80bdd42836c41f360ed518e508a618e81067060

Authored by 陶汉栋
2 parents acd712a6 70c1b5df
Exists in master

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	cloud/quartz/src/main/java/com/sincere/quartz/Swagger2.java
#	cloud/quartz/src/main/java/com/sincere/quartz/job/BindPushJob.java
#	cloud/quartz/src/main/java/com/sincere/quartz/job/KQJob.java
#	cloud/quartz/src/main/java/com/sincere/quartz/job/SyncJob.java
Showing 29 changed files with 1581 additions and 477 deletions   Show diff stats
cloud/quartz/pom.xml
@@ -30,6 +30,11 @@ @@ -30,6 +30,11 @@
30 </dependency> 30 </dependency>
31 <dependency> 31 <dependency>
32 <groupId>org.springframework.boot</groupId> 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 <artifactId>spring-boot-starter-test</artifactId> 38 <artifactId>spring-boot-starter-test</artifactId>
34 <scope>test</scope> 39 <scope>test</scope>
35 </dependency> 40 </dependency>
cloud/quartz/src/main/java/com/sincere/quartz/QuartzApplication.java
@@ -15,12 +15,12 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; @@ -15,12 +15,12 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
15 * @version 1.0 15 * @version 1.0
16 * @date 2019/11/27 0027 14:24 16 * @date 2019/11/27 0027 14:24
17 */ 17 */
  18 +@EnableEurekaClient
18 @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) 19 @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
19 @EnableTransactionManagement(order = 2) //设置事务执行顺序(需要在切换数据源之后,否则只走主库) 20 @EnableTransactionManagement(order = 2) //设置事务执行顺序(需要在切换数据源之后,否则只走主库)
20 @EnableCaching 21 @EnableCaching
21 @EnableScheduling 22 @EnableScheduling
22 @EnableFeignClients(basePackages = "com.sincere.quartz.feign") 23 @EnableFeignClients(basePackages = "com.sincere.quartz.feign")
23 -@EnableEurekaClient  
24 @MapperScan("com.sincere.quartz.mapper") 24 @MapperScan("com.sincere.quartz.mapper")
25 public class QuartzApplication { 25 public class QuartzApplication {
26 26
cloud/quartz/src/main/java/com/sincere/quartz/Swagger2.java
@@ -3,6 +3,7 @@ package com.sincere.quartz; @@ -3,6 +3,7 @@ package com.sincere.quartz;
3 import org.springframework.context.annotation.Bean; 3 import org.springframework.context.annotation.Bean;
4 import org.springframework.context.annotation.Configuration; 4 import org.springframework.context.annotation.Configuration;
5 import springfox.documentation.builders.ApiInfoBuilder; 5 import springfox.documentation.builders.ApiInfoBuilder;
  6 +import springfox.documentation.builders.ParameterBuilder;
6 import springfox.documentation.builders.PathSelectors; 7 import springfox.documentation.builders.PathSelectors;
7 import springfox.documentation.builders.RequestHandlerSelectors; 8 import springfox.documentation.builders.RequestHandlerSelectors;
8 import springfox.documentation.service.ApiInfo; 9 import springfox.documentation.service.ApiInfo;
@@ -10,27 +11,29 @@ import springfox.documentation.spi.DocumentationType; @@ -10,27 +11,29 @@ import springfox.documentation.spi.DocumentationType;
10 import springfox.documentation.spring.web.plugins.Docket; 11 import springfox.documentation.spring.web.plugins.Docket;
11 import springfox.documentation.swagger2.annotations.EnableSwagger2; 12 import springfox.documentation.swagger2.annotations.EnableSwagger2;
12 13
13 -@Configuration  
14 @EnableSwagger2 14 @EnableSwagger2
  15 +@Configuration //让Spring来加载该类配置
15 public class Swagger2 { 16 public class Swagger2 {
16 17
17 @Bean 18 @Bean
18 public Docket createRestApi() { 19 public Docket createRestApi() {
19 return new Docket(DocumentationType.SWAGGER_2) 20 return new Docket(DocumentationType.SWAGGER_2)
20 .apiInfo(apiInfo()) 21 .apiInfo(apiInfo())
  22 + .enableUrlTemplating(false)
21 .select() 23 .select()
22 - .apis(RequestHandlerSelectors.basePackage("com.sincere.quartz.control")) 24 + // 扫描所有有注解的api,用这种方式更灵活
  25 + .apis(RequestHandlerSelectors.basePackage("com.sincere.quartz.controller"))
23 .paths(PathSelectors.any()) 26 .paths(PathSelectors.any())
24 .build(); 27 .build();
  28 +
25 } 29 }
26 30
27 private ApiInfo apiInfo() { 31 private ApiInfo apiInfo() {
28 return new ApiInfoBuilder() 32 return new ApiInfoBuilder()
29 - .title("大华人脸接口")  
30 - .description("") 33 + .title("Spring Boot中使用Swagger2构建RESTful APIs")
  34 + .description("接口文档")
31 .termsOfServiceUrl("") 35 .termsOfServiceUrl("")
32 .version("1.0") 36 .version("1.0")
33 .build(); 37 .build();
34 } 38 }
35 -  
36 } 39 }
cloud/quartz/src/main/java/com/sincere/quartz/controller/YxyController.java 0 → 100644
@@ -0,0 +1,69 @@ @@ -0,0 +1,69 @@
  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 +
  41 + @ApiOperation(value = "syncTeacher")
  42 + @RequestMapping(value = "syncTeacher",method = RequestMethod.GET)
  43 + public BaseDto syncTeacher(String schoolId){
  44 + yxyService.updateTeacherBySchool(schoolId);
  45 + readService.syncTeacher(schoolId);
  46 + return new BaseDto() ;
  47 + }
  48 +
  49 + @ApiOperation(value = "syncStudent")
  50 + @RequestMapping(value = "syncStudent",method = RequestMethod.GET)
  51 + public BaseDto syncStudent(String schoolId){
  52 + yxyService.updateStudentBySchool(schoolId);
  53 + readService.syncStudent(schoolId);
  54 + return new BaseDto() ;
  55 + }
  56 +
  57 + @ApiOperation(value = "syncWrite")
  58 + @RequestMapping(value = "syncWrite",method = RequestMethod.GET)
  59 + public BaseDto syncWrite(int hxyId){
  60 + List<SyncSchoolDto> schoolList = scFeign.selectSyncSchool();
  61 + for (SyncSchoolDto school : schoolList) {
  62 + if(school.getSchoolId() == hxyId){
  63 + List<SyncUserDto> userList = scFeign.selectUser(school.getSchoolId());
  64 + writeService.syncUser(school, userList);
  65 + }
  66 + }
  67 + return new BaseDto();
  68 + }
  69 +}
cloud/quartz/src/main/java/com/sincere/quartz/datasource/DataSourceConfig.java
@@ -12,45 +12,53 @@ import java.util.Map; @@ -12,45 +12,53 @@ import java.util.Map;
12 12
13 /** 13 /**
14 * 数据源配置 14 * 数据源配置
  15 + *
15 */ 16 */
16 @Configuration 17 @Configuration
17 public class DataSourceConfig { 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,24 +2,26 @@ package com.sincere.quartz.datasource;
2 2
3 public enum DataSourceType { 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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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
@@ -21,7 +21,6 @@ @@ -21,7 +21,6 @@
21 // 21 //
22 ///** 22 ///**
23 // * 用户注册激活提醒 23 // * 用户注册激活提醒
24 -// *  
25 // * @author chen 24 // * @author chen
26 // * @version 1.0 25 // * @version 1.0
27 // * @date 2019/12/10 0010 8:31 26 // * @date 2019/12/10 0010 8:31
@@ -38,67 +37,67 @@ @@ -38,67 +37,67 @@
38 // @Autowired 37 // @Autowired
39 // SmsService smsService; 38 // SmsService smsService;
40 // 39 //
41 -// private static Map<String, String> intervalDaysMap = new HashMap<>(); //redis 持久化 替换 可避免重启导致间隔的错误 40 +// private static Map<String , String> intervalDaysMap = new HashMap<>(); //redis 持久化 替换 可避免重启导致间隔的错误
42 // 41 //
43 // @Scheduled(cron = "0 0-59 * * * ? ") 42 // @Scheduled(cron = "0 0-59 * * * ? ")
44 -// public void bindPush() { 43 +// public void bindPush(){
45 // Date nowDate = new Date(); 44 // Date nowDate = new Date();
46 // List<BindPushDto> schoolList = scFeign.selectBindPushSchool(); 45 // 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)) { 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)){
51 // //下发推送 50 // //下发推送
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 -// } 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 +// }
59 // } 58 // }
60 // } 59 // }
61 // } 60 // }
62 // } 61 // }
63 // 62 //
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)); 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));
67 // //未关注 66 // //未关注
68 // List<ParentDto> unFollowList = scFeign.selectNotFollow(bindPushDto.getSchoolId()); 67 // List<ParentDto> unFollowList = scFeign.selectNotFollow(bindPushDto.getSchoolId());
69 -// logger.info(bindPushDto.getSchoolName() + "未关注人数" + unFollowList.size());  
70 -// for (ParentDto parentDto : unFollowList) {  
71 -// sendMessage(parentDto, bindPushDto.getMsg()); 68 +// logger.info(bindPushDto.getSchoolName()+"未关注人数"+unFollowList.size());
  69 +// for(ParentDto parentDto : unFollowList){
  70 +// sendMessage(parentDto,bindPushDto.getMsg());
72 // } 71 // }
73 // //未绑定 72 // //未绑定
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()); 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());
78 // } 77 // }
79 // } 78 // }
80 // } 79 // }
81 // 80 //
82 -// private void sendMessage(ParentDto parentDto, String message) { 81 +// private void sendMessage(ParentDto parentDto , String message){
83 // //手机号为空 82 // //手机号为空
84 -// if (StringUtils.isNotBlank(parentDto.getMobile())) { 83 +// if(StringUtils.isNotBlank(parentDto.getMobile())){
85 // String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format); 84 // String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format);
86 // ShortMsg shortMsg = new ShortMsg(); 85 // ShortMsg shortMsg = new ShortMsg();
87 -// shortMsg.setTableName("smsNew" + tableSuffix); 86 +// shortMsg.setTableName("smsNew"+tableSuffix);
88 // shortMsg.setSchoolId(parentDto.getSchoolId()); 87 // shortMsg.setSchoolId(parentDto.getSchoolId());
89 // shortMsg.setMobile(parentDto.getMobile()); 88 // shortMsg.setMobile(parentDto.getMobile());
90 // shortMsg.setMsg(message); 89 // shortMsg.setMsg(message);
91 // smsService.insertSMS(shortMsg); 90 // smsService.insertSMS(shortMsg);
92 -// logger.info("----学校Id---" + parentDto.getSchoolId() + "----手机号----" + parentDto.getMobile() + "---" + message); 91 +// logger.info("----学校Id---"+parentDto.getSchoolId() + "----手机号----"+parentDto.getMobile()+"---"+message);
93 // } 92 // }
94 // } 93 // }
95 // 94 //
96 // // 0是企业号,1是钉钉 95 // // 0是企业号,1是钉钉
97 -// private int getThirdType(int type) {  
98 -// if (type == 0) {  
99 -// return PushTypeEnums.QIYEHAO.getType();  
100 -// } else {  
101 -// return PushTypeEnums.DING.getType(); 96 +// private int getThirdType(int type){
  97 +// if(type == 0){
  98 +// return PushTypeEnums.QIYEHAO.getType() ;
  99 +// }else {
  100 +// return PushTypeEnums.DING.getType() ;
102 // } 101 // }
103 // } 102 // }
104 // 103 //
cloud/quartz/src/main/java/com/sincere/quartz/job/KQJob.java
@@ -27,7 +27,6 @@ @@ -27,7 +27,6 @@
27 ///** 27 ///**
28 // * 考勤任务推送调用 28 // * 考勤任务推送调用
29 // * 主要推送盯盯以及企业号 29 // * 主要推送盯盯以及企业号
30 -// *  
31 // * @author chen 30 // * @author chen
32 // * @version 1.0 31 // * @version 1.0
33 // * @date 2019/11/27 0027 17:05 32 // * @date 2019/11/27 0027 17:05
@@ -38,119 +37,119 @@ @@ -38,119 +37,119 @@
38 // private Logger logger = LoggerFactory.getLogger(KQJob.class); 37 // private Logger logger = LoggerFactory.getLogger(KQJob.class);
39 // 38 //
40 // @Autowired 39 // @Autowired
41 -// ScFeign scFeign; 40 +// ScFeign scFeign ;
42 // 41 //
43 // @Autowired 42 // @Autowired
44 // SmsService smsService; 43 // SmsService smsService;
45 // 44 //
46 // @Autowired 45 // @Autowired
47 -// ManagerService managerService; 46 +// ManagerService managerService ;
48 // 47 //
49 // private static String iotUrl = "http://60.190.202.57:8035"; 48 // private static String iotUrl = "http://60.190.202.57:8035";
50 // 49 //
51 -// private static String date;  
52 -// private static Map<String, String> map = new HashMap<>(); //学校 考勤推送map 50 +// private static String date ;
  51 +// private static Map<String , String> map = new HashMap<>(); //学校 考勤推送map
53 // 52 //
54 -// private static String alarmDate;  
55 -// private static Map<String, String> alarmMap = new HashMap<>(); //考勤告警推送map  
56 -// private static Map<String, BigDecimal> templateMap = new HashMap<>(); // 考勤比例 53 +// private static String alarmDate ;
  54 +// private static Map<String , String> alarmMap = new HashMap<>(); //考勤告警推送map
  55 +// private static Map<String , BigDecimal> templateMap = new HashMap<>(); // 考勤比例
57 // 56 //
58 -// private static List<String> opexList;  
59 -// private static String integration; 57 +// private static List<String> opexList ;
  58 +// private static String integration ;
60 // 59 //
61 -// static { 60 +// static{
62 // opexList = new ArrayList<>(); 61 // opexList = new ArrayList<>();
63 // opexList.add("15857566147"); //王汉栋 62 // opexList.add("15857566147"); //王汉栋
64 // opexList.add("13858485977"); //王楠彬 63 // opexList.add("13858485977"); //王楠彬
65 // 64 //
66 -// integration = "18767117554"; //林炜 65 +// integration = "18767117554" ; //林炜
67 // } 66 // }
68 // 67 //
69 // @Scheduled(cron = "0 0-59 * * * ? ") 68 // @Scheduled(cron = "0 0-59 * * * ? ")
70 // public void kaoQing() { 69 // public void kaoQing() {
71 -// String now = DateUtils.date2String(new Date(), DateUtils.format1);  
72 -// if (StringUtils.isBlank(date)) { 70 +// String now = DateUtils.date2String(new Date(),DateUtils.format1) ;
  71 +// if(StringUtils.isBlank(date)){
73 // initMap(); 72 // initMap();
74 -// date = now; 73 +// date = now ;
75 // } 74 // }
76 -// if (!DateUtils.date2String(new Date(), DateUtils.format1).equals(date)) { 75 +// if(!DateUtils.date2String(new Date(),DateUtils.format1).equals(date)){
77 // initMap(); 76 // initMap();
78 -// date = DateUtils.date2String(new Date(), DateUtils.format1); 77 +// date = DateUtils.date2String(new Date(),DateUtils.format1) ;
79 // } 78 // }
80 // //开始过滤数据 推送 79 // //开始过滤数据 推送
81 // List<String> keyList = new ArrayList<>(); 80 // List<String> keyList = new ArrayList<>();
82 -// for (Map.Entry<String, String> entity : map.entrySet()) { 81 +// for(Map.Entry<String, String> entity : map.entrySet()){
83 // String endTime = entity.getValue().split("_")[1]; 82 // 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) { 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){
86 // String key = entity.getKey(); 85 // String key = entity.getKey();
87 // String[] messageArray = key.split("_"); 86 // String[] messageArray = key.split("_");
88 -// if (messageArray[2].contains(PushTypeEnums.QIYEHAO.getType() + "")) { 87 +// if(messageArray[2].contains(PushTypeEnums.QIYEHAO.getType()+"")){
89 // logger.info("企业号推送:" + messageArray[0] + "__" + messageArray[1]); 88 // logger.info("企业号推送:" + messageArray[0] + "__" + messageArray[1]);
90 -// weChatBatchPush(messageArray[0], Integer.valueOf(messageArray[1]), entity.getValue()); 89 +// weChatBatchPush(messageArray[0],Integer.valueOf(messageArray[1]),entity.getValue());
91 // } 90 // }
92 -// if (messageArray[2].contains(PushTypeEnums.DING.getType() + "")) { 91 +// if(messageArray[2].contains(PushTypeEnums.DING.getType()+"")){
93 // logger.info(("盯盯推送:" + messageArray[0] + "__" + messageArray[1])); 92 // logger.info(("盯盯推送:" + messageArray[0] + "__" + messageArray[1]));
94 -// dingBatchPush(messageArray[0], Integer.valueOf(messageArray[1]), entity.getValue()); 93 +// dingBatchPush(messageArray[0],Integer.valueOf(messageArray[1]),entity.getValue());
95 // } 94 // }
96 // keyList.add(key); 95 // keyList.add(key);
97 // } 96 // }
98 // } 97 // }
99 -// for (String key : keyList) { 98 +// for(String key : keyList){
100 // map.remove(key); 99 // map.remove(key);
101 // } 100 // }
102 // } 101 // }
103 // 102 //
104 // @Scheduled(cron = "0 0-59 * * * ? ") 103 // @Scheduled(cron = "0 0-59 * * * ? ")
105 // public void alarmKaoQing() { 104 // public void alarmKaoQing() {
106 -// String now = DateUtils.date2String(new Date(), DateUtils.format1);  
107 -// if (StringUtils.isBlank(alarmDate)) { 105 +// String now = DateUtils.date2String(new Date(),DateUtils.format1) ;
  106 +// if(StringUtils.isBlank(alarmDate)){
108 // initAlarmMap(); 107 // initAlarmMap();
109 -// alarmDate = now; 108 +// alarmDate = now ;
110 // } 109 // }
111 -// if (!DateUtils.date2String(new Date(), DateUtils.format1).equals(alarmDate)) { 110 +// if(!DateUtils.date2String(new Date(),DateUtils.format1).equals(alarmDate)){
112 // initAlarmMap(); 111 // initAlarmMap();
113 -// alarmDate = DateUtils.date2String(new Date(), DateUtils.format1); 112 +// alarmDate = DateUtils.date2String(new Date(),DateUtils.format1) ;
114 // } 113 // }
115 // //开始过滤数据 推送 114 // //开始过滤数据 推送
116 // List<String> keyList = new ArrayList<>(); 115 // List<String> keyList = new ArrayList<>();
117 -// for (Map.Entry<String, String> entity : alarmMap.entrySet()) { 116 +// for(Map.Entry<String, String> entity : alarmMap.entrySet()){
118 // String endTime = entity.getValue().split("_")[1]; 117 // String endTime = entity.getValue().split("_")[1];
119 -// if (DateUtils.getDateDifference(new Date(), DateUtils.string2Date(now + " " + endTime + ":00", DateUtils.format2), "m") >= 2  
120 -// ) { 118 +// if(DateUtils.getDateDifference(new Date(),DateUtils.string2Date(now+" "+endTime+":00",DateUtils.format2),"m")>=2
  119 +// ){
121 // String key = entity.getKey(); 120 // String key = entity.getKey();
122 // keyList.add(key); 121 // keyList.add(key);
123 // //alarm(entity); //告警 122 // //alarm(entity); //告警
124 // //insertIOT(entity); //iot 123 // //insertIOT(entity); //iot
125 // } 124 // }
126 // } 125 // }
127 -// for (String key : keyList) { 126 +// for(String key : keyList){
128 // map.remove(key); 127 // map.remove(key);
129 // } 128 // }
130 // } 129 // }
131 // 130 //
132 -// private void initAlarmMap() { 131 +// private void initAlarmMap(){
133 // alarmMap = new HashMap<>(); 132 // alarmMap = new HashMap<>();
134 // List<TemplateDto> list = scFeign.getAllTemplateAlarm(); 133 // List<TemplateDto> list = scFeign.getAllTemplateAlarm();
135 // logger.info(("------考勤告警模板------")); 134 // logger.info(("------考勤告警模板------"));
136 -// for (TemplateDto templateDto : list) { 135 +// for(TemplateDto templateDto : list){
137 // String config = templateDto.getConfig(); 136 // String config = templateDto.getConfig();
138 // String[] array = config.split("<Template"); 137 // String[] array = config.split("<Template");
139 -// for (int i = 1; i < array.length; i++) {  
140 -// try { 138 +// for(int i = 1 ; i<array.length ;i++){
  139 +// try{
141 // String msg = array[i]; 140 // 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()); 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());
152 // } 151 // }
153 -// } catch (Exception e) { 152 +// }catch (Exception e){
154 // e.printStackTrace(); 153 // e.printStackTrace();
155 // } 154 // }
156 // } 155 // }
@@ -158,82 +157,82 @@ @@ -158,82 +157,82 @@
158 // } 157 // }
159 // 158 //
160 // //告警推送 159 // //告警推送
161 -// private void alarm(Map.Entry<String, String> entry) {  
162 -// String templateId = entry.getKey().split("_")[0];  
163 -// String schoolId = entry.getKey().split("_")[1]; 160 +// private void alarm(Map.Entry<String,String> entry){
  161 +// String templateId = entry.getKey().split("_")[0] ;
  162 +// String schoolId = entry.getKey().split("_")[1] ;
164 // String id = entry.getValue().split("_")[3]; 163 // String id = entry.getValue().split("_")[3];
165 -// String type = entry.getValue().split("_")[2]; 164 +// String type = entry.getValue().split("_")[2] ;
166 // 165 //
167 -// if (DateUtils.getWeek() == 2 || DateUtils.getWeek() == 5) { 166 +// if(DateUtils.getWeek() == 2 || DateUtils.getWeek() == 5){
168 // //可以相差40% 167 // //可以相差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) { 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) {
173 // alarmPush(Integer.valueOf(schoolId)); 172 // alarmPush(Integer.valueOf(schoolId));
174 // } 173 // }
175 // } 174 // }
176 -// templateMap.put(templateId, percent);  
177 -// } else { 175 +// templateMap.put(templateId,percent);
  176 +// }else {
178 // //相差30% 177 // //相差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 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
182 // || templateMap.get(templateId).subtract(percent).compareTo(new BigDecimal(0.3)) > 0) { 181 // || templateMap.get(templateId).subtract(percent).compareTo(new BigDecimal(0.3)) > 0) {
183 // alarmPush(Integer.valueOf(schoolId)); 182 // alarmPush(Integer.valueOf(schoolId));
184 // } 183 // }
185 // } 184 // }
186 -// templateMap.put(templateId, percent); 185 +// templateMap.put(templateId,percent);
187 // } 186 // }
188 // } 187 // }
189 // 188 //
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]; 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] ;
194 // String id = entry.getValue().split("_")[3]; 193 // 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]; 194 +// String type = entry.getValue().split("_")[2] ;
  195 +// String beginTime = entry.getValue().split("_")[0] ;
  196 +// String endTime = entry.getValue().split("_")[1] ;
198 // 197 //
199 -// List<Integer> list = getIOTCensus(Integer.valueOf(id), templateId, Integer.valueOf(schoolId), Integer.valueOf(type)); 198 +// List<Integer> list = getIOTCensus(Integer.valueOf(id),templateId,Integer.valueOf(schoolId),Integer.valueOf(type)) ;
200 // JSONObject object = new JSONObject(); 199 // 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()); 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());
212 // } 211 // }
213 // 212 //
214 // //初始化要推送的模板 213 // //初始化要推送的模板
215 -// private void initMap() { 214 +// private void initMap(){
216 // map = new HashMap<>(); 215 // map = new HashMap<>();
217 // List<TemplateDto> list = scFeign.getAllTemplate(); 216 // List<TemplateDto> list = scFeign.getAllTemplate();
218 // logger.info(("------需要推送的考勤模板------")); 217 // logger.info(("------需要推送的考勤模板------"));
219 -// for (TemplateDto templateDto : list) { 218 +// for(TemplateDto templateDto : list){
220 // String config = templateDto.getConfig(); 219 // String config = templateDto.getConfig();
221 // String[] array = config.split("<Template"); 220 // String[] array = config.split("<Template");
222 -// for (int i = 1; i < array.length; i++) {  
223 -// try { 221 +// for(int i = 1 ; i<array.length ;i++){
  222 +// try{
224 // String msg = array[i]; 223 // 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()); 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());
235 // } 234 // }
236 -// } catch (Exception e) { 235 +// }catch (Exception e){
237 // e.printStackTrace(); 236 // e.printStackTrace();
238 // } 237 // }
239 // } 238 // }
@@ -241,76 +240,76 @@ @@ -241,76 +240,76 @@
241 // } 240 // }
242 // 241 //
243 // //盯盯批量推送 242 // //盯盯批量推送
244 -// private void dingBatchPush(String templateId, int schoolId, String key) { 243 +// private void dingBatchPush(String templateId , int schoolId , String key){
245 // String[] times = key.split("_"); 244 // String[] times = key.split("_");
246 -// AppDto appDto = scFeign.getApp(schoolId, 1);  
247 -// if (Integer.valueOf(times[2]) < 7) { 245 +// AppDto appDto = scFeign.getApp(schoolId,1);
  246 +// if(Integer.valueOf(times[2]) < 7){
248 // //出入校 推班主任 247 // //出入校 推班主任
249 // List<KqTeacherDto> list = scFeign.getTeacherList(schoolId); 248 // List<KqTeacherDto> list = scFeign.getTeacherList(schoolId);
250 -// for (KqTeacherDto teacher : list) {  
251 -// dingSchoolPush(templateId, teacher, key, appDto, 0); 249 +// for(KqTeacherDto teacher : list){
  250 +// dingSchoolPush(templateId,teacher,key,appDto,0);
252 // } 251 // }
253 -// } else { 252 +// }else {
254 // //出入寝 推班主任 253 // //出入寝 推班主任
255 // List<KqTeacherDto> list = scFeign.getTeacherList(schoolId); 254 // List<KqTeacherDto> list = scFeign.getTeacherList(schoolId);
256 -// for (KqTeacherDto teacher : list) {  
257 -// dingSchoolPush(templateId, teacher, key, appDto, 1); 255 +// for(KqTeacherDto teacher : list){
  256 +// dingSchoolPush(templateId,teacher, key, appDto,1);
258 // } 257 // }
259 // //推宿管 258 // //推宿管
260 // List<KqTeacherDto> chamberList = scFeign.selectChamberTeacher(schoolId); 259 // List<KqTeacherDto> chamberList = scFeign.selectChamberTeacher(schoolId);
261 -// for (KqTeacherDto teacher : chamberList) {  
262 -// dingChamberPush(templateId, teacher, key, appDto); 260 +// for(KqTeacherDto teacher : chamberList){
  261 +// dingChamberPush(templateId,teacher, key, appDto);
263 // } 262 // }
264 // } 263 // }
265 // } 264 // }
266 // 265 //
267 // //企业号批量推送 266 // //企业号批量推送
268 -// private void weChatBatchPush(String templateId, int schoolId, String key) { 267 +// private void weChatBatchPush(String templateId , int schoolId , String key){
269 // String[] times = key.split("_"); 268 // String[] times = key.split("_");
270 // AppDto appDto = scFeign.getApp(schoolId, 0); 269 // AppDto appDto = scFeign.getApp(schoolId, 0);
271 -// if (Integer.valueOf(times[2]) < 7) { 270 +// if(Integer.valueOf(times[2]) < 7) {
272 // //出入校 推班主任 271 // //出入校 推班主任
273 // List<KqTeacherDto> list = scFeign.getTeacherList(schoolId); 272 // List<KqTeacherDto> list = scFeign.getTeacherList(schoolId);
274 // for (KqTeacherDto teacher : list) { 273 // for (KqTeacherDto teacher : list) {
275 -// weChatSchoolPush(templateId, teacher, key, appDto, 0); 274 +// weChatSchoolPush(templateId,teacher, key, appDto,0);
276 // } 275 // }
277 -// } else { 276 +// }else {
278 // //出入寝 推班主任 277 // //出入寝 推班主任
279 // List<KqTeacherDto> list = scFeign.getTeacherList(schoolId); 278 // List<KqTeacherDto> list = scFeign.getTeacherList(schoolId);
280 // for (KqTeacherDto teacher : list) { 279 // for (KqTeacherDto teacher : list) {
281 -// weChatSchoolPush(templateId, teacher, key, appDto, 1); 280 +// weChatSchoolPush(templateId,teacher, key, appDto,1);
282 // } 281 // }
283 // //推宿管 282 // //推宿管
284 // List<KqTeacherDto> chamberList = scFeign.selectChamberTeacher(schoolId); 283 // List<KqTeacherDto> chamberList = scFeign.selectChamberTeacher(schoolId);
285 -// for (KqTeacherDto teacher : chamberList) {  
286 -// weChatChamberPush(templateId, teacher, key, appDto); 284 +// for(KqTeacherDto teacher : chamberList){
  285 +// weChatChamberPush(templateId,teacher, key, appDto);
287 // } 286 // }
288 // } 287 // }
289 // } 288 // }
290 // 289 //
291 // //盯盯推送班主任 290 // //盯盯推送班主任
292 -// private void dingSchoolPush(String templateId, KqTeacherDto teacher, String key, AppDto appDto, int type) { 291 +// private void dingSchoolPush(String templateId ,KqTeacherDto teacher , String key , AppDto appDto , int type){
293 // String[] times = key.split("_"); 292 // String[] times = key.split("_");
294 // String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format); 293 // 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) { 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){
299 // String message = ""; 298 // String message = "";
300 -// for (CensusKqDto censusKqDto : censusKqDtos) {  
301 -// message += "[" + censusKqDto.getTargetName() + "]未考勤" + censusKqDto.getNotAttendCount() + "人,请假" + censusKqDto.getLeaveCount() + "人;"; 299 +// for(CensusKqDto censusKqDto : censusKqDtos){
  300 +// message += "[" + censusKqDto.getTargetName() + "]未考勤" + censusKqDto.getNotAttendCount() + "人,请假"+censusKqDto.getLeaveCount()+"人;";
302 // } 301 // }
303 // DingSms dingSms = new DingSms(); 302 // DingSms dingSms = new DingSms();
304 // dingSms.setName(teacher.getName()); 303 // 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 - " + 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 - "+
309 // "整体数据:" + message); 308 // "整体数据:" + message);
310 // String wapUrl = "http://campus.myjxt.com/studentRecord/znxwwebapp/index.html?" + 309 // 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); 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) ;
314 // dingSms.setSchoolId(teacher.getSchoolId()); 313 // dingSms.setSchoolId(teacher.getSchoolId());
315 // dingSms.setDingUserId(thirdOpenId); 314 // dingSms.setDingUserId(thirdOpenId);
316 // dingSms.setAgentId(appDto.getAgentId()); 315 // dingSms.setAgentId(appDto.getAgentId());
@@ -324,27 +323,27 @@ @@ -324,27 +323,27 @@
324 // } 323 // }
325 // 324 //
326 // //盯盯推送宿管 325 // //盯盯推送宿管
327 -// private void dingChamberPush(String templateId, KqTeacherDto teacher, String key, AppDto appDto) { 326 +// private void dingChamberPush(String templateId, KqTeacherDto teacher , String key , AppDto appDto){
328 // String[] times = key.split("_"); 327 // String[] times = key.split("_");
329 // String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format); 328 // 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) { 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){
334 // String message = ""; 333 // String message = "";
335 -// for (CensusKqDto censusKqDto : censusKqDtos) {  
336 -// message += "[" + censusKqDto.getTargetName() + "]未考勤" + censusKqDto.getNotAttendCount() + "人,请假" + censusKqDto.getLeaveCount() + "人;"; 334 +// for(CensusKqDto censusKqDto : censusKqDtos){
  335 +// message += "[" + censusKqDto.getTargetName() + "]未考勤" + censusKqDto.getNotAttendCount() + "人,请假"+censusKqDto.getLeaveCount()+"人;";
337 // } 336 // }
338 // DingSms dingSms = new DingSms(); 337 // DingSms dingSms = new DingSms();
339 // dingSms.setName(teacher.getName()); 338 // 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 - " + 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 - "+
344 // "整体数据:" + message); 343 // "整体数据:" + message);
345 // String msgUrl = "http://campus.myjxt.com/studentRecord/znxwwebapp/index.html?" + 344 // 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); 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);
348 // dingSms.setSchoolId(teacher.getSchoolId()); 347 // dingSms.setSchoolId(teacher.getSchoolId());
349 // dingSms.setDingUserId(thirdOpenId); 348 // dingSms.setDingUserId(thirdOpenId);
350 // dingSms.setAgentId(appDto.getAgentId()); 349 // dingSms.setAgentId(appDto.getAgentId());
@@ -358,16 +357,16 @@ @@ -358,16 +357,16 @@
358 // } 357 // }
359 // 358 //
360 // //企业号推送班主任 359 // //企业号推送班主任
361 -// private void weChatSchoolPush(String templateId, KqTeacherDto teacher, String key, AppDto appDto, int type) { 360 +// private void weChatSchoolPush(String templateId, KqTeacherDto teacher , String key , AppDto appDto , int type){
362 // String[] times = key.split("_"); 361 // String[] times = key.split("_");
363 // String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format); 362 // String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format);
364 -// String thirdOpenId = scFeign.getThirdId(teacher.getUserId(), 1); 363 +// String thirdOpenId = scFeign.getThirdId(teacher.getUserId(),1);
365 // if (StringUtils.isNotBlank(thirdOpenId)) { 364 // if (StringUtils.isNotBlank(thirdOpenId)) {
366 -// List<CensusKqDto> censusKqDtos = getCensus(Integer.valueOf(times[3]), templateId, teacher.getSchoolId(), teacher.getUserId(), type); 365 +// List<CensusKqDto> censusKqDtos = getCensus(Integer.valueOf(times[3]),templateId,teacher.getSchoolId(),teacher.getUserId(),type);
367 // if (censusKqDtos != null && censusKqDtos.size() > 0) { 366 // if (censusKqDtos != null && censusKqDtos.size() > 0) {
368 // String message = ""; 367 // String message = "";
369 // for (CensusKqDto censusKqDto : censusKqDtos) { 368 // for (CensusKqDto censusKqDto : censusKqDtos) {
370 -// message += "[" + censusKqDto.getTargetName() + "]未考勤" + censusKqDto.getNotAttendCount() + "人,请假" + censusKqDto.getLeaveCount() + "人;"; 369 +// message += "[" + censusKqDto.getTargetName() + "]未考勤" + censusKqDto.getNotAttendCount() + "人,请假"+censusKqDto.getLeaveCount()+"人;";
371 // } 370 // }
372 // WeChatSms weChatSms = new WeChatSms(); 371 // WeChatSms weChatSms = new WeChatSms();
373 // weChatSms.setTableName("qyhSmsNew" + tableSuffix); 372 // weChatSms.setTableName("qyhSmsNew" + tableSuffix);
@@ -382,9 +381,9 @@ @@ -382,9 +381,9 @@
382 // weChatSms.setAppId(appDto.getAgentId()); 381 // weChatSms.setAppId(appDto.getAgentId());
383 // weChatSms.setSecret(appDto.getAgentSecret()); 382 // weChatSms.setSecret(appDto.getAgentSecret());
384 // String msgUrl = "http://campus.myjxt.com/studentRecord/znxwwebapp/index.html?" + 383 // String msgUrl = "http://campus.myjxt.com/studentRecord/znxwwebapp/index.html?" +
385 -// "schoolid=" + teacher.getSchoolId() + "&userId=" + teacher.getUserId() + "&name=" + teacher.getName() + "&TemplateId=" + templateId + 384 +// "schoolid=" + teacher.getSchoolId() + "&userId=" + teacher.getUserId() + "&name=" + teacher.getName() +"&TemplateId=" + templateId+
386 // "&data=" + thirdOpenId + "&type=1&stype=3&mobile=" + teacher.getMobile() + "&pass=" + teacher.getPass() + 385 // "&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) + "&"; 386 +// "&face=" + teacher.getFace() + "&sourcetype=16&soutype=2&timestamp=" + DateUtils.getDate()+"&time="+DateUtils.date2String(new Date(),DateUtils.format1)+"&";
388 // weChatSms.setMsgUrl(msgUrl); 387 // weChatSms.setMsgUrl(msgUrl);
389 // weChatSms.setTdType(TypeEnums.kaoqing.getType()); 388 // weChatSms.setTdType(TypeEnums.kaoqing.getType());
390 // this.insertQYH(weChatSms); 389 // this.insertQYH(weChatSms);
@@ -394,16 +393,16 @@ @@ -394,16 +393,16 @@
394 // } 393 // }
395 // 394 //
396 // //企业号推送宿管 395 // //企业号推送宿管
397 -// private void weChatChamberPush(String templateId, KqTeacherDto teacher, String key, AppDto appDto) { 396 +// private void weChatChamberPush(String templateId, KqTeacherDto teacher , String key , AppDto appDto){
398 // String[] times = key.split("_"); 397 // String[] times = key.split("_");
399 // String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format); 398 // String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format);
400 -// String thirdOpenId = scFeign.getThirdId(teacher.getUserId(), 1); 399 +// String thirdOpenId = scFeign.getThirdId(teacher.getUserId(),1);
401 // if (StringUtils.isNotBlank(thirdOpenId)) { 400 // if (StringUtils.isNotBlank(thirdOpenId)) {
402 -// List<CensusKqDto> censusKqDtos = getCensus(Integer.valueOf(times[3]), templateId, teacher.getSchoolId(), teacher.getUserId(), 1); 401 +// List<CensusKqDto> censusKqDtos = getCensus(Integer.valueOf(times[3]),templateId,teacher.getSchoolId(),teacher.getUserId(),1);
403 // if (censusKqDtos != null && censusKqDtos.size() > 0) { 402 // if (censusKqDtos != null && censusKqDtos.size() > 0) {
404 // String message = ""; 403 // String message = "";
405 // for (CensusKqDto censusKqDto : censusKqDtos) { 404 // for (CensusKqDto censusKqDto : censusKqDtos) {
406 -// message += "[" + censusKqDto.getTargetName() + "]未考勤" + censusKqDto.getNotAttendCount() + "人,请假" + censusKqDto.getLeaveCount() + "人;"; 405 +// message += "[" + censusKqDto.getTargetName() + "]未考勤" + censusKqDto.getNotAttendCount() + "人,请假"+censusKqDto.getLeaveCount()+"人;";
407 // } 406 // }
408 // WeChatSms weChatSms = new WeChatSms(); 407 // WeChatSms weChatSms = new WeChatSms();
409 // weChatSms.setTableName("qyhSmsNew" + tableSuffix); 408 // weChatSms.setTableName("qyhSmsNew" + tableSuffix);
@@ -418,8 +417,8 @@ @@ -418,8 +417,8 @@
418 // weChatSms.setAppId(appDto.getAgentId()); 417 // weChatSms.setAppId(appDto.getAgentId());
419 // weChatSms.setSecret(appDto.getAgentSecret()); 418 // weChatSms.setSecret(appDto.getAgentSecret());
420 // String msgUrl = "http://campus.myjxt.com/studentRecord/znxwwebapp/index.html?" + 419 // 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) + "&"; 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)+"&";
423 // weChatSms.setMsgUrl(msgUrl); 422 // weChatSms.setMsgUrl(msgUrl);
424 // weChatSms.setTdType(TypeEnums.kaoqing.getType()); 423 // weChatSms.setTdType(TypeEnums.kaoqing.getType());
425 // this.insertQYH(weChatSms); 424 // this.insertQYH(weChatSms);
@@ -429,120 +428,121 @@ @@ -429,120 +428,121 @@
429 // } 428 // }
430 // 429 //
431 // //type 0 出入校 1 出入寝 430 // //type 0 出入校 1 出入寝
432 -// private List<CensusKqDto> getCensus(int id, String templateId, int schoolId, String userId, int type) { 431 +// private List<CensusKqDto> getCensus(int id , String templateId ,int schoolId , String userId ,int type){
433 // List<CensusKqDto> list = new ArrayList<>(); 432 // 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); 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);
436 // JSONObject jsonObject = HttpClientUtils.httpGet(url); 435 // JSONObject jsonObject = HttpClientUtils.httpGet(url);
437 -// try {  
438 -// JSONArray data = (JSONArray) jsonObject.get("data");  
439 -// for (int i = 0; i < data.size(); i++) { 436 +// try{
  437 +// JSONArray data = (JSONArray)jsonObject.get("data");
  438 +// for(int i = 0 ; i < data.size() ; i++){
440 // CensusKqDto censusKqDto = new CensusKqDto(); 439 // CensusKqDto censusKqDto = new CensusKqDto();
441 // JSONObject object = data.getJSONObject(i); 440 // JSONObject object = data.getJSONObject(i);
442 // censusKqDto.setLeaveCount((Integer) object.get("leaveCount")); 441 // censusKqDto.setLeaveCount((Integer) object.get("leaveCount"));
443 // censusKqDto.setNotAttendCount((Integer) object.get("noAttendCount")); 442 // censusKqDto.setNotAttendCount((Integer) object.get("noAttendCount"));
444 -// censusKqDto.setTargetName((String) object.get("name")); 443 +// censusKqDto.setTargetName((String)object.get("name"));
445 // list.add(censusKqDto); 444 // list.add(censusKqDto);
446 // } 445 // }
447 -// } catch (Exception e) { 446 +// }catch (Exception e){
448 // 447 //
449 // } 448 // }
450 -// return list; 449 +// return list ;
451 // } 450 // }
452 // 451 //
453 -// private BigDecimal getAlarmCensus(int id, String templateId, int schoolId, int type) {  
454 -// int allNumber = 0, attendNumber = 0; 452 +// private BigDecimal getAlarmCensus(int id , String templateId ,int schoolId , int type){
  453 +// int allNumber = 0 , attendNumber = 0 ;
455 // List<Integer> list = scFeign.selectClassBySchoolId(schoolId); 454 // 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); 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);
459 // JSONObject jsonObject = HttpClientUtils.httpGet(url); 458 // JSONObject jsonObject = HttpClientUtils.httpGet(url);
460 -// try { 459 +// try{
461 // JSONObject data = (JSONObject) jsonObject.get("data"); 460 // JSONObject data = (JSONObject) jsonObject.get("data");
462 // attendNumber = attendNumber + (Integer) data.get("stuAttendCount"); 461 // attendNumber = attendNumber + (Integer) data.get("stuAttendCount");
463 // allNumber = allNumber + (Integer) data.get("stuCount"); 462 // allNumber = allNumber + (Integer) data.get("stuCount");
464 -// } catch (Exception e) { 463 +// }catch (Exception e){
465 // e.printStackTrace(); 464 // e.printStackTrace();
466 // } 465 // }
467 // } 466 // }
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; 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 ;
473 // } 472 // }
474 // 473 //
475 // } 474 // }
476 // 475 //
477 // /** 476 // /**
  477 +// *
478 // * @param id 478 // * @param id
479 // * @param templateId 479 // * @param templateId
480 // * @param schoolId 480 // * @param schoolId
481 // * @param type 481 // * @param type
482 // * @return list(0) 出勤 list(1) 未出勤 List(2) 请假 482 // * @return list(0) 出勤 list(1) 未出勤 List(2) 请假
483 // */ 483 // */
484 -// private List<Integer> getIOTCensus(int id, String templateId, int schoolId, int type) { 484 +// private List<Integer> getIOTCensus(int id , String templateId ,int schoolId , int type){
485 // List<Integer> result = new ArrayList<>(); 485 // List<Integer> result = new ArrayList<>();
486 -// int attend = 0, unattend = 0, leave = 0; 486 +// int attend = 0 , unattend = 0 , leave = 0;
487 // List<Integer> list = scFeign.selectClassBySchoolId(schoolId); 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); 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); 491 // JSONObject jsonObject = HttpClientUtils.httpGet(url);
492 -// try { 492 +// try{
493 // JSONObject data = (JSONObject) jsonObject.get("data"); 493 // JSONObject data = (JSONObject) jsonObject.get("data");
494 // attend = attend + (Integer) data.get("stuAttendCount"); 494 // attend = attend + (Integer) data.get("stuAttendCount");
495 // unattend = unattend + (Integer) data.get("noAttendCount"); 495 // unattend = unattend + (Integer) data.get("noAttendCount");
496 // leave = leave + (Integer) data.get("leaveCount"); 496 // leave = leave + (Integer) data.get("leaveCount");
497 -// } catch (Exception e) { 497 +// }catch (Exception e){
498 // e.printStackTrace(); 498 // e.printStackTrace();
499 // } 499 // }
500 // } 500 // }
501 // result.add(attend); 501 // result.add(attend);
502 // result.add(unattend); 502 // result.add(unattend);
503 // result.add(leave); 503 // result.add(leave);
504 -// return result; 504 +// return result ;
505 // } 505 // }
506 // 506 //
507 // 507 //
508 -// private void insertDing(DingSms dingSms) {  
509 -// try { 508 +// private void insertDing(DingSms dingSms){
  509 +// try{
510 // smsService.insertDing(dingSms); 510 // smsService.insertDing(dingSms);
511 -// } catch (Exception e) { 511 +// }catch (Exception e){
512 // logger.info(e.toString()); 512 // logger.info(e.toString());
513 // } 513 // }
514 // } 514 // }
515 // 515 //
516 -// private void insertQYH(WeChatSms weChatSms) {  
517 -// try { 516 +// private void insertQYH(WeChatSms weChatSms){
  517 +// try{
518 // smsService.insertWeChat(weChatSms); 518 // smsService.insertWeChat(weChatSms);
519 -// } catch (Exception e) { 519 +// }catch (Exception e){
520 // logger.info(e.toString()); 520 // logger.info(e.toString());
521 // } 521 // }
522 // } 522 // }
523 // 523 //
524 -// private void alarmPush(int schoolId) {  
525 -// String msg = "【考勤异动】";  
526 -// try { 524 +// private void alarmPush(int schoolId){
  525 +// String msg = "【考勤异动】" ;
  526 +// try{
527 // SchoolDto schoolDto = scFeign.selectSchoolBySchoolId(schoolId); 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); 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 // } 535 // }
536 -// } catch (Exception e) { 536 +// }catch (Exception e){
537 // e.printStackTrace(); 537 // e.printStackTrace();
538 // } 538 // }
539 // 539 //
540 // } 540 // }
541 // 541 //
542 -// private void sendMessage(int schoolId, String mobile, String msg) { 542 +// private void sendMessage(int schoolId , String mobile , String msg){
543 // String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format); 543 // String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format);
544 // ShortMsg shortMsg = new ShortMsg(); 544 // ShortMsg shortMsg = new ShortMsg();
545 -// shortMsg.setTableName("smsNew" + tableSuffix); 545 +// shortMsg.setTableName("smsNew"+tableSuffix);
546 // shortMsg.setSchoolId(schoolId); 546 // shortMsg.setSchoolId(schoolId);
547 // shortMsg.setMobile(mobile); 547 // shortMsg.setMobile(mobile);
548 // shortMsg.setMsg(msg); 548 // shortMsg.setMsg(msg);
cloud/quartz/src/main/java/com/sincere/quartz/job/SyncJob.java
@@ -15,10 +15,10 @@ @@ -15,10 +15,10 @@
15 //public class SyncJob { 15 //public class SyncJob {
16 // 16 //
17 // @Autowired 17 // @Autowired
18 -// YXYWriteService yxyWriteService; 18 +// YXYWriteService yxyWriteService ;
19 // 19 //
20 // @Autowired 20 // @Autowired
21 -// YXYReadService yxyReadService; 21 +// YXYReadService yxyReadService ;
22 // 22 //
23 // @Scheduled(cron = "30 1 22 * * ? ") 23 // @Scheduled(cron = "30 1 22 * * ? ")
24 // public void Sync(){ 24 // public void Sync(){
cloud/quartz/src/main/java/com/sincere/quartz/mapper/YxyMapper.java
1 package com.sincere.quartz.mapper; 1 package com.sincere.quartz.mapper;
2 2
  3 +import com.sincere.quartz.dto.*;
3 import com.sincere.quartz.model.YxyAgency; 4 import com.sincere.quartz.model.YxyAgency;
4 import com.sincere.quartz.model.YxyStudent; 5 import com.sincere.quartz.model.YxyStudent;
5 import com.sincere.quartz.model.YxyTeacher; 6 import com.sincere.quartz.model.YxyTeacher;
  7 +import org.apache.ibatis.annotations.Param;
  8 +
  9 +import java.util.List;
6 10
7 public interface YxyMapper { 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 int selectCount(String date); 33 int selectCount(String date);
10 34
11 int deleteWeekBefore(); 35 int deleteWeekBefore();
@@ -21,4 +45,8 @@ public interface YxyMapper { @@ -21,4 +45,8 @@ public interface YxyMapper {
21 int insertTeacher(YxyTeacher teacher) ; 45 int insertTeacher(YxyTeacher teacher) ;
22 46
23 int insertStudent(YxyStudent student) ; 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,13 +2,22 @@ package com.sincere.quartz.model;
2 2
3 public class YxyStudent { 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 private String cardID2; 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 public String getCardID() { 22 public String getCardID() {
14 return cardID; 23 return cardID;
@@ -65,4 +74,18 @@ public class YxyStudent { @@ -65,4 +74,18 @@ public class YxyStudent {
65 public void setAccount(String account) { 74 public void setAccount(String account) {
66 this.account = account; 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,10 +2,19 @@ package com.sincere.quartz.model;
2 2
3 public class YxyTeacher { 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 public String getUserId() { 19 public String getUserId() {
11 return userId; 20 return userId;
@@ -38,4 +47,15 @@ public class YxyTeacher { @@ -38,4 +47,15 @@ public class YxyTeacher {
38 public void setDeptId(String deptId) { 47 public void setDeptId(String deptId) {
39 this.deptId = deptId; 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 package com.sincere.quartz.service; 1 package com.sincere.quartz.service;
2 2
  3 +import com.sincere.quartz.dto.*;
3 import com.sincere.quartz.model.YxyAgency; 4 import com.sincere.quartz.model.YxyAgency;
4 import com.sincere.quartz.model.YxyStudent; 5 import com.sincere.quartz.model.YxyStudent;
5 import com.sincere.quartz.model.YxyTeacher; 6 import com.sincere.quartz.model.YxyTeacher;
  7 +import org.apache.ibatis.annotations.Param;
  8 +
  9 +import java.util.List;
6 10
7 public interface YxyService { 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 int selectCount(String date); 33 int selectCount(String date);
10 34
11 int deleteWeekBefore(); 35 int deleteWeekBefore();
@@ -21,4 +45,8 @@ public interface YxyService { @@ -21,4 +45,8 @@ public interface YxyService {
21 int insertTeacher(YxyTeacher teacher) ; 45 int insertTeacher(YxyTeacher teacher) ;
22 46
23 int insertStudent(YxyStudent student) ; 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,6 +2,7 @@ package com.sincere.quartz.service.impl;
2 2
3 import com.sincere.quartz.datasource.DataSourceType; 3 import com.sincere.quartz.datasource.DataSourceType;
4 import com.sincere.quartz.datasource.MyDataSource; 4 import com.sincere.quartz.datasource.MyDataSource;
  5 +import com.sincere.quartz.dto.*;
5 import com.sincere.quartz.mapper.YxyMapper; 6 import com.sincere.quartz.mapper.YxyMapper;
6 import com.sincere.quartz.model.YxyAgency; 7 import com.sincere.quartz.model.YxyAgency;
7 import com.sincere.quartz.model.YxyStudent; 8 import com.sincere.quartz.model.YxyStudent;
@@ -10,6 +11,8 @@ import com.sincere.quartz.service.YxyService; @@ -10,6 +11,8 @@ import com.sincere.quartz.service.YxyService;
10 import org.springframework.beans.factory.annotation.Autowired; 11 import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.stereotype.Service; 12 import org.springframework.stereotype.Service;
12 13
  14 +import java.util.List;
  15 +
13 @Service 16 @Service
14 public class YxyServiceImpl implements YxyService { 17 public class YxyServiceImpl implements YxyService {
15 18
@@ -17,6 +20,66 @@ public class YxyServiceImpl implements YxyService { @@ -17,6 +20,66 @@ public class YxyServiceImpl implements YxyService {
17 YxyMapper yxyMapper; 20 YxyMapper yxyMapper;
18 21
19 @Override 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 @MyDataSource(DataSourceType.Yxy) 83 @MyDataSource(DataSourceType.Yxy)
21 public int selectCount(String date) { 84 public int selectCount(String date) {
22 return yxyMapper.selectCount(date); 85 return yxyMapper.selectCount(date);
@@ -63,4 +126,16 @@ public class YxyServiceImpl implements YxyService { @@ -63,4 +126,16 @@ public class YxyServiceImpl implements YxyService {
63 public int insertStudent(YxyStudent student) { 126 public int insertStudent(YxyStudent student) {
64 return yxyMapper.insertStudent(student); 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 @@ @@ -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 = syncStudent(yxtId);
  68 + logger.info("学生同步");
  69 + for(YxyStudent student : studentList){
  70 + logger.info(student.toString());
  71 + if(student.getType() == 1){
  72 + //新增
  73 + try{
  74 + String className = yxyService.getDeptName(student.getClassId());
  75 + String gradeName = yxyService.getSuperDeptName(student.getClassId());
  76 + int gradeId = yxyService.getGradeId(hxyId,gradeName);
  77 + int classId = yxyService.getClassId(hxyId,className);
  78 + if(gradeId != 0 && classId != 0){
  79 + AddStudentDto addStudentDto = new AddStudentDto();
  80 + addStudentDto.setAppId(0);
  81 + addStudentDto.setUserId("");
  82 + addStudentDto.setSchoolId(hxyId);
  83 + addStudentDto.setXml(initAddStudentXML(student.getName(),classId,gradeId,student.getAccount(),student.getUserId()));
  84 + yxyService.addStudent(addStudentDto);
  85 + logger.info("操作结果:"+addStudentDto.getErr());
  86 + }
  87 + }catch (Exception e){
  88 + logger.info("操作结果失败:"+e.toString());
  89 + }
  90 + }
  91 + if(student.getType() == 2){
  92 + //修改
  93 + try{
  94 + String className = yxyService.getDeptName(student.getClassId());
  95 + String gradeName = yxyService.getSuperDeptName(student.getClassId());
  96 + int gradeId = yxyService.getGradeId(hxyId,gradeName);
  97 + int classId = yxyService.getClassId(hxyId,className);
  98 + if(gradeId != 0 && classId != 0){
  99 + EditStudentDto editStudentDto = new EditStudentDto();
  100 + editStudentDto.setAppId(0);
  101 + editStudentDto.setUserId("");
  102 + editStudentDto.setParentId(0);
  103 + editStudentDto.setParentUserId("");
  104 + List<StudentView> list = yxyService.getStudentView(classId,student.getName());
  105 + if(list != null && list.size() == 1){
  106 + editStudentDto.setStudentId(list.get(0).getStudentId());
  107 + editStudentDto.setStudentUserId(list.get(0).getUserId());
  108 + editStudentDto.setXml(initEditStudentXML(student.getName(),classId,gradeId,student.getUserId()));
  109 + yxyService.editStudent(editStudentDto);
  110 + logger.info("操作结果:"+editStudentDto.getErr());
  111 + }else {
  112 + throw new Exception("同一个班级同一姓名返回数据两条");
  113 + }
  114 +
  115 + }
  116 + }catch (Exception e){
  117 + logger.info("操作结果失败:"+e.toString());
  118 + }
  119 + }
  120 + if(student.getType() == 3){
  121 + //删除 暂不操作
  122 + }
  123 + }
  124 +// List<YxyTeacher> teacherList = syncTeacher(yxtId);
  125 +// logger.info("教师同步");
  126 +// for(YxyTeacher teacher : teacherList){
  127 +// logger.info(teacher.toString());
  128 +// if(teacher.getType() == 1){
  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(),list.get(0).getUserId()));
  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 , String userId){
  251 + String xml = "<region>" +
  252 + "<school_id>"+schoolId+"</school_id>" +
  253 + "<user_id>"+userId+"</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 =getAllStudent ;
  282 + String ns = nameSpace;
  283 + String method = getALlStudent_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 \ No newline at end of file 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,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 List<SyncUserDto> addStudentList = new ArrayList<>(); 75 List<SyncUserDto> addStudentList = new ArrayList<>();
76 List<SyncUserDto> updateStudentList = new ArrayList<>(); 76 List<SyncUserDto> updateStudentList = new ArrayList<>();
77 List<SyncUserDto> deleteStudentList = new ArrayList<>(); 77 List<SyncUserDto> deleteStudentList = new ArrayList<>();
cloud/quartz/src/main/resources/mapper/YxyMapper.xml
@@ -2,6 +2,78 @@ @@ -2,6 +2,78 @@
2 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > 2 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
3 <mapper namespace="com.sincere.quartz.mapper.YxyMapper"> 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 <delete id="deleteWeekBefore" > 78 <delete id="deleteWeekBefore" >
7 delete Agency where DATEDIFF(d,intime,GETDATE())>7; 79 delete Agency where DATEDIFF(d,intime,GETDATE())>7;
@@ -17,10 +89,18 @@ @@ -17,10 +89,18 @@
17 update Teacher set state = 0 where DATEDIFF(n , intime, getdate()) > 240 89 update Teacher set state = 0 where DATEDIFF(n , intime, getdate()) > 240
18 </update> 90 </update>
19 91
  92 + <update id="updateTeacherBySchool" >
  93 + update Teacher set state = 0 where deptID like '%${deptId}%'
  94 + </update>
  95 +
20 <update id="updateStudent"> 96 <update id="updateStudent">
21 update Student set state = 0 where DATEDIFF(n , intime, getdate()) > 240 97 update Student set state = 0 where DATEDIFF(n , intime, getdate()) > 240
22 </update> 98 </update>
23 99
  100 + <update id="updateStudentBySchool">
  101 + update Student set state = 0 where classID like '%${classId}%'
  102 + </update>
  103 +
24 <select id="selectCount" parameterType="java.lang.String" resultType="java.lang.Integer"> 104 <select id="selectCount" parameterType="java.lang.String" resultType="java.lang.Integer">
25 select count(0) from Student where intime > #{date} 105 select count(0) from Student where intime > #{date}
26 </select> 106 </select>
cloud/weigeng/src/main/java/com/sincere/weigeng/Swagger2.java
@@ -1,39 +0,0 @@ @@ -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 -}  
cloud/zkAttendance/src/main/java/com/sincere/att/Swagger2.java
@@ -19,10 +19,9 @@ public class Swagger2 { @@ -19,10 +19,9 @@ public class Swagger2 {
19 public Docket createRestApi() { 19 public Docket createRestApi() {
20 return new Docket(DocumentationType.SWAGGER_2) 20 return new Docket(DocumentationType.SWAGGER_2)
21 .apiInfo(apiInfo()) 21 .apiInfo(apiInfo())
22 - .enableUrlTemplating(true)  
23 .select() 22 .select()
24 // 扫描所有有注解的api,用这种方式更灵活 23 // 扫描所有有注解的api,用这种方式更灵活
25 - .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) 24 + .apis(RequestHandlerSelectors.basePackage("com.sincere.att.controller"))
26 .paths(PathSelectors.any()) 25 .paths(PathSelectors.any())
27 .build(); 26 .build();
28 27
cloud/zkAttendance/src/main/java/com/sincere/att/controller/AttPushController.java
@@ -14,12 +14,9 @@ import com.sincere.common.dto.smartCampus.SZ_AttendanceDto; @@ -14,12 +14,9 @@ import com.sincere.common.dto.smartCampus.SZ_AttendanceDto;
14 import com.sincere.common.dto.xiaoan.FingerDto; 14 import com.sincere.common.dto.xiaoan.FingerDto;
15 import com.sincere.common.util.DateUtils; 15 import com.sincere.common.util.DateUtils;
16 import com.sincere.common.util.HttpClientUtils; 16 import com.sincere.common.util.HttpClientUtils;
17 -import io.swagger.annotations.Api;  
18 -import io.swagger.annotations.ApiOperation;  
19 import org.apache.commons.lang3.StringUtils; 17 import org.apache.commons.lang3.StringUtils;
20 import org.slf4j.Logger; 18 import org.slf4j.Logger;
21 import org.springframework.beans.factory.annotation.Autowired; 19 import org.springframework.beans.factory.annotation.Autowired;
22 -import org.springframework.stereotype.Controller;  
23 import org.springframework.web.bind.annotation.*; 20 import org.springframework.web.bind.annotation.*;
24 21
25 import javax.servlet.http.HttpServletRequest; 22 import javax.servlet.http.HttpServletRequest;
@@ -35,7 +32,7 @@ import java.util.*; @@ -35,7 +32,7 @@ import java.util.*;
35 /** 32 /**
36 * 所有的设备请求都会在url参数里携带SN,这是设备序列号(serial number的缩写),每个设备唯一标识 33 * 所有的设备请求都会在url参数里携带SN,这是设备序列号(serial number的缩写),每个设备唯一标识
37 */ 34 */
38 -@Controller 35 +@RestController
39 @RequestMapping("/iclock") 36 @RequestMapping("/iclock")
40 public class AttPushController { 37 public class AttPushController {
41 private static final Logger Log_orderFail = LoggerUtils.Logger(LogName.orderFail); 38 private static final Logger Log_orderFail = LoggerUtils.Logger(LogName.orderFail);
@@ -43,80 +40,80 @@ public class AttPushController { @@ -43,80 +40,80 @@ public class AttPushController {
43 private static final Logger Log_kaoInfo = LoggerUtils.Logger(LogName.kaoInfo); 40 private static final Logger Log_kaoInfo = LoggerUtils.Logger(LogName.kaoInfo);
44 41
45 private static Map<String, List<String>> cmdMap = new HashMap<>(); 42 private static Map<String, List<String>> cmdMap = new HashMap<>();
46 - private static Map<String, Integer> cmdOrderMap = new HashMap<>(); 43 + private static Map<String , Integer> cmdOrderMap = new HashMap<>();
47 44
48 - private static String pwd = "22222222-6faf-48uh-a5a9-447ec68bfe2f";  
49 - private static String account = "yueqingzhijiao"; 45 + private static String pwd = "22222222-6faf-48uh-a5a9-447ec68bfe2f" ;
  46 + private static String account = "yueqingzhijiao" ;
50 47
51 48
52 @Autowired 49 @Autowired
53 ScFeign scFeign; 50 ScFeign scFeign;
54 51
55 @Autowired 52 @Autowired
56 - XaFeign xaFeign; 53 + XaFeign xaFeign ;
57 54
58 - @RequestMapping(value = "sendUser/{roomId}", method = RequestMethod.GET)  
59 - public void sendUser(@PathVariable int roomId) { 55 + @RequestMapping(value = "sendUser" , method = RequestMethod.GET)
  56 + public void sendUser(int roomId){
60 JSONObject object = new JSONObject(); 57 JSONObject object = new JSONObject();
61 - object.put("PageIndex", 1);  
62 - object.put("roomId", roomId);  
63 - object.put("pageSize", 9999);  
64 - JSONObject result = HttpClientUtils.httpPostJson("http://campus.myjxt.com/api/Room/GetListPageRoom", object.toJSONString());  
65 - JSONArray array = (JSONArray) ((JSONObject) result.get("data")).get("roomList"); 58 + object.put("pageIndex",1);
  59 + object.put("roomId",roomId);
  60 + object.put("pageSize",9999);
  61 + JSONObject result = HttpClientUtils.httpPostJson("http://campus.myjxt.com/api/Room/GetListPageRoom",object.toJSONString());
  62 + JSONArray array = (JSONArray) ((JSONObject) result.get("data")).get("roomList") ;
66 List<String> order = new ArrayList<>(); 63 List<String> order = new ArrayList<>();
67 List<String> attendanceList = scFeign.selectRoomAttendance(roomId); 64 List<String> attendanceList = scFeign.selectRoomAttendance(roomId);
68 - for (String attendance : attendanceList) {  
69 - for (int i = 0; i < array.size(); i++) { 65 + for(String attendance : attendanceList){
  66 + for(int i = 0 ; i < array.size() ; i++){
70 JSONObject student = (JSONObject) array.get(i); 67 JSONObject student = (JSONObject) array.get(i);
71 UserOrderVo vo = new UserOrderVo(); 68 UserOrderVo vo = new UserOrderVo();
72 vo.setStudentId((Integer) student.get("studentid")); 69 vo.setStudentId((Integer) student.get("studentid"));
73 vo.setStudentName((String) student.get("name")); 70 vo.setStudentName((String) student.get("name"));
74 - int number = 1;  
75 - try {  
76 - number = cmdOrderMap.get(attendance);  
77 - } catch (Exception e) { 71 + int number = 1 ;
  72 + try{
  73 + number = cmdOrderMap.get(attendance) ;
  74 + }catch (Exception e){
78 75
79 } 76 }
80 vo.setNumber(number); 77 vo.setNumber(number);
81 - number++;  
82 - cmdOrderMap.put(attendance, number);  
83 - if (vo.getStudentId() != 0) { 78 + number++ ;
  79 + cmdOrderMap.put(attendance,number) ;
  80 + if(vo.getStudentId() != 0){
84 order.add(vo.toString()); 81 order.add(vo.toString());
85 } 82 }
86 } 83 }
87 - cmdMap.put(attendance, order); 84 + cmdMap.put(attendance,order);
88 } 85 }
89 } 86 }
90 87
91 - @RequestMapping(value = "sendFinger/{roomId}", method = RequestMethod.GET)  
92 - public void sendFinger(@PathVariable int roomId) { 88 + @RequestMapping(value = "sendFinger" , method = RequestMethod.GET)
  89 + public void sendFinger(int roomId){
93 JSONObject object = new JSONObject(); 90 JSONObject object = new JSONObject();
94 - object.put("PageIndex", 1);  
95 - object.put("roomId", roomId);  
96 - object.put("pageSize", 9999);  
97 - JSONObject result = HttpClientUtils.httpPostJson("http://campus.myjxt.com/api/Room/GetListPageRoom", object.toJSONString());  
98 - JSONArray array = (JSONArray) ((JSONObject) result.get("data")).get("roomList"); 91 + object.put("PageIndex",1);
  92 + object.put("roomId",roomId);
  93 + object.put("pageSize",9999);
  94 + JSONObject result = HttpClientUtils.httpPostJson("http://campus.myjxt.com/api/Room/GetListPageRoom",object.toJSONString());
  95 + JSONArray array = (JSONArray) ((JSONObject) result.get("data")).get("roomList") ;
99 List<String> order = new ArrayList<>(); 96 List<String> order = new ArrayList<>();
100 List<String> attendanceList = scFeign.selectRoomAttendance(roomId); 97 List<String> attendanceList = scFeign.selectRoomAttendance(roomId);
101 - for (String attendance : attendanceList) {  
102 - for (int i = 0; i < array.size(); i++) { 98 + for(String attendance : attendanceList){
  99 + for(int i = 0 ; i < array.size() ; i++){
103 JSONObject student = (JSONObject) array.get(i); 100 JSONObject student = (JSONObject) array.get(i);
104 FingerOrderVo vo = new FingerOrderVo(); 101 FingerOrderVo vo = new FingerOrderVo();
105 - int number = 1;  
106 - try {  
107 - number = cmdOrderMap.get(attendance);  
108 - } catch (Exception e) { 102 + int number = 1 ;
  103 + try{
  104 + number = cmdOrderMap.get(attendance) ;
  105 + }catch (Exception e){
109 106
110 } 107 }
111 vo.setNumber(number); 108 vo.setNumber(number);
112 - vo.setOrder(xaFeign.selectFinger((Integer) student.get("studentid")));  
113 - number++;  
114 - cmdOrderMap.put(attendance, number);  
115 - if (StringUtils.isNotBlank(vo.getOrder())) { 109 + vo.setOrder(xaFeign.selectFinger((Integer)student.get("studentid")));
  110 + number++ ;
  111 + cmdOrderMap.put(attendance,number) ;
  112 + if(StringUtils.isNotBlank(vo.getOrder())){
116 order.add(vo.toString()); 113 order.add(vo.toString());
117 } 114 }
118 } 115 }
119 - cmdMap.put(attendance, order); 116 + cmdMap.put(attendance,order);
120 } 117 }
121 } 118 }
122 119
@@ -124,28 +121,29 @@ public class AttPushController { @@ -124,28 +121,29 @@ public class AttPushController {
124 * 1,设备通完电以后第一个发送到后台的请求 121 * 1,设备通完电以后第一个发送到后台的请求
125 * 格式为 /iclock/cdata?options=all&language=xxxx&pushver=xxxx 122 * 格式为 /iclock/cdata?options=all&language=xxxx&pushver=xxxx
126 */ 123 */
127 - @RequestMapping(value = "/cdata", params = {"options", "language", "pushver"}, method = RequestMethod.GET)  
128 - public void init(String SN, String options, String language, String pushver, HttpServletRequest request,  
129 - @RequestParam(required = false) String PushOptionsFlag, HttpServletResponse response) { 124 + @RequestMapping(value="/cdata",params = {"options","language","pushver"},method = RequestMethod.GET)
  125 + public void init(String SN, String options, String language, String pushver, HttpServletRequest request ,
  126 + @RequestParam(required = false) String PushOptionsFlag, HttpServletResponse response){
130 try { 127 try {
131 - if (cmdMap.get(SN) == null) {  
132 - cmdMap.put(SN, new ArrayList<>());  
133 - cmdOrderMap.put(SN, 1); 128 + if(cmdMap.get(SN) == null){
  129 + System.out.println("设备上线:" + SN);
  130 + cmdMap.put(SN,new ArrayList<>());
  131 + cmdOrderMap.put(SN,1);
134 } 132 }
135 - if (scFeign.selectAttendaceWithId(SN) == null) { 133 + if(scFeign.selectAttendaceWithId(SN) == null){
136 SZ_AttendanceDto attendanceDto = new SZ_AttendanceDto(); 134 SZ_AttendanceDto attendanceDto = new SZ_AttendanceDto();
137 attendanceDto.setClint_id(SN); 135 attendanceDto.setClint_id(SN);
138 attendanceDto.setClint_type("24"); 136 attendanceDto.setClint_type("24");
139 attendanceDto.setIp(request.getRemoteAddr()); 137 attendanceDto.setIp(request.getRemoteAddr());
140 attendanceDto.setPort(request.getRemotePort()); 138 attendanceDto.setPort(request.getRemotePort());
141 - attendanceDto.setIntime(DateUtils.date2String(new Date(), DateUtils.format2)); 139 + attendanceDto.setIntime(DateUtils.date2String(new Date(),DateUtils.format2));
142 attendanceDto.setSchool_id("-1"); 140 attendanceDto.setSchool_id("-1");
143 attendanceDto.setState(1); 141 attendanceDto.setState(1);
144 scFeign.insertAttendance(attendanceDto); 142 scFeign.insertAttendance(attendanceDto);
145 - } else { 143 + }else {
146 scFeign.updateAttendance(SN); 144 scFeign.updateAttendance(SN);
147 } 145 }
148 - String initOptions = initOptions(SN, PushOptionsFlag); 146 + String initOptions = initOptions(SN,PushOptionsFlag);
149 response.getWriter().write(initOptions);//返回成功以后设备会发送心跳请求 147 response.getWriter().write(initOptions);//返回成功以后设备会发送心跳请求
150 } catch (IOException e) { 148 } catch (IOException e) {
151 e.printStackTrace(); 149 e.printStackTrace();
@@ -156,18 +154,19 @@ public class AttPushController { @@ -156,18 +154,19 @@ public class AttPushController {
156 * 2,心跳请求,会从服务器拿到命令返回 给设备 154 * 2,心跳请求,会从服务器拿到命令返回 给设备
157 */ 155 */
158 @RequestMapping("/getrequest") 156 @RequestMapping("/getrequest")
159 - public void heartBeat(String SN, HttpServletResponse response) { 157 + public void heartBeat(String SN, HttpServletResponse response){
160 scFeign.updateAttendance(SN); 158 scFeign.updateAttendance(SN);
161 StringBuffer sb = new StringBuffer("OK"); 159 StringBuffer sb = new StringBuffer("OK");
162 - List<String> cmds = cmdMap.get(SN);  
163 - if (cmds == null) {//等于空说明从来没加载过,如果初始化加载过了,此时应该不为Null 只是size为0 160 + List<String> cmds = cmdMap.get(SN);
  161 + if(cmds==null){//等于空说明从来没加载过,如果初始化加载过了,此时应该不为Null 只是size为0
  162 + System.out.println("设备上线:" + SN);
164 cmds = new ArrayList<>(); 163 cmds = new ArrayList<>();
165 - cmdMap.put(SN, cmds);  
166 - cmdOrderMap.put(SN, 1); 164 + cmdMap.put(SN,cmds);
  165 + cmdOrderMap.put(SN,1);
167 } 166 }
168 - if (cmds != null && cmds.size() > 0) {  
169 - sb.setLength(0);//如果有命令就不返回OK了  
170 - cmds.stream().forEach(cmd -> sb.append(cmd).append("\r\n\r\n")); 167 + if(cmds!=null&&cmds.size()>0){
  168 + sb.setLength(0);//如果有命令就不返回OK了
  169 + cmds.stream().forEach(cmd->sb.append(cmd).append("\r\n\r\n"));
171 170
172 } 171 }
173 try { 172 try {
@@ -184,8 +183,8 @@ public class AttPushController { @@ -184,8 +183,8 @@ public class AttPushController {
184 * 这个请求,服务器只能返回OK,不可以返回命令 183 * 这个请求,服务器只能返回OK,不可以返回命令
185 */ 184 */
186 @RequestMapping("/ping") 185 @RequestMapping("/ping")
187 - public void ping(HttpServletResponse response) {  
188 - System.out.println("考勤机心跳请求大量进来了......ping" + new SimpleDateFormat("HH:mm:ss").format(new Date())); 186 + public void ping(HttpServletResponse response){
  187 + System.out.println("考勤机心跳请求大量进来了......ping"+new SimpleDateFormat("HH:mm:ss").format(new Date()));
189 try { 188 try {
190 response.getWriter().write("OK"); 189 response.getWriter().write("OK");
191 } catch (IOException e) { 190 } catch (IOException e) {
@@ -197,20 +196,20 @@ public class AttPushController { @@ -197,20 +196,20 @@ public class AttPushController {
197 * 4,设备端处理完命令以后会发送该请求,告诉服务器命令的处理结果 196 * 4,设备端处理完命令以后会发送该请求,告诉服务器命令的处理结果
198 */ 197 */
199 @RequestMapping("/devicecmd") 198 @RequestMapping("/devicecmd")
200 - public void handleCmd(String SN, @RequestBody String data, HttpServletResponse response) { 199 + public void handleCmd(String SN, @RequestBody String data, HttpServletResponse response){
201 //判断data 清空map 200 //判断data 清空map
202 List<String> cmdList = cmdMap.get(SN); 201 List<String> cmdList = cmdMap.get(SN);
203 String[] returnList = data.split("\n"); 202 String[] returnList = data.split("\n");
204 - if (returnList.length > 0 && cmdList.size() > 0) {  
205 - for (String message : returnList) {  
206 - String number = message.substring(message.indexOf("=") + 1, message.indexOf("&"));  
207 - String result = message.substring(message.indexOf("=", message.indexOf("&")) + 1, message.indexOf("&", message.indexOf("&") + 1));  
208 - if (result.equals("0")) { 203 + if(returnList.length > 0 && cmdList.size() > 0){
  204 + for(String message : returnList){
  205 + String number = message.substring(message.indexOf("=")+1,message.indexOf("&"));
  206 + String result = message.substring(message.indexOf("=",message.indexOf("&"))+1,message.indexOf("&",message.indexOf("&")+1));
  207 + if(result.equals("0")){
209 Iterator<String> it = cmdList.iterator(); 208 Iterator<String> it = cmdList.iterator();
210 while (((Iterator) it).hasNext()) { 209 while (((Iterator) it).hasNext()) {
211 String b = it.next(); 210 String b = it.next();
212 - if (b.contains("C:" + number)) {  
213 - Log_orderSuccess.info("指令成功==========" + b); 211 + if (b.contains("C:"+number)) {
  212 + Log_orderSuccess.info("指令成功=========="+b);
214 it.remove(); 213 it.remove();
215 } 214 }
216 } 215 }
@@ -233,46 +232,50 @@ public class AttPushController { @@ -233,46 +232,50 @@ public class AttPushController {
233 request.setCharacterEncoding("gbk"); 232 request.setCharacterEncoding("gbk");
234 String data = ""; 233 String data = "";
235 ByteArrayOutputStream bos = null; 234 ByteArrayOutputStream bos = null;
236 - byte[] b = new byte[1024]; 235 + byte[] b= new byte[1024];
237 try { 236 try {
238 InputStream is = request.getInputStream(); 237 InputStream is = request.getInputStream();
239 bos = new ByteArrayOutputStream(); 238 bos = new ByteArrayOutputStream();
240 int len = 0; 239 int len = 0;
241 - while ((len = is.read(b)) != -1) {  
242 - bos.write(b, 0, len); 240 + while((len=is.read(b))!=-1){
  241 + bos.write(b,0,len);
243 } 242 }
244 - data = new String(bos.toByteArray(), "gbk"); 243 + data = new String(bos.toByteArray(),"gbk");
245 } catch (IOException e) { 244 } catch (IOException e) {
246 e.printStackTrace(); 245 e.printStackTrace();
247 } 246 }
248 - if ("ATTLOG".equals(table)) { 247 + if("ATTLOG".equals(table)){
249 String[] list = data.split("\t"); 248 String[] list = data.split("\t");
250 String cardNo = scFeign.selectStudentNumByStudentId(Integer.valueOf(list[0])); 249 String cardNo = scFeign.selectStudentNumByStudentId(Integer.valueOf(list[0]));
251 - cardNo = new BigInteger(cardNo, 16).toString();  
252 - //考勤日志  
253 - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
254 - String info = String.format("<AttendanceInfo submitTime=\"%s\"><Info device=\"%s\" card=\"%s\" operTime=\"%s\" direc=\"%s\"></Info></AttendanceInfo>",  
255 - simpleDateFormat.format(new Date()), SN, cardNo, list[1], "-1");  
256 - AttendanceInfoBean attendanceInfoBean = new AttendanceInfoBean();  
257 - attendanceInfoBean.setInfo(info);  
258 - attendanceInfoBean.setIsControl(0);  
259 - attendanceInfoBean.setPwd(pwd);  
260 - attendanceInfoBean.setUsername(account); 250 + if(StringUtils.isNotBlank(cardNo)){
  251 + String cardNo10 = new BigInteger(cardNo, 16).toString();
  252 + //考勤日志
  253 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  254 + String info = String.format("<AttendanceInfo submitTime=\"%s\"><Info device=\"%s\" card=\"%s\" operTime=\"%s\" direc=\"%s\"></Info></AttendanceInfo>",
  255 + simpleDateFormat.format(new Date()), SN, cardNo10, list[1], "-1");
  256 + AttendanceInfoBean attendanceInfoBean = new AttendanceInfoBean();
  257 + attendanceInfoBean.setInfo(info);
  258 + attendanceInfoBean.setIsControl(0);
  259 + attendanceInfoBean.setPwd(pwd);
  260 + attendanceInfoBean.setUsername(account);
261 261
262 - String jsonResult = JSON.toJSONString(attendanceInfoBean);  
263 - String urlHXY = "http://campus.myjxt.com/api/XiaoAnCommon/SendHXY";  
264 - JSONObject jsonObject = HttpClientUtils.httpPostJson(urlHXY, jsonResult);  
265 - if ((int) jsonObject.get("status") == 1) {  
266 - Log_kaoInfo.info("出入寝签到成功:" + SN + " 卡号:" + cardNo);  
267 - } else {  
268 - Log_orderFail.info("出入寝签到失败:" + SN + " 卡号:" + cardNo + " result1:" + jsonObject.toJSONString()); 262 + String jsonResult = JSON.toJSONString(attendanceInfoBean);
  263 + String urlHXY = "http://campus.myjxt.com/api/XiaoAnCommon/SendHXY";
  264 + JSONObject jsonObject = HttpClientUtils.httpPostJson(urlHXY, jsonResult);
  265 + if ((int) jsonObject.get("status") == 1){
  266 + Log_kaoInfo.info("出入寝签到成功:" + SN + " 卡号:" + cardNo);
  267 + }else {
  268 + Log_orderFail.info("出入寝签到失败:" + SN + " 卡号:" + cardNo + " result1:" + jsonObject.toJSONString());
  269 + }
  270 + }else {
  271 + System.out.println(cardNo);
269 } 272 }
270 } 273 }
271 - if ("OPERLOG".equals(table)) { 274 + if("OPERLOG".equals(table)){
272 //操作日志 275 //操作日志
273 - if (data.substring(0, 3).contains("FP")) { 276 + if(data.substring(0,3).contains("FP")){
274 //添加指纹 277 //添加指纹
275 - String studentId = data.substring(data.indexOf("=") + 1, data.indexOf("\t", data.indexOf("="))); 278 + String studentId = data.substring(data.indexOf("=")+1,data.indexOf("\t",data.indexOf("=")));
276 String order = data.substring(3); 279 String order = data.substring(3);
277 FingerDto fingerDto = new FingerDto(); 280 FingerDto fingerDto = new FingerDto();
278 fingerDto.setOrderMsg(order); 281 fingerDto.setOrderMsg(order);
@@ -288,16 +291,40 @@ public class AttPushController { @@ -288,16 +291,40 @@ public class AttPushController {
288 } 291 }
289 } 292 }
290 293
  294 + public static void main(String[] args){
  295 + String cardNo = "FF013E0F" ;
  296 + String SN = "A4JS174260624" ;
  297 + String cardNo10 = new BigInteger(cardNo, 16).toString();
  298 + //考勤日志
  299 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  300 + String info = String.format("<AttendanceInfo submitTime=\"%s\"><Info device=\"%s\" card=\"%s\" operTime=\"%s\" direc=\"%s\"></Info></AttendanceInfo>",
  301 + simpleDateFormat.format(new Date()), SN, cardNo10, DateUtils.date2String(new Date(),DateUtils.format2), "-1");
  302 + AttendanceInfoBean attendanceInfoBean = new AttendanceInfoBean();
  303 + attendanceInfoBean.setInfo(info);
  304 + attendanceInfoBean.setIsControl(0);
  305 + attendanceInfoBean.setPwd(pwd);
  306 + attendanceInfoBean.setUsername(account);
  307 +
  308 + String jsonResult = JSON.toJSONString(attendanceInfoBean);
  309 + String urlHXY = "http://campus.myjxt.com/api/XiaoAnCommon/SendHXY";
  310 + JSONObject jsonObject = HttpClientUtils.httpPostJson(urlHXY, jsonResult);
  311 + if ((int) jsonObject.get("status") == 1){
  312 + Log_kaoInfo.info("出入寝签到成功:" + SN + " 卡号:" + cardNo);
  313 + }else {
  314 + Log_orderFail.info("出入寝签到失败:" + SN + " 卡号:" + cardNo + " result1:" + jsonObject.toJSONString());
  315 + }
  316 + }
  317 +
  318 +
291 /** 319 /**
292 * 设备通电以后连接到服务器,需要返回的初始化参数 320 * 设备通电以后连接到服务器,需要返回的初始化参数
293 - *  
294 * @param sn 321 * @param sn
295 * @param PushOptionsFlag 322 * @param PushOptionsFlag
296 * @return 323 * @return
297 */ 324 */
298 - private String initOptions(String sn, String PushOptionsFlag) { 325 + private String initOptions(String sn,String PushOptionsFlag) {
299 StringBuffer devOptions = new StringBuffer(); 326 StringBuffer devOptions = new StringBuffer();
300 - devOptions.append("GET OPTION FROM: " + sn); 327 + devOptions.append("GET OPTION FROM: "+sn);
301 // + "\nStamp=" + devInfo.devInfoJson.getString("Stamp") 328 // + "\nStamp=" + devInfo.devInfoJson.getString("Stamp")
302 devOptions.append("\nATTLOGStamp=0"); 329 devOptions.append("\nATTLOGStamp=0");
303 devOptions.append("\nOPERLOGStamp=0"); 330 devOptions.append("\nOPERLOGStamp=0");
@@ -321,8 +348,9 @@ public class AttPushController { @@ -321,8 +348,9 @@ public class AttPushController {
321 // 11 工作号码 348 // 11 工作号码
322 // 12 比对照片 349 // 12 比对照片
323 devOptions.append("\nTransFlag=111111111111");// 1-12二进制位 分别代表以上含义 350 devOptions.append("\nTransFlag=111111111111");// 1-12二进制位 分别代表以上含义
324 - System.out.println("PushOptionsFlag=============" + PushOptionsFlag);  
325 - if (PushOptionsFlag != null && PushOptionsFlag.equals("1")) { 351 + System.out.println("PushOptionsFlag============="+PushOptionsFlag);
  352 + if (PushOptionsFlag!=null&&PushOptionsFlag.equals("1"))
  353 + {
326 // 支持参数单独获取的才要把需要获取的参数回传给设备 modifeid by max 20170926 354 // 支持参数单独获取的才要把需要获取的参数回传给设备 modifeid by max 20170926
327 devOptions.append("\nPushOptions=RegDeviceType,FingerFunOn,FaceFunOn,FPVersion,FaceVersion,NetworkType,HardwareId3,HardwareId5,HardwareId56,LicenseStatus3,LicenseStatus5,LicenseStatus56"); 355 devOptions.append("\nPushOptions=RegDeviceType,FingerFunOn,FaceFunOn,FPVersion,FaceVersion,NetworkType,HardwareId3,HardwareId5,HardwareId56,LicenseStatus3,LicenseStatus5,LicenseStatus56");
328 } 356 }