|
@@ -2411,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<>();
|
|
@@ -2469,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~=承包单位.*]");
|
|
@@ -2872,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));
|
|
@@ -3949,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));
|
|
@@ -4411,7 +4431,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
htmlString = htmlString.replaceAll("title", "titlexx");
|
|
|
Document doc = Jsoup.parse(htmlString);
|
|
|
//通过html获取页面上的key值 返回key值对应的数据
|
|
|
- setBasicFormData(doc, reData, sampleInfo, trialMaterialMobilization);
|
|
|
+ setBasicFormData(doc, reData, sampleInfo, trialMaterialMobilization,null);
|
|
|
if (dataIn.size() >= 1) {
|
|
|
Map<String, Object> mysqlData = dataIn.get(0);
|
|
|
for (String key : mysqlData.keySet()) {
|
|
@@ -4509,32 +4529,17 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
- private static void setBasicFormData(Document doc, Map<String, Object> reData, TrialSampleInfo sampleInfo ,TrialMaterialMobilization trialMaterialMobilization) {
|
|
|
-// //样品编号
|
|
|
-// String specificationNumber = sampleInfo.getSpecificationNumber();
|
|
|
-// Elements specificationNumberElements = doc.select("[placeholderxx=样品编号]");
|
|
|
-// if (!specificationNumberElements.isEmpty()) {
|
|
|
-// Element textareaElement = specificationNumberElements.first();
|
|
|
-// String id = textareaElement.attr("id");
|
|
|
-// reData.put(id, specificationNumber);
|
|
|
-// } else {
|
|
|
-// throw new RuntimeException("没有找到[placeholderxx=样品编号]的元素");
|
|
|
-// }
|
|
|
-// //取样地点
|
|
|
-// String samplingLocation = sampleInfo.getSamplingLocation();
|
|
|
-// Elements samplingLocationElements = doc.select("[placeholderxx=取样地点]");
|
|
|
-// if (!samplingLocationElements.isEmpty()) {
|
|
|
-// Element textareaElement = samplingLocationElements.first();
|
|
|
-// String id = textareaElement.attr("id");
|
|
|
-// reData.put(id, samplingLocation);
|
|
|
-// } else {
|
|
|
-// throw new RuntimeException("没有找到[placeholderxx=取样地点]的元素");
|
|
|
-// }
|
|
|
+ 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);
|
|
@@ -4550,18 +4555,33 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
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.first();
|
|
|
- String id = textareaElement.attr("id");
|
|
|
- reData.put(id, value);
|
|
|
+ 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.first();
|
|
|
- List<Node> nodes = textareaElement.childNodes();
|
|
|
- Node node = nodes.get(1);
|
|
|
- String id = node.attributes().get("id");
|
|
|
- reData.put(id, value);
|
|
|
+ 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 + "]的元素");
|
|
|
}
|