| 
					
				 | 
			
			
				@ -34,6 +34,7 @@ import org.slf4j.LoggerFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.text.SimpleDateFormat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.Date; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.Map; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -72,7 +73,7 @@ public class ConsultTeamService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PatientDoorCoachOrderService patientDoorCoachOrderService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private TXYSmsService txySmsService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private MessageUtil messageUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private Logger logger= LoggerFactory.getLogger(ConsultTeamService.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -318,15 +319,10 @@ public class ConsultTeamService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //发送短信给调度员 您有一条新的上门辅导申请,请进入调度平台处理。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            BaseDoctorDO doctorDO = doctorDao.findById(tmp.get("code").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (doctorDO.getMobile()!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                JSONObject sendObj = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sendObj.put("templateCode","VerificationCode"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                JSONArray paramArr = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                paramArr.add("123123123123"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                sendObj.put("templateParamArr",paramArr); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    txySmsService.sendMessageJson(doctorDO.getMobile(),sendObj.toJSONString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    messageUtil.sendTXYSJson("974603",doctorDO.getMobile()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    logger.info("发送腾讯短信给调度员报错:{"+doctorDO.getMobile()+"},"+sendObj.toJSONString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    logger.info("发送腾讯短信给调度员报错:{"+doctorDO.getMobile()+"}"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -511,5 +507,159 @@ public class ConsultTeamService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public int finishConsult(String consult, String endOperator, int endType) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        ConsultTeamDo consultTeam = consultTeamDao.findByConsult(consult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        ConsultDo cons = consultDao.findOne(consult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (consultTeam.getStatus() == 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return -1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        //新增续方咨询结束判断 (续方未审核时不可由医生或居民关闭) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        if (consultTeam.getType() == 8) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            Prescription prescription = prescriptionDao.findByCode(consultTeam.getRelationCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            if (prescription.getStatus() == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                return -2; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String endName = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String endId = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //结束咨询才发送推送给IM文字消息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (endType == 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            BasePatientDO p = patientDao.findById(endOperator); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            endName = p.getName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            endId = p.getId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (endOperator.equals("admin")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                endId = "system"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                endName = "咨询超时未回复,系统自动"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                BaseDoctorDO d = doctorDao.findOne(endOperator); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                endId = d.getId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                endName = d.getName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject obj = imUtill.endTopics(consultTeam.getPatient(), endId, endName, consultTeam.getConsult()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (obj == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            throw new RuntimeException("IM消息结束异常!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (obj.getInteger("status") == -1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            throw new RuntimeException(String.valueOf(obj.get("message"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //结束咨询才发送推送给IM文字消息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        if (endType == 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            BasePatientDO p = patientDao.findOne(endOperator); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            endName = p.getName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            if (consultTeam.getType() == 2 || consultTeam.getType() == 8) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                String openId = p.getOpenid(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_doctor_survey", "zxpj"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                String first = templateConfig.getFirst(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                first = first.replace("key1", (endName == null ? "" : endName)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                String keyword1 = templateConfig.getKeyword1(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                org.json.JSONObject json = new org.json.JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                json.put("keyword1", keyword1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                json.put("keyword2", sdf.format(new Date())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                json.put("toUser", p.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                json.put("represented", p.getCode());//被代理人 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                json.put("remark", ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                json.put("consult", consult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                if (consultTeam.getType() == 8) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    first = first.replace("key2", "续方"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    first = first.replace("key2", ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                json.put("first", first); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                if (StringUtils.isNotBlank(p.getOpenid())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    pushMsgTask.putWxMsg(accessTokenUtils.getAccessToken(), 17, openId, p.getName(), json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    //发送代理人 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    org.json.JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(p.getCode(), p.getOpenid()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    if (jsonArray != null && jsonArray.length() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        for (int i = 0; i < jsonArray.length(); i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                            org.json.JSONObject j = jsonArray.getJSONObject(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                            Patient member = (Patient) j.get("member"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                            org.json.JSONObject data = json; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                            data.remove("toUser"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                            data.put("toUser", member.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                            data.remove("first"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                            data.put("first", weiXinOpenIdUtils.getTitleMes(p, j.getInt("relation"), p.getName()) + first); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                            pushMsgTask.putWxMsg(accessTokenUtils.getAccessToken(), 17, member.getOpenid(), p.getName(), data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            if (consultTeam.getType() == 2 || consultTeam.getType() == 8) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                Patient p = patientDao.findByCode(consultTeam.getPatient()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                String name = p.getName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                String openId = p.getOpenid(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_doctor_survey", "zxpj"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                if (endOperator.equals("admin")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    templateConfig = templateConfigDao.findByScene("template_doctor_survey", "zxcspj"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                String first = templateConfig.getFirst(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                first = first.replace("key1", (name == null ? "" : name)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                String keyword1 = templateConfig.getKeyword1(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                org.json.JSONObject json = new org.json.JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                json.put("keyword1", keyword1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                json.put("keyword2", sdf.format(new Date())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                json.put("toUser", p.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                json.put("represented", p.getCode());//被代理人 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                json.put("remark", ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                json.put("consult", consult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                if (consultTeam.getType() == 8) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    first += "续方"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    first = first.replace("key2", "续方"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    first = first.replace("key2", ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                /*if (endOperator.equals("admin")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    first += "咨询超时未回复,系统自动关闭,请及时对咨询医生进行评价。"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    first += "咨询已结束,请及时对咨询医生进行评价。"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                }*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                json.put("first", first); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                if (StringUtils.isNotBlank(p.getOpenid())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    pushMsgTask.putWxMsg(accessTokenUtils.getAccessToken(), 17, openId, p.getName(), json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    //发送代理人 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    org.json.JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(p.getCode(), p.getOpenid()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    if (jsonArray != null && jsonArray.length() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        for (int i = 0; i < jsonArray.length(); i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                            org.json.JSONObject j = jsonArray.getJSONObject(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                            Patient member = (Patient) j.get("member"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                            org.json.JSONObject data = json; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                            data.remove("toUser"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                            data.put("toUser", member.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                            data.remove("first"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                            data.put("first", weiXinOpenIdUtils.getTitleMes(p, j.getInt("relation"), p.getName()) + first); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                            pushMsgTask.putWxMsg(accessTokenUtils.getAccessToken(), 17, member.getOpenid(), p.getName(), data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        consultTeam.setEndMsgId(obj.getString("id")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        cons.setEndTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        consultTeam.setEndTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        consultTeam.setStatus(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        consultDao.save(cons); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        consultTeamDao.save(consultTeam); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |