dhz
2022-06-22 935b4b66b99b1f022f82cdaef8e3ef6599afbc72
工单统计
6个文件已修改
233 ■■■■■ 已修改文件
src/cn/ksource/web/facade/satis/SatisfactionFacadeImpl.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/cn/ksource/web/facade/tj/IncidentStatisFacadeImpl.java 63 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/cn/ksource/web/facade/tj/LocalStatisFacadeImpl.java 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/cn/ksource/web/facade/tj/QuestionStatisFacadeImpl.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/cn/ksource/web/facade/tj/SatisfactionStatisFacadeImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/cn/ksource/web/facade/ywStatis/YwStatisFacadeImpl.java 70 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/cn/ksource/web/facade/satis/SatisfactionFacadeImpl.java
@@ -831,7 +831,7 @@
        paramMap.put("beginMonth", beginMonth);
        paramMap.put("endMonth", endMonth);
        
        sql.append(" GROUP BY A.CUSTOMER_ID ");
        sql.append(" GROUP BY A.CUSTOMER_ID ,C.CUSTOMER_NAME ");
        
        List<Map> proList = baseDao.queryForList(sql.toString(),paramMap);
        
@@ -895,7 +895,11 @@
        
        builder.append(" SELECT D.SATIS_TYPE,D.ALL_COUNT,D.SATIS_COUNT,D.FG_RATE,D.SATIS_SCORE ");
        builder.append(" FROM TOTLE_SATIS_INFO I,TOTLE_SATIS_DETAIL D  ");
        builder.append(" where  I.ID = D.BUS_ID and I.MONTH = :month and I.CUSTOMER_ID = :cusId group by D.SATIS_TYPE ");
        builder.append(" where  I.ID = D.BUS_ID and I.MONTH = :month and I.CUSTOMER_ID = :cusId " +
                " GROUP BY  D.SATIS_TYPE ,D.ALL_COUNT,\n" +
                "        D.SATIS_COUNT,\n" +
                "        D.FG_RATE,\n" +
                "        D.SATIS_SCORE  ");
        List<Map> list = baseDao.queryForList(builder.toString(),params);
        if(list!=null&&list.size()>0){
            for(Map map:list){
@@ -932,7 +936,7 @@
        String cusId = params.get("cusId");
        StringBuilder builder = new StringBuilder();
        builder.append(" SELECT I.ALL_SCORE,D.SATIS_SCORE,D.SATIS_TYPE,I.MONTH FROM TOTLE_SATIS_DETAIL D ,TOTLE_SATIS_INFO I ");
        builder.append(" WHERE D.BUS_ID = I.ID AND I.CUSTOMER_ID = :cusId  GROUP BY D.SATIS_TYPE,I.MONTH  ORDER BY SATIS_TYPE,MONTH");
        builder.append(" WHERE D.BUS_ID = I.ID AND I.CUSTOMER_ID = :cusId  GROUP BY D.SATIS_TYPE,I.MONTH,I.ALL_SCORE,D.SATIS_SCORE  ORDER BY SATIS_TYPE,MONTH");
        List<Map> queryList = baseDao.queryForList(builder.toString(), params);
        builder.setLength(0);    
        Map<String,Object> queryMap = new HashMap<String,Object>();
@@ -1009,7 +1013,7 @@
        String cusId = params.get("cusId");
        StringBuilder builder = new StringBuilder();
        builder.append(" SELECT D.FG_RATE,D.SATIS_TYPE,I.MONTH FROM TOTLE_SATIS_DETAIL D ,TOTLE_SATIS_INFO I ");
        builder.append(" WHERE D.BUS_ID = I.ID AND I.CUSTOMER_ID = :cusId  GROUP BY D.SATIS_TYPE,I.MONTH  ORDER BY SATIS_TYPE,MONTH");
        builder.append(" WHERE D.BUS_ID = I.ID AND I.CUSTOMER_ID = :cusId  GROUP BY D.SATIS_TYPE,I.MONTH,D.FG_RATE,D.SATIS_TYPE  ORDER BY SATIS_TYPE,MONTH");
        List<Map> queryList = baseDao.queryForList(builder.toString(), params);
        builder.setLength(0);    
        Map<String,Object> queryMap = new HashMap<String,Object>();
src/cn/ksource/web/facade/tj/IncidentStatisFacadeImpl.java
@@ -461,12 +461,12 @@
        sql.append(" mlevel.level_num,manswer.answer_num,mdeal.deal_num,mresolve.resolve_num,mstate.state_num ");
        sql.append(" from "); 
        sql.append(" ( "); 
        sql.append("    select count(ID) total_num,DATE_FORMAT(HAPPEN_TIME,'%Y%m%d') mdate from SC_WORKFLOW_INCIDENT  ");
        sql.append("    select count(ID) total_num,substr(HAPPEN_TIME||'',1,8)  mdate from SC_WORKFLOW_INCIDENT  ");
        sql.append("    where  HAPPEN_TIME>=:beginTime and HAPPEN_TIME<=:endTime  "); 
        if(StringUtil.isNotBlank(cusId)){
            sql.append("and CUSTOMER_ID=:cusId  "); 
        }
        sql.append("    group by DATE_FORMAT(HAPPEN_TIME,'%Y%m%d')  ");
        sql.append("    group by substr(HAPPEN_TIME||'',1,8)  ");
        
        sql.append(" ) mtotal "); 
        //事件类型
@@ -528,12 +528,12 @@
            String column,String tempTableName,String flag,String cusId){
        sql.append(" left join  ");
        sql.append(" (  ");
        sql.append("  select mdate,GROUP_CONCAT(num order by ordernum asc) "+numName+" from ");
        sql.append("  select mdate,WM_CONCAT(num) "+numName+" from ");
        sql.append("  (    ");
        sql.append("      select count(i.ID)  num,mdate,datakey,ordernum from ");
        sql.append("      ( ");
        sql.append("          select DATAKEY,mdate,ordernum from ");
        sql.append("          (select DATE_FORMAT(HAPPEN_TIME,'%Y%m%d') mdate  from SC_WORKFLOW_INCIDENT group by mdate ) d,");
        sql.append("          (select substr(HAPPEN_TIME||'',1,8) mdate  from SC_WORKFLOW_INCIDENT group by substr(HAPPEN_TIME||'',1,8) ) d,");
        sql.append("          ( ");
        if(StringUtil.isNotBlank(categoryKey)){
            sql = getDicSql(sql,categoryKey);
@@ -552,9 +552,9 @@
        }else{
            sql = getStateSql(sql,cusId);
        }
        sql.append(" i on i."+column+" = b.DATAKEY and DATE_FORMAT(i.HAPPEN_TIME,'%Y%m%d')=b.mdate ");
        sql.append("     group by b.mdate,b.datakey order by ordernum");
        sql.append(" ) t group by mdate ");
        sql.append(" i on i."+column+" = b.DATAKEY and substr(HAPPEN_TIME||'',1,8)=b.mdate ");
        sql.append("     group by b.mdate,b.datakey,b.ordernum order by b.ordernum");
        sql.append(" ) t group by t.mdate ");
        sql.append(" ) "+tempTableName);
        sql.append(" on "+tempTableName+".mdate = mtotal.mdate ");
        return sql;
@@ -711,7 +711,7 @@
        StringBuilder builder4 = new StringBuilder(sql);
        
        
        String endSql = " GROUP BY THIRD_CATEGORY_ID ";
        String endSql = " GROUP BY THIRD_CATEGORY_ID,THIRD_CATEGORY_NAME,SECOND_CATEGORY_NAME,FIRST_CATEGORY_NAME ";
        
        builder1.append(endSql);
        
@@ -937,7 +937,9 @@
        
        StringBuilder builder = new StringBuilder();
        builder.append(" select mtotal.THIRD_CATEGORY_ID,mtotal.THIRD_CATEGORY_NAME,mtotal.FIRST_CATEGORY_NAME,mtotal.SECOND_CATEGORY_NAME,total_num,IFNULL(close_num,0) close_num from  ");
        builder.append(" (select THIRD_CATEGORY_NAME,SECOND_CATEGORY_NAME,FIRST_CATEGORY_NAME,count(id) total_num,THIRD_CATEGORY_ID from SC_WORKFLOW_INCIDENT where CUSTOMER_ID=:cusId and CREATE_TIME>=:beginDay and CREATE_TIME<=:endDay  group by THIRD_CATEGORY_ID) mtotal left join  ");
        builder.append(" (select THIRD_CATEGORY_NAME,SECOND_CATEGORY_NAME,FIRST_CATEGORY_NAME,count(id) total_num,THIRD_CATEGORY_ID from SC_WORKFLOW_INCIDENT where CUSTOMER_ID=:cusId and CREATE_TIME>=:beginDay and CREATE_TIME<=:endDay  group by THIRD_CATEGORY_ID,THIRD_CATEGORY_NAME,\n" +
                "        SECOND_CATEGORY_NAME,\n" +
                "        FIRST_CATEGORY_NAME) mtotal left join  ");
        builder.append(" (select count(i.id) close_num,THIRD_CATEGORY_ID from SC_WORKFLOW_INCIDENT i,workflow_base b where i.FLOW_ID=b.ID and b.WFSTATE=3 and i.CUSTOMER_ID=:cusId and i.CREATE_TIME>=:beginDay and i.CREATE_TIME<=:endDay group by i.THIRD_CATEGORY_ID) mclose  ");
        builder.append(" on  mtotal.THIRD_CATEGORY_ID = mclose.THIRD_CATEGORY_ID ");
        List<Map> baseList = baseDao.queryForList(builder.toString(),paramMap);
@@ -1017,15 +1019,15 @@
        
        StringBuilder builder = new StringBuilder();
        builder.append(" select mtotal.THIRD_CATEGORY_ID,mtotal.THIRD_CATEGORY_NAME,mtotal.FIRST_CATEGORY_NAME,mtotal.SECOND_CATEGORY_NAME,total_num from  ");
        builder.append(" (select THIRD_CATEGORY_NAME,SECOND_CATEGORY_NAME,FIRST_CATEGORY_NAME,count(id) total_num,THIRD_CATEGORY_ID from SC_WORKFLOW_INCIDENT where state!=10 and  CUSTOMER_ID=:cusId and CREATE_TIME>=:beginDay and CREATE_TIME<=:endDay  group by THIRD_CATEGORY_ID) mtotal   ");
        builder.append(" (select THIRD_CATEGORY_NAME,SECOND_CATEGORY_NAME,FIRST_CATEGORY_NAME,count(id) total_num,THIRD_CATEGORY_ID from SC_WORKFLOW_INCIDENT where state!=10 and  CUSTOMER_ID=:cusId and CREATE_TIME>=:beginDay and CREATE_TIME<=:endDay  group by THIRD_CATEGORY_ID,THIRD_CATEGORY_NAME,SECOND_CATEGORY_NAME,FIRST_CATEGORY_NAME) mtotal   ");
        List<Map> baseList = baseDao.queryForList(builder.toString(),paramMap);
        
        //查询数据字典
        List<Map> typeList = dataDictionaryService.getDataDictionaryByCategoryKey("INCIDENT_TYPE");
        //查询解决方式,关闭原因
        builder.setLength(0);
        builder.append(" select count(id) m_num,CONCAT(THIRD_CATEGORY_ID,'_',TYPE_ID) m_key,THIRD_CATEGORY_NAME,THIRD_CATEGORY_ID from SC_WORKFLOW_INCIDENT   ");
        builder.append(" where CUSTOMER_ID=:cusId and state!=10 and CREATE_TIME>=:beginDay and CREATE_TIME<=:endDay  group by TYPE_ID,THIRD_CATEGORY_ID   ");
        builder.append(" select count(id) m_num,CONCAT(THIRD_CATEGORY_ID,'_',TYPE_ID) m_key,THIRD_CATEGORY_NAME,THIRD_CATEGORY_ID,TYPE_ID from SC_WORKFLOW_INCIDENT   ");
        builder.append(" where CUSTOMER_ID=:cusId and state!=10 and CREATE_TIME>=:beginDay and CREATE_TIME<=:endDay  group by TYPE_ID,THIRD_CATEGORY_ID,CONCAT(THIRD_CATEGORY_ID,'_',TYPE_ID),THIRD_CATEGORY_NAME   ");
        List<Map> extendList = baseDao.queryForList(builder.toString(),paramMap);
        if(extendList!=null&&extendList.size()>0){
            for(Map extend : extendList){
@@ -1075,8 +1077,8 @@
        
        StringBuilder builder = new StringBuilder();
        builder.append(" select mtotal.THIRD_CATEGORY_NAME,mtotal.FIRST_CATEGORY_NAME,mtotal.SECOND_CATEGORY_NAME,total_num,IFNULL(finish_num,0) finish_num,truncate(ifnull(avg_time,0)*3600*1000,0) avg_time,truncate(ifnull(sum_time,0)*3600*1000,0) sum_time from  ");
        builder.append(" (select AVG(a.DEAL_USE_TIME) avg_time,sum(a.DEAL_USE_TIME) sum_time,b.CATEGORY_NAME THIRD_CATEGORY_NAME,a.SECOND_CATEGORY_NAME,a.FIRST_CATEGORY_NAME,count(a.id) total_num,a.THIRD_CATEGORY_ID from SC_WORKFLOW_INCIDENT a,SC_SERVCE_CATEGORY b where a.state!=10 and  a.CUSTOMER_ID=:cusId and a.CREATE_TIME>=:beginDay and a.CREATE_TIME<=:endDay and a.THIRD_CATEGORY_ID=b.id  group by a.THIRD_CATEGORY_ID) mtotal left join  ");
        builder.append(" (select THIRD_CATEGORY_NAME,count(i.id) finish_num,THIRD_CATEGORY_ID from SC_WORKFLOW_INCIDENT i,workflow_base b where i.FLOW_ID=b.ID and (b.WFSTATE=2 or b.WFSTATE=4)  and i.CUSTOMER_ID=:cusId and i.CREATE_TIME>=:beginDay and i.CREATE_TIME<=:endDay group by i.THIRD_CATEGORY_ID) mfinish  ");
        builder.append(" (select AVG(a.DEAL_USE_TIME) avg_time,sum(a.DEAL_USE_TIME) sum_time,b.CATEGORY_NAME THIRD_CATEGORY_NAME,a.SECOND_CATEGORY_NAME,a.FIRST_CATEGORY_NAME,count(a.id) total_num,a.THIRD_CATEGORY_ID from SC_WORKFLOW_INCIDENT a,SC_SERVCE_CATEGORY b where a.state!=10 and  a.CUSTOMER_ID=:cusId and a.CREATE_TIME>=:beginDay and a.CREATE_TIME<=:endDay and a.THIRD_CATEGORY_ID=b.id  group by a.THIRD_CATEGORY_ID,b.CATEGORY_NAME ,a.SECOND_CATEGORY_NAME,a.FIRST_CATEGORY_NAME) mtotal left join  ");
        builder.append(" (select THIRD_CATEGORY_NAME,count(i.id) finish_num,THIRD_CATEGORY_ID from SC_WORKFLOW_INCIDENT i,workflow_base b where i.FLOW_ID=b.ID and (b.WFSTATE=2 or b.WFSTATE=4)  and i.CUSTOMER_ID=:cusId and i.CREATE_TIME>=:beginDay and i.CREATE_TIME<=:endDay group by i.THIRD_CATEGORY_ID,i.THIRD_CATEGORY_NAME) mfinish  ");
        builder.append(" on  mtotal.THIRD_CATEGORY_ID = mfinish.THIRD_CATEGORY_ID ");
        List<Map> baseList = baseDao.queryForList(builder.toString(),paramMap);
        
@@ -1121,7 +1123,7 @@
        StringBuilder builder = new StringBuilder();
        builder.append(" select mtotal.THIRD_CATEGORY_NAME,mtotal.FIRST_CATEGORY_NAME,mtotal.SECOND_CATEGORY_NAME,total_num,IFNULL(answer_num,0) answer_num,IFNULL(activi_num,0) activi_num,IFNULL(finish_num,0) finish_num,IFNULL(timeout_num,0) timeout_num,  ");
        builder.append(" IFNULL(pri_num,0) pri_num,IFNULL(ques_num,0) ques_num,IFNULL(avg_time,0) avg_time,truncate(IFNULL(first_num, 0)*100/total_num,2) first_rate,truncate((IFNULL(total_num,0)-IFNULL(timeout_num,0))*100/IFNULL(total_num,0),2) ontime_rate  from  ");
        builder.append(" (select THIRD_CATEGORY_NAME,SECOND_CATEGORY_NAME,FIRST_CATEGORY_NAME,count(id) total_num,THIRD_CATEGORY_ID from SC_WORKFLOW_INCIDENT where state!=10 and CUSTOMER_ID=:cusId and CREATE_TIME>=:beginDay and CREATE_TIME<=:endDay  group by THIRD_CATEGORY_ID) mtotal   ");
        builder.append(" (select THIRD_CATEGORY_NAME,SECOND_CATEGORY_NAME,FIRST_CATEGORY_NAME,count(id) total_num,THIRD_CATEGORY_ID from SC_WORKFLOW_INCIDENT where state!=10 and CUSTOMER_ID=:cusId and CREATE_TIME>=:beginDay and CREATE_TIME<=:endDay  group by THIRD_CATEGORY_ID,THIRD_CATEGORY_NAME,SECOND_CATEGORY_NAME,FIRST_CATEGORY_NAME) mtotal   ");
        builder.append(" left join (select count(i.id) answer_num,THIRD_CATEGORY_ID from SC_WORKFLOW_INCIDENT i,workflow_base b,workflow_node n where i.FLOW_ID=b.ID and b.CURRENT_NODE_ID=n.ID and n.FLOWSTATE=1 and i.CUSTOMER_ID=:cusId and i.CREATE_TIME>=:beginDay and i.CREATE_TIME<=:endDay group by i.THIRD_CATEGORY_ID) manswer  ");
        builder.append(" on  mtotal.THIRD_CATEGORY_ID = manswer.THIRD_CATEGORY_ID ");
        builder.append(" left join (select count(i.id) activi_num,THIRD_CATEGORY_ID from SC_WORKFLOW_INCIDENT i,workflow_base b where i.FLOW_ID=b.ID and b.WFSTATE=1 and i.CUSTOMER_ID=:cusId and i.CREATE_TIME>=:beginDay and i.CREATE_TIME<=:endDay group by i.THIRD_CATEGORY_ID) mactivi  ");
@@ -1453,9 +1455,9 @@
     */
    private void getDateWhereSql(String frequency,StringBuilder sql,String colName){
        if(frequency.equals("day")||frequency==null){
            sql.append(" and date_format("+colName+",'%Y%m%d')>=:startDate and date_format("+colName+",'%Y%m%d')<=:endDate  ");
            sql.append(" and substr("+colName+"||'',1,8)>=:startDate and substr("+colName+"||'',1,8)<=:endDate  ");
        }else if(frequency.equals("month")){
            sql.append(" and date_format("+colName+",'%Y%m')>=:startDate and date_format("+colName+",'%Y%m')<=:endDate  ");
            sql.append(" and substr("+colName+"||'',1,6)>=:startDate and substr("+colName+"||'',1,6)<=:endDate  ");
        }
    }
@@ -1585,7 +1587,7 @@
            .addValue("endDate", endDate);
        
        StringBuilder sql = new StringBuilder();
        sql.append(" select id as 'key',level_name as val from sc_sla where state=1 order by serial asc");
        sql.append(" select id as key,level_name as val from sc_sla where state=1 order by serial asc");
        List<Map> categoryList = baseDao.queryForList(sql.toString(),param); 
        
        sql.setLength(0);
@@ -1667,13 +1669,13 @@
            .addValue("startDate", startDate)
            .addValue("endDate", endDate);
        StringBuilder sql = new StringBuilder();
        sql.append(" select hour(happen_time) mhour,count(id) num from sc_workflow_incident c");
        sql.append(" where c.state!=10 and hour(happen_time)>=7  and hour(happen_time)<=18   ");
        sql.append(" select to_number(substr(happen_time||'',9,2)) mhour,count(id) num from sc_workflow_incident c");
        sql.append(" where c.state!=10 and to_number(substr(happen_time||'',9,2))>=7  and to_number(substr(happen_time||'',9,2))<=18   ");
        if(StringUtil.isNotBlank(cusId)){
            sql.append(" and customer_id = :cusId ");
        }
        getDateWhereSql(frequency,sql,"create_time");
        sql.append(" group by mhour ");
        sql.append(" group by to_number(substr(happen_time||'',9,2)) ");
        
        List<Map> list = baseDao.queryForList(sql.toString(),param);
        Map categoriesMap = new HashMap();
@@ -1744,10 +1746,10 @@
                "( SELECT sum(SCORE) score,count(b.id) num,RESOLVE_USER_ID FROM order_satis_info a," +
                "workflow_base b,sc_workflow_incident c WHERE a.BUSINESS_ID = b.id ";
        if(StringUtil.notEmpty(ConvertUtil.obj2Str(param.get("beginDay")))){
            sql+=" and date_format(c.create_time,'%Y%m%d')>=:beginDay ";
            sql+=" and to_number(substr(c.create_time||'',1,8))>=:beginDay ";
        }
        if(StringUtil.notEmpty(ConvertUtil.obj2Str(param.get("endDay")))){
            sql+=" and date_format(c.create_time,'%Y%m%d')<=:endDay ";
            sql+=" and to_number(substr(c.create_time||'',1,8))<=:endDay ";
        }
        if(StringUtil.notEmpty(ConvertUtil.obj2Str(param.get("cusId")))){
            sql+=" and c.CUSTOMER_ID=:cusId ";
@@ -1759,10 +1761,10 @@
                "c.CURRENT_DEALER_ID from sc_workflow_incident a,workflow_base b,workflow_node c" +
                " where a.id=b.BUSINESS_ID and b.id=c.FLOWID ";
        if(StringUtil.notEmpty(ConvertUtil.obj2Str(param.get("beginDay")))){
            sql+=" and date_format(a.create_time,'%Y%m%d')>=:beginDay ";
            sql+=" and to_number(substr(a.create_time||'',1,8))>=:beginDay ";
        }
        if(StringUtil.notEmpty(ConvertUtil.obj2Str(param.get("endDay")))){
            sql+=" and date_format(a.create_time,'%Y%m%d')<=:endDay ";
            sql+=" and to_number(substr(a.create_time||'',1,8))<=:endDay ";
        }
        if(StringUtil.notEmpty(ConvertUtil.obj2Str(param.get("cusId")))){
            sql+=" and a.CUSTOMER_ID=:cusId ";
@@ -1773,10 +1775,11 @@
                " LEFT JOIN " ;
        sql+=" (SELECT count(*) num,RESOLVE_USER_ID from sc_workflow_incident WHERE 1=1 ";
        if(StringUtil.notEmpty(ConvertUtil.obj2Str(param.get("beginDay")))){
            sql+=" and date_format(create_time,'%Y%m%d')>=:beginDay ";
            sql+=" and to_number(substr(create_time||'',1,8))>=:beginDay ";
        }
        if(StringUtil.notEmpty(ConvertUtil.obj2Str(param.get("endDay")))){
            sql+=" and date_format(create_time,'%Y%m%d')<=:endDay ";
            sql+=" and to_number(substr(create_time||'',1,8))<=:endDay ";
        }
        if(StringUtil.notEmpty(ConvertUtil.obj2Str(param.get("cusId")))){
            sql+=" and CUSTOMER_ID=:cusId ";
@@ -1800,15 +1803,15 @@
            sql="SELECT RESOLVE_USER_ID,SLA_ID,COUNT(a.id) num from sc_workflow_incident a," +
                    "workflow_base b where a.id=b.BUSINESS_ID and b.WFSTATE in(2,4) ";
            if(StringUtil.notEmpty(ConvertUtil.obj2Str(param.get("beginDay")))){
                sql+=" and date_format(a.create_time,'%Y%m%d')>=:beginDay ";
                sql+=" and to_number(substr(a.create_time||'',1,8))>=:beginDay ";
            }
            if(StringUtil.notEmpty(ConvertUtil.obj2Str(param.get("endDay")))){
                sql+=" and date_format(a.create_time,'%Y%m%d')<=:endDay ";
                sql+=" and to_number(substr(a.create_time||'',1,8))<=:endDay ";
            }
            if(StringUtil.notEmpty(ConvertUtil.obj2Str(param.get("cusId")))){
                sql+=" and a.CUSTOMER_ID=:cusId ";
            }
            sql+=" GROUP BY RESOLVE_USER_ID,SLA_ID order by SLA_NAME";
            sql+=" GROUP BY RESOLVE_USER_ID,SLA_ID,SLA_NAME order by SLA_NAME";
            List<Map> lvList=baseDao.queryForList(sql, param);
            if(lvList.size()>0){
                for(Map mapa:userList){
src/cn/ksource/web/facade/tj/LocalStatisFacadeImpl.java
@@ -254,9 +254,9 @@
        Map paramMap = new HashMap();
        StringBuilder builder = new StringBuilder("");
        if(type.equals("2")) {
            builder = builder.append("SELECT $KEY COLKEY,COUNT(C.TYPE_ID) AS NUM,DATE_FORMAT(C.CREATE_TIME,'%Y-%m-%d') AS DC_TIME  FROM SC_WORKFLOW_INCIDENT_LOCAL C WHERE 1=1 ");
            builder = builder.append("SELECT $KEY COLKEY,COUNT(C.TYPE_ID) AS NUM,to_char(C.CREATE_TIME,'yyyy-MM-dd') AS DC_TIME  FROM SC_WORKFLOW_INCIDENT_LOCAL C WHERE 1=1 ");
        } else {
            builder = builder.append("SELECT $KEY COLKEY,COUNT(C.TYPE_ID) AS NUM,DATE_FORMAT(C.CREATE_TIME,'%Y-%m') AS DC_TIME FROM SC_WORKFLOW_INCIDENT_LOCAL C WHERE 1=1 ");
            builder = builder.append("SELECT $KEY COLKEY,COUNT(C.TYPE_ID) AS NUM,to_char(C.CREATE_TIME,'yyyy-MM') AS DC_TIME FROM SC_WORKFLOW_INCIDENT_LOCAL C WHERE 1=1 ");
        }
        if(!queryType.equals("3")){
            builder.append(" and state!=5 ");
@@ -278,7 +278,12 @@
            }
        }
        builder.append(" and $KEY is not null ");
        builder.append(" GROUP BY $KEY,DC_TIME ");
        if(type.equals("2")) {
            builder.append(" GROUP BY $KEY,to_char(C.CREATE_TIME,'yyyy-MM-dd') ");
        }else{
            builder.append(" GROUP BY $KEY,to_char(C.CREATE_TIME,'yyyy-MM') ");
        }
        String sql = builder.toString().replace("$KEY", queryMap.get("col").toString());
        return baseDao.queryForList(sql,paramMap);
    }
@@ -291,13 +296,14 @@
        
        StringBuilder sql = new StringBuilder();
        Map paramMap = new HashMap();
        sql.append(" SELECT HOUR(HAPPEN_TIME)  MHOUR,count(ID) NUM FROM SC_WORKFLOW_INCIDENT_LOCAL C");
        sql.append(" where  c.state!=5 and DATE_FORMAT(HAPPEN_TIME,'%Y%m%d')=:selDay and HOUR(HAPPEN_TIME)>=7  and HOUR(HAPPEN_TIME)<=18   ");
        sql.append(" SELECT to_number(substr(HAPPEN_TIME||'',9,2))  MHOUR,count(ID) NUM FROM SC_WORKFLOW_INCIDENT_LOCAL C");
        sql.append(" where  c.state!=5 and to_number(substr(HAPPEN_TIME||'',1,8))=:selDay and to_number(substr(HAPPEN_TIME||'',9,2))>=7  and to_number(substr(HAPPEN_TIME||'',9,2))<=18   ");
        if(StringUtil.notEmpty(cusId) ) {
            sql.append(" AND CUSTOMER_ID = :cusId ");
            paramMap.put("cusId", cusId);
        }
        sql.append(" GROUP BY MHOUR ");
        sql.append(" GROUP BY to_number(substr(HAPPEN_TIME||'',9,2)) ");
        
        paramMap.put("selDay", selDay);
        List<Map> list = baseDao.queryForList(sql.toString(),paramMap);
@@ -387,12 +393,12 @@
        sql.append(" mlevel.level_num,manswer.answer_num,mdeal.deal_num,mresolve.resolve_num,mstate.state_num ");
        sql.append(" from "); 
        sql.append(" ( "); 
        sql.append("    select count(ID) total_num,DATE_FORMAT(HAPPEN_TIME,'%Y%m%d') mdate from SC_WORKFLOW_INCIDENT_LOCAL  ");
        sql.append("    select count(ID) total_num,substr(HAPPEN_TIME||'',1,8) mdate from SC_WORKFLOW_INCIDENT_LOCAL  ");
        sql.append("    where  HAPPEN_TIME>=:beginTime and HAPPEN_TIME<=:endTime  "); 
        if(StringUtil.isNotBlank(cusId)){
            sql.append("and CUSTOMER_ID=:cusId  "); 
        }
        sql.append("    group by DATE_FORMAT(HAPPEN_TIME,'%Y%m%d')  ");
        sql.append("    group by substr(HAPPEN_TIME||'',1,8)  ");
        
        sql.append(" ) mtotal "); 
        //事件类型
@@ -454,12 +460,12 @@
            String column,String tempTableName,String flag,String cusId){
        sql.append(" left join  ");
        sql.append(" (  ");
        sql.append("  select mdate,GROUP_CONCAT(num order by ordernum asc) "+numName+" from ");
        sql.append("  select mdate,WM_CONCAT(num) "+numName+" from ");
        sql.append("  (    ");
        sql.append("      select count(i.ID)  num,mdate,datakey,ordernum from ");
        sql.append("      ( ");
        sql.append("          select DATAKEY,mdate,ordernum from ");
        sql.append("          (select DATE_FORMAT(HAPPEN_TIME,'%Y%m%d') mdate  from SC_WORKFLOW_INCIDENT_LOCAL group by mdate ) d,");
        sql.append("          (select substr(HAPPEN_TIME||'',1,8) mdate  from SC_WORKFLOW_INCIDENT_LOCAL group by substr(HAPPEN_TIME||'',1,8) ) d,");
        sql.append("          ( ");
        if(StringUtil.isNotBlank(categoryKey)){
            sql = getDicSql(sql,categoryKey);
@@ -478,8 +484,8 @@
        }else{
            sql = getStateSql(sql,cusId);
        }
        sql.append(" i on i."+column+" = b.DATAKEY and DATE_FORMAT(i.HAPPEN_TIME,'%Y%m%d')=b.mdate ");
        sql.append("     group by b.mdate,b.datakey  ");
        sql.append(" i on i."+column+" = b.DATAKEY and substr(HAPPEN_TIME||'',1,8)=b.mdate ");
        sql.append("     group by b.mdate,b.datakey,b.ordernum  ");
        sql.append(" ) t group by mdate ");
        sql.append(" ) "+tempTableName);
        sql.append(" on "+tempTableName+".mdate = mtotal.mdate ");
@@ -937,7 +943,7 @@
        StringBuilder builder4 = new StringBuilder(sql);
        
        
        String endSql = " GROUP BY THIRD_CATEGORY_ID ";
        String endSql = " GROUP BY THIRD_CATEGORY_ID,THIRD_CATEGORY_NAME,SECOND_CATEGORY_NAME,FIRST_CATEGORY_NAME ";
        
        builder1.append(endSql);
        
@@ -1043,7 +1049,7 @@
        
        StringBuilder builder = new StringBuilder();
        builder.append(" select mtotal.THIRD_CATEGORY_ID,mtotal.THIRD_CATEGORY_NAME,mtotal.SECOND_CATEGORY_NAME,mtotal.FIRST_CATEGORY_NAME,total_num,IFNULL(close_num,0) close_num from  ");
        builder.append(" (select THIRD_CATEGORY_NAME,SECOND_CATEGORY_NAME,FIRST_CATEGORY_NAME,count(id) total_num,THIRD_CATEGORY_ID from SC_WORKFLOW_INCIDENT_LOCAL where CUSTOMER_ID=:cusId and CREATE_TIME>=:beginDay and CREATE_TIME<=:endDay  group by THIRD_CATEGORY_ID) mtotal left join  ");
        builder.append(" (select THIRD_CATEGORY_NAME,SECOND_CATEGORY_NAME,FIRST_CATEGORY_NAME,count(id) total_num,THIRD_CATEGORY_ID from SC_WORKFLOW_INCIDENT_LOCAL where CUSTOMER_ID=:cusId and CREATE_TIME>=:beginDay and CREATE_TIME<=:endDay  group by THIRD_CATEGORY_ID,THIRD_CATEGORY_NAME,SECOND_CATEGORY_NAME,FIRST_CATEGORY_NAME) mtotal left join  ");
        builder.append(" (select count(i.id) close_num,THIRD_CATEGORY_ID from SC_WORKFLOW_INCIDENT_LOCAL i,workflow_base b where i.FLOW_ID=b.ID and b.WFSTATE=3 and i.CUSTOMER_ID=:cusId and i.CREATE_TIME>=:beginDay and i.CREATE_TIME<=:endDay group by i.THIRD_CATEGORY_ID) mclose  ");
        builder.append(" on  mtotal.THIRD_CATEGORY_ID = mclose.THIRD_CATEGORY_ID ");
        List<Map> baseList = baseDao.queryForList(builder.toString(),paramMap);
@@ -1122,15 +1128,15 @@
        
        StringBuilder builder = new StringBuilder();
        builder.append(" select mtotal.THIRD_CATEGORY_ID,mtotal.THIRD_CATEGORY_NAME,mtotal.SECOND_CATEGORY_NAME,mtotal.FIRST_CATEGORY_NAME,total_num from  ");
        builder.append(" (select THIRD_CATEGORY_NAME,FIRST_CATEGORY_NAME,SECOND_CATEGORY_NAME,count(id) total_num,THIRD_CATEGORY_ID from SC_WORKFLOW_INCIDENT_LOCAL where state!=10 and  CUSTOMER_ID=:cusId and CREATE_TIME>=:beginDay and CREATE_TIME<=:endDay  group by THIRD_CATEGORY_ID) mtotal   ");
        builder.append(" (select THIRD_CATEGORY_NAME,FIRST_CATEGORY_NAME,SECOND_CATEGORY_NAME,count(id) total_num,THIRD_CATEGORY_ID from SC_WORKFLOW_INCIDENT_LOCAL where state!=10 and  CUSTOMER_ID=:cusId and CREATE_TIME>=:beginDay and CREATE_TIME<=:endDay  group by THIRD_CATEGORY_ID,THIRD_CATEGORY_NAME,FIRST_CATEGORY_NAME,SECOND_CATEGORY_NAME) mtotal   ");
        List<Map> baseList = baseDao.queryForList(builder.toString(),paramMap);
        
        //查询数据字典
        List<Map> typeList = dataDictionaryService.getDataDictionaryByCategoryKey("INCIDENT_TYPE");
        //查询解决方式,关闭原因
        builder.setLength(0);
        builder.append(" select count(id) m_num,CONCAT(THIRD_CATEGORY_ID,'_',TYPE_ID) m_key,THIRD_CATEGORY_NAME,THIRD_CATEGORY_ID from SC_WORKFLOW_INCIDENT_LOCAL   ");
        builder.append(" where CUSTOMER_ID=:cusId and state!=10 and CREATE_TIME>=:beginDay and CREATE_TIME<=:endDay  group by TYPE_ID,THIRD_CATEGORY_ID   ");
        builder.append(" select count(id) m_num,CONCAT(THIRD_CATEGORY_ID,'_',TYPE_ID) m_key,THIRD_CATEGORY_NAME,THIRD_CATEGORY_ID,TYPE_ID from SC_WORKFLOW_INCIDENT_LOCAL   ");
        builder.append(" where CUSTOMER_ID=:cusId and state!=10 and CREATE_TIME>=:beginDay and CREATE_TIME<=:endDay  group by TYPE_ID,THIRD_CATEGORY_ID,CONCAT(THIRD_CATEGORY_ID,'_',TYPE_ID),THIRD_CATEGORY_NAME   ");
        List<Map> extendList = baseDao.queryForList(builder.toString(),paramMap);
        if(extendList!=null&&extendList.size()>0){
            for(Map extend : extendList){
@@ -1179,8 +1185,8 @@
        
        StringBuilder builder = new StringBuilder();
        builder.append(" select mtotal.THIRD_CATEGORY_NAME,mtotal.SECOND_CATEGORY_NAME,mtotal.FIRST_CATEGORY_NAME,total_num,IFNULL(finish_num,0) finish_num,truncate(ifnull(avg_time,0)*3600*1000,0) avg_time,truncate(ifnull(sum_time,0)*3600*1000,0) sum_time from  ");
        builder.append(" (select AVG(a.DEAL_USE_TIME) avg_time,sum(a.DEAL_USE_TIME) sum_time,b.CATEGORY_NAME THIRD_CATEGORY_NAME,SECOND_CATEGORY_NAME,FIRST_CATEGORY_NAME,count(a.id) total_num,a.THIRD_CATEGORY_ID from SC_WORKFLOW_INCIDENT_LOCAL a,SC_SERVCE_CATEGORY b where a.state!=10 and  a.CUSTOMER_ID=:cusId and a.CREATE_TIME>=:beginDay and a.CREATE_TIME<=:endDay and a.THIRD_CATEGORY_ID=b.id  group by a.THIRD_CATEGORY_ID) mtotal left join  ");
        builder.append(" (select THIRD_CATEGORY_NAME,count(i.id) finish_num,THIRD_CATEGORY_ID from SC_WORKFLOW_INCIDENT_LOCAL i,workflow_base b where i.FLOW_ID=b.ID and (b.WFSTATE=2 or b.WFSTATE=4)  and i.CUSTOMER_ID=:cusId and i.CREATE_TIME>=:beginDay and i.CREATE_TIME<=:endDay group by i.THIRD_CATEGORY_ID) mfinish  ");
        builder.append(" (select AVG(a.DEAL_USE_TIME) avg_time,sum(a.DEAL_USE_TIME) sum_time,b.CATEGORY_NAME THIRD_CATEGORY_NAME,SECOND_CATEGORY_NAME,FIRST_CATEGORY_NAME,count(a.id) total_num,a.THIRD_CATEGORY_ID from SC_WORKFLOW_INCIDENT_LOCAL a,SC_SERVCE_CATEGORY b where a.state!=10 and  a.CUSTOMER_ID=:cusId and a.CREATE_TIME>=:beginDay and a.CREATE_TIME<=:endDay and a.THIRD_CATEGORY_ID=b.id  group by a.THIRD_CATEGORY_ID,b.CATEGORY_NAME,SECOND_CATEGORY_NAME,FIRST_CATEGORY_NAME) mtotal left join  ");
        builder.append(" (select THIRD_CATEGORY_NAME,count(i.id) finish_num,THIRD_CATEGORY_ID from SC_WORKFLOW_INCIDENT_LOCAL i,workflow_base b where i.FLOW_ID=b.ID and (b.WFSTATE=2 or b.WFSTATE=4)  and i.CUSTOMER_ID=:cusId and i.CREATE_TIME>=:beginDay and i.CREATE_TIME<=:endDay group by i.THIRD_CATEGORY_ID,THIRD_CATEGORY_NAME) mfinish  ");
        builder.append(" on  mtotal.THIRD_CATEGORY_ID = mfinish.THIRD_CATEGORY_ID ");
        List<Map> baseList = baseDao.queryForList(builder.toString(),paramMap);
        
@@ -1224,7 +1230,7 @@
        StringBuilder builder = new StringBuilder();
        builder.append(" select mtotal.THIRD_CATEGORY_NAME,mtotal.SECOND_CATEGORY_NAME,mtotal.FIRST_CATEGORY_NAME,total_num,IFNULL(answer_num,0) answer_num,IFNULL(activi_num,0) activi_num,IFNULL(finish_num,0) finish_num,IFNULL(timeout_num,0) timeout_num,  ");
        builder.append(" IFNULL(pri_num,0) pri_num,IFNULL(ques_num,0) ques_num,IFNULL(avg_time,0) avg_time,truncate(IFNULL(first_num, 0)*100/total_num,2) first_rate,truncate((IFNULL(total_num,0)-IFNULL(timeout_num,0))*100/IFNULL(total_num,0),2) ontime_rate  from  ");
        builder.append(" (select THIRD_CATEGORY_NAME,SECOND_CATEGORY_NAME,FIRST_CATEGORY_NAME,count(id) total_num,THIRD_CATEGORY_ID from SC_WORKFLOW_INCIDENT_LOCAL where state!=10 and CUSTOMER_ID=:cusId and CREATE_TIME>=:beginDay and CREATE_TIME<=:endDay  group by THIRD_CATEGORY_ID) mtotal   ");
        builder.append(" (select THIRD_CATEGORY_NAME,SECOND_CATEGORY_NAME,FIRST_CATEGORY_NAME,count(id) total_num,THIRD_CATEGORY_ID from SC_WORKFLOW_INCIDENT_LOCAL where state!=10 and CUSTOMER_ID=:cusId and CREATE_TIME>=:beginDay and CREATE_TIME<=:endDay  group by THIRD_CATEGORY_ID,THIRD_CATEGORY_NAME,SECOND_CATEGORY_NAME,FIRST_CATEGORY_NAME) mtotal   ");
        builder.append(" left join (select count(i.id) answer_num,THIRD_CATEGORY_ID from SC_WORKFLOW_INCIDENT_LOCAL i,workflow_base b,workflow_node n where i.FLOW_ID=b.ID and b.CURRENT_NODE_ID=n.ID and n.FLOWSTATE=1 and i.CUSTOMER_ID=:cusId and i.CREATE_TIME>=:beginDay and i.CREATE_TIME<=:endDay group by i.THIRD_CATEGORY_ID) manswer  ");
        builder.append(" on  mtotal.THIRD_CATEGORY_ID = manswer.THIRD_CATEGORY_ID ");
        builder.append(" left join (select count(i.id) activi_num,THIRD_CATEGORY_ID from SC_WORKFLOW_INCIDENT_LOCAL i,workflow_base b where i.FLOW_ID=b.ID and b.WFSTATE=1 and i.CUSTOMER_ID=:cusId and i.CREATE_TIME>=:beginDay and i.CREATE_TIME<=:endDay group by i.THIRD_CATEGORY_ID) mactivi  ");
@@ -1290,13 +1296,13 @@
            sql+=" and a.zsxm like :userName ";
        }
        List<Map> userList=baseDao.queryForList(sql, param);
        sql="SELECT count(*) num,RESOLVE_USER_ID,DATE_FORMAT(RESOLVE_TIME,'%Y%m%d') day from sc_workflow_incident_local ";
        sql+=" where DATE_FORMAT(RESOLVE_TIME,'%Y%m%d')>=:beginDay and DATE_FORMAT(RESOLVE_TIME,'%Y%m%d')<=:endDay  ";
        sql="SELECT count(*) num,RESOLVE_USER_ID,to_number(substr(RESOLVE_TIME,1,8)) day from sc_workflow_incident_local ";
        sql+=" where to_number(substr(RESOLVE_TIME,1,8))>=:beginDay and to_number(substr(RESOLVE_TIME,1,8))<=:endDay  ";
        if(StringUtil.notEmpty(ConvertUtil.obj2Str(param.get("cusId")))){
            sql+=" and CUSTOMER_ID=:cusId ";
        }
        sql+=" GROUP BY RESOLVE_USER_ID,DATE_FORMAT(RESOLVE_TIME,'%Y%m%d')";
        sql+=" GROUP BY RESOLVE_USER_ID,to_number(substr(RESOLVE_TIME,1,8))";
        List<Map> numList=baseDao.queryForList(sql, param);
        Long beginDay=ConvertUtil.obj2Long(param.get("beginDay"));
        Long endDay=ConvertUtil.obj2Long(param.get("endDay"));
src/cn/ksource/web/facade/tj/QuestionStatisFacadeImpl.java
@@ -242,9 +242,11 @@
        Map paramMap = new HashMap();
        StringBuilder builder = new StringBuilder("");
        if(frequency.equals("2")) {
            builder = builder.append("SELECT $KEY COLKEY,COUNT(C.ID) AS NUM,DATE_FORMAT(C.CREATE_TIME,'%Y-%m-%d') AS DC_TIME  FROM SC_WORKFLOW_QUESTION C WHERE 1=1");
            builder = builder.append("SELECT $KEY COLKEY,COUNT(C.ID) AS NUM,to_char(C.CREATE_TIME,\n" +
                    "        'yyyy-MM-dd')  AS DC_TIME  FROM SC_WORKFLOW_QUESTION C WHERE 1=1");
        } else {
            builder = builder.append("SELECT $KEY COLKEY,COUNT(C.ID) AS NUM,DATE_FORMAT(C.CREATE_TIME,'%Y-%m') AS DC_TIME FROM SC_WORKFLOW_QUESTION C WHERE 1=1 ");
            builder = builder.append("SELECT $KEY COLKEY,COUNT(C.ID) AS NUM,to_char(C.CREATE_TIME,\n" +
                    "        'yyyy-MM')  AS DC_TIME FROM SC_WORKFLOW_QUESTION C WHERE 1=1 ");
        }
        if(StringUtil.isBlank(queryType)){
            builder.append(" AND state!=7 ");
@@ -267,7 +269,12 @@
            }
        }
        builder.append(" and $KEY is not null ");
        builder.append(" GROUP BY $KEY,DC_TIME ");
        if(frequency.equals("2")){
            builder.append(" GROUP BY $KEY,to_char(C.CREATE_TIME,'yyyy-MM-dd') ");
        }else {
            builder.append(" GROUP BY $KEY,to_char(C.CREATE_TIME,'yyyy-MM') ");
        }
        String sql = builder.toString().replace("$KEY", ConvertUtil.obj2StrBlank(queryMap.get("col")));
        return baseDao.queryForList(sql,paramMap);
    }
@@ -508,8 +515,8 @@
            paramMap.put("subCustomerId", subCustomerId);
        }
        
        String endSql = " GROUP BY THIRD_CATEGORY_ID ";
        String endSql = " GROUP BY THIRD_CATEGORY_ID ,THIRD_CATEGORY_NAME,SECOND_CATEGORY_NAME,FIRST_CATEGORY_NAME ";
        builder1.append(endSql);
        
        
@@ -598,12 +605,15 @@
        List<List<String>> dataList = new ArrayList<List<String>>();  
        //查询数据
        StringBuilder builder = new StringBuilder();
        builder.append(" SELECT q.NAME,q.DESCRIP,q.CONTACT_NAME,q.CONTACT_PHONE,q.SOURCE_NAME,q.THIRD_CATEGORY_NAME,q.SECOND_CATEGORY_NAME,q.FIRST_CATEGORY_NAME,DATE_FORMAT(q.WANT_DEAL_TIME,'%Y-%m-%d') WANT_DEAL_TIME, ");
        builder.append(" q.PRIORITY_NAME,q.INFLUENCE_NAME,q.STATE,q.RESOLVE_TYPE_NAME,q.RESOLVE,t.CREATE_USER_NAME,DATE_FORMAT(t.CREATE_TIME,'%Y-%m-%d') CREATE_TIME,IFNULL(t.deal_time,0) deal_time  ");
        builder.append(" SELECT q.NAME,q.DESCRIP,q.CONTACT_NAME,q.CONTACT_PHONE,q.SOURCE_NAME,q.THIRD_CATEGORY_NAME,q.SECOND_CATEGORY_NAME,q.FIRST_CATEGORY_NAME,q.WANT_DEAL_TIME WANT_DEAL_TIME, ");
        builder.append(" q.PRIORITY_NAME,q.INFLUENCE_NAME,q.STATE,q.RESOLVE_TYPE_NAME,q.RESOLVE,t.CREATE_USER_NAME,t.CREATE_TIME CREATE_TIME,IFNULL(t.deal_time,0) deal_time  ");
        builder.append(" from SC_WORKFLOW_QUESTION q  ");
        builder.append(" LEFT JOIN ( ");
        builder.append("     select z.CREATE_USER_NAME,z.CREATE_TIME,b.ID,truncate(TIMESTAMPDIFF(SECOND, b.CREATETIME, b.ENDTIME)*1000,0) deal_time from QUESTION_ZD_HISTORY z,workflow_base b where b.ID = z.FLOWID ");
        builder.append("     and z.ISTHEEND =1 group by b.ID ");
        builder.append("     select z.CREATE_USER_NAME,z.CREATE_TIME,b.ID,round((\n" +
                "         b.ENDTIME - b.CREATETIME\n" +
                "         )*1000,\n" +
                "        0) deal_time from QUESTION_ZD_HISTORY z,workflow_base b where b.ID = z.FLOWID ");
        builder.append("     and z.ISTHEEND =1 group by b.ID,z.CREATE_USER_NAME,z.CREATE_TIME,round(( b.ENDTIME - b.CREATETIME )*1000,0) ");
        builder.append(" ) t on q.FLOW_ID = t.ID where q.CREATE_TIME >:beginDay and q.CREATE_TIME < :endDay  ");
        if(StringUtil.notEmpty(cusId)){
            builder.append(" and q.CUSTOMER_ID = :cusId ");
@@ -677,7 +687,7 @@
        builder.append(" select mtotal.THIRD_CATEGORY_NAME,mtotal.SECOND_CATEGORY_NAME,mtotal.FIRST_CATEGORY_NAME,total_num,IFNULL(answer_num,0) answer_num,IFNULL(activi_num,0) activi_num,IFNULL(finish_num,0) finish_num,IFNULL(sleep_num,0) sleep_num,  ");
        builder.append(" IFNULL(avg_deal_time,0) avg_deal_time,truncate(IFNULL(major_num,0)*100/total_num,2) major_rate,truncate(IFNULL(finish_num, 0)*100/total_num,2) solve_rate,truncate(IFNULL(close_num, 0)*100/total_num,2) close_rate,  ");
        builder.append(" truncate(IFNULL(repeat_num, 0)*100/total_num,2) repeat_rate,truncate(IFNULL(nosolve_num, 0)*100/total_num,2) nosolve_rate   from  ");
        builder.append(" (select THIRD_CATEGORY_NAME,SECOND_CATEGORY_NAME,FIRST_CATEGORY_NAME,count(i.id) total_num,THIRD_CATEGORY_ID from SC_WORKFLOW_QUESTION i,workflow_base b where b.BUSINESS_ID = i.ID and i.CUSTOMER_ID=:cusId and i.CREATE_TIME>=:beginDay and i.CREATE_TIME<=:endDay group by i.THIRD_CATEGORY_ID) mtotal   ");
        builder.append(" (select THIRD_CATEGORY_NAME,SECOND_CATEGORY_NAME,FIRST_CATEGORY_NAME,count(i.id) total_num,THIRD_CATEGORY_ID from SC_WORKFLOW_QUESTION i,workflow_base b where b.BUSINESS_ID = i.ID and i.CUSTOMER_ID=:cusId and i.CREATE_TIME>=:beginDay and i.CREATE_TIME<=:endDay group by i.THIRD_CATEGORY_ID,i.THIRD_CATEGORY_NAME,i.SECOND_CATEGORY_NAME,i.FIRST_CATEGORY_NAME) mtotal   ");
        builder.append(" left join (select count(i.id) answer_num,THIRD_CATEGORY_ID from SC_WORKFLOW_QUESTION i,workflow_base b,(SELECT FLOWID FROM workflow_node WHERE FLOWSTATE = 1 GROUP BY FLOWID) n where b.BUSINESS_ID = i.ID AND b.id = n.FLOWID  and i.CUSTOMER_ID=:cusId  and i.CREATE_TIME>=:beginDay and i.CREATE_TIME<=:endDay group by i.THIRD_CATEGORY_ID) manswer  ");
        builder.append(" on  mtotal.THIRD_CATEGORY_ID = manswer.THIRD_CATEGORY_ID ");
        builder.append(" left join (select count(i.id) activi_num,THIRD_CATEGORY_ID from SC_WORKFLOW_QUESTION i,workflow_base b where b.BUSINESS_ID = i.ID and b.WFSTATE=1 and i.CUSTOMER_ID=:cusId and i.CREATE_TIME>=:beginDay and i.CREATE_TIME<=:endDay group by i.THIRD_CATEGORY_ID) mactivi  ");
@@ -891,7 +901,7 @@
        builder.append(" IFNULL(finish_num,0) finish_num, IFNULL(close_num,0) close_num from (  ");
        builder.append("     select count(b.id) total_num,i.THIRD_CATEGORY_NAME,i.FIRST_CATEGORY_NAME,i.SECOND_CATEGORY_NAME,i.THIRD_CATEGORY_ID from workflow_base b ,SC_WORKFLOW_QUESTION i      ");
        builder.append("     where b.BUSINESS_ID = i.ID  and b.createtime >:beginDay and b.createtime <:endDay and b.BUSINESSTYPE = 9 and b.CUSTOMER_ID = :cusId ");
        builder.append("     GROUP BY I.THIRD_CATEGORY_ID  ");
        builder.append("     GROUP BY I.THIRD_CATEGORY_ID ,i.THIRD_CATEGORY_NAME,i.FIRST_CATEGORY_NAME,i.SECOND_CATEGORY_NAME ");
        builder.append(" ) mtotal left join (  ");
        builder.append("     select count(b.id) answer_num,i.THIRD_CATEGORY_ID from workflow_base b ,SC_WORKFLOW_QUESTION i,(  ");
        builder.append("           select FLOWID from workflow_node where FLOWSTATE = 1 group by FLOWID ");
src/cn/ksource/web/facade/tj/SatisfactionStatisFacadeImpl.java
@@ -174,7 +174,7 @@
        if(StringUtil.notEmpty(cusId) ) {
            sql.append(" AND i.CUSTOMER_ID = :cusId  ");
        }
        sql.append("     group by i.$COLUMN,t.id1,t.id2 ");
        sql.append("     group by i.$COLUMN,t.id1,t.id2,t.weight ");
        sql.append(" )t group by id1,$COLUMN ");
        
        String finalSql = sql.toString();
src/cn/ksource/web/facade/ywStatis/YwStatisFacadeImpl.java
@@ -40,9 +40,9 @@
            sql.append(" and g.`zsxm` like :engineer ");
            params.put("engineer", "%"+engineer+"%");
        }
        sql.append(" group by g.id " );
        sql.append(" group by g.id, g.ZSXM " );
        sql.append(" ) t left join ( ");
        sql.append("    select t.current_dealer_id,count(*) i_num,sum(t.w_hour) i_hour,format(avg(s.score),2) i_score from ( ");
        sql.append("    select t.current_dealer_id,count(*) i_num,sum(t.w_hour) i_hour,round(avg(s.score),2) i_score from ( ");
        sql.append("    select n.current_dealer_id,n.flowid,sum(n.DEAL_USETIME) w_hour from workflow_node n,sc_workflow_incident d,workflow_base b ");
        sql.append("    where d.id = b.business_id and b.id = n.flowid   and b.WFSTATE<>3 ");
        initSurverQuery(sql,params);
@@ -54,7 +54,7 @@
        sql.append(" GROUP BY n.current_dealer_id,n.flowid) t LEFT JOIN order_satis_info s ON t.flowid = s.business_id GROUP BY t.current_dealer_id ) ia ON t.current_dealer_id = ia.current_dealer_id");
        
        sql.append(" left join ( ");
        sql.append("    select t.current_dealer_id,count(*) l_num,sum(t.w_hour) l_hour,format(avg(s.score),2) l_score from ( ");
        sql.append("    select t.current_dealer_id,count(*) l_num,sum(t.w_hour) l_hour,round(avg(s.score),2) l_score from ( ");
        sql.append("    select n.current_dealer_id,n.flowid,sum(n.DEAL_USETIME) w_hour from workflow_node n,sc_workflow_incident_local d,workflow_base b ");
        sql.append("    where d.id = b.business_id and b.id = n.flowid   and b.WFSTATE<>3 ");
        initSurverQuery(sql,params);
@@ -107,7 +107,9 @@
            params.put("end_date", params.get("end_date").substring(0, 6)+"31");
            sqla+=" and E.SUBMIT_TIME <=:end_date ";
        }
                sqla+=" GROUP BY ZC_ID ORDER BY E.CARD_MONTH DESC, E.SUBMIT_TIME DESC)m";
                sqla+=" GROUP BY D.user_id,E.CARD_MONTH,E.STATE, E.SUBMIT_TIME, E.CREATE_TIME, \n" +
                        "            D.ALLUSER,D.SUB_CUSTOMER_ID, D.SUB_CUSTOMER_NAME,D.CUSTOMER_ID,D.CUSTOMER_NAME" +
                        " ORDER BY E.CARD_MONTH DESC, E.SUBMIT_TIME DESC)m";
        List<Map> listF=baseDao.queryForList(sqla, params);
        if(resList.size()>0){
            if(listF.size()>0){
@@ -186,110 +188,110 @@
            sql.append(" select '事件工单'as type_name,'1' as orderType, t.t_num, ifnull(f.f_num, 0) f_num, ifnull(c.c_num, 0) c_num, ifnull(a.a_num, 0) a_num, ifnull(d.d_num, 0) d_num,ifnull(h.w_hour, 0) w_hour from ( ");
            sql.append("    select b.businesstype, count( *) t_num from workflow_base b, sc_workflow_incident d where b.business_id=d.id ");
            initSurverQuery(sql,params);
            sql.append(" )t left join (   ");
            sql.append(" group by b.businesstype )t left join (   ");
            sql.append("    select businesstype, count(*) f_num from workflow_base b,sc_workflow_incident d where b.business_id=d.id and b.wfstate in(2,4)  ");
            initSurverQuery(sql,params);
            sql.append(" )f on t.businesstype = f.businesstype left join (   ");
            sql.append(" group by b.businesstype )f on t.businesstype = f.businesstype left join (   ");
            sql.append("    select businesstype, count(*) c_num from workflow_base b,sc_workflow_incident d where b.business_id=d.id and b.wfstate = 3  ");
            initSurverQuery(sql,params);
            sql.append(" )c on c.businesstype = t.businesstype left join (   ");
            sql.append(" group by b.businesstype )c on c.businesstype = t.businesstype left join (   ");
            sql.append("   select businesstype, count(*) a_num from workflow_base b,sc_workflow_incident d where b.business_id=d.id and b.wfstate = 1  ");
            initSurverQuery(sql,params);
            sql.append(" )a on a.businesstype = t.businesstype left join ( ");
            sql.append(" group by b.businesstype )a on a.businesstype = t.businesstype left join ( ");
            sql.append("    select businesstype, count(*) d_num from workflow_base b,sc_workflow_incident d where b.business_id=d.id and b.wfstate = 1  and d.ANSWER_TIME is null ");
            initSurverQuery(sql,params);
            sql.append(" )d on d.businesstype = t.businesstype left join (   ");
            sql.append(" group by b.businesstype )d on d.businesstype = t.businesstype left join (   ");
            sql.append("    select b.businesstype, sum(n.deal_usetime) w_hour from workflow_base b, workflow_node n,sc_workflow_incident d where b.id = n.flowid and b.business_id = d.id  and b.wfstate in(2,4) ");
            initSurverQuery(sql,params);
            sql.append(" ) h on t.businesstype=h.businesstype   ");
            sql.append(" group by b.businesstype ) h on t.businesstype=h.businesstype   ");
            resList.addAll(baseDao.queryForList(sql.toString(), params));
          //查询驻场事件
            sql.setLength(0);
            sql.append(" select '驻场工单'as type_name,'2' as orderType, t.t_num, ifnull(f.f_num, 0) f_num, ifnull(c.c_num, 0) c_num, ifnull(a.a_num, 0) a_num, ifnull(d.d_num, 0) d_num,ifnull(h.w_hour,0) w_hour from ( ");
            sql.append("    select b.businesstype, count( *) t_num from workflow_base b, sc_workflow_incident_local d where b.business_id=d.id ");
            initSurverQuery(sql,params);
            sql.append(" )t left join (   ");
            sql.append(" group by b.businesstype )t left join (   ");
            sql.append("    select businesstype, count(*) f_num from workflow_base b,sc_workflow_incident_local d where b.business_id=d.id and b.wfstate in(2,4)  ");
            initSurverQuery(sql,params);
            sql.append(" )f on t.businesstype = f.businesstype left join (   ");
            sql.append(" group by b.businesstype )f on t.businesstype = f.businesstype left join (   ");
            sql.append("    select businesstype, count(*) c_num from workflow_base b,sc_workflow_incident_local d where b.business_id=d.id and b.wfstate = 3  ");
            initSurverQuery(sql,params);
            sql.append(" )c on c.businesstype = t.businesstype left join (   ");
            sql.append(" group by b.businesstype )c on c.businesstype = t.businesstype left join (   ");
            sql.append("   select businesstype, count(*) a_num from workflow_base b,sc_workflow_incident_local d where b.business_id=d.id and b.wfstate = 1  ");
            initSurverQuery(sql,params);
            sql.append(" )a on a.businesstype = t.businesstype left join ( ");
            sql.append(" group by b.businesstype )a on a.businesstype = t.businesstype left join ( ");
            sql.append("    select businesstype, count(*) d_num from workflow_base b,sc_workflow_incident_local d where b.business_id=d.id and b.wfstate = 1  and d.ANSWER_TIME is null ");
            initSurverQuery(sql,params);
            sql.append(" )d on d.businesstype = t.businesstype left join (   ");
            sql.append(" group by b.businesstype )d on d.businesstype = t.businesstype left join (   ");
            sql.append("    select b.businesstype, sum(n.deal_usetime) w_hour from workflow_base b, workflow_node n,sc_workflow_incident_local d where b.id = n.flowid and b.business_id = d.id  and b.wfstate in(2,4) ");
            initSurverQuery(sql,params);
            sql.append(" ) h on t.businesstype=h.businesstype   ");
            sql.append(" group by b.businesstype ) h on t.businesstype=h.businesstype   ");
            resList.addAll(baseDao.queryForList(sql.toString(), params));
            //问题
            sql.setLength(0);
            sql.append(" select '问题工单'as type_name,'3' as orderType, t.t_num, ifnull(f.f_num, 0) f_num, ifnull(c.c_num, 0) c_num, ifnull(a.a_num, 0) a_num, ifnull(d.d_num, 0) d_num,ifnull(h.w_hour,0) w_hour from ( ");
            sql.append("    select b.businesstype, count( *) t_num from workflow_base b, sc_workflow_question d where b.business_id=d.id   ");
            initSurverQuery(sql,params);
            sql.append(" )t left join (   ");
            sql.append(" group by b.businesstype )t left join (   ");
            sql.append("    select businesstype, count(*) f_num from workflow_base b,sc_workflow_question d where b.business_id=d.id and b.wfstate = 2    ");
            initSurverQuery(sql,params);
            sql.append(" )f on t.businesstype = f.businesstype left join (   ");
            sql.append(" group by b.businesstype )f on t.businesstype = f.businesstype left join (   ");
            sql.append("    select businesstype, count(*) c_num from workflow_base b,sc_workflow_question d where b.business_id=d.id and b.wfstate = 3   ");
            initSurverQuery(sql,params);
            sql.append(" )c on c.businesstype = t.businesstype left join (   ");
            sql.append(" group by b.businesstype )c on c.businesstype = t.businesstype left join (   ");
            sql.append("    select businesstype, count(*) a_num from workflow_base b,sc_workflow_question d where b.business_id=d.id and b.wfstate = 1   ");
            initSurverQuery(sql,params);
            sql.append(" )a on a.businesstype = t.businesstype left join ( ");
            sql.append(" group by b.businesstype )a on a.businesstype = t.businesstype left join ( ");
            sql.append("    select businesstype, count(*) d_num from workflow_base b, sc_workflow_question d where b.business_id=d.id and b.wfstate = 3  and d.SHOULI_TIME is null ");
            initSurverQuery(sql,params);
            sql.append(" )d on d.businesstype = t.businesstype left join (   ");
            sql.append(" group by b.businesstype )d on d.businesstype = t.businesstype left join (   ");
            sql.append("    select b.businesstype, sum(n.deal_usetime) w_hour from workflow_base b, workflow_node n,sc_workflow_question d where b.id = n.flowid and b.business_id = d.id    and b.wfstate in(2,4) ");
            initSurverQuery(sql,params);
            sql.append(" ) h on t.businesstype=h.businesstype   ");
            sql.append(" group by b.businesstype ) h on t.businesstype=h.businesstype   ");
            resList.addAll(baseDao.queryForList(sql.toString(), params));
            //变更
            sql.setLength(0);
            sql.append(" select '变更工单'as type_name,'4' as orderType, t.t_num, ifnull(f.f_num, 0) f_num, ifnull(c.c_num, 0) c_num, ifnull(a.a_num, 0) a_num, (0) d_num,ifnull(h.w_hour,0) w_hour from ( ");
            sql.append("    select b.businesstype, count( *) t_num from workflow_base b, sc_workflow_change d where b.business_id=d.id   ");
            initSurverQuery(sql,params);
            sql.append(" )t left join (   ");
            sql.append(" group by b.businesstype )t left join (   ");
            sql.append("    select businesstype, count(*) f_num from workflow_base b,sc_workflow_change d where b.business_id=d.id and b.wfstate = 2   ");
            initSurverQuery(sql,params);
            sql.append(" )f on t.businesstype = f.businesstype left join (   ");
            sql.append(" group by b.businesstype )f on t.businesstype = f.businesstype left join (   ");
            sql.append("    select businesstype, count(*) c_num from workflow_base b,sc_workflow_change d where b.business_id=d.id and b.wfstate = 3   ");
            initSurverQuery(sql,params);
            sql.append(" )c on c.businesstype = t.businesstype left join (   ");
            sql.append(" group by b.businesstype )c on c.businesstype = t.businesstype left join (   ");
            sql.append("    select businesstype, count(*) a_num from workflow_base b,sc_workflow_change d where b.business_id=d.id and b.wfstate = 1   ");
            initSurverQuery(sql,params);
            sql.append(" )a on a.businesstype = t.businesstype left join ( ");
            sql.append(" group by b.businesstype )a on a.businesstype = t.businesstype left join ( ");
            sql.append("    select businesstype, count(*) d_num from workflow_base b, workflow_node n,sc_workflow_change d where b.current_node_id = n.id and b.business_id=d.id and n.flowstate <> 1 and b.wfstate=1   ");
            initSurverQuery(sql,params);
            sql.append(" )d on d.businesstype = t.businesstype left join (   ");
            sql.append(" group by b.businesstype )d on d.businesstype = t.businesstype left join (   ");
            sql.append("    select b.businesstype, sum(n.deal_usetime) w_hour from workflow_base b, workflow_node n,sc_workflow_change d where b.id = n.flowid and b.business_id = d.id  and b.wfstate in(2,4)  ");
            initSurverQuery(sql,params);
            sql.append(" ) h on t.businesstype=h.businesstype   ");
            sql.append(" group by b.businesstype ) h on t.businesstype=h.businesstype   ");
            resList.addAll(baseDao.queryForList(sql.toString(), params));
            //发布
            sql.setLength(0);
            sql.append(" select '发布工单'as type_name,'5' as orderType, t.t_num, ifnull(f.f_num, 0) f_num, ifnull(c.c_num, 0) c_num, ifnull(a.a_num, 0) a_num, (0) d_num,ifnull(h.w_hour,0) w_hour from ( ");
            sql.append("    select b.businesstype, count( *) t_num from workflow_base b, sc_workflow_release d where b.business_id=d.id   ");
            initSurverQuery(sql,params);
            sql.append(" )t left join (   ");
            sql.append(" group by b.businesstype )t left join (   ");
            sql.append("    select businesstype, count(*) f_num from workflow_base b,sc_workflow_release d where b.business_id=d.id and b.wfstate = 2   ");
            initSurverQuery(sql,params);
            sql.append(" )f on t.businesstype = f.businesstype left join (   ");
            sql.append(" group by b.businesstype )f on t.businesstype = f.businesstype left join (   ");
            sql.append("    select businesstype, count(*) c_num from workflow_base b,sc_workflow_release d where b.business_id=d.id and b.wfstate = 3  ");
            initSurverQuery(sql,params);
            sql.append(" )c on c.businesstype = t.businesstype left join (   ");
            sql.append(" group by b.businesstype )c on c.businesstype = t.businesstype left join (   ");
            sql.append("    select businesstype, count(*) a_num from workflow_base b,sc_workflow_release d where b.business_id=d.id and b.wfstate = 1  ");
            initSurverQuery(sql,params);
            sql.append(" )a on a.businesstype = t.businesstype left join ( ");
            sql.append(" group by b.businesstype )a on a.businesstype = t.businesstype left join ( ");
            sql.append("    select businesstype, count(*) d_num from workflow_base b, workflow_node n,sc_workflow_release d where b.current_node_id = n.id and b.business_id=d.id and n.flowstate <> 1 and b.wfstate=1    ");
            initSurverQuery(sql,params);
            sql.append(" )d on d.businesstype = t.businesstype left join (   ");
            sql.append(" group by b.businesstype )d on d.businesstype = t.businesstype left join (   ");
            sql.append("    select b.businesstype, sum(n.deal_usetime) w_hour from workflow_base b, workflow_node n,sc_workflow_release d where b.id = n.flowid and b.business_id = d.id and b.wfstate in(2,4)  ");
            initSurverQuery(sql,params);
            sql.append(" ) h on t.businesstype=h.businesstype   ");
            sql.append(" group by b.businesstype ) h on t.businesstype=h.businesstype   ");
            resList.addAll(baseDao.queryForList(sql.toString(), params));
            //合计