需求方案:

一、业务逻辑
1.业务背景
某集团计划将采购职能(转库单、采购、委外业务)集中到某个业务单元中,形成集团采购中心。所有具有对外销售职能的业务单元的供应需求,都由该采购中心供货。为加速业务流转、减少人工操作,该集团希望通过客开实现入库(转库单保存签字、采购入库单签字、委托加工入库单签字)自动驱动成品对销售业务单元的内部调拨。
2.业务逻辑
【转库单】保存签字而【采购入库单】、【委外入库单】签字时,如果单据表头仓库档案配置了“对方库存组织”、“对方仓库”,且上游【采购订单】、【委外订单】的交易类型参数“自动内部调拨”为“是”,则生成“入库库存组织”对“对方库存组织”的【调拨订单】。【调拨订单】交易类型由组织级参数“入库触发调拨单交易类型”设定。生成的【调拨订单】,根据组织级参数“入库触发调拨单状态”决定是否自动审核。

二、开发需求
1.仓库档案
在仓库档案通过自定义项6、自定义项7,设置自动形成内部调拨业务单据时的“对方库存组织”、“对方仓库”。其中:

  1. 对方库存组织:在具有“库存职能”的业务单元中任选其一,不包含已停用的;
  2. 对方仓库:仓库档案中“所属库存组织”属于“对方库存组织”的所有未停用仓库任选其一;
  3. 编辑仓库档案时,允许修改“对方库存组织”、“对方仓库”,也允许清空。如果修改了“对方库存组织”(含清空),则清空“对方仓库”;
  4. 保存时,如果“对方库存组织”有值,但“对方仓库”为空,则提示“已配置“对方库存组织”,但未配置“对方仓库”,无法自动调拨”,允许保存;

2.交易类型参数
【库存其他入库单】、【采购入库】、【委托加工入库单】交易类型增加“自动内部调拨”参数,可勾选或反选。(动态建模平台->流程管理->交易类型管理)
注:该参数需要在代码中添加实现

3.组织级参数
系统按照下表增加两个组织级参数:

在【参数模板设置】中添加上面表格的参数,添加完后升级组织参数:

4.入库单签字改造
【采购入库单】、【委外入库单】签字时:

  1. 如果入库实收数量为负,则结束;
  2. 如果上游【采购订单】、【委外订单】交易类型“自动内部调拨”参数为“否”,则结束;
  3. 如果本组织的组织级系统参数“采购入库触发调拨单交易类型”、“委外入库触发调拨单交易类型”为空,则提示“参数IC205“采购入库触发调拨单交易类型”未配置,不能自动调拨”、“参数IC207“委外入库触发调拨单交易类型”未配置,不能自动调拨”,并结束;
  4. 如果【采购入库单】、【委外入库单】表头仓库档案自定义项4“对方库存组织”为空,则结束;
  5. 如果【采购入库单】、【委外入库单】表头仓库档案自定义项5“对方仓库”为空则提示“已配置“对方库存组织”,但未配置“对方仓库”,无法自动调拨”,并结束;
  6. 生成【调拨订单】。【调拨订单】的“调出库存组织”、“调出仓库”与入库单的“库存组织”、“入库仓库”保持一致,“调入库存组织”、“调入仓库”与入库单入库仓库档案的“对方库存组织”(自定义项4)、“对方仓库”(自定义项5)保持一致。物料明细行与入库单的物料明细行保持一致(只保留实收数大于零的行),且单位、数量、主单位、主数量与入库单各行的单位、实收数量、主单位、实收主数量保持一致。每一明细行物料按照系统 “内部结算规则”,形成调拨订单价格(税率、无税单价、含税单价、无税金额、价税合计)。;
  7. 本组织组织级参数“采购入库触发调拨单状态”、“委外入库触发调拨单状态”为“自由”,则结束;
  8. 触发【调拨订单】“审核”;

5.入库单取消签字改造
【采购入库单】、【委外入库单】取消签字时,如果入库单存在下游【调拨订单】,则提示:“存在下游单据,不能取消签字”,签字失败。

开发
实现 【库存其他入库单】、【采购入库】、【委托加工入库单】交易类型增加“自动内部调拨”参数,可勾选或反选。

1、在“ic_transactiontype.bmf”元数据文件中新增“自动内部调拨”参数 autointrans
2、添加完后升级元数据。
3、在TransTypeExtendVO 类中添加字段

