Quellcode durchsuchen

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

wangzhinan vor 1 Jahr
Ursprung
Commit
15148c3d57
50 geänderte Dateien mit 3364 neuen und 1261 gelöschten Zeilen
  1. 98 0
      business/base-service/src/main/java/com/yihu/jw/common/CommonSmsService.java
  2. 11 0
      business/base-service/src/main/java/com/yihu/jw/common/dao/BaseSequenceDao.java
  3. 3 0
      business/base-service/src/main/java/com/yihu/jw/hospital/dict/WlyyHospitalSysDictDao.java
  4. 12 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/BaseNatItemDao.java
  5. 3 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/PrescriptionExpressageDao.java
  6. 176 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/NatService.java
  7. 65 8
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionExpressageService.java
  8. 6 10
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  9. 20 18
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/util/SFUtils.java
  10. 155 0
      business/base-service/src/main/java/com/yihu/jw/hospital/record/service/HospitalPatientInpatientRecordService.java
  11. 11 0
      business/base-service/src/main/java/com/yihu/jw/hospital/suggest/service/BaseSuggestionService.java
  12. 12 0
      business/base-service/src/main/java/com/yihu/jw/patient/dao/BaseMedicalRecordCopyingApplyDao.java
  13. 18 0
      business/base-service/src/main/java/com/yihu/jw/patient/dao/BaseMedicalRecordCopyingApplyTypeDao.java
  14. 1 1
      business/base-service/src/main/java/com/yihu/jw/wlyy/service/WlyyBusinessService.java
  15. 1 3
      business/base-service/src/main/java/com/yihu/jw/wlyy/wlyyhttp/WlyyHttpService.java
  16. 9 5
      business/es-service/src/main/java/com/yihu/jw/es/service/StatisticsEsService.java
  17. 172 0
      common/common-entity/src/db/2023.sql
  18. 8 0
      common/common-entity/src/db/达梦数据库.txt
  19. 18 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/common/BaseSequence.java
  20. 22 1
      common/common-entity/src/main/java/com/yihu/jw/entity/base/org/BaseOrgDO.java
  21. 380 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BaseMedicalRecordCopyingApplyDO.java
  22. 58 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BaseMedicalRecordCopyingApplyTypeDO.java
  23. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServiceItemPlanDO.java
  24. 105 56
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/BaseNatAppointmentDO.java
  25. 158 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/BaseNatItemDO.java
  26. 20 1
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyOutpatientExpressageLogDO.java
  27. 21 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyPrescriptionExpressageDO.java
  28. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/suggest/BaseSuggestionDO.java
  29. 5 20
      gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/BasicZuulFilter.java
  30. 1 1
      server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java
  31. 24 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/exception/PwdException.java
  32. 7 1
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/core/redis/WlyyRedisVerifyCodeService.java
  33. 78 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/WlyyTokenGranter.java
  34. 19 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  35. 2 0
      starter/elasticsearch-starter/src/main/java/com/yihu/jw/elasticsearch/ElasticSearch7Pool.java
  36. 5 10
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/dict/DictJobTitleEndpoint.java
  37. 268 2
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/archives/MedicalRecordCopyingEndpoint.java
  38. 17 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/article/BaseMenuNoLoginEndpoint.java
  39. 11 6
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java
  40. 896 922
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/PatientConsultEndpoint.java
  41. 92 9
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/expressage/ExpressageEndpoint.java
  42. 15 4
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/hospital/BaseSuggestionController.java
  43. 141 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/NatEndpoint.java
  44. 26 27
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/statistics/EsStatisticsEndpoint.java
  45. 17 9
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/consult/KnowledgeArticleService.java
  46. 4 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/door/service/DoorOrderService.java
  47. 17 10
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/door/service/WlyyDoorServiceOrderService.java
  48. 9 9
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/PatientDeviceController.java
  49. 0 1
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/PatientHealthIndexService.java
  50. 145 125
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/service/RehabilitationManageService.java

+ 98 - 0
business/base-service/src/main/java/com/yihu/jw/common/CommonSmsService.java

@ -0,0 +1,98 @@
package com.yihu.jw.common;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.restmodel.web.MixEnvelop;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.util.concurrent.TimeUnit;
/**
 * Created by yeshijie on 2023/12/26.
 */
@Service
public class CommonSmsService {
    @Autowired
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
    @Autowired
    private RedisTemplate redisTemplate;
    //通用发送短信接口
    public MixEnvelop sendSms(String client_id,String phoneNum,Integer expire,String type,MixEnvelop mixEnvelop){
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findOneByDictNameAndDictCode("isNeedSMS","isNeedSMS");
        if (wlyyHospitalSysDictDO!=null&&!StringUtils.isEmpty(wlyyHospitalSysDictDO.getDictValue())){
            String captcha = wlyyHospitalSysDictDO.getDictValue();
            store(client_id, phoneNum, captcha, expire,type);
            mixEnvelop.setMessage("验证码发送成功");
        }else {
            String captcha = getCodeNumber();
            System.out.println("=====================当前短信验证码============="+captcha+"=====================");
            System.out.println("发送174医院验证码开始");
            int result = 1;
//                result = zhongShanSMSService.ZhongShangSendSMS(phoneNum, "您好,您当前操作的验证码是:" + captcha + ",5分钟内有效。如非本人操作,请忽略");
            if (0 == result) {
                store(client_id, phoneNum, captcha, expire,type);
                mixEnvelop.setMessage("验证码发送成功");
            } else {
                mixEnvelop.setMessage("验证码发送失败");
                mixEnvelop.setStatus(500);
            }
        }
        return mixEnvelop;
    }
    public void store(String client_id, String username, String code, int expire,String type) {
        String key = client_id + ":" + username + "_"+type;
        redisTemplate.opsForValue().set(key, code);
        redisTemplate.expire(key, expire, TimeUnit.SECONDS);
        String intervalKey = key + ":" + code + "_interval";
        redisTemplate.opsForValue().set(intervalKey, 60);
        redisTemplate.expire(intervalKey, 60, TimeUnit.SECONDS);
    }
    public boolean isIntervalTimeout(String client_id, String username,String type) {
        String key = client_id + ":" + username + "_"+type;
        String code = (String) redisTemplate.opsForValue().get(key);
        if (null == code) {
            return true;
        }
        String intervalKey = key + ":" + code + "_interval";
        if (redisTemplate.opsForValue().get(intervalKey) != null) {
            return false;
        }
        return true;
    }
    //生成6位随机数
    public String getCodeNumber() {
        return (int) ((Math.random() * 9 + 1) * 100000) + "";
    }
    //验证验证码
    public boolean verification(String client_id, String username, String code,String type) {
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("isNeedSMS").orElse(null);
        if (wlyyHospitalSysDictDO!=null&&!StringUtils.isEmpty(wlyyHospitalSysDictDO.getDictValue())){
            if (code.equalsIgnoreCase(wlyyHospitalSysDictDO.getDictValue())){
                return true;
            }else {
                return false;
            }
        }
        if (StringUtils.isEmpty(code)) {
            return false;
        }
        String key = client_id + ":" + username + "_"+type;
        String _code = (String) redisTemplate.opsForValue().get(key);
        if (null == _code) {
            return false;
        }
        if (code.equalsIgnoreCase(_code)) {
            return true;
        }
        return false;
    }
}

+ 11 - 0
business/base-service/src/main/java/com/yihu/jw/common/dao/BaseSequenceDao.java

@ -0,0 +1,11 @@
package com.yihu.jw.common.dao;
import com.yihu.jw.entity.base.common.BaseSequence;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
 * Created by yeshijie on 2023/12/27.
 */
public interface BaseSequenceDao extends JpaRepository<BaseSequence, Long>, JpaSpecificationExecutor<BaseSequence> {
}

+ 3 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/dict/WlyyHospitalSysDictDao.java

@ -21,6 +21,9 @@ public interface WlyyHospitalSysDictDao extends JpaRepository<WlyyHospitalSysDic
    @Query("from WlyyHospitalSysDictDO where dictName = ?1  and  dictCode is null order by sort asc")
    List<WlyyHospitalSysDictDO> findByDictNameNotNull(String dictName);
    @Query("from WlyyHospitalSysDictDO where dictName = ?1  and  dictCode is not null order by sort asc")
    List<WlyyHospitalSysDictDO> findByDictNameSort(String dictName);
    @Query("from WlyyHospitalSysDictDO where dictName = ?1 ")
    List<WlyyHospitalSysDictDO> findByDictName(String dictName);
    @Query("from WlyyHospitalSysDictDO where 1=1")

+ 12 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/BaseNatItemDao.java

@ -0,0 +1,12 @@
package com.yihu.jw.hospital.prescription.dao;
import com.yihu.jw.entity.hospital.prescription.BaseNatItemDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
 * Created by yeshijie on 2023/12/28.
 */
public interface BaseNatItemDao extends JpaRepository<BaseNatItemDO, String>, JpaSpecificationExecutor<BaseNatItemDO> {
}

+ 3 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/PrescriptionExpressageDao.java

@ -19,6 +19,9 @@ public interface PrescriptionExpressageDao extends JpaRepository<WlyyPrescriptio
    @Query("from WlyyPrescriptionExpressageDO p where p.outpatientId=?1 order by p.createTime desc")
    List<WlyyPrescriptionExpressageDO> findByOutpatientId(String outpatientId);
    @Query("from WlyyPrescriptionExpressageDO p where p.relationCode=?1 and p.relationType=?2 order by p.createTime desc")
    List<WlyyPrescriptionExpressageDO> findByRelationCode(String relationCode,String relationType);
    @Modifying
    @Query("update WlyyPrescriptionExpressageDO p set p.mailno=?2  where p.id=?1")
    void updateMailNoById(String id, String mailno);

+ 176 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/NatService.java

@ -0,0 +1,176 @@
package com.yihu.jw.hospital.prescription.service;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.prescription.BaseNatAppointmentDO;
import com.yihu.jw.entity.hospital.prescription.BaseNatItemDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.prescription.dao.BaseNatAppointmentDao;
import com.yihu.jw.hospital.prescription.dao.BaseNatItemDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.common.IdCardUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
 * Created by yeshijie on 2023/12/28.
 */
@Service
public class NatService {
    @Autowired
    private BaseNatItemDao natItemDao;
    @Autowired
    private BaseNatAppointmentDao natAppointmentDao;
    @Autowired
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private BasePatientDao patientDao;
    //新增或修改医技预约项目
    public BaseNatItemDO createOrUpd(String jsonData){
        BaseNatItemDO natItemDO = JSONObject.parseObject(jsonData,BaseNatItemDO.class);
        if(StringUtils.isNotBlank(natItemDO.getId())){
            //修改
            BaseNatItemDO natItemOld = natItemDao.findById(natItemDO.getId()).orElse(null);
            natItemDO.setCreateTime(natItemOld.getCreateTime());
            natItemDO = natItemDao.save(natItemDO);
        }else {
            //新增
            natItemDO.setCreateTime(new Date());
            natItemDO = natItemDao.save(natItemDO);
        }
        return natItemDO;
    }
    //获取医技预约项目详情
    public BaseNatItemDO findDetailById(String id){
        BaseNatItemDO natItemDO = natItemDao.findById(id).orElse(null);
        if(natItemDO!=null){
            WlyyHospitalSysDictDO dictDO = wlyyHospitalSysDictDao.findOneByDictNameAndDictCode("isEffect",natItemDO.getStatus());
            natItemDO.setStatusName(dictDO.getDictValue());
        }
        return natItemDO;
    }
    //修改状态
    public BaseNatItemDO updStatus(String id,String status){
        BaseNatItemDO natItemDO = natItemDao.findById(id).orElse(null);
        natItemDO.setStatus(status);
        return natItemDO;
    }
    //医技预约项目分页
    public PageEnvelop natItemPage(String name,String status,String suitableCrowd,Integer page,Integer size){
        String sql = "select * ";
        String countSql = "select count(*) ";
        String filter = " from base_nat_item where 1=1 ";
        if(StringUtils.isNotBlank(name)){
            filter += " and name like '%"+name+"%'";
        }
        if(StringUtils.isNotBlank(status)){
            filter += " and status = '"+status+"'";
        }
        if(StringUtils.isNotBlank(suitableCrowd)){
            filter += " and suitable_crowd like '%"+suitableCrowd+"%'";
        }
        String orderBy = " order by create_time desc limit "+(page-1)*size+","+size;
        List<BaseNatItemDO> list = jdbcTemplate.query(sql+filter+orderBy,new BeanPropertyRowMapper<>(BaseNatItemDO.class));
        List<WlyyHospitalSysDictDO> dictDOList =  wlyyHospitalSysDictDao.findByDictName("isEffect");
        Map<String,String> isEffectMap = dictDOList.stream().collect(Collectors.toMap(WlyyHospitalSysDictDO::getDictCode,WlyyHospitalSysDictDO::getDictValue));
        List<WlyyHospitalSysDictDO> time_type =  wlyyHospitalSysDictDao.findByDictName("time_type");
        Map<String,String> timeTypeMap = time_type.stream().collect(Collectors.toMap(WlyyHospitalSysDictDO::getDictCode,WlyyHospitalSysDictDO::getDictValue));
        list.stream().forEach(one->{
            one.setStatusName(isEffectMap.get(one.getStatus()));
            one.setTimeTypeName(timeTypeMap.get(one.getTimeType()));
        });
        Long count = jdbcTemplate.queryForObject(countSql+filter,Long.class);
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,size,count);
    }
    //核酸预约记录分页
    public PageEnvelop natAppointmentPage(String name,String payStatus,String merchantOrderNo,String invoiceSerialNo,String medicare,String cardNo
            ,String createTimeStart,String createTimeEnd,String appointmentTimeStart,String appointmentTimeEnd,Integer page,Integer size){
        String sql = "select * ";
        String countSql = "select count(*) ";
        String filter = " from base_nat_appointment where 1=1 ";
        if(StringUtils.isNotBlank(name)){
            filter += " and name like '%"+name+"%'";
        }
        if(StringUtils.isNotBlank(payStatus)){
            filter += " and pay_status = '"+payStatus+"'";
        }
        if(StringUtils.isNotBlank(merchantOrderNo)){
            filter += " and merchant_order_no like '%"+merchantOrderNo+"%'";
        }
        if(StringUtils.isNotBlank(invoiceSerialNo)){
            filter += " and invoice_serial_no like '%"+invoiceSerialNo+"%'";
        }
        if(StringUtils.isNotBlank(medicare)){
            filter += " and medicare like '%"+medicare+"%'";
        }
        if(StringUtils.isNotBlank(cardNo)){
            filter += " and card_no like '%"+cardNo+"%'";
        }
        if(StringUtils.isNotBlank(createTimeStart)){
            filter += " and create_time >= '"+createTimeStart+"'";
        }
        if(StringUtils.isNotBlank(createTimeEnd)){
            filter += " and create_time <= '"+createTimeEnd+"'";
        }
        if(StringUtils.isNotBlank(appointmentTimeStart)){
            filter += " and appointment_time >= '"+appointmentTimeStart+"'";
        }
        if(StringUtils.isNotBlank(appointmentTimeEnd)){
            filter += " and appointment_time <= '"+appointmentTimeEnd+"'";
        }
        String orderBy = " order by id desc limit "+(page-1)*size+","+size;
        List<BaseNatAppointmentDO> list = jdbcTemplate.query(sql+filter+orderBy,new BeanPropertyRowMapper<>(BaseNatAppointmentDO.class));
        List<WlyyHospitalSysDictDO> dictDOList =  wlyyHospitalSysDictDao.findByDictName("PRESCRIPTION_PAY_STATUS");
        Map<String,String> statusMap = dictDOList.stream().collect(Collectors.toMap(WlyyHospitalSysDictDO::getDictCode,WlyyHospitalSysDictDO::getDictValue));
        list.stream().forEach(one->{
            one.setPayStatusName(statusMap.get(one.getPayStatus()));
        });
        Long count = jdbcTemplate.queryForObject(countSql+filter,Long.class);
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,size,count);
    }
    //核酸预约记录详情
    public BaseNatAppointmentDO natAppointmentDetail(Integer id){
        BaseNatAppointmentDO appointmentDO = natAppointmentDao.findById(id).orElse(null);
        WlyyHospitalSysDictDO dictDO = wlyyHospitalSysDictDao.findOneByDictNameAndDictCode("PRESCRIPTION_PAY_STATUS",appointmentDO.getPayStatus());
        appointmentDO.setPayStatusName(dictDO.getDictValue());
        BasePatientDO patientDO = patientDao.findById(appointmentDO.getPatientId()).orElse(null);
        if(patientDO!=null){
            String sex = "未知";
            if(patientDO.getSex()==null){
                sex = "未知";
            }else if(patientDO.getSex() == 1){
                sex = "男";
            }else if(patientDO.getSex() == 2){
                sex = "女";
            }
            appointmentDO.setSex(sex);
            appointmentDO.setAge(IdCardUtil.getAgeByBirthdayOrIdcard(patientDO.getIdcard(),patientDO.getBirthday())+"");
        }
        return appointmentDO;
    }
}

+ 65 - 8
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionExpressageService.java

@ -3,11 +3,13 @@ package com.yihu.jw.hospital.prescription.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.patient.BaseMedicalRecordCopyingApplyDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.hospital.prescription.*;
import com.yihu.jw.hospital.prescription.dao.*;
import com.yihu.jw.hospital.prescription.service.entrance.util.SFUtils;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.patient.dao.BaseMedicalRecordCopyingApplyDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.sfutils.HttpClientUtils;
@ -90,6 +92,8 @@ public class PrescriptionExpressageService extends BaseJpaService<WlyyPrescripti
    private PrescriptionLogDao prescriptionLogDao;
    @Autowired
    PrescriptionService prescriptionService;
    @Autowired
    private BaseMedicalRecordCopyingApplyDao medicalRecordCopyingApplyDao;
    private PrescriptionExpressageService(){}
