Explorar el Código

Merge branch 'dev-1.3.7' of http://192.168.1.220:10080/Amoy/patient-co-management into dev-1.3.7

wujunjie hace 7 años
padre
commit
92f491f4fe

+ 93 - 7
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/PatientInfoService.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.service.app.account;
import com.alibaba.fastjson.JSONArray;
import com.yihu.wlyy.entity.address.City;
import com.yihu.wlyy.entity.address.Province;
import com.yihu.wlyy.entity.address.Street;
@ -32,8 +33,7 @@ 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.service.third.jw.JwArchivesService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.MD5;
import com.yihu.wlyy.util.*;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -42,12 +42,9 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.EncodesUtil;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.net.URLDecoder;
import java.util.*;
/**
 * 患者基本信息类.
@ -94,6 +91,8 @@ public class PatientInfoService extends BaseService {
    JwArchivesService jwArchivesService;
    @Autowired
    JdbcTemplate jdbcTemplate;
    @Autowired
    RSAUtils rsaUtils;
    /**
     * 患者更换手机号
@ -383,4 +382,91 @@ public class PatientInfoService extends BaseService {
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql,new Object[]{name});
        return rs;
    }
    public JSONObject checkPatientArchives(String icCard)throws Exception{
        String rs = jwArchivesService.getSickArchiveFlag(icCard);
        SignFamily signFamily =  signFamilyDao.findByIdcard(icCard);
        JSONObject r = new JSONObject();
        int state = 1;
        if("0".equals(rs)){
            //未建档
            state = -1;
            if(signFamily==null){
                state = -3;
                r.put("state",state);
                r.put("mes","未建档且未签约");
                return r;
            }
            r.put("state",state);
            r.put("mes","未建档且已经签约");
            return r;
        }else{
            if(signFamily==null){
                state = -2;
                r.put("state",state);
                r.put("mes","已建档且未签约");
                return r;
            }else{
                r.put("state",state);
                r.put("mes","已建档已签约");
                return r;
            }
        }
    }
    public JSONObject createProfileAndSign(String doctorCode,
                                           String idcard,
                                           String ssc,
                                           String name,
                                           String mobile,
                                           String brithday,
                                           String jwCountryCode,
                                           String nation,
                                           String blood,
                                           String marry,
                                           String adress)throws Exception{
        JSONObject rs = new  JSONObject();
        // 解密身份证号
        rsaUtils.setBaseService(patientService);
        idcard = rsaUtils.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)) {
                    rs.put("code","-1");
                    rs.put("mes","身份证格式不正确!") ;
                    return rs;
                }
            }
        } else {
            rs.put("code","-1");
            rs.put("mes","身份证格式不正确!") ;
            return rs;
        }
        if(mobile.length()!=11){
            rs.put("code","-2");
            rs.put("mes","手机格式不正确!") ;
            return rs;
        }
        String password = mobile.substring(5,10);
        String salt = UUID.randomUUID().toString().replace("-", "");
        JSONObject p = patientService.registerAPP(idcard,ssc,name,mobile,password,salt,salt,3);
        createProfile(doctorCode , p.getString("uid"), brithday, jwCountryCode, nation, blood, marry,adress);
        rs.put("code","1");
        rs.put("mes","操作成功!") ;
        return rs;
    }
}

+ 34 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java

@ -244,6 +244,40 @@ public class PatientService extends TokenService {
        return null;
    }
    public JSONObject registerAPP(String idcard, String ssc, String name, String mobile
            , String password, String salt, String imei, int platform) throws Exception {
        IdcardInfoExtractor ie = new IdcardInfoExtractor(idcard);
        String code = getCode();
        String sql = "insert wlyy_patient(code,idcard,name,ssc,mobile,password,salt,openid" +
                ",status,birthday,sex,czrq,openid_time,disease,disease_condition,record_amount,points)" +
                " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) ON DUPLICATE KEY UPDATE idcard = ?";
        jdbcTemplate.update(sql, new Object[]{code, idcard, name, ssc, mobile, password, salt, imei, 1, ie.getBirthday()
                , ie.getGender(), clock.getCurrentDate(), clock.getCurrentDate(), 0, 0, 0, 0, idcard});
        Patient temp = patientDao.findByIdcard(idcard);
        if (temp != null) {
            // 更新openid
            updatePatient(temp, imei);
            // 生成登录tokey
            Token token = newToken(temp.getCode(), imei, platform);
            if (token != null) {
                // 生成登录信息成功
                JSONObject json = new JSONObject();
                json.put("id", temp.getId());
                json.put("uid", temp.getCode());
                json.put("token", token.getToken());
                json.put("name", temp.getName());
                json.put("photo", temp.getPhoto());
                json.put("brithday", ie.getBirthday());
                //new Thread(new SignSsGetTask(patient.getIdcard())).start();
                return json;
            }
        }
        return null;
    }
    /**
     * 建立三师团队与患者的关系
     *

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

@ -308,7 +308,8 @@ public class LoginController extends BaseController {
            if (type == 2) {
                // 医生端
                Doctor doctor = doctorService.findDoctorByMobile(mobile);
                String password = RSAUtils.getInstance(doctorService).decryptString(newpwd);
                rsaUtils.setBaseService(doctorService);
                String password = rsaUtils.decryptString(newpwd);
                password = StringUtils.reverse(password);
                password = MD5.GetMD5Code(password + doctor.getSalt());
                doctor.setPassword(password);

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

@ -129,7 +129,10 @@ public class WechatController extends WeixinBaseController {
            //    return error(-1, "该手机号已被注册");
            //}
            // 解密身份证号
            idcard = RSAUtils.getInstance(patientService).decryptString(idcard);
            //idcard = RSAUtils.getInstance(patientService).decryptString(idcard);
            rsaUtils.setBaseService(patientService);
            idcard =rsaUtils.decryptString(idcard);
            idcard = URLDecoder.decode(idcard, "UTF-8");
            idcard = StringUtils.reverse(idcard);
            // 校验身份证号
@ -167,6 +170,7 @@ public class WechatController extends WeixinBaseController {
            }
            return write(200, "验证成功");
        } catch (Exception e) {
            error(e);
            return error(-1, "验证失败");
        }
    }
@ -219,7 +223,8 @@ public class WechatController extends WeixinBaseController {
//				return error(-1, "该微信号已绑定其他手机号!");
//			}
            // 解密身份证号
            idcard = RSAUtils.getInstance(patientService).decryptString(idcard);
            rsaUtils.setBaseService(patientService);
            idcard = rsaUtils.decryptString(idcard);
            idcard = URLDecoder.decode(idcard, "UTF-8");
            idcard = StringUtils.reverse(idcard);
            // 校验身份证号
@ -267,7 +272,8 @@ public class WechatController extends WeixinBaseController {
            //增加密码
            String salt = UUID.randomUUID().toString().replace("-", "");
            patient.setSalt(salt);
            password = RSAUtils.getInstance(patientService).decryptString(password);
            rsaUtils.setBaseService(patientService);
            password = rsaUtils.decryptString(password);
            password = StringUtils.reverse(password);
            patient.setPassword(MD5.GetMD5Code(password + salt));
            patient.setSsc(ssc);
@ -276,7 +282,7 @@ public class WechatController extends WeixinBaseController {
                patient.setOpenidTime(new Date());
            }
            JSONObject json = patientService.register(idcard, ssc, name, mobile, MD5.GetMD5Code(password + salt)
                    , salt, openid, 3);
                    ,salt,openid,3);
            if (json != null) {
                try {
                    Patient p = patientDao.findByIdcard(idcard);

+ 6 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java

@ -94,6 +94,8 @@ public class DoctorController extends BaseController {
    SignPatientLabelDao labelDao;
    @Autowired
    private CommonUtil CommonUtil;
    @Autowired
    private RSAUtils rsaUtils;
    /**
@ -1654,9 +1656,10 @@ public class DoctorController extends BaseController {
                                 String oldPassword,
                                 String doctorCode) {
        try {
            newPassword1 = RSAUtils.getInstance(doctorInfoService).decryptString(newPassword1);
            newPassword2 = RSAUtils.getInstance(doctorInfoService).decryptString(newPassword2);
            oldPassword = RSAUtils.getInstance(doctorInfoService).decryptString(oldPassword);
            rsaUtils.setBaseService(doctorInfoService);
            newPassword1 = rsaUtils.decryptString(newPassword1);
            newPassword2 = rsaUtils.decryptString(newPassword2);
            oldPassword = rsaUtils.decryptString(oldPassword);
            newPassword1 = StringUtils.reverse(newPassword1);
            newPassword2 = StringUtils.reverse(newPassword2);
            oldPassword = StringUtils.reverse(oldPassword);

+ 125 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PatientInfoController.java

@ -6,13 +6,19 @@ import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatientGroup;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatientGroupInfo;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.SocialSecurityInfo;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.patient.SocialSecurityInfoDao;
import com.yihu.wlyy.service.app.account.DoctorInfoService;
import com.yihu.wlyy.service.app.account.DoctorPatientGroupService;
import com.yihu.wlyy.service.app.account.PatientInfoService;
import com.yihu.wlyy.service.app.team.DrHealthTeamService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.IdcardValidator;
import com.yihu.wlyy.util.RSAUtils;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -30,6 +36,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.net.URLDecoder;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
@ -46,6 +53,14 @@ public class PatientInfoController extends BaseController {
    @Autowired
    private PatientInfoService patientInfoService;
    @Autowired
    private RSAUtils rsaUtils;
    @Autowired
    private PatientService patientService;
    @Autowired
    private SocialSecurityInfoDao socialSecurityInfoDao;
    @Autowired
    private PatientDao patientDao;
    /**
     * 获取患者基本信息
     *
@ -139,4 +154,114 @@ public class PatientInfoController extends BaseController {
            return invalidUserException(e, -1, "获取字典信息失败!");
        }
    }
    @RequestMapping(value = "checkPatientArchives",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("判断居民建档状态和签约状态")
    public String checkPatientArchives(@ApiParam(value = "居民身份证", name = "icCard") @RequestParam(required = true)String icCard){
        try {
            // 获取医生下的患者
            return write(200, "获取成功!", "data",patientInfoService.checkPatientArchives(icCard));
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取字典信息失败!");
        }
    }
    /**
     * 注册信息验证
     *
     * @param name   姓名
     * @param idcard 身份证号
     * @param ssc    社保卡号
     * @param mobile 手机号
     * @return
     */
    @RequestMapping(value = "/check_regist_info", method = RequestMethod.POST)
    @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);
            rsaUtils.setBaseService(patientService);
            idcard =rsaUtils.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) {
            error(e);
            return error(-1, "验证失败");
        }
    }
    @RequestMapping(value = "createProfileAndSign",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("居民注册与建档")
    public String createProfileAndSign(@ApiParam(value = "身份证", name = "idcard") @RequestParam(required = true)String idcard,
                                       @ApiParam(value = "医保卡号", name = "ssc") @RequestParam(required = true)String ssc,
                                       @ApiParam(value = "姓名", name = "name") @RequestParam(required = true)String name,
                                       @ApiParam(value = "手机号", name = "mobile") @RequestParam(required = true)String mobile,
                                       @ApiParam(value = "生日", name = "brithday") @RequestParam(required = true)String brithday,
                                       @ApiParam(value = "基卫居委会", name = "jwCountryCode") @RequestParam(required = true)String jwCountryCode,
                                       @ApiParam(value = "民族", name = "nation") @RequestParam(required = true)String nation,
                                       @ApiParam(value = "血型", name = "blood") @RequestParam(required = true)String blood,
                                       @ApiParam(value = "婚姻状况", name = "marry") @RequestParam(required = true)String marry,
                                       @ApiParam(value = "详细地址", name = "adress") @RequestParam(required = true)String adress){
        try {
            // 获取医生下的患者
            return write(200, "建档成功!", "data",patientInfoService.createProfileAndSign(getUID(),idcard,ssc,name,mobile,brithday,jwCountryCode,nation,blood,marry,adress));
        } catch (Exception e) {
            error(e);
            return error( -1, "建档失败!");
        }
    }
}

