package com.engine.htsc.capitalbusinessPayment.dao;

import com.engine.htsc.convertor.EcologyValueConvertor;
import com.engine.htsc.doc.model.UserInfoModel;
import com.engine.htsc.doc.util.ConvertUtil;

import org.apache.commons.lang.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;

import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 数据中心支付 资金业务付款&内部资金调拨
 */
public class OperateLiquidationDataDao extends BaseBean {
    private SimpleDateFormat sdfTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    private SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd");
    //数据中心库
    private final String dataBase_DB = "dataSourceCenter";
    //数据中心表名
    private final String tableName_DC = "T_OperateLiquidationData";
    //数据中心表字段
    private final String tableField_DC = "id,type,source,"
            + "sourceRef,relatedRef,businessBrief,ccy,payment_date,amount,sender_bankcode,"
            + "sender_name,sender_acc_number,receiver_bankcode,receiver_name,receiver_acc_number,"
            + "CNAPS_BANKCODE,initiator,initiator_id,initiator_contact,remark,priority,createTime,"
            + "createUser,lastUpdateTime,lastUpdateUser,receiver_provinceOrCity,receiver_city,drafter_dept_name,sender_seat,receiver_seat";
    //数据中心表字段值占位符
    private final String tableVaule_DC = "OPERATELIQUIDATIONDATA_SEQ.nextval,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?";

    public void saveToDC(String requestId, UserInfoModel currentUser) {
        String mainTableName = EcologyValueConvertor.getMainTableNameByRequestId(requestId);
        String unnumber = ConvertUtil.getUnNumber(requestId);//获取流程英文名
        boolean flag = findDCExist(requestId,mainTableName);
        writeLog("requestId:" + requestId + " 判断是否要写入数据中心表, 流程主表名:" + mainTableName+ " 流程图英文名:"+unnumber+" 当前处理人:"+currentUser.getWorkCode()
        +" flag:"+flag);
        if(!flag) {
            writeLog("requestId:" + requestId + " 开始写入数据中心表, 流程主表名:" + mainTableName+ " 流程图英文名:"+unnumber+" 当前处理人:"+currentUser.getWorkCode());
            if(StringUtils.isNotEmpty(unnumber)&&"zjywfk".equals(unnumber)) {//资金业务付款
                List<List<Object>> insertList = getLiquidDetailData_CapitalBusinessPayment(requestId, mainTableName, currentUser);
                insertList(tableField_DC, tableVaule_DC, insertList, dataBase_DB, tableName_DC);
                writeLog("requestId:" + requestId + " 资金业务付款 写入数据中心表 T_OperateLiquidationData 完成");
            }else if (StringUtils.isNotEmpty(unnumber)&&"zbzjnbdb".equals(unnumber)) {//内部资金调拨
                List<List<Object>> insertList = getLiquidDetailData_HTSelfMoney(requestId, mainTableName, currentUser);
                insertList(tableField_DC, tableVaule_DC, insertList, dataBase_DB, tableName_DC);
                writeLog("requestId:" + requestId + " 内部资金调拨 写入数据中心表 T_OperateLiquidationData 完成");
            } else if (StringUtils.isNotEmpty(unnumber)&&"xgtyfk".equals(unnumber)) {
                List<List<Object>> insertList = getLiquidDetailData_HKPayment(requestId, mainTableName, currentUser);
                insertList(tableField_DC, tableVaule_DC, insertList, dataBase_DB, tableName_DC);
                writeLog("requestId:" + requestId + " 香港付款 写入数据中心表 T_OperateLiquidationData 完成");
            }
        }
    }

