|
@@ -2,36 +2,56 @@ package org.springblade.business.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.commons.lang.time.DateUtils;
|
|
|
+import org.jsoup.Jsoup;
|
|
|
+import org.jsoup.nodes.Document;
|
|
|
+import org.jsoup.nodes.Element;
|
|
|
+import org.jsoup.select.Elements;
|
|
|
import org.springblade.business.dto.TrialDetectionDataDTO;
|
|
|
import org.springblade.business.dto.TrialDetectionDataPageDTO;
|
|
|
import org.springblade.business.entity.TrialDetectionData;
|
|
|
+import org.springblade.business.entity.TrialSampleInfo;
|
|
|
+import org.springblade.business.entity.TrialSelfInspectionRecord;
|
|
|
import org.springblade.business.mapper.TrialDetectionDataMapper;
|
|
|
import org.springblade.business.mapper.TrialSelfInspectionRecordMapper;
|
|
|
import org.springblade.business.service.ITrialDetectionDataService;
|
|
|
import org.springblade.business.vo.TrialDetectionDataVO;
|
|
|
+import org.springblade.business.vo.TrialSelfSample;
|
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
+import org.springblade.core.log.exception.ServiceException;
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.mp.utils.PageUtil;
|
|
|
-import org.springblade.core.tool.utils.BeanUtil;
|
|
|
-import org.springblade.core.tool.utils.DateUtil;
|
|
|
-import org.springblade.core.tool.utils.Func;
|
|
|
-import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
+import org.springblade.core.tool.utils.*;
|
|
|
+import org.springblade.manager.entity.TextdictInfo;
|
|
|
+import org.springblade.manager.entity.WbsFormElement;
|
|
|
+import org.springblade.manager.entity.WbsTreePrivate;
|
|
|
+import org.springblade.manager.feign.WbsTreeContractClient;
|
|
|
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileInputStream;
|
|
|
+import java.io.FileNotFoundException;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.function.Function;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
|
public class TrialDetectionDataServiceImpl extends BaseServiceImpl<TrialDetectionDataMapper, TrialDetectionData> implements ITrialDetectionDataService {
|
|
|
|
|
|
private final TrialSelfInspectionRecordMapper inspectionRecordMapper;
|
|
|
-
|
|
|
+ private final JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
@Override
|
|
|
public TrialDetectionData dataDetail(Long id) {
|
|
@@ -40,6 +60,34 @@ public class TrialDetectionDataServiceImpl extends BaseServiceImpl<TrialDetectio
|
|
|
|
|
|
@Override
|
|
|
public boolean dataSubmit(TrialDetectionData obj) {
|
|
|
+ List<TrialDetectionData> trialDetectionData = baseMapper.selectList(Wrappers.<TrialDetectionData>lambdaQuery()
|
|
|
+ .select(TrialDetectionData::getId)
|
|
|
+ .isNotNull(TrialDetectionData::getReportNo)
|
|
|
+ .eq(TrialDetectionData::getReportNo, obj.getReportNo()));
|
|
|
+ if (ObjectUtil.isEmpty(obj.getId()) && trialDetectionData.size() > 0) {
|
|
|
+ throw new ServiceException("报告编号已存在,请重新填写");
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(obj.getId()) && trialDetectionData.size() > 0) {
|
|
|
+ TrialDetectionData data = trialDetectionData.stream().findAny().orElse(null);
|
|
|
+ if (!obj.getId().equals(data.getId())) {
|
|
|
+ throw new ServiceException("报告编号已存在,请重新填写");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<TrialDetectionData> trialDetectionData2 = baseMapper.selectList(Wrappers.<TrialDetectionData>lambdaQuery()
|
|
|
+ .select(TrialDetectionData::getId)
|
|
|
+ .isNotNull(TrialDetectionData::getEntrustNo)
|
|
|
+ .eq(TrialDetectionData::getEntrustNo, obj.getEntrustNo()));
|
|
|
+ if (ObjectUtil.isEmpty(obj.getId()) && trialDetectionData2.size() > 0) {
|
|
|
+ throw new ServiceException("委托编号已存在,请重新填写");
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(obj.getId()) && trialDetectionData2.size() > 0) {
|
|
|
+ TrialDetectionData data = trialDetectionData2.stream().findAny().orElse(null);
|
|
|
+ if (!obj.getId().equals(data.getId())) {
|
|
|
+ throw new ServiceException("委托编号已存在,请重新填写");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return this.saveOrUpdate(obj);
|
|
|
}
|
|
|
|
|
@@ -60,7 +108,7 @@ public class TrialDetectionDataServiceImpl extends BaseServiceImpl<TrialDetectio
|
|
|
if (StringUtils.isNotEmpty(dto.getQueryValue())) {
|
|
|
queryWrapper.lambda().and(wrapper -> wrapper.like(TrialDetectionData::getEntrustNo, dto.getQueryValue()).or().like(TrialDetectionData::getReportNo, dto.getQueryValue()));
|
|
|
}
|
|
|
- IPage<TrialDetectionData> pages = this.page(page, queryWrapper.lambda().orderBy(true, true, TrialDetectionData::getCreateTime));
|
|
|
+ IPage<TrialDetectionData> pages = this.page(page, queryWrapper.lambda().orderBy(true, false, TrialDetectionData::getCreateTime));
|
|
|
List<TrialDetectionDataVO> trialDetectionDataVOS = BeanUtil.copyProperties(pages.getRecords(), TrialDetectionDataVO.class);
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(dto.getQualityTestPKeyId())) {
|
|
@@ -100,7 +148,7 @@ public class TrialDetectionDataServiceImpl extends BaseServiceImpl<TrialDetectio
|
|
|
} else {
|
|
|
//单条复制编辑新增保存
|
|
|
TrialDetectionData obj = BeanUtil.copyProperties(dto, TrialDetectionData.class);
|
|
|
- if (obj != null){
|
|
|
+ if (obj != null) {
|
|
|
obj.setId(SnowFlakeUtil.getId());
|
|
|
obj.setEntrustNo(String.valueOf(SnowFlakeUtil.getId()));
|
|
|
obj.setReportNo(String.valueOf(SnowFlakeUtil.getId()));
|
|
@@ -110,6 +158,81 @@ public class TrialDetectionDataServiceImpl extends BaseServiceImpl<TrialDetectio
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<String, String> getRecordSampleData(String tabPKeyId, String sampleIds) {
|
|
|
+ Map<String, String> resultMap = new HashMap<>();
|
|
|
+ //获取表中的数据信息Data、以及对应的Key值
|
|
|
+ WbsTreePrivate wbsTreePrivate = jdbcTemplate.query("select init_table_name,html_url,p_key_id from m_wbs_tree_private where p_key_id =" + tabPKeyId, new BeanPropertyRowMapper<>(WbsTreePrivate.class)).stream().findAny().orElse(null);
|
|
|
+ if (wbsTreePrivate == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (wbsTreePrivate.getHtmlUrl() == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 匹配关联
|
|
|
+ try {
|
|
|
+ File file1 = ResourceUtil.getFile(wbsTreePrivate.getHtmlUrl());
|
|
|
+ String htmlString = IoUtil.readToString(new FileInputStream(file1));
|
|
|
+ Document doc = Jsoup.parse(htmlString);
|
|
|
+ Elements ypName = doc.select("el-input[placeholder~=样品名称.*]");
|
|
|
+ Elements ypNumber = doc.select("el-input[placeholder~=样品编号.*]");
|
|
|
+ Elements ypCount = doc.select("el-input[placeholder~=样品数量.*]");
|
|
|
+ Elements ypMs = doc.select("el-input[placeholder~=样品描述.*]");
|
|
|
+
|
|
|
+ //获取样品信息
|
|
|
+ if (StringUtils.isNotEmpty(sampleIds)) {
|
|
|
+ List<TrialSampleInfo> trialSampleInfoList = jdbcTemplate.query("select material_name,specification_number,sample_description,material_count from u_trial_sample_info where id in(" + sampleIds + ")", new BeanPropertyRowMapper<>(TrialSampleInfo.class));
|
|
|
+ List<String> names = trialSampleInfoList.stream().map(TrialSampleInfo::getMaterialName).collect(Collectors.toList());
|
|
|
+ List<String> numbers = trialSampleInfoList.stream().map(TrialSampleInfo::getSpecificationNumber).collect(Collectors.toList());
|
|
|
+ List<String> descriptions = trialSampleInfoList.stream().map(TrialSampleInfo::getSampleDescription).collect(Collectors.toList());
|
|
|
+ List<Integer> counts = trialSampleInfoList.stream().map(TrialSampleInfo::getMaterialCount).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //样品名称
|
|
|
+ if (ypName.size() >= 1) {
|
|
|
+ for (Element element : ypName) {
|
|
|
+ int trIndex = Integer.parseInt(element.attr("trindex"));
|
|
|
+ if (trIndex <= 6) {
|
|
|
+ resultMap.put(element.attr("keyName"), ObjectUtils.isNotEmpty(names) ? StringUtils.join(names, "、") : "");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //样品编号
|
|
|
+ if (ypNumber.size() >= 1) {
|
|
|
+ for (Element element : ypNumber) {
|
|
|
+ int trIndex = Integer.parseInt(element.attr("trindex"));
|
|
|
+ if (trIndex <= 6) {
|
|
|
+ resultMap.put(element.attr("keyName"), ObjectUtils.isNotEmpty(numbers) ? StringUtils.join(numbers, "、") : "");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //样品数量
|
|
|
+ if (ypCount.size() >= 1) {
|
|
|
+ for (Element element : ypCount) {
|
|
|
+ int trIndex = Integer.parseInt(element.attr("trindex"));
|
|
|
+ if (trIndex <= 6) {
|
|
|
+ resultMap.put(element.attr("keyName"), ObjectUtils.isNotEmpty(counts) ? counts.stream().reduce(Integer::sum).orElse(0).toString() : "");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //样品描述
|
|
|
+ if (ypMs.size() >= 1) {
|
|
|
+ for (Element element : ypMs) {
|
|
|
+ int trIndex = Integer.parseInt(element.attr("trindex"));
|
|
|
+ if (trIndex <= 6) {
|
|
|
+ resultMap.put(element.attr("keyName"), ObjectUtils.isNotEmpty(descriptions) ? StringUtils.join(descriptions, "、") : "");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|