package com.zkqy.web.controller.test;

import com.zkqy.common.core.domain.AjaxResult;
import com.zkqy.execution.produce.dispersed.entity.runbpm.BpmRunNodeFormFilterConditionsVo;
import com.zkqy.execution.produce.dispersed.entity.runbpm.BpmRunNodeFromVo;
import com.zkqy.execution.produce.dispersed.service.IBpmExecuteNodeFormService;
import com.zkqy.execution.produce.utils.EchoNodeFormData;
import com.zkqy.system.entity.CommonEntity;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

/**
 * @author hanzihang
 * @date 2023/12/8 5:15 PM
 */
@RestController
@RequestMapping("/system/test")
public class TestController {
    @Autowired
    private IBpmExecuteNodeFormService iBpmExecuteNodeFormService;
    @Autowired
    private ApplicationContext applicationContext;

    @Autowired
    EchoNodeFormData echoNodeFormData;


    @GetMapping("/testController")
    public AjaxResult testcontr(String processKey) {
        Object bean1 = applicationContext.getBean("11f4951b-682f-4185-acb7-f4b8db9d5940");
        try {
            applicationContext.getBean("qwe");

        } catch (NoSuchBeanDefinitionException e) {
            return AjaxResult.error();

        }


        System.err.println(bean1);
        Object sd = iBpmExecuteNodeFormService.selectNodeFromInfos(processKey);
        return AjaxResult.success(sd);
    }


    @GetMapping("/api")
    public CommonEntity common() {
        Map<String, Object> map = new HashMap<>();
        map.put("del_flag", 0);
        map.put("type", 2);
        map.put("id", 7);
        BpmRunNodeFromVo a = new BpmRunNodeFromVo();
        a.setTaskProcessKey("557ae1f460ca44b4bf59ee64eb7bdb7c");
        a.setTaskNodeKey("Event_2920d486-d344-4d10-bd37-13d3b785974b");
        a.getFormDataVoList()
                .add(new BpmRunNodeFormFilterConditionsVo("goods", map));
        a.getFormDataVoList().add(new BpmRunNodeFormFilterConditionsVo("bpm_process", map, "list"));
        return echoNodeFormData.getEchoNodeFormData(a);
    }

}
