diff --git a/src/main/java/com/dsideal/FengHuang/Yp/Controller/YpController.java b/src/main/java/com/dsideal/FengHuang/Yp/Controller/YpController.java index 5621cef..138f215 100644 --- a/src/main/java/com/dsideal/FengHuang/Yp/Controller/YpController.java +++ b/src/main/java/com/dsideal/FengHuang/Yp/Controller/YpController.java @@ -106,6 +106,20 @@ public class YpController extends Controller { renderJson(kv); } + /** + * 功能:停止任务 + * + * @param task_id + */ + @Before(POST.class) + @IsNumericInterface({"task_id"}) + public void stopTask(int task_id) { + model.stopTask(task_id); + Kv kv = Kv.by("success", true); + kv.set("message", "保存成功!"); + renderJson(kv); + } + /** * 功能:根据身份证号计算班型 * 身份证号生成器:http://www.chineseidcard.com/?region=110101&birthday=20210307&sex=1&num=5&r=28 @@ -275,4 +289,14 @@ public class YpController extends Controller { kv.set("message", "保存成功!"); renderJson(kv); } + + /** + 功能:获取指定任务下的班型选择情况 + */ + @Before(GET.class) + @IsNumericInterface({"task_id"}) + public void getBx(int task_id) { + List list = model.getBx(task_id); + renderJson(CommonUtil.renderJsonForLayUI(list)); + } } \ No newline at end of file diff --git a/src/main/java/com/dsideal/FengHuang/Yp/Model/YpModel.java b/src/main/java/com/dsideal/FengHuang/Yp/Model/YpModel.java index 12f2cb6..8db01bb 100644 --- a/src/main/java/com/dsideal/FengHuang/Yp/Model/YpModel.java +++ b/src/main/java/com/dsideal/FengHuang/Yp/Model/YpModel.java @@ -9,7 +9,9 @@ import com.jfinal.plugin.activerecord.Record; import com.jfinal.plugin.activerecord.SqlPara; import java.util.Calendar; +import java.util.HashSet; import java.util.List; +import java.util.Set; public class YpModel { @@ -90,6 +92,27 @@ public class YpModel { Db.update(sql, task_id); } + /** + * 功能:停止任务 + * + * @param task_id + */ + public void stopTask(int task_id) { + String sql = "update t_yp_task set is_run=0 where task_id=?"; + Db.update(sql, task_id); + } + + /** + * 功能:获取全局所有班型 + * + * @return + */ + public List getAllBx() { + String sql = "select * from t_yp_bx where b_use=1"; + List list = Db.find(sql); + return list; + } + /** * 功能:根据身份证号计算班型 * @@ -104,9 +127,7 @@ public class YpModel { } //解析出出生日期 String birth = IdcardUtil.getBirthByIdCard(sfzh); - - String sql = "select * from t_yp_bx where b_use=1"; - List list = Db.find(sql); + List list = getAllBx(); //当前年份 Calendar calendar = Calendar.getInstance(); @@ -233,4 +254,29 @@ public class YpModel { String sql = "delete from t_yp_task_bx_limit where task_id=? and bx_id=?"; Db.update(sql, task_id, bx_id); } + + /** + * 功能:获取指定任务下的班型选择情况 + * + * @param task_id + * @return + */ + public List getBx(int task_id) { + List all = getAllBx(); + //本次任务的班型 + String sql = "select * from t_yp_task_bx_limit where task_id=?"; + List list = Db.find(sql, task_id); + Set set = new HashSet<>(); + for (Record record : list) { + set.add(record.getInt("bx_id")); + } + for (Record record : all) { + if (set.contains(record.getInt("bx_id"))) { + record.set("selected", true); + } else { + record.set("selected", false); + } + } + return all; + } } \ No newline at end of file