Search in sources :

Example 1 with Kv

use of com.topcom.tjs.vo.Kv in project topcom-cloud by 545314690.

the class TjsEnforcementManagerImpl method countByZFPZ.

@Override
public List<Kv> countByZFPZ(String startDate, String endDate, String industryType, String province, String city) {
    String sql = "select JFJCLB as name,count(1) as  value  from t_enforcement t1 INNER JOIN tjs_special_company t2 on t1.companyId=t2.ID ";
    sql = connectSqlString(startDate, endDate, industryType, province, city, "", sql);
    String sql_acc = sql + " and t2.id IN (SELECT companyId from tjs_accident acc GROUP BY companyId)  group by JFJCLB";
    String sql_not = sql + "and t2.id NOT IN (SELECT companyId from tjs_accident acc GROUP BY companyId)  group by JFJCLB";
    List<KVPair> accList = jdbcTemplate.query(sql_acc, RowMappers.kvPairRowMapper());
    List<KVPair> notList = jdbcTemplate.query(sql_acc, RowMappers.kvPairRowMapper());
    List<Kv> result = new ArrayList();
    result.add(new Kv("事故企业", accList));
    result.add(new Kv("非事故企业", notList));
    return result;
}
Also used : KVPair(com.topcom.tjs.vo.KVPair) Kv(com.topcom.tjs.vo.Kv)

Example 2 with Kv

use of com.topcom.tjs.vo.Kv in project topcom-cloud by 545314690.

the class TjsEnforcementManagerImpl method countByJGZG.

@Override
public List<Kv> countByJGZG(String startDate, String endDate, String industryType, String province, String city) {
    String sql = "select sum(CCYBSGYHX) as 一般隐患 ," + "sum(CCZDSGYHX) as 重大隐患, " + "(sum(YZGYBSGYH)+ sum(YZGZDSGYH))*100/(sum(CCYBSGYHX)+sum(CCZDSGYHX)) as 整改率 " + "from t_enforcement t1 INNER JOIN tjs_special_company t2 on t1.companyId=t2.ID ";
    sql = connectSqlString(startDate, endDate, industryType, province, city, "", sql);
    String sql_acc = sql + " and t2.id IN (SELECT companyId from tjs_accident acc GROUP BY companyId) ";
    String sql_not = sql + "and t2.id NOT IN (SELECT companyId from tjs_accident acc GROUP BY companyId)";
    Map accMap = jdbcTemplate.queryForMap(sql_acc);
    Map notMap = jdbcTemplate.queryForMap(sql_not);
    List<Kv> result = new ArrayList();
    result.add(new Kv("事故企业", Kv.map2Kv(accMap)));
    result.add(new Kv("非事故企业", Kv.map2Kv(notMap)));
    return result;
}
Also used : Kv(com.topcom.tjs.vo.Kv)

Example 3 with Kv

use of com.topcom.tjs.vo.Kv in project topcom-cloud by 545314690.

the class TjsEnforcementManagerImpl method countByEnforcet.

