You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
201 lines
7.4 KiB
201 lines
7.4 KiB
package com.sinosoft.lis.otof;
|
|
|
|
import com.sinosoft.lis.i18n.I18nMessage;
|
|
import com.sinosoft.lis.sql.repository.LDComSQL;
|
|
import com.sinosoft.lis.sql.repository.LITranInfoSQL;
|
|
import com.sinosoft.lis.vdb.LITranErrDBSet;
|
|
import com.sinosoft.lis.vdb.LITranInfoDBSet;
|
|
import com.sinosoft.lis.vdb.OFInterfaceDBSet;
|
|
import com.sinosoft.lis.vschema.LITranErrSet;
|
|
import com.sinosoft.lis.vschema.LITranInfoSet;
|
|
import com.sinosoft.lis.vschema.OFInterfaceSet;
|
|
import com.sinosoft.persistence.SQLProxy;
|
|
import com.sinosoft.utility.CError;
|
|
import com.sinosoft.utility.CErrors;
|
|
import com.sinosoft.utility.DBConnPool;
|
|
import com.sinosoft.utility.ExeSQL;
|
|
import com.sinosoft.utility.SQLwithBindVariables;
|
|
import com.sinosoft.utility.SSRS;
|
|
import com.sinosoft.utility.VData;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import java.sql.Connection;
|
|
import java.sql.SQLException;
|
|
|
|
/**
|
|
* <p>Title: Web业务系统投保暂交费功能部分 </p>
|
|
* <p>Description: </p>
|
|
* <p>Copyright: Copyright (c) 2002 </p>
|
|
* <p>Company: Sinosoft< /p>
|
|
* @author YT
|
|
* @version 1.0
|
|
*/
|
|
|
|
public class OtoFBLS
|
|
{
|
|
private static final Logger logger = LoggerFactory.getLogger(OtoFBLS.class);
|
|
|
|
//传输数据类
|
|
private VData mInputData ;
|
|
//错误处理类,每个需要错误处理的类中都放置该类
|
|
public CErrors mErrors = new CErrors();
|
|
|
|
public OtoFBLS() {}
|
|
|
|
//传输数据的公共方法
|
|
public boolean submitData(VData cInputData,String cOperate)
|
|
{
|
|
boolean tReturn = false;
|
|
//首先将数据在本类中做一个备份
|
|
mInputData=(VData)cInputData.clone() ;
|
|
logger.debug("Start OtoF BLS Submit...");
|
|
|
|
if (!this.saveData())
|
|
return false;
|
|
|
|
logger.debug("End OtoF BLS Submit...");
|
|
mInputData=null;
|
|
return true;
|
|
}
|
|
|
|
private boolean saveData()
|
|
{
|
|
//增加并发控制
|
|
int tVoucherID = Integer.parseInt((String)mInputData.get(0));
|
|
String tManageCom = (String)mInputData.get(1);
|
|
String tBussDate = (String)mInputData.get(2);
|
|
LITranInfoSet mLITranInfoSet = new LITranInfoSet();
|
|
mLITranInfoSet = mInputData.get(LITranInfoSet.class,0);
|
|
LITranErrSet mLITranErrSet = new LITranErrSet();
|
|
mLITranErrSet = mInputData.get(LITranErrSet.class,0);
|
|
OFInterfaceSet mOFInterfaceSet = new OFInterfaceSet();
|
|
mOFInterfaceSet = mInputData.get(OFInterfaceSet.class,0);
|
|
Connection conn = DBConnPool.getConnection();
|
|
|
|
if (conn==null)
|
|
{
|
|
// @@错误处理
|
|
CError tError = new CError();
|
|
tError.moduleName = "OtoFBLS";
|
|
tError.functionName = "saveData";
|
|
tError.errorMessage(new I18nMessage("数据库连接失败!", "LIS-06519"));
|
|
this.mErrors .addOneError(tError);
|
|
return false;
|
|
}
|
|
|
|
try
|
|
{
|
|
conn.setAutoCommit(false);
|
|
//2008-8-18 排除业务员押金的控制
|
|
|
|
if(tVoucherID >= 10&& tVoucherID!=13 && tVoucherID!=82 && tVoucherID!=83) //控制销售系统凭证并发操作
|
|
{
|
|
LDComSQL ldComSQL = SQLProxy.getInstance(LDComSQL.class);
|
|
SQLwithBindVariables sqlbv=ldComSQL.findComCodeByComCodeLike(tManageCom);
|
|
logger.debug("-----控制并发操作-----");
|
|
ExeSQL tExeSQL = new ExeSQL(conn);
|
|
SSRS ssrs = (SSRS)tExeSQL.execSQL(sqlbv);
|
|
if(tExeSQL.mErrors.needDealError() || ssrs.getMaxRow() <= 0)
|
|
{
|
|
CError.buildErr(this, new I18nMessage("资源忙,并发操作,请重新操作!", "LIS-12772"));
|
|
conn.rollback() ;
|
|
return false;
|
|
}
|
|
|
|
//校验此时当月的凭证是否已经有插入数据
|
|
LITranInfoSQL liTranInfoSQL = SQLProxy.getInstance(LITranInfoSQL.class);
|
|
logger.debug("校验是否已生成数据:" + "select batchno from litraninfo "
|
|
+ "where voucherid = ?tVoucherID? and managecom like concat('?tManageCom?','%') "
|
|
+ "and bussdate = '?tBussDate?' ");
|
|
SSRS tssrs = liTranInfoSQL.getBatchNoByVoucherIDAndManageComLikeAndBussDate(tVoucherID,tManageCom,tBussDate);
|
|
if(tssrs.getMaxRow() > 0)
|
|
{
|
|
CError.buildErr(this, new I18nMessage("当月数据已经生成,请慎重操作!", "LIS-12773"));
|
|
conn.rollback() ;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
LITranInfoDBSet mLITranInfoDBSet = new LITranInfoDBSet(conn);
|
|
mLITranInfoDBSet.set(mLITranInfoSet);
|
|
if (mLITranInfoDBSet.insert() == false)
|
|
{
|
|
// @@错误处理
|
|
this.mErrors.copyAllErrors(mLITranInfoDBSet.mErrors);
|
|
CError tError = new CError();
|
|
tError.moduleName = "OtoFBLS";
|
|
tError.functionName = "saveData";
|
|
tError.errorMessage(new I18nMessage("保存数据失败!", "LIS-07394"));
|
|
this.mErrors .addOneError(tError);
|
|
conn.rollback() ;
|
|
return false;
|
|
}
|
|
|
|
LITranErrDBSet mLITranErrDBSet = new LITranErrDBSet(conn);
|
|
mLITranErrDBSet.set(mLITranErrSet);
|
|
if (mLITranErrDBSet.insert() == false)
|
|
{
|
|
// @@错误处理
|
|
this.mErrors.copyAllErrors(mLITranErrDBSet.mErrors);
|
|
CError tError = new CError();
|
|
tError.moduleName = "OtoFBLS";
|
|
tError.functionName = "saveData";
|
|
tError.errorMessage(new I18nMessage("保存数据失败!", "LIS-07394"));
|
|
this.mErrors .addOneError(tError);
|
|
conn.rollback() ;
|
|
return false;
|
|
}
|
|
|
|
if(mOFInterfaceSet != null)
|
|
{
|
|
OFInterfaceDBSet mOFInterfaceDBSet = new OFInterfaceDBSet(conn);
|
|
mOFInterfaceDBSet.set(mOFInterfaceSet);
|
|
if(mOFInterfaceDBSet.insert() == false)
|
|
{
|
|
// @@错误处理
|
|
this.mErrors.copyAllErrors(mOFInterfaceDBSet.mErrors);
|
|
CError tError = new CError();
|
|
tError.moduleName = "OtoFBLS";
|
|
tError.functionName = "saveData";
|
|
tError.errorMessage(new I18nMessage("保存数据失败!", "LIS-07394"));
|
|
this.mErrors .addOneError(tError);
|
|
conn.rollback() ;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
conn.commit() ;
|
|
} // end of try
|
|
catch (Exception ex)
|
|
{
|
|
// @@错误处理
|
|
CError tError = new CError();
|
|
tError.moduleName = "ReportBLS";
|
|
tError.functionName = "submitData";
|
|
tError.errorMessage(new I18nMessage( ex.toString(), null));
|
|
this.mErrors .addOneError(tError);
|
|
try{
|
|
conn.rollback() ;
|
|
}
|
|
catch(Exception e){}
|
|
return false;
|
|
}
|
|
finally
|
|
{
|
|
// 统一处理连接关闭
|
|
if (conn != null)
|
|
{
|
|
try
|
|
{
|
|
conn.close();
|
|
}
|
|
catch (SQLException e)
|
|
{
|
|
logger.error("关闭数据库连接失败", e);
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|