diff --git a/pu/src/private/nc/impl/pu/dhjyd/dhjydmaster/ArriveToDhjydImpl.java b/pu/src/private/nc/impl/pu/dhjyd/dhjydmaster/ArriveToDhjydImpl.java index e37692e..007e6ee 100644 --- a/pu/src/private/nc/impl/pu/dhjyd/dhjydmaster/ArriveToDhjydImpl.java +++ b/pu/src/private/nc/impl/pu/dhjyd/dhjydmaster/ArriveToDhjydImpl.java @@ -6,12 +6,19 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.apache.commons.lang3.StringUtils; + import nc.bs.dao.BaseDAO; import nc.bs.framework.common.InvocationInfoProxy; import nc.bs.framework.common.NCLocator; +import nc.bs.pu.pub.PUIDQueryBuilder; import nc.bs.pub.pf.PfUtilTools; import nc.bs.trade.business.HYPubBO; import nc.codeplatform.framework.service.ServiceSupport; +import nc.impl.pubapp.pattern.data.vo.VODelete; +import nc.impl.pubapp.pattern.data.vo.VOQuery; +import nc.impl.pubapp.pattern.data.vo.VOUpdate; +import nc.impl.pubapp.pattern.rule.IRule; import nc.itf.pu.dhjyd.dhjydmaster.IArriveToDhjyd; import nc.itf.pu.dhjyd.dhjydmaster.IDhjydMasterVOService; import nc.jdbc.framework.processor.MapListProcessor; @@ -24,9 +31,12 @@ import nc.vo.pu.m23.entity.ArriveHeaderVO; import nc.vo.pu.m23.entity.ArriveItemVO; import nc.vo.pu.m23.entity.ArriveVO; import nc.vo.pub.BusinessException; +import nc.vo.pub.ISuperVO; import nc.vo.pub.lang.UFBoolean; import nc.vo.pub.lang.UFDate; import nc.vo.pub.lang.UFDouble; +import nc.vo.pubapp.pattern.exception.ExceptionUtils; +import nc.vo.pubapp.pattern.pub.MathTool; public class ArriveToDhjydImpl extends ServiceSupport implements IArriveToDhjyd { @@ -112,9 +122,13 @@ public class ArriveToDhjydImpl extends ServiceSupport implements IArriveToDhjyd if (!"DHJY-Cxx-01".equals(transtype)) {//非到货检验单情况处理结束 return null; } - + ArriveBbVO arriveBb = null;//到货单质检明细 ArrayList vos = new ArrayList(); + UFDouble nchecknum = UFDouble.ZERO_DBL;//本次检验数量 + UFDouble nwillelignum = UFDouble.ZERO_DBL;//本次检验合格数量 + UFDouble nwillnotelignum = UFDouble.ZERO_DBL;//本次检验不合格数量 + //存在一个检验单有多个表体的情况(合格、不合格、回用) if(dhjydItems != null && dhjydItems.length > 0) { for(int i = 0; i < dhjydItems.length; i++) { @@ -122,7 +136,7 @@ public class ArriveToDhjydImpl extends ServiceSupport implements IArriveToDhjyd arriveBb.setPk_group(dhjydMaster.getPk_group());//所属集团id arriveBb.setPk_arriveorder(dhjydMaster.getSrcbillid());//到货单主键id arriveBb.setPk_arriveorder_b(dhjydMaster.getDef1());//到货单表体主键id - UFDouble nnum = dhjydItems[i].getQualifiednum(); + UFDouble nnum = dhjydItems[i].getQualifiednum();//子表合格数量--->模板调整--->数量 arriveBb.setNnum(nnum==null?UFDouble.ZERO_DBL:nnum);//主数量 arriveBb.setNastnum(nnum==null?UFDouble.ZERO_DBL:nnum);//辅数量 arriveBb.setStatus(2);//新增(0:初始 1:更新 2:新增 3:删除) @@ -138,8 +152,10 @@ public class ArriveToDhjydImpl extends ServiceSupport implements IArriveToDhjyd String def1Code = headMap==null?"":headMap.getOrDefault("code", ""); if ("01".equals(def1Code) || "02".equals(def1Code)) { arriveBb.setBeligible(UFBoolean.valueOf(true));//合格 + nwillelignum = nwillelignum.add(nnum==null?UFDouble.ZERO_DBL:nnum);//合格数量获取 } else if("03".equals(def1Code)) { arriveBb.setBeligible(UFBoolean.valueOf(false));//不合格 + nwillnotelignum = nwillnotelignum.add(nnum==null?UFDouble.ZERO_DBL:nnum);//不合格数量获取 } //批次主键查询 @@ -149,6 +165,8 @@ public class ArriveToDhjydImpl extends ServiceSupport implements IArriveToDhjyd arriveBb.setPk_inbatchcode(pk_batchcode==null?"":pk_batchcode.toString());//入库批次号主键 arriveBb.setVinbatchcode(vbatchcode);//入库批次号编码 + nchecknum = dhjydItems[i].getNchecknum();//本次检验数量 + vos.add(arriveBb); } } else { @@ -156,6 +174,18 @@ public class ArriveToDhjydImpl extends ServiceSupport implements IArriveToDhjyd } dao.save(vos.toArray(new ArriveBbVO[0]), true);//批量生成质检明细信息 + + //回写到货单子表累计合格数量、累计不合格数量等 + if(StringUtils.isNotEmpty(dhjydMaster.getDef1())) { + VOQuery vq = new VOQuery(ArriveItemVO.class); + ArriveItemVO[] items = (ArriveItemVO[])vq.query(new String[] {dhjydMaster.getDef1()}); + if(items != null && items.length > 0) { + items[0].setNchecknum(nchecknum);//本次检验数量 + items[0].setNwillelignum(nwillelignum);//本次检验合格数量 + items[0].setNwillnotelignum(nwillnotelignum);//本次检验不合格数量 + } + updateBTableEligNum(items);//检验数、合格数等回写到货单 + } } catch (Exception e) { String errMsg = e.toString(); if (e.getCause() != null) { @@ -188,6 +218,13 @@ public class ArriveToDhjydImpl extends ServiceSupport implements IArriveToDhjyd ArriveBbVO[] vos = dao.listByCondition(ArriveBbVO.class, whereSql);//质检信息查询 dao.delete(vos, true);//删除质量信息 + + //收回到货单子表累计合格数量、累计不合格数量等 + if(StringUtils.isNotEmpty(dhjydMaster.getDef1())) { + VOQuery vq = new VOQuery(ArriveItemVO.class); + ArriveItemVO[] items = (ArriveItemVO[])vq.query(new String[] {dhjydMaster.getDef1()}); + retrieveArrive(items);//检验数、合格数等归零 + } } catch (Exception e) { String errMsg = e.toString(); if (e.getCause() != null) { @@ -225,6 +262,58 @@ public class ArriveToDhjydImpl extends ServiceSupport implements IArriveToDhjyd } + /*** + * 到货检验单审批通过回写到货单累计数量 + * @param + * @return + */ + private void updateBTableEligNum(ArriveItemVO[] bvos) { + + if(bvos == null || bvos.length == 0) { + return; + } + + List volists = new ArrayList(); + for (int j = 0; j < bvos.length; j++) { + bvos[j].setNaccumchecknum(MathTool.add(bvos[j].getNaccumchecknum(), bvos[j].getNchecknum())); + bvos[j].setNelignum(MathTool.add(bvos[j].getNelignum(), bvos[j].getNwillelignum())); + bvos[j].setNnotelignum(MathTool.add(bvos[j].getNnotelignum(), bvos[j].getNwillnotelignum())); + volists.add(bvos[j]); + } + + VOUpdate util = new VOUpdate(); + util.update((ArriveItemVO[])volists.toArray(new ArriveItemVO[volists.size()]), new String[] { "naccumchecknum", "nelignum", "nnotelignum" }); + } + + + /*** + * 到货检验单收回时回写到货单 + * @param + * @return + */ + private void retrieveArrive(ArriveItemVO[] bills) { + if (bills == null || bills.length == 0) { + return; + } + + try { + List list = new ArrayList(); + for (ArriveItemVO bvo : bills) { + bvo.setNnotelignum(UFDouble.ZERO_DBL); + bvo.setNelignum(UFDouble.ZERO_DBL); + bvo.setNaccumchecknum(UFDouble.ZERO_DBL); + list.add(bvo); + } + + ArriveItemVO[] vos = (ArriveItemVO[]) list.toArray(new ArriveItemVO[0]); + VOUpdate update = new VOUpdate(); + update.update(vos, new String[] { "naccumchecknum", "nelignum", "nnotelignum" }); + } catch (Exception ex) { + ExceptionUtils.wrappException(ex); + } + } + + /*** * 获取dao层 * @return @@ -235,6 +324,5 @@ public class ArriveToDhjydImpl extends ServiceSupport implements IArriveToDhjyd } return this.baseDAO; } - - + }