@ -99,6 +103,9 @@ public class PrescriptionExpressageService extends BaseJpaService<WlyyPrescripti
        this.sf_check_word = sf_check_word;
    }
    public List<WlyyPrescriptionExpressageDO> findByRelationCode(String relationCode,String relationType){
        return prescriptionExpressageDao.findByRelationCode(relationCode, relationType);
    }
    /**
     * 组装请求参数,发送请求
@ -200,6 +207,53 @@ public class PrescriptionExpressageService extends BaseJpaService<WlyyPrescripti
    }
    /**
     * 向顺丰快递下订单
     * @param sfexpress_obj
     * @return
     * @throws Exception
     */
    public WlyyPrescriptionExpressageDO postSFOrderServiceCommon(WlyyPrescriptionExpressageDO sfexpress_obj) throws Exception {
        //获取医生所处的医院详细地址,作为寄件人地址
        String orgId = "";
        String patientId = "";
        String depositumInfo = "";
        if("1".equals(sfexpress_obj.getRelationType())){
            BaseMedicalRecordCopyingApplyDO applyDO = medicalRecordCopyingApplyDao.findById(sfexpress_obj.getRelationCode()).orElse(null);
            patientId = applyDO.getPatientId();
            orgId = applyDO.getHospital();
            depositumInfo = "病例";
        }
        BaseOrgDO hospital = baseOrgDao.findByCode(orgId);
        BasePatientDO basePatientDO = basePatientDao.findById(patientId).orElse(null);
        JSONObject params = SFUtils.postSFOrderServiceV2(sfexpress_obj,hospital,basePatientDO,depositumInfo);
        String re = this.SFExpressPostV2(params);
        //xml验证
        logger.info("顺丰快递下订单:re"+re);
        verificationResponV2(re);
        JSONObject respone = JSONObject.parseObject(re);
        String mailno = "";//顺丰运单号
        String bspOrderNo = "";//顺丰业务号
        JSONArray successResult =  respone.getJSONObject("result").getJSONArray("successResult");
        if(!successResult.isEmpty()){
            JSONObject object = successResult.getJSONObject(0);
            mailno = object.getString("mailNo");
            bspOrderNo = object.getString("bspOrderNo");
        }
        logger.info("顺丰快递下订单:mailno"+mailno);
        sfexpress_obj.setMailno(mailno);
        sfexpress_obj.setBspOrderNo(bspOrderNo);
        return sfexpress_obj;
    }
    /**
     * 向顺丰快递下订单
     * @param sfexpress_obj
@ -213,7 +267,7 @@ public class PrescriptionExpressageService extends BaseJpaService<WlyyPrescripti
        BaseOrgDO hospital = baseOrgDao.findByCode(outpatientDO.getHospital());
        BasePatientDO basePatientDO = basePatientDao.findById(outpatientDO.getPatient()).orElse(null);
        JSONObject params = SFUtils.postSFOrderServiceV2(sfexpress_obj,hospital,basePatientDO);
        JSONObject params = SFUtils.postSFOrderServiceV2(sfexpress_obj,hospital,basePatientDO,"药品");
        String re = this.SFExpressPostV2(params);
        //xml验证
        logger.info("顺丰快递下订单:re"+re);
@ -280,11 +334,6 @@ public class PrescriptionExpressageService extends BaseJpaService<WlyyPrescripti
     * @throws Exception
     */
    public String postOrderConfirmService(WlyyPrescriptionExpressageDO sfexpress_obj) throws Exception {
        //获取医生所处的医院详细地址,作为寄件人地址
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(sfexpress_obj.getOutpatientId()).orElse(null);
        BaseOrgDO hospital = baseOrgDao.findByCode(outpatientDO.getHospital());
        String xml = SFUtils.SFOrderConfirmXml(sf_code,sfexpress_obj.getId(),sfexpress_obj.getMailno(),2);
        logger.info("顺丰快递取消订单请求:xml"+xml);
        String re = this.SFExpressPost(xml);
@ -747,7 +796,9 @@ public class PrescriptionExpressageService extends BaseJpaService<WlyyPrescripti
            //如果成功获取到快递单号,则保存处方物流记录,保存配送日志
            //修改处方状态为配送中
            prescriptionDao.updateStatus(sfexpress_obj.getOutpatientId(),65);
            if(StringUtils.isNotBlank(sfexpress_obj.getOutpatientId())){
                prescriptionDao.updateStatus(sfexpress_obj.getOutpatientId(),65);
            }
            //保存处方物流记录
            prescriptionExpressageDao.save(sfexpress_obj);
@ -755,6 +806,8 @@ public class PrescriptionExpressageService extends BaseJpaService<WlyyPrescripti
            //保存配送日志
            WlyyOutpatientExpressageLogDO outpatiExpressLog = new WlyyOutpatientExpressageLogDO();
            outpatiExpressLog.setOutpatientId(sfexpress_obj.getOutpatientId());
            outpatiExpressLog.setRelationCode(sfexpress_obj.getRelationCode());
            outpatiExpressLog.setRelationType(sfexpress_obj.getRelationType());
            outpatiExpressLog.setId(UUID.randomUUID().toString());
            outpatiExpressLog.setType(8);
            outpatiExpressLog.setCreateTime(new Date());
@ -846,13 +899,17 @@ public class PrescriptionExpressageService extends BaseJpaService<WlyyPrescripti
    public void updatePrescriptionExpressage(WlyyPrescriptionExpressageDO prescriptionExpressage) throws Exception {
        //修改门诊处方状态为配送配送中
        prescriptionDao.updateStatus(prescriptionExpressage.getId(), 32);
        if(StringUtils.isNotBlank(prescriptionExpressage.getOutpatientId())){
            prescriptionDao.updateStatus(prescriptionExpressage.getId(), 32);
        }
        //保存处方物流记录
        prescriptionExpressageDao.save(prescriptionExpressage);
        //保存门诊配送日志
        WlyyOutpatientExpressageLogDO prescriptionLog = new WlyyOutpatientExpressageLogDO();
        prescriptionLog.setRelationCode(prescriptionExpressage.getRelationCode());
        prescriptionLog.setRelationType(prescriptionExpressage.getRelationType());
        prescriptionLog.setOutpatientId(prescriptionExpressage.getOutpatientId());
        // 类型: -1 失效 1HIS对接 2易联众对接  3创建处方 4 审核  5付款 6 配送 7完成 8物流对接
        prescriptionLog.setType(8);

Datei-Diff unterdrückt, da er zu groß ist
+ 6 - 10
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java


+ 20 - 18
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/util/SFUtils.java

@ -13,7 +13,6 @@ import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import sun.misc.BASE64Encoder;
@ -21,7 +20,6 @@ import sun.misc.BASE64Encoder;
import java.io.FileInputStream;
import java.io.InputStream;
import java.security.MessageDigest;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -311,7 +309,7 @@ public class SFUtils {
     * @param hospital
     * @return
     */
    public JSONObject postSFOrderServiceV2(WlyyPrescriptionExpressageDO sfexpress_obj, BaseOrgDO hospital,  BasePatientDO basePatientDO) {
    public JSONObject postSFOrderServiceV2(WlyyPrescriptionExpressageDO sfexpress_obj, BaseOrgDO hospital,  BasePatientDO basePatientDO,String depositumInfo) {
    
        JSONObject params = new JSONObject();//请求参数
        JSONArray orders = new JSONArray();//订单集合
@ -338,27 +336,31 @@ public class SFUtils {
        order.put("destAddress",sfexpress_obj.getStreetName()+sfexpress_obj.getAddress());
        
        order.put("packagesNo",1);
        order.put("depositumInfo","药品");
        order.put("depositumInfo",depositumInfo);
        order.put("productCode","OTHER");
        
        //根据快递物流获取门诊信息,根据门诊信息获取处方订单的药品详情
        List<WlyyPrescriptionDO> prescriptionDOList = prescriptionService.findByField("outpatientId",sfexpress_obj.getOutpatientId());
        
        Set<String> prescriptionIdSet = new HashSet<>();
        prescriptionDOList.forEach(
                onePrescription -> {
                    prescriptionIdSet.add(onePrescription.getId());
                }
        );
        List<WlyyPrescriptionInfoDO> prescriptionInfolist = prescriptionInfoDao.queryAllByPrescriptionIdInAndDel(prescriptionIdSet,1);
        
        if(!prescriptionInfolist.isEmpty()){
            order.put("depositumNo",prescriptionInfolist.size());
        }else{
        if(StringUtils.isNotBlank(sfexpress_obj.getOutpatientId())){
            List<WlyyPrescriptionDO> prescriptionDOList = prescriptionService.findByField("outpatientId",sfexpress_obj.getOutpatientId());
            Set<String> prescriptionIdSet = new HashSet<>();
            prescriptionDOList.forEach(
                    onePrescription -> {
                        prescriptionIdSet.add(onePrescription.getId());
                    }
            );
            List<WlyyPrescriptionInfoDO> prescriptionInfolist = prescriptionInfoDao.queryAllByPrescriptionIdInAndDel(prescriptionIdSet,1);
            if(!prescriptionInfolist.isEmpty()){
                order.put("depositumNo",prescriptionInfolist.size());
            }else{
                order.put("depositumNo",1);
            }
        }else {
            order.put("depositumNo",1);
        }
        
        orders.add(order);
        params.put("orderThirds",orders);
        return params;

+ 155 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/record/service/HospitalPatientInpatientRecordService.java

@ -1,11 +1,33 @@
package com.yihu.jw.hospital.record.service;
import com.yihu.jw.common.dao.BaseSequenceDao;
import com.yihu.jw.entity.base.common.BaseSequence;
import com.yihu.jw.entity.base.patient.BaseMedicalRecordCopyingApplyDO;
import com.yihu.jw.entity.base.patient.BaseMedicalRecordCopyingApplyTypeDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionExpressageDO;
import com.yihu.jw.entity.hospital.record.HospitalPatientInpatientRecordDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionExpressageDao;
import com.yihu.jw.hospital.record.dao.HospitalPatientInpatientRecordDao;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.patient.dao.BaseMedicalRecordCopyingApplyDao;
import com.yihu.jw.patient.dao.BaseMedicalRecordCopyingApplyTypeDao;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.entity.ServiceException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
 * Created by yeshijie on 2022/11/28.
@ -15,6 +37,139 @@ public class HospitalPatientInpatientRecordService extends BaseJpaService<Hospit
    @Resource
    private HospitalPatientInpatientRecordDao hospitalPatientInpatientRecordDao;
    @Resource
    private BaseMedicalRecordCopyingApplyDao applyDao;
    @Resource
    private BaseMedicalRecordCopyingApplyTypeDao applyTypeDao;
    @Autowired
    private PrescriptionExpressageDao prescriptionExpressageDao;
    @Autowired
    private BaseSequenceDao baseSequenceDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
    //取消复印
    public void cancelApply(String id) throws Exception{
        BaseMedicalRecordCopyingApplyDO applyDO = applyDao.findById(id).orElse(null);
        if(!"0".equals(applyDO.getStatus())){
            throw new ServiceException("待审核的申请才能取消");
        }
        applyDO.setStatus("3");
        applyDao.save(applyDO);
    }
    //改为自取
    @Transactional
    public void changePickupWay(String id) throws Exception{
        BaseMedicalRecordCopyingApplyDO applyDO = applyDao.findById(id).orElse(null);
        if(!"0".equals(applyDO.getStatus())){
            throw new ServiceException("待审核的申请才能更改");
        }
        if("1".equals(applyDO.getPickupWay())){
            throw new ServiceException("已是自取,无需更改");
        }
        List<WlyyPrescriptionExpressageDO> expressageDOS = prescriptionExpressageDao.findByRelationCode(id,"1");
        expressageDOS.stream().forEach(one->{
            one.setOneselfPickupFlg(1);
        });
        prescriptionExpressageDao.saveAll(expressageDOS);
        applyDao.save(applyDO);
    }
    //申请详情
    public BaseMedicalRecordCopyingApplyDO applyDetail(String id){
        BaseMedicalRecordCopyingApplyDO applyDO = applyDao.findById(id).orElse(null);
        List<BaseMedicalRecordCopyingApplyTypeDO> applyTypeDOList = applyTypeDao.findByApplyId(id);
        applyDO.setApplyTypeList(applyTypeDOList);
        List<WlyyPrescriptionExpressageDO> expressageDOS = prescriptionExpressageDao.findByRelationCode(id,"1");
        if(expressageDOS.size()>0){
            applyDO.setExpressageDO(expressageDOS.get(0));
        }
        WlyyHospitalSysDictDO copy_apply_status =  wlyyHospitalSysDictDao.findOneByDictNameAndDictCode("copy_apply_status",applyDO.getStatus());
        WlyyHospitalSysDictDO copy_use_to =  wlyyHospitalSysDictDao.findOneByDictNameAndDictCode("copy_use_to",applyDO.getUseTo());
        WlyyHospitalSysDictDO patient_relation =  wlyyHospitalSysDictDao.findOneByDictNameAndDictCode("patient_relation",applyDO.getPatientRelation());
        WlyyHospitalSysDictDO EXPRESS_STATUS =  wlyyHospitalSysDictDao.findOneByDictNameAndDictCode("EXPRESS_STATUS",applyDO.getPickupWay());
        applyDO.setStatusName(copy_apply_status.getDictValue());
        applyDO.setUseToName(copy_use_to.getDictValue());
        applyDO.setPatientRelationName(patient_relation.getDictValue());
        applyDO.setPickupWayName(EXPRESS_STATUS.getDictValue());
        return applyDO;
    }
    //复印病案申请列表
    public PageEnvelop applyPage(String patientId,Integer page,Integer size,String name,String status,String startTime,String endTime){
        String sql = "select * ";
        String countSql = "select count(*) ";
        String filter = " from base_medical_record_copying_apply where 1=1  ";
        if(StringUtils.isNotBlank(patientId)){
            filter += " and patient_id='"+patientId+"' ";
        }
        if(StringUtils.isNotBlank(name)){
            filter += " and (patient_name like '%"+name+"%' or apply_name like '%"+name+"%')";
        }
        if(StringUtils.isNotBlank(status)){
            filter += " and status='"+status+"' ";
        }
        if(StringUtils.isNotBlank(startTime)){
            filter += " and apply_time>='"+startTime+"' ";
        }
        if(StringUtils.isNotBlank(endTime)){
            filter += " and apply_time<='"+endTime+"' ";
        }
        String orderBy = " order by apply_time desc limit "+(page-1)*size+","+size;
        List<WlyyHospitalSysDictDO> dictDOList =  wlyyHospitalSysDictDao.findByDictName("copy_apply_status");
        Map<String,String> applyStatusMap = dictDOList.stream().collect(Collectors.toMap(WlyyHospitalSysDictDO::getDictCode,WlyyHospitalSysDictDO::getDictValue));
        List<BaseMedicalRecordCopyingApplyDO> list = jdbcTemplate.query(sql+filter+orderBy,new BeanPropertyRowMapper<>(BaseMedicalRecordCopyingApplyDO.class));
        list.stream().forEach(one->{
            one.setStatusName(applyStatusMap.get(one.getStatus()));
        });
        Long count = jdbcTemplate.queryForObject(countSql+filter,Long.class);
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,size,count);
    }
    //生成不重复的单号
    public synchronized String getApplyNo(){
        BaseSequence seq = new BaseSequence();
        baseSequenceDao.save(seq);
        Long id = jdbcTemplate.queryForObject("select max(id) from base_sequence",Long.class);
        return "DM"+String.format("%08d", id);
    }
    //病案复印申请
    public void apply(BaseMedicalRecordCopyingApplyDO applyDO){
        List<BaseMedicalRecordCopyingApplyTypeDO> applyTypeList = applyDO.getApplyTypeList();
        WlyyPrescriptionExpressageDO expressageDO = applyDO.getExpressageDO();
        applyDO.setApplyNo(getApplyNo());
        applyDO.setApplyTime(DateUtil.getStringDate());
        applyDO.setStatus("0");
        applyDO.setPayStatus("0");
        applyDO.setTotalNum(10);//先写死-需要对接
        String copyNum = applyDO.getCopyingNum();
        //住院记录信息
        applyDO.setDeptName("骨科一病区");
        applyDO.setHospitalNum("1");
        applyDO.setOutpatientTime("2023-12-27 08:58:00");
        applyDO = applyDao.save(applyDO);
        String applyId = applyDO.getId();
        expressageDO.setRelationCode(applyId);
        expressageDO.setRelationType("1");
        expressageDO.setCreateTime(new Date());
        expressageDO.setDel(1);
        prescriptionExpressageDao.save(expressageDO);
        applyTypeList.stream().forEach(one->{
            one.setApplyId(applyId);
            one.setCopyingNum(copyNum);
        });
        applyTypeDao.saveAll(applyTypeList);
    }
    /**
     * 查找最近一次住院记录

+ 11 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/suggest/service/BaseSuggestionService.java

@ -7,6 +7,7 @@ import com.yihu.jw.hospital.suggest.dao.BaseSuggestionDao;
import com.yihu.jw.hospital.suggest.dao.BaseSuggestionDictDao;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.entity.ServiceException;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.jw.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
@ -89,7 +90,17 @@ public class BaseSuggestionService extends BaseJpaService<BaseSuggestionDO, Base
        BaseSuggestionDictDO baseSuggestionDictDO = baseSuggestionDictDao.findById(baseSuggestionDO.getSuggestId()).orElse(null);
        baseSuggestionDO.setSuggestName(baseSuggestionDictDO.getSuggestName());
        return baseSuggestionDO;
    }
    //撤回功能
    public BaseSuggestionDO revoke(String id){
        BaseSuggestionDO baseSuggestionDO = baseSuggestionDao.findById(id).orElse(null);
        if(baseSuggestionDO.getSuggestStatus()!=0){
            throw new ServiceException("只有未处理的建议才能撤回");
        }
        baseSuggestionDO.setSuggestStatus(2);
        baseSuggestionDao.save(baseSuggestionDO);
        return baseSuggestionDO;
    }

+ 12 - 0
business/base-service/src/main/java/com/yihu/jw/patient/dao/BaseMedicalRecordCopyingApplyDao.java

@ -0,0 +1,12 @@
package com.yihu.jw.patient.dao;
import com.yihu.jw.entity.base.patient.BaseMedicalRecordCopyingApplyDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
 * Created by yeshijie on 2023/12/26.
 */
public interface BaseMedicalRecordCopyingApplyDao extends JpaRepository<BaseMedicalRecordCopyingApplyDO, String>,
        JpaSpecificationExecutor<BaseMedicalRecordCopyingApplyDO> {
}

+ 18 - 0
business/base-service/src/main/java/com/yihu/jw/patient/dao/BaseMedicalRecordCopyingApplyTypeDao.java

@ -0,0 +1,18 @@
package com.yihu.jw.patient.dao;
import com.yihu.jw.entity.base.patient.BaseMedicalRecordCopyingApplyTypeDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
/**
 * Created by yeshijie on 2023/12/26.
 */
public interface BaseMedicalRecordCopyingApplyTypeDao extends JpaRepository<BaseMedicalRecordCopyingApplyTypeDO, String>,
        JpaSpecificationExecutor<BaseMedicalRecordCopyingApplyTypeDO> {
    @Query("select a from BaseMedicalRecordCopyingApplyTypeDO a where a.applyId=?1")
    List<BaseMedicalRecordCopyingApplyTypeDO> findByApplyId(String applyId);
}

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/wlyy/service/WlyyBusinessService.java

@ -349,7 +349,7 @@ public class WlyyBusinessService {
                        Integer status = rs.getInteger("status");
                        if (200 == status) {
                            JSONObject data = rs.getJSONObject("data");
                            if (data.get("ssc")!=null){
                            if (data!=null&&data.get("ssc")!=null){
                                patientCardNo = data.getString("ssc");
                                patientMedicareCardDO = new PatientMedicareCardDO();
                                patientMedicareCardDO.setPatientCode(patientId);

Datei-Diff unterdrückt, da er zu groß ist
+ 1 - 3
business/base-service/src/main/java/com/yihu/jw/wlyy/wlyyhttp/WlyyHttpService.java


Datei-Diff unterdrückt, da er zu groß ist
+ 9 - 5
business/es-service/src/main/java/com/yihu/jw/es/service/StatisticsEsService.java


Datei-Diff unterdrückt, da er zu groß ist
+ 172 - 0
common/common-entity/src/db/2023.sql


+ 8 - 0
common/common-entity/src/db/达梦数据库.txt

@ -0,0 +1,8 @@
dm管理工具
插入语句后要 commit后才能查到。
窗口可以 使用 set schema 库;(仅当前窗口生效)
后面查询就不需要表面。
达梦和mysql语法不通,
达梦不支持 `

+ 18 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/common/BaseSequence.java

@ -0,0 +1,18 @@
package com.yihu.jw.entity.base.common;
import com.yihu.jw.entity.LongIdentityEntity;
import javax.persistence.Entity;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
/**
 * 自增序列
 * Created by yeshijie on 2023/12/27.
 */
@Entity
@Table(name = "base_sequence")
@SequenceGenerator(name="id_generated", sequenceName="base_sequence")
public class BaseSequence extends LongIdentityEntity {
}

+ 22 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/base/org/BaseOrgDO.java

@ -133,7 +133,10 @@ public class BaseOrgDO extends UuidIdentityEntityWithOperator {
	 * 机构网址
	 */
	private String orgUrl;
    //门诊时间
    private String clinicTime;
    //交通方式
    private String transportationMode;
    /**
	 * 机构简介
	 */
@ -488,4 +491,22 @@ public class BaseOrgDO extends UuidIdentityEntityWithOperator {
    public void setHisId(String hisId) {
        this.hisId = hisId;
    }
    @Column(name = "clinic_time")
    public String getClinicTime() {
        return clinicTime;
    }
    public void setClinicTime(String clinicTime) {
        this.clinicTime = clinicTime;
    }
    @Column(name = "transportation_mode")
    public String getTransportationMode() {
        return transportationMode;
    }
    public void setTransportationMode(String transportationMode) {
        this.transportationMode = transportationMode;
    }
}

+ 380 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BaseMedicalRecordCopyingApplyDO.java

@ -0,0 +1,380 @@
package com.yihu.jw.entity.base.patient;
import com.yihu.jw.entity.UuidIdentityEntity;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionExpressageDO;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.math.BigDecimal;
import java.util.List;
/**
 * 病案复印申请表
 * Created by yeshijie on 2023/12/26.
 */
@Entity
@Table(name = "base_medical_record_copying_apply")
public class BaseMedicalRecordCopyingApplyDO extends UuidIdentityEntity {
      
      private String applyNo;//申请单号
      private String status;//状态0待审核 1审核通过 2审核拒绝 3已取消
      private String applyName;//申请人姓名
      private String applyIdcard;//申请人身份证
      private String applyMobile;//申请人电话
      private String patientRelation;//与患者关系
      private String patientId;//患者id
      private String patientName;//患者姓名
      private String patientIdcard;//患者身份证
      private String patientMobile;//患者电话
      private String useTo;//复印用途
      private String applyTime;//申请时间
      private String pickupWay;//取件方式 1自取 0快递
      private String copyingNum;//复印份数
      private String checkTime;//审核时间
      private String checkResult;//审核结果
      private Integer totalNum;//总页数
      private BigDecimal price;//总价格
      private String payLostTime;//支付失效时间
      private String payStatus;//支付状态 0待支付 1已支付
      private String caseId;//病例id
      private String hospital;//审核医生所在医院
      private String appendix1;//证件附件-患者证件头像面
      private String appendix2;//证件附件-患者证件国徽面
      private String appendix3;//证件附件-患者手持头像面
      private String appendix4;//证件附件-申请人头像面
      private String appendix5;//证件附件-申请人国徽面
      private String deptName;//住院科室
      private String hospitalNum;//住院次数
      private String outpatientTime;//出院时间
      //非数据库字段
      private List<BaseMedicalRecordCopyingApplyTypeDO> applyTypeList;//复印内容类型
      private WlyyPrescriptionExpressageDO expressageDO;//物流信息
      private String statusName;//状态
      private String useToName;//复印用途
      private String patientRelationName;//与患者关系
      private String pickupWayName;//取件方式 1自取 0快递
      @Column(name = "apply_no")
      public String getApplyNo() {
            return applyNo;
      }
      public void setApplyNo(String applyNo) {
            this.applyNo = applyNo;
      }
      @Column(name = "status")
      public String getStatus() {
            return status;
      }
      public void setStatus(String status) {
            this.status = status;
      }
      @Column(name = "apply_name")
      public String getApplyName() {
            return applyName;
      }
      public void setApplyName(String applyName) {
            this.applyName = applyName;
      }
      @Column(name = "apply_idcard")
      public String getApplyIdcard() {
            return applyIdcard;
      }
      public void setApplyIdcard(String applyIdcard) {
            this.applyIdcard = applyIdcard;
      }
      @Column(name = "patient_relation")
      public String getPatientRelation() {
            return patientRelation;
      }
      public void setPatientRelation(String patientRelation) {
            this.patientRelation = patientRelation;
      }
      @Column(name = "patient_id")
      public String getPatientId() {
            return patientId;
      }
      public void setPatientId(String patientId) {
            this.patientId = patientId;
      }
      @Column(name = "patient_name")
      public String getPatientName() {
            return patientName;
      }
      public void setPatientName(String patientName) {
            this.patientName = patientName;
      }
      @Column(name = "patient_idcard")
      public String getPatientIdcard() {
            return patientIdcard;
      }
      public void setPatientIdcard(String patientIdcard) {
            this.patientIdcard = patientIdcard;
      }
      @Column(name = "patient_mobile")
      public String getPatientMobile() {
            return patientMobile;
      }
      public void setPatientMobile(String patientMobile) {
            this.patientMobile = patientMobile;
      }
      @Column(name = "use_to")
      public String getUseTo() {
            return useTo;
      }
      public void setUseTo(String useTo) {
            this.useTo = useTo;
      }
      @Column(name = "apply_time")
      public String getApplyTime() {
            return applyTime;
      }
      public void setApplyTime(String applyTime) {
            this.applyTime = applyTime;
      }
      @Column(name = "pickup_way")
      public String getPickupWay() {
            return pickupWay;
      }
      public void setPickupWay(String pickupWay) {
            this.pickupWay = pickupWay;
      }
      @Column(name = "check_time")
      public String getCheckTime() {
            return checkTime;
      }
      public void setCheckTime(String checkTime) {
            this.checkTime = checkTime;
      }
      @Column(name = "check_result")
      public String getCheckResult() {
            return checkResult;
      }
      public void setCheckResult(String checkResult) {
            this.checkResult = checkResult;
      }
      @Column(name = "total_num")
      public Integer getTotalNum() {
            return totalNum;
      }
      public void setTotalNum(Integer totalNum) {
            this.totalNum = totalNum;
      }
      @Column(name = "price")
      public BigDecimal getPrice() {
            return price;
      }
      public void setPrice(BigDecimal price) {
            this.price = price;
      }
      @Column(name = "pay_lost_time")
      public String getPayLostTime() {
            return payLostTime;
      }
      public void setPayLostTime(String payLostTime) {
            this.payLostTime = payLostTime;
      }
      @Column(name = "case_id")
      public String getCaseId() {
            return caseId;
      }
      public void setCaseId(String caseId) {
            this.caseId = caseId;
      }
      @Column(name = "apply_mobile")
      public String getApplyMobile() {
            return applyMobile;
      }
      public void setApplyMobile(String applyMobile) {
            this.applyMobile = applyMobile;
      }
      @Column(name = "hospital")
      public String getHospital() {
            return hospital;
      }
      public void setHospital(String hospital) {
            this.hospital = hospital;
      }
      @Column(name = "copying_num")
      public String getCopyingNum() {
            return copyingNum;
      }
      public void setCopyingNum(String copyingNum) {
            this.copyingNum = copyingNum;
      }
      @Column(name = "appendix1")
      public String getAppendix1() {
            return appendix1;
      }
      public void setAppendix1(String appendix1) {
            this.appendix1 = appendix1;
      }
      @Column(name = "appendix2")
      public String getAppendix2() {
            return appendix2;
      }
      public void setAppendix2(String appendix2) {
            this.appendix2 = appendix2;
      }
      @Column(name = "appendix3")
      public String getAppendix3() {
            return appendix3;
      }
      public void setAppendix3(String appendix3) {
            this.appendix3 = appendix3;
      }
      @Column(name = "appendix4")
      public String getAppendix4() {
            return appendix4;
      }
      public void setAppendix4(String appendix4) {
            this.appendix4 = appendix4;
      }
      @Column(name = "appendix5")
      public String getAppendix5() {
            return appendix5;
      }
      public void setAppendix5(String appendix5) {
            this.appendix5 = appendix5;
      }
      @Transient
      public List<BaseMedicalRecordCopyingApplyTypeDO> getApplyTypeList() {
            return applyTypeList;
      }
      public void setApplyTypeList(List<BaseMedicalRecordCopyingApplyTypeDO> applyTypeList) {
            this.applyTypeList = applyTypeList;
      }
      @Transient
      public WlyyPrescriptionExpressageDO getExpressageDO() {
            return expressageDO;
      }
      public void setExpressageDO(WlyyPrescriptionExpressageDO expressageDO) {
            this.expressageDO = expressageDO;
      }
      @Column(name = "pay_status")
      public String getPayStatus() {
            return payStatus;
      }
      public void setPayStatus(String payStatus) {
            this.payStatus = payStatus;
      }
      @Transient
      public String getStatusName() {
            return statusName;
      }
      public void setStatusName(String statusName) {
            this.statusName = statusName;
      }
      @Column(name = "dept_name")
      public String getDeptName() {
            return deptName;
      }
      public void setDeptName(String deptName) {
            this.deptName = deptName;
      }
      @Column(name = "hospital_num")
      public String getHospitalNum() {
            return hospitalNum;
      }
      public void setHospitalNum(String hospitalNum) {
            this.hospitalNum = hospitalNum;
      }
      @Column(name = "outpatient_time")
      public String getOutpatientTime() {
            return outpatientTime;
      }
      public void setOutpatientTime(String outpatientTime) {
            this.outpatientTime = outpatientTime;
      }
      @Transient
      public String getUseToName() {
            return useToName;
      }
      public void setUseToName(String useToName) {
            this.useToName = useToName;
      }
      @Transient
      public String getPatientRelationName() {
            return patientRelationName;
      }
      public void setPatientRelationName(String patientRelationName) {
            this.patientRelationName = patientRelationName;
      }
      @Transient
      public String getPickupWayName() {
            return pickupWayName;
      }
      public void setPickupWayName(String pickupWayName) {
            this.pickupWayName = pickupWayName;
      }
}

+ 58 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BaseMedicalRecordCopyingApplyTypeDO.java

@ -0,0 +1,58 @@
package com.yihu.jw.entity.base.patient;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 病案复印申请复印内容
 * Created by yeshijie on 2023/12/26.
 */
@Entity
@Table(name = "base_medical_record_copying_apply_type")
public class BaseMedicalRecordCopyingApplyTypeDO extends UuidIdentityEntity {
    private String applyId;//申请id
    private String content;//复印内容
    private String type;//复印内容类型
    private String copyingNum;//复印份数
    @Column(name = "apply_id")
    public String getApplyId() {
        return applyId;
    }
    public void setApplyId(String applyId) {
        this.applyId = applyId;
    }
    @Column(name = "content")
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    @Column(name = "type")
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    @Column(name = "copying_num")
    public String getCopyingNum() {
        return copyingNum;
    }
    public void setCopyingNum(String copyingNum) {
        this.copyingNum = copyingNum;
    }
}

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServiceItemPlanDO.java

@ -16,7 +16,7 @@ import javax.persistence.Transient;
public class ServiceItemPlanDO extends UuidIdentityEntityWithCreateTime {
    private String patient;//居民id
    private String status;//状态0未完成 1已完成 2待补录
    private String status;//状态0未完成 1已完成 2待补录  补充【3进行中】
    private String planTime;//计划时间
    private String completeTime;//完成时间
    private String doctor;//医生id

+ 105 - 56
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/BaseNatAppointmentDO.java

@ -2,68 +2,74 @@ package com.yihu.jw.entity.hospital.prescription;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.*;
import java.util.Date;
@Entity
@Table(name = "base_nat_appointment")
@SequenceGenerator(name="id_generated", sequenceName="BASE_NAT_APPOINTMENT_SEQ")
public class BaseNatAppointmentDO extends IntegerIdentityEntity {
    private String cardType;
    private String cardNo;
    private Date appointmentTime;
    private String isSuccess;
    private String appointmentTode;
    private Date endTime;
    private Date createTime;
    private String address;
    private String province;
    private String provinceName;
    private String city;
    private String cityName;
    private String town;
    private String townName;
    private String street;
    private String streetName;
    private String name;
    private String mobile;
    private String payStatus;
    private String realOrder;
    private String inspectionCode;
    private String inspectionName;
    private String dept;
    private String deptName;
    private String doctorId;
    private String patientId;
    private String chargeAmount;
    private String cancelBy;
    private String cancelReson;
    private Date cancelTime;
    private String secondJobCode;
    private String secondJobName;
    private String firstJobCode;
    private String firstJobName;
    private String medicare;
    private String checkPart;
    private String chargeFlag;
    private String winNo;
    private String chargeCode;
    private String icdCode;
    private String doctorName;
    private String voucherNo;
    private String registerNo;
    private String ampm;
    private String cardNoType;
    private String hospitalFlag;
    private String consumer;
    private String consumerName;
    private String oderNum;
    private String idnoType;
    private Integer source;
    private String patientHisId;
    private String cardType;//
    private String cardNo;//证件号
    private Date appointmentTime;//预约时间
    private String isSuccess;//1成功  0失败
    private String appointmentTode;//预约号
    private Date endTime;//结束时间
    private Date createTime;//创建时间
    private String address;//具体地址
    private String province;//省编码
    private String provinceName;//
    private String city;//市
    private String cityName;//
    private String town;//区
    private String townName;//
    private String street;//街道
    private String streetName;//
    private String name;//患者姓名
    private String mobile;//患者手机号
    private String payStatus;//支付状态
    private String realOrder;//处方code
    private String inspectionCode;//检查项目code
    private String inspectionName;//检查项目名称
    private String dept;//
    private String deptName;//部门名称
    private String doctorId;//医生id
    private String patientId;//患者id
    private String chargeAmount;//单价
    private String cancelBy;//取消人id
    private String cancelReson;//取消原因
    private Date cancelTime;//取消时间
    private String secondJobCode;//职业二级分类
    private String secondJobName;//
    private String firstJobCode;//职业一级分类
    private String firstJobName;//
    private String medicare;//就诊卡号(社保卡号、智慧卡号)
    private String checkPart;//检查部位
    private String chargeFlag;//
    private String winNo;//
    private String chargeCode;//号别
    private String icdCode;//诊断code
    private String doctorName;//医生姓名
    private String voucherNo;//
    private String registerNo;//
    private String ampm;//
    private String cardNoType;//
    private String hospitalFlag;//
    private String consumer;//代就诊人
    private String consumerName;//代就诊人名字
    private String oderNum;//
    private String idnoType;//身份类别
    private Integer source;//来源(1二维码2、公众号、3支付宝、4pc端)
    private String patientHisId;//患者his的id
    private String merchantOrderNo;//商户订单号
    private String invoiceSerialNo;//发票流水号
    //非数据字段
    private String payStatusName;//支付状态
    private String age;//年龄
    private String sex;//性别
    public String getOderNum() {
        return oderNum;
@ -482,4 +488,47 @@ public class BaseNatAppointmentDO extends IntegerIdentityEntity {
    public void setPatientHisId(String patientHisId) {
        this.patientHisId = patientHisId;
    }
    public String getMerchantOrderNo() {
        return merchantOrderNo;
    }
    public void setMerchantOrderNo(String merchantOrderNo) {
        this.merchantOrderNo = merchantOrderNo;
    }
    public String getInvoiceSerialNo() {
        return invoiceSerialNo;
    }
    public void setInvoiceSerialNo(String invoiceSerialNo) {
        this.invoiceSerialNo = invoiceSerialNo;
    }
    @Transient
    public String getPayStatusName() {
        return payStatusName;
    }
    public void setPayStatusName(String payStatusName) {
        this.payStatusName = payStatusName;
    }
    @Transient
    public String getAge() {
        return age;
    }
    public void setAge(String age) {
        this.age = age;
    }
    @Transient
    public String getSex() {
        return sex;
    }
    public void setSex(String sex) {
        this.sex = sex;
    }
}

+ 158 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/BaseNatItemDO.java

@ -0,0 +1,158 @@
package com.yihu.jw.entity.hospital.prescription;
import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
/**
 * 医技预约项目配置表
 * Created by yeshijie on 2023/12/28.
 */
@Entity
@Table(name = "base_nat_item")
public class BaseNatItemDO extends UuidIdentityEntityWithCreateTime {
    private String name;//医技项目名称
    private String code;//项目名称编码
    private String suitableCrowd;//适用人群编码(逗号间隔)
    private String suitableCrowdName;//适用人群名称
    private String deptCode;//开单科室编码
    private String deptName;//开单科室
    private String doctorCode;//开单医生编码
    private String doctorName;//开单医生
    private Double price;//项目金额
    private String status;//项目状态 1生效中 0失效
    private String limitFrequency;//是否限定预约频率 1限定 0不限定
    private String timeType;//时段设置 1每天 2每周 3每月 4每年
    private Integer frequency;//频率平次
    //非数据库字段
    private String statusName;//项目状态 1生效中 0失效
    private String timeTypeName;//时段设置 1每天 2每周 3每月 4每年
    @Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "suitable_crowd")
    public String getSuitableCrowd() {
        return suitableCrowd;
    }
    public void setSuitableCrowd(String suitableCrowd) {
        this.suitableCrowd = suitableCrowd;
    }
    @Column(name = "suitable_crowd_name")
    public String getSuitableCrowdName() {
        return suitableCrowdName;
    }
    public void setSuitableCrowdName(String suitableCrowdName) {
        this.suitableCrowdName = suitableCrowdName;
    }
    @Column(name = "dept_code")
    public String getDeptCode() {
        return deptCode;
    }
    public void setDeptCode(String deptCode) {
        this.deptCode = deptCode;
    }
    @Column(name = "dept_name")
    public String getDeptName() {
        return deptName;
    }
    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }
    @Column(name = "doctor_code")
    public String getDoctorCode() {
        return doctorCode;
    }
    public void setDoctorCode(String doctorCode) {
        this.doctorCode = doctorCode;
    }
    @Column(name = "doctor_name")
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    @Column(name = "price")
    public Double getPrice() {
        return price;
    }
    public void setPrice(Double price) {
        this.price = price;
    }
    @Column(name = "status")
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    @Column(name = "limit_frequency")
    public String getLimitFrequency() {
        return limitFrequency;
    }
    public void setLimitFrequency(String limitFrequency) {
        this.limitFrequency = limitFrequency;
    }
    @Column(name = "time_type")
    public String getTimeType() {
        return timeType;
    }
    public void setTimeType(String timeType) {
        this.timeType = timeType;
    }
    @Column(name = "frequency")
    public Integer getFrequency() {
        return frequency;
    }
    public void setFrequency(Integer frequency) {
        this.frequency = frequency;
    }
    @Transient
    public String getStatusName() {
        return statusName;
    }
    public void setStatusName(String statusName) {
        this.statusName = statusName;
    }
    @Transient
    public String getTimeTypeName() {
        return timeTypeName;
    }
    public void setTimeTypeName(String timeTypeName) {
        this.timeTypeName = timeTypeName;
    }
}

+ 20 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyOutpatientExpressageLogDO.java

@ -2,7 +2,7 @@ package com.yihu.jw.entity.hospital.prescription;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntity;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
@ -29,6 +29,9 @@ public class WlyyOutpatientExpressageLogDO extends UuidIdentityEntity {
	 */
	private String outpatientId;
    private String relationType;//关联类型 类型1 病案复印(关联病案复印申请id)
    private String relationCode;//关联id
    /**
	 * 创建时间
	 */
@ -177,6 +180,22 @@ public class WlyyOutpatientExpressageLogDO extends UuidIdentityEntity {
        this.remark = remark;
    }
    @Column(name = "relation_type")
    public String getRelationType() {
        return relationType;
    }
    public void setRelationType(String relationType) {
        this.relationType = relationType;
    }
    @Column(name = "relation_code")
    public String getRelationCode() {
        return relationCode;
    }
    public void setRelationCode(String relationCode) {
        this.relationCode = relationCode;
    }
}

+ 21 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyPrescriptionExpressageDO.java

@ -26,6 +26,9 @@ public class WlyyPrescriptionExpressageDO extends UuidIdentityEntity {
	 */
	private String outpatientId;
    private String relationType;//关联类型 类型1 病案复印(关联病案复印申请id)
    private String relationCode;//关联id
    /**
	 * 快递单号
	 */
@ -338,4 +341,22 @@ public class WlyyPrescriptionExpressageDO extends UuidIdentityEntity {
    public void setBspOrderNo(String bspOrderNo) {
        this.bspOrderNo = bspOrderNo;
    }
    @Column(name = "relation_type")
    public String getRelationType() {
        return relationType;
    }
    public void setRelationType(String relationType) {
        this.relationType = relationType;
    }
    @Column(name = "relation_code")
    public String getRelationCode() {
        return relationCode;
    }
    public void setRelationCode(String relationCode) {
        this.relationCode = relationCode;
    }
}

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/suggest/BaseSuggestionDO.java

@ -52,7 +52,7 @@ public class BaseSuggestionDO extends UuidIdentityEntityWithOperator {
    @Column(name = "is_del")
    private Integer  isDel;
    /*
     *状态图 1回复 0未回复
     *状态图 1回复 0未回复 2已撤回
     */
    @Column(name = "suggest_status")
    private Integer  suggestStatus;

+ 5 - 20
gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/BasicZuulFilter.java

@ -424,32 +424,17 @@ public class BasicZuulFilter extends ZuulFilter {
    private static boolean sqlValidate(String str) {
        if (org.apache.commons.lang3.StringUtils.isNoneBlank(str)){
            logger.info("sql"+str);
            str = str.toLowerCase();//统一转为小写,比较简单的单词加入右边空格,避免单词中包含字段
            String badStr = "xor|sysdate|and |exec |execute |insert |select |delete |update |drop |chr |mid |master |truncate |" +
                    "declare | sitename |net user|xp_cmdshell|or |exec |execute |create |" +
                    "table |from |grant |use |group_concat|column_name|" +
                    "information_schema.columns|table_schema|union |where |select |update |order |by |like |" ;//过滤掉的sql关键字,可以手动添加
            String[] badStrs = badStr.split("\\|");
            for (int i = 0; i < badStrs.length; i++) {
                if (str.indexOf(badStrs[i]) >= 0) {
                    logger.info("true");
                    return true;
                }
            }
            return false;
            String badStr = "xor|sysdate|and|exec|execute|insert|select|delete|update|drop|chr|mid|master|truncate|" +
                    "declare|sitename|net user|xp_cmdshell|or|create|" +
                    "table|from|grant|use|group_concat|column_name|" +
                    "information_schema.columns|table_schema|union|where|order|by|like|" ;//过滤掉的sql关键字,可以手动添加
            return str.matches(badStr);
        }else {
            return true;
        }
    }
//    public static void main(String ag[]){
//        String str ="<?xml version='1.0' encoding='UTF-8'?><Request service=\"RoutePushService\" lang=\"zh-CN\"><Body><WaybillRoute id=\"4771647\" mailno=\"444019056680\" orderid=\"808080eb6c26bcad016c2826b9d6f794\" acceptTime=\"2019-11-26 12:21:46\" acceptAddress=\"深圳市\" remark=\"备注\" opCode=\"50\"/></Body></Request>";
//        sqlValidate(str);
//    }
    /**
     * 文件类型过滤器
     * @param fileName

+ 1 - 1
server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java

@ -621,7 +621,7 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
        if (StringUtils.isBlank(loginType) || "1".equals(loginType)) { //1或默认查找user表,为平台管理员账号
            result = this.getJdbcTemplate().queryForMap("select u.login_failure_count,u.last_login_failure_time from base_user u where u.username = ? or u.mobile = ? or u.idcard = ?", username, username, username);
        } else if ("2".equals(loginType)) {//2.为医生账号
            result = this.getJdbcTemplate().queryForMap("select d.login_failure_count,d.last_login_failure_time from base_doctor d where d.mobile = ? or d.idcard = ?", username, username);
            result = this.getJdbcTemplate().queryForMap("select d.login_failure_count,d.last_login_failure_time from base_doctor d where d.mobile = ? or d.idcard = ? and d.del='1' limit 1", username, username);
        } else if ("3".equals(loginType)) { //3.患者账号
            result = this.getJdbcTemplate().queryForMap("select p.login_failure_count,p.last_login_failure_time from base_patient p where p.mobile = ? or p.idcard = ? limit 1", username, username);
        } else if ("4".equals(loginType)) { //4.第三方患者账号

+ 24 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/exception/PwdException.java

@ -0,0 +1,24 @@
package com.yihu.jw.security.exception;
import org.springframework.security.oauth2.common.exceptions.ClientAuthenticationException;
/**
 * Created by wsl on 2022/9/20
 */
public class PwdException extends ClientAuthenticationException {
    public PwdException(String msg, Throwable t) {
        super(msg, t);
    }
    public PwdException(String msg) {
        super(msg);
    }
    @Override
    public String getOAuth2ErrorCode() {
         return "pwd_low  error";
    }
}

+ 7 - 1
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/core/redis/WlyyRedisVerifyCodeService.java

@ -1,7 +1,6 @@
package com.yihu.jw.security.oauth2.core.redis;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.security.dao.patient.WlyyHospitalSysDictDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
@ -58,6 +57,13 @@ public class WlyyRedisVerifyCodeService {
                return false;
            }
        }
        //新增白名单判断-白名单验证码默认123456
        if("123456".equals(code)){
            WlyyHospitalSysDictDO dictDO = wlyyHospitalSysDictDao.findOneByDictNameAndDictCode("sms_captcha_white",username);
            if(dictDO!=null){
                return true;
            }
        }
        String key = client_id + ":" + username + KEY_SUFFIX;
        String _code = (String) redisTemplate.opsForValue().get(key);
        if (null == _code) {

+ 78 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/WlyyTokenGranter.java

@ -127,6 +127,15 @@ public class WlyyTokenGranter implements TokenGranter {
                        requestFactory,
                        userDetailsService
                ));
        tokenGranters.put(PwdAndCaptchaTokenGranter.GRANT_TYPE,
                new PwdAndCaptchaTokenGranter(
                        authenticationManager,
                        tokenServices,
                        clientDetailsService,
                        requestFactory,
                        userDetailsService,
                        wlyyRedisVerifyCodeService
                ));
    }
    public OAuth2AccessToken grant(String grantType, TokenRequest tokenRequest) {
@ -650,5 +659,74 @@ public class WlyyTokenGranter implements TokenGranter {
            return new OAuth2Authentication(storedOAuth2Request, userAuth);
        }
    }
    /**
     * 密码+验证码登录
     */
    public static class PwdAndCaptchaTokenGranter extends AbstractTokenGranter {
        private static final String GRANT_TYPE = "pwdAndCaptcha";
        private final AuthenticationManager authenticationManager;
        private final UserDetailsService userDetailsService;
        private final WlyyRedisVerifyCodeService wlyyRedisVerifyCodeService;
        private GrantedAuthoritiesMapper authoritiesMapper = new NullAuthoritiesMapper();
        public PwdAndCaptchaTokenGranter(AuthenticationManager authenticationManager,
                                         AuthorizationServerTokenServices tokenServices,
                                         ClientDetailsService clientDetailsService,
                                         OAuth2RequestFactory requestFactory,
                                         UserDetailsService userDetailsService,
                                         WlyyRedisVerifyCodeService wlyyRedisVerifyCodeService) {
            this(authenticationManager, tokenServices, clientDetailsService, requestFactory, userDetailsService,wlyyRedisVerifyCodeService, GRANT_TYPE);
        }
        protected PwdAndCaptchaTokenGranter(AuthenticationManager authenticationManager,
                                            AuthorizationServerTokenServices tokenServices,
                                            ClientDetailsService clientDetailsService,
                                            OAuth2RequestFactory requestFactory,
                                            UserDetailsService userDetailsService,
                                            WlyyRedisVerifyCodeService wlyyRedisVerifyCodeService,
                                            String grantType) {
            super(tokenServices, clientDetailsService, requestFactory, grantType);
            this.authenticationManager = authenticationManager;
            this.wlyyRedisVerifyCodeService = wlyyRedisVerifyCodeService;
            this.userDetailsService = userDetailsService;
        }
        @Override
        protected OAuth2Authentication getOAuth2Authentication(ClientDetails client, TokenRequest tokenRequest) {
            Map<String, String> parameters = new LinkedHashMap<String, String>(tokenRequest.getRequestParameters());
            String client_id = parameters.get("client_id");
            String username = parameters.get("username");
            String captcha = parameters.get("captcha");
            //todo cyx  部署应取消注释(自测试,可注释,不验证短信直接登录)
            if (!wlyyRedisVerifyCodeService.verification(client_id, username, captcha)){
                throw new InvalidGrantException("Invalid captcha");
            }
            String password = parameters.get("password");
//            parameters.remove("password");
            SaltUser userDetails = (SaltUser)userDetailsService.loadUserByUsername(username);
            if(userDetails==null){
                throw new InvalidGrantException("Could not authenticate user: " + username);
            }
            String pwd = MD5.md5Hex(password+ "{" + userDetails.getSalt() + "}");
            if(!pwd.equals(userDetails.getPassword())){
                throw new InvalidGrantException("Bad credentials");
            }
            if (!userDetails.isEnabled()) {
                throw new InvalidGrantException("User is disabled");
            }
            if (!userDetails.isAccountNonLocked()) {
                throw new InvalidGrantException("User account is locked");
            }
            Authentication userAuth = new UsernamePasswordAuthenticationToken(username,userDetails.getPassword(),  this.authoritiesMapper.mapAuthorities(userDetails.getAuthorities()));
            ((AbstractAuthenticationToken) userAuth).setDetails(parameters);
            OAuth2Request storedOAuth2Request = getRequestFactory().createOAuth2Request(client, tokenRequest);
            return new OAuth2Authentication(storedOAuth2Request, userAuth);
        }
    }
}

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

@ -410,6 +410,14 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
                Oauth2Envelop<WlyyUserSimple> oauth2Envelop = new Oauth2Envelop<>("获取用户手机号失败", -1, null);
                return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
            }
        } else if("1".equals(parameters.get("pwdAndCaptcha"))){
            parameters.put("grant_type", "pwdAndCaptcha");
            KeyPair keyPair = (KeyPair) httpSession.getAttribute("privateKey");
            String password = com.yihu.jw.security.utils.RSAUtils.decryptBase64(parameters.get("password"), keyPair);
            parameters.put("password", password);
//            if (!testPwd(parameters.get("password"))) {
//                throw new PwdException("密码强度低,请修改密码后再重新登录!");
//            }
        } else if (StringUtils.isEmpty(parameters.get("captcha"))) {
            parameters.put("grant_type", "password");
            //解密密码
@ -524,6 +532,17 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        return getResponse(wlyyUserSimple);
    }
    private boolean testPwd(String pwd){
        //3种
        String PW_PATTERN2 = "^(?![A-Za-z0-9]+$)(?![A-Za-z\\W]+$)[a-zA-Z0-9_\\W]{8,}$";
        if(org.apache.commons.lang3.StringUtils.isBlank(pwd)){
            return false;
        }
        if(pwd.length()<8||pwd.length()>20){
            return false;
        }
        return pwd.matches(PW_PATTERN2);
    }
    /**
     * 单点登陆第二步 - token验证

+ 2 - 0
starter/elasticsearch-starter/src/main/java/com/yihu/jw/elasticsearch/ElasticSearch7Pool.java

@ -94,6 +94,8 @@ public class ElasticSearch7Pool {
    public ResultSet restHighLevelClientStream(String sql) throws Exception {
//        Connection connection = DriverManager.getConnection("jdbc:es://http://172.26.0.55:9200","elastic","elastic");
//        Connection connection = DriverManager.getConnection("jdbc:es://http://172.26.0.168:9200/","elastic","elastic");
        System.out.println("连接地址==>hosts:"+hosts);
        System.out.println("es账号密码==>userName:"+userName+"   -------------  password:"+password);
        Connection connection = DriverManager.getConnection("jdbc:es://" + hosts, userName, password);
        Statement statement = connection.createStatement();
        ResultSet resultSet = statement.executeQuery(sql);

+ 5 - 10
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/dict/DictJobTitleEndpoint.java

@ -76,16 +76,11 @@ public class DictJobTitleEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = BaseRequestMapping.DictJobTitle.PAGE)
    @ApiOperation(value = "获取分页")
    public PageEnvelop<DictJobTitleVO> page(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段") @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件") @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档") @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1") @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15") @RequestParam(value = "size") int size) throws Exception {
        List<DictJobTitleDO> dictJobTitles = dictJobTitleService.search(fields, filters, sorts, page, size);
        int count = (int) dictJobTitleService.getCount(filters);
        return success(dictJobTitles, count, page, size, DictJobTitleVO.class);

+ 268 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/archives/MedicalRecordCopyingEndpoint.java

@ -1,13 +1,20 @@
package com.yihu.jw.hospital.endpoint.archives;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.common.CommonSmsService;
import com.yihu.jw.contant.CommonContant;
import com.yihu.jw.entity.base.patient.BaseIdcardRecordDO;
import com.yihu.jw.entity.base.patient.BaseMedicalRecordCopyingApplyDO;
import com.yihu.jw.entity.hospital.record.HospitalPatientInpatientRecordDO;
import com.yihu.jw.hospital.record.service.HospitalPatientInpatientRecordService;
import com.yihu.jw.patient.dao.BaseIdcardRecordDao;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.entity.ServiceException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -15,8 +22,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
import java.util.*;
/**
 * Created by yeshijie on 2022/11/28.
@ -30,6 +36,266 @@ public class MedicalRecordCopyingEndpoint extends EnvelopRestEndpoint {
    private HospitalPatientInpatientRecordService inpatientRecordService;
    @Autowired
    private BaseIdcardRecordDao idcardRecordDao;
    @Autowired
    private CommonSmsService commonSmsService;
    private static final Integer expire = 600;//5分钟
    @PostMapping(value = "cancelApply")
    @ApiOperation(value = "取消复印")
    public Envelop cancelApply (
            @ApiParam(name = "id", value = "申请id")
            @RequestParam(value = "id", required = true) String id) {
        try {
            inpatientRecordService.cancelApply(id);
            return Envelop.getSuccess(CommonContant.Message.OPERATE_SUCCESS);
        }catch (ServiceException se){
            return Envelop.getError(se.getMessage());
        }catch (Exception e){
            e.printStackTrace();
        }
        return Envelop.getError(CommonContant.Message.GET_ERROR);
    }
    @PostMapping(value = "changePickupWay")
    @ApiOperation(value = "改为自取")
    public Envelop changePickupWay (
            @ApiParam(name = "id", value = "申请id")
            @RequestParam(value = "id", required = true) String id) {
        try {
            inpatientRecordService.changePickupWay(id);
            return Envelop.getSuccess(CommonContant.Message.OPERATE_SUCCESS);
        }catch (ServiceException se){
            return Envelop.getError(se.getMessage());
        }catch (Exception e){
            e.printStackTrace();
        }
        return Envelop.getError(CommonContant.Message.GET_ERROR);
    }
    @GetMapping(value = "applyDetail")
    @ApiOperation(value = "申请详情")
    public ObjEnvelop applyDetail (
            @ApiParam(name = "id", value = "申请id")
            @RequestParam(value = "id", required = true) String id) {
        try {
            return ObjEnvelop.getSuccess("获取成功",inpatientRecordService.applyDetail(id));
        }catch (Exception e){
            e.printStackTrace();
        }
        return ObjEnvelop.getError(CommonContant.Message.GET_ERROR);
    }
    @GetMapping(value = "applyPage")
    @ApiOperation(value = "复印病案申请列表")
    public PageEnvelop applyPage (
            @ApiParam(name = "patient", value = "居民id")
            @RequestParam(value = "patient", required = false) String patient,
            @ApiParam(name = "name", value = "姓名")
            @RequestParam(value = "name", required = false) String name,
            @ApiParam(name = "status", value = "状态")
            @RequestParam(value = "status", required = false) String status,
            @ApiParam(name = "startTime", value = "开始时间")
            @RequestParam(value = "startTime", required = false) String startTime,
            @ApiParam(name = "endTime", value = "结束时间")
            @RequestParam(value = "endTime", required = false) String endTime,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") Integer page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") Integer size) {
        try {
            return inpatientRecordService.applyPage(patient, page, size,name,status,startTime,endTime);
        }catch (Exception e){
            e.printStackTrace();
        }
        return PageEnvelop.getError(CommonContant.Message.GET_ERROR);
    }
    @ApiOperation("通用发送短信验证码")
    @PostMapping(value = "sendSms")
    public MixEnvelop sendCaptcha(@ApiParam(name = "jsonData", value = "jsonData", required = false)
                                  @RequestParam(value = "jsonData", required = false) String jsonData) throws Exception {
        try {
            MixEnvelop mixEnvelop = new MixEnvelop();
            JSONObject obj = JSONObject.parseObject(jsonData);
            String client_id = obj.getString("client_id");
            String type = obj.getString("type");//类型 idInfoFilling 身份证信息填写
            String phoneNum = obj.getString("phoneNum");
            if (StringUtils.isEmpty(client_id)) {
                mixEnvelop.setStatus(468);
                mixEnvelop.setMessage("client_id不能为空");
                return mixEnvelop;
            }
            if (StringUtils.isEmpty(type)) {
                mixEnvelop.setStatus(468);
                mixEnvelop.setMessage("类型不能为空");
                return mixEnvelop;
            }
            if (StringUtils.isEmpty(phoneNum)) {
                mixEnvelop.setStatus(468);
                mixEnvelop.setMessage("电话号不能为空");
                return mixEnvelop;
            }
            if (phoneNum.length() > 12) {
                mixEnvelop.setStatus(468);
                mixEnvelop.setMessage("请输入正确的手机号");
                return mixEnvelop;
            }
            //验证请求间隔超时,防止频繁获取验证码
            if (!commonSmsService.isIntervalTimeout(client_id, phoneNum,type)) {
                throw new IllegalAccessException("SMS request frequency is too fast");
                //发送短信获取验证码
            }
            mixEnvelop = commonSmsService.sendSms(client_id,phoneNum,expire,type,mixEnvelop);
            return mixEnvelop;
        }catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError("短信发送失败");
        }
    }
    @PostMapping(value = "apply")
    @ApiOperation(value = "申请病案复印")
    public Envelop apply(@ApiParam(name = "jsonData", value = "json入参")
                                 @RequestParam(value = "jsonData", required = true) String jsonData){
        try {
            BaseMedicalRecordCopyingApplyDO applyDO = JSONObject.parseObject(jsonData,BaseMedicalRecordCopyingApplyDO.class);
            if(StringUtils.isBlank(applyDO.getPatientId())){
                return Envelop.getError("参数错误-未选择就诊人");
            }
            if(StringUtils.isBlank(applyDO.getUseTo())){
                return Envelop.getError("参数错误-未选择复印用途");
            }
            if(StringUtils.isBlank(applyDO.getPatientRelation())){
                return Envelop.getError("参数错误-未选择与就诊人关系");
            }
            if(StringUtils.isBlank(applyDO.getAppendix1())){
                return Envelop.getError("参数错误-未上传患者证件头像面");
            }
            if(StringUtils.isBlank(applyDO.getAppendix2())){
                return Envelop.getError("参数错误-未上传患者证件国徽面");
            }
            if(StringUtils.isBlank(applyDO.getAppendix3())){
                return Envelop.getError("参数错误-未上传患者手持头像面");
            }
            if(StringUtils.isBlank(applyDO.getAppendix4())){
                return Envelop.getError("参数错误-未上传申请人证件头像面");
            }
            if(StringUtils.isBlank(applyDO.getAppendix5())){
                return Envelop.getError("参数错误-未上传申请人证件国徽面");
            }
            if(!"1".equals(applyDO.getPatientRelation())){
                if(StringUtils.isBlank(applyDO.getApplyName())){
                    return Envelop.getError("参数错误-未填写申请人姓名");
                }
                if(StringUtils.isBlank(applyDO.getApplyIdcard())){
                    return Envelop.getError("参数错误-未填写申请人身份证");
                }
            }
            if(StringUtils.isBlank(applyDO.getApplyMobile())){
                return Envelop.getError("参数错误-未填写手机号码");
            }
            if(StringUtils.isBlank(applyDO.getCaseId())){
                return Envelop.getError("参数错误-未选择住院病例");
            }
            if(applyDO.getApplyTypeList()==null||applyDO.getApplyTypeList().size()==0){
                return Envelop.getError("参数错误-未选择复印内容");
            }
            if(applyDO.getExpressageDO()==null){
                return Envelop.getError("参数错误-未填写取件信息");
            }
            inpatientRecordService.apply(applyDO);
            return Envelop.getSuccess("申请提交成功");
        }catch (Exception e){
            e.printStackTrace();
            return Envelop.getError("操作失败");
        }
    }
    @PostMapping(value = "idInfoFilling")
    @ApiOperation(value = "身份信息填写")
    public Envelop idInfoFilling(@ApiParam(name = "jsonData", value = "json入参")
                              @RequestParam(value = "jsonData", required = true) String jsonData){
        try {
            JSONObject json = JSON.parseObject(jsonData);
            String patientId = json.getString("patientId");
            String patientName = json.getString("patientName");
            String patientIdcard = json.getString("patientIdcard");
            String useTo = json.getString("useTo");
            String patientRelation = json.getString("patientRelation");
            String applyName = json.getString("applyName");
            String applyIdcard = json.getString("applyIdcard");
            String applyMobile = json.getString("applyMobile");
            String captcha = json.getString("captcha");
            String client_id = json.getString("client_id");
            if(StringUtils.isBlank(client_id)){
                return Envelop.getError("参数错误");
            }
            if(StringUtils.isBlank(patientId)){
                return Envelop.getError("请选择就诊人");
            }
            if(StringUtils.isBlank(useTo)){
                return Envelop.getError("请选择复印用途");
            }
            if(StringUtils.isBlank(patientRelation)){
                return Envelop.getError("请选择与就诊人关系");
            }
            if(!"1".equals(patientRelation)){
                if(StringUtils.isBlank(applyName)){
                    return Envelop.getError("请填写申请人姓名");
                }
                if(StringUtils.isBlank(applyIdcard)){
                    return Envelop.getError("请填写申请人身份证");
                }
            }
            if(StringUtils.isBlank(applyMobile)){
                return Envelop.getError("请填写手机号码");
            }
            if(StringUtils.isBlank(captcha)){
                return Envelop.getError("请填写验证码");
            }
            //判断验证码
            boolean checkCode = commonSmsService.verification(client_id, applyMobile, captcha,"1");
            if(!checkCode){
                return Envelop.getError("验证码错误");
            }
            //判断居民是否有住院记录-对接第三方
            return Envelop.getSuccess("操作成功");
        }catch (Exception e){
            e.printStackTrace();
            return Envelop.getError("操作失败");
        }
    }
    @GetMapping(value = "hospitalRecordPage")
    @ApiOperation(value = "住院记录分页")
    public PageEnvelop hospitalRecordPage (
            @ApiParam(name = "patient", value = "居民id")
            @RequestParam(value = "patient", required = true) String patient,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") Integer page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") Integer size) {
        try {
            List<Map<String,Object>>  recordDOS = new ArrayList<>();
            Map<String,Object> map = new HashMap<>();
            map.put("id","1");
            map.put("deptName","骨科一病区");//科室名称
            map.put("hospitalNum","1");//住院次数
            map.put("outpatientTime","2023-12-27 08:58:00");//出院时间
            recordDOS.add(map);
            return PageEnvelop.getSuccessListWithPage(CommonContant.Message.GET_SUCCESS,recordDOS,page,size,1L);
        }catch (Exception e){
            e.printStackTrace();
        }
        return PageEnvelop.getError(CommonContant.Message.GET_ERROR);
    }
    @GetMapping(value = "page")
    @ApiOperation(value = "获取病例分页")

+ 17 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/article/BaseMenuNoLoginEndpoint.java

@ -3,7 +3,9 @@ package com.yihu.jw.hospital.endpoint.article;
import com.yihu.jw.article.dao.KnowledgeArticleDictDao;
import com.yihu.jw.article.service.BaseMenuManageService;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleBrowseDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDictDO;
import com.yihu.jw.hospital.dao.consult.KnowledgeArticleDao;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
@ -27,6 +29,8 @@ public class BaseMenuNoLoginEndpoint extends EnvelopRestEndpoint {
    @Resource
    private KnowledgeArticleDictDao knowledgeArticleDictDao;
    @Autowired
    private KnowledgeArticleDao knowledgeArticleDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @GetMapping(value = BaseRequestMapping.MenuNologin.findAllMenu)
@ -74,6 +78,19 @@ public class BaseMenuNoLoginEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "queryById2")
    @ApiOperation(value = "根据id查询文章")
    public Envelop queryById2(
            @ApiParam(name = "id", value = "id", required = true)
            @RequestParam(value = "id", required = true)String id) {
        try {
            KnowledgeArticleDO articleDO = knowledgeArticleDao.findById(id).orElse(null);
            return success(articleDO);
        }catch (Exception e){
            return failedException(e);
        }
    }
    @GetMapping(value = BaseRequestMapping.MenuNologin.queryById)
    @ApiOperation(value = "根据id查询文章")
    public Envelop queryByCode(

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

@ -291,14 +291,19 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
							mes="已挂号";
						}
					}else if("xm_dsyy_wx".equals(wxId)){ //dsyy医院挂号
						if (!outpatientDO.getOutpatientType().equalsIgnoreCase("2")&&!outpatientDO.getOutpatientType().equalsIgnoreCase("3")
								&&!outpatientDO.getOutpatientType().equalsIgnoreCase("4")){
							JSONObject res = dsyyPrescriptionService.registerOutPatient(outpatientCode,doctorCode);
							rsCode = res.getString("@RESULT");
							mes = res.getString("@MSG");
						}else  {
						if (demoFlag.equalsIgnoreCase("true")){
							rsCode="0";
							mes="已挂号";
						}else {
							if (!outpatientDO.getOutpatientType().equalsIgnoreCase("2")&&!outpatientDO.getOutpatientType().equalsIgnoreCase("3")
									&&!outpatientDO.getOutpatientType().equalsIgnoreCase("4")){
								JSONObject res = dsyyPrescriptionService.registerOutPatient(outpatientCode,doctorCode);
								rsCode = res.getString("@RESULT");
								mes = res.getString("@MSG");
							}else  {
								rsCode="0";
								mes="已挂号";
							}
						}
					}else {
						if (demoFlag.equalsIgnoreCase("true")){

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

@ -69,950 +69,924 @@ import java.util.*;
@Api(value = "居民端咨询IM接口", description = "居民端咨询IM接口", tags = {"居民端咨询IM接口"})
public class PatientConsultEndpoint extends EnvelopRestEndpoint {
	private static final Logger logger = LoggerFactory.getLogger(PatientConsultEndpoint.class);
	@Autowired
	private ImService imService;
	
	@Autowired
	private PrescriptionService prescriptionService;
	
	@Autowired
	private BasePatientService basePatientService;
	
	
	@Autowired
	private WechatInfoService wechatInfoService;
	
	@Autowired
	private WechatDao wechatDao;
	
	@Autowired
	private HospitalSystemMessageService hospitalSystemMessageService;
	@Autowired
	private EnterpriseService enterpriseService;
	
	@Autowired
	private WlyyBusinessService wlyyBusinessService;
	@Autowired
	private BaseDoctorDao baseDoctorDao;
	@Autowired
	private BasePatientDao basePatientDao;
	
	@Autowired
	FileUploadService fileUploadService;
	@Autowired
	private BaseDoctorInfoService doctorInfoService;
	@Autowired
	private BusinessOrderService businessOrderService;
	@Autowired
	private SystemMessageService systemMessageService;
	@Autowired
	private ConsultDao consultDao;
	@Autowired
	private YkyyService ykyyService;
	@Autowired
	private BaseDoctorRoleDao doctorRoleDao;
	@Autowired
	public ImUtil imUtil;
	@Autowired
	private OutpatientDao outpatientDao;
	@Autowired
	private YlzPayService ylzPayService;
	@Autowired
	private PatientMappingDao patientMappingDao;
	@Autowired
	private PrescriptionDao prescriptionDao;
	@Autowired
	private EntranceService entranceService;
	@Autowired
	private WlyyFamilyMemberService familyMemberService;
	@Value("${fastDFS.fastdfs_file_url}")
	private String fastdfs_file_url;
	
	@Value("${wlyy.url}")
	private String wlyyUrl;
	
	@Value("${qywx.url}")
	private String qywxUrl;
	
	@Value("${qywx.id}")
	private String qywxId;
	@Value("${wechat.id}")
	private String wxId;
	@Value("${pay.flag}")
	private boolean payFlag;
	@Value("${testPattern.remote_inner_url}")
	private String remote_inner_url;
	@Autowired
	private RobotService robotService;
	@Autowired
	private FileUtil fileUtil;
	
	@GetMapping(value = BaseHospitalRequestMapping.PatientIM.records)
	@ApiOperation(value = "患者咨询记录查询")
	public Envelop records(
								@ApiParam(name = "patient", value = "居民id")
								@RequestParam(value = "patient",required = true) String patient,
								@ApiParam(name = "doctorId", value = "医生id",required = false)
								@RequestParam(value = "doctorId",required = false) String doctorId,
								@ApiParam(name = "title", value = "咨询标题关键字")
								@RequestParam(value = "title",required = false) String title,
								@ApiParam(name = "id", value = "咨询ID")
								@RequestParam(value = "id",required = false) String id,
								@ApiParam(name = "type", value = "咨询类型")
								@RequestParam(value = "type",required = true) String type,
								@ApiParam(name = "status", value = "咨询状态:0全部,1候诊中,2就诊中,3结束")
								@RequestParam(value = "status",required = false) Integer status,
								@ApiParam(name = "payStatus", value = "支付状态0支付1已支付")
								@RequestParam(value = "payStatus",required = false) Integer payStatus,
								@ApiParam(name = "page", value = "第几页")
								@RequestParam(value = "page",required = false) int page,
								@ApiParam(name = "pagesize", value = "分页大小")
								@RequestParam(value = "pagesize",required = false) int pagesize,
								@ApiParam(name = "doctorName", value = "医生名字")
								@RequestParam(value = "doctorName",required = false) String doctorName
								){
		try {
			List<Map<String,Object>>  data = imService.findConsultRecordByPatient(patient, id,type, page,pagesize, title,status,payStatus,doctorName,doctorId);
			Long total = imService.countConsultRecordByPatient(patient, id,type,title,doctorId);
			JSONObject result = new JSONObject();
			result.put("total",total);
			result.put("list",data);
			return success(result);
		}catch (Exception e){
			return failedException(e);
		}
	}
	
	@GetMapping(value = BaseHospitalRequestMapping.PatientIM.isExistsUnfinishedConsult)
	@ApiOperation(value = "查询居民与某个医生是否存在未结束的专家咨询")
	public Envelop isExistsUnfinishedConsult(
			@ApiParam(name = "doctor", value = "医生CODE")
			@RequestParam(value = "doctor",required = true) String doctor,
			@ApiParam(name = "patient", value = "居民CODE")
			@RequestParam(value = "patient",required = true) String patient)throws Exception {
		
		try {
			if(StringUtils.isEmpty(patient)){
				patient= getUID();
			}
			String consultCode = imService.getUnfinishedConsult(patient, doctor);
			return success("请求成功",consultCode);
		}catch (Exception e){
			return failedException(e);
		}
	}
	@GetMapping(value = BaseHospitalRequestMapping.PatientIM.isExistsUnfinishedOutpatient)
	@ApiOperation(value = "查询居民与某个医生是否存在未结束的专家咨询")
	public Envelop isExistsUnfinishedOutpatient(
			@ApiParam(name = "doctor", value = "医生CODE")
			@RequestParam(value = "doctor",required = true) String doctor,
			@ApiParam(name = "patient", value = "居民CODE")
			@RequestParam(value = "patient",required = true) String patient)throws Exception {
		try {
			if(StringUtils.isEmpty(patient)){
				patient= getUID();
			}
			String consultCode = imService.getUnfinishedConsult2(patient, doctor);
			return success("请求成功",consultCode);
		}catch (Exception e){
			return failedException(e);
		}
	}
	
	@GetMapping(value = BaseHospitalRequestMapping.PatientIM.participants)
	@ApiOperation(value = "获取会话成员")
	public ListEnvelop participants(
			@ApiParam(name = "sessionId", value = "会话ID")
			@RequestParam(value = "sessionId",required = true) String sessionId)throws Exception{
		
		try {
			JSONArray participants = imService.getSessions(sessionId);
			return success(participants);
		}catch (Exception e){
			return failedListEnvelopException(e);
		}
	}
	
	@GetMapping(value = BaseHospitalRequestMapping.PatientIM.getSessionMessage)
	@ApiOperation(value = "根据会话ID获取消息记录")
	public ListEnvelop getSessionMessage(
			@ApiParam(name = "sessionId", value = "会话ID")
			@RequestParam(value = "sessionId",required = true) String sessionId,
			@ApiParam(name = "startMsgId", value = "开始的消息记录ID")
			@RequestParam(value = "startMsgId",required = false) String startMsgId,
			@ApiParam(name = "endMsgId", value = "结束的消息记录ID")
			@RequestParam(value = "endMsgId",required = false) String endMsgId,
			@ApiParam(name = "page", value = "第几页")
			@RequestParam(value = "page",required = true) int page,
			@ApiParam(name = "pagesize", value = "分页数")
			@RequestParam(value = "pagesize",required = true) int pagesize)throws Exception{
		try {
			JSONArray messageArray = imService.getSessionMessage(sessionId, startMsgId, endMsgId, page, pagesize, getUID());
			return success(messageArray);
		}catch (Exception e){
			return failedListEnvelopException(e);
		}
	}
	
	@PostMapping(value = BaseHospitalRequestMapping.PatientIM.intoTopic)
	@ApiOperation(value = "根据咨询CODE进入会话")
	public Envelop intoTopic(
			@ApiParam(name = "consult", value = "咨询CODE")
			@RequestParam(value = "consult",required = true) String consult,
			@ApiParam(name = "patientCode", value = "居民CODE")
			@RequestParam(value = "patientCode",required = true) String patientCode
			){
		try {
			int result = imService.intoTopic(consult,patientCode,"");
			if(result==-1){
				return failed("该咨询不是进行中");
			}
			return success("进入成功");
		}catch (Exception e){
			return failedException(e);
		}
	}
	
	@PostMapping(value = BaseHospitalRequestMapping.PatientIM.append)
	@ApiOperation(value = "居民咨询发消息(追问接口)")
	public ListEnvelop append(
			@ApiParam(name = "consult", value = "咨询CODE")
			@RequestParam(value = "consult",required = true) String consult,
			@ApiParam(name = "content", value = "追问内容")
			@RequestParam(value = "content",required = true) String content,
			@ApiParam(name = "type", value = "追问内容类型:1文字,2图片,3语音  ... (im消息类型)")
			@RequestParam(value = "type",required = true) Integer type,
			@ApiParam(name = "times", value = "")
			@RequestParam(value = "times",required = false) Integer times,
			@ApiParam(name = "wechat_appid", value = "来源:xm_ihealth_wx厦门i健康,xm_zsyy_wx中山医院")
			@RequestParam(value = "wechat_appid",required = false) String wechat_appid,
			@ApiParam(name = "patientCode", value = "居民CODE")
			@RequestParam(value = "patientCode",required = false) String patientCode) throws Exception {
		try {
			List<String> failed = new ArrayList<>();
			//处理语音文件
			if(!org.springframework.util.StringUtils.isEmpty(wechat_appid)){
    private static final Logger logger = LoggerFactory.getLogger(PatientConsultEndpoint.class);
    @Autowired
    private ImService imService;
    @Autowired
    private PrescriptionService prescriptionService;
    @Autowired
    private BasePatientService basePatientService;
    @Autowired
    private WechatInfoService wechatInfoService;
    @Autowired
    private WechatDao wechatDao;
    @Autowired
    private HospitalSystemMessageService hospitalSystemMessageService;
    @Autowired
    private EnterpriseService enterpriseService;
    @Autowired
    private WlyyBusinessService wlyyBusinessService;
    @Autowired
    private BaseDoctorDao baseDoctorDao;
    @Autowired
    private BasePatientDao basePatientDao;
    @Autowired
    FileUploadService fileUploadService;
    @Autowired
    private BaseDoctorInfoService doctorInfoService;
    @Autowired
    private BusinessOrderService businessOrderService;
    @Autowired
    private SystemMessageService systemMessageService;
    @Autowired
    private ConsultDao consultDao;
    @Autowired
    private YkyyService ykyyService;
    @Autowired
    private BaseDoctorRoleDao doctorRoleDao;
    @Autowired
    public ImUtil imUtil;
    @Autowired
    private OutpatientDao outpatientDao;
    @Autowired
    private YlzPayService ylzPayService;
    @Autowired
    private PatientMappingDao patientMappingDao;
    @Autowired
    private PrescriptionDao prescriptionDao;
    @Autowired
    private EntranceService entranceService;
    @Autowired
    private WlyyFamilyMemberService familyMemberService;
    @Value("${fastDFS.fastdfs_file_url}")
    private String fastdfs_file_url;
    @Value("${wlyy.url}")
    private String wlyyUrl;
    @Value("${qywx.url}")
    private String qywxUrl;
    @Value("${qywx.id}")
    private String qywxId;
    @Value("${wechat.id}")
    private String wxId;
    @Value("${pay.flag}")
    private boolean payFlag;
    @Value("${testPattern.remote_inner_url}")
    private String remote_inner_url;
    @Autowired
    private RobotService robotService;
    @Autowired
    private FileUtil fileUtil;
    @GetMapping(value = BaseHospitalRequestMapping.PatientIM.records)
    @ApiOperation(value = "患者咨询记录查询")
    public Envelop records(
            @ApiParam(name = "patient", value = "居民id") @RequestParam(value = "patient", required = true) String patient,
            @ApiParam(name = "doctorId", value = "医生id", required = false) @RequestParam(value = "doctorId", required = false) String doctorId,
            @ApiParam(name = "title", value = "咨询标题关键字") @RequestParam(value = "title", required = false) String title,
            @ApiParam(name = "id", value = "咨询ID") @RequestParam(value = "id", required = false) String id,
            @ApiParam(name = "type", value = "咨询类型") @RequestParam(value = "type", required = true) String type,
            @ApiParam(name = "status", value = "咨询状态:0全部,1候诊中,2就诊中,3结束") @RequestParam(value = "status", required = false) Integer status,
            @ApiParam(name = "payStatus", value = "支付状态0支付1已支付") @RequestParam(value = "payStatus", required = false) Integer payStatus,
            @ApiParam(name = "page", value = "第几页") @RequestParam(value = "page", required = false) int page,
            @ApiParam(name = "pagesize", value = "分页大小") @RequestParam(value = "pagesize", required = false) int pagesize,
            @ApiParam(name = "doctorName", value = "医生名字") @RequestParam(value = "doctorName", required = false) String doctorName
    ) {
        try {
            List<Map<String, Object>> data = imService.findConsultRecordByPatient(patient, id, type, page, pagesize, title, status, payStatus, doctorName, doctorId);
            Long total = imService.countConsultRecordByPatient(patient, id, type, title, doctorId);
            JSONObject result = new JSONObject();
            result.put("total", total);
            result.put("list", data);
            return success(result);
        } catch (Exception e) {
            return failedException(e);
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.PatientIM.isExistsUnfinishedConsult)
    @ApiOperation(value = "查询居民与某个医生是否存在未结束的专家咨询")
    public Envelop isExistsUnfinishedConsult(
            @ApiParam(name = "doctor", value = "医生CODE")
            @RequestParam(value = "doctor", required = true) String doctor,
            @ApiParam(name = "patient", value = "居民CODE")
            @RequestParam(value = "patient", required = true) String patient) throws Exception {
        try {
            if (StringUtils.isEmpty(patient)) {
                patient = getUID();
            }
            String consultCode = imService.getUnfinishedConsult(patient, doctor);
            return success("请求成功", consultCode);
        } catch (Exception e) {
            return failedException(e);
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.PatientIM.isExistsUnfinishedOutpatient)
    @ApiOperation(value = "查询居民与某个医生是否存在未结束的专家咨询")
    public Envelop isExistsUnfinishedOutpatient(
            @ApiParam(name = "doctor", value = "医生CODE")
            @RequestParam(value = "doctor", required = true) String doctor,
            @ApiParam(name = "patient", value = "居民CODE")
            @RequestParam(value = "patient", required = true) String patient) throws Exception {
        try {
            if (StringUtils.isEmpty(patient)) {
                patient = getUID();
            }
            String consultCode = imService.getUnfinishedConsult2(patient, doctor);
            return success("请求成功", consultCode);
        } catch (Exception e) {
            return failedException(e);
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.PatientIM.participants)
    @ApiOperation(value = "获取会话成员")
    public ListEnvelop participants(
            @ApiParam(name = "sessionId", value = "会话ID")
            @RequestParam(value = "sessionId", required = true) String sessionId) throws Exception {
        try {
            JSONArray participants = imService.getSessions(sessionId);
            return success(participants);
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.PatientIM.getSessionMessage)
    @ApiOperation(value = "根据会话ID获取消息记录")
    public ListEnvelop getSessionMessage(
            @ApiParam(name = "sessionId", value = "会话ID")
            @RequestParam(value = "sessionId", required = true) String sessionId,
            @ApiParam(name = "startMsgId", value = "开始的消息记录ID")
            @RequestParam(value = "startMsgId", required = false) String startMsgId,
            @ApiParam(name = "endMsgId", value = "结束的消息记录ID")
            @RequestParam(value = "endMsgId", required = false) String endMsgId,
            @ApiParam(name = "page", value = "第几页")
            @RequestParam(value = "page", required = true) int page,
            @ApiParam(name = "pagesize", value = "分页数")
            @RequestParam(value = "pagesize", required = true) int pagesize) throws Exception {
        try {
            JSONArray messageArray = imService.getSessionMessage(sessionId, startMsgId, endMsgId, page, pagesize, getUID());
            return success(messageArray);
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    @PostMapping(value = BaseHospitalRequestMapping.PatientIM.intoTopic)
    @ApiOperation(value = "根据咨询CODE进入会话")
    public Envelop intoTopic(
            @ApiParam(name = "consult", value = "咨询CODE")
            @RequestParam(value = "consult", required = true) String consult,
            @ApiParam(name = "patientCode", value = "居民CODE")
            @RequestParam(value = "patientCode", required = true) String patientCode
    ) {
        try {
            int result = imService.intoTopic(consult, patientCode, "");
            if (result == -1) {
                return failed("该咨询不是进行中");
            }
            return success("进入成功");
        } catch (Exception e) {
            return failedException(e);
        }
    }
    @PostMapping(value = BaseHospitalRequestMapping.PatientIM.append)
    @ApiOperation(value = "居民咨询发消息(追问接口)")
    public ListEnvelop append(
            @ApiParam(name = "consult", value = "咨询CODE")
            @RequestParam(value = "consult", required = true) String consult,
            @ApiParam(name = "content", value = "追问内容")
            @RequestParam(value = "content", required = true) String content,
            @ApiParam(name = "type", value = "追问内容类型:1文字,2图片,3语音  ... (im消息类型)")
            @RequestParam(value = "type", required = true) Integer type,
            @ApiParam(name = "times", value = "")
            @RequestParam(value = "times", required = false) Integer times,
            @ApiParam(name = "wechat_appid", value = "来源:xm_ihealth_wx厦门i健康,xm_zsyy_wx中山医院")
            @RequestParam(value = "wechat_appid", required = false) String wechat_appid,
            @ApiParam(name = "patientCode", value = "居民CODE")
            @RequestParam(value = "patientCode", required = false) String patientCode) throws Exception {
        try {
            List<String> failed = new ArrayList<>();
            //处理语音文件
            if (!org.springframework.util.StringUtils.isEmpty(wechat_appid)) {
//			imService.getInputStream("1",wechat_appid);
				if(3 == type){//语音文件
					String voicepath = imService.fetchWxVoices(wechat_appid);
					logger.info("voice_path:"+voicepath);
					JSONObject obj = new JSONObject();
					String voiceurl = "";
					// 将临时语音拷贝到正式存储路径下
					if (org.apache.commons.lang3.StringUtils.isNotEmpty(voicepath)) {
						if("xm_ihealth_wx".equals(wechat_appid)){
							logger.info("voice_wx_type:"+wechat_appid);
							voiceurl = fileUploadService.uploadWxVoice(voicepath);
                if (3 == type) {//语音文件
                    String voicepath = imService.fetchWxVoices(wechat_appid);
                    logger.info("voice_path:" + voicepath);
                    JSONObject obj = new JSONObject();
                    String voiceurl = "";
                    // 将临时语音拷贝到正式存储路径下
                    if (org.apache.commons.lang3.StringUtils.isNotEmpty(voicepath)) {
                        if ("xm_ihealth_wx".equals(wechat_appid)) {
                            logger.info("voice_wx_type:" + wechat_appid);
                            voiceurl = fileUploadService.uploadWxVoice(voicepath);
//					uploadVO.setFullUri(map.get("accessory").toString());
						}else if ("xm_xzzx_wx".equalsIgnoreCase(wechat_appid)||"xm_hcyy_wx".equalsIgnoreCase(wechat_appid)){
							voiceurl = fileUploadService.uploadWxVoiceToEntrance(remote_inner_url,voicepath);
							logger.info(voiceurl);
						}else {
							voiceurl = fileUtil.copyTempVoice(voicepath,fastdfs_file_url);
						}
						obj.put("path", voiceurl);
						obj.put("times", times);
						content = obj.toString();
					}
				}else if(2 == type){//图片文件
					String imagepath = imService.fetchWxImages(wechat_appid);
					logger.info("image_path:"+imagepath);
					JSONObject obj = new JSONObject();
					String imgeUrl = "";
					// 将临时语音拷贝到正式存储路径下
					if (org.apache.commons.lang3.StringUtils.isNotEmpty(imagepath)) {
						if("xm_ihealth_wx".equals(wechat_appid)){
							logger.info("imge_wx_type:"+wechat_appid);
							imgeUrl = fileUploadService.uploadWxImage(imagepath);
                        } else if ("xm_xzzx_wx".equalsIgnoreCase(wechat_appid) || "xm_hcyy_wx".equalsIgnoreCase(wechat_appid)) {
                            voiceurl = fileUploadService.uploadWxVoiceToEntrance(remote_inner_url, voicepath);
                            logger.info(voiceurl);
                        } else {
                            voiceurl = fileUtil.copyTempVoice(voicepath, fastdfs_file_url);
                        }
                        obj.put("path", voiceurl);
                        obj.put("times", times);
                        content = obj.toString();
                    }
                } else if (2 == type) {//图片文件
                    String imagepath = imService.fetchWxImages(wechat_appid);
                    logger.info("image_path:" + imagepath);
                    JSONObject obj = new JSONObject();
                    String imgeUrl = "";
                    // 将临时语音拷贝到正式存储路径下
                    if (org.apache.commons.lang3.StringUtils.isNotEmpty(imagepath)) {
                        if ("xm_ihealth_wx".equals(wechat_appid)) {
                            logger.info("imge_wx_type:" + wechat_appid);
                            imgeUrl = fileUploadService.uploadWxImage(imagepath);
//					uploadVO.setFullUri(map.get("accessory").toString());
						}else{
							imgeUrl = fileUtil.copyTempVoice(imagepath,fastdfs_file_url);
						}
						content = imgeUrl;
					}
				}else{}
			}
			failed = imService.append(consult,content,type,times,patientCode,wechat_appid);
			return success(failed);
		}catch (Exception e){
			return failedListEnvelopException(e);
		}
	}
	
	@GetMapping(value = BaseHospitalRequestMapping.Prescription.findDoctorByHospitalAndDiseaseAndDept)
	@ApiOperation(value = "根据疾病名称,热门部门查询医生", notes = "根据疾病名称,热门部门查询医生")
	public MixEnvelop findDoctorByHospitalAndDiseaseAndDept(@ApiParam(name = "iswork", value = "机构code")
																 @RequestParam(value = "iswork", required = false)String iswork,
															@ApiParam(name = "patientid", value = "居民ID")
	                                                         @RequestParam(value = "patientid", required = false)String patientid,
															@ApiParam(name = "orgCode", value = "机构code")
	                                               @RequestParam(value = "orgCode", required = false)String orgCode,
															@ApiParam(name = "dept", value = "部门code")
	                                               @RequestParam(value = "dept", required = false)String dept,
															@ApiParam(name = "diseaseKey", value = "疾病名称关键字")
	                                               @RequestParam(value = "diseaseKey", required = false)String diseaseKey,
															@ApiParam(name = "doctorNameKey", value = "医生名称关键字")
	                                               @RequestParam(value = "doctorNameKey", required = false)String doctorNameKey,
															@ApiParam(name = "jobTitleNameKey", value = "医生职称关键字")
                                                   @RequestParam(value = "jobTitleNameKey", required = false)String jobTitleNameKey,
															@ApiParam(name = "outpatientType", value = "咨询类型1图文,2视频")
                                                   @RequestParam(value = "outpatientType", required = false)String outpatientType,
															@ApiParam(name = "keyName", value = "姓名/科室/疾病模糊搜索关键字")
                                                   @RequestParam(value = "keyName", required = false)String keyName,
															@ApiParam(name = "workingTime", value = "排班时间YYYY-MM-DD")
	                                               @RequestParam(value = "workingTime", required = false)String workingTime,
															@ApiParam(name = "consultStatus", value = "在线状态")
	                                               @RequestParam(value = "consultStatus", required = false,defaultValue = "")String consultStatus,
															@ApiParam(name = "chargType", value = "医生号别")
	                                                @RequestParam(value = "chargType", required = false,defaultValue = "")String chargType,
															@ApiParam(name = "consutlSort", value = "咨询量排序")
                                                   @RequestParam(value = "consutlSort", required = true,defaultValue = "DESC")String consutlSort,
															@ApiParam(name = "isAttention", value = "是否关注")
													@RequestParam(value = "isAttention", required = false)String isAttention,
															@ApiParam(name = "page", value = "第几页")
	                                                     @RequestParam(value = "page",required = false) Integer page,
															@ApiParam(name = "pagesize", value = "分页大小")
	                                                     @RequestParam(value = "pagesize",required = false) Integer pagesize
	) throws Exception{
		try {
			logger.info("findDoctorByHospitalAndDiseaseAndDept start:"+DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss:SSS"));
			return prescriptionService.findDoctorByHospitalAndDiseaseAndDept2(iswork,patientid,
					orgCode,dept,
					diseaseKey,doctorNameKey,
					jobTitleNameKey,outpatientType,
					keyName,workingTime,consultStatus,chargType,consutlSort,isAttention,page,pagesize);
		}catch (Exception e){
			return failedMixEnvelopException(e);
		}
	}
	
	@GetMapping(value = BaseHospitalRequestMapping.Prescription.findHotDeptAndDiseaseDict)
	@ApiOperation(value = "获取常见疾病、热门部门、医生拒绝接诊原因 字典", notes = "获取常见疾病、热门部门、医生拒绝接诊原因 字典")
	public ListEnvelop findHotDeptAndDiseaseDict(@ApiParam(name = "dictName", value = "dictName")
	                                             @RequestParam(value = "dictName", required = true,defaultValue = "ONLINE_HOSPITAL_DEPT_350211A1002")String dictName)throws Exception{
		try {
			return success(prescriptionService.findHotDeptAndDiseaseDict(dictName));
		}catch (Exception e){
			return failedListEnvelopException(e);
		}
	}
	@PostMapping(value = BaseHospitalRequestMapping.PatientIM.add)
	@ApiOperation(value = "居民添加咨询接口", notes = "居民添加咨询接口")
	public Envelop add(
			@ApiParam(name = "patient", value = "居民CODE")
			@RequestParam(value = "patient",required = false) String patient,
			@ApiParam(name = "doctor", value = "医生CODE")
			@RequestParam(value = "doctor",required = true) String doctor,
			@ApiParam(name = "when", value = "发病时间")
			@RequestParam(value = "when",required = false) String when,
			@ApiParam(name = "symptoms", value = "主述")
			@RequestParam(value = "symptoms",required = false) String symptoms,
			@ApiParam(name = "images", value = "图片")
			@RequestParam(value = "images",required = false) String images,
			@ApiParam(name = "voice", value = "语音")
			@RequestParam(value = "voice",required = false) String voice,
			@ApiParam(name = "relationCode", value = "关联业务表的code(服务项执行计划id)")
			@RequestParam(value = "relationCode",required = false) String relationCode,
			@ApiParam(name = "type", value = "咨询类型:1专家咨询 14导诊助手 17专家视频咨询 28康复咨询")
			@RequestParam(value = "type",required = false) Integer type,
			@ApiParam(name = "source", value = "咨询类型来源")
			@RequestParam(value = "source",required = false) String source)throws Exception{
		System.out.println("symptoms="+symptoms);
		if (type == null) {
			type = 1;
		}
		ConsultTeamDo consult = new ConsultTeamDo();
		// 设置咨询类型:1专家咨询  14导诊助手
		consult.setType(type);
		// 设置发病时间
		consult.setWhen(when);
		// 设置主要症状
		consult.setSymptoms(symptoms);
		// 设置咨询图片URL
		consult.setImages(images);
		// 设置咨询语音URL
		consult.setVoice(voice);
		consult.setDoctor(doctor);
		consult.setPatient(patient);
		// 保存到数据库
                        } else {
                            imgeUrl = fileUtil.copyTempVoice(imagepath, fastdfs_file_url);
                        }
                        content = imgeUrl;
                    }
                } else {
                }
            }
            failed = imService.append(consult, content, type, times, patientCode, wechat_appid);
            return success(failed);
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findDoctorByHospitalAndDiseaseAndDept)
    @ApiOperation(value = "根据疾病名称,热门部门查询医生", notes = "根据疾病名称,热门部门查询医生")
    public MixEnvelop findDoctorByHospitalAndDiseaseAndDept(
            @ApiParam(name = "iswork", value = "机构code") @RequestParam(value = "iswork", required = false) String iswork,
            @ApiParam(name = "patientid", value = "居民ID") @RequestParam(value = "patientid", required = false) String patientid,
            @ApiParam(name = "orgCode", value = "机构code") @RequestParam(value = "orgCode", required = false) String orgCode,
            @ApiParam(name = "dept", value = "部门code") @RequestParam(value = "dept", required = false) String dept,
            @ApiParam(name = "diseaseKey", value = "疾病名称关键字") @RequestParam(value = "diseaseKey", required = false) String diseaseKey,
            @ApiParam(name = "doctorNameKey", value = "医生名称关键字") @RequestParam(value = "doctorNameKey", required = false) String doctorNameKey,
            @ApiParam(name = "jobTitleNameKey", value = "医生职称关键字") @RequestParam(value = "jobTitleNameKey", required = false) String jobTitleNameKey,
            @ApiParam(name = "outpatientType", value = "咨询类型1图文,2视频") @RequestParam(value = "outpatientType", required = false) String outpatientType,
            @ApiParam(name = "keyName", value = "姓名/科室/疾病模糊搜索关键字") @RequestParam(value = "keyName", required = false) String keyName,
            @ApiParam(name = "workingTime", value = "排班时间YYYY-MM-DD") @RequestParam(value = "workingTime", required = false) String workingTime,
            @ApiParam(name = "consultStatus", value = "在线状态") @RequestParam(value = "consultStatus", required = false, defaultValue = "") String consultStatus,
            @ApiParam(name = "chargType", value = "医生号别") @RequestParam(value = "chargType", required = false, defaultValue = "") String chargType,
            @ApiParam(name = "consutlSort", value = "咨询量排序") @RequestParam(value = "consutlSort", required = true, defaultValue = "DESC") String consutlSort,
            @ApiParam(name = "isAttention", value = "是否关注") @RequestParam(value = "isAttention", required = false) String isAttention,
            @ApiParam(name = "page", value = "第几页") @RequestParam(value = "page", required = false) Integer page,
            @ApiParam(name = "pagesize", value = "分页大小") @RequestParam(value = "pagesize", required = false) Integer pagesize
    ) throws Exception {
        try {
            logger.info("findDoctorByHospitalAndDiseaseAndDept start:" + DateUtil.dateToStr(new Date(), "yyyy-MM-dd HH:mm:ss:SSS"));
            return prescriptionService.findDoctorByHospitalAndDiseaseAndDept2(iswork, patientid,
                    orgCode, dept,
                    diseaseKey, doctorNameKey,
                    jobTitleNameKey, outpatientType,
                    keyName, workingTime, consultStatus, chargType, consutlSort, isAttention, page, pagesize);
        } catch (Exception e) {
            return failedMixEnvelopException(e);
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findHotDeptAndDiseaseDict)
    @ApiOperation(value = "获取常见疾病、热门部门、医生拒绝接诊原因 字典", notes = "获取常见疾病、热门部门、医生拒绝接诊原因 字典")
    public ListEnvelop findHotDeptAndDiseaseDict(@ApiParam(name = "dictName", value = "dictName")
                                                 @RequestParam(value = "dictName", required = true, defaultValue = "ONLINE_HOSPITAL_DEPT_350211A1002") String dictName) throws Exception {
        try {
            return success(prescriptionService.findHotDeptAndDiseaseDict(dictName));
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    @PostMapping(value = BaseHospitalRequestMapping.PatientIM.add)
    @ApiOperation(value = "居民添加咨询接口", notes = "居民添加咨询接口")
    public Envelop add(
            @ApiParam(name = "patient", value = "居民CODE")
            @RequestParam(value = "patient", required = false) String patient,
            @ApiParam(name = "doctor", value = "医生CODE")
            @RequestParam(value = "doctor", required = true) String doctor,
            @ApiParam(name = "when", value = "发病时间")
            @RequestParam(value = "when", required = false) String when,
            @ApiParam(name = "symptoms", value = "主述")
            @RequestParam(value = "symptoms", required = false) String symptoms,
            @ApiParam(name = "images", value = "图片")
            @RequestParam(value = "images", required = false) String images,
            @ApiParam(name = "voice", value = "语音")
            @RequestParam(value = "voice", required = false) String voice,
            @ApiParam(name = "relationCode", value = "关联业务表的code(服务项执行计划id)")
            @RequestParam(value = "relationCode", required = false) String relationCode,
            @ApiParam(name = "type", value = "咨询类型:1专家咨询 14导诊助手 17专家视频咨询 28康复咨询")
            @RequestParam(value = "type", required = false) Integer type,
            @ApiParam(name = "source", value = "咨询类型来源")
            @RequestParam(value = "source", required = false) String source) throws Exception {
        System.out.println("symptoms=" + symptoms);
        if (type == null) {
            type = 1;
        }
        ConsultTeamDo consult = new ConsultTeamDo();
        // 设置咨询类型:1专家咨询  14导诊助手
        consult.setType(type);
        // 设置发病时间
        consult.setWhen(when);
        // 设置主要症状
        consult.setSymptoms(symptoms);
        // 设置咨询图片URL
        consult.setImages(images);
        // 设置咨询语音URL
        consult.setVoice(voice);
        consult.setDoctor(doctor);
        consult.setPatient(patient);
        // 保存到数据库
//		int res = 0;
//		JSONArray dts = null;
		synchronized (patient.intern()){//新增同步方法。设备保存写在service层但是不生效,写在controller层才生效
			JSONObject re = null;
			re = imService.addTeamConsult(consult, patient,doctor,source,relationCode);
        synchronized (patient.intern()) {//新增同步方法。设备保存写在service层但是不生效,写在controller层才生效
            JSONObject re = null;
            re = imService.addTeamConsult(consult, patient, doctor, source, relationCode);
//			res = re.getInteger("status");
//			dts = re.containsKey("doctor")?re.getJSONArray("doctor"):null;
			if (payFlag){
				//线上问诊支付提醒
				if (type==17||type==1){
					SystemMessageDO systemMessageDO = new SystemMessageDO();
					systemMessageDO.setTitle("支付提醒");
					systemMessageDO.setType("11");
					systemMessageDO.setSender(re.getString("doctor"));
					systemMessageDO.setSenderName(re.getString("doctorName"));
					systemMessageDO.setRelationCode(re.getString("consult"));
					systemMessageDO.setReceiver(re.getString("patient"));
					systemMessageDO.setReceiverName(re.getString("patientName"));
					net.sf.json.JSONObject data = new net.sf.json.JSONObject();
					data.put("name",re.getString("patientName"));
					data.put("age", IdCardUtil.getAgeForIdcard(re.getString("patient_idcard")));
					data.put("gender",IdCardUtil.getSexForIdcard_new(re.getString("patient_idcard")));
					data.put("question",symptoms);
					data.put("type",type);
					String msg= "";
					/*prescriptionService.sendWxTemplateMsg(wxId,"",consult,type+"","payRemind","");*/
					prescriptionService.saveInquirySystemMessage(null,consult);
					data.put("msg",msg);
					systemMessageDO.setData(data.toString());
					systemMessageService.saveMessage(systemMessageDO);
					BasePatientDO patientDO = basePatientDao.findById(patient).orElse(null);
					if ("xm_ykyy_wx".equalsIgnoreCase(wxId)){
						String templateMsgResult = ykyyService.pushNotificationToYktPatient(patientDO.getYktId(), systemMessageDO.getTitle(), data.get("msg").toString());
					}
				}
			}
			//发送系统消息
			SystemMessageDO systemMessageDO = new SystemMessageDO();
			systemMessageDO.setTitle("新增"+re.getString("title"));
			systemMessageDO.setType("4");
			systemMessageDO.setReceiver(re.getString("doctor"));
			systemMessageDO.setReceiverName(re.getString("doctorName"));
			systemMessageDO.setRelationCode(re.getString("sessiond_id"));
			systemMessageDO.setSender(re.getString("patient"));
			systemMessageDO.setSenderName(re.getString("patientName"));
			net.sf.json.JSONObject data = new net.sf.json.JSONObject();
			data.put("name",re.getString("patientName"));
			data.put("age", IdCardUtil.getAgeForIdcard(re.getString("patient_idcard")));
			data.put("gender",IdCardUtil.getSexForIdcard_new(re.getString("patient_idcard")));
			data.put("question",symptoms);
			data.put("type",1);
			systemMessageDO.setData(data.toString());
			hospitalSystemMessageService.saveMessage(systemMessageDO);
			BaseDoctorDO d = baseDoctorDao.findByIdAndDel(re.getString("doctor"));
			BasePatientDO p = basePatientDao.findById(re.getString("patient")).orElse(null);
			
			try {
				//眼科支付订单
				if (wxId.equalsIgnoreCase("xm_ykyy_wx")){
					BusinessOrderDO businessOrderDO = new BusinessOrderDO();
					businessOrderDO.setDoctor(doctor);
					businessOrderDO.setRematk(symptoms);
					businessOrderDO.setPatient(patient);
					businessOrderDO.setPatientName(re.getString("patientName"));
					businessOrderDO.setDescription("专家咨询费");
					businessOrderDO.setOrderCategory("1");
					if (type==1){
						businessOrderDO.setOrderType(1);
						businessOrderDO.setRelationCode(re.getString("consult"));
						businessOrderDO.setRelationName("新增专家咨询");
					}else if (type==17){
						businessOrderDO.setOrderType(3);
						businessOrderDO.setRelationCode(re.getString("consult"));
						businessOrderDO.setRelationName("新增专家咨询");
					}
					businessOrderService.saveOrder(businessOrderDO);
				}else if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
					Double price = 0.0;
					if(d!=null&& org.apache.commons.lang3.StringUtils.isNoneBlank(d.getFee())){
						price = Double.parseDouble(d.getFee());
					}
					ConsultDo consultDo = consultDao.findById(re.getString("consult")).orElse(null);
					if (price==0.0){
						consultDo.setPayStatus(1);
						consultDao.save(consultDo);
					}
					businessOrderService.recharge(re.getString("consult"),"新增专家咨询","1","专家咨询费",patient,re.getString("patientName"),doctor,price);
				}else if (wxId.equalsIgnoreCase("xm_xzzx_wx")){
					Double price = 0.0;
					if(d!=null&& org.apache.commons.lang3.StringUtils.isNoneBlank(d.getFee())){
						price = Double.parseDouble(d.getFee());
					}
					ConsultDo consultDo = consultDao.findById(re.getString("consult")).orElse(null);
					if (price==0.0){
						consultDo.setPayStatus(1);
						consultDao.save(consultDo);
					}
					businessOrderService.recharge(re.getString("consult"),"新增专家咨询","1","专家咨询费",patient,re.getString("patientName"),doctor,price);
				}
			}catch (Exception e){
			    logger.info("支付订单失败:"+e.getMessage());
			}
			//发送企业号推送
			try{
				
				
				if("zsyy".equals(qywxId)){
					String url = qywxUrl+"/ims-app-web/#/onlineChat/chatroom?rstitle="+p.getName()+"%20专家咨询&type="+type+"&sessionId="+re.getString("sessiond_id");
					logger.info("发送企业号url:"+url);
					enterpriseService.sendMKMesByMobile(qywxId,d.getMobile(),"您的专家咨询有新的消息,请您尽快回复[查看详情]("+url+")");
				}else if("xm_xzzx_wx".equals(qywxId)){
					String roomUrl = "pages/doctor/index?opath=/onlineChat/chatroom&rstitle="+p.getName()+"%20专家咨询&type="+type+"&sessionId="+re.getString("sessiond_id");
					logger.info("发送企业号url:"+roomUrl);
					enterpriseService.sendXCXMesByDoctor(qywxId,
							re.getString("doctor"),
							"wx53f6bb4ac081d840",
							roomUrl,
							p.getName()+"%20专家咨询","您有新的咨询消息",false,"");
				}else{}
				
				
			}catch (Exception e){
				logger.info("发送企业号失败"+e.toString());
			}
			if(!"zsyy".equals(qywxId) && !"xm_xzzx_wx".equals(qywxId)){
				//发送厦门i健康智能推送
				try{
					String wxurl = wlyyUrl+"/im/common/message/sendDoctorTemplateByDoctorIdcard?sessionId="+p.getId()+"_"+d.getId()+"_1&sessionType=1&from="+p.getId()+"&content="+URLEncoder.encode(symptoms)+"&businessType=1&doctor_idcard="+d.getIdcard()+"&patientName="+URLEncoder.encode(p.getName())+"&url=1";
					logger.info("发送厦门i健康智能推送url:"+wxurl);
					wlyyBusinessService.sendDoctorTemplateByDoctorIdcard(wxurl);
				}catch (Exception e){
					logger.info("发送厦门i健康智能失败"+e.toString());
				}
			}
		}
		return success("操作成功", consult);
	}
	@GetMapping(value = BaseHospitalRequestMapping.PatientIM.patientInfo)
	@ApiOperation(value = "根据居民ID获取居民详情信息", notes = "根据居民ID获取居民详情信息")
	public Envelop patientInfo(
			@ApiParam(name = "patient", value = "居民CODE")
			@RequestParam(value = "patient",required = false) String patient) throws Exception {
		try {
			BasePatientDO result = basePatientService.findByIdAndDel(patient);
			//---居民性别取身份证字段--
			result.setSex(Integer.parseInt(IdCardUtil.getSexForIdcard_new(result.getIdcard())));
			if (wxId.equalsIgnoreCase("xm_ykyy_wx")){
				familyMemberService.saveYktFamily(patient);
			}
			return success(result);
		}catch (Exception e){
			return failedException(e);
		}
	}
	
	@PostMapping(value = BaseHospitalRequestMapping.PatientIM.finish)
	@ApiOperation(value = "居民结束咨询", notes = "居民结束咨询")
	public Envelop finish(
			@ApiParam(name = "consult", value = "咨询CODE")
			@RequestParam(value = "consult",required = false) String consult,
			@ApiParam(name = "patientCode", value = "居民COEE")
			@RequestParam(value = "patientCode",required = false) String patientCode
			) throws Exception {
		int resutl = imService.finish(consult,patientCode,1);
		//医生未回复可以退费
		try {
			businessOrderService.consultRefund(consult,wxId);
		}catch (Exception e){
			e.printStackTrace();
		}
		BasePatientDO basePatientDO = basePatientService.findByIdAndDel(patientCode);
		JSONObject msgObj = new JSONObject();
		msgObj.put("msg",basePatientDO.getName()+"结束了咨询");
		msgObj.put("consultcode",consult);
		String jsonStr = "";
		if ("xm_zsyy_wx".equalsIgnoreCase(wxId)){
		//结束时医生未开处方则发送模板消息结算
		ConsultDo cons = consultDao.findById(consult).orElse(null);
		if (org.apache.commons.lang3.StringUtils.isNoneBlank(cons.getRelationCode())){
			WlyyOutpatientDO outpatientDO = outpatientDao.findById(cons.getRelationCode()).orElse(null);
			List<WlyyPrescriptionDO> wlyyPrescriptionDOS = prescriptionDao.findByOutpatientId(outpatientDO.getId());
			if (wlyyPrescriptionDOS==null||wlyyPrescriptionDOS.size()==0){
				logger.info("发送诊查费支付模板消息start");
				BasePatientDO patientDO = basePatientDao.findById(outpatientDO.getPatient()).orElse(null);
				String userName = null;
				String idcard = null;
				if (patientDO != null) {
					userName = patientDO.getName();
					idcard = patientDO.getIdcard();
				}
				PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(outpatientDO.getConsumer());
				String userNo = null;
				if (patientMappingDO != null) {
					userNo = patientMappingDO.getMappingCode();
				}
				String cardNo = null;
				if (org.apache.commons.lang3.StringUtils.isNoneBlank(outpatientDO.getCardNo())) {
					cardNo = outpatientDO.getCardNo();
				}
				String free = 0+"";
				String date=DateUtil.dateToStr(outpatientDO.getRegisterDate(), "yyyyMMddHHmmss");
				if (org.apache.commons.lang3.StringUtils.isNoneBlank(outpatientDO.getRealOrder())){
					net.sf.json.JSONObject object =entranceService.BS15054(patientMappingDO.getMappingCode(),outpatientDO.getRealOrder(),false);
					if(object!=null){
						net.sf.json.JSONObject res = object.getJSONObject("resquest");
						String rsCode = res.getString("@RESULT");
						if ("0".equals(rsCode)) {
							if (res.getString("@settle_flag").equalsIgnoreCase("N")){
								free = res.getString("@total_charge");
							}
						}
						logger.info("获取待结算数据 res: " + res.toString());
					}
				}
				List<WlyyOutpatientDO> outpatientDOS = outpatientDao.findByRegisterNoList(outpatientDO.getRegisterNo());
				if (outpatientDOS!=null&&outpatientDOS.size()>1){
					outpatientDO.setHisStatus(1);
				}else {
					prescriptionService.sendWxTemplateMsg(wxId, outpatientDO.getId(), null,"", "diagnoPayRemind", "");
				}
            if (payFlag) {
                //线上问诊支付提醒
                if (type == 17 || type == 1) {
                    SystemMessageDO systemMessageDO = new SystemMessageDO();
                    systemMessageDO.setTitle("支付提醒");
                    systemMessageDO.setType("11");
                    systemMessageDO.setSender(re.getString("doctor"));
                    systemMessageDO.setSenderName(re.getString("doctorName"));
                    systemMessageDO.setRelationCode(re.getString("consult"));
                    systemMessageDO.setReceiver(re.getString("patient"));
                    systemMessageDO.setReceiverName(re.getString("patientName"));
                    net.sf.json.JSONObject data = new net.sf.json.JSONObject();
                    data.put("name", re.getString("patientName"));
                    data.put("age", IdCardUtil.getAgeForIdcard(re.getString("patient_idcard")));
                    data.put("gender", IdCardUtil.getSexForIdcard_new(re.getString("patient_idcard")));
                    data.put("question", symptoms);
                    data.put("type", type);
                    String msg = "";
                    /*prescriptionService.sendWxTemplateMsg(wxId,"",consult,type+"","payRemind","");*/
                    prescriptionService.saveInquirySystemMessage(null, consult);
                    data.put("msg", msg);
                    systemMessageDO.setData(data.toString());
                    systemMessageService.saveMessage(systemMessageDO);
                    BasePatientDO patientDO = basePatientDao.findById(patient).orElse(null);
                    if ("xm_ykyy_wx".equalsIgnoreCase(wxId)) {
                        String templateMsgResult = ykyyService.pushNotificationToYktPatient(patientDO.getYktId(), systemMessageDO.getTitle(), data.get("msg").toString());
                    }
                }
            }
            //发送系统消息
            SystemMessageDO systemMessageDO = new SystemMessageDO();
            systemMessageDO.setTitle("新增" + re.getString("title"));
            systemMessageDO.setType("4");
            systemMessageDO.setReceiver(re.getString("doctor"));
            systemMessageDO.setReceiverName(re.getString("doctorName"));
            systemMessageDO.setRelationCode(re.getString("sessiond_id"));
            systemMessageDO.setSender(re.getString("patient"));
            systemMessageDO.setSenderName(re.getString("patientName"));
            net.sf.json.JSONObject data = new net.sf.json.JSONObject();
            data.put("name", re.getString("patientName"));
            data.put("age", IdCardUtil.getAgeForIdcard(re.getString("patient_idcard")));
            data.put("gender", IdCardUtil.getSexForIdcard_new(re.getString("patient_idcard")));
            data.put("question", symptoms);
            data.put("type", 1);
            systemMessageDO.setData(data.toString());
            hospitalSystemMessageService.saveMessage(systemMessageDO);
            BaseDoctorDO d = baseDoctorDao.findByIdAndDel(re.getString("doctor"));
            BasePatientDO p = basePatientDao.findById(re.getString("patient")).orElse(null);
            try {
                //眼科支付订单
                if (wxId.equalsIgnoreCase("xm_ykyy_wx")) {
                    BusinessOrderDO businessOrderDO = new BusinessOrderDO();
                    businessOrderDO.setDoctor(doctor);
                    businessOrderDO.setRematk(symptoms);
                    businessOrderDO.setPatient(patient);
                    businessOrderDO.setPatientName(re.getString("patientName"));
                    businessOrderDO.setDescription("专家咨询费");
                    businessOrderDO.setOrderCategory("1");
                    if (type == 1) {
                        businessOrderDO.setOrderType(1);
                        businessOrderDO.setRelationCode(re.getString("consult"));
                        businessOrderDO.setRelationName("新增专家咨询");
                    } else if (type == 17) {
                        businessOrderDO.setOrderType(3);
                        businessOrderDO.setRelationCode(re.getString("consult"));
                        businessOrderDO.setRelationName("新增专家咨询");
                    }
                    businessOrderService.saveOrder(businessOrderDO);
                } else if (wxId.equalsIgnoreCase("xm_zsyy_wx")) {
                    Double price = 0.0;
                    if (d != null && org.apache.commons.lang3.StringUtils.isNoneBlank(d.getFee())) {
                        price = Double.parseDouble(d.getFee());
                    }
                    ConsultDo consultDo = consultDao.findById(re.getString("consult")).orElse(null);
                    if (price == 0.0) {
                        consultDo.setPayStatus(1);
                        consultDao.save(consultDo);
                    }
                    businessOrderService.recharge(re.getString("consult"), "新增专家咨询", "1", "专家咨询费", patient, re.getString("patientName"), doctor, price);
                } else if (wxId.equalsIgnoreCase("xm_xzzx_wx")) {
                    Double price = 0.0;
                    if (d != null && org.apache.commons.lang3.StringUtils.isNoneBlank(d.getFee())) {
                        price = Double.parseDouble(d.getFee());
                    }
                    ConsultDo consultDo = consultDao.findById(re.getString("consult")).orElse(null);
                    if (price == 0.0) {
                        consultDo.setPayStatus(1);
                        consultDao.save(consultDo);
                    }
                    businessOrderService.recharge(re.getString("consult"), "新增专家咨询", "1", "专家咨询费", patient, re.getString("patientName"), doctor, price);
                }
            } catch (Exception e) {
                logger.info("支付订单失败:" + e.getMessage());
            }
            //发送企业号推送
            try {
                if ("zsyy".equals(qywxId)) {
                    String url = qywxUrl + "/ims-app-web/#/onlineChat/chatroom?rstitle=" + p.getName() + "%20专家咨询&type=" + type + "&sessionId=" + re.getString("sessiond_id");
                    logger.info("发送企业号url:" + url);
                    enterpriseService.sendMKMesByMobile(qywxId, d.getMobile(), "您的专家咨询有新的消息,请您尽快回复[查看详情](" + url + ")");
                } else if ("xm_xzzx_wx".equals(qywxId)) {
                    String roomUrl = "pages/doctor/index?opath=/onlineChat/chatroom&rstitle=" + p.getName() + "%20专家咨询&type=" + type + "&sessionId=" + re.getString("sessiond_id");
                    logger.info("发送企业号url:" + roomUrl);
                    enterpriseService.sendXCXMesByDoctor(qywxId,
                            re.getString("doctor"),
                            "wx53f6bb4ac081d840",
                            roomUrl,
                            p.getName() + "%20专家咨询", "您有新的咨询消息", false, "");
                } else {
                }
            } catch (Exception e) {
                logger.info("发送企业号失败" + e.toString());
            }
            if (!"zsyy".equals(qywxId) && !"xm_xzzx_wx".equals(qywxId)) {
                //发送厦门i健康智能推送
                try {
                    String wxurl = wlyyUrl + "/im/common/message/sendDoctorTemplateByDoctorIdcard?sessionId=" + p.getId() + "_" + d.getId() + "_1&sessionType=1&from=" + p.getId() + "&content=" + URLEncoder.encode(symptoms) + "&businessType=1&doctor_idcard=" + d.getIdcard() + "&patientName=" + URLEncoder.encode(p.getName()) + "&url=1";
                    logger.info("发送厦门i健康智能推送url:" + wxurl);
                    wlyyBusinessService.sendDoctorTemplateByDoctorIdcard(wxurl);
                } catch (Exception e) {
                    logger.info("发送厦门i健康智能失败" + e.toString());
                }
            }
        }
        return success("操作成功", consult);
    }
    @GetMapping(value = BaseHospitalRequestMapping.PatientIM.patientInfo)
    @ApiOperation(value = "根据居民ID获取居民详情信息", notes = "根据居民ID获取居民详情信息")
    public Envelop patientInfo(
            @ApiParam(name = "patient", value = "居民CODE")
            @RequestParam(value = "patient", required = false) String patient) throws Exception {
        try {
            BasePatientDO result = basePatientService.findByIdAndDel(patient);
            //---居民性别取身份证字段--
            result.setSex(Integer.parseInt(IdCardUtil.getSexForIdcard_new(result.getIdcard())));
            if (wxId.equalsIgnoreCase("xm_ykyy_wx")) {
                familyMemberService.saveYktFamily(patient);
            }
            return success(result);
        } catch (Exception e) {
            return failedException(e);
        }
    }
    @PostMapping(value = BaseHospitalRequestMapping.PatientIM.finish)
    @ApiOperation(value = "居民结束咨询", notes = "居民结束咨询")
    public Envelop finish(
            @ApiParam(name = "consult", value = "咨询CODE")
            @RequestParam(value = "consult", required = false) String consult,
            @ApiParam(name = "patientCode", value = "居民COEE")
            @RequestParam(value = "patientCode", required = false) String patientCode
    ) throws Exception {
        int resutl = imService.finish(consult, patientCode, 1);
        //医生未回复可以退费
        try {
            businessOrderService.consultRefund(consult, wxId);
        } catch (Exception e) {
            e.printStackTrace();
        }
        BasePatientDO basePatientDO = basePatientService.findByIdAndDel(patientCode);
        JSONObject msgObj = new JSONObject();
        msgObj.put("msg", basePatientDO.getName() + "结束了咨询");
        msgObj.put("consultcode", consult);
        String jsonStr = "";
        if ("xm_zsyy_wx".equalsIgnoreCase(wxId)) {
            //结束时医生未开处方则发送模板消息结算
            ConsultDo cons = consultDao.findById(consult).orElse(null);
            if (org.apache.commons.lang3.StringUtils.isNoneBlank(cons.getRelationCode())) {
                WlyyOutpatientDO outpatientDO = outpatientDao.findById(cons.getRelationCode()).orElse(null);
                List<WlyyPrescriptionDO> wlyyPrescriptionDOS = prescriptionDao.findByOutpatientId(outpatientDO.getId());
                if (wlyyPrescriptionDOS == null || wlyyPrescriptionDOS.size() == 0) {
                    logger.info("发送诊查费支付模板消息start");
                    BasePatientDO patientDO = basePatientDao.findById(outpatientDO.getPatient()).orElse(null);
                    String userName = null;
                    String idcard = null;
                    if (patientDO != null) {
                        userName = patientDO.getName();
                        idcard = patientDO.getIdcard();
                    }
                    PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(outpatientDO.getConsumer());
                    String userNo = null;
                    if (patientMappingDO != null) {
                        userNo = patientMappingDO.getMappingCode();
                    }
                    String cardNo = null;
                    if (org.apache.commons.lang3.StringUtils.isNoneBlank(outpatientDO.getCardNo())) {
                        cardNo = outpatientDO.getCardNo();
                    }
                    String free = 0 + "";
                    String date = DateUtil.dateToStr(outpatientDO.getRegisterDate(), "yyyyMMddHHmmss");
                    if (org.apache.commons.lang3.StringUtils.isNoneBlank(outpatientDO.getRealOrder())) {
                        net.sf.json.JSONObject object = entranceService.BS15054(patientMappingDO.getMappingCode(), outpatientDO.getRealOrder(), false);
                        if (object != null) {
                            net.sf.json.JSONObject res = object.getJSONObject("resquest");
                            String rsCode = res.getString("@RESULT");
                            if ("0".equals(rsCode)) {
                                if (res.getString("@settle_flag").equalsIgnoreCase("N")) {
                                    free = res.getString("@total_charge");
                                }
                            }
                            logger.info("获取待结算数据 res: " + res.toString());
                        }
                    }
                    List<WlyyOutpatientDO> outpatientDOS = outpatientDao.findByRegisterNoList(outpatientDO.getRegisterNo());
                    if (outpatientDOS != null && outpatientDOS.size() > 1) {
                        outpatientDO.setHisStatus(1);
                    } else {
                        prescriptionService.sendWxTemplateMsg(wxId, outpatientDO.getId(), null, "", "diagnoPayRemind", "");
                    }
				/*if (!free.equalsIgnoreCase("0")){
					ylzPayService.msgPush("01", cardNo, "01", patientDO.getMobile(), "00", userNo, userName, idcard, outpatientDO.getXtgzh(), outpatientDO.getDeptName(), outpatientDO.getDoctorName(), date, free, "1","WX_PUB");
				}*/
				logger.info("发送诊查费支付模板消息end");
			}
			outpatientDO.setEndTime(new Date());
			outpatientDao.save(outpatientDO);
		}
		}
		if(1 == resutl){
			jsonStr = "{\"id\":\""+UUID.randomUUID().toString()+"\",\"sender_id\":\""+patientCode+"\",\"sender_name\":\"系统\",\"timestamp\":"+new Date().getTime()+",\"content_type\":7,\"content\":"+msgObj.toString()+",\"business_type\":1}";
		}
                    logger.info("发送诊查费支付模板消息end");
                }
                outpatientDO.setEndTime(new Date());
                outpatientDao.save(outpatientDO);
            }
        }
        if (1 == resutl) {
            jsonStr = "{\"id\":\"" + UUID.randomUUID().toString() + "\",\"sender_id\":\"" + patientCode + "\",\"sender_name\":\"系统\",\"timestamp\":" + new Date().getTime() + ",\"content_type\":7,\"content\":" + msgObj.toString() + ",\"business_type\":1}";
        }
//		else{
//			throw  new Exception("结束失败");
//		}
		return success(jsonStr);
	}
	
	@GetMapping(value = BaseHospitalRequestMapping.PatientIM.getTopic)
	@ApiOperation(value = "根据咨询CODE获取session_id", notes = "根据咨询CODE获取session_id")
	public Envelop getTopic(
			@ApiParam(name = "consult", value = "咨询CODE")
			@RequestParam(value = "consult",required = false) String consult)throws Exception {
		try {
			return success("请求成功",imService.getTopic(consult));
		}catch (Exception e){
			return failedException(e);
		}
	}
	
	@GetMapping(value = BaseHospitalRequestMapping.PatientIM.getConsultCodeByOutpatientId)
	@ApiOperation(value = "根据复诊记录ID获取咨询CODE", notes = "根据复诊记录ID获取咨询CODE")
	public Envelop getConsultCodeByOutpatientId(
			@ApiParam(name = "outpatientid", value = "复诊ID")
			@RequestParam(value = "outpatientid",required = true) String outpatientid)throws Exception {
		try {
			return success("请求成功",imService.getConsultCodeByOutpatientId(outpatientid));
		}catch (Exception e){
			return failedException(e);
		}
	}
	
	@PostMapping(value = BaseHospitalRequestMapping.PatientIM.evaluationByConsultCode)
	@ApiOperation(value = "评价咨询", notes = "评价咨询")
	public Envelop evaluationByConsultCode(
			@ApiParam(name = "consult", value = "咨询CODE")
			@RequestParam(value = "consult",required = true) String consult,
			@ApiParam(name = "scoreContent", value = "评价内容")
			@RequestParam(value = "scoreContent",required = false) String scoreContent,
			@ApiParam(name = "type", value = "1、实名,2、匿名")
			@RequestParam(value = "type",required = true) Integer type,
			@ApiParam(name = "bannerList",value = "锦旗")
			@RequestParam(value = "bannerList",required = false) String bannerList)throws Exception{
        return success(jsonStr);
    }
    @GetMapping(value = BaseHospitalRequestMapping.PatientIM.getTopic)
    @ApiOperation(value = "根据咨询CODE获取session_id", notes = "根据咨询CODE获取session_id")
    public Envelop getTopic(
            @ApiParam(name = "consult", value = "咨询CODE")
            @RequestParam(value = "consult", required = false) String consult) throws Exception {
        try {
            return success("请求成功", imService.getTopic(consult));
        } catch (Exception e) {
            return failedException(e);
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.PatientIM.getConsultCodeByOutpatientId)
    @ApiOperation(value = "根据复诊记录ID获取咨询CODE", notes = "根据复诊记录ID获取咨询CODE")
    public Envelop getConsultCodeByOutpatientId(
            @ApiParam(name = "outpatientid", value = "复诊ID")
            @RequestParam(value = "outpatientid", required = true) String outpatientid) throws Exception {
        try {
            return success("请求成功", imService.getConsultCodeByOutpatientId(outpatientid));
        } catch (Exception e) {
            return failedException(e);
        }
    }
    @PostMapping(value = BaseHospitalRequestMapping.PatientIM.evaluationByConsultCode)
    @ApiOperation(value = "评价咨询", notes = "评价咨询")
    public Envelop evaluationByConsultCode(
            @ApiParam(name = "consult", value = "咨询CODE")
            @RequestParam(value = "consult", required = true) String consult,
            @ApiParam(name = "scoreContent", value = "评价内容")
            @RequestParam(value = "scoreContent", required = false) String scoreContent,
            @ApiParam(name = "type", value = "1、实名,2、匿名")
            @RequestParam(value = "type", required = true) Integer type,
            @ApiParam(name = "bannerList", value = "锦旗")
            @RequestParam(value = "bannerList", required = false) String bannerList) throws Exception {
//		if(StringUtils.isEmpty(scoreContent)){
//			scoreContent= "[{\"scoreType\":\"1\",\"score\":100,\"content\":\"\"},{\"scoreType\":\"2\",\"score\":80,\"content\":\"\"},{\"scoreType\":\"3\",\"score\":80,\"content\":\"\"},{\"scoreType\":\"4\",\"score\":0,\"content\":\"测试评语。。。。123123\"}]";
//		}
		try {
			imService.evaluationByConsultCode(consult,scoreContent,type,bannerList);
			return success("请求成功");
		}catch (Exception e){
			return failedException(e);
		}
	}
	
	@GetMapping(value = BaseHospitalRequestMapping.PatientIM.getEvaluationByConsultCode)
	@ApiOperation(value = "根据咨询CODE获取评价", notes = "根据咨询CODE获取评价")
	public ListEnvelop getEvaluationByConsultCode(
			@ApiParam(name = "consult", value = "咨询CODE")
			@RequestParam(value = "consult",required = true) String consult)throws Exception{
        try {
            imService.evaluationByConsultCode(consult, scoreContent, type, bannerList);
            return success("请求成功");
        } catch (Exception e) {
            return failedException(e);
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.PatientIM.getEvaluationByConsultCode)
    @ApiOperation(value = "根据咨询CODE获取评价", notes = "根据咨询CODE获取评价")
    public ListEnvelop getEvaluationByConsultCode(
            @ApiParam(name = "consult", value = "咨询CODE")
            @RequestParam(value = "consult", required = true) String consult) throws Exception {
//		if(StringUtils.isEmpty(scoreContent)){
//			scoreContent= "[{\"scoreType\":\"1\",\"score\":100,\"content\":\"\"},{\"scoreType\":\"2\",\"score\":80,\"content\":\"\"},{\"scoreType\":\"3\",\"score\":80,\"content\":\"\"},{\"scoreType\":\"4\",\"score\":0,\"content\":\"测试评语。。。。123123\"}]";
//		}
		try {
			return success("请求成功",imService.getEvaluationByConsultCode(consult));
		}catch (Exception e){
			return failedListEnvelopException(e);
		}
	}
	
	@PostMapping(value = BaseHospitalRequestMapping.PatientIM.getSign)
	@ApiOperation(value = "获取微信签名", notes = "获取微信签名")
	public Envelop getSign(@ApiParam(name = "pageUrl", value = "授权页面")
	                       @RequestParam(value = "pageUrl", required = true)String pageUrl,
	                       @ApiParam(name = "wxId", value = "微信id")
	                       @RequestParam(value = "wxId", required = true)String wxId) throws Exception {
		try {
			logger.info("pageUrl="+pageUrl);
			logger.info("wxId="+wxId);
			String ticket = wechatInfoService.getJsapi_ticketByToken(wxId);
			WxWechatDO wxWechatDO = wechatDao.findByIdAndStatus(wxId);
			Map<Object, Object> map = new HashMap<Object, Object>();
			if (ticket != null) {
				String noncestr = UUID.randomUUID().toString();
				long timestamp = System.currentTimeMillis() / 1000;
				String url = pageUrl;
				logger.info("getSign.url="+url);
				String str = "jsapi_ticket=" + ticket + "&noncestr=" + noncestr + "&timestamp=" + timestamp + "&url=" + url;
				logger.info("getSign.str="+str);
				// sha1加密
				String signature = SHA1(str);
				map.put("noncestr", noncestr);
				map.put("timestamp", timestamp);
				map.put("signature", signature);
				map.put("appid", wxWechatDO.getAppId());
				return success(PatientRequestMapping.Wechat.api_success,map);
			}
			return failed(PatientRequestMapping.Wechat.api_error);
		}catch (Exception e){
			return failedException(e);
		}
	}
	
	/**
	 * @description: SHA、SHA1加密 @parameter: str:待加密字符串 @return: 加密串
	 **/
	public String SHA1(String str) throws Exception {
		try {
			MessageDigest digest = java.security.MessageDigest.getInstance("SHA-1"); // 如果是SHA加密只需要将"SHA-1"改成"SHA"即可
			digest.update(str.getBytes());
			byte messageDigest[] = digest.digest();
			// Create Hex String
			StringBuffer hexStr = new StringBuffer();
			// 字节数组转换为 十六进制 数
			for (int i = 0; i < messageDigest.length; i++) {
				String shaHex = Integer.toHexString(messageDigest[i] & 0xFF);
				if (shaHex.length() < 2) {
					hexStr.append(0);
				}
				hexStr.append(shaHex);
			}
			return hexStr.toString();
			
		} catch (Exception e) {
			throw new Exception(e.getMessage());
		}
	}
	
	@PostMapping(value = BaseHospitalRequestMapping.PatientIM.getPatientGuaidenceConsult)
	@ApiOperation(value = "导诊的咨询对话", notes = "导诊的咨询对话")
	public Envelop getPatientGuaidenceConsult(@ApiParam(name = "patientCode", value = "居民CODE")
												  @RequestParam(value = "patientCode", required = true)String patientCode,
											  @ApiParam(name = "type", value = "_guidance_14 导诊收")
											  @RequestParam(value = "type", required = true)String type) throws Exception {
		try {
			String session_id = patientCode+type;
			session_id = imService.getPatientGuaidenceConsult(patientCode,session_id,type);
			return success(session_id);
		}catch (Exception e){
			return failedException(e);
		}
	}
	@PostMapping(value = BaseHospitalRequestMapping.PatientIM.sessionIsExist)
	@ApiOperation(value = "判断导诊sessionId是否存在", notes = "判断导诊sessionId是否存在")
	public Envelop sessionIsExist(@ApiParam(name = "patientCode", value = "居民CODE")
											  @RequestParam(value = "patientCode", required = true)String patientCode,
											  @ApiParam(name = "type", value = "type")
											  @RequestParam(value = "type", required = false)String type) throws Exception {
		try {
			String session_id = null;
			if (org.apache.commons.lang3.StringUtils.isNoneBlank(type)){
				session_id = patientCode+"_guidance_"+type;
			}
			Boolean re = imUtil.sessionIsExist(session_id);
			return success(re);
		}catch (Exception e){
			return failedException(e);
		}
	}
	
	@PostMapping(value = BaseHospitalRequestMapping.PatientIM.updateConsultParticipant)
	@ApiOperation(value = "更新会话成员(新增或删除)", notes = "更新会话成员(新增或删除)")
	public Envelop updateConsultParticipant(@ApiParam(name = "sessionid", value = "会话ID", defaultValue = "1")
	                                       @RequestParam(value = "sessionid", required = true) String sessionid,
	                                       @ApiParam(name = "userid", value = "新增成员ID,多个以英文逗号隔开", defaultValue = "1")
	                                       @RequestParam(value = "userid", required = true) String userid,
	                                       @ApiParam(name = "olduserid", value = "删除的成员id")
	                                       @RequestParam(value = "olduserid", required = false) String olduserid)throws Exception{
		try {
			imService.updateParticipant(sessionid,userid,olduserid);
			return success("操作成功");
		}catch (Exception e){
			return failedException(e);
		}
	}
	
	@PostMapping(value = BaseHospitalRequestMapping.PatientIM.patientGuaidenceAppend)
	@ApiOperation(value = "居民导诊会话发送消息", notes = "居民导诊会话发送消息")
	public Envelop patientGuaidenceAppend(
			@ApiParam(name = "sender_id", value = "发送者id", defaultValue = "")
			@RequestParam(value = "sender_id", required = true) String sender_id,
			@ApiParam(name = "sender_name", value = "发送者姓名", defaultValue = "")
			@RequestParam(value = "sender_name", required = true) String sender_name,
			@ApiParam(name = "session_id", value = "session_id", defaultValue = "")
			@RequestParam(value = "session_id", required = false) String session_id,
			@ApiParam(name = "content_type", value = "内容类型", defaultValue = "")
			@RequestParam(value = "content_type", required = true) String content_type,
			@ApiParam(name = "content", value = "消息内容", defaultValue = "")
			@RequestParam(value = "content", required = true) String content,
			@ApiParam(name = "extend", value = "扩展内容", defaultValue = "")
			@RequestParam(value = "extend", required = false) String extend,
			@ApiParam(name = "type", value = "咨询type", defaultValue = "")
			@RequestParam(value = "type", required = false) String type,
			@ApiParam(name = "times", value = "times", defaultValue = "")
			@RequestParam(value = "times", required = false) Integer times,
			@ApiParam(name = "wechat_appid", value = "wechat_appid", defaultValue = "")
			@RequestParam(value = "wechat_appid", required = false) String wechat_appid
	){
		try {
			//处理语音文件
			if(!org.springframework.util.StringUtils.isEmpty(wechat_appid)){
				if("3".equalsIgnoreCase(content_type)){//语音文件
					String voicepath = imService.fetchWxVoices(wechat_appid);
					logger.info("voice_path:"+voicepath);
					JSONObject obj = new JSONObject();
					String voiceurl = "";
					// 将临时语音拷贝到正式存储路径下
					if (org.apache.commons.lang3.StringUtils.isNotEmpty(voicepath)) {
						if("xm_ihealth_wx".equals(wechat_appid)){
							logger.info("voice_wx_type:"+wechat_appid);
							voiceurl = fileUploadService.uploadWxVoice(voicepath);
						}else if ("xm_xzzx_wx".equalsIgnoreCase(wechat_appid)){
							voiceurl = fileUploadService.uploadWxVoiceToEntrance(remote_inner_url,voicepath);
							logger.info(voiceurl);
						}else {
							voiceurl = fileUtil.copyTempVoice(voicepath,fastdfs_file_url);
						}
						obj.put("path", voiceurl);
						obj.put("times", times);
						content = obj.toString();
					}
				}else if("2".equalsIgnoreCase(content_type)){//图片文件
					String imagepath = imService.fetchWxImages(wechat_appid);
					logger.info("image_path:"+imagepath);
					JSONObject obj = new JSONObject();
					String imgeUrl = "";
					// 将临时语音拷贝到正式存储路径下
					if (org.apache.commons.lang3.StringUtils.isNotEmpty(imagepath)) {
						if("xm_ihealth_wx".equals(wechat_appid)){
							logger.info("imge_wx_type:"+wechat_appid);
							imgeUrl = fileUploadService.uploadWxImage(imagepath);
						}else{
							imgeUrl = fileUtil.copyTempVoice(imagepath,fastdfs_file_url);
						}
						content = imgeUrl;
					}
				}else{
				}
			}
			content = StringUtils.isNotEmpty(content)?content.trim():content;
			Map<String,JSONObject> map = robotService.robotReply(session_id,type,content);
			session_id = imService.getPatientGuaidenceConsult(sender_id,session_id,type);
			String result = imService.patientGuaidenceAppend(sender_id,sender_name,session_id,content_type,content,"1",extend);
			robotService.sendReplyMap(map);
			//消息存在时文本及问题集类型发送时自动回复
			robotService.replyGuaidenceContent(session_id,type,content,content_type,"1",extend);
			List<BaseDoctorRoleDO> doctorRoleDOS = doctorRoleDao.findByRoleCode("guidance");
			for (BaseDoctorRoleDO doctorRoleDO:doctorRoleDOS){
				System.out.println("发送外层SOCKET消息:通知医生导诊");
				JSONObject object = new JSONObject();
				object.put("socket_sms_type",13);
				object.put("relation_code",session_id);
				imService.sendWaiSocketMessage(sender_id,doctorRoleDO.getDoctorCode(),object.toString(),"1");
			}
			return success(result);
		}catch (Exception e){
			return failedException(e);
		}
	}
	
	
	
	@GetMapping(value = BaseHospitalRequestMapping.PatientIM.getDoctorConsultCount)
	@ApiOperation(value = "医生端:查询会话视频邀请状态", notes = "医生端:查询会话视频邀请状态")
	public Envelop getDoctorConsultCount(@ApiParam(name = "doctorids", value = "会话ID")
	                                     @RequestParam(value = "doctorids",required = true) String doctorids)throws Exception  {
		return success("查询成功",imService.getDoctorConsultCount(doctorids));
		
	}
	
	
	@PostMapping(value = BaseHospitalRequestMapping.Prescription.followOrgByPatient)
	@ApiOperation(value = "居民关注医院", notes = "居民关注医院")
	public Envelop followOrgByPatient(
			@ApiParam(name = "patientid", value = "居民ID", defaultValue = "")
			@RequestParam(value = "patientid", required = true) String patientid,
			@ApiParam(name = "orgid", value = "医生ID", defaultValue = "")
			@RequestParam(value = "orgid", required = true) String orgid,
			@ApiParam(name = "type", value = "1关注 0取消关注", defaultValue = "")
			@RequestParam(value = "type", required = true) String type
	)throws Exception{
		prescriptionService.followOrgByPatient(patientid,orgid,type);
		return success("操作成功!");
	}
	@GetMapping(value = BaseHospitalRequestMapping.Prescription.selectByGuidance)
	@ApiOperation(value = "查询是否有导诊助手", notes = "查询是否有导诊助手")
	public MixEnvelop selectByGuidance()throws Exception{
		return MixEnvelop.getSuccessList("查询成功",doctorInfoService.selectByGuidance());
	}
        try {
            return success("请求成功", imService.getEvaluationByConsultCode(consult));
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    @PostMapping(value = BaseHospitalRequestMapping.PatientIM.getSign)
    @ApiOperation(value = "获取微信签名", notes = "获取微信签名")
    public Envelop getSign(@ApiParam(name = "pageUrl", value = "授权页面")
                           @RequestParam(value = "pageUrl", required = true) String pageUrl,
                           @ApiParam(name = "wxId", value = "微信id")
                           @RequestParam(value = "wxId", required = true) String wxId) throws Exception {
        try {
            logger.info("pageUrl=" + pageUrl);
            logger.info("wxId=" + wxId);
            String ticket = wechatInfoService.getJsapi_ticketByToken(wxId);
            WxWechatDO wxWechatDO = wechatDao.findByIdAndStatus(wxId);
            Map<Object, Object> map = new HashMap<Object, Object>();
            if (ticket != null) {
                String noncestr = UUID.randomUUID().toString();
                long timestamp = System.currentTimeMillis() / 1000;
                String url = pageUrl;
                logger.info("getSign.url=" + url);
                String str = "jsapi_ticket=" + ticket + "&noncestr=" + noncestr + "&timestamp=" + timestamp + "&url=" + url;
                logger.info("getSign.str=" + str);
                // sha1加密
                String signature = SHA1(str);
                map.put("noncestr", noncestr);
                map.put("timestamp", timestamp);
                map.put("signature", signature);
                map.put("appid", wxWechatDO.getAppId());
                return success(PatientRequestMapping.Wechat.api_success, map);
            }
            return failed(PatientRequestMapping.Wechat.api_error);
        } catch (Exception e) {
            return failedException(e);
        }
    }
    /**
     * @description: SHA、SHA1加密 @parameter: str:待加密字符串 @return: 加密串
     **/
    public String SHA1(String str) throws Exception {
        try {
            MessageDigest digest = java.security.MessageDigest.getInstance("SHA-1"); // 如果是SHA加密只需要将"SHA-1"改成"SHA"即可
            digest.update(str.getBytes());
            byte messageDigest[] = digest.digest();
            // Create Hex String
            StringBuffer hexStr = new StringBuffer();
            // 字节数组转换为 十六进制 数
            for (int i = 0; i < messageDigest.length; i++) {
                String shaHex = Integer.toHexString(messageDigest[i] & 0xFF);
                if (shaHex.length() < 2) {
                    hexStr.append(0);
                }
                hexStr.append(shaHex);
            }
            return hexStr.toString();
        } catch (Exception e) {
            throw new Exception(e.getMessage());
        }
    }
    @PostMapping(value = BaseHospitalRequestMapping.PatientIM.getPatientGuaidenceConsult)
    @ApiOperation(value = "导诊的咨询对话", notes = "导诊的咨询对话")
    public Envelop getPatientGuaidenceConsult(@ApiParam(name = "patientCode", value = "居民CODE")
                                              @RequestParam(value = "patientCode", required = true) String patientCode,
                                              @ApiParam(name = "type", value = "_guidance_14 导诊收")
                                              @RequestParam(value = "type", required = true) String type) throws Exception {
        try {
            String session_id = patientCode + type;
            session_id = imService.getPatientGuaidenceConsult(patientCode, session_id, type);
            return success(session_id);
        } catch (Exception e) {
            return failedException(e);
        }
    }
    @PostMapping(value = BaseHospitalRequestMapping.PatientIM.sessionIsExist)
    @ApiOperation(value = "判断导诊sessionId是否存在", notes = "判断导诊sessionId是否存在")
    public Envelop sessionIsExist(@ApiParam(name = "patientCode", value = "居民CODE")
                                  @RequestParam(value = "patientCode", required = true) String patientCode,
                                  @ApiParam(name = "type", value = "type")
                                  @RequestParam(value = "type", required = false) String type) throws Exception {
        try {
            String session_id = null;
            if (org.apache.commons.lang3.StringUtils.isNoneBlank(type)) {
                session_id = patientCode + "_guidance_" + type;
            }
            Boolean re = imUtil.sessionIsExist(session_id);
            return success(re);
        } catch (Exception e) {
            return failedException(e);
        }
    }
    @PostMapping(value = BaseHospitalRequestMapping.PatientIM.updateConsultParticipant)
    @ApiOperation(value = "更新会话成员(新增或删除)", notes = "更新会话成员(新增或删除)")
    public Envelop updateConsultParticipant(@ApiParam(name = "sessionid", value = "会话ID", defaultValue = "1")
                                            @RequestParam(value = "sessionid", required = true) String sessionid,
                                            @ApiParam(name = "userid", value = "新增成员ID,多个以英文逗号隔开", defaultValue = "1")
                                            @RequestParam(value = "userid", required = true) String userid,
                                            @ApiParam(name = "olduserid", value = "删除的成员id")
                                            @RequestParam(value = "olduserid", required = false) String olduserid) throws Exception {
        try {
            imService.updateParticipant(sessionid, userid, olduserid);
            return success("操作成功");
        } catch (Exception e) {
            return failedException(e);
        }
    }
    @PostMapping(value = BaseHospitalRequestMapping.PatientIM.patientGuaidenceAppend)
    @ApiOperation(value = "居民导诊会话发送消息", notes = "居民导诊会话发送消息")
    public Envelop patientGuaidenceAppend(
            @ApiParam(name = "sender_id", value = "发送者id", defaultValue = "")
            @RequestParam(value = "sender_id", required = true) String sender_id,
            @ApiParam(name = "sender_name", value = "发送者姓名", defaultValue = "")
            @RequestParam(value = "sender_name", required = true) String sender_name,
            @ApiParam(name = "session_id", value = "session_id", defaultValue = "")
            @RequestParam(value = "session_id", required = false) String session_id,
            @ApiParam(name = "content_type", value = "内容类型", defaultValue = "")
            @RequestParam(value = "content_type", required = true) String content_type,
            @ApiParam(name = "content", value = "消息内容", defaultValue = "")
            @RequestParam(value = "content", required = true) String content,
            @ApiParam(name = "extend", value = "扩展内容", defaultValue = "")
            @RequestParam(value = "extend", required = false) String extend,
            @ApiParam(name = "type", value = "咨询type", defaultValue = "")
            @RequestParam(value = "type", required = false) String type,
            @ApiParam(name = "times", value = "times", defaultValue = "")
            @RequestParam(value = "times", required = false) Integer times,
            @ApiParam(name = "wechat_appid", value = "wechat_appid", defaultValue = "")
            @RequestParam(value = "wechat_appid", required = false) String wechat_appid
    ) {
        try {
            //处理语音文件
            if (!org.springframework.util.StringUtils.isEmpty(wechat_appid)) {
                if ("3".equalsIgnoreCase(content_type)) {//语音文件
                    String voicepath = imService.fetchWxVoices(wechat_appid);
                    logger.info("voice_path:" + voicepath);
                    JSONObject obj = new JSONObject();
                    String voiceurl = "";
                    // 将临时语音拷贝到正式存储路径下
                    if (org.apache.commons.lang3.StringUtils.isNotEmpty(voicepath)) {
                        if ("xm_ihealth_wx".equals(wechat_appid)) {
                            logger.info("voice_wx_type:" + wechat_appid);
                            voiceurl = fileUploadService.uploadWxVoice(voicepath);
                        } else if ("xm_xzzx_wx".equalsIgnoreCase(wechat_appid)) {
                            voiceurl = fileUploadService.uploadWxVoiceToEntrance(remote_inner_url, voicepath);
                            logger.info(voiceurl);
                        } else {
                            voiceurl = fileUtil.copyTempVoice(voicepath, fastdfs_file_url);
                        }
                        obj.put("path", voiceurl);
                        obj.put("times", times);
                        content = obj.toString();
                    }
                } else if ("2".equalsIgnoreCase(content_type)) {//图片文件
                    String imagepath = imService.fetchWxImages(wechat_appid);
                    logger.info("image_path:" + imagepath);
                    JSONObject obj = new JSONObject();
                    String imgeUrl = "";
                    // 将临时语音拷贝到正式存储路径下
                    if (org.apache.commons.lang3.StringUtils.isNotEmpty(imagepath)) {
                        if ("xm_ihealth_wx".equals(wechat_appid)) {
                            logger.info("imge_wx_type:" + wechat_appid);
                            imgeUrl = fileUploadService.uploadWxImage(imagepath);
                        } else {
                            imgeUrl = fileUtil.copyTempVoice(imagepath, fastdfs_file_url);
                        }
                        content = imgeUrl;
                    }
                } else {
                }
            }
            content = StringUtils.isNotEmpty(content) ? content.trim() : content;
            Map<String, JSONObject> map = robotService.robotReply(session_id, type, content);
            session_id = imService.getPatientGuaidenceConsult(sender_id, session_id, type);
            String result = imService.patientGuaidenceAppend(sender_id, sender_name, session_id, content_type, content, "1", extend);
            robotService.sendReplyMap(map);
            //消息存在时文本及问题集类型发送时自动回复
            robotService.replyGuaidenceContent(session_id, type, content, content_type, "1", extend);
            List<BaseDoctorRoleDO> doctorRoleDOS = doctorRoleDao.findByRoleCode("guidance");
            for (BaseDoctorRoleDO doctorRoleDO : doctorRoleDOS) {
                System.out.println("发送外层SOCKET消息:通知医生导诊");
                JSONObject object = new JSONObject();
                object.put("socket_sms_type", 13);
                object.put("relation_code", session_id);
                imService.sendWaiSocketMessage(sender_id, doctorRoleDO.getDoctorCode(), object.toString(), "1");
            }
            return success(result);
        } catch (Exception e) {
            return failedException(e);
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.PatientIM.getDoctorConsultCount)
    @ApiOperation(value = "医生端:查询会话视频邀请状态", notes = "医生端:查询会话视频邀请状态")
    public Envelop getDoctorConsultCount(@ApiParam(name = "doctorids", value = "会话ID")
                                         @RequestParam(value = "doctorids", required = true) String doctorids) throws Exception {
        return success("查询成功", imService.getDoctorConsultCount(doctorids));
    }
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.followOrgByPatient)
    @ApiOperation(value = "居民关注医院", notes = "居民关注医院")
    public Envelop followOrgByPatient(
            @ApiParam(name = "patientid", value = "居民ID", defaultValue = "")
            @RequestParam(value = "patientid", required = true) String patientid,
            @ApiParam(name = "orgid", value = "医生ID", defaultValue = "")
            @RequestParam(value = "orgid", required = true) String orgid,
            @ApiParam(name = "type", value = "1关注 0取消关注", defaultValue = "")
            @RequestParam(value = "type", required = true) String type
    ) throws Exception {
        prescriptionService.followOrgByPatient(patientid, orgid, type);
        return success("操作成功!");
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.selectByGuidance)
    @ApiOperation(value = "查询是否有导诊助手", notes = "查询是否有导诊助手")
    public MixEnvelop selectByGuidance() throws Exception {
        return MixEnvelop.getSuccessList("查询成功", doctorInfoService.selectByGuidance());
    }
}

+ 92 - 9
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/expressage/ExpressageEndpoint.java

@ -2,7 +2,6 @@ package com.yihu.jw.hospital.endpoint.expressage;
import com.yihu.jw.entity.hospital.prescription.WlyyExpressagePriceDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionExpressageDO;
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
import com.yihu.jw.hospital.prescription.service.PrescriptionExpressageService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
@ -20,7 +19,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.net.URLDecoder;
import java.util.List;
@RestController
@ -48,7 +46,6 @@ public class ExpressageEndpoint extends EnvelopRestEndpoint {
            //返回接口异常信息处理结果
            return failed( "查询失败,"+e.getMessage());
        }
    }
@ -183,14 +180,100 @@ public class ExpressageEndpoint extends EnvelopRestEndpoint {
    }
    @RequestMapping(value="/test",method = RequestMethod.GET)
    @ApiOperation("test")
    public Envelop test(String test){
    /****************************common****************************************/
    @RequestMapping(value="/sfrouteserviceSearchCommon",method = RequestMethod.GET)
    @ApiOperation("通过关联编号查询顺丰物流派送记录")
    public Envelop SFRouteServiceSearchCommon(@ApiParam(name="relationType", value="关联类型 类型1 病案复印(关联病案复印申请id)")
                                              @RequestParam(value = "relationType",required = true) String relationType,
                                              @ApiParam(name="relationCode", value="关联id")
                                              @RequestParam(value = "relationCode",required = true) String relationCode){
        try {
            List<WlyyPrescriptionExpressageDO> expressageDOList = sfexpressService.findByRelationCode(relationCode,relationType);
            if(CollectionUtils.isEmpty(expressageDOList)){
                return failed("没有物流信息!");
            }
            WlyyPrescriptionExpressageDO sfexpress_obj = expressageDOList.get(0);
            String result  = sfexpressService.getRoutInfosSearch(sfexpress_obj);
            return success(result);
        }catch (Exception e){
            //返回接口异常信息处理结果
            return failed( "查询失败,"+e.getMessage());
        }
    }
    @RequestMapping(value="/sforderserviceCommon",method = RequestMethod.POST)
    @ApiOperation("向顺丰快递下订单")
    public Envelop SFOrderServiceCommon(@ApiParam(name="relationType", value="关联类型 类型1 病案复印(关联病案复印申请id)")
                                            @RequestParam(value = "relationType",required = true) String relationType,
                                        @ApiParam(name="relationCode", value="关联id")
                                            @RequestParam(value = "relationCode",required = true) String relationCode){
        try {
//            sfexpressService.test();
            return success("ok");
            List<WlyyPrescriptionExpressageDO> expressageDOList = sfexpressService.findByRelationCode(relationCode,relationType);
            if(CollectionUtils.isEmpty(expressageDOList)){
                return failed("顺丰快递下单失败,未找到派送地址!");
            }else{
                WlyyPrescriptionExpressageDO sfexpress_obj = expressageDOList.get(0);
                //如果该处方的快递单号已生成,则说明已经下单成功,不需要重复下单,直接返回成功
                if(StringUtils.isNotBlank(sfexpress_obj.getMailno())){
                    return success("顺丰快递下单成功!");
                }else{
                    //如果该处方的快递单号未生成,则继续下单
                    //根据业务订单号判断是否已经下单成功
                    boolean go_on = sfexpressService.sfOrderSearchService(sfexpress_obj);
                    //如果该业务订单号未下单成功过,则重新下单
                    if(go_on){
                        //请求顺丰接口下单,成功下单后,返回快递单号
                        sfexpress_obj = sfexpressService.postSFOrderServiceCommon(sfexpress_obj);
                        //保存快递单号和增加处方物流记录为配送
                        sfexpressService.updatePrescriptionExpressage(sfexpress_obj);
                    }
                    return success(sfexpress_obj);
                }
            }
        }catch (Exception e){
            //返回接口异常信息处理结果
            return failed(e.getMessage());
        }
    }
    @RequestMapping(value="/sfgetorderinfoserviceCommon",method = RequestMethod.GET)
    @ApiOperation("通过编号查询顺丰快递单信息(不包含物流记录)")
    public Envelop SFGetOrderInfoCommon(@ApiParam(name="relationType", value="关联类型 类型1 病案复印(关联病案复印申请id)")
                                            @RequestParam(value = "relationType",required = true) String relationType,
                                        @ApiParam(name="relationCode", value="关联id")
                                            @RequestParam(value = "relationCode",required = true) String relationCode){
        try {
            List<WlyyPrescriptionExpressageDO> expressageDOList = sfexpressService.findByRelationCode(relationCode,relationType);
            if(CollectionUtils.isEmpty(expressageDOList)){
                return failed( "不存在快递信息");
            }
            WlyyPrescriptionExpressageDO sfexpress_obj = expressageDOList.get(0);
            return success(sfexpress_obj);
        }catch (Exception e) {
            return failed("异常," + e.getMessage());
            return failed("查询失败," + e.getMessage());
        }
    }
    @RequestMapping(value="/sfordersearchserviceCommon",method = RequestMethod.GET)
    @ApiOperation("通过编号查询顺丰快递是否下单成功")
    public Envelop SFOrderSearchServiceCommon(@ApiParam(name="relationType", value="关联类型 类型1 病案复印(关联病案复印申请id)")
                                                  @RequestParam(value = "relationType",required = true) String relationType,
                                              @ApiParam(name="relationCode", value="关联id")
                                                  @RequestParam(value = "relationCode",required = true) String relationCode){
        List<WlyyPrescriptionExpressageDO> expressageDOList = sfexpressService.findByRelationCode(relationCode,relationType);
        if(CollectionUtils.isEmpty(expressageDOList)){
            return failed( "没有顺丰快递信息");
        }
        try {
            WlyyPrescriptionExpressageDO sfexpress_obj = expressageDOList.get(0);
            boolean go_on = sfexpressService.sfOrderSearchServiceJustSearch(sfexpress_obj);
            return success(go_on);
        }catch (Exception e) {
            return failed("查询失败," + e.getMessage());
        }
    }

+ 15 - 4
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/hospital/BaseSuggestionController.java

@ -1,13 +1,12 @@
package com.yihu.jw.hospital.endpoint.hospital;
import com.yihu.jw.entity.base.doctor.BaseDoctorBackgroundDO;
import com.yihu.jw.entity.hospital.message.BaseBannerDO;
import com.yihu.jw.entity.hospital.suggest.BaseSuggestionDO;
import com.yihu.jw.hospital.suggest.service.BaseSuggestionService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.util.entity.ServiceException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -18,8 +17,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping(value = BaseHospitalRequestMapping.suggestion.suggestionManage)
@Api(value = "反馈建议", description = "反馈建议", tags = {"互联网医院 - 反馈建议"})
@ -99,4 +96,18 @@ public class BaseSuggestionController extends EnvelopRestEndpoint {
            return failedException(e);
        }
    }
    @PostMapping(value= "revoke")
    @ApiOperation("撤回功能")
    public Envelop revoke(
            @ApiParam(name = "id", value = "建议id", required = true)
            @RequestParam(value = "id", required = true)String id) {
        try {
            return success(baseSuggestionService.revoke(id));
        }catch (ServiceException se){
            return Envelop.getError(se.getMessage());
        }catch (Exception e){
            return failedException(e);
        }
    }
}

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

@ -0,0 +1,141 @@
package com.yihu.jw.hospital.endpoint.prescription;
import com.yihu.jw.contant.CommonContant;
import com.yihu.jw.hospital.prescription.service.NatService;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.entity.ServiceException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * Created by yeshijie on 2023/12/28.
 */
@RestController
@RequestMapping(value = "natItem")
@Api(value = "专项医技预约管理", description = "专项医技预约管理", tags = {"专项医技预约管理"})
public class NatEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private NatService natService;
    @PostMapping(value = "createOrUpd")
    @ApiOperation(value = "新增或修改医技预约项目")
    public ObjEnvelop createOrUpd (
            @ApiParam(name = "jsonData", value = "json格式")
            @RequestParam(value = "jsonData", required = true) String jsonData) {
        try {
            return ObjEnvelop.getSuccess(CommonContant.Message.SAVE_SUCCESS,natService.createOrUpd(jsonData));
        }catch (ServiceException se){
            return ObjEnvelop.getError(se.getMessage());
        }catch (Exception e){
            e.printStackTrace();
        }
        return ObjEnvelop.getError(CommonContant.Message.SAVE_ERROR);
    }
    @GetMapping(value = "findDetailById")
    @ApiOperation(value = "获取医技预约项目详情")
    public ObjEnvelop findDetailById (
            @ApiParam(name = "id", value = "id")
            @RequestParam(value = "id", required = true) String id) {
        try {
            return ObjEnvelop.getSuccess("获取成功",natService.findDetailById(id));
        }catch (Exception e){
            e.printStackTrace();
        }
        return ObjEnvelop.getError(CommonContant.Message.GET_ERROR);
    }
    @PostMapping(value = "updStatus")
    @ApiOperation(value = "修改状态")
    public ObjEnvelop updStatus (
            @ApiParam(name = "id", value = "id")
            @RequestParam(value = "id", required = true) String id,
            @ApiParam(name = "status", value = "状态")
            @RequestParam(value = "status", required = true) String status) {
        try {
            return ObjEnvelop.getSuccess(CommonContant.Message.SAVE_SUCCESS,natService.updStatus(id,status));
        }catch (ServiceException se){
            return ObjEnvelop.getError(se.getMessage());
        }catch (Exception e){
            e.printStackTrace();
        }
        return ObjEnvelop.getError(CommonContant.Message.SAVE_ERROR);
    }
    @GetMapping(value = "natItemPage")
    @ApiOperation(value = "医技预约项目分页")
    public PageEnvelop natItemPage (
            @ApiParam(name = "name", value = "项目名称")
            @RequestParam(value = "name", required = false) String name,
            @ApiParam(name = "status", value = "状态")
            @RequestParam(value = "status", required = false) String status,
            @ApiParam(name = "suitableCrowd", value = "适用人群")
            @RequestParam(value = "suitableCrowd", required = false) String suitableCrowd,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") Integer page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") Integer size) {
        try {
            return natService.natItemPage(name,status,suitableCrowd, page, size);
        }catch (Exception e){
            e.printStackTrace();
        }
        return PageEnvelop.getError(CommonContant.Message.GET_ERROR);
    }
    @GetMapping(value = "natAppointmentPage")
    @ApiOperation(value = "核酸预约记录分页")
    public PageEnvelop natAppointmentPage (
            @ApiParam(name = "name", value = "患者姓名")
            @RequestParam(value = "name", required = false) String name,
            @ApiParam(name = "payStatus", value = "状态")
            @RequestParam(value = "payStatus", required = false) String payStatus,
            @ApiParam(name = "merchantOrderNo", value = "商户订单号")
            @RequestParam(value = "merchantOrderNo", required = false) String merchantOrderNo,
            @ApiParam(name = "invoiceSerialNo", value = "发票流水号")
            @RequestParam(value = "invoiceSerialNo", required = false) String invoiceSerialNo,
            @ApiParam(name = "medicare", value = "就诊卡号")
            @RequestParam(value = "medicare", required = false) String medicare,
            @ApiParam(name = "cardNo", value = "身份证")
            @RequestParam(value = "cardNo", required = false) String cardNo,
            @ApiParam(name = "createTimeStart", value = "申请开始时间")
            @RequestParam(value = "createTimeStart", required = false) String createTimeStart,
            @ApiParam(name = "createTimeEnd", value = "申请结束时间")
            @RequestParam(value = "createTimeEnd", required = false) String createTimeEnd,
            @ApiParam(name = "appointmentTimeStart", value = "预约开始时间")
            @RequestParam(value = "appointmentTimeStart", required = false) String appointmentTimeStart,
            @ApiParam(name = "appointmentTimeEnd", value = "预约结束时间")
            @RequestParam(value = "appointmentTimeEnd", required = false) String appointmentTimeEnd,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") Integer page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") Integer size) {
        try {
            return natService.natAppointmentPage(name, payStatus, merchantOrderNo, invoiceSerialNo, medicare, cardNo,
                    createTimeStart, createTimeEnd, appointmentTimeStart, appointmentTimeEnd, page, size);
        }catch (Exception e){
            e.printStackTrace();
        }
        return PageEnvelop.getError(CommonContant.Message.GET_ERROR);
    }
    @GetMapping(value = "natAppointmentDetail")
    @ApiOperation(value = "核酸预约记录详情")
    public ObjEnvelop natAppointmentDetail (
            @ApiParam(name = "id", value = "id")
            @RequestParam(value = "id", required = true) Integer id) {
        try {
            return ObjEnvelop.getSuccess("获取成功",natService.natAppointmentDetail(id));
        }catch (Exception e){
            e.printStackTrace();
        }
        return ObjEnvelop.getError(CommonContant.Message.GET_ERROR);
    }
}

+ 26 - 27
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/statistics/EsStatisticsEndpoint.java

@ -1649,7 +1649,7 @@ public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
    public Envelop getDoctorFreeDetail(@RequestParam(required = true) String strJson) {
        try {
            ScreenQvo qvo = JSON.parseObject(strJson, ScreenQvo.class);
            Map<String, Object>  result = statisticsEsService.getDoctorFreeDetail(qvo);
            Map<String, Object> result = statisticsEsService.getDoctorFreeDetail(qvo);
            return success(result);
        } catch (Exception e) {
            e.printStackTrace();
@ -1735,6 +1735,7 @@ public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
        try {
            ScreenQvo qvo = JSON.parseObject(strJson, ScreenQvo.class);
            JSONObject result = statisticsEsService.getHealthChart(qvo);
            System.out.println("获取i健康的患者的健康指标数据==>" + JSON.toJSONString(result));
            return success(result);
        } catch (Exception e) {
            e.printStackTrace();
@ -1743,60 +1744,58 @@ public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
    }
    @GetMapping(value = BaseHospitalRequestMapping.DodtorIM.records2)
    @ApiOperation(value = "医生咨询记录查询")
    public Envelop records2(
            @ApiParam(name = "doctor", value = "医生id")
            @RequestParam(value = "doctor",required = false) String doctor,
            @RequestParam(value = "doctor", required = false) String doctor,
            @ApiParam(name = "title", value = "咨询标题关键字")
            @RequestParam(value = "title",required = false) String title,
            @RequestParam(value = "title", required = false) String title,
            @ApiParam(name = "patient", value = "患者id")
            @RequestParam(value = "patient",required = false) String patient,
            @RequestParam(value = "patient", required = false) String patient,
            @ApiParam(name = "id", value = "咨询ID")
            @RequestParam(value = "id",required = false) String id,
            @RequestParam(value = "id", required = false) String id,
            @ApiParam(name = "type", value = "咨询类型")
            @RequestParam(value = "type",required = true) String type,
            @RequestParam(value = "type", required = true) String type,
            @ApiParam(name = "status", value = "咨询状态:0全部,1候诊中,2就诊中,3结束")
            @RequestParam(value = "status",required = true) Integer status,
            @RequestParam(value = "status", required = true) Integer status,
            @ApiParam(name = "start_time", value = "开始时间 YYYY-MM-DD HH:MM:SS")
            @RequestParam(value = "start_time",required = false) String start_time,
            @RequestParam(value = "start_time", required = false) String start_time,
            @ApiParam(name = "end_time", value = "结束时间 YYYY-MM-DD HH:MM:SS")
            @RequestParam(value = "end_time",required = false) String end_time,
            @RequestParam(value = "end_time", required = false) String end_time,
            @ApiParam(name = "page", value = "第几页")
            @RequestParam(value = "page",required = false) int page,
            @RequestParam(value = "page", required = false) int page,
            @ApiParam(name = "pagesize", value = "分页大小")
            @RequestParam(value = "pagesize",required = false) int pagesize
    )throws Exception{
            @RequestParam(value = "pagesize", required = false) int pagesize
    ) throws Exception {
        try {
            List<Map<String,Object>>  data = imService.findConsultRecordByDoctorNew(doctor, id,type,status, page,pagesize, title,start_time,end_time,patient);
            List<Map<String, Object>> data = imService.findConsultRecordByDoctorNew(doctor, id, type, status, page, pagesize, title, start_time, end_time, patient);
            if (data != null) {
                for(Map<String,Object> consult :data){
                for (Map<String, Object> consult : data) {
                    //如果是协同门诊,多返回全科医生的详细信息
                    if(12 == Integer.parseInt(consult.get("type").toString()) && StringUtils.isNoneBlank((String)consult.get("generalDoctor"))){
                        BaseDoctorDO baseDoctorDO = baseDoctorDao.findByIdAndDel((String)consult.get("generalDoctor"));
                        List<BaseDoctorHospitalDO> baseDoctorHospitalDOList = baseDoctorHospitalDao.findByDoctorCode((String)consult.get("generalDoctor"));
                        if(baseDoctorDO!=null){
                    if (12 == Integer.parseInt(consult.get("type").toString()) && StringUtils.isNoneBlank((String) consult.get("generalDoctor"))) {
                        BaseDoctorDO baseDoctorDO = baseDoctorDao.findByIdAndDel((String) consult.get("generalDoctor"));
                        List<BaseDoctorHospitalDO> baseDoctorHospitalDOList = baseDoctorHospitalDao.findByDoctorCode((String) consult.get("generalDoctor"));
                        if (baseDoctorDO != null) {
                            consult.put("generalDoctorName", baseDoctorDO.getName());
                        }
                        if (baseDoctorHospitalDOList!=null&&baseDoctorHospitalDOList.size()!=0){
                        if (baseDoctorHospitalDOList != null && baseDoctorHospitalDOList.size() != 0) {
                            BaseDoctorHospitalDO baseDoctorHospitalDO = baseDoctorHospitalDOList.get(0);
                            consult.put("generalOrgName",baseDoctorHospitalDO.getOrgName());
                            consult.put("generalDeptName",baseDoctorHospitalDO.getDeptName());
                            consult.put("generalOrgName", baseDoctorHospitalDO.getOrgName());
                            consult.put("generalDeptName", baseDoctorHospitalDO.getDeptName());
                        }
                    }
                }
            }
            Long total = imService.countConsultRecordByDoctor2(doctor, id,type,status,title,start_time,end_time);
            Long total = imService.countConsultRecordByDoctor2(doctor, id, type, status, title, start_time, end_time);
            JSONObject result = new JSONObject();
            result.put("total",total);
            result.put("list",data);
            result.put("total", total);
            result.put("list", data);
            return success(result);
        } catch (Exception e){
        } catch (Exception e) {
            return failedException(e);
        }
    }

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

@ -1,15 +1,14 @@
package com.yihu.jw.hospital.service.consult;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.article.dao.KnowledgeArticleDeptDao;
import com.yihu.jw.article.dao.KnowledgeArticleDictDao;
import com.yihu.jw.article.dao.KnowledgeArticleUserDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.patient.BasePatientBusinessDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDeptDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDictDO;
@ -47,7 +46,8 @@ public class KnowledgeArticleService extends BaseJpaService<KnowledgeArticleDO,
	
	@Autowired
	private KnowledgeArticleDao knowledgeArticleDao;
	
	@Autowired
	private KnowledgeArticleDictDao knowledgeArticleDictDao;
	@Autowired
	private KnowledgeArticleDeptDao knowledgeArticleDeptDao;
	@Autowired
@ -264,14 +264,22 @@ public class KnowledgeArticleService extends BaseJpaService<KnowledgeArticleDO,
				patientBusinessDO.setCollection(0);
				patientBusinessDO.setDel(1);
				patientBusinessDO = patientBusinessDao.save(patientBusinessDO);
					if (patientBusinessDO.getRelationType()==1){
				if (patientBusinessDO.getRelationType()==1){
					KnowledgeArticleDO knowledgeArticleDO = knowledgeArticleDao.findByIdAndDel(patientBusinessDO.getRelationCode());
					System.out.println("content:"+JSON.toJSONString(knowledgeArticleDO));
					JSONObject object = new JSONObject();
					object.put("id",knowledgeArticleDO.getId());
					object.put("title",knowledgeArticleDO.getTitle());
					object.put("content",knowledgeArticleDO.getIntro());
					object.put("img",knowledgeArticleDO.getImage());
					if(knowledgeArticleDO==null){
						KnowledgeArticleDictDO knowledgeArticleDictDO = knowledgeArticleDictDao.findByIdAndDel(patientBusinessDO.getRelationCode());
						object.put("id",knowledgeArticleDictDO.getId());
						object.put("title",knowledgeArticleDictDO.getTitle());
						object.put("content",knowledgeArticleDictDO.getIntro());
						object.put("img",knowledgeArticleDictDO.getImage());
						object.put("type",knowledgeArticleDictDO.getType());
					}else {
						object.put("id",knowledgeArticleDO.getId());
						object.put("title",knowledgeArticleDO.getTitle());
						object.put("content",knowledgeArticleDO.getIntro());
						object.put("img",knowledgeArticleDO.getImage());
					}
					imUtil.sendImMsg(patientBusinessDO.getDoctor(), patientBusinessDO.getDoctorName(), patientBusinessDO.getSessionId(), "4", object.toJSONString(),"1",null);
				}else {
					WlyySurveyUserDO wlyySurveyUserDO = new WlyySurveyUserDO();

+ 4 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/door/service/DoorOrderService.java

@ -11,6 +11,7 @@ import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.servicePackage.ServicePackageSubItemDO;
import com.yihu.jw.entity.base.system.SystemDictDO;
import com.yihu.jw.hospital.module.rehabilitation.service.RehabilitationManageService;
import com.yihu.jw.rehabilitation.ServiceItemPlanDao;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.entity.door.*;
@ -129,6 +130,9 @@ public class DoorOrderService {
    @Autowired
    ServiceItemPlanDao serviceItemPlanDao;
    @Autowired
    RehabilitationManageService rehabilitationManageService;
    /**
     * 服务项查询
     * type =4

+ 17 - 10
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/door/service/WlyyDoorServiceOrderService.java

@ -724,10 +724,10 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        //关联code不为空情况
        ServiceItemPlanDO serviceItemPlanDO = null;
        if(StringUtils.isNotBlank(orderDO.getRelationCode())){
        if (StringUtils.isNotBlank(orderDO.getRelationCode())) {
            serviceItemPlanDO = serviceItemPlanDao.findById(orderDO.getRelationCode()).orElse(null);
            if(serviceItemPlanDO!=null){
                if("1".equals(serviceItemPlanDO.getStatus())){
            if (serviceItemPlanDO != null) {
                if ("1".equals(serviceItemPlanDO.getStatus())) {
                    throw new ServiceException("请勿重复申请");
                }
                orderDO.setDoctor(serviceItemPlanDO.getDoctor());
@ -738,9 +738,12 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        //保存服务订单
        orderDO = wlyyDoorServiceOrderDao.save(orderDO);
        if(serviceItemPlanDO!=null){
        if (serviceItemPlanDO != null) {
            serviceItemPlanDO.setRelationCode(orderDO.getId());
            rehabilitationManageService.completePlan(serviceItemPlanDO);
            //创建初不应是已完成
//           rehabilitationManageService.completePlan(serviceItemPlanDO);
            //设置为进行中
            rehabilitationManageService.planCarryOuting(serviceItemPlanDO);
        }
        //新增工单与服务项费用关联关系
@ -1614,6 +1617,10 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, "工单服务已取消!");
        //设置为取消状态
        rehabilitationManageService.cancelPlan(orderId);
        System.out.println("设置为取消状态");
        return result;
    }
@ -2275,7 +2282,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
                WlyyDoorDoctorStatusDO.Status.serving.getType(),
        });
        if (null == doorDoctorStatusDO) {
            String failMsg = "当前派单的医生不存在或禁止接单" ;
            String failMsg = "当前派单的医生不存在或禁止接单";
            throw new Exception(failMsg);
        }
@ -3044,12 +3051,12 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
    }
    //获取医生列表
    public List<Map<String, Object>> findDoctorList(String name,Integer page,Integer size) {
    public List<Map<String, Object>> findDoctorList(String name, Integer page, Integer size) {
        String sql = "select id,name from base_doctor where del='1' and enabled=1";
        if(StringUtils.isNotBlank(name)){
            sql += " and name like '%"+name+"%'";
        if (StringUtils.isNotBlank(name)) {
            sql += " and name like '%" + name + "%'";
        }
        sql+= " limit "+(page-1)*size+","+size;
        sql += " limit " + (page - 1) * size + "," + size;
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }

+ 9 - 9
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/PatientDeviceController.java

@ -134,9 +134,9 @@ public class PatientDeviceController extends BaseController {
                        throw new Exception("sn码" + newDeviceSN + "已被使用!");
                    }
                    if(!patientDeviceService.checkDeviceSn(newDeviceSN)){
                        return error(-1,"设备不存在");
                    }
//                    if(!patientDeviceService.checkDeviceSn(newDeviceSN)){
//                        return error(-1,"设备不存在");
//                    }
                }
                if ("1".equals(categoryCode)) {
//                        先修改患者设备绑定表
@ -163,7 +163,7 @@ public class PatientDeviceController extends BaseController {
            return write(200, "设置成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, e.getMessage());
            return error(-1, "操作失败");
        }
    }
@ -255,7 +255,7 @@ public class PatientDeviceController extends BaseController {
            return write(200, "查询成功", "data", list);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, ex.getMessage());
            return error(-1, "查询失败");
        }
    }
@ -277,7 +277,7 @@ public class PatientDeviceController extends BaseController {
            return write(200, "查询成功", "data", mapList);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, ex.getMessage());
            return error(-1, "查询失败");
        }
    }
@ -298,7 +298,7 @@ public class PatientDeviceController extends BaseController {
            return write(200, "获取设备绑定信息成功!", "data", list);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, ex.getMessage());
            return error(-1, "查询失败");
        }
    }
    
@ -364,7 +364,7 @@ public class PatientDeviceController extends BaseController {
            }
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, ex.getMessage());
            return error(-1, "操作失败");
        }
    }
@ -424,7 +424,7 @@ public class PatientDeviceController extends BaseController {
            }
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, ex.getMessage());
            return error(-1, "操作失败");
        }
    }

+ 0 - 1
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/PatientHealthIndexService.java

@ -400,7 +400,6 @@ public class PatientHealthIndexService {
                " GROUP BY user,value1,value2,value3,value4,value5,value6,value7,type,record_date,sort_date " +
                " order by record_date,id desc ";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        SimpleDateFormat dateFormat6 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if (list != null && list.size() > 0) {
            obj.put("type", 1);
            obj.put("czrq", dateString);

+ 145 - 125
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/service/RehabilitationManageService.java

@ -99,27 +99,27 @@ public class RehabilitationManageService {
    private FollowUpDao followupDao;
    //近期康复记录
    public Envelop recentServiceItemPlanRecords(String patient,Integer page,Integer size){
    public Envelop recentServiceItemPlanRecords(String patient, Integer page, Integer size) {
        String sql = "select p.* ";
        String countSql = "select count(p.id) ";
        String filter = " from base_service_item_plan p where p.patient='"+patient+"' and p.plan_time<='"+DateUtil.getStringDateShort()+" 23:59:59' ";
        String ordereBy = " order by p.plan_time desc limit "+(page-1)*size+","+size;
        List<ServiceItemPlanDO> planDOList = jdbcTemplate.query(sql+filter+ordereBy,new BeanPropertyRowMapper<>(ServiceItemPlanDO.class));
        long count = jdbcTemplate.queryForObject(countSql+filter,Long.class);
        return PageEnvelop.getSuccessListWithPage("获取成功",planDOList,page,size,count);
        String filter = " from base_service_item_plan p where p.patient='" + patient + "' and p.plan_time<='" + DateUtil.getStringDateShort() + " 23:59:59' ";
        String ordereBy = " order by p.plan_time desc limit " + (page - 1) * size + "," + size;
        List<ServiceItemPlanDO> planDOList = jdbcTemplate.query(sql + filter + ordereBy, new BeanPropertyRowMapper<>(ServiceItemPlanDO.class));
        long count = jdbcTemplate.queryForObject(countSql + filter, Long.class);
        return PageEnvelop.getSuccessListWithPage("获取成功", planDOList, page, size, count);
    }
    //添加康复计划日志
    public void addPlanLog(String planId,String doctorCode,String doctorName){
        if(StringUtils.isBlank(doctorCode)){
    public void addPlanLog(String planId, String doctorCode, String doctorName) {
        if (StringUtils.isBlank(doctorCode)) {
            return;
        }
        if(StringUtils.isBlank(doctorName)){
        if (StringUtils.isBlank(doctorName)) {
            BaseDoctorDO doctorDO = doctorDao.findByIdAndDel(doctorCode);
            doctorName = doctorDO.getName();
        }
        PatientRehabilitationPlanLogDO planLogDO = new PatientRehabilitationPlanLogDO();
        planLogDO.setId(UUID.randomUUID().toString().replace("-",""));
        planLogDO.setId(UUID.randomUUID().toString().replace("-", ""));
        planLogDO.setPlanId(planId);
        planLogDO.setCreateTime(new Date());
        planLogDO.setCreateUser(doctorCode);
@ -128,61 +128,61 @@ public class RehabilitationManageService {
    }
    //计划负责人分配执行人
    public void assignExecutor(PatientRehabilitationPlanDO planDO,String uid){
    public void assignExecutor(PatientRehabilitationPlanDO planDO, String uid) {
        PatientRehabilitationPlanDO planDO1 = patientRehabilitationPlanDao.findById(planDO.getId()).orElse(null);
        if(planDO1==null){
        if (planDO1 == null) {
            throw new ServiceException("康复计划不存在");
        }
        if(planDO1.getStatus()!=3){
        if (planDO1.getStatus() != 3) {
            throw new ServiceException("已分配,请勿重复分配");
        }
        if(StringUtils.isNotBlank(uid)){
            if(!uid.equals(planDO1.getPlanDoctor())){
        if (StringUtils.isNotBlank(uid)) {
            if (!uid.equals(planDO1.getPlanDoctor())) {
                throw new ServiceException("您不是该康复计划负责人,不允许操作");
            }
        }
        List<RehabilitationDetailDO> detailDOS = rehabilitationDetailDao.findByPlanIdAndStatus(planDO.getId(),0);
        List<RehabilitationDetailDO> detailDOS = rehabilitationDetailDao.findByPlanIdAndStatus(planDO.getId(), 0);
        List<RehabilitationDetailDO> detailDOList = planDO.getDetailDOList();
        Map<String,RehabilitationDetailDO> map = detailDOList.stream().collect(Collectors.toMap
                (RehabilitationDetailDO::getHospitalServiceItemId, log->log,(oldLog, newLog)->oldLog));
        Map<String, RehabilitationDetailDO> map = detailDOList.stream().collect(Collectors.toMap
                (RehabilitationDetailDO::getHospitalServiceItemId, log -> log, (oldLog, newLog) -> oldLog));
        List<ServiceItemPlanDO> planDOList = new ArrayList<>();
        List<RehabilitationServiceItemDO> itemDOList = serviceItemDao.findList();
        Map<String, String> serviceItemMap = itemDOList.stream().collect(Collectors.toMap(RehabilitationServiceItemDO::getCode, RehabilitationServiceItemDO::getName));
        for (RehabilitationDetailDO detailDO : detailDOS){
        for (RehabilitationDetailDO detailDO : detailDOS) {
            String serviceItemId = detailDO.getHospitalServiceItemId();
            if(map.containsKey(serviceItemId)){
            if (map.containsKey(serviceItemId)) {
                RehabilitationDetailDO newDetail = map.get(serviceItemId);
                detailDO.setDoctor(newDetail.getDoctor());
                detailDO.setDoctorName(newDetail.getDoctorName());
                detailDO.setDept(newDetail.getDept());
                detailDO.setDeptName(newDetail.getDeptName());
                //生成执行计划列表
                planDOList = addServicePlan(serviceItemMap,planDO1,detailDO,planDOList);
                planDOList = addServicePlan(serviceItemMap, planDO1, detailDO, planDOList);
            }
        }
        rehabilitationDetailDao.saveAll(detailDOS);
        if(planDOList.size()>0){
        if (planDOList.size() > 0) {
            serviceItemPlanDao.saveAll(planDOList);
        }
        planDO1.setStatus(1);
        patientRehabilitationPlanDao.save(planDO1);
        addPlanLog(planDO.getId(),uid,null);
        addPlanLog(planDO.getId(), uid, null);
        //更新状态
        if(StringUtils.isNotBlank(planDO1.getPatientInfoCode())){
        if (StringUtils.isNotBlank(planDO1.getPatientInfoCode())) {
            RehabilitationPatientInfoDO infoDO = rehabilitationPatientInfoDao.findByCode(planDO1.getPatientInfoCode());
            infoDO.setStatus(7);
            rehabilitationPatientInfoDao.save(infoDO);
        }
    }
    public List<ServiceItemPlanDO> addServicePlan(Map<String, String> serviceItemMap,PatientRehabilitationPlanDO planDO,
                                                  RehabilitationDetailDO detailDO,List<ServiceItemPlanDO> planDOList){
    public List<ServiceItemPlanDO> addServicePlan(Map<String, String> serviceItemMap, PatientRehabilitationPlanDO planDO,
                                                  RehabilitationDetailDO detailDO, List<ServiceItemPlanDO> planDOList) {
        String planId = planDO.getId();
        String pateint = planDO.getPatient();
        String relationType = detailDO.getHospitalServiceItemId();
        Integer plan_start_time_type = detailDO.getTimeType();//计划开始时间类型
        String server_count = detailDO.getServerCount();//服务次数
        if(StringUtils.isBlank(server_count)&&!"3".equals(relationType)){
        if (StringUtils.isBlank(server_count) || "3".equals(relationType)) {
            return planDOList;
        }
        String planDetailId = detailDO.getId();
@ -192,8 +192,8 @@ public class RehabilitationManageService {
        LocalDateTime localDateTime = LocalDateTime.now();
        int addNum = 0;
        localDateTime = localDateTime.plusDays(addNum);
        List<String>  timeList = CronUtils.getExecutionTimeByNum(frequency_code,Integer.parseInt(server_count),localDateTime);
        for (String time :timeList){
        List<String> timeList = CronUtils.getExecutionTimeByNum(frequency_code, Integer.parseInt(server_count), localDateTime);
        for (String time : timeList) {
            ServiceItemPlanDO itemPlanDO = new ServiceItemPlanDO();
            itemPlanDO.setPlanTime(time);
            itemPlanDO.setPatient(pateint);
@ -204,10 +204,10 @@ public class RehabilitationManageService {
            itemPlanDO.setPlanDetailId(planDetailId);
            itemPlanDO.setDoctor(doctor);
            itemPlanDO.setDoctorName(doctorName);
            if("6".equals(relationType)){
            if ("6".equals(relationType)) {
                Followup followup = followUpService.addRehabilatationFollowup(itemPlanDO);
                if(followup!=null){
                    itemPlanDO.setRelationCode(followup.getId()+"");
                if (followup != null) {
                    itemPlanDO.setRelationCode(followup.getId() + "");
                }
            }
            planDOList.add(itemPlanDO);
@ -590,11 +590,11 @@ public class RehabilitationManageService {
     * @param taskExecutor 任务执行者 0全部;1我的任务 2他人任务
     */
    public ObjEnvelop calendarPlanDetail(String executeStartTime, String executeEndTime, String planId, Integer searchTask,
                                         Integer status, String doctorCode, String taskExecutor,String patient,String diseaseId) throws Exception {
                                         Integer status, String doctorCode, String taskExecutor, String patient, String diseaseId) throws Exception {
        String sql = " select d.* from base_service_item_plan d,wlyy_patient_rehabilitation_plan p  where d.plan_id=p.id ";
        if(StringUtils.isNotBlank(patient)){
        if (StringUtils.isNotBlank(patient)) {
            sql += " and  d.patient = '" + patient + "' ";
        }else {
        } else {
            String[] planIdlist = planId.split(",");
            StringBuilder planCondition = new StringBuilder();
            planCondition.append("'" + planIdlist[0] + "'");
@ -603,7 +603,7 @@ public class RehabilitationManageService {
            }
            sql += " and  d.plan_id in (" + planCondition + " ) ";
        }
        if(StringUtils.isNotBlank(diseaseId)){
        if (StringUtils.isNotBlank(diseaseId)) {
            sql += " and  p.disease = '" + diseaseId + "' ";
        }
        if (StringUtils.isNotBlank(executeStartTime)) {
@ -626,13 +626,13 @@ public class RehabilitationManageService {
            sql += "and d.doctor <>'" + doctorCode + "' ";
        }
        if (status != null) {
            sql += " and d.status='" + status+"' ";
            sql += " and d.status='" + status + "' ";
        }
        sql += " ORDER BY d.plan_time ";
        List<Map<String, Object>> rehabilitationDetailList = jdbcTemplate.queryForList(sql);
        Map<String, Map<String, Object>> map = new LinkedHashMap<>();
        for (Map<String, Object> one : rehabilitationDetailList) {
            String executeTime = (one.get("plan_time")+"").substring(0,10);
            String executeTime = (one.get("plan_time") + "").substring(0, 10);
            Map<String, Object> m = new HashMap<>();
            if (map.containsKey(executeTime)) {
                m = map.get(executeTime);
@ -645,16 +645,16 @@ public class RehabilitationManageService {
                    specialist.put("all", 0);
                    specialist.put("finish", 0);
                }
                if ("1".equals(one.get("status")+"")) {
                if ("1".equals(one.get("status") + "")) {
                    specialist.put("finish", (specialist.get("finish")) + 1);
                }
                specialist.put("all", (specialist.get("all")) + 1);
                m.put("doctor", specialist);
            }else{
            } else {
                Map<String, Integer> specialist = new HashMap<>();
                specialist.put("all", 0);
                specialist.put("finish", 0);
                if ("1".equals(one.get("status")+"")) {
                if ("1".equals(one.get("status") + "")) {
                    specialist.put("finish", specialist.get("finish") + 1);
                }
                specialist.put("all", specialist.get("all") + 1);
@ -698,12 +698,12 @@ public class RehabilitationManageService {
     * @param taskExecutor 任务执行者 0全部;1我的任务 2他人任务
     */
    public ObjEnvelop calendarPlanDetailList(String planId, Integer searchTask, Integer status, String doctorCode,
                                             String executeStartTime, String executeEndTime, String taskExecutor,String patient,String diseaseId) {
                                             String executeStartTime, String executeEndTime, String taskExecutor, String patient, String diseaseId) {
        String sql = " select d.* from base_service_item_plan d,wlyy_patient_rehabilitation_plan p  where d.plan_id=p.id ";
        if(StringUtils.isNotBlank(patient)){
        if (StringUtils.isNotBlank(patient)) {
            sql += " and  d.patient = '" + patient + "' ";
        }else {
        } else {
            String[] planIdlist = planId.split(",");
            StringBuilder planCondition = new StringBuilder();
            planCondition.append("'" + planIdlist[0] + "'");
@ -712,7 +712,7 @@ public class RehabilitationManageService {
            }
            sql += " and  d.plan_id in (" + planCondition + " ) ";
        }
        if(StringUtils.isNotBlank(diseaseId)){
        if (StringUtils.isNotBlank(diseaseId)) {
            sql += " and  p.disease = '" + diseaseId + "' ";
        }
@ -735,11 +735,11 @@ public class RehabilitationManageService {
            sql += "and d.plan_time>='" + executeStartTime + "' and d.plan_time<='" + executeEndTime + " 23:59:59' ";
        }
        if (status != null) {
            sql += "and d.status='" + status+"' ";
            sql += "and d.status='" + status + "' ";
        }
        sql += "  order by d.plan_time desc ";
        List<ServiceItemPlanDO> rehabilitationDetailList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(ServiceItemPlanDO.class));
        List<ServiceItemPlanDO> rehabilitationDetailList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ServiceItemPlanDO.class));
//        if (rehabilitationDetailList.size() > 0 && null != searchTask) {
//            String patient = rehabilitationDetailList.get(0).getPatient();
//            if (7 == searchTask) { //处方续方 flag 用于判断 1.7.0.5 新增
@ -1337,49 +1337,49 @@ public class RehabilitationManageService {
    //获取其他执行计划
    public List<ServiceItemPlanDO> selectPlanDetailByPlan(String planId, String itemId, String searchTask) {
        String sql = "SELECT * from base_service_item_plan WHERE plan_id='"+planId+"' and relation_type='"+searchTask+"'" +
                " and status='0' and id<>'"+itemId+"' order by plan_time asc";
        return jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(ServiceItemPlanDO.class));
        String sql = "SELECT * from base_service_item_plan WHERE plan_id='" + planId + "' and relation_type='" + searchTask + "'" +
                " and status='0' and id<>'" + itemId + "' order by plan_time asc";
        return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ServiceItemPlanDO.class));
    }
    //康复计划服务项列表
    public List<RehabilitationDetailDO> rehabilitationDetailInfo(String planId,String status,String searchTask){
        String sql = "select * from wlyy_rehabilitation_plan_detail where plan_id='"+planId+"' ";
        if(StringUtils.isNotBlank(status)){
            sql += " and status="+status;
    public List<RehabilitationDetailDO> rehabilitationDetailInfo(String planId, String status, String searchTask) {
        String sql = "select * from wlyy_rehabilitation_plan_detail where plan_id='" + planId + "' ";
        if (StringUtils.isNotBlank(status)) {
            sql += " and status=" + status;
        }
        if(StringUtils.isNotBlank(searchTask)){
            sql += " and hospital_service_item_id='"+searchTask+"' ";
        if (StringUtils.isNotBlank(searchTask)) {
            sql += " and hospital_service_item_id='" + searchTask + "' ";
        }
        sql += " order by hospital_service_item_id";
        List<RehabilitationDetailDO> detailDOList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(RehabilitationDetailDO.class));
        List<RehabilitationDetailDO> detailDOList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(RehabilitationDetailDO.class));
        List<RehabilitationServiceItemDO> itemDOList = serviceItemDao.findList();
        Map<String, String> serviceItemMap = itemDOList.stream().collect(Collectors.toMap(RehabilitationServiceItemDO::getCode, RehabilitationServiceItemDO::getName));
        List<ServiceItemPlanDO> planDOList = serviceItemPlanDao.findByPlanId(planId);
        PatientRehabilitationPlanDO patientRehabilitationPlanDO = patientRehabilitationPlanDao.findById(planId).orElse(null);
        String patient = patientRehabilitationPlanDO.getPatient();
        Map<String,List<ServiceItemPlanDO>> planListMap = planDOList.stream().collect(Collectors.groupingBy(ServiceItemPlanDO::getRelationType));
        for (RehabilitationDetailDO detailDO:detailDOList){
        Map<String, List<ServiceItemPlanDO>> planListMap = planDOList.stream().collect(Collectors.groupingBy(ServiceItemPlanDO::getRelationType));
        for (RehabilitationDetailDO detailDO : detailDOList) {
            String key = detailDO.getHospitalServiceItemId();
            String doctor = detailDO.getDoctor();
            List<ServiceItemPlanDO> planDOS = planListMap.get(key);
            if(planDOS==null){
            if (planDOS == null) {
                planDOS = new ArrayList<>();
            }
            String completeTime = "";
            String planTime = "";
            int total = planDOS.size();
            int complete = 0;
            for (ServiceItemPlanDO planDO:planDOS){
                if("1".equals(planDO.getStatus())){
            for (ServiceItemPlanDO planDO : planDOS) {
                if ("1".equals(planDO.getStatus())) {
                    complete++;
                    if(completeTime.compareTo(planDO.getCompleteTime())<0){
                    if (completeTime.compareTo(planDO.getCompleteTime()) < 0) {
                        completeTime = planDO.getCompleteTime();
                    }
                }else {
                    if("".equals(planTime)){
                } else {
                    if ("".equals(planTime)) {
                        planTime = planDO.getPlanTime();
                    }else if(planTime.compareTo(planDO.getPlanTime())>0){
                    } else if (planTime.compareTo(planDO.getPlanTime()) > 0) {
                        planTime = planDO.getPlanTime();
                    }
                }
@ -1389,30 +1389,30 @@ public class RehabilitationManageService {
            detailDO.setCompleteTime(completeTime);
            detailDO.setPlanTime(planTime);
            detailDO.setName(serviceItemMap.get(key));
            if("2".equals(key)){
            if ("2".equals(key)) {
                //康复咨询
                String sqlTotal = "SELECT COUNT(*) from wlyy_consult_team WHERE patient='"+patient+"' and doctor='"+doctor+"' and type = '28' ";
                Integer signCount = jdbcTemplate.queryForObject(sqlTotal,Integer.class);
                String sqlTotal = "SELECT COUNT(*) from wlyy_consult_team WHERE patient='" + patient + "' and doctor='" + doctor + "' and type = '28' ";
                Integer signCount = jdbcTemplate.queryForObject(sqlTotal, Integer.class);
                detailDO.setFinishNum(signCount);
                if(signCount>0){
                    String sqlTemp = "select DATE_FORMAT(czrq, '%Y-%m-%d %H:%i:%s') czrq from wlyy_consult_team p where p.patient ='" + patient + "' and doctor='"+doctor+"' and " +
                if (signCount > 0) {
                    String sqlTemp = "select DATE_FORMAT(czrq, '%Y-%m-%d %H:%i:%s') czrq from wlyy_consult_team p where p.patient ='" + patient + "' and doctor='" + doctor + "' and " +
                            "type = '28' order by p.czrq desc limit 0,1 ";
                    List<Map<String,Object>> indexList = jdbcTemplate.queryForList(sqlTemp);
                    if(indexList.size()>0){
                        detailDO.setCompleteTime(indexList.get(0).get("czrq")+"");
                    List<Map<String, Object>> indexList = jdbcTemplate.queryForList(sqlTemp);
                    if (indexList.size() > 0) {
                        detailDO.setCompleteTime(indexList.get(0).get("czrq") + "");
                    }
                }
            }
            if("3".equals(key)){
            if ("3".equals(key)) {
                //健康监测
                String sqlTotal = "select count(*) as total from wlyy_patient_health_index p " +
                        "where p.user ='" + patient + "' and p.type IN(1,2) ";//and p.record_date >= '"+createTime+"'
                Integer signCount = jdbcTemplate.queryForObject(sqlTotal,Integer.class);
                Integer signCount = jdbcTemplate.queryForObject(sqlTotal, Integer.class);
                detailDO.setSignCount(signCount);
                if(signCount>0){
                if (signCount > 0) {
                    String sqlTemp = "select p.* from wlyy_patient_health_index p where p.user ='" + patient + "' and p.type IN(1,2) order by p.record_date desc limit 0,1 ";
                    List<DevicePatientHealthIndex> indexList = jdbcTemplate.query(sqlTemp,new BeanPropertyRowMapper<>(DevicePatientHealthIndex.class));
                    if(indexList.size()>0){
                    List<DevicePatientHealthIndex> indexList = jdbcTemplate.query(sqlTemp, new BeanPropertyRowMapper<>(DevicePatientHealthIndex.class));
                    if (indexList.size() > 0) {
                        DevicePatientHealthIndex index = indexList.get(0);
                        detailDO.setSignType(index.getType());
                        detailDO.setValue1(index.getValue1());
@ -1426,27 +1426,27 @@ public class RehabilitationManageService {
    }
    //电话关怀,状态更新成待补录
    public void updItemPlanStatus(String id,String doctor){
    public void updItemPlanStatus(String id, String doctor) {
        ServiceItemPlanDO planDO = serviceItemPlanDao.findById(id).orElse(null);
        if(!planDO.getDoctor().equals(doctor)){
        if (!planDO.getDoctor().equals(doctor)) {
            throw new ServiceException("不是您的任务,无法操作");
        }
        if("1".equals(planDO.getStatus())){
        if ("1".equals(planDO.getStatus())) {
            throw new ServiceException("任务已完成,请勿重复操作");
        }
        if("0".equals(planDO.getStatus())){
        if ("0".equals(planDO.getStatus())) {
            planDO.setStatus("2");
            serviceItemPlanDao.save(planDO);
        }
    }
    //确认完成服务,填写服务笔记
    public ServiceItemPlanDO completePlan(String id,String content,String appendixs,String doctor){
    public ServiceItemPlanDO completePlan(String id, String content, String appendixs, String doctor) {
        ServiceItemPlanDO planDO = serviceItemPlanDao.findById(id).orElse(null);
        if(!planDO.getDoctor().equals(doctor)){
        if (!planDO.getDoctor().equals(doctor)) {
            throw new ServiceException("不是您的任务,无法完成");
        }
        if("1".equals(planDO.getStatus())){
        if ("1".equals(planDO.getStatus())) {
            throw new ServiceException("请勿重复填写");
        }
        planDO.setAppendixs(appendixs);
@ -1455,18 +1455,28 @@ public class RehabilitationManageService {
        return planDO;
    }
    public ServiceItemPlanDO completePlan(ServiceItemPlanDO planDO){
    public ServiceItemPlanDO completePlan(ServiceItemPlanDO planDO) {
        planDO.setStatus("1");
        planDO.setCompleteTime(DateUtil.getStringDate());
        serviceItemPlanDao.save(planDO);
        updPlanStatus(planDO.getPlanId(),planDO.getPlanDetailId());
        updPlanStatus(planDO.getPlanId(), planDO.getPlanDetailId());
        return planDO;
    }
    /**
     * 进行中
     */
    public ServiceItemPlanDO planCarryOuting(ServiceItemPlanDO planDO) {
        planDO.setStatus("3");
        serviceItemPlanDao.save(planDO);
        return planDO;
    }
    //完成随访
    public ServiceItemPlanDO completePlanFollowup(Long followupId){
        ServiceItemPlanDO serviceItemPlanDO = serviceItemPlanDao.findByRelationCodeAndRelationType(followupId+"","6");
        if(serviceItemPlanDO!=null&&"0".equals(serviceItemPlanDO.getStatus())){
    public ServiceItemPlanDO completePlanFollowup(Long followupId) {
        ServiceItemPlanDO serviceItemPlanDO = serviceItemPlanDao.findByRelationCodeAndRelationType(followupId + "", "6");
        if (serviceItemPlanDO != null && "0".equals(serviceItemPlanDO.getStatus())) {
            serviceItemPlanDO = completePlan(serviceItemPlanDO);
        }
        return serviceItemPlanDO;
@ -1474,41 +1484,41 @@ public class RehabilitationManageService {
    //康复计划状态更新
    public void updPlanStatus(String planId,String planDetailId){
        List<ServiceItemPlanDO> itemPlanDOS =  serviceItemPlanDao.findByPlanDetailId(planDetailId,"0");
        if(itemPlanDOS.size()>0){
    public void updPlanStatus(String planId, String planDetailId) {
        List<ServiceItemPlanDO> itemPlanDOS = serviceItemPlanDao.findByPlanDetailId(planDetailId, "0");
        if (itemPlanDOS.size() > 0) {
            //服务项计划都完成了
            jdbcTemplate.update("update wlyy_rehabilitation_plan_detail set status=1 where id='"+planDetailId+"'");
            jdbcTemplate.update("update wlyy_rehabilitation_plan_detail set status=1 where id='" + planDetailId + "'");
            String sql = "SELECT COUNT(*) total,COUNT(if(`status`=1,1,null)) num from wlyy_rehabilitation_plan_detail  " +
                    "WHERE plan_id='"+planId+"'";
            List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
            String total = list.get(0).get("total")+"";
            String num = list.get(0).get("num")+"";
            if(total.equals(num)){
                jdbcTemplate.update("update wlyy_patient_rehabilitation_plan set status=2 where id='"+planId+"'");
                    "WHERE plan_id='" + planId + "'";
            List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
            String total = list.get(0).get("total") + "";
            String num = list.get(0).get("num") + "";
            if (total.equals(num)) {
                jdbcTemplate.update("update wlyy_patient_rehabilitation_plan set status=2 where id='" + planId + "'");
            }
        }
    }
    //执行计划详情
    public ServiceItemPlanDO findServiceItemPlanDetail(String id){
    public ServiceItemPlanDO findServiceItemPlanDetail(String id) {
        ServiceItemPlanDO planDO = serviceItemPlanDao.findById(id).orElse(null);
        if(planDO!=null){
            String sql = "SELECT content from wlyy_guidance_message_log WHERE plan_detail_id ='"+id+"' LIMIT 1";
            List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
            if(list.size()>0){
                planDO.setGuidanceMessage(list.get(0).get("content")+"");
        if (planDO != null) {
            String sql = "SELECT content from wlyy_guidance_message_log WHERE plan_detail_id ='" + id + "' LIMIT 1";
            List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
            if (list.size() > 0) {
                planDO.setGuidanceMessage(list.get(0).get("content") + "");
            }
        }
        String relationCode = planDO.getRelationCode();
        if("6".equals(planDO.getRelationType())&&StringUtils.isNotBlank(relationCode)){
        if ("6".equals(planDO.getRelationType()) && StringUtils.isNotBlank(relationCode)) {
            Followup followup = followupDao.findById(Long.parseLong(relationCode)).orElse(null);
            if(followup!=null){
            if (followup != null) {
                planDO.setFollowupStatus(followup.getStatus());
            }
        }
        PatientRehabilitationPlanDO rehabilitationPlanDO = patientRehabilitationPlanDao.findById(planDO.getPlanId()).orElse(null);
        if(rehabilitationPlanDO!=null){
        if (rehabilitationPlanDO != null) {
            planDO.setPlanDoctor(rehabilitationPlanDO.getPlanDoctor());
            planDO.setPlanDoctorName(rehabilitationPlanDO.getPlanDoctorName());
        }
@ -1516,21 +1526,21 @@ public class RehabilitationManageService {
    }
    //查询指导留言详情
    public GuidanceMessageLogDO findGuidanceMessageDetail(String itemPlanId){
        String sql = "SELECT * from wlyy_guidance_message_log WHERE plan_detail_id ='"+itemPlanId+"' LIMIT 1";
        List<GuidanceMessageLogDO> logDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(GuidanceMessageLogDO.class));
        if(logDOS.size()>0){
    public GuidanceMessageLogDO findGuidanceMessageDetail(String itemPlanId) {
        String sql = "SELECT * from wlyy_guidance_message_log WHERE plan_detail_id ='" + itemPlanId + "' LIMIT 1";
        List<GuidanceMessageLogDO> logDOS = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(GuidanceMessageLogDO.class));
        if (logDOS.size() > 0) {
            return logDOS.get(0);
        }
        return null;
    }
    //查询最新一条指导留言
    public GuidanceMessageLogDO findLastGuidanceMessage(String planId){
        String sql = "SELECT l.* from wlyy_guidance_message_log l,base_service_item_plan p WHERE p.plan_id ='"+planId+"'" +
    public GuidanceMessageLogDO findLastGuidanceMessage(String planId) {
        String sql = "SELECT l.* from wlyy_guidance_message_log l,base_service_item_plan p WHERE p.plan_id ='" + planId + "'" +
                " and l.plan_detail_id=p.id order by l.create_time desc LIMIT 1";
        List<GuidanceMessageLogDO> logDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(GuidanceMessageLogDO.class));
        if(logDOS.size()>0){
        List<GuidanceMessageLogDO> logDOS = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(GuidanceMessageLogDO.class));
        if (logDOS.size() > 0) {
            return logDOS.get(0);
        }
        return null;
@ -1544,14 +1554,14 @@ public class RehabilitationManageService {
     * @param doctorType 1、专科医生,2、计划负责人
     */
    @Transactional
    public Envelop saveGuidanceMessage(String messageId, String doctor, Integer doctorType, String content,String imgs,
    public Envelop saveGuidanceMessage(String messageId, String doctor, Integer doctorType, String content, String imgs,
                                       String planDetailId, Integer contentType) {
        GuidanceMessageLogDO guidanceMessageLogDO = null;
        List<GuidanceMessageLogDO> logDOS =  guidanceMessageLogDao.findByPlanDetailId(planDetailId);
        if(logDOS.size()>0){
        List<GuidanceMessageLogDO> logDOS = guidanceMessageLogDao.findByPlanDetailId(planDetailId);
        if (logDOS.size() > 0) {
            guidanceMessageLogDO = logDOS.get(0);
            guidanceMessageLogDO.setUpdateTime(new Date());
        }else {
        } else {
            guidanceMessageLogDO = new GuidanceMessageLogDO();
            guidanceMessageLogDO.setCreateTime(new Date());
            guidanceMessageLogDO.setUpdateTime(new Date());
@ -1568,7 +1578,7 @@ public class RehabilitationManageService {
//        guidanceMessageLogDO.setAdminTeamName(adminTeamName);
        guidanceMessageLogDO.setDoctorName(doctorDO.getName());
        guidanceMessageLogDO = guidanceMessageLogDao.save(guidanceMessageLogDO);
        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,guidanceMessageLogDO);
        return ObjEnvelop.getSuccess(SpecialistMapping.api_success, guidanceMessageLogDO);
    }
    /**
@ -1706,7 +1716,7 @@ public class RehabilitationManageService {
    public ObjEnvelop appCalendarPlanDetailList(String planId, Integer searchTask, Integer status, String executeStartTime, String executeEndTime) {
        Map<String, Object> resultMap = new HashMap<>();
        ObjEnvelop objEnvelop = calendarPlanDetailList(planId, searchTask, status, null, executeStartTime, executeEndTime, "0",null,null);
        ObjEnvelop objEnvelop = calendarPlanDetailList(planId, searchTask, status, null, executeStartTime, executeEndTime, "0", null, null);
        Integer finishCount = rehabilitationDetailDao.findByStatusAndPlanId(1, planId);
        Integer allCount = rehabilitationDetailDao.findAllByPlanId(planId);
        resultMap.put("planDetailList", objEnvelop.getObj());
@ -2768,7 +2778,7 @@ public class RehabilitationManageService {
        param.put("taskExecutor", taskExecutor);
        ObjEnvelop objEnvelop = calendarPlanDetailList(planIds.toString(), searchTask, status, doctorCode, executeStartTime, executeEndTime, taskExecutor,null,null);
        ObjEnvelop objEnvelop = calendarPlanDetailList(planIds.toString(), searchTask, status, doctorCode, executeStartTime, executeEndTime, taskExecutor, null, null);
        org.json.JSONObject result = new org.json.JSONObject(objEnvelop);
        if (result.getInt("status") == 200) {
@ -3024,4 +3034,14 @@ public class RehabilitationManageService {
        }
        return medicalRecordsDOS;
    }
    public void cancelPlan(String orderId) {
        String sql = "select id from base_service_item_plan where relation_code='" + orderId + "'";
        String itemId = jdbcTemplate.queryForObject(sql, String.class);
        String updateSql = "update base_service_item_plan q set q.status='0' where id='" + itemId + "'";
        jdbcTemplate.execute(updateSql);
        System.out.println("执行sql==>" + updateSql);
    }
}