Browse Source

产品修改

Signed-off-by: sunhz <mpcoo@foxmail.com>
sunhz 3 years ago
parent
commit
e03324dedb

+ 15 - 0
blade-service-api/blade-client-api/src/main/java/org/springblade/client/vo/ProductVO.java

@@ -0,0 +1,15 @@
+package org.springblade.client.vo;
+
+import lombok.Data;
+import org.springblade.client.entity.GoodsDesc;
+
+import java.util.List;
+
+@Data
+public class ProductVO {
+
+	private String type;
+
+	private List<GoodsDesc> goods;
+
+}

+ 15 - 10
blade-service/blade-client/src/main/java/org/springblade/client/goods/controller/GoodsDescController.java

@@ -42,7 +42,6 @@ import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.secure.utils.SecureUtil;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
-import org.springblade.core.tool.utils.StringUtil;
 import org.springblade.mocha.feign.ISalesPolicyClient;
 import org.springblade.purchase.sales.entity.OrderItems;
 import org.springblade.purchase.sales.feign.IOrderItemsClient;
@@ -58,6 +57,7 @@ import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Objects;
 import java.util.stream.Collectors;
 
 /**
@@ -165,8 +165,8 @@ public class GoodsDescController extends BladeController {
 		goodsDescLambdaQueryWrapper.like(!StringUtils.isBlank(code), GoodsDesc::getCode, code);
 		goodsDescLambdaQueryWrapper.eq(GoodsDesc::getTenantId, AuthUtil.getTenantId());
 		goodsDescLambdaQueryWrapper.eq(GoodsDesc::getType, 0);
-		if (StringUtils.isNotEmpty(artsVision)){
-			goodsDescLambdaQueryWrapper.and(i -> i.like(GoodsDesc::getArtsVision,artsVision).or().isNull(GoodsDesc::getArtsVision));
+		if (StringUtils.isNotEmpty(artsVision)) {
+			goodsDescLambdaQueryWrapper.and(i -> i.like(GoodsDesc::getArtsVision, artsVision).or().isNull(GoodsDesc::getArtsVision));
 		}
 		goodsDescLambdaQueryWrapper.orderByDesc(GoodsDesc::getCreateTime);
 		Page<GoodsDesc> page = new Page<>(current, size);
@@ -190,6 +190,11 @@ public class GoodsDescController extends BladeController {
 		return R.data(iPage);
 	}
 
+	@GetMapping("/product")
+	public R<?> product(GoodsDesc goodsDesc) {
+		return R.data(goodsDescService.getProductList(goodsDesc));
+	}
+
 	@GetMapping("/findById")
 	@ApiOperationSupport(order = 2)
 	@ApiOperation(value = "分页", notes = "传入goodsDesc")
@@ -209,12 +214,12 @@ public class GoodsDescController extends BladeController {
 		specificationWrapper.eq(GoodsSpecification::getTenantId, SecureUtil.getTenantId());
 		List<GoodsSpecification> goodsSpecificationList = goodsSpecificationService.list(specificationWrapper);
 		if (!CollectionUtils.isEmpty(priceList)) {
-			List<GoodsPrice> sale = priceList.stream().filter(e -> e.getBillType().equals("0")).collect(Collectors.toList());
-			List<GoodsPrice> buy = priceList.stream().filter(e -> e.getBillType().equals("1")).collect(Collectors.toList());
+			List<GoodsPrice> sale = priceList.stream().filter(e -> "0".equals(e.getBillType())).collect(Collectors.toList());
+			List<GoodsPrice> buy = priceList.stream().filter(e -> "1".equals(e.getBillType())).collect(Collectors.toList());
 			goodsDesc.setSaleGoodsPrice(sale);
 			goodsDesc.setBuyGoodsPrice(buy);
-			goodsDesc.setFilesList(filesList);
 		}
+		goodsDesc.setFilesList(filesList);
 		goodsDesc.setGoodsSpecificationList(goodsSpecificationList);
 		return R.data(goodsDesc);
 	}
@@ -338,7 +343,7 @@ public class GoodsDescController extends BladeController {
 			selectChildById(goodsId, goodsIdList);
 			goodsIdList.add(goodsId);
 		}
-		if (CollectionUtils.isNotEmpty(goodsIdList)){
+		if (CollectionUtils.isNotEmpty(goodsIdList)) {
 			goodsDesc.setGoodsTypeIdList(goodsIdList);
 		}
 		IPage<GoodsDescVO> goodsDescVOIPage = goodsDescService.selectGoods(Condition.getPage(query), goodsDesc);
@@ -350,9 +355,9 @@ public class GoodsDescController extends BladeController {
 				specificationWrapper.eq(GoodsSpecification::getTenantId, SecureUtil.getTenantId());
 				List<GoodsSpecification> goodsSpecificationList = goodsSpecificationService.list(specificationWrapper);
 				e.setGoodsSpecificationList(goodsSpecificationList);
-				if (e.getCorpId() != null){
+				if (e.getCorpId() != null) {
 					CorpsDesc desc = corpsDescService.getById(e.getCorpId());
-					if (desc != null){
+					if (desc != null) {
 						e.setCorpCode(desc.getCode());
 					}
 				}
@@ -440,7 +445,7 @@ public class GoodsDescController extends BladeController {
 				stockGoods.setTenantId(SecureUtil.getTenantId());
 				List<StockGoods> stockGoodsList = stockGoodsClient.postListStockByCondition(stockGoods);
 				if (CollectionUtils.isNotEmpty(stockGoodsList)) {
-					goodsOutExcel.setStorageQuantity(stockGoodsList.stream().filter(ei -> ei.getSurplusRouteQuantity() != null).map(StockGoods::getSurplusRouteQuantity).reduce(BigDecimal.ZERO, BigDecimal::add));
+					goodsOutExcel.setStorageQuantity(stockGoodsList.stream().map(StockGoods::getSurplusRouteQuantity).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
 				} else {
 					goodsOutExcel.setStorageQuantity(BigDecimal.ZERO);
 				}

+ 9 - 34
blade-service/blade-client/src/main/java/org/springblade/client/goods/controller/GoodsFilesController.java

@@ -16,33 +16,14 @@
  */
 package org.springblade.client.goods.controller;
 
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
-import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
 import lombok.AllArgsConstructor;
 import org.springblade.client.entity.GoodsFiles;
