فهرست منبع

Merge branch 'dev' of yeshijie/patient-co-management into dev

yeshijie 7 سال پیش
والد
کامیت
422c05b2b4

+ 5 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/redis/RedisThread.java

@ -2,6 +2,7 @@ package com.yihu.wlyy.redis;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.service.app.prescription.PrescriptionService;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.SystemConf;
import org.apache.commons.lang3.StringUtils;
@ -34,6 +35,8 @@ public class RedisThread implements Runnable {
    private PrescriptionService prescriptionService;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private SMSService smsService;
    //redis链接池
    private JedisPool pool;
    private Jedis jedis;
@ -100,6 +103,8 @@ public class RedisThread implements Runnable {
                //线下调整处方完成
                String prescriptionCode = json.getString("prescription");
                prescriptionService.setPrescriptionInfo(prescriptionCode);
            }else if("sendSms".equals(title)){
                smsService.sendSms(json.getJSONObject("value"));
            }
        }catch (Exception e){
            logger.error("redis_error...",e);

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

@ -1,40 +1,42 @@
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.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)
public class SMSService extends BaseService {
    private static Logger logger = LoggerFactory.getLogger(SMSService.class);
    @Autowired
    public SMSDao smsDao;
    @Autowired
@ -45,6 +47,25 @@ public class SMSService extends BaseService {
    DoctorDao doctorDao;
    @Autowired
    private HttpClientUtil HttpClientUtil;
    @Value("${server.server_url}")
    private String server_url;
    public void sendSms(com.alibaba.fastjson.JSONObject json){
        String time = json.getString("time");
        String now = DateUtil.dateToStrLong(DateUtil.getNextMin(new Date(),-30));
        //超过30分钟之前的就不发送了
        if(time.compareTo(now)>0){
            String url = server_url+"common/captcha";
            List<NameValuePair> par = new ArrayList<NameValuePair>();
            par.add(new BasicNameValuePair("mobile", json.getString("mobile")));
            par.add(new BasicNameValuePair("type", json.getString("type")));
            String result = HttpClientUtil.post(url,par,"UTF-8");
            logger.info("发送短信消息返回结果:"+result);
        }
    }
    /**
     * 发送短信验证码接口

+ 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: