|
@@ -0,0 +1,3455 @@
|
|
|
+package nc.bs.gl.contrastpub;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.sql.Connection;
|
|
|
+import java.sql.PreparedStatement;
|
|
|
+import java.sql.ResultSet;
|
|
|
+import java.sql.SQLException;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Collection;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.HashSet;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.Vector;
|
|
|
+
|
|
|
+import nc.bs.dao.BaseDAO;
|
|
|
+import nc.bs.dao.DAOException;
|
|
|
+import nc.bs.framework.common.NCLocator;
|
|
|
+import nc.bs.framework.core.util.ObjectCreator;
|
|
|
+import nc.bs.gl.contrast.ContrastaccountDMO;
|
|
|
+import nc.bs.gl.contrast.ContrastclassDMO;
|
|
|
+import nc.bs.logging.Logger;
|
|
|
+import nc.bs.pub.DataManageObject;
|
|
|
+import nc.bs.sec.esapi.NCESAPI;
|
|
|
+import nc.cmp.tools.ContrastQueryModuleUtil;
|
|
|
+import nc.cmp.tools.ContrastTools;
|
|
|
+import nc.cmp.tools.StringUtil;
|
|
|
+import nc.impl.gl.contrast.ImpCMPDataAccess;
|
|
|
+import nc.itf.cm.prv.CmpConst;
|
|
|
+import nc.itf.fi.pub.Currency;
|
|
|
+import nc.pubitf.accperiod.AccountCalendar;
|
|
|
+import nc.pubitf.fbm.register.IRegisterPubQueryService;
|
|
|
+import nc.pubitf.uapbd.IBalaTypePubService;
|
|
|
+import nc.vo.bd.balatype.BalaTypeVO;
|
|
|
+import nc.vo.bd.pub.sqlutil.BDSqlInUtil;
|
|
|
+import nc.vo.cmp.bankaccbook.BankAccDetailVO;
|
|
|
+import nc.vo.cmp.bankaccbook.constant.UseFlagEnum;
|
|
|
+import nc.vo.cmp.cb.AccountlinkVO;
|
|
|
+import nc.vo.cmp.cb.BankKeyTool;
|
|
|
+import nc.vo.cmp.cb.BankReceiptVO;
|
|
|
+import nc.vo.cmp.cb.CBalanceKeyTool;
|
|
|
+import nc.vo.cmp.cb.CBalanceVO;
|
|
|
+import nc.vo.cmp.cb.CConditionVO;
|
|
|
+import nc.vo.cmp.cb.CCorpReceiptKey;
|
|
|
+import nc.vo.cmp.cb.CCorpReceiptVO;
|
|
|
+import nc.vo.cmp.cb.CQueryVO;
|
|
|
+import nc.vo.cmp.cb.CTransferVO;
|
|
|
+import nc.vo.cmp.cb.ContrastAccountVO;
|
|
|
+import nc.vo.cmp.cb.ContrastClassVO;
|
|
|
+import nc.vo.cmp.cb.ContrastVO;
|
|
|
+import nc.vo.cmp.cb.CorpReceiptVO;
|
|
|
+import nc.vo.cmp.cb.DefaultKeyTool;
|
|
|
+import nc.vo.cmp.cb.IKey;
|
|
|
+import nc.vo.cmp.cb.UnitKeyTool;
|
|
|
+import nc.vo.fbm.register.RegisterVO;
|
|
|
+import nc.vo.gateway60.accountbook.AccountBookUtil;
|
|
|
+import nc.vo.logging.Debug;
|
|
|
+import nc.vo.pub.BusinessException;
|
|
|
+import nc.vo.pub.lang.UFBoolean;
|
|
|
+import nc.vo.pub.lang.UFDate;
|
|
|
+import nc.vo.pub.lang.UFDouble;
|
|
|
+import nc.vo.pub.lang.UFLiteralDate;
|
|
|
+import nc.vo.pubapp.AppContext;
|
|
|
+import nc.vo.tmpub.util.VOUtil;
|
|
|
+
|
|
|
+
|
|
|
+public class QueryDMO extends DataManageObject {
|
|
|
+ HashMap<Object, String> hashCheckName = new HashMap<Object, String>();
|
|
|
+ //private IBankAccQueryService queryService;
|
|
|
+ private BaseDAO baseDAO = null;
|
|
|
+ private IRegisterPubQueryService fbmQueryService;
|
|
|
+ private IBalaTypePubService balaQry;
|
|
|
+
|
|
|
+ public BaseDAO getBaseDAO() {
|
|
|
+ if (baseDAO == null)
|
|
|
+ baseDAO = new BaseDAO();
|
|
|
+ return baseDAO;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * QueryDMO 构造子注解。
|
|
|
+ *
|
|
|
+ * @exception javax.naming.NamingException
|
|
|
+ * 异常说明。
|
|
|
+ * @exception nc.bs.pub.SystemException
|
|
|
+ * 异常说明。
|
|
|
+ */
|
|
|
+ public QueryDMO() throws javax.naming.NamingException,
|
|
|
+ nc.bs.pub.SystemException {
|
|
|
+ super();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * QueryDMO 构造子注解。
|
|
|
+ *
|
|
|
+ * @param dbName
|
|
|
+ * java.lang.String
|
|
|
+ * @exception javax.naming.NamingException
|
|
|
+ * 异常说明。
|
|
|
+ * @exception nc.bs.pub.SystemException
|
|
|
+ * 异常说明。
|
|
|
+ */
|
|
|
+ public QueryDMO(String dbName) throws javax.naming.NamingException,
|
|
|
+ nc.bs.pub.SystemException {
|
|
|
+ super(dbName);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 得到帐户 创建日期:(2002-3-21 20:09:48)
|
|
|
+ */
|
|
|
+ private ContrastAccountVO getAccount(String strPk_Account) throws Exception {
|
|
|
+ ContrastaccountDMO dmo = new ContrastaccountDMO();
|
|
|
+ ContrastAccountVO vo = dmo.findByPrimaryKey(strPk_Account);
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**********************************************************************************************************
|
|
|
+ * 功能:得到银行到截止日期时(前)的余额 参数:CQueryVO query 查询条件 返回:CBalanceVO[] modifier by
|
|
|
+ * zhaozh on 2009-2-20 下午02:39:36 加入精度,以免不平
|
|
|
+ **********************************************************************************************************/
|
|
|
+ public CTransferVO[] getBankBalance(CQueryVO query) throws SQLException {
|
|
|
+ /*************************************************************/
|
|
|
+ // 保留的系统管理接口:
|
|
|
+ beforeCallMethod("nc.bs.gl.contrastpub.QueryDMO", "getBankMoney",
|
|
|
+ new Object[] { query });
|
|
|
+ /*************************************************************/
|
|
|
+ // getBankBalanceSpread(query);
|
|
|
+ int digit = 2;
|
|
|
+ String[] pk_account = query.getPk_Account();
|
|
|
+ try {
|
|
|
+ digit = Currency.getCurrDigit(getAccount(pk_account[0])
|
|
|
+ .getPk_currtype());
|
|
|
+ } catch (Exception e) {
|
|
|
+ Logger.error(e.getMessage() + "获取币种精度异常", e);
|
|
|
+ throw new SQLException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("3607con_0","03607con-0504")/*@res "获取币种精度异常"*/
|
|
|
+ + e.getMessage());
|
|
|
+ }
|
|
|
+ String strTemp = "";
|
|
|
+ for (int i = 0; i < pk_account.length; i++) {
|
|
|
+ strTemp = strTemp + "'" + pk_account[i] + "',";
|
|
|
+ }
|
|
|
+ if (strTemp.length() > 0) {
|
|
|
+ strTemp = strTemp.substring(0, strTemp.length() - 1);
|
|
|
+ }
|
|
|
+ StringBuffer strSql = new StringBuffer(
|
|
|
+ " select accountstart.pk_contrastaccount,"
|
|
|
+ + "round(debitamount,"
|
|
|
+ + digit
|
|
|
+ + ") as debitamount,"
|
|
|
+ + "round(creditamount,"
|
|
|
+ + digit
|
|
|
+ + ") as creditamount,contrastaspect from gl_accountstart accountstart,gl_contrastaccount account ");
|
|
|
+ strSql
|
|
|
+ .append(" where accountstart.pk_contrastaccount = account.pk_contrastaccount ");
|
|
|
+ // modified by zhufeng 2013-2-19 查询余额时,不需要设置组织,只需要账户即可,组织前台可能传过来的是账簿,查询结果为空 start
|
|
|
+// if (query.getPk_Corp() != null && query.getPk_Corp().length() > 0)
|
|
|
+// strSql
|
|
|
+// .append(" and account.pk_org = '" + query.getPk_Corp()
|
|
|
+// + "' ");
|
|
|
+ // modified by zhufeng 2013-2-19 end
|
|
|
+ if (pk_account != null && pk_account.length > 0)
|
|
|
+ strSql.append(" and accountstart.pk_contrastaccount in (" + strTemp
|
|
|
+ + ")");
|
|
|
+ if (query.getYear() != null)
|
|
|
+ strSql.append(" and years = '" + query.getYear() + "' ");
|
|
|
+
|
|
|
+ if (query.isInitRange() == null || !query.isInitRange().booleanValue()) {
|
|
|
+ strSql.append(" union all ");
|
|
|
+ strSql
|
|
|
+ .append(" select receipt.pk_contrastaccount,"
|
|
|
+ + "round(debitamount,"
|
|
|
+ + digit
|
|
|
+ + ") as debitamount,"
|
|
|
+ + "round(creditamount,"
|
|
|
+ + digit
|
|
|
+ + ") as creditamount,contrastaspect from gl_bankreceipt receipt,gl_contrastaccount account ");
|
|
|
+ strSql
|
|
|
+ .append(" where receipt.pk_contrastaccount = account.pk_contrastaccount ");
|
|
|
+ if (query.getPk_Corp() != null && query.getPk_Corp().length() > 0)
|
|
|
+ strSql.append(" and account.pk_org = '" + query.getPk_Corp()
|
|
|
+ + "' ");
|
|
|
+ AccountCalendar calendar = ContrastTools.getBusiDateAccCalendar(query.getPk_Corp());
|
|
|
+ UFDate lastDate = calendar.getYearVO().getEnddate();
|
|
|
+ UFDate fristDate = calendar.getYearVO().getBegindate();
|
|
|
+ if(query.getBankEndDate()!=null&&!query.getBankEndDate().after(lastDate))
|
|
|
+ {
|
|
|
+ if (query.isIncludeLast().booleanValue())
|
|
|
+ strSql.append(" and checkdate <= '" + query.getBankEndDate() + "' ");
|
|
|
+ else
|
|
|
+ strSql.append(" and checkdate < '" + query.getBankEndDate() + "' ");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (query.isIncludeLast().booleanValue())
|
|
|
+ strSql.append(" and checkdate <= '" + lastDate + "' ");
|
|
|
+ else
|
|
|
+ strSql.append(" and checkdate < '" + lastDate + "' ");
|
|
|
+ }
|
|
|
+ /** 将异常的银行对账单排除掉 modified by zhaozh on2008-12-27 **/
|
|
|
+ strSql.append(" and (styleflag='A' or isnull(styleflag,'~')='~')");
|
|
|
+ strSql.append(" and years = '" + query.getYear()
|
|
|
+ + "' and (period <> '00' or isnull(period,'~')='~' ");
|
|
|
+ strSql.append(" or (period = '00' and checkdate >= ( select startdate from gl_accountstart where gl_accountstart.PK_CONTRASTACCOUNT = receipt.PK_CONTRASTACCOUNT and gl_accountstart.years = receipt.years)))");
|
|
|
+ if (query.getPk_Corp() != null && query.getPk_Corp().length() > 0)
|
|
|
+ strSql.append(" and account.pk_org = '" + query.getPk_Corp()
|
|
|
+ + "' ");
|
|
|
+ if (pk_account != null && pk_account.length > 0)
|
|
|
+ strSql.append(" and receipt.pk_contrastaccount in(" + strTemp
|
|
|
+ + ")");
|
|
|
+ }
|
|
|
+ String sql = " select pk_contrastaccount,contrastaspect,sum(debitamount),sum(creditamount) from ("
|
|
|
+ + strSql + ") temp_table ";
|
|
|
+ sql = sql + " group by pk_contrastaccount,contrastaspect ";
|
|
|
+
|
|
|
+ // 读取查询结果
|
|
|
+ java.sql.Connection con = null;
|
|
|
+ java.sql.Statement stmt = null;
|
|
|
+ java.sql.ResultSet rs = null;
|
|
|
+ java.util.Vector<CBalanceVO> vecResult = new java.util.Vector<CBalanceVO>();
|
|
|
+ try {
|
|
|
+ con = getConnection();
|
|
|
+ stmt = con.createStatement();
|
|
|
+ rs = stmt.executeQuery(sql);
|
|
|
+ CBalanceVO returnValue;
|
|
|
+ BigDecimal debitamount;
|
|
|
+ BigDecimal creditamount;
|
|
|
+ while (rs.next()) {
|
|
|
+ returnValue = new CBalanceVO();
|
|
|
+ returnValue.setPk_account(rs.getString(1));
|
|
|
+ int t = rs.getInt(2);
|
|
|
+ debitamount = rs.getBigDecimal(3);
|
|
|
+ creditamount = rs.getBigDecimal(4);
|
|
|
+ if (t == 0) {
|
|
|
+ returnValue.setDebitamount(new UFDouble(debitamount.subtract(creditamount)/* ,digitMap.get(rs.getString(1)) */));
|
|
|
+ returnValue.setCreditamount(UFDouble.ZERO_DBL);
|
|
|
+ } else {
|
|
|
+ returnValue.setDebitamount(UFDouble.ZERO_DBL);
|
|
|
+ returnValue.setCreditamount(new UFDouble(creditamount.subtract(debitamount)/* ,digitMap.get(rs.getString(1)) */));
|
|
|
+ }
|
|
|
+
|
|
|
+ vecResult.addElement(returnValue);
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ if (rs != null)
|
|
|
+ rs.close();
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ if (stmt != null) {
|
|
|
+ stmt.close();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ if (con != null) {
|
|
|
+ con.close();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ CTransferVO[] balances = new CTransferVO[vecResult.size()];
|
|
|
+ CBalanceKeyTool keyTool = new CBalanceKeyTool();
|
|
|
+ CBalanceVO balance;
|
|
|
+ for (int j = 0; j < vecResult.size(); j++) {
|
|
|
+ CTransferVO votemp = new CTransferVO();
|
|
|
+ balance = vecResult.elementAt(j);
|
|
|
+ votemp.setVo(balance);
|
|
|
+ votemp.setKeyTool(keyTool); // 要查数据库
|
|
|
+ votemp.setInit(new Boolean(true));
|
|
|
+ votemp.setPk_account(balance.getPk_account());
|
|
|
+ balances[j] = votemp;
|
|
|
+ }
|
|
|
+ /*************************************************************/
|
|
|
+ // 保留的系统管理接口:
|
|
|
+ afterCallMethod("nc.bs.gl.contrast.ContrastDMO", "getBankMoney",
|
|
|
+ new Object[] { pk_account });
|
|
|
+ /*************************************************************/
|
|
|
+ return balances;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**********************************************************************************************************
|
|
|
+ * 功能: 得到银行到截止日期时(前)的余额 多单位展开 参数: CQueryVO query 查询条件 返回: CBalanceVO[]
|
|
|
+ **********************************************************************************************************/
|
|
|
+ public CTransferVO[] getBankBalanceSpread(CQueryVO query)
|
|
|
+ throws SQLException {
|
|
|
+
|
|
|
+ /*************************************************************/
|
|
|
+ // 保留的系统管理接口:
|
|
|
+ beforeCallMethod("nc.bs.gl.contrastpub.QueryDMO", "getBankMoney",
|
|
|
+ new Object[] { query });
|
|
|
+ /*************************************************************/
|
|
|
+ int digit = 2;
|
|
|
+ String[] pk_account = query.getPk_Account();
|
|
|
+ try {
|
|
|
+ digit = Currency.getCurrDigit(getAccount(pk_account[0])
|
|
|
+ .getPk_currtype());
|
|
|
+ } catch (Exception e) {
|
|
|
+ Logger.error(e.getMessage() + "获取币种精度异常", e);
|
|
|
+ throw new SQLException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("3607con_0","03607con-0504")/*@res "获取币种精度异常"*/
|
|
|
+ + e.getMessage());
|
|
|
+ }
|
|
|
+ String strTemp = "";
|
|
|
+ for (int i = 0; i < pk_account.length; i++) {
|
|
|
+ strTemp = strTemp + "'" + pk_account[i] + "',";
|
|
|
+ }
|
|
|
+ if (strTemp.length() > 0) {
|
|
|
+ strTemp = strTemp.substring(0, strTemp.length() - 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ StringBuffer strSql = new StringBuffer("");
|
|
|
+ strSql
|
|
|
+ .append(" (select pk_accountlink,accountstart.pk_contrastaccount,contrastaspect,case when isnull(link.debitamount,0)=0 then 0 else link.debitamount end as debitamount,");
|
|
|
+ strSql
|
|
|
+ .append(" case when isnull(link.creditamount,0)=0 then 0 else link.creditamount end as creditamount");
|
|
|
+ strSql
|
|
|
+ .append(" ,link.pk_org,link.pk_subject,link.bankaccount pk_bank,link.pk_ass");
|
|
|
+ strSql
|
|
|
+ .append(" from gl_accountstart accountstart,gl_contrastaccount account,gl_accountlink link");
|
|
|
+ strSql
|
|
|
+ .append(" where accountstart.pk_contrastaccount = account.pk_contrastaccount ");
|
|
|
+ strSql
|
|
|
+ .append(" and link.pk_contrastaccount = account.pk_contrastaccount ");
|
|
|
+ if (query.getPk_Corp() != null && query.getPk_Corp().length() > 0)
|
|
|
+ strSql
|
|
|
+ .append(" and account.pk_org = '" + query.getPk_Corp()
|
|
|
+ + "' ");
|
|
|
+ if (pk_account != null && pk_account.length > 0)
|
|
|
+ strSql.append(" and accountstart.pk_contrastaccount in (" + strTemp
|
|
|
+ + ")");
|
|
|
+ if (query.getYear() != null) {
|
|
|
+ strSql.append(" and accountstart.years = '" + query.getYear()
|
|
|
+ + "' ");
|
|
|
+ strSql.append(" and (link.years = '" + query.getYear()
|
|
|
+ + "' or isnull(link.years,'~')='~') ");
|
|
|
+ }
|
|
|
+ strSql.append(") links");
|
|
|
+ if (query.isInitRange() == null || !query.isInitRange().booleanValue()) {
|
|
|
+
|
|
|
+ strSql.append(" left outer join ");
|
|
|
+ strSql
|
|
|
+ .append(" (select bank.pk_contrastaccount,"
|
|
|
+ + "sum(round(case when isnull(debitamount,0)=0 then 0 else debitamount end,"
|
|
|
+ + digit + ")) debitamount,");
|
|
|
+ strSql
|
|
|
+ .append(" sum(round(case when isnull(creditamount,0)=0 then 0 else creditamount end,"
|
|
|
+ + digit + ")) creditamount");
|
|
|
+ strSql.append(" ,bank.memo");
|
|
|
+ strSql
|
|
|
+ .append(" FROM gl_bankreceipt bank, gl_contrastaccount account ");
|
|
|
+ strSql
|
|
|
+ .append(" where bank.pk_contrastaccount = account.pk_contrastaccount ");
|
|
|
+ if (query.getPk_Corp() != null && query.getPk_Corp().length() > 0)
|
|
|
+ strSql.append(" and account.pk_org = '" + query.getPk_Corp()
|
|
|
+ + "' ");
|
|
|
+ if (query.isIncludeLast().booleanValue())
|
|
|
+ strSql.append(" and checkdate <= '" + query.getBankEndDate() + "' ");
|
|
|
+ else
|
|
|
+ strSql.append(" and checkdate < '" + query.getBankEndDate() + "' ");
|
|
|
+ /** 将异常的银行对账单排除掉 modified by zhaozh on2008-12-27 **/
|
|
|
+ strSql.append(" and (styleflag='A' or isnull(styleflag,'~')='~')");
|
|
|
+ strSql.append(" and years = '" + query.getYear()
|
|
|
+ + "' and (period <> '00' or isnull(period,'~')='~' ) ");
|
|
|
+ if (query.getPk_Corp() != null && query.getPk_Corp().length() > 0) {
|
|
|
+ strSql.append(" and account.pk_org = '" + query.getPk_Corp()
|
|
|
+ + "' ");
|
|
|
+ }
|
|
|
+ if (pk_account != null && pk_account.length > 0) {
|
|
|
+ strSql.append(" and bank.pk_contrastaccount in(" + strTemp
|
|
|
+ + ")");
|
|
|
+ }
|
|
|
+ strSql.append(" GROUP BY bank.pk_contrastaccount,bank.memo) banks");
|
|
|
+ strSql.append(" on links.pk_accountlink = banks.memo");
|
|
|
+ }
|
|
|
+ String sql = " select links.pk_contrastaccount,contrastaspect,";
|
|
|
+ sql += " links.debitamount ";
|
|
|
+ if (query.isInitRange() == null || !query.isInitRange().booleanValue()) {
|
|
|
+ sql += " +case when isnull(banks.debitamount,0)=0 then 0 else banks.debitamount end,";
|
|
|
+ } else {
|
|
|
+ sql += ",";
|
|
|
+ }
|
|
|
+ sql += " links.creditamount ";
|
|
|
+ if (query.isInitRange() == null || !query.isInitRange().booleanValue()) {
|
|
|
+ sql += " +case when isnull(banks.creditamount,0)=0 then 0 else banks.creditamount end,";
|
|
|
+ } else {
|
|
|
+ sql += ",";
|
|
|
+ }
|
|
|
+ sql += " links.pk_accountlink,links.pk_org,links.pk_subject,links.pk_bank,links.pk_ass ";
|
|
|
+ sql += " from " + strSql + " ";
|
|
|
+
|
|
|
+ // 读取查询结果
|
|
|
+ java.sql.Connection con = null;
|
|
|
+ java.sql.Statement stmt = null;
|
|
|
+ java.sql.ResultSet rs = null;
|
|
|
+ java.util.Vector<CBalanceVO> vecResult = new java.util.Vector<CBalanceVO>();
|
|
|
+ try {
|
|
|
+ con = getConnection();
|
|
|
+ stmt = con.createStatement();
|
|
|
+ rs = stmt.executeQuery(sql);
|
|
|
+ CBalanceVO returnValue;
|
|
|
+ double debitamount;
|
|
|
+ double creditamount;
|
|
|
+ while (rs.next()) {
|
|
|
+ returnValue = new CBalanceVO();
|
|
|
+ returnValue.setPk_account(rs.getString(1));
|
|
|
+ int t = rs.getInt(2);
|
|
|
+ debitamount = rs.getDouble(3);
|
|
|
+ creditamount = rs.getDouble(4);
|
|
|
+ if (t == 0) {
|
|
|
+ returnValue.setDebitamount(new UFDouble(debitamount
|
|
|
+ - creditamount));
|
|
|
+ returnValue.setCreditamount(new UFDouble(0));
|
|
|
+ } else {
|
|
|
+ returnValue.setDebitamount(new UFDouble(0));
|
|
|
+ returnValue.setCreditamount(new UFDouble(creditamount
|
|
|
+ - debitamount));
|
|
|
+ }
|
|
|
+ returnValue.setM_pk_link(rs.getString(5));
|
|
|
+ returnValue.setM_pk_corp(rs.getString(6));
|
|
|
+ returnValue.setM_pk_subject(rs.getString(7));
|
|
|
+ returnValue.setM_pk_bank(rs.getString(8));
|
|
|
+ returnValue.setM_pk_ass(rs.getString(9));
|
|
|
+ vecResult.addElement(returnValue);
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ if (rs != null)
|
|
|
+ rs.close();
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ if (stmt != null) {
|
|
|
+ stmt.close();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ if (con != null) {
|
|
|
+ con.close();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ CTransferVO[] balances = new CTransferVO[vecResult.size()];
|
|
|
+ CBalanceKeyTool keyTool = new CBalanceKeyTool();
|
|
|
+ CBalanceVO balance;
|
|
|
+ for (int j = 0; j < vecResult.size(); j++) {
|
|
|
+ CTransferVO votemp = new CTransferVO();
|
|
|
+ balance = vecResult.elementAt(j);
|
|
|
+ votemp.setVo(balance);
|
|
|
+ votemp.setKeyTool(keyTool); // 要查数据库
|
|
|
+ votemp.setInit(new Boolean(true));
|
|
|
+ votemp.setPk_account(balance.getPk_account());
|
|
|
+ votemp.setM_pk_link(balance.getM_pk_link());
|
|
|
+ votemp.setM_pk_corp(balance.getM_pk_corp());
|
|
|
+ votemp.setM_pk_subject(balance.getM_pk_subject());
|
|
|
+ votemp.setM_pk_bank(balance.getM_pk_bank());
|
|
|
+ votemp.setM_pk_ass(balance.getM_pk_ass());
|
|
|
+ balances[j] = votemp;
|
|
|
+ }
|
|
|
+ /*************************************************************/
|
|
|
+ // 保留的系统管理接口:
|
|
|
+ afterCallMethod("nc.bs.gl.contrast.ContrastDMO", "getBankMoney",
|
|
|
+ new Object[] { pk_account });
|
|
|
+ /*************************************************************/
|
|
|
+ return balances;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**********************************************************************************************************
|
|
|
+ * 功能: 查询银行对账单 参数: CQueryVO query 查询条件 返回: BankReceiptVO[] 修改:@author zhaozh
|
|
|
+ * 2008-6-12 上午10:15:47 增加批次号batchnumber查询 增加停用日期过滤
|
|
|
+ **********************************************************************************************************/
|
|
|
+ public CTransferVO[] getBankReceipt(CQueryVO query) throws Exception {
|
|
|
+ /*************************************************************/
|
|
|
+ // 保留的系统管理接口:
|
|
|
+ beforeCallMethod("nc.bs.gl.contrastpub.QueryDMO", "getBankReceipt",
|
|
|
+ new Object[] { query });
|
|
|
+ /*************************************************************/
|
|
|
+ int digit = 2;
|
|
|
+ String[] pk_account = query.getPk_Account();
|
|
|
+ try {
|
|
|
+ digit = Currency.getCurrDigit(getAccount(pk_account[0])
|
|
|
+ .getPk_currtype());
|
|
|
+ } catch (Exception e) {
|
|
|
+ Logger.error(e.getMessage() + "获取币种精度异常", e);
|
|
|
+ throw new SQLException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("3607con_0","03607con-0504")/*@res "获取币种精度异常"*/
|
|
|
+ + e.getMessage());
|
|
|
+ }
|
|
|
+ // 0为正常 1为勾对 2为核销
|
|
|
+ StringBuffer strSql = new StringBuffer("");
|
|
|
+ strSql.append("select gl_bankreceipt.pk_bankreceipt, gl_bankreceipt.pk_contrastaccount, explanation, checkstyle, pk_check, checkdate, "
|
|
|
+ + "round(gl_bankreceipt.debitamount,"
|
|
|
+ + digit
|
|
|
+ + "),round(gl_bankreceipt.creditamount,"
|
|
|
+ + digit
|
|
|
+ + "),gl_bankreceipt.years, gl_bankreceipt.period ,");
|
|
|
+ strSql.append(" case when isnull(gl_contrast.cavdate,'~')='~' and isnull(gl_contrast.contrastdate,'~')='~' then 0 else case when isnull(gl_contrast.cavdate,'~')='~' then 1 else 2 end end");
|
|
|
+ strSql.append(" ,gl_bankreceipt.memo,gl_bankreceipt.pk_org,gl_bankreceipt.pk_subject,gl_bankreceipt.pk_bank,gl_bankreceipt.pk_ass,gl_contrast.batchnumber,gl_bankreceipt.netbanknumber,gl_bankreceipt.styleflag,gl_bankreceipt.pk_org,gl_bankreceipt.pk_group,gl_bankreceipt.oppunitname,gl_bankreceipt.nusage,gl_bankreceipt.transerial");
|
|
|
+ strSql.append(" from gl_bankreceipt left outer join gl_contrast gl_contrast on gl_bankreceipt.pk_bankreceipt = gl_contrast.pk_bankreceipt ");
|
|
|
+ String strTemp = "";
|
|
|
+ for (int i = 0; i < pk_account.length; i++) {
|
|
|
+ strTemp = strTemp + "'" + pk_account[i] + "',";
|
|
|
+ }
|
|
|
+ if (strTemp.length() > 0) {
|
|
|
+ strTemp = strTemp.substring(0, strTemp.length() - 1);
|
|
|
+ }
|
|
|
+ if (pk_account != null && pk_account.length > 0) {
|
|
|
+ // strSql.append(" and gl_contrast.pk_contrastaccount in (" +
|
|
|
+ // strTemp + ")");
|
|
|
+ }
|
|
|
+ // if (query.getDate() != null){
|
|
|
+ // //strWhere.append(" and gl_bankreceipt.checkdate >= '" +
|
|
|
+ // query.getDate().toString() + "'");
|
|
|
+ // strSql.append(" and gl_contrast.corpdate >= '" +
|
|
|
+ // query.getDate().toString() + "'");
|
|
|
+ // }
|
|
|
+ // if (query.getEndDate() != null){
|
|
|
+ // //strWhere.append(" and gl_bankreceipt.checkdate <= '" +
|
|
|
+ // query.getEndDate().toString() + "'");
|
|
|
+ // strSql.append(" and gl_contrast.corpdate <= '" +
|
|
|
+ // query.getEndDate().toString() + "'");
|
|
|
+ // }
|
|
|
+
|
|
|
+ // ///////////
|
|
|
+ StringBuffer strWhere = new StringBuffer("");
|
|
|
+ if (query.isM_cavDetai()) {
|
|
|
+ // 核销明细
|
|
|
+ strWhere.append(" and gl_contrast.cavdate = '" + query.getM_cavDate() + "' ");
|
|
|
+ if (query.getM_cavMan() == null) {
|
|
|
+ strWhere.append(" and isnull(gl_contrast.cavman,'~')='~' ");
|
|
|
+ } else {
|
|
|
+ strWhere.append(" and gl_contrast.cavman = '" + query.getM_cavMan() + "' ");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //余额调节表查询未对账数据 + 对账日期大于截止日期的数据
|
|
|
+ if (query.getNodecode() == 20040115 && query.isM_bflag()
|
|
|
+ && null != query.getBankEndDate()) {
|
|
|
+ strWhere.append(" and gl_contrast.contrastdate >'").append(query.getBankEndDate().toString()).append("' ");
|
|
|
+ }
|
|
|
+ if (pk_account != null && pk_account.length > 0) {
|
|
|
+ strWhere.append(" and gl_bankreceipt.pk_contrastaccount in (" + strTemp + ")");
|
|
|
+ }
|
|
|
+ if (query.isChecked() != null) {
|
|
|
+ if (query.isChecked().booleanValue())
|
|
|
+ strWhere.append(" and isnull(gl_contrast.contrastdate,'~') <> '~' ");
|
|
|
+ else
|
|
|
+ strWhere.append(" and isnull(gl_contrast.contrastdate,'~')='~' ");
|
|
|
+ }
|
|
|
+ if (query.isVerified() != null) {
|
|
|
+ if (query.isVerified().booleanValue())
|
|
|
+ strWhere.append(" and isnull(gl_contrast.cavdate,'~') <> '~' ");
|
|
|
+ else
|
|
|
+ strWhere.append(" and isnull(gl_contrast.cavdate,'~')='~' ");
|
|
|
+ }
|
|
|
+ if (query.getPk_link() != null && !query.isMerge())
|
|
|
+ strWhere.append(" and gl_bankreceipt.memo = '" + query.getPk_link()
|
|
|
+ + "' ");
|
|
|
+
|
|
|
+ if (query.getYear() != null)
|
|
|
+ strWhere.append(" and gl_bankreceipt.years = '" + query.getYear()
|
|
|
+ + "' ");
|
|
|
+ if (query.isInitRange() != null) {
|
|
|
+ if (query.isInitRange().booleanValue())
|
|
|
+ {
|
|
|
+ strWhere.append(" and gl_bankreceipt.period = '00' ");
|
|
|
+ strWhere.append(" AND gl_bankreceipt.checkdate <( select startdate from gl_accountstart where gl_accountstart.PK_CONTRASTACCOUNT = gl_bankreceipt.PK_CONTRASTACCOUNT and gl_accountstart.years = gl_bankreceipt.years) ");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ strWhere.append(" and (gl_bankreceipt.period <> '00' ");
|
|
|
+ strWhere.append(" AND gl_bankreceipt.checkdate <( select startdate from gl_accountstart where gl_accountstart.PK_CONTRASTACCOUNT = gl_bankreceipt.PK_CONTRASTACCOUNT and gl_accountstart.years = gl_bankreceipt.years) ");
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * 增加对方单位查询条件
|
|
|
+ * 2022/03/31
|
|
|
+ * @author YY
|
|
|
+ *
|
|
|
+ */
|
|
|
+ if(query.getOppunitname() != null) {
|
|
|
+ strWhere.append(" and gl_bankreceipt.oppunitname like '%"+query.getOppunitname()+"%' ");
|
|
|
+ }
|
|
|
+ //查询勾兑情况---包括余额调节表查询勾兑,按勾兑日期查询
|
|
|
+ if(query.getNodecode()==20040120 && query.isChecked() != null && query.isChecked()){
|
|
|
+ if (query.getBankBegDate() != null) {
|
|
|
+ strWhere.append(" and gl_contrast.contrastdate >= '"
|
|
|
+ + query.getBankBegDate() + "'");
|
|
|
+ }
|
|
|
+ if (query.getBankEndDate() != null) {
|
|
|
+ strWhere.append(" and gl_contrast.contrastdate <= '"
|
|
|
+ + query.getBankEndDate() + "'");
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if (query.getBankBegDate() != null) {
|
|
|
+ strWhere.append(" and gl_bankreceipt.checkdate >= '"
|
|
|
+ + query.getBankBegDate() + "'");
|
|
|
+ }
|
|
|
+ if (query.getBankEndDate() != null) {
|
|
|
+ strWhere.append(" and gl_bankreceipt.checkdate <= '"
|
|
|
+ + query.getBankEndDate() + "'");
|
|
|
+ }
|
|
|
+ if (query.getM_stopDate() != null)
|
|
|
+ strWhere.append(" and gl_bankreceipt.checkdate < '"
|
|
|
+ + query.getM_stopDate() + "'");
|
|
|
+ }
|
|
|
+ /* zhaozh 2008-5-30 下午01:45:24 增加银行对帐单票据日期查询条件 */
|
|
|
+ if (query.getN_pjdate1() != null) {
|
|
|
+ strWhere.append(" and gl_bankreceipt.checkdate >= '"
|
|
|
+ + query.getN_pjdate1() + "'");
|
|
|
+ }
|
|
|
+ if (query.getN_pjdate2() != null) {
|
|
|
+ strWhere.append(" and gl_bankreceipt.checkdate <= '"
|
|
|
+ + query.getN_pjdate2() + "'");
|
|
|
+ }
|
|
|
+ // 结算方式(增加不等于情况)
|
|
|
+ if (query.getCheckStyle() != null && query.getCheckStyle().length() > 0 ){
|
|
|
+ if(query.getIsEqualCheckStyle()== null || query.getIsEqualCheckStyle().booleanValue()){
|
|
|
+ strWhere.append(" and gl_bankreceipt.checkstyle = '"
|
|
|
+ + query.getCheckStyle() + "'");
|
|
|
+ }else{
|
|
|
+ strWhere.append(" and gl_bankreceipt.checkstyle <> '"
|
|
|
+ + query.getCheckStyle() + "'");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 结算号
|
|
|
+ if (query.getCheckNO() != null && query.getCheckNO().length() > 0)
|
|
|
+ strWhere.append(" and gl_bankreceipt.pk_check = '"
|
|
|
+ + query.getCheckNO().replaceAll("'", "''") + "'");
|
|
|
+
|
|
|
+ // 只查异常记录
|
|
|
+ if (query.getOnlyWrongRec() != null
|
|
|
+ && query.getOnlyWrongRec().booleanValue()) {
|
|
|
+ strWhere.append(" and gl_bankreceipt.styleflag='B' ");
|
|
|
+ } else {
|
|
|
+ strWhere.append(" and (gl_bankreceipt.styleflag='A' or isnull(gl_bankreceipt.styleflag,'~')='~') ");
|
|
|
+ }
|
|
|
+ // 按批次号查询 @author zhaozh 2008-6-16 下午01:45:33
|
|
|
+ if (query.getBatchNumber() != null
|
|
|
+ && !query.getBatchNumber().equals(""))
|
|
|
+ strWhere.append(" and gl_contrast.batchnumber='"
|
|
|
+ + NCESAPI.sqlEncode(query.getBatchNumber()) + "'");
|
|
|
+ strSql.append(" where " + strWhere.substring(4));
|
|
|
+
|
|
|
+ strSql.append(" order by checkdate,gl_bankreceipt.memo,gl_bankreceipt.pk_bankreceipt");
|
|
|
+ Vector<BankReceiptVO> vecResult = new Vector<BankReceiptVO>();
|
|
|
+ Connection con = null;
|
|
|
+ PreparedStatement stmt = null;
|
|
|
+
|
|
|
+ java.util.HashSet<String> checkSet = new java.util.HashSet<String>();
|
|
|
+ java.util.HashMap checkMap = new java.util.HashMap();
|
|
|
+ Object[] checktemp = null;
|
|
|
+
|
|
|
+ try {
|
|
|
+ con = getConnection();
|
|
|
+ stmt = con.prepareStatement(strSql.toString());
|
|
|
+ Logger.debug(" 开始银行查询"
|
|
|
+ + new nc.vo.pub.lang.UFDateTime(new java.util.Date()));
|
|
|
+ ResultSet rs = stmt.executeQuery();
|
|
|
+ Logger.debug(" 开始银行查询"
|
|
|
+ + new nc.vo.pub.lang.UFDateTime(new java.util.Date()));
|
|
|
+ //
|
|
|
+ while (rs.next()) {
|
|
|
+ BankReceiptVO bankreceipt = new BankReceiptVO();
|
|
|
+ bankreceipt.setPk_bankreceipt(rs.getString(1));
|
|
|
+ bankreceipt.setPk_contrastaccount(rs.getString(2));
|
|
|
+ bankreceipt.setExplanation(rs.getString(3));
|
|
|
+
|
|
|
+ strTemp = rs.getString(4);
|
|
|
+ bankreceipt.setCheckstyle(strTemp == null ? strTemp : strTemp
|
|
|
+ .trim());
|
|
|
+
|
|
|
+ if (bankreceipt.getCheckstyle() != null) {
|
|
|
+ checkSet.add(bankreceipt.getCheckstyle());
|
|
|
+ }
|
|
|
+ strTemp = rs.getString(5);
|
|
|
+ bankreceipt.setPk_check(strTemp == null ? strTemp : strTemp
|
|
|
+ .trim());
|
|
|
+ // checkdate :
|
|
|
+ String checkdate = rs.getString(6);
|
|
|
+ bankreceipt.setCheckdate(checkdate == null ? null : new UFDate(
|
|
|
+ checkdate.trim()));
|
|
|
+ Object t1 = rs.getObject(7);
|
|
|
+ Object t2 = rs.getObject(8);
|
|
|
+ // 2004-05-12
|
|
|
+ if (t1 != null) {
|
|
|
+ bankreceipt.setDebitamount(new UFDouble(t1.toString()));
|
|
|
+ } else {
|
|
|
+ bankreceipt.setDebitamount(new UFDouble(0.0));
|
|
|
+ }
|
|
|
+ if (t2 != null) {
|
|
|
+ bankreceipt.setCreditamount(new UFDouble(t2.toString()));
|
|
|
+ } else {
|
|
|
+ bankreceipt.setCreditamount(new UFDouble(0.0));
|
|
|
+ }
|
|
|
+
|
|
|
+ bankreceipt.setYears(rs.getString(9));
|
|
|
+ bankreceipt.setPeriod(rs.getString(10));
|
|
|
+ // flag 勾对标记 :
|
|
|
+ int flags = rs.getInt(11);
|
|
|
+ bankreceipt.setflag(Integer.valueOf(flags));
|
|
|
+
|
|
|
+ bankreceipt.setMemo(rs.getString(12));
|
|
|
+ bankreceipt.setPk_corp(rs.getString(13));
|
|
|
+ bankreceipt.setPk_subject(rs.getString(14));
|
|
|
+ bankreceipt.setPk_bank(rs.getString(15));
|
|
|
+ bankreceipt.setPk_ass(rs.getString(16));
|
|
|
+ // add by zhaozh 增加批次号
|
|
|
+ bankreceipt.setBatchNumber(rs.getString(17));
|
|
|
+ bankreceipt.setNetbanknumber(rs.getString(18));
|
|
|
+ bankreceipt.setStyleflag(rs.getString(19));
|
|
|
+ bankreceipt.setPk_corp(rs.getString(20));
|
|
|
+ bankreceipt.setPk_group(rs.getString(21));
|
|
|
+ bankreceipt.setOppunitname(rs.getString(22));
|
|
|
+ bankreceipt.setNusage(rs.getString(23));
|
|
|
+ bankreceipt.setTranserial(rs.getString(24));
|
|
|
+ vecResult.addElement(bankreceipt);
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ if (stmt != null) {
|
|
|
+ stmt.close();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ if (con != null) {
|
|
|
+ con.close();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // ////////////////////////////////////////////////
|
|
|
+ checktemp = checkSet.toArray();
|
|
|
+ nc.bs.gl.bookinterface.VoucherDetailDMO dmos = new nc.bs.gl.bookinterface.VoucherDetailDMO();
|
|
|
+ checkMap = dmos.getCheckNamesByPKs(checktemp);
|
|
|
+ if (checkMap == null) {
|
|
|
+ checkMap = new java.util.HashMap();
|
|
|
+ }
|
|
|
+ // ///////////////////////////////////////////////
|
|
|
+
|
|
|
+ Object checkpk = null;
|
|
|
+ // 转化为CTransferVO
|
|
|
+ BankKeyTool keyTool = new BankKeyTool();
|
|
|
+ CTransferVO[] corpreceipts = new CTransferVO[vecResult.size()];
|
|
|
+ for (int j = 0; j < vecResult.size(); j++) {
|
|
|
+ CTransferVO votemp = new CTransferVO();
|
|
|
+ BankReceiptVO bankreceipt = vecResult.elementAt(j);
|
|
|
+ checkpk = checkMap.get(bankreceipt.getCheckstyle());
|
|
|
+ if (checkpk != null) {
|
|
|
+ bankreceipt.setCheckstyle(checkpk.toString());
|
|
|
+ }
|
|
|
+ // bankreceipt.setCheckstyle(getCheckStyleName(bankreceipt.getCheckstyle()));
|
|
|
+ votemp.setVo(bankreceipt);
|
|
|
+ votemp.setKeyTool(keyTool);
|
|
|
+ votemp.setPk_account(bankreceipt.getPk_contrastaccount());
|
|
|
+ // ncm heyl 对于已经核销的记录也计入调节的范围。(参照单位方的设置方式)
|
|
|
+ votemp.setCaved(bankreceipt.getflag().intValue() > 0 ? Boolean.TRUE
|
|
|
+ : Boolean.FALSE);
|
|
|
+ votemp.setM_pk_link(bankreceipt.getMemo());
|
|
|
+ votemp.setM_pk_corp(bankreceipt.getPk_corp());
|
|
|
+ votemp.setM_pk_subject(bankreceipt.getPk_subject());
|
|
|
+ votemp.setM_pk_bank(bankreceipt.getPk_bank());
|
|
|
+ votemp.setM_pk_ass(bankreceipt.getPk_ass());
|
|
|
+ // 设置返回结果批次号
|
|
|
+ votemp.setBatchNumber(bankreceipt.getBatchNumber());
|
|
|
+ votemp.setNetbanknumber(bankreceipt.getNetbanknumber());
|
|
|
+ votemp.setStyleflag(bankreceipt.getStyleflag());
|
|
|
+ votemp.setPk_group(bankreceipt.getPk_group());
|
|
|
+ votemp.setOppunitname(bankreceipt.getOppunitname());
|
|
|
+ votemp.setNusage(bankreceipt.getNusage());
|
|
|
+ votemp.setTranserial(bankreceipt.getTranserial());
|
|
|
+ corpreceipts[j] = votemp;
|
|
|
+ }
|
|
|
+
|
|
|
+ /*************************************************************/
|
|
|
+ // 保留的系统管理接口:
|
|
|
+ afterCallMethod("nc.bs.gl.contrastpub.QueryDMO", "getBankReceipt",
|
|
|
+ new Object[] { query });
|
|
|
+ /*************************************************************/
|
|
|
+
|
|
|
+ return corpreceipts;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 得到结算类型
|
|
|
+ *
|
|
|
+ */
|
|
|
+ private String getCheckStyleName(String pk_balatype,Map<String,String> checkStyleNames) throws Exception {
|
|
|
+ if(!checkStyleNames.containsKey(pk_balatype)){
|
|
|
+ BalaTypeVO btvo = getBalaQry().findBalaTypeVOByPK(pk_balatype);
|
|
|
+ if(null != btvo){
|
|
|
+
|
|
|
+ String name = VOUtil.getMultiLangText(btvo, BalaTypeVO.NAME);
|
|
|
+ checkStyleNames.put(pk_balatype, name);
|
|
|
+ return name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return checkStyleNames.get(pk_balatype);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**********************************************************************************************************
|
|
|
+ * 功能: 根据Key值生成相应的数据访问类 参数: CQueryVO query 查询条件 返回: CBalanceVO[]
|
|
|
+ **********************************************************************************************************/
|
|
|
+ public Object getClassName(Integer intSourceID, String strType)
|
|
|
+ throws Exception {
|
|
|
+ Object cName = null;
|
|
|
+ ContrastclassDMO dmo = new ContrastclassDMO();
|
|
|
+ ContrastClassVO queryvo = new ContrastClassVO();
|
|
|
+ queryvo.setSourceid(intSourceID.toString());
|
|
|
+ queryvo.setClasstype(strType);
|
|
|
+ ContrastClassVO[] result = dmo.queryByVO(queryvo, new Boolean(true));
|
|
|
+ if (result != null && result.length != 0) {
|
|
|
+ String str = result[0].getClassname();
|
|
|
+ if (intSourceID.intValue() == 1) {
|
|
|
+ Class className = java.lang.Class.forName(str.trim());
|
|
|
+ cName = className.newInstance();
|
|
|
+ } else {
|
|
|
+ cName = ObjectCreator.newInstance(result[0].getM_module(),
|
|
|
+ str);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return cName;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**********************************************************************************************************
|
|
|
+ * 功能: 查询符合日期范围内的对账情况 参数: CQueryVO query 查询条件 返回:
|
|
|
+ **********************************************************************************************************/
|
|
|
+ public int getContrasts(CQueryVO query, String key, String accountKey)
|
|
|
+ throws SQLException {
|
|
|
+ /*************************************************************/
|
|
|
+ // 保留的系统管理接口:
|
|
|
+ beforeCallMethod("nc.bs.gl.contrastpub.QueryDMO", ".getContrasts()",
|
|
|
+ new Object[] { query });
|
|
|
+ /*************************************************************/
|
|
|
+
|
|
|
+ int result = 0;
|
|
|
+ String sql = "select count(pk_contrast) from gl_contrast ";
|
|
|
+ sql += " where contrastcode = ";
|
|
|
+ sql += "(select distinct contrastcode from gl_contrast where ";
|
|
|
+ if (query.isBank().booleanValue()) {
|
|
|
+ sql += " pk_bankreceipt ='" + key + "'";
|
|
|
+ } else {
|
|
|
+ sql += " fk_detail ='" + key + "'";
|
|
|
+ }
|
|
|
+ sql += " and pk_contrastaccount = '" + accountKey + "')";
|
|
|
+ if (query.getDate() != null) {
|
|
|
+ sql += " and corpdate > '" + query.getDate().toString() + "'";
|
|
|
+ }
|
|
|
+ if (query.getEndDate() != null) {
|
|
|
+ sql += " and corpdate > '" + query.getEndDate().toString() + "'";
|
|
|
+ }
|
|
|
+ sql += "";
|
|
|
+ Connection con = null;
|
|
|
+ PreparedStatement stmt = null;
|
|
|
+ try {
|
|
|
+ con = getConnection();
|
|
|
+ stmt = con.prepareStatement(sql);
|
|
|
+ ResultSet rs = stmt.executeQuery();
|
|
|
+ while (rs.next()) {
|
|
|
+ Object temp = rs.getObject(1);
|
|
|
+ if (temp != null && temp.toString().length() > 0) {
|
|
|
+ result = Integer.parseInt(temp.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ if (stmt != null) {
|
|
|
+ stmt.close();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ if (con != null) {
|
|
|
+ con.close();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /*************************************************************/
|
|
|
+ // 保留的系统管理接口:
|
|
|
+ afterCallMethod("nc.bs.gl.contrastpub.QueryDMO", ".getContrasts()",
|
|
|
+ new Object[] { query });
|
|
|
+ /*************************************************************/
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**********************************************************************************************************
|
|
|
+ * 功能: 得到单位到截止日期时(前)的余额 参数: CQueryVO query 查询条件 返回: CBalanceVO[]
|
|
|
+ **********************************************************************************************************/
|
|
|
+ public CTransferVO[] getCorpBalance(CQueryVO query) throws Exception {
|
|
|
+
|
|
|
+ Vector<CTransferVO> vecResult = new Vector<CTransferVO>();
|
|
|
+ nc.vo.glpub.IVoAccess[] result = null;
|
|
|
+
|
|
|
+ IDataAccess dataAccess = null;
|
|
|
+ IKey keyTool = null;
|
|
|
+
|
|
|
+ // 设置部分单位账查询条件
|
|
|
+ CConditionVO corpCondition = new CConditionVO();
|
|
|
+ corpCondition.setDate(query.getDate());
|
|
|
+ corpCondition.setEndDate(query.getEndDate());
|
|
|
+ corpCondition.setIncludeLast(query.isIncludeLast());
|
|
|
+
|
|
|
+ if (query.getPk_Account() == null || query.getPk_Account().length == 0)
|
|
|
+ throw new Exception(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("3607con_0","03607con-0505")/*@res "未指定要是用的对账对象!"*/);
|
|
|
+
|
|
|
+ CBalanceKeyTool banlanKeyTool = new CBalanceKeyTool();
|
|
|
+ for (int i = 0; i < query.getPk_Account().length; i++) {
|
|
|
+ ContrastAccountVO accountVO = getAccount(query.getPk_Account()[i]);
|
|
|
+ Integer intSourceID = accountVO.getSource();
|
|
|
+
|
|
|
+ corpCondition.setPk_currtype(accountVO.getPk_currtype());
|
|
|
+ corpCondition.setM_isConTally(accountVO.getM_isConTally());
|
|
|
+ if (query.isInitRange() != null
|
|
|
+ && query.isInitRange().booleanValue()) {
|
|
|
+ corpCondition.setDate(getStartDate(accountVO
|
|
|
+ .getPk_contrastaccount(), query.getYear()));
|
|
|
+ }
|
|
|
+ // 得到反射类
|
|
|
+ if (intSourceID != 1) {// 从资金帐查询数据
|
|
|
+ corpCondition.setDate(getStartDate(accountVO
|
|
|
+ .getPk_contrastaccount(), query.getYear()));
|
|
|
+ corpCondition.setEndDate(query.getEndDate());
|
|
|
+ dataAccess = new ImpCMPDataAccess();
|
|
|
+ keyTool = new DefaultKeyTool();
|
|
|
+ } else {
|
|
|
+ dataAccess = (IDataAccess) getClassName(intSourceID, "class");
|
|
|
+ keyTool = (IKey) getClassName(intSourceID, "balance");
|
|
|
+ if (query.getDate() != null)
|
|
|
+ corpCondition.setDate(query.getDate());
|
|
|
+ else {
|
|
|
+ corpCondition.setDate(getStartDate(accountVO
|
|
|
+ .getPk_contrastaccount(), query.getYear()));
|
|
|
+ corpCondition.setEndDate(query.getEndDate());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ AccountlinkVO[] links = getLink(query.getPk_Account()[i], query
|
|
|
+ .getYear());
|
|
|
+ CBalanceVO balanceValue = new CBalanceVO();
|
|
|
+ balanceValue.setPk_account(query.getPk_Account()[i]);
|
|
|
+ UFDouble dblDebit = UFDouble.ZERO_DBL;
|
|
|
+ UFDouble dblCredit = UFDouble.ZERO_DBL;
|
|
|
+ Object objTemp;
|
|
|
+ if (links != null && links.length > 0) {
|
|
|
+ for (int iLink = 0; iLink < links.length; iLink++) {
|
|
|
+ corpCondition.setBankAccount(new String[] { links[iLink]
|
|
|
+ .getBankaccount() });
|
|
|
+ corpCondition.setPk_corp(links[iLink].getPk_corp());
|
|
|
+ corpCondition.setPk_accsubj(new String[] { links[iLink]
|
|
|
+ .getPk_subject() });
|
|
|
+ corpCondition.setAssID(links[iLink].getPk_ass());
|
|
|
+ corpCondition.setPk_contrastAccount(links[iLink]
|
|
|
+ .getPk_contrastaccount());
|
|
|
+ corpCondition.setYears(links[iLink].getYears());
|
|
|
+ corpCondition.setMonths(links[iLink].getPeriod());
|
|
|
+ corpCondition.setPk_accountlink(links[iLink]
|
|
|
+ .getPk_accountlink());
|
|
|
+ // 得到单位期初余额
|
|
|
+ if (dataAccess == null)
|
|
|
+ return null;
|
|
|
+ result = dataAccess.queryBalance(corpCondition);
|
|
|
+
|
|
|
+ // 转化为CTransferVO
|
|
|
+ for (int j = 0; result != null && j < result.length; j++) {
|
|
|
+ objTemp = result[j].getValue(keyTool
|
|
|
+ .getBusinessKey(CCorpReceiptKey.DEBITAMOUNT));
|
|
|
+ dblDebit = dblDebit
|
|
|
+ .add(new UFDouble(objTemp.toString()));
|
|
|
+ objTemp = result[j].getValue(keyTool
|
|
|
+ .getBusinessKey(CCorpReceiptKey.CREDITAMOUNT));
|
|
|
+ dblCredit = dblCredit
|
|
|
+ .add(null == objTemp ? new UFDouble(0)
|
|
|
+ : new UFDouble(objTemp.toString()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ balanceValue.setDebitamount(dblDebit.sub(dblCredit));
|
|
|
+ balanceValue.setCreditamount(new UFDouble(0));
|
|
|
+ CTransferVO transvo = new CTransferVO();
|
|
|
+ transvo.setVo(balanceValue);
|
|
|
+ transvo.setKeyTool(banlanKeyTool);
|
|
|
+ transvo.setPk_account(query.getPk_Account()[i]);
|
|
|
+ vecResult.addElement(transvo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ CTransferVO[] resultVos = new CTransferVO[vecResult.size()];
|
|
|
+ vecResult.copyInto(resultVos);
|
|
|
+ return resultVos;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**********************************************************************************************************
|
|
|
+ * 功能: 得到银行到截止日期时(前)的余额 参数: CQueryVO query 查询条件 返回: CBalanceVO[]
|
|
|
+ *
|
|
|
+ * @author zhaozh 创建日期:(2008-8-5 下午03:45:06) 修改:资金帐多单位取余额
|
|
|
+ **********************************************************************************************************/
|
|
|
+ public CTransferVO[] getCorpBalanceSpread(CQueryVO query) throws Exception {
|
|
|
+
|
|
|
+ Vector<CTransferVO> vecResult = new Vector<CTransferVO>();
|
|
|
+ nc.vo.glpub.IVoAccess[] result = null;
|
|
|
+
|
|
|
+ IDataAccess dataAccess = null;
|
|
|
+ IKey keyTool = null;
|
|
|
+
|
|
|
+ // 设置部分单位账查询条件
|
|
|
+ CConditionVO corpCondition = new CConditionVO();
|
|
|
+ corpCondition.setDate(query.getDate());
|
|
|
+ corpCondition.setEndDate(query.getEndDate());
|
|
|
+ corpCondition.setIncludeLast(query.isIncludeLast());
|
|
|
+ if (query.getPk_Account() == null || query.getPk_Account().length == 0)
|
|
|
+ throw new Exception(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("3607con_0","03607con-0505")/*@res "未指定要是用的对账对象!"*/);
|
|
|
+
|
|
|
+ CBalanceKeyTool banlanKeyTool = new CBalanceKeyTool();
|
|
|
+ for (int i = 0; i < query.getPk_Account().length; i++) {
|
|
|
+ ContrastAccountVO accountVO = getAccount(query.getPk_Account()[i]);
|
|
|
+ Integer intSourceID = accountVO.getSource();
|
|
|
+ // 取反射类
|
|
|
+ if (intSourceID != 1) {// 从资金帐查询数据
|
|
|
+ corpCondition.setDate(getStartDate(accountVO
|
|
|
+ .getPk_contrastaccount(), query.getYear()));
|
|
|
+ corpCondition.setEndDate(query.getDate());
|
|
|
+ dataAccess = new ImpCMPDataAccess();
|
|
|
+ keyTool = new DefaultKeyTool();
|
|
|
+ } else {
|
|
|
+ dataAccess = (IDataAccess) getClassName(intSourceID, "class");
|
|
|
+ keyTool = (IKey) getClassName(intSourceID, "balance");
|
|
|
+ if (query.getDate() != null)
|
|
|
+ corpCondition.setDate(query.getDate());
|
|
|
+ else
|
|
|
+ corpCondition.setDate(getStartDate(accountVO
|
|
|
+ .getPk_contrastaccount(), query.getYear()));
|
|
|
+ corpCondition.setEndDate(query.getEndDate());
|
|
|
+ }
|
|
|
+ corpCondition.setPk_currtype(accountVO.getPk_currtype());
|
|
|
+ if (query.isInitRange() != null
|
|
|
+ && query.isInitRange().booleanValue()) {
|
|
|
+ corpCondition.setDate(getStartDate(accountVO
|
|
|
+ .getPk_contrastaccount(), query.getYear()));
|
|
|
+ }
|
|
|
+ // add by v5
|
|
|
+ corpCondition.setM_isConTally(accountVO.getM_isConTally());
|
|
|
+ // add bt zhaozh加入帐户启动日期
|
|
|
+ corpCondition.setAccountStartDate(getStartDate(accountVO
|
|
|
+ .getPk_contrastaccount(), query.getYear()));
|
|
|
+ // 得到反射类
|
|
|
+ // dataAccess = (IDataAccess) getClassName(intSourceID, "class");
|
|
|
+ // keyTool = (IKey) getClassName(intSourceID, "balance");
|
|
|
+ // if(dataAccess == null){
|
|
|
+ // dataAccess = new ImpCMPDataAccess();
|
|
|
+ // keyTool = new DefaultKeyTool();
|
|
|
+ // }
|
|
|
+ AccountlinkVO[] links = getLink(query.getPk_Account()[i], query
|
|
|
+ .getYear());
|
|
|
+ UFDouble dblDebit = new UFDouble(0);
|
|
|
+ UFDouble dblCredit = new UFDouble(0);
|
|
|
+ Object objTemp;
|
|
|
+ if (links != null && links.length > 0) {
|
|
|
+ for (int iLink = 0; iLink < links.length; iLink++) {
|
|
|
+ corpCondition.setBankAccount(new String[] { links[iLink]
|
|
|
+ .getBankaccount() });
|
|
|
+ corpCondition.setPk_corp(links[iLink].getPk_corp());
|
|
|
+ corpCondition.setPk_accsubj(new String[] { links[iLink]
|
|
|
+ .getPk_subject() });
|
|
|
+ corpCondition.setAssID(links[iLink].getPk_ass());
|
|
|
+ corpCondition.setPk_accountlink(links[iLink]
|
|
|
+ .getPk_accountlink());
|
|
|
+ corpCondition.setPk_contrastAccount(links[iLink]
|
|
|
+ .getPk_contrastaccount());
|
|
|
+ // 得到单位期初余额
|
|
|
+ result = dataAccess.queryBalance(corpCondition);
|
|
|
+ CBalanceVO balanceValue = new CBalanceVO();
|
|
|
+ balanceValue.setPk_account(query.getPk_Account()[i]);
|
|
|
+ // 转化为CTransferVO
|
|
|
+ dblDebit = new UFDouble(0);
|
|
|
+ dblCredit = new UFDouble(0);
|
|
|
+ for (int j = 0; result != null && j < result.length; j++) {
|
|
|
+ objTemp = result[j].getValue(keyTool
|
|
|
+ .getBusinessKey(CCorpReceiptKey.DEBITAMOUNT));
|
|
|
+ dblDebit = dblDebit.add(null == objTemp ? new UFDouble(
|
|
|
+ 0) : new UFDouble(objTemp.toString()));
|
|
|
+ objTemp = result[j].getValue(keyTool
|
|
|
+ .getBusinessKey(CCorpReceiptKey.CREDITAMOUNT));
|
|
|
+ dblCredit = dblCredit
|
|
|
+ .add(null == objTemp ? new UFDouble(0)
|
|
|
+ : new UFDouble(objTemp.toString()));
|
|
|
+ }
|
|
|
+ balanceValue.setDebitamount(dblDebit.sub(dblCredit));
|
|
|
+ balanceValue.setCreditamount(new UFDouble(0));
|
|
|
+ balanceValue.setM_pk_link(links[iLink].getPk_accountlink());
|
|
|
+ balanceValue.setM_pk_corp(links[iLink].getPk_corp());
|
|
|
+ balanceValue.setM_pk_subject(links[iLink].getPk_subject());
|
|
|
+ balanceValue.setM_pk_bank(links[iLink].getBankaccount());
|
|
|
+ balanceValue.setM_pk_ass(links[iLink].getPk_ass());
|
|
|
+ CTransferVO transvo = new CTransferVO();
|
|
|
+ transvo.setVo(balanceValue);
|
|
|
+ transvo.setKeyTool(banlanKeyTool);
|
|
|
+ transvo.setPk_account(query.getPk_Account()[i]);
|
|
|
+ transvo.setM_pk_link(links[iLink].getPk_accountlink());
|
|
|
+ transvo.setM_pk_corp(links[iLink].getPk_corp());
|
|
|
+ transvo.setM_pk_subject(links[iLink].getPk_subject());
|
|
|
+ transvo.setM_pk_bank(links[iLink].getBankaccount());
|
|
|
+ transvo.setM_pk_ass(links[iLink].getPk_ass());
|
|
|
+ vecResult.addElement(transvo);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ CTransferVO[] resultVos = new CTransferVO[vecResult.size()];
|
|
|
+ vecResult.copyInto(resultVos);
|
|
|
+ return resultVos;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**********************************************************************************************************
|
|
|
+ * 功能: 查询单位日记账(所有) 参数: CQueryVO query 查询条件 返回: BankReceiptVO[]
|
|
|
+ **********************************************************************************************************/
|
|
|
+ public CTransferVO[] getCorpReceipt(CQueryVO query) throws Exception {
|
|
|
+ // 得到单位期初数据,不用通过接口
|
|
|
+ CTransferVO[] result1 = getCorpReceiptInit(query);
|
|
|
+ CTransferVO[] result2 = null;
|
|
|
+ // if (query.isInitRange() == null ||
|
|
|
+ // !query.isInitRange().booleanValue()) {
|
|
|
+ // 通过接口得到单位数据
|
|
|
+ result2 = getCorpReceiptOccur(query);
|
|
|
+ // }
|
|
|
+ int count1 = result1 == null ? 0 : result1.length;
|
|
|
+ int count2 = result2 == null ? 0 : result2.length;
|
|
|
+ // 连接两种数据
|
|
|
+ CTransferVO[] corpreceipts = new CTransferVO[count1 + count2];
|
|
|
+ for (int i = 0; i < count1; i++) {
|
|
|
+ corpreceipts[i] = result1[i];
|
|
|
+ }
|
|
|
+ for (int i = 0; i < count2; i++) {
|
|
|
+ corpreceipts[count1 + i] = result2[i];
|
|
|
+ }
|
|
|
+
|
|
|
+ return corpreceipts;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**********************************************************************************************************
|
|
|
+ * 功能:查询单位期初日记账 参数:CQueryVO query 查询条件 返回:BankReceiptVO[] 修改:@author zhaozh
|
|
|
+ * 2008-6-12 上午10:34:54 增加单位期初 批次号查询:batchnumber
|
|
|
+ **********************************************************************************************************/
|
|
|
+ private CTransferVO[] getCorpReceiptInit(CQueryVO query) throws Exception {
|
|
|
+ /*************************************************************/
|
|
|
+ // 保留的系统管理接口:
|
|
|
+ beforeCallMethod("nc.bs.gl.contrastpub.QueryDMO", "getCorpReceiptInit",
|
|
|
+ new Object[] { query });
|
|
|
+ /*************************************************************/
|
|
|
+ String[] pk_account = query.getPk_Account();
|
|
|
+ String strTemp = "";
|
|
|
+ for (int i = 0; i < pk_account.length; i++) {
|
|
|
+ strTemp = strTemp + "'" + pk_account[i] + "',";
|
|
|
+ }
|
|
|
+ if (strTemp.length() > 0) {
|
|
|
+ strTemp = strTemp.substring(0, strTemp.length() - 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ // modified by zhufeng 2013-1-31 start
|
|
|
+ StringBuilder sqlBuilder = new StringBuilder();
|
|
|
+ sqlBuilder.append(" select pk_corpreceipt,gl_corpreceipt.pk_contrastaccount,pk_vouchertype,vouchno,prepareddate,explanation,gl_corpreceipt.debitamount,gl_corpreceipt.creditamount ,checkstyle,checkno ,checkdate,gl_corpreceipt.years, ");
|
|
|
+ sqlBuilder.append(" case when isnull(gl_contrast.cavdate,'~')='~' and isnull(gl_contrast.contrastdate,'~')='~' then 0 else case when isnull(gl_contrast.cavdate,'~')='~' then 1 else 2 end end ");
|
|
|
+ sqlBuilder.append(" ,gl_corpreceipt.memo,gl_corpreceipt.pk_corp,gl_corpreceipt.pk_subject,gl_corpreceipt.pk_bank,gl_corpreceipt.pk_ass,gl_contrast.batchnumber,gl_corpreceipt.netbanknumber,gl_corpreceipt.pk_org,gl_corpreceipt.pk_group,gl_corpreceipt.pk_accountlink,gl_corpreceipt.transerial");
|
|
|
+ sqlBuilder.append(" from gl_corpreceipt left outer join gl_contrast on gl_corpreceipt.pk_corpreceipt = gl_contrast.fk_detail ");
|
|
|
+ //查询勾兑情况---包括余额调节表查询勾兑,按勾兑日期查询
|
|
|
+ if(query.getNodecode()==20040120 && query.isChecked() != null && query.isChecked()){
|
|
|
+ if (query.getDate() != null) {
|
|
|
+ sqlBuilder.append( " and gl_contrast.contrastdate >= '"
|
|
|
+ + query.getDate().toString() + "'");
|
|
|
+ }
|
|
|
+ if (query.getEndDate() != null) {
|
|
|
+ sqlBuilder.append(" and gl_contrast.contrastdate <= '"
|
|
|
+ + query.getEndDate().toString() + "'");
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if (query.getDate() != null) {
|
|
|
+ sqlBuilder.append(" and gl_contrast.corpdate >= '"
|
|
|
+ + query.getDate().toString() + "'");
|
|
|
+ }
|
|
|
+ if (query.getEndDate() != null) {
|
|
|
+ sqlBuilder.append(" and gl_contrast.corpdate <= '"
|
|
|
+ + query.getEndDate().toString() + "'");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ StringBuffer strWhere = new StringBuffer("");
|
|
|
+ if (query.isM_cavDetai()) {
|
|
|
+ // 核销明细
|
|
|
+ strWhere.append(" and gl_contrast.cavdate = '"
|
|
|
+ + query.getM_cavDate() + "' ");
|
|
|
+ if (query.getM_cavMan() == null) {
|
|
|
+ strWhere.append(" and isnull(gl_contrast.cavman,'~')='~'");
|
|
|
+ } else {
|
|
|
+ strWhere.append(" and gl_contrast.cavman = '"
|
|
|
+ + query.getM_cavMan() + "' ");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (query.isChecked() != null) {
|
|
|
+ if (query.isChecked().booleanValue())
|
|
|
+ strWhere.append(" and isnull(gl_contrast.contrastdate,'~') <> '~' ");
|
|
|
+ else
|
|
|
+ strWhere.append(" and isnull(gl_contrast.contrastdate,'~')='~' ");
|
|
|
+ }
|
|
|
+ //余额调节表,查询已勾兑数据,对账日期大于当前截止日期
|
|
|
+ if (query.getNodecode() == 20040115 && query.isM_bflag()
|
|
|
+ && null != query.getEndDate() && !"".equals(query.getEndDate())) {
|
|
|
+ strWhere.append(" and gl_contrast.contrastdate >'").append(query.getEndDate().toString()).append("' ");
|
|
|
+ }
|
|
|
+ if (query.isVerified() != null) {
|
|
|
+ if (query.isVerified().booleanValue())
|
|
|
+ strWhere.append(" and isnull(gl_contrast.cavdate,'~') <> '~' ");
|
|
|
+ else
|
|
|
+ strWhere.append(" and isnull(gl_contrast.cavdate,'~')='~' ");
|
|
|
+ }
|
|
|
+ if (query.getYear() != null)
|
|
|
+ strWhere.append(" and gl_corpreceipt.years = '" + query.getYear()
|
|
|
+ + "' ");
|
|
|
+ if (query.getPk_link() != null)
|
|
|
+ strWhere.append(" and gl_corpreceipt.memo = '" + query.getPk_link()
|
|
|
+ + "' ");
|
|
|
+ // added by zhufeng 2013-1-31 start
|
|
|
+ if(query.getNodecode()==20040120 && query.isChecked() != null && query.isChecked()){
|
|
|
+
|
|
|
+ } else {
|
|
|
+ if (query.getDate() != null) {
|
|
|
+ // added by zhufeng 2013-1-31 start
|
|
|
+ strWhere.append("and gl_corpreceipt.prepareddate>= '" +
|
|
|
+ query.getDate().toString()+"' ");
|
|
|
+ // added by zhufeng 2013-1-31 end
|
|
|
+ }
|
|
|
+ if (query.getEndDate() != null) {
|
|
|
+ // added by zhufeng 2013-1-31 start
|
|
|
+ strWhere.append("and gl_corpreceipt.prepareddate<= '" +
|
|
|
+ query.getEndDate().toString()+"' ");
|
|
|
+ // added by zhufeng 2013-1-31 end
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // added by zhufeng 2013-1-31 end
|
|
|
+ //查询勾兑情况---包括余额调节表查询勾兑,按勾兑日期查询
|
|
|
+ if(query.getNodecode()!=20040120 && query.isChecked() != null && !query.isChecked()){
|
|
|
+ if (query.getDate() != null)
|
|
|
+ strWhere.append(" and gl_corpreceipt.prepareddate >= '"
|
|
|
+ + query.getDate().toString() + "'");
|
|
|
+ if (query.getEndDate() != null)
|
|
|
+ strWhere.append(" and gl_corpreceipt.prepareddate <= '"
|
|
|
+ + query.getEndDate().toString() + "'");
|
|
|
+ }
|
|
|
+ // 结算号
|
|
|
+ if (query.getCheckNO() != null && query.getCheckNO().length() > 0)
|
|
|
+ strWhere.append(" and gl_corpreceipt.checkno = '"
|
|
|
+ + query.getCheckNO().replaceAll("'", "''") + "'");
|
|
|
+ // 结算方式
|
|
|
+ if (query.getCheckStyle() != null && query.getCheckStyle().length() > 0) {
|
|
|
+ if(query.getIsEqualCheckStyle() == null || query.getIsEqualCheckStyle().booleanValue()){
|
|
|
+ strWhere.append(" and gl_corpreceipt.checkstyle = '"
|
|
|
+ + query.getCheckStyle() + "'");
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ strWhere.append(" and gl_corpreceipt.checkstyle <> '"
|
|
|
+ + query.getCheckStyle() + "'");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if (strTemp.length() > 0)
|
|
|
+ strWhere.append(" and gl_corpreceipt.pk_contrastaccount in ( "
|
|
|
+ + strTemp + ") ");
|
|
|
+ // 按批次号查询 @author zhaozh 2008-6-16 下午01:45:33
|
|
|
+ if (query.getBatchNumber() != null
|
|
|
+ && !query.getBatchNumber().equals(""))
|
|
|
+ strWhere.append(" and gl_contrast.batchnumber='"
|
|
|
+ + NCESAPI.sqlEncode(query.getBatchNumber()) + "'");
|
|
|
+ Vector<CorpReceiptVO> vecResult = new Vector<CorpReceiptVO>();
|
|
|
+ Connection con = null;
|
|
|
+ PreparedStatement stmt = null;
|
|
|
+ java.util.HashSet<String> checkSet = new java.util.HashSet<String>();
|
|
|
+ java.util.HashMap checkMap = new java.util.HashMap();
|
|
|
+ Object[] checktemp = null;
|
|
|
+ Map<String,String> subjectMap = new HashMap<String, String>();
|
|
|
+ nc.bs.gl.bookinterface.VoucherDetailDMO dmos = new nc.bs.gl.bookinterface.VoucherDetailDMO();
|
|
|
+ try {
|
|
|
+ sqlBuilder.append(" where " + strWhere.toString().substring(4)
|
|
|
+ + " order by prepareddate,pk_vouchertype,vouchno ");
|
|
|
+ con = getConnection();
|
|
|
+ stmt = con.prepareStatement(sqlBuilder.toString());
|
|
|
+ Logger.debug(" 开始期初单位查询:" + sqlBuilder.toString());
|
|
|
+ // modified by zhufeng 2013-1-31 end
|
|
|
+ ResultSet rs = stmt.executeQuery();
|
|
|
+ while (rs.next()) {
|
|
|
+ CorpReceiptVO corpreceipt = new CorpReceiptVO();
|
|
|
+ corpreceipt.setPk_corpreceipt(rs.getString(1));
|
|
|
+ corpreceipt.setPk_contrastaccount(rs.getString(2));
|
|
|
+
|
|
|
+ corpreceipt.setPk_accountlink(rs.getString("pk_accountlink"));
|
|
|
+
|
|
|
+ corpreceipt.setPk_vouchertype(rs.getString(3));
|
|
|
+ strTemp = rs.getString(4);
|
|
|
+ corpreceipt.setVouchno(strTemp == null ? strTemp : strTemp
|
|
|
+ .trim());
|
|
|
+ corpreceipt.setPrepareddate(new UFDate(rs.getString(5)));
|
|
|
+ corpreceipt.setExplanation(rs.getString(6));
|
|
|
+ Object t1 = rs.getObject(7);
|
|
|
+ Object t2 = rs.getObject(8);
|
|
|
+ if (t1 != null) {
|
|
|
+ corpreceipt.setDebitamount(new UFDouble(t1.toString()));
|
|
|
+ }
|
|
|
+ if (t2 != null) {
|
|
|
+ corpreceipt.setCreditamount(new UFDouble(t2.toString()));
|
|
|
+ }
|
|
|
+ corpreceipt.setCheckstyle(rs.getString(9));
|
|
|
+ corpreceipt.setM_pk_checkstyle(rs.getString(9));
|
|
|
+ if (corpreceipt.getCheckstyle() != null) {
|
|
|
+ checkSet.add(corpreceipt.getCheckstyle());
|
|
|
+ }
|
|
|
+ strTemp = rs.getString(10);
|
|
|
+ corpreceipt.setCheckno(strTemp == null ? strTemp : strTemp
|
|
|
+ .trim());
|
|
|
+ // explanation :
|
|
|
+ String checkdate = rs.getString(11);
|
|
|
+ corpreceipt.setCheckdate(checkdate == null ? null : new UFDate(
|
|
|
+ checkdate));
|
|
|
+ corpreceipt.setYears(rs.getString(12));
|
|
|
+ corpreceipt.setflag(Integer.valueOf(rs.getInt(13)));
|
|
|
+ corpreceipt.setMemo(rs.getString(14));
|
|
|
+ corpreceipt.setPk_corp(rs.getString(15));
|
|
|
+ corpreceipt.setPk_subject(rs.getString(16));
|
|
|
+ subjectMap.put(rs.getString(16), null);
|
|
|
+ corpreceipt.setPk_bank(rs.getString(17));
|
|
|
+ corpreceipt.setPk_ass(rs.getString(18));
|
|
|
+ corpreceipt.setBatchNumber(rs.getString(19));
|
|
|
+ corpreceipt.setNetbanknumber(rs.getString(20));
|
|
|
+ corpreceipt.setPk_org(rs.getString(21));
|
|
|
+ corpreceipt.setPk_corp(rs.getString(21));
|
|
|
+ corpreceipt.setPk_group(rs.getString(22));
|
|
|
+ corpreceipt.setPk_accountlink(rs.getString(23));
|
|
|
+ corpreceipt.setTranserial(rs.getString(24));
|
|
|
+ vecResult.addElement(corpreceipt);
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ if (stmt != null) {
|
|
|
+ stmt.close();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ if (con != null) {
|
|
|
+ con.close();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ Logger.error(e.getMessage(), e);
|
|
|
+ throw new BusinessException(e.getMessage(), e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 转化为CTransferVO
|
|
|
+ CTransferVO[] corpreceipts = new CTransferVO[vecResult.size()];
|
|
|
+ UnitKeyTool keyTool = new UnitKeyTool();
|
|
|
+ CorpReceiptVO corpReceipt = null;
|
|
|
+ // ////////////////////////////////////////////////
|
|
|
+ checktemp = checkSet.toArray();
|
|
|
+ checkMap = dmos.getCheckNamesByPKs(checktemp);
|
|
|
+ if (checkMap == null) {
|
|
|
+ checkMap = new java.util.HashMap();
|
|
|
+ }
|
|
|
+
|
|
|
+ //期初未达的日记账日数和凭证数据处理不一直导致BUG NCdp205539898
|
|
|
+// subjectMap = dmos.getSubNamesByPKs(subjectMap.keySet().toArray(new String[0]));
|
|
|
+ // ///////////////////////////////////////////////
|
|
|
+ Object checkpk = null;
|
|
|
+ for (int j = 0; j < vecResult.size(); j++) {
|
|
|
+ CTransferVO votemp = new CTransferVO();
|
|
|
+ corpReceipt = vecResult.elementAt(j);
|
|
|
+
|
|
|
+ checkpk = checkMap.get(corpReceipt.getCheckstyle());
|
|
|
+ if (checkpk != null) {
|
|
|
+ corpReceipt.setCheckstyle(checkpk.toString());
|
|
|
+ }
|
|
|
+ String subjectName = subjectMap.get(corpReceipt.getPk_subject());
|
|
|
+ if (subjectName!=null) {
|
|
|
+ corpReceipt.setPk_subject(subjectName);
|
|
|
+ }
|
|
|
+ votemp.setVo(corpReceipt);
|
|
|
+ votemp.setKeyTool(keyTool);
|
|
|
+ votemp.setCaved(new Boolean(corpReceipt.flag.intValue() > 0));
|
|
|
+ votemp.setPk_account(corpReceipt.getPk_contrastaccount());
|
|
|
+ votemp.setPk_accountlink(corpReceipt.getPk_accountlink());
|
|
|
+ votemp.setM_pk_link(corpReceipt.getMemo());
|
|
|
+ votemp.setM_pk_corp(corpReceipt.getPk_corp());
|
|
|
+ votemp.setM_pk_subject(corpReceipt.getPk_subject());
|
|
|
+ votemp.setM_pk_bank(corpReceipt.getPk_bank());
|
|
|
+ votemp.setM_pk_ass(corpReceipt.getPk_ass());
|
|
|
+ votemp.setBatchNumber(corpReceipt.getBatchNumber());
|
|
|
+ votemp.setNetbanknumber(corpReceipt.getNetbanknumber());
|
|
|
+ votemp.setTranserial(corpReceipt.getTranserial());
|
|
|
+ votemp.setPk_group(corpReceipt.getPk_group());
|
|
|
+ votemp.setInit(new Boolean(true));
|
|
|
+ corpreceipts[j] = votemp;
|
|
|
+ }
|
|
|
+ /*************************************************************/
|
|
|
+ // 保留的系统管理接口:
|
|
|
+ afterCallMethod("nc.bs.gl.contrastpub.QueryDMO", "getCorpReceiptInit",
|
|
|
+ new Object[] { query });
|
|
|
+ /*************************************************************/
|
|
|
+ return corpreceipts;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**********************************************************************************************************
|
|
|
+ * 功能:查询单位日记账(非期初) 通过接口查询 参数:CQueryVO query 查询条件 返回:BankReceiptVO[]
|
|
|
+ **********************************************************************************************************/
|
|
|
+ private CTransferVO[] getCorpReceiptOccur(CQueryVO query) throws Exception {
|
|
|
+ Vector<CTransferVO> vecResult = new Vector<CTransferVO>();
|
|
|
+ nc.vo.glpub.IVoAccess[] result = null;
|
|
|
+ IDataAccess dataAccess = null;
|
|
|
+ IKey keyTool = null;
|
|
|
+ // 设置部分单位账查询条件
|
|
|
+ CConditionVO corpCondition = new CConditionVO();
|
|
|
+ corpCondition.setDate(query.getDate());
|
|
|
+ corpCondition.setEndDate(query.getEndDate());
|
|
|
+ corpCondition.setIncludeLast(query.isIncludeLast());
|
|
|
+ corpCondition.setM_isConTally(query.getM_isConTally());
|
|
|
+ // songwb 添加结算号和结算方式
|
|
|
+ corpCondition.setM_strCheckNO(query.getCheckNO());
|
|
|
+ corpCondition.setM_strCheckStyle(query.getCheckStyle());
|
|
|
+ if (query.getIsEqualCheckStyle() == null)
|
|
|
+ corpCondition.setM_ischeckstyle(Boolean.TRUE);
|
|
|
+ else
|
|
|
+ corpCondition.setM_ischeckstyle(new Boolean(query
|
|
|
+ .getIsEqualCheckStyle().booleanValue()));
|
|
|
+ // ArrayList<CTransferVO> cmpVos = new ArrayList<CTransferVO>();
|
|
|
+ for (int i = 0; i < query.getPk_Account().length; i++) {
|
|
|
+ ContrastAccountVO accountVO = getAccount(query.getPk_Account()[i]);
|
|
|
+ Integer intSourceID = accountVO.getSource();
|
|
|
+ nc.vo.pub.lang.UFDate startdate = getStartDate(query
|
|
|
+ .getPk_Account()[i], query.getYear());
|
|
|
+ if (startdate != null
|
|
|
+ && (query.getDate() == null || startdate.compareTo(query
|
|
|
+ .getDate()) > 0))
|
|
|
+ corpCondition.setDate(startdate);
|
|
|
+ // 若是取期初余额时,时间范围为账户启用时间
|
|
|
+ if (query != null && query.isInitRange() != null
|
|
|
+ && query.isInitRange()) {
|
|
|
+ corpCondition.setEndDate(startdate);
|
|
|
+ }
|
|
|
+ corpCondition.setPk_currtype(accountVO.getPk_currtype());
|
|
|
+ // 是否包含未记账,作用于余额调节表。前面setM_isConTally(query.getM_isConTally());的设置有漏洞。
|
|
|
+ // by jh
|
|
|
+ corpCondition.setM_isConTally(accountVO.getM_isConTally());
|
|
|
+ // 得到反射类
|
|
|
+ if (intSourceID == 1) {
|
|
|
+ dataAccess = (IDataAccess) getClassName(intSourceID, "class");
|
|
|
+ keyTool = (IKey) getClassName(intSourceID, "key");
|
|
|
+ } else {
|
|
|
+ keyTool = new DefaultKeyTool();
|
|
|
+ }
|
|
|
+ AccountlinkVO[] links = getLink(query.getPk_Account()[i], query
|
|
|
+ .getYear());
|
|
|
+ for (int iLink = 0; iLink < links.length; iLink++) {
|
|
|
+
|
|
|
+ corpCondition.setBankAccount(new String[] { links[iLink]
|
|
|
+ .getBankaccount() });
|
|
|
+ corpCondition.setPk_corp(links[iLink].getPk_corp());
|
|
|
+ corpCondition.setPk_accsubj(new String[] { links[iLink]
|
|
|
+ .getPk_subject() });
|
|
|
+ corpCondition.setIncludeLast(query.isIncludeLast());
|
|
|
+ corpCondition.setAssID(links[iLink].getPk_ass()); // 辅助核算
|
|
|
+ String joinStr = " left outer join gl_contrast on ";
|
|
|
+ //余额调节表查询勾兑,按勾兑日期查询
|
|
|
+ if(query.getNodecode()==20040120 && query.isChecked() != null && query.isChecked()){
|
|
|
+ if (query.getDate() != null) {
|
|
|
+ joinStr += " gl_contrast.contrastdate >= '" + query.getDate() + "' and ";
|
|
|
+ }
|
|
|
+ if (query.getEndDate() != null) {
|
|
|
+ joinStr += " gl_contrast.contrastdate <= '" + query.getEndDate() + "' and ";
|
|
|
+ }
|
|
|
+ //设置起始查询日期为启用日期
|
|
|
+ corpCondition.setDate(startdate);
|
|
|
+ }
|
|
|
+ joinStr += " gl_contrast.fk_detail = ";
|
|
|
+ corpCondition.setSqlJoin(joinStr);
|
|
|
+ String str = "";
|
|
|
+ if (query.getVerified() != null) {
|
|
|
+ if (!query.getVerified().booleanValue()
|
|
|
+ && !query.isM_cavDetai()) {
|
|
|
+ // 不要核销数据
|
|
|
+ str += " and isnull(gl_contrast.cavdate,'~')='~' ";
|
|
|
+ } else {
|
|
|
+ str += " and isnull(gl_contrast.cavdate,'~') <> '~' ";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (query.getChecked() != null) {
|
|
|
+ if (!query.getChecked().booleanValue()) {
|
|
|
+ // 没有对帐数据
|
|
|
+ str += " and isnull(gl_contrast.contrastdate,'~')='~' ";
|
|
|
+ } else {
|
|
|
+ // 对帐数据
|
|
|
+ str += " and isnull(gl_contrast.contrastdate,'~') <> '~' ";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (query.isM_cavDetai()) {
|
|
|
+ // 核销明细
|
|
|
+ str += " and gl_contrast.cavdate = '"
|
|
|
+ + query.getM_cavDate() + "' ";
|
|
|
+ if (query.getM_cavMan() != null) {
|
|
|
+ str += " and gl_contrast.cavman = '"
|
|
|
+ + query.getM_cavMan() + "' ";
|
|
|
+ } else {
|
|
|
+ str += " and isnull(gl_contrast.cavman,'~')='~' ";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 按批次号查询 @author zhaozh 2008-6-16 下午01:54:30
|
|
|
+ if (query.getBatchNumber() != null
|
|
|
+ && !query.getBatchNumber().equals("")) {
|
|
|
+ str += " and gl_contrast.batchnumber='"
|
|
|
+ + NCESAPI.sqlEncode(query.getBatchNumber()) + "' ";
|
|
|
+ }
|
|
|
+ if (query.getNodecode() == 20040115 && query.isM_bflag()
|
|
|
+ && null != query.getEndDate() ) {
|
|
|
+ str += " and gl_contrast.contrastdate >'"+query.getEndDate().toString()+"' ";
|
|
|
+ }
|
|
|
+ if (intSourceID == 1) {// 凭证查询
|
|
|
+ corpCondition.setPk_accountlink(links[iLink].getPk_accountlink());
|
|
|
+ // modified by zhufeng 2013-7-20 默认条件:暂存的凭证不参与对账 start
|
|
|
+ str += " and gl_detail.tempsaveflag <> 'Y' ";
|
|
|
+ // modified by zhufeng 2013-7-20 end
|
|
|
+ corpCondition.setSqlWhere(str);
|
|
|
+ if (dataAccess == null) {
|
|
|
+ throw new BusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("3607con_0","03607con-0506")/*@res "对账接口类nc.bs.gl.bookinterface.BookInterface未注册!"*/);
|
|
|
+ }
|
|
|
+ result = dataAccess.queryByConditionVO(corpCondition);
|
|
|
+ } else if (intSourceID == 2) {// 资金帐查询
|
|
|
+ StringBuilder sb = buildBankSql(query, links, iLink, str);
|
|
|
+ // sb.append(" and pk_contrastaccount='" +
|
|
|
+ // links[iLink].getPk_contrastaccount() + "' ");
|
|
|
+ corpCondition.setSqlWhere(sb.toString());
|
|
|
+ // 设置assid字段为pk_account
|
|
|
+ if (query.getPk_link() != null
|
|
|
+ && query.getPk_Account().length > 0) {
|
|
|
+ corpCondition.setAssID(query.getPk_Account()[0]);
|
|
|
+ }
|
|
|
+ corpCondition.setAssID(links[iLink].getPk_contrastaccount());
|
|
|
+
|
|
|
+ /** 为多单位合并对账修改 */
|
|
|
+// if (query.getPk_Corp() != null) {
|
|
|
+// corpCondition.setM_pk_glorgbook(query.getPk_Corp());
|
|
|
+// } else {
|
|
|
+// corpCondition.setM_pk_glorgbook(links[iLink]
|
|
|
+// .getPk_corp());
|
|
|
+// }
|
|
|
+ corpCondition.setM_pk_glorgbook(links[iLink].getPk_corp());
|
|
|
+
|
|
|
+ // CTransferVO[] vos =
|
|
|
+ // findCmpDetailByCondition(corpCondition);
|
|
|
+ CTransferVO[] vos = findCmpDetail(corpCondition, query);
|
|
|
+ if (vos != null && vos.length > 0) {
|
|
|
+ result = new CTransferVO[vos.length];
|
|
|
+ for (int idx = 0; idx < vos.length; idx++) {
|
|
|
+ result[idx] = vos[idx];
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ result = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 转化为CTransferVO
|
|
|
+ for (int j = 0; result != null && j < result.length; j++) {
|
|
|
+ CTransferVO votemp = new CTransferVO();
|
|
|
+ votemp.setVo(result[j]);
|
|
|
+ if (result[j].getValue(keyTool
|
|
|
+ .getBusinessKey(CCorpReceiptKey.CONTRASTDATE)) == null) {
|
|
|
+ votemp.setCaved(UFBoolean.FALSE.booleanValue());
|
|
|
+ } else {
|
|
|
+ votemp.setCaved(UFBoolean.TRUE.booleanValue());
|
|
|
+ }
|
|
|
+ votemp.setPk_account(query.getPk_Account()[i]);
|
|
|
+ votemp.setInit(UFBoolean.FALSE.booleanValue());
|
|
|
+ votemp.setKeyTool(keyTool); // 要查数据库
|
|
|
+ votemp.setM_pk_link(links[iLink].getPk_accountlink());
|
|
|
+ // added by zhufeng 2013-4-10 凭证对账时,需要将CorpReceiptVO的pk_org值为账簿的值,需要转换为对应核算归属组织的pk start
|
|
|
+ if (intSourceID == 1) {
|
|
|
+ String pk_book = links[iLink].getPk_corp();
|
|
|
+ votemp.setM_pk_corp(AccountBookUtil.getPk_orgByAccountBookPk(pk_book));
|
|
|
+ // added by zhufeng 2013-4-10 end
|
|
|
+ } else {
|
|
|
+ votemp.setM_pk_corp(links[iLink].getPk_corp());
|
|
|
+ }
|
|
|
+ votemp.setM_pk_subject(links[iLink].getPk_subject());
|
|
|
+ votemp.setM_pk_bank(links[iLink].getBankaccount());
|
|
|
+ votemp.setM_pk_ass(links[iLink].getPk_ass());
|
|
|
+ /** @author zhaozh 2008-7-8 下午02:25:40 修改收付款单时批次号问题 **/
|
|
|
+ if (result[j].getValue(keyTool
|
|
|
+ .getBusinessKey(CCorpReceiptKey.BATCHNUMBER)) != null)
|
|
|
+ votemp.setBatchNumber(result[j]
|
|
|
+ .getValue(keyTool.getBusinessKey(CCorpReceiptKey.BATCHNUMBER))
|
|
|
+ .toString());
|
|
|
+ votemp.setNetbanknumber(result[j]
|
|
|
+ .getValue(CCorpReceiptKey.NETBANKNUMBER) == null ? ""
|
|
|
+ : result[j].getValue(CCorpReceiptKey.NETBANKNUMBER).toString());
|
|
|
+ if (intSourceID != 1) {
|
|
|
+ votemp.setTranserial(result[j]
|
|
|
+ .getValue(CCorpReceiptKey.TRANSERIAL) == null ? ""
|
|
|
+ : result[j].getValue(CCorpReceiptKey.TRANSERIAL).toString());
|
|
|
+ }
|
|
|
+ vecResult.addElement(votemp);
|
|
|
+ }
|
|
|
+ }// link loop end
|
|
|
+
|
|
|
+ }
|
|
|
+ // if(cmpVos != null && cmpVos.size() != 0){
|
|
|
+ // return cmpVos.toArray(new CTransferVO[cmpVos.size()]);
|
|
|
+ // }
|
|
|
+ // if(vecResult != null) vecResult.trimToSize();
|
|
|
+ // if(cmpVos != null) cmpVos.trimToSize();
|
|
|
+ CTransferVO[] resultVos = new CTransferVO[vecResult.size()];
|
|
|
+ vecResult.copyInto(resultVos);
|
|
|
+ // resultVos = (CTransferVO[]) ArrayUtils.addAll(vecResult.toArray(new
|
|
|
+ // CTransferVO[vecResult.size()]),
|
|
|
+ // cmpVos.toArray(new CTransferVO[cmpVos.size()]));
|
|
|
+ return resultVos;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 银行账sql
|
|
|
+ * @param query
|
|
|
+ * @param links
|
|
|
+ * @param iLink
|
|
|
+ * @param str
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private StringBuilder buildBankSql(CQueryVO query, AccountlinkVO[] links, int iLink, String str) {
|
|
|
+ StringBuilder sb = new StringBuilder(str);
|
|
|
+ // 结算方式(增加不等于情况)
|
|
|
+ //61 适配新银行帐记录表:将cmp_detail 改为 cmp_bankaccdetail
|
|
|
+ if (query.getCheckStyle() != null) {
|
|
|
+ if (query.getIsEqualCheckStyle() == null
|
|
|
+ || query.getIsEqualCheckStyle().booleanValue()) {
|
|
|
+ sb.append(" and pk_balancetype = '"
|
|
|
+ + query.getCheckStyle() + "' ");
|
|
|
+ }else{
|
|
|
+ sb.append(" and pk_balancetype <> '"
|
|
|
+ + query.getCheckStyle() + "' ");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //V61 取消结算号查询条件
|
|
|
+ // 结算号
|
|
|
+ /*if (query.getCheckNO() != null) {
|
|
|
+ sb.append(" and paybillcode = '"
|
|
|
+ + query.getCheckNO() + "' ");
|
|
|
+ }*/
|
|
|
+ // 金额范围(借 ---- 资金帐付款)
|
|
|
+ if (query.getMoneyAspect() == 0) {
|
|
|
+ sb.append(" and direction = 0 ")
|
|
|
+ .append(query.getMoneyArea1() == null ? ""
|
|
|
+ : " and recmoney >= "
|
|
|
+ + query.getMoneyArea1())
|
|
|
+ .append(query.getMoneyArea2() == null ? ""
|
|
|
+ : " and recmoney <= "
|
|
|
+ + query.getMoneyArea2());
|
|
|
+ }
|
|
|
+ // 金额范围(贷 ---- 资金帐收款)
|
|
|
+ if (query.getMoneyAspect() == 1) {
|
|
|
+ sb.append(" and direction = 1 ")
|
|
|
+ .append(query.getMoneyArea1() == null ? " "
|
|
|
+ : " and paymoney >= "
|
|
|
+ + query.getMoneyArea1())
|
|
|
+ .append(query.getMoneyArea2() == null ? " "
|
|
|
+ : " and paymoney <= "
|
|
|
+ + query.getMoneyArea2());
|
|
|
+ }
|
|
|
+ // 金额范围(借贷)
|
|
|
+ if (query.getMoneyAspect() == -1) {
|
|
|
+ if (query.getMoneyArea1() != null
|
|
|
+ && query.getMoneyArea2() != null) {
|
|
|
+ sb.append(" and ((recmoney >= "
|
|
|
+ + query.getMoneyArea1()
|
|
|
+ + " and recmoney <="
|
|
|
+ + query.getMoneyArea2() + ")")
|
|
|
+ .append(" or ( paymoney >= "
|
|
|
+ + query.getMoneyArea1()
|
|
|
+ + " and paymoney <="
|
|
|
+ + query.getMoneyArea2()
|
|
|
+ + "))");
|
|
|
+ } else if (query.getMoneyArea1() != null) {
|
|
|
+ sb.append(" and (recmoney >= "
|
|
|
+ + query.getMoneyArea1()).append(
|
|
|
+ " or paymoney >= "
|
|
|
+ + query.getMoneyArea1() + ") ");
|
|
|
+ } else if (query.getMoneyArea2() != null) {
|
|
|
+ sb.append(" and (recmoney <= "
|
|
|
+ + query.getMoneyArea2()).append(
|
|
|
+ " or paymoney <= "
|
|
|
+ + query.getMoneyArea2() + ") ");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 票据日期/记账日期
|
|
|
+ if (query.getN_pjdate1() != null) {
|
|
|
+ sb.append(" and checkdate >= '"
|
|
|
+ + query.getN_pjdate1() + "' ");
|
|
|
+ }
|
|
|
+ if (query.getN_pjdate2() != null) {
|
|
|
+ sb.append(" and checkdate <= '"
|
|
|
+ + query.getN_pjdate2() + "' ");
|
|
|
+ }
|
|
|
+ // 单据类型
|
|
|
+ if (!StringUtil.isEmptyWithTrim(query.getN_voucherType())) {
|
|
|
+ sb.append(" and pk_billtype = '"
|
|
|
+ + query.getN_voucherType() + "' ");
|
|
|
+ }
|
|
|
+ // 单据号
|
|
|
+ if (query.getN_voucherCode1() != null) {
|
|
|
+ sb.append(" and vbillno = '"
|
|
|
+ + query.getN_voucherCode1() + "' ");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (links[iLink] != null) {
|
|
|
+ sb.append(" and gl_accountlink.pk_accountlink = '"
|
|
|
+ + links[iLink].getPk_accountlink() + "' ");
|
|
|
+ }
|
|
|
+
|
|
|
+ sb.append(" and gl_contrastaccount.pk_contrastaccount=gl_accountlink.pk_contrastaccount ");
|
|
|
+ return sb;
|
|
|
+ }
|
|
|
+
|
|
|
+ /*private IBankAccQueryService getBankAccQueryService() {
|
|
|
+ if (null == queryService) {
|
|
|
+ queryService = NCLocator.getInstance().lookup(
|
|
|
+ IBankAccQueryService.class);
|
|
|
+ }
|
|
|
+ return queryService;
|
|
|
+ }*/
|
|
|
+
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ private CTransferVO[] findCmpDetail(CConditionVO conVo, CQueryVO query)
|
|
|
+ throws BusinessException {
|
|
|
+ if (query.getNodecode() == 20040115 && query.isM_bflag()) {
|
|
|
+ return findCmpDetailAdjust(conVo, query);
|
|
|
+ }
|
|
|
+ ArrayList<CCorpReceiptVO> list = new ArrayList<CCorpReceiptVO>();
|
|
|
+ //增加对账标志:是对账账面账,不取预占账
|
|
|
+ StringBuilder builder = new StringBuilder("( isnull(tallydate,'~') <> '~') and useflag ="+UseFlagEnum.USE.getOperateTypeValue());
|
|
|
+ builder.append(" and pk_org = '" + conVo.getPk_corp() + "' ");
|
|
|
+ // 币种
|
|
|
+ if (conVo.getPk_currtype() != null) {
|
|
|
+ builder.append(" and pk_curr = '"
|
|
|
+ + conVo.getPk_currtype() + "' ");
|
|
|
+ }
|
|
|
+ // 银行帐户
|
|
|
+ if (conVo.getbankAccount().length > 0) {
|
|
|
+ builder.append(" and pk_account = '"
|
|
|
+ + conVo.getbankAccount()[0] + "' ");
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询勾兑情况---包括余额调节表查询勾兑,按勾兑日期查询 ,其它除外
|
|
|
+ if(query.getNodecode()!= 20040120 || null == query.isChecked()){
|
|
|
+ // 接上传过来的条件 orgbusidate
|
|
|
+ if (conVo.isIncludeLast().booleanValue()) {
|
|
|
+ if (conVo.getDate() != null)
|
|
|
+ builder.append(" and tallydate >= '"
|
|
|
+ + new UFLiteralDate(conVo.getDate().toString()).toString() + "'");
|
|
|
+ if (conVo.getEndDate() != null)
|
|
|
+ builder.append(" and tallydate <= '"
|
|
|
+ + conVo.getEndDate().toStdString() + "'");
|
|
|
+ } else {
|
|
|
+ if (conVo.getDate() != null)
|
|
|
+ builder.append(" and tallydate > '"
|
|
|
+ + new UFLiteralDate(conVo.getDate().toString()).toString() + "'");
|
|
|
+ if (conVo.getEndDate() != null)
|
|
|
+ builder.append(" and tallydate < '"
|
|
|
+ + conVo.getEndDate().toStdString() + "'");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (query.getM_stopDate() != null) {
|
|
|
+ builder.append(" and tallydate < '"
|
|
|
+ + query.getM_stopDate().toStdString() + "'");
|
|
|
+ }
|
|
|
+ // V61 取消
|
|
|
+ // 60增加票据账的单据过滤条件
|
|
|
+ //builder.append(" and dr =0 and (fundformcode in (0,1) or (fundformcode in (2,3) and isbillrecord = 'Y'))");
|
|
|
+ // 结算号就是票据号
|
|
|
+ // modified by zhufeng 2013-7-13 start
|
|
|
+ if (query.getCheckNO() != null) {
|
|
|
+ //
|
|
|
+ String notenumber = query.getCheckNO();
|
|
|
+ // 查询票据号主键
|
|
|
+ if(ContrastQueryModuleUtil.isEnableByGroup(AppContext.getInstance().getPkGroup(), ContrastQueryModuleUtil.TM_FBM_FUNCODE)){
|
|
|
+ Collection<RegisterVO> regVOCol = getBaseDAO().retrieveByClause(
|
|
|
+ RegisterVO.class,
|
|
|
+ RegisterVO.FBMBILLNO + " = '" + NCESAPI.sqlEncode(notenumber) + "'");
|
|
|
+ if(regVOCol != null && regVOCol.size() > 0){
|
|
|
+ notenumber = regVOCol.iterator().next().getPrimaryKey();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ builder.append(" and oribillno = '"
|
|
|
+ + NCESAPI.sqlEncode(notenumber) + "' ");
|
|
|
+ }
|
|
|
+ // 结算方式
|
|
|
+ if (query.getCheckStyle() != null) {
|
|
|
+ if(query.getIsEqualCheckStyle() == null || query.getIsEqualCheckStyle().booleanValue()){
|
|
|
+ builder.append(" and pk_balancetype = '"
|
|
|
+ + query.getCheckStyle() + "' ");
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ builder.append(" and pk_balancetype <> '"
|
|
|
+ + query.getCheckStyle() + "' ");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // builder.append(" and pk_detail not in (select fk_detail from gl_contrast)");
|
|
|
+ // 其他查询条件
|
|
|
+ Collection<BankAccDetailVO> coll = getBaseDAO().retrieveByClause(
|
|
|
+ BankAccDetailVO.class, builder.toString());
|
|
|
+ List<BankAccDetailVO> detailList = new ArrayList<BankAccDetailVO>();
|
|
|
+ detailList.addAll(coll);
|
|
|
+ if(detailList!=null&&detailList.size()>0)
|
|
|
+ {
|
|
|
+
|
|
|
+ try {
|
|
|
+ int count = 0;// 计数器
|
|
|
+ boolean flag = conVo.getLimit() != null && conVo.getLimit() > 0;
|
|
|
+ // modified by zhufeng 2013-4-26 sonar检查:循环中调用数据库查询 start
|
|
|
+ Set<String> accdetailSet = new HashSet<String>();
|
|
|
+ for (BankAccDetailVO bankAccDetailVO : detailList) {
|
|
|
+ accdetailSet.add(bankAccDetailVO.getPk_bankaccdetail());
|
|
|
+ }
|
|
|
+// StringBuffer con = new StringBuffer("fk_detail in '" + detail.getPk_bankaccdetail() + "' ");
|
|
|
+ StringBuffer con = new StringBuffer("1=1");
|
|
|
+ con.append(new StringBuffer(BDSqlInUtil.formInSQL("fk_detail", accdetailSet.toArray(new String[0]), false)));
|
|
|
+ // 查询核销
|
|
|
+ // _TASK for zhufeng 使用功能号作为条件,财务的银行对账肯定会出问题. 2013-3-18
|
|
|
+ if (query.getModuleCode() != null
|
|
|
+ && (query.getModuleCode().equals("3607CVCR") || query.getModuleCode().equals("20026507"))) {
|
|
|
+ if (!StringUtil.isEmptyWithTrim(query.getM_cavDate())) {
|
|
|
+ con.append(" and cavdate= '" + query.getM_cavDate()
|
|
|
+ + "' ");
|
|
|
+ }
|
|
|
+ if (!StringUtil.isEmptyWithTrim(query.getM_cavMan())) {
|
|
|
+ con.append(" and cavman = '" + query.getM_cavMan()
|
|
|
+ + "' ");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //查询勾兑情况---包括余额调节表查询勾兑,按勾兑日期查询
|
|
|
+ if(query.getNodecode()==20040120 && query.isChecked() != null && query.isChecked()){
|
|
|
+ if (query.getDate() != null) {
|
|
|
+ con.append(" and contrastdate >= '"
|
|
|
+ + query.getDate() + "'");
|
|
|
+ }
|
|
|
+ if (query.getEndDate() != null) {
|
|
|
+ con.append(" and contrastdate <= '"
|
|
|
+ + query.getEndDate() + "'");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ HashMap<String, ContrastVO> detailContrastMap = getDetailContrastMap(query, con.toString());
|
|
|
+ Map<String,String> checkStyleNames = new HashMap<>();
|
|
|
+ for (int i = 0; detailList != null && i < detailList.size(); i++) {
|
|
|
+ BankAccDetailVO detail = detailList.get(i);
|
|
|
+ ContrastVO cstvo = detailContrastMap.get(detail.getPk_bankaccdetail());
|
|
|
+ if (cstvo!=null) {
|
|
|
+ if (query.isChecked() != null) {
|
|
|
+ if (query.isChecked().booleanValue()) {
|
|
|
+ if (cstvo.getContrastdate() == null)
|
|
|
+ continue;
|
|
|
+ } else if (cstvo.getContrastdate() != null)
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // modified by zhufeng 2013-4-26 end
|
|
|
+ //查询勾兑情况---包括余额调节表查询勾兑,按勾兑日期查询
|
|
|
+ }else if(query.getNodecode()==20040120 && query.isChecked() != null && query.isChecked()){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (flag) {
|
|
|
+ count++;
|
|
|
+ if (count > conVo.getLimit())
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ CCorpReceiptVO corp = new CCorpReceiptVO();
|
|
|
+ corp.setPk_corp(conVo.getPk_corp()); // 公司pk
|
|
|
+ corp.setPk_detail(detail.getPk_bankaccdetail()); // 明细主键
|
|
|
+ corp.setExplanation(detail.getNote()); // 备注
|
|
|
+ corp.setPk_checkstyle(detail.getPk_balancetype()); // 结算方式主键
|
|
|
+ corp.setCheckstylename(getCheckStyleName(detail
|
|
|
+ .getPk_balancetype(),checkStyleNames));// 结算方式名称
|
|
|
+ if (detail.getOribillno() != null) { // 结算号//票据号
|
|
|
+ String notenumnber = detail.getOribillno().trim();
|
|
|
+ if(notenumnber.length() == 20){
|
|
|
+ RegisterVO vo = getFBMQueryService().getBaseInfoByPk(notenumnber);
|
|
|
+ if(vo != null){
|
|
|
+ notenumnber = vo.getFbmbillno();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ corp.setCheckno(notenumnber);
|
|
|
+ }
|
|
|
+ Object t7 = detail.getRecmoney(); // 借方金额
|
|
|
+ if (t7 != null) {
|
|
|
+ corp.setDebitamount(new UFDouble(t7.toString()));
|
|
|
+ }else{
|
|
|
+ corp.setDebitamount(UFDouble.ZERO_DBL);
|
|
|
+ }
|
|
|
+ Object t8 = detail.getPaymoney(); // 贷方金额
|
|
|
+ if (t8 != null) {
|
|
|
+ corp.setCreditamount(new UFDouble(t8.toString()));
|
|
|
+ }else{
|
|
|
+ corp.setCreditamount(UFDouble.ZERO_DBL);
|
|
|
+ }
|
|
|
+ if (t7 != null && t8 != null) {
|
|
|
+ if (corp.getDebitamount().doubleValue() == 0.0d
|
|
|
+ && corp.getCreditamount().doubleValue() == 0.0d) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //取原单据日期
|
|
|
+ UFDate t9 = new UFDate(detail.getTallydate().toString());
|
|
|
+ if (t9 != null) {
|
|
|
+ corp.setCheckdate(t9); // 票据日期
|
|
|
+ corp.setPrepareddate(t9);//制单日期与票据日期相同
|
|
|
+ }
|
|
|
+ corp.setPk_vouchertype(detail.getPk_billtype()); // 来源单据类型
|
|
|
+ corp.setPk_sub(String.valueOf(detail.getDirection())); // 方向
|
|
|
+ corp.setVouchno(detail.getVbillno()); // 单据号
|
|
|
+ corp.setDateFlag(detail.getTs().toString()); // 时间戳
|
|
|
+ corp.setM_Pk_bank(detail.getPk_account()); // 本方银行主键
|
|
|
+ if (cstvo != null && cstvo.getContrastdate() != null)
|
|
|
+ corp.setM_contrastdate(cstvo.getContrastdate().toString()); // 对账日期
|
|
|
+ // 3607CVCR 只查核销
|
|
|
+ if (query.getModuleCode() != null
|
|
|
+ && (query.getModuleCode().equals("3607CVCR") || query.getModuleCode().equals("20026507"))) {
|
|
|
+ if (cstvo != null && cstvo.getCavdate() != null)
|
|
|
+ corp.setM_cavdate(cstvo.getCavdate().toString()); // 核销日期
|
|
|
+ else
|
|
|
+ continue;
|
|
|
+ } else {
|
|
|
+ if (cstvo != null && cstvo.getCavdate() != null)
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (cstvo != null)
|
|
|
+ corp.setBatchNumber(cstvo.getBatchNumber()); // 批次号
|
|
|
+ corp.setNetbanknumber(detail.getBankrelated_code());//对账标识码
|
|
|
+ //yangxds start 增加交易流水号
|
|
|
+ corp.setTranserial(detail.getTranserial());
|
|
|
+ //yangxds end 增加交易流水号
|
|
|
+ corp.setPk_contrastaccount(conVo.getPk_contrastAccount());// 对账帐户
|
|
|
+ corp.setPk_link(conVo.getPk_accountlink());// 对账帐户关联表
|
|
|
+ corp.setPk_group(detail.getPk_group());
|
|
|
+ corp.setTradername(detail.getOppunit());//对方单位
|
|
|
+ list.add(corp);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ Debug.error(e.getMessage(), e);
|
|
|
+ throw new BusinessException(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 转化为CTransferVO
|
|
|
+ CTransferVO[] corpreceipts = new CTransferVO[list.size()];
|
|
|
+ CCorpReceiptVO corpReceipt = null;
|
|
|
+ for (int j = 0; j < list.size(); j++) {
|
|
|
+ CTransferVO votemp = new CTransferVO();
|
|
|
+ corpReceipt = list.get(j);
|
|
|
+ votemp.setVo(corpReceipt);
|
|
|
+ votemp.setCaved(corpReceipt.getBatchNumber() != null
|
|
|
+ && corpReceipt.getBatchNumber().trim().length() > 0);
|
|
|
+ votemp.setPk_account(corpReceipt.getPk_contrastaccount());
|
|
|
+ votemp.setM_pk_link(corpReceipt.getPk_link());
|
|
|
+ votemp.setM_pk_corp(corpReceipt.getPk_corp());
|
|
|
+ // votemp.setM_pk_subject(corpReceipt.getPk_subject());
|
|
|
+ votemp.setM_pk_bank(corpReceipt.getM_Pk_bank());
|
|
|
+ // votemp.setM_pk_ass(corpReceipt.getPk_ass());
|
|
|
+ votemp.setBatchNumber(corpReceipt.getBatchNumber());
|
|
|
+ //yangxds 增加交易流水号 start
|
|
|
+ votemp.setNetbanknumber(corpReceipt.getNetbanknumber());
|
|
|
+ //yangxds 增加交易流水号 end
|
|
|
+ votemp.setTranserial(corpReceipt.getTranserial());
|
|
|
+ votemp.setPk_group(corpReceipt.getPk_group());
|
|
|
+ votemp.setInit(new Boolean(true));
|
|
|
+ votemp.setKeyTool(new DefaultKeyTool());
|
|
|
+ corpreceipts[j] = votemp;
|
|
|
+ }
|
|
|
+ if (null != corpreceipts && corpreceipts.length > 0) {
|
|
|
+ return corpreceipts;
|
|
|
+ } else
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取key:fk_detail value:ContrastVO Map,避免在循环中调用查询
|
|
|
+ * @param query
|
|
|
+ * @param detailList
|
|
|
+ * @return
|
|
|
+ * @throws DAOException
|
|
|
+ */
|
|
|
+ private HashMap<String, ContrastVO> getDetailContrastMap(CQueryVO query, String contrastSql)
|
|
|
+ throws DAOException {
|
|
|
+ HashMap<String, ContrastVO> detailContrastMap = new HashMap<String, ContrastVO>();
|
|
|
+
|
|
|
+ Collection<nc.vo.cmp.cb.ContrastVO> cc = getBaseDAO().retrieveByClause(nc.vo.cmp.cb.ContrastVO.class,contrastSql);
|
|
|
+ for (ContrastVO contrastVO : cc) {
|
|
|
+ detailContrastMap.put(contrastVO.getFk_detail(), contrastVO);
|
|
|
+ }
|
|
|
+ return detailContrastMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ /*
|
|
|
+ * modifier by zhaozh 余额调节表资金帐户专用查询
|
|
|
+ * 查询后续期间已勾兑数据包含在当前余额调节表期间中的数据
|
|
|
+ */
|
|
|
+ private CTransferVO[] findCmpDetailAdjust(CConditionVO conVo, CQueryVO query)
|
|
|
+ throws BusinessException {
|
|
|
+ ArrayList<CCorpReceiptVO> list = new ArrayList<CCorpReceiptVO>();
|
|
|
+ //增加对账标志:是对账账面账,不取预占账
|
|
|
+ StringBuilder builder = new StringBuilder("( isnull(tallydate,'~') <> '~') and useflag ="+UseFlagEnum.USE.getOperateTypeValue());
|
|
|
+ builder.append(" and pk_org = '" + conVo.getPk_corp() + "' ");
|
|
|
+ // 币种
|
|
|
+ if (conVo.getPk_currtype() != null) {
|
|
|
+ builder.append(" and pk_curr = '"+ conVo.getPk_currtype() + "' ");
|
|
|
+ }
|
|
|
+ // 银行帐户
|
|
|
+ if (conVo.getbankAccount().length > 0) {
|
|
|
+ builder.append(" and pk_account = '" + conVo.getbankAccount()[0] + "' ");
|
|
|
+ }
|
|
|
+ // 接上传过来的条件 orgbusidate
|
|
|
+ if (conVo.isIncludeLast().booleanValue()) {
|
|
|
+ if (conVo.getDate() != null)
|
|
|
+ builder.append(" and tallydate >= '" + new UFLiteralDate(conVo.getDate().toString()).toString() + "'");
|
|
|
+ if (conVo.getEndDate() != null)
|
|
|
+ builder.append(" and tallydate <= '"+ conVo.getEndDate().toStdString() + "'");
|
|
|
+ } else {
|
|
|
+ if (conVo.getDate() != null)
|
|
|
+ builder.append(" and tallydate > '"
|
|
|
+ + new UFLiteralDate(conVo.getDate().toString()).toString() + "'");
|
|
|
+ if (conVo.getEndDate() != null)
|
|
|
+ builder.append(" and tallydate < '" + conVo.getEndDate().toStdString() + "'");
|
|
|
+ }
|
|
|
+ //builder.append(" and dr = 0 and (fundformcode in (0,1) or (fundformcode in (2,3) and isbillrecord = 'Y'))");
|
|
|
+ // 其他查询条件
|
|
|
+ /*ISettlementPubQueryService settleService = getSettleQueryService();
|
|
|
+ Collection<SettlementBodyVO> coll = getBaseDAO().retrieveByClause(
|
|
|
+ SettlementBodyVO.class, builder.toString());
|
|
|
+ List<SettlementBodyVO> settList = new ArrayList<SettlementBodyVO>();
|
|
|
+ settList.addAll(coll);
|
|
|
+ settList = settleService.dealOneToMany(settList);*/
|
|
|
+
|
|
|
+ Collection<BankAccDetailVO> coll = getBaseDAO().retrieveByClause(
|
|
|
+ BankAccDetailVO.class, builder.toString());
|
|
|
+ List<BankAccDetailVO> detailList = new ArrayList<BankAccDetailVO>();
|
|
|
+ detailList.addAll(coll);
|
|
|
+ if(detailList!=null&&detailList.size()>0)
|
|
|
+ {
|
|
|
+ // modified by zhufeng 2013-4-26 sonar检查 start
|
|
|
+ Set<String> accdetailSet = new HashSet<String>();
|
|
|
+ for (BankAccDetailVO bankAccDetailVO : detailList) {
|
|
|
+ accdetailSet.add(bankAccDetailVO.getPk_bankaccdetail());
|
|
|
+ }
|
|
|
+ StringBuffer con = new StringBuffer("1=1 ");
|
|
|
+ con.append(BDSqlInUtil.formInSQL("fk_detail", accdetailSet.toArray(new String[0]), false));
|
|
|
+ // 查询核销
|
|
|
+ if (query.getModuleCode() != null
|
|
|
+ && (query.getModuleCode().equals("3607CVCR") || query.getModuleCode().equals("20026507"))) {
|
|
|
+ if (!StringUtil.isEmptyWithTrim(query.getM_cavDate())) {
|
|
|
+ con.append(" and cavdate= '" + query.getM_cavDate()
|
|
|
+ + "' ");
|
|
|
+ }
|
|
|
+ if (!StringUtil.isEmptyWithTrim(query.getM_cavMan())) {
|
|
|
+ con.append(" and cavman = '" + query.getM_cavMan()
|
|
|
+ + "' ");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 余额调剂表查询
|
|
|
+ //已勾兑数据,对账日期大于当前截止日期
|
|
|
+ if (query.getNodecode() == 20040115 && query.isM_bflag()) {
|
|
|
+ if(null != query.getEndDate()){
|
|
|
+ con.append(" and gl_contrast.contrastdate > '" + query.getEndDate().toString() + "' ");
|
|
|
+ }
|
|
|
+ con.append(" and isnull(gl_contrast.contrastdate,'~') <> '~' ");
|
|
|
+ }
|
|
|
+ HashMap<String, ContrastVO> detailContrastMap = getDetailContrastMap(query, con.toString());
|
|
|
+ // modified by zhufeng 2013-4-26 end
|
|
|
+
|
|
|
+ try {
|
|
|
+ int count = 0;// 计数器
|
|
|
+ boolean flag = conVo.getLimit() != null && conVo.getLimit() > 0;
|
|
|
+ Map<String,String> checkStyleNames = new HashMap<>();
|
|
|
+
|
|
|
+ for (int i = 0; detailList != null && i < detailList.size(); i++) {
|
|
|
+ BankAccDetailVO detail = detailList.get(i);
|
|
|
+ ContrastVO cstvo = detailContrastMap.get(detail.getPk_bankaccdetail());
|
|
|
+
|
|
|
+ if (cstvo != null ) {
|
|
|
+ if (cstvo == null /* || cstvo.getCavdate() != null */)
|
|
|
+ continue;
|
|
|
+ } else{
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (flag) {
|
|
|
+ count++;
|
|
|
+ if (count > conVo.getLimit())
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ CCorpReceiptVO corp = new CCorpReceiptVO();
|
|
|
+ corp.setPk_corp(conVo.getPk_corp()); // 公司pk
|
|
|
+ corp.setPk_detail(detail.getPk_bankaccdetail()); // 结算明细主键
|
|
|
+ corp.setExplanation(detail.getNote()); // 备注
|
|
|
+ corp.setPk_checkstyle(detail.getPk_balancetype()); // 结算方式主键
|
|
|
+ corp.setCheckstylename(getCheckStyleName(detail
|
|
|
+ .getPk_balancetype(),checkStyleNames));// 结算方式名称
|
|
|
+ if (detail.getOribillno() != null) { // 结算号
|
|
|
+ corp.setCheckno(detail.getOribillno().trim());
|
|
|
+ }
|
|
|
+ Object t7 = detail.getRecmoney(); // 借方金额
|
|
|
+ if (t7 != null) {
|
|
|
+ corp.setDebitamount(new UFDouble(t7.toString()));
|
|
|
+ }
|
|
|
+ Object t8 = detail.getPaymoney(); // 贷方金额
|
|
|
+ if (t8 != null) {
|
|
|
+ corp.setCreditamount(new UFDouble(t8.toString()));
|
|
|
+ }
|
|
|
+ if (t7 != null && t8 != null) {
|
|
|
+ if (corp.getDebitamount().doubleValue() == 0.0d
|
|
|
+ && corp.getCreditamount().doubleValue() == 0.0d) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ UFDate t9 = new UFDate(detail.getTallydate().toString());
|
|
|
+ if (t9 != null) {
|
|
|
+ corp.setCheckdate(t9); // 票据日期
|
|
|
+ corp.setPrepareddate(t9);// 制单日期
|
|
|
+ }
|
|
|
+ corp.setPk_vouchertype(detail.getPk_billtype()); // 来源单据类型
|
|
|
+ corp.setPk_sub(String.valueOf(detail.getDirection())); // 方向
|
|
|
+ corp.setVouchno(detail.getVbillno()); // 单据号
|
|
|
+ corp.setDateFlag(detail.getTs().toString()); // 单据号
|
|
|
+ corp.setM_Pk_bank(detail.getPk_account()); // 本方银行主键
|
|
|
+ if (cstvo != null && cstvo.getContrastdate() != null)
|
|
|
+ corp.setM_contrastdate(cstvo.getContrastdate().toString()); // 对账日期
|
|
|
+ // 20040630 只查核销
|
|
|
+ // if(query.getModuleCode() != null &&
|
|
|
+ // query.getModuleCode().equals("20040630")){
|
|
|
+ // if(cstvo != null && cstvo.getCavdate() != null)
|
|
|
+ // corp.setM_cavdate(cstvo.getCavdate().toString()); //核销日期
|
|
|
+ // else continue;
|
|
|
+ // }else{
|
|
|
+ // if(cstvo != null && cstvo.getCavdate() != null)
|
|
|
+ // continue;
|
|
|
+ // }
|
|
|
+ if (cstvo != null)
|
|
|
+ corp.setBatchNumber(cstvo.getBatchNumber()); // 批次号
|
|
|
+ corp.setPk_contrastaccount(conVo.getPk_contrastAccount());// 对账帐户
|
|
|
+ corp.setPk_link(conVo.getPk_accountlink());// 对账帐户关联表
|
|
|
+ list.add(corp);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ Debug.error(e.getMessage(), e);
|
|
|
+ throw new BusinessException(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 转化为CTransferVO
|
|
|
+ CTransferVO[] corpreceipts = new CTransferVO[list.size()];
|
|
|
+ CCorpReceiptVO corpReceipt = null;
|
|
|
+ for (int j = 0; j < list.size(); j++) {
|
|
|
+ CTransferVO votemp = new CTransferVO();
|
|
|
+ corpReceipt = list.get(j);
|
|
|
+ votemp.setVo(corpReceipt);
|
|
|
+ votemp.setCaved(corpReceipt.getBatchNumber() != null
|
|
|
+ && corpReceipt.getBatchNumber().trim().length() > 0);
|
|
|
+ votemp.setPk_account(corpReceipt.getPk_contrastaccount());
|
|
|
+ votemp.setM_pk_link(corpReceipt.getPk_link());
|
|
|
+ votemp.setM_pk_corp(corpReceipt.getPk_corp());
|
|
|
+ // votemp.setM_pk_subject(corpReceipt.getPk_subject());
|
|
|
+ votemp.setM_pk_bank(corpReceipt.getM_Pk_bank());
|
|
|
+ // votemp.setM_pk_ass(corpReceipt.getPk_ass());
|
|
|
+ votemp.setBatchNumber(corpReceipt.getBatchNumber());
|
|
|
+ votemp.setInit(new Boolean(true));
|
|
|
+ votemp.setKeyTool(new DefaultKeyTool());
|
|
|
+ corpreceipts[j] = votemp;
|
|
|
+ }
|
|
|
+ if (null != corpreceipts && corpreceipts.length > 0) {
|
|
|
+ return corpreceipts;
|
|
|
+ } else
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建日期:2008-7-18 上午09:08:05 modifier by zhaozh on 2008-12-31 不取删除的单据dr=1
|
|
|
+ *
|
|
|
+ * @param query
|
|
|
+ * @param condition
|
|
|
+ * @return CTransferVO数组
|
|
|
+ * @throws Exception
|
|
|
+ * 由查询条件查找所需结算信息明细数据
|
|
|
+ */
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ private CTransferVO[] findCmpDetailByCondition(CConditionVO conVo,
|
|
|
+ CQueryVO query) throws BusinessException {
|
|
|
+
|
|
|
+ //修改格式化日期为前10位,避免sqlserver或 oracle查询结果不一致
|
|
|
+ //截取yyyy-mm-dd格式
|
|
|
+ String startDate = conVo.getDate().toStdString();
|
|
|
+
|
|
|
+ ArrayList<CCorpReceiptVO> list = new ArrayList<CCorpReceiptVO>();
|
|
|
+ StringBuilder builder = new StringBuilder("( isnull(tallydate,'~') <> '~') ");
|
|
|
+ builder.append(" and pk_org = '" + conVo.getPk_corp() + "' ");
|
|
|
+ // 币种
|
|
|
+ if (conVo.getPk_currtype() != null) {
|
|
|
+ builder.append(" and pk_curr = '"
|
|
|
+ + conVo.getPk_currtype() + "' ");
|
|
|
+ }
|
|
|
+ // 银行帐户
|
|
|
+ if (conVo.getbankAccount().length > 0) {
|
|
|
+ builder.append(" and pk_account = '"
|
|
|
+ + conVo.getbankAccount()[0] + "' ");
|
|
|
+ }
|
|
|
+ // 接上传过来的条件orgbusidate
|
|
|
+ if (conVo.isIncludeLast().booleanValue()) {
|
|
|
+ builder.append(" and tallydate >= '" + startDate + "'");
|
|
|
+ builder.append(" and tallydate <= '" + conVo.getEndDate() + "'");
|
|
|
+ } else {
|
|
|
+ builder.append(" and tallydate > '" + startDate + "'");
|
|
|
+ builder.append(" and tallydate < '" + conVo.getEndDate() + "'");
|
|
|
+ }
|
|
|
+ if (query.getM_stopDate() != null) {
|
|
|
+ builder.append(" and tallydate < '" + query.getM_stopDate() + "'");
|
|
|
+ }
|
|
|
+ //builder.append(" and dr = 0 and (fundformcode in (0,1) or (fundformcode in (2,3) and isbillrecord = 'Y'))");
|
|
|
+ // 结算号就是票据号
|
|
|
+ if (query.getCheckNO() != null) {
|
|
|
+ builder.append(" and oribillno = '" + query.getCheckNO() + "' ");
|
|
|
+ }
|
|
|
+ // 结算方式
|
|
|
+ if (query.getCheckStyle() != null) {
|
|
|
+ if(query.getIsEqualCheckStyle() == null || query.getIsEqualCheckStyle().booleanValue()){
|
|
|
+ builder.append(" and pk_balancetype = '" + query.getCheckStyle() + "' ");
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ builder.append(" and pk_balancetype <> '" + query.getCheckStyle() + "' ");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ // 其他查询条件
|
|
|
+ /*ISettlementPubQueryService settleService = getSettleQueryService();
|
|
|
+ Collection<SettlementBodyVO> coll = getBaseDAO().retrieveByClause(
|
|
|
+ SettlementBodyVO.class, builder.toString());
|
|
|
+ List<SettlementBodyVO> settList = new ArrayList<SettlementBodyVO>();
|
|
|
+ settList.addAll(coll);
|
|
|
+ settList = settleService.dealOneToMany(settList);*/
|
|
|
+ Collection<BankAccDetailVO> coll = getBaseDAO().retrieveByClause(
|
|
|
+ BankAccDetailVO.class, builder.toString());
|
|
|
+ List<BankAccDetailVO> detailList = new ArrayList<BankAccDetailVO>();
|
|
|
+ detailList.addAll(coll);
|
|
|
+ // modified by zhufeng 2013-4-26 sonar检查 start
|
|
|
+ Set<String> accdetailSet = new HashSet<String>();
|
|
|
+ for (BankAccDetailVO bankAccDetailVO : detailList) {
|
|
|
+ accdetailSet.add(bankAccDetailVO.getPk_bankaccdetail());
|
|
|
+ }
|
|
|
+ StringBuffer con = new StringBuffer(BDSqlInUtil.formInSQLWithoutAnd("fk_detail", accdetailSet.toArray(new String[0]), false));
|
|
|
+ // 查询核销
|
|
|
+ if (query.getModuleCode() != null
|
|
|
+ && (query.getModuleCode().equals("3607CVCR") || query.getModuleCode().equals("20026507"))) {
|
|
|
+ if (!StringUtil.isEmptyWithTrim(query.getM_cavDate())) {
|
|
|
+ con.append(" and cavdate= '" + query.getM_cavDate() + "' ");
|
|
|
+ }
|
|
|
+ if (!StringUtil.isEmptyWithTrim(query.getM_cavMan())) {
|
|
|
+ con.append(" and cavman = '" + query.getM_cavMan() + "' ");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ HashMap<String, ContrastVO> detailContrastMap = getDetailContrastMap(query, con.toString());
|
|
|
+ Map<String,String> checkStyleNames = new HashMap<>();
|
|
|
+ // modified by zhufeng 2013-4-26 end
|
|
|
+ try {
|
|
|
+ int count = 0;// 计数器
|
|
|
+ boolean flag = conVo.getLimit() != null && conVo.getLimit() > 0;
|
|
|
+ for (int i = 0; detailList != null && i < detailList.size(); i++) {
|
|
|
+ BankAccDetailVO detail = detailList.get(i);
|
|
|
+ ContrastVO cstvo = detailContrastMap.get(detail.getPk_bankaccdetail());
|
|
|
+ if (cstvo != null) {
|
|
|
+ if (query.isChecked() != null) {
|
|
|
+ if (query.isChecked().booleanValue()) {
|
|
|
+ if (cstvo.getContrastdate() == null)
|
|
|
+ continue;
|
|
|
+ } else if (cstvo.getContrastdate() != null)
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (flag) {
|
|
|
+ count++;
|
|
|
+ if (count > conVo.getLimit())
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ CCorpReceiptVO corp = new CCorpReceiptVO();
|
|
|
+ corp.setPk_corp(conVo.getPk_corp()); // 公司pk
|
|
|
+ corp.setPk_detail(detail.getPk_bankaccdetail()); // 明细主键
|
|
|
+ // 制单日期 取登账日期
|
|
|
+ UFDate t3 = new UFDate(detail.getTallydate().toString());
|
|
|
+ if (t3 != null) {
|
|
|
+ corp.setPrepareddate(t3);//票据日期
|
|
|
+ corp.setCheckdate(t3);//制单日期
|
|
|
+ }
|
|
|
+ corp.setExplanation(detail.getNote()); // 摘要
|
|
|
+ corp.setPk_checkstyle(detail.getPk_balancetype()); // 结算方式主键
|
|
|
+ corp.setCheckstylename(getCheckStyleName(detail
|
|
|
+ .getPk_balancetype(),checkStyleNames));// 结算方式名称
|
|
|
+ if (detail.getOribillno() != null) { // 结算号
|
|
|
+ corp.setCheckno(detail.getOribillno().trim());
|
|
|
+ }
|
|
|
+ Object t7 = detail.getRecmoney(); // 借方金额
|
|
|
+ if (t7 != null) {
|
|
|
+ corp.setDebitamount(new UFDouble(t7.toString()));
|
|
|
+ } else {
|
|
|
+ corp.setDebitamount(UFDouble.ZERO_DBL);
|
|
|
+ }
|
|
|
+ Object t8 = detail.getPaymoney(); // 贷方金额
|
|
|
+ if (t8 != null) {
|
|
|
+ corp.setCreditamount(new UFDouble(t8.toString()));
|
|
|
+ } else {
|
|
|
+ corp.setCreditamount(UFDouble.ZERO_DBL);
|
|
|
+ }
|
|
|
+ if (t7 != null && t8 != null) {
|
|
|
+ if (corp.getDebitamount().doubleValue() == 0.0d
|
|
|
+ && corp.getCreditamount().doubleValue() == 0.0d) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // String t9 = detail.getTallydate().toString();
|
|
|
+ // if(t9 != null && t9.trim().length()>0){
|
|
|
+ // corp.setCheckdate(new UFDate(t9)); //票据日期
|
|
|
+ // }
|
|
|
+ corp.setPk_vouchertype(detail.getPk_billtype()); // 来源单据类型
|
|
|
+ corp.setPk_sub(String.valueOf(detail.getDirection())); // 方向
|
|
|
+ corp.setVouchno(detail.getVbillno()); // 单据号
|
|
|
+ corp.setDateFlag(detail.getTs().toString()); // 单据号
|
|
|
+ corp.setM_Pk_bank(detail.getPk_account()); // 本方银行主键
|
|
|
+ if (cstvo != null && cstvo.getContrastdate() != null)
|
|
|
+ continue; // 只查未对账数据
|
|
|
+ // 20040630 只查核销
|
|
|
+ if (query.getModuleCode() != null
|
|
|
+ && (query.getModuleCode().equals("3607CVCR") || query.getModuleCode().equals("20026507"))) {
|
|
|
+ if (cstvo != null && cstvo.getCavdate() != null)
|
|
|
+ corp.setM_cavdate(cstvo.getCavdate().toString()); // 核销日期
|
|
|
+ else
|
|
|
+ continue;
|
|
|
+ } else {
|
|
|
+ if (cstvo != null && cstvo.getCavdate() != null)
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (cstvo != null)
|
|
|
+ corp.setBatchNumber(cstvo.getBatchNumber()); // 批次号
|
|
|
+ corp.setPk_contrastaccount(conVo.getPk_contrastAccount());// 对账帐户
|
|
|
+ corp.setPk_link(conVo.getPk_accountlink());// 对账帐户关联表
|
|
|
+ list.add(corp);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ Debug.error(e.getMessage(), e);
|
|
|
+ throw new BusinessException(e.getMessage());
|
|
|
+ }
|
|
|
+ // 转化为CTransferVO
|
|
|
+ CTransferVO[] corpreceipts = new CTransferVO[list.size()];
|
|
|
+ CCorpReceiptVO corpReceipt = null;
|
|
|
+ for (int j = 0; j < list.size(); j++) {
|
|
|
+ CTransferVO votemp = new CTransferVO();
|
|
|
+ corpReceipt = list.get(j);
|
|
|
+ votemp.setVo(corpReceipt);
|
|
|
+ votemp.setCaved(corpReceipt.getBatchNumber() != null
|
|
|
+ && corpReceipt.getBatchNumber().trim().length() > 0);
|
|
|
+ votemp.setPk_account(corpReceipt.getPk_contrastaccount());
|
|
|
+ votemp.setM_pk_link(corpReceipt.getPk_link());
|
|
|
+ votemp.setM_pk_corp(corpReceipt.getPk_corp());
|
|
|
+ // votemp.setM_pk_subject(corpReceipt.getPk_subject());
|
|
|
+ votemp.setM_pk_bank(corpReceipt.getM_Pk_bank());
|
|
|
+ // votemp.setM_pk_ass(corpReceipt.getPk_ass());
|
|
|
+ votemp.setBatchNumber(corpReceipt.getBatchNumber());
|
|
|
+ votemp.setInit(new Boolean(true));
|
|
|
+ votemp.setKeyTool(new DefaultKeyTool());
|
|
|
+ corpreceipts[j] = votemp;
|
|
|
+ }
|
|
|
+ if (null != corpreceipts && corpreceipts.length > 0) {
|
|
|
+ return corpreceipts;
|
|
|
+ } else
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**********************************************************************************************************
|
|
|
+ * 功能: 查询符合对账情况的单据主键 参数: CQueryVO query 查询条件 返回: BankReceiptVO[]
|
|
|
+ **********************************************************************************************************/
|
|
|
+ @SuppressWarnings( { "unused"})
|
|
|
+ private HashMap<Object, String> getCorpReceiptPrimaryKey(CQueryVO query)
|
|
|
+ throws SQLException {
|
|
|
+ /*************************************************************/
|
|
|
+ // 保留的系统管理接口:
|
|
|
+ beforeCallMethod("nc.bs.gl.contrastpub.QueryDMO",
|
|
|
+ ".getCorpReceiptPrimaryKey()", new Object[] { query });
|
|
|
+ /*************************************************************/
|
|
|
+
|
|
|
+ String[] pk_account = query.getPk_Account();
|
|
|
+ String strTemp = "";
|
|
|
+ for (int i = 0; i < pk_account.length; i++) {
|
|
|
+ strTemp += "'" + pk_account[i] + "',";
|
|
|
+ }
|
|
|
+ if (strTemp.length() > 0) {
|
|
|
+ strTemp = strTemp.substring(0, strTemp.length() - 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ String sql = " select fk_detail ,cavdate from gl_contrast where isnull(fk_detail,'~') <> '~' ";
|
|
|
+ if (strTemp.length() > 0) {
|
|
|
+ sql += " and pk_contrastaccount in (" + strTemp + ")";
|
|
|
+ }
|
|
|
+ if (query.getDate() != null)
|
|
|
+ sql += " and corpdate >= '" + query.getDate() + "'";
|
|
|
+ if (query.getEndDate() != null) {
|
|
|
+ if (query.isIncludeLast().booleanValue())
|
|
|
+ sql += " and corpdate <= '" + query.getEndDate() + "'";
|
|
|
+ else
|
|
|
+ sql += " and corpdate < '" + query.getEndDate() + "'";
|
|
|
+ }
|
|
|
+
|
|
|
+ sql += " group by fk_detail,cavdate order by fk_detail,cavdate ";
|
|
|
+
|
|
|
+ HashMap<Object, String> hasResult = new HashMap<Object, String>();
|
|
|
+
|
|
|
+ Connection con = null;
|
|
|
+ PreparedStatement stmt = null;
|
|
|
+ try {
|
|
|
+ con = getConnection();
|
|
|
+ stmt = con.prepareStatement(sql);
|
|
|
+ ResultSet rs = stmt.executeQuery();
|
|
|
+ //
|
|
|
+ while (rs.next()) {
|
|
|
+ Object pks = rs.getString(1);
|
|
|
+ Object cavdate = rs.getObject(2);
|
|
|
+ if (pks != null) {
|
|
|
+ if (cavdate == null
|
|
|
+ || cavdate.toString().trim().length() < 1) {
|
|
|
+ hasResult.put(pks, "1"); // 对帐标记
|
|
|
+ } else {
|
|
|
+ hasResult.put(pks, "2"); // 核销数据标记
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ if (stmt != null) {
|
|
|
+ stmt.close();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ if (con != null) {
|
|
|
+ con.close();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /*************************************************************/
|
|
|
+ // 保留的系统管理接口:
|
|
|
+ afterCallMethod("nc.bs.gl.contrastpub.QueryDMO",
|
|
|
+ ".getCorpReceiptPrimaryKey()", new Object[] { query });
|
|
|
+ /*************************************************************/
|
|
|
+
|
|
|
+ return hasResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**************************************************
|
|
|
+ * 作者: 王建华 创建时间: 2001.9.28 功能: Object,返回其对应的double值
|
|
|
+ **************************************************/
|
|
|
+ public double getDoubleValue(Object objValue) {
|
|
|
+ double dblTemp = 0.00;
|
|
|
+ if (objValue instanceof Double)
|
|
|
+ dblTemp = ((Double) objValue).doubleValue();
|
|
|
+ else if (objValue instanceof Integer)
|
|
|
+ dblTemp = ((Integer) objValue).intValue();
|
|
|
+ else if (objValue instanceof Long)
|
|
|
+ dblTemp = ((Long) objValue).longValue();
|
|
|
+ else if (objValue instanceof UFDouble)
|
|
|
+ dblTemp = ((UFDouble) objValue).doubleValue();
|
|
|
+ else if (objValue instanceof String) {
|
|
|
+ try {
|
|
|
+ dblTemp = (Double.valueOf(String.valueOf(objValue)))
|
|
|
+ .doubleValue();
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ dblTemp = 0.0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return roundDouble(dblTemp);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 得到关联公司 创建日期:(2002-3-21 20:09:48)
|
|
|
+ */
|
|
|
+ private AccountlinkVO[] getLink(String strPk_Account, String years)
|
|
|
+ throws Exception {
|
|
|
+ nc.bs.gl.contrast.ContrastBO bo = new nc.bs.gl.contrast.ContrastBO();
|
|
|
+ AccountlinkVO[] vos = bo.queryAccountLink(strPk_Account, years);
|
|
|
+ return vos;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 得到帐户开始日期。 创建日期:(2002-3-21 20:09:48)
|
|
|
+ */
|
|
|
+ private UFDate getStartDate(String strPk_account, String strYear)
|
|
|
+ throws Exception {
|
|
|
+ /*************************************************************/
|
|
|
+ // 保留的系统管理接口:
|
|
|
+ beforeCallMethod("nc.bs.gl.contrastpub.QueryDMO", "getStartDate",
|
|
|
+ new Object[] { strPk_account });
|
|
|
+ /*************************************************************/
|
|
|
+ String strSql = "select startdate from gl_accountstart where pk_contrastaccount = '"
|
|
|
+ + strPk_account + "' and years = '" + strYear + "'";
|
|
|
+ Connection con = null;
|
|
|
+ PreparedStatement stmt = null;
|
|
|
+ try {
|
|
|
+ con = getConnection();
|
|
|
+ stmt = con.prepareStatement(strSql);
|
|
|
+ ResultSet rs = stmt.executeQuery();
|
|
|
+ if (rs.next()) {
|
|
|
+ String strTemp = rs.getString(1);
|
|
|
+ if (strTemp != null)
|
|
|
+ return new UFDate(strTemp.substring(0, 10) + " 00:00:00");
|
|
|
+ else
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ if (stmt != null) {
|
|
|
+ stmt.close();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ if (con != null) {
|
|
|
+ con.close();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /*************************************************************/
|
|
|
+ // 保留的系统管理接口:
|
|
|
+ afterCallMethod("nc.bs.gl.contrastpub.QueryDMO", "getStartDate",
|
|
|
+ new Object[] { strPk_account });
|
|
|
+ /*************************************************************/
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**************************************************
|
|
|
+ * 作者: 王建华 创建时间: 2000.3.5 功能: 对于一个double型的计算结果进行校正 参数: d:要进行校正的double型数字
|
|
|
+ * 返回值: 调整后的double型转为String字符串
|
|
|
+ **************************************************/
|
|
|
+
|
|
|
+ private double roundDouble(double d) {
|
|
|
+ double dblNew = Math.abs(d);
|
|
|
+
|
|
|
+ long lngTemp = (long) dblNew;
|
|
|
+ double dblTemp = dblNew - lngTemp;
|
|
|
+
|
|
|
+ double convertFactor;
|
|
|
+ int scale = 8;
|
|
|
+ convertFactor = 0.5;
|
|
|
+
|
|
|
+ dblNew = lngTemp
|
|
|
+ + (((long) (dblTemp * Math.pow(10, scale) + convertFactor)) / Math
|
|
|
+ .pow(10, scale));
|
|
|
+
|
|
|
+ if (d < 0)
|
|
|
+ d = dblNew * (-1);
|
|
|
+ else
|
|
|
+ d = dblNew;
|
|
|
+
|
|
|
+ return d;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**********************************************************************************************************
|
|
|
+ * 功能: 余额调节表2.3升级 参数: CQueryVO query 查询条件 返回:
|
|
|
+ **********************************************************************************************************/
|
|
|
+ public boolean updateBalance() throws Exception {
|
|
|
+
|
|
|
+ /*************************************************************/
|
|
|
+ // 保留的系统管理接口:
|
|
|
+ beforeCallMethod("nc.bs.gl.contrastpub.QueryDMO", "updateBalance",
|
|
|
+ new Object[] {});
|
|
|
+ /*************************************************************/
|
|
|
+
|
|
|
+ ContrastVO[] contrasts = null;
|
|
|
+ String strSql = " select contrastcode,max(corpdate),pk_contrastaccount from gl_contrast group by contrastcode, pk_contrastaccount ";
|
|
|
+ //
|
|
|
+ Vector<ContrastVO> v = new Vector<ContrastVO>();
|
|
|
+ Connection con = null;
|
|
|
+ PreparedStatement stmt = null;
|
|
|
+ try {
|
|
|
+ con = getConnection();
|
|
|
+ stmt = con.prepareStatement(strSql);
|
|
|
+ ResultSet rs = stmt.executeQuery();
|
|
|
+ String contrastcode = "";
|
|
|
+ String maxdate = "";
|
|
|
+ String account = "";
|
|
|
+ while (rs.next()) {
|
|
|
+ ContrastVO contrast = new ContrastVO();
|
|
|
+ //
|
|
|
+ contrastcode = rs.getString(1);
|
|
|
+ contrast.setContrastcode(contrastcode == null ? null
|
|
|
+ : contrastcode.trim());
|
|
|
+ maxdate = rs.getString(2);
|
|
|
+ contrast.setMax_contrastdate(maxdate == null ? null
|
|
|
+ : new UFDate(maxdate.trim()));
|
|
|
+ account = rs.getString(3);
|
|
|
+ contrast.setPk_contrastaccount(account == null ? null : account
|
|
|
+ .trim());
|
|
|
+ v.addElement(contrast);
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ if (stmt != null) {
|
|
|
+ stmt.close();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ if (con != null) {
|
|
|
+ con.close();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ contrasts = new ContrastVO[v.size()];
|
|
|
+ if (v.size() > 0) {
|
|
|
+ v.copyInto(contrasts);
|
|
|
+ }
|
|
|
+ if (contrasts != null) {
|
|
|
+ for (int i = 0; i < contrasts.length; i++) {
|
|
|
+ updateContrast(contrasts[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ updateCav();
|
|
|
+ /*************************************************************/
|
|
|
+ // 保留的系统管理接口:
|
|
|
+ afterCallMethod("nc.bs.gl.contrastpub.QueryDMO", "updateBalance",
|
|
|
+ new Object[] {});
|
|
|
+ /*************************************************************/
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用一个VO对象的属性更新数据库中的值。
|
|
|
+ *
|
|
|
+ * 创建日期:(2003-9-9)
|
|
|
+ *
|
|
|
+ * @param contrast
|
|
|
+ * nc.vo.gl.contrast.ContrastVO
|
|
|
+ * @exception java.sql.SQLException
|
|
|
+ * 异常说明。
|
|
|
+ */
|
|
|
+ public void updateCav() throws java.sql.SQLException {
|
|
|
+
|
|
|
+ /*************************************************************/
|
|
|
+ // 保留的系统管理接口:
|
|
|
+ beforeCallMethod("nc.bs.gl.contrastpub.QueryDMO", "updateCav",
|
|
|
+ new Object[] { null });
|
|
|
+ /*************************************************************/
|
|
|
+
|
|
|
+ /*
|
|
|
+ * String sql = "update gl_contrast set cavdate = null"; Connection con
|
|
|
+ * = null; PreparedStatement stmt = null; try { con=getConnection();
|
|
|
+ * stmt = con.prepareStatement(sql);
|
|
|
+ *
|
|
|
+ * stmt.executeUpdate(); } finally { try { if (stmt != null) {
|
|
|
+ * stmt.close(); } }catch (Exception e) {} try { if (con != null) {
|
|
|
+ * con.close(); } }catch (Exception e) {} }
|
|
|
+ *
|
|
|
+ * /
|
|
|
+ */
|
|
|
+ // 保留的系统管理接口:
|
|
|
+ afterCallMethod("nc.bs.gl.contrastpub.QueryDMO", "updateCav",
|
|
|
+ new Object[] { null });
|
|
|
+ /*************************************************************/
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用一个VO对象的属性更新数据库中的值。
|
|
|
+ *
|
|
|
+ * 创建日期:(2003-9-9)
|
|
|
+ *
|
|
|
+ * @param contrast
|
|
|
+ * nc.vo.gl.contrast.ContrastVO
|
|
|
+ * @exception java.sql.SQLException
|
|
|
+ * 异常说明。
|
|
|
+ */
|
|
|
+ public void updateContrast(ContrastVO contrast)
|
|
|
+ throws java.sql.SQLException {
|
|
|
+
|
|
|
+ /*************************************************************/
|
|
|
+ // 保留的系统管理接口:
|
|
|
+ beforeCallMethod("nc.bs.gl.contrastpub.QueryDMO", "updateContrast",
|
|
|
+ new Object[] { contrast });
|
|
|
+ /*************************************************************/
|
|
|
+
|
|
|
+ String sql = "update gl_contrast set memo1 = '"
|
|
|
+ + contrast.getMax_contrastdate() + "'";
|
|
|
+ sql += " where contrastcode = '" + contrast.getContrastcode() + "'";
|
|
|
+ sql += " and pk_contrastaccount = '" + contrast.getPk_contrastaccount()
|
|
|
+ + "'";
|
|
|
+ Connection con = null;
|
|
|
+ PreparedStatement stmt = null;
|
|
|
+ try {
|
|
|
+ con = getConnection();
|
|
|
+ stmt = con.prepareStatement(sql);
|
|
|
+
|
|
|
+ stmt.executeUpdate();
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ if (stmt != null) {
|
|
|
+ stmt.close();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ if (con != null) {
|
|
|
+ con.close();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /*************************************************************/
|
|
|
+ // 保留的系统管理接口:
|
|
|
+ afterCallMethod("nc.bs.gl.contrastpub.QueryDMO", "updateContrast",
|
|
|
+ new Object[] { contrast });
|
|
|
+ /*************************************************************/
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @author zhaozh 2008-6-10 上午10:42:10 查找未对账的银行日记账,以10000条记录为一个单位进行对账
|
|
|
+ * @param query
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public CTransferVO[] getUnContrastBankReceipt(CQueryVO query)
|
|
|
+ throws Exception {
|
|
|
+ if (getDatabaseType() == 1) {
|
|
|
+ /*************************************************************/
|
|
|
+ // 保留的系统管理接口:
|
|
|
+ beforeCallMethod("nc.bs.gl.contrastpub.QueryDMO",
|
|
|
+ "getUnContrastBankReceipt", new Object[] { query });
|
|
|
+ /*************************************************************/
|
|
|
+ // 0为正常 1为勾对 2为核销
|
|
|
+ StringBuffer strSql = new StringBuffer("");
|
|
|
+ strSql.append("select gl_bankreceipt.pk_bankreceipt, gl_bankreceipt.pk_contrastaccount, explanation, checkstyle, pk_check, checkdate, gl_bankreceipt.debitamount, gl_bankreceipt.creditamount, gl_bankreceipt.years, gl_bankreceipt.period ,");
|
|
|
+ strSql.append(" case when isnull(gl_contrast.cavdate,'~')='~' and isnull(gl_contrast.contrastdate,'~')='~' then 0 else case when isnull(gl_contrast.cavdate,'~')='~' then 1 else 2 end end");
|
|
|
+ strSql.append(" ,gl_bankreceipt.memo,gl_bankreceipt.pk_corp,gl_bankreceipt.pk_subject,gl_bankreceipt.pk_bank,gl_bankreceipt.pk_ass");
|
|
|
+ strSql.append(" from gl_bankreceipt left outer join gl_contrast gl_contrast on gl_bankreceipt.pk_bankreceipt = gl_contrast.pk_bankreceipt ");
|
|
|
+ int counter = 0;
|
|
|
+ int limit = query.getNumber();
|
|
|
+ String[] pk_account = query.getPk_Account();
|
|
|
+ String strTemp = "";
|
|
|
+ for (int i = 0; i < pk_account.length; i++) {
|
|
|
+ strTemp = strTemp + "'" + pk_account[i] + "',";
|
|
|
+ }
|
|
|
+ if (strTemp.length() > 0) {
|
|
|
+ strTemp = strTemp.substring(0, strTemp.length() - 1);
|
|
|
+ }
|
|
|
+ // ///////////
|
|
|
+ StringBuffer strWhere = new StringBuffer("");
|
|
|
+ if (query.getNodecode() == 20040115 && query.isM_bflag()) {
|
|
|
+ String str = " and gl_contrast.memo1 > '" + query.getEndDate() + "'";
|
|
|
+ strWhere.append(str);
|
|
|
+ }
|
|
|
+ if (pk_account != null && pk_account.length > 0) {
|
|
|
+ strWhere.append(" and gl_bankreceipt.pk_contrastaccount in (" + strTemp + ")");
|
|
|
+ }
|
|
|
+ // 过滤未对账数据
|
|
|
+ strWhere.append(" and isnull(gl_contrast.contrastdate,'~')='~' ");
|
|
|
+ if (query.getPk_link() != null && !query.isMerge())
|
|
|
+ strWhere.append(" and gl_bankreceipt.memo = '" + query.getPk_link() + "' ");
|
|
|
+
|
|
|
+ if (query.getYear() != null)
|
|
|
+ strWhere.append(" and gl_bankreceipt.years = '" + query.getYear() + "' ");
|
|
|
+ if (query.isInitRange() != null) {
|
|
|
+ if (query.isInitRange().booleanValue())
|
|
|
+ strWhere.append(" and gl_bankreceipt.period = '00' ");
|
|
|
+ else
|
|
|
+ strWhere.append(" and gl_bankreceipt.period <> '00' ");
|
|
|
+ }
|
|
|
+ if (query.getDate() != null) {
|
|
|
+ strWhere.append(" and gl_bankreceipt.checkdate >= '" + query.getDate() + "'");
|
|
|
+ }
|
|
|
+ if (query.getEndDate() != null) {
|
|
|
+ strWhere.append(" and gl_bankreceipt.checkdate <= '" + query.getEndDate() + "'");
|
|
|
+ }
|
|
|
+ /* zhaozh 2008-5-30 下午01:45:24 增加银行对帐单票据日期查询条件 */
|
|
|
+ if (query.getN_pjdate1() != null) {
|
|
|
+ strWhere.append(" and gl_bankreceipt.checkdate >= '" + query.getN_pjdate1() + "'");
|
|
|
+ }
|
|
|
+ if (query.getN_pjdate2() != null) {
|
|
|
+ strWhere.append(" and gl_bankreceipt.checkdate <= '" + query.getN_pjdate2() + "'");
|
|
|
+ }
|
|
|
+ // 结算方式
|
|
|
+ if (query.getCheckStyle() != null
|
|
|
+ && query.getCheckStyle().length() > 0){
|
|
|
+ if(query.getIsEqualCheckStyle() == null || query.getIsEqualCheckStyle().booleanValue()){
|
|
|
+ strWhere.append(" and gl_bankreceipt.checkstyle= '" + query.getCheckStyle() + "'");
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ strWhere.append(" and gl_bankreceipt.checkstyle<> '" + query.getCheckStyle() + "'");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 结算号
|
|
|
+ if (query.getCheckNO() != null && query.getCheckNO().length() > 0)
|
|
|
+ strWhere.append(" and gl_bankreceipt.pk_check = '" + query.getCheckNO() + "'");
|
|
|
+ // 不查异常记录
|
|
|
+ strWhere.append(" and (gl_bankreceipt.styleflag ='A' or isnull(gl_bankreceipt.styleflag,'~')='~') ");
|
|
|
+ strSql.append(" where " + strWhere.substring(4));
|
|
|
+ strSql.append(" order by checkdate ,gl_bankreceipt.debitamount, gl_bankreceipt.creditamount");
|
|
|
+ Vector<BankReceiptVO> vecResult = new Vector<BankReceiptVO>();
|
|
|
+ Connection con = null;
|
|
|
+ PreparedStatement stmt = null;
|
|
|
+ java.util.HashSet<String> checkSet = new java.util.HashSet<String>();
|
|
|
+ java.util.HashMap checkMap = new java.util.HashMap();
|
|
|
+ Object[] checktemp = null;
|
|
|
+ try {
|
|
|
+ con = getConnection();
|
|
|
+ stmt = con.prepareStatement(strSql.toString());
|
|
|
+ Logger.debug(" 开始银行查询:" + strSql.toString());
|
|
|
+ ResultSet rs = stmt.executeQuery();
|
|
|
+ while (rs.next()) {
|
|
|
+ counter++;
|
|
|
+ if (counter > limit)
|
|
|
+ break;
|
|
|
+ BankReceiptVO bankreceipt = new BankReceiptVO();
|
|
|
+ bankreceipt.setPk_bankreceipt(rs.getString(1));
|
|
|
+ bankreceipt.setPk_contrastaccount(rs.getString(2));
|
|
|
+ bankreceipt.setExplanation(rs.getString(3));
|
|
|
+ strTemp = rs.getString(4);
|
|
|
+ bankreceipt.setCheckstyle(strTemp == null ? strTemp
|
|
|
+ : strTemp.trim());
|
|
|
+ if (bankreceipt.getCheckstyle() != null) {
|
|
|
+ checkSet.add(bankreceipt.getCheckstyle());
|
|
|
+ }
|
|
|
+ strTemp = rs.getString(5);
|
|
|
+ bankreceipt.setPk_check(strTemp == null ? strTemp : strTemp
|
|
|
+ .trim());
|
|
|
+ String checkdate = rs.getString(6);
|
|
|
+ bankreceipt.setCheckdate(checkdate == null ? null
|
|
|
+ : new UFDate(checkdate.trim()));
|
|
|
+ Object t1 = rs.getObject(7);
|
|
|
+ Object t2 = rs.getObject(8);
|
|
|
+ if (t1 != null) {
|
|
|
+ bankreceipt.setDebitamount(new UFDouble(t1.toString()));
|
|
|
+ } else {
|
|
|
+ bankreceipt.setDebitamount(new UFDouble(0.0));
|
|
|
+ }
|
|
|
+ if (t2 != null) {
|
|
|
+ bankreceipt.setCreditamount(new UFDouble(t2.toString()));
|
|
|
+ } else {
|
|
|
+ bankreceipt.setCreditamount(new UFDouble(0.0));
|
|
|
+ }
|
|
|
+
|
|
|
+ bankreceipt.setYears(rs.getString(9));
|
|
|
+ bankreceipt.setPeriod(rs.getString(10));
|
|
|
+ // flag 勾对标记 :
|
|
|
+ int flags = rs.getInt(11);
|
|
|
+ bankreceipt.setflag(Integer.valueOf(flags));
|
|
|
+ bankreceipt.setMemo(rs.getString(12));
|
|
|
+ bankreceipt.setPk_corp(rs.getString(13));
|
|
|
+ bankreceipt.setPk_subject(rs.getString(14));
|
|
|
+ bankreceipt.setPk_bank(rs.getString(15));
|
|
|
+ bankreceipt.setPk_ass(rs.getString(16));
|
|
|
+ vecResult.addElement(bankreceipt);
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ if (stmt != null) {
|
|
|
+ stmt.close();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ if (con != null) {
|
|
|
+ con.close();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // ////////////////////////////////////////////////
|
|
|
+ checktemp = checkSet.toArray();
|
|
|
+ nc.bs.gl.bookinterface.VoucherDetailDMO dmos = new nc.bs.gl.bookinterface.VoucherDetailDMO();
|
|
|
+ checkMap = dmos.getCheckNamesByPKs(checktemp);
|
|
|
+ if (checkMap == null) {
|
|
|
+ checkMap = new java.util.HashMap();
|
|
|
+ }
|
|
|
+ // ///////////////////////////////////////////////
|
|
|
+ Object checkpk = null;
|
|
|
+ // 转化为CTransferVO
|
|
|
+ BankKeyTool keyTool = new BankKeyTool();
|
|
|
+ CTransferVO[] corpreceipts = new CTransferVO[vecResult.size()];
|
|
|
+ for (int j = 0; j < vecResult.size(); j++) {
|
|
|
+ CTransferVO votemp = new CTransferVO();
|
|
|
+ BankReceiptVO bankreceipt = vecResult.elementAt(j);
|
|
|
+ checkpk = checkMap.get(bankreceipt.getCheckstyle());
|
|
|
+ if (checkpk != null) {
|
|
|
+ bankreceipt.setCheckstyle(checkpk.toString());
|
|
|
+ }
|
|
|
+ votemp.setVo(bankreceipt);
|
|
|
+ votemp.setKeyTool(keyTool);
|
|
|
+ votemp.setPk_account(bankreceipt.getPk_contrastaccount());
|
|
|
+ votemp.setCaved(bankreceipt.getflag().intValue() == 1 ? Boolean.TRUE : Boolean.FALSE);
|
|
|
+ votemp.setM_pk_link(bankreceipt.getMemo());
|
|
|
+ votemp.setM_pk_corp(bankreceipt.getPk_corp());
|
|
|
+ votemp.setM_pk_subject(bankreceipt.getPk_subject());
|
|
|
+ votemp.setM_pk_bank(bankreceipt.getPk_bank());
|
|
|
+ votemp.setM_pk_ass(bankreceipt.getPk_ass());
|
|
|
+ corpreceipts[j] = votemp;
|
|
|
+ }
|
|
|
+ /*************************************************************/
|
|
|
+ // 保留的系统管理接口:
|
|
|
+ afterCallMethod("nc.bs.gl.contrastpub.QueryDMO",
|
|
|
+ "getUnContrastBankReceipt", new Object[] { query });
|
|
|
+ /*************************************************************/
|
|
|
+ return corpreceipts;
|
|
|
+ } else
|
|
|
+ return getBankReceipt(query);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @author zhaozh 2008-6-10 上午10:55:52 获得单位日记账未对账数据
|
|
|
+ * @param query
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public CTransferVO[] getUnContrastCorpReceipt(CQueryVO query)
|
|
|
+ throws Exception {
|
|
|
+ CTransferVO[] corpreceipts = null;
|
|
|
+ // 得到单位期初数据
|
|
|
+ query.setNumber(CmpConst.LIMIT);
|
|
|
+ CTransferVO[] result1 = getUnContrastCorpReceiptInit(query);
|
|
|
+ query.setNumber(query.getNumber() - result1.length);
|
|
|
+ CTransferVO[] result2 = null;
|
|
|
+ if (query.isInitRange() == null || !query.isInitRange().booleanValue()) {
|
|
|
+ // 通过接口得到单位数据
|
|
|
+ result2 = getUnContrastCorpReceiptOccur(query);
|
|
|
+ }
|
|
|
+ query.setNumber(query.getNumber() + result1.length);
|
|
|
+ int count1 = result1 == null ? 0 : result1.length;
|
|
|
+ int count2 = result2 == null ? 0 : result2.length;
|
|
|
+ // 连接两种数据
|
|
|
+ corpreceipts = new CTransferVO[count1 + count2];
|
|
|
+ for (int i = 0; i < count1; i++) {
|
|
|
+ corpreceipts[i] = result1[i];
|
|
|
+ }
|
|
|
+ for (int i = 0; i < count2; i++) {
|
|
|
+ corpreceipts[count1 + i] = result2[i];
|
|
|
+ }
|
|
|
+ return corpreceipts;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @author zhaozh 2008-6-10 下午01:10:46 获取单位日记账发生额 未对账数据,增加数据量限制
|
|
|
+ * @param query
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private CTransferVO[] getUnContrastCorpReceiptOccur(CQueryVO query)
|
|
|
+ throws Exception {
|
|
|
+ Vector<CTransferVO> vecResult = new Vector<CTransferVO>();
|
|
|
+ nc.vo.glpub.IVoAccess[] result = null;
|
|
|
+
|
|
|
+ IDataAccess dataAccess = null;
|
|
|
+ IKey keyTool = null;
|
|
|
+
|
|
|
+ // 设置部分单位账查询条件
|
|
|
+ CConditionVO corpCondition = new CConditionVO();
|
|
|
+ if (query.getNumber() != null && query.getNumber() > 0)
|
|
|
+ corpCondition.setLimit(query.getNumber());
|
|
|
+ corpCondition.setDate(query.getDate());
|
|
|
+ corpCondition.setEndDate(query.getEndDate());
|
|
|
+ corpCondition.setIncludeLast(query.isIncludeLast());
|
|
|
+ corpCondition.setM_isConTally(query.getM_isConTally());
|
|
|
+ // ArrayList<CTransferVO> cmpVos = new ArrayList<CTransferVO>();
|
|
|
+ for (int i = 0; i < query.getPk_Account().length; i++) {
|
|
|
+ ContrastAccountVO accountVO = getAccount(query.getPk_Account()[i]);
|
|
|
+ Integer intSourceID = accountVO.getSource();
|
|
|
+ nc.vo.pub.lang.UFDate startdate = getStartDate(query
|
|
|
+ .getPk_Account()[i], query.getYear());
|
|
|
+ if (query.getDate() == null
|
|
|
+ || startdate.compareTo(query.getDate()) > 0)
|
|
|
+ corpCondition.setDate(startdate);
|
|
|
+ corpCondition.setPk_currtype(accountVO.getPk_currtype());
|
|
|
+ // 是否包含未记账,作用于余额调节表。前面setM_isConTally(query.getM_isConTally());的设置有漏洞。
|
|
|
+ // by jh
|
|
|
+ corpCondition.setM_isConTally(accountVO.getM_isConTally());
|
|
|
+ // 得到反射类
|
|
|
+ if (intSourceID == 1) {
|
|
|
+ dataAccess = (IDataAccess) getClassName(intSourceID, "class");
|
|
|
+ keyTool = (IKey) getClassName(intSourceID, "key");
|
|
|
+ } else {
|
|
|
+ keyTool = new DefaultKeyTool();
|
|
|
+ }
|
|
|
+ AccountlinkVO[] links = getLink(query.getPk_Account()[i], query
|
|
|
+ .getYear());
|
|
|
+ for (int iLink = 0; iLink < links.length; iLink++) {
|
|
|
+ if (query.getPk_link() != null
|
|
|
+ && query.getPk_link().length() > 0) {
|
|
|
+ if (query.getPk_link().equals(
|
|
|
+ links[iLink].getPk_accountlink())) {
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ corpCondition.setBankAccount(new String[] { links[iLink]
|
|
|
+ .getBankaccount() });
|
|
|
+ corpCondition.setPk_corp(links[iLink].getPk_corp());
|
|
|
+ corpCondition.setPk_accsubj(new String[] { links[iLink]
|
|
|
+ .getPk_subject() });
|
|
|
+ corpCondition.setIncludeLast(query.isIncludeLast());
|
|
|
+ corpCondition.setAssID(links[iLink].getPk_ass()); // 辅助核算
|
|
|
+ String joinStr = " left outer join gl_contrast on ";
|
|
|
+ joinStr += " gl_contrast.fk_detail = ";
|
|
|
+ corpCondition.setSqlJoin(joinStr);
|
|
|
+ String str = "";
|
|
|
+ if (query.getVerified() != null) {
|
|
|
+ if (!query.getVerified().booleanValue()
|
|
|
+ && !query.isM_cavDetai()) {
|
|
|
+ // 不要核销数据
|
|
|
+ str += " and isnull(gl_contrast.cavdate,'~')='~' ";
|
|
|
+ corpCondition.setSqlWhere(str);
|
|
|
+ } else {
|
|
|
+ str += " and isnull(gl_contrast.cavdate,'~') <> '~' ";
|
|
|
+ corpCondition.setSqlWhere(str);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 查询未对账数据
|
|
|
+ str += " and isnull(gl_contrast.contrastdate,'~')='~' ";
|
|
|
+ corpCondition.setSqlWhere(str);
|
|
|
+ // if(query.getChecked() != null){
|
|
|
+ // if(!query.getChecked().booleanValue()){
|
|
|
+ // //没有对帐数据
|
|
|
+ // corpCondition.setSqlWhere(str);
|
|
|
+ // }else{
|
|
|
+ // //对帐数据
|
|
|
+ // corpCondition.setSqlWhere(str);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ if (query.isM_cavDetai()) {
|
|
|
+ // 核销明细
|
|
|
+ str += " and gl_contrast.cavdate = '"
|
|
|
+ + query.getM_cavDate() + "' ";
|
|
|
+ if (query.getM_cavMan() != null) {
|
|
|
+ str += " and gl_contrast.cavman = '"
|
|
|
+ + query.getM_cavMan() + "' ";
|
|
|
+ } else {
|
|
|
+ str += " and isnull(gl_contrast.cavman,'~')='~' ";
|
|
|
+ }
|
|
|
+ corpCondition.setSqlWhere(str);
|
|
|
+ }
|
|
|
+ /* zhaozh 2008-6-10 下午01:21:21 当数据量大时,分批次对账。增加对账数目限制 */
|
|
|
+ // if(query.getNumber()>0){
|
|
|
+ // str += " and rownum<= " + query.getNumber();
|
|
|
+ // corpCondition.setSqlWhere(str);
|
|
|
+ // }
|
|
|
+ if (query.getNodecode() == 20040115 && query.isM_bflag()) {
|
|
|
+ str += " and gl_contrast.memo1 > '" + query.getEndDate()
|
|
|
+ + "'";
|
|
|
+ corpCondition.setSqlWhere(str);
|
|
|
+ }
|
|
|
+ // result = dataAccess.queryByConditionVO(corpCondition);
|
|
|
+ if (intSourceID == 1) {// 凭证查询
|
|
|
+ corpCondition.setSqlWhere(str);
|
|
|
+ result = dataAccess.queryByConditionVO(corpCondition);
|
|
|
+ } else if (intSourceID == 2) {// 资金帐查询
|
|
|
+ StringBuilder sb = new StringBuilder(str);
|
|
|
+ // 结算方式
|
|
|
+ if (query.getCheckStyle() != null) {
|
|
|
+ if(query.getIsEqualCheckStyle() == null || query.getIsEqualCheckStyle().booleanValue()){
|
|
|
+ sb.append(" and pk_balancetype = '"
|
|
|
+ + query.getCheckStyle() + "' ");
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ sb.append(" and pk_balancetype <> '"
|
|
|
+ + query.getCheckStyle() + "' ");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ // 结算号
|
|
|
+ /*if (query.getCheckNO() != null) {
|
|
|
+ sb.append(" and paybillcode = '"
|
|
|
+ + query.getCheckNO() + "' ");
|
|
|
+ }*/
|
|
|
+ // 金额范围(借 ---- 资金帐付款)
|
|
|
+ if (query.getMoneyAspect() == 0) {
|
|
|
+ sb.append(" and direction = 0 ")
|
|
|
+ .append(query.getMoneyArea1() == null ? ""
|
|
|
+ : " and recmoney >= "
|
|
|
+ + query.getMoneyArea1())
|
|
|
+ .append(query.getMoneyArea2() == null ? ""
|
|
|
+ : " and recmoney <= "
|
|
|
+ + query.getMoneyArea2());
|
|
|
+ }
|
|
|
+ // 金额范围(贷 ---- 资金帐收款)
|
|
|
+ if (query.getMoneyAspect() == 1) {
|
|
|
+ sb.append(" and direction = 1 ")
|
|
|
+ .append(query.getMoneyArea1() == null ? " "
|
|
|
+ : " and paymoney >= "
|
|
|
+ + query.getMoneyArea1())
|
|
|
+ .append(query.getMoneyArea2() == null ? " "
|
|
|
+ : " and paymoney <= "
|
|
|
+ + query.getMoneyArea2());
|
|
|
+ }
|
|
|
+ // 金额范围(借贷)
|
|
|
+ if (query.getMoneyAspect() == -1) {
|
|
|
+ if (query.getMoneyArea1() != null
|
|
|
+ && query.getMoneyArea2() != null) {
|
|
|
+ sb.append(" and ((recmoney >= "
|
|
|
+ + query.getMoneyArea1()
|
|
|
+ + " and recmoney <="
|
|
|
+ + query.getMoneyArea2() + ")")
|
|
|
+ .append(" or ( paymoney >= "
|
|
|
+ + query.getMoneyArea1()
|
|
|
+ + " and paymoney <="
|
|
|
+ + query.getMoneyArea2()
|
|
|
+ + "))");
|
|
|
+ } else if (query.getMoneyArea1() != null) {
|
|
|
+ sb.append(" and (recmoney >= "
|
|
|
+ + query.getMoneyArea1()).append(
|
|
|
+ " or paymoney >= " + query.getMoneyArea1() + ") ");
|
|
|
+ } else if (query.getMoneyArea2() != null) {
|
|
|
+ sb.append(" and (recmoney <= "
|
|
|
+ + query.getMoneyArea2()).append(
|
|
|
+ " or paymoney <= " + query.getMoneyArea2() + ") ");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 票据日期/记账日期
|
|
|
+ if (query.getN_pjdate1() != null) {
|
|
|
+ sb.append(" and checkdate >= '" + query.getN_pjdate1() + "' ");
|
|
|
+ }
|
|
|
+ if (query.getN_pjdate2() != null) {
|
|
|
+ sb.append(" and checkdate <= '" + query.getN_pjdate2() + "' ");
|
|
|
+ }
|
|
|
+ // 单据类型
|
|
|
+ if (!StringUtil.isEmptyWithTrim(query.getN_voucherType())) {
|
|
|
+ sb.append(" and pk_billtype = '" + query.getN_voucherType() + "' ");
|
|
|
+ }
|
|
|
+ // 单据号
|
|
|
+ if (!StringUtil.isEmptyWithTrim(query.getN_voucherCode1())) {
|
|
|
+ sb.append(" and vbillno = '" + query.getN_voucherCode1() + "' ");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (links[iLink] != null) {
|
|
|
+ sb.append(" and gl_accountlink.pk_accountlink = '" + links[iLink].getPk_accountlink() + "' ");
|
|
|
+ }
|
|
|
+
|
|
|
+ sb.append(" and gl_contrastaccount.pk_contrastaccount=gl_accountlink.pk_contrastaccount ");
|
|
|
+ corpCondition.setSqlWhere(sb.toString());
|
|
|
+ // 设置assid字段为pk_account
|
|
|
+ if (query.getPk_link() != null
|
|
|
+ && query.getPk_Account().length > 0) {
|
|
|
+ corpCondition.setAssID(query.getPk_Account()[0]);
|
|
|
+ }
|
|
|
+ // if(StringUtil.isEmptyWithTrim(corpCondition.getAssID()))
|
|
|
+ // corpCondition.setAssID(query.getPk_Account()[0]);
|
|
|
+ if (query.getPk_Corp() != null) {
|
|
|
+ corpCondition.setM_pk_glorgbook(query.getPk_Corp());
|
|
|
+ }
|
|
|
+ CTransferVO[] vos = findCmpDetailByCondition(corpCondition, query);
|
|
|
+ if (vos != null && vos.length > 0) {
|
|
|
+ result = new CTransferVO[vos.length];
|
|
|
+ for (int idx = 0; idx < vos.length; idx++) {
|
|
|
+ result[idx] = vos[idx];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // if(vos != null && vos.length>0)
|
|
|
+ // for(CTransferVO vo:vos){
|
|
|
+ // cmpVos.add(vo);
|
|
|
+ // }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 转化为CTransferVO
|
|
|
+ for (int j = 0; result != null && j < result.length; j++) {
|
|
|
+ CTransferVO votemp = new CTransferVO();
|
|
|
+ votemp.setVo(result[j]);
|
|
|
+ // if(intSourceID.intValue() == 1){
|
|
|
+ // 来源凭证
|
|
|
+ if (result[j].getValue(keyTool
|
|
|
+ .getBusinessKey(CCorpReceiptKey.CONTRASTDATE)) == null) {
|
|
|
+ votemp.setCaved(Boolean.FALSE);
|
|
|
+ } else {
|
|
|
+ votemp.setCaved(Boolean.TRUE);
|
|
|
+ }
|
|
|
+ // }
|
|
|
+ // else{
|
|
|
+ // if(result[j].getValue(keyTool.getBusinessKey(CCorpReceiptKey.CONTRASTDATE))
|
|
|
+ // == null){
|
|
|
+ // votemp.setCaved(Boolean.FALSE);
|
|
|
+ // }else{
|
|
|
+ // votemp.setCaved(Boolean.TRUE);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ votemp.setPk_account(query.getPk_Account()[i]);
|
|
|
+ votemp.setInit(new Boolean(false));
|
|
|
+ votemp.setKeyTool(keyTool); // 要查数据库
|
|
|
+ votemp.setM_pk_link(links[iLink].getPk_accountlink());
|
|
|
+ votemp.setM_pk_corp(links[iLink].getPk_corp());
|
|
|
+ votemp.setM_pk_subject(links[iLink].getPk_subject());
|
|
|
+ votemp.setM_pk_bank(links[iLink].getBankaccount());
|
|
|
+ votemp.setM_pk_ass(links[iLink].getPk_ass());
|
|
|
+ vecResult.addElement(votemp);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // if(cmpVos != null && cmpVos.size() != 0){
|
|
|
+ // return cmpVos.toArray(new CTransferVO[cmpVos.size()]);
|
|
|
+ // }
|
|
|
+ }
|
|
|
+ CTransferVO[] resultVos = new CTransferVO[vecResult.size()];
|
|
|
+ vecResult.copyInto(resultVos);
|
|
|
+ return resultVos;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @author zhaozh 2008-6-10 下午01:09:30 获取期初单位日记账 加入对账数目的限制
|
|
|
+ * @param query
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ private CTransferVO[] getUnContrastCorpReceiptInit(CQueryVO query)
|
|
|
+ throws Exception {
|
|
|
+ /*************************************************************/
|
|
|
+ // 保留的系统管理接口:
|
|
|
+ beforeCallMethod("nc.bs.gl.contrastpub.QueryDMO", "getCorpReceiptInit",
|
|
|
+ new Object[] { query });
|
|
|
+ /*************************************************************/
|
|
|
+
|
|
|
+ String[] pk_account = query.getPk_Account();
|
|
|
+ int number = 0;
|
|
|
+ int limit = query.getNumber();
|
|
|
+ String strTemp = "";
|
|
|
+ for (int i = 0; i < pk_account.length; i++) {
|
|
|
+ strTemp = strTemp + "'" + pk_account[i] + "',";
|
|
|
+ }
|
|
|
+ if (strTemp.length() > 0) {
|
|
|
+ strTemp = strTemp.substring(0, strTemp.length() - 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ String sql = "";
|
|
|
+ sql = " select pk_corpreceipt,gl_corpreceipt.pk_contrastaccount,pk_vouchertype,vouchno,prepareddate,explanation,gl_corpreceipt.debitamount,gl_corpreceipt.creditamount ,checkstyle,checkno ,checkdate,gl_corpreceipt.years, ";
|
|
|
+ sql += " case when isnull(gl_contrast.cavdate ,'~')='~' and isnull(gl_contrast.contrastdate,'~')='~' then 0 else case when isnull(gl_contrast.cavdate,'~')='~' then 1 else 2 end end ";
|
|
|
+ sql += " ,gl_corpreceipt.memo,gl_corpreceipt.pk_corp,gl_corpreceipt.pk_subject,gl_corpreceipt.pk_bank,gl_corpreceipt.pk_ass,gl_corpreceipt.pk_group ";
|
|
|
+ sql += " from gl_corpreceipt left outer join gl_contrast on gl_corpreceipt.pk_corpreceipt = gl_contrast.fk_detail ";
|
|
|
+ // ///////////////
|
|
|
+ if (pk_account != null && pk_account.length > 0) {
|
|
|
+ // sql += " and gl_contrast.pk_contrastaccount in (" + strTemp +
|
|
|
+ // ")";
|
|
|
+ }
|
|
|
+ if (query.getDate() != null) {
|
|
|
+ // strWhere.append(" and gl_bankreceipt.checkdate >= '" +
|
|
|
+ // query.getDate().toString() + "'");
|
|
|
+ sql += " and gl_contrast.corpdate >= '"
|
|
|
+ + query.getDate().toString() + "'";
|
|
|
+ }
|
|
|
+ if (query.getEndDate() != null) {
|
|
|
+ // strWhere.append(" and gl_bankreceipt.checkdate <= '" +
|
|
|
+ // query.getEndDate().toString() + "'");
|
|
|
+ sql += " and gl_contrast.corpdate <= '"
|
|
|
+ + query.getEndDate().toString() + "'";
|
|
|
+ }
|
|
|
+
|
|
|
+ // ///////////////
|
|
|
+
|
|
|
+ StringBuffer strWhere = new StringBuffer("");
|
|
|
+
|
|
|
+ if (query.isM_cavDetai()) {
|
|
|
+ // 核销明细
|
|
|
+ strWhere.append(" and gl_contrast.cavdate = '"
|
|
|
+ + query.getM_cavDate() + "' ");
|
|
|
+
|
|
|
+ if (query.getM_cavMan() == null) {
|
|
|
+ strWhere.append(" and isnull(gl_contrast.cavman,'~')='~'");
|
|
|
+ } else {
|
|
|
+ strWhere.append(" and gl_contrast.cavman = '"
|
|
|
+ + query.getM_cavMan() + "' ");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (query.isChecked() != null) {
|
|
|
+ if (query.isChecked().booleanValue())
|
|
|
+ strWhere.append(" and isnull(gl_contrast.contrastdate,'~') <> '~' ");
|
|
|
+ else
|
|
|
+ strWhere.append(" and isnull(gl_contrast.contrastdate,'~')='~' ");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (query.getNodecode() == 20040115 && query.isM_bflag()) {
|
|
|
+ String str = " and gl_contrast.memo1 > '" + query.getEndDate()
|
|
|
+ + "'";
|
|
|
+ strWhere.append(str);
|
|
|
+ }
|
|
|
+ if (query.isVerified() != null) {
|
|
|
+ if (query.isVerified().booleanValue())
|
|
|
+ strWhere.append(" and isnull(gl_contrast.cavdate,'~') <> '~' ");
|
|
|
+ else
|
|
|
+ strWhere.append(" and isnull(gl_contrast.cavdate,'~')='~' ");
|
|
|
+ }
|
|
|
+ if (query.getYear() != null)
|
|
|
+ strWhere.append(" and gl_corpreceipt.years = '" + query.getYear()
|
|
|
+ + "' ");
|
|
|
+ if (query.getPk_link() != null)
|
|
|
+ strWhere.append(" and gl_corpreceipt.memo = '" + query.getPk_link()
|
|
|
+ + "' ");
|
|
|
+
|
|
|
+ if (query.getDate() != null)
|
|
|
+ strWhere.append(" and gl_corpreceipt.prepareddate >= '"
|
|
|
+ + query.getDate().toString() + "'");
|
|
|
+ if (query.getEndDate() != null)
|
|
|
+ strWhere.append(" and gl_corpreceipt.prepareddate <= '"
|
|
|
+ + query.getEndDate().toString() + "'");
|
|
|
+
|
|
|
+ if (query.getCheckNO() != null && query.getCheckNO().length() > 0)
|
|
|
+ strWhere.append(" and gl_corpreceipt.checkno = '"
|
|
|
+ + query.getCheckNO() + "'");
|
|
|
+
|
|
|
+ if (strTemp.length() > 0)
|
|
|
+ strWhere.append(" and gl_corpreceipt.pk_contrastaccount in ( "
|
|
|
+ + strTemp + ") ");
|
|
|
+ /* zhaozh 2008-6-10 下午12:43:28 当数据量大时,分批次对账。增加对账数目限制 */
|
|
|
+ // if(query.getNumber()>0){
|
|
|
+ // strWhere.append(" and rownum <"+query.getNumber());
|
|
|
+ // }
|
|
|
+ Vector<CorpReceiptVO> vecResult = new Vector<CorpReceiptVO>();
|
|
|
+ Connection con = null;
|
|
|
+ PreparedStatement stmt = null;
|
|
|
+
|
|
|
+ java.util.HashSet<String> checkSet = new java.util.HashSet<String>();
|
|
|
+ java.util.HashMap checkMap = new java.util.HashMap();
|
|
|
+ Object[] checktemp = null;
|
|
|
+ nc.bs.gl.bookinterface.VoucherDetailDMO dmos = new nc.bs.gl.bookinterface.VoucherDetailDMO();
|
|
|
+ try {
|
|
|
+ sql += " where " + strWhere.toString().substring(4)
|
|
|
+ + " order by prepareddate,pk_vouchertype,vouchno ";
|
|
|
+ con = getConnection();
|
|
|
+ stmt = con.prepareStatement(sql);
|
|
|
+ ResultSet rs = stmt.executeQuery();
|
|
|
+ while (rs.next()) {
|
|
|
+ number++;
|
|
|
+ if (number > limit)
|
|
|
+ break;
|
|
|
+ CorpReceiptVO corpreceipt = new CorpReceiptVO();
|
|
|
+ corpreceipt.setPk_corpreceipt(rs.getString(1));
|
|
|
+ corpreceipt.setPk_contrastaccount(rs.getString(2));
|
|
|
+ corpreceipt.setPk_vouchertype(rs.getString(3));
|
|
|
+
|
|
|
+ strTemp = rs.getString(4);
|
|
|
+ corpreceipt.setVouchno(strTemp == null ? strTemp : strTemp
|
|
|
+ .trim());
|
|
|
+ corpreceipt.setPrepareddate(new UFDate(rs.getString(5)));
|
|
|
+ corpreceipt.setExplanation(rs.getString(6));
|
|
|
+ Object t1 = rs.getObject(7);
|
|
|
+ Object t2 = rs.getObject(8);
|
|
|
+ if (t1 != null) {
|
|
|
+ corpreceipt.setDebitamount(new UFDouble(t1.toString()));
|
|
|
+ } else {
|
|
|
+ corpreceipt.setDebitamount(UFDouble.ZERO_DBL);
|
|
|
+ }
|
|
|
+ if (t2 != null) {
|
|
|
+ corpreceipt.setCreditamount(new UFDouble(t2.toString()));
|
|
|
+ } else {
|
|
|
+ corpreceipt.setCreditamount(UFDouble.ZERO_DBL);
|
|
|
+ }
|
|
|
+ corpreceipt.setCheckstyle(rs.getString(9));
|
|
|
+ if (corpreceipt.getCheckstyle() != null) {
|
|
|
+ checkSet.add(corpreceipt.getCheckstyle());
|
|
|
+ }
|
|
|
+ strTemp = rs.getString(10);
|
|
|
+ corpreceipt.setCheckno(strTemp == null ? strTemp : strTemp
|
|
|
+ .trim());
|
|
|
+ // explanation :
|
|
|
+ String checkdate = rs.getString(11);
|
|
|
+ corpreceipt.setCheckdate(checkdate == null ? null : new UFDate(
|
|
|
+ checkdate));
|
|
|
+ corpreceipt.setYears(rs.getString(12));
|
|
|
+ corpreceipt.setflag(Integer.valueOf(rs.getInt(13)));
|
|
|
+ corpreceipt.setMemo(rs.getString(14));
|
|
|
+ corpreceipt.setPk_corp(rs.getString(15));
|
|
|
+ corpreceipt.setPk_subject(rs.getString(16));
|
|
|
+ corpreceipt.setPk_bank(rs.getString(17));
|
|
|
+ corpreceipt.setPk_ass(rs.getString(18));
|
|
|
+ corpreceipt.setPk_group(rs.getString(19));
|
|
|
+ vecResult.addElement(corpreceipt);
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ if (stmt != null) {
|
|
|
+ stmt.close();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ if (con != null) {
|
|
|
+ con.close();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 转化为CTransferVO
|
|
|
+ CTransferVO[] corpreceipts = new CTransferVO[vecResult.size()];
|
|
|
+ UnitKeyTool keyTool = new UnitKeyTool();
|
|
|
+ CorpReceiptVO corpReceipt = null;
|
|
|
+ // ////////////////////////////////////////////////
|
|
|
+ checktemp = checkSet.toArray();
|
|
|
+ checkMap = dmos.getCheckNamesByPKs(checktemp);
|
|
|
+ if (checkMap == null) {
|
|
|
+ checkMap = new java.util.HashMap();
|
|
|
+ }
|
|
|
+ // ///////////////////////////////////////////////
|
|
|
+ Object checkpk = null;
|
|
|
+ for (int j = 0; j < vecResult.size(); j++) {
|
|
|
+ CTransferVO votemp = new CTransferVO();
|
|
|
+ corpReceipt = vecResult.elementAt(j);
|
|
|
+
|
|
|
+ checkpk = checkMap.get(corpReceipt.getCheckstyle());
|
|
|
+ if (checkpk != null) {
|
|
|
+ corpReceipt.setCheckstyle(checkpk.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ votemp.setVo(corpReceipt);
|
|
|
+ votemp.setKeyTool(keyTool);
|
|
|
+ votemp.setCaved(new Boolean(corpReceipt.flag.intValue() > 0));
|
|
|
+ votemp.setPk_account(corpReceipt.getPk_contrastaccount());
|
|
|
+
|
|
|
+ votemp.setM_pk_link(corpReceipt.getMemo());
|
|
|
+ votemp.setM_pk_corp(corpReceipt.getPk_corp());
|
|
|
+ votemp.setM_pk_subject(corpReceipt.getPk_subject());
|
|
|
+ votemp.setM_pk_bank(corpReceipt.getPk_bank());
|
|
|
+ votemp.setM_pk_ass(corpReceipt.getPk_ass());
|
|
|
+ votemp.setInit(new Boolean(true));
|
|
|
+ corpreceipts[j] = votemp;
|
|
|
+ }
|
|
|
+ /*************************************************************/
|
|
|
+ // 保留的系统管理接口:
|
|
|
+ afterCallMethod("nc.bs.gl.contrastpub.QueryDMO", "getCorpReceiptInit",
|
|
|
+ new Object[] { query });
|
|
|
+ /*************************************************************/
|
|
|
+ return corpreceipts;
|
|
|
+ }
|
|
|
+
|
|
|
+ private IRegisterPubQueryService getFBMQueryService() {
|
|
|
+ if (fbmQueryService == null) {
|
|
|
+ fbmQueryService = NCLocator.getInstance().lookup(
|
|
|
+ IRegisterPubQueryService.class);
|
|
|
+ }
|
|
|
+ return fbmQueryService;
|
|
|
+ }
|
|
|
+
|
|
|
+ public IBalaTypePubService getBalaQry() {
|
|
|
+ if(balaQry == null) {
|
|
|
+ balaQry = NCLocator.getInstance().lookup(IBalaTypePubService.class);
|
|
|
+ }
|
|
|
+ return balaQry;
|
|
|
+ }
|
|
|
+}
|