|
|
@@ -18,6 +18,7 @@ package org.springblade.mocha.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springblade.client.entity.CorpsDesc;
|
|
|
@@ -38,6 +39,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
@@ -96,7 +98,9 @@ public class PriceBankServiceImpl extends ServiceImpl<PriceBankMapper, PriceBank
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void importUser(List<PriceBankExcel> data, Boolean isCovered) {
|
|
|
+ public R importUser(List<PriceBankExcel> data, Boolean isCovered) {
|
|
|
+ List<String> corpList = new ArrayList<>();//供应商不存在的集合
|
|
|
+ List<String> goodList = new ArrayList<>();//商品不存在的
|
|
|
data.stream().forEach(item ->{
|
|
|
//先查供应商 看供应商是否存在
|
|
|
PriceBank priceBank = new PriceBank();
|
|
|
@@ -134,7 +138,7 @@ public class PriceBankServiceImpl extends ServiceImpl<PriceBankMapper, PriceBank
|
|
|
priceBank.setBillType(item.getBillType());
|
|
|
}
|
|
|
//采购报价=单价 / (1+税率/100) *(1+FOB系数/100)
|
|
|
- priceBank.setPurchaseAmount(priceBank.getPrice().divide((new BigDecimal(1).add((priceBank.getTaxRate().divide(new BigDecimal(100),2)))).multiply(new BigDecimal(1).add((priceBank.getCoefficient().divide(new BigDecimal(100),2)))),2));
|
|
|
+ priceBank.setPurchaseAmount(priceBank.getPrice().divide((new BigDecimal(1).add((priceBank.getTaxRate().divide(new BigDecimal(100))))),4).multiply(new BigDecimal(1).add((priceBank.getCoefficient().divide(new BigDecimal(100))))));
|
|
|
if (StringUtils.isNotBlank(item.getCorpName())){
|
|
|
R<CorpsDesc> corpByName = corpsDescClient.getCorpByName(item.getCorpName(), SecureUtil.getTenantId());
|
|
|
if (corpByName.isSuccess() && corpByName.getData() != null){
|
|
|
@@ -170,10 +174,29 @@ public class PriceBankServiceImpl extends ServiceImpl<PriceBankMapper, PriceBank
|
|
|
baseMapper.updateById(priceBank);
|
|
|
}
|
|
|
|
|
|
+ }else {
|
|
|
+ goodList.add(item.getCname());
|
|
|
}
|
|
|
+ }else {
|
|
|
+ corpList.add(item.getCorpName());
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
+ if (CollectionUtils.isNotEmpty(corpList) || CollectionUtils.isNotEmpty(goodList)){
|
|
|
+ String message = new String();
|
|
|
+ if (CollectionUtils.isNotEmpty(corpList)){
|
|
|
+ StringBuffer stringBuffer = new StringBuffer("未找到供应商的有:");
|
|
|
+ stringBuffer.append(org.apache.commons.lang.StringUtils.join(corpList.toArray(), ","));
|
|
|
+ message = message + stringBuffer.toString();
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(goodList)){
|
|
|
+ StringBuffer stringBuffer = new StringBuffer("根据供应商和商品名未找到商品的有:");
|
|
|
+ stringBuffer.append(org.apache.commons.lang.StringUtils.join(goodList.toArray(), ","));
|
|
|
+ message = message + stringBuffer.toString();
|
|
|
+ }
|
|
|
+ return R.data(message);
|
|
|
+ }
|
|
|
+ return R.data("导入成功");
|
|
|
}
|
|
|
|
|
|
}
|