package weaver.interfaces.htsc.hthy.cron;


import com.alibaba.fastjson.JSONObject;
import com.weaver.general.Util;
import weaver.conn.RecordSet;
import weaver.formmode.setup.ModeRightInfo;
import weaver.interfaces.schedule.BaseCronJob;

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

public class SetHyxxModeRightJob extends BaseCronJob {

    @Override
    public void execute() {
        RecordSet rs = new RecordSet();

        try {
            List<Map<String,String>> list = new ArrayList<Map<String,String>>();
            Map<String,String> map = null;
           String sql =" select id,formmodeid,modedatacreater " +
                        " from uf_hywh where substr(hysj,0,10)>= to_char(sysdate-3,'yyyy-mm-dd') \n" +
                        " and substr(hysj,0,10) < to_char(sysdate,'yyyy-mm-dd')\n" +
                        " and hysj is not null ";
            rs.execute(sql);
            while (rs.next()){
                String id = Util.null2String(rs.getString("id"));
                String formmodeid = Util.null2String(rs.getString("formmodeid"));
                String modedatacreater = Util.null2String(rs.getString("formmomodedatacreaterdeid"));

                map = new HashMap<String,String>();
                map.put("billid",id);
                map.put("formmodeid",formmodeid);
                map.put("modedatacreater",modedatacreater);
                list.add(map);
            }

            ModeRightInfo modeRightInfo = new ModeRightInfo();

            for(int i=0;i<list.size();i++){
                Map<String,String> datamap = list.get(i);
                String billid = Util.null2String(datamap.get("billid"));
                String formmodeid = Util.null2String(datamap.get("formmodeid"));
                String modedatacreater = Util.null2String(datamap.get("modedatacreater"));
                modeRightInfo.editModeDataShare(Util.getIntValue(modedatacreater),Util.getIntValue(formmodeid),Util.getIntValue(billid));
            }
        }catch (Exception e) {
            e.printStackTrace();
        }
    }



}
