Commit 63f3d4ed by baochunxin

#G:新增电子教室档案老师基本信息

parent 8c83facd
...@@ -36,6 +36,13 @@ public interface SysDictDataMapper ...@@ -36,6 +36,13 @@ public interface SysDictDataMapper
*/ */
public String selectDictLabel(@Param("dictType") String dictType, @Param("dictValue") String dictValue); public String selectDictLabel(@Param("dictType") String dictType, @Param("dictValue") String dictValue);
/**
* 、根据字典类型跟字典名字查找字典值
*/
public String selectDictValue(@Param("dictType") String dictType, @Param("dictLable") String dictLable);
/** /**
* 根据字典数据ID查询信息 * 根据字典数据ID查询信息
* *
......
...@@ -51,6 +51,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -51,6 +51,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where dict_type = #{dictType} and dict_value = #{dictValue} where dict_type = #{dictType} and dict_value = #{dictValue}
</select> </select>
<select id="selectDictValue" resultType="String">
select dict_value from sys_dict_data
where dict_type = #{dictType} and dict_label = #{dictLable}
</select>
<select id="selectDictDataById" parameterType="Long" resultMap="SysDictDataResult"> <select id="selectDictDataById" parameterType="Long" resultMap="SysDictDataResult">
<include refid="selectDictDataVo"/> <include refid="selectDictDataVo"/>
where dict_code = #{dictCode} where dict_code = #{dictCode}
......
...@@ -105,6 +105,14 @@ ...@@ -105,6 +105,14 @@
<artifactId>fastjson</artifactId> <artifactId>fastjson</artifactId>
<version>1.2.8</version> <version>1.2.8</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>
package yangtz.cs.liu.campus.controller.teacherFiles;
import cn.hutool.extra.spring.SpringUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import yangtz.cs.liu.campus.domain.organization.SchoolOrganizationInfo;
import yangtz.cs.liu.campus.domain.schoolEquipment.SchoolEquipmentLedger;
import yangtz.cs.liu.campus.domain.student.SchoolStudentEvaluate;
import yangtz.cs.liu.campus.domain.teacherFiles.SchoolTeacherBasicInformation;
import yangtz.cs.liu.campus.domain.teacherFiles.SchoolTeacherBasiclnExport;
import yangtz.cs.liu.campus.domain.teacherFiles.TeacherFiles;
import yangtz.cs.liu.campus.service.impl.teacherFiles.IdCardNumberUtils;
import yangtz.cs.liu.campus.service.teacherFiles.SchoolTeacherBasichlnformationService;
import yangtz.cs.liu.campus.vo.schoolClass.SchoolClassDrVo;
import yangtz.cs.liu.wechat.controller.api.WxApiController;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/teacher/basiclnformation")
public class SchoolTeacherBasiclnformationController extends BaseController {
private Logger log = LoggerFactory.getLogger(SchoolTeacherBasiclnformationController.class);
@Autowired
private SchoolTeacherBasichlnformationService basichlnformationService;
/**
* 获取老师基本信息列表
* @param information
* @return
*/
@GetMapping("/list")
public TableDataInfo list(SchoolTeacherBasicInformation information) throws Exception{
startPage();
List<SchoolTeacherBasicInformation> list = basichlnformationService.list(information);
return getDataTable(list);
}
/**
* 获取详情
*/
@GetMapping("/{id}")
public AjaxResult getById(@PathVariable("id") Long id ) throws Exception{
return AjaxResult.success(basichlnformationService.getById(id));
}
/**
* 新增老师信息
*/
@PostMapping("/add")
public AjaxResult add(@RequestBody SchoolTeacherBasicInformation information){
//出生年月日获取
String birthDayFromIdCard = IdCardNumberUtils.getBirthDayFromIdCard(information.getIdCard());
information.setBirthDate(birthDayFromIdCard);
//性别获取
Map<String, Object> sexFromIdCard = IdCardNumberUtils.getSexFromIdCard(information.getIdCard());
Integer sex = (Integer) sexFromIdCard.get(IdCardNumberUtils.SEX_BY_INT_MAP_KEY);
if (sex == 1){
information.setSex("0");
}else {
information.setSex("1");
}
return AjaxResult.success(basichlnformationService.save(information));
}
/**
* 修改老师信息
*/
@PutMapping("/update")
public AjaxResult update(@RequestBody SchoolTeacherBasicInformation information){
return AjaxResult.success(basichlnformationService.updateById(information));
}
/**
* 删除信息
*/
@DeleteMapping("/{ids}")
public AjaxResult delete(@PathVariable Long[] ids){
List<Long> list = Arrays.asList(ids);
boolean b = basichlnformationService.removeByIds(list);
return AjaxResult.success(b);
}
@GetMapping(value = "/download")
public void downloadFile(HttpServletResponse response) throws Exception {
// 以流的形式下载文件。
try {
//读取文件
InputStream resourceAsStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("file/教师基础信息导入模板.xlsx");
InputStream fis = new BufferedInputStream(resourceAsStream);
byte[] buffer = new byte[fis.available()];
fis.read(buffer);
fis.close();
// 清空response
response.reset();
// 设置response的Header
response.setHeader("Content-Disposition", "attachment;filename="+java.net.URLEncoder.encode("教师基础信息导入模板.xlsx", "utf-8"));
//response.addHeader("Content-Disposition", "attachment;filename=" + new String(filename.getBytes()));
response.addHeader("Content-Length", "" + buffer.length);
OutputStream toClient = new BufferedOutputStream(response.getOutputStream());
response.setContentType("application/octet-stream");
toClient.write(buffer);
toClient.flush();
toClient.close();
} catch (IOException e) {
log.info(e.getMessage());
}
}
/**
* 导入
*
* @param file
* @return
* @throws Exception
*/
@PostMapping("/importData")
public AjaxResult importData(MultipartFile file) throws Exception {
List<SchoolTeacherBasicInformation> schoolTeacherBasicInformations = basichlnformationService.importExcel(file);
for (SchoolTeacherBasicInformation date : schoolTeacherBasicInformations){
//1.处理出生日期
String birthDayFromIdCard = IdCardNumberUtils.getBirthDayFromIdCard(date.getIdCard());
date.setBirthDate(birthDayFromIdCard);
//2.处理性别
Map<String, Object> sexFromIdCard = IdCardNumberUtils.getSexFromIdCard(date.getIdCard());
Integer sex = (Integer) sexFromIdCard.get(IdCardNumberUtils.SEX_BY_INT_MAP_KEY);
if (sex == 1){
date.setSex("0");
}else {
date.setSex("1");
}
}
boolean b = basichlnformationService.saveBatch(schoolTeacherBasicInformations);
return AjaxResult.success(b);
}
/**
* 导出
*
* @param
* @return
*/
@PostMapping("/export")
public void export(HttpServletResponse response,@RequestBody SchoolTeacherBasiclnExport export ) throws Exception{
List<SchoolTeacherBasicInformation> list = new ArrayList<>();
List<SchoolTeacherBasiclnExport> exportList = new ArrayList<>();
ExcelUtil<SchoolTeacherBasiclnExport> util = new ExcelUtil<>(SchoolTeacherBasiclnExport.class);
if (null != export.getIds()){
//1.当前为选中导出
for (int i = 0 ; i < export.getIds().length;i++){
SchoolTeacherBasicInformation byId = basichlnformationService.getById(export.getIds()[i]);
list.add(byId);
}
//复制一份
list.stream().forEach(date->{
SchoolTeacherBasiclnExport schoolTeacherBasiclnExport = new SchoolTeacherBasiclnExport();
BeanUtils.copyProperties(date,schoolTeacherBasiclnExport);
exportList.add(schoolTeacherBasiclnExport);
});
util.exportExcel(response, exportList, "教师基本信息");
}else if (null != export.getId()){
//单条导出
SchoolTeacherBasicInformation byId = basichlnformationService.getById(export.getId());
SchoolTeacherBasiclnExport schoolTeacherBasiclnExport = new SchoolTeacherBasiclnExport();
BeanUtils.copyProperties(byId,schoolTeacherBasiclnExport);
exportList.add(schoolTeacherBasiclnExport);
util.exportExcel(response, exportList, "教师基本信息");
}else {
//全部导出,条件导出
LambdaQueryWrapper<SchoolTeacherBasicInformation> wrapper = Wrappers.lambdaQuery();
//学科
wrapper.eq(StringUtils.isNotEmpty(export.getTeachingSubject()),SchoolTeacherBasicInformation::getTeachingSubject,export.getTeachingSubject());
//姓名
wrapper.like(StringUtils.isNotEmpty(export.getName()),SchoolTeacherBasicInformation::getName,export.getName());
//性别
wrapper.eq(StringUtils.isNotEmpty(export.getSex()),SchoolTeacherBasicInformation::getSex,export.getSex());
//政治面貌
wrapper.eq(StringUtils.isNotEmpty(export.getPoliticalLandscape()),SchoolTeacherBasicInformation::getPoliticalLandscape,export.getPoliticalLandscape());
//现职称
wrapper.like(StringUtils.isNotEmpty(export.getCurrentProfessionalTitle()),SchoolTeacherBasicInformation::getCurrentProfessionalTitle,export.getCurrentProfessionalTitle());
//在岗情况
wrapper.eq(StringUtils.isNotEmpty(export.getOnDutySituation()),SchoolTeacherBasicInformation::getOnDutySituation,export.getOnDutySituation());
//毕业院校
if (StringUtils.isNotEmpty(export.getGraduationInstitution1())){
wrapper.and(w->w.like(SchoolTeacherBasicInformation::getGraduationInstitution1,export.getGraduationInstitution1())
.or()
.like(SchoolTeacherBasicInformation::getGraduationInstitution2,export.getGraduationInstitution1())
.or()
.like(SchoolTeacherBasicInformation::getGraduationInstitution3,export.getGraduationInstitution1())
);
}
//学历
if (StringUtils.isNotEmpty(export.getFirstDegree())) {
wrapper.and(w->w.like(SchoolTeacherBasicInformation::getFirstDegree,export.getFirstDegree())
.or()
.like(SchoolTeacherBasicInformation::getLastDegree,export.getFirstDegree()));
}
//查询出来结果复制
List<SchoolTeacherBasicInformation> list1 = basichlnformationService.list(wrapper);
list1.forEach(date->{
SchoolTeacherBasiclnExport schoolTeacherBasiclnExport = new SchoolTeacherBasiclnExport();
BeanUtils.copyProperties(date,schoolTeacherBasiclnExport);
exportList.add(schoolTeacherBasiclnExport);
});
util.exportExcel(response, exportList, "教师基本信息");
}
}
}
package yangtz.cs.liu.campus.domain.teacherFiles;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.core.domain.OurBaseEntity;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.NonNull;
import java.util.Date;
/**
* 教师电子档案 老师基础信息
*/
@Data
public class SchoolTeacherBasicInformation extends BaseEntity {
// @Excel(name = "年级",combo = {"一年级","二年级","三年级"},readConverterExp = "1=一年级,2=二年级,3=三年级")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 姓名
*/
private String name;
/**
* 身份证号
*/
private String idCard;
/**
* 年龄 。动态查询
*/
private Integer age;
/**
* 性别
*/
private String sex;
/**
* 档案出生日期 (年月)
*/
private Date fileBirthDate;
/**
* 档案年龄
*/
private Integer fileAge;
/**
* 出生年月
*/
private String birthDate;
/**
* 籍贯
*/
private String hometown;
/**
* 民族
*/
private String nation;
/**
* 政治面貌(1中共党员、2共青团员、3群众、4民主党派成员、5无党派人士)
*/
private String politicalLandscape;
/**
* 入党时间(年月)
*/
private Date partyMembershipTime;
/**
* 任教学科(1语文、2数学、3英语、4物理、5化学、6生物、7政治、8历史、9地理、10音乐、11体育、12美术、13技术、14心理、15书法)
*/
private String teachingSubject;
/**
* 现职称(1无、2初级、3中级、4副高、5正高)
*/
private String currentProfessionalTitle;
/**
* 现职称取得资格时间
*/
private Date currentProfessionalTitleTime;
/**
* 现聘职称(1无、2初级、3中级、4副高、5正高)
*/
private String currentHiringProfessionalTitle;
/**
* 现职称聘任时间
*/
private Date currentHiringProfessionalTitleTime;
/**
* 现聘岗位(1专业技术岗、2管理岗、3工勤岗)
*/
private String currentPosition;
/**
* 现岗位等级(见习(三个现聘岗位都有见习这个等级 下拉框联动)、专业技术三级-专业技术十三级、
* 管理五级-管理九级、技术工二级-技术工五级)
*/
private String currentJobLevel;
/**
* 现岗位等级聘任时间
*/
private Date currentJobLevelAppointmentTime;
/**
* 职务
*/
private String duties;
/**
* 教师资格种类
*/
private String teacherQualificationType;
/**
* 教师资格证号码
*/
private String teacherQualificationCertificateNum;
/**
* 参加工作时间
*/
private String workingHours;
/**
* 到二中工作时间
*/
private Date toSecondMiddleSchoolTime;
/**
* 二中工作年龄
*/
private Integer toSecondAge;
/**
* 教龄起算时间
*/
private Date lengthOfTeacherTime;
/**
* 工龄起算时间
*/
private Date lengthOfServiceTime;
/**
* 工龄年限
*/
private Integer seniority;
/**
* 在岗情况(1教学岗位、2教辅岗、3后勤岗、4管理岗、5其他岗、6退休、7行政、8内退岗、9待退岗)
*/
private String onDutySituation;
/**
* 在编情况 1在编 2合同制
*/
private String currentSituation;
/**
* 毕业院校1
*/
private String graduationInstitution1;
/**
* 专业1
*/
private String major1;
/**
* 毕业时间1 年月
*/
private Date graduationTime1;
/**
* 毕业院校2
*/
private String graduationInstitution2;
/**
* 专业2
*/
private String major2;
/**
* 毕业时间2年月
*/
private Date graduationTime2;
/**
* 毕业院校3
*/
private String graduationInstitution3;
/**
* 专业3
*/
private String major3;
/**
* 毕业时间3 年月
*/
private Date graduationTime3;
/**
* 第一学历
*/
private String firstDegree;
/**
* 最后学历
*/
private String lastDegree;
/**
* 学位
*/
private String degree;
/**
* 工作经历
*/
private String workExperience;
/**
* 照片名称
*/
private String photoName;
/**
* 照片地址
*/
private String photoUrl;
/**
* 钉钉手机号
*/
private String ddPhone;
/**
* 出生日期临时查询参数
*/
private String birthDategt;
private String birthDategtd;
private String birthDatelt;
private String birthDateltd;
/**
* 参加工作临时查询参数
*/
private String workingHoursgt;
private String workingHoursgtd;
private String workingHourslt;
private String workingHoursltd;
}
package yangtz.cs.liu.campus.domain.teacherFiles;
import com.ruoyi.common.annotation.Excel;
import lombok.Data;
import java.util.Date;
/**
* 教师电子档案导出对象
*/
@Data
public class SchoolTeacherBasiclnExport {
/**
* 选中导出参数
*/
private Long[] ids;
@Excel(name = "编号")
private Long id;
/**
* 姓名
*/
@Excel(name = "姓名")
private String name;
/**
* 身份证号
*/
@Excel(name = "身份证号")
private String idCard;
/**
* 年龄 。动态查询
*/
@Excel(name = "年龄")
private Integer age;
/**
* 性别
*/
@Excel(name = "性别", readConverterExp = "0=男,1=女,2=未知")
private String sex;
/**
* 档案出生日期 (年月)
*/
@Excel(name = "档案出生日期" ,dateFormat="yyyy-MM-dd")
private Date fileBirthDate;
/**
* 档案年龄
*/
@Excel(name = "档案年龄")
private Integer fileAge;
/**
* 出生年月
*/
@Excel(name = "出生年月")
private String birthDate;
/**
* 籍贯
*/
@Excel(name = "籍贯")
private String hometown;
/**
* 民族
*/
@Excel(name = "民族")
private String nation;
/**
* 政治面貌(1中共党员、2共青团员、3群众、4民主党派成员、5无党派人士)
*/
@Excel(name = "政治面貌" ,dictType="politics_tatusls")
private String politicalLandscape;
/**
* 入党时间(年月)
*/
@Excel(name = "入党时间" ,dateFormat="yyyy-MM-dd")
private Date partyMembershipTime;
/**
* 任教学科(1语文、2数学、3英语、4物理、5化学、6生物、7政治、8历史、9地理、10音乐、11体育、12美术、13技术、14心理、15书法)
*/
@Excel(name = "任教学科" ,dictType= "teaching_subjects")
private String teachingSubject;
/**
* 现职称(1无、2初级、3中级、4副高、5正高)
*/
@Excel(name = "现职称" ,dictType= "current_professional")
private String currentProfessionalTitle;
/**
* 现职称取得资格时间
*/
@Excel(name = "现职称取得时间" ,dateFormat="yyyy-MM-dd")
private Date currentProfessionalTitleTime;
/**
* 现聘职称(1无、2初级、3中级、4副高、5正高)
*/
@Excel(name = "现聘职称",dictType= "current_professional")
private String currentHiringProfessionalTitle;
/**
* 现职称聘任时间
*/
@Excel(name = "现聘职称取得时间" ,dateFormat="yyyy-MM-dd")
private Date currentHiringProfessionalTitleTime;
/**
* 现聘岗位(1专业技术岗、2管理岗、3工勤岗)
*/
@Excel(name = "现聘岗位" ,dictType= "current_position")
private String currentPosition;
/**
* 现岗位等级聘任时间
*/
@Excel(name = "现聘岗位取得时间" ,dateFormat="yyyy-MM-dd")
private Date currentJobLevelAppointmentTime;
/**
* 现岗位等级(见习(三个现聘岗位都有见习这个等级 下拉框联动)、专业技术三级-专业技术十三级、
* 管理五级-管理九级、技术工二级-技术工五级)
*/
@Excel(name = "现岗位等级" ,dictType= "current_joblevel")
private String currentJobLevel;
/**
* 职务
*/
@Excel(name = "职务")
private String duties;
/**
* 教师资格种类
*/
@Excel(name = "教师资格种类")
private String teacherQualificationType;
/**
* 教师资格证号码
*/
@Excel(name = "教师资格证号码")
private String teacherQualificationCertificateNum;
/**
* 参加工作时间
*/
@Excel(name = "参加工作时间")
private String workingHours;
/**
* 到二中工作时间
*/
@Excel(name = "到二中工作时间" ,dateFormat="yyyy-MM-dd")
private Date toSecondMiddleSchoolTime;
/**
* 二中工作年龄
*/
@Excel(name = "到二中工作年限")
private Integer toSecondAge;
/**
* 教龄起算时间
*/
private Date lengthOfTeacherTime;
/**
* 工龄起算时间
*/
private Date lengthOfServiceTime;
/**
* 工龄年限
*/
private Integer seniority;
/**
* 在岗情况(1教学岗位、2教辅岗、3后勤岗、4管理岗、5其他岗、6退休、7行政、8内退岗、9待退岗)
*/
@Excel(name = "在岗情况" ,dictType= "duty_situation")
private String onDutySituation;
/**
* 在编情况 1在编 2合同制
*/
private String currentSituation;
/**
* 毕业院校1
*/
@Excel(name = "毕业院校1")
private String graduationInstitution1;
/**
* 专业1
*/
@Excel(name = "专业1")
private String major1;
/**
* 毕业时间1 年月
*/
@Excel(name = "毕业时间1",dateFormat="yyyy-MM-dd")
private Date graduationTime1;
/**
* 毕业院校2
*/
@Excel(name = "毕业院校2")
private String graduationInstitution2;
/**
* 专业2
*/
@Excel(name = "专业2")
private String major2;
/**
* 毕业时间2年月
*/
@Excel(name = "毕业时间2",dateFormat="yyyy-MM-dd")
private Date graduationTime2;
/**
* 毕业院校3
*/
@Excel(name = "毕业院校3")
private String graduationInstitution3;
/**
* 专业3
*/
@Excel(name = "专业3")
private String major3;
/**
* 毕业时间3 年月
*/
@Excel(name = "毕业时间3",dateFormat="yyyy-MM-dd")
private Date graduationTime3;
/**
* 第一学历
*/
@Excel(name = "第一学历")
private String firstDegree;
/**
* 最后学历
*/
@Excel(name = "最后学历")
private String lastDegree;
/**
* 学位
*/
@Excel(name = "学位")
private String degree;
/**
* 工作经历
*/
@Excel(name = "工作经历")
private String workExperience;
/**\
* 备注
*/
@Excel(name = "备注")
private String remark;
/**
* 照片名称
*/
private String photoName;
/**
* 照片地址
*/
private String photoUrl;
/**
* 钉钉手机号
*/
private String ddPhone;
}
package yangtz.cs.liu.campus.mapper.teacherFiles;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import yangtz.cs.liu.campus.domain.teacherFiles.SchoolTeacherBasicInformation;
import java.util.List;
public interface SchoolTeacherBasichlnformationMapper extends BaseMapper<SchoolTeacherBasicInformation> {
List<SchoolTeacherBasicInformation> list(SchoolTeacherBasicInformation information);
SchoolTeacherBasicInformation selectById(Long id);
}
package yangtz.cs.liu.campus.service.impl.teacherFiles;
import com.ruoyi.common.utils.StringUtils;
import java.util.Calendar;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* @desc 身份证工具类
* @auth llp
* @date 2022/7/7 16:13
*/
public class IdCardNumberUtils {
/** 检验码:余数作为索引,值代表所替换的值 */
private static final String[] CHECK_INDEX = {"1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2"};
/** 居民身份证 正则表达式 */
private static final String SECOND_ID_CARD_REGULAR_EXP = "(^\\d{18}$)|(^\\d{17}(\\d|X|x)$|(^\\d{15}$))";
/** 居民身份证 年份所在位数 */
private static final int ID_CARD_YEAR_INDEX = 6;
/** 第一代居民身份证长度 */
private static final int FIRST_ID_CARD_LENGTH = 15;
/** 第一代居民身份证 年份值 */
private static final String FIRST_ID_CARD_YEAR = "19";
/** 第二代居民身份证长度 */
private static final int SECOND_ID_CARD_LENGTH = 18;
/** 第二代居民身份证 校验码的模 */
private static final int SECOND_ID_CARD_CHECK_MOD = 11;
/** 性别表示的值 */
private static final int MALE_SEX_INT = 1;
private static final String MALE_SEX_STRING = "男";
private static final int FEMALE_SEX_INT = 2;
private static final String FEMALE_SEX_STRING = "女";
/** 性别 map 中的 key 值 */
public static final String SEX_BY_INT_MAP_KEY = "sex_by_int";
public static final String SEX_BY_STRING_MAP_KEY = "sex_by_string";
/**
* @desc 通过身份证获取年龄
* @auth llp
* @date 2022/7/11 17:09
* @param idCard 身份证
* @return java.lang.String
*/
public static int getAgeFromIdCard(String idCard){
if (!isIdCard(idCard)){
return -1;
}
// 获取身份证的出生年月日串
String birth = getIdCardBirthDayStr(idCard);
// 获取年月日
int year = Integer.parseInt(birth.substring(0, 4));
int month = Integer.parseInt(birth.substring(4, 6));
int day = Integer.parseInt(birth.substring(6, 8));
// 计算年龄
Calendar cal = Calendar.getInstance();
int age = cal.get(Calendar.YEAR) - year;
// 周岁计算
boolean monthLtFlag = cal.get(Calendar.MONTH)+1 < month;
boolean monthDayFlag = cal.get(Calendar.MONTH)+1 == month && cal.get(Calendar.DATE) < day;
if ( monthLtFlag || monthDayFlag){
age--;
}
return age;
}
/**
* @desc 通过身份证获取出生日期
* @auth llp
* @date 2022/7/15 16:39
* @param idCard 身份证
* @return java.lang.String
*/
public static String getBirthDayFromIdCard(String idCard){
if (!isIdCard(idCard)){
return "idCard error!";
}
// 获取身份证的出生年月日串
String birth = getIdCardBirthDayStr(idCard);
// 获取年月日
int year = Integer.parseInt(birth.substring(0, 4));
int month = Integer.parseInt(birth.substring(4, 6));
int day = Integer.parseInt(birth.substring(6, 8));
return year + "-" + month + "-" + day;
}
/**
* @desc 通过身份证获取性别
* @auth llp
* @date 2022/7/15 16:10
* @param idCard 身份证
* @return java.util.Map<java.lang.String,java.lang.Object>
*/
public static Map<String, Object> getSexFromIdCard(String idCard){
if (!isIdCard(idCard)){
return Collections.emptyMap();
}
Map<String, Object> sexMap = new HashMap<>();
// 默认值
int sexInt = -1;
String sexStr = "未知";
// 15 位身份证
if (idCard.length() == FIRST_ID_CARD_LENGTH){
String sex = idCard.substring(14, 15);
// 偶数表示女性,奇数表示男性
if (Integer.parseInt(sex) % 2 == 0){
sexInt = FEMALE_SEX_INT;
sexStr = FEMALE_SEX_STRING;
}else {
sexInt = MALE_SEX_INT;
sexStr = MALE_SEX_STRING;
}
}
// 18 位身份证
if (idCard.length() == SECOND_ID_CARD_LENGTH){
String sex = idCard.substring(16, 17);
// 偶数表示女性,奇数表示男性
if (Integer.parseInt(sex) % 2 == 0){
sexInt = FEMALE_SEX_INT;
sexStr = FEMALE_SEX_STRING;
}else {
sexInt = MALE_SEX_INT;
sexStr = MALE_SEX_STRING;
}
}
// 结果
sexMap.put(SEX_BY_INT_MAP_KEY, sexInt);
sexMap.put(SEX_BY_STRING_MAP_KEY, sexStr);
return sexMap;
}
/**
* @desc 检测是否为身份证
* @auth llp
* @date 2022/7/11 15:32
* @param idCard 身份证
* @return boolean
*/
public static boolean isIdCard(String idCard){
if (StringUtils.isBlank(idCard)){
return false;
}
StringBuilder idCardBuilder = new StringBuilder(idCard);
// 正则表达式
boolean matches = idCard.matches(SECOND_ID_CARD_REGULAR_EXP);
// 第二代身份证的验证
if (matches && idCardBuilder.length() == SECOND_ID_CARD_LENGTH){
int index = getIdCardCheckIndex(idCardBuilder);
// 获取传入身份证的检验码
String check = String.valueOf(idCardBuilder.charAt(idCardBuilder.length()-1));
// 检验码校验
return StringUtils.equalsIgnoreCase(CHECK_INDEX[index], check);
}
return matches;
}
/**
* @desc 将 15位身份证号码转为 18位身份证号码
* @auth llp
* @date 2022/7/11 15:13
* @param idCard 身份证号码
* @return java.lang.String
*/
public static String idCardNumber15To18(String idCard){
if (!isIdCard(idCard) || idCard.length() != FIRST_ID_CARD_LENGTH){
return "idCard error!";
}
StringBuilder idCardBuilder = new StringBuilder(idCard);
// 在 第6位后插入年份
idCardBuilder.insert(ID_CARD_YEAR_INDEX, FIRST_ID_CARD_YEAR);
int index =getIdCardCheckIndex(idCardBuilder);
// 根据余数在校验码数组里取值
idCardBuilder.append(CHECK_INDEX[index]);
return idCardBuilder.toString();
}
/**
* @desc 将 18位身份证号码转为 15位身份证号码
* @auth llp
* @date 2022/7/15 16:40
* @param idCard 身份证号码
* @return java.lang.String
*/
public static String idCardNumber18To15(String idCard){
if (!isIdCard(idCard) || idCard.length() != SECOND_ID_CARD_LENGTH){
return "idCard error!";
}
// 去掉18位身份证的年份前两位 去掉校验码
return idCard.substring(0, 5)+idCard.substring(8, 17);
}
/**
* @desc 计算出校验码所在校验码数组的下标值
* @auth llp
* @date 2022/7/13 9:51
* @param idCardBuilder 身份证
* @return int 检验码下标
*/
private static int getIdCardCheckIndex(StringBuilder idCardBuilder){
// 判断传入的是17位还是18位身份证号
int length = idCardBuilder.length() == SECOND_ID_CARD_LENGTH ? idCardBuilder.length()-1 : idCardBuilder.length();
// 计算出校验码
int sum = 0;
// length=17, i=0、2、3...16
for (int i = 0; i < length; i++) {
// 前17位数字
int numVal = Integer.parseInt(String.valueOf(idCardBuilder.charAt(i)));
int numMultiple = (int) (Math.pow(2, length - i) % SECOND_ID_CARD_CHECK_MOD);
sum += (numVal * numMultiple);
}
// 总和取模11
return sum % SECOND_ID_CARD_CHECK_MOD;
}
/**
* @desc 通过身份证获取出生日期的 str 串
* @auth llp
* @date 2022/7/15 16:37
* @param idCard 身份证
* @return java.lang.String
*/
private static String getIdCardBirthDayStr(String idCard){
// 获取身份证的出生年月日串
if (idCard.length() == FIRST_ID_CARD_LENGTH){
return FIRST_ID_CARD_YEAR + idCard.substring(ID_CARD_YEAR_INDEX, 12);
}
if (idCard.length() == SECOND_ID_CARD_LENGTH){
return idCard.substring(ID_CARD_YEAR_INDEX, 14);
}
return StringUtils.EMPTY;
}
}
package yangtz.cs.liu.campus.service.impl.teacherFiles;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.mapper.SysDictDataMapper;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import yangtz.cs.liu.campus.domain.teacherFiles.SchoolTeacherBasicInformation;
import yangtz.cs.liu.campus.mapper.teacherFiles.SchoolTeacherBasichlnformationMapper;
import yangtz.cs.liu.campus.service.teacherFiles.SchoolTeacherBasichlnformationService;
import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@Service
public class SchoolTeacherBasichlnformationServicelmpl extends ServiceImpl<SchoolTeacherBasichlnformationMapper, SchoolTeacherBasicInformation> implements SchoolTeacherBasichlnformationService
{
@Autowired
private SchoolTeacherBasichlnformationMapper teacherBasichlnformationMapper;
@Autowired
private SysDictDataMapper dictDataMapper;
@Override
public List<SchoolTeacherBasicInformation> list(SchoolTeacherBasicInformation information) throws Exception {
//出生日期查询条件转换
this.symbolConversion(information);
this.wordDateConversion(information);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
String format = sdf.format(new Date());
List<SchoolTeacherBasicInformation> list = teacherBasichlnformationMapper.list(information);
for (SchoolTeacherBasicInformation date :list){
//1.计算年龄
int ageFromIdCard = IdCardNumberUtils.getAgeFromIdCard(date.getIdCard());
date.setAge(ageFromIdCard);
//2.计算档案年龄
if (null != date.getFileBirthDate()){
int age = this.getAge(date.getFileBirthDate());
date.setFileAge(age);
}
//3.到二中工作年限
int gl = this.workAge(sdf.parse(format),date.getToSecondMiddleSchoolTime());
date.setToSecondAge(gl);
}
return list;
}
@Override
public SchoolTeacherBasicInformation getById(Long id) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
String format = sdf.format(new Date());
SchoolTeacherBasicInformation schoolTeacherBasicInformation = teacherBasichlnformationMapper.selectById(id);
//1.计算年龄
int ageFromIdCard = IdCardNumberUtils.getAgeFromIdCard(schoolTeacherBasicInformation.getIdCard());
schoolTeacherBasicInformation.setAge(ageFromIdCard);
//2.计算档案年龄
int age = this.getAge(schoolTeacherBasicInformation.getFileBirthDate());
schoolTeacherBasicInformation.setFileAge(age);
//3.到二中工作年限
int nl = this.workAge(sdf.parse(format),schoolTeacherBasicInformation.getToSecondMiddleSchoolTime());
schoolTeacherBasicInformation.setToSecondAge(nl);
//4. 工作年龄
if (null != schoolTeacherBasicInformation.getLengthOfServiceTime()){
int gl = this.workAge(sdf.parse(format),schoolTeacherBasicInformation.getLengthOfServiceTime());
schoolTeacherBasicInformation.setSeniority(gl);
}
return schoolTeacherBasicInformation;
}
/**
* 导入
* @param
* @return
*/
@Override
public List<SchoolTeacherBasicInformation> importExcel(MultipartFile file) {
List<SchoolTeacherBasicInformation> list = new ArrayList<>();
try {
XSSFWorkbook xwb = new XSSFWorkbook(file.getInputStream());//导入.xlxs
//HSSFWorkbook hwb = new HSSFWorkbook(file.getInputStream());//导入.xls
//获取第一个sheet表,下标是从0开始的
XSSFSheet sheet = xwb.getSheetAt(0);
int sheetNum = xwb.getNumberOfSheets();//获取总共有几个sheet表
int rowNum = sheet.getLastRowNum(); //获取excel最后有数据的一行为n,返回n-1.返回数据行的下标 从0开始
for (int i = 2; i <= rowNum; i++) {
SchoolTeacherBasicInformation vo = new SchoolTeacherBasicInformation();
XSSFRow row = sheet.getRow(i); //获取excel第i行,下标从0开始,第一行的下标为0
//XSSFCell cell = row.getCell(0);//获取第i行的第一个单元格
//名称
if (row.getCell(1) != null) {
row.getCell(1).setCellType(CellType.STRING);//设置第i行第一个单元格数据为String类型
String name = row.getCell(1).getStringCellValue(); //获取第一个单元格的值
vo.setName(name);
}
//身份证
if (row.getCell(2) != null) {
row.getCell(2).setCellType(CellType.STRING);
String shelterAddress = row.getCell(2).getStringCellValue(); //获取String类型的值
vo.setIdCard(shelterAddress);
}
//档案出生日期
if (row.getCell(3) != null) {
//对于想要获取日期的值,可以把单元格设置为日期类型,但是如果直接设置为日期类型,表格中的数据不是日期类型,则会导致数据变为1970年或者其他不准确的年份
//先判断数据是否为日期类型
CellType type = row.getCell(3).getCellType();
//1为公式类型
row.getCell(3).setCellType(CellType.STRING);
String shelterAddress = row.getCell(3).getStringCellValue(); //获取日期类型的值
vo.setFileBirthDate(DateUtils.parseDate(shelterAddress));
}
//籍贯
if (row.getCell(4) != null) {
row.getCell(4).setCellType(CellType.STRING);
String shelterAddress = row.getCell(4).getStringCellValue(); //获取String类型的值
vo.setHometown(shelterAddress);
}
//民族
if (row.getCell(5) != null) {
row.getCell(5).setCellType(CellType.STRING);
String shelterAddress = row.getCell(5).getStringCellValue(); //获取String类型的值
vo.setNation(shelterAddress);
}
//政治面貌
if (row.getCell(6) != null) {
row.getCell(6).setCellType(CellType.STRING);
String shelterAddress = row.getCell(6).getStringCellValue(); //获取String类型的值
String s = dictDataMapper.selectDictValue("politics_tatusls", shelterAddress);
vo.setPoliticalLandscape(s);
}
//入党时间
if (row.getCell(7) != null) {
//对于想要获取日期的值,可以把单元格设置为日期类型,但是如果直接设置为日期类型,表格中的数据不是日期类型,则会导致数据变为1970年或者其他不准确的年份
//先判断数据是否为日期类型
//1为公式类型
row.getCell(7).setCellType(CellType.STRING);
String setDate = row.getCell(7).getStringCellValue(); //获取日期类型的值
vo.setPartyMembershipTime(DateUtils.parseDate(setDate));
}
//任教学科
if (row.getCell(8) != null) {
row.getCell(8).setCellType(CellType.STRING);
String shelterAddress = row.getCell(8).getStringCellValue(); //获取String类型的值
String s = dictDataMapper.selectDictValue("teaching_subjects", shelterAddress);
vo.setTeachingSubject(s);
}
//钉钉手机号
if (row.getCell(9) != null) {
row.getCell(9).setCellType(CellType.STRING);
String shelterAddress = row.getCell(9).getStringCellValue(); //获取String类型的值
vo.setDdPhone(shelterAddress);
}
//现职称
if (row.getCell(10) != null) {
row.getCell(10).setCellType(CellType.STRING);
String shelterAddress = row.getCell(10).getStringCellValue(); //获取String类型的值
String s = dictDataMapper.selectDictValue("current_professional", shelterAddress);
vo.setCurrentProfessionalTitle(s);
}
//现职称获取资格时间 currentProfessionalTitleTime
if (row.getCell(11) != null) {
//对于想要获取日期的值,可以把单元格设置为日期类型,但是如果直接设置为日期类型,表格中的数据不是日期类型,则会导致数据变为1970年或者其他不准确的年份
//先判断数据是否为日期类型
//1为公式类型
row.getCell(11).setCellType(CellType.STRING);
String setDate = row.getCell(11).getStringCellValue(); //获取日期类型的值
vo.setCurrentProfessionalTitleTime(DateUtils.parseDate(setDate));
}
//现聘职称
if (row.getCell(12) != null) {
row.getCell(12).setCellType(CellType.STRING);
String shelterAddress = row.getCell(12).getStringCellValue(); //获取String类型的值
String s = dictDataMapper.selectDictValue("current_professional", shelterAddress);
vo.setCurrentHiringProfessionalTitle(s);
}
//现职称聘用时间 currentHiringProfessionalTitleTime
if (row.getCell(13) != null) {
//对于想要获取日期的值,可以把单元格设置为日期类型,但是如果直接设置为日期类型,表格中的数据不是日期类型,则会导致数据变为1970年或者其他不准确的年份
//先判断数据是否为日期类型
CellType type = row.getCell(13).getCellType();
//1为公式类型
row.getCell(13).setCellType(CellType.STRING);
String setDate = row.getCell(13).getStringCellValue(); //获取日期类型的值
vo.setCurrentHiringProfessionalTitleTime(DateUtils.parseDate(setDate));
}
//现聘岗位
if (row.getCell(14) != null) {
row.getCell(14).setCellType(CellType.STRING);
String shelterAddress = row.getCell(14).getStringCellValue(); //获取String类型的值
String s = dictDataMapper.selectDictValue("current_position", shelterAddress);
vo.setCurrentJobLevel(s);
}
//现岗位等级
if (row.getCell(15) != null) {
row.getCell(15).setCellType(CellType.STRING);
String shelterAddress = row.getCell(15).getStringCellValue(); //获取String类型的值
String s = dictDataMapper.selectDictValue("current_joblevel", shelterAddress);
vo.setCurrentJobLevel(s);
}
//现岗位聘用时间 currentJobLevelAppointmentTime
if (row.getCell(16) != null) {
//对于想要获取日期的值,可以把单元格设置为日期类型,但是如果直接设置为日期类型,表格中的数据不是日期类型,则会导致数据变为1970年或者其他不准确的年份
//先判断数据是否为日期类型
//1为公式类型
row.getCell(16).setCellType(CellType.STRING);
String setDate = row.getCell(16).getStringCellValue(); //获取日期类型的值
vo.setCurrentJobLevelAppointmentTime(DateUtils.parseDate(setDate));
}
//职务
if (row.getCell(17) != null) {
row.getCell(17).setCellType(CellType.STRING);
String shelterAddress = row.getCell(17).getStringCellValue(); //获取String类型的值
vo.setDuties(shelterAddress);
}
//教师资格种类
if (row.getCell(18) != null) {
row.getCell(18).setCellType(CellType.STRING);
String shelterAddress = row.getCell(18).getStringCellValue(); //获取String类型的值
vo.setTeacherQualificationType(shelterAddress);
}
//教师资格证号码
if (row.getCell(19) != null) {
row.getCell(19).setCellType(CellType.STRING);
String shelterAddress = row.getCell(19).getStringCellValue(); //获取String类型的值
vo.setTeacherQualificationCertificateNum(shelterAddress);
}
//参加工作时间
if (row.getCell(20) != null) {
row.getCell(20).setCellType(CellType.STRING);
String shelterAddress = row.getCell(20).getStringCellValue(); //获取String类型的值
vo.setWorkingHours(shelterAddress);
}
//到二中工作时间
if (row.getCell(21) != null) {
//对于想要获取日期的值,可以把单元格设置为日期类型,但是如果直接设置为日期类型,表格中的数据不是日期类型,则会导致数据变为1970年或者其他不准确的年份
//先判断数据是否为日期类型
//1为公式类型
row.getCell(21).setCellType(CellType.STRING);
String setDate = row.getCell(21).getStringCellValue(); //获取日期类型的值
vo.setToSecondMiddleSchoolTime(DateUtils.parseDate(setDate));
}
//在岗情况
if (row.getCell(22) != null) {
row.getCell(22).setCellType(CellType.STRING);
String shelterAddress = row.getCell(22).getStringCellValue(); //获取String类型的值
String s = dictDataMapper.selectDictValue("duty_situation", shelterAddress);
vo.setCurrentJobLevel(s);
}
//在编情况
if (row.getCell(23) != null) {
row.getCell(23).setCellType(CellType.STRING);
String shelterAddress = row.getCell(23).getStringCellValue(); //获取String类型的值
String s = dictDataMapper.selectDictValue("current_situation", shelterAddress);
vo.setCurrentJobLevel(s);
}
//毕业学院1
if (row.getCell(24) != null) {
row.getCell(24).setCellType(CellType.STRING);
String shelterAddress = row.getCell(24).getStringCellValue(); //获取String类型的值
vo.setGraduationInstitution1(shelterAddress);
}
//专业1
if (row.getCell(25) != null) {
row.getCell(25).setCellType(CellType.STRING);
String shelterAddress = row.getCell(25).getStringCellValue(); //获取String类型的值
vo.setMajor1(shelterAddress);
}
//毕业时间1
if (row.getCell(26) != null) {
//对于想要获取日期的值,可以把单元格设置为日期类型,但是如果直接设置为日期类型,表格中的数据不是日期类型,则会导致数据变为1970年或者其他不准确的年份
//先判断数据是否为日期类型
//1为公式类型
row.getCell(26).setCellType(CellType.STRING);
String setDate = row.getCell(26).getStringCellValue(); //获取日期类型的值
vo.setGraduationTime1(DateUtils.parseDate(setDate));
}
//毕业学院2
if (row.getCell(27) != null) {
row.getCell(27).setCellType(CellType.STRING);
String shelterAddress = row.getCell(27).getStringCellValue(); //获取String类型的值
vo.setGraduationInstitution2(shelterAddress);
}
//专业2
if (row.getCell(28) != null) {
row.getCell(28).setCellType(CellType.STRING);
String shelterAddress = row.getCell(28).getStringCellValue(); //获取String类型的值
vo.setMajor2(shelterAddress);
}
//毕业时间2
if (row.getCell(29) != null) {
//对于想要获取日期的值,可以把单元格设置为日期类型,但是如果直接设置为日期类型,表格中的数据不是日期类型,则会导致数据变为1970年或者其他不准确的年份
//先判断数据是否为日期类型
//1为公式类型
row.getCell(29).setCellType(CellType.STRING);
String setDate = row.getCell(29).getStringCellValue(); //获取日期类型的值
vo.setGraduationTime2(DateUtils.parseDate(setDate));
}
//毕业学院3
if (row.getCell(30) != null) {
row.getCell(30).setCellType(CellType.STRING);
String shelterAddress = row.getCell(30).getStringCellValue(); //获取String类型的值
vo.setGraduationInstitution3(shelterAddress);
}
//专业3
if (row.getCell(31) != null) {
row.getCell(31).setCellType(CellType.STRING);
String shelterAddress = row.getCell(31).getStringCellValue(); //获取String类型的值
vo.setMajor3(shelterAddress);
}
//毕业时间3
if (row.getCell(32) != null) {
//对于想要获取日期的值,可以把单元格设置为日期类型,但是如果直接设置为日期类型,表格中的数据不是日期类型,则会导致数据变为1970年或者其他不准确的年份
//先判断数据是否为日期类型
//1为公式类型
row.getCell(32).setCellType(CellType.STRING);
String setDate = row.getCell(32).getStringCellValue(); //获取日期类型的值
vo.setGraduationTime3(DateUtils.parseDate(setDate));
}
//第一学历
if (row.getCell(33) != null) {
row.getCell(33).setCellType(CellType.STRING);
String shelterAddress = row.getCell(33).getStringCellValue(); //获取String类型的值
vo.setFirstDegree(shelterAddress);
}
//最后学历
if (row.getCell(34) != null) {
row.getCell(34).setCellType(CellType.STRING);
String shelterAddress = row.getCell(34).getStringCellValue(); //获取String类型的值
vo.setLastDegree(shelterAddress);
}
//学位
if (row.getCell(35) != null) {
row.getCell(35).setCellType(CellType.STRING);
String shelterAddress = row.getCell(35).getStringCellValue(); //获取String类型的值
vo.setDegree(shelterAddress);
}
//工作经理
if (row.getCell(36) != null) {
row.getCell(36).setCellType(CellType.STRING);
String shelterAddress = row.getCell(36).getStringCellValue(); //获取String类型的值
vo.setWorkExperience(shelterAddress);
}
//备注
if (row.getCell(37) != null) {
row.getCell(37).setCellType(CellType.STRING);
String shelterAddress = row.getCell(37).getStringCellValue(); //获取String类型的值
vo.setRemark(shelterAddress);
}
// if (row.getCell(4) != null) {
// row.getCell(4).setCellType(CellType.NUMERIC);
//
// double capacity = row.getCell(4).getNumericCellValue(); //获取数值类型的值
// vo.setCapacity((int) capacity);
// }
list.add(vo);
}
} catch (IOException e) {
e.printStackTrace();
log.error(e.toString());
} catch (IllegalStateException e) {
e.printStackTrace();
log.error(e.toString());
} catch (Exception e) {
e.printStackTrace();
log.error(e.toString());
}
return list;
}
//计算年龄
private int getAge(Date birth) {
Calendar cal = Calendar.getInstance();
int thisYear = cal.get(Calendar.YEAR);
int thisMonth = cal.get(Calendar.MONTH);
cal.setTime(birth);
int birthYear = cal.get(Calendar.YEAR);
int birthMonth = cal.get(Calendar.MONTH);
int age = thisYear - birthYear;
// 未足月
if (thisMonth <= birthMonth) {
// 当月
if (thisMonth == birthMonth) {
} else {
age--;
}
}
return age;
}
//计算工龄
public int workAge(Date nowTime, Date workTime) throws ParseException{
int year = 0;
//当前时间的年月日
Calendar cal = Calendar.getInstance();
cal.setTime(nowTime);
int nowYear = cal.get(Calendar.YEAR);
int nowMonth = cal.get(Calendar.MONTH);
int nowDay = cal.get(Calendar.DAY_OF_MONTH);
//开始工作时间的年月日
cal.setTime(workTime);
int workYear = cal.get(Calendar.YEAR);
int workMonth = cal.get(Calendar.MONTH);
int workDay = cal.get(Calendar.DAY_OF_MONTH);
//得到工龄
year = nowYear - workYear; //得到年差
//若目前月数少于开始工作时间的月数,年差-1
if (nowMonth < workMonth){
year = year - 1;
}else if (nowMonth == workMonth){
//当月数相等时,判断日数,若当月的日数小于开始工作时间的日数,年差-1
if (nowDay < workDay){
year = year - 1;
}
}
return year;
}
/**
* 出生年月条件转换
* @param information
*/
private void symbolConversion(SchoolTeacherBasicInformation information){
String birthDate = information.getBirthDate();
if (StringUtils.isEmpty(birthDate)){
return;
} else if (birthDate.contains(">=")) {
String substring = birthDate.substring(2, birthDate.length());
information.setBirthDategtd(substring);
information.setBirthDate(null);
} else if (birthDate.contains("<=")) {
String substring = birthDate.substring(2, birthDate.length());
information.setBirthDateltd(substring);
information.setBirthDate(null);
} else if (birthDate.contains("<")) {
String substring = birthDate.substring(1, birthDate.length());
information.setBirthDatelt(substring);
information.setBirthDate(null);
} else if (birthDate.contains(">")) {
String substring = birthDate.substring(1, birthDate.length());
information.setBirthDategt(substring);
information.setBirthDate(null);
} else if (birthDate.contains("=")) {
String substring = birthDate.substring(1, birthDate.length());
information.setBirthDate(substring);
}
}
/**
* 参加工作调整
*/
private void wordDateConversion(SchoolTeacherBasicInformation information){
String workingHours = information.getWorkingHours();
if (StringUtils.isEmpty(workingHours)){
return;
} else if (workingHours.contains(">=")) {
String substring = workingHours.substring(2, workingHours.length());
information.setWorkingHoursgtd(substring);
information.setWorkingHours(null);
} else if (workingHours.contains("<=")) {
String substring = workingHours.substring(2, workingHours.length());
information.setWorkingHoursltd(substring);
information.setWorkingHours(null);
} else if (workingHours.contains("<")) {
String substring = workingHours.substring(1, workingHours.length());
information.setWorkingHourslt(substring);
information.setWorkingHours(null);
} else if (workingHours.contains(">")) {
String substring = workingHours.substring(1, workingHours.length());
information.setWorkingHoursgt(substring);
information.setWorkingHours(null);
} else if (workingHours.contains("=")) {
String substring = workingHours.substring(1, workingHours.length());
information.setWorkingHours(substring);
}
}
}
package yangtz.cs.liu.campus.service.teacherFiles;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.web.multipart.MultipartFile;
import yangtz.cs.liu.campus.domain.teacherFiles.SchoolTeacherBasicInformation;
import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;
import java.util.List;
public interface SchoolTeacherBasichlnformationService extends IService<SchoolTeacherBasicInformation> {
List<SchoolTeacherBasicInformation> list(SchoolTeacherBasicInformation information) throws Exception;
SchoolTeacherBasicInformation getById(Long id) throws ParseException;
List<SchoolTeacherBasicInformation> importExcel(MultipartFile inputStream) throws IOException;
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="yangtz.cs.liu.campus.mapper.teacherFiles.SchoolTeacherBasichlnformationMapper">
<sql id="selectSchoolTeacherBasicInformationVo">
select id, name, id_card, sex, file_birth_date, birth_date, hometown, nation, political_landscape, party_membership_time, teaching_subject, current_professional_title, current_professional_title_time, current_hiring_professional_title, current_hiring_professional_title_time, current_position, current_job_level, current_job_level_appointment_time, duties, teacher_qualification_type, teacher_qualification_certificate_num, working_hours, to_second_middle_school_time, length_of_teacher_time, length_of_service_time, on_duty_situation, current_situation, graduation_institution1, major1, graduation_time1, graduation_institution2, major2, graduation_time2, graduation_institution3, major3, graduation_time3, first_degree, last_degree, degree, work_experience, remark, photo_name, photo_url, dd_phone, del_flag from school_teacher_basic_information
</sql>
<select id="list" resultType="yangtz.cs.liu.campus.domain.teacherFiles.SchoolTeacherBasicInformation" parameterType="yangtz.cs.liu.campus.domain.teacherFiles.SchoolTeacherBasicInformation">
SELECT id,name,sex,id_card,file_birth_date,political_landscape,to_second_middle_school_time,current_professional_title,last_degree,on_duty_situation FROM school_teacher_basic_information where del_flag = 0
<if test="teachingSubject != null "> and teaching_subject = #{teachingSubject}</if>
<if test="name != null ">
AND name like concat('%', #{name}, '%')
</if>
<if test="sex != null and sex != ''"> and sex = #{sex}</if>
<if test="birthDategt != null and birthDate != ''"> and birth_date &gt; #{birthDategt}</if>
<if test="birthDategtd != null and birthDate != ''"> and birth_date &gt;= #{birthDategtd}</if>
<if test="birthDatelt != null and birthDate != ''"> and birth_date &lt; #{birthDatelt}</if>
<if test="birthDateltd != null and birthDate != ''"> and birth_date &lt;= #{birthDateltd}</if>
<if test="birthDate != null and birthDate != ''"> and birth_date = #{birthDate}</if>
<if test="politicalLandscape != null "> and political_landscape = #{politicalLandscape}</if>
<if test="workingHoursgt != null "> and working_hours &gt; #{workingHoursgt}</if>
<if test="workingHoursgtd != null "> and working_hours &gt;= #{workingHoursgtd}</if>
<if test="workingHourslt != null "> and working_hours &lt; #{workingHourslt}</if>
<if test="workingHoursltd != null "> and working_hours &lt;= #{workingHoursltd}</if>
<if test="workingHours != null "> and working_hours = #{workingHours}</if>
<if test="currentProfessionalTitle != null ">
and current_professional_title like concat('%', #{currentProfessionalTitle}, '%')
</if>
<if test="onDutySituation != null "> and on_duty_situation = #{onDutySituation}</if>
<if test="graduationInstitution1 != null ">
AND CONCAT(IFNULL(c.graduationInstitution1,''),IFNULL(c.graduationInstitution2,''),IFNULL(c.graduationInstitution3,'')) LIKE concat('%',#{graduationInstitution1},'%')}
</if>
<if test="firstDegree != null ">
AND CONCAT(IFNULL(c.firstDegree,''),IFNULL(c.lastDegree,'')) LIKE concat('%',#{firstDegree},'%')}
</if>
</select>
<select id="selectById" resultType="yangtz.cs.liu.campus.domain.teacherFiles.SchoolTeacherBasicInformation" parameterType="Long">
<include refid="selectSchoolTeacherBasicInformationVo"/>
where id =#{id}
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment