Sfoglia il codice sorgente

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

wangzhinan 4 anni fa
parent
commit
e2f66b6c3a
15 ha cambiato i file con 544 aggiunte e 105 eliminazioni
  1. 1 1
      business/base-service/src/main/java/com/yihu/jw/hospital/httplog/service/WlyyHttpLogService.java
  2. 18 2
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  3. 1 1
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/YkyyPrescriptionService.java
  4. 3 2
      business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java
  5. 135 1
      business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java
  6. 1 2
      common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java
  7. 83 83
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/TimeoutOverDueService.java
  8. 8 5
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java
  9. 14 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java
  10. 32 1
      svr/svr-iot/src/main/java/com/yihu/iot/controller/monitorPlatform/MonitorPlatformController.java
  11. 4 3
      svr/svr-iot/src/main/java/com/yihu/iot/controller/platform/IotInterfaceController.java
  12. 29 0
      svr/svr-iot/src/main/java/com/yihu/iot/model/AppServiceCount.java
  13. 25 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/company/IotCompanyService.java
  14. 180 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/monitorPlatform/MonitorPlatformService.java
  15. 10 3
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/SpecialistScreenResultService.java

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/hospital/httplog/service/WlyyHttpLogService.java

@ -64,7 +64,7 @@ public class WlyyHttpLogService  extends BaseJpaService<WlyyHttpLogDO, WlyyHttpL
        sql+=" a.name as \"patientName\"," +
                "b.name as \"doctorName\"" +
                " from wlyy_http_log t left join base_patient a on t.patient = a.id " +
                " left join base_doctor b on t.doctor = b.id where 1=1 ";
                " left join base_doctor b on t.doctor = b.id where 1=1 and (t.code like '%Check%' or t.name = '合理用药审核接口')";
        if (StringUtils.isNotBlank(endTime)){
            if("xm_ykyy_wx".equals(wxId)){
                if (flag){

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

@ -907,7 +907,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                expressageDO.setProvinceName(baseDrugStoreDO.getProvinceName());
                expressageDO.setTownCode(baseDrugStoreDO.getTownCode());
                expressageDO.setTownName(baseDrugStoreDO.getTownName());
                expressageDO.setHospitalCode(baseDrugStoreDO.getHospitalCode());
                expressageDO.setHospitalCode(baseDrugStoreDO.getDrugStoreCode());
                expressageDO.setHospitalName(baseDrugStoreDO.getHospitalName());
                expressageDO.setHospitalAddress(baseDrugStoreDO.getAddress());
            }
@ -4441,6 +4441,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                "room.outpatient_id AS \"id\"," +
                "room.patient_id AS \"patient_id\"," +
                "room.patient_name AS \"name\"," +
                "outpatient.patient_name AS \"outPatientName\"," +
                "outpatient.patient AS \"outPatient\"," +
                "patient.sex AS \"sex\"," +
                "patient.idcard AS \"idcard\"," +
                "patient.photo AS \"photo\"," +
@ -4530,6 +4532,20 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            //根据身份证计算年龄
            for (Map<String, Object> outpatient : list) {
                String idcard = (String) outpatient.get("idcard");
                int patientAge = 0;
                int patientSex = 3;
                if (null!=outpatient.get("outPatient")){
                   BasePatientDO basePatientDO = basePatientDao.findById(outpatient.get("outPatient").toString());
                   if (null!=basePatientDO){
                       if (StringUtils.isNotBlank(basePatientDO.getIdcard())){
                           patientAge = DateUtil.getAgeForIdcard(basePatientDO.getIdcard());
                           outpatient.put("patientAge", DateUtil.getAgeForIdcard(basePatientDO.getIdcard()));
                       }
                       patientSex =basePatientDO.getSex();
                   }
                }
                outpatient.put("patientAge", patientAge);
                outpatient.put("patientSex", patientSex);
                outpatient.put("age", DateUtil.getAgeForIdcard(idcard));
            }
        }
@ -8908,7 +8924,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    public MixEnvelop prescriptionManage(String keyWord,String doctorId,String startTime,String endTime,String checkStatus,Integer page,Integer pageSize){
        String sql = " select p.create_time as \"createTime\"," +
                " p.patient_name as \"patientName\"," +
                " p.idcard as \"idcard\"," +
                " o.idcard as \"idcard\"," +
                " o.card_no as \"cardNo\"," +
                " p.check_status as \"checkStatus\"," +
                " p.id as \"id\"," +

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

@ -252,7 +252,7 @@ public class YkyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
                expressageDO.setProvinceName(baseDrugStoreDO.getProvinceName());
                expressageDO.setTownCode(baseDrugStoreDO.getTownCode());
                expressageDO.setTownName(baseDrugStoreDO.getTownName());
                expressageDO.setHospitalCode(baseDrugStoreDO.getHospitalCode());
                expressageDO.setHospitalCode(baseDrugStoreDO.getDrugStoreCode());
                expressageDO.setHospitalName(baseDrugStoreDO.getHospitalName());
                expressageDO.setHospitalAddress(baseDrugStoreDO.getAddress());
            }

+ 3 - 2
business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java

@ -771,7 +771,8 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
                                    //同步his写入自取信息
                                    String updatesql = "update v_ms_dd01 t set t.PSFS = 0 ,t.FKZT=1 ,t.SJR= '"+wlyyPrescriptionExpressageDO.getName()+"' ," +
                                            " t.SJRDH = '"+wlyyPrescriptionExpressageDO.getMobile()+"' ,"+
                                            " t.SJRDZ = '"+wlyyPrescriptionExpressageDO.getAddress()+"'"+
                                            " t.SJRDZ = '"+wlyyPrescriptionExpressageDO.getAddress()+"' ,"+
                                            " t.YFSB = '"+wlyyPrescriptionExpressageDO.getHospitalCode()+"'"+
                                            " where t.JZXH = '"+wlyyPrescriptionDO.getAdmNo()+"' and t.CFSB ='"+wlyyPrescriptionDO.getRealOrder()+"'";
                                    ykyyEntranceService.updateHisStatus(updatesql);
                                    logger.info("自取写入更新his");
@ -790,7 +791,7 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
                                        JSONObject json = JSONObject.parseObject(sfResult.toString());
                                        String sfOrder =  json.getString("mailNo");
                                        logger.info("---获取订单号为:"+sfOrder);
                                        String updatesql = "update v_ms_dd01 t set t.PSFS = 1 ,t.FKZT=1 ,t.KDDH ='"+sfOrder+"',t.SJR = '"+wlyyPrescriptionExpressageDO.getName()+"' ," +
                                        String updatesql = "update v_ms_dd01 t set t.PSFS = 1 ,t.FKZT=1 ,t.YFSB = 6 ,t.KDDH ='"+sfOrder+"',t.SJR = '"+wlyyPrescriptionExpressageDO.getName()+"' ," +
                                                " t.SJRDH = '"+wlyyPrescriptionExpressageDO.getMobile()+"' ,"+
                                                " t.SJRDZ = '"+wlyyPrescriptionExpressageDO.getAddress()+"'"+
                                                " where t.JZXH = '"+admNo+"' and t.CFSB ='"+realOrder+"'";

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

@ -1361,6 +1361,15 @@ public class ImService {
		jsonObject.put("age",DateUtil.getAgeForIdcard(p.getIdcard()));
		jsonObject.put("sex",p.getSex());
		jsonObject.put("name",p.getName());
		if (null!=wlyyOutpatientDO){
			BasePatientDO outPatient = basePatientDao.findById(wlyyOutpatientDO.getPatient());
			if (null!=outPatient){
				jsonObject.put("age",DateUtil.getAgeForIdcard(outPatient.getIdcard()));
				jsonObject.put("sex",outPatient.getSex());
				jsonObject.put("name",outPatient.getName());
			}
		}
		//4、创建咨询
		JSONObject users = new JSONObject();//咨询参与者
@ -1594,7 +1603,7 @@ public class ImService {
			throw new RuntimeException("IM消息结束异常!");
		}
		if (obj.getInteger("status") == -1) {
			throw new RuntimeException(String.valueOf(obj.get("message")));
			throw new RuntimeException(String.valueOf(null==obj.get("message")?"无失败信息":obj.get("message")));
		}
//		//推送给IM文字消息
@ -1684,7 +1693,132 @@ public class ImService {
		return 1;
	}
	/**
	 * 居民取消复诊
	 * @param consult 咨询CODE
	 * @param endOperator 操作人
	 * @param endType 1居民 2医生
	 * @return
	 */
	public int cancelRevisit(String consult, String endOperator, int endType) {
		ConsultTeamDo consultTeam = consultTeamDao.findByConsult(consult);
		ConsultDo cons = consultDao.findOne(consult);
		if (consultTeam.getStatus() == 1) {
			return -1;
		}
		String name = "";
		String returnJson = "";
		/**
		 * 发送评价消息
		 */
		BaseDoctorDO doctor = baseDoctorDao.findById(consultTeam.getDoctor());
		BasePatientDO patient = basePatientDao.findById(consultTeam.getPatient());
		/*JSONObject evalueContent = new JSONObject();
		evalueContent.put("patientCode",consultTeam.getPatient());
		evalueContent.put("patientName",patient.getName());
		evalueContent.put("doctorCode",consultTeam.getDoctor());
		evalueContent.put("doctorName",doctor.getName());
		evalueContent.put("doctorPhoto",doctor.getPhoto());
		evalueContent.put("consultCode",consult);*/
//		returnJson = imUtil.sendIM(consultTeam.getDoctor(), consultTeam.getPatient(), "28", evalueContent.toString());
//		String response = imUtil.sendTopicIM(consultTeam.getDoctor(), doctor.getName(), consult, "28", evalueContent.toString(),null);
//		String response = imUtil.sendImMsg(consultTeam.getDoctor(), doctor.getName(), session_id, "28", evalueContent.toString(),null);
		//保存系统消息服务评价
		//systemMsgEvaluation(doctor,patient,cons,consultTeam,consult,wxId);
		String endName = "";
		String endId = "";
		JSONObject obj = new JSONObject();
		//结束咨询才发送推送给IM文字消息
		if (endType == 1) {
			BasePatientDO p = basePatientDao.findById(endOperator);
			endName = p.getName();
			endId = p.getId();
			obj = imUtil.endTopics(consultTeam.getPatient(), endId, endName, consultTeam.getConsult());
		} else {
			BaseDoctorDO d = baseDoctorDao.findById(endOperator);
			if (endOperator.equals("admin")) {
				endId = "system";
				endName = "超时,系统自动";
			} else {
				endId = d.getId();
				endName = d.getName();
			}
			obj = imUtil.endTopics(consultTeam.getDoctor(), endId, endName, consultTeam.getConsult());
		}
		if (obj == null) {
			throw new RuntimeException("IM消息结束异常!");
		}
		if (obj.getInteger("status") == -1) {
			throw new RuntimeException(String.valueOf(obj.get("message")));
		}
		consultTeam.setEndMsgId(obj.getString("id"));
		cons.setEndTime(new Date());
		consultTeam.setEndTime(new Date());
		consultTeam.setStatus(1);
		consultDao.save(cons);
		consultTeamDao.save(consultTeam);
		//判断是否是在线复诊
		/*if(cons.getRelationCode() != null){
			WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findOne(cons.getRelationCode());
			if(wlyyOutpatientDO != null && wlyyOutpatientDO.getId() != null){
				if (wlyyOutpatientDO.getStatus().equalsIgnoreCase("0")){
					wlyyOutpatientDO.setStatus("-1");
				}else {
					wlyyOutpatientDO.setStatus("3");
				}
				outpatientDao.save(wlyyOutpatientDO);
			}
			List<WlyyHospitalWaitingRoomDO> wlyyHospitalWaitingRoomDOS = hospitalWaitingRoomDao.findByOutpatientId(cons.getRelationCode());
			if(!wlyyHospitalWaitingRoomDOS.isEmpty()){
				for (WlyyHospitalWaitingRoomDO wlyyHospitalWaitingRoomDO:wlyyHospitalWaitingRoomDOS){
					wlyyHospitalWaitingRoomDO.setVisitStatus(2);
					hospitalWaitingRoomDao.save(wlyyHospitalWaitingRoomDO);
				}
			}
		}*/
		if (wxId.equalsIgnoreCase("xm_ykyy_wx")){
			if (!flag){
				BusinessOrderDO businessOrderDO = new BusinessOrderDO();
				if(cons.getRelationCode() != null){
					businessOrderDO  = businessOrderDao.selectByRelationCode(cons.getRelationCode());
				}else {
					businessOrderDO  = businessOrderDao.selectByRelationCode(consult);
				}
				if (businessOrderDO!=null){
					String sql ="SELECT * FROM topics t where " +
							"t.id='"+consult+"' and t.reply_user is null and t.reply is null and t.status IN(0,1) ";
					List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
					System.out.println("sql+-----"+sql);
					if (null!=mapList&&mapList.size()>0&&mapList.size()==1){
						//医生没回复的话要把状态改为关闭 status=?
						System.out.println("-------------------进入未回复状态同步--------------------");
						ykyyService.updateYktOrderStatus(businessOrderDO.getOrderNo(),"3");
					}else {
						ykyyService.updateYktOrderStatus(businessOrderDO.getOrderNo(),"4");
					}
				}
			}
		}
		return 1;
	}
	public void systemMsgEvaluation(BaseDoctorDO doctor,BasePatientDO patient,ConsultDo cons,ConsultTeamDo consultTeam ,String consult,String wxId){
		SystemMessageDO messageDO = new SystemMessageDO();

+ 1 - 2
common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java

@ -164,9 +164,8 @@ public class DateUtil {
    }
    public static String getYyyymmddhhmmss(Date date) {
        Date currentTime = new Date();
        SimpleDateFormat formatter = new SimpleDateFormat(YYYYMMDDHHMMSS);
        return formatter.format(currentTime);
        return formatter.format(date);
    }
    /**

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

@ -93,7 +93,7 @@ public class TimeoutOverDueService {
                for(WlyyOutpatientDO wlyyOutpatientDO:timeout){
                    try {
                        long currentTime = new Date().getTime();
                        long outpatientTime = wlyyOutpatientDO.getCreateTime().getTime();
                        long outpatientTime = wlyyOutpatientDO.getRegisterDate().getTime();
                        if (currentTime-outpatientTime>24*60*60*1000){
                            logger.info("时间满足条件");
                            String outPatientId = wlyyOutpatientDO.getId();
@ -101,9 +101,10 @@ public class TimeoutOverDueService {
                            try {
                                consultCode = imService.getConsultCodeByOutpatientId(outPatientId);
                                logger.info("consultCode"+consultCode);
                                if(StringUtils.isNoneBlank(consultCode)){
                                    imService.finish(consultCode,"admin",2);
                                    //医生未回复可以退费
                                if(StringUtils.isNoneBlank(consultCode)) {
                                    imService.cancelRevisit(consultCode, "admin", 2);
                                }
                                    /*//医生未回复可以退费
                                    businessOrderService.consultRefund(consultCode,wechatId);
                                    wlyyOutpatientDO.setDoctorCancelRemark(cancelRemark);
                                    wlyyOutpatientDO.setDoctorCancelType("6");
@ -111,90 +112,89 @@ public class TimeoutOverDueService {
                                    wlyyOutpatientDO.setEndTime(new Date());
                                    wlyyOutpatientDO.setOperator("system");
                                    outpatientDao.save(wlyyOutpatientDO);
                                    logger.info(wlyyOutpatientDO.getId()+"的门诊记录设置为取消");
                                }else{
                                    //判断医生是否接诊
                                    List<WlyyHospitalWaitingRoomDO> roomDOs = hospitalWaitingRoomDao.findByOutpatientId(outPatientId);
                                    if (roomDOs != null && roomDOs.size() > 0) {
                                        for (WlyyHospitalWaitingRoomDO roomDO : roomDOs) {
                                            if (roomDO.getVisitStatus() == 2) {
                                                logger.info("id为:"+outPatientId+"的门诊已被医生接诊");
                                            } else {
                                                roomDO.setVisitStatus(-1);
                                                logger.info("修改候诊室状态,将候诊病人移除候诊室");
                                                hospitalWaitingRoomDao.save(roomDO);
                                            }
                                    logger.info(wlyyOutpatientDO.getId()+"的门诊记录设置为取消");*/
                                //判断医生是否接诊
                                List<WlyyHospitalWaitingRoomDO> roomDOs = hospitalWaitingRoomDao.findByOutpatientId(outPatientId);
                                if (roomDOs != null && roomDOs.size() > 0) {
                                    for (WlyyHospitalWaitingRoomDO roomDO : roomDOs) {
                                        if (roomDO.getVisitStatus() == 2) {
                                            logger.info("id为:"+outPatientId+"的门诊已被医生接诊");
                                        } else {
                                            roomDO.setVisitStatus(-1);
                                            logger.info("修改候诊室状态,将候诊病人移除候诊室");
                                            hospitalWaitingRoomDao.save(roomDO);
                                        }
                                    }
                                    //更改门诊状态
                                    wlyyOutpatientDO.setStatus("-1");
                                    String description = null;
                                    wlyyOutpatientDO.setDoctorCancelRemark(cancelRemark);
                                    wlyyOutpatientDO.setDoctorCancelType("6");
                                    wlyyOutpatientDO.setDoctorCancelValue(cancelValue);
                                    wlyyOutpatientDO.setEndTime(new Date());
                                    wlyyOutpatientDO.setOperator("system");
                                    description = cancelValue;
                                    //系统消息
                                    SystemMessageDO messageDO = new SystemMessageDO();
                                    messageDO.setTitle("超时订单系统自动取消");
                                    messageDO.setType("13");
                                    messageDO.setSender(wlyyOutpatientDO.getDoctor());
                                    messageDO.setSenderName(wlyyOutpatientDO.getDoctorName());
                                    messageDO.setRelationCode(wlyyOutpatientDO.getId());
                                    messageDO.setReceiver(wlyyOutpatientDO.getPatient());
                                    messageDO.setReceiverName(wlyyOutpatientDO.getPatientName());
                                    net.sf.json.JSONObject data = new net.sf.json.JSONObject();
                                    data.put("name", wlyyOutpatientDO.getPatientName());
                                    data.put("age", IdCardUtil.getAgeForIdcard(wlyyOutpatientDO.getIdcard()));
                                    data.put("gender", IdCardUtil.getSexForIdcard(wlyyOutpatientDO.getIdcard()));
                                    data.put("question", wlyyOutpatientDO.getIcd10Name());
                                    String msg = "";
                                    if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                                        data.put("type", "9");
                                        msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个图文复诊已被系统取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                                        prescriptionService.sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "9", "systemCancelRemind", cancelRemark);
                                    }
                                    if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                                        data.put("type", "16");
                                        msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个视频复诊已被系统取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                                        prescriptionService.sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "16", "systemCancelRemind", cancelRemark);
                                    }
                                    data.put("msg", msg);
                                    messageDO.setData(data.toString());
                                    systemMessageService.saveMessage(messageDO);
                                    //推送消息到眼科通
                                    BasePatientDO patient = basePatientDao.findById(wlyyOutpatientDO.getPatient());
                                    if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
                                        logger.info("推送消息到眼科通");
                                        ykyyService.pushNotificationToYktPatient(patient.getYktId(), messageDO.getTitle(), data.get("msg").toString());
                                    }
                                    //删除门诊号源
                                    List<WlyyPatientRegisterTimeDO> list = patientRegisterTimeDao.findByOutpatientId(wlyyOutpatientDO.getId());
                                    if (list != null && list.size() > 0) {
                                        patientRegisterTimeDao.delete(list);
                                    }
                                    BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outPatientId);
                                    if (wechatId.equalsIgnoreCase("xm_ykyy_wx")) {
                                        businessOrderService.orderRefund(wechatId, wlyyOutpatientDO.getConsumer(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
                                        //眼科接诊时更新眼科通状态
                                        if (businessOrderDO!=null){
                                            ykyyService.updateYktOrderStatus(businessOrderDO.getOrderNo(),"2");
                                        }
                                    } else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")) {
        /*
                            businessOrderService.ylzOrderRefund(wechatId, wlyyOutpatientDO.getPatient(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
        */
                                }
                                //更改门诊状态
                                wlyyOutpatientDO.setStatus("-1");
                                String description = null;
                                wlyyOutpatientDO.setDoctorCancelRemark(cancelRemark);
                                wlyyOutpatientDO.setDoctorCancelType("6");
                                wlyyOutpatientDO.setDoctorCancelValue(cancelValue);
                                wlyyOutpatientDO.setEndTime(new Date());
                                wlyyOutpatientDO.setOperator("system");
                                description = cancelValue;
                                //系统消息
                                SystemMessageDO messageDO = new SystemMessageDO();
                                messageDO.setTitle("超时订单系统自动取消");
                                messageDO.setType("13");
                                messageDO.setSender(wlyyOutpatientDO.getDoctor());
                                messageDO.setSenderName(wlyyOutpatientDO.getDoctorName());
                                messageDO.setRelationCode(wlyyOutpatientDO.getId());
                                messageDO.setReceiver(wlyyOutpatientDO.getPatient());
                                messageDO.setReceiverName(wlyyOutpatientDO.getPatientName());
                                net.sf.json.JSONObject data = new net.sf.json.JSONObject();
                                data.put("name", wlyyOutpatientDO.getPatientName());
                                data.put("age", IdCardUtil.getAgeForIdcard(wlyyOutpatientDO.getIdcard()));
                                data.put("gender", IdCardUtil.getSexForIdcard(wlyyOutpatientDO.getIdcard()));
                                data.put("question", wlyyOutpatientDO.getIcd10Name());
                                String msg = "";
                                if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                                    data.put("type", "9");
                                    msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个图文复诊已被系统取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                                    prescriptionService.sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "9", "systemCancelRemind", cancelRemark);
                                }
                                if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
                                    data.put("type", "16");
                                    msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个视频复诊已被系统取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
                                    prescriptionService.sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "16", "systemCancelRemind", cancelRemark);
                                }
                                data.put("msg", msg);
                                messageDO.setData(data.toString());
                                systemMessageService.saveMessage(messageDO);
                                //推送消息到眼科通
                                BasePatientDO patient = basePatientDao.findById(wlyyOutpatientDO.getPatient());
                                if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
                                    logger.info("推送消息到眼科通");
                                    ykyyService.pushNotificationToYktPatient(patient.getYktId(), messageDO.getTitle(), data.get("msg").toString());
                                }
                                //删除门诊号源
                                List<WlyyPatientRegisterTimeDO> list = patientRegisterTimeDao.findByOutpatientId(wlyyOutpatientDO.getId());
                                if (list != null && list.size() > 0) {
                                    patientRegisterTimeDao.delete(list);
                                }
                                BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outPatientId);
                                if (wechatId.equalsIgnoreCase("xm_ykyy_wx")) {
                                    businessOrderService.orderRefund(wechatId, wlyyOutpatientDO.getConsumer(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
                                    //眼科接诊时更新眼科通状态
                                    if (businessOrderDO!=null){
                                        ykyyService.updateYktOrderStatus(businessOrderDO.getOrderNo(),"2");
                                    }
                                    outpatientDao.save(wlyyOutpatientDO);
                                    logger.info(wlyyOutpatientDO.getId()+"的门诊记录设置为取消");
                                } else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")) {
    /*
                        businessOrderService.ylzOrderRefund(wechatId, wlyyOutpatientDO.getPatient(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
    */
                                }
                            }catch(Exception e)  {
                                e.printStackTrace();
                                logger.info("自动结束咨询报错 consultCode: "+consultCode);
                            }
                                outpatientDao.save(wlyyOutpatientDO);
                                logger.info(wlyyOutpatientDO.getId()+"的门诊记录设置为取消");
                        }
                                }catch(Exception e)  {
                                    e.printStackTrace();
                                    logger.info("自动结束咨询报错 consultCode: "+consultCode);
                                }
                            }
                    } catch (Exception e) {
                        e.printStackTrace();
                        logger.info(wlyyOutpatientDO.getId()+"的门诊记录取消失败");

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

@ -997,7 +997,9 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
            WlyyPrescriptionExpressageDO wlyyPrescriptionExpressageDO = expressList.get(0);
            if (null!=wlyyPrescriptionExpressageDO&&wlyyPrescriptionExpressageDO.getOneselfPickupFlg()==1){
                //同步his写入自取信息
                String updatesql = "update v_ms_dd01 t set t.PSFS = 0 ,t.FKZT=1 where t.JZXH = '"+wlyyPrescriptionDO.getAdmNo()+"' and t.CFSB ='"+wlyyPrescriptionDO.getRealOrder()+"'";
                String updatesql = "update v_ms_dd01 t set t.PSFS = 0 ,t.FKZT=1 ," +
                        " t.YFSB = '"+wlyyPrescriptionExpressageDO.getHospitalCode()+"'"+
                        "where t.JZXH = '"+wlyyPrescriptionDO.getAdmNo()+"' and t.CFSB ='"+wlyyPrescriptionDO.getRealOrder()+"'";
                ykyyEntranceService.updateHisStatus(updatesql);
                logger.info("自取写入更新his");
            }else {
@ -1021,7 +1023,8 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
                    logger.info("---获取订单号为:"+sfOrder);
                    String updatesql = "update v_ms_dd01 t set t.PSFS = 1 ,t.FKZT=1 ,t.KDDH ='"+sfOrder+"',t.SJR = '"+wlyyPrescriptionExpressageDO.getName()+"' ," +
                            " t.SJRDH = '"+wlyyPrescriptionExpressageDO.getMobile()+"' ,"+
                            " t.SJRDZ = '"+wlyyPrescriptionExpressageDO.getAddress()+"'"+
                            " t.SJRDZ = '"+wlyyPrescriptionExpressageDO.getAddress()+"' ,"+
                            " t.YFSB = 6"+
                            " where t.JZXH = '"+admNo+"' and t.CFSB ='"+realOrder+"'";
                    ykyyEntranceService.updateHisStatus(updatesql);
                    logger.info("更新his成功");
@ -1063,12 +1066,12 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
                                           @RequestParam(value = "doctor", required = false) String doctor,
                                       @ApiParam(name = "request", value = "request")
                                           @RequestParam(value = "request", required = false) String request,
                                       @ApiParam(name = "respone", value = "respone")
                                           @RequestParam(value = "respone", required = false) String respone,
                                       @ApiParam(name = "response", value = "response")
                                           @RequestParam(value = "response", required = false) String response,
                                       @ApiParam(name = "status", value = "status")
                                           @RequestParam(value = "status", required = false) String status
                                       ) throws Exception {
        wlyyHttpLogService.saveHttpLog(code,name,patient,doctor,request,respone,status);
        wlyyHttpLogService.saveHttpLog(code,name,patient,doctor,request,response,status);
        return success("添加成功");
    }
    @PostMapping(value = "/findHttpLog")

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

@ -695,14 +695,27 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        //修改consult门诊状态
        //修改consult门诊状态
        ConsultDo consultDo = consultDao.findByRelationCode(outPatientId);
        /*ConsultDo consultDo = consultDao.findByRelationCode(outPatientId);
        if (null!=consultDo){
            ConsultTeamDo consultTeamDo = consultTeamDao.findByConsult(consultDo.getId());
            if (null!=consultTeamDo){
                consultTeamDo.setStatus(-1);
                consultTeamDao.save(consultTeamDo);
            }
        }*/
        try {
            String consultCode = imService.getConsultCodeByOutpatientId(outPatientId);
            System.out.println("consultCode"+consultCode);
            if(StringUtils.isNoneBlank(consultCode)) {
                ConsultDo consultDo = consultDao.findByRelationCode(outPatientId);
                if(null!=consultDo){
                    imService.cancelRevisit(consultCode, consultDo.getPatient(), 1);
                }
            }
        }catch (Exception e){
            System.out.println("居民取消复诊失败");
        }
        return success(prescriptionService.cancelOutPatient(outPatientId,cancelType,cancelValue,cancelRemark,1,wxId));
    }
    

