|
@ -11,6 +11,7 @@ import org.apache.http.message.BasicNameValuePair;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@ -33,7 +34,10 @@ public class YlzService {
|
|
private JdbcTemplate jdbcTemplate;
|
|
private JdbcTemplate jdbcTemplate;
|
|
@Autowired
|
|
@Autowired
|
|
private HttpClientUtil httpClientUtil;
|
|
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
|
|
* @return
|
|
* @throws Exception
|
|
* @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");
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|