|
@ -0,0 +1,1294 @@
|
|
|
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.BaseDailyReportUploadDao;
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorRoleDao;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
|
|
|
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.BaseDailyReportUploadDO;
|
|
|
import com.yihu.jw.entity.healthUpload.BaseDoctorMemberDO;
|
|
|
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
|
|
|
import com.yihu.jw.entity.hospital.enterprise.WxEnterpriseUserDO;
|
|
|
import com.yihu.jw.healthUpload.dao.BaseDoctorMemberDao;
|
|
|
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
|
|
|
import com.yihu.jw.util.common.PwdUtil;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.util.idcard.IdCardUtil;
|
|
|
import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
|
|
|
import com.yihu.jw.utils.StringUtil;
|
|
|
import com.yihu.jw.wechat.dao.WxPushLogDao;
|
|
|
import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
|
|
|
import com.yihu.jw.wechat.enterprise.EnterpriseService;
|
|
|
import com.yihu.jw.wechat.enterprise.dao.WxEnterpriseUserDao;
|
|
|
import com.yihu.jw.wechat.service.WxAccessTokenService;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.io.OutputStream;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* Created by Bing on 2022/7/25.
|
|
|
*/
|
|
|
@Service
|
|
|
public class DailyReportUploadService {
|
|
|
|
|
|
@Autowired
|
|
|
private BaseDailyReportUploadDao dailyReportUploadDao;
|
|
|
@Autowired
|
|
|
private BaseDailyReportDetailDao reportDetailDao;
|
|
|
@Autowired
|
|
|
private BaseDoctorMemberDao doctorMemberDao;
|
|
|
@Autowired
|
|
|
private BaseDoctorDao baseDoctorDao;
|
|
|
@Autowired
|
|
|
private BaseDoctorRoleDao doctorRoleDao;
|
|
|
@Autowired
|
|
|
private WlyyHospitalSysDictDao hospitalSysDictDao;
|
|
|
@Autowired
|
|
|
private WxTemplateConfigDao wxTemplateConfigDao;
|
|
|
@Autowired
|
|
|
private BaseDoctorHospitalDao baseDoctorHospitalDao;
|
|
|
@Autowired
|
|
|
private WxAccessTokenService wxAccessTokenService;
|
|
|
@Autowired
|
|
|
private WeixinMessagePushUtils weixinMessagePushUtils;
|
|
|
@Autowired
|
|
|
private WxPushLogDao wxPushLogDao;
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
@Autowired
|
|
|
private WxEnterpriseUserDao wxEnterpriseUserDao;
|
|
|
@Value("${wechat.id}")
|
|
|
private String wechatId;
|
|
|
@Autowired
|
|
|
private EnterpriseService enterpriseService;
|
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(DailyReportUploadService.class);
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 新增医生成员关系
|
|
|
*
|
|
|
* @param doctorId
|
|
|
* @param ids 逗号隔开
|
|
|
* @return
|
|
|
*/
|
|
|
public List<BaseDoctorMemberDO> saveAndCreateMember(String doctorId, String ids) {
|
|
|
String str[] = ids.split(",");
|
|
|
List<BaseDoctorMemberDO> baseDoctorMemberDOList = new ArrayList<>();
|
|
|
for (int i = 0; i < str.length; i++) {
|
|
|
String memberId = str[i];
|
|
|
BaseDoctorMemberDO memberDO = doctorMemberDao.findByDoctorIdAndMemberIdAndDel(doctorId, memberId);
|
|
|
if (memberDO == null) {
|
|
|
BaseDoctorMemberDO baseDoctorMemberDO = new BaseDoctorMemberDO();
|
|
|
baseDoctorMemberDO.setDel(1);
|
|
|
baseDoctorMemberDO.setDoctorId(doctorId);
|
|
|
baseDoctorMemberDO.setMemberId(memberId);
|
|
|
baseDoctorMemberDO.setCreateTime(new Date());
|
|
|
baseDoctorMemberDO.setUpdateTime(new Date());
|
|
|
baseDoctorMemberDO = doctorMemberDao.save(baseDoctorMemberDO);
|
|
|
baseDoctorMemberDOList.add(baseDoctorMemberDO);
|
|
|
}
|
|
|
}
|
|
|
return baseDoctorMemberDOList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除某个成员
|
|
|
*
|
|
|
* @param id 成员id
|
|
|
* @return
|
|
|
*/
|
|
|
public BaseDoctorMemberDO delDoctorMember(String id) {
|
|
|
BaseDoctorMemberDO baseDoctorMemberDO = doctorMemberDao.findById(id);
|
|
|
baseDoctorMemberDO.setDel(0);
|
|
|
baseDoctorMemberDO = doctorMemberDao.save(baseDoctorMemberDO);
|
|
|
return baseDoctorMemberDO;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询医生的成员列表
|
|
|
*
|
|
|
* @param doctorId
|
|
|
* @return
|
|
|
*/
|
|
|
public List<BaseDoctorMemberDO> selectByDoctorId(String doctorId) {
|
|
|
List<BaseDoctorMemberDO> baseDoctorMemberDOList = doctorMemberDao.findByDoctorIdAndDel(doctorId);
|
|
|
BaseDoctorMemberDO memberDO1 = doctorMemberDao.findByDoctorIdAndMemberIdAndDel(doctorId, doctorId);
|
|
|
//添加本人
|
|
|
if (memberDO1 == null) {
|
|
|
BaseDoctorMemberDO baseDoctorMemberDO = new BaseDoctorMemberDO();
|
|
|
baseDoctorMemberDO.setDel(1);
|
|
|
baseDoctorMemberDO.setDoctorId(doctorId);
|
|
|
baseDoctorMemberDO.setMemberId(doctorId);
|
|
|
baseDoctorMemberDO.setCreateTime(new Date());
|
|
|
baseDoctorMemberDO.setUpdateTime(new Date());
|
|
|
baseDoctorMemberDO = doctorMemberDao.save(baseDoctorMemberDO);
|
|
|
}
|
|
|
for (BaseDoctorMemberDO memberDO : baseDoctorMemberDOList) {
|
|
|
BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(memberDO.getMemberId());
|
|
|
if (baseDoctorDO != null) {
|
|
|
memberDO.setBaseDoctorDO(baseDoctorDO);
|
|
|
}
|
|
|
}
|
|
|
return baseDoctorMemberDOList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 新增加医生信息
|
|
|
*
|
|
|
* @param photo
|
|
|
* @param name
|
|
|
* @param idcard
|
|
|
* @param sex
|
|
|
* @param mobile
|
|
|
* @param dept
|
|
|
* @param deptName
|
|
|
* @param idCardType
|
|
|
* @param idType
|
|
|
* @return
|
|
|
*/
|
|
|
public BaseDoctorDO saveDoctorInfo(String id, String photo, String name, String idcard, String sex, String mobile, String dept, String deptName, String idCardType, String idType, Integer mark) throws Exception {
|
|
|
BaseDoctorDO baseDoctorDO = new BaseDoctorDO();
|
|
|
if (StringUtils.isNoneBlank(id)) {
|
|
|
baseDoctorDO = baseDoctorDao.findById(id);
|
|
|
baseDoctorDO.setIdCardType(idCardType);
|
|
|
baseDoctorDO.setIdType(idType);
|
|
|
baseDoctorDO.setPhoto(photo);
|
|
|
baseDoctorDO.setName(name);
|
|
|
baseDoctorDO.setIdcard(idcard);
|
|
|
baseDoctorDO.setSex(Integer.parseInt(sex));
|
|
|
baseDoctorDO.setMobile(mobile);
|
|
|
baseDoctorDO.setMark(mark);
|
|
|
String deptCode = dept;
|
|
|
baseDoctorDO.setChargeType("1");
|
|
|
baseDoctorDO = baseDoctorDao.save(baseDoctorDO);
|
|
|
List<BaseDoctorHospitalDO> baseDoctorHospitalDOS = baseDoctorHospitalDao.findByDoctorCode(baseDoctorDO.getId());
|
|
|
if (null != baseDoctorHospitalDOS && baseDoctorHospitalDOS.size() > 0) {
|
|
|
baseDoctorHospitalDao.delete(baseDoctorHospitalDOS);
|
|
|
BaseDoctorHospitalDO baseDoctorHospitalDO = new BaseDoctorHospitalDO();
|
|
|
baseDoctorHospitalDO.setOrgCode("350211A1002");
|
|
|
baseDoctorHospitalDO.setOrgName("马銮湾医院");
|
|
|
baseDoctorHospitalDO.setDoctorCode(baseDoctorDO.getId());
|
|
|
baseDoctorHospitalDO.setDeptCode(deptCode);
|
|
|
baseDoctorHospitalDO.setDeptName(deptName);
|
|
|
baseDoctorHospitalDO.setDel("1");
|
|
|
baseDoctorHospitalDO.setCreateTime(new Date());
|
|
|
baseDoctorHospitalDao.save(baseDoctorHospitalDO);
|
|
|
} else {
|
|
|
BaseDoctorHospitalDO baseDoctorHospitalDO = new BaseDoctorHospitalDO();
|
|
|
baseDoctorHospitalDO.setOrgCode("350211A1002");
|
|
|
baseDoctorHospitalDO.setOrgName("马銮湾医院");
|
|
|
baseDoctorHospitalDO.setDoctorCode(baseDoctorDO.getId());
|
|
|
baseDoctorHospitalDO.setDeptCode(deptCode);
|
|
|
baseDoctorHospitalDO.setDeptName(deptName);
|
|
|
baseDoctorHospitalDO.setDel("1");
|
|
|
baseDoctorHospitalDO.setCreateTime(new Date());
|
|
|
baseDoctorHospitalDao.save(baseDoctorHospitalDO);
|
|
|
}
|
|
|
} else {
|
|
|
baseDoctorDO.setIdcard(idcard);
|
|
|
baseDoctorDO.setBirthday(IdCardUtil.getBirthdayForIdcard(idcard));
|
|
|
baseDoctorDO.setSex(Integer.parseInt(sex));
|
|
|
baseDoctorDO.setLocked(0);
|
|
|
baseDoctorDO.setEnabled(1);
|
|
|
baseDoctorDO.setMark(mark);
|
|
|
String disableFlag = "0";
|
|
|
//互联网医院:1停用,0使用 转 i健康:1正常,0作废
|
|
|
baseDoctorDO.setDel("1".equals(disableFlag) ? "0" : "1");
|
|
|
baseDoctorDO.setMobile("0");
|
|
|
baseDoctorDO.setName(name);
|
|
|
baseDoctorDO.setIsFamous(0);
|
|
|
baseDoctorDO.setCreateTime(new Date());
|
|
|
baseDoctorDO.setUpdateTime(new Date());
|
|
|
baseDoctorDO.setIdCardType(idCardType);
|
|
|
baseDoctorDO.setIdType(idType);
|
|
|
baseDoctorDO.setPhoto(photo);
|
|
|
baseDoctorDO.setMobile(mobile);
|
|
|
baseDoctorDO.setChargeType("1");
|
|
|
|
|
|
if (StringUtils.isNotBlank(mobile)) {
|
|
|
baseDoctorDO.setSalt(PwdUtil.randomString(5));
|
|
|
try {
|
|
|
baseDoctorDO.setPassword(com.yihu.utils.security.MD5.md5Hex(baseDoctorDO.getMobile().substring(baseDoctorDO.getMobile().length() - 6) + "{" + baseDoctorDO.getSalt() + "}"));
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
} else {
|
|
|
baseDoctorDO.setPassword(com.yihu.utils.security.MD5.md5Hex("123456" + "{" + baseDoctorDO.getSalt() + "}"));
|
|
|
}
|
|
|
// 用医生和机构id、部门判断数据是否存在,若不存在则保存医生机构关联关系
|
|
|
String deptCode = dept;
|
|
|
baseDoctorDO = baseDoctorDao.save(baseDoctorDO);
|
|
|
List<BaseDoctorHospitalDO> baseDoctorHospitalDOS = baseDoctorHospitalDao.findByDoctorCode(baseDoctorDO.getId());
|
|
|
if (null != baseDoctorHospitalDOS && baseDoctorHospitalDOS.size() > 0) {
|
|
|
baseDoctorHospitalDao.delete(baseDoctorHospitalDOS);
|
|
|
BaseDoctorHospitalDO baseDoctorHospitalDO = new BaseDoctorHospitalDO();
|
|
|
baseDoctorHospitalDO.setOrgCode("350211A1002");
|
|
|
baseDoctorHospitalDO.setOrgName("马銮湾医院");
|
|
|
baseDoctorHospitalDO.setDoctorCode(baseDoctorDO.getId());
|
|
|
baseDoctorHospitalDO.setDeptCode(deptCode);
|
|
|
baseDoctorHospitalDO.setDeptName(deptName);
|
|
|
baseDoctorHospitalDO.setDel("1");
|
|
|
baseDoctorHospitalDO.setCreateTime(new Date());
|
|
|
baseDoctorHospitalDao.save(baseDoctorHospitalDO);
|
|
|
} else {
|
|
|
BaseDoctorHospitalDO baseDoctorHospitalDO = new BaseDoctorHospitalDO();
|
|
|
baseDoctorHospitalDO.setOrgCode("350211A1002");
|
|
|
baseDoctorHospitalDO.setOrgName("马銮湾医院");
|
|
|
baseDoctorHospitalDO.setDoctorCode(baseDoctorDO.getId());
|
|
|
baseDoctorHospitalDO.setDeptCode(deptCode);
|
|
|
baseDoctorHospitalDO.setDeptName(deptName);
|
|
|
baseDoctorHospitalDO.setDel("1");
|
|
|
baseDoctorHospitalDO.setCreateTime(new Date());
|
|
|
baseDoctorHospitalDao.save(baseDoctorHospitalDO);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
return baseDoctorDO;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询医生的成员列表带有已上报次数
|
|
|
* @param doctorId
|
|
|
* @return
|
|
|
*/
|
|
|
public List<BaseDoctorMemberDO> selectCountByDoctorId(String doctorId){
|
|
|
List<BaseDoctorMemberDO> baseDoctorMemberDOList = doctorMemberDao.findByDoctorIdAndDel(doctorId);
|
|
|
for (BaseDoctorMemberDO memberDO : baseDoctorMemberDOList) {
|
|
|
BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(memberDO.getMemberId());
|
|
|
if (baseDoctorDO != null) {
|
|
|
memberDO.setBaseDoctorDO(baseDoctorDO);
|
|
|
}
|
|
|
List<BaseDailyReportUploadDO> dailyReportUploadDOS = dailyReportUploadDao.findByDoctorId(doctorId);
|
|
|
memberDO.setCount(dailyReportUploadDOS.size()+"");
|
|
|
}
|
|
|
return baseDoctorMemberDOList;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 查询某一个成员id
|
|
|
*
|
|
|
* @param id 成员id
|
|
|
* @return
|
|
|
*/
|
|
|
public BaseDoctorMemberDO selectById(String id) {
|
|
|
BaseDoctorMemberDO baseDoctorMemberDO = doctorMemberDao.findById(id);
|
|
|
if (baseDoctorMemberDO==null){
|
|
|
return null;
|
|
|
}
|
|
|
BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(baseDoctorMemberDO.getMemberId());
|
|
|
if (baseDoctorDO != null) {
|
|
|
baseDoctorMemberDO.setBaseDoctorDO(baseDoctorDO);
|
|
|
}
|
|
|
List<BaseDoctorHospitalDO> doctorHospitalDOS = baseDoctorHospitalDao.findByDoctorCode(baseDoctorMemberDO.getMemberId());
|
|
|
baseDoctorMemberDO.setDoctorHospitalDOS(doctorHospitalDOS);
|
|
|
return baseDoctorMemberDO;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 提交每日上报信息
|
|
|
* @param doctorId
|
|
|
* @param report_date
|
|
|
* @param week_name
|
|
|
* @param detailDOList
|
|
|
* @return
|
|
|
* @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 {
|
|
|
BaseDoctorDO doctorDO = baseDoctorDao.findById(doctorId);
|
|
|
List<BaseDoctorHospitalDO> doctorHospitalDOS = baseDoctorHospitalDao.findByDoctorCode(doctorId);
|
|
|
if (null==doctorDO){
|
|
|
throw new Exception("上报人不存在");
|
|
|
}
|
|
|
if (1==leaveState){
|
|
|
if (StringUtils.isNotBlank(leaveHour)){
|
|
|
if (Integer.parseInt(leaveHour)<8&&detailDOList.size()==0){
|
|
|
throw new Exception("上传失败,请假未满8小时需要提交完成内容");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (StringUtil.isBlank(report_date)){
|
|
|
report_date = DateUtil.getStringDateShort();
|
|
|
week_name = DateUtil.getWeek(report_date);
|
|
|
}
|
|
|
BaseDailyReportUploadDO dailyReportUploadDO = dailyReportUploadDao.findByDoctorIdAndReportDate(doctorId,report_date);
|
|
|
if (null==dailyReportUploadDO){
|
|
|
dailyReportUploadDO = new BaseDailyReportUploadDO();
|
|
|
dailyReportUploadDO.setState(0);
|
|
|
}else{
|
|
|
reportDetailDao.deleteByReportIdAndState(dailyReportUploadDO.getId(),0);
|
|
|
}
|
|
|
dailyReportUploadDO.setDoctorId(doctorId);
|
|
|
dailyReportUploadDO.setDoctorName(doctorDO.getName());
|
|
|
dailyReportUploadDO.setReportDate(report_date);
|
|
|
dailyReportUploadDO.setWeekName(week_name);
|
|
|
dailyReportUploadDO.setLeaveState(leaveState);
|
|
|
dailyReportUploadDO.setLeaveHour(leaveHour);
|
|
|
dailyReportUploadDO = dailyReportUploadDao.save(dailyReportUploadDO);
|
|
|
for (BaseDailyReportDetailDO tmp :detailDOList){
|
|
|
tmp.setReportId(dailyReportUploadDO.getId());
|
|
|
}
|
|
|
if (detailDOList.size()>0){
|
|
|
reportDetailDao.save(detailDOList);
|
|
|
}
|
|
|
List<BaseDailyReportDetailDO> detailDOS = reportDetailDao.findByReportId(dailyReportUploadDO.getId());
|
|
|
if (reportDetailDao.findByReportIdAndState(dailyReportUploadDO.getId(),0).size()>0){
|
|
|
dailyReportUploadDO.setState(0);
|
|
|
}
|
|
|
|
|
|
String senderID="";//日报发送对象
|
|
|
String sql = " select dict_value from wlyy_hospital_sys_dict where dict_name='BOOS_ADMIN_SENDER' ";
|
|
|
List<String> boosSenderIds = jdbcTemplate.queryForList(sql,String.class);
|
|
|
String boosID = "";
|
|
|
if (boosSenderIds.size()>0){
|
|
|
boosID=boosSenderIds.get(0);
|
|
|
}
|
|
|
List<BaseDoctorRoleDO> roleDOS = doctorRoleDao.findByDoctorCode(doctorId);
|
|
|
if (roleDOS.size()==0){//普通员工 需要查询对应上级人员
|
|
|
if (doctorHospitalDOS != null && doctorHospitalDOS.size() != 0) {
|
|
|
BaseDoctorHospitalDO doctorHospitalDO = doctorHospitalDOS.get(0);
|
|
|
sql = " select role.doctor_code from base_doctor_role role INNER JOIN base_doctor_hospital dh " +
|
|
|
"on role.doctor_code = dh.doctor_code and dh.dept_code='"+doctorHospitalDO.getDeptCode()+"' " +
|
|
|
"where role.role_code='deptAdmin' ";
|
|
|
List<String> deptAdmins = jdbcTemplate.queryForList(sql,String.class);
|
|
|
if (deptAdmins.size()>0){
|
|
|
senderID = deptAdmins.get(0);
|
|
|
}else {
|
|
|
senderID=boosID;
|
|
|
}
|
|
|
}
|
|
|
}else {//部门管理员 发送对象为老板
|
|
|
senderID = boosID;
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(senderID)){
|
|
|
BaseDoctorDO remindDoctorDO = baseDoctorDao.findById(senderID);
|
|
|
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?mode=verify&id="+dailyReportUploadDO.getId();
|
|
|
String res = enterpriseService.sendTWMesByDoctor(wechatId,remindDoctorDO.getId(),title,des,url);
|
|
|
}
|
|
|
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
dailyReportUploadDao.save(dailyReportUploadDO);
|
|
|
dailyReportUploadDO.setDetailDOList(detailDOS);
|
|
|
|
|
|
return dailyReportUploadDO;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 核实审核信息
|
|
|
* @return
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public BaseDailyReportUploadDO verifiedItem(String doctorId,String reportId,List<BaseDailyReportDetailDO> detailDOList) throws Exception {
|
|
|
BaseDoctorDO doctorDO = baseDoctorDao.findById(doctorId);
|
|
|
if (null==doctorDO){
|
|
|
throw new Exception("无权限审核");
|
|
|
}
|
|
|
BaseDailyReportUploadDO dailyReportUploadDO = null;
|
|
|
dailyReportUploadDO = dailyReportUploadDao.findOne(reportId);
|
|
|
if (null==dailyReportUploadDO){
|
|
|
throw new Exception("核实记录未查询到");
|
|
|
}
|
|
|
if(detailDOList.size()>0){//无完成事项内容
|
|
|
boolean doubt =false;
|
|
|
for (BaseDailyReportDetailDO tmp:detailDOList){
|
|
|
if (1==tmp.getDoubt()){
|
|
|
doubt = true;
|
|
|
}
|
|
|
tmp.setVerificationTime(new Date());
|
|
|
}
|
|
|
reportDetailDao.save(detailDOList);
|
|
|
List<BaseDailyReportDetailDO> detailDOS = reportDetailDao.findByReportId(dailyReportUploadDO.getId());
|
|
|
dailyReportUploadDO.setDetailDOList(detailDOS);
|
|
|
if (reportDetailDao.findByReportIdAndState(dailyReportUploadDO.getId(),0).size()==0){
|
|
|
dailyReportUploadDO.setState(1);
|
|
|
dailyReportUploadDao.save(dailyReportUploadDO);
|
|
|
}
|
|
|
if (doubt==true){//有疑惑,推送给总经办"0592181"和老板"0592008";//老板id
|
|
|
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){
|
|
|
try {
|
|
|
BaseDoctorDO remindDoctorDO = baseDoctorDao.findById(senderUser);
|
|
|
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()+"对"+dailyReportUploadDO.getDoctorName()+"已提交的每日日报有存疑,请点击前往审核。";
|
|
|
String url = "https://ehr.yihu.com/hlwyy/zjxl/dailyReport/#/workSummary/commit?mode=verify&id="+dailyReportUploadDO.getId();
|
|
|
String res = enterpriseService.sendTWMesByDoctor(wechatId,remindDoctorDO.getId(),title,des,url);
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}else {
|
|
|
dailyReportUploadDO.setState(1);
|
|
|
dailyReportUploadDao.save(dailyReportUploadDO);
|
|
|
}
|
|
|
|
|
|
return dailyReportUploadDO;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*核实每日报表疑惑
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public BaseDailyReportUploadDO verifiedDoubtItem(String doctorId,List<BaseDailyReportDetailDO> detailDOList) throws Exception {
|
|
|
BaseDoctorDO doctorDO = baseDoctorDao.findById(doctorId);
|
|
|
if (null==doctorDO){
|
|
|
throw new Exception("无权限审核");
|
|
|
}
|
|
|
String sql = " select dict_value from wlyy_hospital_sys_dict where dict_name='MRRB_DOUBT_SENDER' ";
|
|
|
List<String> doubtSendUser = jdbcTemplate.queryForList(sql,String.class);
|
|
|
if (!doubtSendUser.contains(doctorId)){
|
|
|
throw new Exception("无权限审核");
|
|
|
}
|
|
|
BaseDailyReportUploadDO dailyReportUploadDO = new BaseDailyReportUploadDO();
|
|
|
if(detailDOList.size()>0) {
|
|
|
dailyReportUploadDO = dailyReportUploadDao.findOne(detailDOList.get(0).getReportId());
|
|
|
if (null == dailyReportUploadDO) {
|
|
|
throw new Exception("核实记录未查询到");
|
|
|
}
|
|
|
reportDetailDao.save(detailDOList);
|
|
|
}
|
|
|
return dailyReportUploadDO;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取当天日报上传记录
|
|
|
* @param doctor
|
|
|
* @return
|
|
|
*/
|
|
|
public BaseDailyReportUploadDO selectReportByDoctorId2(String doctor){
|
|
|
String nowDate = DateUtil.getStringDateShort();
|
|
|
BaseDailyReportUploadDO dailyReportUploadDO = dailyReportUploadDao.findByDoctorIdAndReportDate(doctor,nowDate);
|
|
|
if (null==dailyReportUploadDO){
|
|
|
return null;
|
|
|
}else{
|
|
|
List<BaseDailyReportDetailDO> detailDOS = reportDetailDao.findByReportId(dailyReportUploadDO.getId());
|
|
|
dailyReportUploadDO.setDetailDOList(detailDOS);
|
|
|
}
|
|
|
return dailyReportUploadDO;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询成员的日报上传记录
|
|
|
* @param doctorId
|
|
|
* @param startDate
|
|
|
* @param endDate
|
|
|
* @param page
|
|
|
* @param pageSize
|
|
|
* @return
|
|
|
*/
|
|
|
public Page<BaseDailyReportUploadDO> selectReportByDoctorId(String doctorId,String startDate,String endDate,Integer page,Integer pageSize){
|
|
|
PageRequest pageRequest = new PageRequest(page - 1, pageSize);
|
|
|
Page<BaseDailyReportUploadDO> list = null;
|
|
|
if (StringUtils.isNoneBlank(startDate)) {
|
|
|
list = dailyReportUploadDao.selectDailyReportByDoctorAndDateAndPage(doctorId, startDate, endDate, pageRequest);
|
|
|
}else {
|
|
|
list = dailyReportUploadDao.selectDailyReportByDoctor(doctorId, pageRequest);
|
|
|
}
|
|
|
for (BaseDailyReportUploadDO tmp:list){
|
|
|
List<BaseDailyReportDetailDO> detailDOS = reportDetailDao.findByReportId(tmp.getId());
|
|
|
tmp.setDetailDOList(detailDOS);
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据id查看日报记录
|
|
|
* @param reportId
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public BaseDailyReportUploadDO selectReportById(String reportId) throws Exception {
|
|
|
BaseDailyReportUploadDO reportUploadDO = dailyReportUploadDao.findOne(reportId);
|
|
|
if (null==reportUploadDO){
|
|
|
throw new Exception("未找到日报记录");
|
|
|
}else {
|
|
|
List<BaseDailyReportDetailDO> detailDOS = reportDetailDao.findByReportId(reportUploadDO.getId());
|
|
|
reportUploadDO.setDetailDOList(detailDOS);
|
|
|
}
|
|
|
return reportUploadDO;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 医生首页
|
|
|
* @param dept
|
|
|
* @param level
|
|
|
* @param doctorId
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject selectDailyReportByRole(String dept,Integer level,String doctorId){
|
|
|
JSONObject result = new JSONObject();
|
|
|
String nowDate = DateUtil.getStringDateShort();
|
|
|
BaseDailyReportUploadDO reportUploadDO = dailyReportUploadDao.findByDoctorIdAndReportDate(doctorId,nowDate);
|
|
|
if (null==reportUploadDO){
|
|
|
reportUploadDO = new BaseDailyReportUploadDO();
|
|
|
}
|
|
|
//今日本人上报数量
|
|
|
String benrenTotalSql = " select count(1) from base_doctor_daily_report_upload where doctor_id='"+doctorId+"' and report_date>='"+nowDate+"' and report_date<='"+nowDate+"' ";
|
|
|
//本人已上报数量
|
|
|
String benrenshangbaoTotalSql = " select count(1) from base_doctor_daily_report_upload where doctor_id='"+doctorId+"' ";
|
|
|
//本人上级未核实事项数
|
|
|
String benrenVerifiedSql = " select count(distinct up.id) from base_doctor_daily_report_upload up inner join base_daily_report_detail de on up.id = de.report_id" +
|
|
|
" where up.doctor_id='"+doctorId+"' and de.state=1 and report_date>='"+nowDate+"' and report_date<='"+nowDate+"' ";
|
|
|
//本人上级已核实事项数
|
|
|
String benrenNotVerifiedSql = " select count(distinct up.id) from base_doctor_daily_report_upload up inner join base_daily_report_detail de on up.id = de.report_id" +
|
|
|
" where up.doctor_id='"+doctorId+"' and de.state=0 and report_date>='"+nowDate+"' and report_date<='"+nowDate+"' ";
|
|
|
|
|
|
//科室总人数
|
|
|
String doctorTotalSql = "";
|
|
|
//科室总上报人数
|
|
|
String sqlTotalSql = "";
|
|
|
//科室已核实人数
|
|
|
String verifiedSql = "";
|
|
|
//科室未核实人数
|
|
|
String notVerifiedSql = "";
|
|
|
if (level == 1) {
|
|
|
//总人数
|
|
|
doctorTotalSql = " select COUNT(1) as 'total' from base_doctor d where d.del=1 ";
|
|
|
//今日上报人数
|
|
|
sqlTotalSql = " select count(1) from base_doctor_daily_report_upload where report_date>='"+nowDate+"' and report_date<='"+nowDate+"' ";
|
|
|
//今日核实数量
|
|
|
verifiedSql = " select count(distinct up.id) from base_doctor_daily_report_upload up inner join base_daily_report_detail de on up.id = de.report_id" +
|
|
|
" where de.state=1 and report_date>='"+nowDate+"' and report_date<='"+nowDate+"' ";
|
|
|
//今日未核实数量
|
|
|
notVerifiedSql = " select count(distinct up.id) from base_doctor_daily_report_upload up inner join base_daily_report_detail de on up.id = de.report_id" +
|
|
|
" where de.state=0 and report_date>='"+nowDate+"' and report_date<='"+nowDate+"' ";
|
|
|
} else if (level == 2) {
|
|
|
//总人次
|
|
|
doctorTotalSql = " select COUNT(1) as 'total' from base_doctor d where d.del=1 and id " +
|
|
|
" IN (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '" + dept + "' and dh.del=1 )";
|
|
|
//今日上报人数
|
|
|
sqlTotalSql = " select count(1) from base_doctor_daily_report_upload where report_date>='"+nowDate+"' and report_date<='"+nowDate+"' " +
|
|
|
" and doctor_id in (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '" + dept + "' and dh.del=1 ) ";
|
|
|
//今日核实数量
|
|
|
verifiedSql = " select count(distinct up.id) from base_doctor_daily_report_upload up inner join base_daily_report_detail de on up.id = de.report_id" +
|
|
|
" where de.state=1 and report_date>='"+nowDate+"' and report_date<='"+nowDate+"'" +
|
|
|
" and up.doctor_id in (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '" + dept + "' and dh.del=1 ) ";
|
|
|
//今日未核实数量
|
|
|
notVerifiedSql = " select count(distinct up.id) from base_doctor_daily_report_upload up inner join base_daily_report_detail de on up.id = de.report_id" +
|
|
|
" where de.state=0 and report_date>='"+nowDate+"' and report_date<='"+nowDate+"' " +
|
|
|
" and up.doctor_id in (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '" + dept + "' and dh.del=1 ) ";
|
|
|
}
|
|
|
|
|
|
|
|
|
Integer benrenTotal = jdbcTemplate.queryForObject(benrenTotalSql,Integer.class);
|
|
|
Integer benrenshangbaoTotal = jdbcTemplate.queryForObject(benrenshangbaoTotalSql,Integer.class);
|
|
|
Integer benrenVerified = jdbcTemplate.queryForObject(benrenVerifiedSql,Integer.class);
|
|
|
Integer benrenNotVerified = jdbcTemplate.queryForObject(benrenNotVerifiedSql,Integer.class);
|
|
|
result.put("benrenTotal", benrenTotal);//今日本人提交
|
|
|
result.put("benrenshangbaoTotal", benrenshangbaoTotal);//本人已上报数量
|
|
|
result.put("benrenVerified",benrenVerified);//本人上级未核实
|
|
|
result.put("benrenNotVerified",benrenNotVerified);//本人上级已核实
|
|
|
|
|
|
Integer doctorTotal = jdbcTemplate.queryForObject(doctorTotalSql,Integer.class);
|
|
|
Integer sqlTotal = jdbcTemplate.queryForObject(sqlTotalSql,Integer.class);
|
|
|
Integer verified = jdbcTemplate.queryForObject(verifiedSql,Integer.class);
|
|
|
Integer notVerified = jdbcTemplate.queryForObject(notVerifiedSql,Integer.class);
|
|
|
result.put("doctorTotal", doctorTotal);//科室总人次
|
|
|
result.put("sqlTotal", sqlTotal);//科室今日上报人数
|
|
|
result.put("notUploadTotal", doctorTotal - sqlTotal);//今日未上报人数
|
|
|
result.put("verified",verified);//科室未核实
|
|
|
result.put("notVerified",notVerified);//科室已核实
|
|
|
result.put("reportUploadDO",reportUploadDO);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 首页按照科室列表统计
|
|
|
*
|
|
|
* @param dept
|
|
|
* @param idType
|
|
|
* @param state 核实状态
|
|
|
* @param startDate
|
|
|
* @param endDate
|
|
|
* @return
|
|
|
*/
|
|
|
public List<Map<String, Object>> selectHeaderList(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 = "";//医生过滤条件
|
|
|
if (StringUtils.isNoneBlank(idType)) {
|
|
|
doctorSqlCondition += " and d.id_type = '" + idType + "' ";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(name)) {
|
|
|
doctorSqlCondition += " and d.name like '%" + name + "%' ";
|
|
|
}
|
|
|
|
|
|
|
|
|
//填报人数、未填报人数、上级已核实、未核实
|
|
|
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+")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+" )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+")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 "+reportCondition+")dh5 ON hd.CODE = dh2.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(dept)) {
|
|
|
deptSql += " and hd.code = '" + dept + "' ";
|
|
|
}
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 具体每一个统计时间列表
|
|
|
*
|
|
|
* @param dept
|
|
|
* @param idType
|
|
|
* @param status
|
|
|
* @param state
|
|
|
* @param startDate
|
|
|
* @param endDate
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONArray selectListByTotal(String dept, String idType, String status, String state, String startDate, String endDate, String name) {
|
|
|
List<String> list = new ArrayList<>();
|
|
|
Date startTime = DateUtil.strToDateShort(startDate);
|
|
|
Date endDateTime = DateUtil.strToDateShort(endDate);
|
|
|
int i=0;
|
|
|
do{
|
|
|
startTime = DateUtil.getPreDays(startTime, i);
|
|
|
String str = DateUtil.dateToStrShort(startTime);
|
|
|
list.add(str);
|
|
|
i=1;
|
|
|
}while (startTime.before(endDateTime));
|
|
|
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 deptCondition = "";
|
|
|
if (StringUtils.isNoneBlank(dept)) {
|
|
|
deptCondition += " (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '" + dept + "' and dh.del=1 )";
|
|
|
}
|
|
|
String idTypeCondition = " ";
|
|
|
if (StringUtils.isNoneBlank(idType)) {
|
|
|
idTypeCondition += " (select d1.id from base_doctor d1 where 1=1 and d1.id_type = '" + idType + "')";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(deptCondition)) {
|
|
|
doctorSql += " and d.id IN " + deptCondition;
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(idTypeCondition)) {
|
|
|
doctorSql += " and d.id IN " + idTypeCondition;
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(status)) {
|
|
|
if (status.equalsIgnoreCase("1")) {//已上报
|
|
|
doctorSql += " and d.id in(select d1.doctor_id from base_doctor_daily_report_upload d1 where 1=1 and d1.report_date >='" + date + "' and d1.report_date<='" + date + "' ) ";
|
|
|
} else if (status.equalsIgnoreCase("2")) {//未上报
|
|
|
doctorSql += " and d.id not in(select d1.doctor_id from base_doctor_daily_report_upload d1 where 1=1 and d1.report_date >='" + date + "' and d1.report_date<='" + date + "' ) ";
|
|
|
}
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(state)) {//核实状态
|
|
|
doctorSql +=" and d.id in(select d1.doctor_id from base_doctor_daily_report_upload d1 where 1=1 and d1.report_date >='" + date + "' and d1.report_date<='" + date +"' and d1.state='"+state+"' ) ";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(name)) {
|
|
|
doctorSql += " and d.name LIKE '%" + name + "%' ";
|
|
|
}
|
|
|
Map<String, Object> map = jdbcTemplate.queryForMap(doctorSql);
|
|
|
Integer total = 0;
|
|
|
if (map != null) {
|
|
|
if (map.get("total") != null) {
|
|
|
total = Integer.parseInt(map.get("total").toString());
|
|
|
}
|
|
|
}
|
|
|
JSONObject object = new JSONObject();
|
|
|
object.put("time", date);
|
|
|
object.put("total", total);
|
|
|
array.add(object);
|
|
|
}
|
|
|
return array;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取列表的具体人员信息
|
|
|
*
|
|
|
* @param dept
|
|
|
* @param idType
|
|
|
* @param status
|
|
|
* @param state
|
|
|
* @param startDate
|
|
|
* @param endDate
|
|
|
* @param name total
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONArray selectListInfoByTotal(String dept, String idType, String status, String state, String startDate, String endDate, String name) {
|
|
|
List<String> list = new ArrayList<>();
|
|
|
Date startTime = DateUtil.strToDateShort(startDate);
|
|
|
Date endDateTime = DateUtil.strToDateShort(endDate);
|
|
|
int i=0;
|
|
|
do{
|
|
|
startTime = DateUtil.getPreDays(startTime, i);
|
|
|
String str = DateUtil.dateToStrShort(startTime);
|
|
|
list.add(str);
|
|
|
i=1;
|
|
|
}while (startTime.before(endDateTime));
|
|
|
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 deptCondition = "";
|
|
|
if (StringUtils.isNoneBlank(dept)) {
|
|
|
deptCondition += " (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '" + dept + "' and dh.del=1 )";
|
|
|
}
|
|
|
String idTypeCondition = " ";
|
|
|
if (StringUtils.isNoneBlank(idType)) {
|
|
|
idTypeCondition += " (select d1.id from base_doctor d1 where 1=1 and d1.id_type = '" + idType + "')";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(deptCondition)) {
|
|
|
doctorSql += " and d.id IN " + deptCondition;
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(idTypeCondition)) {
|
|
|
doctorSql += " and d.id IN " + idTypeCondition;
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(status)) {
|
|
|
if (status.equalsIgnoreCase("1")) {//已上报
|
|
|
doctorSql += " and d.id in(select d1.doctor_id from base_doctor_daily_report_upload d1 where 1=1 and d1.report_date >='" + date + "' and d1.report_date<='" + date + "' ) ";
|
|
|
} else if (status.equalsIgnoreCase("2")) {//未上报
|
|
|
doctorSql += " and d.id not in(select d1.doctor_id from base_doctor_daily_report_upload d1 where 1=1 and d1.report_date >='" + date + "' and d1.report_date<='" + date + "' ) ";
|
|
|
}
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(state)) {//核实状态
|
|
|
doctorSql += " and d.id in(select d1.doctor_id from base_doctor_daily_report_upload d1 where 1=1 and d1.report_date >='" + date + "' and d1.report_date<='" + date + "' and d1.state='" + state + "' ) ";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(name)) {
|
|
|
doctorSql += " and d.name LIKE '%" + name + "%' ";
|
|
|
}
|
|
|
List<Map<String, Object>> mapList = jdbcTemplate.queryForList(doctorSql);
|
|
|
for (Map<String, Object> map : mapList) {
|
|
|
String id = map.get("id").toString();
|
|
|
List<BaseDoctorHospitalDO> hospitalDOList = baseDoctorHospitalDao.findByDoctorCode(id);
|
|
|
map.put("deptInfo", hospitalDOList);
|
|
|
String stateCondition = "";//核实状态
|
|
|
if (StringUtils.isNoneBlank(state)) {
|
|
|
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 ";
|
|
|
List<Map<String, Object>> mapList1 = jdbcTemplate.queryForList(sql);
|
|
|
if (mapList1 != null && mapList1.size() != 0) {
|
|
|
for (Map<String, Object> map1 : mapList1) {
|
|
|
String stateMap = map1.get("state").toString();
|
|
|
if("1".equals(stateMap)){
|
|
|
map1.put("verifiedState", "已核实");
|
|
|
} else {
|
|
|
map1.put("verifiedState", "未核实");
|
|
|
}
|
|
|
map.put("uploadState", "已上报");
|
|
|
map.put("uploadId", map1.get("id").toString());
|
|
|
}
|
|
|
map.put("recordList", mapList1);
|
|
|
} else {
|
|
|
map.put("verifiedState", "未知");
|
|
|
map.put("uploadState", "未上报");
|
|
|
map.put("uploadId", "");
|
|
|
map.put("report_date", "");
|
|
|
map.put("recordList", mapList1);
|
|
|
}
|
|
|
}
|
|
|
JSONObject object = new JSONObject();
|
|
|
object.put("time", date);
|
|
|
object.put("list", mapList);
|
|
|
array.add(object);
|
|
|
}
|
|
|
return array;
|
|
|
}
|
|
|
|
|
|
// /**
|
|
|
// * 报表导出
|
|
|
// *
|
|
|
// * @param startDate
|
|
|
// * @param endDate
|
|
|
// * @return
|
|
|
// */
|
|
|
// public JSONArray pushListWriteDailyReport(OutputStream os, String startDate, String endDate, String dept) throws Exception {
|
|
|
// List<String> list = new ArrayList<>();
|
|
|
// Date startTime = DateUtil.strToDateShort(startDate);
|
|
|
// Date endDateTime = DateUtil.strToDateShort(endDate);
|
|
|
// int i=0;
|
|
|
// do{
|
|
|
// startTime = DateUtil.getPreDays(startTime, i);
|
|
|
// String str = DateUtil.dateToStrShort(startTime);
|
|
|
// list.add(str);
|
|
|
// i++;
|
|
|
// }while (startTime.before(endDateTime));
|
|
|
// JSONArray array = new JSONArray();
|
|
|
// for (i = 0; i < list.size(); i++) {
|
|
|
// String date = list.get(i);
|
|
|
// String doctorSql = " select id,name,job_title_name from base_doctor d where d.del=1 ";
|
|
|
// if (StringUtils.isNoneBlank(dept)) {
|
|
|
// doctorSql += " and d.id in (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '" + dept + "' and dh.del=1 )";
|
|
|
// }
|
|
|
// List<Map<String, Object>> mapList = jdbcTemplate.queryForList(doctorSql);
|
|
|
//
|
|
|
// for (Map<String, Object> map : mapList) {
|
|
|
// String id = map.get("id").toString();
|
|
|
// List<BaseDoctorHospitalDO> baseDoctorHospitalDOS = baseDoctorHospitalDao.findByDoctorCode(id);
|
|
|
// if (baseDoctorHospitalDOS != null && baseDoctorHospitalDOS.size() != 0) {
|
|
|
// map.put("deptName", baseDoctorHospitalDOS.get(0).getDeptName());
|
|
|
// }
|
|
|
// }
|
|
|
// JSONObject object = new JSONObject();
|
|
|
// object.put("time", date);
|
|
|
// object.put("list", mapList);
|
|
|
// array.add(object);
|
|
|
// }
|
|
|
// pushListWritePriceTotal(os, array, startDate, endDate);
|
|
|
// return array;
|
|
|
// }
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 查下上报最新一次记录
|
|
|
* @param doctor
|
|
|
* @return
|
|
|
*/
|
|
|
public BaseDailyReportUploadDO selectRecordByDoctorIdAndConsumer(String doctor){
|
|
|
List<BaseDailyReportUploadDO> dailyReportUploadDOs = dailyReportUploadDao.findByDoctorIdLastOne(doctor);
|
|
|
BaseDailyReportUploadDO dailyReportUploadDO = null;
|
|
|
if (dailyReportUploadDOs.size()>0){
|
|
|
dailyReportUploadDO = dailyReportUploadDOs.get(0);
|
|
|
if (null==dailyReportUploadDO){
|
|
|
return null;
|
|
|
}else{
|
|
|
List<BaseDailyReportDetailDO> detailDOS = reportDetailDao.findByReportId(dailyReportUploadDO.getId());
|
|
|
dailyReportUploadDO.setDetailDOList(detailDOS);
|
|
|
}
|
|
|
}
|
|
|
return dailyReportUploadDO;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
* @param orgCode
|
|
|
* @param dept
|
|
|
* @param doctorCode
|
|
|
* @param key
|
|
|
* @param flag 是否核实1是0否
|
|
|
* @return
|
|
|
*/
|
|
|
public List<Map<String, Object>> findDoctorByHospitalAndDept(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 ";
|
|
|
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());
|
|
|
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 flag 1周2月
|
|
|
* @param dept
|
|
|
* @param level 1院级管理员,2科室管理员
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject selectIndexTotalCircle(Integer flag,String dept, int level) {
|
|
|
JSONObject object = new JSONObject();
|
|
|
String startDate="";
|
|
|
String endDate="";
|
|
|
if (flag==1){
|
|
|
startDate = DateUtil.getMondayOfThisWeek();
|
|
|
endDate = DateUtil.getSundayOfThisWeek();
|
|
|
}else if (flag==2){
|
|
|
startDate = DateUtil.getFristDayOfMonth();
|
|
|
endDate = DateUtil.getLastDayOfMonth();
|
|
|
}
|
|
|
String day = DateUtil.getTwoDay(endDate, startDate);
|
|
|
String doctorSql = " select COUNT(1) as 'total' from base_doctor d where d.del=1 ";
|
|
|
Integer total = 0;//总人次
|
|
|
String sqlCondition = "";
|
|
|
if (level==2){
|
|
|
sqlCondition =" and d.doctor_id IN (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '" + dept + "' and dh.del=1 ) ";
|
|
|
}
|
|
|
String sql = " SELECT SUM(d1.total) as total from (select COUNT(DISTINCT d.doctor_id) as 'total',date_format(d.report_date ,'%Y-%m-%d' ) " +
|
|
|
" from base_doctor_daily_report_upload d where 1=1 "+sqlCondition+" and d.report_date >='"+startDate+"' and d.report_date<='"+endDate+"' " +
|
|
|
" GROUP BY date_format(d.report_date ,'%Y-%m-%d' ))d1 ";
|
|
|
if (level==2){
|
|
|
doctorSql +=" and d.id IN (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '" + dept + "' and dh.del=1 ) ";
|
|
|
}
|
|
|
Map<String, Object> map = jdbcTemplate.queryForMap(doctorSql);
|
|
|
String doctorTotal = "";
|
|
|
if (map != null) {
|
|
|
doctorTotal = map.get("total").toString();
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(doctorTotal)) {
|
|
|
//总人次
|
|
|
if (!day.equalsIgnoreCase("0")) {
|
|
|
total = Integer.parseInt(doctorTotal) * (Integer.parseInt(day)+1);
|
|
|
} else {
|
|
|
total = Integer.parseInt(doctorTotal);
|
|
|
}
|
|
|
}
|
|
|
Integer yishangbaoTotal = 0;
|
|
|
Integer weishangbaoTotal = 0;
|
|
|
Integer verifiedTotal = 0;
|
|
|
Integer notVerifiedTotal = 0;
|
|
|
//已上传
|
|
|
Map<String, Object> yishangchaungMap = jdbcTemplate.queryForMap(sql);
|
|
|
if (yishangchaungMap != null) {
|
|
|
if (yishangchaungMap.get("total") != null) {
|
|
|
yishangbaoTotal = Integer.parseInt(yishangchaungMap.get("total").toString());
|
|
|
}
|
|
|
}
|
|
|
//未上报
|
|
|
weishangbaoTotal = total - yishangbaoTotal;
|
|
|
|
|
|
//上传总次数
|
|
|
Integer shangchuanTotal = 0;
|
|
|
|
|
|
String shangchuanTotalSql = "select COUNT(1) as 'total' from base_doctor_daily_report_upload d where 1=1 ";
|
|
|
|
|
|
if (StringUtils.isNoneBlank(startDate)) {
|
|
|
shangchuanTotalSql += " and d.report_date >='" + startDate + "' and d.report_date<='" + endDate + "' ";
|
|
|
}
|
|
|
if (level==2){
|
|
|
shangchuanTotalSql +=" and d.doctor_id IN (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '" + dept + "' and dh.del=1 ) ";
|
|
|
}
|
|
|
Map<String, Object> shangchuanMap = jdbcTemplate.queryForMap(shangchuanTotalSql);
|
|
|
if (shangchuanMap != null) {
|
|
|
if (shangchuanMap.get("total") != null) {
|
|
|
shangchuanTotal = Integer.parseInt(shangchuanMap.get("total").toString());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
//已核实、未核实
|
|
|
String verifiedTotalSql = "select COUNT(1) as 'total' from base_doctor_daily_report_upload d where state=1 ";
|
|
|
|
|
|
if (StringUtils.isNoneBlank(startDate)) {
|
|
|
verifiedTotalSql += " and d.report_date >='" + startDate + "' and d.report_date<='" + endDate + "' ";
|
|
|
}
|
|
|
if (level==2){
|
|
|
verifiedTotalSql +=" and d.doctor_id IN (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '" + dept + "' and dh.del=1 ) ";
|
|
|
}
|
|
|
//已核实
|
|
|
Map<String, Object> zhengchangMap = jdbcTemplate.queryForMap(verifiedTotalSql);
|
|
|
if (zhengchangMap != null) {
|
|
|
if (zhengchangMap.get("total") != null) {
|
|
|
verifiedTotal = Integer.parseInt(zhengchangMap.get("total").toString());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//未核实
|
|
|
String notVerifiedTotalSql = "select COUNT(1) as 'total' from base_doctor_daily_report_upload d where state=0 ";
|
|
|
if (StringUtils.isNoneBlank(startDate)) {
|
|
|
notVerifiedTotalSql += " and d.report_date >='" + startDate + "' and d.report_date<='" + endDate + "' ";
|
|
|
}
|
|
|
if (level==2){
|
|
|
notVerifiedTotalSql +=" and d.doctor_id IN (select dh.doctor_code from base_doctor_hospital dh where dh.dept_code = '" + dept + "' and dh.del=1 ) ";
|
|
|
}
|
|
|
//正常
|
|
|
Map<String, Object> yichangMap = jdbcTemplate.queryForMap(notVerifiedTotalSql);
|
|
|
if (yichangMap != null) {
|
|
|
if (yichangMap.get("total") != null) {
|
|
|
notVerifiedTotal = Integer.parseInt(yichangMap.get("total").toString());
|
|
|
}
|
|
|
}
|
|
|
object.put("total", total);//总人次
|
|
|
object.put("yishangbaoTotal", yishangbaoTotal);//已上报
|
|
|
object.put("weishangbaoTotal", weishangbaoTotal);//未上报
|
|
|
object.put("verifiedTotal", verifiedTotal);//已核实
|
|
|
object.put("notVerifiedTotal", notVerifiedTotal);//未核实
|
|
|
object.put("shangchuanTotal", shangchuanTotal);//上传总次数
|
|
|
return object;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 首页统计
|
|
|
*
|
|
|
* @param dept
|
|
|
* @param idType
|
|
|
* @param status
|
|
|
* @param state
|
|
|
* @param startDate
|
|
|
* @param endDate
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject selectHeaderTotal(String dept, String idType, String status, String state, String startDate, String endDate, String name) {
|
|
|
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 ";
|
|
|
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 ";
|
|
|
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 )";
|
|
|
}
|
|
|
String idTypeCondition = " ";
|
|
|
if (StringUtils.isNoneBlank(idType)) {
|
|
|
idTypeCondition += " (select d1.id from base_doctor d1 where 1=1 and d1.id_type = '" + idType + "')";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(deptCondition)) {
|
|
|
doctorSql += " and d.id IN " + deptCondition;
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(idTypeCondition)) {
|
|
|
doctorSql += " and d.id IN " + idTypeCondition;
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(name)) {
|
|
|
doctorSql += " and d.name like '%" + name + "%' ";
|
|
|
}
|
|
|
|
|
|
// if (StringUtils.isNoneBlank(status)) {
|
|
|
// if (status.equalsIgnoreCase("1")) {//已上报
|
|
|
// doctorSql += " and d.id in(select d1.doctor_id from base_doctor_daily_report_upload d1 where 1=1 and d1.report_date >='" + startDate + "' and d1.report_date<='" + endDate + "' ) ";
|
|
|
// } else if (status.equalsIgnoreCase("2")) {//未上报
|
|
|
// doctorSql += " and d.id not in(select d1.doctor_id from base_doctor_daily_report_upload d1 where 1=1 and d1.report_date >='" + startDate + "' and d1.report_date<='" + endDate + "' ) ";
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
Integer doctorTotal = jdbcTemplate.queryForObject(doctorSql,Integer.class);
|
|
|
|
|
|
if (!day.equalsIgnoreCase("0")) {
|
|
|
total = doctorTotal * (Integer.parseInt(day)+1);
|
|
|
} else {//当天
|
|
|
total = doctorTotal;
|
|
|
}
|
|
|
|
|
|
Integer yishangbaoTotal=0;//上传人数
|
|
|
Integer weishangbaoTotal=0;//未上报
|
|
|
Integer notVerified=0;//未核实
|
|
|
Integer verified=0;//已核实
|
|
|
Integer shangchuanTotal=0;//上传总次数
|
|
|
|
|
|
if (StringUtils.isNoneBlank(startDate)) {
|
|
|
sql += " and d.report_date >='" + startDate + "' and d.report_date<='" + endDate + "' ";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(state)) {
|
|
|
sql += " and d.state='"+state+"' ";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(deptCondition)) {
|
|
|
sql += " and d.doctor_id IN " + deptCondition;
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(idTypeCondition)) {
|
|
|
sql += " and d.doctor_id IN " + idTypeCondition;
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(name)) {
|
|
|
sql += " and d.doctor_name like '%" + name + "%'";
|
|
|
}
|
|
|
|
|
|
yishangbaoTotal = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
//未上报
|
|
|
weishangbaoTotal = total - yishangbaoTotal;
|
|
|
|
|
|
|
|
|
String shangchuanTotalSql = "select COUNT(1) as \"total\" from base_doctor_daily_report_upload d where 1=1 ";
|
|
|
if (StringUtils.isNoneBlank(startDate)) {
|
|
|
shangchuanTotalSql += " and d.report_date >='" + startDate + "' and d.report_date<='" + endDate + "' ";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(deptCondition)) {
|
|
|
shangchuanTotalSql += " and d.doctor_id IN " + deptCondition;
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(idTypeCondition)) {
|
|
|
shangchuanTotalSql += " and d.doctor_id IN " + idTypeCondition;
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(name)) {
|
|
|
shangchuanTotalSql += " and d.doctor_name like '%" + name + "%'";
|
|
|
}
|
|
|
|
|
|
//未核实数量
|
|
|
String notVerifiedSql = "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 de.state=0 ";
|
|
|
|
|
|
//已核实数量
|
|
|
String verifiedSql = "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 de.state=1 ";
|
|
|
if (StringUtils.isNoneBlank(startDate)) {
|
|
|
notVerifiedSql += " and d.report_date >='" + startDate + "' and d.report_date<='" + endDate + "' ";
|
|
|
verifiedSql += " and d.report_date >='" + startDate + "' and d.report_date<='" + endDate + "' ";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(deptCondition)) {
|
|
|
notVerifiedSql += " and d.doctor_id IN " + deptCondition;
|
|
|
verifiedSql += " and d.doctor_id IN " + deptCondition;
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(idTypeCondition)) {
|
|
|
notVerifiedSql += " and d.doctor_id IN " + idTypeCondition;
|
|
|
verifiedSql += " and d.doctor_id IN " + idTypeCondition;
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(name)) {
|
|
|
notVerifiedSql += " and d.doctor_name like '%" + name + "%'";
|
|
|
verifiedSql += " and d.doctor_name like '%" + name + "%'";
|
|
|
}
|
|
|
notVerified = jdbcTemplate.queryForObject(notVerifiedSql,Integer.class);
|
|
|
verified = jdbcTemplate.queryForObject(verifiedSql,Integer.class);
|
|
|
|
|
|
//上传总次数
|
|
|
shangchuanTotal = jdbcTemplate.queryForObject(shangchuanTotalSql,Integer.class);
|
|
|
|
|
|
object.put("total", total);//总人次
|
|
|
object.put("yishangbaoTotal", yishangbaoTotal);//已上报
|
|
|
object.put("weishangbaoTotal", weishangbaoTotal);//未上报
|
|
|
object.put("notVerified", notVerified);//未核实数量
|
|
|
object.put("verified", verified);//已核实数量
|
|
|
object.put("shangchuanTotal", shangchuanTotal);//上传总次数
|
|
|
return object;
|
|
|
}
|
|
|
|
|
|
}
|