Browse Source

Merge remote-tracking branch 'origin/dev' into dev

hill9868 5 năm trước cách đây
mục cha
commit
b1907ffc9f
77 tập tin đã thay đổi với 5547 bổ sung481 xóa
  1. 14 0
      business/base-service/src/main/java/com/yihu/jw/config/JpaConfig.java
  2. 7 0
      business/base-service/src/main/java/com/yihu/jw/dict/dao/DictHospitalDeptDao.java
  3. 16 0
      business/base-service/src/main/java/com/yihu/jw/hospital/dict/WlyyChargeDictDao.java
  4. 15 0
      business/base-service/src/main/java/com/yihu/jw/hospital/mapping/dao/DoctorMappingDao.java
  5. 1 0
      business/base-service/src/main/java/com/yihu/jw/hospital/mapping/dao/PatientMappingDao.java
  6. 26 0
      business/base-service/src/main/java/com/yihu/jw/hospital/mapping/service/DoctorMappingService.java
  7. 4 2
      business/base-service/src/main/java/com/yihu/jw/hospital/mapping/service/PatientMappingService.java
  8. 8 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/OutpatientDao.java
  9. 16 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/PrescriptionDao.java
  10. 5 1
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/PrescriptionExpressageDao.java
  11. 7 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/PrescriptionExpressageLogDao.java
  12. 2 2
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/PrescriptionInfoDao.java
  13. 1 1
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/PrescriptionInfoLogDao.java
  14. 25 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/WlyyExpressagePriceDao.java
  15. 21 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/WlyyOutpatientExpressageLogDao.java
  16. 16 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionExpressageLogService.java
  17. 721 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionExpressageService.java
  18. 684 118
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  19. 22 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/WlyyExpressagePriceService.java
  20. 368 83
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/EntranceService.java
  21. 301 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/util/SFUtils.java
  22. 20 0
      business/base-service/src/main/java/com/yihu/jw/utils/EntityUtils.java
  23. 10 0
      business/base-service/src/mqConfig/esbmq-config.xml
  24. 1 1
      business/base-service/src/mqConfig/mqdata/BS10111.json
  25. 16 8
      business/base-service/src/mqConfig/mqdata/BS16017.json
  26. 14 7
      business/base-service/src/mqConfig/mqdata/BS16017_03.json
  27. 1 0
      business/base-service/src/mqConfig/mqdata/BS20011.json
  28. 1 0
      business/base-service/src/mqConfig/mqdata/BS20019.json
  29. 1 0
      business/base-service/src/mqConfig/mqdata/BS25017.json
  30. 1 0
      business/base-service/src/mqConfig/mqdata/BS55010.json
  31. 14 1
      common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/DictHospitalDeptDO.java
  32. 30 1
      common/common-entity/src/main/java/com/yihu/jw/entity/base/org/BaseOrgDO.java
  33. 59 1
      common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientDO.java
  34. 98 12
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/consult/WlyyHospitalWaitingRoomDO.java
  35. 66 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/dict/WlyyChargeDictDO.java
  36. 100 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/doctor/WlyyPatientRegisterTimeDO.java
  37. 126 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/mapping/DoctorMappingDO.java
  38. 115 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyExpressagePriceDO.java
  39. 114 2
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyOutpatientDO.java
  40. 182 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyOutpatientExpressageLogDO.java
  41. 192 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyPatientExpressageAddrDO.java
  42. 9 20
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyPrescriptionExpressageDO.java
  43. 9 7
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyPrescriptionExpressageLogDO.java
  44. 42 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyPrescriptionInfoDO.java
  45. 95 0
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/device/IotDeviceBaiyiDO.java
  46. 96 2
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java
  47. 9 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/DictHospitalDeptVO.java
  48. 10 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/org/BaseOrgVO.java
  49. 81 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/prescription/WlyyOutpatientVO.java
  50. 196 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/prescription/WlyyPatientExpressageAddrVO.java
  51. 7 6
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/prescription/WlyyPrescriptionExpressageVO.java
  52. 38 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/prescription/WlyyPrescriptionInfoVO.java
  53. 14 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/prescription/WlyyPrescriptionVO.java
  54. 99 0
      common/common-util/src/main/java/com/yihu/jw/util/http/HttpClientKit.java
  55. 6 3
      gateway/ag-basic/src/main/resources/application.yml
  56. 4 0
      server/svr-authentication/pom.xml
  57. 188 62
      server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java
  58. 182 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/model/WlyyUserDetails.java
  59. 62 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/WlyyTokenGranter.java
  60. 6 4
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  61. 4 4
      server/svr-authentication/src/main/resources/application.yml
  62. 8 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/DictHospitalDeptService.java
  63. 27 0
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/config/bean/BeanConfig.java
  64. 54 33
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/MqSdkController.java
  65. 209 0
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/expressage/ExpressageEndpoint.java
  66. 106 0
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/expressage/WlyyPatientExpressageAddrEndpoint.java
  67. 2 2
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/third/PrescriptionUpdateController.java
  68. 21 0
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/dao/WlyyPatientExpressageAddrDao.java
  69. 39 0
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/service/WlyyPatientExpressageAddrService.java
  70. 31 83
      svr/svr-internet-hospital-entrance/src/main/resources/application.yml
  71. 14 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/config/JpaConfig.java
  72. 72 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/file_upload/FileUploadEndpoint.java
  73. 171 6
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java
  74. 21 1
      svr/svr-internet-hospital/src/main/resources/application.yml
  75. 150 8
      svr/svr-iot-sunnuo/src/main/java/com/yihu/iot/datainput/controller/IotAnalyzerController.java
  76. 12 0
      svr/svr-iot-sunnuo/src/main/java/com/yihu/iot/datainput/dao/IotDeviceBaiyiDao.java
  77. 12 0
      svr/svr-iot-sunnuo/src/main/java/com/yihu/iot/datainput/service/IotAnalyzerService.java

+ 14 - 0
business/base-service/src/main/java/com/yihu/jw/config/JpaConfig.java

@ -0,0 +1,14 @@
package com.yihu.jw.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.orm.jpa.JpaTransactionManager;
@Configuration
public class JpaConfig {
    @Bean
    public JpaTransactionManager transactionManager(){
        return new JpaTransactionManager();
    }
}

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

@ -3,9 +3,11 @@ package com.yihu.jw.dict.dao;
import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import javax.transaction.Transactional;
import java.util.List;
import java.util.Map;
@ -21,6 +23,7 @@ import java.util.Map;
 * </pre>
 * @since 1.
 */
//@Transactional
public interface DictHospitalDeptDao extends PagingAndSortingRepository<DictHospitalDeptDO, Integer>, JpaSpecificationExecutor<DictHospitalDeptDO>  {
    @Query("select code as code,name as name from DictHospitalDeptDO where orgCode in ?1")
@ -39,4 +42,8 @@ public interface DictHospitalDeptDao extends PagingAndSortingRepository<DictHosp
    DictHospitalDeptDO findByCode(String code);
    @Modifying
    @Query("delete from DictHospitalDeptDO  where orgCode=?1")
    void deleteByOrgCode(String orgCode);
}

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

@ -0,0 +1,16 @@
package com.yihu.jw.hospital.dict;
import com.yihu.jw.entity.hospital.dict.WlyyChargeDictDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import javax.transaction.Transactional;
/**
 * Created by zdm on 2019/5/28.
 */
@Transactional
public interface WlyyChargeDictDao extends PagingAndSortingRepository<WlyyChargeDictDO, String>, JpaSpecificationExecutor<WlyyChargeDictDO> {
}

+ 15 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/mapping/dao/DoctorMappingDao.java

@ -0,0 +1,15 @@
package com.yihu.jw.hospital.mapping.dao;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Trick on 2019/6/10.
 */
public interface DoctorMappingDao extends PagingAndSortingRepository<DoctorMappingDO, String>, JpaSpecificationExecutor<DoctorMappingDO> {
    List<DoctorMappingDO> findByDoctorAndOrgCode(String doctor,String orgCode);
}

+ 1 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/mapping/dao/PatientMappingDao.java

@ -10,4 +10,5 @@ import org.springframework.data.repository.PagingAndSortingRepository;
public interface PatientMappingDao extends PagingAndSortingRepository<PatientMappingDO, String>, JpaSpecificationExecutor<PatientMappingDO> {
    PatientMappingDO findByIdcardAndSource(String idcard,String source);
    PatientMappingDO findByMappingCodeAndSource(String mappingCode,String source);
}

+ 26 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/mapping/service/DoctorMappingService.java

@ -0,0 +1,26 @@
package com.yihu.jw.hospital.mapping.service;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * Created by Trick on 2019/6/10.
 */
@Service
public class DoctorMappingService {
    @Autowired
    private DoctorMappingDao doctorMappingDao;
    public DoctorMappingDO findMappingCode(String doctor,String orgCode){
        List<DoctorMappingDO> list = doctorMappingDao.findByDoctorAndOrgCode(doctor,orgCode);
        if(list!=null&&list.size()>0){
            return list.get(0);
        }
        return null;
    }
}

+ 4 - 2
business/base-service/src/main/java/com/yihu/jw/hospital/mapping/service/PatientMappingService.java

@ -55,8 +55,9 @@ public class PatientMappingService {
            patientMappingDao.save(mappingDO);
            return mappingCode;
        }else{
            throw new RuntimeException("获取his居民信息失败!");
        }
        return null;
    }
    public String findHisPatNoByPatient(String patient)throws Exception{
@ -85,7 +86,8 @@ public class PatientMappingService {
            patientMappingDao.save(mappingDO);
            return mappingCode;
        }else{
            throw new RuntimeException("获取his居民信息失败!");
        }
        return null;
    }
}

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

@ -2,10 +2,18 @@ package com.yihu.jw.hospital.prescription.dao;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Trick on 2019/6/3.
 */
public interface OutpatientDao extends PagingAndSortingRepository<WlyyOutpatientDO, String>, JpaSpecificationExecutor<WlyyOutpatientDO> {
    @Query("from WlyyOutpatientDO a where a.patient = ?1 and a.status in(0,1)")
    List<WlyyOutpatientDO> findByPatientList(String patient);
}

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

@ -1,10 +1,14 @@
package com.yihu.jw.hospital.prescription.dao;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Date;
import java.util.List;
/**
@ -14,4 +18,16 @@ public interface PrescriptionDao extends PagingAndSortingRepository<WlyyPrescrip
    @Query("select a from WlyyPrescriptionDO a where a.patientCode = ?1 and a.status >= 0 ")
    List<WlyyPrescriptionDO> findByPatientCode(String patientCode);
    @Modifying
    @Query("update WlyyPrescriptionDO p set p.status=?2 where p.id=?1")
    void updateStatus(String id,Integer status);
    @Modifying
    @Query("update WlyyPrescriptionDO p set p.status=?2 ,p.finishTime =?3 where p.id=?1")
    void updateStatus(String id, Integer status, Date date);
    List<WlyyPrescriptionDO> findByOutpatientId(String outpatientId);
    List<WlyyPrescriptionDO> findById(String id);
}

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

@ -2,6 +2,7 @@ package com.yihu.jw.hospital.prescription.dao;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionExpressageDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
@ -11,5 +12,8 @@ import java.util.List;
 */
public interface PrescriptionExpressageDao extends PagingAndSortingRepository<WlyyPrescriptionExpressageDO, String>, JpaSpecificationExecutor<WlyyPrescriptionExpressageDO> {
    List<WlyyPrescriptionExpressageDO> findByPrescriptionId(String prescriptionId);
    @Query("from WlyyPrescriptionExpressageDO p where p.mailno=?1")
    WlyyPrescriptionExpressageDO findByPrescriptionExpressMailno(String mailno);
    List<WlyyPrescriptionExpressageDO> findByOutpatientId(String outpatientId);
}

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

@ -1,11 +1,18 @@
package com.yihu.jw.hospital.prescription.dao;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionExpressageLogDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Trick on 2019/5/17.
 */
public interface PrescriptionExpressageLogDao extends PagingAndSortingRepository<WlyyPrescriptionExpressageLogDO, String>, JpaSpecificationExecutor<WlyyPrescriptionExpressageLogDO> {
    List<WlyyPrescriptionExpressageLogDO> queryByOutpatientId(String outpatientId);
    List<WlyyPrescriptionExpressageLogDO> queryByOutpatientIdOrderByCreateTimeDesc(String outpatientId);
}

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

@ -1,12 +1,11 @@
package com.yihu.jw.hospital.prescription.dao;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionInfoDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
import java.util.Set;
/**
 * Created by Trick on 2019/5/17.
@ -15,4 +14,5 @@ public interface PrescriptionInfoDao extends PagingAndSortingRepository<WlyyPres
    List<WlyyPrescriptionInfoDO> findByPrescriptionId(String prescriptionId);
    List<WlyyPrescriptionInfoDO> queryAllByPrescriptionIdInAndDel(Set ids,Integer del);
}

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

@ -7,5 +7,5 @@ import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2019/5/17.
 */
public interface PrescriptionInfoLogDao extends PagingAndSortingRepository<WlyyPrescriptionLogDO, String>, JpaSpecificationExecutor<WlyyPrescriptionLogDO> {
public interface PrescriptionLogDao extends PagingAndSortingRepository<WlyyPrescriptionLogDO, String>, JpaSpecificationExecutor<WlyyPrescriptionLogDO> {
}

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

@ -0,0 +1,25 @@
package com.yihu.jw.hospital.prescription.dao;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.jw.entity.hospital.prescription.WlyyExpressagePriceDO;
/**
 * 
 *  数据库访问层
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * Administrator 	1.0  		2019年06月05日 	Created
 *
 * </pre>
 * @since 1.
 */
public interface WlyyExpressagePriceDao extends PagingAndSortingRepository<WlyyExpressagePriceDO, String>, JpaSpecificationExecutor<WlyyExpressagePriceDO>  {
    @Query("from WlyyExpressagePriceDO where code = ?1 and endAddressName LIKE ?2 ")
    WlyyExpressagePriceDO getExprePriceByIdAndEndAdressName(String code,String end_address_name);
}

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

@ -0,0 +1,21 @@
package com.yihu.jw.hospital.prescription.dao;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientExpressageLogDO;
/**
 * 
 * 门诊物流日志表 数据库访问层
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * Administrator 	1.0  		2019年06月05日 	Created
 *
 * </pre>
 * @since 1.
 */
public interface WlyyOutpatientExpressageLogDao extends PagingAndSortingRepository<WlyyOutpatientExpressageLogDO, String>, JpaSpecificationExecutor<WlyyOutpatientExpressageLogDO>  {
}

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

@ -0,0 +1,16 @@
package com.yihu.jw.hospital.prescription.service;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionExpressageLogDO;
import com.yihu.jw.hospital.prescription.dao.PrescriptionExpressageLogDao;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.stereotype.Service;
/**
 *  门诊物流日志服务
 * lith 2019.06.04
 */
@Service
public class PrescriptionExpressageLogService extends BaseJpaService<WlyyPrescriptionExpressageLogDO, PrescriptionExpressageLogDao> {
}

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

@ -0,0 +1,721 @@
package com.yihu.jw.hospital.prescription.service;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.hospital.prescription.*;
import com.yihu.jw.hospital.prescription.dao.*;
import com.yihu.jw.hospital.prescription.service.entrance.util.SFUtils;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientKit;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
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.orm.jpa.JpaTransactionManager;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import java.util.*;
/**
 *  门诊物流服务
 * lith 2019.06.04
 */
public class PrescriptionExpressageService extends BaseJpaService<WlyyPrescriptionExpressageDO, PrescriptionExpressageDao> {
    private static Logger logger = LoggerFactory.getLogger(PrescriptionExpressageService.class);
    //顺丰快递接口请求地址
    private String sf_url;
    //顺丰快递接口接入编码
    private String sf_code;
    //顺丰快递接口checkword
    private String sf_check_word;
    @Autowired
    private SFUtils SFUtils;
    @Autowired
    private JpaTransactionManager transactionManager;
    //处方日志
    @Autowired
    private WlyyOutpatientExpressageLogDao outpatientExpressageLogDao;
    @Autowired
    private PrescriptionDao prescriptionDao;
    @Autowired
    private WlyyExpressagePriceDao expressagePriceDao;
    @Autowired
    private PrescriptionExpressageLogDao prescriptionExpressageLogDao;
    @Autowired
    private PrescriptionExpressageDao prescriptionExpressageDao;
    @Autowired
    private BaseOrgDao baseOrgDao;
    @Autowired
    private OutpatientDao outpatientDao;
    private PrescriptionExpressageService(){}
    public PrescriptionExpressageService(String sf_url,String sf_code,String sf_check_word){
        this.sf_url = sf_url;
        this.sf_code = sf_code;
        this.sf_check_word = sf_check_word;
    }
    /**
     * 组装请求参数,发送请求
     * @param xml
     * @return
     * @throws Exception
     */
    private String SFExpressPost(String xml)throws Exception{
        String verifyCode = SFUtils.verifyCodeSFXmlStr(xml,sf_check_word);
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("xml", xml));
        params.add(new BasicNameValuePair("verifyCode", verifyCode));
        String re = HttpClientKit.post(sf_url, params, "UTF-8");
        return re;
    }
    /**
     * 校验返回的xml报文
     * @param responseXml
     * @param title
     */
    private void verificationResponXml(String responseXml,String title) throws Exception {
        String error = "";
        if (StringUtils.isBlank(responseXml)) {
            // 如果返回的XML报文为空,请求也算失败
            //保存http日志
            error = title + ",返回的XML为空!";
            logger.info(error);
            throw new Exception(error);
        }else{
//          报错的报文示例<Response service="ScopeService"><Head>ERR</Head><ERROR code="8014">校验码错误 </ERROR></Response>
            Document doc = DocumentHelper.parseText(responseXml);
            String headvalue = doc.selectSingleNode("/Response/Head").getText();
            if(StringUtils.isNotBlank(headvalue) && "ERR".equals(headvalue)){
                //错误代码
                String errorCode = "";
                //错误代对应的文字
                String errorMessage = doc.selectSingleNode("/Response/ERROR").getText();
                Document error_doc = doc.selectSingleNode("/Response/ERROR").getDocument();
                Element root = error_doc.getRootElement();
                List<?> child = root.elements();
                for (Object o : child){
                    Element e = (Element) o;
                    errorCode = e.attributeValue("code");
                }
                error = title+","+errorCode+","+errorMessage;
                logger.info(error);
                throw new Exception(error);
            }
        }
    }
    /**
     * 查询派送地址是否属于顺丰的派送范围
     * @param d_address 派送地址
     * @return
     */
    public Boolean getSFOrderFilterService(String d_address) throws Exception {
        boolean result = false;
        String xml = SFUtils.getSFOrderFilterXml(d_address,sf_code,"","","","");
        String re = this.SFExpressPost(xml);
//        String re = "<Response service=\"OrderFilterService\"><Head>OK</Head><Body><OrderFilterResponse orderid=\"TE201407020016\" filter_result=\"2\" origincode=\"755\" remark=\"2\"/></Body></Response>";
        //xml验证
        verificationResponXml(re,"查询派送地址是否有效失败!");
        Document doc = DocumentHelper.parseText(re);
        String headvalue = doc.selectSingleNode("/Response/Head").getText();
        Element root = doc.getRootElement();
        if(StringUtils.isNotBlank(headvalue) && "OK".equals(headvalue)) {
            //是否能派送:1:人工确认;2:可收派;3:不可以收派
            String filter_result = "";
            Element firstWorldElement = root.element("Body");
            List<Element> elements = firstWorldElement.elements();
            for (Element o : elements){
                filter_result = o.attributeValue("filter_result");
            }
            if(StringUtils.isNotBlank(filter_result) && "2".equals(filter_result)){
                result = true;
            }
        }
        return result;
    }
    /**
     * 向顺丰快递下订单
     * @param sfexpress_obj
     * @return
     * @throws Exception
     */
    public WlyyPrescriptionExpressageDO postSFOrderService(WlyyPrescriptionExpressageDO sfexpress_obj) throws Exception {
        //获取医生所处的医院详细地址,作为寄件人地址
        WlyyOutpatientDO outpatientDO = outpatientDao.findOne(sfexpress_obj.getOutpatientId());
        BaseOrgDO hospital = baseOrgDao.findByCode(outpatientDO.getHospital());
        String xml = SFUtils.postSFOrderService(sfexpress_obj,hospital,sf_code);
        logger.info("顺丰快递下订单:xml"+xml);
        String re = this.SFExpressPost(xml);
//        String re = "<Response service=\"OrderService\"><Head>OK</Head><Body><OrderResponse filter_result=\"2\" destcode=\"592\" mailno=\"444844978335\" origincode=\"592\" orderid=\"6daa6baec5fd4b65a1b023a8b60e2e91\"/></Body></Response>";
        //xml验证
        logger.info("顺丰快递下订单:re"+re);
        verificationResponXml(re,"向顺丰快递下订单失败!");
        Document doc = DocumentHelper.parseText(re);
        String headvalue = doc.selectSingleNode("/Response/Head").getText();
        if(StringUtils.isNotBlank(headvalue) && "OK".equals(headvalue)) {
            Element root = doc.getRootElement();
            if (root.element("Body") != null)     //包含OrderResponse节点
            {
                root = root.element("Body");
            }
            //是否能派送:1:人工确认;2:可收派;3:不可以收派
            String filter_result = "";
            String orderid = "";//业务订单号
            String mailno = "";//顺丰运单号
            String destCode = "";//目的地区域代码
            List<?> child = root.elements();
            for (Object o : child) {
                Element e = (Element) o;
                filter_result = e.attributeValue("filter_result");
                orderid = e.attributeValue("orderid");
                mailno = e.attributeValue("mailno");
                destCode = e.attributeValue("destcode");
            }
            if(StringUtils.isNotBlank(filter_result) && "3".equals(filter_result)){
                logger.info("顺丰快递下订单失败:派送地址不可派送,门诊编号:"+sfexpress_obj.getOutpatientId());
                throw new Exception("顺丰快递下订单失败:派送地址不可派送");
            }
            if(StringUtils.isBlank(mailno)){
                logger.info("顺丰快递下订单失败:未获取到快递单号!门诊编号:"+sfexpress_obj.getOutpatientId());
                throw new Exception("顺丰快递下订单失败:未获取到快递单号!");
            }
            sfexpress_obj.setMailno(mailno);
            sfexpress_obj.setCityCode(destCode);
        }
        return sfexpress_obj;
    }
    /**
     * 向顺丰快递取消订单
     * @param sfexpress_obj
     * @return
     * @throws Exception
     */
    public String postOrderConfirmService(WlyyPrescriptionExpressageDO sfexpress_obj) throws Exception {
        //获取医生所处的医院详细地址,作为寄件人地址
        WlyyOutpatientDO outpatientDO = outpatientDao.findOne(sfexpress_obj.getOutpatientId());
        BaseOrgDO hospital = baseOrgDao.findByCode(outpatientDO.getHospital());
        String xml = SFUtils.SFOrderConfirmXml(sf_code,sfexpress_obj.getId(),sfexpress_obj.getMailno(),2);
        logger.info("顺丰快递取消订单请求:xml"+xml);
        String re = this.SFExpressPost(xml);
//        String re = "<Response service=\"OrderService\"><Head>OK</Head><Body><OrderResponse filter_result=\"2\" destcode=\"592\" mailno=\"444844978335\" origincode=\"592\" orderid=\"6daa6baec5fd4b65a1b023a8b60e2e91\"/></Body></Response>";
        //xml验证
        logger.info("顺丰快递取消订单结果:re"+re);
        verificationResponXml(re,"顺丰快递取消订单失败!");
        Document doc = DocumentHelper.parseText(re);
        String headvalue = doc.selectSingleNode("/Response/Head").getText();
        if(StringUtils.isNotBlank(headvalue) && "OK".equals(headvalue)) {
            Element root = doc.getRootElement();
            if (root.element("Body") != null)     //包含OrderResponse节点
            {
                root = root.element("Body");
            }
            String res_status = "";
            List<?> child = root.elements();
            for (Object o : child) {
                Element e = (Element) o;
                // 1:客户订单号与顺丰运单不匹配 2 :操作成功
                res_status = e.attributeValue("res_status");
            }
            if(StringUtils.isNotBlank(res_status) && !"2".equals(res_status)){
                logger.info("顺丰快递取消订单失败:门诊编号:"+sfexpress_obj.getOutpatientId());
                throw new Exception("顺丰快递取消订单失败:客户订单号与顺丰运单不匹配");
            }
        }
        return "取消成功";
    }
    /**
     * 调用顺丰接口获取物流路由日志,与本地匹配,进行增量修改,并返回完整日志列表
     * @param prescription
     * @param sfexpress_obj
     * @param sfexpresslogList
     * @return
     */
    public List<WlyyPrescriptionExpressageLogDO> getRoutInfos(WlyyPrescriptionDO prescription, WlyyPrescriptionExpressageDO sfexpress_obj, List<WlyyPrescriptionExpressageLogDO> sfexpresslogList) throws Exception {
        String xml = SFUtils.getRoutInfos(sfexpress_obj,sf_code);
        String re = this.SFExpressPost(xml);
        //xml验证
        verificationResponXml(re,"查询顺丰快递路由信息失败!");
        Document doc = DocumentHelper.parseText(re);
        String headvalue = doc.selectSingleNode("/Response/Head").getText();
        if(StringUtils.isNotBlank(headvalue) && "OK".equals(headvalue)) {
            Element root = doc.getRootElement();
            if (root.element("Body") != null)     //取报文根节点
            {
                root = root.element("Body");
            }
            List<?> child = root.elements();
            String mailno = "";
            Map<String,List<WlyyPrescriptionExpressageLogDO>> wayroutlsit = new HashMap<>();
            for (Object o : child) {
                Element e = (Element) o;
                mailno = e.attributeValue("mailno");
                //判断快递单号不为空,且和我们本地的一致
                if(StringUtils.isNotBlank(mailno) &&
                        sfexpress_obj.getMailno().equals(mailno)){
                    //解析报文,结合本地数据返回最终的日志结果
                    return this.xmltologlist(e,sfexpresslogList,sfexpress_obj);
                }else{
                    continue;
                }
            }
        }
        return null;
    }
    private List<WlyyPrescriptionExpressageLogDO> xmltologlist(Element e, List<WlyyPrescriptionExpressageLogDO> sfexpresslogList, WlyyPrescriptionExpressageDO sfexpress_obj)throws Exception{
        //获取本地所有路由信息的时间集
        Set<String> routAcceptTimeSet = new HashSet<>();
        for (WlyyPrescriptionExpressageLogDO log: sfexpresslogList) {
            routAcceptTimeSet.add(DateUtil.dateToStrLong(log.getAcceptTime()));
        }
        List<?> child = e.elements();
        List<WlyyPrescriptionExpressageLogDO> newroutinfolist = new ArrayList<>();
        //用于判断新节点是否包含了"已收件"的节点
        boolean isContainEndRoutInfo = false;
        for (Object o : child) {
            Element routinfoe = (Element) o;
            String accept_time = routinfoe.attributeValue("accept_time");
            String accept_address = routinfoe.attributeValue("accept_address");
            String accept_remark = routinfoe.attributeValue("remark");
            String opcode = routinfoe.attributeValue("opcode");
            //和时间集作比对,过滤已存在的
            if(!routAcceptTimeSet.contains(accept_time)){
                WlyyPrescriptionExpressageLogDO newlogobj = new WlyyPrescriptionExpressageLogDO();
                newlogobj.setAcceptTime(DateUtil.strToDate(accept_time));
                newlogobj.setAcceptAddress(accept_address);
                newlogobj.setAcceptRemark(accept_remark);
                newlogobj.setOpCode(opcode);
                newlogobj.setId(UUID.randomUUID().toString().replace("-",""));
                newlogobj.setOutpatientId(sfexpress_obj.getOutpatientId());
                newlogobj.setExpressageId(sfexpress_obj.getId());
                newlogobj.setCreateTime(new Date());
                newroutinfolist.add(newlogobj);
                sfexpresslogList.add(newlogobj);
                //aopcode=80,为已签收
                if("80".equals(opcode)){
                    isContainEndRoutInfo = true;
                }
            }
        }
        DefaultTransactionDefinition def = new DefaultTransactionDefinition();
        def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); // 事物隔离级别,开启新事务
        TransactionStatus status = transactionManager.getTransaction(def); // 获得事务状态
        try {
            //如果有新增的路由信息,则添加到数据库
            if(!newroutinfolist.isEmpty()){
                prescriptionExpressageLogDao.save(newroutinfolist);
            }
            //如果路由信息节点包含了"已收件"节点,这修改处方派送状态为完成,增加物流派送日志为完成
            if(isContainEndRoutInfo){
                //修改处方状态为完成
                prescriptionDao.updateStatus(sfexpress_obj.getId(), 100,new Date());
                //保存门诊处方配送成功的日志
                WlyyOutpatientExpressageLogDO outpatiExpressLog = new WlyyOutpatientExpressageLogDO();
                outpatiExpressLog.setOutpatientId(sfexpress_obj.getOutpatientId());
                outpatiExpressLog.setId(UUID.randomUUID().toString());
                outpatiExpressLog.setType(8);
                outpatiExpressLog.setCreateTime(new Date());
                outpatiExpressLog.setFlag(1);
                outpatiExpressLog.setStatus(100);
                outpatientExpressageLogDao.save(outpatiExpressLog);
            }
            //事务提交
            transactionManager.commit(status);
        } catch (Exception ex) {
            //报错事务回滚
            transactionManager.rollback(status);
        }
        return sfexpresslogList;
    }
    /**
     * 解析顺丰推送过来的路由信息,和本地数据匹配并进行增量更新)
     * @param xml
     * @return
     * @throws Exception
     */
    public void SFRoutePushService(String xml) throws Exception{
        Document doc = DocumentHelper.parseText(xml);
        Element root = doc.getRootElement();
        if (root.element("Body") != null)     //包含WaybillRoute节点
        {
            root = root.element("Body");
        }
        List<?> child = root.elements();
        Map<String,List<WlyyPrescriptionExpressageLogDO>> wayroutlsit = new HashMap<>();
        for (Object o : child) {
            Element routinfoe = (Element) o;
            WlyyPrescriptionExpressageLogDO sflog = new WlyyPrescriptionExpressageLogDO();
            String accept_time = routinfoe.attributeValue("accepttime");
            String accept_address = routinfoe.attributeValue("acceptaddress");
            String accept_remark = routinfoe.attributeValue("remark");
            String opcode = routinfoe.attributeValue("opcode");
            String mailno = routinfoe.attributeValue("mailno");
            String orderid = routinfoe.attributeValue("orderid");
            sflog.setAcceptTime(DateUtil.strToDate(accept_time));
            sflog.setAcceptAddress(accept_address);
            sflog.setAcceptRemark(accept_remark);
            sflog.setOpCode(opcode);
            sflog.setExpressageId(orderid);
            sflog.setId(UUID.randomUUID().toString());
            sflog.setCreateTime(new Date());
            if(wayroutlsit.keySet().contains(mailno)){
                wayroutlsit.get(mailno).add(sflog);
            }else{
                List<WlyyPrescriptionExpressageLogDO> newsflogs = new ArrayList<>();
                newsflogs.add(sflog);
                wayroutlsit.put(mailno,newsflogs);
            }
        }
        if(!wayroutlsit.keySet().isEmpty()){
            for (String mailno:wayroutlsit.keySet()) {
                List<WlyyPrescriptionExpressageLogDO> pushSFLogs = wayroutlsit.get(mailno);
                //同一个快递单号的执行一个事务操作
                this.saveSFPushRoutInfos(mailno,pushSFLogs);
            }
        }
    }
    /**
     * 同一个快递单号的执行一个事务操作
     * @param mailno
     * @param pushSFLogs
     */
    public void saveSFPushRoutInfos(String mailno,List<WlyyPrescriptionExpressageLogDO> pushSFLogs){
        //根据快递单号获取处方配送详细信息
        WlyyPrescriptionExpressageDO sfexpress = prescriptionExpressageDao.findByPrescriptionExpressMailno(mailno);
        //根据快递单号获取本地的路由信息
        List<WlyyPrescriptionExpressageLogDO> localroutinfos = prescriptionExpressageLogDao.queryByOutpatientId(sfexpress.getOutpatientId());
        //需要增量更新到本地的路由信息集合
        List<WlyyPrescriptionExpressageLogDO> newroutinfolist = new ArrayList<>();
        DefaultTransactionDefinition def = new DefaultTransactionDefinition();
        def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); // 事务隔离级别,开启新事务
        TransactionStatus status = transactionManager.getTransaction(def); // 获得事务状态
        try {
            //用于判断新节点是否包含了"已收件"的节点
            boolean isContainEndRoutInfo = false;
            //获取本地所有路由信息的时间集
            Set<String> routAcceptTimeSet = new HashSet<>();
            for (WlyyPrescriptionExpressageLogDO log: localroutinfos) {
                routAcceptTimeSet.add(DateUtil.dateToStrLong(log.getAcceptTime()));
            }
            for (WlyyPrescriptionExpressageLogDO pushlog: pushSFLogs) {
                //判断是否有已收件的路由节点
                if("80".equals(pushlog.getOpCode())){
                    isContainEndRoutInfo = true;
                }
                if(routAcceptTimeSet.contains(DateUtil.dateToStrLong(pushlog.getAcceptTime()))){
                    continue;
                }else{
                    pushlog.setOutpatientId(sfexpress.getOutpatientId());
                    newroutinfolist.add(pushlog);
                }
            }
            //如果有新增的路由信息,则添加到数据库
            if(!newroutinfolist.isEmpty()){
                prescriptionExpressageLogDao.save(newroutinfolist);
            }
            //如果路由信息节点包含了"已收件"节点,则修改处方状态为完成,增加物流派送日志为完成
            if(isContainEndRoutInfo){
                //修改处方状态为完成
                prescriptionDao.updateStatus(sfexpress.getOutpatientId(), 100,new Date());
                //保存配送成功的日志
                WlyyOutpatientExpressageLogDO outpatiExpressLog = new WlyyOutpatientExpressageLogDO();
                outpatiExpressLog.setOutpatientId(sfexpress.getOutpatientId());
                outpatiExpressLog.setId(UUID.randomUUID().toString());
                outpatiExpressLog.setType(8);
                outpatiExpressLog.setCreateTime(new Date());
                outpatiExpressLog.setFlag(1);
                outpatiExpressLog.setStatus(100);
                outpatientExpressageLogDao.save(outpatiExpressLog);
            }
            //事务提交
            transactionManager.commit(status);
        } catch (Exception ex) {
            //报错事务回滚
            transactionManager.rollback(status);
        }
    }
    /**
     * 根据收寄地址获取快递费用
     * @param d_province 省份名称
     * @param d_city     城市名称
     * @return
     */
    public WlyyExpressagePriceDO getSFExpressPrice(String d_province, String d_city) throws Exception{
        String end_address_name = "";
        if("厦门市".equals(d_city)){
            end_address_name = "同城";
        }else{
            if("福建省".equals(d_province)){
                end_address_name = "省内";
            }else{
                end_address_name = d_province;
            }
        }
        end_address_name = "%"+end_address_name.replaceAll("省","").replaceAll("市","")+"%";
        WlyyExpressagePriceDO sfprice =  expressagePriceDao.getExprePriceByIdAndEndAdressName("shunfeng",end_address_name);
        return sfprice;
    }
    /**
     * 根据处方快递订单号判断是否下单成功
     * 如果下单成功,保存处方物流记录,保存配送日志
     * @param sfexpress_obj
     * @return
     * @throws Exception
     */
    public boolean sfOrderSearchService(WlyyPrescriptionExpressageDO sfexpress_obj)  throws Exception{
        boolean go_on = false;
        String xml = SFUtils.sfOrderSearchService(sfexpress_obj.getId(),sf_code);
        String re = this.SFExpressPost(xml);
        try {
            //xml验证
            verificationResponXml(re,"订单处理失败!");
            Document doc = DocumentHelper.parseText(re);
            String headvalue = doc.selectSingleNode("/Response/Head").getText();
            if(StringUtils.isNotBlank(headvalue) && "OK".equals(headvalue)) {
                //是否能派送:1:人工确认;2:可收派;3:不可以收派
                String filter_result = "";
                String orderid = "";//业务订单号
                String mailno = "";//顺丰运单号
                String destCode = "";//目的地区域代码
                //错误代对应的文字
                Document redoc = doc.selectSingleNode("/Response/Body/Orderresponse").getDocument();
                Element root = redoc.getRootElement();
                List<?> child = root.elements();
                for (Object o : child) {
                    Element e = (Element) o;
                    filter_result = e.attributeValue("filter_result");
                    orderid = e.attributeValue("orderid");
                    mailno = e.attributeValue("mailno");
                    destCode = e.attributeValue("destCode");
                }
                if(StringUtils.isBlank(mailno)){
                    logger.info("顺丰快递下订单失败:未获取到快递单号!"+sfexpress_obj.getOutpatientId());
                    return true;
                }
                if(StringUtils.isNotBlank(filter_result) && "3".equals(filter_result)){
                    logger.info("顺丰快递下订单失败:派送地址不可派送,处方编号:"+sfexpress_obj.getOutpatientId());
                    return true;
                }
                sfexpress_obj.setMailno(mailno);
                sfexpress_obj.setCityCode(destCode);
            }
            //如果成功获取到快递单号,则保存处方物流记录,保存配送日志
            //修改处方状态为配送中
            prescriptionDao.updateStatus(sfexpress_obj.getOutpatientId(),65);
            //保存处方物流记录
            prescriptionExpressageDao.save(sfexpress_obj);
            //保存配送日志
            WlyyOutpatientExpressageLogDO outpatiExpressLog = new WlyyOutpatientExpressageLogDO();
            outpatiExpressLog.setOutpatientId(sfexpress_obj.getOutpatientId());
            outpatiExpressLog.setId(UUID.randomUUID().toString());
            outpatiExpressLog.setType(8);
            outpatiExpressLog.setCreateTime(new Date());
            outpatiExpressLog.setFlag(1);
            outpatiExpressLog.setStatus(100);
            outpatientExpressageLogDao.save(outpatiExpressLog);
        }catch (Exception ex){
            logger.info("顺丰快递下订单失败:派送地址不可派送,处方编号:"+sfexpress_obj.getOutpatientId());
            //如果订单处理失败,则可以继续下单
            go_on = true;
        }
        return go_on;
    }
    public boolean sfOrderSearchServiceJustSearch(WlyyPrescriptionExpressageDO sfexpress_obj)  throws Exception{
        String xml = SFUtils.sfOrderSearchService(sfexpress_obj.getId(),sf_code);
        String re = this.SFExpressPost(xml);
        boolean reslut = false;
        try {
            //xml验证
            verificationResponXml(re,"订单处理失败!");
            Document doc = DocumentHelper.parseText(re);
            String headvalue = doc.selectSingleNode("/Response/Head").getText();
            if(StringUtils.isNotBlank(headvalue) && "OK".equals(headvalue)) {
                Element root = doc.getRootElement();
                if (root.element("Body") != null)     //包含OrderResponse节点
                {
                    root = root.element("Body");
                }
                //是否能派送:1:人工确认;2:可收派;3:不可以收派
                String filter_result = "";
                String orderid = "";//业务订单号
                String mailno = "";//顺丰运单号
                List<?> child = root.elements();
                for (Object o : child) {
                    Element e = (Element) o;
                    filter_result = e.attributeValue("filter_result");
                    orderid = e.attributeValue("orderid");
                    mailno = e.attributeValue("mailno");
                }
                if(StringUtils.isNotBlank(filter_result) && "3".equals(filter_result)){
                    logger.info("顺丰快递下订单失败:派送地址不可派送,处方编号:"+sfexpress_obj.getOutpatientId());
                    throw new Exception("顺丰快递下订单失败:派送地址不可派送");
                }
                if(StringUtils.isBlank(mailno)){
                    logger.info("顺丰快递下订单失败:未获取到快递单号!"+sfexpress_obj.getOutpatientId());
                    throw new Exception("顺丰快递下订单失败:未获取到快递单号!");
                }
            }
        }catch (Exception ex){
            logger.info("顺丰快递下订单失败:派送地址不可派送,处方编号:"+sfexpress_obj.getOutpatientId());
            //如果订单处理失败,则可以继续下单
            throw new Exception(ex.getMessage());
        }
        return reslut;
    }
    public String getRoutInfosSearch(WlyyPrescriptionExpressageDO sfexpress_obj)throws Exception {
        String xml = SFUtils.getRoutInfos(sfexpress_obj,sf_code);
        String re = this.SFExpressPost(xml);
        return xml;
    }
    /**
     * 1,保存快递单号增
     * 2,加处方物流记录为配送
     * 3,修改处方状态为配送配送中
     *
     * @param prescriptionExpressage
     * @throws Exception
     */
    @Transactional
    public void updatePrescriptionExpressage(WlyyPrescriptionExpressageDO prescriptionExpressage) throws Exception {
        //修改门诊处方状态为配送配送中
        prescriptionDao.updateStatus(prescriptionExpressage.getId(), 32);
        //保存处方物流记录
        prescriptionExpressageDao.save(prescriptionExpressage);
        //保存门诊配送日志
        WlyyOutpatientExpressageLogDO prescriptionLog = new WlyyOutpatientExpressageLogDO();
        prescriptionLog.setOutpatientId(prescriptionExpressage.getOutpatientId());
        // 类型: -1 失效 1HIS对接 2易联众对接  3创建处方 4 审核  5付款 6 配送 7完成 8物流对接
        prescriptionLog.setType(8);
        // -2 患者自己取消 -1 审核不通过 , 0 审核中, 10 审核通过/待支付 ,21支付失败  20 配药中/支付成功, 21 等待领药 ,30 配送中 ,100配送成功/已完成
        prescriptionLog.setStatus(30);
        prescriptionLog.setCreateTime(new Date());
        prescriptionLog.setFlag(1);
        outpatientExpressageLogDao.save(prescriptionLog);
    }
}

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

