package com.steering.pss.sale.order;

import CoreFS.SA06.CoreReturnObject;
import CoreFS.SA08.CoreXmlSqlParsersFactory;
import com.steering.comm.db.DBCommon;
import com.steering.comm.tools.EntityTool;
import com.steering.pss.sale.order.model.SelFundCustFundinoutEntity;

import java.util.ArrayList;

public class FrmFundInOut extends DBCommon {

    public CoreReturnObject save(ArrayList<String> parms){
        CoreReturnObject returnObject = new CoreReturnObject();
        int success = 0;
        int fail = 0;
        StringBuffer sb = new StringBuffer();
        for(String json : parms){
            try{
                SelFundCustFundinoutEntity entity = EntityTool.getEntityByGson(json, SelFundCustFundinoutEntity.class);
                String sql = CoreXmlSqlParsersFactory.getSql("FrmFundInOut.insert");
                sql = EntityTool.fillSqlByEntity(sql, entity);
                this.setData(sql);
                success++;
            }catch (Exception e){
                fail++;
                sb.append(e.getMessage());
            }
        }
        String msg = "导入成功：" + success + "条!";
        if (fail>0) {
            msg+="导入失败：" + fail + "条！失败原因："+sb;
        }
        returnObject.setV_errMsg(msg);
        return returnObject;
    }
}
