|
@ -26,6 +26,7 @@ import com.yihu.jw.wechat.enterprise.EnterpriseService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
@ -59,6 +60,8 @@ public class BaseComplaintService {
|
|
|
private EnterpriseService enterpriseService;
|
|
|
@Autowired
|
|
|
private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
|
|
|
@Autowired
|
|
|
JdbcTemplate jdbcTemplate;
|
|
|
@Value("${wechat.id}")
|
|
|
private String wxId;
|
|
|
@Value("${wechat.flag}")
|
|
@ -88,7 +91,7 @@ public class BaseComplaintService {
|
|
|
baseComplaintDictDao.save(baseComplaintDictDO);
|
|
|
}
|
|
|
List<BaseComplaintDoctorDO> baseComplaintDoctorDOs = baseComplaintDoctorDao.findbyComplaintId(id);
|
|
|
for (BaseComplaintDoctorDO baseComplaintDoctorDO:baseComplaintDoctorDOs){
|
|
|
for (BaseComplaintDoctorDO baseComplaintDoctorDO : baseComplaintDoctorDOs) {
|
|
|
baseComplaintDoctorDO.setIsDel("0");
|
|
|
}
|
|
|
baseComplaintDoctorDao.saveAll(baseComplaintDoctorDOs);
|
|
@ -116,28 +119,28 @@ public class BaseComplaintService {
|
|
|
@Transactional
|
|
|
public void createOrUpdateComplainDoctor(String id, String complaintId, String doctorList) throws Exception {
|
|
|
JSONArray jsonArray = JSON.parseArray(doctorList);
|
|
|
for (int i=0;i<jsonArray.size();i++){
|
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
|
|
String doctor = jsonObject.getString("doctor");
|
|
|
String deptCode = jsonObject.getString("deptCode");
|
|
|
String deptName = "";
|
|
|
String doctorName = "";
|
|
|
BaseComplaintDoctorDO preDoctor= baseComplaintDoctorDao.findbyDoctorAndDel(doctor);
|
|
|
// BaseComplaintDoctorDO preDoctor = baseComplaintDoctorDao.findbyDoctorAndDel(doctor);
|
|
|
BaseDoctorDO baseDoctorDO = baseDoctorDao.findByIdAndDel(doctor);
|
|
|
List<BaseDoctorRoleDO> baseDoctorRoleDOs = baseDoctorRoleDao.findByDoctorCode(doctor);
|
|
|
if (baseDoctorRoleDOs==null||baseDoctorRoleDOs.size()==0){
|
|
|
if (baseDoctorRoleDOs == null || baseDoctorRoleDOs.size() == 0) {
|
|
|
BaseDoctorRoleDO baseDoctorRoleDO = new BaseDoctorRoleDO();
|
|
|
baseDoctorRoleDO.setDoctorCode(doctor);
|
|
|
baseDoctorRoleDO.setRoleCode("specialist");
|
|
|
baseDoctorRoleDao.save(baseDoctorRoleDO);
|
|
|
}else if (baseDoctorRoleDOs!=null){
|
|
|
Boolean addRoleFlag=true;//是否为对应医生添加专科医生角色表示 true即为添加
|
|
|
for (BaseDoctorRoleDO baseDoctorRoleDO :baseDoctorRoleDOs){
|
|
|
if (baseDoctorRoleDO.getRoleCode().equalsIgnoreCase("specialist")){
|
|
|
addRoleFlag=false;
|
|
|
} else if (baseDoctorRoleDOs != null) {
|
|
|
Boolean addRoleFlag = true;//是否为对应医生添加专科医生角色表示 true即为添加
|
|
|
for (BaseDoctorRoleDO baseDoctorRoleDO : baseDoctorRoleDOs) {
|
|
|
if (baseDoctorRoleDO.getRoleCode().equalsIgnoreCase("specialist")) {
|
|
|
addRoleFlag = false;
|
|
|
}
|
|
|
}
|
|
|
if(addRoleFlag){
|
|
|
if (addRoleFlag) {
|
|
|
BaseDoctorRoleDO baseDoctorRoleDO = new BaseDoctorRoleDO();
|
|
|
baseDoctorRoleDO.setDoctorCode(doctor);
|
|
|
baseDoctorRoleDO.setRoleCode("specialist");
|
|
@ -147,9 +150,9 @@ public class BaseComplaintService {
|
|
|
if (null != baseDoctorDO) {
|
|
|
doctorName = baseDoctorDO.getName();
|
|
|
}
|
|
|
if (preDoctor!=null){
|
|
|
throw new Exception("医生"+doctorName+"已有负责的投诉类型");
|
|
|
}
|
|
|
// if (preDoctor!=null){
|
|
|
// throw new Exception("医生"+doctorName+"已有负责的投诉类型");
|
|
|
// }
|
|
|
List<BaseDoctorHospitalDO> baseDoctorHospitalDO = baseDoctorHospitalDao.findByDeptCodeDoctorCode(deptCode, doctor);
|
|
|
if (baseDoctorHospitalDO != null && baseDoctorHospitalDO.size() > 0) {
|
|
|
deptName = baseDoctorHospitalDO.get(0).getDeptName();
|
|
@ -179,7 +182,7 @@ public class BaseComplaintService {
|
|
|
return baseComplaintDoctorDO;
|
|
|
}
|
|
|
|
|
|
public MixEnvelop findComplaintDoctor(String doctor,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\"," +
|
|
@ -217,30 +220,74 @@ public class BaseComplaintService {
|
|
|
return mixEnvelop;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 去重医生
|
|
|
*/
|
|
|
public MixEnvelop findComplaintDoctorNew(String doctor, String doctorName, String deptName, String complaintType, Integer page, Integer pageSize) {
|
|
|
String sql = "select " +
|
|
|
" 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\"," +
|
|
|
" d.photo as \"photo\"," +
|
|
|
" group_concat(b.name) as \"name\" " +
|
|
|
" from base_complaint_doctor t " +
|
|
|
" INNER join base_complaint_dict b on t.complaint_id=b.id " +
|
|
|
" INNER join base_doctor d on t.doctor=d.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 + "'";
|
|
|
}
|
|
|
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);
|
|
|
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 BaseComplaintDO patiemtComplaint(String json) throws Exception{
|
|
|
WlyyHospitalSysDictDO wlyyHospitalSysDictDO= wlyyHospitalSysDictDao.findById("complaintOpenControl").orElse(null);
|
|
|
if (wlyyHospitalSysDictDO!=null){
|
|
|
if (!"1".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
|
|
|
public BaseComplaintDO patiemtComplaint(String json) throws Exception {
|
|
|
WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("complaintOpenControl").orElse(null);
|
|
|
if (wlyyHospitalSysDictDO != null) {
|
|
|
if (!"1".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())) {
|
|
|
throw new Exception("投诉通道已关闭");
|
|
|
}
|
|
|
}else {
|
|
|
} else {
|
|
|
throw new Exception("投诉通道已关闭");
|
|
|
}
|
|
|
BaseComplaintDO baseComplaintDO =objectMapper.readValue(json,BaseComplaintDO.class);
|
|
|
BaseComplaintDO baseComplaintDO = objectMapper.readValue(json, BaseComplaintDO.class);
|
|
|
BaseComplaintDictDO baseComplaintDictDO = baseComplaintDictDao.findByIdAndIsDel(baseComplaintDO.getComplaintId());
|
|
|
if (baseComplaintDictDO!=null){
|
|
|
if (baseComplaintDictDO != null) {
|
|
|
baseComplaintDO.setComplaintName(baseComplaintDictDO.getName());
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(baseComplaintDO.getVisitDept())){
|
|
|
DictHospitalDeptDO dictHospitalDeptDO=dictHospitalDeptDao.findByCode(baseComplaintDO.getVisitDept());
|
|
|
if (dictHospitalDeptDO!=null){
|
|
|
if (StringUtils.isNoneBlank(baseComplaintDO.getVisitDept())) {
|
|
|
DictHospitalDeptDO dictHospitalDeptDO = dictHospitalDeptDao.findByCode(baseComplaintDO.getVisitDept());
|
|
|
if (dictHospitalDeptDO != null) {
|
|
|
baseComplaintDO.setVisitDeptName(dictHospitalDeptDO.getName());
|
|
|
}
|
|
|
}
|
|
@ -257,7 +304,7 @@ public class BaseComplaintService {
|
|
|
baseComplaintDO.setStatus("0");
|
|
|
baseComplaintDO.setCreateTime(new Date());
|
|
|
baseComplaintDO.setDefaultdoctor("defalutDoctor");
|
|
|
baseComplaintDO= baseComplaintDao.save(baseComplaintDO);
|
|
|
baseComplaintDO = baseComplaintDao.save(baseComplaintDO);
|
|
|
BaseComplaintOperateLogDO baseComplaintOperateLogDO = new BaseComplaintOperateLogDO();
|
|
|
baseComplaintOperateLogDO.setOperateFrom(baseComplaintDO.getPatient());
|
|
|
baseComplaintOperateLogDO.setStatus("0");
|
|
@ -266,26 +313,26 @@ public class BaseComplaintService {
|
|
|
baseComplaintOperateLogDO.setCreateTime(new Date());
|
|
|
baseComplaintOperateDao.save(baseComplaintOperateLogDO);
|
|
|
try {
|
|
|
List<BaseComplaintDoctorDO> doctorList=baseComplaintDoctorDao.findbyComplaintId(baseComplaintDO.getComplaintId());
|
|
|
for (BaseComplaintDoctorDO baseComplaintDoctorDO:doctorList){
|
|
|
String url="https://hlwyy.xmzsh.com/hlwyy/ims-app-web/#/complaint/detail?id="+baseComplaintDO.getId();
|
|
|
enterpriseService.sendTWMesByDoctor("zsyy",baseComplaintDoctorDO.getDoctor(),"投诉反馈","您收到一条投诉反馈,点击查看。",url);
|
|
|
List<BaseComplaintDoctorDO> doctorList = baseComplaintDoctorDao.findbyComplaintId(baseComplaintDO.getComplaintId());
|
|
|
for (BaseComplaintDoctorDO baseComplaintDoctorDO : doctorList) {
|
|
|
String url = "https://hlwyy.xmzsh.com/hlwyy/ims-app-web/#/complaint/detail?id=" + baseComplaintDO.getId();
|
|
|
enterpriseService.sendTWMesByDoctor("zsyy", baseComplaintDoctorDO.getDoctor(), "投诉反馈", "您收到一条投诉反馈,点击查看。", url);
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
}
|
|
|
return baseComplaintDao.save(baseComplaintDO);
|
|
|
return baseComplaintDao.save(baseComplaintDO);
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* 医生转交
|
|
|
* */
|
|
|
public BaseComplaintDO passTo(String id,String complaintId,String doctor,String operator,String reason){
|
|
|
public BaseComplaintDO passTo(String id, String complaintId, String doctor, String operator, String reason) {
|
|
|
BaseComplaintDO baseComplaintDO = baseComplaintDao.findById(id).orElse(null);
|
|
|
BaseComplaintOperateLogDO baseComplaintOperateLogDO = new BaseComplaintOperateLogDO();
|
|
|
String doctorName="";
|
|
|
String complaitTypeName="";
|
|
|
if (null!=baseComplaintDO){
|
|
|
String doctorName = "";
|
|
|
String complaitTypeName = "";
|
|
|
if (null != baseComplaintDO) {
|
|
|
baseComplaintOperateLogDO.setOperateFrom(operator);
|
|
|
baseComplaintOperateLogDO.setReason(reason);
|
|
|
baseComplaintOperateLogDO.setOperateTo(doctor);
|
|
@ -302,35 +349,36 @@ public class BaseComplaintService {
|
|
|
baseComplaintDO.setAcceptorName(doctorName);
|
|
|
}
|
|
|
baseComplaintDO.setAcceptor(doctor);*/
|
|
|
if ("1".equalsIgnoreCase(baseComplaintDO.getStatus())){
|
|
|
if ("1".equalsIgnoreCase(baseComplaintDO.getStatus())) {
|
|
|
baseComplaintDO.setStatus("0");
|
|
|
}
|
|
|
baseComplaintDO.setDefaultdoctor(doctor);
|
|
|
baseComplaintDO.setComplaintId(complaintId);
|
|
|
baseComplaintDO.setPassto(doctor);
|
|
|
BaseComplaintDictDO baseComplaintDictDO = baseComplaintDictDao.findByIdAndIsDel(complaintId);
|
|
|
if (baseComplaintDictDO!=null){
|
|
|
complaitTypeName=baseComplaintDictDO.getName();
|
|
|
if (baseComplaintDictDO != null) {
|
|
|
complaitTypeName = baseComplaintDictDO.getName();
|
|
|
baseComplaintDO.setComplaintName(complaitTypeName);
|
|
|
}
|
|
|
baseComplaintDO= baseComplaintDao.save(baseComplaintDO);
|
|
|
baseComplaintDO = baseComplaintDao.save(baseComplaintDO);
|
|
|
try {
|
|
|
/*List<BaseComplaintDoctorDO> doctorList=baseComplaintDoctorDao.findbyComplaintId(baseComplaintDO.getComplaintId());
|
|
|
for (BaseComplaintDoctorDO baseComplaintDoctorDO:doctorList)*/
|
|
|
String url="https://hlwyy.xmzsh.com/hlwyy/ims-app-web/#/complaint/detail?id="+baseComplaintDO.getId();
|
|
|
enterpriseService.sendTWMesByDoctor("zsyy",doctor,"投诉反馈","您收到一条投诉反馈,点击查看。",url);
|
|
|
String url = "https://hlwyy.xmzsh.com/hlwyy/ims-app-web/#/complaint/detail?id=" + baseComplaintDO.getId();
|
|
|
enterpriseService.sendTWMesByDoctor("zsyy", doctor, "投诉反馈", "您收到一条投诉反馈,点击查看。", url);
|
|
|
|
|
|
}catch (Exception e){
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
}
|
|
|
return baseComplaintDO;
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
//接受投诉
|
|
|
public BaseComplaintDO doctorAccept(String id,String doctor) throws Exception{
|
|
|
public BaseComplaintDO doctorAccept(String id, String doctor) throws Exception {
|
|
|
BaseComplaintDO baseComplaintDO = baseComplaintDao.findById(id).orElse(null);
|
|
|
if (baseComplaintDO!=null){
|
|
|
if (baseComplaintDO != null) {
|
|
|
baseComplaintDO.setStatus("1");
|
|
|
BaseDoctorDO baseDoctorDO = baseDoctorDao.findByIdAndDel(doctor);
|
|
|
if (null != baseDoctorDO) {
|
|
@ -354,10 +402,11 @@ public class BaseComplaintService {
|
|
|
}*/
|
|
|
return baseComplaintDO;
|
|
|
}
|
|
|
|
|
|
//反馈投诉
|
|
|
public BaseComplaintDO dealComplaint(String id,String operator,String content,String imgUrl ,String deptCode) throws Exception{
|
|
|
public BaseComplaintDO dealComplaint(String id, String operator, String content, String imgUrl, String deptCode) throws Exception {
|
|
|
BaseComplaintDO baseComplaintDO = baseComplaintDao.findById(id).orElse(null);
|
|
|
if (baseComplaintDO!=null){
|
|
|
if (baseComplaintDO != null) {
|
|
|
baseComplaintDO.setDealTime(new Date());
|
|
|
baseComplaintDO.setFeedBack(content);
|
|
|
baseComplaintDO.setFeedImg(imgUrl);
|
|
@ -390,14 +439,14 @@ public class BaseComplaintService {
|
|
|
}
|
|
|
|
|
|
//查询投诉列表
|
|
|
public MixEnvelop findComplaintList(String role,String doctor,String status,String patientName,String patientId,String keyWord,String complaintId,
|
|
|
String startTime,String endTime,Integer page ,Integer pageSize){
|
|
|
public MixEnvelop findComplaintList(String role, String doctor, String status, String patientName, String patientId, String keyWord, String complaintId,
|
|
|
String startTime, String endTime, Integer page, Integer pageSize) {
|
|
|
MixEnvelop mixEnvelop = new MixEnvelop();
|
|
|
Boolean queryAll=false;
|
|
|
if ("admin".equalsIgnoreCase(role)){
|
|
|
queryAll=true;
|
|
|
Boolean queryAll = false;
|
|
|
if ("admin".equalsIgnoreCase(role)) {
|
|
|
queryAll = true;
|
|
|
}
|
|
|
String sql="select DISTINCT t.id as \"id\"," +
|
|
|
String sql = "select DISTINCT t.id as \"id\"," +
|
|
|
" t.complaint_id as \"complaintId\"," +
|
|
|
" t.complaint_name as \"complaintName\"," +
|
|
|
" t.complaint_content as \"complaintContent\"," +
|
|
@ -429,18 +478,34 @@ public class BaseComplaintService {
|
|
|
" t.passto as \"passto\"," +
|
|
|
" t.acceptor_name as \"acceptorName\"" +
|
|
|
" from base_complaint t " +
|
|
|
" left join base_patient b on t.patient=b.id " ;
|
|
|
sql+=" left join base_complaint_operate_log g on t.id=g.relation_code where t.is_del='1' ";
|
|
|
if (StringUtils.isNoneBlank(status)&&"3".equalsIgnoreCase(status)){
|
|
|
sql+=" and g.status='3' ";
|
|
|
" left join base_patient b on t.patient=b.id ";
|
|
|
sql += " left join base_complaint_operate_log g on t.id=g.relation_code where t.is_del='1' ";
|
|
|
//排除撤销的
|
|
|
sql += " and t.status<>'-1' ";
|
|
|
if (StringUtils.isNoneBlank(status) && "3".equalsIgnoreCase(status)) {
|
|
|
sql += " and g.status='3' ";
|
|
|
}/*else if (StringUtils.isNoneBlank(status)&&"1".equalsIgnoreCase(status)){
|
|
|
sql+=" and g.status='1' ";
|
|
|
}
|
|
|
else if (StringUtils.isNoneBlank(status)&&"2".equalsIgnoreCase(status)){
|
|
|
sql+=" and g.status='2' ";
|
|
|
}*/
|
|
|
if (!queryAll){
|
|
|
BaseComplaintDoctorDO baseComplaintDoctorDO= baseComplaintDoctorDao.findbyDoctorAndDel(doctor);
|
|
|
boolean flag = false;
|
|
|
if (!queryAll) {
|
|
|
//原本的
|
|
|
// BaseComplaintDoctorDO baseComplaintDoctorDO = baseComplaintDoctorDao.findbyDoctorAndDel(doctor);
|
|
|
|
|
|
String complaint = "";
|
|
|
String dbSql = " SELECT t.complaint_id from base_complaint_doctor t where t.is_del='1' and t.doctor='" + doctor + "'";
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(dbSql);
|
|
|
if (!list.isEmpty()) {
|
|
|
for (Map<String, Object> map : list) {
|
|
|
if (String.valueOf(map.get("complaint_id")).equalsIgnoreCase("808080eb7a194099017a1943fa820004")) {
|
|
|
complaint = String.valueOf(map.get("complaint_id"));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/*List<BaseComplaintOperateLogDO> logList =baseComplaintOperateDao.findbyOperateFrom(doctor);
|
|
|
String types= "";
|
|
|
if (logList!=null&&logList.size()>0){
|
|
@ -452,100 +517,100 @@ public class BaseComplaintService {
|
|
|
}
|
|
|
}
|
|
|
}*/
|
|
|
String complaint="";
|
|
|
if (baseComplaintDoctorDO!=null){
|
|
|
if (baseComplaintDoctorDO.getComplaintId().equalsIgnoreCase("808080eb7a194099017a1943fa820004")){
|
|
|
complaint=baseComplaintDoctorDO.getComplaintId();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// if (baseComplaintDoctorDO != null) {
|
|
|
// if (baseComplaintDoctorDO.getComplaintId().equalsIgnoreCase("808080eb7a194099017a1943fa820004")) {
|
|
|
// complaint = baseComplaintDoctorDO.getComplaintId();
|
|
|
// }
|
|
|
// }
|
|
|
//complaint=complaint+","+types;
|
|
|
if (StringUtils.isNoneBlank(complaint)){
|
|
|
if (!StringUtils.isNoneBlank(status)){
|
|
|
sql+=" and t.status !='-1'";
|
|
|
sql+=" and (t.defaultdoctor ='defalutDoctor' or t.defaultdoctor='"+doctor+"')";
|
|
|
if (StringUtils.isNoneBlank(complaint)) {
|
|
|
if (!StringUtils.isNoneBlank(status)) {
|
|
|
sql += " and t.status !='-1'";
|
|
|
sql += " and (t.defaultdoctor ='defalutDoctor' or t.defaultdoctor='" + doctor + "')";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(status)&&"3".equalsIgnoreCase(status)){
|
|
|
sql+=" and g.operate_from='"+doctor+"'";
|
|
|
}else {
|
|
|
sql+=" and t.complaint_id='"+complaint+"'";
|
|
|
if (StringUtils.isNoneBlank(status) && "3".equalsIgnoreCase(status)) {
|
|
|
sql += " and g.operate_from='" + doctor + "'";
|
|
|
} else {
|
|
|
sql += " and t.complaint_id='" + complaint + "'";
|
|
|
}
|
|
|
if (!StringUtils.isNoneBlank(status)){
|
|
|
sql+=" or (g.operate_from='"+doctor+"' and g.status='3')";
|
|
|
if (!StringUtils.isNoneBlank(status)) {
|
|
|
sql += " or (g.operate_from='" + doctor + "' and g.status='3')";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(status)&&"3".equalsIgnoreCase(status)){
|
|
|
sql+=" and g.operate_from='"+doctor+"'";
|
|
|
}else if (StringUtils.isNoneBlank(status)&&"0".equalsIgnoreCase(status)){
|
|
|
sql+=" and t.status='0' and (t.passto='"+doctor+"' or t.passto is null )";
|
|
|
} else if (StringUtils.isNoneBlank(status)&&"1".equalsIgnoreCase(status)){
|
|
|
sql+=" and t.status='1' and t.acceptor='"+doctor+"' ";
|
|
|
} else if (StringUtils.isNoneBlank(status)&&"2".equalsIgnoreCase(status)){
|
|
|
sql+=" and t.status='2' and t.operator='"+doctor+"' ";
|
|
|
if (StringUtils.isNoneBlank(status) && "3".equalsIgnoreCase(status)) {
|
|
|
sql += " and g.operate_from='" + doctor + "'";
|
|
|
} else if (StringUtils.isNoneBlank(status) && "0".equalsIgnoreCase(status)) {
|
|
|
sql += " and t.status='0' and (t.passto='" + doctor + "' or t.passto is null )";
|
|
|
} else if (StringUtils.isNoneBlank(status) && "1".equalsIgnoreCase(status)) {
|
|
|
sql += " and t.status='1' and t.acceptor='" + doctor + "' ";
|
|
|
} else if (StringUtils.isNoneBlank(status) && "2".equalsIgnoreCase(status)) {
|
|
|
sql += " and t.status='2' and t.operator='" + doctor + "' ";
|
|
|
}
|
|
|
|
|
|
//sql+=" and t.complaint_id in ('"+complaint.replace(",","','")+"')";
|
|
|
}else {
|
|
|
if (StringUtils.isNoneBlank(status)&&"3".equalsIgnoreCase(status)){
|
|
|
sql+=" and g.operate_from='"+doctor+"'";
|
|
|
}else if (StringUtils.isNoneBlank(status)&&"0".equalsIgnoreCase(status)){
|
|
|
sql+=" and t.status='0' and t.passto='"+doctor+"'";
|
|
|
} else if (StringUtils.isNoneBlank(status)&&"1".equalsIgnoreCase(status)){
|
|
|
sql+=" and t.status='1' and t.acceptor='"+doctor+"' ";
|
|
|
} else if (StringUtils.isNoneBlank(status)&&"2".equalsIgnoreCase(status)){
|
|
|
sql+=" and t.status='2' and t.operator='"+doctor+"' ";
|
|
|
} else {
|
|
|
if (StringUtils.isNoneBlank(status) && "3".equalsIgnoreCase(status)) {
|
|
|
sql += " and g.operate_from='" + doctor + "'";
|
|
|
} else if (StringUtils.isNoneBlank(status) && "0".equalsIgnoreCase(status)) {
|
|
|
sql += " and t.status='0' and t.passto='" + doctor + "'";
|
|
|
} else if (StringUtils.isNoneBlank(status) && "1".equalsIgnoreCase(status)) {
|
|
|
sql += " and t.status='1' and t.acceptor='" + doctor + "' ";
|
|
|
} else if (StringUtils.isNoneBlank(status) && "2".equalsIgnoreCase(status)) {
|
|
|
sql += " and t.status='2' and t.operator='" + doctor + "' ";
|
|
|
} else {
|
|
|
sql+=" and t.id IN (select col.relation_code from base_complaint_operate_log col where col.operate_to = '"+doctor+"' )";
|
|
|
sql += " and t.id IN (select col.relation_code from base_complaint_operate_log col where col.operate_to = '" + doctor + "' )";
|
|
|
}
|
|
|
}
|
|
|
//complaint=complaint+","+types;
|
|
|
|
|
|
}else {
|
|
|
if (StringUtils.isNoneBlank(complaintId)){
|
|
|
} else {
|
|
|
if (StringUtils.isNoneBlank(complaintId)) {
|
|
|
//sql+=" and t.complaint_id in ('"+complaint.replace(",","','")+"')";
|
|
|
sql+=" and t.complaint_id='"+complaintId+"'";
|
|
|
sql += " and t.complaint_id='" + complaintId + "'";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(status)){
|
|
|
sql+=" and t.status ='"+status+"'";
|
|
|
if (StringUtils.isNoneBlank(status)) {
|
|
|
sql += " and t.status ='" + status + "'";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isNoneBlank(patientName)){
|
|
|
sql+=" and t.patient_name like '%"+patientName+"%'";
|
|
|
if (StringUtils.isNoneBlank(patientName)) {
|
|
|
sql += " and t.patient_name like '%" + patientName + "%'";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(patientId)){
|
|
|
sql+=" and t.patient ='"+patientId+"'";
|
|
|
if (StringUtils.isNoneBlank(patientId)) {
|
|
|
sql += " and t.patient ='" + patientId + "'";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(keyWord)){
|
|
|
sql+=" and (t.patient_idcard like '%"+keyWord+"%' or t.patient_name like '%"+keyWord+"%')";
|
|
|
if (StringUtils.isNoneBlank(keyWord)) {
|
|
|
sql += " and (t.patient_idcard like '%" + keyWord + "%' or t.patient_name like '%" + keyWord + "%')";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(startTime)){
|
|
|
if("xm_ykyy_wx".equals(wxId)){
|
|
|
if (flag){
|
|
|
sql+=" and t.create_time > '"+startTime+"'";
|
|
|
}else {
|
|
|
sql+=" and t.create_time > to_date('" + startTime + "', 'yyyy-mm-dd hh24:mi:ss') ";
|
|
|
if (StringUtils.isNotBlank(startTime)) {
|
|
|
if ("xm_ykyy_wx".equals(wxId)) {
|
|
|
if (flag) {
|
|
|
sql += " and t.create_time > '" + startTime + "'";
|
|
|
} else {
|
|
|
sql += " and t.create_time > to_date('" + startTime + "', 'yyyy-mm-dd hh24:mi:ss') ";
|
|
|
}
|
|
|
}else{
|
|
|
sql+=" and t.create_time > '"+startTime+"'";
|
|
|
} else {
|
|
|
sql += " and t.create_time > '" + startTime + "'";
|
|
|
}
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(endTime)){
|
|
|
if("xm_ykyy_wx".equals(wxId)){
|
|
|
if (flag){
|
|
|
sql+=" and t.create_time<='" + endTime + "'";
|
|
|
}else {
|
|
|
sql+=" and t.create_time<= to_date('" + endTime + "','yyyy-mm-dd hh24:mi:ss')";
|
|
|
if (StringUtils.isNotBlank(endTime)) {
|
|
|
if ("xm_ykyy_wx".equals(wxId)) {
|
|
|
if (flag) {
|
|
|
sql += " and t.create_time<='" + endTime + "'";
|
|
|
} else {
|
|
|
sql += " and t.create_time<= to_date('" + endTime + "','yyyy-mm-dd hh24:mi:ss')";
|
|
|
}
|
|
|
}else{
|
|
|
sql+=" and t.create_time<='" + endTime + "'";
|
|
|
} else {
|
|
|
sql += " and t.create_time<='" + endTime + "'";
|
|
|
}
|
|
|
}
|
|
|
sql+=" order by t.create_time desc ";
|
|
|
System.out.println("sql"+sql);
|
|
|
List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql,page,pageSize);
|
|
|
String sqlcount = "SELECT COUNT(1) AS \"total\" FROM ("+sql+") q";
|
|
|
sql += " order by t.create_time desc ";
|
|
|
System.out.println("sql" + sql);
|
|
|
List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql, page, pageSize);
|
|
|
String sqlcount = "SELECT COUNT(1) AS \"total\" FROM (" + sql + ") q";
|
|
|
Long count = 0L;
|
|
|
List<Map<String,Object>> total = hibenateUtils.createSQLQuery(sqlcount);
|
|
|
if(total!=null){
|
|
|
List<Map<String, Object>> total = hibenateUtils.createSQLQuery(sqlcount);
|
|
|
if (total != null) {
|
|
|
//mysql 与 Oracle 聚合函数返回类型不一致,需要判断装换
|
|
|
count = hibenateUtils.objTransformLong(total.get(0).get("total"));
|
|
|
}
|
|
@ -555,32 +620,30 @@ public class BaseComplaintService {
|
|
|
mixEnvelop.setCurrPage(page);
|
|
|
return mixEnvelop;
|
|
|
}
|
|
|
public BaseComplaintDO findOnePaitentComplaint(String id){
|
|
|
|
|
|
public BaseComplaintDO findOnePaitentComplaint(String id) {
|
|
|
BaseComplaintDO baseComplaintDO = baseComplaintDao.findById(id).orElse(null);
|
|
|
BasePatientDO basePatientDO=basePatientDao.findById(baseComplaintDO.getPatient()).orElse(null);
|
|
|
if (null!=basePatientDO){
|
|
|
BasePatientDO basePatientDO = basePatientDao.findById(baseComplaintDO.getPatient()).orElse(null);
|
|
|
if (null != basePatientDO) {
|
|
|
baseComplaintDO.setMobile(basePatientDO.getMobile());
|
|
|
}
|
|
|
WlyyHospitalSysDictDO wlyyHospitalSysDictDO =wlyyHospitalSysDictDao.findById("latestFeedBackTime").orElse(null);
|
|
|
Integer timeOut=15;
|
|
|
if (wlyyHospitalSysDictDO!=null){
|
|
|
timeOut =Integer.parseInt(wlyyHospitalSysDictDO.getDictValue());
|
|
|
WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("latestFeedBackTime").orElse(null);
|
|
|
Integer timeOut = 15;
|
|
|
if (wlyyHospitalSysDictDO != null) {
|
|
|
timeOut = Integer.parseInt(wlyyHospitalSysDictDO.getDictValue());
|
|
|
}
|
|
|
long latestDate=baseComplaintDO.getCreateTime().getTime()+timeOut*24*60*60*1000;
|
|
|
baseComplaintDO.setLatestFeedTime( (new Date(latestDate)));
|
|
|
baseComplaintDO.setVisitTypeName(baseComplaintDO.getVisitType().equalsIgnoreCase("1")?"门诊":"住院");
|
|
|
long latestDate = baseComplaintDO.getCreateTime().getTime() + timeOut * 24 * 60 * 60 * 1000;
|
|
|
baseComplaintDO.setLatestFeedTime((new Date(latestDate)));
|
|
|
baseComplaintDO.setVisitTypeName(baseComplaintDO.getVisitType().equalsIgnoreCase("1") ? "门诊" : "住院");
|
|
|
return baseComplaintDO;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//查询投诉列表
|
|
|
public MixEnvelop findPatientComplaintList(String status,String patientName,String patientId,
|
|
|
String startTime,String endTime,String complaintType,Integer page ,Integer pageSize){
|
|
|
public MixEnvelop findPatientComplaintList(String status, String patientName, String patientId,
|
|
|
String startTime, String endTime, String complaintType, Integer page, Integer pageSize) {
|
|
|
MixEnvelop mixEnvelop = new MixEnvelop();
|
|
|
String sql="select t.id as \"id\"," +
|
|
|
String sql = "select t.id as \"id\"," +
|
|
|
" t.complaint_id as \"complaintId\"," +
|
|
|
" t.complaint_name as \"complaintName\"," +
|
|
|
" t.complaint_content as \"complaintContent\"," +
|
|
@ -613,46 +676,46 @@ public class BaseComplaintService {
|
|
|
" from base_complaint t " +
|
|
|
" left join base_patient b on t.patient=b.id" +
|
|
|
" where t.is_del='1'";
|
|
|
if (StringUtils.isNoneBlank(status)){
|
|
|
sql+=" and t.status ='"+status+"'";
|
|
|
if (StringUtils.isNoneBlank(status)) {
|
|
|
sql += " and t.status ='" + status + "'";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(patientName)){
|
|
|
sql+=" and t.patient_name like '%"+patientName+"%'";
|
|
|
if (StringUtils.isNoneBlank(patientName)) {
|
|
|
sql += " and t.patient_name like '%" + patientName + "%'";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(patientId)){
|
|
|
sql+=" and t.patient ='"+patientId+"'";
|
|
|
if (StringUtils.isNoneBlank(patientId)) {
|
|
|
sql += " and t.patient ='" + patientId + "'";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(complaintType)){
|
|
|
sql+=" and t.complaint_id ='"+complaintType+"'";
|
|
|
if (StringUtils.isNoneBlank(complaintType)) {
|
|
|
sql += " and t.complaint_id ='" + complaintType + "'";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(startTime)){
|
|
|
if("xm_ykyy_wx".equals(wxId)){
|
|
|
if (flag){
|
|
|
sql+=" and t.create_time > '"+startTime+"'";
|
|
|
}else {
|
|
|
sql+=" and t.create_time > to_date('" + startTime + "', 'yyyy-mm-dd hh24:mi:ss') ";
|
|
|
if (StringUtils.isNotBlank(startTime)) {
|
|
|
if ("xm_ykyy_wx".equals(wxId)) {
|
|
|
if (flag) {
|
|
|
sql += " and t.create_time > '" + startTime + "'";
|
|
|
} else {
|
|
|
sql += " and t.create_time > to_date('" + startTime + "', 'yyyy-mm-dd hh24:mi:ss') ";
|
|
|
}
|
|
|
}else{
|
|
|
sql+=" and t.create_time > '"+startTime+"'";
|
|
|
} else {
|
|
|
sql += " and t.create_time > '" + startTime + "'";
|
|
|
}
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(endTime)){
|
|
|
if("xm_ykyy_wx".equals(wxId)){
|
|
|
if (flag){
|
|
|
sql+=" and t.create_time<='" + endTime + "'";
|
|
|
}else {
|
|
|
sql+=" and t.create_time<= to_date('" + endTime + "','yyyy-mm-dd hh24:mi:ss')";
|
|
|
if (StringUtils.isNotBlank(endTime)) {
|
|
|
if ("xm_ykyy_wx".equals(wxId)) {
|
|
|
if (flag) {
|
|
|
sql += " and t.create_time<='" + endTime + "'";
|
|
|
} else {
|
|
|
sql += " and t.create_time<= to_date('" + endTime + "','yyyy-mm-dd hh24:mi:ss')";
|
|
|
}
|
|
|
}else{
|
|
|
sql+=" and t.create_time<='" + endTime + "'";
|
|
|
} else {
|
|
|
sql += " and t.create_time<='" + endTime + "'";
|
|
|
}
|
|
|
}
|
|
|
sql+=" order by t.create_time desc ";
|
|
|
List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql,page,pageSize);
|
|
|
String sqlcount = "SELECT COUNT(1) AS \"total\" FROM ("+sql+") q";
|
|
|
sql += " order by t.create_time desc ";
|
|
|
List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql, page, pageSize);
|
|
|
String sqlcount = "SELECT COUNT(1) AS \"total\" FROM (" + sql + ") q";
|
|
|
Long count = 0L;
|
|
|
List<Map<String,Object>> total = hibenateUtils.createSQLQuery(sqlcount);
|
|
|
if(total!=null){
|
|
|
List<Map<String, Object>> total = hibenateUtils.createSQLQuery(sqlcount);
|
|
|
if (total != null) {
|
|
|
//mysql 与 Oracle 聚合函数返回类型不一致,需要判断装换
|
|
|
count = hibenateUtils.objTransformLong(total.get(0).get("total"));
|
|
|
}
|
|
@ -662,153 +725,168 @@ public class BaseComplaintService {
|
|
|
mixEnvelop.setCurrPage(page);
|
|
|
return mixEnvelop;
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* 查询投诉数量*/
|
|
|
public Map<String,Object> findComplaintCount(String doctor,String role){
|
|
|
BaseComplaintDoctorDO baseComplaintDoctorDO=baseComplaintDoctorDao.findbyDoctorAndDel(doctor);
|
|
|
Integer complaints=0;
|
|
|
Integer recieve=0;
|
|
|
Integer deal=0;
|
|
|
Integer cacel=0;
|
|
|
Integer passto=0;
|
|
|
Integer total=0;
|
|
|
if (baseComplaintDoctorDO!=null){
|
|
|
Boolean queryAll=false;
|
|
|
if ("admin".equalsIgnoreCase(role)){
|
|
|
queryAll=true;
|
|
|
* 查询投诉数量*/
|
|
|
public Map<String, Object> findComplaintCount(String doctor, String role) {
|
|
|
// BaseComplaintDoctorDO baseComplaintDoctorDO = baseComplaintDoctorDao.findbyDoctorAndDel(doctor);
|
|
|
|
|
|
String sql = " SELECT t.complaint_id from base_complaint_doctor t where t.is_del='1' and t.doctor='" + doctor + "'";
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
Integer complaints = 0;
|
|
|
Integer recieve = 0;
|
|
|
Integer deal = 0;
|
|
|
Integer cacel = 0;
|
|
|
Integer passto = 0;
|
|
|
Integer total = 0;
|
|
|
boolean flag = false;
|
|
|
System.out.println("数据==>" + JSON.toJSONString(list));
|
|
|
if (list != null && list.size() > 0) {
|
|
|
Boolean queryAll = false;
|
|
|
if ("admin".equalsIgnoreCase(role)) {
|
|
|
queryAll = true;
|
|
|
}
|
|
|
for (Map<String, Object> map : list) {
|
|
|
String complaint_id = String.valueOf(map.get("complaint_id"));
|
|
|
if ("808080eb7a194099017a1943fa820004".equalsIgnoreCase(complaint_id)) {
|
|
|
flag = true;
|
|
|
}
|
|
|
if (!queryAll){
|
|
|
if ("808080eb7a194099017a1943fa820004".equalsIgnoreCase(baseComplaintDoctorDO.getComplaintId())) {
|
|
|
complaints = getCountByStatus(doctor,"0",role);
|
|
|
recieve = getCountByStatus(doctor,"1",role);
|
|
|
deal = getCountByStatus(doctor,"2",role);
|
|
|
passto = getCountByPassto(doctor);
|
|
|
total = getCountByStatus(doctor,"",role);
|
|
|
}else{
|
|
|
complaints=getCountByStatus(doctor,"0",role);
|
|
|
recieve=getCountByStatus(doctor,"1",role);
|
|
|
deal=getCountByStatus(doctor,"2",role);
|
|
|
passto=getCountByPassto(doctor);
|
|
|
total=getCountByStatus(doctor,"",role);
|
|
|
}
|
|
|
//cacel=baseComplaintDao.getCountByStatusAndComplaintId("-1",baseComplaintDoctorDO.getComplaintId());
|
|
|
}else {
|
|
|
complaints=baseComplaintDao.getCountByStatus("0");
|
|
|
recieve=baseComplaintDao.getCountByStatus("1");
|
|
|
deal=baseComplaintDao.getCountByStatus("2");
|
|
|
cacel=baseComplaintDao.getCountByStatus("-1");
|
|
|
total = complaints+recieve+deal+cacel;
|
|
|
}
|
|
|
if (!queryAll) {
|
|
|
// if ("808080eb7a194099017a1943fa820004".equalsIgnoreCase(baseComplaintDoctorDO.getComplaintId())) {
|
|
|
|
|
|
if (flag) {
|
|
|
complaints = getCountByStatus(doctor, "0", role);
|
|
|
recieve = getCountByStatus(doctor, "1", role);
|
|
|
deal = getCountByStatus(doctor, "2", role);
|
|
|
passto = getCountByPassto(doctor);
|
|
|
total = getCountByStatus(doctor, "", role);
|
|
|
} else {
|
|
|
complaints = getCountByStatus(doctor, "0", role);
|
|
|
recieve = getCountByStatus(doctor, "1", role);
|
|
|
deal = getCountByStatus(doctor, "2", role);
|
|
|
passto = getCountByPassto(doctor);
|
|
|
total = getCountByStatus(doctor, "", role);
|
|
|
}
|
|
|
//cacel=baseComplaintDao.getCountByStatusAndComplaintId("-1",baseComplaintDoctorDO.getComplaintId());
|
|
|
} else {
|
|
|
complaints = baseComplaintDao.getCountByStatus("0");
|
|
|
recieve = baseComplaintDao.getCountByStatus("1");
|
|
|
deal = baseComplaintDao.getCountByStatus("2");
|
|
|
cacel = baseComplaintDao.getCountByStatus("-1");
|
|
|
total = complaints + recieve + deal + cacel;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
Map map=new HashMap();
|
|
|
map.put("complaints",complaints);
|
|
|
map.put("recieve",recieve);
|
|
|
map.put("deal",deal);
|
|
|
map.put("passto",passto);
|
|
|
map.put("cacel",cacel);
|
|
|
map.put("total",total);
|
|
|
Map map = new HashMap();
|
|
|
map.put("complaints", complaints);
|
|
|
map.put("recieve", recieve);
|
|
|
map.put("deal", deal);
|
|
|
map.put("passto", passto);
|
|
|
map.put("cacel", cacel);
|
|
|
map.put("total", total);
|
|
|
return map;
|
|
|
}
|
|
|
public Integer getCountByPassto(String doctor){
|
|
|
String sql ="select count(1) as \"total\" from (select DISTINCT t.id from base_complaint t left join base_complaint_operate_log b" +
|
|
|
|
|
|
public Integer getCountByPassto(String doctor) {
|
|
|
String sql = "select count(1) as \"total\" from (select DISTINCT t.id from base_complaint t left join base_complaint_operate_log b" +
|
|
|
" on t.id=b.relation_code where t.is_del='1' and b.status='3'";
|
|
|
if (StringUtils.isNoneBlank(doctor)){
|
|
|
sql+=" and b.operate_from='"+doctor+"'";
|
|
|
if (StringUtils.isNoneBlank(doctor)) {
|
|
|
sql += " and b.operate_from='" + doctor + "'";
|
|
|
}
|
|
|
sql+=") m";
|
|
|
List<Map<String,Object>> listcount=hibenateUtils.createSQLQuery(sql);
|
|
|
Integer count=0;
|
|
|
if (listcount!=null&&listcount.size()>0){
|
|
|
count=Integer.valueOf(listcount.get(0).get("total").toString());
|
|
|
sql += ") m";
|
|
|
List<Map<String, Object>> listcount = hibenateUtils.createSQLQuery(sql);
|
|
|
Integer count = 0;
|
|
|
if (listcount != null && listcount.size() > 0) {
|
|
|
count = Integer.valueOf(listcount.get(0).get("total").toString());
|
|
|
}
|
|
|
return count;
|
|
|
}
|
|
|
public Integer getCountByStatus(String doctor,String status,String role){
|
|
|
Boolean queryAll=false;
|
|
|
if ("admin".equalsIgnoreCase(role)){
|
|
|
queryAll=true;
|
|
|
|
|
|
public Integer getCountByStatus(String doctor, String status, String role) {
|
|
|
Boolean queryAll = false;
|
|
|
if ("admin".equalsIgnoreCase(role)) {
|
|
|
queryAll = true;
|
|
|
}
|
|
|
String sql="select count(1) as \"count\" from (select DISTINCT t.id "+
|
|
|
String sql = "select count(1) as \"count\" from (select DISTINCT t.id " +
|
|
|
" from base_complaint t " +
|
|
|
" left join base_patient b on t.patient=b.id " ;
|
|
|
" left join base_patient b on t.patient=b.id ";
|
|
|
|
|
|
sql+=" left join base_complaint_operate_log g on t.id=g.relation_code where t.is_del='1' ";
|
|
|
if (StringUtils.isNoneBlank(status)&&"3".equalsIgnoreCase(status)){
|
|
|
sql+=" and g.status='3' ";
|
|
|
sql += " left join base_complaint_operate_log g on t.id=g.relation_code where t.is_del='1' ";
|
|
|
if (StringUtils.isNoneBlank(status) && "3".equalsIgnoreCase(status)) {
|
|
|
sql += " and g.status='3' ";
|
|
|
} /*else if (StringUtils.isNoneBlank(status)&&"1".equalsIgnoreCase(status)){
|
|
|
sql+=" and g.status='1' ";
|
|
|
}
|
|
|
else if (StringUtils.isNoneBlank(status)&&"2".equalsIgnoreCase(status)){
|
|
|
sql+=" and g.status='2' ";
|
|
|
}*/
|
|
|
if (!queryAll){
|
|
|
BaseComplaintDoctorDO baseComplaintDoctorDO= baseComplaintDoctorDao.findbyDoctorAndDel(doctor);
|
|
|
/*List<BaseComplaintOperateLogDO> logList =baseComplaintOperateDao.findbyOperateFrom(doctor);
|
|
|
String types= "";
|
|
|
if (logList!=null&&logList.size()>0){
|
|
|
for (int i=0;i<logList.size();i++){
|
|
|
if (i==logList.size()-1){
|
|
|
types+=logList.get(i).getComplaintTo();
|
|
|
}else {
|
|
|
types+=logList.get(i).getComplaintTo()+",";
|
|
|
if (!queryAll) {
|
|
|
|
|
|
|
|
|
//原本的
|
|
|
// BaseComplaintDoctorDO baseComplaintDoctorDO = baseComplaintDoctorDao.findbyDoctorAndDel(doctor);
|
|
|
|
|
|
List<Map<String, Object>> list = getComplaintList(doctor);
|
|
|
String complaint = "";
|
|
|
if (!list.isEmpty()) {
|
|
|
for (Map<String, Object> map : list) {
|
|
|
String complaint_id = String.valueOf(map.get("complaint_id"));
|
|
|
if (complaint_id.equalsIgnoreCase("808080eb7a194099017a1943fa820004")) {
|
|
|
complaint = complaint_id;
|
|
|
}
|
|
|
}
|
|
|
}*/
|
|
|
String complaint="";
|
|
|
if (baseComplaintDoctorDO!=null){
|
|
|
if (baseComplaintDoctorDO.getComplaintId().equalsIgnoreCase("808080eb7a194099017a1943fa820004")){
|
|
|
complaint=baseComplaintDoctorDO.getComplaintId();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
//complaint=complaint+","+types;
|
|
|
if (StringUtils.isNoneBlank(complaint)){
|
|
|
if (!StringUtils.isNoneBlank(status)){
|
|
|
sql+=" and t.status !='-1'";
|
|
|
sql+=" and (t.defaultdoctor ='defalutDoctor' or t.defaultdoctor='"+doctor+"')";
|
|
|
if (StringUtils.isNoneBlank(complaint)) {
|
|
|
if (!StringUtils.isNoneBlank(status)) {
|
|
|
sql += " and t.status !='-1'";
|
|
|
sql += " and (t.defaultdoctor ='defalutDoctor' or t.defaultdoctor='" + doctor + "')";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(status)&&"3".equalsIgnoreCase(status)){
|
|
|
sql+=" and g.operate_from='"+doctor+"'";
|
|
|
}else {
|
|
|
sql+=" and t.complaint_id='"+complaint+"'";
|
|
|
if (StringUtils.isNoneBlank(status) && "3".equalsIgnoreCase(status)) {
|
|
|
sql += " and g.operate_from='" + doctor + "'";
|
|
|
} else {
|
|
|
sql += " and t.complaint_id='" + complaint + "'";
|
|
|
}
|
|
|
if (!StringUtils.isNoneBlank(status)){
|
|
|
sql+=" or (g.operate_from='"+doctor+"' and g.status='3')";
|
|
|
if (!StringUtils.isNoneBlank(status)) {
|
|
|
sql += " or (g.operate_from='" + doctor + "' and g.status='3')";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(status)&&"3".equalsIgnoreCase(status)){
|
|
|
sql+=" and g.operate_from='"+doctor+"'";
|
|
|
}else if (StringUtils.isNoneBlank(status)&&"0".equalsIgnoreCase(status)){
|
|
|
sql+=" and t.status='0' and (t.passto='"+doctor+"' or t.passto is null )";
|
|
|
} else if (StringUtils.isNoneBlank(status)&&"1".equalsIgnoreCase(status)){
|
|
|
sql+=" and t.status='1' and t.acceptor='"+doctor+"' ";
|
|
|
} else if (StringUtils.isNoneBlank(status)&&"2".equalsIgnoreCase(status)){
|
|
|
sql+=" and t.status='2' and t.operator='"+doctor+"' ";
|
|
|
if (StringUtils.isNoneBlank(status) && "3".equalsIgnoreCase(status)) {
|
|
|
sql += " and g.operate_from='" + doctor + "'";
|
|
|
} else if (StringUtils.isNoneBlank(status) && "0".equalsIgnoreCase(status)) {
|
|
|
sql += " and t.status='0' and (t.passto='" + doctor + "' or t.passto is null )";
|
|
|
} else if (StringUtils.isNoneBlank(status) && "1".equalsIgnoreCase(status)) {
|
|
|
sql += " and t.status='1' and t.acceptor='" + doctor + "' ";
|
|
|
} else if (StringUtils.isNoneBlank(status) && "2".equalsIgnoreCase(status)) {
|
|
|
sql += " and t.status='2' and t.operator='" + doctor + "' ";
|
|
|
}
|
|
|
//sql+=" and t.complaint_id in ('"+complaint.replace(",","','")+"')";
|
|
|
}else {
|
|
|
if (StringUtils.isNoneBlank(status)&&"3".equalsIgnoreCase(status)){
|
|
|
sql+=" and g.operate_from='"+doctor+"'";
|
|
|
}else if (StringUtils.isNoneBlank(status)&&"0".equalsIgnoreCase(status)){
|
|
|
sql+=" and t.status='0' and t.passto='"+doctor+"'";
|
|
|
} else if (StringUtils.isNoneBlank(status)&&"1".equalsIgnoreCase(status)){
|
|
|
sql+=" and t.status='1' and t.acceptor='"+doctor+"' ";
|
|
|
} else if (StringUtils.isNoneBlank(status)&&"2".equalsIgnoreCase(status)){
|
|
|
sql+=" and t.status='2' and t.operator='"+doctor+"' ";
|
|
|
} else {
|
|
|
if (StringUtils.isNoneBlank(status) && "3".equalsIgnoreCase(status)) {
|
|
|
sql += " and g.operate_from='" + doctor + "'";
|
|
|
} else if (StringUtils.isNoneBlank(status) && "0".equalsIgnoreCase(status)) {
|
|
|
sql += " and t.status='0' and t.passto='" + doctor + "'";
|
|
|
} else if (StringUtils.isNoneBlank(status) && "1".equalsIgnoreCase(status)) {
|
|
|
sql += " and t.status='1' and t.acceptor='" + doctor + "' ";
|
|
|
} else if (StringUtils.isNoneBlank(status) && "2".equalsIgnoreCase(status)) {
|
|
|
sql += " and t.status='2' and t.operator='" + doctor + "' ";
|
|
|
} else {
|
|
|
sql+=" and t.id IN (select col.relation_code from base_complaint_operate_log col where col.operate_to = '"+doctor+"' )";
|
|
|
sql += " and t.id IN (select col.relation_code from base_complaint_operate_log col where col.operate_to = '" + doctor + "' )";
|
|
|
}
|
|
|
}
|
|
|
if (!StringUtils.isNoneBlank(status)){
|
|
|
sql+=" and t.status !='-1'";
|
|
|
if (!StringUtils.isNoneBlank(status)) {
|
|
|
sql += " and t.status !='-1'";
|
|
|
}
|
|
|
//complaint=complaint+","+types;
|
|
|
|
|
|
}
|
|
|
System.out.println("sql"+sql);
|
|
|
System.out.println("sql" + sql);
|
|
|
Integer count = 0;
|
|
|
sql+=")g";
|
|
|
List<Map<String,Object>> total = hibenateUtils.createSQLQuery(sql);
|
|
|
if(total!=null&&total.size()>0){
|
|
|
sql += ")g";
|
|
|
List<Map<String, Object>> total = hibenateUtils.createSQLQuery(sql);
|
|
|
if (total != null && total.size() > 0) {
|
|
|
//mysql 与 Oracle 聚合函数返回类型不一致,需要判断装换
|
|
|
count = Integer.valueOf(total.get(0).get("count").toString());
|
|
|
}
|
|
@ -817,46 +895,48 @@ public class BaseComplaintService {
|
|
|
|
|
|
/*
|
|
|
* 查询投诉数量*/
|
|
|
public Map<String,Object> findComplaintCountPatient(String patient){
|
|
|
Integer complaints=0;
|
|
|
Integer recieve=0;
|
|
|
Integer deal=0;
|
|
|
Integer cacel=0;
|
|
|
complaints=baseComplaintDao.getCountByStatusByPatient("0",patient);
|
|
|
recieve=baseComplaintDao.getCountByStatusByPatient("1",patient);
|
|
|
deal=baseComplaintDao.getCountByStatusByPatient("2",patient);
|
|
|
cacel=baseComplaintDao.getCountByStatusByPatient("-1",patient);
|
|
|
Integer total = complaints+recieve+deal+cacel;
|
|
|
Map map=new HashMap();
|
|
|
map.put("complaints",complaints);
|
|
|
map.put("recieve",recieve);
|
|
|
map.put("deal",deal);
|
|
|
map.put("cacel",cacel);
|
|
|
map.put("total",total);
|
|
|
public Map<String, Object> findComplaintCountPatient(String patient) {
|
|
|
Integer complaints = 0;
|
|
|
Integer recieve = 0;
|
|
|
Integer deal = 0;
|
|
|
Integer cacel = 0;
|
|
|
complaints = baseComplaintDao.getCountByStatusByPatient("0", patient);
|
|
|
recieve = baseComplaintDao.getCountByStatusByPatient("1", patient);
|
|
|
deal = baseComplaintDao.getCountByStatusByPatient("2", patient);
|
|
|
cacel = baseComplaintDao.getCountByStatusByPatient("-1", patient);
|
|
|
Integer total = complaints + recieve + deal + cacel;
|
|
|
Map map = new HashMap();
|
|
|
map.put("complaints", complaints);
|
|
|
map.put("recieve", recieve);
|
|
|
map.put("deal", deal);
|
|
|
map.put("cacel", cacel);
|
|
|
map.put("total", total);
|
|
|
return map;
|
|
|
}
|
|
|
public BaseComplaintDO cancelPaitentComplaint(String id,String patient) throws Exception{
|
|
|
|
|
|
public BaseComplaintDO cancelPaitentComplaint(String id, String patient) throws Exception {
|
|
|
BaseComplaintDO baseComplaintDO = baseComplaintDao.findById(id).orElse(null);
|
|
|
if (baseComplaintDO!=null){
|
|
|
if ("0".equalsIgnoreCase(baseComplaintDO.getStatus())){
|
|
|
baseComplaintDO.setStatus("-1");
|
|
|
baseComplaintDO=baseComplaintDao.save(baseComplaintDO);
|
|
|
BaseComplaintOperateLogDO baseComplaintOperateLogDO = new BaseComplaintOperateLogDO();
|
|
|
baseComplaintOperateLogDO.setOperateFrom(patient);
|
|
|
baseComplaintOperateLogDO.setStatus("-1");
|
|
|
baseComplaintOperateLogDO.setOperateType("居民撤销投诉");
|
|
|
baseComplaintOperateLogDO.setRelationCode(baseComplaintDO.getId());
|
|
|
baseComplaintOperateLogDO.setCreateTime(new Date());
|
|
|
baseComplaintOperateDao.save(baseComplaintOperateLogDO);
|
|
|
}else {
|
|
|
throw new Exception("不允许撤销");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
return baseComplaintDO;
|
|
|
if (baseComplaintDO != null) {
|
|
|
if ("0".equalsIgnoreCase(baseComplaintDO.getStatus())) {
|
|
|
baseComplaintDO.setStatus("-1");
|
|
|
baseComplaintDO = baseComplaintDao.save(baseComplaintDO);
|
|
|
BaseComplaintOperateLogDO baseComplaintOperateLogDO = new BaseComplaintOperateLogDO();
|
|
|
baseComplaintOperateLogDO.setOperateFrom(patient);
|
|
|
baseComplaintOperateLogDO.setStatus("-1");
|
|
|
baseComplaintOperateLogDO.setOperateType("居民撤销投诉");
|
|
|
baseComplaintOperateLogDO.setRelationCode(baseComplaintDO.getId());
|
|
|
baseComplaintOperateLogDO.setCreateTime(new Date());
|
|
|
baseComplaintOperateDao.save(baseComplaintOperateLogDO);
|
|
|
} else {
|
|
|
throw new Exception("不允许撤销");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
return baseComplaintDO;
|
|
|
}
|
|
|
public List<Map<String,Object>> findComplaintOperateLog(String complaintId){
|
|
|
String sql ="select t.id as \"id\"," +
|
|
|
|
|
|
public List<Map<String, Object>> findComplaintOperateLog(String complaintId) {
|
|
|
String sql = "select t.id as \"id\"," +
|
|
|
" p.name as \"complaintNameFrom\" ," +
|
|
|
" n.name as \"complaintNameto\", " +
|
|
|
" t.operate_from as \"operateFrom\" ," +
|
|
@ -870,51 +950,57 @@ public class BaseComplaintService {
|
|
|
" from base_complaint_operate_log t left join base_complaint c" +
|
|
|
" on t.relation_code=c.id" +
|
|
|
" left join base_complaint_dict p on t.complaint_from= p.id" +
|
|
|
" left join base_complaint_dict n on t.complaint_to=n.id where 1=1 " ;
|
|
|
if (StringUtils.isNoneBlank(complaintId)){
|
|
|
sql+=" and t.relation_code='"+complaintId+"'";
|
|
|
}
|
|
|
sql+=" order by t.create_time desc";
|
|
|
List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql);
|
|
|
List<WlyyHospitalSysDictDO> typeList=wlyyHospitalSysDictDao.findByDictName("complaintStatus");
|
|
|
for (Map<String,Object> map:list){
|
|
|
if (map.get("operateFrom")!=null){
|
|
|
if (map.get("status")!=null){
|
|
|
for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO:typeList){
|
|
|
if (map.get("status").toString().equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
|
|
|
map.put("operateType",wlyyHospitalSysDictDO.getDictValue());
|
|
|
" left join base_complaint_dict n on t.complaint_to=n.id where 1=1 ";
|
|
|
if (StringUtils.isNoneBlank(complaintId)) {
|
|
|
sql += " and t.relation_code='" + complaintId + "'";
|
|
|
}
|
|
|
sql += " order by t.create_time desc";
|
|
|
List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql);
|
|
|
List<WlyyHospitalSysDictDO> typeList = wlyyHospitalSysDictDao.findByDictName("complaintStatus");
|
|
|
for (Map<String, Object> map : list) {
|
|
|
if (map.get("operateFrom") != null) {
|
|
|
if (map.get("status") != null) {
|
|
|
for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO : typeList) {
|
|
|
if (map.get("status").toString().equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())) {
|
|
|
map.put("operateType", wlyyHospitalSysDictDO.getDictValue());
|
|
|
}
|
|
|
}
|
|
|
if ("0".equalsIgnoreCase(map.get("status").toString())||"-1".equalsIgnoreCase(map.get("status").toString())){
|
|
|
if ("0".equalsIgnoreCase(map.get("status").toString()) || "-1".equalsIgnoreCase(map.get("status").toString())) {
|
|
|
BasePatientDO basePatientDO = basePatientDao.findById(map.get("operateFrom").toString()).orElse(null);
|
|
|
if (basePatientDO!=null){
|
|
|
map.put("operateFromName",basePatientDO.getName());
|
|
|
if (basePatientDO != null) {
|
|
|
map.put("operateFromName", basePatientDO.getName());
|
|
|
}
|
|
|
}else {
|
|
|
BaseDoctorDO baseDoctorDO= baseDoctorDao.findByIdAndDel(map.get("operateFrom").toString());
|
|
|
if (baseDoctorDO!=null){
|
|
|
map.put("operateFromName",baseDoctorDO.getName());
|
|
|
} else {
|
|
|
BaseDoctorDO baseDoctorDO = baseDoctorDao.findByIdAndDel(map.get("operateFrom").toString());
|
|
|
if (baseDoctorDO != null) {
|
|
|
map.put("operateFromName", baseDoctorDO.getName());
|
|
|
}
|
|
|
List<BaseDoctorHospitalDO> baseDoctorHospitalDO= baseDoctorHospitalDao.findByDoctorCode(map.get("operateFrom").toString());
|
|
|
if (baseDoctorHospitalDO!=null&&baseDoctorHospitalDO.size()>0){
|
|
|
map.put("operateFromDeptName",baseDoctorHospitalDO.get(0).getDeptName());
|
|
|
List<BaseDoctorHospitalDO> baseDoctorHospitalDO = baseDoctorHospitalDao.findByDoctorCode(map.get("operateFrom").toString());
|
|
|
if (baseDoctorHospitalDO != null && baseDoctorHospitalDO.size() > 0) {
|
|
|
map.put("operateFromDeptName", baseDoctorHospitalDO.get(0).getDeptName());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (map.get("operateTo")!=null){
|
|
|
BaseDoctorDO baseDoctorDO= baseDoctorDao.findByIdAndDel(map.get("operateTo").toString());
|
|
|
if (baseDoctorDO!=null){
|
|
|
map.put("operateToName",baseDoctorDO.getName());
|
|
|
if (map.get("operateTo") != null) {
|
|
|
BaseDoctorDO baseDoctorDO = baseDoctorDao.findByIdAndDel(map.get("operateTo").toString());
|
|
|
if (baseDoctorDO != null) {
|
|
|
map.put("operateToName", baseDoctorDO.getName());
|
|
|
}
|
|
|
List<BaseDoctorHospitalDO> baseDoctorHospitalDO= baseDoctorHospitalDao.findByDoctorCode(map.get("operateTo").toString());
|
|
|
if (baseDoctorHospitalDO!=null&&baseDoctorHospitalDO.size()>0){
|
|
|
map.put("operateToDeptName",baseDoctorHospitalDO.get(0).getDeptName());
|
|
|
List<BaseDoctorHospitalDO> baseDoctorHospitalDO = baseDoctorHospitalDao.findByDoctorCode(map.get("operateTo").toString());
|
|
|
if (baseDoctorHospitalDO != null && baseDoctorHospitalDO.size() > 0) {
|
|
|
map.put("operateToDeptName", baseDoctorHospitalDO.get(0).getDeptName());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return list;
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
public List<Map<String, Object>> getComplaintList(String doctorCode) {
|
|
|
String sql = " SELECT t.complaint_id from base_complaint_doctor t where t.is_del='1' and t.doctor='" + doctorCode + "'";
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
return list;
|
|
|
}
|
|
|
}
|
|
|
|