@ -1,5 +1,6 @@
package com.yihu.jw.hospital.prescription.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.dict.dao.DictHospitalDeptDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
@ -9,27 +10,35 @@ import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.entity.hospital.consult.WlyyDoctorClinicRoomDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalWaitingRoomDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDiagnosisDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionExpressageDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionInfoDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.entity.hospital.prescription.*;
import com.yihu.jw.hospital.consult.dao.DoctorClinicRoomConsultDao;
import com.yihu.jw.hospital.consult.dao.HospitalWaitingRoomDao;
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
import com.yihu.jw.hospital.mapping.service.DoctorMappingService;
import com.yihu.jw.hospital.mapping.service.PatientMappingService;
import com.yihu.jw.hospital.prescription.dao.*;
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.dao.BasePatientMedicareCardDao;
import com.yihu.jw.restmodel.base.dict.DictHospitalDeptVO;
import com.yihu.jw.restmodel.base.org.BaseOrgVO;
import com.yihu.jw.restmodel.hospital.prescription.*;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.mysql.query.BaseJpaService;
import jxl.*;
import jxl.write.*;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.apache.poi.ss.usermodel.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
@ -37,6 +46,9 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.Boolean;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -64,6 +76,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    @Autowired
    private PrescriptionExpressageDao prescriptionExpressageDao;
    @Autowired
    private PrescriptionExpressageLogDao prescriptionExpressageLogDao;
    @Autowired
    private PrescriptionInfoDao prescriptionInfoDao;
    @Autowired
    private DoctorClinicRoomConsultDao doctorClinicRoomConsultDao;
@ -78,7 +92,11 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    @Autowired
    private PatientMappingService patientMappingService;
    @Autowired
    private DoctorMappingService doctorMappingService;
    @Autowired
    private OutpatientDao outpatientDao;
    @Autowired
    private ObjectMapper objectMapper;
    @Value("${demo.flag}")
    private boolean demoFlag;
