Browse Source

Merge branch '2.0' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into 2.0

 Conflicts:
	business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/DsyyPrescriptionService.java
	business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java
	business/im-service/src/main/java/com/yihu/jw/im/service/RobotService.java
wangzhinan 1 year ago
parent
commit
75d23fc40a
28 changed files with 920 additions and 806 deletions
  1. 115 182
      business/base-service/src/main/java/com/yihu/jw/complaint/BaseComplaintService.java
  2. 1 4
      business/base-service/src/main/java/com/yihu/jw/hospital/family/dao/BasePatientMemberDictDao.java
  3. 2 2
      business/base-service/src/main/java/com/yihu/jw/hospital/integrate/service/BaseHospitalActivityService.java
  4. 4 1
      business/base-service/src/main/java/com/yihu/jw/hospital/integrate/service/BaseHospitalGoodsService.java
  5. 6 5
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/DsyyPrescriptionService.java
  6. 97 4
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  7. 8 7
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/DsyyEntranceService.java
  8. 2 2
      business/base-service/src/main/java/com/yihu/jw/hospital/survey/dao/SurveyUserAnswerDao.java
  9. 321 288
      business/base-service/src/main/java/com/yihu/jw/hospital/survey/service/SurveyService.java
  10. 4 6
      business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java
  11. 88 88
      business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java
  12. 191 187
      business/im-service/src/main/java/com/yihu/jw/im/service/RobotService.java
  13. 2 0
      business/im-service/src/main/java/com/yihu/jw/im/util/ImUtil.java
  14. 9 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/survey/WlyySurveyUserAnswerDO.java
  15. 9 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/survey/WlyySurveyUserDO.java
  16. 1 1
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  17. 4 3
      svr/svr-base/src/main/java/com/yihu/jw/base/service/doctor/BaseDoctorService.java
  18. 13 2
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/DsyyController.java
  19. 2 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/complaint/BaseComplaintEndPoint.java
  20. 1 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java
  21. 6 7
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/PatientConsultEndpoint.java
  22. 5 4
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/hospital/WlyyFamilyMemberController.java
  23. 3 4
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/integrate/BaseHospitalGoodsController.java
  24. 3 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java
  25. 13 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java
  26. 4 2
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/survey/SurveyEndpoint.java
  27. 5 5
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/consult/BasePatientBusinessService.java
  28. 1 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/consult/KnowledgeArticleService.java

+ 115 - 182
business/base-service/src/main/java/com/yihu/jw/complaint/BaseComplaintService.java

@ -224,7 +224,7 @@ public class BaseComplaintService {
    /**
    /**
     * 去重医生
     * 去重医生
     */
     */
    public MixEnvelop findComplaintDoctorNew(String doctor, String doctorName, String deptName, String complaintType, Integer page, Integer pageSize) {
    public MixEnvelop findComplaintDoctorNew(String doctor, String doctorName,String role, String deptName, String complaintType, Integer page, Integer pageSize) {
        String sql = "select " +
        String sql = "select " +
                " t.doctor as \"doctor\"," +
                " t.doctor as \"doctor\"," +
                " t.doctor_name as \"doctorName\"," +
                " t.doctor_name as \"doctorName\"," +
@ -439,7 +439,9 @@ public class BaseComplaintService {
        return baseComplaintDO;
        return baseComplaintDO;
    }
    }
    //查询投诉列表
    //查询投诉列表
    //passto 已转交
    public MixEnvelop findComplaintList(String role, String doctor, String status, String patientName, String patientId, String keyWord, String complaintId,
    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, String pcAdmin) {
                                        String startTime, String endTime, Integer page, Integer pageSize, String pcAdmin) {
        MixEnvelop mixEnvelop = new MixEnvelop();
        MixEnvelop mixEnvelop = new MixEnvelop();
@ -491,75 +493,43 @@ public class BaseComplaintService {
        if (StringUtils.isNoneBlank(status) && "3".equalsIgnoreCase(status)) {
        if (StringUtils.isNoneBlank(status) && "3".equalsIgnoreCase(status)) {
            sql += " and  g.status='3' ";
            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' ";
        }*/
        boolean flag = false;
        boolean flag = false;
        if (!queryAll) {
        if (!queryAll) {
            //原本的
//            BaseComplaintDoctorDO baseComplaintDoctorDO = baseComplaintDoctorDao.findbyDoctorAndDel(doctor);
            boolean isOther = false;
            String complaint = "";
            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"));
                    }
            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+"'";
            List<Map<String, Object>> list = jdbcTemplate.queryForList(sql1);
            if(list.size()==0){
                mixEnvelop.setTotalCount(0);
                mixEnvelop.setDetailModelList(new ArrayList());
                mixEnvelop.setPageSize(pageSize);
                mixEnvelop.setCurrPage(page);
                return mixEnvelop;
            }
            for (Map<String, Object> map:list){
                String id = map.get("id")+"";
                String name = map.get("name")+"";
                if("其他".equals(name)){
                    isOther = true;
                }else {
                    complaint += id+",";
                }
                }
            }
            }
            /*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 (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(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) && "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.isNotBlank(complaint)){
                complaint = complaint.substring(0,complaint.length()-1);
                complaint = complaint.replaceAll(",","','");
            }
            if (isOther) {
                if (StringUtils.isNoneBlank(status)) {
                    sql += " and t.status ='" + status + "'";
                }
                }
                //sql+=" and t.complaint_id in ('"+complaint.replace(",","','")+"')";
            } else {
            } else {
                if (StringUtils.isNoneBlank(status) && "3".equalsIgnoreCase(status)) {
                if (StringUtils.isNoneBlank(status) && "3".equalsIgnoreCase(status)) {
                    sql += " and g.operate_from='" + doctor + "'";
                    sql += " and g.operate_from='" + doctor;
                } else if (StringUtils.isNoneBlank(status) && "0".equalsIgnoreCase(status)) {
                } else if (StringUtils.isNoneBlank(status) && "0".equalsIgnoreCase(status)) {
                    sql += " and t.status='0' and t.passto='" + doctor + "'";
                    sql += " and t.status='0' and t.passto='" + doctor + "'"+ "' and t.complaint_id='"+complaint+"' ";
                } else if (StringUtils.isNoneBlank(status) && "1".equalsIgnoreCase(status)) {
                } else if (StringUtils.isNoneBlank(status) && "1".equalsIgnoreCase(status)) {
                    sql += "  and t.status='1' and t.acceptor='" + doctor + "' ";
                    sql += "  and t.status='1' and t.acceptor='" + doctor + "' ";
                } else if (StringUtils.isNoneBlank(status) && "2".equalsIgnoreCase(status)) {
                } else if (StringUtils.isNoneBlank(status) && "2".equalsIgnoreCase(status)) {
@ -568,11 +538,9 @@ public class BaseComplaintService {
                    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 {
        } else {
            if (StringUtils.isNoneBlank(complaintId)) {
            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)) {
            if (StringUtils.isNoneBlank(status)) {
@ -736,71 +704,85 @@ public class BaseComplaintService {
    /*
    /*
     * 查询投诉数量*/
     * 查询投诉数量*/
    public Map<String, Object> findComplaintCount(String doctor, String role, String pcAdmin) {
    public Map<String, Object> findComplaintCount(String doctor, String role, String pcAdmin) {
//        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 complaints = 0;
        Integer recieve = 0;
        Integer recieve = 0;
        Integer deal = 0;
        Integer deal = 0;
        Integer cacel = 0;
        Integer cacel = 0;
        Integer passto = 0;
        Integer passto = 0;
        Integer total = 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;
        Boolean queryAll = false;
        if ("admin".equalsIgnoreCase(role)) {
            queryAll = true;
        }
        if (!queryAll) {
            boolean isOther = false;
            String complaint = "";
            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+"'";
            List<Map<String, Object>> list = jdbcTemplate.queryForList(sql1);
            if(list.size()==0){
                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;
            }
            for (Map<String, Object> map:list){
                String id = map.get("id")+"";
                String name = map.get("name")+"";
                if("其他".equals(name)){
                    isOther = true;
                }else {
                    complaint += id+",";
                }
                }
            }
            }
            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);
                    //撤销
                    cacel = getCountByStatus(doctor, "-1", role);
                    if (StringUtils.isNotBlank(pcAdmin)) {
                        System.out.println("是pc管理员");
                    } else {
                        total = total - cacel;
                    }
            if(StringUtils.isNotBlank(complaint)){
                complaint = complaint.substring(0,complaint.length()-1);
                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)) {
                    System.out.println("是pc管理员");
                } else {
                } else {
                    complaints = getCountByStatus(doctor, "0", role);
                    recieve = getCountByStatus(doctor, "1", role);
                    deal = getCountByStatus(doctor, "2", role);
                    passto = getCountByPassto(doctor);
                    total = getCountByStatus(doctor, "", role);
                    //撤销
                    cacel = getCountByStatus(doctor, "-1", role);
                    if (StringUtils.isNotBlank(pcAdmin)) {
                        System.out.println("是pc管理员");
                    } else {
                        total = total - cacel;
                    }
                    total = total - cacel;
                }
                }
                //cacel=baseComplaintDao.getCountByStatusAndComplaintId("-1",baseComplaintDoctorDO.getComplaintId());
            } else {
            } else {
                complaints = baseComplaintDao.getCountByStatus("0");
                recieve = baseComplaintDao.getCountByStatus("1");
                deal = baseComplaintDao.getCountByStatus("2");
                cacel = baseComplaintDao.getCountByStatus("-1");
                total = complaints + recieve + deal;
                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)) {
                if (StringUtils.isNotBlank(pcAdmin)) {
                    //是管理员加上撤销的
                    total = +cacel;
                    System.out.println("是pc管理员");
                } else {
                    total = total - cacel;
                }
                }
            }
            //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;
            if (StringUtils.isNotBlank(pcAdmin)) {
                //是管理员加上撤销的
                total = +cacel;
            }
            }
        }
        }
        Map map = new HashMap();
        Map map = new HashMap();
@ -828,85 +810,36 @@ public class BaseComplaintService {
        return count;
        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 complaint, boolean 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 ";
        sql += " left join base_complaint_operate_log g on t.id=g.relation_code where t.is_del='1' ";
        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)) {
        if ("3".equalsIgnoreCase(status)) {
            sql += "  and g.status='3' ";
            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<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;
                    }
                }
        if (isOther) {
            if (StringUtils.isNoneBlank(status)) {
                sql += " and t.status ='" + status + "'";
            }
            }
            //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(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) && "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 + "'"+ "' 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 {
            } 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 + "'  )";
                }
            }
            if (!StringUtils.isNoneBlank(status)) {
                sql += " and t.status !='-1'";
                sql += " and t.id IN (select col.relation_code from base_complaint_operate_log col where col.operate_to = '" + doctor + "'  )";
            }
            }
            //complaint=complaint+","+types;
        }
        }
        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;
        Integer count = 0;
        sql += ")g";
        sql += ")g";

+ 1 - 4
business/base-service/src/main/java/com/yihu/jw/hospital/family/dao/BasePatientMemberDictDao.java

