定时任务-停用当前日期大于幼儿园开通截止日期的园所

This commit is contained in:
zhanglipeng 2021-03-08 16:36:33 +08:00
parent 9239ee606c
commit 3279fd5f64
10 changed files with 182 additions and 10 deletions

View File

@ -1,28 +1,93 @@
package com.ruoyi.framework.task; package com.ruoyi.framework.task;
import com.ruoyi.project.common.SchoolCommon;
import com.ruoyi.project.system.domain.BySchool;
import com.ruoyi.project.system.domain.SysDept;
import com.ruoyi.project.system.domain.SysUser;
import com.ruoyi.project.system.service.IBySchoolService;
import com.ruoyi.project.system.service.ISysDeptService;
import com.ruoyi.project.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import java.util.Date;
import java.util.List;
/** /**
* 定时任务调度测试 * 定时任务调度测试
* *
* @author ruoyi * @author ruoyi
*/ */
@Component("ryTask") @Component("ryTask")
public class RyTask public class RyTask {
{
public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) @Autowired
{ private IBySchoolService bySchoolService;
@Autowired
private SchoolCommon schoolCommon;
@Autowired
private ISysDeptService deptService;
@Autowired
private ISysUserService userService;
public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) {
System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i)); System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i));
} }
public void ryParams(String params) public void ryParams(String params) {
{ //jzsj 截止时间 过后禁止登录
if (params.equals("jzsj")) {
BySchool bySchool = new BySchool();
BySchool bySchoolModel = null;
bySchool.setStatus("0");
bySchool.setIsDel("0");
List<BySchool> list = bySchoolService.selectBySchoolList(bySchool);
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
bySchoolModel = list.get(i);
//如果当前时间大于截止时间那么停用账号
Date dt = new Date();
//compareTo()方法的返回值dt1小于dt2返回-1dt1大于dt2返回1相等返回0
int compareTo = dt.compareTo(bySchoolModel.getOpenDeadline());
if (compareTo > 0) {
//停用部门
//System.out.println("xxdm:"+bySchoolModel.getXxdm());
SysDept sysDept = schoolCommon.getDept(bySchoolModel.getXxdm());
sysDept.setStatus("1");
deptService.updateDept(sysDept);
//停用用户
SysUser sysUser = new SysUser();
sysUser.setDeptId(sysDept.getDeptId());
sysUser.setStatus("0");
sysUser.setDelFlag("0");
List<SysUser> listUser = userService.selectUserListAll(sysUser);
if (listUser != null && listUser.size() > 0) {
updateUserState(listUser);
}
//停用当前学校
bySchoolModel.setStatus("1");
bySchoolService.updateBySchool(bySchoolModel);
}
}
}
}
System.out.println("执行有参方法:" + params); System.out.println("执行有参方法:" + params);
} }
public void ryNoParams() //停用用户
{ public void updateUserState(List<SysUser> list) {
SysUser sysUser = null;
for (int j = 0; j < list.size(); j++) {
sysUser = list.get(j);
sysUser.setStatus("1");
userService.updateUser(sysUser);
}
}
public void ryNoParams() {
System.out.println("执行无参方法"); System.out.println("执行无参方法");
} }
} }

View File

