Browse Source

日报代码

liubing 2 years ago
parent
commit
6d63ecf581

+ 43 - 12
business/base-service/src/main/java/com/yihu/jw/dailyReport/service/DailyReportUploadService.java

@ -3785,6 +3785,8 @@ public class DailyReportUploadService {
        List<Map<String,Object>> doctorTypeHourList = jdbcTemplate.queryForList(doctorTypeSql);
        result.put("doctorTypeHourList",doctorTypeHourList);//按人员统计总用时与参与人数
        JSONObject bugObj = selectBugTotal(memberId,startDate,endDate,dept);
        result.putAll(bugObj);
        return result;
    }
@ -5056,23 +5058,40 @@ public class DailyReportUploadService {
    }
    public JSONObject select(String doctorId,String startDate,String endDate,String dept) throws Exception {
    public JSONObject selectBugTotal(String doctorId, String startDate, String endDate, String dept) throws Exception {
        String sqlCondition = "";
        if (StringUtils.isNoneBlank(dept)){
            sqlCondition = " SELECT d.zt_id as ztId FROM base_doctor d LEFT JOIN base_doctor_hospital dh ON d.id=dh.doctor_code where dh.dept_code='"+dept+"' ";
            sqlCondition = " SELECT d.zt_id as ztId FROM base_doctor d LEFT JOIN base_doctor_hospital dh ON d.id=dh.doctor_code where d.del=1 and dh.del=1 and dh.dept_code='"+dept+"' ";
        }
        if (!StringUtils.isNoneBlank(dept)&&StringUtils.isNoneBlank(doctorId)){
        if (StringUtils.isNoneBlank(doctorId)){
            sqlCondition = " SELECT d.zt_id as ztId FROM base_doctor d where d.id = '"+doctorId+"' ";
        }
        List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sqlCondition);
        String str = "";
        if (mapList!=null&&mapList.size()!=0){
            for (Map<String,Object> map:mapList){
                str = "'"+map.get("ztId")+"',";
                str += "'"+map.get("ztId")+"',";
            }
        }
        str = str.substring(0,str.length()-1);
        String sql = "SELECT count(1) as total FROM zt_bug  where resolvedBy in ("+str+") ";
        sqlCondition = " ";
        if (StringUtils.isNotBlank(startDate)){
            sqlCondition += " and lastEditedDate>='"+startDate+"' ";
        }
        if (StringUtils.isNotBlank(endDate)){
            sqlCondition += " and lastEditedDate<='"+endDate+"' ";
        }
        String sql = "  select * from ( " +
                " select count(distinct id) total,'resolve' `status` from zt_bug " +
                " where  (resolvedBy in ("+str+")) or  " +
                " (assignedTo in ("+str+") and `status` in ('closed')) or " +
                " (closedBy in ("+str+")and `status` in ('closed')) " +
                "  and deleted='0' " +sqlCondition+
                " union ALL " +
                " select count(distinct id) total,'unresolved' `status` from zt_bug " +
                " where assignedTo in ("+str+") and `status` in ('active','resolved') and deleted='0' " +sqlCondition+
                " )A ";
        String url = "http://172.19.103.134:10023/ykyy/jdbcSQLQuery";
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
@ -5080,18 +5099,30 @@ public class DailyReportUploadService {
        String content = response.getContent();
        logger.info("response:"+content);
        JSONObject rs = JSON.parseObject(content);
        String total = "0";//总bug数;
        Long total = 0l;//总bug数;
        Long resolveBugTotal=0l;//已解决BUG数
        Long unresolvedBugTotal=0l;//待解决BUG数
        Integer status = rs.getInteger("status");
        if(status!=null&&status == 200){
            JSONArray array = rs.getJSONArray("detailModelList");
            if (array!=null&&array.size()!=0){
                JSONObject jsonObject = array.getJSONObject(0);
                total = jsonObject.getString("total");
                total = array.stream().mapToLong(t ->((JSONObject)t).get("total") == null ? 0 :Long.parseLong(((JSONObject)t).getString("total"))).sum();
                for (int i=0;i<array.size();i++){
                    JSONObject tmp = array.getJSONObject(i);
                    String bugStatus = tmp.getString("status");
                    Long statusTotal  =Long.parseLong(tmp.getString("total"));
                    if("resolve".equals(bugStatus)){
                        resolveBugTotal = statusTotal;
                    }else {
                        unresolvedBugTotal = statusTotal;
                    }
                }
            }
        }
        String yijiejueSql = "SELECT count(1) as total FROM zt_bug  where resolvedBy in ("+str+") ";
        JSONObject result = new JSONObject();
        result.put("bugtotal",total);
        result.put("resolveBugTotal",resolveBugTotal);
        result.put("unresolvedBugTotal",unresolvedBugTotal);
        return result;
    }
}