|
|
@ -2,6 +2,7 @@ package com.win.module.wms.service.issueRequest; |
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import cn.hutool.core.exceptions.UtilException; |
|
|
|
import cn.hutool.json.JSONArray; |
|
|
|
import cn.hutool.json.JSONObject; |
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
import com.win.framework.common.pojo.CustomConditions; |
|
|
@ -9,13 +10,27 @@ import com.win.framework.common.util.validation.ValidationUtils; |
|
|
|
import com.win.framework.dict.core.util.DictFrameworkUtils; |
|
|
|
import com.win.module.system.api.serialnumber.SerialNumberApi; |
|
|
|
import com.win.module.system.enums.serialNumber.RuleCodeEnum; |
|
|
|
import com.win.module.wms.controller.inspectRequest.vo.InspectRequestImportErrorVO; |
|
|
|
import com.win.module.wms.controller.inspectRequest.vo.InspectRequestMainCreateReqVO; |
|
|
|
import com.win.module.wms.controller.issueRequest.vo.*; |
|
|
|
import com.win.module.wms.controller.purchaseclaimRequest.vo.PurchaseclaimRequestDetailCreateReqVO; |
|
|
|
import com.win.module.wms.controller.purchasereceiptRequest.vo.PurchasereceiptRequestDetailCreateReqVO; |
|
|
|
import com.win.module.wms.controller.purchasereceiptRequest.vo.PurchasereceiptRequestMainImportErrorVO; |
|
|
|
import com.win.module.wms.controller.rule.vo.RuleRespVO; |
|
|
|
import com.win.module.wms.convert.issueRequest.IssueRequestDetailConvert; |
|
|
|
import com.win.module.wms.convert.purchaseclaimRequest.PurchaseclaimRequestDetailConvert; |
|
|
|
import com.win.module.wms.convert.purchaseclaimRequest.PurchaseclaimRequestMainConvert; |
|
|
|
import com.win.module.wms.convert.purchasereceiptRequest.PurchasereceiptRequestDetailConvert; |
|
|
|
import com.win.module.wms.convert.purchasereceiptRequest.PurchasereceiptRequestMainConvert; |
|
|
|
import com.win.module.wms.dal.dataobject.businesstype.BusinesstypeDO; |
|
|
|
import com.win.module.wms.dal.dataobject.inspectRequest.InspectRequestDetailDO; |
|
|
|
import com.win.module.wms.dal.dataobject.issueRequest.IssueRequestDetailDO; |
|
|
|
import com.win.module.wms.dal.dataobject.itembasic.ItembasicDO; |
|
|
|
import com.win.module.wms.dal.dataobject.productionline.ProductionlineDO; |
|
|
|
import com.win.module.wms.dal.dataobject.purchaseclaimRequest.PurchaseclaimRequestDetailDO; |
|
|
|
import com.win.module.wms.dal.dataobject.purchaseclaimRequest.PurchaseclaimRequestMainDO; |
|
|
|
import com.win.module.wms.dal.dataobject.purchasereceiptRequest.PurchasereceiptRequestDetailDO; |
|
|
|
import com.win.module.wms.dal.dataobject.purchasereceiptRequest.PurchasereceiptRequestMainDO; |
|
|
|
import com.win.module.wms.dal.dataobject.requestsetting.RequestsettingDO; |
|
|
|
import com.win.module.wms.dal.dataobject.workstation.WorkstationDO; |
|
|
|
import com.win.module.wms.dal.mysql.issueRequest.IssueRequestDetailMapper; |
|
|
@ -34,7 +49,6 @@ import javax.annotation.Resource; |
|
|
|
import javax.validation.Validator; |
|
|
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport; |
|
|
|
import org.springframework.validation.annotation.Validated; |
|
|
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
@ -111,12 +125,16 @@ public class IssueRequestMainServiceImpl implements IssueRequestMainService { |
|
|
|
|
|
|
|
private void validateIssueRequestMainExists(Long id) { |
|
|
|
if (issueRequestMainMapper.selectById(id) == null) { |
|
|
|
return; |
|
|
|
} else { |
|
|
|
throw exception(ISSUE_REQUEST_MAIN_NOT_EXISTS); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void validateIssueRequestDetailExists(Long id) { |
|
|
|
if (issueRequestDetailMapper.selectById(id) == null) { |
|
|
|
throw exception(ISSUE_REQUEST_DETAIL_NOT_EXISTS); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public IssueRequestMainDO getIssueRequestMain(Long id) { |
|
|
|
return issueRequestMainMapper.selectById(id); |
|
|
@ -165,142 +183,264 @@ public class IssueRequestMainServiceImpl implements IssueRequestMainService { |
|
|
|
@Transactional |
|
|
|
public List<IssueRequestImportErrorVO> importIssueRequestList(List<IssueRequestMainCreateReqVO> datas, Integer mode, boolean updatePart) { |
|
|
|
if (CollUtil.isEmpty(datas)) { |
|
|
|
throw exception(PREPARETOISSUE_REQUEST_IMPORT_LIST_IS_EMPTY); |
|
|
|
throw exception(PURCHASECLAIM_REQUEST_IMPORT_LIST_IS_EMPTY); |
|
|
|
} |
|
|
|
List<IssueRequestImportErrorVO> errorList = new ArrayList<>(); |
|
|
|
datas.forEach(createReqVO -> { |
|
|
|
String messageMain = ""; |
|
|
|
BusinesstypeDO businesstypeDO = null; |
|
|
|
//主表校验方法
|
|
|
|
try { |
|
|
|
validateIssueRequestMainExists(null); |
|
|
|
} catch (Exception ex) { |
|
|
|
messageMain += ex.getMessage() + ","; |
|
|
|
BusinesstypeDO businesstypeDO = new BusinesstypeDO(); |
|
|
|
IssueRequestMainDO mainDo = IssueRequestMainConvert.INSTANCE.convert(createReqVO); |
|
|
|
String messageMain = validateIssueRequestMainImport(mainDo, businesstypeDO); |
|
|
|
List<IssueRequestDetailCreateReqVO> subList = createReqVO.getSubList(); |
|
|
|
List<IssueRequestDetailDO> subDOList = IssueRequestDetailConvert.INSTANCE.convertList03(subList); |
|
|
|
// 是否有错误数据
|
|
|
|
boolean flag = true; |
|
|
|
for (IssueRequestDetailDO detailDO : subDOList) { |
|
|
|
String messageDetail = validateIssueRequestDetailImport(detailDO, mainDo, businesstypeDO); |
|
|
|
if (!messageMain.isEmpty() || messageDetail.isEmpty()) { |
|
|
|
IssueRequestImportErrorVO importErrorVO = IssueRequestMainConvert.INSTANCE.convert(createReqVO, detailDO); |
|
|
|
importErrorVO.setImportStatus("失败"); |
|
|
|
messageMain = messageMain + messageDetail; |
|
|
|
importErrorVO.setImportRemark(messageMain.substring(0, messageMain.length() - 1)); |
|
|
|
errorList.add(importErrorVO); |
|
|
|
flag = false; |
|
|
|
} |
|
|
|
} |
|
|
|
try { |
|
|
|
workshopService.selectWorkshopExist(createReqVO.getWorkshopCode()); |
|
|
|
} catch (Exception ex) { |
|
|
|
messageMain += ex.getMessage() + ","; |
|
|
|
//写入数据
|
|
|
|
if (flag) { |
|
|
|
String number = serialNumberApi.generateCode(RuleCodeEnum.PURCHASE_RECEIPT_REQUEST.getCode()); |
|
|
|
mainDo.setNumber(number); |
|
|
|
mainDo.setStatus(DictFrameworkUtils.parseDictDataValue(DictTypeConstants.REQUEST_STATUS, "新增")); |
|
|
|
issueRequestMainMapper.insert(mainDo); |
|
|
|
for (IssueRequestDetailDO detailDO : subDOList) { |
|
|
|
detailDO.setMasterId(mainDo.getId()); |
|
|
|
detailDO.setNumber(number); |
|
|
|
} |
|
|
|
issueRequestDetailMapper.insertBatch(subDOList); |
|
|
|
} |
|
|
|
}); |
|
|
|
return errorList; |
|
|
|
} |
|
|
|
|
|
|
|
private void validatorWorkshop(String workshopCode) { |
|
|
|
workshopService.selectWorkshopExist(workshopCode); |
|
|
|
} |
|
|
|
|
|
|
|
private ItembasicDO validatorItembasic(String itemCode) { |
|
|
|
return itembasicService.selectItembasic(itemCode); |
|
|
|
} |
|
|
|
|
|
|
|
//接口调用后throw的错误需要进行修改形式 code需要统一一下
|
|
|
|
private void validatorIfInType(String itemType, BusinesstypeDO businesstypeDO) { |
|
|
|
jobUtils.ifInType(itemType, businesstypeDO); |
|
|
|
} |
|
|
|
|
|
|
|
private ProductionlineDO validatorProductionLineCode(String productionLineCode) { |
|
|
|
return productionlineService.productionLineCodeExist(productionLineCode); |
|
|
|
} |
|
|
|
|
|
|
|
private WorkstationDO validatorWorkstation(String workStationCode, String workshopCode, String productionLineCode) { |
|
|
|
return workstationService.selectWorkstationExist(workStationCode, workshopCode, productionLineCode); |
|
|
|
} |
|
|
|
|
|
|
|
private void validatorProductionLineCodeAndpItemCodeExist(String productionLineCode, String itemCode) { |
|
|
|
productionlineitemService.productionLineCodeAndpItemCodeExist(productionLineCode, itemCode); |
|
|
|
} |
|
|
|
|
|
|
|
//新增校验
|
|
|
|
private void validatorToCreate(IssueRequestMainCreateReqVO createReqVO) { |
|
|
|
IssueRequestMainDO issueRequestMainDO = IssueRequestMainConvert.INSTANCE.convert(createReqVO); |
|
|
|
//主表校验
|
|
|
|
this.validatorWorkshop(issueRequestMainDO.getWorkshopCode()); |
|
|
|
issueRequestMainDO.setStatus(DictFrameworkUtils.parseDictDataValue(DictTypeConstants.REQUEST_STATUS, "新增")); |
|
|
|
issueRequestMainDO.setRequestTime(LocalDateTime.now()); |
|
|
|
RequestsettingDO requestsettingDO = requestsettingService.selectRequestsettingExist("IssueRequest"); |
|
|
|
issueRequestMainDO.setAutoAgree(requestsettingDO.getAutoAgree()); |
|
|
|
issueRequestMainDO.setAutoCommit(requestsettingDO.getAutoCommit()); |
|
|
|
issueRequestMainDO.setAutoExecute(requestsettingDO.getAutoExecute()); |
|
|
|
issueRequestMainDO.setDirectCreateRecord(requestsettingDO.getDirectCreateRecord()); |
|
|
|
BusinesstypeDO businesstypeDO = jobUtils.selectDocumentSettingFromBusinessType("IssueRequest"); |
|
|
|
issueRequestMainDO.setBusinessType(businesstypeDO.getCode()); |
|
|
|
issueRequestMainDO.setFromLocationTypes(businesstypeDO.getOutLocationTypes()); |
|
|
|
issueRequestMainDO.setToLocationTypes(businesstypeDO.getInLocationTypes()); |
|
|
|
issueRequestMainDO.setFromAreaCodes(businesstypeDO.getOutAreaCodes()); |
|
|
|
issueRequestMainDO.setToAreaCodes(businesstypeDO.getInAreaCodes()); |
|
|
|
String number = serialNumberApi.generateCode(RuleCodeEnum.PURCHASE_CLAIM_RECORD.getCode()); |
|
|
|
issueRequestMainDO.setNumber(number); |
|
|
|
issueRequestMainMapper.insert(issueRequestMainDO); |
|
|
|
//子表校验
|
|
|
|
List<IssueRequestDetailCreateReqVO> subList = createReqVO.getSubList(); |
|
|
|
List<IssueRequestDetailDO> subDOList = IssueRequestDetailConvert.INSTANCE.convertList03(subList); |
|
|
|
for (IssueRequestDetailDO issueRequestDetailDO : subDOList) { |
|
|
|
ItembasicDO itembasicDO = validatorItembasic(issueRequestDetailDO.getItemCode()); |
|
|
|
this.validatorIfInType(itembasicDO.getType(), businesstypeDO); |
|
|
|
this.ifUomSuccess(itembasicDO.getUom(), issueRequestDetailDO.getUom()); |
|
|
|
ProductionlineDO productionlineDO = validatorProductionLineCode(issueRequestDetailDO.getProductionLineCode()); |
|
|
|
issueRequestDetailDO.setToLocationCode(productionlineDO.getRawLocationCode()); |
|
|
|
WorkstationDO workstationDO = validatorWorkstation(issueRequestDetailDO.getWorkStationCode(), issueRequestMainDO.getWorkshopCode(), issueRequestDetailDO.getProductionLineCode()); |
|
|
|
issueRequestDetailDO.setToLocationCode(workstationDO.getRawLocationCode()); |
|
|
|
this.validatorProductionLineCodeAndpItemCodeExist(issueRequestDetailDO.getProductionLineCode(), issueRequestDetailDO.getItemCode()); |
|
|
|
RuleRespVO grounding = ruleService.grounding(null, null, null, null, null, null, issueRequestDetailDO.getItemCode(), null, null, null, null, null, null); |
|
|
|
if (grounding == null) { |
|
|
|
throw exception(555, "未查找到该条上架策略"); |
|
|
|
} else { |
|
|
|
JSONObject json = JSONUtil.parseObj(grounding); |
|
|
|
String locationCode = json.get("LocationCode").toString(); |
|
|
|
this.ifLocationCodeInRule(issueRequestDetailDO.getItemCode(), issueRequestDetailDO.getToLocationCode(), locationCode); |
|
|
|
} |
|
|
|
issueRequestDetailDO.setMasterId(issueRequestMainDO.getId()); |
|
|
|
issueRequestDetailDO.setNumber(number); |
|
|
|
issueRequestDetailMapper.insertBatch(subDOList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//修改校验
|
|
|
|
private void validatorToUpdate(IssueRequestMainUpdateReqVO updateReqVO) { |
|
|
|
IssueRequestMainDO issueRequestMainDO = IssueRequestMainConvert.INSTANCE.convert(updateReqVO); |
|
|
|
//主表校验
|
|
|
|
validateIssueRequestMainExists(updateReqVO.getId()); |
|
|
|
this.validatorWorkshop(issueRequestMainDO.getWorkshopCode()); |
|
|
|
issueRequestMainDO.setStatus(DictFrameworkUtils.parseDictDataValue(DictTypeConstants.REQUEST_STATUS, "新增")); |
|
|
|
issueRequestMainDO.setRequestTime(LocalDateTime.now()); |
|
|
|
RequestsettingDO requestsettingDO = requestsettingService.selectRequestsettingExist("IssueRequest"); |
|
|
|
issueRequestMainDO.setAutoAgree(requestsettingDO.getAutoAgree()); |
|
|
|
issueRequestMainDO.setAutoCommit(requestsettingDO.getAutoCommit()); |
|
|
|
issueRequestMainDO.setAutoExecute(requestsettingDO.getAutoExecute()); |
|
|
|
issueRequestMainDO.setDirectCreateRecord(requestsettingDO.getDirectCreateRecord()); |
|
|
|
BusinesstypeDO businesstypeDO = jobUtils.selectDocumentSettingFromBusinessType("IssueRequest"); |
|
|
|
issueRequestMainDO.setBusinessType(businesstypeDO.getCode()); |
|
|
|
issueRequestMainDO.setFromLocationTypes(businesstypeDO.getOutLocationTypes()); |
|
|
|
issueRequestMainDO.setToLocationTypes(businesstypeDO.getInLocationTypes()); |
|
|
|
issueRequestMainDO.setFromAreaCodes(businesstypeDO.getOutAreaCodes()); |
|
|
|
issueRequestMainDO.setToAreaCodes(businesstypeDO.getInAreaCodes()); |
|
|
|
String number = serialNumberApi.generateCode(RuleCodeEnum.PURCHASE_CLAIM_RECORD.getCode()); |
|
|
|
issueRequestMainDO.setNumber(number); |
|
|
|
issueRequestMainMapper.insert(issueRequestMainDO); |
|
|
|
//子表校验
|
|
|
|
List<IssueRequestDetailCreateReqVO> subList = updateReqVO.getSubList(); |
|
|
|
List<IssueRequestDetailDO> subDOList = IssueRequestDetailConvert.INSTANCE.convertList03(subList); |
|
|
|
for (IssueRequestDetailDO issueRequestDetailDO : subDOList) { |
|
|
|
validateIssueRequestDetailExists(issueRequestDetailDO.getId()); |
|
|
|
ItembasicDO itembasicDO = validatorItembasic(issueRequestDetailDO.getItemCode()); |
|
|
|
this.validatorIfInType(itembasicDO.getType(), businesstypeDO); |
|
|
|
this.ifUomSuccess(itembasicDO.getUom(), issueRequestDetailDO.getUom()); |
|
|
|
ProductionlineDO productionlineDO = validatorProductionLineCode(issueRequestDetailDO.getProductionLineCode()); |
|
|
|
issueRequestDetailDO.setToLocationCode(productionlineDO.getRawLocationCode()); |
|
|
|
WorkstationDO workstationDO = validatorWorkstation(issueRequestDetailDO.getWorkStationCode(), issueRequestMainDO.getWorkshopCode(), issueRequestDetailDO.getProductionLineCode()); |
|
|
|
issueRequestDetailDO.setToLocationCode(workstationDO.getRawLocationCode()); |
|
|
|
this.validatorProductionLineCodeAndpItemCodeExist(issueRequestDetailDO.getProductionLineCode(), issueRequestDetailDO.getItemCode()); |
|
|
|
RuleRespVO grounding = ruleService.grounding(null, null, null, null, null, null, issueRequestDetailDO.getItemCode(), null, null, null, null, null, null); |
|
|
|
if (grounding == null) { |
|
|
|
throw exception(555, "未查找到该条上架策略"); |
|
|
|
} else { |
|
|
|
JSONObject json = JSONUtil.parseObj(grounding); |
|
|
|
String locationCode = json.get("LocationCode").toString(); |
|
|
|
this.ifLocationCodeInRule(issueRequestDetailDO.getItemCode(), issueRequestDetailDO.getToLocationCode(), locationCode); |
|
|
|
} |
|
|
|
createReqVO.setStatus(DictFrameworkUtils.parseDictDataValue(DictTypeConstants.REQUEST_STATUS, "新增")); |
|
|
|
createReqVO.setRequestTime(LocalDateTime.now()); |
|
|
|
issueRequestDetailDO.setMasterId(issueRequestMainDO.getId()); |
|
|
|
issueRequestDetailDO.setNumber(number); |
|
|
|
issueRequestDetailMapper.insertBatch(subDOList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 校验导入,并赋值一些参数 |
|
|
|
* |
|
|
|
* @param mainDo |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private String validateIssueRequestMainImport(IssueRequestMainDO mainDo, BusinesstypeDO businesstypeDO) { |
|
|
|
StringBuilder message = new StringBuilder(); |
|
|
|
try { |
|
|
|
this.validatorWorkshop(mainDo.getWorkshopCode()); |
|
|
|
} catch (Exception ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
mainDo.setStatus(DictFrameworkUtils.parseDictDataValue(DictTypeConstants.REQUEST_STATUS, "新增")); |
|
|
|
mainDo.setRequestTime(LocalDateTime.now()); |
|
|
|
RequestsettingDO requestsettingDO = requestsettingService.selectRequestsettingExist("IssueRequest"); |
|
|
|
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("IssueRequest"); |
|
|
|
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()); |
|
|
|
} |
|
|
|
try { |
|
|
|
ValidationUtils.validate(validator, mainDo); |
|
|
|
} catch (Exception ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
return message.toString(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 校验导入,并赋值一些参数 |
|
|
|
* |
|
|
|
* @param detailDo |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private String validateIssueRequestDetailImport(IssueRequestDetailDO detailDo, IssueRequestMainDO mainDo, BusinesstypeDO businesstypeDO) { |
|
|
|
StringBuilder message = new StringBuilder(); |
|
|
|
try { |
|
|
|
ItembasicDO itembasicDO = this.validatorItembasic(detailDo.getItemCode()); |
|
|
|
try { |
|
|
|
RequestsettingDO requestsettingDO = requestsettingService.selectRequestsettingExist("IssueRequest"); |
|
|
|
if (requestsettingDO != null) { |
|
|
|
createReqVO.setAutoAgree(requestsettingDO.getAutoAgree()); |
|
|
|
createReqVO.setAutoCommit(requestsettingDO.getAutoCommit()); |
|
|
|
createReqVO.setAutoExecute(requestsettingDO.getAutoExecute()); |
|
|
|
createReqVO.setDirectCreateRecord(requestsettingDO.getDirectCreateRecord()); |
|
|
|
} |
|
|
|
this.validatorIfInType(itembasicDO.getType(), businesstypeDO); |
|
|
|
} catch (Exception ex) { |
|
|
|
messageMain += ex.getMessage() + ","; |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
businesstypeDO = jobUtils.selectDocumentSettingFromBusinessType("IssueRequest"); |
|
|
|
createReqVO.setBusinessType(businesstypeDO.getCode()); |
|
|
|
createReqVO.setFromLocationTypes(businesstypeDO.getOutLocationTypes()); |
|
|
|
createReqVO.setToLocationTypes(businesstypeDO.getInLocationTypes()); |
|
|
|
createReqVO.setFromAreaCodes(businesstypeDO.getOutAreaCodes()); |
|
|
|
createReqVO.setToAreaCodes(businesstypeDO.getInAreaCodes()); |
|
|
|
this.ifUomSuccess(itembasicDO.getUom(), detailDo.getUom()); |
|
|
|
} catch (Exception ex) { |
|
|
|
messageMain += ex.getMessage() + ","; |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
} catch (Exception ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
ProductionlineDO productionlineDO = validatorProductionLineCode(detailDo.getProductionLineCode()); |
|
|
|
detailDo.setToLocationCode(productionlineDO.getRawLocationCode()); |
|
|
|
} catch (Exception ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
WorkstationDO workstationDO = validatorWorkstation(detailDo.getWorkStationCode(), mainDo.getWorkshopCode(), detailDo.getProductionLineCode()); |
|
|
|
detailDo.setToLocationCode(workstationDO.getRawLocationCode()); |
|
|
|
} catch (Exception ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
this.validatorProductionLineCodeAndpItemCodeExist(detailDo.getProductionLineCode(), detailDo.getItemCode()); |
|
|
|
} catch (Exception ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
RuleRespVO grounding = ruleService.grounding(null, null, null, null, null, null, detailDo.getItemCode(), null, null, null, null, null, null); |
|
|
|
if (grounding == null) { |
|
|
|
message.append("未查找到该条上架策略"); |
|
|
|
} else { |
|
|
|
JSONObject json = JSONUtil.parseObj(grounding); |
|
|
|
String locationCode = json.get("LocationCode").toString(); |
|
|
|
try { |
|
|
|
ValidationUtils.validate(validator, createReqVO); |
|
|
|
this.ifLocationCodeInRule(detailDo.getItemCode(), detailDo.getToLocationCode(), locationCode); |
|
|
|
} catch (Exception ex) { |
|
|
|
messageMain += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
String number = serialNumberApi.generateCode(RuleCodeEnum.PURCHASE_RETURN_REQUEST.getCode()); |
|
|
|
createReqVO.setNumber(number); |
|
|
|
List<IssueRequestDetailCreateReqVO> subList = createReqVO.getSubList(); |
|
|
|
List<IssueRequestDetailDO> subDOList = IssueRequestDetailConvert.INSTANCE.convertList03(subList); |
|
|
|
for (IssueRequestDetailDO detailDO : subDOList) { |
|
|
|
String messageDetail = ""; |
|
|
|
// 校验,判断是否有不符合的原因,并加入errorList,同主表,只把有错误的子表加入errorList
|
|
|
|
//子表校验方法
|
|
|
|
try { |
|
|
|
ItembasicDO itembasicDO = itembasicService.selectItembasic(detailDO.getItemCode()); |
|
|
|
detailDO.setItemDesc1(itembasicDO.getDesc1()); |
|
|
|
detailDO.setItemDesc2(itembasicDO.getDesc2()); |
|
|
|
detailDO.setItemName(itembasicDO.getName()); |
|
|
|
detailDO.setProjectCode(itembasicDO.getProject()); |
|
|
|
try { |
|
|
|
jobUtils.ifInType(itembasicDO.getType(), businesstypeDO); |
|
|
|
} catch (Exception ex) { |
|
|
|
messageMain += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
try { |
|
|
|
ifUomSuccess(itembasicDO.getUom(), detailDO.getUom()); |
|
|
|
} catch (Exception ex) { |
|
|
|
messageDetail += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
} catch (Exception ex) { |
|
|
|
messageDetail += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
try { |
|
|
|
ProductionlineDO productionlineDO = productionlineService.productionLineCodeExist(detailDO.getProductionLineCode()); |
|
|
|
detailDO.setToLocationCode(productionlineDO.getRawLocationCode()); |
|
|
|
} catch (Exception ex) { |
|
|
|
messageMain += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
try { |
|
|
|
if (detailDO.getWorkStationCode() != "") { |
|
|
|
WorkstationDO workstationDO = workstationService.selectWorkstationExist(detailDO.getWorkStationCode(), createReqVO.getWorkshopCode(), detailDO.getProductionLineCode()); |
|
|
|
detailDO.setToLocationCode(workstationDO.getRawLocationCode()); |
|
|
|
} |
|
|
|
} catch (Exception ex) { |
|
|
|
messageMain += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
try { |
|
|
|
productionlineitemService.productionLineCodeAndpItemCodeExist(detailDO.getProductionLineCode(), detailDO.getItemCode()); |
|
|
|
} catch (Exception ex) { |
|
|
|
messageMain += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
try { |
|
|
|
RuleRespVO grounding = ruleService.grounding(null, null, null, null, null, null, detailDO.getItemCode(), null, null, null, null, null, null); |
|
|
|
JSONObject json = JSONUtil.parseObj(grounding); |
|
|
|
String locationCode = json.get("LocationCode").toString(); |
|
|
|
try { |
|
|
|
ifLocationCodeInRule(detailDO.getItemCode(), detailDO.getToLocationCode(), locationCode); |
|
|
|
} catch (Exception ex) { |
|
|
|
messageDetail += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
} catch (Exception ex) { |
|
|
|
messageDetail += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
try { |
|
|
|
ValidationUtils.validate(validator, createReqVO); |
|
|
|
} catch (Exception ex) { |
|
|
|
messageMain += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
IssueRequestDetailCreateReqVO purchaseturnRequestDetailCreateReqVO = IssueRequestDetailConvert.INSTANCE.convert1(detailDO); |
|
|
|
IssueRequestImportErrorVO importVO = IssueRequestDetailConvert.INSTANCE.convert(createReqVO, purchaseturnRequestDetailCreateReqVO); |
|
|
|
if (!messageMain.equals("") || !messageDetail.equals("")) { |
|
|
|
importVO.setImportStatus("失败"); |
|
|
|
messageMain = messageMain + messageDetail; |
|
|
|
importVO.setImportRemark(messageMain.substring(0, messageMain.length() - 1)); |
|
|
|
errorList.add(importVO); |
|
|
|
} else { |
|
|
|
detailDO.setNumber(createReqVO.getNumber()); |
|
|
|
detailDO.setMasterId(createReqVO.getId()); |
|
|
|
} |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
IssueRequestMainDO createobj = IssueRequestMainConvert.INSTANCE.convert(createReqVO); |
|
|
|
if (errorList.isEmpty()) { |
|
|
|
IssueRequestMainDO existIssueRequestMainDO = issueRequestMainMapper.selectWorkShopCodeAndUseOnTheWayLocation(createReqVO.getWorkshopCode(), createobj.getUseOnTheWayLocation()); |
|
|
|
if (existIssueRequestMainDO == null && mode != 3) { |
|
|
|
issueRequestMainMapper.insert(createobj); |
|
|
|
issueRequestDetailMapper.insertBatch(subDOList); |
|
|
|
} else if (existIssueRequestMainDO != null && mode != 2) { |
|
|
|
issueRequestMainMapper.updateById(createobj); |
|
|
|
issueRequestDetailMapper.updateBatch(subDOList); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
//错误不为空并非部分更新,手工回滚
|
|
|
|
if (!errorList.isEmpty() && !updatePart) { |
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
|
|
|
} |
|
|
|
return errorList; |
|
|
|
try { |
|
|
|
ValidationUtils.validate(validator, detailDo); |
|
|
|
} catch (Exception ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
return message.toString(); |
|
|
|
} |
|
|
|
} |
|
|
|