Parcourir la source

修改bug和新增pc端接口

liuwenbin il y a 8 ans
Parent
commit
5e55a0177a

+ 2 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/SwaggerConfig.java

@ -29,7 +29,8 @@ public class SwaggerConfig {
                .forCodeGeneration(true)
                .pathMapping("/")
                .select()
                .paths(PathSelectors.regex("/doctor/.*"))
                .paths(or(regex("/doctor/.*"),
                        regex("/PC/.*")))
                .build()
                .apiInfo(publicApiInfo());
    }

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctorDao.java

@ -159,6 +159,6 @@ public interface DoctorDao extends PagingAndSortingRepository<Doctor, Long>, Jpa
    @Query("update Doctor set checkPassword = ?2 ,checkSalt = ?3  where code = ?1")
    int updateCheckPassword(String code, String checkPassword, String checkSalt);
    @Query("select count(1) from Doctor where code=?1 and certificateNum=?2 ")
    @Query("select count(1) from Doctor where code=?1 and idcard=?2 ")
    Integer checkCertificate(String doctorCode,String certificateNum);
}

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

@ -203,8 +203,11 @@ public class PrescriptionDispensaryCodeService extends BaseService {
        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,prescriptionCode,patientCode,type);
        return result;
        List<Map<String, Object>> result = jdbcTemplate.queryForList(sql,prescriptionCode,patientCode,type);
        if(result.size()>0){
            return result.get(0);
        }
        return null;
    }
    @Transactional

+ 0 - 288
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/pc/prescription/PCPrescriptionExpressageService.java

@ -1,288 +0,0 @@
package com.yihu.wlyy.service.pc.prescription;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionDispensaryCode;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import com.yihu.wlyy.repository.prescription.PrescriptionDispensaryCodeDao;
import com.yihu.wlyy.repository.prescription.PrescriptionExpressageDao;
import com.yihu.wlyy.repository.prescription.PrescriptionLogDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.prescription.PrescriptionInfoService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.RoleService;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
 * Created by liuwenbin on 2017/8/12.
 * PC端长处方取药/领药业务层
 */
@Service
public class PCPrescriptionExpressageService extends BaseService {
    @Autowired
    private PrescriptionDispensaryCodeDao prescriptionDispensaryCodeDao;
    @Autowired
    private PrescriptionLogDao prescriptionLogDao;
    @Autowired
    private RoleService roleService;
    @Autowired
    private DoctorService doctorService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PrescriptionExpressageDao prescriptionExpressageDao;
    @Autowired
    private PrescriptionInfoService prescriptionInfoService;
    public Integer getMedicine(String code,String userCode){
        JSONObject jsonObject = new JSONObject();
        //获取根据wlyy_prescription_dispensary_code的code处方编码
        PrescriptionDispensaryCode prescriptionDispensaryCode = prescriptionDispensaryCodeDao.finByCode(code);
        Integer returnStatus = -1;
        if (prescriptionDispensaryCode == null) {
            //保存验证二维码的日志
            PrescriptionLog prescriptionLog = new PrescriptionLog();
            prescriptionLog.setCode(UUID.randomUUID().toString());
            prescriptionLog.setPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
            prescriptionLog.setCreateTime(new Date());
            prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
            prescriptionLog.setFlag(1);
            prescriptionLog.setUserCode(userCode);
            prescriptionLog.setUserType(2);
            prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing_error.getValue());
            prescriptionLog.setRemark("编码不存在");
            prescriptionLogDao.save(prescriptionLog);
            returnStatus = -1;
            return returnStatus;
        }
        if (prescriptionDispensaryCode.getIsUse() == 1) {
            //判断编码是否使用过
            PrescriptionLog prescriptionLog = new PrescriptionLog();
            prescriptionLog.setCode(UUID.randomUUID().toString());
            prescriptionLog.setPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
            prescriptionLog.setCreateTime(new Date());
            prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
            prescriptionLog.setFlag(1);
            prescriptionLog.setUserCode(userCode);
            prescriptionLog.setUserType(2);
            prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing_error.getValue());
            prescriptionLog.setRemark("编码重复扫描");
            prescriptionLogDao.save(prescriptionLog);
            returnStatus = -2;
            return returnStatus;
        }
        // 判断出药机构是否与健管师所属机构一致,不一致弹窗提示:“出药机构与您所在机构不一致,无法出药,请重新确认”。一致则进入下一步。
        //获取医生角色和区域权限
