|
|
@ -9,7 +9,9 @@ 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.saleprice.vo.*; |
|
|
|
import com.win.module.wms.convert.bom.BomConvert; |
|
|
|
import com.win.module.wms.convert.saleprice.SalepriceConvert; |
|
|
|
import com.win.module.wms.dal.dataobject.bom.BomDO; |
|
|
|
import com.win.module.wms.dal.dataobject.itembasic.ItembasicDO; |
|
|
|
import com.win.module.wms.dal.dataobject.saleprice.SalepriceDO; |
|
|
|
import com.win.module.wms.dal.mysql.saleprice.SalepriceMapper; |
|
|
@ -88,67 +90,72 @@ public class SalepriceServiceImpl implements SalepriceService { |
|
|
|
return salepriceMapper.selectList(exportReqVO); |
|
|
|
} |
|
|
|
|
|
|
|
public List<SalepriceImportExcelVo> importSalepriceList(List<SalepriceImportExcelVo> saleprices, Integer mode, boolean updatePart) { |
|
|
|
private String validateSalepriceImport( SalepriceDO saleprice ){ |
|
|
|
StringBuilder message = new StringBuilder(); |
|
|
|
try { |
|
|
|
validateSalepriceExists(null); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
validateCodeExists(null, saleprice.getItemCode()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
validateCustomerCodeExists(saleprice.getCustomerCode()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
validateCurrencyExists(saleprice.getCurrency()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
validatePriceExists(saleprice.getPrice()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
validateAvailableExists(saleprice.getAvailable()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
return message.toString(); |
|
|
|
} |
|
|
|
|
|
|
|
public List<SalepriceImportErrorVO> importSalepriceList(List<SalepriceImportExcelVo> saleprices, Integer mode, boolean updatePart) { |
|
|
|
if (CollUtil.isEmpty(saleprices)) { |
|
|
|
throw exception(SALEPRICE_IMPORT_LIST_IS_EMPTY); |
|
|
|
} |
|
|
|
List<SalepriceImportExcelVo> errorList = new ArrayList<>(); |
|
|
|
List<SalepriceImportErrorVO> errorList = new ArrayList<>(); |
|
|
|
saleprices.forEach(saleprice -> { |
|
|
|
SalepriceDO salepriceDO = SalepriceConvert.INSTANCE.convert(saleprice); |
|
|
|
|
|
|
|
// 校验,判断是否有不符合的原因
|
|
|
|
String massage = ""; |
|
|
|
if (mode != null) { |
|
|
|
try { |
|
|
|
validateSalepriceExists(null); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
massage += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
try { |
|
|
|
validateCodeExists(null, saleprice.getItemCode()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
massage += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
try { |
|
|
|
validateCustomerCodeExists(saleprice.getCustomerCode()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
massage += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
try { |
|
|
|
validateCurrencyExists(saleprice.getCurrency()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
massage += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
try { |
|
|
|
validatePriceExists(saleprice.getPrice()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
massage += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
try { |
|
|
|
validateAvailableExists(saleprice.getAvailable()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
massage += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
if (StrUtil.isNotEmpty(massage)) { |
|
|
|
massage.substring(0, massage.length() - 1); |
|
|
|
errorList.add(saleprice); |
|
|
|
} |
|
|
|
if (errorList == null) { |
|
|
|
|
|
|
|
// 判断如果不存在,在进行插入
|
|
|
|
SalepriceDO existSaleprice = salepriceMapper.selectByItemCode(saleprice.getItemCode()); |
|
|
|
if (existSaleprice == null && mode != 3) { |
|
|
|
salepriceMapper.insert(SalepriceConvert.INSTANCE.convert(saleprice)); |
|
|
|
} else if (existSaleprice != null && mode != 2) {// 如果存在,判断是否允许更新
|
|
|
|
SalepriceDO salepriceDO = SalepriceConvert.INSTANCE.convert(saleprice); |
|
|
|
salepriceDO.setId(existSaleprice.getId()); |
|
|
|
salepriceMapper.updateById(salepriceDO); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
String message =validateSalepriceImport(salepriceDO); |
|
|
|
boolean flag = true; |
|
|
|
if(!message.isEmpty()){ |
|
|
|
// 判断如果不存在,在进行插入
|
|
|
|
SalepriceImportErrorVO importErrorVO = SalepriceConvert.INSTANCE.convert2(salepriceDO); |
|
|
|
importErrorVO.setImportStatus("失败"); |
|
|
|
importErrorVO.setImportRemark(message.substring(0, message.length() - 1)); |
|
|
|
errorList.add(importErrorVO); |
|
|
|
flag = false; |
|
|
|
} |
|
|
|
if(flag) { |
|
|
|
// 判断如果不存在,在进行插入
|
|
|
|
SalepriceDO existSaleprice = salepriceMapper.selectByItemCode(saleprice.getItemCode()); |
|
|
|
if (existSaleprice == null && mode != 3) { |
|
|
|
salepriceMapper.insert(SalepriceConvert.INSTANCE.convert(saleprice)); |
|
|
|
} else if (existSaleprice != null && mode != 2) { |
|
|
|
// 如果存在,判断是否允许更新
|
|
|
|
salepriceDO.setId(existSaleprice.getId()); |
|
|
|
salepriceMapper.updateById(salepriceDO); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
//错误不为空并非部分更新,手工回滚
|
|
|
|
if (!errorList.isEmpty() && !updatePart) { |
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
|
|
|
} |
|
|
|
return errorList; |
|
|
|
} |
|
|
|
|
|
|
|