package com.engine.htsc.ReimbursementFlow.Service.Impl;

import com.engine.core.impl.Service;
import com.engine.htsc.ReimbursementFlow.Dao.GettravelsubsidyDao;
import com.engine.htsc.ReimbursementFlow.Service.GettravelsubsidyService;
import com.engine.htsc.ReimbursementFlow.tool.Apireturn;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import weaver.general.Util;
import weaver.interfaces.htsc.GlobatTools.JAVATools;

import java.util.List;
import java.util.Map;

public class GettravelsubsidyServiceImpl extends Service implements GettravelsubsidyService {

    private GettravelsubsidyDao gettravelsubsidyDao=new GettravelsubsidyDao();

    @Override
    public String GettavelSubsiday(Map<String, String> map) {

        try {
            List<Map<String, Object>> listmap = gettravelsubsidyDao.getWorkflowInfo(map);
            if(listmap==null||listmap.size()<=0){
                return Apireturn.returnmes(200,"success",new JSONArray());
            }
            JSONArray relateWfAllowancesarray=new JSONArray();
            for(Map<String, Object> entry : listmap){
                JSONObject relateWfAllowancesObj = new JSONObject();
                relateWfAllowancesObj.put("requestId", Util.null2String(entry.get("requestid")));
                relateWfAllowancesObj.put("workflowNumber", Util.null2String(entry.get("lcbh")));
                relateWfAllowancesObj.put("workflowName", Util.null2String(entry.get("requestname")));
                relateWfAllowancesObj.put("lastOperateTime",Util.null2String(entry.get("lastoperatedate")));
                relateWfAllowancesObj.put("workcode", Util.null2String(entry.get("workcode")));
                relateWfAllowancesObj.put("bankCardNum", Util.null2String(entry.get("yxzh")));
                relateWfAllowancesObj.put("bankName", Util.null2String(entry.get("khxmc")));
                relateWfAllowancesObj.put("allowance", Util.getDoubleValue(Util.null2String(entry.get("yxzfje"))));
                relateWfAllowancesObj.put("deptCode", Util.null2String(entry.get("departmentcode")));
                relateWfAllowancesObj.put("deptName", Util.null2String(entry.get("departmentname")));
                relateWfAllowancesarray.add(relateWfAllowancesObj);
            }

        return Apireturn.returnmes(200,"success",relateWfAllowancesarray);
        }catch (Exception exo){
            JAVATools.SetCmdwritelog("总部补贴数据error",exo.getMessage());
        }
        return Apireturn.returnmes(200,"success",new JSONArray());

    }
}
