0ede56dcf337fd9081e156c857a4288281a9d768.svn-base 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. package cn.com.goldenwater.dcproj.controller.importex;
  2. import cn.com.goldenwater.core.web.BaseController;
  3. import cn.com.goldenwater.core.web.BaseResponse;
  4. import cn.com.goldenwater.dcproj.service.ImpPblmService;
  5. import io.swagger.annotations.Api;
  6. import io.swagger.annotations.ApiOperation;
  7. import io.swagger.annotations.ApiParam;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.web.bind.annotation.*;
  10. import org.springframework.web.multipart.MultipartFile;
  11. import javax.servlet.http.HttpServletResponse;
  12. import java.util.Map;
  13. /**
  14. * <p>
  15. * 导入水库问题的Controller
  16. * 策略:下载,上传,解析,入库
  17. * </p>
  18. *
  19. * @author liyz
  20. * @date 2019/7/10 14:32
  21. **/
  22. @Api(value = "导出导入问题接口", tags = "导出导入问题接口")
  23. @RestController
  24. @RequestMapping("/dc/imp/pblm")
  25. public class ImpPblmController extends BaseController {
  26. @Autowired
  27. private ImpPblmService impPblmService;
  28. @ApiOperation(value = "下载问题模板的接口")
  29. @RequestMapping(value = "/download", method = {RequestMethod.GET, RequestMethod.POST})
  30. public BaseResponse<String> downloadTemplate(HttpServletResponse response,
  31. @ApiParam("userId") @RequestParam() String userId,
  32. @ApiParam("orgType") @RequestParam() String orgType,
  33. @ApiParam("orgIds") @RequestParam() String orgIds,
  34. @ApiParam("datas") @RequestParam(required = false) String datas) {
  35. try {
  36. impPblmService.downloadTemplate(response, userId, orgType, orgIds, datas,getCurrentOrgId());
  37. } catch (Exception e) {
  38. e.printStackTrace();
  39. return buildSuccessResponse("N");
  40. }
  41. return buildSuccessResponse("Y");
  42. }
  43. @ApiOperation(value = "上传接口")
  44. @RequestMapping(value = "/upload", method = {RequestMethod.GET, RequestMethod.POST})
  45. public BaseResponse<String> uploadTemplate(@ApiParam("数据流") @RequestParam() MultipartFile[] file) {
  46. // 返回[存储路径]
  47. return buildSuccessResponse(impPblmService.uploadFile(file));
  48. }
  49. @ApiOperation(value = "解析问题模板的接口")
  50. @RequestMapping(value = "/parse", method = {RequestMethod.GET})
  51. public BaseResponse<Map<String, Object>> parseTemplate(@ApiParam("存储路径") @RequestParam() String filePath,
  52. @ApiParam("用户编码") @RequestParam(required = false) String userId,
  53. @ApiParam("督查编码") @RequestParam(required = false) String orgType) {
  54. // 返回 数据集 和 cacheId
  55. return buildSuccessResponse(impPblmService.parseTemplate(filePath,userId,orgType));
  56. }
  57. @ApiOperation(value = "入库问题模板的接口")
  58. @RequestMapping(value = "/insert", method = {RequestMethod.GET})
  59. public BaseResponse<Boolean> insertTemplate(@ApiParam("cacheId") @RequestParam() String cacheId,
  60. @ApiParam("userId") @RequestParam() String userId,
  61. @ApiParam("updateState:1普通新增 0覆盖新增(先删后增)") @RequestParam() String updateState,
  62. @ApiParam("orgType 001,002,003,004,005,006") @RequestParam() String orgType) {
  63. // 返回 成功或失败
  64. try {
  65. impPblmService.insertTemplate(cacheId, userId, updateState, orgType);
  66. } catch (Exception e) {
  67. e.printStackTrace();
  68. return buildSuccessResponse(false);
  69. }
  70. return buildSuccessResponse(true);
  71. }
  72. @ApiOperation(value = "入库问题模板的接口")
  73. @RequestMapping(value = "/insert/info", method = {RequestMethod.GET})
  74. public BaseResponse<String> insertTemplateInfo(@ApiParam("cacheId") @RequestParam() String cacheId,
  75. @ApiParam("userId") @RequestParam() String userId,
  76. @ApiParam("updateState:1普通新增 0覆盖新增(先删后增)") @RequestParam() String updateState,
  77. @ApiParam("orgType 001,002,003,004,005,006") @RequestParam() String orgType) {
  78. // 返回 成功或失败
  79. String info = "";
  80. try {
  81. info = impPblmService.insertTemplateInfo(cacheId, userId, updateState, orgType);
  82. } catch (Exception e) {
  83. e.printStackTrace();
  84. return buildSuccessResponse(info);
  85. }
  86. return buildSuccessResponse(info);
  87. }
  88. }