package weaver.interfaces.htsc.cooperation.task;

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.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class Usercallback 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 beanBean = new BaseBean();
        beanBean.writeLog("任务开始！！！！");
       TaskTools tasktools=new TaskTools();
        result=tasktools.reloadUser(param);

       if(result.get("flag")=="true")
            result=tasktools.ToSmsUser(param);

        beanBean.writeLog("任务结束查看！！！！"+result.get("flag"));
        return result;
    }


    public String sqlmaintableid(int billid){
        RecordSet rs = new RecordSet();
        BaseBean beanBean = new BaseBean();
        String mainid="";

        String sql=" select  xzsy from uf_rw where id="+billid;
        beanBean.writeLog("协作根据任务查询主表id："+sql);
        rs.execute(sql);
        if(rs.next()){
            mainid=rs.getString("xzsy");
        }
        return mainid;
    }


    public String disinctry(String[] array){

        if(array==null||array.length<0){
            return "";
        }
        String ryvalue="";
        List<String> listarray= java.util.Arrays.asList(array);
        List list=(List) listarray.stream().distinct().collect(Collectors.toList());
        ryvalue=String.join(",", list);
    /*    for (String value:array) {
            if(value!=""&&ryvalue.indexOf(value)<0){
                ryvalue+=value+",";
            }
        }
        if(ryvalue.length()>1){
            ryvalue=ryvalue.substring(0,ryvalue.length()-1);
        }*/
        return ryvalue;
    }







}
