|
@@ -119,7 +119,31 @@ public class DonorMaterialService extends CrudService<DonorMaterialMapper, Donor
|
|
|
ImportExcel pick = new ImportExcel(file, 6, "甲供材超(欠)供分析表");
|
|
|
//获取领料清单数据
|
|
|
List<DonorMaterial> donorMaterials = getData(pick, projectId, projectName);
|
|
|
- insertList(donorMaterials);
|
|
|
+ //所有领料清单数据
|
|
|
+ Iterator<DonorMaterial> iterator = donorMaterials.iterator();
|
|
|
+ HashMap<String, DonorMaterial> map = new HashMap<>();
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ DonorMaterial next = iterator.next();
|
|
|
+ String materialCode = next.getMaterialCode();
|
|
|
+ String materialName = next.getMaterialName();
|
|
|
+ String materialDescribe = next.getMaterialDescribe();
|
|
|
+ String s = materialCode + materialName + materialDescribe;
|
|
|
+ if (!map.containsKey(s)) {
|
|
|
+ map.put(s, next);
|
|
|
+ } else {
|
|
|
+ DonorMaterial donorMaterial = map.get(s);
|
|
|
+ BigDecimal bigDecimal1 = BigDecimal.valueOf(donorMaterial.getExaminedNum());
|
|
|
+ BigDecimal bigDecimal = BigDecimal.valueOf(next.getExaminedNum());
|
|
|
+ double v = bigDecimal.add(bigDecimal1).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
+ donorMaterial.setExaminedNum(v);
|
|
|
+ map.put(s, donorMaterial);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<DonorMaterial> insertList = new ArrayList<>();
|
|
|
+ for (DonorMaterial d : map.values()) {
|
|
|
+ insertList.add(d);
|
|
|
+ }
|
|
|
+ insertList(insertList);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
@@ -134,7 +158,7 @@ public class DonorMaterialService extends CrudService<DonorMaterialMapper, Donor
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * excel文件数据读取
|
|
|
+ * excel文件数据读取-新增同一个表格中存在多个相同物料的情况
|
|
|
*/
|
|
|
private List<DonorMaterial> getData(ImportExcel importExcel, String projectId, String projectName) throws ParseException {
|
|
|
int lastRow = importExcel.getLastDataRowNum();
|