Quellcode durchsuchen

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

liubing vor 4 Jahren
Ursprung
Commit
d001e44f9f
48 geänderte Dateien mit 2925 neuen und 528 gelöschten Zeilen
  1. 5 0
      business/base-service/src/main/java/com/yihu/jw/doctor/dao/BaseDoctorDao.java
  2. 4 0
      business/base-service/src/main/java/com/yihu/jw/doctor/dao/BaseDoctorHospitalDao.java
  3. 2 0
      business/base-service/src/main/java/com/yihu/jw/doctor/dao/BaseDoctorRoleDao.java
  4. 22 2
      business/base-service/src/main/java/com/yihu/jw/doctor/service/BaseDoctorInfoService.java
  5. 9 7
      business/base-service/src/main/java/com/yihu/jw/hospital/family/service/WlyyFamilyMemberService.java
  6. 5 4
      business/base-service/src/main/java/com/yihu/jw/hospital/mapping/service/PatientMappingService.java
  7. 6 2
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/OutpatientDao.java
  8. 580 203
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  9. 96 65
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/YkyyPrescriptionService.java
  10. 2 1
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/YkyyEntranceService.java
  11. 1 0
      business/base-service/src/main/java/com/yihu/jw/hospital/ykyy/service/YkyyService.java
  12. 8 7
      business/base-service/src/main/java/com/yihu/jw/internet/service/InternetCommonService.java
  13. 1 1
      business/base-service/src/main/java/com/yihu/jw/internet/service/ykyy/YkyyInternetService.java
  14. 271 47
      business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java
  15. 451 33
      business/es-service/src/main/java/com/yihu/jw/es/service/StatisticsEsService.java
  16. 512 17
      business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java
  17. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/IntegerIdentityEntity.java
  18. 15 1
      common/common-entity/src/main/java/com/yihu/jw/entity/base/doctor/BaseDoctorHospitalDO.java
  19. 21 1
      common/common-entity/src/main/java/com/yihu/jw/entity/base/wx/WxWechatDO.java
  20. 1 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/dict/WlyyChargeDictDO.java
  21. 8 1
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java
  22. 1 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/prescription/WlyyChargeDictVO.java
  23. 1 1
      gateway/ag-basic/pom.xml
  24. 4 2
      gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/BasicZuulFilter.java
  25. 3 1
      gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/PostFilter.java
  26. 6 5
      server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java
  27. 1 1
      server/svr-authentication/src/main/java/com/yihu/jw/security/dao/doctor/BaseDoctorDao.java
  28. 31 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/dao/patient/WechatDao.java
  29. 56 10
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  30. 2 2
      server/svr-authentication/src/main/java/com/yihu/jw/security/service/OauthSsoService.java
  31. 10 0
      svr/svr-base/src/main/java/com/yihu/SvrBaseApplication.java
  32. 1 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/dict/DictJobTitleDao.java
  33. 2 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/doctor/BaseDoctorRoleDictDao.java
  34. 96 1
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/doctor/BaseDoctorEndpoint.java
  35. 153 0
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/open/nologin/BaseServiceNologin.java
  36. 11 0
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/open/register/RegisterEndpoint.java
  37. 128 16
      svr/svr-base/src/main/java/com/yihu/jw/base/service/doctor/BaseDoctorService.java
  38. 32 6
      svr/svr-base/src/main/java/com/yihu/jw/base/service/doctor/excelImport/BaseDoctorExcelDOReader.java
  39. 2 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/org/BaseOrgService.java
  40. 13 0
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/PrescriptionStatusUpdateService.java
  41. 5 6
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/TimeoutOverDueService.java
  42. 43 1
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/web/quota/JobController.java
  43. 162 44
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java
  44. 28 8
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/PatientConsultEndpoint.java
  45. 80 9
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java
  46. 17 13
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java
  47. 8 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/YkyyPrescriptionEndpoint.java
  48. 8 8
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/ykyy/YkyyController.java

+ 5 - 0
business/base-service/src/main/java/com/yihu/jw/doctor/dao/BaseDoctorDao.java

@ -40,6 +40,11 @@ public interface BaseDoctorDao extends PagingAndSortingRepository<BaseDoctorDO,
    List<BaseDoctorDO> findByIdcard(String idcard);
    @Query("from BaseDoctorDO d where d.idcard = ?1 AND d.del ='1'")
    BaseDoctorDO findByIdcardAndDel(String id);
    @Query("from BaseDoctorDO d where d.mobile = ?1")
    List<BaseDoctorDO> findByMobile(String id);
    @Query("from BaseDoctorDO d where d.yktDoctorId = ?1 AND d.del ='1'")
    BaseDoctorDO findByYktDoctorId(String yktDoctorId);

+ 4 - 0
business/base-service/src/main/java/com/yihu/jw/doctor/dao/BaseDoctorHospitalDao.java

@ -30,4 +30,8 @@ public interface BaseDoctorHospitalDao extends PagingAndSortingRepository<BaseDo
    @Query("select bdo from BaseDoctorHospitalDO bdo where bdo.orgCode=?1 and bdo.deptCode=?2 and bdo.doctorCode = ?3 and bdo.del=1")
    List<BaseDoctorHospitalDO> findByOrgCodeAndDeptCodeAndDoctorCode(String orgCode,String deptCode,String doctorCode);
    @Query("select bdo from BaseDoctorHospitalDO bdo where bdo.orgCode=?1 and bdo.deptCode=?2 and bdo.doctorCode = ?3 and bdo.del=1")
    BaseDoctorHospitalDO findByOrgCodeAndDeptCodeAndDoctorCodeOnly(String orgCode,String deptCode,String doctorCode);
}

+ 2 - 0
business/base-service/src/main/java/com/yihu/jw/doctor/dao/BaseDoctorRoleDao.java

@ -30,4 +30,6 @@ public interface BaseDoctorRoleDao extends PagingAndSortingRepository<BaseDoctor
    Set<Object> findIdListByDoctorCode(String doctorCode);
    List<BaseDoctorRoleDO> findByDoctorCode(String doctorCode);
    @Query("from BaseDoctorRoleDO where doctorCode = ?1 and roleCode = ?2")
    BaseDoctorRoleDO findByDoctorCodeAndroleCode(String doctorCode,String roleCode);
}

+ 22 - 2
business/base-service/src/main/java/com/yihu/jw/doctor/service/BaseDoctorInfoService.java

@ -135,11 +135,21 @@ public class BaseDoctorInfoService extends BaseJpaService<BaseDoctorDO, BaseDoct
                " a.del AS \"del\", " +
                " b.dept_name AS \"deptName\", " +
                " e.req_fee AS \"money\", " +
                " a.charge_type as \"chargeType\" "+
                " a.charge_type as \"chargeType\", "+
                "\tm.req_fee as \"twfzFee\",\n" +
                "\tn.req_fee as \"spfzFee\",\n" +
                "\tp.req_fee as \"spzxFee\",\n" +
                "\tv.req_fee as \"twzxFee\",\n" +
                "\td.req_fee as \"xtzxFee\"\n" +
                " FROM " +
                " base_doctor a " +
                " JOIN base_doctor_hospital b ON a.id = b.doctor_code " +
                " LEFT JOIN (SELECT * FROM wlyy_charge_dict t WHERE t.dept_type_code ='6') e ON a.charge_type = e.charge_type " +
                " LEFT JOIN wlyy_charge_dict m ON a.twfz_charge_type = m.charge_type\n" +
                " LEFT JOIN wlyy_charge_dict n ON a.spfz_charge_type = n.charge_type\n" +
                " LEFT JOIN wlyy_charge_dict p ON a.spzx_charge_type = p.charge_type\n" +
                " LEFT JOIN wlyy_charge_dict v ON a.twzx_charge_type = v.charge_type\n" +
                " LEFT JOIN wlyy_charge_dict d ON a.xtfz_charge_type = d.charge_type\n" +
                " LEFT JOIN base_doctor_mapping c ON a.id = c.doctor " +
                " WHERE 1=1";
        if (StringUtils.isNotBlank(city)){
@ -189,13 +199,23 @@ public class BaseDoctorInfoService extends BaseJpaService<BaseDoctorDO, BaseDoct
                " c.mapping_code AS \"jobNumber\", " +
                " d.disease_name AS \"diseaseName\", " +
                " d.disease_code AS \"diseaseCode\", " +
                " e.req_fee AS \"money\" " +
                " e.req_fee AS \"money\" ," +
                "\tm.req_fee as \"twfzFee\",\n" +
                "\tn.req_fee as \"spfzFee\",\n" +
                "\tp.req_fee as \"spzxFee\",\n" +
                "\tv.req_fee as \"twzxFee\",\n" +
                "\tq.req_fee as \"xtzxFee\"\n" +
                " FROM " +
                " base_doctor a " +
                " LEFT JOIN base_doctor_hospital b ON a.id = b.doctor_code " +
                " LEFT JOIN base_doctor_mapping c ON a.id = c.doctor " +
                " LEFT JOIN wlyy_doctor_special_disease d ON a.id = d.doctor_code " +
                " LEFT JOIN wlyy_charge_dict e ON a.charge_type = e.charge_type " +
                " LEFT JOIN wlyy_charge_dict m ON a.twfz_charge_type = m.charge_type\n" +
                " LEFT JOIN wlyy_charge_dict n ON a.spfz_charge_type = n.charge_type\n" +
                " LEFT JOIN wlyy_charge_dict p ON a.spzx_charge_type = p.charge_type\n" +
                " LEFT JOIN wlyy_charge_dict v ON a.twzx_charge_type = v.charge_type\n" +
                " LEFT JOIN wlyy_charge_dict q ON a.xtfz_charge_type = q.charge_type\n" +
                " WHERE 1=1 ";
        if(StringUtils.isNotBlank(doctorId)){
            sql+=" AND a.id =:id";

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

@ -341,7 +341,15 @@ public class WlyyFamilyMemberService extends BaseJpaService<WlyyPatientFamilyMem
                                }
                                patientDO.setIdcard(jsonObject1.getString("IDCARD"));
                                patientDO.setName(jsonObject1.getString("NAME"));
                                patientDO.setSex(jsonObject1.getInteger("SEX"));
                                if(jsonObject1.getInteger("SEX")!=null){
                                    if (1==jsonObject1.getInteger("SEX")){
                                        patientDO.setSex(1);
                                    }else if (0==jsonObject1.getInteger("SEX")){
                                        patientDO.setSex(2);
                                    }else {
                                        patientDO.setSex(0);
                                    }
                                }
                                patientDO.setDel("1");
                                patientDO.setEnabled(1);
                                patientDO.setLocked(0);
@ -479,12 +487,6 @@ public class WlyyFamilyMemberService extends BaseJpaService<WlyyPatientFamilyMem
        }
    }
    public static void main(String[] args) {
        String ss ="561657600000";
        Date da = new Date(Long.parseLong(ss));
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        System.out.println(simpleDateFormat.format(da));
    }
    private static int getAgeByBirth(Date birthday) {
        int age = 0;
        try {

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

@ -2,20 +2,20 @@ package com.yihu.jw.hospital.mapping.service;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.hospital.prescription.service.PrescriptionService;
import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.dao.BasePatientMedicareCardDao;
import net.sf.json.JSONArray;
import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
import net.sf.json.JSONObject;
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.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
@ -24,6 +24,7 @@ import java.util.Date;
 * 互联网医院居民信息映射
 */
@Service
@Transactional
public class PatientMappingService {
    private static final Logger logger = LoggerFactory.getLogger(PatientMappingService.class);

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

@ -15,11 +15,15 @@ import java.util.List;
 */
public interface OutpatientDao extends PagingAndSortingRepository<WlyyOutpatientDO, String>, JpaSpecificationExecutor<WlyyOutpatientDO> {
    @Query("from WlyyOutpatientDO a where a.patient = ?1 and a.status in(0,1)")
    @Query("from WlyyOutpatientDO a where a.patient = ?1 and a.outpatientType <> '3' and a.status in(0,1)")
    List<WlyyOutpatientDO> findByPatientList(String patient);
    @Query("from WlyyOutpatientDO a where a.patient = ?1 and  a.outpatientType = '3' and a.status in(0,1)")
    List<WlyyOutpatientDO> findByPatientAndDoctorList(String patient);
    @Query("from WlyyOutpatientDO a where a.patient = ?1 and a.status in(3) order by a.createTime desc ")
    @Query("from WlyyOutpatientDO a where a.patient = ?1 and a.outpatientType <> '3' and a.status in(3) order by a.createTime desc ")
    List<WlyyOutpatientDO> findByPatientListByStatus(String patient);
    @Query("from WlyyOutpatientDO a where a.patient = ?1 and a.outpatientType = ?2  and a.status in(3) order by a.createTime desc ")
    List<WlyyOutpatientDO> findByPatientListByStatusAndType(String patient,String outpatientType);
    @Query("from WlyyOutpatientDO a where a.patient = ?1 and a.hisStatus=1 and a.createTime>=?2 and a.createTime<=?3")
    List<WlyyOutpatientDO> findByPatientListNoStatus(String patient,Date startDate,Date endDate);

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

@ -12,6 +12,7 @@ import com.yihu.jw.entity.base.dict.DictDeptDescDO;
import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.org.BaseDoctorPatientFollowDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
@ -79,6 +80,7 @@ import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
import com.yihu.jw.utils.GenerateUserSig;
import com.yihu.jw.utils.Pkis.PKIService_PortType;
import com.yihu.jw.utils.Pkis.PKIService_ServiceLocator;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.WebserviceUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
@ -366,13 +368,13 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @param size
     * @return
     */
    public MixEnvelop findReOutpatientList(String patient, Integer status, String startTime, String endTime, Integer page, Integer size) {
    public MixEnvelop findReOutpatientList(String patient, Integer status, String startTime, String endTime,String outpatientType, Integer page, Integer size) {
        String totalSql = "SELECT " +
                " COUNT(1) AS \"total\" " +
                " FROM " +
                " wlyy_outpatient o " +
                " WHERE " +
                " o.patient =:patient AND o.outpatient_type != '2' ";
                " o.patient =:patient  ";
        Map<String, Object> totalParams = new HashedMap();
        totalParams.put("patient", patient);
        if (status != null) {
@ -388,6 +390,10 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            totalParams.put("endTime", DateUtil.strToDateLong(endTime + " 23:59:59"));
        }
        if (StringUtils.isNotBlank(outpatientType)){
            totalSql+=" AND o.outpatient_type = :outpatientType ";
            totalParams.put("outpatientType", outpatientType);
        }
       /* totalParams.add(patient);
        if(status!=null){
            totalSql +=  " AND o.status = ? ";
@ -428,6 +434,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                " o.hospital_name AS \"hospitalName\"," +
                " o.win_no AS \"winNo\"," +
                " o.type AS  \"type\"," +
                " o.outpatient_type AS  \"outpatientType\"," +
                " o.dept AS \"dept\", " +
                " o.dept_name AS \"deptName\", " +
                " o.patient AS \"patient\", " +
@ -480,7 +487,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            params.put("endTime", DateUtil.strToDateLong(endTime + " 23:59:59"));
        }
        sql += " AND o.outpatient_type != '2' ORDER BY o.create_time DESC ";
        if (StringUtils.isNotBlank(outpatientType)){
            sql+=" AND o.outpatient_type = '"+outpatientType+"' ORDER BY o.create_time DESC ";
        }
        logger.info("sql="+sql);
        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql, params, page, size);
        for(Map<String, Object> map:list){
@ -523,6 +532,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        rs.put("operator",outpatientDO.getOperator());
        rs.put("status",outpatientDO.getStatus());
        rs.put("fee",outpatientDO.getFee());
        rs.put("icd10Name",outpatientDO.getIcd10Name());
        rs.put("createTime",DateUtil.dateToStrLong(outpatientDO.getCreateTime()));
        //居民详情
        BasePatientDO basePatientDO = basePatientDao.findById(outpatientDO.getPatient());
@ -850,51 +860,66 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        outpatientDO.setStatus("0");
        outpatientDO.setCreateTime(new Date());
        outpatientDO.setIdcard(patientDO.getIdcard());
        outpatientDO.setOutpatientType("1");
        outpatientDO.setCreateTime(new Date());
        if (outpatientDO.getRegisterDate() == null) {
            outpatientDO.setRegisterDate(new Date());
        }
        WlyyPrescriptionExpressageDO previous = checkOutPatientPre(outpatientDO.getPatient());
        //2.物流信息
        WlyyPrescriptionExpressageDO expressageDO = objectMapper.readValue(expressageJson, WlyyPrescriptionExpressageDO.class);
        if (null!=previous.getId()&&previous.getOneselfPickupFlg()!=expressageDO.getOneselfPickupFlg()){
            WlyyOutpatientDO wlyyOutpatientDO = new WlyyOutpatientDO();
            wlyyOutpatientDO.setRemindCount(previous.getOneselfPickupFlg());
            return wlyyOutpatientDO;
        WlyyPrescriptionExpressageDO expressageDO = new WlyyPrescriptionExpressageDO();
        if(!outpatientDO.getOutpatientType().equalsIgnoreCase("3")){
            WlyyPrescriptionExpressageDO previous = checkOutPatientPre(outpatientDO.getPatient());
            //2.物流信息
            expressageDO = objectMapper.readValue(expressageJson, WlyyPrescriptionExpressageDO.class);
            if (null!=previous.getId()&&previous.getOneselfPickupFlg()!=expressageDO.getOneselfPickupFlg()){
                WlyyOutpatientDO wlyyOutpatientDO = new WlyyOutpatientDO();
                wlyyOutpatientDO.setOutpatientType(outpatientDO.getOutpatientType());
                wlyyOutpatientDO.setRemindCount(previous.getOneselfPickupFlg());
                return wlyyOutpatientDO;
            }
        }
        WlyyOutpatientDO outpatient = outpatientDao.save(outpatientDO);
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("WX_MONEY");
        Double price = 0.0;
        String chargeType1 = null;
        if (outpatient.getOutpatientType().equalsIgnoreCase("1")){
            if(outpatientDO.getType().equalsIgnoreCase("1")){
                chargeType1 = doctorDO.getTwfzChargeType();
            }else if(outpatientDO.getType().equalsIgnoreCase("2")){
                chargeType1 = doctorDO.getSpfzChargeType();
            }
        }else if (outpatient.getOutpatientType().equalsIgnoreCase("3")){
            if(outpatientDO.getType().equalsIgnoreCase("1")){
                chargeType1 = doctorDO.getTwzxChargeType();
            }else if(outpatientDO.getType().equalsIgnoreCase("2")){
                chargeType1 = doctorDO.getSpzxChargeType();
        if (doctorDO!=null){
            if (outpatient.getOutpatientType().equalsIgnoreCase("1")){
                if(outpatientDO.getType().equalsIgnoreCase("1")){
                    chargeType1 = doctorDO.getTwfzChargeType();
                }else if(outpatientDO.getType().equalsIgnoreCase("2")){
                    chargeType1 = doctorDO.getSpfzChargeType();
                }
            }else if (outpatient.getOutpatientType().equalsIgnoreCase("3")){
                if(outpatientDO.getType().equalsIgnoreCase("1")){
                    chargeType1 = doctorDO.getTwzxChargeType();
                }else if(outpatientDO.getType().equalsIgnoreCase("2")){
                    chargeType1 = doctorDO.getSpzxChargeType();
                }
            }else if (outpatient.getOutpatientType().equalsIgnoreCase("2")){
                chargeType1 = doctorDO.getXtfzChargeType();
            }
            if(doctorDO!=null){
                if (StringUtils.isNoneBlank(chargeType1)){
                    WlyyChargeDictDO chargeDictDO = wlyyChargeDictDao.findByChargeType(chargeType1);
                    if (chargeDictDO!=null){
                        price = chargeDictDO.getReqFee();
                    }else {
                        price = Double.parseDouble(hospitalSysDictDO.getDictValue());
                    }
                }
            }else {
                price = Double.parseDouble(hospitalSysDictDO.getDictValue());
            }
        }else if (outpatient.getOutpatientType().equalsIgnoreCase("2")){
            chargeType1 = doctorDO.getXtfzChargeType();
        }
        if(doctorDO!=null){
            if (StringUtils.isNoneBlank(chargeType1)){
                WlyyChargeDictDO chargeDictDO = wlyyChargeDictDao.findByChargeType(chargeType1);
        }else {
            if (StringUtils.isNoneBlank(chargeType)){
                WlyyChargeDictDO chargeDictDO = wlyyChargeDictDao.findByChargeType(chargeType);
                if (chargeDictDO!=null){
                    price = chargeDictDO.getReqFee();
                }else {
                    price = Double.parseDouble(hospitalSysDictDO.getDictValue());
                }
            }
        }else {
            price = Double.parseDouble(hospitalSysDictDO.getDictValue());
        }
        /*if (doctorDO != null && StringUtils.isNoneBlank(doctorDO.getFee())) {
            price = Double.parseDouble(doctorDO.getFee());
@ -915,6 +940,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            }
        }else if (outpatient.getOutpatientType().equalsIgnoreCase("2")){
            businessOrderService.recharge(outpatient.getId(), "协同复诊-诊查费", "5", "协同复诊-诊查费", outpatient.getConsumer(), outpatient.getConsumerName(), outpatient.getDoctor(), price);
        }else if ("3".equalsIgnoreCase(outpatient.getOutpatientType())){
            BusinessOrderDO businessOrderDO = businessOrderService.recharge(outpatient.getId(), "专家咨询费", "1", "专家咨询费", outpatient.getConsumer(), outpatient.getConsumerName(), outpatient.getDoctor(), price);
        }
@ -931,36 +958,37 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        } catch (Exception e) {
            throw new RuntimeException("号源已经被预约,请选择其他号源");
        }
        if (0==expressageDO.getOneselfPickupFlg()){
            if("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
                String drugCode= expressageDO.getHospitalCode()==null?"5550":expressageDO.getHospitalCode();
                expressageDO.setHospitalCode(drugCode);
        if (!outpatientDO.getOutpatientType().equalsIgnoreCase("3")){
            if (0==expressageDO.getOneselfPickupFlg()){
                if("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
                    String drugCode= expressageDO.getHospitalCode()==null?"5550":expressageDO.getHospitalCode();
                    expressageDO.setHospitalCode(drugCode);
                }
                System.out.println("进入物流信息");
                expressageDO.setDel(1);
                expressageDO.setCreateTime(new Date());
                expressageDO.setOutpatientId(outpatient.getId());
                prescriptionExpressageDao.save(expressageDO);
            }else {
                System.out.println("写入自取信息");
                String drugStoreCode = expressageDO.getHospitalCode();
                BaseDrugStoreDO baseDrugStoreDO = baseDrugStoreDao.findDrugByid(drugStoreCode);
                if (null!=baseDrugStoreDO){
                    expressageDO.setCityCode(baseDrugStoreDO.getCityCode());
                    expressageDO.setCityName(baseDrugStoreDO.getCityName());
                    expressageDO.setProvinceCode(baseDrugStoreDO.getProvinceCode());
                    expressageDO.setProvinceName(baseDrugStoreDO.getProvinceName());
                    expressageDO.setTownCode(baseDrugStoreDO.getTownCode());
                    expressageDO.setTownName(baseDrugStoreDO.getTownName());
                    expressageDO.setHospitalCode(baseDrugStoreDO.getDrugStoreCode());
                    expressageDO.setHospitalName(baseDrugStoreDO.getHospitalName());
                    expressageDO.setHospitalAddress(baseDrugStoreDO.getAddress());
                }
                expressageDO.setDel(1);
                expressageDO.setCreateTime(new Date());
                expressageDO.setOutpatientId(outpatient.getId());
                prescriptionExpressageDao.save(expressageDO);
            }
            System.out.println("进入物流信息");
            expressageDO.setDel(1);
            expressageDO.setCreateTime(new Date());
            expressageDO.setOutpatientId(outpatient.getId());
            prescriptionExpressageDao.save(expressageDO);
        }else {
            System.out.println("写入自取信息");
            String drugStoreCode = expressageDO.getHospitalCode();
            BaseDrugStoreDO baseDrugStoreDO = baseDrugStoreDao.findDrugByid(drugStoreCode);
            if (null!=baseDrugStoreDO){
                expressageDO.setCityCode(baseDrugStoreDO.getCityCode());
                expressageDO.setCityName(baseDrugStoreDO.getCityName());
                expressageDO.setProvinceCode(baseDrugStoreDO.getProvinceCode());
                expressageDO.setProvinceName(baseDrugStoreDO.getProvinceName());
                expressageDO.setTownCode(baseDrugStoreDO.getTownCode());
                expressageDO.setTownName(baseDrugStoreDO.getTownName());
                expressageDO.setHospitalCode(baseDrugStoreDO.getDrugStoreCode());
                expressageDO.setHospitalName(baseDrugStoreDO.getHospitalName());
                expressageDO.setHospitalAddress(baseDrugStoreDO.getAddress());
            }
            expressageDO.setDel(1);
            expressageDO.setCreateTime(new Date());
            expressageDO.setOutpatientId(outpatient.getId());
            prescriptionExpressageDao.save(expressageDO);
        }
        if (wechatId.equalsIgnoreCase("xm_xzzx_wx")){
            logger.info("心脏中心同步患者开始");
@ -1180,18 +1208,27 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        return rs;
    }
    public Map<String, Object> checkOutpatient(String patient,String wxId,boolean flag) throws Exception {
    public Map<String, Object> checkOutpatient(String patient,String wxId,boolean flag,String outpatientType) throws Exception {
        //-1卡余额不足,,-2 存在未结束的诊断热 1成功
        Map<String, Object> rs = new HashedMap();
        //1.余额判断改到前端判断
        //net.sf.json.JSONObject json = entranceService.qutpatientBalance(cardNo,demoFlag);
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("consultAccount");
        String accountControl = "0";
        if (null!=wlyyHospitalSysDictDO){
            accountControl = wlyyHospitalSysDictDO.getDictValue();
        }
        //1.判断
        //net.sf.json.JS余额判断改到前端ONObject json = entranceService.qutpatientBalance(cardNo,demoFlag);
        if (flag){
            if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
                List<WlyyOutpatientDO> outpatientDOS = outpatientDao.findByPatientListByStatus(patient);
                List<WlyyOutpatientDO> outpatientDOS = new ArrayList<>();
                if (StringUtils.isNotBlank(outpatientType)){
                    outpatientDOS = outpatientDao.findByPatientListByStatusAndType(patient,outpatientType);
                }else {
                    outpatientDOS = outpatientDao.findByPatientListByStatus(patient);
                }
                if (outpatientDOS!=null&&outpatientDOS.size()!=0){
                    WlyyOutpatientDO outpatientDO = outpatientDOS.get(0);
                    if (outpatientDO.getHisStatus()!=null){
                    if (outpatientDO.getHisStatus()!=null&&"0".equalsIgnoreCase(accountControl)){
                        logger.info("您上一次就诊进入"+outpatientDO.getHisStatus());
                        if(outpatientDO.getHisStatus()!=1&&outpatientDO.getHisStatus()!=-1){
                            logger.info("您上一次就诊进入======"+outpatientDO.getHisStatus());
@ -1209,7 +1246,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                            return rs;
                        }
                    }else if (outpatientDO.getHisStatus()==null){
                    }else if (outpatientDO.getHisStatus()==null&&"0".equalsIgnoreCase(accountControl)){
                        rs.put("outpatient", outpatientDO);
                        rs.put("code", -3);
                        rs.put("mes", "您上一次就诊未结算,请结算后才能发起复诊。");
@ -1227,16 +1264,26 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            }
        }
        //2.判断是否有未结束的
        List<WlyyOutpatientDO> list = outpatientDao.findByPatientList(patient);
        List<WlyyOutpatientDO> list = new ArrayList<>();
        if(StringUtils.isNotBlank(outpatientType)&&outpatientType.equalsIgnoreCase("3")){
            list = outpatientDao.findByPatientAndDoctorList(patient);
        }else {
            list = outpatientDao.findByPatientList(patient);
        }
        if (list != null && list.size() > 0) {
            rs.put("outpatient", list.get(0));
            rs.put("code", -2);
            rs.put("mes", "存在未结束的诊断");
            return rs;
            if(!list.get(0).getOutpatientType().equalsIgnoreCase("3")){
                rs.put("outpatient", list.get(0));
                rs.put("code", -2);
                rs.put("mes", "存在未结束的诊断");
                return rs;
            }else {
                rs.put("outpatient", list.get(0));
                rs.put("code", -2);
                rs.put("mes", "存在未结束的咨询");
                return rs;
            }
        }
        rs.put("code", 1);
        rs.put("mes", "验证通过");
@ -1600,7 +1647,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                        chargeTypeList = chargeType.replace(",","','");
                    }
                    String sqlCharge = "select charge_type as \"chargeType\",charge_name as \"chargeName\"," +
                            "req_fee  as \"reqFee\",dept_type_code as \"deptTypeCode\" " +
                            "req_fee  as \"reqFee\",zj_fee  as \"zjFee\",xt_fee  as \"xtFee\",dept_type_code as \"deptTypeCode\" " +
                            " from wlyy_charge_dict where 1=1";
                    sqlCharge+=" and charge_type in ( '"+chargeTypeList+"')";
@ -3517,7 +3564,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    chargeType = chargeType.replace(",","','");
                }
                String sqlCharge = "select charge_type as \"chargeType\",charge_name as \"chargeName\"," +
                        "req_fee  as \"reqFee\",dept_type_code as \"deptTypeCode\" " +
                        "req_fee  as \"reqFee\",zj_fee  as \"zjFee\",xt_fee  as \"xtFee\",dept_type_code as \"deptTypeCode\" " +
                        " from wlyy_charge_dict where 1=1";
                sqlCharge+=" and charge_type in ( '"+chargeType+"')";
                if (StringUtils.isNoneBlank(deptTyepCode)){
@ -3525,6 +3572,21 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                }
                chargeDictDOLists =  hibenateUtils.createSQLQuery(sqlCharge);
            }*/
            String sqlCharge = "SELECT\n" +
                    "\tm.req_fee as \"twfzFee\",\n" +
                    "\ta.req_fee as \"spfzFee\",\n" +
                    "\tb.req_fee as \"spzxFee\",\n" +
                    "\tv.req_fee as \"twzxFee\",\n" +
                    "\td.req_fee as \"xtzxFee\"\n" +
                    "FROM\n" +
                    "\tbase_doctor t\n" +
                    "LEFT JOIN wlyy_charge_dict m ON t.twfz_charge_type = m.charge_type\n" +
                    "LEFT JOIN wlyy_charge_dict a ON t.spfz_charge_type = a.charge_type\n" +
                    "LEFT JOIN wlyy_charge_dict b ON t.spzx_charge_type = b.charge_type\n" +
                    "LEFT JOIN wlyy_charge_dict v ON t.twzx_charge_type = v.charge_type\n" +
                    "LEFT JOIN wlyy_charge_dict d ON t.xtfz_charge_type = d.charge_type\n" +
                    "WHERE t.id = '"+doctorDO.getId()+"' ";
            chargeDictDOLists =  hibenateUtils.createSQLQuery(sqlCharge);
            rs.put("chargeTypeList",chargeDictDOLists);
            //机构科室信息
            List<BaseDoctorHospitalDO> hospitalDOs = baseDoctorHospitalDao.findByDoctorCode(doctorDO.getId());
@ -3784,7 +3846,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    chargeType = chargeType.replace(",","','");
                }
                String sqlCharge = "select charge_type as \"chargeType\",charge_name as \"chargeName\"," +
                        "req_fee  as \"reqFee\",dept_type_code as \"deptTypeCode\" " +
                        "req_fee  as \"reqFee\",zj_fee  as \"zjFee\",xt_fee  as \"xtFee\",dept_type_code as \"deptTypeCode\" " +
                        " from wlyy_charge_dict where 1=1";
                sqlCharge+=" and charge_type in ( '"+chargeType+"')";
                if(StringUtils.isNoneBlank(deptTyepCode)){
@ -3809,6 +3871,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    "LEFT JOIN wlyy_charge_dict d ON t.xtfz_charge_type = d.charge_type\n" +
                    "WHERE t.id = '"+doctorDO.getId()+"' ";
            chargeDictDOLists =  hibenateUtils.createSQLQuery(sqlCharge);
            rs.put("chargeTypeList",chargeDictDOLists);
            //机构科室信息
            List<BaseDoctorHospitalDO> hospitalDOs = baseDoctorHospitalDao.findByDoctorCode(doctorDO.getId());
            List<BaseDoctorHospitalDO> hospitalDOList = new ArrayList<>();
@ -3935,16 +3998,30 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                data.put("gender", IdCardUtil.getSexForIdcard(wlyyOutpatientDO.getIdcard()));
                data.put("question", wlyyOutpatientDO.getIcd10Name());
                String msg = "";
                if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                    data.put("type", "9");
                    msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个图文复诊已被医生取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                    sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "9", "doctorRefuseRemind", cancelRemark);
                }
                if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                    data.put("type", "16");
                    msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个视频复诊已被医生取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                    sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "16", "doctorRefuseRemind", cancelRemark);
                if ("1".equalsIgnoreCase(wlyyOutpatientDO.getOutpatientType())||"2".equalsIgnoreCase(wlyyOutpatientDO.getOutpatientType())){
                    if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                        data.put("type", "9");
                        msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个图文复诊已被医生取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                        sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "9", "doctorRefuseRemind", cancelRemark);
                    }
                    if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                        data.put("type", "16");
                        msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个视频复诊已被医生取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                        sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "16", "doctorRefuseRemind", cancelRemark);
                    }
                }else {
                    if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                        data.put("type", "1");
                        msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个图文咨询已被医生取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                        sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "1", "doctorRefuseRemind", cancelRemark);
                    }
                    if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                        data.put("type", "17");
                        msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个视频咨询已被医生取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                        sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "17", "doctorRefuseRemind", cancelRemark);
                    }
                }
                data.put("msg", msg);
                messageDO.setData(data.toString());
                systemMessageService.saveMessage(messageDO);
