ソースを参照

1.文件上传、下载、预览功能后端,车辆维修等实绩功能后端

zhangym 2 年 前
コミット
681b0bc8dd

+ 167 - 0
src/main/java/com/steerinfo/dil/controller/SystemFileController.java

@@ -0,0 +1,167 @@
+package com.steerinfo.dil.controller;
+
+import com.steerinfo.dil.util.FtpFileUtil;
+import com.steerinfo.dil.util.IDutils;
+import com.steerinfo.framework.controller.BaseRESTfulController;
+import com.steerinfo.framework.controller.RESTfulResult;
+import com.steerinfo.framework.service.pagehelper.PageList;
+import com.steerinfo.framework.utils.collection.ListUtils;
+import com.steerinfo.dil.model.SystemFile;
+import com.steerinfo.dil.service.ISystemFileService;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.math.BigDecimal;
+
+/**
+ * SystemFile RESTful接口:
+ *
+ * @author generator
+ * @version 1.0-SNAPSHORT 2023-10-30 09:19
+ * 类描述
+ * 修订历史:
+ * 日期:2023-10-30
+ * 作者:generator
+ * 参考:
+ * 描述:SystemFile RESTful接口
+ * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
+ * @see null
+ */
+@RestController
+@RequestMapping("/${api.version}/systemfiles")
+public class SystemFileController extends BaseRESTfulController {
+
+    @Autowired
+    ISystemFileService systemFileService;
+
+    @Autowired
+    private FtpFileUtil ftpFileUtil;
+
+    @PostMapping("/insertFile")
+    public RESTfulResult insertFile(String alternateFields1, @ModelAttribute MultipartFile[] file) {
+        String filenames = "";
+        for (int i = 0; i < file.length; i++) {
+            filenames += file[i].getOriginalFilename() + ";";
+        }
+        String filesid = "";
+        if (file != null) {
+            for (int i = 0; i < file.length; i++) {
+                try {
+
+                    //获取系统时间
+                    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("/yyyy/MM/dd");
+                    //获取文件名
+                    String oldName = file[i].getOriginalFilename();
+                    //取当前时间的长整形值包含毫秒
+                    String newName = IDutils.getImageName();
+                    //重新命名文件
+                    newName = newName + oldName.substring(oldName.lastIndexOf("."));
+                    String filePath = simpleDateFormat.format(new Date());
+                    //获取输入流
+                    InputStream inputStream = file[i].getInputStream();
+                    boolean result = ftpFileUtil.uploadToFtp(inputStream, filePath, newName, false);
+                    inputStream.close();
+                    if (result) {
+                        SystemFile uploadFile = new SystemFile();
+                        uploadFile.setFilename(oldName);
+                        uploadFile.setFilepath(filePath + "/" + newName);
+                        uploadFile.setId(alternateFields1);
+                        SystemFile modela = systemFileService.add(uploadFile);
+                        if (modela != null) {
+                            filesid += "," + modela.getId();
+                        }
+                    } else {
+                        return failed(null, "上传文件失败");
+                    }
+                } catch (Exception e) {
+                    e.getMessage();
+                }
+            }
+            return success(filesid);
+
+        } else {
+            return failed();
+        }
+
+    }
+
+    @PostMapping("/previewfile")
+    public RESTfulResult previewfile(@RequestBody HashMap parmas) {
+        String filename = parmas.get("filename").toString();
+        String filepath = parmas.get("filepath").toString();
+        if (filename == null ||filename.isEmpty()) {
+            return failed("该图片不存在!");
+        }
+        if (filepath == null ||filepath.isEmpty()) {
+            return failed("该图片地址不存在!");
+        }
+        try {
+            String result = ftpFileUtil.downloadFile(filename, filepath);
+            return success(result);
+        } catch (IOException e) {
+            e.getMessage();
+            return failed();
+        }
+
+    }
+
+
+    @PostMapping("/updateFile")
+    public RESTfulResult updateFile(String alternateFields1, @ModelAttribute MultipartFile[] file) {
+        systemFileService.delete(alternateFields1);
+        String filenames = "";
+        for (int i = 0; i < file.length; i++) {
+            filenames += file[i].getOriginalFilename() + ";";
+        }
+        String filesid = "";
+        if (file != null) {
+            for (int i = 0; i < file.length; i++) {
+                try {
+
+                    //获取系统时间
+                    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("/yyyy/MM/dd");
+                    //获取文件名
+                    String oldName = file[i].getOriginalFilename();
+                    //取当前时间的长整形值包含毫秒
+                    String newName = IDutils.getImageName();
+                    //重新命名文件
+                    newName = newName + oldName.substring(oldName.lastIndexOf("."));
+                    String filePath = simpleDateFormat.format(new Date());
+                    //获取输入流
+                    InputStream inputStream = file[i].getInputStream();
+                    boolean result = ftpFileUtil.uploadToFtp(inputStream, filePath, newName, false);
+                    inputStream.close();
+                    if (result) {
+                        SystemFile uploadFile = new SystemFile();
+                        uploadFile.setFilename(oldName);
+                        uploadFile.setFilepath(filePath + "/" + newName);
+                        uploadFile.setId(alternateFields1);
+                        SystemFile modela = systemFileService.add(uploadFile);
+                        if (modela != null) {
+                            filesid += "," + modela.getId();
+                        }
+                    } else {
+                        return failed(null, "上传文件失败");
+                    }
+                } catch (Exception e) {
+                    e.getMessage();
+                }
+            }
+            return success(filesid);
+
+        } else {
+            return failed();
+        }
+
+    }
+}

+ 49 - 0
src/main/java/com/steerinfo/dil/controller/TMSController.java

@@ -1,6 +1,7 @@
 package com.steerinfo.dil.controller;
 
 
+import com.steerinfo.dil.annotaion.LogAround;
 import com.steerinfo.dil.feign.TmsFeign;
 import com.steerinfo.dil.mapper.UniversalMapper;
 import com.steerinfo.dil.util.BaseRESTfulController;
@@ -13,6 +14,9 @@ import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.math.BigDecimal;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -28,6 +32,51 @@ import java.util.concurrent.Callable;
 public class TMSController extends BaseRESTfulController {
     @Autowired
     private TmsFeign tmsFeign;
+    @ApiOperation(value = "车辆实绩")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "map", value = "参数", required = false, dataType = "map"),
+            @ApiImplicitParam(name = "apiId()", value = "动态表头", required = false, dataType = "Integer"),
+            @ApiImplicitParam(name = "pageNum", value = "页码", required = false, dataType = "Integer"),
+            @ApiImplicitParam(name = "pageSize", value = "页", required = false, dataType = "Integer"),
+    })
+    @PostMapping(value = "/getcomprehensiveresults")
+    public Map<String, Object> getecomprehensiveresultslist(@RequestBody(required = false) Map<String, Object> map, Integer apiId,
+                                               Integer pageNum,
+                                               Integer pageSize) {
+        return tmsFeign.getAmsSalaryContracList(map == null ? new HashMap<>() : map, apiId, pageNum, pageSize);
+    }
+    @ApiOperation(value="新增车辆实绩")
+    @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
+    @LogAround(foreignKeys = {"resultId"},foreignKeyTypes = {"计算公式"})
+    @PostMapping("/addcomprehensiveresults")
+    public  Map<String, Object> insertcomprehensiveresults(@RequestBody(required = false) Map<String, Object> map) throws ParseException {
+        if (!map.isEmpty()) {
+            if (!map.get("resultTime").toString().isEmpty()) {
+                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+                Date resultTime = simpleDateFormat.parse(map.get("resultTime").toString());
+                map.put("resultTime", resultTime);
+            }
+        }
+        map.put("insertUsername",  map.get("userName").toString());
+        return  tmsFeign.insertAmsSalaryContrac(map);
+    }
+
+    @ApiOperation(value="车辆实绩删除")
+    @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
+    @PutMapping(value = "/comprehensiveresultslogicdelete")
+    @LogAround(foreignKeys = {"resultId"},foreignKeyTypes = {"计算公式"})
+    public Map<String, Object> comprehensiveresultsLogicDelete(@RequestBody(required = false) Map<String, Object> map){
+        return tmsFeign.logicdeleteAmsSaalryContrac(map);
+    }
+
+    @ApiOperation(value="修改车辆实绩")
+    @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
+    @PutMapping(value = "/comprehensiveresultsupadete/{id}")
+    @LogAround(foreignKeys = {"resultId"},foreignKeyTypes = {"计算公式"})
+    public Map<String, Object> comprehensiveresultsUpdate(@PathVariable BigDecimal id,@RequestBody(required = false) Map<String, Object> map){
+        map.put("updateUsername", map.get("userName").toString());
+        return tmsFeign.updateAmsSalaryContrac(id,map);
+    }
 
 
 }

+ 15 - 0
src/main/java/com/steerinfo/dil/feign/TmsFeign.java

