Procházet zdrojové kódy

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

# Conflicts:
#	common/common-entity/sql记录
yeshijie před 3 roky
rodič
revize
e0b1668fe5

+ 3 - 11
business/sms-service/src/main/java/com/yihu/jw/sms/service/TXYSmsService.java

@ -120,22 +120,14 @@ public class TXYSmsService {
    /**
     *
     * @param mobile
     * @param str {"templateCode":"974603","templateParamArr":["param1","param2","param3"]}
     * @param jsonObj {"templateCode":"974603","templateParamArr":["param1","param2","param3"]}
     * @return   模板id暂时写死
     */
    public String sendMessageJson(String mobile,String str){
    public String sendMessageJson(String mobile,JSONObject jsonObj){
        try {
            init();
            Credential cred = new Credential(SecretId, SecretKey);
            JSONObject jsonObj = new JSONObject();
            try {
                jsonObj = JSONObject.parseObject(str);
                logger.info("字符串转JSONObject报错:"+str);
            }catch (Exception e){
                return "error";
            }
//            String templateId = redisTemplate.opsForValue().get(key + ":"+jsonObj.getString("templateCode"));
            String templateId = jsonObj.getString("templateCode");
            JSONArray templateParamArr = jsonObj.getJSONArray("templateParamArr");
            String[] templateParamSet1 = templateParamArr.toArray(new String[0]);

+ 0 - 1
svr/svr-cloud-care/src/main/java/com/yihu/SvrCloudCareApplication.java

@ -4,7 +4,6 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
/**

+ 54 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/config/AsyncConfig.java

@ -0,0 +1,54 @@
package com.yihu.jw.care.config;
import org.apache.tomcat.util.threads.ThreadPoolExecutor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
/**
 * Created by yeshijie
 * 启用多綫程
 */
@Configuration
@EnableAsync
public class AsyncConfig {
    /**
     * 如果池中的实际线程数小于corePoolSize,无论是否其中有空闲的线程,都会给新的任务产生新的线程
     */
    private int corePoolSize = 5;
    /**
     * 如果池中的线程数=maximumPoolSize,则有空闲线程使用空闲线程,否则新任务放入queueCapacity.
     * 设定 比 系统native thread个数要大的话,会优先抛出Java.lang.OutOfMemoryError: unable to create new native thread
     */
    private int maxPoolSize = 10;
    /**
     * 缓冲队列大小
     */
    private int queueCapacity = 100;
    /**
     * 线程池维护线程所允许的空闲时间  秒
     */
    private int keepAliveSeconds = 300;
    @Bean
    public Executor wlyyExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(corePoolSize);
        executor.setMaxPoolSize(maxPoolSize);
        executor.setQueueCapacity(queueCapacity);
        executor.setKeepAliveSeconds(keepAliveSeconds);
        /** Reject策略预定义有四种:
         (1)ThreadPoolExecutor.AbortPolicy策略,是默认的策略,处理程序遭到拒绝将抛出运行时 RejectedExecutionException。
         (2)ThreadPoolExecutor.CallerRunsPolicy策略 ,调用者的线程会执行该任务,如果执行器已关闭,则丢弃.
         (3)ThreadPoolExecutor.DiscardPolicy策略,不能执行的任务将被丢弃.
         (4)ThreadPoolExecutor.DiscardOldestPolicy策略,如果执行程序尚未关闭,则位于工作队列头部的任务将被删除,然后重试执行程序(如果再次失败,则重复此过程).
         */
        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
        executor.initialize();
        return executor;
    }
}

+ 6 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/course/CourseService.java

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.dao.course.*;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
@ -65,6 +66,8 @@ public class CourseService {
    private ObjectMapper objectMapper;
    @Autowired
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
    @Autowired
    private MessageUtil messageUtil;
    public String getOrderNo(String type){
        return type + System.currentTimeMillis()+(int)(Math.random() * 900)+100 +"";
@ -832,6 +835,9 @@ public class CourseService {
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put("recordDO",recordDO);
        //这个机构收到新的在线报名申请时,给机构联系人发送一条短信
        messageUtil.sendOnlineRegistSms(recruitStudentsDO.getOrgCode());
        return result;
    }

+ 18 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/MessageUtil.java

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.wx.WxAccessTokenDO;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.entity.care.doorCoach.BaseDoorCoachOrderDO;
@ -12,6 +13,7 @@ import com.yihu.jw.entity.care.lifeCare.LifeCareOrderDO;
import com.yihu.jw.entity.care.securitymonitoring.SecurityMonitoringOrderDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.sms.service.TXYSmsService;
import com.yihu.jw.util.http.HttpClientUtil;
@ -27,6 +29,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import java.util.Date;
@ -62,10 +65,23 @@ public class MessageUtil {
    @Autowired
    private BasePatientDao basePatientDao;
    @Autowired
    private BaseOrgDao orgDao;
    @Autowired
    private TXYSmsService txySmsService;
    //发送微信模板消息
    private  String sendMessageUrl = "http://172.16.100.37:8090/hospitalPortal-sms/sms/sendMessage";
    /**
     * 您好{1}有一条新的在线报名申请,请及时前往APP消息应用进行处理。
     * @param orgCode
     */
    @Async
    public void sendOnlineRegistSms(String orgCode){
        BaseOrgDO orgDO = orgDao.findByCode(orgCode);
        if(StringUtils.isNotBlank(orgDO.getMobile())){
            sendTXYSJson("976005",orgDO.getMobile(),orgDO.getName());
        }
    }
    /**
     *
@ -153,7 +169,7 @@ public class MessageUtil {
        }
    }
    public String sendTXYSJson(String templateCode,String mobile,String ...params)throws Exception{
    public String sendTXYSJson(String templateCode,String mobile,String ...params){
        JSONObject sendObj = new JSONObject();
        sendObj.put("templateCode",templateCode);
        if (params.length>0){
@ -163,7 +179,7 @@ public class MessageUtil {
            JSONArray paramArr =new JSONArray();
            sendObj.put("templateParamArr",paramArr);
        }
        return txySmsService.sendMessageJson(mobile,sendObj.toJSONString());
        return txySmsService.sendMessageJson(mobile,sendObj);
    }
    public WxTemplateConfigDO setTemPlateUrl(WxTemplateConfigDO wxTemplateConfigDO,Integer type,String openid,JSONObject json){