瀏覽代碼

集美宣教代码提交

liuwenbin 7 年之前
父節點
當前提交
63fef04f6b

+ 116 - 116
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/activemq/HealthArtListener.java

@ -1,116 +1,116 @@
//package com.yihu.wlyy.activemq;
//
//import com.yihu.es.entity.HealthEduArticlePatient;
//import com.yihu.wlyy.entity.patient.Patient;
//import com.yihu.wlyy.service.app.consult.ConsultService;
//import com.yihu.wlyy.service.common.account.PatientService;
//import com.yihu.wlyy.task.PushMsgTask;
//import com.yihu.wlyy.util.DateUtil;
//import com.yihu.wlyy.util.ImUtill;
//import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
//import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
//import net.sf.json.JSONObject;
//import org.apache.commons.lang3.StringUtils;
//import org.json.JSONArray;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//import javax.jms.JMSException;
//import javax.jms.Message;
//import javax.jms.MessageListener;
//import javax.jms.TextMessage;
//import java.util.List;
//
///**
// * Created by chenweida on 2017/9/9.
// * 健康教育文章监听
// */
//@Component
//public class HealthArtListener implements MessageListener {
//    private Logger logger = LoggerFactory.getLogger(HealthArtListener.class);
//
//    @Autowired
//    private WeiXinOpenIdUtils weiXinOpenIdUtils;
//    @Autowired
//    private PushMsgTask pushMsgTask;
//    @Autowired
//    private PatientService patientService;
//    @Autowired
//    private ConsultService consultService;
//    @Autowired
//    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
//
//    @Override
//    public void onMessage(Message message) {
//        try {
//            TextMessage textMessage = (TextMessage) message;
//            HealthEduArticlePatient healthEduArticlePatient = (HealthEduArticlePatient)JSONObject.toBean(JSONObject.fromObject(textMessage.getText()),HealthEduArticlePatient.class);
////            logger.info(jo.toString());
//            sendWxTemplateAndIM(healthEduArticlePatient);
//            //返回服务器表示消息消费成功
//            message.acknowledge();
//        } catch (JMSException e) {
//            e.printStackTrace();
//        }
//    }
//
//
//    //发送到IM和微信消息模板
//    private void sendWxTemplateAndIM(HealthEduArticlePatient one) {
//        String endMsg = "";//"为了您的健康," + doctor.getName() + "医生给您发送了一篇患教文章,请仔细查阅,如有问题,可随时咨询医生。";
//
////        healthEduArticlePatients.stream().forEach(one -> {
//            Patient patient = patientService.findByCode(one.getPatient());
//            try {
//                //卫纪委发送不推IM
//                if (1 == one.getSendType()) {
//                    consultService.sendMucMessageBySingnType(one.getSendCode(), one.getSendName(), patient.getCode(), "{\"title\":\"" + one.getAttachedTitle() + "\",\"type\":0,\"id\":\"" + one.getId() + "\",\"img\":\"" + one.getAttachedPic() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}", "4", patient.getName());
//                    if (StringUtils.isNotBlank(one.getAttachedMessage())) {
//                        //发送备注
//                        consultService.sendMucMessageBySingnType(one.getSendCode(), one.getSendName(), patient.getCode(), one.getAttachedMessage(), ImUtill.CONTENT_TYPE_TEXT, patient.getName());
//                    }
//                }
//                // 推送消息给微信端
//                org.json.JSONObject json = new org.json.JSONObject();
//                json.put("first", patient.getName() + ",您好! " + one.getSendName() + (one.getSendType()==2 ? "卫计委":"医生") +"给您发来了一篇患教文章");
//                json.put("toUser", patient.getCode());
//                json.put("article", one.getArticleId() + "");
//                json.put("title", one.getAttachedTitle());
//                json.put("doctorName", one.getSendName()+(one.getSendType()==2 ? "卫计委":"医生"));
//                json.put("represented", patient.getCode());//被代理人
//                json.put("date", DateUtil.dateToStrLong(DateUtil.getNowDate()));
//                json.put("remark", org.springframework.util.StringUtils.isEmpty(one.getAttachedMessage()) ? "  " : one.getAttachedMessage());
//                json.put("articleUrl",one.getArticleUrl());
//                if (StringUtils.isNotBlank(patient.getOpenid())) {
//                    pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 9,
//                            patient.getOpenid(),
//                            patient.getName(),
//                            json);
//                }
//                //发送代理人
//                JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient.getCode(), patient.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");
//                        json.remove("toUser");
//                        json.put("toUser", member.getCode());
//                        json.remove("first");
//                        try {
//                            json.put("first", weiXinOpenIdUtils.getTitleMes(patient, j.isNull("relation") ? 1 : j.getInt("relation"), patient.getName()));
//                        } catch (Exception e) {
//                            e.printStackTrace();
//                        }
//                        if (StringUtils.isNotBlank(member.getOpenid())) {
//                            pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 9, member.getOpenid(), patient.getName(), json);
//                        }
//                    }
//                }
//            } catch (Exception e) {
//                logger.error("patient:" + patient.getCode() + "," + e.getMessage());
//            }
////        });
//    }
//}
package com.yihu.wlyy.activemq;
import com.yihu.es.entity.HealthEduArticlePatient;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.service.app.consult.ConsultService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.ImUtill;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import net.sf.json.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
import java.util.List;
/**
 * Created by chenweida on 2017/9/9.
 * 健康教育文章监听
 */