+ 32 - 1
svr/svr-iot/src/main/java/com/yihu/iot/controller/monitorPlatform/MonitorPlatformController.java

@ -2,6 +2,7 @@ package com.yihu.iot.controller.monitorPlatform;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.iot.service.company.IotCompanyService;
import com.yihu.iot.service.device.IotPatientDeviceService;
import com.yihu.iot.service.dict.IotSystemDictService;
import com.yihu.iot.service.equipment.IotEqtDetailService;
@ -45,6 +46,8 @@ public class MonitorPlatformController extends EnvelopRestEndpoint {
    private IotPatientDeviceService iotPatientDeviceService;
    @Autowired
    private IotEqtDetailService iotEqtDetailService;
    @Autowired
    private IotCompanyService iotCompanyService;
    @PostMapping(value = IotRequestMapping.PatientDevice.addPatientDevice)
@ -724,9 +727,37 @@ public class MonitorPlatformController extends EnvelopRestEndpoint {
    public Envelop getEquipmentDetail(@RequestParam(value = "deviceSn",required = true)
                             @ApiParam(name="deviceSn",value ="设备SN码",required = true)String deviceSn){
        return success(monitorPlatformService.getEquipmentDetail(deviceSn));
    }
    @GetMapping(value ="/getBrandsAndManufacturer")
    @ApiOperation("设备品牌以及商家")
    public Envelop getBrandsAndManufacturer(){
        return success(monitorPlatformService.getBrandsAndManufacturer());
    }
    @GetMapping(value="/getEquipmentStatistics")
    @ApiOperation("设备库存、使用数、总备案、失联率、物联率")
    public Envelop getEquipmentStatistics(@RequestParam(value = "deviceType",required = false)
                                          @ApiParam(name="deviceType",value = "设备类型,1血糖仪,2血压计,5健康小屋",required = false) String deviceType,
                                          @RequestParam(value="deviceName",required = false,defaultValue = "")
                                          @ApiParam(name="deviceName",value = "设备名称(品牌)",required = false) String deviceName,
                                          @RequestParam(value = "showLevel",defaultValue = "0")
                                          @ApiParam(name="showLevel",value ="下转层次,默认0设备大类,1设备类型,2设备品牌") String showLevel){
        return success(monitorPlatformService.getEquipmentStatistics(deviceType, deviceName, showLevel));
    }
    @ApiOperation("大屏应用服务")
    @RequestMapping(value = "/getAppService" , method = RequestMethod.GET)
    public Envelop getAppService() {
        try {
            return success(iotCompanyService.getAppService());
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError("查询失败");
        }
    }
}

+ 4 - 3
svr/svr-iot/src/main/java/com/yihu/iot/controller/platform/IotInterfaceController.java

@ -1,5 +1,6 @@
package com.yihu.iot.controller.platform;
import com.yihu.iot.model.AppServiceCount;
import com.yihu.iot.service.company.IotCompanyService;
import com.yihu.iot.service.platform.IotCompanyAppInterfaceService;
import com.yihu.iot.service.platform.IotInterfaceLogService;
@ -10,6 +11,7 @@ import com.yihu.jw.entity.iot.platform.IotShareInterfaceDO;
import com.yihu.jw.restmodel.iot.company.IotCompanyVO;
import com.yihu.jw.restmodel.iot.platform.IotAppInterfacesVO;
import com.yihu.jw.restmodel.iot.platform.IotInterfaceLogVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.iot.IotRequestMapping;
@ -20,6 +22,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
@ -412,7 +416,4 @@ public class IotInterfaceController extends EnvelopRestEndpoint {
    }
}

