ソースを参照

把i健康的job工程独立出来

chenweida 7 年 前
コミット
e38165fd9b
18 ファイル変更0 行追加1563 行削除
  1. 0 12
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/SignAgainJob.java
  2. 0 531
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/web/common/account/LoginController.java
  3. 0 149
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/web/common/account/RegisterController.java
  4. 0 732
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/web/common/account/WechatController.java
  5. 0 90
      patient-co/patient-co-wlyy-job/src/main/resources/weixin_menu.txt
  6. 0 18
      patient-co/patient-co-wlyy-job/src/main/webapp/downloadPage.html
  7. BIN
      patient-co/patient-co-wlyy-job/src/main/webapp/images/booking.png
  8. BIN
      patient-co/patient-co-wlyy-job/src/main/webapp/images/device.png
  9. BIN
      patient-co/patient-co-wlyy-job/src/main/webapp/images/examination.png
  10. BIN
      patient-co/patient-co-wlyy-job/src/main/webapp/images/familycontract.png
  11. BIN
      patient-co/patient-co-wlyy-job/src/main/webapp/images/inspect.png
  12. BIN
      patient-co/patient-co-wlyy-job/src/main/webapp/images/myfamily.png
  13. BIN
      patient-co/patient-co-wlyy-job/src/main/webapp/images/operatinginstructions.png
  14. BIN
      patient-co/patient-co-wlyy-job/src/main/webapp/images/operatinginstructions1.png
  15. BIN
      patient-co/patient-co-wlyy-job/src/main/webapp/images/prescriptionRecords.png
  16. BIN
      patient-co/patient-co-wlyy-job/src/main/webapp/images/renew.png
  17. BIN
      patient-co/patient-co-wlyy-job/src/main/webapp/images/visit.png
  18. 0 31
      patient-co/patient-co-wlyy-job/src/main/webapp/ssgg_doctor.plist

+ 0 - 12
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/SignAgainJob.java

@ -1,24 +1,12 @@
package com.yihu.wlyy.job;
import com.google.zxing.datamatrix.encoder.SymbolShapeHint;
import com.sun.org.apache.xpath.internal.operations.Bool;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.SendNews;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.WeixinBaseController;
import com.yihu.wlyy.web.common.account.WechatController;
import com.yihu.wlyy.wechat.process.WeiXinEventProcess;
import com.yihu.wlyy.wechat.util.WeiXinMessageReplyUtils;
import org.json.JSONObject;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
import java.text.SimpleDateFormat;

+ 0 - 531
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/web/common/account/LoginController.java

@ -1,531 +0,0 @@
package com.yihu.wlyy.web.common.account;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.login.LoginLog;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.security.Token;
import com.yihu.wlyy.repository.security.TokenDao;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.common.account.RoleService;
import com.yihu.wlyy.service.common.account.TokenService;
import com.yihu.wlyy.service.common.login.LoginLogService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.MD5;
import com.yihu.wlyy.util.RSAUtils;
import com.yihu.wlyy.util.SystemData;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.patchca.color.SingleColorFactory;
import org.patchca.filter.predefined.*;
import org.patchca.service.ConfigurableCaptchaService;
import org.patchca.utils.encoder.EncoderHelper;
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.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.awt.*;
import java.io.IOException;
import java.util.*;
import java.util.List;
//import io.swagger.annotations.Api;
/**
 * @author calvin
 */
