收票登记导入去掉相关校验

This commit is contained in:
zhangxinah@yonyou.com 2025-03-26 11:27:12 +08:00
parent 56756e5aae
commit c92a651666
3 changed files with 3665 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,344 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package nccloud.impl.fbm.gather.excel;
import java.util.Collection;
import java.util.HashMap;
import nc.bs.framework.common.InvocationInfoProxy;
import nc.bs.framework.common.NCLocator;
import nc.bs.sec.esapi.NCESAPI;
import nc.itf.bd.bankdoc.IBankdocQueryService;
import nc.md.persist.framework.IMDPersistenceQueryService;
import nc.pubitf.bd.accessor.GeneralAccessorFactory;
import nc.pubitf.bd.accessor.IGeneralAccessor;
import nc.vo.bd.accessor.IBDData;
import nc.vo.bd.accessor.bankaccsub.BankaccSubAccessorFactory;
import nc.vo.bd.accessor.bankaccsub.BankaccSubGeneralAccessor;
import nc.vo.bd.bankaccount.BankAccbasVO;
import nc.vo.bd.bankdoc.BankdocVO;
import nc.vo.bd.cust.CustSupplierVersionVO;
import nc.vo.fbm.pub.action.ActionVO;
import nc.vo.fbm.pub.util.FbmCommonTools;
import nc.vo.fbm.pub.util.FbmPublicUtil;
import nc.vo.fbm.register.AggRegisterVO;
import nc.vo.fbm.register.RegisterVO;
import nc.vo.ml.NCLangRes4VoTransl;
import nc.vo.pub.BusinessException;
import nc.vo.pub.CircularlyAccessibleValueObject;
import nc.vo.pub.lang.UFBoolean;
import nc.vo.pub.lang.UFDate;
import nc.vo.pub.lang.UFDateTime;
import nc.vo.pub.lang.UFDouble;
import nc.vo.tmpub.util.StringUtil;
import nc.vo.tmpub.util.TMCustSupUtil;
import nc.vo.tmpub.validator.ExcelImportUtil;
import nc.vo.trade.pub.HYBillVO;
import nc.vo.uap.pf.PFBatchExceptionInfo;
import nc.vo.uap.pf.PfProcessBatchRetObject;
import nccloud.bs.excel.IXChangeContext;
import nccloud.bs.excel.plugin.AbstractImportProceeWithContext;
import nccloud.pubitf.riart.pflow.CloudPFlowContext;
import nccloud.pubitf.riart.pflow.ICloudScriptPFlowService;
public class GatherExcelImport4NCCImpl extends AbstractImportProceeWithContext {
public GatherExcelImport4NCCImpl() {
}
protected void processBillWithContext(Object vo, IXChangeContext changcontext) throws BusinessException {
CircularlyAccessibleValueObject regvo = ((HYBillVO) vo).getParentVO();
AggRegisterVO aggvo = new AggRegisterVO();
aggvo.setParentVO(regvo);
this.check(aggvo);
Object[] results = this.doSave(aggvo);
Object[] var6 = results;
int var7 = results.length;
for (int var8 = 0; var8 < var7; ++var8) {
Object obj = var6[var8];
if (obj instanceof PfProcessBatchRetObject batchObj) {
PFBatchExceptionInfo exceptionInfo = batchObj.getExceptionInfo();
throw new BusinessException(exceptionInfo.getErrorMessage());
}
}
}
private Object[] doSave(AggRegisterVO aggVO) throws BusinessException {
this.doBeforeSave(aggVO);
CloudPFlowContext context = new CloudPFlowContext();
context.setActionName("SAVEBASE");
context.setBillType("36H1");
context.setBillVos(new AggRegisterVO[] { aggVO });
Object[] objects = ((ICloudScriptPFlowService) NCLocator.getInstance().lookup(ICloudScriptPFlowService.class))
.exeScriptPFlow(context);
return objects;
}
private void doBeforeSave(AggRegisterVO aggvo) throws BusinessException {
RegisterVO pvo = aggvo.getparentVO();
UFDateTime businessTime = new UFDateTime(InvocationInfoProxy.getInstance().getBizDateTime());
pvo.setPk_group(InvocationInfoProxy.getInstance().getGroupId());
pvo.setBillmaker(InvocationInfoProxy.getInstance().getUserId());
pvo.setCreationtime(businessTime);
pvo.setDoperatedate(new UFDate(InvocationInfoProxy.getInstance().getBizDateTime()));
pvo.setCreationtime(businessTime);
pvo.setCreator(InvocationInfoProxy.getInstance().getUserId());
pvo.setPk_billtypecode("36H1");
pvo.setGathertype("input");
UFBoolean initflag = pvo.getInitflag();
if (StringUtil.isNull(initflag)) {
pvo.setInitflag(UFBoolean.FALSE);
}
pvo.setSfflag(UFBoolean.FALSE);
pvo.setRegisterstatus("on_gather");
pvo.setVbillstatus(-1);
pvo.setRelatedrecbill(UFBoolean.FALSE);
UFBoolean disableflag = pvo.getDisableflag();
if (disableflag == null || !disableflag.booleanValue()) {
pvo.setDisableflag(UFBoolean.FALSE);
}
pvo.setBookflag(UFBoolean.FALSE);
pvo.setPlanflag(UFBoolean.FALSE);
String pk_org = pvo.getPk_org();
if (StringUtil.isNotNull(pvo.getReceiveaccount())) {
BankAccbasVO accbasVO = this.getBankAccbasVOByReceiveaccount(pvo);
String var10002;
if (accbasVO.getEnablestate() != 2) {
var10002 = pvo.getFbmbillno();
throw new BusinessException(
var10002 + NCLangRes4VoTransl.getNCLangRes().getStrByID("3618ncc_0", "03618ncc-0078"));
}
//zhangxinah 去掉银行账户是否电票签约账户的校验
// if (!accbasVO.getIsenableelecbill().booleanValue()) {
// var10002 = pvo.getFbmbillno();
// throw new BusinessException(
// var10002 + NCLangRes4VoTransl.getNCLangRes().getStrByID("3618ncc_0", "03618ncc-0079"));
// }
BankdocVO bankdoc = this.getBanktypeByReceiveaccount(pvo.getReceiveaccount());
pvo.setPk_banktype(bankdoc.getPk_banktype());
pvo.setReceiveaccountname(bankdoc.getName());
}
IGeneralAccessor bankdocAccessor = GeneralAccessorFactory.getAccessor("bf5aeed4-6b35-4a2e-b750-b9aabce59e21");
BankaccSubGeneralAccessor bankaccsubAccessor = (BankaccSubGeneralAccessor) (new BankaccSubAccessorFactory())
.getAccessor("9e10ef4a-0be9-482b-880f-871e5b0504b7");
IGeneralAccessor assLineNumAccessor = GeneralAccessorFactory
.getAccessor("7b6c7dc0-db78-4bef-9cca-f5af4008f893");
TMCustSupUtil.setCustSupPk(aggvo, "paybillunit_v", "paybillunit", "hidepaybillunit");
CustSupplierVersionVO custSupVO;
if (StringUtil.isNotNull(pvo.getPayunit())) {
custSupVO = TMCustSupUtil.getCustSupplierVersionVOByNameAndDate(pvo.getPayunit(), pvo.getGatherdate());
if (custSupVO != null) {
pvo.setHidepayunit(custSupVO.getPk_cust_sup());
pvo.setHidepayunit_v(custSupVO.getPk_cust_sup_v());
}
}
if (StringUtil.isNotNull(pvo.getReceiveunit())) {
custSupVO = TMCustSupUtil.getCustSupplierVersionVOByNameAndDate(pvo.getReceiveunit(), pvo.getGatherdate());
if (custSupVO != null) {
pvo.setHidereceiveunit(custSupVO.getPk_cust_sup());
pvo.setHidereceiveunit_v(custSupVO.getPk_cust_sup_v());
}
}
if (StringUtil.isNotNull(pvo.getReceivebankacc())) {
IBDData cussup = bankaccsubAccessor.getDocByAccnum(pvo.getReceivebankacc(), pvo.getPk_curr());
if (cussup != null) {
pvo.setHidereceivebankacc(cussup.getPk());
}
}
if (StringUtil.isNotNull(pvo.getReceivebank())) {
IBDData cussup = bankdocAccessor.getDocByNameWithMainLang(pk_org, pvo.getReceivebank());
if (cussup != null) {
pvo.setHidereceivebank(cussup.getPk());
}
}
boolean busType = FbmPublicUtil.isBusType(pvo.getFbmbilltype());
IBDData cussup = null;
if (busType) {
if (StringUtil.isNotNull(pvo.getAcceptorname())) {
custSupVO = TMCustSupUtil.getCustSupplierVersionVOByNameAndDate(pvo.getAcceptorname(),
pvo.getGatherdate());
if (custSupVO != null) {
pvo.setPk_signagrbank(custSupVO.getPk_cust_sup());
pvo.setPk_signagrbank_v(custSupVO.getPk_cust_sup_v());
}
}
} else if (StringUtil.isNotNull(pvo.getAcceptorname())) {
cussup = bankdocAccessor.getDocByNameWithMainLang(pk_org, pvo.getAcceptorname());
if (cussup != null) {
pvo.setSignagrbank(cussup.getPk());
}
}
if (StringUtil.isNotNull(pvo.getSignagrbanknum())) {
cussup = assLineNumAccessor.getDocByCode(pk_org, pvo.getSignagrbanknum());
if (cussup != null) {
pvo.setAcceptorbankaccount(cussup.getPk());
}
}
if (StringUtil.isNotNull(pvo.getSignagrbankname())) {
cussup = bankdocAccessor.getDocByNameWithMainLang(pk_org, pvo.getSignagrbankname());
if (cussup != null) {
pvo.setAcceptorbank(cussup.getPk());
}
}
UFBoolean subcontractCirculation = pvo.getSubcontractcirculation();
boolean ifBelongNewbillSys = FbmCommonTools.ifBelongNewBillSystem(pvo.getFbmbillno());
if (ifBelongNewbillSys && subcontractCirculation != null && subcontractCirculation.booleanValue()) {
String var10001 = pvo.getBillrangestart();
pvo.setBillrange(var10001 + "-" + pvo.getBillrangeend());
} else if (ifBelongNewbillSys) {
if (!"0".equals(pvo.getBillrangestart()) || !"0".equals(pvo.getBillrangeend())) {
throw new BusinessException("票据[" + pvo.getFbmbillno() + "]为新一代票且不可分包流转子票区间开始和结束应为0");
}
pvo.setBillrange(String.valueOf("0"));
} else {
pvo.setBillrange((String) null);
}
pvo.setBillsystype(FbmCommonTools.getBillSysTypeByFbmBillNo(pvo.getFbmbillno()));
UFDouble availablemoney = pvo.getAvailablemoney();
if (availablemoney == null) {
pvo.setAvailablemoney(pvo.getMoney());
}
HashMap<String, String> voFieldsMap = new HashMap();
voFieldsMap.put("groupField", "pk_group");
voFieldsMap.put("orgField", "pk_org");
voFieldsMap.put("currField", "pk_curr");
voFieldsMap.put("rateField", "olcrate");
voFieldsMap.put("custsupField", "paybillunit");
voFieldsMap.put("dateField", "gatherdate");
FbmPublicUtil.setOlcRate4Import(aggvo, voFieldsMap);
voFieldsMap.put("rateField", "glcrate");
FbmPublicUtil.setGlcRate4Import(aggvo, voFieldsMap);
voFieldsMap.put("rateField", "gllcrate");
FbmPublicUtil.setGllcRate4Import(aggvo, voFieldsMap);
GatherReCaculateMnyUtil.recaculate(false, new AggRegisterVO[] { aggvo });
ExcelImportUtil.validateOlcratetype(pvo.getOlcratetype(), pvo.getOlcratecategory());
}
private void check(AggRegisterVO aggvo) throws BusinessException {
RegisterVO registerVO = aggvo.getparentVO();
String fbmbillno = registerVO.getFbmbillno();
UFBoolean cyberbankflag = registerVO.getCyberbankflag();
if (cyberbankflag != null && !cyberbankflag.booleanValue()) {
String pk_bankdoc = registerVO.getPk_bankdoc();
if (!StringUtil.isNull(pk_bankdoc)) {
throw new BusinessException(
fbmbillno + NCLangRes4VoTransl.getNCLangRes().getStrByID("3618ncc_0", "03618ncc-0042"));
}
}
UFDate gatherdate = registerVO.getGatherdate();
UFDate invoicedate = registerVO.getInvoicedate();
if (gatherdate != null && invoicedate != null
&& gatherdate.toStdString().compareTo(invoicedate.toStdString()) < 0) {
throw new BusinessException(
fbmbillno + NCLangRes4VoTransl.getNCLangRes().getStrByID("3618ncc_0", "03618ncc-0043"));
} else {
UFDouble money = registerVO.getMoney();
if (money != null && money.doubleValue() < 0.0) {
throw new BusinessException(
fbmbillno + NCLangRes4VoTransl.getNCLangRes().getStrByID("3618ncc_0", "03618ncc-0080"));
} else {
UFDate enddate = registerVO.getEnddate();
if (enddate != null && invoicedate != null
&& enddate.toStdString().compareTo(invoicedate.toStdString()) < 0) {
throw new BusinessException(
fbmbillno + NCLangRes4VoTransl.getNCLangRes().getStrByID("3618ncc_0", "03618ncc-0046"));
} else {
String fbmbilltype = registerVO.getFbmbilltype();
String receiveaccount = registerVO.getReceiveaccount();
boolean isEbill = FbmCommonTools.isEBill(fbmbilltype);
if (isEbill) {
if (StringUtil.isNull(receiveaccount)) {
throw new BusinessException(fbmbillno
+ NCLangRes4VoTransl.getNCLangRes().getStrByID("3618ncc_0", "03618ncc-0051"));
}
} else {
UFBoolean onlinebankflag = registerVO.getOnlinebankflag();
if (onlinebankflag != null && onlinebankflag.booleanValue()) {
throw new BusinessException(fbmbillno
+ NCLangRes4VoTransl.getNCLangRes().getStrByID("3618ncc_0", "03618ncc-0072"));
}
}
FbmCommonTools.validBillRange(registerVO, isEbill);
FbmCommonTools.billNoValication(fbmbillno);
this.checkIsReturnedBill(registerVO);
}
}
}
}
private void checkIsReturnedBill(RegisterVO registerVO) throws BusinessException {
StringBuffer whereSql = new StringBuffer();
whereSql.append(" pk_org = '").append(registerVO.getPk_org()).append("' ");
whereSql.append(" and fbmbillno = '").append(registerVO.getFbmbillno()).append("' ");
if (StringUtil.isNull(registerVO.getBillrangestart())) {
whereSql.append(" and isnull(billrangestart, '0') = '0' ");
} else {
whereSql.append(" and billrangestart <= '").append(registerVO.getBillrangestart()).append("' ");
}
if (StringUtil.isNull(registerVO.getBillrangeend())) {
whereSql.append(" and isnull(billrangeend, '0') = '0' ");
} else {
whereSql.append(" and billrangeend >= '").append(registerVO.getBillrangeend()).append("' ");
}
whereSql.append(" and ( endstatus = 'register' or endstatus = 'has_paybill' ) ");
Collection<ActionVO> actionVOs = ((IMDPersistenceQueryService) NCLocator.getInstance()
.lookup(IMDPersistenceQueryService.class))
.queryBillOfVOByCond(ActionVO.class, whereSql.toString(), false);
boolean returnedBill = false;
if (null != actionVOs && actionVOs.size() > 0) {
returnedBill = true;
}
registerVO.setReturnedbill(UFBoolean.valueOf(returnedBill));
}
private BankAccbasVO getBankAccbasVOByReceiveaccount(RegisterVO pvo) throws BusinessException {
StringBuffer whereSql = new StringBuffer();
whereSql.append(" pk_bankaccbas = (select pk_bankaccbas from bd_bankaccsub where pk_bankaccsub = '");
whereSql.append(NCESAPI.sqlEncode(pvo.getReceiveaccount()));
whereSql.append("' ) ");
IMDPersistenceQueryService service = (IMDPersistenceQueryService) NCLocator.getInstance()
.lookup(IMDPersistenceQueryService.class);
Collection<BankAccbasVO> accbasVOs = service.queryBillOfVOByCond(BankAccbasVO.class, whereSql.toString(),
false);
if (accbasVOs != null && accbasVOs.size() > 0
&& ((BankAccbasVO[]) accbasVOs.toArray(new BankAccbasVO[0]))[0] != null) {
return ((BankAccbasVO[]) accbasVOs.toArray(new BankAccbasVO[0]))[0];
} else {
String var10002 = pvo.getFbmbillno();
throw new BusinessException(
var10002 + NCLangRes4VoTransl.getNCLangRes().getStrByID("3618ncc_0", "03618ncc-0077"));
}
}
private BankdocVO getBanktypeByReceiveaccount(String receiveaccount) throws BusinessException {
StringBuffer whereSql = new StringBuffer();
whereSql.append(" pk_bankdoc = (select pk_bankdoc from bd_bankaccbas where pk_bankaccbas = ");
whereSql.append("(select pk_bankaccbas from bd_bankaccsub where pk_bankaccsub = '");
whereSql.append(NCESAPI.sqlEncode(receiveaccount));
whereSql.append("') ) ");
BankdocVO[] bankdocVO = ((IBankdocQueryService) NCLocator.getInstance().lookup(IBankdocQueryService.class))
.queryBankdocVOsByCon(whereSql.toString());
return bankdocVO != null && bankdocVO.length != 0 ? bankdocVO[0] : null;
}
}

