
package com.xtd.project.activiti.event.listener;

import com.xtd.common.utils.SpringUtil;
import com.xtd.project.activiti.service.impl.LeaveNewServiceImpl;
import com.xtd.project.assets.domain.DbAssetsStock;
import com.xtd.project.assets.domain.DbAssetsStockOut;
import com.xtd.project.assets.mapper.DbAssetsStockMapper;
import com.xtd.project.assets.mapper.DbAssetsStockOutMapper;
import org.activiti.engine.TaskService;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.ExecutionListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class OutRejectListener  implements ExecutionListener {
    protected final Logger logger = LoggerFactory.getLogger(LeaveNewServiceImpl.class);

    @Autowired
    private TaskService taskService;

    @Override
    public void notify(DelegateExecution delegateExecution) {
        String id = delegateExecution.getId();
        DbAssetsStockOut formData = (DbAssetsStockOut)delegateExecution.getVariable("formData");
        //获取到库存id
        Long dbAsStId = formData.getDbAsStId();
//        DbAssetsStockMapper dbAssetsStockMapper = SpringUtil.getBean(DbAssetsStockMapper.class);
//        DbAssetsStock dbAssetsStock = new DbAssetsStock();
//        dbAssetsStock.setaId(dbAsStId);
//        //设置为解除锁定
//        dbAssetsStock.setLocked(0);
//        dbAssetsStockMapper.updateDbAssetsStock(dbAssetsStock);
        logger.info("更新库存信息");
        DbAssetsStockOutMapper dbAssetsStockOutMapper = SpringUtil.getBean(DbAssetsStockOutMapper.class);
        //设置为审核通过
        formData.setState(1);
        dbAssetsStockOutMapper.updateDbAssetsStockOut(formData);
        logger.info("更新出库状态");
    }

}

