WellInfoController.java 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. package com.bowintek.practice.controller;
  2. import com.bowintek.practice.AppConfig;
  3. import com.bowintek.practice.filter.exception.BaseResponse;
  4. import com.bowintek.practice.filter.exception.RespGenerstor;
  5. import com.bowintek.practice.model.WlUserExpendSetting;
  6. import com.bowintek.practice.services.service.AccountService;
  7. import com.bowintek.practice.services.service.OrganizationService;
  8. import com.bowintek.practice.services.service.WellInfoService;
  9. import com.bowintek.practice.util.RemoteHelper;
  10. import com.bowintek.practice.vo.query.WellInfoParams;
  11. import com.github.pagehelper.PageInfo;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.web.bind.annotation.*;
  14. import javax.servlet.http.HttpServletResponse;
  15. import java.io.ByteArrayOutputStream;
  16. import java.io.IOException;
  17. import java.io.OutputStream;
  18. import java.net.URLEncoder;
  19. import java.nio.charset.StandardCharsets;
  20. import java.util.Base64;
  21. import java.util.HashMap;
  22. import java.util.List;
  23. import java.util.Map;
  24. @RestController
  25. @RequestMapping(value = "/api/wellInfo")
  26. public class WellInfoController {
  27. @Autowired
  28. private WellInfoService wellInfoService;
  29. @Autowired
  30. private OrganizationService organizationService;
  31. @Autowired
  32. private AccountService accountService;
  33. @Autowired
  34. private RemoteHelper remoteHelper;
  35. @Autowired
  36. private AppConfig appConfig;
  37. @ResponseBody
  38. @GetMapping("/getList")
  39. public BaseResponse<PageInfo<HashMap<String, Object>>> getList(@RequestParam("page") int page, @RequestParam("rows") int rows,
  40. WellInfoParams params) throws Exception {
  41. PageInfo<HashMap<String, Object>> result = wellInfoService.getList(page, rows, params);
  42. return RespGenerstor.success(result);
  43. }
  44. @ResponseBody
  45. @GetMapping("/getMapList")
  46. public BaseResponse<PageInfo<HashMap<String, Object>>> getMapList(@RequestParam("page") int page, @RequestParam("rows") int rows,
  47. WellInfoParams params) throws Exception {
  48. PageInfo<HashMap<String, Object>> result = wellInfoService.getMapList(page, rows, params);
  49. return RespGenerstor.success(result);
  50. }
  51. @GetMapping("/getOrganizationTree")
  52. public BaseResponse getOrganizationTree() {
  53. return RespGenerstor.success(organizationService.getListTree("HBlQAIBGob"));
  54. }
  55. @GetMapping("/getWellInfo")
  56. public BaseResponse getWellInfo(String well_id) {
  57. HashMap<String, Object> wellInfo = wellInfoService.getWellInfo(well_id);
  58. List<HashMap<String, Object>> boreholeInterList = wellInfoService.selectBoreholeInterList(well_id);
  59. List<HashMap<String, Object>> testHistoryList = wellInfoService.selectTestHistoryList(well_id);
  60. List<HashMap<String, Object>> testHistorySummary = wellInfoService.selectTestHistorySummary(well_id);
  61. HashMap<String, Object> lastTestHistory = wellInfoService.getLastTestHistory(well_id);
  62. List<HashMap<String, Object>> analyticalAssaysList = wellInfoService.selectAnalyticalAssaysList(well_id);
  63. List<HashMap<String, Object>> analyticalAssaysSummary = wellInfoService.selectAnalyticalAssaysSummary(well_id);
  64. List<HashMap<String, Object>> historyAssignmentList = wellInfoService.selectHistoryAssignmentList(well_id);
  65. List<HashMap<String, Object>> historyAssignmentSummary = wellInfoService.selectHistoryAssignmentSummary(well_id);
  66. HashMap<String, Object> lastHistoryAssignment = wellInfoService.getLastHistoryAssignment(well_id);
  67. List<HashMap<String, Object>> dataIndexList = wellInfoService.selectDataIndexList(well_id);
  68. HashMap<String, Object> result = new HashMap<>();
  69. result.put("dataModel", wellInfo);
  70. result.put("boreholeInterList", boreholeInterList);//业务解释列表
  71. result.put("testHistoryList", testHistoryList);//测试历史列表
  72. result.put("testHistorySummary", testHistorySummary);//测试历史汇总
  73. result.put("lastTestHistory", lastTestHistory);//最后一次测试历史
  74. result.put("analyticalAssaysList", analyticalAssaysList);//分析化验列表
  75. result.put("analyticalAssaysSummary", analyticalAssaysSummary);//分析化验汇总
  76. result.put("historyAssignmentList", historyAssignmentList);//作业简史列表
  77. result.put("historyAssignmentSummary", historyAssignmentSummary);//作业简史汇总
  78. result.put("lastHistoryAssignment", lastHistoryAssignment);//最后一次作业简史记录
  79. result.put("dataIndexList", dataIndexList);
  80. return RespGenerstor.success(result);
  81. }
  82. @ResponseBody
  83. @PostMapping("/saveExpendSetting")
  84. public BaseResponse saveExpendSetting(@RequestBody WlUserExpendSetting model) {
  85. int count = 0;
  86. try {
  87. model.setUserID(accountService.getLoginUserID());
  88. count = wellInfoService.saveExpendSetting(model);
  89. } catch (Exception e) {
  90. return RespGenerstor.fail("-1", "程序异常:" + e.getMessage());
  91. }
  92. return RespGenerstor.success(count);
  93. }
  94. @GetMapping("/getExpendSetting")
  95. public BaseResponse getExpendSetting(String wellId) {
  96. return RespGenerstor.success(wellInfoService.getExpendSetting(wellId, accountService.getLoginUserID()));
  97. }
  98. @GetMapping("/getWellDocumentList")
  99. public BaseResponse getWellDocumentList(String wellId) {
  100. List<HashMap<String, Object>> dataIndexList = wellInfoService.selectDataIndexList(wellId);
  101. return RespGenerstor.success(dataIndexList);
  102. }
  103. @GetMapping("/getConstructUnitTree")
  104. public BaseResponse getConstructUnitTree() {
  105. return RespGenerstor.success(wellInfoService.getConstructUnitTree());
  106. }
  107. @GetMapping("/downFile")
  108. public void downFile(HttpServletResponse response, String well_id, String fileName) throws IOException {
  109. Map<String, String> getParams = new HashMap<>();
  110. getParams.put("path", "1");
  111. String reData = remoteHelper.getJson(getParams, appConfig.hdfshelperurl + "read", "UTF-8");
  112. byte[] bytes = Base64.getDecoder().decode(reData);
  113. OutputStream os = response.getOutputStream();
  114. response.setContentType("application/force-download");// 设置强制下载不打开
  115. response.setContentType("multipart/form-data;charset=UTF-8");
  116. response.setHeader("Content-Length", String.valueOf(bytes.length));
  117. response.addHeader("Content-Disposition",
  118. "attachment;fileName=" + URLEncoder.encode(fileName, "UTF-8"));// 设置文件名
  119. //os.write(reData.getBytes(StandardCharsets.UTF_8));
  120. os.write(Base64.getDecoder().decode(reData));
  121. if (null != os) {
  122. os.flush();
  123. os.close();
  124. }
  125. }
  126. }