@Override
public List<Kv> countByEnforcet(String startDate, String endDate, String industryType, String province, String city) {
    String[] keyArray = new String[] { "死亡人数", "事故起数", "执法次数", "违法行为" };
    // 执法行为  违法行为
    // 死亡人数  事故起数
    String sqlAcc = "select DATE_FORMAT(happenedTime, '%Y') as 年,DATE_FORMAT(happenedTime, '%m') as 月,sum(deathNumber) as 死亡人数,count(1) as 事故起数 " + "from tjs_accident as t1 INNER JOIN tjs_special_company as t2 " + "ON " + "t1.companyId = t2.ID ";
    boolean flag = false;
    if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate)) {
        sqlAcc += " WHERE happenedTime BETWEEN '" + startDate + "' AND '" + endDate + "' ";
        flag = true;
    }
    if (StringUtils.isNotBlank(industryType)) {
        if (flag) {
            sqlAcc += " AND ";
        } else {
            sqlAcc += " WHERE ";
            flag = true;
        }
        sqlAcc += " t2.industryType= '" + industryType + "'";
    }
    if (StringUtils.isNotBlank(province)) {
        if (flag) {
            sqlAcc += " AND ";
        } else {
            sqlAcc += " WHERE ";
            flag = true;
        }
        sqlAcc += " t2.province='" + province + "'";
    }
    if (StringUtils.isNotBlank(city)) {
        if (flag) {
            sqlAcc += " AND ";
        } else {
            sqlAcc += " WHERE ";
        }
        sqlAcc += " t2.city='" + city + "'";
    }
    sqlAcc = sqlAcc + "group by 年,月";
    // sqlAcc = connectSqlString(startDate, endDate, industryType, province, city, "", sqlAcc);
    List<JSONObject> acc = jdbcTemplate.query(sqlAcc, RowMappers.tjsAccidentDeathnumberByTime());
    String sqlEnforcet = "select DATE_FORMAT(ZFJCJZSJ, '%Y') as 年," + "DATE_FORMAT(ZFJCJZSJ, '%m') as 月," + "sum(CCAQSCWFWGXWX) as 违法行为," + "sum(CCYBSGYHX) as 一般隐患," + "sum(CCZDSGYHX) as 重大隐患," + "sum(ZFWF) as 执法次数 " + "from t_enforcement as t1 INNER JOIN tjs_special_company as t2 " + "ON " + "t1.companyId = t2.ID ";
    sqlEnforcet = connectSqlString(startDate, endDate, industryType, province, city, "", sqlEnforcet);
    sqlEnforcet = sqlEnforcet + "group by 年,月 ";
    List<JSONObject> enforcet = jdbcTemplate.query(sqlEnforcet, RowMappers.tjsZfyhByTime());
    List<KVPair> deathNumberKV = new ArrayList<>();
    List<KVPair> accNumber = new ArrayList<>();
    List<KVPair> zhifa = new ArrayList<>();
    List<KVPair> weifa = new ArrayList<>();
    List<KVPair> ybyh = new ArrayList<>();
    List<KVPair> zdyh = new ArrayList<>();
    for (int i = 0; i < acc.size(); i++) {
        JSONObject jsonObject = acc.get(i);
        String key = jsonObject.get("年") + "-" + jsonObject.get("月");
        deathNumberKV.add(new KVPair(key, jsonObject.get("死亡人数").toString()));
        accNumber.add(new KVPair(key, jsonObject.get("事故起数").toString()));
    }
    for (int i = 0; i < enforcet.size(); i++) {
        JSONObject jsonObject = enforcet.get(i);
        String key = jsonObject.get("年") + "-" + jsonObject.get("月");
        zhifa.add(new KVPair(key, jsonObject.get("违法行为").toString()));
        weifa.add(new KVPair(key, jsonObject.get("执法次数").toString()));
        ybyh.add(new KVPair(key, jsonObject.get("一般隐患").toString()));
        zdyh.add(new KVPair(key, jsonObject.get("重大隐患").toString()));
    }
    List<Kv> kvList = new ArrayList<>();
    kvList.add(new Kv("死亡人数", deathNumberKV));
    kvList.add(new Kv("事故起数", accNumber));
    kvList.add(new Kv("违法行为", zhifa));
    kvList.add(new Kv("执法次数", weifa));
    kvList.add(new Kv("一般隐患", ybyh));
    kvList.add(new Kv("重大隐患", zdyh));
    return kvList;
}
Also used : JSONObject(net.sf.json.JSONObject) KVPair(com.topcom.tjs.vo.KVPair) Kv(com.topcom.tjs.vo.Kv)

Aggregations

Kv (com.topcom.tjs.vo.Kv)3 KVPair (com.topcom.tjs.vo.KVPair)2 JSONObject (net.sf.json.JSONObject)1