|
@ -1,24 +1,48 @@ |
|
|
package com.win.module.wms.service.deliverRequest; |
|
|
package com.win.module.wms.service.deliverRequest; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
|
|
import cn.hutool.core.exceptions.UtilException; |
|
|
import com.win.framework.common.pojo.CustomConditions; |
|
|
import com.win.framework.common.pojo.CustomConditions; |
|
|
import com.win.module.wms.controller.deliverRequest.vo.DeliverRequestMainCreateReqVO; |
|
|
import com.win.framework.common.util.validation.ValidationUtils; |
|
|
import com.win.module.wms.controller.deliverRequest.vo.DeliverRequestMainExportReqVO; |
|
|
import com.win.framework.dict.core.util.DictFrameworkUtils; |
|
|
import com.win.module.wms.controller.deliverRequest.vo.DeliverRequestMainPageReqVO; |
|
|
import com.win.module.system.api.dict.DictDataApi; |
|
|
import com.win.module.wms.controller.deliverRequest.vo.DeliverRequestMainUpdateReqVO; |
|
|
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.deliverRequest.vo.*; |
|
|
|
|
|
import com.win.module.wms.controller.issueRequest.vo.IssueRequestDetailCreateReqVO; |
|
|
|
|
|
import com.win.module.wms.controller.issueRequest.vo.IssueRequestImportErrorVO; |
|
|
|
|
|
import com.win.module.wms.convert.deliverRequest.DeliverRequestDetailConvert; |
|
|
|
|
|
import com.win.module.wms.convert.issueRequest.IssueRequestDetailConvert; |
|
|
|
|
|
import com.win.module.wms.convert.issueRequest.IssueRequestMainConvert; |
|
|
|
|
|
import com.win.module.wms.dal.dataobject.businesstype.BusinesstypeDO; |
|
|
|
|
|
import com.win.module.wms.dal.dataobject.deliverRequest.DeliverRequestDetailDO; |
|
|
|
|
|
import com.win.module.wms.dal.dataobject.issueRequest.IssueRequestMainDO; |
|
|
|
|
|
import com.win.module.wms.dal.dataobject.itembasic.ItembasicDO; |
|
|
|
|
|
import com.win.module.wms.dal.dataobject.requestsetting.RequestsettingDO; |
|
|
|
|
|
import com.win.module.wms.dal.dataobject.sale.SaleDetailDO; |
|
|
|
|
|
import com.win.module.wms.dal.mysql.deliverRequest.DeliverRequestDetailMapper; |
|
|
|
|
|
import com.win.module.wms.enums.DictTypeConstants; |
|
|
|
|
|
import com.win.module.wms.service.customer.*; |
|
|
|
|
|
import com.win.module.wms.service.itembasic.ItembasicService; |
|
|
|
|
|
import com.win.module.wms.service.requestsetting.RequestsettingService; |
|
|
|
|
|
import com.win.module.wms.util.JobUtils; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import javax.annotation.Resource; |
|
|
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 org.springframework.validation.annotation.Validated; |
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
import com.win.module.wms.dal.dataobject.deliverRequest.DeliverRequestMainDO; |
|
|
import com.win.module.wms.dal.dataobject.deliverRequest.DeliverRequestMainDO; |
|
|
import com.win.framework.common.pojo.PageResult; |
|
|
import com.win.framework.common.pojo.PageResult; |
|
|
|
|
|
|
|
|
import com.win.module.wms.convert.deliverRequest.DeliverRequestMainConvert; |
|
|
import com.win.module.wms.convert.deliverRequest.DeliverRequestMainConvert; |
|
|
import com.win.module.wms.dal.mysql.deliverRequest.DeliverRequestMainMapper; |
|
|
import com.win.module.wms.dal.mysql.deliverRequest.DeliverRequestMainMapper; |
|
|
|
|
|
|
|
|
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.*; |
|
|
import static com.win.module.wms.enums.ErrorCodeConstants.*; |
|
|
|
|
|
import com.win.module.wms.service.deliverJob.*; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 发货申请主 Service 实现类 |
|
|
* 发货申请主 Service 实现类 |
|
@ -32,6 +56,29 @@ public class DeliverRequestMainServiceImpl implements DeliverRequestMainService |
|
|
@Resource |
|
|
@Resource |
|
|
private DeliverRequestMainMapper deliverRequestMainMapper; |
|
|
private DeliverRequestMainMapper deliverRequestMainMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
private DeliverRequestDetailMapper deliverRequestDetailMapper; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private JobUtils jobUtils; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private ItembasicService itembasicService; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private SerialNumberApi serialNumberApi; |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
private Validator validator; |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
private DictDataApi dictDataApi; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private CustomerService customerService; |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
private RequestsettingService requestsettingService; |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
private DeliverJobMainService deliverJobMainService; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public Long createDeliverRequestMain(DeliverRequestMainCreateReqVO createReqVO) { |
|
|
public Long createDeliverRequestMain(DeliverRequestMainCreateReqVO createReqVO) { |
|
|
// 插入
|
|
|
// 插入
|
|
@ -88,5 +135,127 @@ public class DeliverRequestMainServiceImpl implements DeliverRequestMainService |
|
|
public List<DeliverRequestMainDO> getDeliverRequestMainList(DeliverRequestMainExportReqVO exportReqVO) { |
|
|
public List<DeliverRequestMainDO> getDeliverRequestMainList(DeliverRequestMainExportReqVO exportReqVO) { |
|
|
return deliverRequestMainMapper.selectList(exportReqVO); |
|
|
return deliverRequestMainMapper.selectList(exportReqVO); |
|
|
} |
|
|
} |
|
|
|
|
|
public String Isuom(String uom1, String uom2) { |
|
|
|
|
|
DictDataRespDTO dictDataRespDTO = dictDataApi.selectDictValue(uom1); |
|
|
|
|
|
String value = dictDataRespDTO.getLabel(); |
|
|
|
|
|
if(uom2.equals(value)){ |
|
|
|
|
|
return "ture"; |
|
|
|
|
|
}else { |
|
|
|
|
|
throw new UtilException("计量单位"+uom2+"错误,应该是"+value); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
public String Isqty(BigDecimal shippedqty, BigDecimal detailqty, BigDecimal orderqty,String sonumber,String soline,String itemcode) { |
|
|
|
|
|
BigDecimal resultqty = orderqty.subtract(shippedqty); |
|
|
|
|
|
if( resultqty.compareTo(detailqty)>0 ) |
|
|
|
|
|
return "TURE"; |
|
|
|
|
|
else{ |
|
|
|
|
|
throw new UtilException("发货数量"+detailqty+"大于订单号"+sonumber+"、订单行"+soline+"、物品代码"+itemcode+"的未发货数量"+ resultqty ); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
@Transactional |
|
|
|
|
|
public List<DeliverRequestImportErrorVO> importDeliverRequestList(List<DeliverRequestMainCreateReqVO> datas, Integer mode, boolean updatePart){ |
|
|
|
|
|
if (CollUtil.isEmpty(datas)) { |
|
|
|
|
|
throw exception(DELIVER_REQUEST_NOT_EXISTS); |
|
|
|
|
|
} |
|
|
|
|
|
List<DeliverRequestImportErrorVO> errorList = new ArrayList<>(); |
|
|
|
|
|
datas.forEach(createReqVO -> { |
|
|
|
|
|
String messageMain = ""; |
|
|
|
|
|
BusinesstypeDO businesstypeDO = null; |
|
|
|
|
|
try{ |
|
|
|
|
|
customerService.selectCustomerExist(createReqVO.getCustomerCode()); |
|
|
|
|
|
}catch (Exception ex) { |
|
|
|
|
|
messageMain += ex.getMessage() + ","; |
|
|
|
|
|
} |
|
|
|
|
|
createReqVO.setStatus(DictFrameworkUtils.parseDictDataValue(DictTypeConstants.REQUEST_STATUS, "新增")); |
|
|
|
|
|
createReqVO.setRequestTime(LocalDateTime.now()); |
|
|
|
|
|
try { |
|
|
|
|
|
RequestsettingDO requestsettingDO = requestsettingService.selectRequestsettingExist("DeliverRequest"); |
|
|
|
|
|
if (requestsettingDO != null) { |
|
|
|
|
|
createReqVO.setAutoAgree(requestsettingDO.getAutoAgree()); |
|
|
|
|
|
createReqVO.setAutoCommit(requestsettingDO.getAutoCommit()); |
|
|
|
|
|
createReqVO.setAutoExecute(requestsettingDO.getAutoExecute()); |
|
|
|
|
|
createReqVO.setDirectCreateRecord(requestsettingDO.getDirectCreateRecord()); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (Exception ex) { |
|
|
|
|
|
messageMain += ex.getMessage() + ","; |
|
|
|
|
|
} |
|
|
|
|
|
try { |
|
|
|
|
|
businesstypeDO = jobUtils.selectDocumentSettingFromBusinessType("DeliverRequest"); |
|
|
|
|
|
createReqVO.setBusinessType(businesstypeDO.getCode()); |
|
|
|
|
|
createReqVO.setFromLocationTypes(businesstypeDO.getOutLocationTypes()); |
|
|
|
|
|
createReqVO.setToLocationTypes(businesstypeDO.getInLocationTypes()); |
|
|
|
|
|
createReqVO.setFromAreaCodes(businesstypeDO.getOutAreaCodes()); |
|
|
|
|
|
createReqVO.setToAreaCodes(businesstypeDO.getInAreaCodes()); |
|
|
|
|
|
} catch (Exception ex) { |
|
|
|
|
|
messageMain += ex.getMessage() + ","; |
|
|
|
|
|
} |
|
|
|
|
|
try { |
|
|
|
|
|
ValidationUtils.validate(validator, createReqVO); |
|
|
|
|
|
} catch (Exception ex) { |
|
|
|
|
|
messageMain += ex.getMessage() + ","; |
|
|
|
|
|
} |
|
|
|
|
|
String number = serialNumberApi.generateCode(RuleCodeEnum.PURCHASE_RETURN_REQUEST.getCode()); |
|
|
|
|
|
createReqVO.setNumber(number); |
|
|
|
|
|
List<DeliverRequestDetailCreateReqVO> subList = createReqVO.getSubList(); |
|
|
|
|
|
List<DeliverRequestDetailDO> subDOList = DeliverRequestDetailConvert.INSTANCE.convertList03(subList); |
|
|
|
|
|
for (DeliverRequestDetailDO detailDO : subDOList) { |
|
|
|
|
|
String messageDetail = ""; |
|
|
|
|
|
try { |
|
|
|
|
|
ItembasicDO itembasicDO = itembasicService.selectItembasic(detailDO.getItemCode()); |
|
|
|
|
|
detailDO.setItemDesc1(itembasicDO.getDesc1()); |
|
|
|
|
|
detailDO.setItemDesc2(itembasicDO.getDesc2()); |
|
|
|
|
|
detailDO.setItemName(itembasicDO.getName()); |
|
|
|
|
|
detailDO.setProjectCode(itembasicDO.getProject()); |
|
|
|
|
|
try{ |
|
|
|
|
|
Isuom(itembasicDO.getUom(),detailDO.getUom()); |
|
|
|
|
|
}catch (Exception ex) { |
|
|
|
|
|
|
|
|
|
|
|
messageDetail += ex.getMessage() + ","; |
|
|
|
|
|
} |
|
|
|
|
|
}catch (Exception ex) { |
|
|
|
|
|
messageDetail += ex.getMessage() + ","; |
|
|
|
|
|
} |
|
|
|
|
|
try{ |
|
|
|
|
|
SaleDetailDO saleDetailDO =deliverJobMainService.saleDetailExist(detailDO.getSoNumber(),detailDO.getSoLine(),detailDO.getItemCode()); |
|
|
|
|
|
try{ |
|
|
|
|
|
if(saleDetailDO!=null){ |
|
|
|
|
|
Isqty(saleDetailDO.getShippedQty(),detailDO.getQty(),saleDetailDO.getOrderQty(),detailDO.getSoNumber(),detailDO.getSoLine(),detailDO.getItemCode()); |
|
|
|
|
|
} |
|
|
|
|
|
}catch (Exception ex) { |
|
|
|
|
|
messageDetail += ex.getMessage() + ","; |
|
|
|
|
|
} |
|
|
|
|
|
}catch (Exception ex) { |
|
|
|
|
|
messageDetail += ex.getMessage() + ","; |
|
|
|
|
|
} |
|
|
|
|
|
DeliverRequestDetailCreateReqVO purchaseturnRequestDetailCreateReqVO = DeliverRequestDetailConvert.INSTANCE.convert1(detailDO); |
|
|
|
|
|
DeliverRequestImportErrorVO importVO = DeliverRequestDetailConvert.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()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
DeliverRequestMainDO createobj = DeliverRequestMainConvert.INSTANCE.convert(createReqVO); |
|
|
|
|
|
if (errorList.isEmpty()) { |
|
|
|
|
|
DeliverRequestMainDO existDeliverRequestMainDO = deliverRequestMainMapper.selectWorkShopCodeAndUseOnTheWayLocation(createReqVO.getCustomerCode()); |
|
|
|
|
|
if (existDeliverRequestMainDO == null && mode != 3) { |
|
|
|
|
|
deliverRequestMainMapper.insert(createobj); |
|
|
|
|
|
deliverRequestDetailMapper.insertBatch(subDOList); |
|
|
|
|
|
} else if (existDeliverRequestMainDO != null && mode != 2) { |
|
|
|
|
|
deliverRequestMainMapper.updateById(createobj); |
|
|
|
|
|
deliverRequestDetailMapper.updateBatch(subDOList); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
if (!errorList.isEmpty() && !updatePart) { |
|
|
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
|
|
|
|
|
} |
|
|
|
|
|
return errorList; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|