+ 6 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java

@ -80,6 +80,8 @@ public class DoctorFamilyContractController extends WeixinBaseController {
    private HttpUtil HttpUtil;
    @Value("${sign.check_upload}")
    private String sign_check_upload;
    @Autowired
    private RSAUtils rsaUtils;
    /**
     * 根据姓名、地址、身份证搜索已分配的居民
@ -361,7 +363,8 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            }
            JSONObject json = new JSONObject();
            // 解密身份证号
            idcard = RSAUtils.getInstance(familyContractService).decryptString(idcard);
            rsaUtils.setBaseService(familyContractService);
            idcard = rsaUtils.decryptString(idcard);
            idcard = URLDecoder.decode(idcard, "UTF-8");
            idcard = StringUtils.reverse(idcard);
            if (StringUtils.isEmpty(idcard)) {
@ -441,7 +444,8 @@ public class DoctorFamilyContractController extends WeixinBaseController {
                return error(-1, "请选择健康管理师!");
            }
            // 解密身份证号
            idcard = RSAUtils.getInstance(familyContractService).decryptString(idcard);
            rsaUtils.setBaseService(familyContractService);
            idcard = rsaUtils.decryptString(idcard);
            idcard = URLDecoder.decode(idcard, "UTF-8");
            idcard = StringUtils.reverse(idcard);
            // 校验身份证号

+ 8 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java

@ -74,6 +74,8 @@ public class PatientController extends WeixinBaseController {
    private SignFamilyServerDao signFamilyServerDao;
    @Autowired
    private WeiXinTagUtil weiXinTagUtil;
    @Autowired
    private RSAUtils rsaUtils;
    /**
     * 患者基本信息查询接口
@ -859,9 +861,10 @@ public class PatientController extends WeixinBaseController {
                                 String newPassword2,
                                 String oldPassword) {
        try {
            newPassword1 = RSAUtils.getInstance(doctorService).decryptString(newPassword1);
            newPassword2 = RSAUtils.getInstance(doctorService).decryptString(newPassword2);
            oldPassword = RSAUtils.getInstance(doctorService).decryptString(oldPassword);
            rsaUtils.setBaseService(doctorService);
            newPassword1 = rsaUtils.decryptString(newPassword1);
            newPassword2 = rsaUtils.decryptString(newPassword2);
            oldPassword = rsaUtils.decryptString(oldPassword);
            newPassword1 = StringUtils.reverse(newPassword1);
            newPassword2 = StringUtils.reverse(newPassword2);
            oldPassword = StringUtils.reverse(oldPassword);
@ -981,4 +984,6 @@ public class PatientController extends WeixinBaseController {
            return invalidUserException(e, -1, "获取字典信息失败!");
        }
    }
}

+ 4 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/FamilyContractController.java

@ -57,6 +57,8 @@ public class FamilyContractController extends BaseController {
    private DoctorPatientGroupInfoDao doctorPatientGroupInfoDao;
    @Autowired
    private SignWebService signWebService;
    @Autowired
    private RSAUtils rsaUtils;
    /**
     * 得到患者的签约的医生的信息
     *
@ -346,7 +348,8 @@ public class FamilyContractController extends BaseController {
                return error(-1, "请输入身份证号!");
            }
            // 解密身份证号
            idcard = RSAUtils.getInstance(familyContractService).decryptString(idcard);
            rsaUtils.setBaseService(familyContractService);
            idcard = rsaUtils.decryptString(idcard);
            idcard = URLDecoder.decode(idcard, "UTF-8");
            idcard = StringUtils.reverse(idcard);
            // 校验身份证号

+ 2 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/GcLoginController.java

@ -113,7 +113,8 @@ public class GcLoginController extends WeixinBaseController {
            }
            //身份证登录
            if (StringUtils.isNoneEmpty(account) && StringUtils.isNoneEmpty(password)) {
                password = RSAUtils.getInstance(doctorService).decryptString(password);
                rsaUtils.setBaseService(doctorService);
                password = rsaUtils.decryptString(password);
                password = StringUtils.reverse(password);
                //根据电话号码找
                Doctor doctor = doctorService.findDoctorByMobile(account);