    /**
     * 获取支付明细表数据[香港付款]
     * @param requestId
     * @param mainTableName
     * @return
     */
    List<List<Object>> getLiquidDetailData_HKPayment(String requestId, String mainTableName, UserInfoModel currentUser) {
        RecordSet rs = new RecordSet();
        List<List<Object>> insertList = new ArrayList<>();
        String dtTableName = mainTableName + "_dt11";
        String sqlDetail = " select t0.requestid,t1.lastname,d.yxzh,t1.lastname,d.khxmc,d.ss,t1.workcode,d.yxzfje,d.xjzfje,d.zpzfje,t0.lcbh,t0.htxx,t2.requestname," +
                "t0.biz,d.khx,d.skdw,d.yxzh,t0.ngr,t0.bz,t0.jjcd,t0.ngsj,d.ss "+
                " from "+dtTableName+" d, "+ mainTableName +" t0,hrmresource t1,workflow_requestbase t2 where t0.id = d.mainid and t0.requestid = t2.requestid and t0.ngr = t1.id and t0.requestid = '"+requestId+"'";
        writeLog("requestId:"+requestId+" 香港通用付款 关联查询查询明细表sql:"+sqlDetail);
        rs.execute(sqlDetail);
        while(rs.next()) {
            List<Object> list = new ArrayList<>();
            //type
            list.add("香港通用付款");
            //source
            list.add("OA");
            //sourceRef
            list.add(Util.null2String(rs.getString("lcbh")));
            //relatedRef 合同编号
            list.add(Util.null2String(rs.getString("htxx")));
            //businessBrief 流程标题
            list.add(Util.null2String(rs.getString("requestname")));
            //ccy 币种
            String bizId = Util.null2String(rs.getString("biz"));
            list.add(EcologyValueConvertor.getSelectNameByRequestIdAndFieldValue(requestId,"biz",bizId));
            //payment_date 空或待定 置成当前系统日期，否则置成主表单的应付款日期
            list.add(((DateFormat)sdfTime).format(new Date()));
            //amount 银行支付金额 + 现金支付金额 + 支票支付金额
            BigDecimal bankAmount = StringUtils.isEmpty(rs.getString("yxzfje"))?new BigDecimal("0.00"):new BigDecimal(rs.getString("yxzfje"));
            BigDecimal cashAmount = StringUtils.isEmpty(rs.getString("xjzfje"))?new BigDecimal("0.00"):new BigDecimal(rs.getString("xjzfje"));
            BigDecimal chequeAmount = StringUtils.isEmpty(rs.getString("zpzfje"))?new BigDecimal("0.00"):new BigDecimal(rs.getString("zpzfje"));
            list.add(bankAmount.add(cashAmount).add(chequeAmount).toString());
            //sender_bankcode 指定付款账户-开户行
            AssignPaymentAccount account = getAssignPaymentAccountByRequestId(requestId, mainTableName);
            list.add(account.getDepositBank());
            //sender_name 指定付款账户-户名
            list.add(account.getUserName());
            //sender_acc_number 指定付款账户-银行账号
            list.add(account.getBankAccount());
            //receiver_bankcode 收款方-开户行
            String khx = rs.getString("khx").replaceAll("&nbsp;"," ").replaceAll("<br>",""); //直接存文本 不要查14w条记录！！！ 泛微多行文本有bug 手动转义
            list.add(Util.null2String(khx));
            //receiver_name 收款方-收款单位
            list.add(Util.null2String(rs.getString("skdw")).replaceAll("&nbsp;"," ").replaceAll("<br>",""));//泛微多行文本有bug 手动转义
            //receiver_acc_number 收款方-银行账号
            list.add(Util.null2String(rs.getString("yxzh")).replaceAll("&nbsp;"," ").replaceAll("<br>",""));//泛微多行文本有bug 手动转义
            //CNAPS_BANKCODE 大额支付号
            list.add("");
            //initiator 拟稿人姓名
            UserInfoModel userInfo = EcologyValueConvertor.getUserInfoModelById(Util.null2String(rs.getString("ngr")));
            list.add(userInfo.getName());
            //initiator_id 拟稿人工号
            list.add(userInfo.getWorkCode());
            //initiator_contact 拟稿人联系方式
            list.add(userInfo.getMobile());
            //remark 备注
            String remark = Util.null2String(rs.getString("bz"));
            if(StringUtils.isNotEmpty(remark)) {
                remark = remark.replaceAll("&nbsp;"," ").replaceAll("<br>","");
            }
            list.add(remark);
            //priority 缓急程度
            String jjcd = Util.null2String(rs.getString("jjcd"));
            list.add(EcologyValueConvertor.getSelectNameByRequestIdAndFieldValue(requestId,"jjcd",jjcd));
            //createTime 拟稿时间
            list.add(Util.null2String(rs.getString("ngsj"))+":00");
            //createUser 拟稿人工号
            list.add(userInfo.getWorkCode());
            //lastUpdateTime
            list.add(((DateFormat)sdfTime).format(new Date()));
            //lastUpdateUser 当前处理人工号
            list.add(currentUser.getWorkCode());
            //receiver_provinceOrCity  receiver_city 支付省市
            String area = Util.null2String(rs.getString("ss"));
            List<String> areaArray = cityCodeToName(area);
            if (null!=areaArray&&areaArray.size()>0) {
                list.add(areaArray.get(0));
                if (areaArray.size()>1){
                    list.add(areaArray.get(1));
                }else {
                    list.add("");
                }
            }else {
                list.add("");
                list.add("");
            }
            //drafter_dept_name 拟稿人部门名称
            list.add(userInfo.getDepartmentName());
            //sender_seat 付款席位号
            list.add("");
            //receiver_seat 收款席位号
            list.add("");
            insertList.add(list);
        }
        return insertList;
    }

