liyg 2 anos atrás
pai
commit
bcf3efb13b

+ 97 - 5
src/main/java/com/steerinfo/dil/controller/TMSController.java

@@ -2,9 +2,12 @@ package com.steerinfo.dil.controller;
 
 
 import com.steerinfo.dil.annotaion.LogAround;
+import com.steerinfo.dil.feign.AmsFeign;
+import com.steerinfo.dil.feign.RmsFeign;
 import com.steerinfo.dil.feign.TmsFeign;
 import com.steerinfo.dil.mapper.UniversalMapper;
 import com.steerinfo.dil.util.BaseRESTfulController;
+import com.steerinfo.dil.util.ExcelToolUtils;
 import com.steerinfo.framework.controller.RESTfulResult;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -13,14 +16,16 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.io.File;
+import java.io.FileInputStream;
 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;
-import java.util.concurrent.Callable;
+import java.util.*;
+import java.util.stream.Collectors;
+
+import com.steerinfo.dil.util.DataChange;
+import org.springframework.web.multipart.MultipartRequest;
 
 /**
  * @author luobang
@@ -32,6 +37,13 @@ import java.util.concurrent.Callable;
 public class TMSController extends BaseRESTfulController {
     @Autowired
     private TmsFeign tmsFeign;
+
+    @Autowired
+    private AmsFeign amsFeign;
+
+    @Autowired
+    private RmsFeign rmsFeign;
+
     @ApiOperation(value = "车辆实绩")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "map", value = "参数", required = false, dataType = "map"),
@@ -330,6 +342,86 @@ public class TMSController extends BaseRESTfulController {
 
         }
 
+    @ApiOperation(value="采购火运装货作业")
+    @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
+    @PostMapping(value = "/purchaseTrainLoad")
+//    @LogAround(foreignKeys = {"resultId"},foreignKeyTypes = {"装货实绩"})
+    public Map<String, Object> purchaseTrainLoad(@RequestBody MultipartFile file,
+                                                 String materialType,
+                                                 String userId,
+                                                 String userName) throws Exception {
+        File excel =  ExcelToolUtils.multipartFileToFile(file);
+        FileInputStream is = null;
+        String fileName = excel.getName();
+        // 解决fileName兼容性问题
+        int lastindex = fileName.lastIndexOf("\\");
+        fileName = fileName.substring(lastindex + 1);
+        if (fileName != null && fileName.length() > 0) {
+            is = new FileInputStream(excel);
+        }
+        //获取Excel中包含的对象数组
+        List<Map<String,Object>> list = ExcelToolUtils.getExcelList(is, fileName, 0);
+        //对不同的对象数组按通知单号求和
+        /*
+        * requirementMap结构:{
+        *   "通知单号":{
+        *       weight:'重量',
+        *       truckNumber:'车数'
+        *   }
+        * }
+        * */
+        Map<String,Map<String,Object>> requirementMap = new HashMap<>();//需求
+        Set<String>  capacitySet = new HashSet<>();//车牌号
+        for (Map<String,Object> item : list){
+            //通知单统计
+            String key = item.get("通知单号").toString();
+            Map<String,Object> countMap = requirementMap.get(key);
+            if(countMap != null){
+                //已存在,修改
+                BigDecimal weight = DataChange.dataToBigDecimal(countMap.get("weight"));
+                BigDecimal truckNumber = DataChange.dataToBigDecimal(countMap.get("truckNumber"));
+                weight = weight.add(DataChange.dataToBigDecimal(item.get("净重")));
+                truckNumber = truckNumber.add(new BigDecimal(1));
+                countMap.put("weight",weight);
+                countMap.put("truckNumber",truckNumber);
+            }else{
+                //不存在,新增
+                countMap = new HashMap<>();
+                BigDecimal weight = DataChange.dataToBigDecimal(item.get("净重"));
+                BigDecimal truckNumber = new BigDecimal(1);
+                countMap.put("weight",weight);
+                countMap.put("truckNumber",truckNumber);
+            }
+            requirementMap.put(key,countMap);
+            //车牌号去重
+            capacitySet.add(item.get("车号").toString());
+        }
+        //新增火车运力资源
+        String[] capacities = capacitySet.toArray(new String[0]);//车牌号
+        if(capacities.length != list.size()){
+            throw new Exception("操作失败:车号可能重复!");
+        }else{
+            new Runnable(){
+                @Override
+                public void run() {
+                    Map<String,Object> capacityMap = new HashMap<>();
+                    capacityMap.put("capacities",capacities);
+                    capacityMap.put("userId",userId);
+                    capacityMap.put("userName",userName);
+                    rmsFeign.batchInsertCapacityTrain(capacityMap);
+                }
+            }.run();
+        }
+        //新增AMS及TMS
+        Map<String,Object> map = new HashMap<>();
+        map.put("list",list);
+        map.put("userId",userId);
+        map.put("userName",userName);
+        map.put("materialType",materialType);
+        map.put("requirementMap",requirementMap);
+        return tmsFeign.purchaseTrainLoad(map,userId,userName);
+    }
+
     @ApiOperation(value="更改销售运输订单状态")
     @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
     @PostMapping(value = "/changeSaleTransOrder")

