Browse Source

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

Shi Kejing 4 years ago
parent
commit
8674400bac
77 changed files with 5613 additions and 491 deletions
  1. 16 0
      business/base-service/src/main/java/com/yihu/jw/dict/dao/PrivateDictDao.java
  2. 70 0
      business/base-service/src/main/java/com/yihu/jw/dict/service/PrivateDictService.java
  3. 3 0
      business/base-service/src/main/java/com/yihu/jw/hospital/drugstore/dao/BaseDrugStoreDao.java
  4. 2 0
      business/base-service/src/main/java/com/yihu/jw/hospital/family/service/WlyyFamilyMemberService.java
  5. 3 3
      business/base-service/src/main/java/com/yihu/jw/hospital/message/service/BaseBannerDoctorService.java
  6. 5 4
      business/base-service/src/main/java/com/yihu/jw/hospital/message/service/BaseUserMsgService.java
  7. 11 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/OauthCaConfigDao.java
  8. 5 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/OutpatientDao.java
  9. 285 18
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PayInfoNoticeService.java
  10. 1 1
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionExpressageService.java
  11. 284 30
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  12. 235 15
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/XzyyPrescriptionService.java
  13. 39 4
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/YkyyPrescriptionService.java
  14. 1 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/EntranceService.java
  15. 1546 18
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/XzzxEntranceService.java
  16. 47 16
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/YkyyEntranceService.java
  17. 58 43
      business/base-service/src/main/java/com/yihu/jw/internet/service/InternetCommonService.java
  18. 54 7
      business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java
  19. 279 68
      business/es-service/src/main/java/com/yihu/jw/es/service/StatisticsEsService.java
  20. 40 0
      business/es-service/src/main/java/com/yihu/jw/es/util/ElasticsearchUtil.java
  21. 79 22
      business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java
  22. 12 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/doctor/BaseDoctorDO.java
  23. 10 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/im/ConsultDo.java
  24. 18 0
      common/common-entity/src/main/java/com/yihu/jw/entity/ca/OauthCaConfigDO.java
  25. 91 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/dict/PrivateDictDO.java
  26. 27 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyPrescriptionDO.java
  27. 36 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyPrescriptionEmrDO.java
  28. 13 3
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/YkEmrJcsqDO.java
  29. 7 6
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/YkMsYj02DO.java
  30. 35 2
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java
  31. 61 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/doctor/CheckInfoVO.java
  32. 60 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/doctor/PersonInfoVO.java
  33. 9 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/prescription/WlyyPrescriptionVO.java
  34. 1 1
      gateway/ag-basic/src/main/resources/application.yml
  35. 1 1
      gateway/ag-basic/src/main/resources/bootstrap.yml
  36. 4 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/dao/doctor/BaseDoctorDao.java
  37. 45 8
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  38. 3 1
      server/svr-authentication/src/main/java/com/yihu/jw/security/service/OauthCaConfigSerivce.java
  39. 161 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/service/XzzxService.java
  40. 26 1
      server/svr-authentication/src/main/resources/application.yml
  41. 1 1
      server/svr-authentication/src/main/resources/bootstrap.yml
  42. 4 4
      svr/svr-base/src/main/resources/application.yml
  43. 1 1
      svr/svr-base/src/main/resources/bootstrap.yml
  44. 0 13
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/interceptor/ActivatedInterceptor.java
  45. 311 3
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/XzzxCotroller.java
  46. 11 6
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/YkyyController.java
  47. 4 0
      svr/svr-internet-hospital-entrance/src/main/resources/application.yml
  48. 8 1
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/job/CommonDataUploadJob.java
  49. 476 39
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/PrescriptionStatusUpdateService.java
  50. 177 0
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/TimeoutOverDueService.java
  51. 4 1
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/UnSettledHISPrescriptionService.java
  52. 63 0
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/util/TimeoutOverDueJob.java
  53. 42 11
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/web/quota/JobController.java
  54. 2 1
      svr/svr-internet-hospital-job/src/main/resources/application.yml
  55. 82 47
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java
  56. 12 5
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/PatientConsultEndpoint.java
  57. 63 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/dict/PrivateDictEndpoint.java
  58. 6 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/file_upload/FileUploadEndpoint.java
  59. 14 5
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/hospital/BaseDoctorBGController.java
  60. 63 13
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java
  61. 207 17
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java
  62. 12 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/YkyyPrescriptionEndpoint.java
  63. 142 7
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/statistics/EsStatisticsEndpoint.java
  64. 39 2
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/analysis/AnalysisService.java
  65. 6 5
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/consult/KnowledgeArticleService.java
  66. 8 5
      svr/svr-internet-hospital/src/main/resources/application.yml
  67. 1 1
      svr/svr-iot-job/src/main/resources/application.yml
  68. 44 4
      svr/svr-iot/src/main/java/com/yihu/iot/controller/monitorPlatform/MonitorPlatformController.java
  69. 45 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/monitorPlatform/MonitorPlatformService.java
  70. 3 3
      svr/svr-iot/src/main/resources/application.yml
  71. 1 1
      svr/svr-iot/src/main/resources/bootstrap.yml
  72. 12 8
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/rehabilitation/RehabilitationManageController.java
  73. 20 6
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/rehabilitation/RehabilitationPlanController.java
  74. 4 0
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/rehabilitation/RehabilitationDetailDao.java
  75. 6 2
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/SpecialistScreenResultService.java
  76. 32 6
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/rehabilitation/RehabilitationManageService.java
  77. 4 0
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/rehabilitation/RehabilitationPlanService.java

+ 16 - 0
business/base-service/src/main/java/com/yihu/jw/dict/dao/PrivateDictDao.java

@ -0,0 +1,16 @@
package com.yihu.jw.dict.dao;
import com.yihu.jw.entity.hospital.dict.PrivateDictDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface PrivateDictDao extends PagingAndSortingRepository<PrivateDictDO, String>, JpaSpecificationExecutor<PrivateDictDO> {
    @Query("from PrivateDictDO t where t.hospitalCode =?1 and t.dictCode= ?2 and t.isDel = 1")
    List<PrivateDictDO> findoneByCodeAndWechatId(String hospitalCode, String dictCode);
    @Query("from PrivateDictDO t where t.isDel = 1")
    List<PrivateDictDO> findALL();
}

+ 70 - 0
business/base-service/src/main/java/com/yihu/jw/dict/service/PrivateDictService.java

@ -0,0 +1,70 @@
package com.yihu.jw.dict.service;
import com.yihu.jw.dict.dao.PrivateDictDao;
import com.yihu.jw.entity.hospital.dict.PrivateDictDO;
import com.yihu.jw.entity.hospital.message.BaseBannerDO;
import com.yihu.jw.hospital.message.dao.BaseBannerDao;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class PrivateDictService extends BaseJpaService<PrivateDictDO, PrivateDictDao> {
    @Autowired
    private PrivateDictDao privateDictDao;
    @Autowired
    private HibenateUtils hibenateUtils;
    //查找隐私策略
    public List<PrivateDictDO> findByHospitalCodeAndDictCode(String hospitalCode,String dictCode){
        if (StringUtils.isNotBlank(hospitalCode)&&StringUtils.isNotBlank(dictCode)){
            return privateDictDao.findoneByCodeAndWechatId(hospitalCode,dictCode);
        }else {
            return privateDictDao.findALL();
        }
    }
    //添加隐私策略
    public MixEnvelop addPrivateDict(String id,String dictCode,String dictName, String dictValue,String hospitalCode,String hospitalName,String imgUrl){
        PrivateDictDO  privateDictDO = new PrivateDictDO();
        MixEnvelop mixEnvelop = new MixEnvelop();
        if (StringUtils.isNotBlank(id)){
            privateDictDO = privateDictDao.findOne(id);
        }
        if (StringUtils.isNotBlank(dictCode)){
            privateDictDO.setDictCode(dictCode);
            privateDictDO.setDictValue(dictValue);
            privateDictDO.setDictName(dictName);
            privateDictDO.setIsDel(1);
            privateDictDO.setHospitalCode(hospitalCode);
            privateDictDO.setHospitalName(hospitalName);
            privateDictDO.setImgUrl(imgUrl);
            privateDictDao.save(privateDictDO);
            mixEnvelop.setMessage("success");
            mixEnvelop.setStatus(200);
        }else{
            mixEnvelop.setMessage("隐私政策code不能为空");
            mixEnvelop.setStatus(-1);
        }
        return mixEnvelop;
    }
    //删除隐私政策
    public MixEnvelop deleteById(String id){
        PrivateDictDO  privateDictDO = privateDictDao.findOne(id);
        MixEnvelop mixEnvelop = new MixEnvelop();
        if (null!=privateDictDO){
            privateDictDao.delete(id);
            mixEnvelop.setStatus(200);
            mixEnvelop.setMessage("删除成功");
        }else {
            mixEnvelop.setStatus(-1);
            mixEnvelop.setMessage("删除失败");
        }
        return mixEnvelop;
    }
}

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

@ -15,5 +15,8 @@ public interface BaseDrugStoreDao extends PagingAndSortingRepository<BaseDrugSto
    @Query(value = " from  BaseDrugStoreDO  where drugStoreCode =?1 and hospitalCode = ?2 ")
    BaseDrugStoreDO findDrugByNameAndCode(String drugStoreCode,String hospitalCode);
    @Query(value = " from  BaseDrugStoreDO  where id =?1 ")
    BaseDrugStoreDO findDrugByid(String drugStoreCode);
}

+ 2 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/family/service/WlyyFamilyMemberService.java

@ -115,6 +115,8 @@ public class WlyyFamilyMemberService extends BaseJpaService<WlyyPatientFamilyMem
                result.setFamilyMember(patientNewId);
                wlyyPatientFamilyMemberDao.save(result);
                patientMappingDO.setIdcard(idCard);
                patientMappingDO.setSource("1");
                patientMappingDO.setPatientName(familyName);
                patientMappingDO.setMappingCode(familyId);
                patientMappingDO.setPatient(patientNewId);
                patientMappingDO.setCreateTime(new Date());

+ 3 - 3
business/base-service/src/main/java/com/yihu/jw/hospital/message/service/BaseBannerDoctorService.java

@ -273,7 +273,7 @@ public class BaseBannerDoctorService
        List<BaseBannerDoctorDO> baseBannerDoctorDOS = this.baseBannerDoctorDao.getBannersBypatients(patientId, doctor);
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = this.wlyyHospitalSysDictDao.findById("banner_give_timeout");
        if (null != baseBannerDoctorDOS&&baseBannerDoctorDOS.size()>0)
        if (null != baseBannerDoctorDOS&&baseBannerDoctorDOS.size()>0&&baseBannerDoctorDOS.size()>=1)
        {
            BaseBannerDoctorDO lastOne = (BaseBannerDoctorDO)baseBannerDoctorDOS.get(0);
            Date lastDate = lastOne.getCreateTime();
@ -372,9 +372,9 @@ public class BaseBannerDoctorService
    {
        List<BaseUserMessageDO> baseBannerDoctorDOS = this.baseUserMessageDao.getMessageByPatientAndDoctor(reciver, sender);
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = this.wlyyHospitalSysDictDao.findById("leave_message_timeout");
        if (null != baseBannerDoctorDOS)
        if (null != baseBannerDoctorDOS&&baseBannerDoctorDOS.size()>=1)
        {
            BaseUserMessageDO lastOne = (BaseUserMessageDO)baseBannerDoctorDOS.get(0);
            BaseUserMessageDO lastOne = baseBannerDoctorDOS.get(0);
            Date lastDate = lastOne.getCreateTime();
            long timeOut = wlyyHospitalSysDictDO.getDictValue() != null ? Long.valueOf(wlyyHospitalSysDictDO.getDictValue()).longValue() : 5L;
            Date current = new Date();

+ 5 - 4
business/base-service/src/main/java/com/yihu/jw/hospital/message/service/BaseUserMsgService.java

@ -236,12 +236,12 @@ public class BaseUserMsgService extends BaseJpaService<BaseUserMessageDO, BaseUs
            //sql.append(" and t.update_time < '" + endTime+"'");//DateUtil.stringToDate(endTime,"yyyy-MM-dd HH:mm:ss")
            if ("xm_ykyy_wx".equals(wxId)) {
                if (flag){
                    sql.append( " and t.update_time <= str_to_date('" + endTime + " 00:00:00','YYYY-MM-DD HH24:MI:SS')");
                    sql.append( " and t.update_time <= str_to_date('" + endTime + " 23:59:59','YYYY-MM-DD HH24:MI:SS')");
                }else {
                    sql.append(  " and t.update_time <= to_date('" + endTime + " 00:00:00','YYYY-MM-DD HH24:MI:SS')");
                    sql.append(  " and t.update_time <= to_date('" + endTime + " 23:59:59','YYYY-MM-DD HH24:MI:SS')");
                }
            } else {
                sql.append( " AND t.update_time <='" + endTime + " 00:00:00'");
                sql.append( " AND t.update_time <='" + endTime + " 23:59:59'");
            }
        }
        sql.append(" ORDER BY t.update_time Desc");
@ -476,7 +476,7 @@ public class BaseUserMsgService extends BaseJpaService<BaseUserMessageDO, BaseUs
{
    List<BaseUserMessageDO> baseBannerDoctorDOS = this.baseUserMessageDao.getMessageByPatientAndDoctor(reciver, sender);
    WlyyHospitalSysDictDO wlyyHospitalSysDictDO = this.wlyyHospitalSysDictDao.findById("leave_message_timeout");
    if (null != baseBannerDoctorDOS)
    if (null != baseBannerDoctorDOS&&baseBannerDoctorDOS.size()>=1)
    {
        BaseUserMessageDO lastOne = (BaseUserMessageDO)baseBannerDoctorDOS.get(0);
        Date lastDate = lastOne.getCreateTime();
@ -526,4 +526,5 @@ public class BaseUserMsgService extends BaseJpaService<BaseUserMessageDO, BaseUs
        }
        return true;
    }
}

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

@ -0,0 +1,11 @@
package com.yihu.jw.hospital.prescription.dao;
import com.yihu.jw.entity.ca.OauthCaConfigDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2019/12/25.
 */
public interface OauthCaConfigDao extends PagingAndSortingRepository<OauthCaConfigDO, String>, JpaSpecificationExecutor<OauthCaConfigDO> {
}

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

@ -18,6 +18,9 @@ public interface OutpatientDao extends PagingAndSortingRepository<WlyyOutpatient
    @Query("from WlyyOutpatientDO a where a.patient = ?1 and a.status in(0,1)")
    List<WlyyOutpatientDO> findByPatientList(String patient);
    @Query("from WlyyOutpatientDO a where a.patient = ?1 and a.status in(3) order by a.createTime desc ")
    List<WlyyOutpatientDO> findByPatientListByStatus(String patient);
    @Query("from WlyyOutpatientDO a where a.patient = ?1 and a.hisStatus=1 and a.createTime>=?2 and a.createTime<=?3")
    List<WlyyOutpatientDO> findByPatientListNoStatus(String patient,Date startDate,Date endDate);
@ -53,6 +56,8 @@ public interface OutpatientDao extends PagingAndSortingRepository<WlyyOutpatient
    Integer countByTime(String type,String doctor,Date startTime,Date endTime);
    @Query("from WlyyOutpatientDO a where a.status = 0 and a.payStatus = 1 and (a.remindCount<?1 or a.remindCount is null)")
    List<WlyyOutpatientDO> findWaitingOutpatient(Integer remindCount);
    @Query("from WlyyOutpatientDO a where a.status = 0")
    List<WlyyOutpatientDO> findAllWaitingOutpatient();
    /*@Query("from WlyyOutpatientDO a where a.patient = ?1 and a.outpatientType = 1")
    List<WlyyOutpatientDO> findOutpatientByPatientAndStatus(String patient);*/

+ 285 - 18
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PayInfoNoticeService.java

@ -6,16 +6,22 @@ import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import jxl.WorkbookSettings;
import jxl.write.*;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Date;
import java.util.Map;
import java.util.*;
@Service
public class PayInfoNoticeService {
@ -25,7 +31,15 @@ public class PayInfoNoticeService {
    private HttpClientUtil httpClientUtil;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private HibenateUtils hibenateUtils;
    @Value("${wechat.id}")
    private String wxId;
    @Value("${wechat.flag}")
    private boolean flag;
    public String pushPrescriptionPay(String patient,String doctorName,String orderNo,String outpatientId,String prescriptionId,String total,String title,String url){
        BasePatientDO patientDO = patientDao.findById(patient);
@ -85,37 +99,53 @@ public class PayInfoNoticeService {
    }
    //导出es查询数据
    public void exportEsPrescription(OutputStream os, com.alibaba.fastjson.JSONObject jsonObject) throws Exception{
        WritableWorkbook wwb = jxl.Workbook.createWorkbook(os);
        //接诊 +开方+物流
        com.alibaba.fastjson.JSONArray totallist = new JSONArray();
        if (null!=jsonObject){
            totallist = jsonObject.getJSONArray("outpatient");
        }
    public void exportEsPrescription(OutputStream os, List<Map<String,Object>> totallist,List<Map<String,Object>> listDay) throws Exception{
        WorkbookSettings settings = new WorkbookSettings();
        settings.setWriteAccess(null);
        settings.setEncoding("UTF-8");
        WritableWorkbook wwb = jxl.Workbook.createWorkbook(os,settings);
        try {
            WritableSheet ws;
            ws = wwb.createSheet("sheet", 1);
            String[] header = {"医生姓名", "出诊科室", "接诊数量", "开方数量", "物流数量"};
            int k = 0;
            WritableSheet ws2 = wwb.createSheet("sheet2", 2);
            String[] header = {"医生姓名", "出诊科室","发起问诊", "接诊数量", "开方数量", "物流数量"};
            String[] header2 = {"时间", "发起问诊", "接诊数量", "开方数量", "物流数量"};
        int k = 0;
        int m =0;
            for (String h : header) {
                addCell(ws, 0, k, h);//表名,行,列,header
                k++;
            }
            for (String h : header2) {
                addCell(ws2, 0, m, h);//表名,行,列,header
                m++;
            }
            int i = 1;
            if (null!=totallist&&totallist.size()>0){
                for (int n=0;n<totallist.size();n++) {
                    JSONObject object = totallist.getJSONObject(i);
                    Map<String,Object> object = totallist.get(n);
                    addCell(ws, i, 0, object.get("doctorName").toString(), "");
                    addCell(ws, i, 1, null==object.get("dept")?"":object.get("dept").toString(),"");
                    addCell(ws, i, 1, null==object.get("out")?"":object.get("out").toString(),"");
                    addCell(ws, i, 1, null==object.get("pre")?"":object.get("pre").toString(),"");
                    addCell(ws, i, 1, null==object.get("sf")?"":object.get("sf").toString(),"");
                    addCell(ws, i, 1, null==object.get("deptName")?"":object.get("deptName").toString(),"");
                    addCell(ws, i, 2, null==object.get("total")?"":object.get("total").toString(),"");
                    addCell(ws, i, 3, null==object.get("pickNum")?"":object.get("pickNum").toString(),"");
                    addCell(ws, i, 4, null==object.get("preNum")?"":object.get("preNum").toString(),"");
                    addCell(ws, i, 5, null==object.get("wlNum")?"":object.get("wlNum").toString(),"");
                    i++;
                }
            }
            int j =1;
            if (null!=listDay&&listDay.size()>0){
                for (int n=0;n<listDay.size();n++){
                    Map<String,Object> object = listDay.get(n);
                    addCell(ws2, j, 0, object.get("daliy").toString(), "");
                    addCell(ws2, j, 1, null==object.get("total")?"":object.get("total").toString(),"");
                    addCell(ws2, j, 2, null==object.get("pickNum")?"":object.get("pickNum").toString(),"");
                    addCell(ws2, j, 3, null==object.get("preNum")?"":object.get("preNum").toString(),"");
                    addCell(ws2, j, 4, null==object.get("wlNum")?"":object.get("wlNum").toString(),"");
                    j++;
                }
            }
            wwb.write();
            wwb.close();
        } catch (IOException e) {
@ -140,5 +170,242 @@ public class PayInfoNoticeService {
        }
        ws.addCell(label);
    }
    public List<Map<String,Object>> dealSqlQuery(String beginTime,String endTime){
        //发起问诊量
        String sqlOutPatient="SELECT\n" +
                "\tt.doctor as \"doctor\",\n" +
                "\tt.doctor_name as \"doctorName\",\n" +
                "\tt.dept_name as \"deptName\",\n" +
                "\tcount(*) as \"total\" \n" +
                "FROM\n" +
                "\t wlyy_outpatient t \n" +
                "WHERE 1=1 and t.doctor is not null\n " +
                " AND t.doctor!='402803816babc778016babd0dee21112'" ;
        //接诊量
        String sqlDoctorOut = "SELECT\n" +
                "\tt.doctor as \"doctor\",\n" +
                "\tt.doctor_name as \"doctorName\",\n" +
                "\tt.dept_name as \"deptName\",\n" +
                "\tcount(*) as \"total\" \n" +
                "FROM\n" +
                "\t wlyy_outpatient t \n" +
                "WHERE 1=1 and t.doctor is not null\n" +
                " AND t.doctor!='402803816babc778016babd0dee21112'";
        //开具处方量
        String sqlPrescription = "SELECT\n" +
                "\tt.doctor as \"doctor\",\n" +
                "\tt.doctor_name as \"doctorName\",\n" +
                "\tt.dept_name as \"deptName\",\n" +
                "\tcount(*) as \"total\" \n" +
                "FROM\n" +
                "\t wlyy_prescription t \n" +
                "WHERE 1=1 and t.doctor is not null\n" +
                " AND t.doctor!='402803816babc778016babd0dee21112'" ;
        //物流量
        String sqlWL = "SELECT\n" +
                "\to.doctor as \"doctor\",\n" +
                " o.doctor_name as \"doctorName\",\n" +
                " o.dept_name as \"deptName\",\n" +
                " count(*) as \"total\"" +
                "FROM\n" +
                " base.wlyy_prescription_expressage t\n" +
                "LEFT JOIN base.wlyy_prescription b ON b.outpatient_id = t.outpatient_id\n" +
                "LEFT JOIN base.wlyy_outpatient o ON o.id= b.outpatient_id\n" +
                "WHERE 1=1 and o.doctor is not null\n" +
                " AND o.doctor!='402803816babc778016babd0dee21112'" ;
        if (StringUtils.isNotEmpty(beginTime)){
            wxId="xx";
            if("xm_ykyy_wx".equals(wxId)){
                if (flag){
                    sqlOutPatient+=" and t.create_time > '" + beginTime + " 00:00:00' ";
                    sqlDoctorOut+=" and t.create_time > '" + beginTime + " 00:00:00' ";
                    sqlPrescription+=" and t.create_time > '" + beginTime + " 00:00:00' ";
                    sqlWL+=" and t.create_time > '" + beginTime + " 00:00:00' ";
                }else {
                    sqlOutPatient+=" and t.create_time > to_date('" + beginTime + " 00:00:00', 'yyyy-mm-dd hh24:mi:ss') ";
                    sqlDoctorOut+=" and t.create_time > to_date('" + beginTime + " 00:00:00', 'yyyy-mm-dd hh24:mi:ss') ";
                    sqlPrescription+=" and t.create_time > to_date('" + beginTime + " 00:00:00', 'yyyy-mm-dd hh24:mi:ss') ";
                    sqlWL+=" and t.create_time > to_date('" + beginTime + " 00:00:00', 'yyyy-mm-dd hh24:mi:ss') ";
                }
            }else{
                sqlOutPatient+=" and t.create_time > '" + beginTime + " 00:00:00'";
                sqlDoctorOut+=" and t.create_time > '" + beginTime + " 00:00:00'";
                sqlPrescription+=" and t.create_time > '" + beginTime + " 00:00:00'";
                sqlWL+=" and t.create_time > '" + beginTime + " 00:00:00'";
            }
        }
        if (StringUtils.isNotEmpty(endTime)){
            if("xm_ykyy_wx".equals(wxId)){
                if (flag){
                    sqlOutPatient+="  and t.create_time<'" + endTime + " 23:59:59'";
                    sqlDoctorOut+="  and t.create_time<'" + endTime + " 23:59:59'";
                    sqlPrescription+="  and t.create_time<'" + endTime + " 23:59:59'";
                    sqlWL+="  and t.create_time<'" + endTime + " 23:59:59'";
                }else {
                    sqlOutPatient+="  and t.create_time< to_date('" + endTime + " 23:59:59','yyyy-mm-dd hh24:mi:ss')";
                    sqlDoctorOut+="  and t.create_time< to_date('" + endTime + " 23:59:59','yyyy-mm-dd hh24:mi:ss')";
                    sqlPrescription+="  and t.create_time< to_date('" + endTime + " 23:59:59','yyyy-mm-dd hh24:mi:ss')";
                    sqlWL+="  and t.create_time< to_date('" + endTime + " 23:59:59','yyyy-mm-dd hh24:mi:ss')";
                }
            }else{
                sqlOutPatient+="  and t.create_time<'" + endTime + " 23:59:59'";
                sqlDoctorOut+="  and t.create_time<'" + endTime + " 23:59:59'";
                sqlPrescription+="  and t.create_time<'" + endTime + " 23:59:59'";
                sqlWL+="  and t.create_time<'" + endTime + " 23:59:59'";
            }
        }
        sqlOutPatient+="\tAND t.patient_name NOT IN ( '王志南', '游水连', '林志芳', '郑绩', '陈晓亮', '王培坤' ) \n" +
                "\tAND t.STATUS IN ( 0,1,2,3 )\n" +
                "\tGROUP BY t.doctor_name,\n" +
                "\tt.dept_name,t.doctor";
        sqlDoctorOut+= "\tAND t.patient_name NOT IN ( '王志南', '游水连', '林志芳', '郑绩', '陈晓亮', '王培坤' ) \n" +
                "\tAND t.STATUS IN ( 1, 2, 3 )\n" +
                " and t.pay_status =1 "+
                "\tGROUP BY t.doctor_name,\n" +
                "\tt.dept_name ,t.doctor";
        sqlPrescription+="\tAND t.patient_name NOT IN ( '王志南', '游水连', '林志芳', '郑绩', '陈晓亮', '王培坤' ) \n" +
                "\tGROUP BY t.doctor_name,\n" +
                "\tt.dept_name,t.doctor";
        sqlWL+= "AND t. NAME NOT IN (\n" +
                " '王志南',\n" +
                " '游水连',\n" +
                " '林志芳',\n" +
                " '郑绩',\n" +
                " '陈晓亮',\n" +
                " '王培坤',\n" +
                " '林'\n" +
                ")\n" +
                "AND t.oneself_pickup_flg = 0\n" +
                "\n" +
                "AND b.`status`IN(20,32,100)\n" +
                "AND b.drug_fee !=0\n" +
                "AND b.real_order IS not NULL"+
                "\tGROUP BY o.doctor_name,\n" +
                "\to.dept_name,o.doctor";
        List<Map<String,Object>> result = new ArrayList<>();
        List<Map<String,Object>> outPatient=hibenateUtils.createSQLQuery(sqlOutPatient);
        List<Map<String,Object>> docPickup=hibenateUtils.createSQLQuery(sqlDoctorOut);
        List<Map<String,Object>> prescription=hibenateUtils.createSQLQuery(sqlPrescription);
        List<Map<String,Object>> wl=hibenateUtils.createSQLQuery(sqlWL);
        if(null!=outPatient&&outPatient.size()>0){
            for (Map<String,Object> map:outPatient){
                if (docPickup!=null&&docPickup.size()>0){
                    for (Map<String,Object> pickMap:docPickup){
                        if (pickMap.get("doctor").toString().equalsIgnoreCase(map.get("doctor").toString())){
                            map.put("pickNum",null==pickMap.get("total")?"":pickMap.get("total").toString());
                        }
                    }
                }
                if (prescription!=null&&prescription.size()>0){
                    for (Map<String,Object> pre:prescription){
                        if (pre.get("doctor").toString().equalsIgnoreCase(map.get("doctor").toString())){
                            map.put("preNum",null==pre.get("total")?"":pre.get("total").toString());
                        }
                    }
                }
                if (wl!=null&&wl.size()>0){
                    for (Map<String,Object> wMap:wl){
                        if (wMap.get("doctor").toString().equalsIgnoreCase(map.get("doctor").toString())){
                            map.put("wlNum",null==wMap.get("total")?"":wMap.get("total").toString());
                        }
                    }
                }
                result.add(map);
            }
        }
     return result;
    }
    //按天分组查询
    public List<Map<String,Object>> dealSqlQueryGroupDay(String beginTime,String endTime){
        String sqlDemo = "SELECT\n" +
                "\tdate_format( t.create_time, '%Y-%m-%d' ) as \"daliy\",\n" +
                "\tcount( * ) as \"total\" \n" +
                "FROM\n" ;
        //发起复诊量
        String outPatinet =sqlDemo+ "\twlyy_outpatient t where 1=1 AND t.doctor!='402803816babc778016babd0dee21112' and " +
                "t.STATUS IN ( 0,1,2,3 )";
        //接诊
        String outPick  =sqlDemo+  "\twlyy_outpatient t where 1=1 AND t.doctor!='402803816babc778016babd0dee21112' " +
                " and t.STATUS IN (1,2,3) and t.doctor is not null ";
        //处方
        String pre = sqlDemo+"\twlyy_prescription t where 1=1 AND t.doctor!='402803816babc778016babd0dee21112'";
        //物流
        String wl =sqlDemo+" base.wlyy_prescription_expressage t\n" +
                "LEFT JOIN base.wlyy_prescription b ON b.outpatient_id = t.outpatient_id\n" +
                "LEFT JOIN base.wlyy_outpatient o ON o.id= b.outpatient_id\n" +
                "WHERE t.oneself_pickup_flg = 0\n" +
                "AND b.`status`IN(20,32,100)\n" +
                "AND b.drug_fee !=0\n" +
                "AND b.real_order IS not NULL" +
                " AND o.doctor!='402803816babc778016babd0dee21112'";
        String deltime = "";
        if (StringUtils.isNotEmpty(beginTime)){
            wxId="xx";
            if("xm_ykyy_wx".equals(wxId)){
                if (flag){
                    deltime+=" and t.create_time > '" + beginTime + " 00:00:00' ";
                }else {
                    deltime+=" and t.create_time > to_date('" + beginTime + " 00:00:00', 'yyyy-mm-dd hh24:mi:ss') ";
                }
            }else{
                deltime+=" and t.create_time > '" + beginTime + " 00:00:00'";
            }
        }
        if (StringUtils.isNotEmpty(endTime)){
            if("xm_ykyy_wx".equals(wxId)){
                if (flag){
                    deltime+="  and t.create_time<'" + endTime + " 23:59:59'";
                }else {
                    deltime+="  and t.create_time< to_date('" + endTime + " 23:59:59','yyyy-mm-dd hh24:mi:ss')";
                }
            }else{
                deltime+="  and t.create_time<'" + endTime + " 23:59:59'";
            }
        }
        deltime+=" group by date_format(t.create_time, '%Y-%m-%d');";
        outPatinet+=deltime;
        outPick +=deltime;
        pre +=deltime;
        wl+=deltime;
        List<Map<String,Object>> result = new ArrayList<>();
        List<Map<String,Object>> outPatient=hibenateUtils.createSQLQuery(outPatinet);
        List<Map<String,Object>> docPickup=hibenateUtils.createSQLQuery(outPick);
        List<Map<String,Object>> prescription=hibenateUtils.createSQLQuery(pre);
        List<Map<String,Object>> wls=hibenateUtils.createSQLQuery(wl);
        if(null!=outPatient&&outPatient.size()>0){
            for (Map<String,Object> map:outPatient){
                if (docPickup!=null&&docPickup.size()>0){
                    for (Map<String,Object> pickMap:docPickup){
                        if (pickMap.get("daliy").toString().equalsIgnoreCase(map.get("daliy").toString())){
                            map.put("pickNum",null==pickMap.get("total")?"":pickMap.get("total").toString());
                        }
                    }
                }
                if (prescription!=null&&prescription.size()>0){
                    for (Map<String,Object> preMap:prescription){
                        if (preMap.get("daliy").toString().equalsIgnoreCase(map.get("daliy").toString())){
                            map.put("preNum",null==preMap.get("total")?"":preMap.get("total").toString());
                        }
                    }
                }
                if (wl!=null&&wls.size()>0){
                    for (Map<String,Object> wMap:wls){
                        if (wMap.get("daliy").toString().equalsIgnoreCase(map.get("daliy").toString())){
                            map.put("wlNum",null==wMap.get("total")?"":wMap.get("total").toString());
                        }
                    }
                }
                result.add(map);
            }
        }
        return result;
    }
}

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

@ -571,7 +571,7 @@ public class PrescriptionExpressageService extends BaseJpaService<WlyyPrescripti
            for (WlyyPrescriptionExpressageLogDO pushlog: pushSFLogs) {
                //判断是否有已收件的路由节点
                if("80".equals(pushlog.getOpCode())){
                if("80".equals(pushlog.getOpCode())||"8000".equals(pushlog.getOpCode())){
                    isContainEndRoutInfo = true;
                }

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

@ -118,6 +118,7 @@ import java.math.BigDecimal;
import java.net.URL;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@ -140,8 +141,6 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    @Autowired
    private PrescriptionDao prescriptionDao;
    @Autowired
    private PrescriptionDiagnosisDao prescriptionDiagnosisDao;
    @Autowired
    private PrescriptionExpressageDao prescriptionExpressageDao;
    @Autowired
    private PrescriptionInfoDao prescriptionInfoDao;
@ -258,6 +257,10 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    private PrescriptionSignDao prescriptionSignDao;
    @Autowired
    private EnterpriseService enterpriseService;
    @Autowired
    private PrescriptionDiagnosisDao  prescriptionDiagnosisDao;
    @Autowired
    private XzyyPrescriptionService xzyyPrescriptionService;
@ -521,7 +524,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        rs.put("address", basePatientDO.getAddress());
        rs.put("mobile", basePatientDO.getMobile());
        rs.put("birthday", DateUtil.dateToStr(basePatientDO.getBirthday(), "yyyy-MM-dd"));
        String hisPatient="";
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(basePatientDO.getId());
        if(null!=patientMappingDO){
            hisPatient = patientMappingDO.getMappingCode();
        }
        rs.put("hisPatient",hisPatient);
        Long time = new Date().getTime() - outpatientDO.getCreateTime().getTime();
        rs.put("time", time);
@ -533,16 +541,24 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            prescriptionDOs = prescriptionDao.findByOutpatientId(outpatientId);
        }
        List<WlyyPrescriptionVO> prescriptionVOs = new ArrayList<>();
        List<BusinessOrderDO> businessOrders = new ArrayList<>();
        BusinessOrderDO businessOrder = new BusinessOrderDO();
        if (prescriptionDOs != null && prescriptionDOs.size() > 0) {
            convertToModels(prescriptionDOs, prescriptionVOs, WlyyPrescriptionVO.class);
            for (WlyyPrescriptionVO vo : prescriptionVOs) {
                List<WlyyPrescriptionCheckDO> prescriptionCheckDO = prescriptionCheckDao.findByPrescriptionId(vo.getId());
                //疾病信息
                vo.setDiagnosisVOs(findDiagnosisById(vo.getId()));
                if(null!=prescriptionCheckDO&&prescriptionCheckDO.size()>0){
                    vo.setDispUser(prescriptionCheckDO.get(0).getOperate());
                    vo.setDispUserName(prescriptionCheckDO.get(0).getOperateName());
                }
                //药品信息
                List<WlyyPrescriptionInfoVO> infoVOs = new ArrayList<>();
                vo.setInfoVOs(convertToModels(prescriptionInfoDao.findByPrescriptionId(vo.getId(), 1), infoVOs, WlyyPrescriptionInfoVO.class));
                System.out.println("=====PrescriptionId======"+vo.getId());
                convertToModels(prescriptionInfoDao.findByPrescriptionId(vo.getId(), 1), infoVOs, WlyyPrescriptionInfoVO.class);
                vo.setInfoVOs(infoVOs);
                //检查检验信息
                List<WlyyInspectionVO> inspectionVOs = new ArrayList<>();
@ -558,10 +574,16 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                        vo.setWlyyPrescriptionEmrDO(wlyyPrescriptionEmrDO);
                    }
                }
                //支付信息
                BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(vo.getId());
                if (null!=businessOrderDO){
                    businessOrders.add(businessOrderDO);
                }
            }
        }
        rs.put("prescriptions", prescriptionVOs);
        rs.put("businessOrder", businessOrders);
        //物流信息
        List<WlyyPrescriptionExpressageDO> expressageDOs = prescriptionExpressageDao.findByOutpatientId(outpatientId);
@ -582,7 +604,6 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            }
        }
        //预约记录
        List<WlyyPatientRegisterTimeDO> timeDOs = patientRegisterTimeDao.findByOutpatientId(outpatientId);
        if (timeDOs != null && timeDOs.size() > 0) {
@ -671,7 +692,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                " p.prescribe_time AS \"prescribeTime\", " +
                " p.pay_time AS \"payTime\", " +
                " p.dosage_time AS \"dosageTime\", " +
                " p.finish_time AS \"finishTime\", " +
                " p.jih_time AS \"finishTime\", " +
                " p.create_time AS \"createTime\", " +
                " p.dept AS \"dept\", " +
                " p.dept_name AS \"deptName\", " +
@ -865,7 +886,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        }else {
            System.out.println("写入自取信息");
            String drugStoreCode = expressageDO.getHospitalCode();
            BaseDrugStoreDO baseDrugStoreDO = baseDrugStoreDao.findOne(drugStoreCode);
            BaseDrugStoreDO baseDrugStoreDO = baseDrugStoreDao.findDrugByid(drugStoreCode);
            if (null!=baseDrugStoreDO){
                expressageDO.setCityCode(baseDrugStoreDO.getCityCode());
                expressageDO.setCityName(baseDrugStoreDO.getCityName());
@ -873,7 +894,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                expressageDO.setProvinceName(baseDrugStoreDO.getProvinceName());
                expressageDO.setTownCode(baseDrugStoreDO.getTownCode());
                expressageDO.setTownName(baseDrugStoreDO.getTownName());
                expressageDO.setHospitalCode(baseDrugStoreDO.getDrugStoreCode());
                expressageDO.setHospitalCode(baseDrugStoreDO.getHospitalCode());
                expressageDO.setHospitalName(baseDrugStoreDO.getHospitalName());
                expressageDO.setHospitalAddress(baseDrugStoreDO.getAddress());
            }
@ -882,6 +903,10 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            expressageDO.setOutpatientId(outpatient.getId());
            prescriptionExpressageDao.save(expressageDO);
        }
        if (wechatId.equalsIgnoreCase("xm_xzzx_wx")){
            xzzxEntranceService.updatePatientMapping(outpatient.getConsumer(),outpatient.getCardNo());
            logger.info("同步患者id成功");
        }
        //3.创建候诊室
@ -894,15 +919,15 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        String sql = "select t.id as \"id\",t.adm_no as \"admNo\",t.create_time as \"createTime\" from wlyy_outpatient t where 1=1";
        String startDate = DateUtil.getStringDateShort()+" 00:00:00";
        String endDate = DateUtil.getStringDateShort()+" 23:59:59";
        if ("xm_zsyy_wx".equalsIgnoreCase(wechatId)){
        if ("xm_zsyy_wx".equalsIgnoreCase(wechatId)||"xm_xzzx_wx".equalsIgnoreCase(wechatId)){
            sql+=" and t.create_time >= '" +startDate+"' "+
                    " and t.create_time <= '" +endDate+"' ";
        }else if("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
            sql+=" and  t.create_time >= to_char('"+startDate+"','yyyy-mm-dd hh:mm:ss')\n" +
                    "and t.create_time < to_char('"+endDate+"','yyyy-mm-dd hh:mm:ss')";
        }else {
            sql+=" and  t.create_time >= to_char('"+startDate+"','yyyy-mm-dd hh:mm:ss')\n" +
                    "and t.create_time < to_char('"+endDate+"','yyyy-mm-dd hh:mm:ss')";
            sql+=" and t.create_time >= '" +startDate+"' "+
                    " and t.create_time <= '" +endDate+"' ";
        }
        if (StringUtils.isNoneBlank(patientId)){
            sql+=" and t.patient = '"+patientId+"'";
@ -1096,11 +1121,51 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    }
    public Map<String, Object> checkOutpatient(String patient) throws Exception {
    public Map<String, Object> checkOutpatient(String patient,String wxId) throws Exception {
        //-1卡余额不足,,-2 存在未结束的诊断热 1成功
        Map<String, Object> rs = new HashedMap();
        //1.余额判断改到前端判断
        //net.sf.json.JSONObject json = entranceService.qutpatientBalance(cardNo,demoFlag);
        if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
            List<WlyyOutpatientDO> outpatientDOS = outpatientDao.findByPatientListByStatus(patient);
            if (outpatientDOS!=null&&outpatientDOS.size()!=0){
                WlyyOutpatientDO outpatientDO = outpatientDOS.get(0);
                if (outpatientDO.getHisStatus()!=null){
                    logger.info("您上一次就诊进入"+outpatientDO.getHisStatus());
                    if(outpatientDO.getHisStatus()!=1&&outpatientDO.getHisStatus()!=-1){
                        logger.info("您上一次就诊进入======"+outpatientDO.getHisStatus());
                        rs.put("outpatient", outpatientDO);
                        rs.put("code", -3);
                        rs.put("mes", "您上一次就诊未结算,请结算后才能发起复诊。");
                        List<BasePatientWechatDo> patientWechatDos = patientWechatDao.findByWechatIdAndPatientId(wxId, patient);
                        if (patientWechatDos == null || patientWechatDos.size() == 0) {
                            throw new Exception("openid不存在!");
                        }
                        WxWechatDO wxWechatDO = wechatDao.findById(wxId);
                        BasePatientWechatDo patientWechatDo = patientWechatDos.get(0);
                        String payUrl = ylzPayService.createSicardPayUrl(wxWechatDO.getAppOriginId(),patientWechatDo.getOpenid(),outpatientDO.getCardNo(),"WX");
                        rs.put("payUrl",payUrl);
                        return rs;
                    }
                }else if (outpatientDO.getHisStatus()==null){
                    rs.put("outpatient", outpatientDO);
                    rs.put("code", -3);
                    rs.put("mes", "您上一次就诊未结算,请结算后才能发起复诊。");
                    List<BasePatientWechatDo> patientWechatDos = patientWechatDao.findByWechatIdAndPatientId(wxId, outpatientDO.getConsumer());
                    if (patientWechatDos == null || patientWechatDos.size() == 0) {
                        throw new Exception("openid不存在!");
                    }
                    WxWechatDO wxWechatDO = wechatDao.findById(wxId);
                    BasePatientWechatDo patientWechatDo = patientWechatDos.get(0);
                    String payUrl = ylzPayService.createSicardPayUrl(wxWechatDO.getAppOriginId(),patientWechatDo.getOpenid(),outpatientDO.getCardNo(),"WX");
                    rs.put("payUrl",payUrl);
                    return rs;
                }
            }
        }
        //2.判断是否有未结束的
        List<WlyyOutpatientDO> list = outpatientDao.findByPatientList(patient);
@ -1195,10 +1260,16 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                " d.job_title_name AS \"jobTitleName\"," +
                " d.charge_type AS \"chargeType\"," +
                " d.outpatient_type AS \"outpatientType\"," +
                " d.consult_status AS \"consultStatus\"" +
                " d.consult_status AS \"consultStatus\"," +
                " h.dept_code AS \"deptCode\","+
                " h.dept_name AS \"deptName\","+
                " h.org_code AS \"orgCode\","+
                " h.org_name AS \"orgName\","+
                " t.photo AS \"hosptialphoto\""+
                " FROM " +
                " base_doctor d " +
                " JOIN base_doctor_hospital h ON h.doctor_code = d.id " +
                " left join base_org t on t.id = h.org_code" +
                " WHERE  " +
                " 1=1 and d.del=1 ";
        Map<String, Object> params = new HashedMap();
@ -1777,6 +1848,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    WlyyPatientRegisterDO wlyyPatientRegisterDO = patientRegisterDao.findByRegisterNo(outpatientDO.getRegisterNo());
                    wlyyPatientRegisterDO.setDel(0);
                    patientRegisterDao.save(wlyyPatientRegisterDO);
                    outpatientDO.setHisStatus(-1);
                    outpatientDao.save(outpatientDO);
                }
                //保存日志
@ -2108,7 +2181,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @param diagnosisJson
     * @return
     */
    public Map<String, Object> makeDiagnosis(String outPatientId,String prescriptionId, String advice, String type, String infoJsons, String diagnosisJson, String inspectionJson, String emrJson) throws Exception {
    public Map<String, Object> makeDiagnosis(String outPatientId,String prescriptionId, String advice, String type, String infoJsons, String diagnosisJson, String inspectionJson, String emrJson,String hisId) throws Exception {
        Map<String, Object> result = new HashedMap();
@ -2126,6 +2199,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            wlyyPrescriptionDO1 = prescriptionDao.findById(prescriptionId);
            prescriptionDO =wlyyPrescriptionDO1.get(0);
        }else{
            if (StringUtils.isNotBlank(hisId)){
                prescriptionDO.setHisId(hisId);
            }
            prescriptionDO.setOutpatientId(outPatientId);
            prescriptionDO.setType(1);
            prescriptionDO.setDept(outpatientDO.getDept());
@ -2251,11 +2327,11 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            if (StringUtils.isNotBlank(inspectionJson)) {
                List<WlyyInspectionDO> inspections = (List<WlyyInspectionDO>) com.alibaba.fastjson.JSONArray.parseArray(inspectionJson, WlyyInspectionDO.class);
                for (WlyyInspectionDO ins : inspections) {
                    YkEmrJcsqDO ykEmrJcsqDO =new YkEmrJcsqDO();
                    ins.setDel(1);
                    ins.setCreateTime(new Date());
                    ins.setPrescriptionId(prescription.getId());
                    ins.setOutpatientId(outPatientId);
                    System.out.println("____outpatientId=="+outPatientId);
                }
                //保存检查检验。
                wlyyInspectionDao.save(inspections);
@ -2311,6 +2387,11 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                //上传his开方
                //sendHisDiagnosis(jsonData, outpatientDO, prescription)
                //zsSynHis(prescription.getId());
                //同步检查检验
                List<WlyyInspectionDO> inspectionDOS = wlyyInspectionDao.findByPrescriptionId(prescription.getId(),1);
                if (inspectionDOS != null && inspectionDOS.size() > 0) {
                    syCheckParam(outpatientDO.getId());
                }
                Map<String, Object> result1 = new HashedMap();
                result1.put("code", 1);
                result1.put("mes", "开方提交成功");
@ -2335,7 +2416,35 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    }
    /**
     * 组装检查检验项目参数
     *
     * @param outpatientId
     * @return
     */
    public void syCheckParam(String outpatientId) throws  Exception{
        String condition ="";
        condition = "<IoFlag>"+0+"</IoFlag>";
        StringBuffer inspectionList = new StringBuffer();
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId);
        String applyDoctor = "";
        if (null!=outpatientDO){
            DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(outpatientDO.getDoctor());
            if (null!=doctorMappingDO){
                applyDoctor = doctorMappingDO.getMappingCode();
            }
            condition += "<PayCardNo>"+outpatientDO.getCardNo()+"</PayCardNo>";
            condition += "<NullahNumber>"+outpatientDO.getRegisterNo()+"</NullahNumber>";
            condition += "<ApplyDept>"+outpatientDO.getDept()+"</ApplyDept>";
            condition += "<ApplyDoctor>"+applyDoctor+"</ApplyDoctor>";
            List<WlyyInspectionDO>  wlyyInspectionDOS = wlyyInspectionDao.findByOutpatientId(outpatientDO.getId());
            String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                    "<root>"+condition+"</root>";
            Map resultMap =  xzzxEntranceService.checkSyncHis("0",outpatientDO.getCardNo(),outpatientDO.getRegisterNo(),outpatientDO.getDept(),applyDoctor,wlyyInspectionDOS.toString());
            logger.info("同步his检查检验返回结果:"+resultMap.get("success"));
        }
    }
    /**
     * 计算药品费用
@ -2476,6 +2585,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            String voucherNo = jsonObject.getString("@xtgzh0");
            prescription.setAdmNo(admNo);
            prescription.setRealOrder(realOrder);
            prescription.setVoucherNo(voucherNo);
            prescriptionDao.save(prescription);
            outpatientDO.setAdmNo(admNo);
            outpatientDao.save(outpatientDO);
@ -2714,7 +2824,10 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                " o.icd10_name AS \"icd10Name\", " +
                " p.status as \"status\", " +
                " p.id AS \"prescriptionId\" ," +
                " e.id AS \"expressageId\""+
                " e.id AS \"expressageId\" ,"+
                " p.real_order AS \"realOrder\" ,"+
                " p.origin_real_order AS \"originRealOrder\"," +
                " o.patient_name as \"patientName\" "+
                " FROM " +
                " wlyy_outpatient o " +
                " JOIN wlyy_prescription p ON p.outpatient_id = o.id " +
@ -3578,12 +3691,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                }
            }
        }
        //更改门诊状态
        WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findOne(outPatientId);
        wlyyOutpatientDO.setStatus("-1");
        //报错拒诊操作人
        wlyyOutpatientDO.setOperator(userAgent.getUID());
        wlyyOutpatientDO.setEndTime(new Date());
        String description = null;
        if (1 == operator) {
            //居民取消
@ -3654,7 +3767,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                //眼科接诊时更新眼科通状态
                if (!flag){
                    if (businessOrderDO!=null){
                        ykyyService.updateYktOrderStatus(businessOrderDO.getOrderNo(),"9");
                        ykyyService.updateYktOrderStatus(businessOrderDO.getOrderNo(),"2");
                    }
                }
            } else if (wxId.equalsIgnoreCase("xm_zsyy_wx")) {
@ -3717,7 +3830,6 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            if ("9".equals(type)) {
                contentMsg = "医生已取消您的复诊申请,取消原因:"+remindMsg;
                first = outpatientDO.getConsumerName() + ",您好!您的图文复诊已取消";
            }
            if ("16".equals(type)) {
                contentMsg = "医生已取消您的复诊申请,取消原因:"+remindMsg;
@ -3730,6 +3842,17 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            first = outpatientDO.getConsumerName() + ",您好!";
            logger.info("outPatientTimeOutRemind:outpatientId="+outpatientId+"contentMsg"+contentMsg);
            msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
        }else if("systemCancelRemind".equalsIgnoreCase(titelType)){
            if ("9".equals(type)) {
                contentMsg = "图文咨询因超时自动取消。您可重新发起。由于订单取消将不做扣费处理。";
                first = outpatientDO.getConsumerName() + ",您好!您的图文复诊因超时未接诊已取消";
            }
            if ("16".equals(type)) {
                contentMsg = "视频咨询因超时自动取消。您可重新发起。由于订单取消将不做扣费处理。";
                first = outpatientDO.getConsumerName() + ",您好!您的视频复诊因超时未接诊已取消";
            }
            logger.info("系统取消接诊入参:outpatientId="+outpatientId);
            msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
        } else if ("payRemind".equalsIgnoreCase(titelType)) {
            if ("9".equals(type)) {
@ -4005,6 +4128,22 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                //发起微信消息模板推送
                newConfig.setUrl(newConfig.getUrl() + "" + consultTeam.getConsult());
                logger.info("眼科微信消息模板推送 服务评价提醒开始");
            } else if ("systemCancelRemind".equalsIgnoreCase(titelType)) {
                scene = "xtqxfz";
                WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_system_cancel", scene, 1);
                BeanUtils.copyProperties(config, newConfig);
                newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getConsumerName()));
                if ("9".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "图文复诊"));
                } else if ("16".equals(type)) {
                    newConfig.setFirst(newConfig.getFirst().replace("key2", "视频复诊"));
                }
                newConfig.setKeyword1( outpatientDO.getHospitalName());
                newConfig.setKeyword2(outpatientDO.getDoctorName());
                newConfig.setKeyword3( doctorDO.getFee());
                //发起微信消息模板推送
                newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                logger.info("眼科微信消息模板推送 系统拒诊开始");
            }
@ -4164,7 +4303,6 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        }
        return times;
    }
    /**
     * 医生可接单列表(图文复诊、视频复诊、协同门诊)
     *
@ -4174,7 +4312,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @query_status 0:图文复诊候诊 1:图文复诊抢单列表
     * @dept 部门
     */
    public List<Map<String, Object>> findWaitingRoomOutpatientByDoctor(String doctor, Integer type, Integer query_status, String dept) {
    public List<Map<String, Object>> findWaitingRoomOutpatientByDoctor(String doctor, Integer type, Integer query_status, String dept,String sex,String keyword,String ageGroup) {
        String sql = "SELECT " +
                "room.outpatient_id AS \"id\"," +
@ -4190,6 +4328,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                "outpatient.consumer_name as \"consumerName\"," +
                "outpatient.consumer_mobile as \"consumerMobile\", ";
        if ("xm_ykyy_wx".equals(wechatId)) {
            flag =true;
            if(flag){
                sql += "date_format(room.reservation_time ,'yyyy-MM-dd hh24:mi:ss' ) AS \"timedate_format\",";
            }else {
@ -4237,6 +4376,31 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        if (StringUtils.isNoneBlank(dept)) {
            sql += " AND outpatient.dept='" + dept + "' ";
        }
        if(StringUtils.isNoneBlank(sex)){
            sql += " AND patient.sex=" + sex + " ";
        }if(StringUtils.isNoneBlank(keyword)){
            sql += " AND patient.name like '%" + keyword + "%' ";
        }
        if(StringUtils.isNoneBlank(ageGroup)){
            String[] age = ageGroup.split(",");
            Calendar nowBegin = Calendar.getInstance();
            Calendar nowEnd = Calendar.getInstance();
            nowBegin.add(Calendar.YEAR,-Integer.parseInt(age[0]));
            nowEnd.add(Calendar.YEAR,-Integer.parseInt(age[1]));
            SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
            String beginAge =  sf.format(nowBegin.getTime());
            String endAge =  sf.format(nowEnd.getTime());
            if("xm_ykyy_wx".equals(wechatId)){
                if (flag){
                    sql+=" and patient.birthday > '" + endAge + "' and patient.birthday<'" + beginAge + "'";
                }else {
                    sql+=" and patient.birthday > to_date('" + endAge + "', 'yyyy-mm-dd') and patient.birthday < to_date('" + beginAge + "','yyyy-mm-dd')";
                }
            }else{
                sql+=" and patient.birthday > '" + endAge + "' and patient.birthday<'" + beginAge + "'";
            }
        }
        logger.info("接口名称:findWaitingRoomOutpatientByDoctor-->sql="+sql);
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
@ -4718,6 +4882,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                " d.job_title_name AS \"jobTitleName\"," +
                " d.charge_type AS \"chargeType\"," +
                " h.dept_name AS \"deptName\"," +
                " dw.workTotal AS \"workTotal\","+
                " d.consult_status AS \"consultStatus\"," +
                " d.outpatient_type AS \"outpatientType\"," +
                " a.total AS \"consultTotal\"," +
@ -4843,10 +5008,27 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            params.put("consultStatus", consultStatus);
        }
        if("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
            if (flag){
                sql += " and d.del='1' order by dw.workTotal desc ,d.consult_status DESC ,a.total " + consutlSort;
            }else{
                sql += " and d.del='1' order by dw.workTotal desc nulls last,d.consult_status desc nulls last ,a.total " + consutlSort;
            }
        }else {
            sql += " and d.del='1' order by dw.workTotal desc ,d.consult_status DESC ,a.total " + consutlSort;
        sql += " and d.del='1' order by dw.workTotal desc,d.consult_status DESC,a.total " + consutlSort;
        }
        String sqlCount = "select count(1) as \"total\" from ( "+sql+" ) t";
        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql, params, page, pagesize);
        /*list.stream().forEach(e->{
            if (null==e.get("consultStatus")){
                e.put("consultStatus",0);
            }
            if (null==e.get("workTotal")){
                e.put("workTotal",0);
            }
        });
        list.stream().sorted(Comparator.comparing((Map<String, Object> h) -> ((String) h.get("workTotal"))).reversed().thenComparing(Comparator.comparing((Map<String, Object> h) -> ((String) h.get("consultStatus")))).reversed());*/
        for (Map<String,Object> map:list){
            String doctor = map.get("id").toString();
            //查询医生各项评价平均分
@ -7213,12 +7395,14 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            /*prescriptionDao.updateCheckStatus(prescriptionId,2,reason,20);*/
            logger.info("开始=====" + wlyyPrescriptionDO.getCheckStatus());
            WlyyOutpatientDO outpatientDO = outpatientDao.findById(wlyyPrescriptionDO.getOutpatientId());
            DoctorMappingDO doctorMappingDO = doctorMappingService.findMappingCode(outpatientDO.getDoctor(), outpatientDO.getHospital());
            List<WlyyPrescriptionInfoDO> infoDOS = prescriptionInfoDao.findByPrescriptionId(prescriptionId, 1);
            List<WlyyInspectionDO> inspectionDOS = wlyyInspectionDao.findByPrescriptionId(prescriptionId, 1);
            List<WlyyPrescriptionDiagnosisDO> prescriptionDiagnosisDOS = prescriptionDiagnosisDao.findByPrescriptionId(prescriptionId,1);
            List<WlyyPrescriptionExpressageDO> expressageDOS = prescriptionExpressageDao.findByOutpatientId(outpatientDO.getId());
            if (wxId.equalsIgnoreCase("xm_zsyy_wx")) {
                try {
                    List<WlyyPrescriptionInfoDO> infoDOS = prescriptionInfoDao.findByPrescriptionId(prescriptionId, 1);
                    List<WlyyInspectionDO> inspectionDOS = wlyyInspectionDao.findByPrescriptionId(prescriptionId, 1);
                    DoctorMappingDO doctorMappingDO = doctorMappingService.findMappingCode(outpatientDO.getDoctor(), outpatientDO.getHospital());
                    List<WlyyPrescriptionExpressageDO> expressageDOS = prescriptionExpressageDao.findByOutpatientId(outpatientDO.getId());
                    //his处方拼接开方条件
                    com.alibaba.fastjson.JSONArray jsonData = new com.alibaba.fastjson.JSONArray();
                    for (WlyyPrescriptionInfoDO info : infoDOS) {
@ -7303,6 +7487,50 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    e.printStackTrace();
                }
            }else if (wxId.equalsIgnoreCase("xm_xzzx_wx")){
                try {
                    if (prescriptionDiagnosisDOS!=null&&prescriptionDiagnosisDOS.size()!=0){
                        String diagnosisName = prescriptionDiagnosisDOS.get(0).getName();
                        String diagnosisCode = prescriptionDiagnosisDOS.get(0).getCode();
                        //同步诊断
                        com.alibaba.fastjson.JSONObject jsonObject2 = xzzxEntranceService.saveDiagnosisToEntrance(outpatientDO.getRegisterNo(),diagnosisName,diagnosisCode);
                        logger.info("上传诊断返回参数"+jsonObject2);
                        //{"msg":"交易成功","code":"0","data":{"PresDetail":{"PresNo":"16151365"}},"success":"True"}
                        if (jsonObject2!=null){
                            if (jsonObject2.getString("code").equalsIgnoreCase("0")){
                                com.alibaba.fastjson.JSONObject jsonObject = jsonObject2.getJSONObject("data");
                                logger.info("上传诊断成功"+jsonObject2);
                            }
                        }
                    }
                    //同步处方
                    String applyDoctor = doctorMappingDO.getDoctorName()+"/"+doctorMappingDO.getMappingCode();
                    com.alibaba.fastjson.JSONObject object = xzzxEntranceService.savePrescriptionToEntrance("0",outpatientDO.getCardNo(),outpatientDO.getRegisterNo(),outpatientDO.getDept(),applyDoctor,"50100",infoDOS);
                    logger.info("成功上传处方"+object);
                    //{"msg":"交易成功","code":"0","data":{"PresDetail":{"PresNo":"16151365"}},"success":"True"}
                    if (object!=null){
                        if (object.getString("code").equalsIgnoreCase("0")){
                            com.alibaba.fastjson.JSONObject jsonObject = object.getJSONObject("data");
                            com.alibaba.fastjson.JSONObject jsonObject1 = jsonObject.getJSONObject("PresDetail");
                            String realOrder = jsonObject1.getString("PresNo");
                            wlyyPrescriptionDO.setAdmNo(outpatientDO.getAdmNo());
                            wlyyPrescriptionDO.setSerialNo(outpatientDO.getAdmNo());
                            wlyyPrescriptionDO.setRealOrder(realOrder);
                        }
                    }
                    logger.info("进入处方签名");
                    //处方签名
                    xzyyPrescriptionService.SOF_SignDataWithExtraInfo(wlyyPrescriptionDO);
                    //同步电子病历
                    WlyyPrescriptionEmrDO prescriptionEmrDO = prescriptionEmrDao.findEmrByPrescriptionId(prescriptionId);
                    if (prescriptionEmrDO != null) {
                        logger.info("电子病历签名");
                        xzyyPrescriptionService.SOF_SignDataWithExtraInfoEmr(wlyyPrescriptionDO);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            prescriptionLogService.addPrescriptionLog(prescriptionId, 20, 2, operate, operateName, reason, new Date());
            wlyyPrescriptionDO.setCheckStatus(2);
@ -7760,7 +7988,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        params.put("xmlStr", patNo);
        returnValue = com.yihu.jw.utils.WebserviceUtil.post(url,
                "http://business.htemr.haitaiinc.com",
                "manageEmrDataAll",
                "manageEmrDataRestore",
                params);
        logger.info("门诊病历列表信息,返回值xmlstr:" + returnValue);
@ -7794,7 +8022,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        params.put("xmlStr", patNo);
        returnValue = com.yihu.jw.utils.WebserviceUtil.post(url,
                "http://business.htemr.haitaiinc.com",
                "manageEmrDataAll",
                "manageEmrDataRestore",
                params);
        logger.info("门诊病历列表信息,返回值xmlstr:" + returnValue);
@ -8421,4 +8649,30 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        wlyyPrescriptionDO =  prescriptionDao.save(wlyyPrescriptionDO);
        return wlyyPrescriptionDO;
    }
    public void updateHisStatusByOutpatientId(String outpatientId){
        outpatientDao.updateHisStatusById(outpatientId,1);
    }
    //更新患者的诊断记录
    public Envelop updatePatientDiagnosis(String outpatiendId,String icd10,String icd10Name){
       WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findOne(outpatiendId);
        Envelop envelop = new Envelop();
       if (null!=wlyyOutpatientDO){
           if(StringUtils.isNotBlank(icd10)){
               wlyyOutpatientDO.setIcd10(icd10);
           }
           if(StringUtils.isNotBlank(icd10Name)){
               wlyyOutpatientDO.setIcd10Name(icd10Name);
           }
           outpatientDao.save(wlyyOutpatientDO);
           envelop.setMessage("添加成功");
           envelop.setStatus(200);
       }else {
           envelop.setMessage("无该患者门诊记录");
           envelop.setStatus(-1);
       }
       return envelop;
    }
}

+ 235 - 15
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/XzyyPrescriptionService.java

@ -4,22 +4,21 @@ package com.yihu.jw.hospital.prescription.service;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.ca.OauthCaConfigDO;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPatientRegisterDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionExpressageDO;
import com.yihu.jw.entity.hospital.prescription.*;
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
import com.yihu.jw.hospital.prescription.dao.PatientRegisterDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionExpressageDao;
import com.yihu.jw.hospital.prescription.dao.*;
import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@ -58,6 +57,21 @@ public class XzyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
    @Autowired
    private PrescriptionExpressageDao prescriptionExpressageDao;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private OauthCaConfigDao oauthCaConfigDao;
    @Autowired
    private PrescriptionInfoDao infoDao;
    @Autowired
    private PrescriptionDiagnosisDao diagnosisDao;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private PrescriptionEmrDao prescriptionEmrDao;
    /**
     * 挂号接口
@ -110,17 +124,27 @@ public class XzyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
            }
        }
        JSONObject res =  xzzxEntranceService.registeredOperate(doctorFlag,outpatientDO.getDept(),patientMappingDO.getMappingCode(),doctorDO.getChargeType(),courierflag);
        JSONObject result = new JSONObject();
        logger.info("挂号结果 res: " + res.toString());
        JSONObject object = res.getJSONObject("returnContents");
        String rsCode = "";
        if (object!=null){
        String serialNo = "";
        if (res!=null){
            JSONObject object = res.getJSONObject("returnContents");
            serialNo = object.getString("registerNo");
            if (object!=null){
                result.put("@RESULT", "0");
                result.put("@MSG","挂号成功!");
                rsCode = object.getString("registerNo");
            }
        }else {
            result.put("@RESULT", "-1");
            result.put("@MSG","挂号失败");
        }
        rsCode = object.getString("registerNo");
        if (StringUtils.isNoneBlank(rsCode)) {
            //存储挂号号
            String serialNo = object.getString("registerNo");
            outpatientDO.setRegisterNo(serialNo);
            outpatientDO.setAdmDate(new Date());
            outpatientDO.setAdmNo(serialNo);
@ -134,6 +158,7 @@ public class XzyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
            registerDO.setDoctorName(outpatientDO.getDoctorName());
            registerDO.setDept(outpatientDO.getDept());
            registerDO.setDeptName(outpatientDO.getDeptName());
            registerDO.setDel(1);
            registerDO.setPatient(outpatientDO.getPatient());
            registerDO.setPatientName(outpatientDO.getPatientName());
@ -145,7 +170,6 @@ public class XzyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
        } else if ("-2".equals(rsCode)) {
            String serialNo = (String) res.get("registerNo");
            outpatientDO.setRegisterNo(serialNo);
            outpatientDO.setAdmDate(new Date());
            outpatientDO.setAdmNo(serialNo);
@ -159,6 +183,7 @@ public class XzyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
            registerDO.setDoctorName(outpatientDO.getDoctorName());
            registerDO.setDept(outpatientDO.getDept());
            registerDO.setDeptName(outpatientDO.getDeptName());
            registerDO.setDel(1);
            registerDO.setPatient(outpatientDO.getPatient());
            registerDO.setPatientName(outpatientDO.getPatientName());
@ -180,6 +205,201 @@ public class XzyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
        log.setStatus("1");
        log.setCreateTime(new Date());
        wlyyHttpLogDao.save(log);
        return res;
        return result;
    }
    public JSONObject refundRegisterNo(String outpatientId) throws Exception {
        JSONObject object = new JSONObject();
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId);
        if(outpatientDO!=null){
            DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(outpatientDO.getDoctor());
            if (StringUtils.isNoneBlank(outpatientDO.getRegisterNo())){
                object = xzzxEntranceService.refundConsultationToEntrance(outpatientDO.getRegisterNo(), outpatientDO.getCardNo());
                logger.info("退号结果 res: " + object.toString());
                if (object!=null&&object.getString("code").equalsIgnoreCase("0")){
                    WlyyPatientRegisterDO wlyyPatientRegisterDO = patientRegisterDao.findByRegisterNo(outpatientDO.getRegisterNo());
                    wlyyPatientRegisterDO.setDel(0);
                    patientRegisterDao.save(wlyyPatientRegisterDO);
                    outpatientDO.setHisStatus(-1);
                    outpatientDao.save(outpatientDO);
                }
                //保存日志
                WlyyHttpLogDO log = new WlyyHttpLogDO();
                log.setCode("refundregisterOutPatient");
                log.setName("退号");
                log.setPatient(outpatientDO.getPatient());
                log.setDoctor(outpatientDO.getDoctor());
                log.setResponse(object.toString());
                log.setRequest("outPatientId=" + outpatientId + "&doctor=" + outpatientDO.getDoctor());
                log.setStatus(object.getString("code"));
                log.setCreateTime(new Date());
                wlyyHttpLogDao.save(log);
            }
        }
        return  object;
    }
    /**
     * 处方签名
     * @param prescriptionDO
     * @throws Exception
     */
    public void SOF_SignDataWithExtraInfo(WlyyPrescriptionDO prescriptionDO) throws Exception {
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(prescriptionDO.getOutpatientId());
        List<WlyyPrescriptionInfoDO> infoDOS = infoDao.findByPrescriptionId(prescriptionDO.getId(), 1);
        List<WlyyPrescriptionDiagnosisDO> diagnosisDOS = diagnosisDao.findByPrescriptionId(prescriptionDO.getId(),1);
        JSONObject object = new JSONObject();
        object.put("infos",infoDOS);
        object.put("registerSn",outpatientDO.getRegisterNo());
        object.put("diagnosiss",diagnosisDOS);
        JSONObject jsonObject = computeDigestForAlg(object.toJSONString());
        String hashValue = null;
        String hashType = null;
        if (jsonObject.getString("status").equalsIgnoreCase("0")){
            JSONObject data = jsonObject.getJSONObject("data");
            hashValue= data.getString("hashValue");
            hashType = data.getString("hashType");
        }
        BasePatientDO patientDO = patientDao.findById(outpatientDO.getPatient());
        BaseDoctorDO doctorDO = doctorDao.findById(outpatientDO.getDoctor());
        if (patientDO!=null&&doctorDO!=null){
            String patientName = patientDO.getName();
            Integer patientAge = IdCardUtil.getAgeForIdcard(patientDO.getIdcard());
            String patientSex = IdCardUtil.getSexForIdcard(patientDO.getIdcard());
            String recipeTime = DateUtil.dateToStrLong(prescriptionDO.getCreateTime());
            String openId = doctorDO.getOpenid();
            String idcard = patientDO.getIdcard();
            if (hashType!=null&&hashValue!=null){
                JSONObject object1 = synRecipeInfo("hash_004",getCode(),patientName,patientAge.toString(),patientSex,"SF",recipeTime,hashValue,hashType,openId,idcard);
                if (object1.getString("status").equalsIgnoreCase("0")){
                    logger.info("西药处方签名成功"+object1);
                }
            }
        }
    }
    /**
     * 处方签名
     * @param prescriptionDO
     * @throws Exception
     */
    public void SOF_SignDataWithExtraInfoEmr(WlyyPrescriptionDO prescriptionDO) throws Exception {
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(prescriptionDO.getOutpatientId());
        WlyyPrescriptionEmrDO prescriptionEmrDO = prescriptionEmrDao.findEmrByPrescriptionId(prescriptionDO.getId());
        JSONObject object = new JSONObject();
        object.put("emr",prescriptionEmrDO);
        object.put("registerSn",outpatientDO.getRegisterNo());
        object.put("doctorName",outpatientDO.getDoctorName());
        object.put("patientName",outpatientDO.getPatientName());
        JSONObject jsonObject = computeDigestForAlg(object.toJSONString());
        String hashValue = null;
        String hashType = null;
        if (jsonObject.getString("status").equalsIgnoreCase("0")){
            JSONObject data = jsonObject.getJSONObject("data");
            hashValue= data.getString("hashValue");
            hashType = data.getString("hashType");
        }
        BasePatientDO patientDO = patientDao.findById(outpatientDO.getPatient());
        BaseDoctorDO doctorDO = doctorDao.findById(outpatientDO.getDoctor());
        if (patientDO!=null&&doctorDO!=null){
            String patientName = patientDO.getName();
            Integer patientAge = IdCardUtil.getAgeForIdcard(patientDO.getIdcard());
            String patientSex = IdCardUtil.getSexForIdcard(patientDO.getIdcard());
            String recipeTime = DateUtil.dateToStrLong(prescriptionDO.getCreateTime());
            String openId = doctorDO.getOpenid();
            String idcard = patientDO.getIdcard();
            if (hashType!=null&&hashValue!=null){
                JSONObject object1 = synRecipeInfo("hash_002",getCode(),patientName,patientAge.toString(),patientSex,"SF",recipeTime,hashValue,hashType,openId,idcard);
                if (object1.getString("status").equalsIgnoreCase("0")){
                    logger.info("门诊病历签名成功"+object1);
                }
            }
        }
    }
    /**
     * 数据哈希计算接口
     * @param content
     * @return
     */
    public JSONObject computeDigestForAlg(String content){
        try {
            OauthCaConfigDO oauthCaConfigDO = oauthCaConfigDao.findOne("oauth_ca_config");
            String url = "";
            if (oauthCaConfigDO!=null){
                url=oauthCaConfigDO.getUrl()+"/gateway/common/computeDigestForAlg";
            }
            JSONObject object = new JSONObject();
            object.put("originData",content);
            String response = httpClientUtil.sendPost(url,object.toJSONString());
            logger.info("数据哈希计算接口 :"+response);
            return JSONObject.parseObject(response);
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
    /***
     * 数据签名接口
     * @param templateId 模板ID签名数据摘要数据类型
     * @param urId 签名流水ID
     * @param patientName 患者姓名
     * @param patientAge 患者年龄
     * @param patientSex 患者性别
     * @param patientCardType  证件类型
     * @param recipeTime 开具时间
     * @param hashValue Hash原文(从签名指纹接口结果中得到的)
     * @param hashType Hash算法(从签名指纹接口结果中得到的)
     * @return
     */
    public JSONObject synRecipeInfo(String templateId,String urId,String patientName,String patientAge,String patientSex,String patientCardType,String recipeTime,String hashValue,String hashType,String openId,String patientCard){
        try {
            OauthCaConfigDO oauthCaConfigDO = oauthCaConfigDao.findOne("oauth_ca_config");
            String url = "";
            String clientId= "";
            String clientSecret = "";
            if (oauthCaConfigDO!=null){
                url=oauthCaConfigDO.getUrl()+"/gateway/recipe/synRecipeInfo";
                clientId=oauthCaConfigDO.getClientId();
                clientSecret=oauthCaConfigDO.getClientSecret();
            }
            JSONObject object = new JSONObject();
            JSONObject msg = new JSONObject();
            JSONObject head = new JSONObject();
            head.put("clientId",clientId);
            head.put("templateId",templateId);
            head.put("clientSecret",clientSecret);
            head.put("selfSign",true);
            msg.put("head",head);
            JSONObject body = new JSONObject();
            body.put("urId",urId);
            body.put("patientName",patientName);
            body.put("patientAge",patientAge);
            body.put("patientSex",patientSex);
            body.put("patientCardType",patientCardType);
            body.put("recipeTime",recipeTime);
            body.put("hashValue",hashValue);
            body.put("hashType",hashType);
            body.put("patientCard",patientCard);
            body.put("openId",openId);
            msg.put("body",body);
            object.put("msg",msg);
            object.put("signType",0);
            logger.info("请求参数:"+object);
            String response = httpClientUtil.sendPost(url,object.toJSONString());
            logger.info("数据签名接口 :"+response);
            return JSONObject.parseObject(response);
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}

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

@ -4,6 +4,7 @@ package com.yihu.jw.hospital.prescription.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.entity.base.area.BaseDrugStoreDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.base.wx.WxWechatDO;
@ -22,6 +23,7 @@ import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionExpressageDao;
import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService;
import com.yihu.jw.hospital.prescription.service.useragent.BaseUserAgent;
import com.yihu.jw.hospital.ykyy.service.YkyyService;
import com.yihu.jw.order.BusinessOrderService;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.order.pay.wx.WeChatConfig;
@ -93,7 +95,10 @@ public class YkyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
    @Value("${pay.flag}")
    private boolean payFlag;
    @Value("${wechat.id}")
    private String wechatId;
    @Autowired
    private YkyyService ykyyService;
    /**
     * 获取居民就诊记录接口
@ -202,7 +207,7 @@ public class YkyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
        }
        if (!flag){
            businessOrderService.saveOrder(businessOrderDO);
            businessOrderDO = businessOrderService.saveOrder(businessOrderDO);
        }
        WlyyPatientRegisterTimeDO registerTimeDO = null;
@ -226,9 +231,39 @@ public class YkyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
        expressageDO.setOutpatientId(outpatient.getId());
        prescriptionExpressageDao.save(expressageDO);
        if (0==expressageDO.getOneselfPickupFlg()){
            if("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
                String drugCode= expressageDO.getHospitalCode()==null?"5550":expressageDO.getHospitalCode();
                expressageDO.setHospitalCode(drugCode);
            }
            System.out.println("进入物流信息");
            expressageDO.setDel(1);
            expressageDO.setCreateTime(new Date());
            expressageDO.setOutpatientId(outpatient.getId());
            prescriptionExpressageDao.save(expressageDO);
        }else {
            System.out.println("写入自取信息");
            String drugStoreCode = expressageDO.getHospitalCode();
            BaseDrugStoreDO baseDrugStoreDO = baseDrugStoreDao.findDrugByid(drugStoreCode);
            if (null!=baseDrugStoreDO){
                expressageDO.setCityCode(baseDrugStoreDO.getCityCode());
                expressageDO.setCityName(baseDrugStoreDO.getCityName());
                expressageDO.setProvinceCode(baseDrugStoreDO.getProvinceCode());
                expressageDO.setProvinceName(baseDrugStoreDO.getProvinceName());
                expressageDO.setTownCode(baseDrugStoreDO.getTownCode());
                expressageDO.setTownName(baseDrugStoreDO.getTownName());
                expressageDO.setHospitalCode(baseDrugStoreDO.getHospitalCode());
                expressageDO.setHospitalName(baseDrugStoreDO.getHospitalName());
                expressageDO.setHospitalAddress(baseDrugStoreDO.getAddress());
            }
            expressageDO.setDel(1);
            expressageDO.setCreateTime(new Date());
            expressageDO.setOutpatientId(outpatient.getId());
            prescriptionExpressageDao.save(expressageDO);
        }
        //3.创建候诊室
        createRoom(outpatient, chargeType);
        return outpatient;
    }
@ -351,7 +386,7 @@ public class YkyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
        for (int i=0;i<mapList.size();i++){
            JSONObject map = mapList.getJSONObject(i);
            JSONObject object = new JSONObject();
            object.put("charge_code",map.get("ypdm"));
            object.put("charge_code",map.get("ypxh"));
            object.put("drugname",map.get("ypmc"));
            object.put("specification",map.get("yfgg"));
            object.put("pack_unit_name",map.get("jldw"));

+ 1 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/EntranceService.java

@ -374,6 +374,7 @@ public class EntranceService {
                                wlyyPrescriptionInfoVO.setGroupNo(null != jsonObjectBody.get("DISP_DEPOSITE") ? jsonObjectBody.get("DISP_DEPOSITE").toString() : "");
                                //规格
                                wlyyPrescriptionInfoVO.setSpecification(null != jsonObjectBody.get("DRUG_SPEC") ? jsonObjectBody.get("DRUG_SPEC").toString() : "");
                                wlyyPrescriptionInfoVO.setSerial(null!=jsonObjectBody.get("serial")? jsonObjectBody.get("serial").toString() : "");
                                wlyyPrescriptionInfoVO.setDel(1);
                                wlyyPrescriptionInfoVOS.add(wlyyPrescriptionInfoVO);
                            }

+ 1546 - 18
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/XzzxEntranceService.java

@ -3,6 +3,7 @@ package com.yihu.jw.hospital.prescription.service.entrance;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.dict.dao.DictDoctorDutyDao;
import com.yihu.jw.dict.dao.DictHospitalDeptDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
@ -17,6 +18,7 @@ import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.dict.WlyyChargeDictDO;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
import com.yihu.jw.entity.hospital.prescription.*;
@ -28,6 +30,8 @@ import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
import com.yihu.jw.hospital.prescription.dao.*;
import com.yihu.jw.hospital.prescription.service.entrance.util.AES;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.hospital.doctor.CheckInfoVO;
import com.yihu.jw.restmodel.hospital.doctor.PersonInfoVO;
import com.yihu.jw.restmodel.hospital.prescription.*;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
@ -38,6 +42,7 @@ import com.yihu.jw.utils.WebserviceUtil;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import com.yihu.utils.security.MD5;
import net.sf.json.xml.XMLSerializer;
import nu.xom.*;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@ -47,6 +52,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.io.IOException;
import java.io.StringReader;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@ -100,7 +108,14 @@ public class XzzxEntranceService{
    private WlyyInspectionDao wlyyInspectionDao;
    @Autowired
    private PrescriptionDiagnosisDao prescriptionDiagnosisDao;
    @Autowired
    private BaseDoctorDao baseDoctorDao;
    @Autowired
    private BasePatientDao basePatientDao;
    @Autowired
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
    @Autowired
    private PrescriptionEmrDao prescriptionEmrDao;
    private static String key="bvvsf3JA0mUXMU+mVnMaOQ==";
@ -112,9 +127,14 @@ public class XzzxEntranceService{
    public static String entranceUrlLocal = "http://localhost:10023/xzzx/";
    public static String hospitalUrl = "http://192.168.118.240:10022/";//172.16.100.63
    //合理用药接口地址
    public static String checkInfosUrl="http://192.168.102.243:8040/service/api/check.do?tag=1";
    //保存天际处方接口地址
    public static String saveTianJiPrescription = "http://192.168.102.243:8040/service/api/checkFromXmlToJson.do?tag=2";
    //作废处方地址
    public static String deleteTianJiPrescription = "http://192.168.102.243:8040/service/api/checkFromXmlToJson.do?tag=2";
    //药品说明书地址http://192.168.102.243:8221/drugs/@code@?source=dcdt_web&show_navbar=true
    public static String drugUseInfoTianJi = "http://192.168.102.243:8221/drugs/@code@?source=dcdt_web&show_navbar=true";
    public String getSelectUrl(){
        List<WlyyHospitalSysDictDO> list =  wlyyHospitalSysDictDao.findByDictName("xzzxWebSelectService");
@ -932,24 +952,785 @@ public class XzzxEntranceService{
        if (!StringUtils.isEmpty(admNo)){
            condition += "<admNo>"+admNo+"</admNo>";
        }
        if (!StringUtils.isEmpty(realOrder)){
            condition +="<realOrder>"+realOrder+"</realOrder>";
        if (!StringUtils.isEmpty(realOrder)){
            condition +="<realOrder>"+realOrder+"</realOrder>";
        }
        if (!StringUtils.isEmpty(status)){
            condition += "<status>"+status+"</status>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("updatePreStatus params:"+params.toString());
        String xml = getXzzxWebServiceInfo("UpdatePreStatus",params,getOperateUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("updatePreStatus json:"+json);
        return json;
    }
    /**
     *
     *  获取icd10字典
     *
     * @param spellCode spellCode
     * @return
     * @throws Exception
     */
    public String GetICD10Dict(String spellCode)throws Exception{
        String api = "GetICD10Dict";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (!StringUtils.isEmpty(spellCode)){
            condition += "<spell_code>"+spellCode+"</spell_code>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("GetICD10Dict params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("GetICD10Dict json:"+json);
        return json;
    }
    /**
     *
     *  获取药品字典
     *
     * @param spellCode spellCode
     * @return
     * @throws Exception
     */
    public String GetDrugDict(String spellCode)throws Exception{
        String api = "GetDrugDict";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (!StringUtils.isEmpty(spellCode)){
            condition += "<spell_code>"+spellCode+"</spell_code>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("GetDrugDict params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("GetDrugDict json:"+json);
        return json;
    }
    /**
     *
     *  查询药品用药方法
     * @return
     * @throws Exception
     */
    public String GetMedicineUsed(String spellCode)throws Exception{
        String api = "GetMedicineUsed";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (!StringUtils.isEmpty(spellCode)){
            condition = "<spell_code>"+spellCode+"</spell_code>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("GetMedicineUsed params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("GetMedicineUsed json:"+json);
        return json;
    }
    /**
     *
     *  获取药品用药频次字典
     * @return
     * @throws Exception
     */
    public String GetFrequencyDict()throws Exception{
        String api = "GetFrequencyDict";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("GetFrequencyDict params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("GetFrequencyDict json:"+json);
        return json;
    }
    /**
     *
     *  获取检查部位字典
     * @return
     * @throws Exception
     */
    public String  GetCheckBody(String spellCode)throws Exception{
        String api = "GetCheckBody";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (!StringUtils.isEmpty(spellCode)){
            condition = "<spell_code>"+spellCode+"</spell_code>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info(" GetCheckBody params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info(" GetCheckBody json:"+json);
        return json;
    }
    /**
     *
     *  获取检查单据信息
     * @return
     * @throws Exception
     */
    public String GetExamApply(String spellCode)throws Exception{
        String api = "GetExamApply";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (!StringUtils.isEmpty(spellCode)){
            condition = "<spell_code>"+spellCode+"</spell_code>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("GetExamApply params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info(" GetExamApply json:"+json);
        return json;
    }
    /**
     *
     *  获取检验单据信息
     * @return
     * @throws Exception
     */
    public String GetLisApply(String spellCode)throws Exception{
        String api = "GetLisApply";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (!StringUtils.isEmpty(spellCode)){
            condition = "<spell_code>"+spellCode+"</spell_code>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("GetLisApply params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params,getSelectUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info(" GetLisApply json:"+json);
        return json;
    }
    /**
     * 互联网医院开处方信息更新到his
     * @param IoFlag  门诊住院标志
     * @param PayCardNo 就诊卡号
     * @param NullahNumber 挂号流水号
     * @param ApplyDept 执行科室
     * @param ApplyDoctor 开单医生
     * @param ExecuteDept 执行科室(药房)
     * @param prescriptionInfoDOList
     * @return
     * @throws Exception
     */
    public String savePrescriptionToHospital(String IoFlag,String PayCardNo,String NullahNumber,
                                             String ApplyDept,String ApplyDoctor,String ExecuteDept,List<WlyyPrescriptionInfoDO> prescriptionInfoDOList)throws Exception{
        String api = "savePrescriptionToHospital";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (!StringUtils.isEmpty(IoFlag)){
            condition += "<IoFlag>"+IoFlag+"</IoFlag>";
        }
        if (!StringUtils.isEmpty(PayCardNo)){
            condition += "<PayCardNo>"+PayCardNo+"</PayCardNo>";
        }
        if (!StringUtils.isEmpty(NullahNumber)){
            condition += "<NullahNumber>"+NullahNumber+"</NullahNumber>";
        }
        if (!StringUtils.isEmpty(ApplyDept)){
            condition += "<ApplyDept>"+ApplyDept+"</ApplyDept>";
        }
        if (!StringUtils.isEmpty(ApplyDoctor)){
            condition += "<ApplyDoctor>"+ApplyDoctor+"</ApplyDoctor>";
        }
        if (!StringUtils.isEmpty(ExecuteDept)){
            condition += "<ExecuteDept>"+ExecuteDept+"</ExecuteDept>";
        }
        condition +="<PresDetail>";
        for (WlyyPrescriptionInfoDO prescriptionInfoDO:prescriptionInfoDOList){
            String condition1 = "";
            condition1 += "<PhysicCode>"+prescriptionInfoDO.getDrugNo()+"</PhysicCode>";
            condition1 += "<Doseage>"+prescriptionInfoDO.getDosage()+"</Doseage>";
            condition1 += "<DoseUnit>"+prescriptionInfoDO.getUnit()+"</DoseUnit>";
            condition1 += "<Frequency>"+prescriptionInfoDO.getUsageCode()+"</Frequency>";
            condition1 += "<DayCount>"+prescriptionInfoDO.getDays()+"</DayCount>";
            condition1 += "<Usage>"+prescriptionInfoDO.getSupplyCode()+"</Usage>";
            condition1 += "<TotalDoseage>"+prescriptionInfoDO.getQuantity()+"</TotalDoseage>";
            condition1 += "<TotalUnit>"+prescriptionInfoDO.getPackUnit()+"</TotalUnit>";
            condition1 += "<PrescribeMemo>"+"</PrescribeMemo>";
            condition1 += "<FryMode>"+"</FryMode>";
            condition1 += "<HerbalTakeMethodClass>"+"</HerbalTakeMethodClass>";
            condition1 += "<HerbalFryMethod>"+"</HerbalFryMethod>";
            condition1 += "<HerbalFryMethod2>"+"</HerbalFryMethod2>";
            condition+="<PresInfo>"+condition1+"</PresInfo>";
        }
        condition+="</PresDetail>";
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("savePrescriptionToHospital params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params,getOperateUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info(" savePrescriptionToHospital json:"+json);
        return json;
    }
    /**
     * 互联网医院删除处方信息更新到his
     * @param IoFlag  门诊住院标志
     * @param PayCardNo 就诊卡号
     * @param NullahNumber 挂号流水号
     * @param ApplyDept 执行科室
     * @param ApplyDoctor 开单医生
     * @param ExecuteDept 执行科室(药房)
     * @param PresNo 必填,医嘱号
     * @return
     * @throws Exception
     */
    public String delHisPrescriptionByHisNo(String IoFlag,String PayCardNo,String NullahNumber,
                                             String ApplyDept,String ApplyDoctor,String ExecuteDept,String PresNo)throws Exception{
        String api = "delHisPrescriptionByHisNo";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (!StringUtils.isEmpty(IoFlag)){
            condition += "<IoFlag>"+IoFlag+"</IoFlag>";
        }
        if (!StringUtils.isEmpty(PayCardNo)){
            condition += "<PayCardNo>"+PayCardNo+"</PayCardNo>";
        }
        if (!StringUtils.isEmpty(NullahNumber)){
            condition += "<NullahNumber>"+NullahNumber+"</NullahNumber>";
        }
        if (!StringUtils.isEmpty(ApplyDept)){
            condition += "<ApplyDept>"+ApplyDept+"</ApplyDept>";
        }
        if (!StringUtils.isEmpty(ApplyDoctor)){
            condition += "<ApplyDoctor>"+ApplyDoctor+"</ApplyDoctor>";
        }
        if (!StringUtils.isEmpty(ExecuteDept)){
            condition += "<ExecuteDept>"+ExecuteDept+"</ExecuteDept>";
        }
        if (!StringUtils.isEmpty(PresNo)){
            condition += "<PresNo>"+PresNo+"</PresNo>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("delHisPrescriptionByHisNo params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params,getOperateUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("delHisPrescriptionByHisNo json:"+json);
        return json;
    }
    /**
     * 保存入门诊断信息到his
     * @param ApplyNo
     * @param DiagnosisName
     * @param DiagnosisCode
     * @param ChnSymPtomsCode
     * @param ChnSymPtomsName
     * @param ChnDiagnosisCode
     * @param ChnDiagnosisName
     * @return
     * @throws Exception
     */
    public String saveDiagnosis(String ApplyNo,String DiagnosisName,String DiagnosisCode,
                                             String ChnSymPtomsCode,String ChnSymPtomsName,String ChnDiagnosisCode,String ChnDiagnosisName)throws Exception{
        String api = "saveDiagnosis";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (!StringUtils.isEmpty(ApplyNo)){
            condition += "<ApplyNo>"+ApplyNo+"</ApplyNo>";
        }
        if (!StringUtils.isEmpty(DiagnosisName)){
            condition += "<DiagnosisName>"+DiagnosisName+"</DiagnosisName>";
        }
        if (!StringUtils.isEmpty(DiagnosisCode)){
            condition += "<DiagnosisCode>"+DiagnosisCode+"</DiagnosisCode>";
        }
        condition+="<ChnSymPtomsCode>"+"</ChnSymPtomsCode>";
        condition+="<ChnSymPtomsName>"+"</ChnSymPtomsName>";
        condition+="<ChnDiagnosisCode>"+"</ChnDiagnosisCode>";
        condition+="<ChnDiagnosisName>"+"</ChnDiagnosisName>";
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("saveDiagnosis params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params,getOperateUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info(" saveDiagnosis json:"+json);
        return json;
    }
    /**
     * 发送退号信息到his
     * @param ApplyNo
     * @return
     * @throws Exception
     */
    public String refundConsultation(String ApplyNo,String PayCardNo)throws Exception{
        String api = "refundConsultation";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (!StringUtils.isEmpty(ApplyNo)){
            condition += "<ApplyNo>"+ApplyNo+"</ApplyNo>";
        }
        if (!StringUtils.isEmpty(PayCardNo)){
            condition += "<PayCardNo>"+PayCardNo+"</PayCardNo>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("refundConsultation params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params,getOperateUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("refundConsultation json:"+json);
        return json;
    }
    /**
     * 组装检查检验项目参数
     *
     * @param
     * @return
     */
    public String saveInspectToHospital(String IoFlag,String PayCardNo,String NullahNumber,String ApplyDept,String ApplyDoctor,List<WlyyInspectionDO> wlyyInspectionDOS) throws  Exception{
        String api = "saveInspectToHospital";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        condition = "<IoFlag>"+IoFlag+"</IoFlag>";
        StringBuffer inspectionList = new StringBuffer();
        condition += "<PayCardNo>"+PayCardNo+"</PayCardNo>";
        condition += "<NullahNumber>"+NullahNumber+"</NullahNumber>";
        condition += "<ApplyDept>"+ApplyDept+"</ApplyDept>";
        condition += "<ApplyDoctor>"+ApplyDoctor+"</ApplyDoctor>";
        for (WlyyInspectionDO wlyyInspectionDO:wlyyInspectionDOS){
            inspectionList.append("<PresInfo>");
            inspectionList.append("<ClinicCode>"+wlyyInspectionDO.getCode()+"</ClinicCode>");
            inspectionList.append("<ClinicNum>"+wlyyInspectionDO.getQuantity()+"</ClinicNum>");
            inspectionList.append("<ExecuteDept>"+wlyyInspectionDO.getDept()+"</ExecuteDept>");
            inspectionList.append("<CheckResult>"+wlyyInspectionDO.getYwjcResult()+"</CheckResult>");
            inspectionList.append("<CheckPart>"+wlyyInspectionDO.getCheckPart()+"</CheckPart>");
            inspectionList.append("<SickSynptom>"+"临床症状和体征 "+"</SickSynptom>");
            inspectionList.append("<Height>"+"身高"+"</Height>");
            inspectionList.append("<Weight>"+"体重"+"</Weight>");
            inspectionList.append("<SensitiveName>"+"过敏史"+"</SensitiveName>");
            inspectionList.append("<SampleCode>"+"标本类型"+"</SampleCode>");
            inspectionList.append("<ChiefComplaint>"+"主诉"+"</ChiefComplaint>");
            inspectionList.append("<MedicalHistory>"+wlyyInspectionDO.getInformation()+"</MedicalHistory>");
            inspectionList.append("<InspectionPurpose>"+wlyyInspectionDO.getGoal()+"</InspectionPurpose>");
            inspectionList.append("<PastHistory>"+"既往史"+"</PastHistory>");
            inspectionList.append("<LisCheckResult>"+wlyyInspectionDO.getYwjcResult()+"</LisCheckResult>");
            inspectionList.append("<InspectionResult>"+wlyyInspectionDO.getAdresult()+"</InspectionResult>");
            inspectionList.append("<InspectionNotice>"+"注意事项"+"</InspectionNotice>");
            inspectionList.append("<Memo>"+wlyyInspectionDO.getCode()+"</Memo>");
            inspectionList.append("</PresInfo>");
        }
        condition += "<PresDetail>" +inspectionList.toString()+"</PresDetail>";
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("saveInspectToHospital params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params,getOperateUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info(" saveInspectToHospital json:"+json);
        return json;
    }
    /*
     *合理用药审核接口入参
     */
    public String checkPrescriptionInfoParam(JSONObject patientAndDoctor,List<WlyyPrescriptionInfoDO> infos,boolean isDelete){
        String checkDoctor="<Doctor POSITION=\""+patientAndDoctor.getString("POSITION")+
                "\" NAME=\""+patientAndDoctor.getString("DOCTOR_NAME")+
                "\" DEPT_CODE=\""+patientAndDoctor.getString("DEPT_CODE")+
                "\" DEPT_NAME=\""+patientAndDoctor.getString("DEPT_NAME")+"\" USER_ID=\""+patientAndDoctor.getString("DOCTOR_ID")+"\" />";
        String checkPatient="<Patient NAME=\""+patientAndDoctor.getString("PATIENT_NAME")+
                "\" ID=\""+patientAndDoctor.getString("PATIENT_ID")+
                "\" VISIT_ID=\"0\" PATIENT_PRES_ID=\""+patientAndDoctor.getString("PATIENT_PRES_ID")+
                "\" BIRTH=\""+patientAndDoctor.getString("BIRTH")+
                "\" HEIGHT=\"\" WEIGHT=\"\" GENDER=\""+patientAndDoctor.getString("GENDER")+
                "\" PREGNANT=\"\" LACT=\"否\" HEPATICAL=\"\" RENAL=\"\" PANCREAS=\"\" ALERGY_DRUGS=\"\" IDENTITY_TYPE=\"\" FEE_TYPE=\""+patientAndDoctor.getString("FEE_TYPE")+
                "\" SCR=\"\" SCR_UNIT=\"\" GESTATION_AGE=\"\" PRETERM_BIRTH=\"\" DRUG_HISTORY=\"\" FAMILY_DISEASE_HISTORY=\"\" GENETIC_DISEASE=\"\" MEDICARE_01=\"\" MEDICARE_02=\"\" MEDICARE_03=\"\" MEDICARE_04=\"\" MEDICARE_05=\"\" />";
        String checkDiagnosises = "<Diagnosises DIAGNOSISES=\""+patientAndDoctor.getString("diagnosises")+"\" >\n" +
                "</Diagnosises>\n";
        StringBuffer stringBuffer = new StringBuffer();
        if(null!=infos&&infos.size()>0){
            for (WlyyPrescriptionInfoDO wlyyPrescriptionInfoDO:infos){
                int i = 1;
                stringBuffer.append("<Advice REPEAT=\"1\" DRUG_LO_NAME=\""+wlyyPrescriptionInfoDO.getDrugName()+
                        "\" DRUG_LO_ID=\""+wlyyPrescriptionInfoDO.getHisCode()+"\" ADMINISTRATION=\""+wlyyPrescriptionInfoDO.getSupplyName()+
                        "\" DOSAGE=\""+wlyyPrescriptionInfoDO.getDosage()+
                        "\" DOSAGE_UNIT=\""+wlyyPrescriptionInfoDO.getUnitName()+
                        "\" FREQ_COUNT=\""+wlyyPrescriptionInfoDO.getUsageCode()+
                        "\" FREQ_INTERVAL=\"\" FREQ_INTERVAL_UNIT=\"\" START_DAY=\""+patientAndDoctor.getString("CREATE_DATE")+"\" END_DAY=\"\"" +
                        " DEPT_CODE=\""+patientAndDoctor.getString("DEPT_CODE")+"\" DOCTOR_NAME=\""+patientAndDoctor.getString("DOCTOR_NAME")+
                        "\" ORDER_NO=\""+i+
                        "\" ORDER_SUB_NO=\""+1+"\" AUTHORITY_LEVELS=\"\" ALERT_LEVELS=\"\" TITLE=\""+patientAndDoctor.getString("POSITION") +
                        "\" GROUP_ID=\""+i+"\" USER_ID=\""+patientAndDoctor.getString("DOCTOR_ID")+
                        "\" PRES_ID=\""+patientAndDoctor.getString("PATIENT_PRES_ID")+
                        "\" PRES_DATE=\""+patientAndDoctor.getString("CREATE_DATE")+
                        "\" PRES_SEQ_ID=\""+patientAndDoctor.getString("PATIENT_PRES_ID")+
                        "\" PK_ORDER_NO=\"\" COURSE=\""+wlyyPrescriptionInfoDO.getDays()+
                        "\" PKG_COUNT=\""+wlyyPrescriptionInfoDO.getPackQuantity()+
                        "\" PKG_UNIT=\""+wlyyPrescriptionInfoDO.getPackUnitName()+"\" BAK_01=\"\" BAK_02=\"\" BAK_03=\""+wlyyPrescriptionInfoDO.getUnitName()+
                        "\" BAK_04=\""+wlyyPrescriptionInfoDO.getSpecification()+
                        "\" BAK_05=\""+wlyyPrescriptionInfoDO.getDrugPlace()+"\"  />");
                i++;
            }
        }
        String checkInfos = "<Advices></Advices>";
        if (!isDelete){
            checkInfos= "<Advices>"+stringBuffer.toString()+"</Advices>";
        }
        String postBody = "<CheckInput TAG=\"2\" INPATIENT=\"否\">"+checkDoctor+checkPatient+checkDiagnosises+checkInfos+"</CheckInput>";
        return postBody;
    }
    /*
     *合理用药审核接口
     */
    public String checkPrescription(JSONObject patientAndDoctor,List<WlyyPrescriptionInfoDO> infos) throws Exception{
        String postBody = checkPrescriptionInfoParam(patientAndDoctor,infos,false);
        logger.info("发送的报文参数:"+postBody);
        String res =  httpClientUtil.sendPost(checkInfosUrl,postBody);
        logger.info("返回的报文参数:"+res);
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        wlyyHttpLogDO.setDoctor(patientAndDoctor.getString("doctorId"));
        wlyyHttpLogDO.setCreateTime(new Date());
        wlyyHttpLogDO.setRequest(postBody);
        wlyyHttpLogDO.setResponse(res);
        wlyyHttpLogDO.setName("checkPrescriptionInEntrance");
        return  res;
    }
    /*
     *合理用药保存接口
     */
    public String saveCheckPrescription(JSONObject patientAndDoctor,List<WlyyPrescriptionInfoDO> infos) throws Exception{
        String postBody = checkPrescriptionInfoParam(patientAndDoctor,infos,false);
        logger.info("保存处方的报文参数:"+postBody);
        String res =  httpClientUtil.sendPost(saveTianJiPrescription,postBody);
        logger.info("保存处方的报文参数:"+res);
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        wlyyHttpLogDO.setDoctor(patientAndDoctor.getString("doctorId"));
        wlyyHttpLogDO.setCreateTime(new Date());
        wlyyHttpLogDO.setRequest(postBody);
        wlyyHttpLogDO.setResponse(res);
        wlyyHttpLogDO.setName("checkPrescriptionInEntrance");
        return  res;
    }
    /*
     *合理用药作废接口
     */
    public String deleteCheckPrescription(JSONObject patientAndDoctor,List<WlyyPrescriptionInfoDO> infos) throws Exception{
        String postBody = checkPrescriptionInfoParam(patientAndDoctor,infos,true);
        logger.info("作废的报文参数:"+postBody);
        logger.info("deleteTianJiPrescription:"+deleteTianJiPrescription);
        String res =  httpClientUtil.sendPost(deleteTianJiPrescription,postBody);
        logger.info("作废的报文参数:"+res);
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        wlyyHttpLogDO.setDoctor(patientAndDoctor.getString("doctorId"));
        wlyyHttpLogDO.setCreateTime(new Date());
        wlyyHttpLogDO.setRequest(postBody);
        wlyyHttpLogDO.setResponse(res);
        wlyyHttpLogDO.setName("checkPrescriptionInEntrance");
        return  res;
    }
    public List<Map<String,Object>> transXmlCommen(String xml){
        Document doc = null;
        List<Map<String,Object>> returnMap= new ArrayList<>();
        try {
            doc = (new Builder()).build(new StringReader(xml));
            Element root = doc.getRootElement();
            Elements elements = root.getChildElements();
            for (int i=0;i<elements.size();i++){
               Map<String,Object> personInfoMap = new HashMap<>();
                Element personInfo = elements.get(i);
                for (int j=0;j<personInfo.getAttributeCount();j++){
                    Attribute attribute = personInfo.getAttribute(j);
                    personInfoMap.put(attribute.getLocalName(),attribute.getValue());
                }
                List<Map<String,Object>> checkInfoMapList= new ArrayList<>();
                if (personInfo.getChildElements().size()>0){
                    Elements checkInfos = personInfo.getChildElements();
                    for(int ci=0;ci<checkInfos.size();ci++){
                        Element checkInfo = checkInfos.get(ci);
                        Map<String,Object> checkInfoMap = new HashMap<>();
                        for (int n = 0;n<checkInfo.getAttributeCount();n++){
                            Attribute attribute2 = checkInfo.getAttribute(n);
                            checkInfoMap.put(attribute2.getLocalName(),attribute2.getValue());
                        }
                        checkInfoMapList.add(checkInfoMap);
                    }
                }
                personInfoMap.put("checkInfoMapList",checkInfoMapList);
                returnMap.add(personInfoMap);
            }
        } catch (ParsingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
      return returnMap;
    }
    public  List<PersonInfoVO>  transXml(String xml) throws  Exception {
        Document doc = (new Builder()).build(new StringReader(xml));
        Element root = doc.getRootElement();
        Elements presInfos = root.getChildElements("PresInfo");
        List<PersonInfoVO> personInfoVOS = new ArrayList<>();
        for (int i=0;i<presInfos.size();i++){
            PersonInfoVO personInfoVO = new PersonInfoVO();
            List<CheckInfoVO> checkInfoVOS = new ArrayList<>();
            Element presInfo  = presInfos.get(i);
            personInfoVO.setDrugLoId(presInfo.getAttributeValue("DRUG_LO_ID"));
            personInfoVO.setDrugLoName(presInfo.getAttributeValue("DRUG_LO_NAME"));
            personInfoVO.setOrderId(presInfo.getAttributeValue("ORDER_ID"));
            personInfoVO.setOrderSubId(presInfo.getAttributeValue("ORDER_SUB_ID"));
            Elements checkinfos  = presInfo.getChildElements();
            if (checkinfos.size()>0){
                for (int j=0;j<checkinfos.size();j++){
                    CheckInfoVO checkInfoVO = new CheckInfoVO();
                    Element checkinfo = checkinfos.get(j);
                    checkInfoVO.setColor(checkinfo.getAttributeValue("COLOR"));
                    checkInfoVO.setName(checkinfo.getAttributeValue("NAME"));
                    checkInfoVO.setRefResource(checkinfo.getAttributeValue("REF_SOURCE"));
                    checkInfoVO.setWarningInfo(checkinfo.getAttributeValue("WARNING_INFO"));
                    checkInfoVO.setWarningLevel(checkinfo.getAttributeValue("WARNING_LEVEL"));
                    checkInfoVOS.add(checkInfoVO);
                }
                personInfoVO.setCheckInfoVOS(checkInfoVOS);
            }
            personInfoVOS.add(personInfoVO);
        }
        return personInfoVOS;
    }
    /**
     * 同步门诊病历
     * @return
     */
    public String returnEmrHtmlByHLW(JSONObject jsonObject,WlyyPrescriptionEmrDO prescriptionEmrDO)throws Exception{
        String api = "returnEmrHtmlByHLW";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator></callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        String htmlDeo = "";
        if (null!=prescriptionEmrDO){
            WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("EMRHTMLDEMO");
            if (null!=wlyyHospitalSysDictDO){
                htmlDeo = wlyyHospitalSysDictDO.getDictValue();
                htmlDeo = htmlDeo.replace("@patientName@",jsonObject.getString("patientName"));
                htmlDeo = htmlDeo.replace("@patientAge@",jsonObject.getString("patientAge"));
                htmlDeo = htmlDeo.replace("@patientsex@",jsonObject.getString("patientsex"));
                htmlDeo = htmlDeo.replace("@deptCode@",jsonObject.getString("deptCode"));
                htmlDeo = htmlDeo.replace("@r+outpatientCode@",jsonObject.getString("outpatientCode"));
                htmlDeo = htmlDeo.replace("@patientClan@",jsonObject.getString("patientClan"));
                htmlDeo = htmlDeo.replace("@Special@",prescriptionEmrDO.getSpecialHistory());
                SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd hh:MM");
                htmlDeo = htmlDeo.replace("@createTime@",sf.format(prescriptionEmrDO.getCreateTime()));
                htmlDeo = htmlDeo.replace("@complaint@",prescriptionEmrDO.getComplaint());
                htmlDeo = htmlDeo.replace("@medicalHistory@",prescriptionEmrDO.getMedicalHistory());
                htmlDeo = htmlDeo.replace("@popularHistory@",prescriptionEmrDO.getPopularHistory());
                htmlDeo = htmlDeo.replace("@pastHistory@",prescriptionEmrDO.getPastHistory());
                htmlDeo = htmlDeo.replace("@allergicHistory@",prescriptionEmrDO.getAllergicHistory());
                htmlDeo = htmlDeo.replace("@physicalExamination@",prescriptionEmrDO.getPhysicalExamination());
                htmlDeo = htmlDeo.replace("@assistExamination@",prescriptionEmrDO.getAssistExamination());
                condition+="<content>"+htmlDeo+"</content>";
            }
        }
        if ( null!=jsonObject.get("patientid")) {
            condition+="<patientid>"+jsonObject.getString("patientid")+"</patientid>";
        }
        if (!StringUtils.isEmpty(status)){
            condition += "<status>"+status+"</status>";
        if ( null!=jsonObject.get("eventno")) {
            condition+="<eventno>"+jsonObject.getString("eventno")+"</eventno>";
        }
        if ( null!=jsonObject.get("type")) {
            condition+="<type>"+jsonObject.getString("type")+"</type>";
        }
        if ( null!=jsonObject.get("templateid")) {
            condition+="<templateid>"+jsonObject.getString("templateid")+"</templateid>";
        }
        if ( null!=jsonObject.get("emrtitle")) {
            condition+="<emrtitle>"+jsonObject.getString("emrtitle")+"</emrtitle>";
        }
        if (null!=jsonObject.get("catalogid")){
            condition += "<catalogid>"+jsonObject.getString("catalogid")+"</catalogid>";
        }
        if (null!=jsonObject.get("operatorname")){
            condition += "<operatorname>"+jsonObject.getString("operatorname")+"</operatorname>";
        }
        if (null!=jsonObject.get("operatorid")){
            condition += "<operatorid>"+jsonObject.getString("operatorid")+"</operatorid>";
        }
        if (null!=jsonObject.get("emrtype")){
            condition += "<emrtype>"+jsonObject.getString("emrtype")+"</emrtype>";
        }
        if (null!=jsonObject.get("id")){
            condition += "<id>"+jsonObject.getString("id")+"</id>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("updatePreStatus params:"+params.toString());
        String xml = getXzzxWebServiceInfo("UpdatePreStatus",params,getOperateUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("updatePreStatus json:"+json);
        return json;
        logger.info("returnEmrHtmlByHLW params:"+params.toString());
        String xml = getXzzxWebServiceInfo("CallInterface",params,getOperateUrl());
        logger.info("returnEmrHtmlByHLW json:"+xml);
        return xml;
    }
//=====================微信模板消息推送===================================
@ -1119,7 +1900,6 @@ public class XzzxEntranceService{
            return array;
        }
        return null;
    }
@ -1251,6 +2031,39 @@ public class XzzxEntranceService{
        return patientMappingDO.getMappingCode();
    }
    public String updatePatientMapping(String patient,String cardNo){
        BasePatientDO patientDO = patientDao.findById(patient);
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
        String response="";
        String idCard = patientDO.getIdcard();
        String url = entranceUrl+"findPatientCard?idCard="+idCard;
        response = httpClientUtil.get(url,"GBK");
        JSONObject object = JSONObject.parseObject(response);
        if(object.getInteger("status")==200){
            String obj = object.getString("obj");
            JSONArray array = JSONArray.parseArray(obj).getJSONArray(0);
            for (int i=0;i<array.size();i++){
                JSONObject object1 = array.getJSONObject(i);
                if (object1.getString("CARD_NO").equalsIgnoreCase(cardNo)){
                    if (patientMappingDO==null){
                        patientMappingDO = new PatientMappingDO();
                        patientMappingDO.setIdcard(patientDO.getIdcard());
                        patientMappingDO.setPatientName(patientDO.getName());
                        patientMappingDO.setPatient(patientDO.getId());
                        patientMappingDO.setCreateTime(new Date());
                        patientMappingDO.setSource("1");
                        patientMappingDO.setMappingCode(object1.getString("SICKID"));
                    }else {
                        patientMappingDO.setMappingCode(object1.getString("SICKID"));
                    }
                    patientMappingDO = patientMappingDao.save(patientMappingDO);
                }
            }
        }
        return patientMappingDO.getMappingCode();
    }
    /**
     * 获取门诊就诊记录列表
     * @param patient 居民id
@ -1351,7 +2164,7 @@ public class XzzxEntranceService{
                outpatientVO.setHospitalName("厦门大学附属心血管病医院");
                outpatientVO.setHospital("350211A5010");
                outpatientVO.setSex(patientDO.getSex()+"");
                outpatientVO.setPatient(patient);
                outpatientVO.setPatient(patientDO.getId());
                outpatientVO.setBirthday(patientDO.getBirthday());
            }
        }
@ -1817,6 +2630,502 @@ public class XzzxEntranceService{
    }
    /**
     * 获取icd10字典
     * @param spellCode 拼音码
     * @return
     */
    public JSONArray selectIcd10Dict(String spellCode) throws Exception {
        String response="";
        String url = entranceUrl+"getICD10Dict?spellCode="+spellCode;
        response = httpClientUtil.get(url,"GBK");
        JSONObject object = JSONObject.parseObject(response);
        JSONArray jsonArray = new JSONArray();
        if(object.getInteger("status")==200){
            String obj = object.getString("obj");
            JSONArray array = JSONArray.parseArray(obj).getJSONArray(0);
            for (int i=0;i<array.size();i++){
                JSONObject jsonObject = array.getJSONObject(i);
                JSONObject object1 = new JSONObject();
                object1.put("@action","select");
                object1.put("add_code","");
                object1.put("code",jsonObject.getString("ICD10_CODE"));
                object1.put("d_code",jsonObject.getString(""));
                object1.put("name",jsonObject.getString("ICD10_NAME"));
                object1.put("py_code",jsonObject.getString("SPELL_CODE"));
                object1.put("valid_flag",jsonObject.getString("VALID_FLAG"));
                object1.put("icd10_type",jsonObject.getString("ICD10_TYPE"));
                object1.put("icd10_class",jsonObject.getString("ICD10_CLASS"));
                jsonArray.add(object1);
            }
        }
        return jsonArray;
    }
    /**
     * 获取药品字典
     * @param spellCode 拼音码
     * @return
     */
    public JSONArray selectDrugDict(String spellCode) throws Exception {
        String response="";
        String url = entranceUrl+"getDrugDict?spellCode="+spellCode;
        response = httpClientUtil.get(url,"GBK");
        JSONObject object = JSONObject.parseObject(response);
        JSONArray jsonArray = new JSONArray();
        if(object.getInteger("status")==200){
            String obj = object.getString("obj");
            JSONArray array = JSONArray.parseArray(obj).getJSONArray(0);
            for (int i=0;i<array.size();i++){
                JSONObject jsonObject = array.getJSONObject(i);
                JSONObject object1 = new JSONObject();
                object1.put("@action","select");
                object1.put("charge_code",jsonObject.getString("PHYSIC_CODE"));
                object1.put("serial","");
                object1.put("group_no","");
                object1.put("drugname",jsonObject.getString("PHYSIC_NAME"));
                object1.put("dosage",jsonObject.getString("DOSE_UNIT"));
                object1.put("MIN_DOSE",jsonObject.getString("MIN_DOSE"));
                object1.put("mini_unit",jsonObject.getString("PHYSIC_UNIT"));
                object1.put("pack_size",jsonObject.getString("PACK_SPEC"));
                object1.put("retprice",jsonObject.getString("RETAIL_PRICE"));
                object1.put("specification",jsonObject.getString("PHYSIC_SPEC"));
                object1.put("pack_retprice",jsonObject.getString("RETAIL_PRICE"));
                object1.put("stock_amount","");
                object1.put("visible_flag",jsonObject.getString("VALID_FLAG"));
                object1.put("drug_flag",jsonObject.getString("OTC_FLAG"));
                object1.put("py_code",jsonObject.getString("SPELL_CODE"));
                object1.put("pack_unit",jsonObject.getString("PRICE_UNIT"));
                object1.put("manu_name",jsonObject.getString("SUPPLIER_NAME"));
                object1.put("weigh_unit",jsonObject.getString("DOSE_UNIT"));
                object1.put("vol_unit","");
                object1.put("mini_unit_name",jsonObject.getString("PHYSIC_UNIT"));
                object1.put("pack_unit_name",jsonObject.getString("PRICE_UNIT"));
                object1.put("weigh_unit_name",jsonObject.getString("DOSE_UNIT"));
                object1.put("vol_unit_name","");
                object1.put("win_no","");
                object1.put("jbyw",jsonObject.getString("BASE_PHYSIC_FLAG"));
                object1.put("gwyp","");
                object1.put("bz_dosage",jsonObject.getString("DOSEAGE"));
                object1.put("bz_supply",jsonObject.getString("USAGE"));
                object1.put("bz_supply_name",jsonObject.getString("USAGE"));
                object1.put("bz_unit",jsonObject.getString("DOSEAGE_UNIT"));
                object1.put("bz_unit_name",jsonObject.getString("DOSEAGE_UNIT"));
                object1.put("bz_usage",jsonObject.getString("FREQUENCY"));
                object1.put("bz_usage_name",jsonObject.getString("FREQUENCY"));
                object1.put("QUANTITY",jsonObject.getString("QUANTITY"));
                object1.put("DAY_COUNT",jsonObject.getString("DAY_COUNT"));
                jsonArray.add(object1);
            }
        }
        return jsonArray;
    }
    /**
     * 查询药品用药方法
     * @param spellCode 拼音码
     * @return
     */
    public JSONArray selectMedicineUsed(String spellCode) throws Exception {
        String response="";
        String url = entranceUrl+"getMedicineUsed?spellCode="+spellCode;
        response = httpClientUtil.get(url,"GBK");
        JSONObject object = JSONObject.parseObject(response);
        JSONArray jsonArray = new JSONArray();
        if(object.getInteger("status")==200){
            String obj = object.getString("obj");
            JSONArray array = JSONArray.parseArray(obj).getJSONArray(0);
            for (int i=0;i<array.size();i++){
                JSONObject jsonObject = array.getJSONObject(i);
                JSONObject object1 = new JSONObject();
                object1.put("@action","select");
                object1.put("d_code",jsonObject.getString("ITEM_CODE"));
                object1.put("supply_code",jsonObject.getString("TAKE_MEDICINE_WAYS_CODE"));
                object1.put("supply_name",jsonObject.getString("TAKE_MEDICINE_WAYS_NAME"));
                object1.put("py_code",jsonObject.getString("SPELL_CODE"));
                object1.put("del_flag","");
                object1.put("yb_code","");
                object1.put("yb_name",jsonObject.getString("MEMO"));
                object1.put("print_name",jsonObject.getString("TAKE_MEDICINE_WAYS_NAME"));
                jsonArray.add(object1);
            }
        }
        return jsonArray;
    }
    /**
     * 获取药品用药频次字典
     * @return
     */
    public JSONArray selectFrequencyDict() throws Exception {
        String response="";
        String url = entranceUrl+"getFrequencyDict";
        response = httpClientUtil.get(url,"GBK");
        JSONObject object = JSONObject.parseObject(response);
        JSONArray jsonArray = new JSONArray();
        if(object.getInteger("status")==200){
            String obj = object.getString("obj");
            JSONArray array = JSONArray.parseArray(obj).getJSONArray(0);
            for (int i=0;i<array.size();i++){
                JSONObject jsonObject = array.getJSONObject(i);
                JSONObject object1 = new JSONObject();
                object1.put("@action","select");
                object1.put("DAILY_TIMES",jsonObject.getString("FREQ_COUNT"));
                object1.put("FREQ_CODE",jsonObject.getString("FREQ_DESCRIBE"));
                object1.put("FREQ_DESCRIBE_CODE",jsonObject.getString("FREQ_DESCRIBE_CODE"));
                object1.put("FREQ_DESCRIBE",jsonObject.getString("FREQ_DESCRIBE"));
                object1.put("PHYSIC_NOTUSE_FLAG",jsonObject.getString("PHYSIC_NOTUSE_FLAG"));
                object1.put("FREQ_NAME",jsonObject.getString("FREQ_MEMO"));
                object1.put("INSUR_FREQ_DESCRIBE",jsonObject.getString("INSUR_FREQ_DESCRIBE"));
                object1.put("FREQ_INTERVAL",jsonObject.getString("FREQ_INTERVAL"));
                object1.put("FREQ_INTERVAL_UNIT",jsonObject.getString("FREQ_INTERVAL_UNIT"));
                object1.put("DEFAULT_SCHEDULE",jsonObject.getString("DEFAULT_SCHEDULE"));
                object1.put("EXECUTE_TIME_FLAG",jsonObject.getString("EXECUTE_TIME_FLAG"));
                object1.put("DAY_FLAG",jsonObject.getString("DAY_FLAG"));
                object1.put("WEEK_FLAG",jsonObject.getString("WEEK_FLAG"));
                object1.put("WEEK_1",jsonObject.getString("WEEK_1"));
                object1.put("WEEK_2",jsonObject.getString("WEEK_2"));
                object1.put("WEEK_3",jsonObject.getString("WEEK_3"));
                object1.put("WEEK_4",jsonObject.getString("WEEK_4"));
                object1.put("WEEK_5",jsonObject.getString("WEEK_5"));
                object1.put("WEEK_6",jsonObject.getString("WEEK_6"));
                object1.put("WEEK_7",jsonObject.getString("WEEK_7"));
                object1.put("SPELL_CODE",jsonObject.getString("SPELL_CODE"));
                object1.put("VALID_FLAG",jsonObject.getString("VALID_FLAG"));
                object1.put("WEEKLY_TIMES","");
                object1.put("IS_OP_IP","");
                object1.put("HOSP_CODE","");
                object1.put("FREQ_SP",jsonObject.getString("MEMO"));
                jsonArray.add(object1);
            }
        }
        return jsonArray;
    }
    /**
     * 查询检查部位
     * @param spellCode 拼音码
     * @return
     */
    public JSONArray selectCheckBody(String spellCode) throws Exception {
        String response="";
        String url = entranceUrl+"getCheckBody?spellCode="+spellCode;
        response = httpClientUtil.get(url,"GBK");
        JSONObject object = JSONObject.parseObject(response);
        JSONArray jsonArray = new JSONArray();
        if(object.getInteger("status")==200){
            String obj = object.getString("obj");
            JSONArray array = JSONArray.parseArray(obj).getJSONArray(0);
            for (int i=0;i<array.size();i++){
                JSONObject jsonObject = array.getJSONObject(i);
                JSONObject object1 = new JSONObject();
                object1.put("@action","select");
                object1.put("name",jsonObject.getString("NAME"));
                object1.put("code",jsonObject.getString("CODE"));
                object1.put("data",jsonObject.getString("DATA"));
                object1.put("py_code",jsonObject.getString("SPELL_CODE"));
                object1.put("memo",jsonObject.getString("MEMO"));
                object1.put("wb_code",jsonObject.getString("WBZX_CODE"));
                object1.put("sequence",jsonObject.getString("SEQUENCE"));
                object1.put("valid",jsonObject.getString("VALID"));
                jsonArray.add(object1);
            }
        }
        return jsonArray;
    }
    /**
     * 查询检查项目
     * @param spellCode 拼音码或药品名字
     * @return
     */
    public JSONArray selectExamApply(String spellCode) throws Exception {
        String response="";
        String url = entranceUrl+"getExamApply?spellCode="+spellCode;
        response = httpClientUtil.get(url,"GBK");
        JSONObject object = JSONObject.parseObject(response);
        JSONArray jsonArray = new JSONArray();
        if(object.getInteger("status")==200){
            String obj = object.getString("obj");
            JSONArray array = JSONArray.parseArray(obj).getJSONArray(0);
            for (int i=0;i<array.size();i++){
                JSONObject jsonObject = array.getJSONObject(i);
                JSONObject object1 = new JSONObject();
                object1.put("@action","select");
                object1.put("name",jsonObject.getString("ITEM_NAME"));
                object1.put("code",jsonObject.getString("ITEM_CODE"));
                object1.put("type",jsonObject.getString("ITEM_CLASS"));
                object1.put("py_code",jsonObject.getString("SPELL_CODE"));
                object1.put("charge_amount",jsonObject.getString("FACT_PRICE"));
                object1.put("child_amount",jsonObject.getString("CHILD_PRICE"));
                object1.put("charge_unit",jsonObject.getString("UNIT"));
                object1.put("wb_code",jsonObject.getString("FIVE_PEN_CODE"));
                object1.put("memo",jsonObject.getString("MEMO"));
                jsonArray.add(object1);
            }
        }
        return jsonArray;
    }
    /**
     * 查询检验项目
     * @param spellCode 拼音码或药品名字
     * @return
     */
    public JSONArray selectLisApply(String spellCode) throws Exception {
        String response="";
        String url = entranceUrl+"getLisApply?spellCode="+spellCode;
        response = httpClientUtil.get(url,"GBK");
        JSONObject object = JSONObject.parseObject(response);
        JSONArray jsonArray = new JSONArray();
        if(object.getInteger("status")==200){
            String obj = object.getString("obj");
            JSONArray array = JSONArray.parseArray(obj).getJSONArray(0);
            for (int i=0;i<array.size();i++){
                JSONObject jsonObject = array.getJSONObject(i);
                JSONObject object1 = new JSONObject();
                object1.put("@action","select");
                object1.put("name",jsonObject.getString("ITEM_NAME"));
                object1.put("code",jsonObject.getString("ITEM_CODE"));
                object1.put("type",jsonObject.getString("ITEM_CLASS"));
                object1.put("py_code",jsonObject.getString("SPELL_CODE"));
                object1.put("charge_amount",jsonObject.getString("FACT_PRICE"));
                object1.put("child_amount",jsonObject.getString("CHILD_PRICE"));
                object1.put("charge_unit",jsonObject.getString("UNIT"));
                object1.put("wb_code",jsonObject.getString("FIVE_PEN_CODE"));
                object1.put("memo",jsonObject.getString("MEMO"));
                jsonArray.add(object1);
            }
        }
        return jsonArray;
    }
/**
 * 检查检验项目同步his
 * @param
 * @return
 */
public Map checkSyncHis(String IoFlag,String PayCardNo,String NullahNumber,String ApplyDept,String ApplyDoctor,String wlyyInspectionS) throws Exception {
    String response="";
    Map resultMap=new HashMap();
    String url = entranceUrl+"saveInspectToHospital?IoFlag="+IoFlag+"&PayCardNo="+PayCardNo+"&NullahNumber="+NullahNumber+
            "&ApplyDept="+ApplyDept+
            "&ApplyDoctor="+ApplyDoctor+"&wlyyInspectionS="+wlyyInspectionS;
    response = httpClientUtil.get(url,"GBK");
    JSONObject object = JSONObject.parseObject(response);
    if(object.getInteger("status")==200){
        String obj = object.getString("obj");
        JSONObject rootObject = JSONObject.parseObject(obj);
        if (null!=rootObject&&"0".equalsIgnoreCase(rootObject.getString("code"))){
            resultMap.put("success",rootObject.getString("success"));
            resultMap.put("code",rootObject.getString("code"));
            resultMap.put("msg",rootObject.getString("msg"));
            JSONObject dataObj = JSONObject.parseObject(rootObject.getString("data"));
            if (null!=dataObj){
                JSONObject presDetailobj = JSONObject.parseObject(dataObj.getString("PresDetail"));
                resultMap.put("msg",presDetailobj.getString("PresNo"));
                logger.info("his医嘱号:"+presDetailobj.getString("PresNo"));
            }
        }else if(null!=rootObject&&!"0".equalsIgnoreCase(rootObject.getString("code"))){
            resultMap.put("success",rootObject.getString("success"));
            resultMap.put("code",rootObject.getString("code"));
            resultMap.put("msg",rootObject.getString("msg"));
        }else {
            resultMap.put("success","obj转化失败");
        }
    }else {
        resultMap.put("success","调用entrance接口返回失败");
    }
    return resultMap;
}
    /**
     * 保存处方到entrance
     * @param ioFlag 门诊住院标志
     * @param payCardNo 就诊卡号
     * @param nullahNumber 挂号流水号
     * @param applyDept 执行科室
     * @param applyDoctor 开单医生
     * @param executeDept 执行科室(药房)
     * @return
     * @throws Exception
     */
    public JSONObject savePrescriptionToEntrance(String ioFlag,String payCardNo,String nullahNumber,String applyDept,String applyDoctor,String executeDept,List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS) throws Exception {
        JSONObject jsonObject = new JSONObject();
        String response = "";
        String url = entranceUrl+"savePrescriptionToHospital";
        ObjectMapper mapper = new ObjectMapper();
        JSONArray array = new JSONArray();
        for (WlyyPrescriptionInfoDO wlyyPrescriptionInfoDO:wlyyPrescriptionInfoDOS){
            array.add(wlyyPrescriptionInfoDO);
        }
        Map<String,String> params = new HashedMap();
        params.put("IoFlag",ioFlag);
        params.put("PayCardNo",payCardNo);
        params.put("NullahNumber",nullahNumber);
        params.put("ApplyDept",applyDept);
        params.put("ApplyDoctor",applyDoctor);
        params.put("ExecuteDept",executeDept);
        params.put("prescriptionInfoDOS", array.toJSONString());
        logger.info("prescriptionInfoDOS"+params.get("prescriptionInfoDOS"));
        logger.info("params"+params.toString());
        response = httpClientUtil.httpPost(url,params);
        logger.info("开方成功"+response);
        JSONObject object = JSONObject.parseObject(response);
        if(object.getInteger("status")==200){
             jsonObject = object.getJSONObject("obj");
        }
        return jsonObject;
    }
    /**
     * 保存诊断到entrance
     * @param applyNo 必填,流水号
     * @param diagnosisName 必填,诊断名称
     * @param diagnosisCode 诊断代码
     * @return
     * @throws Exception
     */
    public JSONObject saveDiagnosisToEntrance(String applyNo,String diagnosisName,String diagnosisCode) throws Exception {
        JSONObject jsonObject = new JSONObject();
        String response = "";
        String url = entranceUrl+"saveDiagnosis";
        ObjectMapper mapper = new ObjectMapper();
        Map<String,String> params = new HashedMap();
        params.put("ApplyNo",applyNo);
        params.put("DiagnosisName",diagnosisName);
        params.put("DiagnosisCode",diagnosisCode);
        logger.info("params"+params.toString());
        response = httpClientUtil.httpPost(url,params);
        logger.info("诊断同步"+response);
        JSONObject object = JSONObject.parseObject(response);
        if(object.getInteger("status")==200){
            jsonObject = object.getJSONObject("obj");
        }
        return jsonObject;
    }
    /**
     * 发送退号信息到entrance
     * @param applyNo 必填,流水号
     * @param payCardNo 必填,卡号
     * @return
     * @throws Exception
     */
    public JSONObject refundConsultationToEntrance(String applyNo,String payCardNo) throws Exception {
        JSONObject jsonObject = new JSONObject();
        String response = "";
        String url = entranceUrl+"refundConsultation";
        ObjectMapper mapper = new ObjectMapper();
        Map<String,String> params = new HashedMap();
        params.put("ApplyNo",applyNo);
        params.put("PayCardNo",payCardNo);
        logger.info("params"+params.toString());
        response = httpClientUtil.httpPost(url,params);
        logger.info("诊断同步"+response);
        JSONObject object = JSONObject.parseObject(response);
        if(object.getInteger("status")==200){
            jsonObject = object.getJSONObject("obj");
        }
        return jsonObject;
    }
    /**
     * 删除处方信息
     * @param realOrder his处方号
     * @return
     * @throws Exception
     */
    public JSONObject deletePrescriptionToEntrance(String realOrder) throws Exception {
        Map<String,String> params = new HashedMap();
        WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findByRealOrder(realOrder);
        if (null!=wlyyPrescriptionDO){
            params.put("IoFlag","0");
            WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(wlyyPrescriptionDO.getOutpatientId());
            if (null!=wlyyOutpatientDO){
                params.put("PayCardNo",wlyyOutpatientDO.getCardNo());
                params.put("NullahNumber",wlyyOutpatientDO.getRegisterNo());
                params.put("ApplyDept",wlyyOutpatientDO.getDept());
            }
            DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(wlyyPrescriptionDO.getDoctor());
            if (null!=doctorMappingDO){
                params.put("ApplyDoctor",doctorMappingDO.getMappingCode());
            }
            params.put("ExecuteDept","50100");
            params.put("PresNo",realOrder);
        }
        JSONObject jsonObject = new JSONObject();
        String response = "";
        String url = entranceUrl+"delHisPrescriptionByHisNo";
        logger.info("params"+params.toString());
        response = httpClientUtil.httpPost(url,params);
        logger.info("删除处方信息"+response);
        JSONObject object = JSONObject.parseObject(response);
        if(object.getInteger("status")==200){
            jsonObject = object.getJSONObject("obj");
        }
        return jsonObject;
    }
    /**
     * 保存电子病历
     * @param prescriptionId 处方id
     * @return
     * @throws Exception
     */
    public JSONObject saveEmrToEntrance(String prescriptionId) throws Exception {
        Map<String,String> params = new HashedMap();
        WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findOne(prescriptionId);
        JSONObject paramRequest = new JSONObject();
        if (null!=wlyyPrescriptionDO){
            paramRequest.put("patientName",wlyyPrescriptionDO.getPatientName());
            PatientMappingDO patientMappingDO =  patientMappingDao.findByPatient(wlyyPrescriptionDO.getPatientCode());
            BasePatientDO basePatientDO = basePatientDao.findById(wlyyPrescriptionDO.getPatientCode());
            DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(wlyyPrescriptionDO.getDoctor());
            WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(wlyyPrescriptionDO.getOutpatientId());
            if(null!=patientMappingDO){
                paramRequest.put("patientid",patientMappingDO.getMappingCode());
            }
            if(null!=doctorMappingDO){
                paramRequest.put("operatorid",doctorMappingDO.getMappingCode());
                paramRequest.put("operatorname",wlyyPrescriptionDO.getDoctorName());
            }
            paramRequest.put("type","2");
            WlyyPrescriptionEmrDO wlyyPrescriptionEmrDO =  prescriptionEmrDao.findEmrByPrescriptionId(prescriptionId);
            if (null!=wlyyPrescriptionEmrDO){
                paramRequest.put("id",wlyyPrescriptionEmrDO.getId());
                params.put("emrInfo",JSON.toJSONString(wlyyPrescriptionEmrDO));
            }
            if (null!=basePatientDO){
                paramRequest.put("patientAge",IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard()));
                paramRequest.put("patientsex",IdCardUtil.getSexForIdcard(basePatientDO.getIdcard()));
                paramRequest.put("patientName",basePatientDO.getName());
                paramRequest.put("patientClan","0");
            }
            if (null!=wlyyOutpatientDO){
                paramRequest.put("deptCode",wlyyOutpatientDO.getDept());
                paramRequest.put("outpatientCode","R"+wlyyOutpatientDO.getRegisterNo());
                paramRequest.put("eventno","R"+wlyyOutpatientDO.getRegisterNo());
            }
            paramRequest.put("templateid","662");
            paramRequest.put("catalogid","50");
            paramRequest.put("emrtype","0");
            paramRequest.put("emrtitle","互联网医院");
        }
        params.put("jsonInfo",paramRequest.toJSONString());
        JSONObject jsonObject = new JSONObject();
        String response = "";
        String url = entranceUrl+"returnEmrHtmlByHLW";
        logger.info("params"+params.toString());
        response = httpClientUtil.httpPost(url,params);
        logger.info("保存电子病历"+response);
        JSONObject object = JSONObject.parseObject(response);
        if(object.getInteger("status")==200){
            jsonObject = object.getJSONObject("obj");
        }
        return jsonObject;
    }
//=====================hospital应用调用entrance应用============end=================
@ -2009,9 +3318,228 @@ public class XzzxEntranceService{
        }
        return map;
    }
    //组装审药参数并发送到entrance
    public String checkInputInfo(String hisId,String payType,String doctor,String patient,List<WlyyPrescriptionDiagnosisDO> diagnosisDOS,List<WlyyPrescriptionInfoDO> infos) throws Exception{
        JSONObject jsonObject = initEntranceParam(payType,doctor,patient,diagnosisDOS);
        //如果重新审核药品 一定要把返回的orderNo的值拿到赋值到prescriptionId里
        if (StringUtils.isNotEmpty(hisId)){
            jsonObject.put("PATIENT_PRES_ID",hisId);
        }else {
            hisId = UUID.randomUUID().toString();
            jsonObject.put("PATIENT_PRES_ID",hisId);
        }
        if (null!=infos&&infos.size()>0) {
            String response = "";
            String returnJson = "";
            JSONArray array = new JSONArray();
            for (WlyyPrescriptionInfoDO infoDO:infos){
                array.add(infoDO);
            }
            String url = entranceUrl + "checkPrescription";
            Map<String,String> map = new HashedMap();
            map.put("infos",array.toJSONString());
            map.put("patientAndDoctor",jsonObject.toString());
            response = httpClientUtil.httpPost(url, map);
            logger.info("请求entrance的参数:"+map.toString());
            logger.info("请求checkPrescription:" + response);
            JSONObject object = JSONObject.parseObject(response);
            WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
            if (object.getInteger("status") == 200) {
                wlyyHttpLogDO.setCode("200");
                String obj = object.getString("obj");
                System.out.println("obj:"+obj);
                if (StringUtils.isNotBlank(obj)) {
                    List<Map<String,Object>> returnList = transXmlCommen(obj);
                    Map<String,Object> checkIdMap = new HashMap<>();
                    checkIdMap.put("prescriptionOnly",hisId);
                    returnList.add(checkIdMap);
                    returnJson = JSONArray.toJSONString(returnList);
                    logger.info("返回到互联网医院的解析后的结果:"+returnJson);
                    wlyyHttpLogDO.setDoctor(doctor);
                    wlyyHttpLogDO.setCreateTime(new Date());
                    wlyyHttpLogDO.setRequest(infos + jsonObject.toString());
                    wlyyHttpLogDO.setResponse(returnJson);
                    wlyyHttpLogDO.setName("checkPrescription");
                } else {
                    returnJson = "审方返回接口为空请检查参数是否正确";
                    logger.info(returnJson);
                    wlyyHttpLogDO.setCode("error");
                    wlyyHttpLogDO.setDoctor(doctor);
                    wlyyHttpLogDO.setCreateTime(new Date());
                    wlyyHttpLogDO.setRequest(infos + jsonObject.toString());
                    wlyyHttpLogDO.setResponse(returnJson);
                    wlyyHttpLogDO.setName("checkPrescription");
                }
            } else {
                returnJson = "entranceUrl接口调用失败";
                wlyyHttpLogDO.setCode("error");
                wlyyHttpLogDO.setDoctor(doctor);
                wlyyHttpLogDO.setCreateTime(new Date());
                wlyyHttpLogDO.setRequest(infos + jsonObject.toString());
                wlyyHttpLogDO.setResponse(returnJson);
                wlyyHttpLogDO.setName("checkPrescription");
            }
            wlyyHttpLogDao.save(wlyyHttpLogDO);
            return returnJson;
        }else {
            return "药品信息为空";
        }
    }
    //组装审药参数并发送到entrance保存处方
    public String saveCheckInputInfo(String prescriptionId,String payType,String doctor,String patient,List<WlyyPrescriptionDiagnosisDO> diagnosisDOS,List<WlyyPrescriptionInfoDO> infos) throws Exception{
        JSONObject jsonObject = initEntranceParam(payType,doctor,patient,diagnosisDOS);
        String tjPrescriptionId = "";
        //如果重新审核药品 一定要把返回的orderNo的值拿到赋值到prescriptionId里
        if (StringUtils.isNotEmpty(prescriptionId)) {
            tjPrescriptionId = prescriptionId;
            jsonObject.put("PATIENT_PRES_ID",tjPrescriptionId);
        }
        if (null!=infos&&infos.size()>0) {
            String response = "";
            String returnJson = "";
            JSONArray array = new JSONArray();
            for (WlyyPrescriptionInfoDO infoDO:infos){
                array.add(infoDO);
            }
            String url = entranceUrl + "saveCheckPrescription";
            Map<String,String> map = new HashedMap();
            map.put("infos",array.toJSONString());
            map.put("patientAndDoctor",jsonObject.toString());
            response = httpClientUtil.httpPost(url, map);
            logger.info("请求saveCheckPrescription参数:"+map.toString());
            logger.info("saveCheckPrescription返回结果:" + response);
            JSONObject object = JSONObject.parseObject(response);
            WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
            if (object.getInteger("status") == 200) {
                wlyyHttpLogDO.setCode("200");
                String obj = object.getString("obj");
                System.out.println("obj:"+obj);
                if (StringUtils.isNotBlank(obj)) {
                    returnJson = obj;
                    logger.info("返回到互联网医院的解析后的结果:"+returnJson);
                    wlyyHttpLogDO.setDoctor(doctor);
                    wlyyHttpLogDO.setCreateTime(new Date());
                    wlyyHttpLogDO.setRequest(infos + jsonObject.toString());
                    wlyyHttpLogDO.setResponse(returnJson);
                    wlyyHttpLogDO.setName("saveCheckPrescription");
                } else {
                    returnJson = "保存失败";
                    logger.info(returnJson);
                    wlyyHttpLogDO.setCode("failed");
                    wlyyHttpLogDO.setDoctor(doctor);
                    wlyyHttpLogDO.setCreateTime(new Date());
                    wlyyHttpLogDO.setRequest(infos + jsonObject.toString());
                    wlyyHttpLogDO.setResponse(returnJson);
                    wlyyHttpLogDO.setName("saveCheckPrescription");
                }
            } else {
                returnJson = "entranceUrl接口调用失败";
                wlyyHttpLogDO.setCode("error");
                wlyyHttpLogDO.setDoctor(doctor);
                wlyyHttpLogDO.setCreateTime(new Date());
                wlyyHttpLogDO.setRequest(infos + jsonObject.toString());
                wlyyHttpLogDO.setResponse(returnJson);
                wlyyHttpLogDO.setName("saveCheckPrescription");
            }
            wlyyHttpLogDao.save(wlyyHttpLogDO);
            return returnJson;
        }else {
            return "药品信息为空";
        }
    }
    //作废处方
    public String deleteCheckInputInfo(String prescriptionId,String payType,String doctor,String patient,List<WlyyPrescriptionDiagnosisDO> diagnosisDOS) throws Exception{
        JSONObject jsonObject = initEntranceParam(payType,doctor,patient,diagnosisDOS);
        String tjPrescriptionId = "";
        //如果重新审核药品 一定要把返回的orderNo的值拿到赋值到prescriptionId里
        if (StringUtils.isNotEmpty(prescriptionId)){
            tjPrescriptionId = prescriptionId;
            jsonObject.put("PATIENT_PRES_ID",tjPrescriptionId);
        }
        String response = "";
        String returnJson = "";
        String url = entranceUrl + "deleteCheckPrescription";
        Map<String,String> map = new HashedMap();
        map.put("infos","");
        map.put("patientAndDoctor",jsonObject.toString());
        response = httpClientUtil.httpPost(url, map);
        logger.info("请求deleteCheckPrescription参数:"+map.toString());
        logger.info("deleteCheckPrescription返回结果:" + response);
        JSONObject object = JSONObject.parseObject(response);
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        if (object.getInteger("status") == 200) {
            wlyyHttpLogDO.setCode("200");
            String obj = object.getString("obj");
            System.out.println("obj:"+obj);
            if (StringUtils.isNotBlank(obj)) { ;
                returnJson = obj;
                logger.info("返回到互联网医院的解析后的结果:"+returnJson);
                wlyyHttpLogDO.setDoctor(doctor);
                wlyyHttpLogDO.setCreateTime(new Date());
                wlyyHttpLogDO.setRequest(map.toString());
                wlyyHttpLogDO.setResponse(returnJson);
                wlyyHttpLogDO.setName("saveCheckPrescription");
            } else {
                returnJson = "删除成功";
                logger.info(returnJson);
                wlyyHttpLogDO.setCode("删除成功");
                wlyyHttpLogDO.setDoctor(doctor);
                wlyyHttpLogDO.setCreateTime(new Date());
                wlyyHttpLogDO.setRequest(map.toString());
                wlyyHttpLogDO.setResponse(returnJson);
                wlyyHttpLogDO.setName("deleteCheckPrescription");
            }
        } else {
            returnJson = "entranceUrl接口调用失败";
            wlyyHttpLogDO.setCode("error");
            wlyyHttpLogDO.setDoctor(doctor);
            wlyyHttpLogDO.setCreateTime(new Date());
            wlyyHttpLogDO.setRequest(map.toString());
            wlyyHttpLogDO.setResponse(returnJson);
            wlyyHttpLogDO.setName("deleteCheckPrescription");
        }
        wlyyHttpLogDao.save(wlyyHttpLogDO);
        return returnJson;
    }
    //初始化医患和诊断参数
    public JSONObject initEntranceParam(String payType,String doctor,String patient,List<WlyyPrescriptionDiagnosisDO> diagnosisDOS){
        JSONObject jsonObject = new JSONObject();
        //先查询处方获得支付方式
        DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(doctor);
        List<BaseDoctorHospitalDO> baseDoctorHospitalDO = baseDoctorHospitalDao.findByDoctorCode(doctor);
        BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(doctor);
        if (null != doctorMappingDO && null != baseDoctorDO) {
            jsonObject.put("DOCTOR_ID", doctorMappingDO.getMappingCode());
            jsonObject.put("POSITION", baseDoctorDO.getJobTitleName());
            jsonObject.put("DOCTOR_NAME", baseDoctorDO.getName());
            if (null!=baseDoctorHospitalDO&&baseDoctorHospitalDO.size()>0){
                jsonObject.put("DEPT_CODE", baseDoctorHospitalDO.get(0).getDeptCode());
                jsonObject.put("DEPT_NAME", baseDoctorHospitalDO.get(0).getDeptName());
            }
        }
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
        BasePatientDO basePatientDO = patientDao.findById(patient);
        jsonObject.put("PATIENT_NAME", basePatientDO.getName());
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        if (null != patientMappingDO && null != basePatientDO) {
            jsonObject.put("PATIENT_ID", patientMappingDO.getMappingCode());
            jsonObject.put("GENDER", basePatientDO.getSex()==1?"男":"女");
            jsonObject.put("BIRTH", sdf.format(basePatientDO.getBirthday()));
        }
        jsonObject.put("FEE_TYPE", "1".equalsIgnoreCase(payType) ? "医保" : "自费");
        jsonObject.put("CREATE_DATE", sdf.format(new Date()));
        //组装诊断参数
        if (null != diagnosisDOS && diagnosisDOS.size() > 0) {
            List diagnosises = new ArrayList();
            for (WlyyPrescriptionDiagnosisDO wlyyPrescriptionDiagnosisDO : diagnosisDOS) {
                diagnosises.add(wlyyPrescriptionDiagnosisDO.getName());
            }
            jsonObject.put("diagnosises", StringUtils.strip(diagnosises.toString(),"[]"));
        }
        return jsonObject;
    }

+ 47 - 16
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/YkyyEntranceService.java

@ -52,6 +52,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.*;
/**
@ -533,7 +534,7 @@ public class YkyyEntranceService {
    /**
     * 查找眼科his 已审核未付款的处方
     * 查找眼科his 审方失败
     * @throws Exception
     */
    public JSONArray getNoUnsettledPrescription() throws Exception{
@ -1660,28 +1661,48 @@ public class YkyyEntranceService {
        String doctor = null;
        String patient = null;
        String admNo= null;
        String registNo=null;
        String deptNo = null;
        if (inspectionDOS!=null&&inspectionDOS.size()!=0){
            WlyyInspectionDO inspectionDO = inspectionDOS.get(0);
            WlyyOutpatientDO outpatientDO = outpatientDao.findById(inspectionDO.getOutpatientId());
            WlyyPrescriptionDO prescriptionDO = prescriptionDao.findOne(inspectionDO.getPrescriptionId());
            admNo = prescriptionDO.getAdmNo();
            registNo = prescriptionDO.getRealOrder();
            doctor=outpatientDO.getDoctor();
            patient=outpatientDO.getPatient();
            admNo = outpatientDO.getAdmNo();
        }
        for (WlyyInspectionDO wlyyInspectionDO:inspectionDOS){
            YkEmrJcsqDO ykEmrJcsqDO = new YkEmrJcsqDO();
            ykEmrJcsqDO.setJzhm(wlyyInspectionDO.getOutpatientId());
            ykEmrJcsqDO.setJzxh(Integer.parseInt(admNo));
            System.out.println("jcjy=="+wlyyInspectionDO.getOutpatientId());
            ykEmrJcsqDO.setJzhm(registNo);
            if (StringUtils.isNotEmpty(admNo)){
                System.out.println("admno=="+admNo);
                ykEmrJcsqDO.setJzxh(Integer.parseInt(admNo));
            }
            ykEmrJcsqDO.setXmid(Integer.valueOf(wlyyInspectionDO.getCode()));
            JSONArray jsonArray = this.findZlxm(null,wlyyInspectionDO.getCode());
            if (jsonArray!=null&&jsonArray.size()>0){
                JSONObject deptobject = jsonArray.getJSONObject(0);
                deptNo = deptobject.getString("dept");
            }
            ykEmrJcsqDO.setZxks(deptNo==null?0:Integer.parseInt(deptNo));
            ykEmrJcsqDO.setJcxm(wlyyInspectionDO.getName());
            ykEmrJcsqDO.setXmdj(Integer.parseInt(wlyyInspectionDO.getChargeAmount()));
            ykEmrJcsqDO.setXmdj(new BigDecimal(wlyyInspectionDO.getChargeAmount()));
            ykEmrJcsqDO.setSqsl(wlyyInspectionDO.getQuantity());
            ykEmrJcsqDO.setJclx(Integer.valueOf(wlyyInspectionDO.getCheckPart()));
            ykEmrJcsqDO.setXmdw(wlyyInspectionDO.getTotalUnit());
            ykEmrJcsqDO.setKdsj(new Date());
            ykEmrJcsqDOS.add(ykEmrJcsqDO);
        }
        //同步his
        logger.info("开始同步检查检验");
        this.outPatientOrder(ykEmrJcsqDOS,false,doctor,patient);
        Map<String,Object> message = this.outPatientOrder(ykEmrJcsqDOS,false,doctor,patient);
        System.out.println(message.get("code")+"-----"+message.get("msg"));
        if ("-1".equalsIgnoreCase(message.get("code").toString())){
           logger.info("同步检查检验失败,错误信息为:"+message.get("msg").toString());
        }
        System.out.println(message.get("code")+"-----"+message.get("msg"));
    }
    /**
@ -2305,13 +2326,18 @@ public class YkyyEntranceService {
    }
    //查询诊疗项目视图
    public JSONArray findZlxm(String itemName) throws Exception{
    public JSONArray findZlxm(String itemName,String itemCode) throws Exception{
        String sql = "select t.item_code as \"code\",t.item_name as \"name\"," +
                "t.price as \"chargeAmount\",t.total_unit as \"totalUnit\"," +
                "t.zxks as \"dept\" from VEMR_ORDER_ITEM t where 1=1";
        if (StringUtils.isNotEmpty(itemName)){
            sql+=" and t.ITEM_NAME like '%"+itemName+"%'";
        }
        if (StringUtils.isNotEmpty(itemCode)){
            String[] split = itemCode.split(",|,");
            String ids = org.apache.commons.lang.StringUtils.join(split, ",");
            sql+=" and t.item_code in ("+ids+")";
        }
        System.out.println(sql);
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
@ -2371,7 +2397,7 @@ public class YkyyEntranceService {
        return array;
    }
    //门诊开单操作
    public String outPatientOrder(List<YkEmrJcsqDO> surveys,Boolean demoFlag,String doctor,String patient) throws Exception{
    public Map<String,Object> outPatientOrder(List<YkEmrJcsqDO> surveys,Boolean demoFlag,String doctor,String patient) throws Exception{
        DoctorMappingDO doctorMappingDO = new DoctorMappingDO();
        if (StringUtils.isNoneBlank(doctor)){
            doctorMappingDO = doctorMappingDao.findByDoctor(doctor);
@ -2386,6 +2412,7 @@ public class YkyyEntranceService {
        Integer kdks = 0;
        Integer brid=0;
        JSONArray jsonArray = findHisPatient(patientMedicareCardDO.getCode(),demoFlag);
        Map<String,Object> resultMap = new HashMap();
        if(jsonArray!=null&&jsonArray.size()>0){
            //获取居民信息
            JSONObject json = jsonArray.getJSONObject(0);
@ -2400,6 +2427,7 @@ public class YkyyEntranceService {
        if(jsonArray1!=null&&jsonArray1.size()>0){
            JSONObject json = jsonArray1.getJSONObject(0);
            doctorHis=json.getString("code");
            kdks = Integer.parseInt(json.getString("dept"));
        }
        if (surveys!=null){
            for (YkEmrJcsqDO ykEmrJcsqDO:surveys){
@ -2412,7 +2440,7 @@ public class YkyyEntranceService {
                    ykEmrJcsqDO.setBrxm(brxm);
                    ykEmrJcsqDO.setBrnl(brnl);
                    ykEmrJcsqDO.setKdys(doctorHis);
                    ykEmrJcsqDO.setBrks(114);
                    ykEmrJcsqDO.setBrks(kdks);
                    ykEmrJcsqDO.setTjys(doctorHis);
            }
            String jsonString = JSONObject.toJSONString(surveys);
@ -2428,15 +2456,18 @@ public class YkyyEntranceService {
            JSONArray array= new JSONArray();
            if (status==200){
                array = rs.getJSONArray("detailModelList");
                if(array.size()>0){
                    return "success";
                }else {
                    return "failed";
                }
                resultMap.put("code","200");
                resultMap.put("msg",content);
                return resultMap;
            }else {
                resultMap.put("code","-1");
                resultMap.put("msg",content);
                return resultMap;
            }
            return "faild";
        }else {
            return "failed";
            resultMap.put("code","-1");
            resultMap.put("msg","开单信息为空");
            return resultMap;
        }
    }
   //查询检查单

+ 58 - 43
business/base-service/src/main/java/com/yihu/jw/internet/service/InternetCommonService.java

@ -92,7 +92,7 @@ public class InternetCommonService extends BaseJpaService<InternetUpErrorLogDO,
    public String orgSub ;
    public String imgUrl;
    static String imgPath =File.separator+"usr"+File.separator+"local"+File.separator+"ehr"+File.separator+"svr-internet-hospital-job"+File.separator+"img"+File.separator;
    static String imgPath =File.separator+"data1"+File.separator+"ehr"+File.separator+"svr-internet-hospital-job"+File.separator+"img"+File.separator;
    public ObjectMapper objectMapper;
@ -354,11 +354,11 @@ public class InternetCommonService extends BaseJpaService<InternetUpErrorLogDO,
                jb.put("docimg",info.get("photo")==null ?null:getImg("https://hlwyy.xmzsh.com/fastdfs/"+info.get("photo").toString()));
                jb.put("id_card", info.get("idcard")== null ? "0":info.get("idcard"));
                jb.put("sex", info.get("sex")== null ? "0":info.get("sex"));
                jb.put("birthday", info.get("birthday")  == null?"1900-01-01": DateUtil.dateToStrShort((Date)info.get("birthday")));
                jb.put("birthday", info.get("birthday")  == null?"2020-01-01": DateUtil.dateToStrShort((Date)info.get("birthday")));
                jb.put("subject", dept.length>=1?dept[0]:"");
                jb.put("subject_name",dept.length>=2?dept[1]:"");
                jb.put("belong_dept",jb.getString("dept_code"));
                jb.put("belong_dept_name", jb.getString("dept_name"));
                jb.put("belong_dept",info.get("dept_code"));
                jb.put("belong_dept_name", info.get("dept_name"));
                jb.put("doo_tel", info.get("mobile")== null ? "":info.get("mobile"));
                jb.put("title_rec_date", getDateString(info.get("fzrq").toString()));
                jb.put("prac_type", "1");   // 因为上传的是医师的信息,所以该字段全部默认设置为 1 医师
@ -481,14 +481,14 @@ public class InternetCommonService extends BaseJpaService<InternetUpErrorLogDO,
                jb.put("cd_org", orgCode);
                jb.put("cd_area", orgArea);
                jb.put("cd_orgSub", orgSub);
                jb.put("reg_time", info.get("date") == null?"1900-01-01": DateUtil.dateToStrLong((Date)info.get("date")));
                jb.put("reg_time", info.get("date") == null?"2020-01-01": DateUtil.dateToStrLong((Date)info.get("date")));
                jb.put("fg_visit",  fgConvent(info.get("status") == null?"-1":info.get("status").toString()));
                jb.put("reg_dep_code",  info.get("dept") == null?"0":info.get("dept"));
                jb.put("reg_dep_name",  info.get("dept_name") == null?"0":info.get("dept_name"));
                jb.put("reg_subject_code",  dept.length>=1?dept[0]:"");
                jb.put("reg_subject_name", dept.length>=2?dept[1]:"");
                jb.put("reg_price",  "0");
                jb.put("pt_name", info.get("name") == null?"0":info.get("name"));
                jb.put("pt_name", info.get("paName") == null?"0":info.get("paName"));
                jb.put("ge_code",   IdCardUtil.getSexForIdcard_new(info.get("idcard").toString()));
                jb.put("pt_age", IdCardUtil.getAgeForIdcard(info.get("idcard").toString()));
                jb.put("card_type", "1");
@ -641,7 +641,8 @@ public class InternetCommonService extends BaseJpaService<InternetUpErrorLogDO,
                " a.patient_name AS \"patient_name\", " +
                " a.create_time AS \"create_time\", " +
                " e.content AS \"content\", " +
                " d.idcard AS \"docIdCard\" " +
                " d.idcard AS \"docIdCard\", " +
                " e.relation_code AS \"relationCode\" "+
                "FROM " +
                " base_evaluate_score a " +
                "JOIN base_evaluate e ON a.id = e.relation_code " +
@ -671,11 +672,9 @@ public class InternetCommonService extends BaseJpaService<InternetUpErrorLogDO,
            Map<String,Object> info =list.get(i);
            Boolean errorFlag = false;
            JSONObject jb = new JSONObject();
            String interId = "";
            try{
                String interId = "";
                String idCard = info.get("docIdCard") == null ? "0":info.get("docIdCard").toString();
                if( info.get("docIdCard") == null){
                    interId = "0";
@ -685,7 +684,7 @@ public class InternetCommonService extends BaseJpaService<InternetUpErrorLogDO,
//                String[] dept = depToSubject(info.get("dept_code").toString());
                jb.put("id",interId +"_"+ (String)info.get("id"));
                jb.put("id",interId +"_"+ (String)info.get("relationCode"));
                jb.put("id_doctor",interId == null ? "0":interId);
                jb.put("organ_code",orgCode);
                jb.put("organ_name", orgName);
@ -703,16 +702,19 @@ public class InternetCommonService extends BaseJpaService<InternetUpErrorLogDO,
                logger.error(e.toString());
            }
            if(!errorFlag){
                JSONArray jsonArray = new JSONArray();
                jsonArray.add(jb);
                res = postToInter(token,api, jsonArray,url);
                JSONObject resJson = (JSONObject) JSONObject.parse(res);
                if("200".equals(resJson.get("msg").toString())){
                    success++;
                }else{
                    saveErrorLog(upid,"7",info.get("id").toString(),res,2);
                    error++;
                if (!interId.equalsIgnoreCase("0")&&!interId.equalsIgnoreCase("")){
                    JSONArray jsonArray = new JSONArray();
                    jsonArray.add(jb);
                    res = postToInter(token,api, jsonArray,url);
                    JSONObject resJson = (JSONObject) JSONObject.parse(res);
                    if("200".equals(resJson.get("msg").toString())){
                        success++;
                    }else{
                        saveErrorLog(upid,"7",info.get("id").toString(),res,2);
                        error++;
                    }
                }
            }
        }
        String resInfo = "此次共上传:" + total + "条数据,其中成功 :" + success + "条,上传失败 : " + error + "条。格式错误:"+dataError+"条。";
@ -854,7 +856,7 @@ public class InternetCommonService extends BaseJpaService<InternetUpErrorLogDO,
                object.put("send_time",DateUtil.dateToStr(DateUtil.strToDate(map.get("timestamp").toString(),"yyyy-MM-dd HH:mm:ss"),"yyyy-MM-dd HH:mm:ss"));
                array.add(object);
            }
            info.put("content",array.toJSONString());
            info.put("content",array);
        }
@ -881,8 +883,8 @@ public class InternetCommonService extends BaseJpaService<InternetUpErrorLogDO,
                jb.put("visit_doc_name",  info.get("docName")== null? "0":info.get("docName"));
                jb.put("visit_doc_id_no",  info.get("docIdCard")== null? "0":info.get("docIdCard"));
                jb.put("visit_doc_code",  visitDocCode);
                jb.put("visit_dept_code", info.get("dept_code") == null?"0":info.get("dept_code"));
                jb.put("visit_dept_name", info.get("dept_name") == null?"0":info.get("dept_name"));
                jb.put("visit_dept_code",  dept.length>=1?dept[0]:"");
                jb.put("visit_dept_name",  dept.length>=2?dept[1]:"");
                jb.put("pt_no", info.get("patientName")== null? "0":info.get("patientName"));
                jb.put("pt_age", IdCardUtil.getAgeForIdcard(info.get("patIdCard").toString()));
                jb.put("cost_type", "");
@ -892,9 +894,9 @@ public class InternetCommonService extends BaseJpaService<InternetUpErrorLogDO,
                jb.put("card_type", "1");
                jb.put("id_no", info.get("patIdCard")== null? "0":info.get("patIdCard"));
                jb.put("pt_district",info.get("city_code") == null?"":info.get("city_code"));
                jb.put("apply_time", info.get("czrq")==null?"1900-01-01":DateUtil.dateToStrLong((Date)info.get("czrq")));
                jb.put("visit_time", info.get("czrq")==null?"1900-01-01":DateUtil.dateToStrLong((Date)info.get("czrq")));
                jb.put("visit_finish_time", info.get("end_time")==null?"1900-01-01":DateUtil.dateToStrLong((Date)info.get("end_time")));
                jb.put("apply_time", info.get("czrq")==null?"2020-01-01":DateUtil.dateToStrLong((Date)info.get("czrq")));
                jb.put("visit_time", info.get("czrq")==null?"2020-01-01":DateUtil.dateToStrLong((Date)info.get("czrq")));
                jb.put("visit_finish_time", info.get("end_time")==null?"2020-01-01":DateUtil.dateToStrLong((Date)info.get("end_time")));
                jb.put("complaint_content", info.get("content"));
                logger.info("complaint_content"+info.get("content"));
               /* String procFile="";
@ -982,7 +984,9 @@ public class InternetCommonService extends BaseJpaService<InternetUpErrorLogDO,
                "      join base_doctor b on b.id = a.doctor" +
                "      join base_patient c on c.id = a.patient" +
                " where a.register_no is NOT NULL and a.dept is not null " +
                " and a.register_date is not null " ;
                " and a.register_date is not null " +
                " and a.doctor not in ('402803816babc778016babd0dee21112')" +
                " and a.patient not in ('2c9081aa6c2f1892016c6a26a8c102ca','39686349deff487d8f3372fc253b8417') " ;
        Map<String,Object> params = new HashedMap();
@ -1025,9 +1029,9 @@ public class InternetCommonService extends BaseJpaService<InternetUpErrorLogDO,
                jb.put("visit_doc_id_no", info.get("docIdCard"));
                jb.put("visit_doc_code", visitDocCode);
                jb.put("visit_subject_code", dept.length>=1?dept[0]:"");
                jb.put("visit_ subject _name",dept.length>=2?dept[1]:"");
                jb.put("visit_dept_code", info.get("dept"));
                jb.put("visit_dept_name", info.get("dept_name"));
                jb.put("visit_subject_name",dept.length>=2?dept[1]:"");
                jb.put("visit_dept_code",  dept.length>=1?dept[0]:"");
                jb.put("visit_dept_name",  dept.length>=2?dept[1]:"");
                jb.put("pt_no", info.get("paName"));
                jb.put("pt_age", IdCardUtil.getAgeForIdcard(info.get("paId").toString()));
//                jb.put("cost_type", info.get("charge_type").toString());
@ -1054,13 +1058,21 @@ public class InternetCommonService extends BaseJpaService<InternetUpErrorLogDO,
                jb.put("visit_finish_time", dateStr+" 00:00:00");
                jb.put("old_diag_code", "");
                jb.put("old_diag_name", "");
                jb.put("old_diag_code", info.get("icd10"));
                jb.put("old_diag_name", info.get("icd10_name"));
                jb.put("diag_code",info.get("icd10"));
                jb.put("diag_name", info.get("icd10_name"));
                jb.put("diseases_type", info.get("origin_adm_no") == null ? "1":"2");
                jb.put("complaint_content", info.get("paName").toString()+DateUtil.dateToStr(date,"yyyy-MM-dd HH:mm:ss")+info.get("description").toString()+"\n");
                jb.put("proc_file", "");
                JSONObject object = new JSONObject();
                object.put("sender",info.get("paName").toString());
                object.put("receiver",info.get("doctor_name"));
                object.put("msg",info.get("description").toString());
                object.put("send_time",DateUtil.dateToStr(createTime,"yyyy-MM-dd HH:mm:ss"));
                object.put("msg_type",0);
                JSONArray array = new JSONArray();
                array.add(object);
                jb.put("complaint_content",array);
                jb.put("proc_file", "无");
                jb.put("price","0");
                jb.put("fg_reply", "");
                jb.put("crt_time", DateUtil.dateToStrLong(DateUtil.getNow()));
@ -1121,8 +1133,9 @@ public class InternetCommonService extends BaseJpaService<InternetUpErrorLogDO,
                "  p.dept_name AS \"dept_name\"," +
                "  a.doctor AS \"doctor\"," +
                "  a.doctor_name AS \"doctor_name\"," +
                "  a.his_register_fee AS \"his_register_fee\"," +
                "  c.idcard AS \"docIdcard\"" +
                "  a.drug_fee AS \"drug_fee\"," +
                "  c.idcard AS \"docIdcard\", " +
                "  a.create_time AS \"create_time\" " +
                "  from  wlyy_prescription a" +
                "     JOIN base_patient b on a.patient_code = b.id " +
                "     JOIN base_doctor c on a.doctor = c.id " +
@ -1159,6 +1172,8 @@ public class InternetCommonService extends BaseJpaService<InternetUpErrorLogDO,
                // 获取监管平台唯一标识
                String visitDocCode = achNsDoctorRecord(info.get("docIdcard").toString());
                String trialDocCode =  achNsDoctorRecord("350524198906247742");
                jb.put("id_prescription", orgCode +"_"+ (String)info.get("id"));
                jb.put("pres_no",info.get("real_order")== null?"0":info.get("real_order"));
                jb.put("pres_class_code", "1");
@ -1187,21 +1202,21 @@ public class InternetCommonService extends BaseJpaService<InternetUpErrorLogDO,
                jb.put("pres_subject_name", dept.length>=2?dept[1]:"");
                jb.put("pres_dept_code", info.get("dept")== null?"0":info.get("dept"));
                jb.put("pres_dept_name",info.get("dept_name")== null?"0":info.get("dept_name"));
                jb.put("pres_time", info.get("create_time")== null?"1900-01-01 00:00:00":DateUtil.dateToStrLong((Date)info.get("create_time")));
                jb.put("trial_time",DateUtil.dateToStrLong(new Date()));
                jb.put("pres_time", info.get("create_time")== null?DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss"):DateUtil.dateToStrLong((Date)info.get("create_time")));
                jb.put("trial_time",info.get("create_time")== null?DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss"):DateUtil.dateToStrLong(new Date(((Date)info.get("create_time")).getTime()+600000)));
                jb.put("pres_doc_code", visitDocCode);
                jb.put("pres_doc_name", info.get("doctor_name")== null?"0":info.get("doctor_name"));
                jb.put("pres_doc_id_no", info.get("docIdcard")== null?"0":info.get("docIdcard"));
                jb.put("trial_doc_code", visitDocCode);
                jb.put("trial_doc_name", info.get("doctor_name")== null?"0":info.get("doctor_name"));
                jb.put("trial_doc_id_no",info.get("docIdcard")== null?"0":info.get("docIdcard"));
                jb.put("trial_doc_code", trialDocCode);
                jb.put("trial_doc_name", "陈丽玲");
                jb.put("trial_doc_id_no","350524198906247742");
                jb.put("diag_code", info.get("icd10"));
                jb.put("diag_name", info.get("icd10_name"));
                jb.put("diseases_type", "0");
                jb.put("mobility_flag", "3");
                jb.put("long_medical_flag", "3");
                jb.put("pres_effec_days", 0);
                jb.put("total_price",info.get("his_register_fee")== null?  0 : info.get("his_register_fee"));
                jb.put("total_price",info.get("drug_fee")== null?  0 : info.get("drug_fee"));
                jb.put("upload_time", DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss"));
                jb.put("pres_photo", "");
                jb.put("pres_photos_list", "");

File diff suppressed because it is too large
+ 54 - 7
business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java


+ 279 - 68
business/es-service/src/main/java/com/yihu/jw/es/service/StatisticsEsService.java

@ -1,39 +1,29 @@
package com.yihu.jw.es.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.deser.Deserializers;
import com.google.common.annotations.VisibleForTesting;
import com.yihu.jw.area.dao.BaseCityDao;
import com.yihu.jw.dict.dao.DictHospitalDeptDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.es.util.ElasticsearchUtil;
import com.yihu.jw.es.util.SaveModel;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.evaluate.score.service.BaseEvaluateScoreService;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.StringUtil;
import jdk.management.resource.internal.inst.FileOutputStreamRMHooks;
import org.apache.commons.lang3.StringUtils;
import org.junit.runners.parameterized.BlockJUnit4ClassRunnerWithParametersFactory;
import org.omg.CORBA.OBJ_ADAPTER;
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.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import javax.xml.soap.SAAJMetaFactory;
import java.security.acl.LastOwnerException;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@ -59,6 +49,10 @@ public class StatisticsEsService {
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private BaseOrgDao orgDao;
    @Autowired
    private BaseCityDao cityDao;
    @Autowired
    private BaseEvaluateScoreService baseEvaluateScoreService;
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
@ -85,15 +79,16 @@ public class StatisticsEsService {
        SaveModel saveModel3 = null;
        //上周今天收入;
        SaveModel saveModel4 = null;
        SaveModel saveModel7 = null;
        String[] indexes = index.split(",");
        if (StringUtils.isNotEmpty(level2_type)) {
            saveModel = elasticsearchUtil.findOneDateQuotaLevel1(endDate, endDate, area, level, indexes[0], SaveModel.timeLevel_DDL, level2_type);
            saveModel1 = elasticsearchUtil.findOneDateQuotaLevel1(endDate, endDate, area, level, indexes[1], SaveModel.timeLevel_DDL, level2_type);
            saveModel2 = elasticsearchUtil.findOneDateQuotaLevel1(endDate, endDate, area, level, indexes[2], SaveModel.timeLevel_DDL,level2_type);
            saveModel2 = elasticsearchUtil.findOneDateQuotaLevel1(endDate, endDate, area, level, indexes[2]+",21", SaveModel.timeLevel_DDL,level2_type);
        } else {
            saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, area, level, indexes[0], SaveModel.timeLevel_DDL);
            saveModel1 = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, area, level, indexes[1], SaveModel.timeLevel_DDL);
            saveModel2 = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, area, level, indexes[2], SaveModel.timeLevel_DDL);
            saveModel2 = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, area, level, indexes[2]+",21", SaveModel.timeLevel_DDL);
        }
        JSONObject object = new JSONObject();
        String yesterday = DateUtil.getNextDay(endDate, -1);//昨天
@ -110,8 +105,8 @@ public class StatisticsEsService {
        DecimalFormat df = new DecimalFormat("0.00");
        String str = df.format(num);
        object.put("dayPrice",str);//日均收入
        saveModel3 = elasticsearchUtil.findOneDateQuotaLevel0(yesterday, yesterday, area, level, indexes[2], SaveModel.timeLevel_DDL);
        saveModel4 = elasticsearchUtil.findOneDateQuotaLevel0(lastDay, lastDay, area, level, indexes[2], SaveModel.timeLevel_DDL);
        saveModel3 = elasticsearchUtil.findOneDateQuotaLevel0(yesterday, yesterday, area, level, indexes[2]+",21", SaveModel.timeLevel_DDL);
        saveModel4 = elasticsearchUtil.findOneDateQuotaLevel0(lastDay, lastDay, area, level, indexes[2]+",21", SaveModel.timeLevel_DDL);
        object.put("outPatientCount",saveModel.getResult2().longValue());//问诊量
        object.put("prescriptionCount",saveModel1.getResult2().longValue());//开方量
        object.put("priceTotal",saveModel2.getResult1().longValue());//总收入
@ -168,46 +163,46 @@ public class StatisticsEsService {
            object.put("data",array);
            JSONArray array1 = dateTotalStatistics2(startDate,endDate,area,level,"5","1",SaveModel.timeLevel_ZL,null);
            object.put("specialistData",array1);
            JSONArray array2 = dateTotalStatistics2(startDate,endDate,area,level,"5","9",SaveModel.timeLevel_ZL,null);
            JSONArray array2 = dateTotalStatistics2(startDate,endDate,area,level,"12",null,SaveModel.timeLevel_ZL,null);
            object.put("topicData",array2);
            JSONArray array3 = dateTotalStatistics2(startDate,endDate,area,level,"5","12",SaveModel.timeLevel_ZL,null);
            JSONArray array3 = dateTotalStatistics2(startDate,endDate,area,level,"14",null,SaveModel.timeLevel_ZL,null);
            object.put("synergyData",array3);
            JSONArray array4 = dateTotalStatistics2(startDate,endDate,area,level,"5","16",SaveModel.timeLevel_ZL,null);
            JSONArray array4 = dateTotalStatistics2(startDate,endDate,area,level,"16",null,SaveModel.timeLevel_ZL,null);
            object.put("vedioData",array4);
        }else if (interval==2){
            JSONArray array = weekTotalStatistics(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL);
            object.put("data",array);
            JSONArray array1 = weekTotalStatistics(startDate,endDate,area,level,"5","1",SaveModel.timeLevel_ZL);
            object.put("specialistData",array1);
            JSONArray array2 = weekTotalStatistics(startDate,endDate,area,level,"5","9",SaveModel.timeLevel_ZL);
            JSONArray array2 = weekTotalStatistics(startDate,endDate,area,level,"12",null,SaveModel.timeLevel_ZL);
            object.put("topicData",array2);
            JSONArray array3 = weekTotalStatistics(startDate,endDate,area,level,"5","12",SaveModel.timeLevel_ZL);
            JSONArray array3 = weekTotalStatistics(startDate,endDate,area,level,"14",null,SaveModel.timeLevel_ZL);
            object.put("synergyData",array3);
            JSONArray array4 = weekTotalStatistics(startDate,endDate,area,level,"5","16",SaveModel.timeLevel_ZL);
            JSONArray array4 = weekTotalStatistics(startDate,endDate,area,level,"16",null,SaveModel.timeLevel_ZL);
            object.put("vedioData",array4);
        }else if (interval==3){
            JSONArray array = monthTotalStatistics2(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL,null);
            object.put("data",array);
            JSONArray array1 = monthTotalStatistics2(startDate,endDate,area,level,"5","1",SaveModel.timeLevel_ZL,null);
            JSONArray array1 = monthTotalStatistics2(startDate,endDate,area,level,"5",null,SaveModel.timeLevel_ZL,null);
            object.put("specialistData",array1);
            JSONArray array2 = monthTotalStatistics2(startDate,endDate,area,level,"5","9",SaveModel.timeLevel_ZL,null);
            JSONArray array2 = monthTotalStatistics2(startDate,endDate,area,level,"12",null,SaveModel.timeLevel_ZL,null);
            object.put("topicData",array2);
            JSONArray array3 = monthTotalStatistics2(startDate,endDate,area,level,"5","12",SaveModel.timeLevel_ZL,null);
            JSONArray array3 = monthTotalStatistics2(startDate,endDate,area,level,"14",null,SaveModel.timeLevel_ZL,null);
            object.put("synergyData",array3);
            JSONArray array4 = monthTotalStatistics2(startDate,endDate,area,level,"5","16",SaveModel.timeLevel_ZL,null);
            JSONArray array4 = monthTotalStatistics2(startDate,endDate,area,level,"16",null,SaveModel.timeLevel_ZL,null);
            object.put("vedioData",array4);
        }
        if (StringUtils.isNoneBlank(level2_type)){
            //问诊量表格
            //专家咨询数量
            List<SaveModel> specialistSaveModels = elasticsearchUtil.findDateQuotaLevel1(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL,"1",null,level2_type);
            List<SaveModel> specialistSaveModels = elasticsearchUtil.findDateQuotaLevel0(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL,null,level2_type);
            //协同门诊
            List<SaveModel> syngySaveModels = elasticsearchUtil.findDateQuotaLevel1(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL,"12",null,level2_type);
            List<SaveModel> syngySaveModels = elasticsearchUtil.findDateQuotaLevel0(startDate, endDate, area, level, "14", SaveModel.timeLevel_ZL,null,level2_type);
            //图文复诊
            List<SaveModel> topicSaveModels = elasticsearchUtil.findDateQuotaLevel1(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL,"9",null,level2_type);
            List<SaveModel> topicSaveModels = elasticsearchUtil.findDateQuotaLevel0(startDate, endDate, area, level, "12", SaveModel.timeLevel_ZL,null,level2_type);
            ///视频复诊
            List<SaveModel> vedioSaveModels = elasticsearchUtil.findDateQuotaLevel1(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL,"16",null,level2_type);
            List<SaveModel> vedioSaveModels = elasticsearchUtil.findDateQuotaLevel0(startDate, endDate, area, level, "16", SaveModel.timeLevel_ZL,null,level2_type);
            JSONArray array = new JSONArray();
            List<String> list = new ArrayList<>();
@ -443,35 +438,35 @@ public class StatisticsEsService {
        if (interval==1){
            JSONArray array = dateTotalStatistics3(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL,null);
            object.put("data",array);
            JSONArray array1 = dateTotalStatistics3(startDate,endDate,area,level,"3","3",SaveModel.timeLevel_ZL,null);
            JSONArray array1 = dateTotalStatistics3(startDate,endDate,area,level,index,"3",SaveModel.timeLevel_ZL,null);
            object.put("specialistData",array1);
            JSONArray array2 = dateTotalStatistics3(startDate,endDate,area,level,"3","1",SaveModel.timeLevel_ZL,"1");
            JSONArray array2 = dateTotalStatistics3(startDate,endDate,area,level,index,"1",SaveModel.timeLevel_ZL,"1");
            object.put("topicData",array2);
            JSONArray array3 = dateTotalStatistics3(startDate,endDate,area,level,"3","2",SaveModel.timeLevel_ZL,null);
            JSONArray array3 = dateTotalStatistics3(startDate,endDate,area,level,index,"2",SaveModel.timeLevel_ZL,null);
            object.put("synergyData",array3);
            JSONArray array4 = dateTotalStatistics3(startDate,endDate,area,level,"3","1",SaveModel.timeLevel_ZL,"2");
            JSONArray array4 = dateTotalStatistics3(startDate,endDate,area,level,index,"1",SaveModel.timeLevel_ZL,"2");
            object.put("vedioData",array4);
        }else if (interval==2){
            JSONArray array = weekTotalStatisticsDf(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL);
            object.put("data",array);
            JSONArray array1 = weekTotalStatistics3(startDate,endDate,area,level,"3","3",SaveModel.timeLevel_ZL,"1");
            JSONArray array1 = weekTotalStatistics3(startDate,endDate,area,level,index,"3",SaveModel.timeLevel_ZL,"1");
            object.put("specialistData",array1);
            JSONArray array2 = weekTotalStatistics3(startDate,endDate,area,level,"3","1",SaveModel.timeLevel_ZL,"1");
            JSONArray array2 = weekTotalStatistics3(startDate,endDate,area,level,index,"1",SaveModel.timeLevel_ZL,"1");
            object.put("topicData",array2);
            JSONArray array3 = weekTotalStatistics3(startDate,endDate,area,level,"3","2",SaveModel.timeLevel_ZL,null);
            JSONArray array3 = weekTotalStatistics3(startDate,endDate,area,level,index,"2",SaveModel.timeLevel_ZL,null);
            object.put("synergyData",array3);
            JSONArray array4 = weekTotalStatistics3(startDate,endDate,area,level,"3","1",SaveModel.timeLevel_ZL,"2");
            JSONArray array4 = weekTotalStatistics3(startDate,endDate,area,level,index,"1",SaveModel.timeLevel_ZL,"2");
            object.put("vedioData",array4);
        }else if (interval==3){
            JSONArray array = monthTotalStatistics3(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL,null);
            object.put("data",array);
            JSONArray array1 = monthTotalStatistics3(startDate,endDate,area,level,"3","3",SaveModel.timeLevel_ZL,"1");
            JSONArray array1 = monthTotalStatistics3(startDate,endDate,area,level,index,"3",SaveModel.timeLevel_ZL,"1");
            object.put("specialistData",array1);
            JSONArray array2 = monthTotalStatistics3(startDate,endDate,area,level,"3","1",SaveModel.timeLevel_ZL,"1");
            JSONArray array2 = monthTotalStatistics3(startDate,endDate,area,level,index,"1",SaveModel.timeLevel_ZL,"1");
            object.put("topicData",array2);
            JSONArray array3 = monthTotalStatistics3(startDate,endDate,area,level,"3","2",SaveModel.timeLevel_ZL,null);
            JSONArray array3 = monthTotalStatistics3(startDate,endDate,area,level,index,"2",SaveModel.timeLevel_ZL,null);
            object.put("synergyData",array3);
            JSONArray array4 = monthTotalStatistics3(startDate,endDate,area,level,"3","1",SaveModel.timeLevel_ZL,"2");
            JSONArray array4 = monthTotalStatistics3(startDate,endDate,area,level,index,"1",SaveModel.timeLevel_ZL,"2");
            object.put("vedioData",array4);
        }
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
@ -516,6 +511,7 @@ public class StatisticsEsService {
                Double synegy =0.0;
                if (index.equalsIgnoreCase("3")){
                    specialist = 0.0;
                    jsonObject.put("specialist",specialist);
                }else if (index.equalsIgnoreCase("5")){
                    for (SaveModel saveModel:specialistSaveModels){
                        if (level2_type.equals(SaveModel.OrgLevel)){
@ -544,6 +540,13 @@ public class StatisticsEsService {
                                        jsonObject.put("code",doctorHospitalDO.getDeptCode());
                                        jsonObject.put("name",doctorHospitalDO.getDeptName());
                                    }
                                }else if (level==4){
                                    BaseOrgDO orgDO = orgDao.findByCode(area);
                                    jsonObject.put("code",area);
                                    jsonObject.put("name",orgDO.getName());
                                }else if (level==2){
                                    jsonObject.put("code",area);
                                    jsonObject.put("name","厦门市");
                                }else {
                                    DictHospitalDeptDO dictHospitalDeptDO =  hospitalDeptDao.findByCode(area);
                                    jsonObject.put("code",area);
@ -592,6 +595,13 @@ public class StatisticsEsService {
                                    jsonObject.put("code",doctorHospitalDO.getDeptCode());
                                    jsonObject.put("name",doctorHospitalDO.getDeptName());
                                }
                            }else if (level==4){
                                BaseOrgDO orgDO = orgDao.findByCode(area);
                                jsonObject.put("code",area);
                                jsonObject.put("name",orgDO.getName());
                            }else if (level==2){
                                jsonObject.put("code",area);
                                jsonObject.put("name","厦门市");
                            }else {
                                DictHospitalDeptDO dictHospitalDeptDO =  hospitalDeptDao.findByCode(area);
                                jsonObject.put("code",area);
@ -638,6 +648,13 @@ public class StatisticsEsService {
                                    jsonObject.put("code",doctorHospitalDO.getDeptCode());
                                    jsonObject.put("name",doctorHospitalDO.getDeptName());
                                }
                            }else if (level==4){
                                BaseOrgDO orgDO = orgDao.findByCode(area);
                                jsonObject.put("code",area);
                                jsonObject.put("name",orgDO.getName());
                            }else if (level==2){
                                jsonObject.put("code",area);
                                jsonObject.put("name","厦门市");
                            }else {
                                DictHospitalDeptDO dictHospitalDeptDO =  hospitalDeptDao.findByCode(area);
                                jsonObject.put("code",area);
@ -683,6 +700,13 @@ public class StatisticsEsService {
                                    jsonObject.put("code",doctorHospitalDO.getDeptCode());
                                    jsonObject.put("name",doctorHospitalDO.getDeptName());
                                }
                            }else if (level==4){
                                BaseOrgDO orgDO = orgDao.findByCode(area);
                                jsonObject.put("code",area);
                                jsonObject.put("name",orgDO.getName());
                            }else if (level==2){
                                jsonObject.put("code",area);
                                jsonObject.put("name","厦门市");
                            }else {
                                DictHospitalDeptDO dictHospitalDeptDO =  hospitalDeptDao.findByCode(area);
                                jsonObject.put("code",area);
@ -708,7 +732,23 @@ public class StatisticsEsService {
                jsonObject.put("total",decimalFormat.format(total));//总和
                array.add(jsonObject);
            }
            object.put("excelData",array);
            List<JSONObject> bindArrayResult = JSONArray.parseArray(array.toJSONString(), JSONObject.class);
            System.out.println("排序前:"+bindArrayResult);
            Collections.sort(bindArrayResult, new Comparator<JSONObject>() {
                @Override
                public int compare(JSONObject o1, JSONObject o2) {
                    double a = o1.getDouble("total");
                    double b = o2.getDouble("total");
                    if (a > b) {
                        return -1;
                    } else if(a == b) {
                        return 0;
                    } else
                        return 1;
                }
            });
            JSONArray jsonArray = JSONArray.parseArray(bindArrayResult.toString());
            object.put("excelData",jsonArray);
        }
        return object;
    }
@ -755,21 +795,21 @@ public class StatisticsEsService {
        if (index.equalsIgnoreCase("3")){
            //协同门诊
            SaveModel saveModel1 = null;
            saveModel1 = elasticsearchUtil.findOneDateQuotaLevel1(endDate, endDate, area, level, index, SaveModel.timeLevel_DDL, "2");
            saveModel1 = elasticsearchUtil.findOneDateQuotaLevel1(endDate, endDate, area, level, index+",21", SaveModel.timeLevel_DDL, "2");
            //图文复诊
            SaveModel saveModel2 = null;
            //saveModel2 = elasticsearchUtil.findOneDateQuotaLevel2(endDate, endDate, area, level, index, SaveModel.timeLevel_DDL, "1","1");
            saveModel2 = elasticsearchUtil.findOneDateQuotaLevel2(endDate, endDate, area, level, index, SaveModel.timeLevel_DDL, "1","1");
            saveModel2 = elasticsearchUtil.findOneDateQuotaLevel2(endDate, endDate, area, level, index+",21", SaveModel.timeLevel_DDL, "1","1");
            //视频复诊
            SaveModel saveModel3 = null;
/*
    saveModel3 = elasticsearchUtil.findOneDateQuotaLevel2(endDate, endDate, area, level, index, SaveModel.timeLevel_DDL, "1","2");
*/
            saveModel3 = elasticsearchUtil.findOneDateQuotaLevel2(endDate, endDate, area, level, index, SaveModel.timeLevel_DDL, "1","2");
            saveModel3 = elasticsearchUtil.findOneDateQuotaLevel2(endDate, endDate, area, level, index+",21", SaveModel.timeLevel_DDL, "1","2");
            Double specialistCount =0.0;
            //专科咨询
            SaveModel saveModel4 = null;
            saveModel4 = elasticsearchUtil.findOneDateQuotaLevel1(endDate, endDate, area, level, index, SaveModel.timeLevel_DDL, "3");
            saveModel4 = elasticsearchUtil.findOneDateQuotaLevel1(endDate, endDate, area, level, index+",21", SaveModel.timeLevel_DDL, "3");
            specialistCount = saveModel4.getResult1();//专家咨询数量
            Double synergyCount = saveModel1.getResult1();//协同门诊数量
@ -3473,7 +3513,7 @@ public class StatisticsEsService {
            //咨询总数
            List<SaveModel> total = elasticsearchUtil.findListDateQuotaLevel0(startTime, endTime, area, level, index1, SaveModel.timeLevel_ZL, lowLevel);
            //已结束
            List<SaveModel> endTotal = elasticsearchUtil.findListDateQuotaLevel1(startTime, endTime, area, level, index, SaveModel.timeLevel_ZL, lowLevel,"2");
            List<SaveModel> endTotal = elasticsearchUtil.findListDateQuotaLevel1(startTime, endTime, area, level, index, SaveModel.timeLevel_ZL, lowLevel,"1,2,3");
            result.put("resultList", getCoutList1(level, lowLevel, endTotal, total, noReceiveTotal));
        }
@ -3679,7 +3719,7 @@ public class StatisticsEsService {
                object.put("totalData",array);//新增量
                JSONArray array1 = dateTotalStatistics2(startDate,endDate,area,level,index1,"0",SaveModel.timeLevel_ZL,null);//未接诊
                object.put("noReceiveData",array1);//未接诊
                JSONArray array2 = dateTotalStatistics2(startDate,endDate,area,level,index1,"1,2",SaveModel.timeLevel_ZL,null);//已接诊
                JSONArray array2 = dateTotalStatistics2(startDate,endDate,area,level,index,"1,2,3",SaveModel.timeLevel_ZL,null);//已接诊
                object.put("haveReceiveData",array2);//已接诊
                JSONArray array3 = dateTotalStatistics2(startDate,endDate,area,level,index,"-1",SaveModel.timeLevel_ZL,null);//患者取消
                object.put("concleData",array3);//患者取消
@ -3704,12 +3744,12 @@ public class StatisticsEsService {
                object.put("totalData",array);//新增量
                JSONArray array1 = weekTotalStatistics(startDate,endDate,area,level,index1,"0",SaveModel.timeLevel_ZL);//未接诊
                object.put("noReceiveData",array1);;//未接诊
                JSONArray array2 = weekTotalStatistics(startDate,endDate,area,level,index1,"1,2",SaveModel.timeLevel_ZL);//已接诊
                JSONArray array2 = weekTotalStatistics(startDate,endDate,area,level,index,"1,2,3",SaveModel.timeLevel_ZL);//已接诊
                object.put("haveReceiveData",array2);//已接诊
                JSONArray array3 = weekTotalStatistics(startDate,endDate,area,level,index,"-1",SaveModel.timeLevel_ZL);//患者取消
                object.put("concleData",array3);//患者取消
                JSONArray array4 = weekTotalStatistics(startDate,endDate,area,level,index,"3",SaveModel.timeLevel_ZL);//已结束
                object.put("endData",array3);//已结束
                object.put("endData",array4);//已结束
            }
        }else if (interval==3){
@ -3729,7 +3769,7 @@ public class StatisticsEsService {
                object.put("totalData",array);
                JSONArray array1 = monthTotalStatistics2(startDate,endDate,area,level,index1,"0",SaveModel.timeLevel_ZL,null);
                object.put("noReceiveData",array1);
                JSONArray array2 = monthTotalStatistics2(startDate,endDate,area,level,index1,"1,2",SaveModel.timeLevel_ZL,null);
                JSONArray array2 = monthTotalStatistics2(startDate,endDate,area,level,index,"1,2,3",SaveModel.timeLevel_ZL,null);
                object.put("haveReceiveData",array2);
                JSONArray array3 = monthTotalStatistics2(startDate,endDate,area,level,index,"-1",SaveModel.timeLevel_ZL,null);
                object.put("concleData",array3);
@ -3777,11 +3817,11 @@ public class StatisticsEsService {
            //咨询总数
            List<SaveModel> total = elasticsearchUtil.findListDateQuotaLevel0(startTime, endTime, area, level, index1, SaveModel.timeLevel_ZL, lowLevel);
            //已接诊
            List<SaveModel> haveReceiveTotal = elasticsearchUtil.findListDateQuotaLevel1(startTime, endTime, area, level, index, SaveModel.timeLevel_ZL, lowLevel,"1,2");
            List<SaveModel> haveReceiveTotal = elasticsearchUtil.findListDateQuotaLevel1(startTime, endTime, area, level, index, SaveModel.timeLevel_ZL, lowLevel,"1,2,3");
            //未接诊
            List<SaveModel> noReceiveTotal = elasticsearchUtil.findListDateQuotaLevel1(startTime, endTime, area, level, index, SaveModel.timeLevel_ZL, lowLevel,"0");
            result.put("resultList", getCoutListPC1(level, lowLevel, endTotal, total, haveReceiveTotal,noReceiveTotal,concleTotal));
        }
    }
        return result;
@ -3892,6 +3932,7 @@ public class StatisticsEsService {
            rs.put("total", totalNm);
            rs.put("noReceiveCount", noReceiveNm);
            rs.put("haveReceiveCount", haveReceiveNm);
            rs.put("endAndReciveCount",endNm+haveReceiveNm);
            rs.put("code", key);
            resultMaps.add(rs);
        }
@ -4264,7 +4305,23 @@ public class StatisticsEsService {
                }
            }
        }
        object.put("excelData",resultArray);
        List<JSONObject> bindArrayResult = JSONArray.parseArray(resultArray.toJSONString(), JSONObject.class);
        System.out.println("排序前:"+bindArrayResult);
        Collections.sort(bindArrayResult, new Comparator<JSONObject>() {
            @Override
            public int compare(JSONObject o1, JSONObject o2) {
                double a = o1.getDouble("specialist");
                double b = o2.getDouble("specialist");
                if (a > b) {
                    return -1;
                } else if(a == b) {
                    return 0;
                } else
                    return 1;
            }
        });
        JSONArray jsonArray = JSONArray.parseArray(bindArrayResult.toString());
        object.put("excelData",jsonArray);
        return object;
    }
    /**
@ -4436,23 +4493,177 @@ public class StatisticsEsService {
        object.put("excelData",resultArray);
        return object;
    }
    /**
     * 日期柱状图处方变换
     *
     *
     * app端头部收入统计
     * @param startDate
     * @param endDate
     * @param area
     * @param level 2科室
     * @param level
     * @param index
     * @param level2_type 4 医院
     * @return
     * @throws Exception
     *//*
public JSONObject changePrescriptionLineOnlyTop(String startDate, String endDate, String area, int level, String index,int interval, String level2_type,String key1,String key2) throws Exception {
    if(StringUtils.isNotBlank(key1)&&StringUtil.isBlank(key2)){
        List<SaveModel> precriptionList = elasticsearchUtil.findDateQuotaLevel1(startDate, endDate, area, level, index, SaveModel.timeLevel_DDL, "", "", level2_type);
     */
    public  JSONObject appIndexHead(String startDate, String endDate, String area, int level, String index) throws Exception {
        JSONObject object = new JSONObject();
        String nowStartDate = DateUtil.getStringDateShort();
        String monthStartDate = DateUtil.getFristDayOfMonth();
        String monthEndDate = DateUtil.getLastDayOfMonth();
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        //今日收入总收入
        SaveModel nowPrice = elasticsearchUtil.findOneDateQuotaLevel0(nowStartDate, nowStartDate, area, level, index, SaveModel.timeLevel_ZL);
        object.put("nowPrice",decimalFormat.format(nowPrice.getResult1()));
        //本月总收入
        SaveModel nowMonthPrice = elasticsearchUtil.findOneDateQuotaLevel0(monthStartDate, monthEndDate, area, level, index, SaveModel.timeLevel_ZL);
        object.put("nowMonthPrice",decimalFormat.format(nowPrice.getResult1()));
        SaveModel totalPrice = elasticsearchUtil.findOneDateQuotaLevel0(nowStartDate, nowStartDate, area, level, index, SaveModel.timeLevel_DDL);
        object.put("totalPrice",decimalFormat.format(totalPrice.getResult1()));
        return object;
    }
    public  JSONObject appIndexCenter(String startDate, String endDate, String area, int level, String index) throws Exception {
        JSONObject object = new JSONObject();
        //图文复诊
        SaveModel topicTotal = elasticsearchUtil.findOneDateQuotaLevel0(startDate, endDate, area, level, "12", SaveModel.timeLevel_ZL);
        object.put("topicTotal",topicTotal.getResult1());
        //视频复诊
        SaveModel videoTotal = elasticsearchUtil.findOneDateQuotaLevel0(startDate, endDate, area, level, "16", SaveModel.timeLevel_ZL);
        object.put("videoTotal",videoTotal.getResult1());
        //专家咨询
        SaveModel specialistTotal = elasticsearchUtil.findOneDateQuotaLevel0(startDate, endDate, area, level, "6", SaveModel.timeLevel_ZL);
        object.put("specialistTotal",specialistTotal.getResult1());
        //专科协同
        SaveModel synergyTotal = elasticsearchUtil.findOneDateQuotaLevel0(startDate, endDate, area, level, "14", SaveModel.timeLevel_ZL);
        object.put("synergyTotal",synergyTotal.getResult1());
        return object;
    }
    public  JSONObject appPriceHead(String startDate, String endDate, String area,int level, String index) throws Exception {
        JSONObject object = new JSONObject();
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        //图文复诊
        SaveModel topicTotal = elasticsearchUtil.findOneDateQuotaLevel2(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL,"1","1");
        object.put("topicTotal",decimalFormat.format(topicTotal.getResult1()));
        //视频复诊
        SaveModel videoTotal = elasticsearchUtil.findOneDateQuotaLevel2(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL,"1","2");
        object.put("videoTotal",decimalFormat.format(videoTotal.getResult1()));
        //专家咨询
        SaveModel specialistTotal = elasticsearchUtil.findOneDateQuotaLevel1(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL,"3");
        object.put("specialistTotal",decimalFormat.format(specialistTotal.getResult1()));
        //专科协同
        SaveModel synergyTotal = elasticsearchUtil.findOneDateQuotaLevel1(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL,"2");
        object.put("synergyTotal",decimalFormat.format(synergyTotal.getResult1()));
        //总收入
        SaveModel totalPrice = elasticsearchUtil.findOneDateQuotaLevel0(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL);
        object.put("totalPrice",decimalFormat.format(totalPrice.getResult1()));
        return object;
    }
    public  JSONObject appPrescriptionHead(String startDate, String endDate, String area,int level, String index) throws Exception {
        JSONObject object = new JSONObject();
        //图文复诊
        SaveModel topicTotal = elasticsearchUtil.findOneDateQuotaLevel2NoSlaveKey1(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL,"1");
        object.put("topicTotal",topicTotal.getResult1());
        //视频复诊
        SaveModel videoTotal = elasticsearchUtil.findOneDateQuotaLevel2NoSlaveKey1(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL,"2");
        object.put("videoTotal",videoTotal.getResult1());
        //快递
        SaveModel expressTotal = elasticsearchUtil.findOneDateQuotaLevel3NoSlaveKey2(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL,"0");
        object.put("express",expressTotal.getResult1());
        //自取
        SaveModel inviteTotal = elasticsearchUtil.findOneDateQuotaLevel3NoSlaveKey2(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL,"1");
        object.put("invite",inviteTotal.getResult1());
        //总计
        SaveModel specialistTotal = elasticsearchUtil.findOneDateQuotaLevel0(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL);
        object.put("total",specialistTotal.getResult1());
        return object;
    }
    public JSONObject appCenterCircular(String startDate, String endDate, String area, int level, String index,String flag) throws Exception {
        JSONObject object = new JSONObject();
        if (index.equalsIgnoreCase("3")||index.equalsIgnoreCase("3,21")||index.equalsIgnoreCase("21")){
            //协同门诊
            SaveModel saveModel1 = null;
            saveModel1 = elasticsearchUtil.findOneDateQuotaLevel1(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL, "2");
            //图文复诊
            SaveModel saveModel2 = null;
            //saveModel2 = elasticsearchUtil.findOneDateQuotaLevel2(endDate, endDate, area, level, index, SaveModel.timeLevel_DDL, "1","1");
            saveModel2 = elasticsearchUtil.findOneDateQuotaLevel2(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL, "1","1");
            //视频复诊
            SaveModel saveModel3 = null;
/*
    saveModel3 = elasticsearchUtil.findOneDateQuotaLevel2(endDate, endDate, area, level, index, SaveModel.timeLevel_DDL, "1","2");
*/
            saveModel3 = elasticsearchUtil.findOneDateQuotaLevel2(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL, "1","2");
            Double specialistCount =0.0;
            //专科咨询
            SaveModel saveModel4 = null;
            saveModel4 = elasticsearchUtil.findOneDateQuotaLevel1(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL, "3");
            specialistCount = saveModel4.getResult1();//专家咨询数量
            //总量
            SaveModel saveModel5 = null;
            saveModel5 = elasticsearchUtil.findOneDateQuotaLevel0(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL);
            Double synergyCount = saveModel1.getResult1();//协同门诊数量
            Double topicCount = saveModel2.getResult1();//图文复诊数量
            Double videoCount = saveModel3.getResult1();//视频复诊数量
            Double total = saveModel5.getResult1();//总量
            DecimalFormat decimalFormat = new DecimalFormat("0.00");
            object.put("specialistCount",decimalFormat.format(specialistCount));//专家咨询数
            object.put("specialistRate",getRange(specialistCount.intValue(),total.intValue(),0));
            object.put("synergyCount",decimalFormat.format(synergyCount));//专家咨询数
            object.put("synergyRate",getRange(synergyCount.intValue(),total.intValue(),0));
            object.put("topicCount",decimalFormat.format(topicCount));//图文复诊数量
            object.put("topicRate",getRange(topicCount.intValue(),total.intValue(),0));
            object.put("videoCount",decimalFormat.format(videoCount));//视频复诊数量
            object.put("videoRate",getRange(videoCount.intValue(),total.intValue(),0));
            object.put("total",decimalFormat.format(total));
        }else if (index.equalsIgnoreCase("20")){
            if (flag.equalsIgnoreCase("1")){
                //图文复诊
                SaveModel saveModel2 = null;
                saveModel2 = elasticsearchUtil.findOneDateQuotaLevel2NoSlaveKey1(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL, "1");
                //视频复诊
                SaveModel saveModel3 = null;
                saveModel3 = elasticsearchUtil.findOneDateQuotaLevel2NoSlaveKey1(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL, "2");
                //总数
                SaveModel saveModel1 = null;
                saveModel1 = elasticsearchUtil.findOneDateQuotaLevel0(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL);
                Double topicCount = saveModel2.getResult1();//图文复诊数量
                Double videoCount = saveModel3.getResult1();//视频复诊数量
                Double total = saveModel1.getResult1();//总量
                object.put("topicCount",topicCount);//图文复诊数量
                object.put("topicRate",getRange(topicCount.intValue(),total.intValue(),0));
                object.put("videoCount",videoCount);//视频复诊数量
                object.put("videoRate",getRange(videoCount.intValue(),total.intValue(),0));
                object.put("total",total);
            }else if (flag.equalsIgnoreCase("2")){
                //快递
                SaveModel saveModel2 = null;
                saveModel2 = elasticsearchUtil.findOneDateQuotaLevel3NoSlaveKey2(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL, "0");
                //自取
                SaveModel saveModel3 = null;
                saveModel3 = elasticsearchUtil.findOneDateQuotaLevel3NoSlaveKey2(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL, "1");
                //总数
                SaveModel saveModel1 = null;
                saveModel1 = elasticsearchUtil.findOneDateQuotaLevel0(startDate, endDate, area, level, index, SaveModel.timeLevel_ZL);
                Double topicCount = saveModel2.getResult1();//图文复诊数量
                Double videoCount = saveModel3.getResult1();//视频复诊数量
                Double total = saveModel1.getResult1();//总量
                object.put("express",topicCount);//快递数量
                object.put("expressRate",getRange(topicCount.intValue(),total.intValue(),0));
                object.put("invite",videoCount);//自取数量
                object.put("inviteRate",getRange(videoCount.intValue(),total.intValue(),0));
                object.put("total",total);
            }
        }
        return object;
    }
    return null;
}*/
}

+ 40 - 0
business/es-service/src/main/java/com/yihu/jw/es/util/ElasticsearchUtil.java

@ -1167,6 +1167,27 @@ public class ElasticsearchUtil {
        return (SaveModel) list.get(0);
    }
    /**
     * 根据2级维度的2级指标去聚合 没有一级维度
     * 查询某一天某一个2级维度的某个1级维度和2级维度下的指标  例如查询65岁以上的高血压患者
     *
     * @param startDate 时间 yyyy-mm-dd
     * @param endDate 时间 yyyy-mm-dd
     * @param area      code  厦门市 350200
     * @param level     等级 1 省 2 市 3 区县 4 机构 5团队
     * @param index     指标code
     * @param timelevel // 1日 2年
     * @param slaveKey2 二级维度的key
     * @return
     */
    public SaveModel findOneDateQuotaLevel2NoSlaveKey1(String startDate,String endDate, String area, int level, String index, String timelevel, String slaveKey2) throws Exception {
        if (org.springframework.util.StringUtils.isEmpty(slaveKey2)) {
            slaveKey2 = commonParams;
        }
        List list = findDateQuotaLevel2(startDate, endDate, area, level, index, timelevel, null, slaveKey2, null, null);
        return (SaveModel) list.get(0);
    }
    /**
     * 根据2级维度的1级指标去聚合 没有2级维度
     * 查询某一天某一个2级维度的某个1级维度和2级维度下的指标  例如查询65岁以上的高血压患者
@ -1187,6 +1208,25 @@ public class ElasticsearchUtil {
        return (SaveModel) list.get(0);
    }
    /**
     * 根据2级维度的1级指标去聚合 没有2级维度
     * 查询某一天某一个2级维度的某个1级维度和2级维度下的指标  例如查询65岁以上的高血压患者
     *
     * @param endDate 时间 yyyy-mm-dd
     * @param area      code  厦门市 350200
     * @param level     等级 1 省 2 市 3 区县 4 机构 5团队
     * @param index     指标code
     * @param timelevel // 1日 2年
     * @param slaveKey1 二级维度的key
     * @return
     */
    public SaveModel findOneDateQuotaLevel3NoSlaveKey2(String startDate,String endDate, String area, int level, String index, String timelevel, String slaveKey1) throws Exception {
        if (org.springframework.util.StringUtils.isEmpty(slaveKey1)) {
            slaveKey1 = commonParams;
        }
        List list = findDateQuotaLevel2(startDate, endDate, area, level, index, timelevel, slaveKey1, null, null, null);
        return (SaveModel) list.get(0);
    }
    /**
     * 2级维度
     * 查询某个时间区间某一个2级维度的某个1级维度和2级维度下的指标  例如查询65岁以上的高血压患者

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

@ -16,15 +16,19 @@ import com.yihu.jw.entity.base.im.ConsultTeamLogDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.score.BaseEvaluateDO;
import com.yihu.jw.entity.base.score.BaseEvaluateScoreDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalWaitingRoomDO;
import com.yihu.jw.entity.hospital.message.BaseBannerDoctorDO;
import com.yihu.jw.entity.hospital.message.BaseUserMessageDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.hospital.prescription.WlyyConsultAdvice;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.evaluate.score.dao.BaseEvaluateDao;
import com.yihu.jw.evaluate.score.dao.BaseEvaluateScoreDao;
import com.yihu.jw.hospital.consult.dao.HospitalWaitingRoomDao;
import com.yihu.jw.hospital.consult.dao.WlyyConsultAdviceDao;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.message.dao.BaseBannerDoctorDao;
import com.yihu.jw.hospital.message.dao.BaseUserMessageDao;
import com.yihu.jw.hospital.message.service.SystemMessageService;
@ -49,6 +53,7 @@ import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.jw.wechat.service.WxAccessTokenService;
import com.ylzinfo.onepay.sdk.utils.StringUtil;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@ -119,6 +124,8 @@ public class ImService {
	private PrescriptionService prescriptionService;
	@Autowired
	private BaseBannerDoctorDao baseBannerDoctorDao;
	@Autowired
	private WlyyHospitalSysDictDao hospitalSysDictDao;
	
	@Value("${im.data_base_name}")
	private String data_base_name;
@ -161,6 +168,8 @@ public class ImService {
	private BaseUserMessageDao userMessageDao;
	@Autowired
	private BaseDoctorHospitalDao doctorHospitalDao;
	@Autowired
	private WlyyConsultAdviceDao wlyyConsultAdviceDao;
	
	@Value("${wechat.id}")
	private String wxId;
@ -206,7 +215,8 @@ public class ImService {
				"d.job_title_name AS \"jobTitleName\", " +
				"h.dept_name AS \"deptName\", " +
				"h.org_name AS \"hospitalName\", " +
				"a.pay_status AS \"payStatus\" "+
				"a.pay_status AS \"payStatus\", "+
				"a.source AS \"source\" "+
				"FROM wlyy_consult a," +
				"wlyy_consult_team b," +
				"base_doctor d, " +
@ -793,7 +803,7 @@ public class ImService {
			accessToken = wxAccessTokenService.getWxAccessTokenById(wechat_appid).getAccessToken();
		}
		InputStream is = null;
		String url = "http://file.api.weixin.qq.com/cgi-bin/media/get?access_token=" + accessToken + "&media_id=" + mediaId;
		String url = "https://api.weixin.qq.com/cgi-bin/media/get?access_token=" + accessToken + "&media_id=" + mediaId;
//		String url = "http://file.api.weixin.qq.com/cgi-bin/media/get?access_token=30_OBJbMMPW9TnyGHKf32bcjkXtxWnzBrtqWlSMBnNk8MWpJ6qis2TnsecRYNZImgahdx30WrsI1bGco6K67-j4sT1QkDxYKBrVvjaYF6QgbY8dgBMzuoARKoaxtX3ehiYvdCLSUHvogrpF3n0GANIfCHAHUP&media_id=R_060hnyXAFyHD9HaOLl15xhDIzDvcA61-Wz34GkXmCakdrsFJqxrPEBHewmAEK9";
		logger.info("media/get"+url);
		try {
@ -852,7 +862,7 @@ public class ImService {
		logger.info("accessToken 过期时重新下载多媒体文件:wechat_appid:"+wechat_appid);
		logger.info("accessToken 过期时重新下载多媒体文件:mediaId:"+mediaId);
		InputStream is = null;
		String url = "http://file.api.weixin.qq.com/cgi-bin/media/get?access_token=" + accessToken + "&media_id=" + mediaId;
		String url = "https://api.weixin.qq.com/cgi-bin/media/get?access_token=" + accessToken + "&media_id=" + mediaId;
		logger.info("media/get"+url);
		try {
			URL urlGet = new URL(url);
@ -884,15 +894,25 @@ public class ImService {
	 * @return
	 * @throws Exception
	 */
	public JSONObject addTeamConsult(ConsultTeamDo ct, String patient, String doctor) throws Exception {
	public JSONObject addTeamConsult(ConsultTeamDo ct, String patient, String doctor,String source) throws Exception {
		JSONObject re = new JSONObject();
		boolean boo = StringUtils.isEmpty(getUnfinishedConsult(patient, doctor));
		logger.info("boo"+boo);
		if (!StringUtils.isEmpty(getUnfinishedConsult(patient, doctor))) {//判断是否有未结束的咨询移到同步方法中
		WlyyHospitalSysDictDO sysDictDO = hospitalSysDictDao.findById("consultClose");
		boolean flag = false;
		if (sysDictDO!=null){
			if (sysDictDO.getDictCode().equalsIgnoreCase("1")){
				flag = true;
			}
		}
		if (!flag){
			if (!StringUtils.isEmpty(getUnfinishedConsult(patient, doctor))) {//判断是否有未结束的咨询移到同步方法中
//			re.put("status", -3);
//			return re;
			throw new RuntimeException("居民还有未结束的专家咨询!");
				throw new RuntimeException("居民还有未结束的专家咨询!");
			}
		}
		
		JSONObject users = new JSONObject();
		users.put(doctor,0);
@ -919,7 +939,7 @@ public class ImService {
		// 医生未读数量为1
		ct.setDoctorRead(1);
		// 添加咨询记录
		ConsultDo consult = addConsult(ct.getPatient(), "专家咨询", ct.getSymptoms(), ct.getImages(), ct.getType());
		ConsultDo consult = addConsult(ct.getPatient(), "专家咨询", ct.getSymptoms(), ct.getImages(), ct.getType(),source);
//		// 设置关联指导
//		consult.setGuidance(ct.getGuidance());
		// 设置咨询标识
@ -992,7 +1012,7 @@ public class ImService {
	 * @param type 咨询类型:9在线复诊,13专家咨询
	 * @return
	 */
	public ConsultDo addConsult(String patient, String title, String symptoms, String images, int type) {
	public ConsultDo addConsult(String patient, String title, String symptoms, String images, int type,String source) {
		ConsultDo consult = new ConsultDo();
		consult.setId(UUID.randomUUID().toString().replaceAll("-", ""));
		consult.setCzrq(new Date());
@ -1003,6 +1023,7 @@ public class ImService {
		consult.setImages(images);
		consult.setType(type);
		consult.setPayStatus(0);
		consult.setSource(source);
		return consultDao.save(consult);
	}
	
@ -1087,7 +1108,7 @@ public class ImService {
	 * @param reason
	 * @return
	 */
	public JSONObject addPrescriptionConsult(String outpatientCode, String patient,String doctorCode, ConsultTeamDo ct, String reason, Integer type,String wxId) throws Exception {
	public JSONObject addPrescriptionConsult(String outpatientCode, String patient,String doctorCode, ConsultTeamDo ct, String reason, Integer type,String wxId,String source) throws Exception {
		
		synchronized (outpatientCode.intern()) {
			
@ -1208,7 +1229,7 @@ public class ImService {
				//添加就诊图片
				ct.setImages(wlyyOutpatientDO.getDiseaseImg());
				// 添加咨询记录
				ConsultDo consult = addConsult(ct.getPatient(), consultTitle, ct.getSymptoms(), ct.getImages(), ct.getType());
				ConsultDo consult = addConsult(ct.getPatient(), consultTitle, ct.getSymptoms(), ct.getImages(), ct.getType(),wlyyOutpatientDO.getSource());
				// 设置关联指导
				consult.setGuidance(ct.getGuidance());
				//关联业务code
@ -1326,7 +1347,7 @@ public class ImService {
	 * 添加复诊咨询
	 * @return
	 */
	public JSONObject addConsult(String outpatientCode, String patient,String doctorCode, ConsultTeamDo ct, String reason, Integer type,String wxId) throws Exception {
	public JSONObject addConsult(String outpatientCode, String patient,String doctorCode, ConsultTeamDo ct, String reason, Integer type,String wxId,String source) throws Exception {
		//1、获取his就诊记录详情(保存续方表、药品续方信息表、续方疾病类型表)
		WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findOne(outpatientCode);
		BaseDoctorDO doctor = baseDoctorDao.findById(doctorCode);
@ -1388,7 +1409,7 @@ public class ImService {
		//添加就诊图片
		ct.setImages(wlyyOutpatientDO.getDiseaseImg());
		// 添加咨询记录
		ConsultDo consult = addConsult(ct.getPatient(), consultTitle, ct.getSymptoms(), ct.getImages(), ct.getType());
		ConsultDo consult = addConsult(ct.getPatient(), consultTitle, ct.getSymptoms(), ct.getImages(), ct.getType(),wlyyOutpatientDO.getSource());
		// 设置关联指导
		consult.setGuidance(ct.getGuidance());
		//关联业务code
@ -1639,7 +1660,17 @@ public class ImService {
					businessOrderDO  = businessOrderDao.selectByRelationCode(consult);
				}
				if (businessOrderDO!=null){
					ykyyService.updateYktOrderStatus(businessOrderDO.getOrderNo(),"4");
					String sql ="SELECT * FROM topics t where " +
							"t.id='"+consult+"' and t.reply_user is null and t.reply is null and t.status IN(0,1) ";
					List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
					System.out.println("sql+-----"+sql);
					if (null!=mapList&&mapList.size()>0&&mapList.size()==1){
						//医生没回复的话要把状态改为关闭 status=?
						System.out.println("-------------------进入未回复状态同步--------------------");
						ykyyService.updateYktOrderStatus(businessOrderDO.getOrderNo(),"3");
					}else {
						ykyyService.updateYktOrderStatus(businessOrderDO.getOrderNo(),"4");
					}
				}
			}
		}
@ -2145,7 +2176,8 @@ public class ImService {
					"d.idcard as \"patientIdcard\"," +
					"d.sex as \"patientSex\"," +
					"d.photo AS \"patientPhoto\", " +
					"b.doctor as \"doctor\"  "+
					"b.doctor as \"doctor\" ,"+
					"a.source as \"source\"  "+
					"FROM wlyy_consult a," +
					"wlyy_consult_team b," +
					"base_patient d " +
@ -2181,7 +2213,8 @@ public class ImService {
					"op.general_doctor as \"generalDoctor\"," +
					"op.icd10_name as \"icd10Name\"," +
					"d.photo AS \"patientPhoto\" , " +
					"b.doctor as \"doctor\"  "+
					"b.doctor as \"doctor\" ,"+
                    "a.source as \"source\"  "+
					"FROM wlyy_consult_team b," +
					"base_patient d," +
					"wlyy_consult a   " +
@ -2269,7 +2302,21 @@ public class ImService {
					map.put("doctorName",baseDoctorDO.getName());
				}
			}
			if (map.get("id")!=null){
				if("1".equals(type) || "15".equals(type) || type.contains(",")){
					String consultCode = map.get("id").toString();
					List<WlyyConsultAdvice> consultAdvices = wlyyConsultAdviceDao.getByConsult(consultCode);
					StringBuffer content = new StringBuffer();
					for (WlyyConsultAdvice consultAdvice:consultAdvices){
						content.append(consultAdvice.getAdviceValue()+",");
					}
					if (content!=null&&content.length()>0){
						System.out.println("content+====="+content);
						content.deleteCharAt(content.length()-1);
					}
					map.put("icd10Name",content);
				}
			}
		}
		return mapList;
	}
@ -2526,7 +2573,7 @@ public class ImService {
	 * @param images
	 * @return
	 */
	public String generalAddExpertConsult(String patient_code, String general_doctor, String special_doctor, String when, String symptoms, String images, ConsultTeamDo ct) throws Exception {
	public String generalAddExpertConsult(String patient_code, String general_doctor, String special_doctor, String when, String symptoms, String images, ConsultTeamDo ct,String source) throws Exception {
		// 设置咨询类型:15
		ct.setType(15);
		// 设置发病时间
@ -2589,7 +2636,7 @@ public class ImService {
		// 医生未读数量为1
		ct.setDoctorRead(1);
		// 添加咨询记录
		ConsultDo consult = addConsult(ct.getPatient(), consultTitle, ct.getSymptoms(), ct.getImages(), ct.getType());
		ConsultDo consult = addConsult(ct.getPatient(), consultTitle, ct.getSymptoms(), ct.getImages(), ct.getType(),source);
		// 设置关联指导
//		consult.setGuidance(ct.getGuidance());
		//关联业务code
@ -3030,7 +3077,7 @@ public class ImService {
					"wlyy_consult_team b," +
					"base_patient d  " +
					" WHERE a.id=b.consult " +
					" AND b.patient=d.id AND b.doctor='" + doctorCode + "' AND b.type in (1,15,17) and b.status = 0 and a.pay_status=1 " +
					" AND b.patient=d.id AND b.doctor='" + doctorCode + "' AND b.type in (1,15,17) and b.status = 0 and a.pay_status=1" +
					" ORDER BY a.czrq desc ";
		List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(sql);
		Long consultCount = 0l;
@ -3082,7 +3129,9 @@ public class ImService {
			sql = "SELECT " +
					" DISTINCT op.id AS \"outpatientId\"," +
					"op.description AS \"title\"," +
					"op.description AS \"symptoms\",";
					"op.description AS \"symptoms\","+
					//添加排序的列
					"op.create_time AS \"createTime\",";
			if("xm_ykyy_wx".equals(wxId)){
				if (flag){
					sql = sql + "date_format(op.create_time,'%Y-%m-%d %H:%i:%S' )  AS \"czrq\",";
@ -3151,8 +3200,16 @@ public class ImService {
			sql =sql +" ORDER BY op.create_time DESC";
		}
		
		return hibenateUtils.createSQLQuery(sql);
		List<Map<String,Object>> mapList = hibenateUtils.createSQLQuery(sql);
		for (Map<String,Object> map:mapList){
			if (map.get("patientIdcard")!=null){
				String idcard = map.get("patientIdcard").toString();
				Integer age =IdCardUtil.getAgeForIdcard(idcard);
				map.put("patientAge",age);
			}
		}
		return mapList;
	}
	
	/**

+ 12 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/doctor/BaseDoctorDO.java

@ -244,6 +244,10 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
     * 上线下线状态
     */
    private String online;//1上线0下线
    /**
     * ca标识
     */
    private Integer caFlag;
    @Column(name = "popularity")
    public Integer getPopularity() {
@ -620,4 +624,12 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
        this.online = online;
    }
    @Column(name = "ca_flag")
    public Integer getCaFlag() {
        return caFlag;
    }
    public void setCaFlag(Integer caFlag) {
        this.caFlag = caFlag;
    }
}

+ 10 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/im/ConsultDo.java

@ -38,6 +38,16 @@ public class ConsultDo extends UuidIdentityEntity {
	private String relationCode;
	//支付状态
	private Integer payStatus;
	//来源
	private String source;
	public String getSource() {
		return source;
	}
	public void setSource(String source) {
		this.source = source;
	}
	
	public String getPatient() {
		return patient;

+ 18 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/ca/OauthCaConfigDO.java

@ -14,6 +14,8 @@ public class OauthCaConfigDO extends UuidIdentityEntity {
    private String url;
    private String remark;
    private String clientId;
    private String clientSecret;
    public String getUrl() {
        return url;
@ -30,4 +32,20 @@ public class OauthCaConfigDO extends UuidIdentityEntity {
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public String getClientId() {
        return clientId;
    }
    public void setClientId(String clientId) {
        this.clientId = clientId;
    }
    public String getClientSecret() {
        return clientSecret;
    }
    public void setClientSecret(String clientSecret) {
        this.clientSecret = clientSecret;
    }
}

+ 91 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/dict/PrivateDictDO.java

@ -0,0 +1,91 @@
package com.yihu.jw.entity.hospital.dict;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Entity;
import javax.persistence.Table;
@Entity
@Table(name = "private_dict")
public class PrivateDictDO extends UuidIdentityEntityWithOperator {
    /*
     * dictCode
     */
    private String dictCode;
    /*
     * dictName
     */
    private String dictName;
    /*
     * dictValue
     */
    private String dictValue;
    /*
     * 是否删除
     */
    private Integer isDel;
    /*
     * hospitalCode
     */
    private String hospitalCode;
    private String hospitalName;
    private String imgUrl;
    public String getImgUrl() {
        return imgUrl;
    }
    public void setImgUrl(String imgUrl) {
        this.imgUrl = imgUrl;
    }
    public String getDictName() {
        return dictName;
    }
    public void setDictName(String dictName) {
        this.dictName = dictName;
    }
    public String getHospitalCode() {
        return hospitalCode;
    }
    public void setHospitalCode(String hospitalCode) {
        this.hospitalCode = hospitalCode;
    }
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    public String getDictCode() {
        return dictCode;
    }
    public void setDictCode(String dictCode) {
        this.dictCode = dictCode;
    }
    public String getDictValue() {
        return dictValue;
    }
    public void setDictValue(String dictValue) {
        this.dictValue = dictValue;
    }
    public Integer getIsDel() {
        return isDel;
    }
    public void setIsDel(Integer isDel) {
        this.isDel = isDel;
    }
}

+ 27 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyPrescriptionDO.java

@ -268,6 +268,24 @@ public class WlyyPrescriptionDO extends UuidIdentityEntity {
     */
    private Integer signFlag;
    /**
     * 单据号
     */
    private String voucherNo;
    /**
     * 处方审方唯一标识
     */
    private String hisId;
    @Column(name = "his_id")
    public String getHisId() {
        return hisId;
    }
    public void setHisId(String hisId) {
        this.hisId = hisId;
    }
    @Column(name = "outpatient_id")
    public String getOutpatientId() {
        return outpatientId;
@ -666,4 +684,13 @@ public class WlyyPrescriptionDO extends UuidIdentityEntity {
    public void setSignFlag(Integer signFlag) {
        this.signFlag = signFlag;
    }
    @Column(name = "voucher_no")
    public String getVoucherNo() {
        return voucherNo;
    }
    public void setVoucherNo(String voucherNo) {
        this.voucherNo = voucherNo;
    }
}

+ 36 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyPrescriptionEmrDO.java

@ -56,6 +56,42 @@ public class WlyyPrescriptionEmrDO extends UuidIdentityEntityWithOperator {
     * 标识是否删除
     */
    private Integer del;
    /**
     *流行病史
     */
    private String popularHistory;
    /**
     *过敏史
     */
    private String allergicHistory;
    /**
     *特殊病史
     */
    private String specialHistory;
    @Column(name = "popular_history")
    public String getPopularHistory() {
        return popularHistory;
    }
    public void setPopularHistory(String popularHistory) {
        this.popularHistory = popularHistory;
    }
    @Column(name = "allergic_history")
    public String getAllergicHistory() {
        return allergicHistory;
    }
    public void setAllergicHistory(String allergicHistory) {
        this.allergicHistory = allergicHistory;
    }
    @Column(name = "special_history")
    public String getSpecialHistory() {
        return specialHistory;
    }
    public void setSpecialHistory(String specialHistory) {
        this.specialHistory = specialHistory;
    }
    @Column(name = "complaint")
    public String getComplaint() {

+ 13 - 3
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/YkEmrJcsqDO.java

@ -3,6 +3,7 @@ package com.yihu.jw.entity.hospital.prescription;
import com.fasterxml.jackson.annotation.JsonFormat;
import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;
/**
@ -44,11 +45,20 @@ public class YkEmrJcsqDO {
    private String jcxm;//项目名称
    private Integer qxbz;//0
    private Integer yjxh;//关联ms_yj01里面的yjxh
    private Integer xmdj;//项目单价
    private BigDecimal xmdj;//项目单价
    private String xmdw;//项目单位
    private Integer xmid;//项目id  VEMR_ORDER_ITEM_MX
    private Integer sqsl;//数量
    private Integer jzxh;//就诊序号HLWYS_MZ_JZLS的JZXH对应
    private Integer jsbz;
    @Column(name = "JSBZ")
    public Integer getJsbz() {
        return jsbz;
    }
    public void setJsbz(Integer jsbz) {
        this.jsbz = jsbz;
    }
    @Basic
    @Id
@ -236,11 +246,11 @@ public class YkEmrJcsqDO {
    }
    @Basic
    @Column(name = "XMDJ")
    public Integer getXmdj() {
    public BigDecimal getXmdj() {
        return xmdj;
    }
    public void setXmdj(Integer xmdj) {
    public void setXmdj(BigDecimal xmdj) {
        this.xmdj = xmdj;
    }
    @Basic

+ 7 - 6
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/YkMsYj02DO.java

@ -2,6 +2,7 @@ package com.yihu.jw.entity.hospital.prescription;
import javax.persistence.*;
import javax.persistence.criteria.From;
import java.math.BigDecimal;
/*
 * 检查明细
@ -14,9 +15,9 @@ public class YkMsYj02DO {
    private Integer ylxh;//组套明细里关联VEMR_ORDER_ITEM 里面  ITEM_CODE
    private Integer xmlx;//SELECT XMLX  javax.persistence.criteria.From GY_YLSF Where FYXH =l l_fyxh   查询后结果写入
    private Integer yjzx;//明细第一条是1,其它是0
    private Integer Yldj;//单价  select * from  portal_his.gy_ylsf@YKZXTEST where fyxh = l l_fyxh
    private BigDecimal Yldj;//单价  select * from  portal_his.gy_ylsf@YKZXTEST where fyxh = l l_fyxh
    private Integer ylsl;//数量 = 取项目明细 * 医生填的数量  参考截图   fysl
    private Integer hjje;//	合计金额
    private BigDecimal hjje;//	合计金额
    private Integer fygb;//SELECT fygb From GY_YLSF Where FYXH =l l_fyxh  查询后结果写入
    private Integer zfbl;//	默认1
    private Integer zxpb;//默认0
@ -69,11 +70,11 @@ public class YkMsYj02DO {
    }
    @Basic
    @Column(name = "YLDJ")
    public Integer getYldj() {
    public BigDecimal getYldj() {
        return Yldj;
    }
    public void setYldj(Integer yldj) {
    public void setYldj(BigDecimal yldj) {
        Yldj = yldj;
    }
    @Basic
@ -87,11 +88,11 @@ public class YkMsYj02DO {
    }
    @Basic
    @Column(name = "HJJE")
    public Integer getHjje() {
    public BigDecimal getHjje() {
        return hjje;
    }
    public void setHjje(Integer hjje) {
    public void setHjje(BigDecimal hjje) {
        this.hjje = hjje;
    }
    @Basic

+ 35 - 2
common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java

@ -398,9 +398,24 @@ public class BaseHospitalRequestMapping {
        public static final String findByPrescriptionCodeByStatus = "/findByPrescriptionCodeByStatus";
        public static final String findByPartsCode = "/findByPartsCode";
        public static final String xzzxFindByPartsCode = "/xzzxFindByPartsCode";
        //检查项目查询
        public static final String xzzxSelectExamApply = "/xzzxSelectExamApply";
        public static final String xzzxSelectLisApply = "/xzzxSelectLisApply";
        //合理用药审核接口
        public static final String xzzxCheckInfo = "/xzzxCheckInfo";
        //审药通过后保存接口
        public static final String xzzxSaveCheckInfo = "/xzzxSaveCheckInfo";
        //作废处方接口
        public static final String xzzxDeleteCheckInfo = "/xzzxDeleteCheckInfo";
        public static final String findDictByName = "/findDictByName";
        public static final String updatePatientDiagnosis = "/updatePatientDiagnosis";
        //删除his处方信息
        public static final String delHisPrescriptionByHisNo = "/delHisPrescriptionByHisNo";
        //保存电子病历
        public static final String saveEmr = "/saveEmr";
        public static final String getJcmb="/getJcmb";
        public static final String getJymb="/getJymb";
        public static final String getTcxz="/getTcxz";
@ -467,7 +482,7 @@ public class BaseHospitalRequestMapping {
        public static final String selectExpireTime = "/selectExpireTime";
        public static final String saveEmr="/saveEmr";
        public static final String saveEmrToEntrance="/saveEmrToEntrance";
        public static final String findEmrByPrescriptionId="/findEmrByPrescriptionId";
@ -1196,6 +1211,15 @@ public class BaseHospitalRequestMapping {
        public static final String downBanner = "/downBanner";
        public static final String onOff = "/onOff";
    }
    /**
     * 隐私策略管理
     */
    public static class PrivateDictManager extends Basic{
        public static final String privateDictManager = "/privateDictManager";
        public static final String findPrivateDict  = "/findPrivateDict";
        public static final String savePrivateDict = "/savePrivateDict";
        public static final String delPrivateDict = "/delPrivateDict";
    }
    /**
     * 患者家人关系管理
     */
@ -1325,6 +1349,11 @@ public class BaseHospitalRequestMapping {
        public static final String consultLinePC = "/consultLinePC";
        public static final String consultListPC = "/consultListPC";
        public static final String indexTotalApp = "/indexTotalApp";
        public static final String appIndexHead = "/appIndexHead";
        public static final String appIndexCenter ="/appIndexCenter";
        public static final String appCenterCircular ="/appCenterCircular";
        public static final String appPriceHead ="/appPriceHead";
        public static final String appPrescriptionHead="/appPrescriptionHead";
    }
@ -1361,6 +1390,10 @@ public class BaseHospitalRequestMapping {
        public static final String querySettledRecord="/querySettledRecord";
        public static final String paySuccessNotice="/paySuccessNotice";
        public static final String findHisPatientInfo="/findHisPatientInfo";
        public static final String privateDictManager = "/privateDictManager";
        public static final String findPrivateDict  = "/findPrivateDict";
        public static final String savePrivateDict = "/savePrivateDict";
        public static final String delPrivateDict = "/delPrivateDict";
    }
    /**

+ 61 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/doctor/CheckInfoVO.java

@ -0,0 +1,61 @@
package com.yihu.jw.restmodel.hospital.doctor;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ApiModel(value = "CheckInfoVO", description = "审药返回药品结果实体")
public class CheckInfoVO {
    @ApiModelProperty(value = "颜色", example = "模块1")
    private String color;
    @ApiModelProperty(value = "警示名称,如:用法用量", example = "模块1")
    private String name;
    @ApiModelProperty(value = "警示级别:\n" +
            "慎用\n" +
            "禁忌/禁用\n" +
            "强制阻断\n", example = "模块1")
    private String warningLevel;
    @ApiModelProperty(value = "警示信息", example = "模块1")
    private String warningInfo;
    @ApiModelProperty(value = "文献出处", example = "模块1")
    private String refResource;
    public String getColor() {
        return color;
    }
    public void setColor(String color) {
        this.color = color;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getWarningLevel() {
        return warningLevel;
    }
    public void setWarningLevel(String warningLevel) {
        this.warningLevel = warningLevel;
    }
    public String getWarningInfo() {
        return warningInfo;
    }
    public void setWarningInfo(String warningInfo) {
        this.warningInfo = warningInfo;
    }
    public String getRefResource() {
        return refResource;
    }
    public void setRefResource(String refResource) {
        this.refResource = refResource;
    }
}

+ 60 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/doctor/PersonInfoVO.java

@ -0,0 +1,60 @@
package com.yihu.jw.restmodel.hospital.doctor;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
@ApiModel(value = "PersonInfoVO", description = "审药返回接口实体")
public class PersonInfoVO {
    @ApiModelProperty(value = "同处方中每条记录的标识号", example = "模块1")
    private String orderId;
    @ApiModelProperty(value = "同处方中每条记录的子标识号", example = "模块1")
    private String orderSubId;
    @ApiModelProperty(value = "医院药品ID", example = "模块1")
    private String drugLoId;
    @ApiModelProperty(value = "医院药品名称", example = "模块1")
    private String drugLoName;
    @ApiModelProperty(value = "药品信息", example = "模块1")
    private List<CheckInfoVO> checkInfoVOS;
    public String getOrderId() {
        return orderId;
    }
    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }
    public String getOrderSubId() {
        return orderSubId;
    }
    public void setOrderSubId(String orderSubId) {
        this.orderSubId = orderSubId;
    }
    public String getDrugLoId() {
        return drugLoId;
    }
    public void setDrugLoId(String drugLoId) {
        this.drugLoId = drugLoId;
    }
    public String getDrugLoName() {
        return drugLoName;
    }
    public void setDrugLoName(String drugLoName) {
        this.drugLoName = drugLoName;
    }
    public List<CheckInfoVO> getCheckInfoVOS() {
        return checkInfoVOS;
    }
    public void setCheckInfoVOS(List<CheckInfoVO> checkInfoVOS) {
        this.checkInfoVOS = checkInfoVOS;
    }
}

+ 9 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/prescription/WlyyPrescriptionVO.java

@ -397,7 +397,16 @@ public class WlyyPrescriptionVO extends UuidIdentityVOWithOperator {
    @ApiModelProperty(value = "医生职称名称", example = "模块1")
    private String jobTitleName;
    @ApiModelProperty(value = "单据号", example = "模块1")
    private String voucherNo;
    public String getVoucherNo() {
        return voucherNo;
    }
    public void setVoucherNo(String voucherNo) {
        this.voucherNo = voucherNo;
    }
    public Double getDrugFee() {
        return drugFee;

+ 1 - 1
gateway/ag-basic/src/main/resources/application.yml

@ -191,7 +191,7 @@ spring:
spring:
  profiles: iotprod
  datasource:
     url: jdbc:mysql://10.90.32.2:20002/iot-base?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true&useSSL=false
     url: jdbc:mysql://10.90.32.3:20002/iot-base?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true&useSSL=false
     username: wlyy
     password: jkzlehr@123
  redis:

+ 1 - 1
gateway/ag-basic/src/main/resources/bootstrap.yml

@ -102,7 +102,7 @@ spring:
  profiles: iotprod
  cloud:
    config:
      uri: ${wlyy.spring.config.uri:http://192.168.120.216:1221}
      uri: ${wlyy.spring.config.uri:http://127.0.0.1:1221}
      label: ${wlyy.spring.config.label:master}
---

+ 4 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/dao/doctor/BaseDoctorDao.java

@ -2,6 +2,7 @@ package com.yihu.jw.security.dao.doctor;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
@ -27,4 +28,7 @@ public interface BaseDoctorDao extends PagingAndSortingRepository<BaseDoctorDO,
    List<BaseDoctorDO> findByMobile(String mobile);
    @Query("from BaseDoctorDO d where  d.del ='1'")
    List<BaseDoctorDO> findByDel();
}

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

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.login.BaseLoginLogDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.restmodel.ResultStatus;
@ -35,6 +36,7 @@ import org.apache.commons.collections.map.HashedMap;
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.data.redis.core.StringRedisTemplate;
import org.springframework.http.*;
import org.springframework.security.authentication.AuthenticationManager;
@ -136,6 +138,10 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    private BasePatientDao basePatientDao;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Value("${wechat.id}")
    private String wechatId;
    @Autowired
    private XzzxService xzzxService;
    @PostConstruct
    private void init() {
@ -925,8 +931,15 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    @RequestMapping(value = "/oauth/getCaQRCode", method = RequestMethod.GET)
    public ObjEnvelop getCaQRCode(){
        logger.info("/oauth/getCaQRCode");
        String sys ="JKZLHLWYLJKGLPT";
        return ObjEnvelop.getSuccess("success", oauthCaConfigSerivce.getQRCode(sys));
        if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
            String sys ="JKZLHLWYLJKGLPT";
            return ObjEnvelop.getSuccess("success", oauthCaConfigSerivce.getQRCode(sys));
        }else if (wechatId.equalsIgnoreCase("xm_xzzx_wx")){
            return ObjEnvelop.getSuccess("success", xzzxService.getQRCode());
        }else {
            return ObjEnvelop.getSuccess("success", null);
        }
    }
    /**
@ -942,18 +955,42 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id is null");
        }
        String username = null;
        String openId= null;
        JSONObject rs = new JSONObject();
        if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
            rs = oauthCaConfigSerivce.getQueryQRCode(qrcode);
            JSONObject data = rs.getJSONObject("data");
            String qrCodeStatus = data.getString("qrCodeStatus");
            if(!"LoginQrCodeBeenScan".equals(qrCodeStatus)){
                return ObjEnvelop.getSuccess("error",rs);
            }
            username = data.getString("userIdCardNum");
        }else if (wechatId.equalsIgnoreCase("xm_xzzx_wx")){
            rs = xzzxService.getTokeninfo(qrcode);
            JSONObject jsonObject = rs.getJSONObject("data");
            logger.info("查询登录信息"+rs);
            String qrCodeStatus = rs.getString("status");
            if(!"0".equals(qrCodeStatus)){
                return ObjEnvelop.getSuccess("error",rs);
            }
            username = jsonObject.getString("userIdcardNum");
            openId = jsonObject.getString("uniqueid");
            jsonObject.put("qrCodeStatus","LoginQrCodeBeenScan");
            rs.put("code",1000);
        }
        JSONObject rs = oauthCaConfigSerivce.getQueryQRCode(qrcode);
        JSONObject data = rs.getJSONObject("data");
        String qrCodeStatus = data.getString("qrCodeStatus");
        if(!"LoginQrCodeBeenScan".equals(qrCodeStatus)){
            return ObjEnvelop.getSuccess("error",rs);
        if (org.apache.commons.lang.StringUtils.isNotBlank(username)){
            BaseDoctorDO doctorDO = doctorDao.findByIdcard(username);
            doctorDO.setOpenid(openId);
            doctorDO.setCaFlag(1);
            doctorDao.save(doctorDO);
        }
        ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
        Map<String, String> parameters = new HashedMap();
        parameters.put("username",data.getString("userIdCardNum"));
        parameters.put("username",username);
        parameters.put("login_type","2");
        parameters.put("grant_type", "ihealthDcotor");

+ 3 - 1
server/svr-authentication/src/main/java/com/yihu/jw/security/service/OauthCaConfigSerivce.java

@ -26,7 +26,8 @@ public class OauthCaConfigSerivce {
    private OauthCaConfigDao oauthCaConfigDao;
    /**
     * 生成二维码
     *
     * 中山生成二维码
     * @param sys
     * @return
     */
@ -44,6 +45,7 @@ public class OauthCaConfigSerivce {
        return null;
    }
    /**
     * 查询二维码授权结果
     * @param qrcode

+ 161 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/service/XzzxService.java

@ -0,0 +1,161 @@
package com.yihu.jw.security.service;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.ca.OauthCaConfigDO;
import com.yihu.jw.security.dao.OauthCaConfigDao;
import com.yihu.jw.security.dao.doctor.BaseDoctorDao;
import com.yihu.jw.security.dao.doctor.BaseDoctorHospitalDao;
import com.yihu.jw.util.http.HttpClientUtil;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * 心脏中心医院
 * Created by wangzhinan on 2020/10/20.
 *
 * @author yeshijie.
 */
@Service
public class XzzxService {
    private Logger logger = LoggerFactory.getLogger(XzzxService.class);
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private OauthCaConfigDao oauthCaConfigDao;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private BaseDoctorHospitalDao doctorHospitalDao;
    /**
     * OAuth登陆-认证请求接口
     * @param
     * @return
     */
    public String getQRCode() {
        try {
            logger.info("生成二维码 getQRCode :");
            OauthCaConfigDO oauthCaConfigDO = oauthCaConfigDao.findOne("oauth_ca_config");
            String url = "";
            if (oauthCaConfigDO!=null){
                url=oauthCaConfigDO.getUrl()+"/gateway/oauth/authorize?responseType=code&clientId="+oauthCaConfigDO.getClientId();
            }
            String response = httpClientUtil.get(url,"utf-8");
            JSONObject rs = new JSONObject();
            JSONObject data = new JSONObject();
            String res = "";
            if (StringUtils.isNotBlank(response)){
                JSONObject object = JSONObject.parseObject(response);
                String status = object.getString("status");
                if (status.equalsIgnoreCase("0")){
                    JSONObject jsonObject = object.getJSONObject("data");
                    String imgBase64 = jsonObject.getString("imgBase64");
                    data.put("resultCode",0);
                    data.put("resultMsg","Success");
                    data.put("qrCodeImg",imgBase64);
                    data.put("qrCode",jsonObject.getString("requestId"));
                    rs.put("code",1000);
                    rs.put("msg","成功");
                    rs.put("data",data);
                }else {
                    rs.put("code",-1);
                    rs.put("msg",object.getString("message"));
                }
            }
            return rs.toJSONString();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    /**
     * OAuth登陆-获取用户信息
     * @param requestId
     * @return
     */
    public JSONObject getTokeninfo(String requestId){
        try {
            OauthCaConfigDO oauthCaConfigDO = oauthCaConfigDao.findOne("oauth_ca_config");
            String url = "";
            if (oauthCaConfigDO!=null){
                url=oauthCaConfigDO.getUrl()+"/gateway/oauth/tokeninfo?clientId="+oauthCaConfigDO.getClientId()+"&requestId="+requestId+"";
            }
            String response = httpClientUtil.get(url,"utf-8");
            logger.info("验证二维码 getQueryQRCode :"+response);
            return JSONObject.parseObject(response);
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
    public String synDoctorToCa(String clientId,String requestId,String doctorId){
        try {
            OauthCaConfigDO oauthCaConfigDO = oauthCaConfigDao.findOne("oauth_ca_config");
            String url = "";
            if (oauthCaConfigDO!=null){
                url=oauthCaConfigDO.getUrl()+"/gateway/doctor/synDoctor";
            }
            if (StringUtils.isNotBlank(doctorId)){
                BaseDoctorDO doctorDO = doctorDao.findById(doctorId);
                List<BaseDoctorHospitalDO> doctorHospitalDOS = doctorHospitalDao.findByDoctorCode(doctorId);
                JSONObject body = new JSONObject();
                JSONObject head = new JSONObject();
                head.put("clientId","2017070411003376");
                head.put("clientSecret","2017070411003360");
                body.put("head",head);
                JSONObject by= new JSONObject();
                by.put("uid",doctorDO.getIdcard());
                by.put("uidCardType","SF");
                by.put("doctorName",doctorDO.getName());
                by.put("phone",doctorDO.getMobile());
                if (doctorHospitalDOS!=null&&doctorHospitalDOS.size()!=0){
                    by.put("department",doctorHospitalDOS.get(0).getOrgName());
                    by.put("department",doctorHospitalDOS.get(0).getDeptName());
                }
                body.put("body",by);
                String response = httpClientUtil.sendPost(url,body.toJSONString());
                logger.info("同步医生信息"+response);
                return  response;
            }else {
                List<BaseDoctorDO> doctorDOList = doctorDao.findByDel();
                for (BaseDoctorDO doctorDO:doctorDOList){
                    List<BaseDoctorHospitalDO> doctorHospitalDOS = doctorHospitalDao.findByDoctorCode(doctorDO.getId());
                    JSONObject body = new JSONObject();
                    JSONObject head = new JSONObject();
                    head.put("clientId","2017070411003376");
                    head.put("clientSecret","2017070411003360");
                    body.put("head",head);
                    JSONObject by= new JSONObject();
                    by.put("uid",doctorDO.getIdcard());
                    by.put("uidCardType","SF");
                    by.put("doctorName",doctorDO.getName());
                    by.put("phone",doctorDO.getMobile());
                    if (doctorHospitalDOS!=null&&doctorHospitalDOS.size()!=0){
                        by.put("orgName",doctorHospitalDOS.get(0).getOrgName());
                        by.put("department",doctorHospitalDOS.get(0).getDeptName());
                    }
                    body.put("body",by);
                    String response = httpClientUtil.sendPost(url,body.toJSONString());
                    logger.info("同步医生信息"+response);
                }
            }
            return null;
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}

+ 26 - 1
server/svr-authentication/src/main/resources/application.yml

@ -78,6 +78,9 @@ wlyy:
testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wechat:
  id: xm_zsyy_wx  # base库中,wx_wechat 的id字段
---
spring:
  profiles: jwtest
@ -104,6 +107,9 @@ testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wechat:
  id: xm_zsyy_wx  # base库中,wx_wechat 的id字段
---
spring:
  profiles: jwOracleTest
@ -141,6 +147,9 @@ testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wechat:
  id: xm_ykyy_wx  # base库中,wx_wechat 的id字段
---
spring:
  profiles: iottest
@ -167,6 +176,9 @@ testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wechat:
  id: xm_zsyy_wx  # base库中,wx_wechat 的id字段
---
spring:
  profiles: iotyanshi
@ -192,6 +204,8 @@ wlyy:
testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wechat:
  id: xm_zsyy_wx  # base库中,wx_wechat 的id字段
---
spring:
  profiles: jwprod
@ -217,6 +231,8 @@ wlyy:
testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wechat:
  id: xm_zsyy_wx  # base库中,wx_wechat 的id字段
---
## 心脏中心外网
spring:
@ -243,6 +259,8 @@ wlyy:
testPattern:
  sign: 2
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wechat:
  id: xm_xzzx_wx  # base库中,wx_wechat 的id字段
---
## 卫计委
spring:
@ -269,6 +287,8 @@ wlyy:
testPattern:
  sign: 1
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wechat:
  id: xm_ihealth_wx  # base库中,wx_wechat 的id字段
---
spring:
@ -294,6 +314,8 @@ wlyy:
testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wechat:
  id: xm_ykyy_wx  # base库中,wx_wechat 的id字段
---
@ -320,4 +342,7 @@ wlyy:
#文件服务器上传配置 0本地,1.I健康,2.内网调用
testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wechat:
  id: xm_ykyy_wx  # base库中,wx_wechat 的id字段

+ 1 - 1
server/svr-authentication/src/main/resources/bootstrap.yml

@ -104,7 +104,7 @@ spring:
  profiles: iotprod
  cloud:
    config:
      uri: ${wlyy.spring.config.uri:http://192.168.120.216:1221}
      uri: ${wlyy.spring.config.uri:http://127.0.0.1:1221}
      label: ${wlyy.spring.config.label:master}
---

+ 4 - 4
svr/svr-base/src/main/resources/application.yml

@ -414,7 +414,7 @@ im:
spring:
  profiles: iotprod
  datasource:
    url: jdbc:mysql://10.90.32.2:20002/iot-base?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true
    url: jdbc:mysql://10.90.32.3:20002/iot-base?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true
    username: wlyy
    password: jkzlehr@123
#    url: jdbc:mysql://172.19.103.77/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
@ -422,10 +422,10 @@ spring:
#    password: 123456
  elasticsearch:
    cluster-name: jkzl #集群名 默认elasticsearch
    cluster-nodes: 10.90.32.2:20010,10.90.32.2:20012 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode
    cluster-nodes: 10.90.32.3:20010,10.90.32.3:20012 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode
    client-transport-sniff: false
    jest:
      uris: http://10.90.32.2:20009,http://10.90.32.2:20011
      uris: http://10.90.32.3:20009,http://10.90.32.3:20011
      connection-timeout: 60000 # Connection timeout in milliseconds.
      multi-threaded: true # Enable connection requests from multiple execution threads.
  activemq:
@ -433,7 +433,7 @@ spring:
    user: admin
    password: admin
  redis:
    host: 10.90.32.2 # Redis server host.
    host: 10.90.32.3 # Redis server host.
    port: 20008  # Redis server port.
    password: jkzlehr
fastDFS:

+ 1 - 1
svr/svr-base/src/main/resources/bootstrap.yml

@ -84,7 +84,7 @@ spring:
  profiles: iotprod
  cloud:
    config:
      uri: ${wlyy.spring.config.uri:http://192.168.120.216:1221}
      uri: ${wlyy.spring.config.uri:http://127.0.0.1:1221}
      label: ${wlyy.spring.config.label:master}
---

+ 0 - 13
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/interceptor/ActivatedInterceptor.java

@ -1,38 +1,25 @@
package com.yihu.jw.healthyhouse.interceptor;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.healthyhouse.constant.LoginInfo;
import com.yihu.jw.healthyhouse.model.user.User;
import com.yihu.jw.healthyhouse.service.user.UserService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.wlyy.HouseUserContant;
import javassist.*;
import javassist.bytecode.CodeAttribute;
import javassist.bytecode.LocalVariableAttribute;
import javassist.bytecode.MethodInfo;
import net.sf.json.JSON;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;

+ 311 - 3
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/XzzxCotroller.java

@ -1,9 +1,8 @@
package com.yihu.jw.entrance.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDiagnosisDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionInfoDO;
import com.yihu.jw.entity.hospital.prescription.*;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDiagnosisDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionInfoDao;
@ -17,6 +16,7 @@ import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -298,4 +298,312 @@ public class XzzxCotroller extends EnvelopRestEndpoint {
    }
    /**
     * 获取icd10字典
     * @return
     * @throws Exception
     */
    @GetMapping(value = "/getICD10Dict")
    @ApiOperation(value = "获取icd10字典", notes = "获取icd10字典")
    public ObjEnvelop getICD10Dict(@ApiParam(name = "spellCode", value = "拼音码", required = false)
                                  @RequestParam(value = "spellCode",required = false)String spellCode)throws Exception{
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.GetICD10Dict(spellCode));
    }
    /**
     * 获取药品字典
     * @return
     * @throws Exception
     */
    @GetMapping(value = "/getDrugDict")
    @ApiOperation(value = "获取药品字典", notes = "获取药品字典")
    public ObjEnvelop getDrugDict(@ApiParam(name = "spellCode", value = "拼音码", required = false)
                                   @RequestParam(value = "spellCode",required = false)String spellCode)throws Exception{
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.GetDrugDict(spellCode));
    }
    /**
     * 查询药品用药方法
     * @return
     * @throws Exception
     */
    @GetMapping(value = "/getMedicineUsed")
    @ApiOperation(value = "查询药品用药方法", notes = "查询药品用药方法")
    public ObjEnvelop getMedicineUsed(@ApiParam(name = "spellCode", value = "拼音码", required = false)
                                  @RequestParam(value = "spellCode",required = false)String spellCode)throws Exception{
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.GetMedicineUsed(spellCode));
    }
    /**
     * 获取药品用药频次字典
     * @return
     * @throws Exception
     */
    @GetMapping(value = "/getFrequencyDict")
    @ApiOperation(value = "获取药品用药频次字典", notes = "获取药品用药频次字典")
    public ObjEnvelop getFrequencyDict()throws Exception{
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.GetFrequencyDict());
    }
    /**
     * 获取检查部位字典
     * @return
     * @throws Exception
     */
    @GetMapping(value = "/getCheckBody")
    @ApiOperation(value = "获取检查部位字典", notes = "获取检查部位字典")
    public ObjEnvelop getCheckBody(@ApiParam(name = "spellCode", value = "拼音码", required = false)
                                       @RequestParam(value = "spellCode",required = false)String spellCode)throws Exception{
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.GetCheckBody(spellCode));
    }
    /**
     * 获取检查单据信息
     * @return
     * @throws Exception
     */
    @GetMapping(value = "/getExamApply")
    @ApiOperation(value = "获取检查单据信息", notes = "获取检查单据信息")
    public ObjEnvelop getExamApply(@ApiParam(name = "spellCode", value = "拼音码", required = false)
                                       @RequestParam(value = "spellCode",required = false)String spellCode)throws Exception{
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.GetExamApply(spellCode));
    }
    /**
     * 获取检验单据信息
     * @return
     * @throws Exception
     */
    @GetMapping(value = "/getLisApply")
    @ApiOperation(value = "获取检验单据信息", notes = "获取检验单据信息")
    public ObjEnvelop getLisApply(@ApiParam(name = "spellCode", value = "拼音码", required = false)
                                   @RequestParam(value = "spellCode",required = false)String spellCode)throws Exception{
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.GetLisApply(spellCode));
    }
    /**
     * 互联网医院开处方信息更新到his
     *
     * @param IoFlag  门诊住院标志
     * @param PayCardNo 就诊卡号
     * @param NullahNumber 挂号流水号
     * @param ApplyDept 执行科室
     * @param ApplyDoctor 开单医生
     * @param ExecuteDept 执行科室(药房)
     * @param prescriptionInfoDOS
     */
    @PostMapping(value = "/savePrescriptionToHospital")
    @ApiOperation(value = "互联网医院开处方信息更新到his", notes = "互联网医院开处方信息更新到his")
    public ObjEnvelop savePrescriptionToHospital(@ApiParam(name = "IoFlag", value = "门诊住院标志", required = false)
                                                     @RequestParam(value = "IoFlag",required = false)String IoFlag,
                                                 @ApiParam(name = "PayCardNo", value = "就诊卡号", required = false)
                                                    @RequestParam(value = "PayCardNo",required = false)String PayCardNo,
                                                 @ApiParam(name = "NullahNumber", value = "挂号流水号", required = false)
                                                     @RequestParam(value = "NullahNumber",required = false)String NullahNumber,
                                                 @ApiParam(name = "ApplyDept", value = "执行科室", required = false)
                                                     @RequestParam(value = "ApplyDept",required = false)String ApplyDept,
                                                 @ApiParam(name = "ApplyDoctor", value = "开单医生", required = false)
                                                     @RequestParam(value = "ApplyDoctor",required = false)String ApplyDoctor,
                                                 @ApiParam(name = "ExecuteDept", value = "执行科室(药房)", required = false)
                                                     @RequestParam(value = "ExecuteDept",required = false)String ExecuteDept,
                                                 @ApiParam(name = "prescriptionInfoDOS", value = "药品信息", required = false)
                                                     @RequestParam(value = "prescriptionInfoDOS",required = false)String prescriptionInfoDOS)throws Exception{
        List<WlyyPrescriptionInfoDO> prescriptionInfoDOList = new ArrayList<>();
        if (prescriptionInfoDOS!=null){
            JSONArray jsonArray = JSONArray.parseArray(prescriptionInfoDOS);
            for (int i=0;i<jsonArray.size();i++){
                WlyyPrescriptionInfoDO wlyyPrescriptionInfoDO = toEntity(jsonArray.getJSONObject(i).toJSONString(),WlyyPrescriptionInfoDO.class);
                prescriptionInfoDOList.add(wlyyPrescriptionInfoDO);
            }
        }
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.savePrescriptionToHospital(IoFlag,PayCardNo,NullahNumber,ApplyDept,ApplyDoctor,ExecuteDept,prescriptionInfoDOList));
    }
    /**
     * 删除处方信息
     *
     * @param IoFlag  门诊住院标志
     * @param PayCardNo 就诊卡号
     * @param NullahNumber 挂号流水号
     * @param ApplyDept 执行科室
     * @param ApplyDoctor 开单医生
     * @param ExecuteDept 执行科室(药房)
     */
    @PostMapping(value = "/delHisPrescriptionByHisNo")
    @ApiOperation(value = "删除处方信息", notes = "删除处方信息")
    public ObjEnvelop delHisPrescriptionByHisNo(@ApiParam(name = "IoFlag", value = "门诊住院标志", required = false)
                                                 @RequestParam(value = "IoFlag",required = false)String IoFlag,
                                                 @ApiParam(name = "PayCardNo", value = "就诊卡号", required = false)
                                                 @RequestParam(value = "PayCardNo",required = false)String PayCardNo,
                                                 @ApiParam(name = "NullahNumber", value = "挂号流水号", required = false)
                                                 @RequestParam(value = "NullahNumber",required = false)String NullahNumber,
                                                 @ApiParam(name = "ApplyDept", value = "执行科室", required = false)
                                                 @RequestParam(value = "ApplyDept",required = false)String ApplyDept,
                                                 @ApiParam(name = "ApplyDoctor", value = "开单医生", required = false)
                                                 @RequestParam(value = "ApplyDoctor",required = false)String ApplyDoctor,
                                                 @ApiParam(name = "ExecuteDept", value = "执行科室(药房)", required = false)
                                                 @RequestParam(value = "ExecuteDept",required = false)String ExecuteDept,
                                                 @ApiParam(name = "PresNo", value = "必填,医嘱号", required = false)
                                                 @RequestParam(value = "PresNo",required = false)String PresNo)throws Exception{
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.delHisPrescriptionByHisNo(IoFlag,PayCardNo,NullahNumber,ApplyDept,ApplyDoctor,ExecuteDept,PresNo));
    }
    /**
     * 保存入门诊断信息到his
     * @param ApplyNo
     * @param DiagnosisName
     * @param DiagnosisCode
     * @param ChnSymPtomsCode
     * @param ChnSymPtomsName
     * @param ChnDiagnosisCode
     * @param ChnDiagnosisName
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/saveDiagnosis")
    @ApiOperation(value = "保存入门诊断信息到his", notes = "保存入门诊断信息到his")
    public ObjEnvelop saveDiagnosis(@ApiParam(name = "ApplyNo", value = "必填,流水号", required = false)
                                                 @RequestParam(value = "ApplyNo",required = false)String ApplyNo,
                                                 @ApiParam(name = "DiagnosisName", value = "必填,诊断名称", required = false)
                                                 @RequestParam(value = "DiagnosisName",required = false)String DiagnosisName,
                                                 @ApiParam(name = "DiagnosisCode", value = "诊断代码", required = false)
                                                 @RequestParam(value = "DiagnosisCode",required = false)String DiagnosisCode,
                                                 @ApiParam(name = "ChnSymPtomsCode", value = "中医证型代码", required = false)
                                                 @RequestParam(value = "ChnSymPtomsCode",required = false)String ChnSymPtomsCode,
                                                 @ApiParam(name = "ChnSymPtomsName", value = "中医证型", required = false)
                                                 @RequestParam(value = "ChnSymPtomsName",required = false)String ChnSymPtomsName,
                                                 @ApiParam(name = "ChnDiagnosisCode", value = "中医诊断代码", required = false)
                                                 @RequestParam(value = "ChnDiagnosisCode",required = false)String ChnDiagnosisCode,
                                                 @ApiParam(name = "ChnDiagnosisName", value = "中医诊断名称", required = false)
                                                 @RequestParam(value = "ChnDiagnosisName",required = false)String ChnDiagnosisName)throws Exception{
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.saveDiagnosis(ApplyNo,DiagnosisName,DiagnosisCode,ChnSymPtomsCode,ChnSymPtomsName,ChnDiagnosisCode,ChnDiagnosisName));
    }
    /**
     * 发送退号信息到his
     * @param ApplyNo
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/refundConsultation")
    @ApiOperation(value = "发送退号信息到his", notes = "发送退号信息到his")
    public ObjEnvelop refundConsultation(@ApiParam(name = "ApplyNo", value = "必填,流水号", required = false)
                                    @RequestParam(value = "ApplyNo",required = false)String ApplyNo,
                                    @ApiParam(name = "PayCardNo", value = "必填,就诊卡号", required = false)
                                    @RequestParam(value = "PayCardNo",required = false)String PayCardNo)throws Exception{
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.refundConsultation(ApplyNo,PayCardNo));
    }
    /**
     * 获取检验单据信息
     * @return
     * @throws Exception
     */
    @GetMapping(value = "/saveInspectToHospital")
    @ApiOperation(value = "互联网医院开检查检验信息更新到his", notes = "互联网医院开检查检验信息更新到his")
    public ObjEnvelop saveInspectToHospital(@ApiParam(name = "PayCardNo", value = "就诊卡号", required = false)
                                  @RequestParam(value = "PayCardNo",required = false)String PayCardNo,
                                            @ApiParam(name = "IoFlag", value = "门诊住院标志", required = false)
                                            @RequestParam(value = "IoFlag",required = false)String IoFlag,
                                            @ApiParam(name = "NullahNumber", value = "挂号流水号", required = false)
                                                @RequestParam(value = "NullahNumber",required = false)String NullahNumber,
                                            @ApiParam(name = "ApplyDept", value = "执行科室", required = false)
                                                @RequestParam(value = "ApplyDept",required = false)String ApplyDept,
                                            @ApiParam(name = "ApplyDoctor", value = "开单医生", required = false)
                                                @RequestParam(value = "ApplyDoctor",required = false)String ApplyDoctor,
                                            @ApiParam(name = "wlyyInspectionDOS", value = "检查json", required = false)
                                                @RequestParam(value = "wlyyInspectionDOS",required = false) String wlyyInspectionDOS)throws Exception{
        JSONArray jsonArray = JSONArray.parseArray(wlyyInspectionDOS);
        List<WlyyInspectionDO> wlyyInspectionS = new ArrayList<>();
        for (int i=0;i<jsonArray.size();i++){
            WlyyInspectionDO inspectionDO = toEntity(jsonArray.get(i).toString(),WlyyInspectionDO.class);
            wlyyInspectionS.add(inspectionDO);
        }
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.saveInspectToHospital(IoFlag,PayCardNo,NullahNumber,ApplyDept,ApplyDoctor,wlyyInspectionS));
    }
    /**
     * 合理用药审核接口
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/checkPrescription")
    @ApiOperation(value = "合理用药审核接口", notes = "合理用药审核接口")
    public ObjEnvelop checkPrescription(@ApiParam(name = "infos", value = "药品信息", required = false)
                                            @RequestParam(value = "infos",required = false)String infos,
                                            @ApiParam(name = "patientAndDoctor", value = "医患信息", required = false)
                                            @RequestParam(value = "patientAndDoctor",required = false) String patientAndDoctor)throws Exception{
        JSONArray jsonArray = JSONArray.parseArray(infos);
        List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = new ArrayList<>();
        for (int i=0;i<jsonArray.size();i++){
            WlyyPrescriptionInfoDO wlyyPrescriptionInfo = toEntity(jsonArray.get(i).toString(),WlyyPrescriptionInfoDO.class);
            wlyyPrescriptionInfoDOS.add(wlyyPrescriptionInfo);
        }
        JSONObject jsonObject = JSONObject.parseObject(patientAndDoctor);
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.checkPrescription(jsonObject,wlyyPrescriptionInfoDOS));
    }
    /**
     * 合理用药保存接口
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/saveCheckPrescription")
    @ApiOperation(value = "合理用药保存接口", notes = "合理用药保存接口")
    public ObjEnvelop saveCheckPrescription(@ApiParam(name = "infos", value = "药品信息", required = false)
                                        @RequestParam(value = "infos",required = false)String infos,
                                        @ApiParam(name = "patientAndDoctor", value = "医患信息", required = false)
                                        @RequestParam(value = "patientAndDoctor",required = false) String patientAndDoctor)throws Exception{
        JSONArray jsonArray = JSONArray.parseArray(infos);
        List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = new ArrayList<>();
        for (int i=0;i<jsonArray.size();i++){
            WlyyPrescriptionInfoDO wlyyPrescriptionInfo = toEntity(jsonArray.get(i).toString(),WlyyPrescriptionInfoDO.class);
            wlyyPrescriptionInfoDOS.add(wlyyPrescriptionInfo);
        }
        JSONObject jsonObject = JSONObject.parseObject(patientAndDoctor);
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.saveCheckPrescription(jsonObject,wlyyPrescriptionInfoDOS));
    }
    /**
     * 合理用药作废接口
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/deleteCheckPrescription")
    @ApiOperation(value = "合理用药作废接口", notes = "合理用药作废接口")
    public ObjEnvelop deleteCheckPrescription(@ApiParam(name = "infos", value = "药品信息", required = false)
                                              @RequestParam(value = "infos",required = false)String infos,
                                              @ApiParam(name = "patientAndDoctor", value = "医患信息", required = false)
                                              @RequestParam(value = "patientAndDoctor",required = false) String patientAndDoctor)throws Exception{
        List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = new ArrayList<>();
        if (StringUtils.isNotBlank(infos)){
            JSONArray jsonArray = JSONArray.parseArray(infos);
            for (int i=0;i<jsonArray.size();i++){
                WlyyPrescriptionInfoDO wlyyPrescriptionInfo = toEntity(jsonArray.get(i).toString(),WlyyPrescriptionInfoDO.class);
                wlyyPrescriptionInfoDOS.add(wlyyPrescriptionInfo);
            }
        }
        JSONObject jsonObject = JSONObject.parseObject(patientAndDoctor);
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.deleteCheckPrescription(jsonObject,wlyyPrescriptionInfoDOS));
    }
    /**
     * 合理用药作废接口
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/returnEmrHtmlByHLW")
    @ApiOperation(value = "保存电子病历接口", notes = "保存电子病历接口")
    public ObjEnvelop returnEmrHtmlByHLW(@ApiParam(name = "jsonInfo", value = "医生患者信息", required = false)
                                              @RequestParam(value = "jsonInfo",required = false)String jsonInfo,
                                              @ApiParam(name = "emrInfo", value = "病历信息", required = false)
                                              @RequestParam(value = "emrInfo",required = false) String emrInfo)throws Exception{
        JSONObject jsonObject = JSONObject.parseObject(jsonInfo);
        WlyyPrescriptionEmrDO wlyyPrescriptionEmrDO = toEntity(emrInfo,WlyyPrescriptionEmrDO.class);
        return ObjEnvelop.getSuccess("ok",xzzxEntranceService.returnEmrHtmlByHLW(jsonObject,wlyyPrescriptionEmrDO));
    }
}

+ 11 - 6
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/YkyyController.java

@ -28,6 +28,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -248,7 +250,7 @@ public class YkyyController extends EnvelopRestEndpoint {
                                           @RequestParam(value = "table",required = true)String table) throws  Exception{
        List<YkEmrJcsqDO> surveys = EntityUtils.jsonToList(json, YkEmrJcsqDO.class);
        System.out.println(surveys);
        long totalprice=0l;
        BigDecimal totalprice=new BigDecimal(0);
        ListEnvelop mixEnvelop = new ListEnvelop();
        if (surveys!=null){
            for (YkEmrJcsqDO ykEmrJcsqDO:surveys){
@ -258,16 +260,18 @@ public class YkyyController extends EnvelopRestEndpoint {
                if (sqdhList!=null&&sqdhList.size()!=0){
                    sqdh = Long.parseLong(sqdhList.get(0).get("total").toString());
                    System.out.println("sqdh:"+sqdh);
                    String updatesqdh = "update portal_his.gy_identity_ms@ykzxtest set dqz=dqz+1 where bmc = 'EMR_JCSQ'";
                    String updatesqdh = "update portal_his.gy_identity_emr@ykzxtest set dqz=dqz+1 where bmc = 'EMR_JCSQ'";
                    hibenateUtils.updateBySql(updatesqdh);
                }
                ykEmrJcsqDO.setSqdh(sqdh.intValue());
                ykEmrJcsqDO.setJclx(1);
                ykEmrJcsqDO.setJjbz(0);
                ykEmrJcsqDO.setJzlx(1);
                ykEmrJcsqDO.setJczt(1);
                ykEmrJcsqDO.setZfbz(0);
                ykEmrJcsqDO.setQxbz(0);
                totalprice +=ykEmrJcsqDO.getXmdj()*ykEmrJcsqDO.getSqsl();
                ykEmrJcsqDO.setKdsj(new Date());
                ykEmrJcsqDO.setJsbz(0);
                totalprice =ykEmrJcsqDO.getXmdj().multiply(new BigDecimal(ykEmrJcsqDO.getSqsl()));
                System.out.println("totalprice"+totalprice);
                String yjxhSql =" select dqz + 1 as \"total\"  from portal_his.gy_identity_ms@ykzxtest where bmc = 'MS_YJ01'";
                List<Map<String,Object>> yjxhList = hibenateUtils.createSQLQuery(yjxhSql);
@ -337,12 +341,13 @@ public class YkyyController extends EnvelopRestEndpoint {
                        if (fyxhList.size()>0){
                            ykMsYj02DO.setXmlx(Integer.valueOf(fyxhList.get(0).get("xmlx").toString()));
                            ykMsYj02DO.setFygb(Integer.valueOf(fyxhList.get(0).get("fygb").toString()));
                            ykMsYj02DO.setYldj(Integer.valueOf(fyxhList.get(0).get("fydj").toString()));
                            ykMsYj02DO.setHjje(ykMsYj02DO.getYldj()*ykMsYj02DO.getYlsl());
                            ykMsYj02DO.setYldj(new BigDecimal(fyxhList.get(0).get("fydj").toString()));
                            ykMsYj02DO.setHjje(totalprice);
                        }
                        ykMsYj02DO.setZfbl(1);
                        ykMsYj02DO.setZxpb(0);
                        ykMsYj02DO.setZjflag(0);
                        ykMsYj02DO.setHjje(totalprice);
                        System.out.println(ykMsYj02DO);
                        ykyyEntranceService.save(ykMsYj02DO);
                    }

+ 4 - 0
svr/svr-internet-hospital-entrance/src/main/resources/application.yml

@ -21,6 +21,10 @@ spring:
    test-while-idle: true #指明连接是否被空闲连接回收器(如果有)进行检验,如果检测失败,则连接将被从池中去除
    min-evictable-idle-time-millis: 3600000 #连接池中连接,在时间段内一直空闲,被逐出连接池的时间(1000*60*60),以毫秒为单位
    time-between-eviction-runs-millis: 300000 #在空闲连接回收器线程运行期间休眠的时间值,以毫秒为单位,一般比minEvictableIdleTimeMillis小
  http:
    multipart:
      max-file-size: 30MB
      max-request-size: 100MB
  redis:
    database: 0 # Database index used by the connection factory.
    password: # Login password of the redis server.

+ 8 - 1
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/job/CommonDataUploadJob.java

@ -1,7 +1,6 @@
package com.yihu.jw.job;
import com.yihu.jw.internet.service.InternetCommonService;
import com.yihu.jw.internet.service.ykyy.YkyyInternetService;
import com.yihu.jw.util.date.DateUtil;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
@ -114,6 +113,14 @@ public class CommonDataUploadJob implements Job {
            }
            logger.info("END==========2.12 在线诊疗服务信息-过程图片上传 结束========" + res);
            logger.info("START========2.14 数据上传汇总信息 开始========");
            try {
                res = internetService.upNsInvokeTotal(startDate,endDate);
            }catch (Exception e){
                e.printStackTrace();
                logger.error(e.toString());
            }
            logger.info("END==========2.14 数据上传汇总信息 结束========" + res);
            logger.info("END========DataUploadJob 执行结束========");

+ 476 - 39
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/PrescriptionStatusUpdateService.java

@ -2,20 +2,33 @@ package com.yihu.jw.service.channel;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalWaitingRoomDO;
import com.yihu.jw.entity.hospital.doctor.WlyyPatientRegisterTimeDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.hospital.prescription.*;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.hospital.consult.dao.HospitalWaitingRoomDao;
import com.yihu.jw.hospital.doctor.dao.PatientRegisterTimeDao;
import com.yihu.jw.hospital.message.service.SystemMessageService;
import com.yihu.jw.hospital.prescription.dao.*;
import com.yihu.jw.hospital.prescription.service.PrescriptionLogService;
import com.yihu.jw.hospital.prescription.service.PrescriptionService;
import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService;
import com.yihu.jw.hospital.ykyy.service.YkyyService;
import com.yihu.jw.im.service.ImService;
import com.yihu.jw.order.BusinessOrderService;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.repository.job.QuartzJobLogDao;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionDiagnosisVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionInfoVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.status.EnvelopStatus;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.http.HttpUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -63,7 +76,17 @@ public class PrescriptionStatusUpdateService {
    @Autowired
    private PrescriptionLogService prescriptionLogService;
    @Autowired
    private QuartzJobLogDao quartzJobLogDao;
    private HospitalWaitingRoomDao hospitalWaitingRoomDao;
    @Autowired
    private PatientRegisterTimeDao patientRegisterTimeDao;
    @Autowired
    private YkyyService ykyyService;
    @Autowired
    private BasePatientDao basePatientDao;
    @Autowired
    private PrescriptionService prescriptionService;
    @Autowired
    private SystemMessageService systemMessageService;
    public void autoPush() throws Exception {
@ -279,50 +302,56 @@ public class PrescriptionStatusUpdateService {
     */
    public void setOutPatientOver(){
        logger.info("setOutPatientOver start ");
        //复诊记录状态状态安全锁,每天0~2点才允许触发,避免误调用
        //将所有的已接诊的处方记录
        List<WlyyOutpatientDO> outpatientDOs = outpatientDao.findByStatus();
        if(outpatientDOs!=null&&outpatientDOs.size()>0){
            System.out.println(outpatientDOs.get(0).getId()+"id______-");
            for(WlyyOutpatientDO outpatientDO:outpatientDOs){
                //结束门诊
                outpatientDO.setStatus("3");
                String consultCode ="";
                try {
                    consultCode = imService.getConsultCodeByOutpatientId(outpatientDO.getId());
                    logger.info("consultCode"+consultCode);
                    if(StringUtils.isNoneBlank(consultCode)){
                        imService.finish(consultCode,"admin",2);
        //复诊记录状态状态安全锁,每天0点才允许触发,避免误调用
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        int i = calendar.get(Calendar.HOUR_OF_DAY);
        if(i==0){
            //将所有的已接诊的处方记录
            List<WlyyOutpatientDO> outpatientDOs = outpatientDao.findByStatus();
            if(outpatientDOs!=null&&outpatientDOs.size()>0){
                System.out.println(outpatientDOs.get(0).getId()+"id______-");
                for(WlyyOutpatientDO outpatientDO:outpatientDOs){
                    //结束门诊
                    outpatientDO.setStatus("3");
                    outpatientDO.setEndTime(new Date());
                    String consultCode ="";
                    try {
                        consultCode = imService.getConsultCodeByOutpatientId(outpatientDO.getId());
                        logger.info("consultCode"+consultCode);
                        if(StringUtils.isNoneBlank(consultCode)){
                            imService.finish(consultCode,"admin",2);
                        }
                    }catch(Exception e)  {
                        e.printStackTrace();
                        logger.info("自动结束咨询报错 consultCode: "+consultCode);
                    }
                }catch(Exception e)  {
                    e.printStackTrace();
                    logger.info("自动结束咨询报错 consultCode: "+consultCode);
                    logger.info(outpatientDO.getId()+"的处方记录设置为结束");
                }
                logger.info(outpatientDO.getId()+"的处方记录设置为结束");
            }
            outpatientDao.save(outpatientDOs);
            //退费
            for (WlyyOutpatientDO outpatientDO:outpatientDOs){
                try {
                BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outpatientDO.getId());
                if (businessOrderDO!=null){
                    if (businessOrderDO.getPayType()==1){
                        businessOrderService.orderRefund(wechatId,businessOrderDO.getPatient(),businessOrderDO.getOrderNo(),businessOrderDO.getPayPrice(),businessOrderDO.getDescription());
                    }else if (businessOrderDO.getPayType()==3){
    /*
                        businessOrderService.ylzOrderRefund(wechatId,businessOrderDO.getPatient(),businessOrderDO.getOrderNo(),businessOrderDO.getPayPrice(),businessOrderDO.getDescription());
    */
                outpatientDao.save(outpatientDOs);
                //退费
                for (WlyyOutpatientDO outpatientDO:outpatientDOs){
                    try {
                    BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outpatientDO.getId());
                    if (businessOrderDO!=null){
                        if (businessOrderDO.getPayType()==1){
                            businessOrderService.orderRefund(wechatId,businessOrderDO.getPatient(),businessOrderDO.getOrderNo(),businessOrderDO.getPayPrice(),businessOrderDO.getDescription());
                        }else if (businessOrderDO.getPayType()==3){
        /*
                            businessOrderService.ylzOrderRefund(wechatId,businessOrderDO.getPatient(),businessOrderDO.getOrderNo(),businessOrderDO.getPayPrice(),businessOrderDO.getDescription());
        */
                        }
                    } } catch (Exception e) {
                        e.printStackTrace();
                    }
                } } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            logger.info("setOutPatientOver count :"+outpatientDOs.size());
        }else {
            logger.info("setOutPatientOver count :"+0);
                logger.info("setOutPatientOver count :"+outpatientDOs.size());
            }else {
                logger.info("setOutPatientOver count :"+0);
            }
            logger.info("setOutPatientOver end ");
        }
        logger.info("setOutPatientOver end ");
    }
@ -369,7 +398,415 @@ public class PrescriptionStatusUpdateService {
            logger.info("setOutPatientOver Time is not up ");
        }
        logger.info("setOutPatientOver end ");
        Set set = new HashSet();
    }
    public  String  singelCancel(String outpatientId){
        logger.info("进入结束超时未接诊的门诊");
        WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId);
        String msgReturn = "";
        if (null!=wlyyOutpatientDO){
            logger.info("开始结束超时未接诊的门诊");
            String cancelValue = "超时订单系统自动取消";
            String cancelRemark = "当天未接诊的门诊订单自动取消";
            String outPatientId = wlyyOutpatientDO.getId();
            long currentTime = new Date().getTime();
            long outpatientTime = wlyyOutpatientDO.getCreateTime().getTime();
            if (currentTime-outpatientTime>24*60*60*1000) {
                logger.info("时间满足条件");
                //判断医生是否接诊
                List<WlyyHospitalWaitingRoomDO> roomDOs = hospitalWaitingRoomDao.findByOutpatientId(outPatientId);
                if (roomDOs != null && roomDOs.size() > 0) {
                    for (WlyyHospitalWaitingRoomDO roomDO : roomDOs) {
                        if (roomDO.getVisitStatus() == 2) {
                            logger.info("id为:" + outPatientId + "的门诊已被医生接诊");
                        } else {
                            roomDO.setVisitStatus(-1);
                            logger.info("修改候诊室状态,将候诊病人移除候诊室");
                            hospitalWaitingRoomDao.save(roomDO);
                        }
                    }
                }
                //更改门诊状态
                wlyyOutpatientDO.setStatus("-1");
                String description = null;
                wlyyOutpatientDO.setDoctorCancelRemark(cancelRemark);
                wlyyOutpatientDO.setDoctorCancelType("6");
                wlyyOutpatientDO.setDoctorCancelValue(cancelValue);
                wlyyOutpatientDO.setEndTime(new Date());
                wlyyOutpatientDO.setOperator("system");
                description = cancelValue;
                //系统消息
                SystemMessageDO messageDO = new SystemMessageDO();
                messageDO.setTitle("超时订单系统自动取消");
                messageDO.setType("13");
                messageDO.setSender(wlyyOutpatientDO.getDoctor());
                messageDO.setSenderName(wlyyOutpatientDO.getDoctorName());
                messageDO.setRelationCode(wlyyOutpatientDO.getId());
                messageDO.setReceiver(wlyyOutpatientDO.getPatient());
                messageDO.setReceiverName(wlyyOutpatientDO.getPatientName());
                net.sf.json.JSONObject data = new net.sf.json.JSONObject();
                try {
                    data.put("name", wlyyOutpatientDO.getPatientName());
                    data.put("age", IdCardUtil.getAgeForIdcard(wlyyOutpatientDO.getIdcard()));
                    data.put("gender", IdCardUtil.getSexForIdcard(wlyyOutpatientDO.getIdcard()));
                    data.put("question", wlyyOutpatientDO.getIcd10Name());
                    String msg = "";
                    if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                        data.put("type", "9");
                        msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个图文复诊已被系统取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                        prescriptionService.sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(), null, "9", "systemCancelRemind", cancelRemark);
                    }
                    if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                        data.put("type", "16");
                        msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个视频复诊已被系统取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                        prescriptionService.sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(), null, "16", "systemCancelRemind", cancelRemark);
                    }
                    data.put("msg", msg);
                    messageDO.setData(data.toString());
                    systemMessageService.saveMessage(messageDO);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                //推送消息到眼科通
                BasePatientDO patient = basePatientDao.findById(wlyyOutpatientDO.getPatient());
                if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
                    logger.info("推送消息到眼科通");
                    ykyyService.pushNotificationToYktPatient(patient.getYktId(), messageDO.getTitle(), data.get("msg").toString());
                }
                outpatientDao.save(wlyyOutpatientDO);
                logger.info("修改保存的门诊记录:" + wlyyOutpatientDO.getId());
                //删除门诊号源
                List<WlyyPatientRegisterTimeDO> list = patientRegisterTimeDao.findByOutpatientId(wlyyOutpatientDO.getId());
                if (list != null && list.size() > 0) {
                    patientRegisterTimeDao.delete(list);
                }
                BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outPatientId);
                try {
                    if (wechatId.equalsIgnoreCase("xm_ykyy_wx")) {
                        businessOrderService.orderRefund(wechatId, wlyyOutpatientDO.getConsumer(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
                        //眼科接诊时更新眼科通状态
                        if (businessOrderDO != null) {
                            ykyyService.updateYktOrderStatus(businessOrderDO.getOrderNo(), "2");
                        }
                    } else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")) {
/*
                    businessOrderService.ylzOrderRefund(wechatId, wlyyOutpatientDO.getPatient(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
*/
                    }
                    msgReturn = "success";
                } catch (Exception e) {
                    e.printStackTrace();
                    msgReturn = "failed";
                }
            }
            logger.info(wlyyOutpatientDO.getId()+"的门诊记录设置为取消");
        }
        return msgReturn;
    }
    public String  cancelAll(String day){
        logger.info("进入结束超时未接诊的门诊");
        List<WlyyOutpatientDO> timeout = outpatientDao.findAllWaitingOutpatient();
        long days = 1;
        if (StringUtils.isNotBlank(day)){
            days = Integer.parseInt(day);
        }
        String msgReurn = "";
        if (null!=timeout&&timeout.size()>0){
            logger.info("开始结束超时未接诊的门诊");
            String cancelValue = "超时订单系统自动取消";
            String cancelRemark = "当天未接诊的门诊订单自动取消";
            for(WlyyOutpatientDO wlyyOutpatientDO:timeout){
                try {
                    long currentTime = new Date().getTime();
                    long outpatientTime = wlyyOutpatientDO.getCreateTime().getTime();
                    if (currentTime-outpatientTime>24*60*60*1000*days){
                        logger.info("时间满足条件");
                        String outPatientId = wlyyOutpatientDO.getId();
                        //判断医生是否接诊
                        List<WlyyHospitalWaitingRoomDO> roomDOs = hospitalWaitingRoomDao.findByOutpatientId(outPatientId);
                        if (roomDOs != null && roomDOs.size() > 0) {
                            for (WlyyHospitalWaitingRoomDO roomDO : roomDOs) {
                                if (roomDO.getVisitStatus() == 2) {
                                    logger.info("id为:"+outPatientId+"的门诊已被医生接诊");
                                } else {
                                    roomDO.setVisitStatus(-1);
                                    logger.info("修改候诊室状态,将候诊病人移除候诊室");
                                    hospitalWaitingRoomDao.save(roomDO);
                                }
                            }
                        }
                        //更改门诊状态
                        wlyyOutpatientDO.setStatus("-1");
                        String description = null;
                        wlyyOutpatientDO.setDoctorCancelRemark(cancelRemark);
                        wlyyOutpatientDO.setDoctorCancelType("6");
                        wlyyOutpatientDO.setDoctorCancelValue(cancelValue);
                        wlyyOutpatientDO.setEndTime(new Date());
                        wlyyOutpatientDO.setOperator("system");
                        description = cancelValue;
                        //系统消息
                        SystemMessageDO messageDO = new SystemMessageDO();
                        messageDO.setTitle("超时订单系统自动取消");
                        messageDO.setType("13");
                        messageDO.setSender(wlyyOutpatientDO.getDoctor());
                        messageDO.setSenderName(wlyyOutpatientDO.getDoctorName());
                        messageDO.setRelationCode(wlyyOutpatientDO.getId());
                        messageDO.setReceiver(wlyyOutpatientDO.getPatient());
                        messageDO.setReceiverName(wlyyOutpatientDO.getPatientName());
                        net.sf.json.JSONObject data = new net.sf.json.JSONObject();
                        data.put("name", wlyyOutpatientDO.getPatientName());
                        data.put("age", IdCardUtil.getAgeForIdcard(wlyyOutpatientDO.getIdcard()));
                        data.put("gender", IdCardUtil.getSexForIdcard(wlyyOutpatientDO.getIdcard()));
                        data.put("question", wlyyOutpatientDO.getIcd10Name());
                        String msg = "";
                        if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                            data.put("type", "9");
                            msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个图文复诊已被系统取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                            prescriptionService.sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "9", "systemCancelRemind", cancelRemark);
                        }
                        if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                            data.put("type", "16");
                            msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个视频复诊已被系统取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                            prescriptionService.sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "16", "systemCancelRemind", cancelRemark);
                        }
                        data.put("msg", msg);
                        messageDO.setData(data.toString());
                        systemMessageService.saveMessage(messageDO);
                        //推送消息到眼科通
                        BasePatientDO patient = basePatientDao.findById(wlyyOutpatientDO.getPatient());
                        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
                            logger.info("推送消息到眼科通");
                            ykyyService.pushNotificationToYktPatient(patient.getYktId(), messageDO.getTitle(), data.get("msg").toString());
                        }
                        logger.info("修改保存的门诊记录:"+wlyyOutpatientDO.getId());
                        //删除门诊号源
                        List<WlyyPatientRegisterTimeDO> list = patientRegisterTimeDao.findByOutpatientId(wlyyOutpatientDO.getId());
                        if (list != null && list.size() > 0) {
                            patientRegisterTimeDao.delete(list);
                        }
                        BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outPatientId);
                        if (wechatId.equalsIgnoreCase("xm_ykyy_wx")) {
                            businessOrderService.orderRefund(wechatId, wlyyOutpatientDO.getConsumer(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
                            //眼科接诊时更新眼科通状态
                            if (businessOrderDO!=null){
                                ykyyService.updateYktOrderStatus(businessOrderDO.getOrderNo(),"2");
                            }
                        } else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")) {
        /*
                            businessOrderService.ylzOrderRefund(wechatId, wlyyOutpatientDO.getPatient(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
        */
                        }
                        outpatientDao.save(wlyyOutpatientDO);
                        logger.info(wlyyOutpatientDO.getId()+"的门诊记录设置为取消");
                        msgReurn="success";
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    logger.info(wlyyOutpatientDO.getId()+"的门诊记录取消失败");
                    msgReurn="faild";
                }
            }
        }
        return msgReurn;
    }
    public void cancelRecieve(){
        //将所有的已接诊的处方记录
        List<WlyyOutpatientDO> outpatientDOs = outpatientDao.findByStatus();
        if(outpatientDOs!=null&&outpatientDOs.size()>0){
            System.out.println(outpatientDOs.get(0).getId()+"id______-");
            for(WlyyOutpatientDO outpatientDO:outpatientDOs){
                //结束门诊
                outpatientDO.setStatus("3");
                outpatientDO.setEndTime(new Date());
                String consultCode ="";
                try {
                    consultCode = imService.getConsultCodeByOutpatientId(outpatientDO.getId());
                    logger.info("consultCode"+consultCode);
                    if(StringUtils.isNoneBlank(consultCode)){
                        imService.finish(consultCode,"admin",2);
                    }
                }catch(Exception e)  {
                    e.printStackTrace();
                    logger.info("自动结束咨询报错 consultCode: "+consultCode);
                }
                logger.info(outpatientDO.getId()+"的处方记录设置为结束");
            }
            outpatientDao.save(outpatientDOs);
            //退费
            for (WlyyOutpatientDO outpatientDO:outpatientDOs){
                try {
                    BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outpatientDO.getId());
                    if (businessOrderDO!=null){
                        if (businessOrderDO.getPayType()==1){
                            businessOrderService.orderRefund(wechatId,businessOrderDO.getPatient(),businessOrderDO.getOrderNo(),businessOrderDO.getPayPrice(),businessOrderDO.getDescription());
                        }else if (businessOrderDO.getPayType()==3){
        /*
                            businessOrderService.ylzOrderRefund(wechatId,businessOrderDO.getPatient(),businessOrderDO.getOrderNo(),businessOrderDO.getPayPrice(),businessOrderDO.getDescription());
        */
                        }
                    } } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            logger.info("setOutPatientOver count :"+outpatientDOs.size());
        }else {
            logger.info("setOutPatientOver count :"+0);
        }
        logger.info("setOutPatientOver end ");
    }
    public void cancelRecieveSingle(String outpatientId){
        //将所有的已接诊的处方记录
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId);
        if(outpatientDO!=null){
            System.out.println(outpatientDO.getId()+"id______-");
            //结束门诊
            outpatientDO.setStatus("3");
            outpatientDO.setEndTime(new Date());
            String consultCode ="";
            try {
                consultCode = imService.getConsultCodeByOutpatientId(outpatientDO.getId());
                logger.info("consultCode"+consultCode);
                if(StringUtils.isNoneBlank(consultCode)){
                    imService.finish(consultCode,"admin",2);
                }
            }catch(Exception e)  {
                e.printStackTrace();
                logger.info("自动结束咨询报错 consultCode: "+consultCode);
            }
            logger.info(outpatientDO.getId()+"的处方记录设置为结束");
            outpatientDao.save(outpatientDO);
            //退费
            try {
                BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outpatientDO.getId());
                if (businessOrderDO!=null){
                    if (businessOrderDO.getPayType()==1){
                        businessOrderService.orderRefund(wechatId,businessOrderDO.getPatient(),businessOrderDO.getOrderNo(),businessOrderDO.getPayPrice(),businessOrderDO.getDescription());
                    }else if (businessOrderDO.getPayType()==3){
    /*
                        businessOrderService.ylzOrderRefund(wechatId,businessOrderDO.getPatient(),businessOrderDO.getOrderNo(),businessOrderDO.getPayPrice(),businessOrderDO.getDescription());
    */
                    }
                } } catch (Exception e) {
                e.printStackTrace();
            }
        }else {
            logger.info("setOutPatientOver count :"+0);
        }
        logger.info("setOutPatientOver end ");
    }
    public String  cancelAllandSendMessage(String day){
        logger.info("进入结束超时未接诊的门诊");
        List<WlyyOutpatientDO> timeout = outpatientDao.findAllWaitingOutpatient();
        long days = 1;
        if (StringUtils.isNotBlank(day)){
            days = Integer.parseInt(day);
        }
        String msgReurn = "";
        if (null!=timeout&&timeout.size()>0){
            logger.info("开始结束超时未接诊的门诊");
            String cancelValue = "超时订单系统自动取消";
            String cancelRemark = "当天未接诊的门诊订单自动取消";
            for(WlyyOutpatientDO wlyyOutpatientDO:timeout){
                try {
                    long currentTime = new Date().getTime();
                    long outpatientTime = wlyyOutpatientDO.getCreateTime().getTime();
                    if (currentTime-outpatientTime>24*60*60*1000*days){
                        logger.info("时间满足条件");
                        String outPatientId = wlyyOutpatientDO.getId();
                        //判断医生是否接诊
                        List<WlyyHospitalWaitingRoomDO> roomDOs = hospitalWaitingRoomDao.findByOutpatientId(outPatientId);
                        if (roomDOs != null && roomDOs.size() > 0) {
                            for (WlyyHospitalWaitingRoomDO roomDO : roomDOs) {
                                if (roomDO.getVisitStatus() == 2) {
                                    logger.info("id为:"+outPatientId+"的门诊已被医生接诊");
                                } else {
                                    roomDO.setVisitStatus(-1);
                                    logger.info("修改候诊室状态,将候诊病人移除候诊室");
                                    hospitalWaitingRoomDao.save(roomDO);
                                }
                            }
                        }
                        //更改门诊状态
                        wlyyOutpatientDO.setStatus("-1");
                        String description = null;
                        wlyyOutpatientDO.setDoctorCancelRemark(cancelRemark);
                        wlyyOutpatientDO.setDoctorCancelType("6");
                        wlyyOutpatientDO.setDoctorCancelValue(cancelValue);
                        wlyyOutpatientDO.setEndTime(new Date());
                        wlyyOutpatientDO.setOperator("system");
                        description = cancelValue;
                        //系统消息
                        SystemMessageDO messageDO = new SystemMessageDO();
                        messageDO.setTitle("超时订单系统自动取消");
                        messageDO.setType("13");
                        messageDO.setSender(wlyyOutpatientDO.getDoctor());
                        messageDO.setSenderName(wlyyOutpatientDO.getDoctorName());
                        messageDO.setRelationCode(wlyyOutpatientDO.getId());
                        messageDO.setReceiver(wlyyOutpatientDO.getPatient());
                        messageDO.setReceiverName(wlyyOutpatientDO.getPatientName());
                        net.sf.json.JSONObject data = new net.sf.json.JSONObject();
                        data.put("name", wlyyOutpatientDO.getPatientName());
                        data.put("age", IdCardUtil.getAgeForIdcard(wlyyOutpatientDO.getIdcard()));
                        data.put("gender", IdCardUtil.getSexForIdcard(wlyyOutpatientDO.getIdcard()));
                        data.put("question", wlyyOutpatientDO.getIcd10Name());
                        String msg = "";
                        if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                            data.put("type", "9");
                            msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个图文复诊已被系统取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                            //prescriptionService.sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "9", "systemCancelRemind", cancelRemark);
                        }
                        if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                            data.put("type", "16");
                            msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个视频复诊已被系统取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                            // prescriptionService.sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "16", "systemCancelRemind", cancelRemark);
                        }
                        data.put("msg", msg);
                        messageDO.setData(data.toString());
                        systemMessageService.saveMessage(messageDO);
                        //推送消息到眼科通
                        BasePatientDO patient = basePatientDao.findById(wlyyOutpatientDO.getPatient());
                        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
                            logger.info("推送消息到眼科通");
                            ykyyService.pushNotificationToYktPatient(patient.getYktId(), messageDO.getTitle(), data.get("msg").toString());
                        }
                        logger.info("修改保存的门诊记录:"+wlyyOutpatientDO.getId());
                        //删除门诊号源
                        List<WlyyPatientRegisterTimeDO> list = patientRegisterTimeDao.findByOutpatientId(wlyyOutpatientDO.getId());
                        if (list != null && list.size() > 0) {
                            patientRegisterTimeDao.delete(list);
                        }
                        BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outPatientId);
                        if (wechatId.equalsIgnoreCase("xm_ykyy_wx")) {
                            businessOrderService.orderRefund(wechatId, wlyyOutpatientDO.getConsumer(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
                            //眼科接诊时更新眼科通状态
                            if (businessOrderDO!=null){
                                ykyyService.updateYktOrderStatus(businessOrderDO.getOrderNo(),"2");
                            }
                        } else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")) {
        /*
                            businessOrderService.ylzOrderRefund(wechatId, wlyyOutpatientDO.getPatient(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
        */
                        }
                        outpatientDao.save(wlyyOutpatientDO);
                        logger.info(wlyyOutpatientDO.getId()+"的门诊记录设置为取消");
                        msgReurn="success";
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    logger.info(wlyyOutpatientDO.getId()+"的门诊记录取消失败");
                    msgReurn="faild";
                }
            }
        }
        return msgReurn;
    }
}

+ 177 - 0
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/TimeoutOverDueService.java

@ -0,0 +1,177 @@
package com.yihu.jw.service.channel;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalWaitingRoomDO;
import com.yihu.jw.entity.hospital.doctor.WlyyPatientRegisterTimeDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.hospital.consult.dao.HospitalWaitingRoomDao;
import com.yihu.jw.hospital.doctor.dao.PatientRegisterTimeDao;
import com.yihu.jw.hospital.message.service.SystemMessageService;
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDiagnosisDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionInfoDao;
import com.yihu.jw.hospital.prescription.service.PrescriptionLogService;
import com.yihu.jw.hospital.prescription.service.PrescriptionService;
import com.yihu.jw.hospital.ykyy.service.YkyyService;
import com.yihu.jw.im.service.ImService;
import com.yihu.jw.order.BusinessOrderService;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.common.IdCardUtil;
import org.apache.commons.lang3.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.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@Component
@Transactional
public class TimeoutOverDueService {
    private static Logger logger = LoggerFactory.getLogger(TimeoutOverDueService.class);
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Value("${wechat.ids}")
    private String wechatId;
    @Value("${hlwyyEntrance.url}")
    private String hlwyyEntranceUrl;
    @Autowired
    private PrescriptionDao prescriptionDao;
    @Autowired
    private PrescriptionDiagnosisDao prescriptionDiagnosisDao;
    @Autowired
    private PrescriptionInfoDao prescriptionInfoDao;
    @Autowired
    private OutpatientDao outpatientDao;
    @Autowired
    private ImService imService;
    @Autowired
    private BusinessOrderDao businessOrderDao;
    @Autowired
    private BusinessOrderService businessOrderService;
    @Autowired
    private PrescriptionLogService prescriptionLogService;
    @Autowired
    private HospitalWaitingRoomDao hospitalWaitingRoomDao;
    @Autowired
    private PatientRegisterTimeDao patientRegisterTimeDao;
    @Autowired
    private YkyyService ykyyService;
    @Autowired
    private BasePatientDao basePatientDao;
    @Autowired
    private PrescriptionService prescriptionService;
    @Autowired
    private SystemMessageService systemMessageService;
    /**
     *  取消未结束门诊
     */
    public void cancelOutPatientOver(){
            logger.info("进入结束超时未接诊的门诊");
            List<WlyyOutpatientDO> timeout = outpatientDao.findAllWaitingOutpatient();
            if (null!=timeout&&timeout.size()>0){
                logger.info("开始结束超时未接诊的门诊");
                String cancelValue = "超时订单系统自动取消";
                String cancelRemark = "当天未接诊的门诊订单自动取消";
                for(WlyyOutpatientDO wlyyOutpatientDO:timeout){
                    try {
                        long currentTime = new Date().getTime();
                        long outpatientTime = wlyyOutpatientDO.getCreateTime().getTime();
                        if (currentTime-outpatientTime>24*60*60*1000){
                            logger.info("时间满足条件");
                            String outPatientId = wlyyOutpatientDO.getId();
                            //判断医生是否接诊
                            List<WlyyHospitalWaitingRoomDO> roomDOs = hospitalWaitingRoomDao.findByOutpatientId(outPatientId);
                            if (roomDOs != null && roomDOs.size() > 0) {
                                for (WlyyHospitalWaitingRoomDO roomDO : roomDOs) {
                                    if (roomDO.getVisitStatus() == 2) {
                                        logger.info("id为:"+outPatientId+"的门诊已被医生接诊");
                                    } else {
                                        roomDO.setVisitStatus(-1);
                                        logger.info("修改候诊室状态,将候诊病人移除候诊室");
                                        hospitalWaitingRoomDao.save(roomDO);
                                    }
                                }
                            }
                            //更改门诊状态
                            wlyyOutpatientDO.setStatus("-1");
                            String description = null;
                            wlyyOutpatientDO.setDoctorCancelRemark(cancelRemark);
                            wlyyOutpatientDO.setDoctorCancelType("6");
                            wlyyOutpatientDO.setDoctorCancelValue(cancelValue);
                            wlyyOutpatientDO.setEndTime(new Date());
                            wlyyOutpatientDO.setOperator("system");
                            description = cancelValue;
                            //系统消息
                            SystemMessageDO messageDO = new SystemMessageDO();
                            messageDO.setTitle("超时订单系统自动取消");
                            messageDO.setType("13");
                            messageDO.setSender(wlyyOutpatientDO.getDoctor());
                            messageDO.setSenderName(wlyyOutpatientDO.getDoctorName());
                            messageDO.setRelationCode(wlyyOutpatientDO.getId());
                            messageDO.setReceiver(wlyyOutpatientDO.getPatient());
                            messageDO.setReceiverName(wlyyOutpatientDO.getPatientName());
                            net.sf.json.JSONObject data = new net.sf.json.JSONObject();
                            data.put("name", wlyyOutpatientDO.getPatientName());
                            data.put("age", IdCardUtil.getAgeForIdcard(wlyyOutpatientDO.getIdcard()));
                            data.put("gender", IdCardUtil.getSexForIdcard(wlyyOutpatientDO.getIdcard()));
                            data.put("question", wlyyOutpatientDO.getIcd10Name());
                            String msg = "";
                            if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                                data.put("type", "9");
                                msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个图文复诊已被系统取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                                prescriptionService.sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "9", "systemCancelRemind", cancelRemark);
                            }
                            if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                                data.put("type", "16");
                                msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个视频复诊已被系统取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                                prescriptionService.sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "16", "systemCancelRemind", cancelRemark);
                            }
                            data.put("msg", msg);
                            messageDO.setData(data.toString());
                            systemMessageService.saveMessage(messageDO);
                            //推送消息到眼科通
                            BasePatientDO patient = basePatientDao.findById(wlyyOutpatientDO.getPatient());
                            if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
                                logger.info("推送消息到眼科通");
                                ykyyService.pushNotificationToYktPatient(patient.getYktId(), messageDO.getTitle(), data.get("msg").toString());
                            }
                            logger.info("修改保存的门诊记录:"+wlyyOutpatientDO.getId());
                            //删除门诊号源
                            List<WlyyPatientRegisterTimeDO> list = patientRegisterTimeDao.findByOutpatientId(wlyyOutpatientDO.getId());
                            if (list != null && list.size() > 0) {
                                patientRegisterTimeDao.delete(list);
                            }
                            BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outPatientId);
                            if (wechatId.equalsIgnoreCase("xm_ykyy_wx")) {
                                businessOrderService.orderRefund(wechatId, wlyyOutpatientDO.getConsumer(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
                                //眼科接诊时更新眼科通状态
                                if (businessOrderDO!=null){
                                    ykyyService.updateYktOrderStatus(businessOrderDO.getOrderNo(),"2");
                                }
                            } else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")) {
        /*
                            businessOrderService.ylzOrderRefund(wechatId, wlyyOutpatientDO.getPatient(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
        */
                            }
                            outpatientDao.save(wlyyOutpatientDO);
                            logger.info(wlyyOutpatientDO.getId()+"的门诊记录设置为取消");
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        logger.info(wlyyOutpatientDO.getId()+"的门诊记录取消失败");
                    }
                }
            }
        }
    }

+ 4 - 1
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/UnSettledHISPrescriptionService.java

@ -175,7 +175,7 @@ public class UnSettledHISPrescriptionService {
     */
    public void unSettledHISPrescription() throws Exception{
        if("xm_ykyy_wx".equals(wechatId)){
            //获取审核失败
            //获取审核失败5306758
            JSONArray jsonArray = ykyyEntranceService.getNoUnsettledPrescription();
            if(jsonArray!=null&&jsonArray.size()>0) {
                for (int i = 0; i<jsonArray.size(); i++){
@ -197,6 +197,7 @@ public class UnSettledHISPrescriptionService {
                        msgObj.put("prescriptionId",prescriptionId);
                        msgObj.put("reason","处方驳回");
                        WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId);
                        System.out.println("发送诊断消息开始+"+wlyyOutpatientDO.getId());
                        String immsg = imService.pushPrescriptionBackMsg(msgObj,doctor,doctorName,outpatientId,wlyyOutpatientDO.getPatient(),wlyyOutpatientDO.getOutpatientType());
                        System.out.println("发送诊断消息成功:"+immsg);
                    }
@ -258,6 +259,8 @@ public class UnSettledHISPrescriptionService {
                                }
                                WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findOne(prescriptionId);
                                wlyyPrescriptionDO.setPrescribeTime(new Date());
                                wlyyPrescriptionDO.setCheckStatus(0);
                                wlyyPrescriptionDO.setCheckReason("审核通过");
                                prescriptionDao.save(wlyyPrescriptionDO);
                                JSONObject object = (JSONObject) JSONObject.toJSON(wlyyPrescriptionDO);
                                logger.info("wlyyPrescriptionDO参数入参"+object.toJSONString());

+ 63 - 0
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/util/TimeoutOverDueJob.java

@ -0,0 +1,63 @@
package com.yihu.jw.util;
import com.yihu.jw.service.channel.PrescriptionStatusUpdateService;
import com.yihu.jw.service.channel.TimeoutOverDueService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.Trigger;
import org.springframework.scheduling.TriggerContext;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.scheduling.support.CronTrigger;
import org.springframework.stereotype.Component;
import java.util.Date;
@Lazy(false)
@Component
@EnableScheduling
public class TimeoutOverDueJob implements SchedulingConfigurer {
    private static final Logger logger = LoggerFactory.getLogger(TimeoutOverDueJob.class);
    private static String cron = "0 */10 * * * ?";//0 0 0 * * ?
    public TimeoutOverDueJob(){
        cron="0 */10 * * * ?";
        System.out.println("TimeoutOverDueJob初始化时的corn"+cron);
    }
    @Autowired
    private TimeoutOverDueService TimeoutOverDueService;
    public String change(String corIn) {
        if (StringUtils.isNotBlank(corIn)) {
            cron = corIn;
        }
        return cron;
    }
    @Override
    public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
        taskRegistrar.addTriggerTask(new Runnable() {
            @Override
            public void run() {
                logger.info("START========TimeoutOverDueJob========");
                try {
                    TimeoutOverDueService.cancelOutPatientOver();
                    logger.info("END========TimeoutOverDueJob========");
                } catch (Exception e) {
                    e.printStackTrace();
                    logger.error("END===ERROE===TimeoutOverDueJob,message:"+e.getMessage());
                }
            }
        }, new Trigger() {
            @Override
            public Date nextExecutionTime(TriggerContext triggerContext) {
                // 任务触发,可修改任务的执行周期
                CronTrigger trigger = new CronTrigger(cron);
                System.out.println("TimeoutOverDueJobc,可修改任务的执行周期"+cron);
                Date nextExec = trigger.nextExecutionTime(triggerContext);
                return nextExec;
            }
        });
    }
}

+ 42 - 11
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/web/quota/JobController.java

@ -13,14 +13,17 @@ import com.yihu.jw.job.ykyy.UpdateStatusByPayTimeJob;
import com.yihu.jw.job.ykyy.YkyyDataUploadJob;
import com.yihu.jw.repository.job.QuartzJobConfigDao;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.service.channel.PrescriptionStatusUpdateService;
import com.yihu.jw.service.quota.JobService;
import com.yihu.jw.util.AutoTimeOutRemind;
import com.yihu.jw.util.OverdueJob;
import com.yihu.jw.util.SystemConf;
import com.yihu.jw.util.TimeoutOverDueJob;
import com.yihu.jw.web.BaseController;
import com.yihu.jw.wechat.service.WxTemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
@ -66,6 +69,8 @@ public class JobController extends BaseController {
    private QuartzJobConfigDao wlyyJobConfigDao;
    @Autowired
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
    @Autowired
    private PrescriptionStatusUpdateService prescriptionStatusUpdateService;
    @Autowired
    public JobController(JobService jobService, QuartzHelper quartzHelper) {
@ -140,17 +145,6 @@ public class JobController extends BaseController {
                    } else {
                        logger.info("prescription_overdue_job  job exist");
                    }
                    break;
                case "data_upload_job" :
                    //互联网医院 监管平台上报
                    if (!quartzHelper.isExistJob("data_upload_job")) {
                        String trigger = SystemConf.getInstance().getSystemProperties().getProperty("data_upload_job");
                        quartzHelper.addJob(DataUploadJob.class, trigger, "data_upload_job", new HashMap<String, Object>());
                        logger.info("data_upload_job  job success");
                    } else {
                        logger.info("data_upload_job  job exist");
                    }
                    break;
                case "data_ykupload_job" :
                    //互联网医院 监管平台上报
@ -555,6 +549,10 @@ public class JobController extends BaseController {
                    //语句
                    internetCommonService.upNsDoctorRecord(keyId);
                    break; //可选
                case "2.4" :
                    //语句
                    internetCommonService.achNsDoctorRecord(keyId);
                    break; //可选
                case "2.5" :
                    //语句
                    internetCommonService.upAppointmentOnline(startDate,endDate,keyId);
@ -627,5 +625,38 @@ public class JobController extends BaseController {
        return autoTimeOutRemind.change(corn);
    }
    @RequestMapping(value = "changeCancelTime", method = RequestMethod.GET)
    public String changeCancelTime(String corn){
        TimeoutOverDueJob cancel = new TimeoutOverDueJob();
        return cancel.change(corn);
    }
    @RequestMapping(value = "cancelSinglePre", method = RequestMethod.GET)
    @ApiOperation("取消未接诊")
    public String cancelSinglePre(String outpatientId,String day){
        if (StringUtils.isNotBlank(outpatientId)){
            System.out.println(outpatientId);
            return prescriptionStatusUpdateService.singelCancel(outpatientId);
        }else {
            return prescriptionStatusUpdateService.cancelAll(day);
        }
    }
    @RequestMapping(value = "overRecivePre", method = RequestMethod.GET)
    @ApiOperation("结束接诊")
    public void cancelRecivePre(String outpatientId){
        if (StringUtils.isNotBlank(outpatientId)){
            System.out.println(outpatientId);
            prescriptionStatusUpdateService.cancelRecieveSingle(outpatientId);
        }else {
            prescriptionStatusUpdateService.cancelRecieve();
        }
    }
    @RequestMapping(value = "cancelSinglePreByday", method = RequestMethod.GET)
    @ApiOperation("按天取消未接诊")
    public String cancelSinglePreSendMessage(String day){
        return prescriptionStatusUpdateService.cancelAllandSendMessage(day);
    }
}

+ 2 - 1
svr/svr-internet-hospital-job/src/main/resources/application.yml

@ -206,7 +206,7 @@ hospital:
  SourceSysCode: S60
  TargetSysCode: S01
im:
  im_list_get: http://172.26.0.105:3000/
  im_list_get: http://192.168.33.197:3000/
  data_base_name: im_internet_hospital
fastDFS:
  fastdfs_file_url: http://172.26.0.110:8888/
@ -214,6 +214,7 @@ wlyy:
  url: http://www.xmtyw.cn/wlyytest/
wechat:
  id: xm_ykyy_wx  # base库中,wx_wechat 的id字段
  ids: xm_ykyy_wx
  flag: false #演示环境  true走Mysql数据库  false走Oracle
express:
  sf_url: http://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService

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

@ -129,8 +129,14 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
			@ApiParam(name = "query_status", value = "0:图文复诊候诊 1:图文复诊抢单列表")
			@RequestParam(value = "",required = false) Integer query_status,
			@ApiParam(name = "dept", value = "部门")
			@RequestParam(value = "",required = false) String dept){
		return success("请求成功",prescriptionService.findWaitingRoomOutpatientByDoctor(doctor,type,query_status,dept));
			@RequestParam(value = "",required = false) String dept,
			@ApiParam(name = "sex", value = "性别1男2女")
			@RequestParam(value = "sex",required = false) String sex,
			@ApiParam(name = "keyWord", value = "姓名关键字")
			@RequestParam(value = "keyWord",required = false) String keyWord,
			@ApiParam(name = "ageGroup", value = "年龄段")
			@RequestParam(value = "ageGroup",required = false) String ageGroup){
		return success("请求成功",prescriptionService.findWaitingRoomOutpatientByDoctor(doctor,type,query_status,dept,sex,keyWord,ageGroup));
	}
	
	@GetMapping(value = BaseHospitalRequestMapping.DodtorIM.findWaitingRoomPatient)
@ -190,7 +196,9 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
			@ApiParam(name = "type", value = "咨询类型(1、图文;2、视频,3、图文+视频)", defaultValue = "1")
			@RequestParam(value = "type", required = true) Integer type,
			@ApiParam(name = "reason", value = "复诊说明", defaultValue = "复诊说明")
			@RequestParam(value = "reason", required = false) String reason)throws Exception{
			@RequestParam(value = "reason", required = false) String reason,
										  @ApiParam(name = "source", value = "来源")
											  @RequestParam(value = "source", required = false) String source)throws Exception{
			ConsultTeamDo consult = new ConsultTeamDo();
			if(2 == type){
				consult.setType(16);//视频复诊
@ -235,13 +243,13 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
					if("0".equals(rsCode)||"-2".equals(rsCode)){
						//挂号成功,已经挂号
						//2.
						result = imService.addPrescriptionConsult(outpatientCode, patientCode,doctorCode,consult,reason,type,wxId);
						result = imService.addPrescriptionConsult(outpatientCode, patientCode,doctorCode,consult,reason,type,wxId,source);
					}else{
						return failed(mes);
					}
					logger.info("调用挂号接口====END");
				}else {
					result = imService.addPrescriptionConsult(outpatientCode, patientCode,doctorCode,consult,reason,type,wxId);
					result = imService.addPrescriptionConsult(outpatientCode, patientCode,doctorCode,consult,reason,type,wxId,source);
				}
			}
@ -262,6 +270,19 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
				String rsCode = "";
				String mes = "";
				if("xm_xzzx_wx".equals(wxId)){ //心脏中心挂号
					if (demoFlag.equalsIgnoreCase("true")){
						rsCode="0";
						mes="已退号";
					}else {
						JSONObject res = xzyyPrescriptionService.refundRegisterNo(outpatientCode);
						if (res!=null&&res.getString("code").equalsIgnoreCase("0")){
							rsCode = "0";
							mes="已退号";
						}else {
							rsCode = "-1";
							mes=res.getString("msg");
						}
					}
				}else {
					if (demoFlag.equalsIgnoreCase("true")){
@ -297,7 +318,9 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
										  @ApiParam(name = "type", value = "咨询类型(1、图文;2、视频,3、图文+视频)", defaultValue = "1")
										  @RequestParam(value = "type", required = true) Integer type,
										  @ApiParam(name = "reason", value = "复诊说明", defaultValue = "复诊说明")
										  @RequestParam(value = "reason", required = false) String reason)throws Exception{
										  @RequestParam(value = "reason", required = false) String reason,
							  @ApiParam(name = "source", value = "来源")
								  @RequestParam(value = "source", required = false) String source)throws Exception{
		ConsultTeamDo consult = new ConsultTeamDo();
		if(2 == type){
			consult.setType(16);//视频复诊
@ -349,7 +372,7 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
*/
			//2.
			result = imService.addConsult(outpatientCode, patientCode,doctorCode,consult,reason,type,wxId);
			result = imService.addConsult(outpatientCode, patientCode,doctorCode,consult,reason,type,wxId,source);
		}
		return success("操作成功",result);
	}
@ -371,14 +394,16 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
			@ApiParam(name = "images", value = "图片")
			@RequestParam(value = "images",required = false) String images,
			@ApiParam(name = "voice", value = "语音")
			@RequestParam(value = "voice",required = false) String voice)throws Exception{
			@RequestParam(value = "voice",required = false) String voice,
			@ApiParam(name = "source", value = "来源")
			@RequestParam(value = "source",required = false) String source)throws Exception{
		
		ConsultTeamDo consult = new ConsultTeamDo();
		consult.setType(15);//家医咨询求助互联网医院专科医生:全科医生-专科医生-咨询聊天
		
		String result = "";
		synchronized (patient_code.intern()){
			result = imService.generalAddExpertConsult(patient_code, general_doctor,special_doctor,when,symptoms,images,consult);
			result = imService.generalAddExpertConsult(patient_code, general_doctor,special_doctor,when,symptoms,images,consult,source);
			
			BaseDoctorDO generalDoctor = baseDoctorDao.findById(general_doctor);
			BaseDoctorDO specialDoctor = baseDoctorDao.findById(special_doctor);
@ -421,42 +446,48 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
		msgObj.put("msg",baseDoctorDO.getName()+"结束了咨询");
		msgObj.put("consultcode",consult);
		String jsonStr = "";
		//结束时医生未开处方则发送模板消息结算
		ConsultDo cons = consultDao.findOne(consult);
		if (StringUtils.isNoneBlank(cons.getRelationCode())){
			WlyyOutpatientDO outpatientDO = outpatientDao.findById(cons.getRelationCode());
			List<WlyyPrescriptionDO> wlyyPrescriptionDOS = prescriptionDao.findByOutpatientId(outpatientDO.getId());
			if (wlyyPrescriptionDOS==null||wlyyPrescriptionDOS.size()==0){
				logger.info("发送诊查费支付模板消息start");
				BasePatientDO patientDO = basePatientDao.findById(outpatientDO.getPatient());
				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 (StringUtils.isNoneBlank(outpatientDO.getCardNo())) {
					cardNo = outpatientDO.getCardNo();
				}
				String date=DateUtil.dateToStr(outpatientDO.getRegisterDate(), "yyyyMMddHHmmss");
				net.sf.json.JSONObject object =entranceService.BS15054(patientMappingDO.getMappingCode(),outpatientDO.getRealOrder(),false);
				net.sf.json.JSONObject res = object.getJSONObject("resquest");
				logger.info("获取待结算数据 res: " + res.toString());
				String rsCode = res.getString("@RESULT");
				String free= 0+"";
				if ("0".equals(rsCode)) {
					free = res.getString("@total_charge");
				}
				if (!free.equalsIgnoreCase("0")){
					ylzPayService.msgPush("01", cardNo, "01", patientDO.getMobile(), "00", userNo, userName, idcard, outpatientDO.getRealOrder(), outpatientDO.getDeptName(), outpatientDO.getDoctorName(), date, free, "1");
		if ("xm_zsyy_wx".equalsIgnoreCase(wxId)){
			//结束时医生未开处方则发送模板消息结算
			ConsultDo cons = consultDao.findOne(consult);
			if (StringUtils.isNoneBlank(cons.getRelationCode())){
				WlyyOutpatientDO outpatientDO = outpatientDao.findById(cons.getRelationCode());
				List<WlyyPrescriptionDO> wlyyPrescriptionDOS = prescriptionDao.findByOutpatientId(outpatientDO.getId());
				if (wlyyPrescriptionDOS==null||wlyyPrescriptionDOS.size()==0){
					logger.info("发送诊查费支付模板消息start");
					BasePatientDO patientDO = basePatientDao.findById(outpatientDO.getPatient());
					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 (StringUtils.isNoneBlank(outpatientDO.getCardNo())) {
						cardNo = outpatientDO.getCardNo();
					}
					String date=DateUtil.dateToStr(outpatientDO.getRegisterDate(), "yyyyMMddHHmmss");
					net.sf.json.JSONObject object =entranceService.BS15054(patientMappingDO.getMappingCode(),outpatientDO.getRealOrder(),false);
					net.sf.json.JSONObject res = object.getJSONObject("resquest");
					logger.info("获取待结算数据 res: " + res.toString());
					String rsCode = res.getString("@RESULT");
					String free= 0+"";
					if ("0".equals(rsCode)) {
						if (res.getString("@settle_flag").equalsIgnoreCase("N")){
							free = res.getString("@total_charge");
						}
					}
					if (!free.equalsIgnoreCase("0")){
						ylzPayService.msgPush("01", cardNo, "01", patientDO.getMobile(), "00", userNo, userName, idcard, outpatientDO.getXtgzh(), outpatientDO.getDeptName(), outpatientDO.getDoctorName(), date, free, "1");
					}
					logger.info("发送诊查费支付模板消息end");
				}
				logger.info("发送诊查费支付模板消息end");
				outpatientDO.setEndTime(new Date());
				outpatientDao.save(outpatientDO);
			}
		}
		if(1 == resutl){
@ -570,7 +601,9 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
				if(12 == Integer.parseInt(consult.get("type").toString()) && StringUtils.isNoneBlank((String)consult.get("generalDoctor"))){
					BaseDoctorDO baseDoctorDO = baseDoctorDao.findById((String)consult.get("generalDoctor"));
					List<BaseDoctorHospitalDO> baseDoctorHospitalDOList = baseDoctorHospitalDao.findByDoctorCode((String)consult.get("generalDoctor"));
					consult.put("generalDoctorName", baseDoctorDO.getName());
					if(baseDoctorDO!=null){
						consult.put("generalDoctorName", baseDoctorDO.getName());
					}
					if (baseDoctorHospitalDOList!=null&&baseDoctorHospitalDOList.size()!=0){
						BaseDoctorHospitalDO baseDoctorHospitalDO = baseDoctorHospitalDOList.get(0);
						consult.put("generalOrgName",baseDoctorHospitalDO.getOrgName());
@ -1056,9 +1089,11 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
	@PostMapping(value = BaseHospitalRequestMapping.DodtorIM.findZlxm)
	@ApiOperation(value = "诊疗项目查询", notes = "诊疗项目查询")
	public ObjEnvelop findZlxm(@ApiParam(name = "itemName", value = "itemName")
								   @RequestParam(value = "itemName", required = false)String itemName)throws Exception {
								   @RequestParam(value = "itemName", required = false)String itemName,
							   @ApiParam(name = "itemCode", value = "itemCode")
							   @RequestParam(value = "itemCode", required = false)String itemCode)throws Exception {
		JSONArray array= ykyyEntranceService.findZlxm(itemName);
		JSONArray array= ykyyEntranceService.findZlxm(itemName,itemCode);
		ObjEnvelop objEnvelop = new ObjEnvelop();
		objEnvelop.setObj(array);
		return objEnvelop;

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

@ -419,7 +419,9 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
			@ApiParam(name = "voice", value = "语音")
			@RequestParam(value = "voice",required = false) String voice,
			@ApiParam(name = "type", value = "咨询类型:1专家咨询 14导诊助手 17专家视频咨询")
			@RequestParam(value = "type",required = false) Integer type)throws Exception{
			@RequestParam(value = "type",required = false) Integer type,
			@ApiParam(name = "source", value = "咨询类型来源")
			@RequestParam(value = "source",required = false) String source)throws Exception{
		
//		//发送厦门i健康智能推送
//		try{
@ -458,7 +460,7 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
//		JSONArray dts = null;
		synchronized (patient.intern()){//新增同步方法。设备保存写在service层但是不生效,写在controller层才生效
			JSONObject re = null;
			re = imService.addTeamConsult(consult, patient,doctor);
			re = imService.addTeamConsult(consult, patient,doctor,source);
//			res = re.getInteger("status");
//			dts = re.containsKey("doctor")?re.getJSONArray("doctor"):null;
			if (payFlag){
@ -630,6 +632,7 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
		msgObj.put("msg",basePatientDO.getName()+"结束了咨询");
		msgObj.put("consultcode",consult);
		String jsonStr = "";
		if ("xm_zsyy_wx".equalsIgnoreCase(wxId)){
		//结束时医生未开处方则发送模板消息结算
		ConsultDo cons = consultDao.findOne(consult);
		if (org.apache.commons.lang3.StringUtils.isNoneBlank(cons.getRelationCode())){
@ -660,14 +663,18 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
				String rsCode = res.getString("@RESULT");
				String free= 0+"";
				if ("0".equals(rsCode)) {
					free = res.getString("@total_charge");
					if (res.getString("@settle_flag").equalsIgnoreCase("N")){
						free = res.getString("@total_charge");
					}
				}
				if (!free.equalsIgnoreCase("0")){
					ylzPayService.msgPush("01", cardNo, "01", patientDO.getMobile(), "00", userNo, userName, idcard, outpatientDO.getRealOrder(), outpatientDO.getDeptName(), outpatientDO.getDoctorName(), date, free, "1");
					ylzPayService.msgPush("01", cardNo, "01", patientDO.getMobile(), "00", userNo, userName, idcard, outpatientDO.getXtgzh(), outpatientDO.getDeptName(), outpatientDO.getDoctorName(), date, free, "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}";

+ 63 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/dict/PrivateDictEndpoint.java

@ -0,0 +1,63 @@
package com.yihu.jw.hospital.endpoint.dict;
import com.yihu.jw.dict.service.PrivateDictService;
import com.yihu.jw.hospital.endpoint.message.SystemMessageController;
import com.yihu.jw.hospital.message.service.BaseBannerService;
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 io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping(value = BaseHospitalRequestMapping.PatientNoLogin.PREFIX)
@Api(value = "隐私策略管理", description = "隐私策略管理", tags = {"互联网医院 - 隐私策略管理"})
public class PrivateDictEndpoint extends EnvelopRestEndpoint {
    private static Logger logger = LoggerFactory.getLogger(PrivateDictEndpoint.class);
    @Autowired
    private PrivateDictService privateDictService;
    @ApiOperation("查询隐私策略")
    @PostMapping(value= BaseHospitalRequestMapping.PatientNoLogin.findPrivateDict)
    public Envelop findPrivateDict(@ApiParam(name = "dictCode", value = "隐私code")
                                    @RequestParam(value = "dictCode", required = false) String dictCode,
                                    @ApiParam(name = "hospitalCode", value = "医院code")
                                    @RequestParam(value = "hospitalCode", required = false) String hospitalCode){
        return success(privateDictService.findByHospitalCodeAndDictCode(hospitalCode,dictCode));
    }
    @PostMapping(value= BaseHospitalRequestMapping.PatientNoLogin.savePrivateDict)
    @ApiOperation("更新/新增隐私策略")
    public MixEnvelop savePrivateDict(
            @ApiParam(name = "id", value = "id", required = true)
            @RequestParam(value = "id", required = true)String id,
            @ApiParam(name = "dictCode", value = "dictCode", required = false)
            @RequestParam(value = "dictCode", required = false)String dictCode,
            @ApiParam(name = "dictName", value = "dictName", required = false)
            @RequestParam(value = "dictName", required = false)String dictName,
            @ApiParam(name = "dictValue", value = "dictValue", required = false)
            @RequestParam(value = "dictValue", required = false)String dictValue,
            @ApiParam(name = "hospitalCode", value = "hospitalCode", required = false)
            @RequestParam(value = "hospitalCode", required = false)String hospitalCode,
            @ApiParam(name = "hospitalName", value = "hospitalName", required = false)
            @RequestParam(value = "hospitalName", required = false)String hospitalName,
            @ApiParam(name = "imgUrl", value = "imgUrl", required = false)
            @RequestParam(value = "imgUrl", required = false)String imgUrl)throws Exception {
        MixEnvelop mixEnvelop =privateDictService.addPrivateDict(id,dictCode,dictName,dictValue,hospitalCode,hospitalName,imgUrl);
        return mixEnvelop;
    }
    @ApiOperation("删除隐私策略")
    @GetMapping(value= BaseHospitalRequestMapping.PatientNoLogin.delPrivateDict)
    public MixEnvelop delPrivateDict(@ApiParam(name = "id", value = "id", required = true)
                                         @RequestParam(value = "id", required = true)String id){
        MixEnvelop mixEnvelop =privateDictService.deleteById(id);
        return mixEnvelop;
    }
}

+ 6 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/file_upload/FileUploadEndpoint.java

@ -72,6 +72,9 @@ public class FileUploadEndpoint extends EnvelopRestEndpoint {
            JSONObject json = JSON.parseObject(rs);
            uploadVO = objectMapper.readValue(json.getJSONObject("obj").toJSONString(),UploadVO.class);
        }else if (isClose.equalsIgnoreCase("1")){
            Map<String, Object> map = fileUploadService.uploadImg(file);
            uploadVO.setFullUri(map.get("accessory").toString());
        }
        return success("上传成功", uploadVO);
    }
@ -93,6 +96,9 @@ public class FileUploadEndpoint extends EnvelopRestEndpoint {
            JSONObject json = JSON.parseObject(rs);
            uploadVO = objectMapper.readValue(json.getJSONObject("obj").toJSONString(),UploadVO.class);
        }else if (isClose.equalsIgnoreCase("1")){
            Map<String, Object> map = fileUploadService.uploadImg(file);
            uploadVO.setFullUri(map.get("accessory").toString());
        }
        return success("上传成功", uploadVO);
    }

+ 14 - 5
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/hospital/BaseDoctorBGController.java

@ -8,17 +8,19 @@ import com.yihu.jw.es.service.StatisticsEsService;
import com.yihu.jw.hospital.doctor.dao.service.BaseDoctorBGService;
import com.yihu.jw.hospital.prescription.service.PayInfoNoticeService;
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.utils.hibernate.HibenateUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.List;
import java.util.Map;
@ -31,6 +33,8 @@ public class BaseDoctorBGController extends EnvelopRestEndpoint {
    @Autowired
    private PayInfoNoticeService payInfoNoticeService;
    @Autowired
    private HibenateUtils hibenateUtils;
    @Autowired
    private StatisticsEsService statisticsEsService;
    @ApiOperation("获取背景板")
    @PostMapping(value= BaseHospitalRequestMapping.BaseBackground.getAllBackground)
@ -156,10 +160,15 @@ public class BaseDoctorBGController extends EnvelopRestEndpoint {
                              @ApiParam(name = "endTime", value = "结束时间,yyyy-MM-dd")
                              @RequestParam(value = "endTime", required = false)String endTime,
                              HttpServletResponse response) throws Exception{
        JSONObject jsonObject = new JSONObject();
        response.setContentType("octets/stream");
        response.setHeader("Content-Disposition", "attachment; filename="+ new String( "pushDataList.xls"));
        List<Map<String,Object>> list = payInfoNoticeService.dealSqlQuery(startTime,endTime);
        List<Map<String,Object>> listDay = payInfoNoticeService.dealSqlQueryGroupDay(startTime,endTime);
        OutputStream os = response.getOutputStream();
        payInfoNoticeService.exportEsPrescription(os,jsonObject);
        response.reset();
        response.setContentType("application/octet-stream; charset=utf-8");
        response.setCharacterEncoding("UTF-8");
        //response.setHeader("Content-Disposition", "attachment;filename="+new String("sss".getBytes(), "ISO8859-1"));qwe
        response.setHeader("content-disposition",
                "attachment;filename=" + URLEncoder.encode("在线诊疗统计情况.xls", "UTF-8"));
        payInfoNoticeService.exportEsPrescription(os,list,listDay);
    }
}

File diff suppressed because it is too large
+ 63 - 13
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java


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

@ -1,5 +1,6 @@
package com.yihu.jw.hospital.endpoint.prescription;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.area.service.BaseCityService;
import com.yihu.jw.area.service.BaseCommitteeService;
@ -13,6 +14,8 @@ import com.yihu.jw.entity.base.area.BaseCommitteeDO;
import com.yihu.jw.entity.base.area.BaseProvinceDO;
import com.yihu.jw.entity.base.area.BaseTownDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.hospital.prescription.*;
import com.yihu.jw.hospital.mapping.service.PatientMappingService;
@ -26,6 +29,8 @@ import com.yihu.jw.hospital.prescription.service.WorkTimeService;
import com.yihu.jw.hospital.prescription.service.entrance.DoctorPreSignService;
import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
import com.yihu.jw.hospital.service.SystemMessage.HospitalSystemMessageService;
import com.yihu.jw.im.dao.ConsultDao;
import com.yihu.jw.im.dao.ConsultTeamDao;
import com.yihu.jw.im.service.ImService;
import com.yihu.jw.order.BusinessOrderService;
import com.yihu.jw.restmodel.base.area.BaseCityVO;
@ -91,9 +96,6 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private OutpatientDao outpatientDao;
    
    @Autowired
    private XzzxEntranceService xzzxEntranceService;
    
    @Autowired
    private BusinessOrderService businessOrderService;
    @Autowired
@ -113,6 +115,12 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    private PatientMappingService patientMappingService;
    @Autowired
    private BaseDoctorInfoService baseDoctorInfoService;
    @Autowired
    private XzzxEntranceService xzzxEntranceService;
    @Autowired
    private ConsultDao consultDao;
    @Autowired
    private ConsultTeamDao consultTeamDao;
    @Value("${demo.flag}")
    private boolean demoFlag;
@ -256,7 +264,7 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "判断是否可用发起门诊", notes = "判断是否可用发起门诊")
    public ObjEnvelop checkOutpatient(@ApiParam(name = "patient", value = "续方明细")
                                      @RequestParam(value = "patient", required = true)String patient)throws Exception{
        return success(prescriptionService.checkOutpatient(patient));
        return success(prescriptionService.checkOutpatient(patient,wxId));
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findAllHospital)
@ -378,7 +386,14 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "获取ICD10诊断编码", notes = "获取ICD10诊断编码")
    public ListEnvelop getICD10(@ApiParam(name = "pyKey", value = "拼音关键字")
                                @RequestParam(value = "pyKey", required = false)String pyKey)throws Exception {
        return success(prescriptionService.getICD10(pyKey));
        if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
            return success(prescriptionService.getICD10(pyKey));
        }else if (wxId.equalsIgnoreCase("xm_xzzx_wx")){
            return success(xzzxEntranceService.selectIcd10Dict(pyKey));
        }else {
            return ListEnvelop.getError("尚未开发!");
        }
        
    }
    
@ -392,7 +407,14 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                                         @RequestParam(value = "winNo", required = false)String winNo,
                                         @ApiParam(name = "groupNo", value = "药房编码")
                                         @RequestParam(value = "groupNo", required = false)String groupNo)throws Exception {
        return success(prescriptionService.getDrugDictionary(drugNo,pyKey,winNo,groupNo));
        if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
            return success(prescriptionService.getDrugDictionary(drugNo,pyKey,winNo,groupNo));
        }else if (wxId.equalsIgnoreCase("xm_xzzx_wx")){
            return success(xzzxEntranceService.selectDrugDict(pyKey));
        }else {
            return ListEnvelop.getError("尚未开发!");
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getDrugUse)
@ -401,14 +423,28 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                                  @RequestParam(value = "pyKey", required = false)String pyKey,
                                  @ApiParam(name = "drugNo", value = "药品编码")
                                  @RequestParam(value = "drugNo", required = false)String drugNo)throws Exception {
        return success(prescriptionService.getDrugUse(drugNo,pyKey));
        if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
            return success(prescriptionService.getDrugUse(drugNo,pyKey));
        }else if (wxId.equalsIgnoreCase("xm_xzzx_wx")){
            return success(xzzxEntranceService.selectMedicineUsed(pyKey));
        }else {
            return ListEnvelop.getError("尚未开发!");
        }
        
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getDrugFrequency)
    @ApiOperation(value = "获取用药频次", notes = "获取用药频次")
    public ListEnvelop getDrugFrequency()throws Exception {
        return success(prescriptionService.getDrugFrequency());
        if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
            return success(prescriptionService.getDrugFrequency());
        }else if (wxId.equalsIgnoreCase("xm_xzzx_wx")){
            return success(xzzxEntranceService.selectFrequencyDict());
        }else {
            return ListEnvelop.getError("尚未开发!");
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.deletePrescriptionByid)
@ -435,12 +471,14 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                                    @ApiParam(name = "emrJson", value = "电子病历")
                                        @RequestParam(value = "emrJson", required = false)String emrJson,
                                    @ApiParam(name = "prescriptionId", value = "处方id")
                                        @RequestParam(value = "prescriptionId", required = false)String prescriptionId)throws Exception {
        Map<String,Object> result = prescriptionService.makeDiagnosis(outPatientId,prescriptionId,advice,type,infoJsons,diagnosisJson,inspectionJson,emrJson);
                                        @RequestParam(value = "prescriptionId", required = false)String prescriptionId,
                                    @ApiParam(name = "hisId", value = "审方唯一标识")
                                        @RequestParam(value = "hisId", required = false)String hisId)throws Exception {
        Map<String,Object> result = prescriptionService.makeDiagnosis(outPatientId,prescriptionId,advice,type,infoJsons,diagnosisJson,inspectionJson,emrJson,hisId);
        try {
            
            com.alibaba.fastjson.JSONObject msgObj = new com.alibaba.fastjson.JSONObject();
            
            List<WlyyPrescriptionDiagnosisDO> diagnosisDOs = (List<WlyyPrescriptionDiagnosisDO>) com.alibaba.fastjson.JSONArray.parseArray(diagnosisJson, WlyyPrescriptionDiagnosisDO.class);
            String zd_str = "";
            String jl_str = advice;
@ -652,7 +690,17 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                                       @RequestParam(value = "cancelValue", required = false)String cancelValue,
                                       @ApiParam(name = "cancelRemark", value = "取消原因详细说明")
                                       @RequestParam(value = "cancelRemark", required = false)String cancelRemark) {
        
        //修改consult门诊状态
        //修改consult门诊状态
        ConsultDo consultDo = consultDao.findByRelationCode(outPatientId);
        if (null!=consultDo){
            ConsultTeamDo consultTeamDo = consultTeamDao.findByConsult(consultDo.getId());
            if (null!=consultTeamDo){
                consultTeamDo.setStatus(-1);
                consultTeamDao.save(consultTeamDo);
            }
        }
        return success(prescriptionService.cancelOutPatient(outPatientId,cancelType,cancelValue,cancelRemark,1,wxId));
    }
    
@ -1011,11 +1059,21 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "获取检查检验", notes = "获取检查检验")
    public ListEnvelop getInspectionDictionary(@ApiParam(name = "pyKey", value = "拼音码")
                                               @RequestParam(value = "pyKey", required = false)String pyKey,
                                               @ApiParam(name = "winNo", value = "6总部7金榜8夏禾")
                                               @ApiParam(name = "winNo", value = "6总部7金榜8夏禾10检查11检验")
                                               @RequestParam(value = "winNo", required = true)String winNo,
                                               @ApiParam(name = "codes", value = "检查检验收费码codes,用逗号分割")
                                               @RequestParam(value = "codes", required = false)String codes)throws Exception{
        return success(prescriptionService.getInspectionDictionary(pyKey,codes,winNo));
        if("xm_xzzx_wx".equalsIgnoreCase(wxId)){
            if ("10".equalsIgnoreCase(winNo)){
                //检查
                return success(xzzxEntranceService.selectExamApply(pyKey));
            }else {
                //检验
                return success(xzzxEntranceService.selectLisApply(pyKey));
            }
        }else {
            return success(prescriptionService.getInspectionDictionary(pyKey,codes,winNo));
        }
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findPrescriptionLogByPreId)
@ -1031,12 +1089,19 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                                                      @RequestParam(value = "prescriptionCode", required = true)String prescriptionCode)throws Exception{
        return success(prescriptionLogService.findByPrescriptionCodeByStatus(prescriptionCode));
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.xzzxFindByPartsCode)
    @ApiOperation(value = "心脏查询部位字典", notes = "心脏查询部位字典")
    public ListEnvelop xzzxFindByPartsCode(@ApiParam(name = "spellCode", value = "拼音首字母")
                                       @RequestParam(value = "spellCode", required = false)String spellCode)throws Exception{
        return success(xzzxEntranceService.selectCheckBody(spellCode));
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findByPartsCode)
    @ApiOperation(value = "查询部位字典", notes = "查询部位字典")
    public ListEnvelop findByPartsCode(@ApiParam(name = "parentCode", value = "父节点ID,第一层为0")
                                       @RequestParam(value = "parentCode", required = true)String parentCode)throws Exception{
                                       @RequestParam(value = "parentCode", required = false)String parentCode)throws Exception{
        return success(inspectionService.findByPartsCode(parentCode));
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findDictByName)
@ -2029,4 +2094,129 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        BaseDoctorDO baseDoctorDO=baseDoctorInfoService.popularityIncrease(doctor);
        return  success("操作成功",baseDoctorDO);
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.xzzxSelectExamApply)
    @ApiOperation(value = "检查项目查询接口")
    public ListEnvelop selectExamApply(
            @ApiParam(name = "spellCode", value = "拼音首字母")
            @RequestParam(value = "spellCode",defaultValue = "") String spellCode) throws Exception {
        return success(xzzxEntranceService.selectExamApply(spellCode));
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.xzzxSelectLisApply)
    @ApiOperation(value = "检验项目查询接口")
    public ListEnvelop selectLisApply(
            @ApiParam(name = "spellCode", value = "拼音首字母")
            @RequestParam(value = "spellCode",defaultValue = "") String spellCode) throws Exception {
        return success(xzzxEntranceService.selectLisApply(spellCode));
    }
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.xzzxCheckInfo)
    @ApiOperation(value = "合理用药审核接口")
    public Envelop xzzxCheckInfo(
            @ApiParam(name = "prescriptionOnly", value = "处方唯一标识")
            @RequestParam(value = "prescriptionOnly",defaultValue = "") String prescriptionOnly,
            @ApiParam(name = "payType", value = "付款方式0自费;1医保")
            @RequestParam(value = "payType",defaultValue = "") String payType,
            @ApiParam(name = "doctor", value = "医生id")
            @RequestParam(value = "doctor",defaultValue = "") String doctor,
            @ApiParam(name = "patient", value = "病人id")
            @RequestParam(value = "patient",defaultValue = "") String patient,
            @ApiParam(name = "diagnosisDOS", value = "诊断json")
            @RequestParam(value = "diagnosisDOS",defaultValue = "") String diagnosisDOS,
            @ApiParam(name = "infos", value = "药品json")
            @RequestParam(value = "infos",defaultValue = "") String infos) throws Exception {
        JSONArray druginfos = JSONArray.parseArray(infos);
        List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = new ArrayList<>();
        for (int i=0;i<druginfos.size();i++){
            WlyyPrescriptionInfoDO wlyyPrescriptionInfo = toEntity(druginfos.get(i).toString(),WlyyPrescriptionInfoDO.class);
            wlyyPrescriptionInfoDOS.add(wlyyPrescriptionInfo);
        }
        JSONArray diagnosis = JSONArray.parseArray(diagnosisDOS);
        List<WlyyPrescriptionDiagnosisDO> wlyyPrescriptionDiagnosisDOS = new ArrayList<>();
        for (int i=0;i<diagnosis.size();i++){
            WlyyPrescriptionDiagnosisDO wlyyPrescriptionDiagnosisDO = toEntity(diagnosis.get(i).toString(),WlyyPrescriptionDiagnosisDO.class);
            wlyyPrescriptionDiagnosisDOS.add(wlyyPrescriptionDiagnosisDO);
        }
        return success(xzzxEntranceService.checkInputInfo(prescriptionOnly,payType,doctor,patient,wlyyPrescriptionDiagnosisDOS,wlyyPrescriptionInfoDOS));
    }
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.xzzxSaveCheckInfo)
    @ApiOperation(value = "合理用药审核通过后保存接口")
    public Envelop xzzxSaveCheckInfo(
            @ApiParam(name = "prescriptionOnly", value = "处方唯一标识")
            @RequestParam(value = "prescriptionOnly",defaultValue = "") String prescriptionOnly,
            @ApiParam(name = "payType", value = "付款方式0自费;1医保")
            @RequestParam(value = "payType",defaultValue = "") String payType,
            @ApiParam(name = "doctor", value = "医生id")
            @RequestParam(value = "doctor",defaultValue = "") String doctor,
            @ApiParam(name = "patient", value = "病人id")
            @RequestParam(value = "patient",defaultValue = "") String patient,
            @ApiParam(name = "diagnosisDOS", value = "诊断json")
            @RequestParam(value = "diagnosisDOS",defaultValue = "") String diagnosisDOS,
            @ApiParam(name = "infos", value = "药品json")
            @RequestParam(value = "infos",defaultValue = "") String infos) throws Exception {
        JSONArray druginfos = JSONArray.parseArray(infos);
        List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = new ArrayList<>();
        for (int i=0;i<druginfos.size();i++){
            WlyyPrescriptionInfoDO wlyyPrescriptionInfo = toEntity(druginfos.get(i).toString(),WlyyPrescriptionInfoDO.class);
            wlyyPrescriptionInfoDOS.add(wlyyPrescriptionInfo);
        }
        JSONArray diagnosis = JSONArray.parseArray(diagnosisDOS);
        List<WlyyPrescriptionDiagnosisDO> wlyyPrescriptionDiagnosisDOS = new ArrayList<>();
        for (int i=0;i<diagnosis.size();i++){
            WlyyPrescriptionDiagnosisDO wlyyPrescriptionDiagnosisDO = toEntity(diagnosis.get(i).toString(),WlyyPrescriptionDiagnosisDO.class);
            wlyyPrescriptionDiagnosisDOS.add(wlyyPrescriptionDiagnosisDO);
        }
        return success(xzzxEntranceService.saveCheckInputInfo(prescriptionOnly,payType,doctor,patient,wlyyPrescriptionDiagnosisDOS,wlyyPrescriptionInfoDOS));
    }
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.xzzxDeleteCheckInfo)
    @ApiOperation(value = "合理用药作废处方接口")
    public Envelop deleteCheckInputInfo(
            @ApiParam(name = "prescriptionOnly", value = "处方唯一标识")
            @RequestParam(value = "prescriptionOnly",defaultValue = "") String prescriptionOnly,
            @ApiParam(name = "payType", value = "付款方式0自费;1医保")
            @RequestParam(value = "payType",defaultValue = "") String payType,
            @ApiParam(name = "doctor", value = "医生id")
            @RequestParam(value = "doctor",defaultValue = "") String doctor,
            @ApiParam(name = "patient", value = "病人id")
            @RequestParam(value = "patient",defaultValue = "") String patient,
            @ApiParam(name = "diagnosisDOS", value = "诊断json")
            @RequestParam(value = "diagnosisDOS",defaultValue = "") String diagnosisDOS) throws Exception {
        JSONArray diagnosis = JSONArray.parseArray(diagnosisDOS);
        List<WlyyPrescriptionDiagnosisDO> wlyyPrescriptionDiagnosisDOS = new ArrayList<>();
        for (int i=0;i<diagnosis.size();i++){
            WlyyPrescriptionDiagnosisDO wlyyPrescriptionDiagnosisDO = toEntity(diagnosis.get(i).toString(),WlyyPrescriptionDiagnosisDO.class);
            wlyyPrescriptionDiagnosisDOS.add(wlyyPrescriptionDiagnosisDO);
        }
        return success(xzzxEntranceService.deleteCheckInputInfo(prescriptionOnly,payType,doctor,patient,wlyyPrescriptionDiagnosisDOS));
    }
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.updatePatientDiagnosis)
    @ApiOperation(value = "更新患者诊断记录")
    public Envelop updatePatientDiagnosis(
            @ApiParam(name = "outpatientId", value = "outpatientId")
            @RequestParam(value = "outpatientId",defaultValue = "",required = true) String outpatientId,
            @ApiParam(name = "icd10", value = "诊断码")
            @RequestParam(value = "icd10",defaultValue = "") String icd10,
            @ApiParam(name = "icd10Name", value = "诊断名称")
            @RequestParam(value = "icd10Name",defaultValue = "") String icd10Name) throws Exception {
        return prescriptionService.updatePatientDiagnosis(outpatientId,icd10,icd10Name);
    }
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.delHisPrescriptionByHisNo)
    @ApiOperation(value = "删除his处方信息")
    public ObjEnvelop delHisPrescriptionByHisNo(
            @ApiParam(name = "realOrder", value = "realOrder")
            @RequestParam(value = "realOrder",defaultValue = "",required = true) String realOrder) throws Exception {
        ObjEnvelop objEnvelop = new ObjEnvelop();
        objEnvelop.setObj(xzzxEntranceService.deletePrescriptionToEntrance(realOrder));
        return objEnvelop;
    }
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.saveEmrToEntrance)
    @ApiOperation(value = "保存电子病历")
    public ObjEnvelop saveEmr(
            @ApiParam(name = "prescriptionId", value = "prescriptionId")
            @RequestParam(value = "prescriptionId",defaultValue = "",required = true) String prescriptionId) throws Exception {
        ObjEnvelop objEnvelop = new ObjEnvelop();
        objEnvelop.setObj(xzzxEntranceService.saveEmrToEntrance(prescriptionId));
        return objEnvelop;
    }
}

+ 12 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/YkyyPrescriptionEndpoint.java

@ -146,7 +146,18 @@ public class YkyyPrescriptionEndpoint extends EnvelopRestEndpoint {
                                         @RequestParam(value = "chargeType", required = false)String chargeType)throws Exception {
        WlyyOutpatientDO wlyyOutpatientDO = prescriptionService.appointmentRevisit(outpatientJson,expressageJson,registerJson,chargeType);
        if (wlyyOutpatientDO!=null&&null==wlyyOutpatientDO.getId()){
            ObjEnvelop objEnvelop =new ObjEnvelop();
            String msg = "";
            if (1==wlyyOutpatientDO.getRemindCount()){
                msg = "自取";
            }else {
                msg = "快递配送";
            }
            objEnvelop.setMessage("您已经选择过"+msg+"方式,请勿修改");
            objEnvelop.setStatus(300);
            return objEnvelop;
        }
       /* //发送系统消息
        SystemMessageDO systemMessageDO = prescriptionService.sendOutPatientMes(wlyyOutpatientDO);
        //发送IM消息

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

@ -36,7 +36,7 @@ public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
     * @param startDate
     * @param endDate
     * @param area
     * @param level 5 市  4区  3医院 2科室 1医生
     * @param level 2 市  3区  4医院 5、科室 6医生
     * @param index
     * @param level2_type 2 市  3区  4医院 5、科室 6医生
     * @return
@ -55,7 +55,7 @@ public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
        JSONObject result = new JSONObject();
        logger.info("index:"+index+" and level2_type:"+level2_type+" and level:"+level);
        try {
            if (index.contains("3")){
            if (index.equalsIgnoreCase("3,21")||index.equalsIgnoreCase("3")||index.equalsIgnoreCase("21")){
                result= statisticsEsService.getOutPatientPriceLine(startDate, endDate, area, level, index, interval,level2_type);
            }else {
                result= statisticsEsService.getOutPatientLine(startDate, endDate, area, level, index, interval,level2_type);
@ -74,7 +74,7 @@ public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
     * @param startDate
     * @param endDate
     * @param area
     * @param level 5 市  4区  3医院 2科室 1医生
     * @param level 2 市  3区  4医院 5、科室 6医生
     * @param index
     * @param level2_type 2 市  3区  4医院 5、科室 6医生
     * @return
@ -103,7 +103,7 @@ public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
     * @param startDate
     * @param endDate
     * @param area
     * @param level 5 市  4区  3医院 2科室 1医生
     * @param level 2 市  3区  4医院 5、科室 6医生
     * @param index
     * @param level2_type 2 市  3区  4医院 5、科室 6医生
     * @return
@ -132,7 +132,7 @@ public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
     * @param startDate
     * @param endDate
     * @param area
     * @param level 5 市  4区  3医院 2科室 1医生
     * @param level 2 市  3区  4医院 5、科室 6医生
     * @param index
     * @param level2_type 2 市  3区  4医院 5、科室 6医生
     * @return
@ -205,7 +205,7 @@ public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
     * @param area
     * @param level
     * @param index
     * @param level2_type 5 市  4区  3医院 2科室 1医生
     * @param level2_type 2 市  3区  4医院 5、科室 6医生
     * @return
     */
    @GetMapping(value = BaseHospitalRequestMapping.Statistics.outPatientGrade)
@ -234,7 +234,7 @@ public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
     * @param startDate
     * @param endDate
     * @param area
     * @param level 5 市  4区  3医院 2科室 1医生
     * @param level 2 市  3区  4医院 5、科室 6医生
     * @param index
     * @param level2_type 2 市  3区  4医院 5、科室 6医生
     * @return
@ -833,4 +833,139 @@ public class EsStatisticsEndpoint extends EnvelopRestEndpoint {
    }
    /**
     *
     * @param startDate
     * @param endDate
     * @param area
     * @param level 2 市  3区  4医院 5科室 6医生
     * @param index
     * @return
     */
    @GetMapping(value = BaseHospitalRequestMapping.Statistics.appIndexHead)
    @ApiOperation(value = "app首页头部收入统计")
    public ObjEnvelop appIndexHead(
            @RequestParam(required = false) String startDate,
            @RequestParam(required = false) String endDate,
            @RequestParam(required = true) String area,
            @RequestParam(required = true) int level,
            @RequestParam(required = true) String index) {
        JSONObject result = new JSONObject();
        try {
            result= statisticsEsService.appIndexHead(startDate, endDate, area, level, index);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return success(result);
    }
    /**
     *
     * @param startDate
     * @param endDate
     * @param area
     * @param level 2 市  3区  4医院 5科室 6医生
     * @param index
     * @return
     */
    @GetMapping(value = BaseHospitalRequestMapping.Statistics.appIndexCenter)
    @ApiOperation(value = "app首页中部门诊量统计")
    public ObjEnvelop appIndexCenter(
            @RequestParam(required = true) String startDate,
            @RequestParam(required = true) String endDate,
            @RequestParam(required = true) String area,
            @RequestParam(required = true) int level,
            @RequestParam(required = false) String index) {
        JSONObject result = new JSONObject();
        try {
            result= statisticsEsService.appIndexCenter(startDate, endDate, area, level, index);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return success(result);
    }
    /**
     * app收入统计-头部
     * @param startDate
     * @param endDate
     * @param area
     * @param level 2 市  3区  4医院 5科室 6医生
     * @param index
     * @return
     */
    @GetMapping(value = BaseHospitalRequestMapping.Statistics.appPriceHead)
    @ApiOperation(value = "app收入统计-头部")
    public ObjEnvelop appPriceHead(
            @RequestParam(required = true) String startDate,
            @RequestParam(required = true) String endDate,
            @RequestParam(required = true) String area,
            @RequestParam(required = true) int level,
            @RequestParam(required = true) String index) {
        JSONObject result = new JSONObject();
        try {
            result= statisticsEsService.appPriceHead(startDate, endDate, area, level, index);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return success(result);
    }
    /**
     * app收入统计-头部
     * @param startDate
     * @param endDate
     * @param area
     * @param level 2 市  3区  4医院 5科室 6医生
     * @param index
     * @return
     */
    @GetMapping(value = BaseHospitalRequestMapping.Statistics.appPrescriptionHead)
    @ApiOperation(value = "app处方统计-头部")
    public ObjEnvelop appPrescriptionHead(
            @RequestParam(required = true) String startDate,
            @RequestParam(required = true) String endDate,
            @RequestParam(required = true) String area,
            @RequestParam(required = true) int level,
            @RequestParam(required = true) String index) {
        JSONObject result = new JSONObject();
        try {
            result= statisticsEsService.appPrescriptionHead(startDate, endDate, area, level, index);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return success(result);
    }
    /**
     * app中间饼状图-中部
     * @param startDate
     * @param endDate
     * @param area
     * @param level 2 市  3区  4医院 5科室 6医生
     * @param index
     * @return
     */
    @GetMapping(value = BaseHospitalRequestMapping.Statistics.appCenterCircular)
    @ApiOperation(value = "app中间饼状图-中部")
    public ObjEnvelop appCenter(
            @RequestParam(required = true) String startDate,
            @RequestParam(required = true) String endDate,
            @RequestParam(required = true) String area,
            @RequestParam(required = true) int level,
            @RequestParam(required = true) String index,
            @RequestParam(required = false) String flag) {
        JSONObject result = new JSONObject();
        try {
            result= statisticsEsService.appCenterCircular(startDate, endDate, area, level, index,flag);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return success(result);
    }
}

+ 39 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/analysis/AnalysisService.java

@ -3,11 +3,14 @@ package com.yihu.jw.hospital.service.analysis;
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
import com.yihu.jw.im.dao.ConsultTeamDao;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -22,6 +25,14 @@ public class AnalysisService {
    private OutpatientDao outpatientDao;
    @Autowired
    private ConsultTeamDao consultTeamDao;
    @Autowired
    private HibenateUtils hibenateUtils;
    @Value("${wechat.id}")
    private String wxId;
    @Value("${wechat.flag}")
    private boolean flag;
    /**
     * 分析总览数据查询
@ -32,7 +43,7 @@ public class AnalysisService {
     * @throws Exception
     */
    public Object queryAnalysis(String doctor,String startTime,String endTime)throws Exception{
        Map<String, Integer> map = new HashMap<>();
        Map<String, Object> map = new HashMap<>();
        Date start = DateUtil.strToDate(startTime, "yyyy-MM-dd HH:mm:ss");
        Date end = DateUtil.strToDate(endTime, "yyyy-MM-dd HH:mm:ss");
        //在线复诊
@ -41,10 +52,36 @@ public class AnalysisService {
        Integer xtNum = outpatientDao.countByTime("2",doctor,start,end);
        //专家咨询
        Integer imNum = consultTeamDao.countByTime(1,doctor,start,end);
        String sqlCountFee = "select t.drug_fee as \"drugFee\"," +
                " t.inspect_fee as \"inspectFee\" , " +
                " t.reg_fee as \"regFee\"  from wlyy_outpatient o " +
                " left join wlyy_prescription t on o.id = t.outpatient_id where o.status != -1" +
                " and t.status in (30,31,32,100,101) ";
        sqlCountFee+= " and o.doctor = '"+doctor+"'";
        if("xm_ykyy_wx".equals(wxId)){
            if (flag){
                sqlCountFee+=" and t.create_time > '" + startTime + " ' and t.create_time<'" + endTime + " '";
            }else {
                sqlCountFee+=" and t.create_time > to_date('" + startTime + " ', 'yyyy-mm-dd hh24:mi:ss') and t.create_time< to_date('" + endTime + " ','yyyy-mm-dd hh24:mi:ss')";
            }
        }else{
            sqlCountFee+=" and t.create_time > '" + startTime + " ' and t.create_time<'" + endTime + " '";
        }
        double totalFee =0.00;
        List<Map<String,Object>> mapList = hibenateUtils.createSQLQuery(sqlCountFee);
        if (null!=mapList&&mapList.size()>0){
            for (Map<String,Object> feemap:mapList){
                String regFee = null==feemap.get("regFee")?"0":feemap.get("regFee").toString();
                String inspectFee =  null==feemap.get("inspectFee")?"0":feemap.get("inspectFee").toString();
                String drugFee =  null==feemap.get("drugFee")?"0":feemap.get("drugFee").toString();
                double singleTotal = Double.parseDouble(regFee)+Double.parseDouble(inspectFee)+Double.parseDouble(drugFee);
                totalFee=totalFee+singleTotal;
            }
        }
        map.put("fzNum",fzNum);
        map.put("xtNum",xtNum);
        map.put("imNum",imNum);
        map.put("srNum",totalFee);
        return map;
    }

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

@ -21,9 +21,7 @@ import com.yihu.jw.hospital.survey.dao.SurveyTemplateDao;
import com.yihu.jw.hospital.survey.dao.SurveyUserDao;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.patient.dao.BasePatientBusinessDao;
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.utils.EntityUtils;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
@ -246,7 +244,7 @@ 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();
@ -349,7 +347,9 @@ public class KnowledgeArticleService extends BaseJpaService<KnowledgeArticleDO,
                " t.intro as \"intro\",t.category_first_name as \"categoryFirstName\"," +
                " t.category_second_name as \"categorySecondName\" ," +
                "t.content as \"content\",t.image as \"image\",t.create_user_name as \"createUserName\",c.job_title_name as \"jobTitleName\"," +
                "b.dept_name as \"deptName\",b.org_name as \"hospitalName\" from wlyy_knowledge_article t left join wlyy_knowledge_article_dept a " +
                "b.dept_name as \"deptName\",b.org_name as \"hospitalName\"," +
				"t.create_time as \"createTime\" " +
				" from wlyy_knowledge_article t left join wlyy_knowledge_article_dept a " +
                " on a.article_id = t.id left join base_doctor_hospital b on b.doctor_code = t.create_user" +
				" left join base_doctor c on c.id = t.create_user where 1=1 and t.del = 1 and t.status = 1";
		if (StringUtils.isNotBlank(categoryFirst)){
@ -362,7 +362,8 @@ public class KnowledgeArticleService extends BaseJpaService<KnowledgeArticleDO,
            sql+=" and (t.create_user_name like '%"+keyWords+"%' or t.title like '%"+keyWords+"%' or t.content like '%"+keyWords+"%' or a.dept_name like '%"+keyWords+"%' )";
        }
		sql+=" group by t.id ,t.title ,t.intro,t.category_first_name ,t.category_second_name ,c.job_title_name," +
				"t.read_count,t.collection,t.fabulous,t.is_share,t.content ,t.image ,t.create_user_name ,b.dept_name ,b.org_name order by t.create_time desc";
				"t.read_count,t.collection,t.fabulous,t.is_share,t.content ,t.image ,t.create_user_name ,b.dept_name ,b.org_name,t.create_time " +
				" order by t.create_time desc";
        List<Map<String,Object>> result = hibenateUtils.createSQLQuery(sql,page,pageSize);
        List<Map<String,Object>> countList = hibenateUtils.createSQLQuery(sql);
        objEnvelop.setObj(result);

+ 8 - 5
svr/svr-internet-hospital/src/main/resources/application.yml

@ -25,6 +25,7 @@ spring:
  http:
    multipart:
      max-file-size: 30MB
      max-request-size: 100MB
#      location: D:/work/soft_dev/IdeaWorkSpace/wlyy2.0/svr/svr-patient/temp_file/
#      resolve-lazily: true
@ -490,13 +491,13 @@ FileTempPath:
es:
  pwflag: 1 # 1需要密码,2不需要密码
  index:
    Statistics: hlw_quota_test
    Statistics: hlw_quota_prod
  type:
    Statistics: hlw_quota_test
  host:  http://172.26.0.112:9200
  tHost: 172.26.0.112:9300
    Statistics: hlw_quota_prod
  host:  http://192.168.33.198:9200
  tHost: 192.168.33.198:9300
  clusterName: jkzl
  securityUser: elastic:elastic
  securityUser: lion:jkzlehr
  user: lion
  password: jkzlehr
#文件服务器上传配置 0本地,1.I健康,2.内网调用
@ -668,6 +669,8 @@ es:
  tHost: 172.16.100.240:9300
  clusterName: jkzl
  securityUser: lion:jkzlehr
  user: lion
  password: jkzlehr
#文件服务器上传配置 0本地,1.I健康,2.内网调用
testPattern:

+ 1 - 1
svr/svr-iot-job/src/main/resources/application.yml

@ -153,7 +153,7 @@ wechat:
spring:
  profiles: iotprod
  datasource:
    url: jdbc:mysql://10.90.32.2:20002/xmiot?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true
    url: jdbc:mysql://10.90.32.3:20002/xmiot?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true
    username: wlyy
    password: jkzlehr@123
wlyy:

+ 44 - 4
svr/svr-iot/src/main/java/com/yihu/iot/controller/monitorPlatform/MonitorPlatformController.java

@ -13,19 +13,16 @@ import com.yihu.jw.restmodel.iot.device.IotPatientDeviceVO;
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.rm.iot.IotRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import iot.device.LocationDataVO;
import jxl.demo.Write;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import java.io.Writer;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -620,6 +617,49 @@ public class MonitorPlatformController extends EnvelopRestEndpoint {
        }
    }
    /**
     * 根据患者标志获取健康指标
     * @param idcard 患者指标
     * @param type 健康指标类型(1血糖,2血压,3体重,4腰围)
     * @return 操作结果
     */
    @RequestMapping(value = "health_index/listByIdcard",method = RequestMethod.POST)
    @ApiOperation("根据患者标志获取健康指标")
    public String getHealthIndexByIdcard(@ApiParam(name="idcard",value="居民身份证",defaultValue = "P20160901001")
                                         @RequestParam(value="idcard",required = true) String idcard,
                                         @ApiParam(name="type",value="指标类型",defaultValue = "1")
                                         @RequestParam(value="type",required = true) int type,
                                         @ApiParam(name="begin",value="开始时间",defaultValue = "2016-07-23 00:00:00")
                                         @RequestParam(value="begin",required = true) String begin,
                                         @ApiParam(name="end",value="开始时间",defaultValue = "2016-08-23 00:00:00")
                                         @RequestParam(value="end",required = true) String end,
                                         @ApiParam(name="page",value="第几页",defaultValue = "1")
                                         @RequestParam(value="page",required = true) int page,
                                         @ApiParam(name="pagesize",value="每页几行",defaultValue = "10")
                                         @RequestParam(value="pagesize",required = true) int pagesize,HttpServletRequest request) {
        try {
            return monitorPlatformService.getHealthIndexByIdcard(idcard, type, begin, end, page, pagesize,request);
        } catch (Exception ex) {
            ex.printStackTrace();
            return error(-1,"查询失败");
        }
    }
    /**
     * 获取居民信息
     */
    @RequestMapping(value = "patientInfo",method = RequestMethod.GET)
    @ApiOperation("获取居民信息")
    public String patientInfo(@ApiParam(name="idcard",value="居民身份证",defaultValue = "P20160901001")
                              @RequestParam(value="idcard",required = true) String idcard) {
        try {
            return monitorPlatformService.patientInfo(idcard);
        } catch (Exception ex) {
            ex.printStackTrace();
            return error(-1,"查询失败");
        }
    }
    /**
     * 返回接口处理结果
     *

+ 45 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/monitorPlatform/MonitorPlatformService.java

@ -9,6 +9,7 @@ import com.yihu.iot.service.common.MyJdbcTemplate;
import com.yihu.iot.service.device.IotPatientDeviceService;
import com.yihu.iot.service.equipment.IotEqtDetailService;
import com.yihu.iot.service.label.FigureLabelSerachService;
import com.yihu.iot.service.platform.IotInterfaceLogService;
import com.yihu.iot.util.excel.HibenateUtils;
import com.yihu.jw.entity.iot.dict.IotSystemDictDO;
import com.yihu.jw.entity.iot.equipment.IotEquipmentDetailDO;
@ -26,6 +27,7 @@ import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.*;
@ -64,6 +66,8 @@ public class MonitorPlatformService  {
    private HibenateUtils hibenateUtils;
    @Autowired
    private IotSystemDictDao iotSystemDictDao;
    @Autowired
    private IotInterfaceLogService iotInterfaceLogService;
    /**
     * 获取位置信息
@ -398,6 +402,47 @@ public class MonitorPlatformService  {
        return sendGet(url,params);
    }
    /**
     * 根据患者标志获取健康指标
     * @param idcard
     * @param type
     * @param begin
     * @param end
     * @param page
     * @param pagesize
     * @return
     */
    public String getHealthIndexByIdcard(String idcard,int type, String begin,String end, int page,int pagesize,HttpServletRequest request) {
        String url = "/wlyygc/iot_monitoring/health_index/listByIdcard";
        Map<String, Object> params = new HashMap<>();
        params.put("idcard",idcard);
        params.put("begin",begin);
        params.put("end",end);
        params.put("type",type);
        params.put("page",page);
        params.put("pagesize",pagesize);
        try{
            //记录log
            iotInterfaceLogService.saveLog("zy808081724b116c017254d437fe000b",JSONObject.toJSONString(params),null, request,200,"getHealthIndexByIdcard");
        }catch (Exception e){
            e.printStackTrace();
        }
        return sendGet(url,params);
    }
    /**
     * 获取居民信息
     * @param idcard
     * @return
     */
    public String patientInfo(String idcard) {
        String url = "/wlyygc/iot_monitoring/patientInfo";
        Map<String, Object> params = new HashMap<>();
        params.put("idcard",idcard);
        return sendGet(url,params);
    }
    /**
     * 质控情况

+ 3 - 3
svr/svr-iot/src/main/resources/application.yml

@ -231,14 +231,14 @@ wechat:
spring:
  profiles: iotprod
  datasource:
    url: jdbc:mysql://10.90.32.2:20002/xmiot?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
    url: jdbc:mysql://10.90.32.3:20002/xmiot?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
    username: wlyy
    password: jkzlehr@123
  elasticsearch:
    cluster-name: jkzl #默认即为elasticsearch  集群名
    cluster-nodes: 10.90.32.2:20011,10.90.32.2:20011 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode
    cluster-nodes: 10.90.32.3:20011,10.90.32.3:20011 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode
    jest:
      uris: http://10.90.32.2:20011,http://10.90.32.2:20012
      uris: http://10.90.32.3:20011,http://10.90.32.3:20012
  wlyy:
    url: http://www.xmtyw.cn/wlyytest/
    appid: 915d0345-5b1d-11e6-8344-fa163e8aee62

+ 1 - 1
svr/svr-iot/src/main/resources/bootstrap.yml

@ -102,5 +102,5 @@ spring:
  profiles: iotprod
  cloud:
    config:
      uri: ${wlyy.pring.config.uri:http://192.168.120.216:1221}
      uri: ${wlyy.pring.config.uri:http://127.0.0.1:1221}
      label: ${wlyy.spring.config.label:master}

+ 12 - 8
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/rehabilitation/RehabilitationManageController.java

@ -80,16 +80,18 @@ public class RehabilitationManageController {
                                          @RequestParam(value = "executeStartTime", required = false)String executeStartTime,
                                          @ApiParam(name = "executeEndTime", value = "日历结束时间(格式:yyyy-MM-dd HH:mm:ss)")
                                          @RequestParam(value = "executeEndTime", required = false)String executeEndTime,
                                          @ApiParam(name = "planId", value = "计划id", required = true)
                                          @ApiParam(name = "planId", value = "计划id,多个计划逗号隔开", required = true)
                                          @RequestParam(value = "planId", required = true)String planId,
                                          @ApiParam(name = "searchTask", value = "快速查找任务:(1、我的任务,2、健康教育,3、健康指导,4、随访,5、复诊)", required = false)
                                          @ApiParam(name = "searchTask", value = "快速查找任务:(1电话/短信关怀,2康复咨询,3健康监测,4上门服务,5康复指导,6康复随访,7康复复诊)", required = false)
                                          @RequestParam(value = "searchTask", required = false)Integer searchTask,
                                          @ApiParam(name = "status", value = "任务状态(0未完成,1已完成,2已预约)", required = false)
                                          @RequestParam(value = "status", required = false)Integer status,
                                          @ApiParam(name = "doctorCode", value = "医生code(专科医生、家庭医生)", required = false)
                                          @RequestParam(value = "doctorCode", required = false)String doctorCode){
                                          @RequestParam(value = "doctorCode", required = false)String doctorCode,
                                          @ApiParam(name="taskExecutor",value = "任务执行人:0全部;1我的任务:2他人任务",required = false)
                                          @RequestParam(value = "taskExecutor",required = false,defaultValue = "0")String taskExecutor){
        try {
            return rehabilitationManageService.calendarPlanDetail(executeStartTime,executeEndTime,planId,searchTask,status,doctorCode);
            return rehabilitationManageService.calendarPlanDetail(executeStartTime,executeEndTime,planId,searchTask,status,doctorCode,taskExecutor);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
@ -103,16 +105,18 @@ public class RehabilitationManageController {
                                         @RequestParam(value = "executeStartTime", required = false)String executeStartTime,
                                         @ApiParam(name = "executeEndTime", value = "日历结束时间(格式:yyyy-MM-dd HH:mm:ss)")
                                         @RequestParam(value = "executeEndTime", required = false)String executeEndTime,
                                         @ApiParam(name = "planId", value = "计划id", required = true)
                                         @ApiParam(name = "planId", value = "计划id,多个计划逗号隔开", required = true)
                                         @RequestParam(value = "planId", required = true)String planId,
                                         @ApiParam(name = "searchTask", value = "快速查找任务:(1、我的任务,2、健康教育,3、健康指导,4、随访,5、复诊)")
                                         @ApiParam(name = "searchTask", value = "快速查找任务:(1电话/短信关怀,2康复咨询,3健康监测,4上门服务,5康复指导,6康复随访,7康复复诊)")
                                         @RequestParam(value = "searchTask", required = false)Integer searchTask,
                                         @ApiParam(name = "status", value = "任务状态(0未完成,1已完成,2已预约)")
                                         @RequestParam(value = "status", required = false)Integer status,
                                         @ApiParam(name = "doctorCode", value = "医生code(专科医生、家庭医生)")
                                         @RequestParam(value = "doctorCode", required = false)String doctorCode){
                                         @RequestParam(value = "doctorCode", required = false)String doctorCode,
                                         @ApiParam(name="taskExecutor",value = "任务执行人:0全部;1我的任务:2他人任务",required = false)
                                         @RequestParam(value = "taskExecutor",required = false,defaultValue = "0")String taskExecutor){
        try {
            return rehabilitationManageService.calendarPlanDetailList(planId,searchTask,status,doctorCode,executeStartTime,executeEndTime);
            return rehabilitationManageService.calendarPlanDetailList(planId,searchTask,status,doctorCode,executeStartTime,executeEndTime,taskExecutor);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());

+ 20 - 6
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/rehabilitation/RehabilitationPlanController.java

@ -17,6 +17,7 @@ import com.yihu.jw.util.date.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -366,20 +367,33 @@ public class RehabilitationPlanController extends EnvelopRestEndpoint {
    @PostMapping(value = SpecialistMapping.rehabilitation.updateRehabilitationPlan)
    @ApiOperation(value = "居民康复下转套餐编辑")
    public MixEnvelop updateRehabilitationPlan(@ApiParam(name = "rehabilitationPlan", value = "实体JSON")
                                                      @RequestParam(value = "rehabilitationPlan", required = true)String rehabilitationPlan){
                                               @RequestParam(value = "rehabilitationPlan", required = true)String rehabilitationPlan,
                                               @ApiParam(name = "updateStatus", value = "修改类型:0单个服务的修改(默认),1整个计划修改")
                                               @RequestParam(required = false,defaultValue = "0") String updateStatus){
        try {
            JSONObject json = new JSONObject(rehabilitationPlan);
            String planId = json.getString("planId");
            String hospitalServiceItemId = json.getString("hospitalServiceItemId");
            //删除该服务项目今日之后未完成的计划
            rehabilitationPlanService.deleteDetailByPlanIdAndHospitalServiceItemId(planId, hospitalServiceItemId, DateUtil.getDateShort(new Date()));
            if(StringUtils.isBlank(updateStatus)||updateStatus.equals("0")){//单个服务的修改
                rehabilitationPlanService.deleteDetailByPlanIdAndHospitalServiceItemId(planId, hospitalServiceItemId, DateUtil.getDateShort(new Date()));
            }
            else{
                rehabilitationPlanService.deleteDetailByPlanId(planId, DateUtil.getDateShort(new Date()));
            }
            JSONArray array = new JSONArray();
            for(Object planDetail : json.getJSONArray("detail")) {
                String expense="";
                JSONObject j = (JSONObject)planDetail;
                String expense = j.getString("expense");
                if(expense.contains(".")){
                    int pointIndex = expense.indexOf(".");
                    expense = expense.substring(0,pointIndex);
                if (j.get("expense") instanceof Integer){
                    expense= String.valueOf(j.getInt("expense"));
                }
                else{
                    expense = j.getString("expense");
                    if(expense.contains(".")){
                        int pointIndex = expense.indexOf(".");
                        expense = expense.substring(0,pointIndex);
                    }
                }
                j.put("expense",expense);
                if(j.has("executeTime")) {

+ 4 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/rehabilitation/RehabilitationDetailDao.java

@ -84,4 +84,8 @@ public interface RehabilitationDetailDao extends PagingAndSortingRepository<Reha
    @Modifying
    @Query("delete from RehabilitationDetailDO t where t.planId = ?1 and t.hospitalServiceItemId = ?2 and (t.executeTime > ?3 OR t.executeTime is null OR t.executeTime<>'')  and t.status <> 1 ")
    void deleteDetailByPlanIdAndHospitalServiceItemId(String planId, String hospitalServiceItemId, Date dateShort);
    @Modifying
    @Query("delete from RehabilitationDetailDO t where t.planId = ?1 and (t.executeTime > ?2 OR t.executeTime is null OR t.executeTime<>'')  and t.status <> 1 ")
    void deleteDetailByPlanId(String planId, Date dateShort);
}

File diff suppressed because it is too large
+ 6 - 2
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/SpecialistScreenResultService.java


+ 32 - 6
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/rehabilitation/RehabilitationManageService.java

@ -346,11 +346,18 @@ public class RehabilitationManageService {
     * @param searchTask 快速查找任务(1、我的任务,2、随访,3、复诊,4、健康教育)
     * @param status 任务状态(0未完成,1已完成,2已预约)
     * @param doctorCode 登陆医生
     * @param taskExecutor 任务执行者 0全部;1我的任务 2他人任务
     */
    public ObjEnvelop calendarPlanDetail(String executeStartTime,String executeEndTime,String planId,Integer searchTask,Integer status,String doctorCode) throws Exception{
    public ObjEnvelop calendarPlanDetail(String executeStartTime,String executeEndTime,String planId,Integer searchTask,Integer status,String doctorCode,String taskExecutor) throws Exception{
        String[] planIdlist = planId.split(",");
        StringBuilder planCondition = new StringBuilder();
        planCondition .append("'"+planIdlist[0]+"'");
        for (int i=1;i<planIdlist.length;i++){
            planCondition .append(",'"+planIdlist[i]+"'");
        }
        String sql = " select d.* from wlyy_specialist.wlyy_rehabilitation_plan_detail d " +
                " LEFT JOIN wlyy_rehabilitation_service_item i on i.code = d.hospital_service_item_id " +
                " where  d.plan_id='"+planId+"' " ;
                " where  d.plan_id in ("+planCondition+") " ;
        if(StringUtils.isNotBlank(executeStartTime)){
            sql += " and d.execute_time>='"+executeStartTime+"' ";
        }
@ -364,6 +371,12 @@ public class RehabilitationManageService {
                sql+=" and i.code="+searchTask+" " ;
            }
        }
        if(taskExecutor.equals("1")){ //我的任务
            sql+="and d.doctor='"+doctorCode+"' ";
        }
        if(taskExecutor.equals("2")){//他人任务
            sql+="and d.doctor <>'"+doctorCode+"' ";
        }
        if(status!=null){
            sql+= " and d.status="+status;
        }
@ -477,14 +490,21 @@ public class RehabilitationManageService {
     * @param searchTask 快速查找任务(1、我的任务,2、随访,3、复诊,4、健康教育)
     * @param status 任务状态(0未完成,1已完成,2已预约)
     * @param doctorCode 登陆医生
     * @param taskExecutor 任务执行者 0全部;1我的任务 2他人任务
     */
    public ObjEnvelop calendarPlanDetailList(String planId,Integer searchTask,Integer status,String doctorCode,String executeStartTime,String executeEndTime){
    public ObjEnvelop calendarPlanDetailList(String planId,Integer searchTask,Integer status,String doctorCode,String executeStartTime,String executeEndTime,String taskExecutor){
        String[] planIdlist = planId.split(",");
        StringBuilder planCondition = new StringBuilder();
        planCondition .append("'"+planIdlist[0]+"'");
        for (int i=1;i<planIdlist.length;i++){
            planCondition .append(",'"+planIdlist[i]+"'");
        }
        String sql = " select d.*,DATE_FORMAT(d.execute_time,'%Y/%m/%d %H:%i') as executeTime ,i.code,i.name from wlyy_specialist.wlyy_rehabilitation_plan_detail d " +
                " LEFT JOIN wlyy_rehabilitation_service_item i on i.code = d.hospital_service_item_id  " +
                " where  d.plan_id='"+planId+"' AND  d.execute_time IS NOT NULL  and d.execute_time <>'' " ;
                " where  d.plan_id in ("+planCondition+" )AND  d.execute_time IS NOT NULL  and d.execute_time <>'' " ;
        if(searchTask!=null){
            if(searchTask==8){
            if(searchTask==8){//
                sql+="and d.doctor='"+doctorCode+"' ";
            }else {
                sql+=" and i.code="+searchTask+" " ;
@ -492,6 +512,12 @@ public class RehabilitationManageService {
                sql+=" and i.reserve=1 " ;
            }*/
        }
        if(taskExecutor.equals("1")){ //我的任务
            sql+="and d.doctor='"+doctorCode+"' ";
        }
        if(taskExecutor.equals("2")){//他人任务
            sql+="and d.doctor <>'"+doctorCode+"' ";
        }
        if (StringUtils.isNoneBlank(executeEndTime)&&StringUtils.isNoneBlank(executeStartTime)){
            sql+="and d.execute_time>='"+executeStartTime+"' and d.execute_time<='"+executeEndTime+"' ";
        }
@ -1217,7 +1243,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);
        ObjEnvelop objEnvelop = calendarPlanDetailList(planId,searchTask,status,null,executeStartTime,executeEndTime,"0");
        Integer finishCount = rehabilitationDetailDao.findByStatusAndPlanId(1,planId);
        Integer allCount = rehabilitationDetailDao.findAllByPlanId(planId);
        resultMap.put("planDetailList",objEnvelop.getObj());

+ 4 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/rehabilitation/RehabilitationPlanService.java

@ -476,4 +476,8 @@ public class RehabilitationPlanService extends BaseJpaService<RehabilitationPlan
    public void deleteDetailByPlanIdAndHospitalServiceItemId(String planId, String hospitalServiceItemId, Date dateShort) {
        rehabilitationDetailDao.deleteDetailByPlanIdAndHospitalServiceItemId(planId, hospitalServiceItemId, dateShort);
    }
    public void deleteDetailByPlanId(String planId, Date dateShort) {
        rehabilitationDetailDao.deleteDetailByPlanId(planId, dateShort);
    }
}