package com.zkqy.execution.produce.dispersed.service.impl.runbpm.nuts;

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.entity.runbpm.IRunBPMEntity;
import com.zkqy.execution.produce.dispersed.service.IRunBPMService;
import com.zkqy.execution.produce.utils.EchoNodeFormData;
import com.zkqy.system.entity.CommonEntity;
import com.zkqy.system.mapper.CommonMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import javax.annotation.PreDestroy;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @author hanzihang
 * <p>
 * 库房人员选择仓库位置区域进行入库操作
 * @date 2023/12/1
 */
@Service("d4b4fa0b-f998-4298-a3ef-adaa8a8152ee")
@Scope("prototype")
public class WarehousingImpl implements IRunBPMService {

    @Resource
    private EchoNodeFormData echoNodeFormData;
    
    @Resource
    private CommonMapper commonMapper;

    @Override
    public CommonEntity getNodeFormData(BpmRunNodeFromVo bpmRunNodeFromVo) {
        HashMap hashMap=new HashMap();
        hashMap.put("id", bpmRunNodeFromVo.getTaskPlanKey());
        CommonEntity commonEntity = commonMapper.selectOne("plan", hashMap);
        String goodsno = commonEntity.getResultMap().get("goodsno").toString();
        Map<String, Object> map2 = new HashMap<>();
        map2.put("del_flag", 0);
        map2.put("id",goodsno);
        BpmRunNodeFormFilterConditionsVo bpmRunNodeFormFilterConditionsVo2 = new BpmRunNodeFormFilterConditionsVo();
        bpmRunNodeFormFilterConditionsVo2.setCondition(map2);
        bpmRunNodeFormFilterConditionsVo2.setNodeOnlyData(false);
        bpmRunNodeFormFilterConditionsVo2.setListKey("goods");
        bpmRunNodeFromVo.getFormDataVoList().add(bpmRunNodeFormFilterConditionsVo2);
        bpmRunNodeFormFilterConditionsVo2.setTableName("product");
        return echoNodeFormData.getEchoNodeFormData(bpmRunNodeFromVo);
    }


    @Override
    public AjaxResult preValidation(IRunBPMEntity iRunBPMEntity) {
        return AjaxResult.success();
    }

    @Override
    public AjaxResult executeNode(IRunBPMEntity iRunBPMEntity) {
        return AjaxResult.success();
    }

    @Override
    public AjaxResult afterValidation(IRunBPMEntity iRunBPMEntity) {
        return AjaxResult.success();
    }

    @Override
    public boolean isVerificationMethod() {
        return true;
    }

    @Override
    @PreDestroy
    public boolean preDestroy() {
        System.err.println("清理成功！");
        return true;
    }

}