    /**
     * 获取支付明细表数据[资金业务付款]
     * @param requestId
     * @param mainTableName
     * @return
     */
    List<List<Object>> getLiquidDetailData_CapitalBusinessPayment(String requestId, String mainTableName, UserInfoModel currentUser) {
        RecordSet rs = new RecordSet();
        List<List<Object>> insertList = new ArrayList<>();
        String dtTableName = mainTableName + "_dt11";
        String sqlDetail = " select t0.requestid,t1.lastname,d.yxzh,t1.lastname,d.khxmc,d.ss,t1.workcode,d.yxzfje,d.xjzfje,d.zpzfje,t0.lcbh,t0.htxx,t2.requestname," +
                "t0.biz,t0.yfkrq,d.khx,d.skdw,d.yxzh,d.dezfh,t0.ngr,t0.bz,t0.jjcd,t0.ngsj,d.ss "+
                " from "+dtTableName+" d, "+ mainTableName +" t0,hrmresource t1,workflow_requestbase t2 where t0.id = d.mainid and t0.requestid = t2.requestid and t0.ngr = t1.id and t0.requestid = '"+requestId+"'";
        writeLog("requestId:"+requestId+" 资金业务付款 关联查询查询明细表sql:"+sqlDetail);
        rs.execute(sqlDetail);
        while(rs.next()) {
            List<Object> list = new ArrayList<>();
            //type
            list.add("资金业务付款");
            //source
            list.add("OA");
            //sourceRef
            list.add(Util.null2String(rs.getString("lcbh")));
            //relatedRef 合同编号
            list.add(Util.null2String(rs.getString("htxx")));
            //businessBrief 流程标题
            list.add(Util.null2String(rs.getString("requestname")));
            //ccy 币种
            String bizId = Util.null2String(rs.getString("biz"));
            list.add(EcologyValueConvertor.getSelectNameByRequestIdAndFieldValue(requestId,"biz",bizId));
            //payment_date 空或待定 置成当前系统日期，否则置成主表单的应付款日期
            if(StringUtils.isEmpty(rs.getString("yfkrq"))||"待定".equals(rs.getString("yfkrq"))) {
                list.add(((DateFormat)sdfDate).format(new Date()));
            }else {
                list.add(Util.null2String(rs.getString("yfkrq")));
            }
            //amount 银行支付金额 + 现金支付金额 + 支票支付金额
            BigDecimal bankAmount = StringUtils.isEmpty(rs.getString("yxzfje"))?new BigDecimal("0.00"):new BigDecimal(rs.getString("yxzfje"));
            BigDecimal cashAmount = StringUtils.isEmpty(rs.getString("xjzfje"))?new BigDecimal("0.00"):new BigDecimal(rs.getString("xjzfje"));
            BigDecimal chequeAmount = StringUtils.isEmpty(rs.getString("zpzfje"))?new BigDecimal("0.00"):new BigDecimal(rs.getString("zpzfje"));
            list.add(bankAmount.add(cashAmount).add(chequeAmount).toString());
            //sender_bankcode 指定付款账户-开户行
            AssignPaymentAccount account = getAssignPaymentAccountByRequestId(requestId, mainTableName);
            list.add(account.getDepositBank());
            //sender_name 指定付款账户-户名
            list.add(account.getUserName());
            //sender_acc_number 指定付款账户-银行账号
            list.add(account.getBankAccount());
            //receiver_bankcode 收款方-开户行
            String khx = rs.getString("khx").replaceAll("&nbsp;"," ").replaceAll("<br>",""); //直接存文本 不要查14w条记录！！！ 泛微多行文本有bug 手动转义
            list.add(Util.null2String(khx));
            //receiver_name 收款方-收款单位
            list.add(Util.null2String(rs.getString("skdw")).replaceAll("&nbsp;"," ").replaceAll("<br>",""));//泛微多行文本有bug 手动转义
            //receiver_acc_number 收款方-银行账号
            list.add(Util.null2String(rs.getString("yxzh")).replaceAll("&nbsp;"," ").replaceAll("<br>",""));//泛微多行文本有bug 手动转义
            //CNAPS_BANKCODE 大额支付号
            list.add(Util.null2String(rs.getString("dezfh")));
            //initiator 拟稿人姓名
            UserInfoModel userInfo = EcologyValueConvertor.getUserInfoModelById(Util.null2String(rs.getString("ngr")));
            list.add(userInfo.getName());
            //initiator_id 拟稿人工号
            list.add(userInfo.getWorkCode());
            //initiator_contact 拟稿人联系方式
            list.add(userInfo.getMobile());
            //remark 备注
            String remark = Util.null2String(rs.getString("bz"));
            if(StringUtils.isNotEmpty(remark)) {
                remark = remark.replaceAll("&nbsp;"," ").replaceAll("<br>","");
            }
            list.add(remark);
            //priority 缓急程度
            String jjcd = Util.null2String(rs.getString("jjcd"));
            list.add(EcologyValueConvertor.getSelectNameByRequestIdAndFieldValue(requestId,"jjcd",jjcd));
            //createTime 拟稿时间
            list.add(Util.null2String(rs.getString("ngsj"))+":00");
            //createUser 拟稿人工号
            list.add(userInfo.getWorkCode());
            //lastUpdateTime
            list.add(((DateFormat)sdfTime).format(new Date()));
            //lastUpdateUser 当前处理人工号
            list.add(currentUser.getWorkCode());
            //receiver_provinceOrCity  receiver_city 支付省市
            String area = Util.null2String(rs.getString("ss"));
            List<String> areaArray = cityCodeToName(area);
            if (null!=areaArray&&areaArray.size()>0) {
                list.add(areaArray.get(0));
                if (areaArray.size()>1){
                    list.add(areaArray.get(1));
                }else {
                    list.add("");
                }
            }else {
                list.add("");
                list.add("");
            }
            //drafter_dept_name 拟稿人部门名称
            list.add(userInfo.getDepartmentName());
            //sender_seat 付款席位号
            list.add("");
            //receiver_seat 收款席位号
            list.add("");
            insertList.add(list);
        }
        return insertList;
    }



    /**
     * 获取支付明细表数据[内部资金调拨]
     * @param requestId
     * @param mainTableName
     * @return
     */
    List<List<Object>> getLiquidDetailData_HTSelfMoney(String requestId, String mainTableName, UserInfoModel currentUser) {
        RecordSet rs = new RecordSet();
        List<List<Object>> insertList = new ArrayList<>();
        String dtTableName = mainTableName + "_dt2";
        String sqlDetail = " select t0.requestid,t1.lastname,t1.workcode,d.zhlx,d.zh,d.hm,d.khx,d.xwh,d.dbje,t0.lcbh,t2.requestname,"+
                           " t0.zhbz,t0.fkrq,dd.khx as khx_pay,dd.hm as hm_pay,dd.zh as zh_pay,dd.xwh as xwh_pay,'',t0.ngr,t0.sqyy,t0.fksm,t0.jjcd,t0.ngsj,d.label "+
                           " from "+dtTableName+" d,"+ mainTableName+" t0,hrmresource t1,workflow_requestbase t2,"+dtTableName+" dd where t0.id = d.mainid and t0.requestid = t2.requestid and t0.ngr = t1.id and "+
                           " d.zhlx = '收款账户' and dd.zhlx = '付款账户' and dd.mainid = d.mainid and dd.label = d.label "+
                           " and t0.requestid = '"+requestId+"'";

        writeLog("requestId:"+requestId+" 内部资金调拨 关联查询查询明细表sql:"+sqlDetail);
        rs.execute(sqlDetail);
        while(rs.next()) {
            List<Object> list = new ArrayList<>();
            //type
            list.add("内部资金调拨");
            //source
            list.add("OA");
            //sourceRef
            list.add(Util.null2String(rs.getString("lcbh")));
            //relatedRef 合同编号
            list.add("");
            //businessBrief 流程标题
            list.add(Util.null2String(rs.getString("requestname")));
            //ccy 币种
            String zhbzId = Util.null2String(rs.getString("zhbz"));
            list.add(EcologyValueConvertor.getSelectNameByRequestIdAndFieldValue(requestId,"zhbz",zhbzId));
            //payment_date 空或待定 置成当前系统日期，否则置成主表单的应付款日期
            if(StringUtils.isEmpty(rs.getString("fkrq"))||"待定".equals(rs.getString("fkrq"))) {
                list.add(((DateFormat)sdfDate).format(new Date()));
            }else {
                list.add(Util.null2String(rs.getString("fkrq")));
            }
            //amount 调拨金额
            list.add(Util.null2String(rs.getString("dbje")));
            //sender_bankcode 付款账户-开户行
            list.add(Util.null2String(rs.getString("khx_pay")).replaceAll("&nbsp;"," ").replaceAll("<br>",""));
            //sender_name 付款账户-户名
            list.add(Util.null2String(rs.getString("hm_pay")).replaceAll("&nbsp;"," ").replaceAll("<br>",""));
            //sender_acc_number 付款账户-银行账号
            list.add(Util.null2String(rs.getString("zh_pay")).replaceAll("&nbsp;"," ").replaceAll("<br>",""));
            //receiver_bankcode 收款方-开户行
            String khx = rs.getString("khx").replaceAll("&nbsp;"," ").replaceAll("<br>",""); //直接存文本 不要查14w条记录！！！ 泛微多行文本有bug 手动转义
            list.add(Util.null2String(khx));
            //receiver_name 收款方-收款单位
            list.add(Util.null2String(rs.getString("hm")).replaceAll("&nbsp;"," ").replaceAll("<br>",""));//泛微多行文本有bug 手动转义
            //receiver_acc_number 收款方-银行账号
            list.add(Util.null2String(rs.getString("zh")).replaceAll("&nbsp;"," ").replaceAll("<br>",""));//泛微多行文本有bug 手动转义
            //CNAPS_BANKCODE 大额支付号
            list.add(Util.null2String(rs.getString("")));
            //initiator 拟稿人姓名
            UserInfoModel userInfo = EcologyValueConvertor.getUserInfoModelById(Util.null2String(rs.getString("ngr")));
            list.add(userInfo.getName());
            //initiator_id 拟稿人工号
            list.add(userInfo.getWorkCode());
            //initiator_contact 拟稿人联系方式
            list.add(userInfo.getMobile());
            //remark 备注
            String remark = Util.null2String(rs.getString("sqyy"))+Util.null2String(rs.getString("fksm"));
            if(StringUtils.isNotEmpty(remark)) {
                remark = remark.replaceAll("&nbsp;"," ").replaceAll("<br>","");
            }
            list.add(remark);
            //priority 缓急程度
            String jjcd = Util.null2String(rs.getString("jjcd"));
            list.add(EcologyValueConvertor.getSelectNameByRequestIdAndFieldValue(requestId,"jjcd",jjcd));
            //createTime 拟稿时间
            list.add(Util.null2String(rs.getString("ngsj"))+":00");
            //createUser 拟稿人工号
            list.add(userInfo.getWorkCode());
            //lastUpdateTime
            list.add(((DateFormat)sdfTime).format(new Date()));
            //lastUpdateUser 当前处理人工号
            list.add(currentUser.getWorkCode());
            //receiver_provinceOrCity  receiver_city 支付省市
            list.add("");
            list.add("");
            //drafter_dept_name 拟稿人部门名称
            list.add(userInfo.getDepartmentName());
            //sender_seat 付款席位号
            list.add(Util.null2String(rs.getString("xwh_pay")));
            //receiver_seat 收款席位号
            list.add(Util.null2String(rs.getString("xwh")));
            insertList.add(list);
        }
        return insertList;
    }


