智慧保安后台管理项目备份
tangzy
2021-11-25 9b1c48e0aadf587a104daa144dbb9f070b3d35b2
1.统计
6 files modified
5 files added
804 ■■■■■ changed files
src/main/java/org/springblade/common/config/FtpConfig.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/FTP/FtpUtil.java 55 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/FTP/monitor.java 48 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/dispatcher/img.png patch | view | raw | blame | history
src/main/java/org/springblade/modules/equipage/controller/CarController.java 188 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/equipage/controller/DowloadZipUtil.java 66 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/equipage/controller/FileZip.java 97 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/equipage/controller/HttpReqUtil.java 280 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/equipage/controller/Md5SignUtil.java 59 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml 2 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/entity/User.java 2 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/common/config/FtpConfig.java
@@ -3,6 +3,8 @@
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import java.util.List;
/**
 * ftp 配置路径
 * @author zhongrj
@@ -59,6 +61,7 @@
    public static String jsonUrl;
    public static List list;
    public void setSqlConnect(String sqlConnect) {
@@ -96,4 +99,8 @@
    public void setJsonUrl(String jsonUrl) {
        FtpConfig.jsonUrl = jsonUrl;
    }
    public void setList(List list){
        FtpConfig.list=list;
    }
}
src/main/java/org/springblade/modules/FTP/FtpUtil.java
@@ -6,10 +6,12 @@
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPReply;
import org.springframework.web.multipart.MultipartFile;
import java.io.*;
import java.net.SocketException;
import java.util.Date;
import net.lingala.zip4j.core.ZipFile;
import static org.springblade.common.config.FtpConfig.*;
@@ -302,5 +304,58 @@
        }
        FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserName, ftpPassword, ftpPath, "/",  "n"+response1+".json", in1);
    }
    /**
     *
     * 解压zip 包
     * @author panchaoyuan
     * @param srcFile    Unzipped file
     * @param destDirPath   Unzipped destination folder
     * @throws RuntimeException
     * @throws IOException
     */
    public static void unZip(MultipartFile srcFile, String destDirPath, String savePath) throws RuntimeException, IOException {
        File file = null;
        InputStream ins = srcFile.getInputStream();
        String savaPaths = savePath+srcFile.getOriginalFilename();
        file=new File(savaPaths);
        inputStreamToFile(ins, file);
        if (!file.exists()) {
            throw new RuntimeException(file.getPath() + ",file is not found");
        }
        ZipFile zipFile = null;
        try {
            zipFile = new ZipFile(file);
//            zipFile.setFileNameCharset("utf-8");
            zipFile.setFileNameCharset("gbk");
            //解压到 destDirPath
            zipFile.extractAll(destDirPath);
        }catch(Exception e) {
            throw new RuntimeException("unzip error from FileUtil", e);
        }
    }
    /**
     * 输入流转换为文件
     * @author panchaoyuan
     * @return
     */
    private static void inputStreamToFile(InputStream ins, File file) {
        try {
            OutputStream os = new FileOutputStream(file);
            int bytesRead = 0;
            byte[] buffer = new byte[8192];
            while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) {
                os.write(buffer, 0, bytesRead);
            }
            os.close();
            ins.close();
        }catch(Exception e) {
            e.printStackTrace();
        }
    }
}
src/main/java/org/springblade/modules/FTP/monitor.java
@@ -24,7 +24,7 @@
    public static boolean isFTPFileExist() {
        FTPClient ftp = new FTPClient();
        String fileName = null;
        try {
//            System.out.println("ftpHost = " + ftpHost);
@@ -76,7 +76,7 @@
                return false;
            } else {
                for (FTPFile file : files) {
                    String fileName = file.getName();
                     fileName = file.getName();
                    InputStream is = ftp.retrieveFileStream(new String(fileName.getBytes("GBK"), FTP.DEFAULT_CONTROL_ENCODING));
                    if (null == is) {
                        return false;
@@ -127,49 +127,9 @@
                return true;
            }
            //InputStream is = ftp.retrieveFileStream(new String(file.getBytes("GBK"), FTP.DEFAULT_CONTROL_ENCODING));
//            if (is == null || ftp.getReplyCode() == FTPReply.FILE_UNAVAILABLE) {
//                return false;
//
//            }
//
//            if (is != null) {
//                //把文件下载到本地
//                FtpUtil.downloadFtpFile(ftpHost, ftpUserName, ftpPassword, ftpPort, ftpPath, localPath, fileName);
//                //
//                String s = OutJson.TestJson();
//                //sql语句
//                String sql = OutJson.stringReplace(s);
//                String[] split = sql.split(";");//以逗号分割
//                for (String sqls : split) {
//                    //判断是否是新增,删除,修改
//                    String substring = sqls.substring(0, 2);
//                    //新增
//                    if (substring.equals("in")) {
//                        //运行sql语句
//                        MysqlCenlint.inster(sqls);
//                    }
//                    //修改
//                    else if (substring.equals("up")) {
//                        MysqlCenlint.update(sqls);
//                    }
//                    //删除
//                    else {
//                        MysqlCenlint.delete(sqls);
//                    }
//                }
//                //删除本地文件
//                MysqlCenlint.delete();
//                FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", "nsql.json");
//                is.close();
//                ftp.completePendingCommand();
//
//            }
        } catch (Exception e) {
            MysqlCenlint.deletess(fileName);
            FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", fileName);
            e.printStackTrace();
        } finally {
src/main/java/org/springblade/modules/dispatcher/img.png
src/main/java/org/springblade/modules/equipage/controller/CarController.java
@@ -3,7 +3,10 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import liquibase.pro.packaged.C;
import lombok.AllArgsConstructor;
import org.apache.commons.io.FileUtils;
import org.apache.commons.net.ftp.FTPConnectionClosedException;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
@@ -12,6 +15,22 @@
import org.springblade.modules.equipage.service.CarService;
import org.springblade.modules.equipage.vo.CarVo;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.awt.*;
import java.io.*;
import java.net.URL;
import java.net.URLDecoder;
import java.nio.charset.Charset;
import java.util.*;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
import static org.springblade.common.config.FtpConfig.*;
/**
 * @author zhongrj
@@ -24,11 +43,13 @@
public class CarController {
    private final CarService carService;
    private static String csvurl;
    /**
     * 自定义分页
     *
     * @param query page,size
     * @param car 车辆信息对象
     * @param car   车辆信息对象
     */
    @GetMapping("/page")
    public R<IPage<CarVo>> page(CarVo car, Query query) {
@@ -38,6 +59,7 @@
    /**
     * 新增
     *
     * @param car 车辆信息对象
     */
    @PostMapping("/save")
@@ -48,6 +70,7 @@
    /**
     * 修改
     *
     * @param car 车辆信息对象
     */
    @PostMapping("/update")
@@ -57,6 +80,7 @@
    /**
     * 新增或修改
     *
     * @param car 车辆信息对象
     */
    @PostMapping("/submit")
@@ -66,6 +90,7 @@
    /**
     * 删除
     *
     * @param ids 车辆信息ids 数组
     */
    @PostMapping("/remove")
@@ -75,6 +100,7 @@
    /**
     * 详情
     *
     * @param car 车辆信息对象
     */
    @GetMapping("/detail")
@@ -84,4 +110,164 @@
        return R.data(detail);
    }
    /**
     * 查询车辆实时位置
     */
    @GetMapping("/locationcar")
    public String locationcar(String imei) {
        String url = "http://dvopenapi.aimap.net.cn/openapi/device/location";
        String res = null;
        Map<String, Object> params = new HashMap<>();
        params.put("imei", imei);
        params.put("appId", "PO00000761");
        params.put("timestamp", System.currentTimeMillis());
        String secert = "dXRGb2pRNVdWOGQ3d1ouV29UYzc1MnJaUnBwTzUx";
        String computeSign = "";
        try {
            computeSign = Md5SignUtil.signRequest(params, secert);
        } catch (IOException e1) {
            e1.printStackTrace();
        }
        params.put("sign", computeSign);
        try {
            //String res = HttpReqUtil.getInstance().doGet(url, params, null);
            res = HttpReqUtil.getInstance().doPost(url, params, null);
            System.out.println("----" + res);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return res;
    }
    /**
     * 查询车辆轨迹
     */
    @GetMapping("/locationhistoryTrack")
    public R locationhistoryTrack(String beginTime, String endTime, String rectify,String callbackId) throws AWTException {
        String url = "http://dvopenapi.aimap.net.cn/openapi/device/historyTrack";
        String res = null;
        Map<String, Object> params = new HashMap<>();
        params.put("imei", "861636056082414");
        params.put("beginTime", beginTime);
        params.put("endTime", endTime);
        params.put("rectify", rectify);
        params.put("callbackUrl", "http://2h3f861221.wicp.vip/car/SaveUrl");
        params.put("callbackId", callbackId);
        params.put("appId", "PO00000761");
        params.put("timestamp", System.currentTimeMillis());
        String secert = "dXRGb2pRNVdWOGQ3d1ouV29UYzc1MnJaUnBwTzUx";
        String computeSign = "";
        try {
            computeSign = Md5SignUtil.signRequest(params, secert);
        } catch (IOException e1) {
            e1.printStackTrace();
        }
        params.put("sign", computeSign);
        try {
            //String res = HttpReqUtil.getInstance().doGet(url, params, null);
            res = HttpReqUtil.getInstance().doPost(url, params, null);
            Thread.sleep(2000);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return R.data(csvurl);
    }
    /**
     * 实时视频直播指令下发接口
     */
    @GetMapping("/cmd")
    public String cmd(int camera, String action) {
        String url = "http://dvopenapi.aimap.net.cn/openapi/live/cmd";
        String res = null;
        Map<String, Object> params = new HashMap<>();
        //设备imei号
        params.put("imei", "861636056082414");
        //摄像头ID
        params.put("camera", camera);
        //实时视频指令类型
        params.put("action", action);
        params.put("appId", "PO00000761");
        params.put("timestamp", System.currentTimeMillis());
        String secert = "dXRGb2pRNVdWOGQ3d1ouV29UYzc1MnJaUnBwTzUx";
        String computeSign = "";
        try {
            computeSign = Md5SignUtil.signRequest(params, secert);
        } catch (IOException e1) {
            e1.printStackTrace();
        }
        params.put("sign", computeSign);
        try {
            //String res = HttpReqUtil.getInstance().doGet(url, params, null);
            long startTime=System.currentTimeMillis();   //获取开始时间
            res = HttpReqUtil.getInstance().doPost(url, params, null);
            long endTime=System.currentTimeMillis(); //获取结束时间
            System.out.println("程序运行时间: "+(endTime-startTime)+"ms");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return res;
    }
    /**
     * 轨迹回调
     *
     * @param callbackId
     * @param fileUrl
     * @throws UnsupportedEncodingException
     */
    @PostMapping("/SaveUrl")
    @ApiOperation(value = "详情", notes = "传入car")
    public void SaveUrl(String callbackId, String fileUrl) throws Exception {
        csvurl = null;
        DowloadZipUtil dowloadZipUtil = new DowloadZipUtil();
        File file = dowloadZipUtil.downloadFile(fileUrl, "D:\\caiji");
        //文件名
        String name = file.getName();
        String substring = name.substring(0, name.length() - 4);
        //解压数据
        FileZip fileZip = new FileZip();
        fileZip.ZipUncompress("D:\\caiji\\" + substring + ".zip", "D:\\caiji");
        csvurl =substring + ".csv";
    }
    /**
     * 人员
     * @return
     * @throws Exception
     */
    @GetMapping("/Peo")
    public String cs() throws Exception {
        String url = "http://223.82.109.183:2080/Escort/getgis.php";
        Map<String, Object> params = new HashMap<>();
        //设备imei号
        params.put("acc", "7731");
        String res = null;
            res = HttpReqUtil.getInstance().doPost(url, params, null);
        return res;
    }
    /**
     * 轨迹
     * @return
     * @throws Exception
     */
    @GetMapping("/Peog")
    public String Peocar() throws Exception {
        String url = "http://223.82.109.183:2080/Escort/getgistrack.php";
        Map<String, Object> params = new HashMap<>();
        //设备imei号
        params.put("number", "7730");
        params.put("acc", "7731");
        String res = null;
        res = HttpReqUtil.getInstance().doPost(url, params, null);
        return res;
    }
}
src/main/java/org/springblade/modules/equipage/controller/DowloadZipUtil.java
New file
@@ -0,0 +1,66 @@
package org.springblade.modules.equipage.controller;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
public class DowloadZipUtil {
    //urlPath:目标文件路径, downloadDir:下载后要放的文件路径
    public static File downloadFile(String urlPath, String downloadDir) {
        File file = null;
        try {
            // 统一资源
            URL url = new URL(urlPath);
            // 连接类的父类,抽象类
            URLConnection urlConnection = url.openConnection();
            // http的连接类
            HttpURLConnection httpURLConnection = (HttpURLConnection) urlConnection;
            // 设定请求的方法,默认是GET
            httpURLConnection.setRequestMethod("GET");
            // 设置字符编码
            httpURLConnection.setRequestProperty("Charset", "UTF-8");
            // 打开到此 URL 引用的资源的通信链接(如果尚未建立这样的连接)。
            httpURLConnection.connect();
            // 文件大小
            int fileLength = httpURLConnection.getContentLength();
            // 文件名
            String filePathUrl = httpURLConnection.getURL().getFile();
            String[]  strs=filePathUrl.split("/");
            String s = strs[4].toString();
            System.out.println(s);
            //File.separatorChar代表的是分隔符“/”或者“\”,若详知 自行百度
            String fileFullName = filePathUrl.substring(filePathUrl.lastIndexOf(File.separatorChar) + 1);
            System.out.println("file length---->" + fileLength);
            URLConnection con = url.openConnection();
            BufferedInputStream bin = new BufferedInputStream(httpURLConnection.getInputStream());
            String path = downloadDir + "/"+strs[4].toString();
            file = new File(path);
            if (!file.getParentFile().exists()) {
                file.getParentFile().mkdirs();
            }
            OutputStream out = new FileOutputStream(file);
            int size = 0;
            int len = 0;
            byte[] buf = new byte[1024];
            while ((size = bin.read(buf)) != -1) {
                len += size;
                out.write(buf, 0, size);
                // 打印下载百分比
                // System.out.println("下载了-------> " + len * 100 / fileLength +
                // "%\n");
            }
            bin.close();
            out.close();
        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } finally {
            return file;
        }
    }
}
src/main/java/org/springblade/modules/equipage/controller/FileZip.java
New file
@@ -0,0 +1,97 @@
package org.springblade.modules.equipage.controller;
import java.io.*;
import java.util.zip.*;
import java.util.zip.ZipEntry;
public class FileZip {
    /**
     * zip文件压缩
     * @param inputFile 待压缩文件夹/文件名
     * @param outputFile 生成的压缩包名字
     */
    public static void ZipCompress(String inputFile, String outputFile) throws Exception {
        //创建zip输出流
        ZipOutputStream out = new ZipOutputStream(new FileOutputStream(outputFile));
        //创建缓冲输出流
        BufferedOutputStream bos = new BufferedOutputStream(out);
        File input = new File(inputFile);
        compress(out, bos, input,null);
        bos.close();
        out.close();
    }
    /**
     * @param name 压缩文件名,可以写为null保持默认
     */
    //递归压缩
    public static void compress(ZipOutputStream out, BufferedOutputStream bos, File input, String name) throws IOException {
        if (name == null) {
            name = input.getName();
        }
        //如果路径为目录(文件夹)
        if (input.isDirectory()) {
            //取出文件夹中的文件(或子文件夹)
            File[] flist = input.listFiles();
            if (flist.length == 0)//如果文件夹为空,则只需在目的地zip文件中写入一个目录进入
            {
                out.putNextEntry(new ZipEntry(name + "/"));
            } else//如果文件夹不为空,则递归调用compress,文件夹中的每一个文件(或文件夹)进行压缩
            {
                for (int i = 0; i < flist.length; i++) {
                    compress(out, bos, flist[i], name + "/" + flist[i].getName());
                }
            }
        } else//如果不是目录(文件夹),即为文件,则先写入目录进入点,之后将文件写入zip文件中
        {
            out.putNextEntry(new ZipEntry(name));
            FileInputStream fos = new FileInputStream(input);
            BufferedInputStream bis = new BufferedInputStream(fos);
            int len=-1;
            //将源文件写入到zip文件中
            byte[] buf = new byte[1024];
            while ((len = bis.read(buf)) != -1) {
                bos.write(buf,0,len);
            }
            bis.close();
            fos.close();
        }
    }
    /**
     * zip解压
     * @param inputFile 待解压文件名
     * @param destDirPath  解压路径
     */
    public static void ZipUncompress(String inputFile,String destDirPath) throws Exception {
        File srcFile = new File(inputFile);//获取当前压缩文件
        // 判断源文件是否存在
        if (!srcFile.exists()) {
            throw new Exception(srcFile.getPath() + "所指文件不存在");
        }
        //开始解压
        //构建解压输入流
        ZipInputStream zIn = new ZipInputStream(new FileInputStream(srcFile));
        ZipEntry entry = null;
        File file = null;
        while ((entry = zIn.getNextEntry()) != null) {
            if (!entry.isDirectory()) {
                file = new File(destDirPath, entry.getName());
                if (!file.exists()) {
                    new File(file.getParent()).mkdirs();//创建此文件的上级目录
                }
                OutputStream out = new FileOutputStream(file);
                BufferedOutputStream bos = new BufferedOutputStream(out);
                int len = -1;
                byte[] buf = new byte[1024];
                while ((len = zIn.read(buf)) != -1) {
                    bos.write(buf, 0, len);
                }
                // 关流顺序,先打开的后关闭
                bos.close();
                out.close();
            }
        }
    }
}
src/main/java/org/springblade/modules/equipage/controller/HttpReqUtil.java
New file
@@ -0,0 +1,280 @@
package org.springblade.modules.equipage.controller;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.URI;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicHeader;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
public class HttpReqUtil {
    protected final static Log LOG = LogFactory.getLog(HttpReqUtil.class);
    private static HttpReqUtil instance;
    protected Charset charset;
    private HttpReqUtil(){}
    public static HttpReqUtil getInstance() {
        return getInstance(Charset.defaultCharset());
    }
    public static HttpReqUtil getInstance(Charset charset){
        if(instance == null){
            instance = new HttpReqUtil();
        }
        instance.setCharset(charset);
        return instance;
    }
    public void setCharset(Charset charset) {
        this.charset = charset;
    }
    /**
     * post请求
     */
    public String doPost(String url) throws Exception {
        return doPost(url, null, null);
    }
    public String doPost(String url, Map<String, Object> params) throws Exception {
        return doPost(url, params, null);
    }
    public String doPost(String url, Map<String, Object> params, Map<String, String> header) throws Exception {
        String body = null;
        try {
            // Post请求
            LOG.debug(" protocol: POST");
            LOG.debug("      url: " + url);
            HttpPost httpPost = new HttpPost(url.trim());
            // 设置参数
            LOG.debug("   params: " + JSON.toJSONString(params));
            httpPost.setEntity(new UrlEncodedFormEntity(map2NameValuePairList(params), charset));
            // 设置Header
            if (header != null && !header.isEmpty()) {
                LOG.debug("   header: " + JSON.toJSONString(header));
                for (Iterator<Entry<String, String>> it = header.entrySet().iterator(); it.hasNext();) {
                    Entry<String, String> entry = (Entry<String, String>) it.next();
                    httpPost.setHeader(new BasicHeader(entry.getKey(), entry.getValue()));
                }
            }
            // 发送请求,获取返回数据
            body = execute(httpPost);
        } catch (Exception e) {
            throw e;
        }
        LOG.debug("   result: " + body);
        return body;
    }
    /**
     * postJson请求
     */
    public String doPostJson(String url, Map<String, Object> params) throws Exception {
        return doPostJson(url, params, null);
    }
    public String doPostJson(String url, Map<String, Object> params, Map<String, String> header) throws Exception {
        String json = null;
        if (params != null && !params.isEmpty()) {
            for (Iterator<Entry<String, Object>> it = params.entrySet().iterator(); it.hasNext();) {
                Entry<String, Object> entry = (Entry<String, Object>) it.next();
                Object object = entry.getValue();
                if (object == null) {
                    it.remove();
                }
            }
            json = JSON.toJSONString(params);
        }
        return postJson(url, json, header);
    }
    public String doPostJson(String url, String json) throws Exception {
        return doPostJson(url, json, null);
    }
    public String doPostJson(String url, String json, Map<String, String> header) throws Exception {
        return postJson(url, json, header);
    }
    private String postJson(String url, String json, Map<String, String> header) throws Exception {
        String body = null;
        try {
            // Post请求
            LOG.debug(" protocol: POST");
            LOG.debug("      url: " + url);
            HttpPost httpPost = new HttpPost(url.trim());
            // 设置参数
            LOG.debug("   params: " + json);
            httpPost.setEntity(new StringEntity(json, ContentType.DEFAULT_TEXT.withCharset(charset)));
            httpPost.setHeader(new BasicHeader("Content-Type", "application/json"));
            LOG.debug("     type: JSON");
            // 设置Header
            if (header != null && !header.isEmpty()) {
                LOG.debug("   header: " + JSON.toJSONString(header));
                for (Iterator<Entry<String, String>> it = header.entrySet().iterator(); it.hasNext();) {
                    Entry<String, String> entry = (Entry<String, String>) it.next();
                    httpPost.setHeader(new BasicHeader(entry.getKey(), entry.getValue()));
                }
            }
            // 发送请求,获取返回数据
            body = execute(httpPost);
        } catch (Exception e) {
            throw e;
        }
        LOG.debug("  result: " + body);
        return body;
    }
    /**
     * get请求
     */
    public String doGet(String url) throws Exception {
        return doGet(url, null, null);
    }
    public String doGet(String url, Map<String, String> header) throws Exception {
        return doGet(url, null, header);
    }
    public String doGet(String url, Map<String, Object> params, Map<String, String> header) throws Exception {
        String body = null;
        try {
            // Get请求
            LOG.debug("protocol: GET");
            HttpGet httpGet = new HttpGet(url.trim());
            // 设置参数
            if (params != null && !params.isEmpty()) {
                String str = EntityUtils.toString(new UrlEncodedFormEntity(map2NameValuePairList(params), charset));
                String uri = httpGet.getURI().toString();
                if(uri.indexOf("?") >= 0){
                    httpGet.setURI(new URI(httpGet.getURI().toString() + "&" + str));
                }else {
                    httpGet.setURI(new URI(httpGet.getURI().toString() + "?" + str));
                }
            }
            LOG.debug("     url: " + httpGet.getURI());
            // 设置Header
            if (header != null && !header.isEmpty()) {
                LOG.debug("   header: " + header);
                for (Iterator<Entry<String, String>> it = header.entrySet().iterator(); it.hasNext();) {
                    Entry<String, String> entry = (Entry<String, String>) it.next();
                    httpGet.setHeader(new BasicHeader(entry.getKey(), entry.getValue()));
                }
            }
            // 发送请求,获取返回数据
            body =  execute(httpGet);
        } catch (Exception e) {
            throw e;
        }
        LOG.debug("  result: " + body);
        return body;
    }
    private String execute(HttpRequestBase requestBase) throws Exception {
        CloseableHttpClient httpclient = HttpClients.createDefault();
        String body = null;
        try {
            CloseableHttpResponse response = httpclient.execute(requestBase);
            try {
                HttpEntity entity = response.getEntity();
                if (entity != null) {
                    body = EntityUtils.toString(entity, charset.toString());
                }
                EntityUtils.consume(entity);
            } catch (Exception e) {
                throw e;
            }finally {
                response.close();
            }
        } catch (Exception e) {
            throw e;
        } finally {
            httpclient.close();
        }
        return body;
    }
    private List<NameValuePair> map2NameValuePairList(Map<String, Object> params) {
        if (params != null && !params.isEmpty()) {
            List<NameValuePair> list = new ArrayList<NameValuePair>();
            Iterator<String> it = params.keySet().iterator();
            while (it.hasNext()) {
                String key = it.next();
                if(params.get(key) != null) {
                    String value = String.valueOf(params.get(key));
                    list.add(new BasicNameValuePair(key, value));
                }
            }
            return list;
        }
        return null;
    }
    public static void main(String[] args) {
        String url = "http://dvopenapi.aimap.net.cn/openapi/device/location";
        Map<String, Object> params = new HashMap<>();
//        params.put("beginTime",  1585059861400L);
//        params.put("endTime", 1585059862400L);
//        params.put("alarmType ", "8");
        params.put("imei",  "861636056082414");
        params.put("appId", "PO00000761");
        params.put("timestamp", System.currentTimeMillis());
        String secert="dXRGb2pRNVdWOGQ3d1ouV29UYzc1MnJaUnBwTzUx";
        String computeSign = "";
        try {
            computeSign = Md5SignUtil.signRequest(params, secert);
        } catch (IOException e1) {
            e1.printStackTrace();
        }
        params.put("sign",computeSign);
        try {
            //String res = HttpReqUtil.getInstance().doGet(url, params, null);
            String res = HttpReqUtil.getInstance().doPost(url, params, null);
            System.out.println("----"+res);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
src/main/java/org/springblade/modules/equipage/controller/Md5SignUtil.java
New file
@@ -0,0 +1,59 @@
package org.springblade.modules.equipage.controller;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.collect.Maps;
import com.google.common.hash.Hashing;
import java.io.IOException;
public class Md5SignUtil {
    private final static Logger logger = LoggerFactory.getLogger(Md5SignUtil.class);
    public static String signRequest(Map<String, Object> params, String secret) throws IOException {
        // 第一步:检查参数是否已经排序
        String[] keys = params.keySet().toArray(new String[0]);
        Arrays.sort(keys);
        // 第二步:把所有参数名和参数值串在一起
        StringBuilder query = new StringBuilder();
        query.append(secret);
        for (String key : keys) {
            Object o = params.get(key);
            if (o!= null && o!="") {
                query.append(key).append(o);
            }
        }
        query.append(secret);
//        logger.info("query={}",query);
        // 第三步:使用MD5加密
        byte[] bytes = encryptMD5(query.toString());
        // 第四步:把二进制转化为大写的十六进制(正确签名应该为32大写字符串,此方法需要时使用)
        return byte2hex(bytes);
    }
    public static byte[] encryptMD5(String data) throws IOException {
        return Hashing.md5().hashBytes(data.getBytes("utf-8")).asBytes();
    }
    public static String byte2hex(byte[] bytes) {
        StringBuilder sign = new StringBuilder();
        for (int i = 0; i < bytes.length; i++) {
            String hex = Integer.toHexString(bytes[i] & 0xFF);
            if (hex.length() == 1) {
                sign.append("0");
            }
            sign.append(hex.toUpperCase());
        }
        return sign.toString();
    }
}
src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml
@@ -1198,7 +1198,7 @@
        A.stats,
        j.dept_name AS jurname
        FROM
        ( SELECT jurisdiction, departmentid,enterpriseName,stats,create_time FROM sys_information where state !=1) A
        ( SELECT jurisdiction, departmentid,enterpriseName,stats,create_time FROM sys_information where stats !=1) A
        LEFT JOIN (
        SELECT
        J.znum+J.fznum as num,
src/main/java/org/springblade/modules/system/entity/User.java
@@ -211,7 +211,7 @@
     * 是否缴纳保险 0:是   1:否
     */
    private Integer insurance;
    private Integer guncode;
    private String guncode;
    /**
     * 审查时间