|
|
@ -9,10 +9,13 @@ 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.stdcostprice.vo.*; |
|
|
|
import com.win.module.wms.convert.purchasereceiptRequest.PurchasereceiptRequestMainConvert; |
|
|
|
import com.win.module.wms.convert.stdcostprice.StdcostpriceConvert; |
|
|
|
import com.win.module.wms.dal.dataobject.purchasereceiptRequest.PurchasereceiptRequestMainDO; |
|
|
|
import com.win.module.wms.dal.dataobject.stdcostprice.StdcostpriceDO; |
|
|
|
import com.win.module.wms.dal.mysql.stdcostprice.StdcostpriceMapper; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport; |
|
|
|
import org.springframework.validation.annotation.Validated; |
|
|
|
|
|
|
@ -90,69 +93,75 @@ public class StdcostpriceServiceImpl implements StdcostpriceService { |
|
|
|
public List<StdcostpriceDO> getStdcostpriceList(StdcostpriceExportReqVO exportReqVO) { |
|
|
|
return stdcostpriceMapper.selectList(exportReqVO); |
|
|
|
} |
|
|
|
public List<StdcostpriceImportExcelVo> importStdcostpriceList(List<StdcostpriceImportExcelVo> stdcostprices, Integer mode, boolean updatePart) { |
|
|
|
|
|
|
|
private String validateStdcostpriceImport(StdcostpriceDO stdcostprice) { |
|
|
|
StringBuilder message = new StringBuilder(); |
|
|
|
try { |
|
|
|
validateStdcostpriceExists(null); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
validateCodeExists(null,stdcostprice.getSupplierCode(),stdcostprice.getItemCode()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
validateSuppercodeExists(stdcostprice.getSupplierCode()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
validateCurrencyExists(stdcostprice.getCurrency()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
validatePriceExists(stdcostprice.getPrice()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
validateAvailableExists(stdcostprice.getAvailable()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
return message.toString(); |
|
|
|
} |
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public List<StdcostpriceImportErrorVO> importStdcostpriceList(List<StdcostpriceImportExcelVo> stdcostprices, Integer mode, boolean updatePart) { |
|
|
|
if (CollUtil.isEmpty(stdcostprices)) { |
|
|
|
throw exception(STDCOSTPRICE_IMPORT_LIST_IS_EMPTY); |
|
|
|
} |
|
|
|
List<StdcostpriceImportExcelVo> errorList = new ArrayList<>(); |
|
|
|
List<StdcostpriceImportErrorVO> errorList = new ArrayList<>(); |
|
|
|
stdcostprices.forEach(stdcostprice -> { |
|
|
|
// 校验,判断是否有不符合的原因
|
|
|
|
String massage = ""; |
|
|
|
StdcostpriceDO stdcostpriceDO = StdcostpriceConvert.INSTANCE.convert(stdcostprice); |
|
|
|
if(mode != null){ |
|
|
|
try { |
|
|
|
validateStdcostpriceExists(null); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
massage += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
try { |
|
|
|
validateCodeExists(null,stdcostprice.getSupplierCode(),stdcostprice.getItemCode()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
massage += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
try { |
|
|
|
validateSuppercodeExists(stdcostprice.getSupplierCode()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
massage += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
try { |
|
|
|
validateCurrencyExists(stdcostprice.getCurrency()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
massage += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
try { |
|
|
|
validatePriceExists(stdcostprice.getPrice()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
massage += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
try { |
|
|
|
validateAvailableExists(stdcostprice.getAvailable()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
massage += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
|
|
|
|
if(StrUtil.isNotEmpty(massage)){ |
|
|
|
massage.substring(0,massage.length()-1); |
|
|
|
errorList.add(stdcostprice); |
|
|
|
} |
|
|
|
if(errorList == null) { |
|
|
|
|
|
|
|
String massage = this.validateStdcostpriceImport(stdcostpriceDO); |
|
|
|
boolean flag = true; |
|
|
|
if(!massage.isEmpty()){ |
|
|
|
StdcostpriceImportErrorVO importErrorVO = StdcostpriceConvert.INSTANCE.convert1(stdcostpriceDO); |
|
|
|
importErrorVO.setImportStatus("失败"); |
|
|
|
importErrorVO.setImportRemark(massage.substring(0, massage.length() - 1)); |
|
|
|
errorList.add(importErrorVO); |
|
|
|
flag = false; |
|
|
|
} |
|
|
|
//写入数据
|
|
|
|
if(flag) { |
|
|
|
// 判断如果不存在,在进行插入
|
|
|
|
StdcostpriceDO existStdcostprice = stdcostpriceMapper.selectByStdcostpriceCode(stdcostprice.getSupplierCode(),stdcostprice.getItemCode()); |
|
|
|
if (existStdcostprice == null && mode != 3) { |
|
|
|
stdcostpriceMapper.insert(StdcostpriceConvert.INSTANCE.convert(stdcostprice)); |
|
|
|
} else if (existStdcostprice != null && mode != 2) {// 如果存在,判断是否允许更新
|
|
|
|
StdcostpriceDO stdcostpriceDO = StdcostpriceConvert.INSTANCE.convert(stdcostprice); |
|
|
|
stdcostpriceMapper.insert(stdcostpriceDO); |
|
|
|
} else if (existStdcostprice != null && mode != 2) { |
|
|
|
// 如果存在,判断是否允许更新
|
|
|
|
stdcostpriceDO.setId(existStdcostprice.getId()); |
|
|
|
stdcostpriceMapper.updateById(stdcostpriceDO); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
//错误不为空并非部分更新,手工回滚
|
|
|
|
if(!errorList.isEmpty() && !updatePart) { |
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
|
|
|
} |
|
|
|
return errorList; |
|
|
|
} |
|
|
|
|
|
|
|