+ 3 - 0
src/main/java/com/steerinfo/dil/feign/AmsFeign.java

@@ -81,6 +81,9 @@ public interface AmsFeign {
     @PostMapping(value = "api/v1/ams/amstransplans/purchasePlanUpdate")
     Map<String, Object> purchasePlanUpdate(Map<String, Object> map);
 
+    @PostMapping(value = "api/v1/ams/amstransplans/purchaseTrainPlanAdd")
+    Map<String, Object> purchaseTrainPlanAdd(Map<String,Map<String,Object>> map);
+
     @PostMapping(value = "api/v1/ams/amstransplans/purchasePlanChange")
     Map<String, Object> purchasePlanChange(Map<String, Object> map);
 

+ 3 - 0
src/main/java/com/steerinfo/dil/feign/RmsFeign.java

@@ -204,6 +204,9 @@ public interface RmsFeign {
     @PostMapping(value = "api/v1/rms/rmscapacity/insertCapacity")
     Map<String, Object> insertCapacity(@RequestBody(required = false) Map<String, Object> map);
 
+    @PostMapping(value = "api/v1/rms/rmscapacity/batchInsertCapacityTrain")
+    Map<String, Object> batchInsertCapacityTrain(@RequestBody(required = false) Map<String, Object> map);
+
     //删除运力
     @PostMapping(value = "api/v1/rms/rmscapacity/deleteCapacity")
     Map<String, Object> deleteCapacity(@RequestBody(required = false) Map<String, Object> map);

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

@@ -166,6 +166,11 @@ public interface TmsFeign {
                                          @RequestParam  Integer pageNum,
                                          @RequestParam  Integer pageSize);
 
+    @PostMapping("api/v1/tms/tmsloadresults/purchaseTrainLoad")
+    Map<String, Object> purchaseTrainLoad(Map<String, Object> map,
+                                          @RequestParam  String userId,
+                                          @RequestParam  String userName);
+
     @PostMapping("api/v1/tms/omstransorders/changeSaleTransOrder")
     Map<String, Object> changeSaleTransOrder(Map<String, Object> map);
 }

+ 507 - 0
src/main/java/com/steerinfo/dil/util/ExcelToolUtils.java

@@ -0,0 +1,507 @@
+package com.steerinfo.dil.util;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFDataFormat;
+import org.apache.poi.hssf.usermodel.HSSFDateUtil;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.apache.tomcat.util.http.fileupload.FileItem;
+import org.apache.tomcat.util.http.fileupload.FileItemFactory;
+import org.apache.tomcat.util.http.fileupload.disk.DiskFileItemFactory;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.*;
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+
+/**
+ * @Author fubo
+ * @Description  excel导入
+ * @Date 2020/6/10 8:46
+ **/
+public class ExcelToolUtils {
+
+
+    /**
+     * MultipartFile转 FileItem 并删除本地临时文件
+     **/
+    public static FileItem MultipartFileItem(MultipartFile file) throws Exception {
+        File files = multipartFileToFile(file);
+        FileItem fielitem = createFileItem(files, files.getName());
+        delteTempFile(files);
+
+        return fielitem;
+    }
+
+    /*
+      创建FileItem
+       */
+    public static FileItem createFileItem(File file, String fieldName) {
+        FileItemFactory factory = new DiskFileItemFactory(16, null);
+        FileItem item = factory.createItem(fieldName, "text/plain", true, file.getName());
+        int bytesRead = 0;
+        byte[] buffer = new byte[8192];
+        try {
+            FileInputStream fis = new FileInputStream(file);
+            OutputStream os = item.getOutputStream();
+            while ((bytesRead = fis.read(buffer, 0, 8192)) != -1) {
+                os.write(buffer, 0, bytesRead);
+            }
+            os.close();
+            fis.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return item;
+    }
+
+
+    /**
+     * MultipartFile 转 File
+     *
+     * @param file
+     * @throws Exception
+     */
+    public static File multipartFileToFile(MultipartFile file) throws Exception {
+        File toFile = null;
+        if (file.equals("") || file.getSize() <= 0) {
+            file = null;
+        } else {
+            InputStream ins = null;
+            ins = file.getInputStream();
+            toFile = new File(file.getOriginalFilename());
+            inputStreamToFile(ins, toFile);
+            ins.close();
+        }
+        return toFile;
+    }
+
+    //获取流文件
+    private static void inputStreamToFile(InputStream ins, File file) {
+        try {
+            OutputStream os = new FileOutputStream(file);
+            int bytesRead = 0;
+            byte[] buffer = new byte[8192];
+            while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) {
+                os.write(buffer, 0, bytesRead);
+            }
+            os.close();
+            ins.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 删除本地临时文件
+     *
+     * @param file
+     */
+    public static void delteTempFile(File file) {
+        if (file != null) {
+            File del = new File(file.toURI());
+            del.delete();
+        }
+    }
+
+    private static NumberFormat numberFormat = NumberFormat.getInstance();
+
+    static {
+        numberFormat.setGroupingUsed(false);
+    }
+
+    /**
+     * 解析文件的方法.
+     *
+     * @param inputStream 文件输入流, 要解析的Excel文件输入流
+     * @param fileName    文件名.
+     * @param startRow    从第几行开始读取数据.
+     * @return List<String [ ]> 集合中的一个元素对应一行解析的数据.
+     * 元素为字符串数组类型. 数组中的每个元素对应一列数据.
+     * @throws IOException
+     */
+    public static List<String[]> parseExcel(InputStream inputStream, String fileName, int startRow)
+            throws Exception {
+
+        // 1. 定义excel对象变量
+        Workbook workbook = null;
+
+        //获取后缀
+        String suffix = fileName.substring(fileName.lastIndexOf("."));
+
+        // 2. 判断后缀.决定使用的解析方式. 决定如何创建具体的对象
+        if (".xls".equals(suffix)) {
+            // 2003
+            workbook = new HSSFWorkbook(inputStream);
+        } else if (".xlsx".equals(suffix)) {
+            // 2007
+            workbook = new XSSFWorkbook(inputStream);
+        } else {
+            // 未知内容
+            throw new Exception("请选择xls或者xlsx文件!");
+        }
+
+        // 获取工作表  excel分为若干个表. sheet
+        Sheet sheet = workbook.getSheetAt(0);
+
+        if (sheet == null) {
+            return null;
+        }
+
+        // 获取表格中最后一行的行号
+        int lastRowNum = sheet.getLastRowNum();
+
+        // 最后一行的行号小于startRow
+        if (lastRowNum < startRow) {
+            throw new Exception("请输入数据");
+        }
+
+
+        List<String[]> result = new ArrayList<>();
+
+        // 定义行变量和单元格变量
+        Row row = null;
+        Cell cell = null;
+        // 循环读取
+        try{
+        for (int rowNum = startRow; rowNum <= lastRowNum; rowNum++) {
+            row = sheet.getRow(rowNum);
+            // 获取当前行的第一列和最后一列的标记(列数)
+            short firstCellNum = row.getFirstCellNum();//第一列从0开始
+            short lastCellNum = row.getLastCellNum();//最后一列
+            if (lastCellNum != 0) {
+                String[] rowArray = new String[lastCellNum];
+                for (int cellNum = firstCellNum; cellNum < lastCellNum; cellNum++) {
+                    cell = row.getCell(cellNum);
+                    // 判断单元格是否有数据
+                    if (cell == null) {
+                        rowArray[cellNum] = null;
+                    } else {
+                        rowArray[cellNum] = parseCell(cell);
+                    }
+                }
+                if(rowArray[0] != null || !rowArray[0].equals("")){
+                    result.add(rowArray);
+                }
+            }
+        }
+
+        } catch (Exception e){
+            throw new Exception("文件存在隐藏行或合并列!");
+        }
+        return result;
+    }
+
+    /**
+     * 解析文件的方法.
+     *
+     * @param inputStream 文件输入流, 要解析的Excel文件输入流
+     * @param fileName    文件名.
+     * @param startRow    从第几行开始读取数据.
+     * @return List<String []> 集合中的一个元素对应一行解析的数据.
+     * 元素为字符串数组类型. 数组中的每个元素对应一列数据.
+     * @throws IOException
+     */
+    public static List<List<String[]>> parseExcels(InputStream inputStream, String fileName, int startRow)
+            throws Exception {
+
+        // 1. 定义excel对象变量
+        Workbook workbook = null;
+
+        //获取后缀
+        String suffix = fileName.substring(fileName.lastIndexOf("."));
+
+        // 2. 判断后缀.决定使用的解析方式. 决定如何创建具体的对象
+        if (".xls".equals(suffix)) {
+            // 2003
+            workbook = new HSSFWorkbook(inputStream);
+        } else if (".xlsx".equals(suffix)) {
+            // 2007
+            workbook = new XSSFWorkbook(inputStream);
+        } else {
+            // 未知内容
+            throw new Exception("请选择xls或者xlsx文件!");
+        }
+        List<List<String[]>> result = new ArrayList<>();
+        for (int k = 0; k < workbook.getNumberOfSheets();k++) {
+            // 获取工作表  excel分为若干个表. sheet
+            Sheet sheet = workbook.getSheetAt(k);
+
+            if (sheet == null) {
+                return null;
+            }
+
+            // 获取表格中最后一行的行号
+            int lastRowNum = sheet.getLastRowNum();
+
+            // 最后一行的行号小于startRow
+            if (lastRowNum < startRow) {
+                throw new Exception("请输入数据");
+            }
+            List<String[]> res = new ArrayList<>();
+            // 定义行变量和单元格变量
+            Row row = null;
+            Cell cell = null;
+            // 循环读取
+            try {
+                for (int rowNum = startRow; rowNum <= lastRowNum; rowNum++) {
+                    row = sheet.getRow(rowNum);
+                    // 获取当前行的第一列和最后一列的标记(列数)
+                    short firstCellNum = row.getFirstCellNum();//第一列从0开始
+                    short lastCellNum = row.getLastCellNum();//最后一列
+                    if (lastCellNum != 0) {
+                        String[] rowArray = new String[lastCellNum];
+                        for (int cellNum = firstCellNum; cellNum < lastCellNum; cellNum++) {
+                            cell = row.getCell(cellNum);
+                            // 判断单元格是否有数据
+                            if (cell == null) {
+                                rowArray[cellNum] = null;
+                            } else {
+                                rowArray[cellNum] = parseCell(cell);
+                            }
+                        }
+                        res.add(rowArray);
+                        if (rowArray[0] != null && !"".equals(rowArray[0])) {
+                            res.add(rowArray);
+                        }
+                    }
+                }
+                result.add(res);
+            } catch (Exception e) {
+                e.printStackTrace();
+                throw new Exception("文件存在隐藏行或合并列!");
+            }
+        }
+        return result;
+    }
+
+    /**
+     * 解析单元格
+     *
+     * @return String 单元格数据
+     */
+    private static String parseCell(Cell cell) {
+        //空返回空
+        if(cell == null){
+            return null;
+        }
+
+        String result = null;
+
+        switch (cell.getCellType()) {
+
+            case HSSFCell.CELL_TYPE_NUMERIC:// 判断单元格的值是否为数字类型
+
+                if (HSSFDateUtil.isCellDateFormatted(cell)) {// 处理日期格式、时间格式
+                    SimpleDateFormat sdf = null;
+                    if (cell.getCellStyle().getDataFormat() == HSSFDataFormat
+                            .getBuiltinFormat("h:mm")) {
+                        sdf = new SimpleDateFormat("HH:mm");
+                    } 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)
+					/*yyyy年m月d日----->31
+					yyyy-MM-dd-----	14
+					yyyy年m月-------	57
+					m月d日  ----------58
+					HH:mm-----------20
+					h时mm分  -------	32*/
+
+                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+                    double value = cell.getNumericCellValue();
+                    Date date = DateUtil
+                            .getJavaDate(value);
+                    result = sdf.format(date);
+                } else {
+                    // 返回数值类型的值
+                    Object inputValue = null;// 单元格值
+                    Long longVal = Math.round(cell.getNumericCellValue());
+                    Double doubleVal = cell.getNumericCellValue();
+                    if (Double.parseDouble(longVal + ".0") == doubleVal) {   //判断是否含有小数位.0
+                        inputValue = longVal;
+                    } else {
+                        inputValue = doubleVal;
+                    }
+                    DecimalFormat df = new DecimalFormat("#.##");    //格式化为四位小数,按自己需求选择;
+                    result = String.valueOf(df.format(inputValue));      //返回String类型
+
+//                    double value = cell.getNumericCellValue();
+//                    CellStyle style = cell.getCellStyle();
+//                    DecimalFormat format = new DecimalFormat("0.00");
+//                    String temp = style.getDataFormatString();
+//                    // 单元格设置成常规
+//                    if (temp.equals("General")) {
+//                        format.applyPattern("#");
+//                    }
+//                    result = format.format(value);
+                }
+                break;
+            case HSSFCell.CELL_TYPE_STRING:// 判断单元格的值是否为String类型
+                result = cell.getRichStringCellValue().toString();
+                break;
+            case HSSFCell.CELL_TYPE_BLANK://判断单元格的值是否为布尔类型
+                result = "";
+            default:
+                result = "";
+                break;
+        }
+
+        return result;
+    }
+
+
+   
+
+  
+   
+
+
+    /**
+     * 生成随机数:当前年月日时分秒+四位随机数
+     *
+     * @return
+     */
+    public static String getRandom() {
+
+        SimpleDateFormat simpleDateFormat;
+
+        simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
+
+        Date date = new Date();
+
+        String str = simpleDateFormat.format(date);//当前年月日
+
+        Random random = new Random();
+
+        int rannum = (int) (random.nextDouble() * (9999 - 1000 + 1)) + 1000;// 获取5位随机数
+
+        return str + rannum;
+    }
+
+
+    /**
+     * 发货单页面生成的随机发货单编号-按前端设定
+     *
+     * @return
+     */
+    public static String Random() {
+
+        SimpleDateFormat simpleDateFormat;
+
+        simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
+
+        Date date = new Date();
+
+        String str = simpleDateFormat.format(date);//当前年月日
+
+        Random random = new Random();
+
+        int rannum = (int) (random.nextDouble() * (99999 - 10000 + 1)) + 10000;// 获取5位随机数
+
+        return "CX-" + str + rannum;
+    }
+
+    //截取字符串中数字-按MEs规则来(前八位位年月日,后面拼编号和英文做辨识)
+    public static String getNumberText(String str){
+        if(StringUtils.isBlank(str)){
+            throw new RuntimeException("参数str不能为空");
+        }
+        StringBuffer number = new StringBuffer("");
+
+        String[] strArray = str.split("");
+        for (String string : strArray) {
+            //if(!StringUtils.isBlank(string) && RegUtils.isNumberText(string)){
+            //    number.append(string);
+            //}
+        }
+        return number.toString()+"XG";
+    }
+
+
+    /**
+     * 获取Excel中的对象数组
+     * @param inputStream
+     * @param fileName
+     * @param startRow 默认0
+     * @return
+     * @throws Exception
+     */
+    public static List<Map<String,Object>> getExcelList(InputStream inputStream, String fileName, int startRow)
+            throws Exception {
+        //构建返回数组
+        List<Map<String,Object>> list = new ArrayList<>();
+        // 1. 创建工作簿
+        Workbook workbook = null;
+        // 2. 根据格式解析文件
+        if (fileName.endsWith(".xls")) {
+            workbook = new HSSFWorkbook(inputStream);
+        }else if(fileName.endsWith(".xlsx")){
+            workbook = new XSSFWorkbook(inputStream);
+        }else {
+            throw new Exception("请选择xls或者xlsx文件!");
+        }
+        for (int sheetIndex = 0; sheetIndex < workbook.getNumberOfSheets();sheetIndex++) {
+            // 获取工作表  excel分为若干个表. sheet
+            Sheet sheet = workbook.getSheetAt(sheetIndex);
+            if (sheet == null) {
+                break;
+            }
+            // 获取表格中最后一行的行号
+            int lastRowNum = sheet.getLastRowNum();
+            if (lastRowNum < startRow) {
+                throw new Exception("第"+sheetIndex+"个工作簿无数据!请检查Excel!");
+            }
+            // 定义行变量和单元格变量
+            Row row = null;
+            Cell cell = null;
+            //获取表头
+            Row titlesRow = sheet.getRow(startRow);
+            // 获取当前行的第一列和最后一列的标记(列数)
+            int firstCellNum = titlesRow.getFirstCellNum();//第一列
+            int lastCellNum = titlesRow.getLastCellNum();//最后一列
+            String[] titles = new String[lastCellNum];
+            if (lastCellNum > firstCellNum) {
+                for (int cellNum = firstCellNum; cellNum < lastCellNum; cellNum++) {
+                    cell = titlesRow.getCell(cellNum);
+                    // 判断单元格是否有数据
+                    if (cell == null) {
+                        titles[cellNum] = null;
+                    } else {
+                        titles[cellNum] = parseCell(cell);
+                    }
+                }
+            }else {
+                throw new Exception("第"+sheetIndex+"个工作簿无表头数据!请检查Excel!");
+            }
+            try {
+                //遍历除表头外的所有行
+                for (int rowNum = startRow+1; rowNum <= lastRowNum; rowNum++) {
+                    row = sheet.getRow(rowNum);
+                    //遍历行的所有列
+                    Map<String,Object> item = new HashMap<>();
+                    for (int cellNum = firstCellNum; cellNum < lastCellNum; cellNum++) {
+                        cell = row.getCell(cellNum);
+                        //获取表头对应数据
+                        if (titles[cellNum] != null && !titles[cellNum].equals("")) {
+                            item.put(titles[cellNum],parseCell(cell));
+                        }
+                    }
+                    list.add(item);
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+                throw new Exception("文件存在隐藏行或合并列!");
+            }
+        }
+        return list;
+    }
+}

+ 172 - 0
src/main/java/com/steerinfo/dil/util/poiutil.java

@@ -0,0 +1,172 @@
+package com.steerinfo.dil.util;
+
+
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+
+
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.lang.reflect.Method;
+import java.nio.charset.StandardCharsets;
+
+import java.util.*;
+
+
+//导入excle工具类
+
+public class poiutil {
+    private final static String xls = "xls";
+    private final static String xlsx = "xlsx";
+    private final static String DATE_FORMAT = "yyyy/MM/dd";
+
+    //参数说明:  fileName:文件名   projects:对象集合  columnNames: 列名   keys: map中的key
+    public static void start_download(HttpServletResponse response, String fileName, List<?> projects, String[] columnNames, String[] keys) throws IOException {
+
+        //将集合中对象的属性  对应到  List<Map<String,Object>>
+        List<Map<String, Object>> list = createExcelRecord(projects, keys);
+
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        try {
+            //将转换成的Workbook对象通过流形式下载
+            createWorkBook(list, keys, columnNames).write(os);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        byte[] content = os.toByteArray();
+        InputStream is = new ByteArrayInputStream(content);
+        // 设置response参数,可以打开下载页面
+        response.reset();
+        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+        response.setCharacterEncoding("utf-8");
+        response.setHeader("Content-Disposition", "attachment;filename=" + new String((fileName + ".xlsx").getBytes(), StandardCharsets.ISO_8859_1));
+        ServletOutputStream out = response.getOutputStream();
+        BufferedInputStream bis = null;
+        BufferedOutputStream bos = null;
+        try {
+            bis = new BufferedInputStream(is);
+            bos = new BufferedOutputStream(out);
+            byte[] buff = new byte[2048];
+            int bytesRead;
+            while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
+                bos.write(buff, 0, bytesRead);
+            }
+        } catch (final IOException e) {
+            throw e;
+        } finally {
+            if (bis != null) bis.close();
+            if (bos != null) bos.close();
+        }
+    }
+
+    private static List<Map<String, Object>> createExcelRecord(List<?> projects, String[] keys) {
+        List<Map<String, Object>> listmap = new ArrayList<Map<String, Object>>();
+        Map<String, Object> map = new HashMap<String, Object>();
+        map.put("sheetName", "sheet");
+        listmap.add(map);
+        Object project = null;
+        for (int j = 0; j < projects.size(); j++) {
+            project = projects.get(j);
+            Map<String, Object> mapValue = new HashMap<String, Object>();
+            for (int i = 0; i < keys.length; i++) {
+                mapValue.put(keys[i], getFieldValueByName(keys[i], project));
+            }
+
+            listmap.add(mapValue);
+        }
+        return listmap;
+    }
+
+    /**
+     * 利用反射  根据属性名获取属性值
+     */
+    private static Object getFieldValueByName(String fieldName, Object o) {
+        try {
+            String firstLetter = fieldName.substring(0, 1).toUpperCase();
+            String getter = "get" + firstLetter + fieldName.substring(1);
+            Method method = o.getClass().getMethod(getter);
+            Object value = method.invoke(o);
+            return value;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+    /**
+     * 创建excel文档对象
+     *
+     * @param keys        list中map的key数组集合
+     * @param columnNames excel的列名
+     */
+    private static Workbook createWorkBook(List<Map<String, Object>> list, String[] keys, String[] columnNames) {
+        // 创建excel工作簿
+        Workbook wb = new XSSFWorkbook();
+
+        // 创建第一个sheet(页),并命名
+        Sheet sheet = wb.createSheet(list.get(0).get("sheetName").toString());
+        // 手动设置列宽。第一个参数表示要为第几列设;,第二个参数表示列的宽度,n为列高的像素数。
+        for (int i = 0; i < keys.length; i++) {
+            sheet.setColumnWidth((short) i, (short) (35.7 * 150));
+        }
+
+        // 创建第一行
+        Row row = sheet.createRow((short) 0);
+
+        // 创建两种单元格格式
+        CellStyle cs = wb.createCellStyle();
+        CellStyle cs2 = wb.createCellStyle();
+
+        // 创建两种字体
+        Font f = wb.createFont();
+        Font f2 = wb.createFont();
+
+        // 创建第一种字体样式(用于列名)
+        f.setFontHeightInPoints((short) 10);
+        f.setColor(IndexedColors.BLACK.getIndex());
+        f.setBold(true);
+
+        // 创建第二种字体样式(用于值)
+        f2.setFontHeightInPoints((short) 10);
+        f2.setColor(IndexedColors.BLACK.getIndex());
+
+        // 设置第一种单元格的样式(用于列名)
+        cs.setFont(f);
+        cs.setBorderLeft(BorderStyle.THIN);
+        cs.setBorderRight(BorderStyle.THIN);
+        cs.setBorderTop(BorderStyle.THIN);
+        cs.setBorderBottom(BorderStyle.THIN);
+        cs.setAlignment(HorizontalAlignment.CENTER);
+
+        // 设置第二种单元格的样式(用于值)
+        cs2.setFont(f2);
+        cs2.setBorderLeft(BorderStyle.THIN);
+        cs2.setBorderRight(BorderStyle.THIN);
+        cs2.setBorderTop(BorderStyle.THIN);
+        cs2.setBorderBottom(BorderStyle.THIN);
+        cs2.setAlignment(HorizontalAlignment.CENTER);
+        //设置列名
+        for (int i = 0; i < columnNames.length; i++) {
+            Cell cell = row.createCell(i);
+            cell.setCellValue(columnNames[i]);
+            cell.setCellStyle(cs);
+        }
+        //设置每行每列的值
+        for (short i = 1; i < list.size(); i++) {
+            // Row 行,Cell 方格 , Row 和 Cell 都是从0开始计数的
+            // 创建一行,在页sheet上
+            Row row1 = sheet.createRow(i);
+            // 在row行上创建一个方格
+            for (short j = 0; j < keys.length; j++) {
+                Cell cell = row1.createCell(j);
+                cell.setCellValue(list.get(i).get(keys[j]) == null ? " " : list.get(i).get(keys[j]).toString());
+                cell.setCellStyle(cs2);
+            }
+        }
+        return wb;
+    }
+
+
+}

+ 2 - 2
src/main/resources/application-dev.yml

@@ -51,7 +51,7 @@ openfeign:
   OMSFeign:
     url: ${OMSFEIGN_URL:localhost:8095}
   RmsFeign:
-    url: ${RMSFEIGN_URL:172.16.90.214:8060}
+    url: ${RMSFEIGN_URL:localhost:8060}
   IntegrationFeign:
     url: ${INTEGRATIONFEIGN_URL:localhost:8066}
   OTMSFeign:
@@ -66,7 +66,7 @@ feign:
     config:
       default:  #默认配置,连接时间要短,读取时间要长
         connectTimeout: 1000 #单位毫秒
-        readTimeout: 10000 #单位毫秒
+        readTimeout: 100000 #单位毫秒
 #熔断器
 hystrix:
   command: