123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- package com.bowintek.practice.controller;
- import com.bowintek.practice.AppConfig;
- import com.bowintek.practice.filter.exception.BaseResponse;
- import com.bowintek.practice.filter.exception.RespGenerstor;
- import com.bowintek.practice.model.WlUserExpendSetting;
- import com.bowintek.practice.services.service.AccountService;
- import com.bowintek.practice.services.service.OrganizationService;
- import com.bowintek.practice.services.service.WellInfoService;
- import com.bowintek.practice.util.RemoteHelper;
- import com.bowintek.practice.vo.query.WellInfoParams;
- import com.github.pagehelper.PageInfo;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import javax.servlet.http.HttpServletResponse;
- import java.io.ByteArrayOutputStream;
- import java.io.IOException;
- import java.io.OutputStream;
- import java.net.URLEncoder;
- import java.nio.charset.StandardCharsets;
- import java.util.Base64;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- @RestController
- @RequestMapping(value = "/api/wellInfo")
- public class WellInfoController {
- @Autowired
- private WellInfoService wellInfoService;
- @Autowired
- private OrganizationService organizationService;
- @Autowired
- private AccountService accountService;
- @Autowired
- private RemoteHelper remoteHelper;
- @Autowired
- private AppConfig appConfig;
- @ResponseBody
- @GetMapping("/getList")
- public BaseResponse<PageInfo<HashMap<String, Object>>> getList(@RequestParam("page") int page, @RequestParam("rows") int rows,
- WellInfoParams params) throws Exception {
- PageInfo<HashMap<String, Object>> result = wellInfoService.getList(page, rows, params);
- return RespGenerstor.success(result);
- }
- @ResponseBody
- @GetMapping("/getMapList")
- public BaseResponse<PageInfo<HashMap<String, Object>>> getMapList(@RequestParam("page") int page, @RequestParam("rows") int rows,
- WellInfoParams params) throws Exception {
- PageInfo<HashMap<String, Object>> result = wellInfoService.getMapList(page, rows, params);
- return RespGenerstor.success(result);
- }
- @GetMapping("/getOrganizationTree")
- public BaseResponse getOrganizationTree() {
- return RespGenerstor.success(organizationService.getListTree("HBlQAIBGob"));
- }
- @GetMapping("/getWellInfo")
- public BaseResponse getWellInfo(String well_id) {
- HashMap<String, Object> wellInfo = wellInfoService.getWellInfo(well_id);
- List<HashMap<String, Object>> boreholeInterList = wellInfoService.selectBoreholeInterList(well_id);
- List<HashMap<String, Object>> testHistoryList = wellInfoService.selectTestHistoryList(well_id);
- List<HashMap<String, Object>> testHistorySummary = wellInfoService.selectTestHistorySummary(well_id);
- HashMap<String, Object> lastTestHistory = wellInfoService.getLastTestHistory(well_id);
- List<HashMap<String, Object>> analyticalAssaysList = wellInfoService.selectAnalyticalAssaysList(well_id);
- List<HashMap<String, Object>> analyticalAssaysSummary = wellInfoService.selectAnalyticalAssaysSummary(well_id);
- List<HashMap<String, Object>> historyAssignmentList = wellInfoService.selectHistoryAssignmentList(well_id);
- List<HashMap<String, Object>> historyAssignmentSummary = wellInfoService.selectHistoryAssignmentSummary(well_id);
- HashMap<String, Object> lastHistoryAssignment = wellInfoService.getLastHistoryAssignment(well_id);
- List<HashMap<String, Object>> dataIndexList = wellInfoService.selectDataIndexList(well_id);
- HashMap<String, Object> result = new HashMap<>();
- result.put("dataModel", wellInfo);
- result.put("boreholeInterList", boreholeInterList);//业务解释列表
- result.put("testHistoryList", testHistoryList);//测试历史列表
- result.put("testHistorySummary", testHistorySummary);//测试历史汇总
- result.put("lastTestHistory", lastTestHistory);//最后一次测试历史
- result.put("analyticalAssaysList", analyticalAssaysList);//分析化验列表
- result.put("analyticalAssaysSummary", analyticalAssaysSummary);//分析化验汇总
- result.put("historyAssignmentList", historyAssignmentList);//作业简史列表
- result.put("historyAssignmentSummary", historyAssignmentSummary);//作业简史汇总
- result.put("lastHistoryAssignment", lastHistoryAssignment);//最后一次作业简史记录
- result.put("dataIndexList", dataIndexList);
- return RespGenerstor.success(result);
- }
- @ResponseBody
- @PostMapping("/saveExpendSetting")
- public BaseResponse saveExpendSetting(@RequestBody WlUserExpendSetting model) {
- int count = 0;
- try {
- model.setUserID(accountService.getLoginUserID());
- count = wellInfoService.saveExpendSetting(model);
- } catch (Exception e) {
- return RespGenerstor.fail("-1", "程序异常:" + e.getMessage());
- }
- return RespGenerstor.success(count);
- }
- @GetMapping("/getExpendSetting")
- public BaseResponse getExpendSetting(String wellId) {
- return RespGenerstor.success(wellInfoService.getExpendSetting(wellId, accountService.getLoginUserID()));
- }
- @GetMapping("/getWellDocumentList")
- public BaseResponse getWellDocumentList(String wellId) {
- List<HashMap<String, Object>> dataIndexList = wellInfoService.selectDataIndexList(wellId);
- return RespGenerstor.success(dataIndexList);
- }
- @GetMapping("/getConstructUnitTree")
- public BaseResponse getConstructUnitTree() {
- return RespGenerstor.success(wellInfoService.getConstructUnitTree());
- }
- @GetMapping("/downFile")
- public void downFile(HttpServletResponse response, String well_id, String fileName) throws IOException {
- Map<String, String> getParams = new HashMap<>();
- getParams.put("path", "1");
- String reData = remoteHelper.getJson(getParams, appConfig.hdfshelperurl + "read", "UTF-8");
- byte[] bytes = Base64.getDecoder().decode(reData);
- OutputStream os = response.getOutputStream();
- response.setContentType("application/force-download");// 设置强制下载不打开
- response.setContentType("multipart/form-data;charset=UTF-8");
- response.setHeader("Content-Length", String.valueOf(bytes.length));
- response.addHeader("Content-Disposition",
- "attachment;fileName=" + URLEncoder.encode(fileName, "UTF-8"));// 设置文件名
- //os.write(reData.getBytes(StandardCharsets.UTF_8));
- os.write(Base64.getDecoder().decode(reData));
- if (null != os) {
- os.flush();
- os.close();
- }
- }
- }
|