@Component
public class HealthArtListener implements MessageListener {
    private Logger logger = LoggerFactory.getLogger(HealthArtListener.class);
    @Autowired
    private WeiXinOpenIdUtils weiXinOpenIdUtils;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private PatientService patientService;
    @Autowired
    private ConsultService consultService;
    @Autowired
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Override
    public void onMessage(Message message) {
        try {
            TextMessage textMessage = (TextMessage) message;
            HealthEduArticlePatient healthEduArticlePatient = (HealthEduArticlePatient)JSONObject.toBean(JSONObject.fromObject(textMessage.getText()),HealthEduArticlePatient.class);
//            logger.info(jo.toString());
            sendWxTemplateAndIM(healthEduArticlePatient);
            //返回服务器表示消息消费成功
            message.acknowledge();
        } catch (JMSException e) {
            e.printStackTrace();
        }
    }
    //发送到IM和微信消息模板
    private void sendWxTemplateAndIM(HealthEduArticlePatient one) {
        String endMsg = "";//"为了您的健康," + doctor.getName() + "医生给您发送了一篇患教文章,请仔细查阅,如有问题,可随时咨询医生。";
//        healthEduArticlePatients.stream().forEach(one -> {
            Patient patient = patientService.findByCode(one.getPatient());
            try {
                //卫纪委发送不推IM
                if (1 == one.getSendType()) {
                    consultService.sendMucMessageBySingnType(one.getDoctorCode(), one.getDoctorName(), patient.getCode(), "{\"title\":\"" + one.getAttachedTitle() + "\",\"type\":0,\"id\":\"" + one.getId() + "\",\"img\":\"" + one.getAttachedPic() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}", "4", patient.getName());
                    if (StringUtils.isNotBlank(one.getAttachedMessage())) {
                        //发送备注
                        consultService.sendMucMessageBySingnType(one.getDoctorCode(), one.getDoctorName(), patient.getCode(), one.getAttachedMessage(), ImUtill.CONTENT_TYPE_TEXT, patient.getName());
                    }
                }
                // 推送消息给微信端
                org.json.JSONObject json = new org.json.JSONObject();
                json.put("first", patient.getName() + ",您好! " + one.getSendName() + (one.getSendType()==2 ? "卫计委":"医生") +"给您发来了一篇患教文章");
                json.put("toUser", patient.getCode());
                json.put("article", one.getArticleId() + "");
                json.put("title", one.getAttachedTitle());
                json.put("doctorName", one.getDoctorName()+(one.getSendType()==2 ? "卫计委":"医生"));
                json.put("represented", patient.getCode());//被代理人
                json.put("date", DateUtil.dateToStrLong(DateUtil.getNowDate()));
                json.put("remark", org.springframework.util.StringUtils.isEmpty(one.getAttachedMessage()) ? "  " : one.getAttachedMessage());
                json.put("articleUrl",one.getArticleUrl());
                if (StringUtils.isNotBlank(patient.getOpenid())) {
                    pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 9,
                            patient.getOpenid(),
                            patient.getName(),
                            json);
                }
                //发送代理人
                JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient.getCode(), patient.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");
                        json.remove("toUser");
                        json.put("toUser", member.getCode());
                        json.remove("first");
                        try {
                            json.put("first", weiXinOpenIdUtils.getTitleMes(patient, j.isNull("relation") ? 1 : j.getInt("relation"), patient.getName()));
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isNotBlank(member.getOpenid())) {
                            pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 9, member.getOpenid(), patient.getName(), json);
                        }
                    }
                }
            } catch (Exception e) {
                logger.error("patient:" + patient.getCode() + "," + e.getMessage());
            }
//        });
    }
}

+ 1 - 1
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/task/PushMsgTask.java

