|  | @ -3,6 +3,7 @@ package com.yihu.jw.dailyReport.service;
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONArray;
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | import com.yihu.jw.dailyReport.dao.BaseDailyReportDetailDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.dailyReport.dao.BaseDailyReportLogDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.dailyReport.dao.BaseDailyReportUploadDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.doctor.dao.BaseDoctorDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
 | 
	
	
		
			
				|  | @ -14,6 +15,7 @@ import com.yihu.jw.entity.base.wx.WxAccessTokenDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.wx.WxPushLogDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.dailyReport.BaseDailyReportDetailDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.dailyReport.BaseDailyReportLogDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.dailyReport.BaseDailyReportUploadDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.healthUpload.BaseDoctorMemberDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
 | 
	
	
		
			
				|  | @ -55,6 +57,8 @@ public class DailyReportUploadService {
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BaseDailyReportUploadDao dailyReportUploadDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BaseDailyReportLogDao dailyReportLogDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BaseDailyReportDetailDao reportDetailDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BaseDoctorMemberDao doctorMemberDao;
 | 
	
	
		
			
				|  | @ -317,7 +321,7 @@ public class DailyReportUploadService {
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |     public BaseDailyReportUploadDO createDailyReport(String doctorId,String report_date,Integer leaveState,String leaveHour,String week_name, List<BaseDailyReportDetailDO> detailDOList) throws Exception {
 | 
	
		
			
				|  |  |     public BaseDailyReportUploadDO createDailyReport(String doctorId,String report_date,Integer leaveState,String leaveHour,String week_name,String totalHour, List<BaseDailyReportDetailDO> detailDOList) throws Exception {
 | 
	
		
			
				|  |  |         BaseDoctorDO doctorDO = baseDoctorDao.findById(doctorId);
 | 
	
		
			
				|  |  |         List<BaseDoctorHospitalDO> doctorHospitalDOS = baseDoctorHospitalDao.findByDoctorCode(doctorId);
 | 
	
		
			
				|  |  |         if (null==doctorDO){
 | 
	
	
		
			
				|  | @ -348,6 +352,7 @@ public class DailyReportUploadService {
 | 
	
		
			
				|  |  |         dailyReportUploadDO.setWeekName(week_name);
 | 
	
		
			
				|  |  |         dailyReportUploadDO.setLeaveState(leaveState);
 | 
	
		
			
				|  |  |         dailyReportUploadDO.setLeaveHour(leaveHour);
 | 
	
		
			
				|  |  |         dailyReportUploadDO.setTotalHour(totalHour);
 | 
	
		
			
				|  |  |         dailyReportUploadDO = dailyReportUploadDao.save(dailyReportUploadDO);
 | 
	
		
			
				|  |  |         for (BaseDailyReportDetailDO tmp :detailDOList){
 | 
	
		
			
				|  |  |             tmp.setReportId(dailyReportUploadDO.getId());
 | 
	
	
		
			
				|  | @ -405,7 +410,15 @@ public class DailyReportUploadService {
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         dailyReportUploadDao.save(dailyReportUploadDO);
 | 
	
		
			
				|  |  |         dailyReportUploadDO.setDetailDOList(detailDOS);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         BaseDailyReportLogDO baseDailyReportLogDO = new BaseDailyReportLogDO();
 | 
	
		
			
				|  |  |         baseDailyReportLogDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |         baseDailyReportLogDO.setReportId(dailyReportUploadDO.getId());
 | 
	
		
			
				|  |  |         baseDailyReportLogDO.setContent("日报提交");
 | 
	
		
			
				|  |  |         baseDailyReportLogDO.setOperateUser(dailyReportUploadDO.getDoctorId());
 | 
	
		
			
				|  |  |         baseDailyReportLogDO.setOperateUserName(dailyReportUploadDO.getDoctorName());
 | 
	
		
			
				|  |  |         baseDailyReportLogDO.setType(1);
 | 
	
		
			
				|  |  |         baseDailyReportLogDO.setTypeName("日报提交");
 | 
	
		
			
				|  |  |         dailyReportLogDao.save(baseDailyReportLogDO);
 | 
	
		
			
				|  |  |         return dailyReportUploadDO;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -439,7 +452,15 @@ public class DailyReportUploadService {
 | 
	
		
			
				|  |  |                 dailyReportUploadDO.setState(1);
 | 
	
		
			
				|  |  |                 dailyReportUploadDao.save(dailyReportUploadDO);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             BaseDailyReportLogDO baseDailyReportLogDO = new BaseDailyReportLogDO();
 | 
	
		
			
				|  |  |             baseDailyReportLogDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |             baseDailyReportLogDO.setReportId(dailyReportUploadDO.getId());
 | 
	
		
			
				|  |  |             baseDailyReportLogDO.setOperateUser(doctorDO.getId());
 | 
	
		
			
				|  |  |             baseDailyReportLogDO.setOperateUserName(doctorDO.getName());
 | 
	
		
			
				|  |  |             if (doubt==true){//有疑惑,推送给总经办"0592181"和老板"0592008";//老板id
 | 
	
		
			
				|  |  |                 baseDailyReportLogDO.setType(3);
 | 
	
		
			
				|  |  |                 baseDailyReportLogDO.setTypeName("上级核实存疑");
 | 
	
		
			
				|  |  |                 baseDailyReportLogDO.setContent("上级核实存疑");
 | 
	
		
			
				|  |  |                 String sql = " select dict_value from wlyy_hospital_sys_dict where dict_name='MRRB_DOUBT_SENDER'  ";
 | 
	
		
			
				|  |  |                 List<String> doubtSendUser = jdbcTemplate.queryForList(sql,String.class);
 | 
	
		
			
				|  |  |                 for (String senderUser:doubtSendUser){
 | 
	
	
		
			
				|  | @ -464,7 +485,12 @@ public class DailyReportUploadService {
 | 
	
		
			
				|  |  |                         e.printStackTrace();
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }else {
 | 
	
		
			
				|  |  |                 baseDailyReportLogDO.setType(2);
 | 
	
		
			
				|  |  |                 baseDailyReportLogDO.setTypeName("上级核实未存疑");
 | 
	
		
			
				|  |  |                 baseDailyReportLogDO.setContent("上级核实未存疑");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             dailyReportLogDao.save(baseDailyReportLogDO);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             dailyReportUploadDO.setState(1);
 | 
	
	
		
			
				|  | @ -496,6 +522,36 @@ public class DailyReportUploadService {
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             reportDetailDao.save(detailDOList);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         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 = "您好,您上报的日报有新的反馈,请点击前往查看。";
 | 
	
		
			
				|  |  |                         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();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         BaseDailyReportLogDO baseDailyReportLogDO = new BaseDailyReportLogDO();
 | 
	
		
			
				|  |  |         baseDailyReportLogDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |         baseDailyReportLogDO.setReportId(dailyReportUploadDO.getId());
 | 
	
		
			
				|  |  |         baseDailyReportLogDO.setOperateUser(doctorDO.getId());
 | 
	
		
			
				|  |  |         baseDailyReportLogDO.setOperateUserName(doctorDO.getName());
 | 
	
		
			
				|  |  |         baseDailyReportLogDO.setType(4);
 | 
	
		
			
				|  |  |         baseDailyReportLogDO.setTypeName("存疑核实");
 | 
	
		
			
				|  |  |         baseDailyReportLogDO.setContent("存疑核实");
 | 
	
		
			
				|  |  |         dailyReportLogDao.save(baseDailyReportLogDO);
 | 
	
		
			
				|  |  |         return dailyReportUploadDO;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -512,6 +568,8 @@ public class DailyReportUploadService {
 | 
	
		
			
				|  |  |         }else{
 | 
	
		
			
				|  |  |             List<BaseDailyReportDetailDO> detailDOS = reportDetailDao.findByReportId(dailyReportUploadDO.getId());
 | 
	
		
			
				|  |  |             dailyReportUploadDO.setDetailDOList(detailDOS);
 | 
	
		
			
				|  |  |             List<BaseDailyReportLogDO> dailyReportLogDOList = dailyReportLogDao.findByReportId(dailyReportUploadDO.getId());
 | 
	
		
			
				|  |  |             dailyReportUploadDO.setDailyReportLogDOList(dailyReportLogDOList);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return dailyReportUploadDO;
 | 
	
		
			
				|  |  |     }
 | 
	
	
		
			
				|  | @ -536,6 +594,8 @@ public class DailyReportUploadService {
 | 
	
		
			
				|  |  |         for (BaseDailyReportUploadDO tmp:list){
 | 
	
		
			
				|  |  |             List<BaseDailyReportDetailDO> detailDOS = reportDetailDao.findByReportId(tmp.getId());
 | 
	
		
			
				|  |  |             tmp.setDetailDOList(detailDOS);
 | 
	
		
			
				|  |  |             List<BaseDailyReportLogDO> dailyReportLogDOList = dailyReportLogDao.findByReportId(tmp.getId());
 | 
	
		
			
				|  |  |             tmp.setDailyReportLogDOList(dailyReportLogDOList);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return list;
 | 
	
		
			
				|  |  |     }
 | 
	
	
		
			
				|  | @ -553,6 +613,8 @@ public class DailyReportUploadService {
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             List<BaseDailyReportDetailDO> detailDOS = reportDetailDao.findByReportId(reportUploadDO.getId());
 | 
	
		
			
				|  |  |             reportUploadDO.setDetailDOList(detailDOS);
 | 
	
		
			
				|  |  |             List<BaseDailyReportLogDO> dailyReportLogDOList = dailyReportLogDao.findByReportId(reportUploadDO.getId());
 | 
	
		
			
				|  |  |             reportUploadDO.setDailyReportLogDOList(dailyReportLogDOList);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return reportUploadDO;
 | 
	
		
			
				|  |  |     }
 | 
	
	
		
			
				|  | @ -661,7 +723,7 @@ public class DailyReportUploadService {
 | 
	
		
			
				|  |  |             reportCondition += " and up.state ='"+state+"' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String doctorSqlCondition = "";//医生过滤条件
 | 
	
		
			
				|  |  |         String doctorSqlCondition = "  and d.identity=0  ";//医生过滤条件
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(idType)) {
 | 
	
		
			
				|  |  |             doctorSqlCondition += " and d.id_type = '" + idType + "' ";
 | 
	
		
			
				|  |  |         }
 | 
	
	
		
			
				|  | @ -737,6 +799,131 @@ public class DailyReportUploadService {
 | 
	
		
			
				|  |  |         return mapList;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 首页按照科室列表统计核实
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param dept
 | 
	
		
			
				|  |  |      * @param idType
 | 
	
		
			
				|  |  |      * @param state     核实状态
 | 
	
		
			
				|  |  |      * @param startDate
 | 
	
		
			
				|  |  |      * @param endDate
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public List<Map<String, Object>> selectHeaderListHeshi(String doctor,String dept, String idType, String state, String startDate, String endDate, String name) {
 | 
	
		
			
				|  |  |         String reportCondition = "";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(startDate)) {//上传过滤条件
 | 
	
		
			
				|  |  |             reportCondition += " and up.report_date >='" + startDate + "' and up.report_date<='" + endDate + "' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(state)){
 | 
	
		
			
				|  |  |             reportCondition += " and up.state ='"+state+"' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String doctorSqlCondition = " and d.identity=0 ";//医生过滤条件
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(idType)) {
 | 
	
		
			
				|  |  |             doctorSqlCondition += " and d.id_type = '" + idType + "' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(name)) {
 | 
	
		
			
				|  |  |             doctorSqlCondition += " and d.name like '%" + name + "%' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(doctor)){
 | 
	
		
			
				|  |  |             WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("dailyHeshiConfig");
 | 
	
		
			
				|  |  |             String buffer = "";
 | 
	
		
			
				|  |  |             if (hospitalSysDictDO!=null){
 | 
	
		
			
				|  |  |                 JSONArray array = JSONArray.parseArray(hospitalSysDictDO.getDictValue());
 | 
	
		
			
				|  |  |                 for (int i=0;i<array.size();i++){
 | 
	
		
			
				|  |  |                     JSONObject object = array.getJSONObject(i);
 | 
	
		
			
				|  |  |                     String header = object.getString("header");
 | 
	
		
			
				|  |  |                     if (header.equalsIgnoreCase(doctor)){
 | 
	
		
			
				|  |  |                         JSONArray jsonArray = object.getJSONArray("data");
 | 
	
		
			
				|  |  |                         for (int j=0;j<jsonArray.size();j++){
 | 
	
		
			
				|  |  |                             String str = jsonArray.getString(j);
 | 
	
		
			
				|  |  |                             buffer +="'"+str+"',";
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                         buffer =buffer.substring(0,buffer.length()-1);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (StringUtils.isNoneBlank(buffer)){
 | 
	
		
			
				|  |  |                 doctorSqlCondition += " and d.id IN ("+buffer+")";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //填报人数、未填报人数、上级已核实、未核实
 | 
	
		
			
				|  |  |         String deptSql = " select code,name,dh1.doctorTotal,dh2.yishangbaoTotal,dh3.verified,dh4.notVerified,dh5.shangchuanTotal  from dict_hospital_dept hd  " +
 | 
	
		
			
				|  |  |                 "LEFT JOIN (select count(1) as 'doctorTotal',dh.dept_code from base_doctor d LEFT JOIN base_doctor_hospital dh ON dh.doctor_code = d.id " +
 | 
	
		
			
				|  |  |                 "WHERE d.del = 1 AND dh.del = 1 "+doctorSqlCondition+" GROUP BY dh.dept_code)dh1 ON hd.CODE = dh1.dept_code " +
 | 
	
		
			
				|  |  |                 "LEFT JOIN(select dh.dept_code,count(up.id) 'yishangbaoTotal' from base_doctor_daily_report_upload up INNER JOIN base_doctor d on up.doctor_id = d.id " +
 | 
	
		
			
				|  |  |                 "LEFT JOIN base_doctor_hospital dh ON dh.doctor_code = d.id " +
 | 
	
		
			
				|  |  |                 "where 1=1 "+doctorSqlCondition+reportCondition+" GROUP BY dh.dept_code )dh2 ON hd.CODE = dh2.dept_code " +
 | 
	
		
			
				|  |  |                 "LEFT JOIN(select dh.dept_code,count(distinct up.id) 'verified' from base_doctor_daily_report_upload up LEFT JOIN base_daily_report_detail de on up.id = de.report_id " +
 | 
	
		
			
				|  |  |                 "INNER JOIN base_doctor d on up.doctor_id = d.id LEFT JOIN base_doctor_hospital dh ON dh.doctor_code = d.id " +
 | 
	
		
			
				|  |  |                 "where 1=1 and de.state=1 "+doctorSqlCondition+reportCondition+" GROUP BY dh.dept_code )dh3 ON hd.CODE = dh3.dept_code " +
 | 
	
		
			
				|  |  |                 "LEFT JOIN(select dh.dept_code,count(distinct up.id) 'notVerified' from base_doctor_daily_report_upload up LEFT JOIN base_daily_report_detail de on up.id = de.report_id " +
 | 
	
		
			
				|  |  |                 "INNER JOIN base_doctor d on up.doctor_id = d.id LEFT JOIN base_doctor_hospital dh ON dh.doctor_code = d.id " +
 | 
	
		
			
				|  |  |                 "where 1=1 and de.state=0 "+doctorSqlCondition+reportCondition+" GROUP BY dh.dept_code )dh4 ON hd.CODE = dh4.dept_code " +
 | 
	
		
			
				|  |  |                 "LEFT JOIN(select dh.dept_code,count(up.id) 'shangchuanTotal' from base_doctor_daily_report_upload up INNER JOIN base_doctor d on up.doctor_id = d.id " +
 | 
	
		
			
				|  |  |                 "LEFT JOIN base_doctor_hospital dh ON dh.doctor_code = d.id " +
 | 
	
		
			
				|  |  |                 "where 1=1 "+doctorSqlCondition+reportCondition+" GROUP BY dh.dept_code )dh5 ON hd.CODE = dh5.dept_code  " +
 | 
	
		
			
				|  |  |                 " WHERE hd.consult_dept_flag = 1 ";
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(name)) {
 | 
	
		
			
				|  |  |             deptSql += " and hd.code IN(SELECT dha.dept_code FROM base_doctor_hospital dha LEFT JOIN base_doctor da ON da.id=dha.doctor_code where da.name LIKE '%" + name + "%') ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (!StringUtils.isNoneBlank(doctor)){
 | 
	
		
			
				|  |  |             if (StringUtils.isNoneBlank(dept)) {
 | 
	
		
			
				|  |  |                 deptSql += " and hd.code = '" + dept + "' ";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         logger.info("deptSql=="+deptSql);
 | 
	
		
			
				|  |  |         List<Map<String, Object>> mapList = jdbcTemplate.queryForList(deptSql);
 | 
	
		
			
				|  |  |         for (Map<String,Object> deptMap:mapList){
 | 
	
		
			
				|  |  |             String day = DateUtil.getTwoDay(endDate, startDate);
 | 
	
		
			
				|  |  |             Integer doctorTotal = 0;
 | 
	
		
			
				|  |  |             Integer total=0;
 | 
	
		
			
				|  |  |             Integer yishangbaoTotal=0;
 | 
	
		
			
				|  |  |             Integer weishangbaoTotal=0;
 | 
	
		
			
				|  |  |             Integer notVerified=0;
 | 
	
		
			
				|  |  |             Integer verified=0;
 | 
	
		
			
				|  |  |             Integer shangchuanTotal=0;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if (deptMap.get("doctorTotal")!=null){
 | 
	
		
			
				|  |  |                 doctorTotal = Integer.parseInt(deptMap.get("doctorTotal").toString());
 | 
	
		
			
				|  |  |                 //总人次
 | 
	
		
			
				|  |  |                 if (!day.equalsIgnoreCase("0")) {
 | 
	
		
			
				|  |  |                     total = doctorTotal * (Integer.parseInt(day)+1);
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     total = doctorTotal;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (deptMap.get("yishangbaoTotal")!=null) {
 | 
	
		
			
				|  |  |                 yishangbaoTotal = Integer.parseInt(deptMap.get("yishangbaoTotal").toString());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             weishangbaoTotal = total-yishangbaoTotal;
 | 
	
		
			
				|  |  |             if (deptMap.get("notVerified")!=null) {
 | 
	
		
			
				|  |  |                 notVerified = Integer.parseInt(deptMap.get("notVerified").toString());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (deptMap.get("verified")!=null) {
 | 
	
		
			
				|  |  |                 verified = Integer.parseInt(deptMap.get("verified").toString());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (deptMap.get("shangchuanTotal")!=null) {
 | 
	
		
			
				|  |  |                 shangchuanTotal = Integer.parseInt(deptMap.get("shangchuanTotal").toString());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             deptMap.put("total", total);//总人次
 | 
	
		
			
				|  |  |             deptMap.put("yishangbaoTotal", yishangbaoTotal);//已上报
 | 
	
		
			
				|  |  |             deptMap.put("weishangbaoTotal", weishangbaoTotal);//未上报
 | 
	
		
			
				|  |  |             deptMap.put("notVerified", notVerified);//未核实数量
 | 
	
		
			
				|  |  |             deptMap.put("verified", verified);//已核实数量
 | 
	
		
			
				|  |  |             deptMap.put("shangchuanTotal", shangchuanTotal);//上传总次数
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return mapList;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 具体每一个统计时间列表
 | 
	
		
			
				|  |  |      *
 | 
	
	
		
			
				|  | @ -762,7 +949,7 @@ public class DailyReportUploadService {
 | 
	
		
			
				|  |  |         JSONArray array = new JSONArray();
 | 
	
		
			
				|  |  |         for ( i = 0; i < list.size(); i++) {
 | 
	
		
			
				|  |  |             String date = list.get(i);
 | 
	
		
			
				|  |  |             String doctorSql = " select COUNT(1) as 'total' from base_doctor d where d.del=1 ";
 | 
	
		
			
				|  |  |             String doctorSql = " select COUNT(1) as 'total' from base_doctor d where d.del=1 and d.identity=0  ";
 | 
	
		
			
				|  |  |             String deptCondition = "";
 | 
	
		
			
				|  |  |             if (StringUtils.isNoneBlank(dept)) {
 | 
	
		
			
				|  |  |                 deptCondition += " (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '" + dept + "' and dh.del=1 )";
 | 
	
	
		
			
				|  | @ -831,7 +1018,7 @@ public class DailyReportUploadService {
 | 
	
		
			
				|  |  |         JSONArray array = new JSONArray();
 | 
	
		
			
				|  |  |         for (i = 0; i < list.size(); i++) {
 | 
	
		
			
				|  |  |             String date = list.get(i);
 | 
	
		
			
				|  |  |             String doctorSql = " select d.name,d.id,d.job_title_name as jobTitleName,d.photo from base_doctor d where d.del=1 ";
 | 
	
		
			
				|  |  |             String doctorSql = " select d.name,d.id,d.job_title_name as jobTitleName,d.photo from base_doctor d where d.del=1 and d.identity=0  ";
 | 
	
		
			
				|  |  |             String deptCondition = "";
 | 
	
		
			
				|  |  |             if (StringUtils.isNoneBlank(dept)) {
 | 
	
		
			
				|  |  |                 deptCondition += " (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '" + dept + "' and dh.del=1 )";
 | 
	
	
		
			
				|  | @ -869,7 +1056,7 @@ public class DailyReportUploadService {
 | 
	
		
			
				|  |  |                     stateCondition += " and d1.state='"+state+"' ";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 String sql = " select d1.id,d1.state from base_doctor_daily_report_upload d1 where d1.doctor_id='"+id+"' and d1.report_date>='"+date+"' and d1.report_date<='"+date+"' ORDER BY report_date desc ";
 | 
	
		
			
				|  |  |                 String sql = " select d1.id,d1.state,total_hour from base_doctor_daily_report_upload d1 where d1.doctor_id='"+id+"' and d1.report_date>='"+date+"' and d1.report_date<='"+date+"' ORDER BY report_date desc ";
 | 
	
		
			
				|  |  |                 List<Map<String, Object>> mapList1 = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |                 if (mapList1 != null && mapList1.size() != 0) {
 | 
	
		
			
				|  |  |                     for (Map<String, Object> map1 : mapList1) {
 | 
	
	
		
			
				|  | @ -881,6 +1068,8 @@ public class DailyReportUploadService {
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                         map.put("uploadState", "已上报");
 | 
	
		
			
				|  |  |                         map.put("uploadId", map1.get("id").toString());
 | 
	
		
			
				|  |  |                         map.put("totalHour", map1.get("total_hour"));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     map.put("recordList", mapList1);
 | 
	
		
			
				|  |  |                 } else {
 | 
	
	
		
			
				|  | @ -996,10 +1185,113 @@ public class DailyReportUploadService {
 | 
	
		
			
				|  |  |                 " JOIN base_doctor_hospital h ON h.doctor_code = d.id " +
 | 
	
		
			
				|  |  |                 " left join base_org t on t.id = h.org_code" +
 | 
	
		
			
				|  |  |                 " WHERE  " +
 | 
	
		
			
				|  |  |                 " 1=1 and d.del=1 ";
 | 
	
		
			
				|  |  |                 " 1=1 and d.del=1 and d.identity=0 ";
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(dept)) {
 | 
	
		
			
				|  |  |             sql += " AND h.dept_code = '" + dept + "'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(orgCode)) {
 | 
	
		
			
				|  |  |             sql += " AND h.org_code = '" + orgCode + "'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(key)) {
 | 
	
		
			
				|  |  |             sql += " AND (h.dept_name like '%" + key + "%' OR d.name like '%" + key + "%' OR d.expertise like '%" + key + "%') ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |         for (Map<String,Object> map:list){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String id = map.get("id").toString();
 | 
	
		
			
				|  |  |             List<BaseDailyReportUploadDO> dailyReportUploadDOS = dailyReportUploadDao.selectDailyReportByDoctorAndDate(id,DateUtil.getStringDateShort(),DateUtil.getStringDateShort());
 | 
	
		
			
				|  |  |             if (dailyReportUploadDOS!=null&&dailyReportUploadDOS.size()!=0){
 | 
	
		
			
				|  |  |                 BaseDailyReportUploadDO dailyReportUploadDO = dailyReportUploadDOS.get(0);
 | 
	
		
			
				|  |  |                 List<BaseDailyReportDetailDO> detailDOList = reportDetailDao.findByReportId(dailyReportUploadDO.getId());
 | 
	
		
			
				|  |  |                 List<BaseDailyReportLogDO> reportLogDOS = dailyReportLogDao.findByReportId(dailyReportUploadDO.getId());
 | 
	
		
			
				|  |  |                 dailyReportUploadDO.setDailyReportLogDOList(reportLogDOS);
 | 
	
		
			
				|  |  |                 dailyReportUploadDO.setDetailDOList(detailDOList);
 | 
	
		
			
				|  |  |                 String verifiedName = "";
 | 
	
		
			
				|  |  |                 if ("1".equals(dailyReportUploadDO.getState())) {
 | 
	
		
			
				|  |  |                     verifiedName = "已核实";
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     verifiedName = "未核实";
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 map.put("verifiedName",verifiedName);
 | 
	
		
			
				|  |  |                 map.put("reportUploadDO",dailyReportUploadDO);
 | 
	
		
			
				|  |  |             }else {
 | 
	
		
			
				|  |  |                 map.put("reportUploadDO",null);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (list != null && list.size() > 0 && StringUtils.isNotBlank(doctorCode)) {
 | 
	
		
			
				|  |  |             //排序
 | 
	
		
			
				|  |  |             for (int i = 0; i < list.size(); i++) {
 | 
	
		
			
				|  |  |                 String id = (String) list.get(i).get("id");
 | 
	
		
			
				|  |  |                 if (doctorCode.equals(id)) {
 | 
	
		
			
				|  |  |                     Collections.swap(list, 0, i);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return list;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param orgCode
 | 
	
		
			
				|  |  |      * @param dept
 | 
	
		
			
				|  |  |      * @param doctorCode
 | 
	
		
			
				|  |  |      * @param key
 | 
	
		
			
				|  |  |      * @param flag 是否核实1是0否
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public List<Map<String, Object>> findDoctorByHospitalAndDeptHeshi(String doctor,String orgCode, String dept, String doctorCode,String key, Integer flag) {
 | 
	
		
			
				|  |  |         String sql = "SELECT " +
 | 
	
		
			
				|  |  |                 " d.id AS \"id\", " +
 | 
	
		
			
				|  |  |                 " d.photo AS \"photo\", " +
 | 
	
		
			
				|  |  |                 " d.name AS \"name\", " +
 | 
	
		
			
				|  |  |                 " d.expertise AS \"expertise\"," +
 | 
	
		
			
				|  |  |                 " d.introduce AS \"introduce\"," +
 | 
	
		
			
				|  |  |                 " d.job_title_code AS \"jobTitleCode\", " +
 | 
	
		
			
				|  |  |                 " d.job_title_name AS \"jobTitleName\"," +
 | 
	
		
			
				|  |  |                 " d.charge_type AS \"chargeType\"," +
 | 
	
		
			
				|  |  |                 " d.outpatient_type AS \"outpatientType\"," +
 | 
	
		
			
				|  |  |                 " d.consult_status AS \"consultStatus\"," +
 | 
	
		
			
				|  |  |                 " h.dept_code AS \"deptCode\","+
 | 
	
		
			
				|  |  |                 " h.dept_name AS \"deptName\","+
 | 
	
		
			
				|  |  |                 " h.org_code AS \"orgCode\","+
 | 
	
		
			
				|  |  |                 " h.org_name AS \"orgName\","+
 | 
	
		
			
				|  |  |                 " t.photo AS \"hosptialphoto\","+
 | 
	
		
			
				|  |  |                 " d.id_type AS \"idType\","+
 | 
	
		
			
				|  |  |                 " d.id_card_type AS \"idCardType\" "+
 | 
	
		
			
				|  |  |                 " FROM " +
 | 
	
		
			
				|  |  |                 " base_doctor d " +
 | 
	
		
			
				|  |  |                 " JOIN base_doctor_hospital h ON h.doctor_code = d.id " +
 | 
	
		
			
				|  |  |                 " left join base_org t on t.id = h.org_code" +
 | 
	
		
			
				|  |  |                 " WHERE  " +
 | 
	
		
			
				|  |  |                 " 1=1 and d.del=1 and d.identity=0 ";
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(dept)) {
 | 
	
		
			
				|  |  |             sql += " AND h.dept_code = '" + dept + "'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(doctor)){
 | 
	
		
			
				|  |  |             WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("dailyHeshiConfig");
 | 
	
		
			
				|  |  |             String buffer = "";
 | 
	
		
			
				|  |  |             if (hospitalSysDictDO!=null){
 | 
	
		
			
				|  |  |                 JSONArray array = JSONArray.parseArray(hospitalSysDictDO.getDictValue());
 | 
	
		
			
				|  |  |                 for (int i=0;i<array.size();i++){
 | 
	
		
			
				|  |  |                     JSONObject object = array.getJSONObject(i);
 | 
	
		
			
				|  |  |                     String header = object.getString("header");
 | 
	
		
			
				|  |  |                     if (header.equalsIgnoreCase(doctor)){
 | 
	
		
			
				|  |  |                         JSONArray jsonArray = object.getJSONArray("data");
 | 
	
		
			
				|  |  |                         for (int j=0;j<jsonArray.size();j++){
 | 
	
		
			
				|  |  |                             String str = jsonArray.getString(j);
 | 
	
		
			
				|  |  |                             buffer +="'"+str+"',";
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                         buffer =buffer.substring(0,buffer.length()-1);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (StringUtils.isNoneBlank(buffer)){
 | 
	
		
			
				|  |  |                 sql += " and d.id IN ("+buffer+")";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(orgCode)) {
 | 
	
		
			
				|  |  |             sql += " AND h.org_code = '" + orgCode + "'";
 | 
	
		
			
				|  |  |         }
 | 
	
	
		
			
				|  | @ -1014,6 +1306,8 @@ public class DailyReportUploadService {
 | 
	
		
			
				|  |  |             if (dailyReportUploadDOS!=null&&dailyReportUploadDOS.size()!=0){
 | 
	
		
			
				|  |  |                 BaseDailyReportUploadDO dailyReportUploadDO = dailyReportUploadDOS.get(0);
 | 
	
		
			
				|  |  |                 List<BaseDailyReportDetailDO> detailDOList = reportDetailDao.findByReportId(dailyReportUploadDO.getId());
 | 
	
		
			
				|  |  |                 List<BaseDailyReportLogDO> reportLogDOS = dailyReportLogDao.findByReportId(dailyReportUploadDO.getId());
 | 
	
		
			
				|  |  |                 dailyReportUploadDO.setDailyReportLogDOList(reportLogDOS);
 | 
	
		
			
				|  |  |                 dailyReportUploadDO.setDetailDOList(detailDOList);
 | 
	
		
			
				|  |  |                 String verifiedName = "";
 | 
	
		
			
				|  |  |                 if ("1".equals(dailyReportUploadDO.getState())) {
 | 
	
	
		
			
				|  | @ -1060,7 +1354,7 @@ public class DailyReportUploadService {
 | 
	
		
			
				|  |  |             endDate = DateUtil.getLastDayOfMonth();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String day = DateUtil.getTwoDay(endDate, startDate);
 | 
	
		
			
				|  |  |         String doctorSql = " select COUNT(1) as 'total' from base_doctor d where d.del=1 ";
 | 
	
		
			
				|  |  |         String doctorSql = " select COUNT(1) as 'total' from base_doctor d where d.del=1 and d.identity=0  ";
 | 
	
		
			
				|  |  |         Integer total = 0;//总人次
 | 
	
		
			
				|  |  |         String sqlCondition = "";
 | 
	
		
			
				|  |  |         if (level==2){
 | 
	
	
		
			
				|  | @ -1174,7 +1468,7 @@ public class DailyReportUploadService {
 | 
	
		
			
				|  |  |         JSONObject object = new JSONObject();
 | 
	
		
			
				|  |  |         String day = DateUtil.getTwoDay(endDate, startDate);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String doctorSql = " select COUNT(1) as \"total\" from base_doctor d where d.del=1 ";
 | 
	
		
			
				|  |  |         String doctorSql = " select COUNT(1) as \"total\" from base_doctor d where d.del=1 and d.identity=0 ";
 | 
	
		
			
				|  |  |         Integer total = 0;//总人次
 | 
	
		
			
				|  |  |         String sql = "select COUNT(DISTINCT d.id) as \"total\" from base_doctor_daily_report_upload d inner join base_daily_report_detail de " +
 | 
	
		
			
				|  |  |                 " on d.id = de.report_id where 1=1 ";
 | 
	
	
		
			
				|  | @ -1184,7 +1478,7 @@ public class DailyReportUploadService {
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String idTypeCondition = " ";
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(idType)) {
 | 
	
		
			
				|  |  |             idTypeCondition += "  (select d1.id from base_doctor d1 where 1=1 and d1.id_type = '" + idType + "')";
 | 
	
		
			
				|  |  |             idTypeCondition += "  (select d1.id from base_doctor d1 where 1=1 and  d1.identity=0 and d1.id_type = '" + idType + "')";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(deptCondition)) {
 | 
	
		
			
				|  |  |             doctorSql += " and d.id IN " + deptCondition;
 |