Kaynağa Gözat

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

trick9191 7 yıl önce
ebeveyn
işleme
8ac9f9590e

+ 1 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/team/sign/DoctorTeamMember.java

@ -22,7 +22,7 @@ public class DoctorTeamMember extends IdEntity {
    private String memberCode;
    private String code;
    private String name;
    private Integer type;//医生类型:1服务医生
    private Integer type;//医生类型:1专科医生,2全科医生,3健康管理师,4临时专科;5居民
    private Date czrq;
    private String del;//是否作废,1正常,0作废
    private String signType;//签约类型(1表示三师签约,2表示家庭签约)  废弃字段

+ 32 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/service/common/QrcodeService.java

@ -1,9 +1,11 @@
package com.yihu.wlyy.service.common;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.address.Town;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.repository.address.TownDao;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.service.BaseService;
@ -37,6 +39,8 @@ public class QrcodeService extends BaseService {
    private TownDao townDao;
    @Autowired
    private HttpUtil HttpUtil;
    @Autowired
    private DoctorAdminTeamDao doctorAdminTeamDao;
    /**
     * 所有医生二维码生成
@ -430,6 +434,34 @@ public class QrcodeService extends BaseService {
        }
    }
    /**
     * 生成某个医生的二维码
     *
     * @param doc
     * @param token
     * @return
     * @throws Exception
     */
    public boolean makeSpecialistQrcode(Doctor doc,Long teamCode, String token) throws Exception {
        AdminTeam adminTeam = doctorAdminTeamDao.findOne(teamCode);
        if (doc != null&&adminTeam!=null) {
            // 二维码内容
            String content = "sp_disease_" + doc.getCode() +"_"+teamCode+ "_" + doc.getName();
            // 二维码图片文件名
            String fileName = doc.getMobile();
            String path = QrcodeService.class.getResource("/").getPath().replace("/WEB-INF/classes/", "")
                    + File.separator + "qrcode";
            // 通过微信接口生成医生二维码
            makeQrcodeFromWeiXin(content, fileName.replaceAll("\r\n", ""), path, token);
            doc.setQrcode(fileName + ".png");
            doctorDao.save(doc);
            return true;
        } else {
            throw new Exception("找不到对应医生信息!");
        }
    }
    /**
     * 从微信生成二维码并下载到本地
     *

+ 54 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/web/common/qrcode/QrCodeController.java

@ -3,14 +3,19 @@ package com.yihu.wlyy.web.common.qrcode;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.service.common.QrcodeService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.web.WeixinBaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletResponse;
@ -27,6 +32,7 @@ import java.io.OutputStream;
@Api(description = "二维码")
public class QrCodeController extends WeixinBaseController {
    private static Logger logger = LoggerFactory.getLogger(QrCodeController.class);
    @Autowired
    private QrcodeService qrcodeService;
    @Autowired
@ -291,6 +297,54 @@ public class QrCodeController extends WeixinBaseController {
        }
    }
    /**
     * 下载某个医生的二维码
     *
     * @param doctor
     * @param response
     */
    @RequestMapping(value = "/specialist_img",method = {RequestMethod.GET,RequestMethod.POST})
    public void downloadSpecialistImage(@ApiParam(name = "doctor", value = "医生id") @RequestParam(value = "doctor", required = true)String doctor,
                                        @ApiParam(name = "teamCode", value = "团队id") @RequestParam(value = "teamCode", required = true)Long teamCode,
                                        HttpServletResponse response) {
        try {
            logger.info("------------------specialist_img:" + doctor);
            Doctor doc = doctorService.findDoctorByCode(doctor);
            if (doc != null) {
                if (StringUtils.isEmpty(doc.getQrcode())) {
                    qrcodeService.makeSpecialistQrcode(doc,teamCode, getAccessToken());
                } else {
                    File file = new File(QrCodeController.class.getResource("/").getPath().replace("/WEB-INF/classes/", "") +
                            File.separator + "qrcode" + File.separator + doc.getQrcode());
                    if (!file.exists()) {
                        qrcodeService.makeSpecialistQrcode(doc,teamCode, getAccessToken());
                    }
                }
                String path = request.getSession().getServletContext().getRealPath("/")
                        + File.separator + "qrcode" + File.separator + doc.getQrcode();
                InputStream inputStream = new FileInputStream(path);
                response.setCharacterEncoding("utf-8");
                response.setContentType("multipart/form-data");
                response.setHeader("Content-Disposition", "attachment;fileName=" + doc.getQrcode());
                OutputStream outputStream = response.getOutputStream();
                byte[] b = new byte[2048];
                int length = 0;
                while ((length = inputStream.read(b)) > 0) {
                    outputStream.write(b, 0, length);
                }
                outputStream.flush();
                outputStream.close();
                inputStream.close();
            } else {
                throw new Exception("医生信息不存在!");
            }
        } catch (Exception e) {
            response.setStatus(500);
        }
    }
    /**
     * 下载所有医生的二维码图片
     *

+ 67 - 15
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java

@ -2620,21 +2620,73 @@ public class SignWebService extends BaseService {
        if (hd == null) {
            return;
        }
        team.setName(renew.getDoctorName() + "," + hd.getName() + "," + renew.getName());
        //新建健康管理师
        DoctorTeamMember hdmb = new DoctorTeamMember();
        hdmb.setName(hd.getName());
        hdmb.setMemberCode(healthDoctor);
        hdmb.setCode(getCode());
        hdmb.setDel("1");
        hdmb.setCzrq(new Date());
        hdmb.setTeam(team.getCode());
        hdmb.setType(3);
        hdmb.setSignType("2");
        //新增团队成员
        doctorTeamMemberDao.save(hdmb);
        //保存团队
        doctorTeamDao.save(team);
        if(team!=null){
            team.setName(renew.getDoctorName() + "," + hd.getName() + "," + renew.getName());
            //新建健康管理师
            DoctorTeamMember hdmb = new DoctorTeamMember();
            hdmb.setName(hd.getName());
            hdmb.setMemberCode(healthDoctor);
            hdmb.setCode(getCode());
            hdmb.setDel("1");
            hdmb.setCzrq(new Date());
            hdmb.setTeam(team.getCode());
            hdmb.setType(3);
            hdmb.setSignType("2");
            //新增团队成员
            doctorTeamMemberDao.save(hdmb);
            //保存团队
            doctorTeamDao.save(team);
        }else{
            //创建团队
            DoctorTeam t = new DoctorTeam();
            String code = getCode();
            t.setCode(code);
            t.setName(renew.getDoctorName() + "," + hd.getName() + "," + renew.getName());
            t.setSignType("2");
            t.setDel("1");
            t.setCzrq(new Date());
            //新建健康管理师
            DoctorTeamMember hdmb = new DoctorTeamMember();
            hdmb.setName(hd.getName());
            hdmb.setMemberCode(healthDoctor);
            hdmb.setCode(getCode());
            hdmb.setDel("1");
            hdmb.setCzrq(new Date());
            hdmb.setTeam(code);
            hdmb.setType(3);
            hdmb.setSignType("2");
            //新建全科医生成员
            DoctorTeamMember dmb = new DoctorTeamMember();
            dmb.setName(renew.getDoctorName());
            dmb.setMemberCode(renew.getDoctor());
            dmb.setCode(getCode());
            dmb.setDel("1");
            dmb.setCzrq(new Date());
            dmb.setTeam(code);
            dmb.setType(2);
            dmb.setSignType("2");
            //新建居民成员
            DoctorTeamMember pmb = new DoctorTeamMember();
            pmb.setName(renew.getName());
            pmb.setMemberCode(renew.getPatient());
            pmb.setCode(getCode());
            pmb.setDel("1");
            pmb.setCzrq(new Date());
            pmb.setTeam(code);
            pmb.setType(5);
            pmb.setSignType("2");
            //新增团队成员
            doctorTeamMemberDao.save(hdmb);
            doctorTeamMemberDao.save(dmb);
            doctorTeamMemberDao.save(pmb);
            //保存团队
            doctorTeamDao.save(t);
        }
        renew.setDoctorHealthName(hd.getName());
        renew.setDoctorHealth(hd.getCode());

+ 32 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/QrcodeService.java

@ -1,9 +1,11 @@
package com.yihu.wlyy.service.common;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.address.Town;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.repository.address.TownDao;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.service.BaseService;
@ -40,7 +42,8 @@ public class QrcodeService extends BaseService {
    private HttpUtil HttpUtil;
    @Value("${server.server_url}")
    private String server_url;
    @Autowired
    private DoctorAdminTeamDao doctorAdminTeamDao;
    /**
     * 所有医生二维码生成
     *
@ -77,6 +80,34 @@ public class QrcodeService extends BaseService {
        return true;
    }
    /**
     * 生成某个医生的二维码
     *
     * @param doc
     * @param token
     * @return
     * @throws Exception
     */
    public boolean makeSpecialistQrcode(Doctor doc,Long teamCode, String token) throws Exception {
        AdminTeam adminTeam = doctorAdminTeamDao.findOne(teamCode);
        if (doc != null&&adminTeam!=null) {
            // 二维码内容
            String content = "sp_disease_" + doc.getCode() +"_"+teamCode+ "_" + doc.getName();
            // 二维码图片文件名
            String fileName = doc.getMobile();
            String path = QrcodeService.class.getResource("/").getPath().replace("/WEB-INF/classes/", "")
                    + File.separator + "qrcode";
            // 通过微信接口生成医生二维码
            makeQrcodeFromWeiXin(content, fileName.replaceAll("\r\n", ""), path, token);
            doc.setQrcode(fileName + ".png");
            doctorDao.save(doc);
            return true;
        } else {
            throw new Exception("找不到对应医生信息!");
        }
    }
    /**
     * 生成社区医院二维码
     *

+ 55 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/qrcode/QrCodeController.java

@ -5,12 +5,16 @@ import com.yihu.wlyy.service.common.QrcodeService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.web.WeixinBaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletResponse;
@ -27,6 +31,7 @@ import java.io.OutputStream;
@Api(description = "二维码")
public class QrCodeController extends WeixinBaseController {
    private static Logger logger = LoggerFactory.getLogger(QrCodeController.class);
    @Autowired
    private QrcodeService qrcodeService;
    @Autowired
@ -296,6 +301,56 @@ public class QrCodeController extends WeixinBaseController {
        }
    }
    /**
     * 下载某个医生的二维码
     *
     * @param doctor
     * @param response
     */
    @RequestMapping(value = "/specialist_img",method = {RequestMethod.GET,RequestMethod.POST})
    public void downloadSpecialistImage(@ApiParam(name = "doctor", value = "医生id") @RequestParam(value = "doctor", required = true)String doctor,
                                        @ApiParam(name = "teamCode", value = "团队id") @RequestParam(value = "teamCode", required = true)Long teamCode,
                                        HttpServletResponse response) {
        try {
            //logger.info("------------------specialist_img:" + doctor);
            Doctor doc = doctorService.findDoctorByCode(doctor);
            if (doc != null) {
                if (StringUtils.isEmpty(doc.getQrcode())) {
                    qrcodeService.makeSpecialistQrcode(doc,teamCode, getAccessToken());
                } else {
                    File file = new File(QrCodeController.class.getResource("/").getPath().replace("/WEB-INF/classes/", "") +
                            File.separator + "qrcode" + File.separator + doc.getQrcode());
                    if (!file.exists()) {
                        qrcodeService.makeSpecialistQrcode(doc,teamCode, getAccessToken());
                    }
                }
                String path = request.getSession().getServletContext().getRealPath("/")
                        + File.separator + "qrcode" + File.separator + doc.getQrcode();
                InputStream inputStream = new FileInputStream(path);
                response.setCharacterEncoding("utf-8");
                response.setContentType("multipart/form-data");
                response.setHeader("Content-Disposition", "attachment;fileName=" + doc.getQrcode());
                OutputStream outputStream = response.getOutputStream();
                byte[] b = new byte[2048];
                int length = 0;
                while ((length = inputStream.read(b)) > 0) {
                    outputStream.write(b, 0, length);
                }
                outputStream.flush();
                outputStream.close();
                inputStream.close();
            } else {
                throw new Exception("医生信息不存在!");
            }
        } catch (Exception e) {
            response.setStatus(500);
        }
    }
    /**
     * 下载所有医生的二维码图片
     *

+ 32 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/wechat/process/WeiXinEventProcess.java

@ -802,11 +802,43 @@ public class WeiXinEventProcess {
            // 构建回复消息XML
            result = WeiXinMessageReplyUtils.replyNewsMessage(message.get("FromUserName"), message.get("ToUserName"), articles);
        }else if (StringUtils.isNotEmpty(eventKey) && eventKey.startsWith("sp_disease_")){
            // 配置信息
            Properties systemConf = SystemConf.getInstance().getSystemProperties();
            // 图文信息
            List<Map<String, String>> articles = new ArrayList<>();
            // 二维码参数
            String[] keys = eventKey.replace("sp_disease_", "").split("_");
            //设置抽奖
            setSpDisease(articles,keys[0],keys[1],systemConf);
            // 构建回复消息XMLs
            result = WeiXinMessageReplyUtils.replyNewsMessage(message.get("FromUserName"), message.get("ToUserName"), articles);
        }
        return result;
    }
    public void setSpDisease(List<Map<String, String>> articles,String teamId,String doctor,Properties systemConf){
        String url = systemDictDao.findByDictName("SP_DISEASE").get(0).getCode();
        url = url.replace("{server}", wechat_base_url)
                 .replace("{appId}", appId)
                 .replace("{data}",doctor+"_"+teamId);
        logger.info("setSpDisease:"+url);
        // 图文消息图片URL
        String picUrlConsult = systemConf.getProperty("specialist_sign_url");
        picUrlConsult = picUrlConsult.replace("{server}", serverUrl);
        Map<String, String> articleConsult = new HashMap<>();
        articleConsult.put("Url", url);
        articleConsult.put("Title", "您需要开通家庭医生与专科医生的”三师共管“的服务邀请");
        articleConsult.put("Description", "优秀的专科医生团队为您提供个性化健康服务");
        articleConsult.put("PicUrl", picUrlConsult);
        articles.add(articleConsult);
    }
    /**
     * 构建单个图文消息工具类
     *

+ 2 - 0
patient-co/patient-co-wlyy/src/main/resources/system.properties

@ -36,6 +36,8 @@ patient_immune_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid={ap
patient_wifi_pic_url = {server}/images/wifi.png
#居民抽奖图片地址
patient_draw_pic_url = {server}/images/banner01.png
#专科医生签约图片地址
specialist_sign_url = {server}/images/SpBanner.png
#居民wifi链接
patient_wifi_url =http://freewifi.mobcb.com/Portal/Wx/login
#就诊记录

BIN
patient-co/patient-co-wlyy/src/main/webapp/images/SpBanner.png