|
@@ -1,11 +1,9 @@
|
|
package com.fjhx.supply.service.supplier.impl;
|
|
package com.fjhx.supply.service.supplier.impl;
|
|
|
|
|
|
-import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
|
-import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
-import com.fjhx.common.constant.SourceConstant;
|
|
|
|
import com.fjhx.item.entity.product.po.ProductInfo;
|
|
import com.fjhx.item.entity.product.po.ProductInfo;
|
|
import com.fjhx.item.service.product.ProductClassifyService;
|
|
import com.fjhx.item.service.product.ProductClassifyService;
|
|
import com.fjhx.item.service.product.ProductInfoService;
|
|
import com.fjhx.item.service.product.ProductInfoService;
|
|
@@ -17,8 +15,10 @@ import com.fjhx.supply.entity.supplier.vo.SupplierPriceAddVo;
|
|
import com.fjhx.supply.entity.supplier.vo.SupplierPriceVo;
|
|
import com.fjhx.supply.entity.supplier.vo.SupplierPriceVo;
|
|
import com.fjhx.supply.mapper.supplier.SupplierPriceMapper;
|
|
import com.fjhx.supply.mapper.supplier.SupplierPriceMapper;
|
|
import com.fjhx.supply.service.supplier.SupplierPriceService;
|
|
import com.fjhx.supply.service.supplier.SupplierPriceService;
|
|
|
|
+import com.fjhx.tenant.utils.DeptUstil;
|
|
import com.ruoyi.common.core.domain.BaseIdPo;
|
|
import com.ruoyi.common.core.domain.BaseIdPo;
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
|
+import com.ruoyi.common.utils.SecurityUtils;
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
import com.ruoyi.common.utils.wrapper.SqlField;
|
|
import com.ruoyi.common.utils.wrapper.SqlField;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -70,6 +70,9 @@ public class SupplierPriceServiceImpl extends ServiceImpl<SupplierPriceMapper, S
|
|
wrapper.eq("si", SupplierInfo::getType, dto.getSupplierType());
|
|
wrapper.eq("si", SupplierInfo::getType, dto.getSupplierType());
|
|
wrapper.keyword(dto, new SqlField("si.name"));
|
|
wrapper.keyword(dto, new SqlField("si.name"));
|
|
|
|
|
|
|
|
+ //权限过滤:供应商价格自己看自己
|
|
|
|
+ wrapper.eq("sp", SupplierPrice::getCompanyId, SecurityUtils.getCompanyId());
|
|
|
|
+
|
|
Page<SupplierPriceVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
Page<SupplierPriceVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
List<SupplierPriceVo> records = page.getRecords();
|
|
List<SupplierPriceVo> records = page.getRecords();
|
|
|
|
|
|
@@ -92,6 +95,15 @@ public class SupplierPriceServiceImpl extends ServiceImpl<SupplierPriceMapper, S
|
|
item.setProductClassifyName(productClassify.getName());
|
|
item.setProductClassifyName(productClassify.getName());
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ //获取归属公司信息
|
|
|
|
+ List<Long> companyIds = records.stream().map(SupplierPrice::getCompanyId).collect(Collectors.toList());
|
|
|
|
+ Map<Long, String> companyNameMap = DeptUstil.getDeptNameMap(companyIds);
|
|
|
|
+
|
|
|
|
+ for (SupplierPriceVo record : records) {
|
|
|
|
+ //赋值生产公司名称
|
|
|
|
+ record.setCompanyName(companyNameMap.get(record.getCompanyId()));
|
|
|
|
+ }
|
|
|
|
+
|
|
// DynamicDataSourceContextHolder.clear();
|
|
// DynamicDataSourceContextHolder.clear();
|
|
return page;
|
|
return page;
|
|
}
|
|
}
|
|
@@ -102,6 +114,14 @@ public class SupplierPriceServiceImpl extends ServiceImpl<SupplierPriceMapper, S
|
|
|
|
|
|
// 添加产品列表
|
|
// 添加产品列表
|
|
List<SupplierPrice> supplierPriceList = supplierPriceDto.getSupplierPriceList();
|
|
List<SupplierPrice> supplierPriceList = supplierPriceDto.getSupplierPriceList();
|
|
|
|
+ for (SupplierPrice supplierPrice : supplierPriceList) {
|
|
|
|
+ //赋值产品归属公司
|
|
|
|
+ Long companyId = supplierPrice.getCompanyId();
|
|
|
|
+ if (ObjectUtil.isEmpty(companyId)) {
|
|
|
|
+ supplierPrice.setCompanyId(SecurityUtils.getCompanyId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
// 添加产品id列表
|
|
// 添加产品id列表
|
|
List<Long> productInfoIdList = supplierPriceList.stream().map(SupplierPrice::getProductInfoId).collect(Collectors.toList());
|
|
List<Long> productInfoIdList = supplierPriceList.stream().map(SupplierPrice::getProductInfoId).collect(Collectors.toList());
|
|
|
|
|
|
@@ -115,7 +135,7 @@ public class SupplierPriceServiceImpl extends ServiceImpl<SupplierPriceMapper, S
|
|
|
|
|
|
if (existSupplierPriceList.size() == 0) {
|
|
if (existSupplierPriceList.size() == 0) {
|
|
supplierPriceList.forEach(item -> item.setSupplierInfoId(supplierPriceDto.getSupplierInfoId()));
|
|
supplierPriceList.forEach(item -> item.setSupplierInfoId(supplierPriceDto.getSupplierInfoId()));
|
|
- saveBatch(supplierPriceList);
|
|
|
|
|
|
+ this.saveBatch(supplierPriceList);
|
|
supplierPriceAddVo.setAddSuccess(true);
|
|
supplierPriceAddVo.setAddSuccess(true);
|
|
return supplierPriceAddVo;
|
|
return supplierPriceAddVo;
|
|
}
|
|
}
|
|
@@ -135,7 +155,7 @@ public class SupplierPriceServiceImpl extends ServiceImpl<SupplierPriceMapper, S
|
|
supplierPrice.setId(existSupplierPrice.getId());
|
|
supplierPrice.setId(existSupplierPrice.getId());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- saveOrUpdateBatch(supplierPriceList);
|
|
|
|
|
|
+ this.saveOrUpdateBatch(supplierPriceList);
|
|
supplierPriceAddVo.setAddSuccess(true);
|
|
supplierPriceAddVo.setAddSuccess(true);
|
|
return supplierPriceAddVo;
|
|
return supplierPriceAddVo;
|
|
}
|
|
}
|