瀏覽代碼

药柜接口内外网访问控制

bing 2 年之前
父節點
當前提交
9e28fd5863

+ 2 - 3
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/common/CommonEndpoint.java

@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.RestController;
 * Created by Bing on 2022/6/1.
 */
@RestController
@RequestMapping("/common/test/opem")
@RequestMapping("/common/test/open")
@Api(tags = "通用测试接口", description = "通用测试接口")
public class CommonEndpoint extends EnvelopRestEndpoint {
    @Autowired
@ -32,8 +32,7 @@ public class CommonEndpoint extends EnvelopRestEndpoint {
                                  @ApiParam(name = "dataInfo",value = "医保data参数",required = true)
                                  @RequestParam(value = "dataInfo")String dataInfo){
        try {
            JSONObject data = JSONObject.parseObject(dataInfo);
            return ObjEnvelop.getSuccess("success",ylzService.deviceYBApi(apiStr,orgCode,data));
            return ObjEnvelop.getSuccess("success",ylzService.deviceYBApi(apiStr,orgCode,dataInfo));
        }catch (Exception e){
            return failedObjEnvelopException(e);
        }

+ 38 - 17
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/YlzService.java

@ -11,6 +11,7 @@ import org.apache.http.message.BasicNameValuePair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -33,7 +34,10 @@ public class YlzService {
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Value("${spring.profiles}")
    private String springProfiles;
    private final String entranceUrl="http://10.90.32.3:22174/cityihealth/base/";
    /**
     *药柜预缴金充值--易慧
@ -114,25 +118,42 @@ public class YlzService {
     * @return
     * @throws Exception
     */
    public String deviceYBApi(String apiStr,String orgCode,JSONObject dataInfo)throws Exception{
        String sql = " select dp.* from t_mediicine_device de INNER JOIN t_mediicine_device_param dp on de.id = dp.device_id  " +
                "where de.del=1 and dp.del=1 and de.belong_community='"+orgCode+"' ";
        List<Map<String,Object>> deviceParams =  jdbcTemplate.queryForList(sql);
        if (deviceParams.size()==0){
            throw new Exception("药柜参数获取错误");
        }
        Map<String,Object> deviceParam = deviceParams.get(0);
        JSONObject strinObj = JSONObject.parseObject(deviceParam.get("yb_strin").toString());
        strinObj.put("func",apiStr);
        strinObj.put("data",dataInfo);
        String deviceIp = deviceParam.get("device_ip").toString();
    public String deviceYBApi(String apiStr,String orgCode,String dataInfo)throws Exception{
        if ("jwZnygProdIn".equals(springProfiles)){//内网访问
            String sql = " select dp.* from t_mediicine_device de INNER JOIN t_mediicine_device_param dp on de.id = dp.device_id  " +
                    "where de.del=1 and dp.del=1 and de.belong_community='"+orgCode+"' ";
            List<Map<String,Object>> deviceParams =  jdbcTemplate.queryForList(sql);
            if (deviceParams.size()==0){
                throw new Exception("药柜参数获取错误");
            }
            Map<String,Object> deviceParam = deviceParams.get(0);
            JSONObject strinObj = JSONObject.parseObject(deviceParam.get("yb_strin").toString());
            strinObj.put("func",apiStr);
            strinObj.put("data",JSONObject.parseObject(dataInfo));
            String deviceIp = deviceParam.get("device_ip").toString();
            List<NameValuePair> params = new ArrayList<>();
            params.add(new BasicNameValuePair("strin", strinObj.toJSONString()));
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("strin", strinObj.toJSONString()));
            String url = "http://"+deviceIp+":9000/api/Mi";
            String result =  httpClientUtil.get(url,params,"UTF-8");
            return result;
        }else {
            List<NameValuePair> params = new ArrayList<>();
            params.add(new BasicNameValuePair("apiStr", apiStr));
            params.add(new BasicNameValuePair("orgCode",orgCode));
            params.add(new BasicNameValuePair("apiStr", dataInfo));
        String url = "http://"+deviceIp+":9000/api/Mi";
        String result =  httpClientUtil.get(url,params,"UTF-8");
        return result;
            String url = entranceUrl+"/common/test/open/deviceYBApi";
            String resultStr =  httpClientUtil.get(url,params,"UTF-8");
//           String resultStr="{\"message\":\"success\",\"status\":200,\"obj\":\"\\\"{\\\\\\\"func\\\\\\\":\\\\\\\"fsi.terminal.readcard\\\\\\\",\\\\\\\"retCode\\\\\\\":\\\\\\\"-4\\\\\\\",\\\\\\\"retMsg\\\\\\\":\\\\\\\"服务器连接失败。\\\\\\\"}\\\"\"}";
            JSONObject resultObj = JSONObject.parseObject(resultStr);
            if (200==resultObj.getInteger("status")){
                return resultObj.getString("obj");
            }else {
                return resultObj.getString("message");
            }
        }
    }
}