nc生成临时凭证配置
要实现的功能:
- 审批时生成临时凭证
- 弃审时删除临时凭证
- 前台配置
- 后台配置
- BillReflectorServiceImpl.java
package nc.pubimpl.jych.qtsq.voucher;import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;import nc.impl.pubapp.pattern.data.bill.BillQuery;
import nc.impl.pubapp.pattern.data.bill.tool.BillConcurrentTool;
import nc.pubitf.fip.external.IBillReflectorService;
import nc.vo.fip.external.FipExtendAggVO;
import nc.vo.fip.service.FipRelationInfoVO;
import nc.vo.jych.qthtfksqd.AggQthtfksqdVO;
import nc.vo.pub.BusinessException;
import nc.vo.pubapp.pattern.log.TimeLog;public class BillReflectorServiceImpl implements IBillReflectorService{@Overridepublic Collection<FipExtendAggVO> queryBillByRelations(Collection<FipRelationInfoVO> collection) throws BusinessException {// TODO 自动生成的方法存根Map<String, FipRelationInfoVO> mapInfo = this.getMapRelationInfo(collection);String[] hids =mapInfo.keySet().toArray(new String[mapInfo.keySet().size()]);BillQuery<AggQthtfksqdVO> query =new BillQuery<AggQthtfksqdVO>(AggQthtfksqdVO.class);AggQthtfksqdVO[] bills = query.query(hids);// 加锁BillConcurrentTool tool = new BillConcurrentTool();TimeLog.logStart();tool.lockBill(bills);TimeLog.info("锁定表头、表体主健"); /*-=notranslate=-*/Collection<FipExtendAggVO> fipAggVO = this.createFipMsgVO(bills);return fipAggVO;}private Collection<FipExtendAggVO> createFipMsgVO(AggQthtfksqdVO[] vos) {Collection<FipExtendAggVO> msgvolist = new ArrayList<FipExtendAggVO>();for (AggQthtfksqdVO vo : vos) {// SaleInvoiceBVO[] items = vo.getChildrenVO();FipExtendAggVO msgvo = new FipExtendAggVO();// String cbillbid = items[0].getCsaleinvoicebid();msgvo.setBillVO(vo);msgvo.setRelationID(vo.getPrimaryKey());// FipRelationInfoVO infovo = mapInfo.get(cbillbid);// msgvo.setMessageinfo(infovo);msgvolist.add(msgvo);}return msgvolist;}private Map<String, FipRelationInfoVO> getMapRelationInfo(Collection<FipRelationInfoVO> relationvos) {Map<String, FipRelationInfoVO> map =new HashMap<String, FipRelationInfoVO>();for (FipRelationInfoVO vo : relationvos) {String id = vo.getRelationID();map.put(id, vo);}return map;}
}
- 执行一条sql插入脚本
insert into fip_billregister (BILLDRAWCLASS, BILLREFLECTCLASS, BILLSUMCLASS, CLASS_ENTITY_ID, CTRLORGFINDCLASS, DEFDOC1, DEFDOC2, DEFDOC3, DEFQUERYCLASS, DESBILLSERVCLASS, DESBILLSUMCLASS, DESCTRLRULECLASS, DESSUMRULECLASS, DESSUMRULEENTITY, DESSUMRULEREF, DISPLAYCLASS, DR, DRAWQUERYCLASS, EDITCLASS, LINKQUERYCLASS, MODULECODE, ORG_CTRL_ENTITY1, ORG_CTRL_ENTITY2, ORG_ENTITY_ID, PK_BILLREGISTER, PK_BILLTYPE, PK_GROUP, PK_ORG, TS)
values (null, 'nc.pubimpl.zyzj.loanytlx.voucher.BillReflectorServiceImpl', null, '~', null, '990d709e-deeb-4e73-b526-ee0d173c7870', null, null, null, null, null, null, null, null, null, null, 0, null, null, null, 'zyzj', '~', '~', '~', '0000Z80000000zyzj003', 'H104', '~', '~', '2020-04-21 16:05:53');
--------------------------------------------------------------------------------------------------------------------------------
其中:
'nc.pubimpl.zyzj.loanytlx.voucher.BillReflectorServiceImpl'为新建的一个类
'990d709e-deeb-4e73-b526-ee0d173c7870'为该单据在md_class表中的id字段的值(md_class为该单据元数据的实体表)
'zyzj'为该单据的模块名
'0000Z80000000zyzj003'自行命名,不重复即可
'H104'为该单据的单据类型
- GenQthtsqRule.java
package nc.bs.jych.qthtfksqd.ace.bp.rule;import nc.bs.framework.common.NCLocator;
import nc.impl.pubapp.pattern.rule.IRule;
import nc.pubitf.fip.service.IFipMessageService;
import nc.vo.fip.service.FipMessageVO;
import nc.vo.fip.service.FipRelationInfoVO;
import nc.vo.jych.qthtfksqd.AggQthtfksqdVO;
import nc.vo.jych.qthtfksqd.QthtfksqdVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFDate;
import nc.vo.pub.lang.UFDouble;
import nc.vo.pubapp.AppContext;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
import nc.vo.wgbfb.tool.NullValueUtils;
/*** @author hanh*/
public class GenQthtsqRule implements IRule<AggQthtfksqdVO>{@Overridepublic void process(AggQthtfksqdVO[] aggvos) {// TODO 自动生成的方法存根for (int i = 0; i < aggvos.length; i++) {execute(aggvos[i]);}}private void execute(AggQthtfksqdVO aggvo) {if(aggvo.getParentVO().getBillstatus() != 1){return;}QthtfksqdVO headvo = null;// 传会计平台try {headvo = aggvo.getParentVO();//核定金额UFDouble nmny = headvo.getHdje();UFDate date = AppContext.getInstance().getBusiDate();FipRelationInfoVO infovo = new FipRelationInfoVO();// 组装VOinfovo.setPk_group(headvo.getPk_group());// 集团infovo.setPk_org(headvo.getPk_org());// 组织infovo.setPk_system("H9");// 系统类型infovo.setPk_billtype("QTSQ");// 单据类型或者交易类型infovo.setRelationID(headvo.getPrimaryKey());// 关联号-主键infovo.setPk_operator(headvo.getCreator());// 制单人infovo.setBusidate(date);// 业务日期infovo.setDefdoc1(null);// 自定义关联档案1infovo.setDefdoc2(null);// 自定义关联档案2infovo.setDefdoc3(null);// 自定义关联档案3infovo.setFreedef1(headvo.getVbillno());// 单据号infovo.setFreedef2(headvo.getZy());// 说明、摘要infovo.setFreedef3(NullValueUtils.getNullStringValue(nmny));// 金额infovo.setFreedef4(null);// 自定义项4infovo.setFreedef5(null);// 自定义项5// 消息VOFipMessageVO msgvo = new FipMessageVO();msgvo.setMessagetype(0);// 0是增加,1是删除msgvo.setBillVO(aggvo);msgvo.setMessageinfo(infovo);getService().sendMessage(msgvo);} catch (BusinessException e) {ExceptionUtils.wrappBusinessException("单据"+headvo.getVbillno()+"审核生成凭证出现异常:"+e.getMessage());}}private IFipMessageService service;private IFipMessageService getService(){if(service == null){service = NCLocator.getInstance().lookup(IFipMessageService.class);}return service;}
}
- DeleteQthtsqRule.java
package nc.bs.jych.qthtfksqd.ace.bp.rule;import nc.bs.framework.common.NCLocator;
import nc.impl.pubapp.pattern.rule.IRule;
import nc.pubitf.fip.service.IFipMessageService;
import nc.vo.fip.service.FipMessageVO;
import nc.vo.fip.service.FipRelationInfoVO;
import nc.vo.jych.qthtfksqd.AggQthtfksqdVO;
import nc.vo.jych.qthtfksqd.QthtfksqdVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFDouble;
import nc.vo.pubapp.AppContext;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
import nc.vo.wgbfb.tool.NullValueUtils;
/*** @author hanh*/
public class DeleteQthtsqRule implements IRule<AggQthtfksqdVO>{@Overridepublic void process(AggQthtfksqdVO[] aggvos) {// TODO 自动生成的方法存根for (int i = 0; i < aggvos.length; i++) {execute(aggvos[i]);}}private void execute(AggQthtfksqdVO aggvo) {QthtfksqdVO headvo = null;// 传会计平台try {headvo = aggvo.getParentVO();//核定金额UFDouble nmny = headvo.getHdje();FipRelationInfoVO infovo = new FipRelationInfoVO();// 组装VOinfovo.setPk_group(headvo.getPk_group());// 集团infovo.setPk_org(headvo.getPk_org());// 组织infovo.setPk_system("H9");// 系统类型infovo.setPk_billtype("QTSQ");// 单据类型或者交易类型infovo.setRelationID(headvo.getPrimaryKey());// 关联号-主键infovo.setPk_operator(headvo.getCreator());// 制单人infovo.setBusidate(AppContext.getInstance().getBusiDate());// 业务日期infovo.setDefdoc1(null);// 自定义关联档案1infovo.setDefdoc2(null);// 自定义关联档案2infovo.setDefdoc3(null);// 自定义关联档案3infovo.setFreedef1(headvo.getVbillno());// 单据号infovo.setFreedef2(null);// 说明、摘要infovo.setFreedef3(NullValueUtils.getNullStringValue(nmny));// 核定金额infovo.setFreedef4(null);// 自定义项4infovo.setFreedef5(null);// 自定义项5// 消息VOFipMessageVO msgvo = new FipMessageVO();msgvo.setMessagetype(1);// 0是增加,1是删除msgvo.setBillVO(aggvo);msgvo.setMessageinfo(infovo);getService().sendMessage(msgvo);} catch (BusinessException e) {ExceptionUtils.wrappBusinessException("单据"+headvo.getVbillno()+"弃审删除凭证出现异常:"+e.getMessage());}}private IFipMessageService service;private IFipMessageService getService(){if(service == null){service = NCLocator.getInstance().lookup(IFipMessageService.class);}return service;}
}
- 往审批规则和弃审规则里面引入这两个类
- 前台配置
转换模板找实施配置