package com.engine.htsc.ReimbursementFlow.Esb.ThreadAsync;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.engine.htsc.ReimbursementFlow.Esb.Dao.UfzbbxesblocalDao;
import weaver.general.Util;
import weaver.interfaces.htsc.GlobatTools.JAVATools;

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

public class Ufzbbxesblocalinsert extends Thread  {

    private  String value;

    private UfzbbxesblocalDao ufzbbxesblocalDao=new UfzbbxesblocalDao();

    public Ufzbbxesblocalinsert(String value) {
        this.value = value;
    }


    @Override
    public void run() {
        Insert(this.value);
    }

    public void Insert(String responsestr) {

        JSONArray retjsonarray = new JSONArray();

        JSONObject jsonObjectstr = JSONObject.parseObject(responsestr);
        JSONArray jsonArray = (JSONArray) jsonObjectstr.get("travelList");

        for (int i = 0; i < jsonArray.size(); i++) {
            JSONObject jsonobj = (JSONObject) jsonArray.get(i);
            String travelCodedetail = Util.null2String(jsonobj.get("travelCode"));
            if (travelCodedetail != "") {
                if(ufzbbxesblocalDao.gettravelcodesum(travelCodedetail)<=0){
                    Map<String,String> map=new HashMap<>();
                    map.put("travelCode",travelCodedetail);
                    map.put("cjsj", JAVATools.getDatetime());
                    map.put("nr", JSON.toJSONString(jsonobj, SerializerFeature.WriteMapNullValue));
                    JAVATools.Excetesql(map,"uf_zbbxesblocal");
                }
            }


        }
    }
}
