Commit eff94aa9bbbbd80ab8eed94ded152367de3a481e
1 parent
a6e4f898
Exists in
master
获取学生信息修改,微信模板推送
Showing
12 changed files
with
301 additions
and
42 deletions
Show diff stats
springboot/morning-check/src/main/java/com/sincere/morningcheck/common/AESDeEncoder.java
0 → 100644
| ... | ... | @@ -0,0 +1,134 @@ |
| 1 | +package com.sincere.morningcheck.common; | |
| 2 | + | |
| 3 | +import sun.misc.BASE64Decoder; | |
| 4 | +import sun.misc.BASE64Encoder; | |
| 5 | + | |
| 6 | +import javax.crypto.Cipher; | |
| 7 | +import javax.crypto.KeyGenerator; | |
| 8 | +import javax.crypto.SecretKey; | |
| 9 | +import javax.crypto.spec.SecretKeySpec; | |
| 10 | +import java.security.SecureRandom; | |
| 11 | + | |
| 12 | +public class AESDeEncoder { | |
| 13 | + /* | |
| 14 | + * 加密 | |
| 15 | + * 1.构造密钥生成器KeyGenerator | |
| 16 | + * 2.根据ecnodeRules规则初始化密钥生成器 | |
| 17 | + * 3.产生密钥 | |
| 18 | + * 4.创建和初始化密码器 | |
| 19 | + * 5.内容加密 | |
| 20 | + * 6.返回字符串 | |
| 21 | + */ | |
| 22 | + public static String AESEncode(String encodeRules, String content) { | |
| 23 | + try { | |
| 24 | + //1.构造密钥生成器,指定为AES算法,不区分大小写 | |
| 25 | + /*javax.crypto | |
| 26 | + 类 KeyGenerator | |
| 27 | + * 此类提供(对称)密钥生成器的功能。 | |
| 28 | + */ | |
| 29 | + KeyGenerator keygen = KeyGenerator.getInstance("AES"); | |
| 30 | + //2.根据ecnodeRules规则初始化密钥生成器 | |
| 31 | + //生成一个128位的随机源,根据传入的字节数组 | |
| 32 | + keygen.init(128, new SecureRandom(encodeRules.getBytes())); | |
| 33 | + //3.产生原始对称密钥 | |
| 34 | + /*javax.crypto | |
| 35 | + 接口 SecretKey | |
| 36 | + 所有超级接口: | |
| 37 | + Key, Serializable | |
| 38 | + * SecretKey | |
| 39 | + * public interface SecretKey extends Key | |
| 40 | + * 秘密(对称)密钥。 | |
| 41 | + * 此接口不包含方法或常量。其唯一目的是分组秘密密钥(并为其提供类型安全)。 | |
| 42 | +此接口的提供者实现必须改写继承自 java.lang.Object 的 equals 和 hashCode 方法, | |
| 43 | +***以便根据底层密钥材料而不是根据引用进行秘密密钥比较***。 | |
| 44 | +实现此接口的密钥以其编码格式(请参阅 getFormat)返回字符串 RAW,并返回作为 getEncoded 方法调用结果的原始密钥字节。 | |
| 45 | +(getFormat 和 getEncoded 方法继承自 java.security.Key 父接口。) | |
| 46 | + 常用方法: | |
| 47 | + * byte[] getEncoded() | |
| 48 | + 返回基本编码格式的密钥,如果此密钥不支持编码,则返回 null。 | |
| 49 | + * | |
| 50 | + */ | |
| 51 | + SecretKey original_key = keygen.generateKey(); | |
| 52 | + //4.获得原始 对称密钥 的字节数组 | |
| 53 | + byte[] raw = original_key.getEncoded(); | |
| 54 | + //5.根据字节数组生成AES密钥 | |
| 55 | + /* | |
| 56 | + * SecretKeySpec | |
| 57 | + * public class SecretKeySpec extends Object implements KeySpec, SecretKey | |
| 58 | + * 此类以与 provider 无关的方式指定一个密钥。 | |
| 59 | +此类仅对能表示为 一个字节数组 并且没有任何与之相关联的钥参数的 原始密钥 有用,如,DES 或者 Triple DES 密钥。 | |
| 60 | + */ | |
| 61 | + SecretKey key = new SecretKeySpec(raw, "AES"); | |
| 62 | + //6.根据指定算法AES自成密码器 | |
| 63 | + /* | |
| 64 | + * Cipher | |
| 65 | + * public class Cipher extends Object | |
| 66 | + * 此类为加密和解密提供密码功能。它构成了 Java Cryptographic Extension (JCE) 框架的核心。 | |
| 67 | + * 为创建 Cipher 对象,应用程序调用 Cipher 的 getInstance 方法并将所请求转换 的名称传递给它。 | |
| 68 | + 还可以指定提供者的名称(可选)。 | |
| 69 | + 常用方法 | |
| 70 | + byte[] doFinal() | |
| 71 | + 结束多部分加密或解密操作(具体取决于此 Cipher 的初始化方式)。 | |
| 72 | + | |
| 73 | + */ | |
| 74 | + Cipher cipher = Cipher.getInstance("AES"); | |
| 75 | + //7.初始化密码器,第一个参数为加密(Encrypt_mode)或者解密解密(Decrypt_mode)操作,第二个参数为使用的KEY | |
| 76 | + cipher.init(Cipher.ENCRYPT_MODE, key); | |
| 77 | + //8.获取加密内容的字节数组(这里要设置为utf-8)不然内容中如果有中文和英文混合中文就会解密为乱码 | |
| 78 | + byte[] byte_encode = content.getBytes("utf-8"); | |
| 79 | + //9.根据密码器的初始化方式--加密:将数据加密 | |
| 80 | + byte[] byte_AES = cipher.doFinal(byte_encode); | |
| 81 | + //10.将加密后的数据转换为字符串 | |
| 82 | + //这里用Base64Encoder中会找不到包 | |
| 83 | + //解决办法: | |
| 84 | + //在项目的Build path中先移除JRE System Library,再添加库JRE System Library,重新编译后就一切正常了。 | |
| 85 | + String AES_encode = new String(new BASE64Encoder().encode(byte_AES)); | |
| 86 | + //11.将字符串返回 | |
| 87 | + return AES_encode; | |
| 88 | + } catch (Exception e) { | |
| 89 | + e.printStackTrace(); | |
| 90 | + } | |
| 91 | + //如果有错就返加nulll | |
| 92 | + return null; | |
| 93 | + } | |
| 94 | + | |
| 95 | + /* | |
| 96 | + * 解密 | |
| 97 | + * 解密过程: | |
| 98 | + * 1.同加密1-4步 | |
| 99 | + * 2.将加密后的字符串反纺成byte[]数组 | |
| 100 | + * 3.将加密内容解密 | |
| 101 | + */ | |
| 102 | + public static String AESDncode(String encodeRules, String content) { | |
| 103 | + try { | |
| 104 | + //1.构造密钥生成器,指定为AES算法,不区分大小写 | |
| 105 | + KeyGenerator keygen = KeyGenerator.getInstance("AES"); | |
| 106 | + //2.根据ecnodeRules规则初始化密钥生成器 | |
| 107 | + //生成一个128位的随机源,根据传入的字节数组 | |
| 108 | + keygen.init(128, new SecureRandom(encodeRules.getBytes())); | |
| 109 | + //3.产生原始对称密钥 | |
| 110 | + SecretKey original_key = keygen.generateKey(); | |
| 111 | + //4.获得原始对称密钥的字节数组 | |
| 112 | + byte[] raw = original_key.getEncoded(); | |
| 113 | + //5.根据字节数组生成AES密钥 | |
| 114 | + SecretKey key = new SecretKeySpec(raw, "AES"); | |
| 115 | + //6.根据指定算法AES自成密码器 | |
| 116 | + Cipher cipher = Cipher.getInstance("AES"); | |
| 117 | + //7.初始化密码器,第一个参数为加密(Encrypt_mode)或者解密(Decrypt_mode)操作,第二个参数为使用的KEY | |
| 118 | + cipher.init(Cipher.DECRYPT_MODE, key); | |
| 119 | + //8.将加密并编码后的内容解码成字节数组 | |
| 120 | + byte[] byte_content = new BASE64Decoder().decodeBuffer(content); | |
| 121 | + /* | |
| 122 | + * 解密 | |
| 123 | + */ | |
| 124 | + byte[] byte_decode = cipher.doFinal(byte_content); | |
| 125 | + String AES_decode = new String(byte_decode, "utf-8"); | |
| 126 | + return AES_decode; | |
| 127 | + } catch (Exception e) { | |
| 128 | + e.printStackTrace(); | |
| 129 | + } | |
| 130 | + | |
| 131 | + //如果有错就返加nulll | |
| 132 | + return null; | |
| 133 | + } | |
| 134 | +} | ... | ... |
springboot/morning-check/src/main/java/com/sincere/morningcheck/controller/MorningCheckController.java
| 1 | 1 | package com.sincere.morningcheck.controller; |
| 2 | 2 | |
| 3 | -import com.sincere.morningcheck.common.EhcacheUtil; | |
| 3 | +import com.alibaba.fastjson.JSON; | |
| 4 | +import com.sincere.morningcheck.common.AESDeEncoder; | |
| 4 | 5 | import com.sincere.morningcheck.common.MD5; |
| 5 | 6 | import com.sincere.morningcheck.common.ServerResponse; |
| 6 | 7 | import com.sincere.morningcheck.model.*; |
| ... | ... | @@ -8,7 +9,7 @@ import com.sincere.morningcheck.service.FileUpAndDownService; |
| 8 | 9 | import com.sincere.morningcheck.service.StudentCheckReportService; |
| 9 | 10 | import com.sincere.morningcheck.service.StudentService; |
| 10 | 11 | import com.sincere.morningcheck.service.UserServer; |
| 11 | -import com.sincere.morningcheck.service.impl.FileUpAndDownServiceImpl; | |
| 12 | +import com.sincere.morningcheck.utils.ApiHelper; | |
| 12 | 13 | import com.sincere.morningcheck.utils.DataConvertHelper; |
| 13 | 14 | import com.sincere.morningcheck.utils.LogUtil; |
| 14 | 15 | import io.swagger.annotations.Api; |
| ... | ... | @@ -21,22 +22,15 @@ import org.springframework.beans.factory.annotation.Value; |
| 21 | 22 | import org.springframework.web.bind.annotation.*; |
| 22 | 23 | import org.springframework.web.multipart.MultipartFile; |
| 23 | 24 | |
| 24 | -import javax.servlet.http.HttpServletRequest; | |
| 25 | -import javax.servlet.http.HttpServletResponse; | |
| 26 | -import javax.servlet.http.HttpSession; | |
| 27 | 25 | import java.text.ParseException; |
| 28 | 26 | import java.text.SimpleDateFormat; |
| 29 | -import java.util.Calendar; | |
| 30 | -import java.util.Date; | |
| 31 | -import java.util.HashMap; | |
| 32 | -import java.util.Map; | |
| 27 | +import java.util.*; | |
| 33 | 28 | |
| 34 | 29 | @RestController |
| 35 | 30 | @RequestMapping("user") |
| 36 | 31 | @Api(value = "MorningCheckController", tags = "晨检机晨检接口说明") |
| 37 | 32 | public class MorningCheckController { |
| 38 | 33 | |
| 39 | - private String token = "CESHI651BB2B8AEBBF0DB2FFC9B4EAD5F04E2"; | |
| 40 | 34 | |
| 41 | 35 | @Value("${salt}") |
| 42 | 36 | private String salt; |
| ... | ... | @@ -60,10 +54,10 @@ public class MorningCheckController { |
| 60 | 54 | @ApiImplicitParam(name = "authSign", value = "签名", dataType = "String",required = true,paramType = "query"), |
| 61 | 55 | }) |
| 62 | 56 | @PostMapping("login") |
| 63 | - public ServerResponse login(HttpServletRequest request,@RequestParam String deviceNo, @RequestParam String password,@RequestParam String authSign){ | |
| 57 | + public ServerResponse login(@RequestParam String deviceNo, @RequestParam String password,@RequestParam String authSign){ | |
| 64 | 58 | |
| 65 | 59 | ServerResponse serverResponse = null; |
| 66 | - | |
| 60 | + LogUtil.printInfoLog("进入登陆接口"); | |
| 67 | 61 | Map map = new HashMap(); |
| 68 | 62 | map.put("password", password); |
| 69 | 63 | map.put("deviceNo", deviceNo); |
| ... | ... | @@ -72,18 +66,16 @@ public class MorningCheckController { |
| 72 | 66 | System.out.println(queryUrl); |
| 73 | 67 | try { |
| 74 | 68 | String signUrl = queryUrl.replace("&",""); |
| 75 | - System.out.println(signUrl); | |
| 76 | 69 | // String md5 = MD5.md5(signUrl, salt); |
| 77 | 70 | boolean verify = MD5.verify(signUrl,salt,authSign); |
| 78 | - | |
| 71 | + System.out.println("校验是否成功:"+verify); | |
| 79 | 72 | if(verify) { |
| 80 | 73 | |
| 81 | 74 | User user = userServer.getDeviceUser(deviceNo); |
| 82 | 75 | user.setParameter("0"); |
| 76 | + String token = user.getDeviceId()+","+user.getSchoolId();//AESDeEncoder.AESEncode("token",user.getDeviceId()+","+user.getSchoolId()); | |
| 83 | 77 | user.setToken(token); |
| 84 | - HttpSession session = request.getSession(); | |
| 85 | - session.setAttribute("deviceId",user.getDeviceId()); | |
| 86 | - session.setMaxInactiveInterval(-1);//从不过期 | |
| 78 | + LogUtil.printInfoLog("生成的Token信息包括设备标识和学校标识"+token); | |
| 87 | 79 | serverResponse = ServerResponse.createBySuccess("success",user); |
| 88 | 80 | |
| 89 | 81 | }else{ |
| ... | ... | @@ -152,7 +144,7 @@ public class MorningCheckController { |
| 152 | 144 | "时间格式为 : yyyy-MM-dd-HH-mm-ss", dataType = "String",paramType = "query") |
| 153 | 145 | }) |
| 154 | 146 | @PostMapping("signByCard") |
| 155 | - public ServerResponse swipeCard(HttpServletRequest request,@RequestParam String token,@RequestParam String cardNo,@RequestParam Integer imageId,@RequestParam String authSign,@RequestParam(required = false) String date){ | |
| 147 | + public ServerResponse swipeCard(@RequestParam String token,@RequestParam String cardNo,@RequestParam Integer imageId,@RequestParam String authSign,@RequestParam(required = false) String date){ | |
| 156 | 148 | |
| 157 | 149 | LogUtil.printInfoLog("刷卡签到传入的参数:卡号"+cardNo+",图片ID:"+imageId+",签名"+authSign); |
| 158 | 150 | ServerResponse serverResponse = null; |
| ... | ... | @@ -167,8 +159,6 @@ public class MorningCheckController { |
| 167 | 159 | Date dateIn = null; |
| 168 | 160 | if(StringUtils.isBlank(date)){ |
| 169 | 161 | Calendar calendar= Calendar.getInstance(); |
| 170 | -// SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss"); | |
| 171 | -// date = dateFormat.format(calendar.getTime()); | |
| 172 | 162 | dateIn= calendar.getTime(); |
| 173 | 163 | |
| 174 | 164 | }else{ |
| ... | ... | @@ -188,8 +178,9 @@ public class MorningCheckController { |
| 188 | 178 | boolean verify = MD5.verify(signUrl,salt,authSign); |
| 189 | 179 | System.out.println("签名是否正确"+verify); |
| 190 | 180 | if(verify) { |
| 191 | - HttpSession session = request.getSession(); | |
| 192 | - String deviceId = session.getAttribute("deviceId").toString(); | |
| 181 | + | |
| 182 | + LogUtil.printInfoLog(token);; | |
| 183 | + String deviceId = token.split(",")[0]; | |
| 193 | 184 | Map<String,Object> hashMap = new HashMap<>(); |
| 194 | 185 | //设备编号 |
| 195 | 186 | hashMap.put("att_id",deviceId); |
| ... | ... | @@ -197,7 +188,7 @@ public class MorningCheckController { |
| 197 | 188 | hashMap.put("func_no","08"); |
| 198 | 189 | hashMap.put("flag",0); |
| 199 | 190 | hashMap.put("intime",dateIn); |
| 200 | - System.out.println(deviceId); | |
| 191 | + System.out.println("设备标识"+deviceId); | |
| 201 | 192 | |
| 202 | 193 | studentService.swipeCard(hashMap); |
| 203 | 194 | System.out.println("集合数量:"+hashMap.size()); |
| ... | ... | @@ -230,7 +221,7 @@ public class MorningCheckController { |
| 230 | 221 | @ApiImplicitParam(name = "authSign", value = "签名", dataType = "String",required = true,paramType = "query") |
| 231 | 222 | }) |
| 232 | 223 | @PostMapping("signOutByCard") |
| 233 | - public ServerResponse signOutByCard(HttpServletRequest request,@RequestParam String token,@RequestParam String cardNo,@RequestParam Integer imageId,@RequestParam String authSign){ | |
| 224 | + public ServerResponse signOutByCard(@RequestParam String token,@RequestParam String cardNo,@RequestParam Integer imageId,@RequestParam String authSign){ | |
| 234 | 225 | |
| 235 | 226 | ServerResponse serverResponse = null; |
| 236 | 227 | LogUtil.printInfoLog("离园签到传入的参数:卡号"+cardNo+",图片ID:"+imageId+",签名"+authSign); |
| ... | ... | @@ -248,8 +239,7 @@ public class MorningCheckController { |
| 248 | 239 | boolean verify = MD5.verify(signUrl,salt,authSign); |
| 249 | 240 | System.out.println("签名是否正确"+verify); |
| 250 | 241 | if(verify) { |
| 251 | - HttpSession session = request.getSession(); | |
| 252 | - String deviceId = session.getAttribute("deviceId").toString(); | |
| 242 | + String deviceId = token.split(",")[0]; | |
| 253 | 243 | Map<String,Object> hashMap = new HashMap<>(); |
| 254 | 244 | hashMap.put("att_id",deviceId); |
| 255 | 245 | hashMap.put("card_num",card); |
| ... | ... | @@ -352,18 +342,50 @@ public class MorningCheckController { |
| 352 | 342 | map.put("handImgId",handImgId); |
| 353 | 343 | map.put("mouthImgId",mouthImgId); |
| 354 | 344 | map.put("eyeImgId",eyeImgId); |
| 355 | - | |
| 345 | + Date checkDate = new Date(); | |
| 356 | 346 | String queryUrl = DataConvertHelper.mapAscSortToUrl(map); |
| 357 | 347 | try { |
| 358 | 348 | String signUrl = queryUrl.replace("&",""); |
| 359 | 349 | boolean verify = MD5.verify(signUrl,salt,authSign); |
| 360 | 350 | if(verify) { |
| 351 | + //微信模板消息推送 | |
| 352 | + Thread thread = new Thread(()->{ | |
| 353 | + | |
| 354 | + try { | |
| 355 | + | |
| 356 | + String schoolId = token.split(",")[1];//AESDeEncoder.AESDncode("token",token).split(",")[1]; | |
| 357 | + String stuUserId = studentService.getStuUserId(card, schoolId); | |
| 358 | + List<String> openIds = studentService.getOpenId(stuUserId, schoolId); | |
| 359 | + if (openIds != null) { | |
| 360 | + | |
| 361 | + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
| 362 | + | |
| 363 | + for (String openId : openIds) { | |
| 364 | + WXCheckTemplate wxCheckTemplate = new WXCheckTemplate(); | |
| 365 | + wxCheckTemplate.setFirstData("家长您好,有一份晨检报告待查看"); | |
| 366 | + wxCheckTemplate.setKeyword1("晨检"); | |
| 367 | + wxCheckTemplate.setKeyword2(simpleDateFormat.format(checkDate)); | |
| 368 | + wxCheckTemplate.setOpenID(openId); | |
| 369 | + wxCheckTemplate.setSchoolID(schoolId); | |
| 370 | + wxCheckTemplate.setUrl("http://campus.myjxt.com/Web/Skin/EasyNotice/Modules/EMGzh/XSTVerification3.html?type=5"); | |
| 371 | + String jsonResult = JSON.toJSONString(wxCheckTemplate); | |
| 372 | + LogUtil.printInfoLog("微信模板接口调用:"+jsonResult); | |
| 373 | + String returnResult = ApiHelper.doPost("http://campus.myjxt.com/api/SendGzhTemplate/SengMorningCheck", null, jsonResult); | |
| 374 | + } | |
| 375 | + } | |
| 376 | + }catch (Exception ex){ | |
| 377 | + LogUtil.printInfoLog("异常信息"+ex.getMessage()); | |
| 378 | + } | |
| 379 | + | |
| 380 | + }); | |
| 381 | + thread.start(); | |
| 382 | + | |
| 361 | 383 | StudentCheckReport studentCheckReport = new StudentCheckReport(); |
| 362 | 384 | studentCheckReport.setAccess(access); |
| 363 | 385 | studentCheckReport.setCardNo(card); |
| 364 | 386 | studentCheckReport.setCheckResult(result); |
| 365 | 387 | studentCheckReport.setRobotResult(robotResult); |
| 366 | - Date checkDate = new Date(); | |
| 388 | + | |
| 367 | 389 | studentCheckReport.setCheckTime(checkDate); |
| 368 | 390 | studentCheckReport.setInTime(checkDate); |
| 369 | 391 | studentCheckReport.setTemperature(temperature); | ... | ... |
springboot/morning-check/src/main/java/com/sincere/morningcheck/dao/StudentDao.java
| ... | ... | @@ -18,14 +18,27 @@ public interface StudentDao { |
| 18 | 18 | |
| 19 | 19 | Student getStudentByCardNo(@Param("cardNo") String cardNo); |
| 20 | 20 | |
| 21 | + Student getStudentByStudentId(@Param("schoolId")Integer schoolId,@Param("studentId")Integer studentId); | |
| 22 | + | |
| 21 | 23 | Student getStudentByStuUserId(@Param("sUserId") String sUserId); |
| 22 | 24 | |
| 23 | 25 | int getStuCountBySchoolId(@Param("schoolId") Integer schoolId); |
| 24 | 26 | |
| 25 | 27 | List<Grade> getGradeBySchoolId(@Param("schoolId") Integer schoolId); |
| 28 | + | |
| 29 | + /** | |
| 30 | + * 获取学生用户标识 | |
| 31 | + * @param num | |
| 32 | + * @return | |
| 33 | + */ | |
| 34 | + String getStuUserId(@Param("num") String num,@Param("schoolId")String schoolId); | |
| 35 | + | |
| 36 | + List<String> getOpenId(@Param("stuUserId")String stuUserId,@Param("schoolId")String schoolId); | |
| 26 | 37 | /** |
| 27 | 38 | * 传入的参数和返回的结果都在map集合参数params中 |
| 28 | 39 | * @param params |
| 29 | 40 | */ |
| 30 | 41 | void swipeCard(Map<String, Object> params); |
| 42 | + | |
| 43 | + | |
| 31 | 44 | } | ... | ... |
springboot/morning-check/src/main/java/com/sincere/morningcheck/model/WXCheckTemplate.java
0 → 100644
| ... | ... | @@ -0,0 +1,37 @@ |
| 1 | +package com.sincere.morningcheck.model; | |
| 2 | + | |
| 3 | +import lombok.Data; | |
| 4 | + | |
| 5 | +import java.util.Date; | |
| 6 | + | |
| 7 | +@Data | |
| 8 | +public class WXCheckTemplate { | |
| 9 | + | |
| 10 | + /** | |
| 11 | + * 详情页面url | |
| 12 | + */ | |
| 13 | + private String Url ; | |
| 14 | + /** | |
| 15 | + * 通知提示 | |
| 16 | + */ | |
| 17 | + private String FirstData; | |
| 18 | + /** | |
| 19 | + * 报告类型 | |
| 20 | + */ | |
| 21 | + private String Keyword1 ; | |
| 22 | + /** | |
| 23 | + * 生成时间 | |
| 24 | + */ | |
| 25 | + private String Keyword2; | |
| 26 | + | |
| 27 | + /** | |
| 28 | + * open数组 | |
| 29 | + */ | |
| 30 | + public String OpenID; | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * 学校id | |
| 34 | + */ | |
| 35 | + private String SchoolID; | |
| 36 | + | |
| 37 | +} | ... | ... |
springboot/morning-check/src/main/java/com/sincere/morningcheck/service/StudentService.java
| ... | ... | @@ -12,4 +12,8 @@ public interface StudentService { |
| 12 | 12 | Student getStudentByCardNo(String cardNo); |
| 13 | 13 | |
| 14 | 14 | void swipeCard(Map<String, Object> params); |
| 15 | + | |
| 16 | + String getStuUserId(String num,String schoolId); | |
| 17 | + | |
| 18 | + List<String> getOpenId(String stuUserId,String schoolId); | |
| 15 | 19 | } | ... | ... |
springboot/morning-check/src/main/java/com/sincere/morningcheck/service/impl/StudentCheckReportServiceImpl.java
| ... | ... | @@ -206,7 +206,7 @@ public class StudentCheckReportServiceImpl implements StudentCheckReportService |
| 206 | 206 | for(StudentCheckReport item : studentCheckReports){ |
| 207 | 207 | ApiStudent apiStudent = new ApiStudent(); |
| 208 | 208 | apiStudent.setCardNo(item.getCardNo()); |
| 209 | - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("hh:mm"); | |
| 209 | + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm"); | |
| 210 | 210 | apiStudent.setCheckTime(simpleDateFormat.format(item.getCheckTime())); |
| 211 | 211 | apiStudent.setTemperature(item.getTemperature()); |
| 212 | 212 | if(StringUtils.isNotBlank(item.getCheckResult())){ |
| ... | ... | @@ -214,7 +214,7 @@ public class StudentCheckReportServiceImpl implements StudentCheckReportService |
| 214 | 214 | apiStudent.setCheckResultObj(getCheckResult(chs)); |
| 215 | 215 | } |
| 216 | 216 | if(StringUtils.isNotBlank(item.getCardNo())){ |
| 217 | - Student student = studentDao.getStudentByCardNo(item.getCardNo()); | |
| 217 | + Student student = studentDao.getStudentByStudentId(schoolId,item.getStudent_id()); | |
| 218 | 218 | apiStudent.setClassName(student.getClassName()); |
| 219 | 219 | apiStudent.setStudent_id(student.getStuId()); |
| 220 | 220 | apiStudent.setStuName(student.getStuName()); |
| ... | ... | @@ -236,7 +236,7 @@ public class StudentCheckReportServiceImpl implements StudentCheckReportService |
| 236 | 236 | ApiStudentCheckReport apiStudentCheckReport = new ApiStudentCheckReport(); |
| 237 | 237 | if(isMorningCheck) { |
| 238 | 238 | apiStudentCheckReport.setCardNo(studentCheckReport.getCardNo()); |
| 239 | - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm"); | |
| 239 | + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | |
| 240 | 240 | System.out.println(studentCheckReport.getCheckTime()); |
| 241 | 241 | apiStudentCheckReport.setCheckTime(simpleDateFormat.format(studentCheckReport.getCheckTime())); |
| 242 | 242 | apiStudentCheckReport.setStudent_id(studentCheckReport.getStudent_id()); | ... | ... |
springboot/morning-check/src/main/java/com/sincere/morningcheck/service/impl/StudentServiceImpl.java
| ... | ... | @@ -31,4 +31,14 @@ public class StudentServiceImpl implements StudentService { |
| 31 | 31 | |
| 32 | 32 | studentDao.swipeCard(params); |
| 33 | 33 | } |
| 34 | + | |
| 35 | + @Override | |
| 36 | + public String getStuUserId(String num,String schoolId) { | |
| 37 | + return studentDao.getStuUserId(num,schoolId); | |
| 38 | + } | |
| 39 | + | |
| 40 | + @Override | |
| 41 | + public List<String> getOpenId(String stuUserId, String schoolId) { | |
| 42 | + return studentDao.getOpenId(stuUserId,schoolId); | |
| 43 | + } | |
| 34 | 44 | } | ... | ... |
springboot/morning-check/src/main/java/com/sincere/morningcheck/utils/ApiHelper.java
| ... | ... | @@ -88,9 +88,11 @@ public class ApiHelper { |
| 88 | 88 | httpClient = HttpClients.createDefault(); |
| 89 | 89 | // 创建HttpDelete远程连接实例 |
| 90 | 90 | HttpDelete httpDelete = new HttpDelete(url); |
| 91 | - // 设置请求头信息, | |
| 92 | - for (Map.Entry<String, String> entry : headerParamMap.entrySet()) { | |
| 93 | - httpDelete.setHeader(entry.getKey(),entry.getValue()); | |
| 91 | + if(headerParamMap!=null) { | |
| 92 | + // 设置请求头信息, | |
| 93 | + for (Map.Entry<String, String> entry : headerParamMap.entrySet()) { | |
| 94 | + httpDelete.setHeader(entry.getKey(), entry.getValue()); | |
| 95 | + } | |
| 94 | 96 | } |
| 95 | 97 | |
| 96 | 98 | // 设置配置请求参数 |
| ... | ... | @@ -198,8 +200,10 @@ public class ApiHelper { |
| 198 | 200 | HttpPost httpPost = new HttpPost(url); |
| 199 | 201 | // 设置请求头 |
| 200 | 202 | httpPost.addHeader("Content-Type", "application/json"); |
| 201 | - for (Map.Entry<String, String> entry : headerParamMap.entrySet()) { | |
| 202 | - httpPost.setHeader(entry.getKey(),entry.getValue()); | |
| 203 | + if(headerParamMap!=null) { | |
| 204 | + for (Map.Entry<String, String> entry : headerParamMap.entrySet()) { | |
| 205 | + httpPost.setHeader(entry.getKey(), entry.getValue()); | |
| 206 | + } | |
| 203 | 207 | } |
| 204 | 208 | // 配置请求参数实例 |
| 205 | 209 | RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(35000)// 设置连接主机服务超时时间 | ... | ... |
springboot/morning-check/src/main/resources/application-dev.properties
0 → 100644
| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | +salt = sincere | |
| 2 | + | |
| 3 | +server.port=8999 | |
| 4 | + | |
| 5 | +#测试站点数据库 | |
| 6 | +spring.datasource.username=SZJXTUSER | |
| 7 | +spring.datasource.password=xst200919 | |
| 8 | +spring.datasource.url=jdbc:sqlserver://60.190.202.57:14333;Database=SmartCampusSZ | |
| 9 | +spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver | |
| 10 | + | |
| 11 | +mybatis.mapper-locations=classpath:/mapper/*.xml | |
| 12 | +mybatis.type-aliases-package=com.sincere.morningcheck.model | |
| 13 | + | |
| 14 | +# springboot 部署环境的选取 | |
| 15 | +spring.profiles.active=dev | ... | ... |
springboot/morning-check/src/main/resources/application-prod.properties
springboot/morning-check/src/main/resources/application.properties
| ... | ... | @@ -2,14 +2,14 @@ salt = sincere |
| 2 | 2 | |
| 3 | 3 | server.port=8999 |
| 4 | 4 | |
| 5 | -#测试站点数据库 | |
| 6 | -spring.datasource.username=SZJXTUSER | |
| 7 | -spring.datasource.password=xst200919 | |
| 8 | -spring.datasource.url=jdbc:sqlserver://60.190.202.57:14333;Database=SmartCampusSZ | |
| 5 | +#正式站点数据库 | |
| 6 | +spring.datasource.username=szjxtuser | |
| 7 | +spring.datasource.password=RQminVCJota3H1u8bBYH | |
| 8 | +spring.datasource.url=jdbc:sqlserver://116.62.155.137:33419;database=smartcampus | |
| 9 | 9 | spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver |
| 10 | 10 | |
| 11 | 11 | mybatis.mapper-locations=classpath:/mapper/*.xml |
| 12 | 12 | mybatis.type-aliases-package=com.sincere.morningcheck.model |
| 13 | 13 | |
| 14 | 14 | # springboot 部署环境的选取 |
| 15 | -spring.profiles.active=dev | |
| 15 | +spring.profiles.active=prod | ... | ... |
springboot/morning-check/src/main/resources/mapper/studentmapper.xml
| ... | ... | @@ -33,6 +33,10 @@ |
| 33 | 33 | where vs.role_state=1 |
| 34 | 34 | </select> |
| 35 | 35 | |
| 36 | + <select id="getStudentByStudentId" resultMap="BaseResultMap"> | |
| 37 | + select top 1 vs.name,vs.student_id,vs.class_id,vs.class_name from SZ_V_School_Student vs | |
| 38 | + where role_state=1 and school_id=#{schoolId} and student_id=#{studentId} | |
| 39 | + </select> | |
| 36 | 40 | <select id="getStudentByStuUserId" resultMap="BaseResultMap"> |
| 37 | 41 | select top 1 vs.name,vs.student_id,vs.class_id,vs.class_name,Cards=vs.student_num from SZ_V_School_Student vs |
| 38 | 42 | where user_id=#{sUserId} |
| ... | ... | @@ -45,6 +49,22 @@ |
| 45 | 49 | <select id="getGradeBySchoolId" resultType="com.sincere.morningcheck.model.Grade"> |
| 46 | 50 | select id,grade,ShortName from SZ_Grade where Status=1 and SchoolId = #{schoolId} |
| 47 | 51 | </select> |
| 52 | + | |
| 53 | + <select id="getStuUserId" resultType="java.lang.String"> | |
| 54 | + select vs.user_id from SZ_V_School_Student vs | |
| 55 | + inner join SZ_V_Card b on b.type=2 and vs.student_id=b.user_id and b.num=#{num} | |
| 56 | + where vs.role_state=1 and school_id = #{schoolId} | |
| 57 | + </select> | |
| 58 | + | |
| 59 | + <select id="getOpenId" resultType="java.lang.String"> | |
| 60 | + select u.XSTOpenId from SZ_UserRole ur join | |
| 61 | + SZ_SPRole sp on ur.customerId = sp.student_id join | |
| 62 | + SZ_userrole ur2 on sp.parent_id = ur2.customerId | |
| 63 | + join sz_user u on ur2.user_id = u.user_id | |
| 64 | + where ur.user_id = #{stuUserId} | |
| 65 | + and ur2.usertype = 3 and ur2.school_id = #{schoolId} | |
| 66 | + and (u.XSTOpenId !='' or u.XSTOpenId is not null) | |
| 67 | + </select> | |
| 48 | 68 | <select id="swipeCard" statementType="CALLABLE" resultType="java.util.Map"> |
| 49 | 69 | {call xiaoan.dbo.AttendanceService( |
| 50 | 70 | #{att_id, mode=IN}, | ... | ... |