-import org.springblade.client.entity.GoodsType;
-import org.springblade.client.goods.enums.GoodsTypeEnum;
 import org.springblade.client.goods.service.IGoodsFilesService;
-import org.springblade.client.goods.service.IGoodsTypeService;
-import org.springblade.client.vo.GoodsTypeVO;
 import org.springblade.core.boot.ctrl.BladeController;
-import org.springblade.core.mp.support.Condition;
-import org.springblade.core.mp.support.Query;
-import org.springblade.core.secure.BladeUser;
-import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
-import org.springblade.core.tool.utils.Func;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
-import javax.validation.Valid;
-import java.util.List;
-
 /**
  * 商品类别表 控制器
  *
@@ -53,24 +34,18 @@ import java.util.List;
 @AllArgsConstructor
 @RequestMapping("/goodsfiles")
 @Api(value = "商品文件表", tags = "商品文件表接口")
-public class GoodsFilesController extends BladeController
-{
-     @Autowired
-	private IGoodsFilesService goodsFilesService;
+public class GoodsFilesController extends BladeController {
 
-    @PostMapping("add")
-    public  R add(@RequestBody GoodsFiles goodsFiles)
-	{
-		goodsFilesService.save(goodsFiles);
-		return R.success("操作成功");
-	}
+	private final IGoodsFilesService goodsFilesService;
 
-	@DeleteMapping("delete")
-	public R delete(@RequestParam(name = "id", required = true) String id)
-	{
-		goodsFilesService.removeById(id);
-		return R.success("操作成功");
+	@PostMapping("add")
+	public R add(@RequestBody GoodsFiles goodsFiles) {
+		return R.status(goodsFilesService.save(goodsFiles));
 	}
 
+	@PostMapping("delete")
+	public R delete(@RequestParam(name = "ids") String ids) {
+		return R.status(goodsFilesService.removeById(ids));
+	}
 
 }

+ 27 - 10
blade-service/blade-client/src/main/java/org/springblade/client/goods/service/IGoodsDescService.java

@@ -16,14 +16,13 @@
  */
 package org.springblade.client.goods.service;
 
-import org.apache.ibatis.annotations.Param;
-import org.springblade.client.corps.excel.CorpsExcel;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.IService;
 import org.springblade.client.entity.GoodsDesc;
 import org.springblade.client.goods.excel.GoodsExcel;
 import org.springblade.client.goods.excel.GoodsInfoExcel;
 import org.springblade.client.vo.GoodsDescVO;
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springblade.client.vo.ProductVO;
 import org.springblade.core.tool.api.R;
 
 import java.util.List;
