|
|
@ -2,27 +2,31 @@ package com.win.module.wms.service.deliverRequest; |
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import cn.hutool.core.exceptions.UtilException; |
|
|
|
import com.win.framework.common.exception.ErrorCode; |
|
|
|
import com.win.framework.common.pojo.CustomConditions; |
|
|
|
import com.win.framework.common.util.validation.ValidationUtils; |
|
|
|
import com.win.framework.dict.core.util.DictFrameworkUtils; |
|
|
|
import com.win.module.infra.api.trends.TrendsApi; |
|
|
|
import com.win.module.infra.enums.TrendsTypeEnum; |
|
|
|
import com.win.module.system.api.dict.DictDataApi; |
|
|
|
import com.win.module.system.api.dict.dto.DictDataRespDTO; |
|
|
|
import com.win.module.system.api.serialnumber.SerialNumberApi; |
|
|
|
import com.win.module.system.enums.serialNumber.RuleCodeEnum; |
|
|
|
import com.win.module.wms.controller.deliverRequest.vo.*; |
|
|
|
import com.win.module.wms.controller.issueRequest.vo.IssueRequestDetailCreateReqVO; |
|
|
|
import com.win.module.wms.controller.issueRequest.vo.IssueRequestImportErrorVO; |
|
|
|
import com.win.module.wms.controller.issueRequest.vo.*; |
|
|
|
import com.win.module.wms.convert.deliverRequest.DeliverRequestDetailConvert; |
|
|
|
import com.win.module.wms.convert.issueRequest.IssueRequestDetailConvert; |
|
|
|
import com.win.module.wms.convert.issueRequest.IssueRequestMainConvert; |
|
|
|
import com.win.module.wms.dal.dataobject.businesstype.BusinesstypeDO; |
|
|
|
import com.win.module.wms.dal.dataobject.deliverRequest.DeliverRequestDetailDO; |
|
|
|
import com.win.module.wms.dal.dataobject.issueRequest.IssueRequestDetailDO; |
|
|
|
import com.win.module.wms.dal.dataobject.issueRequest.IssueRequestMainDO; |
|
|
|
import com.win.module.wms.dal.dataobject.itembasic.ItembasicDO; |
|
|
|
import com.win.module.wms.dal.dataobject.requestsetting.RequestsettingDO; |
|
|
|
import com.win.module.wms.dal.dataobject.sale.SaleDetailDO; |
|
|
|
import com.win.module.wms.dal.mysql.deliverRequest.DeliverRequestDetailMapper; |
|
|
|
import com.win.module.wms.enums.DictTypeConstants; |
|
|
|
import com.win.module.wms.enums.request.RequestStatusEnum; |
|
|
|
import com.win.module.wms.service.customer.*; |
|
|
|
import com.win.module.wms.service.itembasic.ItembasicService; |
|
|
|
import com.win.module.wms.service.requestsetting.RequestsettingService; |
|
|
@ -68,6 +72,9 @@ public class DeliverRequestMainServiceImpl implements DeliverRequestMainService |
|
|
|
@Resource |
|
|
|
private Validator validator; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private TrendsApi trendsApi; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private DictDataApi dictDataApi; |
|
|
|
@Resource |
|
|
@ -79,23 +86,100 @@ public class DeliverRequestMainServiceImpl implements DeliverRequestMainService |
|
|
|
@Resource |
|
|
|
private DeliverJobMainService deliverJobMainService; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public Long createDeliverRequestMain(DeliverRequestMainCreateReqVO createReqVO) { |
|
|
|
// 插入
|
|
|
|
DeliverRequestMainDO deliverRequestMain = DeliverRequestMainConvert.INSTANCE.convert(createReqVO); |
|
|
|
deliverRequestMainMapper.insert(deliverRequestMain); |
|
|
|
// 返回
|
|
|
|
RequestsettingDO requestsettingDO = new RequestsettingDO(); |
|
|
|
DeliverRequestMainDO deliverRequestMain = validatorToCreate(createReqVO,requestsettingDO); |
|
|
|
//调用自动执行方法
|
|
|
|
if(RequestStatusEnum.HANDLING.getCode().equals(deliverRequestMain.getStatus())) { |
|
|
|
|
|
|
|
} |
|
|
|
trendsApi.createTrends(requestsettingDO.getId(), "IssueRequest", "增加了发料申请", TrendsTypeEnum.CREATE); |
|
|
|
return deliverRequestMain.getId(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private DeliverRequestMainDO validatorToCreate(DeliverRequestMainCreateReqVO createReqVO, RequestsettingDO requestsettingDO) { |
|
|
|
BusinesstypeDO businesstypeDO = new BusinesstypeDO(); |
|
|
|
DeliverRequestMainDO deliverRequestMainDO = validateMainMethod(createReqVO,businesstypeDO,requestsettingDO); |
|
|
|
List<DeliverRequestDetailCreateReqVO> subList = createReqVO.getSubList(); |
|
|
|
List<DeliverRequestDetailDO> subDOList = DeliverRequestDetailConvert.INSTANCE.convertList03(subList); |
|
|
|
for (DeliverRequestDetailDO deliverRequestDetailDO : subDOList) { |
|
|
|
validateDetailMethod(deliverRequestDetailDO); |
|
|
|
} |
|
|
|
String number = serialNumberApi.generateCode(RuleCodeEnum.PURCHASE_CLAIM_RECORD.getCode()); |
|
|
|
deliverRequestMainDO.setNumber(number); |
|
|
|
deliverRequestMainMapper.insert(deliverRequestMainDO); |
|
|
|
for (DeliverRequestDetailDO deliverRequestDetailDO : subDOList) { |
|
|
|
deliverRequestDetailDO.setMasterId(deliverRequestMainDO.getId()); |
|
|
|
deliverRequestDetailDO.setNumber(deliverRequestMainDO.getNumber()); |
|
|
|
} |
|
|
|
deliverRequestDetailMapper.insertBatch(subDOList); |
|
|
|
return deliverRequestMainDO; |
|
|
|
} |
|
|
|
|
|
|
|
private DeliverRequestMainDO validateMainMethod(DeliverRequestMainBaseVO baseVO, BusinesstypeDO businesstypeDO, RequestsettingDO requestsettingDO){ |
|
|
|
DeliverRequestMainDO deliverRequestMainDO = DeliverRequestMainConvert.INSTANCE.convert(baseVO); |
|
|
|
deliverRequestMainDO.setStatus(DictFrameworkUtils.parseDictDataValue(DictTypeConstants.REQUEST_STATUS, "新增")); |
|
|
|
deliverRequestMainDO.setRequestTime(LocalDateTime.now()); |
|
|
|
requestsettingDO = requestsettingService.selectRequestsettingExist("DeliverRequest"); |
|
|
|
deliverRequestMainDO.setAutoAgree(requestsettingDO.getAutoAgree()); |
|
|
|
deliverRequestMainDO.setAutoCommit(requestsettingDO.getAutoCommit()); |
|
|
|
deliverRequestMainDO.setAutoExecute(requestsettingDO.getAutoExecute()); |
|
|
|
deliverRequestMainDO.setDirectCreateRecord(requestsettingDO.getDirectCreateRecord()); |
|
|
|
businesstypeDO = jobUtils.selectDocumentSettingFromBusinessType("DeliverRequest"); |
|
|
|
deliverRequestMainDO.setBusinessType(businesstypeDO.getCode()); |
|
|
|
deliverRequestMainDO.setFromLocationTypes(businesstypeDO.getOutLocationTypes()); |
|
|
|
deliverRequestMainDO.setToLocationTypes(businesstypeDO.getInLocationTypes()); |
|
|
|
deliverRequestMainDO.setFromAreaCodes(businesstypeDO.getOutAreaCodes()); |
|
|
|
deliverRequestMainDO.setToAreaCodes(businesstypeDO.getInAreaCodes()); |
|
|
|
return deliverRequestMainDO; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private DeliverRequestDetailDO validateDetailMethod(DeliverRequestDetailDO deliverRequestDetailDO) { |
|
|
|
ItembasicDO itembasicDO = validatoritemcode(deliverRequestDetailDO.getItemCode()); |
|
|
|
deliverRequestDetailDO.setItemDesc1(itembasicDO.getDesc1()); |
|
|
|
deliverRequestDetailDO.setItemDesc2(itembasicDO.getDesc2()); |
|
|
|
deliverRequestDetailDO.setItemName(itembasicDO.getName()); |
|
|
|
deliverRequestDetailDO.setProjectCode(itembasicDO.getProject()); |
|
|
|
Isuom(itembasicDO.getUom(),deliverRequestDetailDO.getUom()); |
|
|
|
SaleDetailDO saleDetailDO =validatorSale(deliverRequestDetailDO.getSoNumber(),deliverRequestDetailDO.getSoLine(),deliverRequestDetailDO.getItemCode()); |
|
|
|
if(saleDetailDO!=null) { |
|
|
|
Isqty(saleDetailDO.getShippedQty(), deliverRequestDetailDO.getQty(), saleDetailDO.getOrderQty(), deliverRequestDetailDO.getSoNumber(), deliverRequestDetailDO.getSoLine(), deliverRequestDetailDO.getItemCode()); |
|
|
|
} |
|
|
|
return deliverRequestDetailDO; |
|
|
|
|
|
|
|
} |
|
|
|
@Override |
|
|
|
public void updateDeliverRequestMain(DeliverRequestMainUpdateReqVO updateReqVO) { |
|
|
|
RequestsettingDO requestsettingDO = new RequestsettingDO(); |
|
|
|
// 校验存在
|
|
|
|
validateDeliverRequestMainExists(updateReqVO.getId()); |
|
|
|
// 更新
|
|
|
|
DeliverRequestMainDO deliverRequestMainDO = validatorToUpdate(updateReqVO, requestsettingDO); |
|
|
|
DeliverRequestMainDO updateObj = DeliverRequestMainConvert.INSTANCE.convert(updateReqVO); |
|
|
|
deliverRequestMainMapper.updateById(updateObj); |
|
|
|
} |
|
|
|
private DeliverRequestMainDO validatorToUpdate(DeliverRequestMainUpdateReqVO updateReqVO, RequestsettingDO requestsettingDO) { |
|
|
|
BusinesstypeDO businesstypeDO = new BusinesstypeDO(); |
|
|
|
DeliverRequestMainDO deliverRequestMainDO = validateMainMethod(updateReqVO,businesstypeDO,requestsettingDO); |
|
|
|
//子表校验
|
|
|
|
List<DeliverRequestDetailCreateReqVO> subList = updateReqVO.getSubList(); |
|
|
|
List<DeliverRequestDetailDO> subDOList = DeliverRequestDetailConvert.INSTANCE.convertList03(subList); |
|
|
|
for (DeliverRequestDetailDO issueRequestDetailDO : subDOList) { |
|
|
|
validateDetailMethod(issueRequestDetailDO); |
|
|
|
} |
|
|
|
deliverRequestMainMapper.updateById(deliverRequestMainDO); |
|
|
|
deliverRequestDetailMapper.updateBatch(subDOList); |
|
|
|
return deliverRequestMainDO; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void deleteDeliverRequestMain(Long id) { |
|
|
@ -138,10 +222,12 @@ public class DeliverRequestMainServiceImpl implements DeliverRequestMainService |
|
|
|
public String Isuom(String uom1, String uom2) { |
|
|
|
DictDataRespDTO dictDataRespDTO = dictDataApi.selectDictValue(uom1); |
|
|
|
String value = dictDataRespDTO.getLabel(); |
|
|
|
if(uom2.equals(value)){ |
|
|
|
DictDataRespDTO dictDataRespDTO1 = dictDataApi.selectDictValue(uom2); |
|
|
|
String value2 = dictDataRespDTO1.getLabel(); |
|
|
|
if(value2.equals(value)){ |
|
|
|
return "ture"; |
|
|
|
}else { |
|
|
|
throw new UtilException("计量单位"+uom2+"错误,应该是"+value); |
|
|
|
throw exception(UOM_ERROR, value2); |
|
|
|
} |
|
|
|
} |
|
|
|
public String Isqty(BigDecimal shippedqty, BigDecimal detailqty, BigDecimal orderqty,String sonumber,String soline,String itemcode) { |
|
|
@ -149,113 +235,141 @@ public class DeliverRequestMainServiceImpl implements DeliverRequestMainService |
|
|
|
if( resultqty.compareTo(detailqty)>0 ) |
|
|
|
return "TURE"; |
|
|
|
else{ |
|
|
|
throw new UtilException("发货数量"+detailqty+"大于订单号"+sonumber+"、订单行"+soline+"、物品代码"+itemcode+"的未发货数量"+ resultqty ); |
|
|
|
throw exception(QTY_ERROR, detailqty,sonumber,soline,itemcode,resultqty); |
|
|
|
} |
|
|
|
} |
|
|
|
private String validateDeliverRequestMainImport(DeliverRequestMainDO mainDo, BusinesstypeDO businesstypeDO) { |
|
|
|
StringBuilder message = new StringBuilder(); |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public List<DeliverRequestImportErrorVO> importDeliverRequestList(List<DeliverRequestMainCreateReqVO> datas, Integer mode, boolean updatePart){ |
|
|
|
if (CollUtil.isEmpty(datas)) { |
|
|
|
throw exception(DELIVER_REQUEST_NOT_EXISTS); |
|
|
|
mainDo.setStatus(DictFrameworkUtils.parseDictDataValue(DictTypeConstants.REQUEST_STATUS, "新增")); |
|
|
|
mainDo.setRequestTime(LocalDateTime.now()); |
|
|
|
RequestsettingDO requestsettingDO = requestsettingService.selectRequestsettingExist("DeliverRequest"); |
|
|
|
if (requestsettingDO == null) { |
|
|
|
message.append("未查找到发料申请的相关申请设置"); |
|
|
|
} else { |
|
|
|
mainDo.setAutoAgree(requestsettingDO.getAutoAgree()); |
|
|
|
mainDo.setAutoCommit(requestsettingDO.getAutoCommit()); |
|
|
|
mainDo.setAutoExecute(requestsettingDO.getAutoExecute()); |
|
|
|
mainDo.setDirectCreateRecord(requestsettingDO.getDirectCreateRecord()); |
|
|
|
} |
|
|
|
businesstypeDO = jobUtils.selectDocumentSettingFromBusinessType("DeliverRequest"); |
|
|
|
if(businesstypeDO == null){ |
|
|
|
message.append("根据单据设置未查找到发料申请的相关业务类型"); |
|
|
|
}else { |
|
|
|
mainDo.setBusinessType(businesstypeDO.getCode()); |
|
|
|
mainDo.setFromLocationTypes(businesstypeDO.getOutLocationTypes()); |
|
|
|
mainDo.setToLocationTypes(businesstypeDO.getInLocationTypes()); |
|
|
|
mainDo.setFromAreaCodes(businesstypeDO.getOutAreaCodes()); |
|
|
|
mainDo.setToAreaCodes(businesstypeDO.getInAreaCodes()); |
|
|
|
} |
|
|
|
List<DeliverRequestImportErrorVO> errorList = new ArrayList<>(); |
|
|
|
datas.forEach(createReqVO -> { |
|
|
|
String messageMain = ""; |
|
|
|
BusinesstypeDO businesstypeDO = null; |
|
|
|
try { |
|
|
|
customerService.selectCustomerExist(createReqVO.getCustomerCode()); |
|
|
|
ValidationUtils.validate(validator, mainDo); |
|
|
|
} catch (Exception ex) { |
|
|
|
messageMain += ex.getMessage() + ","; |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
createReqVO.setStatus(DictFrameworkUtils.parseDictDataValue(DictTypeConstants.REQUEST_STATUS, "新增")); |
|
|
|
createReqVO.setRequestTime(LocalDateTime.now()); |
|
|
|
try { |
|
|
|
RequestsettingDO requestsettingDO = requestsettingService.selectRequestsettingExist("DeliverRequest"); |
|
|
|
if (requestsettingDO != null) { |
|
|
|
createReqVO.setAutoAgree(requestsettingDO.getAutoAgree()); |
|
|
|
createReqVO.setAutoCommit(requestsettingDO.getAutoCommit()); |
|
|
|
createReqVO.setAutoExecute(requestsettingDO.getAutoExecute()); |
|
|
|
createReqVO.setDirectCreateRecord(requestsettingDO.getDirectCreateRecord()); |
|
|
|
return message.toString(); |
|
|
|
} |
|
|
|
} catch (Exception ex) { |
|
|
|
messageMain += ex.getMessage() + ","; |
|
|
|
private void validatorcustomercode(String code){ |
|
|
|
customerService.selectCustomerExist(code); |
|
|
|
} |
|
|
|
try { |
|
|
|
businesstypeDO = jobUtils.selectDocumentSettingFromBusinessType("DeliverRequest"); |
|
|
|
createReqVO.setBusinessType(businesstypeDO.getCode()); |
|
|
|
createReqVO.setFromLocationTypes(businesstypeDO.getOutLocationTypes()); |
|
|
|
createReqVO.setToLocationTypes(businesstypeDO.getInLocationTypes()); |
|
|
|
createReqVO.setFromAreaCodes(businesstypeDO.getOutAreaCodes()); |
|
|
|
createReqVO.setToAreaCodes(businesstypeDO.getInAreaCodes()); |
|
|
|
} catch (Exception ex) { |
|
|
|
messageMain += ex.getMessage() + ","; |
|
|
|
private ItembasicDO validatoritemcode(String code){ |
|
|
|
ItembasicDO itembasicDO = itembasicService.selectItembasic(code); |
|
|
|
return itembasicDO; |
|
|
|
} |
|
|
|
|
|
|
|
private SaleDetailDO validatorSale(String SoNumber,String SoLine,String ItemCode ){ |
|
|
|
SaleDetailDO saleDetailDO =deliverJobMainService.saleDetailExist(SoNumber,SoLine,ItemCode ); |
|
|
|
return saleDetailDO; |
|
|
|
} |
|
|
|
|
|
|
|
private String validateIssueRequestDetailImport(DeliverRequestDetailDO detailDo, DeliverRequestMainDO mainDo, BusinesstypeDO businesstypeDO) { |
|
|
|
StringBuilder message = new StringBuilder(); |
|
|
|
try{ |
|
|
|
ValidationUtils.validate(validator, createReqVO); |
|
|
|
validatorcustomercode(mainDo.getCustomerCode()); |
|
|
|
} catch (Exception ex) { |
|
|
|
messageMain += ex.getMessage() + ","; |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
String number = serialNumberApi.generateCode(RuleCodeEnum.PURCHASE_RETURN_REQUEST.getCode()); |
|
|
|
createReqVO.setNumber(number); |
|
|
|
List<DeliverRequestDetailCreateReqVO> subList = createReqVO.getSubList(); |
|
|
|
List<DeliverRequestDetailDO> subDOList = DeliverRequestDetailConvert.INSTANCE.convertList03(subList); |
|
|
|
for (DeliverRequestDetailDO detailDO : subDOList) { |
|
|
|
String messageDetail = ""; |
|
|
|
try { |
|
|
|
ItembasicDO itembasicDO = itembasicService.selectItembasic(detailDO.getItemCode()); |
|
|
|
detailDO.setItemDesc1(itembasicDO.getDesc1()); |
|
|
|
detailDO.setItemDesc2(itembasicDO.getDesc2()); |
|
|
|
detailDO.setItemName(itembasicDO.getName()); |
|
|
|
detailDO.setProjectCode(itembasicDO.getProject()); |
|
|
|
ItembasicDO itembasicDO = validatoritemcode(detailDo.getItemCode()); |
|
|
|
detailDo.setItemDesc1(itembasicDO.getDesc1()); |
|
|
|
detailDo.setItemDesc2(itembasicDO.getDesc2()); |
|
|
|
detailDo.setItemName(itembasicDO.getName()); |
|
|
|
detailDo.setProjectCode(itembasicDO.getProject()); |
|
|
|
try{ |
|
|
|
Isuom(itembasicDO.getUom(),detailDO.getUom()); |
|
|
|
Isuom(itembasicDO.getUom(),detailDo.getUom()); |
|
|
|
}catch (Exception ex) { |
|
|
|
|
|
|
|
messageDetail += ex.getMessage() + ","; |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
}catch (Exception ex) { |
|
|
|
messageDetail += ex.getMessage() + ","; |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try{ |
|
|
|
SaleDetailDO saleDetailDO =deliverJobMainService.saleDetailExist(detailDO.getSoNumber(),detailDO.getSoLine(),detailDO.getItemCode()); |
|
|
|
try{ |
|
|
|
SaleDetailDO saleDetailDO =validatorSale(detailDo.getSoNumber(),detailDo.getSoLine(),detailDo.getItemCode()); |
|
|
|
|
|
|
|
if(saleDetailDO!=null) { |
|
|
|
Isqty(saleDetailDO.getShippedQty(),detailDO.getQty(),saleDetailDO.getOrderQty(),detailDO.getSoNumber(),detailDO.getSoLine(),detailDO.getItemCode()); |
|
|
|
try { |
|
|
|
Isqty(saleDetailDO.getShippedQty(), detailDo.getQty(), saleDetailDO.getOrderQty(), detailDo.getSoNumber(), detailDo.getSoLine(), detailDo.getItemCode()); |
|
|
|
} catch (Exception ex) { |
|
|
|
|
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
} |
|
|
|
}catch (Exception ex) { |
|
|
|
messageDetail += ex.getMessage() + ","; |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
ValidationUtils.validate(validator, detailDo); |
|
|
|
} catch (Exception ex) { |
|
|
|
messageDetail += ex.getMessage() + ","; |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
return message.toString(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public List<DeliverRequestImportErrorVO> importDeliverRequestList(List<DeliverRequestMainCreateReqVO> datas, Integer mode, boolean updatePart){ |
|
|
|
if (CollUtil.isEmpty(datas)) { |
|
|
|
throw exception(DELIVER_REQUEST_NOT_EXISTS); |
|
|
|
} |
|
|
|
DeliverRequestDetailCreateReqVO purchaseturnRequestDetailCreateReqVO = DeliverRequestDetailConvert.INSTANCE.convert1(detailDO); |
|
|
|
DeliverRequestImportErrorVO importVO = DeliverRequestDetailConvert.INSTANCE.convert(createReqVO, purchaseturnRequestDetailCreateReqVO); |
|
|
|
if (!messageMain.equals("") || !messageDetail.equals("")) { |
|
|
|
importVO.setImportStatus("失败"); |
|
|
|
List<DeliverRequestImportErrorVO> errorList = new ArrayList<>(); |
|
|
|
datas.forEach(createReqVO -> { |
|
|
|
|
|
|
|
BusinesstypeDO businesstypeDO = new BusinesstypeDO(); |
|
|
|
DeliverRequestMainDO mainDo = DeliverRequestMainConvert.INSTANCE.convert(createReqVO); |
|
|
|
String messageMain = validateDeliverRequestMainImport(mainDo, businesstypeDO); |
|
|
|
List<DeliverRequestDetailCreateReqVO> subList = createReqVO.getSubList(); |
|
|
|
List<DeliverRequestDetailDO> subDOList = DeliverRequestDetailConvert.INSTANCE.convertList03(subList); |
|
|
|
// 是否有错误数据
|
|
|
|
boolean flag = true; |
|
|
|
for (DeliverRequestDetailDO detailDO : subDOList) { |
|
|
|
String messageDetail = validateIssueRequestDetailImport(detailDO, mainDo, businesstypeDO); |
|
|
|
if (!messageMain.isEmpty() || messageDetail.isEmpty()) { |
|
|
|
DeliverRequestImportErrorVO importErrorVO = DeliverRequestMainConvert.INSTANCE.convert(createReqVO, detailDO); |
|
|
|
importErrorVO.setImportStatus("失败"); |
|
|
|
messageMain = messageMain + messageDetail; |
|
|
|
importVO.setImportRemark(messageMain.substring(0, messageMain.length() - 1)); |
|
|
|
errorList.add(importVO); |
|
|
|
} else { |
|
|
|
detailDO.setNumber(createReqVO.getNumber()); |
|
|
|
detailDO.setMasterId(createReqVO.getId()); |
|
|
|
importErrorVO.setImportRemark(messageMain.substring(0, messageMain.length() - 1)); |
|
|
|
errorList.add(importErrorVO); |
|
|
|
flag = false; |
|
|
|
} |
|
|
|
} |
|
|
|
DeliverRequestMainDO createobj = DeliverRequestMainConvert.INSTANCE.convert(createReqVO); |
|
|
|
if (errorList.isEmpty()) { |
|
|
|
DeliverRequestMainDO existDeliverRequestMainDO = deliverRequestMainMapper.selectWorkShopCodeAndUseOnTheWayLocation(createReqVO.getCustomerCode()); |
|
|
|
if (existDeliverRequestMainDO == null && mode != 3) { |
|
|
|
deliverRequestMainMapper.insert(createobj); |
|
|
|
deliverRequestDetailMapper.insertBatch(subDOList); |
|
|
|
} else if (existDeliverRequestMainDO != null && mode != 2) { |
|
|
|
deliverRequestMainMapper.updateById(createobj); |
|
|
|
deliverRequestDetailMapper.updateBatch(subDOList); |
|
|
|
//写入数据
|
|
|
|
if (flag) { |
|
|
|
String number = serialNumberApi.generateCode(RuleCodeEnum.PURCHASE_RECEIPT_REQUEST.getCode()); |
|
|
|
mainDo.setNumber(number); |
|
|
|
mainDo.setStatus(DictFrameworkUtils.parseDictDataValue(DictTypeConstants.REQUEST_STATUS, "新增")); |
|
|
|
deliverRequestMainMapper.insert(mainDo); |
|
|
|
for (DeliverRequestDetailDO detailDO : subDOList) { |
|
|
|
detailDO.setMasterId(mainDo.getId()); |
|
|
|
detailDO.setNumber(number); |
|
|
|
} |
|
|
|
deliverRequestDetailMapper.insertBatch(subDOList); |
|
|
|
} |
|
|
|
}); |
|
|
|
if (!errorList.isEmpty() && !updatePart) { |
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
|
|
|
} |
|
|
|
return errorList; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|