|
|
@ -8,12 +8,11 @@ import com.win.framework.common.exception.ServiceException; |
|
|
|
import com.win.framework.common.pojo.CustomConditions; |
|
|
|
import com.win.framework.common.pojo.PageResult; |
|
|
|
import com.win.framework.datapermission.core.util.DataPermissionUtils; |
|
|
|
import com.win.module.wms.controller.warehouse.vo.WarehouseCreateReqVO; |
|
|
|
import com.win.module.wms.controller.warehouse.vo.WarehouseExportReqVO; |
|
|
|
import com.win.module.wms.controller.warehouse.vo.WarehousePageReqVO; |
|
|
|
import com.win.module.wms.controller.warehouse.vo.WarehouseUpdateReqVO; |
|
|
|
import com.win.module.wms.controller.warehouse.vo.WarehouseImportExcelVo; |
|
|
|
import com.win.module.wms.controller.bom.vo.BomImportErrorVO; |
|
|
|
import com.win.module.wms.controller.warehouse.vo.*; |
|
|
|
import com.win.module.wms.convert.bom.BomConvert; |
|
|
|
import com.win.module.wms.convert.warehouse.WarehouseConvert; |
|
|
|
import com.win.module.wms.dal.dataobject.bom.BomDO; |
|
|
|
import com.win.module.wms.dal.dataobject.warehouse.WarehouseDO; |
|
|
|
import com.win.module.wms.dal.dataobject.packageMassage.PackageDO; |
|
|
|
import com.win.module.wms.dal.dataobject.warehouse.WarehouseDO; |
|
|
@ -95,51 +94,57 @@ public class WarehouseServiceImpl implements WarehouseService { |
|
|
|
return warehouseMapper.selectSenior(conditions); |
|
|
|
} |
|
|
|
|
|
|
|
public List<WarehouseImportExcelVo> importWarehouseList(List<WarehouseImportExcelVo> warehouses, Integer mode, boolean updatePart) { |
|
|
|
private String validateWarehouseImport( WarehouseDO warehouse ){ |
|
|
|
StringBuilder message = new StringBuilder(); |
|
|
|
try { |
|
|
|
validateWarehouseExists(null); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
validateCodeExists(null,warehouse.getCode()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
validateAvailableExists(warehouse.getAvailable()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
return message.toString(); |
|
|
|
} |
|
|
|
|
|
|
|
public List<WarehouseImportErrorVO> importWarehouseList(List<WarehouseImportExcelVo> warehouses, Integer mode, boolean updatePart) { |
|
|
|
if (CollUtil.isEmpty(warehouses)) { |
|
|
|
throw exception(WAREHOUSE_IMPORT_LIST_IS_EMPTY); |
|
|
|
} |
|
|
|
List<WarehouseImportExcelVo> errorList = new ArrayList<>(); |
|
|
|
List<WarehouseImportErrorVO> errorList = new ArrayList<>(); |
|
|
|
warehouses.forEach(warehouse -> { |
|
|
|
WarehouseDO WarehouseDO = WarehouseConvert.INSTANCE.convert(warehouse); |
|
|
|
// 校验,判断是否有不符合的原因
|
|
|
|
String massage = ""; |
|
|
|
|
|
|
|
if(mode != null){ |
|
|
|
try { |
|
|
|
validateWarehouseExists(null); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
massage += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
try { |
|
|
|
validateCodeExists(null,warehouse.getCode()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
massage += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
try { |
|
|
|
validateAvailableExists(warehouse.getAvailable()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
massage += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
} |
|
|
|
if(StrUtil.isNotEmpty(massage)){ |
|
|
|
massage.substring(0,massage.length()-1); |
|
|
|
errorList.add(warehouse); |
|
|
|
String massage =this.validateWarehouseImport(WarehouseDO); |
|
|
|
boolean flag = true; |
|
|
|
if(!massage.isEmpty()){ |
|
|
|
WarehouseImportErrorVO importErrorVO = WarehouseConvert.INSTANCE.convert2(WarehouseDO); |
|
|
|
importErrorVO.setImportStatus("失败"); |
|
|
|
importErrorVO.setImportRemark(massage.substring(0, massage.length() - 1)); |
|
|
|
errorList.add(importErrorVO); |
|
|
|
flag = false; |
|
|
|
} |
|
|
|
|
|
|
|
// 判断如果不存在,在进行插入
|
|
|
|
if(errorList == null){ WarehouseDO existWarehouse = warehouseMapper.selectByCode(warehouse.getCode()); |
|
|
|
if (existWarehouse == null&& mode != 3) { |
|
|
|
warehouseMapper.insert(WarehouseConvert.INSTANCE.convert(warehouse)); |
|
|
|
} |
|
|
|
else if (existWarehouse != null && mode != 2) {// 如果存在,判断是否允许更新
|
|
|
|
WarehouseDO warehouseDO = WarehouseConvert.INSTANCE.convert(warehouse); |
|
|
|
warehouseDO.setId(existWarehouse.getId()); |
|
|
|
warehouseMapper.updateById(warehouseDO);} |
|
|
|
if(flag) { |
|
|
|
WarehouseDO existWarehouse = warehouseMapper.selectByCode(warehouse.getCode()); |
|
|
|
if (existWarehouse == null && mode != 3) { |
|
|
|
warehouseMapper.insert(WarehouseConvert.INSTANCE.convert(warehouse)); |
|
|
|
} else if (existWarehouse != null && mode != 2) { |
|
|
|
// 如果存在,判断是否允许更新
|
|
|
|
WarehouseDO warehouseDO = WarehouseConvert.INSTANCE.convert(warehouse); |
|
|
|
warehouseDO.setId(existWarehouse.getId()); |
|
|
|
warehouseMapper.updateById(warehouseDO); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
//错误不为空并非部分更新,手工回滚
|
|
|
|
if(!errorList.isEmpty() && !updatePart) { |
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
|
|
|
} |
|
|
|
return errorList; |
|
|
|
} |
|
|
|
|
|
|
@ -190,7 +195,7 @@ public class WarehouseServiceImpl implements WarehouseService { |
|
|
|
} |
|
|
|
@Override |
|
|
|
public WarehouseDO WarehouseExist(String code) { |
|
|
|
QueryWrapper queryWrapper = new QueryWrapper(); |
|
|
|
QueryWrapper<WarehouseDO> queryWrapper = new QueryWrapper(); |
|
|
|
queryWrapper.eq("code",code); |
|
|
|
WarehouseDO warehouseDO = warehouseMapper.selectOne(queryWrapper); |
|
|
|
if(warehouseDO != null&& warehouseDO.getAvailable().equals("TRUE")){ |
|
|
|