@ -67,6 +67,17 @@ public class SchoolCommon {
return sysDept; return sysDept;
} }
public SysDept getDept(String schoolId) {
SysDept sysDept = new SysDept();
sysDept.setSchoolId(schoolId);
List<SysDept> list = deptService.selectDeptListAll(sysDept);
if (list != null && list.size() > 0) {
sysDept = list.get(0);
}
return sysDept;
}
//获取用户信息 //获取用户信息
public SysUser getUser() { public SysUser getUser() {
LoginUser loginUser = SecurityUtils.getLoginUser(); LoginUser loginUser = SecurityUtils.getLoginUser();
@ -97,7 +108,6 @@ public class SchoolCommon {
} }
/** /**
* 判断当前用户是否拥有班级 * 判断当前用户是否拥有班级
**/ **/

View File

@ -19,6 +19,14 @@ public interface SysDeptMapper
*/ */
public List<SysDept> selectDeptList(SysDept dept); public List<SysDept> selectDeptList(SysDept dept);
/**
* 查询部门管理数据
*
* @param dept 部门信息
* @return 部门信息集合
*/
public List<SysDept> selectDeptListAll(SysDept dept);
/** /**
* 根据角色ID查询部门树信息 * 根据角色ID查询部门树信息
* *

View File

@ -29,6 +29,14 @@ public interface SysUserMapper
*/ */
public List<SysUser> selectUserList(SysUser sysUser); public List<SysUser> selectUserList(SysUser sysUser);
/**
* 根据条件分页查询用户列表
*
* @param sysUser 用户信息
* @return 用户信息集合信息
*/
public List<SysUser> selectUserListAll(SysUser sysUser);
/** /**
* 通过用户名查询用户 * 通过用户名查询用户
* *

View File

@ -19,6 +19,14 @@ public interface ISysDeptService
*/ */
public List<SysDept> selectDeptList(SysDept dept); public List<SysDept> selectDeptList(SysDept dept);
/**
* 查询部门管理数据
*
* @param dept 部门信息
* @return 部门信息集合
*/
public List<SysDept> selectDeptListAll(SysDept dept);
/** /**
* 根据用户ID获取岗位选择框列表 * 根据用户ID获取岗位选择框列表
* *

View File

@ -27,6 +27,14 @@ public interface ISysUserService
*/ */
public List<SysUser> selectUserList(SysUser user); public List<SysUser> selectUserList(SysUser user);
/**
* 根据条件分页查询用户列表
*
* @param user 用户信息
* @return 用户信息集合信息
*/
public List<SysUser> selectUserListAll(SysUser user);
/** /**
* 通过用户名查询用户 * 通过用户名查询用户
* *

View File

@ -39,6 +39,18 @@ public class SysDeptServiceImpl implements ISysDeptService
return deptMapper.selectDeptList(dept); return deptMapper.selectDeptList(dept);
} }
/**
* 查询部门管理数据
*
* @param dept 部门信息
* @return 部门信息集合
*/
@Override
public List<SysDept> selectDeptListAll(SysDept dept)
{
return deptMapper.selectDeptListAll(dept);
}
/** /**
* 根据用户ID获取岗位选择框列表 * 根据用户ID获取岗位选择框列表
* *

View File

@ -70,6 +70,17 @@ public class SysUserServiceImpl implements ISysUserService {
return userMapper.selectUserList(user); return userMapper.selectUserList(user);
} }
/**
* 根据条件分页查询用户列表
*
* @param user 用户信息
* @return 用户信息集合信息
*/
@Override
public List<SysUser> selectUserListAll(SysUser user) {
return userMapper.selectUserListAll(user);
}
/** /**
* 通过用户名查询用户 * 通过用户名查询用户
* *

View File

@ -65,6 +65,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
${dataScope} ${dataScope}
order by d.parent_id, d.order_num order by d.parent_id, d.order_num
</select> </select>
<select id="selectDeptListAll" parameterType="SysDept" resultMap="SysDeptResult">
<include refid="selectDeptVo"/>
where d.del_flag = '0'
<if test="parentId != null and parentId != 0">
AND parent_id = #{parentId}
</if>
<if test="deptName != null and deptName != ''">
AND dept_name like concat('%', #{deptName}, '%')
</if>
<if test="status != null and status != ''">
AND status = #{status}
</if>
<if test="schoolId != null and schoolId != ''">
AND school_id = #{schoolId}
</if>
order by d.parent_id, d.order_num
</select>
<select id="selectDeptListByRoleId" parameterType="Long" resultType="Integer"> <select id="selectDeptListByRoleId" parameterType="Long" resultType="Integer">
select d.dept_id, d.parent_id select d.dept_id, d.parent_id

View File

@ -86,6 +86,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- 数据范围过滤 --> <!-- 数据范围过滤 -->
${dataScope} ${dataScope}
</select> </select>
<select id="selectUserListAll" parameterType="SysUser" resultMap="SysUserResult">
select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
where u.del_flag = '0'
<if test="userName != null and userName != ''">
AND u.user_name like concat('%', #{userName}, '%')
</if>
<if test="status != null and status != ''">
AND u.status = #{status}
</if>
<if test="phonenumber != null and phonenumber != ''">
AND u.phonenumber like concat('%', #{phonenumber}, '%')
</if>
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
</if>
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
</if>
<if test="deptId != null and deptId != 0">
AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE FIND_IN_SET (#{deptId},ancestors) ))
</if>
</select>
<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult"> <select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
<include refid="selectUserVo"/> <include refid="selectUserVo"/>