修改提出的问题和新需求
This commit is contained in:
@ -44,7 +44,6 @@ public class CjStudentController extends BaseController
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(CjStudent cjStudent)
|
||||
{
|
||||
startPage();
|
||||
Long deptId = SecurityUtils.getLoginUser().getDeptId();
|
||||
if (deptId.intValue() != 100){
|
||||
SysDept dept = sysDeptService.selectDeptById(deptId);
|
||||
@ -60,6 +59,7 @@ public class CjStudentController extends BaseController
|
||||
cjStudent.setLtYear(currentYear);
|
||||
}
|
||||
}
|
||||
startPage();
|
||||
List<CjStudent> list = cjStudentService.selectCjStudentList(cjStudent);
|
||||
return getDataTable(list);
|
||||
}
|
||||
@ -77,6 +77,17 @@ public class CjStudentController extends BaseController
|
||||
util.exportExcel(response, list, "采集学生信息数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出采集学生信息列表
|
||||
*/
|
||||
@Log(title = "采集学生信息", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/importData")
|
||||
public void importSData(MultipartFile file)
|
||||
{
|
||||
cjStudentService.importCjStudent(file);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取采集学生信息详细信息
|
||||
*/
|
||||
|
@ -1,11 +1,14 @@
|
||||
package com.ruoyi.dw.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import org.springframework.data.annotation.Transient;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 采集学生信息对象 cj_student
|
||||
*
|
||||
@ -34,6 +37,9 @@ public class CjStudent
|
||||
@Excel(name = "专业")
|
||||
private String zy;
|
||||
|
||||
@Excel(name = "班级")
|
||||
private String bj;
|
||||
|
||||
/** 学院 */
|
||||
@Excel(name = "学院")
|
||||
private String xy;
|
||||
@ -107,6 +113,10 @@ public class CjStudent
|
||||
@Transient
|
||||
private Integer gtYear;
|
||||
|
||||
/** 更新时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
@ -331,6 +341,22 @@ public class CjStudent
|
||||
this.gtYear = gtYear;
|
||||
}
|
||||
|
||||
public String getBj() {
|
||||
return bj;
|
||||
}
|
||||
|
||||
public void setBj(String bj) {
|
||||
this.bj = bj;
|
||||
}
|
||||
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
|
@ -82,4 +82,6 @@ public interface ICjStudentService
|
||||
* @return
|
||||
*/
|
||||
public int importData(MultipartFile file);
|
||||
|
||||
public int importCjStudent(MultipartFile file);
|
||||
}
|
||||
|
@ -1,8 +1,11 @@
|
||||
package com.ruoyi.dw.service.impl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
@ -190,5 +193,51 @@ public class CjStudentServiceImpl implements ICjStudentService
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
public static int findFirstDigitIndexRegex(String str) {
|
||||
if (str == null || str.isEmpty()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
Pattern pattern = Pattern.compile("\\d"); // 匹配任意数字
|
||||
Matcher matcher = pattern.matcher(str);
|
||||
|
||||
if (matcher.find()) {
|
||||
return matcher.start(); // 返回第一个匹配数字字符的起始位置
|
||||
}
|
||||
|
||||
return -1; // 没有找到数字
|
||||
}
|
||||
|
||||
@Override
|
||||
public int importCjStudent(MultipartFile file) {
|
||||
try {
|
||||
Workbook workbook = WorkbookFactory.create(file.getInputStream());
|
||||
Sheet sheet = workbook.getSheetAt(0);
|
||||
int rows = sheet.getLastRowNum();
|
||||
for (int i = 3; i <= rows; i++) {
|
||||
Row row = sheet.getRow(i);
|
||||
CjStudent cjStudent = new CjStudent();
|
||||
Cell xmCell = row.getCell(1);
|
||||
cjStudent.setXm(xmCell.getStringCellValue());
|
||||
Cell xhCell = row.getCell(2);
|
||||
cjStudent.setXh(xhCell.getStringCellValue());
|
||||
Cell xyCell = row.getCell(3);
|
||||
cjStudent.setXy(xyCell.getStringCellValue());
|
||||
Cell bjCell = row.getCell(4);
|
||||
String bj = bjCell.getStringCellValue();
|
||||
cjStudent.setBj(bj);
|
||||
int a = findFirstDigitIndexRegex(bj);
|
||||
String zy = bj.substring(0,a);
|
||||
String bynfStr = "20" + bj.substring(a,a+2);
|
||||
cjStudent.setZy(zy);
|
||||
cjStudent.setBynf(Integer.valueOf(bynfStr));
|
||||
cjStudentMapper.insertCjStudent(cjStudent);
|
||||
}
|
||||
|
||||
}catch (IOException e) {
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -26,20 +26,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="yx" column="yx" />
|
||||
<result property="qt" column="qt" />
|
||||
<result property="sfqr" column="sfqr" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectCjStudentVo">
|
||||
select id, xm,xh, xb, zy,xy,sydsh, sydshi, bynf, zgyl, gzdw, dwxz, dwdz, zwjb, shjz, dbry, rysfzs,sj, yx, qt, sfqr from cj_student
|
||||
select id, xm,xh,bj, xb, zy,xy,sydsh, sydshi, bynf, zgyl, gzdw, dwxz, dwdz, zwjb, shjz, dbry, rysfzs,sj, yx, qt, sfqr,update_time from cj_student
|
||||
</sql>
|
||||
|
||||
<select id="selectCjStudentList" parameterType="CjStudent" resultMap="CjStudentResult">
|
||||
<include refid="selectCjStudentVo"/>
|
||||
<where>
|
||||
<if test="xm != null and xm != ''"> and xm = #{xm}</if>
|
||||
<if test="xm != null and xm != ''"> and xm like concat('%', #{xm}, '%')</if>
|
||||
<if test="xh != null and xh != ''"> and xh = #{xh}</if>
|
||||
<if test="bj != null and bj != ''"> and bj = #{bj}</if>
|
||||
<if test="xb != null and xb != ''"> and xb = #{xb}</if>
|
||||
<if test="zy != null and zy != ''"> and zy = #{zy}</if>
|
||||
<if test="xy != null and xy != ''"> and xy = #{xy}</if>
|
||||
<if test="zy != null and zy != ''"> and zy like concat('%', #{zy}, '%')</if>
|
||||
<if test="xy != null and xy != ''"> and xy like concat('%', #{xy}, '%')</if>
|
||||
<if test="sydsh != null and sydsh != ''"> and sydsh = #{sydsh}</if>
|
||||
<if test="sydshi != null and sydshi != ''"> and sydshi = #{sydshi}</if>
|
||||
<if test="bynf != null "> and bynf = #{bynf}</if>
|
||||
@ -75,7 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
WHEN rysfzs = 0 THEN '***'
|
||||
WHEN rysfzs = 1 THEN xm
|
||||
ELSE xm -- 可选:处理 rysfzs 不是 0 或 1 的情况
|
||||
END AS xm,xh, xb, zy,xy,sydsh, sydshi, bynf, zgyl, gzdw, dwxz, dwdz, zwjb, shjz, dbry, rysfzs,sj, yx, qt, sfqr from cj_student
|
||||
END AS xm,xh, xb,bj, zy,xy,sydsh, sydshi, bynf, zgyl, gzdw, dwxz, dwdz, zwjb, shjz, dbry, rysfzs,sj, yx, qt, sfqr from cj_student
|
||||
<where>
|
||||
dbry is not null and dbry != '' and dbry != '无'
|
||||
</where>
|
||||
@ -90,6 +92,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
insert into cj_student
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="xm != null">xm,</if>
|
||||
<if test="bj != null">bj,</if>
|
||||
<if test="xh != null">xh,</if>
|
||||
<if test="xb != null">xb,</if>
|
||||
<if test="zy != null">zy,</if>
|
||||
@ -109,9 +112,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="yx != null">yx,</if>
|
||||
<if test="qt != null">qt,</if>
|
||||
<if test="sfqr != null">sfqr,</if>
|
||||
</trim>
|
||||
update_time
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="xm != null">#{xm},</if>
|
||||
<if test="bj != null">#{bj},</if>
|
||||
<if test="xh != null">#{xh},</if>
|
||||
<if test="xb != null">#{xb},</if>
|
||||
<if test="zy != null">#{zy},</if>
|
||||
@ -131,16 +136,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="yx != null">#{yx},</if>
|
||||
<if test="qt != null">#{qt},</if>
|
||||
<if test="sfqr != null">#{sfqr},</if>
|
||||
sysdate()
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<insert id="insertCjStudentBatch" parameterType="list">
|
||||
insert into cj_student
|
||||
(xm,xh, xb, zy,xy,sydsh, sydshi, bynf, zgyl, gzdw, dwxz, dwdz, zwjb, shjz, dbry, rysfzs,sj, yx, qt, sfqr)
|
||||
(xm,bj,xh, xb, zy,xy,sydsh, sydshi, bynf, zgyl, gzdw, dwxz, dwdz, zwjb, shjz, dbry, rysfzs,sj, yx, qt, sfqr,update_time)
|
||||
VALUES
|
||||
<foreach item="item" collection="list" separator=",">
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
#{item.xm},
|
||||
#{item.bj},
|
||||
#{item.xh},
|
||||
#{item.xb},
|
||||
#{item.zy},
|
||||
@ -159,7 +166,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
#{item.sj},
|
||||
#{item.yx},
|
||||
#{item.qt},
|
||||
#{item.sfqr}
|
||||
#{item.sfqr},
|
||||
sysdate()
|
||||
</trim>
|
||||
</foreach>
|
||||
</insert>
|
||||
@ -168,6 +176,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
update cj_student
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="xm != null">xm = #{xm},</if>
|
||||
<if test="bj != null">bj = #{bj},</if>
|
||||
<if test="xb != null">xb = #{xb},</if>
|
||||
<if test="zy != null">zy = #{zy},</if>
|
||||
<if test="sydsh != null">sydsh = #{sydsh},</if>
|
||||
@ -185,6 +194,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="yx != null">yx = #{yx},</if>
|
||||
<if test="qt != null">qt = #{qt},</if>
|
||||
<if test="sfqr != null">sfqr = #{sfqr},</if>
|
||||
update_time = sysdate()
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
@ -118,7 +118,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
END AS city,
|
||||
COUNT(*) AS student_count
|
||||
FROM cj_student
|
||||
where sfqr = 1
|
||||
where sfqr = 1 and sydsh is not null
|
||||
and cast(bynf as unsigned)
|
||||
between YEAR(CURRENT_DATE) - #{year} + 1 and YEAR(CURRENT_DATE)
|
||||
GROUP BY
|
||||
|
@ -40,8 +40,12 @@ public class UserDetailsServiceImpl implements UserDetailsService
|
||||
SysUser user = userService.selectUserByUserName(username);
|
||||
if (StringUtils.isNull(user))
|
||||
{
|
||||
log.info("登录用户:{} 不存在.", username);
|
||||
throw new ServiceException(MessageUtils.message("user.not.exists"));
|
||||
//用手机号在查询一遍
|
||||
user = userService.selectUserByPhone(username);
|
||||
if (StringUtils.isNull(user)){
|
||||
log.info("登录用户:{} 不存在.", username);
|
||||
throw new ServiceException(MessageUtils.message("user.not.exists"));
|
||||
}
|
||||
}
|
||||
else if (UserStatus.DELETED.getCode().equals(user.getDelFlag()))
|
||||
{
|
||||
|
@ -43,6 +43,14 @@ public interface SysUserMapper
|
||||
*/
|
||||
public SysUser selectUserByUserName(String userName);
|
||||
|
||||
|
||||
/**
|
||||
* 根据手机号查询用户
|
||||
* @param phone 手机号
|
||||
* @return
|
||||
*/
|
||||
public SysUser selectUserByPhone(String phone);
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户
|
||||
*
|
||||
|
@ -42,6 +42,13 @@ public interface ISysUserService
|
||||
*/
|
||||
public SysUser selectUserByUserName(String userName);
|
||||
|
||||
/**
|
||||
* 根据手机号查询用户
|
||||
* @param phone 手机号
|
||||
* @return
|
||||
*/
|
||||
public SysUser selectUserByPhone(String phone);
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户
|
||||
*
|
||||
|
@ -116,6 +116,12 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
return userMapper.selectUserByUserName(userName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUser selectUserByPhone(String phone)
|
||||
{
|
||||
return userMapper.selectUserByPhone(phone);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户
|
||||
*
|
||||
|
@ -126,6 +126,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where u.user_name = #{userName} and u.del_flag = '0'
|
||||
</select>
|
||||
|
||||
<select id="selectUserByPhone" parameterType="String" resultMap="SysUserResult">
|
||||
<include refid="selectUserVo"/>
|
||||
where u.phonenumber = #{phone} and u.del_flag = '0' limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
|
||||
<include refid="selectUserVo"/>
|
||||
where u.user_id = #{userId}
|
||||
|
Reference in New Issue
Block a user