@ -4041,6 +4118,14 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                contentMsg = "医生已取消您的复诊申请,取消原因:"+remindMsg;
                first = outpatientDO.getConsumerName() + ",您好!您的视频复诊已取消";
            }
            if ("1".equals(type)) {
                contentMsg = "医生已取消您的复诊申请,取消原因:"+remindMsg;
                first = outpatientDO.getConsumerName() + ",您好!您的图文咨询已取消";
            }
            if ("17".equals(type)) {
                contentMsg = "医生已取消您的复诊申请,取消原因:"+remindMsg;
                first = outpatientDO.getConsumerName() + ",您好!您的视频咨询已取消";
            }
            logger.info("doctorRefuseRemind医生拒诊入参:outpatientId="+outpatientId);
            msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
        } else if("outPatientTimeOutRemind".equalsIgnoreCase(titelType)) {
@ -4074,13 +4159,23 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            }
            if ("1".equals(type)) {
                contentMsg = "您有一个图文咨询订单待支付,点击完成支付,如您已支付请忽略本条信息";
                first = consPatientDO.getName() + ",您好!您有一个图文咨询订单待支付,请及时支付。";
                msgUrl="/ims-wx/index.html#/chatRoom?type=1&consultCode="+consultTeam.getConsult();
                if (StringUtils.isNotBlank(outpatientId)){
                    msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
                    first = outpatientDO.getConsumerName() + ",您好!您有一个图文咨询订单待支付,请及时支付。";
                }else{
                    msgUrl="/ims-wx/index.html#/chatRoom?type=1&consultCode="+consultTeam.getConsult();
                    first = consPatientDO.getName() + ",您好!您有一个图文咨询订单待支付,请及时支付。";
                }
                logger.info("图文咨询订单待支付微信消息模板推送开始");
            } else if ("17".equals(type)) {
                contentMsg = "您有一个视频咨询订单待支付,点击完成支付,如您已支付请忽略本条信息";
                first =  consPatientDO.getName() + ",您好!您有一个视频咨询订单待支付,请及时支付。";
                msgUrl="/ims-wx/index.html#/chatRoom?type=1&consultCode="+consultTeam.getConsult();
                if (StringUtils.isNotBlank(outpatientId)){
                    msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
                    first =  outpatientDO.getConsumerName() + ",您好!您有一个视频咨询订单待支付,请及时支付。";
                }else{
                    msgUrl="/ims-wx/index.html#/chatRoom?type=1&consultCode="+consultTeam.getConsult();
                    first =  consPatientDO.getName() + ",您好!您有一个视频咨询订单待支付,请及时支付。";
                }
                logger.info("视频咨询订单待支付微信消息模板推送开始");
            }
@ -4095,7 +4190,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            contentMsg = "" + remindMsg;
            remark = "请您尽快回复";
        } else if ("outpatientMsgRemind".equalsIgnoreCase(titelType)) {
          if (StringUtils.isNotEmpty(outpatientId)){
              if ("16".equals(type)) {
                  first = doctorDO.getName() + doctorDO.getJobTitleName() + "医生已向您发起视频通话邀请,请点击详情进入视频诊室。";
                  contentMsg = "您的视频复诊已开始,错过将重新排队";
@ -4103,8 +4198,18 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                  msgUrl="/ims-wx/index.html#/returnVisit/preChat?type=16&outpatientId="+outpatientId;
                  logger.info("视频问诊已接诊提醒微信模板消息发送开始");
              }
          }
          if (consultTeam!=null){
              if ("17".equals(type)) {
                  first = doctorDO.getName() + doctorDO.getJobTitleName() + "医生已向您发起视频通话邀请,请点击详情进入视频诊室。";
                  contentMsg = "您的视频咨询已开始,错过将重新排队";
                  remark = "点击消息进入视频诊室接听视频通话,开始视频复诊。";
                  if (StringUtils.isNotEmpty(outpatientId)){
                      msgUrl="/ims-wx/index.html#/returnVisit/preChat?type=17&outpatientId="+outpatientId;
                  }else{
                      msgUrl="/ims-wx/index.html#/zx/prechat?consultCode="+consultTeam.getConsult();
                  }
                  logger.info("视频咨询已接诊提醒微信模板消息发送开始");
              }
          /*if (consultTeam!=null){
              if ("17".equals(type)) {
                  first = consDoctorDO.getName() + consDoctorDO.getJobTitleName() + "医生已向您发起视频通话邀请,请点击详情进入视频诊室。";
                  contentMsg = "您的视频咨询已开始,错过将重新排队";
@ -4112,19 +4217,37 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                  msgUrl="/ims-wx/index.html#/zx/prechat?consultCode="+consultTeam.getConsult();
                  logger.info("视频咨询已接诊提醒微信模板消息发送开始");
              }
          }
          }*/
        } else if ("videoOrderRemind".equalsIgnoreCase(titelType)) {
            if ("16".equals(type)) {
                first = "您的视频复诊已预约成功。";
                contentMsg = "预计" + outpatientDO.getDoctorName() + "医生将于" + DateUtil.dateToStrLong(outpatientDO.getRegisterDate()) + " 与您进行视频复诊。请留意微信公众号消息。";
                msgUrl="/ims-wx/index.html#/returnVisit/preChat?type=16&outpatientId="+outpatientId;
                if (StringUtils.isNoneBlank(outpatientDO.getDoctorName())){
                    first = "您的视频复诊已预约成功。";
                    contentMsg = "预计" + outpatientDO.getDoctorName() + "医生将于" + DateUtil.dateToStrLong(outpatientDO.getRegisterDate()) + " 与您进行视频复诊。请留意微信公众号消息。";
                }else {
                    first = outpatientDO.getPatientName()+"您好!您已成功发起快速视频复诊。";
                    contentMsg = "您已预约" + DateUtil.dateToStrLong(consultTeam.getCzrq()) +  "的视频复诊 与您进行视频复诊。请留意微信公众号消息。请耐心等待医生接单。如长时间无医生接单,建议选择医生发起视频复诊";
                }
                logger.info("视频复诊已预约成功微信消息模板推送开始");
            } else if ("17".equals(type)) {
                first = "您的视频咨询已预约成功。";
                contentMsg = "预计" + consDoctorDO.getName() + "医生将于" + DateUtil.dateToStrLong(consultTeam.getCzrq()) + " 与您进行视频咨询。请留意微信公众号消息。";
                msgUrl="/ims-wx/index.html#/zx/prechat?consultCode="+consultTeam.getConsult();
                if (StringUtils.isNotEmpty(outpatientId)){
                    msgUrl="/ims-wx/index.html#/returnVisit/preChat?type=17&outpatientId="+outpatientId;
                    if (StringUtils.isNoneBlank(outpatientDO.getDoctorName())){
                        first = "您的视频咨询已预约成功。";
                        contentMsg = "预计" + outpatientDO.getDoctorName() + "医生将于" + DateUtil.dateToStrLong(consultTeam.getCzrq()) + " 与您进行视频咨询。请留意微信公众号消息。";
                    }else{
                        first = outpatientDO.getPatientName()+"您好!您已成功发起快速视频咨询。";
                        contentMsg = "您已预约" + DateUtil.dateToStrLong(consultTeam.getCzrq()) +  "的视频咨询 与您进行视频咨询。请留意微信公众号消息。请耐心等待医生接单。如长时间无医生接单,建议选择医生发起视频咨询";
                    }
                }else{
                    msgUrl="/ims-wx/index.html#/zx/prechat?consultCode="+consultTeam.getConsult();
                    contentMsg = "预计" + consDoctorDO.getName() + "医生将于" + DateUtil.dateToStrLong(consultTeam.getCzrq()) + " 与您进行视频咨询。请留意微信公众号消息。";
                }
                logger.info("视频咨询已预约成功微信消息模板推送开始");
            }
            remark = "咨询开始时,医生将邀请您进行视频通话,请您关注消息提醒,及时接受医生视频邀请。";
@ -4202,17 +4325,6 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "视频复诊"));
                        newConfig.setKeyword1( "视频复诊支付");
                    }
                    newConfig.setKeyword2(outpatientDO.getHospitalName());
                    newConfig.setKeyword3(outpatientDO.getDoctorName());
                    //发起微信消息模板推送
                    newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                    logger.info("眼科微信消息模板推送 就诊支付提醒开始");
                }
                //咨询支付
                if (consultTeam!=null){
                    WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_pay_notice_zx", scene, 1);
                    BeanUtils.copyProperties(config, newConfig);
                    newConfig.setFirst(config.getFirst().replace("key1", consPatientDO.getName()));
                    if ("1".equals(type)) {
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "图文咨询"));
                        newConfig.setKeyword1("图文咨询支付");
@ -4220,13 +4332,31 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                        newConfig.setFirst(newConfig.getFirst().replace("key2", "视频咨询"));
                        newConfig.setKeyword1("视频咨询支付");
                    }
                    newConfig.setKeyword2( hospitalDO.getOrgName());
                    newConfig.setKeyword3( consDoctorDO.getName());
                    newConfig.setKeyword2(outpatientDO.getHospitalName());
                    newConfig.setKeyword3(outpatientDO.getDoctorName());
                    //发起微信消息模板推送
                    newConfig.setUrl(newConfig.getUrl() + "" + consultTeam.getConsult());
                    logger.info("眼科微信消息模板推送 咨询支付提醒开始");
                    newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                    logger.info("眼科微信消息模板推送 就诊支付提醒开始");
                }else {
                    //咨询支付
                    if (consultTeam!=null){
                        WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_pay_notice_zx", scene, 1);
                        BeanUtils.copyProperties(config, newConfig);
                        newConfig.setFirst(config.getFirst().replace("key1", consPatientDO.getName()));
                        if ("1".equals(type)) {
                            newConfig.setFirst(newConfig.getFirst().replace("key2", "图文咨询"));
                            newConfig.setKeyword1("图文咨询支付");
                        } else if ("17".equals(type)) {
                            newConfig.setFirst(newConfig.getFirst().replace("key2", "视频咨询"));
                            newConfig.setKeyword1("视频咨询支付");
                        }
                        newConfig.setKeyword2( hospitalDO.getOrgName());
                        newConfig.setKeyword3( consDoctorDO.getName());
                        //发起微信消息模板推送
                        newConfig.setUrl(newConfig.getUrl() + "" + consultTeam.getConsult());
                        logger.info("眼科微信消息模板推送 咨询支付提醒开始");
                    }
                }
            } else if ("prescriptionPayRemind".equalsIgnoreCase(titelType)) {
                scene = "cfzfts";
                WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_prescription_pay_notice", scene, 1);
@ -4255,49 +4385,53 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_outpatient_msg_notice_jz", scene, 1);
                    BeanUtils.copyProperties(config, newConfig);
                    newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getDoctorName()).replace("key2", doctorDO.getJobTitleName()));
                    newConfig.setFirst(config.getFirst().replace("key1", outpatientDO.getDoctorName()).replace("key2", StringUtils.isNoneBlank(doctorDO.getJobTitleName())?doctorDO.getJobTitleName():""));
                    newConfig.setKeyword1( outpatientDO.getDoctorName());
                    newConfig.setKeyword2(DateUtil.dateToStrLong(outpatientDO.getAdmDate()));
                    newConfig.setKeyword3(outpatientDO.getDeptName());
                    newConfig.setKeyword4( outpatientDO.getIcd10Name());
                    if ("16".equals(type)) {
                        newConfig.setRemark(config.getRemark().replace("key1", "视频复诊"));
                        newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                    } else if ("17".equals(type)) {
                        newConfig.setRemark(config.getRemark().replace("key1", "视频咨询"));
                        newConfig.setUrl(newConfig.getUrl().replace("type=16","type=17") + "" + outpatientDO.getId());
                    }
                    //发起微信消息模板推送
                    newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                    logger.info("眼科微信消息模板推送 视频问诊接诊提醒开始");
                }
                if (consultTeam!=null){
                    WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_outpatient_msg_notice_zx", scene, 1);
                    BeanUtils.copyProperties(config, newConfig);
                    newConfig.setFirst(config.getFirst().replace("key1", consPatientDO.getName()).replace("key2", consDoctorDO.getJobTitleName()));
                    newConfig.setKeyword1( consDoctorDO.getName());
                    newConfig.setKeyword2(DateUtil.dateToStrLong(consultTeam.getCzrq()));//咨询暂无挂号时间
                    newConfig.setKeyword3( hospitalDO.getDeptName());
                    newConfig.setKeyword4( consultTeam.getSymptoms());
                    if ("16".equals(type)) {
                        newConfig.setRemark(config.getRemark().replace("key1", "视频复诊"));
                    } else if ("17".equals(type)) {
                        newConfig.setRemark(config.getRemark().replace("key1", "视频咨询"));
                    logger.info("眼科微信消息模板推送 视频问诊接诊提醒开始");
                }else {
                    if (consultTeam!=null){
                        WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_outpatient_msg_notice_zx", scene, 1);
                        BeanUtils.copyProperties(config, newConfig);
                        newConfig.setFirst(config.getFirst().replace("key1", consPatientDO.getName()).replace("key2", consDoctorDO.getJobTitleName()));
                        newConfig.setKeyword1( consDoctorDO.getName());
                        newConfig.setKeyword2(DateUtil.dateToStrLong(consultTeam.getCzrq()));//咨询暂无挂号时间
                        newConfig.setKeyword3( hospitalDO.getDeptName());
                        newConfig.setKeyword4( consultTeam.getSymptoms());
                        if ("16".equals(type)) {
                            newConfig.setRemark(config.getRemark().replace("key1", "视频复诊"));
                        } else if ("17".equals(type)) {
                            newConfig.setRemark(config.getRemark().replace("key1", "视频咨询"));
                        }
                        //发起微信消息模板推送
                        newConfig.setUrl(newConfig.getUrl() + "" + consultTeam.getConsult());
                        logger.info("眼科微信消息模板推送 视频咨询接诊提醒开始");
                    }
                    //发起微信消息模板推送
                    newConfig.setUrl(newConfig.getUrl() + "" + consultTeam.getConsult());
                    logger.info("眼科微信消息模板推送 视频咨询接诊提醒开始");
                }
            } else if ("videoOrderRemind".equalsIgnoreCase(titelType)) {
                scene = "spwzyytx";
                if (StringUtils.isNotEmpty(outpatientId)){
                    WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_video_notice_fz", scene, 1);
                    WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_video_notice", scene, 1);
                    BeanUtils.copyProperties(config, newConfig);
                    if ("16".equals(type)) {
                        newConfig.setFirst(config.getFirst().replaceFirst("key1", "视频复诊"));
                    }
                    if ("17".equals(type)) {
                        newConfig.setFirst(config.getFirst().replaceFirst("key1", "视频咨询"));
                    }
                    newConfig.setKeyword1( outpatientDO.getConsumerName());
                    newConfig.setKeyword2( outpatientDO.getDeptName());
                    newConfig.setKeyword3( outpatientDO.getDoctorName());
@ -4306,24 +4440,23 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    //发起微信消息模板推送
                    newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                    logger.info("眼科微信消息模板推送 视频问诊预约提醒开始");
                }
                if (consultTeam!=null){
                    WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_video_notice_zx", scene, 1);
                    BeanUtils.copyProperties(config, newConfig);
                    if ("17".equals(type)) {
                        newConfig.setFirst(config.getFirst().replaceFirst("key1", "视频咨询"));
                }else {
                    if (consultTeam!=null){
                        WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_video_notice", scene, 1);
                        BeanUtils.copyProperties(config, newConfig);
                        if ("17".equals(type)) {
                            newConfig.setFirst(config.getFirst().replaceFirst("key1", "视频咨询"));
                        }
                        newConfig.setKeyword1(consPatientDO.getName());
                        newConfig.setKeyword2(hospitalDO.getDeptName());
                        newConfig.setKeyword3(consDoctorDO.getName());
                        newConfig.setKeyword4(DateUtil.dateToStrLong(consultTeam.getCzrq()));
                        newConfig.setKeyword5(generalDoctorWaitingNumber(consDoctorDO.getId(), wxId, outpatientId));
                        //发起微信消息模板推送
                        newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                        logger.info("眼科微信消息模板推送 视频咨询预约提醒开始");
                    }
                    newConfig.setKeyword1(consPatientDO.getName());
                    newConfig.setKeyword2(hospitalDO.getDeptName());
                    newConfig.setKeyword3(consDoctorDO.getName());
                    newConfig.setKeyword4(DateUtil.dateToStrLong(consultTeam.getCzrq()));
                    newConfig.setKeyword5(generalDoctorWaitingNumber(consDoctorDO.getId(), wxId, outpatientId));
                    //发起微信消息模板推送
                    newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
                    logger.info("眼科微信消息模板推送 视频咨询预约提醒开始");
                }
            } else if ("evaluateRemind".equalsIgnoreCase(titelType)) {
                scene = "fwqjtx";
                WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_evaluate_notice", scene, 1);
@ -4573,9 +4706,17 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        //协同门诊
        if (3 == type) {
            sql += " AND room.reservation_type=2 ";
        } else {
        } else if (4==type){
            //专家咨询
            sql += " AND room.reservation_type=3 AND room.consult_type =1";
        } else if (1==type) {
            //在线复诊
            sql += " AND room.reservation_type=1 AND room.consult_type =1";
        }else if (2==type) {//视频复诊
            //在线复诊
            sql += " AND room.reservation_type=1 AND room.consult_type=" + type;
            sql += " AND room.reservation_type !=3 AND room.consult_type =2";
        } else {
        }
        if (StringUtils.isNoneBlank(dept)) {
@ -4584,7 +4725,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        if(StringUtils.isNoneBlank(sex)){
            sql += " AND patient.sex=" + sex + " ";
        }if(StringUtils.isNoneBlank(keyword)){
            sql += " AND patient.name like '%" + keyword + "%' ";
            sql += " AND outpatient.patient_name like '%" + keyword + "%' ";
        }
        if(StringUtils.isNoneBlank(ageGroup)){
            String[] age = ageGroup.split(",");
@ -4621,8 +4762,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                       if (StringUtils.isNotBlank(basePatientDO.getIdcard())){
                           patientAge = DateUtil.getAgeForIdcard(basePatientDO.getIdcard());
                           outpatient.put("patientAge", DateUtil.getAgeForIdcard(basePatientDO.getIdcard()));
                           patientSex =basePatientDO.getSex();
                       }
                       patientSex =basePatientDO.getSex();
                   }
                }
                outpatient.put("patientAge", patientAge);
@ -5242,6 +5383,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                sql += " and d.del='1' order by d.consult_status DESC ,evaluate.score desc,a.total " + consutlSort;
            }else{
                sql += " and d.del='1' order by d.consult_status desc nulls last ,evaluate.score desc nulls last ,a.total " + consutlSort;
                sql+=" NULLS LAST,\n" +
                        "\tD.id DESC";
            }
        }else {
            sql += " and d.del='1' order by d.consult_status DESC ,evaluate.score desc,a.total " + consutlSort;
@ -5284,7 +5427,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    chargeType = chargeType.replace(",","','");
                }
                String sqlCharge = "select charge_type as \"chargeType\",charge_name as \"chargeName\"," +
                        "req_fee  as \"reqFee\",dept_type_code as \"deptTypeCode\" " +
                        "req_fee  as \"reqFee\",zj_fee  as \"zjFee\",xt_fee  as \"xtFee\",dept_type_code as \"deptTypeCode\" " +
                        " from wlyy_charge_dict where 1=1";
                sqlCharge+=" and charge_type in ( '"+chargeType+"')";
                if (StringUtils.isNoneBlank(deptTyepCode)){
@ -5309,6 +5452,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    "LEFT JOIN wlyy_charge_dict d ON t.xtfz_charge_type = d.charge_type\n" +
                    "WHERE t.id = '"+map.get("id")+"' ";
            chargeDictDOLists =  hibenateUtils.createSQLQuery(sqlCharge);
            map.put("chargeTypeList",chargeDictDOLists);
            //查询医生各项评价平均分
            String sqlscore = "SELECT " +
                    "AVG(a.score) AS \"score\"," +
@ -5896,6 +6040,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                "AND room.outpatient_id=outpatient.id " +
                "AND consult.relation_code=outpatient.id " +
                "AND outpatient.pay_status=1 " +
                "AND outpatient.type =2 " +
                "AND consult.status = 0 ";
        if (StringUtils.isNoneBlank(doctor)) {
            sql = sql + "AND room.doctor='" + doctor + "' " +
@ -6000,7 +6145,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        return waitCount.toString();
    }
    public com.alibaba.fastjson.JSONArray getWaitingForVisitVideoPrescriptionByDoctor(String doctor, String wxId) {
    public com.alibaba.fastjson.JSONArray getWaitingForVisitVideoPrescriptionByDoctor(String doctor, String wxId,String outpatientType,String keyWord) {
        String condition = "";
        if ("xm_ykyy_wx".equals(wxId)) {
            if(flag){
@ -6046,11 +6191,19 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                "AND outpatient.status = 0 " +
                "AND outpatient.pay_status = 1 " +
                "AND room.doctor='" + doctor + "' " +
                "AND room.reservation_time is not null " +
                "AND room.consult_type= 2 ";/* +
                "AND room.reservation_time is not null ";/* +
                "AND room.reservation_time >= '"+DateUtil.dateToStrShort(new Date())+" 00:00:00' order by room.reservation_time ASC ";
//                "AND room.reservation_time>='"+DateUtil.getStringDate("yyyy-MM-dd")+" 00:00:00"+"' ";*/
        if(StringUtils.isNotBlank(outpatientType)&&"1".equalsIgnoreCase(outpatientType)){
            sql+="  AND room.consult_type= 2 and room.reservation_type in (1,2)";
        } else if (StringUtils.isNotBlank(outpatientType)&&"4".equalsIgnoreCase(outpatientType)) {
            sql+="  AND room.consult_type= 2 and room.reservation_type = 3";
        } else {
            sql += " AND room.consult_type= 2 ";
        }
        if (StringUtils.isNotBlank(keyWord)){
            sql += " AND outpatient.patient_name like '%"+keyWord+"%'";
        }
        if ("xm_ykyy_wx".equals(wxId)) {
            if(flag){
                sql += " AND room.reservation_time >= str_to_date('" + DateUtil.dateToStrShort(new Date()) + " 00:00:00','YYYY-MM-DD HH24:MI:SS')";
@ -6159,6 +6312,49 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        wlyyOutpatientDO.setDoctor(doctor);
        wlyyOutpatientDO.setDoctorName(baseDoctorDO.getName());
        outpatientDao.save(wlyyOutpatientDO);
        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
            String doctorYktid ="";
            if (baseDoctorDO!=null){
                if(StringUtils.isNoneBlank(baseDoctorDO.getYktDoctorId())){
                    doctorYktid = baseDoctorDO.getYktDoctorId();
                }else {
                    DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(baseDoctorDO.getId());
                    if (doctorMappingDO!=null){
                        String doctorResponse = ykyyService.getYktDoctor(doctorMappingDO.getMappingCode());
                        System.out.println("Continue");
                        com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(doctorResponse);
                        if (jsonObject.getInteger("code")==200){
                            com.alibaba.fastjson.JSONArray array = jsonObject.getJSONArray("data");
                            if (array!=null&&array.size()!=0){
                                doctorYktid=array.getJSONObject(0).getString("DOCTORUSERID");
                            }
                        }
                    }
                }
            }
            String orderNo = "";
            BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outpatientCode);
            if (businessOrderDO!=null){
                orderNo = businessOrderDO.getOrderNo();
            }
            String res = ykyyService.updateDoctorIdByOrderId(doctorYktid,orderNo);
            WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
            if (StringUtils.isNoneBlank(res)){
                com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(res);
                if (object!=null){
                    wlyyHttpLogDO.setCode(object.getString("code"));
                }
            }
            wlyyHttpLogDO.setName("抢单医生id写入眼科通");
            wlyyHttpLogDO.setCode("update_doctorid_by_orderno");
            wlyyHttpLogDO.setRequest("doctorId="+doctorYktid+";"+"orderNo="+orderNo);
            wlyyHttpLogDO.setDoctor(doctor);
            wlyyHttpLogDO.setResponse(res);
            wlyyHttpLogDO.setCreateTime(new Date());
            wlyyHttpLogDao.save(wlyyHttpLogDO);
        }
    }
@ -6434,7 +6630,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                "AND outpatient.doctor='" + doctor + "' " +
                "AND outpatient.pay_status = 1 " +
                "AND outpatient.outpatient_type= '" + outpatient_type + "'  ";
        if ("1".equals(outpatient_type)) {//复诊
        if ("1".equals(outpatient_type)||"3".equals(outpatient_type)) {//复诊
            sql = sql + " AND outpatient.type= '" + type + "' ";
            if ("2".equals(type)) {//视频复诊才需要判断时间,
                if ("xm_ykyy_wx".equals(wxId)) {
@ -6565,17 +6761,58 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @param outpatient
     * @return
     */
    public SystemMessageDO sendOutPatientMes(WlyyOutpatientDO outpatient,boolean payFlag) {
    public SystemMessageDO sendOutPatientMes(WlyyOutpatientDO outpatient,boolean payFlag)  {
        System.out.println("发送新增门诊信息");
        SystemMessageDO systemMessageDO = new SystemMessageDO();
        String msg = "";
        JSONObject data = new JSONObject();
        try {
            JSONObject data = new JSONObject();
            //1.在线复诊2.协同门诊
            if ("2".equals(outpatient.getOutpatientType())) {
                systemMessageDO.setTitle("协同门诊");
                systemMessageDO.setType("3");
            } else {
            } else if ("3".equals(outpatient.getOutpatientType())) {//专家咨询
                //1.图文 2.视频 3家医
                if ("1".equals(outpatient.getType())) {
                    systemMessageDO.setTitle("图文咨询");
                    systemMessageDO.setType("18");
                    if (payFlag){
                        saveInquirySystemMessage(outpatient,null);
                    }
                    msg="图文咨询";
                } else if("3".equals(outpatient.getType())){
                    systemMessageDO.setTitle("家医咨询");
                    systemMessageDO.setType("15");
                    msg="家医咨询";
                    if (payFlag){
                        saveInquirySystemMessage(outpatient,null);
                    }
                }else {
                    systemMessageDO.setTitle("视频咨询预约成功");
                    systemMessageDO.setType("17");
                    if (payFlag){
                        saveInquirySystemMessage(outpatient,null);
                    }
                    msg = "您的视频咨询已预约成功。\n" +
                            "预计" + outpatient.getDoctorName() + "医生将于" + outpatient.getRegisterDate() + " 与您进行视频咨询。请留意系统消息或微信公众号消息。咨询开始时,医生将邀请您进行视频通话,请您关注消息提醒,及时接受医生视频邀请。";
                    sendWxTemplateMsg(wechatId, outpatient.getId(),null, "17", "videoOrderRemind", "");
                }
                systemMessageDO.setReceiver(outpatient.getDoctor());
                systemMessageDO.setReceiverName(outpatient.getDoctorName());
                systemMessageDO.setRelationCode(outpatient.getId());
                systemMessageDO.setSender(outpatient.getPatient());
                systemMessageDO.setSenderName(outpatient.getPatientName());
                systemMessageDO.setRelationCode(outpatient.getId());
                data.put("name", outpatient.getPatientName());
                data.put("age", IdCardUtil.getAgeForIdcard(outpatient.getIdcard()));
                data.put("gender", IdCardUtil.getSexForIdcard_new(outpatient.getIdcard()));
                data.put("question", outpatient.getDescription());
                data.put("msg", msg);
                systemMessageDO.setData(data.toString());
                logger.info("添加模板消息4");
                systemMessageService.saveMessage(systemMessageDO);
            } else if ("1".equals(outpatient.getOutpatientType()))  {//在线复诊
                //1.图文 2.视频
                if ("1".equals(outpatient.getType())) {
                    systemMessageDO.setTitle("图文复诊");
@ -6583,42 +6820,44 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    if (payFlag){
                        saveInquirySystemMessage(outpatient,null);
                    }
                    msg="图文复诊";
                } else {
                    systemMessageDO.setTitle("视频复诊预约成功");
                    systemMessageDO.setType("2");
                    if (payFlag){
                        saveInquirySystemMessage(outpatient,null);
                    }
                    msg = "您的视频复诊已预约成功。\n" +
                            "预计" + outpatient.getDoctorName() + "医生将于" + outpatient.getRegisterDate() + " 与您进行视频咨询。请留意系统消息或微信公众号消息。咨询开始时,医生将邀请您进行视频通话,请您关注消息提醒,及时接受医生视频邀请。";
                    systemMessageDO.setReceiver(outpatient.getDoctor());
                    systemMessageDO.setReceiverName(outpatient.getDoctorName());
                    systemMessageDO.setRelationCode(outpatient.getId());
                    systemMessageDO.setSender(outpatient.getPatient());
                    systemMessageDO.setSenderName(outpatient.getPatientName());
                    systemMessageDO.setRelationCode(outpatient.getId());
                    data.put("name", outpatient.getPatientName());
                    data.put("age", IdCardUtil.getAgeForIdcard(outpatient.getIdcard()));
                    data.put("gender", IdCardUtil.getSexForIdcard_new(outpatient.getIdcard()));
                    data.put("question", outpatient.getDescription());
                    data.put("msg", msg);
                    systemMessageDO.setData(data.toString());
                    systemMessageService.saveMessage(systemMessageDO);
                    sendWxTemplateMsg(wechatId, outpatient.getId(),null, "17", "videoOrderRemind", "");
                    sendWxTemplateMsg(wechatId, outpatient.getId(),null, "16", "videoOrderRemind", "");
                }
                systemMessageDO.setReceiver(outpatient.getDoctor());
                systemMessageDO.setReceiverName(outpatient.getDoctorName());
                systemMessageDO.setRelationCode(outpatient.getId());
                systemMessageDO.setSender(outpatient.getPatient());
                systemMessageDO.setSenderName(outpatient.getPatientName());
                systemMessageDO.setRelationCode(outpatient.getId());
                logger.info("添加模板消息5");
                data.put("name", outpatient.getPatientName());
                data.put("age", IdCardUtil.getAgeForIdcard(outpatient.getIdcard()));
                data.put("gender", IdCardUtil.getSexForIdcard_new(outpatient.getIdcard()));
                data.put("question", outpatient.getDescription());
                data.put("msg", msg);
                systemMessageDO.setData(data.toString());
                systemMessageService.saveMessage(systemMessageDO);
            }
            BasePatientDO patient = basePatientDao.findById(outpatient.getPatient());
            if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
                ykyyService.pushNotificationToYktPatient(patient.getYktId(), systemMessageDO.getTitle(), data.get("msg").toString());
            }
        } catch (Exception e) {
            logger.error("sendOutPatientMes :" + e.toString());
            return null;
            return systemMessageDO;
        }catch (Exception e){
            e.printStackTrace();
            logger.info("sendOutPatientMes"+e.getMessage());
            return  null;
        }
        return systemMessageDO;
    }
    public void saveInquirySystemMessage(WlyyOutpatientDO outpatient,ConsultTeamDo consultTeamDo) {
@ -6629,14 +6868,23 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        systemMessageDO.setType("11");
        JSONObject data = new JSONObject();
        if (outpatient!=null){
            if ("1".equals(outpatient.getType())) {
                type = "9";
                msg = outpatient.getPatientName() + ",您好!您有一个图文复诊订单待支付,请及时支付。点击完成支付,如您已支付请忽略本条信息。";
            } else if ("2".equals(outpatient.getType())){
                type = "16";
                msg = outpatient.getPatientName() + ",您好!您有一个视频复诊订单待支付,请及时支付。点击完成支付,如您已支付请忽略本条信息。";
            if("1".equalsIgnoreCase(outpatient.getOutpatientType())){
                if ("1".equals(outpatient.getType())) {
                    type = "9";
                    msg = outpatient.getPatientName() + ",您好!您有一个图文复诊订单待支付,请及时支付。点击完成支付,如您已支付请忽略本条信息。";
                } else if ("2".equals(outpatient.getType())){
                    type = "16";
                    msg = outpatient.getPatientName() + ",您好!您有一个视频复诊订单待支付,请及时支付。点击完成支付,如您已支付请忽略本条信息。";
                }
            }else if ("3".equalsIgnoreCase(outpatient.getOutpatientType())){
                if ("1".equals(outpatient.getType())) {
                    type = "1";
                    msg = outpatient.getPatientName() + ",您好!您有一个图文咨询订单待支付,请及时支付。点击完成支付,如您已支付请忽略本条信息。";
                } else if ("2".equals(outpatient.getType())){
                    type = "17";
                    msg = outpatient.getPatientName() + ",您好!您有一个视频咨询订单待支付,请及时支付。点击完成支付,如您已支付请忽略本条信息。";
                }
            }
            systemMessageDO.setSender(outpatient.getDoctor());
            systemMessageDO.setSenderName(outpatient.getDoctorName());
            systemMessageDO.setRelationCode(outpatient.getId());
@ -6725,6 +6973,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        one.setDept(outpatientDO.getDept());
        one.setDeptName(outpatientDO.getDeptName());
        one.setType(outpatientDO.getType());
        one.setOutpatientType(outpatientDO.getOutpatientType());
        WlyyOutpatientDO outpatient = outpatientDao.save(one);
        WlyyPatientRegisterTimeDO registerTimeDO = null;
@ -6742,6 +6991,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                registerTimeDO.setOutpatientId(outpatient.getId());
                registerTimeDO.setCreateTime(new Date());
                patientRegisterTimeDao.save(registerTimeDO);
            }else {
                one.setRegisterDate(new Date());
                outpatientDao.save(one);
            }
        } catch (Exception e) {
            throw new RuntimeException("号源已经被预约,请选择其他号源");
@ -6761,6 +7013,49 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            }
            hospitalWaitingRoomDao.save(roomDOs);
        }
        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
            String doctorYktid = "";
            String orderNo = "";
            BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(outpatientDO.getDoctor());
            if (baseDoctorDO!=null){
                if(StringUtils.isNoneBlank(baseDoctorDO.getYktDoctorId())){
                    doctorYktid = baseDoctorDO.getYktDoctorId();
                }else {
                    DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(baseDoctorDO.getId());
                    if (doctorMappingDO!=null){
                        String doctorResponse = ykyyService.getYktDoctor(doctorMappingDO.getMappingCode());
                        System.out.println("Continue");
                        com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(doctorResponse);
                        if (jsonObject.getInteger("code")==200){
                            com.alibaba.fastjson.JSONArray array = jsonObject.getJSONArray("data");
                            if (array!=null&&array.size()!=0){
                                doctorYktid=array.getJSONObject(0).getString("DOCTORUSERID");
                            }
                        }
                    }
                }
            }
            BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outpatientDO.getId());
            if (businessOrderDO!=null){
                orderNo = businessOrderDO.getOrderNo();
            }
            String res = ykyyService.updateDoctorIdByOrderId(doctorYktid,orderNo);
            WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
            if (StringUtils.isNoneBlank(res)){
                com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(res);
                if (object!=null){
                    wlyyHttpLogDO.setCode(object.getString("code"));
                }
            }
            wlyyHttpLogDO.setName("患者选择抢单医生id写入眼科通");
            wlyyHttpLogDO.setCode("update_doctorid_by_orderno");
            wlyyHttpLogDO.setRequest("doctorId="+doctorYktid+";"+"orderNo="+orderNo);
            wlyyHttpLogDO.setDoctor(outpatientDO.getDoctor());
            wlyyHttpLogDO.setPatient(outpatientDO.getConsumer());
            wlyyHttpLogDO.setResponse(res);
            wlyyHttpLogDO.setCreateTime(new Date());
            wlyyHttpLogDao.save(wlyyHttpLogDO);
        }
        return outpatient;
    }
@ -6821,7 +7116,6 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                        patient.setCreateTime(new Date());
                        patient.setUpdateTime(new Date());
                        patient.setBirthday(DateUtil.strToDate(biz.getString("birthday"), "yyyyMMdd"));
                        basePatientDao.save(patient);
                        rsMap.put("sCode", auth_status);
                        rsMap.put("sMes", "success");
@ -8231,6 +8525,33 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     */
    public Boolean sendOutPatientSuggest(String advicesJson) {
        List<WlyyConsultAdvice> advices = (List<WlyyConsultAdvice>) com.alibaba.fastjson.JSONArray.parseArray(advicesJson, WlyyConsultAdvice.class);
        if (advices!=null&&advices.size()>0){
            WlyyConsultAdvice advice = advices.get(0);
            String consult =  advice.getConsult();
            String sql = "select t.relation_code as \"relationCode\" from wlyy_consult t where t.id = '"+consult+"'";
            List<Map<String,Object>> map = hibenateUtils.createSQLQuery(sql);
            if(map!=null&&map.size()>0){
                String outpatientId= map.get(0).get("relationCode").toString();
               WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId);
               if (wlyyOutpatientDO!=null){
                   StringBuffer content = new StringBuffer();
                   StringBuffer icd10Code = new StringBuffer();
                   for (WlyyConsultAdvice consultAdvice:advices){
                       content.append(consultAdvice.getAdviceValue()+",");
                       icd10Code.append(consultAdvice.getAdviceKey()+",");
                   }
                   if (content!=null&&content.length()>0){
                       System.out.println("content+====="+content);
                       content.deleteCharAt(content.length()-1);
                       icd10Code.deleteCharAt(icd10Code.length()-1);
                   }
                   wlyyOutpatientDO.setIcd10Name(content.toString());
                   wlyyOutpatientDO.setIcd10(icd10Code.toString());
                   outpatientDao.save(wlyyOutpatientDO);
               }
            }
        }
        wlyyConsultAdviceDao.save(advices);
        return true;
    }
@ -9186,8 +9507,10 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        return null;
    }
    public static void main(String[] args) {
        String ss = DateUtil.getStringDateShort();
        System.out.println(ss);
    }
    public com.alibaba.fastjson.JSONObject selectHospitalInfo(String doctorId,String orgCode){
        /**
         * 1、今日待就诊:今日当前家庭医生在当前医院的未完成的协同门诊书
@ -9202,8 +9525,10 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
         6、累计就诊:当前医院累计协同门诊的已接诊数量
         */
        Date startTime  = DateUtil.strToDateLong(DateUtil.getStringDateShort()+" 00:00:00");
        Date endTime  = DateUtil.strToDateLong(DateUtil.getStringDateShort()+" 23:59:59");
        String nowDate = DateUtil.getStringDateShort();
        Date startTime  = DateUtil.strToDateLong(nowDate+" 00:00:00");
        Date endTime  = DateUtil.strToDateLong(nowDate+" 23:59:59");
        com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
        // 1、今日待就诊:今日当前家庭医生在当前医院的未完成的协同门诊书
        List<WlyyOutpatientDO> outpatientDOS =  outpatientDao.findByGeneralDoctorAndStatusAndDate(doctorId,startTime,endTime,"0,1,2");
@ -9216,12 +9541,22 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            jsonObject.put("nextTime",null);
        }
        //3、服务评分:当前医院的综合服务评分
        //在线医生:当前医院在班的专科医生数
        String sql ="SELECT d.id as \"id\",d.name as \"name\" FROM base_doctor d WHERE (EXISTS (SELECT 1 FROM wlyy_doctor_work_time t WHERE t.doctor = d.id AND t.start_time >=:startTime AND t.end_time <=:endTime ) OR  d.consult_status = '1')";
        Map<String, Object> params = new HashedMap();
        params.put("startTime",startTime);
        params.put("endTime",endTime);
        String timeCondition="";
        if("xm_ykyy_wx".equals(wechatId)){
            if (flag){
                timeCondition+="AND t.start_time >= '"+nowDate+" 00:00:00'";
                timeCondition+="AND t.start_time <= '"+nowDate+" 23:59:59'";
            }else {
                timeCondition+="AND t.start_time >= to_date('"+nowDate+" 00:00:00','yyyy-mm-dd hh24:mi:ss')";
                timeCondition+="AND t.start_time <= to_date('"+nowDate+" 23:59:59','yyyy-mm-dd hh24:mi:ss')";
            }
        }else{
            timeCondition+="AND t.start_time >= '"+nowDate+" 00:00:00'";
            timeCondition+="AND t.start_time <= '"+nowDate+" 23:59:59'";
        }
        String sql ="SELECT d.id as \"id\",d.name as \"name\" FROM base_doctor d WHERE (EXISTS (SELECT 1 FROM wlyy_doctor_work_time t WHERE t.doctor = d.id "+timeCondition+"  ) OR  d.consult_status = '1')";
        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql, params);
        jsonObject.put("onlineDoctors",list.size());
@ -9434,5 +9769,47 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            return "ok";
        }
    }
    public List<Map<String,Object>> findOutpatientAndPatient(String startTime,String endTime){
        String sql  = "SELECT\n" +
                "\tt.status as \"status\",\n" +
                "\tt.source as \"source\",\n" +
                "\tt.outpatient_type as \"outpatientType\",\n" +
                "\tt.create_time as \"createTime\",\n" +
                "\tb.idcard as \"idCard\" \n" +
                "FROM\n" +
                "\twlyy_outpatient t\n" +
                "\tLEFT JOIN base_patient b ON t.patient = b.id where 1=1 ";
        if (StringUtils.isNoneBlank(startTime)){
            if("xm_ykyy_wx".equals(wechatId)){
                if (flag){
                    sql+=" and t.create_time >= '" + startTime + " ' ";
                }else {
                    sql+=" and t.create_time >= to_date('" + startTime + "', 'yyyy-mm-dd hh24:mi:ss') ";
                }
            }else{
                sql+=" and t.create_time >= '" + startTime + "' ";
            }
        }
        if (StringUtils.isNoneBlank(endTime)){
            if("xm_ykyy_wx".equals(wechatId)){
                if (flag){
                    sql+=" and t.create_time <= '" + endTime + "' ";
                }else {
                    sql+=" and t.create_time <= to_date('" + endTime + "', 'yyyy-mm-dd hh24:mi:ss') ";
                }
            }else{
                sql+=" and t.create_time <= '" + endTime + "'";
            }
        }
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql);
        for (Map<String,Object> map:list){
            if (map.get("createTime")!=null){
                map.put("createTime",DateUtil.dateToStrLong(DateUtil.strToDateLong(map.get("createTime").toString())));
                map.put("orgCode",wechatId);
            }
        }
        return list;
    }
}

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

