Browse Source

代码修改

LAPTOP-KB9HII50\70708 1 year ago
parent
commit
c57389d1f8

+ 13 - 5
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/service/IotDeviceService.java

@ -1,11 +1,15 @@
package com.yihu.jw.entrance.service;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entrance.util.zysoft.ZysoftBaseService;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
 * 三院物联网对接
@ -16,6 +20,8 @@ public class IotDeviceService {
    @Autowired
    private ZysoftBaseService zysoftBaseService;
    @Autowired
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
    /**
     * 获取accesstoken
@ -24,13 +30,15 @@ public class IotDeviceService {
     */
    public String getAccessToken() throws Exception{
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE","350211A1004");
        header.put("LICENCE","1GPM6UKII0NF33155F0A0000348D061E");
        List<WlyyHospitalSysDictDO> dictDOList =  wlyyHospitalSysDictDao.findByDictName("zy_iot");
        Map<String,String> dictMap = dictDOList.stream().collect(Collectors.toMap(WlyyHospitalSysDictDO::getDictCode,WlyyHospitalSysDictDO::getDictValue));
        header.put("ORGCODE",dictMap.get("ORGCODE"));
        header.put("LICENCE",dictMap.get("LICENCE"));
        Map<String,String> params = new HashMap<>();
        params.put("appid","dsyy808081724b116c017254d437fe0008");
        params.put("appSecret","dsyy808081724b116c017254d437fe0008");
        String response = zysoftBaseService.postSecondYg("accesstoken","获取accesstoken",params,null,header,false,5,"5");
        params.put("appid",dictMap.get("appid"));
        params.put("appSecret",dictMap.get("appSecret"));
        String response = zysoftBaseService.postSecondYg("accesstoken","获取accesstoken",params,null,header,false,0);
        return response;
    }

+ 3 - 3
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/service/LogService.java

@ -63,15 +63,15 @@ public class LogService {
    /**
     * 保存http调用日志【基卫接口】
     **/
    public void saveHttpLog(Boolean isSuccess,String url,String content,String method,String header,String params,String response,String error)
    public void saveHttpLog(Boolean isSuccess,String url,String content,String method,String params,String response,String error)
    {
        saveHttpLog( isSuccess, url, content, method, header, params, response, error,"1");
        saveHttpLog( isSuccess, url, content, method,  params, response, error,"1");
    }
    /**
     * 保存http调用日志    0开放api  1基卫接口  2市民健康网接口   3易联众接口  4长处方接口
     **/
    public void saveHttpLog(Boolean isSuccess,String url,String content,String method,String header,String params,String response,String error,String type)
    public void saveHttpLog(Boolean isSuccess,String url,String content,String method,String params,String response,String error,String type)
    {
        try {
            WlyyHttpLogDO log = new WlyyHttpLogDO();

+ 2 - 2
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/util/zysoft/ZysoftApiSeconde.java

@ -20,8 +20,8 @@ import java.util.Map;
 **/
public class ZysoftApiSeconde extends AbstractApiExecuter2 {
//    private static final String keyPath = "D:\\jkzl\\wlyy2.0-springb2.4\\svr\\svr-internet-hospital-entrance\\src\\main\\resources";
    private static final String keyPath = "/data/hospital/svr-internet-hospital-entrance-1024/resources";
    private static final String keyPath = "D:\\jkzl\\wlyy2.0-springb2.4\\svr\\svr-internet-hospital-entrance\\src\\main\\resources";
//    private static final String keyPath = "/data/hospital/svr-internet-hospital-entrance-10024/resources";
    @Override

+ 20 - 23
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/util/zysoft/ZysoftBaseService.java

@ -48,7 +48,16 @@ public class ZysoftBaseService {
     * @return
     */
    private String getBaseApi(Integer apiType){
        return "wlw";
        String baseApi = "";
        switch (apiType){
            case 0:
                baseApi = "/wlw/accesstoken";
                break;
            default:
                baseApi = "";
                break;
        }
        return baseApi;
    }
@ -208,58 +217,46 @@ public class ZysoftBaseService {
     * YG请求 新的公钥和私钥
     */
    public String postSecondYg(String api,String content, Map<String,String> params,JSONObject jsonParams, Map<String,String> headers,
                               boolean needRetry,Integer apiType,String type) throws Exception
                               boolean needRetry,Integer apiType) throws Exception
    {
        String re = "";
        headers.put("INTERFACE",api);
        Map<String,String> paramsList = new HashMap<>();
        String msgBody = params==null?JSONObject.toJSONString(jsonParams, SerializerFeature.WriteMapNullValue):
                JSONObject.toJSONString(params, SerializerFeature.WriteMapNullValue);
        String msgHeader = JSONObject.toJSONString(headers, SerializerFeature.WriteMapNullValue);
        paramsList.put("msgHeader",msgHeader);
        paramsList.put("msgBody",msgBody);
        logger.info("msgHeader:"+msgHeader+"\r\n");
        logger.info("msgBody:"+msgBody+"\r\n");
        //新增日志
        String method = "POST";
        Boolean isSuccess = true;
        String error = "";
        String msgBody = params==null?JSONObject.toJSONString(jsonParams, SerializerFeature.WriteMapNullValue):
                JSONObject.toJSONString(params, SerializerFeature.WriteMapNullValue);
        String baseApi = getBaseApi(apiType);
        int times = 0;
        try {
            re = ZysoftApiSeconde.getSingleton().post(baseApi, paramsList, null,openCrypto,"SM2_V2",headers.get("LICENCE").toString());
            re = ZysoftApiSeconde.getSingleton().post(baseApi, params, null,openCrypto,"SM2_V2", headers.get("LICENCE"));
            if(needRetry)
            {
                int maxTimes = retryTimes;
                while(maxTimes>0 && re.contains("接口调用传入的参数[msgHeader]格式不正确"))    //基卫bug预防,重调接口
                {
                    re = ZysoftApiSeconde.getSingleton().post(baseApi, paramsList, null,openCrypto,"SM2_V2",headers.get("LICENCE").toString());
                    re = ZysoftApiSeconde.getSingleton().post(baseApi, params, null,openCrypto,"SM2_V2", headers.get("LICENCE"));
                    maxTimes --;
                    times++;
                }
            }
            logger.info("=====接口返回============="+re);
            Map<String,String> map = objectMapper.readValue(re,Map.class);
            String code = map.get("CODE");
            if(!code.equals("1"))
            if(!"1".equals(code)&&code!=null)
            {
                throw new HttpApiException(Integer.valueOf(code),map.get("MESSAGE"));
                throw new HttpApiException(Integer.parseInt(code),map.get("MESSAGE"));
            }
            //保存http日志
            logService.saveHttpLog(isSuccess,api,content,method,msgHeader,msgBody,re,error);
            logService.saveHttpLog(isSuccess,api,content,method,msgBody,re,error);
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
            //保存http日志
            logService.saveHttpLog(isSuccess,api,content,method,msgHeader,msgBody,re,error);
            logService.saveHttpLog(isSuccess,api,content,method,msgBody,re,error);
            if(ex instanceof ApiException)
            {