|
@ -0,0 +1,212 @@
|
|
|
package com.yihu.jw.complaint;
|
|
|
|
|
|
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.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.dict.DictHospitalDeptDO;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
|
|
|
import com.yihu.jw.restmodel.web.MixEnvelop;
|
|
|
import com.yihu.jw.utils.StringUtil;
|
|
|
import com.yihu.jw.utils.hibernate.HibenateUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@Service
|
|
|
public class BaseComplaintService {
|
|
|
@Autowired
|
|
|
private BaseComplaintDictDao baseComplaintDictDao;
|
|
|
@Autowired
|
|
|
private BaseComplaintDoctorDao baseComplaintDoctorDao;
|
|
|
@Autowired
|
|
|
private BaseDoctorDao baseDoctorDao;
|
|
|
@Autowired
|
|
|
private BaseDoctorHospitalDao baseDoctorHospitalDao;
|
|
|
@Autowired
|
|
|
private HibenateUtils hibenateUtils;
|
|
|
@Autowired
|
|
|
private BaseComplaintDao baseComplaintDao;
|
|
|
@Autowired
|
|
|
private ObjectMapper objectMapper;
|
|
|
@Autowired
|
|
|
private DictHospitalDeptDao dictHospitalDeptDao;
|
|
|
|
|
|
//修改新增
|
|
|
public BaseComplaintDictDO createOrUpdateDict(String id, String name) {
|
|
|
BaseComplaintDictDO baseComplaintDictDO = new BaseComplaintDictDO();
|
|
|
if (StringUtils.isNoneBlank(id)) {
|
|
|
baseComplaintDictDO = baseComplaintDictDao.findById(id);
|
|
|
baseComplaintDictDO.setName(name);
|
|
|
baseComplaintDictDO.setUpdateTime(new Date());
|
|
|
} else {
|
|
|
baseComplaintDictDO.setIsDel("1");
|
|
|
baseComplaintDictDO.setName(name);
|
|
|
baseComplaintDictDO.setCreateTime(new Date());
|
|
|
}
|
|
|
return baseComplaintDictDao.save(baseComplaintDictDO);
|
|
|
}
|
|
|
|
|
|
//删除
|
|
|
public BaseComplaintDictDO deleteDict(String id) {
|
|
|
BaseComplaintDictDO baseComplaintDictDO = baseComplaintDictDao.findById(id);
|
|
|
if (null != baseComplaintDictDO) {
|
|
|
baseComplaintDictDO.setIsDel("0");
|
|
|
baseComplaintDictDO.setUpdateTime(new Date());
|
|
|
baseComplaintDictDao.save(baseComplaintDictDO);
|
|
|
}
|
|
|
return baseComplaintDictDO;
|
|
|
}
|
|
|
|
|
|
public BaseComplaintDictDO findOneDict(String id) {
|
|
|
BaseComplaintDictDO baseComplaintDictDO = baseComplaintDictDao.findById(id);
|
|
|
return baseComplaintDictDO;
|
|
|
}
|
|
|
|
|
|
//查询
|
|
|
public List<BaseComplaintDictDO> findAll(String name) {
|
|
|
List<BaseComplaintDictDO> list = new ArrayList<>();
|
|
|
if (StringUtils.isNoneBlank(name)) {
|
|
|
list = baseComplaintDictDao.findByName(name);
|
|
|
} else {
|
|
|
list = baseComplaintDictDao.findByAll();
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
//新增投诉管理医生
|
|
|
public BaseComplaintDoctorDO createOrUpdateComplainDoctor(String id, String complaintId, String doctor, String deptCode) {
|
|
|
String deptName = "";
|
|
|
String doctorName = "";
|
|
|
BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(doctor);
|
|
|
if (null != baseDoctorDO) {
|
|
|
doctorName = baseDoctorDO.getName();
|
|
|
}
|
|
|
List<BaseDoctorHospitalDO> baseDoctorHospitalDO = baseDoctorHospitalDao.findByDeptCodeDoctorCode(deptCode, deptCode);
|
|
|
if (baseDoctorHospitalDO != null && baseDoctorHospitalDO.size() > 0) {
|
|
|
deptName = baseDoctorHospitalDO.get(0).getDeptName();
|
|
|
}
|
|
|
BaseComplaintDoctorDO baseComplaintDoctorDO = new BaseComplaintDoctorDO();
|
|
|
if (StringUtils.isNoneBlank(id)) {
|
|
|
baseComplaintDoctorDO = baseComplaintDoctorDao.findByDelAndId(id);
|
|
|
baseComplaintDoctorDO.setDept(deptCode);
|
|
|
baseComplaintDoctorDO.setDeptName(deptName);
|
|
|
baseComplaintDoctorDO.setComplaintId(complaintId);
|
|
|
baseComplaintDoctorDO.setDoctor(doctor);
|
|
|
baseComplaintDoctorDO.setDoctorName(doctorName);
|
|
|
baseComplaintDoctorDO.setUpdateTime(new Date());
|
|
|
} else {
|
|
|
baseComplaintDoctorDO.setDept(deptCode);
|
|
|
baseComplaintDoctorDO.setDeptName(deptName);
|
|
|
baseComplaintDoctorDO.setComplaintId(complaintId);
|
|
|
baseComplaintDoctorDO.setDoctor(doctor);
|
|
|
baseComplaintDoctorDO.setDoctorName(doctorName);
|
|
|
baseComplaintDoctorDO.setIsDel("1");
|
|
|
baseComplaintDoctorDO.setCreateTime(new Date());
|
|
|
}
|
|
|
return baseComplaintDoctorDao.save(baseComplaintDoctorDO);
|
|
|
}
|
|
|
|
|
|
//删除管理医生
|
|
|
public BaseComplaintDoctorDO deleteDoctorComplain(String id) {
|
|
|
BaseComplaintDoctorDO baseComplaintDoctorDO = baseComplaintDoctorDao.findByDelAndId(id);
|
|
|
if (null != baseComplaintDoctorDO) {
|
|
|
baseComplaintDoctorDO.setIsDel("0");
|
|
|
baseComplaintDoctorDO.setUpdateTime(new Date());
|
|
|
baseComplaintDoctorDao.save(baseComplaintDoctorDO);
|
|
|
}
|
|
|
return baseComplaintDoctorDO;
|
|
|
}
|
|
|
|
|
|
public MixEnvelop findComplaintDoctor(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\"," +
|
|
|
" t.doctor_name as \"doctorName\"," +
|
|
|
" t.dept as \"dept\"," +
|
|
|
" t.dept_name as \"deptName\"," +
|
|
|
" t.is_del as \"isDel\"," +
|
|
|
" t.create_time as \"createTime\"," +
|
|
|
" t.update_time as \"updateTime\"," +
|
|
|
" b.name as \"name\" " +
|
|
|
" from base_complaint_doctor t left join base_complaint_dict b" +
|
|
|
" on t.complaint_id=b.id where t.is_del='1'";
|
|
|
if (StringUtils.isNoneBlank(doctorName)) {
|
|
|
sql += " and t.doctor_name like '%" + doctorName + "%'";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(deptName)) {
|
|
|
sql += " and t.dept_name like '%" + deptName + "%'";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(complaintType)) {
|
|
|
sql += " and t.complaint_id = '" + complaintType + "'";
|
|
|
}
|
|
|
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);
|
|
|
MixEnvelop mixEnvelop = new MixEnvelop();
|
|
|
mixEnvelop.setTotalCount(listCount == null ? 0 : listCount.size());
|
|
|
mixEnvelop.setPageSize(pageSize);
|
|
|
mixEnvelop.setCurrPage(page);
|
|
|
mixEnvelop.setDetailModelList(list);
|
|
|
return mixEnvelop;
|
|
|
}
|
|
|
|
|
|
public BaseComplaintDoctorDO findOneDoctorComplain(String id) {
|
|
|
BaseComplaintDoctorDO baseComplaintDoctorDO = baseComplaintDoctorDao.findByDelAndId(id);
|
|
|
return baseComplaintDoctorDO;
|
|
|
}
|
|
|
/*
|
|
|
* 患者举报接口
|
|
|
* */
|
|
|
public void patiemtComplaint(String json) throws Exception{
|
|
|
BaseComplaintDO baseComplaintDO =objectMapper.readValue(json,BaseComplaintDO.class);
|
|
|
BaseComplaintDictDO baseComplaintDictDO = baseComplaintDictDao.findById(baseComplaintDO.getComplaintId());
|
|
|
if (baseComplaintDictDO!=null){
|
|
|
baseComplaintDO.setComplaintName(baseComplaintDictDO.getName());
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(baseComplaintDO.getVisitDept())){
|
|
|
DictHospitalDeptDO dictHospitalDeptDO=dictHospitalDeptDao.findByCode(baseComplaintDO.getVisitDept());
|
|
|
if (dictHospitalDeptDO!=null){
|
|
|
baseComplaintDO.setVisitDeptName(dictHospitalDeptDO.getName());
|
|
|
}
|
|
|
}
|
|
|
baseComplaintDO.setIsDel("1");
|
|
|
baseComplaintDO.setStatus("0");
|
|
|
baseComplaintDO.setCreateTime(new Date());
|
|
|
baseComplaintDao.save(baseComplaintDO);
|
|
|
}
|
|
|
/*
|
|
|
* 医生转交
|
|
|
* */
|
|
|
public void passTo(String id,String complaintId,String doctor,String operator){
|
|
|
BaseComplaintDO baseComplaintDO = baseComplaintDao.findOne(id);
|
|
|
String doctorName="";
|
|
|
String complaitTypeName="";
|
|
|
if (null!=baseComplaintDO){
|
|
|
BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(doctor);
|
|
|
if (null != baseDoctorDO) {
|
|
|
doctorName=baseDoctorDO.getName();
|
|
|
baseComplaintDO.setAcceptorName(doctorName);
|
|
|
}
|
|
|
baseComplaintDO.setAcceptor(doctor);
|
|
|
baseComplaintDO.setComplaintId(complaintId);
|
|
|
BaseComplaintDictDO baseComplaintDictDO = baseComplaintDictDao.findById(id);
|
|
|
if (baseComplaintDictDO!=null){
|
|
|
complaitTypeName=baseComplaintDictDO.getName();
|
|
|
baseComplaintDO.setComplaintName(complaitTypeName);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|