//        List<Map<String, String>> roleMap = roleService.getUserRoleAndArea(userCode);
//        if("10".equals(doctor.getLevel())&&roleMap.size()==0){
//            errorMessage="该用户没有管理员权限";
//            loginLog.setErrorMessage(errorMessage);
//            loginLogService.saveLog(loginLog);
//            return error(-1, errorMessage);
//        }
        switch (prescriptionDispensaryCode.getType()) {
            case 1: {
                //判断是1 居民取药码
//                returnStatus = dispensaryCode_1(userCode, prescriptionDispensaryCode);
                break;
            }
            case 2: {
                //判断是2 配送员(健管师)取药码
//                returnStatus = dispensaryCode_2(userCode, prescriptionDispensaryCode);
                break;
            }
            case 3: {
                //判断是3 配送员(健管师)配送码
//                returnStatus = dispensaryCode_3(userCode, prescriptionDispensaryCode);
                break;
            }
            default: {
                PrescriptionLog prescriptionLog = new PrescriptionLog();
                prescriptionLog.setCode(UUID.randomUUID().toString());
                prescriptionLog.setPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
                prescriptionLog.setCreateTime(new Date());
                prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
                prescriptionLog.setFlag(1);
                prescriptionLog.setUserCode(userCode);
                prescriptionLog.setUserType(2);
                prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing_error.getValue());
                prescriptionLog.setRemark("编码类型错误");
                prescriptionLogDao.save(prescriptionLog);
                returnStatus = -3;
                return returnStatus;
            }
        }
        return 0;
    }
    //健管师取药码
    public JSONObject dispensaryCode_2(String userCode,PrescriptionDispensaryCode prescriptionDispensaryCode){
//        Integer returnStatus = -3;
        JSONObject jsonObject = new JSONObject();
        Doctor doctor = doctorService.findDoctorByCode(userCode);
        String sql = "select a.type,c.status,b.hospital_code as hospitalCode from wlyy_prescription_dispensary_code a \n" +
                "left join wlyy_prescription_expressage b on a.prescription_code = b.prescription_code \n" +
                "left join wlyy_prescription c on a.prescription_code = c.code \n" +
                "where a.prescription_code=?";
        Map<String, Object> result = jdbcTemplate.queryForMap(sql,prescriptionDispensaryCode.getPrescriptionCode());
        if(result.size()>0){
            int status = (Integer)result.get("status");
            if((Integer)result.get("type")==1){//居民取药码
                if(status>=30){
                    if(status==30){
                        jsonObject.put("status",-5);//订单正在配药中,暂时无法出药
                    }else if(status==40){
                        jsonObject.put("status",1);//取药成功
                    }else{
                        jsonObject.put("status",-6);//”订单已取药,出药人:张三,出药时间:XXXX-XX-XX,无法重新出药
                    }
                }
            }else if((Integer)result.get("type")==2){//健管师取药码
                if(result.get("hospitalCode").toString().equals(doctor.getHospital())){
                    //20开方完成/待支付, 21 支付失败 , 30 支付成功/待配药 , 40配药成功/待配送  41配送失败 42分配健管师 45配送中   49配送到服务站  100配送到患者手中/已完成
                    if(status==30){
                        jsonObject.put("status",-5);//订单正在配药中,暂时无法出药
                    }else if(status>=45){
                        jsonObject.put("status",-6);//”订单已取药,出药人:张三,出药时间:XXXX-XX-XX,无法重新出药
                    }else if(status==40){
                        jsonObject.put("status",1);
                    }
                }else{
                    jsonObject.put("status",-4);//出药机构与您所在机构不一致,无法出药,请重新确认
//            return jsonObject;
                }
            }else{
                jsonObject.put("status",-7); //取药码错误
                //保存验证二维码的日志
                PrescriptionLog prescriptionLog = new PrescriptionLog();
                prescriptionLog.setCode(UUID.randomUUID().toString());
                prescriptionLog.setPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
                prescriptionLog.setCreateTime(new Date());
                prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
                prescriptionLog.setFlag(1);
                prescriptionLog.setUserCode(userCode);
                prescriptionLog.setUserType(2);
                prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing_error.getValue());
                prescriptionLog.setRemark("PC端取药码输入错误!");
                prescriptionLogDao.save(prescriptionLog);
            }
        }else{
            jsonObject.put("status",-7); //取药码错误
            //保存验证二维码的日志
            PrescriptionLog prescriptionLog = new PrescriptionLog();
            prescriptionLog.setCode(UUID.randomUUID().toString());
            prescriptionLog.setPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
            prescriptionLog.setCreateTime(new Date());
            prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
            prescriptionLog.setFlag(1);
            prescriptionLog.setUserCode(userCode);
            prescriptionLog.setUserType(2);
            prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing_error.getValue());
            prescriptionLog.setRemark("编码不存在");
            prescriptionLogDao.save(prescriptionLog);
        }
        jsonObject.put("result",result);
        return jsonObject;
    }
    public JSONObject getMedicine2(String code,String userCode){
        JSONObject jsonObject = new JSONObject();
        Doctor doctor = doctorService.findDoctorByCode(userCode);
        String sql = "select a.type,a.prescription_code as prescriptionCode c.status,b.hospital_code as hospitalCode, \n" +
                "b.code as expressageCode, b.hospital_name as hospitalName,c.dispensary_type as dispensaryType, \n" +
                "b.expressage_name as expressageName, b.expressage_code as expressageCode,b.expressage_mobile as expressageMobile \n" +
                "from wlyy_prescription_dispensary_code a \n" +
                "left join wlyy_prescription_expressage b on a.prescription_code = b.prescription_code \n" +
                "left join wlyy_prescription c on a.prescription_code = c.code \n" +
                "where a.is_use=0 and a.cod=? and c.status>=30";
        Map<String, Object> result = jdbcTemplate.queryForMap(sql,code);
        if(result.size()>0){
            int type = result.get("type")!=null?(Integer) result.get("type"):0;
            int status = result.get("status")!=null?(Integer) result.get("status"):-100;
            switch (type){
                //居民取药码
                case 1:{
                    if(status==30){
                        jsonObject.put("status",-5);//订单正在配药中,暂时无法出药
                    }else if(status==40){
                        jsonObject.put("status",1);
                    }else{
                        jsonObject.put("status",-6);//”订单已取药,出药人:张三,出药时间:XXXX-XX-XX,无法重新出药
                    }
                }
                //健管师取药码
                case 2:{
                    //判断出药机构是否与健管师所属机构一致,不一致弹窗提示:“出药机构与您所在机构不一致,无法出药,请重新确认”。一致则进入下一步。
                    if(doctor.getHospital().equals(result.get("hospitalCode").toString())){
                        //20开方完成/待支付, 21 支付失败 , 30 支付成功/待配药 , 40配药成功/待配送  41配送失败 42分配健管师 45配送中   49配送到服务站  100配送到患者手中/已完成
                        if(status==30){
                            jsonObject.put("status",-5);//订单正在配药中,暂时无法出药
                        }else if(status>=45){
                            jsonObject.put("status",-6);//”订单已取药,出药人:张三,出药时间:XXXX-XX-XX,无法重新出药
                        }else if(status==40){
                            jsonObject.put("status",1);
                        }
                    }else{
                        jsonObject.put("status",-4);//出药机构与您所在机构不一致,无法出药,请重新确认
                    }
                }
                default:{
                    PrescriptionLog prescriptionLog = new PrescriptionLog();
                    prescriptionLog.setCode(UUID.randomUUID().toString());
                    prescriptionLog.setPrescriptionCode(result.get("prescriptionCode").toString());
                    prescriptionLog.setCreateTime(new Date());
                    prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
                    prescriptionLog.setFlag(1);
                    prescriptionLog.setUserCode(userCode);
                    prescriptionLog.setUserType(2);
                    prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing_error.getValue());
                    prescriptionLog.setRemark("编码类型错误");
                    prescriptionLogDao.save(prescriptionLog);
                }
            }
        }else{
            //保存验证二维码的日志
            PrescriptionLog prescriptionLog = new PrescriptionLog();
            prescriptionLog.setCode(UUID.randomUUID().toString());
//            prescriptionLog.setPrescriptionCode(result.get("").toString());
            prescriptionLog.setCreateTime(new Date());
            prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
            prescriptionLog.setFlag(1);
            prescriptionLog.setUserCode(userCode);
            prescriptionLog.setUserType(2);
            prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing_error.getValue());
            prescriptionLog.setRemark("PC端取药码输入错误!");
        }
