注意:程序中数据库关闭自动提交,事务设置TRANSACTION_READ_UNCOMMITTED:未提交读
1.查询是否下推发票标志:
select fvalue from t_SystemProfile where FCategory='IC' and FKey='MakeSaleInvoAfterOrderAudit'
如果 fvalue等于2,则执行下推发票操作。
2.查询出要下推发票的销售出库单集合
2.1 查询供应链当前年度,用于后续单据赋值
select FValue from t_SystemProfile where FCategory='IC' and FKey='CurrentYear'
2.2查询供应链当前期间,用于后续单据赋值
select FValue from t_SystemProfile where FCategory='IC' and FKey='CurrentPeriod'
2.3查询当前期间是否关帐 0未关 1关,,用于判断是否关账,关账则不再同步
select FValue from t_SystemProfile where FCategory='IC' and FKey='BillStatus'
2.4 判断总金额是否为0,为0则不下推发票:
SELECT SUM(FConsignAmount) as amount FROM ICStockBillEntry
WHERE FInterID in (
select FInterID from ICStockBill where FBillNo='code'
);
ps:code为要下推发票的销售出库单号。
3.获取金蝶发票表当前最大id:
select max(finterid) finterid from icsale
4.根据配置选择生成‘普票’还是'专票':
构建普票编号:
public String buildFbillnofp()throws Exception{
String buildOnlyNumber=null;
int fcurno=0;
String fpre="";
SqlServerUtil mysql=new SqlServerUtil();
Connection conn=mysql.getConnection();
synchronized (this){
try{
conn.setAutoCommit(false);
conn.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
String ssql=" select fpreletter,fcurno from icbillno where fbillid = 86 ";
Statement stat = conn.createStatement();
ResultSet rs=stat.executeQuery(ssql);
while(rs.next()) {
f