You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
2.7 KiB
89 lines
2.7 KiB
package com.dsideal.FengHuang.Yp.Model;
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
import com.dsideal.FengHuang.Interceptor.EmptyInterface;
|
|
import com.dsideal.FengHuang.Interceptor.IsNumericInterface;
|
|
import com.dsideal.FengHuang.LoginPerson.Model.LoginPersonModel;
|
|
import com.dsideal.FengHuang.Util.CommonUtil;
|
|
import com.dsideal.FengHuang.Util.IpUtil;
|
|
import com.jfinal.aop.Before;
|
|
import com.jfinal.ext.interceptor.POST;
|
|
import com.jfinal.plugin.activerecord.Db;
|
|
import com.jfinal.plugin.activerecord.Page;
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
import com.jfinal.plugin.activerecord.SqlPara;
|
|
|
|
import java.util.List;
|
|
|
|
public class YpModel {
|
|
|
|
/**
|
|
* 功能:获取当前任务名称
|
|
*
|
|
* @return
|
|
*/
|
|
public Record getCurrentTaskInfo() {
|
|
String sql = "select task_id,task_name,is_run from t_yp_task where b_use=1";
|
|
return Db.findFirst(sql);
|
|
}
|
|
|
|
/**
|
|
* 功能:获取指定任务的开启班型及人数限制
|
|
*/
|
|
public List<Record> getTaskLimit(int task_id) {
|
|
String sql = "select * from t_yp_task_bx_limit where task_id=?";
|
|
return Db.find(sql, task_id);
|
|
}
|
|
|
|
public List<Record> getTaskApplyCount(int task_id) {
|
|
String sql = "select bx_id from t_yp_task_bx_limit as t1 where t1.task_id=?";
|
|
List<Record> list = Db.find(sql, task_id);
|
|
|
|
for (Record record : list) {
|
|
int bx_id = record.getInt("bx_id");
|
|
sql = "select count(*) as count from t_yp_record as t2 where t2.task_id=? and t2.bx_id=?";
|
|
Record r1 = Db.findFirst(sql, task_id, bx_id);
|
|
record.set("apply_count", r1.getInt("count"));
|
|
}
|
|
return list;
|
|
}
|
|
|
|
/**
|
|
* 功能:增加任务
|
|
*/
|
|
public void addTask(String task_name) {
|
|
Record record = new Record();
|
|
record.set("task_name", task_name);
|
|
record.set("create_time", DateTime.now());
|
|
record.set("b_use", 0);
|
|
record.set("is_run", 0);
|
|
Db.save("t_yp_task", "task_id", record);
|
|
}
|
|
|
|
/**
|
|
* 功能:修改任务
|
|
*/
|
|
public void updateTask(int task_id, String task_name) {
|
|
String sql = "update t_yp_task set task_name=? where task_id=?";
|
|
Db.update(sql, task_name, task_id);
|
|
}
|
|
|
|
/**
|
|
* 功能:删除任务
|
|
*
|
|
* @param task_id
|
|
*/
|
|
public void delTask(int task_id) {
|
|
String sql = "update t_yp_task set b_use=0 where task_id=?";
|
|
Db.update(sql, task_id);
|
|
}
|
|
/**
|
|
* 功能:启动任务
|
|
*
|
|
* @param task_id
|
|
*/
|
|
public void startTask(int task_id){
|
|
String sql = "update t_yp_task set b_use=1,is_run=1 where task_id=?";
|
|
Db.update(sql, task_id);
|
|
}
|
|
} |