kgdxpr 1 year ago
commit cc3c908dd5

@ -1,6 +1,10 @@
package com.dsideal.QingLong.Zbdc.Controller;
import cn.hutool.core.date.DateTime;
import com.dsideal.QingLong.Interceptor.EmptyInterface;
import com.dsideal.QingLong.Interceptor.IsLoginInterface;
import com.dsideal.QingLong.Interceptor.IsNumericInterface;
import com.dsideal.QingLong.Util.CommonUtil;
import com.dsideal.QingLong.Util.SessionKit;
import com.dsideal.QingLong.Zbdc.Model.ZbdcModel;
import com.jfinal.aop.Before;
@ -8,8 +12,11 @@ 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.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import java.util.List;
public class ZbdcController extends Controller {
private final ZbdcModel zm = new ZbdcModel();
@ -20,6 +27,7 @@ public class ZbdcController extends Controller {
* @param year http://127.0.0.1:9000/QingLong/zbdc/getSchoolBase
*/
@Before({GET.class})
@IsLoginInterface({})
public void getSchoolBase(int year) {
if (year == 0) year = DateTime.now().year();//如果没有传入获取的年份,那么就是系统的默认当前年份
String bureau_id = SessionKit.get(getRequest(), getResponse(), "bureau_id");
@ -41,6 +49,7 @@ public class ZbdcController extends Controller {
* @param gz_class_count
*/
@Before({POST.class})
@IsLoginInterface({})
public void saveSchool(int year, int xx_student_count, int cz_student_count, int gz_student_count,
int xx_teacher_count, int cz_teacher_count, int gz_teacher_count,
int xx_class_count, int cz_class_count, int gz_class_count) {
@ -68,6 +77,7 @@ public class ZbdcController extends Controller {
* @param year
*/
@Before({GET.class})
@IsLoginInterface({})
public void getSchoolCgzb(int year) {
if (year == 0) year = DateTime.now().year();//如果没有传入获取的年份,那么就是系统的默认当前年份
String bureau_id = SessionKit.get(getRequest(), getResponse(), "bureau_id");
@ -149,6 +159,7 @@ public class ZbdcController extends Controller {
* @param xxkx_yqypjs -()
*/
@Before({POST.class})
@IsLoginInterface({})
public void saveCgzb(int year,
int wl_cgss, float wl_cgmj, int wl_tjss, float wl_tjmj, int wl_yqsss, float wl_yqsmj, int wl_yqyppz,
int wl_yqypjs, int hx_cgss, float hx_cgmj, int hx_tjss, float hx_tjmj, int hx_yqsss, float hx_yqsmj,
@ -186,6 +197,7 @@ public class ZbdcController extends Controller {
* ID
*/
@Before({GET.class})
@IsLoginInterface({})
public void getSchoolTypeId() {
Record record = zm.getBureauBean(SessionKit.get(getRequest(), getResponse(), "bureau_id"));
int school_type_id = record.getInt("school_type_id");
@ -195,4 +207,55 @@ public class ZbdcController extends Controller {
kv.set("school_type_id", school_type_id);
renderJson(kv);
}
/**
*
*/
@Before({GET.class})
@IsLoginInterface({})
public void getKm() {
Record record = zm.getBureauBean(SessionKit.get(getRequest(), getResponse(), "bureau_id"));
int school_type_id = record.getInt("school_type_id");
//有哪些学段
List<Integer> listStage = zm.getStageListBySchoolTypeId(school_type_id);
//有哪些需要填报的科目
List<Record> list = zm.getZbdcKm(listStage);
renderJson(CommonUtil.renderJsonForLayUI(list));
}
/**
*
*
* @param km_code
* @param level_filter ,,
* @param year
* @param page
* @param limit
*/
@Before({GET.class})
@IsLoginInterface({})
@EmptyInterface({"km_code"})
public void getFill(String km_code, String level_filter, int year, int page, int limit) {
if (year == 0) year = DateTime.now().year();//如果没有传入获取的年份,那么就是系统的默认当前年份
String bureau_id = SessionKit.get(getRequest(), getResponse(), "bureau_id");
Page<Record> list = zm.getFill(bureau_id, year, km_code, level_filter, page, limit);
renderJson(CommonUtil.renderJsonForLayUI(list));
}
/**
*
*/
@Before({POST.class})
@IsLoginInterface({})
@IsNumericInterface({"templet_id"})
public void saveFill(int year, int templet_id, Float xysl) {
if (year == 0) year = DateTime.now().year();//如果没有传入获取的年份,那么就是系统的默认当前年份
String bureau_id = SessionKit.get(getRequest(), getResponse(), "bureau_id");
zm.saveFill(year, bureau_id, templet_id, xysl);
Kv kv = Kv.create();
kv.set("success", true);
kv.set("message", "保存成功!");
renderJson(kv);
}
}

@ -1,11 +1,32 @@
package com.dsideal.QingLong.Zbdc.Model;
import cn.hutool.core.date.DateTime;
import com.dsideal.QingLong.Interceptor.IsLoginInterface;
import com.jfinal.aop.Before;
import com.jfinal.ext.interceptor.POST;
import com.jfinal.kit.Kv;
import com.jfinal.kit.StrKit;
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.HashMap;
import java.util.List;
import java.util.Map;
public class ZbdcModel {
/**
* ID
*
* @param school_type_id
* @return
*/
public List<Integer> getStageListBySchoolTypeId(int school_type_id) {
String sql = "select stage_id from t_dm_schooltype_stage where school_type_id=?";
return Db.query(sql, school_type_id);
}
/**
*
*
@ -266,4 +287,78 @@ public class ZbdcModel {
Db.update("t_zbdc_bureau_cgzb", "year,bureau_id", r);
}
}
/**
* ID
*
* @param listStage
*/
public List<Record> getZbdcKm(List<Integer> listStage) {
String str = "";
for (Integer i : listStage) {
str += i + ",";
}
if (str.length() > 0) str = str.substring(0, str.length() - 1);
String sql = "select km_code,km_name from t_zbdc_km where stage_id in (" + str + ")";
return Db.find(sql);
}
/**
*
*/
public Page<Record> getFill(String bureau_id, int year, String km_code, String level_filter, int page, int limit) {
String c = "";
if (!StrKit.isBlank(level_filter)) {
String[] s = level_filter.split(",");
for (int i = 1; i <= s.length; i++) {
c += "level_" + i + "=" + s[i] + " and ";
}
}
if (!StrKit.isBlank(c)) {
c = c.substring(0, c.length() - 4);
}
String sql = "select * from t_zbdc_templet where km_code=?";
if (!StrKit.isBlank(c)) sql += c;
sql += " order by templet_id";
Page<Record> list = Db.paginate(page, limit, sql, km_code);
//获取此单位已填报的内容
sql = "select templet_id,bureau_id,bureau_name,xysl,update_ts from t_zbdc_fill where year=? and bureau_id=?";
List<Record> fillList = Db.find(sql, year, bureau_id);
Map<Integer, Float> _map = new HashMap<>();
for (Record record : fillList) {
_map.put(record.getInt("templet_id"), record.getFloat("xysl"));
}
//填充已填报的内容
for (Record record : list.getList()) {
if (_map.containsKey(record.getInt("templet_id"))) {
record.set("xysl", _map.get(record.getInt("templet_id")));
} else {
record.set("xysl", 0);
}
}
return list;
}
/**
*
*/
public void saveFill(int year, String bureau_id, int templet_id, Float xysl) {
String sql = "select * from t_zbdc_fill where year=? and template_id=? and bureau_id=?";
Record record = Db.findFirst(sql, year, templet_id, bureau_id);
if (record == null) {
record = new Record();
record.set("year", year);
record.set("templet_id", templet_id);
record.set("bureau_id", bureau_id);
record.set("xysl", xysl);
record.set("update_ts", DateTime.now());
Db.save("t_zbdc_fill", "year,templet_id,bureau_id", record);
} else {
record.set("xysl", xysl);
record.set("update_ts", DateTime.now());
Db.update("t_zbdc_fill", "year,templet_id,bureau_id", record);
}
}
}

Loading…
Cancel
Save