package com.kingdee.eas.custom.esign.contract;

import com.alibaba.fastjson.JSONObject;
import com.kingdee.bos.BOSException;
import com.kingdee.bos.Context;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.shr.base.syssetting.MSFServiceFacadeFactory;
import com.kingdee.shr.base.syssetting.context.SHRContext;
import com.kingdee.shr.base.syssetting.exception.SHRWebException;
import com.kingdee.shr.base.syssetting.web.json.JSONUtils;
import com.kingdee.shr.batchContract.web.handler.ContractCompositionQueryHandler;
import org.springframework.ui.ModelMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

public class ContractCompositionQueryHandlerEx extends ContractCompositionQueryHandler {
    public String getTableDataAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws SHRWebException {
        Context ctx = SHRContext.getInstance().getContext();
        String id = request.getParameter("id");
        String number = request.getParameter("number");
        try {
            Map<String,Object> getSqlServiceMap = new HashMap<String,Object>();
            getSqlServiceMap.put("number",number);
            getSqlServiceMap.put("filter","  where \"employeeContract\".FID = '"+id+"'");
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("id",id);
            getSqlServiceMap.put("otherParameters",jsonObject);
            Object o2 = MSFServiceFacadeFactory.getLocalInstance(ctx)
                    .processService("getESignConfigTableService", getSqlServiceMap);
            Map<String,Object> map = new HashMap<String,Object>();
            map.put("code",200);
            map.put("data",o2);
            JSONUtils.SUCCESS(map);
        } catch (BOSException e) {
            throw new RuntimeException(e);
        } catch (EASBizException e) {
            throw new RuntimeException(e);
        }
        return null;
    }
}
