@ -6,18 +6,13 @@ import java.math.RoundingMode;
import cn.hutool.core.date.DateTime ;
import cn.hutool.core.date.DateUtil ;
import com.alibaba.fastjson.JSONObject ;
import com.dsideal.QingLong.Interceptor.IsLoginInterface ;
import com.dsideal.QingLong.Util.SessionKit ;
import com.jfinal.aop.Before ;
import com.jfinal.ext.interceptor.GET ;
import com.jfinal.ext.interceptor.POST ;
import com.jfinal.kit.Kv ;
import com.jfinal.kit.PropKit ;
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 kotlin.text._OneToManyTitlecaseMappingsKt ;
import java.util.* ;
import java.text.SimpleDateFormat ;
@ -858,6 +853,84 @@ public class ZbdcModel {
record . set ( "update_ts" , DateTime . now ( ) ) ;
Db . update ( "t_zbdc_fill" , "year,templet_id,bureau_id" , record ) ;
}
//回写数据表 t_zbdc_bureau_cgzb
// 问题:因为常规装备数据填写可能是在仪器设备填报之前进行,也可能是在之后进行,所以 t_zbdc_bureau_cgzb 中可能已经存在 year+bureau_id的记录, 也可能不存在
sql = "select count(1) as c from t_zbdc_bureau_cgzb where bureau_id=? and year=?" ;
int count = Db . findFirst ( sql , bureau_id , year ) . getInt ( "c" ) ;
//如果不存在,则需要插入一条空的记录
if ( count = = 0 ) {
//获取学校的学校名称等信息
Record rBureau = getBureauBean ( bureau_id ) ;
String bureau_name = rBureau . getStr ( "org_name" ) ;
String school_type_name = rBureau . getStr ( "school_type_name" ) ;
saveCgzb ( year , 0 , bureau_id , bureau_name , school_type_name , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 ) ;
}
sql = "select km_code,km_name, from t_zbdc_templet where templet_id=?" ;
Record r = Db . findFirst ( sql , templet_id ) ;
String km_code = r . getStr ( "km_code" ) ;
//仪器已配品种(个) 只统计必备
//仪器已配件数(件)
boolean flag = false ;
//小学科学(xxkx) 小学音乐(xxyl) 小学美术(xxms) 小学体育(xxty)
if ( km_code . equals ( "xxkx" ) | | km_code . equals ( "xxyl" ) | | km_code . equals ( "xxms" ) | | km_code . equals ( "xxty" ) ) {
flag = true ;
}
//初中音乐(czyl) 初中美术(czms) 初中体育(czty)
if ( km_code . equals ( "czyl" ) | | km_code . equals ( "czms" ) | | km_code . equals ( "czty" ) ) {
flag = true ;
}
//高中音乐(gzyl) 高中美术(gzms) 高中体育(gzty)
if ( km_code . equals ( "gzyl" ) | | km_code . equals ( "gzms" ) | | km_code . equals ( "gzty" ) ) {
flag = true ;
}
// 初中物理(czwl), 初中化学(czhx) 初中生物(czsw)
if ( km_code . equals ( "czwl" ) | | km_code . equals ( "czhx" ) | | km_code . equals ( "czsw" ) ) {
flag = true ;
}
//高中物理(gzwl) 高中化学(gzhx) 高中生物(gzsw)
if ( km_code . equals ( "gzwl" ) | | km_code . equals ( "gzhx" ) | | km_code . equals ( "gzsw" ) ) {
flag = true ;
}
if ( flag ) {
//已配品种数
String yppz = km_code . substring ( 0 , 2 ) + "_" + km_code . substring ( 2 , 4 ) + "yppz" ;
//已配件数
String ypjs = km_code . substring ( 0 , 2 ) + "_" + km_code . substring ( 2 , 4 ) + "ypjs" ;
//更新此bureau_id,此year, 统计此科目的仪器已配品种(个) 只统计必备
sql = "select count(1) as c,sum(t1.xysl) as s from t_zbdc_fill as t1 inner join t_zbdc_templet as t2 on t1.templet_id=t2.templet_id where " +
" t1.bureau_id=? and t1.year=? and t1.xysl>0 and t2.bp='√' and t2.km_code=?" ;
Record r1 = Db . findFirst ( sql , bureau_id , year , km_code ) ;
int c = r1 . getInt ( "c" ) ;
float s = r1 . getFloat ( "s" ) ;
//更新字段
sql = "update t_zbdc_bureau_cgzb set " + yppz + "=?," + ypjs + "=? where year=? and bureau_id=?" ;
Db . update ( sql , c , s , year , bureau_id ) ;
}
}
/ * *
@ -1185,7 +1258,7 @@ public class ZbdcModel {
* 功 能 : 获 取 查 询 功 能 中 的 行 政 区 划
* /
public List < Record > getQueryXzqh ( ) {
String sql = "select t1.id,t1.area_name,(select count(1) from t_base_organization as t2 where t2.org_id=t2.bureau_id and t2.area_id=t1.area_id and t2.org_type_id=16) as count ,(select count(1) from t_zbdc_report as t3 where t3.year=2024 and t3.area_id=t1.area_id and t3.report_level=2) as pass from t_dm_area as t1 where t1.city_id='064BB3C9-E8DB-45ED-B0C1-6ABC5EA3B667' and t1.city_id<>t1.id order by t1.sort_id";
String sql = "select t1.id,t1.area_name,(select count(1) from t_base_organization as t2 where t2.org_id=t2.bureau_id and t2.area_id=t1.area_id and t2.org_type_id=16) as count from t_dm_area as t1 where t1.city_id='064BB3C9-E8DB-45ED-B0C1-6ABC5EA3B667' and t1.city_id<>t1.id order by t1.sort_id";
List < Record > list = Db . find ( sql ) ;
Record record = new Record ( ) ;
record . set ( "id" , 0 ) ;
@ -1193,7 +1266,6 @@ public class ZbdcModel {
sql = "select count(1) as count from t_base_organization where city_id='064BB3C9-E8DB-45ED-B0C1-6ABC5EA3B667' and org_type_id=9 and org_id=bureau_id" ;
int count = Db . findFirst ( sql ) . getInt ( "count" ) ;
record . set ( "count" , count ) ;
record . set ( "pass" , 1 ) ;
list . add ( 0 , record ) ;
return list ;
}
@ -1670,52 +1742,54 @@ public class ZbdcModel {
* @return
* /
public List < Record > getSummaryCgzb ( int year ) {
Kv kv = Kv . by ( "year" , year ) ;
SqlPara sqlPara = Db . getSqlPara ( "Zbdc.getSummaryCgzb" , kv ) ;
List < Record > list = Db . find ( sqlPara ) ;
list = expandList ( list ) ;
//共七个配备率,需要重新计算
Map < String , Kv > wlPbl = calcPbl ( year , new String [ ] { "初中物理" , "高中物理" } ) ; //key:市直,二道区,南关区 Kv:count,radio
Map < String , Kv > hxPbl = calcPbl ( year , new String [ ] { "初中化学" , "高中化学" } ) ;
Map < String , Kv > swPbl = calcPbl ( year , new String [ ] { "初中生物" , "高中生物" } ) ;
Map < String , Kv > kxPbl = calcPbl ( year , new String [ ] { "小学科学" } ) ;
Map < String , Kv > yyPbl = calcPbl ( year , new String [ ] { "小学音乐" , "初中音乐" } ) ;
Map < String , Kv > tyPbl = calcPbl ( year , new String [ ] { "小学体育" , "初中体育" , "高中体育" } ) ;
Map < String , Kv > msPbl = calcPbl ( year , new String [ ] { "小学美术" , "初中美术" , "高中美术" } ) ;
//修改一下list
for ( Record record : list ) {
String area_name = record . getStr ( "area_name" ) ;
if ( wlPbl . containsKey ( area_name ) ) { //物理配备率
float value = wlPbl . get ( area_name ) . getFloat ( "radio" ) / wlPbl . get ( area_name ) . getInt ( "count" ) ;
record . set ( "wl_pbl" , String . format ( "%.2f%%" , value * 100 ) ) ;
}
if ( hxPbl . containsKey ( area_name ) ) { //化学配备率
float value = hxPbl . get ( area_name ) . getFloat ( "radio" ) / hxPbl . get ( area_name ) . getInt ( "count" ) ;
record . set ( "hx_pbl" , String . format ( "%.2f%%" , value * 100 ) ) ;
}
if ( swPbl . containsKey ( area_name ) ) { //生物配备率
float value = swPbl . get ( area_name ) . getFloat ( "radio" ) / swPbl . get ( area_name ) . getInt ( "count" ) ;
record . set ( "sw_pbl" , String . format ( "%.2f%%" , value * 100 ) ) ;
}
if ( kxPbl . containsKey ( area_name ) ) { //小学科学配备率
float value = kxPbl . get ( area_name ) . getFloat ( "radio" ) / kxPbl . get ( area_name ) . getInt ( "count" ) ;
record . set ( "kx_pbl" , String . format ( "%.2f%%" , value * 100 ) ) ;
}
if ( yyPbl . containsKey ( area_name ) ) { //音乐配备率
float value = yyPbl . get ( area_name ) . getFloat ( "radio" ) / yyPbl . get ( area_name ) . getInt ( "count" ) ;
record . set ( "yy_pbl" , String . format ( "%.2f%%" , value * 100 ) ) ;
}
if ( tyPbl . containsKey ( area_name ) ) { //体育配备率
float value = tyPbl . get ( area_name ) . getFloat ( "radio" ) / tyPbl . get ( area_name ) . getInt ( "count" ) ;
record . set ( "ty_pbl" , String . format ( "%.2f%%" , value * 100 ) ) ;
}
if ( msPbl . containsKey ( area_name ) ) { //美术配备率
float value = msPbl . get ( area_name ) . getFloat ( "radio" ) / msPbl . get ( area_name ) . getInt ( "count" ) ;
record . set ( "ms_pbl" , String . format ( "%.2f%%" , value * 100 ) ) ;
}
}
addSummaryRow ( list ) ;
return list ;
//TODO
return null ;
// Kv kv = Kv.by("year", year);
// SqlPara sqlPara = Db.getSqlPara("Zbdc.getSummaryCgzb", kv);
// List<Record> list = Db.find(sqlPara);
// list = expandList(list);
// //共七个配备率,需要重新计算
// Map<String, Kv> wlPbl = calcPbl(year, new String[]{"初中物理", "高中物理"}); //key:市直,二道区,南关区 Kv:count,radio
// Map<String, Kv> hxPbl = calcPbl(year, new String[]{"初中化学", "高中化学"});
// Map<String, Kv> swPbl = calcPbl(year, new String[]{"初中生物", "高中生物"});
// Map<String, Kv> kxPbl = calcPbl(year, new String[]{"小学科学"});
// Map<String, Kv> yyPbl = calcPbl(year, new String[]{"小学音乐", "初中音乐", "高中音乐"});
// Map<String, Kv> tyPbl = calcPbl(year, new String[]{"小学体育", "初中体育", "高中体育"});
// Map<String, Kv> msPbl = calcPbl(year, new String[]{"小学美术", "初中美术", "高中美术"});
// //修改一下list
// for (Record record : list) {
// String area_name = record.getStr("area_name");
// if (wlPbl.containsKey(area_name)) {//物理配备率
// float value = wlPbl.get(area_name).getFloat("radio") / wlPbl.get(area_name).getInt("count");
// record.set("wl_pbl", String.format("%.2f%%", value * 100));
// }
// if (hxPbl.containsKey(area_name)) {//化学配备率
// float value = hxPbl.get(area_name).getFloat("radio") / hxPbl.get(area_name).getInt("count");
// record.set("hx_pbl", String.format("%.2f%%", value * 100));
// }
// if (swPbl.containsKey(area_name)) {//生物配备率
// float value = swPbl.get(area_name).getFloat("radio") / swPbl.get(area_name).getInt("count");
// record.set("sw_pbl", String.format("%.2f%%", value * 100));
// }
// if (kxPbl.containsKey(area_name)) {//小学科学配备率
// float value = kxPbl.get(area_name).getFloat("radio") / kxPbl.get(area_name).getInt("count");
// record.set("kx_pbl", String.format("%.2f%%", value * 100));
// }
// if (yyPbl.containsKey(area_name)) {//音乐配备率
// float value = yyPbl.get(area_name).getFloat("radio") / yyPbl.get(area_name).getInt("count");
// record.set("yy_pbl", String.format("%.2f%%", value * 100));
// }
// if (tyPbl.containsKey(area_name)) {//体育配备率
// float value = tyPbl.get(area_name).getFloat("radio") / tyPbl.get(area_name).getInt("count");
// record.set("ty_pbl", String.format("%.2f%%", value * 100));
// }
// if (msPbl.containsKey(area_name)) {//美术配备率
// float value = msPbl.get(area_name).getFloat("radio") / msPbl.get(area_name).getInt("count");
// record.set("ms_pbl", String.format("%.2f%%", value * 100));
// }
// }
// addSummaryRow(list);
// return list;
}
/ * *
@ -1725,12 +1799,12 @@ public class ZbdcModel {
* @return
* /
public List < Record > expandList ( List < Record > list ) {
if ( list . size( ) = = 0 ) return null ;
if ( list . isEmpty( ) ) return null ;
//行政区划
List < Record > listXzqh = getQueryXzqh ( ) ;
//有用的记录
Record originalRecord = list . get ( 0 ) ;
Record originalRecord = list . get First ( ) ;
// 遍历每个属性, 如果不是area_name,那么给初值0
Map < String , Object > attrs = originalRecord . getColumns ( ) ;
// 遍历Map中的所有属性
@ -1775,7 +1849,7 @@ public class ZbdcModel {
Map < String , Kv > _map = new HashMap < > ( ) ;
for ( int i = 0 ; i < kmList . length ; i + + ) {
Kv kv = Kv . by ( "year" , year ) ;
kv . set ( "km" , kmList [ i ] ) ;
kv . set ( "km" , kmList [ i ] ) ; //每个科目分别计算配备率,按科目名计算获取
SqlPara sqlPara = Db . getSqlPara ( "Zbdc.calcPbl" , kv ) ;
List < Record > list = Db . find ( sqlPara ) ;
@ -1961,7 +2035,7 @@ public class ZbdcModel {
/ * *
* 功 能 : 上 报 审 核 标 记
*
* @param year
* @param year 数 据 上 报 年 份
* /
public void saveReport ( int year , String bureau_id ) {
String sql = "select org_type_id,org_name from t_base_organization where org_id=?" ;
@ -1971,14 +2045,15 @@ public class ZbdcModel {
Map < String , Record > _map = getSchoolAreaName ( ) ;
String area_id = _map . get ( bureau_id ) . getStr ( "area_id" ) ;
String area_name = _map . get ( bureau_id ) . getStr ( "area_name" ) ;
int report_level = 2 ;
if ( org_type_id = = 9 | | org_type_id = = 16 ) {
report_level = 1 ;
int report_level = 2 ; //默认是县区上报的, 1:学校 2:县区
if ( org_type_id = = 9 | | org_type_id = = 16 ) { //市直属中小学,区属中小学
report_level = 1 ; //是学校上报的
}
sql = "delete from t_zbdc_report where bureau_id=? and year=?" ;
//以前的都修改为不是当前状态,现在是全新上报
sql = "update t_zbdc_report set b_use=0 where bureau_id=? and year=?" ;
Db . update ( sql , bureau_id , year ) ;
sql = "insert into t_zbdc_report(bureau_id,bureau_name,year,area_id,area_name,report_level,update_ts ) values(?,?,?,?,?,?,now())";
//插入数据
sql = "insert into t_zbdc_report(bureau_id,bureau_name,year,area_id,area_name,report_level,update_ts ,b_use ) values(?,?,?,?,?,?,now(),1 )";
Db . update ( sql , bureau_id , bureau_name , year , area_id , area_name , report_level ) ;
}
@ -2001,7 +2076,7 @@ public class ZbdcModel {
//如果当前人员是长春市教育局的审核员
String sql ;
if ( bureau_id . equals ( "5CE95FA9-B866-473D-862F-55C813CCCA4C" ) ) {
if ( bureau_id . equals ( PropKit . get ( "ZhuangBeiCenterId" ) ) ) {
if ( StrKit . isBlank ( area_id ) | | area_id . equals ( "0" ) ) {
sql = "from t_base_organization as t1 inner join t_dm_schooltype as t2 on t1.school_type_id=t2.school_type_id where t1.org_id=t1.bureau_id and t1.org_type_id=9 and t1.org_name like '%" + keyword + "%' " ;
if ( school_type_id > 0 ) sql + = " and t1.school_type_id=" + school_type_id ;
@ -2047,33 +2122,53 @@ public class ZbdcModel {
}
/ * *
* 功 能 : 一键 审核 通 过
* 功 能 : 审核
*
* @param year
* @param bureau_id
* @param year 年 份
* @param area_ids 区 域 IDs
* @param bureau_ids 单 位 IDS
* @param check_type_id 1 : 通 过 - 1 : 不 通 过
* @param message 领 导 批 示 内 容
* /
public void oneKeyPass ( int year , String bureau_id ) {
String updateSql = "update t_zbdc_report set check_type_id=1 where year=? and area_id=? and report_level=1" ;
if ( bureau_id . equals ( "5CE95FA9-B866-473D-862F-55C813CCCA4C" ) ) { //市直
//如果是当前人员是张璐
Db . update ( updateSql , year , "0" ) ;
} else {
//当前登录人的区域,区县
String sql = "select area_id from t_base_organization where org_id=?" ;
String area_id = Db . findFirst ( sql , bureau_id ) . getStr ( "area_id" ) ;
Db . update ( updateSql , year , area_id ) ;
public void checkReport ( int year , String area_ids , String bureau_ids , int check_type_id , String message , String check_bureau_id ) {
for ( String s : area_ids . split ( "," ) ) {
//1、多个区县
//2、指定年份
//3、指定审核状态
//4、report_level=2 只处理区域报上来的数据
String sql = "update t_zbdc_report set check_type_id=?,message=?,check_bureau_id=? where year=? and area_id=? and b_use=1 and report_level=2" ;
Db . update ( sql , check_type_id , message , check_bureau_id , year , s ) ;
}
for ( String s : bureau_ids . split ( "," ) ) {
//1、多个学校
//2、指定年份
//3、指定审核状态
//4、report_level=1 只处理学校报上来的数据
String sql = "update t_zbdc_report set check_type_id=?,message=?,check_bureau_id=? where year=? and bureau_id=? and b_use=1 and report_level=1" ;
Db . update ( sql , check_type_id , message , check_bureau_id , year , s ) ;
}
}
/ * *
* 功 能 : 市 审 核 区 通 过
*
* @param year
* @param area_id
* 功 能 : 查 看 审 核 日 志
* type_id : 1 : 我 上 报 过 的 日 志 , 查 看 被 审 核 的 结 果 2 : 我 审 核 过 的 日 志 , 查 看 我 审 核 的 日 志
* 使 用 者 :
* 1 、 市 管 理 员
* 所 有 我 审 核 过 的 日 志
* 2 、 县 区 管 理 员
* ( 1 ) 所 有 我 审 核 过 的 日 志
* ( 2 ) 所 有 我 上 报 的 日 志
* 3 、 学 校 管 理 员
* 所 有 我 上 报 的 日 志
* /
public void ShiCheckQuPass ( int year , String area_id ) {
String updateSql = "update t_zbdc_report set check_type_id=1 where year=? and area_id=? and report_level=2" ;
Db . update ( updateSql , year , area_id ) ;
public Page < Record > ViewReport ( String bureau_id , int type_id , int page , int limit ) {
String sql ;
if ( type_id = = 1 ) {
sql = "from t_zbdc_report where bureau_id=? order by id desc" ;
} else {
sql = "from t_zbdc_report where check_bureau_id=? order by id desc" ;
}
return Db . paginate ( page , limit , "select *" , sql , bureau_id ) ;
}
/ * *