Browse Source

居民端统计

trick9191 8 years ago
parent
commit
41d46b2f19

+ 9 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java

@ -202,6 +202,15 @@ public class SignPatientLabelInfoService extends BaseService {
            json.put("wechatFocusRemind", 1);
        }
        String timeKey = DateUtil.dateToStr(new Date(),"yyyyMMdd");
        String flag = redisTemplate.opsForValue().get("renew:"+timeKey+":"+patient);
        if(StringUtils.isNotBlank(flag)){
            json.put("isRemainRenew","1");
        }else{
            json.put("isRemainRenew","0");
        }
        return json;
    }

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

@ -8,6 +8,7 @@ import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeamMember;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.SignFamilyRenew;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamMemberDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.patient.SignFamilyRenewDao;
@ -64,6 +65,8 @@ public class SignWebService extends BaseService {
    private WeiXinOpenIdUtils weiXinOpenIdUtils;
    @Autowired
    private SignFamilyRenewDao signFamilyRenewDao;
    @Autowired
    private DoctorDao doctorDao;
    /**
     * 根据医生代码及签约状态编码 获取该医生签约患者的信息列表
     *
@ -1031,4 +1034,63 @@ public class SignWebService extends BaseService {
        rs.put("guidanceResult",guidanceResult);
        return rs;
    }
    /**
     * 提醒用户续签约
     * @param access_token
     * @param patientCode
     * @param doctor
     * @return
     * @throws Exception
     */
    public int remainPatientRenew(String access_token,String patientCode,String doctor)throws Exception{
        Doctor d = doctorDao.findByCode(doctor);
        if(doctor==null){
            return -1;
        }
        //发送微信模板消息
        Patient p = patientService.findByCode(patientCode);
        JSONObject json = new JSONObject();
        json.put("keyword1", "续签家庭医生");
        json.put("keyword2", DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
        json.put("remark","提醒医生 :"+d.getName()+"\n"
                +"我们将继续为您提供优质的健康服务。");
        String openid = p.getOpenid();
        String name = p.getName();
        if(StringUtils.isNotBlank(openid)){
            json.put("first",name+",您好!\n" +
                    "您的家庭医生签约将于7月31日到期,为了能继续给您提供健康服务,诚邀您续签家庭医生。");
            PushMsgTask.getInstance().putWxMsg(access_token, 16, openid, name, json);
            patientSetReminFlag(patientCode);
            return 1;
        }else{
            //如果自己没有绑定,则发给家人
            JSONObject j = weiXinOpenIdUtils.getFamilyOpenId(patientCode);
            Patient member = (Patient)j.get("member");
            if(StringUtils.isNotBlank(member.getOpenid())){
                json.put("first",weiXinOpenIdUtils.getTitleMes(p,(int)j.get("relation"),member.getName())+"\n"+
                        name+",您好!\n" +
                        "您的家庭医生签约将于7月31日到期,为了能继续给您提供健康服务,诚邀您续签家庭医生。");
                PushMsgTask.getInstance().putWxMsg(access_token, 16, member.getOpenid(), member.getName(), json);
                patientSetReminFlag(patientCode);
                return 1;
            }else{
                //发送短信
                String mobile = p.getMobile();
                if(StringUtils.isNotBlank(mobile)){
                    SMSService.sendMsg(mobile,name+"您好!您的家庭医生将于7月31日到期,为了继续给您提供健康服务,请关注“厦门i健康”公众号,回复“续签”,进行家庭医生线上续签。");
                    patientSetReminFlag(patientCode);
                    return 2;
                }
            }
        }
        return -1;
    }
    public void patientSetReminFlag(String patient){
        String dateKey = DateUtil.dateToStr(new Date(),"yyyyMMdd");
        redisTemplate.opsForValue().set("renew:"+dateKey+":"+patient,"1");
    }
}

+ 18 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorSignController.java

@ -513,4 +513,22 @@ public class DoctorSignController extends WeixinBaseController {
            return error(-1, "请求失败");
        }
    }
    @RequestMapping("/remainPatientRenew")
    @ApiOperation(value = "统计咨询量、获取待预约、获取健康教育、获取健康指导")
    public String remainPatientRenew(@RequestParam(required = true)String patient){
        try{
            int rs =signWebService.remainPatientRenew(getAccessToken(),patient,getUID());
            if(rs==-1){
                return error(-1, "提醒失败");
            }else if(rs ==1){
                return write(200, "微信提醒成功!", "data", rs);
            }else if(rs ==2){
                return write(200, "短信提醒成功!", "data", rs);
            }
            return error(-1, "提醒失败");
        }catch (Exception e){
            return error(-1, "请求失败");
        }
    }
}