diff --git a/lab-service-api/lab-dict-api/src/main/java/org/springblade/system/enums/DictBizEnum.java b/lab-service-api/lab-dict-api/src/main/java/org/springblade/system/enums/DictBizEnum.java index 3493c0e..0753eb5 100644 --- a/lab-service-api/lab-dict-api/src/main/java/org/springblade/system/enums/DictBizEnum.java +++ b/lab-service-api/lab-dict-api/src/main/java/org/springblade/system/enums/DictBizEnum.java @@ -84,7 +84,11 @@ public enum DictBizEnum { /** * 数采 */ - DATA_ACQUISITION("data_acquisition") + DATA_ACQUISITION("data_acquisition"), + /** + * 样品处理方式 + */ + SAMPLE_HANDLING("sample_handling") ; diff --git a/lab-service-api/lab-lims-api/src/main/java/org/springblade/lims/entry/Examine.java b/lab-service-api/lab-lims-api/src/main/java/org/springblade/lims/entry/Examine.java index cd9071e..1211fe6 100644 --- a/lab-service-api/lab-lims-api/src/main/java/org/springblade/lims/entry/Examine.java +++ b/lab-service-api/lab-lims-api/src/main/java/org/springblade/lims/entry/Examine.java @@ -231,4 +231,8 @@ public class Examine extends BaseEntity implements Serializable { @TableField(exist = false) private String instrumentId; + + // 样品处理方式 + @TableField(exist = false) + private String sampleHandling; } \ No newline at end of file diff --git a/lab-service-api/lab-lims-api/src/main/java/org/springblade/lims/entry/ExamineResult.java b/lab-service-api/lab-lims-api/src/main/java/org/springblade/lims/entry/ExamineResult.java index c124ef1..13c9c54 100644 --- a/lab-service-api/lab-lims-api/src/main/java/org/springblade/lims/entry/ExamineResult.java +++ b/lab-service-api/lab-lims-api/src/main/java/org/springblade/lims/entry/ExamineResult.java @@ -165,4 +165,7 @@ public class ExamineResult extends BaseEntity implements Serializable { @TableField(exist = false) private String jsonDatas; + + // 合样类型 + private Integer conformityType; } \ No newline at end of file diff --git a/lab-service/lab-lims/src/main/java/org/springblade/lims/config/RedisConfig.java b/lab-service/lab-lims/src/main/java/org/springblade/lims/config/RedisConfig.java new file mode 100644 index 0000000..478fcf0 --- /dev/null +++ b/lab-service/lab-lims/src/main/java/org/springblade/lims/config/RedisConfig.java @@ -0,0 +1,39 @@ +//package org.springblade.lims.config; +// +//import com.fasterxml.jackson.annotation.JsonAutoDetect; +//import com.fasterxml.jackson.annotation.PropertyAccessor; +//import com.fasterxml.jackson.databind.ObjectMapper; +//import org.springframework.cache.annotation.CachingConfigurerSupport; +//import org.springframework.cache.annotation.EnableCaching; +//import org.springframework.context.annotation.Bean; +//import org.springframework.context.annotation.Configuration; +//import org.springframework.data.redis.connection.RedisConnectionFactory; +//import org.springframework.data.redis.core.RedisTemplate; +//import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; +//import org.springframework.data.redis.serializer.StringRedisSerializer; +// +//@Configuration +//@EnableCaching //开启注解 +//public class RedisConfig extends CachingConfigurerSupport { +// /** +// * retemplate相关配置 +// * 序列化配置,如果没有配置序列化的话可能会出现往redis存了值,但是获取不到 +// */ +// @Bean +// public RedisTemplate redisTemplate(RedisConnectionFactory factory) { +// RedisTemplate template = new RedisTemplate<>(); +// template.setConnectionFactory(factory); +// Jackson2JsonRedisSerializer jacksonSeial = new Jackson2JsonRedisSerializer(Object.class); +// ObjectMapper om = new ObjectMapper(); +// om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); +// om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); +// jacksonSeial.setObjectMapper(om); +// template.setValueSerializer(jacksonSeial); +// template.setKeySerializer(new StringRedisSerializer()); +// template.setHashKeySerializer(new StringRedisSerializer()); +// template.setHashValueSerializer(jacksonSeial); +// template.afterPropertiesSet(); +// return template; +// } +//} +// diff --git a/lab-service/lab-lims/src/main/java/org/springblade/lims/config/RedisToolConfig.java b/lab-service/lab-lims/src/main/java/org/springblade/lims/config/RedisToolConfig.java new file mode 100644 index 0000000..5882480 --- /dev/null +++ b/lab-service/lab-lims/src/main/java/org/springblade/lims/config/RedisToolConfig.java @@ -0,0 +1,21 @@ +package org.springblade.lims.config; + +import lombok.RequiredArgsConstructor; +import org.springblade.lims.tools.RedisUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.core.RedisTemplate; + +@Configuration +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) +public class RedisToolConfig { + + private final RedisTemplate redisTemplate; + + @Bean(name = "redisUtil") + public RedisUtil redisUtil() { + return new RedisUtil(redisTemplate); + } + +} diff --git a/lab-service/lab-lims/src/main/java/org/springblade/lims/controller/EntrustController.java b/lab-service/lab-lims/src/main/java/org/springblade/lims/controller/EntrustController.java index c431c11..f2410d1 100644 --- a/lab-service/lab-lims/src/main/java/org/springblade/lims/controller/EntrustController.java +++ b/lab-service/lab-lims/src/main/java/org/springblade/lims/controller/EntrustController.java @@ -64,7 +64,6 @@ import java.util.stream.Collectors; /** * 委托单 - * * @author swj * @since 2022年5月28日14:33:30 */ diff --git a/lab-service/lab-lims/src/main/java/org/springblade/lims/controller/ExamineController.java b/lab-service/lab-lims/src/main/java/org/springblade/lims/controller/ExamineController.java index fbb879d..2f2bd98 100644 --- a/lab-service/lab-lims/src/main/java/org/springblade/lims/controller/ExamineController.java +++ b/lab-service/lab-lims/src/main/java/org/springblade/lims/controller/ExamineController.java @@ -1,8 +1,6 @@ package org.springblade.lims.controller; -import com.alibaba.nacos.common.utils.CollectionUtils; -import com.alibaba.nacos.common.utils.StringUtils; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; @@ -18,8 +16,6 @@ import org.springblade.core.tool.api.R; import org.springblade.lims.ao.CommonAo; import org.springblade.lims.entry.*; import org.springblade.lims.service.*; -import org.springblade.resource.enums.SysTypeEnum; -import org.springblade.resource.feign.IMessageClient; import org.springblade.system.cache.DictBizCache; import org.springblade.system.enums.DictBizEnum; import org.springblade.system.feign.ISysClient; @@ -125,8 +121,9 @@ public class ExamineController extends BladeController { //检验数据 Examine examine = examineService.getById(id); Entrust entrust = service.getById(examine.getEntrustId()); - // 字典获取样品状态 -// String simpleStatus = DictBizCache.getValue(DictBizEnum.SIMPLE_STATUS, examine.getSimpleName().split("-")[1]); + // 字典获取样品处理方式 + String sampleHandling = DictBizCache.getKey(DictBizEnum.SAMPLE_HANDLING.getName(), examine.getSimpleName().split("-")[1]); + examine.setSampleHandling(sampleHandling); examine.setSimpleStatus(entrust.getSimpleState()); if (examine != null) { diff --git a/lab-service/lab-lims/src/main/java/org/springblade/lims/controller/ExamineResultController.java b/lab-service/lab-lims/src/main/java/org/springblade/lims/controller/ExamineResultController.java index 50647bf..673d27e 100644 --- a/lab-service/lab-lims/src/main/java/org/springblade/lims/controller/ExamineResultController.java +++ b/lab-service/lab-lims/src/main/java/org/springblade/lims/controller/ExamineResultController.java @@ -3,6 +3,8 @@ package org.springblade.lims.controller; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.TypeReference; +import com.alibaba.nacos.common.utils.CollectionUtils; +import com.alibaba.nacos.common.utils.StringUtils; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; @@ -2132,7 +2134,7 @@ public class ExamineResultController extends BladeController { } } // 牛结核病γ-干扰素ELISA检测试剂盒---武汉科前生物股份有限公司 - else if ("1570297053211455490".equals(reagentId)) { + else if ("1570297053211455490".equals(reagentId) || "1631222146321997826".equals(reagentId)) { for (int i = 0; i < group; i++) { List>> mapList = new ArrayList<>(); List excels = map.get(i + 1 + ""); @@ -2261,7 +2263,7 @@ public class ExamineResultController extends BladeController { mapResult.put("originResult", code); mapResult1.put("originResult", code); mapResult.put("value", code); - mapResult1.put("value",df.format(v1) + "," + df.format(v2)); + mapResult1.put("value", df.format(v1) + "," + df.format(v2)); int indexNum = (i * 32) + (num * 8 + j) - ((i + 1) * 2); mapResult.put("num", split[indexNum]); mapResult1.put("num", split[indexNum]); @@ -2677,7 +2679,7 @@ public class ExamineResultController extends BladeController { // map1.put("g" + (i + 1), mapList); // } // 不是该试剂的才去赋值检测编号 - if (!"1570297053211455490".equals(reagentId)) { + if (!"1570297053211455490".equals(reagentId) && !"1631222146321997826".equals(reagentId)) { Collections.sort(list, new Comparator>() { @Override public int compare(Map o1, Map o2) { @@ -4483,7 +4485,7 @@ public class ExamineResultController extends BladeController { @PostMapping("/pcrExcel") public R pcrExcel(@RequestBody ExamineResult entry) { List read = JSON.parseArray(entry.getJsonDatas(), PCR2Excel.class); - if (read != null && read.size() > 0) { + if (CollectionUtils.isNotEmpty(read)) { for (int i = 0; i < read.size(); i++) { String ctValue = read.get(i).getCtValue(); String length = ""; @@ -4514,13 +4516,15 @@ public class ExamineResultController extends BladeController { wrapper.eq(ExamineResult::getExamineId, entry.getExamineId().toString()); ExamineResult result = service.getOne(wrapper); if (result != null) { + result.setConformityType(entry.getConformityType()); result.setOriginRecordData(JSON.toJSONString(read)); result.setOriginRecordResult(JSON.toJSONString(read)); result.setExamineDataArr(JSON.toJSONString(read)); service.updateById(result); } else { ExamineResult examineResult = new ExamineResult(); - examineResult.setExamineId(Long.valueOf(entry.getExamineId())); + examineResult.setConformityType(entry.getConformityType()); + examineResult.setExamineId(entry.getExamineId()); examineResult.setOriginRecordData(JSON.toJSONString(read)); examineResult.setOriginRecordResult(JSON.toJSONString(read)); examineResult.setExamineDataArr(JSON.toJSONString(read)); @@ -4803,4 +4807,44 @@ public class ExamineResultController extends BladeController { public R resultPicture(@RequestParam MultipartFile file, @RequestParam(required = false) String examineId) { return R.data(service.resultPicture(file, examineId)); } + + /** + * 合样检测编号处理 + */ + @GetMapping("/handleNum") + public R handleNum(String id, Integer number) { + + Examine examine = examineService.getById(id); + + // 原始检测编号 + String[] nums = examine.getExperieNum().split(","); + + // 合样类型(5合1,,10合1) +// int type = Integer.parseInt(number); + + String res = ""; + if (number > 1) { + // 循环次数 + int count = examine.getSimpleCount() % number == 0 ? examine.getSimpleCount() / number : examine.getSimpleCount() / number + 1; + + for (int i = 0; i < count; i++) { + String start = nums[i * number]; + String end = ""; + if (i * number != nums.length - 1) { + if (i == count - 1) { + String[] split = nums[nums.length - 1].split("-"); + end = "-" + split[split.length - 1]; + } else { + String[] split = nums[(i + 1) * number - 1].split("-"); + end = "-" + split[split.length - 1]; + } + } + res += start + end + ","; + } + } else { + res = examine.getExperieNum(); + } + + return R.data(res); + } } \ No newline at end of file diff --git a/lab-service/lab-lims/src/main/java/org/springblade/lims/controller/LargeScreenController.java b/lab-service/lab-lims/src/main/java/org/springblade/lims/controller/LargeScreenController.java index 1bf18ad..11d04d2 100644 --- a/lab-service/lab-lims/src/main/java/org/springblade/lims/controller/LargeScreenController.java +++ b/lab-service/lab-lims/src/main/java/org/springblade/lims/controller/LargeScreenController.java @@ -1,18 +1,17 @@ package org.springblade.lims.controller; +import com.alibaba.nacos.common.utils.StringUtils; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import io.swagger.annotations.Api; import lombok.AllArgsConstructor; -import org.openxmlformats.schemas.drawingml.x2006.chart.STErrBarType; import org.springblade.core.boot.ctrl.BladeController; -import org.springblade.core.cache.utils.CacheUtil; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; -import org.springblade.lims.Cache.LimsCache; import org.springblade.lims.entry.*; import org.springblade.lims.service.*; +import org.springblade.lims.tools.RedisUtil; import org.springblade.system.cache.DictBizCache; import org.springblade.system.enums.DictBizEnum; import org.springblade.system.feign.ISysClient; @@ -24,12 +23,11 @@ import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.util.*; -import static org.springblade.core.cache.constant.CacheConstant.DEFAULT_CACHE; import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE; /** - * @author swj - * @since 2022年6月1日19:49:10 + * @author + * @since */ @RestController @AllArgsConstructor @@ -49,6 +47,10 @@ public class LargeScreenController extends BladeController { private final ISysClient sysClient; + private final RedisUtil redisUtil; + + private static final String DATA_ACQUISTION_ID = "dataAcquisition:id:"; + /** * 1.本年度委托单完成情况 */ @@ -72,13 +74,12 @@ public class LargeScreenController extends BladeController { int count = entrtrustService.count(wrapper); // 年度计划数量 String yearPlan = sysClient.getParamValue("entrust_year_plan").getData(); - double plan = Double.parseDouble(yearPlan); - double actual = 0.00; - actual += count; + int plan = Integer.parseInt(yearPlan); + // 完成率 double rate = 0; if (plan > 0) { - rate = actual / plan * 100; + rate = (double) count / (double) plan * 100; } // 委托 wrapper.clear(); @@ -131,7 +132,7 @@ public class LargeScreenController extends BladeController { Map map = new HashMap<>(); map.put("yearPlan", yearPlan); map.put("entrustCount", count); - map.put("rate", rate); + map.put("rate", (int)Math.round(rate)); map.put("wt", rate1); map.put("jd", rate2); map.put("zc", rate3); @@ -565,21 +566,26 @@ public class LargeScreenController extends BladeController { */ @GetMapping("/dataAcquisition") public R dataAcquisition(String num) { -// String value = DictBizCache.getValue(DictBizEnum.DATA_ACQUISITION, num); -// System.out.println("value:" + value); - Map map = LimsCache.getDeptChildIds(num); -// Map map = CacheUtil.get(DEFAULT_CACHE, "dataAcquisition:id:", value, Map.class); -// Map map = CacheUtil.get(SYS_CACHE, "dataAcquisition:id:", 10051504 + "-" + 1, Map.class); - System.out.println("map:" + map); + String value = DictBizCache.getValue(DictBizEnum.DATA_ACQUISITION, num); + System.out.println("value:" + value); + + Map map = null; + if (StringUtils.isNotBlank(value)) { + map = (Map)redisUtil.get(SYS_CACHE + "::" + DATA_ACQUISTION_ID + value); + } + System.out.println(map); + if (map != null) { float wd = (float) map.get("wd"); float sd = (float) map.get("sd"); - map.put("wd", (int) (wd + 0.5)); - map.put("sd", (int) (sd + 0.5)); + map.put("temperature", (int) (wd + 0.5)); + map.put("humidity", (int) (sd + 0.5)); } -// System.out.println("温度:" + map.get("wd")); -// System.out.println("湿度:" + map.get("sd")); - System.out.println("map:" + map); + +// Map map = new HashMap(); +// map.put("temperature", 25); +// map.put("humidity", 33); + return R.data(map); } } diff --git a/lab-service/lab-lims/src/main/java/org/springblade/lims/controller/WordToPDF.java b/lab-service/lab-lims/src/main/java/org/springblade/lims/controller/WordToPDF.java index 7133cf2..be4735c 100644 --- a/lab-service/lab-lims/src/main/java/org/springblade/lims/controller/WordToPDF.java +++ b/lab-service/lab-lims/src/main/java/org/springblade/lims/controller/WordToPDF.java @@ -13,6 +13,7 @@ import org.apache.pdfbox.printing.Scaling; import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.springblade.lims.entry.Entrust; import org.springblade.lims.entry.Simple; +import org.springblade.lims.utils.BarcodeUtils; import org.springblade.lims.utils.PrintToPdfUtil; import org.springblade.system.cache.DictBizCache; import org.springblade.system.enums.DictBizEnum; @@ -52,20 +53,22 @@ public class WordToPDF { // // 图片路径集合 // List list = new ArrayList<>(); // -// for (int i = 0; i < 24; i++) { -// StringBuilder stringBuilder = new StringBuilder(); -// stringBuilder.append("编号:").append("aaa").append(i).append(" ") -// .append("方式:").append("eee").append(i).append(" "); -// System.out.println(stringBuilder.toString()); +// for (int i = 0; i < 5; i++) { +// String s = "编号:aaa" + i + "\r\n" + "方式:eee" + i; +//// StringBuilder stringBuilder = new StringBuilder(); +//// stringBuilder.append("编号:").append("aaa").append(i).append("\r\n") +//// .append("方式:").append("eee").append(i); +// System.out.println(s); // // //设置条形码表尾信息 -// BufferedImage image = insertWords(getBarCode("sdsj-" + i), stringBuilder.toString()); +// BufferedImage image = insertWords(getBarCode("sdsj-" + i), s); // // String pathpicture = path + format + "-(" + i + ").png"; // System.out.println(pathpicture); // list.add(pathpicture); // //生成指定的图片 // ImageIO.write(image, "jpg", new File(pathpicture)); +//// BarcodeUtils.createWithText("GVB125828", pathpicture); // } // //将图片存放到pdf中 //// PrintToPdfUtil.toPdf(path, spath + format + ".pdf"); @@ -74,7 +77,8 @@ public class WordToPDF { // simpleHandlePrint(list); // // // 首先将word文件转化为pdf文件 -//// documents4jWordToPdf("C:\\Users\\AAA\\Desktop\\txm.docx", "C:\\Users\\AAA\\Desktop\\txm.pdf"); +// documents4jWordToPdf("C:\\Users\\AAA\\Desktop\\txm.docx", "C:\\Users\\AAA\\Desktop\\txm.pdf"); +// // // // 然后打印pdf文件 //// String pdfFile = "C:\\Users\\AAA\\Desktop\\txm.pdf";//文件路径 @@ -85,6 +89,9 @@ public class WordToPDF { //// if (file.exists() && file.isFile()) { //// file.delete(); //// } +// // 删除生成的所有图片及文件夹 +//// File file2 = new File(spath + format); +//// deleteDirectoryLegacyIO(file2); // } /** @@ -96,26 +103,26 @@ public class WordToPDF { // 获取所有图片 int count = 0; - if (list.size() % 3 == 0) { - count = list.size() / 3; + if (list.size() % 2 == 0) { + count = list.size() / 2; } else { - count = (list.size() / 3) + 1; + count = (list.size() / 2) + 1; } - for (int i = 0; i < count; i++) { Map map = new HashMap<>(); - for (int j = 0; j < 3; j++) { - if ((i * 3) + j <= list.size() - 1) { - String s = list.get((i * 3) + j); + for (int j = 0; j < 2; j++) { + if ((i * 2) + j <= list.size() - 1) { + String s = list.get((i * 2) + j); ImageEntity farView1 = new ImageEntity(); - farView1.setHeight(124);//设置高度 - farView1.setWidth(240);//设置宽度 + farView1.setHeight(166);//设置高度 + farView1.setWidth(365);//设置宽度 farView1.setType(ImageEntity.Data);//类型 FileInputStream fis = null; try { fis = new FileInputStream(new File(s)); byte[] bytes = readInputStream(fis); farView1.setData(bytes); + fis.close(); } catch (Exception e) { e.printStackTrace(); } @@ -127,7 +134,7 @@ public class WordToPDF { result.put("list", resultList); //模板地址 - String handleUrl = "C://Users//AAA//Desktop//ceshi.docx"; + String handleUrl = "C://Users//AAA//Desktop//shuojin//dayin//labelPrint.docx"; // String url = DictBizCache.getKey(DictBizEnum.PRINT_URL.getName(), "simpleHandlePrint"); XWPFDocument doc = null; @@ -182,16 +189,16 @@ public class WordToPDF { return outStream.toByteArray(); } - /** * 通过documents4j 实现word转pdf + * * @param sourcePath 源文件地址 如 /root/example.doc * @param targetPath 目标文件地址 如 /root/example.pdf */ public static void documents4jWordToPdf(String sourcePath, String targetPath) { File inputWord = new File(sourcePath); File outputFile = new File(targetPath); - try { + try { InputStream docxInputStream = new FileInputStream(inputWord); OutputStream outputStream = new FileOutputStream(outputFile); IConverter converter = LocalConverter.builder().build(); @@ -200,16 +207,16 @@ public class WordToPDF { .to(outputStream) .as(DocumentType.PDF).execute(); outputStream.close(); + docxInputStream.close(); } catch (Exception e) { System.out.println("[documents4J] word转pdf失败:{}"); } } - /** * 这里传入的文件为word转化生成的pdf文件 */ - public static void PDFprint(File file ,String printerName) throws Exception { + public static void PDFprint(File file, String printerName) throws Exception { PDDocument document = null; try { document = PDDocument.load(file); @@ -219,24 +226,24 @@ public class WordToPDF { // 查找并设置打印机 //获得本台电脑连接的所有打印机 PrintService[] printServices = PrinterJob.lookupPrintServices(); - if(printServices == null || printServices.length == 0) { + if (printServices == null || printServices.length == 0) { System.out.print("打印失败,未找到可用打印机,请检查。"); - return ; + return; } PrintService printService = null; //匹配指定打印机 - for (int i = 0;i < printServices.length; i++) { + for (int i = 0; i < printServices.length; i++) { System.out.println(printServices[i].getName()); if (printServices[i].getName().contains(printerName)) { printService = printServices[i]; break; } } - if(printService!=null){ + if (printService != null) { printJob.setPrintService(printService); - }else{ + } else { System.out.print("打印失败,未找到名称为" + printerName + "的打印机,请检查。"); - return ; + return; } } //设置纸张及缩放 @@ -254,7 +261,7 @@ public class WordToPDF { HashPrintRequestAttributeSet pars = new HashPrintRequestAttributeSet(); pars.add(Sides.DUPLEX); //设置单双页 printJob.print(pars); - }finally { + } finally { if (document != null) { try { document.close(); @@ -265,7 +272,6 @@ public class WordToPDF { } } - public static Paper getPaper() { Paper paper = new Paper(); // 默认为A4纸张,对应像素宽和高分别为 595, 842 @@ -281,4 +287,20 @@ public class WordToPDF { paper.setImageableArea(marginLeft, marginRight, width - (marginLeft + marginRight), height - (marginTop + marginBottom)); return paper; } + + + private static void deleteDirectoryLegacyIO(File file) { + File[] list = file.listFiles(); + if (list != null) { + for (File temp : list) { + deleteDirectoryLegacyIO(temp); + } + } + + if (file.delete()) { + System.out.printf("删除成功 : %s%n", file); + } else { + System.err.printf("删除失败 : %s%n", file); + } + } } diff --git a/lab-service/lab-lims/src/main/java/org/springblade/lims/demo/DataAcquisition.java b/lab-service/lab-lims/src/main/java/org/springblade/lims/demo/DataAcquisition.java index 12e716f..ed4aa9f 100644 --- a/lab-service/lab-lims/src/main/java/org/springblade/lims/demo/DataAcquisition.java +++ b/lab-service/lab-lims/src/main/java/org/springblade/lims/demo/DataAcquisition.java @@ -1,18 +1,22 @@ package org.springblade.lims.demo; +import com.alibaba.fastjson.JSONObject; import com.jnrsmcu.sdk.netdevice.*; import org.springblade.core.cache.utils.CacheUtil; +import org.springblade.lims.tools.RedisUtil; import java.text.SimpleDateFormat; import java.util.HashMap; import java.util.Map; -import static org.springblade.core.cache.constant.CacheConstant.DEFAULT_CACHE; +import static org.springblade.core.cache.constant.CacheConstant.*; public class DataAcquisition implements Runnable { private RSServer rsServer; + private RedisUtil redisUtil; + private static final String DATA_ACQUISITION_ID = "dataAcquisition:id:"; @Override @@ -60,10 +64,20 @@ public class DataAcquisition implements Runnable { Map map = new HashMap(); map.put("wd", nd.getTem()); map.put("sd", nd.getHum()); - CacheUtil.put(DEFAULT_CACHE, "dataAcquisition:id:", data.getDeviceId() + "-" + nd.getNodeId(), map); - Map map1 = CacheUtil.get(DEFAULT_CACHE, "dataAcquisition:id:", data.getDeviceId() + "-" + nd.getNodeId(), Map.class); + + CacheUtil.put(SYS_CACHE, "dataAcquisition:id:", data.getDeviceId() + "-" + nd.getNodeId(), map); +// boolean set = redisUtil.set(SYS_CACHE + ":" + "dataAcquisition:id:" + data.getDeviceId() + "-" + nd.getNodeId(), JSONObject.toJSONString(map)); +// System.out.println("isChengGong: " + set); +// String str = (String) redisUtil.get(data.getDeviceId() + "-" + nd.getNodeId()); +// System.out.println(str); +// Map map3 = JSONObject.parseObject(str, Map.class); +// System.out.println("map3: " + map3); + + Map map1 = CacheUtil.get(SYS_CACHE, "dataAcquisition:id:", data.getDeviceId() + "-" + nd.getNodeId(), Map.class); System.out.println(data.getDeviceId() + "-" + nd.getNodeId() + ":" + map1); + System.out.println("==================="); } + System.out.println("========================================================================"); } @Override diff --git a/lab-service/lab-lims/src/main/java/org/springblade/lims/service/impl/EntrustServiceImpl.java b/lab-service/lab-lims/src/main/java/org/springblade/lims/service/impl/EntrustServiceImpl.java index e4879a1..14ed779 100644 --- a/lab-service/lab-lims/src/main/java/org/springblade/lims/service/impl/EntrustServiceImpl.java +++ b/lab-service/lab-lims/src/main/java/org/springblade/lims/service/impl/EntrustServiceImpl.java @@ -2587,7 +2587,8 @@ public class EntrustServiceImpl extends BaseServiceImpl || "1570666622551781378".equals(examineResult.getReagentId()) || "1570667398619656194".equals(examineResult.getReagentId())) { result.put("18", "S/N"); - } else if ("1570297053211455490".equals(examineResult.getReagentId())) { + } else if ("1570297053211455490".equals(examineResult.getReagentId()) + || "1631222146321997826".equals(examineResult.getReagentId())) { result.put("18", "牛PPD-PBS"); result.put("19", "牛PPD-禽PPD"); } else { @@ -2661,7 +2662,7 @@ public class EntrustServiceImpl extends BaseServiceImpl // list1.add(dataArrVO1); // list1.add(dataArrVO2); - if ("1570297053211455490".equals(examineResult.getReagentId())) { + if ("1570297053211455490".equals(examineResult.getReagentId()) || "1631222146321997826".equals(examineResult.getReagentId())) { // 根据样品编号去重 list1 = list1.stream().collect(Collectors .collectingAndThen( @@ -2724,8 +2725,7 @@ public class EntrustServiceImpl extends BaseServiceImpl } result.put("list1", resultList1); } - } - else { + } else { if (list1.size() > 0) { Map> resultMap = new HashMap<>(); int count = 0; @@ -3066,7 +3066,7 @@ public class EntrustServiceImpl extends BaseServiceImpl } result.put("list2", resultList2); result.put("list3", resultList3); - if ("1570297053211455490".equals(examineResult.getReagentId())) { + if ("1570297053211455490".equals(examineResult.getReagentId()) || "1631222146321997826".equals(examineResult.getReagentId())) { url = DictBizCache.getKey(DictBizEnum.PRINT_URL.getName(), "reportPrint2"); } else { url = DictBizCache.getKey(DictBizEnum.PRINT_URL.getName(), "reportPrint"); @@ -3329,7 +3329,7 @@ public class EntrustServiceImpl extends BaseServiceImpl resultList3.add(map3); } // 牛结核病γ-干扰素ELISA检测试剂盒---武汉科前生物股份有限公司 - else if ("1570297053211455490".equals(reagentId)) { + else if ("1570297053211455490".equals(reagentId) || "1631222146321997826".equals(reagentId)) { double yin1 = Double.parseDouble(list.get((i * 96)).getOriginResult()); double yin2 = Double.parseDouble(list.get((i * 96) + 8).getOriginResult()); double yin3 = Double.parseDouble(list.get((i * 96) + 16).getOriginResult()); diff --git a/lab-service/lab-lims/src/main/java/org/springblade/lims/service/impl/ExamineResultServiceImpl.java b/lab-service/lab-lims/src/main/java/org/springblade/lims/service/impl/ExamineResultServiceImpl.java index 0128ac2..466fc5d 100644 --- a/lab-service/lab-lims/src/main/java/org/springblade/lims/service/impl/ExamineResultServiceImpl.java +++ b/lab-service/lab-lims/src/main/java/org/springblade/lims/service/impl/ExamineResultServiceImpl.java @@ -365,16 +365,34 @@ public class ExamineResultServiceImpl extends BaseServiceImpl private final ISimpleRelService simpleRelService; + private final ISimpleDoExamineLogService simpleDoExamineLogService; + @Override @Transactional(rollbackFor = Exception.class) public void updateSimpleCurrPlace(Long taskId, Long deptId, int operateType) { @@ -269,6 +271,16 @@ public class ExamineServiceImpl extends BaseServiceImpl for (Examine examine : examines) { String experieNum = examine.getExperieNum(); examine.setExperieNum(updatePrefix(experieNum, prefix)); + + LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); + lqw.eq(SimpleDoExamineLog::getExamineId, examine.getId()); + List logs = simpleDoExamineLogService.list(lqw); + if (CollectionUtils.isNotEmpty(logs)) { + for (SimpleDoExamineLog simpleDoExamineLog : logs) { + simpleDoExamineLog.setExperieNum(updatePrefix(simpleDoExamineLog.getExperieNum(), prefix)); + } + simpleDoExamineLogService.updateBatchById(logs); + } } } return this.updateBatchById(examines); diff --git a/lab-service/lab-lims/src/main/java/org/springblade/lims/tools/RedisUtil.java b/lab-service/lab-lims/src/main/java/org/springblade/lims/tools/RedisUtil.java new file mode 100644 index 0000000..22f2267 --- /dev/null +++ b/lab-service/lab-lims/src/main/java/org/springblade/lims/tools/RedisUtil.java @@ -0,0 +1,569 @@ +package org.springblade.lims.tools; + +import org.springframework.data.redis.core.BoundListOperations; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.util.CollectionUtils; + +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +public class RedisUtil { + + private RedisTemplate redisTemplate; + + public RedisUtil(RedisTemplate redisTemplate) { + this.redisTemplate = redisTemplate; + } + + /** + * 指定缓存失效时间 + * @param key 键 + * @param time 时间(秒) + * @return + */ + public boolean expire(String key,long time){ + try { + if(time>0){ + redisTemplate.expire(key, time, TimeUnit.SECONDS); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 根据key 获取过期时间 + * @param key 键 不能为null + * @return 时间(秒) 返回0代表为永久有效 + */ + public long getExpire(String key){ + return redisTemplate.getExpire(key,TimeUnit.SECONDS); + } + + /** + * 判断key是否存在 + * @param key 键 + * @return true 存在 false不存在 + */ + public boolean hasKey(String key){ + try { + return redisTemplate.hasKey(key); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 删除缓存 + * @param key 可以传一个值 或多个 + */ + @SuppressWarnings("unchecked") + public void del(String ... key){ + if(key!=null&&key.length>0){ + if(key.length==1){ + redisTemplate.delete(key[0]); + }else{ + redisTemplate.delete(CollectionUtils.arrayToList(key)); + } + } + } + + /** + * 普通缓存获取 + * @param key 键 + * @return 值 + */ + public Object get(String key){ + return key==null?null:redisTemplate.opsForValue().get(key); + } + + /** + * 普通缓存放入 + * @param key 键 + * @param value 值 + * @return true成功 false失败 + */ + public boolean set(String key,Object value) { + try { + redisTemplate.opsForValue().set(key, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 普通缓存放入并设置时间 + * @param key 键 + * @param value 值 + * @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期 + * @return true成功 false 失败 + */ + public boolean set(String key,Object value,long time){ + try { + if(time>0){ + redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS); + }else{ + set(key, value); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 递增 + * @param key 键 + * @param delta 要增加几(大于0) + * @return + */ + public long incr(String key, long delta){ + if(delta<0){ + throw new RuntimeException("递增因子必须大于0"); + } + return redisTemplate.opsForValue().increment(key, delta); + } + + /** + * 递减 + * @param key 键 + * @param delta 要减少几(小于0) + * @return + */ + public long decr(String key, long delta){ + if(delta<0){ + throw new RuntimeException("递减因子必须大于0"); + } + return redisTemplate.opsForValue().increment(key, -delta); + } + + /** + * HashGet + * @param key 键 不能为null + * @param item 项 不能为null + * @return 值 + */ + public Object hget(String key,String item){ + return redisTemplate.opsForHash().get(key, item); + } + + /** + * 获取hashKey对应的所有键值 + * @param key 键 + * @return 对应的多个键值 + */ + public Map hmget(String key){ + return redisTemplate.opsForHash().entries(key); + } + + /** + * HashSet + * @param key 键 + * @param map 对应多个键值 + * @return true 成功 false 失败 + */ + public boolean hmset(String key, Map map){ + try { + redisTemplate.opsForHash().putAll(key, map); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * HashSet 并设置时间 + * @param key 键 + * @param map 对应多个键值 + * @param time 时间(秒) + * @return true成功 false失败 + */ + public boolean hmset(String key, Map map, long time){ + try { + redisTemplate.opsForHash().putAll(key, map); + if(time>0){ + expire(key, time); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 向一张hash表中放入数据,如果不存在将创建 + * @param key 键 + * @param item 项 + * @param value 值 + * @return true 成功 false失败 + */ + public boolean hset(String key,String item,Object value) { + try { + redisTemplate.opsForHash().put(key, item, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 向一张hash表中放入数据,如果不存在将创建 + * @param key 键 + * @param item 项 + * @param value 值 + * @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间 + * @return true 成功 false失败 + */ + public boolean hset(String key,String item,Object value,long time) { + try { + redisTemplate.opsForHash().put(key, item, value); + if(time>0){ + expire(key, time); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 删除hash表中的值 + * @param key 键 不能为null + * @param item 项 可以使多个 不能为null + */ + public void hdel(String key, Object... item){ + redisTemplate.opsForHash().delete(key,item); + } + + /** + * 判断hash表中是否有该项的值 + * @param key 键 不能为null + * @param item 项 不能为null + * @return true 存在 false不存在 + */ + public boolean hHasKey(String key, String item){ + return redisTemplate.opsForHash().hasKey(key, item); + } + + /** + * hash递增 如果不存在,就会创建一个 并把新增后的值返回 + * @param key 键 + * @param item 项 + * @param by 要增加几(大于0) + * @return + */ + public double hincr(String key, String item,double by){ + return redisTemplate.opsForHash().increment(key, item, by); + } + + /** + * hash递减 + * @param key 键 + * @param item 项 + * @param by 要减少记(小于0) + * @return + */ + public double hdecr(String key, String item,double by){ + return redisTemplate.opsForHash().increment(key, item,-by); + } + + /** + * 根据key获取Set中的所有值 + * @param key 键 + * @return + */ + public Set sGet(String key){ + try { + return redisTemplate.opsForSet().members(key); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + /** + * 根据value从一个set中查询,是否存在 + * @param key 键 + * @param value 值 + * @return true 存在 false不存在 + */ + public boolean sHasKey(String key,Object value){ + try { + return redisTemplate.opsForSet().isMember(key, value); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 将数据放入set缓存 + * @param key 键 + * @param values 值 可以是多个 + * @return 成功个数 + */ + public long sSet(String key, Object...values) { + try { + return redisTemplate.opsForSet().add(key, values); + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 将set数据放入缓存 + * @param key 键 + * @param time 时间(秒) + * @param values 值 可以是多个 + * @return 成功个数 + */ + public long sSetAndTime(String key,long time,Object...values) { + try { + Long count = redisTemplate.opsForSet().add(key, values); + if(time>0) { + expire(key, time); + } + return count; + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 获取set缓存的长度 + * @param key 键 + * @return + */ + public long sGetSetSize(String key){ + try { + return redisTemplate.opsForSet().size(key); + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 移除值为value的 + * @param key 键 + * @param values 值 可以是多个 + * @return 移除的个数 + */ + public long setRemove(String key, Object ...values) { + try { + Long count = redisTemplate.opsForSet().remove(key, values); + return count; + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 获取list缓存的内容 + * @param key 键 + * @param start 开始 + * @param end 结束 0 到 -1代表所有值 + * @return + */ + public List lGet(String key, long start, long end){ + try { + return redisTemplate.opsForList().range(key, start, end); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + /** + * 获取list缓存的长度 + * @param key 键 + * @return + */ + public long lGetListSize(String key){ + try { + return redisTemplate.opsForList().size(key); + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 通过索引 获取list中的值 + * @param key 键 + * @param index 索引 index>=0时, 0 表头,1 第二个元素,依次类推;index<0时,-1,表尾,-2倒数第二个元素,依次类推 + * @return + */ + public Object lGetIndex(String key,long index){ + try { + return redisTemplate.opsForList().index(key, index); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + /** + * 将list放入缓存 + * @param key 键 + * @param value 值 + * @return + */ + public boolean lSet(String key, Object value) { + try { + redisTemplate.opsForList().rightPush(key, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 将list放入缓存 + * @param key 键 + * @param value 值 + * @param time 时间(秒) + * @return + */ + public boolean lSet(String key, Object value, long time) { + try { + redisTemplate.opsForList().rightPush(key, value); + if (time > 0) { + expire(key, time); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 将list放入缓存 + * @param key 键 + * @param value 值 + * @return + */ + public boolean lSet(String key, List value) { + try { + redisTemplate.opsForList().rightPushAll(key, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 将list放入缓存 + * @param key 键 + * @param value 值 + * @param time 时间(秒) + * @return + */ + public boolean lSet(String key, List value, long time) { + try { + redisTemplate.opsForList().rightPushAll(key, value); + if (time > 0) { + expire(key, time); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 根据索引修改list中的某条数据 + * @param key 键 + * @param index 索引 + * @param value 值 + * @return + */ + public boolean lUpdateIndex(String key, long index,Object value) { + try { + redisTemplate.opsForList().set(key, index, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 移除N个值为value + * @param key 键 + * @param count 移除多少个 + * @param value 值 + * @return 移除的个数 + */ + public long lRemove(String key,long count,Object value) { + try { + Long remove = redisTemplate.opsForList().remove(key, count, value); + return remove; + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 模糊查询获取key值 + * @param pattern + * @return + */ + public Set keys(String pattern){ + return redisTemplate.keys(pattern); + } + + /** + * 使用Redis的消息队列 + * @param channel + * @param message 消息内容 + */ + public void convertAndSend(String channel, Object message){ + redisTemplate.convertAndSend(channel,message); + } + + /** + * 根据起始结束序号遍历Redis中的list + * @param listKey + * @param start 起始序号 + * @param end 结束序号 + * @return + */ + public List rangeList(String listKey, long start, long end) { + //绑定操作 + BoundListOperations boundValueOperations = redisTemplate.boundListOps(listKey); + //查询数据 + return boundValueOperations.range(start, end); + } + + /** + * 弹出右边的值 --- 并且移除这个值 + * @param listKey + */ + public Object rifhtPop(String listKey){ + //绑定操作 + BoundListOperations boundValueOperations = redisTemplate.boundListOps(listKey); + return boundValueOperations.rightPop(); + } + +} diff --git a/lab-service/lab-user/src/main/java/org/springblade/system/user/controller/TeacherController.java b/lab-service/lab-user/src/main/java/org/springblade/system/user/controller/TeacherController.java index dad2b00..ccf57c6 100644 --- a/lab-service/lab-user/src/main/java/org/springblade/system/user/controller/TeacherController.java +++ b/lab-service/lab-user/src/main/java/org/springblade/system/user/controller/TeacherController.java @@ -9,6 +9,7 @@ import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; import org.springblade.system.feign.ISysClient; import org.springblade.system.user.entity.Teacher; import org.springblade.system.user.entity.Train; @@ -129,7 +130,16 @@ public class TeacherController extends BladeController { if (CollectionUtils.isNotEmpty(users)) { for (User user : users) { if (StringUtils.isNotBlank(user.getDeptId())) { - user.setDeptName(sysClient.getDeptName(Long.valueOf(user.getDeptId())).getData()); + String deptName = ""; + List deptIds = Func.toLongList(user.getDeptId()); + for (int i = 0; i < deptIds.size(); i++) { + if (i == deptIds.size() - 1) { + deptName += sysClient.getDeptName(deptIds.get(i)).getData(); + } else { + deptName += sysClient.getDeptName(deptIds.get(i)).getData() + ","; + } + } + user.setDeptName(deptName); } } }