package cn.com.goldenwater.dcproj.controller.importex; import cn.com.goldenwater.core.web.BaseController; import cn.com.goldenwater.core.web.BaseResponse; import cn.com.goldenwater.dcproj.service.ImpDcInfoService; import cn.com.goldenwater.dcproj.service.ImpPblmService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.util.Map; /** *

* 导入督查信息的接口类,督查填报模块批量导入 *

* * @author liyz * @date 2019/8/14 11:36 **/ @Api(value = "导出导入督查信息批量填报接口", tags = "导出导入督查信息批量填报接口") @RestController @RequestMapping("/dc/imp/dcInfo") public class ImpDcInfoController extends BaseController { @Autowired private ImpDcInfoService impDcInfoService; @Autowired private ImpPblmService impPblmService; @ApiOperation(value = "下载模板的接口") @RequestMapping(value = "/download", method = {RequestMethod.GET, RequestMethod.POST}) public BaseResponse downloadTemplate(HttpServletResponse response, @ApiParam("userId") @RequestParam() String userId, @ApiParam("orgType") @RequestParam() String orgType, @ApiParam("orgIds") @RequestParam() String orgIds) { try { impDcInfoService.downloadTemplate(response, userId, orgType, orgIds); } catch (Exception e) { e.printStackTrace(); return buildSuccessResponse("N"); } return buildSuccessResponse("Y"); } @ApiOperation(value = "上传接口") @RequestMapping(value = "/upload", method = {RequestMethod.GET, RequestMethod.POST}) public BaseResponse uploadTemplate(@ApiParam("数据流") @RequestParam() MultipartFile[] file) { // 返回[存储路径] return buildSuccessResponse(impPblmService.uploadFile(file)); } @ApiOperation(value = "解析模板的接口") @RequestMapping(value = "/parse", method = {RequestMethod.GET}) public BaseResponse> parseTemplate(@ApiParam("存储路径") @RequestParam() String filePath, @ApiParam("用户编码") @RequestParam(required = false) String userId, @ApiParam("督查编码") @RequestParam(required = false) String orgType) { // 返回 数据集 和 cacheId return buildSuccessResponse(impDcInfoService.parseTemplate(filePath,userId,orgType)); } @ApiOperation(value = "入库模板的接口") @RequestMapping(value = "/insert/info", method = {RequestMethod.GET}) public BaseResponse insertTemplateInfo(@ApiParam("cacheId") @RequestParam() String cacheId, @ApiParam("userId") @RequestParam() String userId, @ApiParam("orgType 001,002,003,004,005,006") @RequestParam() String orgType) { // 返回 导入信息 String info = ""; try { info = impDcInfoService.insertTemplateInfo(cacheId, userId, orgType); } catch (Exception e) { e.printStackTrace(); return buildSuccessResponse(info); } return buildSuccessResponse(info); } }