chen 2 سال پیش
والد
کامیت
fc96b09017

+ 5 - 0
src/main/java/org/springblade/modules/pl/factory/entity/FactoryEntity.java

@@ -36,6 +36,11 @@ import org.springblade.core.tenant.mp.TenantEntity;
 @EqualsAndHashCode(callSuper = true)
 public class FactoryEntity extends TenantEntity {
 
+	/**
+	 * 工厂类型
+	 */
+	@ApiModelProperty(value = "工厂类型")
+	private String type;
 	/**
 	 * 工厂名称
 	 */

+ 8 - 0
src/main/java/org/springblade/modules/pl/product/entity/ProductEntity.java

@@ -133,4 +133,12 @@ public class ProductEntity extends TenantEntity {
 //
 //	public boolean is$cellEdit() { return true; }
 
+
+	/**
+	 * 新二维码编号
+	 */
+	@ApiModelProperty(value = "新二维码编号")
+	@TableField(exist = false)
+	private String newQrCode;
+
 }

+ 12 - 0
src/main/java/org/springblade/modules/pl/productBatch/controller/ProductBatchController.java

@@ -71,6 +71,7 @@ public class ProductBatchController extends BladeController {
 
 	private final IProductBatchService productBatchService;
 	private final IProductService productService;
+	private final IProductModelService productModelService;
 
 	/**
 	 * 产品入库批次表 详情
@@ -80,9 +81,11 @@ public class ProductBatchController extends BladeController {
 	@ApiOperation(value = "详情", notes = "传入productBatch")
 	public R<ProductBatchVO> detail(ProductBatchEntity productBatch) {
 		ProductBatchEntity detail = productBatchService.getOne(Condition.getQueryWrapper(productBatch));
+		ProductModelEntity productModel = productModelService.getOne(Wrappers.<ProductModelEntity>lambdaQuery().eq(ProductModelEntity::getId,detail.getProductModelId()));
 		List<ProductEntity> productEntityList = productService.list(Wrappers.<ProductEntity>lambdaQuery().eq(ProductEntity::getBatchId,detail.getId()));
 		ProductBatchVO productBatchVO = ProductBatchWrapper.build().entityVO(detail);
 		productBatchVO.setDetails(productEntityList);
+		productBatchVO.setInStockFormItem(productModel.getInStockFormItem());
 		return R.data(productBatchVO);
 	}
 	/**
@@ -150,6 +153,15 @@ public class ProductBatchController extends BladeController {
 	public R submit(@Valid @RequestBody ProductBatchVO productBatch) {
 		return productBatchService.submit(productBatch);
 	}
+	/**
+	 * 产品入库批次表 变更
+	 */
+	@PostMapping("/change")
+	@ApiOperationSupport(order = 6)
+	@ApiOperation(value = "新增或修改", notes = "传入productBatch")
+	public R change(@Valid @RequestBody ProductBatchVO productBatch) {
+		return productBatchService.change(productBatch);
+	}
 
 	/**
 	 * 产品入库批次表 删除

+ 2 - 0
src/main/java/org/springblade/modules/pl/productBatch/service/IProductBatchService.java

@@ -51,4 +51,6 @@ public interface IProductBatchService extends BaseService<ProductBatchEntity> {
 	List<ProductBatchExcel> exportProductBatch(Wrapper<ProductBatchEntity> queryWrapper);
 
 	R submit(ProductBatchVO productBatch);
+
+	R change(ProductBatchVO productBatch);
 }

+ 85 - 4
src/main/java/org/springblade/modules/pl/productBatch/service/impl/ProductBatchServiceImpl.java

@@ -16,7 +16,10 @@
  */
 package org.springblade.modules.pl.productBatch.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import liquibase.pro.packaged.P;
 import org.springblade.core.secure.BladeUser;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
@@ -38,6 +41,7 @@ import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.Objects;
@@ -97,9 +101,9 @@ public class ProductBatchServiceImpl extends BaseServiceImpl<ProductBatchMapper,
 					if(!Objects.equals(product.getProductModelId(), productBatch.getProductModelId())){
 						return R.fail("产品二维码:"+productEntity.getQrCode()+"与当前批次的型号不符,请更换产品");
 					}
-					if(StringUtil.isBlank(productEntity.getColdQrCode())){
-						return R.fail("产品二维码:"+productEntity.getQrCode()+"的冷板二维码不能为空");
-					}
+//					if(StringUtil.isBlank(productEntity.getColdQrCode())){
+//						return R.fail("产品二维码:"+productEntity.getQrCode()+"的冷板二维码不能为空");
+//					}
 					productEntity.setId(product.getId());
 				}else{
 					if(product != null){
@@ -147,10 +151,16 @@ public class ProductBatchServiceImpl extends BaseServiceImpl<ProductBatchMapper,
 					return R.fail("产品数据异常,请联系管理员");
 				}
 				ProductEntity product = productService.getById(productEntity.getId());
-				productEntity.setId(product.getId());
+				if(product == null){
+					return R.fail("产品二维码:"+productEntity.getQrCode()+"不存在,请更换产品");
+				}
+				if(!Objects.equals(product.getProductModelId(), productBatch.getProductModelId())){
+					return R.fail("产品二维码:"+productEntity.getQrCode()+"与当前批次的型号不符,请更换产品");
+				}
 				if(product.getStatus()!=3){
 					return R.fail("产品二维码:"+productEntity.getQrCode()+"未入库,无法修改");
 				}
+				productEntity.setId(product.getId());
 				productEntity.setFactoryId(productModel.getFactoryId());
 				productEntity.setProductModelId(productModel.getId());
 				productEntity.setProductName(productModel.getProductName());
@@ -183,4 +193,75 @@ public class ProductBatchServiceImpl extends BaseServiceImpl<ProductBatchMapper,
 		}
 	}
 
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public R change(ProductBatchVO productBatch) {
+		ProductModelEntity productModel = productModelService.getById(productBatch.getProductModelId());
+		List<ProductEntity> changeProductList = new ArrayList<>();
+		for(ProductEntity productEntity : productBatch.getDetails()){
+			if(productEntity.getId() == null){
+				return R.fail("产品数据异常,请联系管理员");
+			}
+			if(StringUtil.isNotBlank(productEntity.getNewQrCode())){
+				if(productEntity.getNewQrCode().equals(productEntity.getQrCode())){
+					return R.fail("产品二维码:"+productEntity.getNewQrCode()+"不能与原二维码相同");
+				}
+				ProductEntity product = productService.getOne(Wrappers.<ProductEntity>lambdaQuery().eq(ProductEntity::getFactoryId,productBatch.getFactoryId()).eq(ProductEntity::getQrCode,productEntity.getNewQrCode()));
+				if(product == null){
+					return R.fail("产品二维码:"+productEntity.getNewQrCode()+"不存在,请更换产品");
+				}
+				if(!Objects.equals(product.getProductModelId(), productBatch.getProductModelId())){
+					return R.fail("产品二维码:"+productEntity.getNewQrCode()+"与当前批次的型号不符,请更换产品");
+				}
+				if(product.getStatus()!=2){
+					return R.fail("产品二维码:"+productEntity.getNewQrCode()+"无法入库,无法变更");
+				}
+				changeProductList.add(productEntity);
+			}
+		}
+		if(changeProductList.size()==0){
+			return R.fail("请填写需要变更的产品新二维码");
+		}
+		ProductBatchEntity productBatchEntity = this.getById(productBatch.getId());
+		if(productBatchEntity==null){
+			return R.fail("数据异常,请联系管理员");
+		}
+		for(ProductEntity productEntity : changeProductList){
+			ProductEntity oldProduct = productService.getOne(Wrappers.<ProductEntity>lambdaQuery().eq(ProductEntity::getFactoryId,productBatch.getFactoryId()).eq(ProductEntity::getQrCode,productEntity.getQrCode()));
+			LambdaUpdateWrapper<ProductEntity> updateWrapper = new LambdaUpdateWrapper<>();
+			updateWrapper.set(ProductEntity::getScanDate,null);
+			updateWrapper.set(ProductEntity::getInStockDate,null);
+			updateWrapper.set(ProductEntity::getStatus,2);
+			updateWrapper.set(ProductEntity::getBatchId,null);
+			updateWrapper.set(ProductEntity::getBatchNo,null);
+			updateWrapper.set(ProductEntity::getClientId,null);
+			updateWrapper.set(ProductEntity::getOrderNo,null);
+			updateWrapper.set(ProductEntity::getWaterCooling,null);
+			updateWrapper.set(ProductEntity::getAirtight,null);
+			updateWrapper.set(ProductEntity::getColdQrCode,null);
+			updateWrapper.eq(ProductEntity::getId,oldProduct.getId());
+			productService.update(updateWrapper);
+
+
+			ProductEntity newProduct = productService.getOne(Wrappers.<ProductEntity>lambdaQuery().eq(ProductEntity::getFactoryId,productBatch.getFactoryId()).eq(ProductEntity::getQrCode,productEntity.getNewQrCode()));
+			productEntity.setOldQrCode(productEntity.getQrCode());
+			productEntity.setQrCode(productEntity.getNewQrCode());
+			productEntity.setId(newProduct.getId());
+			productEntity.setFactoryId(productModel.getFactoryId());
+			productEntity.setProductModelId(productModel.getId());
+			productEntity.setProductName(productModel.getProductName());
+			productEntity.setProductModel(productModel.getProductModel());
+			productEntity.setScanDate(DateUtil.formatDate(new Date()));
+			productEntity.setInStockDate(new Date());
+			productEntity.setStatus(3);
+			productEntity.setBatchId(productBatchEntity.getId());
+			productEntity.setBatchNo(productBatchEntity.getBatchNo());
+			productEntity.setClientId(productBatch.getClientId());
+			productEntity.setOrderNo(productBatchEntity.getOrderNo());
+			productService.updateById(productEntity);
+		}
+
+		return null;
+	}
+
 }

+ 3 - 0
src/main/java/org/springblade/modules/pl/productBatch/vo/ProductBatchVO.java

@@ -37,4 +37,7 @@ public class ProductBatchVO extends ProductBatchEntity {
 
 
 	private List<ProductEntity> details;
+
+	private String inStockFormItem;
+
 }

+ 6 - 0
src/main/java/org/springblade/modules/pl/productModel/entity/ProductModelEntity.java

@@ -74,4 +74,10 @@ public class ProductModelEntity extends TenantEntity {
 	@ApiModelProperty(value = "入库数量")
 	private Integer inStockNum;
 
+	/**
+	 * 入库表单填写项
+	 */
+	@ApiModelProperty(value = "入库表单填写项")
+	private String inStockFormItem;
+
 }