Browse Source

提交代码

mengshibin 4 years ago
commit
5650772f72

+ 6 - 0
src/main/docker/Dockerfile

@@ -0,0 +1,6 @@
+FROM frolvlad/alpine-oraclejdk8:slim
+VOLUME /tmp
+ADD fbxtoobj-0.0.1-SNAPSHOT.jar app.jar
+#RUN bash -c 'touch /app.jar'
+ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-Dfile.encoding=UTF8","-Duser.timezone=GMT+08","-jar","/app.jar"]
+EXPOSE 7081

+ 20 - 0
src/main/java/com/fdkankan/FbxToObjApplication.java

@@ -0,0 +1,20 @@
+package com.fdkankan;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
+
+@SpringBootApplication
+public class FbxToObjApplication extends SpringBootServletInitializer {
+
+	@Override
+	protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
+		return application.sources(FbxToObjApplication.class);
+	}
+
+	public static void main(String[] args) {
+		SpringApplication.run(FbxToObjApplication.class, args);
+	}
+
+}

+ 130 - 0
src/main/java/com/fdkankan/controller/AddressController.java

@@ -0,0 +1,130 @@
+package com.fdkankan.controller;
+
+//import io.swagger.annotations.Api;
+//import io.swagger.annotations.ApiImplicitParam;
+//import io.swagger.annotations.ApiOperation;
+import com.fdkankan.entity.AddressEntity;
+import com.fdkankan.entity.HouseholdEntity;
+import com.fdkankan.mapper.IAddressMapper;
+import com.fdkankan.util.IsPtInPolyUtil;
+import com.fdkankan.util.Point;
+import com.fdkankan.util.Result;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created by Hb_zzZ on 2021/1/15.
+ */
+@Slf4j
+@RestController
+@RequestMapping("/address")
+//@Api(tags = "测试地址模块")
+public class AddressController {
+
+    @Autowired
+    private IAddressMapper addressMapper;
+
+//    @ApiOperation("获取所有地址信息")
+    @RequestMapping(value = "/findAllAddress", method = RequestMethod.GET)
+    public Result findAllAddress(){
+        return Result.success(addressMapper.findAllAddress());
+    }
+
+//    @ApiOperation("获取所有房屋信息")
+    @RequestMapping(value = "/findAllHouse", method = RequestMethod.GET)
+    public Result findAllHouse(){
+        return Result.success(addressMapper.findAllHousehold());
+    }
+
+//    @ApiOperation("根据id获取地址信息")
+    @RequestMapping(value = "/findAddressById", method = RequestMethod.GET)
+//    @ApiImplicitParam(name = "id", value = "id", dataType = "String")
+    public Result findAddressById(String id){
+        return Result.success(addressMapper.findAddressById(id));
+    }
+
+//    @ApiOperation("根据id获取房屋信息")
+    @RequestMapping(value = "/findHouseById", method = RequestMethod.GET)
+//    @ApiImplicitParam(name = "id", value = "id", dataType = "String")
+    public Result findHouseById(String id){
+        return Result.success(addressMapper.findHouseholdById(id));
+    }
+
+    @RequestMapping(value = "/findAllName", method = RequestMethod.GET)
+    public Result findAllName(){
+        return Result.success(addressMapper.findAllName());
+    }
+
+    @RequestMapping(value = "/findAllBuildNumberByName", method = RequestMethod.GET)
+    public Result findAllBuildNumberByName(String name){
+        return Result.success(addressMapper.findAllBuildNumberByName(name));
+    }
+
+    @RequestMapping(value = "/findPageHouseByBuildNumber", method = RequestMethod.GET)
+    public Result findPageHouseByBuildNumber(String buildNumber, Integer pageNum, Integer pageSize){
+        PageHelper.startPage(pageNum, pageSize);
+
+        List<HouseholdEntity> list = addressMapper.findPageHouseByBuildNumber(buildNumber);
+        PageInfo<HouseholdEntity> pageInfo = new PageInfo<>(list);
+        Map<String, Object> map = new HashMap<>();
+        map.put("house", pageInfo);
+        map.put("totalFloor", addressMapper.findMaxFloorHouseByBuildNumber(buildNumber));
+        return Result.success(map);
+    }
+
+    @RequestMapping(value = "/findHouseByGps", method = RequestMethod.GET)
+    public Result findHouseByGps(Double longitude1, Double longitude2, Double longitude3,
+                                 Double longitude4, Double latitude1, Double latitude2,
+                                 Double latitude3, Double latitude4){
+        List<Point> list = new ArrayList<>();
+        Point point = new Point();
+        point.setLongitude(longitude1);
+        point.setLatitude(latitude1);
+        list.add(point);
+
+        point = new Point();
+        point.setLongitude(longitude2);
+        point.setLatitude(latitude2);
+        list.add(point);
+
+        point = new Point();
+        point.setLongitude(longitude3);
+        point.setLatitude(latitude3);
+        list.add(point);
+
+        point = new Point();
+        point.setLongitude(longitude4);
+        point.setLatitude(latitude4);
+        list.add(point);
+
+        List<AddressEntity> allAddress = addressMapper.findAddress();
+        Point nowPoint = null;
+        List<AddressEntity> result = new ArrayList<>();
+        for (AddressEntity addressEntity : allAddress) {
+            nowPoint = new Point();
+            if(StringUtils.isEmpty(addressEntity.getLatitude()) || StringUtils.isEmpty(addressEntity.getLongitude())){
+                continue;
+            }
+
+            nowPoint.setLatitude(Double.valueOf(addressEntity.getLatitude()));
+            nowPoint.setLongitude(Double.valueOf(addressEntity.getLongitude()));
+
+            if(IsPtInPolyUtil.isPtInPoly(list, nowPoint)){
+                result.add(addressEntity);
+            }
+        }
+
+        return Result.success(result);
+    }
+}

