diff --git a/src/main/java/com/dsideal/QingLong/Util/CommonUtil.java b/src/main/java/com/dsideal/QingLong/Util/CommonUtil.java index 574706c9..2edd0c06 100644 --- a/src/main/java/com/dsideal/QingLong/Util/CommonUtil.java +++ b/src/main/java/com/dsideal/QingLong/Util/CommonUtil.java @@ -34,6 +34,22 @@ public class CommonUtil { public static String WebRoot; + public static void mergeJsonObjects(JSONObject j1, JSONObject j2) { + // 获取j2的所有键 + Set keys = j2.keySet(); + for (String key : keys) { + // 确保j1也有相同的键 + if (j1.containsKey(key)) { + // 累加数值 + Object value1 = j1.get(key); + Object value2 = j2.get(key); + if (value1 instanceof Number && value2 instanceof Number) { + j1.put(key, ((Number) value1).doubleValue() + ((Number) value2).doubleValue()); + } + } + } + } + /** * 功能:克隆Record对象 * diff --git a/src/main/java/com/dsideal/QingLong/Util/JSONUtil.java b/src/main/java/com/dsideal/QingLong/Util/JSONUtil.java index d29e04c7..33a39140 100644 --- a/src/main/java/com/dsideal/QingLong/Util/JSONUtil.java +++ b/src/main/java/com/dsideal/QingLong/Util/JSONUtil.java @@ -1,4 +1,5 @@ package com.dsideal.QingLong.Util; + import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.jfinal.kit.StrKit; @@ -7,6 +8,7 @@ import com.jfinal.plugin.activerecord.Record; import java.util.ArrayList; import java.util.List; import java.util.Map; + public class JSONUtil { public static Record parse(JSONObject jobj) { return buildJSONObject(jobj); @@ -36,6 +38,26 @@ public class JSONUtil { return record; } + /** + * 功能:将List转为List + * + * @param list + * @return + */ + public static List parseListJSONObject(List list) { + List list1 = new ArrayList<>(); + for (JSONObject jsonObject : list) { + Record record = new Record(); + for (String key : jsonObject.keySet()) { + Object value = jsonObject.get(key); + // 假设record是你要填充的Record对象 + record.set(key, value); + } + list1.add(record); + } + return list1; + } + private static List addChild(JSONArray array) { List result = new ArrayList<>(); for (int i = 0; i < array.size(); i++) { diff --git a/src/main/java/com/dsideal/QingLong/Zbdc/Controller/ZbdcController.java b/src/main/java/com/dsideal/QingLong/Zbdc/Controller/ZbdcController.java index f7f02bd3..aad6b90d 100644 --- a/src/main/java/com/dsideal/QingLong/Zbdc/Controller/ZbdcController.java +++ b/src/main/java/com/dsideal/QingLong/Zbdc/Controller/ZbdcController.java @@ -8,6 +8,7 @@ import com.dsideal.QingLong.Interceptor.IsLoginInterface; import com.dsideal.QingLong.Interceptor.IsNumericInterface; import com.dsideal.QingLong.Util.CommonUtil; import com.dsideal.QingLong.Util.ExcelExportUtil; +import com.dsideal.QingLong.Util.JSONUtil; import com.dsideal.QingLong.Util.SessionKit; import com.dsideal.QingLong.Zbdc.Model.ZbdcModel; import com.jfinal.aop.Before; @@ -657,10 +658,20 @@ public class ZbdcController extends Controller { // http://10.10.21.20:9000/QingLong/zbdc/getQueryBaseInfo?area_id=0&school_type_id=342&keyword=&page=1&limit=100 // 县区小学 // http://10.10.21.20:9000/QingLong/zbdc/getQueryBaseInfo?area_id=2C0CE452-B43C-478E-8D51-F4470A36F739&school_type_id=211&keyword=&page=1&limit=100 - public void getQueryBaseInfo(String area_id, int school_type_id, int year, String keyword, int page, int limit) { + public void getQueryBaseInfo(String area_id, int school_type_id, int year, String keyword, int page, int limit, int export_flag) throws URISyntaxException, IOException { if (year == 0) year = DateTime.now().year();//如果没有传入获取的年份,那么就是系统的默认当前年份 Page list = zm.getQueryBaseInfo(area_id, school_type_id, year, keyword, page, limit); - renderJson(CommonUtil.renderJsonForLayUI(list)); + + if (export_flag == 0) { + renderJson(CommonUtil.renderJsonForLayUI(list)); + } else { + String excelPath = CommonUtil.getClassPath() + PropKit.get("excelExportTemplatePathSuffix").replace("\\", "/"); + String template = excelPath + "Query_BaseInfo.xlsx"; + //导出 + String excelFile = excelPath + "excelTemp/" + UUID.randomUUID().toString().toUpperCase() + ".xlsx"; + ExcelExportUtil.exportByTemplate(list.getList(), template, excelFile); + renderFile(new File(excelFile), "基础信息.xlsx"); + } } @@ -676,10 +687,19 @@ public class ZbdcController extends Controller { // http://10.10.21.20:9000/QingLong/zbdc/getQueryCgzb?area_id=&school_type_id=211&year=0&keyword=&page=1&limit=10 // 县区小学 // http://10.10.21.20:9000/QingLong/zbdc/getQueryCgzb?area_id=2C0CE452-B43C-478E-8D51-F4470A36F739&school_type_id=211&year=0&keyword=&page=1&limit=10 - public void getQueryCgzb(String area_id, int school_type_id, String keyword, int year, int page, int limit) { + public void getQueryCgzb(String area_id, int school_type_id, String keyword, int year, int page, int limit, int export_flag) throws URISyntaxException, IOException { if (year == 0) year = DateTime.now().year();//如果没有传入获取的年份,那么就是系统的默认当前年份 Page list = zm.getQueryCgzb(area_id, school_type_id, year, keyword, page, limit); - renderJson(CommonUtil.renderJsonForLayUI(list)); + if (export_flag == 0) { + renderJson(CommonUtil.renderJsonForLayUI(list)); + } else { + String excelPath = CommonUtil.getClassPath() + PropKit.get("excelExportTemplatePathSuffix").replace("\\", "/"); + String template = excelPath + "Query_Cgzb.xlsx"; + //导出 + String excelFile = excelPath + "excelTemp/" + UUID.randomUUID().toString().toUpperCase() + ".xlsx"; + ExcelExportUtil.exportByTemplate(list.getList(), template, excelFile); + renderFile(new File(excelFile), "常规装备信息.xlsx"); + } } /** @@ -698,11 +718,21 @@ public class ZbdcController extends Controller { @IsLoginInterface({}) @EmptyInterface({"km_code"}) // http://10.10.21.20:9000/QingLong/zbdc/getQueryYqsb?page=1&limit=15&area_id=&school_type_id=312&km_code=czyl&level_filter=&keyword= - public void getQueryYqsb(String area_id, int school_type_id, String keyword, String km_code, String level_filter, int year, int type_id, int pbyq, int page, int limit) { + public void getQueryYqsb(String area_id, int school_type_id, String keyword, String km_code, String level_filter, int year, int type_id, int pbyq, int page, int limit, int export_flag) throws URISyntaxException, IOException { if (year == 0) year = DateTime.now().year();//如果没有传入获取的年份,那么就是系统的默认当前年份 String bureauIds = zm.getBureauIds(area_id, school_type_id, keyword); Page list = zm.getQueryYqsb(bureauIds, year, km_code, level_filter, type_id, pbyq, page, limit); - renderJson(CommonUtil.renderJsonForLayUI(list)); + if (export_flag == 0) { + renderJson(CommonUtil.renderJsonForLayUI(list)); + } else { + String excelPath = CommonUtil.getClassPath() + PropKit.get("excelExportTemplatePathSuffix").replace("\\", "/"); + String template = excelPath + "Query_Yqsb.xlsx"; + //导出 + String excelFile = excelPath + "excelTemp/" + UUID.randomUUID().toString().toUpperCase() + ".xlsx"; + ExcelExportUtil.exportByTemplate(list.getList(), template, excelFile); + renderFile(new File(excelFile), "仪器设备.xlsx"); + } + } @@ -726,10 +756,20 @@ public class ZbdcController extends Controller { // http://10.10.21.20:9000/QingLong/zbdc/getQueryXxhsb?area_id=&school_type_id=211&dcb_id=1&year=0&keyword=&page=1&limit=10 // 县区小学 // http://10.10.21.20:9000/QingLong/zbdc/getQueryXxhsb?area_id=2C0CE452-B43C-478E-8D51-F4470A36F739&school_type_id=211&dcb_id=1&year=0&keyword=&page=1&limit=10 - public void getQueryXxhsb(String school_id, int type_id, String area_id, int school_type_id, String keyword, int year, int dcb_id, int page, int limit) { + public void getQueryXxhsb(String school_id, String area_id, int school_type_id, String keyword, int year, int dcb_id, int page, int limit, int export_flag) throws URISyntaxException, IOException { if (year == 0) year = DateTime.now().year();//如果没有传入获取的年份,那么就是系统的默认当前年份 Page list = zm.getQueryXxhsb(school_id, area_id, school_type_id, year, keyword, dcb_id, page, limit); - renderJson(CommonUtil.renderJsonForLayUI(list)); + if (export_flag == 0) { + renderJson(CommonUtil.renderJsonForLayUI(list)); + } else { + String excelPath = CommonUtil.getClassPath() + PropKit.get("excelExportTemplatePathSuffix").replace("\\", "/"); + String template = excelPath + "Query_Xxhsb.xlsx"; + //导出 + String excelFile = excelPath + "excelTemp/" + UUID.randomUUID().toString().toUpperCase() + ".xlsx"; + ExcelExportUtil.exportByTemplate(list.getList(), template, excelFile); + renderFile(new File(excelFile), "信息化设备.xlsx"); + } + } /** @@ -783,8 +823,8 @@ public class ZbdcController extends Controller { // http://10.10.21.20:9000/QingLong/zbdc/getSummaryCgzb public void getSummaryCgzb(int year) { if (year == 0) year = DateTime.now().year();//如果没有传入获取的年份,那么就是系统的默认当前年份 - List list = zm.getSummaryCgzb(year); - renderJson(CommonUtil.renderJsonForLayUI(list)); + List list = zm.getSummaryCgzb(year); + renderJson(list); } @Before({GET.class}) @@ -793,13 +833,12 @@ public class ZbdcController extends Controller { // http://10.10.21.20:9000/QingLong/zbdc/exportSummaryCgzb public void exportSummaryCgzb(int year) throws URISyntaxException, IOException { if (year == 0) year = DateTime.now().year();//如果没有传入获取的年份,那么就是系统的默认当前年份 - List list = zm.getSummaryCgzb(year); - //TODO + List list = zm.getSummaryCgzb(year); String excelPath = CommonUtil.getClassPath() + PropKit.get("excelExportTemplatePathSuffix").replace("\\", "/"); String template = excelPath + "exportSummaryCgzb.xlsx"; //导出 String excelFile = excelPath + "excelTemp/" + UUID.randomUUID().toString().toUpperCase() + ".xlsx"; - ExcelExportUtil.exportByTemplate(list, template, excelFile); + ExcelExportUtil.exportByTemplate(JSONUtil.parseListJSONObject(list), template, excelFile); renderFile(new File(excelFile), "常规装备汇总.xlsx"); } @@ -929,7 +968,7 @@ public class ZbdcController extends Controller { * 所有我上报的日志 */ @IsLoginInterface({}) - @IsNumericInterface({"type_id","page","limit"}) + @IsNumericInterface({"type_id", "page", "limit"}) public void ViewReport(int type_id, int page, int limit) { //审核单位ID String bureau_id = SessionKit.get(getRequest(), getResponse(), "bureau_id"); diff --git a/src/main/java/com/dsideal/QingLong/Zbdc/Model/ZbdcModel.java b/src/main/java/com/dsideal/QingLong/Zbdc/Model/ZbdcModel.java index d607e513..01aa8f74 100644 --- a/src/main/java/com/dsideal/QingLong/Zbdc/Model/ZbdcModel.java +++ b/src/main/java/com/dsideal/QingLong/Zbdc/Model/ZbdcModel.java @@ -6,6 +6,7 @@ import java.math.RoundingMode; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.dsideal.QingLong.Start; import com.dsideal.QingLong.Util.CommonUtil; @@ -19,9 +20,12 @@ import com.jfinal.plugin.activerecord.dialect.PostgreSqlDialect; import com.jfinal.plugin.hikaricp.HikariCpPlugin; import com.jfinal.plugin.redis.RedisPlugin; +import java.sql.SQLException; +import java.text.DecimalFormat; import java.util.*; import java.text.SimpleDateFormat; + public class ZbdcModel { /** * 功能:传入学校类型ID,返回此学校类型有哪些学段 @@ -650,9 +654,6 @@ public class ZbdcModel { return Db.find(sql); } - /** - * 功能:获取指定科目下的填报模板 - */ /** * 功能:获取指定科目下的填报模板 */ @@ -1481,12 +1482,21 @@ public class ZbdcModel { } //配备情况 List listPb = calcPbl(year); - Map mapPb = new HashMap<>(); + Map mapPbl = new HashMap<>();//配备率 + Map mapNowCnt = new HashMap<>();//现有品种数量 + Map mapNeedCnt = new HashMap<>();//应配置品种数量 for (Record record : listPb) { String bureau_id = record.getStr("bureau_id"); String col = record.getStr("col"); //summary_yypbl float radio = record.getFloat("radio"); - mapPb.put(bureau_id + "_" + col, radio); + int nowcnt = record.getInt("nowcnt"); + int needcnt = record.getInt("needcnt"); + //配置率 + mapPbl.put(bureau_id + "_" + col, radio); + //已配置品种数量 + mapNowCnt.put(bureau_id + "_" + col, nowcnt); + //应配置品牌数量 + mapNeedCnt.put(bureau_id + "_" + col, needcnt); } for (Record record : p.getList()) { @@ -1585,34 +1595,35 @@ public class ZbdcModel { record.set("summary_qdljtrmj", record.getFloat("cz_qdljtrmj") + record.getFloat("gz_qdljtrmj")); record.set("summary_lsjtrshshu", record.getInt("cz_lsjtrshshu") + record.getInt("gz_lsjtrshshu")); record.set("summary_lsjtrmj", record.getFloat("cz_lsjtrmj") + record.getFloat("gz_lsjtrmj")); - //配备率 - record.set("xx_kxpbl", mapPb.get(bureau_id + "_" + "xx_kxpbl"));//小学科学 配备率 - record.set("xx_yypbl", mapPb.get(bureau_id + "_" + "xx_yypbl"));//小学音乐 配备率 - record.set("cz_yypbl", mapPb.get(bureau_id + "_" + "cz_yypbl"));//初中音乐 配备率 - record.set("gz_yypbl", mapPb.get(bureau_id + "_" + "gz_yypbl"));//高中音乐 配备率 - record.set("summary_yypbl", mapPb.get(bureau_id + "_" + "summary_yypbl"));//汇总 配备率 - - record.set("xx_typbl", mapPb.get(bureau_id + "_" + "xx_typbl"));//小学体育 配备率 - record.set("cz_typbl", mapPb.get(bureau_id + "_" + "cz_typbl"));//初中体育 配备率 - record.set("gz_typbl", mapPb.get(bureau_id + "_" + "gz_typbl"));//高中体育 配备率 - record.set("summary_typbl", mapPb.get(bureau_id + "_" + "summary_typbl"));//汇总 配备率 - - record.set("xx_mspbl", mapPb.get(bureau_id + "_" + "xx_mspbl"));//小学美术 配备率 - record.set("cz_mspbl", mapPb.get(bureau_id + "_" + "cz_mspbl"));//初中美术 配备率 - record.set("gz_mspbl", mapPb.get(bureau_id + "_" + "gz_mspbl"));//高中美术 配备率 - record.set("summary_mspbl", mapPb.get(bureau_id + "_" + "summary_mspbl"));//汇总 配备率 - - record.set("cz_wlpbl", mapPb.get(bureau_id + "_" + "cz_wlpbl"));//初中物理 配备率 - record.set("gz_wlpbl", mapPb.get(bureau_id + "_" + "gz_wlpbl"));//高中物理 配备率 - record.set("summary_wlpbl", mapPb.get(bureau_id + "_" + "summary_wlpbl"));//汇总 配备率 - - record.set("cz_hxpbl", mapPb.get(bureau_id + "_" + "cz_hxpbl"));//初中化学 配备率 - record.set("gz_hxpbl", mapPb.get(bureau_id + "_" + "gz_hxpbl"));//高中化学 配备率 - record.set("summary_hxpbl", mapPb.get(bureau_id + "_" + "summary_hxpbl"));//汇总 配备率 - - record.set("cz_swpbl", mapPb.get(bureau_id + "_" + "cz_swpbl"));//初中生物 配备率 - record.set("gz_swpbl", mapPb.get(bureau_id + "_" + "gz_swpbl"));//高中生物 配备率 - record.set("summary_swpbl", mapPb.get(bureau_id + "_" + "summary_swpbl"));//汇总 配备率 + + //配备率 cz_swyppz cz_swypjs + record.set("xx_kxpbl", mapPbl.get(bureau_id + "_" + "xx_kxpbl"));//小学科学 配备率 + record.set("xx_yypbl", mapPbl.get(bureau_id + "_" + "xx_yypbl"));//小学音乐 配备率 + record.set("cz_yypbl", mapPbl.get(bureau_id + "_" + "cz_yypbl"));//初中音乐 配备率 + record.set("gz_yypbl", mapPbl.get(bureau_id + "_" + "gz_yypbl"));//高中音乐 配备率 + record.set("summary_yypbl", mapPbl.get(bureau_id + "_" + "summary_yypbl"));//汇总 配备率 + + record.set("xx_typbl", mapPbl.get(bureau_id + "_" + "xx_typbl"));//小学体育 配备率 + record.set("cz_typbl", mapPbl.get(bureau_id + "_" + "cz_typbl"));//初中体育 配备率 + record.set("gz_typbl", mapPbl.get(bureau_id + "_" + "gz_typbl"));//高中体育 配备率 + record.set("summary_typbl", mapPbl.get(bureau_id + "_" + "summary_typbl"));//汇总 配备率 + + record.set("xx_mspbl", mapPbl.get(bureau_id + "_" + "xx_mspbl"));//小学美术 配备率 + record.set("cz_mspbl", mapPbl.get(bureau_id + "_" + "cz_mspbl"));//初中美术 配备率 + record.set("gz_mspbl", mapPbl.get(bureau_id + "_" + "gz_mspbl"));//高中美术 配备率 + record.set("summary_mspbl", mapPbl.get(bureau_id + "_" + "summary_mspbl"));//汇总 配备率 + + record.set("cz_wlpbl", mapPbl.get(bureau_id + "_" + "cz_wlpbl"));//初中物理 配备率 + record.set("gz_wlpbl", mapPbl.get(bureau_id + "_" + "gz_wlpbl"));//高中物理 配备率 + record.set("summary_wlpbl", mapPbl.get(bureau_id + "_" + "summary_wlpbl"));//汇总 配备率 + + record.set("cz_hxpbl", mapPbl.get(bureau_id + "_" + "cz_hxpbl"));//初中化学 配备率 + record.set("gz_hxpbl", mapPbl.get(bureau_id + "_" + "gz_hxpbl"));//高中化学 配备率 + record.set("summary_hxpbl", mapPbl.get(bureau_id + "_" + "summary_hxpbl"));//汇总 配备率 + + record.set("cz_swpbl", mapPbl.get(bureau_id + "_" + "cz_swpbl"));//初中生物 配备率 + record.set("gz_swpbl", mapPbl.get(bureau_id + "_" + "gz_swpbl"));//高中生物 配备率 + record.set("summary_swpbl", mapPbl.get(bureau_id + "_" + "summary_swpbl"));//汇总 配备率 //如果配备率为空,则设为0,什么情况下为空呢?比如用户就没有配置 for (Map.Entry entry : record.getColumns().entrySet()) { @@ -1798,55 +1809,61 @@ public class ZbdcModel { * @param year * @return */ - public List getSummaryCgzb(int year) { - //TODO - return null; -// Kv kv = Kv.by("year", year); -// SqlPara sqlPara = Db.getSqlPara("Zbdc.getSummaryCgzb", kv); -// List list = Db.find(sqlPara); -// list = expandList(list); -// //共七个配备率,需要重新计算 -// Map wlPbl = calcPbl(year, new String[]{"初中物理", "高中物理"}); //key:市直,二道区,南关区 Kv:count,radio -// Map hxPbl = calcPbl(year, new String[]{"初中化学", "高中化学"}); -// Map swPbl = calcPbl(year, new String[]{"初中生物", "高中生物"}); -// Map kxPbl = calcPbl(year, new String[]{"小学科学"}); -// Map yyPbl = calcPbl(year, new String[]{"小学音乐", "初中音乐", "高中音乐"}); -// Map tyPbl = calcPbl(year, new String[]{"小学体育", "初中体育", "高中体育"}); -// Map 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; + public List getSummaryCgzb(int year) { + //基于常规装备查询功能构建统计功能 + Page list = getQueryCgzb(null, 0, year, "", 1, 9999); + String json = JsonKit.toJson(list.getList()); + JSONArray ja = JSONArray.parseArray(json); + Map map = new HashMap<>(); + for (int i = 0; i < ja.size(); i++) { + JSONObject j2 = ja.getJSONObject(i); + String area_name = j2.getString("area_name"); + //移除多余属性 + j2.remove("id"); + j2.remove("bureau_id"); + j2.remove("bureau_name"); + j2.remove("year"); + j2.remove("school_type_name"); + + //处理一下配备率百分号 + j2 = convertBfhToDouble(j2); + if (map.containsKey(area_name)) {//包含 + JSONObject j1 = map.get(area_name); + j1 = convertBfhToDouble(j1); + //将jo中所有属性叠加到j2上去,并重新将j2放入到map中, 将j2的所有属性值累加到j1上 + CommonUtil.mergeJsonObjects(j1, j2); + //放回去 + j1.put("cnt", j1.getInteger("cnt") + 1); + map.put(area_name, j1); + } else {//不包含 + j2.put("cnt", 1); + map.put(area_name, j2); + } + } + //所有以pbl结尾的字段,都需要再除以cnt + for (String key : map.keySet()) { + JSONObject j = map.get(key); + for (String k : j.keySet()) { + if (k.endsWith("pbl")) { + // 计算百分比 + String percentage = String.format("%.1f%%", j.getDouble(k) / j.getInteger("cnt")); + j.put(k, percentage); + } + } + } + //以指定顺序的顺序输出 + List L = getQueryXzqh(); + List res = new ArrayList<>(); + for (int i = 0; i < L.size(); i++) { + Record r = L.get(i); + String area_name = r.getStr("area_name"); + if (map.containsKey(area_name)) { + JSONObject j = map.get(area_name); + res.add(j); + } + } + //System.out.println(JsonKit.toJson(res)); + return res; } /** @@ -2304,7 +2321,26 @@ public class ZbdcModel { } } - public static void main(String[] args) { + /** + * 功能:将JSONObject对象中的百分比转换为double + * + * @param jo + * @return + */ + public static JSONObject convertBfhToDouble(JSONObject jo) { + Set keys = jo.keySet(); + for (String key : keys) { + // 累加数值 + Object v = jo.get(key); + if (v.toString().indexOf("%") > 0) { + v = v.toString().replace("%", ""); + jo.put(key, (Double.parseDouble(v.toString()))); + } + } + return jo; + } + + public static void main(String[] args) throws SQLException { //告之配置文件位置 PropKit.use("application.properties"); HikariCpPlugin hp = new HikariCpPlugin(PropKit.get("jdbcUrl"), PropKit.get("user"), @@ -2336,8 +2372,6 @@ public class ZbdcModel { redis.start(); ZbdcModel zm = new ZbdcModel(); - List list = zm.calcPbl(2024); - String json = JsonKit.toJson(list); - System.out.println(json); + } } \ No newline at end of file diff --git a/src/main/resource/ExcelExportTemplate/Query_Xxhsbcx.xlsx b/src/main/resource/ExcelExportTemplate/Query_Xxhsb.xlsx similarity index 100% rename from src/main/resource/ExcelExportTemplate/Query_Xxhsbcx.xlsx rename to src/main/resource/ExcelExportTemplate/Query_Xxhsb.xlsx diff --git a/src/main/resource/ExcelExportTemplate/exportSummaryCgzb.xlsx b/src/main/resource/ExcelExportTemplate/exportSummaryCgzb.xlsx new file mode 100644 index 00000000..1e2fbbd2 Binary files /dev/null and b/src/main/resource/ExcelExportTemplate/exportSummaryCgzb.xlsx differ