package nc.vo.ic.transtype;import nc.vo.ic.pub.define.ICPubMetaNameConst;
import nc.vo.pub.IVOMeta;
import nc.vo.pub.SuperVO;
import nc.vo.pub.lang.UFBoolean;
import nc.vo.pub.lang.UFDateTime;
import nc.vo.pubapp.pattern.model.meta.entity.vo.VOMetaFactory;public class TransTypeExtendVO extends SuperVO {// 影响成本public static final String BAFFECTCOST = "baffectcost";// 影响现存量public static final String BAFFECTONHAND = "baffectonhand";// 审批后自动推式生成其它出入库单public static final String BAPPROVEPUSHBILL = "bapprovepushbill";// 保存即审批public static final String BAUTOAPPROVE = "bautoapprove";// 保存即签字public static final String BAUTOSIGN = "bautosign";// 核销方式public static final String CAVTYPE = "cavtype";// 助促销品出库public static final String BSALEPROMOTION = "bsalepromotion";// 适用零售public static final String BRETAIL = "bretail";//自动内部调拨 add by 2020-09-03public static final String AUTOINTRANS = "autointrans";// 申请出库类型public static final String DEST_BILLTYPECODE = "dest_billtypecode";// 出入库标识public static final String FINOUTFLAG = "finoutflag";// 单据类型主键// public static final String PK_BILLTYPEID = "pk_billtypeid";// 集团public static final String PK_GROUP = "pk_group";// 库存交易类型主键public static final String PK_TRANSTYPE = "pk_transtype";// 库存交易类型编码public static final String TRANSTYPECODE = "transtypecode";// 时间戳public static final String TS = "ts";//寄存消耗结算方public static final String FCONSSETTLEFLAG = "fconssettleflag";private static final long serialVersionUID = 216342704177031780L;public UFBoolean getBaffectcost() {return (UFBoolean) this.getAttributeValue(TransTypeExtendVO.BAFFECTCOST);}public UFBoolean getBaffectonhand() {return (UFBoolean) this.getAttributeValue(TransTypeExtendVO.BAFFECTONHAND);}public UFBoolean getBapprovepushbill() {return (UFBoolean) this.getAttributeValue(TransTypeExtendVO.BAPPROVEPUSHBILL);}public UFBoolean getBautoapprove() {return (UFBoolean) this.getAttributeValue(TransTypeExtendVO.BAUTOAPPROVE);}public UFBoolean getBautosign() {return (UFBoolean) this.getAttributeValue(TransTypeExtendVO.BAUTOSIGN);}public Integer getCavtype() {return (Integer) this.getAttributeValue(TransTypeExtendVO.CAVTYPE);}public UFBoolean getBsalepromotion() {return (UFBoolean) this.getAttributeValue(TransTypeExtendVO.BSALEPROMOTION);}public UFBoolean getBretail() {return (UFBoolean) this.getAttributeValue(TransTypeExtendVO.BRETAIL);}public UFBoolean getAutointrans() {return (UFBoolean) this.getAttributeValue(TransTypeExtendVO.AUTOINTRANS);}public String getDest_billtypecode() {return (String) this.getAttributeValue(TransTypeExtendVO.DEST_BILLTYPECODE);}public Integer getFinoutflag() {return (Integer) this.getAttributeValue(TransTypeExtendVO.FINOUTFLAG);}public Integer getFconssettleflag() {return (Integer) this.getAttributeValue(TransTypeExtendVO.FCONSSETTLEFLAG);}@Overridepublic IVOMeta getMetaData() {IVOMeta meta = VOMetaFactory.getInstance().getVOMeta("ic.ic_transtype");return meta;}// public String getPk_billtypeid() {// return (String) this.getAttributeValue(TransTypeExtendVO.PK_BILLTYPEID);// }public String getPk_group() {return (String) this.getAttributeValue(TransTypeExtendVO.PK_GROUP);}public String getPk_transtype() {return (String) this.getAttributeValue(TransTypeExtendVO.PK_TRANSTYPE);}public String getTranstypecode() {return (String) this.getAttributeValue(TransTypeExtendVO.TRANSTYPECODE);}public UFDateTime getTs() {return (UFDateTime) this.getAttributeValue(TransTypeExtendVO.TS);}public void setBaffectcost(UFBoolean baffectcost) {this.setAttributeValue(TransTypeExtendVO.BAFFECTCOST, baffectcost);}public void setBaffectonhand(UFBoolean baffectonhand) {this.setAttributeValue(TransTypeExtendVO.BAFFECTONHAND, baffectonhand);}public void setBapprovepushbill(UFBoolean bapprovepushbill) {this.setAttributeValue(TransTypeExtendVO.BAPPROVEPUSHBILL, bapprovepushbill);}public void setBautoapprove(UFBoolean bautoapprove) {this.setAttributeValue(TransTypeExtendVO.BAUTOAPPROVE, bautoapprove);}public void setBautosign(UFBoolean bautosign) {this.setAttributeValue(TransTypeExtendVO.BAUTOSIGN, bautosign);}public void setCavtype(Integer cavtype) {this.setAttributeValue(TransTypeExtendVO.CAVTYPE, cavtype);}public void setBsalepromotion(UFBoolean bsalepromotion) {this.setAttributeValue(TransTypeExtendVO.BSALEPROMOTION, bsalepromotion);}public void setBretail(UFBoolean bretail) {this.setAttributeValue(TransTypeExtendVO.BRETAIL, bretail);}public void setAutointrans(UFBoolean autointrans) {this.setAttributeValue(TransTypeExtendVO.AUTOINTRANS, autointrans);  }public void setDest_billtypecode(String dest_billtypecode) {this.setAttributeValue(TransTypeExtendVO.DEST_BILLTYPECODE,dest_billtypecode);}public void setFinoutflag(Integer finoutflag) {this.setAttributeValue(TransTypeExtendVO.FINOUTFLAG, finoutflag);}// public void setPk_billtypeid(String pk_billtypeid) {// this.setAttributeValue(TransTypeExtendVO.PK_BILLTYPEID, pk_billtypeid);// }public void setPk_group(String pk_group) {this.setAttributeValue(TransTypeExtendVO.PK_GROUP, pk_group);}public void setPk_transtype(String pk_transtype) {this.setAttributeValue(TransTypeExtendVO.PK_TRANSTYPE, pk_transtype);}public void setTranstypecode(String transtypecode) {this.setAttributeValue(TransTypeExtendVO.TRANSTYPECODE, transtypecode);}public void setTs(UFDateTime ts) {this.setAttributeValue(TransTypeExtendVO.TS, ts);}public String getCtrantypeid() {return (String) this.getAttributeValue(ICPubMetaNameConst.CTRANTYPEID);}public void setCtrantypeid(String ctrantypeid) {this.setAttributeValue(ICPubMetaNameConst.CTRANTYPEID, ctrantypeid);}public void setFconssettleflag(Integer fconssettleflag) {this.setAttributeValue(TransTypeExtendVO.FCONSSETTLEFLAG, fconssettleflag);}}

交易类型扩展编辑器类 GeneralTransTypePanelFor45

package nc.ui.ic.transtype;import nc.ui.pub.bill.BillData;
import nc.ui.pub.transtype.EditorContext;
import nc.vo.ic.transtype.TransTypeExtendVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFBoolean;/*** * <p>* <b>本类主要完成以下功能:</b> 采购入库单的交易类型扩展界面 注:45为采购入库单的单据类型* <ul>* <li>* </ul>* * <p>* <p>* * @version 6.5* @since 6.5* @time 2020-09-03 下午16:24:14*/
public class GeneralTransTypePanelFor45 extends GeneralTransTypePanel {@Overridepublic Object getTransTypeExtObj(EditorContext context) throws BusinessException {TransTypeExtendVO vo = (TransTypeExtendVO) super.getTransTypeExtObj(context);// 自动内部调拨 add by  2020-09-03if (((Boolean) this.getValue(TransTypeExtendVO.AUTOINTRANS)).booleanValue()) {vo.setAutointrans(UFBoolean.TRUE);} else {vo.setAutointrans(UFBoolean.FALSE);}return vo;}@Overridepublic void processItemView(BillData billData) {super.processItemView(billData);// 核销类型super.setVisible(billData, TransTypeExtendVO.CAVTYPE, false);
//    super.setWidth(billData, TransTypeExtendVO.CAVTYPE);// 保存即签字super.setVisible(billData, TransTypeExtendVO.BAUTOSIGN, true);// 自动内部调拨 add by 2020-09-03super.setVisible(billData, TransTypeExtendVO.AUTOINTRANS, true);super.setWidth(billData, TransTypeExtendVO.AUTOINTRANS);}
}
package nc.ui.ic.transtype;import nc.ui.pub.bill.BillData;
import nc.ui.pub.transtype.EditorContext;
import nc.vo.ic.transtype.TransTypeExtendVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFBoolean;/*** 其他出库单的交易类型扩展界面* * @since 6.31* @version 2013-9-3 上午10:11:28* @author */
public class GeneralTransTypePanelFor4A extends GeneralTransTypePanel {@Overridepublic Object getTransTypeExtObj(EditorContext context)throws BusinessException {TransTypeExtendVO vo =(TransTypeExtendVO) super.getTransTypeExtObj(context);// 适用零售if (((Boolean) this.getValue(TransTypeExtendVO.BRETAIL)).booleanValue()) {vo.setBretail(UFBoolean.TRUE);}else {vo.setBretail(UFBoolean.FALSE);}// 自动内部调拨  add by 2020-09-03if (((Boolean) this.getValue(TransTypeExtendVO.AUTOINTRANS)).booleanValue()) {vo.setAutointrans(UFBoolean.TRUE);}else {vo.setAutointrans(UFBoolean.FALSE);}return vo;}@Overridepublic void processItemView(BillData billData) {super.processItemView(billData);// 适用零售super.setVisible(billData, TransTypeExtendVO.BRETAIL, true);super.setWidth(billData, TransTypeExtendVO.BRETAIL);// 自动内部调拨 add by  2020-09-03 super.setVisible(billData, TransTypeExtendVO.AUTOINTRANS, true);super.setWidth(billData, TransTypeExtendVO.AUTOINTRANS);}
}
package nc.ui.ic.transtype;import nc.ui.pub.bill.BillData;
import nc.ui.pub.transtype.EditorContext;
import nc.vo.ic.transtype.TransTypeExtendVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFBoolean;/*** * <p>* <b>本类主要完成以下功能:</b> 委外加工入库单的交易类型扩展界面 注:47为委外加工入库单的单据类型* <ul>* <li>* </ul>* * <p>* <p>* * @version 6.0* @since 6.0* @author songhy* @time 2010-6-4 下午02:24:14*/
public class GeneralTransTypePanelFor47 extends GeneralTransTypePanel {@Overridepublic Object getTransTypeExtObj(EditorContext context) throws BusinessException {TransTypeExtendVO vo = (TransTypeExtendVO) super.getTransTypeExtObj(context);// 自动内部调拨 add by 2020-09-03if (((Boolean) this.getValue(TransTypeExtendVO.AUTOINTRANS)).booleanValue()) {vo.setAutointrans(UFBoolean.TRUE);} else {vo.setAutointrans(UFBoolean.FALSE);}return vo;}@Overridepublic void processItemView(BillData billData) {super.processItemView(billData);// 保存即签字super.setVisible(billData, TransTypeExtendVO.BAUTOSIGN, false);// 自动内部调拨 add by 2020-09-03super.setVisible(billData, TransTypeExtendVO.AUTOINTRANS, true);super.setWidth(billData, TransTypeExtendVO.AUTOINTRANS);// 核销类型super.setVisible(billData, TransTypeExtendVO.CAVTYPE, true);}
}

在单据类型管理中新增此类(GeneralTransTypePanelFor45 ),如图


如果界面新增、修改保存报错,则只能后台直接修改数据库了或sql语句插入了。

编写自动调拨的业务逻辑

做后规则有两种套路:
一个是代码写
代码编写需要在入口类中注册

签字入口类

package nc.bs.ic.m47.sign;import nc.bs.ic.general.sign.ISignBP;
import nc.bs.ic.general.sign.ISignRuleProvider;
import nc.bs.ic.general.sign.SignBPTemplate;
import nc.bs.ic.m47.base.BPPlugInPoint;
import nc.bs.ic.m47.sign.rule.M47AfterSignAuto5XBillVO;
import nc.bs.ic.m47.sign.rule.AfterSignAutoVerifyRule;
import nc.bs.ic.m47.sign.rule.AfterSignForFI;
import nc.bs.ic.m47.sign.rule.AfterSignRuleForFinanceProcess;
import nc.impl.pubapp.pattern.rule.processer.AroundProcesser;
import nc.vo.ic.m47.entity.SubcontInVO;/*** <p> <b>本类主要完成以下功能:</b> <ul> <li>委托加工入库签字 </ul> <p> <p>* * @version 6.0* @since 6.0* @author wanghna* @time 2010-10-25 上午09:23:19*/
public class SignBP implements ISignBP<SubcontInVO>,ISignRuleProvider<SubcontInVO> {@Overridepublic SubcontInVO[] sign(SubcontInVO[] vos) {SignBPTemplate<SubcontInVO> signBP =new SignBPTemplate<SubcontInVO>(BPPlugInPoint.SignAction, this);return signBP.sign(vos);}@Overridepublic void addAfterRule(SubcontInVO[] vos,AroundProcesser<SubcontInVO> processor) {// 签字生成存货核算的委托加工入库processor.addAfterRule(new AfterSignRuleForFinanceProcess());// 签字自动核销processor.addAfterRule(new AfterSignAutoVerifyRule());// 委托加工入库单签字生成采购副本processor.addAfterRule(new AfterSignForFI());//签字后自动生成调拨订单  add by 2020-09-03processor.addAfterRule(new M47AfterSignAuto5XBillVO());}@Overridepublic void addBeforeRule(SubcontInVO[] vos,AroundProcesser<SubcontInVO> processor) {// do nothing}}

自动生成调拨订单业务处理类

package nc.bs.ic.m47.sign.rule;import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;import nc.bs.dao.BaseDAO;
import nc.bs.dao.DAOException;
import nc.bs.framework.common.NCLocator;
import nc.impl.pubapp.pattern.rule.IRule;
import nc.itf.ic.transtype.ITransTypeExtendQueryService;
import nc.itf.to.m5x.ITransOrderForGeneralIn;
import nc.itf.to.m5x.ITransOrderMaintain;
import nc.itf.uap.IUAPQueryBS;
import nc.itf.uap.pf.IPfExchangeService;
import nc.itf.uap.pf.IplatFormEntry;
import nc.itf.uap.pf.busiflow.PfButtonClickContext;
import nc.jdbc.framework.processor.ColumnProcessor;
import nc.pub.occnc.syn.common.UFBoolean;
import nc.pubitf.uapbd.IMaterialBaseClassPubService;
import nc.pubitf.uapbd.IMaterialPubService_C;
import nc.ui.pub.para.SysInitBO_Client;
import nc.util.mmf.busi.consts.BillTypeConst;
import nc.vo.bd.material.MaterialVO;
import nc.vo.bd.material.marbasclass.MarBasClassVO;
import nc.vo.bd.stordoc.StordocVO;
import nc.vo.ic.m47.entity.SubcontInBodyVO;
import nc.vo.ic.m47.entity.SubcontInHeadVO;
import nc.vo.ic.m47.entity.SubcontInVO;import nc.vo.ic.transtype.TransTypeExtendVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.billtype.BilltypeVO;
import nc.vo.pub.lang.UFDouble;
import nc.vo.pub.para.SysInitVO;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
import nc.vo.to.m5x.entity.BillHeaderVO;
import nc.vo.to.m5x.entity.BillItemVO;
import nc.vo.to.m5x.entity.BillVO;/*** * @description 委托加工入库单签字后生成调拨订单* @scene 委托加工单签字* @param* ** @since 6.5* @version 2020-09-03* @author */
public class M47AfterSignAuto5XBillVO implements IRule<SubcontInVO> {@Overridepublic void process(SubcontInVO[] vos) {if ((vos == null) || (vos.length == 0)) {return;}// 2.如果入库实收数量为负,则结束;// 2.如果上游【委托加工入库单】交易类型“自动内部调拨”参数为“否”,则结束;// 4.如果 【委托加工入库单】表头仓库档案自定义项6“对方库存组织”为空,则结束;"ITransTypeExtendQueryService queryService = NCLocator.getInstance().lookup(ITransTypeExtendQueryService.class);for (SubcontInVO subcontInVO : vos) {SubcontInHeadVO headVO = subcontInVO.getHead();SubcontInBodyVO[] bodyVOs = subcontInVO.getBodys();String pk_org = headVO.getPk_org();// 1、判断来源单据是否是委托订单-61if (headVO == null || !"61".equals(bodyVOs[0].getCsourcetype())) {continue;}// 2判断实收数量为负if (headVO.getNtotalnum() == null || headVO.getNtotalnum().compareTo(UFDouble.ZERO_DBL) < 0) {continue;}// 3如果【委托加工入库单】交易类型“自动内部调拨”参数为“否”TransTypeExtendVO[] transTypeExtendVO = null;try {transTypeExtendVO = queryService.queryByIds(new String[] { headVO.getCtrantypeid() });} catch (BusinessException e) {ExceptionUtils.wrappBusinessException("获取委托加工入库单的交易类型出错" + e.getMessage());}if (transTypeExtendVO == null || transTypeExtendVO[0].getAutointrans() == null|| !transTypeExtendVO[0].getAutointrans().booleanValue()) {// 并上自动调拨参数为否continue;}// 4如果本组织的组织级系统参数“入库触发调拨单交易类型”为空,则提示SysInitVO initVO = null;try {initVO = SysInitBO_Client.queryByParaCode(pk_org, "IC207");} catch (BusinessException e) {ExceptionUtils.wrappBusinessException("获取业务组织参数 IC207失败!" + e.getMessage());}if (null == initVO || initVO.getValue() == null) {continue;}// 5如果【委托加工入库单】表头仓库档案自定义项6“对方库存组织”为空StordocVO stordocVO = this.getStordocVOById(headVO.getCwarehouseid());if (stordocVO == null || stordocVO.getDef6() == null) {continue;}// 6如果【委托加工入库单】表头仓库档案自定义项7“对方仓库”为空则提示if (stordocVO.getDef7() == null) {continue;}// 调用单据转换规则 委托加工入库单-调拨订单IPfExchangeService ipfes = NCLocator.getInstance().lookup(IPfExchangeService.class);BillVO[] billVO = null;try {billVO = (BillVO[]) ipfes.runChangeDataAryNeedClassify(BillTypeConst.SUBCONTIN, BillTypeConst.TRAN,new SubcontInVO[] { subcontInVO }, null, PfButtonClickContext.ClassifyByBusiflow);} catch (BusinessException e) {ExceptionUtils.wrappBusinessException("走单据转换规则【委托加工入库单-调拨订单】失败" + e.getMessage());}if (billVO == null) {ExceptionUtils.wrappBusinessException("走单据转换规则没有生成调拨订单");}BillVO tobillVO = billVO[0];// 调入调出组织,仓库设置,物流明细行过滤BillHeaderVO headerVO = tobillVO.getParentVO();BillItemVO[] itemVO = tobillVO.getChildrenVO();if (itemVO == null || itemVO.length <= 0) {ExceptionUtils.wrappBusinessException("走单据转换规则没有生成调拨订单");}ArrayList<BillItemVO> itemVOList = new ArrayList<BillItemVO>();for (BillItemVO bodyVO : itemVO) {//              bodyVO.setVpricerule("1");UFBoolean notZero = UFBoolean.TRUE;if (bodyVO.getNnum() == null && bodyVO.getNastnum() == null) {notZero = UFBoolean.FALSE;}if (bodyVO.getNnum().compareTo(UFDouble.ZERO_DBL) < 0|| bodyVO.getNastnum().compareTo(UFDouble.ZERO_DBL) < 0) {notZero = UFBoolean.FALSE;}if (notZero.booleanValue()) {itemVOList.add(bodyVO);}}tobillVO.setChildrenVO(itemVOList.toArray(new BillItemVO[itemVOList.size()]));headerVO.SetCtrantypeid(initVO.getValue());headerVO.setCinstockorgid(stordocVO.getDef6());String pk_org_v = getOrgVidById(stordocVO.getDef6());headerVO.setCinstockorgvid(pk_org_v);headerVO.setCinfinanceorgid(stordocVO.getDef6());headerVO.setCinfinanceorgvid(pk_org_v);headerVO.setPk_org(pk_org);headerVO.setPk_org_v(headVO.getPk_org_v());headerVO.setCoutfinanceorgid(pk_org);headerVO.setCoutfinanceorgvid(headVO.getPk_org_v());headerVO.setCtoutfinanceorgid(pk_org);headerVO.setCtoutfinanceorgvid(headVO.getPk_org_v());BilltypeVO billtypevo = getBilltypeVOById(initVO.getValue());String vtrantypecode = "5X-Cxx-03";if (billtypevo != null) {vtrantypecode = billtypevo.getPk_billtypecode();}headerVO.setVtrantypecode(vtrantypecode);String cbiztypeid = "1001E11000000000WHAO";String busitype = getBusitypeVOById(vtrantypecode);if (busitype != null) {cbiztypeid = busitype;}headerVO.setCbiztypeid(cbiztypeid);tobillVO.setParentVO(headerVO);// 每busitypeVO行明细物料按系统 “内部结算规则“,形成调拨订单价格(税率、无税单价、含税单价、无税金额、价税合计)。ITransOrderForGeneralIn iTransOrderForGeneralIn = NCLocator.getInstance().lookup(ITransOrderForGeneralIn.class);BillVO[] returnvos = null;try {returnvos = iTransOrderForGeneralIn.setDefaultTransOrder(new BillVO[] { tobillVO });} catch (BusinessException e2) {ExceptionUtils.wrappBusinessException("调拨订单设置默认值失败:" + e2.getMessage());}tobillVO = returnvos[0];// 保存调拨订单IplatFormEntry iplatFormEntry = NCLocator.getInstance().lookup(IplatFormEntry.class);ITransOrderMaintain iTransOrderMaintain = NCLocator.getInstance().lookup(ITransOrderMaintain.class);subcontInVO.getHead().setStatus(2);BillVO[] billvo = null;try {billvo = iTransOrderMaintain.insertTransOrder(new BillVO[] { tobillVO });} catch (BusinessException e1) {ExceptionUtils.wrappBusinessException("生成调拨订单保存失败:" + e1.getMessage());}if (billvo != null) {tobillVO = billvo[0];// 回写委托加工入库单vdef8, 是否已经自动调拨try {new BaseDAO().executeUpdate("update ic_subcontin_h set vdef8 ='Y' where vbillcode = '" + headVO.getVbillcode() + "'");} catch (DAOException e1) {ExceptionUtils.wrappBusinessException("回写委托加工入库单失败!" + e1.getMessage());}}// 根据组织参数,是否审批SysInitVO init = null;try {init = SysInitBO_Client.queryByParaCode(pk_org, "IC208");} catch (BusinessException e) {ExceptionUtils.wrappBusinessException("获取业务组织参数 IC208失败!" + e.getMessage());}if (initVO != null && init != null && "已审核".equals(init.getValue())) {try {iplatFormEntry.processAction("APPROVE", vtrantypecode, null, tobillVO, null, null);} catch (BusinessException e) {ExceptionUtils.wrappBusinessException("生成调拨订单审批失败:" + e.getMessage());}}}}/*** 根据pk找仓库* * @param pk* @return*/private StordocVO getStordocVOById(String pk) {StordocVO stordocVO = null;try {stordocVO = (StordocVO) getIUAPQueryBS().retrieveByPK(StordocVO.class, pk);} catch (BusinessException e) {ExceptionUtils.wrappBusinessException("根据pk: " + pk + "找仓库失败:" + e.getMessage());}return stordocVO;}/*** 根据pk找交易类型* * @param pk* @return*/private BilltypeVO getBilltypeVOById(String pk) {BilltypeVO BilltypeVO = null;try {BilltypeVO = (BilltypeVO) getIUAPQueryBS().retrieveByPK(BilltypeVO.class, pk);} catch (BusinessException e) {ExceptionUtils.wrappBusinessException("根据pk: " + pk + "找交易类型失败:" + e.getMessage());}return BilltypeVO;}/*** 根据交易类型code找业务流程* * @param vtrantypecode* @return*/private String getBusitypeVOById(String vtrantypecode) {String busitype = null;String sql = "select pk_busitype from bd_busitype where  primarybilltype= '" + vtrantypecode + "';";try {busitype = (String) getIUAPQueryBS().executeQuery(sql, new ColumnProcessor());} catch (BusinessException e) {ExceptionUtils.wrappBusinessException("根据交易类型code: " + vtrantypecode + "找业务流程失败:" + e.getMessage());}return busitype;}/*** 根据pk_org找组织版本pk_org_v* * @param vtrantypecode* @return*/private String getOrgVidById(String pk_org) {String pk_org_v = null;String sql = "select  pk_vid from org_orgs where dr = 0 and enablestate = 2 and pk_org = '" + pk_org + "'";try {pk_org_v = (String) getIUAPQueryBS().executeQuery(sql, new ColumnProcessor());} catch (BusinessException e) {ExceptionUtils.wrappBusinessException("根据pk_org: " + pk_org + "找组织版本pk_org_v:" + e.getMessage());}return pk_org_v;}private IUAPQueryBS getIUAPQueryBS() {return NCLocator.getInstance().lookup(IUAPQueryBS.class);}/*** 查询物料对应的物料分类code Map<物料pk,物料分类code> panfengc* * @param pks* @return*/private Map<String, String> queryMaterialBaseClassCode(String[] pks) {Map<String, String> map = new HashMap<String, String>();if (pks == null || pks.length == 0)return map;try {// 查询物料对应的物料分类主键Map<String, MaterialVO> mapMaterial = this.getIMaterialPubService_C().queryMaterialBaseInfoByPks(pks,new String[] { MaterialVO.PK_MARBASCLASS });Set<Entry<String, MaterialVO>> setMaterial = mapMaterial.entrySet();List<String> pk_marbasclass_list = new ArrayList<String>();for (Entry<String, MaterialVO> entry : setMaterial) {String Pk_marbasclass = entry.getValue().getPk_marbasclass();pk_marbasclass_list.add(Pk_marbasclass);if (!map.containsKey(entry.getKey())) {map.put(entry.getKey(), Pk_marbasclass);}if (pk_marbasclass_list.size() == 0) {ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4001002_0", "04001002-0410")/** @res "查询物料基本分类出错"*/);}}// 根据物料分类pk查询物料分类VOMarBasClassVO[] basclass = this.queryMaterialBaseClassByPk(pk_marbasclass_list.toArray(new String[0]),false);// 建立 Map pk,code, 循环mapMaterial,组件新的数组Map<String, String> marbasCodehash = new HashMap<String, String>();for (MarBasClassVO marbasvo : basclass) {if (!marbasCodehash.containsKey(marbasvo.getPk_marbasclass())) {marbasCodehash.put(marbasvo.getPk_marbasclass(), marbasvo.getCode());}}// 根据物料分类pk,找对应的物料分类codefor (String pk : pks) {if (map.containsKey(pk)) {String Pk_marbasclass = map.get(pk);if (marbasCodehash.containsKey(Pk_marbasclass)) {String code = marbasCodehash.get(Pk_marbasclass);map.put(pk, code);} elsemap.put(pk, null);}}} catch (BusinessException e) {ExceptionUtils.wrappException(e);}return map;}private IMaterialPubService_C getIMaterialPubService_C() {return NCLocator.getInstance().lookup(IMaterialPubService_C.class);}private MarBasClassVO[] queryMaterialBaseClassByPk(String[] pk_marbasclass, boolean isContainParents) {MarBasClassVO[] aterialBaseClass = null;try {aterialBaseClass = NCLocator.getInstance().lookup(IMaterialBaseClassPubService.class).queryMaterialBaseClassByPks(pk_marbasclass, isContainParents);} catch (BusinessException e) {// 日志异常ExceptionUtils.wrappException(e);}return aterialBaseClass;}
}

取消签字入口注册类

package nc.bs.ic.m47.cancelsign;import nc.bs.ic.general.cancelsign.CancelSignBPTemplate;
import nc.bs.ic.general.cancelsign.ICancelSignBP;
import nc.bs.ic.general.cancelsign.ICancelSignRuleProvider;
import nc.bs.ic.m47.base.BPPlugInPoint;
import nc.bs.ic.m47.cancelsign.rule.AfterCancelSignAutoVerifyRule;
import nc.bs.ic.m47.cancelsign.rule.AfterCancelSignForFI;
import nc.bs.ic.m47.cancelsign.rule.AfterUnsSgnRuleForFinanceProcess;
import nc.bs.ic.m47.cancelsign.rule.BeforeUnSignRuleForVerty;
import nc.bs.ic.m47.cancelsign.rule.M47CheckTo5XCancelSignRule;
import nc.bs.ic.m47.cancelsign.rule.UnSignRuleFor25;
import nc.bs.ic.pub.cancelsign.rule.CancelSignCheckPickedFlag;
import nc.impl.pubapp.pattern.rule.processer.AroundProcesser;
import nc.vo.ic.m47.entity.SubcontInVO;/*** <p> <b>本类主要完成以下功能:</b> <ul> <li>委托加工入库取消签字 </ul>* * @version 6.0* @since 6.0* @author wanghna* @time 2010-10-25 上午09:22:11*/
public class CancelSignBP implements ICancelSignBP<SubcontInVO>,ICancelSignRuleProvider<SubcontInVO> {@Overridepublic SubcontInVO[] cancelSign(SubcontInVO[] vos) {CancelSignBPTemplate<SubcontInVO> cancelSignBP =new CancelSignBPTemplate<SubcontInVO>(BPPlugInPoint.CancelSignAction,this);return cancelSignBP.cancelSign(vos);}@Overridepublic void addAfterRule(SubcontInVO[] vos,AroundProcesser<SubcontInVO> processor) {// 取消签字 删除存货核算的加工入库processor.addAfterRule(new AfterUnsSgnRuleForFinanceProcess());// 取消自动核销  删除对应的单据processor.addAfterRule(new AfterCancelSignAutoVerifyRule());// 委托加工入库签字删除采购副本processor.addAfterRule(new AfterCancelSignForFI());}@Overridepublic void addBeforeRule(SubcontInVO[] vos,AroundProcesser<SubcontInVO> processor) {// 已核销单据不能取消签字//processor.addBeforeRule(new BeforeUnSignRuleForVerty());// 已开票单据不能取消签字processor.addBeforeRule(new UnSignRuleFor25());// 已拣配不能取消签字processor.addBeforeRule(new CancelSignCheckPickedFlag<SubcontInVO>());//已自动生成调拨订单不能取消签字  add by  2020-09-03processor.addBeforeFinalRule(new M47CheckTo5XCancelSignRule());}}

取消签字校验类

package nc.bs.ic.m47.cancelsign.rule;import nc.bs.ic.pub.base.ICRule;
import nc.vo.ic.m47.entity.SubcontInVO;
import nc.vo.ic.m47.entity.SubcontInHeadVO;
import nc.vo.pub.BusinessException;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;/*** * @description 检查是否可取消签字,取消签字前检查: 下游是否生成*              检查是否已经生成下游【调拨订单】,则提示:“存在下游单据,不能取消签字”,签字失败。* @scene 委托加工入库单取消签字* @param 无* * @since v6.5* @author * @version 2020-09-03 */
public class M47CheckTo5XCancelSignRule extends ICRule<SubcontInVO> {/*** 检查执行情况*/public void checkExec(SubcontInVO[] vos) throws BusinessException {SubcontInHeadVO headvo = null;for (SubcontInVO vo : vos) {headvo = vo.getHead();if ("Y".equals(headvo.getVdef8())) {ExceptionUtils.wrappBusinessException("已生成下游调拨订单,不能取消签字");}}}/*** 父类方法重写*/@Overridepublic void process(SubcontInVO[] vos) {try {// 检查执行情况this.checkExec(vos);} catch (Exception e) {ExceptionUtils.wrappException(e);}}
}

另一个是从脚本注入后规则事件
执行以下脚本插入事件类

insert into PUB_PLUGINITEM (DR, INDUSTRYTYPE, IORDER, LOCALTYPE, PK_PLUGINITEM, TS, VCOMPONENTNAME, VDESCRIPTION, VEVENTTYPE, VEXTENDMODULE, VEXTENDPOINTNAME, VEXTENDTYPE, VMODULENAME, VRULECLASS, VTARGETCLASS)
values (0, '~', null, '~', '1001ZZ100000000AOE0P', '2020-09-02 17:00:39', 'm45', '库存采购入库单取消签字校验是否是字段调拨', 'before', 'ic', 'nc.impl.ic.m45.action.CancelSignAction', 'addBefore', 'IC', 'nc.bs.ic.m45.cancelsign.rule.M45CheckTo5XCancelSignRule', null);insert into PUB_PLUGINITEM (DR, INDUSTRYTYPE, IORDER, LOCALTYPE, PK_PLUGINITEM, TS, VCOMPONENTNAME, VDESCRIPTION, VEVENTTYPE, VEXTENDMODULE, VEXTENDPOINTNAME, VEXTENDTYPE, VMODULENAME, VRULECLASS, VTARGETCLASS)
values (0, '~', null, '~', '1001ZZ100000000AOA40', '2020-08-31 14:09:39', 'm45', '采购入库单签字后自动调拨', 'after', 'ic', 'nc.impl.ic.m45.action.SignAction', 'addAfter', 'IC', 'nc.bs.ic.m45.sign.rule.M45AfterSignAuto5XBillVO', null);select * from PUB_PLUGINITEM where VRULECLASS like '%nc.bs.ic.m45%' ORDER BY ts desc;

自动生成调拨订单业务处理类

package nc.bs.ic.m45.sign.rule;import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;import nc.bs.dao.BaseDAO;
import nc.bs.dao.DAOException;
import nc.bs.framework.common.NCLocator;
import nc.impl.pubapp.pattern.rule.IRule;
import nc.itf.ic.transtype.ITransTypeExtendQueryService;
import nc.itf.to.m5x.ITransOrderForGeneralIn;
import nc.itf.to.m5x.ITransOrderMaintain;
import nc.itf.uap.IUAPQueryBS;
import nc.itf.uap.pf.IPfExchangeService;
import nc.itf.uap.pf.IplatFormEntry;
import nc.itf.uap.pf.busiflow.PfButtonClickContext;
import nc.jdbc.framework.processor.ColumnProcessor;
import nc.pub.occnc.syn.common.UFBoolean;
import nc.pubitf.uapbd.IMaterialBaseClassPubService;
import nc.pubitf.uapbd.IMaterialPubService_C;
import nc.ui.pub.para.SysInitBO_Client;
import nc.util.mmf.busi.consts.BillTypeConst;
import nc.vo.bd.material.MaterialVO;
import nc.vo.bd.material.marbasclass.MarBasClassVO;
import nc.vo.bd.stordoc.StordocVO;
import nc.vo.ic.m45.entity.PurchaseInBodyVO;
import nc.vo.ic.m45.entity.PurchaseInHeadVO;
import nc.vo.ic.m45.entity.PurchaseInVO;
import nc.vo.ic.transtype.TransTypeExtendVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.billtype.BilltypeVO;
import nc.vo.pub.lang.UFDouble;
import nc.vo.pub.para.SysInitVO;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
import nc.vo.to.m5x.entity.BillHeaderVO;
import nc.vo.to.m5x.entity.BillItemVO;
import nc.vo.to.m5x.entity.BillVO;/*** * @description 采购入库单签字后生成调拨订单* ** @since 6.5* @version 2020-09-03* @author */
public class M45AfterSignAuto5XBillVO implements IRule<PurchaseInVO> {@Overridepublic void process(PurchaseInVO[] vos) {if ((vos == null) || (vos.length == 0)) {return;}// 2.如果入库实收数量为负,则结束;// 2.如果上游【采购入库单】交易类型“自动内部调拨”参数为“否”,则结束;// 4.如果 【采购入库单】表头仓库档案自定义项6“对方库存组织”为空,则结束;"ITransTypeExtendQueryService queryService = NCLocator.getInstance().lookup(ITransTypeExtendQueryService.class);for (PurchaseInVO purchaseInVO : vos) {PurchaseInHeadVO headVO = purchaseInVO.getHead();PurchaseInBodyVO[] bodyVOs = purchaseInVO.getBodys();String pk_org = headVO.getPk_org();// 1、判断来源单据是否是采购订单-21
//          if (headVO == null || !"21".equals(bodyVOs[0].getCsourcetype())) {//              continue;
//          }// 2判断实收数量为负if (headVO.getNtotalnum() == null || headVO.getNtotalnum().compareTo(UFDouble.ZERO_DBL) < 0) {continue;}// 3如果【采购入库单】交易类型“自动内部调拨”参数为“否”TransTypeExtendVO[] transTypeExtendVO = null;try {transTypeExtendVO = queryService.queryByIds(new String[] { headVO.getCtrantypeid() });} catch (BusinessException e) {ExceptionUtils.wrappBusinessException("获取采购入库单的交易类型出错" + e.getMessage());}if (transTypeExtendVO == null || transTypeExtendVO[0].getAutointrans() == null|| !transTypeExtendVO[0].getAutointrans().booleanValue()) {// 并上自动调拨参数为否continue;}// 4如果本组织的组织级系统参数“入库触发调拨单交易类型”为空,则提示SysInitVO initVO = null;try {initVO = SysInitBO_Client.queryByParaCode(pk_org, "IC205");} catch (BusinessException e) {ExceptionUtils.wrappBusinessException("获取业务组织参数 IC205失败!" + e.getMessage());}if (null == initVO || initVO.getValue() == null) {continue;}// 5如果【采购入库单】表头仓库档案自定义项6“对方库存组织”为空StordocVO stordocVO = this.getStordocVOById(headVO.getCwarehouseid());if (stordocVO == null || stordocVO.getDef6() == null) {continue;}// 6如果【采购入库单】表头仓库档案自定义项7“对方仓库”为空则提示if (stordocVO.getDef7() == null) {continue;}// 调用单据转换规则 采购入库单-调拨订单IPfExchangeService ipfes = NCLocator.getInstance().lookup(IPfExchangeService.class);BillVO[] billVO = null;try {billVO = (BillVO[]) ipfes.runChangeDataAryNeedClassify(BillTypeConst.PURCHASEIN, BillTypeConst.TRAN, new PurchaseInVO[] { purchaseInVO }, null, PfButtonClickContext.ClassifyByBusiflow);} catch (BusinessException e) {ExceptionUtils.wrappBusinessException("走单据转换规则【采购入库单-调拨订单】失败" + e.getMessage());}if (billVO == null) {ExceptionUtils.wrappBusinessException("走单据转换规则没有生成调拨订单");}BillVO tobillVO = billVO[0];// 调入调出组织,仓库设置,物流明细行过滤BillHeaderVO headerVO = tobillVO.getParentVO();BillItemVO[] itemVO = tobillVO.getChildrenVO();if (itemVO == null || itemVO.length <= 0) {ExceptionUtils.wrappBusinessException("走单据转换规则没有生成调拨订单");}ArrayList<BillItemVO> itemVOList = new ArrayList<BillItemVO>();for (BillItemVO bodyVO : itemVO) {//              bodyVO.setVpricerule("1");UFBoolean notZero = UFBoolean.TRUE;if (bodyVO.getNnum() == null && bodyVO.getNastnum() == null) {notZero = UFBoolean.FALSE;}if (bodyVO.getNnum().compareTo(UFDouble.ZERO_DBL) < 0|| bodyVO.getNastnum().compareTo(UFDouble.ZERO_DBL) < 0) {notZero = UFBoolean.FALSE;}if (notZero.booleanValue()) {itemVOList.add(bodyVO);}}tobillVO.setChildrenVO(itemVOList.toArray(new BillItemVO[itemVOList.size()]));headerVO.SetCtrantypeid(initVO.getValue());headerVO.setCinstockorgid(stordocVO.getDef6());String pk_org_v = getOrgVidById(stordocVO.getDef6());headerVO.setCinstockorgvid(pk_org_v);headerVO.setCinfinanceorgid(stordocVO.getDef6());headerVO.setCinfinanceorgvid(pk_org_v);headerVO.setPk_org(pk_org);headerVO.setPk_org_v(headVO.getPk_org_v());headerVO.setCoutfinanceorgid(pk_org);headerVO.setCoutfinanceorgvid(headVO.getPk_org_v());headerVO.setCtoutfinanceorgid(pk_org);headerVO.setCtoutfinanceorgvid(headVO.getPk_org_v());BilltypeVO billtypevo = getBilltypeVOById(initVO.getValue());String vtrantypecode = "5X-Cxx-03";if (billtypevo != null) {vtrantypecode = billtypevo.getPk_billtypecode();}headerVO.setVtrantypecode(vtrantypecode);String cbiztypeid = "1001E11000000000WHAO";String busitype = getBusitypeVOById(vtrantypecode);if (busitype != null) {cbiztypeid = busitype;}headerVO.setCbiztypeid(cbiztypeid);tobillVO.setParentVO(headerVO);// 每busitypeVO行明细物料按系统 “内部结算规则“,形成调拨订单价格(税率、无税单价、含税单价、无税金额、价税合计)。ITransOrderForGeneralIn iTransOrderForGeneralIn = NCLocator.getInstance().lookup(ITransOrderForGeneralIn.class);BillVO[] returnvos = null;try {returnvos = iTransOrderForGeneralIn.setDefaultTransOrder(new BillVO[] { tobillVO });} catch (BusinessException e2) {ExceptionUtils.wrappBusinessException("调拨订单设置默认值失败:" + e2.getMessage());}tobillVO = returnvos[0];// 保存调拨订单IplatFormEntry iplatFormEntry = NCLocator.getInstance().lookup(IplatFormEntry.class);ITransOrderMaintain iTransOrderMaintain = NCLocator.getInstance().lookup(ITransOrderMaintain.class);purchaseInVO.getHead().setStatus(2);BillVO[] billvo = null;try {billvo = iTransOrderMaintain.insertTransOrder(new BillVO[] { tobillVO });} catch (BusinessException e1) {ExceptionUtils.wrappBusinessException("生成调拨订单保存失败:" + e1.getMessage());}if (billvo != null) {tobillVO = billvo[0];// 回写采购入库单vdef8, 是否已经自动调拨try {new BaseDAO().executeUpdate("update ic_purchasein_h set vdef8 ='Y' where vbillcode = '" + headVO.getVbillcode() + "'");} catch (DAOException e1) {ExceptionUtils.wrappBusinessException("回写采购入库单失败!" + e1.getMessage());}}// 根据组织参数,是否审批SysInitVO init = null;try {init = SysInitBO_Client.queryByParaCode(pk_org, "IC206");} catch (BusinessException e) {ExceptionUtils.wrappBusinessException("获取业务组织参数 IC206失败!" + e.getMessage());}if (initVO != null && init != null && "已审核".equals(init.getValue())) {try {iplatFormEntry.processAction("APPROVE", vtrantypecode, null, tobillVO, null, null);} catch (BusinessException e) {ExceptionUtils.wrappBusinessException("生成调拨订单审批失败:" + e.getMessage());}}}}/*** 根据pk找仓库* * @param pk* @return*/private StordocVO getStordocVOById(String pk) {StordocVO stordocVO = null;try {stordocVO = (StordocVO) getIUAPQueryBS().retrieveByPK(StordocVO.class, pk);} catch (BusinessException e) {ExceptionUtils.wrappBusinessException("根据pk: " + pk + "找仓库失败:" + e.getMessage());}return stordocVO;}/*** 根据pk找交易类型* * @param pk* @return*/private BilltypeVO getBilltypeVOById(String pk) {BilltypeVO BilltypeVO = null;try {BilltypeVO = (BilltypeVO) getIUAPQueryBS().retrieveByPK(BilltypeVO.class, pk);} catch (BusinessException e) {ExceptionUtils.wrappBusinessException("根据pk: " + pk + "找交易类型失败:" + e.getMessage());}return BilltypeVO;}/*** 根据交易类型code找业务流程* * @param vtrantypecode* @return*/private String getBusitypeVOById(String vtrantypecode) {String busitype = null;String sql = "select pk_busitype from bd_busitype where  primarybilltype= '" + vtrantypecode + "';";try {busitype = (String) getIUAPQueryBS().executeQuery(sql, new ColumnProcessor());} catch (BusinessException e) {ExceptionUtils.wrappBusinessException("根据交易类型code: " + vtrantypecode + "找业务流程失败:" + e.getMessage());}return busitype;}/*** 根据pk_org找组织版本pk_org_v* * @param vtrantypecode* @return*/private String getOrgVidById(String pk_org) {String pk_org_v = null;String sql = "select  pk_vid from org_orgs where dr = 0 and enablestate = 2 and pk_org = '" + pk_org + "'";try {pk_org_v = (String) getIUAPQueryBS().executeQuery(sql, new ColumnProcessor());} catch (BusinessException e) {ExceptionUtils.wrappBusinessException("根据pk_org: " + pk_org + "找组织版本pk_org_v:" + e.getMessage());}return pk_org_v;}private IUAPQueryBS getIUAPQueryBS() {return NCLocator.getInstance().lookup(IUAPQueryBS.class);}/*** 查询物料对应的物料分类code Map<物料pk,物料分类code> panfengc* * @param pks* @return*/private Map<String, String> queryMaterialBaseClassCode(String[] pks) {Map<String, String> map = new HashMap<String, String>();if (pks == null || pks.length == 0)return map;try {// 查询物料对应的物料分类主键Map<String, MaterialVO> mapMaterial = this.getIMaterialPubService_C().queryMaterialBaseInfoByPks(pks,new String[] { MaterialVO.PK_MARBASCLASS });Set<Entry<String, MaterialVO>> setMaterial = mapMaterial.entrySet();List<String> pk_marbasclass_list = new ArrayList<String>();for (Entry<String, MaterialVO> entry : setMaterial) {String Pk_marbasclass = entry.getValue().getPk_marbasclass();pk_marbasclass_list.add(Pk_marbasclass);if (!map.containsKey(entry.getKey())) {map.put(entry.getKey(), Pk_marbasclass);}if (pk_marbasclass_list.size() == 0) {ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4001002_0", "04001002-0410")/** @res "查询物料基本分类出错"*/);}}// 根据物料分类pk查询物料分类VOMarBasClassVO[] basclass = this.queryMaterialBaseClassByPk(pk_marbasclass_list.toArray(new String[0]),false);// 建立 Map pk,code, 循环mapMaterial,组件新的数组Map<String, String> marbasCodehash = new HashMap<String, String>();for (MarBasClassVO marbasvo : basclass) {if (!marbasCodehash.containsKey(marbasvo.getPk_marbasclass())) {marbasCodehash.put(marbasvo.getPk_marbasclass(), marbasvo.getCode());}}// 根据物料分类pk,找对应的物料分类codefor (String pk : pks) {if (map.containsKey(pk)) {String Pk_marbasclass = map.get(pk);if (marbasCodehash.containsKey(Pk_marbasclass)) {String code = marbasCodehash.get(Pk_marbasclass);map.put(pk, code);} elsemap.put(pk, null);}}} catch (BusinessException e) {ExceptionUtils.wrappException(e);}return map;}private IMaterialPubService_C getIMaterialPubService_C() {return NCLocator.getInstance().lookup(IMaterialPubService_C.class);}private MarBasClassVO[] queryMaterialBaseClassByPk(String[] pk_marbasclass, boolean isContainParents) {MarBasClassVO[] aterialBaseClass = null;try {aterialBaseClass = NCLocator.getInstance().lookup(IMaterialBaseClassPubService.class).queryMaterialBaseClassByPks(pk_marbasclass, isContainParents);} catch (BusinessException e) {// 日志异常ExceptionUtils.wrappException(e);}return aterialBaseClass;}
}

取消签字校验类

package nc.bs.ic.m45.cancelsign.rule;import nc.bs.ic.pub.base.ICRule;
import nc.vo.ic.m45.entity.PurchaseInVO;
import nc.vo.ic.m45.entity.PurchaseInHeadVO;
import nc.vo.pub.BusinessException;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;/*** * @description* 检查是否可取消签字,取消签字前检查:* 下游是否生成* 检查是否已经生成下游【调拨订单】,则提示:“存在下游单据,不能取消签字”,签字失败。* @scene* 采购入库单取消签字* @param* 无* * @since v6.5* @author * @version 2020-09-03 下午04:48:10*/
public class M45CheckTo5XCancelSignRule extends ICRule<PurchaseInVO> {/*** 检查执行情况*/public void checkExec(PurchaseInVO[] vos) throws BusinessException {PurchaseInHeadVO headvo = null;for (PurchaseInVO vo : vos) {headvo = vo.getHead();if ("Y".equals(headvo.getVdef8())) {ExceptionUtils.wrappBusinessException("已生成下游调拨订单,不能取消签字");} }}/*** 父类方法重写*/@Overridepublic void process(PurchaseInVO[] vos) {try {// 检查执行情况this.checkExec(vos);}catch (Exception e) {ExceptionUtils.wrappException(e);}}
}

转库单的逻辑可以根据上面委托加工入库或者采购入库的方式编写

接下来就是单据转换规则的配置
如采购入库单-调拨订单的转换规则配置:
在单据转换规则界面中新增 【采购入库单】转【调拨订单】记录





其他单据依次添加配置。

以上就是大概的流程,如有不对的地方,欢迎留言指出,大家共同学习进步。

NC6 转库单、采购入库单、库存委托入库单签字后自动生成调拨订单相关推荐

  1. 3.20 采购订单自动生成销售订单

    3.20.1   业务方案描述 对于同一企业集团内部的不同法人之间,存在需要调让物料,买方和卖方采用买卖方式进行业务运作和财务核算. 对于买方,按照内部商定的协议价格创建采购订单,按照采购订单收货,按 ...

  2. pil库修改图片大小_Gvcode库:一个更简单的、华人开源的、自动生成验证码的python库...

    1 说明: ===== 1.1 gvcode全称:graphic-verification-code. 1.2 基本介绍,一秒搞懂. 1.3 并对源码进行修改一个小bug,教您如何修改源码,解决bug ...

  3. 如何做好采购计划和库存管理?

    "销售计划不专业且不稳定""准确性低" "目前只按照过往销量和采购周期做安全库存,但欠货和滞销依然严重" 题主的问题其实蛮有代表性的, 也是 ...

  4. antd 的form 表单怎么回显数据_jsonschema-form-vue基于JSONSchema的表单自动生成方案

    现象 作为一名前端开发,「表单开发」是我们的家常便饭,一般我们需要做以下重复性工作: 编写模板 编写校验规则 * 获取数据,提交表单 同时,后台服务也需要编写校验规则,随着业务变动或者沟通不及时,前后 ...

  5. antd vue form 手动校验_jsonschema-form-vue基于JSONSchema的表单自动生成方案

    现象 作为一名前端开发,「表单开发」是我们的家常便饭,一般我们需要做以下重复性工作: 编写模板 编写校验规则 * 获取数据,提交表单 同时,后台服务也需要编写校验规则,随着业务变动或者沟通不及时,前后 ...

  6. 进销存ERP系统、销售单、采购单、退货单、库存管理、库存盘点、调拨、借入、借出、出库、入库、归还单、收款单、付款单、资金流水、销售报表、采购报表、库存报表、财务报表、商品库、电商erp、连锁erp

    进销存ERP系统.销售单.采购单.退货单.库存管理.库存盘点.调拨.借入.借出.出库.入库.归还单.收款单.付款单.资金流水.销售报表.采购报表.库存报表.财务报表.商品库.电商erp.连锁erp A ...

  7. 进销存ERP系统、销售单、采购单、退货单、库存管理、库存盘点、调拨、借入、借出、出库、入库、归还单、收款单、付款单、资金流水、销售报表、采购报表、库存报表、财务报表、商品库、电商erp、连锁erp 1

    进销存ERP系统.销售单.采购单.退货单.库存管理.库存盘点.调拨.借入.借出.出库.入库.归还单.收款单.付款单.资金流水.销售报表.采购报表.库存报表.财务报表.商品库.电商erp.连锁erp A ...

  8. psm进销存管理系统、供应商管理、进货管理、销售管理、仓库管理、采购记录、库存盘点、调拨单、出库单、借入单、进货报表、采购记录、销售往来账、采购往来账、图表分析、人事管理、销售报表、财务报表、rp原型

    psm进销存管理系统.供应商管理.进货管理.销售管理.仓库管理.采购记录.库存盘点.调拨单.出库单.借入单.进货报表.采购记录.销售往来账.采购往来账.图表分析.人事管理.销售报表.财务报表.rp原型 ...

  9. 企业ERP系统、电商erp、企业erp、智慧电商erp、工作台、销售管理、出库、退货、生产管理、生产订单、礼品、资产、员工、库存管理、仓库盘点、物品入库、采购管理、采购订单、采购退货、库存预警、供应商

    企业ERP系统.电商erp.企业erp.智慧电商erp.工作台.销售管理.销售订单.出库.退货.生产管理.生产订单.礼品.资产.员工.库存管理.仓库盘点.物品入库.采购管理.采购订单.采购退货.库存预 ...

  10. eas库存状态调整单不能反审核_石材家装企业采购库存管理流程案例

    石材家装企业采购库存管理流程是以石材企业有ERP系统管理为前提.石材家装企业采购和存货管理是石材企业控制成本的重要工作.本文以某石材家装加工企业实际采购库存管理流程案例,分享给大家. 一.采购流程 1 ...

最新文章

  1. 玩转 iOS 开发:《iOS 设计模式 — 工厂模式》
  2. 【BZOJ】4873: [Shoi2017]寿司餐厅
  3. STM32 基础系列教程 13 – ADC DMA
  4. 听说你们找我很久了?
  5. PHP高并发高负载系统架构
  6. c#中的long类型示例_C#中带示例的带符号字节数组
  7. linux系统中安装python_2. Linux 下安装python
  8. matplotlib.pyplot.savefig(*args, **kwargs)保存图片$close()关闭图片
  9. IntelliJ IDEA 2018.2设置背景图片及透明度
  10. java for 变量赋值_Java 如何引用变量赋值?
  11. 高等代数第3版下 [丘维声 著] 2015年版_义务教育数学课程标准(2011年版)(部分内容)...
  12. js中的new Option默认选中
  13. Macbook pro 2015款 换完硬盘bootcamp 尝试访问启动磁盘设置时出错解决方法
  14. AI-统计学习(11)-改进的迭代算法及拟牛顿法
  15. 优秀实践采购团队的8个要点
  16. 免费空间(免备案,无广告) 1G免费全能空间
  17. 安装win7纯净版系统时,提示缺少所需的CD/DVD驱动器设备驱动程序的解决方案,亲测有效
  18. 大话私服虚拟服务器,大话西游私服服务器
  19. 要善于借势破局——宁向东的清华管理学课第4课
  20. 智能车辆纵向速度跟踪与控制方法研究

热门文章

  1. Mp4Box 常用指令
  2. PostgreSQL 跨数据库实例之间的数据访问
  3. 聊天ai机器人_适用于您网站的14种最佳AI聊天机器人软件(已比较)
  4. 触摸屏学习:利用状态机编程
  5. java: 类StreamTest是公共的, 应在名为 StreamTest.java 的文件中声明
  6. 计算机一级office题库百度云,历年全国计算机等级考试一级MSOffice真题
  7. 8086CPU标志位
  8. VUE 文字转语音播放
  9. 计算机二级Access软件百度云,全国计算机等级考试二级ACCESS练习软件
  10. 第十节 直流变直流电路(DCDC)芯片选型