代码优化

This commit is contained in:
mzr 2025-09-01 19:40:40 +08:00
parent f4e4e95bba
commit 3900d6c257
1 changed files with 59 additions and 55 deletions

View File

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