package com.engine.htxc.contract.modeaction;


import com.engine.common.util.ServiceUtil;
import com.engine.htxc.commonutil.db.DbTools;
import com.engine.htxc.contract.service.ContractService;
import com.engine.htxc.contract.service.impl.ContractServiceImpl;
import com.google.common.collect.Maps;
import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.soa.workflow.request.RequestInfo;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author K1810015
 * @version 1.0.0
 * @ClassName ContractdoctopdfAction.java
 * @createTime 2022年07月29日 13:44:00
 */
public class SaveBankInfoToCounterpartyAction extends AbstractModeExpandJavaCodeNew {
    private DbTools dbtools=new DbTools();

    private ContractService getService() {
        return ServiceUtil.getService(ContractServiceImpl.class);
    }
    @Override
    public Map<String, String> doModeExpand(Map<String, Object> param) {
        Map<String, String> result = new HashMap<String, String>();
        try {
            User user = (User)param.get("user");
            int billid = -1;//数据id
            int modeid = -1;//模块id
            RequestInfo requestInfo = (RequestInfo)param.get("RequestInfo");
            if(requestInfo!=null){
                billid = Util.getIntValue(requestInfo.getRequestid());
                modeid = Util.getIntValue(requestInfo.getWorkflowid());
                if(billid>0&&modeid>0){
                    String tableName = dbtools.getFormmodeidToTable(String.valueOf(modeid))+"_dt2";
                    String sql = "select htdsf,yxzh,khx from "+tableName+" where mainid="+billid;
                    List<Map<String, Object>> dataList =  dbtools.getSqlToList(sql);
                    Map<String, Object> data = Maps.newHashMap();
                    data.put("data",dataList);
                    Map<String,Object> map = getService().saveBankInfoToCounterparty(data);
                }
            }
        } catch (Exception e) {
            result.put("errmsg",e.getMessage());
            result.put("flag", "false");
        }
        return result;
    }
}
