代码优化
This commit is contained in:
parent
f4e4e95bba
commit
3900d6c257
|
@ -34,10 +34,10 @@ import nc.vo.pubapp.util.VORowNoUtils;
|
|||
* <p>
|
||||
* <b>单据现存量捡货结果</b>
|
||||
*
|
||||
* @version 本版本号
|
||||
* @since 上一版本号
|
||||
* @author yangb
|
||||
* @version 本版本号
|
||||
* @time 2010-4-16 下午01:05:00
|
||||
* @since 上一版本号
|
||||
*/
|
||||
public class ICBillPickResults implements Serializable {
|
||||
|
||||
|
@ -60,7 +60,7 @@ public class ICBillPickResults implements Serializable {
|
|||
// 精度的工具类
|
||||
private transient ScaleUtils scale;
|
||||
|
||||
//标识是否为预留拣货
|
||||
// 标识是否为预留拣货
|
||||
private boolean isResPick = false;
|
||||
|
||||
/**
|
||||
|
@ -106,12 +106,12 @@ public class ICBillPickResults implements Serializable {
|
|||
for (int i = 0; i < this.originbillbodyvos.length; i++) {
|
||||
bodyvos = this.getPickBodys(i);
|
||||
if (bodyvos == null || bodyvos.length <= 0) {
|
||||
//如果没有拣到,返回originvo,并在备注上提示现存量不足
|
||||
// 如果没有拣到,返回originvo,并在备注上提示现存量不足
|
||||
this.originbillbodyvos[i].setVnotebody(OnhandRes.getOnhandErro());
|
||||
retlist.add(this.originbillbodyvos[i]);
|
||||
continue;
|
||||
}
|
||||
//如果拣货后有对应的数据,根据拣货的结果处理拣货行(bodyvos)上的备注
|
||||
// 如果拣货后有对应的数据,根据拣货的结果处理拣货行(bodyvos)上的备注
|
||||
this.processBodyNote(this.originbillbodyvos[i], bodyvos);
|
||||
CollectionUtils.addArrayToList(retlist, bodyvos);
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ public class ICBillPickResults implements Serializable {
|
|||
/**
|
||||
* 处理表体备注,如果原始行应发数量大于对应拣货结果总结存,报现存量不足
|
||||
*
|
||||
* @param orivo 原始行
|
||||
* @param orivo 原始行
|
||||
* @param curvos 拣货结果
|
||||
*/
|
||||
private void processBodyNote(ICBillBodyVO orivo, ICBillBodyVO[] curvos) {
|
||||
|
@ -185,14 +185,14 @@ public class ICBillPickResults implements Serializable {
|
|||
bodyvo.setCgeneralbid(null);
|
||||
bodyvo.setCrowno(null);
|
||||
bodyvo.setPseudoColumn(bodyvo.getPseudoColumn());
|
||||
//bodyvo.setNshouldnum(null);
|
||||
//bodyvo.setNshouldassistnum(null);
|
||||
// bodyvo.setNshouldnum(null);
|
||||
// bodyvo.setNshouldassistnum(null);
|
||||
}
|
||||
//因为存在实发数量拣货,需要
|
||||
// 因为存在实发数量拣货,需要
|
||||
this.synBodyData(bodyvo, lbalances.get(0));
|
||||
ICLocationVO[] locs = null;
|
||||
List<ICLocationVO> listlocs = new ArrayList<ICLocationVO>();
|
||||
//因为存在实发数量拣货,需清除原有的数量
|
||||
// 因为存在实发数量拣货,需清除原有的数量
|
||||
bodyvo.setNnum(null);
|
||||
bodyvo.setNassistnum(null);
|
||||
for (BalanceOnhandRes balance : lbalances) {
|
||||
|
@ -204,7 +204,7 @@ public class ICBillPickResults implements Serializable {
|
|||
.adjustNumScale(nnum, bodyvo.getCunitid()));
|
||||
bodyvo.setNassistnum(this.getScale().adjustNumScale(nassistnum,
|
||||
bodyvo.getCastunitid()));
|
||||
//不处理毛重
|
||||
// 不处理毛重
|
||||
/*bodyvo.setNgrossnum(NCBaseTypeUtils.add(bodyvo.getNgrossnum(),
|
||||
balance.getNgrossnum()));*/
|
||||
locs = balance.getLocatonVO(bodyvo);
|
||||
|
@ -213,27 +213,27 @@ public class ICBillPickResults implements Serializable {
|
|||
}
|
||||
CollectionUtils.addArrayToList(listlocs, locs);
|
||||
}
|
||||
//拆行的话需要清空拆出来的行的应发数量
|
||||
if(rowCount > 1) {
|
||||
// 拆行的话需要清空拆出来的行的应发数量
|
||||
if (rowCount > 1) {
|
||||
// bodyvo.setNshouldnum(null);
|
||||
// bodyvo.setNshouldassistnum(null);
|
||||
//78--2025年4月9日19点11分--sdlizheng--实发传输到应发,最后一行做合计处理--start
|
||||
// 78--2025年4月9日19点11分--sdlizheng--实发传输到应发,最后一行做合计处理--start
|
||||
bodyvo.setNshouldnum(retlist.get(0).getNshouldnum());
|
||||
bodyvo.setNshouldassistnum(retlist.get(0).getNshouldassistnum());
|
||||
//78--2025年4月9日19点11分--sdlizheng--实发传输到应发,最后一行做合计处理--start
|
||||
// 78--2025年4月9日19点11分--sdlizheng--实发传输到应发,最后一行做合计处理--start
|
||||
}
|
||||
if (listlocs.size() > 0) {
|
||||
//清除重复的孙表数据
|
||||
// 清除重复的孙表数据
|
||||
// listlocs = clearDuplicatelvo(bodyvo, listlocs);
|
||||
//处理修改时 带有孙表的自动拣货 重复出库问题 因为拣货把删除的数据给覆盖了 这里补充上
|
||||
// 处理修改时 带有孙表的自动拣货 重复出库问题 因为拣货把删除的数据给覆盖了 这里补充上
|
||||
ICLocationVO[] originLocationVos = bodyvo.getLocationVOs();
|
||||
if (originLocationVos != null && originLocationVos.length > 0) {
|
||||
for (ICLocationVO lvo: originLocationVos) {
|
||||
for (ICLocationVO lvo : originLocationVos) {
|
||||
lvo.setStatus(VOStatus.DELETED);
|
||||
listlocs.add(lvo);
|
||||
}
|
||||
}
|
||||
//处理修改时 带有孙表的自动拣货 重复出库问题 因为拣货把删除的数据给覆盖了 这里补充上
|
||||
// 处理修改时 带有孙表的自动拣货 重复出库问题 因为拣货把删除的数据给覆盖了 这里补充上
|
||||
bodyvo.setLocationVOs(listlocs.toArray((ICLocationVO[]) Array
|
||||
.newInstance(listlocs.get(0).getClass(), listlocs.size())));
|
||||
// 检出
|
||||
|
@ -252,33 +252,34 @@ public class ICBillPickResults implements Serializable {
|
|||
|
||||
/**
|
||||
* 预处理拣货结果,序列号拣货的优先,然后在不满足需求的前提下再加上全捡的部分结果
|
||||
*
|
||||
* @param resList
|
||||
* @param bodyvo
|
||||
*/
|
||||
private List<BalanceOnhandRes> prepare(List<BalanceOnhandRes> resList, ICBillBodyVO bodyvo) {
|
||||
List<BalanceOnhandRes> ret = new ArrayList<BalanceOnhandRes>();
|
||||
String snField = SysInitGroupQuery.isSNEnabled() ? ICPubMetaNameConst.PK_SERIALCODE : OnhandSNVO.VSNCODE;
|
||||
//行上没有序列号单位,认为不是序列号管理,不做处理
|
||||
// 行上没有序列号单位,认为不是序列号管理,不做处理
|
||||
Map<String, InvCalBodyVO> mapInvvos = new ICBSContext().getInvInfo().getMapInvCalBodyVO(bodyvo.getPk_org(),
|
||||
new String[] {bodyvo.getCmaterialvid()});
|
||||
if(mapInvvos == null) {
|
||||
new String[]{bodyvo.getCmaterialvid()});
|
||||
if (mapInvvos == null) {
|
||||
return resList;
|
||||
}
|
||||
InvCalBodyVO invvo = mapInvvos.get(bodyvo.getCmaterialvid());
|
||||
if(invvo == null || !ValueCheckUtil.isTrue(invvo.getSerialmanaflag())) {
|
||||
if (invvo == null || !ValueCheckUtil.isTrue(invvo.getSerialmanaflag())) {
|
||||
return resList;
|
||||
}
|
||||
// if( bodyvo.getCSnunitid() == null) {
|
||||
// return resList;
|
||||
// }
|
||||
//序列号需求数量的字段
|
||||
// 序列号需求数量的字段
|
||||
String snNumReqField = invvo.getSernumunit() != null && invvo.getSernumunit().equals(bodyvo.getCastunitid()) ?
|
||||
ICPubMetaNameConst.NSHOULDASSISTNUM : ICPubMetaNameConst.NSHOULDNUM;
|
||||
//获取序列号拣货捡出的序列号集合
|
||||
// 获取序列号拣货捡出的序列号集合
|
||||
Set<String> bySNValues = new HashSet<String>();
|
||||
//第一次循环,找出序列号拣货捡出的所有序列号
|
||||
for(BalanceOnhandRes res : resList) {
|
||||
if(res.isBySN()) {
|
||||
// 第一次循环,找出序列号拣货捡出的所有序列号
|
||||
for (BalanceOnhandRes res : resList) {
|
||||
if (res.isBySN()) {
|
||||
List<OnhandSNVO> locs = res.getListsnvo();
|
||||
if (locs == null || locs.size() <= 0) {
|
||||
continue;
|
||||
|
@ -288,15 +289,15 @@ public class ICBillPickResults implements Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
int needNum = ((UFDouble)bodyvo.getAttributeValue(snNumReqField)).intValue() - bySNValues.size();
|
||||
int needNum = ((UFDouble) bodyvo.getAttributeValue(snNumReqField)).intValue() - bySNValues.size();
|
||||
ICLocationVO[] blvos = getLVOsBySNField(bodyvo, snField);
|
||||
Set bsns = VOEntityUtil.getVOsValueSet(blvos, snField);
|
||||
int needsnNum = ((UFDouble)bodyvo.getAttributeValue(snNumReqField)).intValue()-blvos.length;
|
||||
//第二次循环,对于非序列号拣货捡出的结果,移除其中已有的序列号结果,如果最终结果为空,则移除这条结果
|
||||
for(BalanceOnhandRes res : resList) {
|
||||
if(res.isBySN()) {
|
||||
int needsnNum = ((UFDouble) bodyvo.getAttributeValue(snNumReqField)).intValue() - blvos.length;
|
||||
// 第二次循环,对于非序列号拣货捡出的结果,移除其中已有的序列号结果,如果最终结果为空,则移除这条结果
|
||||
for (BalanceOnhandRes res : resList) {
|
||||
if (res.isBySN()) {
|
||||
ret.add(res);
|
||||
}else {
|
||||
} else {
|
||||
List<OnhandSNVO> locs = res.getListsnvo();
|
||||
if (locs == null || locs.size() <= 0) {
|
||||
ret.add(res);
|
||||
|
@ -304,22 +305,22 @@ public class ICBillPickResults implements Serializable {
|
|||
}
|
||||
List<OnhandSNVO> list = new ArrayList<OnhandSNVO>();
|
||||
String[] lpks = VOEntityUtil.getVOsValuesNotDel(blvos, ICLocationVO.PK_SERIALCODE, String.class);
|
||||
for(OnhandSNVO lvo : locs) {
|
||||
if(needsnNum > 0) {
|
||||
if(lpks != null) {
|
||||
if(lvo.getAttributeValue(snField) != null && !Arrays.asList(lpks).contains(lvo.getPk_serialcode())) {
|
||||
for (OnhandSNVO lvo : locs) {
|
||||
if (needsnNum > 0) {
|
||||
if (lpks != null) {
|
||||
if (lvo.getAttributeValue(snField) != null && !Arrays.asList(lpks).contains(lvo.getPk_serialcode())) {
|
||||
list.add(lvo);
|
||||
needsnNum--;
|
||||
}
|
||||
} else {
|
||||
if(lvo.getAttributeValue(snField) != null) {
|
||||
if (lvo.getAttributeValue(snField) != null) {
|
||||
list.add(lvo);
|
||||
needsnNum--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(list.size() > 0) {
|
||||
if (list.size() > 0) {
|
||||
res.setListsnvo(list);
|
||||
// 根据孙表数量计算表体数量
|
||||
UFDouble[] sums = VOEntityUtil.sumVOsFieldValuesNotDel(list.toArray(new OnhandSNVO[0]),
|
||||
|
@ -327,7 +328,7 @@ public class ICBillPickResults implements Serializable {
|
|||
res.setNastnum(new UFDouble(list.size()));
|
||||
res.setNnum(sums[0]);
|
||||
ret.add(res);
|
||||
}else {
|
||||
} else {
|
||||
res.setListsnvo(null);
|
||||
}
|
||||
}
|
||||
|
@ -337,17 +338,18 @@ public class ICBillPickResults implements Serializable {
|
|||
|
||||
/**
|
||||
* 有的场景会向后台传序列号的编码,不传序列号的主键,这个时候认为没有传孙表数据
|
||||
*
|
||||
* @param bodyvo
|
||||
* @param snField
|
||||
* @return
|
||||
*/
|
||||
private ICLocationVO[] getLVOsBySNField(ICBillBodyVO bodyvo, String snField) {
|
||||
if(bodyvo.getLocationVOs() == null) {
|
||||
return new ICLocationVO[] {};
|
||||
if (bodyvo.getLocationVOs() == null) {
|
||||
return new ICLocationVO[]{};
|
||||
}
|
||||
List<ICLocationVO> list = new ArrayList<ICLocationVO>();
|
||||
for(ICLocationVO lvo : bodyvo.getLocationVOs()) {
|
||||
if(lvo.getAttributeValue(snField) != null && lvo.getStatus() != VOStatus.DELETED) {
|
||||
for (ICLocationVO lvo : bodyvo.getLocationVOs()) {
|
||||
if (lvo.getAttributeValue(snField) != null && lvo.getStatus() != VOStatus.DELETED) {
|
||||
list.add(lvo);
|
||||
}
|
||||
}
|
||||
|
@ -361,7 +363,7 @@ public class ICBillPickResults implements Serializable {
|
|||
return;
|
||||
}
|
||||
// 根据孙表数量计算表体数量
|
||||
UFDouble[] sums = VOEntityUtil.sumVOsFieldValuesNotDel(locs, new String[]{ICLocationVO.NNUM,ICLocationVO.NASSISTNUM});
|
||||
UFDouble[] sums = VOEntityUtil.sumVOsFieldValuesNotDel(locs, new String[]{ICLocationVO.NNUM, ICLocationVO.NASSISTNUM});
|
||||
bodyvo.setNnum(sums[0]);
|
||||
bodyvo.setNassistnum(sums[1]);
|
||||
}
|
||||
|
@ -375,7 +377,7 @@ public class ICBillPickResults implements Serializable {
|
|||
new HashMap<String, OnhandBalanceResult<ICBillOnhandReq>>();
|
||||
if (this.pickresults != null && this.pickresults.size() > 0) {
|
||||
for (OnhandBalanceResult<ICBillOnhandReq> result : this.pickresults) {
|
||||
if(result.getOnhandReq()!= null) {
|
||||
if (result.getOnhandReq() != null) {
|
||||
this.maponhandbalanceresult.put(result.getOnhandReq().getRowno(),
|
||||
result);
|
||||
}
|
||||
|
@ -396,7 +398,7 @@ public class ICBillPickResults implements Serializable {
|
|||
List<BalanceOnhandRes> lbalance = null;
|
||||
for (BalanceOnhandRes balance : lbalances) {
|
||||
key = OnhandVOTools.getAstDimContentKey(balance.getOnhanddimvo());
|
||||
key = key+balance.getCgeneralbid()+balance.getOnhanddimvo().getClocationid();
|
||||
key = key + balance.getCgeneralbid() + balance.getOnhanddimvo().getClocationid();
|
||||
lbalance = mapgroup.get(key);
|
||||
if (lbalance == null) {
|
||||
lbalance = new ArrayList<BalanceOnhandRes>();
|
||||
|
@ -420,16 +422,17 @@ public class ICBillPickResults implements Serializable {
|
|||
// TODO 精度未处理 等待公共方法
|
||||
ICBSContext context = new ICBSContext();
|
||||
for (int i = 0; i < bodyvos.length; i++) {
|
||||
bodyvos[i].setNcostmny(NCBaseTypeUtils.mult(bodyvos[i].getNcostprice(),
|
||||
UFDouble ncostprice = (bodyvos[i].getNcostprice() == null) ? UFDouble.ZERO_DBL : bodyvos[i].getNcostprice();
|
||||
bodyvos[i].setNcostmny(NCBaseTypeUtils.mult(ncostprice,
|
||||
bodyvos[i].getNnum()));
|
||||
bodyvos[i].setNplannedmny(NCBaseTypeUtils.mult(
|
||||
bodyvos[i].getNplannedprice(), bodyvos[i].getNnum()));
|
||||
// 实发数量和主数量都为空时,不补业务日期
|
||||
if(bodyvos[i].getNnum() == null && bodyvos[i].getNassistnum() == null){
|
||||
if (bodyvos[i].getNnum() == null && bodyvos[i].getNassistnum() == null) {
|
||||
continue;
|
||||
}
|
||||
// 如果业务日期为空的话,补充 modify by guozhq
|
||||
if(bodyvos[i].getDbizdate() == null) {
|
||||
if (bodyvos[i].getDbizdate() == null) {
|
||||
bodyvos[i].setDbizdate(context.getBizDate());
|
||||
}
|
||||
}
|
||||
|
@ -449,6 +452,7 @@ public class ICBillPickResults implements Serializable {
|
|||
// locvo.setNinspaceassistnum(balance.getNastnum());
|
||||
// locvo.setNingrossnum(balance.getNgrossnum());
|
||||
// }
|
||||
|
||||
/**
|
||||
* 设置捡货后的表体数据
|
||||
*/
|
||||
|
@ -456,9 +460,9 @@ public class ICBillPickResults implements Serializable {
|
|||
if (bodyvo == null || res == null) {
|
||||
return;
|
||||
}
|
||||
//现存量维度的单位和单据界面的辅单位不能同步
|
||||
String[] onhandDims=StringUtil.getArrayWithOutStr(OnhandDimVO.getDimContentFields(),
|
||||
OnhandDimVO.CASTUNITID );
|
||||
// 现存量维度的单位和单据界面的辅单位不能同步
|
||||
String[] onhandDims = StringUtil.getArrayWithOutStr(OnhandDimVO.getDimContentFields(),
|
||||
OnhandDimVO.CASTUNITID);
|
||||
OnhandDimVO handdimvo = res.getOnhanddimvo();
|
||||
for (String field : OnhandDimVO.getDimContentFields()) {
|
||||
if (field.equals(OnhandDimVO.VCHANGERATE)) {
|
||||
|
@ -473,7 +477,7 @@ public class ICBillPickResults implements Serializable {
|
|||
}
|
||||
}
|
||||
VOEntityUtil.copyVOByVO(bodyvo, onhandDims,
|
||||
res.getOnhanddimvo(),onhandDims);
|
||||
res.getOnhanddimvo(), onhandDims);
|
||||
|
||||
bodyvo.setCcorrespondtype(res.getCbilltype());
|
||||
bodyvo.setCcorrespondtranstype(res.getVtrantypecode());
|
||||
|
|
Loading…
Reference in New Issue