From 544703aec10da0c3e9e56f7e9fc0bf2506dcb7cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=B5=B7?= <10402852@qq.com> Date: Fri, 21 Apr 2023 15:42:32 +0800 Subject: [PATCH] 'commit' --- .../FengHuang/Yp/Controller/YpController.java | 56 +++++++++++++++++-- .../dsideal/FengHuang/Yp/Model/YpModel.java | 31 +++++++++- 2 files changed, 81 insertions(+), 6 deletions(-) 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 15c3497..0a00e0a 100644 --- a/src/main/java/com/dsideal/FengHuang/Yp/Controller/YpController.java +++ b/src/main/java/com/dsideal/FengHuang/Yp/Controller/YpController.java @@ -49,14 +49,13 @@ public class YpController extends Controller { renderJson(list); } - /** * 功能:增加任务 */ @Before(POST.class) - @EmptyInterface({"task_name"}) - public void addTask(String task_name) { - model.addTask(task_name); + @EmptyInterface({"task_name", "bx_ids", "limits"}) + public void addTask(String task_name, String bx_ids, String limits) { + model.addTask(task_name, bx_ids, limits); Kv kv = Kv.by("success", true); kv.set("message", "保存成功!"); renderJson(kv); @@ -165,7 +164,7 @@ public class YpController extends Controller { * @param limit */ @Before(GET.class) - @IsNumericInterface({"task_id", "page", "limit"}) + @IsNumericInterface({"task_id","bx_id", "page", "limit"}) public void getTaskInfo(int task_id, int bx_id, int page, int limit) { Page list = model.getTaskInfo(task_id, bx_id, page, limit); renderJson(CommonUtil.renderJsonForLayUI(list)); @@ -224,4 +223,51 @@ public class YpController extends Controller { renderJson(kv); //path : /FengHuang/upload/sfzh+".jpg" } + + /** + * 功能:当前任务增加班型 + * + * @param task_id + * @param bx_id + * @param limit + */ + @Before(POST.class) + @IsNumericInterface({"task_id", "bx_id", "limit"}) + public void addBx(int task_id, int bx_id, int limit) { + model.addBx(task_id, bx_id, limit); + Kv kv = Kv.by("success", true); + kv.set("message", "保存成功!"); + renderJson(kv); + } + + /** + * 功能:当前任务修改班型 + * + * @param task_id + * @param bx_id + * @param limit + */ + @Before(POST.class) + @IsNumericInterface({"task_id", "bx_id", "limit"}) + public void updateBx(int task_id, int bx_id, int limit) { + model.updateBx(task_id, bx_id, limit); + Kv kv = Kv.by("success", true); + kv.set("message", "保存成功!"); + renderJson(kv); + } + + /** + * 功能:当前任务删除班型 + * + * @param task_id + * @param bx_id + */ + @Before(POST.class) + @IsNumericInterface({"task_id", "bx_id"}) + public void delBx(int task_id, int bx_id) { + model.delBx(task_id, bx_id); + Kv kv = Kv.by("success", true); + kv.set("message", "保存成功!"); + renderJson(kv); + } } \ 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 627a0bd..61ca5c8 100644 --- a/src/main/java/com/dsideal/FengHuang/Yp/Model/YpModel.java +++ b/src/main/java/com/dsideal/FengHuang/Yp/Model/YpModel.java @@ -40,13 +40,23 @@ public class YpModel { /** * 功能:增加任务 */ - public void addTask(String task_name) { + public void addTask(String task_name, String bx_id, String limits) { 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); + String[] a = bx_id.split(","); + String[] b = limits.split(","); + int task_id = record.getInt("task_id"); + for (int i = 0; i < a.length; i++) { + Record r1 = new Record(); + r1.set("task_id", task_id); + r1.set("bx_id", a[i]); + r1.set("limit", b[i]); + Db.save("t_yp_task_bx_limit", "task_id,bx_id", r1); + } } /** @@ -197,4 +207,23 @@ public class YpModel { Page pageRecord = Db.paginate(page, limit, sqlPara); return pageRecord; } + + public void addBx(int task_id, int bx_id, int limit) { + delBx(task_id, bx_id); + Record record = new Record(); + record.set("task_id", task_id); + record.set("bx_id", bx_id); + record.set("limit", limit); + Db.save("t_yp_task_bx_limit", "task_id,bx_id", record); + } + + public void updateBx(int task_id, int bx_id, int limit) { + delBx(task_id, bx_id); + addBx(task_id, bx_id, limit); + } + + public void delBx(int task_id, int bx_id) { + String sql = "delete from t_yp_task_bx_limit where task_id=? and bx_id=?"; + Db.update(sql, task_id, bx_id); + } } \ No newline at end of file