Просмотр исходного кода

中心仓商品信息启用时修改库存数据

liyuan 3 недель назад
Родитель
Сommit
90b630d274

+ 29 - 21
blade-service/blade-sales-part/src/main/java/org/springblade/salesPart/goods/controller/GoodsDescController.java

@@ -1,27 +1,14 @@
-/*
- *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
- *
- *  Redistribution and use in source and binary forms, with or without
- *  modification, are permitted provided that the following conditions are met:
- *
- *  Redistributions of source code must retain the above copyright notice,
- *  this list of conditions and the following disclaimer.
- *  Redistributions in binary form must reproduce the above copyright
- *  notice, this list of conditions and the following disclaimer in the
- *  documentation and/or other materials provided with the distribution.
- *  Neither the name of the dreamlu.net developer nor the names of its
- *  contributors may be used to endorse or promote products derived from
- *  this software without specific prior written permission.
- *  Author: Chill 庄骞 (smallchill@163.com)
- */
 package org.springblade.salesPart.goods.controller;
 package org.springblade.salesPart.goods.controller;
 
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ecp.tire.center.warehouse.api.stock.entity.CenterStockDesc;
+import com.ecp.tire.center.warehouse.stock.service.ICenterStockDescService;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiOperation;
@@ -32,6 +19,7 @@ import org.springblade.core.boot.ctrl.BladeController;
 import org.springblade.core.excel.util.ExcelUtil;
 import org.springblade.core.excel.util.ExcelUtil;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.mp.support.Query;
+import org.springblade.core.secure.BladeUser;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.secure.utils.SecureUtil;
 import org.springblade.core.secure.utils.SecureUtil;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.api.R;
@@ -58,10 +46,7 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import javax.validation.Valid;
 import java.math.BigDecimal;
 import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
 /**
 /**
@@ -86,6 +71,8 @@ public class GoodsDescController extends BladeController {
 	private final IBrandFilesService brandFilesService;
 	private final IBrandFilesService brandFilesService;
 	private final IStockDescService stockDescService;
 	private final IStockDescService stockDescService;
 
 
+	private final ICenterStockDescService centerStockDescService;
+
 	/**
 	/**
 	 * 详情
 	 * 详情
 	 */
 	 */
@@ -375,16 +362,37 @@ public class GoodsDescController extends BladeController {
 		if (goodsDesc.getId() == null) {
 		if (goodsDesc.getId() == null) {
 			return R.fail(500, "请选择数据");
 			return R.fail(500, "请选择数据");
 		}
 		}
+		BladeUser nowUpdateUser = AuthUtil.getUser();
 		if (0 == goodsDesc.getEnableOrNot()) {
 		if (0 == goodsDesc.getEnableOrNot()) {
 			long count = productLaunchService.count(new LambdaQueryWrapper<PjProductLaunch>()
 			long count = productLaunchService.count(new LambdaQueryWrapper<PjProductLaunch>()
 				.eq(PjProductLaunch::getIsDeleted, 0)
 				.eq(PjProductLaunch::getIsDeleted, 0)
-				.eq(PjProductLaunch::getTenantId, AuthUtil.getTenantId())
+				.eq(PjProductLaunch::getTenantId, nowUpdateUser.getTenantId())
 				.eq(PjProductLaunch::getGoodsId, goodsDesc.getId())
 				.eq(PjProductLaunch::getGoodsId, goodsDesc.getId())
 				.eq(PjProductLaunch::getUpAndDownShelves, 1));
 				.eq(PjProductLaunch::getUpAndDownShelves, 1));
 			if (count > 0) {
 			if (count > 0) {
 				return R.fail(500, "该轮胎已上架,请先下架轮胎在进行操作");
 				return R.fail(500, "该轮胎已上架,请先下架轮胎在进行操作");
 			}
 			}
 		}
 		}
+		if ("147149".equals(nowUpdateUser.getTenantId())) {
+			PjGoodsDesc beforeGoodsData = goodsDescService.getById(goodsDesc.getId());
+			if (org.springframework.util.ObjectUtils.isEmpty(beforeGoodsData)) {
+				return R.fail(500, "未找到当前更改的数据");
+			}
+			CenterStockDesc updateCenterStock = new CenterStockDesc();
+			updateCenterStock.setCname(beforeGoodsData.getCname());
+			updateCenterStock.setCode(beforeGoodsData.getCode());
+			updateCenterStock.setBrandId(beforeGoodsData.getBrandId());
+			updateCenterStock.setBrandName(beforeGoodsData.getBrandName());
+			updateCenterStock.setTypeNo(beforeGoodsData.getSpecificationAndModel());
+			updateCenterStock.setBrandItem(beforeGoodsData.getBrandItem());
+			updateCenterStock.setGoodsTypeId(Long.valueOf(beforeGoodsData.getGoodsTypeId()));
+			updateCenterStock.setGoodsTypeName(beforeGoodsData.getGoodsTypeName());
+			updateCenterStock.setProductDescription(beforeGoodsData.getGoodsDescription());
+			updateCenterStock.setUpdateTime(new Date());
+			updateCenterStock.setUpdateUser(nowUpdateUser.getUserId());
+			centerStockDescService.update(updateCenterStock, new LambdaUpdateWrapper<CenterStockDesc>()
+				.eq(CenterStockDesc::getGoodsId, goodsDesc.getId()).eq(CenterStockDesc::getTenantId, nowUpdateUser.getTenantId()).eq(CenterStockDesc::getIsDeleted, 0));
+		}
 		boolean status = goodsDescService.updateById(goodsDesc);
 		boolean status = goodsDescService.updateById(goodsDesc);
 		return R.status(status);
 		return R.status(status);
 	}
 	}