Browse Source

导入下载错误数据excel

master
chenfang 2 years ago
parent
commit
c677071f51
  1. 108
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/itembasic/ItembasicServiceImpl.java

108
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/itembasic/ItembasicServiceImpl.java

@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
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.CustomConditions;
import com.win.framework.common.pojo.PageResult;
@ -118,15 +119,82 @@ public class ItembasicServiceImpl implements ItembasicService {
}
List<ItembasicImportExcelVo> errorList = new ArrayList<>();
importItembasics.forEach(importItembasic -> {
String massage = "";
// 校验,判断是否有不符合的原因
try {
if(mode != null){
validateItembasicForCreateOrUpdate(null,importItembasic.getCode(),importItembasic.getStatus(),importItembasic.getUom(),importItembasic.getIsStdPack()
,importItembasic.getEnableBuy(),importItembasic.getEnableMake(),importItembasic.getEnableOutsourcing()
,importItembasic.getIsRecycled(),importItembasic.getIsPhantom(),importItembasic.getAbcClass()
,importItembasic.getType(),importItembasic.getValidityDays(),importItembasic.getAvailable());
if(mode != null){
try {
validateItembasicExists(null);
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
try {
validateCodeExists(null,importItembasic.getCode());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
try {
validateStatusExists(importItembasic.getStatus());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
try {
validateUomExists(importItembasic.getUom());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
try {
validateIsStdPackExists(importItembasic.getIsStdPack());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
try {
validateEnableBuyExists(importItembasic.getEnableMake());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
try {
validateEnableMakeExists(importItembasic.getEnableBuy());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
try {
validateEnableOutsouringExists(importItembasic.getEnableOutsourcing());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
} catch (ServiceException ex) {
try {
validateIsRecycledExists(importItembasic.getIsRecycled());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
try {
validateIsPhantomExists(importItembasic.getIsPhantom());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
try {
validateAbcClassExists(importItembasic.getAbcClass());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
try {
validateTypeExists(importItembasic.getType());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
try {
validateValidityDaysExists(importItembasic.getValidityDays());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
try {
validateAvailableExists(importItembasic.getAvailable());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
}
if(StrUtil.isNotEmpty(massage)){
massage.substring(0,massage.length()-1);
errorList.add(importItembasic);
return;
}
@ -203,73 +271,73 @@ public class ItembasicServiceImpl implements ItembasicService {
}
@VisibleForTesting
private void validateStatusExists(String status) {
if (status.isEmpty()) {
if (status == null || status.isEmpty()) {
throw exception(ITEMBASIC_STATUS_NOT_EXISTS);
}
}
@VisibleForTesting
private void validateUomExists(String uom) {
if (uom.isEmpty()) {
if (uom == null || uom.isEmpty()) {
throw exception(ITEMBASIC_UOM_NOT_EXISTS);
}
}
@VisibleForTesting
private void validateIsStdPackExists(String stdPack) {
if (stdPack == null) {
if (stdPack == null || stdPack == null) {
throw exception(ITEMBASIC_IS_STDPACK_NOT_EXISTS);
}
}
@VisibleForTesting
private void validateEnableBuyExists(String enableBuy) {
if (enableBuy == null) {
if (enableBuy == null || enableBuy == null) {
throw exception(ITEMBASIC_ENABLE_BUY_NOT_EXISTS);
}
}
@VisibleForTesting
private void validateEnableMakeExists(String enableMark) {
if (enableMark == null) {
if (enableMark == null || enableMark == null) {
throw exception(ITEMBASIC_ENABLE_MAKE_NOT_EXISTS);
}
}
@VisibleForTesting
private void validateEnableOutsouringExists(String enblOutsouring) {
if (enblOutsouring == null) {
if (enblOutsouring == null || enblOutsouring.isEmpty()) {
throw exception(ITEMBASIC_ENABLE_OUTSOURING_NOT_EXISTS);
}
}
@VisibleForTesting
private void validateIsRecycledExists(String isRecycled) {
if (isRecycled == null) {
if (isRecycled == null || isRecycled.isEmpty()) {
throw exception(ITEMBASIC_IS_RECYCLED_NOT_EXISTS);
}
}
@VisibleForTesting
private void validateIsPhantomExists(String isPhantom) {
if (isPhantom == null) {
if (isPhantom == null|| isPhantom.isEmpty()) {
throw exception(ITEMBASIC_IS_PHANTOM_NOT_EXISTS);
}
}
@VisibleForTesting
private void validateAbcClassExists(String abcClass) {
if (abcClass.isEmpty()) {
if (abcClass == null ||abcClass.isEmpty()) {
throw exception(ITEMBASIC_ABC_CLASS_NOT_EXISTS);
}
}
@VisibleForTesting
private void validateTypeExists(String type) {
if (type.isEmpty()) {
if (type == null || type.isEmpty()) {
throw exception(ITEMBASIC_TYPE_NOT_EXISTS);
}
}
@VisibleForTesting
private void validateValidityDaysExists(Integer validityDays) {
if (validityDays == null) {
if (validityDays == null) {
throw exception(ITEMBASIC_VALIDITY_DAYS_NOT_EXISTS);
}
}
@VisibleForTesting
private void validateAvailableExists(String available) {
if (available == null) {
if (available == null || available.isEmpty()) {
throw exception(ITEMBASIC_AVAIABLE_NOT_EXISTS);
}
}
@ -278,7 +346,7 @@ public class ItembasicServiceImpl implements ItembasicService {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("code",code);
ItembasicDO itembasicDO = itembasicMapper.selectOne(queryWrapper);
if(itembasicDO != null && "ENABLE".equals(itembasicDO.getStatus())){
if(itembasicDO != null || "ENABLE".equals(itembasicDO.getStatus())){
return itembasicDO;
}else {
throw exception(ITEMBASIC_NOT_EXISTS);

Loading…
Cancel
Save