liyg il y a 1 an
Parent
commit
cb7a827b87

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

@@ -677,6 +677,39 @@ public class RMScontroller extends BaseRESTfulController {
         return rmsFeign.getCapacityList(mapValue == null ? new HashMap<>() : mapValue, pageNum, pageSize, apiId, con, carrierSSOId);
     }
 
+    @ApiOperation("导入车辆")
+    @PostMapping("/importCapacity")
+    public Map<String, Object> importCapacity(@RequestBody MultipartFile file,
+                                              String userId,
+                                              String userName) throws Exception {
+        Map<String, Object> map = new HashMap<>();
+        //获取Excel中包含的对象数组
+        List<Map<String, Object>> list = ExcelToolUtils.getExcelList(file, 0);
+        map.put("list", list);
+        Set<String> set = new HashSet<>();
+        for (Map<String, Object> item : list) {
+            //校验行
+            if(
+                    item.get("车号")==null || item.get("车号").equals("")
+            ){
+                throw new Exception("单元格数据异常,请检查模板或数据是否正确!");
+            }
+            //隔开用于查询是否数据库存在
+            set.add(item.get("车号").toString());
+            //key-value结构方便数据库去重后获取值
+            map.put(item.get("车号").toString(),item);
+        }
+        //去重
+        String[] setList = set.toArray(new String[0]);
+        if (setList.length != list.size()) {
+            throw new Exception("车号不允许重复!");
+        }
+        map.put("setList",setList);
+        map.put("userId",userId);
+        map.put("userName",userName);
+        return rmsFeign.importCapacity(map);
+    }
+
 
     @ApiOperation(value = "删除", notes = "根据rmsCarrier对象创建")
     @ApiImplicitParam(name = "仓库id", value = "id", required = true, dataType = "int")

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

@@ -276,6 +276,9 @@ public interface RmsFeign {
     @PostMapping(value = "api/v1/rms/rmscapacity/getCapacityById")
     Map<String, Object> getCapacityById(@RequestBody Map<String, Object> map);
 
+    @PostMapping(value = "api/v1/rms/rmscapacity/importCapacity")
+    Map<String, Object> importCapacity(Map<String, Object> map);
+
     //==============仓库
     //新增仓库
     @PostMapping(value = "api/v1/rms/rmswarehouse/insertWarehouse")