@Controller
@RequestMapping(value = "/login", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "患者、医生及管理员登录")
public class LoginController extends BaseController {
    @Autowired
    private DoctorService doctorService;
    @Autowired
    private PatientService patientService;
    @Autowired
    private TokenService tokenService;
    @Autowired
    private SMSService smsService;
    @Autowired
    public TokenDao tokenDao;
    @Autowired
    private RoleService roleService;
    @Autowired
    private LoginLogService loginLogService;
    /**
     * 公钥生成并返回接口
     *
     * @return
     */
    @RequestMapping(value = "public_key")
    @ResponseBody
    public String publicKey() {
        try {
            String modulus = RSAUtils.getInstance(smsService).getModulus();
            String exponent = RSAUtils.getInstance(smsService).getExponent();
            if (StringUtils.isEmpty(modulus) || StringUtils.isEmpty(exponent)) {
                return error(-1, "公钥获取失败!");
            } else {
                JSONObject json = new JSONObject();
                json.put("modulus", modulus);
                json.put("exponent", exponent);
                return write(200, "公钥获取成功!", "data", json);
            }
        } catch (Exception e) {
            return error(-1, "公钥获取失败!");
        }
    }
    // @RequestMapping(value = "testPush")
    // @ResponseBody
    // public String testPush(String receiver, String type, String title, String msg, String data) throws JSONException, InterruptedException {
    // PushMsgTask.getInstance().put(receiver, type, title, msg, data);
    // return "OK";
    // }
    //
    // @RequestMapping(value = "test_public_key")
    // @ResponseBody
    // public String testPublicKey(String str) {
    // try {
    // String modulus = RSAUtils.getInstance(smsService).getModulus();
    // String exponent = RSAUtils.getInstance(smsService).getExponent();
    //
    // String temp = RSAUtils.getInstance(smsService).decryptStringByJs(str);
    // System.out.println(temp);
    // temp = URLDecoder.decode(temp, "UTF-8");
    // System.out.println(temp);
    //
    // if (StringUtils.isEmpty(modulus) || StringUtils.isEmpty(exponent)) {
    // return error(-1, "公钥获取失败!");
    // } else {
    // JSONObject json = new JSONObject();
    // json.put("modulus", modulus);
    // json.put("exponent", exponent);
    // return write(200, "公钥获取成功!", "data", json);
    // }
    // } catch (Exception e) {
    // return error(-1, "公钥获取失败!");
    // }
    // }
    /**
     * 医生登录接口
     *
     *  @param mobile  手机号
     * @param captcha 短信验证码
     * @param idcard  身份证号
     * @param platform  // 1患者端,2医生端app,3微信公众号wechat,4医生端pc
     * @param password 密码
     * @return
     */
    @RequestMapping(value = "doctor")
    @ResponseBody
    public String doctor(@RequestParam(required = false) String mobile,
                         @RequestParam(required = false) String captcha,
                         @RequestParam(required = false) String idcard,
                         @RequestParam(required = false) Integer platform,
                         @RequestParam(required = false) String password) {
        String errorMessage;
        LoginLog loginLog=new LoginLog();
        loginLog.setCreateTime(new Date());
        loginLog.setPhone(mobile);
        loginLog.setType("2");
        loginLog.setUserType("2");
        loginLog.setAppVersion(super.getAppVersion());
        try {
            if (StringUtils.isEmpty(getIMEI())) {
                errorMessage="获取手机IMEI码失败!";
                loginLog.setErrorMessage(errorMessage);
                loginLogService.saveLog(loginLog);
                return error(-1, errorMessage);
            }
            if(platform==null){
                platform = 2;//默认为医生app端
            }
            //身份证登录
            if(StringUtils.isNoneEmpty(mobile)&&StringUtils.isNoneEmpty(password)){
                password = RSAUtils.getInstance(doctorService).decryptString(password);
                password=StringUtils.reverse(password);
                Doctor doctor=doctorService.findDoctorByMobile(mobile);
                loginLog.setLoginType("2");
                if(doctor==null){
                    errorMessage="该号码未注册!";
                    loginLog.setErrorMessage(errorMessage);
                    loginLogService.saveLog(loginLog);
                    return error(-1,errorMessage);
                }
                loginLog.setUserCode(doctor.getCode());
                String loginPassword= MD5.GetMD5Code(password+doctor.getSalt());
                if(loginPassword.equals(doctor.getPassword())){
                    // 用户校验通过,生成token
                    Token token = tokenService.newToken(doctor.getCode(), getIMEI(), platform);
                    loginLog.setTokenId(token.getId());
                    loginLog.setType("1");
                    Map<String, Object> map = new HashMap<>();
                    map.put("id", doctor.getId());
                    map.put("uid", doctor.getCode());
                    map.put("token", token.getToken());
                    map.put("name", doctor.getName());
                    map.put("hospital", doctor.getHospital());
                    map.put("photo", doctor.getPhoto());
                    // 设置医生类型:1专科医生,2全科医生,3健康管理师
                    map.put("doctorType", doctor.getLevel());
                    //获取医生角色和区域权限
                    List<Map<String, String>> roleMap = roleService.getUserRoleAndArea(doctor.getCode());
                    map.put("userRole", roleMap);
                    if("10".equals(doctor.getLevel())&&roleMap.size()==0){
                        errorMessage="改用户没有管理员权限";
                        loginLog.setErrorMessage(errorMessage);
                        loginLogService.saveLog(loginLog);
                        return error(-1, errorMessage);
                    }
                    loginLogService.saveLog(loginLog);
                    return write(200, "登录成功", "data", map);
                }else{
                    errorMessage="密码错误,登录失败";
                    loginLog.setErrorMessage(errorMessage);
                    loginLogService.saveLog(loginLog);
                    return error(-1, errorMessage);
                }
            }
            if(StringUtils.isNoneEmpty(mobile)&&StringUtils.isNoneEmpty(captcha)){
                // 对验证码进行校验
                int res = smsService.check(mobile, 5, captcha);
                switch (res) {
                    case -2:{
                        errorMessage="验证码已过期!";
                        loginLog.setErrorMessage(errorMessage);
                        loginLogService.saveLog(loginLog);
                        return error(-1, errorMessage);}
                    case -1:{
                        errorMessage="请输入正确的验证码!";
                        loginLog.setErrorMessage(errorMessage);
                        loginLogService.saveLog(loginLog);
                        return error(-1, errorMessage);}
                    case 0:{
                        errorMessage="验证码无效!";
                        loginLog.setErrorMessage(errorMessage);
                        loginLogService.saveLog(loginLog);
                        return error(-1, errorMessage);}
                }
                Doctor doctor = doctorService.findDoctorByMobile(mobile);
                loginLog.setLoginType("1");
                if (doctor == null) {
                     errorMessage="该手机号未注册,请确认!";
                    loginLog.setErrorMessage(errorMessage);
                    loginLogService.saveLog(loginLog);
                    return error(-1, errorMessage);
                } else {
                    loginLog.setUserCode(doctor.getCode());
                    // 用户校验通过,生成token
                    Token token = tokenService.newToken(doctor.getCode(), getIMEI(), platform);
                    loginLog.setTokenId(token.getId());
                    loginLog.setType("1");
                    Map<String, Object> map = new HashMap<>();
                    map.put("id", doctor.getId());
                    map.put("uid", doctor.getCode());
                    map.put("token", token.getToken());
                    map.put("name", doctor.getName());
                    map.put("hospital", doctor.getHospital());
                    map.put("photo", doctor.getPhoto());
                    // 设置医生类型:1专科医生,2全科医生,3健康管理师
                    map.put("doctorType", doctor.getLevel());
                    //获取医生角色和区域权限
                    List<Map<String, String>> roleMap = roleService.getUserRoleAndArea(doctor.getCode());
                    map.put("userRole", roleMap);
                    if("10".equals(doctor.getLevel())&&roleMap.size()==0){
                        errorMessage="改用户没有管理员权限";
                        loginLog.setErrorMessage(errorMessage);
                        loginLogService.saveLog(loginLog);
                        return error(-1, errorMessage);
                    }
                    loginLogService.saveLog(loginLog);
                    return write(200, "登录成功", "data", map);
                }
            }
            errorMessage="登录信息不完整,请重新输入!";
            loginLog.setErrorMessage(errorMessage);
            loginLogService.saveLog(loginLog);
            return error(-1,errorMessage);
        } catch (Exception e) {
            loginLog.setErrorMessage(e.getMessage());
            loginLogService.saveLog(loginLog);
            error(e);
            return error(-1, "系统异常,登录失败");
        }
    }
    /**
     * 忘记密码
     *
     * @param type    1患者端,2医生端
     * @param idcard  患者身份证号
     * @param mobile  手机号
     * @param captcha 手机验证码
     * @param newpwd  新密码
     * @return
     */
    @RequestMapping(value = "forgetpwd")
    @ResponseBody
    public String forgetpwd(int type,
                            @RequestParam(required = false) String idcard,
                            @RequestParam(required = false) String mobile,
                            @RequestParam(required = false) String captchaToken,
                            @RequestParam(required = false)String captcha,
                            @RequestParam(required = false)String patient,
                            String newpwd) {
        try {
            //String ct = request.getSession().getAttribute("captchaToken").toString();
//            if (StringUtils.isEmpty(captchaToken)) {
//                return error(-1, "图形验证码不允许为空!");
//            }
//            if (!StringUtils.equalsIgnoreCase(captchaToken, ct)) {
//                return error(-1, "图形验证码错误!");
//            }
//            idcard = RSAUtils.getInstance(doctorService).decryptString(idcard);
//            idcard = URLDecoder.decode(idcard, "UTF-8");
//            idcard = StringUtils.reverse(idcard);
//            newpwd = RSAUtils.getInstance(doctorService).decryptString(newpwd);
//            newpwd = URLDecoder.decode(newpwd, "UTF-8");
//            newpwd = StringUtils.reverse(newpwd);
            // 对验证码进行校验
            if (type == 2) {
                // 医生端
                    Doctor doctor = doctorService.findDoctorByMobile(mobile);
                    String password = RSAUtils.getInstance(doctorService).decryptString(newpwd);
                    password=StringUtils.reverse(password);
                    password=MD5.GetMD5Code(password+doctor.getSalt());
                    doctor.setPassword(password);
                    doctorService.updateDoctorPwd(doctor);
                    return success("操作成功!");
            } else {
                // 患者端
                Patient patientTemp = patientService.findByIdcard(idcard);
                if (patientTemp == null) {
                    return error(-1, "操作失败:此用户未注册");
                } else {
                    String password = RSAUtils.getInstance(doctorService).decryptString(newpwd);
                    password=StringUtils.reverse(password);
                    password=MD5.GetMD5Code(password+patientTemp.getSalt());
                    patientTemp.setPassword(password);
                    patientService.updatePatientPwd(patientTemp);
                    return success("操作成功!");
                }
            }
        } catch (Exception e) {
            error(e);
            return error(-1, "系统异常,操作失败");
        }
    }
    /**
     * 退出登录
     *
     * @param type 1患者,2医生,3微信公众号
     * @return
     */
    @RequestMapping(value = "exit")
    @ResponseBody
    public String logout(int type) {
        try {
            tokenService.delToken(type, getUID());
            return success("已成功退出!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "操作失败!");
        }
    }
    @RequestMapping(value = "/third/login")
    @ResponseBody
    public String thirdLogin(
            @RequestParam(value = "id") int id,
            @RequestParam(value = "uid") String uid,
            @RequestParam(value = "imei") String imei,
            @RequestParam(value = "token") String tokenStr,
            @RequestParam(value = "platform") int platform) {
        try {
            if (StringUtils.isEmpty(tokenStr) || StringUtils.isEmpty(imei) || StringUtils.isEmpty(uid)) {
                // response.getWriter().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!"));
                return error(-1, "系统异常,操作失败");
            }
            Token token = SystemData.doctorTokens.get(uid);
            if (token == null) {
                token = tokenDao.findByToken(tokenStr);
                if (token != null) {
                    // 加入缓存
                    SystemData.doctorTokens.put(uid, token);
                }
            }
            if (token == null || token.getPlatform() != 2) {
                // 未登录
                return error(-1, "系统异常,操作失败");
            } else {
                if (token.getTimeout().getTime() < new Date().getTime()) {
                    // 登录超时
                    return error(-1, "系统异常,操作失败");
                } else if (!StringUtils.equals(uid, token.getUser()) || !StringUtils.equals(imei, token.getImei())) {
                    // 别处登录
                    return error(-1, "系统异常,操作失败");
                } else {
                    // 一天只更新一次
                    if (DateUtil.getDays(token.getCzrq(), DateUtil.getNowDateShort()) != 0) {
                        // 今天未更新,则更新缓存
                        token.setCzrq(new Date());
                        // 更新内存
                        SystemData.doctorTokens.put(uid, token);
                        // 更新数据库
                        tokenDao.save(token);
                    }
                }
            }
            return success("登陆成功");
        } catch (Exception ex) {
            error(ex);
            return error(-1, "系统异常,操作失败");
        }
    }
    // public String getLoginInfo()
    // {
    // try{
    // Token token = SystemData.doctorTokens.get(tokenStr);
    // return "";
    // }
    // catch(Exception ex)
    // {
    // error(ex);
    // return error(-1, "系统异常,操作失败");
    // }
    // }
    /**
     * 验证码地址
     *
     * @param request
     * @param response
     * @throws IOException
     */
    @RequestMapping("pcrimg")
    public void crimg(HttpServletRequest request, HttpServletResponse response) throws IOException {
        ConfigurableCaptchaService cs = new ConfigurableCaptchaService();
        cs.setColorFactory(new SingleColorFactory(new Color(25, 60, 170)));
        Random random = new Random();
        switch (random.nextInt(5)) {
            case 0:
                cs.setFilterFactory(new CurvesRippleFilterFactory(cs.getColorFactory()));
                break;
            case 1:
                cs.setFilterFactory(new MarbleRippleFilterFactory());
                break;
            case 2:
                cs.setFilterFactory(new DoubleRippleFilterFactory());
                break;
            case 3:
                cs.setFilterFactory(new WobbleRippleFilterFactory());
                break;
            case 4:
                cs.setFilterFactory(new DiffuseRippleFilterFactory());
                break;
        }
        HttpSession session = request.getSession(false);
        if (session == null) {
            session = request.getSession();
        }
        setResponseHeaders(response);
        String token = EncoderHelper.getChallangeAndWriteImage(cs, "png", response.getOutputStream());
        session.setAttribute("captchaToken", token);
    }
    protected void setResponseHeaders(HttpServletResponse response) {
        response.setContentType("image/png");
        response.setHeader("Cache-Control", "no-cache, no-store");
        response.setHeader("Pragma", "no-cache");
        long time = System.currentTimeMillis();
        response.setDateHeader("Last-Modified", time);
        response.setDateHeader("Date", time);
        response.setDateHeader("Expires", time);
    }
    // @RequestMapping(value = "test_sms")
    // @ResponseBody
    // public String testSms() {
    // try {
    // JSONObject params = new JSONObject();
    // params.put("SpCode", SystemConf.SMS_SP_CODE);
    // params.put("LoginName", SystemConf.SMS_LOGIN_NAME);
    // params.put("Password", SystemConf.SMS_PASSWORD);
    // params.put("MessageContent", "您的找回密码验证码为:123456");
    // params.put("UserNumber", "18559687019");
    // params.put("SerialNumber", "");
    // params.put("ScheduleTime", "");
    // params.put("f", 1);
    // String result = HttpClientUtil.post(SystemConf.SMS_URL, SMSService.buildSmsParams("您的找回密码验证码为:123456", "18559687019"), "GBK");
    // JSONObject json = SMSService.toJson(result);
    // System.out.println(json.toString());
    // System.out.println(json.getInt("result"));
    // if (json.getInt("result") != 0) {
    // return error(-1, "短信发送失败!");
    // }
    // return success("短信发送成功!");
    // } catch (Exception e) {
    // error(e);
    // return error(-1, "短信发送失败!");
    // }
    // }
    /**
     * 患者,医生注册-验证手机号
     *
     * @param mobile 登录手机号
     * @return
     */
    @RequestMapping(value = "checkmobile")
    @ResponseBody
    public String checkmobile(@RequestParam(required = true,value = "mobile",defaultValue = "0")String mobile,
                              @RequestParam(required = true,value = "type",defaultValue = "0") int type) {
        try {
            if(type==0){//患者端
                List<Patient> temp = patientService.findByMobile(mobile);
                if (temp != null&&temp.size()>0) {
                    // 设置身份证号
                    return write(200, "手机号码已经被注册!");
                }
                return error(-1, "该手机号未被注册!");
            }else if(type==1){
                Doctor doctor = doctorService.findDoctorByMobile(mobile);
                if(doctor!=null){
                    return write(200, "手机号码已经被注册!");
                }
                return error(-1, "该手机号未被注册!");
            }else{
                return error(1, "错误的请求类型!");
            }
        } catch (Exception e) {
            error(e);
            return error(-1, "手机号验证失败");
        }
    }
}

+ 0 - 149
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/web/common/account/RegisterController.java

@ -1,149 +0,0 @@
package com.yihu.wlyy.web.common.account;
//import io.swagger.annotations.Api;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.yihu.wlyy.web.BaseController;
/**
 * 用户注册的Controller.
 * 
 * @author calvin
 */
@Controller
@RequestMapping(value = "/register")
//@Api(description = "用户注册")
public class RegisterController extends BaseController {
	// @Autowired
	// private DoctorService doctorService;
//	@Autowired
//	private PatientService patientService;
//	@Autowired
//	private SMSService smsService;
	// /**
	// * 医生注册
	// * @param name 医生姓名
	// * @param mobile 登录手机号
	// * @param password 登录密码
	// * @param captcha 手机验证码
	// * @return
	// */
	// @RequestMapping(value = "doctor")
	// @ResponseBody
	// public String doctor(String name, String mobile, String password, String captcha) {
	// try {
	// if (doctorService.findDoctorByMobile(mobile) != null) {
	// return error(-1, "该手机号已被注册!");
	// }
	// Doctor doctor = new Doctor();
	// doctor.setName(name);
	// doctor.setMobile(mobile);
	// doctor.setPassword(password);
	// JSONObject json = doctorService.registerDoctor(doctor, getIMEI());
	// if (json != null) {
	// // 注册成功
	// return write(200, "注册成功!", "data", json);
	// } else {
	// // 注册失败
	// return error(-1, "注册失败!");
	// }
	// } catch (Exception e) {
	// error(e);
	// return error(-1, "注册失败!");
	// }
	// }
//	/**
//	 * 患者注册
//	 * @param name 姓名
//	 * @param idcard 身份證號
//	 * @param ssc 社保卡号
//	 * @param mobile 登录手机号
//	 * @param captcha 手机验证码
//	 * @param type 1校验,2保存
//	 * @return
//	 */
//	@RequestMapping(value = "patient")
//	@ResponseBody
//	public String patient(String name, String idcard, String ssc, String mobile, String captcha, int type) {
//		try {
//			if (type != 1 && type != 2) {
//				return error(-1, "无效请求!");
//			}
//			if (StringUtils.isEmpty(name)) {
//				return error(-1, "姓名不允许为空!");
//			}
//			if (StringUtils.isEmpty(idcard)) {
//				return error(-1, "身份证号码不允许为空!");
//			}
//			if (StringUtils.isEmpty(ssc)) {
//				return error(-1, "社保卡号不允许为空!");
//			}
//			if (StringUtils.isEmpty(mobile)) {
//				return error(-1, "手机号码不允许为空!");
//			}
//			if (StringUtils.isEmpty(captcha)) {
//				return error(-1, "验证码不允许为空!");
//			}
//			if (StringUtils.isNotEmpty(getOpenid())) {
//				Patient patient = patientService.findByOpenid(getOpenid());
//				if (patient != null) {
//					return error(-1, "当前微信号已绑定身份证:" + CommonUtil.getIdcardEncode(patient.getIdcard()) + " !");
//				}
//			}
//			// 对验证码进行校验
//			int res = smsService.check(mobile, 1, captcha);
//			switch (res) {
//			case -2:
//				return error(-1, "验证码已过期!");
//			case -1:
//				return error(-1, "请输入正确的验证码!");
//			case 0:
//				return error(-1, "验证码无效!");
//			}
//			// 解密身份证号
//			idcard = RSAUtils.getInstance(patientService).decryptString(idcard);
//			idcard = URLDecoder.decode(idcard, "UTF-8");
//			idcard = StringUtils.reverse(idcard);
//			// 判断用户是否已注册
//			Patient patient = patientService.findByIdcard(idcard);
//			if (patient != null) {
//				return error(-1, "该帐号已绑定手机号" + CommonUtil.getMobileEncode(patient.getMobile()) + ",请直接使用此手机号登录");
//			}
//			patient = patientService.findBySsc(ssc);
//			if (patient != null) {
//				return error(-1, "该帐号已绑定手机号" + CommonUtil.getMobileEncode(patient.getMobile()) + ",请直接使用此手机号登录");
//			}
//			patient = patientService.findByMobile(mobile);
//			if (patient != null) {
//				return error(-1, "该手机号码已绑定其他身份证和医保卡,建议您重新输入新手机号码");
//			}
//			if (type == 2) {
//				patient = new Patient();
//				patient.setIdcard(idcard);
//				patient.setMobile(mobile);
//				patient.setName(name);
//				patient.setSsc(ssc);
//				patient.setOpenid(getOpenid());
//				JSONObject json = patientService.register(patient, getIMEI(), 1);
//				if (json != null) {
//					// 注册成功
//					return write(200, "注册成功!", "data", json);
//				} else {
//					// 注册失败
//					return error(-1, "注册失败!");
//				}
//			} else {
//				return success("验证通过!");
//			}
//		} catch (Exception e) {
//			error(e);
//			return error(-1, "注册失败!");
//		}
//	}
}

+ 0 - 732
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/web/common/account/WechatController.java

@ -1,732 +0,0 @@
package com.yihu.wlyy.web.common.account;
import com.yihu.wlyy.entity.login.LoginLog;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SocialSecurityInfo;
import com.yihu.wlyy.entity.security.Token;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SocialSecurityInfoDao;
import com.yihu.wlyy.service.app.family.FamilyMemberService;
import com.yihu.wlyy.service.app.family.FamilyService;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.service.common.account.AccessTokenService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.common.account.TokenService;
import com.yihu.wlyy.service.common.login.LoginLogService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.HttpUtil;
import com.yihu.wlyy.util.IdcardValidator;
import com.yihu.wlyy.util.MD5;
import com.yihu.wlyy.util.RSAUtils;
import com.yihu.wlyy.web.WeixinBaseController;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
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.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.net.URLDecoder;
import java.util.*;
/**
 * @author calvin
 */
@Controller
@RequestMapping(value = "/weixin", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "微信端用户注册")
public class WechatController extends WeixinBaseController {
    @Autowired
    private PatientService patientService;
    @Autowired
    private TokenService tokenService;
    @Autowired
    private SMSService smsService;
    @Autowired
    private SocialSecurityInfoDao socialSecurityInfoDao;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private FamilyService familyService;
    @Autowired
    private LoginLogService loginLogService;
    @Autowired
    private FamilyMemberService familyMemberService;
    @Autowired
    WeiXinOpenIdUtils weiXinOpenIdUtils;
    @Autowired
    AccessTokenService accessTokenService;
    @Autowired
    HttpUtil HttpUtil;
    @Autowired
    private PushMsgTask pushMsgTask;
    /**
     * 患者注册-验证手机号
     *
     * @param phone 登录手机号
     * @return
     */
    @RequestMapping(value = "checkmobile")
    @ResponseBody
    public String checkmobile(String phone) {
        try {
            /**modify by linz 2017年2月28日10:11:49 校验手机号码的时候返回使用此号码的所有人员**/
            List<Patient> temp = patientService.findByMobile(phone);
            if (temp != null && temp.size() > 0) {
                // 设置身份证号
                return write(200, "患者信息查询成功!", "data", temp);
            }
            return error(1, "该手机号未被注册");
        } catch (Exception e) {
            error(e);
            return error(-1, "手机号验证失败");
        }
    }
    /**
     * 获取验证码发送的手机号码
     *
     * @param idCard
     * @return
     */
    @RequestMapping(value = "getMobile")
    @ResponseBody
    public String getPatientInfoByIdCard(@RequestParam(value = "idCard", required = true) String idCard) {
        Patient temp = patientService.findByIdcard(idCard);
        getAccessToken();
        if (temp == null) {
            return error(-1, "用户未注册");
        } else {
            if (StringUtils.isBlank(temp.getMobile())) {
                return error(-2, "用户未绑定手机号");
            } else {
                JSONObject object = new JSONObject();
                object.put("mobile", temp.getMobile());
                return write(200, "获取成功", "data", object);
            }
        }
    }
    /**
     * 患者注册-验证身份证
     *
     * @param idcard 身份證號
     * @param mobile 登录手机号
     * @return
     */
    @RequestMapping(value = "checkidcard")
    @ResponseBody
    public String checkidcard(String idcard, String mobile) {
        try {
            // 解密身份证号
            idcard = RSAUtils.getInstance(patientService).decryptString(idcard);
            idcard = URLDecoder.decode(idcard, "UTF-8");
            idcard = StringUtils.reverse(idcard);
            Patient temp = patientService.findByIdcard(idcard);
            if (temp != null) {
                JSONObject json = new JSONObject();
                // 设置患者标识
                json.put("code", temp.getCode());
                // 设置手机号码
                json.put("mobile", temp.getMobile());
                // 设置身份证号
                json.put("idcard", temp.getIdcard());
                return write(1, "患者信息查询成功!", "data", json);
            } else {
                List<Patient> temp1 = patientService.findByMobile(mobile);
                if (temp1 != null && temp1.size() > 0) {
                    //JSONObject json = new JSONObject();
                    // 设置患者标识
                    //json.put("code", temp1.getCode());
                    //// 设置手机号码
                    //json.put("mobile", temp1.getMobile());
                    //// 设置身份证号
                    //json.put("idcard", temp1.getIdcard());
                    return write(2, "患者信息查询成功!", "data", temp1);
                }
            }
            return success("该身份证和手机号未被注册");
        } catch (Exception e) {
            error(e);
            return error(-1, "身份证验证失败");
        }
    }
    /**
     * 注册信息验证
     *
     * @param name   姓名
     * @param idcard 身份证号
     * @param ssc    社保卡号
     * @param mobile 手机号
     * @return
     */
    @RequestMapping(value = "/check_regist_info")
    @ResponseBody
    public String checkRegistInfo(String name, String idcard, String ssc, String mobile) {
        try {
            if (StringUtils.isEmpty(name)) {
                return error(-1, "姓名不允许为空");
            }
            if (StringUtils.isEmpty(idcard)) {
                return error(-1, "身份证号不允许为空");
            }
            if (StringUtils.isEmpty(ssc)) {
                return error(-1, "社保卡号不允许为空");
            }
            if (StringUtils.isEmpty(mobile)) {
                return error(-1, "手机号不允许为空");
            }
            //if (patientService.findByMobile(mobile) != null) {
            //    return error(-1, "该手机号已被注册");
            //}
            // 解密身份证号
            idcard = RSAUtils.getInstance(patientService).decryptString(idcard);
            idcard = URLDecoder.decode(idcard, "UTF-8");
            idcard = StringUtils.reverse(idcard);
            // 校验身份证号
            IdcardValidator validator = new IdcardValidator();
            if (validator.isValidatedAllIdcard(idcard)) {
                if (idcard.length() == 15) {
                    idcard = validator.convertIdcarBy15bit(idcard);
                    if (StringUtils.isEmpty(idcard)) {
                        return error(-1, "请输入正确的身份证号");
                    }
                }
            } else {
                return error(-1, "请输入正确的身份证号");
            }
            SocialSecurityInfo socialSecurityInfo = socialSecurityInfoDao.findBySfzh18Max(idcard);
            if (socialSecurityInfo != null) {
                if (name.compareTo(socialSecurityInfo.getXming0() == null ? "" : socialSecurityInfo.getXming0()) != 0) {
                    return error(-1, "身份证号与姓名不一致,请检查后重新输入");
                }
                if (ssc.compareTo(socialSecurityInfo.getCardno() == null ? "" : socialSecurityInfo.getCardno()) != 0 && ssc.compareTo(socialSecurityInfo.getCard16() == null ? "" : socialSecurityInfo.getCard16()) != 0) {
                    return error(-1, "身份证号与医保卡号不一致,请检查后重新输入");
                }
            } else {
                return error(-1, "对不起,暂不支持16年6月份之后办理的医保卡注册");
            }
            Patient patient = patientDao.findByIdcard(idcard);
            if (patient != null) {
                if (!StringUtils.isEmpty(patient.getMobile())) {
                    return error(-2, "该身份证已被注册");
                }
            }
            return write(200, "验证成功");
        } catch (Exception e) {
            return error(-1, "验证失败");
        }
    }
    /**
     * 患者注册
     *
     * @param idcard  身份證號
     * @param mobile  登录手机号
     * @param captcha 手机验证码
     * @return
     */
    @RequestMapping(value = "regist")
    @ResponseBody
    public String regist(@RequestParam(value = "name", required = true) String name,
                         @RequestParam(value = "idcard", required = true) String idcard,
                         @RequestParam(value = "ssc", required = true) String ssc,
                         @RequestParam(value = "mobile", required = true) String mobile,
                         @RequestParam(value = "captcha", required = true) String captcha,
                         @RequestParam(value = "openid", required = true) String openid,
                         @RequestParam(value = "password", required = true) String password) {
        try {
            if (StringUtils.isEmpty(name)) {
                return error(-1, "姓名不允许为空!");
            }
            if (StringUtils.isEmpty(idcard)) {
                return error(-1, "身份证号不允许为空!");
            }
            if (StringUtils.isEmpty(ssc)) {
                return error(-1, "社保卡号不允许为空!");
            }
            if (StringUtils.isEmpty(mobile)) {
                return error(-1, "手机号不允许为空!");
            }
            //if (patientService.findByMobile(mobile) != null) {
            //    return error(-1, "该手机号已被注册!");
            //}
            // 对验证码进行校验
            int res = smsService.check(mobile, 1, captcha);
            switch (res) {
                case -2:
                    return error(-1, "验证码已过期!");
                case -1:
                    return error(-1, "请输入正确的验证码!");
                case 0:
                    return error(-1, "验证码无效!");
            }
            // 未绑定openid,查询是否绑定其他账号
//			if (patientService.countByOpenid(openid) > 0) {
//				return error(-1, "该微信号已绑定其他手机号!");
//			}
            // 解密身份证号
            idcard = RSAUtils.getInstance(patientService).decryptString(idcard);
            idcard = URLDecoder.decode(idcard, "UTF-8");
            idcard = StringUtils.reverse(idcard);
            // 校验身份证号
            IdcardValidator validator = new IdcardValidator();
            if (validator.isValidatedAllIdcard(idcard)) {
                if (idcard.length() == 15) {
                    idcard = validator.convertIdcarBy15bit(idcard);
                    if (StringUtils.isEmpty(idcard)) {
                        return error(-1, "请输入正确的身份证号!");
                    }
                }
            } else {
                return error(-1, "请输入正确的身份证号!");
            }
            SocialSecurityInfo socialSecurityInfo = socialSecurityInfoDao.findBySfzh18Max(idcard);
            if (socialSecurityInfo != null) {
                if (name.compareTo(socialSecurityInfo.getXming0() == null ? "" : socialSecurityInfo.getXming0()) != 0) {
                    return error(-1, "身份证号与姓名不一致<br/>请检查后重新输入");
                }
                if (ssc.compareTo(socialSecurityInfo.getCardno() == null ? "" : socialSecurityInfo.getCardno()) != 0) {
                    if (ssc.compareTo(socialSecurityInfo.getCard16() == null ? "" : socialSecurityInfo.getCard16()) != 0) {
                        return error(-1, "身份证号与医保卡号不一致,请检查后重新输入");
                    } else {
                        ssc = socialSecurityInfo.getCardno();//统一只存英文字母开头的医保卡
                    }
                }
            } else {
                return error(-1, "对不起,暂不支持16年6月份之后办理的医保卡注册");
            }
            Patient patient = patientDao.findByIdcard(idcard);
            if (patient == null) {
                patient = new Patient();
            } else {
                if (!StringUtils.isEmpty(patient.getMobile())) {
                    return error(-2, "该身份证已被注册!");
                }
            }
            patient.setName(name);
            patient.setIdcard(idcard);
            patient.setMobile(mobile);
            //增加密码
            String salt = UUID.randomUUID().toString().replace("-", "");
            patient.setSalt(salt);
            password = RSAUtils.getInstance(patientService).decryptString(password);
            password = StringUtils.reverse(password);
            patient.setPassword(MD5.GetMD5Code(password + salt));
            patient.setSsc(ssc);
            if (!org.springframework.util.StringUtils.isEmpty(openid)) {
                patient.setOpenid(openid);
                patient.setOpenidTime(new Date());
            }
            JSONObject json = patientService.register(idcard, ssc, name, mobile, MD5.GetMD5Code(password + salt)
                    , salt, openid, 3);
            if (json != null) {
                try {
                    Patient p = patientDao.findByIdcard(idcard);
                    BusinessLogs.info(BusinessLogs.BusinessType.register, p.getCode(), p.getCode(), new JSONObject(p));
                } catch (Exception e) {
                    e.printStackTrace();
                }
                // 注册成功
                return write(200, "注册成功!", "data", json);
            } else {
                // 注册失败
                return error(-1, "注册失败!");
            }
        } catch (Exception e) {
            error(e);
            return error(-1, "注册失败!");
        }
    }
    /**
     * 患者微信登录接口
     *
     * @param captcha  短信号
     * @param mobile   电话号码
     * @param password 登录密码
     * @return
     */
    @RequestMapping(value = "login")
    @ResponseBody
    public String login(
            @RequestParam(required = false) String mobile,
            @RequestParam(required = false) String captcha,
            @RequestParam(required = false) String password,
            String openid) {
        System.out.println("login openid : " + openid);
        String errorMessage;
        LoginLog loginLog = new LoginLog();
        loginLog.setCreateTime(new Date());
        loginLog.setPhone(mobile);
        loginLog.setType("2");
        loginLog.setUserType("1");
        try {
            //账号登录 mobile可能是电话号也可能是身份证
            if (StringUtils.isNoneEmpty(mobile) && StringUtils.isNoneEmpty(password)) {
                Patient p = patientService.findByIdcard(mobile);
                if (p == null) {
                    List<Patient> patients = patientService.findByMobile(mobile);
                    if (patients.size() > 1) {
                        return error(-1, "此手机号码存在多个用户,请用身份证进行登录!");
                    } else if (patients.size() == 1) {
                        p = patients.get(0);
                    }
                }
                loginLog.setLoginType("2");
                if (p == null) {
                    if (mobile.length() == 11) {
                        errorMessage = "该手机号暂未注册账号,请确认后重新输入!";
                    } else {
                        errorMessage = "该身份证号暂未注册账号,请确认后重新输入!";
                    }
                    loginLog.setErrorMessage(errorMessage);
                    loginLogService.saveLog(loginLog);
                    return error(-1, errorMessage);
                } else if (p.getStatus() == 0) {
                    if (mobile.length() == 11) {
                        errorMessage = "该手机号已被禁止使用!";
                    } else {
                        errorMessage = "该身份证号已被禁止使用!";
                    }
                    loginLog.setErrorMessage(errorMessage);
                    loginLogService.saveLog(loginLog);
                    return error(-1, errorMessage);
                } else if (p.getStatus() == 2) {
                    errorMessage = "该账号正在审核中,请确认审核通过后再登录,“如有疑问,拨打400-6677-400转2人工客服”";
                    loginLog.setErrorMessage(errorMessage);
                    loginLogService.saveLog(loginLog);
                    return error(-1, errorMessage);
                } else if (StringUtils.isEmpty(openid)) {
                    errorMessage = "无效的OpenID!";
                    loginLog.setErrorMessage(errorMessage);
                    loginLogService.saveLog(loginLog);
                    return error(-1, errorMessage);
                }
                loginLog.setUserCode(p.getCode());
                //解密
                password = RSAUtils.getInstance(patientService).decryptString(password);
                password = StringUtils.reverse(password);
                //生成MD5
                String loginPassword = MD5.GetMD5Code(password + p.getSalt());
                //判断d登录密码是否正确
                if (loginPassword.equals(p.getPassword())) {
                    // 绑定用户手机号和openid
                    if (!StringUtils.equals(p.getOpenid(), openid) && !"undefined".equals(openid)) {//undefined不更新数据库
                        //patient.setOpenid(openid);
                        patientService.updatePatient(p, openid);
                    }
                    // 用户校验通过,生成token
                    Token token = tokenService.newTxToken(p.getCode(), openid);
                    Map<Object, Object> map = new HashMap<Object, Object>();
                    map.put("id", p.getId());
                    map.put("uid", p.getCode());
                    map.put("name", p.getName());
                    map.put("token", token.getToken());
                    map.put("photo", p.getPhoto());
                    if (StringUtils.isNoneEmpty(openid)) {
                        //发送微信模板
                        familyService.sendWXMessage(p);
                    }
                    loginLog.setLoginType("1");
                    loginLogService.saveLog(loginLog);
                    return write(200, "登录成功", "data", map);
                } else {
                    errorMessage = "密码错误,登录失败";
                    loginLog.setErrorMessage(errorMessage);
                    loginLogService.saveLog(loginLog);
                    return error(-1, errorMessage);
                }
            }
            //短信登录
            if (StringUtils.isNoneEmpty(mobile) && StringUtils.isNoneEmpty(captcha)) {
                List<Patient> patients = patientService.findByMobile(mobile);
                if (patients.size() > 1) {
                    return error(-1, "此手机存在多个用户,请用身份证和密码登录!");
                }
                // 对验证码进行校验
                int res = smsService.check(mobile, 4, captcha);
                switch (res) {
                    case -2: {
                        errorMessage = "验证码已过期!";
                        loginLog.setErrorMessage(errorMessage);
                        loginLogService.saveLog(loginLog);
                        return error(-1, errorMessage);
                    }
                    case -1: {
                        errorMessage = "请输入正确的验证码!";
                        loginLog.setErrorMessage(errorMessage);
                        loginLogService.saveLog(loginLog);
                        return error(-1, errorMessage);
                    }
                    case 0: {
                        errorMessage = "验证码无效!";
                        loginLog.setErrorMessage(errorMessage);
                        loginLogService.saveLog(loginLog);
                        return error(-1, errorMessage);
                    }
                }
                loginLog.setLoginType("1");
                if (patients == null || patients.size() == 0) {
                    if (mobile.length() == 11) {
                        errorMessage = "该手机号暂未注册账号,请确认后重新输入!";
                    } else {
                        errorMessage = "该身份证号暂未注册账号,请确认后重新输入!";
                    }
                    loginLog.setErrorMessage(errorMessage);
                    loginLogService.saveLog(loginLog);
                    return error(-1, errorMessage);
                } else {
                    Patient p = null;
                    if (patients.size() == 1) {
                        p = patients.get(0);
                    }
                    if (p.getStatus() == 0) {
                        if (mobile.length() == 11) {
                            errorMessage = "该手机号已被禁止使用!";
                        } else {
                            errorMessage = "该身份证号已被禁止使用!";
                        }
                        loginLog.setErrorMessage(errorMessage);
                        loginLogService.saveLog(loginLog);
                        return error(-1, errorMessage);
                    } else if (p.getStatus() == 2) {
                        errorMessage = "该账号正在审核中,请确认审核通过后再登录,“如有疑问,拨打400-6677-400转2人工客服”";
                        loginLog.setErrorMessage(errorMessage);
                        loginLogService.saveLog(loginLog);
                        return error(-1, errorMessage);
                    } else if (StringUtils.isEmpty(openid)) {
                        errorMessage = "无效的OpenID!";
                        loginLog.setErrorMessage(errorMessage);
                        loginLogService.saveLog(loginLog);
                        return error(-1, errorMessage);
                    }
                    loginLog.setUserCode(p.getCode());
                    // 绑定用户手机号和openid
                    if (!StringUtils.equals(p.getOpenid(), openid)) {
                        //patient.setOpenid(openid);
                        patientService.updatePatient(p, openid);
                    }
                    // 用户校验通过,生成token
                    Token token = tokenService.newTxToken(p.getCode(), openid);
                    Map<Object, Object> map = new HashMap<Object, Object>();
                    map.put("id", p.getId());
                    map.put("uid", p.getCode());
                    map.put("name", p.getName());
                    map.put("token", token.getToken());
                    map.put("photo", p.getPhoto());
                    if (StringUtils.isNoneEmpty(openid)) {
                        //发送微信模板
                        familyService.sendWXMessage(p);
                    }
                    loginLog.setType("1");
                    loginLogService.saveLog(loginLog);
                    return write(200, "登录成功", "data", map);
                }
            }
            return error(-1, "登录失败");
        } catch (Exception e) {
            errorMessage = "系统异常,登录失败";
            loginLog.setErrorMessage(errorMessage);
            loginLogService.saveLog(loginLog);
            error(e);
            return error(-1, "系统异常,登录失败");
        }
    }
    /**
     * 获取签名signature
     *
     * @param pageUrl 需要签名的页面全地址(?后的也需要除了#后的不需要)
     * @return
     */
    @RequestMapping(value = "getSign")
    @ResponseBody
    public String getSign(String pageUrl) {
        try {
            String ticket = getJsapi_ticketByToken();
            if (ticket != null) {
                String noncestr = UUID.randomUUID().toString();
                long timestamp = System.currentTimeMillis() / 1000;
                String url = pageUrl;
                String str = "jsapi_ticket=" + ticket + "&noncestr=" + noncestr + "&timestamp=" + timestamp + "&url=" + url;
                // sha1加密
                String signature = SHA1(str);
                Map<Object, Object> map = new HashMap<Object, Object>();
                map.put("noncestr", noncestr);
                map.put("timestamp", timestamp);
                map.put("signature", signature);
                return write(200, "获取签名成功", "data", map);
            } else
                return error(-1, "获取签名失败");
        } catch (Exception e) {
            error(e);
        }
        return error(-1, "获取签名失败");
    }
    /**
     * 发送微信签约成功的消息
     *
     * @param code 患者编号
     * @return
     */
    @RequestMapping(value = "sendSign")
    @ResponseBody
    public String sendSignSucess(String code) {
        try {
            Patient patient = patientService.findByCode(code);
            JSONObject json = new JSONObject();
            json.put("first", "开始");
            json.put("remark", "指导备注");
            json.put("date", "2016-06-08");
            json.put("doctorName", "徐小鹏");
            json.put("orgName", "厦门第一医院");
            //判断是否判定openId,有没有发则查找家人发送
            if (StringUtils.isNotBlank(patient.getOpenid())) {
                // 添加到发送队列
                pushMsgTask.putWxMsg(getAccessToken(), 5, patient.getOpenid(), patient.getName(), json);
            } else {
                JSONObject j = weiXinOpenIdUtils.getFamilyOpenId(patient.getCode());
                Patient member = (Patient) j.get("member");
                if (StringUtils.isNotBlank(member.getOpenid())) {
                    String first = (String) json.get("first");
                    json.remove("first");
                    json.put("first", weiXinOpenIdUtils.getTitleMes(patient, j.getInt("relation"), patient.getName()) + first);
                    pushMsgTask.putWxMsg(getAccessToken(), 5, member.getOpenid(), patient.getName(), json);
                }
            }
            return write(200, "发送成功");
        } catch (Exception e) {
            error(e);
            return error(-1, "发送失败");
        }
    }
    /**
     * 获取微信用户身份
     * @param code
     * @return
     */
    // @RequestMapping(value = "identity")
    // @ResponseBody
    // public String identity(String code) {
    // try {
    // String openid = getOpenid();
    // if(StringUtils.isEmpty(openid)){
    // openid = getOpenidByCode(code);
    // }
    // if (StringUtils.isEmpty(openid)) {
    // return error(-1, "获取openid异常!");
    // }
    // JSONObject userAgent = new JSONObject();
    // Patient patient = patientService.findByOpenid(openid);
    // long id = 0;
    // String uid = "";
    // String name = "";
    // String photo = "";
    // String tokenStr = "";
    // if (patient != null) {
    // id = patient.getId();
    // uid = patient.getCode();
    // name = patient.getName();
    // photo = patient.getPhoto();
    // // 查询token
    // Token token = SystemData.wxPatientTokens.get(patient.getCode());
    // if (token == null) {
    // // 从数据库加载
    // token = tokenService.findWxToken(patient.getCode());
    // }
    // if (token == null) {
    // // 生成新的token
    // token = tokenService.newTxToken(patient.getCode(), openid);
    // }
    // tokenStr = token.getToken();
    // }
    // userAgent.put("id", id);
    // userAgent.put("uid", uid);
    // userAgent.put("openid", openid);
    // userAgent.put("name", name);
    // userAgent.put("photo", photo);
    // userAgent.put("token", tokenStr);
    // return write(200, "获取身份信息成功!", "data", userAgent);
    // } catch (Exception e) {
    // error(e);
    // return error(-1, "获取身份信息失败!");
    // }
    // }
    /**
     * 获取微信openid
     *
     * @param code
     * @return
     */
    @RequestMapping(value = "getOpenidByCode")
    @ResponseBody
    public String getOpenidByCode(String code) {
        try {
            String openid = super.getOpenidByCode(code);
            if (!StringUtils.isEmpty(openid)) {
                return write(200, "获取openid成功!", "openid", openid);
            } else {
                return error(-1, "获取openid失败!");
            }
        } catch (Exception e) {
            error(e);
            return error(-1, "获取openid失败!");
        }
    }
    /**
     * 判断是否关注
     *
     * @param openid
     * @return
     */
    @RequestMapping(value = "/is_subscribe")
    @ResponseBody
    public String getIsSubscribe(String openid) {
        try {
            String userInfo_url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=" + getAccessToken() + "&openid=" + openid + "&lang=zh_CN";
            String params = "";
            String result = HttpUtil.sendGet(userInfo_url, params);
            JSONObject json = new JSONObject(result);
            if (json.has("subscribe")) {
                return write(200, "查询成功", "subsribe", json.get("subscribe").toString());
            } else {
                return error(-1, json.getString("errmsg"));
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
}

+ 0 - 90
patient-co/patient-co-wlyy-job/src/main/resources/weixin_menu.txt

@ -1,90 +0,0 @@
{
"button":[
   {
	  "name":"家庭医生",
	  "sub_button":[
		  {
			"type":"view",
			"name":"签约管理",
			"url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fqygl%2fhtml%2fsigning_management.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		  },
		  {
			"type":"view",
			"name":"医生咨询",
			"url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fyszx%2fhtml%2fdoctor-consultation.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		  },
		  {
			"type":"view",
			"name":"医生指导",
			"url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fyszd%2fhtml%2fdoctor-guidance.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		  },
		  {
            "type":"view",
            "name":"健康文章",
            "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fjkjy%2fhtml%2farticle_list.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
          }
	  ]
   },
   {
	  "name":"健康管理",
	  "sub_button":[
		 {
			  "type":"view",
			  "name":"预约挂号",
			  "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fwdyy%2fhtml%2fappointment-register.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		 },
		 {
               "type":"view",
               "name":"健康记录",
               "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fjkjl%2fhtml%2fhealth-record.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
         },
		{
			"type":"click",
			"name":"健康档案",
			"key":"jiankangdangan"
		},
         {
            "type":"view",
            "name":"疾病社区",
            "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fjbsq%2fhtml%2fdisease-community.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
        },
        {
            "type":"view",
            "name":"热量查询",
            "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2frlcx%2fhtml%2fserach-index.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
        }
	  ]
   },
   {
	  "name":"我的",
	  "sub_button":[
		{
		   "type":"view",
		   "name":"我的资料",
		   "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fgrzx%2fhtml%2fmy-detail.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		},
        {
           "type":"view",
           "name":"我的家庭",
           "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fjtgx%2fhtml%2ffamily.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
        },
		{
		   "type":"view",
		   "name":"我的设备",
		   "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fwdsb%2fhtml%2fmy-equipments.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		},
        {
         	"type":"click",
         	"name":"操作说明",
         	"key":"caozuoshuoming"
        },
        {
        	 "type":"view",
        	 "name":"意见反馈",
        	 "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fyjfk%2fhtml%2ffeedback.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
        }
	 ]
  }
]
}

+ 0 - 18
patient-co/patient-co-wlyy-job/src/main/webapp/downloadPage.html

@ -1,18 +0,0 @@
<html>
<body>
演示版本下载:
<br>
<b>Android (说明:可以与生产版APP同时安装)</b>
<br>
<ul>
<li>
<a href="http://ehr.yihu.com/ssgg/app/ssgg_doctor_demo_v1.1.3.apk">V1.1.3(Android) -- 发布日期2016-09-07</a></li>
</ul>
<b>IOS (说明:不能与生产版APP同时安装)</b>
<br>
<ul>
<li><a href="itms-services://?action=download-manifest&url=https://ehr.yihu.com/ssgg/ssgg_doctor.plist">V1.1.3(IOS) -- 发布日期2016-09-07</a></li>
</ul>
</body>
</html>

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


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


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


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


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


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


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


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


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


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


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


+ 0 - 31
patient-co/patient-co-wlyy-job/src/main/webapp/ssgg_doctor.plist

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>items</key>
	<array>
		<dict>
			<key>assets</key>
			<array>
				<dict>
					<key>kind</key>
					<string>software-package</string>
					<key>url</key>
					<string>http://ehr.yihu.com/ssgg/app/ssgg_doctor_demo_v1.1.3.ipa</string>
				</dict>
			</array>
			<key>metadata</key>
			<dict>
				<key>bundle-identifier</key>
				<string>com.wjw.ssgg.doctor</string>
				<key>bundle-version</key>
				<string>1.1.3</string>
				<key>kind</key>
				<string>software</string>
				<key>title</key>
				<string>厦门i健康医生端演示版App</string>
			</dict>
		</dict>
	</array>
</dict>
</plist>