//        prescriptionInfoService.
        jsonObject.put("expressageCode",result.get("expressageCode"));
        jsonObject.put("hospitalCode",result.get("hospitalCode"));
        jsonObject.put("hospitalName",result.get("hospitalName"));
        jsonObject.put("status",result.get("status"));
        jsonObject.put("dispensaryType",result.get("dispensaryType"));
        jsonObject.put("expressageName",result.get("expressageName"));
        jsonObject.put("expressageMobile",result.get("expressageMobile"));
        return jsonObject;
    }
}

+ 237 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/pc/prescription/PrescriptionExpressagePCService.java

@ -0,0 +1,237 @@
package com.yihu.wlyy.service.pc.prescription;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.prescription.*;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.prescription.*;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.prescription.PrescriptionExpressageService;
import com.yihu.wlyy.service.app.prescription.PrescriptionInfoService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.RoleService;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.beans.Transient;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
 * Created by liuwenbin on 2017/8/12.
 * PC端长处方取药/领药业务层
 */
@Service
public class PrescriptionExpressagePCService extends BaseService {
    @Autowired
    private PrescriptionDispensaryCodeDao prescriptionDispensaryCodeDao;
    @Autowired
    private PrescriptionLogDao prescriptionLogDao;
    @Autowired
    private RoleService roleService;
    @Autowired
    private DoctorService doctorService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PrescriptionExpressageDao prescriptionExpressageDao;
    @Autowired
    private PrescriptionInfoDao prescriptionInfoDao;
    @Autowired
    private PrescriptionDao prescriptionDao;
    @Autowired
    private PrescriptionExpressageService prescriptionExpressageService;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private DoctorDao doctorDao;
    @Transactional
    public JSONObject getMedicine(String code,String userCode) throws Exception{
        JSONObject jsonObject = new JSONObject();
        Doctor doctor = doctorService.findDoctorByCode(userCode);
        String sql = "select a.type,a.prescription_code as prescriptionCode ,c.status,b.hospital_code as hospitalCode, \n" +
                "b.code as orderCode, b.hospital_name as hospitalName,c.dispensary_type as dispensaryType, \n" +
                "b.expressage_name as expressageName, b.expressage_code as expressageCode,b.expressage_mobile as expressageMobile,d.idcard \n" +
                "from wlyy_prescription_dispensary_code a \n" +
                "left join wlyy_prescription_expressage b on a.prescription_code = b.prescription_code \n" +
                "left join wlyy_prescription c on a.prescription_code = c.code \n" +
                "left join wlyy_doctor d on b.code=b.expressage_code \n"+
                "where a.is_use=0 and a.code=? and c.status>=50";
           List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql,code);
            if(resultList.size()>0){
                Map<String, Object> result = resultList.get(0);
                int type = result.get("type")!=null?(Integer) result.get("type"):0;
                int status = result.get("status")!=null?(Integer) result.get("status"):-100;
                switch (type){
                    //居民取药码
                    case 1:{
                        if(status==50){
                            jsonObject.put("status",-5);//订单正在配药中,暂时无法出药
                        }else if(status==60){
                            jsonObject.put("flag",1);
                            List<PrescriptionInfo> list = prescriptionInfoDao.findByPrescriptionCode(result.get("prescriptionCode").toString());
                            jsonObject.put("prescriptionInfoList",list);
                            jsonObject.put("idcard",result.get("idcard"));
                            jsonObject.put("orderCode",result.get("orderCode"));
                            jsonObject.put("hospitalCode",result.get("hospitalCode"));
                            jsonObject.put("hospitalName",result.get("hospitalName"));
                            jsonObject.put("status",result.get("status"));
                            jsonObject.put("dispensaryType",result.get("dispensaryType"));
                            jsonObject.put("expressageName",result.get("expressageName"));
                            jsonObject.put("expressageMobile",result.get("expressageMobile"));
                        }else{
                            jsonObject.put("flag",-6);//”订单已取药,出药人:张三,出药时间:XXXX-XX-XX,无法重新出药
                            List<PrescriptionInfo> list = prescriptionInfoDao.findByPrescriptionCode(result.get("prescriptionCode").toString());
                            jsonObject.put("prescriptionInfoList",list);
                            jsonObject.put("idcard",result.get("idcard"));
                            jsonObject.put("orderCode",result.get("orderCode"));
                            jsonObject.put("hospitalCode",result.get("hospitalCode"));
                            jsonObject.put("hospitalName",result.get("hospitalName"));
                            jsonObject.put("status",result.get("status"));
                            jsonObject.put("dispensaryType",result.get("dispensaryType"));
                            jsonObject.put("expressageName",result.get("expressageName"));
                            jsonObject.put("expressageMobile",result.get("expressageMobile"));
                        }
                    }
                    //健管师取药码
                    case 2:{
                        //判断出药机构是否与健管师所属机构一致,不一致弹窗提示:“出药机构与您所在机构不一致,无法出药,请重新确认”。一致则进入下一步。
                        if(doctor.getHospital().equals(result.get("hospitalCode").toString())){
                            //20开方完成/待支付, 21 支付失败 , 30 支付成功/待配药 , 40配药成功/待配送  41配送失败 42分配健管师 45配送中   49配送到服务站  100配送到患者手中/已完成
                            if(status==50){
                                jsonObject.put("flag",-5);//订单正在配药中,暂时无法出药
                            }else if(status==60){
                                jsonObject.put("flag",1);
                                List<PrescriptionInfo> list = prescriptionInfoDao.findByPrescriptionCode(result.get("prescriptionCode").toString());
                                jsonObject.put("prescriptionInfoList",list);
                                jsonObject.put("orderCode",result.get("orderCode"));
                                jsonObject.put("idcard",result.get("idcard"));
                                jsonObject.put("hospitalCode",result.get("hospitalCode"));
                                jsonObject.put("hospitalName",result.get("hospitalName"));
                                jsonObject.put("status",result.get("status"));
                                jsonObject.put("dispensaryType",result.get("dispensaryType"));
                                jsonObject.put("expressageName",result.get("expressageName"));
                                jsonObject.put("expressageMobile",result.get("expressageMobile"));
                            }else{
                                jsonObject.put("flag",-6);//”订单已取药,出药人:张三,出药时间:XXXX-XX-XX,无法重新出药
                                List<PrescriptionInfo> list = prescriptionInfoDao.findByPrescriptionCode(result.get("prescriptionCode").toString());
                                jsonObject.put("prescriptionInfoList",list);
                                jsonObject.put("orderCode",result.get("orderCode"));
                                jsonObject.put("idcard",result.get("idcard"));
                                jsonObject.put("hospitalCode",result.get("hospitalCode"));
                                jsonObject.put("hospitalName",result.get("hospitalName"));
                                jsonObject.put("status",result.get("status"));
                                jsonObject.put("dispensaryType",result.get("dispensaryType"));
                                jsonObject.put("expressageName",result.get("expressageName"));
                                jsonObject.put("expressageMobile",result.get("expressageMobile"));
                            }
                        }else{
                            jsonObject.put("flag",-4);//出药机构与您所在机构不一致,无法出药,请重新确认
                        }
                    }
                    default:{
                        PrescriptionLog prescriptionLog = new PrescriptionLog();
                        prescriptionLog.setCode(UUID.randomUUID().toString());
                        prescriptionLog.setPrescriptionCode(result.get("prescriptionCode").toString());
                        prescriptionLog.setCreateTime(new Date());
                        prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
                        prescriptionLog.setFlag(1);
                        prescriptionLog.setUserCode(userCode);
                        prescriptionLog.setUserType(2);
                        prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing_error.getValue());
                        prescriptionLog.setRemark("编码类型错误");
                        prescriptionLogDao.save(prescriptionLog);
                    }
                }
            }else{
                //保存验证二维码的日志
                PrescriptionLog prescriptionLog = new PrescriptionLog();
                prescriptionLog.setCode(UUID.randomUUID().toString());
//            prescriptionLog.setPrescriptionCode(result.get("").toString());
                prescriptionLog.setCreateTime(new Date());
                prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
                prescriptionLog.setFlag(1);
                prescriptionLog.setUserCode(userCode);
                prescriptionLog.setUserType(2);
                prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing_error.getValue());
                prescriptionLog.setRemark("PC端取药码输入错误!");
            }
            return jsonObject;
    }
    @Transactional
    public void fetchingMedicine(String code,String userCode) throws Exception{
        //更新二维码(isUse)
        PrescriptionDispensaryCode prescriptionDispensaryCode = prescriptionDispensaryCodeDao.finByCode(code);
        prescriptionDispensaryCode.setIsUse(1);
        prescriptionDispensaryCodeDao.save(prescriptionDispensaryCode);
        //更新处方状态
        //判断二维码是居民取药码还是健管师取药码
        Prescription prescription =  prescriptionDao.findByCode(prescriptionDispensaryCode.getPrescriptionCode());
        if(prescriptionDispensaryCode.getType()==1){//居民取药码
            prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.finish.getValue());
        }else if(prescriptionDispensaryCode.getType()==2){
            prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
        }
        prescriptionDao.save(prescription);
        //处方日志
        PrescriptionLog prescriptionLog = new PrescriptionLog();
        prescriptionLog.setCode(UUID.randomUUID().toString());
        prescriptionLog.setPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
        prescriptionLog.setCreateTime(new Date());
        PrescriptionExpressage prescriptionExpressage = prescriptionExpressageDao.findByPrescriptionCode("e707487f063540e1b6d581b16bb8fb12");
        if(prescriptionDispensaryCode.getType()==1){//居民取药码
            prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.finish.getValue());
            prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.finish.getValue());
            prescriptionLog.setUserCode(prescription.getPatient());
            prescriptionLog.setUserName(prescription.getPatientName());
            prescriptionLog.setUserType(1);
        }else if(prescriptionDispensaryCode.getType()==2){
            prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
            prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
            prescriptionLog.setUserCode(prescriptionExpressage.getExpressageCode());
            prescriptionLog.setUserName(prescriptionExpressage.getExpressageName());
            prescriptionLog.setUserType(2);
            //发送模板消息通知患者药品开始配送
        }
        prescriptionLog.setFlag(1);
        prescriptionLog.setHospital(prescriptionExpressage.getHospitalCode());
        prescriptionLog.setHospitalName(prescriptionExpressage.getHospitalName());
        prescriptionLogDao.save(prescriptionLog);
