|
|
@ -1,12 +1,14 @@ |
|
|
|
package com.win.module.wms.service.productionlineitem; |
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.google.common.annotations.VisibleForTesting; |
|
|
|
import com.win.framework.common.exception.ServiceException; |
|
|
|
import com.win.framework.common.pojo.PageResult; |
|
|
|
import com.win.framework.datapermission.core.util.DataPermissionUtils; |
|
|
|
import com.win.module.wms.controller.productionlineitem.vo.*; |
|
|
|
import com.win.module.wms.convert.productionlineitem.ProductionlineitemConvert; |
|
|
|
import com.win.module.wms.dal.dataobject.customerdock.CustomerdockDO; |
|
|
|
import com.win.module.wms.dal.dataobject.owner.OwnerDO; |
|
|
|
import com.win.module.wms.dal.dataobject.productionlineitem.ProductionlineitemDO; |
|
|
|
import com.win.module.wms.dal.mysql.productionlineitem.ProductionlineitemMapper; |
|
|
@ -36,8 +38,8 @@ public class ProductionlineitemServiceImpl implements ProductionlineitemService |
|
|
|
|
|
|
|
@Override |
|
|
|
public Long createProductionlineitem(ProductionlineitemCreateReqVO createReqVO) { |
|
|
|
validateProcessForCreateOrUpdate(createReqVO.getId(),createReqVO.getFgLocationCode(),createReqVO.getProductionLineCode() |
|
|
|
,createReqVO.getItemCode(),createReqVO.getAvailable()); |
|
|
|
validateProcessForCreateOrUpdate(createReqVO.getId(), createReqVO.getFgLocationCode(), createReqVO.getProductionLineCode() |
|
|
|
, createReqVO.getItemCode(), createReqVO.getAvailable()); |
|
|
|
// 插入
|
|
|
|
ProductionlineitemDO productionlineitem = ProductionlineitemConvert.INSTANCE.convert(createReqVO); |
|
|
|
productionlineitemMapper.insert(productionlineitem); |
|
|
@ -48,8 +50,8 @@ public class ProductionlineitemServiceImpl implements ProductionlineitemService |
|
|
|
@Override |
|
|
|
public void updateProductionlineitem(ProductionlineitemUpdateReqVO updateReqVO) { |
|
|
|
// 校验存在
|
|
|
|
validateProcessForCreateOrUpdate(updateReqVO.getId(),updateReqVO.getFgLocationCode(),updateReqVO.getProductionLineCode() |
|
|
|
,updateReqVO.getItemCode(),updateReqVO.getAvailable()); |
|
|
|
validateProcessForCreateOrUpdate(updateReqVO.getId(), updateReqVO.getFgLocationCode(), updateReqVO.getProductionLineCode() |
|
|
|
, updateReqVO.getItemCode(), updateReqVO.getAvailable()); |
|
|
|
// 更新
|
|
|
|
ProductionlineitemDO updateObj = ProductionlineitemConvert.INSTANCE.convert(updateReqVO); |
|
|
|
productionlineitemMapper.updateById(updateObj); |
|
|
@ -92,31 +94,32 @@ public class ProductionlineitemServiceImpl implements ProductionlineitemService |
|
|
|
productionlineItems.forEach(productionlineItem -> { |
|
|
|
// 校验,判断是否有不符合的原因
|
|
|
|
try { |
|
|
|
if(mode != null){ |
|
|
|
validateProcessForCreateOrUpdate(null,productionlineItem.getFgLocationCode(),productionlineItem.getProductionLineCode() |
|
|
|
,productionlineItem.getItemCode(),productionlineItem.getAvailable());} |
|
|
|
if (mode != null) { |
|
|
|
validateProcessForCreateOrUpdate(null, productionlineItem.getFgLocationCode(), productionlineItem.getProductionLineCode() |
|
|
|
, productionlineItem.getItemCode(), productionlineItem.getAvailable()); |
|
|
|
} |
|
|
|
} catch (ServiceException ex) { |
|
|
|
errorList.add(productionlineItem); |
|
|
|
return; |
|
|
|
} |
|
|
|
// 判断如果不存在,在进行插入
|
|
|
|
OwnerDO existConfigurationSetting = null; |
|
|
|
if (existConfigurationSetting == null&& mode != 3) { |
|
|
|
if (existConfigurationSetting == null && mode != 3) { |
|
|
|
productionlineitemMapper.insert(ProductionlineitemConvert.INSTANCE.convert(productionlineItem)); |
|
|
|
} |
|
|
|
else if (existConfigurationSetting != null && mode != 2) {// 如果存在,判断是否允许更新
|
|
|
|
} else if (existConfigurationSetting != null && mode != 2) {// 如果存在,判断是否允许更新
|
|
|
|
ProductionlineitemDO productionlineItemDo = ProductionlineitemConvert.INSTANCE.convert(productionlineItem); |
|
|
|
productionlineItemDo.setId(existConfigurationSetting.getId()); |
|
|
|
productionlineitemMapper.updateById(productionlineItemDo); |
|
|
|
} |
|
|
|
}); |
|
|
|
//错误不为空并非部分更新,手工回滚
|
|
|
|
if(!errorList.isEmpty() && !updatePart) { |
|
|
|
if (!errorList.isEmpty() && !updatePart) { |
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
|
|
|
} |
|
|
|
return errorList; |
|
|
|
} |
|
|
|
private void validateProcessForCreateOrUpdate(Long id, String fgLocationCode,String productionLineCode,String itemCode,String available) { |
|
|
|
|
|
|
|
private void validateProcessForCreateOrUpdate(Long id, String fgLocationCode, String productionLineCode, String itemCode, String available) { |
|
|
|
// 关闭数据权限,避免因为没有数据权限,查询不到数据,进而导致唯一校验不正确
|
|
|
|
DataPermissionUtils.executeIgnore(() -> { |
|
|
|
validateProductionlineitemExists(id); |
|
|
@ -136,28 +139,47 @@ public class ProductionlineitemServiceImpl implements ProductionlineitemService |
|
|
|
throw exception(PRODUCTIONLINEITEM_NOT_EXISTS); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@VisibleForTesting |
|
|
|
private void validateFgLocationCodeExists(String fgLocationCode) { |
|
|
|
if (fgLocationCode.isEmpty()) { |
|
|
|
throw exception(PRODUCTIONLINEITEM_FGLOCATION_CODE_NOT_EXISTS); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@VisibleForTesting |
|
|
|
private void validateProductionLineCodeExists(String productionLineCode) { |
|
|
|
if (productionLineCode.isEmpty()) { |
|
|
|
throw exception(PRODUCTIONLINEITEM_PRODUCT_LINE_COED_NOT_EXISTS); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@VisibleForTesting |
|
|
|
private void validateItemCodeExists(String itemCode) { |
|
|
|
if (itemCode.isEmpty()) { |
|
|
|
throw exception(PRODUCTIONLINEITEM_ITEM_CODE_NOT_EXISTS); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@VisibleForTesting |
|
|
|
private void validateAvailableExists(String available) { |
|
|
|
if (available.isEmpty()) { |
|
|
|
throw exception(PRODUCTIONLINEITEM_AVAILABLE_NOT_EXISTS); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public ProductionlineitemDO ProductionlineitemExist(String code, String linecode) { |
|
|
|
QueryWrapper queryWrapper = new QueryWrapper(); |
|
|
|
queryWrapper.eq("code", code); |
|
|
|
queryWrapper.eq("linecode", linecode); |
|
|
|
ProductionlineitemDO productionlineitemDO = productionlineitemMapper.selectOne(queryWrapper); |
|
|
|
if (productionlineitemDO != null && productionlineitemDO.getAvailable().equals("TRUE")) { |
|
|
|
return productionlineitemDO; |
|
|
|
} else { |
|
|
|
throw exception(CUSTOMERDOCK_NOT_EXISTS); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|