| 
					
				 | 
			
			
				@ -4,12 +4,15 @@ import com.fasterxml.jackson.databind.ObjectMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.dict.dao.DictHospitalDeptDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				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.complaint.BaseComplaintDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.complaint.BaseComplaintDictDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.complaint.BaseComplaintDoctorDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.complaint.BaseComplaintOperateLogDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.dict.DictHospitalDeptDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				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.restmodel.web.MixEnvelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.utils.StringUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.utils.hibernate.HibenateUtils; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -40,6 +43,10 @@ public class BaseComplaintService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private ObjectMapper objectMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private DictHospitalDeptDao dictHospitalDeptDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BaseComplaintOperateDao baseComplaintOperateDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BaseDoctorRoleDao baseDoctorRoleDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    //修改新增 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public BaseComplaintDictDO createOrUpdateDict(String id, String name) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -91,7 +98,7 @@ public class BaseComplaintService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (null != baseDoctorDO) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            doctorName = baseDoctorDO.getName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<BaseDoctorHospitalDO> baseDoctorHospitalDO = baseDoctorHospitalDao.findByDeptCodeDoctorCode(deptCode, deptCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<BaseDoctorHospitalDO> baseDoctorHospitalDO = baseDoctorHospitalDao.findByDeptCodeDoctorCode(deptCode, doctor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (baseDoctorHospitalDO != null && baseDoctorHospitalDO.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            deptName = baseDoctorHospitalDO.get(0).getDeptName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -127,7 +134,7 @@ public class BaseComplaintService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return baseComplaintDoctorDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public MixEnvelop findComplaintDoctor(String doctorName, String deptName, String complaintType, Integer page, Integer pageSize) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public MixEnvelop findComplaintDoctor(String doctor,String doctorName, String deptName, String complaintType, Integer page, Integer pageSize) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "select t.id as \"id\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.complaint_id as \"complaintId\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.doctor as \"doctor\"," + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -149,6 +156,9 @@ public class BaseComplaintService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNoneBlank(complaintType)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " and t.complaint_id = '" + complaintType + "'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNoneBlank(doctor)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " and t.doctor = '" + doctor + "'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql += "order by t.create_time desc"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql, page, pageSize); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> listCount = hibenateUtils.createSQLQuery(sql); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -189,9 +199,17 @@ public class BaseComplaintService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void passTo(String id,String complaintId,String doctor,String operator){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BaseComplaintDO baseComplaintDO = baseComplaintDao.findOne(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BaseComplaintOperateLogDO baseComplaintOperateLogDO = new BaseComplaintOperateLogDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String doctorName=""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String complaitTypeName=""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (null!=baseComplaintDO){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            baseComplaintOperateLogDO.setOperateFrom(operator); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            baseComplaintOperateLogDO.setOperateTo(doctor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            baseComplaintOperateLogDO.setComplaintTo(complaintId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            baseComplaintOperateLogDO.setComplaintFrom(baseComplaintDO.getComplaintId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            baseComplaintOperateLogDO.setRelationCode(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            baseComplaintOperateLogDO.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            baseComplaintOperateDao.save(baseComplaintOperateLogDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(doctor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (null != baseDoctorDO) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                doctorName=baseDoctorDO.getName(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -204,8 +222,117 @@ public class BaseComplaintService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                complaitTypeName=baseComplaintDictDO.getName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                baseComplaintDO.setComplaintName(complaitTypeName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            baseComplaintDao.save(baseComplaintDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    //接受投诉 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void doctorAccept(String id,String doctor) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BaseComplaintDO baseComplaintDO = baseComplaintDao.findOne(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (baseComplaintDO!=null&&"0".equalsIgnoreCase(baseComplaintDO.getStatus())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            baseComplaintDO.setStatus("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(doctor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (null != baseDoctorDO) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                baseComplaintDO.setAcceptorName(baseDoctorDO.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            baseComplaintDO.setAcceptor(doctor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            baseComplaintDO.setAcceptTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            baseComplaintDao.save(baseComplaintDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else if ("1".equalsIgnoreCase(baseComplaintDO.getStatus())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            throw new Exception("该工单已被接受"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            throw new Exception("该工单已被处理完成"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    //反馈投诉 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void dealComplaint(String id,String operator,String content,String imgUrl ,String deptCode) throws  Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BaseComplaintDO baseComplaintDO = baseComplaintDao.findOne(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (baseComplaintDO!=null&&"1".equalsIgnoreCase(baseComplaintDO.getStatus())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            baseComplaintDO.setDealTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            baseComplaintDO.setFeedBack(content); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            baseComplaintDO.setFeedImg(imgUrl); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            baseComplaintDO.setOperator(operator); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(operator); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (null != baseDoctorDO) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                baseComplaintDO.setOperatorName(baseDoctorDO.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            baseComplaintDO.setOperatorDept(deptCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<BaseDoctorHospitalDO> baseDoctorHospitalDO = baseDoctorHospitalDao.findByDeptCodeDoctorCode(deptCode, operator); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (baseDoctorHospitalDO != null && baseDoctorHospitalDO.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                baseComplaintDO.setOperatorDeptName(baseDoctorHospitalDO.get(0).getDeptName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            baseComplaintDao.save(baseComplaintDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else if ("2".equalsIgnoreCase(baseComplaintDO.getStatus())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            throw new Exception("该工单已被处理完成"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else if ("0".equalsIgnoreCase(baseComplaintDO.getStatus())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            throw new Exception("该工单未被接收"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    //查询投诉列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void findComplaintList(String doctor,String status,String patientName,String patientId,String keyWord,Integer page ,Integer pageSize){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<BaseDoctorRoleDO>  rolelist= baseDoctorRoleDao.findByDoctorCode(doctor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Boolean queryAll=false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (rolelist.contains("admin")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            queryAll=true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql="select t.id as \"id\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.complaint_id as \"complaintId\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.complaint_name as \"complaintName\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.complaint_content as \"complaintContent\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.visit_type as \"visitType\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.visit_time as \"visitTime\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.visit_dept as \"visitDept\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.visit_dept_name as \"visitDeptName\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.adm_no as \"admNo\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.patient as \"patient\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.patient_name as \"patientName\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.patient_idcard as \"patientIdcard\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.idcard_front as \"idcardFront\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.idcard_back as \"idcardBack\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.img_url as \"imgUrl\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.is_del as \"isDel\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.status as \"status\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.create_time as \"createTime\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.accept_time as \"acceptTime\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.deal_time as \"dealTime\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.operator_dept as \"operatorDept\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.operator_dept_name as \"operatorDeptName\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.operator as \"operator\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.operator_name as \"operatorName\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.feed_back as \"feedBack\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.feed_img as \"feedImg\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.acceptor as \"acceptor\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " b.mobile as \"mobile\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " t.acceptor_name as \"acceptorName\"" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "from base_complaint t " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " left join base_patient b on t.patient=b.id" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " where t.is_del=1"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (!queryAll){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            BaseComplaintDoctorDO baseComplaintDoctorDO= baseComplaintDoctorDao.findbyDoctorAndDel(doctor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String complaint=""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (baseComplaintDoctorDO!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                complaint=baseComplaintDoctorDO.getComplaintId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isNoneBlank(complaint)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sql+=" and t.complaint_id ='"+complaint+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNoneBlank(status)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+=" and t.status ='"+status+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNoneBlank(patientName)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+=" and t.patient_name like '%"+patientName+"%'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNoneBlank(patientId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+=" and t.patient ='"+patientId+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNoneBlank(keyWord)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql+=" and t.patient_name like '%"+patientName+"%'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 |