@ -94,19 +112,30 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     */
    public  List<WlyyOutpatientVO> findOutpatientList(String patient, String startTime, String endTime, boolean demoFlag)throws Exception{
        String patNo =patientMappingService.findHisPatNoByPatient(patient);
        return entranceService.BS30025(patNo,null,null,startTime,endTime,demoFlag);
        return entranceService.BS30025(patNo,null,startTime,endTime,demoFlag);
    }
    /**
     * 原处方记录列表
     * @param registerSn
     * @param patNo
     * @param admNo
     * @param demoFlag
     * 查询单条门诊记录
     * @param patient
     * @param conNo
     * @return
     * @throws Exception
     */
    public List<WlyyPrescriptionVO> findOriginPrescriptionList(String registerSn,String patNo,String admNo,boolean demoFlag)throws Exception{
    public WlyyOutpatientVO findOutpatientInfo(String patient,String conNo)throws Exception{
        String patNo =patientMappingService.findHisPatNoByPatient(patient);
        List<WlyyOutpatientVO> list = entranceService.BS30025(patNo,conNo,null,null,demoFlag);
        if(list!=null&&list.size()>0){
            return list.get(0);
        }
        return null;
    }
    /**
     *
     */
    public List<WlyyPrescriptionVO> findOriginPrescriptionList(String registerSn,String patient,String admNo,boolean demoFlag)throws Exception{
        String patNo =patientMappingService.findHisPatNoByPatient(patient);
        return entranceService.BS16017(registerSn,patNo,admNo,null,demoFlag);
    }
@ -130,7 +159,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    }
    /**
     *
     * 获取复诊记录列表
     * @param patient
     * @param status
     * @param page
@ -143,8 +172,10 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                " FROM " +
                " wlyy_outpatient o " +
                " WHERE " +
                " o.patient = '"+patient+"'" +
                " o.status = "+status;
                " o.patient = '"+patient+"'";
        if(status!=null){
            totalSql +=  " AND o.status = "+status;
        }
        if(StringUtils.isNotBlank(startTime)){
            totalSql += " AND create_time >='"+startTime+" 00:00:00'";
        }
@ -162,6 +193,10 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                " o.origin_adm_no AS originAdmNo, " +
                " o.register_no AS registerNo, " +
                " o.origin_register_no AS originRegisterNo, " +
                " o.hospital," +
                " o.hospital_name AS hospitalName," +
                " o.win_no AS winNo," +
                " o.type," +
                " o.dept AS dept, " +
                " o.dept_name AS deptName, " +
                " o.patient AS patient, " +
@ -169,6 +204,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                " o.doctor AS doctor, " +
                " o.doctor_name AS doctorName, " +
                " o.idcard AS idcard, " +
                " o.card_no AS cardNo," +
                " o.mjz AS mjz, " +
                " o.icd10 AS icd10, " +
                " o.icd10_name AS icd10Name, " +
@ -181,13 +217,15 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                " FROM " +
                " wlyy_outpatient o " +
                " WHERE " +
                " o.patient = '"+patient+"'" +
                " o.status = "+status;
                " o.patient = '"+patient+"'";
        if(status!=null){
            sql +=  " AND o.status = "+status;
        }
        if(StringUtils.isNotBlank(startTime)){
            totalSql += " AND create_time >='"+startTime+" 00:00:00'";
            sql += " AND create_time >='"+startTime+" 00:00:00'";
        }
        if(StringUtils.isNotBlank(endTime)){
            totalSql += " AND create_time <='"+endTime+" 23:59:59'";
            sql += " AND create_time <='"+endTime+" 23:59:59'";
        }
        sql += " LIMIT " + (page - 1) * size + "," + size + "";
        List<WlyyOutpatientVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WlyyOutpatientVO.class));
@ -195,6 +233,75 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        return MixEnvelop.getSuccessListWithPage(BaseHospitalRequestMapping.Prescription.api_success, list, page, size, count);
    }
    /**
     * 获取单条复诊记录信息
     * @param outpatientId
     * @return
     */
    public com.alibaba.fastjson.JSONObject findReOutpatientInfo(String outpatientId,String prescriptionId){
        com.alibaba.fastjson.JSONObject rs = new com.alibaba.fastjson.JSONObject();
        //复诊信息
        WlyyOutpatientDO outpatientDO = outpatientDao.findOne(outpatientId);
        rs.put("outpatient",convertToModel(outpatientDO,WlyyOutpatientVO.class));
        //居民详情
        BasePatientDO basePatientDO = basePatientDao.findById(outpatientDO.getPatient());
        rs.put("patientName",basePatientDO.getName());
        rs.put("patientId",basePatientDO.getId());
        rs.put("idCard",basePatientDO.getIdcard());
        rs.put("sex", basePatientDO.getSex());
        PatientMedicareCardDO cardDO = basePatientMedicareCardDao.findByTypeAndPatientCodeAndDel(PatientMedicareCardDO.Type.MedicareCard.getType(),outpatientDO.getPatient(),"1");
        rs.put("ssc",cardDO);
        rs.put("age",IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard()));
        rs.put("address",basePatientDO.getAddress());
        rs.put("mobile",basePatientDO.getMobile());
        //获取处方信息
        List<WlyyPrescriptionDO> prescriptionDOs = null;
        if(StringUtils.isNotBlank(prescriptionId)){
            prescriptionDOs = prescriptionDao.findById(prescriptionId);
        }else{
            prescriptionDOs = prescriptionDao.findByOutpatientId(outpatientId);
        }
        List<WlyyPrescriptionVO> prescriptionVOs = new ArrayList<>();
        if(prescriptionDOs!=null&&prescriptionDOs.size()>0){
            convertToModels(prescriptionDOs,prescriptionVOs,WlyyPrescriptionVO.class);
            for(WlyyPrescriptionVO vo:prescriptionVOs){
                //疾病信息
                vo.setDiagnosisVOs(findDiagnosisById(vo.getId()));
                //药品信息
                List<WlyyPrescriptionInfoVO> infoVOs = new ArrayList<>();
                vo.setInfoVOs(convertToModels(prescriptionInfoDao.findByPrescriptionId(vo.getId()),infoVOs,WlyyPrescriptionInfoVO.class));
            }
        }
        rs.put("prescriptions",prescriptionVOs);
        //物流信息
        List<WlyyPrescriptionExpressageDO> expressageDOs = prescriptionExpressageDao.findByOutpatientId(outpatientId);
        if(expressageDOs!=null&&expressageDOs.size()>0){
            rs.put("expressage",convertToModel(expressageDOs.get(0), WlyyPrescriptionExpressageVO.class));
        }else{
            rs.put("expressage",null);
        }
        //物流配送新
        List<WlyyPrescriptionExpressageLogDO>  expressageLogDOs = prescriptionExpressageLogDao.queryByOutpatientIdOrderByCreateTimeDesc(outpatientId);
        List<WlyyPrescriptionExpressageLogVO> expressageLogVOs = new ArrayList<>();
        if(expressageLogDOs!=null&&expressageLogDOs.size()>0){
            rs.put("expressageLogs",convertToModels(expressageLogDOs,expressageLogVOs, WlyyPrescriptionExpressageLogVO.class));
        }else{
            rs.put("expressageLogs",null);
        }
        return rs;
    }
    /**
     * 查询历史
     * @param patient
@ -329,14 +436,6 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        rs.put("ssc",cardDO);
        rs.put("age",IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard()));
        //物流信息
        List<WlyyPrescriptionExpressageDO> expressageDOs = prescriptionExpressageDao.findByPrescriptionId(wlyyPrescriptionDO.getId());
        if(expressageDOs!=null&&expressageDOs.size()>0){
            rs.put("expressage",convertToModel(expressageDOs.get(0), WlyyPrescriptionExpressageVO.class));
        }else{
            rs.put("expressage",null);
        }
        //诊断信息
        rs.put("diagnosis",findDiagnosisById(wlyyPrescriptionDO.getId()));
@ -354,143 +453,610 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        return true;
    }
    /**
     * 预约
     * @param json
     * 发起图文和视频复诊
     * @param outpatientJson
     * @param expressageJson
     * @return
     * @throws Exception
     */
    public Boolean appointmentRevisit(JSONObject json)throws Exception{
    public Boolean appointmentRevisit(String outpatientJson,String expressageJson)throws Exception{
        //1.创建支付
        //1.保存就诊实体
        WlyyOutpatientDO outpatientDO = objectMapper.readValue(outpatientJson,WlyyOutpatientDO.class);
        BasePatientDO patientDO = basePatientDao.findById(outpatientDO.getPatient());
        outpatientDO.setMjz("mz");
        outpatientDO.setStatus("0");
        outpatientDO.setCreateTime(new Date());
        outpatientDO.setIdcard(patientDO.getIdcard());
        outpatientDO.setCreateTime(new Date());
        WlyyOutpatientDO outpatient = outpatientDao.save(outpatientDO);
        //2.物流信息
        WlyyPrescriptionExpressageDO expressageDO = objectMapper.readValue(expressageJson,WlyyPrescriptionExpressageDO.class);
        expressageDO.setDel(1);
        expressageDO.setCreateTime(new Date());
        expressageDO.setOutpatientId(outpatient.getId());
        prescriptionExpressageDao.save(expressageDO);
        //3.创建候诊室
        createRoom(outpatient);
        //2.支付回调
        paymentCallback(json);
        return true;
    }
//    /**
//     *
//     * @param json
//     * @return
//     */
//    public String paymentCallback(JSONObject json)throws Exception{
//
//        //创建续方
//        createPrescription(json);
//        //创建诊室
//        createRoom(json);
//        return null;
//    }
//    public Boolean createPrescription(JSONObject json) throws Exception{
//
//        String patient = json.getString("patient");
//        String doctor = json.getString("doctor");
//
//        String originRealOrder = json.getString("originRealOrder");
//        String originAdmNo = json.getString("originAdmNo");
//        String serialNo = json.getString("serialNo");
//
//
//        BasePatientDO basePatientDO = basePatientDao.findById(patient);
//        PatientMedicareCardDO cardDO = basePatientMedicareCardDao.findByTypeAndPatientCodeAndDel(PatientMedicareCardDO.Type.MedicareCard.getType(),patient,"1");
//        BaseDoctorDO baseDoctorDO = baseDoctorDao.findOne(doctor);
//        String patNo  = patientMappingService.findHisPatNoByIdCard(basePatientDO.getIdcard());
//
//        WlyyPrescriptionVO originPrescriptionVO = findOriginPrescription(serialNo,patNo,originAdmNo,originRealOrder,demoFlag);
//
//        WlyyPrescriptionDO prescription = new WlyyPrescriptionDO();
//        prescription.setOriginAdmNo(originAdmNo);
//        prescription.setOriginRealOrder(originRealOrder);
//        prescription.setOriginSerialNo(serialNo);
//        prescription.setStatus(0);
//        prescription.setPatientCode(patient);
//        prescription.setPatientName(basePatientDO.getName());
//        prescription.setSsc(cardDO.getCode());
//        prescription.setDoctor(doctor);
//        prescription.setDoctorName(baseDoctorDO.getName());
//
//        List<WlyyPrescriptionInfoVO> originInfoVOs = originPrescriptionVO.getInfoVOs();
//        List<WlyyPrescriptionInfoDO> infoDOs = new ArrayList<>();
//        List<WlyyPrescriptionDiagnosisVO> diagnosisVOs = originPrescriptionVO.getDiagnosisVOs();
//        List<WlyyPrescriptionDiagnosisDO> diagnosisDOs = new ArrayList<>();
//
//        prescriptionInfoDao.save(convertToModels(originInfoVOs,infoDOs,WlyyPrescriptionInfoDO.class));
//        prescriptionDiagnosisDao.save(convertToModels(diagnosisVOs,diagnosisDOs,WlyyPrescriptionDiagnosisDO.class));
//        prescriptionDao.save(prescription);
//        return true;
//    }
    /**
     *
     * @param json
     * 创建候诊室
     * @param outpatientDO
     * @return
     */
    public String paymentCallback(JSONObject json)throws Exception{
    public Boolean createRoom(WlyyOutpatientDO outpatientDO){
        //创建续方
        createPrescription(json);
        //创建诊室
        createRoom(json);
        return null;
        WlyyHospitalWaitingRoomDO waitingRoom = new WlyyHospitalWaitingRoomDO();
        waitingRoom.setConsultType(1);
        waitingRoom.setPatientId(outpatientDO.getPatient());
        waitingRoom.setPatientName(outpatientDO.getPatientName());
        waitingRoom.setReservationTime(outpatientDO.getAdmDate());
        waitingRoom.setVisitStatus(0);
        waitingRoom.setReservationType(1);
        waitingRoom.setSort(0);
        waitingRoom.setConsultType(Integer.parseInt(outpatientDO.getType()));
        if(StringUtils.isNotBlank(outpatientDO.getDoctor())){
            waitingRoom.setDoctor(outpatientDO.getDoctor());
            waitingRoom.setDoctor(outpatientDO.getDoctorName());
        }
        waitingRoom.setOutpatientId(outpatientDO.getId());
        waitingRoom.setCreateTime(new Date());
        HospitalWaitingRoomDao.save(waitingRoom);
        return true;
    }
    public Boolean createPrescription(JSONObject json) throws Exception{
        String patient = json.getString("patient");
        String doctor = json.getString("doctor");
    public Boolean cancelPrescription(String prescriptionId){
        WlyyPrescriptionDO prescriptionDO = prescriptionDao.findOne(prescriptionId);
        prescriptionDO.setStatus(-2);
        return true;
    }
        String originRealOrder = json.getString("originRealOrder");
        String originAdmNo = json.getString("originAdmNo");
        String serialNo = json.getString("serialNo");
    /**
     *@param admNo 门诊唯一号
     * @param realOrder 处方号
     *  @param status 处方状态 1审方失败,2审核完成,3结算完成
     * @return
     */
    public boolean updatePrescriptionByHisStatu(String admNo,String realOrder,String status)throws Exception {
        String sql = "";
        //status 处方流程状态 ,13  开方失败/调整中,20 诊断完成/开方成功/待支付,已完成:100 已完成
        //pay_status`:处方结算状态,0为未结算,1为结算成功,默认为0',
        String outPatientSql="";
        if ("1".equals(status)) {
            sql = "UPDATE base.wlyy_prescription p SET p.`status`='13' WHERE p.adm_no='" + admNo + "' AND p.real_order='" + realOrder + "' ";
        } else if ("2".equals(status)) {
            sql = "UPDATE base.wlyy_prescription p SET p.`status`='20' WHERE p.adm_no='" + admNo + "' AND p.real_order='" + realOrder + "' ";
            //变更门诊状态
            outPatientSql="UPDATE base.wlyy_outpatient p SET p.`status`='2' WHERE p.adm_no='" + admNo + "'";
            jdbcTemplate.execute(outPatientSql);
        } else if ("3".equals(status)) {
            sql = "UPDATE base.wlyy_prescription p SET p.`status`='100',p.pay_status='1' WHERE p.adm_no='" + admNo + "' AND p.real_order='" + realOrder + "' ";
        }
        jdbcTemplate.execute(sql);
        return true;
    }
        BasePatientDO basePatientDO = basePatientDao.findById(patient);
        PatientMedicareCardDO cardDO = basePatientMedicareCardDao.findByTypeAndPatientCodeAndDel(PatientMedicareCardDO.Type.MedicareCard.getType(),patient,"1");
        BaseDoctorDO baseDoctorDO = baseDoctorDao.findOne(doctor);
        String patNo  = patientMappingService.findHisPatNoByIdCard(basePatientDO.getIdcard());
    /**
     * 获取卡记录
     * @param patient
     * @return
     * @throws Exception
     */
    public JSONArray findPatientCard(String patient)throws Exception{
        BasePatientDO patientDO = basePatientDao.findById(patient);
        return entranceService.BS15018(patientDO.getIdcard(),null,demoFlag);
    }
        WlyyPrescriptionVO originPrescriptionVO = findOriginPrescription(serialNo,patNo,originAdmNo,originRealOrder,demoFlag);
        WlyyPrescriptionDO prescription = new WlyyPrescriptionDO();
        prescription.setOriginAdmNo(originAdmNo);
        prescription.setOriginRealOrder(originRealOrder);
        prescription.setOriginSerialNo(serialNo);
        prescription.setStatus(0);
        prescription.setPatientCode(patient);
        prescription.setPatientName(basePatientDO.getName());
        prescription.setSsc(cardDO.getCode());
        prescription.setDoctor(doctor);
        prescription.setDoctorName(baseDoctorDO.getName());
    public JSONObject checkOutpatient(String patient){
        //-1卡余额不足,,-2 存在未结束的诊断热 1成功
        JSONObject rs = new JSONObject();
        //1.判断钱是否够
        List<WlyyPrescriptionInfoVO> originInfoVOs = originPrescriptionVO.getInfoVOs();
        List<WlyyPrescriptionInfoDO> infoDOs = new ArrayList<>();
        List<WlyyPrescriptionDiagnosisVO> diagnosisVOs = originPrescriptionVO.getDiagnosisVOs();
        List<WlyyPrescriptionDiagnosisDO> diagnosisDOs = new ArrayList<>();
        //2.判断是否有未结束的
        List<WlyyOutpatientDO> list = outpatientDao.findByPatientList(patient);
        if(list!=null&&list.size()>0){
            rs.put("code",-2);
            rs.put("mes","存在未结束的诊断");
            return rs;
        }
        rs.put("code",1);
        rs.put("mes","验证通过");
        return rs;
    }
        prescriptionInfoDao.save(convertToModels(originInfoVOs,infoDOs,WlyyPrescriptionInfoDO.class));
        prescriptionDiagnosisDao.save(convertToModels(diagnosisVOs,diagnosisDOs,WlyyPrescriptionDiagnosisDO.class));
        prescriptionDao.save(prescription);
        return true;
    /**
     * 获取所有医院列表
     * @return
     */
    public List<BaseOrgVO> findAllHospital(){
        List<BaseOrgDO> list = baseOrgDao.findByDel("1");
        List<BaseOrgVO> rs = new ArrayList<>();
        return convertToModels(list,rs,BaseOrgVO.class);
    }
    /**
     * 获取机构下部门信息
     * @param orgCode
     * @return
     */
    public List<DictHospitalDeptVO> findDeptByHospital(String orgCode){
        List<DictHospitalDeptDO> list =  dictHospitalDeptDao.findByOrgCodeIn(orgCode);
        List<DictHospitalDeptVO> rs = new ArrayList<>();
        return convertToModels(list,rs,DictHospitalDeptVO.class);
    }
    public Boolean createRoom(JSONObject json){
    /**
     * 获取医生列表
     * @param orgCode
     * @param dept
     * @return
     */
    public List<Map<String,Object>> findDoctorByHospitalAndDept(String orgCode,String dept){
        String sql ="SELECT " +
                " d.id, " +
                " d.photo, " +
                " d.`name`, " +
                " h.doctor_duty_code, " +
                " h.doctor_duty_name " +
                " FROM " +
                " base_doctor d " +
                " JOIN base_doctor_hospital h ON h.doctor_code = d.id " +
                " WHERE  " +
                " h.dept_code = '"+dept+"' " +
                " AND h.org_code = '"+orgCode+"'";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
        String patient = json.getString("patient");
        String doctor = json.getString("doctor");
        String dept = json.getString("dept");
        String hospital = json.getString("hospital");
        String reservationTime = json.getString("reservationTime");
        Integer consultType = json.getInt("consultType");
    /**
     * 挂号
     * @return
     */
    public net.sf.json.JSONObject registerOutPatient(String outPatientId,String doctor)throws Exception{
        BasePatientDO basePatientDO = basePatientDao.findById(patient);
        BaseDoctorDO baseDoctorDO = baseDoctorDao.findOne(doctor);
        List<WlyyDoctorClinicRoomDO> list = doctorClinicRoomConsultDao.findByDoctorAndStatus(doctor,1);
        if(list!=null&&list.size()>0){
            //已经有诊室不做操作
        }else{
            //未有诊室则新增
            WlyyDoctorClinicRoomDO room = new WlyyDoctorClinicRoomDO();
            room.setDoctor(doctor);
            room.setDoctorName(baseDoctorDO.getName());
            room.setClinicName(baseDoctorDO.getName());
        WlyyOutpatientDO outpatientDO = outpatientDao.findOne(outPatientId);
        DoctorMappingDO doctorMappingDO = doctorMappingService.findMappingCode(doctor,outpatientDO.getHospital());
        if(doctorMappingDO==null){
            throw new RuntimeException("未找到医生映射信息");
        }
        net.sf.json.JSONObject rs = entranceService.BS10111(outpatientDO.getCardNo(),doctorMappingDO.getMappingCode(),outpatientDO.getDept(),null,outpatientDO.getWinNo(),demoFlag);
        String rsCode = (String)rs.get("@RESULT");
        if("0".equals(rsCode)){
            //存储挂号号
            String serialNo = (String)rs.get("serial_no");
            outpatientDO.setRegisterNo(serialNo);
        }
        return rs;
    }
    /**
     * 获取诊断
     * @param pyKey
     * @return
     * @throws Exception
     */
    public JSONArray getICD10(String pyKey)throws Exception{
        return entranceService.MS25001(pyKey,demoFlag);
    }
    /**
     * 获取药品
     * @return
     */
    public JSONArray getDrugDictionary(String chargeCode,String pyKey,String winNo)throws Exception{
        return entranceService.MS53001(chargeCode,pyKey,null,winNo,"0",demoFlag);
    }
    /**
     * 获取药品用法
     */
    public JSONArray getDrugUse(String pyKey)throws Exception{
        return entranceService.BS10110(null,pyKey,demoFlag);
    }
    /**
     * 医院频次
     * @return
     */
    public JSONArray getDrugFrequency()throws Exception{
        return entranceService.MS30012(demoFlag);
    }
    /**
     *
     * @param outPatientId
     * @param advice
     * @param type 1带处方,2不带处方
     * @param infoJsons
     * @param diagnosisJson
     * @return
     */
    public Map<String,Object> makeDiagnosis(String outPatientId,String advice,String type,String infoJsons,String diagnosisJson)throws Exception{
            DictHospitalDeptDO deptDO = dictHospitalDeptDao.findByCode(dept);
            room.setDept(dept);
            room.setDept(deptDO.getName());
        Map<String,Object> result = new HashedMap();
            BaseOrgDO baseOrgDO = baseOrgDao.findByCode(hospital);
            room.setDept(hospital);
            room.setDept(baseOrgDO.getName());
        //获取门诊记录
        WlyyOutpatientDO outpatientDO = outpatientDao.findOne(outPatientId);
        outpatientDO.setAdvice(advice);
            room.setClinicStatus(-1);
            room.setDate(new Date());
            room.setStatus(1);
            doctorClinicRoomConsultDao.save(room);
        //创建处方记录
        List<WlyyPrescriptionDO> prescriptionDOs = prescriptionDao.findByOutpatientId(outPatientId);
        WlyyPrescriptionDO prescriptionDO = null;
        if(prescriptionDOs!=null&&prescriptionDOs.size()>0){
            prescriptionDO = prescriptionDOs.get(0);
        }else{
            prescriptionDO = new WlyyPrescriptionDO();
        }
        prescriptionDO.setStatus(10);
        prescriptionDO.setPatientCode(outpatientDO.getPatient());
        prescriptionDO.setPatientName(outpatientDO.getPatientName());
        prescriptionDO.setDoctor(outpatientDO.getDoctor());
        prescriptionDO.setDoctorName(outpatientDO.getDoctorName());
        WlyyPrescriptionDO prescription = prescriptionDao.save(prescriptionDO);
        WlyyHospitalWaitingRoomDO waitingRoom = new WlyyHospitalWaitingRoomDO();
        waitingRoom.setConsultType(1);
        waitingRoom.setPatientId(patient);
        waitingRoom.setPatientName(basePatientDO.getName());
        waitingRoom.setReservationTime(DateUtil.strToDate(reservationTime));
        waitingRoom.setVisitStatus(0);
        waitingRoom.setReservationType(1);
        waitingRoom.setSort(0);
        waitingRoom.setConsultType(consultType);
        //下诊断
        //删除之前诊断
        List<WlyyPrescriptionDiagnosisDO> ds = prescriptionDiagnosisDao.findByPrescriptionId(prescription.getId());
        prescriptionDiagnosisDao.delete(ds);
        HospitalWaitingRoomDao.save(waitingRoom);
        List<WlyyPrescriptionDiagnosisDO> diagnosisDOs = (List<WlyyPrescriptionDiagnosisDO>) com.alibaba.fastjson.JSONArray.parseArray(diagnosisJson, WlyyPrescriptionDiagnosisDO.class);
        String Icd10 = "";
        String Icd10Name = "";
        for(WlyyPrescriptionDiagnosisDO diagnosisDO:diagnosisDOs){
            if("1".equals(diagnosisDO.getType())){
                Icd10 = diagnosisDO.getCode()+","+Icd10;
                Icd10Name+=diagnosisDO.getName()+","+Icd10Name;
            }else {
                Icd10+=diagnosisDO.getCode()+",";
                Icd10Name+=diagnosisDO.getName()+",";
            }
            diagnosisDO.setPrescriptionId(prescription.getId());
        }
        prescriptionDiagnosisDao.save(diagnosisDOs);
        Icd10 = Icd10.substring(0,Icd10.length()-1);
        Icd10Name = Icd10Name.substring(0,Icd10Name.length()-1);
        outpatientDO.setIcd10(Icd10);
        outpatientDO.setIcd10Name(Icd10Name);
        outpatientDao.save(outpatientDO);
        //判断是否需药品,有药品到his开处方,没有药品直接下诊断开方
        if("1".equals(type)){
            //doctor转换为his医生
            DoctorMappingDO doctorMappingDO = doctorMappingService.findMappingCode(outpatientDO.getDoctor(),outpatientDO.getHospital());
            if(doctorMappingDO==null){
                throw new RuntimeException("未找到医生映射信息");
            }
            //删除原有药品信息
            List<WlyyPrescriptionInfoDO> oldInfos = prescriptionInfoDao.findByPrescriptionId(prescription.getId());
            if(oldInfos!=null&&oldInfos.size()>0){
                prescriptionInfoDao.delete(oldInfos);
            }
            if(StringUtils.isNotBlank(infoJsons)){
                //药品
                List<WlyyPrescriptionInfoDO> infoDOs = (List<WlyyPrescriptionInfoDO>) com.alibaba.fastjson.JSONArray.parseArray(infoJsons, WlyyPrescriptionInfoDO.class);
                //his处方拼接开方条件
                com.alibaba.fastjson.JSONArray jsonData = new com.alibaba.fastjson.JSONArray();
                for(WlyyPrescriptionInfoDO info:infoDOs){
                    info.setDel(1);
                    info.setPrescriptionId(prescription.getId());
                    com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
                    json.put("cardNo",outpatientDO.getCardNo());
                    json.put("doctor",doctorMappingDO.getMappingCode());
                    json.put("dept",outpatientDO.getDept());
                    json.put("chargeCode",info.getDrugNo());
                    json.put("winNo",outpatientDO.getWinNo());
                    json.put("chargeFlag",1);
                    json.put("quantity",info.getQuantity());
                    json.put("serialNo",outpatientDO.getRegisterNo());
                    json.put("groupNo",info.getGroupNo());
                    json.put("serial",info.getSerial());
                    String Icd10s[] = Icd10.split(",");
                    for(int i=0;i<Icd10s.length;i++){
                        if(i==0){
                            json.put("icdCode",Icd10s[i]);
                        }else if(i==1){
                            json.put("diagTwo",Icd10s[i]);
                        }else if(i==2){
                            json.put("diagThree",Icd10s[i]);
                        }else if(i==3){
                            json.put("diagFour",Icd10s[i]);
                        }else if(i==4){
                            json.put("diagFive",Icd10s[i]);
                        }
                    }
                    json.put("dosage",info.getDosage());
                    json.put("unit",info.getUnit());
                    json.put("usage",info.getUsage());
                    json.put("supplyCode",info.getSupplyCode());
                    json.put("days ",info.getDays());
                    json.put("frequency",info.getFrequency());
                    jsonData.add(json);
                }
                //保存处方
                prescriptionInfoDao.save(infoDOs);
                //调用his开方接口
                net.sf.json.JSONObject jsonObject = entranceService.BS10112(jsonData.toJSONString(),demoFlag);
                //判断返回结果
                String rs = jsonObject.getString("@RESULT");
                if("0".equals(rs)){
                    String admNo = jsonObject.getString("@ADM_NO");
                    String realOrder = jsonObject.getString("@real_order");
                    prescription.setAdmNo(admNo);
                    prescription.setRealOrder(realOrder);
                    prescriptionDao.save(prescription);
                    outpatientDO.setAdmNo(admNo);
                    outpatientDao.save(outpatientDO);
                    result.put("code",1);
                    result.put("mes","开方提交成功");
                    return result;
                }else{
                    //开方失败
                    prescription.setStatus(13);
                    prescriptionDao.save(prescription);
                    result.put("code",-1);
                    result.put("mes","开方提交失败");
                    return result;
                }
            }else{
                result.put("code",-2);
                result.put("mes","参数错误,药品参数错误");
                return result;
            }
        }else{
            //
            outpatientDO.setStatus("2");
            outpatientDao.save(outpatientDO);
            result.put("code",1);
            result.put("mes","诊断完成");
            return result;
        }
        return true;
    }
    public Boolean cancelPrescription(String prescriptionId){
        WlyyPrescriptionDO prescriptionDO = prescriptionDao.findOne(prescriptionId);
        prescriptionDO.setStatus(-2);
    /**
     * 订单查询
     * @param status
     * @param oneselfPickupFlg
     * @param nameKey
     * @param startTime
     * @param endTime
     * @param page
     * @param size
     * @return
     */
    public MixEnvelop findExpressageList(String status,String oneselfPickupFlg,String nameKey,String startTime,String endTime,Integer page,Integer size){
        String totalSql="SELECT " +
                " COUNT(1) AS total " +
                " FROM " +
                " wlyy_outpatient o " +
                " JOIN wlyy_prescription p ON p.outpatient_id = o.id " +
                " JOIN wlyy_prescription_expressage e ON e.outpatient_id = o.id" +
                " WHERE" +
                " 1=1";
        if(StringUtils.isNotBlank(status)){
            totalSql+=" AND p.status in("+status+")";
        }
        if(StringUtils.isNotBlank(oneselfPickupFlg)){
            totalSql+=" AND e.oneself_pickup_flg ="+oneselfPickupFlg;
        }
        if(StringUtils.isNotBlank(nameKey)){
            totalSql+=" AND e.name like '%"+nameKey+"%'";
        }
        if(StringUtils.isNotBlank(startTime)){
            totalSql+=" AND e.create_time >='"+startTime+" 00:00:00'";
        }
        if(StringUtils.isNotBlank(endTime)){
            totalSql+=" AND e.create_time <='"+endTime+" 23:59:59'";
        }
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
        Long count = 0L;
        if (rstotal != null && rstotal.size() > 0) {
            count = (Long) rstotal.get(0).get("total");
        }
        String sql ="SELECT " +
                " e.create_time AS createTime, " +
                " e.`name`, " +
                " e.oneself_pickup_flg AS oneselfPickupFlg, " +
                " o.id AS outpatientId, " +
                " o.icd10_name AS icd10Name, " +
                " p.`status`, " +
                " p.id AS prescriptionId ," +
                " e.id AS expressageId" +
                " FROM " +
                " wlyy_outpatient o " +
                " JOIN wlyy_prescription p ON p.outpatient_id = o.id " +
                " JOIN wlyy_prescription_expressage e ON e.outpatient_id = o.id " +
                " WHERE" +
                " 1=1";
        if(StringUtils.isNotBlank(status)){
            sql+=" AND p.status in("+status+")";
        }
        if(StringUtils.isNotBlank(oneselfPickupFlg)){
            sql+=" AND e.oneself_pickup_flg ="+oneselfPickupFlg;
        }
        if(StringUtils.isNotBlank(nameKey)){
            sql+=" AND e.name like '%"+nameKey+"%'";
        }
        if(StringUtils.isNotBlank(startTime)){
            sql+=" AND e.create_time >='"+startTime+" 00:00:00'";
        }
        if(StringUtils.isNotBlank(endTime)){
            sql+=" AND e.create_time <='"+endTime+" 23:59:59'";
        }
        sql += " LIMIT " + (page - 1) * size + "," + size + "";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return MixEnvelop.getSuccessListWithPage(BaseHospitalRequestMapping.Prescription.api_success, list, page, size, count);
    }
    public Boolean setMailno(String mailno, String expressageId){
        WlyyPrescriptionExpressageDO expressageDO =  prescriptionExpressageDao.findOne(expressageId);
        expressageDO.setMailno(mailno);
        prescriptionExpressageDao.save(expressageDO);
        return true;
    }
    public void pushListWrite(OutputStream os, List<Map<String,Object>> ls) throws Exception{
        WritableWorkbook wwb = jxl.Workbook.createWorkbook(os);
        try {
            WritableSheet ws;
            ws = wwb.createSheet("sheet",1);
            String[] header = {"订单日期","收货人","诊断结果","配送方式", "订单状态"};
            int k = 0;
            for (String h : header) {
                addCell(ws, 0, k, h);//表名,行,列,header
                k++;
            }
            int i = 1;
            for (Map<String,Object> m : ls) {
                addCell(ws, i, 0, DateUtil.dateToStr((Date)m.get("createTime"),"yyyy-MM-dd HH:mm:ss"),"");
                addCell(ws, i, 1, (String)m.get("name"),"");
                addCell(ws, i, 2, (String)m.get("icd10Name"),"");
                addCell(ws, i, 3, getOneselfPickupFlgString((Integer)m.get("oneselfPickupFlg")),"");
                addCell(ws, i, 4, getStatusName((Integer)m.get("status")),"");
                i++;
            }
            wwb.write();
            wwb.close();
        } catch (IOException e) {
            e.printStackTrace();
            if (wwb != null) wwb.close();
            throw e;
        }
    }
    /**
     *
     * @return
     */
    public boolean updatePrescriptionByHisStatu(String admNo,String realOrder,String status)throws Exception{
        //TODO 状态需要再判断
        String sql="UPDATE base.wlyy_prescription p SET p.`status`='',p.pay_status='' WHERE p.adm_no='"+admNo+"' AND p.real_order='"+realOrder+"' ";
        jdbcTemplate.execute(sql);
        return true;
    public String getOneselfPickupFlgString(Integer oneselfPickupFlg){
        if(1 == oneselfPickupFlg){
            return "自取";
        }else if(0 == oneselfPickupFlg){
            return "快递";
        }else{
            return "其他";
        }
    }
    /**
     *
     * @param status
     * @return
     */
    public String getStatusName(Integer status){
        if(31==status){
            return "待配送";
        }else if(32==status){
            return "配送中";
        }else if(100==status){
            return "已完成";
        }else{
            return "其他";
        }
    }
    //添加单元格内容
    public void addCell(WritableSheet ws, int row, int column,  String data) throws WriteException {
        Label label = new Label(column ,row, data);
        ws.addCell(label);
    }
    //添加单元格内容
    public void addCell(WritableSheet ws, int row, int column, String data, String memo) throws WriteException {
        Label label = new Label(column ,row, data);
        if(!org.springframework.util.StringUtils.isEmpty(memo)){
            WritableCellFeatures cellFeatures = new WritableCellFeatures();
            cellFeatures.setComment(memo);
            label.setCellFeatures(cellFeatures);
        }
        ws.addCell(label);
    }
}

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

@ -0,0 +1,22 @@
package com.yihu.jw.hospital.prescription.service;
import com.yihu.jw.hospital.prescription.dao.WlyyExpressagePriceDao;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.stereotype.Service;
import com.yihu.jw.entity.hospital.prescription.WlyyExpressagePriceDO;
/**
 * 
 * 服务service
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * Administrator    1.0  2019年06月05日 Created
 *
 * </pre>
 * @since 1.
 */
@Service
public class WlyyExpressagePriceService extends BaseJpaService<WlyyExpressagePriceDO, WlyyExpressagePriceDao> {
}

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

@ -3,8 +3,15 @@ package com.yihu.jw.hospital.prescription.service.entrance;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.dict.dao.DictHospitalDeptDao;
import com.yihu.jw.dict.service.DictHospitalDeptService;
import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import com.yihu.jw.entity.hospital.dict.WlyyChargeDictDO;
import com.yihu.jw.entity.hospital.mapping.HospitalDeptMappingDO;
import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
import com.yihu.jw.hospital.dict.WlyyChargeDictDao;
import com.yihu.jw.hospital.mapping.dao.HospitalDeptMappingDao;
import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
import com.yihu.jw.hospital.prescription.service.entrance.util.ConvertUtil;
import com.yihu.jw.hospital.prescription.service.entrance.util.MqSdkUtil;
import com.yihu.jw.hospital.prescription.service.entrance.util.WebserviceUtil;
@ -16,10 +23,12 @@ import net.sf.json.xml.XMLSerializer;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
@ -34,6 +43,7 @@ import java.util.stream.Collectors;
 * Created by zdm on 2019/5/20.
 */
@Service
@Transactional
public class EntranceService {
    //门诊余额查询
    private static String BS15017="BS15017";
@ -59,8 +69,20 @@ public class EntranceService {
    private static String MS02013="MS02013";
    //医院频次字典表
    private static String MS30012="MS30012";
    @Value("${hospital.mqUser}")
    private String mqUser;
    @Value("${hospital.mqPwd}")
    private String mqPwd;
    @Value("${hospital.SourceSysCode}")
    private String sourceSysCode;
    @Value("${hospital.TargetSysCode}")
    private String targetSysCode;
    @Autowired
    private HospitalDeptMappingDao hospitalDeptMappingDao;
    private DictHospitalDeptDao dictHospitalDeptDao;
    @Autowired
    private PatientMappingDao patientMappingDao;
    @Autowired
    private WlyyChargeDictDao wlyyChargeDictDao;
    /**
     * 获取本地示例返参
@ -151,9 +173,9 @@ public class EntranceService {
        } else {
            StringBuffer sbs = new StringBuffer();
            //AccessControl :用户、密码、服务id
            sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>JKZL</UserName><Password>123456</Password></AccessControl>");
            sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>"+mqUser+"</UserName><Password>"+mqPwd+"</Password></AccessControl>");
            //MessageHeader :固定值 消费方系统编号 S60,提供方系统编号 S01
            sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>S60</SourceSysCode><TargetSysCode>S01</TargetSysCode></MessageHeader>");
            sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>"+sourceSysCode+"</SourceSysCode><TargetSysCode>"+targetSysCode+"</TargetSysCode></MessageHeader>");
            //查询信息拼接
            sbs.append("<MsgInfo><endNum>20000</endNum><Msg/>");
            if (StringUtils.isNotBlank(SOCIAL_NO)) {
@ -189,9 +211,9 @@ public class EntranceService {
        } else {
            StringBuffer sbs = new StringBuffer();
            //AccessControl :用户、密码、服务id
            sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>JKZL</UserName><Password>123456</Password></AccessControl>");
            sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>"+mqUser+"</UserName><Password>"+mqPwd+"</Password></AccessControl>");
            //MessageHeader :固定值 消费方系统编号 S60,提供方系统编号 S01
            sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>S60</SourceSysCode><TargetSysCode>S01</TargetSysCode></MessageHeader>");
            sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>"+sourceSysCode+"</SourceSysCode><TargetSysCode>"+targetSysCode+"</TargetSysCode></MessageHeader>");
            //查询信息拼接
            sbs.append("<MsgInfo><endNum>20000</endNum><Msg/>");
            if (StringUtils.isNotBlank(REGISTER_SN)) {
@ -253,6 +275,8 @@ public class EntranceService {
                                if (!(null != stringSet && stringSet.contains(realOrder))) {
                                    //初始化处方
                                    wlyyPrescriptionVO = initWlyyPrescriptionVo(new WlyyPrescriptionVO(), jsonObjectBody, realOrder);
                                    wlyyPrescriptionVO.setHospital("350211A1002");
                                    wlyyPrescriptionVO.setHospitalName("厦门市中山医院");
                                    wlyyPrescriptionVOMap.put(realOrder, wlyyPrescriptionVO);
                                    //主诊断 毒蛇咬伤&T63.001
                                    String[] icdName = jsonObjectBody.get("icd_name").toString().split("&");
@ -338,10 +362,18 @@ public class EntranceService {
        wlyyPrescriptionVO.setRealOrder(realOrder);
        wlyyPrescriptionVO.setSerialNo(null != jsonObjectBody.get("REGISTER_SN") ? jsonObjectBody.get("REGISTER_SN").toString() : "");
        wlyyPrescriptionVO.setType(1);
        wlyyPrescriptionVO.setPatientCode(null != jsonObjectBody.get("PAT_NO") ? jsonObjectBody.get("PAT_NO").toString() : "");
        wlyyPrescriptionVO.setPatientName(null != jsonObjectBody.get("UOM") ? jsonObjectBody.get("UOM").toString() : "");
        //TODO 通过映射表获取居民身份证号e
        wlyyPrescriptionVO.setIdcard("");
        String patNo=null != jsonObjectBody.get("PAT_NO") ? jsonObjectBody.get("PAT_NO").toString() : "";
        String patientName=null != jsonObjectBody.get("UOM") ? jsonObjectBody.get("UOM").toString() : "";
        PatientMappingDO patientMappingDo=new PatientMappingDO();
        if(StringUtils.isNotBlank(patNo)){
            patientMappingDo=  patientMappingDao.findByMappingCodeAndSource(patNo.trim(),"1");
            patNo=null==patientMappingDo?null:patientMappingDo.getPatient();
            patientName=null==patientMappingDo?null:patientMappingDo.getPatientName();
        }
        wlyyPrescriptionVO.setPatientCode(patNo);
        wlyyPrescriptionVO.setPatientName(patientName);
        wlyyPrescriptionVO.setIdcard(patientMappingDo.getIdcard());
        //TODO 社保卡号
        wlyyPrescriptionVO.setSsc("");
        wlyyPrescriptionVO.setHisDoctorCode(null != jsonObjectBody.get("PRESC_DOC") ? jsonObjectBody.get("PRESC_DOC").toString() : "");
@ -371,14 +403,15 @@ public class EntranceService {
     *  患者门诊就诊记录
     *  使用时间查询的话,很可能会超时。时间没有索引,所以超时时间需要加长
     *  @param PAT_NO 居民唯一号 一个居民在该医院只有一个号,该接口必须输入的参数
     *  @param admNo 就诊唯一号 每一次就诊都有一个唯一号:居民号+就诊次数,查询确定的一条就诊记录时需要传,否则传null
     *  @param registerSn 挂号流水号,查询确定的一条就诊记录时需要传,否则传null
     *  @param conNo 就诊次数,使用居民唯一号+就诊次数获取唯一一条就诊记录
    // *  @param admNo 就诊唯一号 每一次就诊都有一个唯一号:居民号+就诊次数,查询确定的一条就诊记录时需要传,否则传null
    // *  @param registerSn 挂号流水号,查询确定的一条就诊记录时需要传,否则传null
     *  @param startTime 开始时间 (查询一段时间内就诊记录开始时间,查询就诊记录列表时需要传,否则传null)
     *  @param endTime  结束时间 (查询一段时间内就诊记录结束时间,查询就诊记录列表时需要传,否则传null)
     * @return
     * @throws Exception
     */
    public  List<WlyyOutpatientVO> BS30025(String PAT_NO,String admNo,String registerSn,String startTime,String endTime,boolean demoFlag) throws Exception {
    public  List<WlyyOutpatientVO> BS30025(String PAT_NO,String conNo,String startTime,String endTime,boolean demoFlag) throws Exception {
        String fid = BS30025;
        String resp = "";
        if (demoFlag) {
@ -386,19 +419,16 @@ public class EntranceService {
        } else {
            StringBuffer sbs = new StringBuffer();
            //AccessControl :用户、密码、服务id
            sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>JKZL</UserName><Password>123456</Password></AccessControl>");
            sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>"+mqUser+"</UserName><Password>"+mqPwd+"</Password></AccessControl>");
            //MessageHeader :固定值 消费方系统编号 S60,提供方系统编号 S01
            sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>S60</SourceSysCode><TargetSysCode>S01</TargetSysCode></MessageHeader>");
            sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>"+sourceSysCode+"</SourceSysCode><TargetSysCode>"+targetSysCode+"</TargetSysCode></MessageHeader>");
            //查询信息拼接
            sbs.append("<MsgInfo><onceFlag>1</onceFlag><startNum>1</startNum><endNum>50000</endNum><Msg/>");
            if (StringUtils.isNotBlank(PAT_NO)) {
                sbs.append("<query compy=\"=\" item=\"PAT_NO\" splice=\"and\" value=\"'" + PAT_NO + "'\"/>");
            }
            if (StringUtils.isNotBlank(admNo)) {
                sbs.append("<query compy=\"=\" item=\"ADM_NO\" splice=\"and\" value=\"'" + admNo + "'\"/>");
            }
            if (StringUtils.isNotBlank(registerSn)) {
                sbs.append("<query compy=\"=\" item=\"REGISTER_SN\" splice=\"and\" value=\"'" + registerSn + "'\"/>");
            if (StringUtils.isNotBlank(conNo)) {
                sbs.append("<query compy=\"=\" item=\"CON_NO\" splice=\"and\" value=\"'" + conNo + "'\"/>");
            }
            if (StringUtils.isNotBlank(startTime)) {
                sbs.append("<query compy=\"&gt;=\" item=\"CON_DATE\" splice=\"and\" value=\"'" + startTime + "'\"/>");
@ -418,14 +448,23 @@ public class EntranceService {
            net.sf.json.JSONObject jsonObjectMgsInfo = (net.sf.json.JSONObject) object;
            if (null != jsonObjectMgsInfo) {
                wlyyOutpatientVO = new WlyyOutpatientVO();
                wlyyOutpatientVO.setHospital("350211A1002");
                wlyyOutpatientVO.setHospitalName("厦门市中山医院");
                wlyyOutpatientVO.setAdmNo(null == jsonObjectMgsInfo.get("ADM_NO") ? "" : jsonObjectMgsInfo.get("ADM_NO") + "");
                wlyyOutpatientVO.setRegisterNo(null == jsonObjectMgsInfo.get("REGISTER_SN") ? "" : jsonObjectMgsInfo.get("REGISTER_SN") + "");
                wlyyOutpatientVO.setDept(null == jsonObjectMgsInfo.get("ADM_SPEC") ? "" : jsonObjectMgsInfo.get("ADM_SPEC") + "");
                wlyyOutpatientVO.setDeptName(null == jsonObjectMgsInfo.get("ADM_SPEC_NAME") ? "" : jsonObjectMgsInfo.get("ADM_SPEC_NAME") + "");
                wlyyOutpatientVO.setPatient(null == jsonObjectMgsInfo.get("PAT_NO") ? "" : jsonObjectMgsInfo.get("PAT_NO") + "");
                wlyyOutpatientVO.setPatientName(null == jsonObjectMgsInfo.get("PAT_NAME") ? "" : jsonObjectMgsInfo.get("PAT_NAME") + "");
                String patNo=null != jsonObjectMgsInfo.get("PAT_NO") ? jsonObjectMgsInfo.get("PAT_NO").toString() : "";
                String patientName=null != jsonObjectMgsInfo.get("PAT_NAME") ? jsonObjectMgsInfo.get("PAT_NAME").toString() : "";
                PatientMappingDO patientMappingDo=new PatientMappingDO();
                if(StringUtils.isNotBlank(patNo)){
                    patientMappingDo=  patientMappingDao.findByMappingCodeAndSource(patNo.trim(),"1");
                    patNo=null==patientMappingDo?null:patientMappingDo.getPatient();
                    patientName=null==patientMappingDo?null:patientMappingDo.getPatientName();
                }
                wlyyOutpatientVO.setPatient(patNo);
                wlyyOutpatientVO.setPatientName(patientName);
                wlyyOutpatientVO.setConNo(null == jsonObjectMgsInfo.get("CON_NO") ? "" : jsonObjectMgsInfo.get("CON_NO") + "");
                wlyyOutpatientVO.setDoctor(null == jsonObjectMgsInfo.get("CON_DOC") ? "" : jsonObjectMgsInfo.get("CON_DOC") + "");
                wlyyOutpatientVO.setDoctorName(null == jsonObjectMgsInfo.get("CON_DOC_NAME") ? "" : jsonObjectMgsInfo.get("CON_DOC_NAME") + "");
@ -455,9 +494,9 @@ public class EntranceService {
        String fid=MS30001;
        StringBuffer sbs= new StringBuffer();
        //AccessControl :用户、密码、服务id
        sbs.append("<ESBEntry><AccessControl><Fid>"+fid+"</Fid><UserName>JKZL</UserName><Password>123456</Password></AccessControl>");
        sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>"+mqUser+"</UserName><Password>"+mqPwd+"</Password></AccessControl>");
        //MessageHeader :固定值 消费方系统编号 S60,提供方系统编号 S01
        sbs.append("<MessageHeader><Fid>"+fid+"</Fid><MsgDate>"+ DateUtil.dateToStr(new Date(),DateUtil.YYYY_MM_DD_HH_MM_SS)+"</MsgDate><SourceSysCode>S60</SourceSysCode><TargetSysCode>S01</TargetSysCode></MessageHeader>");
        sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>"+sourceSysCode+"</SourceSysCode><TargetSysCode>"+targetSysCode+"</TargetSysCode></MessageHeader>");
        //查询信息拼接
        sbs.append("<MsgInfo><endNum>1000</endNum><Msg></Msg><startNum>1</startNum></MsgInfo></ESBEntry>");
        String resp = MqSdkUtil.putReqAndGetRespByQueryStr(sbs.toString(), fid );
@ -483,9 +522,9 @@ public class EntranceService {
        } else {
            StringBuffer sbs = new StringBuffer();
            //AccessControl :用户、密码、服务id
            sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>JKZL</UserName><Password>123456</Password></AccessControl>");
            sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>"+mqUser+"</UserName><Password>"+mqPwd+"</Password></AccessControl>");
            //MessageHeader :固定值 消费方系统编号 S60,提供方系统编号 S01
            sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>S60</SourceSysCode><TargetSysCode>S01</TargetSysCode></MessageHeader>");
            sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>"+sourceSysCode+"</SourceSysCode><TargetSysCode>"+targetSysCode+"</TargetSysCode></MessageHeader>");
            //查询信息拼接
            sbs.append("<MsgInfo><endNum>10</endNum><Msg/>");
            if (StringUtils.isNotBlank(charge_code)) {
@ -526,9 +565,9 @@ public class EntranceService {
        } else {
            StringBuffer sbs = new StringBuffer();
            //AccessControl :用户、密码、服务id
            sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>JKZL</UserName><Password>123456</Password></AccessControl>");
            sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>"+mqUser+"</UserName><Password>"+mqPwd+"</Password></AccessControl>");
            //MessageHeader :固定值 消费方系统编号 S60,提供方系统编号 S01
            sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>S60</SourceSysCode><TargetSysCode>S01</TargetSysCode></MessageHeader>");
            sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>"+sourceSysCode+"</SourceSysCode><TargetSysCode>"+targetSysCode+"</TargetSysCode></MessageHeader>");
            //查询信息拼接
            sbs.append("<MsgInfo><endNum>20000</endNum><Msg/>");
            if (StringUtils.isNotBlank(supply_code)) {
@ -563,10 +602,10 @@ public class EntranceService {
        } else {
            StringBuffer sbs = new StringBuffer();
            //AccessControl :用户、密码、服务id
            sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>JKZL</UserName><Password>123456</Password></AccessControl>");
            sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>"+mqUser+"</UserName><Password>"+mqPwd+"</Password></AccessControl>");
            //MessageHeader :固定值 消费方系统编号 S60,提供方系统编号 S01
            sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>S60</SourceSysCode><TargetSysCode>S01</TargetSysCode></MessageHeader>");
            //查询信息拼接
            sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>"+sourceSysCode+"</SourceSysCode><TargetSysCode>"+targetSysCode+"</TargetSysCode></MessageHeader>");
           //查询信息拼接
            sbs.append("<MsgInfo><endNum>20000</endNum><Msg><![CDATA[<?xml version=\"1.0\" encoding=\"utf-8\"?><root>");
            sbs.append("<resquest card_no=\"" + card_no + "\" doctor=\"" + doctor + "\" dept=\"" + dept + "\" charge_type=\"" + charge_type + "\"   win_no=\"" + win_no + "\" >");
            sbs.append("</resquest></root>]]></Msg><startNum>1</startNum></MsgInfo></ESBEntry>");
@ -593,9 +632,11 @@ public class EntranceService {
            resp = getJosnFileResullt(fid);
        } else {
            StringBuffer sbs = new StringBuffer();
            sbs.append("<ESBEntry><AccessControl><Fid>BS10112</Fid><UserName>jkzl</UserName><Password>123456</Password></AccessControl>");
            sbs.append("<MessageHeader><Fid>BS10112</Fid><MsgDate>2018-10-09 16:52:39</MsgDate><SourceSysCode>S60</SourceSysCode><TargetSysCode>S01</TargetSysCode></MessageHeader>");
            sbs.append("<MsgInfo><endNum>20000</endNum><Msg><![CDATA[<?xml version=\"1.0\" encoding=\"utf-8\"?><root>");
            //AccessControl :用户、密码、服务id
            sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>"+mqUser+"</UserName><Password>"+mqPwd+"</Password></AccessControl>");
            //MessageHeader :固定值 消费方系统编号 S60,提供方系统编号 S01
            sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>"+sourceSysCode+"</SourceSysCode><TargetSysCode>"+targetSysCode+"</TargetSysCode></MessageHeader>");
           sbs.append("<MsgInfo><endNum>20000</endNum><Msg><![CDATA[<?xml version=\"1.0\" encoding=\"utf-8\"?><root>");
            for(WlyyHisPrescriptionVO vo:patientSubscribeJkedus){
                //必输字段
                sbs.append("<resquest card_no=\"" + vo.getCardNo() + "\" doctor=\"" + vo.getDoctor() + "\" dept=\"" + vo.getDept() + "\" charge_code=\"" + vo.getChargeCode() + "\" win_no=\"" + vo.getWinNo() + "\" charge_flag=\"" + vo.getChargeFlag() + "\" ");
@ -657,9 +698,9 @@ public class EntranceService {
        } else {
            StringBuffer sbs = new StringBuffer();
            //AccessControl :用户、密码、服务id
            sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>JKZL</UserName><Password>123456</Password></AccessControl>");
            sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>"+mqUser+"</UserName><Password>"+mqPwd+"</Password></AccessControl>");
            //MessageHeader :固定值 消费方系统编号 S60,提供方系统编号 S01
            sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>S60</SourceSysCode><TargetSysCode>S01</TargetSysCode></MessageHeader>");
            sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>"+sourceSysCode+"</SourceSysCode><TargetSysCode>"+targetSysCode+"</TargetSysCode></MessageHeader>");
            //查询信息拼接
            sbs.append("<MsgInfo><endNum>20000</endNum><Msg/>");
            if (StringUtils.isNotBlank(doctor_code)) {
@ -686,8 +727,8 @@ public class EntranceService {
     * @return
     * @throws Exception
     */
    @org.springframework.transaction.annotation.Transactional(rollbackFor = Exception.class)
    public List<HospitalDeptMappingDO> MS02001(boolean demoFlag) throws Exception {
//    @org.springframework.transaction.annotation.Transactional(rollbackFor = Exception.class)
    public List<DictHospitalDeptDO> MS02001(boolean demoFlag) throws Exception {
        String fid=MS02001;
        String resp="";
        if (demoFlag) {
@ -695,9 +736,9 @@ public class EntranceService {
        } else {
            StringBuffer sbs = new StringBuffer();
            //AccessControl :用户、密码、服务id
            sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>JKZL</UserName><Password>123456</Password></AccessControl>");
            sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>"+mqUser+"</UserName><Password>"+mqPwd+"</Password></AccessControl>");
            //MessageHeader :固定值 消费方系统编号 S60,提供方系统编号 S01
            sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>S60</SourceSysCode><TargetSysCode>S01</TargetSysCode></MessageHeader>");
            sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>"+sourceSysCode+"</SourceSysCode><TargetSysCode>"+targetSysCode+"</TargetSysCode></MessageHeader>");
            //查询信息拼接
            sbs.append("<MsgInfo><endNum>1000</endNum><Msg></Msg>");
            sbs.append("<startNum>1</startNum></MsgInfo></ESBEntry>");
@ -705,14 +746,36 @@ public class EntranceService {
            resp = MqSdkUtil.xml2jsonArrayRootRow(resp);
        }
        JSONArray jsonArray= ConvertUtil.convertListEnvelopInBody(resp);
        List<HospitalDeptMappingDO> hospitalDeptMappingDOS=new ArrayList<>();
        HospitalDeptMappingDO hdmDo;
        List<DictHospitalDeptDO> hospitalDeptMappingDOS=new ArrayList<>();
        DictHospitalDeptDO hdmDo;
        String orgCode="350211A1002";
        Map<String,String> orgCodeMap=new HashMap<>();
        //6总部7金榜8夏禾
        orgCodeMap.put("6",orgCode);
        orgCodeMap.put("7","");
        orgCodeMap.put("8","");
        //删除旧数据
        hospitalDeptMappingDao.deleteBySource("1");
        List<String> strings=new ArrayList<>(orgCodeMap.values()) ;
        for(String s:strings) {
            if(StringUtils.isNotBlank(s)){
                dictHospitalDeptDao.deleteByOrgCode(s);
            }
        }
        for(Object object:jsonArray){
            hdmDo=new HospitalDeptMappingDO();
            hdmDo=new DictHospitalDeptDO();
            net.sf.json.JSONObject jsonObjectBody=(net.sf.json.JSONObject)object;
            hdmDo.setSerialNo(null==jsonObjectBody.get("Serial_No")?"":jsonObjectBody.get("Serial_No").toString());
            String deptTypeCode=null==jsonObjectBody.get("Dept_Type_Code")?"":jsonObjectBody.get("Dept_Type_Code").toString();
            if(StringUtils.isNotBlank(orgCodeMap.get(deptTypeCode))){
                hdmDo.setOrgCode(orgCode);
                hdmDo.setCode(null==jsonObjectBody.get("Dept_Code")?"":jsonObjectBody.get("Dept_Code").toString());
                hdmDo.setName(null==jsonObjectBody.get("Dept_Name")?"":jsonObjectBody.get("Dept_Name").toString());
                hdmDo.setDeptTypeCode(deptTypeCode);
                hdmDo.setCreateTime(new Date());
//                DictHospitalDeptDao.save(hdmDo);
                hospitalDeptMappingDOS.add(hdmDo);
            }
       /*     hdmDo.setSerialNo(null==jsonObjectBody.get("Serial_No")?"":jsonObjectBody.get("Serial_No").toString());
            hdmDo.setDeptCode(null==jsonObjectBody.get("Dept_Code")?"":jsonObjectBody.get("Dept_Code").toString());
            hdmDo.setDeptName(null==jsonObjectBody.get("Dept_Name")?"":jsonObjectBody.get("Dept_Name").toString());
            hdmDo.setDeptAlias(null==jsonObjectBody.get("Dept_Alias")?"":jsonObjectBody.get("Dept_Alias").toString());
@ -725,7 +788,6 @@ public class EntranceService {
            hdmDo.setInputCode(null==jsonObjectBody.get("Input_Code")?"":jsonObjectBody.get("Input_Code").toString());
            hdmDo.setPinyinCode(null==jsonObjectBody.get("Pinyin_Code")?"":jsonObjectBody.get("Pinyin_Code").toString());
            hdmDo.setWubiCode(null==jsonObjectBody.get("Wubi_Code")?"":jsonObjectBody.get("Wubi_Code").toString());
            hdmDo.setDeptTypeCode(null==jsonObjectBody.get("Dept_Type_Code")?"":jsonObjectBody.get("Dept_Type_Code").toString());
            hdmDo.setLocation(null==jsonObjectBody.get("Location")?"":jsonObjectBody.get("Location").toString());
            hdmDo.setDisplaySequence(null==jsonObjectBody.get("Display_Sequence")?"":jsonObjectBody.get("Display_Sequence").toString());
            hdmDo.setOpenBedNum(null==jsonObjectBody.get("Open_Bed_Num")?"":jsonObjectBody.get("Open_Bed_Num").toString());
@ -738,11 +800,11 @@ public class EntranceService {
            hdmDo.setDeptZipCode(null==jsonObjectBody.get("Dept_Zip_Code")?"":jsonObjectBody.get("Dept_Zip_Code").toString());
            hdmDo.setDeDlid(null==jsonObjectBody.get("De_Dlid")?"":jsonObjectBody.get("De_Dlid").toString());
            hdmDo.setDeLcid(null==jsonObjectBody.get("De_Lcid")?"":jsonObjectBody.get("De_Lcid").toString());
            hdmDo.setSource("1");
            hdmDo.setCreateTime(new Date());
            hospitalDeptMappingDOS.add(hdmDo);
            hdmDo.setSource("1");*/
        }
        hospitalDeptMappingDao.save(hospitalDeptMappingDOS);
        dictHospitalDeptDao.save(hospitalDeptMappingDOS);
        return hospitalDeptMappingDOS;
    }
@ -751,22 +813,21 @@ public class EntranceService {
     * @return
     * @throws Exception
     */
    public JSONArray MS02013(boolean demoFlag) throws Exception {
    public net.sf.json.JSONArray MS02013(String code) throws Exception {
        String fid=MS02013;
        String resp="";
        if (demoFlag) {
            resp = getJosnFileResullt(fid);
        } else {
            StringBuffer sbs = new StringBuffer();
            //AccessControl :用户、密码、服务id
            sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>JKZL</UserName><Password>123456</Password></AccessControl>");
            //MessageHeader :固定值 消费方系统编号 S60,提供方系统编号 S01
            sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>S60</SourceSysCode><TargetSysCode>S01</TargetSysCode></MessageHeader>");
            //查询信息拼接
            sbs.append("<MsgInfo><endNum>20000</endNum><Msg/><startNum>1</startNum></MsgInfo></ESBEntry>");
            resp = MqSdkUtil.putReqAndGetRespByQueryStr(sbs.toString(), fid);
            resp = MqSdkUtil.xml2jsonArrayRootRow(resp);
        StringBuffer sbs= new StringBuffer();
        //AccessControl :用户、密码、服务id
        sbs.append("<ESBEntry><AccessControl><Fid>"+fid+"</Fid><UserName>JKZL</UserName><Password>123456</Password></AccessControl>");
        //MessageHeader :固定值 消费方系统编号 S60,提供方系统编号 S01
        sbs.append("<MessageHeader><Fid>"+fid+"</Fid><MsgDate>"+ DateUtil.dateToStr(new Date(),DateUtil.YYYY_MM_DD_HH_MM_SS)+"</MsgDate><SourceSysCode>S60</SourceSysCode><TargetSysCode>S01</TargetSysCode></MessageHeader>");
        //查询信息拼接
        sbs.append("<MsgInfo><endNum>20000</endNum><Msg/>");
        if(StringUtils.isNotBlank(code)){
            sbs.append("<query compy=\"=\" item=\"code\" splice=\"and\" value=\"'"+code+"'\"/>");
        }
        sbs.append("<startNum>1</startNum></MsgInfo></ESBEntry>");
        String resp = MqSdkUtil.putReqAndGetRespByQueryStr(sbs.toString(), fid );
        resp= MqSdkUtil.xml2jsonArrayRootRow(resp);
        return ConvertUtil.convertListEnvelopInBodyRow(resp);
    }
@ -783,9 +844,9 @@ public class EntranceService {
        } else {
            StringBuffer sbs = new StringBuffer();
            //AccessControl :用户、密码、服务id
            sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>JKZL</UserName><Password>123456</Password></AccessControl>");
            sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>"+mqUser+"</UserName><Password>"+mqPwd+"</Password></AccessControl>");
            //MessageHeader :固定值 消费方系统编号 S60,提供方系统编号 S01
            sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>S60</SourceSysCode><TargetSysCode>S01</TargetSysCode></MessageHeader>");
            sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>"+sourceSysCode+"</SourceSysCode><TargetSysCode>"+targetSysCode+"</TargetSysCode></MessageHeader>");
            //查询信息拼接
            sbs.append("<MsgInfo><endNum>20000</endNum><Msg/><startNum>1</startNum></MsgInfo></ESBEntry>");
            resp = MqSdkUtil.putReqAndGetRespByQueryStr(sbs.toString(), fid);
@ -808,9 +869,9 @@ public class EntranceService {
        } else {
            StringBuffer sbs = new StringBuffer();
            //AccessControl :用户、密码、服务id
            sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>JKZL</UserName><Password>123456</Password></AccessControl>");
            sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>"+mqUser+"</UserName><Password>"+mqPwd+"</Password></AccessControl>");
            //MessageHeader :固定值 消费方系统编号 S60,提供方系统编号 S01
            sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>S60</SourceSysCode><TargetSysCode>S01</TargetSysCode></MessageHeader>");
            sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>"+sourceSysCode+"</SourceSysCode><TargetSysCode>"+targetSysCode+"</TargetSysCode></MessageHeader>");
            //查询信息拼接
            sbs.append("<MsgInfo><endNum>1000</endNum><Msg/>");
            if (StringUtils.isNotBlank(py_code)) {
@ -829,13 +890,13 @@ public class EntranceService {
     * @return
     * @throws Exception
     */
    public String MS25002(String py_code,String win_no) throws Exception {
    public JSONArray MS25002(String py_code,String win_no) throws Exception {
        String fid="MS25002";
        StringBuffer sbs= new StringBuffer();
        //AccessControl :用户、密码、服务id
        sbs.append("<ESBEntry><AccessControl><Fid>"+fid+"</Fid><UserName>JKZL</UserName><Password>123456</Password></AccessControl>");
        sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>"+mqUser+"</UserName><Password>"+mqPwd+"</Password></AccessControl>");
        //MessageHeader :固定值 消费方系统编号 S60,提供方系统编号 S01
        sbs.append("<MessageHeader><Fid>"+fid+"</Fid><MsgDate>"+ DateUtil.dateToStr(new Date(),DateUtil.YYYY_MM_DD_HH_MM_SS)+"</MsgDate><SourceSysCode>S60</SourceSysCode><TargetSysCode>S01</TargetSysCode></MessageHeader>");
        sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>"+sourceSysCode+"</SourceSysCode><TargetSysCode>"+targetSysCode+"</TargetSysCode></MessageHeader>");
        //查询信息拼接
        sbs.append("<MsgInfo><endNum>1000</endNum><Msg/>");
        if(StringUtils.isNotBlank(py_code)){
@ -850,7 +911,7 @@ public class EntranceService {
        // <MsgInfo><endNum>20000</endNum><Msg></Msg><startNum>1</startNum></MsgInfo></ESBEntry>
        String resp = MqSdkUtil.putReqAndGetRespByQueryStr(sbs.toString(), fid );
        resp= MqSdkUtil.xml2jsonArrayRootRow(resp);
        return resp;
        return  ConvertUtil.convertListEnvelopInBodyRow(resp);
    }
    /**
@ -915,9 +976,9 @@ public class EntranceService {
            resp = getJosnFileResullt(fid);
        } else {
            //AccessControl :用户、密码、服务id
            sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>JKZL</UserName><Password>123456</Password></AccessControl>");
            sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>"+mqUser+"</UserName><Password>"+mqPwd+"</Password></AccessControl>");
            //MessageHeader :固定值 消费方系统编号 S60,提供方系统编号 S01
            sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>S60</SourceSysCode><TargetSysCode>S01</TargetSysCode></MessageHeader>");
            sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>"+sourceSysCode+"</SourceSysCode><TargetSysCode>"+targetSysCode+"</TargetSysCode></MessageHeader>");
            //查询信息拼接
            sbs.append("<MsgInfo><onceFlag>1</onceFlag><startNum>1</startNum><endNum>50000</endNum><Msg/>");
            if (StringUtils.isNotBlank(patNo)) {
@ -993,9 +1054,9 @@ public class EntranceService {
        } else {
            StringBuffer sbs = new StringBuffer();
            //AccessControl :用户、密码、服务id
            sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>JKZL</UserName><Password>123456</Password></AccessControl>");
            sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>"+mqUser+"</UserName><Password>"+mqPwd+"</Password></AccessControl>");
            //MessageHeader :固定值 消费方系统编号 S60,提供方系统编号 S01
            sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>S60</SourceSysCode><TargetSysCode>S01</TargetSysCode></MessageHeader>");
            sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>"+sourceSysCode+"</SourceSysCode><TargetSysCode>"+targetSysCode+"</TargetSysCode></MessageHeader>");
            //查询信息拼接
            sbs.append("<MsgInfo><endNum>1000</endNum><Msg/>");
            if (StringUtils.isNotBlank(patNo)) {
@ -1005,17 +1066,241 @@ public class EntranceService {
                sbs.append("<query compy=\"=\" item=\"times\" splice=\"and\" value=\"'" + conNo + "'\"/>");
            }
             sbs.append("<order item=\"apply_date\" sort=\"desc\"/>");
            //<ESBEntry><AccessControl><Fid>BS25017</Fid><UserName>JKZL</UserName><Password>123456</Password></AccessControl>
            // <MessageHeader><Fid>BS25017</Fid><MsgDate>2019-06-03 13:52:39</MsgDate><SourceSysCode>S47</SourceSysCode><TargetSysCode>S01</TargetSysCode></MessageHeader>
            // <MsgInfo><endNum>20000</endNum><Msg/>
            // <query compy="=" item="inpatient_no" splice="and" value="'P10728535-0'"/>
            // <query compy="=" item="times" splice="and" value="'62'"/>
            // <order item="apply_date" sort="desc"/><startNum>1</startNum></MsgInfo></ESBEntry>
            sbs.append("<startNum>1</startNum></MsgInfo></ESBEntry>");
            resp = MqSdkUtil.putReqAndGetRespByQueryStr(sbs.toString(), fid);
            resp = MqSdkUtil.xml2jsonArrayRootRow(resp);
        }
        return ConvertUtil.convertListEnvelopInBodyRow(resp);
    }
    /**
     * 检验送检信息查询
     * @param patNo 患者唯一号 必传参数
     * @param conNo 就诊次数 必传参数
     * @param demoFlag 是否获取测试数据
     * @return
     * @throws Exception
     */
    public JSONArray BS20010(String patNo,String  conNo,boolean demoFlag) throws Exception {
        String fid="BS20010";
        String resp="";
        if (demoFlag) {
            resp = getJosnFileResullt(fid);
        } else {
            StringBuffer sbs = new StringBuffer();
            //AccessControl :用户、密码、服务id
            sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>"+mqUser+"</UserName><Password>"+mqPwd+"</Password></AccessControl>");
            //MessageHeader :固定值 消费方系统编号 S60,提供方系统编号 S01
            sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>"+sourceSysCode+"</SourceSysCode><TargetSysCode>"+targetSysCode+"</TargetSysCode></MessageHeader>");
            //查询信息拼接
            sbs.append("<MsgInfo><endNum>1000</endNum><Msg/>");
            if (StringUtils.isNotBlank(patNo)) {
                sbs.append("<query compy=\"=\" item=\"CureNo\" splice=\"and\" value=\"'" + patNo + "'\"/>");
            }
            if (StringUtils.isNotBlank(conNo)) {
                sbs.append("<query compy=\"=\" item=\"patientid\" splice=\"and\" value=\"'" + conNo + "'\"/>");
            }
            sbs.append("<order item=\"receiveTime\" sort=\"desc\"/>");
            sbs.append("<startNum>1</startNum></MsgInfo></ESBEntry>");
            resp = MqSdkUtil.putReqAndGetRespByQueryStr(sbs.toString(), fid);
            resp = MqSdkUtil.xml2jsonArrayRootRow(resp);
        }
        return ConvertUtil.convertListEnvelopInBodyRow(resp);
    }
    /**
     *检验的是通过BS20010先查出applyno 这个,然后去查BS20019
     * @param patNo 居民唯一号 必传参数
     * @param conNo 就诊次数 必传次数
     * @param demoFlag 是否获取本地示例数据 true 是,false 否
     * @return
     * @throws Exception
     */
    public JSONArray BS20019(String patNo,String  conNo,boolean demoFlag) throws Exception {
        String fid="BS20019";
        String resp="";
        net.sf.json.JSONArray jsonArrayLast=new net.sf.json.JSONArray();
        if (demoFlag) {
            resp = getJosnFileResullt(fid);
            net.sf.json.JSONArray jsonArray1= ConvertUtil.convertListEnvelopInBodyRow(resp);
            jsonArrayLast.add(jsonArray1);
        } else {
            //获取检验送检记录
            JSONArray jsonArray= BS20010(patNo,conNo,demoFlag);
            for(Object object:jsonArray){
                net.sf.json.JSONObject jsonObjectBody=(net.sf.json.JSONObject)object;
                if(null!=jsonObjectBody){
                    String applyno=null==jsonObjectBody.get("applyno")?"":jsonObjectBody.get("applyno").toString();
                    if(StringUtils.isNotBlank(applyno)){
                        StringBuffer sbs = new StringBuffer();
                        //AccessControl :用户、密码、服务id
                        sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>"+mqUser+"</UserName><Password>"+mqPwd+"</Password></AccessControl>");
                        //MessageHeader :固定值 消费方系统编号 S60,提供方系统编号 S01
                        sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>"+sourceSysCode+"</SourceSysCode><TargetSysCode>"+targetSysCode+"</TargetSysCode></MessageHeader>");
                        //查询信息拼接
                        sbs.append("<RequestOption><onceFlag>0</onceFlag></RequestOption><MsgInfo><startNum>1</startNum><endNum>20000</endNum><Msg/>");
                        if (StringUtils.isNotBlank(applyno)) {
                            sbs.append("<query compy=\"=\" item=\"applyno\" splice=\"and\" value=\"'" + applyno + "'\"/>");
                        }
                        sbs.append("<order item=\"ResultTime\" sort=\"desc\"/>");
                        sbs.append("</MsgInfo></ESBEntry>");
                        resp = MqSdkUtil.putReqAndGetRespByQueryStr(sbs.toString(), fid);
                        resp = MqSdkUtil.xml2jsonArrayRootRow(resp);
                        net.sf.json.JSONArray jsonArray1= ConvertUtil.convertListEnvelopInBodyRow(resp);
                        jsonArrayLast.add(jsonArray1);
                    }
                }
            }
        }
        return jsonArrayLast;
    }
    /**
     *微生物的是先查BS20018,也是查出applyno 再去查BS20011
     * @param patNo 居民唯一号 必传参数
     * @param conNo 就诊次数 必传次数
     * @param demoFlag 是否获取本地示例数据 true 是,false 否
     * @return
     * @throws Exception
     */
    public JSONArray BS20011(String patNo,String  conNo,boolean demoFlag) throws Exception {
        String fid="BS20011";
        String resp="";
        net.sf.json.JSONArray jsonArrayLast=new net.sf.json.JSONArray();
        if (demoFlag) {
            resp = getJosnFileResullt(fid);
            net.sf.json.JSONArray jsonArray1= ConvertUtil.convertListEnvelopInBodyRow(resp);
            jsonArrayLast.add(jsonArray1);
        } else {
            //获取微生物送检记录
            JSONArray jsonArray= BS20018(patNo,conNo,demoFlag);
            for(Object object:jsonArray){
                net.sf.json.JSONObject jsonObjectBody=(net.sf.json.JSONObject)object;
                jsonObjectBody= (net.sf.json.JSONObject)jsonObjectBody.get("body");
                jsonObjectBody=null==jsonObjectBody?jsonObjectBody:(net.sf.json.JSONObject)jsonObjectBody.get("row");
                if(null!=jsonObjectBody){
                    String applyno=null==jsonObjectBody.get("applyno")?"":jsonObjectBody.get("applyno").toString();
                    if(StringUtils.isNotBlank(applyno)){
                        StringBuffer sbs = new StringBuffer();
                        //AccessControl :用户、密码、服务id
                        sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>"+mqUser+"</UserName><Password>"+mqPwd+"</Password></AccessControl>");
                        //MessageHeader :固定值 消费方系统编号 S60,提供方系统编号 S01
                        sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>"+sourceSysCode+"</SourceSysCode><TargetSysCode>"+targetSysCode+"</TargetSysCode></MessageHeader>");
                        //查询信息拼接
                        sbs.append("<MsgInfo><endNum>20000</endNum><Msg/>");
                        if (StringUtils.isNotBlank(applyno)) {
                            sbs.append("<query compy=\"=\" item=\"applyno\" splice=\"and\" value=\"'" + applyno + "'\"/>");
                        }
                        sbs.append("<startNum>1</startNum></MsgInfo></ESBEntry>");
                        resp = MqSdkUtil.putReqAndGetRespByQueryStr(sbs.toString(), fid);
                        resp = MqSdkUtil.xml2jsonArrayRootRow(resp);
                        net.sf.json.JSONArray jsonArray1= ConvertUtil.convertListEnvelopInBodyRow(resp);
                        jsonArrayLast.add(jsonArray1);
                    }
                }
            }
        }
        return jsonArrayLast;
    }
    /**
     * 获取微生物检查记录
     * @param patNo 居民唯一号 必传
     * @param conNo 就诊次数 必传
     * @param demoFlag
     * @return
     * @throws Exception
     */
    public JSONArray BS20018(String patNo,String  conNo,boolean demoFlag) throws Exception {
        String fid="BS20018";
        String resp="";
        if (demoFlag) {
            resp = getJosnFileResullt(fid);
        } else {
            StringBuffer sbs = new StringBuffer();
            //AccessControl :用户、密码、服务id
            sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>"+mqUser+"</UserName><Password>"+mqPwd+"</Password></AccessControl>");
            //MessageHeader :固定值 消费方系统编号 S60,提供方系统编号 S01
            sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>"+sourceSysCode+"</SourceSysCode><TargetSysCode>"+targetSysCode+"</TargetSysCode></MessageHeader>");
            //查询信息拼接
            sbs.append("<MsgInfo><endNum>20000</endNum><Msg/>");
            if (StringUtils.isNotBlank(patNo)) {
                sbs.append("<query compy=\"=\" item=\"CureNo\" splice=\"and\" value=\"'" + patNo + "'\"/>");
            }
            if (StringUtils.isNotBlank(conNo)) {
                sbs.append("<query compy=\"=\" item=\"patientid\" splice=\"and\" value=\"'" + conNo + "'\"/>");
            }
            sbs.append("<order item=\"receiveTime\" sort=\"desc\"/>");
            sbs.append("<startNum>1</startNum></MsgInfo></ESBEntry>");
            resp = MqSdkUtil.putReqAndGetRespByQueryStr(sbs.toString(), fid);
            resp = MqSdkUtil.xml2jsonArrayRootRow(resp);
        }
        return ConvertUtil.convertListEnvelopInBodyRow(resp);
    }
    public List<WlyyChargeDictDO> BS55010(String windowsNo,String code,String chargeType,boolean demoFlag) throws Exception {
        String fid="BS55010";
        String resp="";
        Map<String,Object> map=new HashMap<>();
        List<WlyyChargeDictDO> wlyyChargeDictDOS=new ArrayList<>();
        if (demoFlag) {
            resp = getJosnFileResullt(fid);
        } else {
            StringBuffer sbs = new StringBuffer();
            //AccessControl :用户、密码、服务id
            sbs.append("<ESBEntry><AccessControl><Fid>" + fid + "</Fid><UserName>"+mqUser+"</UserName><Password>"+mqPwd+"</Password></AccessControl>");
            //MessageHeader :固定值 消费方系统编号 S60,提供方系统编号 S01
            sbs.append("<MessageHeader><Fid>" + fid + "</Fid><MsgDate>" + DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD_HH_MM_SS) + "</MsgDate><SourceSysCode>"+sourceSysCode+"</SourceSysCode><TargetSysCode>"+targetSysCode+"</TargetSysCode></MessageHeader>");
            //查询信息拼接
            sbs.append("<MsgInfo><endNum>20000</endNum><Msg/>");
            if (StringUtils.isNotBlank(windowsNo)) {
                sbs.append("<query compy=\"=\" item=\"windows_no\" splice=\"and\" value=\"'"+windowsNo+"'\"/>");
            }
            if (StringUtils.isNotBlank(chargeType)) {
                sbs.append("<query compy=\"=\" item=\"charge_type\" splice=\"and\" value=\"'"+chargeType+"'\"/>");
            }
            if (StringUtils.isNotBlank(code)) {
                sbs.append("<query compy=\"=\" item=\"code\" splice=\"and\" value=\"'"+code+"'\"/>");
            }
            sbs.append("<startNum>1</startNum></MsgInfo></ESBEntry>");
            resp = MqSdkUtil.putReqAndGetRespByQueryStr(sbs.toString(), fid);
            resp = MqSdkUtil.xml2jsonArrayRootRow(resp);
        }
        net.sf.json.JSONArray jsonArray= ConvertUtil.convertListEnvelopInBodyRow(resp);
        for(Object object:jsonArray){
            net.sf.json.JSONObject jsonObjectBody=(net.sf.json.JSONObject)object;
            String chareName="";
            if(null!=jsonObjectBody){
                String chareCode=null==jsonObjectBody.get("charge_type")?"":jsonObjectBody.get("charge_type").toString();
                String winNo=null==jsonObjectBody.get("windows_no")?"":jsonObjectBody.get("windows_no").toString();
                //WlyyChargeDictDO
                if(!map.containsKey(chareCode+"_"+winNo)){
                    //查询号别
                    net.sf.json.JSONArray chares= MS02013(chareCode);
                    for(Object object1:chares) {
                        net.sf.json.JSONObject jsonObjectBody1 = (net.sf.json.JSONObject) object1;
                        chareName=null==jsonObjectBody1.get("name")?"":jsonObjectBody1.get("name").toString();
                        System.out.println(chareCode+chareName);
                        WlyyChargeDictDO wlyyChargeDictDO=new WlyyChargeDictDO();
                        wlyyChargeDictDO.setChargeType(chareCode);
                        wlyyChargeDictDO.setChargeName(chareName);
                        wlyyChargeDictDO.setDeptTypeCode(winNo);
                        Double free=null==jsonObjectBody.get("req_fee")?0:Double.parseDouble(jsonObjectBody.get("req_fee").toString());
                        wlyyChargeDictDO.setReqFee(free);
                        wlyyChargeDictDO.setCreateTime(new Date());
                        map.put(chareCode+"_"+winNo,chareName);
                        wlyyChargeDictDO=wlyyChargeDictDao.save(wlyyChargeDictDO);
                        wlyyChargeDictDOS.add(wlyyChargeDictDO);
                    }
                }
            }
        }
        return wlyyChargeDictDOS;
    }
}

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

@ -0,0 +1,301 @@
package com.yihu.jw.hospital.prescription.service.entrance.util;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionExpressageDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionInfoDO;
import com.yihu.jw.hospital.prescription.dao.PrescriptionInfoDao;
import com.yihu.jw.hospital.prescription.service.PrescriptionService;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import sun.misc.BASE64Encoder;
import java.io.FileInputStream;
import java.io.InputStream;
import java.security.MessageDigest;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
 * 顺丰速递接口相关的一些公用方法
 * @author huangwenjie 2017.8.2
 */
@Component
public class SFUtils {
    private static Logger logger = LoggerFactory.getLogger(SFUtils.class);
    @Autowired
    private PrescriptionService prescriptionService;
    @Autowired
    private PrescriptionInfoDao prescriptionInfoDao;
    /**
     * 生成接口校验码
     * 1.先把XML报文与checkword前后连接。
     * 2.把连接后的字符串做 MD5(16位) 编码。
     * 3.把MD5编码后的数据进行 Base64 编码,此时编码后的字符串即为校验码。
     * @param xml   xml报文
     * @param sf_check_word  接口check_word
     * @return
     */
    public String verifyCodeSFXmlStr(String xml,String sf_check_word){
        String verifyCode = xml+sf_check_word;
        verifyCode = md5EncryptAndBase64(verifyCode);
        return verifyCode;
    }
    /**
     * 查询派送地址是否属于顺丰的派送范围
     * @param d_address     派送地址
     * @param sf_code       顺丰接口接入码
     * @param orderid       订单ID
     * @param j_tel         寄方电话
     * @param j_address     寄方地址
     * @param d_tel         收方电话
     * @return
     */
    public String getSFOrderFilterXml(String d_address,String sf_code,String orderid,String j_tel,String j_address,String d_tel){
        //head 传入接口接入码
        StringBuilder xml = new StringBuilder("<Request service='OrderFilterService' lang='zh-cn'><Head>"+sf_code+"</Head><Body>");
        xml.append("<OrderFilter filter_type='1' ");
        //订单号
        if(StringUtils.isNotBlank(orderid)){
            xml.append("orderid='"+orderid+"' ");
        }
        //派送地址,必填
        xml.append("d_address='"+d_address+"'/>");
        //如果扩张字段有不为空的,则增加扩张字段参数
        if(StringUtils.isNotBlank(j_tel) ||
                StringUtils.isNotBlank(j_address)||
                    StringUtils.isNotBlank(d_tel)){
            xml.append("<OrderFilterOption ");
            //寄方电话
            if(StringUtils.isNotBlank(j_tel)){
                xml.append("j_tel='"+j_tel+"' ");
            }
            //寄方地址
            if(StringUtils.isNotBlank(j_address)){
                xml.append("j_address='"+j_address+"' ");
            }
            //收方电话
            if(StringUtils.isNotBlank(d_tel)){
                xml.append("d_tel='"+d_tel+"' ");
            }
            xml.append("/></OrderFilter>");
        }
        xml.append("</Body></Request>");
        return xml.toString();
    }
    /**
     * 向顺丰快递下订单
     * @param sfexpress_obj
     * @param hospital
     * @return
     */
    public String postSFOrderService(WlyyPrescriptionExpressageDO sfexpress_obj, BaseOrgDO hospital, String sf_code) {
        //head 传入接口接入码
        StringBuilder xml = new StringBuilder("<Request service='OrderService' lang='zh-cn'><Head>"+sf_code+"</Head><Body>");
        xml.append("<Order ");
        //订单号(快递业务号作为订单号"SF开头的为顺丰快递")
        xml.append("orderid='"+sfexpress_obj.getId()+"' ");
        /**
         * --------寄方参数------
         */
        //寄件方公司名称
        if(StringUtils.isNotBlank(hospital.getName())){
            xml.append("j_company='"+hospital.getName()+"' ");
        }
        //寄方联系人
        if(StringUtils.isNotBlank(hospital.getName())){
            xml.append("j_contact='"+hospital.getName()+"' ");
        }
        //寄件方联系电话
        if(StringUtils.isNotBlank(hospital.getMobile())){
            xml.append("j_tel='"+hospital.getMobile()+"' ");
            xml.append("j_mobile='"+hospital.getMobile()+"' ");
        }
        //寄方所在省份
        if(StringUtils.isNotBlank(hospital.getProvinceName())){
            xml.append("j_province='"+hospital.getProvinceName()+"' ");
        }
        //寄方所在城市
        if(StringUtils.isNotBlank(hospital.getCityName())){
            xml.append("j_city='"+hospital.getCityName()+"' ");
        }
        //寄方所在县/区
        if(StringUtils.isNotBlank(hospital.getTownName())){
            xml.append("j_county='"+hospital.getTownName()+"' ");
        }
        //寄件方详细地址,包括省市县/区
        if(StringUtils.isNotBlank(hospital.getAddress())){
            xml.append("j_address='"+hospital.getAddress()+"' ");
        }
        /**
         * --------收方参数------
         */
        //派送地址,必填
        xml.append("d_address='"+sfexpress_obj.getAddress()+"' ");
        //到件方单位名称,因为接口不能为空,这里默认放到件方联系人
        xml.append("d_company='"+sfexpress_obj.getName()+"' ");
        //到件方联系人
        xml.append("d_contact='"+sfexpress_obj.getName()+"' ");
        //到件方联系电话
        xml.append("d_tel='"+sfexpress_obj.getPhone()+"' ");
        //到件方手机
        if(StringUtils.isNotBlank(sfexpress_obj.getMobile())){
            xml.append("d_mobile='"+sfexpress_obj.getMobile()+"' ");
        }
        xml.append("d_province='"+sfexpress_obj.getProvinceName()+"' ");
        xml.append("d_city='"+sfexpress_obj.getCityName()+"' ");
        xml.append("d_county='"+sfexpress_obj.getTownName()+"' ");
        //是否要求通过是否手持终端;通知顺丰收派员收件:1:要求,其它为不要求
        xml.append("is_docall='1' ");
        //快件产品类别:11,医药常温,1:顺丰标快
        //付款方式:1:寄方付,2:收方付 3:第三方付
        xml.append("express_type='1' pay_method='2' >");
//        xml.append("express_type='11' pay_method='1' custid='9999999999'>");
        //根据快递物流获取门诊信息,根据门诊信息获取处方订单的药品详情
        List<WlyyPrescriptionDO> prescriptionDOList = prescriptionService.findByField("outpatientId",sfexpress_obj.getOutpatientId());
        if(CollectionUtils.isEmpty(prescriptionDOList)){
        }
        Set<String> prescriptionIdSet = new HashSet<>();
        prescriptionDOList.forEach(
               onePrescription -> {
                   prescriptionIdSet.add(onePrescription.getId());
                }
        );
        List<WlyyPrescriptionInfoDO> prescriptionInfolist = prescriptionInfoDao.queryAllByPrescriptionIdInAndDel(prescriptionIdSet,1);
        if(!prescriptionInfolist.isEmpty()){
            for (int i = 0; i < prescriptionInfolist.size(); i++) {
                xml.append("<Cargo name='"+prescriptionInfolist.get(i).getDrugName()+"' count='"+prescriptionInfolist.get(i).getQuantity()+"'></Cargo>");
            }
        }
        xml.append("</Order></Request>");
        return xml.toString();
    }
    /**
     * 订单确认/取消
     * @param sf_code
     * @param orderid
     * @param mailno
     * @param dealtype
     * @return
     */
    public String SFOrderConfirmXml(String sf_code,String orderid ,String mailno,int dealtype){
        //head 传入接口接入码
        StringBuilder xml = new StringBuilder("<Request service='OrderConfirmService' lang='zh-cn'><Head>"+sf_code+"</Head><Body>");
        xml.append("<OrderConfirm ");
        //订单号
        if(StringUtils.isNotBlank(orderid)){
            xml.append("orderid='"+orderid+"' ");
        }
        //派送订单号,必填
        xml.append("mailno='" + mailno + "'/> ");
        xml.append("dealtype='" + dealtype + "'/>");
        xml.append("/></OrderConfirm>");
        xml.append("</Body></Request>");
        return xml.toString();
    }
    /**
     * 顺丰路由查询
     * @param sfexpress_obj
     * @param sf_code
     * @return
     */
    public String getRoutInfos(WlyyPrescriptionExpressageDO sfexpress_obj, String sf_code) {
        //head 传入接口接入码
        StringBuilder xml = new StringBuilder("<Request service='RouteService' lang='zh-cn'><Head>"+sf_code+"</Head><Body>");
        xml.append("<RouteRequest tracking_type='1' method_type='1' ").append("tracking_number='"+sfexpress_obj.getMailno()+"' />");
        xml.append("</Body></Request>");
        return xml.toString();
    }
    /**
     * 订单结果查询接口
     * @param sfexpress_objCode
     * @param sf_code
     * @return
     */
    public String sfOrderSearchService(String sfexpress_objCode, String sf_code) {
        StringBuilder xml = new StringBuilder("<Request service='OrderSearchService' lang='zh-cn'><Head>"+sf_code+"</Head><Body>");
        xml.append("<OrderSearch orderid='"+sfexpress_objCode+"'/>");
        xml.append("</Body></Request>");
        return xml.toString();
    }
    //-----------顺丰快递验证码加密的相关方法------------------START
    public static String loadFile(String fileName) {
        InputStream fis;
        try {
            fis = new FileInputStream(fileName);
            byte[] bs = new byte[fis.available()];
            fis.read(bs);
            String res = new String(bs);
            fis.close();
            return res;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    public static String md5EncryptAndBase64(String str) {
        return encodeBase64(md5Encrypt(str));
    }
    private static byte[] md5Encrypt(String encryptStr) {
        try {
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            md5.update(encryptStr.getBytes("utf8"));
            return md5.digest();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    private static String encodeBase64(byte[] b) {
        BASE64Encoder base64Encode = new BASE64Encoder();
        String str = base64Encode.encode(b);
        return str;
    }
    public static void main(String[] args) {
        String xml = "<Request service='OrderSearchService' lang='zh-cn'><Head>SDDF</Head><Body><OrderSearch orderid='6daa6baec5fd4b65a1b023a8b60e2e76'/></Body></Request>";
        String check_word = "ttzlgGyOQu4L";
        System.out.println(md5EncryptAndBase64(xml + check_word));
//        System.out.println(md5EncryptAndBase64("abc"));
//        System.out.println(md5EncryptAndBase64("中"));
    }
    //-----------顺丰快递验证码加密的相关方法------------------END
}

+ 20 - 0
business/base-service/src/main/java/com/yihu/jw/utils/EntityUtils.java

@ -0,0 +1,20 @@
package com.yihu.jw.utils;
import com.fasterxml.jackson.databind.ObjectMapper;
public class EntityUtils {
    protected static ObjectMapper objectMapper = new ObjectMapper();
    public static <T> T jsonToEntity(String json,Class<T> target){
        T entity = null;
        try {
            entity  = objectMapper.readValue(json,target);
        } catch (Exception e) {
           throw new RuntimeException("Json字符串转换成【"+target.getName()+"】实体类异常:" + e.getMessage());
        }
        return entity;
    }
}

+ 10 - 0
business/base-service/src/mqConfig/esbmq-config.xml

@ -47,6 +47,16 @@
				<MS25002_1>EwellQ.S60.MS25002.GET</MS25002_1>
				<BS25017_0>EwellQ.S60.BS25017.PUT</BS25017_0>
				<BS25017_1>EwellQ.S60.BS25017.GET</BS25017_1>
				<BS20010_0>EwellQ.S60.BS20010.PUT</BS20010_0>
				<BS20010_1>EwellQ.S60.BS20010.GET</BS20010_1>
				<BS20019_0>EwellQ.S60.BS20019.PUT</BS20019_0>
				<BS20019_1>EwellQ.S60.BS20019.GET</BS20019_1>
				<BS20018_0>EwellQ.S60.BS20018.PUT</BS20018_0>
				<BS20018_1>EwellQ.S60.BS20018.GET</BS20018_1>
				<BS20011_0>EwellQ.S60.BS20011.PUT</BS20011_0>
				<BS20011_1>EwellQ.S60.BS20011.GET</BS20011_1>
				<BS55010_0>EwellQ.S60.BS55010.PUT</BS55010_0>
				<BS55010_1>EwellQ.S60.BS55010.GET</BS55010_1>
			</QUEUES>
		</QMGR.S60>
	</MQCONFIG>

+ 1 - 1
business/base-service/src/mqConfig/mqdata/BS10111.json

@ -1 +1 @@
{"code":"1","MsgInfo":[{"resquest":{"@RESULT":"0","@MSG":"完成","@serial_no":"47147412"}}]}
{"code":"1","MsgInfo":[{"resquest":{"@RESULT":"0","@MSG":"完成","@serial_no":"47310714","@times":"66"}}]}

+ 16 - 8
business/base-service/src/mqConfig/mqdata/BS16017.json

@ -48,7 +48,8 @@
				"diag_five": [],
				"real_order": "401934082",
				"drug_win": "1",
				"frequency": "无组"
				"frequency": "无组",
				"SETTLE_FLAG": "1"
			}
		}
	},
@ -100,7 +101,8 @@
					"diag_five": [],
					"real_order": "401934082",
					"drug_win": "1",
					"frequency": "无组"
					"frequency": "无组",
					"SETTLE_FLAG": "1"
				}
			}
		},
@ -152,7 +154,8 @@
					"diag_five": [],
					"real_order": "401934081",
					"drug_win": "1",
					"frequency": "无组"
					"frequency": "无组",
					"SETTLE_FLAG": "1"
				}
			}
		},
@ -204,7 +207,8 @@
					"diag_five": [],
					"real_order": "401934082",
					"drug_win": "1",
					"frequency": "无组"
					"frequency": "无组",
					"SETTLE_FLAG": "1"
				}
			}
		},
@ -256,7 +260,8 @@
					"diag_five": [],
					"real_order": "401934082",
					"drug_win": "1",
					"frequency": "无组"
					"frequency": "无组",
					"SETTLE_FLAG": "1"
				}
			}
		},
@ -308,7 +313,8 @@
					"diag_five": [],
					"real_order": "401934082",
					"drug_win": "1",
					"frequency": "无组"
					"frequency": "无组",
					"SETTLE_FLAG": "1"
				}
			}
		},
@ -360,7 +366,8 @@
					"diag_five": [],
					"real_order": "401934082",
					"drug_win": "1",
					"frequency": "无组"
					"frequency": "无组",
					"SETTLE_FLAG": "1"
				}
			}
		},
@ -412,7 +419,8 @@
					"diag_five": [],
					"real_order": "401934082",
					"drug_win": "1",
					"frequency": "无组"
					"frequency": "无组",
					"SETTLE_FLAG": "1"
				}
			}
		}]

+ 14 - 7
business/base-service/src/mqConfig/mqdata/BS16017_03.json

@ -48,7 +48,8 @@
				"diag_five": [],
				"real_order": "401934082",
				"drug_win": "1",
				"frequency": "无组"
				"frequency": "无组",
				"SETTLE_FLAG": "1"
			}
		}
	},
@ -100,7 +101,8 @@
				"diag_five": [],
				"real_order": "401934082",
				"drug_win": "1",
				"frequency": "无组"
				"frequency": "无组",
				"SETTLE_FLAG": "1"
			}
		}
	},
@ -152,7 +154,8 @@
				"diag_five": [],
				"real_order": "401934082",
				"drug_win": "1",
				"frequency": "无组"
				"frequency": "无组",
				"SETTLE_FLAG": "1"
			}
		}
	},
@ -204,7 +207,8 @@
				"diag_five": [],
				"real_order": "401934082",
				"drug_win": "1",
				"frequency": "无组"
				"frequency": "无组",
				"SETTLE_FLAG": "1"
			}
		}
	},
@ -256,7 +260,8 @@
				"diag_five": [],
				"real_order": "401934082",
				"drug_win": "1",
				"frequency": "无组"
				"frequency": "无组",
				"SETTLE_FLAG": "1"
			}
		}
	},
@ -308,7 +313,8 @@
				"diag_five": [],
				"real_order": "401934082",
				"drug_win": "1",
				"frequency": "无组"
				"frequency": "无组",
				"SETTLE_FLAG": "1"
			}
		}
	},
