package weaver.interfaces.htsc.gwlc;

import com.alibaba.fastjson.JSONObject;
import net.qiyuesuo.sdk.impl.UserServiceImpl;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.GCONST;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.interfaces.htsc.comInfo.PropBean;
import weaver.interfaces.workflow.action.Action;
import weaver.mobile.plugin.ecology.service.UserService;
import weaver.soa.workflow.request.RequestInfo;

/**
 * Created by K1810007 on 2020/10/21.
 */

public class sendPostOldSignetAction implements Action {
    public String getDetailid() {
        return detailid;
    }

    public void setDetailid(String detailid) {
        this.detailid = detailid;
    }

    private   String detailid;


    @Override
    public String execute(RequestInfo requestInfo)
    {


        RecordSet rs = new RecordSet();
        String requestid = requestInfo.getRequestid();
      User usr= requestInfo.getRequestManager().getUser();
      //  User usr=new User(13723);

    //  usr=new net.qiyuesuo.sdk.bean.user.User()
        new BaseBean().writeLog("用印开始了1！");
        new BaseBean().writeLog("detailid："+detailid);
        new BaseBean().writeLog("requestid："+requestid);
       // String detailid= requestInfo.g
        String message ="";
        if(!"".equals(requestid))
        {
            try{
                WrokflowOATooldSignet wrokflowoatooldsignet = new WrokflowOATooldSignet();
                 message = wrokflowoatooldsignet.createFwToOldSignet(Util.getIntValue(requestid),Util.getIntValue(detailid), usr );
                if("filelistisnull".equals(message)){
                    return Action.SUCCESS;
                }
                if(!"".equals(message)){
                    JSONObject messageObject = JSONObject.parseObject(message);
                    String status = Util.null2String(messageObject.get("status"));
                    if("200".equals(status)){
                        JSONObject dataObject = messageObject.getJSONObject("data");
                        String res = wrokflowoatooldsignet.insertDetail(dataObject);
                        if(!"1".equals(res)){
                            new BaseBean().writeLog("测试返回数据1："+message);
                         //   requestInfo.getRequestManager().setMessageid("1111"+message);
                          //  requestInfo.getRequestManager().setMessagecontent("用印推送回写信息异常");
                           // return Action.FAILURE_AND_CONTINUE;
                            return Action.SUCCESS;
                        }
                    }else{
                        new BaseBean().writeLog("测试返回数据2："+message);
                      //  requestInfo.getRequestManager().setMessageid("1111"+message);
                      //  requestInfo.getRequestManager().setMessagecontent("用印推送接口异常"+message);
                      //  return Action.FAILURE_AND_CONTINUE;
                        return Action.SUCCESS;
                    }
                }
            }catch (Exception e){
                new BaseBean().writeLog("测试返回数据："+message);
              //  requestInfo.getRequestManager().setMessageid("eeee"+e.getMessage());
               // requestInfo.getRequestManager().setMessagecontent("用印推送异常"+e.getMessage());
                return Action.SUCCESS;
            }
        }
        return Action.SUCCESS;
    }

    public static void main(String[] args) {
        GCONST.setRootPath("WEB-INF/");
        GCONST.setServerName("ecology");
        sendPostOldSignetAction sendPostOldSignetAction=  new sendPostOldSignetAction();
        sendPostOldSignetAction.setDetailid("4");
        RequestInfo requestInfo =new RequestInfo();
        requestInfo.setRequestid("1397397");



        sendPostOldSignetAction.execute(requestInfo);
    }

}
