浏览代码

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

 Conflicts:
	svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/MessageUtil.java
liubing 4 年之前
父节点
当前提交
3f65caeead

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

@ -20,8 +20,6 @@ import org.springframework.stereotype.Service;
import java.util.List;
;
/**
 * Created with IntelliJ IDEA.
 *
@ -120,22 +118,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;
    }
}

+ 14 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/consult/PatientConsultEndpoint.java

@ -103,6 +103,20 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
	@Autowired
	private ConsultService consultService;
	@GetMapping(value = "findLastOnlineConsult")
	@ApiOperation(value = "获取居民该机构的最近一次在线咨询")
	public Envelop findLastOnlineConsult(
			@ApiParam(name = "orgCode", value = "机构code")
			@RequestParam(value = "orgCode",required = true) String orgCode,
			@ApiParam(name = "patient", value = "居民CODE")
			@RequestParam(value = "patient",required = true) String patient)throws Exception {
		try {
			return success("请求成功",consultService.findLastOnlineConsult(patient, orgCode));
		}catch (Exception e){
			return failedException(e);
		}
	}
	@GetMapping(value = "isExistsUnfinishedOnline")
	@ApiOperation(value = "查询居民是否存在未结束的在线咨询")
	public Envelop isExistsUnfinishedOnline(

+ 3 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/course/PatientCourseEndpoint.java

@ -179,10 +179,11 @@ public class PatientCourseEndpoint extends EnvelopRestEndpoint {
    @GetMapping("getOrgInfoById")
    @ApiOperation(value = "在线报名-获取机构详情")
    public ObjEnvelop getOrgInfoById(
            @ApiParam(name = "id", value = "机构id", defaultValue = "808080eb7861c327017861d18d070011") @RequestParam(value = "id", required = true) String id
            @ApiParam(name = "id", value = "机构id", defaultValue = "808080eb7861c327017861d18d070011") @RequestParam(value = "id", required = true) String id,
            @ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = true) String patient
    ) {
        try {
            JSONObject json = courseService.getOrgInfoById(id);
            JSONObject json = courseService.getOrgInfoById(id,patient);
            return ObjEnvelop.getSuccess("获取成功",json);
        } catch (Exception e) {
            e.printStackTrace();

+ 4 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/DoctorEndpoint.java

@ -175,10 +175,11 @@ public class DoctorEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "getNotificationCount")
    @ApiOperation(value = "教师首页-上门辅导待完成工单、在线咨询未回复、消息列表未回复")
    public ObjEnvelop getNotificationCount(
            @ApiParam(name = "doctor", value = "doctor", defaultValue = "4028030c796376b801796380a2b50003") @RequestParam(value = "doctor",required = true) String doctor,
            @ApiParam(name = "type", value = "type", defaultValue = "0") @RequestParam(value = "type",required = false) Integer type){
            @ApiParam(name = "doctor", value = "doctor", defaultValue = "4028030c796376b801796380a2b50003") @RequestParam(value = "doctor",required = true) String doctor
//            ,@ApiParam(name = "type", value = "type", defaultValue = "0") @RequestParam(value = "type",required = false) Integer type
    ){
        try {
            return ObjEnvelop.getSuccess("查询成功",doctorService.getNotificationCount(doctor,type));
            return ObjEnvelop.getSuccess("查询成功",doctorService.getNotificationCount(doctor));//,type
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败");

+ 27 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/consult/ConsultService.java

@ -23,6 +23,7 @@ import com.yihu.jw.sms.dao.HospitalSysDictDao;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
@ -69,6 +70,32 @@ public class ConsultService {
    @Autowired
    private BaseDoctorHospitalDao doctorHospitalDao;
    /**
     * 获取居民该机构的最近一次在线咨询
     * @param patient
     * @param orgCode
     */
    public Map<String,Object> findLastOnlineConsult(String patient,String orgCode){
        Map<String,Object> map = new HashedMap();
        String sql = "SELECT " +
                " b.consult, " +
                " b.type,b.status " +
                "FROM " +
                " wlyy_consult_team b, " +
                " base_doctor_hospital h " +
                "WHERE " +
                " b.doctor = h.doctor_code " +
                "AND b.patient = '"+patient+"' " +
                "AND b.type = 23 "+
                "AND h.org_code = '"+orgCode+"' ORDER BY b.czrq desc LIMIT 1 ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        if(list.size()>0){
            map = list.get(0);
            map.put("sessionId",String.valueOf(map.get("consult"))+"_"+patient+"_23");
        }
        return map;
    }
    /**
     * 居民结束咨询
     * @param consult 咨询CODE

+ 19 - 1
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 +"";
@ -650,7 +653,7 @@ public class CourseService {
        return object;
    }
    public JSONObject getOrgInfoById(String id){
    public JSONObject getOrgInfoById(String id,String patient){
        JSONObject object = new JSONObject();
        String sql = "SELECT o.id,rs.id recruitId,o.`code`,o.`name`,o.mobile,o.photo,o.address,o.brief,rs.start_time startTime,rs.end_time endTime,rs.num,rs.fee,rs.id rsId \n" +
                "FROM base_org o,base_recruit_students rs\n" +
@ -700,6 +703,17 @@ public class CourseService {
            }
            object.put("count",count);//已报名人数
            //判断用户是否已录取
            String statusSql = "SELECT rsr.`status` status FROM base_recruit_students rs , base_recruit_students_record rsr WHERE rs.id = rsr.recruit_students_id AND rs.del = 1 AND rsr.org_code = rs.org_code AND rsr.org_code = '"+mapList.get(0).get("code")+"' AND rsr.patient = '"+patient+"'";
            List<Map<String , Object>> status = jdbcTemplate.queryForList(statusSql);
            if (status.size() == 0){
                object.put("status",0); //未报名
            }else {
                object.put("status",status.get(0).get("status")); //未报名
            }
        }else {
            String sql1 = "SELECT o.id,o.`code`,o.`name`,o.mobile,o.photo,o.address,o.brief " +
                    "FROM base_org o " +
@ -719,6 +733,7 @@ public class CourseService {
            }else {
                object.put("allDoctor","");//教师
            }
            object.put("num",-1);//招生名额(未开放报名)
        }
        return object;
    }
@ -832,6 +847,9 @@ public class CourseService {
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put("recordDO",recordDO);
        //这个机构收到新的在线报名申请时,给机构联系人发送一条短信
        messageUtil.sendOnlineRegistSms(recruitStudentsDO.getOrgCode());
        return result;
    }

+ 8 - 6
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doctor/CareDoctorService.java

@ -301,19 +301,21 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
        return result;
    }
    public JSONObject getNotificationCount(String doctor,Integer type){
    public JSONObject getNotificationCount(String doctor){ //,Integer type
        JSONObject object = new JSONObject();
        // 上门辅导工单 待完成
        List<BaseDoorCoachOrderDO> coachOrderDOList = baseDoorCoachOrderDao.getUnFinishOrderByDoctor(doctor);
        if (type > 0){
            return object;
        }else {
//        if (type > 0){
//            return object;
//        }else {
            Integer unreadMessageCount = imService.SessionsUnreadMessageCountByUserId(doctor);
            object.put("unreadMessageCount",unreadMessageCount);
            object.put("unreadMessageCount",unreadMessageCount);//未读消息数量
            object.put("doorCoachOrder",coachOrderDOList.size());//上门辅导待完成数量
            Integer unConsultMsgCount = imService.SessionsUnreadMessageCount(doctor,"23");
            object.put("unConsultMsgCount",unConsultMsgCount);//咨询未读消息数量
            return object;
        }
//        }
    }
}

+ 18 - 4
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,9 +169,7 @@ public class MessageUtil {
        }
    }
    public String sendTXYSJson(String templateCode,String mobile,String ...params)throws Exception{
        //974597 未回复消息通知 短信内容 -- {1}您好,您的云照护平台有{2}条信息未回复,请及时处理。
        //974603 上门辅导通知 您有一条新的上门辅导申请,请进入调度平台处理。
    public String sendTXYSJson(String templateCode,String mobile,String ...params){
        JSONObject sendObj = new JSONObject();
        sendObj.put("templateCode",templateCode);
        if (params.length>0){
@ -165,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){