|  |  |  | 
|---|
|  |  |  | import doumeemes.service.system.SystemDataPermissionService; | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | import io.swagger.annotations.ApiImplicitParam; | 
|---|
|  |  |  | import io.swagger.annotations.ApiImplicitParams; | 
|---|
|  |  |  | import io.swagger.annotations.ApiOperation; | 
|---|
|  |  |  | import org.apache.commons.lang3.StringUtils; | 
|---|
|  |  |  | import org.apache.shiro.authz.annotation.RequiresPermissions; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  | import org.springframework.web.multipart.MultipartFile; | 
|---|
|  |  |  | import org.springframework.web.multipart.MultipartHttpServletRequest; | 
|---|
|  |  |  | import org.springframework.web.multipart.commons.CommonsMultipartResolver; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.servlet.http.HttpServletRequest; | 
|---|
|  |  |  | import javax.servlet.http.HttpServletResponse; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.Iterator; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private DeviceExtService deviceExtService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private DeviceService deviceService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | return ApiResponse.success(list); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "批量导入计划", notes = "批量导入计划", httpMethod = "POST", position = 6) | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(name = "folder", value = "文件夹", required = true, paramType = "query", dataType = "String", dataTypeClass = String.class), | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | @PostMapping(value = "/importBatch", headers = "content-type=multipart/form-data") | 
|---|
|  |  |  | //    @RequiresPermissions("business:salaryparam:create") | 
|---|
|  |  |  | public ApiResponse importBatch(String folder, HttpServletRequest request, HttpServletResponse response) throws Exception { | 
|---|
|  |  |  | CommonsMultipartResolver multipartResovler = new CommonsMultipartResolver(); | 
|---|
|  |  |  | if (multipartResovler.isMultipart(request)) { | 
|---|
|  |  |  | MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; | 
|---|
|  |  |  | Iterator<String> it = multipartRequest.getFileNames(); | 
|---|
|  |  |  | while (it.hasNext()) { | 
|---|
|  |  |  | MultipartFile file = multipartRequest.getFile((String) it.next()); | 
|---|
|  |  |  | deviceService.importPlans(file); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ApiResponse.success( null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|