|
|
@ -39,17 +39,19 @@ import com.win.module.wms.util.JobUtils; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport; |
|
|
|
import javax.validation.Validator; |
|
|
|
import org.springframework.validation.annotation.Validated; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.validation.Validator; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Collection; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; |
|
|
|
import static com.win.module.wms.enums.ErrorCodeConstants.*; |
|
|
|
import static com.win.module.wms.enums.ErrorCodeConstants.INSPECT_REQUEST_IMPORT_LIST_IS_EMPTY; |
|
|
|
import static com.win.module.wms.enums.ErrorCodeConstants.INSPECT_REQUEST_MAIN_NOT_EXISTS; |
|
|
|
|
|
|
|
/** |
|
|
|
* 检验申请主 Service 实现类 |
|
|
@ -84,13 +86,17 @@ public class InspectRequestMainServiceImpl implements InspectRequestMainService |
|
|
|
private RequestsettingService requestsettingService; |
|
|
|
@Resource |
|
|
|
private TrendsApi trendsApi; |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public Long createInspectRequestMain(InspectRequestMainCreateReqVO createReqVO) { |
|
|
|
RequestsettingDO requestsettingDO = requestsettingService.selectRequestsettingExist("InspectRequest"); |
|
|
|
BusinesstypeDO businesstypeDO = jobUtils.selectDocumentSettingFromBusinessType("InspectRequest"); |
|
|
|
InspectRequestMainDO inspectRequestMainDO = validatorToCreate(createReqVO, businesstypeDO); |
|
|
|
InspectRequestMainDO inspectRequestMainDO = this.validatorCreate(createReqVO, businesstypeDO, requestsettingDO); |
|
|
|
String number = serialNumberApi.generateCode(RuleCodeEnum.INSPECT_REQUEST.getCode()); |
|
|
|
inspectRequestMainDO.setNumber(number); |
|
|
|
//调用自动执行方法
|
|
|
|
if(RequestStatusEnum.HANDLING.getCode().equals(inspectRequestMainDO.getStatus())) { |
|
|
|
if (RequestStatusEnum.HANDLING.getCode().equals(inspectRequestMainDO.getStatus())) { |
|
|
|
|
|
|
|
} |
|
|
|
trendsApi.createTrends(requestsettingDO.getId(), "InspectRequest", "增加了到货校验申请", TrendsTypeEnum.CREATE); |
|
|
@ -98,20 +104,22 @@ public class InspectRequestMainServiceImpl implements InspectRequestMainService |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public void updateInspectRequestMain(InspectRequestMainUpdateReqVO updateReqVO) { |
|
|
|
RequestsettingDO requestsettingDO = requestsettingDO = requestsettingService.selectRequestsettingExist("InspectRequest"); |
|
|
|
RequestsettingDO requestsettingDO = requestsettingService.selectRequestsettingExist("InspectRequest"); |
|
|
|
BusinesstypeDO businesstypeDO = jobUtils.selectDocumentSettingFromBusinessType("InspectRequest"); |
|
|
|
// 校验存在
|
|
|
|
validateInspectRequestMainExists(updateReqVO.getId()); |
|
|
|
// 更新主表
|
|
|
|
InspectRequestMainDO inspectRequestMainDO = validatorToUpdate(updateReqVO, businesstypeDO); |
|
|
|
if(RequestStatusEnum.HANDLING.getCode().equals(inspectRequestMainDO.getStatus())) { |
|
|
|
InspectRequestMainDO inspectRequestMainDO = validatorUpdate(updateReqVO, businesstypeDO, requestsettingDO); |
|
|
|
if (RequestStatusEnum.HANDLING.getCode().equals(inspectRequestMainDO.getStatus())) { |
|
|
|
|
|
|
|
} |
|
|
|
trendsApi.createTrends(requestsettingDO.getId(), "InspectRequest", "增加了到货校验申请", TrendsTypeEnum.CREATE); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public void deleteInspectRequestMain(Long id) { |
|
|
|
// 校验存在
|
|
|
|
validateInspectRequestMainExists(id); |
|
|
@ -139,196 +147,200 @@ public class InspectRequestMainServiceImpl implements InspectRequestMainService |
|
|
|
public PageResult<InspectRequestMainDO> getInspectRequestMainPage(InspectRequestMainPageReqVO pageReqVO) { |
|
|
|
return inspectRequestMainMapper.selectPage(pageReqVO); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageResult<InspectRequestMainDO> getInspectRequestMainSenior(CustomConditions conditions) { |
|
|
|
return inspectRequestMainMapper.selectSenior(conditions); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<InspectRequestMainDO> getInspectRequestMainList(InspectRequestMainExportReqVO exportReqVO) { |
|
|
|
return inspectRequestMainMapper.selectList(exportReqVO); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public List<InspectRequestImportErrorVO> importInspectRequestList(List<InspectRequestMainCreateReqVO> datas, Integer mode, boolean updatePart) { |
|
|
|
if (CollUtil.isEmpty(datas)) { |
|
|
|
throw exception(INSPECT_REQUEST_IMPORT_LIST_IS_EMPTY); |
|
|
|
} |
|
|
|
List<InspectRequestImportErrorVO> errorList = new ArrayList<>(); |
|
|
|
datas.forEach(createReqVO -> { |
|
|
|
//主表校验方法
|
|
|
|
InspectRequestMainDO mainDO = InspectRequestMainConvert.INSTANCE.convert(createReqVO); |
|
|
|
BusinesstypeDO businesstypeDO = jobUtils.selectDocumentSettingFromBusinessType("InspectRequest"); |
|
|
|
String messageMain = this.validatorInspectRequestMainImport(mainDO, businesstypeDO); |
|
|
|
List<InspectRequestDetailCreateReqVO> subList = createReqVO.getSubList(); |
|
|
|
List<InspectRequestDetailDO> subDOList = InspectRequestDetailConvert.INSTANCE.convertList03(subList); |
|
|
|
for (InspectRequestDetailDO detailDO : subDOList) { |
|
|
|
String messageDetail = this.validatorInspectRequestDetailImport(detailDO, mainDO, businesstypeDO); |
|
|
|
InspectRequestDetailCreateReqVO inspectRequestDetailCreateReqVO = InspectRequestDetailConvert.INSTANCE.convert1(detailDO); |
|
|
|
InspectRequestImportErrorVO importVO = InspectRequestDetailConvert.INSTANCE.convert(createReqVO, inspectRequestDetailCreateReqVO); |
|
|
|
if (!messageMain.isEmpty() || !messageDetail.isEmpty()) { |
|
|
|
importVO.setImportStatus("失败"); |
|
|
|
messageMain = messageMain + messageDetail; |
|
|
|
importVO.setImportRemark(messageMain.substring(0, messageMain.length() - 1)); |
|
|
|
errorList.add(importVO); |
|
|
|
} |
|
|
|
} |
|
|
|
mainDO.setStatus(DictFrameworkUtils.parseDictDataValue(DictTypeConstants.REQUEST_STATUS, "新增")); |
|
|
|
if (errorList.isEmpty()) { |
|
|
|
InspectRequestMainDO existInspectRequestMainDO = inspectRequestMainMapper.selectPurchaseReceiptNumber(createReqVO.getPurchaseReceiptRecordNumber()); |
|
|
|
if (existInspectRequestMainDO == null && mode != 3) { |
|
|
|
String number = serialNumberApi.generateCode(RuleCodeEnum.INSPECT_REQUEST.getCode()); |
|
|
|
mainDO.setNumber(number); |
|
|
|
inspectRequestMainMapper.insert(mainDO); |
|
|
|
for(InspectRequestDetailDO inspectRequestDetailDO : subDOList) { |
|
|
|
inspectRequestDetailDO.setMasterId(mainDO.getId()); |
|
|
|
} |
|
|
|
inspectRequestDetailMapper.insertBatch(subDOList); |
|
|
|
} else if (existInspectRequestMainDO != null && mode != 2) { |
|
|
|
inspectRequestMainMapper.updateById(mainDO); |
|
|
|
inspectRequestDetailMapper.updateBatch(subDOList); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
//错误不为空并非部分更新,手工回滚
|
|
|
|
if (!errorList.isEmpty() && !updatePart) { |
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
|
|
|
} |
|
|
|
return errorList; |
|
|
|
} |
|
|
|
|
|
|
|
//判断导入单位是否正确
|
|
|
|
private void ifUomSuccess(String itemUom,String uom) { |
|
|
|
private void ifUomSuccess(String itemUom, String uom) { |
|
|
|
DictDataRespDTO dictDataRespDTO = dictDataApi.selectDictLabel(uom); |
|
|
|
if(dictDataRespDTO != null){ |
|
|
|
if(!itemUom.equals(dictDataRespDTO.getLabel())){ |
|
|
|
throw new UtilException("提示单位"+ uom + "错误,应该是" + itemUom); |
|
|
|
if (dictDataRespDTO != null) { |
|
|
|
if (!itemUom.equals(dictDataRespDTO.getLabel())) { |
|
|
|
throw new UtilException("提示单位" + uom + "错误,应该是" + itemUom); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//查询检验类型
|
|
|
|
private Integer selectInspectType(Integer sampleQty, HashMap<String, String> ruleAll) { |
|
|
|
@Override |
|
|
|
public BigDecimal selectInspectType(BigDecimal sampleQty, HashMap<String, String> ruleAll) { |
|
|
|
String inspectType = ruleAll.get("InspectType"); |
|
|
|
if("EXEMPT".equals(inspectType)){ |
|
|
|
return 0; |
|
|
|
} else if ("FULL".equals(inspectType)) { |
|
|
|
if ("FULL".equals(inspectType)) { |
|
|
|
return sampleQty; |
|
|
|
}else if("SAMPLING".equals(inspectType)){ |
|
|
|
} else if ("SAMPLING".equals(inspectType)) { |
|
|
|
return selectSampleMethod(ruleAll, sampleQty); |
|
|
|
}else { |
|
|
|
return 0; |
|
|
|
} else { |
|
|
|
return BigDecimal.ZERO; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//查询抽检方式 计算抽检数量并返回
|
|
|
|
private Integer selectSampleMethod(HashMap<String, String> ruleAll,Integer sampleQty) { |
|
|
|
private BigDecimal selectSampleMethod(HashMap<String, String> ruleAll, BigDecimal sampleQty) { |
|
|
|
String sampleMethod = ruleAll.get("SampleMethod"); |
|
|
|
JSONArray aplList = JSONUtil.parseArray(ruleAll.get("AplList")); |
|
|
|
//获取最大校验规则范围
|
|
|
|
Integer maxFloorQty = 0; |
|
|
|
Integer maxCeilingQty = 0; |
|
|
|
Integer maxSampleValue = 0; |
|
|
|
Integer result = 0; |
|
|
|
BigDecimal maxFloorQty = BigDecimal.ZERO; |
|
|
|
BigDecimal maxCeilingQty = BigDecimal.ZERO; |
|
|
|
BigDecimal maxSampleValue = BigDecimal.ZERO; |
|
|
|
BigDecimal result = BigDecimal.ZERO; |
|
|
|
for (Object o : aplList) { |
|
|
|
JSONObject parse = JSONUtil.parseObj(o); |
|
|
|
Integer floorQty = Integer.valueOf(parse.get("FloorQty").toString()); |
|
|
|
Integer ceilingQty = Integer.valueOf(parse.get("CeilingQty").toString()); |
|
|
|
Integer sampleValue = Integer.valueOf(parse.get("SampleValue").toString()); |
|
|
|
if (maxFloorQty < floorQty){ |
|
|
|
BigDecimal floorQty = new BigDecimal(String.valueOf(parse.get("FloorQty"))); |
|
|
|
BigDecimal ceilingQty = new BigDecimal(String.valueOf(parse.get("CeilingQty"))); |
|
|
|
BigDecimal sampleValue = new BigDecimal(String.valueOf(parse.get("SampleValue"))); |
|
|
|
if (maxFloorQty.compareTo(floorQty) < 0) { |
|
|
|
maxFloorQty = floorQty; |
|
|
|
} |
|
|
|
if (maxCeilingQty < ceilingQty){ |
|
|
|
if (maxCeilingQty.compareTo(ceilingQty) < 0) { |
|
|
|
maxCeilingQty = ceilingQty; |
|
|
|
} |
|
|
|
if (maxSampleValue < sampleValue){ |
|
|
|
if (maxSampleValue.compareTo(sampleValue) < 0) { |
|
|
|
maxSampleValue = sampleValue; |
|
|
|
} |
|
|
|
//根据校验规则计算出抽样数量
|
|
|
|
if(sampleQty != null && sampleQty != 0){ |
|
|
|
if(floorQty <= sampleQty && sampleQty <= ceilingQty){ |
|
|
|
if("QTY".equals(sampleMethod)){ |
|
|
|
if (sampleQty != null && sampleQty.compareTo(BigDecimal.ZERO) != 0) { |
|
|
|
if(floorQty.compareTo(sampleQty) <= 0 && sampleQty.compareTo(ceilingQty) <= 0) { |
|
|
|
if ("QTY".equals(sampleMethod)) { |
|
|
|
result = sampleValue; |
|
|
|
}else if ("PERCENT".equals(sampleMethod)) { |
|
|
|
double doubleSampleQty = sampleQty * (sampleValue * 0.01); |
|
|
|
result = (int) Math.round(doubleSampleQty); |
|
|
|
} else if ("PERCENT".equals(sampleMethod)) { |
|
|
|
result = sampleQty.multiply(sampleValue).multiply(new BigDecimal("0.01")); |
|
|
|
} |
|
|
|
} |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
throw new UtilException("当前到货数量为空,不能进行校验"); |
|
|
|
} |
|
|
|
} |
|
|
|
if (maxCeilingQty < sampleQty) { |
|
|
|
if (maxCeilingQty.compareTo(sampleQty) < 0) { |
|
|
|
throw new UtilException("当前到货数量已超出校验规则范围"); |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//获取策略里的参数进行字段对应
|
|
|
|
private HashMap<String, String> selectRule(String supplierCode,String itemCode){ |
|
|
|
RuleRespVO inspect = ruleService.inspect(supplierCode,itemCode ); |
|
|
|
if(inspect == null){ |
|
|
|
public HashMap<String, String> selectRule(String supplierCode, String itemCode) { |
|
|
|
RuleRespVO inspect = ruleService.inspect(supplierCode, itemCode); |
|
|
|
if (inspect == null) { |
|
|
|
throw new UtilException("未找到该策略"); |
|
|
|
} |
|
|
|
JSONArray configuration = JSONUtil.parseArray(inspect.getConfiguration()); |
|
|
|
HashMap<String, String> mapRule = new HashMap<>(); |
|
|
|
for (Object o : configuration) { |
|
|
|
JSONObject entries = JSONUtil.parseObj(o); |
|
|
|
mapRule.put(entries.get("ParamCode").toString(),entries.get("Value").toString()); |
|
|
|
mapRule.put(entries.get("ParamCode").toString(), entries.get("Value").toString()); |
|
|
|
} |
|
|
|
String aqlList = mapRule.get("AqlList"); |
|
|
|
if(aqlList !=null){ |
|
|
|
if (aqlList != null) { |
|
|
|
JSONArray objects = JSONUtil.parseArray(aqlList); |
|
|
|
for (int i = 0; i < objects.size(); i++) { |
|
|
|
JSONObject entries = JSONUtil.parseObj(objects.getObj(i)); |
|
|
|
mapRule.put("FloorQty" + (i+1),entries.get("FloorQty").toString()); |
|
|
|
mapRule.put("CeilingQty" + (i+1),entries.get("CeilingQty").toString()); |
|
|
|
mapRule.put("SampleValue" + (i+1),entries.get("SampleValue").toString()); |
|
|
|
mapRule.put("FloorQty" + (i + 1), entries.get("FloorQty").toString()); |
|
|
|
mapRule.put("CeilingQty" + (i + 1), entries.get("CeilingQty").toString()); |
|
|
|
mapRule.put("SampleValue" + (i + 1), entries.get("SampleValue").toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
return mapRule; |
|
|
|
} |
|
|
|
private PurchasereceiptRecordDetailDO validatorPurchasereceiptExist(String purchaseReceiptRecordNumber, String poNumber, String poLine, String itemCode){ |
|
|
|
|
|
|
|
private PurchasereceiptRecordDetailDO validatorPurchasereceiptExist(String purchaseReceiptRecordNumber, String poNumber, String poLine, String itemCode) { |
|
|
|
return purchasereceiptRecordMainService.selectPurchasereceiptExist(poNumber, null, purchaseReceiptRecordNumber, poLine, itemCode); |
|
|
|
} |
|
|
|
private void validatorRule(InspectRequestMainDO mainDO){ |
|
|
|
|
|
|
|
private void validatorRule(InspectRequestMainDO mainDO) { |
|
|
|
HashMap<String, String> rule = selectRule(null, mainDO.getItemCode()); |
|
|
|
selectInspectType(mainDO.getReceiveQty(),rule); |
|
|
|
mainDO.setSampleQty(selectInspectType(mainDO.getReceiveQty(), rule)); |
|
|
|
} |
|
|
|
private ItembasicDO validatorItembasic(String itemCode){ |
|
|
|
|
|
|
|
private ItembasicDO validatorItembasic(String itemCode) { |
|
|
|
return itembasicService.selectItembasic(itemCode); |
|
|
|
} |
|
|
|
private void validatorLocation(String fromLocationCode){ |
|
|
|
|
|
|
|
private void validatorLocation(String fromLocationCode) { |
|
|
|
locationService.selectLocation(fromLocationCode); |
|
|
|
} |
|
|
|
private void validatorIfInType(String itemType, BusinesstypeDO businesstypeDO){ |
|
|
|
|
|
|
|
private void validatorIfInType(String itemType, BusinesstypeDO businesstypeDO) { |
|
|
|
jobUtils.ifInType(itemType, businesstypeDO); |
|
|
|
} |
|
|
|
private void validatorIfOutInventoryStatuses(String inventoryStatus,BusinesstypeDO businesstypeDO){ |
|
|
|
|
|
|
|
private void validatorIfOutInventoryStatuses(String inventoryStatus, BusinesstypeDO businesstypeDO) { |
|
|
|
jobUtils.ifOutInventoryStatuses(inventoryStatus, businesstypeDO); |
|
|
|
} |
|
|
|
private void validatorIfInFromLocationType(String fromLocationCode,BusinesstypeDO businesstypeDO){ |
|
|
|
|
|
|
|
private void validatorIfInFromLocationType(String fromLocationCode, BusinesstypeDO businesstypeDO) { |
|
|
|
jobUtils.ifInFromLocationType(fromLocationCode, businesstypeDO); |
|
|
|
} |
|
|
|
private void validatorLlocationReturnManagementAccuracy(String itemCode,String packingNumber,String batch,String fromLocationCode,String inventoryStatu){ |
|
|
|
ArrayList inventoryStatus = new ArrayList(); |
|
|
|
|
|
|
|
private void validatorLocationReturnManagementAccuracy(String itemCode, String packingNumber, String batch, String fromLocationCode, String inventoryStatu) { |
|
|
|
ArrayList<String> inventoryStatus = new ArrayList<>(); |
|
|
|
inventoryStatus.add(inventoryStatu); |
|
|
|
jobUtils.selectlocationReturnManagementAccuracy(itemCode, packingNumber, batch, fromLocationCode, inventoryStatus); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public List<InspectRequestImportErrorVO> importInspectRequestList(List<InspectRequestMainCreateReqVO> datas, Integer mode, boolean updatePart) { |
|
|
|
if (CollUtil.isEmpty(datas)) { |
|
|
|
throw exception(INSPECT_REQUEST_IMPORT_LIST_IS_EMPTY); |
|
|
|
} |
|
|
|
List<InspectRequestImportErrorVO> errorList = new ArrayList<>(); |
|
|
|
datas.forEach(createReqVO -> { |
|
|
|
String messageMain = ""; |
|
|
|
//主表校验方法
|
|
|
|
List<InspectRequestDetailCreateReqVO> subList = createReqVO.getSubList(); |
|
|
|
List<InspectRequestDetailDO> subDOList = InspectRequestDetailConvert.INSTANCE.convertList03(subList); |
|
|
|
for (InspectRequestDetailDO detailDO : subDOList) { |
|
|
|
String messageDetail = ""; |
|
|
|
try { |
|
|
|
BusinesstypeDO businesstypeDO = jobUtils.selectDocumentSettingFromBusinessType("InspectRequest"); |
|
|
|
createReqVO.setBusinessType(businesstypeDO.getCode()); |
|
|
|
createReqVO.setFromLocationTypes(businesstypeDO.getOutLocationTypes()); |
|
|
|
createReqVO.setFromLocationTypes(businesstypeDO.getOutLocationTypes()); |
|
|
|
}catch (Exception ex) { |
|
|
|
messageDetail += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
|
|
|
|
InspectRequestDetailCreateReqVO inspectRequestDetailCreateReqVO = InspectRequestDetailConvert.INSTANCE.convert1(detailDO); |
|
|
|
InspectRequestImportErrorVO importVO = InspectRequestDetailConvert.INSTANCE.convert(createReqVO, inspectRequestDetailCreateReqVO); |
|
|
|
if(!messageMain.equals("") || !messageDetail.equals("")){ |
|
|
|
importVO.setImportStatus("失败"); |
|
|
|
messageMain = messageMain + messageDetail; |
|
|
|
importVO.setImportRemark(messageMain.substring(0,messageMain.length()-1)); |
|
|
|
errorList.add(importVO); |
|
|
|
}else { |
|
|
|
detailDO.setMasterId(createReqVO.getId()); |
|
|
|
} |
|
|
|
} |
|
|
|
createReqVO.setStatus(DictFrameworkUtils.parseDictDataValue(DictTypeConstants.REQUEST_STATUS, "新增")); |
|
|
|
|
|
|
|
InspectRequestMainDO createobj = InspectRequestMainConvert.INSTANCE.convert(createReqVO); |
|
|
|
if(errorList.isEmpty()){ |
|
|
|
InspectRequestMainDO existInspectRequestMainDO = inspectRequestMainMapper.selectPurchaseReceiptNumber(createReqVO.getPurchaseReceiptRecordNumber()); |
|
|
|
if(existInspectRequestMainDO == null && mode != 3){ |
|
|
|
inspectRequestMainMapper.insert(createobj); |
|
|
|
inspectRequestDetailMapper.insertBatch(subDOList); |
|
|
|
}else if(existInspectRequestMainDO != null && mode != 2){ |
|
|
|
inspectRequestMainMapper.updateById(createobj); |
|
|
|
inspectRequestDetailMapper.updateBatch(subDOList); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
//错误不为空并非部分更新,手工回滚
|
|
|
|
if(!errorList.isEmpty() && !updatePart) { |
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
|
|
|
} |
|
|
|
return errorList; |
|
|
|
} |
|
|
|
// 新增校验
|
|
|
|
private InspectRequestMainDO validatorToCreate(InspectRequestMainCreateReqVO createReqVO, BusinesstypeDO businesstypeDO) { |
|
|
|
InspectRequestMainDO mainDo = validatorMainMethod(createReqVO,businesstypeDO); |
|
|
|
private InspectRequestMainDO validatorCreate(InspectRequestMainCreateReqVO createReqVO, BusinesstypeDO businesstypeDO, RequestsettingDO requestsettingDO) { |
|
|
|
InspectRequestMainDO mainDo = validatorMainMethod(createReqVO, businesstypeDO, requestsettingDO); |
|
|
|
//子表校验
|
|
|
|
List<InspectRequestDetailCreateReqVO> subList = createReqVO.getSubList(); |
|
|
|
List<InspectRequestDetailDO> subDOList = InspectRequestDetailConvert.INSTANCE.convertList03(subList); |
|
|
|
for (InspectRequestDetailDO detailDO : subDOList) { |
|
|
|
validatorDetailMethod(detailDO,mainDo,businesstypeDO); |
|
|
|
validatorDetailMethod(detailDO, mainDo, businesstypeDO); |
|
|
|
} |
|
|
|
String number = serialNumberApi.generateCode(RuleCodeEnum.PURCHASE_CLAIM_RECORD.getCode()); |
|
|
|
mainDo.setNumber(number); |
|
|
@ -339,37 +351,37 @@ public class InspectRequestMainServiceImpl implements InspectRequestMainService |
|
|
|
} |
|
|
|
|
|
|
|
//修改校验
|
|
|
|
private InspectRequestMainDO validatorToUpdate(InspectRequestMainUpdateReqVO updateReqVO, BusinesstypeDO businesstypeDO) { |
|
|
|
InspectRequestMainDO mainDo = validatorMainMethod(updateReqVO,businesstypeDO); |
|
|
|
private InspectRequestMainDO validatorUpdate(InspectRequestMainUpdateReqVO updateReqVO, BusinesstypeDO businesstypeDO, RequestsettingDO requestsettingDO) { |
|
|
|
InspectRequestMainDO mainDo = validatorMainMethod(updateReqVO, businesstypeDO, requestsettingDO); |
|
|
|
//子表校验
|
|
|
|
List<InspectRequestDetailUpdateReqVO> subList = updateReqVO.getSubList(); |
|
|
|
List<InspectRequestDetailDO> subDOList = InspectRequestDetailConvert.INSTANCE.convertList05(subList); |
|
|
|
for (InspectRequestDetailDO detailDO : subDOList) { |
|
|
|
validatorDetailMethod(detailDO,mainDo,businesstypeDO); |
|
|
|
validatorDetailMethod(detailDO, mainDo, businesstypeDO); |
|
|
|
} |
|
|
|
inspectRequestMainMapper.updateById(mainDo); |
|
|
|
inspectRequestDetailMapper.updateBatch(subDOList); |
|
|
|
return mainDo; |
|
|
|
} |
|
|
|
|
|
|
|
//校验主表公共方法(适用于新增/修改)
|
|
|
|
private InspectRequestMainDO validatorMainMethod(InspectRequestMainBaseVO baseVO, BusinesstypeDO businesstypeDO){ |
|
|
|
private InspectRequestMainDO validatorMainMethod(InspectRequestMainBaseVO baseVO, BusinesstypeDO businesstypeDO, RequestsettingDO requestsettingDO) { |
|
|
|
InspectRequestMainDO mainDo = InspectRequestMainConvert.INSTANCE.convert(baseVO); |
|
|
|
PurchasereceiptRecordDetailDO purchasereceiptRecordDetailDO = validatorPurchasereceiptExist(mainDo.getPurchaseReceiptRecordNumber(), mainDo.getPoNumber(), mainDo.getPoLine(), mainDo.getItemCode()); |
|
|
|
mainDo.setReceiveQty(purchasereceiptRecordDetailDO.getQty().intValue()); |
|
|
|
mainDo.setReceiveQty(purchasereceiptRecordDetailDO.getQty()); |
|
|
|
validatorRule(mainDo); |
|
|
|
businesstypeDO = jobUtils.selectDocumentSettingFromBusinessType("InspectRequest"); |
|
|
|
mainDo.setBusinessType(businesstypeDO.getCode()); |
|
|
|
mainDo.setFromLocationTypes(businesstypeDO.getOutLocationTypes()); |
|
|
|
mainDo.setFromAreaCodes(businesstypeDO.getOutAreaCodes()); |
|
|
|
RequestsettingDO requestsettingDO = requestsettingService.selectRequestsettingExist("InspectRequest"); |
|
|
|
mainDo.setAutoAgree(requestsettingDO.getAutoAgree()); |
|
|
|
mainDo.setAutoCommit(requestsettingDO.getAutoCommit()); |
|
|
|
mainDo.setAutoExecute(requestsettingDO.getAutoExecute()); |
|
|
|
mainDo.setDirectCreateRecord(requestsettingDO.getDirectCreateRecord()); |
|
|
|
return mainDo; |
|
|
|
} |
|
|
|
|
|
|
|
//校验子表公共方法(适用于新增/修改)
|
|
|
|
private void validatorDetailMethod(InspectRequestDetailDO detailDo,InspectRequestMainDO mainDo, BusinesstypeDO businesstypeDO) { |
|
|
|
private void validatorDetailMethod(InspectRequestDetailDO detailDo, InspectRequestMainDO mainDo, BusinesstypeDO businesstypeDO) { |
|
|
|
ItembasicDO itembasicDO = validatorItembasic(detailDo.getItemCode()); |
|
|
|
detailDo.setItemDesc1(itembasicDO.getDesc1()); |
|
|
|
detailDo.setItemDesc2(itembasicDO.getDesc2()); |
|
|
@ -380,7 +392,7 @@ public class InspectRequestMainServiceImpl implements InspectRequestMainService |
|
|
|
validatorLocation(detailDo.getFromLocationCode()); |
|
|
|
validatorIfOutInventoryStatuses(detailDo.getInventoryStatus(), businesstypeDO); |
|
|
|
validatorIfInFromLocationType(detailDo.getFromLocationCode(), businesstypeDO); |
|
|
|
validatorLlocationReturnManagementAccuracy(detailDo.getItemCode(), detailDo.getPackingNumber(), mainDo.getBatch(), detailDo.getFromLocationCode(), detailDo.getInventoryStatus()); |
|
|
|
validatorLocationReturnManagementAccuracy(detailDo.getItemCode(), detailDo.getPackingNumber(), mainDo.getBatch(), detailDo.getFromLocationCode(), detailDo.getInventoryStatus()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -389,24 +401,22 @@ public class InspectRequestMainServiceImpl implements InspectRequestMainService |
|
|
|
* @param mainDo |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private String validatorInspectRequestMainImport(InspectRequestMainDO mainDo,BusinesstypeDO businesstypeDO) { |
|
|
|
private String validatorInspectRequestMainImport(InspectRequestMainDO mainDo, BusinesstypeDO businesstypeDO) { |
|
|
|
StringBuilder message = new StringBuilder(); |
|
|
|
try { |
|
|
|
PurchasereceiptRecordDetailDO purchasereceiptRecordDetailDO = validatorPurchasereceiptExist(mainDo.getPurchaseReceiptRecordNumber(), mainDo.getPoNumber(), mainDo.getPoLine(), mainDo.getItemCode()); |
|
|
|
mainDo.setReceiveQty(purchasereceiptRecordDetailDO.getQty().intValue()); |
|
|
|
}catch (Exception ex) { |
|
|
|
mainDo.setReceiveQty(purchasereceiptRecordDetailDO.getQty()); |
|
|
|
} catch (Exception ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
validatorRule(mainDo); |
|
|
|
}catch (Exception ex) { |
|
|
|
} catch (Exception ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
businesstypeDO = jobUtils.selectDocumentSettingFromBusinessType("InspectRequest"); |
|
|
|
if (businesstypeDO == null) { |
|
|
|
message.append("根据业务类型设置未查找到采购退货申请的相关业务类型"); |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
mainDo.setBusinessType(businesstypeDO.getCode()); |
|
|
|
mainDo.setFromLocationTypes(businesstypeDO.getOutLocationTypes()); |
|
|
|
mainDo.setFromAreaCodes(businesstypeDO.getOutAreaCodes()); |
|
|
@ -414,8 +424,7 @@ public class InspectRequestMainServiceImpl implements InspectRequestMainService |
|
|
|
RequestsettingDO requestsettingDO = requestsettingService.selectRequestsettingExist("InspectRequest"); |
|
|
|
if (requestsettingDO == null) { |
|
|
|
message.append("根据申请单设置未查找到采购退货申请的相关业务类型"); |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
mainDo.setAutoAgree(requestsettingDO.getAutoAgree()); |
|
|
|
mainDo.setAutoCommit(requestsettingDO.getAutoCommit()); |
|
|
|
mainDo.setAutoExecute(requestsettingDO.getAutoExecute()); |
|
|
@ -435,24 +444,25 @@ public class InspectRequestMainServiceImpl implements InspectRequestMainService |
|
|
|
* @param detailDo |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private String validatorInspectRequestDetailImport(InspectRequestDetailDO detailDo, InspectRequestMainDO mainDo,BusinesstypeDO businesstypeDO) { |
|
|
|
private String validatorInspectRequestDetailImport(InspectRequestDetailDO detailDo, InspectRequestMainDO mainDo, BusinesstypeDO businesstypeDO) { |
|
|
|
StringBuilder message = new StringBuilder(); |
|
|
|
ItembasicDO itembasicDO = null; |
|
|
|
try { |
|
|
|
ItembasicDO itembasicDO = validatorItembasic(detailDo.getItemCode()); |
|
|
|
itembasicDO = validatorItembasic(detailDo.getItemCode()); |
|
|
|
detailDo.setItemDesc1(itembasicDO.getDesc1()); |
|
|
|
detailDo.setItemDesc2(itembasicDO.getDesc2()); |
|
|
|
detailDo.setItemName(itembasicDO.getName()); |
|
|
|
detailDo.setProjectCode(itembasicDO.getProject()); |
|
|
|
try { |
|
|
|
this.ifUomSuccess(itembasicDO.getUom(), detailDo.getUom()); |
|
|
|
} catch (Exception ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try{ |
|
|
|
validatorIfInType(itembasicDO.getType(), businesstypeDO); |
|
|
|
}catch (Exception ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
} catch (Exception ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
this.ifUomSuccess(itembasicDO.getUom(), detailDo.getUom()); |
|
|
|
} catch (Exception ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
validatorIfInType(itembasicDO.getType(), businesstypeDO); |
|
|
|
} catch (Exception ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
@ -461,18 +471,18 @@ public class InspectRequestMainServiceImpl implements InspectRequestMainService |
|
|
|
} catch (Exception ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try{ |
|
|
|
try { |
|
|
|
validatorIfOutInventoryStatuses(detailDo.getInventoryStatus(), businesstypeDO); |
|
|
|
}catch (Exception ex) { |
|
|
|
} catch (Exception ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try{ |
|
|
|
try { |
|
|
|
validatorIfInFromLocationType(detailDo.getFromLocationCode(), businesstypeDO); |
|
|
|
}catch (Exception ex) { |
|
|
|
} catch (Exception ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
validatorLlocationReturnManagementAccuracy(detailDo.getItemCode(), detailDo.getPackingNumber(), mainDo.getBatch(), detailDo.getFromLocationCode(), detailDo.getInventoryStatus()); |
|
|
|
validatorLocationReturnManagementAccuracy(detailDo.getItemCode(), detailDo.getPackingNumber(), mainDo.getBatch(), detailDo.getFromLocationCode(), detailDo.getInventoryStatus()); |
|
|
|
} catch (Exception ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|