|
|
@ -4,7 +4,8 @@ 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.PageResult; |
|
|
|
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.countRequest.vo.*; |
|
|
|
import com.win.module.wms.convert.countRequest.CountRequestDetailConvert; |
|
|
|
import com.win.module.wms.convert.countRequest.CountRequestMainConvert; |
|
|
@ -13,13 +14,15 @@ import com.win.module.wms.dal.dataobject.countPlan.CountPlanDetailDO; |
|
|
|
import com.win.module.wms.dal.dataobject.countRequest.CountRequestDetailDO; |
|
|
|
import com.win.module.wms.dal.dataobject.countRequest.CountRequestMainDO; |
|
|
|
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.requestsetting.RequestsettingDO; |
|
|
|
import com.win.module.wms.dal.mysql.countRequest.CountRequestDetailMapper; |
|
|
|
import com.win.module.wms.dal.mysql.countRequest.CountRequestMainMapper; |
|
|
|
import com.win.module.wms.enums.DictTypeConstants; |
|
|
|
import com.win.module.wms.enums.request.RequestStatusEnum; |
|
|
|
import com.win.module.wms.enums.request.RequestStatusState; |
|
|
|
import com.win.module.wms.service.countPlan.CountPlanMainService; |
|
|
|
import com.win.module.wms.service.itembasic.ItembasicService; |
|
|
|
import com.win.module.wms.service.location.LocationService; |
|
|
|
import com.win.module.wms.service.requestsetting.RequestsettingService; |
|
|
|
import com.win.module.wms.service.shift.ShiftService; |
|
|
|
import com.win.module.wms.service.supplieritem.SupplieritemService; |
|
|
|
import com.win.module.wms.util.JobUtils; |
|
|
@ -31,6 +34,7 @@ import javax.annotation.Resource; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Collection; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Objects; |
|
|
|
|
|
|
|
import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; |
|
|
|
import static com.win.module.wms.enums.ErrorCodeConstants.COUNT_REQUEST_MAIN_NOT_EXISTS; |
|
|
@ -60,6 +64,10 @@ public class CountRequestMainServiceImpl implements CountRequestMainService { |
|
|
|
private LocationService locationService; |
|
|
|
@Resource |
|
|
|
private CountPlanMainService countPlanMainService; |
|
|
|
@Resource |
|
|
|
private RequestsettingService requestsettingService; |
|
|
|
@Resource |
|
|
|
private SerialNumberApi serialNumberApi; |
|
|
|
|
|
|
|
@Override |
|
|
|
public Long createCountRequestMain(CountRequestMainCreateReqVO createReqVO) { |
|
|
@ -124,89 +132,48 @@ public class CountRequestMainServiceImpl implements CountRequestMainService { |
|
|
|
} |
|
|
|
List<CountRequestMainImportErrorVO> errorList = new ArrayList<>(); |
|
|
|
datas.forEach(createReqVO -> { |
|
|
|
CountRequestMainDO mainDO = CountRequestMainConvert.INSTANCE.convert(createReqVO); |
|
|
|
// 校验,判断是否有不符合的原因,并加入errorList,如果主表则所有子表都加入errorList
|
|
|
|
String messageMain = ""; |
|
|
|
//主表的验证
|
|
|
|
|
|
|
|
String messageMain = validateCountRequestMainImport(mainDO); |
|
|
|
//子表的验证
|
|
|
|
List<CountRequestDetailCreateReqVO> subList = createReqVO.getSubList(); |
|
|
|
List<CountRequestDetailDO> subDOList = CountRequestDetailConvert.INSTANCE.convertList03(subList); |
|
|
|
for (CountRequestDetailDO purchasePlanDetailDO : subDOList) { |
|
|
|
String messageDetail = ""; |
|
|
|
//校验库位基础信息
|
|
|
|
try { |
|
|
|
LocationDO locationDO = locationService.selectLocation(purchasePlanDetailDO.getLocationCode()); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
messageMain += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
// 校验物品基础信息
|
|
|
|
try { |
|
|
|
ItembasicDO itembasicDO = itembasicService.selectItembasic(purchasePlanDetailDO.getItemCode()); |
|
|
|
if (itembasicDO.getUom() != purchasePlanDetailDO.getUom()) { |
|
|
|
messageDetail += "计量单位" + itembasicDO.getUom() + "错误,应该是" + purchasePlanDetailDO.getUom() + ","; |
|
|
|
} else { |
|
|
|
purchasePlanDetailDO.setItemDesc1(itembasicDO.getDesc1()); |
|
|
|
purchasePlanDetailDO.setItemDesc2(itembasicDO.getDesc2()); |
|
|
|
purchasePlanDetailDO.setItemName(itembasicDO.getName()); |
|
|
|
purchasePlanDetailDO.setProjectCode(itembasicDO.getProject()); |
|
|
|
} |
|
|
|
} catch (ServiceException ex) { |
|
|
|
messageDetail += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
// 校验业务类型
|
|
|
|
try { |
|
|
|
BusinesstypeDO businesstypeDO = jobUtils.selectDocumentSettingFromBusinessType("CountRequest"); |
|
|
|
jobUtils.ifInToLocationType(purchasePlanDetailDO.getLocationCode(), businesstypeDO); |
|
|
|
jobUtils.ifOutInventoryStatuses(purchasePlanDetailDO.getInventoryStatus(), businesstypeDO); |
|
|
|
} catch (ServiceException ex) { |
|
|
|
messageDetail += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
// 校验盘点计划
|
|
|
|
try { |
|
|
|
CountPlanDetailDO countPlanDetailDO = countPlanMainService.selectCountPlanExist(createReqVO.getPlanNumber()); |
|
|
|
if (countPlanDetailDO != null) { |
|
|
|
// createReqVO.setWarehouseCode(countPlanDetailDO.get)
|
|
|
|
} else { |
|
|
|
messageDetail += "盘点计划" + createReqVO.getPlanNumber() + "无效" + ","; |
|
|
|
} |
|
|
|
} catch (ServiceException ex) { |
|
|
|
messageDetail += ex.getMessage() + ","; |
|
|
|
} |
|
|
|
CountRequestDetailCreateReqVO purchasePlanDetailCreateReqVO = CountRequestDetailConvert.INSTANCE.convert1(purchasePlanDetailDO); |
|
|
|
for (CountRequestDetailDO countRequestDetailDO : subDOList) { |
|
|
|
String messageDetail = validateCountRequestDetailImport(countRequestDetailDO); |
|
|
|
//主子表有错误时写入excel
|
|
|
|
if (!messageMain.isEmpty() || !messageDetail.isEmpty()) { |
|
|
|
CountRequestDetailCreateReqVO purchasePlanDetailCreateReqVO = CountRequestDetailConvert.INSTANCE.convert1(countRequestDetailDO); |
|
|
|
CountRequestMainImportErrorVO importVO = CountRequestDetailConvert.INSTANCE.convert(createReqVO, purchasePlanDetailCreateReqVO); |
|
|
|
//进行子表的错误统计
|
|
|
|
//主表没有错误 写入库里
|
|
|
|
if (!messageMain.equals("") || !messageDetail.equals("")) { |
|
|
|
importVO.setImportStatus("失败"); |
|
|
|
messageMain = messageMain + messageDetail; |
|
|
|
importVO.setImportRemark(messageMain.substring(0, messageMain.length() - 1)); |
|
|
|
errorList.add(importVO); |
|
|
|
} else { |
|
|
|
purchasePlanDetailDO.setNumber(createReqVO.getNumber()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//没有错误数据
|
|
|
|
if (errorList.isEmpty()) { |
|
|
|
// 判断如果不存在,在进行插入
|
|
|
|
CountRequestMainDO existPurchaseclaimRequestMainDO = countRequestMainMapper.selectByPlanNumber(createReqVO.getPlanNumber()); |
|
|
|
if (existPurchaseclaimRequestMainDO == null && mode != 3) { |
|
|
|
createReqVO.setStatus(DictFrameworkUtils.parseDictDataValue(DictTypeConstants.REQUEST_STATUS, "新增")); |
|
|
|
BusinesstypeDO businesstypeDO = jobUtils.selectDocumentSettingFromBusinessType("PurchasePlan"); |
|
|
|
if (businesstypeDO != null) { |
|
|
|
createReqVO.setBusinessType(businesstypeDO.getCode()); |
|
|
|
} |
|
|
|
CountRequestMainDO createObj =CountRequestMainConvert.INSTANCE.convert(createReqVO); |
|
|
|
countRequestMainMapper.insert(createObj); |
|
|
|
countRequestDetailMapper.insertBatch(subDOList); |
|
|
|
} else if (existPurchaseclaimRequestMainDO != null && mode != 2) { |
|
|
|
createReqVO.setStatus(DictFrameworkUtils.parseDictDataValue(DictTypeConstants.REQUEST_STATUS, "新增")); |
|
|
|
BusinesstypeDO businesstypeDO = jobUtils.selectDocumentSettingFromBusinessType("PurchaseOrder"); |
|
|
|
if (businesstypeDO != null) { |
|
|
|
createReqVO.setBusinessType(businesstypeDO.getCode()); |
|
|
|
String number = serialNumberApi.generateCode(RuleCodeEnum.PURCHASE_RECEIPT_REQUEST.getCode()); |
|
|
|
mainDO.setNumber(number); |
|
|
|
BusinesstypeDO businesstypeDO = jobUtils.selectDocumentSettingFromBusinessType("CountRequest"); |
|
|
|
mainDO.setBusinessType(businesstypeDO.getCode()); |
|
|
|
RequestsettingDO requestsettingDO = requestsettingService.selectRequestsettingExist("CountRequest"); |
|
|
|
RequestStatusState requestStatusState = new RequestStatusState(); |
|
|
|
requestStatusState.newObject(requestsettingDO.getAutoCommit(), requestsettingDO.getAutoAgree(), requestsettingDO.getAutoExecute()); |
|
|
|
mainDO.setStatus(requestStatusState.getState().getCode()); |
|
|
|
mainDO.setAutoCommit(requestsettingDO.getAutoCommit()); |
|
|
|
mainDO.setAutoAgree(requestsettingDO.getAutoAgree()); |
|
|
|
mainDO.setAutoExecute(requestsettingDO.getAutoExecute()); |
|
|
|
mainDO.setDirectCreateRecord(requestsettingDO.getDirectCreateRecord()); |
|
|
|
countRequestMainMapper.insert(mainDO); |
|
|
|
for (CountRequestDetailDO detailDO : subDOList) { |
|
|
|
detailDO.setMasterId(mainDO.getId()); |
|
|
|
detailDO.setNumber(number); |
|
|
|
} |
|
|
|
CountRequestMainDO createObj = CountRequestMainConvert.INSTANCE.convert(createReqVO); |
|
|
|
countRequestMainMapper.updateById(createObj); |
|
|
|
countRequestDetailMapper.updateBatch(subDOList); |
|
|
|
countRequestDetailMapper.insertBatch(subDOList); |
|
|
|
//调用自动执行方法
|
|
|
|
if(RequestStatusEnum.HANDLING.getCode().equals(mainDO.getStatus())) { |
|
|
|
this.generateJob(mainDO, subDOList); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
@ -216,5 +183,66 @@ public class CountRequestMainServiceImpl implements CountRequestMainService { |
|
|
|
} |
|
|
|
return errorList; |
|
|
|
} |
|
|
|
/** |
|
|
|
* 生成盘点任务,不要改动事务传播方式,否则会有事务问题 |
|
|
|
* @param mainDO 采购收货主 |
|
|
|
* @param detailDOList 采购收货子 |
|
|
|
*/ |
|
|
|
private void generateJob(CountRequestMainDO mainDO, List<CountRequestDetailDO> detailDOList) { |
|
|
|
|
|
|
|
} |
|
|
|
/** |
|
|
|
* 校验导入,并赋值一些参数,未完全实现 |
|
|
|
* @param mainDo |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private String validateCountRequestMainImport(CountRequestMainDO mainDo) { |
|
|
|
StringBuilder message = new StringBuilder(); |
|
|
|
try { |
|
|
|
CountPlanDetailDO countPlanDetailDO = countPlanMainService.selectCountPlanExist(mainDo.getPlanNumber()); |
|
|
|
//mainDo.setWarehouseCode(countPlanDetailDO.getW)
|
|
|
|
} catch (ServiceException e) { |
|
|
|
message.append(e.getMessage()).append(","); |
|
|
|
} |
|
|
|
return message.toString(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 校验导入,并赋值一些参数,未完全实现 |
|
|
|
* @param detailDO |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private String validateCountRequestDetailImport(CountRequestDetailDO detailDO) { |
|
|
|
StringBuilder message = new StringBuilder(); |
|
|
|
//校验库位基础信息
|
|
|
|
try { |
|
|
|
locationService.selectLocation(detailDO.getLocationCode()); |
|
|
|
} catch (ServiceException e) { |
|
|
|
message.append(e.getMessage()).append(","); |
|
|
|
} |
|
|
|
// 校验物品基础信息
|
|
|
|
try { |
|
|
|
ItembasicDO itembasicDO = itembasicService.selectItembasic(detailDO.getItemCode()); |
|
|
|
if (!Objects.equals(itembasicDO.getUom(), detailDO.getUom())) { |
|
|
|
message.append("计量单位").append("错误,应该是").append(","); |
|
|
|
} else { |
|
|
|
detailDO.setItemDesc1(itembasicDO.getDesc1()); |
|
|
|
detailDO.setItemDesc2(itembasicDO.getDesc2()); |
|
|
|
detailDO.setItemName(itembasicDO.getName()); |
|
|
|
detailDO.setProjectCode(itembasicDO.getProject()); |
|
|
|
} |
|
|
|
} catch (ServiceException e) { |
|
|
|
message.append(e.getMessage()).append(","); |
|
|
|
} |
|
|
|
// 校验业务类型
|
|
|
|
try { |
|
|
|
BusinesstypeDO businesstypeDO = jobUtils.selectDocumentSettingFromBusinessType("CountRequest"); |
|
|
|
jobUtils.ifInToLocationType(detailDO.getLocationCode(), businesstypeDO); |
|
|
|
jobUtils.ifOutInventoryStatuses(detailDO.getInventoryStatus(), businesstypeDO); |
|
|
|
} catch (ServiceException e) { |
|
|
|
message.append(e.getMessage()).append(","); |
|
|
|
} |
|
|
|
return message.toString(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|