| 
					
				 | 
			
			
				@ -42,12 +42,18 @@ public class PrescriptionExpressageService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 确认配送成功 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param code 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param code     编码code 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param userCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param type     1是患者 2是医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 返回取药码或者配送码的类型  1 居民取药码 2 配送员(健管师)取药码 3 配送员(健管师)配送码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 前端根据这个类型去跳转 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Transactional 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Integer expressage(String code, String userCode) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Integer expressage(String code, String userCode, Integer type) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Integer returnStatus = -1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //获取根据wlyy_prescription_dispensary_code的code处方编码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        PrescriptionDispensaryCode prescriptionDispensaryCode = prescriptionDispensaryCodeDao.finByCode(code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (prescriptionDispensaryCode == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //保存配送失败的日志 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            PrescriptionLog prescriptionLog = new PrescriptionLog(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -61,11 +67,12 @@ public class PrescriptionExpressageService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing_error.getValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            prescriptionLog.setRemark("配送失败,处方编码不存在"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            prescriptionLogDao.save(prescriptionLog); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return -1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return returnStatus; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //判断是否是取药码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (prescriptionDispensaryCode.getType() != 1 || prescriptionDispensaryCode.getType() != 2) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //保存取药失败的日志 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //判断患者不能扫描医生的二维码 医生也不能扫描患者的二维码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (!((type == 1 && prescriptionDispensaryCode.getType() == 1) || 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                (type == 2 && (prescriptionDispensaryCode.getType() == 2 || prescriptionDispensaryCode.getType() == 3)))) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //保存配送失败的日志 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            PrescriptionLog prescriptionLog = new PrescriptionLog(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            prescriptionLog.setCode(UUID.randomUUID().toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            prescriptionLog.setPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -75,11 +82,41 @@ public class PrescriptionExpressageService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            prescriptionLog.setUserCode(userCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            prescriptionLog.setUserType(2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing_error.getValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            prescriptionLog.setRemark("配送失败,处方编码不是取药码"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            prescriptionLog.setRemark("患者不能扫描医生的二维码 医生也不能扫描患者的二维码"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            prescriptionLogDao.save(prescriptionLog); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return -1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return returnStatus; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return returnStatus; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 1 居民取药码 业务 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param userCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param prescriptionDispensaryCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private Integer dispensaryCode_1(String userCode, PrescriptionDispensaryCode prescriptionDispensaryCode) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //修改处方状态为完成 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        prescriptionDao.updateStatus(prescriptionDispensaryCode.getPrescriptionCode(), PrescriptionLog.PrescriptionLogStatus.finish.getValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -97,7 +134,64 @@ public class PrescriptionExpressageService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //修改取药码code为已经使用 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        prescriptionDispensaryCode.setIsUse(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return prescriptionDispensaryCode.getType(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 配送员(健管师)取药码 业务 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param userCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param prescriptionDispensaryCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private Integer dispensaryCode_2(String userCode, PrescriptionDispensaryCode prescriptionDispensaryCode) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //修改处方状态为配送中 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        prescriptionDao.updateStatus(prescriptionDispensaryCode.getPrescriptionCode(), PrescriptionLog.PrescriptionLogStatus.expressageing.getValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //保存配送成功的日志 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        PrescriptionLog prescriptionLog = new PrescriptionLog(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        prescriptionLog.setPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        prescriptionLog.setCode(UUID.randomUUID().toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        prescriptionLog.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        prescriptionLog.setFlag(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        prescriptionLog.setUserCode(userCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        prescriptionLog.setUserType(2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing.getValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        prescriptionLogDao.save(prescriptionLog); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //修改取药码code为已经使用 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        prescriptionDispensaryCode.setIsUse(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return prescriptionDispensaryCode.getType(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 配送员(健管师)配送码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param userCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param prescriptionDispensaryCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private Integer dispensaryCode_3(String userCode, PrescriptionDispensaryCode prescriptionDispensaryCode) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //修改处方状态为完成 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        prescriptionDao.updateStatus(prescriptionDispensaryCode.getPrescriptionCode(), PrescriptionLog.PrescriptionLogStatus.finish.getValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //保存配送成功的日志 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        PrescriptionLog prescriptionLog = new PrescriptionLog(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        prescriptionLog.setPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        prescriptionLog.setCode(UUID.randomUUID().toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        prescriptionLog.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        prescriptionLog.setFlag(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        prescriptionLog.setUserCode(userCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        prescriptionLog.setUserType(2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressage2hospital.getValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        prescriptionLogDao.save(prescriptionLog); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //修改取药码code为已经使用 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        prescriptionDispensaryCode.setIsUse(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return prescriptionDispensaryCode.getType(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 |