Forráskód Böngészése

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

huangwenjie 7 éve
szülő
commit
d9c4a2130d

+ 3 - 3
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/GuahaoController.java

@ -252,12 +252,12 @@ public class GuahaoController {
	@RequestMapping(value = "/imm/GetChildrenInfo",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("计免:获取儿童信息")
	public Result GetChildrenInfo(@ApiParam(name="credential",value="条形编码",defaultValue = "0052248552")
								@RequestParam String credential)
	public Result GetChildrenInfo(@ApiParam(name="barCode",value="条形编码",defaultValue = "0052248552")
								@RequestParam String barCode)
	{
		try {
			
			String data = guahaoService.GetChildrenInfo(credential);
			String data = guahaoService.GetChildrenInfo(barCode);
			
			return Result.success("获取儿童信息成功!",data);
		} catch (Exception ex) {

+ 81 - 26
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/guahao/GuahaoService.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.service.service.guahao;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.service.common.http.HttpApiException;
@ -1154,19 +1155,6 @@ public class GuahaoService {
     * =============================计免预约挂号相关接口==========================================START
     */
    
    /**
     * 获取儿童信息
     * @param credential 条形编码
     * @return
     */
    public String GetChildrenInfo(String credential)throws Exception  {
        String result = "";
    
        Map<String,String> params = new HashMap<>();
        params.put("BarCode", credential);
        
        return immPostSecond("GetChildrenInfo","计免预约-获取儿童信息",params);
    }
    
    /**
     * 计免预约Post接口
@ -1174,24 +1162,37 @@ public class GuahaoService {
    private String immPostSecond(String api,String content, Map<String,String> params) throws Exception
    {
        String re = "";
    
        
        //新增日志
        String method = "POST";
        Boolean isSuccess = true;
        String error = "";
    
        
        int times = 0;
        try {
            re = ZysoftApi.getSingleton().post("imm/"+api, params, null,openCrypto);
        
            Map<String,String> map = objectMapper.readValue(re,Map.class);
            String code = map.get("CODE");
        
            if(!code.equals("1"))
            {
                throw new HttpApiException(Integer.valueOf(code),map.get("MESSAGE"));
    
            //---结果验证,并保存日志 ---START
            if (StringUtils.isEmpty(re)) {
                // 请求失败
                //保存http日志
                logService.saveHttpLog(isSuccess,api,content,method,api,net.sf.json.JSONObject.fromObject(params).toString(),re,error);
                throw new Exception(error);
            } else if (StringUtils.startsWith(re, "System-Error")) {
                // 调用失败
                //保存http日志
                error = re.substring(re.indexOf(":") + 1, re.length());
                logService.saveHttpLog(isSuccess,api,content,method,api,net.sf.json.JSONObject.fromObject(params).toString(),re,error);
                throw new Exception(error);
            } else if (StringUtils.startsWith(re, "Error")) {
                // 调用失败
                //保存http日志
                error = re.substring(re.indexOf(":") + 1, re.length());
                logService.saveHttpLog(isSuccess,api,content,method,api,net.sf.json.JSONObject.fromObject(params).toString(),re,error);
                throw new Exception(error);
            }
        
            //---结果验证,并保存日志 ---END
            
            //保存http日志
            logService.saveHttpLog(isSuccess,api,content,method,api, net.sf.json.JSONObject.fromObject(params).toString(),re,error);
        }
@ -1202,10 +1203,10 @@ public class GuahaoService {
            ex.printStackTrace(pw);
            error = sw.toString();
            isSuccess = false;
        
            
            //保存http日志
            logService.saveHttpLog(isSuccess,api,content,method,api,net.sf.json.JSONObject.fromObject(params).toString(),re,error);
        
            
            if(ex instanceof ApiException)
            {
                ApiException apiEx = (ApiException) ex;
@ -1215,7 +1216,61 @@ public class GuahaoService {
                throw new HttpApiException(-1,ex.getMessage());
            }
        }
    
        
        return re;
    }
    
    
    /**
     * 计免请求结果验证,并保存日志
     * @param url
     * @param content
     * @param method
     * @param msgBody
     * @param res
     */
    private void  verificationImmResult(String result,String title,String url,String content,String method,String msgBody,String res) throws Exception{
        String error = "";
        Boolean isSuccess = false;
        if (StringUtils.isEmpty(result)) {
            // 请求失败
            //保存http日志
            error = title;
            logService.saveHttpLog(isSuccess,url,content,method,null,msgBody,res,error,logService.archiveType);
            throw new Exception(error);
        } else if (StringUtils.startsWith(result, "System-Error")) {
            // 调用失败
            //保存http日志
            error = result.substring(result.indexOf(":") + 1, result.length());
            logService.saveHttpLog(isSuccess,url,content,method,null,msgBody,res,error,logService.archiveType);
            throw new Exception(error);
        } else if (StringUtils.startsWith(result, "Error")) {
            // 调用失败
            //保存http日志
            error = result.substring(result.indexOf(":") + 1, result.length());
            logService.saveHttpLog(isSuccess,url,content,method,null,msgBody,res,error,logService.archiveType);
            throw new Exception(error);
        }
    }
    
    /**
     * 获取儿童信息
     * @param credential 条形编码
     * @return
     */
    public String GetChildrenInfo(String credential)throws Exception  {
        String result = "";
        Map<String,String> params = new HashMap<>();
        params.put("BarCode", credential);
        result = immPostSecond("GetChildrenInfo","计免预约-获取儿童信息",params);
    
        com.alibaba.fastjson.JSONObject data = com.alibaba.fastjson.JSONObject.parseObject(result);
        
        if(data.containsKey("OK")){
            result = data.getString("OK");
        }
        
        return result;
    }
}