guq 6 gadi atpakaļ
vecāks
revīzija
aa95911da0

+ 0 - 2
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/controller/GradeController.java

@@ -40,6 +40,4 @@ public class GradeController {
         return Result.success();
     }
 
-
-
 }

+ 7 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/controller/TeacherController.java

@@ -45,4 +45,11 @@ public class TeacherController {
         DocBaseDTO formData = teacherService.saveFormData(teacher);
         return Result.success(formData);
     }
+
+    //导入保存至列表
+    @RequestMapping("/saveToFormal")
+    public Result saveToFormal(Integer id, boolean update) {
+        teacherService.saveToFormal(id, update);
+        return Result.success();
+    }
 }

+ 2 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/service/TeacherService.java

@@ -13,4 +13,6 @@ public interface TeacherService {
     TeacherForm getFormData(Long id);
 
     DocBaseDTO saveFormData(SysTeacher teacher);
+
+    void saveToFormal(Integer id, boolean update);
 }

+ 54 - 3
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/basic/service/impl/TeacherServiceImpl.java

@@ -1,5 +1,6 @@
 package com.usoftchina.smartschool.school.basic.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.usoftchina.smartschool.context.BaseContextHolder;
@@ -9,15 +10,18 @@ import com.usoftchina.smartschool.school.basic.service.TeacherService;
 import com.usoftchina.smartschool.school.dto.DocBaseDTO;
 import com.usoftchina.smartschool.school.dto.ListReqDTO;
 import com.usoftchina.smartschool.school.exception.BizExceptionCode;
+import com.usoftchina.smartschool.school.mapper.DataImportMapper;
 import com.usoftchina.smartschool.school.mapper.SysTeacherMapper;
