Bladeren bron

宠物食品检测附件调整

陈长荣 2 weken geleden
bovenliggende
commit
abcc1c7dc4

+ 9 - 9
jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/sample/service/biz/SampleFoodServiceImpl.java

@@ -169,8 +169,8 @@ public class SampleFoodServiceImpl extends ServiceImpl<SampleFoodMapper, SampleF
         if (StrUtil.isNotBlank(join)) {
             sb.append(",").append(foodCommon.getString("title"));
         }
-        checkbox(mappings, "常规指标条目", "☐水分  ☐灰分  ☐粗纤维  ☐粗脂肪   ☐粗蛋白   ☐水溶性氯化物  ☐PH  ☐酸价  ☐过氧化值  ☐淀粉  ☐挥发性盐基氮  ☐还原糖  ☐SOD  ☐总黄酮  ☐Ω-3脂肪酸  ☐Ω-6脂肪酸  ☐混合均匀度  ☐碳水化合物  ☐硬度  ☐不溶性杂质  ☐粘稠度  ☐杂质  ☐容重  ☐镜检  ☐嫩度(剪切力)  ☐水分活度  ☐膳食纤维  ☐可溶性膳食纤维  ☐不可溶性膳食纤维  ☐尿素酶活性  ☐其他", join);
-        mappings.put("常规指标条目-其他", foodCommon.getString("qt"));
+        checkbox(mappings, "常规指标条目", "☐水分  ☐灰分  ☐粗纤维  ☐粗脂肪   ☐粗蛋白   ☐水溶性氯化物  ☐PH  ☐酸价  ☐过氧化值  ☐淀粉  ☐挥发性盐基氮  ☐还原糖  ☐SOD  ☐总黄酮  ☐Ω-3脂肪酸  ☐Ω-6脂肪酸  ☐混合均匀度  ☐碳水化合物  ☐硬度  ☐不溶性杂质  ☐黏稠性  ☐杂质  ☐容重  ☐镜检  ☐嫩度(剪切力)  ☐水分活度  ☐膳食纤维  ☐可溶性膳食纤维  ☐不可溶性膳食纤维  ☐尿素酶活性  ☐其他", join);
+        mappings.put("常规指标条目-其他", join.contains("其他") ? foodCommon.getString("qt") : "");
         //矿物质
         JSONObject foodMineral = detectionObj.getJSONObject("foodMineral");
         join = CollUtil.join(foodMineral.getJSONArray("values"), ",");
@@ -178,7 +178,7 @@ public class SampleFoodServiceImpl extends ServiceImpl<SampleFoodMapper, SampleF
             sb.append(",").append(foodMineral.getString("title"));
         }
         checkbox(mappings, "矿物质条目", "☐硒  ☐总磷  ☐氟  ☐铜  ☐铁  ☐锌  ☐锰  ☐钙  ☐钾  ☐钠  ☐镁  ☐其他", join);
-        mappings.put("矿物质条目-其他", foodMineral.getString("qt"));
+        mappings.put("矿物质条目-其他", join.contains("其他") ? foodMineral.getString("qt") : "");
         //维生素
         JSONObject foodVitamin = detectionObj.getJSONObject("foodVitamin");
         join = CollUtil.join(foodVitamin.getJSONArray("values"), ",");
@@ -186,7 +186,7 @@ public class SampleFoodServiceImpl extends ServiceImpl<SampleFoodMapper, SampleF
             sb.append(",").append(foodVitamin.getString("title"));
         }
         checkbox(mappings, "维生素条目", "☐维生素D3  ☐维生素E  ☐维生素B1  ☐维生素B6  ☐泛酸  ☐维生素C  ☐生物素  ☐维生素A  ☐维生素K3  ☐维生素B2  ☐烟酸  ☐维生素B12  ☐叶酸  ☐左旋肉碱  ☐其他", join);
-        mappings.put("维生素条目-其他", foodVitamin.getString("qt"));
+        mappings.put("维生素条目-其他", join.contains("其他") ? foodVitamin.getString("qt") : "");
         //污染物
         JSONObject foodPollutant = detectionObj.getJSONObject("foodPollutant");
         join = CollUtil.join(foodPollutant.getJSONArray("values"), ",");
@@ -194,7 +194,7 @@ public class SampleFoodServiceImpl extends ServiceImpl<SampleFoodMapper, SampleF
             sb.append(",").append(foodPollutant.getString("title"));
         }
         checkbox(mappings, "污染物条目", "☐亚硝酸盐  ☐铅  ☐镉  ☐铬  ☐总砷  ☐汞  ☐游离棉酚  ☐组胺  ☐苯并(a)芘  ☐其他", join);
