|
@@ -4537,9 +4537,14 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
}
|
|
|
|
|
|
private static void setBasicFormData(Document doc, Map<String, Object> reData, TrialSampleInfo sampleInfo ,TrialMaterialMobilization trialMaterialMobilization, EntrustInfo entrustInfo) {
|
|
|
- if(entrustInfo != null){
|
|
|
- setFirstData(doc,"委托编号",entrustInfo.getEntrustNo(),reData);
|
|
|
- }
|
|
|
+ String representativeCount = sampleInfo.getRepresentativeCount();
|
|
|
+ String calculationUnit = sampleInfo.getCalculationUnit();
|
|
|
+ Date mobilizationDate = sampleInfo.getMobilizationDate();
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ String format = simpleDateFormat.format(mobilizationDate);
|
|
|
+
|
|
|
+ setFirstData(doc,"批号",sampleInfo.getBatchNumber(),reData);
|
|
|
+ setFirstData(doc,"生产批号",sampleInfo.getBatchNumber(),reData);
|
|
|
setFirstData(doc,"样品编号",sampleInfo.getSpecificationNumber(),reData);
|
|
|
setFirstData(doc,"取样地点",sampleInfo.getSamplingLocation(),reData);
|
|
|
setFirstData(doc,"样品描述",sampleInfo.getSampleDescription(),reData);
|
|
@@ -4547,53 +4552,85 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
setFirstData(doc,"取样日期",sampleInfo.getSamplingDate(),reData);
|
|
|
setFirstData(doc,"试样名称",sampleInfo.getMaterialName(),reData);
|
|
|
setFirstData(doc,"样品名称",sampleInfo.getMaterialName(),reData);
|
|
|
+ setFirstData(doc,"材料名称",sampleInfo.getMaterialName(),reData);
|
|
|
setFirstData(doc,"规格 型号",sampleInfo.getSpecificationModel(),reData);
|
|
|
setFirstData(doc,"规格型号",sampleInfo.getSpecificationModel(),reData);
|
|
|
+ setFirstData(doc,"材料规格",sampleInfo.getSpecificationModel(),reData);
|
|
|
setFirstData(doc,"试样 数量",sampleInfo.getMaterialCount(),reData);
|
|
|
+ setFirstData(doc,"试样数量",sampleInfo.getMaterialCount(),reData);
|
|
|
+ setFirstData(doc,"代表数量",sampleInfo.getMaterialCount(),reData);
|
|
|
+ setFirstData(doc,"拟用结构部 位",sampleInfo.getProposedPosition(),reData);
|
|
|
+ setFirstData(doc,"拟用结构部位",sampleInfo.getProposedPosition(),reData);
|
|
|
+ setFirstData(doc,"用途(使用在何工程部位)",sampleInfo.getProposedPosition(),reData);
|
|
|
+ setFirstData(doc,"进场日期代表数量",format+"/"+representativeCount+calculationUnit,reData);
|
|
|
+ setFirstData(doc,"材料进场日期",format,reData);
|
|
|
+
|
|
|
+ if(entrustInfo != null){
|
|
|
+ setFirstData(doc,"委托编号",entrustInfo.getEntrustNo(),reData);
|
|
|
+ setFirstData(doc,"本批材料数量",entrustInfo.getExpCount()+calculationUnit,reData);
|
|
|
+ }
|
|
|
if(trialMaterialMobilization != null){
|
|
|
setFirstData(doc,"生产厂家",trialMaterialMobilization.getPlaceOfProduction(),reData);
|
|
|
+ setFirstData(doc,"供应商",trialMaterialMobilization.getPlaceOfProduction(),reData);
|
|
|
}
|
|
|
- String representativeCount = sampleInfo.getRepresentativeCount();
|
|
|
- String calculationUnit = sampleInfo.getCalculationUnit();
|
|
|
- Date mobilizationDate = sampleInfo.getMobilizationDate();
|
|
|
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- String format = simpleDateFormat.format(mobilizationDate);
|
|
|
- setFirstData(doc,"批号",sampleInfo.getBatchNumber(),reData);
|
|
|
- setFirstData(doc,"拟用结构部 位",sampleInfo.getProposedPosition(),reData);
|
|
|
- setFirstData(doc,"进场日期代表数量",format+"/"+representativeCount+calculationUnit,reData);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 指定条件查找元素
|
|
|
+ * @param doc
|
|
|
+ * @param elementValue
|
|
|
+ * @param value
|
|
|
+ * @param 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()){//没找到加上:继续找
|
|
|
+ String elementValueNew = elementValue + ":";
|
|
|
+ select = doc.select("[placeholderxx=" + elementValueNew + "]");
|
|
|
+ }
|
|
|
+ if(select.isEmpty()){// 以传入的参数为结尾 继续找
|
|
|
+ select = doc.select("[placeholderxx$=" + elementValue + "]");
|
|
|
}
|
|
|
- if (!select.isEmpty()) {
|
|
|
+
|
|
|
+ if (!select.isEmpty()) {//找到元素后 获取输入框
|
|
|
+
|
|
|
Element textareaElement = select.stream().filter(element -> element.tagName().equals("el-input")).findFirst().orElse(null);
|
|
|
- if( (elementValue.contains("时间") || elementValue.contains("日期")) && textareaElement == null){
|
|
|
+ if( (elementValue.contains("时间") || elementValue.contains("日期")) && textareaElement == null){//特殊处理日期 没有id属性获取keyName
|
|
|
textareaElement = select.first();
|
|
|
String keyName = textareaElement.attr("keyName");
|
|
|
reData.put(keyName, value);
|
|
|
return;
|
|
|
}
|
|
|
- if(textareaElement != null){
|
|
|
+ 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);
|
|
|
+
|
|
|
+ } else {// 没有找到 可能格式不同 换一种方式找
|
|
|
+ Elements select2 = doc.select("[titlexx$="+elementValue+"]");
|
|
|
+ if(select2.isEmpty()){//还是没找到 进入特殊情况
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ System.out.println("没有找到[" + elementValue + "]的元素");
|
|
|
}
|
|
|
-// Element textareaElement = select1.first();
|
|
|
}else {
|
|
|
- System.out.println("没有找到[" + elementValue + "]的元素");
|
|
|
+ //另一种方式找到后 获取id的值并赋值到map
|
|
|
+ Element textareaElement = select2.first();
|
|
|
+
|
|
|
+ if(textareaElement != null){//正常情况
|
|
|
+ String id = textareaElement.attr("id");
|
|
|
+ reData.put(id, value);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|