|  | @ -1,5 +1,6 @@
 | 
	
		
			
				|  |  | package com.yihu.jw.dailyReport.service;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSON;
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONArray;
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | import com.yihu.jw.dailyReport.dao.*;
 | 
	
	
		
			
				|  | @ -2420,6 +2421,273 @@ public class DailyReportUploadService {
 | 
	
		
			
				|  |  |         return list;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取某个部门的项目趋势图一级
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public List<Map<String,Object>> statisticDeptProjectTrend(String user,String dept,String startDate,String endDate,Integer type) throws Exception {
 | 
	
		
			
				|  |  |         String sql = " select * from base_doctor_role where doctor_code='"+user+"' ";
 | 
	
		
			
				|  |  |         List<Map<String,Object>> userRoles = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         if (userRoles.size()==0){
 | 
	
		
			
				|  |  |             throw new Exception("您无权限操作");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String sqlCondition = "  ";
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(startDate)){
 | 
	
		
			
				|  |  |             sqlCondition += " and up.report_date>='"+startDate+"' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(endDate)){
 | 
	
		
			
				|  |  |             sqlCondition += " and up.report_date<='"+endDate+"' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String groupTimeFormat = "";
 | 
	
		
			
				|  |  |         String uploadTimeFormat = "";
 | 
	
		
			
				|  |  |         if(0==type){//全部
 | 
	
		
			
				|  |  |             groupTimeFormat=" DATE_FORMAT(de.create_time,'%Y-%m-%d') ";
 | 
	
		
			
				|  |  |             uploadTimeFormat=" DATE_FORMAT(up.report_date,'%Y-%m-%d') ";
 | 
	
		
			
				|  |  |         }else if(1==type){//日
 | 
	
		
			
				|  |  |             groupTimeFormat=" DATE_FORMAT(de.create_time,'%Y-%m-%d') ";
 | 
	
		
			
				|  |  |             uploadTimeFormat=" DATE_FORMAT(up.report_date,'%Y-%m-%d') ";
 | 
	
		
			
				|  |  |         }else if(2==type){//周
 | 
	
		
			
				|  |  |             groupTimeFormat=" DATE_FORMAT(de.create_time,'%Y%v') ";
 | 
	
		
			
				|  |  |             uploadTimeFormat=" DATE_FORMAT(up.report_date,'%Y-%m-%d') ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         else if(3==type){//月
 | 
	
		
			
				|  |  |             groupTimeFormat=" DATE_FORMAT(de.create_time,'%Y-%m') ";
 | 
	
		
			
				|  |  |             uploadTimeFormat=" DATE_FORMAT(up.report_date,'%Y-%m') ";
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             throw new Exception("查询失败,请检查传入参数");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String projectSql = " select  dict.dict_code project_code,dict.dict_value projectName " +
 | 
	
		
			
				|  |  |                 " from wlyy_hospital_sys_dict dict INNER JOIN base_daily_report_item i on i.project_code = dict.dict_code " +
 | 
	
		
			
				|  |  |                 " where dict.dict_name='daily_report_project' and i.dept='"+dept+"'" +
 | 
	
		
			
				|  |  |                 "GROUP BY dict.dict_code ";
 | 
	
		
			
				|  |  |         List<Map<String,Object>> deptProjectList = jdbcTemplate.queryForList(projectSql);
 | 
	
		
			
				|  |  |         String sqlList = "  select i.project_code,CAST((sum(IFNULL(de.actual_completion_hour,IFNULL(de.completion_hour,'0')))) as char ) as completionHour,  " +
 | 
	
		
			
				|  |  |                 " count(distinct up.doctor_id) as doctorTotal, "+uploadTimeFormat+" as 'time' " +
 | 
	
		
			
				|  |  |                 " from base_daily_report_item i LEFT JOIN base_daily_report_detail de on i.id = de.report_item_id  " +
 | 
	
		
			
				|  |  |                 " INNER JOIN base_doctor_daily_report_upload up on up.id = de.report_id  where i.del=1 and i.dept='"+dept+"' and i.project_code='{project_code}'  "+sqlCondition+
 | 
	
		
			
				|  |  |                 " GROUP BY "+groupTimeFormat+" order by time asc";
 | 
	
		
			
				|  |  |         for (Map<String,Object>tmp:deptProjectList){
 | 
	
		
			
				|  |  |             String project_code = tmp.get("project_code").toString();
 | 
	
		
			
				|  |  |             List<Map<String,Object>> useTimeList = jdbcTemplate.queryForList(sqlList.replace("{project_code}",project_code));
 | 
	
		
			
				|  |  |             if (useTimeList.size()>0){
 | 
	
		
			
				|  |  |                 OptionalDouble avg =  useTimeList.stream().mapToDouble(t -> t.get("completionHour") == null ? 0.0 :Double.parseDouble(t.get("completionHour").toString())).average();
 | 
	
		
			
				|  |  |                 Double totalHour =  useTimeList.stream().mapToDouble(t -> t.get("completionHour") == null ? 0.0 :Double.parseDouble(t.get("completionHour").toString())).sum();
 | 
	
		
			
				|  |  |                 Double avgValue = avg.getAsDouble();
 | 
	
		
			
				|  |  |                 tmp.put("avgValue",avgValue);
 | 
	
		
			
				|  |  |                 tmp.put("totalHour",totalHour);
 | 
	
		
			
				|  |  |                 if(2==type){//获取周的最后一天
 | 
	
		
			
				|  |  |                     for (Map<String,Object>useTimeTmp :useTimeList){
 | 
	
		
			
				|  |  |                         String time = useTimeTmp.get("time").toString();
 | 
	
		
			
				|  |  |                         String sunday = DateUtil.getSundayOfThisWeek(DateUtil.strToDate(time));
 | 
	
		
			
				|  |  |                         useTimeTmp.put("time",sunday);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             tmp.put("useTimeList",useTimeList);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return deptProjectList;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取某个部门的某个项目详情趋势图二级
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public List<Map<String,Object>> statisticDeptProjectItemTrend(String user,String dept,String projectCode,String startDate,String endDate,Integer type) throws Exception {
 | 
	
		
			
				|  |  |         String sql = " select * from base_doctor_role where doctor_code='"+user+"' ";
 | 
	
		
			
				|  |  |         List<Map<String,Object>> userRoles = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         if (userRoles.size()==0){
 | 
	
		
			
				|  |  |             throw new Exception("您无权限操作");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String sqlCondition = "  ";
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(startDate)){
 | 
	
		
			
				|  |  |             sqlCondition += " and up.report_date>='"+startDate+"' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(endDate)){
 | 
	
		
			
				|  |  |             sqlCondition += " and up.report_date<='"+endDate+"' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String groupTimeFormat = "";
 | 
	
		
			
				|  |  |         String uploadTimeFormat = "";
 | 
	
		
			
				|  |  |         if(0==type){//全部
 | 
	
		
			
				|  |  |             groupTimeFormat=" DATE_FORMAT(de.create_time,'%Y-%m-%d') ";
 | 
	
		
			
				|  |  |             uploadTimeFormat=" DATE_FORMAT(up.report_date,'%Y-%m-%d') ";
 | 
	
		
			
				|  |  |         }else if(1==type){//日
 | 
	
		
			
				|  |  |             groupTimeFormat=" DATE_FORMAT(de.create_time,'%Y-%m-%d') ";
 | 
	
		
			
				|  |  |             uploadTimeFormat=" DATE_FORMAT(up.report_date,'%Y-%m-%d') ";
 | 
	
		
			
				|  |  |         }else if(2==type){//周
 | 
	
		
			
				|  |  |             groupTimeFormat=" DATE_FORMAT(de.create_time,'%Y%v') ";
 | 
	
		
			
				|  |  |             uploadTimeFormat=" DATE_FORMAT(up.report_date,'%Y-%m-%d') ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         else if(3==type){//月
 | 
	
		
			
				|  |  |             groupTimeFormat=" DATE_FORMAT(de.create_time,'%Y-%m') ";
 | 
	
		
			
				|  |  |             uploadTimeFormat=" DATE_FORMAT(up.report_date,'%Y-%m') ";
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             throw new Exception("查询失败,请检查传入参数");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String projectSql = "  select i.id,CONCAT(i.title,'(',i.dept_name,')') title,i.content,i.state,i.begin_time beginTime, " +
 | 
	
		
			
				|  |  |                 " i.end_time endTime, i.create_user_name createUserName " +
 | 
	
		
			
				|  |  |                 "  from  base_daily_report_item i  where  i.project_code='"+projectCode+"' and  i.dept='"+dept+"' " +
 | 
	
		
			
				|  |  |                 "  GROUP BY i.id ";
 | 
	
		
			
				|  |  |         List<Map<String,Object>> deptProjectItemList = jdbcTemplate.queryForList(projectSql);
 | 
	
		
			
				|  |  |         String sqlList = "  select i.project_code,CAST((sum(IFNULL(de.actual_completion_hour,IFNULL(de.completion_hour,'0')))) as char ) as completionHour,  " +
 | 
	
		
			
				|  |  |                 " count(distinct up.doctor_id) as doctorTotal, "+uploadTimeFormat+" as 'time' " +
 | 
	
		
			
				|  |  |                 " from base_daily_report_item i LEFT JOIN base_daily_report_detail de on i.id = de.report_item_id  " +
 | 
	
		
			
				|  |  |                 " INNER JOIN base_doctor_daily_report_upload up on up.id = de.report_id  where i.del=1 and i.dept='"+dept+"' and i.id='{itemId}'  "+sqlCondition+
 | 
	
		
			
				|  |  |                 " GROUP BY "+groupTimeFormat+" order by time asc";
 | 
	
		
			
				|  |  |         for (Map<String,Object>tmp:deptProjectItemList){
 | 
	
		
			
				|  |  |             String itemId = tmp.get("id").toString();
 | 
	
		
			
				|  |  |             List<Map<String,Object>> useTimeList = jdbcTemplate.queryForList(sqlList.replace("{itemId}",itemId));
 | 
	
		
			
				|  |  |             if (useTimeList.size()>0){
 | 
	
		
			
				|  |  |                 OptionalDouble avg =  useTimeList.stream().mapToDouble(t -> t.get("completionHour") == null ? 0.0 :Double.parseDouble(t.get("completionHour").toString())).average();
 | 
	
		
			
				|  |  |                 Double totalHour =  useTimeList.stream().mapToDouble(t -> t.get("completionHour") == null ? 0.0 :Double.parseDouble(t.get("completionHour").toString())).sum();
 | 
	
		
			
				|  |  |                 Double avgValue = avg.getAsDouble();
 | 
	
		
			
				|  |  |                 tmp.put("avgValue",avgValue);
 | 
	
		
			
				|  |  |                 tmp.put("totalHour",totalHour);
 | 
	
		
			
				|  |  |                 if(2==type){//获取周的最后一天
 | 
	
		
			
				|  |  |                     for (Map<String,Object>useTimeTmp :useTimeList){
 | 
	
		
			
				|  |  |                         String time = useTimeTmp.get("time").toString();
 | 
	
		
			
				|  |  |                         String sunday = DateUtil.getSundayOfThisWeek(DateUtil.strToDate(time));
 | 
	
		
			
				|  |  |                         useTimeTmp.put("time",sunday);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             tmp.put("useTimeList",useTimeList);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return deptProjectItemList;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取员工项目趋势图一级
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public List<Map<String,Object>> statisticDoctorProjectTrend(String user,String dept,String memberId,String startDate,String endDate,Integer type) throws Exception {
 | 
	
		
			
				|  |  |         String sql = " select * from base_doctor_role where doctor_code='"+user+"' ";
 | 
	
		
			
				|  |  |         List<Map<String,Object>> userRoles = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         if (userRoles.size()==0){
 | 
	
		
			
				|  |  |             throw new Exception("您无权限操作");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String sqlCondition = "  ";
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(startDate)){
 | 
	
		
			
				|  |  |             sqlCondition += " and up.report_date>='"+startDate+"' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(endDate)){
 | 
	
		
			
				|  |  |             sqlCondition += " and up.report_date<='"+endDate+"' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String groupTimeFormat = "";
 | 
	
		
			
				|  |  |         String uploadTimeFormat = "";
 | 
	
		
			
				|  |  |         if(0==type){//全部
 | 
	
		
			
				|  |  |             groupTimeFormat=" DATE_FORMAT(de.create_time,'%Y-%m-%d') ";
 | 
	
		
			
				|  |  |             uploadTimeFormat=" DATE_FORMAT(up.report_date,'%Y-%m-%d') ";
 | 
	
		
			
				|  |  |         }else if(1==type){//日
 | 
	
		
			
				|  |  |             groupTimeFormat=" DATE_FORMAT(de.create_time,'%Y-%m-%d') ";
 | 
	
		
			
				|  |  |             uploadTimeFormat=" DATE_FORMAT(up.report_date,'%Y-%m-%d') ";
 | 
	
		
			
				|  |  |         }else if(2==type){//周
 | 
	
		
			
				|  |  |             groupTimeFormat=" DATE_FORMAT(de.create_time,'%Y%v') ";
 | 
	
		
			
				|  |  |             uploadTimeFormat=" DATE_FORMAT(up.report_date,'%Y-%m-%d') ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         else if(3==type){//月
 | 
	
		
			
				|  |  |             groupTimeFormat=" DATE_FORMAT(de.create_time,'%Y-%m') ";
 | 
	
		
			
				|  |  |             uploadTimeFormat=" DATE_FORMAT(up.report_date,'%Y-%m') ";
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             throw new Exception("查询失败,请检查传入参数");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String projectSql = " select  dict.dict_code project_code,dict.dict_value projectName,i.dept " +
 | 
	
		
			
				|  |  |                 " from wlyy_hospital_sys_dict dict INNER JOIN base_daily_report_item i on i.project_code = dict.dict_code " +
 | 
	
		
			
				|  |  |                 " INNER JOIN base_daily_report_item_members mem on i.id =mem.report_item_id " +
 | 
	
		
			
				|  |  |                 " where dict.dict_name='daily_report_project' and i.dept='"+dept+"'  and mem.user_id='"+memberId+"'" +
 | 
	
		
			
				|  |  |                 " GROUP BY dict.dict_code; ";
 | 
	
		
			
				|  |  |         List<Map<String,Object>> deptProjectList = jdbcTemplate.queryForList(projectSql);
 | 
	
		
			
				|  |  |         String sqlList = "  select i.project_code,CAST((sum(IFNULL(de.actual_completion_hour,IFNULL(de.completion_hour,'0')))) as char ) as completionHour,  " +
 | 
	
		
			
				|  |  |                 " count(distinct up.doctor_id) as doctorTotal, "+uploadTimeFormat+" as 'time' " +
 | 
	
		
			
				|  |  |                 " from base_daily_report_item i LEFT JOIN base_daily_report_detail de on i.id = de.report_item_id  " +
 | 
	
		
			
				|  |  |                 " INNER JOIN base_doctor_daily_report_upload up on up.id = de.report_id  where up.doctor_id='"+memberId+"' and i.del=1 and i.dept='"+dept+"' and i.project_code='{project_code}'  "+sqlCondition+
 | 
	
		
			
				|  |  |                 " GROUP BY "+groupTimeFormat+" order by time asc";
 | 
	
		
			
				|  |  |         for (Map<String,Object>tmp:deptProjectList){
 | 
	
		
			
				|  |  |             String project_code = tmp.get("project_code").toString();
 | 
	
		
			
				|  |  |             List<Map<String,Object>> useTimeList = jdbcTemplate.queryForList(sqlList.replace("{project_code}",project_code));
 | 
	
		
			
				|  |  |             if (useTimeList.size()>0){
 | 
	
		
			
				|  |  |                 OptionalDouble avg =  useTimeList.stream().mapToDouble(t -> t.get("completionHour") == null ? 0.0 :Double.parseDouble(t.get("completionHour").toString())).average();
 | 
	
		
			
				|  |  |                 Double totalHour =  useTimeList.stream().mapToDouble(t -> t.get("completionHour") == null ? 0.0 :Double.parseDouble(t.get("completionHour").toString())).sum();
 | 
	
		
			
				|  |  |                 Double avgValue = avg.getAsDouble();
 | 
	
		
			
				|  |  |                 tmp.put("avgValue",avgValue);
 | 
	
		
			
				|  |  |                 tmp.put("totalHour",totalHour);
 | 
	
		
			
				|  |  |                 if(2==type){//获取周的最后一天
 | 
	
		
			
				|  |  |                     for (Map<String,Object>useTimeTmp :useTimeList){
 | 
	
		
			
				|  |  |                         String time = useTimeTmp.get("time").toString();
 | 
	
		
			
				|  |  |                         String sunday = DateUtil.getSundayOfThisWeek(DateUtil.strToDate(time));
 | 
	
		
			
				|  |  |                         useTimeTmp.put("time",sunday);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             tmp.put("useTimeList",useTimeList);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return deptProjectList;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取员工某个项目详情趋势图二级
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public List<Map<String,Object>> statisticDoctorProjectItemTrend(String user,String dept,String memberId,String projectCode,String startDate,String endDate,Integer type) throws Exception {
 | 
	
		
			
				|  |  |         String sql = " select * from base_doctor_role where doctor_code='"+user+"' ";
 | 
	
		
			
				|  |  |         List<Map<String,Object>> userRoles = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         if (userRoles.size()==0){
 | 
	
		
			
				|  |  |             throw new Exception("您无权限操作");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String sqlCondition = "  ";
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(startDate)){
 | 
	
		
			
				|  |  |             sqlCondition += " and up.report_date>='"+startDate+"' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(endDate)){
 | 
	
		
			
				|  |  |             sqlCondition += " and up.report_date<='"+endDate+"' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String groupTimeFormat = "";
 | 
	
		
			
				|  |  |         String uploadTimeFormat = "";
 | 
	
		
			
				|  |  |         if(0==type){//全部
 | 
	
		
			
				|  |  |             groupTimeFormat=" DATE_FORMAT(de.create_time,'%Y-%m-%d') ";
 | 
	
		
			
				|  |  |             uploadTimeFormat=" DATE_FORMAT(up.report_date,'%Y-%m-%d') ";
 | 
	
		
			
				|  |  |         }else if(1==type){//日
 | 
	
		
			
				|  |  |             groupTimeFormat=" DATE_FORMAT(de.create_time,'%Y-%m-%d') ";
 | 
	
		
			
				|  |  |             uploadTimeFormat=" DATE_FORMAT(up.report_date,'%Y-%m-%d') ";
 | 
	
		
			
				|  |  |         }else if(2==type){//周
 | 
	
		
			
				|  |  |             groupTimeFormat=" DATE_FORMAT(de.create_time,'%Y%v') ";
 | 
	
		
			
				|  |  |             uploadTimeFormat=" DATE_FORMAT(up.report_date,'%Y-%m-%d') ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         else if(3==type){//月
 | 
	
		
			
				|  |  |             groupTimeFormat=" DATE_FORMAT(de.create_time,'%Y-%m') ";
 | 
	
		
			
				|  |  |             uploadTimeFormat=" DATE_FORMAT(up.report_date,'%Y-%m') ";
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             throw new Exception("查询失败,请检查传入参数");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String projectSql = "  select i.id,CONCAT(i.title,'(',i.dept_name,')') title,i.content,i.state,i.begin_time beginTime, " +
 | 
	
		
			
				|  |  |                 " i.end_time endTime, i.create_user_name createUserName " +
 | 
	
		
			
				|  |  |                 "  from  base_daily_report_item i INNER JOIN base_daily_report_item_members mem on i.id =mem.report_item_id " +
 | 
	
		
			
				|  |  |                 " where  i.project_code='"+projectCode+"' and mem.user_id='"+memberId+"' and  i.dept='"+dept+"' " +
 | 
	
		
			
				|  |  |                 "  GROUP BY i.id ";
 | 
	
		
			
				|  |  |         List<Map<String,Object>> deptProjectItemList = jdbcTemplate.queryForList(projectSql);
 | 
	
		
			
				|  |  |         String sqlList = "  select i.project_code,CAST((sum(IFNULL(de.actual_completion_hour,IFNULL(de.completion_hour,'0')))) as char ) as completionHour,  " +
 | 
	
		
			
				|  |  |                 " count(distinct up.doctor_id) as doctorTotal, "+uploadTimeFormat+" as 'time' " +
 | 
	
		
			
				|  |  |                 " from base_daily_report_item i LEFT JOIN base_daily_report_detail de on i.id = de.report_item_id  " +
 | 
	
		
			
				|  |  |                 " INNER JOIN base_doctor_daily_report_upload up on up.id = de.report_id  where i.del=1 and up.doctor_id='"+memberId+"' and i.dept='"+dept+"' and i.id='{itemId}'  "+sqlCondition+
 | 
	
		
			
				|  |  |                 " GROUP BY "+groupTimeFormat+" order by time asc";
 | 
	
		
			
				|  |  |         for (Map<String,Object>tmp:deptProjectItemList){
 | 
	
		
			
				|  |  |             String itemId = tmp.get("id").toString();
 | 
	
		
			
				|  |  |             List<Map<String,Object>> useTimeList = jdbcTemplate.queryForList(sqlList.replace("{itemId}",itemId));
 | 
	
		
			
				|  |  |             if (useTimeList.size()>0){
 | 
	
		
			
				|  |  |                 OptionalDouble avg =  useTimeList.stream().mapToDouble(t -> t.get("completionHour") == null ? 0.0 :Double.parseDouble(t.get("completionHour").toString())).average();
 | 
	
		
			
				|  |  |                 Double totalHour =  useTimeList.stream().mapToDouble(t -> t.get("completionHour") == null ? 0.0 :Double.parseDouble(t.get("completionHour").toString())).sum();
 | 
	
		
			
				|  |  |                 Double avgValue = avg.getAsDouble();
 | 
	
		
			
				|  |  |                 tmp.put("avgValue",avgValue);
 | 
	
		
			
				|  |  |                 tmp.put("totalHour",totalHour);
 | 
	
		
			
				|  |  |                 if(2==type){//获取周的最后一天
 | 
	
		
			
				|  |  |                     for (Map<String,Object>useTimeTmp :useTimeList){
 | 
	
		
			
				|  |  |                         String time = useTimeTmp.get("time").toString();
 | 
	
		
			
				|  |  |                         String sunday = DateUtil.getSundayOfThisWeek(DateUtil.strToDate(time));
 | 
	
		
			
				|  |  |                         useTimeTmp.put("time",sunday);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             tmp.put("useTimeList",useTimeList);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return deptProjectItemList;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 导出项目计划周报月报用时情况
 | 
	
		
			
				|  |  |      * @param user
 | 
	
	
		
			
				|  | @ -2457,7 +2725,7 @@ public class DailyReportUploadService {
 | 
	
		
			
				|  |  |             throw new Exception("导出失败,请检查传入参数");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //项目耗时情况
 | 
	
		
			
				|  |  |         sql = " select CONCAT(it.title,'(',i.dept_name,')') title,it.content,sum(IFNULL(pd.actual_completion_hour,IFNULL(pd.completion_hour,0))) 'completion_hour' ," +
 | 
	
		
			
				|  |  |         sql = " select CONCAT(it.title,'(',it.dept_name,')') title,it.content,sum(IFNULL(pd.actual_completion_hour,IFNULL(pd.completion_hour,0))) 'completion_hour' ," +
 | 
	
		
			
				|  |  |                 " CASE it.state WHEN 1 THEN '已完成' ELSE '未完成' END as 'state',DATE_FORMAT(it.create_time,'%Y-%m-%d %H:%i:%S') create_time,it.create_user_name " +
 | 
	
		
			
				|  |  |                 "from base_daily_report_item it LEFT JOIN base_daily_report_detail pd  " +
 | 
	
		
			
				|  |  |                 "on it.id = pd.report_item_id " +
 | 
	
	
		
			
				|  | @ -2478,7 +2746,7 @@ public class DailyReportUploadService {
 | 
	
		
			
				|  |  |                 "INNER JOIN base_doctor_hospital dh on doc.id = dh.doctor_code and dh.del=1 LEFT JOIN  " +
 | 
	
		
			
				|  |  |                 "base_daily_report_detail rd on up.id = rd.report_id " +
 | 
	
		
			
				|  |  |                 "LEFT JOIN base_daily_report_item it on rd.report_item_id = it.id " +
 | 
	
		
			
				|  |  |                 "where 1=1 and rd.create_time>='"+startTime+"' and rd.create_time<='"+endTime+"' " ;
 | 
	
		
			
				|  |  |                 "where 1=1 and up.create_time>='"+startTime+"' and up.create_time<='"+endTime+"' " ;
 | 
	
		
			
				|  |  |         if (!adminFlag){
 | 
	
		
			
				|  |  |             sql +=" and up.doctor_id in ( select distinct dh2.doctor_code from base_doctor_hospital dh " +
 | 
	
		
			
				|  |  |                     "INNER JOIN base_doctor_hospital dh2 on dh.dept_code = dh2.dept_code " +
 | 
	
	
		
			
				|  | @ -2537,7 +2805,7 @@ public class DailyReportUploadService {
 | 
	
		
			
				|  |  |                 "INNER JOIN base_doctor_hospital dh on doc.id = dh.doctor_code and dh.del=1 LEFT JOIN  " +
 | 
	
		
			
				|  |  |                 "base_daily_report_detail rd on up.id = rd.report_id " +
 | 
	
		
			
				|  |  |                 "LEFT JOIN base_daily_report_item it on rd.report_item_id = it.id " +
 | 
	
		
			
				|  |  |                 "where 1=1 and rd.create_time>='"+startTime+"' and rd.create_time<='"+endTime+"' " ;
 | 
	
		
			
				|  |  |                 "where 1=1 and up.create_time>='"+startTime+"' and up.create_time<='"+endTime+"' " ;
 | 
	
		
			
				|  |  |         if (!adminFlag){
 | 
	
		
			
				|  |  |             sql +=" and up.doctor_id in ( select distinct dh2.doctor_code from base_doctor_hospital dh " +
 | 
	
		
			
				|  |  |                     "INNER JOIN base_doctor_hospital dh2 on dh.dept_code = dh2.dept_code " +
 |