package com.weaver.seconddev.interfaces.htjt.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import com.weaver.common.i18n.tool.util.I18nContextUtil;
import com.weaver.verupgrade.conn.CONN_TYPE;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.weaver.verupgrade.general.Util;
import com.weaver.verupgrade.conn.RecordSet;
import com.weaver.verupgrade.formmode.setup.ModeRightInfo;

/**
 * createby
 * createTime
 * version v1
 * desc
 */
public class LogUtil {

    private static final org.slf4j.Logger logger_aada5a9c = LoggerFactory.getLogger(LogUtil.class);

    // 0 接收 1 推送
    private String lx = "";

    // 标题
    private String bt = "";

    // 流程id
    private String lcid = "";

    // 流程类型id
    private String lclxid = "";

    // 接口类名
    private String jklm = "";

    // 接口状态 	0成功　1失败　2异常
    private String jkzt = "";

    // 返回消息
    private String fhxx = "";

    // 推送参数
    private String tscs = "";

    /**
     */
    public void insertLog() {
        //TODO custom 已解决 ConnStatement
        InsertUtil iu = new InsertUtil();
        String tablename = "uf_interface_log";
        //TODO custom 已解决 ConnStatement
        String modeid = iu.getModeId(tablename);
//        String modeid ="";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        SimpleDateFormat sdf1 = new SimpleDateFormat("HH:mm:ss");
        SimpleDateFormat sdf2 = new SimpleDateFormat("HH:mm");
        String nowDate = sdf.format(new Date());
        String nowTime = sdf1.format(new Date());
        String nowTime2 = sdf2.format(new Date());
        String uuid = java.util.UUID.randomUUID().toString();
        Map<String, String> map = new HashMap<>();
        map.put("modedatacreatedate", nowDate);
        map.put("modedatacreatetime", nowTime);
        map.put("modedatacreater", "1");
        map.put("modedatacreatertype", "0");
        map.put("formmodeid", modeid);
        map.put("modeuuid", uuid);
        map.put("dyrq", nowDate);
        map.put("dysj", nowTime2);
        //
        map.put("lx", this.lx);
        //
        map.put("bt", this.bt);
        //
        map.put("lcid", this.lcid);
        //
        map.put("lclxid", this.lclxid);
        //
        map.put("jklm", this.jklm);
        //
        map.put("jkzt", this.jkzt);
        //
        map.put("fhxx", this.fhxx);
        //
        map.put("tscs", this.tscs);
        //TODO custom 已解决 ConnStatement
        iu.insert(map, tablename);
        String billid = "";
        RecordSet rs = I18nContextUtil.getBean(RecordSet.class);
        String sql = "select max(id) as billid from " + tablename + " where modeuuid='" + uuid + "'";
        String poolname = CONN_TYPE.workflow.getType();
        // TODO E10执行sql方法第二参数必须指定源，默认使用流程源，单体客户无需修改，微服务/组合客户需根据查询表所属服务切换源，或使用外部数据源
        rs.executeSql(sql, poolname);
        if (rs.next()) {
            billid = Util.null2String(rs.getString("billid"));
        }
        if (!"".equals(billid)) {
            ModeRightInfo ModeRightInfo = I18nContextUtil.getBean(ModeRightInfo.class);
            /* TODO 方法参数:Integer.valueOf("1") 类型发生变化 e9类型:java.lang.Integer e10类型:long
 TODO 方法参数:Util.getIntValue(modeid) 类型发生变化 e9类型:int e10类型:long
 TODO 方法参数:Integer.valueOf(billid) 类型发生变化 e9类型:java.lang.Integer e10类型:long
 TODO // 创建人字段已废弃 默认是用billid 数据对应的数据创建人*/
            ModeRightInfo.editModeDataShare(Integer.valueOf("1"), Util.getIntValue(modeid), Integer.valueOf(billid));
        }
    }

    public String getLx() {
        return lx;
    }

    public void setLx(String lx) {
        this.lx = lx;
    }

    public String getBt() {
        return bt;
    }

    public void setBt(String bt) {
        this.bt = bt;
    }

    public String getLcid() {
        return lcid;
    }

    public void setLcid(String lcid) {
        this.lcid = lcid;
    }

    public String getLclxid() {
        return lclxid;
    }

    public void setLclxid(String lclxid) {
        this.lclxid = lclxid;
    }

    public String getJklm() {
        return jklm;
    }

    public void setJklm(String jklm) {
        this.jklm = jklm;
    }

    public String getJkzt() {
        return jkzt;
    }

    public void setJkzt(String jkzt) {
        this.jkzt = jkzt;
    }

    public String getFhxx() {
        return fhxx;
    }

    public void setFhxx(String fhxx) {
        this.fhxx = fhxx;
    }

    public String getTscs() {
        return tscs;
    }

    public void setTscs(String tscs) {
        this.tscs = tscs;
    }
}