+ 29 - 0
svr/svr-iot/src/main/java/com/yihu/iot/model/AppServiceCount.java

@ -0,0 +1,29 @@
package com.yihu.iot.model;
/***
 * @ClassName: AppServiceCount
 * @Description:
 * @Auther: shi kejing
 * @Date: 2020/11/18 15:45
 */
public class AppServiceCount {
    private int count;
    private String appName;
    public int getCount() {
        return count;
    }
    public void setCount(int count) {
        this.count = count;
    }
    public String getAppName() {
        return appName;
    }
    public void setAppName(String appName) {
        this.appName = appName;
    }
}

+ 25 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/company/IotCompanyService.java

@ -1,8 +1,10 @@
package com.yihu.iot.service.company;
import com.alibaba.fastjson.JSONObject;
import com.yihu.iot.dao.company.*;
import com.yihu.iot.dao.platform.IotCompanyAppInterfaceDao;
import com.yihu.iot.dao.platform.IotInterfaceLogDao;
import com.yihu.iot.model.AppServiceCount;
import com.yihu.iot.service.useragent.UserAgent;
import com.yihu.jw.entity.iot.company.*;
import com.yihu.jw.entity.iot.platform.IotCompanyAppInterfaceDO;
@ -1157,4 +1159,27 @@ public class IotCompanyService extends BaseJpaService<IotCompanyDO,IotCompanyDao
        return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_create);
    }
    public JSONObject getAppService(){
        JSONObject object = new JSONObject();
        String str = "SELECT SUM(b.count) count,b.app_name appName\n" +
                "FROM (SELECT COUNT(id) fali,app_name,interface_name FROM xmiot.iot_interface_log  WHERE state=0 GROUP BY app_name,interface_name) c\n" +
                "RIGHT JOIN (SELECT count(id) count,app_name,interface_name,work_type FROM xmiot.iot_interface_log WHERE app_name IS NOT NULL\n" +
                "GROUP BY app_name,interface_name) b ON c.app_name=b.app_name AND c.interface_name=b.interface_name\n" +
                "GROUP BY b.app_name ORDER BY count DESC";
        String str1 = "SELECT SUM(b.count) count,b.app_name appName\n" +
                "FROM (SELECT COUNT(id) fali,app_name,interface_name FROM xmiot.iot_interface_log  WHERE state=0 GROUP BY app_name,interface_name) c\n" +
                "RIGHT JOIN (SELECT count(id) count,app_name,interface_name,work_type FROM xmiot.iot_interface_log WHERE app_name IS NOT NULL\n" +
                "GROUP BY app_name,interface_name) b ON c.app_name=b.app_name AND c.interface_name=b.interface_name\n" +
                "GROUP BY b.app_name ORDER BY count DESC limit 0,3";
        List<AppServiceCount> counts = jdbcTemplate.query(str,new BeanPropertyRowMapper<>(AppServiceCount.class));
        List<AppServiceCount> counts1 = jdbcTemplate.query(str1,new BeanPropertyRowMapper<>(AppServiceCount.class));
        object.put("appcount",counts.size());
        object.put("sortList",counts1);
        object.put("medicalcount",0);//目前暂无医疗机构接入,默认0家。
        return object;
    }
}

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

