Browse Source

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

liuwenbin 7 years ago
parent
commit
a731e67cbe

+ 173 - 13
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.service.app.account;
import com.alibaba.fastjson.JSON;
import com.yihu.wlyy.entity.address.City;
import com.yihu.wlyy.entity.address.Province;
import com.yihu.wlyy.entity.address.Town;
@ -28,17 +29,18 @@ import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.service.app.talk.TalkGroupService;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.service.third.httplog.LogService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.EncodesUtil;
import com.yihu.wlyy.util.ImUtill;
import com.yihu.wlyy.util.MD5;
import com.yihu.wlyy.util.*;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
@ -54,6 +56,7 @@ import org.springside.modules.persistence.SearchFilter.Operator;
import org.springside.modules.security.utils.Digests;
import org.springside.modules.utils.Encodes;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@ -113,6 +116,16 @@ public class DoctorInfoService extends BaseService {
    @Autowired
    private PushMsgTask pushMsgTask;
    //基卫服务地址
    @Value("${sign.check_upload}")
    private String jwUrl;
    @Autowired
    private HttpClientUtil HttpClientUtil;
    @Autowired
    private LogService logService;
    /**
     * 获取医生的签约病人
     *
@ -1268,17 +1281,164 @@ public class DoctorInfoService extends BaseService {
        }
    }
//    /**
//     * 审方密码设置
//     * @param passwoed
//     * @return
//     */
//    @Transactional
//    public void setCheckPassword(Doctor doctor,String passwoed){
//
//        byte[] salt = Digests.generateSalt(8);
//        doctor.setCheckSalt(Encodes.encodeHex(salt));
//        byte[] hashPassword = Digests.sha1(passwoed.getBytes(), salt, 1024);
//        doctor.setCheckPassword(Encodes.encodeHex(hashPassword));
//    }
    /**
     * 审方密码设置
     * @param passwoed
     * @return
     * 获取CA证书过期时间
     */
    @Transactional
    public void setCheckPassword(Doctor doctor,String passwoed){
    public JSONObject getCAPastDue(String strUserIdcardNum)  throws Exception{
        Boolean isSuccess = true;
        String url = jwUrl+"/third/prescription/GetRealNameSoftCertExpiredDatetime";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("strUserIdcardNum",strUserIdcardNum));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        if (!StringUtils.isEmpty(response)){
            JSONObject responseObject = new JSONObject(response);
            int status = responseObject.getInt("status");
            String msg = responseObject.getString("msg");
            if (status == 200) {
                String data = responseObject.getString("data");
                if (!StringUtils.isEmpty(data) && data.startsWith("error")) {
                    throw new Exception(data);
                } else {
//                    JSONObject jsonData = new JSONObject(data);
//                    JSONArray jsonArray = jsonData.getJSONArray("EventList");
//                    re = jsonArray.toString();
                    JSONObject jsonObject = new JSONObject();
                    //1、有证书,并有效,2、有证书,已过期,3、无证书
                    if(StringUtils.isNotEmpty(data)){
                        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                        long times = simpleDateFormat.parse(data).getTime();
                        if(System.currentTimeMillis()<=times){
                            jsonObject.put("type",1);
                        }else{
                            jsonObject.put("type",2);
                        }
                    }else{
                        jsonObject.put("type",3);
                    }
                    jsonObject.put("time",data);
                    return jsonObject;
                }
            } else {
                throw new Exception(responseObject.getString("msg"));
            }
        }else {
            throw new Exception("null response.");
        }
    }
        byte[] salt = Digests.generateSalt(8);
        doctor.setCheckSalt(Encodes.encodeHex(salt));
        byte[] hashPassword = Digests.sha1(passwoed.getBytes(), salt, 1024);
        doctor.setCheckPassword(Encodes.encodeHex(hashPassword));
    /**
     * 修改实名软证书调用保护口令
     */
    public boolean updateAuthenticationPassword(String strUserIdcardNum,String strOldCalledPasswd,String strNewCalledPasswd) throws Exception{
        String url = jwUrl+"/third/prescription/ModifyRealNameSoftCertCalledPasswd";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("strUserIdcardNum",strUserIdcardNum));
        params.add(new BasicNameValuePair("strOldCalledPasswd",strOldCalledPasswd));
        params.add(new BasicNameValuePair("strNewCalledPasswd",strNewCalledPasswd));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        if (!StringUtils.isEmpty(response)){
            JSONObject responseObject = new JSONObject(response);
            int status = responseObject.getInt("status");
            String msg = responseObject.getString("msg");
            if (status == 200) {
                String data = responseObject.getString("data");
                if (!StringUtils.isEmpty(data) && data.startsWith("error")) {
                    throw new Exception(data);
                }else{
                    if("0".equals(data)){
                        return true;
                    }
                }
            }else{
                throw new Exception(responseObject.getString("msg"));
            }
        }else{
            throw new Exception("null response.");
        }
        return false;
    }
    public boolean requestRealNameSoftCertAndSign(String strUserIdcardNum,String strRealNameSoftCertCalledPasswd,String strOriginalData, String srcBusinessStreamNO) throws Exception{
        String url = jwUrl+"/third/prescription/RequestRealNameSoftCertAndSign";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("strUserIdcardNum",strUserIdcardNum));
        params.add(new BasicNameValuePair("strRealNameSoftCertCalledPasswd",strRealNameSoftCertCalledPasswd));
        params.add(new BasicNameValuePair("strOriginalData",strOriginalData));
        params.add(new BasicNameValuePair("srcBusinessStreamNO",srcBusinessStreamNO));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        if (!StringUtils.isEmpty(response)){
            JSONObject responseObject = new JSONObject(response);
            int status = responseObject.getInt("status");
            String msg = responseObject.getString("msg");
            if (status == 200) {
                String data = responseObject.getString("data");
                if (!StringUtils.isEmpty(data) && data.startsWith("error")) {
                    throw new Exception(data);
                }else{
                    String[] str = data.split("||");
//                    String strSignData = str[0];
//                    String strCertData = str[1];
//                    JSONObject jsonObject = new JSONObject();
//                    jsonObject.put("strSignData",str[0]);
//                    jsonObject.put("strCertData",str[1]);
                    return verifySignOnMultiServer(str[0],str[1],strOriginalData);
//                    return jsonObject;
                }
            }else{
                throw new Exception(responseObject.getString("msg"));
            }
        }else{
            throw new Exception("null response.");
        }
    }
    //验证签名( ( 带多服务器负载均衡) )
    public boolean verifySignOnMultiServer(String strSignData,String strCertData,String strOriginalData) throws Exception{
        String url = jwUrl+"/third/prescription/VerifySignOnMultiServer";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("strSignData",strSignData));
        params.add(new BasicNameValuePair("strCertData",strCertData));
        params.add(new BasicNameValuePair("strOriginalData",strOriginalData));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        if (!StringUtils.isEmpty(response)){
            JSONObject responseObject = new JSONObject(response);
            int status = responseObject.getInt("status");
            String msg = responseObject.getString("msg");
            if (status == 200) {
                String data = responseObject.getString("data");
                if (!StringUtils.isEmpty(data) && data.startsWith("error")) {
                    throw new Exception(data);
                }else{
                    if("0".equals(data)){
                        return true;
                    }
                }
            }else{
                throw new Exception(responseObject.getString("msg"));
            }
        }else{
            throw new Exception("null response.");
        }
        return false;
    }
}

