|
|
@@ -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;
|
|
|
+ }
|
|
|
+
|
|
|
}
|