    /**
     * 获取流程指定付款账户中的第一条信息
     * @param requestId
     * @return
     */
    private AssignPaymentAccount getAssignPaymentAccountByRequestId(String requestId, String mainTableName) {
        RecordSet rs = new RecordSet();
        AssignPaymentAccount account = new AssignPaymentAccount();
        String sql = " select t9.* from "+mainTableName+" t0, "+mainTableName+"_dt9 t9,workflow_requestbase t2 "+
                " where t0.id = t9.mainid and t0.requestid = t2.requestid and t0.requestid = '"+ requestId + "' ";
        rs.executeQuery(sql);
        if(rs.next()) {
            account.setUserName(Util.null2String(rs.getString("hm")));
            account.setDepositBank(Util.null2String(rs.getString("khx")));
            account.setBankAccount(Util.null2String(rs.getString("yxzh")));
        }
        return account;
    }

    /**
     * 指定账户信息
     */
    public class AssignPaymentAccount {
        private String userName = ""; //户名
        private String depositBank = ""; //开户行
        private String bankAccount = "";  //银行账户

        public String getUserName() {
            return userName;
        }
        public void setUserName(String userName) {
            this.userName = userName;
        }
        public String getDepositBank() {
            return depositBank;
        }
        public void setDepositBank(String depositBank) {
            this.depositBank = depositBank;
        }
        public String getBankAccount() {
            return bankAccount;
        }
        public void setBankAccount(String bankAccount) {
            this.bankAccount = bankAccount;
        }
    }

