main
黄海 2 years ago
parent 8b8d600b04
commit 6bc6623c05

@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSONObject;
import com.dsideal.FengHuang.Interceptor.*;
import com.dsideal.FengHuang.LoginPerson.Model.LoginPersonModel;
import com.dsideal.FengHuang.Util.CommonUtil;
import com.dsideal.FengHuang.Util.ExcelExportUtil;
import com.dsideal.FengHuang.Util.FileUtil;
import com.dsideal.FengHuang.Util.IpUtil;
import com.dsideal.FengHuang.Yp.Model.YpModel;
import com.jfinal.aop.Before;
@ -11,10 +13,14 @@ import com.jfinal.core.Controller;
import com.jfinal.ext.interceptor.GET;
import com.jfinal.ext.interceptor.POST;
import com.jfinal.kit.Kv;
import com.jfinal.kit.PathKit;
import com.jfinal.kit.PropKit;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import java.io.File;
import java.util.List;
import java.util.UUID;
public class YpController extends Controller {
YpModel model = new YpModel();
@ -125,4 +131,67 @@ public class YpController extends Controller {
kv.set("bx_id", bx_id);
renderJson(kv);
}
/**
*
*
* @param task_id
* @param name
* @param xb
* @param bx_id
* @param address
* @param father_name
* @param mother_name
* @param sfzh
* @param tel
*/
@Before(POST.class)
@EmptyInterface({"sfzh"})
public void save(int task_id, String name, String xb, int bx_id, String address, String father_name, String mother_name, String sfzh, String tel) {
int result = model.save(task_id, name, xb, bx_id, address, father_name, mother_name, sfzh, tel);
Kv kv = Kv.by("success", result);
if (result == 1) kv.set("message", "获取成功!");
if (result == 2) kv.set("message", "此身份证号已申请过,不能重复申请!");
if (result == 3) kv.set("message", "指定班型人数已达上限,不能申请!");
renderJson(kv);
}
/**
*
*
* @param task_id
* @param bx_id
* @param page
* @param limit
*/
@Before(GET.class)
@IsNumericInterface({"task_id", "page", "limit"})
public void getTaskInfo(int task_id, int bx_id, int page, int limit) {
Page<Record> list = model.getTaskInfo(task_id, bx_id, page, limit);
renderJson(CommonUtil.renderJsonForLayUI(list));
}
/**
* excel
*
* @param task_id
* @param bx_id
*/
@Before(GET.class)
@IsNumericInterface({"task_id", "page", "limit"})
public void exportExcel(int task_id, int bx_id) {
//模板文件
String excelPath = PathKit.getRootClassPath() + PropKit.get("excelExportTemplatePathSuffix").replace("\\", "/");
String filePath = excelPath + "YangPuZhaoShengExcel.json";
//转成 json对象
JSONObject jo = FileUtil.readJsonFile(filePath);
//导出
Page<Record> rs = model.getTaskInfo(task_id, bx_id, 1, 99999);
String excelFile = excelPath + "excelTemp/" + UUID.randomUUID().toString().toUpperCase() + ".xls";
ExcelExportUtil.export(rs, jo, excelFile);
//提供下载
String filename = "招生.xls";
renderFile(new File(excelFile), filename);
}
}

@ -3,8 +3,11 @@ 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;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import com.jfinal.plugin.activerecord.SqlPara;
import java.util.Calendar;
import java.util.List;
@ -115,4 +118,59 @@ public class YpModel {
}
return result;//如果result=-2表示不在指定的时间段内
}
/**
*
*
* @param task_id
* @param name
* @param xb
* @param bx_id
* @param address
* @param father_name
* @param mother_name
* @param sfzh
* @param tel
*/
public int save(int task_id, String name, String xb, int bx_id, String address, String father_name, String mother_name, String sfzh, String tel) {
//1、检查身份证号是不是已存在
String sql = "select count(1) as count from t_yp_record where sfzh=?";
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");
if (count >= limit_count) return 3;
//3、保存
Record record = new Record();
record.set("task_id", task_id);
record.set("name", name);
record.set("xb", xb);
record.set("bx_id", bx_id);
record.set("address", address);
record.set("father_name", father_name);
record.set("mother_name", mother_name);
record.set("sfzh", sfzh);
record.set("tel", tel);
Db.save("t_yp_record", "id", record);
return 1;
}
/**
*
* @param task_id
* @param bx_id
* @param page
* @param limit
*/
public Page<Record> getTaskInfo(int task_id,int bx_id, int page, int limit){
Kv kv = Kv.by("task_id", task_id);
kv.set("bx_id",bx_id);
SqlPara sqlPara = Db.getSqlPara("yp.getTaskInfo", kv);
Page<Record> pageRecord = Db.paginate(page, limit, sqlPara);
return pageRecord;
}
}

@ -0,0 +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
}
]
}

@ -0,0 +1,7 @@
-- 应用接入命名空间
#namespace("yp")
#sql("getTaskInfo")
select * from t_yp_record where task_id=#para(task_id) and bx_id=#para(bx_id)
#end
#end

@ -0,0 +1,7 @@
-- 应用接入命名空间
#namespace("yp")
#sql("getTaskInfo")
select * from t_yp_record where task_id=#para(task_id) and bx_id=#para(bx_id)
#end
#end
Loading…
Cancel
Save