fix:修改产品物料模块

main
HuangHuiKang 2 weeks ago
parent a90d9e557f
commit a21f92779c

@ -80,9 +80,9 @@ public class ErpProductCategoryController {
@GetMapping("/simple-list") @GetMapping("/simple-list")
@Operation(summary = "获得产品分类精简列表", description = "只包含被开启的分类,主要用于前端的下拉选项") @Operation(summary = "获得产品分类精简列表", description = "只包含被开启的分类,主要用于前端的下拉选项")
public CommonResult<List<ErpProductCategoryRespVO>> getProductCategorySimpleList() { public CommonResult<List<ErpProductCategoryRespVO>> getProductCategorySimpleList(@RequestParam("type") Integer type) {
List<ErpProductCategoryDO> list = productCategoryService.getProductCategoryList( List<ErpProductCategoryDO> list = productCategoryService.getProductCategoryList(
new ErpProductCategoryListReqVO().setStatus(CommonStatusEnum.ENABLE.getStatus())); new ErpProductCategoryListReqVO().setStatus(CommonStatusEnum.ENABLE.getStatus()).setType(type));
return success(convertList(list, category -> new ErpProductCategoryRespVO() return success(convertList(list, category -> new ErpProductCategoryRespVO()
.setId(category.getId()).setName(category.getName()).setParentId(category.getParentId()).setSort(category.getSort()))); .setId(category.getId()).setName(category.getName()).setParentId(category.getParentId()).setSort(category.getSort())));
} }

@ -128,8 +128,11 @@ public class ErpProductController {
} }
@GetMapping("/simple-list-product") @GetMapping("/simple-list-product")
@Operation(summary = "获得产品精简列表", description = "只包含被开启的产品,主要用于前端的下拉选项") @Operation(summary = "获得产品精简列表", description = "只包含被开启的产品,主要用于前端的下拉选项")
public CommonResult<List<ErpProductRespVO>> getProductSimpleList() { public CommonResult<List<ErpProductRespVO>> getProductSimpleList(
List<ErpProductRespVO> list = productService.getProductVOListByCategory(ProductTypeEnum.PRODUCT.getTypeId()); @Parameter(name = "categoryType", description = "产品分类类型", example = "1")
@RequestParam(name = "categoryType", required = false) Integer categoryType) {
// List<ErpProductRespVO> list = productService.getProductVOListByCategory(ProductTypeEnum.PRODUCT.getTypeId(), categoryType);
List<ErpProductRespVO> list = productService.getProductVOListByCategory(null, categoryType);
return success(convertList(list, product -> new ErpProductRespVO().setId(product.getId()) return success(convertList(list, product -> new ErpProductRespVO().setId(product.getId())
.setName(product.getName()).setBarCode(product.getBarCode()) .setName(product.getName()).setBarCode(product.getBarCode())
.setCategoryId(product.getCategoryId()).setCategoryName(product.getCategoryName()) .setCategoryId(product.getCategoryId()).setCategoryName(product.getCategoryName())

@ -15,6 +15,9 @@ public class ErpProductListReqVO {
@Schema(description = "产品分类编号", example = "11161") @Schema(description = "产品分类编号", example = "11161")
private Long categoryId; private Long categoryId;
@Schema(description = "产品分类类型", example = "1")
private Integer categoryType;
@Schema(description = "产品编号", example = "11161") @Schema(description = "产品编号", example = "11161")
private String code; private String code;

@ -33,6 +33,9 @@ public class ErpProductRespVO extends ErpProductDO {
@Schema(description = "产品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11161") @Schema(description = "产品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11161")
private Long categoryId; private Long categoryId;
@Schema(description = "产品分类类型")
private Integer categoryType;
@Schema(description = "产品分类", requiredMode = Schema.RequiredMode.REQUIRED, example = "水果") @Schema(description = "产品分类", requiredMode = Schema.RequiredMode.REQUIRED, example = "水果")
@ExcelProperty("产品分类") @ExcelProperty("产品分类")
private String categoryName; private String categoryName;

@ -15,6 +15,7 @@ import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@ -34,6 +35,9 @@ public interface ErpProductMapper extends BaseMapperX<ErpProductDO> {
default PageResult<ErpProductDO> selectPage(ErpProductPageReqVO reqVO) { default PageResult<ErpProductDO> selectPage(ErpProductPageReqVO reqVO) {
List<Long> categoryIds = selectCategoryIdsByType(reqVO.getCategoryType()); List<Long> categoryIds = selectCategoryIdsByType(reqVO.getCategoryType());
if (reqVO.getCategoryType() != null && CollUtil.isEmpty(categoryIds)) {
return PageResult.empty();
}
return selectPage(reqVO, new LambdaQueryWrapperX<ErpProductDO>() return selectPage(reqVO, new LambdaQueryWrapperX<ErpProductDO>()
.likeIfPresent(ErpProductDO::getName, reqVO.getName()) .likeIfPresent(ErpProductDO::getName, reqVO.getName())
@ -55,11 +59,16 @@ public interface ErpProductMapper extends BaseMapperX<ErpProductDO> {
List<Long> selectCategoryIdListByType(@Param("categoryType") Integer categoryType); List<Long> selectCategoryIdListByType(@Param("categoryType") Integer categoryType);
default List<ErpProductDO> selectList(ErpProductListReqVO reqVO) { default List<ErpProductDO> selectList(ErpProductListReqVO reqVO) {
List<Long> categoryIds = selectCategoryIdsByType(reqVO.getCategoryType());
if (reqVO.getCategoryType() != null && CollUtil.isEmpty(categoryIds)) {
return new ArrayList<>();
}
return selectList(new LambdaQueryWrapperX<ErpProductDO>() return selectList(new LambdaQueryWrapperX<ErpProductDO>()
.inIfPresent(ErpProductDO::getId, reqVO.getIds()) .inIfPresent(ErpProductDO::getId, reqVO.getIds())
.likeIfPresent(ErpProductDO::getName, reqVO.getName()) .likeIfPresent(ErpProductDO::getName, reqVO.getName())
.likeIfPresent(ErpProductDO::getBarCode, reqVO.getCode()) .likeIfPresent(ErpProductDO::getBarCode, reqVO.getCode())
.eqIfPresent(ErpProductDO::getCategoryId, reqVO.getCategoryId()) .eqIfPresent(ErpProductDO::getCategoryId, reqVO.getCategoryId())
.inIfPresent(ErpProductDO::getCategoryId, categoryIds)
.likeIfPresent(ErpProductDO::getStandard, reqVO.getStandard()) .likeIfPresent(ErpProductDO::getStandard, reqVO.getStandard())
.orderByDesc(ErpProductDO::getId)); .orderByDesc(ErpProductDO::getId));
} }

@ -74,6 +74,7 @@ public interface ErpProductService {
*/ */
List<ErpProductRespVO> getProductVOListByStatus(Integer status,Integer categoryId); List<ErpProductRespVO> getProductVOListByStatus(Integer status,Integer categoryId);
List<ErpProductRespVO> getProductVOListByCategory(Integer categoryId); List<ErpProductRespVO> getProductVOListByCategory(Integer categoryId);
List<ErpProductRespVO> getProductVOListByCategory(Integer categoryId, Integer categoryType);
List<ErpProductRespVO> buildProductVOList(List<ErpProductDO> list); List<ErpProductRespVO> buildProductVOList(List<ErpProductDO> list);
/** /**
* VO * VO

@ -125,14 +125,16 @@ public class ErpProductServiceImpl implements ErpProductService {
throw exception(PRODUCT_CATEGORY_NOT_EXISTS); throw exception(PRODUCT_CATEGORY_NOT_EXISTS);
} }
Long id = productCategory.getParentId(); // Long id = productCategory.getParentId();
product.setSubCategoryName(productCategory.getName()); product.setSubCategoryName(productCategory.getName());
product.setSubCategoryId(product.getCategoryId()); product.setSubCategoryId(product.getCategoryId());
while(id != 0) { product.setCategoryId(product.getCategoryId());
productCategory = productCategoryMapper.selectById(id);
product.setCategoryId(id); // while(id != 0) {
id = productCategory.getParentId(); // productCategory = productCategoryMapper.selectById(id);
} // product.setCategoryId(id);
// id = productCategory.getParentId();
// }
// 自动生成才拼接 分类编码-流水号;手工输入则原样保存 // 自动生成才拼接 分类编码-流水号;手工输入则原样保存
if (autoGeneratedCode) { if (autoGeneratedCode) {
@ -311,6 +313,8 @@ public class ErpProductServiceImpl implements ErpProductService {
if (product == null) { if (product == null) {
return null; return null;
} }
ErpProductCategoryDO erpProductCategoryDO = productCategoryMapper.selectOne(Wrappers.<ErpProductCategoryDO>lambdaQuery().eq(ErpProductCategoryDO::getId, product.getSubCategoryId()));
String qrcodeUrl = qrcodeService.selectQrcodeUrlByIdAndCode( String qrcodeUrl = qrcodeService.selectQrcodeUrlByIdAndCode(
QrcodeBizTypeEnum.PRODUCT.getCode(), id, product.getBarCode()); QrcodeBizTypeEnum.PRODUCT.getCode(), id, product.getBarCode());
@ -319,6 +323,9 @@ public class ErpProductServiceImpl implements ErpProductService {
ErpProductRespVO respVO = BeanUtils.toBean(product, ErpProductRespVO.class); ErpProductRespVO respVO = BeanUtils.toBean(product, ErpProductRespVO.class);
respVO.setDevices(productMapper.selectDevicesByProductId(id)); respVO.setDevices(productMapper.selectDevicesByProductId(id));
respVO.setMolds(productMapper.selectMoldsByProductId(id)); respVO.setMolds(productMapper.selectMoldsByProductId(id));
if (erpProductCategoryDO !=null ){
respVO.setCategoryType(erpProductCategoryDO.getType());
}
// //
// respVO.setDeviceIds(respVO.getDevices().stream() // respVO.setDeviceIds(respVO.getDevices().stream()
// .map(ProductRelationRespVO::getId) // .map(ProductRelationRespVO::getId)
@ -377,6 +384,15 @@ public class ErpProductServiceImpl implements ErpProductService {
return buildProductVOList(list); return buildProductVOList(list);
} }
@Override
public List<ErpProductRespVO> getProductVOListByCategory(Integer categoryId, Integer categoryType) {
ErpProductListReqVO reqVO = new ErpProductListReqVO();
reqVO.setCategoryId(categoryId == null ? null : categoryId.longValue());
reqVO.setCategoryType(categoryType);
List<ErpProductDO> list = productMapper.selectList(reqVO);
return buildProductVOList(list);
}
@Override @Override
public List<ErpProductRespVO> getProductVOList(Collection<Long> ids) { public List<ErpProductRespVO> getProductVOList(Collection<Long> ids) {
if (CollUtil.isEmpty(ids)) { if (CollUtil.isEmpty(ids)) {

Loading…
Cancel
Save