Переглянути джерело

Merge branch 'dev' of liubing/wlyy2.0 into dev

liubing 2 роки тому
батько
коміт
0e901b3589

+ 439 - 78
business/base-service/src/main/java/com/yihu/jw/dailyReport/service/DailyReportUploadService.java

@ -532,7 +532,7 @@ public class DailyReportUploadService {
            for (BaseDailyReportDetailDO tmp:detailDOList){
            for (BaseDailyReportDetailDO tmp:detailDOList){
                if (1==tmp.getDoubt()&&(null==tmp.getDoubtState()||0==tmp.getDoubtState())){
                if (1==tmp.getDoubt()&&(null==tmp.getDoubtState()||0==tmp.getDoubtState())){
                    doubt = true;
                    doubt = true;
                    if(0!=tmp.getDoubtType()&&doubtTypeObj.containsKey(tmp.getDoubtType())){
                    if(0!=tmp.getDoubtType()&&doubtTypeObj.containsKey(tmp.getDoubtType()+"")){
                        doubtTypeName.add(doubtTypeObj.getString(tmp.getDoubtType()+""));
                        doubtTypeName.add(doubtTypeObj.getString(tmp.getDoubtType()+""));
                    }
                    }
                }
                }
@ -586,20 +586,22 @@ public class DailyReportUploadService {
                baseDailyReportLogDO.setContent("上级核实未存疑");
                baseDailyReportLogDO.setContent("上级核实未存疑");
            }
            }
            try {
            try {
                BaseDoctorDO remindDoctorDO = baseDoctorDao.findById(dailyReportUploadDO.getDoctorId());
                if (remindDoctorDO != null) {
                    try {
                        WxEnterpriseUserDO enterpriseUserDO = wxEnterpriseUserDao.findByEnterpriseIdAndMobile(wechatId,remindDoctorDO.getMobile());
                        if(enterpriseUserDO==null){
                            logger.info("该用户"+doctorDO.getName()+"没有企业微信手机号,无法推送模版消息,用户ID:"+doctorDO.getId()+"wechatId:"+wechatId);
                        }else{
                            String title = "待办事项";
                            String des = "您好,"+doctorDO.getName()+"对您提交的每日日报已核实,请点击前往查看。";
                            String url = "https://ehr.yihu.com/hlwyy/zjxl/dailyReport/#/workSummary/commit?id="+dailyReportUploadDO.getId();
                            String res = enterpriseService.sendTWMesByDoctor(wechatId,remindDoctorDO.getId(),title,des,url);
                if (doubt==true){
                    BaseDoctorDO remindDoctorDO = baseDoctorDao.findById(dailyReportUploadDO.getDoctorId());
                    if (remindDoctorDO != null) {
                        try {
                            WxEnterpriseUserDO enterpriseUserDO = wxEnterpriseUserDao.findByEnterpriseIdAndMobile(wechatId,remindDoctorDO.getMobile());
                            if(enterpriseUserDO==null){
                                logger.info("该用户"+doctorDO.getName()+"没有企业微信手机号,无法推送模版消息,用户ID:"+doctorDO.getId()+"wechatId:"+wechatId);
                            }else{
                                String title = "待办事项";
                                String des = "您好,"+doctorDO.getName()+"对您提交的每日日报提出"+doubtTypeName.stream().map(String::valueOf).collect(Collectors.joining("'、'"))+",请点击进行查看。";
                                String url = "https://ehr.yihu.com/hlwyy/zjxl/dailyReport/#/workSummary/commit?id="+dailyReportUploadDO.getId();
                                String res = enterpriseService.sendTWMesByDoctor(wechatId,remindDoctorDO.getId(),title,des,url);
                            }
                        }catch (Exception e){
                            e.printStackTrace();
                        }
                        }
                    }catch (Exception e){
                        e.printStackTrace();
                    }
                    }
                }
                }
            }catch (Exception e){
            }catch (Exception e){
@ -717,7 +719,7 @@ public class DailyReportUploadService {
                    }else{
                    }else{
                        String title = "日报反馈";
                        String title = "日报反馈";
                        String des = "您好,"+doctorDO.getName()+"对您发起"+urgingRecordDOS.size()+"项加急待办事项,请点击进行查看。";
                        String des = "您好,"+doctorDO.getName()+"对您发起"+urgingRecordDOS.size()+"项加急待办事项,请点击进行查看。";
                        String url = "https://ehr.yihu.com/hlwyy/zjxl/dailyReport/#/workSummary/urge?code="+code;
                        String url = "https://ehr.yihu.com/hlwyy/zjxl/dailyReport/#/workSummary/urge?id="+code;
                        String res = enterpriseService.sendTWMesByDoctor(wechatId,remindDoctorDO.getId(),title,des,url);
                        String res = enterpriseService.sendTWMesByDoctor(wechatId,remindDoctorDO.getId(),title,des,url);
                    }
                    }
                }catch (Exception e){
                }catch (Exception e){
@ -1395,7 +1397,7 @@ public class DailyReportUploadService {
            String doubtSql = " select count(distinct rd.id) as 'total' from base_doctor_daily_report_upload up " +
            String doubtSql = " select count(distinct rd.id) as 'total' from base_doctor_daily_report_upload up " +
                    " inner join base_doctor d on up.doctor_id = d.id and d.del=1 and d.identity=0 " +
                    " inner join base_doctor d on up.doctor_id = d.id and d.del=1 and d.identity=0 " +
                    " inner join base_daily_report_detail rd on up.id = rd.report_id  " +
                    " inner join base_daily_report_detail rd on up.id = rd.report_id  " +
                    "  where rd.doubt=1 and up.report_date >='" + date + "' and up.report_date<='" + date + "' and up.state=1  ";
                    "  where  up.report_date >='" + date + "' and up.report_date<='" + date + "' and up.state=1  ";
            String deptCondition = "";
            String deptCondition = "";
            if (StringUtils.isNoneBlank(dept)) {
            if (StringUtils.isNoneBlank(dept)) {
@ -1408,11 +1410,7 @@ public class DailyReportUploadService {
                doubtSql += " and d.id IN " + deptCondition;
                doubtSql += " and d.id IN " + deptCondition;
            }
            }
            if (null!=doubtType){
            if (null!=doubtType){
                if (0==doubtType){
                    doubtSql += " and rd.doubt_type is not null ";
                }else{
                    doubtSql += " and rd.doubt_type='"+doubtType+"' ";
                }
                 doubtSql += " and rd.doubt_type='"+doubtType+"' ";
            }
            }
            if (StringUtils.isNoneBlank(name)) {
            if (StringUtils.isNoneBlank(name)) {
                doubtSql += " and d.name LIKE  '%" + name + "%' ";
                doubtSql += " and d.name LIKE  '%" + name + "%' ";
@ -1471,7 +1469,7 @@ public class DailyReportUploadService {
                    " from base_doctor_daily_report_upload up " +
                    " from base_doctor_daily_report_upload up " +
                    " inner join base_doctor d on up.doctor_id = d.id and d.del=1 and d.identity=0 " +
                    " inner join base_doctor d on up.doctor_id = d.id and d.del=1 and d.identity=0 " +
                    " inner join base_daily_report_detail rd on up.id = rd.report_id  " +
                    " inner join base_daily_report_detail rd on up.id = rd.report_id  " +
                    "  where rd.doubt=1 and up.report_date >='" + date + "' and up.report_date<='" + date + "' and up.state=1  ";
                    "  where up.report_date >='" + date + "' and up.report_date<='" + date + "' and up.state=1  ";
            String deptCondition = "";
            String deptCondition = "";
            if (StringUtils.isNoneBlank(dept)) {
            if (StringUtils.isNoneBlank(dept)) {
@ -1484,11 +1482,7 @@ public class DailyReportUploadService {
                doubtSql += " and d.id IN " + deptCondition;
                doubtSql += " and d.id IN " + deptCondition;
            }
            }
            if (null!=doubtType){
            if (null!=doubtType){
                if(0==doubtType){
                    doubtSql += " and rd.doubt_type is not null ";
                }else {
                    doubtSql += " and rd.doubt_type='"+doubtType+"' ";
                }
                doubtSql += " and rd.doubt_type='"+doubtType+"' ";
            }
            }
            if (StringUtils.isNoneBlank(name)) {
            if (StringUtils.isNoneBlank(name)) {
                doubtSql += " and d.name LIKE  '%" + name + "%' ";
                doubtSql += " and d.name LIKE  '%" + name + "%' ";
@ -1514,7 +1508,6 @@ public class DailyReportUploadService {
                        map.put("doubt_state", "存疑未核实");
                        map.put("doubt_state", "存疑未核实");
                    }
                    }
                }
                }
                map.put("doubt_type", "");
                if (StringUtils.isNotBlank(doubt_type)){
                if (StringUtils.isNotBlank(doubt_type)){
                    map.put("doubt_type",null==doubtTypeObj.get("doubt_type")?"":doubtTypeObj.get("doubt_type").toString());
                    map.put("doubt_type",null==doubtTypeObj.get("doubt_type")?"":doubtTypeObj.get("doubt_type").toString());
                }
                }
@ -2328,7 +2321,7 @@ public class DailyReportUploadService {
    /**
    /**
     * 管理员获取所有日报项目
     * 管理员获取所有日报项目
     */
     */
    public List<BaseDailyReportItemDO> findReportItemListAdmin(String user,String title,String content,Integer state,String begin_time,String end_time,String createUser,String createUserName) throws Exception {
    public List<BaseDailyReportItemDO> findReportItemListAdmin(String user,String projectCode,String title,String content,Integer state,String begin_time,String end_time,String createUser,String createUserName) throws Exception {
        String sql = " select * from base_doctor_role where doctor_code='"+user+"' ";
        String sql = " select * from base_doctor_role where doctor_code='"+user+"' ";
        List<Map<String,Object>> userRoles = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> userRoles = jdbcTemplate.queryForList(sql);
        if (userRoles.size()==0){
        if (userRoles.size()==0){
@ -2336,6 +2329,9 @@ public class DailyReportUploadService {
        }
        }
        List<BaseDailyReportItemDO> itemDOS = new ArrayList<>();
        List<BaseDailyReportItemDO> itemDOS = new ArrayList<>();
        sql = " select i.* from base_daily_report_item i where 1=1 and i.del=1 ";
        sql = " select i.* from base_daily_report_item i where 1=1 and i.del=1 ";
        if(StringUtils.isNotBlank(projectCode)){
            sql += " and i.project_code='"+projectCode+"' ";
        }
        if (StringUtils.isNotBlank(title)){
        if (StringUtils.isNotBlank(title)){
            sql +=" and i.title like '%"+title+"%' ";
            sql +=" and i.title like '%"+title+"%' ";
        }
        }
@ -2409,12 +2405,32 @@ public class DailyReportUploadService {
    /**
    /**
     * 管理员日报项目统计一级
     * 管理员日报项目统计一级
     */
     */
    public List<Map<String,Object>> statisticReportProjectList(String user, String projectCode,String startDate, String endDate,String dept,String member) throws Exception {
    public List<JSONObject> statisticReportProjectList(String user, String projectCode,String startDate, String endDate,String dept,String member) throws Exception {
        //判断导出人权限
        String sql = " select * from base_doctor_role where doctor_code='"+user+"' ";
        String sql = " select * from base_doctor_role where doctor_code='"+user+"' ";
        List<Map<String,Object>> userRoles = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> userRoles = jdbcTemplate.queryForList(sql);
        if (userRoles.size()==0){
        if (userRoles.size()==0){
            throw new Exception("您无权限操作");
            throw new Exception("您无权限操作");
        }else {
            String role_code = userRoles.get(0).get("role_code").toString();
            if ("admin".equals(role_code)){
            } else if ("deptAdmin".equals(role_code)) {//查询出管理员所在部门
                if(StringUtils.isBlank(dept)){
                    sql = " select dh.dept_code from base_doctor doc INNER JOIN base_doctor_hospital dh on doc.id = dh.doctor_code " +
                            " and doc.del=1 and dh.del=1 where doc.id='"+user+"' ";
                    List<String> userDept = jdbcTemplate.queryForList(sql,String.class);
                    if (userDept.size()>0){
                        dept = userDept.get(0);
                    }else {
                        throw new Exception("您无权限操作");
                    }
                }
            }else {
                throw new Exception("您无权限操作");
            }
        }
        }
        String sqlCondition = "  ";
        String sqlCondition = "  ";
        if (StringUtils.isNotBlank(startDate)){
        if (StringUtils.isNotBlank(startDate)){
@ -2427,34 +2443,95 @@ public class DailyReportUploadService {
            sqlCondition += " and i.project_code='"+projectCode+"' ";
            sqlCondition += " and i.project_code='"+projectCode+"' ";
        }
        }
        if (StringUtils.isNotBlank(dept)){//查询指定部门
        if (StringUtils.isNotBlank(dept)){//查询指定部门
            sqlCondition += "  and i.dept='"+dept+"' ";
            sqlCondition += "  and dh.dept_code='"+dept+"' ";
        }
        }
        if (StringUtils.isNotBlank(member)){//查询指定员工
        if (StringUtils.isNotBlank(member)){//查询指定员工
            sqlCondition += " and up.doctor_id='"+member+"' ";
            sqlCondition += " and up.doctor_id='"+member+"' ";
        }
        }
        String sqlList = "  select dict.dict_code project_code,dict.dict_value projectName,IFNULL( A.completionHour,0) 'completionHour', " +
        String sqlList = "  select dict.dict_code project_code,dict.dict_value projectName,IFNULL( A.completionHour,0) 'completionHour', " +
                " IFNULL(A.doctorTotal,0) 'doctorTotal' from wlyy_hospital_sys_dict dict " +
                " IFNULL(A.doctorTotal,0) 'doctorTotal',B.dict_code 'categoryCode',B.dict_value 'categoryName',C.dict_code 'levelCode' ,C.dict_value 'levelName' from wlyy_hospital_sys_dict dict " +
                " Left JOIN (" +
                " Left JOIN (" +
                " select i.project_code,CAST((sum(IFNULL(de.actual_completion_hour,IFNULL(de.completion_hour,'0')))) as char ) as completionHour, " +
                " 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 from base_daily_report_item i LEFT JOIN base_daily_report_detail de on i.id = de.report_item_id " +
                " count(distinct up.doctor_id) as doctorTotal 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 INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1  where i.del=1 "+sqlCondition+" GROUP BY i.project_code )A " +
                "on A.project_code = dict.dict_code where dict.dict_name='daily_report_project' ";
                " INNER JOIN base_doctor_daily_report_upload up on up.id = de.report_id INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1 " +
                "  INNER JOIN base_doctor_hospital dh on doc.id = dh.doctor_code and dh.del=1  where i.del=1 "+sqlCondition+" GROUP BY i.project_code )A " +
                "on A.project_code = dict.dict_code " +
                " INNER JOIN ( select dict_code,dict_value,sort from wlyy_hospital_sys_dict where dict_name='daily_report_category' )B on dict.saas_id = B.dict_code  " +
                " INNER JOIN ( select dict_code,dict_value,sort from wlyy_hospital_sys_dict where dict_name='daily_report_level' )C on dict.py_code = C.dict_code " +
                " where dict.dict_name='daily_report_project' ";
        if (StringUtils.isNotBlank(projectCode)){
        if (StringUtils.isNotBlank(projectCode)){
            sqlList +=" and dict.dict_code='"+projectCode+"' ";
            sqlList +=" and dict.dict_code='"+projectCode+"' ";
        }
        }
        sqlList += "  order by sort, completionHour desc ";
        return jdbcTemplate.queryForList(sqlList);
        sqlList += "  order by B.sort asc, c.sort asc,completionHour desc ";
        List<Map<String,Object>> sqlResult =  jdbcTemplate.queryForList(sqlList);
        List<JSONObject> result = new ArrayList<>();
        if (sqlResult.size()>0){
            Map<String,List<Map<String,Object>>> sqlResultMap = sqlResult.stream().collect(Collectors.groupingBy(e -> e.get("categoryCode").toString()));
            for (String key: sqlResultMap.keySet()){
                JSONObject categoryTmp = new JSONObject();
                sql = " select dict_code,dict_value,sort from wlyy_hospital_sys_dict where dict_name='daily_report_category' and dict_code='"+key+"' ";
                Map<String,Object> dictValue = jdbcTemplate.queryForMap(sql);
                categoryTmp.put("categoryName",dictValue.get("dict_value"));
                categoryTmp.put("categoryCode",key);
                categoryTmp.put("sort",dictValue.get("sort"));
                JSONArray categoryList = new JSONArray();
                List<Map<String,Object>> listTmp = sqlResultMap.get(key);
                if (listTmp.size()>0){
                    Map<String,List<Map<String,Object>>> sqlResultMap2 = listTmp.stream().collect(Collectors.groupingBy(e -> e.get("levelCode").toString()));
                    for (String key2: sqlResultMap2.keySet()){
                        JSONObject levelTmp = new JSONObject();
                        sql = " select dict_code,dict_value,sort from wlyy_hospital_sys_dict where dict_name='daily_report_level' and dict_code='"+key2+"' ";
                        dictValue = jdbcTemplate.queryForMap(sql);
                        levelTmp.put("levelName",dictValue.get("dict_value"));
                        levelTmp.put("levelCode",key2);
                        levelTmp.put("sort",dictValue.get("sort"));
                        List<Map<String,Object>> listTmp2 = sqlResultMap2.get(key2);
                        levelTmp.put("value",listTmp2);
                        categoryList.add(levelTmp);
                    }
                }
                categoryTmp.put("value",categoryList);
                if (categoryList.size()>0){
                    categoryList.sort(Comparator.comparing(e->((JSONObject)e).getString("sort")));
                }
                result.add(categoryTmp);
            }
        }
        if (result.size()>0){
            result.sort(Comparator.comparing(e->e.getString("sort")));
        }
        return result;
    }
    }
    /**
    /**
     * 管理员日报项目统计二级
     * 管理员日报项目统计二级
     */
     */
    public List<Map<String,Object>> statisticReportProjectDeptList(String user, String projectCode,String startDate, String endDate,String dept,String member) throws Exception {
    public List<Map<String,Object>> statisticReportProjectDeptList(String user, String projectCode,String startDate, String endDate,String dept,String member) throws Exception {
        //判断导出人权限
        String sql = " select * from base_doctor_role where doctor_code='"+user+"' ";
        String sql = " select * from base_doctor_role where doctor_code='"+user+"' ";
        List<Map<String,Object>> userRoles = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> userRoles = jdbcTemplate.queryForList(sql);
        if (userRoles.size()==0){
        if (userRoles.size()==0){
            throw new Exception("您无权限操作");
            throw new Exception("您无权限操作");
        }else {
            String role_code = userRoles.get(0).get("role_code").toString();
            if ("admin".equals(role_code)){
            } else if ("deptAdmin".equals(role_code)) {//查询出管理员所在部门
                if(StringUtils.isBlank(dept)){
                    sql = " select dh.dept_code from base_doctor doc INNER JOIN base_doctor_hospital dh on doc.id = dh.doctor_code " +
                            " and doc.del=1 and dh.del=1 where doc.id='"+user+"' ";
                    List<String> userDept = jdbcTemplate.queryForList(sql,String.class);
                    if (userDept.size()>0){
                        dept = userDept.get(0);
                    }else {
                        throw new Exception("您无权限操作");
                    }
                }
            }else {
                throw new Exception("您无权限操作");
            }
        }
        }
        String sqlCondition = "  ";
        String sqlCondition = "  ";
        if (StringUtils.isNotBlank(startDate)){
        if (StringUtils.isNotBlank(startDate)){
@ -2467,14 +2544,15 @@ public class DailyReportUploadService {
            sqlCondition += " and i.project_code='"+projectCode+"' ";
            sqlCondition += " and i.project_code='"+projectCode+"' ";
        }
        }
        if (StringUtils.isNotBlank(dept)){//查询指定部门
        if (StringUtils.isNotBlank(dept)){//查询指定部门
            sqlCondition += "  and i.dept='"+dept+"' ";
            sqlCondition += "  and dh.dept_code='"+dept+"' ";
        }
        }
        if (StringUtils.isNotBlank(member)){//查询指定员工
        if (StringUtils.isNotBlank(member)){//查询指定员工
            sqlCondition += " and up.doctor_id='"+member+"' ";
            sqlCondition += " and up.doctor_id='"+member+"' ";
        }
        }
        String sqlList = " select i.dept,i.dept_name deptName,i.project_code,CAST((sum(IFNULL(de.actual_completion_hour,IFNULL(de.completion_hour,'0')))) as char ) as completionHour, " +
        String sqlList = " select i.dept,i.dept_name deptName,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 from base_daily_report_item i LEFT JOIN base_daily_report_detail de on i.id = de.report_item_id " +
                " count(distinct up.doctor_id) as doctorTotal 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 INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1  where i.del=1 "+sqlCondition+" GROUP BY i.project_code,i.dept  ";
                " INNER JOIN base_doctor_daily_report_upload up on up.id = de.report_id INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1 " +
                "  INNER JOIN base_doctor_hospital dh on doc.id = dh.doctor_code and dh.del=1  where i.del=1 "+sqlCondition+" GROUP BY i.project_code,i.dept  ";
        sqlList += "  order by  completionHour desc ";
        sqlList += "  order by  completionHour desc ";
        return jdbcTemplate.queryForList(sqlList);
        return jdbcTemplate.queryForList(sqlList);
@ -2487,13 +2565,34 @@ public class DailyReportUploadService {
                                               String startDate, String endDate, String createUser,String createUserName, Integer page, Integer size,
                                               String startDate, String endDate, String createUser,String createUserName, Integer page, Integer size,
                                               String dept,String member) throws Exception {
                                               String dept,String member) throws Exception {
        page = page>0?page-1:0;
        page = page>0?page-1:0;
        //判断导出人权限
        String sql = " select * from base_doctor_role where doctor_code='"+user+"' ";
        String sql = " select * from base_doctor_role where doctor_code='"+user+"' ";
        List<Map<String,Object>> userRoles = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> userRoles = jdbcTemplate.queryForList(sql);
        if (userRoles.size()==0){
        if (userRoles.size()==0){
            throw new Exception("您无权限操作");
            throw new Exception("您无权限操作");
        }else {
            String role_code = userRoles.get(0).get("role_code").toString();
            if ("admin".equals(role_code)){
            } else if ("deptAdmin".equals(role_code)) {//查询出管理员所在部门
                if(StringUtils.isBlank(dept)){
                    sql = " select dh.dept_code from base_doctor doc INNER JOIN base_doctor_hospital dh on doc.id = dh.doctor_code " +
                            " and doc.del=1 and dh.del=1 where doc.id='"+user+"' ";
                    List<String> userDept = jdbcTemplate.queryForList(sql,String.class);
                    if (userDept.size()>0){
                        dept = userDept.get(0);
                    }else {
                        throw new Exception("您无权限操作");
                    }
                }
            }else {
                throw new Exception("您无权限操作");
            }
        }
        }
        List<Map<String,Object>> itemDOS = new ArrayList<>();
        List<Map<String,Object>> itemDOS = new ArrayList<>();
        String sqlCondition = "  ";
        String updateTimeSql="";
        String updateTimeSql="";
        if (StringUtils.isNotBlank(startDate)){
        if (StringUtils.isNotBlank(startDate)){
            updateTimeSql += " and up.report_date>='"+startDate+"' ";
            updateTimeSql += " and up.report_date>='"+startDate+"' ";
@ -2504,16 +2603,23 @@ public class DailyReportUploadService {
        if (StringUtils.isNotBlank(member)){
        if (StringUtils.isNotBlank(member)){
            updateTimeSql +=  " and up.doctor_id='"+member+"' ";
            updateTimeSql +=  " and up.doctor_id='"+member+"' ";
        }
        }
        if (StringUtils.isNotBlank(dept)){//查询指定部门
            updateTimeSql += "  and dh.dept_code='"+dept+"' ";
        }
        String sqlList = " select i.id,CONCAT(i.title,'(',i.dept_name,')') title,i.content,i.state,i.begin_time beginTime,i.end_time endTime, " +
        String sqlList = " 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,IFNULL(A.completionHour,'0') completionHour ,IFNULL(A.doctorTotal,0) doctorTotal " +
                " from base_daily_report_item i  LEFT JOIN( " +
                " i.create_user_name createUserName,IFNULL(A.completionHour,'0') completionHour ,IFNULL(A.doctorTotal,0) doctorTotal ";
        String sqlCount = " select count(distinct i.id)  ";
        String sqlCondition = " from base_daily_report_item i  LEFT JOIN( " +
                " select de.report_item_id,CAST((sum(IFNULL(de.actual_completion_hour,IFNULL(de.completion_hour,'0')))) as char ) as completionHour, " +
                " select de.report_item_id,CAST((sum(IFNULL(de.actual_completion_hour,IFNULL(de.completion_hour,'0')))) as char ) as completionHour, " +
                " count(distinct up.doctor_id) as doctorTotal " +
                " count(distinct up.doctor_id) as doctorTotal " +
                "  from base_daily_report_detail de Inner JOIN base_doctor_daily_report_upload up on up.id = de.report_id INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1 " +updateTimeSql+
                "  from base_daily_report_detail de Inner JOIN base_doctor_daily_report_upload up on up.id = de.report_id INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1 " +
                "  INNER JOIN base_doctor_hospital dh on doc.id = dh.doctor_code and dh.del=1 " +updateTimeSql+
                "  group by de.report_item_id " +
                "  group by de.report_item_id " +
                " )A on i.id = A.report_item_id where i.del=1 ";
                " )A on i.id = A.report_item_id where i.del=1 ";
        String sqlCount = " select count(distinct i.id) from base_daily_report_item i where i.del=1 ";
        if (StringUtils.isNotBlank(title)){
        if (StringUtils.isNotBlank(title)){
            sqlCondition +=" and i.title like '%"+title+"%' ";
            sqlCondition +=" and i.title like '%"+title+"%' ";
        }
        }
@ -2532,15 +2638,11 @@ public class DailyReportUploadService {
        if (StringUtils.isNotBlank(projectCode)){
        if (StringUtils.isNotBlank(projectCode)){
            sqlCondition += " and i.project_code='"+projectCode+"' ";
            sqlCondition += " and i.project_code='"+projectCode+"' ";
        }
        }
        if (StringUtils.isNotBlank(dept)){//查询指定部门
            sqlCondition += "  and i.dept='"+dept+"' ";
        }
        if (StringUtils.isNotBlank(member)){
        if (StringUtils.isNotBlank(member)){
            sqlCondition += "  and exists (select 1 from base_daily_report_item_members mem " +
            sqlCondition += "  and exists (select 1 from base_daily_report_item_members mem " +
                    " INNER JOIN base_doctor doc on mem.user_id = doc.id and doc.del=1 " +
                    " INNER JOIN base_doctor doc on mem.user_id = doc.id and doc.del=1 " +
                    " where i.id =mem.report_item_id and mem.user_id='"+member+"' and mem.del=1  )";
                    " where i.id =mem.report_item_id and mem.user_id='"+member+"' and mem.del=1  )";
        }
        }
        sqlList +=sqlCondition+ " group by i.id order by i.create_time,i.id desc limit "+page*size+","+size;
        sqlList +=sqlCondition+ " group by i.id order by i.create_time,i.id desc limit "+page*size+","+size;
        itemDOS = jdbcTemplate.queryForList(sqlList);
        itemDOS = jdbcTemplate.queryForList(sqlList);
        Long count = jdbcTemplate.queryForObject(sqlCount+sqlCondition,Long.class);
        Long count = jdbcTemplate.queryForObject(sqlCount+sqlCondition,Long.class);
@ -2549,11 +2651,32 @@ public class DailyReportUploadService {
    public List<Map<String,Object>> statisticReportItemById(String user,String item_id,Integer type,String startDate,String endDate,
    public List<Map<String,Object>> statisticReportItemById(String user,String item_id,Integer type,String startDate,String endDate,
                                                            String dept,String member) throws Exception {
                                                            String dept,String member) throws Exception {
        //判断导出人权限
        String sql = " select * from base_doctor_role where doctor_code='"+user+"' ";
        String sql = " select * from base_doctor_role where doctor_code='"+user+"' ";
        List<Map<String,Object>> userRoles = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> userRoles = jdbcTemplate.queryForList(sql);
        if (userRoles.size()==0){
        if (userRoles.size()==0){
            throw new Exception("您无权限操作");
            throw new Exception("您无权限操作");
        }else {
            String role_code = userRoles.get(0).get("role_code").toString();
            if ("admin".equals(role_code)){
            } else if ("deptAdmin".equals(role_code)) {//查询出管理员所在部门
                if(StringUtils.isBlank(dept)){
                    sql = " select dh.dept_code from base_doctor doc INNER JOIN base_doctor_hospital dh on doc.id = dh.doctor_code " +
                            " and doc.del=1 and dh.del=1 where doc.id='"+user+"' ";
                    List<String> userDept = jdbcTemplate.queryForList(sql,String.class);
                    if (userDept.size()>0){
                        dept = userDept.get(0);
                    }else {
                        throw new Exception("您无权限操作");
                    }
                }
            }else {
                throw new Exception("您无权限操作");
            }
        }
        }
        String updateTimeSql = " ";
        String updateTimeSql = " ";
        String itemSql = " ";
        String itemSql = " ";
        if (StringUtils.isNotBlank(startDate)){
        if (StringUtils.isNotBlank(startDate)){
@ -2566,27 +2689,30 @@ public class DailyReportUploadService {
            updateTimeSql +=  " and up.doctor_id='"+member+"' ";
            updateTimeSql +=  " and up.doctor_id='"+member+"' ";
        }
        }
        if (StringUtils.isNotBlank(dept)){
        if (StringUtils.isNotBlank(dept)){
            itemSql += " and i.dept='"+dept+"' ";
            itemSql += " and dh.dept_code='"+dept+"' ";
        }
        }
        if(1==type){//天
        if(1==type){//天
            sql = " 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, " +
            sql = " 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, " +
                    " CAST((sum(IFNULL(de.actual_completion_hour,IFNULL(de.completion_hour,'0')))) as char ) as completionHour,DATE_FORMAT(de.create_time,'%Y-%m-%d') as 'time', " +
                    " CAST((sum(IFNULL(de.actual_completion_hour,IFNULL(de.completion_hour,'0')))) as char ) as completionHour,DATE_FORMAT(de.create_time,'%Y-%m-%d') as 'time', " +
                    " count(distinct up.doctor_id) as doctorTotal from base_daily_report_item i LEFT JOIN base_daily_report_detail de " +
                    " count(distinct up.doctor_id) as doctorTotal 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 INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1 " +updateTimeSql+
                    "on i.id = de.report_item_id INNER JOIN base_doctor_daily_report_upload up on up.id = de.report_id INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1 " +
                    "  INNER JOIN base_doctor_hospital dh on doc.id = dh.doctor_code and dh.del=1 " +updateTimeSql+
                    "where 1=1 and i.id='"+item_id+"' " +itemSql+
                    "where 1=1 and i.id='"+item_id+"' " +itemSql+
                    "group by i.id,DATE_FORMAT(de.create_time,'%Y-%m-%d') order by time asc ";
                    "group by i.id,DATE_FORMAT(de.create_time,'%Y-%m-%d') order by time asc ";
        }else if (2==type){//按周
        }else if (2==type){//按周
            sql = " 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, " +
            sql = " 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, " +
                    " CAST((sum(IFNULL(de.actual_completion_hour,IFNULL(de.completion_hour,'0')))) as char ) as completionHour,DATE_FORMAT(de.create_time,'%Y-%m-%d') as 'time', " +
                    " CAST((sum(IFNULL(de.actual_completion_hour,IFNULL(de.completion_hour,'0')))) as char ) as completionHour,DATE_FORMAT(de.create_time,'%Y-%m-%d') as 'time', " +
                    " count(distinct up.doctor_id) as doctorTotal from base_daily_report_item i LEFT JOIN base_daily_report_detail de " +
                    " count(distinct up.doctor_id) as doctorTotal 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 INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1 " +updateTimeSql+
                    "on i.id = de.report_item_id INNER JOIN base_doctor_daily_report_upload up on up.id = de.report_id INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1 " +
                    "  INNER JOIN base_doctor_hospital dh on doc.id = dh.doctor_code and dh.del=1 " +updateTimeSql+
                    "where 1=1 and i.id='"+item_id+"' " +itemSql+
                    "where 1=1 and i.id='"+item_id+"' " +itemSql+
                    "group by i.id,DATE_FORMAT(de.create_time,'%Y%v') order by time asc ";
                    "group by i.id,DATE_FORMAT(de.create_time,'%Y%v') order by time asc ";
        }else if (3==type){//月
        }else if (3==type){//月
            sql = " 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, " +
            sql = " 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, " +
                    " CAST((sum(IFNULL(de.actual_completion_hour,IFNULL(de.completion_hour,'0')))) as char ) as completionHour,DATE_FORMAT(de.create_time,'%Y-%m') as 'time', " +
                    " CAST((sum(IFNULL(de.actual_completion_hour,IFNULL(de.completion_hour,'0')))) as char ) as completionHour,DATE_FORMAT(de.create_time,'%Y-%m') as 'time', " +
                    " count(distinct up.doctor_id) as doctorTotal from base_daily_report_item i LEFT JOIN base_daily_report_detail de " +
                    " count(distinct up.doctor_id) as doctorTotal 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 INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1 " +updateTimeSql+
                    "on i.id = de.report_item_id INNER JOIN base_doctor_daily_report_upload up  on up.id = de.report_id INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1 " +
                    "  INNER JOIN base_doctor_hospital dh on doc.id = dh.doctor_code and dh.del=1 " +updateTimeSql+
                    "where 1=1 and i.id='"+item_id+"' " +itemSql+
                    "where 1=1 and i.id='"+item_id+"' " +itemSql+
                    "group by i.id,DATE_FORMAT(de.create_time,'%Y-%m') order by time asc ";
                    "group by i.id,DATE_FORMAT(de.create_time,'%Y-%m') order by time asc ";
        }else {
        }else {
@ -2648,11 +2774,14 @@ public class DailyReportUploadService {
    }
    }
    public List<Map<String,Object>> statisticReportItemMembersById(String user,String item_id,Integer type,String member,String startDate,String endDate ) throws Exception {
    public List<Map<String,Object>> statisticReportItemMembersById(String user,String item_id,Integer type,String member,String startDate,String endDate ) throws Exception {
        //判断导出人权限
        String sql = " select * from base_doctor_role where doctor_code='"+user+"' ";
        String sql = " select * from base_doctor_role where doctor_code='"+user+"' ";
        List<Map<String,Object>> userRoles = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> userRoles = jdbcTemplate.queryForList(sql);
        if (userRoles.size()==0){
        if (userRoles.size()==0){
            throw new Exception("您无权限操作");
            throw new Exception("您无权限操作");
        }
        }
        String memberSql = " ";
        String memberSql = " ";
        if (StringUtils.isNotBlank(member)){
        if (StringUtils.isNotBlank(member)){
            memberSql = " and up.doctor_id='"+member+"' ";
            memberSql = " and up.doctor_id='"+member+"' ";
@ -2782,11 +2911,32 @@ public class DailyReportUploadService {
     * 获取某个部门的项目趋势图一级
     * 获取某个部门的项目趋势图一级
     */
     */
    public List<Map<String,Object>> statisticDeptProjectTrend(String user,String dept,String startDate,String endDate,Integer type) throws Exception {
    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+"' ";
        String sql = " select * from base_doctor_role where doctor_code='"+user+"' ";
        List<Map<String,Object>> userRoles = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> userRoles = jdbcTemplate.queryForList(sql);
        if (userRoles.size()==0){
        if (userRoles.size()==0){
            throw new Exception("您无权限操作");
            throw new Exception("您无权限操作");
        }else {
            String role_code = userRoles.get(0).get("role_code").toString();
            if ("admin".equals(role_code)){
            } else if ("deptAdmin".equals(role_code)) {//查询出管理员所在部门
                if(StringUtils.isBlank(dept)){
                    sql = " select dh.dept_code from base_doctor doc INNER JOIN base_doctor_hospital dh on doc.id = dh.doctor_code " +
                            " and doc.del=1 and dh.del=1 where doc.id='"+user+"' ";
                    List<String> userDept = jdbcTemplate.queryForList(sql,String.class);
                    if (userDept.size()>0){
                        dept = userDept.get(0);
                    }else {
                        throw new Exception("您无权限操作");
                    }
                }
            }else {
                throw new Exception("您无权限操作");
            }
        }
        }
        String sqlCondition = "  ";
        String sqlCondition = "  ";
        if (StringUtils.isNotBlank(startDate)){
        if (StringUtils.isNotBlank(startDate)){
            sqlCondition += " and up.report_date>='"+startDate+"' ";
            sqlCondition += " and up.report_date>='"+startDate+"' ";
@ -2795,7 +2945,7 @@ public class DailyReportUploadService {
            sqlCondition += " and up.report_date<='"+endDate+"' ";
            sqlCondition += " and up.report_date<='"+endDate+"' ";
        }
        }
        if(StringUtils.isNotBlank(dept)){
        if(StringUtils.isNotBlank(dept)){
            sqlCondition += " and i.dept='"+dept+"' ";
            sqlCondition += " and dh.dept_code='"+dept+"' ";
        }
        }
        String groupTimeFormat = "";
        String groupTimeFormat = "";
        String uploadTimeFormat = "";
        String uploadTimeFormat = "";
@ -2822,11 +2972,20 @@ public class DailyReportUploadService {
            projectSql += "   and i.dept='"+dept+"'";
            projectSql += "   and i.dept='"+dept+"'";
        }
        }
        projectSql +="GROUP BY dict.dict_code ";
        projectSql +="GROUP BY dict.dict_code ";
        projectSql += " union "+
                " select i.project_code,i.project_name projectName" +
                " 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 INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1 \n" +
                "  INNER JOIN base_doctor_hospital dh on doc.id = dh.doctor_code and dh.del=1 where i.del=1  " +sqlCondition+
                " GROUP BY i.id ";
        List<Map<String,Object>> deptProjectList = jdbcTemplate.queryForList(projectSql);
        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,  " +
        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' " +
                " 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  " +
                " 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 INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1  where i.del=1  and i.project_code='{project_code}'  "+sqlCondition+
                " INNER JOIN base_doctor_daily_report_upload up on up.id = de.report_id INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1  " +
                " INNER JOIN base_doctor_hospital dh on doc.id = dh.doctor_code and dh.del=1 where i.del=1  and i.project_code='{project_code}'  "+sqlCondition+
                " GROUP BY "+groupTimeFormat+" order by time asc";
                " GROUP BY "+groupTimeFormat+" order by time asc";
        for (Map<String,Object>tmp:deptProjectList){
        for (Map<String,Object>tmp:deptProjectList){
            String project_code = tmp.get("project_code").toString();
            String project_code = tmp.get("project_code").toString();
@ -2860,11 +3019,32 @@ public class DailyReportUploadService {
     * 获取某个部门的某个项目详情趋势图二级
     * 获取某个部门的某个项目详情趋势图二级
     */
     */
    public List<Map<String,Object>> statisticDeptProjectItemTrend(String user,String dept,String projectCode,String startDate,String endDate,Integer type) throws Exception {
    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+"' ";
        String sql = " select * from base_doctor_role where doctor_code='"+user+"' ";
        List<Map<String,Object>> userRoles = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> userRoles = jdbcTemplate.queryForList(sql);
        if (userRoles.size()==0){
        if (userRoles.size()==0){
            throw new Exception("您无权限操作");
            throw new Exception("您无权限操作");
        }else {
            String role_code = userRoles.get(0).get("role_code").toString();
            if ("admin".equals(role_code)){
            } else if ("deptAdmin".equals(role_code)) {//查询出管理员所在部门
                if(StringUtils.isBlank(dept)){
                    sql = " select dh.dept_code from base_doctor doc INNER JOIN base_doctor_hospital dh on doc.id = dh.doctor_code " +
                            " and doc.del=1 and dh.del=1 where doc.id='"+user+"' ";
                    List<String> userDept = jdbcTemplate.queryForList(sql,String.class);
                    if (userDept.size()>0){
                        dept = userDept.get(0);
                    }else {
                        throw new Exception("您无权限操作");
                    }
                }
            }else {
                throw new Exception("您无权限操作");
            }
        }
        }
        String sqlCondition = "  ";
        String sqlCondition = "  ";
        if (StringUtils.isNotBlank(startDate)){
        if (StringUtils.isNotBlank(startDate)){
            sqlCondition += " and up.report_date>='"+startDate+"' ";
            sqlCondition += " and up.report_date>='"+startDate+"' ";
@ -2873,7 +3053,7 @@ public class DailyReportUploadService {
            sqlCondition += " and up.report_date<='"+endDate+"' ";
            sqlCondition += " and up.report_date<='"+endDate+"' ";
        }
        }
        if(StringUtils.isNotBlank(dept)){
        if(StringUtils.isNotBlank(dept)){
            sqlCondition+= " and i.dept='"+dept+"' ";
            sqlCondition+= " and dh.dept_code='"+dept+"' ";
        }
        }
        String groupTimeFormat = "";
        String groupTimeFormat = "";
        String uploadTimeFormat = "";
        String uploadTimeFormat = "";
@ -2900,12 +3080,46 @@ public class DailyReportUploadService {
            projectSql+=" and  i.dept='"+dept+"' ";
            projectSql+=" and  i.dept='"+dept+"' ";
        }
        }
        projectSql +="  GROUP BY i.id ";
        projectSql +="  GROUP BY i.id ";
        projectSql += " union "+
                " 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 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 INNER JOIN base_doctor doc on up.doctor_id = doc.id " +
                " and doc.del=1    INNER JOIN base_doctor_hospital dh on doc.id = dh.doctor_code and dh.del=1 where i.del=1 and i.project_code='"+projectCode+"'  " +sqlCondition+
                " GROUP BY i.id ";
        List<Map<String,Object>> deptProjectItemList = jdbcTemplate.queryForList(projectSql);
        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,  " +
        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' " +
                " 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  " +
                " 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 INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1  where i.del=1  and i.id='{itemId}'  "+sqlCondition+
                " INNER JOIN base_doctor_daily_report_upload up on up.id = de.report_id INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1  " +
                "  INNER JOIN base_doctor_hospital dh on doc.id = dh.doctor_code and dh.del=1 where i.del=1  and i.id='{itemId}'  "+sqlCondition+
                " GROUP BY "+groupTimeFormat+" order by time asc";
                " GROUP BY "+groupTimeFormat+" order by time asc";
        Set<String> resultTimeList = new HashSet<>();
        if (deptProjectItemList.size()>0){
           if (StringUtils.isNotBlank(startDate)){
               Date startDateTmp = DateUtil.strToDate(startDate);
               Date endDateTmp = DateUtil.strToDate(endDate);
               if (type==1){
                   for (;!startDateTmp.after(endDateTmp);){
                       resultTimeList.add(DateUtil.dateToStr(startDateTmp,DateUtil.YYYY_MM_DD));
                       startDateTmp = DateUtil.getNextDay1(startDateTmp,1);
                   }
               } else if (type==2) {
                   for (;!startDateTmp.after(endDateTmp);){
                       startDateTmp = DateUtil.strToDate(DateUtil.getSundayOfThisWeek(startDateTmp));
                       resultTimeList.add(DateUtil.getSundayOfThisWeek(startDateTmp));
                       startDateTmp = DateUtil.getNextWeek(startDateTmp,1);
                   }
               }else if (type==3){
                   for (;!startDateTmp.after(endDateTmp);){
                       resultTimeList.add(DateUtil.dateToStr(startDateTmp,DateUtil.YYYY_MM));
                       startDateTmp = DateUtil.getNextMonthReturnDate(startDateTmp,1);
                   }
               }
           }
       }
        for (Map<String,Object>tmp:deptProjectItemList){
        for (Map<String,Object>tmp:deptProjectItemList){
            String itemId = tmp.get("id").toString();
            String itemId = tmp.get("id").toString();
            List<Map<String,Object>> useTimeList = jdbcTemplate.queryForList(sqlList.replace("{itemId}",itemId));
            List<Map<String,Object>> useTimeList = jdbcTemplate.queryForList(sqlList.replace("{itemId}",itemId));
@ -2915,17 +3129,37 @@ public class DailyReportUploadService {
                Double avgValue = avg.getAsDouble();
                Double avgValue = avg.getAsDouble();
                tmp.put("avgValue",avgValue);
                tmp.put("avgValue",avgValue);
                tmp.put("totalHour",totalHour);
                tmp.put("totalHour",totalHour);
                if(2==type){//获取周的最后一天
                    for (Map<String,Object>useTimeTmp :useTimeList){
                Set searchTimeList = new HashSet();
                for (Map<String,Object>useTimeTmp :useTimeList){
                    if(2==type){
                        String time = useTimeTmp.get("time").toString();
                        String time = useTimeTmp.get("time").toString();
                        String sunday = DateUtil.getSundayOfThisWeek(DateUtil.strToDate(time));
                        String sunday = DateUtil.getSundayOfThisWeek(DateUtil.strToDate(time));
                        useTimeTmp.put("time",sunday);
                        useTimeTmp.put("time",sunday);
                    }
                    }
                    String time = useTimeTmp.get("time").toString();
                    searchTimeList.add(time);
                }
                }
                if (type!=0){
                    for (String tmpTime:resultTimeList){
                        if (!searchTimeList.contains(tmpTime)){
                            Map<String,Object> mapTmp = new HashMap<>();
                            mapTmp.put("time",tmpTime);
                            mapTmp.put("completionHour",0);
                            mapTmp.put("doctorTotal",0);
                            useTimeList.add(mapTmp);
                        }
                    }
                }
            }else {
            }else {
                tmp.put("avgValue",0.0);
                tmp.put("avgValue",0.0);
                tmp.put("totalHour",0.0);
                tmp.put("totalHour",0.0);
            }
            }
            if(useTimeList.size()>0){
                useTimeList.sort(Comparator.comparing(e->e.get("time").toString()));
            }
            tmp.put("useTimeList",useTimeList);
            tmp.put("useTimeList",useTimeList);
        }
        }
        if (deptProjectItemList.size()>0){
        if (deptProjectItemList.size()>0){
@ -2938,11 +3172,32 @@ public class DailyReportUploadService {
     * 获取员工项目趋势图一级
     * 获取员工项目趋势图一级
     */
     */
    public List<Map<String,Object>> statisticDoctorProjectTrend(String user,String dept,String memberId,String startDate,String endDate,Integer type) throws Exception {
    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+"' ";
        String sql = " select * from base_doctor_role where doctor_code='"+user+"' ";
        List<Map<String,Object>> userRoles = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> userRoles = jdbcTemplate.queryForList(sql);
        if (userRoles.size()==0){
        if (userRoles.size()==0){
            throw new Exception("您无权限操作");
            throw new Exception("您无权限操作");
        }else {
            String role_code = userRoles.get(0).get("role_code").toString();
            if ("admin".equals(role_code)){
            } else if ("deptAdmin".equals(role_code)) {//查询出管理员所在部门
                if(StringUtils.isBlank(dept)){
                    sql = " select dh.dept_code from base_doctor doc INNER JOIN base_doctor_hospital dh on doc.id = dh.doctor_code " +
                            " and doc.del=1 and dh.del=1 where doc.id='"+user+"' ";
                    List<String> userDept = jdbcTemplate.queryForList(sql,String.class);
                    if (userDept.size()>0){
                        dept = userDept.get(0);
                    }else {
                        throw new Exception("您无权限操作");
                    }
                }
            }else {
                throw new Exception("您无权限操作");
            }
        }
        }
        String sqlCondition = "  ";
        String sqlCondition = "  ";
        if (StringUtils.isNotBlank(startDate)){
        if (StringUtils.isNotBlank(startDate)){
            sqlCondition += " and up.report_date>='"+startDate+"' ";
            sqlCondition += " and up.report_date>='"+startDate+"' ";
@ -2972,13 +3227,15 @@ public class DailyReportUploadService {
                " from wlyy_hospital_sys_dict dict INNER JOIN base_daily_report_item i on i.project_code = dict.dict_code " +
                " 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 " +
                " INNER JOIN base_daily_report_item_members mem on i.id =mem.report_item_id " +
                " INNER JOIN base_doctor doc on mem.user_id = doc.id and doc.del=1 " +
                " INNER JOIN base_doctor doc on mem.user_id = doc.id and doc.del=1 " +
                " where dict.dict_name='daily_report_project' and i.dept='"+dept+"'  and mem.user_id='"+memberId+"' and mem.del=1 " +
                " INNER JOIN base_doctor_hospital dh on doc.id = dh.doctor_code and dh.del=1 " +
                " where dict.dict_name='daily_report_project' and dh.dept_code='"+dept+"'  and mem.user_id='"+memberId+"' and mem.del=1 " +
                " GROUP BY dict.dict_code; ";
                " GROUP BY dict.dict_code; ";
        List<Map<String,Object>> deptProjectList = jdbcTemplate.queryForList(projectSql);
        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,  " +
        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' " +
                " 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  " +
                " 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 INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1  where up.doctor_id='"+memberId+"' and i.del=1 and i.dept='"+dept+"' and i.project_code='{project_code}'  "+sqlCondition+
                " INNER JOIN base_doctor_daily_report_upload up on up.id = de.report_id INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1 " +
                " INNER JOIN base_doctor_hospital dh on doc.id = dh.doctor_code and dh.del=1 where up.doctor_id='"+memberId+"' and i.del=1 and dh.dept_code='"+dept+"' and i.project_code='{project_code}'  "+sqlCondition+
                " GROUP BY "+groupTimeFormat+" order by time asc";
                " GROUP BY "+groupTimeFormat+" order by time asc";
        for (Map<String,Object>tmp:deptProjectList){
        for (Map<String,Object>tmp:deptProjectList){
            String project_code = tmp.get("project_code").toString();
            String project_code = tmp.get("project_code").toString();
@ -3012,11 +3269,31 @@ public class DailyReportUploadService {
     * 获取员工某个项目详情趋势图二级
     * 获取员工某个项目详情趋势图二级
     */
     */
    public List<Map<String,Object>> statisticDoctorProjectItemTrend(String user,String dept,String memberId,String projectCode,String startDate,String endDate,Integer type) throws Exception {
    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+"' ";
        String sql = " select * from base_doctor_role where doctor_code='"+user+"' ";
        List<Map<String,Object>> userRoles = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> userRoles = jdbcTemplate.queryForList(sql);
        if (userRoles.size()==0){
        if (userRoles.size()==0){
            throw new Exception("您无权限操作");
            throw new Exception("您无权限操作");
        }else {
            String role_code = userRoles.get(0).get("role_code").toString();
            if ("admin".equals(role_code)){
            } else if ("deptAdmin".equals(role_code)) {//查询出管理员所在部门
                if(StringUtils.isBlank(dept)){
                    sql = " select dh.dept_code from base_doctor doc INNER JOIN base_doctor_hospital dh on doc.id = dh.doctor_code " +
                            " and doc.del=1 and dh.del=1 where doc.id='"+user+"' ";
                    List<String> userDept = jdbcTemplate.queryForList(sql,String.class);
                    if (userDept.size()>0){
                        dept = userDept.get(0);
                    }else {
                        throw new Exception("您无权限操作");
                    }
                }
            }else {
                throw new Exception("您无权限操作");
            }
        }
        }
        String sqlCondition = "  ";
        String sqlCondition = "  ";
        if (StringUtils.isNotBlank(startDate)){
        if (StringUtils.isNotBlank(startDate)){
            sqlCondition += " and up.report_date>='"+startDate+"' ";
            sqlCondition += " and up.report_date>='"+startDate+"' ";
@ -3046,7 +3323,8 @@ public class DailyReportUploadService {
                " i.end_time endTime, i.create_user_name createUserName " +
                " 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 " +
                "  from  base_daily_report_item i INNER JOIN base_daily_report_item_members mem on i.id =mem.report_item_id " +
                " INNER JOIN base_doctor doc on mem.user_id = doc.id and doc.del=1 " +
                " INNER JOIN base_doctor doc on mem.user_id = doc.id and doc.del=1 " +
                " where  i.project_code='"+projectCode+"' and mem.user_id='"+memberId+"' and mem.del=1 and  i.dept='"+dept+"' " +
                " INNER JOIN base_doctor_hospital dh on doc.id = dh.doctor_code and dh.del=1 " +
                " where  i.project_code='"+projectCode+"' and mem.user_id='"+memberId+"' and mem.del=1 and  dh.dept_code='"+dept+"' " +
                "  GROUP BY i.id ";
                "  GROUP BY i.id ";
        List<Map<String,Object>> deptProjectItemList = jdbcTemplate.queryForList(projectSql);
        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,  " +
        String sqlList = "  select i.project_code,CAST((sum(IFNULL(de.actual_completion_hour,IFNULL(de.completion_hour,'0')))) as char ) as completionHour,  " +
@ -3054,7 +3332,8 @@ public class DailyReportUploadService {
                " from base_daily_report_item i LEFT JOIN base_daily_report_detail de on i.id = de.report_item_id  " +
                " 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 " +
                " INNER JOIN base_doctor_daily_report_upload up on up.id = de.report_id " +
                " INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1 " +
                " INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1 " +
                "  where i.del=1 and up.doctor_id='"+memberId+"' and i.dept='"+dept+"' and i.id='{itemId}'  "+sqlCondition+
                " INNER JOIN base_doctor_hospital dh on doc.id = dh.doctor_code and dh.del=1 " +
                "  where i.del=1 and up.doctor_id='"+memberId+"' and dh.dept_code='"+dept+"' and i.id='{itemId}'  "+sqlCondition+
                " GROUP BY "+groupTimeFormat+" order by time asc";
                " GROUP BY "+groupTimeFormat+" order by time asc";
        for (Map<String,Object>tmp:deptProjectItemList){
        for (Map<String,Object>tmp:deptProjectItemList){
            String itemId = tmp.get("id").toString();
            String itemId = tmp.get("id").toString();
@ -3096,11 +3375,32 @@ public class DailyReportUploadService {
     * @return
     * @return
     */
     */
    public JSONObject statisticDetailHeaderInfo(String user,String projectCode,String item_id,String dept,String memberId,String startDate,String endDate) throws Exception {
    public JSONObject statisticDetailHeaderInfo(String user,String projectCode,String item_id,String dept,String memberId,String startDate,String endDate) throws Exception {
        //判断导出人权限
        String sql = " select * from base_doctor_role where doctor_code='"+user+"' ";
        String sql = " select * from base_doctor_role where doctor_code='"+user+"' ";
        List<Map<String,Object>> userRoles = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> userRoles = jdbcTemplate.queryForList(sql);
        if (userRoles.size()==0){
        if (userRoles.size()==0){
            throw new Exception("您无权限操作");
            throw new Exception("您无权限操作");
        }else {
            String role_code = userRoles.get(0).get("role_code").toString();
            if ("admin".equals(role_code)){
            } else if ("deptAdmin".equals(role_code)) {//查询出管理员所在部门
                if(StringUtils.isBlank(dept)){
                    sql = " select dh.dept_code from base_doctor doc INNER JOIN base_doctor_hospital dh on doc.id = dh.doctor_code " +
                            " and doc.del=1 and dh.del=1 where doc.id='"+user+"' ";
                    List<String> userDept = jdbcTemplate.queryForList(sql,String.class);
                    if (userDept.size()>0){
                        dept = userDept.get(0);
                    }else {
                        throw new Exception("您无权限操作");
                    }
                }
            }else {
                throw new Exception("您无权限操作");
            }
        }
        }
        sql = " select dict_value from  wlyy_hospital_sys_dict where dict_name='healthUpload' and dict_code='healthUpload' ";
        sql = " select dict_value from  wlyy_hospital_sys_dict where dict_name='healthUpload' and dict_code='healthUpload' ";
        List<String> dictValues = jdbcTemplate.queryForList(sql,String.class);
        List<String> dictValues = jdbcTemplate.queryForList(sql,String.class);
        JSONObject doubtTypeObj = new JSONObject();
        JSONObject doubtTypeObj = new JSONObject();
@ -3168,23 +3468,29 @@ public class DailyReportUploadService {
                "LEFT JOIN base_daily_report_detail rd on up.id = rd.report_id and rd.report_item_id = it.id where 1=1 "+sqlWhere;
                "LEFT JOIN base_daily_report_detail rd on up.id = rd.report_id and rd.report_item_id = it.id where 1=1 "+sqlWhere;
        members = jdbcTemplate.queryForObject(memberSql,Long.class);
        members = jdbcTemplate.queryForObject(memberSql,Long.class);
        sqlWhere += " and up.report_date>='"+startDate+"' and up.report_date<='"+endDate+"' ";
        Long workDays = DateUtil.getWorkDays(startDate,endDate);
        if (StringUtils.isNotBlank(startDate)) {
            sqlWhere += " and up.report_date>='"+DateUtil.strToStrShort(startDate) +"' ";
        }if (StringUtils.isNotBlank(endDate)){
            sqlWhere += "  and up.report_date<='"+DateUtil.strToStrShort(endDate)+"' ";
        }
        Long workDays=0l;
        if (StringUtils.isNotBlank(startDate)&&StringUtils.isNotBlank(endDate)) {
            workDays = DateUtil.getWorkDays(startDate, endDate);
        }
        String shangchuanSql = " select count(distinct up.id) from base_doctor_daily_report_upload up " +
        String shangchuanSql = " select count(distinct up.id) from base_doctor_daily_report_upload up " +
                " INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1 " +
                " INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1 " +
                "Inner JOIN base_doctor_hospital dh on doc.id = dh.doctor_code and dh.del=1 " +
                "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  where 1=1 " +
                " and DATE_FORMAT(up.report_date,'%w') BETWEEN 1 and 5  "+sqlWhere;
                "LEFT JOIN base_daily_report_detail rd on up.id = rd.report_id " +
                "inner join base_daily_report_item i on i.id = rd.report_item_id and i.del=1 where 1=1 " +
                "and DATE_FORMAT(up.report_date,'%w') BETWEEN 1 and 5  "+sqlWhere;
        //只计算出周一到周五上传的数量去求未上传
        //只计算出周一到周五上传的数量去求未上传
        Long shangchuanTotal = jdbcTemplate.queryForObject(shangchuanSql,Long.class);
        Long shangchuanTotal = jdbcTemplate.queryForObject(shangchuanSql,Long.class);
        Long acWorkHours = 0l;
        Double acWorkHours = 0d;
        Long needWorkHours = workDays*members*8;
        Long needWorkHours = workDays*members*8;
        Long urgingTotal=0l;
        Long urgingTotal=0l;
@ -3207,15 +3513,17 @@ public class DailyReportUploadService {
                " from base_doctor_daily_report_upload up  " +
                " from base_doctor_daily_report_upload up  " +
                "INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1 " +
                "INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1 " +
                "Inner JOIN base_doctor_hospital dh on doc.id = dh.doctor_code and dh.del=1 " +
                "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  where 1=1 " +
                "LEFT JOIN base_daily_report_detail rd on up.id = rd.report_id " +
                " inner join base_daily_report_item i on i.id = rd.report_item_id and i.del=1  where 1=1 " +
                " "+sqlWhere;
                " "+sqlWhere;
        acWorkHours = jdbcTemplate.queryForObject(acWorkHoursSql,Long.class);
        acWorkHours = jdbcTemplate.queryForObject(acWorkHoursSql,Double.class);
        String doubtTypeSql = " select count(distinct rd.id) as total,rd.doubt_type " +
        String doubtTypeSql = " select count(distinct rd.id) as total,rd.doubt_type " +
                " from base_doctor_daily_report_upload up  " +
                " from base_doctor_daily_report_upload up  " +
                "INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1 " +
                "INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1 " +
                "Inner JOIN base_doctor_hospital dh on doc.id = dh.doctor_code and dh.del=1 " +
                "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  where 1=1 " +
                "LEFT JOIN base_daily_report_detail rd on up.id = rd.report_id " +
                "inner join base_daily_report_item i on i.id = rd.report_item_id and i.del=1 where 1=1 " +
                " "+sqlWhere+" and rd.doubt_type is not null group by rd.doubt_type";
                " "+sqlWhere+" and rd.doubt_type is not null group by rd.doubt_type";
        List<Map<String,Object>> doubtTypeList = jdbcTemplate.queryForList(doubtTypeSql);
        List<Map<String,Object>> doubtTypeList = jdbcTemplate.queryForList(doubtTypeSql);
        for (Map<String,Object>tmp:doubtTypeList){
        for (Map<String,Object>tmp:doubtTypeList){
@ -3249,10 +3557,11 @@ public class DailyReportUploadService {
                " from base_doctor_daily_report_upload up  " +
                " from base_doctor_daily_report_upload up  " +
                "INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1 " +
                "INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1 " +
                "Inner JOIN base_doctor_hospital dh on doc.id = dh.doctor_code and dh.del=1 " +
                "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  where 1=1 " +
                "LEFT JOIN base_daily_report_detail rd on up.id = rd.report_id " +
                "inner join base_daily_report_item i on i.id = rd.report_item_id and i.del=1 where 1=1 " +
                " "+sqlWhere+" group by doctor_duty_code ";
                " "+sqlWhere+" group by doctor_duty_code ";
       List<Map<String,Object>> doctorTypeHourList = jdbcTemplate.queryForList(doctorTypeSql);
        List<Map<String,Object>> doctorTypeHourList = jdbcTemplate.queryForList(doctorTypeSql);
        result.put("doctorTypeHourList",doctorTypeHourList);//按人员统计总用时与参与人数
        result.put("doctorTypeHourList",doctorTypeHourList);//按人员统计总用时与参与人数
@ -3261,11 +3570,32 @@ public class DailyReportUploadService {
    }
    }
    public List<Map<String,Object>> statisticWorkTypeInfo(String user,String  projectCode,String  item_id,String  dept,String memberId,String  startDate,String endDate) throws Exception {
    public List<Map<String,Object>> statisticWorkTypeInfo(String user,String  projectCode,String  item_id,String  dept,String memberId,String  startDate,String endDate) throws Exception {
        //判断导出人权限
        String sql = " select * from base_doctor_role where doctor_code='"+user+"' ";
        String sql = " select * from base_doctor_role where doctor_code='"+user+"' ";
        List<Map<String,Object>> userRoles = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> userRoles = jdbcTemplate.queryForList(sql);
        if (userRoles.size()==0){
        if (userRoles.size()==0){
            throw new Exception("您无权限操作");
            throw new Exception("您无权限操作");
        }else {
            String role_code = userRoles.get(0).get("role_code").toString();
            if ("admin".equals(role_code)){
            } else if ("deptAdmin".equals(role_code)) {//查询出管理员所在部门
                if(StringUtils.isBlank(dept)){
                    sql = " select dh.dept_code from base_doctor doc INNER JOIN base_doctor_hospital dh on doc.id = dh.doctor_code " +
                            " and doc.del=1 and dh.del=1 where doc.id='"+user+"' ";
                    List<String> userDept = jdbcTemplate.queryForList(sql,String.class);
                    if (userDept.size()>0){
                        dept = userDept.get(0);
                    }else {
                        throw new Exception("您无权限操作");
                    }
                }
            }else {
                throw new Exception("您无权限操作");
            }
        }
        }
        String sqlWhere = "  ";
        String sqlWhere = "  ";
        if (StringUtils.isNotBlank(projectCode)){
        if (StringUtils.isNotBlank(projectCode)){
            sqlWhere += "  and rd.project_code='"+projectCode+"' ";
            sqlWhere += "  and rd.project_code='"+projectCode+"' ";
@ -3297,10 +3627,37 @@ public class DailyReportUploadService {
    public PageEnvelop searchReportDetailListInfo(String user,String projectCode,String item_id,String dept,String memberName,
    public PageEnvelop searchReportDetailListInfo(String user,String projectCode,String item_id,String dept,String memberName,
                                                               String  workTypeName,String doubt,Integer urgeFlag,String startDate,String endDate,Integer page,Integer pageSize) throws Exception {
                                                               String  workTypeName,String doubt,Integer urgeFlag,String startDate,String endDate,Integer page,Integer pageSize) throws Exception {
        page = page>0?page-1:0;
        page = page>0?page-1:0;
        String sql = " select * from base_doctor_role where doctor_code='"+user+"' ";
        String sql = " select dict_value from  wlyy_hospital_sys_dict where dict_name='healthUpload' and dict_code='healthUpload' ";
        List<String> dictValues = jdbcTemplate.queryForList(sql,String.class);
        JSONObject doubtTypeObj = new JSONObject();
        if (dictValues.size()>0){
            JSONObject tmp = JSONObject.parseObject(dictValues.get(0));
            doubtTypeObj = tmp.getJSONObject("dailyReportDoubtTypeName");
        }
        //判断导出人权限
        sql = " select * from base_doctor_role where doctor_code='"+user+"' ";
        List<Map<String,Object>> userRoles = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> userRoles = jdbcTemplate.queryForList(sql);
        if (userRoles.size()==0){
        if (userRoles.size()==0){
            throw new Exception("您无权限操作");
            throw new Exception("您无权限操作");
        }else {
            String role_code = userRoles.get(0).get("role_code").toString();
            if ("admin".equals(role_code)){
            } else if ("deptAdmin".equals(role_code)) {//查询出管理员所在部门
                if(StringUtils.isBlank(dept)){
                    sql = " select dh.dept_code from base_doctor doc INNER JOIN base_doctor_hospital dh on doc.id = dh.doctor_code " +
                            " and doc.del=1 and dh.del=1 where doc.id='"+user+"' ";
                    List<String> userDept = jdbcTemplate.queryForList(sql,String.class);
                    if (userDept.size()>0){
                        dept = userDept.get(0);
                    }else {
                        throw new Exception("您无权限操作");
                    }
                }
            }else {
                throw new Exception("您无权限操作");
            }
        }
        }
        String sqlWhere = "  ";
        String sqlWhere = "  ";
@ -3336,7 +3693,7 @@ public class DailyReportUploadService {
            sqlUrgeWhere +=" and ur.create_time<='"+endDate+"' ";
            sqlUrgeWhere +=" and ur.create_time<='"+endDate+"' ";
        }
        }
       String  reportSql = " select dh.dept_name,doc.id doctorCode,doc.name,CONCAT(rd.project_name,'(',rd.report_item_name,')') as 'projectNameStr', " +
       String  reportSql = " select up.id,'report' as 'itemType',dh.dept_name,doc.id doctorCode,doc.name,CONCAT(rd.project_name,'(',rd.report_item_name,')') as 'projectNameStr', " +
               " rd.project_name,rd.report_item_name,CONCAT(rd.work_type_name,'(',rd.report_content,')') as 'workContent', " +
               " rd.project_name,rd.report_item_name,CONCAT(rd.work_type_name,'(',rd.report_content,')') as 'workContent', " +
               " rd.work_type_name,rd.report_content,up.report_date,IFNULL(rd.actual_completion_hour,rd.completion_hour) 'completionHour', " +
               " rd.work_type_name,rd.report_content,up.report_date,IFNULL(rd.actual_completion_hour,rd.completion_hour) 'completionHour', " +
               " rd.doubt,rd.doubt_type,rd.verification_user_name,rd.remark  " +
               " rd.doubt,rd.doubt_type,rd.verification_user_name,rd.remark  " +
@ -3348,7 +3705,7 @@ public class DailyReportUploadService {
                "Inner JOIN base_doctor_hospital dh on doc.id = dh.doctor_code and dh.del=1 " +
                "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  where 1=1 "+sqlWhere+" ";
                "LEFT JOIN base_daily_report_detail rd on up.id = rd.report_id  where 1=1 "+sqlWhere+" ";
        String urgeSql = " select dh.dept_name,doc.id doctorCode,doc.name,CONCAT(ur.project_name,'(',ur.report_item_name,')') as 'projectNameStr',  " +
        String urgeSql = " select ur.code as id,'urge' as 'itemType',dh.dept_name,doc.id doctorCode,doc.name,CONCAT(ur.project_name,'(',ur.report_item_name,')') as 'projectNameStr',  " +
                " ur.project_name,ur.report_item_name,'启动催促' as 'workContent',  " +
                " ur.project_name,ur.report_item_name,'启动催促' as 'workContent',  " +
                " '' as 'work_type_name','' as 'rd.report_content',date_format(ur.create_time,'%Y-%m-%d' ) as 'report_date','' as 'completionHour', " +
                " '' as 'work_type_name','' as 'rd.report_content',date_format(ur.create_time,'%Y-%m-%d' ) as 'report_date','' as 'completionHour', " +
                " '' as 'doubt', '' as 'doubt_type' , ur.create_user_name as 'verification_user_name' , ur.remark " +
                " '' as 'doubt', '' as 'doubt_type' , ur.create_user_name as 'verification_user_name' , ur.remark " +
@ -3375,6 +3732,10 @@ public class DailyReportUploadService {
        }
        }
        sql += " order by report_date desc,doctorCode desc limit  "+page*pageSize+","+pageSize;
        sql += " order by report_date desc,doctorCode desc limit  "+page*pageSize+","+pageSize;
        result = jdbcTemplate.queryForList(sql);
        result = jdbcTemplate.queryForList(sql);
        for (Map<String,Object> tmp:result){
            tmp.put("doubt_type_name",null==tmp.get("doubt_type")?"":StringUtils.isBlank(tmp.get("doubt_type").toString())?"":doubtTypeObj.getString(tmp.get("doubt_type").toString()));
        }
        Long count = jdbcTemplate.queryForObject(" select sum(total) from ("+sqlCount+")A ",Long.class);
        Long count = jdbcTemplate.queryForObject(" select sum(total) from ("+sqlCount+")A ",Long.class);
        return PageEnvelop.getSuccessListWithPage("success",result,page,pageSize,count);
        return PageEnvelop.getSuccessListWithPage("success",result,page,pageSize,count);
    }
    }
@ -3432,7 +3793,7 @@ public class DailyReportUploadService {
                "it.title,it.content,rd.sort,rd.report_content,IFNULL(rd.actual_completion_hour,IFNULL(rd.completion_hour,0)) 'completion_hour', " +
                "it.title,it.content,rd.sort,rd.report_content,IFNULL(rd.actual_completion_hour,IFNULL(rd.completion_hour,0)) 'completion_hour', " +
                "DATE_FORMAT(rd.create_time,'%Y-%m-%d %H:%i:%S') create_time,DATE_FORMAT(rd.verification_time,'%Y-%m-%d %H:%i:%S') verification_time," +
                "DATE_FORMAT(rd.create_time,'%Y-%m-%d %H:%i:%S') create_time,DATE_FORMAT(rd.verification_time,'%Y-%m-%d %H:%i:%S') verification_time," +
                " CASE rd.state WHEN 1 THEN '已核实' ELSE '未核实' END as 'verification_state',rd.verification_user_name,CASE rd.doubt WHEN 1 THEN '存疑' ELSE '无存疑' END as 'doubt', " +
                " CASE rd.state WHEN 1 THEN '已核实' ELSE '未核实' END as 'verification_state',rd.verification_user_name,CASE rd.doubt WHEN 1 THEN '存疑' ELSE '无存疑' END as 'doubt', " +
                " rd.doubt_type, rd.remark " +
                " rd.doubt_type doubtType, rd.remark " +
                "from base_doctor_daily_report_upload up INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1  " +
                "from base_doctor_daily_report_upload up INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1  " +
                "INNER JOIN base_doctor_hospital dh on doc.id = dh.doctor_code and dh.del=1 LEFT JOIN  " +
                "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 " +
                "base_daily_report_detail rd on up.id = rd.report_id " +
@ -3491,7 +3852,7 @@ public class DailyReportUploadService {
                "it.title,it.content,rd.sort,rd.report_content,IFNULL(rd.actual_completion_hour,IFNULL(rd.completion_hour,0)) 'completion_hour', " +
                "it.title,it.content,rd.sort,rd.report_content,IFNULL(rd.actual_completion_hour,IFNULL(rd.completion_hour,0)) 'completion_hour', " +
                "DATE_FORMAT(rd.create_time,'%Y-%m-%d %H:%i:%S') create_time,DATE_FORMAT(rd.verification_time,'%Y-%m-%d %H:%i:%S') verification_time," +
                "DATE_FORMAT(rd.create_time,'%Y-%m-%d %H:%i:%S') create_time,DATE_FORMAT(rd.verification_time,'%Y-%m-%d %H:%i:%S') verification_time," +
                " CASE rd.state WHEN 1 THEN '已核实' ELSE '未核实' END as 'verification_state',rd.verification_user_name,CASE rd.doubt WHEN 1 THEN '存疑' ELSE '无存疑' END as 'doubt'," +
                " CASE rd.state WHEN 1 THEN '已核实' ELSE '未核实' END as 'verification_state',rd.verification_user_name,CASE rd.doubt WHEN 1 THEN '存疑' ELSE '无存疑' END as 'doubt'," +
                " rd.doubt_type, rd.remark " +
                " rd.doubt_type doubtType, rd.remark " +
                "from base_doctor_daily_report_upload up INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1  " +
                "from base_doctor_daily_report_upload up INNER JOIN base_doctor doc on up.doctor_id = doc.id and doc.del=1  " +
                "INNER JOIN base_doctor_hospital dh on doc.id = dh.doctor_code and dh.del=1 LEFT JOIN  " +
                "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 " +
                "base_daily_report_detail rd on up.id = rd.report_id " +

+ 13 - 8
common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java

@ -344,6 +344,18 @@ public class DateUtil {
        return formatter.format(dateDate);
        return formatter.format(dateDate);
    }
    }
    /**
     * 时间字符串转日期
     * @param dateDate
     * @return
     */
    public static String strToStrShort(String dateDate) {
        if (dateDate == null) {
            return "";
        }
        return dateToStrShort(strToDate(dateDate));
    }
    /**
    /**
     * 将短时间格式时间转换为字符串 yyyy-MM-dd
     * 将短时间格式时间转换为字符串 yyyy-MM-dd
     */
     */
@ -1411,14 +1423,7 @@ public class DateUtil {
    }
    }
    public static void main(String[] args) {
    public static void main(String[] args) {
        String time = DateUtil.getStringDateShort()+" 09:00:00";
        Date timeDate = DateUtil.strToDate(time);
        System.out.println(dateToChineseTime2(timeDate));
        Date dateStart = getDateStart();
        Date dateEnd = getDateEnd();
        System.out.println(dateStart );
        System.out.println(dateEnd);
        System.out.println(getWorkDays("2022-08-01","2022-09-01"));
    }
    }
    
    
    /**
    /**

+ 5 - 3
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/dailyReport/DailyReportUploadPoint.java

@ -422,7 +422,7 @@ public class DailyReportUploadPoint extends EnvelopRestEndpoint {
                                         @RequestParam(value = "dept", required = false) String dept,
                                         @RequestParam(value = "dept", required = false) String dept,
                                         @ApiParam(name = "idType", value = "身份类别")
                                         @ApiParam(name = "idType", value = "身份类别")
                                         @RequestParam(value = "idType", required = false) String idType,
                                         @RequestParam(value = "idType", required = false) String idType,
                                         @ApiParam(name = "doubtType", value = "存疑类型0全部 存疑类型,1不饱和存疑 2效率存疑")
                                         @ApiParam(name = "doubtType", value = "存疑类型 存疑类型,1不饱和存疑 2效率存疑")
                                         @RequestParam(value = "doubtType", required = false) Integer doubtType,
                                         @RequestParam(value = "doubtType", required = false) Integer doubtType,
                                         @ApiParam(name = "startDate", value = "开始时间")
                                         @ApiParam(name = "startDate", value = "开始时间")
                                         @RequestParam(value = "startDate", required = false) String startDate,
                                         @RequestParam(value = "startDate", required = false) String startDate,
@ -659,6 +659,8 @@ public class DailyReportUploadPoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "管理员获取所有日报项目")
    @ApiOperation(value = "管理员获取所有日报项目")
    public ListEnvelop findReportItemListAdmin(@ApiParam(name = "user", value = "user")
    public ListEnvelop findReportItemListAdmin(@ApiParam(name = "user", value = "user")
                                      @RequestParam(value = "user", required = true) String user,
                                      @RequestParam(value = "user", required = true) String user,
                                      @ApiParam(name = "projectCode", value = "一级项目code")
                                      @RequestParam(value = "projectCode", required = false) String projectCode,
                                      @ApiParam(name = "title", value = "事项标题")
                                      @ApiParam(name = "title", value = "事项标题")
                                      @RequestParam(value = "title", required = false) String title,
                                      @RequestParam(value = "title", required = false) String title,
                                      @ApiParam(name = "content", value = "项目内容")
                                      @ApiParam(name = "content", value = "项目内容")
@ -674,7 +676,7 @@ public class DailyReportUploadPoint extends EnvelopRestEndpoint {
                                      @ApiParam(name = "createUserName", value = "createUserName")
                                      @ApiParam(name = "createUserName", value = "createUserName")
                                      @RequestParam(value = "createUserName", required = false) String createUserName) {
                                      @RequestParam(value = "createUserName", required = false) String createUserName) {
        try {
        try {
            List<BaseDailyReportItemDO> list = dailyReportUploadService.findReportItemListAdmin(user,title,content,state,begin_time,end_time,createUser,createUserName);
            List<BaseDailyReportItemDO> list = dailyReportUploadService.findReportItemListAdmin(user,projectCode,title,content,state,begin_time,end_time,createUser,createUserName);
            return ListEnvelop.getSuccess("success",list);
            return ListEnvelop.getSuccess("success",list);
        } catch (Exception e) {
        } catch (Exception e) {
            return failedListEnvelopException(e);
            return failedListEnvelopException(e);
@ -1000,7 +1002,7 @@ public class DailyReportUploadPoint extends EnvelopRestEndpoint {
    }
    }
    @GetMapping(value = "searchReportDetailListInfo")
    @GetMapping(value = "searchReportDetailListInfo")
    @ApiOperation(value = "统计工作类型分布")
    @ApiOperation(value = "综合查询")
    public PageEnvelop searchReportDetailListInfo(@ApiParam(name = "user", value = "user")
    public PageEnvelop searchReportDetailListInfo(@ApiParam(name = "user", value = "user")
                                            @RequestParam(value = "user", required = true) String user,
                                            @RequestParam(value = "user", required = true) String user,
                                            @ApiParam(name = "projectCode", value = "一级项目Code")
                                            @ApiParam(name = "projectCode", value = "一级项目Code")