| | |
| | | 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.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 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; |
| | |
| | | |
| | | private final ProductService productService; |
| | | |
| | | @Value("${dept.smj}") |
| | | private String smj; |
| | | |
| | | @Value("${dept.smjsc}") |
| | | private String smjsc; |
| | | |
| | | @Value("${dept.smjzt}") |
| | | private String smjzt; |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * @param page 分页对象 |
| | |
| | | @GetMapping("/page" ) |
| | | @PreAuthorize("@pms.hasPermission('business_product_view')" ) |
| | | public R getProductPage(@ParameterObject Page page, @ParameterObject Product product) { |
| | | if (StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smj) || StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smjsc) || |
| | | StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smjzt)) { |
| | | 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()); |
| | | List<String> smjList = new ArrayList<>(); |
| | | smjList.add(smj); |
| | | smjList.add(smjsc); |
| | | smjList.add(smjzt); |
| | | wrapper.in(Product::getCompId, smjList); |
| | | wrapper.orderByDesc(Product::getCreateTime); |
| | | Page<Product> page1 = productService.page(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); |
| | | } |
| | | LambdaQueryWrapper<Product> wrapper = Wrappers.lambdaQuery(); |
| | | wrapper.eq(product.getParentId()!=null,Product::getParentId,product.getParentId()); |
| | | wrapper.like(StrUtil.isNotEmpty(product.getProductName()),Product::getProductName,product.getProductName()); |
| | |
| | | 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); |
| | | } |
| | | } |