View File

@ -0,0 +1,679 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package nc.vo.fbm.pub.util;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.regex.Pattern;
import nc.bs.framework.common.NCLocator;
import nc.itf.fbm.gather.IGatherQueryService;
import nc.md.model.MetaDataException;
import nc.md.persist.framework.IMDPersistenceQueryService;
import nc.pub.templet.converter.util.helper.ExceptionUtils;
import nc.pubitf.uapbd.IRateTypePubService;
import nc.vo.bd.notetype.NotetypeVO;
import nc.vo.bd.ratetype.RateTypeVO;
import nc.vo.fbm.register.AggRegisterVO;
import nc.vo.fbm.register.RegisterVO;
import nc.vo.fbm.util.BillRangeTools;
import nc.vo.ml.NCLangRes4VoTransl;
import nc.vo.pub.AggregatedValueObject;
import nc.vo.pub.BusinessException;
import nc.vo.pub.CircularlyAccessibleValueObject;
import nc.vo.pub.ISuperVO;
import nc.vo.pub.SuperVO;
import nc.vo.pub.lang.UFBoolean;
import nc.vo.pub.lang.UFDouble;
import nc.vo.pubapp.pattern.model.entity.bill.AbstractBill;
import nc.vo.tmpub.util.StringUtil;
import nc.vo.tmpub.util.TMCurrencyUtil;
import nccloud.itf.fbm.gather.GatherConstant;
import nccloud.itf.fbm.pub.IFBMCommonService4NCC;
import nccloud.pubitf.tmpub.pub.ITMPrecisionServiceForNCC;
import nccloud.vo.tmpub.precison.PrecisionField;
import org.apache.commons.codec.binary.StringUtils;
public class FbmCommonTools {
private static final IFBMCommonService4NCC commonService = (IFBMCommonService4NCC) NCLocator.getInstance()
.lookup(IFBMCommonService4NCC.class);
public FbmCommonTools() {
}
public static boolean isEBill(String pk_fbmBilltype) {
return commonService.isEBill(pk_fbmBilltype);
}
public static boolean isEBillByPk_register(String pk_register) {
try {
return commonService.isEcdNoteClass(pk_register);
} catch (BusinessException var2) {
BusinessException e = var2;
ExceptionUtils.wrapException(e);
return false;
}
}
public static boolean isBankType(String pk_fbmBilltype) {
return commonService.isBankType(pk_fbmBilltype);
}
public static boolean isBusType(String pk_fbmBilltype) {
return commonService.isBusType(pk_fbmBilltype);
}
public static String getfbmbilltypeByNo(String fbmbillno) throws BusinessException {
String flag = null;
String type = null;
boolean isEbill = true;
if (fbmbillno.length() == 16) {
flag = String.valueOf(fbmbillno.charAt(6));
isEbill = false;
} else if (fbmbillno.length() == 30) {
flag = String.valueOf(fbmbillno.charAt(0));
}
Objects.requireNonNull(flag);
if (isEbill) {
switch (flag) {
case "5" -> type = "FBMTZ6E0000000000003";
case "6" -> type = "FBMTZ6E0000000000004";
case "1" -> type = "FBMTZ6E0000000000003";
case "2" -> type = "FBMTZ6E0000000000004";
}
} else {
switch (flag) {
case "5" -> type = "FBMTZ6E0000000000001";
case "6" -> type = "FBMTZ6E0000000000002";
}
}
return type;
}
public static void setSubcontractcirculation(RegisterVO registerVO, String fbmbilltype) throws MetaDataException {
if (!StringUtil.isNull(fbmbilltype)) {
String condtion = "PK_NOTETYPE = '" + fbmbilltype + "'";
Collection<NotetypeVO> collection = ((IMDPersistenceQueryService) NCLocator.getInstance()
.lookup(IMDPersistenceQueryService.class)).queryBillOfVOByCond(NotetypeVO.class, condtion, false);
if (collection != null && collection.size() > 0) {
NotetypeVO notetypeVO = (NotetypeVO) collection.iterator().next();
if (notetypeVO.getNoteclass() == 9) {
registerVO.setSubcontractcirculation(UFBoolean.TRUE);
registerVO.setBillrangestart("000000000000");
registerVO.setBillrangeend("000000000000");
} else if (notetypeVO.getNoteclass() == 2) {
registerVO.setSubcontractcirculation(UFBoolean.FALSE);
}
}
}
}
public static String getPKBilltypeByCode(String billtypeCode) throws Exception {
return commonService.getPKBilltypeByCode(billtypeCode);
}
public static String getCodeByPKBilltype(String pk_billtype) throws BusinessException {
return commonService.getCodeByPKBilltype(pk_billtype);
}
public static void billNoValication(String fbmbillno) throws BusinessException {
if (fbmbillno != null && fbmbillno.length() != 0) {
Pattern blankCheck = Pattern.compile("\\s*|\t|\r|\n");
if (blankCheck.matcher(fbmbillno) == null) {
throw new BusinessException(
fbmbillno + NCLangRes4VoTransl.getNCLangRes().getStrByID("3618nccd_0", "03618nccd--186"));
} else {
// zhangxinah 去掉收票登记导入时票据长度校验
// checkFbmbillnoLength(fbmbillno);
if (fbmbillno.length() > 16) {
eBillNoCheck(fbmbillno);
} else {
paperBillCheck(fbmbillno);
}
}
} else {
throw new BusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("3618nccd_0", "03618nccd--187"));
}
}
public static void checkFbmbillnoLength(String fbmbillno) throws BusinessException {
if (fbmbillno.length() != 30 && fbmbillno.length() != 16) {
throw new BusinessException(
fbmbillno + NCLangRes4VoTransl.getNCLangRes().getStrByID("3618nccd_0", "03618nccd--185"));
}
}
public static void checkFbmbillnoByIsEbill(String fbmbillno, boolean isEbill) throws BusinessException {
if (isEbill) {
if (fbmbillno != null && fbmbillno.length() != 30) {
throw new BusinessException(
NCLangRes4VoTransl.getNCLangRes().getStrByID("3618nccd_0", "03618nccd--185"));
}
} else if (fbmbillno != null && fbmbillno.length() != 16) {
throw new BusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("3618nccd_0", "03618nccd--185"));
}
}
private static void paperBillCheck(String fbmbillno) throws BusinessException {
Pattern pattern = Pattern.compile("\\d{16}");
Boolean ismatch = pattern.matcher(fbmbillno).matches();
if (!ismatch) {
throw new BusinessException(
fbmbillno + NCLangRes4VoTransl.getNCLangRes().getStrByID("3618nccd_0", "03618nccd--184"));
} else {
String bankCode = fbmbillno.substring(0, 3);
String provinceCode = fbmbillno.substring(4, 6);
String billtypeCode = fbmbillno.substring(6, 7);
String printCode = fbmbillno.substring(7, 8);
if (!"00".equals(provinceCode)) {
throw new BusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("3618nccd_0", "03618nccd--183",
(String) null, new String[] { String.valueOf(fbmbillno) }));
} else if (!"5".equals(billtypeCode) && !"6".equals(billtypeCode)) {
throw new BusinessException(
fbmbillno + NCLangRes4VoTransl.getNCLangRes().getStrByID("3618nccd_0", "03618nccd--182"));
} else if ("6".equals(billtypeCode) && !"001".equals(bankCode)) {
throw new BusinessException(
fbmbillno + NCLangRes4VoTransl.getNCLangRes().getStrByID("3618nccd_0", "03618nccd--181"));
} else if ("7".equals(printCode) || "8".equals(printCode) || "9".equals(printCode)) {
throw new BusinessException(
fbmbillno + NCLangRes4VoTransl.getNCLangRes().getStrByID("3618nccd_0", "03618nccd--180"));
}
}
}
private static void eBillNoCheck(String fbmno) throws BusinessException {
Pattern pattern = Pattern.compile("\\d{30}");
Boolean ismatch = pattern.matcher(fbmno).matches();
// 电票不校验票据号长度
ismatch = true;
if (!ismatch) {
throw new BusinessException(
fbmno + NCLangRes4VoTransl.getNCLangRes().getStrByID("3618nccd_0", "03618nccd--179"));
} else {
String firstNum = fbmno.substring(0, 1);
if (!"2".equals(firstNum) && !"1".equals(firstNum) && !"5".equals(firstNum) && !"6".equals(firstNum)) {
throw new BusinessException(
fbmno + NCLangRes4VoTransl.getNCLangRes().getStrByID("3618nccd_0", "03618nccd--178"));
} else {
int year = Integer.parseInt(fbmno.substring(13, 17));
int month = Integer.parseInt(fbmno.substring(17, 19));
int day = Integer.parseInt(fbmno.substring(19, 21));
if (month > 0 && month <= 12) {
if (year % 4 == 0 && month == 2 && (day <= 0 || day > 29)) {
throw new BusinessException(
fbmno + NCLangRes4VoTransl.getNCLangRes().getStrByID("3618nccd_0", "03618nccd-0243"));
} else if (year % 4 == 0 || month != 2 || day > 0 && day <= 28) {
Integer[] bigMonthArray = new Integer[] { 1, 3, 5, 7, 8, 10, 12 };
Integer[] smallMonthArray = new Integer[] { 4, 6, 9, 11 };
List<Integer> bigMonth = Arrays.asList(bigMonthArray);
List<Integer> smallMonth = Arrays.asList(smallMonthArray);
if (!bigMonth.contains(month) || day > 0 && day <= 31) {
if (smallMonth.contains(month) && (day <= 0 || day > 30)) {
throw new BusinessException(fbmno
+ NCLangRes4VoTransl.getNCLangRes().getStrByID("3618nccd_0", "03618nccd-0243"));
}
} else {
throw new BusinessException(fbmno
+ NCLangRes4VoTransl.getNCLangRes().getStrByID("3618nccd_0", "03618nccd-0243"));
}
} else {
throw new BusinessException(
fbmno + NCLangRes4VoTransl.getNCLangRes().getStrByID("3618nccd_0", "03618nccd-0243"));
}
} else {
throw new BusinessException(
fbmno + NCLangRes4VoTransl.getNCLangRes().getStrByID("3618nccd_0", "03618nccd-0243"));
}
}
}
}
public String getBankdocPkByAccessorAndName(String pk_org, String name) throws BusinessException {
return commonService.getBankdocPkByAccessorAndName(pk_org, name);
}
public String getAssLineNumPkByAccessorAndName(String pk_org, String name) throws BusinessException {
return commonService.getAssLineNumPkByAccessorAndName(pk_org, name);
}
public String getBankaccsubPkByAccessorAndName(String name, String pk_curr) throws BusinessException {
return commonService.getBankaccsubPkByAccessorAndName(name, pk_curr);
}
public static AbstractBill resetProcessAmounts(AggregatedValueObject aggregvo, AbstractBill destAggvo,
List<PrecisionField> headPrecisionFields,
Map<Class<? extends ISuperVO>, List<PrecisionField>> bodyPrecisionFields, String errmsg)
throws BusinessException {
if (destAggvo == null) {
return null;
} else {
new Object();
new Object();
new Object();
new Object();
SuperVO destHeadVO = (SuperVO) destAggvo.getParentVO();
Object olcratecategoryObj;
Object olcratedate;
Object olcratetype;
Object olcrate;
if (aggregvo != null) {
SuperVO srcHeadVO = (SuperVO) aggregvo.getParentVO();
olcratecategoryObj = srcHeadVO.getAttributeValue("olcratecategory");
olcratedate = srcHeadVO.getAttributeValue("olcratedate");
olcratetype = srcHeadVO.getAttributeValue("olcratetype");
olcrate = srcHeadVO.getAttributeValue("olcrate");
} else {
olcratecategoryObj = destHeadVO.getAttributeValue("olcratecategory");
olcratedate = destHeadVO.getAttributeValue("olcratedate");
olcratetype = destHeadVO.getAttributeValue("olcratetype");
olcrate = destHeadVO.getAttributeValue("olcrate");
}
String billtype = (String) destHeadVO.getAttributeValue("pk_billtypecode");
Integer olcratecategory = null;
if (olcratecategoryObj != null) {
olcratecategory = (Integer) olcratecategoryObj;
} else if (olcratecategoryObj == null && olcratetype != null) {
IRateTypePubService service = (IRateTypePubService) NCLocator.getInstance()
.lookup(IRateTypePubService.class);
RateTypeVO[] rateTypeVOs = service.queryRateTypeByPKs(new String[] { (String) olcratetype });
if (rateTypeVOs != null && rateTypeVOs.length != 0) {
olcratecategory = rateTypeVOs[0].getRate_category();
}
}
destHeadVO.setAttributeValue("olcratetype", olcratetype);
boolean isResetRate = true;
if (olcratecategory != null && TMCurrencyUtil.judgeRatecategory(olcratecategory)) {
destHeadVO.setAttributeValue("olcratedate", olcratedate);
destHeadVO.setAttributeValue("olcratecategory", olcratecategoryObj);
destHeadVO.setAttributeValue("olcrate", olcrate);
if (!StringUtil.isNull(billtype) && (billtype.equals("36HA") || billtype.equals("36HK"))) {
destHeadVO.setAttributeValue("olcbrate", olcrate);
}
FbmPublicUtil.copyRateTyefieldsHead2Body(destAggvo);
isResetRate = false;
}
AbstractBill[] returnAggvos = ((ITMPrecisionServiceForNCC) NCLocator.getInstance()
.lookup(ITMPrecisionServiceForNCC.class)).processAggVOPrecision(new AbstractBill[] { destAggvo },
headPrecisionFields, bodyPrecisionFields, isResetRate, true);
boolean notHasOlcrate = false;
if (!StringUtil.isNull(billtype) && (billtype.equals("36HA") || billtype.equals("36HK"))) {
if (StringUtil.isNull(destAggvo.getParent().getAttributeValue("olcbrate"))) {
notHasOlcrate = true;
}
} else if (StringUtil.isNull(destAggvo.getParent().getAttributeValue("olcrate"))) {
notHasOlcrate = true;
}
if (notHasOlcrate) {
throw new BusinessException(errmsg);
} else {
return returnAggvos[0];
}
}
}
public static void validRepeatBill(RegisterVO registerVO) throws BusinessException {
String fbmBillNo = registerVO.getFbmbillno();
if (registerVO.getSubcontractcirculation() != null
&& !registerVO.getSubcontractcirculation().equals(UFBoolean.FALSE)
&& registerVO.getPk_register() == null) {
Integer billrangestart = BillRangeTools.handleBillRange(registerVO.getBillrangestart());
Integer billrangeend = BillRangeTools.handleBillRange(registerVO.getBillrangeend());
String condition = "FBMBILLNO = '" + fbmBillNo + "'";
Collection<AggRegisterVO> collections = ((IMDPersistenceQueryService) NCLocator.getInstance()
.lookup(IMDPersistenceQueryService.class))
.queryBillOfVOByCond(AggRegisterVO.class, condition, false);
if (collections != null && collections.size() > 0) {
Iterator var6 = collections.iterator();
while (var6.hasNext()) {
AggRegisterVO aggAllocateAgreeVO = (AggRegisterVO) var6.next();
RegisterVO register = aggAllocateAgreeVO.getparentVO();
if (billrangestart != null && billrangeend != null && register.getBillrangeend() != null
&& register.getBillrangestart() != null
&& (BillRangeTools.handleBillRange(register.getBillrangeend()) <= billrangeend
&& BillRangeTools.handleBillRange(register.getBillrangeend()) >= billrangestart
|| BillRangeTools.handleBillRange(register.getBillrangestart()) >= billrangestart
&& BillRangeTools
.handleBillRange(register.getBillrangestart()) <= billrangeend)) {
throw new BusinessException(
"票据号码" + fbmBillNo + "子票区间" + billrangestart + "-" + billrangeend + "已存在");
}
}
}
}
}
public static void validateAmount(RegisterVO registerVO) throws BusinessException {
if (registerVO.getSubcontractcirculation() != null
&& !registerVO.getSubcontractcirculation().equals(UFBoolean.FALSE)) {
Integer billrangestart = BillRangeTools.handleBillRange(registerVO.getBillrangestart());
Integer billrangeend = BillRangeTools.handleBillRange(registerVO.getBillrangeend());
UFDouble money = registerVO.getMoney();
if (billrangestart != null && billrangeend != null) {
Integer total = billrangeend - billrangestart + 1;
UFDouble count = (new UFDouble("0.01")).multiply((double) total);
if (count.compareTo(money) != 0) {
throw new BusinessException("票据号码" + registerVO.getFbmbillno() + "子票区间" + billrangestart + "-"
+ billrangeend + "的金额" + count.toString() + "与票据金额不相等,请修改");
}
}
}
}
public static void setBillRange(RegisterVO registerVO) {
Boolean isSplitAllowed = registerVO.getSubcontractcirculation() != null
&& registerVO.getSubcontractcirculation().booleanValue();
if (isSplitAllowed) {
String var10001 = registerVO.getBillrangestart();
registerVO.setBillrange(var10001 + "-" + registerVO.getBillrangeend());
} else if (ifBelongNewBillSystem(registerVO.getFbmbillno())) {
registerVO.setBillrange("0");
}
}
private static ITMPrecisionServiceForNCC getPrecisionService() {
return (ITMPrecisionServiceForNCC) NCLocator.getInstance().lookup(ITMPrecisionServiceForNCC.class);
}
private static RegisterVO calcMoneyPrecision(RegisterVO registerVO, UFDouble money) throws BusinessException {
RegisterVO newRegisterVO = new RegisterVO();
newRegisterVO.setOlcmoney(registerVO.getOlcmoney());
newRegisterVO.setOlcrate(registerVO.getOlcrate());
newRegisterVO.setGlcmoney(registerVO.getGlcmoney());
newRegisterVO.setGlcrate(registerVO.getGlcrate());
newRegisterVO.setGllcmoney(registerVO.getGllcmoney());
newRegisterVO.setGllcrate(registerVO.getGllcrate());
newRegisterVO.setGatherdate(registerVO.getGatherdate());
newRegisterVO.setPk_curr(registerVO.getPk_curr());
newRegisterVO.setPaybillunit(registerVO.getPaybillunit());
newRegisterVO.setMoney(money);
getPrecisionService().processHeadPrecision(newRegisterVO,
GatherConstant.getHeadPrecisionFieldsWithFieldRateType(), true);
return newRegisterVO;
}
public static void validBillRange(RegisterVO registerVO, boolean isEbill) throws BusinessException {
UFBoolean subcontractCirculation = registerVO.getSubcontractcirculation();
if (subcontractCirculation != null && subcontractCirculation.booleanValue()) {
label101: {
String billRangeStart = registerVO.getBillrangestart();
String billRangeEnd = registerVO.getBillrangeend();
String firstNum = registerVO.getFbmbillno().substring(0, 1);
if (isEbill && !"5".equals(firstNum) && !"6".equals(firstNum)) {
throw new BusinessException("票据" + registerVO.getFbmbillno() + "非新一代票据,不可进行分包流转!");
}
if (StringUtil.isNull(billRangeStart) || StringUtil.isNull(billRangeEnd)) {
throw new BusinessException("票据可分包流转状态下,票据子票区间开始和截止值不能为空!");
}
if (Long.valueOf(billRangeStart) > 0L && Long.valueOf(billRangeEnd) > 0L) {
if (billRangeStart.length() >= 12 && billRangeEnd.length() >= 12) {
if (Long.parseLong(billRangeEnd) < Long.parseLong(billRangeStart)) {
throw new BusinessException("子票区间截止值不能小于开始值!");
}
checkMoneyFormatCorrect(registerVO.getMoney());
Long rangeDiff = Long.parseLong(registerVO.getBillrangeend())
- Long.parseLong(registerVO.getBillrangestart());
UFDouble diffMoney = (new UFDouble(rangeDiff)).add(1.0).multiply(0.01);
RegisterVO newRegisterVO = calcMoneyPrecision(registerVO, diffMoney);
if (newRegisterVO.getMoney().doubleValue() != registerVO.getMoney().doubleValue()) {
throw new BusinessException("票据号码" + registerVO.getFbmbillno() + ",子票区间" + billRangeStart
+ "-" + billRangeEnd + "的金额" + newRegisterVO.getMoney().toString()
+ "(根据公式自动计算出的金额)与票据金额不相等,请修改!");
}
if (!isEbill) {
throw new BusinessException("纸票不能进行分包流转!");
}
if (Long.parseLong(billRangeEnd) < Long.parseLong(billRangeStart)) {
throw new BusinessException("子票区间截止值不能小于开始值!");
}
break label101;
}
throw new BusinessException("子票区间开始值和截止值长度都必须为12位");
}
throw new BusinessException("子票区间开始值和截止值都必须大于0");
}
}
boolean isBelongNewBillSys = ifBelongNewBillSystem(registerVO.getFbmbillno());
if (!isBelongNewBillSys || subcontractCirculation != null && subcontractCirculation.booleanValue()
|| "0".equals(registerVO.getBillrangestart()) && "0".equals(registerVO.getBillrangeend())) {
if (isBelongNewBillSys || !StringUtil.isNotNull(registerVO.getBillrangestart())
&& !StringUtil.isNotNull(registerVO.getBillrangeend())) {
AggRegisterVO[] registers = ((IGatherQueryService) NCLocator.getInstance()
.lookup(IGatherQueryService.class))
.queryRegisterByFbmBillnoAndPkorg(registerVO.getFbmbillno(), registerVO.getPk_org());
if (null != registers && registers.length > 0) {
checkBillRangeRepeat(registers, registerVO);
}
} else {
throw new BusinessException("非新一代票据不可进行分包流转,不可输入子票区间!");
}
} else {
throw new BusinessException("票据[" + registerVO.getFbmbillno() + "]为新一代票且不可分包流转子票区间开始和结束应为0");
}
}
public static String checkBillRangeRepeat(AggRegisterVO[] registers, RegisterVO newRegisterVO)
throws BusinessException {
int var4;
String var10002;
if (StringUtil.isNull(newRegisterVO.getPrimaryKey())) {
if (registers != null && registers.length == 1) {
AggRegisterVO register = registers[0];
RegisterVO vo = register.getparentVO();
if (!StringUtil.isNull(vo.getBillrangestart()) && !StringUtil.isNull(vo.getBillrangeend())) {
if (!StringUtil.isNull(newRegisterVO.getBillrangestart())
&& !StringUtil.isNull(newRegisterVO.getBillrangeend())) {
if (ifIncludesInterval(register, newRegisterVO)) {
var10002 = register.getparentVO().getFbmbillno();
throw new BusinessException(
"票据号码" + var10002 + ",子票区间" + register.getparentVO().getBillrangestart() + "-"
+ register.getparentVO().getBillrangeend()
+ "已存在,请勿重复录入,请在票据台账节点查询该票据号对应单据是否处理完成!");
}
return null;
}
throw new BusinessException("票据号[" + newRegisterVO.getFbmbillno() + "]已存在,且为等分票据,不可再登记非等分票据信息!");
}
if (!StringUtil.isNull(newRegisterVO.getBillrangestart())
&& !StringUtil.isNull(newRegisterVO.getBillrangeend())) {
return "票据号[" + newRegisterVO.getFbmbillno() + "]已存在,且为非等分票据,不可再登记等分票据信息!";
}
throw new BusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("3618fbm_0", "03618fbm-0598",
(String) null, new String[] { newRegisterVO.getFbmbillno() }));
} else if (registers != null && registers.length > 1) {
if (StringUtil.isNull(newRegisterVO.getBillrangestart())
|| StringUtil.isNull(newRegisterVO.getBillrangeend())) {
throw new BusinessException("票据号[" + newRegisterVO.getFbmbillno() + "]已存在,且为等分票据,不可再登记非等分票据信息!");
}
AggRegisterVO[] var7 = registers;
int var9 = registers.length;
for (var4 = 0; var4 < var9; ++var4) {
AggRegisterVO vo = var7[var4];
if (ifIncludesInterval(vo, newRegisterVO)) {
var10002 = vo.getparentVO().getFbmbillno();
throw new BusinessException("票据号码" + var10002 + ",子票区间" + vo.getparentVO().getBillrangestart()
+ "-" + vo.getparentVO().getBillrangeend() + "已存在,请勿重复录入,请在票据台账节点查询该票据号对应单据是否处理完成!");
}
}
}
} else {
if (registers == null || registers.length == 0) {
throw new BusinessException("修改失败,票据" + newRegisterVO.getFbmbillno() + "数据不存在!");
}
if (registers != null && registers.length > 1) {
if (newRegisterVO.getSubcontractcirculation() != null
&& !newRegisterVO.getSubcontractcirculation().booleanValue()) {
throw new BusinessException("票据号码 " + newRegisterVO.getFbmbillno() + "作为等分票据已拆包,无法再变更为非等分票据!");
}
boolean intervalRepeat = false;
AggRegisterVO[] var3 = registers;
var4 = registers.length;
for (int var5 = 0; var5 < var4; ++var5) {
AggRegisterVO vo = var3[var5];
if (StringUtil.isNull(vo.getparentVO().getBillrangestart())
|| StringUtil.isNull(vo.getparentVO().getBillrangeend())) {
throw new BusinessException(
"修改失败,票据 " + newRegisterVO.getFbmbillno() + "既存在等分票据数据,又存在非等分票据数据!");
}
if (vo.getparentVO().getPk_register().equals(newRegisterVO.getPk_register())) {
if (vo.getparentVO().getBillrangestart().equals(newRegisterVO.getBillrangestart())
&& vo.getparentVO().getBillrangeend().equals(newRegisterVO.getBillrangeend())) {
intervalRepeat = false;
}
} else if (ifIncludesInterval(vo, newRegisterVO)) {
intervalRepeat = true;
}
}
if (intervalRepeat) {
var10002 = newRegisterVO.getFbmbillno();
throw new BusinessException("票据号码" + var10002 + ",子票区间" + newRegisterVO.getBillrangestart() + "-"
+ newRegisterVO.getBillrangeend() + "已存在,请勿重复录入,请在票据台账节点查询该票据号对应单据是否处理完成!");
}
}
}
return null;
}
private static boolean ifIncludesInterval(AggRegisterVO aggRegisterVO, RegisterVO newRegisterVO) {
boolean flag = false;
if (Long.parseLong(aggRegisterVO.getparentVO().getBillrangestart()) <= Long
.parseLong(newRegisterVO.getBillrangeend())
&& Long.parseLong(aggRegisterVO.getparentVO().getBillrangeend()) >= Long
.parseLong(newRegisterVO.getBillrangeend())) {
flag = true;
}
if (Long.parseLong(aggRegisterVO.getparentVO().getBillrangestart()) <= Long
.parseLong(newRegisterVO.getBillrangestart())
&& Long.parseLong(aggRegisterVO.getparentVO().getBillrangeend()) >= Long
.parseLong(newRegisterVO.getBillrangestart())) {
flag = true;
}
if (Long.parseLong(newRegisterVO.getBillrangestart()) <= Long
.parseLong(aggRegisterVO.getparentVO().getBillrangeend())
&& Long.parseLong(newRegisterVO.getBillrangeend()) >= Long
.parseLong(aggRegisterVO.getparentVO().getBillrangeend())) {
flag = true;
}
if (Long.parseLong(newRegisterVO.getBillrangestart()) <= Long
.parseLong(aggRegisterVO.getparentVO().getBillrangestart())
&& Long.parseLong(newRegisterVO.getBillrangeend()) >= Long
.parseLong(aggRegisterVO.getparentVO().getBillrangestart())) {
flag = true;
}
if (Long.parseLong(aggRegisterVO.getparentVO().getBillrangestart()) >= Long
.parseLong(newRegisterVO.getBillrangestart())
&& Long.parseLong(aggRegisterVO.getparentVO().getBillrangeend()) <= Long
.parseLong(newRegisterVO.getBillrangeend())) {
flag = true;
}
if (Long.parseLong(newRegisterVO.getBillrangestart()) >= Long
.parseLong(aggRegisterVO.getparentVO().getBillrangestart())
&& Long.parseLong(newRegisterVO.getBillrangeend()) <= Long
.parseLong(aggRegisterVO.getparentVO().getBillrangeend())) {
flag = true;
}
return flag;
}
public static Long checkMoneyFormatCorrect(UFDouble money) throws BusinessException {
if (money == null) {
return 0L;
} else {
UFDouble standardAmountMultiplier = money.multiply(100.0);
long roundmum = standardAmountMultiplier.longValue();
if (!(standardAmountMultiplier.sub(new UFDouble(roundmum)).doubleValue() > 0.0)
&& !(standardAmountMultiplier.sub(new UFDouble(roundmum)).doubleValue() < 0.0)) {
return roundmum;
} else {
throw new BusinessException("等分票据的票据金额要等于标准金额的整数倍,请修改!");
}
}
}
public static String formatBillRangeValue(String rangeValue) {
if (StringUtil.isNull(rangeValue)) {
return "000000000001";
} else if (rangeValue.length() != 12 && rangeValue.length() <= 12) {
long needSupplyCharacterLeng = (long) (12 - rangeValue.length());
StringBuilder builder;
for (builder = new StringBuilder(); needSupplyCharacterLeng > 0L; --needSupplyCharacterLeng) {
builder.append("0");
}
builder.append(rangeValue);
return builder.toString();
} else {
return rangeValue;
}
}
public static String getBillSysTypeByFbmBillNo(String fbmBillNo) {
if (StringUtil.isNull(fbmBillNo)) {
return null;
} else {
String firstNum = fbmBillNo.substring(0, 1);
return ("5".equals(firstNum) || "6".equals(firstNum)) && fbmBillNo.length() == 30 ? "CS02" : "CS01";
}
}
public static boolean ifBelongNewBillSystem(String fbmBillNo) {
String billsystype = getBillSysTypeByFbmBillNo(fbmBillNo);
return "CS02".equals(billsystype);
}
public static boolean ifRangeMatched(CircularlyAccessibleValueObject one, CircularlyAccessibleValueObject other) {
String oneStart = (String) one.getAttributeValue("billrangestart");
String oneEnd = (String) one.getAttributeValue("billrangeend");
String otherStart = (String) other.getAttributeValue("billrangestart");
String otherEnd = (String) other.getAttributeValue("billrangeend");
return StringUtils.equals(oneStart, otherStart) && StringUtils.equals(oneEnd, otherEnd);
}
}