| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				 | 
				
					@ -104,51 +104,282 @@ public class IdentifyBookServiceImpl extends ServiceImpl<IdentifyBookMapper, Ide | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        return fileNames; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//    @Override
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//    public EntrustCaseDTO buildIdentifyBook(String entrustId) throws Exception {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        //获取到制作文书的实验数据
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        R<IdentificationBookDTO> identifyBookData = remoteTestToIdentifyService.getIdentifyBookDataByBusinessId(entrustId);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        log.info("从检验鉴定获取的数据信息 ========》》》》》》》 {}", identifyBookData.getData());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        if (ObjectUtils.isEmpty(identifyBookData.getData())) {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            return null;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        //将获取到的数据封装到 identificationBookDTO 中,我们从这个对象中获取需要的数据
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        IdentificationBookDTO identificationBookDTO = identifyBookData.getData();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        EntrustCaseDTO entrustCaseDTO = entrustmentService.getEntrustCaseDTOById(entrustId);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        //将鉴定ID相同的其他委托ID取出来,由于存在补送,所以我们需要根据鉴定ID查询出其他委托书的数据
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        List<Entrustment> entrustmentList = entrustmentService.list(new LambdaQueryWrapper<Entrustment>()
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                .select(Entrustment::getId)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                .eq(Entrustment::getIdentificationId, entrustCaseDTO.getIdentificationId())
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                .ne(Entrustment::getId, entrustCaseDTO.getId()));//排除自己
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        //将这个案件的所有委托ID全部放在一个列表中
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        List<String> stringIDSList = new ArrayList<>();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        stringIDSList.add(entrustCaseDTO.getId());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        if (CollectionUtils.isNotEmpty(entrustmentList)) {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            stringIDSList.addAll(entrustmentList.stream().map(m -> m.getId()).collect(Collectors.toList()));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        //定义模板填充参数Map
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        //Map<String, Object> retTemplateParameter = ClassUtils.objectToMap(entrustCaseDTO);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        Map<String, Object> retTemplateParameter = ClassUtils.objectToMap(identificationBookDTO.getEntrustInfo());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        //retTemplateParameter.put("acceptTime", sdf.format(entrustCaseDTO.getAcceptTime()));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        retTemplateParameter.put("acceptTime", identificationBookDTO.getEntrustInfo().getAcceptDate().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日")));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        //查出鉴定书的状态信息,根据委托ID
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        IdentifyBookRelevance identifyBookRelevance =
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                identifyBookRelevanceService.getOne(new LambdaQueryWrapper<IdentifyBookRelevance>()
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                        .in(IdentifyBookRelevance::getRelevanceBusinessId, stringIDSList));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        //如果查到鉴定书状态信息表
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        if (ObjectUtils.isNotEmpty(identifyBookRelevance)) {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            identifyBookRelevance.setBookStatus(0);//改变状态
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            //设置模板中用到的参数
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            retTemplateParameter.put("year", identifyBookRelevance.getYear());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            retTemplateParameter.put("serialNumber", identifyBookRelevance.getSerialNumber());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        } else {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            //如果鉴定信息表中不存在记录,那么我们就创建一个
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            // String[] arrNo = entrustCaseDTO.getAcceptNo().split("-");//使用-号来分割
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            String[] arrNo = identificationBookDTO.getEntrustInfo().getAcceptNo().split("-");//使用-号来分割
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            identifyBookRelevance = new IdentifyBookRelevance();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            identifyBookRelevance.setRelevanceBusinessId(entrustId);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            identifyBookRelevance.setYear(arrNo[0]);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            identifyBookRelevance.setSerialNumber(arrNo[1]);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            identifyBookRelevance.setBookStatus(0);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            identifyBookRelevance.setId(IdType.ASSIGN_ID.toString());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        if (ObjectUtils.isNotEmpty(identifyBookRelevance)) {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            // 获取最高的一个版本的文书
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            IdentifyBook identifyBook = identifyBookService.getMaxVersionIdentifyBook(identifyBookRelevance.getId());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            String remarks = "制作文书";
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            String version = "v1.0"; // 默认版本号
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            if (ObjectUtils.isNotEmpty(identifyBook)) {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                version = "v" + new BigDecimal(identifyBook.getVersion().substring(1)).add(new BigDecimal("0.1"));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                remarks = "重新制作文书";
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            String fileName = "鉴定文书-" + version;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            String fileType = ".docx"; // 文件类型
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            //String templateFileName=getIdentifyBookTemplate(entrustCaseDTO);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            String templateFileName = getIdentifyBookTemplate(identificationBookDTO.getEntrustInfo());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            log.info("你选择的模板是:{}", templateFileName);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            String identifyBookPathFileName = OSSDirectoryConstants.IDENTIFY_BOOK_DIRECTORY + "/" + identifyBookRelevance.getRelevanceBusinessId() + "/book/" + fileName; // 鉴定文书存储路径及文件名
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            String submissionSampleList = "submissionSampleList"; // 送检材料集合名称
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            String outcomeSampleList = "outcomeSampleList"; // 检验结果集合名称
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            // 获取送检材料集合--将委托书中对应的检材全部取出放到一个List中
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////            List<EntrustmentIdentificationMaterial> entrustmentIdentificationMaterials = entrustmentIdentificationMaterialService
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                    .list(new LambdaQueryWrapper<EntrustmentIdentificationMaterial>()
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                            .in(EntrustmentIdentificationMaterial::getEntrustmentId, stringIDSList)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                            .orderByAsc(EntrustmentIdentificationMaterial::getAcceptNo));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            //retTemplateParameter.put(submissionSampleList, entrustmentIdentificationMaterials);//检材列表
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            DecimalFormat df = new DecimalFormat("#.00");// 保留两位小数
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            retTemplateParameter.put(
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    submissionSampleList,
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    identificationBookDTO.getSampleInfoList().stream().map(item -> {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                        Map<String, Object> map = new HashMap<>();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                        map.put("acceptNo", item.getAcceptNo());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                        map.put("sampleName", item.getSampleName());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                        map.put("form", item.getForm());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                        map.put("quality", df.format(item.getQuality()));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                        map.put("unit", UnitEnums.fromUnit(item.getUnit()));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                        return map;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    }).collect(Collectors.toList())
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            );//检材列表
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////            // 根据委托ID,查询出实验数据
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////            List<String> experimentIds=new ArrayList<>();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////            List<ExperimentVO> experimentVOList = new ArrayList<>();//实验信息
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////            List<String> experimentAllIds = new ArrayList<>();//实验IDs
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////            List<String> methodIds = new ArrayList<>();//用到的方法IDs
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////            //
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////            experimentAllIds.addAll(experimentIds);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////            for (String experimentId : experimentIds) {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                 Experiment experiment = experimentService.getById(experimentId);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                 ExperimentVO experimentVO = new ExperimentVO();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                 BeanUtil.copyProperties(experiment, experimentVO);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                 experimentVO.setOpUserName(remoteUserService.innerGetById(experimentVO.getOpUserId()).getData().getName());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                 experimentVO.setCreateUserName(remoteUserService.innerGetById(experimentVO.getCreateBy()).getData().getName());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                 experimentVO.setUpdateUserName(remoteUserService.innerGetById(experimentVO.getUpdateBy()).getData().getName());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                 experimentVOList.add(experimentVO);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                 methodIds.add(experiment.getMethodId());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////            }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////            // 取方法列表
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////            List<ExaminationMethods> methodList = examinationMethodsService.list(new LambdaQueryWrapper<ExaminationMethods>()
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                    .in(ExaminationMethods::getId, methodIds));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////            //== 取定性结果
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////            List<ResultEntrustmentQualitative> resultEntrustmentQualitativeList = resultEntrustmentQualitativeService.list(
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                    new LambdaQueryWrapper<ResultEntrustmentQualitative>()
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                            .in(ResultEntrustmentQualitative::getExperimentId, experimentAllIds)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                            .orderByAsc(ResultEntrustmentQualitative::getSampleNo));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////            //== 取定量结果
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////            List<ResultEntrustmentRation> resultEntrustmentRationList = resultEntrustmentRationService.list(
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                    new LambdaQueryWrapper<ResultEntrustmentRation>()
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                            .in(ResultEntrustmentRation::getExperimentId, experimentAllIds)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                            .orderByAsc(ResultEntrustmentRation::getMaterialIndex));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////            //
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////            List<Date> minStartDateList = experimentVOList.stream().map(m -> m.getCreateTime()).collect(Collectors.toList());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////            List<Date> maxEndDateList = experimentVOList.stream().map(m -> m.getFinishDate()).collect(Collectors.toList());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            //retTemplateParameter.put("inspectionStartDate", sdf.format(Collections.min(minStartDateList))); // 检验开始日期(格式:xxxx年xx月xx日)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            retTemplateParameter.put("inspectionStartDate", identificationBookDTO.getEntrustInfo().getAcceptDate().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日"))); // 检验开始日期(格式:xxxx年xx月xx日)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            //
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            retTemplateParameter.put("inspectionLocation", identificationBookDTO.getEntrustInfo().getIdentityDepartment()); // 检验地点
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            //
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////            String inspectionMethod = "";
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////            int i = 1;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////            for (ExaminationMethods methods : methodList){
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                if(StringUtils.isEmpty(inspectionMethod)){ //
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                    inspectionMethod = i + ": " + methods.getMethodName() + "   ( " + methods.getStandardNumber() + " )。";
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                } else {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                    inspectionMethod =inspectionMethod + "\r\n" + i + ": " + methods.getMethodName() + "   ( " + methods.getStandardNumber() + " )。";
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                i++;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////            }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            retTemplateParameter.put("entrustRequirement", identificationBookDTO.getEntrustInfo().getEntrustRequirement());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            retTemplateParameter.put("clientOrgName", identificationBookDTO.getEntrustInfo().getEntrustDepartment());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            retTemplateParameter.put("deliverer1Name", identificationBookDTO.getEntrustInfo().getDeliver1Name());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            retTemplateParameter.put("deliverer2Name", identificationBookDTO.getEntrustInfo().getDeliver2Name());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            retTemplateParameter.put("testResult", identificationBookDTO.getTestResult());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            retTemplateParameter.put("inspectionMethod", identificationBookDTO.getTestMethod()); // 检验方法
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            //检验过程
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            String testProcessStr = "";
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            retTemplateParameter.put("inspectionProcess", identificationBookDTO.getTestProcessDes()); // 检验过程
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            //
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            //retTemplateParameter.put("finishDate", sdf.format(Collections.max(maxEndDateList))); // 实验完成日期(格式:xxxx年xx月xx日)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            retTemplateParameter.put("finishDate", identificationBookDTO.getTestFinishDate()); // 实验完成日期(格式:xxxx年xx月xx日)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            retTemplateParameter.put("appraisalUserName", remoteUserService.innerGetById(identificationBookDTO.getTestOptUser()).getData().getName()); // 鉴定人
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            retTemplateParameter.put("authorizedSignatory", ""); // 授权签字人
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            retTemplateParameter.put("authorizedSignatureDate", ""); // 授权签字人日期
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////            Map<String, Object> objectMap = null;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////            List<Map<String, Object>> mapList = new ArrayList<>();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////            for (ResultEntrustmentQualitative entrustmentQualitative : resultEntrustmentQualitativeList){
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                objectMap = new HashMap<>();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                objectMap.put("materialIndex", entrustmentQualitative.getMaterialIndex());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                objectMap.put("sampleNo", entrustmentQualitative.getSampleNo());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                objectMap.put("qualitativeResultFlag", 1); // 定性结果
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                objectMap.put("qualitativeResult", entrustmentQualitative.getResult()? "检出": "未检出"); // 定性结果
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                objectMap.put("qualitativeCompound", entrustmentQualitative.getCompound()); // 定性检出(化合物)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                objectMap.put("rationResultFlag", -1); // 定量结果
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                objectMap.put("rationResult", "/"); // 定量结果
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                objectMap.put("rationCompound", "/"); // 定量检出(化合物)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                objectMap.put("remark", "/"); // 备注
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                mapList.add(objectMap);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////            }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////            for (ResultEntrustmentRation resultEntrustmentRation : resultEntrustmentRationList){
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                boolean flag = true;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                for(Map<String, Object> map: mapList){
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                    if(resultEntrustmentRation.getSampleNo().equals(map.get("sampleNo"))){
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                        objectMap.put("rationResultFlag", 1); // 定量结果
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                        map.put("rationResult", resultEntrustmentRation.getResult());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                        map.put("rationCompound", resultEntrustmentRation.getCompound());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                        flag = false;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                    }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                if(flag){
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                    objectMap = new HashMap<>();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                    objectMap.put("materialIndex", resultEntrustmentRation.getMaterialIndex());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                    objectMap.put("sampleNo", resultEntrustmentRation.getSampleNo());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                    objectMap.put("qualitativeResultFlag", -1); // 定性结果
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                    objectMap.put("qualitativeResult", "/"); // 定性结果
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                    objectMap.put("qualitativeCompound", "/"); // 定性检出(化合物)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                    objectMap.put("rationResultFlag", 1); // 定量结果
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                    objectMap.put("rationResult", resultEntrustmentRation.getResult()); // 定量结果
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                    objectMap.put("rationCompound", resultEntrustmentRation.getCompound()); // 定量检出(化合物)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                    objectMap.put("remark", "/"); // 备注
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                    mapList.add(objectMap);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////                }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////            }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					////            retTemplateParameter.put(outcomeSampleList, mapList);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            //retTemplateParameter.put("inspectionResult",identifyBookService.qualitativeCodeToZhCn(resultEntrustmentQualitativeList));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            retTemplateParameter.put("inspectionResult", identificationBookDTO.getTestResult());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            // 设置集合名称列表
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            List<String> listNameCollection = new ArrayList<>();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            listNameCollection.add(submissionSampleList);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            listNameCollection.add(outcomeSampleList);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            // 生成文书并上传
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            R r = remoteGenerateWordService.generateWord(templateFileName, null, identifyBookPathFileName, fileType,
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    "", listNameCollection, false, retTemplateParameter);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            if (r != null && r.getCode() == 0) {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                boolean bss = identifyBookRelevanceService.saveOrUpdate(identifyBookRelevance);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                if (!bss) {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    throw new RuntimeException("生成文书时,更新业务状态失败!!!。");
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                // 保存文书相关消息
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                boolean b = this.saveIdentifyBookComm(identifyBookRelevance.getId(), identifyBookPathFileName + fileType,
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                        fileName + fileType, version, remarks);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                if (b) {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    //ossFile.fileGet(identifyBookPathFileName + fileType, response.getOutputStream());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    //response.setContentType(new MimetypesFileTypeMap().getContentType(fileName + fileType));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    String uuid = IdWorker.get32UUID();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    //return R.ok( uuid+"#"+identifyBookPathFileName + fileType, "获取文件成功");
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        return entrustCaseDTO;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//    }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					    @Override | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					    public EntrustCaseDTO buildIdentifyBook(String entrustId) throws Exception { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        //获取到制作文书的实验数据
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        // 调用检验鉴定模块,获取生成鉴定文书所需的数据
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        R<IdentificationBookDTO> identifyBookData = remoteTestToIdentifyService.getIdentifyBookDataByBusinessId(entrustId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        log.info("从检验鉴定获取的数据信息 ========》》》》》》》 {}", identifyBookData.getData()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        if (ObjectUtils.isEmpty(identifyBookData.getData())) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            return null; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        //将获取到的数据封装到 identificationBookDTO 中,我们从这个对象中获取需要的数据
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        // 提取鉴定数据
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        IdentificationBookDTO identificationBookDTO = identifyBookData.getData(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        // 获取当前委托案件的基本信息
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        EntrustCaseDTO entrustCaseDTO = entrustmentService.getEntrustCaseDTOById(entrustId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        //将鉴定ID相同的其他委托ID取出来,由于存在补送,所以我们需要根据鉴定ID查询出其他委托书的数据
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        // 获取当前鉴定 ID 下,除当前委托外的其他委托(处理补送情况)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        List<Entrustment> entrustmentList = entrustmentService.list(new LambdaQueryWrapper<Entrustment>() | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                .select(Entrustment::getId) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                .eq(Entrustment::getIdentificationId, entrustCaseDTO.getIdentificationId()) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                .ne(Entrustment::getId, entrustCaseDTO.getId()));//排除自己
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        //将这个案件的所有委托ID全部放在一个列表中
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                .ne(Entrustment::getId, entrustCaseDTO.getId())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        // 合并所有关联委托 ID(包括当前和其他)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        List<String> stringIDSList = new ArrayList<>(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        stringIDSList.add(entrustCaseDTO.getId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        if (CollectionUtils.isNotEmpty(entrustmentList)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            stringIDSList.addAll(entrustmentList.stream().map(m -> m.getId()).collect(Collectors.toList())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            stringIDSList.addAll(entrustmentList.stream().map(Entrustment::getId).collect(Collectors.toList())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        //定义模板填充参数Map
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        //Map<String, Object> retTemplateParameter = ClassUtils.objectToMap(entrustCaseDTO);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        Map<String, Object> retTemplateParameter = ClassUtils.objectToMap(identificationBookDTO.getEntrustInfo()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        //retTemplateParameter.put("acceptTime", sdf.format(entrustCaseDTO.getAcceptTime()));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        // 构建文书模板参数
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        Map<String, Object> retTemplateParameter = ClassUtils.objectToMap(identificationBookDTO.getEntrustInfo()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        retTemplateParameter.put("acceptTime", identificationBookDTO.getEntrustInfo().getAcceptDate().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日"))); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        //查出鉴定书的状态信息,根据委托ID
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        IdentifyBookRelevance identifyBookRelevance = | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                identifyBookRelevanceService.getOne(new LambdaQueryWrapper<IdentifyBookRelevance>() | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        // 查询当前文书的状态记录(若存在)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        IdentifyBookRelevance identifyBookRelevance = identifyBookRelevanceService.getOne(new LambdaQueryWrapper<IdentifyBookRelevance>() | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                .in(IdentifyBookRelevance::getRelevanceBusinessId, stringIDSList)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        //如果查到鉴定书状态信息表
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        if (ObjectUtils.isNotEmpty(identifyBookRelevance)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            identifyBookRelevance.setBookStatus(0);//改变状态
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            //设置模板中用到的参数
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            // 若已存在,更新状态为“制作中”
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            identifyBookRelevance.setBookStatus(0); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            retTemplateParameter.put("year", identifyBookRelevance.getYear()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            retTemplateParameter.put("serialNumber", identifyBookRelevance.getSerialNumber()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        } else { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            //如果鉴定信息表中不存在记录,那么我们就创建一个
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            // String[] arrNo = entrustCaseDTO.getAcceptNo().split("-");//使用-号来分割
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            String[] arrNo = identificationBookDTO.getEntrustInfo().getAcceptNo().split("-");//使用-号来分割
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            // 否则初始化新的文书状态记录
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            String[] arrNo = identificationBookDTO.getEntrustInfo().getAcceptNo().split("-"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            identifyBookRelevance = new IdentifyBookRelevance(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            identifyBookRelevance.setRelevanceBusinessId(entrustId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            identifyBookRelevance.setYear(arrNo[0]); | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				 | 
				
					@ -158,31 +389,34 @@ public class IdentifyBookServiceImpl extends ServiceImpl<IdentifyBookMapper, Ide | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        if (ObjectUtils.isNotEmpty(identifyBookRelevance)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            // 获取最高的一个版本的文书
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            // 获取该文书历史最大版本号,准备生成新版本
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            IdentifyBook identifyBook = identifyBookService.getMaxVersionIdentifyBook(identifyBookRelevance.getId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            String remarks = "制作文书"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            String version = "v1.0"; // 默认版本号
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            String version = "v1.0"; // 初始版本号
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            if (ObjectUtils.isNotEmpty(identifyBook)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                version = "v" + new BigDecimal(identifyBook.getVersion().substring(1)).add(new BigDecimal("0.1")); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                remarks = "重新制作文书"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            // 生成文书文件名与类型
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            String fileName = "鉴定文书-" + version; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            String fileType = ".docx"; // 文件类型
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            //String templateFileName=getIdentifyBookTemplate(entrustCaseDTO);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            String templateFileName = getIdentifyBookTemplate(identificationBookDTO.getEntrustInfo()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            String fileType = ".docx"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            // 获取文书模板名称 2025-4-15 现在要改成贵阳市局的模板
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            String templateFileName = getIdentifyBookTemplate(identificationBookDTO.getEntrustInfo());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            String templateFileName = "贵阳市公安局禁毒支队实验室检验报告模板.docx"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            log.info("你选择的模板是:{}", templateFileName); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            String identifyBookPathFileName = OSSDirectoryConstants.IDENTIFY_BOOK_DIRECTORY + "/" + identifyBookRelevance.getRelevanceBusinessId() + "/book/" + fileName; // 鉴定文书存储路径及文件名
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            String submissionSampleList = "submissionSampleList"; // 送检材料集合名称
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            String outcomeSampleList = "outcomeSampleList"; // 检验结果集合名称
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            // 获取送检材料集合--将委托书中对应的检材全部取出放到一个List中
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            List<EntrustmentIdentificationMaterial> entrustmentIdentificationMaterials = entrustmentIdentificationMaterialService
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    .list(new LambdaQueryWrapper<EntrustmentIdentificationMaterial>()
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                            .in(EntrustmentIdentificationMaterial::getEntrustmentId, stringIDSList)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                            .orderByAsc(EntrustmentIdentificationMaterial::getAcceptNo));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            //retTemplateParameter.put(submissionSampleList, entrustmentIdentificationMaterials);//检材列表
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            DecimalFormat df = new DecimalFormat("#.00");// 保留两位小数
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            // 定义 OSS 路径,存储文书的位置
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            String identifyBookPathFileName = OSSDirectoryConstants.IDENTIFY_BOOK_DIRECTORY + "/" + identifyBookRelevance.getRelevanceBusinessId() + "/book/" + fileName; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            // 模板中使用到的集合字段名
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            String submissionSampleList = "submissionSampleList"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            String outcomeSampleList = "outcomeSampleList"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            // 构建检材(送检样本)信息
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            DecimalFormat df = new DecimalFormat("#.00"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            retTemplateParameter.put( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                    submissionSampleList, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                    identificationBookDTO.getSampleInfoList().stream().map(item -> { | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				 | 
				
					@ -194,140 +428,47 @@ public class IdentifyBookServiceImpl extends ServiceImpl<IdentifyBookMapper, Ide | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                        map.put("unit", UnitEnums.fromUnit(item.getUnit())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                        return map; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                    }).collect(Collectors.toList()) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            );//检材列表
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            // 根据委托ID,查询出实验数据
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            List<String> experimentIds=new ArrayList<>();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            List<ExperimentVO> experimentVOList = new ArrayList<>();//实验信息
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            List<String> experimentAllIds = new ArrayList<>();//实验IDs
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            List<String> methodIds = new ArrayList<>();//用到的方法IDs
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            //
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            experimentAllIds.addAll(experimentIds);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            for (String experimentId : experimentIds) {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                 Experiment experiment = experimentService.getById(experimentId);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                 ExperimentVO experimentVO = new ExperimentVO();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                 BeanUtil.copyProperties(experiment, experimentVO);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                 experimentVO.setOpUserName(remoteUserService.innerGetById(experimentVO.getOpUserId()).getData().getName());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                 experimentVO.setCreateUserName(remoteUserService.innerGetById(experimentVO.getCreateBy()).getData().getName());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                 experimentVO.setUpdateUserName(remoteUserService.innerGetById(experimentVO.getUpdateBy()).getData().getName());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                 experimentVOList.add(experimentVO);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                 methodIds.add(experiment.getMethodId());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            // 取方法列表
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            List<ExaminationMethods> methodList = examinationMethodsService.list(new LambdaQueryWrapper<ExaminationMethods>()
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    .in(ExaminationMethods::getId, methodIds));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            //== 取定性结果
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            List<ResultEntrustmentQualitative> resultEntrustmentQualitativeList = resultEntrustmentQualitativeService.list(
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    new LambdaQueryWrapper<ResultEntrustmentQualitative>()
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                            .in(ResultEntrustmentQualitative::getExperimentId, experimentAllIds)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                            .orderByAsc(ResultEntrustmentQualitative::getSampleNo));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            //== 取定量结果
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            List<ResultEntrustmentRation> resultEntrustmentRationList = resultEntrustmentRationService.list(
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    new LambdaQueryWrapper<ResultEntrustmentRation>()
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                            .in(ResultEntrustmentRation::getExperimentId, experimentAllIds)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                            .orderByAsc(ResultEntrustmentRation::getMaterialIndex));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            //
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            List<Date> minStartDateList = experimentVOList.stream().map(m -> m.getCreateTime()).collect(Collectors.toList());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            List<Date> maxEndDateList = experimentVOList.stream().map(m -> m.getFinishDate()).collect(Collectors.toList());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            //retTemplateParameter.put("inspectionStartDate", sdf.format(Collections.min(minStartDateList))); // 检验开始日期(格式:xxxx年xx月xx日)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            retTemplateParameter.put("inspectionStartDate", identificationBookDTO.getEntrustInfo().getAcceptDate().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日"))); // 检验开始日期(格式:xxxx年xx月xx日)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            //
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            retTemplateParameter.put("inspectionLocation", identificationBookDTO.getEntrustInfo().getIdentityDepartment()); // 检验地点
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            //
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            String inspectionMethod = "";
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            int i = 1;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            for (ExaminationMethods methods : methodList){
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                if(StringUtils.isEmpty(inspectionMethod)){ //
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    inspectionMethod = i + ": " + methods.getMethodName() + "   ( " + methods.getStandardNumber() + " )。";
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                } else {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    inspectionMethod =inspectionMethod + "\r\n" + i + ": " + methods.getMethodName() + "   ( " + methods.getStandardNumber() + " )。";
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                i++;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            retTemplateParameter.put("entrustRequirement", identificationBookDTO.getEntrustInfo().getEntrustRequirement()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            retTemplateParameter.put("clientOrgName", identificationBookDTO.getEntrustInfo().getEntrustDepartment()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            retTemplateParameter.put("deliverer1Name", identificationBookDTO.getEntrustInfo().getDeliver1Name()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            retTemplateParameter.put("deliverer2Name", identificationBookDTO.getEntrustInfo().getDeliver2Name()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            retTemplateParameter.put("testResult", identificationBookDTO.getTestResult()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            retTemplateParameter.put("inspectionMethod", identificationBookDTO.getTestMethod()); // 检验方法
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            //检验过程
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            String testProcessStr = ""; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            retTemplateParameter.put("inspectionProcess", identificationBookDTO.getTestProcessDes()); // 检验过程
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            //
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            //retTemplateParameter.put("finishDate", sdf.format(Collections.max(maxEndDateList))); // 实验完成日期(格式:xxxx年xx月xx日)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            retTemplateParameter.put("finishDate", identificationBookDTO.getTestFinishDate()); // 实验完成日期(格式:xxxx年xx月xx日)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            retTemplateParameter.put("appraisalUserName", remoteUserService.innerGetById(identificationBookDTO.getTestOptUser()).getData().getName()); // 鉴定人
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            retTemplateParameter.put("authorizedSignatory", ""); // 授权签字人
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            retTemplateParameter.put("authorizedSignatureDate", ""); // 授权签字人日期
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            Map<String, Object> objectMap = null;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            List<Map<String, Object>> mapList = new ArrayList<>();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            for (ResultEntrustmentQualitative entrustmentQualitative : resultEntrustmentQualitativeList){
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                objectMap = new HashMap<>();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                objectMap.put("materialIndex", entrustmentQualitative.getMaterialIndex());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                objectMap.put("sampleNo", entrustmentQualitative.getSampleNo());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                objectMap.put("qualitativeResultFlag", 1); // 定性结果
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                objectMap.put("qualitativeResult", entrustmentQualitative.getResult()? "检出": "未检出"); // 定性结果
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                objectMap.put("qualitativeCompound", entrustmentQualitative.getCompound()); // 定性检出(化合物)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                objectMap.put("rationResultFlag", -1); // 定量结果
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                objectMap.put("rationResult", "/"); // 定量结果
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                objectMap.put("rationCompound", "/"); // 定量检出(化合物)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                objectMap.put("remark", "/"); // 备注
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                mapList.add(objectMap);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            for (ResultEntrustmentRation resultEntrustmentRation : resultEntrustmentRationList){
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                boolean flag = true;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                for(Map<String, Object> map: mapList){
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    if(resultEntrustmentRation.getSampleNo().equals(map.get("sampleNo"))){
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                        objectMap.put("rationResultFlag", 1); // 定量结果
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                        map.put("rationResult", resultEntrustmentRation.getResult());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                        map.put("rationCompound", resultEntrustmentRation.getCompound());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                        flag = false;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                if(flag){
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    objectMap = new HashMap<>();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    objectMap.put("materialIndex", resultEntrustmentRation.getMaterialIndex());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    objectMap.put("sampleNo", resultEntrustmentRation.getSampleNo());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    objectMap.put("qualitativeResultFlag", -1); // 定性结果
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    objectMap.put("qualitativeResult", "/"); // 定性结果
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    objectMap.put("qualitativeCompound", "/"); // 定性检出(化合物)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    objectMap.put("rationResultFlag", 1); // 定量结果
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    objectMap.put("rationResult", resultEntrustmentRation.getResult()); // 定量结果
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    objectMap.put("rationCompound", resultEntrustmentRation.getCompound()); // 定量检出(化合物)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    objectMap.put("remark", "/"); // 备注
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    mapList.add(objectMap);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            retTemplateParameter.put(outcomeSampleList, mapList);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            ); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            //retTemplateParameter.put("inspectionResult",identifyBookService.qualitativeCodeToZhCn(resultEntrustmentQualitativeList));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            retTemplateParameter.put("inspectionResult", identificationBookDTO.getTestResult()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            EntrustInfo entrustInfo = identificationBookDTO.getEntrustInfo(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            // 添加其他模板参数(检验信息)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            String[] split = entrustInfo.getAcceptNo().split("-"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            if (split.length == 2) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                retTemplateParameter.put("acceptNo", "[" + split[0] + "]" + split[1] + "号"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            retTemplateParameter.put("entrustDepartment", entrustInfo.getEntrustDepartment()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            retTemplateParameter.put("deliver1Name", entrustInfo.getDeliver1Name()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            retTemplateParameter.put("deliver2Name", entrustInfo.getDeliver2Name()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            // 格式化受理时间,添加到模板参数中
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            retTemplateParameter.put("acceptTime", entrustInfo.getAcceptDate().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日"))); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            retTemplateParameter.put("caseBrief", entrustInfo.getCaseBrief()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            retTemplateParameter.put("materialCharacterDesc", identificationBookDTO.getMaterialCharacterDesc()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            retTemplateParameter.put("materialIngredient", identificationBookDTO.getMaterialIngredient()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            retTemplateParameter.put("testStartDate", identificationBookDTO.getTestStartDate()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            retTemplateParameter.put("testMethod", identificationBookDTO.getTestMethod()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            retTemplateParameter.put("testResult", identificationBookDTO.getTestResult()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            // 设置集合名称列表
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            // 添加集合字段名列表(用于识别 Word 模板中的列表)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            List<String> listNameCollection = new ArrayList<>(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            listNameCollection.add(submissionSampleList); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            listNameCollection.add(outcomeSampleList); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            // 生成文书并上传
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            // 调用远程服务生成 Word 文档并上传至 OSS
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            R r = remoteGenerateWordService.generateWord(templateFileName, null, identifyBookPathFileName, fileType, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                    "", listNameCollection, false, retTemplateParameter); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            if (r != null && r.getCode() == 0) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                // 更新文书状态记录表
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                boolean bss = identifyBookRelevanceService.saveOrUpdate(identifyBookRelevance); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                if (!bss) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                    throw new RuntimeException("生成文书时,更新业务状态失败!!!。"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                // 保存文书相关消息
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                // 保存文书记录(元信息)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                boolean b = this.saveIdentifyBookComm(identifyBookRelevance.getId(), identifyBookPathFileName + fileType, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                        fileName + fileType, version, remarks); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                if (b) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                    //ossFile.fileGet(identifyBookPathFileName + fileType, response.getOutputStream());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                    //response.setContentType(new MimetypesFileTypeMap().getContentType(fileName + fileType));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                    String uuid = IdWorker.get32UUID(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                    // return R.ok(uuid + "#" + identifyBookPathFileName + fileType, "获取文件成功");
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                } | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				 | 
				
					@ -336,6 +477,7 @@ public class IdentifyBookServiceImpl extends ServiceImpl<IdentifyBookMapper, Ide | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        return entrustCaseDTO; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					    /** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					     * 选择模板,根据业务选择模板,可能的业务有,毛发鉴定报告模板,NPS案件的鉴定报告模板 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					     * | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				 | 
				
					
  |