@@ -840,6 +840,21 @@ public interface TmsFeign {
 
     @PostMapping("/api/v1/truckTms/statisticalReport/yawnReport")
     Map<String, Object> yawnReport(@RequestBody(required = false) Map<String, Object> map);
+
+    //======================>车辆综合实绩
+    @PostMapping("api/v1/tms/tmscomprehensiveresults/gettmscomprehensiveresult")
+    Map<String, Object> getAmsSalaryContracList(@RequestBody(required = false) Map<String, Object> map,@RequestParam  Integer apiId,
+                                                @RequestParam  Integer pageNum,
+                                                @RequestParam  Integer pageSize);
+
+    @PostMapping("api/v1/tms/tmscomprehensiveresults/add")
+    Map<String, Object> insertAmsSalaryContrac(@RequestBody(required = false) Map<String, Object> map);
+
+    @PutMapping("api/v1/tms/tmscomprehensiveresults/{id}")
+    Map<String, Object> updateAmsSalaryContrac(@PathVariable BigDecimal id,@RequestBody(required = false) Map<String, Object> map);
+
+    @PutMapping("api/v1/tms/tmscomprehensiveresults/logicdelete")
+    Map<String, Object> logicdeleteAmsSaalryContrac(@RequestBody(required = false) Map<String, Object> map);
 }
 
 

+ 12 - 0
src/main/java/com/steerinfo/dil/mapper/SystemFileMapper.java

@@ -0,0 +1,12 @@
+package com.steerinfo.dil.mapper;
+
+import com.steerinfo.dil.model.SystemFile;
+import com.steerinfo.framework.mapper.IBaseMapper;
+import java.math.*;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface SystemFileMapper extends IBaseMapper<SystemFile, String> {
+
+    SystemFile insertAll(SystemFile systemFile);
+}

+ 57 - 0
src/main/java/com/steerinfo/dil/model/SystemFile.java

@@ -0,0 +1,57 @@
+package com.steerinfo.dil.model;
+
+import com.steerinfo.framework.model.IBasePO;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+@ApiModel(value="null")
+public class SystemFile implements IBasePO<String> {
+    @ApiModelProperty(value="",required=true)
+    private String id;
+
+    @ApiModelProperty(value="",required=false)
+    private String filename;
+
+    @ApiModelProperty(value="",required=false)
+    private String filepath;
+
+    private static final long serialVersionUID = 1L;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id == null ? null : id.trim();
+    }
+
+    public String getFilename() {
+        return filename;
+    }
+
+    public void setFilename(String filename) {
+        this.filename = filename == null ? null : filename.trim();
+    }
+
+    public String getFilepath() {
+        return filepath;
+    }
+
+    public void setFilepath(String filepath) {
+        this.filepath = filepath == null ? null : filepath.trim();
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", id=").append(id);
+        sb.append(", filename=").append(filename);
+        sb.append(", filepath=").append(filepath);
+        sb.append(", serialVersionUID=").append(serialVersionUID);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 27 - 0
src/main/java/com/steerinfo/dil/service/ISystemFileService.java

@@ -0,0 +1,27 @@
+package com.steerinfo.dil.service;
+
+import com.steerinfo.framework.service.IBaseService;
+import com.steerinfo.dil.model.SystemFile;
+import io.swagger.models.auth.In;
+
+import java.util.Date;
+import java.math.BigDecimal;
+
+/**
+ * SystemFile服务接口:
+ * @author generator
+ * @version 1.0-SNAPSHORT 2023-10-30 09:19
+ * 类描述
+ * 修订历史:
+ * 日期:2023-10-30
+ * 作者:generator
+ * 参考:
+ * 描述:SystemFile服务接口
+ * @see null
+ * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
+ */
+public interface ISystemFileService extends IBaseService<SystemFile, String>{
+
+    SystemFile insertFile(SystemFile systemFile);
+
+}

+ 47 - 0
src/main/java/com/steerinfo/dil/service/impl/SystemFileServiceImpl.java

@@ -0,0 +1,47 @@
+package com.steerinfo.dil.service.impl;
+
+import com.steerinfo.framework.mapper.IBaseMapper;
+import com.steerinfo.framework.service.impl.BaseServiceImpl;
+import com.steerinfo.dil.model.SystemFile;
+import com.steerinfo.dil.mapper.SystemFileMapper;
+import com.steerinfo.dil.service.ISystemFileService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import java.util.Date;
+import java.math.BigDecimal;
+
+/**
+ * SystemFile服务实现:
+ * @author generator
+ * @version 1.0-SNAPSHORT 2023-10-30 09:19
+ * 类描述
+ * 修订历史:
+ * 日期:2023-10-30
+ * 作者:generator
+ * 参考:
+ * 描述:SystemFile服务实现
+ * @see null
+ * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
+ */
+@Service(value = "systemFileService")
+public class SystemFileServiceImpl extends BaseServiceImpl<SystemFile, String> implements ISystemFileService {
+
+    @Autowired
+    private SystemFileMapper systemFileMapper;
+
+    @Override
+    protected IBaseMapper<SystemFile, String> getMapper() {
+        return systemFileMapper;
+    }
+
+    @Override
+    public SystemFile insertFile(SystemFile systemFile) {
+        SystemFile s = systemFileMapper.insertAll(systemFile);
+        if (s!=null){
+            return s;
+        }else {
+            return null;
+        }
+
+    }
+}

+ 481 - 0
src/main/java/com/steerinfo/dil/util/FtpFileUtil.java