@ -360,7 +366,8 @@
				"diag_five": [],
				"real_order": "401934082",
				"drug_win": "1",
				"frequency": "无组"
				"frequency": "无组",
				"SETTLE_FLAG": "1"
			}
		}
	}]

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1 - 0
business/base-service/src/mqConfig/mqdata/BS20011.json


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1 - 0
business/base-service/src/mqConfig/mqdata/BS20019.json


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1 - 0
business/base-service/src/mqConfig/mqdata/BS25017.json


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1 - 0
business/base-service/src/mqConfig/mqdata/BS55010.json


+ 14 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/DictHospitalDeptDO.java

@ -2,6 +2,8 @@ package com.yihu.jw.entity.base.dict;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IntegerIdentityEntity;
import org.springframework.beans.factory.annotation.Autowired;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
@ -39,6 +41,11 @@ public class DictHospitalDeptDO extends IntegerIdentityEntity {
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	private Date createTime;
    /**
     * 6总部7金榜8夏禾
     */
    private String deptTypeCode;
	@Column(name = "org_code")
    public String getOrgCode() {
@ -72,6 +79,12 @@ public class DictHospitalDeptDO extends IntegerIdentityEntity {
        this.createTime = createTime;
    }
    @Column(name = "dept_type_code")
    public String getDeptTypeCode() {
        return deptTypeCode;
    }
    public void setDeptTypeCode(String deptTypeCode) {
        this.deptTypeCode = deptTypeCode;
    }
}

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

@ -105,6 +105,12 @@ public class BaseOrgDO extends UuidIdentityEntityWithOperator {
	 */
	private String photo;
   /**
	 * 机构联系电话
	 */
	private String mobile;
    /**
	 * 经度
	 */
@ -152,6 +158,11 @@ public class BaseOrgDO extends UuidIdentityEntityWithOperator {
     */
    private Integer level;
    /**
     * 机构分部号,每个机构都不一样,例如中山医院:6总部7金榜8夏禾
     */
    private String winNo;
    public BaseOrgDO() {
    }
@ -303,7 +314,16 @@ public class BaseOrgDO extends UuidIdentityEntityWithOperator {
        this.photo = photo;
    }
	@Column(name = "longitude")
    @Column(name = "mobile")
    public String getMobile() {
        return mobile;
    }
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }
    @Column(name = "longitude")
    public String getLongitude() {
        return longitude;
    }
@ -375,4 +395,13 @@ public class BaseOrgDO extends UuidIdentityEntityWithOperator {
    public void setLevel(Integer level) {
        this.level = level;
    }
    @Column(name = "win_no")
    public String getWinNo() {
        return winNo;
    }
    public void setWinNo(String winNo) {
        this.winNo = winNo;
    }
}

+ 59 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientDO.java

@ -13,7 +13,6 @@ import java.util.Date;
 * 居民信息(居民就是患者)实体
 *
 * @author Administrator on  2018年09月05日
 *
 */
@Entity
@Table(name = "base_patient")
@ -181,6 +180,18 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
     */
    private String openid;
    /**
     * i健康微信编号
     */
    private String ihealthOpenid;
    /**
     * i健康微信编号添加时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    private Date ihealthOpenidTime;
    /**
     * 用户状态:1正常,0禁用,-1恶意注册,2审核中
     */
@ -252,6 +263,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
@ -260,6 +272,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
@ -268,6 +281,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
@ -276,6 +290,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public String getSalt() {
        return salt;
    }
    public void setSalt(String salt) {
        this.salt = salt;
    }
@ -284,6 +299,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
@ -292,6 +308,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public Date getBirthday() {
        return birthday;
    }
    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }
@ -300,6 +317,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public Integer getSex() {
        return sex;
    }
    public void setSex(Integer sex) {
        this.sex = sex;
    }
@ -308,6 +326,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public String getMobile() {
        return mobile;
    }
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }
@ -316,6 +335,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public String getPhoto() {
        return photo;
    }
    public void setPhoto(String photo) {
        this.photo = photo;
    }
