public static JSONObject doLoadInfo(JSONObject params, ActionContext context) throws Exception {
String pID = params.getString("epid");
String sql = "select \n"
+ " (select count(*) from YH_YHXX where YHDJ='一般隐患' AND EPID='" + pID + "') as YBYH,\n"
+ " (select count(*) from YH_YHXX where YHDJ='重大隐患' AND EPID='" + pID + "') as ZDYH,\n"
+ " (select count(*) from YH_YHXX where YHDJ='一般隐患' AND EPID='" + pID + "' AND (ZGZT='未整改' OR ZGZT='退回整改')) as YBYH_ZGZ,\n"
+ " (select count(*) from YH_YHXX where YHDJ='重大隐患' AND (ZGZT='未整改' OR ZGZT='退回整改') AND EPID='" + pID + "') as ZDYH_ZGZ,\n"
+ " (select count(*) from YH_YHXX where YHDJ='一般隐患' AND YHZGQX < SYSDATE AND EPID='" + pID + "' AND (ZGZT='未整改' OR ZGZT='退回整改')) as YBYH_YQWZG,\n"
+ " (select count(*) from YH_YHXX where YHDJ='重大隐患' AND YHZGQX < SYSDATE AND EPID='" + pID + "' AND (ZGZT='未整改' OR ZGZT='退回整改')) as ZDYH_YQWZG,\n"
+ " (select count(*) from YH_YHXX where YHDJ='一般隐患' AND ZGZT='已整改' AND EPID='" + pID + "') as YBYH_YGZ,\n"
+ " (select count(*) from YH_YHXX where YHDJ='重大隐患' AND ZGZT='已整改' AND EPID='" + pID + "') as ZDYH_YGZ,\n"
+ " (select count(*) from YH_YHXX where ZGZT='未整改(审核中)' AND EPID='" + pID + "') as DHZYH,\n"
+ " (select count(*) from YH_YHXX where EPID='" + pID + "' AND (ZGZT='未整改' OR ZGZT='退回整改' )) as XYZG,\n"
+ " (select count(*) from YH_YHXX where ZGZT='已整改' AND HXZT='未核销' AND EPID='" + pID + "') as DHX,\n"
+ " (select count(*) from YH_YHXX where YHDJ='重大隐患' AND EPID='" + pID + "') as ZDYHZ\n"
+ " from dual";
System.out.println(sql);
JSONObject result = new JSONObject();
Connection conn = null;
try {
conn = context.getConnection("em");
Table table = DataUtils.queryData(conn, sql, null, null, null, null);
List<Row> ls_row = table.getRows();
if (ls_row.size() > 0) {
Row row = ls_row.get(0);
result.put("result", "success");
JSONObject userInfo = new JSONObject();
userInfo.put("YBYH", row.getDecimal("YBYH").toString());
userInfo.put("ZDYH", row.getDecimal("ZDYH").toString());
userInfo.put("YBYH_ZGZ", row.getDecimal("YBYH_ZGZ").toString());
userInfo.put("ZDYH_ZGZ", row.getDecimal("ZDYH_ZGZ").toString());
userInfo.put("YBYH_YQWZG", row.getDecimal("YBYH_YQWZG").toString());
userInfo.put("ZDYH_YQWZG", row.getDecimal("ZDYH_YQWZG").toString());
userInfo.put("YBYH_YGZ", row.getDecimal("YBYH_YGZ").toString());
userInfo.put("ZDYH_YGZ", row.getDecimal("ZDYH_YGZ").toString());
userInfo.put("DHZYH", row.getDecimal("DHZYH").toString());
userInfo.put("XYZG", row.getDecimal("XYZG").toString());
userInfo.put("DHX", row.getDecimal("DHX").toString());
userInfo.put("ZDYHZ", row.getDecimal("ZDYHZ").toString());
result.put("Info", userInfo);
} else {
result.put("result", "fail");
result.put("reason", "查询出错!");
}
} finally {
if (conn != null) {
conn.close();
}
}
return result;
}
String pID = params.getString("epid");
String sql = "select \n"
+ " (select count(*) from YH_YHXX where YHDJ='一般隐患' AND EPID='" + pID + "') as YBYH,\n"
+ " (select count(*) from YH_YHXX where YHDJ='重大隐患' AND EPID='" + pID + "') as ZDYH,\n"
+ " (select count(*) from YH_YHXX where YHDJ='一般隐患' AND EPID='" + pID + "' AND (ZGZT='未整改' OR ZGZT='退回整改')) as YBYH_ZGZ,\n"
+ " (select count(*) from YH_YHXX where YHDJ='重大隐患' AND (ZGZT='未整改' OR ZGZT='退回整改') AND EPID='" + pID + "') as ZDYH_ZGZ,\n"
+ " (select count(*) from YH_YHXX where YHDJ='一般隐患' AND YHZGQX < SYSDATE AND EPID='" + pID + "' AND (ZGZT='未整改' OR ZGZT='退回整改')) as YBYH_YQWZG,\n"
+ " (select count(*) from YH_YHXX where YHDJ='重大隐患' AND YHZGQX < SYSDATE AND EPID='" + pID + "' AND (ZGZT='未整改' OR ZGZT='退回整改')) as ZDYH_YQWZG,\n"
+ " (select count(*) from YH_YHXX where YHDJ='一般隐患' AND ZGZT='已整改' AND EPID='" + pID + "') as YBYH_YGZ,\n"
+ " (select count(*) from YH_YHXX where YHDJ='重大隐患' AND ZGZT='已整改' AND EPID='" + pID + "') as ZDYH_YGZ,\n"
+ " (select count(*) from YH_YHXX where ZGZT='未整改(审核中)' AND EPID='" + pID + "') as DHZYH,\n"
+ " (select count(*) from YH_YHXX where EPID='" + pID + "' AND (ZGZT='未整改' OR ZGZT='退回整改' )) as XYZG,\n"
+ " (select count(*) from YH_YHXX where ZGZT='已整改' AND HXZT='未核销' AND EPID='" + pID + "') as DHX,\n"
+ " (select count(*) from YH_YHXX where YHDJ='重大隐患' AND EPID='" + pID + "') as ZDYHZ\n"
+ " from dual";
System.out.println(sql);
JSONObject result = new JSONObject();
Connection conn = null;
try {
conn = context.getConnection("em");
Table table = DataUtils.queryData(conn, sql, null, null, null, null);
List<Row> ls_row = table.getRows();
if (ls_row.size() > 0) {
Row row = ls_row.get(0);
result.put("result", "success");
JSONObject userInfo = new JSONObject();
userInfo.put("YBYH", row.getDecimal("YBYH").toString());
userInfo.put("ZDYH", row.getDecimal("ZDYH").toString());
userInfo.put("YBYH_ZGZ", row.getDecimal("YBYH_ZGZ").toString());
userInfo.put("ZDYH_ZGZ", row.getDecimal("ZDYH_ZGZ").toString());
userInfo.put("YBYH_YQWZG", row.getDecimal("YBYH_YQWZG").toString());
userInfo.put("ZDYH_YQWZG", row.getDecimal("ZDYH_YQWZG").toString());
userInfo.put("YBYH_YGZ", row.getDecimal("YBYH_YGZ").toString());
userInfo.put("ZDYH_YGZ", row.getDecimal("ZDYH_YGZ").toString());
userInfo.put("DHZYH", row.getDecimal("DHZYH").toString());
userInfo.put("XYZG", row.getDecimal("XYZG").toString());
userInfo.put("DHX", row.getDecimal("DHX").toString());
userInfo.put("ZDYHZ", row.getDecimal("ZDYHZ").toString());
result.put("Info", userInfo);
} else {
result.put("result", "fail");
result.put("reason", "查询出错!");
}
} finally {
if (conn != null) {
conn.close();
}
}
return result;
}