|
@ -1,39 +1,52 @@ |
|
|
package com.win.module.wms.service.inventorymoveRequest; |
|
|
package com.win.module.wms.service.inventorymoveRequest; |
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
import com.win.framework.common.exception.ServiceException; |
|
|
|
|
|
import com.win.framework.common.pojo.CustomConditions; |
|
|
import com.win.framework.common.pojo.CustomConditions; |
|
|
import com.win.framework.common.pojo.PageResult; |
|
|
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.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.inventorymoveRequest.vo.*; |
|
|
import com.win.module.wms.controller.inventorymoveRequest.vo.*; |
|
|
|
|
|
import com.win.module.wms.controller.productputawayRequest.vo.ProductputawayRequestDetailUpdateReqVO; |
|
|
|
|
|
import com.win.module.wms.controller.productputawayRequest.vo.ProductputawayRequestMainBaseVO; |
|
|
|
|
|
import com.win.module.wms.controller.productputawayRequest.vo.ProductputawayRequestMainCreateReqVO; |
|
|
|
|
|
import com.win.module.wms.controller.productputawayRequest.vo.ProductputawayRequestMainUpdateReqVO; |
|
|
import com.win.module.wms.convert.inventorymoveRequest.InventorymoveRequestDetailConvert; |
|
|
import com.win.module.wms.convert.inventorymoveRequest.InventorymoveRequestDetailConvert; |
|
|
import com.win.module.wms.convert.inventorymoveRequest.InventorymoveRequestMainConvert; |
|
|
import com.win.module.wms.convert.inventorymoveRequest.InventorymoveRequestMainConvert; |
|
|
|
|
|
import com.win.module.wms.convert.productputawayRequest.ProductputawayRequestDetailConvert; |
|
|
|
|
|
import com.win.module.wms.convert.productputawayRequest.ProductputawayRequestMainConvert; |
|
|
import com.win.module.wms.dal.dataobject.balance.BalanceDO; |
|
|
import com.win.module.wms.dal.dataobject.balance.BalanceDO; |
|
|
import com.win.module.wms.dal.dataobject.businesstype.BusinesstypeDO; |
|
|
import com.win.module.wms.dal.dataobject.businesstype.BusinesstypeDO; |
|
|
import com.win.module.wms.dal.dataobject.inventorymoveRequest.InventorymoveRequestDetailDO; |
|
|
import com.win.module.wms.dal.dataobject.inventorymoveRequest.InventorymoveRequestDetailDO; |
|
|
import com.win.module.wms.dal.dataobject.inventorymoveRequest.InventorymoveRequestMainDO; |
|
|
import com.win.module.wms.dal.dataobject.inventorymoveRequest.InventorymoveRequestMainDO; |
|
|
import com.win.module.wms.dal.dataobject.itembasic.ItembasicDO; |
|
|
import com.win.module.wms.dal.dataobject.itembasic.ItembasicDO; |
|
|
import com.win.module.wms.dal.dataobject.location.LocationDO; |
|
|
import com.win.module.wms.dal.dataobject.location.LocationDO; |
|
|
|
|
|
import com.win.module.wms.dal.dataobject.productputawayRequest.ProductputawayRequestDetailDO; |
|
|
|
|
|
import com.win.module.wms.dal.dataobject.productputawayRequest.ProductputawayRequestMainDO; |
|
|
|
|
|
import com.win.module.wms.dal.dataobject.requestsetting.RequestsettingDO; |
|
|
import com.win.module.wms.dal.mysql.inventorymoveRequest.InventorymoveRequestDetailMapper; |
|
|
import com.win.module.wms.dal.mysql.inventorymoveRequest.InventorymoveRequestDetailMapper; |
|
|
import com.win.module.wms.dal.mysql.inventorymoveRequest.InventorymoveRequestMainMapper; |
|
|
import com.win.module.wms.dal.mysql.inventorymoveRequest.InventorymoveRequestMainMapper; |
|
|
import com.win.module.wms.enums.DictTypeConstants; |
|
|
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.itembasic.ItembasicService; |
|
|
import com.win.module.wms.service.itempackaging.ItempackagingService; |
|
|
|
|
|
import com.win.module.wms.service.location.LocationService; |
|
|
import com.win.module.wms.service.location.LocationService; |
|
|
import com.win.module.wms.service.shift.ShiftService; |
|
|
import com.win.module.wms.service.requestsetting.RequestsettingService; |
|
|
import com.win.module.wms.util.JobUtils; |
|
|
import com.win.module.wms.util.JobUtils; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport; |
|
|
|
|
|
import org.springframework.validation.annotation.Validated; |
|
|
import org.springframework.validation.annotation.Validated; |
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
import javax.annotation.Resource; |
|
|
|
|
|
import javax.validation.Validator; |
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
import java.util.Collection; |
|
|
import java.util.Collection; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; |
|
|
import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; |
|
|
import static com.win.module.wms.enums.ErrorCodeConstants.INVENTORYMOVE_REQUEST_MAIN_NOT_EXISTS; |
|
|
import static com.win.module.wms.enums.ErrorCodeConstants.*; |
|
|
import static com.win.module.wms.enums.ErrorCodeConstants.PURCHASECLAIM_REQUEST_IMPORT_LIST_IS_EMPTY; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 库存转移申请主 Service 实现类 |
|
|
* 库存转移申请主 Service 实现类 |
|
@ -49,35 +62,116 @@ public class InventorymoveRequestMainServiceImpl implements InventorymoveRequest |
|
|
|
|
|
|
|
|
@Resource |
|
|
@Resource |
|
|
private InventorymoveRequestDetailMapper inventorymoveRequestDetailMapper; |
|
|
private InventorymoveRequestDetailMapper inventorymoveRequestDetailMapper; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private Validator validator; |
|
|
|
|
|
|
|
|
@Resource |
|
|
@Resource |
|
|
private ItembasicService itembasicService; |
|
|
private ItembasicService itembasicService; |
|
|
|
|
|
|
|
|
@Resource |
|
|
@Resource |
|
|
private ItempackagingService itempackagingService; |
|
|
private SerialNumberApi serialNumberApi; |
|
|
|
|
|
|
|
|
@Resource |
|
|
@Resource |
|
|
private ShiftService shiftService; |
|
|
private RequestsettingService requestsettingService; |
|
|
@Resource |
|
|
@Resource |
|
|
private JobUtils jobUtils; |
|
|
private JobUtils jobUtils; |
|
|
@Resource |
|
|
@Resource |
|
|
private LocationService locationService; |
|
|
private LocationService locationService; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private TrendsApi trendsApi; |
|
|
@Override |
|
|
@Override |
|
|
public Long createInventorymoveRequestMain(InventorymoveRequestMainCreateReqVO createReqVO) { |
|
|
public Long createInventorymoveRequestMain(InventorymoveRequestMainCreateReqVO createReqVO) { |
|
|
|
|
|
RequestsettingDO requestsettingDO = requestsettingService.selectRequestsettingExist("MoveRequest"); |
|
|
// 插入
|
|
|
// 插入
|
|
|
InventorymoveRequestMainDO inventorymoveRequestMain = InventorymoveRequestMainConvert.INSTANCE.convert(createReqVO); |
|
|
InventorymoveRequestMainDO inventorymoveRequestMain = validatorToCreate(createReqVO,requestsettingDO); |
|
|
inventorymoveRequestMainMapper.insert(inventorymoveRequestMain); |
|
|
if(RequestStatusEnum.HANDLING.getCode().equals(inventorymoveRequestMain.getStatus())) { |
|
|
// 返回
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
trendsApi.createTrends(requestsettingDO.getId(), "MoveRequest", "增加了库存移动申请", TrendsTypeEnum.CREATE); |
|
|
return inventorymoveRequestMain.getId(); |
|
|
return inventorymoveRequestMain.getId(); |
|
|
} |
|
|
} |
|
|
|
|
|
private InventorymoveRequestMainDO validatorToCreate(InventorymoveRequestMainCreateReqVO createReqVO, RequestsettingDO requestsettingDO) { |
|
|
|
|
|
BusinesstypeDO businesstypeDO = jobUtils.selectDocumentSettingFromBusinessType("MoveRequest"); |
|
|
|
|
|
InventorymoveRequestMainDO inventorymoveRequestMainDO = validateMainMethod(createReqVO,businesstypeDO,requestsettingDO); |
|
|
|
|
|
List<InventorymoveRequestDetailCreateReqVO> subList = createReqVO.getSubList(); |
|
|
|
|
|
List<InventorymoveRequestDetailDO> subDOList = InventorymoveRequestDetailConvert.INSTANCE.convertList03(subList); |
|
|
|
|
|
for(InventorymoveRequestDetailDO inventorymoveRequestDetailDO: subDOList){ |
|
|
|
|
|
validateDetailMethod(inventorymoveRequestDetailDO,businesstypeDO,inventorymoveRequestMainDO); |
|
|
|
|
|
} |
|
|
|
|
|
String number = serialNumberApi.generateCode(RuleCodeEnum.INVENTORY_MOVE_REQUEST.getCode()); |
|
|
|
|
|
inventorymoveRequestMainDO.setNumber(number); |
|
|
|
|
|
inventorymoveRequestMainMapper.insert(inventorymoveRequestMainDO); |
|
|
|
|
|
for( InventorymoveRequestDetailDO inventorymoveRequestDetailDO : subDOList){ |
|
|
|
|
|
inventorymoveRequestDetailDO.setMasterId(inventorymoveRequestMainDO.getId()); |
|
|
|
|
|
inventorymoveRequestDetailDO.setNumber(inventorymoveRequestMainDO.getNumber()); |
|
|
|
|
|
} |
|
|
|
|
|
inventorymoveRequestDetailMapper.insertBatch(subDOList); |
|
|
|
|
|
return inventorymoveRequestMainDO; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void validateDetailMethod(InventorymoveRequestDetailDO inventorymoveRequestDetailDO, BusinesstypeDO businesstypeDO, InventorymoveRequestMainDO productputawayRequestMainDO) { |
|
|
|
|
|
inventorymoveRequestDetailDO.setCreateTime(LocalDateTime.now()); |
|
|
|
|
|
ItembasicDO itembasic = validteitem(inventorymoveRequestDetailDO); |
|
|
|
|
|
inventorymoveRequestDetailDO.setItemDesc1(itembasic.getDesc1()); |
|
|
|
|
|
inventorymoveRequestDetailDO.setItemDesc2(itembasic.getDesc2()); |
|
|
|
|
|
inventorymoveRequestDetailDO.setItemName(itembasic.getName()); |
|
|
|
|
|
inventorymoveRequestDetailDO.setProjectCode(itembasic.getProject()); |
|
|
|
|
|
inventorymoveRequestDetailDO.setUom(itembasic.getUom()); |
|
|
|
|
|
jobUtils.ifInToLocationType(inventorymoveRequestDetailDO.getFromLocationCode(), businesstypeDO); |
|
|
|
|
|
jobUtils.ifOutInventoryStatuses(inventorymoveRequestDetailDO.getFromInventoryStatus(), businesstypeDO); |
|
|
|
|
|
validtebalance(inventorymoveRequestDetailDO); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
private InventorymoveRequestMainDO validateMainMethod(InventorymoveRequestMainBaseVO baseVO, BusinesstypeDO businesstypeDO, RequestsettingDO requestsettingDO){ |
|
|
|
|
|
InventorymoveRequestMainDO inventorymoveRequestMainDO = InventorymoveRequestMainConvert.INSTANCE.convert(baseVO); |
|
|
|
|
|
inventorymoveRequestMainDO.setStatus(DictFrameworkUtils.parseDictDataValue(DictTypeConstants.REQUEST_STATUS, "新增")); |
|
|
|
|
|
inventorymoveRequestMainDO.setCreateTime(LocalDateTime.now()); |
|
|
|
|
|
inventorymoveRequestMainDO.setAutoAgree(requestsettingDO.getAutoAgree()); |
|
|
|
|
|
inventorymoveRequestMainDO.setAutoCommit(requestsettingDO.getAutoCommit()); |
|
|
|
|
|
inventorymoveRequestMainDO.setAutoExecute(requestsettingDO.getAutoExecute()); |
|
|
|
|
|
inventorymoveRequestMainDO.setDirectCreateRecord(requestsettingDO.getDirectCreateRecord()); |
|
|
|
|
|
inventorymoveRequestMainDO.setBusinessType(businesstypeDO.getCode()); |
|
|
|
|
|
inventorymoveRequestMainDO.setFromLocationTypes(businesstypeDO.getOutLocationTypes()); |
|
|
|
|
|
inventorymoveRequestMainDO.setToLocationTypes(businesstypeDO.getInLocationTypes()); |
|
|
|
|
|
inventorymoveRequestMainDO.setFromAreaCodes(businesstypeDO.getOutAreaCodes()); |
|
|
|
|
|
inventorymoveRequestMainDO.setToAreaCodes(businesstypeDO.getInAreaCodes()); |
|
|
|
|
|
return inventorymoveRequestMainDO; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void updateInventorymoveRequestMain(InventorymoveRequestMainUpdateReqVO updateReqVO) { |
|
|
public void updateInventorymoveRequestMain(InventorymoveRequestMainUpdateReqVO updateReqVO) { |
|
|
|
|
|
RequestsettingDO requestsettingDO = requestsettingService.selectRequestsettingExist("MoveRequest"); |
|
|
// 校验存在
|
|
|
// 校验存在
|
|
|
validateInventorymoveRequestMainExists(updateReqVO.getId()); |
|
|
validateInventorymoveRequestMainExists(updateReqVO.getId()); |
|
|
// 更新
|
|
|
// 更新
|
|
|
InventorymoveRequestMainDO updateObj = InventorymoveRequestMainConvert.INSTANCE.convert(updateReqVO); |
|
|
InventorymoveRequestMainDO inventorymoveRequestMainDO = validatorToUpdate(updateReqVO, requestsettingDO); |
|
|
inventorymoveRequestMainMapper.updateById(updateObj); |
|
|
|
|
|
|
|
|
if(RequestStatusEnum.HANDLING.getCode().equals(inventorymoveRequestMainDO.getStatus())) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
trendsApi.createTrends(requestsettingDO.getId(), "MoveRequest", "增加了库存移动申请", TrendsTypeEnum.CREATE); |
|
|
|
|
|
} |
|
|
|
|
|
private InventorymoveRequestMainDO validatorToUpdate(InventorymoveRequestMainUpdateReqVO updateReqVO, RequestsettingDO requestsettingDO) { |
|
|
|
|
|
BusinesstypeDO businesstypeDO = jobUtils.selectDocumentSettingFromBusinessType("MoveRequest"); |
|
|
|
|
|
InventorymoveRequestMainDO inventorymoveRequestMainDO = validateMainMethod(updateReqVO,businesstypeDO,requestsettingDO); |
|
|
|
|
|
//子表校验
|
|
|
|
|
|
List<InventorymoveRequestDetailUpdateReqVO> subList = updateReqVO.getSubList(); |
|
|
|
|
|
if(!subList.isEmpty()) { |
|
|
|
|
|
List<InventorymoveRequestDetailDO> subDOList = InventorymoveRequestDetailConvert.INSTANCE.convertList05(subList); |
|
|
|
|
|
for (InventorymoveRequestDetailDO inventorymoveRequestDetailDO : subDOList) { |
|
|
|
|
|
validateDetailMethod(inventorymoveRequestDetailDO, businesstypeDO, inventorymoveRequestMainDO); |
|
|
|
|
|
} |
|
|
|
|
|
inventorymoveRequestDetailMapper.updateBatch(subDOList); |
|
|
|
|
|
} |
|
|
|
|
|
inventorymoveRequestMainMapper.updateById(inventorymoveRequestMainDO); |
|
|
|
|
|
return inventorymoveRequestMainDO; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void deleteInventorymoveRequestMain(Long id) { |
|
|
public void deleteInventorymoveRequestMain(Long id) { |
|
|
// 校验存在
|
|
|
// 校验存在
|
|
@ -92,6 +186,9 @@ public class InventorymoveRequestMainServiceImpl implements InventorymoveRequest |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
private DictDataApi dictDataApi; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public InventorymoveRequestMainDO getInventorymoveRequestMain(Long id) { |
|
|
public InventorymoveRequestMainDO getInventorymoveRequestMain(Long id) { |
|
|
return inventorymoveRequestMainMapper.selectById(id); |
|
|
return inventorymoveRequestMainMapper.selectById(id); |
|
@ -117,112 +214,138 @@ public class InventorymoveRequestMainServiceImpl implements InventorymoveRequest |
|
|
return inventorymoveRequestMainMapper.selectList(exportReqVO); |
|
|
return inventorymoveRequestMainMapper.selectList(exportReqVO); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
private String validateInventorymoveRequestMainImport(InventorymoveRequestMainDO mainDo, BusinesstypeDO businesstypeDO) { |
|
|
public List<InventorymoveRequestMainImportErrorVO> importInventorymoveRequestMainList(List<InventorymoveRequestMainCreateReqVO> datas, Integer mode, boolean updatePart) { |
|
|
StringBuilder message = new StringBuilder(); |
|
|
if (CollUtil.isEmpty(datas)) { |
|
|
mainDo.setStatus(DictFrameworkUtils.parseDictDataValue(DictTypeConstants.REQUEST_STATUS, "新增")); |
|
|
throw exception(PURCHASECLAIM_REQUEST_IMPORT_LIST_IS_EMPTY); |
|
|
mainDo.setCreateTime(LocalDateTime.now()); |
|
|
|
|
|
RequestsettingDO requestsettingDO = requestsettingService.selectRequestsettingExist("MoveRequest"); |
|
|
|
|
|
if (requestsettingDO == null) { |
|
|
|
|
|
message.append("未查找到制品上架申请的相关申请设置"); |
|
|
|
|
|
} else { |
|
|
|
|
|
mainDo.setAutoAgree(requestsettingDO.getAutoAgree()); |
|
|
|
|
|
mainDo.setAutoCommit(requestsettingDO.getAutoCommit()); |
|
|
|
|
|
mainDo.setAutoExecute(requestsettingDO.getAutoExecute()); |
|
|
|
|
|
mainDo.setDirectCreateRecord(requestsettingDO.getDirectCreateRecord()); |
|
|
|
|
|
} |
|
|
|
|
|
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(); |
|
|
|
|
|
} |
|
|
|
|
|
private InventorymoveRequestDetailDO validatelocation(InventorymoveRequestDetailDO detailDo){ |
|
|
|
|
|
LocationDO locationDO = locationService.selectLocation(detailDo.getFromLocationCode()); |
|
|
|
|
|
if (locationDO != null) { |
|
|
|
|
|
detailDo.setFromLocationCode(locationDO.getCode()); |
|
|
|
|
|
} |
|
|
|
|
|
return detailDo; |
|
|
} |
|
|
} |
|
|
List<InventorymoveRequestMainImportErrorVO> errorList = new ArrayList<>(); |
|
|
|
|
|
datas.forEach(createReqVO -> { |
|
|
|
|
|
// 校验,判断是否有不符合的原因,并加入errorList,如果主表则所有子表都加入errorList
|
|
|
|
|
|
String messageMain = ""; |
|
|
|
|
|
//主表的验证
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//校验供应商送货策略
|
|
|
private ItembasicDO validteitem(InventorymoveRequestDetailDO detailDo) { |
|
|
// try {
|
|
|
ItembasicDO itembasicDO = itembasicService.selectItembasic(detailDo.getItemCode()); |
|
|
// RuleRespVO ruleRespVO = ruleService.deliverGoods(null, createReqVO.getSupplierCode(), null);
|
|
|
return itembasicDO; |
|
|
// String json = ruleRespVO.getConfiguration();
|
|
|
} |
|
|
// } catch (ServiceException ex) {
|
|
|
|
|
|
// importRemark += ex.getMessage() + ",";
|
|
|
|
|
|
// }
|
|
|
|
|
|
//子表的验证
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void validtebalance(InventorymoveRequestDetailDO detailDo){ |
|
|
|
|
|
List<String> inventoryStatus = new ArrayList<>(); |
|
|
|
|
|
inventoryStatus.add(detailDo.getFromInventoryStatus()); |
|
|
|
|
|
List<BalanceDO> balanceDOList = jobUtils.selectlocationReturnManagementAccuracy(detailDo.getItemCode(), detailDo.getFromPackingNumber() |
|
|
|
|
|
, detailDo.getFromBatch(), detailDo.getFromLocationCode(), inventoryStatus); |
|
|
|
|
|
|
|
|
List<InventorymoveRequestDetailCreateReqVO> subList = createReqVO.getSubList(); |
|
|
} |
|
|
List<InventorymoveRequestDetailDO> subDOList = InventorymoveRequestDetailConvert.INSTANCE.convertList03(subList); |
|
|
|
|
|
for (InventorymoveRequestDetailDO purchaseDetailDO : subDOList) { |
|
|
private String validateInventorymoveRequestDetailImport(InventorymoveRequestDetailDO detailDo, InventorymoveRequestMainDO mainDo, BusinesstypeDO businesstypeDO) { |
|
|
String messageDetail = ""; |
|
|
StringBuilder message = new StringBuilder(); |
|
|
//校验来源/目标库位基础信息
|
|
|
// 校验,判断是否有不符合的原因,并加入errorList,同主表,只把有错误的子表加入errorList
|
|
|
try{ |
|
|
try{ |
|
|
LocationDO locationDO = locationService.selectLocation(createReqVO.getFromWarehouseOde()); |
|
|
detailDo.setCreateTime(LocalDateTime.now()); |
|
|
if (locationDO != null) { |
|
|
detailDo = validatelocation(detailDo); |
|
|
purchaseDetailDO.setFromLocationCode(locationDO.getCode()); |
|
|
}catch (Exception ex) { |
|
|
// purchaseDetailDO.setArea_code(purchaseDetailDO.getAreaCode());
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
// purchaseDetailDO.setLocation_group_code(purchaseDetailDO.getAreaCode());
|
|
|
|
|
|
} |
|
|
} |
|
|
} catch (ServiceException ex) { |
|
|
try{ |
|
|
messageMain += ex.getMessage() + ","; |
|
|
ItembasicDO itembasic = validteitem(detailDo); |
|
|
|
|
|
detailDo.setItemDesc1(itembasic.getDesc1()); |
|
|
|
|
|
detailDo.setItemDesc2(itembasic.getDesc2()); |
|
|
|
|
|
detailDo.setItemName(itembasic.getName()); |
|
|
|
|
|
detailDo.setProjectCode(itembasic.getProject()); |
|
|
|
|
|
detailDo.setUom(itembasic.getUom()); |
|
|
|
|
|
|
|
|
|
|
|
}catch (Exception ex) { |
|
|
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
} |
|
|
} |
|
|
// 校验物品基础信息
|
|
|
|
|
|
try{ |
|
|
try{ |
|
|
ItembasicDO itembasicDO = itembasicService.selectItembasic(purchaseDetailDO.getItemCode()); |
|
|
jobUtils.ifInToLocationType(detailDo.getFromLocationCode(), businesstypeDO); |
|
|
if (itembasicDO.getUom() != purchaseDetailDO.getUom()) { |
|
|
}catch (Exception ex) { |
|
|
messageDetail += "计量单位" + itembasicDO.getUom() + "错误,应该是" + purchaseDetailDO.getUom() + ","; |
|
|
message.append(ex.getMessage()).append(","); |
|
|
} else { |
|
|
|
|
|
purchaseDetailDO.setItemDesc1(itembasicDO.getDesc1()); |
|
|
|
|
|
purchaseDetailDO.setItemDesc2(itembasicDO.getDesc2()); |
|
|
|
|
|
purchaseDetailDO.setItemName(itembasicDO.getName()); |
|
|
|
|
|
purchaseDetailDO.setProjectCode(itembasicDO.getProject()); |
|
|
|
|
|
} |
|
|
} |
|
|
purchaseDetailDO.setProjectCode(itembasicDO.getCode()); |
|
|
try{ |
|
|
} catch (ServiceException ex) { |
|
|
jobUtils.ifOutInventoryStatuses(detailDo.getFromInventoryStatus(), businesstypeDO); |
|
|
messageDetail += ex.getMessage() + ","; |
|
|
}catch (Exception ex) { |
|
|
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
} |
|
|
} |
|
|
// 校验业务类型
|
|
|
|
|
|
try{ |
|
|
try{ |
|
|
BusinesstypeDO businesstypeDO = jobUtils.selectDocumentSettingFromBusinessType("MoveRequest"); |
|
|
validtebalance(detailDo); |
|
|
jobUtils.ifInToLocationType(purchaseDetailDO.getFromLocationCode(), businesstypeDO); |
|
|
}catch (Exception ex) { |
|
|
jobUtils.ifOutInventoryStatuses(purchaseDetailDO.getFromInventoryStatus(), businesstypeDO); |
|
|
message.append(ex.getMessage()).append(","); |
|
|
} catch (ServiceException ex) { |
|
|
} |
|
|
messageDetail += ex.getMessage() + ","; |
|
|
return message.toString(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 校验业务类型
|
|
|
|
|
|
try { |
|
|
|
|
|
List<String> inventoryStatus = new ArrayList<>(); |
|
|
@Override |
|
|
inventoryStatus.add(purchaseDetailDO.getFromInventoryStatus()); |
|
|
public List<InventorymoveRequestMainImportErrorVO> importInventorymoveRequestMainList(List<InventorymoveRequestMainCreateReqVO> datas, Integer mode, boolean updatePart) { |
|
|
List<BalanceDO> balanceDOList = jobUtils.selectlocationReturnManagementAccuracy(purchaseDetailDO.getItemCode(), purchaseDetailDO.getFromPackingNumber() |
|
|
if (CollUtil.isEmpty(datas)) { |
|
|
, purchaseDetailDO.getFromBatch(), purchaseDetailDO.getFromLocationCode(), inventoryStatus); |
|
|
throw exception(PURCHASECLAIM_REQUEST_IMPORT_LIST_IS_EMPTY); |
|
|
if (balanceDOList != null) { |
|
|
} |
|
|
BalanceDO balanceDO = balanceDOList.get(0); |
|
|
List<InventorymoveRequestMainImportErrorVO> errorList = new ArrayList<>(); |
|
|
// purchaseDetailDO.setArriveDate( balanceDO.getArriveDate() );
|
|
|
datas.forEach(createReqVO -> { |
|
|
// purchaseDetailDO.setProduceDate( balanceDO.getProduceDate() );
|
|
|
BusinesstypeDO businesstypeDO = jobUtils.selectDocumentSettingFromBusinessType("MoveRequest"); |
|
|
// purchaseDetailDO.setExpireDate( balanceDO.getExpireDate() );
|
|
|
// 校验,判断是否有不符合的原因,并加入errorList,如果主表则所有子表都加入errorList
|
|
|
} |
|
|
//主表的验证
|
|
|
} catch (ServiceException ex) { |
|
|
InventorymoveRequestMainDO mainDo = InventorymoveRequestMainConvert.INSTANCE.convert(createReqVO); |
|
|
messageDetail += ex.getMessage() + ","; |
|
|
String messageMain = validateInventorymoveRequestMainImport(mainDo, businesstypeDO); |
|
|
} |
|
|
//子表的验证
|
|
|
InventorymoveRequestDetailCreateReqVO purchaseDetailCreateReqVO = InventorymoveRequestDetailConvert.INSTANCE.convert1(purchaseDetailDO); |
|
|
List<InventorymoveRequestDetailCreateReqVO> subList = createReqVO.getSubList(); |
|
|
InventorymoveRequestMainImportErrorVO importVO = InventorymoveRequestDetailConvert.INSTANCE.convert(createReqVO, purchaseDetailCreateReqVO); |
|
|
List<InventorymoveRequestDetailDO> subDOList = InventorymoveRequestDetailConvert.INSTANCE.convertList03(subList); |
|
|
//进行子表的错误统计
|
|
|
boolean flag = true; |
|
|
//主表没有错误 写入库里
|
|
|
for (InventorymoveRequestDetailDO purchaseDetailDO : subDOList) { |
|
|
if (!messageMain.equals("") || !messageDetail.equals("")) { |
|
|
String messageDetail = validateInventorymoveRequestDetailImport(purchaseDetailDO, mainDo, businesstypeDO); |
|
|
importVO.setImportStatus("失败"); |
|
|
//校验来源/目标库位基础信息
|
|
|
|
|
|
if (!"".equals(messageMain) ||!"".equals(messageDetail) ) { |
|
|
|
|
|
InventorymoveRequestMainImportErrorVO importErrorVO = InventorymoveRequestMainConvert.INSTANCE.convert(createReqVO, purchaseDetailDO); |
|
|
|
|
|
importErrorVO.setImportStatus("失败"); |
|
|
messageMain = messageMain + messageDetail; |
|
|
messageMain = messageMain + messageDetail; |
|
|
importVO.setImportRemark(messageMain.substring(0, messageMain.length() - 1)); |
|
|
importErrorVO.setImportRemark(messageMain.substring(0, messageMain.length() - 1)); |
|
|
errorList.add(importVO); |
|
|
errorList.add(importErrorVO); |
|
|
} else { |
|
|
flag = false; |
|
|
purchaseDetailDO.setNumber(createReqVO.getNumber()); |
|
|
|
|
|
purchaseDetailDO.setMasterId(createReqVO.getId()); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
//写入数据
|
|
|
if (errorList.isEmpty()) { |
|
|
if (flag) { |
|
|
// 判断如果不存在,在进行插入
|
|
|
String number = serialNumberApi.generateCode(RuleCodeEnum.INVENTORY_CHANGE_REQUEST.getCode()); |
|
|
if (mode != 3) { |
|
|
mainDo.setNumber(number); |
|
|
createReqVO.setStatus(DictFrameworkUtils.parseDictDataValue(DictTypeConstants.REQUEST_STATUS, "新增")); |
|
|
mainDo.setStatus(DictFrameworkUtils.parseDictDataValue(DictTypeConstants.REQUEST_STATUS, "新增")); |
|
|
inventorymoveRequestDetailMapper.insertBatch(subDOList); |
|
|
inventorymoveRequestMainMapper.insert(mainDo); |
|
|
} else if (mode != 2) { |
|
|
for (InventorymoveRequestDetailDO detailDO : subDOList) { |
|
|
createReqVO.setStatus(DictFrameworkUtils.parseDictDataValue(DictTypeConstants.REQUEST_STATUS, "新增")); |
|
|
detailDO.setMasterId(mainDo.getId()); |
|
|
inventorymoveRequestDetailMapper.updateBatch(subDOList); |
|
|
detailDO.setNumber(number); |
|
|
} |
|
|
} |
|
|
|
|
|
inventorymoveRequestDetailMapper.insertBatch(subDOList); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
//错误不为空并非部分更新,手工回滚
|
|
|
|
|
|
if (!errorList.isEmpty() && !updatePart) { |
|
|
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
|
|
|
|
|
} |
|
|
|
|
|
return errorList; |
|
|
return errorList; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|