| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.by4cloud.platformx.admin.api.vo.DeptExcelVO; |
| | | import com.by4cloud.platformx.business.dto.ProductAddDTO; |
| | | import com.by4cloud.platformx.business.dto.ProductQueryDTO; |
| | | import com.by4cloud.platformx.business.dto.SyncProductDTO; |
| | | import com.by4cloud.platformx.business.entity.BusinessCustomer; |
| | | import com.by4cloud.platformx.business.vo.ProductExcelVO; |
| | | import com.by4cloud.platformx.business.vo.ProductTreeVo; |
| | | import com.by4cloud.platformx.common.core.util.R; |
| | | import com.by4cloud.platformx.common.excel.annotation.RequestExcel; |
| | | import com.by4cloud.platformx.common.log.annotation.SysLog; |
| | | import com.by4cloud.platformx.business.entity.Product; |
| | | import com.by4cloud.platformx.business.service.ProductService; |
| | | import com.by4cloud.platformx.common.security.annotation.Inner; |
| | | import com.by4cloud.platformx.common.security.util.SecurityUtils; |
| | | import com.github.yulichang.query.MPJLambdaQueryWrapper; |
| | | import com.github.yulichang.query.MPJQueryWrapper; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import com.by4cloud.platformx.common.excel.annotation.ResponseExcel; |
| | | import io.swagger.v3.oas.annotations.security.SecurityRequirement; |
| | |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.validation.BindingResult; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.ArrayList; |
| | |
| | | @GetMapping("/page" ) |
| | | @PreAuthorize("@pms.hasPermission('business_product_view')" ) |
| | | public R getProductPage(@ParameterObject Page page, @ParameterObject Product product) { |
| | | LambdaQueryWrapper<Product> wrapper = Wrappers.lambdaQuery(); |
| | | wrapper.eq(product.getParentId()!=null,Product::getParentId,product.getParentId()); |
| | | wrapper.like(StrUtil.isNotEmpty(product.getProductName()),Product::getProductName,product.getProductName()); |
| | | wrapper.like(StrUtil.isNotEmpty(product.getMainCode()),Product::getMainCode,product.getMainCode()); |
| | | wrapper.like(StrUtil.isNotEmpty(product.getErpCode()),Product::getErpCode,product.getErpCode()); |
| | | wrapper.orderByDesc(Product::getCreateTime); |
| | | Page<Product> page1 = productService.pageByScope(page, wrapper); |
| | | List<Product> list = page1.getRecords(); |
| | | for(Product product1 : list){ |
| | | Product parent = productService.getById(product1.getParentId()); |
| | | if(parent==null){ |
| | | product1.setParentName("根级产品"); |
| | | }else { |
| | | product1.setParentName(parent.getProductName()); |
| | | } |
| | | } |
| | | page1.setRecords(list); |
| | | return R.ok(page1); |
| | | // if (StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smj) || StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smjhw)) { |
| | | // MPJLambdaWrapper<Product> wrapper =new MPJLambdaWrapper<Product>() |
| | | // .selectAll(Product.class) |
| | | // .selectAs("ifnull((select product_name from product t1 where t1.id = t.parent_id),'根级产品')",Product::getParentName) |
| | | // .eq(product.getParentId()!=null,Product::getParentId,product.getParentId()) |
| | | // .like(StrUtil.isNotEmpty(product.getProductName()),Product::getProductName,product.getProductName()) |
| | | // .like(StrUtil.isNotEmpty(product.getMainCode()),Product::getMainCode,product.getMainCode()) |
| | | // .like(StrUtil.isNotEmpty(product.getErpCode()),Product::getErpCode,product.getErpCode()); |
| | | // List<String> smjList = new ArrayList<>(); |
| | | // smjList.add(smj); |
| | | //// smjList.add(smjsc); |
| | | //// smjList.add(smjzt); |
| | | // smjList.add(smjhw); |
| | | // wrapper.in(Product::getCompId, smjList); |
| | | // wrapper.orderByDesc(Product::getCreateTime); |
| | | // return R.ok(productService.page(page, wrapper)); |
| | | // } |
| | | // MPJLambdaWrapper<Product> wrapper =new MPJLambdaWrapper<Product>() |
| | | // .selectAll(Product.class) |
| | | // .selectAs("ifnull((select product_name from product t1 where t1.id = parent_id),'根级产品')",Product::getParentName) |
| | | // .eq(product.getParentId()!=null,Product::getParentId,product.getParentId()) |
| | | // .like(StrUtil.isNotEmpty(product.getProductName()),Product::getProductName,product.getProductName()) |
| | | // .like(StrUtil.isNotEmpty(product.getMainCode()),Product::getMainCode,product.getMainCode()) |
| | | // .like(StrUtil.isNotEmpty(product.getErpCode()),Product::getErpCode,product.getErpCode()); |
| | | //// .eq(Product::getCompId,SecurityUtils.getUser().getCompId()); |
| | | // return R.ok(productService.pageByScope(page, wrapper)); |
| | | return R.ok(productService.pageScope(page,product)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @PostMapping |
| | | @PreAuthorize("@pms.hasPermission('business_product_add')" ) |
| | | public R save(@RequestBody Product product) { |
| | | if (ArrayUtil.isNotEmpty(productService.listByScope(Wrappers.lambdaQuery(product).eq(Product::getErpCode,product.getErpCode())).toArray())){ |
| | | if (CollUtil.isNotEmpty(productService.listByScope(Wrappers.lambdaQuery(product).eq(Product::getErpCode,product.getErpCode())))){ |
| | | return R.failed("产品Erp编码已存在"); |
| | | } |
| | | return R.ok(productService.save(product)); |
| | |
| | | public List<Product> export(Product product,Long[] ids) { |
| | | return productService.list(Wrappers.lambdaQuery(product).in(ArrayUtil.isNotEmpty(ids), Product::getId, ids)); |
| | | } |
| | | |
| | | /** |
| | | * 新增产品信息 |
| | | * @param addDTOS 产品信息 |
| | | * @return R |
| | | */ |
| | | @Operation(summary = "各公司新增产品信息" , description = "各公司新增产品信息" ) |
| | | @SysLog("各公司新增产品信息" ) |
| | | @PostMapping("/saveErpProduct") |
| | | public R saveErpProduct(@RequestBody List<ProductAddDTO> addDTOS) { |
| | | return productService.saveErpProduct(addDTOS); |
| | | } |
| | | |
| | | /** |
| | | * 导入部门 |
| | | * @param excelVOList |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping("/importProduct") |
| | | public R importProduct(@RequestExcel List<ProductExcelVO> excelVOList, BindingResult bindingResult) { |
| | | return productService.importProduct(excelVOList, bindingResult); |
| | | } |
| | | |
| | | /** |
| | | * 石煤机产品同步 |
| | | * @return |
| | | */ |
| | | @Inner(value = false) |
| | | @GetMapping("/syncSMJByDate") |
| | | public R syncSMJByDate(@ParameterObject SyncProductDTO dto) { |
| | | return productService.syncSMJByDate(dto); |
| | | } |
| | | } |