@ -330,7 +330,6 @@ public class YkyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
        outpatientDO.setStatus("0");
        outpatientDO.setCreateTime(new Date());
        outpatientDO.setIdcard(patientDO.getIdcard());
        outpatientDO.setOutpatientType("1");
        outpatientDO.setCreateTime(new Date());
        if (!payFlag){
            outpatientDO.setPayStatus(1);
@ -343,50 +342,79 @@ public class YkyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
        WlyyOutpatientDO outpatient = outpatientDao.save(outpatientDO);
        BusinessOrderDO businessOrderDO = new BusinessOrderDO();
        businessOrderDO.setRelationCode(outpatient.getId());
        businessOrderDO.setRelationName("复诊-诊查费");
        businessOrderDO.setDescription("复诊-诊查费");
        businessOrderDO.setRematk(outpatient.getDescription());
        businessOrderDO.setPatient(outpatient.getConsumer());
        businessOrderDO.setPatientName(outpatient.getConsumerName());
        businessOrderDO.setDoctor(outpatient.getDoctor());
        if (outpatientDO.getType().equalsIgnoreCase("1")) {
            businessOrderDO.setOrderType(1);
            businessOrderDO.setOrderCategory("2");
        } else if (outpatientDO.getType().equalsIgnoreCase("2")) {
            businessOrderDO.setOrderType(3);
            businessOrderDO.setOrderCategory("3");
        if("3".equalsIgnoreCase(outpatient.getOutpatientType())){
            businessOrderDO.setRelationCode(outpatient.getId());
            businessOrderDO.setRelationName("专家咨询费");
            businessOrderDO.setDescription("专家咨询费");
            businessOrderDO.setRematk(outpatient.getDescription());
            businessOrderDO.setPatient(outpatient.getConsumer());
            businessOrderDO.setPatientName(outpatient.getConsumerName());
            businessOrderDO.setDoctor(outpatient.getDoctor());
            if (outpatientDO.getType().equalsIgnoreCase("1")) {
                businessOrderDO.setOrderType(1);
                businessOrderDO.setOrderCategory("1");
            } else if (outpatientDO.getType().equalsIgnoreCase("2")) {
                businessOrderDO.setOrderType(17);
                businessOrderDO.setOrderCategory("1");
            }
        }else {
            businessOrderDO.setRelationCode(outpatient.getId());
            businessOrderDO.setRelationName("复诊-诊查费");
            businessOrderDO.setDescription("复诊-诊查费");
            businessOrderDO.setRematk(outpatient.getDescription());
            businessOrderDO.setPatient(outpatient.getConsumer());
            businessOrderDO.setPatientName(outpatient.getConsumerName());
            businessOrderDO.setDoctor(outpatient.getDoctor());
            if (outpatientDO.getType().equalsIgnoreCase("1")) {
                businessOrderDO.setOrderType(1);
                businessOrderDO.setOrderCategory("2");
            } else if (outpatientDO.getType().equalsIgnoreCase("2")) {
                businessOrderDO.setOrderType(3);
                businessOrderDO.setOrderCategory("3");
            }
        }
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("WX_MONEY");
        Double price = 0.0;
        String chargeType1 = null;
        if (outpatient.getOutpatientType().equalsIgnoreCase("1")){
            if(outpatientDO.getType().equalsIgnoreCase("1")){
                chargeType1 = doctorDO.getTwfzChargeType();
            }else if(outpatientDO.getType().equalsIgnoreCase("2")){
                chargeType1 = doctorDO.getSpfzChargeType();
        if (doctorDO!=null){
            if (outpatient.getOutpatientType().equalsIgnoreCase("1")){
                if(outpatientDO.getType().equalsIgnoreCase("1")){
                    chargeType1 = doctorDO.getTwfzChargeType();
                }else if(outpatientDO.getType().equalsIgnoreCase("2")){
                    chargeType1 = doctorDO.getSpfzChargeType();
                }
            }else if (outpatient.getOutpatientType().equalsIgnoreCase("3")){
                if(outpatientDO.getType().equalsIgnoreCase("1")){
                    chargeType1 = doctorDO.getTwzxChargeType();
                }else if(outpatientDO.getType().equalsIgnoreCase("2")){
                    chargeType1 = doctorDO.getSpzxChargeType();
                }
            }else if (outpatient.getOutpatientType().equalsIgnoreCase("2")){
                chargeType1 = doctorDO.getXtfzChargeType();
            }
        }else if (outpatient.getOutpatientType().equalsIgnoreCase("3")){
            if(outpatientDO.getType().equalsIgnoreCase("1")){
                chargeType1 = doctorDO.getTwzxChargeType();
            }else if(outpatientDO.getType().equalsIgnoreCase("2")){
                chargeType1 = doctorDO.getSpzxChargeType();
            if(doctorDO!=null){
                if (StringUtils.isNoneBlank(chargeType1)){
                    WlyyChargeDictDO chargeDictDO = wlyyChargeDictDao.findByChargeType(chargeType1);
                    if (chargeDictDO!=null){
                        price = chargeDictDO.getReqFee();
                    }else {
                        price = Double.parseDouble(hospitalSysDictDO.getDictValue());
                    }
                }
            }else {
                price = Double.parseDouble(hospitalSysDictDO.getDictValue());
            }
        }else if (outpatient.getOutpatientType().equalsIgnoreCase("2")){
            chargeType1 = doctorDO.getXtfzChargeType();
        }
        if(doctorDO!=null){
            if (StringUtils.isNoneBlank(doctorDO.getChargeType())){
                WlyyChargeDictDO chargeDictDO = wlyyChargeDictDao.findByChargeType(chargeType1);
        }else {
            if (StringUtils.isNoneBlank(chargeType)){
                WlyyChargeDictDO chargeDictDO = wlyyChargeDictDao.findByChargeType(chargeType);
                if (chargeDictDO!=null){
                    price = chargeDictDO.getReqFee();
                }else {
                    price = Double.parseDouble(hospitalSysDictDO.getDictValue());
                }
            }
        }else {
            price = Double.parseDouble(hospitalSysDictDO.getDictValue());
        }
        /*if (doctorDO != null && StringUtils.isNoneBlank(doctorDO.getFee())) {
            price = Double.parseDouble(doctorDO.getFee());
        }else {
@ -400,6 +428,7 @@ public class YkyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
        businessOrderDO.setPayPrice(price*100);
        if (!flag){
            businessOrderDO = businessOrderService.saveOrder(businessOrderDO);
        }
@ -417,45 +446,47 @@ public class YkyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
        } catch (Exception e) {
            throw new RuntimeException("号源已经被预约,请选择其他号源");
        }
        if ("3".equalsIgnoreCase(outpatient.getOutpatientType())){
        //2.物流信息
        WlyyPrescriptionExpressageDO expressageDO = objectMapper.readValue(expressageJson, WlyyPrescriptionExpressageDO.class);
        expressageDO.setDel(1);
        expressageDO.setCreateTime(new Date());
        expressageDO.setOutpatientId(outpatient.getId());
        prescriptionExpressageDao.save(expressageDO);
        if (0==expressageDO.getOneselfPickupFlg()){
            if("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
                String drugCode= expressageDO.getHospitalCode()==null?"5550":expressageDO.getHospitalCode();
                expressageDO.setHospitalCode(drugCode);
            }
            System.out.println("进入物流信息");
            expressageDO.setDel(1);
            expressageDO.setCreateTime(new Date());
            expressageDO.setOutpatientId(outpatient.getId());
            prescriptionExpressageDao.save(expressageDO);
        }else {
            System.out.println("写入自取信息");
            String drugStoreCode = expressageDO.getHospitalCode();
            BaseDrugStoreDO baseDrugStoreDO = baseDrugStoreDao.findDrugByid(drugStoreCode);
            if (null!=baseDrugStoreDO){
                expressageDO.setCityCode(baseDrugStoreDO.getCityCode());
                expressageDO.setCityName(baseDrugStoreDO.getCityName());
                expressageDO.setProvinceCode(baseDrugStoreDO.getProvinceCode());
                expressageDO.setProvinceName(baseDrugStoreDO.getProvinceName());
                expressageDO.setTownCode(baseDrugStoreDO.getTownCode());
                expressageDO.setTownName(baseDrugStoreDO.getTownName());
                expressageDO.setHospitalCode(baseDrugStoreDO.getDrugStoreCode());
                expressageDO.setHospitalName(baseDrugStoreDO.getHospitalName());
                expressageDO.setHospitalAddress(baseDrugStoreDO.getAddress());
            }
            //2.物流信息
            WlyyPrescriptionExpressageDO expressageDO = objectMapper.readValue(expressageJson, WlyyPrescriptionExpressageDO.class);
            expressageDO.setDel(1);
            expressageDO.setCreateTime(new Date());
            expressageDO.setOutpatientId(outpatient.getId());
            prescriptionExpressageDao.save(expressageDO);
        }
            if (0==expressageDO.getOneselfPickupFlg()){
                if("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
                    String drugCode= expressageDO.getHospitalCode()==null?"5550":expressageDO.getHospitalCode();
                    expressageDO.setHospitalCode(drugCode);
                }
                System.out.println("进入物流信息");
                expressageDO.setDel(1);
                expressageDO.setCreateTime(new Date());
                expressageDO.setOutpatientId(outpatient.getId());
                prescriptionExpressageDao.save(expressageDO);
            }else {
                System.out.println("写入自取信息");
                String drugStoreCode = expressageDO.getHospitalCode();
                BaseDrugStoreDO baseDrugStoreDO = baseDrugStoreDao.findDrugByid(drugStoreCode);
                if (null!=baseDrugStoreDO){
                    expressageDO.setCityCode(baseDrugStoreDO.getCityCode());
                    expressageDO.setCityName(baseDrugStoreDO.getCityName());
                    expressageDO.setProvinceCode(baseDrugStoreDO.getProvinceCode());
                    expressageDO.setProvinceName(baseDrugStoreDO.getProvinceName());
                    expressageDO.setTownCode(baseDrugStoreDO.getTownCode());
                    expressageDO.setTownName(baseDrugStoreDO.getTownName());
                    expressageDO.setHospitalCode(baseDrugStoreDO.getDrugStoreCode());
                    expressageDO.setHospitalName(baseDrugStoreDO.getHospitalName());
                    expressageDO.setHospitalAddress(baseDrugStoreDO.getAddress());
                }
                expressageDO.setDel(1);
                expressageDO.setCreateTime(new Date());
                expressageDO.setOutpatientId(outpatient.getId());
                prescriptionExpressageDao.save(expressageDO);
            }
        }
        //3.创建候诊室
        createRoom(outpatient, chargeType);
        return outpatient;
@ -832,7 +863,7 @@ public class YkyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
            String url = wxWechatDO.getBaseUrl();
            String notifyUrl =url;
            String totalFee =businessOrderDO.getPayPrice().intValue()+"";
            map = businessOrderService.unifiedorder(wechatId,businessOrderDO.getDescription(),totalFee, tradeType,openId,businessOrderDO.getOrderNo(),notifyUrl);
            map = businessOrderService.unifiedorder(wechatId,businessOrderDO.getDescription(),totalFee, tradeType,openId,businessOrderDO.getOrderNo(),notifyUrl,businessOrderDO.getPatient());
        }
        return map;
    }

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

@ -1021,7 +1021,8 @@ public class YkyyEntranceService {
                    String mappingCode = jsonObject.getString("DOCTORCODE");
                    String photo = jsonObject.getString("doctor_image");
                    if (StringUtils.isNoneBlank(photo)){
                        String name = photo.substring(photo.lastIndexOf("/"),photo.length()-1);
                        String name = photo.substring(photo.lastIndexOf("/")+1,photo.length());
                        logger.info("name"+name);
                        InputStream inputStream = fileUploadService.getInputStream(photo);
                        UploadVO uploadVO = new UploadVO();
                        uploadVO = fileUploadService.uploadStream(inputStream,name,fastdfs_file_url);

+ 1 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/ykyy/service/YkyyService.java

@ -248,6 +248,7 @@ public class YkyyService {
        if (StringUtils.isNoneBlank(appCallbackUrl)){
            url+="&app_callback_url="+URLEncoder.encode(appCallbackUrl);
        }
        logger.info("眼科通新增订单接口url:"+url);
        response = httpClientUtil.get(url,"GBK");
        logger.info("眼科通新增订单接口:"+response);
        return response;

+ 8 - 7
business/base-service/src/main/java/com/yihu/jw/internet/service/InternetCommonService.java

@ -41,6 +41,7 @@ import sun.misc.BASE64Encoder;
import java.io.*;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -649,10 +650,11 @@ public class InternetCommonService extends BaseJpaService<InternetUpErrorLogDO,
                " e.relation_code AS \"relationCode\" "+
                "FROM " +
                " base_evaluate_score a " +
                "JOIN base_evaluate e ON a.id = e.relation_code " +
                "JOIN base_doctor d ON d.id = a.doctor " +
                " JOIN base_evaluate e ON a.id = e.relation_code " +
                " JOIN base_doctor d ON d.id = a.doctor  " +
                " JOIN wlyy_consult m ON m.id = a.relation_code  " +
                "WHERE " +
                " e.score_type = '4' ";
                " e.score_type = '4' and m.id != '' and m.id is not null ";
        Map<String,Object> params = new HashedMap();
        if(StringUtils.isNotBlank(startDate)){
@ -1520,11 +1522,11 @@ public class InternetCommonService extends BaseJpaService<InternetUpErrorLogDO,
                " WHERE 1=1" ;
        if(StringUtils.isNotBlank(startDate)){
            yyghSql =  yyghSql + "  and p.create_time >=:startDate ";
            params.put("startDate",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"));
            params.put("startDate",DateUtil.stringToDate(startDate+" 00:00:00","yyyy-MM-dd HH:mm:ss"));
        }
        if(StringUtils.isNotBlank(endDate)){
            yyghSql =  yyghSql +  "  and p.create_time <=:endDate";
            params.put("endDate",DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"));
            params.put("endDate",DateUtil.stringToDate(endDate+" 00:00:00","yyyy-MM-dd HH:mm:ss"));
        }
        List<Map<String,Object>> yygh = hibenateUtils.createSQLQuery(yyghSql,params);
@ -1686,8 +1688,7 @@ public class InternetCommonService extends BaseJpaService<InternetUpErrorLogDO,
            jb.put("dzcf_upload_count", dzcftotal);
            jb.put("ypmx_upload_count", infototal);
            jb.put("gctp_upload_count", gctptotal);
            jb.put("ywsj", DateUtil.dateToStr(new Date(),"yyyy-MM-dd"));
            jb.put("ywsj", startDate);
            jb.put("crt_time", DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss"));

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/internet/service/ykyy/YkyyInternetService.java

@ -788,7 +788,7 @@ public class YkyyInternetService extends BaseJpaService<InternetUpErrorLogDO, In
                    "\tM .\"TIMESTAMP\" AS \"timestamp\",\n" +
                    "\tM . \"CONTENT\" AS \"content\",\n" +
                    "\tM . \"CONTENT_TYPE\" AS \"content_type\",\n" +
                    "\tT . \"ID\" AS \"id\"\n" +
                    "\tT . \"ID\" AS \"id\",\n" +
                    "\tM . \"SESSION_ID\" AS \"session_id\"\n" +
                    "FROM\n" +
                    "\tTOPICS T \n" +

+ 271 - 47
business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java

@ -12,6 +12,7 @@ import com.yihu.jw.entity.base.wx.WxPayLogDO;
import com.yihu.jw.entity.base.wx.WxWechatDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.dict.WlyyChargeDictDO;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
@ -21,6 +22,7 @@ import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.entity.order.BusinessOrderRefundDO;
import com.yihu.jw.hospital.dict.WlyyChargeDictDao;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
@ -50,6 +52,8 @@ import com.yihu.jw.wechat.dao.WechatDao;
import com.yihu.jw.wechat.dao.WxPayLogDao;
import com.yihu.jw.wechat.enterprise.EnterpriseService;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.network.HttpResponse;
import com.yihu.utils.network.HttpUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@ -125,6 +129,8 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
    private PrescriptionService prescriptionService;
    @Autowired
    private WlyyChargeDictDao chargeDictDao;
    @Autowired
    private WlyyHttpLogDao wlyyHttpLogDao;
@ -243,7 +249,11 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
        businessOrderDO.setCreateTime(new Date());
        businessOrderDO.setUpdateTime(new Date());
        businessOrderDO.setStatus(0);
        businessOrderDO.setOrderNo("HLWYY"+businessOrderDO.getOrderType()+System.currentTimeMillis()+(int)(Math.random()*900)+100);
        if (StringUtils.isNoneBlank(businessOrderDO.getDoctor())){
            businessOrderDO.setOrderNo("HLWYY"+businessOrderDO.getOrderType()+System.currentTimeMillis()+(int)(Math.random()*900)+100);
        }else {
            businessOrderDO.setOrderNo("HLWYYQD"+businessOrderDO.getOrderType()+System.currentTimeMillis()+(int)(Math.random()*900)+100);
        }
        businessOrderDO.setUploadStatus(0);
        businessOrderDO.setPayType(1);
        if (businessOrderDO.getOrderCategory().equalsIgnoreCase("1")){
@ -282,7 +292,10 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
        String orderType =businessOrderDO.getOrderType().toString();
        String payType="2";
        String patientTel = basePatientDO.getMobile();
        DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(businessOrderDO.getDoctor());
        DoctorMappingDO doctorMappingDO = null;
        if (StringUtils.isNoneBlank(businessOrderDO.getDoctor())){
            doctorMappingDO = doctorMappingDao.findByDoctor(businessOrderDO.getDoctor());
        }
        String orderCatagrate = businessOrderDO.getOrderCategory();
        String pcCallBack=businessOrderDO.getPcCallbackUrl();
        String appCallBack = businessOrderDO.getAppCallbackUrl();
@ -299,13 +312,17 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
                    JSONArray array = jsonObject.getJSONArray("data");
                    if (array!=null&&array.size()!=0){
                        yktDoctor=array.getJSONObject(0).getString("DOCTORUSERID");
                    }else {
                        yktDoctor = "hlwyymrys001";
                    }
                }
            }
        }else {
            /*throw new Exception("医生映射表不存在!");*/
            yktDoctor="hlwyymrys001";
            if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
                yktDoctor="hlwyymrys001";
            }
        }
        String remark = businessOrderDO.getRematk();
        if (null != hospitalSysDictDO && "0".equalsIgnoreCase(hospitalSysDictDO.getDictValue())) {
@ -313,6 +330,12 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
        } else {
            String response=ykyyService.addYktOrder(orderNo,patientId,orderAmout,remark,state,orderType,yktDoctor,payType,null,patientTel,orderCatagrate,pcCallBack,appCallBack);
            JSONObject object = JSONObject.parseObject(response);
            WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
            wlyyHttpLogDO.setResponse(response);
            wlyyHttpLogDO.setRequest("orderNo;"+orderNo+";"+"yktDoctor:"+yktDoctor);
            wlyyHttpLogDO.setName("同步眼科通订单接口");
            wlyyHttpLogDO.setCreateTime(new Date());
            wlyyHttpLogDao.save(wlyyHttpLogDO);
            if (object.getInteger("code")==200){
                businessOrderDO.setUploadStatus(1);
                businessOrderDao.save(businessOrderDO);
@ -354,16 +377,23 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
        String orderType =businessOrderDO.getOrderType().toString();
        String payType="2";
        String patientTel = basePatientDO.getMobile();
        DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(businessOrderDO.getDoctor());
        DoctorMappingDO doctorMappingDO = null;
        if (StringUtils.isNoneBlank(businessOrderDO.getDoctor())){
            doctorMappingDO = doctorMappingDao.findByDoctor(businessOrderDO.getDoctor());
        }
        String orderCatagrate = businessOrderDO.getOrderCategory();
        String pcCallBack=businessOrderDO.getPcCallbackUrl();
        String appCallBack = businessOrderDO.getAppCallbackUrl();
        String url = wxWechatDO.getBaseUrl();
        String notifyUrl =url;
        Map<String,Object> map = unifiedorder(wechatId,description,businessOrderDO.getPayPrice().toString(),WeChatConfig.TRADE_TYPE_JSAPI,openId,orderNo,notifyUrl);
        Map<String,Object> map = unifiedorder(wechatId,description,businessOrderDO.getPayPrice().toString(),WeChatConfig.TRADE_TYPE_JSAPI,openId,orderNo,notifyUrl,patient);
        String doctorId = "";
        if (doctorMappingDO!=null){
            doctorId = doctorMappingDO.getMappingCode();
        }else {
            if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
                doctorId="hlwyymrys001";
            }
        }
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("YKTCONTROL");
        if (null != hospitalSysDictDO && "0".equalsIgnoreCase(hospitalSysDictDO.getDictValue())) {
@ -404,32 +434,59 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
        return HttpUtil.doRefund("https://api.mch.weixin.qq.com/secapi/pay/refund",xml,hospitalSysDictDO.getDictCode(),hospitalSysDictDO.getDictValue());
    }
    public Map<String,Object> selectOrderByRelationCode(String relationCode,String tradeType,String wechatId,boolean payFlag) throws Exception {
    public Map<String, Object> checkApplets(String code,String appid,String appSecret) throws Exception {
        HttpUtils httpUtils = new HttpUtils();
        Map<String, Object> param = new HashedMap();
        param.put("appid", appid);
        param.put("secret", appSecret);
        param.put("js_code", code);
        param.put("grant_type", "authorization_code");
        HttpResponse response = httpUtils.doGet("https://api.weixin.qq.com/sns/jscode2session", param);
        org.json.JSONObject rs = new org.json.JSONObject(response.getContent());
        Map<String, Object> res = new HashedMap();
        logger.info("checkApplets:"+response.getContent());
        if (rs.has("openid")){
            res.put("openid", rs.getString("openid"));
            res.put("sessionKey", rs.getString("session_key"));
        }
        return res;
    }
    public Map<String,Object> selectOrderByRelationCode(String relationCode,String tradeType,String wechatId,boolean payFlag,String appletCode) throws Exception {
        WxWechatDO wxWechatDO = wechatDao.findById(wechatId);
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(relationCode);
        String body = businessOrderDO.getDescription();
        String totalFee = businessOrderDO.getPayPrice().intValue()+"";
        String patient = businessOrderDO.getPatient();
        String openid = "";
        if (StringUtils.isNoneBlank(patient)){
            List<BasePatientWechatDo> patientWechatDo = patientWechatDao.findByWechatIdAndPatientId(wechatId,patient);
            if (patientWechatDo!=null&&patientWechatDo.size()!=0){
                openid = patientWechatDo.get(0).getOpenid();
        if (StringUtils.isNotBlank(appletCode)){
            logger.info("appletCode不为空"+appletCode);
            Map<String,Object> objectMap = checkApplets(appletCode,wxWechatDO.getApplets(),wxWechatDO.getAppletsSecret());
            if (objectMap!=null){
                openid = objectMap.get("openid").toString();
                logger.info("appletCode"+appletCode);
                logger.info("openid"+openid);
            }
        }else {
            logger.info("appletCode为空"+appletCode);
            if (StringUtils.isNoneBlank(patient)){
                List<BasePatientWechatDo> patientWechatDo = patientWechatDao.findByWechatIdAndPatientId(wechatId,patient);
                if (patientWechatDo!=null&&patientWechatDo.size()!=0){
                    openid = patientWechatDo.get(0).getOpenid();
                }
            }
        }
        String ourTradeNo = businessOrderDO.getOrderNo();
        if (!StringUtils.isNoneBlank(tradeType)){
            tradeType=WeChatConfig.TRADE_TYPE_JSAPI;
        }
        String url = wxWechatDO.getBaseUrl();
        String notifyUrl =url;
        Map<String,Object> map = new HashedMap();
        if (payFlag){
            map = unifiedorder(wechatId,body,totalFee,tradeType,openid,ourTradeNo,notifyUrl);
            map = unifiedorder(wechatId,body,totalFee,tradeType,openid,ourTradeNo,notifyUrl,patient);
        }else {
            updatePayStatusByRelation(relationCode);
            updatePayStatusByRelation(relationCode,wechatId);
        }
        return map;
    }
@ -446,7 +503,7 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
     * @return
     * @throws Exception
     */
    public  Map<String,Object> unifiedorder(String wechatId,String body,String totalFee,String tradeType,String openId,String ourTradeNo,String notifyUrl) throws Exception {
    public  Map<String,Object> unifiedorder(String wechatId,String body,String totalFee,String tradeType,String openId,String ourTradeNo,String notifyUrl,String code) throws Exception {
        WxWechatDO wxWechatDO = wechatDao.findById(wechatId);
        if(wxWechatDO==null){
            throw new Exception("can't find wechat:the wxId is "+wechatId);
@ -469,7 +526,14 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
            throw new Exception("ourTradeNo is null :the ourTradeNo is "+ourTradeNo);
        }
        HashMap<String, String> map = new HashMap<>();
        map.put("appid",wxWechatDO.getAppId());
        if (tradeType.equalsIgnoreCase("APPLETS")){
            map.put("appid",wxWechatDO.getApplets());
            map.put("trade_type", "JSAPI");
        }else {
            map.put("appid",wxWechatDO.getAppId());
            map.put("trade_type", tradeType);
        }
        map.put("mch_id",wxWechatDO.getMchId());
        map.put("body",body);
        map.put("out_trade_no",ourTradeNo);
@ -477,10 +541,17 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
        map.put("total_fee",totalFee);
        map.put("spbill_create_ip",getServerIp());
        map.put("notify_url",notifyUrl);
        map.put("trade_type", tradeType);
        if (tradeType.equalsIgnoreCase("JSAPI")){
            map.put("openid", openId);
        }
        if (tradeType.equalsIgnoreCase("APPLETS")){
            /*BasePatientDO patientDO = patientDao.findById(code);
            if (patientDO!=null){
                map.put("openid",patientDO.getOpenid());
            }*/
            map.put("openid", openId);
        }
        String wapUrl = "";
        String wapName = "";
        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
@ -745,11 +816,23 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
            BusinessOrderDO businessOrderDO = businessOrderDao.selectByOrderNo(seqNo);
            businessOrderDO.setPayTime(DateUtil.strToDate(timeEnd,DateUtil.YYYY_MM_DD_HH_MM_SS));
            WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("YKTCONTROL");
            WlyyHospitalSysDictDO changeMethod = hospitalSysDictDao.findById("consultPay");
            String changeflag="0";
            if(null!=changeMethod){
                changeflag = changeMethod.getDictValue();
            }
            if (businessOrderDO!=null){
                if (businessOrderDO.getOrderCategory().equalsIgnoreCase("1")){
                    ConsultDo consultDo = consultOrderDao.findOne(businessOrderDO.getRelationCode());
                    consultDo.setPayStatus(1);
                    consultOrderDao.save(consultDo);
                    if ("0".equalsIgnoreCase(changeflag)){
                        ConsultDo consultDo = consultOrderDao.findOne(businessOrderDO.getRelationCode());
                        consultDo.setPayStatus(1);
                        consultOrderDao.save(consultDo);
                    }else {
                        WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(businessOrderDO.getRelationCode());
                        wlyyOutpatientDO.setPayStatus(1);
                        outpatientDao.save(wlyyOutpatientDO);
                    }
                }else if (businessOrderDO.getOrderCategory().equalsIgnoreCase("2")||businessOrderDO.getOrderCategory().equalsIgnoreCase("3")){
                    WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(businessOrderDO.getRelationCode());
                    wlyyOutpatientDO.setPayStatus(1);
@ -841,11 +924,11 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
            wxPayLogDO.setPayTime(new Date());
            wxPayLogDO.setPayStatus(1);
            wxPayLogDao.save(wxPayLogDO);
            rs.put("code","1");
            rs.put("message","支付成功");
            rs.put("return_code","SUCCESS");
            rs.put("return_msg","OK");
        }else{
            rs.put("code","-1");
            rs.put("return_msg","FAIL");
            rs.put("return_code","FAIL");
            rs.put("return_msg","OK");
        }
        return rs;
    }
@ -863,19 +946,33 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
        String orderType =businessOrderDO.getOrderType().toString();
        String payType="2";
        String patientTel = basePatientDO.getMobile();
        DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(businessOrderDO.getDoctor());
        DoctorMappingDO doctorMappingDO = null;
        if (StringUtils.isNoneBlank(businessOrderDO.getDoctor())){
            doctorMappingDO = doctorMappingDao.findByDoctor(businessOrderDO.getDoctor());
        }
        String orderCatagrate = businessOrderDO.getOrderCategory();
        String pcCallBack=businessOrderDO.getPcCallbackUrl();
        String appCallBack = businessOrderDO.getAppCallbackUrl();
        String doctorResponse = ykyyService.getYktDoctor(doctorMappingDO.getMappingCode());
        String yktDoctor ="";
        JSONObject jsonObject = JSONObject.parseObject(doctorResponse);
        if (jsonObject.getInteger("code")==200){
            JSONArray array = jsonObject.getJSONArray("data");
            if (array!=null&&array.size()!=0){
                yktDoctor=array.getJSONObject(0).getString("DOCTORUSERID");
        if (null!=doctorMappingDO){
            String doctorResponse = ykyyService.getYktDoctor(doctorMappingDO.getMappingCode());
            JSONObject jsonObject = JSONObject.parseObject(doctorResponse);
            if (jsonObject.getInteger("code")==200){
                JSONArray array = jsonObject.getJSONArray("data");
                if (array!=null&&array.size()!=0){
                    yktDoctor=array.getJSONObject(0).getString("DOCTORUSERID");
                }else {
                    if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
                        yktDoctor="hlwyymrys001";
                    }
                }
            }
        }else {
            if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
                yktDoctor="hlwyymrys001";
            }
        }
        String response = ykyyService.addYktOrder(orderNo,patientId,orderAmout,description,state,orderType,yktDoctor,payType,null,patientTel,orderCatagrate,pcCallBack,appCallBack);
        return response;
    }
@ -1093,10 +1190,22 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
        if (businessOrderDO==null){
            throw new Exception("查不到订单!");
        }
        String newPayFlag = "0";
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = hospitalSysDictDao.findById("consultPay");
        if (null!=wlyyHospitalSysDictDO){
            newPayFlag = wlyyHospitalSysDictDO.getDictValue();
        }
        if (businessOrderDO.getOrderCategory().equalsIgnoreCase("1")){
            ConsultDo consultDo = consultOrderDao.findOne(businessOrderDO.getRelationCode());
            consultDo.setPayStatus(2);
            consultOrderDao.save(consultDo);
            if ("0".equalsIgnoreCase(newPayFlag)){
                ConsultDo consultDo = consultOrderDao.findOne(businessOrderDO.getRelationCode());
                consultDo.setPayStatus(2);
                consultOrderDao.save(consultDo);
            }else {
                WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(businessOrderDO.getRelationCode());
                wlyyOutpatientDO.setPayStatus(2);
                outpatientDao.save(wlyyOutpatientDO);
            }
        }else if (businessOrderDO.getOrderCategory().equalsIgnoreCase("2")||businessOrderDO.getOrderCategory().equalsIgnoreCase("3")){
            WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(businessOrderDO.getRelationCode());
            wlyyOutpatientDO.setPayStatus(2);
@ -1116,13 +1225,59 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
    public BusinessOrderDO updatePayStatus(String orderNo) throws Exception {
        logger.info("入参:"+orderNo);
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByOrderNo(orderNo);
        WlyyHospitalSysDictDO changeMethod = hospitalSysDictDao.findById("consultPay");
        String changeflag="0";
        if(null!=changeMethod){
            changeflag = changeMethod.getDictValue();
        }
        if (businessOrderDO==null){
            throw new Exception("查不到订单!");
        }
        if (businessOrderDO.getOrderCategory().equalsIgnoreCase("1")){
           ConsultDo consultDo = consultOrderDao.findOne(businessOrderDO.getRelationCode());
           consultDo.setPayStatus(1);
           consultOrderDao.save(consultDo);
            if ("0".equalsIgnoreCase(changeflag)){
                ConsultDo consultDo = consultOrderDao.findOne(businessOrderDO.getRelationCode());
                consultDo.setPayStatus(1);
                consultOrderDao.save(consultDo);
            }else {
                WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(businessOrderDO.getRelationCode());
                wlyyOutpatientDO.setPayStatus(1);
                WlyyOutpatientDO outpatientDO = outpatientDao.save(wlyyOutpatientDO);
                //发送企业模板消息给医生
                BasePatientDO patientDO = new BasePatientDO();
                patientDO = patientDao.findById(outpatientDO.getPatient());
                String msg = "";
                String name=outpatientDO.getPatientName();
                String sex = "";
                String age="";
                String date = "";
                String title = "";
                if (patientDO!=null){
                    sex= IdCardUtil.getSexForIdcard(patientDO.getIdcard());
                    age = IdCardUtil.getAgeForIdcard(patientDO.getIdcard())+"";
                }
                if (outpatientDO!=null){
                    if (outpatientDO.getType().equalsIgnoreCase("1")){
                        title = "图文咨询";
                        msg = name+"("+sex+" "+age+"岁)向您发起了图文咨询,点击查看";
                    }else if (outpatientDO.getType().equalsIgnoreCase("2")){
                        title = "视频咨询";
                        date = DateUtil.dateToStrLong(outpatientDO.getRegisterDate());
                        msg = name+"("+sex+" "+age+"岁)预约了"+date+"的视频咨询,点击查看";
                    }
                }
                if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                    String url="https://hlwyy.xmzsh.com/hlwyy/ims-app-web/#/onlineChat/detail?_rs_title="+outpatientDO.getDescription()+"&type=3&id="+outpatientDO.getId();
                    enterpriseService.sendTWMesByDoctor("zsyy",outpatientDO.getDoctor(),title,msg,url);
                }else if(wechatId.equalsIgnoreCase("xm_ykyy_wx")){
                    String url="https://intel.yanketong.com/ims-app-web/#/onlineChat/detail?_rs_title="+outpatientDO.getDescription()+"&type=3&id="+outpatientDO.getId();
                    enterpriseService.sendTWMesByDoctor("xm_ykyy_wx",outpatientDO.getDoctor(),title,msg,url);
                }else if (wechatId.equalsIgnoreCase("xm_xzzx_wx")){
                    String url="https://ih.xmheart.com/hlwyy/ims-app-web/#/onlineChat/detail?_rs_title="+outpatientDO.getDescription()+"&type=3&id="+outpatientDO.getId();
                    enterpriseService.sendTWMesByDoctor("xm_xzzx_wx",outpatientDO.getDoctor(),title,msg,url);
                }
                System.out.println("发送企业模板消息成功");
            }
        }else if (businessOrderDO.getOrderCategory().equalsIgnoreCase("2")||businessOrderDO.getOrderCategory().equalsIgnoreCase("3")){
           WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(businessOrderDO.getRelationCode());
           wlyyOutpatientDO.setPayStatus(1);
@ -1137,7 +1292,7 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
               String age="";
               String date = "";
               String title = "";
               String url="https://hlwyy.xmzsh.com/hlwyy/ims-app-web/#/onlineChat/detail?_rs_title="+outpatientDO.getDescription()+"&type=3&id="+outpatientDO.getId();
               if (patientDO!=null){
                   sex= IdCardUtil.getSexForIdcard(patientDO.getIdcard());
                   age = IdCardUtil.getAgeForIdcard(patientDO.getIdcard())+"";
@ -1152,7 +1307,17 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
                       msg = name+"("+sex+" "+age+"岁)预约了"+date+"的视频复诊,点击查看";
                   }
               }
               enterpriseService.sendTWMesByDoctor("zsyy",outpatientDO.getDoctor(),title,msg,url);
               if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                   String url="https://hlwyy.xmzsh.com/hlwyy/ims-app-web/#/onlineChat/detail?_rs_title="+outpatientDO.getDescription()+"&type=3&id="+outpatientDO.getId();
                   enterpriseService.sendTWMesByDoctor("zsyy",outpatientDO.getDoctor(),title,msg,url);
               }else if (wechatId.equalsIgnoreCase("xm_ykyy_wx")){
                   String url="https://intel.yanketong.com/ims-app-web/#/onlineChat/detail?_rs_title="+outpatientDO.getDescription()+"&type=3&id="+outpatientDO.getId();
                   enterpriseService.sendTWMesByDoctor("xm_ykyy_wx",outpatientDO.getDoctor(),title,msg,url);
               }else if (wechatId.equalsIgnoreCase("xm_xzzx_wx")){
                   String url="https://ih.xmheart.com/hlwyy/ims-app-web/#/onlineChat/detail?_rs_title="+outpatientDO.getDescription()+"&type=3&id="+outpatientDO.getId();
                   enterpriseService.sendTWMesByDoctor("xm_xzzx_wx",outpatientDO.getDoctor(),title,msg,url);
               }
               System.out.println("发送企业模板消息成功");
           }
@ -1177,17 +1342,65 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
     * @param relationCode
     * @return
     */
    public BusinessOrderDO updatePayStatusByRelation(String relationCode) throws Exception {
    public BusinessOrderDO updatePayStatusByRelation(String relationCode,String wxId) throws Exception {
        logger.info("入参:"+relationCode);
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(relationCode);
        WlyyHospitalSysDictDO changeMethod = hospitalSysDictDao.findById("consultPay");
        String changeflag="0";
        if(null!=changeMethod){
            changeflag = changeMethod.getDictValue();
        }
        if (businessOrderDO==null){
            throw new Exception("查不到订单!");
        }
        if (businessOrderDO.getOrderCategory().equalsIgnoreCase("1")){
            ConsultDo consultDo = consultOrderDao.findOne(businessOrderDO.getRelationCode());
            consultDo.setPayStatus(1);
            consultOrderDao.save(consultDo);
        }else if (businessOrderDO.getOrderCategory().equalsIgnoreCase("2")){
            if ("0".equalsIgnoreCase(changeflag)){
                ConsultDo consultDo = consultOrderDao.findOne(businessOrderDO.getRelationCode());
                consultDo.setPayStatus(1);
                consultOrderDao.save(consultDo);
            }else {
                WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(businessOrderDO.getRelationCode());
                wlyyOutpatientDO.setPayStatus(1);
                WlyyOutpatientDO outpatientDO = outpatientDao.save(wlyyOutpatientDO);
                if (businessOrderDO.getStatus()!=null&&businessOrderDO.getStatus()!=1){
                    //发送企业模板消息给医生
                    BasePatientDO patientDO = new BasePatientDO();
                    patientDO = patientDao.findById(outpatientDO.getPatient());
                    String msg = "";
                    String name=outpatientDO.getPatientName();
                    String sex = "";
                    String age="";
                    String date = "";
                    String title = "";
                    if (patientDO!=null){
                        sex= IdCardUtil.getSexForIdcard(patientDO.getIdcard());
                        age = IdCardUtil.getAgeForIdcard(patientDO.getIdcard())+"";
                    }
                    if (outpatientDO!=null){
                        if (outpatientDO.getType().equalsIgnoreCase("1")){
                            title = "图文咨询";
                            msg = name+"("+sex+" "+age+"岁)向您发起了图文咨询,点击查看";
                        }else if (outpatientDO.getType().equalsIgnoreCase("2")){
                            title = "视频咨询";
                            date = DateUtil.dateToStrLong(outpatientDO.getRegisterDate());
                            msg = name+"("+sex+" "+age+"岁)预约了"+date+"的视频咨询,点击查看";
                        }
                    }
                    if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
                        String url="https://hlwyy.xmzsh.com/hlwyy/ims-app-web/#/onlineChat/detail?_rs_title="+outpatientDO.getDescription()+"&type=3&id="+outpatientDO.getId();
                        enterpriseService.sendTWMesByDoctor("zsyy",outpatientDO.getDoctor(),title,msg,url);
                    }else if (wxId.equalsIgnoreCase("xm_xzzx_wx")){
                        String url="https://ih.xmheart.com/hlwyy/ims-app-web/#/onlineChat/detail?_rs_title="+outpatientDO.getDescription()+"&type=3&id="+outpatientDO.getId();
                        enterpriseService.sendTWMesByDoctor("xm_xzzx_wx",outpatientDO.getDoctor(),title,msg,url);
                    }else if (wxId.equalsIgnoreCase("xm_ykyy_wx")){
                        String url="https://intel.yanketong.com/ims-app-web/#/onlineChat/detail?_rs_title="+outpatientDO.getDescription()+"&type=3&id="+outpatientDO.getId();
                        enterpriseService.sendTWMesByDoctor("xm_ykyy_wx",outpatientDO.getDoctor(),title,msg,url);
                    }
                    System.out.println("发送企业模板消息成功");
                }
            }
        }else if (businessOrderDO.getOrderCategory().equalsIgnoreCase("2")||businessOrderDO.getOrderCategory().equalsIgnoreCase("3")){
            WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(businessOrderDO.getRelationCode());
            wlyyOutpatientDO.setPayStatus(1);
            WlyyOutpatientDO outpatientDO = outpatientDao.save(wlyyOutpatientDO);
@ -1201,7 +1414,7 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
                String age="";
                String date = "";
                String title = "";
                String url="https://hlwyy.xmzsh.com/hlwyy/ims-app-web/#/onlineChat/detail?_rs_title="+outpatientDO.getDescription()+"&type=3&id="+outpatientDO.getId();
                if (patientDO!=null){
                    sex= IdCardUtil.getSexForIdcard(patientDO.getIdcard());
                    age = IdCardUtil.getAgeForIdcard(patientDO.getIdcard())+"";
@ -1216,7 +1429,17 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
                        msg = name+"("+sex+" "+age+"岁)预约了"+date+"的视频复诊,点击查看";
                    }
                }
                enterpriseService.sendTWMesByDoctor("zsyy",outpatientDO.getDoctor(),title,msg,url);
                if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
                    String url="https://hlwyy.xmzsh.com/hlwyy/ims-app-web/#/onlineChat/detail?_rs_title="+outpatientDO.getDescription()+"&type=3&id="+outpatientDO.getId();
                    enterpriseService.sendTWMesByDoctor("zsyy",outpatientDO.getDoctor(),title,msg,url);
                }else if (wxId.equalsIgnoreCase("xm_xzzx_wx")){
                    String url="https://ih.xmheart.com/hlwyy/ims-app-web/#/onlineChat/detail?_rs_title="+outpatientDO.getDescription()+"&type=3&id="+outpatientDO.getId();
                    enterpriseService.sendTWMesByDoctor("xm_xzzx_wx",outpatientDO.getDoctor(),title,msg,url);
                }else if (wxId.equalsIgnoreCase("xm_ykyy_wx")){
                    String url="https://intel.yanketong.com/ims-app-web/#/onlineChat/detail?_rs_title="+outpatientDO.getDescription()+"&type=3&id="+outpatientDO.getId();
                    enterpriseService.sendTWMesByDoctor("xm_ykyy_wx",outpatientDO.getDoctor(),title,msg,url);
                }
                System.out.println("发送企业模板消息成功");
            }
        } else if (businessOrderDO.getOrderCategory().equalsIgnoreCase("4")) {
@ -1480,9 +1703,10 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
        String url = wxWechatDO.getBaseUrl();
        String notifyUrl =url;
        String price = (int)(businessOrderDO.getPayPrice()*100)+"";
        map = unifiedorder(wechatId,businessOrderDO.getDescription(),price,wxPayType,patientWechatDoList.get(0).getOpenid(),businessOrderDO.getOrderNo(),notifyUrl);
        map = unifiedorder(wechatId,businessOrderDO.getDescription(),price,wxPayType,patientWechatDoList.get(0).getOpenid(),businessOrderDO.getOrderNo(),notifyUrl,patientId);
        logger.info("success="+JSONObject.toJSONString(map));
        return map;
    }
}

+ 451 - 33
business/es-service/src/main/java/com/yihu/jw/es/service/StatisticsEsService.java

@ -95,7 +95,7 @@ public class StatisticsEsService {
        String lastDay = DateUtil.getNextDay(endDate, -7);//上周的今天
        String weekFirstDay = DateUtil.getMondayOfThisWeek();//周一
        String weekLastDay = DateUtil.getSundayOfThisWeek();//周日
        JSONArray array = dateTotalStatistics2(weekFirstDay,weekLastDay,area,level,indexes[2],null,SaveModel.timeLevel_ZL,null);//本周量
        JSONArray array = dateTotalStatistics2(weekFirstDay,weekLastDay,area,level,indexes[2]+",21",null,SaveModel.timeLevel_ZL,null);//本周量
        Double prices = 0.0;
        for (int i=0;i<array.size();i++){
            JSONObject jsonObject = array.getJSONObject(i);
@ -116,7 +116,7 @@ public class StatisticsEsService {
        object.put("prescriptionRate",prescriptionRate);//开方率
        String startTime = DateUtil.getStringDateShort()+" 00:00:00";
        String endTime = DateUtil.getStringDateShort() +" 23:59:59";
        String sql = "select count(*) as \"total\" from base.wlyy_consult_oupatient_info o where  o.create_time >='"+startTime+"' and o.create_time <='"+endTime+"'";
        String sql = "select count(*) as \"total\" from wlyy_consult_oupatient_info o where  o.create_time >='"+startTime+"' and o.create_time <='"+endTime+"'";
        if (level==4){
            sql += " and o.doctor IN (SELECT doctor_code as \"doctor_code\" FROM `base_doctor_hospital` dh where dh.org_code ='"+area+"' and dh.del=1)";
        }if (level==2){
@ -170,20 +170,21 @@ public class StatisticsEsService {
            JSONArray array4 = dateTotalStatistics2(startDate,endDate,area,level,"16",null,SaveModel.timeLevel_ZL,null);
            object.put("vedioData",array4);
        }else if (interval==2){
            JSONArray array = weekTotalStatistics(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL);
            JSONArray array = weekTotalStatistics7(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL);
            object.put("data",array);
            JSONArray array1 = weekTotalStatistics(startDate,endDate,area,level,"5","1",SaveModel.timeLevel_ZL);
            JSONArray array1 = weekTotalStatistics7(startDate,endDate,area,level,"5","1",SaveModel.timeLevel_ZL);
            object.put("specialistData",array1);
            JSONArray array2 = weekTotalStatistics(startDate,endDate,area,level,"12",null,SaveModel.timeLevel_ZL);
            JSONArray array2 = weekTotalStatistics7(startDate,endDate,area,level,"12",null,SaveModel.timeLevel_ZL);
            object.put("topicData",array2);
            JSONArray array3 = weekTotalStatistics(startDate,endDate,area,level,"14",null,SaveModel.timeLevel_ZL);
            JSONArray array3 = weekTotalStatistics7(startDate,endDate,area,level,"14",null,SaveModel.timeLevel_ZL);
            object.put("synergyData",array3);
            JSONArray array4 = weekTotalStatistics(startDate,endDate,area,level,"16",null,SaveModel.timeLevel_ZL);
            JSONArray array4 = weekTotalStatistics7(startDate,endDate,area,level,"16",null,SaveModel.timeLevel_ZL);
            object.put("vedioData",array4);
        }else if (interval==3){
            JSONArray array = monthTotalStatistics2(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL,null);
            object.put("data",array);
            JSONArray array1 = monthTotalStatistics2(startDate,endDate,area,level,"5",null,SaveModel.timeLevel_ZL,null);
            JSONArray array1 = monthTotalStatistics2(startDate,endDate,area,level,"5","1",SaveModel.timeLevel_ZL,null);
            object.put("specialistData",array1);
            JSONArray array2 = monthTotalStatistics2(startDate,endDate,area,level,"12",null,SaveModel.timeLevel_ZL,null);
            object.put("topicData",array2);
@ -447,15 +448,15 @@ public class StatisticsEsService {
            JSONArray array4 = dateTotalStatistics3(startDate,endDate,area,level,index,"1",SaveModel.timeLevel_ZL,"2");
            object.put("vedioData",array4);
        }else if (interval==2){
            JSONArray array = weekTotalStatisticsDf(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL);
            JSONArray array = weekTotalStatistics7(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL);
            object.put("data",array);
            JSONArray array1 = weekTotalStatistics3(startDate,endDate,area,level,index,"3",SaveModel.timeLevel_ZL,"1");
            JSONArray array1 = weekTotalStatistics8(startDate,endDate,area,level,index,"3",SaveModel.timeLevel_ZL,"1");
            object.put("specialistData",array1);
            JSONArray array2 = weekTotalStatistics3(startDate,endDate,area,level,index,"1",SaveModel.timeLevel_ZL,"1");
            JSONArray array2 = weekTotalStatistics8(startDate,endDate,area,level,index,"1",SaveModel.timeLevel_ZL,"1");
            object.put("topicData",array2);
            JSONArray array3 = weekTotalStatistics3(startDate,endDate,area,level,index,"2",SaveModel.timeLevel_ZL,null);
            JSONArray array3 = weekTotalStatistics8(startDate,endDate,area,level,index,"2",SaveModel.timeLevel_ZL,null);
            object.put("synergyData",array3);
            JSONArray array4 = weekTotalStatistics3(startDate,endDate,area,level,index,"1",SaveModel.timeLevel_ZL,"2");
            JSONArray array4 = weekTotalStatistics8(startDate,endDate,area,level,index,"1",SaveModel.timeLevel_ZL,"2");
            object.put("vedioData",array4);
        }else if (interval==3){
            JSONArray array = monthTotalStatistics3(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL,null);
@ -1764,12 +1765,11 @@ public class StatisticsEsService {
            startDate = df.format(preDate.getTime());
        }
        List<SaveModel> saveModels = new ArrayList<>();
        if (StringUtils.isNotBlank(lowCode)) {
            saveModels = elasticsearchUtil.findLineChartDateQuotaLevel1(startDate, endDate, area, level, index, timelevel, SaveModel.interval_week, lowCode);
            saveModels = elasticsearchUtil.findLineChartDateQuotaLevel1(startDate, endDate, area, level, index, timelevel, SaveModel.interval_day, lowCode);
        } else {
            saveModels = elasticsearchUtil.findLineChartDateQuotaLevel0(startDate, endDate, area, level, index, timelevel, SaveModel.interval_week);
            saveModels = elasticsearchUtil.findLineChartDateQuotaLevel0(startDate, endDate, area, level, index, timelevel, SaveModel.interval_day);
        }
        if (saveModels != null) {
            // 计算结果
@ -1778,6 +1778,8 @@ public class StatisticsEsService {
                if (saveModel.getQuotaDate() != null) {
                    Calendar quotaDate = Calendar.getInstance();
                    quotaDate.setTime(saveModel.getQuotaDate());
                    /*int thisWeek = start.get(Calendar.DAY_OF_WEEK);
                    int thisIncre = 7 - week;*/
                    quotaDate.add(Calendar.DATE, 6);
                    range = df.format(quotaDate.getTime());
@ -1790,8 +1792,10 @@ public class StatisticsEsService {
                if (json != null) {
                    long amount = saveModel.getResult2().longValue();
                    double num = saveModel.getResult1();
                    json.put("amount", amount);
                    json.put("num",num);
                    long previousAmount = Long.valueOf(json.get("amount").toString());
                    double previousNum = Double.parseDouble(json.get("num").toString());
                    json.put("amount", amount+previousAmount);
                    json.put("num",num+previousNum);
                }
            }
@ -1821,7 +1825,6 @@ public class StatisticsEsService {
        }
    }
    /**
     * 按周统计 折线图
     *
@ -3116,7 +3119,7 @@ public class StatisticsEsService {
        if (interval==1){
            array = dateTotalStatistics2(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL,null);
        }else if (interval==2){
            array = weekTotalStatistics(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL);
            array = weekTotalStatistics7(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL);
        }else if (interval==3){
            array = monthTotalStatistics2(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL,null);
        }
@ -3258,7 +3261,7 @@ public class StatisticsEsService {
            JSONArray array = dateTotalStatistics2(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL,null);
            object.put("data",array);
        }else if (interval==2){
            JSONArray array = weekTotalStatistics(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL);
            JSONArray array = weekTotalStatistics7(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL);
            object.put("data",array);
        }else if (interval==3){
            JSONArray array = monthTotalStatistics2AndMonth(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL);
@ -3474,7 +3477,7 @@ public class StatisticsEsService {
            JSONArray array = dateTotalStatistics2(startDate,endDate,area,level,index1,null,SaveModel.timeLevel_ZL,null);
            object.put("data",array);
        }else if (interval==2){
            JSONArray array = weekTotalStatistics(startDate,endDate,area,level,index1,null,SaveModel.timeLevel_ZL);
            JSONArray array = weekTotalStatistics7(startDate,endDate,area,level,index1,null,SaveModel.timeLevel_ZL);
            object.put("data",array);
        }else if (interval==3){
            JSONArray array = monthTotalStatistics2(startDate,endDate,area,level,index1,null,SaveModel.timeLevel_ZL,null);
@ -3609,7 +3612,7 @@ public class StatisticsEsService {
            JSONArray array = dateTotalStatistics2(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL,null);
            object.put("data",array);
        }else if (interval==2){
            JSONArray array = weekTotalStatistics(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL);
            JSONArray array = weekTotalStatistics7(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL);
            object.put("data",array);
        }else if (interval==3){
            JSONArray array = monthTotalStatistics2(startDate,endDate,area,level,index,null,SaveModel.timeLevel_ZL,null);
@ -3729,26 +3732,26 @@ public class StatisticsEsService {
        }else if (interval==2){
            if (index.equalsIgnoreCase("6")){
                JSONArray array = weekTotalStatistics(startDate,endDate,area,level,index1,null,SaveModel.timeLevel_ZL);
                JSONArray array = weekTotalStatistics7(startDate,endDate,area,level,index1,null,SaveModel.timeLevel_ZL);
                object.put("totalData",array);//新增量
                JSONArray array1 = weekTotalStatistics(startDate,endDate,area,level,index,"0",SaveModel.timeLevel_ZL);//未回复
                JSONArray array1 = weekTotalStatistics7(startDate,endDate,area,level,index,"0",SaveModel.timeLevel_ZL);//未回复
                object.put("noReplyData",array1);;//未回复
                JSONArray array2 = weekTotalStatistics(startDate,endDate,area,level,index,"1",SaveModel.timeLevel_ZL);//已回复
                JSONArray array2 = weekTotalStatistics7(startDate,endDate,area,level,index,"1",SaveModel.timeLevel_ZL);//已回复
                object.put("replyData",array2);//已回复
                JSONArray array3 = weekTotalStatistics(startDate,endDate,area,level,index1,"0",SaveModel.timeLevel_ZL);//进行中
                JSONArray array3 = weekTotalStatistics7(startDate,endDate,area,level,index1,"0",SaveModel.timeLevel_ZL);//进行中
                object.put("commingData",array3);//进行中
                JSONArray array4 = weekTotalStatistics(startDate,endDate,area,level,index1,"1",SaveModel.timeLevel_ZL);//已完成
                JSONArray array4 = weekTotalStatistics7(startDate,endDate,area,level,index1,"1",SaveModel.timeLevel_ZL);//已完成
                object.put("endData",array3);//进行中
            }else {
                JSONArray array = weekTotalStatistics(startDate,endDate,area,level,index1,null,SaveModel.timeLevel_ZL);
                JSONArray array = weekTotalStatistics7(startDate,endDate,area,level,index1,null,SaveModel.timeLevel_ZL);
                object.put("totalData",array);//新增量
                JSONArray array1 = weekTotalStatistics(startDate,endDate,area,level,index1,"0",SaveModel.timeLevel_ZL);//未接诊
                JSONArray array1 = weekTotalStatistics7(startDate,endDate,area,level,index1,"0",SaveModel.timeLevel_ZL);//未接诊
                object.put("noReceiveData",array1);;//未接诊
                JSONArray array2 = weekTotalStatistics(startDate,endDate,area,level,index,"1,2,3",SaveModel.timeLevel_ZL);//已接诊
                JSONArray array2 = weekTotalStatistics7(startDate,endDate,area,level,index,"1,2,3",SaveModel.timeLevel_ZL);//已接诊
                object.put("haveReceiveData",array2);//已接诊
                JSONArray array3 = weekTotalStatistics(startDate,endDate,area,level,index,"-1",SaveModel.timeLevel_ZL);//患者取消
                JSONArray array3 = weekTotalStatistics7(startDate,endDate,area,level,index,"-1",SaveModel.timeLevel_ZL);//患者取消
                object.put("concleData",array3);//患者取消
                JSONArray array4 = weekTotalStatistics(startDate,endDate,area,level,index,"3",SaveModel.timeLevel_ZL);//已结束
                JSONArray array4 = weekTotalStatistics7(startDate,endDate,area,level,index,"3",SaveModel.timeLevel_ZL);//已结束
                object.put("endData",array4);//已结束
            }
@ -4666,4 +4669,419 @@ public class StatisticsEsService {
        }
        return object;
    }
    /**
     * 按周统计 折线图
     *
     * @param startDate
     * @param endDate
     * @param area
     * @param level
     * @param index
     * @param lowCode
     * @return
     * @throws Exception
     */
    private JSONArray weekTotalStatistics7(String startDate, String endDate, String area, int level, String index, String lowCode, String timelevel) throws Exception {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        // 起始日期
        Calendar start = Calendar.getInstance();
        start.setTime(DateUtil.strToDate(startDate, DateUtil.YYYY_MM_DD));
        // 第一个统计周期结束日期
        String firstEnd = "";
        // 结束日期
        Calendar end = Calendar.getInstance();
        //因为统计时间是统计到当前时间的前一天,所以这里的时间是提前一天
        Calendar temp = Calendar.getInstance();
        temp.setTime(DateUtil.strToDate(endDate, DateUtil.YYYY_MM_DD));
//        temp.add(Calendar.DAY_OF_MONTH, -1);
        end.setTime(temp.getTime());
        // 起始日期为周几
        int week = start.get(Calendar.DAY_OF_WEEK);
        int incre = 7 - week + 1;
        // 日期集合
        List<Calendar> days = new ArrayList<>();
        days.add(start);
        boolean flag = true;
        int i = 0;
        if (startDate.compareTo(endDate) == 0) {
            flag = false;
            days.add(end);
            firstEnd = df.format(end.getTime());
        }
        // 计算统计日期
        while (flag) {
            Calendar next = Calendar.getInstance();
            next.setTime(days.get(days.size() - 1).getTime());
            if (i == 0) {
                if (incre != 7) {
                    next.add(Calendar.DATE, incre);
                }
            } else {
                next.add(Calendar.DATE, 7);
            }
            if (next.getTime().before(DateUtil.strToDate(endDate, "yyyy-MM-dd"))) {
                days.add(next);
                if (i == 0) {
                    firstEnd = df.format(next.getTime());
                }
            } else {
                days.add(end);
                flag = false;
                if (i == 0) {
                    firstEnd = df.format(end.getTime());
                }
            }
            i++;
        }
        // 结果集
        Map<String, JSONObject> countResult = new HashMap<>();
//        Date dd = df.parse();
        // 算出每个查询周期
        for (int j = 0; j < days.size() - 1; j++) {
            String startStr = "";
            String endStr = df.format(days.get(j + 1).getTime());
            // 起始、截止日期
            if (j == 0) {
                startStr = df.format(days.get(j).getTime());
            } else {
                Calendar cal = Calendar.getInstance();
                cal.setTime(days.get(j).getTime());
                cal.add(Calendar.DATE, 1);
                startStr = df.format(cal.getTime());
            }
            JSONObject range = new JSONObject();
            range.put("range", endStr);
            range.put("amount", 0);
            range.put("num",0.0);
            countResult.put(endStr, range);
//            if(!DateUtil.getSundayOfThisDate(new Date()).equals(df.format(new Date()))){
//                JSONObject range2 = new JSONObject();
//                range2.put("range", endDate);
//                range2.put("amount", 0);
//                countResult.put(df.format(new Date()), range2);
//            };
        }
        if (startDate.equals(df.format(new Date()))) {
            Calendar preDate = Calendar.getInstance();
            preDate.setTime(df.parse(endDate));
            preDate.add(Calendar.DATE, -1);
            startDate = df.format(preDate.getTime());
        }
        List<SaveModel> saveModels = new ArrayList<>();
        if (StringUtils.isNotBlank(lowCode)) {
            saveModels = elasticsearchUtil.findLineChartDateQuotaLevel1(startDate, endDate, area, level, index, timelevel, SaveModel.interval_day, lowCode);
        } else {
            saveModels = elasticsearchUtil.findLineChartDateQuotaLevel0(startDate, endDate, area, level, index, timelevel, SaveModel.interval_day);
        }
        if (saveModels != null) {
            // 计算结果
            for (SaveModel saveModel : saveModels) {
                String range = "";
                if (saveModel.getQuotaDate() != null) {
                    Calendar quotaDate = Calendar.getInstance();
                    quotaDate.setTime(saveModel.getQuotaDate());
                    int thisWeek = quotaDate.get(Calendar.DAY_OF_WEEK);
                    switch (thisWeek){
                        case 1:
                            thisWeek =7;
                            break;
                        case 2:
                            thisWeek =1;
                            break;
                        case 3:
                            thisWeek =2;
                            break;
                        case 4:
                            thisWeek =3;
                            break;
                        case 5:
                            thisWeek =4;
                            break;
                        case 6:
                            thisWeek =5;
                            break;
                        case 7:
                            thisWeek =6;
                            break;
                    }
                    int thisIncre = 7 - thisWeek;
                    quotaDate.add(Calendar.DATE, thisIncre);
                    if(quotaDate.getTime().before(DateUtil.strToDate(endDate, "yyyy-MM-dd"))){
                        range = df.format(quotaDate.getTime());
                    }else {
                        range = df.format(DateUtil.strToDate(endDate, "yyyy-MM-dd"));
                    }
                }
                JSONObject json = countResult.get(range);
//                //因为上述时间集提前一天  但是前端是显示当前时间,所以这里给调整回去
//                if (range.equals(df.format(temp.getTime()))) {
//                    json.put("range", endDate);
//                }
                if (json != null) {
                    long amount = saveModel.getResult2().longValue();
                    double num = saveModel.getResult1();
                    long previousAmount = Long.valueOf(json.get("amount").toString());
                    double previousNum = Double.parseDouble(json.get("num").toString());
                    json.put("amount", amount+previousAmount);
                    json.put("num",num+previousNum);
                }
            }
            List<JSONObject> result = new ArrayList<>(countResult.values());
            // 排序
            result.sort(new Comparator<JSONObject>() {
                @Override
                public int compare(JSONObject o1, JSONObject o2) {
                    if (o1.getString("range").compareTo(o2.getString("range")) > 0) {
                        return 1;
                    } else if (o1.getString("range").compareTo(o2.getString("range")) < 0) {
                        return -1;
                    } else {
                        return 0;
                    }
                }
            });
            JSONArray jsonArray = new JSONArray();
            for (JSONObject object:result){
                jsonArray.add(object);
            }
            return jsonArray;
        } else {
            return new JSONArray();
        }
    }
    /**
     * 两位小数
     * @param startDate
     * @param endDate
     * @param area
     * @param level
     * @param index
     * @param lowCode
     * @param timelevel
     * @param lowCode2
     * @return
     * @throws Exception
     */
    private JSONArray weekTotalStatistics8(String startDate, String endDate, String area, int level, String index, String lowCode, String timelevel,String lowCode2) throws Exception {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        // 起始日期
        Calendar start = Calendar.getInstance();
        start.setTime(DateUtil.strToDate(startDate, DateUtil.YYYY_MM_DD));
        // 第一个统计周期结束日期
        String firstEnd = "";
        // 结束日期
        Calendar end = Calendar.getInstance();
        //因为统计时间是统计到当前时间的前一天,所以这里的时间是提前一天
        Calendar temp = Calendar.getInstance();
        temp.setTime(DateUtil.strToDate(endDate, DateUtil.YYYY_MM_DD));
//        temp.add(Calendar.DAY_OF_MONTH, -1);
        end.setTime(temp.getTime());
        // 起始日期为周几
        int week = start.get(Calendar.DAY_OF_WEEK);
        int incre = 7 - week + 1;
        // 日期集合
        List<Calendar> days = new ArrayList<>();
        days.add(start);
        boolean flag = true;
        int i = 0;
        if (startDate.compareTo(endDate) == 0) {
            flag = false;
            days.add(end);
            firstEnd = df.format(end.getTime());
        }
        // 计算统计日期
        while (flag) {
            Calendar next = Calendar.getInstance();
            next.setTime(days.get(days.size() - 1).getTime());
            if (i == 0) {
                if (incre != 7) {
                    next.add(Calendar.DATE, incre);
                }
            } else {
                next.add(Calendar.DATE, 7);
            }
            if (next.getTime().before(DateUtil.strToDate(endDate, "yyyy-MM-dd"))) {
                days.add(next);
                if (i == 0) {
                    firstEnd = df.format(next.getTime());
                }
            } else {
                days.add(end);
                flag = false;
                if (i == 0) {
                    firstEnd = df.format(end.getTime());
                }
            }
            i++;
        }
        // 结果集
        Map<String, JSONObject> countResult = new HashMap<>();
//        Date dd = df.parse();
        // 算出每个查询周期
        for (int j = 0; j < days.size() - 1; j++) {
            String startStr = "";
            String endStr = df.format(days.get(j + 1).getTime());
            // 起始、截止日期
            if (j == 0) {
                startStr = df.format(days.get(j).getTime());
            } else {
                Calendar cal = Calendar.getInstance();
                cal.setTime(days.get(j).getTime());
                cal.add(Calendar.DATE, 1);
                startStr = df.format(cal.getTime());
            }
            JSONObject range = new JSONObject();
            range.put("range", endStr);
            range.put("amount", 0);
            range.put("num",0.0);
            countResult.put(endStr, range);
//            if(!DateUtil.getSundayOfThisDate(new Date()).equals(df.format(new Date()))){
//                JSONObject range2 = new JSONObject();
//                range2.put("range", endDate);
//                range2.put("amount", 0);
//                countResult.put(df.format(new Date()), range2);
//            };
        }
        if (startDate.equals(df.format(new Date()))) {
            Calendar preDate = Calendar.getInstance();
            preDate.setTime(df.parse(endDate));
            preDate.add(Calendar.DATE, -1);
            startDate = df.format(preDate.getTime());
        }
        List<SaveModel> saveModels = new ArrayList<>();
        if (StringUtils.isNotBlank(lowCode)) {
            if (StringUtils.isNoneBlank(lowCode2)){
                saveModels = elasticsearchUtil.findLineChartDateQuotaLevel2(startDate, endDate, area, level, index, timelevel, SaveModel.interval_day, lowCode,lowCode2);
            }else {
                saveModels = elasticsearchUtil.findLineChartDateQuotaLevel1(startDate, endDate, area, level, index, timelevel, SaveModel.interval_day, lowCode);
            }
        }else if(StringUtils.isNoneBlank(lowCode2)&&StringUtils.isBlank(lowCode)){
            saveModels = elasticsearchUtil.findLineChartDateQuotaLevel2OnlySlaveKey2(startDate, endDate, area, level, index, timelevel, SaveModel.interval_day,lowCode2);
        }
        else {
            saveModels = elasticsearchUtil.findLineChartDateQuotaLevel0(startDate, endDate, area, level, index, timelevel, SaveModel.interval_day);
        }
        DecimalFormat decimalFormat = new DecimalFormat("0.00");
        if (saveModels != null) {
            // 计算结果
            for (SaveModel saveModel : saveModels) {
                String range = "";
                if (saveModel.getQuotaDate() != null) {
                    Calendar quotaDate = Calendar.getInstance();
                    quotaDate.setTime(saveModel.getQuotaDate());
                    int thisWeek = quotaDate.get(Calendar.DAY_OF_WEEK);
                    switch (thisWeek){
                        case 1:
                            thisWeek =7;
                            break;
                        case 2:
                            thisWeek =1;
                            break;
                        case 3:
                            thisWeek =2;
                            break;
                        case 4:
                            thisWeek =3;
                            break;
                        case 5:
                            thisWeek =4;
                            break;
                        case 6:
                            thisWeek =5;
                            break;
                        case 7:
                            thisWeek =6;
                            break;
                    }
                    int thisIncre = 7 - thisWeek;
                    quotaDate.add(Calendar.DATE, thisIncre);
                    if(quotaDate.getTime().before(DateUtil.strToDate(endDate, "yyyy-MM-dd"))){
                        range = df.format(quotaDate.getTime());
                    }else {
                        range = df.format(DateUtil.strToDate(endDate, "yyyy-MM-dd"));
                    }
                }
                JSONObject json = countResult.get(range);
//                //因为上述时间集提前一天  但是前端是显示当前时间,所以这里给调整回去
//                if (range.equals(df.format(temp.getTime()))) {
//                    json.put("range", endDate);
//                }
                if (json != null) {
                    long amount = saveModel.getResult2().longValue();
                    double num = saveModel.getResult1();
                    long previousAmount = Long.valueOf(json.get("amount").toString());
                    double previousNum = Double.parseDouble(json.get("num").toString());
                    json.put("amount", amount+previousAmount);
                    json.put("num",num+previousNum);
                }
            }
            List<JSONObject> result = new ArrayList<>(countResult.values());
            // 排序
            result.sort(new Comparator<JSONObject>() {
                @Override
                public int compare(JSONObject o1, JSONObject o2) {
                    if (o1.getString("range").compareTo(o2.getString("range")) > 0) {
                        return 1;
                    } else if (o1.getString("range").compareTo(o2.getString("range")) < 0) {
                        return -1;
                    } else {
                        return 0;
                    }
                }
            });
            JSONArray jsonArray = new JSONArray();
            for (JSONObject object:result){
                jsonArray.add(object);
            }
            return jsonArray;
        } else {
            return new JSONArray();
        }
    }
}

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

@ -1,5 +1,6 @@
package com.yihu.jw.im.service;
import ch.qos.logback.core.joran.conditional.ElseAction;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@ -54,6 +55,7 @@ import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.jw.wechat.service.WxAccessTokenService;
import com.ylzinfo.onepay.sdk.domain.ext.WaitPayDetailVO;
import com.ylzinfo.onepay.sdk.utils.StringUtil;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -65,6 +67,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import javax.servlet.http.HttpServletRequest;
import javax.xml.bind.Element;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@ -324,6 +327,33 @@ public class ImService {
		logger.info("未结束判断语句"+totalSql+"======consultCode"+consultCode);
		return consultCode;
	}
	/**
	 * 查询居民与某个医生未结束的专家咨询
	 *
	 * @param patient 居民
	 * @param doctor  医生
	 * @return
	 */
	public String  getUnfinishedConsult2(String patient, String doctor) {
		String totalSql = "SELECT a.id as \"consultCode\" " +
				"FROM wlyy_outpatient a " +
				"WHERE a.consult=b.consult " +
				"AND a.patient= '" +patient+"' "+
				"AND a.doctor='" +doctor+"' "+
				"AND a.type in (1,2 )" +
				"AND a.status in (0,1)" +
				"AND a.outpatient_type = 3";
		List<Map<String, Object>> rstotal = hibenateUtils.createSQLQuery(totalSql);
		String consultCode = null;
		if (rstotal != null && rstotal.size() > 0) {
			consultCode = rstotal.get(0).get("consultCode").toString();
		}
		logger.info("未结束判断语句"+totalSql+"======consultCode"+consultCode);
		return consultCode;
	}
	/**
	 * 根据咨询Code,查询咨询详情
@ -1195,7 +1225,22 @@ public class ImService {
					consultName.put("patientName",p.getName());
					consultName.put("doctorName",doctor.getName());
					jsonObject.put("name",consultName.toJSONString());
				}else{
				}else if ("3".equals(wlyyOutpatientDO.getOutpatientType())){
					if (wlyyOutpatientDO.getType().equalsIgnoreCase("1")){
						users.put(patient, 0);
						ct.setType(1);
						consultTitle = "图文咨询";
					}else if (wlyyOutpatientDO.getType().equalsIgnoreCase("2")){
						users.put(patient, 0);
						ct.setType(17);
						consultTitle = "视频咨询";
					}else {
						users.put(patient, 0);
						ct.setType(15);
						consultTitle = "家医咨询";
					}
				} else{
					users.put(patient, 0);
					consultTitle = "申请复诊";
				}
@ -1253,12 +1298,27 @@ public class ImService {
					sessionId = patient + "_" + outpatientCode + "_" + ct.getType();
					obj = imUtil.createTopics(sessionId, consult.getId(), p.getName(), users, messages, imUtil.SESSION_TYPE_COLLABORATION_HOSPITAL);
				}else{
				}else if("3".equals(wlyyOutpatientDO.getOutpatientType())){
					messages = imUtil.getCreateTopicMessage(patient, p.getName(), consult.getTitle(), content, consult.getImages(), doctorCode);
					//5、(im创建咨询) 续方咨询的sessionid为居民code+就诊code+9(图文,视频,图文+视频)
					sessionId = patient + "_" + outpatientCode + "_" + ct.getType();
					if(1== type){
					if("1".equalsIgnoreCase(wlyyOutpatientDO.getType())){
						//图文咨询
						obj = imUtil.createTopics(sessionId, consult.getId(), p.getName(), users, messages, imUtil.SESSION_TYPE_MUC);
					}
					else if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())){
						//视频咨询
						obj = imUtil.createTopics(sessionId, consult.getId(), p.getName(), users, messages, imUtil.SESSION_TYPE_MUC_VIDEO);
					}else{
						obj = imUtil.createTopics(sessionId, consult.getId(), p.getName(), users, messages, imUtil.SESSION_TYPE_GENERAL_EXPERT);
					}
				} else{
					messages = imUtil.getCreateTopicMessage(patient, p.getName(), consult.getTitle(), content, consult.getImages(), doctorCode);
					//5、(im创建咨询) 续方咨询的sessionid为居民code+就诊code+9(图文,视频,图文+视频)
					sessionId = patient + "_" + outpatientCode + "_" + ct.getType();
					if("1".equalsIgnoreCase(wlyyOutpatientDO.getType())){
						//图文复诊
						obj = imUtil.createTopics(sessionId, consult.getId(), p.getName(), users, messages, imUtil.SESSION_TYPE_EXAMINATION);
					}else{
@ -1326,7 +1386,7 @@ public class ImService {
				JSONObject object = new JSONObject();
				object.put("socket_sms_type",5);
				object.put("relation_code",wlyyOutpatientDO.getId());
				imUtil.sendMessage(wlyyOutpatientDO.getDoctor(),wlyyOutpatientDO.getPatient(),"1",object.toString());
				imUtil.sendMessage(wlyyOutpatientDO.getDoctor(),wlyyOutpatientDO.getConsumer(),"1",object.toString());
				//医生接诊发送导诊护士外层消息
				this.sendOutpatientGuaidanceMessage(wlyyOutpatientDO);
			}else if("2".equals(wlyyOutpatientDO.getOutpatientType())){
@ -1338,12 +1398,20 @@ public class ImService {
				imUtil.sendMessage(wlyyOutpatientDO.getDoctor(),wlyyOutpatientDO.getGeneralDoctor(),"1",object.toString());
				//医生接诊发送导诊护士外层消息
				this.sendOutpatientGuaidanceMessage(wlyyOutpatientDO);
			}else {
				//专家咨询
				System.out.println("发送外层SOCKET消息:专家咨询");
				JSONObject object = new JSONObject();
				object.put("socket_sms_type",5);
				object.put("relation_code",wlyyOutpatientDO.getId());
				imUtil.sendMessage(wlyyOutpatientDO.getDoctor(),wlyyOutpatientDO.getConsumer(),"1",object.toString());
				//医生接诊发送导诊护士外层消息
				this.sendOutpatientGuaidanceMessage(wlyyOutpatientDO);
			}
			return result;
		}
	}
	/**
	 * 添加复诊咨询
	 * @return
@ -1356,7 +1424,11 @@ public class ImService {
		// 查询患者信息
		BasePatientDO p = basePatientDao.findById(patient);
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("title", p.getName() + "申请复诊");
		if("3".equals(wlyyOutpatientDO.getOutpatientType())){
			jsonObject.put("title", p.getName() + "申请咨询");
		}else{
			jsonObject.put("title", p.getName() + "申请复诊");
		}
		jsonObject.put("content",wlyyOutpatientDO.getDescription());
		jsonObject.put("age",DateUtil.getAgeForIdcard(p.getIdcard()));
		jsonObject.put("sex",p.getSex());
@ -1379,12 +1451,26 @@ public class ImService {
			users.put(wlyyOutpatientDO.getGeneralDoctor(),0);
			ct.setType(12);
			consultTitle = "申请协同门诊";
			JSONObject consultName = new JSONObject();
			consultName.put("patientName",p.getName());
			consultName.put("doctorName",doctor.getName());
			jsonObject.put("name",consultName.toJSONString());
		}else{
		}else if ("3".equals(wlyyOutpatientDO.getOutpatientType())){
			if (wlyyOutpatientDO.getType().equalsIgnoreCase("1")){
				users.put(patient, 0);
				ct.setType(1);
				consultTitle = "图文咨询";
			}else if (wlyyOutpatientDO.getType().equalsIgnoreCase("2")){
				users.put(patient, 0);
				ct.setType(17);
				consultTitle = "视频咨询";
			}else {
				users.put(patient, 0);
				ct.setType(15);
				consultTitle = "家医咨询";
			}
		}  else{
			users.put(patient, 0);
			consultTitle = "申请复诊";
		}
@ -1442,12 +1528,27 @@ public class ImService {
			sessionId = patient + "_" + outpatientCode + "_" + ct.getType();
			obj = imUtil.createTopics(sessionId, consult.getId(), p.getName(), users, messages, imUtil.SESSION_TYPE_COLLABORATION_HOSPITAL);
		}else{
		}else if("3".equals(wlyyOutpatientDO.getOutpatientType())){
			messages = imUtil.getCreateTopicMessage(patient, p.getName(), consult.getTitle(), content, consult.getImages(), doctorCode);
			//5、(im创建咨询) 续方咨询的sessionid为居民code+就诊code+1,17.15图文,视频,家医
			sessionId = patient + "_" + outpatientCode + "_" + ct.getType();
			if("1".equalsIgnoreCase(wlyyOutpatientDO.getType())){
				//图文咨询
				obj = imUtil.createTopics(sessionId, consult.getId(), p.getName(), users, messages, imUtil.SESSION_TYPE_MUC);
			}
			else if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())){
				//视频咨询
				obj = imUtil.createTopics(sessionId, consult.getId(), p.getName(), users, messages, imUtil.SESSION_TYPE_MUC_VIDEO);
			}else{
				obj = imUtil.createTopics(sessionId, consult.getId(), p.getName(), users, messages, imUtil.SESSION_TYPE_GENERAL_EXPERT);
			}
		} else{
			messages = imUtil.getCreateTopicMessage(patient, p.getName(), consult.getTitle(), content, consult.getImages(), doctorCode);
			//5、(im创建咨询) 续方咨询的sessionid为居民code+就诊code+9(图文,视频,图文+视频)
			sessionId = patient + "_" + outpatientCode + "_" + ct.getType();
			if(1== type){
			if("1".equalsIgnoreCase(wlyyOutpatientDO.getType())){
				//图文复诊
				obj = imUtil.createTopics(sessionId, consult.getId(), p.getName(), users, messages, imUtil.SESSION_TYPE_EXAMINATION);
			}else{
@ -1487,14 +1588,13 @@ public class ImService {
		// 添加医生咨询日志
		addLogs(ct);
		JSONObject result = imUtil.getSingleSessionInfo(sessionId,doctorCode);
		//发送外层SOCKET消息 在线复诊
		if("1".equals(wlyyOutpatientDO.getOutpatientType())){
		if("1".equals(wlyyOutpatientDO.getOutpatientType())||"3".equals(wlyyOutpatientDO.getOutpatientType())){
			System.out.println("发送外层SOCKET消息:在线复诊");
			JSONObject object = new JSONObject();
			object.put("socket_sms_type",5);
			object.put("relation_code",wlyyOutpatientDO.getId());
			imUtil.sendMessage(wlyyOutpatientDO.getDoctor(),wlyyOutpatientDO.getPatient(),"1",object.toString());
			imUtil.sendMessage(wlyyOutpatientDO.getDoctor(),wlyyOutpatientDO.getConsumer(),"1",object.toString());
			//医生接诊发送导诊护士外层消息
			this.sendOutpatientGuaidanceMessage(wlyyOutpatientDO);
		}else if("2".equals(wlyyOutpatientDO.getOutpatientType())){
@ -1527,6 +1627,8 @@ public class ImService {
			msgStr = msgStr + "  已开始复诊";
		}else if("2".equals(wlyyOutpatientDO.getOutpatientType())){
			msgStr = msgStr + "  已开始协同门诊";
		}else {
			msgStr = msgStr + "  已开始专家咨询";
		}
		object.put("msg",msgStr);
@ -2531,6 +2633,10 @@ public class ImService {
						"base_patient d," +
						"wlyy_consult a   " +
						"left join wlyy_outpatient op on  a.relation_code = op.id " +
						/*"FROM wlyy_outpatient op left join wlyy_consult_team b," +
						"base_patient d," +
						"wlyy_consult a   " +
						" on  a.relation_code = op.id " +*/
						"WHERE a.id=b.consult " +
						"AND b.patient=d.id ";
				if (status == 1) {
@ -3548,13 +3654,31 @@ public class ImService {
	public Long doctorConsults(String doctorCode){
		String sql=  "SELECT count(1) AS \"total\"  " +
		/*String sql=  "SELECT count(1) AS \"total\"  " +
				" FROM wlyy_consult a," +
				"wlyy_consult_team b," +
				"base_patient d  " +
				" WHERE a.id=b.consult " +
				" AND b.patient=d.id AND b.doctor='" + doctorCode + "' AND b.type in (1,15,17) and b.status = 0 and a.pay_status=1" +
				" ORDER BY a.czrq desc ";
				" ORDER BY a.czrq desc ";*/
		String sql=  "SELECT count(1) AS \"total\"  " +
				" FROM wlyy_outpatient a " +
				" WHERE a.outpatient_type in (1,2,3)" +
				" AND a.doctor='" + doctorCode + "' AND a.type in (1,2,3) and a.status in (0,1) and a.pay_status=1" +
				" ORDER BY a.create_time desc ";
		List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(sql);
		Long consultCount = 0l;
		if (rstotal != null && rstotal.size() > 0) {
			consultCount = Long.parseLong(rstotal.get(0).get("total").toString());
		}
		return consultCount;
	}
	public Long doctorConsultsNew(String doctorCode){
		String sql=  "SELECT count(1) AS \"total\"  " +
				" FROM wlyy_outpatient a " +
				" WHERE a.outpatient_type in (1,2,3)" +
				" AND b.doctor='" + doctorCode + "' AND a.type in (1,2,3) and a.status in (0,1,2) and a.pay_status=1" +
				" ORDER BY a.create_time desc ";
		List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(sql);
		Long consultCount = 0l;
		if (rstotal != null && rstotal.size() > 0) {
@ -3571,7 +3695,7 @@ public class ImService {
	public List<Map<String,Object>> doctorUpcomingList(String doctorCode, String type) {
		String sql = "";
		if("1,15,17".equals(type)) {
			sql = "SELECT " +
			/*sql = "SELECT " +
					"a.id AS \"id\"," +
					"a.type AS \"type\"," +
					"a.title AS \"title\"," +
@ -3599,7 +3723,93 @@ public class ImService {
					"base_patient d  " +
					"WHERE a.id=b.consult " +
					"AND b.patient=d.id AND b.doctor='" + doctorCode + "' AND b.type in (" + type + ") and b.status = 0 and a.pay_status=1 " +
					"ORDER BY a.czrq desc ";
					"ORDER BY a.czrq desc ";*/
			sql = "SELECT " +
					" DISTINCT op.id AS \"outpatientId\"," +
					"op.description AS \"title\"," +
					"op.description AS \"symptoms\","+
					//添加排序的列
					"op.create_time AS \"createTime\",";
			if("xm_ykyy_wx".equals(wxId)){
				if (flag){
					sql = sql + "date_format(op.create_time,'%Y-%m-%d %H:%i:%S' )  AS \"czrq\",";
				}else {
					sql = sql + "to_char(op.create_time,'YYYY-MM-DD hh24:mi:ss')  AS \"czrq\",";
				}
			}else{
				sql = sql + "date_format(op.create_time,'%Y-%m-%d %H:%i:%S' )  AS \"czrq\",";
			}
			sql =sql +"op.status AS \"status\"," +
					"op.evaluate_status AS \"evaluate\"," +
					"op.doctor AS \"doctorCode\"," +
					"case op.type when '1' then '1'  when '3' then '15' else  '17' end \"type\"," +
					"op.general_doctor AS \"generalDoctor\"," +
					"patient.NAME AS \"patientName\"," +
					"patient.id AS \"patientId\"," +
					"op.consumer AS \"consumer\"," +
					"patient.idcard AS \"patientIdcard\"," +
					"patient.sex AS \"patientsex\"," +
					"patient.photo AS \"patientphoto\",";
			if("xm_ykyy_wx".equals(wxId)){
				if (flag){
					sql = sql + "date_format(op.register_date,'%Y-%m-%d %H:%i:%S' )  AS \"registerDate\",";
				}else {
					sql = sql + "to_char(op.register_date,'YYYY-MM-DD hh24:mi:ss')  AS \"registerDate\",";
				}
			}else{
				sql = sql + "date_format(op.register_date,'%Y-%m-%d %H:%i:%S' )  AS \"registerDate\",";
			}
			sql = sql +		"op.status AS \"outpatientstatus\", " +
					"p.check_status as \"checkStatus\"," +
					"p.check_reason as \"checkReason\""+
					"FROM base_patient patient," +
					"wlyy_outpatient op " +
					" left join wlyy_prescription p on p.outpatient_id = op.id "+
					"WHERE op.patient=patient.id " +
					"AND op.doctor='"+doctorCode+"' " +
					"AND op.status in ('0','1','2') and  op.pay_status=1 ";
			/*if("9".equals(type)){
				//图文复诊
				sql =sql +"AND op.type=1 AND op.outpatient_type=1 ";
			}else if("16".equals(type)){
				//视频复诊
				sql =sql +"AND op.type=2 AND op.outpatient_type=1 ";
				if("xm_ykyy_wx".equals(wxId)){
					if (flag){
						sql +=" and op.register_date >= str_to_date('"+DateUtil.dateToStrShort(new Date())+" 00:00:00','YYYY-MM-DD HH24:MI:SS')";
					}else {
						sql +=" and op.register_date >= to_date('"+DateUtil.dateToStrShort(new Date())+" 00:00:00','YYYY-MM-DD HH24:MI:SS')";
					}
				}else {
					sql +=" AND  op.register_date >= '"+DateUtil.dateToStrShort(new Date())+" 00:00:00' ";
				}
			}else if("12".equals(type)){
				//视频复诊
				sql =sql +"AND op.outpatient_type=2";
				if("xm_ykyy_wx".equals(wxId)){
					if (flag){
						sql +=" and op.register_date >= str_to_date('"+DateUtil.dateToStrShort(new Date())+" 00:00:00','YYYY-MM-DD HH24:MI:SS')";
					}else  {
						sql +=" and op.register_date >= to_date('"+DateUtil.dateToStrShort(new Date())+" 00:00:00','YYYY-MM-DD HH24:MI:SS')";
					}
				}else {
					sql +=" AND  op.register_date >= '"+DateUtil.dateToStrShort(new Date())+" 00:00:00' ";
				}
			}else{}*/
			if("xm_ykyy_wx".equals(wxId)){
				if (flag){
					sql +=" and op.register_date >= str_to_date('"+DateUtil.dateToStrShort(new Date())+" 00:00:00','YYYY-MM-DD HH24:MI:SS')";
				}else {
					sql +=" and op.register_date >= to_date('"+DateUtil.dateToStrShort(new Date())+" 00:00:00','YYYY-MM-DD HH24:MI:SS')";
				}
			}else {
				sql +=" AND  op.register_date >= '"+DateUtil.dateToStrShort(new Date())+" 00:00:00' ";
			}
			sql =sql +" AND op.type in ('1','2') AND op.outpatient_type = 3 ";
			sql =sql +" ORDER BY op.create_time DESC";
		}
		if("9".equals(type) || "16".equals(type)|| "12".equals(type)){
			sql = "SELECT " +
@ -3621,6 +3831,7 @@ public class ImService {
					"op.evaluate_status AS \"evaluate\"," +
					"op.doctor AS \"doctorCode\"," +
					"op.general_doctor AS \"generalDoctor\"," +
					"op.consumer AS \"consumer\"," +
					"patient.NAME AS \"patientName\"," +
					"patient.id AS \"patientId\"," +
					"patient.idcard AS \"patientIdcard\"," +
@ -3767,5 +3978,289 @@ public class ImService {
			}
		}
	}
	/**
	 * 查询医生所有的咨询记录
	 * @param doctor 医生标识
	 * @param id 会话ID(等同IM表topicId)
	 * @param type 咨询会话类型 : 0 全部
	 * @param status 咨询状态:0全部,1候诊中,2就诊中,3结束
	 * @param pagesize 分页大小
	 * @param title 标题关键字
	 * @param start_time 开始时间
	 * @param end_time 结束时间
	 * @return
	 */
	public List<Map<String,Object>>  findConsultRecordByDoctorNew(String doctor, String id,
															   String type, Integer status,
															   int page,int pagesize,
															   String title,String start_time,String end_time) {
		String  sql = "";
		sql = "SELECT " +
				"a.id AS \"id\"," +
				"op.pay_status AS \"payStatus\"," +
				"op.type as \"type\"," +
				"op.outpatient_type as \"outpatientType\"," +
				"op.description AS \"title\"," +
				"op.description AS \"symptoms\",";
		if ("xm_ykyy_wx".equals(wxId)) {
			if (flag) {
				sql = sql + "date_format(op.create_time,'%Y-%m-%d %H:%i:%S' )  AS \"czrq\",";
			} else {
				sql = sql + "to_char(op.create_time,'YYYY-MM-DD hh24:mi:ss')  AS \"czrq\",";
			}
		} else {
			sql = sql + "date_format(op.create_time,'%Y-%m-%d %H:%i:%S' )  AS \"czrq\",";
		}
		sql = sql + "op.status AS \"status\"," +
				"b.evaluate AS \"evaluate\"," +
				"d.name AS \"patientName\"," +
				"d.id as \"patientId\"," +
				"d.idcard as \"patientIdcard\"," +
				"d.sex as \"patientSex\"," +
				"op.consumer as \"consumer\"," +
				"op.consumer_name as \"consumerName\"," +
				"op.consumer_mobile as \"consumerMobile\"," +
				"op.id as \"outpatientId\"," +
				"op.type as \"consultType\"," +
				"op.general_doctor as \"generalDoctor\"," +
				"op.icd10_name as \"icd10Name\"," +
				"d.photo AS \"patientPhoto\" , " +
				"op.doctor as \"doctor\" ," +
				"op.source as \"source\"  " +
				"FROM wlyy_outpatient op LEFT JOIN wlyy_consult a  ON a.relation_code = op.id \n" +
				" LEFT join wlyy_consult_team b on a.id = b.consult" +
				" LEFT JOIN base_patient d on op.patient = d.id " +
				" WHERE 1=1 ";
		if (status == 1) {
			sql += " and op.status = 0";
		}else if (status==0){
		}else if (status==2) {
			sql += " and op.status = 1";
		}else{
			sql += " and op.status = "+status;
		}
		if (org.apache.commons.lang.StringUtils.isNotBlank(doctor)) {
			sql += " AND op.doctor='" + doctor + "' ";
		}
		if (!StringUtils.isEmpty(title)) {
			title = "%" + title + "%";
			sql += " and op.description like '" + title + "'";
		}
		if (!StringUtils.isEmpty(start_time)) {
			if ("xm_ykyy_wx".equals(wxId)) {
				if (flag) {
					sql += " and op.create_time >= str_to_date('" + start_time + "','YYYY-MM-DD HH24:MI:SS')";
				} else {
					sql += " and op.create_time >= to_date('" + start_time + "','YYYY-MM-DD HH24:MI:SS')";
				}
			} else {
				sql += " and op.create_time >= '" + start_time + "'";
			}
		}
		if (!StringUtils.isEmpty(end_time)) {
			if ("xm_ykyy_wx".equals(wxId)) {
				if (flag) {
					sql += " and op.create_time <= str_to_date('" + end_time + "','YYYY-MM-DD HH24:MI:SS')";
				} else {
					sql += " and op.create_time <= to_date('" + end_time + "','YYYY-MM-DD HH24:MI:SS')";
				}
			} else {
				sql += " and op.create_time <= '" + end_time + "'";
			}
		}
		//咨询类型
		if(!StringUtils.isEmpty(type)){
			if (type.equalsIgnoreCase("9")){
				sql +=" AND op.type =1 and op.outpatient_type = 1";
			}else if (type.equalsIgnoreCase("16")){
				sql +=" AND op.type =2 and op.outpatient_type = 1";
			}else if (type.equalsIgnoreCase("1")){
				sql +=" AND op.type =1 and op.outpatient_type = 3";
			}else if (type.equalsIgnoreCase("15")){
				sql +=" AND op.type =3 and op.outpatient_type = 3";
			}else if (type.equalsIgnoreCase("17")){
				sql +=" AND op.type =2 and op.outpatient_type = 3";
			}else if (type.equalsIgnoreCase("12")){
				sql +=" AND op.outpatient_type = 2";
			} else {
				sql +=" AND op.type in (1,2,3) ";
			}
		}
		if (!StringUtils.isEmpty(id)) {
			sql += " and a.id = '" + id + "'";
		}
		sql += " ORDER BY op.create_time desc ";
		List<Map<String,Object>> mapList = hibenateUtils.createSQLQuery(sql,page,pagesize);
		for (Map<String,Object> map:mapList){
			if (map.get("patientIdcard")!=null){
				String idcard = map.get("patientIdcard").toString();
				Integer age = IdCardUtil.getAgeForIdcard(idcard);
				map.put("patientAge",age);
			}else {
				map.put("patientAge",null);
			}
			if (map.get("doctor")!=null){
				String doctorId = map.get("doctor").toString();
				BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(doctorId);
				List<BaseDoctorHospitalDO> doctorHospitalDOS = doctorHospitalDao.findByDoctorCode(doctorId);
				if (doctorHospitalDOS!=null&&doctorHospitalDOS.size()!=0){
					map.put("deptName",doctorHospitalDOS.get(0).getDeptName());
				}
				if (baseDoctorDO!=null){
					map.put("doctorName",baseDoctorDO.getName());
				}
			}
			if (map.get("outpatientType")!=null){
				if ("3".equalsIgnoreCase(map.get("outpatientType").toString())&&"1".equalsIgnoreCase(map.get("type").toString())){
					map.put("type",1);
				}
				if ("3".equalsIgnoreCase(map.get("outpatientType").toString())&&"2".equalsIgnoreCase(map.get("type").toString())){
					map.put("type",17);
				}
				if ("3".equalsIgnoreCase(map.get("outpatientType").toString())&&"3".equalsIgnoreCase(map.get("type").toString())){
					map.put("type",15);
				}
				if ("1".equalsIgnoreCase(map.get("outpatientType").toString())&&"1".equalsIgnoreCase(map.get("type").toString())){
					map.put("type",9);
				}
				if ("1".equalsIgnoreCase(map.get("outpatientType").toString())&&"2".equalsIgnoreCase(map.get("type").toString())){
					map.put("type",16);
				}
				if ("2".equalsIgnoreCase(map.get("outpatientType").toString())){
					map.put("type",12);
				}
			}
			if (map.get("id")!=null){
				if("1".equals(type) || "15".equals(type) || type.contains(",")|| "17".equals(type)){
					String consultCode = map.get("id").toString();
					List<WlyyConsultAdvice> consultAdvices = wlyyConsultAdviceDao.getByConsult(consultCode);
					StringBuffer content = new StringBuffer();
					for (WlyyConsultAdvice consultAdvice:consultAdvices){
						content.append(consultAdvice.getAdviceValue()+",");
					}
					if (content!=null&&content.length()>0){
						System.out.println("content+====="+content);
						content.deleteCharAt(content.length()-1);
					}
					map.put("icd10Name",content);
				}else if ("0".equals(type)&&null!=map.get("outpatientType")&&"3".equalsIgnoreCase(map.get("outpatientType").toString())){
					String consultCode = map.get("id").toString();
					List<WlyyConsultAdvice> consultAdvices = wlyyConsultAdviceDao.getByConsult(consultCode);
					StringBuffer content = new StringBuffer();
					for (WlyyConsultAdvice consultAdvice:consultAdvices){
						content.append(consultAdvice.getAdviceValue()+",");
					}
					if (content!=null&&content.length()>0){
						System.out.println("content+====="+content);
						content.deleteCharAt(content.length()-1);
					}
					map.put("icd10Name",content);
				}
			}
		}
		return mapList;
	}
	/**
	 * 查询患者所有的咨询记录总数
	 * 	 * @param doctor 患者标识
	 * 	 * @param id 会话ID(等同IM表topicId)
	 * 	 * @param type 咨询会话类型
	 * 	 * @param status 咨询状态:0全部,1候诊中,2就诊中,3结束
	 * 	 * @param title 标题关键字
	 * 	 * @param start_time 开始时间
	 * 	 * @param end_time 结束时间
	 * @return
	 */
	public Long countConsultRecordByDoctor2(String doctor, String id,String type, Integer status,String title,String start_time,String end_time) {
		String  sql = "";
		sql = "SELECT " +
				" COUNT(1) AS \"total\" "+
				"FROM wlyy_outpatient op LEFT JOIN wlyy_consult a  ON a.relation_code = op.id \n" +
				" LEFT join wlyy_consult_team b on a.id = b.consult" +
				" LEFT JOIN base_patient d on op.patient = d.id " +
				" WHERE 1=1 ";
		if (status == 1) {
			sql += " and op.status = 0";
		}else if (status==0){
		}else if (status==2) {
			sql += " and op.status = 1";
		}else{
			sql += " and op.status = "+status;
		}
		if (org.apache.commons.lang.StringUtils.isNotBlank(doctor)) {
			sql += " AND op.doctor='" + doctor + "' ";
		}
		if (!StringUtils.isEmpty(title)) {
			title = "%" + title + "%";
			sql += " and op.description like '" + title + "'";
		}
		if (!StringUtils.isEmpty(start_time)) {
			if ("xm_ykyy_wx".equals(wxId)) {
				if (flag) {
					sql += " and op.create_time >= str_to_date('" + start_time + "','YYYY-MM-DD HH24:MI:SS')";
				} else {
					sql += " and op.create_time >= to_date('" + start_time + "','YYYY-MM-DD HH24:MI:SS')";
				}
			} else {
				sql += " and op.create_time >= '" + start_time + "'";
			}
		}
		if (!StringUtils.isEmpty(end_time)) {
			if ("xm_ykyy_wx".equals(wxId)) {
				if (flag) {
					sql += " and op.create_time <= str_to_date('" + end_time + "','YYYY-MM-DD HH24:MI:SS')";
				} else {
					sql += " and op.create_time <= to_date('" + end_time + "','YYYY-MM-DD HH24:MI:SS')";
				}
			} else {
				sql += " and op.create_time <= '" + end_time + "'";
			}
		}
		//咨询类型
		if(!StringUtils.isEmpty(type)){
			if (type.equalsIgnoreCase("9")){
				sql +=" AND op.type =1 and op.outpatient_type = 1";
			}else if (type.equalsIgnoreCase("16")){
				sql +=" AND op.type =2 and op.outpatient_type = 1";
			}else if (type.equalsIgnoreCase("1")){
				sql +=" AND op.type =1 and op.outpatient_type = 3";
			}else if (type.equalsIgnoreCase("15")){
				sql +=" AND op.type =3 and op.outpatient_type = 3";
			}else if (type.equalsIgnoreCase("17")){
				sql +=" AND op.type =2 and op.outpatient_type = 3";
			}else if (type.equalsIgnoreCase("12")){
				sql +=" AND op.outpatient_type = 2";
			} else {
				sql +=" AND op.type in (1,2,3) ";
			}
		}
		if (!StringUtils.isEmpty(id)) {
			sql += " and a.id = '" + id + "'";
		}
		sql += " ORDER BY op.create_time desc ";
		List<Map<String,Object>> mapList = hibenateUtils.createSQLQuery(sql);
		Long count = 0L;
		if (mapList != null && mapList.size() > 0) {
			count = Long.parseLong(mapList.get(0).get("total").toString());
		}
		return count;
	}
}

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/IntegerIdentityEntity.java

@ -18,7 +18,7 @@ public abstract class IntegerIdentityEntity implements Serializable {
    @Id
//==========mysql 环境 id策略======================================================
 /*   @GeneratedValue(generator = "generator")
/*    @GeneratedValue(generator = "generator")
    @GenericGenerator(name = "generator", strategy = "identity")
    @Column(name = "id", unique = true, nullable = false)*/
//==========mysql 环境 id策略 end======================================================

+ 15 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/base/doctor/BaseDoctorHospitalDO.java

@ -3,6 +3,7 @@ package com.yihu.jw.entity.base.doctor;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.*;
import java.util.Date;
/**
@ -66,8 +67,21 @@ public class BaseDoctorHospitalDO extends IntegerIdentityEntity {
     *
     */
	private String hisId;
    /**
     * hisid
     *
     */
    private Date createTime;
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
	public BaseDoctorHospitalDO(){}
    public BaseDoctorHospitalDO(){}
	public BaseDoctorHospitalDO(String orgCode, String orgName, String doctorDutyCode, String doctorDutyName){
	    this.orgCode = orgCode;

+ 21 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/base/wx/WxWechatDO.java

@ -7,7 +7,6 @@ import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -36,6 +35,8 @@ public class WxWechatDO extends UuidIdentityEntityWithOperator implements java.i
    private String mchId;//商户id
    private String cerfiticate;//商户证书(预留字段,保存证书路径??) 目前暂未使用到
    private String appKey;//appKey
    private String applets;//小程序id
    private String appletsSecret;//小程序秘钥
    @Transient
@ -218,4 +219,23 @@ public class WxWechatDO extends UuidIdentityEntityWithOperator implements java.i
    public void setAppKey(String appKey) {
        this.appKey = appKey;
    }
    @Column(name = "applets")
    public String getApplets() {
        return applets;
    }
    public void setApplets(String applets) {
        this.applets = applets;
    }
    @Column(name = "applets_secret")
    public String getAppletsSecret() {
        return appletsSecret;
    }
    public void setAppletsSecret(String appletsSecret) {
        this.appletsSecret = appletsSecret;
    }
}

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

@ -23,6 +23,7 @@ public class WlyyChargeDictDO extends UuidIdentityEntity {
    /**6总部7金榜8夏禾*/
    private String deptTypeCode;
    public String getChargeType() {
        return chargeType;
    }

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

@ -879,6 +879,8 @@ public class BaseHospitalRequestMapping {
    
        //查询居民与某个医生是否存在未结束的咨询
        public static final String isExistsUnfinishedConsult ="/isExistsUnfinishedConsult";
        //查询居民与某个医生是否存在未结束的咨询
        public static final String isExistsUnfinishedOutpatient ="/isExistsUnfinishedOutpatient";
        
        //获取会话成员
        public static final String participants ="/participants";
@ -937,9 +939,11 @@ public class BaseHospitalRequestMapping {
     */
    public static class DodtorIM extends Basic{
        public static final String PREFIX  = "/im/doctor";
    
        //医生咨询记录查询
        public static final String records ="/records";
        //医生咨询记录查询
        public static final String records2 ="/records2";
        
        //添加(复诊咨询,协同门诊)
        public static final String addPrescriptionConsult ="/addPrescriptionConsult";
@ -1025,6 +1029,8 @@ public class BaseHospitalRequestMapping {
        //医生端:进行中的专家咨询人数
        public static final String doctorSpecialistConsultCountNew="doctorSpecialistConsultCountNew";
        //医生端:进行中的专家咨询人数
        public static final String doctorSpecialistConsultCountNew2="doctorSpecialistConsultCountNew2";
    
        //医生端:图文复诊、视频复诊咨询数量、协同门诊候诊数量
        public static final String doctorReviewConsultCount="doctorReviewConsultCount";
@ -1408,6 +1414,7 @@ public class BaseHospitalRequestMapping {
        public static final String delPrivateDict = "/delPrivateDict";
        public static final String findHospitalInfo = "/findHospitalInfo";
        public static final String synYktZxPrice = "/synYktZxPrice";
        public static final String findHospitalConsultInfo = "/findHospitalConsultInfo";
    }
    /**

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

@ -27,6 +27,7 @@ public class WlyyChargeDictVO {
    @ApiModelProperty(value = "6总部7金榜8夏禾", example = "模块1")
    private String deptTypeCode;
    public String getChargeType() {
        return chargeType;
    }

+ 1 - 1
gateway/ag-basic/pom.xml

@ -12,7 +12,7 @@
    <artifactId>ag-basic</artifactId>
    <version>${parent.version}</version>
    <packaging>jar</packaging>
    <packaging>war</packaging>
    <dependencies>
        <!-- 支持Tomcat启动 -->

+ 4 - 2
gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/BasicZuulFilter.java

@ -104,7 +104,8 @@ public class BasicZuulFilter extends ZuulFilter {
            url.contains("/open/noLogin/getSFExpressInfoNew")||
            url.contains("/open/noLogin/sfroutepushservice")||
            url.contains("/open/noLogin/ylzSettleRecord")||
                url.contains("/weixin"))){
                url.contains("/weixin")||
                url.contains("/excelControl"))){
            logger.info("入参"+ctx.getRequestQueryParams());
            try {
                decrypt(ctx,request);
@ -131,7 +132,8 @@ public class BasicZuulFilter extends ZuulFilter {
                || url.contains("/accountAppeal/create")
                || url.contains("/open/")//开放接口
                || url.contains("/image/")//获取默认图片
                ||url.contains("/weixin")) {
                ||url.contains("/weixin")||
                url.contains("/excelControl")) {
            return true;
        }
        System.out.println("进入token验证");

+ 3 - 1
gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/PostFilter.java

@ -42,7 +42,9 @@ public class PostFilter extends ZuulFilter {
        logger.info("进入post过滤器");
        HttpServletRequest request = ctx.getRequest();
        String url = request.getRequestURI();
        if (url.contains("/excelControl")){
            return true;
        }
        InputStream stream = RequestContext.getCurrentContext().getResponseDataStream();
        try {
        byte[] bytes;

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

@ -658,9 +658,6 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
                String idcard = patient.getString("idcard");
                BasePatientDO patientDO2 = patientDao.findByIdcardAndDel(idcard,"1");
                BasePatientDO patient1 = new BasePatientDO();
                if (patientDO2!=null){
                    patient1=patientDO2;
                }
                String salt = UUID.randomUUID().toString().substring(0,5);
                String mobile = patient.getString("mobile");
                String pw = null;
@ -669,10 +666,14 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
                }else{
                    pw = idcard.substring(idcard.length()-6);
                }
                if (patientDO2!=null){
                    patient1=patientDO2;
                }else {
                    patient1.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
                    patient1.setSalt(salt);
                }
                patient1.setIdcard(idcard);
                patient1.setName(patient.getString("name"));
                patient1.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
                patient1.setSalt(salt);
                patient1.setSex(StringUtils.isNotBlank(idcard)?Integer.parseInt(IdCardUtil.getSexForIdcard_new(idcard)):null);
                patient1.setMobile(mobile);
                patient1.setDel("1");

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

@ -23,7 +23,7 @@ import java.util.List;
public interface BaseDoctorDao extends PagingAndSortingRepository<BaseDoctorDO, String>, JpaSpecificationExecutor<BaseDoctorDO>  {
    BaseDoctorDO findById(String id);
    @Query("from BaseDoctorDO d where d.idcard=?1 and d.del ='1'")
    BaseDoctorDO findByIdcard(String idcard);
    List<BaseDoctorDO> findByMobile(String mobile);

+ 31 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/dao/patient/WechatDao.java

@ -0,0 +1,31 @@
package com.yihu.jw.security.dao.patient;
import com.yihu.jw.entity.base.wx.WxWechatDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Administrator on 2017/5/20 0020.
 */
public interface WechatDao extends PagingAndSortingRepository<WxWechatDO, String>, JpaSpecificationExecutor<WxWechatDO> {
    @Query("from WxWechatDO w where w.appId = ?1 and w.status!=-1")
    WxWechatDO findByAppId(String appId);
    @Query("from WxWechatDO w where w.appId = ?1 and w.id!= ?2 and w.status!=-1")
    WxWechatDO findByAppIdExcludeId(String appId, String id);
    @Query("from WxWechatDO w where w.id = ?1 and w.status!=-1")
    WxWechatDO findById(String id);
    @Query("from WxWechatDO w where w.status!=-1")
    List<WxWechatDO> findAll();
    @Query("from WxWechatDO w where w.appOriginId = ?1 and w.status!=-1")
    WxWechatDO findByAppOriginId(String appOriginId);
    List<WxWechatDO> findByName(String name);
}

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

@ -7,6 +7,7 @@ import com.google.code.kaptcha.util.Config;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.login.BaseLoginLogDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.WxWechatDO;
import com.yihu.jw.restmodel.ResultStatus;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
@ -14,6 +15,7 @@ import com.yihu.jw.security.core.userdetails.jdbc.WlyyUserDetailsService;
import com.yihu.jw.security.dao.OauthKeypairDao;
import com.yihu.jw.security.dao.doctor.BaseDoctorDao;
import com.yihu.jw.security.dao.patient.BasePatientDao;
import com.yihu.jw.security.dao.patient.WechatDao;
import com.yihu.jw.security.exception.ImgCaptchaException;
import com.yihu.jw.security.login.service.BaseLoginLogService;
import com.yihu.jw.security.model.*;
@ -28,6 +30,8 @@ import com.yihu.jw.security.utils.SerializeUtil;
import com.yihu.jw.sms.service.YkyySMSService;
import com.yihu.jw.sms.service.ZhongShanSMSService;
import com.yihu.jw.sms.util.ykyy.vo.ResultMsg;
import com.yihu.utils.network.HttpResponse;
import com.yihu.utils.network.HttpUtils;
import com.yihu.utils.security.MD5;
import com.yihu.utils.security.RSAUtils;
import io.swagger.annotations.Api;
@ -143,6 +147,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    private String wechatId;
    @Autowired
    private XzzxService xzzxService;
    @Autowired
    private WechatDao wechatDao;
    @PostConstruct
    private void init() {
@ -605,6 +611,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
                if ("10000".equalsIgnoreCase(jsonObject.getString("code"))){
                    captcha = jsonObject.getString("value");
                    resltCode = jsonObject.getString("code");
                    msg = "发送成功";
                }
            }
            if ("10000".equalsIgnoreCase(resltCode)) {
@ -614,7 +621,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
                _captcha.setExpiresIn(300);
                wlyyRedisVerifyCodeService.store(client_id, username, captcha, 300);
                Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>("captcha", 200, _captcha);
                Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>(msg, 200);
                HttpHeaders headers = new HttpHeaders();
                headers.set("Cache-Control", "no-store");
                headers.set("Pragma", "no-cache");
@ -652,7 +659,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
                    _captcha.setExpiresIn(300);
                    wlyyRedisVerifyCodeService.store(client_id, username, captcha1, 300);
                    Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>("captcha", 200, _captcha);
                    Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>("captcha", 200);
                    HttpHeaders headers = new HttpHeaders();
                    headers.set("Cache-Control", "no-store");
                    headers.set("Pragma", "no-cache");
@ -669,7 +676,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
                _captcha.setExpiresIn(300);
                wlyyRedisVerifyCodeService.store(client_id, username, captcha, 300);
                Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>("captcha", 200, _captcha);
                Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>("captcha", 200);
                HttpHeaders headers = new HttpHeaders();
                headers.set("Cache-Control", "no-store");
                headers.set("Pragma", "no-cache");
@ -1361,7 +1368,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        try {
            logger.info("authCode :"+authCode);
            Map<String,Object> rs = oauthSsoService.savePatient(code,appId,authCode);
            Map<String,Object> rs = oauthSsoService.savePatient(code,appId,authCode,wechatId);
            Integer c = (Integer) rs.get("code");
            if(c != 1){
                return ObjEnvelop.getError(rs.get("mes")+"");
@ -1717,6 +1724,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        String text = parameters.get("text");
        String captcha = parameters.get("captcha");
        String loginType = parameters.get("login_type");
        String appletCode = parameters.get("appletCode");
        if(org.apache.commons.lang3.StringUtils.isNotBlank(key)&& org.apache.commons.lang3.StringUtils.isNotBlank(text)){
            if(!verifyCaptcha(key,text)){
                throw new ImgCaptchaException("img_captcha error");
@ -1748,8 +1756,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
                            String userId= jsonObject.getString("ID");
                            String tel = jsonObject.getString("LOGINID");
                            List<BasePatientDO> basePatientDOS = basePatientDao.findByMobile(tel);
                            BasePatientDO basePatientDO = new BasePatientDO();
                            if (basePatientDOS==null||basePatientDOS.size()==0){
                                BasePatientDO basePatientDO = new BasePatientDO();
                                String familyList = ykyyService.getFamilyList(null,userId);
                                JSONObject familyJson = JSONObject.parseObject(familyList);
                                if (familyJson.getString("code").equalsIgnoreCase("200")){
@ -1836,9 +1844,13 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
                                            iliness.add(family.getString("ILLNESS"));
                                        }
                                    }
                                    String birdth = com.yihu.jw.util.idcard.IdCardUtil.getBirthdayForIdcardStr(basePatientDO1.getIdcard());
                                    Integer age = com.yihu.jw.util.idcard.IdCardUtil.getAgeForIdcard(basePatientDO1.getIdcard());
                                    Integer sex = basePatientDO.getSex()!=null?basePatientDO.getSex():0;
                                    String birdth = null;
                                    Integer age = 0;
                                    if (org.apache.commons.lang3.StringUtils.isNoneBlank(basePatientDO1.getIdcard())){
                                        birdth = com.yihu.jw.util.idcard.IdCardUtil.getBirthdayForIdcardStr(basePatientDO1.getIdcard());
                                        age =com.yihu.jw.util.idcard.IdCardUtil.getAgeForIdcard(basePatientDO1.getIdcard());
                                    }
                                    Integer sex = basePatientDO1.getSex()!=null?basePatientDO1.getSex():0;
                                    if (iliness!=null&&iliness.size()!=0){
                                        if (!iliness.contains("本人")){
                                            ykyyService.addFamily(basePatientDO1.getUserId(),basePatientDO1.getIdcard(),basePatientDO1.getName(),sex+"",birdth,age+"",basePatientDO1.getMobile());
@ -1864,17 +1876,20 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        } else {
            parameters.put("grant_type", "captcha");
        }
        logger.info("登陆111111111111111111");
        ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
        if (null == authenticatedClient) {
            throw new InvalidRequestException("client_id");
        }
        logger.info("登陆22222222222222222");
        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());
        }
        logger.info("登陆33333333333333333333");
        /*如果是移动端登陆则移除之前的token,
        在网关处通过HTTP状态码告知前端是过期(402)还是账号在别处登陆(403),
        实现同一账号只能在一处登陆*/
@ -1887,6 +1902,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        if (token == null) {
            throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
        }
        logger.info("登陆4444444444444444");
        WlyyUserSimple wlyyUserSimple = userDetailsService.authSuccess(parameters.get("username"));
        wlyyUserSimple.setAccessToken(token.getValue());
        wlyyUserSimple.setTokenType(token.getTokenType());
@ -1901,7 +1917,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        BaseLoginLogDO baseLoginLogDO = new BaseLoginLogDO();
        if (!StringUtils.isEmpty(openid) && !"undefined".equalsIgnoreCase(openid) && "3".equals(loginType)) {
            baseLoginLogDO.setOpenid(openid);
            userDetailsService.updateOpenId(openid, wlyyUserSimple.getId());
            /*userDetailsService.updateOpenId(openid, wlyyUserSimple.getId());*/
            if (!StringUtils.isEmpty(wechatId)&& !"undefined".equalsIgnoreCase(wechatId)){
                userDetailsService.updateOpenIdAndWechatId(openid,wlyyUserSimple.getId(),wechatId);
            }
@ -1910,6 +1926,16 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            //使用密码登录成功后, 更新失败次数为 0
            userDetailsService.addFailureCount(username, 0);
        }
        WxWechatDO wxWechatDO = wechatDao.findById(wechatId);
        String appletOpenid = null;
        if (!StringUtils.isEmpty(appletCode)){
            Map<String,Object> objectMap = checkApplets(appletCode,wxWechatDO.getApplets(),wxWechatDO.getAppletsSecret());
            if (objectMap!=null){
                appletOpenid = objectMap.get("openid").toString();
                userDetailsService.updateOpenId(appletOpenid, wlyyUserSimple.getId());
            }
        }
        userDetailsService.setRolePhth(loginType, token, wlyyUserSimple.getId(), redisTemplate);
        baseLoginLogDO.setUserId(wlyyUserSimple.getId());
@ -1923,6 +1949,26 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    }
    public Map<String, Object> checkApplets(String code,String appid,String appSecret) throws Exception {
        HttpUtils httpUtils = new HttpUtils();
        Map<String, Object> param = new HashedMap();
        param.put("appid", appid);
        param.put("secret", appSecret);
        param.put("js_code", code);
        param.put("grant_type", "authorization_code");
        HttpResponse response = httpUtils.doGet("https://api.weixin.qq.com/sns/jscode2session", param);
        org.json.JSONObject rs = new org.json.JSONObject(response.getContent());
        Map<String, Object> res = new HashedMap();
        logger.info("checkApplets:"+response.getContent());
        if (rs.has("openid")){
            res.put("openid", rs.getString("openid"));
            res.put("sessionKey", rs.getString("session_key"));
        }
        return res;
    }
    @RequestMapping(value = "/oauth/findYktPatientPw", method = RequestMethod.POST)
    public Envelop findYktPatientPw(String mobile,String client_id,String login_type,String captcha,String pw)throws Exception {
        if (wlyyRedisVerifyCodeService.verification(client_id, mobile, captcha)) {

+ 2 - 2
server/svr-authentication/src/main/java/com/yihu/jw/security/service/OauthSsoService.java

@ -86,7 +86,7 @@ public class OauthSsoService {
        return oauthRsaKeyDO.getPublicKey();
    }
    public Map<String,Object> savePatient(String code,String appId,String authCode)throws Exception{
    public Map<String,Object> savePatient(String code,String appId,String authCode,String wechatId)throws Exception{
        Map<String,Object> rs = new HashedMap();
        try{
@ -128,7 +128,7 @@ public class OauthSsoService {
                    rs.put("mes","获取居民信息成功");
                    rs.put("patient",basePatientDO);
                    List<BasePatientWechatDo> wechatDos = basePatientWechatDao.findByWechatIdAndPatientId(appId,basePatientDO.getId());
                    List<BasePatientWechatDo> wechatDos = basePatientWechatDao.findByWechatIdAndPatientId(wechatId,basePatientDO.getId());
                    if(wechatDos!=null&&wechatDos.size()>0){
                        for(BasePatientWechatDo wechatDo:wechatDos){
                            wechatDo.setOpenid(openid);

+ 10 - 0
svr/svr-base/src/main/java/com/yihu/SvrBaseApplication.java

@ -3,9 +3,13 @@ package com.yihu;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import javax.servlet.MultipartConfigElement;
/**
 * Created by chenweida on 2017/5/10.
 * localhost:10020/refresh  刷新当个微服务的配置 可以在需要刷新的bean上面@RefreshScope
@ -22,5 +26,11 @@ public class SvrBaseApplication extends SpringBootServletInitializer {
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(SvrBaseApplication.class);
    }
    @Bean
    MultipartConfigElement multipartConfigElement() {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        factory.setLocation("/home/temp");
        return factory.createMultipartConfig();
    }
}

+ 1 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/dict/DictJobTitleDao.java

@ -35,6 +35,7 @@ public interface DictJobTitleDao extends PagingAndSortingRepository<DictJobTitle
    Long countBySaasId(String saasId);
    DictJobTitleDO findByName(String code);
    DictJobTitleDO findByCode(String code);
    boolean existsByCode(String code);

+ 2 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/doctor/BaseDoctorRoleDictDao.java

@ -11,4 +11,6 @@ import java.util.List;
public interface BaseDoctorRoleDictDao extends PagingAndSortingRepository<BaseDoctorRoleDictDO, String>, JpaSpecificationExecutor<BaseDoctorRoleDictDO> {
    @Query(value = "select * from base_doctor_role_dict where name = ?1",nativeQuery = true)
    List<BaseDoctorRoleDictDO> getByname(String name);
    boolean existsByCode(String code);
    boolean existsByName(String name);
}

+ 96 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/doctor/BaseDoctorEndpoint.java

@ -19,13 +19,21 @@ import com.yihu.jw.rm.base.BaseRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
@ -33,6 +41,7 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
 * 医生基础信息控制器
@ -277,7 +286,9 @@ public class BaseDoctorEndpoint extends EnvelopRestEndpoint {
        try {
            request.setCharacterEncoding("UTF-8");
//            AExcelReader excelReader = new BaseDoctorExcelDOReader();
            doctorExcelDOReader.read(file);
            InputStream inputStream = file.getInputStream();
            Workbook workbook = getWorkbook(inputStream,file.getOriginalFilename());
            doctorExcelDOReader.read(workbook);
            //验证未通过(暂无验证)
            List<BaseDoctorExcelDO> errorLs = doctorExcelDOReader.getErrorLs();
            List<BaseDoctorExcelDO> correctLs = doctorExcelDOReader.getCorrectLs();
@ -292,4 +303,88 @@ public class BaseDoctorEndpoint extends EnvelopRestEndpoint {
        }
        return failed("导入失败");
    }
    @GetMapping("/exportExcel")
    public void exportExcel(HttpServletRequest request, HttpServletResponse response) {
        try {
            HSSFWorkbook wb = new HSSFWorkbook(new FileInputStream("/home/医生模板信息.xls"));
// 根据页面index 获取sheet页
            HSSFSheet sheet = wb.getSheet("Sheet1");
            for (int i = 0; i < 2; i++) {
// 创建HSSFRow对象
                HSSFRow row = sheet.createRow(i + 1);
// 创建HSSFCell对象 设置单元格的值
                row.createCell(0).setCellValue("张三" + i);
                row.createCell(1).setCellValue("1");
                row.createCell(2).setCellValue("1");
                row.createCell(3).setCellValue("210503199507250333");
                row.createCell(4).setCellValue("18841409773");
                row.createCell(5).setCellValue("350211A1002/0000001/1303");
                row.createCell(6).setCellValue("1302");
                row.createCell(7).setCellValue("admin");
                row.createCell(8).setCellValue("1");
            }
// 输出Excel文件
            OutputStream output = response.getOutputStream();
            response.reset();
// 设置文件头
            /*response.setHeader("Content-Disposition",
                    "attchement;filename=" + new String("人员信息.xls".getBytes("gb2312"), "ISO8859-1"));
            response.setContentType("application/msexcel");*/
            response.setCharacterEncoding("utf-8");
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename="
                    + new String( "医生模板信息".getBytes("gb2312"), "ISO8859-1" )+".xls");
            wb.write(output);
            wb.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 判断文件格式
     * @param in
     * @param fileName
     * @return
     */
    private static Workbook getWorkbook(InputStream in, String fileName) throws Exception {
        Workbook book = null;
        String filetype = fileName.substring(fileName.lastIndexOf("."));
        if(".xls".equals(filetype)) {
            book = new HSSFWorkbook(in);
        } else if (".xlsx".equals(filetype)) {
            book = new XSSFWorkbook(in);
        } else {
            throw new Exception("请上传excel文件!");
        }
        return book;
    }
}

+ 153 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/open/nologin/BaseServiceNologin.java

@ -0,0 +1,153 @@
package com.yihu.jw.base.endpoint.open.nologin;
import com.yihu.jw.base.service.doctor.BaseDoctorService;
import com.yihu.jw.base.service.doctor.excelImport.BaseDoctorExcelDO;
import com.yihu.jw.base.service.doctor.excelImport.BaseDoctorExcelDOReader;
import com.yihu.jw.exception.business.ManageException;
import com.yihu.jw.restmodel.web.Envelop;
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.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/excelControl")
@Api(value = "不走网关接口", description = "不走网关接口", tags = {"base基础服务 - 不走网关接口"})
public class BaseServiceNologin extends EnvelopRestEndpoint {
    @Autowired
    private BaseDoctorService baseDoctorService;
    @Autowired
    private BaseDoctorExcelDOReader doctorExcelDOReader;
    @GetMapping("/exportExcel")
    public void exportExcel(HttpServletRequest request, HttpServletResponse response) {
        try {
            HSSFWorkbook wb = new HSSFWorkbook(new FileInputStream("/home/医生模板信息.xls"));
// 根据页面index 获取sheet页
            HSSFSheet sheet = wb.getSheet("Sheet1");
            for (int i = 0; i < 2; i++) {
// 创建HSSFRow对象
                HSSFRow row = sheet.createRow(i + 1);
// 创建HSSFCell对象 设置单元格的值
                row.createCell(0).setCellValue("张三" + i);
                row.createCell(1).setCellValue("1");
                row.createCell(2).setCellValue("1");
                row.createCell(3).setCellValue("210503199507250333");
                row.createCell(4).setCellValue("18841409773");
                row.createCell(5).setCellValue("350211A1002/0000001/1303");
                row.createCell(6).setCellValue("1302");
                row.createCell(7).setCellValue("admin");
                row.createCell(8).setCellValue("1");
            }
// 输出Excel文件
            OutputStream output = new BufferedOutputStream(response.getOutputStream());
            response.reset();
// 设置文件头
            /*response.setHeader("Content-Disposition",
                    "attchement;filename=" + new String("人员信息.xls".getBytes("gb2312"), "ISO8859-1"));
            response.setContentType("application/msexcel");*/
            response.setCharacterEncoding("UTF-8");
            response.setContentType("application/x-msdownload");
            /*response.setHeader("Content-Disposition", "attachment; filename="
                    + new String( "医生模板信息".getBytes("gb2312"), "ISO8859-1" )+".xls");*/
            response.setHeader("Content-Disposition", "attachment; filename="
                    + URLEncoder.encode("医生模板信息.xls","UTF-8"));
            wb.write(output);
            wb.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 判断文件格式
     * @param in
     * @param fileName
     * @return
     */
    private static Workbook getWorkbook(InputStream in, String fileName) throws Exception {
        Workbook book = null;
        String filetype = fileName.substring(fileName.lastIndexOf("."));
        if(".xls".equals(filetype)) {
            book = new HSSFWorkbook(in);
        } else if (".xlsx".equals(filetype)) {
            book = new XSSFWorkbook(in);
        } else {
            throw new Exception("请上传excel文件!");
        }
        return book;
    }
    @PostMapping(value = BaseRequestMapping.BaseDoctor.DOCTOR_INFO_IMPORT)
    @Transactional(rollbackFor = Exception.class)
    @ApiOperation(value = "基础医生信息列表导入")
    public Envelop importData(
            @ApiParam(name = "file", value = "文件", required = true)
            @RequestPart(value = "file") MultipartFile file,
            HttpServletRequest request) throws IOException, ManageException {
        try {
            request.setCharacterEncoding("UTF-8");
//            AExcelReader excelReader = new BaseDoctorExcelDOReader();
            InputStream inputStream = file.getInputStream();
            Workbook workbook = getWorkbook(inputStream,file.getOriginalFilename());
            doctorExcelDOReader.read(workbook);
            //验证未通过(暂无验证)
            List<BaseDoctorExcelDO> errorLs = doctorExcelDOReader.getErrorLs();
            List<BaseDoctorExcelDO> correctLs = doctorExcelDOReader.getCorrectLs();
            if(correctLs.size()>0){
                Map<String, Object> result = baseDoctorService.batchInsertDoctor(correctLs);
                result.put("errorLs", errorLs);
                int errors = errorLs.size();
                int corrects = correctLs.size();
                String msg = "当前导入成功"+corrects+"条数据"+";失败"+errors+"条数据";
                return success(msg, result);
            }
        }catch (Exception e){
            e.printStackTrace();
            return failed("导入异常,请检查导入文件格式" + e.getMessage());
        }
        return failed("导入失败");
    }
}

+ 11 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/open/register/RegisterEndpoint.java

@ -22,12 +22,22 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.concurrent.TimeUnit;
@ -216,4 +226,5 @@ public class RegisterEndpoint extends EnvelopRestEndpoint {
            return failed(e.getMessage(), ObjEnvelop.class);
        }
    }
}

+ 128 - 16
svr/svr-base/src/main/java/com/yihu/jw/base/service/doctor/BaseDoctorService.java

@ -3,6 +3,7 @@ package com.yihu.jw.base.service.doctor;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.sun.tools.corba.se.idl.ExceptionEntry;
import com.yihu.jw.base.dao.dict.DictJobTitleDao;
import com.yihu.jw.base.service.dict.DictDoctorDutyService;
import com.yihu.jw.base.service.doctor.excelImport.BaseDoctorExcelDO;
@ -14,6 +15,7 @@ import com.yihu.jw.dict.dao.DictDoctorDutyDao;
import com.yihu.jw.dict.dao.DictHospitalDeptDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.doctor.dao.BaseDoctorRoleDao;
import com.yihu.jw.entity.base.dict.DictDoctorDutyDO;
import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import com.yihu.jw.entity.base.dict.DictJobTitleDO;
@ -21,17 +23,28 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.exception.business.ManageException;
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.util.MqSdkUtil;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.restmodel.base.wx.WxGraphicMessageVO;
import com.yihu.jw.restmodel.base.wx.WxReplySceneVO;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.security.MD5;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
@ -89,9 +102,26 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
    private DictDoctorDutyService dictDoctorDutyService;
    @Autowired
    private DictHospitalDeptDao dictHospitalDeptDao;
    @Autowired
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
    @Autowired
    private XzzxEntranceService xzzxEntranceService;
    @Autowired
    private EntranceService entranceService;
    @Autowired
    private YkyyEntranceService ykyyEntranceService;
    @Autowired
    private DoctorMappingDao doctorMappingDao;
    @Value("${wechat.flag}")
    private boolean flag;
    @Value("${wechat.id}")
    private String  wxId;
    public static String entranceUrl = "http://172.16.100.240:10023/xzzx/";
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private BaseDoctorRoleDao baseDoctorRoleDao;
    /**
@ -189,6 +219,9 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
                "\ttb.idcard AS \"idcard\",\n" +
                "\ttb.name AS \"name\",\n" +
                "\ttb.sex AS \"sex\",\n" +
                "\ttb.orgName AS \"orgName\",\n" +
                "\ttb.deptname AS \"deptname\",\n" +
                "\ttb.doctorDutyName AS \"doctorDutyName\",\n" +
                "\ttb.mobile AS \"mobile\",";
        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
            if (flag){
@ -219,6 +252,9 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
                "\t\tEND AS sex,\n" +
                "\t\tdoc.mobile,\n" +
                "\t\thos.org_name || '/' || dept. NAME || '/' || hos.doctor_duty_name AS org,\n" +
                "\t\thos.org_name as orgName,\n" +
                "\t\tdept.NAME as deptname,\n" +
                "\t\thos.doctor_duty_name as doctorDutyName,\n" +
                "\t\tdoc.job_title_name,\n" +
                "\t\tCASE\n" +
                "\tWHEN doc.del = 0 THEN\n" +
@ -254,7 +290,7 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
                "\ttb.sex,\n" +
                "\ttb.mobile,\n" +
                "\ttb.job_title_name,\n" +
                "\ttb.status,\n" +
                "\ttb.status,\n" +"\ttb.orgName,\n" +"\ttb.deptname,\n" +"\ttb.doctorDutyName,\n" +
                "  tb.create_time\n" +
                "ORDER BY\n" +
                "\ttb.create_time DESC";
@ -341,6 +377,12 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
//        List<Map<String,Object>> list = jdbcTemplate.queryForList(finalSql);
        Logger.getAnonymousLogger().info("finalCountSql="+countSql);
        int count = jdbcTemplate.queryForObject(countSql,Integer.class);
        for (Map<String,Object> map:list){
            String orgname = map.get("orgName")==null?"":map.get("orgName").toString();
            String deptname = map.get("deptname")==null?"":map.get("deptname").toString();
            String doctorDutyName = map.get("doctorDutyName")==null?"":map.get("doctorDutyName").toString();
            map.put("orgInfo",orgname+"/"+deptname+"/"+doctorDutyName);
        }
        result.put("count", count);
        result.put("msg", JavaBeanUtils.getInstance().mapListJson(list));
        return result;
@ -370,35 +412,81 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
        }
        //组装医生信息
        BaseDoctorDO baseDoctorDO = null;
        BaseDoctorDO baseDoctorvo = null;
        try {
            baseDoctorDO = objectMapper.readValue(doctor.toJSONString(), BaseDoctorDO.class);
            baseDoctorvo = objectMapper.readValue(doctor.toJSONString(), BaseDoctorDO.class);
            baseDoctorDO =  baseDoctorDao.findByIdcardAndDel(baseDoctorvo.getIdcard());
            if (null==baseDoctorDO){
                baseDoctorvo.setSalt(randomString(5));
                baseDoctorvo.setEnabled(1);
                baseDoctorvo.setLocked(0);
                baseDoctorvo.setChargeType("12");
                baseDoctorvo.setBirthday(IdCardUtil.getBirthdayForIdcard(baseDoctorvo.getIdcard()));
                baseDoctorvo.setPassword(MD5.md5Hex(baseDoctorvo.getIdcard().substring(12, 18) + "{" + baseDoctorvo.getSalt() + "}"));
                baseDoctorDO = baseDoctorDao.save(baseDoctorvo);
                if ("xm_zsyy_wx".equalsIgnoreCase(wxId)){
                }else if("xm_xzzx_wx".equalsIgnoreCase(wxId)){
                    String url = entranceUrl+"selectDoctorInfo?idCard="+baseDoctorDO.getIdcard();
                    String response = httpClientUtil.get(url,"GBK");
                    JSONObject object = JSONObject.parseObject(response);
                    String mappingCode = "";
                    if(object.getInteger("status")==200){
                        String obj = object.getString("obj");
                        JSONArray array = JSONArray.parseArray(obj);
                        if (array!=null&&array.size()!=0){
                            JSONObject jsonObjectDoctor = array.getJSONObject(0);
                            mappingCode = jsonObjectDoctor.getString("code");
                        }else {
                        }
                    }
                    DoctorMappingDO doctorMappingDO =doctorMappingDao.findByDoctor(baseDoctorDO.getId());
                    if (null==doctorMappingDO){
                        doctorMappingDO = new DoctorMappingDO();
                        doctorMappingDO.setMappingCode(mappingCode);
                        doctorMappingDO.setDoctor(baseDoctorDO.getId());
                        doctorMappingDO.setDoctorName(baseDoctorDO.getName());
                        doctorMappingDO.setOrgCode("350211A5010");
                        doctorMappingDO.setOrgName("厦门大学附属心血管病医院");
                        doctorMappingDO.setCreateTime(new Date());
                        doctorMappingDao.save(doctorMappingDO);
                    }
                }
            }
        } catch (IOException e) {
            result.put("msg", "convert doctor jsonObject to BaseDoctorDO failed," + e.getCause());
            result.put("response", ConstantUtils.FAIL);
            return result.toJSONString();
        } catch (Exception e) {
            result.put("msg", "convert doctor birth failed," + e.getCause());
            result.put("response", ConstantUtils.FAIL);
            return result.toJSONString();
        }
        baseDoctorDO.setSalt(randomString(5));
        baseDoctorDO.setEnabled(1);
        baseDoctorDO.setLocked(0);
        baseDoctorDO.setPassword(MD5.md5Hex(baseDoctorDO.getIdcard().substring(12, 18) + "{" + baseDoctorDO.getSalt() + "}"));
        this.save(baseDoctorDO);
        //组装医生角色关联关系,医生默认可以没有角色,没有机构/部门信息等
        if (!CollectionUtils.isEmpty(role)) {
            BaseDoctorRoleDO baseDoctorRoleDO = null;
            List<BaseDoctorRoleDO> baseDoctorRoleDOList = new ArrayList<>();
            List<BaseDoctorRoleDO> list = baseDoctorRoleDao.findByDoctorCode(baseDoctorDO.getId());
            if (list!=null&&list.size()>0){
                for (BaseDoctorRoleDO baseDoctorRoleDO2 : list){
                    baseDoctorRoleDao.delete(baseDoctorRoleDO2.getId());
                }
            }
            try {
                for (Object object : role) {
                    baseDoctorRoleDO = objectMapper.readValue(object.toString(), BaseDoctorRoleDO.class);
                    baseDoctorRoleDO.setDoctorCode(baseDoctorDO.getId());
                    baseDoctorRoleDOList.add(baseDoctorRoleDO);
                    BaseDoctorRoleDO baseDoctorRoleDO1 = baseDoctorRoleDao.findByDoctorCodeAndroleCode(baseDoctorDO.getId(),baseDoctorRoleDO.getRoleCode());
                    if (null==baseDoctorRoleDO1){
                        baseDoctorRoleDO.setDoctorCode(baseDoctorDO.getId());
                        baseDoctorRoleDao.save(baseDoctorRoleDO);
                    }
                }
            } catch (IOException e) {
                result.put("msg", "convert hospital jsonObject to baseDoctorHospitalDO failed," + e.getCause());
                result.put("response", ConstantUtils.FAIL);
                return result.toJSONString();
            }
            baseDoctorRoleService.batchInsert(baseDoctorRoleDOList);
        }
        // 组装医生任职机构及职业信息,医生默认可以没有角色,没有机构/部门信息等
@ -408,15 +496,32 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
            try {
                for (Object object : hospital) {
                    baseDoctorHospitalDO = objectMapper.readValue(object.toString(), BaseDoctorHospitalDO.class);
                    baseDoctorHospitalDO.setDoctorCode(baseDoctorDO.getId());
                    hospitalDOList.add(baseDoctorHospitalDO);
                    BaseDoctorHospitalDO baseDoctorHospitalDO1 =  baseDoctorHospitalDao.findByOrgCodeAndDeptCodeAndDoctorCodeOnly(baseDoctorHospitalDO.getOrgCode(),baseDoctorHospitalDO.getDeptCode(),baseDoctorDO.getId());
                    if (baseDoctorHospitalDO1 == null) {
                        baseDoctorHospitalDO.setDoctorCode(baseDoctorDO.getId());
                        baseDoctorHospitalDO.setDel("1");
                        baseDoctorHospitalDO.setCreateTime(new Date());
                        DictHospitalDeptDO dictHospitalDeptDO = dictHospitalDeptDao.findByCode(baseDoctorHospitalDO.getDeptCode());
                        if (null!=dictHospitalDeptDO){
                            baseDoctorHospitalDO.setDeptName(dictHospitalDeptDO.getName());
                        }
                        baseDoctorHospitalDao.save(baseDoctorHospitalDO);
                    }else {
                        try {
                            throw new Exception("添加失败,该医生以添加过相同的部门信息");
                        }catch (Exception e){
                            result.put("msg", "添加失败,该医生以添加过相同的部门信息");
                            result.put("response", ConstantUtils.FAIL);
                            return result.toJSONString();
                        }
                    }
                }
            } catch (IOException e) {
                result.put("msg", "convert hospital jsonObject to baseDoctorHospitalDO failed," + e.getCause());
                result.put("response", ConstantUtils.FAIL);
                return result.toJSONString();
            }
            baseDoctorHospitalService.batchInsert(hospitalDOList);
        }
        result.put("response", ConstantUtils.SUCCESS);
        result.put("msg", baseDoctorDO);
@ -458,6 +563,7 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
            baseDoctorDO = objectMapper.readValue(doctor.toJSONString(),BaseDoctorDO.class);
            BaseDoctorDO oldDoctor = baseDoctorDao.findOne(baseDoctorDO.getId());
            baseDoctorDO.setPassword(oldDoctor.getPassword());
            baseDoctorDO.setEnabled(baseDoctorDO.getDel().equalsIgnoreCase("1")?1:0);
        } catch (IOException e) {
            result.put("msg","convert doctor jsonObject to BaseDoctorDO failed," + e.getCause());
            result.put("response",ConstantUtils.FAIL);
@ -523,6 +629,7 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
        result.put("response",ConstantUtils.SUCCESS);
        result.put("msg",baseDoctorDO);
        return result.toJSONString();
    }
    /**
@ -545,6 +652,7 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
            return result.toJSONString();
        }
        baseDoctorDO.setDel(del);
        baseDoctorDO.setEnabled(Integer.parseInt(del));
        this.save(baseDoctorDO);
        result.put("response",ConstantUtils.SUCCESS);
        return result.toJSONString();
@ -754,7 +862,11 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
            baseDoctorDO.setIsFamous(one.getIsFamous());
            baseDoctorDO.setExpertise(one.getExpertise());
            baseDoctorDO.setIntroduce(one.getBrief());
            baseDoctorDO.setPassword(baseDoctorDO.getIdcard().substring(11,17));
            baseDoctorDO.setEnabled(1);
            baseDoctorDO.setLocked(0);
            String salt = UUID.randomUUID().toString().substring(0,5);
            String pw = one.getIdcard().substring(one.getIdcard().length()-6,one.getIdcard().length());
            baseDoctorDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
            if(!StringUtils.isEmpty(one.getJobTitleName())){
                String[] job = one.getJobTitleName().split(",");
                String jobCode = job[0];

+ 32 - 6
svr/svr-base/src/main/java/com/yihu/jw/base/service/doctor/excelImport/BaseDoctorExcelDOReader.java

@ -2,11 +2,14 @@ package com.yihu.jw.base.service.doctor.excelImport;
import com.yihu.jw.base.dao.dict.DictJobTitleDao;
import com.yihu.jw.base.dao.doctor.BaseDoctorRoleDictDao;
import com.yihu.jw.base.dao.doctor.BaseDoctorRoleInfoDao;
import com.yihu.jw.base.endpoint.common.excel.AExcelReader;
import com.yihu.jw.dict.dao.DictDoctorDutyDao;
import com.yihu.jw.dict.dao.DictHospitalDeptDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorRoleDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.org.dao.BaseOrgDao;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Sheet;
@ -16,6 +19,7 @@ import org.springframework.stereotype.Component;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
/**
 * 医生信息列表-excel解析类
@ -33,6 +37,10 @@ public class BaseDoctorExcelDOReader extends AExcelReader {
    private DictJobTitleDao jobTitleDao;
    @Autowired
    private BaseDoctorRoleInfoDao roleInfoDao;
    @Autowired
    private BaseDoctorRoleDictDao baseDoctorRoleDictDao;
    @Autowired
    private BaseDoctorDao baseDoctorDao;
    @Override
    public void read(Workbook rwb) throws Exception {
@ -51,6 +59,8 @@ public class BaseDoctorExcelDOReader extends AExcelReader {
            getRepeat().put("isFamous", new HashSet<>());
            getRepeat().put("expertise", new HashSet<>());
            getRepeat().put("brief", new HashSet<>());
            errorLs.clear();
            correctLs.clear();
            while (sheets.hasNext()){
                Sheet sheet = sheets.next();
                if ((rows = sheet.getLastRowNum()) == 0) {
@ -71,7 +81,7 @@ public class BaseDoctorExcelDOReader extends AExcelReader {
                    baseDoctorExcelDO.setBrief(replaceBlank(getCellCont(sheet, i, 10)));
                    baseDoctorExcelDO.setExcelSeq(i);
                    int rs = baseDoctorExcelDO.validate(repeat);
                    if (rs == 0||validate(baseDoctorExcelDO)== 0) {
                    if (validate(baseDoctorExcelDO)== 0||rs == 0) {
                        errorLs.add(baseDoctorExcelDO);
                    } else if (rs == 1) {
                        correctLs.add(baseDoctorExcelDO);
@ -91,7 +101,23 @@ public class BaseDoctorExcelDOReader extends AExcelReader {
    }
    public int validate(BaseDoctorExcelDO baseDoctorExcelDO) {
        int rs = 1;
        if(StringUtils.isNotEmpty(baseDoctorExcelDO.getHospitalInfo())){
        if (StringUtils.isNoneBlank(baseDoctorExcelDO.getIdcard())){
            List<BaseDoctorDO> baseDoctorDO = baseDoctorDao.findByIdcard(baseDoctorExcelDO.getIdcard());
            System.out.println("当前导入数据的身份证号:"+baseDoctorExcelDO.getIdcard());
            if (baseDoctorDO!=null&&baseDoctorDO.size()>0){
                System.out.println("进入身份验证有重复数据"+baseDoctorDO.get(0).getIdcard());
                return 0;
            }
        }
        if (StringUtils.isNoneBlank(baseDoctorExcelDO.getMobile())){
            System.out.println("当前导入数据的电话号:"+baseDoctorExcelDO.getMobile());
            List<BaseDoctorDO> baseDoctorDO = baseDoctorDao.findByMobile(baseDoctorExcelDO.getMobile());
            if (baseDoctorDO!=null&&baseDoctorDO.size()>0){
                System.out.println("进入电话验证有重复数据"+baseDoctorDO.get(0).getMobile());
                return 0;
            }
        }
        if(StringUtils.isNoneBlank(baseDoctorExcelDO.getHospitalInfo())){
            String[] hospitals = baseDoctorExcelDO.getHospitalInfo().split(";");
            for(String hospital:hospitals){
                String[] element = hospital.split("/");
@ -112,20 +138,20 @@ public class BaseDoctorExcelDOReader extends AExcelReader {
                }
            }
        }
        if(StringUtils.isNotEmpty(baseDoctorExcelDO.getRoleInfo())){
        if(StringUtils.isNoneBlank(baseDoctorExcelDO.getRoleInfo())){
            String[] roles = baseDoctorExcelDO.getRoleInfo().split(";");
            for(String role:roles){
                String[] element = role.split(",");
                String roleCode = element[0];
                if(!roleInfoDao.existsByCode(roleCode)){
                if(!baseDoctorRoleDictDao.existsByCode(roleCode)){
                    return 0;
                }
            }
        }
        if(StringUtils.isEmpty(baseDoctorExcelDO.getIdcard())){
        if(StringUtils.isBlank(baseDoctorExcelDO.getIdcard())){
            return 0;
        }
        if(StringUtils.isEmpty(baseDoctorExcelDO.getMobile())){
        if(StringUtils.isBlank(baseDoctorExcelDO.getMobile())){
            return 0;
        }
        return rs;

+ 2 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/org/BaseOrgService.java

@ -134,6 +134,8 @@ public class BaseOrgService extends BaseJpaService<BaseOrgDO, BaseOrgDao> {
                        " province_name AS \"provinceName\"," +
                        " city_name AS \"cityName\" ," +
                        "town_name AS \"townName\"," +
                        " photo AS \"photo\"," +
                        " brief AS \"brief\"," +
                        "address AS \"address\"\n" +
                        "FROM\n" +
                        "\tbase_org\n" +

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

@ -809,4 +809,17 @@ public class PrescriptionStatusUpdateService {
        }
        return msgReurn;
    }
    public String finishOldConsult(String consult){
        int resutl = imService.finish(consult,"admin",2);
        //医生未回复可以退费
        try {
            businessOrderService.consultRefund(consult,wechatId);
        }catch (Exception e){
            e.printStackTrace();
            return  "failed";
        }
        return "success";
    }
}

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

@ -99,11 +99,6 @@ public class TimeoutOverDueService {
                            String outPatientId = wlyyOutpatientDO.getId();
                            String consultCode ="";
                            try {
                                consultCode = imService.getConsultCodeByOutpatientId(outPatientId);
                                logger.info("consultCode"+consultCode);
                                if(StringUtils.isNoneBlank(consultCode)) {
                                    imService.cancelRevisit(consultCode, "admin", 2);
                                }
                                    /*//医生未回复可以退费
                                    businessOrderService.consultRefund(consultCode,wechatId);
                                    wlyyOutpatientDO.setDoctorCancelRemark(cancelRemark);
@ -188,7 +183,11 @@ public class TimeoutOverDueService {
                                }
                                outpatientDao.save(wlyyOutpatientDO);
                                logger.info(wlyyOutpatientDO.getId()+"的门诊记录设置为取消");
                                consultCode = imService.getConsultCodeByOutpatientId(outPatientId);
                                logger.info("consultCode"+consultCode);
                                if(StringUtils.isNoneBlank(consultCode)) {
                                    imService.cancelRevisit(consultCode, "admin", 2);
                                }
                                }catch(Exception e)  {
                                    e.printStackTrace();
                                    logger.info("自动结束咨询报错 consultCode: "+consultCode);

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

@ -16,6 +16,7 @@ import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.service.channel.PrescriptionStatusUpdateService;
import com.yihu.jw.service.quota.JobService;
import com.yihu.jw.util.*;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.web.BaseController;
import com.yihu.jw.wechat.service.WxTemplateService;
import io.swagger.annotations.Api;
@ -28,6 +29,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
@ -599,7 +603,14 @@ public class JobController extends BaseController {
                    break; //可选
                case "2.14" :
                    //语句
                    internetCommonService.upNsInvokeTotal(startDate,endDate);
                    long days = getDaySub(startDate,endDate);
                    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
                    for (int i = 0;i<days;i++){
                        endDate = format.format(com.yihu.jw.util.date.DateUtil.getPreDays(format.parse(startDate),1));
                        internetCommonService.upNsInvokeTotal(startDate,endDate);
                        startDate = endDate;
                    }
                    break; //可选
                default : //可选
                    //语句
@ -611,6 +622,29 @@ public class JobController extends BaseController {
        }
    }
    public static void main(String[] args) throws Exception {
        String startDate = "2020-08-19";
        String endDate = "2020-12-01";
        long days = getDaySub(startDate,endDate);
        System.out.println(days);
    }
    public static long getDaySub(String beginDateStr,String endDateStr) throws Exception {
        long day = 0;
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        Date beginDate;
        Date endDate;
        try {
            beginDate = format.parse(beginDateStr);
            endDate = format.parse(endDateStr);
            day = (endDate.getTime()-beginDate.getTime())/(24*60*60*1000);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        System.out.println("day:"+day);
        return day;
    }
    @RequestMapping(value = "/testImg", method = RequestMethod.GET)
    @ApiOperation("测试图片")
@ -667,4 +701,12 @@ public class JobController extends BaseController {
        return prescriptionStatusUpdateService.cancelAllandSendMessage(day);
    }
    @RequestMapping(value = "finishOldConsult", method = RequestMethod.GET)
    @ApiOperation("取消旧的咨询")
    public String finishOldConsult(String consult){
        return success(prescriptionStatusUpdateService.finishOldConsult(consult));
    }
}

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

@ -125,7 +125,7 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
			@ApiParam(name = "doctor", value = "医生CODE",defaultValue = "1cd15ffe6b3a11e69f7c005056850d66")
			@RequestParam(value = "doctor",required = true) String doctor,
			@ApiParam(name = "type", value = "图文诊室:1、视频:2")
			@RequestParam(value = "type",required = true) Integer type,
			@RequestParam(value = "type",required = false) Integer type,
			@ApiParam(name = "query_status", value = "0:图文复诊候诊 1:图文复诊抢单列表")
			@RequestParam(value = "",required = false) Integer query_status,
			@ApiParam(name = "dept", value = "部门")
@ -200,22 +200,40 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
										  @ApiParam(name = "source", value = "来源")
											  @RequestParam(value = "source", required = false) String source)throws Exception{
			ConsultTeamDo consult = new ConsultTeamDo();
			if(2 == type){
				consult.setType(16);//视频复诊
				if ("xm_ykyy_wx".equalsIgnoreCase(wxId)){
					prescriptionService.sendWxTemplateMsg(wxId,outpatientCode,null,"16","outpatientMsgRemind","");
			WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientCode);
			if (null!=outpatientDO){
                if(!outpatientDO.getDoctor().equalsIgnoreCase(doctorCode)){
                    return failed("当前患者已选择其他医生进行咨询或复诊。");
                }
				if ("1".equalsIgnoreCase(outpatientDO.getOutpatientType())){
					if("2".equalsIgnoreCase(outpatientDO.getType())){
						consult.setType(16);//视频复诊
						if ("xm_ykyy_wx".equalsIgnoreCase(wxId)){
							prescriptionService.sendWxTemplateMsg(wxId,outpatientCode,null,"16","outpatientMsgRemind","");
						}
					}else{
						consult.setType(9);//图文复诊
					}
					//咨询类型(1、图文;2、视频,3、图文+视频)
					consult.setHealthindexType(Integer.valueOf(StringUtils.isNotBlank(outpatientDO.getType())?outpatientDO.getType():"0"));
				}else if ("3".equalsIgnoreCase(outpatientDO.getOutpatientType())){
					if("2".equalsIgnoreCase(outpatientDO.getType())){
						consult.setType(17);//视频咨询
						if ("xm_ykyy_wx".equalsIgnoreCase(wxId)){
							prescriptionService.sendWxTemplateMsg(wxId,outpatientCode,null,"17","outpatientMsgRemind","");
						}
					}else if ("1".equalsIgnoreCase(outpatientDO.getType())){
						consult.setType(1);//图文咨询
					}
				}
			}else{
				consult.setType(9);//图文复诊
			}
			WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientCode);
			if (outpatientDO.getStatus().equalsIgnoreCase("-1")){
				return failed("患者已取消!");
			}
			
			
			//咨询类型(1、图文;2、视频,3、图文+视频)
			consult.setHealthindexType(type);
//			int res = 0;
		
			JSONObject result = new JSONObject();
@ -226,28 +244,35 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
					String rsCode = "";
					String mes = "";
					if("xm_xzzx_wx".equals(wxId)){ //心脏中心挂号
						if (!outpatientDO.getOutpatientType().equalsIgnoreCase("2")){
						if (!outpatientDO.getOutpatientType().equalsIgnoreCase("2")&&!outpatientDO.getOutpatientType().equalsIgnoreCase("3")){
							JSONObject res = xzyyPrescriptionService.registerOutPatient(outpatientCode,doctorCode);
							rsCode = res.getString("@RESULT");
							mes = res.getString("@MSG");
						}else {
						}else  {
							rsCode="0";
							mes="已挂号";
						}
						if (type==2){
							prescriptionService.sendWxTemplateMsg(wxId,outpatientCode,null,"16","outpatientMsgRemind","");
						if ("1".equalsIgnoreCase(outpatientDO.getOutpatientType())){
							if ("2".equalsIgnoreCase(outpatientDO.getType())){
								prescriptionService.sendWxTemplateMsg(wxId,outpatientCode,null,"16","outpatientMsgRemind","");
							}
						}
						if ("3".equalsIgnoreCase(outpatientDO.getOutpatientType())){
							if ("2".equalsIgnoreCase(outpatientDO.getType())){
								prescriptionService.sendWxTemplateMsg(wxId,outpatientCode,null,"17","outpatientMsgRemind","");
							}
						}
					}else {
						if (demoFlag.equalsIgnoreCase("true")){
							rsCode="0";
							mes="已挂号";
						}else {
							if (!outpatientDO.getOutpatientType().equalsIgnoreCase("2")){
							if (!outpatientDO.getOutpatientType().equalsIgnoreCase("2")&&!outpatientDO.getOutpatientType().equalsIgnoreCase("3")){
								net.sf.json.JSONObject res = prescriptionService.registerOutPatient(outpatientCode,doctorCode);
								rsCode = (String)res.get("@RESULT");
								mes = (String)res.get("@MSG");
							}else {
							}else  {
								rsCode="0";
								mes="已挂号";
							}
@ -337,21 +362,34 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
							  @ApiParam(name = "source", value = "来源")
								  @RequestParam(value = "source", required = false) String source)throws Exception{
		ConsultTeamDo consult = new ConsultTeamDo();
		if(2 == type){
			consult.setType(16);//视频复诊
			/*if ("xm_ykyy_wx".equalsIgnoreCase(wxId)){
				prescriptionService.sendWxTemplateMsg(wxId,outpatientCode,null,"16","outpatientMsgRemind","");
			}*/
		}else{
			consult.setType(9);//图文复诊
		WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientCode);
		if (null!=outpatientDO){
		    if(!outpatientDO.getDoctor().equalsIgnoreCase(doctorCode)){
                return failed("当前患者已选择其他医生进行咨询或复诊。");
            }
			if ("1".equalsIgnoreCase(outpatientDO.getOutpatientType())){
				if("2".equalsIgnoreCase(outpatientDO.getType())){
					consult.setType(16);//视频复诊
					if ("xm_ykyy_wx".equalsIgnoreCase(wxId)){
						prescriptionService.sendWxTemplateMsg(wxId,outpatientCode,null,"16","outpatientMsgRemind","");
					}
				}else{
					consult.setType(9);//图文复诊
				}
				//咨询类型(1、图文;2、视频,3、图文+视频)
				consult.setHealthindexType(Integer.valueOf(StringUtils.isNotBlank(outpatientDO.getType())?outpatientDO.getType():"0"));
			}else if ("3".equalsIgnoreCase(outpatientDO.getOutpatientType())){
				if("2".equalsIgnoreCase(outpatientDO.getType())){
					consult.setType(17);//视频咨询
					if ("xm_ykyy_wx".equalsIgnoreCase(wxId)){
						prescriptionService.sendWxTemplateMsg(wxId,outpatientCode,null,"17","outpatientMsgRemind","");
					}
				}else if ("1".equalsIgnoreCase(outpatientDO.getType())){
					consult.setType(1);//图文咨询
				}
			}
		}
		//咨询类型(1、图文;2、视频,3、图文+视频)
		consult.setHealthindexType(type);
//			int res = 0;
		WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientCode);
		if (outpatientDO.getStatus().equalsIgnoreCase("-1")){
			return failed("患者已取消!");
		}
@ -491,16 +529,21 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
						cardNo = outpatientDO.getCardNo();
					}
					String date=DateUtil.dateToStr(outpatientDO.getRegisterDate(), "yyyyMMddHHmmss");
					net.sf.json.JSONObject object =entranceService.BS15054(patientMappingDO.getMappingCode(),outpatientDO.getRealOrder(),false);
					net.sf.json.JSONObject res = object.getJSONObject("resquest");
					logger.info("获取待结算数据 res: " + res.toString());
					String rsCode = res.getString("@RESULT");
					String free= 0+"";
					if ("0".equals(rsCode)) {
						if (res.getString("@settle_flag").equalsIgnoreCase("N")){
							free = res.getString("@total_charge");
                    String free= 0+"";
                    if (StringUtils.isNoneBlank(outpatientDO.getRealOrder())){
                        net.sf.json.JSONObject object =entranceService.BS15054(patientMappingDO.getMappingCode(),outpatientDO.getRealOrder(),false);
                        if(object!=null){
							net.sf.json.JSONObject res = object.getJSONObject("resquest");
							String rsCode = res.getString("@RESULT");
							if ("0".equals(rsCode)) {
								if (res.getString("@settle_flag").equalsIgnoreCase("N")){
									free = res.getString("@total_charge");
								}
							}
							logger.info("获取待结算数据 res: " + res.toString());
						}
					}
                    }
					if (!free.equalsIgnoreCase("0")){
						ylzPayService.msgPush("01", cardNo, "01", patientDO.getMobile(), "00", userNo, userName, idcard, outpatientDO.getXtgzh(), outpatientDO.getDeptName(), outpatientDO.getDoctorName(), date, free, "1");
					}
@ -541,7 +584,8 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
			@ApiParam(name = "doctor", value = "医生CODE")
			@RequestParam(value = "doctor",required = false) String doctor,
			@ApiParam(name = "general_doctor", value = "全科医生CODE")
			@RequestParam(value = "general_doctor",required = false) String general_doctor)throws Exception{
			@RequestParam(value = "general_doctor",required = false) String general_doctor
			)throws Exception{
		return success("请求成功",prescriptionService.getVideoPrescriptionByDoctor(doctor,general_doctor,wxId));
	}
	
@ -549,8 +593,13 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
	@ApiOperation(value = "获取等待就诊的视频复诊/协同门诊", notes = "获取等待就诊的视频复诊/协同门诊")
	public ListEnvelop getWaitingForVisitVideoPrescriptionByDoctor(
			@ApiParam(name = "doctor", value = "医生CODE")
			@RequestParam(value = "doctor",required = true) String doctor)throws Exception{
		return success("请求成功",prescriptionService.getWaitingForVisitVideoPrescriptionByDoctor(doctor,wxId));
			@RequestParam(value = "doctor",required = true) String doctor,
			@ApiParam(name = "type", value = "1在线复诊2协同3专家咨询")
			@RequestParam(value = "type",required = false) String type,
            @ApiParam(name = "keyWord", value = "病人姓名")
            @RequestParam(value = "keyWord",required = false) String keyWord
            )throws Exception{
		return success("请求成功",prescriptionService.getWaitingForVisitVideoPrescriptionByDoctor(doctor,wxId,type,keyWord));
	}
	
	@PostMapping(value = BaseHospitalRequestMapping.DodtorIM.pickVideoPrescripitonWaitingPeople)
@ -562,7 +611,14 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
			@RequestParam(value = "doctor",required = true) String doctor)throws Exception{
		prescriptionService.pickVideoPrescripitonWaitingPeople(outpatientCode,doctor);
		WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findOne(outpatientCode);
		if (StringUtils.isNoneBlank(wlyyOutpatientDO.getType())){
			if (wlyyOutpatientDO.getType().equalsIgnoreCase("2")&&wlyyOutpatientDO.getOutpatientType().equalsIgnoreCase("3")){
				prescriptionService.sendWxTemplateMsg(wxId, wlyyOutpatientDO.getId(),null, "17", "videoOrderRemind", "");
			}else if (wlyyOutpatientDO.getType().equalsIgnoreCase("2")&&wlyyOutpatientDO.getOutpatientType().equalsIgnoreCase("1")){
				prescriptionService.sendWxTemplateMsg(wxId, wlyyOutpatientDO.getId(),null, "16", "videoOrderRemind", "");
			}
		}
		//发送外层SOCKET消息 在线复诊
		if("2".equals(wlyyOutpatientDO.getOutpatientType())){
			System.out.println("发送外层SOCKET消息:协同门诊医生抢单之后,通知全科医生修改状态");
@ -575,8 +631,9 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
			JSONObject object = new JSONObject();
			object.put("socket_sms_type",6);
			object.put("relation_code",wlyyOutpatientDO.getId());
			imService.sendWaiSocketMessage(wlyyOutpatientDO.getDoctor(),wlyyOutpatientDO.getPatient(),object.toString(),"1");
			imService.sendWaiSocketMessage(wlyyOutpatientDO.getDoctor(),wlyyOutpatientDO.getConsumer(),object.toString(),"1");
		}
		return success("请求成功");
	}
	
@ -641,7 +698,56 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
		result.put("list",data);
		return success(result);
	}
	
	@GetMapping(value = BaseHospitalRequestMapping.DodtorIM.records2)
	@ApiOperation(value = "医生咨询记录查询")
	public Envelop records2(
			@ApiParam(name = "doctor", value = "医生id")
			@RequestParam(value = "doctor",required = false) String doctor,
			@ApiParam(name = "title", value = "咨询标题关键字")
			@RequestParam(value = "title",required = false) String title,
			@ApiParam(name = "id", value = "咨询ID")
			@RequestParam(value = "id",required = false) String id,
			@ApiParam(name = "type", value = "咨询类型")
			@RequestParam(value = "type",required = true) String type,
			@ApiParam(name = "status", value = "咨询状态:0全部,1候诊中,2就诊中,3结束")
			@RequestParam(value = "status",required = true) Integer status,
			@ApiParam(name = "start_time", value = "开始时间 YYYY-MM-DD HH:MM:SS")
			@RequestParam(value = "start_time",required = false) String start_time,
			@ApiParam(name = "end_time", value = "结束时间 YYYY-MM-DD HH:MM:SS")
			@RequestParam(value = "end_time",required = false) String end_time,
			@ApiParam(name = "page", value = "第几页")
			@RequestParam(value = "page",required = false) int page,
			@ApiParam(name = "pagesize", value = "分页大小")
			@RequestParam(value = "pagesize",required = false) int pagesize
	)throws Exception{
		List<Map<String,Object>>  data = imService.findConsultRecordByDoctorNew(doctor, id,type,status, page,pagesize, title,start_time,end_time);
		if (data != null) {
			for(Map<String,Object> consult :data){
				//如果是协同门诊,多返回全科医生的详细信息
				if(12 == Integer.parseInt(consult.get("type").toString()) && StringUtils.isNoneBlank((String)consult.get("generalDoctor"))){
					BaseDoctorDO baseDoctorDO = baseDoctorDao.findById((String)consult.get("generalDoctor"));
					List<BaseDoctorHospitalDO> baseDoctorHospitalDOList = baseDoctorHospitalDao.findByDoctorCode((String)consult.get("generalDoctor"));
					if(baseDoctorDO!=null){
						consult.put("generalDoctorName", baseDoctorDO.getName());
					}
					if (baseDoctorHospitalDOList!=null&&baseDoctorHospitalDOList.size()!=0){
						BaseDoctorHospitalDO baseDoctorHospitalDO = baseDoctorHospitalDOList.get(0);
						consult.put("generalOrgName",baseDoctorHospitalDO.getOrgName());
						consult.put("generalDeptName",baseDoctorHospitalDO.getDeptName());
					}
				}
			}
		}
		Long total = imService.countConsultRecordByDoctor2(doctor, id,type,status,title,start_time,end_time);
		JSONObject result = new JSONObject();
		result.put("total",total);
		result.put("list",data);
		return success(result);
	}
	
	@GetMapping(value = BaseHospitalRequestMapping.DodtorIM.testSendPrescriptionIM)
	@ApiOperation(value = "测试发送处方消息", notes = "测试发送处方消息")
@ -789,6 +895,15 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
		result.put("zjCount",imService.doctorConsults(doctor));//专家咨询数量
		return success("请求成功",result);
	}
	@GetMapping(value = BaseHospitalRequestMapping.DodtorIM.doctorSpecialistConsultCountNew2)
	@ApiOperation(value = "医生端:进行中的专家咨询数量", notes = "医生端:进行中的专家咨询数量")
	public Envelop doctorSpecialistConsultCountNew2(@ApiParam(name = "doctor", value = "医生CODE")
												   @RequestParam(value = "doctor",required = true) String doctor){
		//专家咨询
		JSONObject result = new JSONObject();
		result.put("zjCount",imService.doctorConsultsNew(doctor));//专家咨询数量
		return success("请求成功",result);
	}
	
	@GetMapping(value = BaseHospitalRequestMapping.DodtorIM.doctorReviewConsultCount)
	@ApiOperation(value = "医生端:图文复诊、视频复诊咨询数量、协同门诊候诊数量", notes = "医生端:图文复诊、视频复诊咨询数量、协同门诊候诊数量")
@ -799,6 +914,9 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
		result.put("imgCount",prescriptionService.getWaitVideoCount(doctor,"1","1",wxId));//图文复诊数量
		result.put("videoCount",prescriptionService.getWaitVideoCount(doctor,"2","1",wxId));//视频复诊数量
		result.put("xtCount",prescriptionService.getWaitVideoCount(doctor,"","2",wxId));//协同门诊候诊数量
		result.put("imgConsultCount",prescriptionService.getWaitVideoCount(doctor,"1","3",wxId));//图文咨询数量
		result.put("videoConsultCount",prescriptionService.getWaitVideoCount(doctor,"2","3",wxId));//视频咨询数量
		result.put("homeConsultCount",prescriptionService.getWaitVideoCount(doctor,"3","3",wxId));//家医咨询数量
		logger.info("action:doctorReviewConsultCount--end:"+DateUtil.dateToStrLong(new Date()));
		return success("请求成功",result);
	}

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

@ -240,6 +240,21 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
		String consultCode = imService.getUnfinishedConsult(patient, doctor);
		return success("请求成功",consultCode);
	}
	@GetMapping(value = BaseHospitalRequestMapping.PatientIM.isExistsUnfinishedOutpatient)
	@ApiOperation(value = "查询居民与某个医生是否存在未结束的专家咨询")
	public Envelop isExistsUnfinishedOutpatient(
			@ApiParam(name = "doctor", value = "医生CODE")
			@RequestParam(value = "doctor",required = true) String doctor,
			@ApiParam(name = "patient", value = "居民CODE")
			@RequestParam(value = "patient",required = true) String patient)throws Exception {
		if(StringUtils.isEmpty(patient)){
			patient= getUID();
		}
		String consultCode = imService.getUnfinishedConsult2(patient, doctor);
		return success("请求成功",consultCode);
	}
	
	@GetMapping(value = BaseHospitalRequestMapping.PatientIM.participants)
	@ApiOperation(value = "获取会话成员")
@ -661,16 +676,21 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
				if (org.apache.commons.lang3.StringUtils.isNoneBlank(outpatientDO.getCardNo())) {
					cardNo = outpatientDO.getCardNo();
				}
				String free = 0+"";
				String date=DateUtil.dateToStr(outpatientDO.getRegisterDate(), "yyyyMMddHHmmss");
				net.sf.json.JSONObject object =entranceService.BS15054(patientMappingDO.getMappingCode(),outpatientDO.getRealOrder(),false);
				net.sf.json.JSONObject res = object.getJSONObject("resquest");
				logger.info("获取待结算数据 res: " + res.toString());
				String rsCode = res.getString("@RESULT");
				String free= 0+"";
				if ("0".equals(rsCode)) {
					if (res.getString("@settle_flag").equalsIgnoreCase("N")){
						free = res.getString("@total_charge");
				if (org.apache.commons.lang3.StringUtils.isNoneBlank(outpatientDO.getRealOrder())){
					net.sf.json.JSONObject object =entranceService.BS15054(patientMappingDO.getMappingCode(),outpatientDO.getRealOrder(),false);
					if(object!=null){
						net.sf.json.JSONObject res = object.getJSONObject("resquest");
						String rsCode = res.getString("@RESULT");
						if ("0".equals(rsCode)) {
							if (res.getString("@settle_flag").equalsIgnoreCase("N")){
								free = res.getString("@total_charge");
							}
						}
						logger.info("获取待结算数据 res: " + res.toString());
					}
				}
				if (!free.equalsIgnoreCase("0")){
					ylzPayService.msgPush("01", cardNo, "01", patientDO.getMobile(), "00", userNo, userName, idcard, outpatientDO.getXtgzh(), outpatientDO.getDeptName(), outpatientDO.getDoctorName(), date, free, "1");

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

@ -10,6 +10,7 @@ import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import com.yihu.jw.entity.base.dict.DictJobTitleDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.base.wx.WxWechatDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleUserDO;
@ -23,10 +24,7 @@ import com.yihu.jw.hospital.dao.consult.KnowledgeArticleUserDao;
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
import com.yihu.jw.hospital.httplog.service.WlyyHttpLogService;
import com.yihu.jw.hospital.prescription.dao.*;
import com.yihu.jw.hospital.prescription.service.PayInfoNoticeService;
import com.yihu.jw.hospital.prescription.service.PrescriptionExpressageService;
import com.yihu.jw.hospital.prescription.service.PrescriptionService;
import com.yihu.jw.hospital.prescription.service.WorkTimeService;
import com.yihu.jw.hospital.prescription.service.*;
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService;
import com.yihu.jw.hospital.service.SystemMessage.HospitalSystemMessageService;
@ -49,6 +47,7 @@ import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.rm.patient.PatientRequestMapping;
import com.yihu.jw.util.common.XMLUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import com.yihu.jw.wechat.dao.WechatDao;
import com.yihu.jw.wechat.service.WechatInfoService;
import com.ylzinfo.onepay.sdk.OnepayClient;
@ -64,6 +63,7 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import net.sf.json.JSONArray;
import org.apache.axis.utils.StringUtils;
import org.apache.commons.collections.map.HashedMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -117,6 +117,8 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
    private WechatInfoService wechatInfoService;
    @Value("${wechat.id}")
    private String wxId;
    @Value("${pay.flag}")
    private boolean payFlag;
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
@ -164,6 +166,11 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
    private HospitalSystemMessageService hospitalSystemMessageService;
    @Autowired
    private StatisticsEsService statisticsEsService;
    @Autowired
    private BasePatientWechatDao patientWechatDao;
    @Autowired
    private YkyyPrescriptionService ykyyPrescriptionService;
@ -385,7 +392,7 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
     */
    @RequestMapping(value = "/getOpenidByCode", method = {RequestMethod.POST, RequestMethod.GET})
    @ResponseBody
    public Envelop getOpenidByCode(String code) throws Exception {
    public Envelop getOpenidByCode(String code,String patientId) throws Exception {
        //通过redis获取openid, 获取不到,则调用微信接口去取
        String key = wxId+":code";
        String openid = redisTemplate.opsForValue().get(key);
@ -393,6 +400,20 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
            return success(PatientRequestMapping.Wechat.api_success,openid);
        }
        openid = wechatInfoService.getOpenidByCode(code, wxId);
        List<BasePatientWechatDo> patientWechatDoList =  patientWechatDao.findByWechatIdAndPatientId(wxId,patientId);
        if (patientWechatDoList!=null&&patientWechatDoList.size()!=0){
            BasePatientWechatDo patientWechatDo = patientWechatDoList.get(0);
            patientWechatDo.setOpenid(openid);
            patientWechatDao.save(patientWechatDo);
        }else {
            BasePatientWechatDo patientWechatDo = new BasePatientWechatDo();
            patientWechatDo.setCreateTime(new Date());
            patientWechatDo.setOpenid(openid);
            patientWechatDo.setWechatId(wxId);
            patientWechatDo.setPatientId(patientId);
            patientWechatDo.setSaasId("dev");
            patientWechatDao.save(patientWechatDo);
        }
        redisTemplate.opsForValue().set(key,openid);
        redisTemplate.expire(key,10, TimeUnit.SECONDS);
        return success(PatientRequestMapping.Wechat.api_success,openid);
@ -409,7 +430,7 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
    @ResponseBody
    @ApiOperation("微信支付结果通知")
    @RequestMapping(value = "/notify", method = {RequestMethod.GET, RequestMethod.POST})
    public Map<String, String> wxPayNotify(HttpServletRequest request, HttpServletResponse response) throws Exception {
    public String wxPayNotify(HttpServletRequest request, HttpServletResponse response) throws Exception {
        String result = "";
        String inputLine;
        while ((inputLine = request.getReader().readLine()) != null) {
@ -418,11 +439,12 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
        request.getReader().close();
        //im处方发消息
        Map<String,Object> wxrs =  XMLUtil.xmltoMap(result);
        Map<String, String> map = new HashedMap();
        if("SUCCESS".equals(wxrs.get("return_code").toString())){
            // 我方 订单号+时间差
            String seqNo = wxrs.get("out_trade_no")+"";
            BusinessOrderDO businessOrderDO = businessOrderDao.selectByOrderNo(seqNo);
            if (businessOrderDO.getStatus()!=1){
            if (businessOrderDO.getStatus()!=1&&businessOrderDO.getStatus()!=9){
                if (businessOrderDO!=null&&businessOrderDO.getOrderCategory().equalsIgnoreCase("4")){
                    WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findOne(businessOrderDO.getRelationCode());
                    JSONObject object = (JSONObject) JSONObject.toJSON(wlyyPrescriptionDO);
@ -440,10 +462,12 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
                    prescriptionVO.setPayStatus(1);
                    imService.pushPrescriptionImMessage(prescriptionVO);
                }
                map= businessOrderService.getWxPayResultNotify(result);
            }
        }
        Map<String, String> map = businessOrderService.getWxPayResultNotify(result);
        return map;
        return XMLUtil.map2xml(map);
    }
@ -1141,5 +1165,52 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
        String object = prescriptionService.synYktZxPrice(idcard,price,type,flag);
        return success(object);
    }
    @GetMapping(value = BaseHospitalRequestMapping.PatientNoLogin.findHospitalConsultInfo)
    @ApiOperation(value = "根据疾病查询咨询数量", notes = "根据疾病查询咨询数量")
    public ListEnvelop findHospitalConsultInfo(
                                                  @ApiParam(name = "startTime", value = "开始时间 yyyy-MM-dd hh:mm:ss")
                                                  @RequestParam(value = "startTime", required = false)String startTime,
                                              @ApiParam(name = "endTime", value = "结束时间 yyyy-MM-dd hh:mm:ss")
                                                  @RequestParam(value = "endTime", required = false)String endTime) throws Exception{
        return success(prescriptionService.findOutpatientAndPatient(startTime,endTime));
    }
    /**
     * 获取微信支付参数
     *
     * @param relationCode 关联code
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "selectOrderByRelationCode", method = RequestMethod.POST)
    @ApiOperation("获取微信支付参数")
    public ObjEnvelop selectOrderByRelationCode(
            @ApiParam(name = "relationCode", value = "relationCode", required = true)
            @RequestParam(required = true)String relationCode,
            @ApiParam(name = "tradeType", value = "tradeType", required = false)
            @RequestParam(required = false)String tradeType,
            @ApiParam(name = "appletCode", value = "appletCode", required = false)
            @RequestParam(value = "appletCode",required = false)String appletCode) throws Exception {
        try {
            return ObjEnvelop.getSuccess("ok",businessOrderService.selectOrderByRelationCode(relationCode,tradeType,wxId,payFlag,appletCode));
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.prescriptionPay)
    @ApiOperation(value = "处方支付", notes = "处方支付")
    public ObjEnvelop findPatientCard(@ApiParam(name = "code", value = "处方code")
                                      @RequestParam(value = "code", required = true)String code,
                                      @ApiParam(name = "price", value = "支付费用")
                                      @RequestParam(value = "price", required = false)Double price,
                                      @ApiParam(name = "tradeType", value = "支付方式")
                                      @RequestParam(value = "tradeType", required = false)String tradeType)throws Exception {
        try {
            return success("ok",ykyyPrescriptionService.savePrescriptionOrder(code,price,tradeType,wxId));
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
    }
}

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

@ -210,11 +210,13 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                                                                              @RequestParam(value = "startTime", required = false)String startTime,
                                                                              @ApiParam(name = "endTime", value = "结束时间,yyyy-MM-dd’")
                                                                              @RequestParam(value = "endTime", required = false)String endTime,
                                                                              @ApiParam(name = "outpatientType", value = "1复诊2协同3咨询")
                                                                                  @RequestParam(value = "outpatientType", required = false)String outpatientType,
                                                                              @ApiParam(name = "page", value = "第几页,1开始’")
                                                                              @RequestParam(value = "page", required = false)Integer page,
                                                                              @ApiParam(name = "size", value = "每页大小")
                                                                              @RequestParam(value = "size", required = true) Integer size) {
        return prescriptionService.findReOutpatientList(patient,status,startTime,endTime,page,size);
        return prescriptionService.findReOutpatientList(patient,status,startTime,endTime,outpatientType,page,size);
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findReOutpatientInfo)
@ -263,8 +265,10 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    public ObjEnvelop checkOutpatient(@ApiParam(name = "patient", value = "续方明细")
                                      @RequestParam(value = "patient", required = true)String patient,
                                      @ApiParam(name = "flag", value = "标识是否开启结算")
                                      @RequestParam(value = "flag", required = false)boolean flag)throws Exception{
        return success(prescriptionService.checkOutpatient(patient,wxId,flag));
                                      @RequestParam(value = "flag", required = false)boolean flag,
                                      @ApiParam(name = "outpatientType", value = "1在线复诊 2 协同 3 专家咨询")
                                          @RequestParam(value = "outpatientType", required = false)String outpatientType)throws Exception{
        return success(prescriptionService.checkOutpatient(patient,wxId,flag,outpatientType));
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findAllHospital)
@ -353,7 +357,7 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                                         @RequestParam(value = "chargeType", required = false)String chargeType)throws Exception {
        
        WlyyOutpatientDO wlyyOutpatientDO = prescriptionService.appointmentRevisit(outpatientJson,expressageJson,registerJson,chargeType);
        if (wlyyOutpatientDO!=null&&null==wlyyOutpatientDO.getId()){
        if (wlyyOutpatientDO!=null&&null==wlyyOutpatientDO.getId()&&!wlyyOutpatientDO.getOutpatientType().equalsIgnoreCase("3")){
            ObjEnvelop objEnvelop =new ObjEnvelop();
            String msg = "";
            if (1==wlyyOutpatientDO.getRemindCount()){
@ -903,7 +907,7 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        
    }
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.updatePatientInfo)
        @PostMapping(value = BaseHospitalRequestMapping.Prescription.updatePatientInfo)
    @ApiOperation(value = "修改居民信息", notes = "修改居民信息")
    public ObjEnvelop findPatientInfo(@ApiParam(name = "patient", value = "居民ID")
                                      @RequestParam(value = "patient", required = true)String patient,
@ -1249,21 +1253,21 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                if("1,15,17".equals(type)){//专家咨询
                    Integer consultType =  Integer.parseInt(consult.get("type").toString());
                    if(1 == consultType){//专家咨询
                        consult.put("session_id", consult.get("patientId").toString()+"_"+ consult.get("doctorCode").toString()+"_1");
                        consult.put("session_id", consult.get("consumer").toString()+"_"+ consult.get("outpatientId").toString()+"_1");
                    }else if(15 == consultType){//家医求助
                        consult.put("session_id", consult.get("patientId").toString()+"_"+ consult.get("generalDoctor").toString()+"_"+ consult.get("doctorCode").toString()+"_15");
                        consult.put("session_id", consult.get("consumer").toString()+"_"+ consult.get("outpatientId").toString()+"_"+ consult.get("doctorCode").toString()+"_15");
                    }else if (17==consultType){//视频咨询
                        consult.put("session_id", consult.get("patientId").toString()+"_"+ consult.get("doctorCode").toString()+"_17");
                        consult.put("session_id", consult.get("consumer").toString()+"_"+ consult.get("outpatientId").toString()+"_17");
                    }
                }else if("9".equals(type)){//图文复诊
                    consult.put("session_id", consult.get("patientId").toString()+"_"+consult.get("outpatientId").toString()+"_9");
                    consult.put("session_id", consult.get("consumer").toString()+"_"+consult.get("outpatientId").toString()+"_9");
                    consult.put("type",type);
                }else if("16".equals(type)){//视频复诊
                    consult.put("session_id", consult.get("patientId").toString()+"_"+consult.get("outpatientId").toString()+"_16");
                    consult.put("session_id", consult.get("consumer").toString()+"_"+consult.get("outpatientId").toString()+"_16");
                    consult.put("type",type);
                }else if("12".equals(type)){//协同门诊
                    consult.put("session_id", consult.get("patientId").toString()+"_"+consult.get("outpatientId").toString()+"_12");
                    consult.put("session_id", consult.get("consumer").toString()+"_"+consult.get("outpatientId").toString()+"_12");
                    consult.put("type",type);
                }else{}
                
@ -1460,7 +1464,7 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
            @RequestParam(required = true)Integer type,
            @ApiParam(name = "paymentType", value = "1支付宝 2微信", required = true)
            @RequestParam(required = true)Integer paymentType,
            @ApiParam(name = "patientId", value = "居民Ccode", required = true)
            @ApiParam(name = "patientId", value = "居民code", required = true)
            @RequestParam(required = true)String patientId,
            @ApiParam(name = "hospitalId", value = "医院Ccode", required = true)
            @RequestParam(required = true)String hospitalId,
@ -2092,7 +2096,7 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "relationCode", value = "业务code")
            @RequestParam(value = "relationCode", required = false) String relationCode) throws Exception {
        try {
            BusinessOrderDO businessOrderDO = businessOrderService.updatePayStatusByRelation(relationCode);
            BusinessOrderDO businessOrderDO = businessOrderService.updatePayStatusByRelation(relationCode,wxId);
            if (businessOrderDO.getOrderCategory().equalsIgnoreCase("2")){
                SystemMessageDO systemMessageDO = new SystemMessageDO();
                systemMessageDO.setType("1");

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

@ -1,6 +1,8 @@
package com.yihu.jw.hospital.endpoint.prescription;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.hospital.prescription.service.PrescriptionService;
import com.yihu.jw.hospital.prescription.service.YkyyPrescriptionService;
import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService;
import com.yihu.jw.order.BusinessOrderService;
@ -33,12 +35,16 @@ public class YkyyPrescriptionEndpoint extends EnvelopRestEndpoint {
    private YkyyEntranceService ykyyEntranceService;
    @Autowired
    private BusinessOrderService businessOrderService;
    @Autowired
    private PrescriptionService commenPrescriptionService;
    @Value("${demo.flag}")
    private boolean demoFlag;
    @Value("${wechat.id}")
    private String wxId;
    @Value("${pay.flag}")
    private boolean payFlag;
    @GetMapping(value = "vlisReportMasterlist")
    @ApiOperation(value = "检验信息列表")
@ -161,7 +167,7 @@ public class YkyyPrescriptionEndpoint extends EnvelopRestEndpoint {
                                         @RequestParam(value = "chargeType", required = false)String chargeType)throws Exception {
        WlyyOutpatientDO wlyyOutpatientDO = prescriptionService.appointmentRevisit(outpatientJson,expressageJson,registerJson,chargeType);
        if (wlyyOutpatientDO!=null&&null==wlyyOutpatientDO.getId()){
        if (wlyyOutpatientDO!=null&&null==wlyyOutpatientDO.getId()&&!wlyyOutpatientDO.getOutpatientType().equalsIgnoreCase("3")){
            ObjEnvelop objEnvelop =new ObjEnvelop();
            String msg = "";
            if (1==wlyyOutpatientDO.getRemindCount()){
@ -173,6 +179,7 @@ public class YkyyPrescriptionEndpoint extends EnvelopRestEndpoint {
            objEnvelop.setStatus(300);
            return objEnvelop;
        }
        SystemMessageDO systemMessageDO = commenPrescriptionService.sendOutPatientMes(wlyyOutpatientDO,payFlag);
       /* //发送系统消息
        SystemMessageDO systemMessageDO = prescriptionService.sendOutPatientMes(wlyyOutpatientDO);
        //发送IM消息

+ 8 - 8
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/ykyy/YkyyController.java

@ -1,21 +1,17 @@
package com.yihu.jw.hospital.endpoint.ykyy;
import com.yihu.jw.entity.hospital.mapping.HospitalDeptMappingDO;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService;
import com.yihu.jw.hospital.ykyy.service.YkyyService;
import com.yihu.jw.order.BusinessOrderService;
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.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.rm.patient.PatientRequestMapping;
import com.yihu.jw.wechat.service.WxTemplateService;
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.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
@ -205,9 +201,11 @@ public class YkyyController extends EnvelopRestEndpoint {
            @ApiParam(name = "outTradeNo", value = "outTradeNo", required = true)
            @RequestParam(required = true)String outTradeNo,
            @ApiParam(name = "notifyUrl", value = "notifyUrl", required = true)
            @RequestParam(required = true)String notifyUrl) throws Exception {
            @RequestParam(required = true)String notifyUrl,
            @ApiParam(name = "patient", value = "patient", required = false)
            @RequestParam(required = false)String patient) throws Exception {
        try {
            return ObjEnvelop.getSuccess("ok",businessOrderService.unifiedorder(wxId,body,totalFee,tradeType,openId,outTradeNo,notifyUrl));
            return ObjEnvelop.getSuccess("ok",businessOrderService.unifiedorder(wxId,body,totalFee,tradeType,openId,outTradeNo,notifyUrl,patient));
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
@ -327,9 +325,11 @@ public class YkyyController extends EnvelopRestEndpoint {
            @ApiParam(name = "relationCode", value = "relationCode", required = true)
            @RequestParam(required = true)String relationCode,
            @ApiParam(name = "tradeType", value = "tradeType", required = false)
            @RequestParam(required = false)String tradeType) throws Exception {
            @RequestParam(required = false)String tradeType,
            @ApiParam(name = "appletCode", value = "appletCode", required = false)
            @RequestParam(required = false)String appletCode) throws Exception {
        try {
            return ObjEnvelop.getSuccess("ok",businessOrderService.selectOrderByRelationCode(relationCode,tradeType,wxId,payFlag));
            return ObjEnvelop.getSuccess("ok",businessOrderService.selectOrderByRelationCode(relationCode,tradeType,wxId,payFlag,appletCode));
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }