package weaver.interfaces.htsc.tgpt;

import com.engine.integration.util.StringUtils;
import weaver.conn.RecordSet;
import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.soa.workflow.request.RequestInfo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * @Title: ecology-9
 * @Company: 泛微软件
 * @author: K1810039
 * @version: 1.0
 * @CreateDate: 2022-08-19
 * @Description: 这个接口主要是外部分析师再导入时将初始值更新到今年沟通数量
 * @ModifyLog:
 **/
public class InitConnectNum extends AbstractModeExpandJavaCodeNew {
    /**
     * 执行模块扩展动作
     * @param param
     *  param包含(但不限于)以下数据
     *  user 当前用户
     *  importtype 导入方式(仅在批量导入的接口动作会传输) 1 追加，2覆盖,3更新，获取方式(int)param.get("importtype")
     *  导入链接中拼接的特殊参数(仅在批量导入的接口动作会传输)，比如a=1，可通过param.get("a")获取参数值
     *  页面链接拼接的参数，比如b=2,可以通过param.get("b")来获取参数
     * @return
     */
    public Map<String, String> doModeExpand(Map<String, Object> param) {
        Map<String, String> result = new HashMap<String, String>();
        BaseBean bb = new BaseBean();
        bb.writeLog("投关平台修改沟通次数开始");
        RecordSet rs = new RecordSet();
        ArrayList<Map<String, Object>> list = new ArrayList<>();
        try {
            User user = (User)param.get("user");
            int billid = -1;//数据id
            int modeid = -1;//模块id
//            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){
                    //------请在下面编写业务逻辑代码------
                    bb.writeLog("投关平台billid"+billid);
                    bb.writeLog("投关平台modeid"+modeid);
                    String sql = "select * from uf_wbfxsxxgl where id =  " + billid;
                    rs.execute(sql);
                    rs.next();
                    String csz = rs.getString("csz");
                    sql =   "update uf_wbfxsxxgl set jnylygsgtsl =  '"+csz+"' where id = '"+billid+"'" ;
                    rs.execute(sql);

                }
            }
            result.put("flag", "true");
        } catch (Exception e) {
            result.put("errmsg","自定义出错信息");
            result.put("flag", "false");
        }
        return result;
    }

}
