package weaver.interfaces.htsc.lhcd;

import com.engine.common.util.ServiceUtil;
import com.engine.htsc.lhcd.Service.LhcdDelaytriggerService;
import com.engine.htsc.lhcd.Service.impl.LhcdDelaytriggerServiceimpl;
import com.engine.htsc.lhhtsq.Serivce.LhhtsqBaseService;
import com.engine.htsc.lhhtsq.Serivce.impl.LhhtsqBaseServiceImpl;
import com.weaver.general.BaseBean;
import weaver.general.Util;
import weaver.interfaces.htsc.GlobatTools.JAVATools;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;

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

/**
 * @author xf
 * @version 1.0.0
 * @ClassName Lhcdendreload.java
 * @createTime 2021年12月28日 14:44:00
 */
public class Lhcdendreload extends BaseBean implements Action {


    private LhcdDelaytriggerService getlhcddelaytrigger()
    {
        return ServiceUtil.getService(LhcdDelaytriggerServiceimpl.class);
    }


    @Override
    public String  execute(RequestInfo requestInfo) {
       String requestid= Util.null2String(requestInfo.getRequestid());
       String tablename= Util.null2String(requestInfo.getRequestManager().getBillTableName());
       Map<String,Object> tablemap= gettablename(tablename,requestid);
       if(tablemap== null || tablemap.size()<=0){
           return Action.SUCCESS;
       }
       String cdxz= Util.null2String(tablemap.get("cdxz"));
       if(!"1".equals(cdxz)){
           return Action.SUCCESS;
       }
       //写入建模
        getlhcddelaytrigger().innermodel(tablemap);
        return Action.SUCCESS;
    }
    private Map<String,Object> gettablename(String tablename,String requestid){
        String sql="select * from "+tablename+" where 1=1 ";
        Map<String,String> params=new HashMap<>();
        params.put("requestid",requestid);
        return JAVATools.GetTableToMap(sql,params);
    }
}
