|
@@ -90,64 +90,10 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
@Autowired
|
|
|
private ProductStockInfoService productStockInfoService;
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
public Page<ProductInfoVo> getPage(ProductInfoSelectDto dto) {
|
|
|
- IWrapper<ProductInfo> wrapper = getWrapper();
|
|
|
- wrapper.eq("pi", ProductInfo::getType, dto.getType());
|
|
|
- wrapper.eq("pi", ProductInfo::getDefinition, dto.getDefinition());
|
|
|
-
|
|
|
- if (dto.getProductClassifyId() != null) {
|
|
|
- List<Long> childIdList = productClassifyService.getChildIdList(dto.getProductClassifyId());
|
|
|
- wrapper.in("pi", ProductInfo::getProductClassifyId, childIdList);
|
|
|
- }
|
|
|
-
|
|
|
- wrapper.like("pi", ProductInfo::getName, dto.getName());
|
|
|
- wrapper.like("pi", ProductInfo::getCustomCode, dto.getCustomCode());
|
|
|
- wrapper.like("pi", ProductInfo::getBarCode, dto.getBarCode());
|
|
|
- wrapper.keyword(dto.getKeyword(),
|
|
|
- new SqlField("pi", ProductInfo::getName),
|
|
|
- new SqlField("pi", ProductInfo::getCode),
|
|
|
- new SqlField("pi", ProductInfo::getCustomCode),
|
|
|
- new SqlField("pi", ProductInfo::getSpec)
|
|
|
- );
|
|
|
-
|
|
|
- //过滤产品是否配置原材料
|
|
|
- Integer isRawMaterial = dto.getIsRawMaterial();
|
|
|
- if (ObjectUtil.isNotEmpty(isRawMaterial)) {
|
|
|
- if (isRawMaterial.equals(1)) {
|
|
|
- //过滤有配置原材料的产品
|
|
|
- wrapper.isNotNull("pi.raw_material_id");
|
|
|
- //同时过滤未配置工艺的的产品
|
|
|
- wrapper.isNotNull("pi.technology_id");
|
|
|
- } else {
|
|
|
- //过滤没原材料的产品
|
|
|
- wrapper.isNull("pi.raw_material_id");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //选择物料时不显示原材料分类的数据
|
|
|
- Integer isNeRawMaterial = dto.getIsNeRawMaterial();
|
|
|
- if (Objects.equals(isNeRawMaterial, 1)) {
|
|
|
- List<Long> pcIds = productClassifyService.listObject(ProductClassify::getId, q -> q
|
|
|
- .eq(ProductClassify::getId, 100)
|
|
|
- .or().apply("FIND_IN_SET(parent_id_set, 100)")
|
|
|
- );
|
|
|
- if (ObjectUtil.isNotEmpty(pcIds)) {
|
|
|
- wrapper.notIn("pi", ProductInfo::getProductClassifyId, pcIds);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //权限过滤:产品-子公司看自己的产品,总公司看全部,物料没有限制
|
|
|
- Long companyId = SecurityUtils.getCompanyId();
|
|
|
- if (!Objects.equals(companyId, 100L)) {
|
|
|
- dto.setCompanyId(companyId);
|
|
|
- }
|
|
|
- wrapper.and(q1 -> q1.
|
|
|
- and(q -> q.eq("pi", ProductInfo::getDefinition, 1).eq("pi", ProductInfo::getCompanyId, dto.getCompanyId()))
|
|
|
- .or().eq("pi", ProductInfo::getDefinition, 2)
|
|
|
- );
|
|
|
-
|
|
|
- wrapper.orderByDesc("pi", ProductInfo::getId);
|
|
|
+ IWrapper<ProductInfo> wrapper = getPageWrapper(dto);
|
|
|
Page<ProductInfoVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
|
|
|
List<ProductInfoVo> records = page.getRecords();
|
|
@@ -207,6 +153,66 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
return page;
|
|
|
}
|
|
|
|
|
|
+ private IWrapper<ProductInfo> getPageWrapper(ProductInfoSelectDto dto) {
|
|
|
+ IWrapper<ProductInfo> wrapper = getWrapper();
|
|
|
+ wrapper.eq("pi", ProductInfo::getType, dto.getType());
|
|
|
+ wrapper.eq("pi", ProductInfo::getDefinition, dto.getDefinition());
|
|
|
+
|
|
|
+ if (dto.getProductClassifyId() != null) {
|
|
|
+ List<Long> childIdList = productClassifyService.getChildIdList(dto.getProductClassifyId());
|
|
|
+ wrapper.in("pi", ProductInfo::getProductClassifyId, childIdList);
|
|
|
+ }
|
|
|
+
|
|
|
+ wrapper.like("pi", ProductInfo::getName, dto.getName());
|
|
|
+ wrapper.like("pi", ProductInfo::getCustomCode, dto.getCustomCode());
|
|
|
+ wrapper.like("pi", ProductInfo::getBarCode, dto.getBarCode());
|
|
|
+ wrapper.keyword(dto.getKeyword(),
|
|
|
+ new SqlField("pi", ProductInfo::getName),
|
|
|
+ new SqlField("pi", ProductInfo::getCode),
|
|
|
+ new SqlField("pi", ProductInfo::getCustomCode),
|
|
|
+ new SqlField("pi", ProductInfo::getSpec)
|
|
|
+ );
|
|
|
+
|
|
|
+ //过滤产品是否配置原材料
|
|
|
+ Integer isRawMaterial = dto.getIsRawMaterial();
|
|
|
+ if (ObjectUtil.isNotEmpty(isRawMaterial)) {
|
|
|
+ if (isRawMaterial.equals(1)) {
|
|
|
+ //过滤有配置原材料的产品
|
|
|
+ wrapper.isNotNull("pi.raw_material_id");
|
|
|
+ //同时过滤未配置工艺的的产品
|
|
|
+ wrapper.isNotNull("pi.technology_id");
|
|
|
+ } else {
|
|
|
+ //过滤没原材料的产品
|
|
|
+ wrapper.isNull("pi.raw_material_id");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //选择物料时不显示原材料分类的数据
|
|
|
+ Integer isNeRawMaterial = dto.getIsNeRawMaterial();
|
|
|
+ if (Objects.equals(isNeRawMaterial, 1)) {
|
|
|
+ List<Long> pcIds = productClassifyService.listObject(ProductClassify::getId, q -> q
|
|
|
+ .eq(ProductClassify::getId, 100)
|
|
|
+ .or().apply("FIND_IN_SET(parent_id_set, 100)")
|
|
|
+ );
|
|
|
+ if (ObjectUtil.isNotEmpty(pcIds)) {
|
|
|
+ wrapper.notIn("pi", ProductInfo::getProductClassifyId, pcIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //权限过滤:产品-子公司看自己的产品,总公司看全部,物料没有限制
|
|
|
+ Long companyId = SecurityUtils.getCompanyId();
|
|
|
+ if (!Objects.equals(companyId, 100L)) {
|
|
|
+ dto.setCompanyId(companyId);
|
|
|
+ }
|
|
|
+ wrapper.and(q1 -> q1.
|
|
|
+ and(q -> q.eq("pi", ProductInfo::getDefinition, 1).eq("pi", ProductInfo::getCompanyId, dto.getCompanyId()))
|
|
|
+ .or().eq("pi", ProductInfo::getDefinition, 2)
|
|
|
+ );
|
|
|
+
|
|
|
+ wrapper.orderByDesc("pi", ProductInfo::getId);
|
|
|
+ return wrapper;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public ProductInfoVo detail(Long id) {
|
|
@@ -763,19 +769,8 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
|
|
|
@Override
|
|
|
public void excelExport(HttpServletResponse httpServletResponse, ProductInfoSelectDto dto) {
|
|
|
- IWrapper<ProductInfo> wrapper = IWrapper.getWrapper();
|
|
|
- //权限过滤:产品-子公司看自己的产品,总公司看全部,物料没有限制
|
|
|
- Long companyId = SecurityUtils.getCompanyId();
|
|
|
- if (!Objects.equals(companyId, 100L)) {
|
|
|
- dto.setCompanyId(companyId);
|
|
|
- }
|
|
|
- wrapper.and(q1 -> q1.
|
|
|
- and(q -> q.eq("pi", ProductInfo::getDefinition, 1).eq("pi", ProductInfo::getCompanyId, dto.getCompanyId()))
|
|
|
- .or().eq("pi", ProductInfo::getDefinition, 2)
|
|
|
- );
|
|
|
-
|
|
|
- List<ProductInfo> productInfoList = this.list(wrapper);
|
|
|
-
|
|
|
+ IWrapper<ProductInfo> wrapper = getPageWrapper(dto);
|
|
|
+ List<ProductInfoVo> productInfoList = baseMapper.getList(wrapper);
|
|
|
List<Long> pIds = productInfoList.stream().map(ProductInfo::getId).collect(Collectors.toList());
|
|
|
|
|
|
//处理产品图片
|