+ 194 - 0
src/main/java/com/fdkankan/controller/FbxToObjController.java

@@ -0,0 +1,194 @@
+package com.fdkankan.controller;
+
+import com.fdkankan.util.FileUtils;
+import com.fdkankan.util.StreamGobbler;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.*;
+
+/**
+ * Created by Hb_zzZ on 2020/12/17.
+ */
+@Slf4j
+@RestController
+public class FbxToObjController {
+
+    @Value("${server.file.location}")
+    private String path;
+
+    /**
+     * 上传模型文件
+     * @param
+     * @return
+     */
+    @RequestMapping(value = "/fbxToObj")
+    public String fbxToObj(HttpServletRequest request){
+        String uuid = request.getParameter("uuid");
+        String fbx = request.getParameter("fbx");
+        String obj = request.getParameter("obj");
+        String jpg = request.getParameter("jpg");
+        String r = request.getParameter("r");
+
+        if(StringUtils.isEmpty(r)){
+            r = "30";
+        }
+        String filePath = path + uuid + File.separator;
+        FileUtils.deleteFile(filePath + obj);
+        log.info(("fbx转换obj开始"));
+//        String command = "hython C:\\user\\FbxMeshReduce.py -i " +  filePath + fbx + " -obj " + filePath + obj +
+//                " -oj " + filePath + "baker.jpg -r " + r;
+
+        String command = "hython C:\\user\\CombineFbxClass.py -i " +  filePath + fbx + " -obj " + filePath + obj +
+                " -oj " + filePath + "baker.jpg -r " + r;
+        callshell(command);
+        log.info(("fbx转换obj完毕:" + command));
+
+        log.info(("图片开始压缩"));
+        command = "python C:\\user\\compressImage\\CompressImage.cpython-39.pyc -i " + filePath + "baker.jpg -o " + filePath + jpg;
+        callshell(command);
+        log.info(("图片压缩完毕:" + command));
+        return "0";
+    }
+
+    /**
+     * 上传模型文件不烘焙图片
+     * @param
+     * @return
+     */
+    @RequestMapping(value = "/fbxToObjNoImg")
+    public String fbxToObjNoImg(HttpServletRequest request){
+        String uuid = request.getParameter("uuid");
+        String fbx = request.getParameter("fbx");
+        String obj = request.getParameter("obj");
+        String r = request.getParameter("r");
+
+        if(StringUtils.isEmpty(r)){
+            r = "30";
+        }
+        String filePath = path + uuid + File.separator;
+        FileUtils.deleteFile(filePath + obj);
+        log.info(("fbx转换obj开始"));
+        String command = "hython C:\\user\\FbxMeshReduce.py -i " +  filePath + fbx + " -obj " + filePath + obj +
+                " -r " + r + " -ba a ";
+        callshell(command);
+        log.info(("fbx转换obj完毕:" + command));
+        return "0";
+    }
+
+    /**
+     * 上传.max文件转成datasmith
+     * @param
+     * @return
+     */
+    @RequestMapping(value = "/maxToDatasmith")
+    public String maxToDatasmith(HttpServletRequest request){
+        String uuid = request.getParameter("uuid");
+        String max = request.getParameter("max");
+
+        String filePath = path + uuid;
+        String command = "hython C:\\Users\\Administrator\\Documents\\fbxTodatasmith\\DetachModel.py C:\\Users\\Administrator\\Documents\\fbxTodatasmith\\DetachModel.bat " + filePath + " " + filePath + File.separator + max;
+        log.info(("max转换datasmith开始: " + command));
+        callshell(command);
+        log.info(("max转换datasmith完毕:" + command));
+        return "0";
+    }
+
+    /**
+     * obj转成obj并进行压缩
+     * @param
+     * @return
+     */
+    @RequestMapping(value = "/objToObj")
+    public String objToObj(HttpServletRequest request) throws Exception{
+        String uuid = request.getParameter("uuid");
+        String inObj = request.getParameter("inObj");
+        String outObj = request.getParameter("outObj");
+        String r = request.getParameter("r");
+
+        String filePath = path + uuid + File.separator;
+
+        String command = "hython C:\\Users\\Administrator\\Documents\\user\\ReduceObjOnly.py -i " + filePath + inObj +
+                " -o " + filePath + outObj + " -r " + r;
+
+//        String faceTxt = r + "\n" + filePath + inObj + "\n" + filePath + outObj + "\n";
+//        FileUtils.writeFile(filePath + "face.txt", faceTxt);
+//        String maxPath = "";
+//        for (File file : new File(filePath).listFiles()) {
+//            if(file.getName().endsWith(".max")){
+//                maxPath = file.getAbsolutePath();
+//            }
+//        }
+//        String command = "python C:\\Users\\Administrator\\Documents\\fbxTodatasmith\\ReduceFace.py C:\\Users\\Administrator\\Documents\\fbxTodatasmith\\ReduceFace.bat " + maxPath;
+
+        log.info(("obj转换obj压缩开始: " + command));
+        callshell(command);
+        log.info(("obj转换obj压缩完毕:" + command));
+        return "0";
+    }
+
+    /**
+     * obj转成obj并进行压缩
+     * @param
+     * @return
+     */
+    @RequestMapping(value = "/objToObjPercentage")
+    public String objToObjPercentage(HttpServletRequest request) throws Exception{
+        String inObj = request.getParameter("inObj");
+        String outObj = request.getParameter("outObj");
+        String r = request.getParameter("r");
+
+//        String filePath = path + uuid + File.separator;
+
+        String command = "hython C:\\Users\\Administrator\\Documents\\user\\ReduceObjOnly_percent.py -i " + inObj +
+                " -o " + outObj + " -r " + r;
+
+        log.info(("obj转换obj百分比压缩开始: " + command));
+        callshell(command);
+        log.info(("obj转换obj百分比压缩完毕:" + command));
+        return "0";
+    }
+
+    @RequestMapping(value = "/testRun")
+    public String testRun(HttpServletRequest request){
+
+        return "isRunning";
+    }
+
+    public void runCmd(String strcmd) {
+        try {
+            Process process = Runtime.getRuntime().exec(strcmd);
+            InputStream in = process.getInputStream();
+            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(in));
+            String s = "1";
+            while ((s = bufferedReader.readLine()) != null) {
+                log.info("sss:" + s);
+            }
+            in.close();
+            bufferedReader.close();
+        } catch (IOException ioe) {
+            ioe.printStackTrace();
+        }
+    }
+
+
+    public void callshell(String command)
+    {
+        try {
+            Process process = Runtime.getRuntime().exec(command);
+
+            StreamGobbler errorGobbler = new StreamGobbler(process.getErrorStream(), "ERROR");
+            errorGobbler.start();
+            StreamGobbler outGobbler = new StreamGobbler(process.getInputStream(), "STDOUT");
+            outGobbler.start();
+            process.waitFor();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+}
+

+ 31 - 0
src/main/java/com/fdkankan/entity/AddressEntity.java

@@ -0,0 +1,31 @@
+package com.fdkankan.entity;
+
+import lombok.Data;
+
+import javax.persistence.Table;
+
+/**
+ * Created by Hb_zzZ on 2021/1/15.
+ */
+@Data
+@Table(name = "tb_address")
+public class AddressEntity {
+
+    private String id;
+
+    private String longitude;
+
+    private String latitude;
+
+    private String addressName;
+
+    private String standardAddress;
+
+    private String mainNumber;
+
+    private String auxiliaryNumber;
+
+    private String buildNumber;
+
+    private String buildUnits;
+}

+ 29 - 0
src/main/java/com/fdkankan/entity/HouseholdEntity.java

@@ -0,0 +1,29 @@
+package com.fdkankan.entity;
+
+import lombok.Data;
+
+import javax.persistence.Table;
+
+/**
+ * Created by Hb_zzZ on 2021/1/15.
+ */
+@Data
+@Table(name = "tb_household")
+public class HouseholdEntity {
+
+    private String id;
+
+    private String addressId;
+
+    private String name;
+
+    private String floor;
+
+    private String unit;
+
+    private String floorAbbreviation;
+
+    private String unitAbbreviation;
+
+    private String addressMsg;
+}

+ 56 - 0
src/main/java/com/fdkankan/mapper/IAddressMapper.java

@@ -0,0 +1,56 @@
+package com.fdkankan.mapper;
+
+import com.fdkankan.entity.AddressEntity;
+import com.fdkankan.entity.HouseholdEntity;
+import org.apache.ibatis.annotations.Insert;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created by Hb_zzZ on 2021/1/15.
+ */
+@Mapper
+public interface IAddressMapper {
+
+    @Insert("INSERT INTO tb_address (id, longitude, latitude, addressName, standardAddress," +
+            " mainNumber, auxiliaryNumber, buildNumber, buildUnits) values(#{id}, #{longitude}, " +
+            " #{latitude}, #{addressName}, #{standardAddress}, #{mainNumber}, #{auxiliaryNumber}, " +
+            " #{buildNumber}, #{buildUnits} )")
+    int saveAddress(AddressEntity addressEntity);
+
+    @Insert("INSERT INTO tb_household (id, addressId, name, floor, unit," +
+            " floorAbbreviation, unitAbbreviation, addressMsg) values(#{id}, #{addressId}, " +
+            " #{name}, #{floor}, #{unit}, #{floorAbbreviation}, #{unitAbbreviation}, " +
+            " #{addressMsg})")
+    int saveHousehold(HouseholdEntity householdEntity);
+
+    @Select("SELECT id, longitude, latitude  FROM tb_address")
+    List<Map<String, Object>> findAllAddress();
+
+    @Select("SELECT * FROM tb_address")
+    List<AddressEntity> findAddress();
+
+    @Select("SELECT * FROM tb_address where id = #{id}")
+    List<AddressEntity> findAddressById(String id);
+
+    @Select("SELECT * FROM tb_household")
+    List<HouseholdEntity> findAllHousehold();
+
+    @Select("SELECT * FROM tb_household where id = #{id}")
+    List<HouseholdEntity> findHouseholdById(String id);
+
+    @Select("SELECT DISTINCT NAME FROM tb_address")
+    List<String> findAllName();
+
+    @Select("SELECT DISTINCT buildNumber FROM tb_address WHERE NAME = #{name} AND buildNumber != '';")
+    List<String> findAllBuildNumberByName(String name);
+
+    @Select("SELECT a.* FROM `tb_household` a LEFT JOIN `tb_address` b ON a.addressId = b.`id` WHERE b.buildNumber = #{buildName}")
+    List<HouseholdEntity> findPageHouseByBuildNumber(String buildName);
+
+    @Select("SELECT MAX(a.floor + 0) FROM `tb_household` a LEFT JOIN `tb_address` b ON a.addressId = b.`id` WHERE b.buildNumber = #{buildName}")
+    Integer findMaxFloorHouseByBuildNumber(String buildName);
+}

+ 696 - 0
src/main/java/com/fdkankan/util/FileUtils.java

@@ -0,0 +1,696 @@
+package com.fdkankan.util;
+
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.util.ResourceUtils;
+import sun.misc.BASE64Decoder;
+
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLDecoder;
+import java.util.*;
+
+@Slf4j
+public class FileUtils {
+
+    //文件路径+名称
+    private static String fileNameTemp;
+
+    public static void uploadImg(String path, String base64Data)
+            throws Exception {
+        byte[] bt = null;
+        try {
+            BASE64Decoder decoder = new BASE64Decoder();
+            if (base64Data.startsWith("data:image/png;base64,")) {
+                bt = decoder.decodeBuffer(base64Data.replace("data:image/png;base64,", ""));
+            } else if (base64Data.startsWith("data:image/jpeg;base64,")) {
+                bt = decoder.decodeBuffer(base64Data.replace("data:image/jpeg;base64,", ""));
+            } else if (base64Data.startsWith("data:image/bmp;base64,")) {
+                bt = decoder.decodeBuffer(base64Data.replace("data:image/bmp;base64,", ""));
+            } else {
+                return;
+            }
+            writeBinary(bt, path);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    private static void writeBinary(byte[] buf, String filePath) throws Exception {
+        File fout = new File(filePath);
+        if (!fout.getParentFile().exists()) {
+            fout.getParentFile().mkdirs();
+        }
+        FileOutputStream fos = new FileOutputStream(fout);
+        ByteArrayInputStream stream = new ByteArrayInputStream(buf);
+        BufferedOutputStream bos = new BufferedOutputStream(fos);//设置输出路径
+        BufferedInputStream bis = new BufferedInputStream(stream);
+        int b = -1;
+        while ((b = bis.read()) != -1) {
+            bos.write(b);
+        }
+        bis.close();
+        bos.close();
+    }
+
+	public static boolean createDir(String destDirName) {
+        File dir = new File(destDirName);
+        if (dir.exists()) {
+            System.out.println("创建目录" + destDirName + "失败,目标目录已经存在");
+            return false;
+        }
+        if (!destDirName.endsWith(File.separator)) {
+            destDirName = destDirName + File.separator;
+        }
+        //创建目录
+        if (dir.mkdirs()) {
+            System.out.println("创建目录" + destDirName + "成功!");
+            return true;
+        } else {
+            System.out.println("创建目录" + destDirName + "失败!");
+            return false;
+        }
+    }
+
+
+    /**
+     * 创建文件
+     * @param fileName  文件名称
+     * @param fileContent   文件内容
+     * @return  是否创建成功,成功则返回true
+     */
+    public static boolean createFile(String path, String fileName,String fileContent){
+        Boolean bool = false;
+        fileNameTemp = path+fileName+".json";//文件路径+名称+文件类型
+        File file = new File(fileNameTemp);
+        try {
+        	File folder = new File(path);
+        	if (!folder.exists()){
+        		folder.mkdirs();
+        	}
+            //如果文件不存在,则创建新的文件
+            if(!file.exists()){
+                file.createNewFile();
+                bool = true;
+                System.out.println("success create file,the file is "+ fileNameTemp);
+                //创建文件成功后,写入内容到文件里
+                writeFileContent(fileNameTemp, fileContent);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return bool;
+    }
+
+    /**
+     * 向文件中写入内容
+     * @param filePath 文件路径与名称
+     * @param newstr  写入的内容
+     * @return
+     * @throws IOException
+     */
+    public static boolean writeFileContent(String filePath, String newstr) throws IOException{
+        Boolean bool = false;
+        String filein = newstr+"\r\n";//新写入的行,换行
+        String temp  = "";
+
+        FileInputStream fis = null;
+        InputStreamReader isr = null;
+        BufferedReader br = null;
+        FileOutputStream fos  = null;
+        PrintWriter pw = null;
+        try {
+            File file = new File(filePath);//文件路径(包括文件名称)
+            //将文件读入输入流
+            fis = new FileInputStream(file);
+            isr = new InputStreamReader(fis);
+            br = new BufferedReader(isr);
+            StringBuffer buffer = new StringBuffer();
+
+            //文件原有内容
+            for(int i=0;(temp =br.readLine())!=null;i++){
+                buffer.append(temp);
+                // 行与行之间的分隔符 相当于“\n”
+                buffer = buffer.append(System.getProperty("line.separator"));
+            }
+            buffer.append(filein);
+
+            fos = new FileOutputStream(file);
+            pw = new PrintWriter(fos);
+            pw.write(buffer.toString().toCharArray());
+            pw.flush();
+            bool = true;
+        } catch (Exception e) {
+            // TODO: handle exception
+            e.printStackTrace();
+        }finally {
+            //不要忘记关闭
+            if (pw != null) {
+                pw.close();
+            }
+            if (fos != null) {
+                fos.close();
+            }
+            if (br != null) {
+                br.close();
+            }
+            if (isr != null) {
+                isr.close();
+            }
+            if (fis != null) {
+                fis.close();
+            }
+        }
+        return bool;
+    }
+
+    /**
+     * 删除单个文件
+     *
+     * @param fileName
+     *            要删除的文件的文件名
+     * @return 单个文件删除成功返回true,否则返回false
+     */
+    public static boolean deleteFile(String fileName) {
+        File file = new File(fileName);
+        if (file.exists() && file.isFile()) {
+            if (file.delete()) {
+                return true;
+            } else {
+                return false;
+            }
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     *  根据路径删除指定的目录,无论存在与否
+     *@param sPath  要删除的目录path
+     *@return 删除成功返回 true,否则返回 false。
+     */
+    public static boolean deleteFolder(String sPath) {
+        boolean flag = false;
+        File file = new File(sPath);
+        // 判断目录或文件是否存在
+        if (!file.exists()) {  // 不存在返回 false
+            return flag;
+        } else {
+            // 判断是否为文件
+            if (file.isFile()) {  // 为文件时调用删除文件方法
+                return deleteFile(sPath);
+            } else {  // 为目录时调用删除目录方法
+                return deleteDirectory(sPath);
+            }
+        }
+    }
+
+    /**
+     * 删除目录以及目录下的文件
+     * @param   sPath 被删除目录的路径
+     * @return  目录删除成功返回true,否则返回false
+     */
+    public static boolean deleteDirectory(String sPath) {
+        //如果sPath不以文件分隔符结尾,自动添加文件分隔符
+        if (!sPath.endsWith(File.separator)) {
+            sPath = sPath + File.separator;
+        }
+        File dirFile = new File(sPath);
+        //如果dir对应的文件不存在,或者不是一个目录,则退出
+        if (!dirFile.exists() || !dirFile.isDirectory()) {
+            return false;
+        }
+        boolean flag = true;
+        //删除文件夹下的所有文件(包括子目录)
+        File[] files = dirFile.listFiles();
+        for (int i = 0; i < files.length; i++) {
+            //删除子文件
+            if (files[i].isFile()) {
+                flag = deleteFile(files[i].getAbsolutePath());
+                if (!flag) break;
+            } //删除子目录
+            else {
+                flag = deleteDirectory(files[i].getAbsolutePath());
+                if (!flag) break;
+            }
+        }
+        if (!flag) return false;
+        //删除当前目录
+        if (dirFile.delete()) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    //按行读文件
+    public static String readFile(String path) throws Exception {
+        File f = new File(path);
+        if (!f.exists()) {
+            return null;
+        }
+
+        ByteArrayOutputStream bos = new ByteArrayOutputStream((int) f.length());
+        BufferedInputStream in = null;
+        try {
+            in = new BufferedInputStream(new FileInputStream(f));
+            int buf_size = 1024;
+            byte[] buffer = new byte[buf_size];
+            int len = 0;
+            while (-1 != (len = in.read(buffer, 0, buf_size))) {
+                bos.write(buffer, 0, len);
+            }
+            return bos.toString();
+        } catch (IOException e) {
+            e.printStackTrace();
+            throw e;
+        } finally {
+            try {
+                in.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+            bos.close();
+        }
+    }
+
+    public static boolean copyFile(String srcFileName, String destFileName, boolean overlay) {
+        File srcFile = new File(srcFileName);
+        // 判断源文件是否存在
+        if (!srcFile.exists()) {
+            return false;
+        } else if (!srcFile.isFile()) {
+            return false;
+        }
+        // 判断目标文件是否存在
+        File destFile = new File(destFileName);
+        if (destFile.exists()) {
+            // 如果目标文件存在并允许覆盖
+            if (overlay) {
+                // 删除已经存在的目标文件,无论目标文件是目录还是单个文件
+                new File(destFileName).delete();
+            }
+        } else {
+            // 如果目标文件所在目录不存在,则创建目录
+            if (!destFile.getParentFile().exists()) {
+                // 目标文件所在目录不存在
+                if (!destFile.getParentFile().mkdirs()) {
+                    // 复制文件失败:创建目标文件所在目录失败
+                    return false;
+                }
+            }
+        }
+        // 复制文件
+        int byteread = 0; // 读取的字节数
+        InputStream in = null;
+        OutputStream out = null;
+        try {
+            in = new FileInputStream(srcFile);
+            out = new FileOutputStream(destFile);
+            byte[] buffer = new byte[1024];
+
+            while ((byteread = in.read(buffer)) != -1) {
+                out.write(buffer, 0, byteread);
+            }
+            return true;
+        } catch (IOException e) {
+            return false;
+        } finally {
+            try {
+                if (out != null)
+                    out.close();
+                if (in != null)
+                    in.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    /**
+     * 从网络Url中下载文件
+     *
+     * @param urlStr
+     * @param fileName
+     * @param savePath
+     * @return
+     * @throws IOException
+     */
+    public static boolean downLoadFromUrl(String urlStr, String fileName, String savePath){
+        FileOutputStream fos = null;
+        InputStream inputStream = null;
+        try {
+            URL url = new URL(urlStr);
+            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+            // 设置超时间为3秒
+            conn.setConnectTimeout(3 * 1000);
+            // 防止屏蔽程序抓取而返回403错误
+            conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
+
+            // 得到输入流
+            inputStream = conn.getInputStream();
+            // 获取自己数组
+            byte[] getData = readInputStream(inputStream);
+
+            // 文件保存位置
+            File saveDir = new File(savePath);
+            if (!saveDir.exists()) {
+                saveDir.mkdirs();
+            }
+            String filePath = saveDir + File.separator + fileName;
+            String filePathFolder = filePath.substring(0, filePath.lastIndexOf("/") + 1);
+            FileUtils.createDir(filePathFolder);
+
+            File file = new File(filePath);
+            fos = new FileOutputStream(file);
+            fos.write(getData);
+            if (fos != null) {
+                fos.close();
+            }
+            if (inputStream != null) {
+                inputStream.close();
+            }
+            System.out.println("info:" + url + " download success");
+        } catch(FileNotFoundException e){
+            return false;
+        } catch (IOException e) {
+            return false;
+        }finally {
+            if (fos != null) {
+                try {
+                    fos.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            if (inputStream != null) {
+                try {
+                    inputStream.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return true;
+    }
+
+    /**
+     * 从输入流中获取字节数组
+     *
+     * @param inputStream
+     * @return
+     * @throws IOException
+     */
+    private static byte[] readInputStream(InputStream inputStream) throws IOException {
+        byte[] buffer = new byte[1024];
+        int len = 0;
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        while ((len = inputStream.read(buffer)) != -1) {
+            bos.write(buffer, 0, len);
+        }
+        bos.close();
+        return bos.toByteArray();
+    }
+
+    public static void writeFile(String filePath,String str) throws IOException {
+        File fout = new File(filePath);
+        if(!fout.getParentFile().exists()){
+            fout.getParentFile().mkdirs();
+        }
+        if(!fout.exists()){
+            fout.createNewFile();
+        }
+        FileOutputStream fos = new FileOutputStream(fout);
+        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos));
+        bw.write(str);
+        bw.close();
+    }
+
+    /**
+     * 将byte数组写入文件
+     *
+     * @param path
+     * @param fileName
+     * @param content
+     * @throws IOException
+     */
+    public static void writeFile(String path, String fileName, byte[] content)
+            throws IOException {
+        try {
+            File f = new File(path);
+            if (!f.exists()) {
+                f.mkdirs();
+            }
+            FileOutputStream fos = new FileOutputStream(path + fileName);
+            fos.write(content);
+            fos.close();
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    /**
+     * 向json文件写入参数,重复的覆盖,多的新增
+     * @return
+     */
+    public static void writeJsonFile(String path, Map<String, Object> map) throws Exception{
+        String str = readFile(path);
+        JSONObject json = new JSONObject();
+        if(str!=null){
+            json = JSONObject.parseObject(str);
+        }
+        else{
+            File file = new File(path);
+            if(!file.getParentFile().exists())
+            {
+                file.getParentFile().mkdirs();
+            }
+            if(!file.exists())
+            {
+                file.createNewFile();
+            }
+        }
+        Iterator entries = map.entrySet().iterator();
+        while (entries.hasNext()) {
+            Map.Entry entry = (Map.Entry) entries.next();
+            json.put(String.valueOf(entry.getKey()), entry.getValue());
+        }
+
+        writeFile(path, json.toString());
+    }
+
+
+    //删除文件夹
+    public static void delFolder(String folderPath) {
+        try {
+            delAllFile(folderPath); //删除完里面所有内容
+            String filePath = folderPath;
+            filePath = filePath.toString();
+            File myFilePath = new File(filePath);
+            myFilePath.delete(); //删除空文件夹
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    //删除指定文件夹下的所有文件
+    public static boolean delAllFile(String path) {
+        boolean flag = false;
+        File file = new File(path);
+        if (!file.exists()) {
+            return flag;
+        }
+        if (!file.isDirectory()) {
+            return flag;
+        }
+        String[] tempList = file.list();
+        File temp = null;
+        if(tempList!=null)
+        {
+            for (int i = 0; i < tempList.length; i++) {
+                if (path.endsWith(File.separator)) {
+                    temp = new File(path + tempList[i]);
+                } else {
+                    temp = new File(path + File.separator + tempList[i]);
+                }
+                if (temp.isFile()) {
+                    temp.delete();
+                }
+                if (temp.isDirectory()) {
+                    delAllFile(path + "/" + tempList[i]);//先删除文件夹里面的文件
+                    delFolder(path + "/" + tempList[i]);//再删除空文件夹
+                    flag = true;
+                }
+            }
+        }
+
+        //再删除当前空文件夹
+        file.delete();
+        return flag;
+    }
+
+    public static List<String> readfileNamesForDirectory(String path, String except)
+    {
+        try{
+            File file = new File(path);
+            if(file.isDirectory())
+            {
+                String[] fileNames = file.list();
+                List<String> list = new ArrayList<String>();
+                if(fileNames!=null)
+                {
+                    for(int i=0;i<fileNames.length;++i)
+                    {
+                        if(fileNames[i].toLowerCase().endsWith(except) )
+                        {
+                            list.add(fileNames[i]);
+                        }
+                    }
+                }
+
+                return list;
+            }
+        }catch(Exception e){
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    //递归获取文件中所有文件的路径
+    public static List<String> readfilePath(String path, List<String> urlList) {
+        try{
+            File file = new File(path);
+            if(file != null && file.isDirectory()) {
+                File[] files = file.listFiles();
+
+                if(files != null) {
+                    for(int i=0;i<files.length;++i) {
+                        if(files[i].isDirectory()){
+                            readfilePath(files[i].getAbsolutePath(), urlList);
+                        }else {
+                            urlList.add(files[i].getAbsolutePath());
+                        }
+                    }
+                }
+                return urlList;
+            }
+        }catch(Exception e){
+            e.printStackTrace();
+        }
+        return urlList;
+    }
+
+    public static void saveImageToDisk(String accessToken, String mediaId, String picName, String picPath,InputStream inputStream)
+            throws Exception {
+        byte[] data = new byte[10240];
+        int len = 0;
+        FileOutputStream fileOutputStream = null;
+        try {
+            fileOutputStream = new FileOutputStream(picPath+picName+".amr");
+            while ((len = inputStream.read(data)) != -1) {
+                fileOutputStream.write(data, 0, len);
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            if (inputStream != null) {
+                try {
+                    inputStream.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            if (fileOutputStream != null) {
+                try {
+                    fileOutputStream.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
+
+
+    /**
+     *
+     * @param content base64内容
+     * @param path 输出文件路径,需要后缀名
+     * @return
+     */
+    public static  boolean base64ToFileWriter(String content, String path) {
+        if (content == null) {
+            return false;
+        }
+        BASE64Decoder decoder = new BASE64Decoder();
+        try {
+            // decoder
+            byte[] b = decoder.decodeBuffer(content);
+            // processing data
+            for (int i = 0; i < b.length; ++i) {
+                if (b[i] < 0) {
+                    b[i] += 256;
+                }
+            }
+            OutputStream out = new FileOutputStream(path);
+            out.write(b);
+            out.flush();
+            out.close();
+            return true;
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
+    /**
+     * 获取类路径(classes路径)
+     */
+    public static String getResource(){
+        String path = "";
+        try {
+            path = ResourceUtils.getURL("classpath:").getPath();
+            path = URLDecoder.decode(path,"utf-8");
+        } catch (Exception e) {
+        }
+        return path;
+    }
+
+    /**
+     * 判断文件大小处于限制内
+     *
+     * @param fileLen 文件长度
+     * @param fileSize 限制大小
+     * @param fileUnit 限制的单位(B,K,M,G)
+     * @return
+     */
+    public static boolean checkFileSizeIsLimit(Long fileLen, double fileSize, String fileUnit) {
+//        long len = file.length();
+        double fileSizeCom = 0;
+        if ("B".equals(fileUnit.toUpperCase())) {
+            fileSizeCom = (double) fileLen;
+        } else if ("K".equals(fileUnit.toUpperCase())) {
+            fileSizeCom = (double) fileLen / 1024;
+        } else if ("M".equals(fileUnit.toUpperCase())) {
+            fileSizeCom = (double) fileLen / (1024*1024);
+        } else if ("G".equals(fileUnit.toUpperCase())) {
+            fileSizeCom = (double) fileLen / (1024*1024*1024);
+        }
+        if (fileSizeCom > fileSize) {
+            return false;
+        }
+        return true;
+
+    }
+
+
+    public static void main(String[] args) {
+//        File f = new File("F:\\桌面\\vr-t-2KZ4MQv");
+//        for(File f1 : f.listFiles()){
+//            f1.renameTo(new File(f1.getAbsolutePath().replace(".png", ".jpg")));
+//        }
+        System.out.println(System.currentTimeMillis());
+    }
+
+}

+ 30 - 0
src/main/java/com/fdkankan/util/IsPtInPolyUtil.java

@@ -0,0 +1,30 @@
+package com.fdkankan.util;
+
+import java.util.List;
+
+/**
+ * Created by Hb_zzZ on 2021/1/21.
+ */
+public class IsPtInPolyUtil{
+
+    public static boolean isPtInPoly(List<Point> list, Point point){
+
+        boolean inside = false;
+
+        double longitude = point.getLongitude();
+        double latitude = point.getLatitude();
+
+        for (int i = 0, j = list.size() - 1; i < list.size(); j = i++) {
+            double longitudeI = list.get(i).getLongitude();
+            double latitudeI = list.get(i).getLatitude();
+            double longitudeJ = list.get(j).getLongitude();
+            double latitudeJ = list.get(j).getLatitude();
+
+            if (((latitudeI > latitude) != (latitudeJ > latitude)) &&
+                    (longitude <= (longitudeJ - longitudeI) * (latitude - latitudeI) / (latitudeJ - latitudeI) + longitudeI)) {
+                inside = !inside;
+            }
+        }
+        return inside;
+    }
+}

+ 14 - 0
src/main/java/com/fdkankan/util/Point.java

@@ -0,0 +1,14 @@
+package com.fdkankan.util;
+
+import lombok.Data;
+
+/**
+ * Created by Hb_zzZ on 2021/1/21.
+ */
+@Data
+public class Point {
+
+    private double longitude;
+
+    private double latitude;
+}

+ 101 - 0
src/main/java/com/fdkankan/util/Result.java

@@ -0,0 +1,101 @@
+package com.fdkankan.util;
+
+//import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * 通用返回类
+ *
+ * @author
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class Result<T> implements Serializable {
+    private static final long serialVersionUID = -1491499610244557029L;
+    public static final String SUCCESS_MSG = "操作成功";
+    public static int CODE_SUCCESS = 0;
+    public static int CODE_FAILURE = -1;
+    public static String[] NOOP = new String[]{};
+
+    /**
+     * 处理状态:0: 成功, 1: 失败
+     */
+//    @ApiModelProperty(value = "处理状态:0: 成功, 1: 失败", name = "code")
+    private int code;
+    /**
+     * 消息
+     */
+//    @ApiModelProperty(value = "消息", name = "msg")
+    private String msg;
+    /**
+     * 返回数据
+     */
+//    @ApiModelProperty(value = "返回数据", name = "data")
+    private T data;
+    /**
+     * 处理成功,并返回数据
+     *
+     * @param data 数据对象
+     * @return data
+     */
+    public static Result success(Object data) {
+        return new Result(CODE_SUCCESS, SUCCESS_MSG, data);
+    }
+    /**
+     * 处理成功
+     *
+     * @return data
+     */
+    public static Result success() {
+        return new Result(CODE_SUCCESS, SUCCESS_MSG, NOOP);
+    }
+    /**
+     * 处理成功
+     *
+     * @param msg 消息
+     * @return data
+     */
+    public static Result success(String msg) {
+        return new Result(CODE_SUCCESS, msg, NOOP);
+    }
+    /**
+     * 处理成功
+     *
+     * @param msg  消息
+     * @param data 数据对象
+     * @return data
+     */
+    public static Result success(String msg, Object data) {
+        return new Result(CODE_SUCCESS, msg, data);
+    }
+    /**
+     * 处理失败,并返回数据(一般为错误信息)
+     *
+     * @param code 错误代码
+     * @param msg  消息
+     * @return data
+     */
+    public static Result failure(int code, String msg) {
+        return new Result(code, msg, NOOP);
+    }
+    /**
+     * 处理失败
+     *
+     * @param msg 消息
+     * @return data
+     */
+    public static Result failure(String msg) {
+        return failure(CODE_FAILURE, msg);
+    }
+
+    @Override
+    public String toString() {
+        return "JsonResult [code=" + code + ", msg=" + msg + ", data="
+                + data + "]";
+    }
+}

+ 61 - 0
src/main/java/com/fdkankan/util/StreamGobbler.java

@@ -0,0 +1,61 @@
+package com.fdkankan.util;
+
+import java.io.*;
+
+public class StreamGobbler extends Thread {
+
+	InputStream is;  
+    String type;  
+    OutputStream os;  
+
+    public StreamGobbler(InputStream is, String type) {  
+        this(is, type, null);  
+    }  
+
+    StreamGobbler(InputStream is, String type, OutputStream redirect) {  
+        this.is = is;  
+        this.type = type;  
+        this.os = redirect;  
+    }  
+
+    public void run() {  
+        InputStreamReader isr = null;  
+        BufferedReader br = null;  
+        PrintWriter pw = null;  
+        try {  
+            if (os != null)  
+                pw = new PrintWriter(os);  
+
+            isr = new InputStreamReader(is);  
+            br = new BufferedReader(isr);  
+            String line=null;  
+            while ( (line = br.readLine()) != null) {  
+                if (pw != null)  
+                    pw.println(line);  
+                System.out.println(type + ">" + line);      
+            }  
+
+            if (pw != null)  
+                pw.flush();  
+        } catch (IOException ioe) {  
+            ioe.printStackTrace();    
+        } finally{  
+            try {  
+            	if(pw!=null)
+            	{
+            		 pw.close();  
+            	}
+            	if(br!=null)
+            	{
+            		br.close();  
+            	}
+            	if(isr!=null)
+            	{
+            		isr.close();  
+            	}
+            } catch (IOException e) {  
+                e.printStackTrace();  
+            }  
+        }  
+    }  
+}

+ 12 - 0
src/main/resources/application.properties

@@ -0,0 +1,12 @@
+server.port=8080
+
+server.file.location=Z:\\OneKeyDecorate\\upload\\
+
+spring.mvc.async.request-timeout=600000
+
+spring.datasource.url=jdbc:mysql://192.168.0.47:3306/change_clothes?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
+spring.datasource.username=root
+spring.datasource.password=123123
+spring.datasource.driverClassName=com.mysql.jdbc.Driver
+
+logging.level.com.fdkankan=debug

+ 13 - 0
src/test/java/com/fdkankan/FbxToObjApplicationTests.java

@@ -0,0 +1,13 @@
+package com.fdkankan;
+
+//import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class FbxToObjApplicationTests {
+
+//	@Test
+	void contextLoads() {
+	}
+
+}