@ -3,6 +3,7 @@ package com.yihu.iot.service.monitorPlatform;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonObject;
import com.yihu.iot.dao.dict.IotSystemDictDao;
import com.yihu.iot.dao.equipment.IotEquipmentDetailDao;
import com.yihu.iot.service.common.MyJdbcTemplate;
@ -16,12 +17,14 @@ import com.yihu.jw.entity.iot.equipment.IotEquipmentDetailDO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.util.http.HttpClientUtil;
import io.swagger.annotations.ApiOperation;
import io.swagger.util.Json;
import iot.device.LocationDataVO;
import org.apache.http.Consts;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.message.BasicNameValuePair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
@ -30,6 +33,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.text.DecimalFormat;
import java.time.temporal.Temporal;
import java.util.*;
/**
@ -68,6 +72,8 @@ public class MonitorPlatformService  {
    private IotSystemDictDao iotSystemDictDao;
    @Autowired
    private IotInterfaceLogService iotInterfaceLogService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 获取位置信息
@ -1053,7 +1059,181 @@ public class MonitorPlatformService  {
            e.printStackTrace();
            return null;
        }
    }
    /**
     * 获取设备品牌以及商家品牌排行
     */
    public JSONObject getBrandsAndManufacturer(){
        try {
            String sql  = "select count(DISTINCT pd.device_name) as total,pd.device_name,wd.device_name,wd.manufacturer from wlyy.wlyy_patient_device pd,device.wlyy_devices wd \n" +
                    "where pd.device_sn = wd.device_code \n" +
                    "and wd.manufacturer_code is not null and wd.manufacturer_code <>'' \n" +
                    "group by wd.manufacturer_code \n" +
                    "ORDER BY total desc";
            List<Map<String,Object>>Manufacturers = jdbcTemplate.queryForList(sql);
            JSONObject result = new JSONObject();
            JSONArray arr = JSONArray.parseArray(JSON.toJSONString(Manufacturers));
            result.put("Manufacturers",arr);
            sql = "select count(DISTINCT pd.device_name)from wlyy.wlyy_patient_device pd,device.wlyy_devices wd \n" +
                    "where pd.device_sn = wd.device_code \n" +
                    "and wd.manufacturer_code is not null and wd.manufacturer_code <>'' \n" +
                    "ORDER BY pd.device_name desc  ";
            Integer BrandsCount = jdbcTemplate.queryForObject(sql,Integer.class);
            result.put("Brands",BrandsCount);
            result.put("manufacturerCount",arr.size());
            return result;
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }
    /**
     * 谁设备库存、使用中、总备案、物联率、失联率
     * @param deviceType
     * @param deviceName
     * @param showLevel
     * @return
     */
    public JSONObject getEquipmentStatistics(String deviceType,String deviceName,String showLevel){
        try {
            JSONObject result = new JSONObject();
            JSONArray arrTmp = new JSONArray();
            result.put("deviceInfo",arrTmp);
            result.put("iotCount",0);
            result.put("grantCount",0);
            result.put("lostContact",0);
            if (deviceType.contains("1")||deviceType.contains("2")) {
                StringBuffer sql = new StringBuffer("SELECT a.category_code type,a.device_name,a.c as 'using',b.c-a.c as 'stock',b.c as 'total' from ( ");
                StringBuffer sqlCondition = new StringBuffer();
                if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName)){
                    sqlCondition.append("and d.device_name='"+deviceName+"' ");
                }
                sql.append("SELECT d.category_code,d.device_name, COUNT(*) c from wlyy.wlyy_patient_device d,wlyy.wlyy_sign_family f WHERE f.`status`>0 and f.patient = d.`user` "+sqlCondition+" ");
                if ("0".equals(showLevel)){//组合一体机(5健康小屋,取自物联网),单体征测量仪(2血压计、1血糖仪)
                    if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)){
                        sql.append("and d.category_code in ('").append(deviceType.replace(",","','")).append("'))a, ");
                    }
                    sql.append("(SELECT d.category_code,d.device_name,COUNT(*) c from wlyy.wlyy_patient_device d where 1=1 "+sqlCondition+" ");
                    if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)){
                        sql.append("and d.category_code in ('").append(deviceType.replace(",","','")).append("'))b ");
                    }
                }
                else if("1".equals(showLevel)){ //血压计,血糖仪。。。
                    sql.append("GROUP BY d.category_code )a, ");
                    sql.append("(SELECT d.category_code,d.device_name,COUNT(*) c from wlyy.wlyy_patient_device d where 1=1 "+sqlCondition+" ");
                    sql.append("GROUP BY d.category_code )b ");
                    sql.append("WHERE a.category_code = b.category_code ");
                    if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)){
                        sql.append("and a.category_code in ('").append(deviceType.replace(",","','")).append("') ");
                    }
                }else if ("2".equals(showLevel)){//XX血压计1,XX血压计1
                    sql.append("GROUP BY d.category_code,d.device_name) a, ");
                    sql.append("(SELECT d.category_code,d.device_name,COUNT(*) c from wlyy.wlyy_patient_device d where 1=1 "+sqlCondition+" ");
                    sql.append("GROUP BY d.category_code,d.device_name) b ");
                    sql.append("WHERE a.category_code = b.category_code and a.device_name = b.device_name ");
                    if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)){
                        sql.append("and a.category_code in ('").append(deviceType.replace(",","','")).append("') ");
                    }
                }
                List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql.toString());
                JSONArray arr = JSONArray.parseArray(JSON.toJSONString(sqlResult));
                for(int i=0;i<arr.size();i++){
                    JSONObject obj = arr.getJSONObject(i);
                    if ("0".equals(showLevel)){
                        obj.put("device_name","单体征测量仪");
                        obj.put("Subdivision",true);//是否可查看下一层次
                    }
                    else if("1".equals(showLevel)){
                        String temp = obj.getString("type");
                        if("1".equals(temp)){
                            obj.put("device_name","血糖仪");
                        }else if("2".equals(temp)){
                            obj.put("device_name","血压计");
                        }
                        obj.put("Subdivision",true);
                    }
                    else{
                        obj.put("Subdivision",false);
                    }
                }
                result.put("deviceInfo",arr);//设备信息统计
                //统计物联率设备,失联设备
                sql = new StringBuffer("select count(*) from wlyy.wlyy_patient_device d ");
                sql.append("where d.device_sn in(select DISTINCT device_sn from device.wlyy_patient_health_index where device_sn<>'') "+sqlCondition+" ");
                if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)){
                    sql.append("and d.category_code in ('").append(deviceType.replace(",","','")).append("') ");
                }
                Integer iotCount = jdbcTemplate.queryForObject(sql.toString(),Integer.class);//物联设备数量
                result.put("iotCount",iotCount);
                sql = new StringBuffer("select count(*) from wlyy.wlyy_patient_device d ,wlyy.wlyy_sign_family f WHERE f.`status`>0 and f.patient = d.`user` "+sqlCondition+" ");
                if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)){
                    sql.append("and d.category_code in ('").append(deviceType.replace(",","','")).append("') ");
                }
                Integer grantCount = jdbcTemplate.queryForObject(sql.toString(),Integer.class);//设备发放总数
                result.put("grantCount",grantCount);
                //失联设备(一周未上传当作失联)
                sql.append("and d.device_sn not in (select device_sn from ( select device_sn,MAX(record_date) record_date from device.wlyy_patient_health_index where device_sn<>'' GROUP BY device_sn)a ");
                sql.append("where TIMESTAMPDIFF(DAY,record_date,NOW()) <= 7)");
                Integer lostContact = jdbcTemplate.queryForObject(sql.toString(),Integer.class);
                result.put("lostContact",lostContact);
            }
            //deviceType包含小屋且设备名称为空||deviceType包含小屋且设备名称为健康小屋。
          if ((deviceType.contains("5")&&org.apache.commons.lang3.StringUtils.isBlank(deviceName))||(deviceType.contains("5")&&org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName)&&"健康小屋".equals(deviceName))){
                String sql = "select COUNT(*) from xmiot.iot_equipmet_detail";
                Integer count = jdbcTemplate.queryForObject(sql,Integer.class);
                JSONObject tmp = new JSONObject();
                tmp.put("using",count);
                tmp.put("total",count);
                tmp.put("type","5");
                tmp.put("stock",0);
                if("0".equals(showLevel)){
                    tmp.put("device_name","组合一体机");
                    tmp.put("Subdivision",true);
                }else{
                    tmp.put("device_name","健康小屋");
                    tmp.put("Subdivision",false);
                }
                result.getJSONArray("deviceInfo").add(tmp);
                result.put("grantCount",result.getInteger("grantCount")+count);
                //统计健康小屋数据/ 小屋全部统计为正常使用
                sql ="select count(*) from xmiot.iot_equipmet_detail where device_code in (select DISTINCT sn device_model from xmiot.wlyy_iot_m)";
                count = jdbcTemplate.queryForObject(sql,Integer.class);
                result.put("iotCount",result.getInteger("iotCount")+count);//小屋物联
            }
            arrTmp = result.getJSONArray("deviceInfo");
            for (int i=0;i<arrTmp.size();i++){
                JSONObject tmp = arrTmp.getJSONObject(i);
                if (tmp.getInteger("total")==0){
                    arrTmp.remove(tmp);
                }
            }
            result.put("iotRangeString",result.getInteger("iotCount")+"/"+result.getInteger("grantCount"));
            result.put("lostRangeString",result.getInteger("lostContact")+"/"+result.getInteger("grantCount"));
            result.put("iotRange",getRange(result.getInteger("iotCount"),result.getInteger("grantCount"),2));
            result.put("lostRange",getRange(result.getInteger("lostContact"),result.getInteger("grantCount"),2));
            return result;
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }
    public String getRange(int first, int second, int i) {
        if (second == 0 && first > 0) {
            return "100%";
        } else if (second == 0 && first == 0) {
            return "0.00%";
        }
        float size = (float) (first * 100) / second;
        DecimalFormat df = new DecimalFormat("0.00");//格式化小数,不足的补0
        String filesize = df.format(size);
        return filesize + "%";
    }
}

