From 30a143f368dd2ff6e9c27b9d5dd17923ffed03ae Mon Sep 17 00:00:00 2001 From: zss <zss@example.com> Date: 星期四, 01 八月 2024 18:59:12 +0800 Subject: [PATCH] 检验单增加外部委托编号+报告批量下载批量上传 --- inspect-server/src/main/resources/mapper/InsSampleMapper.xml | 1 user-server/src/main/java/com/yuanchu/mom/mapper/UserMapper.java | 1 inspect-server/src/main/java/com/yuanchu/mom/pojo/InsOrder.java | 9 + inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsReportServiceImpl.java | 217 ++++++++++++++++++++++++++---- inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderServiceImpl.java | 17 ++ user-server/src/main/resources/mapper/UserMapper.xml | 3 framework/src/main/java/com/yuanchu/mom/utils/GiveCode.java | 14 ++ inspect-server/src/main/java/com/yuanchu/mom/controller/InsReportController.java | 17 ++ inspect-server/src/main/java/com/yuanchu/mom/service/impl/StandardProductListServiceImpl.java | 97 +++++++------ inspect-server/src/main/resources/mapper/InsOrderMapper.xml | 1 system-run/src/main/java/com/yuanchu/mom/backup/MysqlDataBackup.java | 11 + user-server/src/main/java/com/yuanchu/mom/service/UserService.java | 2 framework/src/main/java/com/yuanchu/mom/mapper/SystemLogMapper.java | 3 inspect-server/src/main/java/com/yuanchu/mom/controller/InsOrderController.java | 6 user-server/src/main/java/com/yuanchu/mom/service/impl/UserServiceImp.java | 5 inspect-server/src/main/java/com/yuanchu/mom/service/InsReportService.java | 6 16 files changed, 326 insertions(+), 84 deletions(-) diff --git a/framework/src/main/java/com/yuanchu/mom/mapper/SystemLogMapper.java b/framework/src/main/java/com/yuanchu/mom/mapper/SystemLogMapper.java index fc5f555..045f040 100644 --- a/framework/src/main/java/com/yuanchu/mom/mapper/SystemLogMapper.java +++ b/framework/src/main/java/com/yuanchu/mom/mapper/SystemLogMapper.java @@ -28,5 +28,8 @@ @Select("select coalesce(count(id), 0) from ${tableName} where examine_time like concat('%', #{date}, '%') and laboratory=#{laboratory} and company_id=#{companyId}") int countRowsByNow3(String tableName, Long companyId, String laboratory, String date); + + @Select("select coalesce(count(id), 0) from ${tableName} where create_time like concat('%', #{date}, '%') and laboratory=#{laboratory} and company_id=#{companyId}") + int countRowsByNow4(String tableName, Long companyId, String laboratory, String date); } diff --git a/framework/src/main/java/com/yuanchu/mom/utils/GiveCode.java b/framework/src/main/java/com/yuanchu/mom/utils/GiveCode.java index c5ee8ce..54eaa1d 100644 --- a/framework/src/main/java/com/yuanchu/mom/utils/GiveCode.java +++ b/framework/src/main/java/com/yuanchu/mom/utils/GiveCode.java @@ -40,4 +40,18 @@ return code + (date2 == null ? date : date2) + symbol + nums; } + //妫�楠屽崟鐢熸垚澶栭儴濮旀墭缂栧彿鐨勮鍒� + public String giveCode3(String code, Long companyId, String laboratory, String tableName, String symbol, String patten) { + String date = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")); + String date2 = LocalDate.now().format(DateTimeFormatter.ofPattern(patten)); + int num; + num = systemLogMapper.countRowsByNow4(tableName, companyId, laboratory, LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM"))) + 1; + String nums = num + ""; + if (nums.length() == 1) nums = "0000" + num; + else if (nums.length() == 2) nums = "000" + num; + else if (nums.length() == 3) nums = "00" + num; + else if (nums.length() == 4) nums = "0" + num; + return code + (date2 == null ? date : date2) + symbol + nums; + } + } diff --git a/inspect-server/src/main/java/com/yuanchu/mom/controller/InsOrderController.java b/inspect-server/src/main/java/com/yuanchu/mom/controller/InsOrderController.java index d2a612e..8681513 100644 --- a/inspect-server/src/main/java/com/yuanchu/mom/controller/InsOrderController.java +++ b/inspect-server/src/main/java/com/yuanchu/mom/controller/InsOrderController.java @@ -51,12 +51,6 @@ return Result.success(insOrderService.selectInsOrderParameter(page, sampleOrderDto)); } -// @ValueClassify("妫�楠屼笅鍗�") -// @ApiOperation(value = "鏌ョ湅鎵�鏈夋楠屽崟") -// @PostMapping("/selectAllInsOrder") -// public Result selectAllInsOrder(){ -// return Result.success(); -// } @ValueClassify("妫�楠屼笅鍗�") @ApiOperation(value = "妫�楠屽垎閰�") diff --git a/inspect-server/src/main/java/com/yuanchu/mom/controller/InsReportController.java b/inspect-server/src/main/java/com/yuanchu/mom/controller/InsReportController.java index 8e450da..14518a5 100644 --- a/inspect-server/src/main/java/com/yuanchu/mom/controller/InsReportController.java +++ b/inspect-server/src/main/java/com/yuanchu/mom/controller/InsReportController.java @@ -21,6 +21,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.IOException; import java.io.PrintWriter; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -63,7 +64,7 @@ pathName = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyMMddHHmmss")) + "_" + file.getOriginalFilename(); urlString = realpath + "/" + pathName; file.transferTo(new File(urlString)); - return Result.success(insReportService.inReport("/word/"+pathName, id)); + return Result.success(insReportService.inReport("/word/" + pathName, id)); } catch (Exception e) { throw new ErrorException("鏂囦欢涓婁紶澶辫触"); } @@ -133,4 +134,18 @@ writer.write("{\"error\":0}"); } } + + @ValueAuth + @ApiOperation(value = "鎶ュ憡鎵归噺涓嬭浇") + @GetMapping("/downAll") + public Result downAll(String ids) { + return Result.success(insReportService.downAll(ids)); + } + + @ValueAuth + @ApiOperation(value = "鎶ュ憡鎵归噺涓婁紶") + @PostMapping("/upAll") + public Result upAll(MultipartFile file) throws IOException { + return Result.success(insReportService.upAll(file)); + } } diff --git a/inspect-server/src/main/java/com/yuanchu/mom/pojo/InsOrder.java b/inspect-server/src/main/java/com/yuanchu/mom/pojo/InsOrder.java index c57bf45..0d521fd 100644 --- a/inspect-server/src/main/java/com/yuanchu/mom/pojo/InsOrder.java +++ b/inspect-server/src/main/java/com/yuanchu/mom/pojo/InsOrder.java @@ -34,6 +34,15 @@ @Length(max= 255,message="缂栫爜闀垮害涓嶈兘瓒呰繃255") private String entrustCode; + /** + * 澶栭儴濮旀墭缂栧彿 + */ + @ValueTableShow(1) + @Size(max= 255,message="缂栫爜闀垮害涓嶈兘瓒呰繃255") + @ApiModelProperty(value = "澶栭儴濮旀墭缂栧彿") + @Length(max= 255,message="缂栫爜闀垮害涓嶈兘瓒呰繃255") + private String outEntrustCode; + @Size(max= 255,message="缂栫爜闀垮害涓嶈兘瓒呰繃255") @ApiModelProperty(value = "妫�楠岀被鍒�") @Length(max= 255,message="缂栫爜闀垮害涓嶈兘瓒呰繃255") diff --git a/inspect-server/src/main/java/com/yuanchu/mom/service/InsReportService.java b/inspect-server/src/main/java/com/yuanchu/mom/service/InsReportService.java index 0b1a01e..886075e 100644 --- a/inspect-server/src/main/java/com/yuanchu/mom/service/InsReportService.java +++ b/inspect-server/src/main/java/com/yuanchu/mom/service/InsReportService.java @@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.yuanchu.mom.dto.ReportPageDto; import com.yuanchu.mom.pojo.InsReport; +import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.Map; /** @@ -32,4 +34,8 @@ int ratifyReport(Integer id, Integer isRatify, String ratifyTell); int wordInsertUrl(Map<String, Object> map, String url); + + String downAll(String ids); + + int upAll(MultipartFile file) throws IOException; } diff --git a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderServiceImpl.java b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderServiceImpl.java index 2876dd4..18e437b 100644 --- a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderServiceImpl.java +++ b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderServiceImpl.java @@ -158,8 +158,21 @@ @Transactional(rollbackFor = Exception.class) public int addInsOrder(List<SampleProductDto> list, InsOrder insOrder, List<List<Integer>> pairing) { insOrder.setState(0); - String code = customMapper.selectById(insOrder.getCompanyId()).getCode2(); - //insOrder.setEntrustCode(giveCode.giveCode("JCZX-" + code + "-", "ins_order", "", "yyMMdd")); + //瀹㈡埛浠e彿 + Custom custom = customMapper.selectById(insOrder.getCompanyId()); + String code = custom.getCode2(); + if (!custom.getCompany().equals(insOrder.getCompany())){ + Custom one = customMapper.selectOne(Wrappers.<Custom>lambdaQuery().eq(Custom::getCompany, insOrder.getCompany())); + insOrder.setCompanyId(one.getId()); + code=one.getCode2(); + } + //瀹為獙瀹ょ紪鍙� + String code2 = baseMapper.selLaboratoryCode(insOrder.getLaboratory()); + if (StringUtils.isEmpty(code2)) { + code2 = ""; + } + //澶栭儴濮旀墭缂栧彿 + insOrder.setOutEntrustCode(giveCode.giveCode3("ZT/" + code2 + "-" + code + "-", insOrder.getCompanyId(), insOrder.getLaboratory(), "ins_order", "", "yyMM")); String giveCode = this.giveCode.giveCode("JCZX-" + code + "-", "ins_sample", "", "yyMMdd"); insOrderMapper.insert(insOrder); AtomicInteger count = new AtomicInteger(); diff --git a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsReportServiceImpl.java b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsReportServiceImpl.java index f238926..9800317 100644 --- a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsReportServiceImpl.java +++ b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsReportServiceImpl.java @@ -23,22 +23,30 @@ import com.yuanchu.mom.pojo.InsReport; import com.yuanchu.mom.service.InsReportService; import com.yuanchu.mom.utils.QueryWrappers; +import com.yuanchu.mom.vo.Result; import org.springframework.beans.factory.annotation.Value; import org.springframework.core.io.ClassPathResource; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.imageio.ImageIO; -import java.awt.*; import java.awt.image.BufferedImage; import java.io.*; import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; import java.time.LocalDateTime; -import java.util.HashMap; -import java.util.Map; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.List; import java.util.concurrent.CompletableFuture; +import java.util.stream.Collectors; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; +import java.util.zip.ZipOutputStream; /** * @author Administrator @@ -189,7 +197,7 @@ put("seal1", Pictures.ofLocal(imgUrl + "/" + sealUrl).create()); put("seal2", Pictures.ofLocal(imgUrl + "/" + sealUrl).create()); }}, finalUrl); - wordToPdf(finalUrl,sealUrl); + wordToPdf(finalUrl, sealUrl); /* String replace = finalUrl.replace(".docx", ".pdf"); CompletableFuture.supplyAsync(() -> { @@ -223,11 +231,161 @@ return 1; } + + //鎶ュ憡鎵归噺涓嬭浇 @Override - public void wordToPdf(String path,String sealUrl) { + @Transactional(rollbackFor = Exception.class) + public String downAll(String ids) { + List<Long> list = Arrays.stream(ids.split(",")).map(Long::parseLong).collect(Collectors.toList()); + List<InsReport> insReports = insReportMapper.selectBatchIds(list); + String zipFilePath = null; + // 涓存椂鏂囦欢澶硅矾寰� + try { + String tempFolderPath = wordUrl + "/tempFolder"; + File tempFolder = new File(tempFolderPath); + if (tempFolder.exists()) { + deleteDirectory(tempFolder); // 鍒犻櫎鏃х殑涓存椂鏂囦欢澶� + } + tempFolder.mkdirs(); // 鍒涘缓鏂扮殑涓存椂鏂囦欢澶� + for (InsReport insReport : insReports) { + File sourceFile = new File((ObjectUtils.isNotEmpty(insReport.getUrlS()) ? insReport.getUrlS() : insReport.getUrl()).replace("/word", wordUrl)); + File destinationFile = new File(tempFolder, sourceFile.getName()); + Files.copy(sourceFile.toPath(), destinationFile.toPath(), StandardCopyOption.REPLACE_EXISTING); + } + // 鍘嬬缉涓存椂鏂囦欢澶� + zipFilePath = wordUrl + "/zip/output.zip"; + zipDirectory(tempFolderPath, zipFilePath); + + // 娓呯悊涓存椂鏂囦欢澶� + deleteDirectory(tempFolder); + + System.out.println("ZIP鏂囦欢鍒涘缓瀹屾垚锛�"); + } catch (IOException e) { + e.printStackTrace(); + } + return "/word/zip/output.zip"; + } + + //鎵归噺涓婁紶 + @Override + @Transactional(rollbackFor = Exception.class) + public int upAll(MultipartFile file) throws IOException { + File tempFile = null; + File unzipDir = null; + try { + tempFile = File.createTempFile(wordUrl, ".zip"); + file.transferTo(tempFile); + + unzipDir = new File("uploaded_files"); + if (!unzipDir.exists()) { + unzipDir.mkdir(); + } + unzip(tempFile, unzipDir); + // 澶勭悊瑙e帇鍚庣殑鏂囦欢 + File[] files = unzipDir.listFiles(); + if (files != null) { + for (File f : files) { + // 鏍规嵁鏂囦欢鍚嶆煡璇d + String name = f.getName(); + InsReport insReport = insReportMapper.selectOne(Wrappers.<InsReport>lambdaQuery().like(InsReport::getCode, f.getName().replace(".docx", "").replace("JCZX", "JCZX/"))); + if (ObjectUtils.isEmpty(insReport)) { + throw new ErrorException("娌℃湁鎵惧埌 " + f.getName() + " 杩欎釜鏂囦欢瀵瑰簲鐨勬姤鍛婃暟鎹�"); + } + String urlString; + String pathName; + try { + String path = wordUrl; + File realpath = new File(path); + if (!realpath.exists()) { + realpath.mkdirs(); + } + pathName = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyMMddHHmmss")) + "_" + f.getName(); + urlString = realpath + "/" + pathName; + // 澶嶅埗鏂囦欢鍒版寚瀹氳矾寰� + Files.copy(f.toPath(), new File(urlString).toPath(), StandardCopyOption.REPLACE_EXISTING); + inReport("/word/" + pathName, insReport.getId()); + } + catch (IOException e) { + throw new ErrorException("鏂囦欢涓婁紶澶辫触"); + } + } + } + } catch (IOException e) { + throw new ErrorException("鏂囦欢澶勭悊澶辫触"); + } finally { + if (tempFile != null && tempFile.exists()) { + tempFile.delete(); + } + // 閫掑綊鍒犻櫎瑙e帇鐩綍鍙婂叾涓殑鏂囦欢 + if (unzipDir.exists()) { + deleteDirectory(unzipDir); // 鍒犻櫎鏃х殑涓存椂鏂囦欢澶� + } + } + return 0; + } + + + //瑙e帇鏂囦欢澶� + private void unzip(File zipFile, File destDir) throws IOException { + try (ZipFile zip = new ZipFile(zipFile)) { + Enumeration<? extends ZipEntry> entries = zip.entries(); + while (entries.hasMoreElements()) { + ZipEntry entry = entries.nextElement(); + File file = new File(destDir, entry.getName()); + if (entry.isDirectory()) { + file.mkdirs(); + } else { + file.getParentFile().mkdirs(); + try (InputStream in = zip.getInputStream(entry); + OutputStream out = new FileOutputStream(file)) { + byte[] buffer = new byte[1024]; + int len; + while ((len = in.read(buffer)) > 0) { + out.write(buffer, 0, len); + } + } + } + } + } + } + + // 鍘嬬缉鏂囦欢澶� + public static void zipDirectory(String sourceDirPath, String zipFilePath) throws IOException { + try (ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(zipFilePath))) { + Path sourceDir = Paths.get(sourceDirPath); + Files.walk(sourceDir) + .filter(path -> !Files.isDirectory(path)) + .forEach(path -> { + ZipEntry zipEntry = new ZipEntry(sourceDir.relativize(path).toString()); + try { + zipOut.putNextEntry(zipEntry); + Files.copy(path, zipOut); + zipOut.closeEntry(); + } catch (IOException e) { + e.printStackTrace(); + } + }); + } + } + + // 鍒犻櫎鏂囦欢澶瑰強鍏跺唴瀹� + public static void deleteDirectory(File directory) throws IOException { + if (directory.isDirectory()) { + File[] files = directory.listFiles(); + if (files != null) { + for (File file : files) { + deleteDirectory(file); + } + } + } + Files.delete(directory.toPath()); + } + + @Override + public void wordToPdf(String path, String sealUrl) { CompletableFuture.supplyAsync(() -> { try { - wordToPdf(path, path.replace(".docx", ".pdf"),sealUrl); + wordToPdf(path, path.replace(".docx", ".pdf"), sealUrl); return null; } catch (Exception e) { throw new ErrorException("杞崲澶辫触"); @@ -239,7 +397,7 @@ }); } - public String wordToPdf(String wordPath, String pdfPath,String sealUrl) { + public String wordToPdf(String wordPath, String pdfPath, String sealUrl) { FileOutputStream os = null; try { //鍑瘉 涓嶇劧鍒囨崲鍚庢湁姘村嵃 @@ -264,14 +422,14 @@ return null; } //鐢熸垚涓�涓┖鐨凱DF鏂囦欢 - File file = new File(pdfPath.replace(".pdf","-1.pdf")); + File file = new File(pdfPath.replace(".pdf", "-1.pdf")); os = new FileOutputStream(file); //瑕佽浆鎹㈢殑word鏂囦欢 com.aspose.words.Document doc = new com.aspose.words.Document(wordPath); doc.save(os, SaveFormat.PDF); //娣诲姞楠戠紳绔� - stamperCheckMarkPDF(pdfPath.replace(".pdf","-1.pdf"),pdfPath,imgUrl + "/" +sealUrl); + stamperCheckMarkPDF(pdfPath.replace(".pdf", "-1.pdf"), pdfPath, imgUrl + "/" + sealUrl); } catch (Exception e) { @@ -290,26 +448,27 @@ /** * 鍒囧壊鍥剧墖 - * @param Path 鍥剧墖璺緞 - * @param n 鍒囧壊浠芥暟 + * + * @param Path 鍥剧墖璺緞 + * @param n 鍒囧壊浠芥暟 */ public static com.itextpdf.text.Image[] slicingImages(String Path, int n) throws IOException, BadElementException { - com.itextpdf.text.Image[] nImage = new com.itextpdf.text.Image[n]; + com.itextpdf.text.Image[] nImage = new com.itextpdf.text.Image[n]; BufferedImage img = ImageIO.read(new File(Path)); int h = img.getHeight(); int w = img.getWidth(); - int sw = w/n; - for(int i=0;i<n;i++){ + int sw = w / n; + for (int i = 0; i < n; i++) { BufferedImage subImg; - if(i==n-1){//鏈�鍚庡墿浣欓儴鍒� - subImg = img.getSubimage(i * sw, 0, w-i*sw, h); - }else {//鍓峮-1鍧楀潎鍖�鍒� + if (i == n - 1) {//鏈�鍚庡墿浣欓儴鍒� + subImg = img.getSubimage(i * sw, 0, w - i * sw, h); + } else {//鍓峮-1鍧楀潎鍖�鍒� subImg = img.getSubimage(i * sw, 0, sw, h); } ByteArrayOutputStream out = new ByteArrayOutputStream(); - ImageIO.write(subImg,Path.substring(Path.lastIndexOf('.')+1),out); + ImageIO.write(subImg, Path.substring(Path.lastIndexOf('.') + 1), out); nImage[i] = com.itextpdf.text.Image.getInstance(out.toByteArray()); } @@ -317,30 +476,30 @@ } /** - * 鐩栭獞缂濈珷 + * 鐩栭獞缂濈珷 * - * @param infilePath 鍘烶DF璺緞 - * @param outFilePath 杈撳嚭PDF璺緞 + * @param infilePath 鍘烶DF璺緞 + * @param outFilePath 杈撳嚭PDF璺緞 */ - public static void stamperCheckMarkPDF(String infilePath,String outFilePath,String picPath) throws IOException, DocumentException { + public static void stamperCheckMarkPDF(String infilePath, String outFilePath, String picPath) throws IOException, DocumentException { PdfReader reader = new PdfReader(infilePath);//閫夋嫨闇�瑕佸嵃绔犵殑pdf PdfStamper stamp = new PdfStamper(reader, new FileOutputStream(outFilePath));//鍔犲畬鍗扮珷鍚庣殑pdf com.itextpdf.text.Rectangle pageSize = reader.getPageSize(1);//鑾峰緱绗竴椤� float height = pageSize.getHeight(); - float width = pageSize.getWidth(); + float width = pageSize.getWidth(); int nums = reader.getNumberOfPages(); - com.itextpdf.text.Image[] nImage = slicingImages(picPath,nums);//鐢熸垚楠戠紳绔犲垏鍓插浘鐗� + com.itextpdf.text.Image[] nImage = slicingImages(picPath, nums);//鐢熸垚楠戠紳绔犲垏鍓插浘鐗� - for(int n=1;n<=nums;n++){ + for (int n = 1; n <= nums; n++) { PdfContentByte over = stamp.getOverContent(n);//璁剧疆鍦ㄧ鍑犻〉鎵撳嵃鍗扮珷 - com.itextpdf.text.Image img = nImage[n-1];//閫夋嫨鍥剧墖 + com.itextpdf.text.Image img = nImage[n - 1];//閫夋嫨鍥剧墖 float newHeight = 100f; - float newWidth = img.getWidth()/(img.getHeight()/100); - img.scaleAbsolute(newWidth,newHeight);//鎺у埗鍥剧墖澶у皬 - img.setAbsolutePosition(width-newWidth,height/2-newHeight/2);//鎺у埗鍥剧墖浣嶇疆 + float newWidth = img.getWidth() / (img.getHeight() / 100); + img.scaleAbsolute(newWidth, newHeight);//鎺у埗鍥剧墖澶у皬 + img.setAbsolutePosition(width - newWidth, height / 2 - newHeight / 2);//鎺у埗鍥剧墖浣嶇疆 over.addImage(img); } stamp.close(); diff --git a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/StandardProductListServiceImpl.java b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/StandardProductListServiceImpl.java index 4169a84..ced1edd 100644 --- a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/StandardProductListServiceImpl.java +++ b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/StandardProductListServiceImpl.java @@ -69,14 +69,20 @@ String[] split = insSample.getFactory().split(" - "); String tree = split[0] + " - " + split[1] + " - " + split[2] + " - " + split[3] + " - null"; list = standardProductListMapper.selectDetail2(insSample.getStandardMethodListId(), 1, tree); - if (list.size()==0){ - String tree1 = split[0] + " - " + split[1] + " - " + split[2] + " - null - " + split[3] ; + if (list.size() == 0) { + String tree1 = split[0] + " - " + split[1] + " - " + split[2] + " - null - " + split[3]; list = standardProductListMapper.selectDetail2(insSample.getStandardMethodListId(), 1, tree1); } } String[] split1 = insSample.getFactory().split(" - "); - if (ObjectUtils.isNotEmpty(split1[3])){ - list = list.stream().filter(list1 -> list1.getSample().equals(split1[3])).collect(Collectors.toList()); + //鍒ゆ柇闀垮害 + if (split1.length > 3) { + if (ObjectUtils.isNotEmpty(split1[3])) { + list = list.stream().filter(list1 -> list1.getSample().equals(split1[3])).collect(Collectors.toList()); + }else if (split1[3].equals("")) { + list = list.stream().filter(list1 -> list1.getSampleType().equals(split1[2])).collect(Collectors.toList()); + + } } list = list.stream().filter(a -> { try { @@ -147,9 +153,9 @@ @Transactional(rollbackFor = Exception.class) public Map<String, Object> selectStandardProductListByMethodId(Integer id, String tree, Integer page) { String[] trees = tree.split(" - "); - try{ + try { String tree1 = trees[2]; - }catch (Exception e){ + } catch (Exception e) { throw new ErrorException("鎿嶄綔澶揩,绯荤粺浼犲弬閿欒!!!!"); } List<StandardProductList> list = new ArrayList<>(); @@ -183,7 +189,8 @@ list.addAll(standardTreeMapper.selectStandardProductListByTree("\"" + trees[2] + "\"", standardTree2.getSample(), standardTree2.getModel(), tree2, trees[1])); list.addAll(standardTreeMapper.selectStandardProductListByTree2("\"" + trees[2] + "\",\"" + standardTree2.getSample() + "\"", standardTree2.getSample(), standardTree2.getModel(), tree2, trees[1])); } - } else if (trees.length == 4) { + } + else if (trees.length == 4) { List<StandardTree> treeList = standardTreeMapper.selectList(Wrappers.<StandardTree>lambdaQuery().eq(StandardTree::getLaboratory, trees[1]).eq(StandardTree::getSampleType, trees[2]).eq(StandardTree::getSample, trees[3])); if (treeList.size() == 0) { StandardTree standardTree = new StandardTree(); @@ -198,7 +205,8 @@ list.addAll(standardTreeMapper.selectStandardProductListByTree("\"" + trees[2] + "\"", standardTree.getSample(), standardTree.getModel(), str, trees[1])); list.addAll(standardTreeMapper.selectStandardProductListByTree2("\"" + trees[2] + "\",\"" + trees[3] + "\"", standardTree.getSample(), standardTree.getModel(), str, trees[1])); } - } else { + } + else { list.addAll(standardTreeMapper.selectStandardProductListByTree("\"" + trees[2] + "\"", trees[3].equals("null") ? null : trees[3], trees[4], tree, trees[1])); list.addAll(standardTreeMapper.selectStandardProductListByTree2("\"" + trees[2] + "\",\"" + trees[3] + "\"", trees[3].equals("null") ? null : trees[3], trees[4], tree, trees[1])); } @@ -249,45 +257,46 @@ if (page == 1) { Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId"); // CompletableFuture.supplyAsync(() -> { - System.out.println("寮�濮嬪紑濮嬪紑濮嬪紑濮�!!!!!!!!!!"); - if (trees.length == 5) { - standardProductListMapper.delete(Wrappers.<StandardProductList>lambdaUpdate() - .eq(StandardProductList::getStandardMethodListId, id) - .eq(StandardProductList::getTree, tree)); - } else { - standardProductListMapper.delete(Wrappers.<StandardProductList>lambdaUpdate() - .eq(StandardProductList::getStandardMethodListId, id) - .like(StandardProductList::getTree, tree)); - } + System.out.println("寮�濮嬪紑濮嬪紑濮嬪紑濮�!!!!!!!!!!"); + if (trees.length == 5) { + standardProductListMapper.delete(Wrappers.<StandardProductList>lambdaUpdate() + .eq(StandardProductList::getStandardMethodListId, id) + .eq(StandardProductList::getTree, tree)); + } else { + standardProductListMapper.delete(Wrappers.<StandardProductList>lambdaUpdate() + .eq(StandardProductList::getStandardMethodListId, id) + .like(StandardProductList::getTree, tree)); + } - boolean success = false; - int retryCount = 0; - while (!success && retryCount < 100) { - try { - standardProductListService2.saveBatch(list.stream().map(a -> { - a.setFactory(trees[0]); - a.setLaboratory(trees[1]); - a.setSampleType(trees[2]); - a.setCreateUser(userId); - a.setUpdateUser(userId); - a.setStandardMethodListId(id); - return a; - }).collect(Collectors.toList()));; - success = true; - } catch (Exception e) { - retryCount++; - System.out.println("閲嶅"+ retryCount+"娆�"); - // 澶勭悊閲嶅 ID 鐨勮褰曪紝閲嶆柊鐢熸垚 ID 骞剁户缁皾璇曟彃鍏� - for (StandardProductList productList : list) { - productList.setId(IdWorker.getId()); - } + boolean success = false; + int retryCount = 0; + while (!success && retryCount < 100) { + try { + standardProductListService2.saveBatch(list.stream().map(a -> { + a.setFactory(trees[0]); + a.setLaboratory(trees[1]); + a.setSampleType(trees[2]); + a.setCreateUser(userId); + a.setUpdateUser(userId); + a.setStandardMethodListId(id); + return a; + }).collect(Collectors.toList())); + ; + success = true; + } catch (Exception e) { + retryCount++; + System.out.println("閲嶅" + retryCount + "娆�"); + // 澶勭悊閲嶅 ID 鐨勮褰曪紝閲嶆柊鐢熸垚 ID 骞剁户缁皾璇曟彃鍏� + for (StandardProductList productList : list) { + productList.setId(IdWorker.getId()); } } - if (!success) { - throw new RuntimeException("鎻掑叆澶辫触"); - }else { - System.out.println("缁撴潫缁撴潫缁撴潫缁撴潫@@@@@@@@@@@@"); - } + } + if (!success) { + throw new RuntimeException("鎻掑叆澶辫触"); + } else { + System.out.println("缁撴潫缁撴潫缁撴潫缁撴潫@@@@@@@@@@@@"); + } /* standardProductListService2.saveBatch(list.stream().map(a -> { a.setFactory(trees[0]); diff --git a/inspect-server/src/main/resources/mapper/InsOrderMapper.xml b/inspect-server/src/main/resources/mapper/InsOrderMapper.xml index 9aa7a27..681ec55 100644 --- a/inspect-server/src/main/resources/mapper/InsOrderMapper.xml +++ b/inspect-server/src/main/resources/mapper/InsOrderMapper.xml @@ -6,6 +6,7 @@ <resultMap id="BaseResultMap" type="com.yuanchu.mom.pojo.InsOrder"> <id property="id" column="id" jdbcType="INTEGER"/> <result property="entrustCode" column="entrust_code" jdbcType="VARCHAR"/> + <result property="outEntrustCode" column="out_entrust_code" jdbcType="VARCHAR"/> <result property="custom" column="custom" jdbcType="VARCHAR"/> <result property="company" column="company" jdbcType="VARCHAR"/> <result property="code" column="code" jdbcType="VARCHAR"/> diff --git a/inspect-server/src/main/resources/mapper/InsSampleMapper.xml b/inspect-server/src/main/resources/mapper/InsSampleMapper.xml index ade36d6..3d68d42 100644 --- a/inspect-server/src/main/resources/mapper/InsSampleMapper.xml +++ b/inspect-server/src/main/resources/mapper/InsSampleMapper.xml @@ -268,6 +268,7 @@ select name_en from `center-lims`.product where name = #{sample} + limit 1 </select> <select id="selectSampleProductListByOrderId2" resultMap="sampleDto"> select isa.*, diff --git a/system-run/src/main/java/com/yuanchu/mom/backup/MysqlDataBackup.java b/system-run/src/main/java/com/yuanchu/mom/backup/MysqlDataBackup.java index 8684946..4eafbf4 100644 --- a/system-run/src/main/java/com/yuanchu/mom/backup/MysqlDataBackup.java +++ b/system-run/src/main/java/com/yuanchu/mom/backup/MysqlDataBackup.java @@ -1,10 +1,14 @@ package com.yuanchu.mom.backup; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.yuanchu.mom.dto.PerformanceShiftAddDto; +import com.yuanchu.mom.mapper.DepartmentLimsMapper; import com.yuanchu.mom.mapper.EnumMapper; +import com.yuanchu.mom.pojo.DepartmentLims; import com.yuanchu.mom.pojo.Enums; import com.yuanchu.mom.pojo.PerformanceShift; import com.yuanchu.mom.pojo.User; +import com.yuanchu.mom.service.DepartmentLimsService; import com.yuanchu.mom.service.EnumService; import com.yuanchu.mom.service.PerformanceShiftService; import com.yuanchu.mom.service.UserService; @@ -81,6 +85,9 @@ @Resource private UserService userService; + + @Resource + private DepartmentLimsMapper departmentLimsMapper; /** * 姣忓ぉ鏅氫笂23鐐�05绉掓墽琛� 銆� 0 0 4 1/1 * ? 銆� @@ -213,8 +220,8 @@ List<Enums> shiftType = enumService.selectEnumByCategory("鐝绫诲瀷"); List<String> collect = shiftType.stream().filter(enums -> enums.getLabel().equals("鏃�")).map(enums -> enums.getValue()).collect(Collectors.toList()); performanceShiftAddDto.setShift(collect.get(0)); - //浜哄憳--鎵�鏈変汉 - String userIds = userService.getDeviceManager().stream().map(user -> user.getId().toString()).distinct().collect(Collectors.joining(",")); + //浜哄憳--(departlims琛ㄧ殑涓や釜瀹為獙瀹ょ殑浜�) + String userIds = userService.getUser().stream().map(user -> user.getId().toString()).distinct().collect(Collectors.joining(",")); performanceShiftAddDto.setUserId(userIds); //鍛ㄦ--褰撴湀鎵�鏈� // 鑾峰彇褰撳墠鏃ユ湡 diff --git a/user-server/src/main/java/com/yuanchu/mom/mapper/UserMapper.java b/user-server/src/main/java/com/yuanchu/mom/mapper/UserMapper.java index e0323b2..1d0ad90 100644 --- a/user-server/src/main/java/com/yuanchu/mom/mapper/UserMapper.java +++ b/user-server/src/main/java/com/yuanchu/mom/mapper/UserMapper.java @@ -23,4 +23,5 @@ User getCustom(Integer userId); + List<User> getUser(); } diff --git a/user-server/src/main/java/com/yuanchu/mom/service/UserService.java b/user-server/src/main/java/com/yuanchu/mom/service/UserService.java index 067fa11..dbcad1a 100644 --- a/user-server/src/main/java/com/yuanchu/mom/service/UserService.java +++ b/user-server/src/main/java/com/yuanchu/mom/service/UserService.java @@ -5,6 +5,7 @@ import com.yuanchu.mom.dto.UserPageDto; import com.yuanchu.mom.pojo.User; +import java.util.Arrays; import java.util.List; import java.util.Map; @@ -41,4 +42,5 @@ int delUserDepardLimsId(Integer id); + List<User> getUser(); } diff --git a/user-server/src/main/java/com/yuanchu/mom/service/impl/UserServiceImp.java b/user-server/src/main/java/com/yuanchu/mom/service/impl/UserServiceImp.java index 6dcc77e..f47fbe9 100644 --- a/user-server/src/main/java/com/yuanchu/mom/service/impl/UserServiceImp.java +++ b/user-server/src/main/java/com/yuanchu/mom/service/impl/UserServiceImp.java @@ -196,4 +196,9 @@ public int delUserDepardLimsId(Integer id) { return userMapper.update(null, Wrappers.<User>lambdaUpdate().eq(User::getId, id).set(User::getDepartLimsId, null).set(User::getUpdateTime, LocalDateTime.now()).set(User::getUpdateUser, getLook.selectPowerByMethodAndUserId(null).get("userId"))); } + + @Override + public List<User> getUser() { + return userMapper.getUser(); + } } diff --git a/user-server/src/main/resources/mapper/UserMapper.xml b/user-server/src/main/resources/mapper/UserMapper.xml index 3a9e863..d249c20 100644 --- a/user-server/src/main/resources/mapper/UserMapper.xml +++ b/user-server/src/main/resources/mapper/UserMapper.xml @@ -44,4 +44,7 @@ left join custom c on u.company = c.id where u.id = #{userId} </select> + <select id="getUser" resultType="com.yuanchu.mom.pojo.User"> + select * from user where depart_lims_id=FIND_IN_SET(depart_lims_id, (select GROUP_CONCAT(id SEPARATOR ',') from department_lims where department_lims.name like '%瀹為獙瀹�')) + </select> </mapper> \ No newline at end of file -- Gitblit v1.9.3