|
|
|
@ -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<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=?";
|
|
|
|
|
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);
|
|
|
|
|
record.set("apply_count", r1.getInt("count"));
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
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;
|
|
|
|
|