-import com.usoftchina.smartschool.school.po.SysTeacher;
-import com.usoftchina.smartschool.school.po.TeacherDetail;
-import com.usoftchina.smartschool.school.po.TeacherForm;
+import com.usoftchina.smartschool.school.po.*;
+import com.usoftchina.smartschool.utils.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.StringUtils;
 
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @author: guq
@@ -29,6 +33,9 @@ public class TeacherServiceImpl implements TeacherService{
     @Autowired
     private SysTeacherMapper sysTeacherMapper;
 
+    @Autowired
+    private DataImportMapper dataImportMapper;
+
     @Override
     public PageInfo<SysTeacher> getListData(PageRequest page, ListReqDTO listReqDTO) {
         PageHelper.startPage(page.getNumber(), page.getSize());
@@ -64,6 +71,7 @@ public class TeacherServiceImpl implements TeacherService{
         }
         Long school_id = BaseContextHolder.getSchoolId();
         formdata.setSchool_id(school_id);
+        formdata.setTeacher_status(1);
         //新增教师
         if (StringUtils.isEmpty(formdata.getSchool_id()) || "0".equals(formdata.getSchool_id().toString())) {
             sysTeacherMapper.insertSelective(formdata);
@@ -75,4 +83,47 @@ public class TeacherServiceImpl implements TeacherService{
         return new DocBaseDTO(formdata.getTeacher_id(), null, null);
     }
 
+    @Override
+    @Transactional
+    public void saveToFormal(Integer id, boolean update) {
+        if (null == id || "0".equals(id)) {
+            return;
+        }
+        Long schoolId = BaseContextHolder.getSchoolId();
+        List<DataImportDetail> details = dataImportMapper.selectDataById(id);
+        List<SysTeacher> teachers = new ArrayList<>();
+        SysTeacher teacher =null;
+        JSONObject json = null;
+        if (!CollectionUtils.isEmpty(details) && details.size() > 0) {
+            for(DataImportDetail detail : details) {
+                String phone = detail.getDd_codevalue();
+                 teacher = sysTeacherMapper.selectByPhone(phone, schoolId);
+                //老师不存在
+                if (null == teacher) {
+                    json = JSONObject.parseObject(detail.getDd_maindata());
+                    if (null != json) {
+                        if ("男".equals(json.get("teacher_sex"))) {
+                            json.put("teacher_sex", 1);
+                        }else if ("女".equals(json.get("teacher_sex"))) {
+                            json.put("teacher_sex", 0);
+                        };
+                    }
+                    teacher = JSONObject.parseObject(json.toJSONString(), SysTeacher.class);
+                    teacher.setSchool_id(schoolId);
+                    teacher.setTeacher_status(1);
+                    sysTeacherMapper.insertSelective(teacher);
+                    //年纪存在、需要更新
+                } else if (update){
+                    teacher.setSchool_id(schoolId);
+                    teacher.setTeacher_status(1);
+                    sysTeacherMapper.updateByPrimaryKeySelective(teacher);
+                    //年纪存在、不需要处理
+                } else {
+                    continue;
+                }
+            }
+            dataImportMapper.updateDataImport(id);
+        }
+    }
+
 }

+ 2 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/mapper/SysTeacherMapper.java

@@ -26,4 +26,6 @@ public interface SysTeacherMapper {
     List<SysTeacher> selectByConditon(@Param("con") String con, @Param("schoolId") Long schoolId);
 
     List<TeacherDetail> selectDetail(Long id);
+
+    SysTeacher selectByPhone(@Param("phone") String phone, @Param("school_id") Long school_id);
 }

+ 50 - 0
applications/school/school-server/src/main/java/com/usoftchina/smartschool/school/po/SysTeacher.java

@@ -40,6 +40,56 @@ public class SysTeacher {
 
     private String teacher_experience;
 
+    private String teacher_phone;
+
+    private String teacher_email;
+
+    private String teacher_nation;
+
+    private String teacher_school;
+
+    private String teacher_education;
+
+    public String getTeacher_phone() {
+        return teacher_phone;
+    }
+
+    public void setTeacher_phone(String teacher_phone) {
+        this.teacher_phone = teacher_phone;
+    }
+
+    public String getTeacher_email() {
+        return teacher_email;
+    }
+
+    public void setTeacher_email(String teacher_email) {
+        this.teacher_email = teacher_email;
+    }
+
+    public String getTeacher_nation() {
+        return teacher_nation;
+    }
+
+    public void setTeacher_nation(String teacher_nation) {
+        this.teacher_nation = teacher_nation;
+    }
+
+    public String getTeacher_school() {
+        return teacher_school;
+    }
+
+    public void setTeacher_school(String teacher_school) {
+        this.teacher_school = teacher_school;
+    }
+
+    public String getTeacher_education() {
+        return teacher_education;
+    }
+
+    public void setTeacher_education(String teacher_education) {
+        this.teacher_education = teacher_education;
+    }
+
     public String getTeacher_photo() {
         return teacher_photo;
     }

+ 54 - 4
applications/school/school-server/src/main/resources/mapper/SysTeacherMapper.xml

@@ -16,6 +16,11 @@
     <result column="teacher_entry" property="teacher_entry" jdbcType="DATE" />
     <result column="teacher_honor" property="teacher_honor" jdbcType="VARCHAR" />
     <result column="teacher_remarks" property="teacher_remarks" jdbcType="VARCHAR" />
+    <result column="teacher_phone" property="teacher_phone" jdbcType="VARCHAR" />
+    <result column="teacher_email" property="teacher_email" jdbcType="VARCHAR" />
+    <result column="teacher_nation" property="teacher_nation" jdbcType="VARCHAR" />
+    <result column="teacher_school" property="teacher_school" jdbcType="VARCHAR" />
+    <result column="teacher_education" property="teacher_education" jdbcType="VARCHAR" />
   </resultMap>
   <sql id="Base_Column_List" >
     teacher_id, user_id, openid, school_id, teacher_number, teacher_name, teacher_sex, 
@@ -26,10 +31,7 @@
     teacher_photo, teacher_experience
   </sql>
   <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
-    select 
-    <include refid="Base_Column_List" />
-    ,
-    <include refid="Blob_Column_List" />
+    select *
     from sys_teacher
     where teacher_id = #{teacher_id,jdbcType=BIGINT}
   </select>
@@ -102,6 +104,21 @@
       <if test="teacher_experience != null" >
         teacher_experience,
       </if>
+      <if test="teacher_phone != null" >
+        teacher_phone,
+      </if>
+      <if test="teacher_email != null" >
+        teacher_email,
+      </if>
+      <if test="teacher_nation != null" >
+        teacher_nation,
+      </if>
+      <if test="teacher_school != null" >
+        teacher_school,
+      </if>
+      <if test="teacher_education != null" >
+        teacher_education,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides="," >
       <if test="user_id != null" >
@@ -149,6 +166,21 @@
       <if test="teacher_experience != null" >
         #{teacher_experience,jdbcType=VARCHAR},
       </if>
+      <if test="teacher_phone != null" >
+        #{teacher_phone,jdbcType=VARCHAR},
+      </if>
+      <if test="teacher_email != null" >
+        #{teacher_email,jdbcType=VARCHAR},
+      </if>
+      <if test="teacher_nation != null" >
+        #{teacher_nation,jdbcType=VARCHAR},
+      </if>
+      <if test="teacher_school != null" >
+        #{teacher_school,jdbcType=VARCHAR},
+      </if>
+      <if test="teacher_education != null" >
+        #{teacher_education,jdbcType=VARCHAR},
+      </if>
     </trim>
   </insert>
   <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.smartschool.school.po.SysTeacher" >
@@ -199,6 +231,21 @@
       <if test="teacher_experience != null" >
         teacher_experience = #{teacher_experience,jdbcType=VARCHAR},
       </if>
+      <if test="teacher_phone != null" >
+        teacher_phone = #{teacher_phone,jdbcType=VARCHAR},
+      </if>
+      <if test="teacher_email != null" >
+        teacher_email = #{teacher_email,jdbcType=VARCHAR},
+      </if>
+      <if test="teacher_nation != null" >
+        teacher_nation = #{teacher_nation,jdbcType=VARCHAR},
+      </if>
+      <if test="teacher_school != null" >
+        teacher_school = #{teacher_school,jdbcType=VARCHAR},
+      </if>
+      <if test="teacher_education != null" >
+        teacher_education = #{teacher_education,jdbcType=VARCHAR},
+      </if>
     </set>
     where teacher_id = #{teacher_id,jdbcType=BIGINT}
   </update>
@@ -266,4 +313,7 @@ left join sys_clazz on sys_teacher_clazz.clazz_id = sys_clazz.clazz_id
 left join sys_grade on sys_grade.grade_id=sys_clazz.grade_id
 where sys_teacher_clazz.teacher_id=#{id}
   </select>
+  <select id="selectByPhone" resultMap="BaseResultMap">
+    select * from sys_teacher where teacher_phone=#{phone} and school_id=#{school_id}
+  </select>
 </mapper>