Commit ee86e799ff71c6a83fbe637e8ddfe27913a81006
Exists in
master
合并
Showing
10 changed files
with
403 additions
and
1 deletions
Show diff stats
cloud/dahua/src/main/java/com/example/dahua/bean/CheckIn.java
0 → 100644
| ... | ... | @@ -0,0 +1,74 @@ |
| 1 | +package com.example.dahua.bean; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * @author chen | |
| 5 | + * @version 1.0 | |
| 6 | + * @date 2019/10/30 0030 10:26 | |
| 7 | + */ | |
| 8 | +public class CheckIn { | |
| 9 | + | |
| 10 | + private String deviceId ; | |
| 11 | + private String cardNo ; | |
| 12 | + private int funNo ; | |
| 13 | + private int flag ; | |
| 14 | + private String checkTime ; | |
| 15 | + | |
| 16 | + private String out; | |
| 17 | + private int isSuccess ; | |
| 18 | + | |
| 19 | + public String getDeviceId() { | |
| 20 | + return deviceId; | |
| 21 | + } | |
| 22 | + | |
| 23 | + public void setDeviceId(String deviceId) { | |
| 24 | + this.deviceId = deviceId; | |
| 25 | + } | |
| 26 | + | |
| 27 | + public String getCardNo() { | |
| 28 | + return cardNo; | |
| 29 | + } | |
| 30 | + | |
| 31 | + public void setCardNo(String cardNo) { | |
| 32 | + this.cardNo = cardNo; | |
| 33 | + } | |
| 34 | + | |
| 35 | + public int getFlag() { | |
| 36 | + return flag; | |
| 37 | + } | |
| 38 | + | |
| 39 | + public void setFlag(int flag) { | |
| 40 | + this.flag = flag; | |
| 41 | + } | |
| 42 | + | |
| 43 | + public String getCheckTime() { | |
| 44 | + return checkTime; | |
| 45 | + } | |
| 46 | + | |
| 47 | + public void setCheckTime(String checkTime) { | |
| 48 | + this.checkTime = checkTime; | |
| 49 | + } | |
| 50 | + | |
| 51 | + public String getOut() { | |
| 52 | + return out; | |
| 53 | + } | |
| 54 | + | |
| 55 | + public void setOut(String out) { | |
| 56 | + this.out = out; | |
| 57 | + } | |
| 58 | + | |
| 59 | + public int getIsSuccess() { | |
| 60 | + return isSuccess; | |
| 61 | + } | |
| 62 | + | |
| 63 | + public void setIsSuccess(int isSuccess) { | |
| 64 | + this.isSuccess = isSuccess; | |
| 65 | + } | |
| 66 | + | |
| 67 | + public int getFunNo() { | |
| 68 | + return funNo; | |
| 69 | + } | |
| 70 | + | |
| 71 | + public void setFunNo(int funNo) { | |
| 72 | + this.funNo = funNo; | |
| 73 | + } | |
| 74 | +} | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/bean/Message.java
0 → 100644
| ... | ... | @@ -0,0 +1,31 @@ |
| 1 | +package com.example.dahua.bean; | |
| 2 | + | |
| 3 | +public class Message { | |
| 4 | + private String name ; | |
| 5 | + private int schoolId ; | |
| 6 | + private String parentMobile ; | |
| 7 | + | |
| 8 | + public String getName() { | |
| 9 | + return name; | |
| 10 | + } | |
| 11 | + | |
| 12 | + public void setName(String name) { | |
| 13 | + this.name = name; | |
| 14 | + } | |
| 15 | + | |
| 16 | + public int getSchoolId() { | |
| 17 | + return schoolId; | |
| 18 | + } | |
| 19 | + | |
| 20 | + public void setSchoolId(int schoolId) { | |
| 21 | + this.schoolId = schoolId; | |
| 22 | + } | |
| 23 | + | |
| 24 | + public String getParentMobile() { | |
| 25 | + return parentMobile; | |
| 26 | + } | |
| 27 | + | |
| 28 | + public void setParentMobile(String parentMobile) { | |
| 29 | + this.parentMobile = parentMobile; | |
| 30 | + } | |
| 31 | +} | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/bean/ShortMsg.java
0 → 100644
| ... | ... | @@ -0,0 +1,42 @@ |
| 1 | +package com.example.dahua.bean; | |
| 2 | + | |
| 3 | +public class ShortMsg { | |
| 4 | + | |
| 5 | + private String tableName ; | |
| 6 | + | |
| 7 | + private int schoolId ; | |
| 8 | + private String mobile ; | |
| 9 | + private String msg ; | |
| 10 | + | |
| 11 | + public String getTableName() { | |
| 12 | + return tableName; | |
| 13 | + } | |
| 14 | + | |
| 15 | + public void setTableName(String tableName) { | |
| 16 | + this.tableName = tableName; | |
| 17 | + } | |
| 18 | + | |
| 19 | + public int getSchoolId() { | |
| 20 | + return schoolId; | |
| 21 | + } | |
| 22 | + | |
| 23 | + public void setSchoolId(int schoolId) { | |
| 24 | + this.schoolId = schoolId; | |
| 25 | + } | |
| 26 | + | |
| 27 | + public String getMobile() { | |
| 28 | + return mobile; | |
| 29 | + } | |
| 30 | + | |
| 31 | + public void setMobile(String mobile) { | |
| 32 | + this.mobile = mobile; | |
| 33 | + } | |
| 34 | + | |
| 35 | + public String getMsg() { | |
| 36 | + return msg; | |
| 37 | + } | |
| 38 | + | |
| 39 | + public void setMsg(String msg) { | |
| 40 | + this.msg = msg; | |
| 41 | + } | |
| 42 | +} | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/bean/User.java
0 → 100644
| ... | ... | @@ -0,0 +1,46 @@ |
| 1 | +package com.example.dahua.bean; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * @author chen | |
| 5 | + * @version 1.0 | |
| 6 | + * @date 2019/10/14 0014 14:41 | |
| 7 | + */ | |
| 8 | +public class User { | |
| 9 | + | |
| 10 | + private int schoolId; | |
| 11 | + private int classId ; | |
| 12 | + private String name ; | |
| 13 | + private int studentId ; | |
| 14 | + | |
| 15 | + public int getSchoolId() { | |
| 16 | + return schoolId; | |
| 17 | + } | |
| 18 | + | |
| 19 | + public void setSchoolId(int schoolId) { | |
| 20 | + this.schoolId = schoolId; | |
| 21 | + } | |
| 22 | + | |
| 23 | + public int getClassId() { | |
| 24 | + return classId; | |
| 25 | + } | |
| 26 | + | |
| 27 | + public void setClassId(int classId) { | |
| 28 | + this.classId = classId; | |
| 29 | + } | |
| 30 | + | |
| 31 | + public String getName() { | |
| 32 | + return name; | |
| 33 | + } | |
| 34 | + | |
| 35 | + public void setName(String name) { | |
| 36 | + this.name = name; | |
| 37 | + } | |
| 38 | + | |
| 39 | + public int getStudentId() { | |
| 40 | + return studentId; | |
| 41 | + } | |
| 42 | + | |
| 43 | + public void setStudentId(int studentId) { | |
| 44 | + this.studentId = studentId; | |
| 45 | + } | |
| 46 | +} | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/dao/SearchDao.java
0 → 100644
| ... | ... | @@ -0,0 +1,55 @@ |
| 1 | +package com.example.dahua.dao; | |
| 2 | + | |
| 3 | +import com.example.dahua.bean.CheckIn; | |
| 4 | +import com.example.dahua.bean.Message; | |
| 5 | +import com.example.dahua.bean.User; | |
| 6 | +import org.apache.ibatis.annotations.Param; | |
| 7 | +import org.apache.ibatis.annotations.Select; | |
| 8 | +import org.springframework.stereotype.Repository; | |
| 9 | + | |
| 10 | +import java.util.List; | |
| 11 | + | |
| 12 | +@Repository | |
| 13 | +public interface SearchDao { | |
| 14 | + /** | |
| 15 | + * 考勤推送存储过程 | |
| 16 | + * @param checkIn | |
| 17 | + * @return | |
| 18 | + */ | |
| 19 | + int checkIn(CheckIn checkIn); | |
| 20 | + | |
| 21 | + /** | |
| 22 | + * 获取学生信息 | |
| 23 | + * @param cardNum | |
| 24 | + * @return | |
| 25 | + */ | |
| 26 | + List<User> selectUserByCardNum(String cardNum); | |
| 27 | + | |
| 28 | + /** | |
| 29 | + * 获取卡号 | |
| 30 | + * @param cardNo | |
| 31 | + * @return | |
| 32 | + */ | |
| 33 | + @Select("select Top(1) StudentNum from HS_LeaveExaminePassList where StudentNum= #{cardNo} and GETDATE() <![CDATA[ > ]]> LeaveTime and GETDATE() <![CDATA[ < ]]> ReturnTime") | |
| 34 | + String checkLeave(@Param("cardNo") String cardNo); | |
| 35 | + | |
| 36 | + /** | |
| 37 | + * 获取学生父母电话 | |
| 38 | + * @param cardNo | |
| 39 | + * @return | |
| 40 | + */ | |
| 41 | + @Select("select school_id , ParentMobile , name from SZ_V_School_Student where student_num = #{cardNo}") | |
| 42 | + Message selectByParentMobile(@Param("cardNo") String cardNo); | |
| 43 | + | |
| 44 | + /** | |
| 45 | + * 插入短信发送表 | |
| 46 | + * @param tableName | |
| 47 | + * @param schoolId | |
| 48 | + * @param mobile | |
| 49 | + * @param msg | |
| 50 | + */ | |
| 51 | + @Select("insert into ${tableName} (SchoolID,Mobile,Msg,tdtype,Status,IsNeedSend,SendTime,intime) values (#{schoolId},#{mobile},#{msg},1,0,1,GETDATE(),GETDATE())") | |
| 52 | + void insertMessage(@Param("tableName") String tableName,@Param("schoolId") String schoolId,@Param("mobile") String mobile,@Param("msg") String msg); | |
| 53 | + | |
| 54 | + | |
| 55 | +} | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/dbconfig/MessageDataSourceConfig.java
0 → 100644
| ... | ... | @@ -0,0 +1,43 @@ |
| 1 | +package com.example.dahua.dbconfig; | |
| 2 | + | |
| 3 | +import org.apache.ibatis.session.SqlSessionFactory; | |
| 4 | +import org.mybatis.spring.SqlSessionFactoryBean; | |
| 5 | +import org.mybatis.spring.annotation.MapperScan; | |
| 6 | +import org.springframework.beans.factory.annotation.Qualifier; | |
| 7 | +import org.springframework.boot.context.properties.ConfigurationProperties; | |
| 8 | +import org.springframework.boot.jdbc.DataSourceBuilder; | |
| 9 | +import org.springframework.context.annotation.Bean; | |
| 10 | +import org.springframework.context.annotation.Configuration; | |
| 11 | +import org.springframework.context.annotation.Primary; | |
| 12 | +import org.springframework.core.io.support.PathMatchingResourcePatternResolver; | |
| 13 | +import org.springframework.jdbc.core.JdbcTemplate; | |
| 14 | + | |
| 15 | +import javax.sql.DataSource; | |
| 16 | + | |
| 17 | +@Configuration | |
| 18 | +@MapperScan(basePackages = "com.example.dahua.dao", sqlSessionFactoryRef = "messageSessionFactory") | |
| 19 | +public class MessageDataSourceConfig { | |
| 20 | + @Primary | |
| 21 | + @Bean(name = "messageDataSource") | |
| 22 | + @ConfigurationProperties("spring.datasource.message") | |
| 23 | + public DataSource masterDataSource() { | |
| 24 | + return DataSourceBuilder.create().build(); | |
| 25 | + } | |
| 26 | + | |
| 27 | + @Bean(name = "messageSessionFactory") | |
| 28 | + public SqlSessionFactory sqlSessionFactory(@Qualifier("messageDataSource") DataSource dataSource) throws Exception { | |
| 29 | + | |
| 30 | + SqlSessionFactoryBean sessionFactoryBean = new SqlSessionFactoryBean(); | |
| 31 | + sessionFactoryBean.setDataSource(dataSource); | |
| 32 | + sessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver() | |
| 33 | + .getResources("classpath:mapper/*.xml")); | |
| 34 | + return sessionFactoryBean.getObject(); | |
| 35 | + | |
| 36 | + } | |
| 37 | + | |
| 38 | + @Bean | |
| 39 | + public JdbcTemplate campusJdbcTemplate(@Qualifier("messageDataSource") DataSource dataSource) { | |
| 40 | + return new JdbcTemplate(dataSource); | |
| 41 | + } | |
| 42 | + | |
| 43 | +} | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/utils/DateUtils.java
0 → 100644
| ... | ... | @@ -0,0 +1,71 @@ |
| 1 | +package com.example.dahua.utils; | |
| 2 | + | |
| 3 | +import java.text.ParseException; | |
| 4 | +import java.text.SimpleDateFormat; | |
| 5 | +import java.util.Date; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * @author chen | |
| 9 | + * @version 1.0 | |
| 10 | + * @date 2019/10/14 0014 14:16 | |
| 11 | + */ | |
| 12 | +public class DateUtils { | |
| 13 | + | |
| 14 | + public static String format = "yyyy"; | |
| 15 | + | |
| 16 | + public static String format1 = "yyyy-MM-dd"; | |
| 17 | + | |
| 18 | + public static String format2 = "yyyy-MM-dd HH:mm:ss"; | |
| 19 | + | |
| 20 | + public static String format3 = "yyyyMMddHHmm" ; | |
| 21 | + | |
| 22 | + public static String format4 = "yyyyMM"; | |
| 23 | + | |
| 24 | + public static long getDate(){ | |
| 25 | + return System.currentTimeMillis(); | |
| 26 | + } | |
| 27 | + | |
| 28 | + public static String date2String(Date date, String format) { | |
| 29 | + SimpleDateFormat sdf = new SimpleDateFormat(format); | |
| 30 | + return sdf.format(date); | |
| 31 | + } | |
| 32 | + | |
| 33 | + public static Date string2Date(String date, String format) { | |
| 34 | + try{ | |
| 35 | + SimpleDateFormat sdf = new SimpleDateFormat(format); | |
| 36 | + return sdf.parse(date); | |
| 37 | + }catch (Exception e){ | |
| 38 | + | |
| 39 | + } | |
| 40 | + return new Date(); | |
| 41 | + } | |
| 42 | + | |
| 43 | + public static Date getToday(){ | |
| 44 | + return new Date(); | |
| 45 | + } | |
| 46 | + | |
| 47 | + public static String getToday(String format) throws ParseException{ | |
| 48 | + SimpleDateFormat sdf = new SimpleDateFormat(format); | |
| 49 | + return sdf.format(new Date()); | |
| 50 | + } | |
| 51 | + | |
| 52 | + public static int getDateDifference(Date date1, Date date2, String timeType) { | |
| 53 | + int between = (int) (date1.getTime() - date2.getTime()); | |
| 54 | + int difference = 0; | |
| 55 | + switch (timeType) { | |
| 56 | + case "day": | |
| 57 | + difference = between / (24 * 60 * 60 * 1000); | |
| 58 | + break; | |
| 59 | + case "hour": | |
| 60 | + difference = between / (60 * 60 * 1000); | |
| 61 | + break; | |
| 62 | + case "min": | |
| 63 | + difference = between / (60 * 1000); | |
| 64 | + break; | |
| 65 | + case "s": | |
| 66 | + difference = between / 1000; | |
| 67 | + } | |
| 68 | + return difference; | |
| 69 | + } | |
| 70 | + | |
| 71 | +} | ... | ... |
cloud/dahua/src/main/resources/application.yml
| ... | ... | @@ -27,6 +27,11 @@ spring: |
| 27 | 27 | # username: SZJXTUSER |
| 28 | 28 | # password: xst200919 |
| 29 | 29 | # driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver |
| 30 | + message: | |
| 31 | + username: sa | |
| 32 | + password: qaz!@#0401 | |
| 33 | + jdbcUrl: jdbc:sqlserver://60.190.202.38:49469;database=XST | |
| 34 | + driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver | |
| 30 | 35 | |
| 31 | 36 | |
| 32 | 37 | mybatis: | ... | ... |
cloud/dahua/src/main/resources/xiaoanmapper/SearchMapper.xml
0 → 100644
| ... | ... | @@ -0,0 +1,35 @@ |
| 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.example.dahua.dao.SearchDao" > | |
| 4 | + | |
| 5 | + | |
| 6 | + <resultMap id="resultMap" type="com.example.dahua.bean.CheckIn"> | |
| 7 | + <result column="arr" property="out" jdbcType="VARCHAR" /> | |
| 8 | + <result column="iscuccess" property="isSuccess" jdbcType="INTEGER" /> | |
| 9 | + </resultMap> | |
| 10 | + <insert id="checkIn" parameterType="com.example.dahua.bean.CheckIn" statementType="CALLABLE" > | |
| 11 | + {call AttendanceService( | |
| 12 | + #{deviceId,mode=IN} , #{cardNo,mode=IN} , #{funNo,mode=IN}, #{flag,mode=IN} , #{checkTime,mode=IN}, | |
| 13 | + #{out,mode=OUT,jdbcType=VARCHAR,resultMap=resultMap},#{isSuccess,mode=OUT,jdbcType=INTEGER,resultMap=resultMap} | |
| 14 | + )} | |
| 15 | + </insert> | |
| 16 | + | |
| 17 | + <resultMap id="User" type="com.example.dahua.bean.User" > | |
| 18 | + <result column="school_id" property="schoolId" jdbcType="INTEGER" /> | |
| 19 | + <result column="class_id" property="classId" jdbcType="INTEGER" /> | |
| 20 | + <result column="name" property="name" jdbcType="VARCHAR" /> | |
| 21 | + <result column="student_id" property="studentId" jdbcType="INTEGER" /> | |
| 22 | + </resultMap> | |
| 23 | + <select id="selectUserByCardNum" parameterType="java.lang.String" resultMap="User"> | |
| 24 | + select school_id , class_id ,name ,student_id from | |
| 25 | + (select top 1 b.school_id, b.class_id, b.name, student_id from SZ_V_Card a | |
| 26 | + inner join SZ_V_School_Student b on a.user_id = b.student_id | |
| 27 | + and b.role_state = 1 where a.type = 2 and a.num = #{cardNum} | |
| 28 | + union | |
| 29 | + select top 1 b.school_id, 0 as class_id, b.name,b.teacher_id as student_id from SZ_V_Card a | |
| 30 | + inner join SZ_V_School_Teacher b on a.user_id = b.teacher_id | |
| 31 | + and b.role_state = 1 where a.type = 0 and a.num = #{cardNum} | |
| 32 | + ) x | |
| 33 | + </select> | |
| 34 | + | |
| 35 | +</mapper> | |
| 0 | 36 | \ No newline at end of file | ... | ... |
cloud/pom.xml
| ... | ... | @@ -31,7 +31,7 @@ |
| 31 | 31 | <module>common</module> |
| 32 | 32 | <module>getaway</module> |
| 33 | 33 | <module>haikang</module> |
| 34 | - <!-- <module>dahua</module>--> | |
| 34 | + <module>dahua</module> | |
| 35 | 35 | <!-- <module>consumer</module>--> |
| 36 | 36 | <module>haikangface</module> |
| 37 | 37 | <!-- <module>search_independence</module>--> | ... | ... |