|
@@ -1,6 +1,7 @@
|
|
package org.jeecg.modules.costModelWxPrice.service.impl;
|
|
package org.jeecg.modules.costModelWxPrice.service.impl;
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.hibernate.query.criteria.internal.expression.function.AggregationFunction;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.modules.costModelWxPrice.entity.CostModelWxPrice;
|
|
import org.jeecg.modules.costModelWxPrice.entity.CostModelWxPrice;
|
|
import org.jeecg.modules.costModelWxPrice.mapper.CostModelWxPriceMapper;
|
|
import org.jeecg.modules.costModelWxPrice.mapper.CostModelWxPriceMapper;
|
|
@@ -42,7 +43,7 @@ public class CostModelWxPriceServiceImpl extends ServiceImpl<CostModelWxPriceMap
|
|
return wxpMapper.getWXPAllDetailList();
|
|
return wxpMapper.getWXPAllDetailList();
|
|
}
|
|
}
|
|
|
|
|
|
- /**查看表中所有数据-用来判断导入的数据是否有重复数据*/
|
|
|
|
|
|
+ /**外协价格库-通过外协项目查看表中的数据-用来判断导入的数据是否有重复数据*/
|
|
public List<CostModelWxPrice> getWXPFProDetailList(String wx_project){
|
|
public List<CostModelWxPrice> getWXPFProDetailList(String wx_project){
|
|
return wxpMapper.getWXPFProDetailList(wx_project);
|
|
return wxpMapper.getWXPFProDetailList(wx_project);
|
|
}
|
|
}
|
|
@@ -91,19 +92,36 @@ public class CostModelWxPriceServiceImpl extends ServiceImpl<CostModelWxPriceMap
|
|
//4.判断去重后的listNew中是否有数据已经在数据库中记录过了,如果已经保存过直接删掉
|
|
//4.判断去重后的listNew中是否有数据已经在数据库中记录过了,如果已经保存过直接删掉
|
|
while(iterator.hasNext()){
|
|
while(iterator.hasNext()){
|
|
CostModelWxPrice wxpNew = iterator.next();
|
|
CostModelWxPrice wxpNew = iterator.next();
|
|
- //5.此处的条件可能更改,目前是外协项目、单价、计量单位都不为null的数据才能进行判断是否重复在确定是否录入数据
|
|
|
|
- if((wxpNew.getWxProject()!=null)&(wxpNew.getDanjia()!=null)&(wxpNew.getUnit()!=null)){
|
|
|
|
|
|
+ //5.此处的条件可能更改,目前是外协项目、外协单位、单价最大值、单价最小值、计量单位都不为null的数据才能进行判断是否重复在确定是否录入数据
|
|
|
|
+ if((wxpNew.getWxProject()!=null)&(wxpNew.getWxCompany()!=null)&(wxpNew.getMaxPrice()!=null)&(wxpNew.getMinPrice()!=null)&(wxpNew.getUnit()!=null)){
|
|
|
|
+ boolean noRepeat = true; //用来判断数据是否重复
|
|
//6.从数据库中取出对应外协项目的数据内容
|
|
//6.从数据库中取出对应外协项目的数据内容
|
|
List<CostModelWxPrice> list1 = getWXPFProDetailList(wxpNew.getWxProject());
|
|
List<CostModelWxPrice> list1 = getWXPFProDetailList(wxpNew.getWxProject());
|
|
|
|
+// System.out.println("从数据库中取出的数据");
|
|
|
|
+// list1.forEach(System.out::println);
|
|
|
|
|
|
|
|
+ //7.与数据库中的数据比较,如果数据重复,则删除,如果数据不重复,计算平均值,在将整条信息进行录入
|
|
for(CostModelWxPrice wxp1:list1) {
|
|
for(CostModelWxPrice wxp1:list1) {
|
|
- if((Objects.equals(wxpNew.getDanjia(), wxp1.getDanjia()))&(Objects.equals(wxpNew.getUnit(), wxp1.getUnit()))&(Objects.equals(wxpNew.getWxCompany(), wxp1.getWxCompany()))){
|
|
|
|
|
|
+ //因为根据外协项目查找的数据库数据,所以不用再比较外协项目
|
|
|
|
+ if((Objects.equals(wxpNew.getMaxPrice(), wxp1.getMaxPrice()))&(Objects.equals(wxpNew.getMinPrice(), wxp1.getMinPrice()))&(Objects.equals(wxpNew.getUnit(), wxp1.getUnit()))&(Objects.equals(wxpNew.getWxCompany(), wxp1.getWxCompany()))){
|
|
iterator.remove();
|
|
iterator.remove();
|
|
|
|
+ noRepeat = false;
|
|
//System.out.println("当前元素重复,进行删除");
|
|
//System.out.println("当前元素重复,进行删除");
|
|
//listNew.forEach(System.out::println); //foreach中不能remove,不然会报错java.util.ConcurrentModificationException
|
|
//listNew.forEach(System.out::println); //foreach中不能remove,不然会报错java.util.ConcurrentModificationException
|
|
break;//因为wxpNew元素已经被删除了,所有此段循环可以跳过了
|
|
break;//因为wxpNew元素已经被删除了,所有此段循环可以跳过了
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if(noRepeat){
|
|
|
|
+ try{
|
|
|
|
+ //计算平均值并写入list
|
|
|
|
+ wxpNew.setAvePrice(Float.toString((Float.parseFloat(wxpNew.getMaxPrice())+Float.parseFloat(wxpNew.getMinPrice()))/2));
|
|
|
|
+
|
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
|
+ System.out.println("Float.parseFloat(String)方法执行异常");
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
else{
|
|
else{
|
|
//System.out.println("当前关键数据内容为空,删除");
|
|
//System.out.println("当前关键数据内容为空,删除");
|