|
@@ -42,10 +42,15 @@ public class CostModelWxPriceServiceImpl extends ServiceImpl<CostModelWxPriceMap
|
|
|
return wxpMapper.getWXPAllDetailList();
|
|
|
}
|
|
|
|
|
|
+ /**查看表中所有数据-用来判断导入的数据是否有重复数据*/
|
|
|
+ public List<CostModelWxPrice> getWXPFProDetailList(String wx_project){
|
|
|
+ return wxpMapper.getWXPFProDetailList(wx_project);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 通过excel导入数据
|
|
|
- *如果数据重复,删除重复的数据,然后在写入数据库
|
|
|
- * 当前是取数据库中所有的数据进行比较,如果确定哪个字段是必须有值不能为null,可以根据该字段找出来相应数据再进行比较 --sl
|
|
|
+ * 如果数据重复,删除重复的数据,然后在写入数据库
|
|
|
+ * 根据外协项目字段从数据库中取相关数据,再判断数据是否重复,重复的数据不予录入
|
|
|
*
|
|
|
* @param request
|
|
|
* @param response
|
|
@@ -78,7 +83,7 @@ public class CostModelWxPriceServiceImpl extends ServiceImpl<CostModelWxPriceMap
|
|
|
// listNew.forEach(System.out::println);
|
|
|
|
|
|
//3.从数据库中读取全部表中数据
|
|
|
- List<CostModelWxPrice> list1 = getWXPAllDetailList();
|
|
|
+// List<CostModelWxPrice> list1 = getWXPAllDetailList();
|
|
|
// System.out.println("从数据库中取出的数据");
|
|
|
// list1.forEach(System.out::println);
|
|
|
|
|
@@ -86,13 +91,13 @@ public class CostModelWxPriceServiceImpl extends ServiceImpl<CostModelWxPriceMap
|
|
|
//4.判断去重后的listNew中是否有数据已经在数据库中记录过了,如果已经保存过直接删掉
|
|
|
while(iterator.hasNext()){
|
|
|
CostModelWxPrice wxpNew = iterator.next();
|
|
|
- if((wxpNew.getWxProject()==null)&(wxpNew.getDanjia()==null)&(wxpNew.getUnit()==null)&(wxpNew.getWxCompany()==null)){
|
|
|
- //System.out.println("当前数据内容都为空,删除");
|
|
|
- iterator.remove();
|
|
|
- }
|
|
|
- else{
|
|
|
+ //5.此处的条件可能更改,目前是外协项目、单价、计量单位都不为null的数据才能进行判断是否重复在确定是否录入数据
|
|
|
+ if((wxpNew.getWxProject()!=null)&(wxpNew.getDanjia()!=null)&(wxpNew.getUnit()!=null)){
|
|
|
+ //6.从数据库中取出对应外协项目的数据内容
|
|
|
+ List<CostModelWxPrice> list1 = getWXPFProDetailList(wxpNew.getWxProject());
|
|
|
+
|
|
|
for(CostModelWxPrice wxp1:list1) {
|
|
|
- if((Objects.equals(wxpNew.getWxProject(), wxp1.getWxProject()))&(Objects.equals(wxpNew.getDanjia(), wxp1.getDanjia()))&(Objects.equals(wxpNew.getUnit(), wxp1.getUnit()))&(Objects.equals(wxpNew.getWxCompany(), wxp1.getWxCompany()))){
|
|
|
+ if((Objects.equals(wxpNew.getDanjia(), wxp1.getDanjia()))&(Objects.equals(wxpNew.getUnit(), wxp1.getUnit()))&(Objects.equals(wxpNew.getWxCompany(), wxp1.getWxCompany()))){
|
|
|
iterator.remove();
|
|
|
//System.out.println("当前元素重复,进行删除");
|
|
|
//listNew.forEach(System.out::println); //foreach中不能remove,不然会报错java.util.ConcurrentModificationException
|
|
@@ -100,6 +105,10 @@ public class CostModelWxPriceServiceImpl extends ServiceImpl<CostModelWxPriceMap
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ else{
|
|
|
+ //System.out.println("当前关键数据内容为空,删除");
|
|
|
+ iterator.remove();
|
|
|
+ }
|
|
|
}
|
|
|
// System.out.println("最终需要存入的数据");
|
|
|
// listNew.forEach(System.out::println);
|