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{
@Override
public 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>{
@Override
public 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();
// 组装VO
infovo.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);// 自定义关联档案1
infovo.setDefdoc2(null);// 自定义关联档案2
infovo.setDefdoc3(null);// 自定义关联档案3
infovo.setFreedef1(headvo.getVbillno());// 单据号
infovo.setFreedef2(headvo.getZy());// 说明、摘要
infovo.setFreedef3(NullValueUtils.getNullStringValue(nmny));// 金额
infovo.setFreedef4(null);// 自定义项4
infovo.setFreedef5(null);// 自定义项5
// 消息VO
FipMessageVO 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>{
@Override
public 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();
// 组装VO
infovo.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);// 自定义关联档案1
infovo.setDefdoc2(null);// 自定义关联档案2
infovo.setDefdoc3(null);// 自定义关联档案3
infovo.setFreedef1(headvo.getVbillno());// 单据号
infovo.setFreedef2(null);// 说明、摘要
infovo.setFreedef3(NullValueUtils.getNullStringValue(nmny));// 核定金额
infovo.setFreedef4(null);// 自定义项4
infovo.setFreedef5(null);// 自定义项5
// 消息VO
FipMessageVO 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;
}
}
- 往审批规则和弃审规则里面引入这两个类
- 前台配置
转换模板找实施配置