企业列表出来了

master
法外狂徒张三 2024-09-04 15:14:31 +08:00
parent 97d2dd487d
commit 86712ed438
5 changed files with 221 additions and 14 deletions

View File

@ -6,7 +6,8 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="72651396-d9d2-4022-b080-e21d75d1bedb" name="更改" comment="企业列表出来了"> <list default="true" id="72651396-d9d2-4022-b080-e21d75d1bedb" name="更改" comment="企业列表出来了">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cloud-market-common/src/main/java/com/muyu/market/domain/SysFirm.java" beforeDir="false" afterPath="$PROJECT_DIR$/cloud-market-common/src/main/java/com/muyu/market/domain/SysFirm.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/logs/cloud-system/error.log" beforeDir="false" afterPath="$PROJECT_DIR$/logs/cloud-system/error.log" afterDir="false" />
<change beforePath="$PROJECT_DIR$/logs/cloud-system/info.log" beforeDir="false" afterPath="$PROJECT_DIR$/logs/cloud-system/info.log" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -63,6 +64,10 @@
</component> </component>
<component name="PropertiesComponent">{ <component name="PropertiesComponent">{
&quot;keyToString&quot;: { &quot;keyToString&quot;: {
&quot;RequestMappingsPanelOrder0&quot;: &quot;0&quot;,
&quot;RequestMappingsPanelOrder1&quot;: &quot;1&quot;,
&quot;RequestMappingsPanelWidth0&quot;: &quot;75&quot;,
&quot;RequestMappingsPanelWidth1&quot;: &quot;75&quot;,
&quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;, &quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;, &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;, &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
@ -96,6 +101,13 @@
<recent name="com.muyu" /> <recent name="com.muyu" />
</key> </key>
</component> </component>
<component name="RunDashboard">
<option name="configurationTypes">
<set>
<option value="SpringBootApplicationConfigurationType" />
</set>
</option>
</component>
<component name="RunManager"> <component name="RunManager">
<configuration name="MarkerInfoApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" temporary="true" nameIsGenerated="true"> <configuration name="MarkerInfoApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" temporary="true" nameIsGenerated="true">
<module name="cloud-market-server" /> <module name="cloud-market-server" />
@ -155,6 +167,9 @@
<workItem from="1725242763338" duration="3072000" /> <workItem from="1725242763338" duration="3072000" />
<workItem from="1725247138979" duration="2255000" /> <workItem from="1725247138979" duration="2255000" />
<workItem from="1725258712426" duration="3588000" /> <workItem from="1725258712426" duration="3588000" />
<workItem from="1725382242808" duration="955000" />
<workItem from="1725383441201" duration="397000" />
<workItem from="1725410973845" duration="2494000" />
</task> </task>
<task id="LOCAL-00001" summary="初始化"> <task id="LOCAL-00001" summary="初始化">
<created>1724047244829</created> <created>1724047244829</created>
@ -338,7 +353,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1725247697205</updated> <updated>1725247697205</updated>
</task> </task>
<option name="localTasksCounter" value="27" /> <task id="LOCAL-00027" summary="企业列表出来了">
<created>1725412228813</created>
<option name="number" value="00027" />
<option name="presentableId" value="LOCAL-00027" />
<option name="project" value="LOCAL" />
<updated>1725412228813</updated>
</task>
<option name="localTasksCounter" value="28" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">

View File

@ -22,6 +22,39 @@
<groupId>com.muyu</groupId> <groupId>com.muyu</groupId>
<artifactId>cloud-common-core</artifactId> <artifactId>cloud-common-core</artifactId>
</dependency> </dependency>
<!-- JSONObject对象依赖的jar包 -->
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.3</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>net.sf.ezmorph</groupId>
<artifactId>ezmorph</artifactId>
<version>1.0.6</version>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.2.3</version>
<classifier>jdk15</classifier><!-- 指定jdk版本 -->
</dependency>
<!-- Json依赖架包下载 -->
</dependencies> </dependencies>
</project> </project>

View File

@ -0,0 +1,142 @@
package com.muyu.market.config;
import net.sf.json.JSONObject;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
public class MobileLocationConfig {
// 手机归属地查询接口地址
public static String API_URL = "http://apis.juhe.cn/mobile/get";
// 接口请求Key
public static String API_KEY = "e0ed0cf7105ff74665b094bef8b20099";
public static void phone(String phone) {
String mobile = phone;
queryMobileLocation(mobile);
}
/**
* /7
* @param mobile
*/
public static String queryMobileLocation(String mobile)
{
Map<String, Object> params = new HashMap<>();//组合参数
params.put("phone", mobile);
params.put("key", API_KEY);
String queryParams = urlencode(params);
String response = doGet(API_URL, queryParams);
try {
JSONObject jsonObject = JSONObject.fromObject(response);
int error_code = jsonObject.getInt("error_code");
if (error_code == 0) {
System.out.println("调用接口成功");
JSONObject result = jsonObject.getJSONObject("result");
System.out.printf("省份:%s%n", result.getString("province"));
System.out.printf("城市:%s%n", result.getString("city"));
System.out.printf("区号:%s%n", result.getString("areacode"));
System.out.printf("邮编:%s%n", result.getString("zip"));
System.out.printf("运营商:%s%n", result.getString("company"));
} else {
System.out.println("调用接口失败:" + jsonObject.getString("reason"));
}
} catch (Exception e) {
e.printStackTrace();
}
return response;
}
/**
* gethttp
*
* @param httpUrl
* @return
*/
public static String doGet(String httpUrl, String queryParams) {
HttpURLConnection connection = null;
InputStream inputStream = null;
BufferedReader bufferedReader = null;
String result = null;// 返回结果字符串
try {
// 创建远程url连接对象
URL url = new URL(new StringBuffer(httpUrl).append("?").append(queryParams).toString());
// 通过远程url连接对象打开一个连接强转成httpURLConnection类
connection = (HttpURLConnection) url.openConnection();
// 设置连接方式get
connection.setRequestMethod("GET");
// 设置连接主机服务器的超时时间15000毫秒
connection.setConnectTimeout(5000);
// 设置读取远程返回的数据时间60000毫秒
connection.setReadTimeout(6000);
// 发送请求
connection.connect();
// 通过connection连接获取输入流
if (connection.getResponseCode() == 200) {
inputStream = connection.getInputStream();
// 封装输入流,并指定字符集
bufferedReader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
// 存放数据
StringBuilder sbf = new StringBuilder();
String temp;
while ((temp = bufferedReader.readLine()) != null) {
sbf.append(temp);
sbf.append(System.getProperty("line.separator"));
}
result = sbf.toString();
}
} catch (IOException e) {
e.printStackTrace();
} finally {
// 关闭资源
if (null != bufferedReader) {
try {
bufferedReader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (null != inputStream) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (connection != null) {
connection.disconnect();// 关闭远程连接
}
}
return result;
}
/**
* map
*
* @param data
* @return
*/
public static String urlencode(Map<String, ?> data) {
StringBuilder sb = new StringBuilder();
for (Map.Entry<String, ?> i : data.entrySet()) {
try {
sb.append(i.getKey()).append("=").append(URLEncoder.encode(i.getValue() + "", "UTF-8")).append("&");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
String result = sb.toString();
result = result.substring(0, result.lastIndexOf("&"));
return result;
}
}

View File

@ -1,11 +1,6 @@
package com.muyu.market.controller; package com.muyu.market.config;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
@ -15,12 +10,9 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@RestController public class ThirdPartyConfig {
@RequestMapping("/third")
public class ThirdPartyController {
@GetMapping("/getAirQuality/{cityId}") public static String airQuality(String cityId) throws Exception {
public ResponseEntity<String> airQuality(@PathVariable("cityId") String cityId) throws Exception {
String apiKey = "02ccc3ea04810432b45399ecb183195d"; String apiKey = "02ccc3ea04810432b45399ecb183195d";
String apiUrl = "http://apis.juhe.cn/fapigw/air/historyHours"; String apiUrl = "http://apis.juhe.cn/fapigw/air/historyHours";
@ -41,9 +33,11 @@ public class ThirdPartyController {
connection.disconnect(); connection.disconnect();
// 返回HTTP 200 OK状态码和响应体 // 返回HTTP 200 OK状态码和响应体
return ResponseEntity.ok(response.toString()); return response.toString();
} }
public static String params(Map<String, String> map) { public static String params(Map<String, String> map) {
return map.entrySet().stream() return map.entrySet().stream()
.map(entry -> { .map(entry -> {

View File

@ -9,6 +9,8 @@ import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log; import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType; import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions; import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.market.config.MobileLocationConfig;
import com.muyu.market.config.ThirdPartyConfig;
import com.muyu.market.domain.SysApitype; import com.muyu.market.domain.SysApitype;
import com.muyu.market.service.ISysApitypeService; import com.muyu.market.service.ISysApitypeService;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
@ -98,4 +100,18 @@ public class SysApitypeController extends BaseController
{ {
return toAjax(sysApitypeService.deleteSysApitypeBySysIds(sysIds)); return toAjax(sysApitypeService.deleteSysApitypeBySysIds(sysIds));
} }
@GetMapping("/third/{sysId}/{UnknownValue}")
public String airQuality(@PathVariable("sysId") Long sysId,@PathVariable("UnknownValue") String UnknownValue) throws Exception{
if(sysId==1){
String air = ThirdPartyConfig.airQuality(UnknownValue);
return air;
}
if(sysId==2){
//String[] value=UnknownValue.split(",");
String mobile = MobileLocationConfig.queryMobileLocation(UnknownValue);
return mobile;
}
return "error";
}
} }