@@ -47,6 +46,7 @@ public interface IGoodsDescService extends IService<GoodsDesc> {
 
 	/**
 	 * 保存商品信息
+	 *
 	 * @param goodsDesc
 	 * @return
 	 */
@@ -54,6 +54,7 @@ public interface IGoodsDescService extends IService<GoodsDesc> {
 
 	/**
 	 * 获取商品详情
+	 *
 	 * @param goodsDesc
 	 * @return
 	 */
@@ -61,12 +62,15 @@ public interface IGoodsDescService extends IService<GoodsDesc> {
 
 	/**
 	 * 校验商品编码唯一性
+	 *
 	 * @param goodsDesc
 	 * @return
 	 */
 	void selectGoodsCode(GoodsDesc goodsDesc);
+
 	/**
 	 * 校验商品名称唯一性
+	 *
 	 * @param goodsDesc
 	 * @return
 	 */
@@ -74,16 +78,19 @@ public interface IGoodsDescService extends IService<GoodsDesc> {
 
 	/**
 	 * 下单查询商品信息
+	 *
 	 * @param goodsDesc
 	 * @return
 	 */
-	IPage<GoodsDescVO> selectGoods(IPage<GoodsDescVO> page,GoodsDesc goodsDesc);
+	IPage<GoodsDescVO> selectGoods(IPage<GoodsDescVO> page, GoodsDesc goodsDesc);
+
 	/**
 	 * 订单获取商品信息
-	 * @param Id
+	 *
+	 * @param id
 	 * @return
 	 */
-	GoodsDescVO selectGoodsMessage(Long Id);
+	GoodsDescVO selectGoodsMessage(Long id);
 
 	void modify(GoodsDesc goodsDesc);
 
@@ -98,13 +105,23 @@ public interface IGoodsDescService extends IService<GoodsDesc> {
 
 	/**
 	 * 导入产品信息
-	 * */
-	R importGoodsInfo(List<GoodsInfoExcel> data,Boolean isCovered);
+	 */
+	R importGoodsInfo(List<GoodsInfoExcel> data, Boolean isCovered);
 
 	/**
 	 * 获取商品信息
+	 *
 	 * @param code
 	 * @return
 	 */
-	GoodsDesc terraceCode(String code,String tenantId);
+	GoodsDesc terraceCode(String code, String tenantId);
+
+	/**
+	 * 获取产品列表
+	 *
+	 * @param goodsDesc 产品
+	 * @return 产品列表
+	 */
+	List<ProductVO> getProductList(GoodsDesc goodsDesc);
+
 }

+ 36 - 4
blade-service/blade-client/src/main/java/org/springblade/client/goods/service/impl/GoodsDescServiceImpl.java

@@ -31,6 +31,7 @@ import org.springblade.client.goods.excel.GoodsInfoExcel;
 import org.springblade.client.goods.mapper.*;
 import org.springblade.client.goods.service.IGoodsDescService;
 import org.springblade.client.vo.GoodsDescVO;
+import org.springblade.client.vo.ProductVO;
 import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.secure.utils.SecureUtil;
@@ -45,6 +46,7 @@ import java.math.BigDecimal;
 import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+import java.util.stream.Collectors;
 
 /**
  * 商品详情表 服务实现类
@@ -180,8 +182,8 @@ public class GoodsDescServiceImpl extends ServiceImpl<GoodsDescMapper, GoodsDesc
 	}
 
 	@Override
-	public GoodsDescVO selectGoodsMessage(Long Id) {
-		return baseMapper.selectGoodsMessage(Id);
+	public GoodsDescVO selectGoodsMessage(Long id) {
+		return baseMapper.selectGoodsMessage(id);
 	}
 
 	@Override
@@ -489,8 +491,38 @@ public class GoodsDescServiceImpl extends ServiceImpl<GoodsDescMapper, GoodsDesc
 	}
 
 	@Override
-	public GoodsDesc terraceCode(String code,String tenantId) {
-		return baseMapper.getTerraceCode(code,tenantId);
+	public GoodsDesc terraceCode(String code, String tenantId) {
+		return baseMapper.getTerraceCode(code, tenantId);
+	}
+
+	@Override
+	public List<ProductVO> getProductList(GoodsDesc goodsDesc) {
+		LambdaQueryWrapper<GoodsDesc> wrapper = new LambdaQueryWrapper<>();
+		wrapper.like(!org.apache.commons.lang3.StringUtils.isBlank(goodsDesc.getCname()), GoodsDesc::getCname, goodsDesc.getCname())
+			.like(!org.apache.commons.lang3.StringUtils.isBlank(goodsDesc.getCnameInt()), GoodsDesc::getCnameInt, goodsDesc.getCnameInt())
+			.like(!org.apache.commons.lang3.StringUtils.isBlank(goodsDesc.getEname()), GoodsDesc::getEname, goodsDesc.getEname())
+			.like(!org.apache.commons.lang3.StringUtils.isBlank(goodsDesc.getCode()), GoodsDesc::getCode, goodsDesc.getCode())
+			.eq(GoodsDesc::getTenantId, AuthUtil.getTenantId())
+			.eq(GoodsDesc::getType, 0)
+			.orderByDesc(GoodsDesc::getCreateTime);
+
+		List<GoodsDesc> goodsDescList = goodsDescMapper.selectList(wrapper);
+		Map<String, List<GoodsDesc>> group = goodsDescList.stream()
+			.collect(Collectors.groupingBy(e -> e.getGoodsTypeId().split(",")[0]));
+
+		List<ProductVO> productList = new ArrayList<>();
+		group.forEach((k, v) -> {
+			if (StringUtil.isNotBlank(k)) {
+				GoodsType goodsType = goodsTypeMapper.selectById(Long.parseLong(k));
+				if (ObjectUtil.isNotEmpty(goodsType)) {
+					ProductVO vo = new ProductVO();
+					vo.setType(goodsType.getCname());
+					vo.setGoods(v);
+					productList.add(vo);
+				}
+			}
+		});
+		return productList;
 	}
 
 	private String getCnameInt(String cname) {