|
|
|
|
@ -1,26 +1,23 @@
|
|
|
|
|
package com.flossom.system.controller;
|
|
|
|
|
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import javax.servlet.ServletException;
|
|
|
|
|
import javax.servlet.ServletOutputStream;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
|
|
import com.flossom.common.core.domain.R;
|
|
|
|
|
import com.flossom.common.core.domain.entity.WxInstrumentInstructions;
|
|
|
|
|
import com.flossom.common.core.utils.poi.ExcelUtil;
|
|
|
|
|
import com.flossom.common.core.utils.StringUtils;
|
|
|
|
|
import com.flossom.common.core.web.controller.BaseController;
|
|
|
|
|
import com.flossom.common.core.web.domain.AjaxResult;
|
|
|
|
|
import com.flossom.common.core.web.page.TableDataInfo;
|
|
|
|
|
import com.flossom.common.log.annotation.Log;
|
|
|
|
|
import com.flossom.common.log.enums.BusinessType;
|
|
|
|
|
import com.flossom.common.security.annotation.RequiresPermissions;
|
|
|
|
|
import org.apache.commons.io.IOUtils;
|
|
|
|
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
|
|
import org.apache.http.client.methods.HttpGet;
|
|
|
|
|
import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
|
|
import org.apache.http.impl.client.HttpClients;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import com.flossom.system.service.IWxInstrumentInstructionsService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -75,4 +72,35 @@ public class WxInstrumentInstructionsController extends BaseController {
|
|
|
|
|
public AjaxResult remove(@PathVariable Long[] ids) {
|
|
|
|
|
return toAjax(wxInstrumentInstructionsService.deleteWxInstrumentInstructionsByIds(ids));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* TODO: 要求跟原来的一样
|
|
|
|
|
* 预览仪器说明书
|
|
|
|
|
*
|
|
|
|
|
* @param id 仪器id
|
|
|
|
|
* @param type 仪器别名(要求唯一)
|
|
|
|
|
* <p>
|
|
|
|
|
* 另一个方法
|
|
|
|
|
* {@link utilsTest.pdfPreview.PdfPreviewTest#method1(HttpServletResponse, String)}
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("/book")
|
|
|
|
|
public void book(HttpServletResponse response, @RequestParam("type") String type, @RequestParam("id") Integer id) throws IOException, ServletException {
|
|
|
|
|
WxInstrumentInstructions query = new WxInstrumentInstructions();
|
|
|
|
|
query.setInstrumentId(id.longValue());
|
|
|
|
|
query.setName(type);
|
|
|
|
|
List<WxInstrumentInstructions> instructionList = wxInstrumentInstructionsService.selectWxInstrumentInstructionsList(query);
|
|
|
|
|
if (instructionList != null && instructionList.size() > 0 && StringUtils.isNotBlank(instructionList.get(0).getLink())) {
|
|
|
|
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
|
|
|
HttpGet httpGet = new HttpGet(instructionList.get(0).getLink());
|
|
|
|
|
try (CloseableHttpResponse resp = httpClient.execute(httpGet)) {
|
|
|
|
|
InputStream inputStream = resp.getEntity().getContent();
|
|
|
|
|
ServletOutputStream outputStream = response.getOutputStream();
|
|
|
|
|
IOUtils.copy(inputStream, outputStream);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|