@ -460,7 +460,7 @@ public class PushMsgTask {
                //如果是ArticleUrl不为空,那就说明是外部系统推送文章(如:集美宣教)
                String articleUrl = json.has("articleUrl") ? json.getString("articleUrl") : null;
                if(StringUtils.isNotEmpty(articleUrl)){
                    temp.setUrl(articleUrl);
                    temp.setUrl(url + "jkjy/html/article2.html?openid=" + openid + "&dataId=" + json.getString("article") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented"));
                }
                temp_id = template_healthy_article;
                temp.setTemplate_id(temp_id);

+ 16 - 16
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/fastdfs/FastDFSClientPool.java

@ -91,6 +91,22 @@ public class FastDFSClientPool {
        return null;
    }
    public void releaseStorageClient(StorageClient client) {
        if (client == null) {
            return;
        }
        try {
            if(map.containsKey(client)) {
                    map.put(client, true);
            } else {
                client =null;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public synchronized StorageClient getStorageClient() {
        StorageClient client = null;
        try {
@ -115,20 +131,4 @@ public class FastDFSClientPool {
        }
        return client;
    }
    public void releaseStorageClient(StorageClient client) {
        if (client == null) {
            return;
        }
        try {
            if(map.containsKey(client)) {
                    map.put(client, true);
            } else {
                client =null;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

+ 23 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/LoginController.java

@ -175,6 +175,25 @@ public class LoginController extends BaseController {
                    //获取医生角色和区域权限
                    List<Map<String, String>> roleMap = roleService.getUserRoleAndArea(doctor.getCode());
                    map.put("userRole", roleMap);
                    //医生当前登录的角色
                    if(roleMap.size()>0){
                        for(Map<String, String> one:roleMap){
                            if("1".equals(one.get("isManage"))){
                                map.put("currentUserRole", one);
                                continue;
                            }
                        }
                    }else{
                        Map<String, String> one = new HashMap<>();
                        one.put("isManage","0");
                        map.put("code", doctor.getHospital());
                        map.put("name", doctor.getHospitalName());
                        map.put("areas", "");
                        map.put("level","4");
                        map.put("authOperate", "0");
                        map.put("currentUserRole", one);
                    }
                    if ("10" .equals(doctor.getLevel()) && roleMap.size() == 0) {
                        errorMessage = "该用户没有管理员权限";
                        loginLog.setErrorMessage(errorMessage);
@ -252,7 +271,7 @@ public class LoginController extends BaseController {
                    List<Map<String, String>> roleMap = roleService.getUserRoleAndArea(doctor.getCode());
                    map.put("userRole", roleMap);
                    //医生当前登录的角色
                    if(roleMap.size()>0){
                     if(roleMap.size()>0){
                        for(Map<String, String> one:roleMap){
                            if("1".equals(one.get("isManage"))){
@ -261,14 +280,14 @@ public class LoginController extends BaseController {
                            }
                        }
                    }else{
                        Map<String, String> one = new HashMap<>();
                        one.put("isManage","0");
//                        Map<String, String> one = new HashMap<>();
                        map.put("isManage","0");
                        map.put("code", doctor.getHospital());
                        map.put("name", doctor.getHospitalName());
                        map.put("areas", "");
                        map.put("level","4");
                        map.put("authOperate", "0");
                        map.put("currentUserRole", one);
                        map.put("currentUserRole", map);
                    }
                    if ("10" .equals(doctor.getLevel()) && roleMap.size() == 0) {
                        errorMessage = "改用户没有管理员权限";

+ 5 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/jimeiJkEduPC/DoctorJMJkEduArticlePCController.java

@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.InputStream;
import java.util.List;
/**
@ -273,13 +274,15 @@ public class DoctorJMJkEduArticlePCController extends BaseController {
    @RequestMapping(value = "uploadArticleImag", method = RequestMethod.POST)
    @ApiOperation("编辑文章上传图片")
    public String pushArticleList(@ApiParam(name = "file", value = "文件", required = true)
                                   @RequestParam(value = "file", required = false) MultipartFile file){
                                   @RequestParam(value = "file", required = true) MultipartFile file){
//        temp=new File(FileUploadUtil.getTomcatLogDir()+System.currentTimeMillis()+file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf('.')-1));
//        file.transferTo(temp);
        try {
            ObjectNode imgNode = FastDFSUtil.upload(file.getInputStream(),"png",file.getOriginalFilename());
            InputStream inputStream  = file.getInputStream();
            String fileName = file.getOriginalFilename().substring(0,file.getOriginalFilename().lastIndexOf("."));
            ObjectNode imgNode = FastDFSUtil.upload(inputStream,"png",fileName);
            String fileUrl = fastdfs_file_url + imgNode.get("groupName").toString().replaceAll("\"","")
                    + "/" + imgNode.get("remoteFileName").toString().replaceAll("\"","");

+ 2 - 2
patient-co/patient-co-wlyy/src/main/resources/config/fdfs_client.conf

@ -9,11 +9,11 @@ http.secret_key = FastDFS1234567890
#tracker_server = 172.19.103.54:22122
#-------------测试环境---------------#
#tracker_server = 172.19.103.54:22122
tracker_server = 172.19.103.54:22122
#-------------正式环境---------------#
#外网项目地址
tracker_server = 192.168.120.172:22122
#tracker_server = 192.168.120.172:22122
#网闸
#tracker_server = 59.61.92.90:9055
#内网项目地址