|
@@ -7,14 +7,18 @@ import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.io.resource.ResourceUtil;
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
+import cn.hutool.core.util.EscapeUtil;
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.crypto.digest.DigestUtil;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.github.jfcloud.admin.api.sys.dto.message.MessageUserDTO;
|
|
|
import com.github.jfcloud.common.holder.RequestHolder;
|
|
|
import com.github.jfcloud.gene.cache.UserIdNameCache;
|
|
|
import com.github.jfcloud.gene.common.constant.StrConstant;
|
|
|
+import com.github.jfcloud.gene.common.constant.WhetherEnum;
|
|
|
import com.github.jfcloud.gene.common.util.CustomIdGenerator;
|
|
|
import com.github.jfcloud.gene.common.util.UserUtil;
|
|
|
import com.github.jfcloud.gene.constants.GeneStatusEnum;
|
|
@@ -124,78 +128,135 @@ public class SampleFoodServiceImpl extends ServiceImpl<SampleFoodMapper, SampleF
|
|
|
}
|
|
|
String applyDate = DateUtil.format(sampleInfo.getApplyTime(), DatePattern.CHINESE_DATE_PATTERN);
|
|
|
|
|
|
+ //替换excel中的变量,勾选框使用字符串代替
|
|
|
+ Map<String, String> mappings = new HashMap<>();
|
|
|
+ mappings.put("送检目的", detail.getPurpose());
|
|
|
+ mappings.put("送检方名称", detail.getSenderName());
|
|
|
+ mappings.put("送检方地址", detail.getSenderAddress());
|
|
|
+ mappings.put("送检方联系人", detail.getSenderContactName());
|
|
|
+ mappings.put("送检方联系电话", detail.getSenderPhone());
|
|
|
+ mappings.put("送检方电子邮箱", detail.getSenderEmail());
|
|
|
+ checkbox(mappings, "报告方式", "☐一个样品一个报告 ☐多个样品一个报告", detail.getReportMethod());
|
|
|
+ checkbox(mappings, "报告类型", "☐电子报告 ☐纸质报告", detail.getReportType());
|
|
|
+ checkbox(mappings,"是否评判结果", "☐是 ☐否", WhetherEnum.getLabel(detail.getHasEvaluation()));
|
|
|
+ checkbox(mappings,"是否以干基计", "☐是 ☐否", WhetherEnum.getLabel(detail.getDryBasis()));
|
|
|
+ checkbox(mappings,"其他要求", "☐CNAS ☐CMA ☐保密数据", detail.getOtherRequirements());
|
|
|
+ checkbox(mappings,"自定义", "☐自定义", detail.getSampleType());
|
|
|
+ checkbox(mappings,"样品照片", "☐否(不需要) ☐是(需要) ☐外观 ☐内容物 ☐其他", detail.getSamplePhoto());
|
|
|
+ mappings.put("样品照片-其他", detail.getSamplePhotoOther());
|
|
|
+ checkbox(mappings,"样品储存要求", "☐室温 ☐冷藏(0℃~8℃) ☐冷冻(≤18℃) ☐避光 ☐干燥 ☐其他", detail.getStorageRequirements());
|
|
|
+ mappings.put("样品储存要求-其他", detail.getStorageRequirementsOther());
|
|
|
+ checkbox(mappings,"样品保留期限", "☐常规样品一个月(默认) ☐新鲜产品一周 ☐冷冻产品三周", detail.getRetentionPeriod());
|
|
|
+ mappings.put("非危险性样品", "☐非危险性样品");
|
|
|
+ checkbox(mappings,"危险性样品", "☐易燃易爆 ☐腐蚀性 ☐毒性(非剧毒) ☐氧化剂 ☐其他", detail.getHazardDescription());
|
|
|
+ mappings.put("危险性样品-其他", detail.getHazardDescriptionOther());
|
|
|
+ checkbox(mappings,"服务时限", "☐标准时间(7个工作日) ☐5个工作日\n\n☐3个工作日 ☐1个工作日\n\n☐加急", detail.getServiceDeadline());
|
|
|
+
|
|
|
+ List<SampleFoodDetailVo> detailList = detail.getDetailList();
|
|
|
+ SampleFoodDetailVo itemVo = CollUtil.isEmpty(detailList) ? new SampleFoodDetailVo() : detailList.get(0);
|
|
|
+ mappings.put("样品名称", itemVo.getSampleName());
|
|
|
+ mappings.put("生产商", itemVo.getManufacturer());
|
|
|
+ mappings.put("生产日期", DateUtil.formatDate(itemVo.getProductionDate()));
|
|
|
+ mappings.put("批号", itemVo.getBatchNumber());
|
|
|
+ mappings.put("数量", itemVo.getQuantity());
|
|
|
+ checkbox(mappings,"样品状态", "☐固体 ☐半固体\n☐液体 ☐其他", itemVo.getSampleStatus());
|
|
|
+ mappings.put("样品状态-其他", itemVo.getSampleStatusOther());
|
|
|
+ checkbox(mappings,"包装方式", "☐袋装 ☐罐装\n☐瓶装 ☐其他", itemVo.getPackaging());
|
|
|
+ mappings.put("包装方式-其他", itemVo.getPackagingOther());
|
|
|
+ mappings.put("样品-其他", itemVo.getOtherInfo());
|
|
|
+
|
|
|
+ //解析检测项目
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ JSONObject detectionObj = JSONObject.parseObject(itemVo.getDetectionItems());
|
|
|
+ //常规指标
|
|
|
+ JSONObject foodCommon = detectionObj.getJSONObject("foodCommonIndex");
|
|
|
+ String join = CollUtil.join(foodCommon.getJSONArray("values"), ",");
|
|
|
+ if (StrUtil.isNotBlank(join)) {
|
|
|
+ sb.append(",").append(foodCommon.getString("title"));
|
|
|
+ }
|
|
|
+ checkbox(mappings,"常规指标条目", "☐水分 ☐灰分 ☐粗纤维 ☐粗脂肪 ☐粗蛋白 ☐水溶性氯化物 ☐pH ☐酸价 ☐过氧化值 ☐淀粉 ☐挥发性盐基氮 ☐还原糖 ☐SOD ☐总黄酮 ☐Ω-3脂肪酸 ☐Ω-6脂肪酸 ☐混合均匀度 ☐碳水化合物 ☐硬度 ☐不溶性杂质 ☐粘稠度 ☐杂质 ☐容重 ☐镜检 ☐嫩度(剪切力) ☐水分活度 ☐膳食纤维 ☐可溶性膳食纤维 ☐不可溶性膳食纤维 ☐尿素酶活性 ☐其他", join);
|
|
|
+ mappings.put("常规指标条目-其他", foodCommon.getString("qt"));
|
|
|
+ //矿物质
|
|
|
+ JSONObject foodMineral = detectionObj.getJSONObject("foodMineral");
|
|
|
+ join = CollUtil.join(foodMineral.getJSONArray("values"), ",");
|
|
|
+ if (StrUtil.isNotBlank(join)) {
|
|
|
+ sb.append(",").append(foodMineral.getString("title"));
|
|
|
+ }
|
|
|
+ checkbox(mappings,"矿物质条目", "☐硒 ☐总磷 ☐氟 ☐铜 ☐铁 ☐锌 ☐锰 ☐钙 ☐钾 ☐钠 ☐镁 ☐其他", join);
|
|
|
+ mappings.put("矿物质条目-其他", foodMineral.getString("qt"));
|
|
|
+ //污染物
|
|
|
+ JSONObject foodPollutant = detectionObj.getJSONObject("foodPollutant");
|
|
|
+ join = CollUtil.join(foodPollutant.getJSONArray("values"), ",");
|
|
|
+ if (StrUtil.isNotBlank(join)) {
|
|
|
+ sb.append(",").append(foodPollutant.getString("title"));
|
|
|
+ }
|
|
|
+ checkbox(mappings,"污染物条目", "☐亚硝酸盐 ☐铅 ☐镉 ☐铬 ☐总砷 ☐汞 ☐游离棉酚 ☐组胺 ☐苯并(a)芘 ☐其他", join);
|
|
|
+ mappings.put("污染物条目-其他", foodPollutant.getString("qt"));
|
|
|
+ //维生素
|
|
|
+ JSONObject foodVitamin = detectionObj.getJSONObject("foodVitamin");
|
|
|
+ join = CollUtil.join(foodVitamin.getJSONArray("values"), ",");
|
|
|
+ if (StrUtil.isNotBlank(join)) {
|
|
|
+ sb.append(",").append(foodVitamin.getString("title"));
|
|
|
+ }
|
|
|
+ checkbox(mappings,"维生素条目", "☐维生素D3 ☐维生素E ☐维生素B1 ☐维生素B6 ☐泛酸 ☐维生素C ☐生物素 ☐维生素A ☐维生素K3 ☐维生素B2 ☐烟酸 ☐维生素B12 ☐叶酸 ☐左旋肉碱 ☐其他", join);
|
|
|
+ mappings.put("维生素条目-其他", foodVitamin.getString("qt"));
|
|
|
+ //真菌毒素
|
|
|
+ JSONObject foodMucus = detectionObj.getJSONObject("foodMucus");
|
|
|
+ join = CollUtil.join(foodMucus.getJSONArray("values"), ",");
|
|
|
+ if (StrUtil.isNotBlank(join)) {
|
|
|
+ sb.append(",").append(foodMucus.getString("title"));
|
|
|
+ }
|
|
|
+ checkbox(mappings,"真菌毒素条目", "☐黄曲霉毒素B1 ☐玉米赤霉烯酮 ☐T2毒素 ☐脱氧雪腐镰刀菌烯醇 ☐赭曲霉毒素A ☐伏马毒素 ☐其他", join);
|
|
|
+ mappings.put("真菌毒素条目-其他", foodMucus.getString("qt"));
|
|
|
+ //微生物
|
|
|
+ JSONObject foodMicrobiome = detectionObj.getJSONObject("foodMicrobiome");
|
|
|
+ join = CollUtil.join(foodMicrobiome.getJSONArray("values"), ",");
|
|
|
+ if (StrUtil.isNotBlank(join)) {
|
|
|
+ sb.append(",").append(foodMicrobiome.getString("title"));
|
|
|
+ }
|
|
|
+ checkbox(mappings,"微生物条目", "☐沙门氏菌 ☐细菌总数 ☐酵母菌 ☐金黄色葡萄球菌 ☐志贺氏菌 ☐霉菌总数 ☐大肠菌群 ☐蜡样芽孢杆菌 ☐阪崎肠杆菌 ☐单核细胞增生李斯特氏菌 ☐其他", join);
|
|
|
+ mappings.put("微生物条目-其他", foodMicrobiome.getString("qt"));
|
|
|
+ //其他
|
|
|
+ JSONObject foodQt = detectionObj.getJSONObject("foodQt");
|
|
|
+ join = CollUtil.join(foodQt.getJSONArray("values"), ",");
|
|
|
+ if (StrUtil.isNotBlank(join)) {
|
|
|
+ sb.append(",").append(foodQt.getString("title"));
|
|
|
+ }
|
|
|
+ checkbox(mappings,"其他条目", "☐17种氨基酸 ☐牛磺酸 ☐六六六 ☐滴滴涕 ☐BHA ☐BHT ☐TBHQ ☐山梨酸 ☐苯甲酸 ☐其他", join);
|
|
|
+ mappings.put("其他条目-其他", foodQt.getString("qt"));
|
|
|
+ //套餐
|
|
|
+ JSONObject foodTaocan = detectionObj.getJSONObject("foodTaocan");
|
|
|
+ join = CollUtil.join(foodTaocan.getJSONArray("values"), ",");
|
|
|
+ if (StrUtil.isNotBlank(join)) {
|
|
|
+ sb.append(",").append(foodTaocan.getString("title"));
|
|
|
+ }
|
|
|
+ checkbox(mappings,"套餐条目", "☐套餐①基础九项 ☐套餐②国标全检 ☐套餐③农业部20号公告全检 ☐套餐④AAFCO套餐全检", join);
|
|
|
+ //自定义
|
|
|
+ JSONObject customize = detectionObj.getJSONObject("customize");
|
|
|
+ mappings.put("自定义条目", customize.getString("qt"));
|
|
|
+ if (StrUtil.isNotBlank(customize.getString("qt"))) {
|
|
|
+ sb.append(",").append(customize.getString("title"));
|
|
|
+ }
|
|
|
+ mappings.put("检测项目", sb.substring(1));
|
|
|
+
|
|
|
+ mappings.put("日期", applyDate);
|
|
|
+
|
|
|
try (InputStream stream = ResourceUtil.getStream("officeTemplate/sampleFood.xlsx")) {
|
|
|
- //替换excel中的变量,勾选框使用字符串代替
|
|
|
- Map<String, String> mappings = new HashMap<>();
|
|
|
- mappings.put("送检目的", detail.getPurpose());
|
|
|
- mappings.put("送检方名称", detail.getSenderName());
|
|
|
- mappings.put("送检方地址", detail.getSenderAddress());
|
|
|
- mappings.put("送检方联系人", detail.getSenderContactName());
|
|
|
- mappings.put("送检方联系电话", detail.getSenderPhone());
|
|
|
- mappings.put("送检方电子邮箱", detail.getSenderEmail());
|
|
|
- mappings.put("报告方式", "☐一个样品一个报告 ☐多个样品一个报告");
|
|
|
- mappings.put("报告类型", "☐电子报告 ☐纸质报告");
|
|
|
- mappings.put("是否评判结果", "☐是 ☐否");
|
|
|
- mappings.put("是否以干基计", "☐是 ☐否");
|
|
|
- mappings.put("其他要求", "☐CNAS ☐CMA ☐保密数据");
|
|
|
- mappings.put("自定义", "☐自定义");
|
|
|
- mappings.put("样品照片", "☐是(需要) ☐外观 ☐内容物 ☐其他");
|
|
|
- mappings.put("样品照片-其他", "");
|
|
|
- mappings.put("样品照片-否", " ☐否(不需要)");
|
|
|
- mappings.put("样品储存要求", "☐室温 ☐冷藏(0℃~8℃) ☐冷冻(≤18℃) ☐避光 ☐干燥 ☐其他");
|
|
|
- mappings.put("样品储存要求-其他", "");
|
|
|
- mappings.put("样品保留期限", "☐常规样品一个月(默认) ☐新鲜产品一周 ☐冷冻产品三周");
|
|
|
- mappings.put("非危险性样品", "☐非危险性样品");
|
|
|
- mappings.put("危险性样品", "☐易燃易爆 ☐腐蚀性 ☐毒性(非剧毒) ☐氧化剂 ☐其他");
|
|
|
- mappings.put("危险性样品-其他", "");
|
|
|
- mappings.put("服务时限", "☐标准时间(7个工作日) ☐5个工作日\n\n☐3个工作日 ☐1个工作日\n\n☐加急");
|
|
|
-
|
|
|
- List<SampleFoodDetailVo> detailList = detail.getDetailList();
|
|
|
- SampleFoodDetailVo itemVo = CollUtil.isEmpty(detailList) ? new SampleFoodDetailVo() : detailList.get(0);
|
|
|
- mappings.put("样品名称", itemVo.getSampleName());
|
|
|
- mappings.put("生产商", itemVo.getManufacturer());
|
|
|
- mappings.put("生产日期", "");
|
|
|
- mappings.put("批号", itemVo.getBatchNumber());
|
|
|
- mappings.put("数量", itemVo.getQuantity());
|
|
|
- mappings.put("样品状态", "☐固体 ☐半固体\n☐液体 ☐其他");
|
|
|
- mappings.put("样品状态-其他", "");
|
|
|
- mappings.put("包装方式", "☐袋装 ☐罐装\n☐瓶装 ☐其他");
|
|
|
- mappings.put("包装方式-其他", "");
|
|
|
- mappings.put("检测项目", "常规指标,矿物质,维生素");
|
|
|
- mappings.put("样品-其他", "");
|
|
|
-
|
|
|
- mappings.put("常规指标条目", "☐水分 ☐灰分 ☐粗纤维 ☐粗脂肪 ☐粗蛋白 ☐水溶性氯化物 ☐pH ☐酸价 ☐过氧化值 ☐淀粉 ☐挥发性盐基氮 ☐还原糖 ☐SOD ☐总黄酮 ☐Ω-3脂肪酸 ☐Ω-6脂肪酸 ☐混合均匀度 ☐碳水化合物 ☐硬度 ☐不溶性杂质 ☐粘稠度 ☐杂质 ☐容重 ☐镜检 ☐嫩度(剪切力) ☐水分活度 ☐膳食纤维 ☐可溶性膳食纤维 ☐不可溶性膳食纤维 ☐尿素酶活性 ☐其他");
|
|
|
- mappings.put("常规指标条目-其他", "");
|
|
|
- mappings.put("矿物质条目", "☐硒 ☐总磷 ☐氟 ☐铜 ☐铁 ☐锌 ☐锰 ☐钙 ☐钾 ☐钠 ☐镁 ☐其他");
|
|
|
- mappings.put("矿物质条目-其他", "");
|
|
|
- mappings.put("污染物条目", "☐亚硝酸盐 ☐铅 ☐镉 ☐铬 ☐总砷 ☐汞 ☐游离棉酚 ☐组胺 ☐苯并(a)芘 ☐其他");
|
|
|
- mappings.put("污染物条目-其他", "");
|
|
|
- mappings.put("维生素条目", "☐维生素D3 ☐维生素E ☐维生素B1 ☐维生素B6 ☐泛酸 ☐维生素C ☐生物素 ☐维生素A ☐维生素K3 ☐维生素B2 ☐烟酸 ☐维生素B12 ☐叶酸 ☐左旋肉碱 ☐其他");
|
|
|
- mappings.put("维生素条目-其他", "");
|
|
|
- mappings.put("真菌毒素条目", "☐黄曲霉毒素B1 ☐玉米赤霉烯酮 ☐T2毒素 ☐脱氧雪腐镰刀菌烯醇 ☐赭曲霉毒素A ☐伏马毒素 ☐其他");
|
|
|
- mappings.put("真菌毒素条目-其他", "");
|
|
|
- mappings.put("微生物条目", "☐沙门氏菌 ☐细菌总数 ☐酵母菌 ☐金黄色葡萄球菌 ☐志贺氏菌 ☐霉菌总数 ☐大肠菌群 ☐蜡样芽孢杆菌 ☐阪崎肠杆菌 ☐单核细胞增生李斯特氏菌 ☐其他");
|
|
|
- mappings.put("微生物条目-其他", "");
|
|
|
- mappings.put("其他条目", "☐17种氨基酸 ☐牛磺酸 ☐六六六 ☐滴滴涕 ☐BHA ☐BHT ☐TBHQ ☐山梨酸 ☐苯甲酸 ☐其他");
|
|
|
- mappings.put("其他条目-其他", "");
|
|
|
- mappings.put("套餐条目", "☐套餐①基础九项 ☐套餐②国标全检 ☐套餐③农业部20号公告全检 ☐套餐④AAFCO套餐全检");
|
|
|
- mappings.put("自定义条目", "");
|
|
|
-
|
|
|
- mappings.put("日期", applyDate);
|
|
|
+ //加载excel模板,并替换变量
|
|
|
+ SpreadsheetMLPackage opcPackagePkg = SpreadsheetMLPackage.load(stream);
|
|
|
+ JaxbSmlPart<?> smlPart = (JaxbSmlPart) opcPackagePkg.getParts().get(new PartName("/xl/sharedStrings.xml"));
|
|
|
//将null替换为空字符串
|
|
|
mappings.forEach((key, value) -> {
|
|
|
if (value == null) {
|
|
|
mappings.put(key, "");
|
|
|
+ } else {
|
|
|
+ mappings.put(key, EscapeUtil.escapeXml(value));
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
- //加载excel模板,并替换变量
|
|
|
- SpreadsheetMLPackage opcPackagePkg = SpreadsheetMLPackage.load(stream);
|
|
|
- JaxbSmlPart<?> smlPart = (JaxbSmlPart) opcPackagePkg.getParts().get(new PartName("/xl/sharedStrings.xml"));
|
|
|
smlPart.variableReplace(mappings);
|
|
|
|
|
|
//查询审核记录,添加签字图片
|
|
|
- List<FlowAudit> flowAudits = flowAuditService.auditList(sampleId,"sample." + sampleInfo.getType(), true);
|
|
|
+ List<FlowAudit> flowAudits = flowAuditService.auditList(sampleId, "sample." + sampleInfo.getType(), true);
|
|
|
//项目管理部审核
|
|
|
flowAudits.stream()
|
|
|
.filter(audit -> GeneStatusEnum.PROJECT_MANAGEMENT.getStatus().equals(audit.getFlowStatus()) && StrConstant.YES.equals(audit.getAuditResult()))
|
|
@@ -217,6 +278,9 @@ public class SampleFoodServiceImpl extends ServiceImpl<SampleFoodMapper, SampleF
|
|
|
|
|
|
//保存为excel
|
|
|
String targetFileName = String.format("食品检测部门送检单(详细)-%s-%s.xlsx", applyDate, RandomUtil.randomString(RandomUtil.BASE_CHAR_NUMBER_LOWER, 4));
|
|
|
+ if (StrUtil.isNotBlank(detail.getSenderName())) {
|
|
|
+ targetFileName = String.format("食品检测部门送检单(详细)-%s-%s-%s.xlsx", detail.getSenderName(), applyDate, RandomUtil.randomString(RandomUtil.BASE_CHAR_NUMBER_LOWER, 4));
|
|
|
+ }
|
|
|
File tmpFile = new File(System.getProperty("user.dir"), targetFileName);
|
|
|
opcPackagePkg.save(tmpFile);
|
|
|
|
|
@@ -330,6 +394,29 @@ public class SampleFoodServiceImpl extends ServiceImpl<SampleFoodMapper, SampleF
|
|
|
drawing.setJaxbElement(dmlCtDrawing);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 添加复选框
|
|
|
+ *
|
|
|
+ * @param mappings 映射
|
|
|
+ * @param content 需要勾选的文本
|
|
|
+ */
|
|
|
+ private void checkbox(Map<String, String> mappings, String key, String value, String content) {
|
|
|
+ mappings.put(key, value);
|
|
|
+ if (StrUtil.isBlank(content)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ //按逗号划分
|
|
|
+ String[] split = content.split(",");
|
|
|
+ for (String s : split) {
|
|
|
+ if (StrUtil.isNotBlank(s)) {
|
|
|
+ //勾选
|
|
|
+ value = value.replace("☐" + s, "☑" + s);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ mappings.put(key, value);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void afterAudit(Long sampleId) {
|
|
|
SampleInfo sampleInfo = sampleInfoMapper.selectById(sampleId);
|