diff --git a/lis-common/src/main/java/com/czlis/common/utils/file/FileUtils.java b/lis-common/src/main/java/com/czlis/common/utils/file/FileUtils.java index c35e11c..b6f2371 100644 --- a/lis-common/src/main/java/com/czlis/common/utils/file/FileUtils.java +++ b/lis-common/src/main/java/com/czlis/common/utils/file/FileUtils.java @@ -11,6 +11,8 @@ import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + +import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.ArrayUtils; import com.czlis.common.config.RuoYiConfig; @@ -28,6 +30,37 @@ public class FileUtils { public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+"; + + public static void writeBytes(HttpServletResponse response,String filePath, OutputStream os) throws IOException + { + FileInputStream fis = null; + try + { + File file = new File(filePath); + if (!file.exists()) + { + throw new FileNotFoundException(filePath); + } + response.setHeader("Content-Length", String.valueOf(file.length())); + fis = new FileInputStream(file); + byte[] b = new byte[1024]; + int length; + while ((length = fis.read(b)) > 0) + { + os.write(b, 0, length); + } + } + catch (IOException e) + { + throw e; + } + finally + { + IOUtils.close(os); + IOUtils.close(fis); + } + } + /** * 输出指定文件的byte数组 * diff --git a/lis-system/src/main/java/com/czlis/system/web/controller/common/CommonController.java b/lis-system/src/main/java/com/czlis/system/web/controller/common/CommonController.java index 6669b88..5017cf1 100644 --- a/lis-system/src/main/java/com/czlis/system/web/controller/common/CommonController.java +++ b/lis-system/src/main/java/com/czlis/system/web/controller/common/CommonController.java @@ -55,7 +55,7 @@ public class CommonController { response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); FileUtils.setAttachmentResponseHeader(response, realFileName); - FileUtils.writeBytes(filePath, response.getOutputStream()); + FileUtils.writeBytes(response,filePath, response.getOutputStream()); if (delete) { FileUtils.deleteFile(filePath); } diff --git a/zybgcx/src/main/java/com/czlis/zybgcx/pojo/Web_fs_printReport.java b/zybgcx/src/main/java/com/czlis/zybgcx/pojo/Web_fs_printReport.java index 97d7af2..3806f7f 100644 --- a/zybgcx/src/main/java/com/czlis/zybgcx/pojo/Web_fs_printReport.java +++ b/zybgcx/src/main/java/com/czlis/zybgcx/pojo/Web_fs_printReport.java @@ -27,6 +27,7 @@ public class Web_fs_printReport { private String confirmer; private String sqh; private String bgdh; + private String bgdhTemp; private String xmdh; private String csjg; private String refs; diff --git a/zybgcx/src/main/java/com/czlis/zybgcx/service/impl/ZybgcxServcieImpl.java b/zybgcx/src/main/java/com/czlis/zybgcx/service/impl/ZybgcxServcieImpl.java index a6fe2fe..173685c 100644 --- a/zybgcx/src/main/java/com/czlis/zybgcx/service/impl/ZybgcxServcieImpl.java +++ b/zybgcx/src/main/java/com/czlis/zybgcx/service/impl/ZybgcxServcieImpl.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.util.Collections; import java.util.Date; import java.util.List; +import java.util.stream.Collectors; @Service @Slf4j @@ -101,8 +102,51 @@ public class ZybgcxServcieImpl implements ZybgcxService { @Override public Result getFSResult(Web_fs_printReport webFsPrintReport) { - List webFsPrintReportList = zybgcxMapper.getFSResult(webFsPrintReport); - return new Result("0","获取数据成功!",webFsPrintReportList); + //List webFsPrintReportList = zybgcxMapper.getFSResult(webFsPrintReport); + String bgdhTemp = ""; + String yqdl = webFsPrintReport.getYqdl(); + String brdh = webFsPrintReport.getBrdh(); + List fsResultList = zybgcxMapper.getFSResult(webFsPrintReport); + //查询这个仪器大类数据中包含这个项目的报告单号 + List webFsPrintReportCollect = fsResultList.stream().filter(webFsPrintReport1 -> webFsPrintReport1.getXmdh().equals(webFsPrintReport.getXmdh())).collect(Collectors.toList()); + for (Web_fs_printReport web_fs_printReport : webFsPrintReportCollect) { + bgdhTemp = bgdhTemp + ",'" + web_fs_printReport.getBgdh() + "'"; + } + if(bgdhTemp.length() > 0){ + bgdhTemp = bgdhTemp.substring(1); + } + Web_fs_printReport webFsPrintReport1 = new Web_fs_printReport(); + webFsPrintReport1.setYqdl(yqdl); + webFsPrintReport1.setBrdh(brdh); + webFsPrintReport1.setBgdhTemp(bgdhTemp); + List fsResult = zybgcxMapper.getFSResult(webFsPrintReport1); +// for (Web_fs_printReport web_fs_printReport : fsResultList) { +// bgdhTemp = bgdhTemp + "," + web_fs_printReport.getBgdh(); +// } +// if(bgdhTemp.length() > 0){ +// bgdhTemp = bgdhTemp.substring(1); +// } +// Web_fs_printReport webFsPrintReport1 = new Web_fs_printReport(); +// webFsPrintReport1.setYqdl(yqdl); +// webFsPrintReport1.setBrdh(brdh); + + + +// if(webFsPrintReportList.size() > 0){ +// String yqdl = webFsPrintReportList.get(0).getYqdl(); +// Web_fs_printReport webFsPrintReport1 = new Web_fs_printReport(); +// webFsPrintReport1.setBrdh(webFsPrintReportList.get(0).getBrdh()); +// webFsPrintReport1.setYqdl(yqdl); +// List fsResultList = zybgcxMapper.getFSResult(webFsPrintReport1); +// for (Web_fs_printReport web_fs_printReport : fsResultList) { +// bgdhTemp = bgdhTemp + "," + web_fs_printReport.getBgdh(); +// } +// if(bgdhTemp.length() > 0){ +// bgdhTemp = bgdhTemp.substring(1); +// } +// } + + return new Result("0","获取数据成功!",fsResult); } diff --git a/zybgcx/src/main/resources/mapper/ZybgcxMapper.xml b/zybgcx/src/main/resources/mapper/ZybgcxMapper.xml index 3dc1cdf..f509c60 100644 --- a/zybgcx/src/main/resources/mapper/ZybgcxMapper.xml +++ b/zybgcx/src/main/resources/mapper/ZybgcxMapper.xml @@ -26,9 +26,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"