From 5f93e5cab44a89ac2a19582da9a8bfe558543afa 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:30:46 +0800 Subject: [PATCH 1/2] 'commit' --- .../FengHuang/Yp/Controller/YpController.java | 15 +-- .../dsideal/FengHuang/Yp/Model/YpModel.java | 48 ++++++---- .../YangPuZhaoShengExcel.json | 96 +++++++++---------- target/classes/Sql/yp.sql | 12 +-- 4 files changed, 86 insertions(+), 85 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 1632707..15c3497 100644 --- a/src/main/java/com/dsideal/FengHuang/Yp/Controller/YpController.java +++ b/src/main/java/com/dsideal/FengHuang/Yp/Controller/YpController.java @@ -49,16 +49,6 @@ public class YpController extends Controller { renderJson(list); } - /* - 功能:获取指定任务已经申报的各班型人员数量 - http://10.10.21.20:9000/FengHuang/yp/getTaskApplyCount?task_id=1 - */ - @Before(GET.class) - @IsNumericInterface({"task_id"}) - public void getTaskApplyCount(int task_id) { - List list = model.getTaskApplyCount(task_id); - renderJson(list); - } /** * 功能:增加任务 @@ -125,8 +115,9 @@ public class YpController extends Controller { */ @Before(GET.class) @EmptyInterface({"sfzh"}) - public void evalBx(String sfzh) { - Kv kv = model.evalBx(sfzh); + @IsNumericInterface({"task_id"}) + public void evalBx(int task_id, String sfzh) { + Kv kv = model.evalBx(task_id, sfzh); kv.set("success", true); renderJson(kv); } 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 6ad560f..627a0bd 100644 --- a/src/main/java/com/dsideal/FengHuang/Yp/Model/YpModel.java +++ b/src/main/java/com/dsideal/FengHuang/Yp/Model/YpModel.java @@ -1,7 +1,6 @@ package com.dsideal.FengHuang.Yp.Model; import cn.hutool.core.date.DateTime; -import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdcardUtil; import com.jfinal.kit.Kv; import com.jfinal.plugin.activerecord.Db; @@ -32,17 +31,10 @@ public class YpModel { return Db.find(sql, task_id); } - public List getTaskApplyCount(int task_id) { - String sql = "select bx_id from t_yp_task_bx_limit as t1 where t1.task_id=?"; - List 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 int getTaskApplyCount(int task_id, int bx_id) { + String 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); + return r1.getInt("count"); } /** @@ -90,7 +82,7 @@ public class YpModel { * * @param sfzh */ - public Kv evalBx(String sfzh) { + public Kv evalBx(int task_id, String sfzh) { Kv kv = Kv.create(); if (!IdcardUtil.isValidCard(sfzh)) { kv.set("bx_id", -1); @@ -119,6 +111,14 @@ public class YpModel { String st = year - start_year_num + start_month_day; String ed = year - end_year_num + end_month_day; if (birth.compareTo(st) >= 0 && birth.compareTo(ed) <= 0) { + //是不是满了呢? + int applyCount = getTaskApplyCount(task_id, bx_id); + int limit_count = limitCount(task_id, bx_id); + if (applyCount >= limit_count) { + kv.set("bx_id", -3); + kv.set("bx_name", "人数已满!"); + return kv; + } kv.set("bx_id", bx_id); kv.set("bx_name", bx_name); return kv; @@ -129,6 +129,18 @@ public class YpModel { return kv; } + public int applyCount(int task_id, int bx_id) { + String sql = "select count(1) as count from t_yp_record where task_id=? and bx_id=?"; + int count = Db.findFirst(sql, task_id, bx_id).getInt("count"); + return count; + } + + public int limitCount(int task_id, int bx_id) { + String sql = "select * from t_yp_task_bx_limit where task_id=? and bx_id=?"; + int limit_count = Db.findFirst(sql, task_id, bx_id).getInt("limit"); + return limit_count; + } + /** * 功能:保存申报结果 * @@ -148,11 +160,9 @@ public class YpModel { int count = Db.findFirst(sql, sfzh).getInt("count"); if (count > 0) return 2; //2、是不是指定班型已招满 - sql = "select count(1) as count from t_yp_record where task_id=? and bx_id=?"; - count = Db.findFirst(sql, task_id, bx_id).getInt("count"); - //可以招多少人? - sql = "select * from t_yp_task_bx_limit where task_id=? and bx_id=?"; - int limit_count = Db.findFirst(sql, task_id, bx_id).getInt("limit"); + count = applyCount(task_id, bx_id); + //限制招多少人? + int limit_count = limitCount(task_id, bx_id); if (count >= limit_count) return 3; //3、保存 @@ -166,7 +176,7 @@ public class YpModel { record.set("mother_name", mother_name); record.set("sfzh", sfzh); record.set("tel", tel); - record.set("create_time",DateTime.now()); + record.set("create_time", DateTime.now()); record.set("pic", "/upload/" + uuid + ".jpg"); Db.save("t_yp_record", "id", record); return 1; diff --git a/target/classes/ExcelExportTemplate/YangPuZhaoShengExcel.json b/target/classes/ExcelExportTemplate/YangPuZhaoShengExcel.json index b0b4960..ba5cce4 100644 --- a/target/classes/ExcelExportTemplate/YangPuZhaoShengExcel.json +++ b/target/classes/ExcelExportTemplate/YangPuZhaoShengExcel.json @@ -1,49 +1,49 @@ -{ - "title": "招生结果", - "sheetName": "结果", - "titleHeight": 30, - "rowHeight": 30, - "showNumber": true, - "colInfo": [ - { - "show_column_name": "姓名", - "list_column_name": "name", - "width": 40 - }, - { - "show_column_name": "性别", - "list_column_name": "xb", - "width": 20 - }, - { - "show_column_name": "家庭住址", - "list_column_name": "address", - "width": 50 - }, - { - "show_column_name": "父亲姓名", - "list_column_name": "address", - "width": 40 - }, - { - "show_column_name": "母亲姓名", - "list_column_name": "address", - "width": 40 - }, - { - "show_column_name": "身份证号", - "list_column_name": "sfzh", - "width": 40 - }, - { - "show_column_name": "联系电话", - "list_column_name": "tel", - "width": 40 - }, - { - "show_column_name": "申报时间", - "list_column_name": "create_time", - "width": 40 - } - ] +{ + "title": "招生结果", + "sheetName": "结果", + "titleHeight": 30, + "rowHeight": 30, + "showNumber": true, + "colInfo": [ + { + "show_column_name": "姓名", + "list_column_name": "name", + "width": 40 + }, + { + "show_column_name": "性别", + "list_column_name": "xb", + "width": 20 + }, + { + "show_column_name": "家庭住址", + "list_column_name": "address", + "width": 50 + }, + { + "show_column_name": "父亲姓名", + "list_column_name": "address", + "width": 40 + }, + { + "show_column_name": "母亲姓名", + "list_column_name": "address", + "width": 40 + }, + { + "show_column_name": "身份证号", + "list_column_name": "sfzh", + "width": 40 + }, + { + "show_column_name": "联系电话", + "list_column_name": "tel", + "width": 40 + }, + { + "show_column_name": "申报时间", + "list_column_name": "create_time", + "width": 40 + } + ] } \ No newline at end of file diff --git a/target/classes/Sql/yp.sql b/target/classes/Sql/yp.sql index 9fa9bfc..d310146 100644 --- a/target/classes/Sql/yp.sql +++ b/target/classes/Sql/yp.sql @@ -1,7 +1,7 @@ --- 应用接入命名空间 -#namespace("yp") - #sql("getTaskInfo") - select * from t_yp_record where task_id=#para(task_id) and bx_id=#para(bx_id) - #end - +-- 应用接入命名空间 +#namespace("yp") + #sql("getTaskInfo") + select * from t_yp_record where task_id=#para(task_id) and bx_id=#para(bx_id) + #end + #end \ No newline at end of file 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 2/2] '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