//        prescriptionLog.setType();
//        prescriptionLogDao
        if(prescriptionDispensaryCode.getType()==2){
            Patient patient = patientDao.findByCode(prescription.getPatient());
            String url="prescription/html/order_tracking.html?openid=" + patient.getOpenid() + "" +
                    "&code=" + prescriptionDispensaryCode.getPrescriptionCode() + "&toUser=" + patient.getCode() + "&toName=" + patient.getName() ;
        }
        prescriptionExpressage.setExpressageTime(new Date());
        Doctor doctor = doctorDao.findByCode(userCode);
        prescriptionExpressage.setHospitalDoctorCode(userCode);
        prescriptionExpressage.setHospitalDoctor(doctor.getName());
        prescriptionExpressageDao.save(prescriptionExpressage);
    }
}

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

@ -1979,7 +1979,7 @@ public class DoctorController extends BaseController {
    @ObserverRequired
    @ResponseBody
    @RequestMapping(value = "/checkCertificate", method = RequestMethod.GET)
    @ApiOperation("校验医师输入的CA证书是否正确")
    @ApiOperation("校验医师输入的身份证是否正确")
    public String checkCertificate(
            @ApiParam(required = true, name = "certificateNum", value = "证书编号") @RequestParam(value = "certificateNum",required = true) String certificateNum){

+ 25 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescriptionPC/PrescriptionExpressagePCController.java

@ -1,9 +1,12 @@
package com.yihu.wlyy.web.doctor.prescriptionPC;
import com.yihu.wlyy.service.pc.prescription.PrescriptionExpressagePCService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
@ -16,13 +19,32 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(value = "/PC/prescription")
public class PrescriptionExpressagePCController extends BaseController {
    @Autowired
    private PrescriptionExpressagePCService prescriptionExpressagePCService;
    @ApiOperation(value = "取药/领药")
    @RequestMapping(value = "/getMedicine", method = RequestMethod.POST)
    public String getMedicine(
            @ApiParam(required = true, name = "code", value = "二维码(取药码、配送码)") @RequestParam(value = "code", required = true) String code){
            @ApiParam(required = true, name = "code", value = "二维码(居民取药码、健管师取药码)") @RequestParam(value = "code", required = true) String code){
        try{
            JSONObject jsonObject = prescriptionExpressagePCService.getMedicine(code,"hxmD201703150111");
            return write(200, "获取信息成功!", "data", jsonObject);
        }catch (Exception e) {
            error(e);
            return error(-1, "获取信息失败!");
        }
    }
        return "";
    @ApiOperation(value = "确认取药/领药")
    @RequestMapping(value = "/fetchingMedicine", method = RequestMethod.POST)
    public String fetchingMedicine(
            @ApiParam(required = true, name = "code", value = "二维码(居民取药码、健管师取药码)") @RequestParam(value = "code", required = true) String code){
        try {
            prescriptionExpressagePCService.fetchingMedicine(code, "hxmD201703150111");
            return write(200, "更改成功!");
        }catch (Exception e) {
            error(e);
            return error(-1, "更改失败!");
        }
    }
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionController.java

@ -126,7 +126,7 @@ public class PatientPrescriptionController extends WeixinBaseController {
     * @return
     */
    @RequestMapping(value = "/dispensaryCode/getPatientQrcode", method = RequestMethod.GET)
    public String getPatientQrcode(@RequestParam(value = "dispensaryCode",required = true) String prescriptionCode) {
    public String getPatientQrcode(@RequestParam(value = "prescriptionCode",required = true) String prescriptionCode) {
        try{
            Map<String, Object> map = prescriptionDispensaryCodeService.getQrcode(prescriptionCode,getRepUID(),1);