Przeglądaj źródła

Merge branch 'master' of https://gitee.com/antai-wuliu/ANTAI-API

dengpan 2 lat temu
rodzic
commit
535507f043

+ 1 - 1
pom.xml

@@ -6,7 +6,7 @@
 
     <groupId>org.example</groupId>
     <artifactId>antai-api</artifactId>
-    <version>2.4</version>
+    <version>1.0</version>
 
     <parent>
         <groupId>org.springframework.boot</groupId>

+ 1 - 1
src/main/java/com/steerinfo/dil/annotaion/RequestLimit.java

@@ -9,6 +9,6 @@ import java.lang.annotation.*;
 @Retention(RetentionPolicy.RUNTIME)
 @Documented
 public @interface RequestLimit {
-    int seconds() default 3;//秒
+    int seconds() default 1;//秒
     int maxCount() default 1;//最大访问次数
 }

+ 75 - 0
src/main/java/com/steerinfo/dil/config/RepeatRequestIntercept.java

@@ -0,0 +1,75 @@
+package com.steerinfo.dil.config;
+
+import com.alibaba.fastjson.JSON;
+import com.steerinfo.dil.annotaion.RequestLimit;
+import com.steerinfo.framework.cache.server.redis.RedisCache;
+import com.steerinfo.framework.controller.RESTfulResult;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.messaging.handler.HandlerMethod;
+import org.springframework.stereotype.Component;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.Objects;
+
+@Component
+public class RepeatRequestIntercept extends HandlerInterceptorAdapter {
+    @Autowired
+    private RedisCache redisUtils;
+    @Override
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
+        //判断请求是否为方法的请求
+        if (handler instanceof HandlerMethod) {
+            HandlerMethod hm = (HandlerMethod) handler;
+            //获取方法中是否有幂等性注解
+            RequestLimit anno = hm.getMethodAnnotation(RequestLimit.class);
+            //若注解为空则直接返回
+            if (Objects.isNull(anno)) {
+                return true;
+            }
+            int seconds = anno.seconds();
+            int max = anno.maxCount();
+            String key = request.getRemoteAddr() + "-" + request.getMethod() + "-" + request.getRequestURL();
+            Object requestCountObj = redisUtils.get(key);
+            if (Objects.isNull(requestCountObj)) {
+                //若为空则为第一次请求
+                redisUtils.setex(key, 1,"ok");
+            } else {
+                //限定时间内的第n次请求
+                int requestCount = Integer.parseInt(requestCountObj.toString());
+                //判断是否超过最大限定请求次数
+                if (requestCount < max) {
+                    //未超过则请求次数+1
+                    redisUtils.incr(key, 1);
+                } else {
+                    //否则拒绝请求并返回信息
+                    refuse(response);
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+    /**
+     * @param response
+     * @date 2023-08-10 15:25
+     * @author Bummon
+     * @description 拒绝请求并返回结果
+     */
+    private void refuse(HttpServletResponse response) throws IOException {
+        response.setContentType("application/json;charset=utf-8");
+        ServletOutputStream os = response.getOutputStream();
+        RESTfulResult result = new RESTfulResult();
+        result.setFailed();
+        result.setMessage("请求已提交,请勿重复请求");
+        result.setCode("100");
+        String jsonString = JSON.toJSONString(result);
+        os.write(jsonString.getBytes());
+        os.flush();
+        os.close();
+    }
+}

+ 6 - 0
src/main/java/com/steerinfo/dil/config/WebConfig.java

@@ -14,8 +14,14 @@ public class WebConfig extends WebMvcConfigurerAdapter {
     @Autowired
     private SessionInterceptor interceptor;
 
+    @Autowired
+    private RepeatRequestIntercept repeatRequestIntercept;
+
     @Override
     public void addInterceptors(InterceptorRegistry registry) {
+
         registry.addInterceptor(interceptor);
+        registry.addInterceptor(repeatRequestIntercept);
     }
+
 }

+ 24 - 0
src/main/java/com/steerinfo/dil/config/WebExceptionHandler.java

@@ -0,0 +1,24 @@
+package com.steerinfo.dil.config;
+
+import com.steerinfo.framework.controller.RESTfulResult;
+import org.apache.log4j.Logger;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+@ControllerAdvice
+public class WebExceptionHandler {
+
+    static final Logger log = Logger.getLogger(WebExceptionHandler.class);
+
+    @ExceptionHandler(value =Exception.class)
+    @ResponseBody
+    public RESTfulResult exceptionHandler(Exception e){
+        log.error("全局异常捕获:"+e);
+        e.printStackTrace();
+        if(e instanceof NullPointerException){
+            return new RESTfulResult("500", "操作失败:缺乏必要参数!", e);
+        }
+        return new RESTfulResult("500", "操作失败:"+e.getMessage(), e);
+    }
+}

+ 5 - 8
src/main/java/com/steerinfo/dil/controller/AMScontroller.java

@@ -273,15 +273,12 @@ public class AMScontroller {
     @LogAround(foreignKeys = {"priceId"}, foreignKeyTypes = {"承运合同"})
     @PostMapping("/")
     public Map<String, Object> insertTransPrice(@RequestBody(required = false) Map<String, Object> map) throws ParseException {
-
-        if (!map.isEmpty()) {
-            if (!map.get("priceDate").toString().isEmpty()) {
-                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
-                Date priceDate = simpleDateFormat.parse(map.get("priceDate").toString());
-                map.put("priceDate", priceDate);
-            }
+        if (map.containsKey("priceDate")){
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            Date priceDate = simpleDateFormat.parse(map.get("priceDate").toString());
+            map.put("priceDate", priceDate);
         }
-        map.put("insertUsername", map.get("userName").toString());
+
         return amsFeign.add(map);
     }
 

+ 131 - 0
src/main/java/com/steerinfo/dil/controller/EMSController.java

@@ -0,0 +1,131 @@
+package com.steerinfo.dil.controller;
+
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.steerinfo.dil.annotaion.LogAround;
+import com.steerinfo.dil.feign.AmsFeign;
+import com.steerinfo.dil.feign.EmsFeign;
+import com.steerinfo.dil.feign.RmsFeign;
+import com.steerinfo.dil.feign.TmsFeign;
+import com.steerinfo.dil.util.BaseRESTfulController;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+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;
+
+/**
+ * @author luobang
+ * @create 2021-09-17 14:11
+ */
+
+@RestController
+@RequestMapping("${api.version}/ems")
+public class EMSController extends BaseRESTfulController {
+    @Autowired
+    private EmsFeign emsFeign;
+    @Autowired
+    private AmsFeign amsFeign;
+    @Autowired
+    private RmsFeign rmsFeign;
+
+
+    @ApiOperation(value = "新增详单明细")
+    @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
+    @LogAround(foreignKeys = {"settlementId"}, foreignKeyTypes = {"新增详单明细"})
+    @PostMapping("/emsdetailsordersAdd")
+    public Map<String, Object> emsdetailsordersAdd(@RequestBody(required = false) Map<String, Object> map){
+
+        return emsFeign.emsdetailsordersAdd(map);
+    }
+
+    @ApiOperation(value = "新增账单明细")
+    @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
+    @LogAround(foreignKeys = {"settlementId"}, foreignKeyTypes = {"新增详单明细"})
+    @PostMapping("/emssettlementordersAdd")
+    public Map<String, Object> emssettlementordersAdd(@RequestBody Map<String, Object> map){
+        return emsFeign.emssettlementordersAdd(map);
+    }
+
+    @ApiOperation(value = "修改详单明细")
+    @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
+    @LogAround(foreignKeys = {"settlementId"}, foreignKeyTypes = {"新增详单明细"})
+    @PutMapping("/emsdetailsordersupdate/{id}")
+    public Map<String, Object> emsdetailsordersupdate(@PathVariable BigDecimal id,@RequestBody(required = false) Map<String, Object> map){
+        map.put("updateUsername", map.get("userName").toString());
+        return emsFeign.emsdetailsordersdelete(id,map);
+    }
+
+    @ApiOperation(value = "更新详单状态")
+    @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
+    @LogAround(foreignKeys = {"settlementId"}, foreignKeyTypes = {"新增详单明细"})
+    @PutMapping("/emsdetailsordersdelete/{id}")
+    public Map<String, Object> emsdetailsordersdelete(@PathVariable BigDecimal id,@RequestBody(required = false) Map<String, Object> map){
+        map.put("updateUsername", map.get("userName").toString());
+        return emsFeign.emsdetailsordersupdate(id,map);
+    }
+
+    @ApiOperation(value = "展示账单详情")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "mapValue", 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 = "/emssettlementordersList")
+    Map<String, Object> emssettlementordersList(@RequestBody(required = false) Map<String, Object> mapValue,
+                                             Integer apiId,
+                                             Integer pageNum,
+                                             Integer pageSize
+    ) {
+        return emsFeign.emssettlementordersList(mapValue == null ? new HashMap<>() : mapValue, apiId, pageNum, pageSize);
+    }
+
+    @ApiOperation(value = "展示详单详情")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "mapValue", 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 = "/emsdetailsordersList")
+    Map<String, Object> emsdetailsordersList(@RequestBody(required = false) Map<String, Object> mapValue,
+                                             Integer apiId,
+                                             Integer pageNum,
+                                             Integer pageSize
+    ) {
+        return emsFeign.emsdetailsordersList(mapValue == null ? new HashMap<>() : mapValue, apiId, pageNum, pageSize);
+    }
+
+
+    @ApiOperation(value = "账单详情更新")
+    @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
+    @LogAround(foreignKeys = {"settlementId"}, foreignKeyTypes = {"账单详情更新"})
+    @PutMapping("/emssettlementorderupdate/{id}")
+    public Map<String, Object> emssettlementorderupdate(@PathVariable BigDecimal id,@RequestBody(required = false) Map<String, Object> map) throws ParseException {
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Date settlementStartDate = simpleDateFormat.parse(map.get("settlementStartDate").toString());
+        Date settlementEndDate = simpleDateFormat.parse(map.get("settlementEndDate").toString());
+        map.put("settlementStartDate",settlementStartDate);
+        map.put("settlementEndDate",settlementEndDate);
+        return emsFeign.emssettlementorderupdate(id,map);
+    }
+
+    @ApiOperation(value = "异常处理")
+    @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
+    @LogAround(foreignKeys = {"settlementId"}, foreignKeyTypes = {"异常处理"})
+    @PostMapping("/abnormal")
+    public Map<String, Object> abnormal(@RequestBody(required = false) Map<String, Object> map){
+        return emsFeign.abnormal(map);
+    }
+
+}

+ 24 - 0
src/main/java/com/steerinfo/dil/controller/RMScontroller.java

@@ -998,4 +998,28 @@ public class RMScontroller extends BaseRESTfulController {
         return rmsFeign.rmsexpansecategorysupdate(id,map);
     }
 
+    @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 = "/getBusinessType")
+    public Map<String, Object> getBusinessType(@RequestBody(required = false) Map<String, Object> map, Integer apiId,
+                                                      Integer pageNum,
+                                                      Integer pageSize) {
+        return rmsFeign.getBusinessType(map == null ? new HashMap<>() : map, apiId, pageNum, pageSize);
+    }
+
+
+    @ApiOperation(value="新增业务类型")
+    @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
+    @LogAround(foreignKeys = {"categoryId"},foreignKeyTypes = {"业务类型"})
+    @PostMapping("/insertBusinessType")
+    public  Map<String, Object> insertBusinessType(@RequestBody(required = false) Map<String, Object> map) {
+        map.put("insertUsername", map.get("userName").toString());
+        return  rmsFeign.insertBusinessType(map);
+    }
+
 }

+ 49 - 3
src/main/java/com/steerinfo/dil/controller/SystemFileController.java

@@ -48,9 +48,9 @@ public class SystemFileController extends BaseRESTfulController {
 
     @Autowired
     private FtpFileUtil ftpFileUtil;
-
+//同一个信息包含多个上传文件信息
     @PostMapping("/insertFile")
-    public RESTfulResult insertFile(String alternateFields1, @ModelAttribute MultipartFile[] file) {
+    public RESTfulResult insertFile(String fileuuid, @ModelAttribute MultipartFile[] file) {
         String filenames = "";
         for (int i = 0; i < file.length; i++) {
             filenames += file[i].getOriginalFilename() + ";";
@@ -76,7 +76,7 @@ public class SystemFileController extends BaseRESTfulController {
                         SystemFile uploadFile = new SystemFile();
                         uploadFile.setFilename(oldName);
                         uploadFile.setFilepath(filePath + "/" + newName);
-                        uploadFile.setId(alternateFields1);
+                        uploadFile.setId(fileuuid);
                         SystemFile modela = systemFileService.add(uploadFile);
                         if (modela != null) {
                             filesid += "," + modela.getId();
@@ -96,6 +96,52 @@ public class SystemFileController extends BaseRESTfulController {
 
     }
 
+    @PostMapping("/insertFiles2")
+    public RESTfulResult insertFiles2(String[] fileuuid, @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(fileuuid[i]);
+                        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("/insertFiles")
     public RESTfulResult insertFiles(String[] fileUuids,String[] fileNames,String[]fileTypes, Map<Object,MultipartFile>FileList, MultipartRequest request) throws Exception {
 

+ 244 - 110
src/main/java/com/steerinfo/dil/controller/TMSController.java

@@ -2,9 +2,13 @@ package com.steerinfo.dil.controller;
 
 
 import com.steerinfo.dil.annotaion.LogAround;
+import com.steerinfo.dil.annotaion.RequestLimit;
+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 +17,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 +38,16 @@ import java.util.concurrent.Callable;
 public class TMSController extends BaseRESTfulController {
     @Autowired
     private TmsFeign tmsFeign;
+
+    @Autowired
+    private AmsFeign amsFeign;
+
+    @Autowired
+    private RmsFeign rmsFeign;
+
+    @Autowired
+    private UniversalMapper universalMapper;
+
     @ApiOperation(value = "车辆实绩")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "map", value = "参数", required = false, dataType = "map"),
@@ -41,15 +57,16 @@ public class TMSController extends BaseRESTfulController {
     })
     @PostMapping(value = "/getcomprehensiveresults")
     public Map<String, Object> getecomprehensiveresultslist(@RequestBody(required = false) Map<String, Object> map, Integer apiId,
-                                               Integer pageNum,
-                                               Integer pageSize) {
+                                                            Integer pageNum,
+                                                            Integer pageSize) {
         return tmsFeign.getAmsSalaryContracList(map == null ? new HashMap<>() : map, apiId, pageNum, pageSize);
     }
-    @ApiOperation(value="新增车辆实绩")
+
+    @ApiOperation(value = "新增车辆实绩")
     @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
-    @LogAround(foreignKeys = {"resultId"},foreignKeyTypes = {"计算公式"})
+    @LogAround(foreignKeys = {"resultId"}, foreignKeyTypes = {"计算公式"})
     @PostMapping("/addcomprehensiveresults")
-    public  Map<String, Object> insertcomprehensiveresults(@RequestBody(required = false) Map<String, Object> map) throws ParseException {
+    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");
@@ -57,48 +74,48 @@ public class TMSController extends BaseRESTfulController {
                 map.put("resultTime", resultTime);
             }
         }
-        map.put("insertUsername",  map.get("userName").toString());
-        return  tmsFeign.insertAmsSalaryContrac(map);
+        map.put("insertUsername", map.get("userName").toString());
+        return tmsFeign.insertAmsSalaryContrac(map);
     }
 
-    @ApiOperation(value="车辆实绩删除")
+    @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){
+    @LogAround(foreignKeys = {"resultId"}, foreignKeyTypes = {"计算公式"})
+    public Map<String, Object> comprehensiveresultsLogicDelete(@RequestBody(required = false) Map<String, Object> map) {
         return tmsFeign.logicdeleteAmsSaalryContrac(map);
     }
 
-    @ApiOperation(value="修改车辆实绩")
+    @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){
+    @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);
+        return tmsFeign.updateAmsSalaryContrac(id, map);
     }
 
-    @ApiOperation(value="派发运输订单")
+    @ApiOperation(value = "派发运输订单")
     @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
     @PostMapping(value = "/dispatchOrder")
-    @LogAround(foreignKeys = {"transOrderId"},foreignKeyTypes = {"运输订单"})
-    public Map<String, Object> dispatchOrder(@RequestBody(required = false) Map<String, Object> map){
+    @LogAround(foreignKeys = {"transOrderId"}, foreignKeyTypes = {"运输订单"})
+    public Map<String, Object> dispatchOrder(@RequestBody(required = false) Map<String, Object> map) {
         return tmsFeign.dispatchOrder(map);
     }
 
-    @ApiOperation(value="更改运输订单状态")
+    @ApiOperation(value = "更改运输订单状态")
     @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
     @PostMapping(value = "/changeTransOrder")
-    @LogAround(foreignKeys = {"transOrderId"},foreignKeyTypes = {"运输订单"})
-    public Map<String, Object> changeTransOrder(@RequestBody(required = false) Map<String, Object> map){
+    @LogAround(foreignKeys = {"transOrderId"}, foreignKeyTypes = {"运输订单"})
+    public Map<String, Object> changeTransOrder(@RequestBody(required = false) Map<String, Object> map) {
         return tmsFeign.changeTransOrder(map);
     }
 
-    @ApiOperation(value="司机接收运单")
+    @ApiOperation(value = "司机接收运单")
     @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
     @PostMapping(value = "/receiptOrder")
-    @LogAround(foreignKeys = {"transOrderId"},foreignKeyTypes = {"运输订单"})
-    public Map<String, Object> receiptOrder(@RequestBody(required = false) Map<String, Object> map){
+    @LogAround(foreignKeys = {"transOrderId"}, foreignKeyTypes = {"运输订单"})
+    public Map<String, Object> receiptOrder(@RequestBody(required = false) Map<String, Object> map) {
         return tmsFeign.receiptOrder(map);
     }
 
@@ -108,134 +125,161 @@ public class TMSController extends BaseRESTfulController {
                                                  Integer apiId,
                                                  Integer pageNum,
                                                  Integer pageSize) {
-        return tmsFeign.getTransOrderList(map ==null ? new HashMap<>() : map, apiId, pageNum, pageSize);
+        return tmsFeign.getTransOrderList(map == null ? new HashMap<>() : map, apiId, pageNum, pageSize);
     }
 
-    @ApiOperation(value="查询运输订单所有运输实绩")
+    @ApiOperation(value = "查询运输订单所有运输实绩")
     @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
     @PostMapping(value = "/getTransResult")
-    public Map<String, Object> getTransResult(@RequestBody(required = false) Map<String, Object> map){
+    public Map<String, Object> getTransResult(@RequestBody(required = false) Map<String, Object> map) {
         return tmsFeign.getTransResult(map);
     }
 
-    @ApiOperation(value="同步进厂")
+    @ApiOperation(value = "同步进厂")
     @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
     @PostMapping(value = "/syncEnfactoryResult")
-    @LogAround(foreignKeys = {"resultId"},foreignKeyTypes = {"进厂实绩"})
-    public Map<String, Object> syncEnfactoryResult(@RequestBody(required = false) Map<String, Object> map){
+    @LogAround(foreignKeys = {"resultId"}, foreignKeyTypes = {"进厂实绩"})
+    public Map<String, Object> syncEnfactoryResult(@RequestBody(required = false) Map<String, Object> map) {
         return tmsFeign.syncEnfactoryResult(map);
     }
 
-    @ApiOperation(value="同步出厂")
+    @ApiOperation(value = "同步出厂")
     @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
     @PostMapping(value = "/syncOutfactoryResult")
-    @LogAround(foreignKeys = {"resultId"},foreignKeyTypes = {"出厂实绩"})
-    public Map<String, Object> syncOutfactoryResult(@RequestBody(required = false) Map<String, Object> map){
+    @LogAround(foreignKeys = {"resultId"}, foreignKeyTypes = {"出厂实绩"})
+    public Map<String, Object> syncOutfactoryResult(@RequestBody(required = false) Map<String, Object> map) {
         return tmsFeign.syncOutfactoryResult(map);
     }
 
-    @ApiOperation(value="同步计量")
+    @ApiOperation(value = "同步计量")
     @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
     @PostMapping(value = "/syncWeightResult")
-    @LogAround(foreignKeys = {"resultId"},foreignKeyTypes = {"计量实绩"})
-    public Map<String, Object> syncWeightResult(@RequestBody(required = false) Map<String, Object> map){
+    @LogAround(foreignKeys = {"resultId"}, foreignKeyTypes = {"计量实绩"})
+    public Map<String, Object> syncWeightResult(@RequestBody(required = false) Map<String, Object> map) {
         return tmsFeign.syncWeightResult(map);
     }
 
+    @ApiOperation(value="计时")
+    @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
+    @RequestLimit()
+    @PostMapping(value = "/startend")
+    @LogAround(foreignKeys = {"resultId"}, foreignKeyTypes = {"计时"})
+    public Map<String, Object> start(@RequestBody(required = false) Map<String, Object> map) {
+        return tmsFeign.startend(map);
+    }
 
-    @ApiOperation(value="销售派发运输订单")
+    @ApiOperation(value = "查询计时")
+    @PostMapping("/tmstimingresultsList")
+    public Map<String, Object> tmstimingresultsList(@RequestBody(required = false) Map<String, Object> map,
+                                                    Integer apiId,
+                                                    Integer pageNum,
+                                                    Integer pageSize) {
+        return tmsFeign.tmstimingresultsList(map == null ? new HashMap<>() : map, apiId, pageNum, pageSize);
+    }
+
+    @ApiOperation(value = "修改计时")
+    @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
+    @PostMapping(value = "/tmstimingresultsUpdate")
+    @LogAround(foreignKeys = {"resultId"}, foreignKeyTypes = {"修改计时"})
+    public Map<String, Object> tmstimingresultsUpdate(@RequestBody(required = false) Map<String, Object> map) {
+        return tmsFeign.tmstimingresultsUpdate(map);
+    }
+
+    @ApiOperation(value = "销售派发运输订单")
     @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
     @PostMapping(value = "/saleDispatchOrder")
-    @LogAround(foreignKeys = {"transOrderId"},foreignKeyTypes = {"运输订单"})
-    public Map<String, Object> saleDispatchOrder(@RequestBody(required = false) Map<String, Object> map){
+    @LogAround(foreignKeys = {"transOrderId"}, foreignKeyTypes = {"运输订单"})
+    public Map<String, Object> saleDispatchOrder(@RequestBody(required = false) Map<String, Object> map) {
         return tmsFeign.saleDispatchOrder(map);
     }
 
     @ApiOperation(value = "查询销售运输订单")
     @PostMapping("/getSaleTransOrderList")
     public Map<String, Object> getSaleTransOrderList(@RequestBody(required = false) Map<String, Object> map,
-                                                 Integer apiId,
-                                                 Integer pageNum,
-                                                 Integer pageSize) {
+                                                     Integer apiId,
+                                                     Integer pageNum,
+                                                     Integer pageSize) {
         return tmsFeign.getSaleTransOrderList(map == null ? new HashMap<>() : map, apiId, pageNum, pageSize);
     }
-    @ApiOperation(value="同步质检")
+
+    @ApiOperation(value = "同步质检")
     @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
     @PostMapping(value = "/syncQualityResult")
-    @LogAround(foreignKeys = {"resultId"},foreignKeyTypes = {"质检实绩"})
-    public Map<String, Object> syncQualityResult(@RequestBody(required = false) Map<String, Object> map){
+    @LogAround(foreignKeys = {"resultId"}, foreignKeyTypes = {"质检实绩"})
+    public Map<String, Object> syncQualityResult(@RequestBody(required = false) Map<String, Object> map) {
         return tmsFeign.syncQualityResult(map);
     }
-    @ApiOperation(value="签到")
+
+    @ApiOperation(value = "签到")
     @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
     @PostMapping(value = "/signIn")
-    @LogAround(foreignKeys = {"resultId"},foreignKeyTypes = {"签到实绩"})
-    public Map<String, Object> signIn(@RequestBody(required = false) Map<String, Object> map){
+    @LogAround(foreignKeys = {"resultId"}, foreignKeyTypes = {"签到实绩"})
+    public Map<String, Object> signIn(@RequestBody(required = false) Map<String, Object> map) {
         return tmsFeign.signIn(map);
     }
 
-    @ApiOperation(value="换车头")
+    @ApiOperation(value = "换车头")
     @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
     @PostMapping(value = "/replaceFront")
-    @LogAround(foreignKeys = {"resultId"},foreignKeyTypes = {"换车头实绩"})
-    public Map<String, Object> replaceFront(@RequestBody(required = false) Map<String, Object> map){
+    @LogAround(foreignKeys = {"resultId"}, foreignKeyTypes = {"换车头实绩"})
+    public Map<String, Object> replaceFront(@RequestBody(required = false) Map<String, Object> map) {
         return tmsFeign.replaceFront(map);
     }
 
-    @ApiOperation(value="装货")
+    @ApiOperation(value = "装货")
     @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
     @PostMapping(value = "/load")
-    @LogAround(foreignKeys = {"resultId"},foreignKeyTypes = {"装货实绩"})
-    public Map<String, Object> load(@RequestBody(required = false) Map<String, Object> map){
+    @LogAround(foreignKeys = {"resultId"}, foreignKeyTypes = {"装货实绩"})
+    public Map<String, Object> load(@RequestBody(required = false) Map<String, Object> map) {
         return tmsFeign.load(map);
     }
 
-    @ApiOperation(value="装货修改")
+    @ApiOperation(value = "装货修改")
     @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
     @PostMapping(value = "/loadUpd")
-    @LogAround(foreignKeys = {"resultId"},foreignKeyTypes = {"装货实绩"})
-    public Map<String, Object> loadUpd(@RequestBody(required = false) Map<String, Object> map){
+    @LogAround(foreignKeys = {"resultId"}, foreignKeyTypes = {"装货实绩"})
+    public Map<String, Object> loadUpd(@RequestBody(required = false) Map<String, Object> map) {
         return tmsFeign.loadUpd(map);
     }
 
-    @ApiOperation(value="卸货")
+    @ApiOperation(value = "卸货")
     @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
     @PostMapping(value = "/unload")
-    @LogAround(foreignKeys = {"resultId"},foreignKeyTypes = {"卸货实绩"})
-    public Map<String, Object> unload(@RequestBody(required = false) Map<String, Object> map){
+    @LogAround(foreignKeys = {"resultId"}, foreignKeyTypes = {"卸货实绩"})
+    public Map<String, Object> unload(@RequestBody(required = false) Map<String, Object> map) {
         return tmsFeign.unload(map);
     }
 
-    @ApiOperation(value="卸货修改")
+    @ApiOperation(value = "卸货修改")
     @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
     @PostMapping(value = "/unloadUpd")
-    @LogAround(foreignKeys = {"resultId"},foreignKeyTypes = {"卸货实绩"})
-    public Map<String, Object> unloadUpd(@RequestBody(required = false) Map<String, Object> map){
+    @LogAround(foreignKeys = {"resultId"}, foreignKeyTypes = {"卸货实绩"})
+    public Map<String, Object> unloadUpd(@RequestBody(required = false) Map<String, Object> map) {
         return tmsFeign.unloadUpd(map);
     }
 
-    @ApiOperation(value="抵达")
+    @ApiOperation(value = "抵达")
     @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
     @PostMapping(value = "/arrival")
-    @LogAround(foreignKeys = {"resultId"},foreignKeyTypes = {"抵达实绩"})
-    public Map<String, Object> arrival(@RequestBody(required = false) Map<String, Object> map){
+    @LogAround(foreignKeys = {"resultId"}, foreignKeyTypes = {"抵达实绩"})
+    public Map<String, Object> arrival(@RequestBody(required = false) Map<String, Object> map) {
         return tmsFeign.arrival(map);
     }
 
-    @ApiOperation(value="签收")
+    @ApiOperation(value = "签收")
     @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
     @PostMapping(value = "/receipt")
-    @LogAround(foreignKeys = {"resultId"},foreignKeyTypes = {"签收实绩"})
-    public Map<String, Object> receipt(@RequestBody(required = false) Map<String, Object> map){
+    @LogAround(foreignKeys = {"resultId"}, foreignKeyTypes = {"签收实绩"})
+    public Map<String, Object> receipt(@RequestBody(required = false) Map<String, Object> map) {
         return tmsFeign.receipt(map);
     }
 
 
-    @ApiOperation(value="查询厂内车辆数")
+    @ApiOperation(value = "查询厂内车辆数")
     @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
     @PostMapping(value = "/getCountEnfactory")
-    public Map<String, Object> getCountEnfactory(@RequestBody(required = false) Map<String, Object> map){
-        return tmsFeign.getCountEnfactory(map == null ? new HashMap<>():map);
+    public Map<String, Object> getCountEnfactory(@RequestBody(required = false) Map<String, Object> map) {
+        return tmsFeign.getCountEnfactory(map == null ? new HashMap<>() : map);
     }
 
     @ApiOperation(value = "查询签到")
@@ -244,7 +288,7 @@ public class TMSController extends BaseRESTfulController {
                                                    Integer apiId,
                                                    Integer pageNum,
                                                    Integer pageSize) {
-        return tmsFeign.getSignInResultList(map ==null ? new HashMap<>() : map, apiId, pageNum, pageSize);
+        return tmsFeign.getSignInResultList(map == null ? new HashMap<>() : map, apiId, pageNum, pageSize);
     }
 
     @ApiOperation(value = "查询换车头")
@@ -253,25 +297,26 @@ public class TMSController extends BaseRESTfulController {
                                                          Integer apiId,
                                                          Integer pageNum,
                                                          Integer pageSize) {
-        return tmsFeign.getReplaceFrontResultList(map ==null ? new HashMap<>() : map, apiId, pageNum, pageSize);
+        return tmsFeign.getReplaceFrontResultList(map == null ? new HashMap<>() : map, apiId, pageNum, pageSize);
     }
 
     @ApiOperation(value = "查询进厂")
     @PostMapping("/getEnfactoryResultList")
     public Map<String, Object> getEnfactoryResultList(@RequestBody(required = false) Map<String, Object> map,
-                                                 Integer apiId,
-                                                 Integer pageNum,
-                                                 Integer pageSize) {
-        return tmsFeign.getEnfactoryResultList(map ==null ? new HashMap<>() : map, apiId, pageNum, pageSize);
+                                                      Integer apiId,
+                                                      Integer pageNum,
+                                                      Integer pageSize) {
+        return tmsFeign.getEnfactoryResultList(map == null ? new HashMap<>() : map, apiId, pageNum, pageSize);
     }
 
     @ApiOperation(value = "查询出厂")
     @PostMapping("/getOutfactoryResultList")
-    public Map<String, Object> getTmsOutfactoryResultList(@RequestBody(required = false) Map<String, Object> map,
-                                                 Integer apiId,
-                                                 Integer pageNum,
-                                                 Integer pageSize) {
-        return tmsFeign.getOutfactoryResultList(map ==null ? new HashMap<>() : map, apiId, pageNum, pageSize);
+    public Map<String, Object> getTmsOutfactoryResultList
+            (@RequestBody(required = false) Map<String, Object> map,
+             Integer apiId,
+             Integer pageNum,
+             Integer pageSize) {
+        return tmsFeign.getOutfactoryResultList(map == null ? new HashMap<>() : map, apiId, pageNum, pageSize);
     }
 
     @ApiOperation(value = "查询装货")
@@ -280,60 +325,149 @@ public class TMSController extends BaseRESTfulController {
                                                  Integer apiId,
                                                  Integer pageNum,
                                                  Integer pageSize) {
-        return tmsFeign.getLoadResultList(map ==null ? new HashMap<>() : map, apiId, pageNum, pageSize);
+        return tmsFeign.getLoadResultList(map == null ? new HashMap<>() : map, apiId, pageNum, pageSize);
     }
 
 
     @ApiOperation(value = "查询卸货")
     @PostMapping("/getUnloadResultList")
     public Map<String, Object> getUnloadResultList(@RequestBody(required = false) Map<String, Object> map,
-                                                 Integer apiId,
-                                                 Integer pageNum,
-                                                 Integer pageSize) {
-        return tmsFeign.getUnloadResultList(map ==null ? new HashMap<>() : map, apiId, pageNum, pageSize);
+                                                   Integer apiId,
+                                                   Integer pageNum,
+                                                   Integer pageSize) {
+        return tmsFeign.getUnloadResultList(map == null ? new HashMap<>() : map, apiId, pageNum, pageSize);
     }
 
     @ApiOperation(value = "查询计量")
     @PostMapping("/getWeightResultList")
     public Map<String, Object> getWeightResultList(@RequestBody(required = false) Map<String, Object> map,
-                                                 Integer apiId,
-                                                 Integer pageNum,
-                                                 Integer pageSize) {
-        return tmsFeign.getWeightResultList(map ==null ? new HashMap<>() : map, apiId, pageNum, pageSize);
+                                                   Integer apiId,
+                                                   Integer pageNum,
+                                                   Integer pageSize) {
+        return tmsFeign.getWeightResultList(map == null ? new HashMap<>() : map, apiId, pageNum, pageSize);
     }
 
     @ApiOperation(value = "查询质检")
     @PostMapping("/getQualityResultList")
     public Map<String, Object> getQualityResult(@RequestBody(required = false) Map<String, Object> map,
-                                                 Integer apiId,
-                                                 Integer pageNum,
-                                                 Integer pageSize) {
-        return tmsFeign.getQualityResultList(map ==null ? new HashMap<>() : map, apiId, pageNum, pageSize);
+                                                Integer apiId,
+                                                Integer pageNum,
+                                                Integer pageSize) {
+        return tmsFeign.getQualityResultList(map == null ? new HashMap<>() : map, apiId, pageNum, pageSize);
     }
 
     @ApiOperation(value = "查询抵达")
     @PostMapping("/getArrivalResultList")
     public Map<String, Object> getArrivalResultList(@RequestBody(required = false) Map<String, Object> map,
-                                                 Integer apiId,
-                                                 Integer pageNum,
-                                                 Integer pageSize) {
-        return tmsFeign.getArrivalResultList(map ==null ? new HashMap<>() : map, apiId, pageNum, pageSize);
+                                                    Integer apiId,
+                                                    Integer pageNum,
+                                                    Integer pageSize) {
+        return tmsFeign.getArrivalResultList(map == null ? new HashMap<>() : map, apiId, pageNum, pageSize);
     }
 
     @ApiOperation(value = "查询签收")
     @PostMapping("/getReceiptResultList")
     public Map<String, Object> getReceiptResultList(@RequestBody(required = false) Map<String, Object> map,
-                                                 Integer apiId,
-                                                 Integer pageNum,
-                                                 Integer pageSize){
-            return tmsFeign.getReceiptResultList(map == null ? new HashMap<>() : map, apiId, pageNum, pageSize);
+                                                    Integer apiId,
+                                                    Integer pageNum,
+                                                    Integer pageSize) {
+        return tmsFeign.getReceiptResultList(map == null ? new HashMap<>() : map, apiId, pageNum, pageSize);
 
+    }
+
+    @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 orderType,
+                                                 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);
+        }
+        Map<String, Object> map = new HashMap<>();
+        //获取Excel中包含的对象数组
+        List<Map<String, Object>> list = ExcelToolUtils.getExcelList(is, fileName, 0);
+        List<String> capacityIds = new ArrayList<>();
+        for (Map<String, Object> item : list) {
+            capacityIds.add(item.get("车号").toString());
         }
+        map.put("list", list);
+        //校验当前excel是否已经导过
+        if (universalMapper.checkTrainOrder(map) > 0) {
+            throw new Exception("存在24小时内的重复运单!不允许重复导入!");
+        }
+        //统计通知单的重量车数和车牌号
+        Set<String> capacitySet = new HashSet<>();//车牌号
+        for (Map<String, Object> item : list) {
+            //通知单统计
+            String requirementNumber = item.get("通知单号").toString();
+            if (map.get("requirementNumber") != null) {
+                if (map.get("requirementNumber").equals(requirementNumber)) {
+                    //已存在,修改
+                    BigDecimal weight = DataChange.dataToBigDecimal(map.get("weight"));
+                    BigDecimal truckNumber = DataChange.dataToBigDecimal(map.get("truckNumber"));
+                    weight = weight.add(DataChange.dataToBigDecimal(item.get("净重")));
+                    truckNumber = truckNumber.add(new BigDecimal(1));
+                    map.put("weight", weight);
+                    map.put("truckNumber", truckNumber);
+                } else {
+                    throw new Exception("同一个Excel文件中只允许有一个采购订单号!");
+                }
+            } else {
+                //不存在,新增
+                BigDecimal weight = DataChange.dataToBigDecimal(item.get("净重"));
+                BigDecimal truckNumber = new BigDecimal(1);
+                map.put("requirementNumber", requirementNumber);
+                map.put("weight", weight);
+                map.put("truckNumber", truckNumber);
+            }
+            //车牌号去重
+            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.put("userId",userId);
+        map.put("userName",userName);
+        map.put("orderType",orderType);
+        return tmsFeign.purchaseTrainLoad(map);
+    }
+
+    @ApiOperation(value = "查询采购火运装货")
+    @PostMapping("/purchaseTrainLoadList")
+    public Map<String, Object> purchaseTrainLoadList(@RequestBody(required = false) Map<String, Object> map,
+                                                     Integer apiId,
+                                                     Integer pageNum,
+                                                     Integer pageSize) {
+        return tmsFeign.purchaseTrainLoadList(map == null ? new HashMap<>() : map, apiId, pageNum, pageSize);
+    }
 
-    @ApiOperation(value="更改销售运输订单状态")
+    @ApiOperation(value = "更改销售运输订单状态")
     @ApiImplicitParam(name = "map", value = "JSON格式数据", required = true, dataType = "Map<String, Object>")
     @PostMapping(value = "/changeSaleTransOrder")
-    @LogAround(foreignKeys = {"transOrderId"},foreignKeyTypes = {"销售运输订单"})
+    @LogAround(foreignKeys = {"transOrderId"}, foreignKeyTypes = {"销售运输订单"})
     public Map<String, Object> changeSaleTransOrder(@RequestBody(required = false) Map<String, Object> map) {
         return tmsFeign.changeSaleTransOrder(map);
     }

+ 8 - 0
src/main/java/com/steerinfo/dil/controller/UniversalController.java

@@ -181,4 +181,12 @@ public class UniversalController extends BaseRESTfulController {
     public String getWlUrl() {
         return universalMapper.getWlUrl();
     }
+
+    @ApiModelProperty(value = "边输边查业务类型")
+    @PostMapping("/getBusinessTypeLike")
+    public RESTfulResult getBusinessTypeLike(@RequestBody(required = false) Map<String,Object> map) {
+        List<Map<String, Object>> list = universalMapper.getBusinessTypeLike(map);
+        return success(list);
+    }
+
 }

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

@@ -83,6 +83,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);
 

+ 56 - 0
src/main/java/com/steerinfo/dil/feign/EmsFeign.java

@@ -0,0 +1,56 @@
+package com.steerinfo.dil.feign;
+
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.*;
+
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @ author    :TXF
+ * @ time      :2021/9/28 9:30
+ */
+
+@FeignClient(name = "ANTAI-EMS-API", url = "${openfeign.EmsFeign.url}")
+public interface EmsFeign {
+
+    //======================>车辆综合实绩
+
+    @PostMapping("api/v1/ems/emsdetailsorders/emsdetailsordersAdd")
+    Map<String, Object> emsdetailsordersAdd(@RequestBody(required = false) Map<String, Object> map);
+
+    @PostMapping("api/v1/ems/emssettlementorders/emssettlementordersAdd")
+    Map<String, Object> emssettlementordersAdd(@RequestBody Map<String, Object> map);
+    @PutMapping("api/v1/ems/emsdetailsorders/emsdetailsordersupdate/{id}")
+    Map<String, Object> emsdetailsordersupdate(@PathVariable BigDecimal id,@RequestBody(required = false) Map<String, Object> map);
+
+
+    @PostMapping("api/v1/ems/emsdetailsorders/abnormal")
+    Map<String, Object> abnormal(@RequestBody(required = false) Map<String, Object> map);
+    @PutMapping("api/v1/ems/emssettlementorders/emssettlementorderupdate/{id}")
+    Map<String, Object> emssettlementorderupdate(@PathVariable BigDecimal id,@RequestBody(required = false) Map<String, Object> map);
+
+    @PutMapping("api/v1/ems/emsdetailsorders/emsdetailsordersdelete/{id}")
+    Map<String, Object> emsdetailsordersdelete(@PathVariable BigDecimal id,@RequestBody(required = false) Map<String, Object> map);
+
+
+    @PostMapping("api/v1/ems/emsdetailsorders/emsdetailsordersList")
+    Map<String, Object> emsdetailsordersList(@RequestBody(required = false) Map<String, Object> mapValue,
+                                             @RequestParam Integer apiId,
+                                             @RequestParam Integer pageNum,
+                                             @RequestParam Integer pageSize
+    );
+    @PostMapping("api/v1/ems/emssettlementorders/emssettlementordersList")
+    Map<String, Object> emssettlementordersList(@RequestBody(required = false) Map<String, Object> mapValue,
+                                             @RequestParam Integer apiId,
+                                             @RequestParam Integer pageNum,
+                                             @RequestParam Integer pageSize
+    );
+}
+
+
+
+
+
+

+ 12 - 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);
@@ -629,6 +632,15 @@ public interface RmsFeign {
 
     @PutMapping("api/v1/rms/rmsexpansecategorys/rmsexpansecategorysUpdate/{id}")
     Map<String, Object> rmsexpansecategorysupdate(@PathVariable BigDecimal id, @RequestBody(required = false) Map<String, Object> map);
+
+
+    @PostMapping("/api/v1/rms/dilbusinesstypes/getBusinessType")
+    Map<String, Object> getBusinessType(@RequestBody(required = false) Map<String, Object> map, @RequestParam Integer apiId,
+                                        @RequestParam Integer pageNum,
+                                        @RequestParam Integer pageSize);
+
+    @PostMapping("api/v1/rms/dilbusinesstypes/insertBusinessType")
+    Map<String, Object> insertBusinessType(@RequestBody(required = false) Map<String, Object> map);
 }
 
 

+ 63 - 38
src/main/java/com/steerinfo/dil/feign/TmsFeign.java

@@ -24,15 +24,15 @@ public interface TmsFeign {
 
     //======================>车辆综合实绩
     @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);
+    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);
+    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);
@@ -42,9 +42,9 @@ public interface TmsFeign {
 
     @PostMapping("api/v1/tms/omstransorders/getTransOrderList")
     Map<String, Object> getTransOrderList(@RequestBody(required = false) Map<String, Object> map,
-                                                @RequestParam  Integer apiId,
-                                                @RequestParam  Integer pageNum,
-                                                @RequestParam  Integer pageSize);
+                                          @RequestParam Integer apiId,
+                                          @RequestParam Integer pageNum,
+                                          @RequestParam Integer pageSize);
 
 
     @PostMapping("api/v1/tms/omstransorders/changeTransOrder")
@@ -66,6 +66,20 @@ public interface TmsFeign {
     Map<String, Object> syncWeightResult(Map<String, Object> map);
 
 
+    @PostMapping("api/v1/tms/tmstimingresults/startend")
+    Map<String, Object> startend(Map<String, Object> map);
+
+    @PostMapping("api/v1/tms/tmstimingresults/tmstimingresultsUpdate")
+    Map<String, Object> tmstimingresultsUpdate(Map<String, Object> map);
+
+
+    @PostMapping("api/v1/tms/tmstimingresults/tmstimingresultsList")
+    Map<String, Object> tmstimingresultsList(@RequestBody(required = false) Map<String, Object> map,
+                                             @RequestParam Integer apiId,
+                                             @RequestParam Integer pageNum,
+                                             @RequestParam Integer pageSize);
+
+
     @PostMapping("api/v1/tms/omstransorders/saleDispatchOrder")
     Map<String, Object> saleDispatchOrder(@RequestBody(required = false) Map<String, Object> map);
 
@@ -75,6 +89,7 @@ public interface TmsFeign {
                                           @RequestParam  Integer pageNum,
                                           @RequestParam  Integer pageSize);
 
+
     @PostMapping("api/v1/tms/tmsqualityresults/syncQualityResult")
     Map<String, Object> syncQualityResult(Map<String, Object> map);
 
@@ -104,70 +119,80 @@ public interface TmsFeign {
     Map<String, Object> receipt(Map<String, Object> map);
 
     @PostMapping("api/v1/tms/omstransorders/getCountEnfactory")
-    Map<String, Object>  getCountEnfactory(@RequestBody(required = false) Map<String, Object> map);
+    Map<String, Object> getCountEnfactory(@RequestBody(required = false) Map<String, Object> map);
 
     @PostMapping("api/v1/tms/tmssigninresults/getSignInResultList")
     Map<String, Object> getSignInResultList(@RequestBody(required = false) Map<String, Object> map,
-                                            @RequestParam  Integer apiId,
-                                            @RequestParam  Integer pageNum,
-                                            @RequestParam  Integer pageSize);
+                                            @RequestParam Integer apiId,
+                                            @RequestParam Integer pageNum,
+                                            @RequestParam Integer pageSize);
 
     @PostMapping("api/v1/tms/tmsreplacefrontresults/getReplaceFrontResultList")
     Map<String, Object> getReplaceFrontResultList(@RequestBody(required = false) Map<String, Object> map,
-                                                  @RequestParam  Integer apiId,
-                                                  @RequestParam  Integer pageNum,
-                                                  @RequestParam  Integer pageSize);
+                                                  @RequestParam Integer apiId,
+                                                  @RequestParam Integer pageNum,
+                                                  @RequestParam Integer pageSize);
 
     @PostMapping("api/v1/tms/tmsenfactoryresults/getEnfactoryResultList")
     Map<String, Object> getEnfactoryResultList(@RequestBody(required = false) Map<String, Object> map,
-                                          @RequestParam  Integer apiId,
-                                          @RequestParam  Integer pageNum,
-                                          @RequestParam  Integer pageSize);
+                                               @RequestParam Integer apiId,
+                                               @RequestParam Integer pageNum,
+                                               @RequestParam Integer pageSize);
 
     @PostMapping("api/v1/tms/tmsoutfactoryresults/getOutfactoryResultList")
     Map<String, Object> getOutfactoryResultList(@RequestBody(required = false) Map<String, Object> map,
-                                              @RequestParam  Integer apiId,
-                                              @RequestParam  Integer pageNum,
-                                              @RequestParam  Integer pageSize);
+                                                @RequestParam Integer apiId,
+                                                @RequestParam Integer pageNum,
+                                                @RequestParam Integer pageSize);
 
     @PostMapping("api/v1/tms/tmsloadresults/getLoadResultList")
     Map<String, Object> getLoadResultList(@RequestBody(required = false) Map<String, Object> map,
-                                                   @RequestParam  Integer apiId,
-                                                   @RequestParam  Integer pageNum,
-                                                   @RequestParam  Integer pageSize);
+                                          @RequestParam Integer apiId,
+                                          @RequestParam Integer pageNum,
+                                          @RequestParam Integer pageSize);
+
+    @PostMapping("api/v1/tms/tmsloadresults/purchaseTrainLoadList")
+    Map<String, Object> purchaseTrainLoadList(@RequestBody(required = false) Map<String, Object> map,
+                                              @RequestParam Integer apiId,
+                                              @RequestParam Integer pageNum,
+                                              @RequestParam Integer pageSize);
 
     @PostMapping("api/v1/tms/tmsunloadresults/getUnloadResultList")
     Map<String, Object> getUnloadResultList(@RequestBody(required = false) Map<String, Object> map,
-                                          @RequestParam  Integer apiId,
-                                          @RequestParam  Integer pageNum,
-                                          @RequestParam  Integer pageSize);
+                                            @RequestParam Integer apiId,
+                                            @RequestParam Integer pageNum,
+                                            @RequestParam Integer pageSize);
 
     @PostMapping("api/v1/tms/tmsweightresults/getWeightResultList")
     Map<String, Object> getWeightResultList(@RequestBody(required = false) Map<String, Object> map,
-                                            @RequestParam  Integer apiId,
-                                            @RequestParam  Integer pageNum,
-                                            @RequestParam  Integer pageSize);
+                                            @RequestParam Integer apiId,
+                                            @RequestParam Integer pageNum,
+                                            @RequestParam Integer pageSize);
 
     @PostMapping("api/v1/tms/tmsqualityresults/getQualityResultList")
     Map<String, Object> getQualityResultList(@RequestBody(required = false) Map<String, Object> map,
-                                            @RequestParam  Integer apiId,
-                                            @RequestParam  Integer pageNum,
-                                            @RequestParam  Integer pageSize);
+                                             @RequestParam Integer apiId,
+                                             @RequestParam Integer pageNum,
+                                             @RequestParam Integer pageSize);
 
     @PostMapping("api/v1/tms/tmsarrivalresults/getArrivalResultList")
     Map<String, Object> getArrivalResultList(@RequestBody(required = false) Map<String, Object> map,
-                                         @RequestParam  Integer apiId,
-                                         @RequestParam  Integer pageNum,
-                                         @RequestParam  Integer pageSize);
+                                             @RequestParam Integer apiId,
+                                             @RequestParam Integer pageNum,
+                                             @RequestParam Integer pageSize);
 
     @PostMapping("api/v1/tms/tmsreceiptresults/getReceiptResultList")
     Map<String, Object> getReceiptResultList(@RequestBody(required = false) Map<String, Object> map,
-                                         @RequestParam  Integer apiId,
-                                         @RequestParam  Integer pageNum,
-                                         @RequestParam  Integer pageSize);
+                                             @RequestParam Integer apiId,
+                                             @RequestParam Integer pageNum,
+                                             @RequestParam Integer pageSize);
+
+    @PostMapping("api/v1/tms/tmsloadresults/purchaseTrainLoad")
+    Map<String, Object> purchaseTrainLoad(Map<String, Object> map);
 
     @PostMapping("api/v1/tms/omstransorders/changeSaleTransOrder")
     Map<String, Object> changeSaleTransOrder(Map<String, Object> map);
+
 }
 
 

+ 4 - 0
src/main/java/com/steerinfo/dil/mapper/UniversalMapper.java

@@ -51,4 +51,8 @@ public interface UniversalMapper {
     List<Map<String, Object>> getColumnAllScheme(Map<String, Object> map);
 
     String getWlUrl();
+
+    int checkTrainOrder(Map<String, Object> map);
+
+    List<Map<String, Object>> getBusinessTypeLike(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;
+    }
+
+
+}

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

@@ -51,11 +51,13 @@ 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:
     url: ${OTMSFEIGN_URL:localhost:8038}
+  EmsFeign:
+    url: ${TMSFEIGN_URL:localhost:8096}
 
 
 #远程调用
@@ -66,7 +68,7 @@ feign:
     config:
       default:  #默认配置,连接时间要短,读取时间要长
         connectTimeout: 1000 #单位毫秒
-        readTimeout: 10000 #单位毫秒
+        readTimeout: 100000 #单位毫秒
 #熔断器
 hystrix:
   command:

+ 4 - 2
src/main/resources/application-prod.yml

@@ -29,17 +29,19 @@ openfeign:
   BmsFeign:
     url: ${BMSFEIGN_URL:172.16.90.214:8078}
   TmsFeign:
-    url: ${TMSFEIGN_URL:172.16.90.214:8086}
+    url: ${TMSFEIGN_URL:localhost:8086}
   WMSFeign:
     url: ${WMSFEIGN_URL:172.16.90.214:8093}
   OMSFeign:
     url: ${OMSFEIGN_URL:172.16.90.214:8095}
   RmsFeign:
-    url: ${RMSFEIGN_URL:172.16.90.214:8060}
+    url: ${RMSFEIGN_URL:localhost:8060}
   IntegrationFeign:
     url: ${INTEGRATIONFEIGN_URL:172.16.90.214:8066}
   OTMSFeign:
     url: ${OTMSFEIGN_URL:172.16.90.214:8038}
+  EmsFeign:
+    url: ${TMSFEIGN_URL:172.16.90.214:8096}
 
 
 #远程调用

+ 1 - 1
src/main/resources/bootstrap.yml

@@ -1,7 +1,7 @@
 api.version: api/v1
 spring:
   profiles:
-    include: ${SPRING_PROFILES:dev}
+    include: ${SPRING_PROFILES:prod}
   jackson:
     date-format: yyyy-MM-dd HH:mm:ss
     time-zone: GMT+8

+ 43 - 0
src/main/resources/com/steerinfo/dil/mapper/UniversalMapper.xml

@@ -436,5 +436,48 @@
         </where>
         FETCH NEXT 100 ROWS ONLY
     </select>
+    <select id="checkTrainOrder" resultType="java.lang.Integer">
+        SELECT COUNT(*)
+        FROM OMS_TRANS_ORDER
+        <where>
+            INSERT_TIME > SYSDATE-1
+            AND CAPACITY_ID IN
+            <foreach collection="list" item="item"  open="(" close=")" separator="," >
+                #{item.车号}
+            </foreach>
+        </where>
+    </select>
+    <select id="getBusinessTypeLike" resultType="java.util.Map">
+        select * from(
+        select
+        DBT.BUSINESS_TYPE_ID  "businessTypeId",
+        DBT.BUSINESS_TYPE_ID  "id",
+        DBT.BUSINESS_TYPE_ID "value",
+        DBT.BUSINESS_TYPE_NAME "text",
+        DBT.BUSINESS_TYPE_NAME "businessTypeName",
+        DBT.BUSINESS_TYPE_NAME "label",
+        DBT.ALTERNATE_FIELDS1 "transportType",
+        DBT.ALTERNATE_FIELDS2 "materialTypeName"
+        from DIL_BUSINESS_TYPE DBT
+        )
+        <where>
+            <if test="index!=null and index!=''">
+                AND REGEXP_LIKE("label", #{index})
+            </if>
+            <if test="transportType!=null and transportType!=''">
+                AND REGEXP_LIKE("transportType", #{transportType})
+            </if>
+            <if test="materialTypeName!=null and materialTypeName!=''">
+                AND REGEXP_LIKE("materialTypeName", #{materialTypeName})
+            </if>
+            <if test="id!=null and !(index!=null and index!='')">
+                AND "id" in
+                <foreach collection="id" item="item"  open="(" close=")" separator="," >
+                    #{item}
+                </foreach>
+            </if>
+        </where>
+        FETCH NEXT 100 ROWS ONLY
+    </select>
 
 </mapper>