    public static List<String> cityCodeToName(String code){
        RecordSet rs = new RecordSet();
        List<String> resultList = new ArrayList<>();
        if (StringUtils.isBlank(code)){
            return resultList;
        }
        String[] desInfo = code.split(",");
        String ids = Arrays.stream(desInfo).map(s -> "\'" + s +"\'").collect(Collectors.joining(","));
        String sql = "select name from uf_city where code in (" + ids + ") order by instr('" + code + "',code)";
        rs.executeQuery(sql);
        while (rs.next()){
            resultList.add(rs.getString("name"));
        }
        return resultList;
    }

    //批量插入表单，切换数据源
    public boolean insertList(String sqlTableS,String sqlTableE,List<List<Object>> insertList,String sqlData,String tablename){
        boolean flag = true;
        try {
            RecordSet rs = new RecordSet();
            //批量插入并切换数据源
            flag = rs.executeBatchSql(String.format("insert into %s (" + sqlTableS + ") values(" + sqlTableE + ") ", tablename), insertList, sqlData);
            String exceptionMsg = rs.getExceptionMsg();
            writeLog("exceptionMsg = " + exceptionMsg);
            writeLog("rs.getMsg() = " + rs.getMsg());
            writeLog("flag = " + flag);
        }catch (Exception exo){
            flag=false;
            exo.printStackTrace();
            new BaseBean().writeLog("插入明细表失败:"+exo.getMessage());
        }
        return flag;
    }

    /**
     * 查询数据中心是否存在已经写入的数据
     * @param requestId
     * @param mainTableName
     * @return 数据中心已存在true 数据中心不存在 false
     */
    public boolean findDCExist(String requestId, String mainTableName) {
        boolean flag = false;
        try {
            RecordSet rs = new RecordSet();
            String sql = " select lcbh from "+mainTableName+" t where t.requestid = '"+requestId+"' ";
            rs.executeQuery(sql);
            if(rs.next()) {
                RecordSet rs_DC = new RecordSet();
                String workflownum = rs.getString("lcbh");
                String findSQL = " select * from t_operateliquidationdata t where t.sourceref = '"+workflownum+"' ";
                new BaseBean().writeLog("requestId:"+requestId+" workflowNum:"+workflownum+" 查询数据中心是否存在:"+findSQL);
                rs_DC.executeSqlWithDataSource(findSQL,dataBase_DB);
                if(rs_DC.next()) {
                    flag = true;
                    new BaseBean().writeLog("requestId:"+requestId+" workflowNum:"+workflownum+" 数据存在 flag:"+flag);
                    return flag;
                }
            }
        }catch(Exception e) {
            e.printStackTrace();
            new BaseBean().writeLog("requestId:"+requestId+" 查询数据中心 t_operateliquidationdata 是否存在失败"+e.getStackTrace());
            return flag;
        }
        return flag;
    }

}