@@ -0,0 +1,481 @@
+package com.steerinfo.dil.util;
+
+import com.steerinfo.framework.utils.io.IOUtils;
+import com.steerinfo.framework.utils.text.Charsets;
+import org.apache.commons.net.ftp.*;
+import org.springframework.stereotype.Component;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.util.Base64;
+
+/**
+ * POIExcelToHtml 文件转换:
+ *
+ * @author generator
+ * @version 1.0-SNAPSHOT 2021-08-09 18:06
+ * 类描述
+ * 修订历史:
+ * 日期:2021-08-09
+ * 作者:shadow
+ * 参考:
+ * 描述:
+ * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
+ * @see null
+ */
+@Component
+public class FtpFileUtil {
+    /**
+     * ftp服务器ip地址
+     */
+
+    // String FTP_ADDRESS;
+    private String FTP_ADDRESS = "172.16.90.238";
+
+    /**
+     * 端口号
+     */
+
+    //Integer FTP_PORT;
+    private Integer FTP_PORT = 21;
+    /**
+     * 用户名
+     */
+
+    private String FTP_USERNAME = "ftptest";
+    /**
+     * 密码
+     */
+
+    private String FTP_PASSWORD = "at286315";
+
+    private FTPClient ftpClient = new FTPClient();
+    private static final String SPOT = ".";
+
+    /**
+     * 上传文件
+     *
+     * @param filePath    文件路径
+     * @param filename    文件名称
+     * @param basePath    上级目录
+     * @param inputStream 文件输入流
+     * @return 是否成功
+     */
+    public boolean uploadFile(String filePath, String filename, String basePath, InputStream inputStream) {
+        boolean result = false;
+        try {
+            // 连接FTP服务器
+            ftpClient.connect(FTP_ADDRESS, FTP_PORT);
+            ftpClient.login(FTP_USERNAME, FTP_PASSWORD);
+            int reply;
+            ftpClient.enterLocalPassiveMode();
+            reply = ftpClient.getReplyCode();
+            if (!FTPReply.isPositiveCompletion(reply)) {
+                ftpClient.disconnect();
+                return false;
+            }
+            //切换到上传目录
+            boolean changed = ftpClient.changeWorkingDirectory(filePath);
+            if (!changed) {
+                //如果目录不存在创建目录
+                String[] dirs = filePath.split("/");
+                String tempPath = basePath;
+                for (String dir : dirs) {
+                    if (null == dir || "".equals(dir)) {
+                        continue;
+                    }
+                    tempPath += "/" + dir;
+                    if (!ftpClient.makeDirectory(tempPath)) {
+                        return false;
+                    } else {
+                        ftpClient.changeWorkingDirectory(tempPath);
+                    }
+                }
+            }
+            System.out.println("当前目录" + ftpClient.printWorkingDirectory());
+            //设置为被动模式
+
+            //设置上传文件的类型为二进制类型
+            ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
+            //上传文件
+            if (!ftpClient.storeFile(filename, inputStream)) {
+                System.out.println("上传文件失败");
+                return false;
+            }
+            ftpClient.logout();
+            result = true;
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            if (ftpClient.isConnected()) {
+                try {
+                    inputStream.close();
+                    ftpClient.disconnect();
+                } catch (IOException ioe) {
+                    ioe.printStackTrace();
+                }
+            }
+        }
+        return result;
+    }
+
+    /***
+     * 上传
+     * @param buffIn 文件流
+     * @param filePath 文件路径
+     * @param fileName 文件名称
+     * @param needDelete 是否删除
+     * @return 是否成功
+     * @throws FTPConnectionClosedException ftp错误
+     * @throws IOException io流错误
+     * @throws Exception 普通错误
+     */
+    public boolean uploadToFtp(InputStream buffIn, String filePath, String fileName, boolean needDelete)
+            throws FTPConnectionClosedException, IOException, Exception {
+        boolean result;
+        try {
+            //建立连接
+            this.connectToServer();
+            ftpClient.changeWorkingDirectory("/");
+            this.setFileType(FTP.BINARY_FILE_TYPE);
+            int reply = ftpClient.getReplyCode();
+            if (!FTPReply.isPositiveCompletion(reply)) {
+                ftpClient.disconnect();
+                throw new IOException("failed to connect to the FTP Server:" + FTP_ADDRESS);
+            }
+            //进入文件目录
+            boolean changeWork = ftpClient.changeWorkingDirectory(filePath);
+            if (!changeWork) {
+                if (!createDirectory(filePath)) {
+                    return false;
+                }
+            }
+            result = ftpClient.storeFile(fileName, buffIn);
+            if (needDelete) {
+                ftpClient.deleteFile(fileName);
+            }
+            // 输出操作结果信息
+            if (result) {
+                System.out.println("uploadToFtp INFO: upload file  to ftp : succeed!");
+            } else {
+                System.out.println("uploadToFtp INFO: upload file  to ftp : failed!");
+            }
+        } catch (FTPConnectionClosedException e) {
+            System.out.println("ftp连接被关闭!");
+            throw e;
+        } catch (Exception e) {
+            System.out.println("ERR : upload file  to ftp : failed! ");
+            throw e;
+        } finally {
+            try {
+                if (buffIn != null) {
+                    buffIn.close();
+                }
+            } catch (Exception e) {
+                System.out.println("ftp关闭输入流时失败!");
+            }
+            if (ftpClient.isConnected()) {
+                closeConnect();
+            }
+        }
+        return result;
+    }
+
+    /***
+     * 预览
+     * @param fileName 文件名
+     * @param filePath 文件路径
+     * @return 返回HTML
+     * @throws IOException io流错误
+     */
+    public String downloadFile(String fileName, String filePath) throws IOException {
+        InputStream inputStream;
+        String data = fileName + "预览失败";
+        String workhtml = null;
+        File temp = File.createTempFile("temp", ".temp");
+        try {
+            this.connectToServer();
+            // 设置传输二进制文件
+            this.setFileType(FTP.BINARY_FILE_TYPE);
+            ftpClient.enterLocalPassiveMode();
+            int reply = ftpClient.getReplyCode();
+            if (!FTPReply.isPositiveCompletion(reply)) {
+                ftpClient.disconnect();
+                throw new IOException("failed to connect to the FTP Server:" + FTP_ADDRESS);
+            }
+
+            String directory = filePath.substring(0, filePath.lastIndexOf("/") + 1);
+            // 进入文件所在目录,注意编码格式,以能够正确识别中文目录
+            boolean cdStatus = ftpClient.changeWorkingDirectory(directory);
+            if (!cdStatus) {
+                return data;
+            }
+            String file = filePath.substring(filePath.lastIndexOf("/") + 1);
+            // 检验文件是否存在
+            inputStream = ftpClient.retrieveFileStream(file);
+
+            String suffixName;
+            if (inputStream != null) {
+                if (fileName != null && fileName.contains(SPOT)) {
+                    POIWordToHtml poiWordToHtml = new POIWordToHtml();
+                    suffixName = fileName.substring(fileName.indexOf(".") + 1);
+                    switch (suffixName) {
+                        case "docx":
+                            data = poiWordToHtml.readWordImgToHtml(inputStream);
+                            break;
+                        case "doc":
+                            data = poiWordToHtml.docToHtml(inputStream);
+                            break;
+
+                        case "xlsx":
+                        case "xls":
+                            data = POIExcelToHtml.excelToHtml(inputStream);
+                            break;
+                        case "pptx":
+                        case "ppt":
+                            data = POIPptToHtml.pptToHtml(inputStream, suffixName);
+                            break;
+                        case "jpg":
+                        case "gif":
+                        case "png":
+                        case "jpeg":
+                        case "jpe":
+                            ByteArrayOutputStream stream = new ByteArrayOutputStream();
+                            IOUtils.copy(inputStream, stream);
+                            String imgStr = Base64.getEncoder().encodeToString(stream.toByteArray());
+                            data = "<img style='width:100%' src=" + "\"data:image/" + suffixName + ";base64," + imgStr + "\"" + "/>";
+                            stream.close();
+                            break;
+                        case "txt":
+                            ByteArrayOutputStream txtStream = new ByteArrayOutputStream();
+                            IOUtils.copy(inputStream, txtStream);
+                            data = txtStream.toString();
+                            break;
+                        default:
+                            data = fileName + "文件暂时不支持预览。";
+                            break;
+                    }
+                }
+                inputStream.close();
+                ftpClient.completePendingCommand();
+            }
+        } catch (FTPConnectionClosedException e) {
+            System.out.println("ftp连接被关闭!");
+            throw e;
+        } catch (Exception e) {
+            System.out.println("ERR : upload file " + fileName + " from ftp : failed!" + e.getMessage());
+        } finally {
+            if (ftpClient.isConnected()) {
+                closeConnect();
+            }
+        }
+        return data;
+    }
+
+    /**
+     * 下载
+     *
+     * @param response 响应头
+     * @param fileName 文件名
+     * @param filePath 文件路径
+     * @return 返回下载是否成功
+     */
+    public boolean download(HttpServletResponse response, String fileName, String filePath) {
+        boolean flag = false;
+        try {
+            this.connectToServer();
+            // 设置传输二进制文件
+            this.setFileType(FTP.BINARY_FILE_TYPE);
+            this.ftpClient.enterLocalPassiveMode();
+            int reply = ftpClient.getReplyCode();
+            if (!FTPReply.isPositiveCompletion(reply)) {
+                ftpClient.disconnect();
+                throw new IOException("failed to connect to the FTP Server:" + FTP_ADDRESS);
+            }
+            String transferName = new String(fileName.getBytes(Charsets.UTF_8), Charsets.ISO_8859_1);
+            String directory = filePath.substring(0, filePath.lastIndexOf("/") + 1);
+            String file = filePath.substring(filePath.lastIndexOf("/") + 1);
+            // 进入文件所在目录,注意编码格式,以能够正确识别中文目录
+            ftpClient.changeWorkingDirectory(directory);
+            response.setCharacterEncoding("UTF-8");
+            response.setContentType("multipart/form-data;charset=UTF-8");
+            response.setHeader("Content-Disposition", "attachment; filename=\"" + transferName + "\"");
+            FTPFile[] fs = ftpClient.listFiles();
+            for (FTPFile ff : fs) {
+                if (ff.getName().equals(file)) {
+                    OutputStream os = response.getOutputStream();
+                    flag = ftpClient.retrieveFile(ff.getName(), os);
+                    os.flush();
+                    os.close();
+                    break;
+                }
+            }
+            closeConnect();
+
+        } catch (FTPConnectionClosedException ignored) {
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return flag;
+    }
+
+    /**
+     * 下载返回流
+     *
+     * @param fileName 文件名称
+     * @param filePath 文件路径
+     * @return 返回是否成功
+     */
+    public ByteArrayOutputStream download(String fileName, String filePath) {
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        try {
+            this.connectToServer();
+            // 设置传输二进制文件
+            this.setFileType(FTP.BINARY_FILE_TYPE);
+            ftpClient.enterLocalPassiveMode();
+            int reply = ftpClient.getReplyCode();
+            if (!FTPReply.isPositiveCompletion(reply)) {
+                ftpClient.disconnect();
+                throw new IOException("failed to connect to the FTP Server:" + FTP_ADDRESS);
+            }
+            String directory = filePath.substring(0, filePath.lastIndexOf("/") + 1);
+            String file = filePath.substring(filePath.lastIndexOf("/") + 1);
+            // 进入文件所在目录,注意编码格式,以能够正确识别中文目录
+            ftpClient.changeWorkingDirectory(directory);
+            FTPFile[] fs = ftpClient.listFiles();
+            for (FTPFile ff : fs) {
+                if (ff.getName().equals(file)) {
+                    os.close();
+                    break;
+                }
+            }
+            closeConnect();
+        } catch (FTPConnectionClosedException ignored) {
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return os;
+    }
+
+    public boolean deleteFile(String filePath) throws Exception {
+        boolean result;
+        try {
+            //建立连接
+            this.connectToServer();
+            ftpClient.changeWorkingDirectory("/");
+            this.setFileType(FTP.BINARY_FILE_TYPE);
+            int reply = ftpClient.getReplyCode();
+            if (!FTPReply.isPositiveCompletion(reply)) {
+                ftpClient.disconnect();
+                throw new IOException("failed to connect to the FTP Server:" + FTP_ADDRESS);
+            }
+            String directory = filePath.substring(0, filePath.lastIndexOf("/") + 1);
+            String fileName = filePath.substring(filePath.lastIndexOf("/") + 1);
+            //进入文件目录
+            boolean changeWork = ftpClient.changeWorkingDirectory(directory);
+            if (!changeWork) {
+                return false;
+            }
+            result = ftpClient.deleteFile(fileName);
+        } catch (FTPConnectionClosedException e) {
+            System.out.println("ftp连接被关闭!");
+            throw e;
+        } catch (Exception e) {
+            System.out.println("ERR : delete file  to ftp : failed! ");
+            throw e;
+        } finally {
+            if (ftpClient.isConnected()) {
+                closeConnect();
+            }
+        }
+        return result;
+    }
+
+    /***
+     * 建立连接
+     * @throws FTPConnectionClosedException ftp错误
+     * @throws Exception 普通错误
+     */
+    private void connectToServer() throws FTPConnectionClosedException, Exception {
+        if (!ftpClient.isConnected()) {
+            int reply;
+            try {
+                //建立连接
+                ftpClient = new FTPClient();
+                //ftpClient.setControlEncoding("GBK");//windows default服务器gbk
+                ftpClient.setControlEncoding("UTF-8");//linux default UTF-8
+                ftpClient.connect(FTP_ADDRESS, FTP_PORT);
+                ftpClient.login(FTP_USERNAME, FTP_PASSWORD);
+                ftpClient.enterLocalPassiveMode();
+                reply = ftpClient.getReplyCode();
+                if (!FTPReply.isPositiveCompletion(reply)) {
+                    ftpClient.disconnect();
+                    System.out.println("connectToServer FTP server refused connection.");
+                }
+            } catch (FTPConnectionClosedException ex) {
+                System.out.println("没有连接数!there are too many connected users,please try later");
+                throw ex;
+            } catch (Exception e) {
+                System.out.println("登录ftp服务器失败");
+                throw e;
+            }
+        }
+    }
+
+    /**
+     * 设置传输文件类型
+     *
+     * @param fileType 文件类型
+     */
+    private void setFileType(int fileType) {
+        try {
+            ftpClient.setFileType(fileType);
+        } catch (Exception e) {
+            System.out.println("ftp设置传输文件的类型时失败!");
+
+        }
+    }
+
+    /**
+     * 关闭连接
+     */
+    public void closeConnect() {
+        try {
+            if (ftpClient != null) {
+                ftpClient.logout();
+                ftpClient.disconnect();
+            }
+        } catch (Exception e) {
+            System.out.println("ftp连接关闭失败!");
+        }
+    }
+
+    /**
+     * 创建文件夹
+     */
+    public boolean createDirectory(String directory) {
+        try {
+            ftpClient.changeWorkingDirectory("/");
+            String[] dirs = directory.split("/");
+            String tempPath = "";
+            for (String dir : dirs) {
+                if (null == dir || "".equals(dir)) {
+                    continue;
+                }
+                tempPath += "/" + dir;
+                if (!ftpClient.makeDirectory(tempPath)) {
+                    if (!ftpClient.changeWorkingDirectory(tempPath)) {
+                        return false;
+                    }
+                } else {
+                    ftpClient.changeWorkingDirectory(tempPath);
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return true;
+    }
+}

+ 18 - 0
src/main/java/com/steerinfo/dil/util/IDutils.java

@@ -0,0 +1,18 @@
+package com.steerinfo.dil.util;
+
+import java.util.Random;
+
+public class IDutils {
+    public static String getImageName() {
+        //取当前时间的长整形值包含毫秒
+        long millis = System.currentTimeMillis();
+        //long millis = System.nanoTime();
+        //加上三位随机数
+        Random random = new Random();
+        int end3 = random.nextInt(999);
+        //如果不足三位前面补0
+        String str = millis + String.format("%03d", end3);
+
+        return str;
+    }
+}

+ 424 - 0
src/main/java/com/steerinfo/dil/util/POIExcelToHtml.java

@@ -0,0 +1,424 @@
+package com.steerinfo.dil.util;
+
+import org.apache.poi.hssf.usermodel.*;
+import org.apache.poi.hssf.util.HSSFColor;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.usermodel.XSSFCellStyle;
+import org.apache.poi.xssf.usermodel.XSSFColor;
+import org.apache.poi.xssf.usermodel.XSSFFont;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.DecimalFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * POIExcelToHtml 文件转换:
+ * @author generator
+ * @version 1.0-SNAPSHORT 2021-08-09 18:06
+ * 类描述
+ * 修订历史:
+ * 日期:2021-08-09
+ * 作者:shadow
+ * 参考:
+ * 描述:Execl转HTML
+ * @see null
+ * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
+ */
+public class POIExcelToHtml {
+
+	public static String excelToHtml(InputStream is) {
+
+		String htmlExcel = "预览文件失败";
+		try {
+			Workbook wb = WorkbookFactory.create(is);
+			if (wb instanceof XSSFWorkbook) {
+				XSSFWorkbook xWb = (XSSFWorkbook) wb;
+				htmlExcel = POIExcelToHtml.getExcelInfo(xWb);
+			} else if (wb instanceof HSSFWorkbook) {
+				HSSFWorkbook hWb = (HSSFWorkbook) wb;
+				htmlExcel = POIExcelToHtml.getExcelInfo(hWb);
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		} finally {
+			try {
+				is.close();
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+		return htmlExcel;
+	}
+
+	private static String getExcelInfo(Workbook wb) {
+		StringBuffer sb = new StringBuffer();
+		int sheetCounts = wb.getNumberOfSheets();
+		// sb.append("<!DOCTYPE html> <html> <head> <meta charset='utf-8'
+		// /><title>HTML实例</title></head> ");
+
+		for (int i = 0; i < sheetCounts; i++) {
+			Sheet sheet = wb.getSheetAt(i);// 获取第一个Sheet的内容
+			int lastRowNum = sheet.getLastRowNum();
+			Map<String, String> map[] = getRowSpanColSpanMap(sheet);
+			// sb.append("<br><br>");
+			sb.append(sheet.getSheetName());
+			sb.append("<table style='border-collapse:collapse;' width='100%'>");
+			Row row = null; // 兼容
+			Cell cell = null; // 兼容
+			for (int rowNum = sheet.getFirstRowNum(); rowNum <= lastRowNum; rowNum++) {
+				row = sheet.getRow(rowNum);
+				if (row == null) {
+					sb.append("<tr><td > &nbsp;</td></tr>");
+					continue;
+				}
+				sb.append("<tr>");
+				int lastColNum = row.getLastCellNum();
+				for (int colNum = 0; colNum < lastColNum; colNum++) {
+					cell = row.getCell(colNum);
+					if (cell == null) { // 特殊情况 空白的单元格会返回null
+						sb.append("<td>&nbsp;</td>");
+						continue;
+					}
+
+					String stringValue = getCellValue(cell);//````````````
+					if (map[0].containsKey(rowNum + "," + colNum)) {
+						String pointString = map[0].get(rowNum + "," + colNum);
+						map[0].remove(rowNum + "," + colNum);
+						int bottomeRow = Integer.valueOf(pointString.split(",")[0]);
+						int bottomeCol = Integer.valueOf(pointString.split(",")[1]);
+						int rowSpan = bottomeRow - rowNum + 1;
+						int colSpan = bottomeCol - colNum + 1;
+						sb.append("<td rowspan= '" + rowSpan + "' colspan= '" + colSpan + "' ");
+					} else if (map[1].containsKey(rowNum + "," + colNum)) {
+						map[1].remove(rowNum + "," + colNum);
+						continue;
+					} else {
+						sb.append("<td ");
+					}
+
+					dealExcelStyle(wb, sheet, cell, sb);// 处理单元格样式
+					sb.append(">");
+					if (stringValue == null || "".equals(stringValue.trim())) {
+						sb.append(" &nbsp; ");
+					} else {
+						// 将ascii码为160的空格转换为html下的空格(&nbsp;)
+						sb.append(stringValue.replace(String.valueOf((char) 160), "&nbsp;"));
+					}
+					sb.append("</td>");
+				}
+				sb.append("</tr>");
+			}
+			sb.append("</table>");
+		}
+
+		// sb.append("</body></html> ");
+		return sb.toString();
+	}
+
+	private static Map<String, String>[] getRowSpanColSpanMap(Sheet sheet) {
+		Map<String, String> map0 = new HashMap<String, String>();
+		Map<String, String> map1 = new HashMap<String, String>();
+		int mergedNum = sheet.getNumMergedRegions();
+		CellRangeAddress range = null;
+		for (int i = 0; i < mergedNum; i++) {
+			range = sheet.getMergedRegion(i);
+			int topRow = range.getFirstRow();
+			int topCol = range.getFirstColumn();
+			int bottomRow = range.getLastRow();
+			int bottomCol = range.getLastColumn();
+			map0.put(topRow + "," + topCol, bottomRow + "," + bottomCol);
+			// System.out.println(topRow + "," + topCol + "," + bottomRow + ","
+			// + bottomCol);
+			int tempRow = topRow;
+			while (tempRow <= bottomRow) {
+				int tempCol = topCol;
+				while (tempCol <= bottomCol) {
+					map1.put(tempRow + "," + tempCol, "");
+					tempCol++;
+				}
+				tempRow++;
+			}
+			map1.remove(topRow + "," + topCol);
+		}
+		Map[] map = { map0, map1 };
+		return map;
+	}
+
+	/**
+	 * 200 * 获取表格单元格Cell内容 201 * @param cell 202 * @return 203
+	 */
+	private static String getCellValue(Cell cell) {
+		String result = new String();
+		switch (cell.getCellType()) {
+			case Cell.CELL_TYPE_NUMERIC:// 数字类型
+				if (HSSFDateUtil.isCellDateFormatted(cell)) {// 处理日期格式、时间格式
+					SimpleDateFormat sdf = null;
+					if (cell.getCellStyle().getDataFormat() == HSSFDataFormat.getBuiltinFormat("hh:mm")) {
+						sdf = new SimpleDateFormat("HH:mm");
+					} else if (cell.getCellStyle().getDataFormat() == HSSFDataFormat
+							.getBuiltinFormat("yyyy-MM-dd HH:mm:ss")) {// 日期
+						sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+					} else {
+						sdf = new SimpleDateFormat("yyyy-MM-dd");
+					}
+					Date date = cell.getDateCellValue();
+					result = sdf.format(date);
+				} else if (cell.getCellStyle().getDataFormat() == 58) {
+					// 处理自定义日期格式:m月d日(通过判断单元格的格式id解决,id的值是58)
+					SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+					double value = cell.getNumericCellValue();
+					Date date = DateUtil.getJavaDate(value);
+					result = sdf.format(date);
+				} else {
+					double value = cell.getNumericCellValue();
+					CellStyle style = cell.getCellStyle();
+					DecimalFormat format = new DecimalFormat();
+					String temp = style.getDataFormatString();
+					// 单元格设置成常规
+					if (temp.equals("General")) {
+						format.applyPattern("#");
+					}
+					result = format.format(value);
+				}
+				break;
+			case Cell.CELL_TYPE_STRING:// String类型
+				result = cell.getRichStringCellValue().toString();
+				break;
+			case Cell.CELL_TYPE_BLANK:
+				result = "";
+				break;
+			default:
+				result = "";
+				break;
+		}
+		return result;
+	}
+
+	/**
+	 * 251 * 处理表格样式 252 * @param wb 253 * @param sheet 254 * @param cell 255
+	 * * @param sb 256
+	 */
+	private static void dealExcelStyle(Workbook wb, Sheet sheet, Cell cell, StringBuffer sb) {
+
+		CellStyle cellStyle = cell.getCellStyle();
+		if (cellStyle != null) {
+			//short alignment = cellStyle.getAlignment();旧写法获取枚举数字;新写法获取枚举
+
+			sb.append("align='" + convertAlignToHtml(cellStyle.getAlignmentEnum()) + "' ");// 单元格内容的水平对齐方式
+			//short verticalAlignment = cellStyle.getVerticalAlignment();
+			//short verticalAlignment = cellStyle.getVerticalAlignmentEnum().getCode();
+			sb.append("valign='" + convertVerticalAlignToHtml(cellStyle.getVerticalAlignmentEnum()) + "' ");// 单元格中内容的垂直排列方式
+
+			if (wb instanceof XSSFWorkbook) {
+				XSSFFont xf = ((XSSFCellStyle) cellStyle).getFont();
+				Boolean boldWeight = xf.getBold();
+				//short boldWeight = xf.getBoldweight();
+				String fontfamily = xf.getFontName();
+				int underline = xf.getUnderline();
+				boolean Italic = xf.getItalic();
+
+				sb.append("style='");
+				if (underline >= 1) {
+					sb.append("text-decoration:underline;"); // 字体型号
+				}
+				if (Italic) {
+					sb.append("font-style: italic;"); // 字体型号
+				}
+				sb.append("font-family:" + fontfamily + ";"); // 字体型号
+				sb.append("font-weight:" + (boldWeight ? "bold" : "100") + ";"); // 字体加粗
+				sb.append("font-size: " + xf.getFontHeight() / 2 + "%;"); // 字体大小
+				int columnWidth = sheet.getColumnWidth(cell.getColumnIndex());
+				sb.append("width:" + columnWidth + "px;");
+
+				XSSFColor xc = xf.getXSSFColor();
+				if (xc != null && !"".equals(xc)) {
+					sb.append("color:#" + xc.getARGBHex().substring(2) + ";"); // 字体颜色
+				}
+
+				XSSFColor bgColor = (XSSFColor) cellStyle.getFillForegroundColorColor();
+				if (bgColor != null && !"".equals(bgColor)) {
+					sb.append("background-color:#" + bgColor.getARGBHex().substring(2) + ";"); // 背景颜色
+				}
+				sb.append(getBorderStyle(0, cellStyle.getBorderTop(),
+						((XSSFCellStyle) cellStyle).getTopBorderXSSFColor()));
+				sb.append(getBorderStyle(1, cellStyle.getBorderRight(),
+						((XSSFCellStyle) cellStyle).getRightBorderXSSFColor()));
+				sb.append(getBorderStyle(2, cellStyle.getBorderBottom(),
+						((XSSFCellStyle) cellStyle).getBottomBorderXSSFColor()));
+				sb.append(getBorderStyle(3, cellStyle.getBorderLeft(),
+						((XSSFCellStyle) cellStyle).getLeftBorderXSSFColor()));
+
+			} else if (wb instanceof HSSFWorkbook) {
+
+				HSSFFont hf = ((HSSFCellStyle) cellStyle).getFont(wb);
+				short fontColor = hf.getColor();
+				Boolean boldWeight = hf.getBold();
+				//short boldWeight = hf.getBoldweight();
+				String fontfamily = hf.getFontName();
+				int underline = hf.getUnderline();
+				boolean Italic = hf.getItalic();
+
+				sb.append("style='");
+				if (underline >= 1) {
+					// 字体型号
+					sb.append("text-decoration:underline;");
+				}
+				if (Italic) {
+					// 字体型号
+					sb.append("font-style: italic;");
+				}
+				// 类HSSFPalette用于求的颜色的国际标准形式
+				HSSFPalette palette = ((HSSFWorkbook) wb).getCustomPalette();
+				HSSFColor hc = palette.getColor(fontColor);
+				// 字体加粗
+				sb.append("font-weight:" + (boldWeight ? "bold" : "100") + ";");
+				// 字体型号
+				sb.append("font-family:" + fontfamily + ";");
+				// 字体大小
+				sb.append("font-size: " + hf.getFontHeight() / 2 + "%;");
+				String fontColorStr = convertToStardColor(hc);
+				// 字体颜色
+				if (fontColorStr != null && !"".equals(fontColorStr.trim())) {
+					sb.append("color:" + fontColorStr + ";");
+				}
+				int columnWidth = sheet.getColumnWidth(cell.getColumnIndex());
+				sb.append("width:" + columnWidth + "px;");
+				short bgColor = cellStyle.getFillForegroundColor();
+				//short bgColor = cellStyle.getFillBackgroundColor();
+				hc = palette.getColor(bgColor);
+				String bgColorStr = convertToStardColor(hc);
+				if (bgColorStr != null && !"".equals(bgColorStr.trim())) {
+					// 背景颜色
+					sb.append("background-color:" + bgColorStr + ";");
+				}
+				/**
+				 * 旧版本 cellStyle.getBorderTop()
+				 * 新版本 cellStyle.getBorderTopEnum()
+				 */
+				sb.append(getBorderStyle(palette, 0, cellStyle.getBorderTop(), cellStyle.getTopBorderColor()));
+				sb.append(getBorderStyle(palette, 1, cellStyle.getBorderRight(), cellStyle.getRightBorderColor()));
+				sb.append(getBorderStyle(palette, 3, cellStyle.getBorderLeft(), cellStyle.getLeftBorderColor()));
+				sb.append(getBorderStyle(palette, 2, cellStyle.getBorderBottom(), cellStyle.getBottomBorderColor()));
+			}
+
+			sb.append("' ");
+		}
+	}
+
+	/**
+	 * 330 * 单元格内容的水平对齐方式 331 * @param alignment 332 * @return 333
+	 * @param alignment
+	 */
+	private static String convertAlignToHtml( HorizontalAlignment alignment) {
+
+		String align = "left";
+		/**
+		 * CellStyle.ALIGN_CENTER:旧写法
+		 * HorizontalAlignment.LEFT:新写法
+		 */
+		switch (alignment) {
+			case LEFT:
+				align = "left";
+				break;
+			case CENTER:
+				align = "center";
+				break;
+			case RIGHT:
+				align = "right";
+				break;
+			default:
+				break;
+		}
+		return align;
+	}
+
+	/**
+	 * 354 * 单元格中内容的垂直排列方式 355 * @param verticalAlignment 356 * @return 357
+	 * @param verticalAlignment
+	 */
+	private static String convertVerticalAlignToHtml(VerticalAlignment verticalAlignment) {
+
+		/**
+		 * 旧写法CellStyle.VERTICAL_BOTTOM:
+		 * 新写法VerticalAlignment.BOTTOM:
+		 */
+		String valign = "middle";
+		switch (verticalAlignment) {
+			case BOTTOM:
+				valign = "bottom";
+				break;
+			case CENTER:
+				valign = "center";
+				break;
+			case TOP:
+				valign = "top";
+				break;
+			default:
+				break;
+		}
+		return valign;
+	}
+
+	private static String convertToStardColor(HSSFColor hc) {
+
+		/**
+		 * 颜色定义变化
+		 * 旧版本 : HSSFColor.BLACK.index
+		 * 新版本 : IndexedColors.BLACK.index
+		 */
+		StringBuffer sb = new StringBuffer("");
+		if (hc != null) {
+			if (IndexedColors.AUTOMATIC.index == hc.getIndex()) {
+				return null;
+			}
+			sb.append("#");
+			for (int i = 0; i < hc.getTriplet().length; i++) {
+				sb.append(fillWithZero(Integer.toHexString(hc.getTriplet()[i])));
+			}
+		}
+
+		return sb.toString();
+	}
+
+	private static String fillWithZero(String str) {
+		if (str != null && str.length() < 2) {
+			return "0" + str;
+		}
+		return str;
+	}
+
+	static String[] bordesr = { "border-top:", "border-right:", "border-bottom:", "border-left:" };
+	static String[] borderStyles = { "solid ", "solid ", "solid ", "solid ", "solid ", "solid ", "solid ", "solid ",
+			"solid ", "solid", "solid", "solid", "solid", "solid" };
+
+	private static String getBorderStyle(HSSFPalette palette, int b, short s, short t) {
+		if (s == 0) {
+			return bordesr[b] + borderStyles[s] + "#d0d7e5 1px;";
+		}
+		String borderColorStr = convertToStardColor(palette.getColor(t));
+		borderColorStr = borderColorStr == null || borderColorStr.length() < 1 ? "#000000" : borderColorStr;
+		return bordesr[b] + borderStyles[s] + borderColorStr + " 1px;";
+
+	}
+
+	private static String getBorderStyle(int b, short s, XSSFColor xc) {
+		if (s == 0) {
+			return bordesr[b] + borderStyles[s] + "#d0d7e5 1px;";
+		}
+		if (xc != null && !"".equals(xc)) {
+			// t.getARGBHex();
+			String borderColorStr = xc.getARGBHex();
+			borderColorStr = borderColorStr == null || borderColorStr.length() < 1 ? "#000000"
+					: borderColorStr.substring(2);
+			return bordesr[b] + borderStyles[s] + borderColorStr + " 1px;";
+		}
+		return "";
+	}
+
+}

+ 155 - 0
src/main/java/com/steerinfo/dil/util/POIPptToHtml.java

@@ -0,0 +1,155 @@
+package com.steerinfo.dil.util;
+
+import org.apache.poi.hslf.usermodel.*;
+import org.apache.poi.xslf.usermodel.*;
+
+import javax.imageio.ImageIO;
+import java.awt.*;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Base64;
+
+/**
+ *
+ * @author ruand http://blog.csdn.net/emoven/article/details/52683215
+ */
+public class POIPptToHtml {
+
+	private final static String PPT = "ppt";
+	private final static String PPTX = "pptx";
+
+	public static String pptToHtml(InputStream is, String type) {
+		String htmlStr = "预览失败";
+		try {
+				if (PPT.equals(type)) {
+					 htmlStr = toImage2003(is);
+				} else if (PPTX.equals(type)) {
+					 htmlStr = toImage2007(is);
+				} else {
+					htmlStr = "the file is not a ppt";
+				}
+
+			} catch (Exception e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+		return htmlStr;
+	}
+
+	public static String toImage2007(InputStream is) throws Exception {
+		String htmlStr = "预览失败";
+		XMLSlideShow ppt = new XMLSlideShow(is);
+		is.close();
+		Dimension pgsize = ppt.getPageSize();
+		System.out.println(pgsize.width + "--" + pgsize.height);
+
+		StringBuffer sb = new StringBuffer();
+		for (int i = 0; i < ppt.getSlides().size(); i++) {
+			try {
+				// 防止中文乱码
+				for (XSLFShape shape : ppt.getSlides().get(i).getShapes()) {
+					if (shape instanceof XSLFTextShape) {
+						XSLFTextShape tsh = (XSLFTextShape) shape;
+						for (XSLFTextParagraph p : tsh) {
+							for (XSLFTextRun r : p) {
+								r.setFontFamily("宋体");
+							}
+						}
+					}
+				}
+				BufferedImage img = new BufferedImage(pgsize.width, pgsize.height, BufferedImage.TYPE_INT_RGB);
+				Graphics2D graphics = img.createGraphics();
+				// clear the drawing area
+				graphics.setPaint(Color.white);
+				graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width, pgsize.height));
+				// render
+				ppt.getSlides().get(i).draw(graphics);
+				ByteArrayOutputStream stream = new ByteArrayOutputStream();
+				ImageIO.write(img, "png", stream);
+				String imgStr = Base64.getEncoder().encodeToString(stream.toByteArray());
+				// save the output
+				sb.append("<br>");
+				sb.append("<img src=" + "\"data:image/png;base64," + imgStr + "\"" + "/>");
+				stream.close();
+			} catch (Exception e) {
+				System.out.println("第" + i + "张ppt转换出错");
+			}
+		}
+		System.out.println("success");
+		htmlStr = sb.toString();
+
+		return htmlStr;
+	}
+
+	public static String toImage2003(InputStream is) {
+		String htmlStr = "预览失败";
+		try {
+			HSLFSlideShow ppt = new HSLFSlideShow(is);
+			Dimension pgsize = ppt.getPageSize();
+			StringBuffer sb = new StringBuffer();
+			for (int i = 0; i < ppt.getSlides().size(); i++) {
+				// 防止中文乱码
+				for (HSLFShape shape : ppt.getSlides().get(i).getShapes()) {
+					if (shape instanceof HSLFTextShape) {
+						HSLFTextShape tsh = (HSLFTextShape) shape;
+						for (HSLFTextParagraph p : tsh) {
+							for (HSLFTextRun r : p) {
+								r.setFontFamily("宋体");
+							}
+						}
+					}
+				}
+				BufferedImage img = new BufferedImage(pgsize.width, pgsize.height, BufferedImage.TYPE_INT_RGB);
+				Graphics2D graphics = img.createGraphics();
+				// clear the drawing area
+				graphics.setPaint(Color.white);
+				graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width, pgsize.height));
+				// render
+				ppt.getSlides().get(i).draw(graphics);
+				ByteArrayOutputStream stream = new ByteArrayOutputStream();
+				//String imageDir = targetDir + "/" + pptFileName + "/";
+				//FileUtils.createDir(imageDir);// create image dir
+				//String imagePath = imageDir + pptFileName + "-" + (i + 1) + ".png";
+				ImageIO.write(img, "png", stream);
+				String imgStr = Base64.getEncoder().encodeToString(stream.toByteArray());
+				sb.append("<br>");
+				sb.append("<img src=" + "\"data:image/png;base64," + imgStr + "\"" + "/>");
+				stream.close();
+
+			}
+			System.out.println("success");
+			htmlStr = sb.toString();
+		} catch (Exception e) {
+
+		}
+		return htmlStr;
+	}
+
+	/***
+	 * 功能 :调整图片大小
+	 *
+	 * @param srcImgPath
+	 *            原图片路径
+	 * @param distImgPath
+	 *            转换大小后图片路径
+	 * @param width
+	 *            转换后图片宽度
+	 * @param height
+	 *            转换后图片高度
+	 */
+	public static void resizeImage(String srcImgPath, String distImgPath, int width, int height) throws IOException {
+
+		File srcFile = new File(srcImgPath);
+		Image srcImg = ImageIO.read(srcFile);
+		BufferedImage buffImg = null;
+		buffImg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+		buffImg.getGraphics().drawImage(srcImg.getScaledInstance(width, height, Image.SCALE_SMOOTH), 0, 0, null);
+
+		ImageIO.write(buffImg, "JPEG", new File(distImgPath));
+
+	}
+}

+ 320 - 0
src/main/java/com/steerinfo/dil/util/POIWordToHtml.java

@@ -0,0 +1,320 @@
+package com.steerinfo.dil.util;
+
+import fr.opensagres.poi.xwpf.converter.xhtml.Base64EmbedImgManager;
+import fr.opensagres.poi.xwpf.converter.xhtml.XHTMLConverter;
+import fr.opensagres.poi.xwpf.converter.xhtml.XHTMLOptions;
+import org.apache.poi.hwpf.HWPFDocumentCore;
+import org.apache.poi.hwpf.converter.WordToHtmlConverter;
+import org.apache.poi.hwpf.converter.WordToHtmlUtils;
+import org.apache.poi.hwpf.usermodel.Picture;
+import org.apache.poi.xwpf.usermodel.*;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDecimalNumber;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import java.io.*;
+import java.math.BigInteger;
+import java.util.Base64;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * POIExcelToHtml 文件转换:
+ *
+ * @author generator
+ * @version 1.0-SNAPSHORT 2021-08-09 18:06
+ * 类描述
+ * 修订历史:
+ * 日期:2021-08-09
+ * 作者:shadow
+ * 参考:https://blog.csdn.net/u013585096/article/details/85104888
+ * 描述:Execl转HTML
+ * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
+ * @see null
+ */
+public class POIWordToHtml {
+    private static final String ENCODING = "GB2312";// UTF-8
+
+
+    public String docToHtml(InputStream input) throws Exception {
+        String htmlData = "预览失败";
+        try {
+        HWPFDocumentCore wordDocument = WordToHtmlUtils.loadDoc(input);
+        WordToHtmlConverter wordToHtmlConverter = new ImageConverter(
+                DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument()
+        );
+        //wordToHtmlConverter.setPicturesManager(new PicturesManager() {
+        //    @Override
+        //    public String savePicture(byte[] content,
+        //                              PictureType pictureType, String suggestedName,
+        //                              float widthInches, float heightInches) {
+        //            //给生成的页面写图片的路径
+        //            return "word/media/" + suggestedName;
+        //    }
+        //});
+        wordToHtmlConverter.processDocument(wordDocument);
+        Document htmlDocument = wordToHtmlConverter.getDocument();
+        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+        DOMSource domSource = new DOMSource(htmlDocument);
+        StreamResult streamResult = new StreamResult(outStream);
+        TransformerFactory tf = TransformerFactory.newInstance();
+        Transformer serializer = tf.newTransformer();
+        serializer.setOutputProperty(OutputKeys.ENCODING, "utf-8");
+        serializer.setOutputProperty(OutputKeys.INDENT, "yes");
+        serializer.setOutputProperty(OutputKeys.METHOD, "html");
+        serializer.transform(domSource, streamResult);
+        htmlData =  outStream.toString();
+        outStream.close();
+        } catch (Exception e){
+            e.printStackTrace();
+        }
+        return htmlData;
+    }
+
+    public String docxToHtml(InputStream inputStream) throws IOException {
+        String htmlData = "预览失败";
+        try{
+        XWPFDocument docxDocument = new XWPFDocument(inputStream);
+        XHTMLOptions options = XHTMLOptions.create().indent(4);
+            //获取文档中的图片
+        //List<XWPFPictureData> allPictures = docxDocument.getAllPictures();
+        //for (XWPFPictureData xwpfPictureData : allPictures) {
+        //    String name = xwpfPictureData.getFileName();
+        //    byte[] data = xwpfPictureData.getData();
+        //    InputStream input = new ByteArrayInputStream(data);
+        //    TODO 图片处理
+        //
+        //}
+        //final String imageUrl = "";
+        //不把图片生成出来
+        options.setExtractor(null);
+        options.setIgnoreStylesIfUnused(false);
+        options.setFragment(true);
+        //options.URIResolver(new IURIResolver() {
+        //    @Override
+        //    public String resolve(String uri) {
+        //        return imageUrl + uri;
+        //    }
+        //});
+        // 图片转base64 新版本支持
+        options.setImageManager(new Base64EmbedImgManager());
+         //转换htm1
+        ByteArrayOutputStream htmlStream = new ByteArrayOutputStream();
+        XHTMLConverter.getInstance().convert(docxDocument, htmlStream, options);
+        htmlData = htmlStream.toString();
+        htmlStream.close();
+        } catch(Exception e) {
+            e.printStackTrace();
+        }
+        return htmlData;
+    }
+
+
+    /**
+     * 图片处理
+     *
+     *
+     */
+    public class ImageConverter extends WordToHtmlConverter {
+
+        public ImageConverter(Document document) {
+            super(document);
+        }
+
+        @Override
+        protected void processImageWithoutPicturesManager(Element currentBlock, boolean inlined, Picture picture) {
+            Element imgNode = currentBlock.getOwnerDocument().createElement("img");
+            StringBuffer sb = new StringBuffer();
+            sb.append(Base64.getMimeEncoder().encodeToString(picture.getRawContent()));
+            sb.insert(0, "data:" + picture.getMimeType() + ";base64,");
+            imgNode.setAttribute("src", sb.toString());
+            currentBlock.appendChild(imgNode);
+        }
+    }
+
+
+    /**
+     * 读取word中的文本内容(段落、表格、图片分开处理)转HTML docx后缀名的Word
+     * @param
+     * @throws IOException
+     */
+    public  String readWordImgToHtml(InputStream inputStream) throws IOException{
+        String htmlData = "预览失败";
+        XWPFDocument document = new XWPFDocument(inputStream);
+        String htmlText="";
+        try {
+            // 获取word中的所有段落与表格
+            List<IBodyElement> elements = document.getBodyElements();
+            for (IBodyElement element : elements) {
+                // 段落
+                if (element instanceof XWPFParagraph) {
+                    htmlText+=getParagraphHtmlText((XWPFParagraph) element);
+                }
+                // 表格
+                else if (element instanceof XWPFTable) {
+                    htmlText+=getTabelHtmlText((XWPFTable) element);
+                }
+            }
+
+
+            XHTMLOptions options = XHTMLOptions.create().indent(4);
+            options.setExtractor(null);
+            options.setIgnoreStylesIfUnused(false);
+            options.setFragment(true);
+            options.setImageManager(new Base64EmbedImgManager());
+            ByteArrayOutputStream htmlStream = new ByteArrayOutputStream();
+
+            XHTMLConverter.getInstance().convert(document, htmlStream, options);
+            htmlData = htmlStream.toString();
+            htmlStream.close();
+            //获取word中的所有图片
+//            List<XWPFPictureData> picLists= document.getAllPictures();
+//            for(XWPFPictureData pic:picLists){
+//                System.out.println("图片名称:\t" + pic.getFileName());
+//                System.out.println("图片类型:\t" + pic.getPictureType());
+//                byte[] data = pic.getData();
+//                System.out.println(data);
+//                //字节流图片上传,并返回服务器地址
+//                String imgUrl = getImageUrl(data, pic.getFileName());
+//                System.out.println("图片服务器地址:"+imgUrl);
+//                //组装img
+//                htmlText+="<p><img alt='' src='"+imgUrl+"'></p>";
+            }
+        catch (Exception e) {
+            e.printStackTrace();
+        }
+        return  htmlData;
+    }
+    /**
+     * 获取段落内容并组装段落HTML
+     * @param paragraph
+     */
+    private static String getParagraphHtmlText(XWPFParagraph paragraph) {
+        // 获取段落中所有内容
+        List<XWPFRun> runs = paragraph.getRuns();
+        if (runs.size() == 0) {
+            return "";
+        }
+        StringBuffer runText = new StringBuffer();
+        for (XWPFRun run : runs) {
+            runText.append(run.text());
+        }
+        return "<p style='margin:unset;text-align:"+paragraph.getAlignment().name()+"'>"+runText.toString()+"</p>";
+    }
+    /**
+     * 获取表格内容并组装表格HTML
+     * @param table
+     */
+    private static String getTabelHtmlText(XWPFTable table) {
+        String result="";
+        //获取表格数据行
+        List<XWPFTableRow> rows = table.getRows();
+
+        if(rows.size()>0){
+            result+="<table border='1' cellspacing=0 style='border-collapse: collapse;'>";
+            //遍历
+            for (int i=0;i<rows.size();i++) {
+                XWPFTableRow row = rows.get(i);
+                result+="<tr style='font-weight: bold;'>";
+                //获取每行的数据列
+                List<XWPFTableCell> cells = row.getTableCells();
+                for (XWPFTableCell cell : cells) {
+                    //获取单元格跨列个数
+                    BigInteger gridSpanNum = getCellGridSpanNum(cell);
+
+                    result+="<td colspan="+gridSpanNum+" valign=center style='text-align: center;vertical-align: middle;'>";
+                    String cellText="";
+                    // 简单获取内容(简单方式是不能获取字体对齐方式的)
+                    // System.out.println(cell.getText());
+                    // 一个单元格可以理解为一个word文档,单元格里也可以加段落与表格
+                    List<XWPFParagraph> paragraphs = cell.getParagraphs();
+                    for (XWPFParagraph paragraph : paragraphs) {
+                        cellText+="<p style='margin: unset;text-align:"+paragraph.getAlignment().name()+"'>"+getParagraphText(paragraph)+"</p>";
+                    }
+                    result+=cellText;
+                    result+="</td>";
+                }
+
+                result+="</tr>";
+            }
+            result+="</table>";
+        }
+        return result;
+    }
+    /**
+     * 获取段落内容( docx后缀名的Word)
+     * @param paragraph
+     */
+    private static String getParagraphText(XWPFParagraph paragraph) {
+        // 获取段落中所有内容
+        List<XWPFRun> runs = paragraph.getRuns();
+        if (runs.size() == 0) {
+            //System.out.println("按了回车(新段落)");
+            return "";
+        }
+        StringBuffer runText = new StringBuffer();
+        for (XWPFRun run : runs) {
+            runText.append(run.text());
+        }
+//		if (runText.length() > 0) {
+//			runText.append(",对齐方式:").append(paragraph.getAlignment().name());
+//			System.out.println(runText);
+//		}
+        return runText.toString();
+    }
+
+    /**
+     * 字节流图片上传
+     * @param data:图片字节流
+     * @param fileName:图片名称
+     */
+    public static String getImageUrl(byte[] data,String fileName) throws Exception{
+        String imgUrl="";
+        Long res =new Date().getTime();
+        //设置文件存储路径,可以存放在你想要指定的路径里面
+        String rootPath="D:/mimi/"+File.separator+"upload/images/";
+        // 新文件名
+        String newFileName =res + fileName.substring(fileName.lastIndexOf("."));
+        //新文件
+        File newFile=new File(rootPath+File.separator+newFileName);
+        //判断文件目录是否存在
+        if(!newFile.getParentFile().exists()){
+            //如果目标文件所在的目录不存在,则创建父目录
+            newFile.getParentFile().mkdirs();
+        }
+
+        //-------把图片文件写入磁盘 start ----------------
+        FileOutputStream fos = new FileOutputStream(newFile);
+        fos.write(data);
+        fos.close();
+        //-------把图片文件写入磁盘 end ----------------
+        //服务器图片地址
+        String baseURL = "http://192.168.0.76:8080/mimi/upload/images/";
+        imgUrl=baseURL+newFileName;
+
+        return imgUrl;
+    }
+    /**
+     * 获取单元格跨列个数
+     * @return
+     */
+    public static BigInteger getCellGridSpanNum(XWPFTableCell cell){
+        BigInteger gridSpanNum =null;
+        //获取单元格跨列
+        CTDecimalNumber gridSpanXml = cell.getCTTc().getTcPr().getGridSpan();
+        if(gridSpanXml!=null){
+            gridSpanNum = gridSpanXml.getVal();
+            System.out.println("gridSpanNum:"+gridSpanNum);
+        }
+        return gridSpanNum;
+    }
+
+
+
+}

+ 168 - 0
src/main/resources/com/steerinfo/dil/mapper/SystemFileMapper.xml

@@ -0,0 +1,168 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.steerinfo.dil.mapper.SystemFileMapper">
+  <resultMap id="BaseResultMap" type="com.steerinfo.dil.model.SystemFile">
+    <id column="ID" jdbcType="VARCHAR" property="id" />
+    <result column="FILENAME" jdbcType="VARCHAR" property="filename" />
+    <result column="FILEPATH" jdbcType="VARCHAR" property="filepath" />
+  </resultMap>
+  <sql id="columns">
+    ID, FILENAME, FILEPATH
+  </sql>
+  <sql id="columns_alias">
+    t.ID, t.FILENAME, t.FILEPATH
+  </sql>
+  <sql id="select">
+    SELECT <include refid="columns"/> FROM SYSTEM_FILE
+  </sql>
+  <sql id="select_alias">
+    SELECT <include refid="columns_alias"/> FROM SYSTEM_FILE t
+  </sql>
+  <sql id="where">
+    <where> 
+      <if test="id != null and id != ''">
+        and ID = #{id}
+      </if>
+      <if test="filename != null and filename != ''">
+        and FILENAME = #{filename}
+      </if>
+      <if test="filepath != null and filepath != ''">
+        and FILEPATH = #{filepath}
+      </if>
+    </where>
+  </sql>
+  <sql id="whereLike">
+    <where> 
+      <if test="id != null and id != ''">
+        and ID LIKE '%${id}%'
+      </if>
+      <if test="filename != null and filename != ''">
+        and FILENAME LIKE '%${filename}%'
+      </if>
+      <if test="filepath != null and filepath != ''">
+        and FILEPATH LIKE '%${filepath}%'
+      </if>
+    </where>
+  </sql>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
+    delete from SYSTEM_FILE
+    where ID = #{id,jdbcType=VARCHAR}
+  </delete>
+  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
+    delete from SYSTEM_FILE
+    where 1!=1 
+      <if test="filename != null and filename != ''">
+        or FILENAME = #{filename}
+      </if>
+      <if test="filepath != null and filepath != ''">
+        or FILEPATH = #{filepath}
+      </if>
+  </delete>
+  <insert id="insert" parameterType="com.steerinfo.dil.model.SystemFile">
+    insert into SYSTEM_FILE (ID, FILENAME, FILEPATH
+      )
+    values (#{id,jdbcType=VARCHAR}, #{filename,jdbcType=VARCHAR}, #{filepath,jdbcType=VARCHAR}
+      )
+  </insert>
+  <insert id="insertSelective" parameterType="com.steerinfo.dil.model.SystemFile">
+    insert into SYSTEM_FILE
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        ID,
+      </if>
+      <if test="filename != null">
+        FILENAME,
+      </if>
+      <if test="filepath != null">
+        FILEPATH,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        #{id,jdbcType=VARCHAR},
+      </if>
+      <if test="filename != null">
+        #{filename,jdbcType=VARCHAR},
+      </if>
+      <if test="filepath != null">
+        #{filepath,jdbcType=VARCHAR},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKey" parameterType="com.steerinfo.dil.model.SystemFile">
+    update SYSTEM_FILE
+    set FILENAME = #{filename,jdbcType=VARCHAR},
+      FILEPATH = #{filepath,jdbcType=VARCHAR}
+    where ID = #{id,jdbcType=VARCHAR}
+  </update>
+  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.dil.model.SystemFile">
+    update SYSTEM_FILE
+    <set>
+      <if test="filename != null">
+        FILENAME = #{filename,jdbcType=VARCHAR},
+      </if>
+      <if test="filepath != null">
+        FILEPATH = #{filepath,jdbcType=VARCHAR},
+      </if>
+    </set>
+    where ID = #{id,jdbcType=VARCHAR}
+  </update>
+  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
+    <include refid="select"/>
+    where ID = #{id,jdbcType=VARCHAR}
+  </select>
+  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
+    <include refid="select"/>
+    <include refid="where"/>
+  </select>
+  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
+    <include refid="select"/>
+    <include refid="whereLike"/>
+  </select>
+  <insert id="batchInsert" parameterType="java.util.List">
+    insert into SYSTEM_FILE 
+      (ID, 
+      FILENAME, FILEPATH)
+    ( <foreach collection="list" item="item" separator="union all"> 
+   select  
+      #{item.id,jdbcType=VARCHAR}, 
+      #{item.filename,jdbcType=VARCHAR}, #{item.filepath,jdbcType=VARCHAR} from dual  
+   </foreach> )
+  </insert>
+
+  <update id="batchUpdate" parameterType="java.util.List">
+     update SYSTEM_FILE
+     set
+       ID=
+       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
+          when #{item.id,jdbcType=VARCHAR} then #{item.id,jdbcType=VARCHAR}
+       </foreach>
+       ,FILENAME=
+       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
+          when #{item.id,jdbcType=VARCHAR} then #{item.filename,jdbcType=VARCHAR}
+       </foreach>
+       ,FILEPATH=
+       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
+          when #{item.id,jdbcType=VARCHAR} then #{item.filepath,jdbcType=VARCHAR}
+       </foreach>
+     where ID in 
+     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
+    #{item.id,jdbcType=VARCHAR}
+     </foreach> 
+  </update>
+  <delete id="batchDelete" parameterType="java.util.List">
+    delete from SYSTEM_FILE
+    where ID in 
+    <foreach collection="list" item="id" open="(" close=")" separator=",">
+      #{id}
+    </foreach>
+  </delete>
+  <!-- 友情提示!!!-->
+  <!-- 请将自己写的代码放在此标签之下,方便以后粘贴复制。-->
+  <insert id="insertAll" parameterType="com.steerinfo.dil.model.SystemFile">
+    insert into SYSTEM_FILE (ID, FILENAME, FILEPATH
+    )
+    values (#{id,jdbcType=VARCHAR}, #{filename,jdbcType=VARCHAR}, #{filepath,jdbcType=VARCHAR}
+           )
+  </insert>
+</mapper>