Commit 2c1cf78b by 冯文杰

Excel文件地址转换以及运维监控页面整合一块。

parents
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4" />
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>myDemo</groupId>
<artifactId>excelDemo</artifactId>
<version>1.0-SNAPSHOT</version>
<!-- <packaging>jar</packaging>-->
<name>excelDemo Maven Webapp</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.13.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.1</version>
</dependency>
<!-- 用于编译jsp springboot tomcat jsp 支持开启-->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<!-- <scope>provided</scope>-->
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.35</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>2.2.8</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<!-- <plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.4.2.RELEASE</version>
<configuration>
<fork>true</fork> &lt;!&ndash; 如果没有该配置,devtools不会生效 &ndash;&gt;
</configuration>
</plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/webapp</directory>
<targetPath>META-INF/resources</targetPath>
<includes>
<include>**/**</include>
</includes>
<!--<filtering>false</filtering>-->
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</build>
<!-- <build>
<finalName>excelDemo</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>-->
</project>
package fwj;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class})
@EnableScheduling
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
package fwj.controller;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSONObject;
import fwj.entity.tranLngLat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import fwj.utils.addressLocationListener;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@Controller
public class kyPersonController {
Logger logger = LoggerFactory.getLogger(kyPersonController.class);
public static volatile int baidu_geoNum = 0;
public static volatile int gaode_geoNum = 0;
public static volatile int tengxun_geoNum = 0;
public static volatile int baidu_regeuNum = 0;
public static volatile int gaode_regeoNum = 0;
public static volatile int tengxun_regeoNum = 0;
@RequestMapping("/a")
public void testA(MultipartFile fileName1, HttpServletResponse response,String isEF){
// 行头使用.headRowNumber(1)
try {
//正向的
//EasyExcel.read(fileName1.getInputStream(), idAddress.class, new address2LocationListener(response, fileName1.getOriginalFilename())).headRowNumber(1).sheet("Sheet1").doRead();
//反向的
// EasyExcel.read(fileName1.getInputStream(), idLocation.class, new location2AddressListener(response, fileName1.getOriginalFilename())).headRowNumber(1).sheet("Sheet1").doRead();
/* System.out.println("来源" +source);
if( "baidu".equals(source) || "gaode".equals(source) || "tengxun".equals(source)){
EasyExcel.read(fileName1.getInputStream(), tranLngLat.class, new addressLocationListener(response, fileName1.getOriginalFilename())).headRowNumber(1).sheet("Sheet1").doRead();
}else {//默认百度
EasyExcel.read(fileName1.getInputStream(), tranLngLat.class, new addressLocationListener(response, fileName1.getOriginalFilename())).headRowNumber(1).sheet("Sheet1").doRead();
}*/
if("true".equals(isEF)){
EasyExcel.read(fileName1.getInputStream(), tranLngLat.class, new addressLocationListener(response, fileName1.getOriginalFilename(), true)).headRowNumber(1).sheet("Sheet1").doRead();
}else {
EasyExcel.read(fileName1.getInputStream(), tranLngLat.class, new addressLocationListener(response, fileName1.getOriginalFilename(), false)).headRowNumber(1).sheet("Sheet1").doRead();
}
} catch (IOException e) {
e.printStackTrace();
}
}
@RequestMapping("/")
public ModelAndView All(){
ModelAndView mv = new ModelAndView();
mv.setViewName("index");
return mv;
}
//每天凌晨重置访问配额
@Scheduled(cron = "0 0 0 * * *")
private void resetNum(){
baidu_geoNum = 0;
gaode_geoNum = 0;
tengxun_geoNum = 0;
baidu_regeuNum = 0;
gaode_regeoNum = 0;
tengxun_regeoNum = 0;
}
//#百度每天上限6000,并发50
//#腾讯每天上限10000,并发5
//#高度每天上限300000,并发200
@ResponseBody
@RequestMapping("/getNum")
public JSONObject culNum(String source){
int a = 0;
int b = 0;
int c = 0;
int total = 0;
JSONObject result = new JSONObject();
if("baidu".equals(source)){
// result.put("getNum", baidu_geoNum);
// result.put("regetNum", baidu_regeuNum);
StringBuilder sb = new StringBuilder();
if(baidu_geoNum >= 6000){
sb.append("百度地理编码免费使用上限超6000,请选择其它来源;\n");
a = 1;
}else{
sb.append("百度地理编码免费使用上限为6000,已使用" + baidu_geoNum + "\n");
}
if(baidu_regeuNum >= 6000){
sb.append("百度逆地理编码免费使用上限超6000,请选择其它来源;\n");
}else{
sb.append("百度逆地理编码免费使用上限为6000,已使用" + baidu_regeuNum + "\n");
}
result.put("msg", sb.toString());
}
if("gaode".equals(source)){
result.put("getNum", gaode_geoNum);
result.put("regetNum", gaode_regeoNum);
StringBuilder sb = new StringBuilder();
if(gaode_geoNum >= 6000){
sb.append("高德地理编码免费使用上限超300,000,请选择其它来源;\n");
}else{
sb.append("高德地理编码免费使用上限为300,000,已使用" + gaode_geoNum + "\n");
}
if(gaode_regeoNum >= 6000){
sb.append("高德逆地理编码免费使用上限超300,000,请选择其它来源;\n");
}else{
sb.append("高德逆地理编码免费使用上限为300,000,已使用" + gaode_regeoNum + "\n");
}
result.put("msg", sb.toString());
b = 2;
}
if("tengxun".equals(source)){
result.put("getNum", tengxun_geoNum);
result.put("regetNum", tengxun_regeoNum);
StringBuilder sb = new StringBuilder();
if(tengxun_geoNum >= 6000){
sb.append("腾讯地理编码免费使用上限1,000,请选择其它来源;\n");
}else{
sb.append("腾讯地理编码免费使用上限为1,000,已使用" + tengxun_geoNum + "\n");
}
if(tengxun_regeoNum >= 6000){
sb.append("腾讯逆地理编码免费使用上限超1,000,请选择其它来源;\n");
}else{
sb.append("腾讯逆地理编码免费使用上限为1,000,已使用" + tengxun_regeoNum + "\n");
}
result.put("msg", sb.toString());
c =3;
}
result.put("flag", a + b + c);
return result;
}
}
package fwj.entity;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
public class tranLngLat {
@ExcelProperty(value="ID")
private String id;
@ExcelProperty(value="经度")
private String lng;
@ExcelProperty(value="维度")
private String lat;
@ExcelProperty(value="标准地址")
private String address;
@ExcelProperty(value="转换来源")
private String source;
@ExcelIgnore
private int hasSuccess;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getLng() {
return lng;
}
public void setLng(String lng) {
this.lng = lng;
}
public String getLat() {
return lat;
}
public void setLat(String lat) {
this.lat = lat;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public int getHasSuccess() {
return hasSuccess;
}
public void setHasSuccess(int hasSuccess) {
this.hasSuccess = hasSuccess;
}
}
package fwj.utils;
import java.util.regex.Pattern;
/**
* 坐标转换工具
*/
public class LngLonUtil {
//注意:lat 纬度 lon 经度 ************************************
public static double x_pi = 3.14159265358979324 * 3000.0 / 180.0;
public static double pi = 3.1415926535897932384626;
public static double a = 6378245.0;
public static double ee = 0.00669342162296594323;
public static double transformLat(double x, double y) {
double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x));
ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;
ret += (20.0 * Math.sin(y * pi) + 40.0 * Math.sin(y / 3.0 * pi)) * 2.0 / 3.0;
ret += (160.0 * Math.sin(y / 12.0 * pi) + 320 * Math.sin(y * pi / 30.0)) * 2.0 / 3.0;
return ret;
}
public static double transformLon(double x, double y) {
double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x));
ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;
ret += (20.0 * Math.sin(x * pi) + 40.0 * Math.sin(x / 3.0 * pi)) * 2.0 / 3.0;
ret += (150.0 * Math.sin(x / 12.0 * pi) + 300.0 * Math.sin(x / 30.0 * pi)) * 2.0 / 3.0;
return ret;
}
public static double[] transform(double lat, double lon) {
if (outOfChina(lat, lon)) {
return new double[]{lat,lon};
}
double dLat = transformLat(lon - 105.0, lat - 35.0);
double dLon = transformLon(lon - 105.0, lat - 35.0);
double radLat = lat / 180.0 * pi;
double magic = Math.sin(radLat);
magic = 1 - ee * magic * magic;
double sqrtMagic = Math.sqrt(magic);
dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi);
dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi);
double mgLat = lat + dLat;
double mgLon = lon + dLon;
return new double[]{mgLat,mgLon};
}
/**
* 判断是否在中国
* @param lat
* @param lon
* @return
*/
public static boolean outOfChina(double lat, double lon) {
if (lon < 72.004 || lon > 137.8347)
return true;
if (lat < 0.8293 || lat > 55.8271)
return true;
return false;
}
/**
* 84 ==》 高德 --已测试,与前端一致
* @param lat
* @param lon
* @return
*/
public static double[] gps84_To_Gcj02(double lat, double lon) {
if (outOfChina(lat, lon)) {
return new double[]{lat,lon};
}
double dLat = transformLat(lon - 105.0, lat - 35.0);
double dLon = transformLon(lon - 105.0, lat - 35.0);
double radLat = lat / 180.0 * pi;
double magic = Math.sin(radLat);
magic = 1 - ee * magic * magic;
double sqrtMagic = Math.sqrt(magic);
dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi);
dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi);
double mgLat = lat + dLat;
double mgLon = lon + dLon;
return new double[]{mgLat, mgLon};
}
/**
* 高德 ==》 84 --已测试,与前端一致
* @param lon * @param lat * @return
* */
public static double[] gcj02_To_Gps84(double lat, double lon) {
double[] gps = transform(lat, lon);
double lontitude = lon * 2 - gps[1];
double latitude = lat * 2 - gps[0];
return new double[]{latitude, lontitude};
}
/**
* 高德 == 》 百度
* @param lat
* @param lon
*/
public static double[] gcj02_To_Bd09(double lat, double lon) {
double x = lon, y = lat;
// double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi);//百度的算法是x_pi,前端的是pi,暂时保持一致 chentian20200424
// double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi);//百度的算法是x_pi,前端的是pi,暂时保持一致 chentian20200424
double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * pi);
double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * pi);
double tempLon = z * Math.cos(theta) + 0.0065;
double tempLat = z * Math.sin(theta) + 0.006;
double[] gps = {tempLat,tempLon};
return gps;
}
/**
* 百度 == 》 高德
* @param lat
* @param lon
*/
public static double[] bd09_To_Gcj02(double lat, double lon) {
double x = lon - 0.0065, y = lat - 0.006;
double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi);
double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi);
double tempLon = z * Math.cos(theta);
double tempLat = z * Math.sin(theta);
double[] gps = {tempLat,tempLon};
return gps;
}
/**
* 84 == 》 百度 --已测试,与前端一致
* @param lat
* @param lon
* @return
*/
public static double[] gps84_To_bd09(double lat,double lon){
double[] gcj02 = gps84_To_Gcj02(lat,lon);
double[] bd09 = gcj02_To_Bd09(gcj02[0],gcj02[1]);
return bd09;
}
/**
* 百度 == 》 84 --已测试,与前端一致
* @param lat
* @param lon
* @return
*/
public static double[] bd09_To_gps84(double lat,double lon){
double[] gcj02 = bd09_To_Gcj02(lat, lon);
double[] gps84 = gcj02_To_Gps84(gcj02[0], gcj02[1]);
//保留小数点后六位
gps84[0] = retain6(gps84[0]);
gps84[1] = retain6(gps84[1]);
return gps84;
}
/*
* 保留小数点后六位
* @param num
* @return
*/
private static double retain6(double num){
String result = String .format("%.6f", num);
return Double.valueOf(result);
}
public static void main(String[] args){
System.out.println("===============84转百度=====================");
//84转百度
double[] xy=gps84_To_bd09(22.7426833,114.1329);
System.out.println("y:"+xy[0]+"#x:"+xy[1]);
double[] xy1=gps84_To_bd09(22.87525,113.8616333);
System.out.println("y:"+xy1[0]+"#x:"+xy1[1]);
//
/* double[] xy2=gps84_To_bd09(113.9302,23.0039833);
System.out.println("x:"+xy2[0]+"#y:"+xy2[1]);
double[] xy3=gps84_To_bd09(113.9439333,22.9951167);
System.out.println("x:"+xy3[0]+"#y:"+xy3[1]);
double[] xy4=gps84_To_bd09(113.8736,22.9265667);
System.out.println("x:"+xy4[0]+"#y:"+xy4[1]);*/
System.out.println("============百度转84========================");
//百度转84
double[] xy5=bd09_To_gps84(22.7426833,114.1329);
System.out.println("x:"+xy5[0]+"#y:"+xy5[1]);
double[] xy6=bd09_To_gps84(22.87525,113.8616333);
System.out.println("x:"+xy6[0]+"#y:"+xy6[1]);
System.out.println("===============高德/谷歌/腾讯 转 84=====================");
//高德/谷歌/腾讯 转 84
double[] xy7=gcj02_To_Gps84(22.7426833,114.1329);
System.out.println("x:"+xy7[0]+"#y:"+xy7[1]);
double[] xy8=gcj02_To_Gps84(22.87525,113.8616333);
System.out.println("x:"+xy8[0]+"#y:"+xy8[1]);
System.out.println("==============84 转高德/谷歌/腾讯======================");
// 84 转高德/谷歌/腾讯
double[] xy9=gps84_To_Gcj02(22.7426833,114.1329);
System.out.println("x:"+xy9[0]+"#y:"+xy9[1]);
double[] xy10=gps84_To_Gcj02(22.87525,113.8616333);
System.out.println("x:"+xy10[0]+"#y:"+xy10[1]);
}
//private static final String LONGITUDE = "/^[\\-\\+]?(0?\\d{1,2}\\.\\d{1,5}|1[0-7]?\\d{1}\\.\\d{1,5}|180\\.0{1,5})$/";//经度
// private static final String LATITUDE = "/^[\\-\\+]?(0?\\d{1,2}\\.\\d{1,5}|1[0-7]?\\d{1}\\.\\d{1,5}|180\\.0{1,5})$/";//纬度
//校验经纬度合理性
public static boolean verifyLongAndLat(Double x,Double y) {
//经度: -180.0~+180.0(整数部分为0~180,必须输入1到8位小数)
String longitudePattern="^[\\-\\+]?(0?\\d{1,2}\\.\\d{1,8}|1[0-7]?\\d{1}\\.\\d{1,8}|180\\.0{1,8})$";
//纬度: -90.0~+90.0(整数部分为0~90,必须输入1到8位小数)
String latitudePattern="^[\\-\\+]?([0-8]?\\d{1}\\.\\d{1,8}|90\\.0{1,8})$";
boolean longitudeMatch = Pattern.matches(longitudePattern, String.valueOf(x));
boolean latitudeMatch = Pattern.matches(latitudePattern, String.valueOf(y));
if(longitudeMatch&&latitudeMatch){
return true;
}
return false;
}
}
package fwj.utils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.client.RestTemplate;
public class addressDNSUtil {
private static final String BAIDU_AK = "cYfcu0CsGGNIl9GnfwUvGBjdiQDoMsGL";
private static final String GAODE_AK = "3866dcd12908db106e73b8f2e75ef3e3";
private static final String TENGXUN_AK = "63GBZ-ADNWX-I564B-765QB-QEMW6-EXFOY";
//type标识正向反向. geo是正向,regeo是反向。
//source 表示调用百度还是高德,高德用gaode,百度用baidu,
//正向需要参数address,使用|分割,
//反向需要参数location,使用|分割,
//这里一开始没定好方向,经纬度整一块了,对性能损耗不大,不修改。
public static JSONObject getGeo(String type, String source, String address, String location){
RestTemplate restTemplate = new RestTemplate();
JSONObject responseJO = new JSONObject();
//正向 ---使用address
if("geo".equals(type)){
//来源是百度---百度无法一次性批量,使用循环查询再拼装结果。
if("baidu".equals(source)){
String[] addressList;
if(address.contains("|")){//查询多个
addressList = address.split("\\|");
}else{//查询一个
addressList = new String[1];
addressList[0] = address;
}
StringBuffer url = new StringBuffer();
JSONArray jsonArray = new JSONArray();
JSONObject queryJO;//这里不new,减少JVM垃圾回收。
for(int i = 0;i < addressList.length;i ++){
JSONObject addJO = new JSONObject();
url.append("http://api.map.baidu.com/geocoding/v3/?address=");
url.append(addressList[i]);
//2021-05-27
url.append("&output=json&ak=").append(BAIDU_AK);
String result = restTemplate.getForObject(url.toString(), String.class);
System.out.println(addressList[i] + result);
queryJO = (JSONObject) JSONObject.parseObject(result).get("result");
addJO.put("formatted_address", addressList[i]);
//0是百度正向解析成功。
if(JSONObject.parseObject(result).getIntValue("status") == 0){
queryJO = (JSONObject) queryJO.get("location");
StringBuffer latlng = new StringBuffer(queryJO.getString("lng"));
latlng.append(",").append(queryJO.getString("lat"));
addJO.put("location", latlng);
}else {
addJO.put("location", "");
}
jsonArray.add(addJO);
url.delete(0 ,url.length());
}
responseJO.put("status", 200);
responseJO.put("geocodes", jsonArray);
return responseJO;
}
if("gaode".equals(source)){
StringBuffer url = new StringBuffer("https://restapi.amap.com/v3/geocode/geo?address=");
url.append(address);
url.append("&output=json&key=").append(GAODE_AK);
url.append("&batch=").append("true");//默认开启批量,|分割,最多支持10个
String result = restTemplate.getForObject(url.toString(), String.class);
System.out.println(result);
responseJO = JSONObject.parseObject(result);
if("1".equals(responseJO.getString("status"))){
responseJO.put("status", 200);
}
return responseJO;
}
if("tengxun".equals(source)){//不支持批量,这里也不进行批量,只查一个。
StringBuffer url = new StringBuffer("https://apis.map.qq.com/ws/geocoder/v1/?address=");
url.append(address);
url.append("&output=json&key=").append(TENGXUN_AK);
String result = restTemplate.getForObject(url.toString(), String.class);
System.out.println(result);
responseJO = JSONObject.parseObject(result);
JSONArray jsonArray = new JSONArray();
JSONObject queryJO;
if(0 ==(responseJO.getIntValue("status"))){
responseJO.put("status", 200);
queryJO = (JSONObject) ((JSONObject) responseJO.get("result")).get("location");
StringBuffer latlng = new StringBuffer(queryJO.getString("lng"));
latlng.append(",").append(queryJO.getString("lat"));
queryJO.put("formatted_address", address);
queryJO.put("location", latlng);
jsonArray.add(queryJO);
}
responseJO.put("geocodes", jsonArray);
return responseJO;
}
}
//反向
if("regeo".equals(type)){
//来源是百度
if("baidu".equals(source)){
String[] locationList;
if(location.contains("|")){//查询多个
locationList = location.split("\\|");
}else{//查询一个
locationList = new String[1];
locationList[0] = location;
}
StringBuffer url = new StringBuffer();
JSONArray jsonArray = new JSONArray();
JSONObject queryJO;//这里不new,减少JVM垃圾回收。
for(int i = 0;i < locationList.length;i ++){
JSONObject addJO = new JSONObject();
url.append("http://api.map.baidu.com/reverse_geocoding/v3/?coordtype=wgs84ll&ak=");
url.append(BAIDU_AK);
url.append("&output=json&location=");
url.append(locationList[i]);
String result = restTemplate.getForObject(url.toString(), String.class);
System.out.println(url);
queryJO = (JSONObject) JSONObject.parseObject(result).get("result");
addJO.put("location", locationList[i]);
//0是百度正向解析成功。
if(JSONObject.parseObject(result).getIntValue("status") == 0 && ! "".equals(queryJO.getString("formatted_address"))){
addJO.put("formatted_address", queryJO.getString("formatted_address"));
}else {
addJO.put("formatted_address", "无效地址");
}
jsonArray.add(addJO);
url.delete(0 ,url.length());
}
responseJO.put("status", 200);
responseJO.put("regeocodes", jsonArray);
return responseJO;
}
if("gaode".equals(source)){
StringBuffer url = new StringBuffer("https://restapi.amap.com/v3/geocode/regeo?extensions=base&output=json&key=");
url.append(GAODE_AK);
url.append("&location=").append(location);
url.append("&batch=").append("true");
String result = restTemplate.getForObject(url.toString(), String.class);
responseJO = JSONObject.parseObject(result);
if("1".equals(responseJO.getString("status"))){
responseJO.put("status", 200);
}
return responseJO;
}
if("tengxun".equals(source)){//不支持批量,这里也不进行批量,只查一个。
StringBuffer url = new StringBuffer("https://apis.map.qq.com/ws/geocoder/v1/?location=");
url.append(location);
url.append("&output=json&key=");
url.append(TENGXUN_AK);
String result = restTemplate.getForObject(url.toString(), String.class);
System.out.println(url);
JSONArray jsonArray = new JSONArray();
JSONObject addJO = new JSONObject();
JSONObject queryJO = (JSONObject) JSONObject.parseObject(result).get("result");
addJO.put("location", location);
//0是百度正向解析成功。
if(JSONObject.parseObject(result).getIntValue("status") == 0 && ! "".equals(queryJO.getString("formatted_address"))){
addJO.put("formatted_address", queryJO.getString("address"));
}else {
addJO.put("formatted_address", "无效地址");
}
jsonArray.add(addJO);
responseJO.put("status", 200);
responseJO.put("regeocodes", jsonArray);
return responseJO;
}
}
//请求参数错误。
responseJO.put("status", 400);
return responseJO;
}
}
Manifest-Version: 1.0
Main-Class: fwj.DemoApplication
tomcat.uri-encoding=utf-8
logging.level.com = INFO
logging.level.org.springframework=INFO
logging.level.org.spring.springboot.dao=INFO
spring.mvc.view.prefix=/
spring.mvc.view.suffix=.jsp
spring.mvc.favicon.enabled=false
spring.mvc.static-path-pattern=/**
spring.resources.static-locations=classpath:/webapp/
#ȲЧ
spring.devtools.restart.enabled=true
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
</web-app>
<!DOCTYPE html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>excel地理/逆地理编码</title>
<link rel="stylesheet" href="/static/css/base_initialize.css">
<link rel="stylesheet" type="text/css" href="/static/css/table.css">
<style>
html,body{overflow: hidden;height: 100%;}
/*loading*/
.loaddingWrap{position: absolute;left:50%;top:130px;margin-left:-68px;}
.loaddingWrap>p{padding:5px 10px;color:#000;background: rgb(255,255,255);border:1px solid #ccc;border-radius:5px;width:136px;height:26px;line-height: 26px;}
.loaddingWrap .fa{font-size: 20px;margin-right: 5px; position: relative;top: -2px;}
.loaddingWrap span{display: inline-block;position: relative; top: -6px;}
</style>
</head>
<body>
<article class="w" style="width:100%;background:url(/static/img/bg.jpg) no-repeat;
background-size: cover;">
<div class="head clearfix">
<%--<div class="aj_message">
<span class="aj_code">案(事)件校验情况统计</span>
</div>--%>
<span class="linkT" style="text-decoration: none;font-size: 20px"><i class="fa fa-search"></i>excel地理/逆地理编码</span>
</div>
<div class="tableContent" style="top:-167px;height: calc(100vh - 180px);">
<!-- 菜单1 -->
<div id="" class="content">
<!--查询条件-->
<div class="condition" id="tableWrap">
<div class="cx_t">
<h6 style="display: inline-block;margin-right: 10px">excel地理/逆地理编码</h6>
<span style="position: absolute;right: 18px;">
<a style="padding-right: 20px;text-decoration: underline" href="地理编码模板.xls" download="地理编码模板.xls">下载地理编码模板</a>
<a style="padding-right: 17px;text-decoration: underline" href="逆地理编码模板.xls" download="逆地理编码模板.xls">下载逆地理编码模板</a>
</span>
</div>
<form method="post" enctype="multipart/form-data" id="queryCourseForm" style="margin: 5px">
<div class="bar_tb" style="margin-top: 10px;position: relative;min-height: 10px;height: 10px">
<span style="color: red"> 选择文件:</span> <input style="width: 150px" id="fileName1" name="fileName1" type="file" />
</div>
<%-- <div class="bar_tb" style="position: relative;min-height: 10px;height: 10px;margin-top: 25px">
<span style="color: red"> 选择来源:</span>
<select id="source" name="source">
<option value="baidu">百度</option>
<option selected="selected" value="gaode">高德</option>
<option value="tengxun">腾讯</option>
</select>
</div>--%>
<div class="bar_tb" style="position: relative;min-height: 10px;height: 10px;margin-top: 25px">
<span style="color: red"> (只使用于已知地址)是否转换为WGS84:</span>
<input type="checkbox" id="isEF" name="isEF"></input>
</div>
<div style="padding: 8px">
<a class="btn_a btn_cx" style="margin-left: 45%;margin-top: 3%; " onclick="doSaveBg()">确定</a>
</div>
</form>
</div>
</div>
</div>
</article>
<script src="/static/js/jquery.min.js"></script>
<script>
$(function () {
/* $("#source").change(function(){
var selected=$(this).children('option:selected').val();
//alert(selected);
$.ajax({
url:"/getNum",
type : "post",
data : {source : selected},
success:function(res){
alert(res.msg);
console.log(res);
},
})
if(selected=="order_time"){
//document.getElementById("search_content_id").
$("#search_content_id")[0].placeholder="时间格式:20150923";
}else if(selected=="order_id"){
$("#search_content_id")[0].placeholder="";
}
});*/
})
function doSaveBg() {
var localPath = $("#fileName1").val();
var a = $("#isEF").prop("checked");
if(a){
$("#isEF").val("true");
}
if(localPath == ""){
alert("请选择文件");
return;
}
if(localPath.lastIndexOf(".xls") == -1 && localPath.lastIndexOf(".xlsx") == -1 && localPath.lastIndexOf(".XLS") == -1 && localPath.lastIndexOf(".XLSX") == -1){
alert("请选择excel文件");
return;
}
$("#queryCourseForm").attr("action","/a");//改变表单的提交地址为下载的地址
$("#queryCourseForm").submit();//提交表单
/* var formData = new FormData();//这里需要实例化一个FormData来进行文件上传
var type = "fileName1";
formData.append(type,$("#fileName1")[0].files[0]);
console.log("时间" +$("#lrtime").datebox("getValue"));
$.ajax({
url:"/a",
type : "post",
data : formData,
processData : false,
contentType : false,
success:function(res){
alert(JSON.stringify(res));
var eleLink = document.createElement('a');
eleLink.download = $("#fileName1")[0].files[0].name;
eleLink.style.display = 'none';
// 字符内容转变成blob地址
var blob = bs64toBlob(res);
eleLink.href = URL.createObjectURL(blob);
// 触发点击
document.body.appendChild(eleLink);
eleLink.click();
// 然后移除
document.body.removeChild(eleLink);
},
error: function(){
alert("修改失败,请检查网络状态!");
}
});*/
}
</script>
</body>
</html>
\ No newline at end of file
@charset "UTF-8";
/*css 初始化 */
html,
body,
ul,
li,
ol,
dl,
dd,
dt,
p,
h1,
h2,
h3,
h4,
h5,
h6,
form,
fieldset,
legend,
img {
margin: 0;
padding: 0;
}
fieldset,
img,
input,
button {
border: none;
padding: 0;
margin: 0;
outline-style: none;
}
/*清除边框外发光 */
ul,
ol {
list-style: none;
/* 清除左侧小圆点标注 */
}
input {
padding-top: 0;
padding-bottom: 0;
font-family: "SimSun", "宋体";
}
select,
input {
vertical-align: middle;
}
select,
input,
textarea {
font-size: 12px;
margin: 0;
}
textarea {
resize: none;
/*防止拖动*/
}
img {
border: 0;
vertical-align: middle;
/* 去掉图片底部默认的3像素空白缝隙*/
}
table {
border-collapse: collapse;
/* 边框合并 */
}
body {
font: 12px/150% Arial, Verdana, "\5b8b\4f53";
/* 宋体 */
color: #666;
background: #fff
}
.clearfix:before,
.clearfix:after {
content: "";
display: table;
/* 清除浮动 */
}
.clearfix:after {
clear: both;
/* 清除浮动 */
}
.clearfix {
*zoom: 1;
/*IE/7/6*/
}
a {
color: #666;
text-decoration: none;
/* 清除下划线 */
}
h1,
h2,
h3,
h4,
h5,
h6 {
text-decoration: none;
font-weight: normal;
font-size: 100%;
}
s,
i,
em {
font-style: normal;
text-decoration: none;
}
.col-red {
color: #C81623!important;
}
/*公共类*/
.w {
width: 1210px;
margin: 0 auto;
/*版心 提取 */
}
.fl {
float: left
}
.fr {
float: right
}
.al {
text-align: left
}
.ac {
text-align: center
}
.ar {
text-align: right
}
.hide {
display: none
}
.show{
display: block;
}
.sp_table td.ar{
color:#0066cc;
}
\ No newline at end of file
@charset "UTF-8";
html, body, ul,li,div,text, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {
margin: 0;
padding: 0;
border: 0;
outline: 0;
font-family: "ËÎÌå","serif","sans-serif","cursive","fantasy","monospace","Times New Roman",Georgia,Serif;
font-size: 14px;
list-style: none;
}
html,body{width:100%;height:100%;overflow: hidden;}
fieldset,
img,
input,
button,
select {
/* border: none; */
border:1px solid #ccc;
border-radius: 5px;
padding: 0;
margin: 0;
outline-style: none;
}
a{color:#3692c6;font-weight:600;}
p,div{margin:0px;padding:0px;}
/*清除边框外发光 */
fieldset{border: none;box-shadow: 1px 4px 2px #ccc;}
.fl{float: left;}
.fr{float: right;}
.clear{overflow: hidden;}
.al{text-align: left;}
.ac{text-align: center;}
.padding10{padding:0 10px;}a:hover{color: #3585c6;}
.lf{float:left;}
.fw{font-weight:600; padding-left: 10px;}
.rg{float:right;}
.absolute{position: absolute;}
.btnA{
top: -36px;
right: 9px;
}
.TableList .fa{
bottom: 11px;
right: 0px;
}
table td .fa{right:9px !important;top:11px;}
.fkTable{
width:96%;border-collapse: collapse;margin:18px auto;border:1px solid #ccc;border-radius:5px;background-color: #f7f7f7;text-align:left;
}
.btnA:hover{color:inherit;}
.btnA .fa:hover,table td .fa:hover{color: red;}
.btnA .fa,table td .fa,.cx_t .fa,.TableList .fa{font-size:20px;cursor: pointer;margin-right: 5px;}
.cx_t .fkbtn{float: right;margin-right: calc(2% + 16px);margin-top:8px;}
.TableList{position: relative;}
.tableListNum{position: absolute;left:2%;top:0px;display: inline-block;width:20px;height:20px;line-height: 20px;text-align: center;background: #ccc;color:#000;border-radius:2px;}
.aj_message{padding-left: 13px;font-size: 32px;}
.aj_code{
margin-top: 35px;
display: inline-block;
font-size: 30px;
font-weight: 600;
text-shadow: 0px 7px 10px #000;
}
.head {
height: 246px;
width: 100%;
margin: 0 auto;
color:#fff;
font-size: 22px;
padding-left:15px;
font-weight: 600;
border-bottom: 1px solid #ececec;
border-radius: 5px;
}
/*.tableContent table{width:100%;}*/
.datagrid-header-inner,.datagrid-header-inner .datagrid-htable,.datagrid-body .datagrid-btable{width:100%;}
/************menu*************/
#menu{width:100%;height:30px;}
.menu_list{float:left;color:#fff;height:100%;line-height: 30px;margin-left:111px;}
.menu_list li{float:left;margin:0 18px;height:100%;line-height: 30px;font-weight:600;}
.menu_list li a{display: inline-block;position:relative;width:100%;height:100%;line-height: 30px;cursor: pointer;color:#000;}
.act{border-bottom:1.5px solid #2158f7;font-weight:600;}
.menu_list .act a{color: #2158f7;}
.bot_triangle{width: 0px;height: 0px;*width: 8px; *height: 8px;font-size: 0;line-height: 0; overflow: hidden;border-width: 8px;border-style: dashed dashed solid dashed;border-color:#2158f7 transparent transparent transparent;position:absolute;bottom:-16px;left:50%;margin-left: -4px;}
/*查询条件*/
.condition{margin-bottom:14px;border:1px solid #d8d8d8;
border-radius: 5px;}
.content_box{padding:18px;margin:13px 10px;box-shadow:2px 2px 23px #909090;background:#e8e5e4;}
.cx_t{margin: 0 0 2px 0;width: calc(100% - 10px); height: 36px;line-height: 36px;background: #e2e2e2;border-bottom: 1px solid #ccc;padding-left: 10px;font-weight: 600;color: #212121;}
.cx_t span{font-size: 12px;font-weight: 600;margin:0 10px;}
table .td_r{text-align: right;color: #296294;font-weight: 600;}
table .td_rc{text-align: right;color:#122ee2;}
table .td_c{text-align: center;}
.common_t>tr,.common_t>tbody>tr{border-bottom:1px dashed #ccc;}
.common_t>tbody>tr:last-child{border:none;}
.cx_table_tj td{height:40px;line-height: 40px;}
.cx_table_tj td input,.cx_table_tj td select{margin: 0px;padding:0 8px;height: 24px;line-height: 24px;width: 210px;white-space: normal;vertical-align: top;outline-style: none;resize: none;-moz-border-radius: 5px 5px 5px 5px;-webkit-border-radius: 5px 5px 5px 5px;border-radius: 5px 5px 5px 5px;border: 1px solid #ccc;background-color: #fff;vertical-align: middle;display: inline-block;overflow: hidden;white-space: nowrap;}
.cx_table_tj td input[type="radio"]{width:16px;height:16px;margin:0 5px;}
.btn_cx{padding: 5px 12px;margin-left:16px;border: 1px solid #245580;background-color: #337ab7;color: #fff;background-image: linear-gradient(to bottom,#4de4ba 0,#265a88 100%);background-repeat: repeat-x;text-shadow: 0 -1px 0 rgba(0,0,0,.2);box-shadow: inset 0 1px 0 rgba(255,255,255,.15), 0 1px 1px rgba(0,0,0,.075);border-radius: 4px;font-weight: normal;font-size: 12px;cursor: pointer;}
.btn_cx:hover {background: #2c689d;}
.btn_qkcxtj{margin-left:16px;padding: 5px 12px;border: 1px solid #b92c28;background-color: #d9534f;color: #fff;background-image: linear-gradient(to bottom,#d9534f 0,#c12e2a 100%);background-repeat: repeat-x;text-shadow: 0 -1px 0 rgba(0,0,0,.2);box-shadow: inset 0 1px 0 rgba(255,255,255,.15), 0 1px 1px rgba(0,0,0,.075);border-radius: 4px;font-weight: normal;font-size: 12px;cursor: pointer;}
.btn_qkcxtj:hover {background: #c12e2a;}
.datagrid-btable tr td:nth-child(1) a{cursor: pointer;margin:0 4px;}
.eclipse{vertical-align: bottom;display:inline-block;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;width:100%;}
/*覆盖*/
.datagrid-body td{border:1px solid #e4dede !important}
/**/
.tableContent{width:98%;border-radius: 5px;box-shadow: 0px 1px 27px #a9a7a7;background:#fff;margin:10px auto;padding:10px 0;height: calc(100vh - 141px);overflow-y:auto;position: relative;top: -146px;}
.tableContent>div{width:98%;margin:5px auto;}
/*翻页*/
.pagination > .disabled > span,
.pagination > .disabled > span:hover,
.pagination > .disabled > span:focus,
.pagination > .disabled > a,
.pagination > .disabled > a:hover,
.pagination > .disabled > a:focus {
color: #777777;
background-color: #fff;
border-color: #ddd;
cursor: not-allowed;
}
.wrap{width:1200px;margin:0 auto;}
.wrap h1{font-size:24px;font-weight:600;line-height: 40px;margin:10px 0;}
.wrap input,.wrap select{border:none;width:100%;line-height: 26px;height: 26px;text-indent: 10px;}
table.borderTable,table.borderTable tr th, table.borderTable tr td {border: 1px solid #9a9a9a; }
.noborder,.noborder tr th,.noborder tr td{border:none;}
.noborder tr th,.noborder tr td{border-right:1px solid #292929;}
.noborder tr th:last-child,.noborder tr td:last-child{border-right:none;}
table.borderTable{width:100%;line-height: 25px; text-align: center; border-collapse: collapse;}
.wrap p{line-height: 26px;margin:2px 0;}
table.borderTable td,table.borderTable tr{line-height: 26px;height:26px;}
.magin{margin-right:100px !important;}
.tbsm{border:1px solid #292929;border-radius: 5px;padding:8px 12px; }
.mg{margin:5px 0;}
.posionicon{position: absolute;bottom: 0px;right: -48px; font-size: 20px;}
.fa{cursor: pointer;
font-size: 23px;
float: right;
margin-right: -26px;}
.width{width: 50%;}
.title{line-height: 50px;}
.toggleBtn{margin-right:-49px;}
/*打印和导出*/
.btn-wrap{float: right;margin:10px 0;}
.btn-wrap li{float: left;width:36px;height: 36px;line-height:36px;cursor:pointer;font-size:20px;border:1px solid #ded6d6;text-align: center;color:#b5b4b4;}
.btn-wrap li:first-child{border-radius:2px 0 0 2px;}
.btn-wrap li:last-child{border-radius:0px 2px 2px 0px;border-left:none;}
.btn-wrap li.active{background: #5a94ff;color:#fff;}
/*选择文件*/
/*蓝色按钮,绝对定位*/
td .details{text-align: left;}
td .details span{margin:5px 22px;}
td .details span a{margin:0 4px;}
.detail-tip{text-align: left;}
.append-input,.detail-tip{padding-left: 22px;}
.lineH{padding:18px 0;}
.margin{margin:0 20px 0 50px;}
.zdy-upload {
padding: 6px 12px;
margin-left: 5px;
}
.btn_a {
padding: 5px 12px;
color: #fff;
border: 1px solid #ccc;
border-radius: 5px;
margin-right: 10px;
}
.btn_search {
background-color: #3692C6;
border-color: #217cb1;
}
.btn_search:hover {
background-color:#2682b5;
border-color: #217cb1;
}
.select-file{
position: absolute;
display: block;
width: 74px;
left:22px;
top:0;
text-decoration: none;
text-align: center;
cursor: pointer;
margin-left:0px !important;
}
.blueButton:hover{
text-decoration: none;
}
.append-input{position: relative;min-height:45px;}
/*自定义上传,位置大小都和a完全一样,而且完全透明*/
.fileCss{
position: absolute;
left:0;
width:74px;
top:0;
display: block;
padding: 6px 12px;
opacity: 0;
}
.append-input input{cursor: pointer;}
.linkT{
text-shadow: 0px 4px 4px rgba(0, 2, 53, 0.5);float: right;color: #fff;margin-right: 39px;text-decoration: underline;line-height: 90px;font-weight:600;
}
.linkT:hover{cursor: pointer;text-decoration: underline;}
.linkT .fa{
float: left;
margin-right: 4px;
line-height: 90px;
font-size: 17px;
}
\ No newline at end of file
<!DOCTYPE html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>excel地理/逆地理编码</title>
<link rel="stylesheet" href="/static/css/base_initialize.css">
<link rel="stylesheet" type="text/css" href="/static/css/table.css">
<style>
html,body{overflow: hidden;height: 100%;}
/*loading*/
.loaddingWrap{position: absolute;left:50%;top:130px;margin-left:-68px;}
.loaddingWrap>p{padding:5px 10px;color:#000;background: rgb(255,255,255);border:1px solid #ccc;border-radius:5px;width:136px;height:26px;line-height: 26px;}
.loaddingWrap .fa{font-size: 20px;margin-right: 5px; position: relative;top: -2px;}
.loaddingWrap span{display: inline-block;position: relative; top: -6px;}
</style>
</head>
<body>
<article class="w" style="width:100%;background:url(/static/img/bg.jpg) no-repeat;
background-size: cover;">
<div class="head clearfix">
<%--<div class="aj_message">
<span class="aj_code">案(事)件校验情况统计</span>
</div>--%>
<span class="linkT" style="text-decoration: none;font-size: 20px"><i class="fa fa-search"></i>excel地理/逆地理编码</span>
</div>
<div class="tableContent" style="top:-167px;height: calc(100vh - 180px);">
<!-- 菜单1 -->
<div id="" class="content">
<!--查询条件-->
<div class="condition" id="tableWrap">
<div class="cx_t">
<h6 style="display: inline-block;margin-right: 10px">excel地理/逆地理编码</h6>
<span style="position: absolute;right: 18px;">
<a style="padding-right: 20px;text-decoration: underline" href="地理编码模板.xls" download="地理编码模板.xls">下载地理编码模板</a>
<a style="padding-right: 17px;text-decoration: underline" href="逆地理编码模板.xls" download="逆地理编码模板.xls">下载逆地理编码模板</a>
</span>
</div>
<form method="post" enctype="multipart/form-data" id="queryCourseForm" style="margin: 5px">
<div class="bar_tb" style="margin-top: 10px;position: relative;min-height: 10px;height: 10px">
<span style="color: red"> 选择文件:</span> <input style="width: 150px" id="fileName1" name="fileName1" type="file" />
</div>
<%-- <div class="bar_tb" style="position: relative;min-height: 10px;height: 10px;margin-top: 25px">
<span style="color: red"> 选择来源:</span>
<select id="source" name="source">
<option value="baidu">百度</option>
<option selected="selected" value="gaode">高德</option>
<option value="tengxun">腾讯</option>
</select>
</div>--%>
<div style="padding: 8px">
<a class="btn_a btn_cx" style="margin-left: 45%;margin-top: 3%; " onclick="doSaveBg()">确定</a>
</div>
</form>
</div>
</div>
</div>
</article>
<script src="/static/js/jquery.min.js"></script>
<script>
$(function () {
/* $("#source").change(function(){
var selected=$(this).children('option:selected').val();
//alert(selected);
$.ajax({
url:"/getNum",
type : "post",
data : {source : selected},
success:function(res){
alert(res.msg);
console.log(res);
},
})
if(selected=="order_time"){
//document.getElementById("search_content_id").
$("#search_content_id")[0].placeholder="时间格式:20150923";
}else if(selected=="order_id"){
$("#search_content_id")[0].placeholder="";
}
});*/
})
function doSaveBg() {
var localPath = $("#fileName1").val();
// console.log(JSON.stringify(localPath));
if(localPath == ""){
alert("请选择文件");
return;
}
if(localPath.lastIndexOf(".xls") == -1 && localPath.lastIndexOf(".xlsx") == -1 && localPath.lastIndexOf(".XLS") == -1 && localPath.lastIndexOf(".XLSX") == -1){
alert("请选择excel文件");
return;
}
$("#queryCourseForm").attr("action","/a");//改变表单的提交地址为下载的地址
$("#queryCourseForm").submit();//提交表单
/* var formData = new FormData();//这里需要实例化一个FormData来进行文件上传
var type = "fileName1";
formData.append(type,$("#fileName1")[0].files[0]);
console.log("时间" +$("#lrtime").datebox("getValue"));
$.ajax({
url:"/a",
type : "post",
data : formData,
processData : false,
contentType : false,
success:function(res){
alert(JSON.stringify(res));
var eleLink = document.createElement('a');
eleLink.download = $("#fileName1")[0].files[0].name;
eleLink.style.display = 'none';
// 字符内容转变成blob地址
var blob = bs64toBlob(res);
eleLink.href = URL.createObjectURL(blob);
// 触发点击
document.body.appendChild(eleLink);
eleLink.click();
// 然后移除
document.body.removeChild(eleLink);
},
error: function(){
alert("修改失败,请检查网络状态!");
}
});*/
}
</script>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment