增加关联明细id字段,解决明细中重复商品进行批次发货遇到的问题
This commit is contained in:
@@ -207,12 +207,13 @@ public class DepotItemController {
|
||||
item.put("operNumber", diEx.getOperNumber());
|
||||
item.put("basicNumber", diEx.getBasicNumber());
|
||||
item.put("preNumber", diEx.getOperNumber()); //原数量
|
||||
item.put("finishNumber", depotItemService.getFinishNumber(diEx.getMaterialExtendId(), diEx.getHeaderId(), unitInfo, materialUnit, linkType)); //已入库|已出库
|
||||
item.put("finishNumber", depotItemService.getFinishNumber(diEx.getMaterialExtendId(), diEx.getId(), diEx.getHeaderId(), unitInfo, materialUnit, linkType)); //已入库|已出库
|
||||
item.put("purchaseDecimal", diEx.getPurchaseDecimal()); //采购价
|
||||
item.put("unitPrice", diEx.getUnitPrice());
|
||||
item.put("taxUnitPrice", diEx.getTaxUnitPrice());
|
||||
item.put("allPrice", diEx.getAllPrice());
|
||||
item.put("remark", diEx.getRemark());
|
||||
item.put("linkId", diEx.getLinkId());
|
||||
item.put("depotId", diEx.getDepotId() == null ? "" : diEx.getDepotId());
|
||||
item.put("depotName", diEx.getDepotId() == null ? "" : diEx.getDepotName());
|
||||
item.put("anotherDepotId", diEx.getAnotherDepotId() == null ? "" : diEx.getAnotherDepotId());
|
||||
|
||||
@@ -46,6 +46,8 @@ public class DepotItem {
|
||||
|
||||
private Date expirationDate;
|
||||
|
||||
private Long linkId;
|
||||
|
||||
private Long tenantId;
|
||||
|
||||
private String deleteFlag;
|
||||
@@ -218,6 +220,14 @@ public class DepotItem {
|
||||
this.expirationDate = expirationDate;
|
||||
}
|
||||
|
||||
public Long getLinkId() {
|
||||
return linkId;
|
||||
}
|
||||
|
||||
public void setLinkId(Long linkId) {
|
||||
this.linkId = linkId;
|
||||
}
|
||||
|
||||
public Long getTenantId() {
|
||||
return tenantId;
|
||||
}
|
||||
|
||||
@@ -1426,6 +1426,66 @@ public class DepotItemExample {
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLinkIdIsNull() {
|
||||
addCriterion("link_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLinkIdIsNotNull() {
|
||||
addCriterion("link_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLinkIdEqualTo(Long value) {
|
||||
addCriterion("link_id =", value, "linkId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLinkIdNotEqualTo(Long value) {
|
||||
addCriterion("link_id <>", value, "linkId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLinkIdGreaterThan(Long value) {
|
||||
addCriterion("link_id >", value, "linkId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLinkIdGreaterThanOrEqualTo(Long value) {
|
||||
addCriterion("link_id >=", value, "linkId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLinkIdLessThan(Long value) {
|
||||
addCriterion("link_id <", value, "linkId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLinkIdLessThanOrEqualTo(Long value) {
|
||||
addCriterion("link_id <=", value, "linkId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLinkIdIn(List<Long> values) {
|
||||
addCriterion("link_id in", values, "linkId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLinkIdNotIn(List<Long> values) {
|
||||
addCriterion("link_id not in", values, "linkId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLinkIdBetween(Long value1, Long value2) {
|
||||
addCriterion("link_id between", value1, value2, "linkId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLinkIdNotBetween(Long value1, Long value2) {
|
||||
addCriterion("link_id not between", value1, value2, "linkId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTenantIdIsNull() {
|
||||
addCriterion("tenant_id is null");
|
||||
return (Criteria) this;
|
||||
|
||||
@@ -143,11 +143,13 @@ public interface DepotItemMapperEx {
|
||||
|
||||
BigDecimal getFinishNumber(
|
||||
@Param("meId") Long meId,
|
||||
@Param("linkId") Long linkId,
|
||||
@Param("linkNumber") String linkNumber,
|
||||
@Param("goToType") String goToType);
|
||||
|
||||
BigDecimal getRealFinishNumber(
|
||||
@Param("meId") Long meId,
|
||||
@Param("linkId") Long linkId,
|
||||
@Param("linkNumber") String linkNumber,
|
||||
@Param("currentHeaderId") Long currentHeaderId,
|
||||
@Param("goToType") String goToType);
|
||||
|
||||
@@ -259,12 +259,12 @@ public class DepotItemService {
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public DepotItem getPreItemByHeaderIdAndMaterial(String linkNumber, Long meId)throws Exception {
|
||||
public DepotItem getPreItemByHeaderIdAndMaterial(String linkNumber, Long meId, Long linkId)throws Exception {
|
||||
DepotItem depotItem = new DepotItem();
|
||||
try{
|
||||
DepotHead depotHead = depotHeadService.getDepotHead(linkNumber);
|
||||
DepotItemExample example = new DepotItemExample();
|
||||
example.createCriteria().andHeaderIdEqualTo(depotHead.getId()).andMaterialExtendIdEqualTo(meId).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||
example.createCriteria().andHeaderIdEqualTo(depotHead.getId()).andMaterialExtendIdEqualTo(meId).andIdEqualTo(linkId).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||
List<DepotItem> list = depotItemMapper.selectByExample(example);
|
||||
if(list!=null && list.size()>0) {
|
||||
depotItem = list.get(0);
|
||||
@@ -430,6 +430,9 @@ public class DepotItemService {
|
||||
if (StringUtil.isExist(rowObj.get("sku"))) {
|
||||
depotItem.setSku(rowObj.getString("sku"));
|
||||
}
|
||||
if (StringUtil.isExist(rowObj.get("linkId"))) {
|
||||
depotItem.setLinkId(rowObj.getLong("linkId"));
|
||||
}
|
||||
//以下进行单位换算
|
||||
Unit unitInfo = materialService.findUnit(materialExtend.getMaterialId()); //查询计量单位信息
|
||||
if (StringUtil.isExist(rowObj.get("operNumber"))) {
|
||||
@@ -467,9 +470,9 @@ public class DepotItemService {
|
||||
String unit = rowObj.get("unit").toString();
|
||||
Long preHeaderId = depotHeadService.getDepotHead(depotHead.getLinkNumber()).getId();
|
||||
//前一个单据的数量
|
||||
BigDecimal preNumber = getPreItemByHeaderIdAndMaterial(depotHead.getLinkNumber(), depotItem.getMaterialExtendId()).getOperNumber();
|
||||
BigDecimal preNumber = getPreItemByHeaderIdAndMaterial(depotHead.getLinkNumber(), depotItem.getMaterialExtendId(), depotItem.getLinkId()).getOperNumber();
|
||||
//除去此单据之外的已入库|已出库
|
||||
BigDecimal realFinishNumber = getRealFinishNumber(depotItem.getMaterialExtendId(), preHeaderId, headerId, unitInfo, unit);
|
||||
BigDecimal realFinishNumber = getRealFinishNumber(depotItem.getMaterialExtendId(), depotItem.getLinkId(), preHeaderId, headerId, unitInfo, unit);
|
||||
if(depotItem.getOperNumber().add(realFinishNumber).compareTo(preNumber)>0) {
|
||||
throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_NUMBER_NEED_EDIT_FAILED_CODE,
|
||||
String.format(ExceptionConstants.DEPOT_HEAD_NUMBER_NEED_EDIT_FAILED_MSG, barCode));
|
||||
@@ -853,7 +856,8 @@ public class DepotItemService {
|
||||
}
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public BigDecimal getFinishNumber(Long meId, Long headerId, Unit unitInfo, String materialUnit, String linkType) {
|
||||
public BigDecimal getFinishNumber(Long meId, Long id, Long headerId, Unit unitInfo, String materialUnit, String linkType) {
|
||||
Long linkId = id;
|
||||
String goToType = "";
|
||||
DepotHead depotHead =depotHeadMapper.selectByPrimaryKey(headerId);
|
||||
String linkNumber = depotHead.getNumber(); //订单号
|
||||
@@ -869,7 +873,7 @@ public class DepotItemService {
|
||||
goToType = BusinessConstants.SUB_TYPE_SALES;
|
||||
}
|
||||
}
|
||||
BigDecimal count = depotItemMapperEx.getFinishNumber(meId, linkNumber, goToType);
|
||||
BigDecimal count = depotItemMapperEx.getFinishNumber(meId, linkId, linkNumber, goToType);
|
||||
//根据多单位情况进行数量的转换
|
||||
if(materialUnit.equals(unitInfo.getOtherUnit()) && unitInfo.getRatio() != 0) {
|
||||
count = count.divide(BigDecimal.valueOf(unitInfo.getRatio()),2,BigDecimal.ROUND_HALF_UP);
|
||||
@@ -886,6 +890,7 @@ public class DepotItemService {
|
||||
/**
|
||||
* 除去此单据之外的已入库|已出库
|
||||
* @param meId
|
||||
* @param linkId
|
||||
* @param preHeaderId
|
||||
* @param currentHeaderId
|
||||
* @param unitInfo
|
||||
@@ -893,7 +898,7 @@ public class DepotItemService {
|
||||
* @return
|
||||
*/
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public BigDecimal getRealFinishNumber(Long meId, Long preHeaderId, Long currentHeaderId, Unit unitInfo, String materialUnit) {
|
||||
public BigDecimal getRealFinishNumber(Long meId, Long linkId, Long preHeaderId, Long currentHeaderId, Unit unitInfo, String materialUnit) {
|
||||
String goToType = "";
|
||||
DepotHead depotHead =depotHeadMapper.selectByPrimaryKey(preHeaderId);
|
||||
String linkNumber = depotHead.getNumber(); //订单号
|
||||
@@ -903,7 +908,7 @@ public class DepotItemService {
|
||||
if(BusinessConstants.SUB_TYPE_SALES_ORDER.equals(depotHead.getSubType())) {
|
||||
goToType = BusinessConstants.SUB_TYPE_SALES;
|
||||
}
|
||||
BigDecimal count = depotItemMapperEx.getRealFinishNumber(meId, linkNumber, currentHeaderId, goToType);
|
||||
BigDecimal count = depotItemMapperEx.getRealFinishNumber(meId, linkId, linkNumber, currentHeaderId, goToType);
|
||||
//根据多单位情况进行数量的转换
|
||||
if(materialUnit.equals(unitInfo.getOtherUnit()) && unitInfo.getRatio() != 0) {
|
||||
count = count.divide(BigDecimal.valueOf(unitInfo.getRatio()),2,BigDecimal.ROUND_HALF_UP);
|
||||
|
||||
Reference in New Issue
Block a user