liuwenbin hace 7 años
padre
commit
d8ce922958

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

@ -15,6 +15,7 @@ import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeamMember;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.WlyyPatientSick;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.repository.address.CityDao;
import com.yihu.wlyy.repository.address.ProvinceDao;
import com.yihu.wlyy.repository.address.TownDao;
@ -25,6 +26,7 @@ import com.yihu.wlyy.repository.doctor.*;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientSickDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.service.app.talk.TalkGroupService;
@ -116,9 +118,12 @@ public class DoctorInfoService extends BaseService {
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private PrescriptionDao prescriptionDao;
    //基卫服务地址
    @Value("${sign.check_upload}")
    private String jwUrl;
    private String jwUrl;//="http://192.168.131.105:8011";
    @Autowired
    private HttpClientUtil HttpClientUtil;
@ -1295,19 +1300,49 @@ public class DoctorInfoService extends BaseService {
//        doctor.setCheckPassword(Encodes.encodeHex(hashPassword));
//    }
    /**
     *  判断实名软证书是否已申请
     */
    public boolean judgeRealNameSoftCertIsApplied(String doctorCode) throws Exception{
        Doctor doctor = findDoctorByCode(doctorCode);
        String strUserIdcardNum = doctor.getIdcard();
        String data ="";
        String url = jwUrl+"/third/prescription/IsApplied";
        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");
            if (status == 200) {
                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("null response.");
        }
        return false;
    }
    /**
     * 获取线上CA是否认证过
     */
    public JSONObject isAuthentication(String doctorCode)  throws Exception{
    public JSONObject isAuthentication(String doctorCode) throws Exception{
        Doctor doctor = findDoctorByCode(doctorCode);
        String strUserIdcardNum = doctor.getIdcard();
//        String strUserIdcardNum = doctor.getIdcard();
        Boolean isSuccess = true;
        JSONObject jsonObject = new JSONObject();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if(doctor.getIscertified()==1){
            if(doctor.getCertifiedOvertime().getTime()>System.currentTimeMillis()){
                //1、线上未认证,有证书,并有效,2、线上未认证,有证书,已过期,3、线上未认证,无证书,4、线上已认证,并有效
                jsonObject.put("type",4);
                String data = simpleDateFormat.format(doctor.getCertifiedOvertime());
                jsonObject.put("time",data);
@ -1315,17 +1350,20 @@ public class DoctorInfoService extends BaseService {
                jsonObject = getCAPastDue(doctorCode,jsonObject);
            }
        }else{
            jsonObject = getCAPastDue(doctorCode,jsonObject);
            boolean j = judgeRealNameSoftCertIsApplied(doctorCode);
            if(j){
                jsonObject = getCAPastDue(doctorCode,jsonObject);
            }else{
                jsonObject.put("type",3);
            }
        }
        return jsonObject;
    }
    /**
     * 获取CA证书过期时间
     */
    @Transactional
    public JSONObject getCAPastDue(String doctorCode,JSONObject jsonObject)  throws Exception{
        Doctor doctor = findDoctorByCode(doctorCode);
        String strUserIdcardNum = doctor.getIdcard();
@ -1340,7 +1378,6 @@ public class DoctorInfoService extends BaseService {
        if (!StringUtils.isEmpty(response)){
            JSONObject responseObject = new JSONObject(response);
            int status = responseObject.getInt("status");
            String msg = responseObject.getString("msg");
            if (status == 200) {
                data = responseObject.getString("data");
                if (!StringUtils.isEmpty(data) && data.startsWith("error")) {
@ -1358,12 +1395,13 @@ public class DoctorInfoService extends BaseService {
                            jsonObject.put("type",2);
                        }
                    }else{
                        jsonObject.put("type",3);
//                        jsonObject.put("type",3);
                        throw new Exception("null data.");
                    }
                }
            } else {
                throw new Exception(responseObject.getString("msg"));
                jsonObject.put("type",3);
            }
        }else {
            throw new Exception("null response.");
@ -1413,18 +1451,19 @@ public class DoctorInfoService extends BaseService {
     * @param strUserIdcardNum
     * @param strRealNameSoftCertCalledPasswd
     * @param strOriginalData
     * @param srcBusinessStreamNO
     * @return
     * @throws Exception
     */
    public boolean requestRealNameSoftCertAndSign(String strUserIdcardNum,String strRealNameSoftCertCalledPasswd,String strOriginalData, String srcBusinessStreamNO) throws Exception{
    @Transactional
    public JSONObject requestRealNameSoftCertAndSign(String strUserIdcardNum,String strRealNameSoftCertCalledPasswd,String strOriginalData,String prescriptionCode) 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));
        params.add(new BasicNameValuePair("strOriginalData",MD5.GetMD5Code(strOriginalData)));
//        params.add(new BasicNameValuePair("srcBusinessStreamNO",srcBusinessStreamNO));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        if (!StringUtils.isEmpty(response)){
            JSONObject responseObject = new JSONObject(response);
@ -1438,11 +1477,17 @@ public class DoctorInfoService extends BaseService {
                    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;
                    JSONObject jsonObject = new JSONObject();
                    jsonObject.put("strSignData",str[0]);
                    jsonObject.put("strCertData",str[1]);
                    jsonObject.put("srcBusinessStreamNO",str[2]);
                    Prescription prescription = prescriptionDao.findByCode(prescriptionCode);
                    prescription.setCaMessage(str[0]);
                    prescription.setCaCertData(str[1]);
                    prescriptionDao.save(prescription);
//                    String srcBusinessStreamNO = str[2];//CA 数字签名唯一流水号
//                    return verifySignOnMultiServer(str[0],str[1],strOriginalData);
                    return jsonObject;
                }
            }else{
                throw new Exception(responseObject.getString("msg"));
@ -1459,7 +1504,7 @@ public class DoctorInfoService extends BaseService {
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("strSignData",strSignData));
        params.add(new BasicNameValuePair("strCertData",strCertData));
        params.add(new BasicNameValuePair("strOriginalData",strOriginalData));
        params.add(new BasicNameValuePair("strOriginalData",MD5.GetMD5Code(strOriginalData)));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        if (!StringUtils.isEmpty(response)){
            JSONObject responseObject = new JSONObject(response);
@ -1485,8 +1530,6 @@ public class DoctorInfoService extends BaseService {
    //校验医师输入的CA证书是否正确
    public boolean  checkCertificate(String doctorCode,String certificateNum){
        List<NameValuePair> params = new ArrayList<>();
        String response = HttpClientUtil.post("http://120.77.209.211:5000/yueren/phonekey", params, "UTF-8");
        int count = doctorDao.checkCertificate(doctorCode,certificateNum);
        if(count>0){
            return true;

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionDispensaryCodeService.java

@ -193,7 +193,7 @@ public class PrescriptionDispensaryCodeService extends BaseService {
    }
    public Map<String, Object> getQrcode(String dispensaryCode ,String patientCode ,Integer type){
        String sql = "select p2.code as dispensaryCode,p2.img_url,p3.hospital_name as hospitalName  from wlyy_prescription_dispensary_code p2 " +
        String sql = "select  p2.is_use as isUse,p2.code as dispensaryCode,p2.img_url,p3.hospital_name as hospitalName  from wlyy_prescription_dispensary_code p2 " +
                " left join  wlyy_prescription p1 on p2.prescription_code=p1.code LEFT JOIN wlyy_prescription_expressage p3 on p1.code=p3.prescription_code " +
                " where p2.prescription_code=? and p1.patient=? and p2.type=?  and p2.is_Use=0 ";
        Map<String, Object> result = jdbcTemplate.queryForMap(sql,dispensaryCode,patientCode,type);

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

@ -1871,11 +1871,12 @@ public class DoctorController extends BaseController {
    @RequestMapping(value = "/isAuthentication", method = RequestMethod.GET)
    public String isAuthentication(){
        try {
            //0de6a26a62dd11e69faffa163e8aee56
            JSONObject data = doctorInfoService.isAuthentication(getRepUID());
            return write(200, "获取信息成功!", "data", data);
        }catch (Exception e) {
            error(e);
            return error(-1, "获取信息失败!");
            return error(-1, e.getMessage());
        }
    }
@ -1896,7 +1897,7 @@ public class DoctorController extends BaseController {
            return error(-1, "修改密码失败!");
        }catch (Exception e) {
            error(e);
            return error(-1, "修改密码失败!");
            return error(-1, e.getMessage());
        }
    }
@ -1910,19 +1911,19 @@ public class DoctorController extends BaseController {
    public String requestRealNameSoftCertAndSign(
            @RequestParam(value = "strRealNameSoftCertCalledPasswd",required = true) String strRealNameSoftCertCalledPasswd,
            @RequestParam(value = "strOriginalData",required = true) String strOriginalData,
            @RequestParam(value = "srcBusinessStreamNO",required = true) String srcBusinessStreamNO){
            @RequestParam(value = "prescriptionCode",required = true) String prescriptionCode){
        try {
            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);
            }
            return error(-1, "认证失败!");
            JSONObject jsonObject = doctorInfoService.requestRealNameSoftCertAndSign(doctor.getIdcard(),strRealNameSoftCertCalledPasswd,strOriginalData,prescriptionCode);
//            if(b){
            return write(200, "获取信息成功!", "data", jsonObject);
//            }
//            return error(-1, "认证失败!");
        }catch (Exception e) {
            error(e);
            return error(-1, "认证失败!");
            return error(-1, e.getMessage());
        }
    }
@ -1940,8 +1941,29 @@ public class DoctorController extends BaseController {
            return write(200, "获取信息成功!", "data", b);
        }catch (Exception e) {
            error(e);
            return error(-1, "获取信息失败!");
            return error(-1, e.getMessage());
        }
    }
    /**
     * 验证签名( ( 带多服务器负载均衡) )
     */
    @ApiOperation("验证签名")
    @ObserverRequired
    @ResponseBody
    @RequestMapping(value = "/verifySignOnMultiServer", method = RequestMethod.GET)
    public String verifySignOnMultiServer(
            @RequestParam(value = "strSignData",required = true) String strSignData,
            @RequestParam(value = "strCertData",required = true) String strCertData,
            @RequestParam(value = "strOriginalData",required = true) String strOriginalData){
            try {
                boolean b = doctorInfoService.verifySignOnMultiServer(strSignData,strCertData,strOriginalData);
                return write(200, "获取信息成功!", "data", b);
            }catch (Exception e) {
                error(e);
                return error(-1, e.getMessage());
            }
    }
}

+ 0 - 57
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionNoticesController.java

@ -1,57 +0,0 @@
package com.yihu.wlyy.web.doctor.prescription;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.service.app.prescription.PrescriptionDispensaryCodeService;
import com.yihu.wlyy.service.app.prescription.PrescriptionExpressageService;
import com.yihu.wlyy.service.app.prescription.PrescriptionNoticesService;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.WeixinBaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * Created by Reece on 2017/8/3.
 */
@RestController
@RequestMapping(value = "/doctor/prescriptionNotices")
@Api(description = "医生端-长处方模板消息接口")
public class PrescriptionNoticesController extends WeixinBaseController {
    @Autowired
    private PrescriptionNoticesService noticesService;
    /**
     * 医生端及基卫发送给居民的模板消息
     * @param doctor   相关医生信息
     * @param patient  目标居民信息
     * @param checkDoctor  审核医生姓名
     * @param ordenTime     订单完成时间 时间字符串格式yyyy-MM-dd HH:mm:ss
     * @param type       1:续方审核通知 2:取药代办通知 3:配送中信息变更 4:已完成服务结果
     * @param status    续方通知状态 0不通过 1通过 2调整处方  其余模板通知消息状态均为0
     * @return
     */
    @RequestMapping(value = "/sendMessage", method = RequestMethod.POST)
    @ApiOperation(value = "模板消息发送")
    public String sendMessage(
            @RequestParam() @ApiParam(value = "相关医生信息", name = "doctor")String doctor,
            @RequestParam() @ApiParam(value = "目标居民信息", name = "patient")String patient,
            @RequestParam() @ApiParam(value = "审核医生姓名", name = "checkDoctor")String checkDoctor,
            @RequestParam() @ApiParam(value = "订单完成时间 格式yyyy-MM-dd HH:mm:ss", name = "ordenTime")String ordenTime,
            @RequestParam() @ApiParam(value = "模板类型", name = "type")int type,
            @RequestParam() @ApiParam(value = "模板", name = "status")int status) {
        try {
            String accessToken = getAccessToken();
            noticesService.sendMessages(accessToken,doctor,patient,checkDoctor,ordenTime,type,status);
            return write(200, "配送成功");
        } catch (Exception e) {
            return error(-1, "失败");
        }
    }
}