-        mappings.put("污染物条目-其他", foodPollutant.getString("qt"));
+        mappings.put("污染物条目-其他", join.contains("其他") ? foodPollutant.getString("qt") : "");
         //真菌毒素
         JSONObject foodMucus = detectionObj.getJSONObject("foodMucus");
         join = CollUtil.join(foodMucus.getJSONArray("values"), ",");
@@ -202,7 +202,7 @@ public class SampleFoodServiceImpl extends ServiceImpl<SampleFoodMapper, SampleF
             sb.append(",").append(foodMucus.getString("title"));
         }
         checkbox(mappings, "真菌毒素条目", "☐黄曲霉毒素B1  ☐玉米赤霉烯酮  ☐T2毒素  ☐脱氧雪腐镰刀菌烯醇  ☐赭曲霉毒素A  ☐伏马毒素  ☐其他", join);
-        mappings.put("真菌毒素条目-其他", foodMucus.getString("qt"));
+        mappings.put("真菌毒素条目-其他", join.contains("其他") ? foodMucus.getString("qt") : "");
         //微生物
         JSONObject foodMicrobiome = detectionObj.getJSONObject("foodMicrobiome");
         join = CollUtil.join(foodMicrobiome.getJSONArray("values"), ",");
@@ -210,7 +210,7 @@ public class SampleFoodServiceImpl extends ServiceImpl<SampleFoodMapper, SampleF
             sb.append(",").append(foodMicrobiome.getString("title"));
         }
         checkbox(mappings, "微生物条目", "☐沙门氏菌  ☐细菌总数  ☐酵母菌  ☐金黄色葡萄球菌  ☐志贺氏菌  ☐霉菌总数  ☐大肠菌群  ☐蜡样芽孢杆菌  ☐阪崎肠杆菌  ☐单核细胞增生李斯特氏菌  ☐其他", join);
-        mappings.put("微生物条目-其他", foodMicrobiome.getString("qt"));
+        mappings.put("微生物条目-其他", join.contains("其他") ? foodMicrobiome.getString("qt") : "");
         //其他
         JSONObject foodQt = detectionObj.getJSONObject("foodQt");
         join = CollUtil.join(foodQt.getJSONArray("values"), ",");
@@ -218,7 +218,7 @@ public class SampleFoodServiceImpl extends ServiceImpl<SampleFoodMapper, SampleF
             sb.append(",").append(foodQt.getString("title"));
         }
         checkbox(mappings, "其他条目", "☐17种氨基酸  ☐牛磺酸  ☐六六六  ☐滴滴涕  ☐BHA  ☐BHT  ☐TBHQ  ☐山梨酸  ☐苯甲酸  ☐其他", join);
-        mappings.put("其他条目-其他", foodQt.getString("qt"));
+        mappings.put("其他条目-其他", join.contains("其他") ? foodQt.getString("qt") : "");
         //套餐
         JSONObject foodTaocan = detectionObj.getJSONObject("foodTaocan");
         join = CollUtil.join(foodTaocan.getJSONArray("values"), ",");
@@ -230,7 +230,7 @@ public class SampleFoodServiceImpl extends ServiceImpl<SampleFoodMapper, SampleF
         JSONObject customize = detectionObj.getJSONObject("customize");
         mappings.put("自定义条目", customize.getString("qt"));
         if (StrUtil.isNotBlank(customize.getString("qt"))) {
-            sb.append(",").append(customize.getString("title"));
+            sb.append(",").append(customize.getString("title")).append(":").append(customize.getString("qt"));
         }
         mappings.put("检测项目", sb.substring(1));
 

+ 9 - 1
jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/util/ExcelImageService.java

@@ -44,6 +44,10 @@ public class ExcelImageService {
         List<String> imgUrls = imageList.stream().map(ExcelImage::getImageUrl).distinct().collect(Collectors.toList());
         for (String imageUrl : imgUrls) {
             byte[] bytes = wordDataService.getBytes(imageUrl);
+            if (bytes == null) {
+                log.warn("Excel单元格 插入图片失败:图片不存在:{}", imageUrl);
+                continue;
+            }
             imageList.stream().filter(x -> x.getImageUrl().equals(imageUrl)).forEach(x -> x.setBytes(bytes));
         }
 
@@ -67,7 +71,11 @@ public class ExcelImageService {
             ExcelImage excelImage = imageList.get(i - 1);
 
             // 创建图片
-            BinaryPartAbstractImage imagePart = BinaryPartAbstractImage.createImagePart(pkg, part, excelImage.getBytes());
+            byte[] bytes = excelImage.getBytes();
+            if (bytes == null) {
+                continue;
+            }
+            BinaryPartAbstractImage imagePart = BinaryPartAbstractImage.createImagePart(pkg, part, bytes);
             String imageRelID = imagePart.getSourceRelationships().get(0).getId();
             log.info("Excel单元格[{}] relId={} 插入图片:{}", excelImage.getLocation(), imageRelID, excelImage.getImageUrl());