Commit 7a375a4f2ac9dfadd0b00605573e6a2ea9ab7a1c
1 parent
d847e886
Exists in
master
智能校卫 告警服务
Showing
43 changed files
with
800 additions
and
17 deletions
Show diff stats
cloud/common/src/main/java/com/sincere/common/dto/smartCampus/SchoolDto.java
| ... | ... | @@ -11,6 +11,15 @@ public class SchoolDto implements Serializable { |
| 11 | 11 | |
| 12 | 12 | private int schoolId ; |
| 13 | 13 | private String schoolName ; |
| 14 | + private int managerUserId ; | |
| 15 | + | |
| 16 | + public int getManagerUserId() { | |
| 17 | + return managerUserId; | |
| 18 | + } | |
| 19 | + | |
| 20 | + public void setManagerUserId(int managerUserId) { | |
| 21 | + this.managerUserId = managerUserId; | |
| 22 | + } | |
| 14 | 23 | |
| 15 | 24 | public int getSchoolId() { |
| 16 | 25 | return schoolId; | ... | ... |
cloud/quartz/src/main/java/com/sincere/quartz/QuartzApplication.java
| ... | ... | @@ -3,19 +3,24 @@ package com.sincere.quartz; |
| 3 | 3 | import org.mybatis.spring.annotation.MapperScan; |
| 4 | 4 | import org.springframework.boot.SpringApplication; |
| 5 | 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| 6 | +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; | |
| 7 | +import org.springframework.cache.annotation.EnableCaching; | |
| 6 | 8 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; |
| 7 | 9 | import org.springframework.cloud.openfeign.EnableFeignClients; |
| 8 | 10 | import org.springframework.scheduling.annotation.EnableScheduling; |
| 11 | +import org.springframework.transaction.annotation.EnableTransactionManagement; | |
| 9 | 12 | |
| 10 | 13 | /** |
| 11 | 14 | * @author chen |
| 12 | 15 | * @version 1.0 |
| 13 | 16 | * @date 2019/11/27 0027 14:24 |
| 14 | 17 | */ |
| 18 | +@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) | |
| 19 | +@EnableTransactionManagement(order = 2) //设置事务执行顺序(需要在切换数据源之后,否则只走主库) | |
| 20 | +@EnableCaching | |
| 15 | 21 | @EnableScheduling |
| 16 | 22 | @EnableFeignClients(basePackages = "com.sincere.quartz.feign") |
| 17 | 23 | @EnableEurekaClient |
| 18 | -@SpringBootApplication | |
| 19 | 24 | @MapperScan("com.sincere.quartz.mapper") |
| 20 | 25 | public class QuartzApplication { |
| 21 | 26 | ... | ... |
cloud/quartz/src/main/java/com/sincere/quartz/datasource/DataSourceAspect.java
0 → 100644
| ... | ... | @@ -0,0 +1,43 @@ |
| 1 | +package com.sincere.quartz.datasource; | |
| 2 | + | |
| 3 | +import org.aspectj.lang.JoinPoint; | |
| 4 | +import org.aspectj.lang.annotation.Aspect; | |
| 5 | +import org.aspectj.lang.annotation.Before; | |
| 6 | +import org.aspectj.lang.annotation.Pointcut; | |
| 7 | +import org.aspectj.lang.reflect.MethodSignature; | |
| 8 | +import org.springframework.core.annotation.Order; | |
| 9 | +import org.springframework.stereotype.Component; | |
| 10 | + | |
| 11 | +import java.lang.reflect.Method; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * AOP根据注解给上下文赋值 | |
| 15 | + */ | |
| 16 | +@Aspect | |
| 17 | +@Order(1) //设置AOP执行顺序(需要在事务之前,否则事务只发生在默认库中) | |
| 18 | +@Component | |
| 19 | +public class DataSourceAspect { | |
| 20 | + | |
| 21 | + //切点 | |
| 22 | + @Pointcut("execution(* com.sincere.quartz.service..*.*(..)))") | |
| 23 | + public void aspect() { } | |
| 24 | + | |
| 25 | + @Before("aspect()") | |
| 26 | + private void before(JoinPoint point) { | |
| 27 | + Object target = point.getTarget(); | |
| 28 | + String method = point.getSignature().getName(); | |
| 29 | + Class<?> classz = target.getClass(); | |
| 30 | + Class<?>[] parameterTypes = ((MethodSignature) point.getSignature()) | |
| 31 | + .getMethod().getParameterTypes(); | |
| 32 | + try { | |
| 33 | + Method m = classz.getMethod(method, parameterTypes); | |
| 34 | + if (m != null && m.isAnnotationPresent(MyDataSource.class)) { | |
| 35 | + MyDataSource data = m.getAnnotation(MyDataSource.class); | |
| 36 | + JdbcContextHolder.putDataSource(data.value().getName()); | |
| 37 | + } | |
| 38 | + } catch (Exception e) { | |
| 39 | + e.printStackTrace(); | |
| 40 | + } | |
| 41 | + | |
| 42 | + } | |
| 43 | +} | ... | ... |
cloud/quartz/src/main/java/com/sincere/quartz/datasource/DataSourceConfig.java
0 → 100644
| ... | ... | @@ -0,0 +1,49 @@ |
| 1 | +package com.sincere.quartz.datasource; | |
| 2 | + | |
| 3 | +import org.springframework.boot.context.properties.ConfigurationProperties; | |
| 4 | +import org.springframework.boot.jdbc.DataSourceBuilder; | |
| 5 | +import org.springframework.context.annotation.Bean; | |
| 6 | +import org.springframework.context.annotation.Configuration; | |
| 7 | +import org.springframework.context.annotation.Primary; | |
| 8 | + | |
| 9 | +import javax.sql.DataSource; | |
| 10 | +import java.util.HashMap; | |
| 11 | +import java.util.Map; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * 数据源配置 | |
| 15 | + * | |
| 16 | + */ | |
| 17 | +@Configuration | |
| 18 | +public class DataSourceConfig { | |
| 19 | + | |
| 20 | + @Bean(name = "master") | |
| 21 | + @ConfigurationProperties(prefix = "datasource.master") | |
| 22 | + public DataSource dataSource1() { | |
| 23 | + return DataSourceBuilder.create().build(); | |
| 24 | + } | |
| 25 | + | |
| 26 | + @Bean(name = "slave") | |
| 27 | + @ConfigurationProperties(prefix = "datasource.slave") | |
| 28 | + public DataSource dataSource2() { | |
| 29 | + return DataSourceBuilder.create().build(); | |
| 30 | + } | |
| 31 | + | |
| 32 | + | |
| 33 | + @Bean(name="dynamicDataSource") | |
| 34 | + @Primary //优先使用,多数据源 | |
| 35 | + public DataSource dataSource() { | |
| 36 | + DynamicDataSource dynamicDataSource = new DynamicDataSource(); | |
| 37 | + DataSource master = dataSource1(); | |
| 38 | + DataSource slave = dataSource2(); | |
| 39 | + //设置默认数据源 | |
| 40 | + dynamicDataSource.setDefaultTargetDataSource(master); | |
| 41 | + //配置多数据源 | |
| 42 | + Map<Object,Object> map = new HashMap<>(); | |
| 43 | + map.put(DataSourceType.Master.getName(), master); //key需要跟ThreadLocal中的值对应 | |
| 44 | + map.put(DataSourceType.Slave.getName(), slave); | |
| 45 | + dynamicDataSource.setTargetDataSources(map); | |
| 46 | + return dynamicDataSource; | |
| 47 | + } | |
| 48 | + | |
| 49 | +} | ... | ... |
cloud/quartz/src/main/java/com/sincere/quartz/datasource/DataSourceType.java
0 → 100644
| ... | ... | @@ -0,0 +1,23 @@ |
| 1 | +package com.sincere.quartz.datasource; | |
| 2 | + | |
| 3 | +public enum DataSourceType { | |
| 4 | + | |
| 5 | + Master("master"), | |
| 6 | + | |
| 7 | + Slave("slave"); | |
| 8 | + | |
| 9 | + | |
| 10 | + private String name; | |
| 11 | + | |
| 12 | + private DataSourceType(String name) { | |
| 13 | + this.name = name; | |
| 14 | + } | |
| 15 | + | |
| 16 | + public String getName() { | |
| 17 | + return name; | |
| 18 | + } | |
| 19 | + | |
| 20 | + public void setName(String name) { | |
| 21 | + this.name = name; | |
| 22 | + } | |
| 23 | +} | ... | ... |
cloud/quartz/src/main/java/com/sincere/quartz/datasource/DynamicDataSource.java
0 → 100644
| ... | ... | @@ -0,0 +1,20 @@ |
| 1 | +package com.sincere.quartz.datasource; | |
| 2 | + | |
| 3 | +import org.slf4j.Logger; | |
| 4 | +import org.slf4j.LoggerFactory; | |
| 5 | +import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * | |
| 9 | + */ | |
| 10 | +public class DynamicDataSource extends AbstractRoutingDataSource { | |
| 11 | + | |
| 12 | + private Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 13 | + | |
| 14 | + @Override | |
| 15 | + protected Object determineCurrentLookupKey() { | |
| 16 | + logger.info("数据源为{}",JdbcContextHolder.getDataSource()); | |
| 17 | + return JdbcContextHolder.getDataSource(); | |
| 18 | + } | |
| 19 | + | |
| 20 | +} | |
| 0 | 21 | \ No newline at end of file | ... | ... |
cloud/quartz/src/main/java/com/sincere/quartz/datasource/JdbcContextHolder.java
0 → 100644
| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | +package com.sincere.quartz.datasource; | |
| 2 | +/** | |
| 3 | + */ | |
| 4 | +public class JdbcContextHolder { | |
| 5 | + | |
| 6 | + private final static ThreadLocal<String> local = new ThreadLocal<>(); | |
| 7 | + | |
| 8 | + public static void putDataSource(String name) { | |
| 9 | + local.set(name); | |
| 10 | + } | |
| 11 | + | |
| 12 | + public static String getDataSource() { | |
| 13 | + return local.get(); | |
| 14 | + } | |
| 15 | + | |
| 16 | +} | |
| 0 | 17 | \ No newline at end of file | ... | ... |
cloud/quartz/src/main/java/com/sincere/quartz/datasource/MyDataSource.java
0 → 100644
| ... | ... | @@ -0,0 +1,17 @@ |
| 1 | +package com.sincere.quartz.datasource; | |
| 2 | + | |
| 3 | +import java.lang.annotation.ElementType; | |
| 4 | +import java.lang.annotation.Retention; | |
| 5 | +import java.lang.annotation.RetentionPolicy; | |
| 6 | +import java.lang.annotation.Target; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * 数据源选择--自定义注解 | |
| 10 | + */ | |
| 11 | +@Retention(RetentionPolicy.RUNTIME) | |
| 12 | +@Target(ElementType.METHOD) | |
| 13 | +public @interface MyDataSource { | |
| 14 | + | |
| 15 | + DataSourceType value() default DataSourceType.Master; //默认主表 | |
| 16 | + | |
| 17 | +} | ... | ... |
cloud/quartz/src/main/java/com/sincere/quartz/feign/ScFeign.java
| ... | ... | @@ -7,9 +7,7 @@ import org.springframework.web.bind.annotation.RequestMapping; |
| 7 | 7 | import org.springframework.web.bind.annotation.RequestMethod; |
| 8 | 8 | import org.springframework.web.bind.annotation.RequestParam; |
| 9 | 9 | |
| 10 | -import java.util.HashMap; | |
| 11 | 10 | import java.util.List; |
| 12 | -import java.util.Map; | |
| 13 | 11 | |
| 14 | 12 | /** |
| 15 | 13 | * @author chen |
| ... | ... | @@ -19,10 +17,26 @@ import java.util.Map; |
| 19 | 17 | @FeignClient("smartCampusSearch") |
| 20 | 18 | public interface ScFeign { |
| 21 | 19 | |
| 20 | + @RequestMapping(value = "/sm/wg/selectSchoolBySchoolId",method = RequestMethod.GET) | |
| 21 | + SchoolDto selectSchoolBySchoolId(@RequestParam("schoolId") int schoolId); | |
| 22 | + | |
| 23 | + //考勤设备 | |
| 24 | + @RequestMapping(value = "attendance/selectCloudAttendance", method = RequestMethod.GET) | |
| 25 | + List<Integer> selectCloudAttendance(); | |
| 26 | + | |
| 27 | + @RequestMapping(value = "attendance/selectCloudAttendanceBySchoolId", method = RequestMethod.GET) | |
| 28 | + List<SZ_AttendanceDto> selectCloudAttendanceBySchoolId(@RequestParam("schoolId") int schoolId); | |
| 29 | + | |
| 30 | + @RequestMapping(value = "attendance/selectByDeviceNo", method = RequestMethod.GET) | |
| 31 | + String selectByDeviceNo(@RequestParam("deviceNo") String deviceNo); | |
| 32 | + | |
| 22 | 33 | //考勤推送 |
| 23 | 34 | @RequestMapping(value = "/sm/kq/getAllTemplate",method = RequestMethod.GET) |
| 24 | 35 | List<TemplateDto> getAllTemplate(); |
| 25 | 36 | |
| 37 | + @RequestMapping(value = "/sm/kq/getAllTemplateAlarm",method = RequestMethod.GET) | |
| 38 | + List<TemplateDto> getAllTemplateAlarm(); | |
| 39 | + | |
| 26 | 40 | @RequestMapping(value = "/sm/kq/getTeacherList",method = RequestMethod.GET) |
| 27 | 41 | List<KqTeacherDto> getTeacherList(@RequestParam("schoolId")int schoolId); |
| 28 | 42 | |
| ... | ... | @@ -35,6 +49,8 @@ public interface ScFeign { |
| 35 | 49 | @RequestMapping(value = "/sm/kq/getThirdId",method = RequestMethod.GET) |
| 36 | 50 | String getThirdId(@RequestParam("userId")String userId , @RequestParam("type") int type); |
| 37 | 51 | |
| 52 | + @RequestMapping(value = "/sm/kq/selectClassBySchoolId",method = RequestMethod.GET) | |
| 53 | + List<Integer> selectClassBySchoolId(@RequestParam("schoolId") int schoolId); | |
| 38 | 54 | |
| 39 | 55 | //关注绑定推送 |
| 40 | 56 | @RequestMapping(value = "/sm/rp/selectBindPushSchool",method = RequestMethod.GET) | ... | ... |
cloud/quartz/src/main/java/com/sincere/quartz/job/AlarmJob.java
0 → 100644
| ... | ... | @@ -0,0 +1,169 @@ |
| 1 | +package com.sincere.quartz.job; | |
| 2 | + | |
| 3 | +import com.alibaba.fastjson.JSONArray; | |
| 4 | +import com.alibaba.fastjson.JSONObject; | |
| 5 | +import com.sincere.common.dto.smartCampus.SZ_AttendanceDto; | |
| 6 | +import com.sincere.common.dto.smartCampus.SchoolDto; | |
| 7 | +import com.sincere.common.util.DateUtils; | |
| 8 | +import com.sincere.common.util.HttpClientUtils; | |
| 9 | +import com.sincere.quartz.feign.ScFeign; | |
| 10 | +import com.sincere.quartz.model.ShortMsg; | |
| 11 | +import com.sincere.quartz.service.ManagerService; | |
| 12 | +import com.sincere.quartz.service.SmsService; | |
| 13 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 14 | +import org.springframework.scheduling.annotation.Scheduled; | |
| 15 | +import org.springframework.stereotype.Service; | |
| 16 | + | |
| 17 | +import java.util.ArrayList; | |
| 18 | +import java.util.Date; | |
| 19 | +import java.util.List; | |
| 20 | + | |
| 21 | +/** | |
| 22 | + * @author chen | |
| 23 | + * @version 1.0 | |
| 24 | + * @date 2020/1/3 0003 10:02 | |
| 25 | + */ | |
| 26 | +@Service | |
| 27 | +public class AlarmJob { | |
| 28 | + | |
| 29 | + @Autowired | |
| 30 | + ScFeign scFeign; | |
| 31 | + | |
| 32 | + @Autowired | |
| 33 | + SmsService smsService; | |
| 34 | + | |
| 35 | + @Autowired | |
| 36 | + ManagerService managerService ; | |
| 37 | + | |
| 38 | + private static List<String> opexList ; | |
| 39 | + private static String integration ; | |
| 40 | + | |
| 41 | + static{ | |
| 42 | + opexList = new ArrayList<>(); | |
| 43 | + opexList.add("15857566147"); //王汉栋 | |
| 44 | + opexList.add("13858485977"); //王楠彬 | |
| 45 | + | |
| 46 | + integration = "18767117554" ; //林炜 | |
| 47 | + } | |
| 48 | + | |
| 49 | + /** | |
| 50 | + * 设备掉线 | |
| 51 | + */ | |
| 52 | + @Scheduled(cron = "0 0 6-18 * * ? ") | |
| 53 | + public void attendanceAlarm(){ | |
| 54 | + List<Integer> list = scFeign.selectCloudAttendance(); | |
| 55 | + for(Integer schoolId : list){ | |
| 56 | + if(schoolId != 0 && schoolId != 16){ | |
| 57 | + SchoolDto schoolDto = scFeign.selectSchoolBySchoolId(schoolId); | |
| 58 | + List<String> weigengList = new ArrayList<>(); | |
| 59 | + List<String> faceList = new ArrayList<>(); | |
| 60 | + List<SZ_AttendanceDto> attendanceList = scFeign.selectCloudAttendanceBySchoolId(schoolId); | |
| 61 | + for(SZ_AttendanceDto attendanceDto : attendanceList){ | |
| 62 | + if(attendanceDto.getClint_type().equals("6")){ | |
| 63 | + //微耕,查询另一张表 | |
| 64 | + String lastDate = scFeign.selectByDeviceNo(attendanceDto.getClint_id()); | |
| 65 | + if(lastDate != null){ | |
| 66 | + if(DateUtils.getDateDifference(new Date(),DateUtils.string2Date(lastDate,DateUtils.format2),"s") > 20){ | |
| 67 | + weigengList.add(attendanceDto.getClint_id()); | |
| 68 | + } | |
| 69 | + } | |
| 70 | + }else { | |
| 71 | + //人脸 | |
| 72 | + if(attendanceDto.getIsConnection() == 0){ | |
| 73 | + faceList.add(attendanceDto.getClint_id()); } | |
| 74 | + } | |
| 75 | + } | |
| 76 | + if(weigengList.size() + faceList.size() > 0){ | |
| 77 | + //有设备掉线,发送短信 | |
| 78 | + String msg = "【设备掉线预警】" + schoolDto.getSchoolName() + "!" ; | |
| 79 | + if(weigengList.size() > 0){ | |
| 80 | + msg += weigengList.size() + "台闸机掉线。" ; | |
| 81 | + } | |
| 82 | + if(faceList.size() > 0){ | |
| 83 | + msg += faceList.size() + "台人脸机掉线。" ; | |
| 84 | + } | |
| 85 | + msg += "请关注。" ; | |
| 86 | + try{ | |
| 87 | + sendMessage(schoolDto.getSchoolId(),opexList.get(0),msg); | |
| 88 | + sendMessage(schoolDto.getSchoolId(),opexList.get(1),msg); | |
| 89 | + sendMessage(schoolDto.getSchoolId(),integration,msg); | |
| 90 | + sendMessage(schoolDto.getSchoolId(),managerService.selectManagerById(schoolDto.getManagerUserId()),msg); | |
| 91 | + }catch (Exception e){ | |
| 92 | + e.printStackTrace(); | |
| 93 | + } | |
| 94 | + } | |
| 95 | + } | |
| 96 | + } | |
| 97 | + } | |
| 98 | + | |
| 99 | + | |
| 100 | + /** | |
| 101 | + * 卡 脸未下发 | |
| 102 | + */ | |
| 103 | + @Scheduled(cron = "0 0 12,18 * * ? ") | |
| 104 | + public void unPush(){ | |
| 105 | + List<Integer> list = scFeign.selectCloudAttendance(); | |
| 106 | + for(Integer schoolId : list) { | |
| 107 | + if(schoolId != 0 && schoolId != 16){ | |
| 108 | + SchoolDto schoolDto = scFeign.selectSchoolBySchoolId(schoolId); | |
| 109 | + JSONObject schoolResult = getCount(schoolDto); | |
| 110 | + int cardStudentCount = Integer.valueOf( schoolResult.get("studentCardCount").toString() ); | |
| 111 | + int successStudentCardCount = Integer.valueOf( schoolResult.get("successStudentCardCount").toString() ); | |
| 112 | + int fushuCardCount = Integer.valueOf( schoolResult.get("fushuCardCount").toString() ); | |
| 113 | + int successFushuCardCount = Integer.valueOf( schoolResult.get("successFushuCardCount").toString() ); | |
| 114 | + int teaCardCount = Integer.valueOf( schoolResult.get("teaCardCount").toString() ); | |
| 115 | + int successTeaCardCount = Integer.valueOf( schoolResult.get("successTeaCardCount").toString() ); | |
| 116 | + int totalCardNumber = cardStudentCount + fushuCardCount +teaCardCount ; | |
| 117 | + int successCardNumber = successFushuCardCount +successStudentCardCount +successTeaCardCount ; | |
| 118 | + int unSendCard = totalCardNumber-successCardNumber ; | |
| 119 | + | |
| 120 | + int errorStudentPhotoCount = Integer.valueOf( schoolResult.get("errorStudentPhotoCount").toString() ); | |
| 121 | + int errorFushuPhotoCount = Integer.valueOf( schoolResult.get("errorFushuPhotoCount").toString() ); | |
| 122 | + int errorTeaPhotoCount = Integer.valueOf( schoolResult.get("errorTeaPhotoCount").toString() ); | |
| 123 | + int unSendFace = errorStudentPhotoCount+errorFushuPhotoCount+errorTeaPhotoCount ; | |
| 124 | + if(unSendCard + unSendFace > 0) { | |
| 125 | + String msg = "【人脸卡号下发异常预警】" + schoolDto.getSchoolName() + "!"; | |
| 126 | + if (unSendCard > 0) { | |
| 127 | + msg += unSendCard + "卡未下发。"; | |
| 128 | + } | |
| 129 | + if (unSendFace > 0) { | |
| 130 | + msg += unSendFace + "脸未下发。"; | |
| 131 | + } | |
| 132 | + msg += "请关注。"; | |
| 133 | + try { | |
| 134 | + sendMessage(schoolDto.getSchoolId(),opexList.get(0),msg); | |
| 135 | + sendMessage(schoolDto.getSchoolId(),opexList.get(1),msg); | |
| 136 | + sendMessage(schoolDto.getSchoolId(),integration,msg); | |
| 137 | + sendMessage(schoolDto.getSchoolId(),managerService.selectManagerById(schoolDto.getManagerUserId()),msg); | |
| 138 | + } catch (Exception e) { | |
| 139 | + e.printStackTrace(); | |
| 140 | + } | |
| 141 | + } | |
| 142 | + } | |
| 143 | + } | |
| 144 | + } | |
| 145 | + | |
| 146 | + | |
| 147 | + public JSONObject getCount(SchoolDto schoolDto){ | |
| 148 | + JSONObject object = new JSONObject(); | |
| 149 | + object.put("schoolName",schoolDto.getSchoolName()); | |
| 150 | + object.put("pageIndex",1); | |
| 151 | + object.put("pageSize",1); | |
| 152 | + JSONObject result = HttpClientUtils.httpPostJson("http://campus.myjxt.com/api/GateServiceManager/GetFacePhotoList",object.toJSONString()); | |
| 153 | + JSONObject data = (JSONObject) result.get("data"); | |
| 154 | + JSONArray array = (JSONArray) data.get("list"); | |
| 155 | + | |
| 156 | + JSONObject schoolResult = (JSONObject) array.get(0); | |
| 157 | + return schoolResult ; | |
| 158 | + } | |
| 159 | + | |
| 160 | + private void sendMessage(int schoolId , String mobile , String msg){ | |
| 161 | + String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format); | |
| 162 | + ShortMsg shortMsg = new ShortMsg(); | |
| 163 | + shortMsg.setTableName("smsNew"+tableSuffix); | |
| 164 | + shortMsg.setSchoolId(schoolId); | |
| 165 | + shortMsg.setMobile(mobile); | |
| 166 | + shortMsg.setMsg(msg); | |
| 167 | + smsService.insertSMS(shortMsg); | |
| 168 | + } | |
| 169 | +} | ... | ... |
cloud/quartz/src/main/java/com/sincere/quartz/job/BindPushJob.java
| ... | ... | @@ -5,8 +5,8 @@ import com.sincere.common.dto.smartCampus.ParentDto; |
| 5 | 5 | import com.sincere.common.enums.PushTypeEnums; |
| 6 | 6 | import com.sincere.common.util.DateUtils; |
| 7 | 7 | import com.sincere.quartz.feign.ScFeign; |
| 8 | -import com.sincere.quartz.mapper.SmsMapper; | |
| 9 | 8 | import com.sincere.quartz.model.ShortMsg; |
| 9 | +import com.sincere.quartz.service.SmsService; | |
| 10 | 10 | import org.apache.commons.lang3.StringUtils; |
| 11 | 11 | import org.slf4j.Logger; |
| 12 | 12 | import org.slf4j.LoggerFactory; |
| ... | ... | @@ -14,7 +14,10 @@ import org.springframework.beans.factory.annotation.Autowired; |
| 14 | 14 | import org.springframework.scheduling.annotation.Scheduled; |
| 15 | 15 | import org.springframework.stereotype.Service; |
| 16 | 16 | |
| 17 | -import java.util.*; | |
| 17 | +import java.util.Date; | |
| 18 | +import java.util.HashMap; | |
| 19 | +import java.util.List; | |
| 20 | +import java.util.Map; | |
| 18 | 21 | |
| 19 | 22 | /** |
| 20 | 23 | * 用户注册激活提醒 |
| ... | ... | @@ -32,7 +35,7 @@ public class BindPushJob { |
| 32 | 35 | ScFeign scFeign; |
| 33 | 36 | |
| 34 | 37 | @Autowired |
| 35 | - SmsMapper smsMapper; | |
| 38 | + SmsService smsService; | |
| 36 | 39 | |
| 37 | 40 | private static Map<String , String> intervalDaysMap = new HashMap<>(); //redis 持久化 替换 可避免重启导致间隔的错误 |
| 38 | 41 | |
| ... | ... | @@ -84,7 +87,7 @@ public class BindPushJob { |
| 84 | 87 | shortMsg.setSchoolId(parentDto.getSchoolId()); |
| 85 | 88 | shortMsg.setMobile(parentDto.getMobile()); |
| 86 | 89 | shortMsg.setMsg(message); |
| 87 | - smsMapper.insertSMS(shortMsg); | |
| 90 | + smsService.insertSMS(shortMsg); | |
| 88 | 91 | logger.info("----学校Id---"+parentDto.getSchoolId() + "----手机号----"+parentDto.getMobile()+"---"+message); |
| 89 | 92 | } |
| 90 | 93 | } | ... | ... |
cloud/quartz/src/main/java/com/sincere/quartz/job/KQJob.java
| ... | ... | @@ -9,9 +9,11 @@ import com.sincere.common.util.HttpClientUtils; |
| 9 | 9 | import com.sincere.quartz.enums.KqTypeEnums; |
| 10 | 10 | import com.sincere.quartz.enums.TypeEnums; |
| 11 | 11 | import com.sincere.quartz.feign.ScFeign; |
| 12 | -import com.sincere.quartz.mapper.SmsMapper; | |
| 13 | 12 | import com.sincere.quartz.model.DingSms; |
| 13 | +import com.sincere.quartz.model.ShortMsg; | |
| 14 | 14 | import com.sincere.quartz.model.WeChatSms; |
| 15 | +import com.sincere.quartz.service.ManagerService; | |
| 16 | +import com.sincere.quartz.service.SmsService; | |
| 15 | 17 | import org.apache.commons.lang3.StringUtils; |
| 16 | 18 | import org.slf4j.Logger; |
| 17 | 19 | import org.slf4j.LoggerFactory; |
| ... | ... | @@ -19,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
| 19 | 21 | import org.springframework.scheduling.annotation.Scheduled; |
| 20 | 22 | import org.springframework.stereotype.Service; |
| 21 | 23 | |
| 24 | +import java.math.BigDecimal; | |
| 22 | 25 | import java.util.*; |
| 23 | 26 | |
| 24 | 27 | /** |
| ... | ... | @@ -37,10 +40,28 @@ public class KQJob { |
| 37 | 40 | ScFeign scFeign ; |
| 38 | 41 | |
| 39 | 42 | @Autowired |
| 40 | - SmsMapper smsMapper; | |
| 43 | + SmsService smsService; | |
| 44 | + | |
| 45 | + @Autowired | |
| 46 | + ManagerService managerService ; | |
| 41 | 47 | |
| 42 | 48 | private static String date ; |
| 43 | - private static Map<String , String> map = new HashMap<>(); | |
| 49 | + private static Map<String , String> map = new HashMap<>(); //学校 考勤推送map | |
| 50 | + | |
| 51 | + private static String alarmDate ; | |
| 52 | + private static Map<String , String> alarmMap = new HashMap<>(); //考勤告警推送map | |
| 53 | + private static Map<String , BigDecimal> templateMap = new HashMap<>(); // 考勤比例 | |
| 54 | + | |
| 55 | + private static List<String> opexList ; | |
| 56 | + private static String integration ; | |
| 57 | + | |
| 58 | + static{ | |
| 59 | + opexList = new ArrayList<>(); | |
| 60 | + opexList.add("15857566147"); //王汉栋 | |
| 61 | + opexList.add("13858485977"); //王楠彬 | |
| 62 | + | |
| 63 | + integration = "18767117554" ; //林炜 | |
| 64 | + } | |
| 44 | 65 | |
| 45 | 66 | @Scheduled(cron = "0 0-59 * * * ? ") |
| 46 | 67 | public void kaoQing() { |
| ... | ... | @@ -77,6 +98,90 @@ public class KQJob { |
| 77 | 98 | } |
| 78 | 99 | } |
| 79 | 100 | |
| 101 | + @Scheduled(cron = "0 0 18 * * MON-FRI") | |
| 102 | + public void alarmKaoQing() { | |
| 103 | + String now = DateUtils.date2String(new Date(),DateUtils.format1) ; | |
| 104 | + if(StringUtils.isBlank(alarmDate)){ | |
| 105 | + initAlarmMap(); | |
| 106 | + alarmDate = now ; | |
| 107 | + } | |
| 108 | + if(!DateUtils.date2String(new Date(),DateUtils.format1).equals(alarmDate)){ | |
| 109 | + initAlarmMap(); | |
| 110 | + alarmDate = DateUtils.date2String(new Date(),DateUtils.format1) ; | |
| 111 | + } | |
| 112 | + //开始过滤数据 推送 | |
| 113 | + List<String> keyList = new ArrayList<>(); | |
| 114 | + for(Map.Entry<String, String> entity : alarmMap.entrySet()){ | |
| 115 | + String endTime = entity.getValue().split("_")[1]; | |
| 116 | + if(DateUtils.getDateDifference(new Date(),DateUtils.string2Date(now+" "+endTime+":00",DateUtils.format2),"m")>=2 | |
| 117 | + ){ | |
| 118 | + String key = entity.getKey(); | |
| 119 | + keyList.add(key); | |
| 120 | + alarm(entity); | |
| 121 | + } | |
| 122 | + } | |
| 123 | + for(String key : keyList){ | |
| 124 | + map.remove(key); | |
| 125 | + } | |
| 126 | + } | |
| 127 | + | |
| 128 | + private void initAlarmMap(){ | |
| 129 | + alarmMap = new HashMap<>(); | |
| 130 | + List<TemplateDto> list = scFeign.getAllTemplateAlarm(); | |
| 131 | + logger.info(("------考勤告警模板------")); | |
| 132 | + for(TemplateDto templateDto : list){ | |
| 133 | + String config = templateDto.getConfig(); | |
| 134 | + String[] array = config.split("<Template"); | |
| 135 | + for(int i = 1 ; i<array.length ;i++){ | |
| 136 | + try{ | |
| 137 | + String msg = array[i]; | |
| 138 | + String beginTime = msg.substring(msg.indexOf("BeginTime")+11,msg.indexOf("BeginTime")+16); | |
| 139 | + String endTime = msg.substring(msg.indexOf("EndTime")+9,msg.indexOf("EndTime")+14); | |
| 140 | + String templateId = msg.substring(msg.indexOf("TemplateID")+12,msg.indexOf("TemplateID")+22); | |
| 141 | + String Week = msg.substring(msg.indexOf("Week")+6,msg.indexOf("Week")+19); | |
| 142 | + String type = msg.substring(msg.indexOf("Type")+6,msg.indexOf("Type")+8); | |
| 143 | + type = type.replace("\"",""); | |
| 144 | + int nowWeek = DateUtils.getWeek() ; | |
| 145 | + if(Week.contains(nowWeek+"") && nowWeek != 1 && nowWeek != 7 ){ //周末不告警 | |
| 146 | + logger.info((templateId+"_"+templateDto.getSchoolId()+"------"+beginTime+"_"+endTime)); | |
| 147 | + alarmMap.put(templateId+"_"+templateDto.getSchoolId() , beginTime+"_"+endTime+"_"+type+"_"+templateDto.getId()); | |
| 148 | + } | |
| 149 | + }catch (Exception e){ | |
| 150 | + e.printStackTrace(); | |
| 151 | + } | |
| 152 | + } | |
| 153 | + } | |
| 154 | + } | |
| 155 | + | |
| 156 | + //告警推送 | |
| 157 | + private void alarm(Map.Entry<String,String> entry){ | |
| 158 | + String templateId = entry.getKey().split("_")[0] ; | |
| 159 | + String schoolId = entry.getKey().split("_")[1] ; | |
| 160 | + String id = entry.getValue().split("_")[3]; | |
| 161 | + String type = entry.getValue().split("_")[2] ; | |
| 162 | + if(DateUtils.getWeek() == 3 || DateUtils.getWeek() == 6){ | |
| 163 | + //可以相差40% | |
| 164 | + BigDecimal percent = getAlarmCensus(Integer.valueOf(id),templateId,Integer.valueOf(schoolId),Integer.valueOf(type)); | |
| 165 | + if(templateMap.get(templateId) != null){ | |
| 166 | + if(percent.subtract(templateMap.get(templateId)).compareTo(new BigDecimal(0.4)) > 0 | |
| 167 | + || templateMap.get(templateId).subtract(percent).compareTo(new BigDecimal(0.4)) > 0) { | |
| 168 | + alarmPush(Integer.valueOf(schoolId)); | |
| 169 | + } | |
| 170 | + } | |
| 171 | + templateMap.put(templateId,percent); | |
| 172 | + }else { | |
| 173 | + //相差30% | |
| 174 | + BigDecimal percent = getAlarmCensus(Integer.valueOf(id),templateId,Integer.valueOf(schoolId),Integer.valueOf(type)); | |
| 175 | + if(templateMap.get(templateId) != null){ | |
| 176 | + if(percent.subtract(templateMap.get(templateId)).compareTo(new BigDecimal(0.3)) > 0 | |
| 177 | + || templateMap.get(templateId).subtract(percent).compareTo(new BigDecimal(0.3)) > 0) { | |
| 178 | + alarmPush(Integer.valueOf(schoolId)); | |
| 179 | + } | |
| 180 | + } | |
| 181 | + templateMap.put(templateId,percent); | |
| 182 | + } | |
| 183 | + } | |
| 184 | + | |
| 80 | 185 | //初始化要推送的模板 |
| 81 | 186 | private void initMap(){ |
| 82 | 187 | map = new HashMap<>(); |
| ... | ... | @@ -316,9 +421,28 @@ public class KQJob { |
| 316 | 421 | return list ; |
| 317 | 422 | } |
| 318 | 423 | |
| 424 | + private BigDecimal getAlarmCensus(int id , String templateId ,int schoolId , int type){ | |
| 425 | + int allNumber = 0 , attendNumber = 0 ; | |
| 426 | + List<Integer> list = scFeign.selectClassBySchoolId(schoolId); | |
| 427 | + for(Integer classId : list){ | |
| 428 | + String url = "http://campus.myjxt.com/api/EasyN/GeAttendDetail?classId="+classId+ | |
| 429 | + "&id="+id+"&templateID="+templateId+"&type="+type+"&time=" + DateUtils.date2String(new Date(),DateUtils.format1); | |
| 430 | + JSONObject jsonObject = HttpClientUtils.httpGet(url); | |
| 431 | + try{ | |
| 432 | + JSONObject data = (JSONObject) jsonObject.get("data"); | |
| 433 | + attendNumber = attendNumber + (Integer) data.get("stuAttendCount"); | |
| 434 | + allNumber = allNumber + (Integer) data.get("stuCount"); | |
| 435 | + }catch (Exception e){ | |
| 436 | + e.printStackTrace(); | |
| 437 | + } | |
| 438 | + } | |
| 439 | + return new BigDecimal(attendNumber).divide(new BigDecimal(allNumber)) ; | |
| 440 | + } | |
| 441 | + | |
| 442 | + | |
| 319 | 443 | private void insertDing(DingSms dingSms){ |
| 320 | 444 | try{ |
| 321 | - smsMapper.insertDing(dingSms); | |
| 445 | + smsService.insertDing(dingSms); | |
| 322 | 446 | }catch (Exception e){ |
| 323 | 447 | logger.info(e.toString()); |
| 324 | 448 | } |
| ... | ... | @@ -326,9 +450,34 @@ public class KQJob { |
| 326 | 450 | |
| 327 | 451 | private void insertQYH(WeChatSms weChatSms){ |
| 328 | 452 | try{ |
| 329 | - smsMapper.insertWeChat(weChatSms); | |
| 453 | + smsService.insertWeChat(weChatSms); | |
| 330 | 454 | }catch (Exception e){ |
| 331 | 455 | logger.info(e.toString()); |
| 332 | 456 | } |
| 333 | 457 | } |
| 458 | + | |
| 459 | + private void alarmPush(int schoolId){ | |
| 460 | + String msg = "【考勤异动】" ; | |
| 461 | + try{ | |
| 462 | + SchoolDto schoolDto = scFeign.selectSchoolBySchoolId(schoolId); | |
| 463 | + msg += schoolDto.getSchoolName() + "考勤有异动,请关注!" ; | |
| 464 | + sendMessage(schoolDto.getSchoolId(),opexList.get(0),msg); | |
| 465 | + sendMessage(schoolDto.getSchoolId(),opexList.get(1),msg); | |
| 466 | + sendMessage(schoolDto.getSchoolId(),integration,msg); | |
| 467 | + sendMessage(schoolDto.getSchoolId(),managerService.selectManagerById(schoolDto.getManagerUserId()),msg); | |
| 468 | + }catch (Exception e){ | |
| 469 | + e.printStackTrace(); | |
| 470 | + } | |
| 471 | + | |
| 472 | + } | |
| 473 | + | |
| 474 | + private void sendMessage(int schoolId , String mobile , String msg){ | |
| 475 | + String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format); | |
| 476 | + ShortMsg shortMsg = new ShortMsg(); | |
| 477 | + shortMsg.setTableName("smsNew"+tableSuffix); | |
| 478 | + shortMsg.setSchoolId(schoolId); | |
| 479 | + shortMsg.setMobile(mobile); | |
| 480 | + shortMsg.setMsg(msg); | |
| 481 | + smsService.insertSMS(shortMsg); | |
| 482 | + } | |
| 334 | 483 | } | ... | ... |
cloud/quartz/src/main/java/com/sincere/quartz/job/SyncJob.java
| ... | ... | @@ -20,11 +20,11 @@ public class SyncJob { |
| 20 | 20 | @Autowired |
| 21 | 21 | YXYReadService yxyReadService ; |
| 22 | 22 | |
| 23 | - @Scheduled(cron = "0 1-59 * * * ? ") | |
| 23 | + //@Scheduled(cron = "0/1 * * * * ? ") | |
| 24 | 24 | //@Scheduled(cron = "0 0 23 * * ? ") |
| 25 | 25 | public void Sync(){ |
| 26 | 26 | //翼校通的同步 之后还有钉钉的同步等等 |
| 27 | - yxyWriteService.sync(); | |
| 27 | + //yxyWriteService.sync(); | |
| 28 | 28 | yxyReadService.sync(); |
| 29 | 29 | } |
| 30 | 30 | } | ... | ... |
cloud/quartz/src/main/java/com/sincere/quartz/mapper/ManagerMapper.java
0 → 100644
cloud/quartz/src/main/java/com/sincere/quartz/service/ManagerService.java
0 → 100644
cloud/quartz/src/main/java/com/sincere/quartz/service/SmsService.java
0 → 100644
| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | +package com.sincere.quartz.service; | |
| 2 | + | |
| 3 | +import com.sincere.quartz.model.DingSms; | |
| 4 | +import com.sincere.quartz.model.ShortMsg; | |
| 5 | +import com.sincere.quartz.model.WeChatSms; | |
| 6 | + | |
| 7 | +public interface SmsService { | |
| 8 | + | |
| 9 | + int insertDing(DingSms dingSms); | |
| 10 | + | |
| 11 | + int insertWeChat(WeChatSms weChatSms); | |
| 12 | + | |
| 13 | + int insertSMS(ShortMsg shortMsg); | |
| 14 | +} | ... | ... |
cloud/quartz/src/main/java/com/sincere/quartz/service/impl/ManagerServiceImpl.java
0 → 100644
| ... | ... | @@ -0,0 +1,21 @@ |
| 1 | +package com.sincere.quartz.service.impl; | |
| 2 | + | |
| 3 | +import com.sincere.quartz.datasource.DataSourceType; | |
| 4 | +import com.sincere.quartz.datasource.MyDataSource; | |
| 5 | +import com.sincere.quartz.mapper.ManagerMapper; | |
| 6 | +import com.sincere.quartz.service.ManagerService; | |
| 7 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 8 | +import org.springframework.stereotype.Service; | |
| 9 | + | |
| 10 | +@Service | |
| 11 | +public class ManagerServiceImpl implements ManagerService { | |
| 12 | + | |
| 13 | + @Autowired | |
| 14 | + ManagerMapper managerMapper ; | |
| 15 | + | |
| 16 | + @Override | |
| 17 | + @MyDataSource(DataSourceType.Master) | |
| 18 | + public String selectManagerById(int id) { | |
| 19 | + return managerMapper.selectManagerById(id); | |
| 20 | + } | |
| 21 | +} | ... | ... |
cloud/quartz/src/main/java/com/sincere/quartz/service/impl/SmsServiceImpl.java
0 → 100644
| ... | ... | @@ -0,0 +1,36 @@ |
| 1 | +package com.sincere.quartz.service.impl; | |
| 2 | + | |
| 3 | +import com.sincere.quartz.datasource.DataSourceType; | |
| 4 | +import com.sincere.quartz.datasource.MyDataSource; | |
| 5 | +import com.sincere.quartz.mapper.SmsMapper; | |
| 6 | +import com.sincere.quartz.model.DingSms; | |
| 7 | +import com.sincere.quartz.model.ShortMsg; | |
| 8 | +import com.sincere.quartz.model.WeChatSms; | |
| 9 | +import com.sincere.quartz.service.SmsService; | |
| 10 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 11 | +import org.springframework.stereotype.Service; | |
| 12 | + | |
| 13 | +@Service | |
| 14 | +public class SmsServiceImpl implements SmsService { | |
| 15 | + | |
| 16 | + @Autowired | |
| 17 | + SmsMapper smsMapper; | |
| 18 | + | |
| 19 | + @Override | |
| 20 | + @MyDataSource(DataSourceType.Slave) | |
| 21 | + public int insertDing(DingSms dingSms) { | |
| 22 | + return smsMapper.insertDing(dingSms); | |
| 23 | + } | |
| 24 | + | |
| 25 | + @Override | |
| 26 | + @MyDataSource(DataSourceType.Slave) | |
| 27 | + public int insertWeChat(WeChatSms weChatSms) { | |
| 28 | + return smsMapper.insertWeChat(weChatSms); | |
| 29 | + } | |
| 30 | + | |
| 31 | + @Override | |
| 32 | + @MyDataSource(DataSourceType.Slave) | |
| 33 | + public int insertSMS(ShortMsg shortMsg) { | |
| 34 | + return smsMapper.insertSMS(shortMsg); | |
| 35 | + } | |
| 36 | +} | ... | ... |
cloud/quartz/src/main/resources/application.yaml
| ... | ... | @@ -4,10 +4,17 @@ server: |
| 4 | 4 | spring: |
| 5 | 5 | application: |
| 6 | 6 | name: quartz-server |
| 7 | - datasource: | |
| 7 | + | |
| 8 | +datasource: | |
| 9 | + master: ## 查询 | |
| 10 | + username: szjxtuser | |
| 11 | + password: RQminVCJota3H1u8bBYH | |
| 12 | + jdbcUrl: jdbc:sqlserver://116.62.155.137:33419;database=SmartAdmin | |
| 13 | + driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver | |
| 14 | + slave: ## 短信 | |
| 8 | 15 | username: sa |
| 9 | 16 | password: qaz!@#0401 |
| 10 | - url: jdbc:sqlserver://60.190.202.38:49469;database=XST | |
| 17 | + jdbcUrl: jdbc:sqlserver://60.190.202.38:49469;database=XST | |
| 11 | 18 | driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver |
| 12 | 19 | ##mybatis |
| 13 | 20 | mybatis: | ... | ... |
cloud/quartz/src/main/resources/mapper/ManagerMapper.xml
0 → 100644
| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | +<?xml version="1.0" encoding="UTF-8" ?> | |
| 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.ManagerMapper"> | |
| 4 | + | |
| 5 | + <select id="selectManagerById" parameterType="java.lang.Integer" resultType="java.lang.String"> | |
| 6 | + select phone from SZ_Manager where ID = #{id} | |
| 7 | + </select> | |
| 8 | + | |
| 9 | +</mapper> | ... | ... |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/controller/AttendanceController.java
| 1 | 1 | package com.sincere.smartSearch.controller; |
| 2 | 2 | |
| 3 | 3 | import com.sincere.common.dto.smartCampus.SZ_AttendanceDto; |
| 4 | +import com.sincere.common.util.DateUtils; | |
| 4 | 5 | import com.sincere.smartSearch.service.AttendacenService; |
| 6 | +import com.sincere.smartSearch.service.DeviceService; | |
| 5 | 7 | import io.swagger.annotations.Api; |
| 6 | 8 | import io.swagger.annotations.ApiOperation; |
| 7 | 9 | import org.apache.ibatis.annotations.Param; |
| 8 | 10 | import org.springframework.beans.factory.annotation.Autowired; |
| 9 | 11 | import org.springframework.web.bind.annotation.*; |
| 10 | 12 | |
| 13 | +import java.util.Date; | |
| 11 | 14 | import java.util.List; |
| 12 | 15 | |
| 13 | 16 | @RestController |
| ... | ... | @@ -18,6 +21,9 @@ public class AttendanceController { |
| 18 | 21 | @Autowired |
| 19 | 22 | AttendacenService attendacenService; |
| 20 | 23 | |
| 24 | + @Autowired | |
| 25 | + DeviceService deviceService; | |
| 26 | + | |
| 21 | 27 | @RequestMapping(method = RequestMethod.GET, value = "selectAttendaceWithId") |
| 22 | 28 | public SZ_AttendanceDto selectAttendaceWithId(@RequestParam("clint_id") String clint_id) { |
| 23 | 29 | return attendacenService.selectDevice(clint_id); |
| ... | ... | @@ -45,4 +51,25 @@ public class AttendanceController { |
| 45 | 51 | List<String> selectRoomAttendance(@RequestParam("placeId") int placeId){ |
| 46 | 52 | return attendacenService.selectRoomAttendance(placeId); |
| 47 | 53 | } |
| 54 | + | |
| 55 | + @RequestMapping(value = "selectCloudAttendance", method = RequestMethod.GET) | |
| 56 | + List<Integer> selectCloudAttendance(){ | |
| 57 | + return attendacenService.selectCloudAttendance(); | |
| 58 | + } | |
| 59 | + | |
| 60 | + @RequestMapping(value = "selectCloudAttendanceBySchoolId", method = RequestMethod.GET) | |
| 61 | + List<SZ_AttendanceDto> selectCloudAttendanceBySchoolId(@RequestParam("schoolId") int schoolId){ | |
| 62 | + return attendacenService.selectCloudAttendanceBySchoolId(schoolId); | |
| 63 | + } | |
| 64 | + | |
| 65 | + | |
| 66 | + @RequestMapping(value = "selectByDeviceNo", method = RequestMethod.GET) | |
| 67 | + String selectByDeviceNo(@RequestParam("deviceNo") String deviceNo){ | |
| 68 | + Date date = deviceService.selectByDeviceNo(deviceNo) ; | |
| 69 | + if(date == null){ | |
| 70 | + return null ; | |
| 71 | + }else { | |
| 72 | + return DateUtils.date2String(date,DateUtils.format2); | |
| 73 | + } | |
| 74 | + } | |
| 48 | 75 | } | ... | ... |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/controller/KqController.java
| ... | ... | @@ -36,6 +36,20 @@ public class KqController { |
| 36 | 36 | return templateDtos; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | + @RequestMapping(value = "getAllTemplateAlarm",method = RequestMethod.GET) | |
| 40 | + public List<TemplateDto> getAllTemplateAlarm(){ | |
| 41 | + List<KqTemplate> list = kqService.selectAllKqTemplate(); | |
| 42 | + List<TemplateDto> templateDtos = new ArrayList<>(); | |
| 43 | + for(KqTemplate kqTemplate : list){ | |
| 44 | + TemplateDto templateDto = new TemplateDto(); | |
| 45 | + templateDto.setId(kqTemplate.getId()); | |
| 46 | + templateDto.setConfig(kqTemplate.getConfig()); | |
| 47 | + templateDto.setSchoolId(kqTemplate.getSchoolId()); | |
| 48 | + templateDtos.add(templateDto); | |
| 49 | + } | |
| 50 | + return templateDtos; | |
| 51 | + } | |
| 52 | + | |
| 39 | 53 | |
| 40 | 54 | @RequestMapping(value = "getTeacherList",method = RequestMethod.GET) |
| 41 | 55 | public List<KqTeacherDto> getTeacherList(@RequestParam("schoolId")int schoolId){ |
| ... | ... | @@ -62,4 +76,9 @@ public class KqController { |
| 62 | 76 | map.put("type",type+""); |
| 63 | 77 | return kqService.selectThirdId(map); |
| 64 | 78 | } |
| 79 | + | |
| 80 | + @RequestMapping(value = "selectClassBySchoolId",method = RequestMethod.GET) | |
| 81 | + List<Integer> selectClassBySchoolId(@RequestParam("schoolId") int schoolId){ | |
| 82 | + return kqService.selectClassBySchoolId(schoolId); | |
| 83 | + } | |
| 65 | 84 | } | ... | ... |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/controller/WgController.java
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/mapper/AttendaceMapper.java
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/mapper/DeviceMapper.java
| ... | ... | @@ -3,6 +3,8 @@ package com.sincere.smartSearch.mapper; |
| 3 | 3 | import com.sincere.smartSearch.model.DeviceLink; |
| 4 | 4 | import com.sincere.smartSearch.model.DeviceOrder; |
| 5 | 5 | |
| 6 | +import java.util.Date; | |
| 7 | + | |
| 6 | 8 | /** |
| 7 | 9 | * @author chen |
| 8 | 10 | * @version 1.0 |
| ... | ... | @@ -15,4 +17,6 @@ public interface DeviceMapper { |
| 15 | 17 | int insertLink(DeviceLink deviceLink); |
| 16 | 18 | |
| 17 | 19 | String selectOutOrderId(DeviceOrder deviceOrder); |
| 20 | + | |
| 21 | + Date selectByDeviceNo(String deviceNo); | |
| 18 | 22 | } | ... | ... |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/mapper/KqTemplateMapper.java
| ... | ... | @@ -18,6 +18,8 @@ public interface KqTemplateMapper { |
| 18 | 18 | |
| 19 | 19 | List<KqTemplate> selectKqTemplate(); |
| 20 | 20 | |
| 21 | + List<KqTemplate> selectAllKqTemplate(); | |
| 22 | + | |
| 21 | 23 | List<KqTeacherDto> selectSchoolTeacher(int schoolId); |
| 22 | 24 | |
| 23 | 25 | List<KqTeacherDto> selectChamberTeacher(int schoolId); |
| ... | ... | @@ -26,4 +28,6 @@ public interface KqTemplateMapper { |
| 26 | 28 | |
| 27 | 29 | String selectThirdId(Map<String,String> map); |
| 28 | 30 | |
| 31 | + List<Integer> selectClassBySchoolId(int schoolId); | |
| 32 | + | |
| 29 | 33 | } | ... | ... |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/model/School.java
| ... | ... | @@ -9,6 +9,15 @@ public class School { |
| 9 | 9 | |
| 10 | 10 | private int schoolId ; |
| 11 | 11 | private String schoolName ; |
| 12 | + private int managerUserId ; | |
| 13 | + | |
| 14 | + public int getManagerUserId() { | |
| 15 | + return managerUserId; | |
| 16 | + } | |
| 17 | + | |
| 18 | + public void setManagerUserId(int managerUserId) { | |
| 19 | + this.managerUserId = managerUserId; | |
| 20 | + } | |
| 12 | 21 | |
| 13 | 22 | public int getSchoolId() { |
| 14 | 23 | return schoolId; | ... | ... |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/service/AttendacenService.java
| ... | ... | @@ -18,4 +18,8 @@ public interface AttendacenService { |
| 18 | 18 | int updateAttendance(String client_id); |
| 19 | 19 | |
| 20 | 20 | List<String> selectRoomAttendance(int placeId); |
| 21 | + | |
| 22 | + List<Integer> selectCloudAttendance(); | |
| 23 | + | |
| 24 | + List<SZ_AttendanceDto> selectCloudAttendanceBySchoolId(int schoolId); | |
| 21 | 25 | } | ... | ... |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/service/DeviceService.java
| 1 | 1 | package com.sincere.smartSearch.service; |
| 2 | 2 | |
| 3 | +import java.util.Date; | |
| 4 | + | |
| 3 | 5 | /** |
| 4 | 6 | * @author chen |
| 5 | 7 | * @version 1.0 |
| ... | ... | @@ -12,4 +14,6 @@ public interface DeviceService { |
| 12 | 14 | |
| 13 | 15 | String selectOutOrderId(int type, int insideOrderId); |
| 14 | 16 | |
| 17 | + | |
| 18 | + Date selectByDeviceNo(String deviceNo); | |
| 15 | 19 | } | ... | ... |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/service/KqService.java
| ... | ... | @@ -18,6 +18,8 @@ public interface KqService { |
| 18 | 18 | |
| 19 | 19 | List<KqTemplate> selectKqTemplate(); |
| 20 | 20 | |
| 21 | + List<KqTemplate> selectAllKqTemplate(); | |
| 22 | + | |
| 21 | 23 | List<KqTeacherDto> selectSchoolTeacher(int schoolId); |
| 22 | 24 | |
| 23 | 25 | List<KqTeacherDto> selectChamberTeacher(int schoolId); |
| ... | ... | @@ -25,4 +27,6 @@ public interface KqService { |
| 25 | 27 | AppDto selectApp(Map<String,Integer> map); |
| 26 | 28 | |
| 27 | 29 | String selectThirdId(Map<String,String> map); |
| 30 | + | |
| 31 | + List<Integer> selectClassBySchoolId(int schoolId); | |
| 28 | 32 | } | ... | ... |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/service/impl/AttendacenServiceImp.java
| ... | ... | @@ -39,4 +39,14 @@ public class AttendacenServiceImp implements AttendacenService { |
| 39 | 39 | public List<String> selectRoomAttendance(int placeId) { |
| 40 | 40 | return attendaceMapper.selectRoomAttendance(placeId); |
| 41 | 41 | } |
| 42 | + | |
| 43 | + @Override | |
| 44 | + public List<Integer> selectCloudAttendance() { | |
| 45 | + return attendaceMapper.selectCloudAttendance(); | |
| 46 | + } | |
| 47 | + | |
| 48 | + @Override | |
| 49 | + public List<SZ_AttendanceDto> selectCloudAttendanceBySchoolId(int schoolId) { | |
| 50 | + return attendaceMapper.selectCloudAttendanceBySchoolId(schoolId); | |
| 51 | + } | |
| 42 | 52 | } | ... | ... |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/service/impl/DeviceServiceImpl.java
| ... | ... | @@ -40,4 +40,9 @@ public class DeviceServiceImpl implements DeviceService { |
| 40 | 40 | deviceOrder.setInsideOrderId(insideOrderId); |
| 41 | 41 | return deviceMapper.selectOutOrderId(deviceOrder); |
| 42 | 42 | } |
| 43 | + | |
| 44 | + @Override | |
| 45 | + public Date selectByDeviceNo(String deviceNo) { | |
| 46 | + return deviceMapper.selectByDeviceNo(deviceNo); | |
| 47 | + } | |
| 43 | 48 | } | ... | ... |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/service/impl/KqServiceImpl.java
| ... | ... | @@ -31,6 +31,11 @@ public class KqServiceImpl implements KqService { |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | @Override |
| 34 | + public List<KqTemplate> selectAllKqTemplate() { | |
| 35 | + return kqTemplateMapper.selectAllKqTemplate(); | |
| 36 | + } | |
| 37 | + | |
| 38 | + @Override | |
| 34 | 39 | public List<KqTeacherDto> selectSchoolTeacher(int schoolId) { |
| 35 | 40 | return kqTemplateMapper.selectSchoolTeacher(schoolId); |
| 36 | 41 | } |
| ... | ... | @@ -49,4 +54,9 @@ public class KqServiceImpl implements KqService { |
| 49 | 54 | public String selectThirdId(Map<String, String> map) { |
| 50 | 55 | return kqTemplateMapper.selectThirdId(map); |
| 51 | 56 | } |
| 57 | + | |
| 58 | + @Override | |
| 59 | + public List<Integer> selectClassBySchoolId(int schoolId) { | |
| 60 | + return kqTemplateMapper.selectClassBySchoolId(schoolId); | |
| 61 | + } | |
| 52 | 62 | } | ... | ... |
cloud/search_smartCampus/src/main/resources/mapper/AttendanceMapper.xml
| ... | ... | @@ -42,4 +42,11 @@ |
| 42 | 42 | select KaoQinAttendance from XA_PlaceAttendance where PlaceId = #{placeId} |
| 43 | 43 | </select> |
| 44 | 44 | |
| 45 | + <select id="selectCloudAttendance" resultType="java.lang.Integer"> | |
| 46 | + select DISTINCT school_id from SZ_Attendance where school_id != -1 and ( clint_type = 18 or clint_type = 22 or clint_id like '253%' ) | |
| 47 | + </select> | |
| 48 | + | |
| 49 | + <select id="selectCloudAttendanceBySchoolId" parameterType="java.lang.Integer" resultMap="BaseResultMap"> | |
| 50 | + select * from SZ_Attendance where school_id = #{schoolId} and ( clint_type = 18 or clint_type = 22 or clint_id like '253%' ) | |
| 51 | + </select> | |
| 45 | 52 | </mapper> | ... | ... |
cloud/search_smartCampus/src/main/resources/mapper/DeviceMapper.xml
| ... | ... | @@ -14,4 +14,8 @@ |
| 14 | 14 | <select id="selectOutOrderId" parameterType="com.sincere.smartSearch.model.DeviceOrder" resultType="java.lang.String"> |
| 15 | 15 | select OutsideOrderID from AC_DeviceOrder where Type = #{type} and InsideOrderID = #{insideOrderId} |
| 16 | 16 | </select> |
| 17 | + | |
| 18 | + <select id="selectByDeviceNo" parameterType="java.lang.String" resultType="java.util.Date"> | |
| 19 | + select LastTime from AC_DeviceLink where DeviceNo = #{deviceNo} | |
| 20 | + </select> | |
| 17 | 21 | </mapper> |
| 18 | 22 | \ No newline at end of file | ... | ... |
cloud/search_smartCampus/src/main/resources/mapper/KqTemplateMapper.xml
| ... | ... | @@ -17,6 +17,11 @@ |
| 17 | 17 | and SZ_School.IsPush =1 |
| 18 | 18 | </select> |
| 19 | 19 | |
| 20 | + <select id="selectAllKqTemplate" resultMap="TemplateMap"> | |
| 21 | + select XA_KqTemplate.Id , XA_KqTemplate.config , XA_KqTemplate.SchoolId from XA_KqTemplate | |
| 22 | + where XA_KqTemplate.State = 1 and XA_KqTemplate.TType = 1 | |
| 23 | + </select> | |
| 24 | + | |
| 20 | 25 | <resultMap id="TeacherMap" type="com.sincere.common.dto.smartCampus.KqTeacherDto"> |
| 21 | 26 | <result column="user_id" property="userId"/> |
| 22 | 27 | <result column="school_id" property="schoolId"/> |
| ... | ... | @@ -55,4 +60,8 @@ |
| 55 | 60 | <select id="selectThirdId" parameterType="java.util.Map" resultType="java.lang.String"> |
| 56 | 61 | select top 1 DQuserId from EM_QyDingUser where HxyUserId = #{userId} and State = 1 and QyType = #{type} |
| 57 | 62 | </select> |
| 63 | + | |
| 64 | + <select id="selectClassBySchoolId" parameterType="java.lang.Integer" resultType="java.lang.Integer"> | |
| 65 | + select class_id from SZ_Class where school_id = #{schoolId} and state=1 and is_finish=0 | |
| 66 | + </select> | |
| 58 | 67 | </mapper> | ... | ... |
cloud/search_smartCampus/src/main/resources/mapper/WgUserSearchMapper.xml
| ... | ... | @@ -10,11 +10,12 @@ |
| 10 | 10 | |
| 11 | 11 | <resultMap id="School" type="com.sincere.smartSearch.model.School" > |
| 12 | 12 | <result column="school_id" property="schoolId" jdbcType="INTEGER" /> |
| 13 | + <result column="manageuser_id" property="managerUserId" jdbcType="INTEGER" /> | |
| 13 | 14 | <result column="school_name" property="schoolName" jdbcType="VARCHAR" /> |
| 14 | 15 | </resultMap> |
| 15 | 16 | |
| 16 | 17 | <select id="selectSchoolBySchoolId" parameterType="java.lang.Integer" resultMap="School"> |
| 17 | - select school_id , school_name from SZ_School where school_id = #{schoolId} | |
| 18 | + select school_id , school_name , manageuser_id from SZ_School where school_id = #{schoolId} | |
| 18 | 19 | </select> |
| 19 | 20 | |
| 20 | 21 | ... | ... |
cloud/search_xiaoan/src/main/java/com/sincere/xiaoanSearch/controller/WgController.java
| ... | ... | @@ -96,4 +96,14 @@ public class WgController { |
| 96 | 96 | } |
| 97 | 97 | return sendMessageDto ; |
| 98 | 98 | } |
| 99 | + | |
| 100 | + @RequestMapping(value = "selectCountByDeviceNo",method = RequestMethod.GET) | |
| 101 | + int selectCountByDeviceNo(@RequestParam("deviceId") String deviceId){ | |
| 102 | + return wgService.selectCountByDeviceNo(deviceId); | |
| 103 | + } | |
| 104 | + | |
| 105 | + @RequestMapping(value = "selectCountByDaceDeviceNo",method = RequestMethod.GET) | |
| 106 | + int selectCountByDaceDeviceNo(@RequestParam("deviceId") String deviceId){ | |
| 107 | + return wgService.selectCountByDaceDeviceNo(deviceId); | |
| 108 | + } | |
| 99 | 109 | } | ... | ... |
cloud/search_xiaoan/src/main/java/com/sincere/xiaoanSearch/mapper/WgResultMapper.java
cloud/search_xiaoan/src/main/java/com/sincere/xiaoanSearch/service/WgService.java
cloud/search_xiaoan/src/main/java/com/sincere/xiaoanSearch/service/impl/WgServiceImpl.java
| ... | ... | @@ -98,4 +98,14 @@ public class WgServiceImpl implements WgService { |
| 98 | 98 | public int updateSendSuccess(SendSuccess sendSuccess) { |
| 99 | 99 | return wgResultMapper.updateSendSuccess(sendSuccess); |
| 100 | 100 | } |
| 101 | + | |
| 102 | + @Override | |
| 103 | + public int selectCountByDeviceNo(String deviceId) { | |
| 104 | + return wgResultMapper.selectCountByDeviceNo(deviceId); | |
| 105 | + } | |
| 106 | + | |
| 107 | + @Override | |
| 108 | + public int selectCountByDaceDeviceNo(String deviceId) { | |
| 109 | + return wgResultMapper.selectCountByDaceDeviceNo(deviceId); | |
| 110 | + } | |
| 101 | 111 | } | ... | ... |
cloud/search_xiaoan/src/main/resources/mapper/WgResultMapper.xml
| ... | ... | @@ -35,4 +35,12 @@ |
| 35 | 35 | <delete id="deleteSendFail" parameterType="com.sincere.xiaoanSearch.model.SendFail"> |
| 36 | 36 | delete WG_SendFail where deviceID = #{deviceId} and cardNum = #{cardNum} and shiduan=#{shiduan} |
| 37 | 37 | </delete> |
| 38 | + | |
| 39 | + <select id="selectCountByDeviceNo" parameterType="java.lang.String" resultType="java.lang.Integer"> | |
| 40 | + select count(DISTINCT cardNum) from WG_SendSuccess where deviceID = #{deviceId} | |
| 41 | + </select> | |
| 42 | + | |
| 43 | + <select id="selectCountByDaceDeviceNo" parameterType="java.lang.String" resultType="java.lang.Integer"> | |
| 44 | + select count(DISTINCT Num) from Face_SendSuccess where deviceID = #{deviceId} | |
| 45 | + </select> | |
| 38 | 46 | </mapper> |
| 39 | 47 | \ No newline at end of file | ... | ... |
cloud/zkAttendance/src/main/java/com/sincere/att/controller/AttPushController.java
| ... | ... | @@ -14,6 +14,8 @@ import com.sincere.common.dto.smartCampus.SZ_AttendanceDto; |
| 14 | 14 | import com.sincere.common.dto.xiaoan.FingerDto; |
| 15 | 15 | import com.sincere.common.util.DateUtils; |
| 16 | 16 | import com.sincere.common.util.HttpClientUtils; |
| 17 | +import io.swagger.annotations.Api; | |
| 18 | +import io.swagger.annotations.ApiOperation; | |
| 17 | 19 | import org.apache.commons.lang3.StringUtils; |
| 18 | 20 | import org.slf4j.Logger; |
| 19 | 21 | import org.springframework.beans.factory.annotation.Autowired; | ... | ... |