@ -324,6 +344,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public String getProvinceCode() {
        return provinceCode;
    }
    public void setProvinceCode(String provinceCode) {
        this.provinceCode = provinceCode;
    }
@ -332,6 +353,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public String getProvinceName() {
        return provinceName;
    }
    public void setProvinceName(String provinceName) {
        this.provinceName = provinceName;
    }
@ -340,6 +362,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public String getCityCode() {
        return cityCode;
    }
    public void setCityCode(String cityCode) {
        this.cityCode = cityCode;
    }
@ -348,6 +371,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public String getCityName() {
        return cityName;
    }
    public void setCityName(String cityName) {
        this.cityName = cityName;
    }
@ -356,6 +380,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public String getTownCode() {
        return townCode;
    }
    public void setTownCode(String townCode) {
        this.townCode = townCode;
    }
@ -364,6 +389,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public String getTownName() {
        return townName;
    }
    public void setTownName(String townName) {
        this.townName = townName;
    }
@ -372,6 +398,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public String getStreetCode() {
        return streetCode;
    }
    public void setStreetCode(String streetCode) {
        this.streetCode = streetCode;
    }
@ -380,6 +407,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public String getStreetName() {
        return streetName;
    }
    public void setStreetName(String streetName) {
        this.streetName = streetName;
    }
@ -415,6 +443,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public String getPoints() {
        return points;
    }
    public void setPoints(String points) {
        this.points = points;
    }
@ -423,6 +452,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public String getRecordAmount() {
        return recordAmount;
    }
    public void setRecordAmount(String recordAmount) {
        this.recordAmount = recordAmount;
    }
@ -431,6 +461,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public String getOpenid() {
        return openid;
    }
    public void setOpenid(String openid) {
        this.openid = openid;
    }
@ -439,6 +470,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public String getPatientStatus() {
        return patientStatus;
    }
    public void setPatientStatus(String patientStatus) {
        this.patientStatus = patientStatus;
    }
@ -447,6 +479,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public String getMobileRemarks() {
        return mobileRemarks;
    }
    public void setMobileRemarks(String mobileRemarks) {
        this.mobileRemarks = mobileRemarks;
    }
@ -455,6 +488,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public Date getOpenidTime() {
        return openidTime;
    }
    public void setOpenidTime(Date openidTime) {
        this.openidTime = openidTime;
    }
@ -463,6 +497,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public String getPrincipalCode() {
        return principalCode;
    }
    public void setPrincipalCode(String principalCode) {
        this.principalCode = principalCode;
    }
@ -471,6 +506,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public Integer getStandardStatus() {
        return standardStatus;
    }
    public void setStandardStatus(Integer standardStatus) {
        this.standardStatus = standardStatus;
    }
@ -479,6 +515,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public String getUnionid() {
        return unionid;
    }
    public void setUnionid(String unionid) {
        this.unionid = unionid;
    }
