|
|
@ -1,21 +1,52 @@ |
|
|
|
package com.win.module.wms.service.inspectRequest; |
|
|
|
|
|
|
|
import com.win.framework.common.pojo.CustomConditions; |
|
|
|
import com.win.module.wms.controller.inspectRequest.vo.InspectRequestMainCreateReqVO; |
|
|
|
import com.win.module.wms.controller.inspectRequest.vo.InspectRequestMainExportReqVO; |
|
|
|
import com.win.module.wms.controller.inspectRequest.vo.InspectRequestMainPageReqVO; |
|
|
|
import com.win.module.wms.controller.inspectRequest.vo.InspectRequestMainUpdateReqVO; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import org.springframework.validation.annotation.Validated; |
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
import com.win.module.wms.dal.dataobject.inspectRequest.InspectRequestMainDO; |
|
|
|
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; |
|
|
|
import com.win.framework.common.pojo.PageResult; |
|
|
|
|
|
|
|
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.inspectRequest.vo.*; |
|
|
|
import com.win.module.wms.controller.rule.vo.RuleRespVO; |
|
|
|
import com.win.module.wms.convert.inspectRequest.InspectRequestDetailConvert; |
|
|
|
import com.win.module.wms.convert.inspectRequest.InspectRequestMainConvert; |
|
|
|
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.inspectRequest.InspectRequestMainDO; |
|
|
|
import com.win.module.wms.dal.dataobject.itembasic.ItembasicDO; |
|
|
|
import com.win.module.wms.dal.dataobject.purchasereceiptRecord.PurchasereceiptRecordDetailDO; |
|
|
|
import com.win.module.wms.dal.dataobject.requestsetting.RequestsettingDO; |
|
|
|
import com.win.module.wms.dal.mysql.inspectRequest.InspectRequestDetailMapper; |
|
|
|
import com.win.module.wms.dal.mysql.inspectRequest.InspectRequestMainMapper; |
|
|
|
import com.win.module.wms.enums.DictTypeConstants; |
|
|
|
import com.win.module.wms.enums.request.RequestStatusEnum; |
|
|
|
import com.win.module.wms.service.itembasic.ItembasicService; |
|
|
|
import com.win.module.wms.service.location.LocationService; |
|
|
|
import com.win.module.wms.service.purchasereceiptRecord.PurchasereceiptRecordMainService; |
|
|
|
import com.win.module.wms.service.requestsetting.RequestsettingService; |
|
|
|
import com.win.module.wms.service.rule.RuleService; |
|
|
|
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 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.*; |
|
|
@ -31,23 +62,53 @@ public class InspectRequestMainServiceImpl implements InspectRequestMainService |
|
|
|
|
|
|
|
@Resource |
|
|
|
private InspectRequestMainMapper inspectRequestMainMapper; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private InspectRequestDetailMapper inspectRequestDetailMapper; |
|
|
|
@Resource |
|
|
|
private PurchasereceiptRecordMainService purchasereceiptRecordMainService; |
|
|
|
@Resource |
|
|
|
private SerialNumberApi serialNumberApi; |
|
|
|
@Resource |
|
|
|
private DictDataApi dictDataApi; |
|
|
|
@Resource |
|
|
|
private ItembasicService itembasicService; |
|
|
|
@Resource |
|
|
|
private Validator validator; |
|
|
|
@Resource |
|
|
|
private LocationService locationService; |
|
|
|
@Resource |
|
|
|
private JobUtils jobUtils; |
|
|
|
@Resource |
|
|
|
private RuleService ruleService; |
|
|
|
@Resource |
|
|
|
private RequestsettingService requestsettingService; |
|
|
|
@Resource |
|
|
|
private TrendsApi trendsApi; |
|
|
|
@Override |
|
|
|
public Long createInspectRequestMain(InspectRequestMainCreateReqVO createReqVO) { |
|
|
|
// 插入
|
|
|
|
InspectRequestMainDO inspectRequestMain = InspectRequestMainConvert.INSTANCE.convert(createReqVO); |
|
|
|
inspectRequestMainMapper.insert(inspectRequestMain); |
|
|
|
// 返回
|
|
|
|
return inspectRequestMain.getId(); |
|
|
|
RequestsettingDO requestsettingDO = requestsettingService.selectRequestsettingExist("InspectRequest"); |
|
|
|
BusinesstypeDO businesstypeDO = jobUtils.selectDocumentSettingFromBusinessType("InspectRequest"); |
|
|
|
InspectRequestMainDO inspectRequestMainDO = validatorToCreate(createReqVO, businesstypeDO); |
|
|
|
//调用自动执行方法
|
|
|
|
if(RequestStatusEnum.HANDLING.getCode().equals(inspectRequestMainDO.getStatus())) { |
|
|
|
|
|
|
|
} |
|
|
|
trendsApi.createTrends(requestsettingDO.getId(), "InspectRequest", "增加了到货校验申请", TrendsTypeEnum.CREATE); |
|
|
|
return inspectRequestMainDO.getId(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void updateInspectRequestMain(InspectRequestMainUpdateReqVO updateReqVO) { |
|
|
|
RequestsettingDO requestsettingDO = requestsettingDO = requestsettingService.selectRequestsettingExist("InspectRequest"); |
|
|
|
BusinesstypeDO businesstypeDO = jobUtils.selectDocumentSettingFromBusinessType("InspectRequest"); |
|
|
|
// 校验存在
|
|
|
|
validateInspectRequestMainExists(updateReqVO.getId()); |
|
|
|
// 更新
|
|
|
|
InspectRequestMainDO updateObj = InspectRequestMainConvert.INSTANCE.convert(updateReqVO); |
|
|
|
inspectRequestMainMapper.updateById(updateObj); |
|
|
|
// 更新主表
|
|
|
|
InspectRequestMainDO inspectRequestMainDO = validatorToUpdate(updateReqVO, businesstypeDO); |
|
|
|
if(RequestStatusEnum.HANDLING.getCode().equals(inspectRequestMainDO.getStatus())) { |
|
|
|
|
|
|
|
} |
|
|
|
trendsApi.createTrends(requestsettingDO.getId(), "InspectRequest", "增加了到货校验申请", TrendsTypeEnum.CREATE); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -87,4 +148,339 @@ public class InspectRequestMainServiceImpl implements InspectRequestMainService |
|
|
|
return inspectRequestMainMapper.selectList(exportReqVO); |
|
|
|
} |
|
|
|
|
|
|
|
//判断导入单位是否正确
|
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//查询检验类型
|
|
|
|
private Integer selectInspectType(Integer sampleQty, HashMap<String, String> ruleAll) { |
|
|
|
String inspectType = ruleAll.get("InspectType"); |
|
|
|
if("EXEMPT".equals(inspectType)){ |
|
|
|
return 0; |
|
|
|
} else if ("FULL".equals(inspectType)) { |
|
|
|
return sampleQty; |
|
|
|
}else if("SAMPLING".equals(inspectType)){ |
|
|
|
return selectSampleMethod(ruleAll, sampleQty); |
|
|
|
}else { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
//查询抽检方式 计算抽检数量并返回
|
|
|
|
private Integer selectSampleMethod(HashMap<String, String> ruleAll,Integer 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; |
|
|
|
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){ |
|
|
|
maxFloorQty = floorQty; |
|
|
|
} |
|
|
|
if (maxCeilingQty < ceilingQty){ |
|
|
|
maxCeilingQty = ceilingQty; |
|
|
|
} |
|
|
|
if (maxSampleValue < sampleValue){ |
|
|
|
maxSampleValue = sampleValue; |
|
|
|
} |
|
|
|
//根据校验规则计算出抽样数量
|
|
|
|
if(sampleQty != null && sampleQty != 0){ |
|
|
|
if(floorQty <= sampleQty && sampleQty <= ceilingQty){ |
|
|
|
if("QTY".equals(sampleMethod)){ |
|
|
|
result = sampleValue; |
|
|
|
}else if ("PERCENT".equals(sampleMethod)) { |
|
|
|
double doubleSampleQty = sampleQty * (sampleValue * 0.01); |
|
|
|
result = (int) Math.round(doubleSampleQty); |
|
|
|
} |
|
|
|
} |
|
|
|
}else { |
|
|
|
throw new UtilException("当前到货数量为空,不能进行校验"); |
|
|
|
} |
|
|
|
} |
|
|
|
if (maxCeilingQty < sampleQty) { |
|
|
|
throw new UtilException("当前到货数量已超出校验规则范围"); |
|
|
|
}else { |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//获取策略里的参数进行字段对应
|
|
|
|
private 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()); |
|
|
|
} |
|
|
|
String aqlList = mapRule.get("AqlList"); |
|
|
|
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()); |
|
|
|
} |
|
|
|
} |
|
|
|
return mapRule; |
|
|
|
} |
|
|
|
private PurchasereceiptRecordDetailDO validatorPurchasereceiptExist(String purchaseReceiptRecordNumber, String poNumber, String poLine, String itemCode){ |
|
|
|
return purchasereceiptRecordMainService.selectPurchasereceiptExist(poNumber, null, purchaseReceiptRecordNumber, poLine, itemCode); |
|
|
|
} |
|
|
|
private void validatorRule(InspectRequestMainDO mainDO){ |
|
|
|
HashMap<String, String> rule = selectRule(null, mainDO.getItemCode()); |
|
|
|
selectInspectType(mainDO.getReceiveQty(),rule); |
|
|
|
} |
|
|
|
private ItembasicDO validatorItembasic(String itemCode){ |
|
|
|
return itembasicService.selectItembasic(itemCode); |
|
|
|
} |
|
|
|
private void validatorLocation(String fromLocationCode){ |
|
|
|
locationService.selectLocation(fromLocationCode); |
|
|
|
} |
|
|
|
private void validatorIfInType(String itemType, BusinesstypeDO businesstypeDO){ |
|
|
|
jobUtils.ifInType(itemType, businesstypeDO); |
|
|
|
} |
|
|
|
private void validatorIfOutInventoryStatuses(String inventoryStatus,BusinesstypeDO businesstypeDO){ |
|
|
|
jobUtils.ifOutInventoryStatuses(inventoryStatus, 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(); |
|
|
|
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); |
|
|
|
//子表校验
|
|
|
|
List<InspectRequestDetailCreateReqVO> subList = createReqVO.getSubList(); |
|
|
|
List<InspectRequestDetailDO> subDOList = InspectRequestDetailConvert.INSTANCE.convertList03(subList); |
|
|
|
for (InspectRequestDetailDO detailDO : subDOList) { |
|
|
|
validatorDetailMethod(detailDO,mainDo,businesstypeDO); |
|
|
|
} |
|
|
|
String number = serialNumberApi.generateCode(RuleCodeEnum.PURCHASE_CLAIM_RECORD.getCode()); |
|
|
|
mainDo.setNumber(number); |
|
|
|
mainDo.setStatus(DictFrameworkUtils.parseDictDataValue(DictTypeConstants.REQUEST_STATUS, "新增")); |
|
|
|
inspectRequestMainMapper.insert(mainDo); |
|
|
|
inspectRequestDetailMapper.insertBatch(subDOList); |
|
|
|
return mainDo; |
|
|
|
} |
|
|
|
|
|
|
|
//修改校验
|
|
|
|
private InspectRequestMainDO validatorToUpdate(InspectRequestMainUpdateReqVO updateReqVO, BusinesstypeDO businesstypeDO) { |
|
|
|
InspectRequestMainDO mainDo = validatorMainMethod(updateReqVO,businesstypeDO); |
|
|
|
//子表校验
|
|
|
|
List<InspectRequestDetailUpdateReqVO> subList = updateReqVO.getSubList(); |
|
|
|
List<InspectRequestDetailDO> subDOList = InspectRequestDetailConvert.INSTANCE.convertList05(subList); |
|
|
|
for (InspectRequestDetailDO detailDO : subDOList) { |
|
|
|
validatorDetailMethod(detailDO,mainDo,businesstypeDO); |
|
|
|
} |
|
|
|
inspectRequestMainMapper.updateById(mainDo); |
|
|
|
inspectRequestDetailMapper.updateBatch(subDOList); |
|
|
|
return mainDo; |
|
|
|
} |
|
|
|
//校验主表公共方法(适用于新增/修改)
|
|
|
|
private InspectRequestMainDO validatorMainMethod(InspectRequestMainBaseVO baseVO, BusinesstypeDO businesstypeDO){ |
|
|
|
InspectRequestMainDO mainDo = InspectRequestMainConvert.INSTANCE.convert(baseVO); |
|
|
|
PurchasereceiptRecordDetailDO purchasereceiptRecordDetailDO = validatorPurchasereceiptExist(mainDo.getPurchaseReceiptRecordNumber(), mainDo.getPoNumber(), mainDo.getPoLine(), mainDo.getItemCode()); |
|
|
|
mainDo.setReceiveQty(purchasereceiptRecordDetailDO.getQty().intValue()); |
|
|
|
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) { |
|
|
|
ItembasicDO itembasicDO = validatorItembasic(detailDo.getItemCode()); |
|
|
|
detailDo.setItemDesc1(itembasicDO.getDesc1()); |
|
|
|
detailDo.setItemDesc2(itembasicDO.getDesc2()); |
|
|
|
detailDo.setItemName(itembasicDO.getName()); |
|
|
|
detailDo.setProjectCode(itembasicDO.getProject()); |
|
|
|
this.ifUomSuccess(itembasicDO.getUom(), detailDo.getUom()); |
|
|
|
validatorIfInType(itembasicDO.getType(), businesstypeDO); |
|
|
|
validatorLocation(detailDo.getFromLocationCode()); |
|
|
|
validatorIfOutInventoryStatuses(detailDo.getInventoryStatus(), businesstypeDO); |
|
|
|
validatorIfInFromLocationType(detailDo.getFromLocationCode(), businesstypeDO); |
|
|
|
validatorLlocationReturnManagementAccuracy(detailDo.getItemCode(), detailDo.getPackingNumber(), mainDo.getBatch(), detailDo.getFromLocationCode(), detailDo.getInventoryStatus()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 校验主表导入,并赋值一些参数 |
|
|
|
* |
|
|
|
* @param mainDo |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
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) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
validatorRule(mainDo); |
|
|
|
}catch (Exception ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
businesstypeDO = jobUtils.selectDocumentSettingFromBusinessType("InspectRequest"); |
|
|
|
if (businesstypeDO == null) { |
|
|
|
message.append("根据业务类型设置未查找到采购退货申请的相关业务类型"); |
|
|
|
} |
|
|
|
else { |
|
|
|
mainDo.setBusinessType(businesstypeDO.getCode()); |
|
|
|
mainDo.setFromLocationTypes(businesstypeDO.getOutLocationTypes()); |
|
|
|
mainDo.setFromAreaCodes(businesstypeDO.getOutAreaCodes()); |
|
|
|
} |
|
|
|
RequestsettingDO requestsettingDO = requestsettingService.selectRequestsettingExist("InspectRequest"); |
|
|
|
if (requestsettingDO == null) { |
|
|
|
message.append("根据申请单设置未查找到采购退货申请的相关业务类型"); |
|
|
|
} |
|
|
|
else { |
|
|
|
mainDo.setAutoAgree(requestsettingDO.getAutoAgree()); |
|
|
|
mainDo.setAutoCommit(requestsettingDO.getAutoCommit()); |
|
|
|
mainDo.setAutoExecute(requestsettingDO.getAutoExecute()); |
|
|
|
mainDo.setDirectCreateRecord(requestsettingDO.getDirectCreateRecord()); |
|
|
|
} |
|
|
|
try { |
|
|
|
ValidationUtils.validate(validator, mainDo); |
|
|
|
} catch (Exception ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
return message.toString(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 校验子表导入,并赋值一些参数 |
|
|
|
* |
|
|
|
* @param detailDo |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private String validatorInspectRequestDetailImport(InspectRequestDetailDO detailDo, InspectRequestMainDO mainDo,BusinesstypeDO businesstypeDO) { |
|
|
|
StringBuilder message = new StringBuilder(); |
|
|
|
try { |
|
|
|
ItembasicDO 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.validatorLocation(detailDo.getFromLocationCode()); |
|
|
|
} catch (Exception ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try{ |
|
|
|
validatorIfOutInventoryStatuses(detailDo.getInventoryStatus(), businesstypeDO); |
|
|
|
}catch (Exception ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try{ |
|
|
|
validatorIfInFromLocationType(detailDo.getFromLocationCode(), businesstypeDO); |
|
|
|
}catch (Exception ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
validatorLlocationReturnManagementAccuracy(detailDo.getItemCode(), detailDo.getPackingNumber(), mainDo.getBatch(), detailDo.getFromLocationCode(), detailDo.getInventoryStatus()); |
|
|
|
} catch (Exception ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
try { |
|
|
|
ValidationUtils.validate(validator, detailDo); |
|
|
|
} catch (Exception ex) { |
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
} |
|
|
|
return message.toString(); |
|
|
|
} |
|
|
|
} |
|
|
|