Browse Source

代码修改

yeshijie 7 years ago
parent
commit
0534e0d7c8

+ 37 - 12
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/SMSService.java

@ -1,35 +1,34 @@
package com.yihu.wlyy.service.common;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.message.SMS;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.message.SMSDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.SystemConf;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.yihu.wlyy.entity.message.SMS;
import com.yihu.wlyy.repository.message.SMSDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.SystemConf;
import org.springframework.util.StringUtils;
import javax.print.Doc;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Component
@Transactional(rollbackFor = Exception.class)
@ -45,6 +44,32 @@ public class SMSService extends BaseService {
    DoctorDao doctorDao;
    @Autowired
    private HttpClientUtil HttpClientUtil;
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Value("${pushMes.redis_prescription_title}")
    private String redisQueue;
    /**
     * 内网通过redis的队列发送
     * @param mobile
     * @param ip
     * @param type
     * @return
     */
    public String sendToNeiWang(String mobile, String ip, int type){
        com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
        json.put("mobile",mobile);
        json.put("ip",ip);
        json.put("type",type);
        json.put("time",DateUtil.getStringDate());
        com.alibaba.fastjson.JSONObject mes = new com.alibaba.fastjson.JSONObject();
        mes.put("title", "sendSms");
        mes.put("value", json.toString());
        redisTemplate.opsForList().leftPush(redisQueue, mes.toString());
        return  "ok";
    }
    /**
     * 发送短信验证码接口

+ 10 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/sms/SMSController.java

@ -3,6 +3,7 @@ package com.yihu.wlyy.web.common.sms;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@ -30,6 +31,8 @@ public class SMSController extends BaseController {
	private PatientDao patientDao;
	@Autowired
	private DoctorDao doctorDao;
	@Value("${spring.profiles}")
	private String springProfiles;
	/**
	 * 发送短信验证码接口
@ -73,7 +76,13 @@ public class SMSController extends BaseController {
				return error(-1, "无效的ip请求!");
			}
//			String res = smsService.send(mobile, ip, type, getUID());
			String res = smsService.send(mobile, ip, type, getRepUID());
			String res = null;
			//内网发送 通过redis的队列
			if("local".equals(springProfiles)){
				res = smsService.sendToNeiWang(mobile, ip, type);
			}else {
				res = smsService.send(mobile, ip, type, getRepUID());
			}
			if (StringUtils.equals(res, "ok")) {
				return write(200, "验证码短信已发送!");
			} else {

+ 1 - 1
patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml

@ -98,7 +98,7 @@ pushMes:
# 1为推送redis,0为推送消息队列
  method: 0
  # redis队列名称
  redis_prescription_title: redisPrescription
  redis_prescription_title: redisMessage
es:
  index:
    HealthEduArticlePatient: health_edu_article_patient_test4

+ 1 - 1
patient-co/patient-co-wlyy/src/main/resources/application-local.yml

@ -96,7 +96,7 @@ pushMes:
# 1为推送redis,0为推送消息队列
  method: 1
  # redis队列名称
  redis_prescription_title: redisPrescription
  redis_prescription_title: redisMessage
es:
  index:
    HealthEduArticlePatient: health_edu_article_patient_test

+ 1 - 1
patient-co/patient-co-wlyy/src/main/resources/application-prod.yml

@ -96,7 +96,7 @@ pushMes:
# 1为推送redis,0为推送消息队列
  method: 0
  # redis队列名称
  redis_prescription_title: redisPrescription
  redis_prescription_title: redisMessage
es:

+ 1 - 1
patient-co/patient-co-wlyy/src/main/resources/application-test.yml

@ -94,7 +94,7 @@ pushMes:
# 1为推送redis,0为推送消息队列
  method: 0
  # redis队列名称
  redis_prescription_title: redisPrescription
  redis_prescription_title: redisMessage
es:
  index: