Browse Source

抓取门禁照片作为学生头像

chenw 7 years ago
parent
commit
101dca3be1

+ 3 - 0
applications/device/device-server/src/main/java/com/usoftchina/smartschool/device/mapper/StudentInfoMapper.java

@@ -2,6 +2,7 @@ package com.usoftchina.smartschool.device.mapper;
 
 import com.usoftchina.smartschool.device.po.StudentInfo;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -12,4 +13,6 @@ import java.util.List;
 @Mapper
 public interface StudentInfoMapper {
     List<StudentInfo> selectInfoByCardNo(String cardNo);
+
+    void updatePhoto(@Param("photo") String photo, @Param("stuId") Long stuId);
 }

+ 2 - 0
applications/device/device-server/src/main/java/com/usoftchina/smartschool/device/po/StudentInfo.java

@@ -35,4 +35,6 @@ public class StudentInfo implements Serializable{
 
     private int stuSex;
 
+    private String stuPhoto;
+
 }

+ 4 - 0
applications/device/device-server/src/main/java/com/usoftchina/smartschool/device/service/impl/AccessControlServiceImpl.java

@@ -82,6 +82,10 @@ public class AccessControlServiceImpl implements AccessControlService{
             try {
                 fileInfo = fileApi.upload(0L, new ByteArrayMultipartFile("file", information.get(0).getStuName() + ".jpg", "application/jpeg", imageData));
                 filePath = fileInfo.getData().getAccessPath();
+                StudentInfo studentInfo = information.get(0);
+                if (StringUtils.isEmpty(studentInfo.getStuPhoto())) {
+                    studentInfoMapper.updatePhoto(studentInfo.getStuPhoto(), studentInfo.getStuId());
+                }
             }catch (Exception ex) {
                 logger.error(ex.getMessage());
             }

+ 6 - 1
applications/device/device-server/src/main/resources/mapper/StudentInfoMapper.xml

@@ -3,11 +3,15 @@
 <mapper namespace="com.usoftchina.smartschool.device.mapper.StudentInfoMapper" >
     <select id="selectInfoByCardNo" parameterType="string" resultMap="studentInfo">
         select school_appid,school_secret,sys_parents.openid,sys_student.stu_name,sys_student.stu_id,sys_school.school_id,
-         stu_number,sys_student.clazz_id,stu_class,stu_grade,stu_classnickname,stu_sex from sys_student left join sys_school on sys_student.school_id=sys_school.school_id
+         stu_number,sys_student.clazz_id,stu_class,stu_grade,stu_classnickname,stu_sex,stu_photo from sys_student left join sys_school on sys_student.school_id=sys_school.school_id
         left join sys_parents_stu on sys_student.stu_id=sys_parents_stu.stu_id left join sys_parents on sys_parents.parent_id =
         sys_parents_stu.parent_id where stu_cardNo = #{cardNo} and  ifnull(openid,'') != ''
     </select>
 
+    <update id="updatePhoto">
+      update sys_student set stu_photo = #{photo} where stu_id = #{stuId}
+    </update>
+
     <resultMap id="studentInfo" type="com.usoftchina.smartschool.device.po.StudentInfo" >
         <result column="school_appid" property="appId" jdbcType="VARCHAR" />
         <result column="school_secret" property="secret" jdbcType="VARCHAR" />
@@ -21,5 +25,6 @@
         <result column="stu_grade" property="stuGrade" jdbcType="VARCHAR" />
         <result column="stu_classnickname" property="stuClassnickname" jdbcType="VARCHAR"/>
         <result column="stu_sex" property="stuSex" jdbcType="INTEGER"/>
+        <result column="stu_photo" property="stuPhoto" jdbcType="VARCHAR"/>
     </resultMap>
 </mapper>