+ 4 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/httplog/LogService.java

@ -22,9 +22,10 @@ public class LogService {
    private SystemDictService systemDictService;
    public String openApiType = "0";
    public String signType = "1";
    public String archiveType = "2";
    public String onepayType = "3";
    public String signType = "1";   //签约
    public String archiveType = "2";    //档案
    public String onepayType = "3"; //医保支付
    public String caType = "4";     //CA认证

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

@ -26,9 +26,12 @@ import com.yihu.wlyy.util.*;
import io.swagger.annotations.Api;
import io.swagger.models.auth.In;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.MediaType;
@ -95,6 +98,7 @@ public class DoctorController extends BaseController {
    @Autowired
    private CommonUtil CommonUtil;
    /**
     * 社区医院下医生列表查询接口 没分页
     *
@ -1888,57 +1892,119 @@ public class DoctorController extends BaseController {
        }
    }
    /**
     * 设置审方密码
     * @param password
     * @return
     */
    @RequestMapping(value = "/setCheckPassword", method = RequestMethod.POST)
    @ResponseBody
//    /**
//     * 设置审方密码
//     * @param password
//     * @return
//     */
//    @RequestMapping(value = "/setCheckPassword", method = RequestMethod.POST)
//    @ResponseBody
//    @ObserverRequired
//    public String setCheckPassword(@RequestParam String password){
//
//        try {
//
//            Doctor doctor = doctorInfoService.findDoctorByCode(getUID());
//            if (doctor == null) {
//                return error(-1, "密码设置失败!");
//            }
////            doctorInfoService.setCheckPassword(doctor,password);
//            return write(200, "密码设置成功");
//        }catch (Exception e){
//            error(e);
//            return invalidUserException(e, -1, "密码设置失败");
//        }
//    }
//    /**
//     * 修改审方密码
//     * @param oldPassword
//     * @param newPassword
//     * @return
//     */
//    @ObserverRequired
//    @ResponseBody
//    @RequestMapping(value = "/updateCheckPassword", method = RequestMethod.POST)
//    public String updateCheckPassword(@RequestParam String oldPassword,@RequestParam String newPassword){
//
//        try {
//            Doctor doctor = doctorInfoService.findDoctorByCode(getUID());
//            if (doctor == null) {
//                return error(-1, "修改审方密码失败!");
//            } else {
//                String encodePWD = EncodesUtil.entryptPassword(Encodes.decodeHex(doctor.getCheckSalt()), oldPassword);
//                if (StringUtils.equals(doctor.getCheckPassword(), encodePWD)) {
////                    doctorInfoService.setCheckPassword(doctor,newPassword);
//                    return write(200, "密码设置成功");
//                } else {
//                    return error(-1, "修改失败:审方旧密码错误!");
//                }
//            }
//        } catch (Exception e) {
//            error(e);
//            return invalidUserException(e, -1, "修改失败!");
//        }
//    }
    //获取实名软证书的过期时间
    @ObserverRequired
    public String setCheckPassword(@RequestParam String password){
    @ResponseBody
    @RequestMapping(value = "/getAuthenticationCA", method = RequestMethod.GET)
    public String getAuthenticationCA(){
        try {
            Doctor doctor = doctorInfoService.findDoctorByCode(getRepUID());
            JSONObject data = doctorInfoService.getCAPastDue(doctor.getIdcard());
            return write(200, "获取信息成功!", "data", data);
        }catch (Exception e) {
            error(e);
            return error(-1, "获取信息失败!");
        }
            Doctor doctor = doctorInfoService.findDoctorByCode(getUID());
            if (doctor == null) {
                return error(-1, "密码设置失败!");
    }
    //修改实名软证书调用保护口令
    @ObserverRequired
    @ResponseBody
    @RequestMapping(value = "/updateAuthenticationPassword", method = RequestMethod.POST)
    public String updateAuthenticationPassword(
            @RequestParam(value = "strOldCalledPasswd",required = true) String strOldCalledPasswd,
            @RequestParam(value = "strNewCalledPasswd",required = true) String strNewCalledPasswd){
        try {
            Doctor doctor = doctorInfoService.findDoctorByCode(getRepUID());
            boolean b = doctorInfoService.updateAuthenticationPassword(doctor.getIdcard(),strOldCalledPasswd,strNewCalledPasswd);
            if(b){
                return write(200, "修改密码成功!", "data", b);
            }
            doctorInfoService.setCheckPassword(doctor,password);
            return write(200, "密码设置成功");
        }catch (Exception e){
            return error(-1, "修改密码失败!");
        }catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "密码设置失败");
            return error(-1, "修改密码失败!");
        }
    }
    /**
     * 修改审方密码
     * @param oldPassword
     * @param newPassword
     * @return
     * 请求实名软证书并进行数字签名
     */
    @ObserverRequired
    @ResponseBody
    @RequestMapping(value = "/updateCheckPassword", method = RequestMethod.POST)
    public String updateCheckPassword(@RequestParam String oldPassword,@RequestParam String newPassword){
    @RequestMapping(value = "/requestRealNameSoftCertAndSign", method = RequestMethod.POST)
    public String requestRealNameSoftCertAndSign(
            @RequestParam(value = "strRealNameSoftCertCalledPasswd",required = true) String strRealNameSoftCertCalledPasswd,
            @RequestParam(value = "strOriginalData",required = true) String strOriginalData,
            @RequestParam(value = "srcBusinessStreamNO",required = true) String srcBusinessStreamNO){
        try {
            Doctor doctor = doctorInfoService.findDoctorByCode(getUID());
            if (doctor == null) {
                return error(-1, "修改审方密码失败!");
            } else {
                String encodePWD = EncodesUtil.entryptPassword(Encodes.decodeHex(doctor.getCheckSalt()), oldPassword);
                if (StringUtils.equals(doctor.getCheckPassword(), encodePWD)) {
                    doctorInfoService.setCheckPassword(doctor,newPassword);
                    return write(200, "密码设置成功");
                } else {
                    return error(-1, "修改失败:审方旧密码错误!");
                }
            Doctor doctor = doctorInfoService.findDoctorByCode(getRepUID());
//            JSONObject obj = doctorInfoService.requestRealNameSoftCertAndSign(doctor.getIdcard(),strRealNameSoftCertCalledPasswd,strOriginalData,srcBusinessStreamNO);
            boolean b = doctorInfoService.requestRealNameSoftCertAndSign(doctor.getIdcard(),strRealNameSoftCertCalledPasswd,strOriginalData,srcBusinessStreamNO);
            if(b){
                return write(200, "认证成功!", "data", b);
            }
        } catch (Exception e) {
            return error(-1, "认证失败!");
        }catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "修改失败!");
            return error(-1, "认证失败!");
        }
    }
}