+ 10 - 3
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/SpecialistScreenResultService.java

@ -140,9 +140,16 @@ public class SpecialistScreenResultService {
            surveyScreenResultVo.setDoctorMobile(String.valueOf(doctorList.get(0).get("mobile")));
        }
        //获取问卷详情
        String templateSql = "select t.is_third from "+basedb+".wlyy_survey_templates t where t.code = '" + templateCode + "' and t.del = 1 ";
        String thirdId = jdbcTemplate.queryForObject(templateSql, String.class);
        surveyScreenResultVo.setIsThird(thirdId);
        String templateSql = "select t.* from "+basedb+".wlyy_survey_templates t where t.code = '" + templateCode + "' and t.del = 1 ";
        List<Map<String, Object>> templateSqlList = jdbcTemplate.queryForList(templateSql);
        if (templateSqlList.size()>0){
            surveyScreenResultVo.setIsThird(templateSqlList.get(0).get("is_third").toString());
        }else {
            surveyScreenResultVo.setIsThird(null);
        }
//        String templateSql = "select t.is_third from "+basedb+".wlyy_survey_templates t where t.code = '" + templateCode + "' and t.del = 1 ";
//        String thirdId = jdbcTemplate.queryForObject(templateSql, String.class);
//        surveyScreenResultVo.setIsThird(thirdId);
        //获取转诊信息
        String reservationSql = "SELECT * FROM " + basedb + ".`wlyy_patient_reservation` r where r.relation_code = '" + code + "' and r.`status` = 1 ";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(reservationSql);