package weaver.interfaces.htxc.contract.modeaction;

import cn.hutool.core.thread.ThreadUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.htxc.commonutil.log.CustomizeLog;
import com.engine.htxc.contract.number.service.impl.ContractNumberServiceImpl;
import com.engine.htxc.contract.service.impl.ContractdoctopdfServiceImpl;
import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.soa.workflow.request.RequestInfo;

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

/**
 * @author K1810015
 * @version 1.0.0
 * @ClassName ContractdoctopdfAction.java
 * @createTime 2022年07月29日 13:44:00
 */
public class ContractdoctopdfAction extends AbstractModeExpandJavaCodeNew {


    @Override
    public Map<String, String> doModeExpand(Map<String, Object> param) {
        Map<String, String> result = new HashMap<String, String>();
        try {
            User user = (User)param.get("user");
            int billid = -1;//数据id
            int modeid = -1;//模块id
            RequestInfo requestInfo = (RequestInfo)param.get("RequestInfo");
            if(requestInfo!=null){
                billid = Util.getIntValue(requestInfo.getRequestid());
                modeid = Util.getIntValue(requestInfo.getWorkflowid());
                if(billid>0&&modeid>0){
                    Map<String,Object> map=new HashMap<>();
                    map.put("billid",billid);
                    map.put("modeid",modeid);
                    CustomizeLog.printLog("开始做doc转pdf操作");
                    //单独跑一个线程来做转pdf操作
                    //ThreadUtil.execute
                    ThreadUtil.execute(new Runnable() {
                        @Override
                        public void run() {
                            CustomizeLog.printLog("转dpf异步开始");
                            ServiceUtil.getService(ContractdoctopdfServiceImpl.class).doctopdf(map);
                            CustomizeLog.printLog("转dpf异步结束");
                        }
                    });
                }
            }
        } catch (Exception e) {

        }
        return result;
    }
}