@ -487,6 +524,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
@ -494,6 +532,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public String getRemark() {
        return remark;
    }
    @Column(name = "remark")
    public void setRemark(String remark) {
        this.remark = remark;
@ -555,6 +594,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public void setLiveStreetCode(String liveStreetCode) {
        this.liveStreetCode = liveStreetCode;
    }
    @Column(name = "live_street_name")
    public String getLiveStreetName() {
        return liveStreetName;
@ -603,4 +643,22 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public void setLoginDate(Date loginDate) {
        this.loginDate = loginDate;
    }
    @Column(name = "ihealth_openid")
    public String getIhealthOpenid() {
        return ihealthOpenid;
    }
    public void setIhealthOpenid(String ihealthOpenid) {
        this.ihealthOpenid = ihealthOpenid;
    }
    @Column(name = "ihealth_openid_time")
    public Date getIhealthOpenidTime() {
        return ihealthOpenidTime;
    }
    public void setIhealthOpenidTime(Date ihealthOpenidTime) {
        this.ihealthOpenidTime = ihealthOpenidTime;
    }
}

+ 98 - 12
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/consult/WlyyHospitalWaitingRoomDO.java

@ -19,11 +19,6 @@ import java.util.Date;
@Table(name = "wlyy_hospital_waiting_room")
public class WlyyHospitalWaitingRoomDO extends UuidIdentityEntity {
    /**
	 * 
	 */
	private String saasId;
    /**
	 * 诊室ID
	 */
@ -39,6 +34,36 @@ public class WlyyHospitalWaitingRoomDO extends UuidIdentityEntity {
	 */
	private String patientName;
    /**
     * 医院code
     */
    private String hospital;
    /**
     * 医院名称
     */
    private String hospitalName;
    /**
     * 部门
     */
    private String dept;
    /**
     * 部门名称
     */
    private String deptName;
    /**
     * 医生
     */
    private String doctor;
    /**
     * 医生名称
     */
    private String doctorName;
    /**
	 * 0离线 1在线(候诊) 2已诊
	 */
@ -70,14 +95,12 @@ public class WlyyHospitalWaitingRoomDO extends UuidIdentityEntity {
	 */
	private String outpatientId;
    /**
     *  创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    private Date createTime;
	@Column(name = "saas_id")
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
	@Column(name = "clinicroom_id")
    public String getClinicroomId() {
@ -151,4 +174,67 @@ public class WlyyHospitalWaitingRoomDO extends UuidIdentityEntity {
	public void setOutpatientId(String outpatientId) {
		this.outpatientId = outpatientId;
	}
    @Column(name = "hospital")
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    @Column(name = "hospital_name")
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    @Column(name = "dept")
    public String getDept() {
        return dept;
    }
    public void setDept(String dept) {
        this.dept = dept;
    }
    @Column(name = "dept_name")
    public String getDeptName() {
        return deptName;
    }
    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }
    @Column(name = "doctor")
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    @Column(name = "doctor_name")
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 66 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/dict/WlyyChargeDictDO.java

@ -0,0 +1,66 @@
package com.yihu.jw.entity.hospital.dict;
import com.yihu.jw.entity.IntegerIdentityEntity;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by zdm on 2019/5/28.
 */
@Entity
@Table(name = "wlyy_charge_dict")
public class WlyyChargeDictDO extends UuidIdentityEntity {
    /**号别code*/
    private String chargeType;
    /**号别名称*/
    private String chargeName;
    /**诊查费,单位元*/
    private double reqFee;
    /**创建时间*/
    private Date createTime;
    /**6总部7金榜8夏禾*/
    private String deptTypeCode;
    public String getChargeType() {
        return chargeType;
    }
    public void setChargeType(String chargeType) {
        this.chargeType = chargeType;
    }
    public String getChargeName() {
        return chargeName;
    }
    public void setChargeName(String chargeName) {
        this.chargeName = chargeName;
    }
    public double getReqFee() {
        return reqFee;
    }
    public void setReqFee(double reqFee) {
        this.reqFee = reqFee;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getDeptTypeCode() {
        return deptTypeCode;
    }
    public void setDeptTypeCode(String deptTypeCode) {
        this.deptTypeCode = deptTypeCode;
    }
}

+ 100 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/doctor/WlyyPatientRegisterTimeDO.java

@ -0,0 +1,100 @@
package com.yihu.jw.entity.hospital.doctor;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Trick on 2019/6/14.
 */
@Entity
@Table(name = "wlyy_patient_register_time")
public class WlyyPatientRegisterTimeDO extends UuidIdentityEntity {
    private String patient;//患者code',
    private String patientName;//患者姓名',
    private String doctor;//医生code',
    private String doctorName;//医生姓名',
    private String workId;//医生排班id',
    private Date startTime;//预约开始时间',
    private Date endTime;//
    private String date;//预约日期',
    private Date create_time;//创建时间',
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    public String getWorkId() {
        return workId;
    }
    public void setWorkId(String workId) {
        this.workId = workId;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getStartTime() {
        return startTime;
    }
    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getEndTime() {
        return endTime;
    }
    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }
    public String getDate() {
        return date;
    }
    public void setDate(String date) {
        this.date = date;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreate_time() {
        return create_time;
    }
    public void setCreate_time(Date create_time) {
        this.create_time = create_time;
    }
}

+ 126 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/mapping/DoctorMappingDO.java

@ -0,0 +1,126 @@
package com.yihu.jw.entity.hospital.mapping;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Trick on 2019/6/10.
 */
@Entity
@Table(name = "base_doctor_mapping")
public class DoctorMappingDO extends UuidIdentityEntity {
    private String doctor;//医生code',
    private String doctor_name;//医生名称',
    private String idcard;//身份证号',
    private String orgCode;//机构code',
    private String orgName;//机构名称',
    private String mappingCode;//映射code',
    private String mappingName;//映射名称',
    private String mappingDept;//映射部门',
    private String mappingDeptName;//映射部门名称',
    private String mappingJob;//映射职称',
    private String mappingJobName;//映射职称名称',
    private Date createTime;//创建时间',
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    public String getDoctor_name() {
        return doctor_name;
    }
    public void setDoctor_name(String doctor_name) {
        this.doctor_name = doctor_name;
    }
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    public String getOrgCode() {
        return orgCode;
    }
    public void setOrgCode(String orgCode) {
        this.orgCode = orgCode;
    }
    public String getOrgName() {
        return orgName;
    }
    public void setOrgName(String orgName) {
        this.orgName = orgName;
    }
    public String getMappingCode() {
        return mappingCode;
    }
    public void setMappingCode(String mappingCode) {
        this.mappingCode = mappingCode;
    }
    public String getMappingName() {
        return mappingName;
    }
    public void setMappingName(String mappingName) {
        this.mappingName = mappingName;
    }
    public String getMappingDept() {
        return mappingDept;
    }
    public void setMappingDept(String mappingDept) {
        this.mappingDept = mappingDept;
    }
    public String getMappingDeptName() {
        return mappingDeptName;
    }
    public void setMappingDeptName(String mappingDeptName) {
        this.mappingDeptName = mappingDeptName;
    }
    public String getMappingJob() {
        return mappingJob;
    }
    public void setMappingJob(String mappingJob) {
        this.mappingJob = mappingJob;
    }
    public String getMappingJobName() {
        return mappingJobName;
    }
    public void setMappingJobName(String mappingJobName) {
        this.mappingJobName = mappingJobName;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 115 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyExpressagePriceDO.java

@ -0,0 +1,115 @@
package com.yihu.jw.entity.hospital.prescription;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
* 实体
*
* @author Administrator on  2019年06月05日
*
*/
@Entity
@Table(name = "wlyy_expressage_price")
public class WlyyExpressagePriceDO extends UuidIdentityEntity {
    /**
	 * 不同类型快递code
	 */
	private String code;
    /**
	 * 起始地址名称
	 */
	private String startAddressName;
    /**
	 * 结束地址名称
	 */
	private String endAddressName;
    /**
	 * 首重
	 */
	private Integer firstWeight;
    /**
	 * 首重价格
	 */
	private Integer firstWeightPrice;
    /**
	 * 续重
	 */
	private Integer continueWeight;
    /**
	 * 续重价格
	 */
	private Integer continueWeightPrice;
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "start_address_name")
    public String getStartAddressName() {
        return startAddressName;
    }
    public void setStartAddressName(String startAddressName) {
        this.startAddressName = startAddressName;
    }
	@Column(name = "end_address_name")
    public String getEndAddressName() {
        return endAddressName;
    }
    public void setEndAddressName(String endAddressName) {
        this.endAddressName = endAddressName;
    }
	@Column(name = "first_weight")
    public Integer getFirstWeight() {
        return firstWeight;
    }
    public void setFirstWeight(Integer firstWeight) {
        this.firstWeight = firstWeight;
    }
	@Column(name = "first_weight_price")
    public Integer getFirstWeightPrice() {
        return firstWeightPrice;
    }
    public void setFirstWeightPrice(Integer firstWeightPrice) {
        this.firstWeightPrice = firstWeightPrice;
    }
	@Column(name = "continue_weight")
    public Integer getContinueWeight() {
        return continueWeight;
    }
    public void setContinueWeight(Integer continueWeight) {
        this.continueWeight = continueWeight;
    }
	@Column(name = "continue_weight_price")
    public Integer getContinueWeightPrice() {
        return continueWeightPrice;
    }
    public void setContinueWeightPrice(Integer continueWeightPrice) {
        this.continueWeightPrice = continueWeightPrice;
    }
}

+ 114 - 2
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyOutpatientDO.java

@ -39,6 +39,36 @@ public class WlyyOutpatientDO extends UuidIdentityEntity {
	 */
	private String originRegisterNo;
    /**
     * 原始就诊次数
     */
    private String originConNo;
    /**
     * 就诊次数
     */
    private String conNo;
    /**
     * 1.图文 2.视频
     */
    private String type;
    /**
     * 医院编码
     */
    private String hospital;
    /**
     * 医院名称
     */
    private String hospitalName;
    /**
     * 机构分部编码
     */
    private String winNo;
    /**
	 * 部门
	 */
@ -74,6 +104,11 @@ public class WlyyOutpatientDO extends UuidIdentityEntity {
	 */
	private String idcard;
    /**
     * 就诊卡
     */
    private String cardNo;
    /**
	 * 门急诊标记(MZ门诊,JZ急诊)
	 */
@ -89,6 +124,11 @@ public class WlyyOutpatientDO extends UuidIdentityEntity {
	 */
	private String icd10Name;
    /**
     * 医嘱
     */
    private String advice;
    /**
	 * 挂号时间
	 */
@ -153,7 +193,34 @@ public class WlyyOutpatientDO extends UuidIdentityEntity {
        this.originRegisterNo = originRegisterNo;
    }
	@Column(name = "dept")
    @Column(name = "type")
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    @Column(name = "hospital")
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    @Column(name = "hospital_name")
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    @Column(name = "dept")
    public String getDept() {
        return dept;
    }
@ -233,7 +300,16 @@ public class WlyyOutpatientDO extends UuidIdentityEntity {
        this.icd10Name = icd10Name;
    }
	@Column(name = "adm_date")
    @Column(name = "advice")
    public String getAdvice() {
        return advice;
    }
    public void setAdvice(String advice) {
        this.advice = advice;
    }
    @Column(name = "adm_date")
    public Date getAdmDate() {
        return admDate;
    }
@ -283,4 +359,40 @@ public class WlyyOutpatientDO extends UuidIdentityEntity {
    public void setDiseaseImg(String diseaseImg) {
        this.diseaseImg = diseaseImg;
    }
    @Column(name="card_no")
    public String getCardNo() {
        return cardNo;
    }
    public void setCardNo(String cardNo) {
        this.cardNo = cardNo;
    }
    @Column(name="win_no")
    public String getWinNo() {
        return winNo;
    }
    public void setWinNo(String winNo) {
        this.winNo = winNo;
    }
    @Column(name="origin_con_no")
    public String getOriginConNo() {
        return originConNo;
    }
    public void setOriginConNo(String originConNo) {
        this.originConNo = originConNo;
    }
    @Column(name="con_no")
    public String getConNo() {
        return conNo;
    }
    public void setConNo(String conNo) {
        this.conNo = conNo;
    }
}

+ 182 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyOutpatientExpressageLogDO.java

@ -0,0 +1,182 @@
package com.yihu.jw.entity.hospital.prescription;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntity;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
* 门诊物流日志表实体
*
* @author Administrator on  2019年06月05日
*
*/
@Entity
@Table(name = "wlyy_outpatient_expressage_log")
public class WlyyOutpatientExpressageLogDO extends UuidIdentityEntity {
    /**
	 * 
	 */
	private String saasId;
    /**
	 * 门诊id 关联表wlyy_outpatient id
	 */
	private String outpatientId;
    /**
	 * 创建时间
	 */
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	private Date createTime;
    /**
	 * 类型: -1 失效 1HIS对接 2易联众对接  3创建处方 4 审核  5付款 6 配送 7完成 8物流对接
	 */
	private Integer type;
    /**
	 * (-2 患者自己取消 -1 审核不通过 , 0 审核中, 10 审核通过/待支付 ,21支付失败  20 配药中/支付成功, 21 等待领药 ,30 配送中 ,100配送成功/已完成)
	 */
	private Integer status;
    /**
	 * 医生或者患者code
	 */
	private String userCode;
    /**
	 * 医生或者患者name
	 */
	private String userName;
    /**
	 * 1 患者 2医生
	 */
	private Integer userType;
    /**
	 * 医院id
	 */
	private String hospital;
    /**
	 * 医院名称
	 */
	private String hospitalName;
    /**
	 * 操作是否成功 1成功 0失败
	 */
	private Integer flag;
    /**
	 * 备注信息
	 */
	private String remark;
	@Column(name = "saas_id")
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
	@Column(name = "outpatient_id")
    public String getOutpatientId() {
        return outpatientId;
    }
    public void setOutpatientId(String outpatientId) {
        this.outpatientId = outpatientId;
    }
	@Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
	@Column(name = "type")
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
	@Column(name = "status")
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
	@Column(name = "user_code")
    public String getUserCode() {
        return userCode;
    }
    public void setUserCode(String userCode) {
        this.userCode = userCode;
    }
	@Column(name = "user_name")
    public String getUserName() {
        return userName;
    }
    public void setUserName(String userName) {
        this.userName = userName;
    }
	@Column(name = "user_type")
    public Integer getUserType() {
        return userType;
    }
    public void setUserType(Integer userType) {
        this.userType = userType;
    }
	@Column(name = "hospital")
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
	@Column(name = "hospital_name")
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
	@Column(name = "flag")
    public Integer getFlag() {
        return flag;
    }
    public void setFlag(Integer flag) {
        this.flag = flag;
    }
	@Column(name = "remark")
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
}

+ 192 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyPatientExpressageAddrDO.java

@ -0,0 +1,192 @@
package com.yihu.jw.entity.hospital.prescription;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
* 居民收获地址实体
*
* @author Administrator on  2019年06月12日
*
*/
@Entity
@Table(name = "wlyy_patient_expressage_addr")
public class WlyyPatientExpressageAddrDO extends UuidIdentityEntityWithOperator {
    /**
	 * 居民标识
	 */
	private String patient;
    /**
	 * 省编码
	 */
	private String provinceCode;
    /**
	 * 省名称
	 */
	private String provinceName;
    /**
	 * 市编码
	 */
	private String cityCode;
    /**
	 * 城市名称
	 */
	private String cityName;
    /**
	 * 区县编码
	 */
	private String townCode;
    /**
	 * 区县名称
	 */
	private String townName;
    /**
	 * 街道编码
	 */
	private String streetCode;
    /**
	 * 街道名称
	 */
	private String streetName;
    /**
	 * 居住居委会代码
	 */
	private String committeeCode;
    /**
	 * 居住居委会名称
	 */
	private String committeeName;
    /**
	 * 具体详细地址
	 */
	private String address;
    /**
	 * 作废标识,1正常,0作废
	 */
	private String del;
	@Column(name = "patient")
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
	@Column(name = "province_code")
    public String getProvinceCode() {
        return provinceCode;
    }
    public void setProvinceCode(String provinceCode) {
        this.provinceCode = provinceCode;
    }
	@Column(name = "province_name")
    public String getProvinceName() {
        return provinceName;
    }
    public void setProvinceName(String provinceName) {
        this.provinceName = provinceName;
    }
	@Column(name = "city_code")
    public String getCityCode() {
        return cityCode;
    }
    public void setCityCode(String cityCode) {
        this.cityCode = cityCode;
    }
	@Column(name = "city_name")
    public String getCityName() {
        return cityName;
    }
    public void setCityName(String cityName) {
        this.cityName = cityName;
    }
	@Column(name = "town_code")
    public String getTownCode() {
        return townCode;
    }
    public void setTownCode(String townCode) {
        this.townCode = townCode;
    }
	@Column(name = "town_name")
    public String getTownName() {
        return townName;
    }
    public void setTownName(String townName) {
        this.townName = townName;
    }
	@Column(name = "street_code")
    public String getStreetCode() {
        return streetCode;
    }
    public void setStreetCode(String streetCode) {
        this.streetCode = streetCode;
    }
	@Column(name = "street_name")
    public String getStreetName() {
        return streetName;
    }
    public void setStreetName(String streetName) {
        this.streetName = streetName;
    }
	@Column(name = "committee_code")
    public String getCommitteeCode() {
        return committeeCode;
    }
    public void setCommitteeCode(String committeeCode) {
        this.committeeCode = committeeCode;
    }
	@Column(name = "committee_name")
    public String getCommitteeName() {
        return committeeName;
    }
    public void setCommitteeName(String committeeName) {
        this.committeeName = committeeName;
    }
	@Column(name = "address")
    public String getAddress() {
        return address;
    }
    public void setAddress(String address) {
        this.address = address;
    }
	@Column(name = "del")
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
}

+ 9 - 20
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyPrescriptionExpressageDO.java

@ -19,15 +19,12 @@ import java.util.Date;
@Table(name = "wlyy_prescription_expressage")
public class WlyyPrescriptionExpressageDO extends UuidIdentityEntity {
    /**
	 * 
	 */
	private String saasId;
    /**
	 * 关联wlyy_wlyy_prescription id
	 * 门诊记录ID
	 * 关联wlyy_outpatient id
	 */
	private String prescriptionId;
	private String outpatientId;
    /**
	 * 快递单号
@ -142,24 +139,16 @@ public class WlyyPrescriptionExpressageDO extends UuidIdentityEntity {
	private Integer del;
	@Column(name = "saas_id")
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    @Column(name = "outpatient_id")
    public String getOutpatientId() {
        return outpatientId;
    }
	@Column(name = "prescription_id")
    public String getPrescriptionId() {
        return prescriptionId;
    }
    public void setPrescriptionId(String prescriptionId) {
        this.prescriptionId = prescriptionId;
    public void setOutpatientId(String outpatientId) {
        this.outpatientId = outpatientId;
    }
	@Column(name = "mailno")
    @Column(name = "mailno")
    public String getMailno() {
        return mailno;
    }

+ 9 - 7
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyPrescriptionExpressageLogDO.java

@ -25,9 +25,9 @@ public class WlyyPrescriptionExpressageLogDO extends UuidIdentityEntity {
	private String saasId;
    /**
	 * 关联表wlyy_prescription id
	 * 关联表wlyy_ouapatient id
	 */
	private String prescriptionId;
	private String outpatientId;
    /**
	 * 关联wlyy_prescription_expressage id
@ -141,12 +141,14 @@ public class WlyyPrescriptionExpressageLogDO extends UuidIdentityEntity {
        this.saasId = saasId;
    }
	@Column(name = "prescription_id")
    public String getPrescriptionId() {
        return prescriptionId;
    @Column(name = "outpatient_id")
    public String getOutpatientId() {
        return outpatientId;
    }
    public void setPrescriptionId(String prescriptionId) {
        this.prescriptionId = prescriptionId;
    public void setOutpatientId(String outpatientId) {
        this.outpatientId = outpatientId;
    }
	@Column(name = "expressage_id")

+ 42 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyPrescriptionInfoDO.java

@ -72,6 +72,21 @@ public class WlyyPrescriptionInfoDO extends UuidIdentityEntity {
     */
    private String frequency;
    /**
     * 药品收费码
     */
    private String serial;
    /**
     * 库房号
     */
    private String groupNo;
    /**
     * 规格
     */
    private String specification;
    /**
     * 1可用 0删除
     */
@ -166,6 +181,33 @@ public class WlyyPrescriptionInfoDO extends UuidIdentityEntity {
        this.frequency = frequency;
    }
    @Column(name = "serial")
    public String getSerial() {
        return serial;
    }
    public void setSerial(String serial) {
        this.serial = serial;
    }
    @Column(name = "group_no")
    public String getGroupNo() {
        return groupNo;
    }
    public void setGroupNo(String groupNo) {
        this.groupNo = groupNo;
    }
    @Column(name = "specification")
    public String getSpecification() {
        return specification;
    }
    public void setSpecification(String specification) {
        this.specification = specification;
    }
    @Column(name = "del")
    public Integer getDel() {
        return del;

+ 95 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/device/IotDeviceBaiyiDO.java

@ -0,0 +1,95 @@
package com.yihu.jw.entity.iot.device;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
/**
 * @author zdm on 2019/6/11.
 */
@Entity
@Table(name = "iot_device_baiyi")
public class IotDeviceBaiyiDO extends UuidIdentityEntityWithOperator implements Serializable {
    /** 15位设备唯一序号*/
    @Column(name = "imei")
    private String imei;
    /** 发生时间*/
    @Column(name = "time_begin")
    private String timeBegin;
    /**心率/舒张压*/
    @Column(name = "value1")
    private Integer value1;
    /** 心率阈值上限/舒张压报警下限*/
    @Column(name = "value2")
    private Integer value2;
    /** 心率阈值下限/收缩压*/
    @Column(name = "value3")
    private Integer value3;
    /** 测量数据种类名称/收缩压报警上限*/
    @Column(name = "value4")
    private Integer value4;
    /** 类型:1血压、5心率*/
    @Column(name = "type")
    private Integer type;
    public String getImei() {
        return imei;
    }
    public void setImei(String imei) {
        this.imei = imei;
    }
    public String getTimeBegin() {
        return timeBegin;
    }
    public void setTimeBegin(String timeBegin) {
        this.timeBegin = timeBegin;
    }
    public Integer getValue1() {
        return value1;
    }
    public void setValue1(Integer value1) {
        this.value1 = value1;
    }
    public Integer getValue2() {
        return value2;
    }
    public void setValue2(Integer value2) {
        this.value2 = value2;
    }
    public Integer getValue3() {
        return value3;
    }
    public void setValue3(Integer value3) {
        this.value3 = value3;
    }
    public Integer getValue4() {
        return value4;
    }
    public void setValue4(Integer value4) {
        this.value4 = value4;
    }
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
}

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

@ -26,6 +26,7 @@ public class BaseHospitalRequestMapping {
        public static final String PREFIX  = "/prescription";
        //=====================start=======================================
        /**
         * 获取门诊记录
         */
@ -35,11 +36,90 @@ public class BaseHospitalRequestMapping {
         * 查询单条门诊记录接口
         */
        public static final String findOutpatientInfo ="/findOutpatientInfo";
        /**
         * 查询单条复诊信息全部接口
         */
        public static final String findReOutpatientInfo = "/findReOutpatientInfo";
        /**
         * 获取复诊记录类别
         */
        public static final String findReOutpatientList ="/findReOutpatientList";
        /**
         * 查询患者就诊卡
         */
        public static final String findPatientCard = "/findPatientCard";
        /**
         * 判断是否可用发起门诊
         */
        public static final String checkOutpatient ="/checkOutpatient";
        /**
         * 居民发起复诊
         */
        public static final String appointmentRevisit = "/appointmentRevisit";
        /**
         * 查询所有机构
         */
        public static final String findAllHospital ="/findAllHospital";
        /**
         * 查询机构底下部门
         */
        public static final String findDeptByHospital ="/findDeptByHospital";
        /**
         * 查询部门下医生
         */
        public static final String findDoctorByHospitalAndDept = "/findDoctorByHospitalAndDept";
        /**
         * 挂号
         */
        public static final String registerOutPatient ="/registerOutPatient";
        /**
         * 获取ICD10诊断编码
         */
        public static final String getICD10 ="/getICD10";
        /**
         * 获取药品字典
         */
        public static final String getDrugDictionary ="/getDrugDictionary";
        /**
         * 获取用药方式
         */
        public static final String getDrugUse ="/getDrugUse";
        /**
         * 获取用药频次
         */
        public static final String getDrugFrequency="/getDrugFrequency";
        /**
         * 下诊断
         */
        public static final String makeDiagnosis="/makeDiagnosis";
        /**
         * 获取订单列表
         */
        public static final String findExpressageList="/findExpressageList";
        /**
         * 设置订单
         */
        public static final String setMailno="/setMailno";
        /**
         * 订单导出
         */
        public static final String pushListWrite="/pushListWrite";
        //=================end=======================================
        /**
         * 原处方记录
         */
@ -67,8 +147,6 @@ public class BaseHospitalRequestMapping {
         * 获取医生及号员信息
         */
        public static final String findDoctorList = "/findDoctorList";
        //支付+预约
        public static final String appointmentRevisit = "/appointmentRevisit";
        /**
         * 进入候诊室
@ -103,4 +181,20 @@ public class BaseHospitalRequestMapping {
        //医生下诊断
        public static final String diagnose ="/diagnose";
    }
    /**
     * 门诊处方物流
     */
    public static class Expressage extends Basic {
        public static final String PREFIX  = "/expressage";
    }
    /**
     * 居民收获地址
     */
    public static class WlyyPatientExpressageAddr extends Basic {
        public static final String PREFIX  = "/expressageAddr";
    }
}

+ 9 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/dict/DictHospitalDeptVO.java

@ -47,6 +47,9 @@ public class DictHospitalDeptVO extends IntegerIdentityVO{
	@ApiModelProperty(value = "创建时间", example = "yyyy-MM-dd HH:mm:ss/该字段可不填")
    private Date createTime;
    @ApiModelProperty(value = "6总部7金榜8夏禾", example = "神经内科")
    private String deptTypeCode;
    public String getOrgCode() {
        return orgCode;
@ -76,5 +79,11 @@ public class DictHospitalDeptVO extends IntegerIdentityVO{
        this.createTime = createTime;
    }
    public String getDeptTypeCode() {
        return deptTypeCode;
    }
    public void setDeptTypeCode(String deptTypeCode) {
        this.deptTypeCode = deptTypeCode;
    }
}

+ 10 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/org/BaseOrgVO.java

@ -151,6 +151,8 @@ public class BaseOrgVO extends UuidIdentityVOWithOperator {
     */
    @ApiModelProperty(value = "11一级甲等 12一级乙等 13一级丙等二级甲等 22二级乙等 23二级丙等31三级特等 32三级甲等 33三级乙等 34三级丙级", example = "1")
    private Integer level;
    @ApiModelProperty(value = "机构分部号,每个机构都不一样,例如中山医院:6总部7金榜8夏禾", example = "1")
    private String winNo;
    private List<DictHospitalDeptVO> depts;
@ -310,4 +312,12 @@ public class BaseOrgVO extends UuidIdentityVOWithOperator {
    public void setDepts(List<DictHospitalDeptVO> depts) {
        this.depts = depts;
    }
    public String getWinNo() {
        return winNo;
    }
    public void setWinNo(String winNo) {
        this.winNo = winNo;
    }
}

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

@ -47,6 +47,35 @@ public class WlyyOutpatientVO extends UuidIdentityVO {
	@ApiModelProperty(value = "原始挂号流水号", example = "模块1")
    private String originRegisterNo;
    /**
     * 原始就诊次数
     */
    @ApiModelProperty(value = "原始就诊次数", example = "模块1")
    private String originConNo;
    /**
     * 就诊次数
     */
    @ApiModelProperty(value = "就诊次数", example = "模块1")
    private String conNo;
    /**
     * 医院编码
     */
    @ApiModelProperty(value = "医院编码", example = "模块1")
    private String hospital;
    /**
     * 医院名称
     */
    @ApiModelProperty(value = "医院名称", example = "模块1")
    private String hospitalName;
    /**
     * 机构分部编码
     */
    @ApiModelProperty(value = "机构分部编码", example = "模块1")
    private String winNo;
    /**
	 * 部门
	 */
@ -89,6 +118,9 @@ public class WlyyOutpatientVO extends UuidIdentityVO {
	@ApiModelProperty(value = "身份证号", example = "模块1")
    private String idcard;
    @ApiModelProperty(value = "就诊卡", example = "模块1")
    private String cardNo;
    /**
	 * 门急诊标记(MZ门诊,JZ急诊)
	 */
@ -136,6 +168,7 @@ public class WlyyOutpatientVO extends UuidIdentityVO {
    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @ApiModelProperty(value = "创建时间", example = "模块1")
    private Date createTime;
@ -174,6 +207,22 @@ public class WlyyOutpatientVO extends UuidIdentityVO {
        this.originRegisterNo = originRegisterNo;
    }
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    public String getDept() {
        return dept;
    }
@ -288,4 +337,36 @@ public class WlyyOutpatientVO extends UuidIdentityVO {
    public void setDiseaseImg(String diseaseImg) {
        this.diseaseImg = diseaseImg;
    }
    public String getCardNo() {
        return cardNo;
    }
    public void setCardNo(String cardNo) {
        this.cardNo = cardNo;
    }
    public String getWinNo() {
        return winNo;
    }
    public void setWinNo(String winNo) {
        this.winNo = winNo;
    }
    public String getOriginConNo() {
        return originConNo;
    }
    public void setOriginConNo(String originConNo) {
        this.originConNo = originConNo;
    }
    public String getConNo() {
        return conNo;
    }
    public void setConNo(String conNo) {
        this.conNo = conNo;
    }
}

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

@ -0,0 +1,196 @@
package com.yihu.jw.restmodel.hospital.prescription;
import com.yihu.jw.restmodel.UuidIdentityVOWithOperator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
/**
 * 
 * 居民收获地址vo
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * Administrator 	1.0  2019年06月12日 Created
 *
 * </pre>
 * @since 1.
 */
@ApiModel(value = "WlyyPatientExpressageAddrVO", description = "居民收获地址")
public class WlyyPatientExpressageAddrVO extends UuidIdentityVOWithOperator {
    /**
	 * 居民标识
	 */
	@ApiModelProperty(value = "居民标识", example = "模块1")
    private String patient;
    /**
	 * 省编码
	 */
	@ApiModelProperty(value = "省编码", example = "模块1")
    private String provinceCode;
    /**
	 * 省名称
	 */
	@ApiModelProperty(value = "省名称", example = "模块1")
    private String provinceName;
    /**
	 * 市编码
	 */
	@ApiModelProperty(value = "市编码", example = "模块1")
    private String cityCode;
    /**
	 * 城市名称
	 */
	@ApiModelProperty(value = "城市名称", example = "模块1")
    private String cityName;
    /**
	 * 区县编码
	 */
	@ApiModelProperty(value = "区县编码", example = "模块1")
    private String townCode;
    /**
	 * 区县名称
	 */
	@ApiModelProperty(value = "区县名称", example = "模块1")
    private String townName;
    /**
	 * 街道编码
	 */
	@ApiModelProperty(value = "街道编码", example = "模块1")
    private String streetCode;
    /**
	 * 街道名称
	 */
	@ApiModelProperty(value = "街道名称", example = "模块1")
    private String streetName;
    /**
	 * 居住居委会代码
	 */
	@ApiModelProperty(value = "居住居委会代码", example = "模块1")
    private String committeeCode;
    /**
	 * 居住居委会名称
	 */
	@ApiModelProperty(value = "居住居委会名称", example = "模块1")
    private String committeeName;
    /**
	 * 具体详细地址
	 */
	@ApiModelProperty(value = "具体详细地址", example = "模块1")
    private String address;
    /**
	 * 作废标识,1正常,0作废
	 */
	@ApiModelProperty(value = "作废标识,1正常,0作废", example = "模块1")
    private String del;
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getProvinceCode() {
        return provinceCode;
    }
    public void setProvinceCode(String provinceCode) {
        this.provinceCode = provinceCode;
    }
    public String getProvinceName() {
        return provinceName;
    }
    public void setProvinceName(String provinceName) {
        this.provinceName = provinceName;
    }
    public String getCityCode() {
        return cityCode;
    }
    public void setCityCode(String cityCode) {
        this.cityCode = cityCode;
    }
    public String getCityName() {
        return cityName;
    }
    public void setCityName(String cityName) {
        this.cityName = cityName;
    }
    public String getTownCode() {
        return townCode;
    }
    public void setTownCode(String townCode) {
        this.townCode = townCode;
    }
    public String getTownName() {
        return townName;
    }
    public void setTownName(String townName) {
        this.townName = townName;
    }
    public String getStreetCode() {
        return streetCode;
    }
    public void setStreetCode(String streetCode) {
        this.streetCode = streetCode;
    }
    public String getStreetName() {
        return streetName;
    }
    public void setStreetName(String streetName) {
        this.streetName = streetName;
    }
    public String getCommitteeCode() {
        return committeeCode;
    }
    public void setCommitteeCode(String committeeCode) {
        this.committeeCode = committeeCode;
    }
    public String getCommitteeName() {
        return committeeName;
    }
    public void setCommitteeName(String committeeName) {
        this.committeeName = committeeName;
    }
    public String getAddress() {
        return address;
    }
    public void setAddress(String address) {
        this.address = address;
    }
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
}

+ 7 - 6
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/prescription/WlyyPrescriptionExpressageVO.java

@ -31,8 +31,8 @@ public class WlyyPrescriptionExpressageVO extends UuidIdentityVOWithOperator {
    /**
	 * 关联wlyy_wlyy_prescription id
	 */
	@ApiModelProperty(value = "关联wlyy_wlyy_prescription id", example = "模块1")
    private String prescriptionId;
	@ApiModelProperty(value = "关联门诊记录", example = "模块1")
    private String outpatientId;
    /**
	 * 快递单号
@ -305,11 +305,12 @@ public class WlyyPrescriptionExpressageVO extends UuidIdentityVOWithOperator {
        this.saasId = saasId;
    }
    public String getPrescriptionId() {
        return prescriptionId;
    public String getOutpatientId() {
        return outpatientId;
    }
    public void setPrescriptionId(String prescriptionId) {
        this.prescriptionId = prescriptionId;
    public void setOutpatientId(String outpatientId) {
        this.outpatientId = outpatientId;
    }
    public String getMailno() {

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

@ -87,6 +87,21 @@ public class WlyyPrescriptionInfoVO extends UuidIdentityVOWithOperator {
    @ApiModelProperty(value = "组数", example = "模块1")
    private String frequency;
    /**
     * 药品收费码
     */
    @ApiModelProperty(value = "药品收费码", example = "模块1")
    private String serial;
    /**
     * 库房号
     */
    @ApiModelProperty(value = "库房号", example = "模块1")
    private String groupNo;
    @ApiModelProperty(value = "规格", example = "模块1")
    private String specification;
    /**
     * 1可用 0删除
     */
@ -178,4 +193,27 @@ public class WlyyPrescriptionInfoVO extends UuidIdentityVOWithOperator {
        this.del = del;
    }
    public String getSerial() {
        return serial;
    }
    public void setSerial(String serial) {
        this.serial = serial;
    }
    public String getGroupNo() {
        return groupNo;
    }
    public void setGroupNo(String groupNo) {
        this.groupNo = groupNo;
    }
    public String getSpecification() {
        return specification;
    }
    public void setSpecification(String specification) {
        this.specification = specification;
    }
}

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

@ -85,6 +85,9 @@ public class WlyyPrescriptionVO extends UuidIdentityVOWithOperator {
    @ApiModelProperty(value = "居民身份证号", example = "模块1")
    private String idcard;
    @ApiModelProperty(value = "居民就诊卡", example = "模块1")
    private String cardNo;
    /**
     * 社保卡号
     */
@ -298,6 +301,9 @@ public class WlyyPrescriptionVO extends UuidIdentityVOWithOperator {
    @ApiModelProperty(value = "关联药品实体", example = "模块1")
    List<WlyyPrescriptionInfoVO> infoVOs;
    @ApiModelProperty(value = "关联物流实体", example = "模块1")
    WlyyPrescriptionExpressageVO expressage;
    public String getOutpatientId() {
        return outpatientId;
    }
@ -631,4 +637,12 @@ public class WlyyPrescriptionVO extends UuidIdentityVOWithOperator {
    public void setDiseaseImg(String diseaseImg) {
        this.diseaseImg = diseaseImg;
    }
    public WlyyPrescriptionExpressageVO getExpressage() {
        return expressage;
    }
    public void setExpressage(WlyyPrescriptionExpressageVO expressage) {
        this.expressage = expressage;
    }
}

+ 99 - 0
common/common-util/src/main/java/com/yihu/jw/util/http/HttpClientKit.java

@ -1,9 +1,23 @@
package com.yihu.jw.util.http;
import javafx.util.Pair;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.ParseException;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -152,4 +166,89 @@ public class HttpClientKit {
        }
    }
    /**
     * 发送post请求
     *
     * @param url     请求地址
     * @param params  请求参数
     * @param chatSet 编码格式
     * @return
     */
    public  static String post(String url, List<NameValuePair> params, String chatSet) {
        // 创建默认的httpClient实例.
        CloseableHttpClient httpclient = HttpClients.createDefault();
        // 创建httppost
        HttpPost httppost = new HttpPost(url);
        UrlEncodedFormEntity uefEntity;
        try {
            uefEntity = new UrlEncodedFormEntity(params, chatSet);
            httppost.setEntity(uefEntity);
            CloseableHttpResponse response = httpclient.execute(httppost);
            try {
                HttpEntity entity = response.getEntity();
                if (entity != null) {
                    return EntityUtils.toString(entity, chatSet);
                }
            } finally {
                response.close();
            }
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e1) {
            e1.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            // 关闭连接,释放资源
            try {
                httpclient.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return null;
    }
    /**
     * 发送get请求
     *
     * @param url     请求地址
     * @param chatSet 编码格式
     * @return
     */
    public  String get(String url, String chatSet) {
        CloseableHttpClient httpclient = HttpClients.createDefault();
        try {
            // 创建httpget.
            HttpGet httpget = new HttpGet(url);
            // 执行get请求.
            CloseableHttpResponse response = httpclient.execute(httpget);
            try {
                // 获取响应实体
                HttpEntity entity = response.getEntity();
                if (entity != null) {
                    return EntityUtils.toString(entity, chatSet);
                }
            } finally {
                response.close();
            }
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (ParseException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            // 关闭连接,释放资源
            try {
                httpclient.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return null;
    }
}

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

@ -55,14 +55,17 @@ zuul:
    svr-internet-hospital:
      path: /hospital/**
      serviceId: svr-internet-hospital
    svr-internet-hospital-entrance:
      path: /hospitalEntrance/**
      serviceId: svr-internet-hospital-entrance
---
spring:
  profiles: jwdev
  datasource:
    url: jdbc:mysql://172.19.103.77/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
    username: root
    password: 123456
    url: jdbc:mysql://172.26.0.114/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
    username: jkzl
    password: jkzlehr
  redis:
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.

+ 4 - 0
server/svr-authentication/pom.xml

@ -118,6 +118,10 @@
            <artifactId>mysql-starter</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-util</artifactId>
        </dependency>
    </dependencies>

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

@ -1,10 +1,14 @@
package com.yihu.jw.security.core.userdetails.jdbc;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.security.core.userdetails.SaltUser;
import com.yihu.jw.security.model.WlyyUserDetails;
import com.yihu.jw.security.model.WlyyUserSimple;
import com.yihu.jw.util.http.HttpClientKit;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
@ -16,6 +20,8 @@ import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.provider.ClientDetails;
import org.springframework.security.oauth2.provider.ClientDetailsService;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
@ -36,6 +42,13 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
    private static final String DEFAULT_DOCTOR_DETAILS_STATEMENT = "SELECT * FROM base_doctor d WHERE d.mobile = ? OR d.idcard = ?";
    private static final String DEFAULT_PATIENT_DETAILS_STATEMENT = "SELECT * FROM base_patient p WHERE p.mobile = ? OR p.idcard = ?";
    private static final String DEFAULT_PATIENT_DETAILS_ID_STATEMENT = "SELECT * FROM base_patient p WHERE p.id = ? ";
    private static final String DEFAULT_PATIENT_INSERT_STATEMENT =
            "INSERT into base_patient (`id`,`ihealth_openid`,`ihealth_openid_time`,`idcard`,`password`,`salt`,`name`,`birthday`,`sex`,`mobile`," +
                    "`province_code`,`province_name`,`city_code`,`city_name`,`town_code`,`town_name`,`street_code`,`street_name`,`address`," +
                    "`del`,`locked`,`enabled`,`login_failure_count`,`login_date`) " +
                    " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
    private static final String BespeakRegist = "bespeakRegist:";
@ -48,6 +61,13 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
    @Value("${user.tryLoginTimes}")
    private Integer tryLoginTimes;//失败重试次数
    @Value("${iHealth.user-info-uri}")
    private String iHealthUserInfoUrl;//失败重试次数
    @Autowired
    private ClientDetailsService clientDetailsService;
    public WlyyUserDetailsService(DataSource dataSource) {
        this.setDataSource(dataSource);
    }
@ -56,6 +76,7 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
     * 用户登录判读接口
     * 判断loginType查找用户信息
     * 用户类型 1或默认为user,2:医生登录,3:患者登录
     *
     * @param username
     * @return
     * @throws UsernameNotFoundException
@ -66,7 +87,7 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
        if (users == null || users.size() == 0) {
            throw new UsernameNotFoundException(username);
        }
        if (users.get(0).isLocked()) {
        if (null != users.get(0).isLocked() && users.get(0).isLocked()) {
            Date date = users.get(0).getLockedDate();
            if (new Date().after(DateUtils.addMinutes(date, autoUnlockTime))) {
                //解除锁定
@ -74,65 +95,134 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
                users.get(0).setLocked(false);
            }
        }
        return new SaltUser(username, users.get(0).getPassword(), users.get(0).getSalt(), users.get(0).isEnabled(), users.get(0).isLocked(), getGrantedAuthorities(username));
        boolean isEnabled = null == users.get(0).isEnabled() ? false : users.get(0).isEnabled();
        boolean isLocked = null == users.get(0).isLocked() ? false : users.get(0).isLocked();
        return new SaltUser(username, users.get(0).getPassword(), users.get(0).getSalt(), isEnabled, isLocked, getGrantedAuthorities(username));
    }
    public void unlocked(String username){
    public void unlocked(String username) {
        String loginType = getLogintype();
        if(StringUtils.isBlank(loginType)||"1".equals(loginType)){ //1或默认查找user表,为平台管理员账号
        if (StringUtils.isBlank(loginType) || "1".equals(loginType)) { //1或默认查找user表,为平台管理员账号
            //解除锁定
            this.getJdbcTemplate().update("update base_user u set login_failure_count = 0, u.locked = 0 where u.username = ? or u.mobile = ? or u.idcard = ?", username, username, username);
        }else if("2".equals(loginType)){//2.为医生账号
        } else if ("2".equals(loginType)) {//2.为医生账号
            //解除锁定
            this.getJdbcTemplate().update("update base_doctor d set d.login_failure_count = 0, d.locked = 0 where d.mobile = ? or d.idcard = ?",username, username);
        }else if("3".equals(loginType)){ //3.患者账号
            this.getJdbcTemplate().update("update base_doctor d set d.login_failure_count = 0, d.locked = 0 where d.mobile = ? or d.idcard = ?", username, username);
        } else if ("3".equals(loginType)) { //3.患者账号
            //解除锁定
            this.getJdbcTemplate().update("update base_patient p set p.login_failure_count = 5, p.locked = 0 where p.mobile = ? or p.idcard = ?",username, username);
            this.getJdbcTemplate().update("update base_patient p set p.login_failure_count = 5, p.locked = 0 where p.mobile = ? or p.idcard = ?", username, username);
        } //...
    }
    /**
     * 用户登录判读接口
     * 判断loginType查找用户信息
     * 用户类型 1或默认为user,2:医生登录,3:患者登录
     * 用户类型 1或默认为user,2:医生登录,3:患者登录,4:i健康系统-患者登录(i健康患者可以不注册直接登录互联网系统,首次使用,根据i健康居民code去i健康查询居民信息,然后保存到base.base_patient)
     *
     * @param username
     * @return
     */
    public  List<WlyyUserDetails> getWlyyUserDetails(String username){
    public List<WlyyUserDetails> getWlyyUserDetails(String username) {
        String loginType = getLogintype();
        List<WlyyUserDetails> users = null;
        //1或默认查找user表,为平台管理员账号
        if(StringUtils.isBlank(loginType)||"1".equals(loginType)){
        if (StringUtils.isBlank(loginType) || "1".equals(loginType)) {
            users = this.getJdbcTemplate().query(DEFAULT_USER_DETAILS_STATEMENT, new BeanPropertyRowMapper(WlyyUserDetails.class), username, username, username);
            //2.为医生登录账号
        }else if("2".equals(loginType)){
        } else if ("2".equals(loginType)) {
            users = this.getJdbcTemplate().query(DEFAULT_DOCTOR_DETAILS_STATEMENT, new BeanPropertyRowMapper(WlyyUserDetails.class), username, username);
            //3.患者登录
        }else if("3".equals(loginType)){
        } else if ("3".equals(loginType)) {
            //查找是否存在预注册 用户
            String userName = redisTemplate.opsForValue().get(BespeakRegist + username);
            if(StringUtils.isNotBlank(userName)){
            if (StringUtils.isNotBlank(userName)) {
                //保存到数据库
                this.getJdbcTemplate().execute("update base_patient set del=1 where mobile='"+username+"'");
                this.getJdbcTemplate().execute("update base_patient set del=1 where mobile='" + username + "'");
                redisTemplate.opsForValue().get(BespeakRegist + username);
                redisTemplate.delete(BespeakRegist+username);
                redisTemplate.delete(BespeakRegist + username);
            }
            users = this.getJdbcTemplate().query(DEFAULT_PATIENT_DETAILS_STATEMENT, new BeanPropertyRowMapper(WlyyUserDetails.class), username, username);
        }//..
            // 去i健康查询用户
        }else if("4".equals(loginType)){
            users = this.getJdbcTemplate().query(DEFAULT_PATIENT_DETAILS_ID_STATEMENT, new BeanPropertyRowMapper(WlyyUserDetails.class), username);
            if ((null == users || users.size() == 0) && "4".equals(loginType)) {
                List<NameValuePair> params = new ArrayList<>();
                params.add(new BasicNameValuePair("clientId", getClientId()));
                ClientDetails clientDetails = clientDetailsService.loadClientByClientId(getClientId());
                params.add(new BasicNameValuePair("clientSecret", clientDetails.getClientSecret()));
                params.add(new BasicNameValuePair("code", username));
                params.add(new BasicNameValuePair("openid", getOpenid()));
                String res = HttpClientKit.post(iHealthUserInfoUrl, params, "UTF-8");
                JSONObject patient = JSONObject.parseObject(res);
                if(patient.getInteger("status") == -1){
                    logger.error("去i健康查询用户信息失败:" + patient.getString("error"));
                    return users;
                }
                try {
                    this.getJdbcTemplate().update(DEFAULT_PATIENT_INSERT_STATEMENT,
                            new Object[]{patient.getString("code"),
                                    patient.getString("openid"),
                                    new Date(),
                                    patient.getString("idcard"),
                                    patient.getString("password"),
                                    patient.getString("salt"),
                                    patient.getString("name"),
                                    patient.getDate("birthday"),
                                    patient.getInteger("sex"),
                                    patient.getString("mobile"),
                                    patient.getString("province"),
                                    patient.getString("provinceName"),
                                    patient.getString("city"),
                                    patient.getString("cityName"),
                                    patient.getString("town"),
                                    patient.getString("townName"),
                                    patient.getString("street"),
                                    patient.getString("streetName"),
                                    patient.getString("address"),
                                    1,
                                    0,
                                    1,
                                    0,
                                    new Date()
                            }
                    );
                }catch (Exception e){
                    e.printStackTrace();
                }
                WlyyUserDetails user = new WlyyUserDetails();
                user.setName(patient.getString("name"));
                user.setPassword(patient.getString("password"));
                if(patient.getInteger("sex") == 1){
                    user.setGender(WlyyUserDetails.Gender.male);
                }else if(patient.getInteger("sex") == 2){
                    user.setGender(WlyyUserDetails.Gender.female);
                }
                user.setId(username);
                user.setIdcard(patient.getString("idcard"));
                user.setMobile(patient.getString("mobile"));
                user.setEnabled(true);
                user.setLocked(false);
                user.setLockedDate(null);
                users.add(user);
            }
        }
        return users;
    }
    /**
     * 设置用户登录时间,返回登录信息
     * 判断loginType,用户类型 1或默认为user,2:医生登录,3:患者登录
     *
     * @param username
     * @return
     * @throws UsernameNotFoundException
     */
    public WlyyUserSimple authSuccess (String username) throws UsernameNotFoundException {
    public WlyyUserSimple authSuccess(String username) throws UsernameNotFoundException {
        //加载用户简略信息
        List<WlyyUserSimple> users = getWlyyUserSimple(username);
        if (users == null || users.size() == 0) {
@ -141,16 +231,16 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
        return users.get(0);
    }
    public String authFailure () throws UsernameNotFoundException {
    public String authFailure() throws UsernameNotFoundException {
        //获取失败次数
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        String username = request.getParameter("username");
        Map<String,Object> map = getLoginFailureCount(username);
        Integer loginFailureCount = Integer.valueOf(map.get("login_failure_count").toString());
        Map<String, Object> map = getLoginFailureCount(username);
        Integer loginFailureCount = null == map.get("login_failure_count") ? 0 : Integer.valueOf(map.get("login_failure_count").toString());
        Object timeObj = map.get("last_login_failure_time");
        if(timeObj == null){
        if (timeObj == null) {
            loginFailureCount = 0;
        }else{
        } else {
            Timestamp timestamp = (Timestamp) timeObj;
            //判断是否得重置登陆次数
            Date date = new Date(timestamp.getTime());
@ -159,49 +249,50 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
                loginFailureCount = 0;
            }
        }
        loginFailureCount ++;
        loginFailureCount++;
        if (loginFailureCount >= tryLoginTimes) {
            locked(username);
            return "账号已被锁定,请"+autoUnlockTime+"分钟后重试!";
            return "账号已被锁定,请" + autoUnlockTime + "分钟后重试!";
        } else {
            addFailureCount(username,loginFailureCount);
            addFailureCount(username, loginFailureCount);
            return "账号或密码错误,还可以再试" + (tryLoginTimes - loginFailureCount) + "次!";
        }
    }
    /**
     * 获取失败次数 返回 map  key1: login_failure_count   失败次数
     *                       key2: last_login_failure_time 上次登录失败时间 /可能为null
     * key2: last_login_failure_time 上次登录失败时间 /可能为null
     *
     * @param username
     * @return
     */
    public Map<String, Object> getLoginFailureCount(String username){
    public Map<String, Object> getLoginFailureCount(String username) {
        Map<String, Object> result = new HashMap<>();
        String loginType = getLogintype();
        if(StringUtils.isBlank(loginType)||"1".equals(loginType)){ //1或默认查找user表,为平台管理员账号
        if (StringUtils.isBlank(loginType) || "1".equals(loginType)) { //1或默认查找user表,为平台管理员账号
            result = this.getJdbcTemplate().queryForMap("select u.login_failure_count,u.last_login_failure_time from base_user u where u.username = ? or u.mobile = ? or u.idcard = ?", username, username, username);
        }else if("2".equals(loginType)){//2.为医生账号
        } else if ("2".equals(loginType)) {//2.为医生账号
            result = this.getJdbcTemplate().queryForMap("select d.login_failure_count,d.last_login_failure_time from base_doctor d where d.mobile = ? or d.idcard = ?", username, username);
        }else if("3".equals(loginType)){ //3.患者账号
            result = this.getJdbcTemplate().queryForMap("select p.login_failure_count,p.last_login_failure_time from base_patient p where p.mobile = ? or p.idcard = ?",username, username);
        } else if ("3".equals(loginType)) { //3.患者账号
            result = this.getJdbcTemplate().queryForMap("select p.login_failure_count,p.last_login_failure_time from base_patient p where p.mobile = ? or p.idcard = ?", username, username);
        }
        return result;
    }
    /**
     * 锁定账号
     *
     * @param username
     */
    public void locked(String username){
    public void locked(String username) {
        String loginType = getLogintype();
        if(StringUtils.isBlank(loginType)||"1".equals(loginType)){ //1或默认查找user表,为平台管理员账号
        if (StringUtils.isBlank(loginType) || "1".equals(loginType)) { //1或默认查找user表,为平台管理员账号
            //账号锁定
            this.getJdbcTemplate().update("update base_user u set u.login_failure_count = 5, u.locked = 1, u.locked_date = ? where u.username = ? or u.mobile = ? or u.idcard = ?", new Date(), username, username, username);
        }else if("2".equals(loginType)){//2.为医生账号
        } else if ("2".equals(loginType)) {//2.为医生账号
            //账号锁定
            this.getJdbcTemplate().update("update base_doctor d set d.login_failure_count = 5, d.locked = 1, d.locked_date = ? where d.mobile = ? or d.idcard = ?", new Date(), username, username);
        }else if("3".equals(loginType)){ //3.患者账号
        } else if ("3".equals(loginType)) { //3.患者账号
            //账号锁定
            this.getJdbcTemplate().update("update base_patient p set p.login_failure_count = 5, p.locked = 1, p.locked_date = ?  where p.mobile = ? or p.idcard = ?", new Date(), username, username);
        } //...
@ -209,20 +300,21 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
    /**
     * 更新登录失败次数
     *
     * @param username
     * @param loginFailureCount
     */
    public void addFailureCount(String username,Integer loginFailureCount){
    public void addFailureCount(String username, Integer loginFailureCount) {
        String loginType = getLogintype();
        if(StringUtils.isBlank(loginType)||"1".equals(loginType)){ //1或默认查找user表,为平台管理员账号
        if (StringUtils.isBlank(loginType) || "1".equals(loginType)) { //1或默认查找user表,为平台管理员账号
            //更新失败次数
            this.getJdbcTemplate().update("update base_user u set u.login_failure_count = ? ,u.last_login_failure_time = ? where u.username = ? or u.mobile = ? or u.idcard = ?", loginFailureCount,new Date(), username, username, username);
        }else if("2".equals(loginType)){//2.为医生账号
            this.getJdbcTemplate().update("update base_user u set u.login_failure_count = ? ,u.last_login_failure_time = ? where u.username = ? or u.mobile = ? or u.idcard = ?", loginFailureCount, new Date(), username, username, username);
        } else if ("2".equals(loginType)) {//2.为医生账号
            //更新失败次数
            this.getJdbcTemplate().update("update base_doctor d set d.login_failure_count = ?, d.last_login_failure_time = ?  where d.mobile = ? or d.idcard = ?", loginFailureCount,new Date(), username, username);
        }else if("3".equals(loginType)){ //3.患者账号
            this.getJdbcTemplate().update("update base_doctor d set d.login_failure_count = ?, d.last_login_failure_time = ?  where d.mobile = ? or d.idcard = ?", loginFailureCount, new Date(), username, username);
        } else if ("3".equals(loginType)) { //3.患者账号
            //更新失败次数
            this.getJdbcTemplate().update("update base_patient p set p.login_failure_count = ? ,p.last_login_failure_time = ? where p.mobile = ? or p.idcard = ?", loginFailureCount,new Date(),username, username);
            this.getJdbcTemplate().update("update base_patient p set p.login_failure_count = ? ,p.last_login_failure_time = ? where p.mobile = ? or p.idcard = ?", loginFailureCount, new Date(), username, username);
        } //...
    }
@ -235,40 +327,46 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
    /**
     * 设置用户登录时间,返回登录信息
     * 判断loginType,用户类型 1或默认为user,2:医生登录,3:患者登录
     *
     * @param username
     * @return
     */
    public List<WlyyUserSimple> getWlyyUserSimple(String username){
    public List<WlyyUserSimple> getWlyyUserSimple(String username) {
        String loginType = getLogintype();
        List<WlyyUserSimple> users = null;
        //1或默认查找user表,为平台管理员账号
        if(StringUtils.isBlank(loginType)||"1".equals(loginType)){
        if (StringUtils.isBlank(loginType) || "1".equals(loginType)) {
            //更新登录时间
            this.getJdbcTemplate().update("update base_user u set u.login_failure_count = 0, u.login_date = ? where u.username = ? or u.mobile = ? or u.idcard = ?", new Date(), username, username, username);
            users = this.getJdbcTemplate().query(DEFAULT_USER_DETAILS_STATEMENT, new BeanPropertyRowMapper(WlyyUserSimple.class), username, username, username);
            //2.为医生登录账号
        }else if("2".equals(loginType)){
        } else if ("2".equals(loginType)) {
            //更新登录时间
            this.getJdbcTemplate().update("update base_doctor d set d.login_failure_count = 0, d.login_date = ? where d.mobile = ? or d.idcard = ?", new Date(), username, username);
            users = this.getJdbcTemplate().query(DEFAULT_DOCTOR_DETAILS_STATEMENT, new BeanPropertyRowMapper(WlyyUserSimple.class), username, username);
            //3.患者登录
        }else if("3".equals(loginType)){
        } else if ("3".equals(loginType)) {
            //更新登录时间
            this.getJdbcTemplate().update("update base_patient p set p.login_failure_count = 0, p.login_date = ? where p.mobile = ? or p.idcard = ?", new Date(), username, username);
            users = this.getJdbcTemplate().query(DEFAULT_PATIENT_DETAILS_STATEMENT, new BeanPropertyRowMapper(WlyyUserSimple.class), username, username);
        } //...
        } else if("4".equals(loginType)){
            //更新登录时间
            this.getJdbcTemplate().update("update base_patient p set p.login_failure_count = 0, p.login_date = ? where p.mobile = ? or p.idcard = ?", new Date(), username, username);
            users = this.getJdbcTemplate().query(DEFAULT_PATIENT_DETAILS_ID_STATEMENT, new BeanPropertyRowMapper(WlyyUserSimple.class), username);
        }
        return users;
    }
    /**
     * 获取用户登录类型
     *
     * @return
     */
    public String getLogintype(){
    public String getLogintype() {
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
@ -277,26 +375,54 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
        return loginType;
    }
    /**
     * 获取i健康用户登录openid型
     *
     * @return
     */
    public String getOpenid() {
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        String openid = request.getParameter("openid");
        return openid;
    }
    /**
     * 获取i健康用户登录openid型
     *
     * @return
     */
    public String getClientId() {
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
    public boolean setRolePhth(String loginType, OAuth2AccessToken token, String id, StringRedisTemplate redisTemplate){
        String clientId = request.getParameter("client_id");
        if(org.apache.commons.lang.StringUtils.isBlank(loginType)||"1".equals(loginType)){ //1或默认查找user表,为平台管理员账号
            String key = "wlyy2:auth:token:"+token.getValue();
            redisTemplate.opsForValue().set(key,"/**");
            redisTemplate.expire(key,token.getExpiresIn(), TimeUnit.SECONDS);
        }else if("2".equals(loginType)){//2.为医生账号
        return clientId;
    }
    public boolean setRolePhth(String loginType, OAuth2AccessToken token, String id, StringRedisTemplate redisTemplate) {
        }else if("3".equals(loginType)){ //3.患者账号
            String key = "wlyy2:auth:token:"+token.getValue();
            redisTemplate.opsForValue().set(key,"/**");
            redisTemplate.expire(key,token.getExpiresIn(), TimeUnit.SECONDS);
        }else{
        if (org.apache.commons.lang.StringUtils.isBlank(loginType) || "1".equals(loginType)) { //1或默认查找user表,为平台管理员账号
            String key = "wlyy2:auth:token:" + token.getValue();
            redisTemplate.opsForValue().set(key, "/**");
            redisTemplate.expire(key, token.getExpiresIn(), TimeUnit.SECONDS);
        } else if ("2".equals(loginType)) {//2.为医生账号
        } else if ("3".equals(loginType) || "4".equals(loginType)) { //3.患者账号
            String key = "wlyy2:auth:token:" + token.getValue();
            redisTemplate.opsForValue().set(key, "/**");
            redisTemplate.expire(key, token.getExpiresIn(), TimeUnit.SECONDS);
        } else {
            return false;
        }
        return true;
    }
    public void updateOpenId(String openid,String userId){
        this.getJdbcTemplate().update("update base_patient p set p.openid = ? where p.id= ?",openid ,userId);
    public void updateOpenId(String openid, String userId) {
        this.getJdbcTemplate().update("update base_patient p set p.openid = ? where p.id= ?", openid, userId);
    }
}

+ 182 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/model/WlyyUserDetails.java

@ -1,5 +1,8 @@
package com.yihu.jw.security.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import javax.persistence.Column;
import java.io.Serializable;
import java.util.Date;
@ -58,6 +61,161 @@ public class WlyyUserDetails implements Serializable {
    //登陆失败次数
    private Integer loginFailureCount;
    /**
     * 生日
     */
//	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    private Date birthday;
    // 性別,1男,2女
    private Integer sex;
    /**
     * 省代码
     */
    private String provinceCode;
    /**
     * 省名称
     */
    private String provinceName;
    /**
     * 市代码
     */
    private String cityCode;
    /**
     * 市名称
     */
    private String cityName;
    /**
     * 区县代码
     */
    private String townCode;
    /**
     * 区县名称
     */
    private String townName;
    /**
     * 街道代码
     */
    private String streetCode;
    /**
     * 街道名称
     */
    private String streetName;
    /**
     * 地址
     */
    private String address;
    /**
     * i健康微信编号
     */
    private String ihealthOpenid;
    /**
     * i健康微信编号添加时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    private Date ihealthOpenidTime;
    public Date getBirthday() {
        return birthday;
    }
    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }
    public String getProvinceCode() {
        return provinceCode;
    }
    public void setProvinceCode(String provinceCode) {
        this.provinceCode = provinceCode;
    }
    public String getProvinceName() {
        return provinceName;
    }
    public void setProvinceName(String provinceName) {
        this.provinceName = provinceName;
    }
    public String getCityCode() {
        return cityCode;
    }
    public void setCityCode(String cityCode) {
        this.cityCode = cityCode;
    }
    public String getCityName() {
        return cityName;
    }
    public void setCityName(String cityName) {
        this.cityName = cityName;
    }
    public String getTownCode() {
        return townCode;
    }
    public void setTownCode(String townCode) {
        this.townCode = townCode;
    }
    public String getTownName() {
        return townName;
    }
    public void setTownName(String townName) {
        this.townName = townName;
    }
    public String getStreetCode() {
        return streetCode;
    }
    public void setStreetCode(String streetCode) {
        this.streetCode = streetCode;
    }
    public String getStreetName() {
        return streetName;
    }
    public void setStreetName(String streetName) {
        this.streetName = streetName;
    }
    public String getIhealthOpenid() {
        return ihealthOpenid;
    }
    public void setIhealthOpenid(String ihealthOpenid) {
        this.ihealthOpenid = ihealthOpenid;
    }
    public Date getIhealthOpenidTime() {
        return ihealthOpenidTime;
    }
    public void setIhealthOpenidTime(Date ihealthOpenidTime) {
        this.ihealthOpenidTime = ihealthOpenidTime;
    }
    public String getId() {
        return id;
    }
@ -217,4 +375,28 @@ public class WlyyUserDetails implements Serializable {
    public void setLoginFailureCount(Integer loginFailureCount) {
        this.loginFailureCount = loginFailureCount;
    }
    public Boolean getEnabled() {
        return enabled;
    }
    public Boolean getLocked() {
        return locked;
    }
    public String getAddress() {
        return address;
    }
    public void setAddress(String address) {
        this.address = address;
    }
    public Integer getSex() {
        return sex;
    }
    public void setSex(Integer sex) {
        this.sex = sex;
    }
}

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

@ -4,6 +4,8 @@ import com.yihu.jw.security.core.userdetails.SaltUser;
import com.yihu.jw.security.oauth2.core.redis.WlyyRedisVerifyCodeService;
import org.springframework.security.authentication.*;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.authority.mapping.GrantedAuthoritiesMapper;
import org.springframework.security.core.authority.mapping.NullAuthoritiesMapper;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
@ -77,6 +79,15 @@ public class WlyyTokenGranter implements TokenGranter {
                        wlyyRedisVerifyCodeService,
                        userDetailsService
                ));
        tokenGranters.put(IhealthOwnerCodeTokenGranter.GRANT_TYPE,
                new IhealthOwnerCodeTokenGranter(
                        authenticationManager,
                        tokenServices,
                        clientDetailsService,
                        requestFactory,
                        userDetailsService
                ));
    }
    public OAuth2AccessToken grant(String grantType, TokenRequest tokenRequest) {
@ -333,5 +344,56 @@ public class WlyyTokenGranter implements TokenGranter {
        }
    }
    /**
     * i健康居民code模式Token授权器。
     */
    public static class IhealthOwnerCodeTokenGranter extends AbstractTokenGranter {
        private static final String GRANT_TYPE = "ihealthCode";
        private final AuthenticationManager authenticationManager;
        private final UserDetailsService userDetailsService;
        private GrantedAuthoritiesMapper authoritiesMapper = new NullAuthoritiesMapper();
        public IhealthOwnerCodeTokenGranter(AuthenticationManager authenticationManager,
                                       AuthorizationServerTokenServices tokenServices,
                                       ClientDetailsService clientDetailsService,
                                       OAuth2RequestFactory requestFactory,
                                       UserDetailsService userDetailsService) {
            this(authenticationManager, tokenServices, clientDetailsService, requestFactory, userDetailsService, GRANT_TYPE);
        }
        protected IhealthOwnerCodeTokenGranter(AuthenticationManager authenticationManager,
                                          AuthorizationServerTokenServices tokenServices,
                                          ClientDetailsService clientDetailsService,
                                          OAuth2RequestFactory requestFactory,
                                          UserDetailsService userDetailsService,
                                          String grantType) {
            super(tokenServices, clientDetailsService, requestFactory, grantType);
            this.authenticationManager = authenticationManager;
            this.userDetailsService = userDetailsService;
        }
        @Override
        protected OAuth2Authentication getOAuth2Authentication(ClientDetails client, TokenRequest tokenRequest) {
            Map<String, String> parameters = new LinkedHashMap<String, String>(tokenRequest.getRequestParameters());
            String username = parameters.get("username");
            SaltUser userDetails = (SaltUser)userDetailsService.loadUserByUsername(username);
            if (!userDetails.isEnabled()) {
                throw new InvalidGrantException("User is disabled");
            }
            if (!userDetails.isAccountNonLocked()) {
                throw new InvalidGrantException("User account is locked");
            }
//            parameters.put("password",userDetails.getPassword());
            Authentication userAuth = new UsernamePasswordAuthenticationToken(username,userDetails.getPassword(),  this.authoritiesMapper.mapAuthorities(userDetails.getAuthorities()));
            ((AbstractAuthenticationToken) userAuth).setDetails(parameters);
            OAuth2Request storedOAuth2Request = getRequestFactory().createOAuth2Request(client, tokenRequest);
            return new OAuth2Authentication(storedOAuth2Request, userAuth);
        }
    }
}

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

@ -129,17 +129,19 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
                String password = com.yihu.jw.security.utils.RSAUtils.decryptBase64(parameters.get("password"),keyPair);
                parameters.put("password",password);
//                parameters.put("password", RSAUtils.decryptByPrivateKey(parameters.get("password"), rsaPrivateKey));
            }else {
                parameters.put("grant_type", "ihealthCode");
            }
        } else {
            parameters.put("grant_type", "captcha");
        }
        ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
        TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
        if (authenticatedClient != null) {
            oAuth2RequestValidator.validateScope(tokenRequest, authenticatedClient);
        if(null == authenticatedClient){
            throw new InvalidRequestException("client_id");
        }
        TokenRequest tokenRequest = oAuth2RequestFactory.createTokenRequest(parameters, authenticatedClient);
        oAuth2RequestValidator.validateScope(tokenRequest, authenticatedClient);
        OAuth2AccessToken token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
        if (token == null) {
            throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());

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

@ -33,11 +33,11 @@ user:
spring:
  profiles: jwdev
  datasource:
    url: jdbc:mysql://172.19.103.77/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
    username: root
    password: 123456
    url: jdbc:mysql://172.26.0.114/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
    username: jkzl
    password: jkzlehr
  redis:
    host: 172.19.103.88 # Redis server host.
    host: 172.26.0.253 # Redis server host.
    port: 6379 # Redis server port.
#    password: jkzl_ehr
---

+ 8 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/DictHospitalDeptService.java

@ -95,4 +95,12 @@ public class DictHospitalDeptService extends BaseJpaService<DictHospitalDeptDO,
       return dictHospitalDeptDao.findByOrgCode(orgCode);
    }
    /**
     * 批量保存
     * @return
     */
    public void saveBatch(List<DictHospitalDeptDO> dictHospitalDeptDOS)throws Exception{
        dictHospitalDeptDao.save(dictHospitalDeptDOS);
    }
}

+ 27 - 0
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/config/bean/BeanConfig.java

@ -0,0 +1,27 @@
package com.yihu.jw.entrance.config.bean;
import com.yihu.jw.hospital.prescription.service.PrescriptionExpressageService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class BeanConfig {
    //顺丰快递接口请求地址
    @Value("${express.sf_url}")
    private String sf_url;
    //顺丰快递接口接入编码
    @Value("${express.sf_code}")
    private String sf_code;
    //顺丰快递接口checkword
    @Value("${express.sf_check_word}")
    private String sf_check_word;
    @Bean(name = "prescriptionExpressageService")
    PrescriptionExpressageService prescriptionExpressageService(){
        return new PrescriptionExpressageService(sf_url,sf_code,sf_check_word);
    }
}

+ 54 - 33
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/MqSdkController.java

@ -1,9 +1,10 @@
package com.yihu.jw.entrance.controller;
import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import com.yihu.jw.entity.hospital.dict.WlyyChargeDictDO;
import com.yihu.jw.entity.hospital.mapping.HospitalDeptMappingDO;
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.util.ConvertUtil;
import com.yihu.jw.restmodel.hospital.prescription.WlyyOutpatientVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
import com.yihu.jw.restmodel.web.ListEnvelop;
@ -12,7 +13,6 @@ import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import net.sf.json.JSON;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -20,7 +20,6 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
@ -80,15 +79,13 @@ public class MqSdkController extends EnvelopRestEndpoint {
    @ApiOperation(value = " 查询某个时间段的患者门诊就诊记录 V1.00")
    public ListEnvelop BS30025(@ApiParam(name = "patNo", value = "居民id")
                               @RequestParam(value = "patNo", required = false) String patNo,
                               @ApiParam(name = "admNo", value = "就诊唯一号")
                               @RequestParam(value = "admNo", required = false) String admNo,
                               @ApiParam(name = "registerSn", value = "流水号(处方号)")
                               @RequestParam(value = "registerSn", required = false) String registerSn,
                               @ApiParam(name = "conNo", value = "就诊次数")
                               @RequestParam(value = "conNo", required = false) String conNo,
                               @ApiParam(name = "startTime", value = "开始时间")
                               @RequestParam(value = "startTime", required = false) String startTime,
                               @ApiParam(name = "endTime", value = "结束时间")
                               @RequestParam(value = "endTime", required = false) String endTime) throws Exception {
        List<WlyyOutpatientVO> obj = entranceService.BS30025(patNo,admNo,registerSn, startTime, endTime, demoFlag);
        List<WlyyOutpatientVO> obj = entranceService.BS30025(patNo,conNo, startTime, endTime, demoFlag);
        return success(obj);
    }
@ -176,15 +173,17 @@ public class MqSdkController extends EnvelopRestEndpoint {
    @GetMapping(value = "/MS02001")
    @ApiOperation(value = "科室字典  ")
    public ListEnvelop MS02001() throws Exception {
        List<HospitalDeptMappingDO> obj = entranceService.MS02001(demoFlag);
        //TODO 待解析 存储入库
        List<DictHospitalDeptDO> obj = entranceService.MS02001(demoFlag);
        return success(obj);
    }
    @GetMapping(value = "/MS02013")
    @ApiOperation(value = "号别字典接口   ")
    public ListEnvelop MS02013() throws Exception {
        JSONArray obj = entranceService.MS02013(demoFlag);
    public ListEnvelop MS02013(
            @ApiParam(name = "code", value = "号别字典")
            @RequestParam(value = "code", required = false) String code
    ) throws Exception {
        JSONArray obj = entranceService.MS02013(code);
        return success(obj);
    }
@ -240,27 +239,6 @@ public class MqSdkController extends EnvelopRestEndpoint {
    }
    @GetMapping(value = "/MS25002")
    @ApiOperation(value = " 检查检验字典接口 ")
    public String MS25002( @ApiParam(name = "pyCode", value = "拼音码")
                           @RequestParam(value = "pyCode", required = false) String pyCode,
                           @ApiParam(name = "winNo", value = "库存")
                           @RequestParam(value = "winNo", required = false) String winNo) {
        try {
            String  obj="";
            if(!testProfiles){
                obj=  entranceService.MS25002(pyCode,winNo);
            }else {
                obj="{\"code\":\"1\",\"MsgInfo\":[{\"resquest\":{\"@RESULT\":\"-1\",\"@MSG\":\"该医生无权挂号该科室!\"}}]}";
            }
            System.out.println("obj=="+obj);
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }
        return "";
    }
    @GetMapping(value = "/yytDown")
    @ApiOperation(value = " 银医通下载 ")
    public ObjEnvelop yytDown(
@ -292,6 +270,16 @@ public class MqSdkController extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "/MS25002")
    @ApiOperation(value = " 检查检验字典接口 ")
    public ListEnvelop MS25002( @ApiParam(name = "pyCode", value = "拼音码")
                           @RequestParam(value = "pyCode", required = false) String pyCode,
                           @ApiParam(name = "winNo", value = "库存")
                           @RequestParam(value = "winNo", required = false) String winNo) throws Exception {
        JSONArray obj = entranceService.MS25002(pyCode, winNo);
        return success(obj);
    }
    @GetMapping(value = "/BS25017")
    @ApiOperation(value = "影像信息表")
    public ListEnvelop BS25017(@ApiParam(name = "patNo", value = "居民id")
@ -302,6 +290,39 @@ public class MqSdkController extends EnvelopRestEndpoint {
            return success(obj);
    }
    //检验的是通过BS20010先查出applyno 这个,然后去查BS20019
    @GetMapping(value = "/BS20019")
    @ApiOperation(value = "检验")
    public ListEnvelop BS20019(@ApiParam(name = "patNo", value = "居民id")
                               @RequestParam(value = "patNo",required = false) String patNo,
                               @ApiParam(name = "conNo", value = "就诊次数")
                               @RequestParam(value = "conNo",required = false) String conNo) throws Exception{
        JSONArray  obj = entranceService.BS20019(patNo,conNo,demoFlag);
        return success(obj);
    }
    //微生物的是先查BS20018,也是查出applyno 再去查BS20011
    @GetMapping(value = "/BS20011")
    @ApiOperation(value = "微生物")
    public ListEnvelop BS20011(@ApiParam(name = "patNo", value = "居民id")
                               @RequestParam(value = "patNo",required = false) String patNo,
                               @ApiParam(name = "conNo", value = "就诊次数")
                               @RequestParam(value = "conNo",required = false) String conNo) throws Exception{
        JSONArray  obj = entranceService.BS20011(patNo,conNo,demoFlag);
        return success(obj);
    }
    @GetMapping(value = "/BS55010")
    @ApiOperation(value = "医生号别及诊查费")
    public ListEnvelop BS55010(@ApiParam(name = "windowsNo", value = "分部号")
                               @RequestParam(value = "windowsNo", required = false) String windowsNo,
                               @ApiParam(name = "chargeType", value = "号别")
                               @RequestParam(value = "chargeType", required = false) String chargeType,
                               @ApiParam(name = "code", value = "医生编码")
                               @RequestParam(value = "code", required = false) String code) throws Exception {
        List<WlyyChargeDictDO> obj = entranceService.BS55010(windowsNo, code,chargeType, demoFlag);
        return success(obj);
    }
}

+ 209 - 0
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/expressage/ExpressageEndpoint.java

@ -0,0 +1,209 @@
package com.yihu.jw.entrance.controller.expressage;
import com.yihu.jw.entity.hospital.prescription.WlyyExpressagePriceDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionExpressageDO;
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
import com.yihu.jw.hospital.prescription.service.PrescriptionExpressageService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.net.URLDecoder;
import java.util.List;
@RestController
@RequestMapping(value = BaseHospitalRequestMapping.Expressage.PREFIX)
@Api(value = "门诊处方快递物流管理器", description = "门诊处方快递物流管理器", tags = {"wlyy基础服务 - 门诊处方快递物流管理服务接口"})
public class ExpressageEndpoint extends EnvelopRestEndpoint {
    private static Logger logger = LoggerFactory.getLogger(ExpressageEndpoint.class);
    @Autowired
    private PrescriptionExpressageService sfexpressService;
    @Autowired
    private OutpatientDao outpatientDao;
    private String successxml = "<Response service='RoutePushService'><Head>OK</Head></Response>";
    private String failedxml = "<Response service='RoutePushService'><Head>ERR</Head><ERROR code='-1'>系统发生数据错误或运行时异常</ERROR></Response>";
    @RequestMapping(value="/routepushservice",method = RequestMethod.POST)
    @ApiOperation("接受顺丰推送过来的路由信息")
    public Envelop SFRoutePushService (
            @ApiParam(name="content", value="入参报文") @RequestParam(value = "content",required = true) String content){
        try {
            content = URLDecoder.decode(content,"utf-8");
            logger.info("顺丰路由信息推送,xml="+content);
            sfexpressService.SFRoutePushService(content);
            return success(successxml);
        }catch (Exception e){
            logger.error("接收顺丰路由信息推送失败,入参xml:"+content);
            //日志文件中记录异常信息
            //返回接口异常信息处理结果
            return failed(failedxml);
        }
    }
    @RequestMapping(value="/sfrouteserviceSearch",method = RequestMethod.GET)
    @ApiOperation("通过门诊编号查询顺丰物流派送记录")
    public Envelop SFRouteServiceSearch(@ApiParam(name="outpatientId", value="门诊编号") @RequestParam(value = "outpatientId",required = true) String outpatientId){
        try {
            List<WlyyPrescriptionExpressageDO> expressageDOList = sfexpressService.findByField("outpatientId",outpatientId);
            if(CollectionUtils.isEmpty(expressageDOList)){
                return failed("当前门诊没有物流信息!");
            }
            WlyyPrescriptionExpressageDO sfexpress_obj = expressageDOList.get(0);
            String result  = sfexpressService.getRoutInfosSearch(sfexpress_obj);
            return success(result);
        }catch (Exception e){
            //返回接口异常信息处理结果
            return failed( "查询失败,"+e.getMessage());
        }
    }
    @RequestMapping(value = "/getsfexpressprice", method = RequestMethod.GET)
    @ApiOperation("根据收寄地址获取快递费用")
    public Envelop SFExpressPrice(
//            @ApiParam(name = "j_city", value = "寄方地址(城市),默认为厦门", defaultValue = "厦门")
//            @RequestParam(value = "j_city", required = false) String j_city,
            @ApiParam(name = "d_province", value = "收方地址(省份)")
            @RequestParam(value = "d_province", required = false) String d_province,
            @ApiParam(name = "d_city", value = "收方地址(城市)")
            @RequestParam(value = "d_city", required = false) String d_city){
        try {
            WlyyExpressagePriceDO expreprice = sfexpressService.getSFExpressPrice(d_province,d_city);
            return success(expreprice);
        }catch (Exception e){
            //返回接口异常信息处理结果
            return failed("获取快递费用,"+e.getMessage());
        }
    }
    @RequestMapping(value = "/sforderfilterservice", method = RequestMethod.GET)
    @ApiOperation("查询派送地址是否属于顺丰的派送范围")
    public Envelop SFOrderFilterService(
            @ApiParam(name = "d_address", value = "派送地址", defaultValue = "福建省厦门市思明区软件园二期望海路55号")
            @RequestParam(value = "d_address", required = true) String d_address){
        try {
            boolean result = sfexpressService.getSFOrderFilterService(d_address);
            if(result){
                return success("地址可派送!");
            }else{
                return failed("地址不可派送!");
            }
        }catch (Exception e){
            return failed("异常:"+e.getMessage());
        }
    }
    @RequestMapping(value="/sforderservice",method = RequestMethod.POST)
    @ApiOperation("向顺丰快递下订单")
    public Envelop SFOrderService(
            @ApiParam(name="outpatientId", value="门诊编号") @RequestParam(value = "outpatientId",required = true) String outpatientId){
        try {
            List<WlyyPrescriptionExpressageDO> expressageDOList = sfexpressService.findByField("outpatientId",outpatientId);
            if(CollectionUtils.isEmpty(expressageDOList)){
                return failed("顺丰快递下单失败,未找到该处方的派送地址!");
            }else{
                WlyyPrescriptionExpressageDO sfexpress_obj = expressageDOList.get(0);
                //如果该处方的快递单号已生成,则说明已经下单成功,不需要重复下单,直接返回成功
                if(StringUtils.isNotBlank(sfexpress_obj.getMailno())){
                    return success("顺丰快递下单成功!");
                }else{
                    //如果该处方的快递单号未生成,则继续下单
                    //由于下单前已经判断过是否派送,这里不再重复判断----huangwenjie-2017.08.04
                    //先判断地址是否可派送boolean delivery = sfexpressService.getSFOrderFilterService(sfexpress_obj.getProvinceName()+sfexpress_obj.getCityName()+sfexpress_obj.getTownName()+sfexpress_obj.getAddress());
                    //根据业务订单号判断是否已经下单成功
                    boolean go_on = sfexpressService.sfOrderSearchService(sfexpress_obj);
                    //如果该业务订单号未下单成功过,则重新下单
                    if(go_on){
                        //请求顺丰接口下单,成功下单后,返回快递单号
                        sfexpress_obj = sfexpressService.postSFOrderService(sfexpress_obj);
                        //保存快递单号和增加处方物流记录为配送
                        sfexpressService.updatePrescriptionExpressage(sfexpress_obj);
                    }
                    return success("顺丰快递下单成功!");
                }
            }
        }catch (Exception e){
            //返回接口异常信息处理结果
            return failed(e.getMessage());
        }
    }
    @RequestMapping(value="/sfgetorderinfoservice",method = RequestMethod.GET)
    @ApiOperation("通过门诊编号查询顺丰快递单信息(不包含物流记录)")
    public Envelop SFGetOrderInfo(
            @ApiParam(name="outpatientId", value="门诊编号") @RequestParam(value = "outpatientId",required = true) String outpatientId){
        try {
            List<WlyyPrescriptionExpressageDO> expressageDOList = sfexpressService.findByField("outpaitentId",outpatientId);
            if(CollectionUtils.isEmpty(expressageDOList)){
                return failed( "查询失败,");
            }
            WlyyPrescriptionExpressageDO sfexpress_obj = expressageDOList.get(0);
            return success(sfexpress_obj);
        }catch (Exception e) {
            return failed("查询失败," + e.getMessage());
        }
    }
    @RequestMapping(value="/sfordersearchservice",method = RequestMethod.GET)
    @ApiOperation("通过门诊编号查询顺丰快递是否下单成功")
    public Envelop SFOrderSearchService(
            @ApiParam(name="outpatientId", value="门诊编号") @RequestParam(value = "outpatientId",required = true) String outpatientId){
        List<WlyyPrescriptionExpressageDO> expressageDOList = sfexpressService.findByField("outpaitentId",outpatientId);
        if(CollectionUtils.isEmpty(expressageDOList)){
            return failed( "查询失败,");
        }
        try {
            WlyyPrescriptionExpressageDO sfexpress_obj = expressageDOList.get(0);
            boolean go_on = sfexpressService.sfOrderSearchServiceJustSearch(sfexpress_obj);
            return success(go_on);
        }catch (Exception e) {
            return failed("查询失败," + e.getMessage());
        }
    }
    @RequestMapping(value="/sforderConfirm",method = RequestMethod.GET)
    @ApiOperation("通过快递单号取消快递")
    public Envelop sforderConfirm(
            @ApiParam(name="mailno", value="快递单号") @RequestParam(value = "mailno",required = true) String mailno){
        List<WlyyPrescriptionExpressageDO> expressageDOList = sfexpressService.findByField("mailno",mailno);
        if(CollectionUtils.isEmpty(expressageDOList)){
            return failed( "当前快递单号的门诊不存在,");
        }
        try {
            WlyyPrescriptionExpressageDO sfexpress_obj = expressageDOList.get(0);
            String result = sfexpressService.postOrderConfirmService(sfexpress_obj);
            return success(result);
        }catch (Exception e) {
            return failed("异常," + e.getMessage());
        }
    }
}

+ 106 - 0
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/expressage/WlyyPatientExpressageAddrEndpoint.java

@ -0,0 +1,106 @@
package com.yihu.jw.entrance.controller.expressage;
import com.yihu.jw.entrance.service.WlyyPatientExpressageAddrService;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPatientExpressageAddrVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
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.*;
import java.util.List;
import com.yihu.jw.entity.hospital.prescription.WlyyPatientExpressageAddrDO;
/**
 * 居民收获地址控制器
 *
 * @version <pre>
 * Author	Version		Date		Changes
 * Administrator 	1.0  		2019年06月12日 	Created
 *
 * </pre>
 * @since 1.
 */
@RestController
@RequestMapping(value = BaseHospitalRequestMapping.WlyyPatientExpressageAddr.PREFIX)
@Api(value = "居民收获地址管理", description = "居民收获地址管理服务接口", tags = {"wlyy基础服务 - 居民收获地址管理服务接口"})
public class WlyyPatientExpressageAddrEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private WlyyPatientExpressageAddrService wlyyPatientExpressageAddrService;
    @PostMapping(value = BaseHospitalRequestMapping.WlyyPatientExpressageAddr.CREATE)
    @ApiOperation(value = "创建")
    public Envelop create(
            @ApiParam(name = "jsonData", value = "Json数据", required = true)
            @RequestParam String jsonData) throws Exception {
        StringBuilder log = new StringBuilder();
        WlyyPatientExpressageAddrDO addrDO = wlyyPatientExpressageAddrService.createAddr(jsonData,log);
        if(!StringUtils.isEmpty(log.toString())){
            return failed(log.toString());
        }
        return success(addrDO, WlyyPatientExpressageAddrVO.class);
    }
    @PostMapping(value = BaseHospitalRequestMapping.WlyyPatientExpressageAddr.DELETE)
    @ApiOperation(value = "删除")
    public Envelop delete(
            @ApiParam(name = "ids", value = "id串,中间用,分隔", required = true)
            @RequestParam(value = "ids") String ids) {
        wlyyPatientExpressageAddrService.delete(ids.split(","));
        return success("删除成功");
    }
    @PostMapping(value = BaseHospitalRequestMapping.WlyyPatientExpressageAddr.UPDATE)
    @ApiOperation(value = "更新")
    public ObjEnvelop<WlyyPatientExpressageAddrVO> update(
            @ApiParam(name = "jsonData", value = "Json数据", required = true)
            @RequestParam String jsonData) throws Exception {
        WlyyPatientExpressageAddrDO wlyyPatientExpressageAddr = toEntity(jsonData, WlyyPatientExpressageAddrDO.class);
        if (null == wlyyPatientExpressageAddr.getId()) {
            return failed("ID不能为空", ObjEnvelop.class);
        }
        wlyyPatientExpressageAddr = wlyyPatientExpressageAddrService.save(wlyyPatientExpressageAddr);
        return success(wlyyPatientExpressageAddr, WlyyPatientExpressageAddrVO.class);
    }
    @GetMapping(value = BaseHospitalRequestMapping.WlyyPatientExpressageAddr.PAGE)
    @ApiOperation(value = "获取分页")
    public PageEnvelop<WlyyPatientExpressageAddrVO> page(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        List<WlyyPatientExpressageAddrDO> wlyyPatientExpressageAddrs = wlyyPatientExpressageAddrService.search(fields, filters, sorts, page, size);
        int count = (int) wlyyPatientExpressageAddrService.getCount(filters);
        return success(wlyyPatientExpressageAddrs, count, page, size, WlyyPatientExpressageAddrVO.class);
    }
    @GetMapping(value = BaseHospitalRequestMapping.WlyyPatientExpressageAddr.LIST)
    @ApiOperation(value = "获取列表")
    public ListEnvelop<WlyyPatientExpressageAddrVO> list(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        List<WlyyPatientExpressageAddrDO> wlyyPatientExpressageAddrs = wlyyPatientExpressageAddrService.search(fields, filters, sorts);
        return success(wlyyPatientExpressageAddrs, WlyyPatientExpressageAddrVO.class);
    }
}

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

@ -29,11 +29,11 @@ public class PrescriptionUpdateController extends EnvelopRestEndpoint {
    @GetMapping(value = "/preUpdate")
    @ApiOperation(value = "药房配药his提示处方变更")
    public ObjEnvelop prescriptionUpdate(
            @ApiParam(name = "admNo", value = "卡号", required = true)
            @ApiParam(name = "admNo", value = "门诊就诊唯一号", required = true)
            @RequestParam(value = "admNo") String admNo,
            @ApiParam(name = "realOrder", value = "处方号", required = true)
            @RequestParam(value = "realOrder") String realOrder,
            @ApiParam(name = "status", value = "处方状态", required = true)
            @ApiParam(name = "status", value = "处方状态:1审方失败,2审核完成,3结算完成", required = true)
            @RequestParam(value = "status") String status) {
        try {
            boolean obj= prescriptionService.updatePrescriptionByHisStatu(admNo,realOrder,status);

+ 21 - 0
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/dao/WlyyPatientExpressageAddrDao.java

@ -0,0 +1,21 @@
package com.yihu.jw.entrance.dao;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.jw.entity.hospital.prescription.WlyyPatientExpressageAddrDO;
/**
 * 
 * 居民收获地址 数据库访问层
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * Administrator 	1.0  		2019年06月12日 	Created
 *
 * </pre>
 * @since 1.
 */
public interface WlyyPatientExpressageAddrDao extends PagingAndSortingRepository<WlyyPatientExpressageAddrDO, String>, JpaSpecificationExecutor<WlyyPatientExpressageAddrDO>  {
}

+ 39 - 0
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/service/WlyyPatientExpressageAddrService.java

@ -0,0 +1,39 @@
package com.yihu.jw.entrance.service;
import com.yihu.jw.entrance.dao.WlyyPatientExpressageAddrDao;
import com.yihu.jw.utils.EntityUtils;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.stereotype.Service;
import com.yihu.jw.entity.hospital.prescription.WlyyPatientExpressageAddrDO;
/**
 * 居民收获地址服务service
 *
 * @version <pre>
 * Author	Version		Date		Changes
 * Administrator    1.0  2019年06月12日 Created
 *
 * </pre>
 * @since 1.
 */
@Service
public class WlyyPatientExpressageAddrService extends BaseJpaService<WlyyPatientExpressageAddrDO, WlyyPatientExpressageAddrDao> {
    /**
     * 新增居民收货地址
     * @param jsonData
     * @param error
     * @return
     */
    public WlyyPatientExpressageAddrDO createAddr(String jsonData, StringBuilder error) {
        WlyyPatientExpressageAddrDO addrDO = null;
        try {
            addrDO = EntityUtils.jsonToEntity(jsonData,WlyyPatientExpressageAddrDO.class);
        } catch (Exception e) {
            error.append(e.getMessage());
            return null;
        }
        this.save(addrDO);
        return addrDO;
    }
}

+ 31 - 83
svr/svr-internet-hospital-entrance/src/main/resources/application.yml

@ -1,6 +1,7 @@
#通用的配置不用区分环境变量
server:
  port: ${server.svr-internet-hospital-entrance-port}
#  port: ${server.svr-internet-hospital-entrance-port}
  port: 10023
spring:
  datasource:
@ -37,6 +38,12 @@ fast-dfs:
configDefault: # 默认配置
  saasId: xmjkzl_saasId
express:
  sf_url: http://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService
  sf_code: JKZL
  sf_check_word: QkeIfIvQdheqIv2cVSgAUnBU29lfNbVk
---
spring:
  profiles: jwdev
@ -48,37 +55,11 @@ spring:
# mq 是否获取his数据,flag代表获取演示数据,false代表获取his真实数据
demo:
  flag: true
#  elasticsearch:
#    cluster-name: jkzl #集群名 默认elasticsearch
#    cluster-nodes: 172.26.0.115:9300,172.26.0.115:9300 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode
#    client-transport-sniff: false
#    jest:
#      uris: http://172.26.0.112:9200,http://172.26.0.112:9200
#      connection-timeout: 60000 # Connection timeout in milliseconds.
#      multi-threaded: true # Enable connection requests from multiple execution threads.
#  activemq:
#    broker-url: tcp://172.26.0.116:61616
#    user: admin
#    password: admin
#  redis:
#    host: 172.26.0.253 # Redis server host.
#    port: 6379 # Redis server port.
#    password: jkzl_ehr
#  zipkin:
#    base-url: http://localhost:9411 #日志追踪的地址
#
#fastDFS:
#  fastdfs_file_url: http://172.26.0.110:22122/
## 短信发送地址
#jw:
#  smsUrl: http://svr-base:10020/sms_gateway/send
#myFamily:
#  qrCodeFailurTime: 2
#wechat:
#  id: d24d1367-7f4f-43af-910e-a0a43799e040  # base库中,wx_wechat 的id字段
## 短信验证码发送的客户端标识,居民端
#sms:
#  clientId: EwC0iRSrcP
hospital:
  mqUser: JKZL
  mqPwd: 123456
  SourceSysCode: S60
  TargetSysCode: S01
---
spring:
  profiles: jwtest
@ -86,33 +67,15 @@ spring:
    url: jdbc:mysql://172.26.0.104/base?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true
    username: ssgg
    password: ssgg@jkzl2019
#    url: jdbc:mysql://172.19.103.77/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
#    username: root
#    password: 123456
  elasticsearch:
    cluster-name: jkzl #集群名 默认elasticsearch
    cluster-nodes: 172.26.0.115:9300,172.26.0.115:9300 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode
    client-transport-sniff: false
    jest:
      uris: http://172.26.0.112:9200,http://172.26.0.112:9200
      connection-timeout: 60000 # Connection timeout in milliseconds.
      multi-threaded: true # Enable connection requests from multiple execution threads.
  activemq:
    broker-url: tcp://172.26.0.116:61616
    user: admin
    password: admin
  redis:
    host: 172.26.0.253 # Redis server host.
    port: 6379 # Redis server port.
fastDFS:
  fastdfs_file_url: http://172.26.0.110:22122/
wechat:
  id: 97ed8a0a-4f07-4b85-ab02-b716c611a464  # base库中,wx_wechat 的id字段
# 短信验证码发送的客户端标识,居民端
sms:
  clientId: EwC0iRSrcP
myFamily:
  qrCodeFailurTime: 2
# mq 是否获取his数据,flag代表获取演示数据,false代表获取his真实数据
demo:
  flag: true
hospital:
  mqUser: JKZL
  mqPwd: 123456
  SourceSysCode: S60
  TargetSysCode: S01
---
spring:
  profiles: prod
@ -120,27 +83,12 @@ spring:
    url: jdbc:mysql://59.61.92.90:9069/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
    username: wlyy
    password: jkzlehr@123
  elasticsearch:
    cluster-name: jkzl #集群名 默认elasticsearch
    cluster-nodes: 59.61.92.90:9066,59.61.92.90:9068 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode
    client-transport-sniff: false
    jest:
      uris: http://59.61.92.90:9065,http://59.61.92.90:9067
      connection-timeout: 60000 # Connection timeout in milliseconds.
      multi-threaded: true # Enable connection requests from multiple execution threads.
  activemq:
    broker-url: tcp://59.61.92.90:9103
    user: jkzl
    password: jkzlehr
  redis:
    host: 192.168.131.172 # Redis server host.
    port: 6379 # Redis server port.
fastDFS:
  fastdfs_file_url: http://172.19.103.54:80/
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040  # base库中,wx_wechat 的id字段  # todo 待配置
# 短信验证码发送的客户端标识,居民端
sms:
  clientId: EwC0iRSrcP #todo 待配置
myFamily:
  qrCodeFailurTime: 2
# mq 是否获取his数据,flag代表获取演示数据,false代表获取his真实数据
demo:
  flag: false
hospital:
  mqUser: JKZL
  mqPwd: 123456
  SourceSysCode: S60
  TargetSysCode: S01

+ 14 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/config/JpaConfig.java

@ -0,0 +1,14 @@
package com.yihu.jw.hospital.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.orm.jpa.JpaTransactionManager;
@Configuration
public class JpaConfig {
    @Bean
    public JpaTransactionManager transactionManager(){
        return new JpaTransactionManager();
    }
}

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

@ -0,0 +1,72 @@
package com.yihu.jw.hospital.endpoint.file_upload;
import com.yihu.jw.file_upload.FileUploadService;
import com.yihu.jw.restmodel.iot.common.UploadVO;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.InputStream;
/**
 * 文件上传公共类
 */
@RestController
@RequestMapping(BaseRequestMapping.FileUpload.PREFIX)
@Api(tags = "文件上传相关操作", description = "文件上传相关操作")
public class FileUploadEndpoint extends EnvelopRestEndpoint {
    @Value("${fastDFS.fastdfs_file_url}")
    private String fastdfs_file_url;
    @Autowired
    FileUploadService fileUploadService;
    @PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STREAM_IMG)
    @ApiOperation(value = "文件流上传图片", notes = "文件流上传图片")
    public ObjEnvelop<UploadVO> uploadImg(@ApiParam(value = "文件", required = true)
                                       @RequestParam(value = "file", required = true) MultipartFile file) throws Exception{
        // 得到文件的完整名称  xxx.txt
        String originalFilename = file.getOriginalFilename();
        InputStream inputStream = file.getInputStream();
        UploadVO uploadVO = fileUploadService.uploadImg(inputStream,originalFilename,file.getSize(),fastdfs_file_url);
        return success("上传成功", uploadVO);
    }
    @PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STREAM_ATTACHMENT)
    @ApiOperation(value = "文件流上传附件", notes = "文件流上传附件")
    public ObjEnvelop<UploadVO> uploadAttachment(@ApiParam(value = "文件", required = true)
                                       @RequestParam(value = "file", required = true) MultipartFile file) throws Exception{
        String originalFilename = file.getOriginalFilename();
        InputStream inputStream = file.getInputStream();
        UploadVO uploadVO = fileUploadService.uploadAttachment(inputStream,originalFilename,file.getSize(),fastdfs_file_url);
        return success("上传成功", uploadVO);
    }
    @PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STREAM)
    @ApiOperation(value = "文件流上传文件", notes = "文件流上传文件")
    public ObjEnvelop<UploadVO> uploadStream(@ApiParam(value = "文件", required = true)
                                                 @RequestParam(value = "file", required = true) MultipartFile file) throws Exception{
        // 得到文件的完整名称  xxx.txt
        String originalFilename = file.getOriginalFilename();
        InputStream inputStream = file.getInputStream();
        UploadVO uploadVO = fileUploadService.uploadStream(inputStream,originalFilename,fastdfs_file_url);
        return success("上传成功", uploadVO);
    }
    @PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STRING)
    @ApiOperation(value = "base64上传图片",notes = "base64上传图片")
    public ObjEnvelop<UploadVO> uploadImages(@ApiParam(name = "jsonData", value = "头像转化后的输入流")
                                                 @RequestBody String jsonData) throws Exception {
        UploadVO uploadVO = fileUploadService.uploadImages(jsonData,fastdfs_file_url);
        return success("上传成功", uploadVO);
    }
}

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

@ -1,6 +1,8 @@
package com.yihu.jw.hospital.endpoint.prescription;
import com.yihu.jw.hospital.prescription.service.PrescriptionService;
import com.yihu.jw.restmodel.base.dict.DictHospitalDeptVO;
import com.yihu.jw.restmodel.base.org.BaseOrgVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyOutpatientVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
import com.yihu.jw.restmodel.web.ListEnvelop;
@ -12,13 +14,13 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
@ -37,7 +39,7 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    private boolean demoFlag;
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findOutpatientList)
    @ApiOperation(value = " 查询某个时间段的患者门诊就诊记录 V1.00")
    @ApiOperation(value = " 查询某个时间段的患者门诊就诊记录")
    public ListEnvelop findOutpatientList(@ApiParam(name = "patient", value = "居民id")
                               @RequestParam(value = "patient",required = false) String patient,
                               @ApiParam(name = "startTime", value = "开始时间")
@ -48,6 +50,16 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        return success(vos);
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findOutpatientInfo)
    @ApiOperation(value = " 查询单条门诊就诊记录")
    public ObjEnvelop findOutpatientInfo(@ApiParam(name = "patient", value = "居民id")
                                         @RequestParam(value = "patient",required = false) String patient,
                                         @ApiParam(name = "conNo", value = "就诊次数")
                                         @RequestParam(value = "conNo",required = false) String conNo)throws Exception{
        WlyyOutpatientVO obj = prescriptionService.findOutpatientInfo(patient,conNo);
        return success(obj);
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findOriginPrescriptionList)
    @ApiOperation(value = "门诊下所有处方信息")
    public ListEnvelop findOriginPrescriptionList(
@ -112,7 +124,17 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        return prescriptionService.findReOutpatientList(patient,status,startTime,endTime,page,size);
    }
        @GetMapping(value = BaseHospitalRequestMapping.Prescription.findPrescriptionInfo)
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findReOutpatientInfo)
    @ApiOperation(value = "查询复诊记录,处方,居民信息,物流(单条)", notes = "查询复诊记录,处方,居民信息,物流(单条)")
    public ObjEnvelop findReOutpatientInfo(@ApiParam(name = "outpatientId", value = "复诊ID")
                                           @RequestParam(value = "outpatientId", required = true) String outpatientId,
                                           @ApiParam(name = "prescriptionId", value = "处方ID")
                                           @RequestParam(value = "prescriptionId", required = false) String prescriptionId)throws Exception{
        com.alibaba.fastjson.JSONObject obj =  prescriptionService.findReOutpatientInfo(outpatientId,prescriptionId);
        return success(obj);
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findPrescriptionInfo)
    @ApiOperation(value = "获取所有居民相关信息,续方信息,物流信息,药品信息(单条)", notes = "获取所有居民相关信息,续方信息,物流信息,药品信息(单条)")
    public ObjEnvelop<Map<String,Object>> findPrescriptionInfo(@ApiParam(name = "prescriptionId", value = "续方明细")
                                                               @RequestParam(value = "prescriptionId", required = false) String prescriptionId) {
@ -135,6 +157,149 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        return success(BaseHospitalRequestMapping.Prescription.api_success,prescriptionService.cancelPrescription(prescriptionId));
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findPatientCard)
    @ApiOperation(value = "查询患者就诊卡", notes = "查询患者就诊卡")
    public ListEnvelop findPatientCard(@ApiParam(name = "patient", value = "居民Code")
                                       @RequestParam(value = "patient", required = true)String patient)throws Exception {
        return success(prescriptionService.findPatientCard(patient));
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.checkOutpatient)
    @ApiOperation(value = "判断是否可用发起门诊", notes = "判断是否可用发起门诊")
    public ObjEnvelop checkOutpatient(@ApiParam(name = "patient", value = "续方明细")
                                      @RequestParam(value = "patient", required = true)String patient){
        return success(prescriptionService.checkOutpatient(patient));
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findAllHospital)
    @ApiOperation(value = "查询所有机构", notes = "查询所有机构")
    public ListEnvelop findAllHospital() {
        return success(prescriptionService.findAllHospital());
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findDeptByHospital)
    @ApiOperation(value = "查询机构底下部门", notes = "查询机构底下部门")
    public ListEnvelop findDeptByHospital(@ApiParam(name = "orgCode", value = "机构code")
                                          @RequestParam(value = "orgCode", required = true)String orgCode) {
        return success(prescriptionService.findDeptByHospital(orgCode));
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findDoctorByHospitalAndDept)
    @ApiOperation(value = "查询部门下医生", notes = "查询机构底下部门")
    public ListEnvelop findDoctorByHospitalAndDept(@ApiParam(name = "orgCode", value = "机构code")
                                                   @RequestParam(value = "orgCode", required = true)String orgCode,
                                                   @ApiParam(name = "dept", value = "部门code")
                                                   @RequestParam(value = "dept", required = true)String dept) {
        return success(prescriptionService.findDoctorByHospitalAndDept(orgCode,dept));
    }
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.appointmentRevisit)
    @ApiOperation(value = "居民发起复诊", notes = "居民发起复诊")
    public ObjEnvelop appointmentRevisit(@ApiParam(name = "outpatientJson", value = "居民门诊json")
                                         @RequestParam(value = "outpatientJson", required = false)String outpatientJson,
                                         @ApiParam(name = "expressageJson", value = "居民物流json")
                                         @RequestParam(value = "expressageJson", required = false)String expressageJson)throws Exception {
        return success(BaseHospitalRequestMapping.Prescription.api_success,prescriptionService.appointmentRevisit(outpatientJson,expressageJson));
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getICD10)
    @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));
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getDrugDictionary)
    @ApiOperation(value = "获取药品字典", notes = "获取药品字典")
    public ListEnvelop getDrugDictionary(@ApiParam(name = "drugNo", value = "药品编码")
                                         @RequestParam(value = "drugNo", required = false)String drugNo,
                                         @ApiParam(name = "pyKey", value = "拼音关键字")
                                         @RequestParam(value = "pyKey", required = false)String pyKey,
                                         @ApiParam(name = "winNo", value = "分部编码")
                                         @RequestParam(value = "winNo", required = false)String winNo)throws Exception {
        return success(prescriptionService.getDrugDictionary(drugNo,pyKey,winNo));
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getDrugUse)
    @ApiOperation(value = "获取用法", notes = "获取用法")
    public ListEnvelop getDrugUse(@ApiParam(name = "pyKey", value = "拼音关键字")
                                  @RequestParam(value = "pyKey", required = false)String pyKey)throws Exception {
        return success(prescriptionService.getDrugUse(pyKey));
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getDrugFrequency)
    @ApiOperation(value = "获取用药频次", notes = "获取用药频次")
    public ListEnvelop getDrugFrequency()throws Exception {
        return success(prescriptionService.getDrugFrequency());
    }
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.makeDiagnosis)
    @ApiOperation(value = "下诊断", notes = "下诊断")
    public ObjEnvelop makeDiagnosis(@ApiParam(name = "outPatientId", value = "门诊编号")
                                            @RequestParam(value = "outPatientId", required = false)String outPatientId,
                                            @ApiParam(name = "advice", value = "医嘱")
                                            @RequestParam(value = "advice", required = false)String advice,
                                            @ApiParam(name = "type", value = "1带药品,2不带药品")
                                            @RequestParam(value = "type", required = false)String type,
                                            @ApiParam(name = "infoJsons", value = "药品json")
                                            @RequestParam(value = "infoJsons", required = false)String infoJsons,
                                            @ApiParam(name = "diagnosisJson", value = "诊断json")
                                            @RequestParam(value = "diagnosisJson", required = false)String diagnosisJson)throws Exception {
        return success(prescriptionService.makeDiagnosis(outPatientId,advice,type,infoJsons,diagnosisJson));
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findExpressageList)
    @ApiOperation(value = "获取订单列表", notes = "获取订单列表")
    public MixEnvelop findExpressageList(@ApiParam(name = "status", value = "流程状态,多状态用‘,’分割")
                                         @RequestParam(value = "status", required = false)String status,
                                         @ApiParam(name = "oneselfPickupFlg", value = "是否自取 1是 0否")
                                         @RequestParam(value = "oneselfPickupFlg", required = false)String oneselfPickupFlg,
                                         @ApiParam(name = "nameKey", value = "配送员名称")
                                         @RequestParam(value = "nameKey", required = false)String nameKey,
                                         @ApiParam(name = "startTime", value = "开始时间,yyyy-MM-dd")
                                         @RequestParam(value = "startTime", required = false)String startTime,
                                         @ApiParam(name = "endTime", value = "结束时间,yyyy-MM-dd")
                                         @RequestParam(value = "endTime", required = false)String endTime,
                                         @ApiParam(name = "page", value = "第几页,1开始")
                                         @RequestParam(value = "page", required = false)Integer page,
                                         @ApiParam(name = "size", value = "每页大小")
                                         @RequestParam(value = "size", required = false)Integer size) {
        return prescriptionService.findExpressageList(status,oneselfPickupFlg,nameKey,startTime,endTime,page,size);
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.setMailno)
    @ApiOperation(value = "设置订单编号", notes = "设置订单编号")
    public ObjEnvelop setMailno(@ApiParam(name = "mailno", value = "订单号")
                                @RequestParam(value = "mailno", required = false)String mailno,
                                @ApiParam(name = "expressageId", value = "订单id")
                                @RequestParam(value = "expressageId", required = false)String expressageId) {
        return success(prescriptionService.setMailno(mailno,expressageId));
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.pushListWrite)
    @ApiOperation(value = "订单导出", notes = "订单导出")
    public void pushListWrite(@ApiParam(name = "status", value = "流程状态,多状态用‘,’分割")
                                    @RequestParam(value = "status", required = false)String status,
                                    @ApiParam(name = "oneselfPickupFlg", value = "是否自取 1是 0否")
                                    @RequestParam(value = "oneselfPickupFlg", required = false)String oneselfPickupFlg,
                                    @ApiParam(name = "nameKey", value = "配送员名称")
                                    @RequestParam(value = "nameKey", required = false)String nameKey,
                                    @ApiParam(name = "startTime", value = "开始时间,yyyy-MM-dd")
                                    @RequestParam(value = "startTime", required = false)String startTime,
                                    @ApiParam(name = "endTime", value = "结束时间,yyyy-MM-dd")
                                    @RequestParam(value = "endTime", required = false)String endTime,
                                    HttpServletResponse response) throws Exception{
        MixEnvelop expressages = prescriptionService.findExpressageList(status,oneselfPickupFlg,nameKey,startTime,endTime,1,10000);
        List<Map<String,Object>> list = expressages.getDetailModelList();
        response.setContentType("octets/stream");
        response.setHeader("Content-Disposition", "attachment; filename="+ new String( "pushDataList.xls"));
        OutputStream os = response.getOutputStream();
        prescriptionService.pushListWrite(os,list);
    }
    //===========

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

@ -72,6 +72,11 @@ fast-dfs:
configDefault: # 默认配置
  saasId: xmjkzl_saasId
express:
  sf_url: http://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService
  sf_code: JKZL
  sf_check_word: QkeIfIvQdheqIv2cVSgAUnBU29lfNbVk
---
spring:
  profiles: jwdev
@ -116,6 +121,11 @@ sms:
# mq 是否获取his数据,flag代表获取演示数据,false代表获取his真实数据
demo:
  flag: true
hospital:
  mqUser: JKZL
  mqPwd: 123456
  SourceSysCode: S60
  TargetSysCode: S01
---
spring:
  profiles: jwtest
@ -153,6 +163,11 @@ myFamily:
# mq 是否获取his数据,flag代表获取演示数据,false代表获取his真实数据
demo:
  flag: true
hospital:
  mqUser: JKZL
  mqPwd: 123456
  SourceSysCode: S60
  TargetSysCode: S01
---
spring:
  profiles: prod
@ -186,4 +201,9 @@ myFamily:
  qrCodeFailurTime: 2
# mq 是否获取his数据,flag代表获取演示数据,false代表获取his真实数据
demo:
  flag: false
  flag: false
hospital:
  mqUser: JKZL
  mqPwd: 123456
  SourceSysCode: S60
  TargetSysCode: S01

+ 150 - 8
svr/svr-iot-sunnuo/src/main/java/com/yihu/iot/datainput/controller/IotAnalyzerController.java

@ -3,24 +3,19 @@ package com.yihu.iot.datainput.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.iot.datainput.dao.IotDeviceBaiyiDao;
import com.yihu.iot.datainput.service.DataInputService;
import com.yihu.iot.datainput.util.ConstantUtils;
import com.yihu.jw.entity.iot.device.IotDeviceBaiyiDO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
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.apache.http.client.utils.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat;
import java.util.Date;
@ -43,6 +38,8 @@ public class IotAnalyzerController extends EnvelopRestEndpoint {
    @Autowired
    ObjectMapper objectMapper;
    @Autowired
    private IotDeviceBaiyiDao iotDeviceBaiyiDao;
    /**
     * 基于奕拓小屋上传的体征数据,进行解析入库
@ -160,4 +157,149 @@ public class IotAnalyzerController extends EnvelopRestEndpoint {
            return strResult;
        }
    }
    @PostMapping(value = "/heartRate")
    @ApiOperation(value = "柏颐心率数据接收", notes = "柏颐心率数据接收")
    public String heartRate(
            @ApiParam(name = "imei", value = "15位设备唯一序号")
            @RequestParam(value = "imei",required = false)String imei,
            @ApiParam(name = "time_begin", value = "发生时间YYYY-MM-DD HH:mm:SS")
            @RequestParam(value = "time_begin",required = false)String time_begin,
            @ApiParam(name = "heartrate", value = "心率")
            @RequestParam(value = "heartrate",required = false)int heartrate,
            @ApiParam(name = "theshold_heartrate_h", value = "心率阈值上限")
            @RequestParam(value = "theshold_heartrate_h",required = false)int theshold_heartrate_h,
            @ApiParam(name = "theshold_heartrate_l", value = "心率阈值下限")
            @RequestParam(value = "theshold_heartrate_l",required = false)int theshold_heartrate_l) throws Exception{
        String strResult = "";
        Map res = new HashMap();
        String info  = "imei="+imei+";time_begin="+time_begin+";heartrate="+heartrate+";theshold_heartrate_h="+theshold_heartrate_h+";theshold_heartrate_l="+theshold_heartrate_l;
        logger.info("info="+info);
        try {
            IotDeviceBaiyiDO iotDeviceBaiyiDO=new IotDeviceBaiyiDO();
            iotDeviceBaiyiDO.setImei(imei);
            iotDeviceBaiyiDO.setType(1);
            iotDeviceBaiyiDO.setTimeBegin(time_begin);
            iotDeviceBaiyiDO.setValue1(heartrate);
            iotDeviceBaiyiDO.setValue2(theshold_heartrate_h);
            iotDeviceBaiyiDO.setValue3(theshold_heartrate_l);
            iotDeviceBaiyiDao.save(iotDeviceBaiyiDO);
            return BaiyiDataParam(iotDeviceBaiyiDO);
//            return "";
        } catch (Exception e) {
            e.printStackTrace();
            res.put("statusCode", "03");
            res.put("desc", "服务异常,体征信息上传失败。");
            strResult = objectMapper.writeValueAsString(res);
            logger.error(strResult);
            return strResult;
        }
    }
    @PostMapping(value = "/bloodPressure")
    @ApiOperation(value = "柏颐血压数据接收", notes = "柏颐血压数据接收")
    public String bloodPressure(
            @ApiParam(name = "imei", value = "15位设备唯一序号", required = true)
            @RequestParam(value = "imei",required = false)String imei,
            @ApiParam(name = "time_begin", value = "发生时间YYYY-MM-DD HH:mm:SS", required = true)
            @RequestParam(value = "time_begin",required = false)String time_begin,
            @ApiParam(name = "dbp", value = "舒张压", required = true)
            @RequestParam(value = "dbp",required = false)int dbp,
            @ApiParam(name = "dbp_l", value = "舒张压报警下限", required = true)
            @RequestParam(value = "dbp_l",required = false)int dbp_l,
            @ApiParam(name = "sbp", value = "收缩压", required = true)
            @RequestParam(value = "sbp",required = false)int sbp,
            @ApiParam(name = "sbp_h", value = "收缩压报警上限", required = true)
            @RequestParam(value = "sbp_h",required = false)int sbp_h) throws Exception{
        String strResult = "";
        Map res = new HashMap();
        String info= "imei="+imei+";time_begin="+time_begin+";dbp="+dbp+";dbp_l="+dbp_l+";sbp="+sbp+";sbp_h="+sbp_h;
        logger.info("info="+info);
        try {
            IotDeviceBaiyiDO iotDeviceBaiyiDO=new IotDeviceBaiyiDO();
            iotDeviceBaiyiDO.setImei(imei);
            iotDeviceBaiyiDO.setTimeBegin(time_begin);
            iotDeviceBaiyiDO.setType(2);
            iotDeviceBaiyiDO.setValue1(dbp);
            iotDeviceBaiyiDO.setValue2(dbp_l);
            iotDeviceBaiyiDO.setValue3(sbp);
            iotDeviceBaiyiDO.setValue4(sbp_h);
            iotDeviceBaiyiDao.save(iotDeviceBaiyiDO);
            return BaiyiDataParam(iotDeviceBaiyiDO);
//            return "";
        } catch (Exception e) {
            e.printStackTrace();
            res.put("statusCode", "03");
            res.put("desc", "服务异常,体征信息上传失败。");
            strResult = objectMapper.writeValueAsString(res);
            logger.error(strResult);
            return strResult;
        }
    }
    /**
     * 封装数据上传至i健康
     * @param iotDeviceBaiyiDO 设备数据实体
     * @return
     * @throws Exception
     */
    public String BaiyiDataParam(IotDeviceBaiyiDO iotDeviceBaiyiDO)throws Exception {
        JSONArray jsonArray = new JSONArray();
        JSONObject params = new JSONObject();
        JSONObject data = new JSONObject();
        Map res = new HashMap();
        // 增加判断,当测量值小于1时,定义为异常值,不进行数据的存储。
        if (iotDeviceBaiyiDO.getValue1() < 1) {
            res.put("statusCode", "00");
            res.put("desc", iotDeviceBaiyiDO.getImei() + "体征数据异常(小于正常值)。");
            return objectMapper.writeValueAsString(res);
        } else {
            if (2 == iotDeviceBaiyiDO.getType()) {
                //血压测量数据
                data.put("data", iotDeviceBaiyiDO.getValue3() + "," + iotDeviceBaiyiDO.getValue1());
                //单位
                data.put("unit", "mmHg");
            } else {
                //心率测量数据
                data.put("data", iotDeviceBaiyiDO.getValue1());
                //单位
                data.put("unit", "bpm");
            }
        }
        //按键号
        data.put("button", "-1");
        //设备唯一码
        data.put("deviceSn", iotDeviceBaiyiDO.getImei());
        //设备类型1:血压 5:心率
        data.put("deviceType", "4");
        data.put("measurementType",iotDeviceBaiyiDO.getType());
        //厂商代码
        data.put("manufacturerCode", "baiyi");
        //厂商名称
        data.put("manufacturerName", "柏颐设备");
        //发送时间yyyy-MM-dd HH:mm:ss
        data.put("sendTime", iotDeviceBaiyiDO.getTimeBegin());
        data.put("state", 0);
        //单位mmol/L,mmHg
        data.put("unit", "");
        //体征上传时间yyyy-MM-dd HH:mm:ss
        data.put("uploadTime", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
        jsonArray.add(data);
        params.put("data", jsonArray);
        //体征信息上传成功后,同步到厦门I健康
        data.put("id", "");
        boolean synFlag = dataInputService.synXMIjk(data);
        if (synFlag) {
            res.put("statusCode", "00");
            res.put("desc", iotDeviceBaiyiDO.getImei() + "体征信息上传厦门I健康成功。");
        } else {
            res.put("statusCode", "02");
            res.put("desc", iotDeviceBaiyiDO.getImei() + "体征信息上传厦门I健康失败。");
        }
        String strResult = objectMapper.writeValueAsString(res);
        logger.info(strResult);
        return strResult;
//      return "";
    }
}

+ 12 - 0
svr/svr-iot-sunnuo/src/main/java/com/yihu/iot/datainput/dao/IotDeviceBaiyiDao.java

@ -0,0 +1,12 @@
package com.yihu.iot.datainput.dao;
import com.yihu.jw.entity.iot.device.IotDeviceBaiyiDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author zdm on 2019/6/11.
 */
public interface IotDeviceBaiyiDao extends PagingAndSortingRepository<IotDeviceBaiyiDO,String>,JpaSpecificationExecutor<IotDeviceBaiyiDO> {
}

+ 12 - 0
svr/svr-iot-sunnuo/src/main/java/com/yihu/iot/datainput/service/IotAnalyzerService.java

@ -0,0 +1,12 @@
package com.yihu.iot.datainput.service;
import org.springframework.stereotype.Service;
/**
 * Created by zdm on 2019/6/11.
 */
@Service
public class IotAnalyzerService {
}