LAPTOP-KB9HII50\70708 11 mesi fa
parent
commit
c62bd1e48e

+ 62 - 66
business/base-service/src/main/java/com/yihu/jw/complaint/BaseComplaintService.java

@ -282,10 +282,19 @@ public class BaseComplaintService {
            throw new Exception("投诉通道已关闭");
            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) {
            baseComplaintDO.setComplaintName(baseComplaintDictDO.getName());
        if(StringUtils.isBlank(baseComplaintDO.getComplaintId())){
            //其他
            List<BaseComplaintDictDO> dictDOList =  baseComplaintDictDao.findByName(baseComplaintDO.getComplaintName());
            if(dictDOList.size()>0){
                baseComplaintDO.setComplaintId(dictDOList.get(0).getId());
            }
        }else {
            BaseComplaintDictDO baseComplaintDictDO = baseComplaintDictDao.findByIdAndIsDel(baseComplaintDO.getComplaintId());
            if (baseComplaintDictDO != null) {
                baseComplaintDO.setComplaintName(baseComplaintDictDO.getName());
            }
        }
        }
        if (StringUtils.isNoneBlank(baseComplaintDO.getVisitDept())) {
        if (StringUtils.isNoneBlank(baseComplaintDO.getVisitDept())) {
            DictHospitalDeptDO dictHospitalDeptDO = dictHospitalDeptDao.findByCode(baseComplaintDO.getVisitDept());
            DictHospitalDeptDO dictHospitalDeptDO = dictHospitalDeptDao.findByCode(baseComplaintDO.getVisitDept());
            if (dictHospitalDeptDO != null) {
            if (dictHospitalDeptDO != null) {
@ -496,7 +505,7 @@ public class BaseComplaintService {
        }
        }
        boolean flag = false;
        boolean flag = false;
        if (!queryAll) {
        if (!queryAll) {
            boolean isOther = false;
            String isOther = "";
            String complaint = "";
            String complaint = "";
            String sql1 = "SELECT distinct di.id,di.`name` from base_complaint_doctor d,base_complaint_dict di " +
            String sql1 = "SELECT distinct di.id,di.`name` from base_complaint_doctor d,base_complaint_dict di " +
                    "WHERE di.id=d.complaint_id and d.is_del=1 and di.is_del=1 and d.doctor='"+doctor+"'";
                    "WHERE di.id=d.complaint_id and d.is_del=1 and di.is_del=1 and d.doctor='"+doctor+"'";
@ -512,7 +521,7 @@ public class BaseComplaintService {
                String id = map.get("id")+"";
                String id = map.get("id")+"";
                String name = map.get("name")+"";
                String name = map.get("name")+"";
                if("其他".equals(name)){
                if("其他".equals(name)){
                    isOther = true;
                    isOther = id;
                }else {
                }else {
                    complaint += id+",";
                    complaint += id+",";
                }
                }
@ -521,23 +530,29 @@ public class BaseComplaintService {
                complaint = complaint.substring(0,complaint.length()-1);
                complaint = complaint.substring(0,complaint.length()-1);
                complaint = complaint.replaceAll(",","','");
                complaint = complaint.replaceAll(",","','");
            }
            }
            if (isOther) {
                if (StringUtils.isNoneBlank(status)) {
                    sql += " and t.status ='" + status + "'";
            if (StringUtils.isNoneBlank(status) && "3".equalsIgnoreCase(status)) {
                sql += " and g.operate_from='" + doctor;
            } else if (StringUtils.isNoneBlank(status) && "0".equalsIgnoreCase(status)) {
                if(StringUtils.isNotBlank(isOther)){
                    //其他权限医生可以看到所有已投诉的工单
                    sql += " and t.status='0' and ((t.passto='" + doctor + "' and t.complaint_id in ('"+complaint+"')) or t.complaint_id='"+isOther+"' ) ";
                }else {
                    sql += " and t.status='0' and t.passto='" + doctor + "' and t.complaint_id in ('"+complaint+"') ";
                }
                }
            } 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 {
            } 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 + "' and t.complaint_id='"+complaint+"' ";
                } 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.status='2' and t.operator='" + doctor + "') or (t.status='1' and t.acceptor='" + doctor + "') " +
                            " or (t.status='0' and t.passto='" + doctor + "' and t.complaint_id='"+complaint+"')) ";
                String statusSql = "";
                if(StringUtils.isNotBlank(isOther)){
                    //其他权限医生可以看到所有已投诉的工单
                    statusSql += " t.status='0' and ((t.passto='" + doctor + "' and t.complaint_id in ('"+complaint+"')) or t.complaint_id='"+isOther+"' ) ";
                }else {
                    statusSql += " t.status='0' and t.passto='" + doctor + "' and t.complaint_id in ('"+complaint+"') ";
                }
                }
                sql += " and ((t.status='2' and t.operator='" + doctor + "') or (t.status='1' and t.acceptor='" + doctor + "') " +
                        " or (" + statusSql + " )) ";
            }
            }
        } else {
        } else {
@ -717,8 +732,8 @@ public class BaseComplaintService {
//        }
//        }
        if (!queryAll) {
        if (!queryAll) {
            boolean isOther = false;
            String complaint = "";
            String complaint = "";
            String isOther = "";
            String sql1 = "SELECT distinct di.id,di.`name` from base_complaint_doctor d,base_complaint_dict di " +
            String sql1 = "SELECT distinct di.id,di.`name` from base_complaint_doctor d,base_complaint_dict di " +
                    "WHERE di.id=d.complaint_id and d.is_del=1 and di.is_del=1 and d.doctor='"+doctor+"'";
                    "WHERE di.id=d.complaint_id and d.is_del=1 and di.is_del=1 and d.doctor='"+doctor+"'";
            List<Map<String, Object>> list = jdbcTemplate.queryForList(sql1);
            List<Map<String, Object>> list = jdbcTemplate.queryForList(sql1);
@ -735,8 +750,9 @@ public class BaseComplaintService {
            for (Map<String, Object> map:list){
            for (Map<String, Object> map:list){
                String id = map.get("id")+"";
                String id = map.get("id")+"";
                String name = map.get("name")+"";
                String name = map.get("name")+"";
                complaint += id+",";
                if("其他".equals(name)){
                if("其他".equals(name)){
                    isOther = true;
                    isOther = id;
                }else {
                }else {
                    complaint += id+",";
                    complaint += id+",";
                }
                }
@ -745,36 +761,19 @@ public class BaseComplaintService {
                complaint = complaint.substring(0,complaint.length()-1);
                complaint = complaint.substring(0,complaint.length()-1);
                complaint = complaint.replaceAll(",","','");
                complaint = complaint.replaceAll(",","','");
            }
            }
            if (isOther) {
                complaints = getCountByStatus(doctor, "0",complaint, isOther);
                recieve = getCountByStatus(doctor, "1",complaint, isOther);
                deal = getCountByStatus(doctor, "2",complaint, isOther);
//                passto = getCountByPassto(doctor);
//                total = getCountByStatus(doctor, "",complaint, isOther);
                //撤销
                cacel = getCountByStatus(doctor, "-1",complaint, isOther);
                if (StringUtils.isNotBlank(pcAdmin)) {
                    total = complaints + recieve+deal+cacel;
                    System.out.println("是pc管理员");
                } else {
                    total = complaints + recieve+deal;
                }
            } else {
                complaints = getCountByStatus(doctor, "0",complaint, isOther);
                recieve = getCountByStatus(doctor, "1",complaint, isOther);
                deal = getCountByStatus(doctor, "2",complaint, isOther);
            complaints = getCountByStatus(doctor, "0",complaint,isOther);
            recieve = getCountByStatus(doctor, "1",complaint,"");
            deal = getCountByStatus(doctor, "2",complaint,"");
//                passto = getCountByPassto(doctor);
//                passto = getCountByPassto(doctor);
//                total = getCountByStatus(doctor, "",complaint, isOther);
                //撤销
                cacel = getCountByStatus(doctor, "-1",complaint, isOther);
                if (StringUtils.isNotBlank(pcAdmin)) {
                    total = complaints + recieve+deal+cacel;
                    System.out.println("是pc管理员");
                } else {
                    total = complaints + recieve+deal;
                }
//                total = getCountByStatus(doctor, "",complaint);
            //撤销
            cacel = getCountByStatus(doctor, "-1",complaint,"");
            if (StringUtils.isNotBlank(pcAdmin)) {
                total = complaints + recieve+deal+cacel;
                System.out.println("是pc管理员");
            } else {
                total = complaints + recieve+deal;
            }
            }
            //cacel=baseComplaintDao.getCountByStatusAndComplaintId("-1",baseComplaintDoctorDO.getComplaintId());
            //cacel=baseComplaintDao.getCountByStatusAndComplaintId("-1",baseComplaintDoctorDO.getComplaintId());
        } else {
        } else {
@ -814,7 +813,7 @@ public class BaseComplaintService {
        return count;
        return count;
    }
    }
    public Integer getCountByStatus(String doctor, String status,String complaint, boolean isOther) {
    public Integer getCountByStatus(String doctor, String status,String complaint,String isOther) {
        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  " +
                "  from base_complaint t  " +
                " left join base_patient b on t.patient=b.id ";
                " left join base_patient b on t.patient=b.id ";
@ -823,22 +822,19 @@ public class BaseComplaintService {
        if ("3".equalsIgnoreCase(status)) {
        if ("3".equalsIgnoreCase(status)) {
            sql += "  and g.status='3' ";
            sql += "  and g.status='3' ";
        }
        }
        if (isOther) {
            if (StringUtils.isNoneBlank(status)) {
                sql += " and t.status ='" + status + "'";
            }
        } 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 + "'  and t.complaint_id='"+complaint+"' ";
            } 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 + "'  )";
            }
        if (StringUtils.isNoneBlank(status) && "3".equalsIgnoreCase(status)) {
            sql += " and g.operate_from='" + doctor + "'";
        } else if (StringUtils.isNoneBlank(status) && "0".equalsIgnoreCase(status)) {
            if(StringUtils.isNotBlank(isOther)){
                //其他权限医生可以看到所有已投诉的工单
                sql += " and t.status='0' and ((t.passto='" + doctor + "' and t.complaint_id in ('"+complaint+"')) or t.complaint_id='"+isOther+"' ) ";
            }else {
                sql += " and t.status='0' and t.passto='" + doctor + "' and t.complaint_id in ('"+complaint+"') ";
            }
        } 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)) {
        if (!StringUtils.isNoneBlank(status)) {
            sql += " and t.status !='-1'";
            sql += " and t.status !='-1'";