|
@@ -2,7 +2,6 @@ package org.springblade.manager.service.impl;
|
|
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.StopWatch;
|
|
|
-import org.springblade.core.mp.support.Query;
|
|
|
import cn.hutool.log.StaticLog;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
@@ -15,33 +14,26 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.mixsmart.utils.FormulaUtils;
|
|
|
import com.mixsmart.utils.ListUtils;
|
|
|
import com.mixsmart.utils.RegexUtils;
|
|
|
-import com.spire.pdf.PdfDocument;
|
|
|
import com.spire.xls.FileFormat;
|
|
|
-import com.spire.xls.Worksheet;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
-import org.apache.poi.ss.usermodel.CellStyle;
|
|
|
-import org.apache.poi.ss.usermodel.Font;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
-import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
import org.apache.poi.util.IOUtils;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.jsoup.Jsoup;
|
|
|
import org.jsoup.nodes.Document;
|
|
|
import org.jsoup.nodes.Element;
|
|
|
+import org.jsoup.nodes.Node;
|
|
|
import org.jsoup.select.Elements;
|
|
|
import org.springblade.business.dto.TrialSelfInspectionRecordDTO;
|
|
|
-import org.springblade.business.entity.ContractLog;
|
|
|
-import org.springblade.business.entity.InformationQuery;
|
|
|
-import org.springblade.business.entity.TrialSelfInspectionRecord;
|
|
|
+import org.springblade.business.entity.*;
|
|
|
import org.springblade.business.feign.ContractLogClient;
|
|
|
import org.springblade.business.feign.InformationQueryClient;
|
|
|
import org.springblade.business.feign.OperationLogClient;
|
|
|
-import org.springblade.business.feign.TrialSelfInspectionRecordClient;
|
|
|
import org.springblade.business.vo.SaveContractLogVO;
|
|
|
import org.springblade.common.constant.CommonConstant;
|
|
|
import org.springblade.common.utils.CommonUtil;
|
|
@@ -50,6 +42,7 @@ import org.springblade.common.vo.DataVO;
|
|
|
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.support.Query;
|
|
|
import org.springblade.core.oss.model.BladeFile;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
@@ -66,14 +59,13 @@ import org.springblade.manager.formula.NodeTable;
|
|
|
import org.springblade.manager.formula.impl.TableElementConverter;
|
|
|
import org.springblade.manager.mapper.ExcelTabMapper;
|
|
|
import org.springblade.manager.service.*;
|
|
|
-import org.springblade.manager.utils.ExcelInfoUtils;
|
|
|
import org.springblade.manager.utils.FileUtils;
|
|
|
import org.springblade.manager.utils.PdfAddimgUtil;
|
|
|
import org.springblade.manager.vo.*;
|
|
|
import org.springblade.resource.feign.NewIOSSClient;
|
|
|
import org.springblade.system.cache.ParamCache;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.dao.DataIntegrityViolationException;
|
|
|
+import org.springframework.dao.DataAccessException;
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
@@ -81,18 +73,13 @@ import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.TransactionDefinition;
|
|
|
import org.springframework.transaction.TransactionStatus;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
|
|
|
|
|
-import java.awt.geom.Rectangle2D;
|
|
|
import java.io.*;
|
|
|
-import java.net.URL;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.List;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
-import java.util.concurrent.ConcurrentSkipListMap;
|
|
|
import java.util.concurrent.CountDownLatch;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.function.Function;
|
|
@@ -358,17 +345,27 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
List<NodeTable> tableAll = createNodeTables(nodeId, tableInfoList.get(0).getContractId(), tableInfoList.get(0).getProjectId(), type,tableInfoList.get(0).getClassify());
|
|
|
if (tableAll.size() > tableInfoList.size()) {
|
|
|
TableInfo example = tableInfoList.get(0);
|
|
|
+
|
|
|
/*补充缺失的数据*/
|
|
|
List<Long> cp = tableInfoList.stream().map(TableInfo::getPkeyId).map(Long::parseLong).collect(Collectors.toList());
|
|
|
List<Long> load = tableAll.stream().map(NodeTable::getPKeyId).filter(pk -> !cp.contains(pk)).collect(Collectors.toList());
|
|
|
+
|
|
|
Map<Long, String> keyMap = tableAll.stream().collect(toMap(NodeTable::getPKeyId, NodeTable::getInitTableName));
|
|
|
Map<String, List<Long>> loadMap = load.stream().collect(Collectors.groupingBy(keyMap::get, Collectors.toList()));
|
|
|
+
|
|
|
loadMap.entrySet().parallelStream().forEach(entry -> {
|
|
|
/*init_table_name*/
|
|
|
String k = entry.getKey();
|
|
|
/*pkeyId集合*/
|
|
|
List<Long> v = entry.getValue();
|
|
|
- List<Map<String, Object>> dataMap = this.jdbcTemplate.queryForList("select * from " + k + " where p_key_id in (" + v.stream().map(Objects::toString).collect(Collectors.joining(",")) + ")");
|
|
|
+ String selSql = "";
|
|
|
+ if(type.equals(ExecuteType.TESTING)) {
|
|
|
+ selSql = "select * from " + k + " where p_key_id in (" + v.stream().map(Objects::toString).collect(Collectors.joining(",")) + ") and group_id="+example.getTestGroupId()+"";
|
|
|
+ }else{
|
|
|
+ selSql = "select * from " + k + " where p_key_id in (" + v.stream().map(Objects::toString).collect(Collectors.joining(",")) + ")";
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Map<String, Object>> dataMap = this.jdbcTemplate.queryForList(selSql);
|
|
|
if (dataMap.size() > 0) {
|
|
|
dataMap.forEach(map -> {
|
|
|
TableInfo e = new TableInfo();
|
|
@@ -2206,6 +2203,9 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
FileUtils.excelToPdf(excelPath, pdfPath);
|
|
|
|
|
|
BladeFile bladeFile = newIOSSClient.uploadFile(pkeyId + ".pdf", pdfPath);
|
|
|
+ if(pkeyId == 1806174262705258575L){
|
|
|
+ System.out.println();
|
|
|
+ }
|
|
|
|
|
|
//附件
|
|
|
TableFile tableFile1 = tableFileService.getBaseMapper().selectList(Wrappers.<TableFile>query().lambda().eq(TableFile::getTabId, pkeyId + "").eq(TableFile::getType, 1)).stream().findAny().orElse(null);
|
|
@@ -2323,6 +2323,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
TableInfo tableInfo = new TableInfo();
|
|
|
JSONObject dataInfo2 = dataArray.getJSONObject(m);
|
|
|
tableInfo.setPkeyId(dataInfo2.getString("pkeyId"));
|
|
|
+ tableInfo.setTestGroupId(dataInfo2.getString("group_id"));
|
|
|
tableInfo.setToBeUpdated(true);
|
|
|
|
|
|
// entrustInfo = 为 委托单信息
|
|
@@ -2410,7 +2411,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
* 试验 获取填报信息
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<Map<String, Object>> getBussDataInfoTrial(Long groupId, Long pkeyId, Long contractId) {
|
|
|
+ public List<Map<String, Object>> getBussDataInfoTrial(Long groupId, Long pkeyId, Long contractId, Long entrustId) {
|
|
|
String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
String sys_file_net_url = ParamCache.getValue(CommonConstant.SYS_FILE_NET_URL);
|
|
|
List<Map<String, Object>> list = new ArrayList<>();
|
|
@@ -2468,6 +2469,26 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
htmlString = htmlString.replaceAll("placeholder", "placeholderxx");
|
|
|
htmlString = htmlString.replaceAll("title", "titlexx");
|
|
|
Document doc = Jsoup.parse(htmlString);
|
|
|
+ if(entrustId != null){
|
|
|
+ //有委托单信息是从实验报告关联委托单进来的 通过委托单查询到具体的样品id
|
|
|
+ String sql = "select * from u_entrust_info where id ="+entrustId;
|
|
|
+ EntrustInfo entrustInfo = jdbcTemplate.queryForObject(sql,new BeanPropertyRowMapper<>(EntrustInfo.class));
|
|
|
+ String sampleId= entrustInfo.getSampleId().toString();
|
|
|
+ String querySql1 = "select * from u_trial_sample_info where id=" + sampleId ;
|
|
|
+ TrialSampleInfo sampleInfo = jdbcTemplate.queryForObject(querySql1, new BeanPropertyRowMapper<>(TrialSampleInfo.class));
|
|
|
+ //用sampleId查询出关联的材料对象
|
|
|
+ String querySql2 = "select * from u_trial_material_mobilization where id =(select mobilization_id from u_trial_sampling_record where sample_info_id = "+sampleId+") ";
|
|
|
+ TrialMaterialMobilization trialMaterialMobilization = null;
|
|
|
+ try {
|
|
|
+ trialMaterialMobilization = jdbcTemplate.queryForObject(querySql2, new BeanPropertyRowMapper<>(TrialMaterialMobilization.class));
|
|
|
+ } catch (DataAccessException e) {
|
|
|
+ trialMaterialMobilization = null;
|
|
|
+ }
|
|
|
+ //通过html获取页面上的key值 返回key值对应的数据
|
|
|
+ setBasicFormData(doc, reData, sampleInfo, trialMaterialMobilization,entrustInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
//匹配
|
|
|
Elements bgBH = doc.select("el-input[placeholderxx~=报告编号.*]");
|
|
|
Elements cbdwBH = doc.select("el-input[placeholderxx~=承包单位.*]");
|
|
@@ -2871,7 +2892,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
}
|
|
|
|
|
|
//获取数据信息info
|
|
|
- List<Map<String, Object>> bussDataInfoTrial = this.getBussDataInfoTrial(id, pkeyId, Long.parseLong(contractId));
|
|
|
+ List<Map<String, Object>> bussDataInfoTrial = this.getBussDataInfoTrial(id, pkeyId, Long.parseLong(contractId),null);
|
|
|
Map<String, Object> DataInfo = new HashMap<>();
|
|
|
if (bussDataInfoTrial.size() > 0) {
|
|
|
DataInfo.putAll(bussDataInfoTrial.stream().findAny().orElse(null));
|
|
@@ -3948,7 +3969,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
}
|
|
|
|
|
|
//获取数据信息info
|
|
|
- List<Map<String, Object>> bussDataInfoTrial = this.getBussDataInfoTrial(groupId, pkeyId, Long.parseLong(contractId));
|
|
|
+ List<Map<String, Object>> bussDataInfoTrial = this.getBussDataInfoTrial(groupId, pkeyId, Long.parseLong(contractId),null);
|
|
|
Map<String, Object> DataInfo = new HashMap<>();
|
|
|
if (bussDataInfoTrial.size() > 0) {
|
|
|
DataInfo.putAll(bussDataInfoTrial.stream().findAny().orElse(null));
|
|
@@ -4326,10 +4347,10 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 试验 委托单获取填报信息
|
|
|
+ * 试验 委托单获取填报信息 groupId和sampleId1必须传其中一个
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<Map<String, Object>> getBussDataInfoTrialentrust(Long groupId, Long pkeyId, Long contractId) {
|
|
|
+ public List<Map<String, Object>> getBussDataInfoTrialentrust(Long groupId, Long pkeyId, Long contractId,Long sampleId1) {
|
|
|
String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
String sys_file_net_url = ParamCache.getValue(CommonConstant.SYS_FILE_NET_URL);
|
|
|
List<Map<String, Object>> list = new ArrayList<>();
|
|
@@ -4355,6 +4376,10 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
//获取引用数据信息
|
|
|
String loadDataId = "";
|
|
|
String sampleId = "";
|
|
|
+ if(groupId == null){
|
|
|
+ sampleId = sampleId1.toString();
|
|
|
+ }
|
|
|
+
|
|
|
try {
|
|
|
String sqlQuery = "select * from u_trial_self_data_record where record_id = " + groupId + " and tab_id = " + pkeyId;
|
|
|
List<Map<String, Object>> stringObjectMap = jdbcTemplate.queryForList(sqlQuery);
|
|
@@ -4362,10 +4387,12 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
loadDataId = stringObjectMap.get(0).get("load_data_id") + "";
|
|
|
}
|
|
|
|
|
|
- String samQuery = "SELECT * from u_entrust_info where id=" + groupId + " ";
|
|
|
- List<Map<String, Object>> strbjectMap = jdbcTemplate.queryForList(samQuery);
|
|
|
- if (strbjectMap != null && strbjectMap.size() >= 1) {
|
|
|
- sampleId = strbjectMap.get(0).get("sample_id") + "";
|
|
|
+ if(groupId !=null){
|
|
|
+ String samQuery = "SELECT * from u_entrust_info where id=" + groupId + " ";
|
|
|
+ List<Map<String, Object>> strbjectMap = jdbcTemplate.queryForList(samQuery);
|
|
|
+ if (strbjectMap != null && strbjectMap.size() >= 1) {
|
|
|
+ sampleId = strbjectMap.get(0).get("sample_id") + "";
|
|
|
+ }
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
@@ -4374,8 +4401,16 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
reData.put("loadDataId", loadDataId);
|
|
|
reData.put("sampleId", sampleId);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+ String querySql1 = "select * from u_trial_sample_info where id=" + sampleId ;
|
|
|
+ TrialSampleInfo sampleInfo = jdbcTemplate.queryForObject(querySql1, new BeanPropertyRowMapper<>(TrialSampleInfo.class));
|
|
|
+ //用sampleId查询出关联的材料对象
|
|
|
+ String querySql2 = "select * from u_trial_material_mobilization where id =(select mobilization_id from u_trial_sampling_record where sample_info_id = "+sampleId+") ";
|
|
|
+ TrialMaterialMobilization trialMaterialMobilization = null;
|
|
|
+ try {
|
|
|
+ trialMaterialMobilization = jdbcTemplate.queryForObject(querySql2, new BeanPropertyRowMapper<>(TrialMaterialMobilization.class));
|
|
|
+ } catch (DataAccessException e) {
|
|
|
+ trialMaterialMobilization = null;
|
|
|
+ }
|
|
|
//实体数据
|
|
|
String querySql = "select * from " + wbsTreePrivate.getInitTableName() + " where p_key_id=" + pkeyId + " and group_id = " + groupId;
|
|
|
List<Map<String, Object>> dataIn = jdbcTemplate.queryForList(querySql);
|
|
@@ -4395,8 +4430,8 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
htmlString = htmlString.replaceAll("placeholder", "placeholderxx");
|
|
|
htmlString = htmlString.replaceAll("title", "titlexx");
|
|
|
Document doc = Jsoup.parse(htmlString);
|
|
|
-
|
|
|
-
|
|
|
+ //通过html获取页面上的key值 返回key值对应的数据
|
|
|
+ setBasicFormData(doc, reData, sampleInfo, trialMaterialMobilization,null);
|
|
|
if (dataIn.size() >= 1) {
|
|
|
Map<String, Object> mysqlData = dataIn.get(0);
|
|
|
for (String key : mysqlData.keySet()) {
|
|
@@ -4494,4 +4529,63 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ private static void setBasicFormData(Document doc, Map<String, Object> reData, TrialSampleInfo sampleInfo ,TrialMaterialMobilization trialMaterialMobilization, EntrustInfo entrustInfo) {
|
|
|
+ setFirstData(doc,"委托编号",entrustInfo.getEntrustNo(),reData);
|
|
|
+ setFirstData(doc,"样品编号",sampleInfo.getSpecificationNumber(),reData);
|
|
|
+ setFirstData(doc,"取样地点",sampleInfo.getSamplingLocation(),reData);
|
|
|
+ setFirstData(doc,"样品描述",sampleInfo.getSampleDescription(),reData);
|
|
|
+ setFirstData(doc,"取样时间",sampleInfo.getSamplingDate(),reData);
|
|
|
+ setFirstData(doc,"取样日期",sampleInfo.getSamplingDate(),reData);
|
|
|
+ setFirstData(doc,"试样名称",sampleInfo.getMaterialName(),reData);
|
|
|
+ setFirstData(doc,"样品名称",sampleInfo.getMaterialName(),reData);
|
|
|
+ setFirstData(doc,"规格 型号",sampleInfo.getSpecificationModel(),reData);
|
|
|
+ setFirstData(doc,"规格型号",sampleInfo.getSpecificationModel(),reData);
|
|
|
+ setFirstData(doc,"试样 数量",sampleInfo.getMaterialCount(),reData);
|
|
|
+ if(trialMaterialMobilization != null){
|
|
|
+ setFirstData(doc,"生产厂家",trialMaterialMobilization.getPlaceOfProduction(),reData);
|
|
|
+ }
|
|
|
+ String representativeCount = sampleInfo.getRepresentativeCount();
|
|
|
+ Date mobilizationDate = sampleInfo.getMobilizationDate();
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:ss:mm");
|
|
|
+ String format = simpleDateFormat.format(mobilizationDate);
|
|
|
+ setFirstData(doc,"批号",sampleInfo.getBatchNumber(),reData);
|
|
|
+ setFirstData(doc,"拟用结构部 位",sampleInfo.getProposedPosition(),reData);
|
|
|
+ setFirstData(doc,"进场日期代表数量",format+representativeCount,reData);
|
|
|
+ }
|
|
|
+ private static void setFirstData(Document doc, String elementValue,Object value,Map<String, Object> reData) {
|
|
|
+
|
|
|
+ Elements select = doc.select("[placeholderxx=" + elementValue + "]");
|
|
|
+ if(select.isEmpty()){
|
|
|
+ elementValue = elementValue + ":";
|
|
|
+ select = doc.select("[placeholderxx=" + elementValue + "]");
|
|
|
+ }
|
|
|
+ if (!select.isEmpty()) {
|
|
|
+ Element textareaElement = select.stream().filter(element -> element.tagName().equals("el-input")).findFirst().orElse(null);
|
|
|
+ if( (elementValue.contains("时间") || elementValue.contains("日期")) && textareaElement == null){
|
|
|
+ textareaElement = select.first();
|
|
|
+ String keyName = textareaElement.attr("keyName");
|
|
|
+ reData.put(keyName, value);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(textareaElement != null){
|
|
|
+ String id = textareaElement.attr("id");
|
|
|
+ reData.put(id, value);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if(elementValue.equals("进场日期代表数量")){
|
|
|
+ Elements select1 = doc.select("[titlexx=\"进场日期/ 代表数量\"]");
|
|
|
+ Element textareaElement = select1.stream().filter(element -> element.tagName().equals("el-input")).findFirst().orElse(null);
|
|
|
+ if(textareaElement != null){
|
|
|
+ List<Node> nodes = textareaElement.childNodes();
|
|
|
+ Node node = nodes.get(1);
|
|
|
+ String id = node.attributes().get("id");
|
|
|
+ reData.put(id, value);
|
|
|
+ }
|
|
|
+// Element textareaElement = select1.first();
|
|
|
+ }else {
|
|
|
+ System.out.println("没有找到[" + elementValue + "]的元素");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|