@ -1,17 +1,14 @@
package com.yihu.jw.hospital.family.dao;
package com.yihu.jw.hospital.family.dao;
import com.yihu.jw.entity.hospital.family.BasePatientMemberDictDO;
import com.yihu.jw.entity.hospital.family.BasePatientMemberDictDO;
import com.yihu.jw.entity.hospital.family.WlyyPatientFamilyMemberDO;
import org.checkerframework.checker.units.qual.A;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
import java.util.List;
public interface BasePatientMemberDictDao extends JpaRepository<BasePatientMemberDictDO, String>, JpaSpecificationExecutor<BasePatientMemberDictDO> {
public interface BasePatientMemberDictDao extends JpaRepository<BasePatientMemberDictDO, String>, JpaSpecificationExecutor<BasePatientMemberDictDO> {
    @Query("from BasePatientMemberDictDO t where t.isDel = 1")
    @Query(value = "select * from base_patient_member_dict t where t.is_del = '1' order by is_sort ",nativeQuery = true)
    List<BasePatientMemberDictDO> findDictAll();
    List<BasePatientMemberDictDO> findDictAll();
    @Query("from BasePatientMemberDictDO t where t.relationName = ?1 and t.isDel = 1")
    @Query("from BasePatientMemberDictDO t where t.relationName = ?1 and t.isDel = 1")
    BasePatientMemberDictDO findByRelationName(String illness);
    BasePatientMemberDictDO findByRelationName(String illness);

+ 2 - 2
business/base-service/src/main/java/com/yihu/jw/hospital/integrate/service/BaseHospitalActivityService.java

@ -168,8 +168,8 @@ public class BaseHospitalActivityService extends BaseJpaService<BaseHospitalActi
     * 查询活动列表
     * 查询活动列表
     */
     */
    public MixEnvelop selectByCondition(String title, Integer page, Integer size,Integer flag,Integer status,String startTime,String endTime,String user,String userId){
    public MixEnvelop selectByCondition(String title, Integer page, Integer size,Integer flag,Integer status,String startTime,String endTime,String user,String userId){
//        String orderBy = "  order by sort asc,create_time desc  ";
        String orderBy = "  order by create_time desc  ";
        String orderBy = "  order by sort asc,create_time desc  ";
//        String orderBy = "  order by create_time desc  ";
        String condition = " ";
        String condition = " ";
        String sql = "SELECT\n" +
        String sql = "SELECT\n" +
                "\tid,\n" +
                "\tid,\n" +

+ 4 - 1
business/base-service/src/main/java/com/yihu/jw/hospital/integrate/service/BaseHospitalGoodsService.java

@ -204,7 +204,7 @@ public class BaseHospitalGoodsService extends BaseJpaService<BaseHospitalGoodsDO
    /**
    /**
     * 查询商品兑换记录
     * 查询商品兑换记录
     */
     */
    public MixEnvelop selectGoodsExchageByCondition(String name,String user,String startTime,String endTime,Integer page, Integer size){
    public MixEnvelop selectGoodsExchageByCondition(String name,String user,String type,String startTime,String endTime,Integer page, Integer size){
        String orderBy = "  order by create_time desc  ";
        String orderBy = "  order by create_time desc  ";
        String condition = " ";
        String condition = " ";
        String sql = "SELECT\n" +
        String sql = "SELECT\n" +
@ -231,6 +231,9 @@ public class BaseHospitalGoodsService extends BaseJpaService<BaseHospitalGoodsDO
        if (StringUtils.isNoneBlank(user)){
        if (StringUtils.isNoneBlank(user)){
            condition +=" and user = '"+user+"' ";
            condition +=" and user = '"+user+"' ";
        }
        }
        if (StringUtils.isNoneBlank(type)){
            condition +=" and type = '"+type+"' ";
        }
        if (StringUtils.isNoneBlank(startTime)){
        if (StringUtils.isNoneBlank(startTime)){
            condition +=" and create_time >= '"+startTime+"' ";
            condition +=" and create_time >= '"+startTime+"' ";
        }
        }

+ 6 - 5
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/DsyyPrescriptionService.java

@ -14,7 +14,6 @@ import com.yihu.jw.entity.hospital.healthCare.YlzMedicalRelationDO;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.hospital.prescription.*;
import com.yihu.jw.entity.hospital.prescription.*;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.hospital.healthCare.YlzMedicailIcdDao;
import com.yihu.jw.hospital.healthCare.YlzMedicailIcdDao;
@ -33,7 +32,6 @@ import com.yihu.jw.restmodel.hospital.prescription.WlyyOutpatientVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionDiagnosisVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionDiagnosisVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionInfoVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionInfoVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.entity.ServiceException;
import com.yihu.jw.util.entity.ServiceException;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.util.http.HttpClientUtil;
@ -315,7 +313,8 @@ public class DsyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
            rs.add(jsonObject);
            rs.add(jsonObject);
            return rs;
            return rs;
        }
        }
        deleteCard(patient);
//        deleteCard(patient);
        jdbcTemplate.update("DELETE from patient_medicare_card WHERE patient_code = '"+patient+"'");
        JSONArray array = dsyyEntranceService.findCardNo(patientDO.getIdcard());
        JSONArray array = dsyyEntranceService.findCardNo(patientDO.getIdcard());
        for (int i=0;i<array.size();i++){
        for (int i=0;i<array.size();i++){
            JSONObject object = array.getJSONObject(i);
            JSONObject object = array.getJSONObject(i);
@ -743,14 +742,16 @@ public class DsyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
        JSONObject rs = JSON.parseObject(content);
        JSONObject rs = JSON.parseObject(content);
        Integer status = rs.getInteger("status");
        Integer status = rs.getInteger("status");
        if (status==200){
        if (status==200){
            if(!rs.getString("obj").contains("00")){
            JSONObject obj = rs.getJSONObject("obj");
            if("00".equals(obj.getString("retCode"))){
                object = obj;
            }else {
                throw new ServiceException(rs.getString("obj"));
                throw new ServiceException(rs.getString("obj"));
            }
            }
        }
        }
        return object;
        return object;
    }
    }
    /**
    /**
     *  查询住院病人日清单
     *  查询住院病人日清单
     *
     *

+ 97 - 4
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -1659,13 +1659,17 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @param orgCode
     * @param orgCode
     * @return
     * @return
     */
     */
    public List<DictHospitalDeptVO> findInDeptByHospital(String orgCode, String dept, String deptType) {
        List<DictHospitalDeptDO> list;
    public List<DictHospitalDeptVO> findInDeptByHospital(String orgCode, String dept, String deptType,String consultDeptFlag) {
        String sql = "select * from dict_hospital_dept where 1=1 ";
        if (StringUtils.isNotBlank(deptType) ) {
        if (StringUtils.isNotBlank(deptType) ) {
            list = dictHospitalDeptDao.findByOrgCodeAndDeptType(orgCode, deptType);
            sql += " and org_code='"+orgCode+"' and dept_type='"+deptType+"' ";
        } else {
        } else {
            list = dictHospitalDeptDao.findByOrgCodeIn(Arrays.asList(orgCode.split(",")));
            sql += " and org_code in ('"+orgCode.replaceAll(",","','")+"') ";
        }
        }
        if (StringUtils.isNotBlank(consultDeptFlag) ) {
            sql += " and consult_dept_flag='"+consultDeptFlag+"' ";
        }
        List<DictHospitalDeptDO> list = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(DictHospitalDeptDO.class));
        List<DictHospitalDeptVO> rs = new ArrayList<>();
        List<DictHospitalDeptVO> rs = new ArrayList<>();
        convertToModels(list, rs, DictHospitalDeptVO.class);
        convertToModels(list, rs, DictHospitalDeptVO.class);
        if (rs != null && rs.size() > 0 && StringUtils.isNotBlank(dept)) {
        if (rs != null && rs.size() > 0 && StringUtils.isNotBlank(dept)) {
@ -4856,6 +4860,80 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        return rs;
        return rs;
    }
    }
    //医生首页统计
    //1、满意度:使用100分制,取值与医生端首页—我的评价功能内“总评分”的取值相同;
    //2、积分:获得的积分总和-已过期的积分-已兑换的积分;
    //3、个人结算:该医生通过图文复诊、视频复诊收取到的诊查费总和 加上药品费用。
    public com.alibaba.fastjson.JSONObject doctorIndexStatis(String doctor){
        com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
        WlyyHospitalSysDictDO dictDO = hospitalSysDictDao.findOneByDictNameAndDictCode("HOSPITAL_INTEGRATE_VALIDITY_DICT","HOSPITAL_INTEGRATE_VALIDITY_DICT");
        com.alibaba.fastjson.JSONArray jsonArray = JSON.parseArray(dictDO.getDictValue());
        //[{"type":0,"flag":0,"dateTime":"2023-07-06T16:00:00.000Z","days":"","description":"<p>1111</p>"},
        //{"type":1,"flag":1,"dateTime":"","days":"2","description":"<p>5555</p>"}]
        int flag = 0;
        String dateTime = "";
        String days = "";
        for (int i=0;i<jsonArray.size();i++){
            com.alibaba.fastjson.JSONObject jsonObject = jsonArray.getJSONObject(i);
            if(jsonObject.getInteger("type")==1){
                flag = jsonObject.getInteger("flag");
                dateTime = jsonObject.getString("dateTime");
                days = jsonObject.getString("days");
            }
        }
        if(StringUtils.isNotBlank(dateTime)){
            dateTime = dateTime.substring(0,19);
            dateTime = dateTime.replaceAll("T"," ");
        }
        //医生获取积分数据
        String integrateSql ="SELECT\n" +
                "\tIFNULL(SUM(integrate), 0) AS \"total\"\n" +
                "FROM\n" +
                "\tbase_hospital_user_integrate\n" +
                "WHERE\n" +
                "\tuser = '"+doctor+"' and status=1 ";
        if(flag==0){
            integrateSql += " and create_time>'"+dateTime+"' ";
        }else {
            integrateSql += " and (integrate_type=2 or (integrate_type=1 and DATEDIFF(NOW(),create_time)<'"+days+"')) ";
        }
        List<Map<String, Object>> rstotal = hibenateUtils.createSQLQuery(integrateSql);
        Double integrateTotal = 0.0;
        if (rstotal != null && rstotal.size() > 0) {
            integrateTotal = Double.parseDouble(rstotal.get(0).get("total").toString());
            integrateTotal = integrateTotal>0?integrateTotal:0;
        }
        json.put("integrateTotal",integrateTotal);
        //查询医生各项评价平均分
        String sqlscore = "SELECT " +
                "AVG(a.score) AS \"score\"," +
                "a.score_type AS \"score_type\" " +
                "FROM base_evaluate a,base_evaluate_score b " +
                "WHERE " +
                "a.relation_code=b.id " +
                "AND b.doctor='" + doctor + "' " +
                "GROUP BY a.score_type ORDER BY  a.score_type ASC ";
        List<Map<String, Object>> listscore = jdbcTemplate.queryForList(sqlscore);
        Double doctorScore = new Double("0");
        if (listscore != null && listscore.size() > 0) {
            for (Map<String, Object> _listscore : listscore) {
                doctorScore += Double.parseDouble(_listscore.get("score").toString());
            }
        }
        doctorScore = doctorScore / 3;
        json.put("doctorScore", String.format("%.2f", doctorScore));
        String sql3 = "SELECT SUM(drug_fee)+SUM(inspect_fee)+SUM(reg_fee) from wlyy_prescription " +
                "where doctor='"+doctor+"' and `status`>30 ";
        Double fee = jdbcTemplate.queryForObject(sql3,Double.class);
        json.put("fee", fee);
        return json;
    }
    public BaseDoctorDO updateDoctorInfo(String id, String img,String background,String expertise,String visitHospital,String visitHospitalName,String visitDept,String visitDeptName,String backgroundId,String name,Integer sex,String learning,String introduce,String photo){
    public BaseDoctorDO updateDoctorInfo(String id, String img,String background,String expertise,String visitHospital,String visitHospitalName,String visitDept,String visitDeptName,String backgroundId,String name,Integer sex,String learning,String introduce,String photo){
        if (StringUtils.isNoneBlank(id)){
        if (StringUtils.isNoneBlank(id)){
            BaseDoctorDO baseDoctorDO = baseDoctorDao.findByIdAndDel(id);
            BaseDoctorDO baseDoctorDO = baseDoctorDao.findByIdAndDel(id);
@ -8605,6 +8683,21 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    }
    }
    //待接诊数量
    public Long getWaitRoomCount(String doctor){
        String sql = "SELECT COUNT(DISTINCT room.id) AS \"total\" " +
                "FROM  " +
                " wlyy_hospital_waiting_room room, " +
                " base_patient patient,\n" +
                " wlyy_outpatient outpatient \n" +
                " WHERE \n" +
                " room.patient_id=patient.id \n" +
                " AND room.outpatient_id=outpatient.id \n" +
                " AND outpatient.pay_status = 1 \n" +
                " AND outpatient.status = 0 AND room.doctor='"+doctor+"' ";
        return jdbcTemplate.queryForObject(sql,Long.class);
    }
    /**
    /**
     * 根据类型获取候诊居民数量
     * 根据类型获取候诊居民数量
     *
     *

+ 8 - 7
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/DsyyEntranceService.java

@ -44,13 +44,15 @@ import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.util.network.HttpResponse;
import com.yihu.jw.util.network.HttpResponse;
import com.yihu.jw.util.network.HttpUtils;
import com.yihu.jw.util.network.HttpUtils;
import com.yihu.jw.utils.WebserviceUtil;
import com.yihu.jw.utils.WebserviceUtil;
import com.yihu.jw.utils.dsyyUtil.*;
import com.yihu.jw.utils.dsyyUtil.SendMessge_ServiceLocator;
import com.yihu.jw.utils.dsyyUtil.ServiceLocator;
import com.yihu.jw.utils.dsyyUtil.WritebackCvalueInterfaceLocator;
import com.yihu.jw.utils.dsyyUtil.ZoesoftHipServiceLocator;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import net.sf.json.xml.XMLSerializer;
import net.sf.json.xml.XMLSerializer;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.httpclient.util.EncodingUtil;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.Logger;
@ -63,11 +65,9 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.annotation.Transactional;
import javax.print.DocFlavor;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Collectors;
@ -792,6 +792,7 @@ public class DsyyEntranceService {
        if (StringUtils.isNoneBlank(ksdm)){
        if (StringUtils.isNoneBlank(ksdm)){
            sql += " and dept ='"+ksdm+"' ";
            sql += " and dept ='"+ksdm+"' ";
        }
        }
        sql +=" order by ADMDATE desc ";
        Map<String,Object> params = new HashedMap();
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
        params.put("sql",sql);
        logger.info("获取就诊记录列表:"+sql);
        logger.info("获取就诊记录列表:"+sql);

+ 2 - 2
business/base-service/src/main/java/com/yihu/jw/hospital/survey/dao/SurveyUserAnswerDao.java

@ -1,11 +1,9 @@
package com.yihu.jw.hospital.survey.dao;
package com.yihu.jw.hospital.survey.dao;
import com.yihu.jw.entity.hospital.survey.WlyySurveyInspLabelInfoDO;
import com.yihu.jw.entity.hospital.survey.WlyySurveyUserAnswerDO;
import com.yihu.jw.entity.hospital.survey.WlyySurveyUserAnswerDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
import java.util.List;
@ -18,6 +16,8 @@ public interface SurveyUserAnswerDao extends JpaRepository<WlyySurveyUserAnswerD
    List<WlyySurveyUserAnswerDO> findBySurverUserId(String surverUserId);
    List<WlyySurveyUserAnswerDO> findBySurverUserId(String surverUserId);
    List<WlyySurveyUserAnswerDO> findBySurverUserCode(String surverUserCode);
    List<WlyySurveyUserAnswerDO> findByTempQuestionCode(String tempQuestionCode);
    List<WlyySurveyUserAnswerDO> findByTempQuestionCode(String tempQuestionCode);
    @Query("From WlyySurveyUserAnswerDO c WHERE c.tempOptionCode = ?1 and c.surveyTempCode = ?2")
    @Query("From WlyySurveyUserAnswerDO c WHERE c.tempOptionCode = ?1 and c.surveyTempCode = ?2")
    List<WlyySurveyUserAnswerDO> findBytempOptionCode(String tempOptionCode,String surveyTempCode);
    List<WlyySurveyUserAnswerDO> findBytempOptionCode(String tempOptionCode,String surveyTempCode);

+ 321 - 288
business/base-service/src/main/java/com/yihu/jw/hospital/survey/service/SurveyService.java

@ -8,6 +8,7 @@ import com.yihu.jw.entity.base.patient.BasePatientBusinessDO;
import com.yihu.jw.entity.hospital.survey.*;
import com.yihu.jw.entity.hospital.survey.*;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.survey.dao.*;
import com.yihu.jw.hospital.survey.dao.*;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.patient.dao.BasePatientBusinessDao;
import com.yihu.jw.patient.dao.BasePatientBusinessDao;
import com.yihu.jw.restmodel.hospital.consult.WlyyHospitalSysDictVO;
import com.yihu.jw.restmodel.hospital.consult.WlyyHospitalSysDictVO;
import com.yihu.jw.restmodel.hospital.survey.*;
import com.yihu.jw.restmodel.hospital.survey.*;
@ -19,7 +20,6 @@ import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.utils.EntityUtils;
import com.yihu.jw.utils.EntityUtils;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.jw.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.annotation.Value;
@ -81,42 +81,45 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
    @Value("${im.im_list_get}")
    @Value("${im.im_list_get}")
    private String im_host;
    private String im_host;
    /**
    /**
     * 查询字典
     * 查询字典
     * 1.surveyLabel;2.surveyScreenLabel
     * 1.surveyLabel;2.surveyScreenLabel
     *
     * @param name
     * @param name
     * @return
     * @return
     */
     */
    public List<WlyyHospitalSysDictVO> findSurveyLabel(String name){
    public List<WlyyHospitalSysDictVO> findSurveyLabel(String name) {
        List<WlyyHospitalSysDictVO> list = new ArrayList<>();
        List<WlyyHospitalSysDictVO> list = new ArrayList<>();
        return convertToModels(sysDictDao.findByDictName(name),list,WlyyHospitalSysDictVO.class);
        return convertToModels(sysDictDao.findByDictName(name), list, WlyyHospitalSysDictVO.class);
    }
    }
    /**
    /**
     * 查询问题
     * 查询问题
     *
     * @param title
     * @param title
     * @param questionType
     * @param questionType
     * @param page
     * @param page
     * @param size
     * @param size
     * @return
     * @return
     */
     */
    public MixEnvelop findSurveyQuestion(String title,String creater, Integer questionType,Integer page,Integer size)throws Exception{
    public MixEnvelop findSurveyQuestion(String title, String creater, Integer questionType, Integer page, Integer size) throws Exception {
        //计算总数
        //计算总数
        String totalSql ="SELECT" +
        String totalSql = "SELECT" +
                " COUNT(1) AS \"total\"" +
                " COUNT(1) AS \"total\"" +
                " FROM" +
                " FROM" +
                " wlyy_survey_question q " +
                " wlyy_survey_question q " +
                " WHERE q.del = '1' ";
                " WHERE q.del = '1' ";
        if(StringUtils.isNotBlank(title)){
            totalSql+=" AND q.title like '%"+title+"%'";
        if (StringUtils.isNotBlank(title)) {
            totalSql += " AND q.title like '%" + title + "%'";
        }
        }
        if(questionType!=null){
            totalSql+=" AND q.question_type ="+questionType;
        if (questionType != null) {
            totalSql += " AND q.question_type =" + questionType;
        }
        }
        if (StringUtils.isNoneBlank(creater)){
            totalSql+=" AND q.creater ='"+creater+"' ";
        if (StringUtils.isNoneBlank(creater)) {
            totalSql += " AND q.creater ='" + creater + "' ";
        }
        }
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
@ -126,7 +129,7 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
        }
        }
        //计算总数
        //计算总数
        String sql ="SELECT " +
        String sql = "SELECT " +
                " q.id AS \"id\", " +
                " q.id AS \"id\", " +
                " q.title AS \"title\", " +
                " q.title AS \"title\", " +
                " q.question_comment AS \"questionComment\", " +
                " q.question_comment AS \"questionComment\", " +
@ -141,41 +144,41 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
                " wlyy_survey_question q " +
                " wlyy_survey_question q " +
                " WHERE q.del = '1' ";
                " WHERE q.del = '1' ";
        if(StringUtils.isNotBlank(title)){
            sql+=" AND q.title like '%"+title+"%'";
        if (StringUtils.isNotBlank(title)) {
            sql += " AND q.title like '%" + title + "%'";
        }
        }
        if(questionType!=null){
            sql+=" AND q.question_type ="+questionType;
        if (questionType != null) {
            sql += " AND q.question_type =" + questionType;
        }
        }
        if (StringUtils.isNoneBlank(creater)){
            sql+=" AND q.creater ='"+creater+"' ";
        if (StringUtils.isNoneBlank(creater)) {
            sql += " AND q.creater ='" + creater + "' ";
        }
        }
        sql += " ORDER BY q.create_time DESC  ";
        sql += " ORDER BY q.create_time DESC  ";
        if ("xm_ykyy_wx".equals(wxId)) {
        if ("xm_ykyy_wx".equals(wxId)) {
            if (!flag){
                sql ="SELECT * FROM\n" +
            if (!flag) {
                sql = "SELECT * FROM\n" +
                        "( SELECT A.*, ROWNUM RN FROM\n" +
                        "( SELECT A.*, ROWNUM RN FROM\n" +
                        "    ("+sql+") A \n" +
                        "    WHERE ROWNUM <= "+page*size+" ) \n" +
                        "       WHERE RN >= "+((page-1)*size+1);
                        "    (" + sql + ") A \n" +
                        "    WHERE ROWNUM <= " + page * size + " ) \n" +
                        "       WHERE RN >= " + ((page - 1) * size + 1);
            }else {
                sql+="LIMIT "+ (page - 1) * size + "," + size + " ";
            } else {
                sql += "LIMIT " + (page - 1) * size + "," + size + " ";
            }
            }
        } else {
        } else {
            sql+="LIMIT "+ (page - 1) * size + "," + size + " ";
            sql += "LIMIT " + (page - 1) * size + "," + size + " ";
        }
        }
        List<WlyySurveyQuestionVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WlyySurveyQuestionVO.class));
        List<WlyySurveyQuestionVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WlyySurveyQuestionVO.class));
        if(list!=null&&list.size()>0){
            for(WlyySurveyQuestionVO sq:list){
                List<WlyySurveyQuestionsOptionDO> optionDOs = surveyQuestionsOptionDao.findByQuestionCodeAndDelOrderBySortAsc(sq.getId(),"1");
                if(optionDOs!=null&&optionDOs.size()>0){
        if (list != null && list.size() > 0) {
            for (WlyySurveyQuestionVO sq : list) {
                List<WlyySurveyQuestionsOptionDO> optionDOs = surveyQuestionsOptionDao.findByQuestionCodeAndDelOrderBySortAsc(sq.getId(), "1");
                if (optionDOs != null && optionDOs.size() > 0) {
                    List<WlyySurveyQuestionsOptionVO> optionVOs = new ArrayList<>();
                    List<WlyySurveyQuestionsOptionVO> optionVOs = new ArrayList<>();
                    sq.setOptionVOs(convertToModels(optionDOs,optionVOs,WlyySurveyQuestionsOptionVO.class));
                    sq.setOptionVOs(convertToModels(optionDOs, optionVOs, WlyySurveyQuestionsOptionVO.class));
                }
                }
            }
            }
        }
        }
@ -185,44 +188,46 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
    /**
    /**
     * 查询问题单条
     * 查询问题单条
     *
     * @param surveyId
     * @param surveyId
     * @return
     * @return
     */
     */
    public WlyySurveyQuestionVO findBySurveyId(String surveyId){
    public WlyySurveyQuestionVO findBySurveyId(String surveyId) {
        WlyySurveyQuestionDO sq = surveyQuestionDao.findById(surveyId).orElse(null);
        WlyySurveyQuestionDO sq = surveyQuestionDao.findById(surveyId).orElse(null);
        WlyySurveyQuestionVO surveyQuestionVO = convertToModel(sq,WlyySurveyQuestionVO.class);
        List<WlyySurveyQuestionsOptionDO> optionDOs = surveyQuestionsOptionDao.findByQuestionCodeAndDelOrderBySortAsc(sq.getId(),"1");
        if(optionDOs!=null&&optionDOs.size()>0){
        WlyySurveyQuestionVO surveyQuestionVO = convertToModel(sq, WlyySurveyQuestionVO.class);
        List<WlyySurveyQuestionsOptionDO> optionDOs = surveyQuestionsOptionDao.findByQuestionCodeAndDelOrderBySortAsc(sq.getId(), "1");
        if (optionDOs != null && optionDOs.size() > 0) {
            List<WlyySurveyQuestionsOptionVO> optionVOs = new ArrayList<>();
            List<WlyySurveyQuestionsOptionVO> optionVOs = new ArrayList<>();
            surveyQuestionVO.setOptionVOs(convertToModels(optionDOs,optionVOs,WlyySurveyQuestionsOptionVO.class));
            surveyQuestionVO.setOptionVOs(convertToModels(optionDOs, optionVOs, WlyySurveyQuestionsOptionVO.class));
        }
        }
        return surveyQuestionVO;
        return surveyQuestionVO;
    }
    }
    /**
    /**
     * 保存问题
     * 保存问题
     *
     * @param sqOptionJson
     * @param sqOptionJson
     * @return
     * @return
     * @throws Exception
     * @throws Exception
     */
     */
    public Boolean saveSurveyQuestion(String sqjsons,String sqOptionJson)throws Exception{
    public Boolean saveSurveyQuestion(String sqjsons, String sqOptionJson) throws Exception {
        //保存问题
        //保存问题
        List<WlyySurveyQuestionDO> surveys = EntityUtils.jsonToList(sqjsons, WlyySurveyQuestionDO.class);
        List<WlyySurveyQuestionDO> surveys = EntityUtils.jsonToList(sqjsons, WlyySurveyQuestionDO.class);
        for (WlyySurveyQuestionDO wlyySurveyQuestionDO:surveys){
        for (WlyySurveyQuestionDO wlyySurveyQuestionDO : surveys) {
            wlyySurveyQuestionDO.setCreateTime(new Date());
            wlyySurveyQuestionDO.setCreateTime(new Date());
            wlyySurveyQuestionDO.setUpdateTime(new Date());
            wlyySurveyQuestionDO.setUpdateTime(new Date());
        }
        }
        surveyQuestionDao.saveAll(surveys);
        surveyQuestionDao.saveAll(surveys);
        if(surveys!=null&&surveys.size()>0){
            for(WlyySurveyQuestionDO sq:surveys){
                List<WlyySurveyQuestionsOptionDO> optionDOs = surveyQuestionsOptionDao.findByQuestionCodeAndDelOrderBySortAsc(sq.getId(),"1");
                if(optionDOs!=null&&optionDOs.size()>0){
        if (surveys != null && surveys.size() > 0) {
            for (WlyySurveyQuestionDO sq : surveys) {
                List<WlyySurveyQuestionsOptionDO> optionDOs = surveyQuestionsOptionDao.findByQuestionCodeAndDelOrderBySortAsc(sq.getId(), "1");
                if (optionDOs != null && optionDOs.size() > 0) {
                    surveyQuestionsOptionDao.deleteAll(optionDOs);
                    surveyQuestionsOptionDao.deleteAll(optionDOs);
                }
                }
                if(StringUtils.isNotBlank(sqOptionJson)){
                if (StringUtils.isNotBlank(sqOptionJson)) {
                    List<WlyySurveyQuestionsOptionDO> options = EntityUtils.jsonToList(sqOptionJson, WlyySurveyQuestionsOptionDO.class);
                    List<WlyySurveyQuestionsOptionDO> options = EntityUtils.jsonToList(sqOptionJson, WlyySurveyQuestionsOptionDO.class);
                    surveyQuestionsOptionDao.saveAll(options);
                    surveyQuestionsOptionDao.saveAll(options);
                }
                }
@ -233,21 +238,22 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
    /**
    /**
     * 单个编辑问题
     * 单个编辑问题
     *
     * @param sqjson
     * @param sqjson
     * @param sqOptionJson
     * @param sqOptionJson
     * @return
     * @return
     * @throws Exception
     * @throws Exception
     */
     */
    public Boolean updataSurveyQuestion(String sqjson,String sqOptionJson) throws Exception{
        WlyySurveyQuestionDO sq = objectMapper.readValue(sqjson,WlyySurveyQuestionDO.class);
    public Boolean updataSurveyQuestion(String sqjson, String sqOptionJson) throws Exception {
        WlyySurveyQuestionDO sq = objectMapper.readValue(sqjson, WlyySurveyQuestionDO.class);
        sq.setUpdateTime(new Date());
        sq.setUpdateTime(new Date());
        surveyQuestionDao.save(sq);
        surveyQuestionDao.save(sq);
        List<WlyySurveyQuestionsOptionDO> optionDOs = surveyQuestionsOptionDao.findByQuestionCodeAndDelOrderBySortAsc(sq.getId(),"1");
        if(optionDOs!=null&&optionDOs.size()>0){
        List<WlyySurveyQuestionsOptionDO> optionDOs = surveyQuestionsOptionDao.findByQuestionCodeAndDelOrderBySortAsc(sq.getId(), "1");
        if (optionDOs != null && optionDOs.size() > 0) {
            surveyQuestionsOptionDao.deleteAll(optionDOs);
            surveyQuestionsOptionDao.deleteAll(optionDOs);
        }
        }
        if(StringUtils.isNotBlank(sqOptionJson)){
        if (StringUtils.isNotBlank(sqOptionJson)) {
            List<WlyySurveyQuestionsOptionDO> options = EntityUtils.jsonToList(sqOptionJson, WlyySurveyQuestionsOptionDO.class);
            List<WlyySurveyQuestionsOptionDO> options = EntityUtils.jsonToList(sqOptionJson, WlyySurveyQuestionsOptionDO.class);
            surveyQuestionsOptionDao.saveAll(options);
            surveyQuestionsOptionDao.saveAll(options);
        }
        }
@ -256,20 +262,21 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
    /**
    /**
     * 删除问题
     * 删除问题
     *
     * @param ids
     * @param ids
     * @return
     * @return
     */
     */
    public Boolean delSurveyQuestion(String ids){
    public Boolean delSurveyQuestion(String ids) {
        String sids[] =ids.split(",");
        if(sids!=null&&ids.length()>0){
            for(String id:sids){
        String sids[] = ids.split(",");
        if (sids != null && ids.length() > 0) {
            for (String id : sids) {
                WlyySurveyQuestionDO del = surveyQuestionDao.findById(id).orElse(null);
                WlyySurveyQuestionDO del = surveyQuestionDao.findById(id).orElse(null);
                if(del!=null){
                if (del != null) {
                    surveyQuestionDao.delete(del);
                    surveyQuestionDao.delete(del);
                }
                }
                List<WlyySurveyQuestionsOptionDO> optionDOs = surveyQuestionsOptionDao.findByQuestionCodeAndDelOrderBySortAsc(id,"1");
                if(optionDOs!=null&&optionDOs.size()>0){
                List<WlyySurveyQuestionsOptionDO> optionDOs = surveyQuestionsOptionDao.findByQuestionCodeAndDelOrderBySortAsc(id, "1");
                if (optionDOs != null && optionDOs.size() > 0) {
                    surveyQuestionsOptionDao.deleteAll(optionDOs);
                    surveyQuestionsOptionDao.deleteAll(optionDOs);
                }
                }
            }
            }
@ -280,32 +287,33 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
    //=====================问卷模板=====================================
    //=====================问卷模板=====================================
    /**
    /**
     *  查询模板列表
     * 查询模板列表
     *
     * @param title
     * @param title
     * @param label
     * @param label
     * @param page
     * @param page
     * @param size
     * @param size
     * @return
     * @return
     */
     */
    public MixEnvelop findSurveyTemplate(String title,String creater,String label,Integer page,Integer size){
    public MixEnvelop findSurveyTemplate(String title, String creater, String label, Integer page, Integer size) {
        String totalSql ="SELECT " +
        String totalSql = "SELECT " +
                " COUNT(1) AS \"total\"" +
                " COUNT(1) AS \"total\"" +
                " FROM " +
                " FROM " +
                " wlyy_survey_template t ";
                " wlyy_survey_template t ";
        if(StringUtils.isNotBlank(label)){
            totalSql+=" JOIN wlyy_survey_label_info i ON t.id = i.survey_temp_code";
        if (StringUtils.isNotBlank(label)) {
            totalSql += " JOIN wlyy_survey_label_info i ON t.id = i.survey_temp_code";
        }
        }
        totalSql += " WHERE " +
        totalSql += " WHERE " +
                    " t.del = '1'";
        if(StringUtils.isNotBlank(title)){
            totalSql += " AND t.title like '%"+title+"%' ";
                " t.del = '1'";
        if (StringUtils.isNotBlank(title)) {
            totalSql += " AND t.title like '%" + title + "%' ";
        }
        }
        if(StringUtils.isNotBlank(label)){
            totalSql += " AND i.label_code ='"+label+"'";
        if (StringUtils.isNotBlank(label)) {
            totalSql += " AND i.label_code ='" + label + "'";
        }
        }
        if (StringUtils.isNoneBlank(creater)){
            totalSql +=" AND  t.creater_code = '"+creater+"' ";
        if (StringUtils.isNoneBlank(creater)) {
            totalSql += " AND  t.creater_code = '" + creater + "' ";
        }
        }
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
@ -327,67 +335,67 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
                " t.update_time AS \"updateTime\"" +
                " t.update_time AS \"updateTime\"" +
                " FROM " +
                " FROM " +
                " wlyy_survey_template t ";
                " wlyy_survey_template t ";
        if(StringUtils.isNotBlank(label)){
        if (StringUtils.isNotBlank(label)) {
            sql += " JOIN wlyy_survey_label_info i ON t.id = i.survey_temp_code";
            sql += " JOIN wlyy_survey_label_info i ON t.id = i.survey_temp_code";
        }
        }
            sql += " WHERE " +
                   " t.del = '1'";
        if(StringUtils.isNotBlank(title)){
            sql += " AND t.title like '%"+title+"%' ";
        sql += " WHERE " +
                " t.del = '1'";
        if (StringUtils.isNotBlank(title)) {
            sql += " AND t.title like '%" + title + "%' ";
        }
        }
        if(StringUtils.isNotBlank(label)){
            sql += " AND  i.label_code ='"+label+"'";
        if (StringUtils.isNotBlank(label)) {
            sql += " AND  i.label_code ='" + label + "'";
        }
        }
        if (StringUtils.isNoneBlank(creater)){
            sql +=" AND  t.creater_code = '"+creater+"' ";
        if (StringUtils.isNoneBlank(creater)) {
            sql += " AND  t.creater_code = '" + creater + "' ";
        }
        }
        sql += " ORDER BY t.create_time DESC  ";
        sql += " ORDER BY t.create_time DESC  ";
        if ("xm_ykyy_wx".equals(wxId)) {
        if ("xm_ykyy_wx".equals(wxId)) {
            if (!flag){
                sql ="SELECT * FROM\n" +
            if (!flag) {
                sql = "SELECT * FROM\n" +
                        "( SELECT A.*, ROWNUM RN FROM\n" +
                        "( SELECT A.*, ROWNUM RN FROM\n" +
                        "    ("+sql+") A \n" +
                        "    WHERE ROWNUM <= "+page*size+" ) \n" +
                        "       WHERE RN >= "+((page-1)*size+1);
                        "    (" + sql + ") A \n" +
                        "    WHERE ROWNUM <= " + page * size + " ) \n" +
                        "       WHERE RN >= " + ((page - 1) * size + 1);
                System.out.println(sql);
                System.out.println(sql);
            }else {
                sql+="LIMIT "+ (page - 1) * size + "," + size + " ";
            } else {
                sql += "LIMIT " + (page - 1) * size + "," + size + " ";
            }
            }
        } else {
        } else {
            sql+="LIMIT "+ (page - 1) * size + "," + size + " ";
            sql += "LIMIT " + (page - 1) * size + "," + size + " ";
        }
        }
        List<WlyySurveyTemplateVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WlyySurveyTemplateVO.class));
        List<WlyySurveyTemplateVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WlyySurveyTemplateVO.class));
        if(list!=null&&list.size()>0){
        if (list != null && list.size() > 0) {
            //设置标签
            //设置标签
            for(WlyySurveyTemplateVO templateVO : list){
            for (WlyySurveyTemplateVO templateVO : list) {
                String templateCode = templateVO.getId();
                String templateCode = templateVO.getId();
                String sqlUsed = "select t.used as \"used\" from wlyy_knowledge_article_user t where t.relation_code = '"+templateCode +"'";
                if(StringUtils.isNotEmpty(creater)){
                    sqlUsed += " and t.user_code = '"+creater+"'";
                String sqlUsed = "select t.used as \"used\" from wlyy_knowledge_article_user t where t.relation_code = '" + templateCode + "'";
                if (StringUtils.isNotEmpty(creater)) {
                    sqlUsed += " and t.user_code = '" + creater + "'";
                }
                }
                List<Map<String,Object>> listUsed = hibenateUtils.createSQLQuery(sqlUsed);
                for (Map<String,Object> map:listUsed){
                List<Map<String, Object>> listUsed = hibenateUtils.createSQLQuery(sqlUsed);
                for (Map<String, Object> map : listUsed) {
                    Integer in = null;
                    Integer in = null;
                    if (listUsed.size()>0){
                        if (null!=listUsed.get(0)){
                    if (listUsed.size() > 0) {
                        if (null != listUsed.get(0)) {
                            Object object = map.get("used");
                            Object object = map.get("used");
                            if(object!=null){
                                if(object instanceof Integer){
                                    in = (Integer)object;
                                }else if(object instanceof String){
                                    in = Integer.parseInt((String)object);
                                }else if(object instanceof Double){
                                    in = (int)((double)object);
                                }else if(object instanceof Float){
                                    in = (int)((float)object);
                                }else if(object instanceof BigDecimal){
                                    in = ((BigDecimal)object).intValue();
                                }else if(object instanceof Long){
                                    in = ((Long)object).intValue();
                            if (object != null) {
                                if (object instanceof Integer) {
                                    in = (Integer) object;
                                } else if (object instanceof String) {
                                    in = Integer.parseInt((String) object);
                                } else if (object instanceof Double) {
                                    in = (int) ((double) object);
                                } else if (object instanceof Float) {
                                    in = (int) ((float) object);
                                } else if (object instanceof BigDecimal) {
                                    in = ((BigDecimal) object).intValue();
                                } else if (object instanceof Long) {
                                    in = ((Long) object).intValue();
                                }
                                }
                            }
                            }
                        }
                        }
@ -396,7 +404,6 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
                }
                }
                templateVO.setLabels(findSurveyTemplateLabel(templateVO.getId()));
                templateVO.setLabels(findSurveyTemplateLabel(templateVO.getId()));
            }
            }
        }
        }
@ -406,38 +413,39 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
    /**
    /**
     * 获取问卷模板详情
     * 获取问卷模板详情
     *
     * @param tempId
     * @param tempId
     * @return
     * @return
     */
     */
    public WlyySurveyTemplateVO findSurveyTemplateById(String tempId,String userCode ){
    public WlyySurveyTemplateVO findSurveyTemplateById(String tempId, String userCode) {
        WlyySurveyTemplateDO templateDO = surveyTemplateDao.findById(tempId).orElse(null);
        WlyySurveyTemplateDO templateDO = surveyTemplateDao.findById(tempId).orElse(null);
        WlyySurveyTemplateVO templateVO = convertToModel(templateDO,WlyySurveyTemplateVO.class);
        WlyySurveyTemplateVO templateVO = convertToModel(templateDO, WlyySurveyTemplateVO.class);
        templateVO.setLabels(findSurveyTemplateLabel(tempId));
        templateVO.setLabels(findSurveyTemplateLabel(tempId));
        templateVO.setInsplabels(findSurveyInspTemplateLabel(tempId));
        templateVO.setInsplabels(findSurveyInspTemplateLabel(tempId));
        String templateCode = templateDO.getId();
        String templateCode = templateDO.getId();
        String sqlUsed = "select t.used as \"used\" from wlyy_knowledge_article_user t where t.relation_code = '"+templateCode +"'";
        if(StringUtils.isNotEmpty(userCode)){
            sqlUsed += " and t.user_code = '"+userCode+"'";
        String sqlUsed = "select t.used as \"used\" from wlyy_knowledge_article_user t where t.relation_code = '" + templateCode + "'";
        if (StringUtils.isNotEmpty(userCode)) {
            sqlUsed += " and t.user_code = '" + userCode + "'";
            System.out.println(sqlUsed);
            System.out.println(sqlUsed);
            List<Map<String,Object>> listUsed = hibenateUtils.createSQLQuery(sqlUsed);
            if (listUsed.size()>0){
                String used = null!=listUsed.get(0).get("used")?listUsed.get(0).get("used").toString():"0";
            List<Map<String, Object>> listUsed = hibenateUtils.createSQLQuery(sqlUsed);
            if (listUsed.size() > 0) {
                String used = null != listUsed.get(0).get("used") ? listUsed.get(0).get("used").toString() : "0";
                templateVO.setUsed(Integer.valueOf(used));
                templateVO.setUsed(Integer.valueOf(used));
            }
            }
        }
        }
        List<WlyySurveyTemplateQuestionDO> tqDOs = surveyTemplateQuestionDao.findByTemplateCodeAndDelOrderBySortAsc(tempId,"1");
        if(tqDOs!=null&&tqDOs.size()>0){
        List<WlyySurveyTemplateQuestionDO> tqDOs = surveyTemplateQuestionDao.findByTemplateCodeAndDelOrderBySortAsc(tempId, "1");
        if (tqDOs != null && tqDOs.size() > 0) {
            //设置问题
            //设置问题
            List<WlyySurveyTemplateQuestionVO> tqVOs = new ArrayList<>();
            List<WlyySurveyTemplateQuestionVO> tqVOs = new ArrayList<>();
            convertToModels(tqDOs,tqVOs,WlyySurveyTemplateQuestionVO.class);
            convertToModels(tqDOs, tqVOs, WlyySurveyTemplateQuestionVO.class);
            //设置选项
            //设置选项
            for(WlyySurveyTemplateQuestionVO tq:tqVOs){
                List<WlyySurveyTemplateOptionDO> optionDOs  = surveyTemplateOptionDao.findByQuestionCodeAndDelOrderBySortAsc(tq.getCode(),tq.getTemplateCode(),"1");
            for (WlyySurveyTemplateQuestionVO tq : tqVOs) {
                List<WlyySurveyTemplateOptionDO> optionDOs = surveyTemplateOptionDao.findByQuestionCodeAndDelOrderBySortAsc(tq.getCode(), tq.getTemplateCode(), "1");
                List<WlyySurveyTemplateOptionVO> optionVOs = new ArrayList<>();
                List<WlyySurveyTemplateOptionVO> optionVOs = new ArrayList<>();
                convertToModels(optionDOs,optionVOs,WlyySurveyTemplateOptionVO.class);
                for (WlyySurveyTemplateOptionVO optionVO:optionVOs){
                convertToModels(optionDOs, optionVOs, WlyySurveyTemplateOptionVO.class);
                for (WlyySurveyTemplateOptionVO optionVO : optionVOs) {
                    optionVO.setId(optionVO.getCode());
                    optionVO.setId(optionVO.getCode());
                }
                }
                tq.setOptionVOs(optionVOs);
                tq.setOptionVOs(optionVOs);
@ -448,32 +456,33 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
        return templateVO;
        return templateVO;
    }
    }
    public List<WlyySurveyLabelInfoVO> findSurveyTemplateLabel(String tempId){
    public List<WlyySurveyLabelInfoVO> findSurveyTemplateLabel(String tempId) {
        List<WlyySurveyLabelInfoDO> list = surveyLabelInfoDao.findBySurveyTempCode(tempId);
        List<WlyySurveyLabelInfoDO> list = surveyLabelInfoDao.findBySurveyTempCode(tempId);
        List<WlyySurveyLabelInfoVO> rs = new ArrayList<>();
        List<WlyySurveyLabelInfoVO> rs = new ArrayList<>();
        return convertToModels(list,rs,WlyySurveyLabelInfoVO.class);
        return convertToModels(list, rs, WlyySurveyLabelInfoVO.class);
    }
    }
    public List<WlyySurveyInspLabelInfoVO> findSurveyInspTemplateLabel(String tempId){
    public List<WlyySurveyInspLabelInfoVO> findSurveyInspTemplateLabel(String tempId) {
        List<WlyySurveyInspLabelInfoDO> list = surveyInspLabelInfoDao.findBySurveyTempCode(tempId);
        List<WlyySurveyInspLabelInfoDO> list = surveyInspLabelInfoDao.findBySurveyTempCode(tempId);
        List<WlyySurveyInspLabelInfoVO> rs = new ArrayList<>();
        List<WlyySurveyInspLabelInfoVO> rs = new ArrayList<>();
        return convertToModels(list,rs,WlyySurveyInspLabelInfoVO.class);
        return convertToModels(list, rs, WlyySurveyInspLabelInfoVO.class);
    }
    }
    /**
    /**
     * 保存,更新模板
     * 保存,更新模板
     *
     * @param tempJson
     * @param tempJson
     * @param tempQJson
     * @param tempQJson
     * @param tempOpJson
     * @param tempOpJson
     * @return
     * @return
     * @throws Exception
     * @throws Exception
     */
     */
    public Boolean saveSurveyTemplate(String tempJson,String tempQJson,String tempOpJson,String labelJson,String labelInspJson)throws Exception{
    public Boolean saveSurveyTemplate(String tempJson, String tempQJson, String tempOpJson, String labelJson, String labelInspJson) throws Exception {
        WlyySurveyTemplateDO temp = objectMapper.readValue(tempJson,WlyySurveyTemplateDO.class);
        if (StringUtils.isNotEmpty(temp.getId())){
        WlyySurveyTemplateDO temp = objectMapper.readValue(tempJson, WlyySurveyTemplateDO.class);
        if (StringUtils.isNotEmpty(temp.getId())) {
            WlyySurveyTemplateDO templateDO = surveyTemplateDao.findById(temp.getId()).orElse(null);
            WlyySurveyTemplateDO templateDO = surveyTemplateDao.findById(temp.getId()).orElse(null);
            if(null!=templateDO){
            if (null != templateDO) {
                temp.setCreater(templateDO.getCreater());
                temp.setCreater(templateDO.getCreater());
                temp.setCreaterCode(templateDO.getCreaterCode());
                temp.setCreaterCode(templateDO.getCreaterCode());
                temp.setUpdateTime(new Date());
                temp.setUpdateTime(new Date());
@ -483,14 +492,14 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
        temp.setUpdateTime(new Date());
        temp.setUpdateTime(new Date());
        temp = surveyTemplateDao.save(temp);
        temp = surveyTemplateDao.save(temp);
        //删除原有问题
        //删除原有问题
        List<WlyySurveyTemplateQuestionDO> questionDODels = surveyTemplateQuestionDao.findByTemplateCodeAndDelOrderBySortAsc(temp.getId(),"1");
        if(questionDODels!=null&&questionDODels.size()>0){
        List<WlyySurveyTemplateQuestionDO> questionDODels = surveyTemplateQuestionDao.findByTemplateCodeAndDelOrderBySortAsc(temp.getId(), "1");
        if (questionDODels != null && questionDODels.size() > 0) {
            surveyTemplateQuestionDao.deleteAll(questionDODels);
            surveyTemplateQuestionDao.deleteAll(questionDODels);
        }
        }
        //新增问题
        //新增问题
        if(StringUtils.isNotBlank(tempQJson)){
        if (StringUtils.isNotBlank(tempQJson)) {
            List<WlyySurveyTemplateQuestionDO> questions = EntityUtils.jsonToList(tempQJson, WlyySurveyTemplateQuestionDO.class);
            List<WlyySurveyTemplateQuestionDO> questions = EntityUtils.jsonToList(tempQJson, WlyySurveyTemplateQuestionDO.class);
            for (WlyySurveyTemplateQuestionDO wlyySurveyTemplateQuestionDO:questions){
            for (WlyySurveyTemplateQuestionDO wlyySurveyTemplateQuestionDO : questions) {
                wlyySurveyTemplateQuestionDO.setTemplateCode(temp.getId());
                wlyySurveyTemplateQuestionDO.setTemplateCode(temp.getId());
                wlyySurveyTemplateQuestionDO.setCode(wlyySurveyTemplateQuestionDO.getId());
                wlyySurveyTemplateQuestionDO.setCode(wlyySurveyTemplateQuestionDO.getId());
                wlyySurveyTemplateQuestionDO.setId(UUID.randomUUID().toString());
                wlyySurveyTemplateQuestionDO.setId(UUID.randomUUID().toString());
@ -502,18 +511,18 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
        }
        }
        //删除原有问题选项
        //删除原有问题选项
        List<WlyySurveyTemplateOptionDO> optionDODels = surveyTemplateOptionDao.findByTemplateCodeAndDelOrderBySortAsc(temp.getId(),"1");
        if(optionDODels!=null&&optionDODels.size()>0){
        List<WlyySurveyTemplateOptionDO> optionDODels = surveyTemplateOptionDao.findByTemplateCodeAndDelOrderBySortAsc(temp.getId(), "1");
        if (optionDODels != null && optionDODels.size() > 0) {
            surveyTemplateOptionDao.deleteAll(optionDODels);
            surveyTemplateOptionDao.deleteAll(optionDODels);
        }
        }
        //保存新问题选项
        //保存新问题选项
        if(StringUtils.isNotBlank(tempOpJson)){
        if (StringUtils.isNotBlank(tempOpJson)) {
            List<WlyySurveyTemplateOptionDO> options = EntityUtils.jsonToList(tempOpJson, WlyySurveyTemplateOptionDO.class);
            List<WlyySurveyTemplateOptionDO> options = EntityUtils.jsonToList(tempOpJson, WlyySurveyTemplateOptionDO.class);
            for (WlyySurveyTemplateOptionDO wlyySurveyTemplateOptionDO:options){
            for (WlyySurveyTemplateOptionDO wlyySurveyTemplateOptionDO : options) {
                wlyySurveyTemplateOptionDO.setTemplateCode(temp.getId());
                wlyySurveyTemplateOptionDO.setTemplateCode(temp.getId());
                wlyySurveyTemplateOptionDO.setCode(wlyySurveyTemplateOptionDO.getId());
                wlyySurveyTemplateOptionDO.setCode(wlyySurveyTemplateOptionDO.getId());
                wlyySurveyTemplateOptionDO.setId(UUID.randomUUID()+"");
                wlyySurveyTemplateOptionDO.setId(UUID.randomUUID() + "");
            }
            }
            surveyTemplateOptionDao.saveAll(options);
            surveyTemplateOptionDao.saveAll(options);
@ -521,21 +530,21 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
        //保存标签
        //保存标签
        List<WlyySurveyLabelInfoDO> labelDels = surveyLabelInfoDao.findBySurveyTempCode(temp.getId());
        List<WlyySurveyLabelInfoDO> labelDels = surveyLabelInfoDao.findBySurveyTempCode(temp.getId());
        if(labelDels!=null&&labelDels.size()>0){
        if (labelDels != null && labelDels.size() > 0) {
            surveyLabelInfoDao.deleteAll(labelDels);
            surveyLabelInfoDao.deleteAll(labelDels);
        }
        }
        if(StringUtils.isNotBlank(labelJson)){
        if (StringUtils.isNotBlank(labelJson)) {
            List<WlyySurveyLabelInfoDO> labels = EntityUtils.jsonToList(labelJson, WlyySurveyLabelInfoDO.class);
            List<WlyySurveyLabelInfoDO> labels = EntityUtils.jsonToList(labelJson, WlyySurveyLabelInfoDO.class);
            surveyLabelInfoDao.saveAll(labels);
            surveyLabelInfoDao.saveAll(labels);
        }
        }
        //删除检查标签
        //删除检查标签
        List<WlyySurveyInspLabelInfoDO> labelInspDels = surveyInspLabelInfoDao.findBySurveyTempCode(temp.getId());
        List<WlyySurveyInspLabelInfoDO> labelInspDels = surveyInspLabelInfoDao.findBySurveyTempCode(temp.getId());
        if(labelDels!=null&&labelDels.size()>0){
        if (labelDels != null && labelDels.size() > 0) {
            surveyInspLabelInfoDao.deleteAll(labelInspDels);
            surveyInspLabelInfoDao.deleteAll(labelInspDels);
        }
        }
        //保存检查标签
        //保存检查标签
        if(StringUtils.isNotBlank(labelInspJson)){
        if (StringUtils.isNotBlank(labelInspJson)) {
            List<WlyySurveyInspLabelInfoDO> labels = EntityUtils.jsonToList(labelInspJson, WlyySurveyInspLabelInfoDO.class);
            List<WlyySurveyInspLabelInfoDO> labels = EntityUtils.jsonToList(labelInspJson, WlyySurveyInspLabelInfoDO.class);
            surveyInspLabelInfoDao.saveAll(labels);
            surveyInspLabelInfoDao.saveAll(labels);
        }
        }
@ -545,20 +554,21 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
    /**
    /**
     * 删除
     * 删除
     *
     * @param tempId
     * @param tempId
     * @return
     * @return
     */
     */
    public Boolean delSurveyTemplate(String tempId){
    public Boolean delSurveyTemplate(String tempId) {
        WlyySurveyTemplateDO temp = surveyTemplateDao.getOne(tempId);
        WlyySurveyTemplateDO temp = surveyTemplateDao.getOne(tempId);
        if(temp!=null){
        if (temp != null) {
            //删除原有问题
            //删除原有问题
            List<WlyySurveyTemplateQuestionDO> questionDODels = surveyTemplateQuestionDao.findByTemplateCodeAndDelOrderBySortAsc(temp.getId(),"1");
            if(questionDODels!=null&&questionDODels.size()>0){
            List<WlyySurveyTemplateQuestionDO> questionDODels = surveyTemplateQuestionDao.findByTemplateCodeAndDelOrderBySortAsc(temp.getId(), "1");
            if (questionDODels != null && questionDODels.size() > 0) {
                surveyTemplateQuestionDao.deleteAll(questionDODels);
                surveyTemplateQuestionDao.deleteAll(questionDODels);
            }
            }
            //删除原有问题选项
            //删除原有问题选项
            List<WlyySurveyTemplateOptionDO> optionDODels = surveyTemplateOptionDao.findByTemplateCodeAndDelOrderBySortAsc(temp.getId(),"1");
            if(optionDODels!=null&&optionDODels.size()>0){
            List<WlyySurveyTemplateOptionDO> optionDODels = surveyTemplateOptionDao.findByTemplateCodeAndDelOrderBySortAsc(temp.getId(), "1");
            if (optionDODels != null && optionDODels.size() > 0) {
                surveyTemplateOptionDao.deleteAll(optionDODels);
                surveyTemplateOptionDao.deleteAll(optionDODels);
            }
            }
            surveyTemplateDao.delete(temp);
            surveyTemplateDao.delete(temp);
@ -570,22 +580,23 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
    /**
    /**
     * 保存问卷科室关系
     * 保存问卷科室关系
     *
     * @param tempId
     * @param tempId
     * @param sdJsons
     * @param sdJsons
     * @return
     * @return
     * @throws Exception
     * @throws Exception
     */
     */
    public Boolean saveSurveyDept(String tempId,String sdJsons)throws Exception{
    public Boolean saveSurveyDept(String tempId, String sdJsons) throws Exception {
        //删除之前关系
        //删除之前关系
        List<WlyySurveyDeptDO> dels = surveyDeptDao.findBySurveyTempCode(tempId);
        List<WlyySurveyDeptDO> dels = surveyDeptDao.findBySurveyTempCode(tempId);
        if(dels!=null&&dels.size()>0){
        if (dels != null && dels.size() > 0) {
            surveyDeptDao.deleteAll(dels);
            surveyDeptDao.deleteAll(dels);
        }
        }
        if(StringUtils.isNotBlank(sdJsons)){
            List<WlyySurveyDeptDO> list = EntityUtils.jsonToList(sdJsons,WlyySurveyDeptDO.class);
            if(list!=null&&list.size()>0){
        if (StringUtils.isNotBlank(sdJsons)) {
            List<WlyySurveyDeptDO> list = EntityUtils.jsonToList(sdJsons, WlyySurveyDeptDO.class);
            if (list != null && list.size() > 0) {
                surveyDeptDao.saveAll(list);
                surveyDeptDao.saveAll(list);
            }
            }
        }
        }
@ -594,22 +605,23 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
    /**
    /**
     * 保存部门问卷关系
     * 保存部门问卷关系
     *
     * @param dept
     * @param dept
     * @param sdJsons
     * @param sdJsons
     * @return
     * @return
     * @throws Exception
     * @throws Exception
     */
     */
    public Boolean saveDeptSurvey(String dept,String sdJsons)throws Exception{
    public Boolean saveDeptSurvey(String dept, String sdJsons) throws Exception {
        //删除之前关系
        //删除之前关系
        List<WlyySurveyDeptDO> dels = surveyDeptDao.findByDept(dept);
        List<WlyySurveyDeptDO> dels = surveyDeptDao.findByDept(dept);
        if(dels!=null&&dels.size()>0){
        if (dels != null && dels.size() > 0) {
            surveyDeptDao.deleteAll(dels);
            surveyDeptDao.deleteAll(dels);
        }
        }
        if(StringUtils.isNotBlank(sdJsons)){
            List<WlyySurveyDeptDO> list = EntityUtils.jsonToList(sdJsons,WlyySurveyDeptDO.class);
            if(list!=null&&list.size()>0){
        if (StringUtils.isNotBlank(sdJsons)) {
            List<WlyySurveyDeptDO> list = EntityUtils.jsonToList(sdJsons, WlyySurveyDeptDO.class);
            if (list != null && list.size() > 0) {
                surveyDeptDao.saveAll(list);
                surveyDeptDao.saveAll(list);
            }
            }
        }
        }
@ -618,10 +630,11 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
    /**
    /**
     * 查询科室下问卷列表
     * 查询科室下问卷列表
     *
     * @param dept
     * @param dept
     * @return
     * @return
     */
     */
    public List<Map<String,Object>> findSurveyByDept(String dept){
    public List<Map<String, Object>> findSurveyByDept(String dept) {
        String sql = "SELECT " +
        String sql = "SELECT " +
                " t.id as \"id\", " +
                " t.id as \"id\", " +
                " t.title as \"title\", " +
                " t.title as \"title\", " +
@ -630,22 +643,22 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
                " wlyy_survey_template t " +
                " wlyy_survey_template t " +
                " JOIN wlyy_survey_dept d ON t.id = d.survey_temp_code " +
                " JOIN wlyy_survey_dept d ON t.id = d.survey_temp_code " +
                " WHERE " +
                " WHERE " +
                " d.dept = '"+dept+"'";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
                " d.dept = '" + dept + "'";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        return list;
        return list;
    }
    }
    public List<Map<String,Object>> findSurveyByDeptAndPatient(String dept,String patient) {
        List<Map<String,Object>> result = findSurveyByDept(dept);
        if(result!=null&&result.size()>0){
            for(Map<String,Object> map:result){
                String tempId = (String)map.get("id");
                List<WlyySurveyUserDO> list = surveyUserDao.findBySurvey(tempId,patient);
                if(list!=null&&list.size()>0){
                    map.put("isAnswer",true);
                }else{
                    map.put("isAnswer",false);
    public List<Map<String, Object>> findSurveyByDeptAndPatient(String dept, String patient) {
        List<Map<String, Object>> result = findSurveyByDept(dept);
        if (result != null && result.size() > 0) {
            for (Map<String, Object> map : result) {
                String tempId = (String) map.get("id");
                List<WlyySurveyUserDO> list = surveyUserDao.findBySurvey(tempId, patient);
                if (list != null && list.size() > 0) {
                    map.put("isAnswer", true);
                } else {
                    map.put("isAnswer", false);
                }
                }
            }
            }
        }
        }
@ -653,12 +666,13 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
    }
    }
    /**
    /**
    * 查询问卷下科室
    * @param tempId
    * @return
    */
    public List<Map<String,Object>> findDeptBySurvey(String tempId){
        String sql ="SELECT " +
     * 查询问卷下科室
     *
     * @param tempId
     * @return
     */
    public List<Map<String, Object>> findDeptBySurvey(String tempId) {
        String sql = "SELECT " +
                " d.survey_temp_code AS \"surveyTempCode\"," +
                " d.survey_temp_code AS \"surveyTempCode\"," +
                " d.dept AS \"dept\", " +
                " d.dept AS \"dept\", " +
                " d.dept_name AS \"deptName\" " +
                " d.dept_name AS \"deptName\" " +
@ -666,63 +680,79 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
                " wlyy_survey_template t " +
                " wlyy_survey_template t " +
                " JOIN wlyy_survey_dept d ON t.id = d.survey_temp_code " +
                " JOIN wlyy_survey_dept d ON t.id = d.survey_temp_code " +
                " WHERE " +
                " WHERE " +
                " t.id = '"+tempId+"'";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
                " t.id = '" + tempId + "'";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        return list;
        return list;
    }
    }
    /**
    /**
     *
     * @param suJson
     * @param suJson
     * @param suaJsons
     * @param suaJsons
     * @return
     * @return
     * @throws Exception
     * @throws Exception
     */
     */
    public Boolean saveSurveyAnswer(String suJson,String suaJsons)throws Exception{
    public Boolean saveSurveyAnswer(String suJson, String suaJsons) throws Exception {
        WlyySurveyUserDO surveyUserDO = objectMapper.readValue(suJson,WlyySurveyUserDO.class);
        surveyUserDO.setFixDate(DateUtil.dateToStr(new Date(),"yyyy-MM-dd"));
        WlyySurveyUserDO surveyUserDO = objectMapper.readValue(suJson, WlyySurveyUserDO.class);
        surveyUserDO.setFixDate(DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
        surveyUserDO.setId(UUID.randomUUID().toString());
        surveyUserDO.setId(UUID.randomUUID().toString());
        surveyUserDO = surveyUserDao.save(surveyUserDO);
        surveyUserDO = surveyUserDao.save(surveyUserDO);
        //删除问题答案
        //删除问题答案
        List<WlyySurveyUserAnswerDO> dels = surveyUserAnswerDao.findBySurverUserId(surveyUserDO.getId());
        List<WlyySurveyUserAnswerDO> dels = surveyUserAnswerDao.findBySurverUserId(surveyUserDO.getId());
        if(dels!=null&&dels.size()>0){
        if (dels != null && dels.size() > 0) {
            surveyUserAnswerDao.deleteAll(dels);
            surveyUserAnswerDao.deleteAll(dels);
        }
        }
        //保存答案
        //保存答案
        if(StringUtils.isNotBlank(suaJsons)){
            List<WlyySurveyUserAnswerDO> answerDOs = EntityUtils.jsonToList(suaJsons,WlyySurveyUserAnswerDO.class);
            for(WlyySurveyUserAnswerDO answerDO : answerDOs){
        if (StringUtils.isNotBlank(suaJsons)) {
            List<WlyySurveyUserAnswerDO> answerDOs = EntityUtils.jsonToList(suaJsons, WlyySurveyUserAnswerDO.class);
            for (WlyySurveyUserAnswerDO answerDO : answerDOs) {
                answerDO.setSurverUserId(surveyUserDO.getId());
                answerDO.setSurverUserId(surveyUserDO.getId());
                answerDO.setSurverUserCode(surveyUserDO.getCode());
                answerDO.setCreateTime(new Date());
                answerDO.setCreateTime(new Date());
                /*WlyySurveyTemplateOptionDO surveyTemplateOptionDO = surveyTemplateOptionDao.getOne(answerDO.getTempOptionCode());
                /*WlyySurveyTemplateOptionDO surveyTemplateOptionDO = surveyTemplateOptionDao.getOne(answerDO.getTempOptionCode());
                answerDO.setTempQuestionCode(surveyTemplateOptionDO.getQuestionCode());
                answerDO.setTempQuestionCode(surveyTemplateOptionDO.getQuestionCode());
                answerDO.setTempOptionCode(surveyTemplateOptionDO.getCode());*/
                answerDO.setTempOptionCode(surveyTemplateOptionDO.getCode());*/
            }
            }
            surveyUserAnswerDao.saveAll(answerDOs);
            surveyUserAnswerDao.saveAll(answerDOs);
            BasePatientBusinessDO basePatientBusinessDO = basePatientBusinessDao.findByDoctorPatientRelationCode(surveyUserDO.getPatient(),surveyUserDO.getSurveyTempCode(),surveyUserDO.getDoctor());
            String sql = " select * from base_patient_business a " +
                    " where a.del=1 " +
                    " and a.patient='" + surveyUserDO.getPatient() + "' " +
                    " and a.relation_code='" + surveyUserDO.getSurveyTempCode() + "' " +
                    " and a.doctor = '" + surveyUserDO.getDoctor() + "' order by create_time desc";
            List<BasePatientBusinessDO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(BasePatientBusinessDO.class));
            BasePatientBusinessDO basePatientBusinessDO = null;
            if (!list.isEmpty()) {
                basePatientBusinessDO = list.get(0);
            }
//            BasePatientBusinessDO basePatientBusinessDO = basePatientBusinessDao.findByDoctorPatientRelationCode(surveyUserDO.getPatient(),surveyUserDO.getSurveyTempCode(),surveyUserDO.getDoctor());
            JSONObject object = new JSONObject();
            JSONObject object = new JSONObject();
            if (null!=basePatientBusinessDO){
                object.put("title",surveyUserDO.getSurveyTempTitle());
                object.put("content",answerDOs);
                object.put("id",surveyUserDO.getSurveyTempCode());
            if (null != basePatientBusinessDO) {
                object.put("title", surveyUserDO.getSurveyTempTitle());
                object.put("content", answerDOs);
                object.put("id", surveyUserDO.getSurveyTempCode());
                object.put("surverUserCode", surveyUserDO.getCode());
            }
            }
            this.sendImMsg(basePatientBusinessDO.getPatient(), basePatientBusinessDO.getPatientName(), basePatientBusinessDO.getSessionId(), "36", object.toJSONString(),"1");
            this.sendImMsg(basePatientBusinessDO.getPatient(), basePatientBusinessDO.getPatientName(), basePatientBusinessDO.getSessionId(), "36", object.toJSONString(), "1");
        }
        }
        return true;
        return true;
    }
    }
    public List<WlyySurveyUserAnswerDO> findAnswerBySurveyTempCode(String surverUserId,String patient,String tempId){
    public List<WlyySurveyUserAnswerDO> findAnswerBySurveyTempCode(String surverUserId,String surverUserCode, String patient, String tempId) {
        List<WlyySurveyUserAnswerDO> list = null;
        List<WlyySurveyUserAnswerDO> list = null;
        if(StringUtils.isNotBlank(surverUserId)){
        if(StringUtils.isNotBlank(surverUserCode)){
            list = surveyUserAnswerDao.findBySurverUserCode(surverUserCode);
        }else if (StringUtils.isNotBlank(surverUserId)) {
            list = surveyUserAnswerDao.findBySurverUserId(surverUserId);
            list = surveyUserAnswerDao.findBySurverUserId(surverUserId);
        }else{
            List<WlyySurveyUserDO> surveys = surveyUserDao.findBySurvey(tempId,patient);
        } else {
            List<WlyySurveyUserDO> surveys = surveyUserDao.findBySurvey(tempId, patient);
            System.out.println(surveys);
            System.out.println(surveys);
            if(surveys!=null&&surveys.size()>0){
            if (surveys != null && surveys.size() > 0) {
                WlyySurveyUserDO wlyySurveyUserDO = surveys.get(0);
                WlyySurveyUserDO wlyySurveyUserDO = surveys.get(0);
                System.out.println(wlyySurveyUserDO);
                System.out.println(wlyySurveyUserDO);
                list = surveyUserAnswerDao.findBySurverUserId(wlyySurveyUserDO.getId());
                list = surveyUserAnswerDao.findBySurverUserId(wlyySurveyUserDO.getId());
@ -733,56 +763,57 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
    /**
    /**
     * 查询问题情况
     * 查询问题情况
     *
     * @param tempId
     * @param tempId
     * @return
     * @return
     */
     */
    public WlyySurveyTemplateVO findSurveyTemplateResult(String tempId) {
    public WlyySurveyTemplateVO findSurveyTemplateResult(String tempId) {
        WlyySurveyTemplateDO templateDO = surveyTemplateDao.getOne(tempId);
        WlyySurveyTemplateDO templateDO = surveyTemplateDao.getOne(tempId);
        WlyySurveyTemplateVO templateVO = convertToModel(templateDO,WlyySurveyTemplateVO.class);
        WlyySurveyTemplateVO templateVO = convertToModel(templateDO, WlyySurveyTemplateVO.class);
        templateVO.setLabels(findSurveyTemplateLabel(tempId));
        templateVO.setLabels(findSurveyTemplateLabel(tempId));
        templateVO.setInsplabels(findSurveyInspTemplateLabel(tempId));
        templateVO.setInsplabels(findSurveyInspTemplateLabel(tempId));
        BaseDoctorDO doctor = baseDoctorDao.findByIdAndDel(templateDO.getCreaterCode());
        BaseDoctorDO doctor = baseDoctorDao.findByIdAndDel(templateDO.getCreaterCode());
        if (null!=doctor){
        if (null != doctor) {
            templateVO.setVisitDept(doctor.getVisitDept());
            templateVO.setVisitDept(doctor.getVisitDept());
            templateVO.setVisitDeptName(doctor.getVisitDeptName());
            templateVO.setVisitDeptName(doctor.getVisitDeptName());
        }
        }
        //查询所有答题过的用户,计算答题总数
        //查询所有答题过的用户,计算答题总数
        List<WlyySurveyUserDO> surveyUsers = surveyUserDao.findBySurveyTempCodeAndStatus(tempId,1);
        Integer total =0;
        if(surveyUsers!=null&&surveyUsers.size()>0){
        List<WlyySurveyUserDO> surveyUsers = surveyUserDao.findBySurveyTempCodeAndStatus(tempId, 1);
        Integer total = 0;
        if (surveyUsers != null && surveyUsers.size() > 0) {
            total = surveyUsers.size();
            total = surveyUsers.size();
        }
        }
        templateVO.setAnswerCount(total);
        templateVO.setAnswerCount(total);
        List<WlyySurveyTemplateQuestionDO> tqDOs = surveyTemplateQuestionDao.findByTemplateCodeAndDelOrderBySortAsc(tempId,"1");
        if(tqDOs!=null&&tqDOs.size()>0){
        List<WlyySurveyTemplateQuestionDO> tqDOs = surveyTemplateQuestionDao.findByTemplateCodeAndDelOrderBySortAsc(tempId, "1");
        if (tqDOs != null && tqDOs.size() > 0) {
            //设置问题
            //设置问题
            List<WlyySurveyTemplateQuestionVO> tqVOs = new ArrayList<>();
            List<WlyySurveyTemplateQuestionVO> tqVOs = new ArrayList<>();
            convertToModels(tqDOs,tqVOs,WlyySurveyTemplateQuestionVO.class);
            convertToModels(tqDOs, tqVOs, WlyySurveyTemplateQuestionVO.class);
            //设置选项
            //设置选项
            for(WlyySurveyTemplateQuestionVO tq:tqVOs){
                List<WlyySurveyTemplateOptionDO> optionDOs  = surveyTemplateOptionDao.findByQuestionCodeAndDelOrderBySortAsc(tq.getCode(),tq.getTemplateCode(),"1");
            for (WlyySurveyTemplateQuestionVO tq : tqVOs) {
                List<WlyySurveyTemplateOptionDO> optionDOs = surveyTemplateOptionDao.findByQuestionCodeAndDelOrderBySortAsc(tq.getCode(), tq.getTemplateCode(), "1");
                List<WlyySurveyTemplateOptionVO> optionVOs = new ArrayList<>();
                List<WlyySurveyTemplateOptionVO> optionVOs = new ArrayList<>();
                convertToModels(optionDOs,optionVOs,WlyySurveyTemplateOptionVO.class);
                convertToModels(optionDOs, optionVOs, WlyySurveyTemplateOptionVO.class);
                int tpCount = 0;
                int tpCount = 0;
                List<WlyySurveyUserAnswerDO> answerQuestionDOs = surveyUserAnswerDao.findByTempQuestionCodeDistinctPatient(tq.getCode(),tempId);
                if(answerQuestionDOs!=null&&answerQuestionDOs.size()>0){
                List<WlyySurveyUserAnswerDO> answerQuestionDOs = surveyUserAnswerDao.findByTempQuestionCodeDistinctPatient(tq.getCode(), tempId);
                if (answerQuestionDOs != null && answerQuestionDOs.size() > 0) {
                    tpCount = answerQuestionDOs.size();
                    tpCount = answerQuestionDOs.size();
                }
                }
                tq.setTqCount(tpCount);
                tq.setTqCount(tpCount);
                /**
                /**
                 * 统计每个选项选择的百分比
                 * 统计每个选项选择的百分比
                 */
                 */
                if(optionVOs!=null&&optionVOs.size()>0){
                    for(WlyySurveyTemplateOptionVO vo:optionVOs){
                        Integer answerCount =0;
                        List<WlyySurveyUserAnswerDO> answerDOs = surveyUserAnswerDao.findBytempOptionCode(vo.getCode(),vo.getTemplateCode());
                        if(answerDOs!=null&&answerDOs.size()>0){
                if (optionVOs != null && optionVOs.size() > 0) {
                    for (WlyySurveyTemplateOptionVO vo : optionVOs) {
                        Integer answerCount = 0;
                        List<WlyySurveyUserAnswerDO> answerDOs = surveyUserAnswerDao.findBytempOptionCode(vo.getCode(), vo.getTemplateCode());
                        if (answerDOs != null && answerDOs.size() > 0) {
                            answerCount = answerDOs.size();
                            answerCount = answerDOs.size();
                        }
                        }
                        vo.setPercentage(PercentageUtil.bs(answerCount,total)+"%");
                        vo.setPercentage(PercentageUtil.bs(answerCount, total) + "%");
                        vo.setOptCount(answerCount);
                        vo.setOptCount(answerCount);
                        vo.setId(vo.getCode());
                        vo.setId(vo.getCode());
                    }
                    }
@ -797,6 +828,7 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
    /**
    /**
     * 综合查询问题答案
     * 综合查询问题答案
     *
     * @param comment
     * @param comment
     * @param content
     * @param content
     * @param tempQuestionCode
     * @param tempQuestionCode
@ -805,27 +837,27 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
     * @param size
     * @param size
     * @return
     * @return
     */
     */
    public MixEnvelop findQuestionInfoList(String comment, String tempId,String content, String tempQuestionCode,String tempOptionCode,Integer page,Integer size){
    public MixEnvelop findQuestionInfoList(String comment, String tempId, String content, String tempQuestionCode, String tempOptionCode, Integer page, Integer size) {
        String totalSql ="SELECT " +
        String totalSql = "SELECT " +
                " COUNT(1) AS \"total\"" +
                " COUNT(1) AS \"total\"" +
                " FROM " +
                " FROM " +
                " wlyy_survey_user_answer t " +
                " wlyy_survey_user_answer t " +
                " WHERE 1=1";
                " WHERE 1=1";
        if(StringUtils.isNotBlank(comment)){
            totalSql += " AND t.comment like '%"+comment+"%' ";
        if (StringUtils.isNotBlank(comment)) {
            totalSql += " AND t.comment like '%" + comment + "%' ";
        }
        }
        if(StringUtils.isNotBlank(content)){
            totalSql += " AND t.content  like '%"+content+"%'";
        if (StringUtils.isNotBlank(content)) {
            totalSql += " AND t.content  like '%" + content + "%'";
        }
        }
        if(StringUtils.isNotBlank(tempQuestionCode)){
            totalSql += " AND t.temp_question_code ='"+tempQuestionCode+"'";
        if (StringUtils.isNotBlank(tempQuestionCode)) {
            totalSql += " AND t.temp_question_code ='" + tempQuestionCode + "'";
        }
        }
        if(StringUtils.isNotBlank(tempOptionCode)){
            totalSql += " AND t.temp_option_code ='"+tempOptionCode+"'";
        if (StringUtils.isNotBlank(tempOptionCode)) {
            totalSql += " AND t.temp_option_code ='" + tempOptionCode + "'";
        }
        }
        if(StringUtils.isNotBlank(tempId)){
            totalSql += " AND t.survey_temp_code ='"+tempId+"'";
        if (StringUtils.isNotBlank(tempId)) {
            totalSql += " AND t.survey_temp_code ='" + tempId + "'";
        }
        }
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
@ -850,36 +882,36 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
                " FROM " +
                " FROM " +
                " wlyy_survey_user_answer t " +
                " wlyy_survey_user_answer t " +
                " WHERE 1=1";
                " WHERE 1=1";
        if(StringUtils.isNotBlank(comment)){
            sql += " AND t.user_comment like '%"+comment+"%' ";
        if (StringUtils.isNotBlank(comment)) {
            sql += " AND t.user_comment like '%" + comment + "%' ";
        }
        }
        if(StringUtils.isNotBlank(content)){
            sql += " AND t.user_content  like '%"+content+"%'";
        if (StringUtils.isNotBlank(content)) {
            sql += " AND t.user_content  like '%" + content + "%'";
        }
        }
        if(StringUtils.isNotBlank(tempQuestionCode)){
            sql += " AND t.temp_question_code ='"+tempQuestionCode+"'";
        if (StringUtils.isNotBlank(tempQuestionCode)) {
            sql += " AND t.temp_question_code ='" + tempQuestionCode + "'";
        }
        }
        if(StringUtils.isNotBlank(tempOptionCode)){
            sql += " AND t.temp_option_code ='"+tempOptionCode+"'";
        if (StringUtils.isNotBlank(tempOptionCode)) {
            sql += " AND t.temp_option_code ='" + tempOptionCode + "'";
        }
        }
        if(StringUtils.isNotBlank(tempId)){
            sql += " AND t.survey_temp_code ='"+tempId+"'";
        if (StringUtils.isNotBlank(tempId)) {
            sql += " AND t.survey_temp_code ='" + tempId + "'";
        }
        }
        sql += " ORDER BY t.create_time DESC  ";
        sql += " ORDER BY t.create_time DESC  ";
        if ("xm_ykyy_wx".equals(wxId)) {
        if ("xm_ykyy_wx".equals(wxId)) {
            if (!flag){
                sql ="SELECT * FROM\n" +
            if (!flag) {
                sql = "SELECT * FROM\n" +
                        "( SELECT A.*, ROWNUM RN FROM\n" +
                        "( SELECT A.*, ROWNUM RN FROM\n" +
                        "    ("+sql+") A \n" +
                        "    WHERE ROWNUM <= "+page*size+" ) \n" +
                        "       WHERE RN >= "+((page-1)*size+1);
                        "    (" + sql + ") A \n" +
                        "    WHERE ROWNUM <= " + page * size + " ) \n" +
                        "       WHERE RN >= " + ((page - 1) * size + 1);
            }else {
                sql+="LIMIT "+ (page - 1) * size + "," + size + " ";
            } else {
                sql += "LIMIT " + (page - 1) * size + "," + size + " ";
            }
            }
        } else {
        } else {
            sql+="LIMIT "+ (page - 1) * size + "," + size + " ";
            sql += "LIMIT " + (page - 1) * size + "," + size + " ";
        }
        }
        List<WlyySurveyUserAnswerDO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WlyySurveyUserAnswerDO.class));
        List<WlyySurveyUserAnswerDO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WlyySurveyUserAnswerDO.class));
@ -889,35 +921,36 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
    /**
    /**
     * 查询
     * 查询
     *
     * @param
     * @param
     * @param
     * @param
     * @param
     * @param
     * @return
     * @return
     */
     */
    public MixEnvelop findAnswerList(String tempId,String patient,String patientName,String title,Integer page,Integer size,String startTime,String endTime){
    public MixEnvelop findAnswerList(String tempId, String patient, String patientName, String title, Integer page, Integer size, String startTime, String endTime) {
        String totalSql ="SELECT " +
        String totalSql = "SELECT " +
                " COUNT(1) AS \"total\"" +
                " COUNT(1) AS \"total\"" +
                " FROM " +
                " FROM " +
                " wlyy_survey_user t " +
                " wlyy_survey_user t " +
                " WHERE 1=1 and t.status = 1 ";
                " WHERE 1=1 and t.status = 1 ";
        if(StringUtils.isNotBlank(title)){
            totalSql += " AND t.survey_temp_title like '%"+title+"%' ";
        if (StringUtils.isNotBlank(title)) {
            totalSql += " AND t.survey_temp_title like '%" + title + "%' ";
        }
        }
        if(StringUtils.isNotBlank(patient)){
            totalSql += " AND t.patient = '"+patient+"' ";
        if (StringUtils.isNotBlank(patient)) {
            totalSql += " AND t.patient = '" + patient + "' ";
        }
        }
        if(StringUtils.isNotBlank(tempId)){
            totalSql += " AND t.survey_temp_code = '"+tempId+"' ";
        if (StringUtils.isNotBlank(tempId)) {
            totalSql += " AND t.survey_temp_code = '" + tempId + "' ";
        }
        }
        if(StringUtils.isNotBlank(patientName)){
            totalSql += " AND t.patient_name like  '%"+patientName+"%' ";
        if (StringUtils.isNotBlank(patientName)) {
            totalSql += " AND t.patient_name like  '%" + patientName + "%' ";
        }
        }
        if(StringUtils.isNotBlank(startTime)){
            totalSql += " AND t.create_time >=  '"+startTime+" 00:00:00' ";
        if (StringUtils.isNotBlank(startTime)) {
            totalSql += " AND t.create_time >=  '" + startTime + " 00:00:00' ";
        }
        }
        if(StringUtils.isNotBlank(endTime)){
            totalSql += " AND t.create_time <=  '"+endTime+" 23:59:59' ";
        if (StringUtils.isNotBlank(endTime)) {
            totalSql += " AND t.create_time <=  '" + endTime + " 23:59:59' ";
        }
        }
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
@ -945,47 +978,47 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
                " wlyy_survey_user t " +
                " wlyy_survey_user t " +
                " JOIN base_patient p ON t.patient = p.id " +
                " JOIN base_patient p ON t.patient = p.id " +
                " WHERE 1=1 and t.status = 1 ";
                " WHERE 1=1 and t.status = 1 ";
        if(StringUtils.isNotBlank(title)){
            sql += " AND t.survey_temp_title like '%"+title+"%' ";
        if (StringUtils.isNotBlank(title)) {
            sql += " AND t.survey_temp_title like '%" + title + "%' ";
        }
        }
        if(StringUtils.isNotBlank(patient)){
            sql += " AND t.patient = '"+patient+"' ";
        if (StringUtils.isNotBlank(patient)) {
            sql += " AND t.patient = '" + patient + "' ";
        }
        }
        if(StringUtils.isNotBlank(patientName)){
            sql += " AND t.patient_name like  '%"+patientName+"%' ";
        if (StringUtils.isNotBlank(patientName)) {
            sql += " AND t.patient_name like  '%" + patientName + "%' ";
        }
        }
        if(StringUtils.isNotBlank(tempId)){
            sql += " AND t.survey_temp_code = '"+tempId+"' ";
        if (StringUtils.isNotBlank(tempId)) {
            sql += " AND t.survey_temp_code = '" + tempId + "' ";
        }
        }
        if(StringUtils.isNotBlank(startTime)){
            sql += " AND t.create_time >=  '"+startTime+" 00:00:00' ";
        if (StringUtils.isNotBlank(startTime)) {
            sql += " AND t.create_time >=  '" + startTime + " 00:00:00' ";
        }
        }
        if(StringUtils.isNotBlank(endTime)){
            sql += " AND t.create_time <=  '"+endTime+" 23:59:59' ";
        if (StringUtils.isNotBlank(endTime)) {
            sql += " AND t.create_time <=  '" + endTime + " 23:59:59' ";
        }
        }
        sql += " ORDER BY t.create_time DESC " ;
        sql += " ORDER BY t.create_time DESC ";
        if ("xm_ykyy_wx".equals(wxId)) {
        if ("xm_ykyy_wx".equals(wxId)) {
            if (!flag){
                sql ="SELECT * FROM\n" +
            if (!flag) {
                sql = "SELECT * FROM\n" +
                        "( SELECT A.*, ROWNUM RN FROM\n" +
                        "( SELECT A.*, ROWNUM RN FROM\n" +
                        "    ("+sql+") A \n" +
                        "    WHERE ROWNUM <= "+page*size+" ) \n" +
                        "       WHERE RN >= "+((page-1)*size+1);
                        "    (" + sql + ") A \n" +
                        "    WHERE ROWNUM <= " + page * size + " ) \n" +
                        "       WHERE RN >= " + ((page - 1) * size + 1);
            }else {
                sql+="LIMIT "+ (page - 1) * size + "," + size + " ";
            } else {
                sql += "LIMIT " + (page - 1) * size + "," + size + " ";
            }
            }
        } else {
        } else {
            sql+="LIMIT "+ (page - 1) * size + "," + size + " ";
            sql += "LIMIT " + (page - 1) * size + "," + size + " ";
        }
        }
        System.out.println(sql);
        System.out.println(sql);
        List<WlyySurveyUserVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WlyySurveyUserVO.class));
        List<WlyySurveyUserVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WlyySurveyUserVO.class));
        if(list!=null&&list.size()>0){
            for(WlyySurveyUserVO vo :list){
        if (list != null && list.size() > 0) {
            for (WlyySurveyUserVO vo : list) {
                vo.setAge(IdCardUtil.getAgeForIdcard(vo.getIdcard()));
                vo.setAge(IdCardUtil.getAgeForIdcard(vo.getIdcard()));
            }
            }
        }
        }
@ -995,7 +1028,7 @@ public class SurveyService extends BaseJpaService<WlyySurveyQuestionDO, SurveyQu
    public String sendImMsg(String from, String fromName, String sessionId, String contentType, String content, String businessType) {
    public String sendImMsg(String from, String fromName, String sessionId, String contentType, String content, String businessType) {
        String imAddr = im_host + "api/v2/sessions/" + sessionId + "/messages";
        String imAddr = im_host + "api/v2/sessions/" + sessionId + "/messages";
        System.out.println("im地址"+imAddr);
        System.out.println("im地址" + imAddr);
        JSONObject params = new JSONObject();
        JSONObject params = new JSONObject();
        params.put("sender_id", from);
        params.put("sender_id", from);
        params.put("sender_name", fromName);
        params.put("sender_name", fromName);

+ 4 - 6
business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java

@ -7,7 +7,6 @@ import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.base.wx.WxPayLogDO;
import com.yihu.jw.entity.base.wx.WxPayLogDO;
import com.yihu.jw.entity.base.wx.WxWechatDO;
import com.yihu.jw.entity.base.wx.WxWechatDO;
@ -16,8 +15,6 @@ import com.yihu.jw.entity.hospital.dict.WlyyChargeDictDO;
import com.yihu.jw.entity.hospital.healthCare.YlzMedicalRelationDO;
import com.yihu.jw.entity.hospital.healthCare.YlzMedicalRelationDO;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.hospital.prescription.*;
import com.yihu.jw.entity.hospital.prescription.*;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.entity.order.BusinessOrderRefundDO;
import com.yihu.jw.entity.order.BusinessOrderRefundDO;
@ -36,14 +33,13 @@ import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService;
import com.yihu.jw.hospital.ykyy.service.YkyyService;
import com.yihu.jw.hospital.ykyy.service.YkyyService;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.order.dao.BusinessOrderRefundDao;
import com.yihu.jw.order.dao.BusinessOrderRefundDao;
import com.yihu.jw.order.dao.ConsultOrderDao;
import com.yihu.jw.order.dao.ConsultOrderDao;
import com.yihu.jw.order.pay.wx.WeChatConfig;
import com.yihu.jw.order.pay.wx.WeChatConfig;
import com.yihu.jw.order.pay.ylz.YlzPayService;
import com.yihu.jw.order.pay.ylz.YlzPayService;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionInfoVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.sms.dao.BaseSmsTemplateDao;
import com.yihu.jw.sms.dao.BaseSmsTemplateDao;
@ -52,6 +48,8 @@ import com.yihu.jw.util.common.QrcodeUtil;
import com.yihu.jw.util.common.XMLUtil;
import com.yihu.jw.util.common.XMLUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.util.network.HttpResponse;
import com.yihu.jw.util.network.HttpUtils;
import com.yihu.jw.util.wechat.WeiXinPayUtils;
import com.yihu.jw.util.wechat.WeiXinPayUtils;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import com.yihu.jw.utils.ByteToInputStream;
import com.yihu.jw.utils.ByteToInputStream;
@ -2232,7 +2230,7 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
                logger.info("appletCode不为空"+appletCode);
                logger.info("appletCode不为空"+appletCode);
                Map<String,Object> objectMap = checkApplets(appletCode,wxWechatDO.getApplets(),wxWechatDO.getAppletsSecret());
                Map<String,Object> objectMap = checkApplets(appletCode,wxWechatDO.getApplets(),wxWechatDO.getAppletsSecret());
                if (objectMap!=null){
                if (objectMap!=null){
                    openId = objectMap.get("openid").toString();
                    openId = objectMap.get("openid")+"";
                    logger.info("appletCode"+appletCode);
                    logger.info("appletCode"+appletCode);
                    logger.info("openid"+openId);
                    logger.info("openid"+openId);
                }
                }

+ 88 - 88
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java

@ -180,15 +180,15 @@ public class ImService {
    public static String im_host;
    public static String im_host;
//    @Value("${im-service.im_service_url}")
    //    @Value("${im-service.im_service_url}")
    @Value("${im.im_list_get}")
    @Value("${im.im_list_get}")
    public void setIm_host(String im_host) {
    public void setIm_host(String im_host) {
        ImService.im_host = im_host;
        ImService.im_host = im_host;
    }
    }
    public String getSender(){
    public String getSender() {
        WlyyHospitalSysDictDO dictDO = hospitalSysDictDao.findById("customer").orElse(null);
        WlyyHospitalSysDictDO dictDO = hospitalSysDictDao.findById("customer").orElse(null);
        if(dictDO==null){
        if (dictDO == null) {
            dictDO = new WlyyHospitalSysDictDO();
            dictDO = new WlyyHospitalSysDictDO();
            dictDO.setDictCode("customer");
            dictDO.setDictCode("customer");
            dictDO.setDictValue("客服");
            dictDO.setDictValue("客服");
@ -197,9 +197,9 @@ public class ImService {
    }
    }
    //是否加入客服
    //是否加入客服
    public boolean isAddCustomer(String type){
        List<WlyyHospitalSysDictDO> dos = hospitalSysDictDao.findByDictNameAndDictCode("customer_type",type);
        if(dos.size()>0){
    public boolean isAddCustomer(String type) {
        List<WlyyHospitalSysDictDO> dos = hospitalSysDictDao.findByDictNameAndDictCode("customer_type", type);
        if (dos.size() > 0) {
            return true;
            return true;
        }
        }
        return false;
        return false;
@ -292,9 +292,9 @@ public class ImService {
        sql += " ORDER BY a.czrq desc ";
        sql += " ORDER BY a.czrq desc ";
        logger.info("sql=" + sql);
        logger.info("sql=" + sql);
        List<Map<String, Object>> result = hibenateUtils.createSQLQuery(sql, page, pagesize);
        List<Map<String, Object>> result = hibenateUtils.createSQLQuery(sql, page, pagesize);
        for (Map<String, Object> map:result){
            map.put("patientAge",IdCardUtil.getAgeForIdcard(map.get("patientIdcard")+""));
            map.put("doctorAge",IdCardUtil.getAgeForIdcard(map.get("doctorIdcard")+""));
        for (Map<String, Object> map : result) {
            map.put("patientAge", IdCardUtil.getAgeForIdcard(map.get("patientIdcard") + ""));
            map.put("doctorAge", IdCardUtil.getAgeForIdcard(map.get("doctorIdcard") + ""));
        }
        }
        /*result = jdbcTemplate.query(sql, new BeanPropertyRowMapper(ConsultVO.class));*/
        /*result = jdbcTemplate.query(sql, new BeanPropertyRowMapper(ConsultVO.class));*/
        return result;
        return result;
@ -366,17 +366,17 @@ public class ImService {
        return consultCode;
        return consultCode;
    }
    }
    public List<ConsultTeamDo> getUnfinishedConsult3(String patient, String doctor,int type) {
        return consultTeamDao.findUnfinishedConsultType(patient,doctor,type);
    public List<ConsultTeamDo> getUnfinishedConsult3(String patient, String doctor, int type) {
        return consultTeamDao.findUnfinishedConsultType(patient, doctor, type);
    }
    }
    public String getUnfinishedConsult(String patient, String doctor,int type) {
    public String getUnfinishedConsult(String patient, String doctor, int type) {
        String totalSql = "SELECT a.consult as \"consultCode\" " +
        String totalSql = "SELECT a.consult as \"consultCode\" " +
                "FROM wlyy_consult_team a " +
                "FROM wlyy_consult_team a " +
                "WHERE a.patient= '" + patient + "' " +
                "WHERE a.patient= '" + patient + "' " +
                "AND a.doctor='" + doctor + "' " +
                "AND a.doctor='" + doctor + "' " +
                "AND a.del='1' " +
                "AND a.del='1' " +
                "AND a.type=" +type+
                "AND a.type=" + type +
                " AND a.status=0";
                " AND a.status=0";
        List<Map<String, Object>> rstotal = hibenateUtils.createSQLQuery(totalSql);
        List<Map<String, Object>> rstotal = hibenateUtils.createSQLQuery(totalSql);
        String consultCode = null;
        String consultCode = null;
@ -693,7 +693,7 @@ public class ImService {
            }
            }
        }
        }
        robotService.reply(consultModel.getType()+"",content,consult,type);
        robotService.reply(consultModel.getType() + "", content, consult, type);
        return failed;
        return failed;
    }
    }
@ -903,11 +903,11 @@ public class ImService {
            } else {
            } else {
                throw new Exception("获取ACCESSTOKEN失败");
                throw new Exception("获取ACCESSTOKEN失败");
            }
            }
        }else if("xm_xzzx_wx".equals(wxId)){
        } else if ("xm_xzzx_wx".equals(wxId)) {
            accessToken = xzzxEntranceService.getXzToken();
            accessToken = xzzxEntranceService.getXzToken();
        }else if ("xm_hcyy_wx".equals(wechat_appid)) { //海沧医院
                accessToken = hcyyEntranceService.getHcToken();
        }else if("xm_dsyy_wx".equals(wechat_appid)){//第三医院
        } else if ("xm_hcyy_wx".equals(wechat_appid)) { //海沧医院
            accessToken = hcyyEntranceService.getHcToken();
        } else if ("xm_dsyy_wx".equals(wechat_appid)) {//第三医院
            accessToken = wxAccessTokenService.getWxAppletsAccessTokenById(wechat_appid).getAccessToken();
            accessToken = wxAccessTokenService.getWxAppletsAccessTokenById(wechat_appid).getAccessToken();
        } else {
        } else {
            accessToken = wxAccessTokenService.getWxAccessTokenById(wechat_appid).getAccessToken();
            accessToken = wxAccessTokenService.getWxAccessTokenById(wechat_appid).getAccessToken();
@ -1005,7 +1005,7 @@ public class ImService {
     * @return
     * @return
     * @throws Exception
     * @throws Exception
     */
     */
    public JSONObject addTeamConsult(ConsultTeamDo ct, String patient, String doctor, String source,String relationCode) throws Exception {
    public JSONObject addTeamConsult(ConsultTeamDo ct, String patient, String doctor, String source, String relationCode) throws Exception {
        JSONObject re = new JSONObject();
        JSONObject re = new JSONObject();
        boolean boo = StringUtils.isEmpty(getUnfinishedConsult(patient, doctor));
        boolean boo = StringUtils.isEmpty(getUnfinishedConsult(patient, doctor));
        logger.info("boo" + boo);
        logger.info("boo" + boo);
@ -1017,22 +1017,22 @@ public class ImService {
            }
            }
        }
        }
        if (!flag) {
        if (!flag) {
            if(ct.getType()==28){
                if (!StringUtils.isEmpty(getUnfinishedConsult(patient, doctor,ct.getType()))) {
            if (ct.getType() == 28) {
                if (!StringUtils.isEmpty(getUnfinishedConsult(patient, doctor, ct.getType()))) {
                    throw new RuntimeException("居民还有未结束的康复咨询!");
                    throw new RuntimeException("居民还有未结束的康复咨询!");
                }
                }
            }else {
            } else {
                if (!StringUtils.isEmpty(getUnfinishedConsult(patient, doctor))) {//判断是否有未结束的咨询移到同步方法中
                if (!StringUtils.isEmpty(getUnfinishedConsult(patient, doctor))) {//判断是否有未结束的咨询移到同步方法中
                    throw new RuntimeException("居民还有未结束的专家咨询!");
                    throw new RuntimeException("居民还有未结束的专家咨询!");
                }
                }
            }
            }
        }
        }
        String title = "专家咨询";
        String title = "专家咨询";
        if(ct.getType()==28){
        if (ct.getType() == 28) {
            title = "康复咨询";
            title = "康复咨询";
            ServiceItemPlanDO serviceItemPlanDO = serviceItemPlanDao.findById(relationCode).orElse(null);
            ServiceItemPlanDO serviceItemPlanDO = serviceItemPlanDao.findById(relationCode).orElse(null);
            if(serviceItemPlanDO!=null){
                if(!StringUtils.isEmpty(serviceItemPlanDO.getRelationCode())){
            if (serviceItemPlanDO != null) {
                if (!StringUtils.isEmpty(serviceItemPlanDO.getRelationCode())) {
                    throw new RuntimeException("该计划已发起过咨询,请选择其他计划发起!");
                    throw new RuntimeException("该计划已发起过咨询,请选择其他计划发起!");
                }
                }
                serviceItemPlanDO.setRelationCode(ct.getConsult());
                serviceItemPlanDO.setRelationCode(ct.getConsult());
@ -1077,7 +1077,7 @@ public class ImService {
        ct.setDoctorName(baseDoctorDO.getName());
        ct.setDoctorName(baseDoctorDO.getName());
        JSONObject jsonObject = new JSONObject();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("title", tempPatient.getName() + "申请"+title);
        jsonObject.put("title", tempPatient.getName() + "申请" + title);
        jsonObject.put("content", ct.getSymptoms());
        jsonObject.put("content", ct.getSymptoms());
        jsonObject.put("age", DateUtil.getAgeForIdcard(tempPatient.getIdcard()));
        jsonObject.put("age", DateUtil.getAgeForIdcard(tempPatient.getIdcard()));
        jsonObject.put("sex", tempPatient.getSex());
        jsonObject.put("sex", tempPatient.getSex());
@ -1304,7 +1304,7 @@ public class ImService {
                        consultTitle = "家医咨询";
                        consultTitle = "家医咨询";
                    }
                    }
                }else if("4".equals(wlyyOutpatientDO.getOutpatientType())){
                } else if ("4".equals(wlyyOutpatientDO.getOutpatientType())) {
                    //康复咨询
                    //康复咨询
                    users.put(patient, 0);
                    users.put(patient, 0);
                    ct.setType(28);
                    ct.setType(28);
@ -1381,7 +1381,7 @@ public class ImService {
                    } else {
                    } else {
                        obj = imUtil.createTopics(sessionId, consult.getId(), p.getName(), users, messages, imUtil.SESSION_TYPE_GENERAL_EXPERT);
                        obj = imUtil.createTopics(sessionId, consult.getId(), p.getName(), users, messages, imUtil.SESSION_TYPE_GENERAL_EXPERT);
                    }
                    }
                }else if("4".equals(wlyyOutpatientDO.getOutpatientType())){
                } else if ("4".equals(wlyyOutpatientDO.getOutpatientType())) {
                    messages = imUtil.getCreateTopicMessage(patient, p.getName(), consult.getTitle(), content, consult.getImages(), doctorCode);
                    messages = imUtil.getCreateTopicMessage(patient, p.getName(), consult.getTitle(), content, consult.getImages(), doctorCode);
                    //5、(im创建咨询) 续方咨询的sessionid为居民code+就诊code+28(图文,视频,图文+视频)
                    //5、(im创建咨询) 续方咨询的sessionid为居民code+就诊code+28(图文,视频,图文+视频)
                    sessionId = patient + "_" + outpatientCode + "_" + ct.getType();
                    sessionId = patient + "_" + outpatientCode + "_" + ct.getType();
@ -1507,7 +1507,7 @@ public class ImService {
        JSONObject jsonObject = new JSONObject();
        JSONObject jsonObject = new JSONObject();
        if ("3".equals(wlyyOutpatientDO.getOutpatientType())) {
        if ("3".equals(wlyyOutpatientDO.getOutpatientType())) {
            jsonObject.put("title", p.getName() + "申请咨询");
            jsonObject.put("title", p.getName() + "申请咨询");
        } else if("4".equals(wlyyOutpatientDO.getOutpatientType())){
        } else if ("4".equals(wlyyOutpatientDO.getOutpatientType())) {
            jsonObject.put("title", p.getName() + "申请康复咨询");
            jsonObject.put("title", p.getName() + "申请康复咨询");
        } else {
        } else {
            jsonObject.put("title", p.getName() + "申请复诊");
            jsonObject.put("title", p.getName() + "申请复诊");
@ -1553,7 +1553,7 @@ public class ImService {
                consultTitle = "家医咨询";
                consultTitle = "家医咨询";
            }
            }
        }else if("4".equals(wlyyOutpatientDO.getOutpatientType())){
        } else if ("4".equals(wlyyOutpatientDO.getOutpatientType())) {
            users.put(patient, 0);
            users.put(patient, 0);
            ct.setType(28);
            ct.setType(28);
            consultTitle = "申请康复咨询";
            consultTitle = "申请康复咨询";
@ -1629,7 +1629,7 @@ public class ImService {
            } else {
            } else {
                obj = imUtil.createTopics(sessionId, consult.getId(), p.getName(), users, messages, imUtil.SESSION_TYPE_GENERAL_EXPERT);
                obj = imUtil.createTopics(sessionId, consult.getId(), p.getName(), users, messages, imUtil.SESSION_TYPE_GENERAL_EXPERT);
            }
            }
        }else if("4".equals(wlyyOutpatientDO.getOutpatientType())){
        } else if ("4".equals(wlyyOutpatientDO.getOutpatientType())) {
            messages = imUtil.getCreateTopicMessage(patient, p.getName(), consult.getTitle(), content, consult.getImages(), doctorCode);
            messages = imUtil.getCreateTopicMessage(patient, p.getName(), consult.getTitle(), content, consult.getImages(), doctorCode);
            //5、(im创建咨询) 续方咨询的sessionid为居民code+就诊code+28(图文,视频,图文+视频)
            //5、(im创建咨询) 续方咨询的sessionid为居民code+就诊code+28(图文,视频,图文+视频)
            sessionId = patient + "_" + outpatientCode + "_" + ct.getType();
            sessionId = patient + "_" + outpatientCode + "_" + ct.getType();
@ -1681,7 +1681,7 @@ public class ImService {
        addLogs(ct);
        addLogs(ct);
        JSONObject result = imUtil.getSingleSessionInfo(sessionId, doctorCode);
        JSONObject result = imUtil.getSingleSessionInfo(sessionId, doctorCode);
        //发送外层SOCKET消息 在线复诊
        //发送外层SOCKET消息 在线复诊
        if ("1".equals(wlyyOutpatientDO.getOutpatientType()) || "3".equals(wlyyOutpatientDO.getOutpatientType())|| "4".equals(wlyyOutpatientDO.getOutpatientType())) {
        if ("1".equals(wlyyOutpatientDO.getOutpatientType()) || "3".equals(wlyyOutpatientDO.getOutpatientType()) || "4".equals(wlyyOutpatientDO.getOutpatientType())) {
            System.out.println("发送外层SOCKET消息:在线复诊");
            System.out.println("发送外层SOCKET消息:在线复诊");
            JSONObject object = new JSONObject();
            JSONObject object = new JSONObject();
            object.put("socket_sms_type", 5);
            object.put("socket_sms_type", 5);
@ -1720,7 +1720,7 @@ public class ImService {
            msgStr = msgStr + "  已开始复诊";
            msgStr = msgStr + "  已开始复诊";
        } else if ("2".equals(wlyyOutpatientDO.getOutpatientType())) {
        } else if ("2".equals(wlyyOutpatientDO.getOutpatientType())) {
            msgStr = msgStr + "  已开始协同门诊";
            msgStr = msgStr + "  已开始协同门诊";
        } else if("4".equals(wlyyOutpatientDO.getOutpatientType())){
        } else if ("4".equals(wlyyOutpatientDO.getOutpatientType())) {
            msgStr = msgStr + "  已开始康复咨询";
            msgStr = msgStr + "  已开始康复咨询";
        } else {
        } else {
            msgStr = msgStr + "  已开始专家咨询";
            msgStr = msgStr + "  已开始专家咨询";
@ -1820,13 +1820,13 @@ public class ImService {
                outpatientDao.save(wlyyOutpatientDO);
                outpatientDao.save(wlyyOutpatientDO);
                //结束康复执行计划
                //结束康复执行计划
                if(org.apache.commons.lang3.StringUtils.isNotBlank(wlyyOutpatientDO.getPlanId())){
                if (org.apache.commons.lang3.StringUtils.isNotBlank(wlyyOutpatientDO.getPlanId())) {
                    ServiceItemPlanDO serviceItemPlanDO = serviceItemPlanDao.findById(wlyyOutpatientDO.getPlanId()).orElse(null);
                    ServiceItemPlanDO serviceItemPlanDO = serviceItemPlanDao.findById(wlyyOutpatientDO.getPlanId()).orElse(null);
                    if(serviceItemPlanDO!=null){
                    if (serviceItemPlanDO != null) {
                        serviceItemPlanDO.setStatus("1");
                        serviceItemPlanDO.setStatus("1");
                        serviceItemPlanDO.setCompleteTime(DateUtil.getStringDate());
                        serviceItemPlanDO.setCompleteTime(DateUtil.getStringDate());
                        serviceItemPlanDao.save(serviceItemPlanDO);
                        serviceItemPlanDao.save(serviceItemPlanDO);
                        updPlanStatus(serviceItemPlanDO.getPlanId(),serviceItemPlanDO.getPlanDetailId());
                        updPlanStatus(serviceItemPlanDO.getPlanId(), serviceItemPlanDO.getPlanDetailId());
                    }
                    }
                }
                }
            }
            }
@ -2027,8 +2027,8 @@ public class ImService {
        net.sf.json.JSONObject data = new net.sf.json.JSONObject();
        net.sf.json.JSONObject data = new net.sf.json.JSONObject();
        data.put("name", patient.getName());
        data.put("name", patient.getName());
        WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(consultTeam.getRelationCode()).orElse(null);
        WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(consultTeam.getRelationCode()).orElse(null);
        if (wlyyOutpatientDO!=null){
            data.put("consumerName",wlyyOutpatientDO.getConsumerName());
        if (wlyyOutpatientDO != null) {
            data.put("consumerName", wlyyOutpatientDO.getConsumerName());
        }
        }
        data.put("age", IdCardUtil.getAgeForIdcard(patient.getIdcard()));
        data.put("age", IdCardUtil.getAgeForIdcard(patient.getIdcard()));
        data.put("gender", StringUtils.isEmpty(patient.getSex()) ? null : patient.getSex().toString());
        data.put("gender", StringUtils.isEmpty(patient.getSex()) ? null : patient.getSex().toString());
@ -2106,14 +2106,14 @@ public class ImService {
     */
     */
    public JSONObject getConsultInfoAndPatientInfo(String consult, String patientCode) {
    public JSONObject getConsultInfoAndPatientInfo(String consult, String patientCode) {
        JSONObject result = new JSONObject();
        JSONObject result = new JSONObject();
        if(!StringUtils.isEmpty(consult)){
        if (!StringUtils.isEmpty(consult)) {
            ConsultDo consultDo = consultDao.findById(consult).orElse(null);
            ConsultDo consultDo = consultDao.findById(consult).orElse(null);
            if (StringUtils.isEmpty(patientCode)) {
            if (StringUtils.isEmpty(patientCode)) {
                patientCode = consultDo.getPatient();
                patientCode = consultDo.getPatient();
            }
            }
            result.put("consultDo", consultDo);
            result.put("consultDo", consultDo);
        }else {
        } else {
            result.put("consultDo", null);
            result.put("consultDo", null);
        }
        }
        BasePatientDO basePatientDO = null;
        BasePatientDO basePatientDO = null;
@ -3207,32 +3207,32 @@ public class ImService {
    }
    }
    //发送在线候诊室消息
    //发送在线候诊室消息
    public void sendConstomerImg(String patientCode,String outpatientId,String outpatientType,String doctorCode){
    public void sendConstomerImg(String patientCode, String outpatientId, String outpatientType, String doctorCode) {
        try {
        try {
            //808080eb8223c9e50182249cd6ff0000_guidance_26
            //808080eb8223c9e50182249cd6ff0000_guidance_26
            String session_id26 = patientCode +"_guidance_26";
            String session_id27 = patientCode +"_guidance_27";
            String session_id26 = patientCode + "_guidance_26";
            String session_id27 = patientCode + "_guidance_27";
            BaseDoctorDO doctorDO = baseDoctorDao.findByIdAndDel(doctorCode);
            BaseDoctorDO doctorDO = baseDoctorDao.findByIdAndDel(doctorCode);
            String msg = "您好,"+doctorDO.getName()+"医生已接诊,请您及时进入诊室与您的医生沟通。医生将会与您详细讨论病情,并为您提供专业的治疗建议。我们将竭诚为您服务,为您的健康保驾护航。";
            String msg = "您好," + doctorDO.getName() + "医生已接诊,请您及时进入诊室与您的医生沟通。医生将会与您详细讨论病情,并为您提供专业的治疗建议。我们将竭诚为您服务,为您的健康保驾护航。";
            JSONObject json = new JSONObject();
            JSONObject json = new JSONObject();
            json.put("outpatientId",outpatientId);
            json.put("outpatientType",outpatientType);
            json.put("msg",msg);
            json.put("outpatientId", outpatientId);
            json.put("outpatientType", outpatientType);
            json.put("msg", msg);
            WlyyHospitalSysDictDO dictDO = hospitalSysDictDao.findById("customer").orElse(null);
            WlyyHospitalSysDictDO dictDO = hospitalSysDictDao.findById("customer").orElse(null);
            String sender_id = "customer";
            String sender_id = "customer";
            String sender_name = "客服";
            String sender_name = "客服";
            if(dictDO!=null){
            if (dictDO != null) {
                sender_id = dictDO.getDictCode();
                sender_id = dictDO.getDictCode();
                sender_name = dictDO.getDictValue();
                sender_name = dictDO.getDictValue();
            }
            }
            if(imUtil.sessionIsExist(session_id26)){
            if (imUtil.sessionIsExist(session_id26)) {
                imUtil.sendImMsg(sender_id, sender_name, session_id26, "51", json.toJSONString(), "1", null);
                imUtil.sendImMsg(sender_id, sender_name, session_id26, "51", json.toJSONString(), "1", null);
            }
            }
            if(imUtil.sessionIsExist(session_id27)){
            if (imUtil.sessionIsExist(session_id27)) {
                imUtil.sendImMsg(sender_id, sender_name, session_id27, "51", json.toJSONString(), "1", null);
                imUtil.sendImMsg(sender_id, sender_name, session_id27, "51", json.toJSONString(), "1", null);
            }
            }
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
        }
        }
    }
    }
@ -3271,11 +3271,12 @@ public class ImService {
                int age = DateUtil.getAgeForIdcard(basePatientDO.getIdcard());
                int age = DateUtil.getAgeForIdcard(basePatientDO.getIdcard());
                patientAge = "" + age;
                patientAge = "" + age;
            }
            }
            if(isAddCustomer(type)){
            if (isAddCustomer(type)) {
                //加入客服
                //加入客服
                participants.put(getSender(), 0);
                participants.put(getSender(), 0);
            }
            }
            JSONObject sessionJson = imUtil.createSession(participants, sessionType, basePatientDO.getName() + " " + patientSex + " " + patientAge, session_id);
            JSONObject sessionJson = imUtil.createSession(participants, sessionType, basePatientDO.getName() + " " + patientSex + " " + patientAge, session_id);
            System.out.println("sessionJson==>" + JSON.toJSONString(sessionJson));
            if (sessionJson.getInteger("status") == -1) {
            if (sessionJson.getInteger("status") == -1) {
                throw new RuntimeException(sessionJson.getString("message"));
                throw new RuntimeException(sessionJson.getString("message"));
            } else {
            } else {
@ -3303,7 +3304,7 @@ public class ImService {
     * @return
     * @return
     */
     */
    public String patientGuaidenceAppend(String sender_id, String sender_name, String session_id, String content_type, String content, String business_type, String extend) throws Exception {
    public String patientGuaidenceAppend(String sender_id, String sender_name, String session_id, String content_type, String content, String business_type, String extend) throws Exception {
        logger.info("导诊推送im="+content);
        logger.info("导诊推送im=" + content);
        return imUtil.sendImMsg(sender_id, sender_name, session_id, content_type, content, "1", extend);
        return imUtil.sendImMsg(sender_id, sender_name, session_id, content_type, content, "1", extend);
    }
    }
@ -4141,13 +4142,13 @@ public class ImService {
        boolean flag = false;
        boolean flag = false;
        //发送导诊结束消息
        //发送导诊结束消息
        String systemType = "1";
        String systemType = "1";
        if (sessionId.endsWith("_26")){
        if (sessionId.endsWith("_26")) {
            systemType = "2";
            systemType = "2";
        }else if (sessionId.endsWith("_27")){
        } else if (sessionId.endsWith("_27")) {
            systemType = "3";
            systemType = "3";
        }
        }
        BaseSystemDialogSetting endSetting =  dialogSettingDao.findBySystemTypeAndFunctionType(systemType,"5",1);
        if(endSetting!=null){
        BaseSystemDialogSetting endSetting = dialogSettingDao.findBySystemTypeAndFunctionType(systemType, "5", 1);
        if (endSetting != null) {
            String content = endSetting.getContent();
            String content = endSetting.getContent();
            BaseDoctorDO doctorDO = baseDoctorDao.findByIdAndDel(participants);
            BaseDoctorDO doctorDO = baseDoctorDao.findByIdAndDel(participants);
            imUtil.sendImMsg(participants, doctorDO.getName(), sessionId, "1", content, "1", null);
            imUtil.sendImMsg(participants, doctorDO.getName(), sessionId, "1", content, "1", null);
@ -4258,9 +4259,9 @@ public class ImService {
        }
        }
        if (org.apache.commons.lang.StringUtils.isNotBlank(doctor)) {
        if (org.apache.commons.lang.StringUtils.isNotBlank(doctor)) {
            if("28".equals(type)){
                sql += " AND (op.doctor='" + doctor + "' or op.plan_doctor='"+doctor+"')";
            }else {
            if ("28".equals(type)) {
                sql += " AND (op.doctor='" + doctor + "' or op.plan_doctor='" + doctor + "')";
            } else {
                sql += " AND op.doctor='" + doctor + "' ";
                sql += " AND op.doctor='" + doctor + "' ";
            }
            }
@ -4317,9 +4318,9 @@ public class ImService {
                sql += " AND op.outpatient_type = 2";
                sql += " AND op.outpatient_type = 2";
            } else if (type.equalsIgnoreCase("28")) {
            } else if (type.equalsIgnoreCase("28")) {
                sql += " AND op.outpatient_type = 4";
                sql += " AND op.outpatient_type = 4";
            } else if(type.equalsIgnoreCase("29")){
            } else if (type.equalsIgnoreCase("29")) {
                sql += " AND op.outpatient_type = 1 and  oh.id is not null ";
                sql += " AND op.outpatient_type = 1 and  oh.id is not null ";
            }else {
            } else {
                sql += " AND op.type in (1,2,3) ";
                sql += " AND op.type in (1,2,3) ";
            }
            }
        }
        }
@ -4502,32 +4503,32 @@ public class ImService {
    }
    }
    public MixEnvelop recordByDoctor(String doctor, String id,String type, Integer status,String title, String start_time, String end_time, String patient) { //
    public MixEnvelop recordByDoctor(String doctor, String id, String type, Integer status, String title, String start_time, String end_time, String patient) { //
        String sql = "";
        String sql = "";
        sql ="SELECT\n" +
                        "\ta.patient_name AS \"pname\",\n" +
                        "\ta.doctor_name AS \"dname\",\n" +
                        "\ta.dept_name AS \"dept\",\n" +
                        "\ta.outpatient_type AS \"type\",\n" +
                        "\ta.create_time AS \"ctime\",\n" +
                        "\ta.register_date AS \"rtime\",\n" +
                        "\ta.end_time AS \"etime\",\n" +
                        "\ta.description AS \"des\",\n" +
                        "\tb. STATUS AS \"pay\",\n" +
                        "\ta. STATUS AS \"STATUS\"\n" +
                        "FROM\n" +
                        "\twlyy_outpatient a\n" +
                        "LEFT JOIN wlyy_prescription b ON a.id = b.outpatient_id\n" +
                        "LEFT JOIN wlyy_consult c ON c.relation_code = a.id\n" +
                        "LEFT JOIN wlyy_consult_team d ON c.id = d.consult\n" +
                        "LEFT JOIN base_patient e ON a.patient = e.id\n" +
                        "WHERE\n" +
                        "\t1 = 1 ";
        if (status == null){
        }else if (status == 1) {
        sql = "SELECT\n" +
                "\ta.patient_name AS \"pname\",\n" +
                "\ta.doctor_name AS \"dname\",\n" +
                "\ta.dept_name AS \"dept\",\n" +
                "\ta.outpatient_type AS \"type\",\n" +
                "\ta.create_time AS \"ctime\",\n" +
                "\ta.register_date AS \"rtime\",\n" +
                "\ta.end_time AS \"etime\",\n" +
                "\ta.description AS \"des\",\n" +
                "\tb. STATUS AS \"pay\",\n" +
                "\ta. STATUS AS \"STATUS\"\n" +
                "FROM\n" +
                "\twlyy_outpatient a\n" +
                "LEFT JOIN wlyy_prescription b ON a.id = b.outpatient_id\n" +
                "LEFT JOIN wlyy_consult c ON c.relation_code = a.id\n" +
                "LEFT JOIN wlyy_consult_team d ON c.id = d.consult\n" +
                "LEFT JOIN base_patient e ON a.patient = e.id\n" +
                "WHERE\n" +
                "\t1 = 1 ";
        if (status == null) {
        } else if (status == 1) {
            sql += " and a.status = 0 and a.pay_status =1 ";
            sql += " and a.status = 0 and a.pay_status =1 ";
        } else if (status == 0) {
        } else if (status == 0) {
@ -4992,5 +4993,4 @@ public class ImService {
    }
    }
}
}

+ 191 - 187
business/im-service/src/main/java/com/yihu/jw/im/service/RobotService.java

@ -40,7 +40,7 @@ public class RobotService {
    @Autowired
    @Autowired
    private BaseKnowledgeQuestionDao knowledgeQuestionDao;
    private BaseKnowledgeQuestionDao knowledgeQuestionDao;
    @Autowired
    @Autowired
    private  BaseKnowledgeFlowConfigurationRelationDao knowledgeFlowConfigurationRelationDao;
    private BaseKnowledgeFlowConfigurationRelationDao knowledgeFlowConfigurationRelationDao;
    @Autowired
    @Autowired
    private BaseKnowledgeQuestionsDao knowledgeQuestionsDao;
    private BaseKnowledgeQuestionsDao knowledgeQuestionsDao;
    @Autowired
    @Autowired
@ -57,34 +57,35 @@ public class RobotService {
    /**
    /**
     * 发送卡片
     * 发送卡片
     *
     * @param session_id
     * @param session_id
     * @param type 会话类型
     * @param cardType 1 常见问题 2科室医生 3 症状描述
     * @param type       会话类型
     * @param cardType   1 常见问题 2科室医生 3 症状描述
     */
     */
    public void sendCard(String session_id,String type,String cardType){
        if("1".equals(cardType)){
    public void sendCard(String session_id, String type, String cardType) {
        if ("1".equals(cardType)) {
            //1常见问题
            //1常见问题
            List<BaseKnowledgeQuestion> questionList = knowledgeQuestionDao.findTopList(DateUtil.getStringDate(),5);
            List<BaseKnowledgeQuestion> questionList = knowledgeQuestionDao.findTopList(DateUtil.getStringDate(), 5);
            JSONArray jsonArray = new JSONArray();
            JSONArray jsonArray = new JSONArray();
            for (BaseKnowledgeQuestion question:questionList){
            for (BaseKnowledgeQuestion question : questionList) {
                JSONObject json = new JSONObject();
                JSONObject json = new JSONObject();
                json.put("id",question.getId());
                json.put("questionName",question.getQuestionName());
                json.put("id", question.getId());
                json.put("questionName", question.getQuestionName());
                jsonArray.add(jsonArray);
                jsonArray.add(jsonArray);
            }
            }
            JSONObject result = new JSONObject();
            JSONObject result = new JSONObject();
            result.put("content",jsonArray);
            result.put("content_type",ImUtil.ContentType.KnowCommonQuestion);
            result.put("session_id",session_id);
            result.put("content", jsonArray);
            result.put("content_type", ImUtil.ContentType.KnowCommonQuestion);
            result.put("session_id", session_id);
            sendReply(result);
            sendReply(result);
            return;
            return;
        }
        }
    }
    }
    //获取发送者
    //获取发送者
    public WlyyHospitalSysDictDO getSender(){
    public WlyyHospitalSysDictDO getSender() {
        WlyyHospitalSysDictDO dictDO = hospitalSysDictDao.findById("customer").orElse(null);
        WlyyHospitalSysDictDO dictDO = hospitalSysDictDao.findById("customer").orElse(null);
        if(dictDO==null){
        if (dictDO == null) {
            dictDO = new WlyyHospitalSysDictDO();
            dictDO = new WlyyHospitalSysDictDO();
            dictDO.setDictCode("customer");
            dictDO.setDictCode("customer");
            dictDO.setDictValue("客服");
            dictDO.setDictValue("客服");
@ -93,402 +94,405 @@ public class RobotService {
    }
    }
    //发送回复消息
    //发送回复消息
    public void sendReply(JSONObject json){
    public void sendReply(JSONObject json) {
        try {
        try {
            WlyyHospitalSysDictDO dictDO = getSender();
            WlyyHospitalSysDictDO dictDO = getSender();
            imService.patientGuaidenceAppend(dictDO.getDictCode(),dictDO.getDictValue(),json.getString("session_id"),
                    json.getString("content_type"),json.getString("content"),"1",null);
        }catch (Exception e){
            imService.patientGuaidenceAppend(dictDO.getDictCode(), dictDO.getDictValue(), json.getString("session_id"),
                    json.getString("content_type"), json.getString("content"), "1", null);
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
        }
        }
        json = null;
        json = null;
    }
    }
    public void sendReplyMap(Map<String,JSONObject> map){
    public void sendReplyMap(Map<String, JSONObject> map) {
        try {
        try {
            System.out.println("map"+map);
            WlyyHospitalSysDictDO dictDO = getSender();
            WlyyHospitalSysDictDO dictDO = getSender();
            for (JSONObject json:map.values()){
                imService.patientGuaidenceAppend(dictDO.getDictCode(),dictDO.getDictValue(),json.getString("session_id"),
                        json.getString("content_type"),json.getString("content"),"1",null);
            for (JSONObject json : map.values()) {
                String s = imService.patientGuaidenceAppend(dictDO.getDictCode(), dictDO.getDictValue(), json.getString("session_id"),
                        json.getString("content_type"), json.getString("content"), "1", null);
                System.out.println("结果==>" + s);
            }
            }
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
        }
        }
        map = null;
        map = null;
    }
    }
    //智能导诊助手回复
    //智能导诊助手回复
    public Map<String,JSONObject> robotReply(String session_id,String type,String content){
        Map<String,JSONObject> map = new HashMap<>();
    public Map<String, JSONObject> robotReply(String session_id, String type, String content) {
        Map<String, JSONObject> map = new HashMap<>();
        try {
        try {
            System.out.println("自动回复1==="+type+"==="+session_id);
            List<BaseSystemDialogSetting> settingList = dialogSettingDao.selectBySystemTypeAndFlag(sessionTypeToType(type),1);
            if(settingList.size()==0){
            List<BaseSystemDialogSetting> settingList = dialogSettingDao.selectBySystemTypeAndFlag(sessionTypeToType(type), 1);
            if (settingList.size() == 0) {
                //未配置自动回复内容
                //未配置自动回复内容
                return map;
                return map;
            }
            }
            Map<String,BaseSystemDialogSetting> mapSetting = settingList.stream().collect(Collectors.toMap(BaseSystemDialogSetting::getFunctionType, v -> v,(o1,o2)->o1));
            Map<String, BaseSystemDialogSetting> mapSetting = settingList.stream().collect(Collectors.toMap(BaseSystemDialogSetting::getFunctionType, v -> v, (o1, o2) -> o1));
            //欢迎语
            //欢迎语
            welcome(session_id,mapSetting,map);
            welcome(session_id, mapSetting, map);
            //自动匹配回复文字内容
            //自动匹配回复文字内容
//            replyContent(session_id,type,content,mapSetting,map);
//            replyContent(session_id,type,content,mapSetting,map);
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
        }
        }
        return map;
        return map;
    }
    }
    public void reply(String sessionType,String content,String consult,Integer contentType){
        if(contentType==1||contentType==3001){
    public void reply(String sessionType, String content, String consult, Integer contentType) {
        if (contentType == 1 || contentType == 3001) {
            //常见问题
            //常见问题
            replyContent(sessionType,content,consult,contentType);
            replyContent(sessionType, content, consult, contentType);
            return;
            return;
        }
        }
        if(contentType==3006){
        if (contentType == 3006) {
            //回复疾病
            //回复疾病
            replyDisease(sessionType,content,null,consult,contentType+"");
            replyDisease(sessionType, content, null, consult, contentType + "");
            return;
            return;
        }
        }
    }
    }
    //回复疾病
    //回复疾病
    public void replyDisease(String sessionType,String content,String sessionId,String consult,String contentType){
    public void replyDisease(String sessionType, String content, String sessionId, String consult, String contentType) {
        try {
        try {
            JSONObject jsonObject = JSON.parseObject(content);
            JSONObject jsonObject = JSON.parseObject(content);
            String id = jsonObject.getString("id");
            String id = jsonObject.getString("id");
            JSONArray jsonArray = baseKnowledgeDictService.findDeptById(id);
            JSONArray jsonArray = baseKnowledgeDictService.findDeptById(id);
            WlyyHospitalSysDictDO dictDO = getSender();
            WlyyHospitalSysDictDO dictDO = getSender();
            if(StringUtils.isNotEmpty(consult)){
                imUtil.sendTopicIM(dictDO.getDictCode(), dictDO.getDictName(), consult, ImUtil.ContentType.KnowSymptomsDiseaseA.getValue(), jsonArray.toJSONString(),null);
            }else {
                imService.patientGuaidenceAppend(dictDO.getDictCode(),dictDO.getDictValue(),sessionId,
                        ImUtil.ContentType.KnowSymptomsDiseaseA.getValue(),jsonArray.toJSONString(),"1",null);
            if (StringUtils.isNotEmpty(consult)) {
                imUtil.sendTopicIM(dictDO.getDictCode(), dictDO.getDictName(), consult, ImUtil.ContentType.KnowSymptomsDiseaseA.getValue(), jsonArray.toJSONString(), null);
            } else {
                imService.patientGuaidenceAppend(dictDO.getDictCode(), dictDO.getDictValue(), sessionId,
                        ImUtil.ContentType.KnowSymptomsDiseaseA.getValue(), jsonArray.toJSONString(), "1", null);
            }
            }
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
        }
        }
    }
    }
    /**
    /**
     *
     * @param sessionType 会话类型
     * @param sessionType 会话类型
     * @param content 消息内容
     * @param consult 咨询code
     * @param content     消息内容
     * @param consult     咨询code
     * @param contentType 消息类型 文本1 问题集3002
     * @param contentType 消息类型 文本1 问题集3002
     */
     */
    //普通咨询常见问题匹配
    //普通咨询常见问题匹配
    public void replyContent(String sessionType,String content,String consult,Integer contentType){
    public void replyContent(String sessionType, String content, String consult, Integer contentType) {
        try {
        try {
            WlyyHospitalSysDictDO dictDO = getSender();
            WlyyHospitalSysDictDO dictDO = getSender();
            if (contentType==3003){
                String contentTypes = ImUtil.ContentType.KnowCommonDict+"";
                String contentMsg = selectByContentType(contentTypes,content).toJSONString();
                imUtil.sendTopicIM(dictDO.getDictCode(), dictDO.getDictName(), consult, contentTypes, contentMsg,null);
            if (contentType == 3003) {
                String contentTypes = ImUtil.ContentType.KnowCommonDict + "";
                String contentMsg = selectByContentType(contentTypes, content).toJSONString();
                imUtil.sendTopicIM(dictDO.getDictCode(), dictDO.getDictName(), consult, contentTypes, contentMsg, null);
            }
            }
            BaseSystemDialogSetting setting = dialogSettingDao.findBySystemTypeAndFunctionType(sessionTypeToType(sessionType),"7",1);
            if(setting==null){
            BaseSystemDialogSetting setting = dialogSettingDao.findBySystemTypeAndFunctionType(sessionTypeToType(sessionType), "7", 1);
            if (setting == null) {
                return;
                return;
            }
            }
            //查找相似问题
            //查找相似问题
            BaseKnowledgeQuestion question = new BaseKnowledgeQuestion();
            BaseKnowledgeQuestion question = new BaseKnowledgeQuestion();
            if (contentType==1){
            if (contentType == 1) {
                question = findQuestionLikeName(content);
                question = findQuestionLikeName(content);
            }else if ((contentType+"").equalsIgnoreCase(ImUtil.ContentType.KnowCommonQuestions+"")){
            } else if ((contentType + "").equalsIgnoreCase(ImUtil.ContentType.KnowCommonQuestions + "")) {
                question = knowledgeQuestionDao.findById(content).get();
                question = knowledgeQuestionDao.findById(content).get();
            }
            }
            if(question!=null&&StringUtils.isNotBlank(question.getAnswer())){
            if (question != null && StringUtils.isNotBlank(question.getAnswer())) {
                //匹配到相关问题后先推送答案
                //匹配到相关问题后先推送答案
                String answer = question.getAnswer();
                String answer = question.getAnswer();
                imUtil.sendTopicIM(dictDO.getDictCode(), dictDO.getDictName(), consult, "1", answer,null);
                imUtil.sendTopicIM(dictDO.getDictCode(), dictDO.getDictName(), consult, "1", answer, null);
                //匹配问题是否关联其他配置;
                //匹配问题是否关联其他配置;
                if (question.getFlag()==null){
                if (question.getFlag() == null) {
                    List<BaseKnowledgeFlowConfigurationRelation> flowConfigurationRelations = findFlowConfigurationRelationLikeName(content);
                    List<BaseKnowledgeFlowConfigurationRelation> flowConfigurationRelations = findFlowConfigurationRelationLikeName(content);
                    if (flowConfigurationRelations!=null&&flowConfigurationRelations.size()!=0){
                    if (flowConfigurationRelations != null && flowConfigurationRelations.size() != 0) {
                        BaseKnowledgeFlowConfigurationRelation flowConfigurationRelation = flowConfigurationRelations.get(0);
                        BaseKnowledgeFlowConfigurationRelation flowConfigurationRelation = flowConfigurationRelations.get(0);
                        String contentTypes = "1";
                        String contentTypes = "1";
                        String contentMsg = "";
                        String contentMsg = "";
                        if (flowConfigurationRelation.getRelationType().equalsIgnoreCase("2")){
                            contentTypes = ImUtil.ContentType.KnowCommonDict+"";
                            contentMsg = selectByContentType(contentTypes,flowConfigurationRelation.getRelationCode()).toJSONString();
                        }else  if (flowConfigurationRelation.getRelationType().equalsIgnoreCase("3")){
                            contentTypes = ImUtil.ContentType.KnowCommonQuestions+"";
                            contentMsg = selectByContentType(contentTypes,flowConfigurationRelation.getRelationCode()).toJSONString();
                        if (flowConfigurationRelation.getRelationType().equalsIgnoreCase("2")) {
                            contentTypes = ImUtil.ContentType.KnowCommonDict + "";
                            contentMsg = selectByContentType(contentTypes, flowConfigurationRelation.getRelationCode()).toJSONString();
                        } else if (flowConfigurationRelation.getRelationType().equalsIgnoreCase("3")) {
                            contentTypes = ImUtil.ContentType.KnowCommonQuestions + "";
                            contentMsg = selectByContentType(contentTypes, flowConfigurationRelation.getRelationCode()).toJSONString();
                        }
                        }
                        imUtil.sendTopicIM(dictDO.getDictCode(), dictDO.getDictName(), consult, contentTypes, contentMsg,null);
                        imUtil.sendTopicIM(dictDO.getDictCode(), dictDO.getDictName(), consult, contentTypes, contentMsg, null);
                    }
                    }
                }
                }
            }
            }
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
        }
        }
    }
    }
    /**
    /**
     *
     * @param sessionId 会话id
     * @param type 咨询类型
     * @param content 内容
     * @param contentType 消息类型
     * @param businessType  业务类型
     * @param extend 扩展
     * 导诊咨询常见问题匹配
     * @param sessionId    会话id
     * @param type         咨询类型
     * @param content      内容
     * @param contentType  消息类型
     * @param businessType 业务类型
     * @param extend       扩展
     *                     导诊咨询常见问题匹配
     */
     */
    public void replyGuaidenceContent(String sessionId,String type,String content,String contentType,String businessType, String extend){
    public void replyGuaidenceContent(String sessionId, String type, String content, String contentType, String businessType, String extend) {
        try {
        try {
            if(contentType.equals(ImUtil.ContentType.KnowSymptomsDiseaseQ.getValue())){
            if (contentType.equals(ImUtil.ContentType.KnowSymptomsDiseaseQ.getValue())) {
                //回复疾病
                //回复疾病
                replyDisease(type,content,sessionId,null,contentType);
                replyDisease(type, content, sessionId, null, contentType);
                return;
                return;
            }
            }
            WlyyHospitalSysDictDO dictDO = getSender();
            WlyyHospitalSysDictDO dictDO = getSender();
            if (contentType.equalsIgnoreCase("3003")){
            if (contentType.equalsIgnoreCase("3003")) {
                String contentTypes = ImUtil.ContentType.KnowCommonDict.getValue();
                String contentTypes = ImUtil.ContentType.KnowCommonDict.getValue();
                String contentMsg = selectByContentType(contentTypes,content).toJSONString();
                imService.patientGuaidenceAppend(dictDO.getDictCode(),dictDO.getDictValue(),sessionId,
                        contentTypes+"", contentMsg, "1",null);
                String contentMsg = selectByContentType(contentTypes, content).toJSONString();
                imService.patientGuaidenceAppend(dictDO.getDictCode(), dictDO.getDictValue(), sessionId,
                        contentTypes + "", contentMsg, "1", null);
            }
            }
            String systemType = sessionTypeToType(type);
            String systemType = sessionTypeToType(type);
            BaseSystemDialogSetting setting = dialogSettingDao.findBySystemTypeAndFunctionType(systemType,"7",1);
            if(setting==null){
            BaseSystemDialogSetting setting = dialogSettingDao.findBySystemTypeAndFunctionType(systemType, "7", 1);
            if (setting == null) {
                return;
                return;
            }
            }
            Boolean re = imUtil.sessionIsExist(sessionId);
            Boolean re = imUtil.sessionIsExist(sessionId);
            if(re){
            if (re) {
                //查找相似问题
                //查找相似问题
                BaseKnowledgeQuestion question = new BaseKnowledgeQuestion();
                BaseKnowledgeQuestion question = new BaseKnowledgeQuestion();
                if (contentType.equalsIgnoreCase("1")){
                if (contentType.equalsIgnoreCase("1")) {
                    question = findQuestionLikeName(content);
                    question = findQuestionLikeName(content);
                }else if ((contentType+"").equalsIgnoreCase(ImUtil.ContentType.KnowCommonQuestions.getValue()+"")){
                } else if ((contentType + "").equalsIgnoreCase(ImUtil.ContentType.KnowCommonQuestions.getValue() + "")) {
                    question = knowledgeQuestionDao.findById(content).orElse(null);
                    question = knowledgeQuestionDao.findById(content).orElse(null);
                }
                }
                if(question!=null&&StringUtils.isNotBlank(question.getAnswer())){
                if (question != null && StringUtils.isNotBlank(question.getAnswer())) {
                    //匹配到相关问题后先推送答案
                    //匹配到相关问题后先推送答案
                    String answer = question.getAnswer();
                    String answer = question.getAnswer();
                    imService.patientGuaidenceAppend(dictDO.getDictCode(),dictDO.getDictValue(),sessionId,
                            contentType+"", answer, "1",null);
                    imService.patientGuaidenceAppend(dictDO.getDictCode(), dictDO.getDictValue(), sessionId,
                            contentType + "", answer, "1", null);
                    //匹配问题是否关联其他配置;
                    //匹配问题是否关联其他配置;
                    if (question.getFlag()==null){
                    if (question.getFlag() == null) {
                        List<BaseKnowledgeFlowConfigurationRelation> flowConfigurationRelations = findFlowConfigurationRelationLikeName(content);
                        List<BaseKnowledgeFlowConfigurationRelation> flowConfigurationRelations = findFlowConfigurationRelationLikeName(content);
                        if (flowConfigurationRelations!=null&&flowConfigurationRelations.size()!=0){
                        if (flowConfigurationRelations != null && flowConfigurationRelations.size() != 0) {
                            BaseKnowledgeFlowConfigurationRelation flowConfigurationRelation = flowConfigurationRelations.get(0);
                            BaseKnowledgeFlowConfigurationRelation flowConfigurationRelation = flowConfigurationRelations.get(0);
                            String contentTypes = "1";
                            String contentTypes = "1";
                            String contentMsg = "";
                            String contentMsg = "";
                            if (flowConfigurationRelation.getRelationType().equalsIgnoreCase("2")){
                                contentTypes = ImUtil.ContentType.KnowCommonDict+"";
                                contentMsg = selectByContentType(contentTypes,flowConfigurationRelation.getRelationCode()).toJSONString();
                            }else  if (flowConfigurationRelation.getRelationType().equalsIgnoreCase("3")){
                                contentTypes = ImUtil.ContentType.KnowCommonQuestions+"";
                                contentMsg = selectByContentType(contentTypes,flowConfigurationRelation.getRelationCode()).toJSONString();
                            if (flowConfigurationRelation.getRelationType().equalsIgnoreCase("2")) {
                                contentTypes = ImUtil.ContentType.KnowCommonDict + "";
                                contentMsg = selectByContentType(contentTypes, flowConfigurationRelation.getRelationCode()).toJSONString();
                            } else if (flowConfigurationRelation.getRelationType().equalsIgnoreCase("3")) {
                                contentTypes = ImUtil.ContentType.KnowCommonQuestions + "";
                                contentMsg = selectByContentType(contentTypes, flowConfigurationRelation.getRelationCode()).toJSONString();
                            }
                            }
                            imService.patientGuaidenceAppend(dictDO.getDictCode(),dictDO.getDictValue(),sessionId,
                                    contentTypes+"", contentMsg, "1",null);
                            imService.patientGuaidenceAppend(dictDO.getDictCode(), dictDO.getDictValue(), sessionId,
                                    contentTypes + "", contentMsg, "1", null);
                        }
                        }
                    }
                    }
                }
                }
            }
            }
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
        }
        }
    }
    }
    public JSONObject selectByContentType(String contentType,String id){
    public JSONObject selectByContentType(String contentType, String id) {
        JSONObject object = new JSONObject();
        JSONObject object = new JSONObject();
        if (contentType.equalsIgnoreCase(ImUtil.ContentType.KnowCommonDict+"")){
        if (contentType.equalsIgnoreCase(ImUtil.ContentType.KnowCommonDict + "")) {
            BaseKnowledgeDict dict = knowledgeDictDao.findById(id).get();
            BaseKnowledgeDict dict = knowledgeDictDao.findById(id).get();
            BaseKnowledgeDictRelation dictRelation  = knowledgeDictRelationDao.selectByDictId(id);
            if (dictRelation!=null){
            BaseKnowledgeDictRelation dictRelation = knowledgeDictRelationDao.selectByDictId(id);
            if (dictRelation != null) {
                String dept = dictRelation.getDept();
                String dept = dictRelation.getDept();
            }
            }
            List<DictHospitalDeptDO> deptDOList = findDeptList(id);
            List<DictHospitalDeptDO> deptDOList = findDeptList(id);
            object.put("content",deptDOList);
            object.put("contentType",contentType);
            object.put("content", deptDOList);
            object.put("contentType", contentType);
        }else if (contentType.equalsIgnoreCase(ImUtil.ContentType.KnowCommonQuestions+"")){
        } else if (contentType.equalsIgnoreCase(ImUtil.ContentType.KnowCommonQuestions + "")) {
            BaseKnowledgeQuestions questions = knowledgeQuestionsDao.findById(id).get();
            BaseKnowledgeQuestions questions = knowledgeQuestionsDao.findById(id).get();
            List<BaseKnowledgeQuestionsRelation> questionsRelations = knowledgeQuestionsRelationDao.selectByQuestionsId(questions.getId());
            List<BaseKnowledgeQuestionsRelation> questionsRelations = knowledgeQuestionsRelationDao.selectByQuestionsId(questions.getId());
            object.put("content",questionsRelations);
            object.put("contentType",contentType);
            object.put("content", questionsRelations);
            object.put("contentType", contentType);
        }
        }
        return object;
        return object;
    }
    }
    public void replyContent(String session_id,String type,String content,Map<String,BaseSystemDialogSetting> mapSetting,Map<String,JSONObject> map){
    public void replyContent(String session_id, String type, String content, Map<String, BaseSystemDialogSetting> mapSetting, Map<String, JSONObject> map) {
        try {
        try {
            BaseSystemDialogSetting setting = null;
            BaseSystemDialogSetting setting = null;
            if(mapSetting==null){
                setting = dialogSettingDao.findBySystemTypeAndFunctionType(sessionTypeToType(type),"7",1);
            }else {
            if (mapSetting == null) {
                setting = dialogSettingDao.findBySystemTypeAndFunctionType(sessionTypeToType(type), "7", 1);
            } else {
                setting = mapSetting.get("7");
                setting = mapSetting.get("7");
            }
            }
            if(setting==null){
            if (setting == null) {
                return;
                return;
            }
            }
            //查找相似问题
            //查找相似问题
            BaseKnowledgeQuestion question = findQuestionLikeName(content);
            BaseKnowledgeQuestion question = findQuestionLikeName(content);
            if(question!=null){
            if (question != null) {
                String answer = question.getAnswer();
                String answer = question.getAnswer();
                JSONObject result = new JSONObject();
                JSONObject result = new JSONObject();
                result.put("content",answer);
                result.put("content_type","1");
                result.put("session_id",session_id);
                map.put("7",result);
                result.put("content", answer);
                result.put("content_type", "1");
                result.put("session_id", session_id);
                map.put("7", result);
            }
            }
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
        }
        }
    }
    }
    public void welcome(String session_id,Map<String,BaseSystemDialogSetting> mapSetting,Map<String,JSONObject> map){
    public void welcome(String session_id, Map<String, BaseSystemDialogSetting> mapSetting, Map<String, JSONObject> map) {
        try {
        try {
            Integer sessionStatus = imUtil.sessionStatus(session_id);
            Integer sessionStatus = imUtil.sessionStatus(session_id);
            System.out.println("mapSetting==="+mapSetting+"==sessionStatus=="+sessionStatus);
            if(sessionStatus==null||sessionStatus==0){
            System.out.println("session_id="+session_id);
            System.out.println("sessionStatus="+sessionStatus);
            if (sessionStatus == null || sessionStatus == 1) {
                //系统客服tip
                //系统客服tip
                JSONObject tip = new JSONObject();
                JSONObject tip = new JSONObject();
                tip.put("content","1");
                tip.put("content_type",ImUtil.ContentType.KnowCommonCustomer.getValue());
                tip.put("session_id",session_id);
                map.put("0",tip);
                tip.put("content", "1");
                tip.put("content_type", ImUtil.ContentType.KnowCommonCustomer.getValue());
                tip.put("session_id", session_id);
                map.put("0", tip);
                //欢迎语
                //欢迎语
                BaseSystemDialogSetting welcomeSetting = mapSetting.get("1");
                BaseSystemDialogSetting welcomeSetting = mapSetting.get("1");
                if(welcomeSetting!=null&&StringUtils.isNotBlank(welcomeSetting.getContent())){
                if (welcomeSetting != null && StringUtils.isNotBlank(welcomeSetting.getContent())) {
                    String welcomeContent = welcomeSetting.getContent();
                    String welcomeContent = welcomeSetting.getContent();
                    JSONObject result = new JSONObject();
                    JSONObject result = new JSONObject();
                    result.put("content",welcomeContent);
                    result.put("content_type","1");
                    result.put("session_id",session_id);
                    map.put("1",result);
                    result.put("content", welcomeContent);
                    result.put("content_type", "1");
                    result.put("session_id", session_id);
                    map.put("1", result);
                }
                }
                //欢迎消息关联问题
                //欢迎消息关联问题
                BaseSystemDialogSetting welcomeQueSetting = mapSetting.get("2");
                BaseSystemDialogSetting welcomeQueSetting = mapSetting.get("2");
                if(welcomeQueSetting!=null){
                if (welcomeQueSetting != null) {
                    Integer relaitonCodeType = welcomeQueSetting.getRelaitonCodeType();//1常见问题2字典中心3问题集
                    Integer relaitonCodeType = welcomeQueSetting.getRelaitonCodeType();//1常见问题2字典中心3问题集
                    relaitonCodeType = relaitonCodeType==null?-1:relaitonCodeType;
                    relaitonCodeType = relaitonCodeType == null ? -1 : relaitonCodeType;
                    String relationCode = welcomeQueSetting.getRelationCode();//relationType2对应业务code,多个逗号隔开
                    String relationCode = welcomeQueSetting.getRelationCode();//relationType2对应业务code,多个逗号隔开
                    if(StringUtils.isNotBlank(relationCode)){
                    if (StringUtils.isNotBlank(relationCode)) {
                        return;
                        return;
                    }
                    }
                    relationCode = relationCode.replace(",","','");
                    if(relaitonCodeType==1){
                    relationCode = relationCode.replace(",", "','");
                    if (relaitonCodeType == 1) {
                        //1常见问题
                        //1常见问题
                        JSONObject result = new JSONObject();
                        JSONObject result = new JSONObject();
                        result.put("content",relationCode);
                        result.put("content_type",ImUtil.ContentType.KnowCommonQuestion.getValue());
                        result.put("session_id",session_id);
                        map.put("2",result);
                    }else if(relaitonCodeType==2){
                        result.put("content", relationCode);
                        result.put("content_type", ImUtil.ContentType.KnowCommonQuestion.getValue());
                        result.put("session_id", session_id);
                        map.put("2", result);
                    } else if (relaitonCodeType == 2) {
                        JSONObject result = new JSONObject();
                        JSONObject result = new JSONObject();
                        result.put("content",relationCode);
                        result.put("content_type",ImUtil.ContentType.KnowCommonDict.getValue());
                        result.put("session_id",session_id);
                        map.put("2",result);
                    }else if(relaitonCodeType==3){
                        result.put("content", relationCode);
                        result.put("content_type", ImUtil.ContentType.KnowCommonDict.getValue());
                        result.put("session_id", session_id);
                        map.put("2", result);
                    } else if (relaitonCodeType == 3) {
                        JSONObject result = new JSONObject();
                        JSONObject result = new JSONObject();
                        result.put("content",relationCode);
                        result.put("content_type",ImUtil.ContentType.KnowCommonQuestions.getValue());
                        result.put("session_id",session_id);
                        map.put("2",result);
                        result.put("content", relationCode);
                        result.put("content_type", ImUtil.ContentType.KnowCommonQuestions.getValue());
                        result.put("session_id", session_id);
                        map.put("2", result);
                    }
                    }
                }
                }
            }
            }
            if(sessionStatus==1){
            System.out.println("sessionStatus==>" + sessionStatus);
            if (sessionStatus == 1) {
                //结束的会话开启
                //结束的会话开启
                imUtil.updateSessionStatus(session_id,"0");
                System.out.println("开启结束的会话");
                imUtil.updateSessionStatus(session_id, "0");
            } else {
                System.out.println("没有开启结束的会话");
            }
            }
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
        }
        }
    }
    }
    //查找常见问题
    //查找常见问题
    public BaseKnowledgeQuestion findQuestionLikeName(String content){
        if(!StringUtils.isNotEmpty(content)){
    public BaseKnowledgeQuestion findQuestionLikeName(String content) {
        if (!StringUtils.isNotEmpty(content)) {
            return null;
            return null;
        }
        }
        String sql = "select p.* from base_knowledge_question p where p.status = 1 and p.del=1 and  " +
        String sql = "select p.* from base_knowledge_question p where p.status = 1 and p.del=1 and  " +
                " (p.time=1 or (p.time=2 and p.date<'"+DateUtil.getStringDate()+"')) " +
                " and (p.question_name like '%"+content+"%' or p.similar_question_name like '"+content+"')  order by sort limit 1";
        List<BaseKnowledgeQuestion> questionList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(BaseKnowledgeQuestion.class));
        if(questionList.size()>0){
                " (p.time=1 or (p.time=2 and p.date<'" + DateUtil.getStringDate() + "')) " +
                " and (p.question_name like '%" + content + "%' or p.similar_question_name like '" + content + "')  order by sort limit 1";
        List<BaseKnowledgeQuestion> questionList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(BaseKnowledgeQuestion.class));
        if (questionList.size() > 0) {
            return questionList.get(0);
            return questionList.get(0);
        }
        }
        return null;
        return null;
    }
    }
    //查找常见问题关联配置
    //查找常见问题关联配置
    public List<BaseKnowledgeFlowConfigurationRelation> findFlowConfigurationRelationLikeName(String content){
        if(!StringUtils.isNotEmpty(content)){
    public List<BaseKnowledgeFlowConfigurationRelation> findFlowConfigurationRelationLikeName(String content) {
        if (!StringUtils.isNotEmpty(content)) {
            return null;
            return null;
        }
        }
        String sql = "select p.* from base_knowledge_flow_configuration_relation p where " +
        String sql = "select p.* from base_knowledge_flow_configuration_relation p where " +
                "  p.relation_name like '%"+content+"%'  order by sort asc ";
        List<BaseKnowledgeFlowConfigurationRelation> flowConfigurationRelations = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(BaseKnowledgeFlowConfigurationRelation.class));
                "  p.relation_name like '%" + content + "%'  order by sort asc ";
        List<BaseKnowledgeFlowConfigurationRelation> flowConfigurationRelations = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(BaseKnowledgeFlowConfigurationRelation.class));
        return flowConfigurationRelations;
        return flowConfigurationRelations;
    }
    }
    public List<BaseKnowledgeQuestions> findTopQuestionsList(Integer limit,String ids){
        String sql = "select p.* from base_knowledge_questions p where p.status = 1 and p.del=1 and p.id in ('"+ids+"')" +
                "(p.time=1 or (p.time=2 and p.date<'"+DateUtil.getStringDate()+"'))  order by sort limit "+limit;
        List<BaseKnowledgeQuestions> questionList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(BaseKnowledgeQuestions.class));
    public List<BaseKnowledgeQuestions> findTopQuestionsList(Integer limit, String ids) {
        String sql = "select p.* from base_knowledge_questions p where p.status = 1 and p.del=1 and p.id in ('" + ids + "')" +
                "(p.time=1 or (p.time=2 and p.date<'" + DateUtil.getStringDate() + "'))  order by sort limit " + limit;
        List<BaseKnowledgeQuestions> questionList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(BaseKnowledgeQuestions.class));
        return questionList;
        return questionList;
    }
    }
    public List<BaseKnowledgeQuestion> findTopQuestionList(Integer limit,String ids){
        String sql = "select p.* from base_knowledge_question p where p.status = 1 and p.del=1 and p.id in ('"+ids+"')" +
                "(p.time=1 or (p.time=2 and p.date<'"+DateUtil.getStringDate()+"'))  order by sort limit "+limit;
        List<BaseKnowledgeQuestion> questionList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(BaseKnowledgeQuestion.class));
    public List<BaseKnowledgeQuestion> findTopQuestionList(Integer limit, String ids) {
        String sql = "select p.* from base_knowledge_question p where p.status = 1 and p.del=1 and p.id in ('" + ids + "')" +
                "(p.time=1 or (p.time=2 and p.date<'" + DateUtil.getStringDate() + "'))  order by sort limit " + limit;
        List<BaseKnowledgeQuestion> questionList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(BaseKnowledgeQuestion.class));
        return questionList;
        return questionList;
    }
    }
    /**
    /**
     * 查询相关字典
     * 查询相关字典
     *
     * @param limit
     * @param limit
     * @param ids
     * @param ids
     * @return
     * @return
     */
     */
    public List<BaseKnowledgeDict> findTopDictList(Integer limit,String ids){
        String sql = "select p.* from base_knowledge_dict p where p.del=1 and p.id in ('"+ids+"') order by sort limit "+limit;
        List<BaseKnowledgeDict> dictList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(BaseKnowledgeDict.class));
    public List<BaseKnowledgeDict> findTopDictList(Integer limit, String ids) {
        String sql = "select p.* from base_knowledge_dict p where p.del=1 and p.id in ('" + ids + "') order by sort limit " + limit;
        List<BaseKnowledgeDict> dictList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(BaseKnowledgeDict.class));
        return dictList;
        return dictList;
    }
    }
    /**
    /**
     * 根据业务不一样转换相关的会话类型
     * 根据业务不一样转换相关的会话类型
     *
     * @param type
     * @param type
     * @return
     * @return
     */
     */
    //会话类型转类型
    //会话类型转类型
    public String sessionTypeToType(String type){
        if(!StringUtils.isNotEmpty(type)){
    public String sessionTypeToType(String type) {
        if (!StringUtils.isNotEmpty(type)) {
            return type;
            return type;
        }
        }
        if("18".equalsIgnoreCase(type)){
        if ("18".equalsIgnoreCase(type)) {
            return "1";
            return "1";
        }
        }
        if("26".equalsIgnoreCase(type)){
        if ("26".equalsIgnoreCase(type)) {
            return "2";
            return "2";
        }
        }
        if("27".equalsIgnoreCase(type)){
        if ("27".equalsIgnoreCase(type)) {
            return "3";
            return "3";
        }
        }
        if("1".equalsIgnoreCase(type)||"5".equalsIgnoreCase(type)||"9".equalsIgnoreCase(type)||"12".equalsIgnoreCase(type)||"15".equalsIgnoreCase(type)||"16".equalsIgnoreCase(type)){
        if ("1".equalsIgnoreCase(type) || "5".equalsIgnoreCase(type) || "9".equalsIgnoreCase(type) || "12".equalsIgnoreCase(type) || "15".equalsIgnoreCase(type) || "16".equalsIgnoreCase(type)) {
            return "4";
            return "4";
        }
        }
        return type;
        return type;
    }
    }
    public List<DictHospitalDeptDO> findDeptList(String ids){
        String sql = "select p.* from dict_hospital_dept p where p.consult_dept_flag=1 and p.code in ('"+ids+"') ";
        List<DictHospitalDeptDO> deptDOList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(DictHospitalDeptDO.class));
    public List<DictHospitalDeptDO> findDeptList(String ids) {
        String sql = "select p.* from dict_hospital_dept p where p.consult_dept_flag=1 and p.code in ('" + ids + "') ";
        List<DictHospitalDeptDO> deptDOList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(DictHospitalDeptDO.class));
        return deptDOList;
        return deptDOList;
    }
    }
}
}

+ 2 - 0
business/im-service/src/main/java/com/yihu/jw/im/util/ImUtil.java

@ -580,6 +580,8 @@ public class ImUtil {
    public Integer sessionStatus(String sessionId) {
    public Integer sessionStatus(String sessionId) {
        String url = im_host + "api/v2/sessions/isExist?session_id=" + sessionId;
        String url = im_host + "api/v2/sessions/isExist?session_id=" + sessionId;
        String ret = HttpClientUtil.get(url, "UTF-8");
        String ret = HttpClientUtil.get(url, "UTF-8");
        System.out.println("url="+url);
        System.out.println("ret="+ret);
        JSONObject obj = null;
        JSONObject obj = null;
        try {
        try {
            obj = JSON.parseObject(ret);
            obj = JSON.parseObject(ret);

+ 9 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/survey/WlyySurveyUserAnswerDO.java

@ -16,6 +16,7 @@ import java.util.Date;
public class WlyySurveyUserAnswerDO extends UuidIdentityEntity {
public class WlyySurveyUserAnswerDO extends UuidIdentityEntity {
    private String surverUserId;//答题批次号
    private String surverUserId;//答题批次号
    private String surverUserCode;//答题批次号code
    private String surveyTempCode;//问卷模板编码',
    private String surveyTempCode;//问卷模板编码',
    private String tempQuestionCode;//问答题题目编码',
    private String tempQuestionCode;//问答题题目编码',
    private Integer questionType;//
    private Integer questionType;//
@ -35,6 +36,14 @@ public class WlyySurveyUserAnswerDO extends UuidIdentityEntity {
        this.surverUserId = surverUserId;
        this.surverUserId = surverUserId;
    }
    }
    public String getSurverUserCode() {
        return surverUserCode;
    }
    public void setSurverUserCode(String surverUserCode) {
        this.surverUserCode = surverUserCode;
    }
    public String getSurveyTempCode() {
    public String getSurveyTempCode() {
        return surveyTempCode;
        return surveyTempCode;
    }
    }

+ 9 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/survey/WlyySurveyUserDO.java

@ -15,6 +15,7 @@ import java.util.Date;
@Table(name = "wlyy_survey_user")
@Table(name = "wlyy_survey_user")
public class WlyySurveyUserDO extends UuidIdentityEntity {
public class WlyySurveyUserDO extends UuidIdentityEntity {
    private String code;//新增唯一标识
    private String surveyTempCode;//问卷模板编码',
    private String surveyTempCode;//问卷模板编码',
    private String surveyTempTitle;//模板标题
    private String surveyTempTitle;//模板标题
    private String patient;//患者ID',
    private String patient;//患者ID',
@ -125,4 +126,12 @@ public class WlyySurveyUserDO extends UuidIdentityEntity {
    public void setFixDate(String fixDate) {
    public void setFixDate(String fixDate) {
        this.fixDate = fixDate;
        this.fixDate = fixDate;
    }
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
}
}

+ 1 - 1
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java

@ -2519,7 +2519,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
                return ObjEnvelop.getError("图形验证码不能为空!");
                return ObjEnvelop.getError("图形验证码不能为空!");
            }
            }
            if (!verifyCaptcha(key, text)) {
            if (!verifyCaptcha(key, text)) {
                throw new ImgCaptchaException("图形验证码错误!");
                return ObjEnvelop.getError("图形验证码错误!");
            }
            }
            Integer re = registerService.checkeMobileAndIdcard(mobile, idcard);
            Integer re = registerService.checkeMobileAndIdcard(mobile, idcard);

+ 4 - 3
svr/svr-base/src/main/java/com/yihu/jw/base/service/doctor/BaseDoctorService.java

@ -51,6 +51,7 @@ import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.annotation.Transactional;
@ -177,8 +178,6 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
            }
            }
        }
        }
        //医生归属业务模块角色信息,非必填,数据可有可没有
        //医生归属业务模块角色信息,非必填,数据可有可没有
        String[] paramNames = {"doctorCode"};
        Object[] paramValue = {doctorId};
        JSONObject jsonObject = new JSONObject();
        JSONObject jsonObject = new JSONObject();
        List<BaseTeamMemberDO> baseTeamMemberDO = baseTeamMemberDao.findUseDoctorCode(doctorId);
        List<BaseTeamMemberDO> baseTeamMemberDO = baseTeamMemberDao.findUseDoctorCode(doctorId);
        List<BaseTeamDO> teamlist = new ArrayList<>();
        List<BaseTeamDO> teamlist = new ArrayList<>();
@ -190,7 +189,8 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
            }
            }
            jsonObject.put("teamInfo",teamlist);
            jsonObject.put("teamInfo",teamlist);
        }
        }
        List<BaseDoctorRoleDO> roleList = baseDoctorRoleService.findByFields(paramNames,paramValue);
        String sql = "select * from base_doctor_role where doctor_code='"+doctorId+"' and del=1 ";
        List<BaseDoctorRoleDO> roleList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(BaseDoctorRoleDO.class));
        jsonObject.put("doctor",doctors);
        jsonObject.put("doctor",doctors);
        jsonObject.put("role",roleList);
        jsonObject.put("role",roleList);
        List<BaseDoctorHospitalDO> baseDoctorHospitalDO = baseDoctorHospitalDao.findByDoctorCode(doctorId);
        List<BaseDoctorHospitalDO> baseDoctorHospitalDO = baseDoctorHospitalDao.findByDoctorCode(doctorId);
@ -621,6 +621,7 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
                        roleIdList.remove(baseDoctorRoleDO.getId());
                        roleIdList.remove(baseDoctorRoleDO.getId());
                    }
                    }
                    baseDoctorRoleDO.setDoctorCode(baseDoctorDO.getId());
                    baseDoctorRoleDO.setDoctorCode(baseDoctorDO.getId());
                    baseDoctorRoleDO.setDel(1);
                    baseDoctorRoleService.save(baseDoctorRoleDO);
                    baseDoctorRoleService.save(baseDoctorRoleDO);
                }
                }
            } catch (IOException e) {
            } catch (IOException e) {

+ 13 - 2
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/DsyyController.java

@ -44,14 +44,25 @@ public class DsyyController extends EnvelopRestEndpoint {
                                      @RequestParam(value = "page",required = false)Integer page,
                                      @RequestParam(value = "page",required = false)Integer page,
                                      @ApiParam(name = "size", value = "分页大小", required = false)
                                      @ApiParam(name = "size", value = "分页大小", required = false)
                                      @RequestParam(value = "size",required = false)Integer size){
                                      @RequestParam(value = "size",required = false)Integer size){
        return success(dsyyEntranceService.createSQLQuery(sql,params,page,size));
        try {
            return success(dsyyEntranceService.createSQLQuery(sql,params,page,size));
        }catch (Exception e){
            e.printStackTrace();
            return ListEnvelop.getError("查询失败");
        }
    }
    }
    @GetMapping(value = "/jdbcSQLQuery")
    @GetMapping(value = "/jdbcSQLQuery")
    @ApiOperation(value = "视图统一查询")
    @ApiOperation(value = "视图统一查询")
    public ListEnvelop jdbcSQLQuery(@ApiParam(name = "sql", value = "sql语句", required = true)
    public ListEnvelop jdbcSQLQuery(@ApiParam(name = "sql", value = "sql语句", required = true)
                                      @RequestParam(value = "sql",required = true)String sql){
                                      @RequestParam(value = "sql",required = true)String sql){
        return success(dsyyEntranceService.jdbcSQLQuery(sql));
        try {
            return success(dsyyEntranceService.jdbcSQLQuery(sql));
        }catch (Exception e){
            e.printStackTrace();
            return ListEnvelop.getError("查询失败");
        }
    }
    }
    @PostMapping(value = "/registered")
    @PostMapping(value = "/registered")

+ 2 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/complaint/BaseComplaintEndPoint.java

@ -170,13 +170,14 @@ public class BaseComplaintEndPoint extends EnvelopRestEndpoint {
    public MixEnvelop findComplaintDoctorNew(
    public MixEnvelop findComplaintDoctorNew(
            @ApiParam(name = "doctorName", value = "doctorName", required = false) @RequestParam(value = "doctorName", required = false) String doctorName,
            @ApiParam(name = "doctorName", value = "doctorName", required = false) @RequestParam(value = "doctorName", required = false) String doctorName,
            @ApiParam(name = "doctor", value = "doctor", required = false) @RequestParam(value = "doctor", required = false) String doctor,
            @ApiParam(name = "doctor", value = "doctor", required = false) @RequestParam(value = "doctor", required = false) String doctor,
            @ApiParam(name = "role", value = "role", required = false) @RequestParam(value = "role", required = false) String role,
            @ApiParam(name = "deptName", value = "deptName", required = false) @RequestParam(value = "deptName", required = false) String deptName,
            @ApiParam(name = "deptName", value = "deptName", required = false) @RequestParam(value = "deptName", required = false) String deptName,
            @ApiParam(name = "complaintType", value = "complaintType", required = false) @RequestParam(value = "complaintType", required = false) String complaintType,
            @ApiParam(name = "complaintType", value = "complaintType", required = false) @RequestParam(value = "complaintType", required = false) String complaintType,
            @ApiParam(name = "page", value = "page", required = false) @RequestParam(value = "page", required = false) Integer page,
            @ApiParam(name = "page", value = "page", required = false) @RequestParam(value = "page", required = false) Integer page,
            @ApiParam(name = "pageSize", value = "pageSize", required = false) @RequestParam(value = "pageSize", required = false) Integer pageSize
            @ApiParam(name = "pageSize", value = "pageSize", required = false) @RequestParam(value = "pageSize", required = false) Integer pageSize
    ) throws Exception {
    ) throws Exception {
        try {
        try {
            return baseComplaintService.findComplaintDoctorNew(doctor, doctorName, deptName, complaintType, page, pageSize);
            return baseComplaintService.findComplaintDoctorNew(doctor, doctorName,role, deptName, complaintType, page, pageSize);
        } catch (Exception e) {
        } catch (Exception e) {
            return failedMixEnvelopException(e);
            return failedMixEnvelopException(e);
        }
        }

+ 1 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java

@ -1075,6 +1075,7 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
			if ("sd_tnzyy_wx".equalsIgnoreCase(wxId)){
			if ("sd_tnzyy_wx".equalsIgnoreCase(wxId)){
				result.put("doorServiceCount",prescriptionService.waitUpdoorCount(doctor));//上门服务数量
				result.put("doorServiceCount",prescriptionService.waitUpdoorCount(doctor));//上门服务数量
			}
			}
			result.put("waitRoomCount",prescriptionService.getWaitRoomCount(doctor));//待接诊数量
			logger.info("action:doctorReviewConsultCount--end:"+DateUtil.dateToStrLong(new Date()));
			logger.info("action:doctorReviewConsultCount--end:"+DateUtil.dateToStrLong(new Date()));
			return success("请求成功",result);
			return success("请求成功",result);
		}catch (Exception e){
		}catch (Exception e){

+ 6 - 7
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/PatientConsultEndpoint.java

@ -1,5 +1,6 @@
package com.yihu.jw.hospital.endpoint.consult;
package com.yihu.jw.hospital.endpoint.consult;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
@ -877,18 +878,16 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
    @PostMapping(value = "robotWelcome")
    @PostMapping(value = "robotWelcome")
    @ApiOperation(value = "居民导诊欢迎语", notes = "居民导诊欢迎语")
    @ApiOperation(value = "居民导诊欢迎语", notes = "居民导诊欢迎语")
    public Envelop robotWelcome(
    public Envelop robotWelcome(
            @ApiParam(name = "sender_id", value = "居民id", defaultValue = "")
            @RequestParam(value = "sender_id", required = true) String sender_id,
            @ApiParam(name = "session_id", value = "session_id", defaultValue = "")
            @RequestParam(value = "session_id", required = false) String session_id,
            @ApiParam(name = "type", value = "咨询type", defaultValue = "")
            @RequestParam(value = "type", required = false) String type
            @ApiParam(name = "sender_id", value = "居民id", defaultValue = "") @RequestParam(value = "sender_id", required = true) String sender_id,
            @ApiParam(name = "session_id", value = "session_id", defaultValue = "") @RequestParam(value = "session_id", required = false) String session_id,
            @ApiParam(name = "type", value = "咨询type", defaultValue = "") @RequestParam(value = "type", required = false) String type
    ) {
    ) {
        try {
        try {
            System.out.println("sender_id[居民id]==>" + sender_id + "   session_id==>" + session_id);
            Map<String, JSONObject> map = robotService.robotReply(session_id, type, null);
            Map<String, JSONObject> map = robotService.robotReply(session_id, type, null);
            imService.getPatientGuaidenceConsult(sender_id, session_id, type);
            imService.getPatientGuaidenceConsult(sender_id, session_id, type);
            robotService.sendReplyMap(map);
            robotService.sendReplyMap(map);
            return Envelop.getSuccess("success");
            return Envelop.getSuccess(JSON.toJSONString(map));
        } catch (Exception e) {
        } catch (Exception e) {
            return failedException(e);
            return failedException(e);
        }
        }

+ 5 - 4
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/hospital/WlyyFamilyMemberController.java

@ -106,6 +106,7 @@ public class WlyyFamilyMemberController extends EnvelopRestEndpoint {
            }
            }
        }*/
        }*/
        net.sf.json.JSONArray jsonArray = new JSONArray();
        net.sf.json.JSONArray jsonArray = new JSONArray();
        com.alibaba.fastjson.JSONArray jsonArrayDsyy = new com.alibaba.fastjson.JSONArray();
        if("xm_ykyy_wx".equalsIgnoreCase(wxId)){
        if("xm_ykyy_wx".equalsIgnoreCase(wxId)){
            /*jsonArray = ykyyEntranceService.findHisPatientBymMedicare(medicare,clinicId,false);
            /*jsonArray = ykyyEntranceService.findHisPatientBymMedicare(medicare,clinicId,false);
            if(jsonArray!=null&&jsonArray.size()>0){
            if(jsonArray!=null&&jsonArray.size()>0){
@ -163,9 +164,9 @@ public class WlyyFamilyMemberController extends EnvelopRestEndpoint {
            JSONObject object = dsyyPrescriptionService.queryCardListToHospital("",idCard);
            JSONObject object = dsyyPrescriptionService.queryCardListToHospital("",idCard);
            if (object!=null){
            if (object!=null){
                if (object.getString("retCode").equalsIgnoreCase("00")){
                if (object.getString("retCode").equalsIgnoreCase("00")){
                    com.alibaba.fastjson.JSONArray array = object.getJSONArray("cardlist");
                    if(array!=null&&array.size()>0){
                        JSONObject jsonObject= array.getJSONObject(0);
                    jsonArrayDsyy = object.getJSONArray("cardlist");
                    if(jsonArrayDsyy!=null&&jsonArrayDsyy.size()>0){
                        JSONObject jsonObject= jsonArrayDsyy.getJSONObject(0);
                        String Pat_name = jsonObject.getString("userName");
                        String Pat_name = jsonObject.getString("userName");
                        String Next_Of_Kin_Phone = jsonObject.getString("phone");
                        String Next_Of_Kin_Phone = jsonObject.getString("phone");
                        if(!Next_Of_Kin_Phone.equalsIgnoreCase(phoneNum)){
                        if(!Next_Of_Kin_Phone.equalsIgnoreCase(phoneNum)){
@ -252,7 +253,7 @@ public class WlyyFamilyMemberController extends EnvelopRestEndpoint {
            }else if("xm_dsyy_wx".equalsIgnoreCase(wxId)){
            }else if("xm_dsyy_wx".equalsIgnoreCase(wxId)){
                System.out.println("发送第三医院验证码开始");
                System.out.println("发送第三医院验证码开始");
                int result = 1;
                int result = 1;
                if (null!=jsonArray&&jsonArray.size() > 0) {
                if (null!=jsonArrayDsyy&&jsonArrayDsyy.size() > 0) {
                    result = dsyyPrescriptionService.SendSms(phoneNum, "您好,您当前操作的验证码是:" + captcha + ",2分钟内有效。如非本人操作,请忽略");
                    result = dsyyPrescriptionService.SendSms(phoneNum, "您好,您当前操作的验证码是:" + captcha + ",2分钟内有效。如非本人操作,请忽略");
                } else {
                } else {
                    result = 2;
                    result = 2;

+ 3 - 4
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/integrate/BaseHospitalGoodsController.java

@ -2,16 +2,13 @@ package com.yihu.jw.hospital.endpoint.integrate;
import com.yihu.jw.entity.hospital.integrate.BaseHospitalGoodsDO;
import com.yihu.jw.entity.hospital.integrate.BaseHospitalGoodsDO;
import com.yihu.jw.entity.hospital.integrate.BaseHospitalMedalDO;
import com.yihu.jw.hospital.integrate.service.BaseHospitalGoodsService;
import com.yihu.jw.hospital.integrate.service.BaseHospitalGoodsService;
import com.yihu.jw.hospital.integrate.service.BaseHospitalMedalService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiParam;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.*;
@ -125,12 +122,14 @@ public class BaseHospitalGoodsController extends EnvelopRestEndpoint {
                                     @RequestParam(value = "name", required = false) String name,
                                     @RequestParam(value = "name", required = false) String name,
                                     @ApiParam(name = "user", value = "用户编码", required = false)
                                     @ApiParam(name = "user", value = "用户编码", required = false)
                                     @RequestParam(value = "user", required = false) String user,
                                     @RequestParam(value = "user", required = false) String user,
                                     @ApiParam(name = "type", value = "类型", required = false)
                                     @RequestParam(value = "type", required = false) String type,
                                     @ApiParam(name = "startTime", value = "开始时间", required = false)
                                     @ApiParam(name = "startTime", value = "开始时间", required = false)
                                     @RequestParam(value = "startTime", required = false) String startTime,
                                     @RequestParam(value = "startTime", required = false) String startTime,
                                     @ApiParam(name = "endTime", value = "结束时间", required = false)
                                     @ApiParam(name = "endTime", value = "结束时间", required = false)
                                     @RequestParam(value = "endTime", required = false) String endTime) {
                                     @RequestParam(value = "endTime", required = false) String endTime) {
        try {
        try {
            return success(hospitalGoodsService.selectGoodsExchageByCondition(name,user,startTime,endTime,page,size));
            return success(hospitalGoodsService.selectGoodsExchageByCondition(name,user,type,startTime,endTime,page,size));
        }catch (Exception e){
        }catch (Exception e){
            return failedException(e);
            return failedException(e);
        }
        }

+ 3 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java

@ -2022,11 +2022,13 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
                                          @RequestParam(value = "orgCode", required = true)String orgCode,
                                          @RequestParam(value = "orgCode", required = true)String orgCode,
                                          @ApiParam(name = "dept", value = "需要置顶部门")
                                          @ApiParam(name = "dept", value = "需要置顶部门")
                                          @RequestParam(value = "dept", required = false)String dept,
                                          @RequestParam(value = "dept", required = false)String dept,
                                          @ApiParam(name = "consultDeptFlag", value = "是否咨询科室")
                                          @RequestParam(value = "consultDeptFlag", required = false)String consultDeptFlag,
                                          @ApiParam(name = "deptType", value = "门诊和病区标识")
                                          @ApiParam(name = "deptType", value = "门诊和病区标识")
                                          @RequestParam(value = "deptType", required = false)String deptType) {
                                          @RequestParam(value = "deptType", required = false)String deptType) {
        try {
        try {
            return success(prescriptionService.findInDeptByHospital(orgCode,dept,deptType));
            return success(prescriptionService.findInDeptByHospital(orgCode,dept,deptType,consultDeptFlag));
        }catch (Exception e) {
        }catch (Exception e) {
            return failedListEnvelopException2(e);
            return failedListEnvelopException2(e);
        }
        }

+ 13 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java

@ -453,6 +453,7 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                return ListEnvelop.getError("暂未开放");
                return ListEnvelop.getError("暂未开放");
            }
            }
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return failedListEnvelopException(e);
            return failedListEnvelopException(e);
        }
        }
    }
    }
@ -1129,6 +1130,17 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        }
        }
    }
    }
    @GetMapping(value = "doctorIndexStatis")
    @ApiOperation(value = "医生首页统计", notes = "医生首页统计")
    public ObjEnvelop doctorIndexStatis(@ApiParam(name = "doctor", value = "医生code")
                                     @RequestParam(value = "doctor", required = true) String doctor) {
        try {
            return success(prescriptionService.doctorIndexStatis(doctor));
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    @GetMapping(value = "setXcxQrCode")
    @GetMapping(value = "setXcxQrCode")
    @ApiOperation(value = "生成医生小程序二维码")
    @ApiOperation(value = "生成医生小程序二维码")
    public Envelop setXcxQrCode(@ApiParam(name = "doctor", value = "doctor", required = false)
    public Envelop setXcxQrCode(@ApiParam(name = "doctor", value = "doctor", required = false)
@ -3795,6 +3807,7 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        try {
        try {
            return success("操作成功", dsyyPrescriptionService.queryDayDetailListToHospital(iptNo,patientId,beginDate,endDate));
            return success("操作成功", dsyyPrescriptionService.queryDayDetailListToHospital(iptNo,patientId,beginDate,endDate));
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
        }
    }
    }

+ 4 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/survey/SurveyEndpoint.java

@ -261,9 +261,11 @@ public class SurveyEndpoint extends EnvelopRestEndpoint {
                                                  @ApiParam(name = "tempId", value = "模板id")
                                                  @ApiParam(name = "tempId", value = "模板id")
                                                  @RequestParam(value = "tempId",required = true)String tempId,
                                                  @RequestParam(value = "tempId",required = true)String tempId,
                                                  @ApiParam(name = "surverUserId", value = "答题批次号")
                                                  @ApiParam(name = "surverUserId", value = "答题批次号")
                                                  @RequestParam(value = "surverUserId",required = false)String surverUserId)throws Exception {
                                                  @RequestParam(value = "surverUserId",required = false)String surverUserId,
                                                  @ApiParam(name = "surverUserCode", value = "答题批次号code")
                                                  @RequestParam(value = "surverUserCode",required = false)String surverUserCode)throws Exception {
        try {
        try {
            return success(surveyService.findAnswerBySurveyTempCode(surverUserId,patient,tempId));
            return success(surveyService.findAnswerBySurveyTempCode(surverUserId,surverUserCode,patient,tempId));
        }catch (Exception e) {
        }catch (Exception e) {
            return failedListEnvelopException(e);
            return failedListEnvelopException(e);
        }
        }

+ 5 - 5
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/consult/BasePatientBusinessService.java

@ -1,14 +1,14 @@
package com.yihu.jw.hospital.service.consult;
package com.yihu.jw.hospital.service.consult;
import com.yihu.jw.article.dao.KnowledgeArticleDictDao;
import com.yihu.jw.article.dao.KnowledgeArticleUserDao;
import com.yihu.jw.article.dao.KnowledgeArticleUserDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientBusinessDO;
import com.yihu.jw.entity.base.patient.BasePatientBusinessDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDictDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleUserDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleUserDO;
import com.yihu.jw.entity.hospital.survey.WlyySurveyTemplateDO;
import com.yihu.jw.entity.hospital.survey.WlyySurveyTemplateDO;
import com.yihu.jw.hospital.dao.consult.KnowledgeArticleDao;
import com.yihu.jw.hospital.survey.dao.SurveyTemplateDao;
import com.yihu.jw.hospital.survey.dao.SurveyTemplateDao;
import com.yihu.jw.hospital.survey.service.SurveyService;
import com.yihu.jw.hospital.survey.service.SurveyService;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.mysql.query.BaseJpaService;
@ -35,7 +35,7 @@ public class BasePatientBusinessService extends BaseJpaService<BasePatientBusine
	@Autowired
	@Autowired
	private BasePatientBusinessDao patientBusinessDao;
	private BasePatientBusinessDao patientBusinessDao;
	@Autowired
	@Autowired
	private KnowledgeArticleDao knowledgeArticleDao;
	private KnowledgeArticleDictDao knowledgeArticleDao;
	@Autowired
	@Autowired
	private KnowledgeArticleUserDao knowledgeArticleUserDao;
	private KnowledgeArticleUserDao knowledgeArticleUserDao;
	@Autowired
	@Autowired
@ -55,8 +55,8 @@ public class BasePatientBusinessService extends BaseJpaService<BasePatientBusine
	 * @param status
	 * @param status
	 * @return
	 * @return
	 */
	 */
	public KnowledgeArticleDO setCollectionById(String id,Integer flag,Integer status,String user,String userType){
		KnowledgeArticleDO knowledgeArticleDO = knowledgeArticleDao.findByIdAndDel(id);
	public KnowledgeArticleDictDO setCollectionById(String id,Integer flag,Integer status,String user,String userType){
		KnowledgeArticleDictDO knowledgeArticleDO = knowledgeArticleDao.findByIdAndDel(id);
		KnowledgeArticleUserDO knowledgeArticleUserDO =knowledgeArticleUserDao.findByrelationCodeAndUserAndDel(id,user);
		KnowledgeArticleUserDO knowledgeArticleUserDO =knowledgeArticleUserDao.findByrelationCodeAndUserAndDel(id,user);
		if (knowledgeArticleUserDO==null){
		if (knowledgeArticleUserDO==null){
			knowledgeArticleUserDO = new KnowledgeArticleUserDO();
			knowledgeArticleUserDO = new KnowledgeArticleUserDO();

+ 1 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/consult/KnowledgeArticleService.java

@ -323,6 +323,7 @@ public class KnowledgeArticleService extends BaseJpaService<KnowledgeArticleDO,
                        object.put("doctor", patientBusinessDO.getDoctor());
                        object.put("doctor", patientBusinessDO.getDoctor());
                        object.put("doctorName", patientBusinessDO.getDoctorName());
                        object.put("doctorName", patientBusinessDO.getDoctorName());
                        object.put("id", wlyySurveyTemplateDO.getId());
                        object.put("id", wlyySurveyTemplateDO.getId());
                        object.put("surverUserCode", UUID.randomUUID().toString());
                    }
                    }
                    imUtil.sendImMsg(patientBusinessDO.getDoctor(), patientBusinessDO.getDoctorName(), patientBusinessDO.getSessionId(), "17", object.toJSONString(), "1", null);
                    imUtil.sendImMsg(patientBusinessDO.getDoctor(), patientBusinessDO.getDoctorName(), patientBusinessDO.getSessionId(), "17", object.toJSONString(), "1", null);
                }
                }