package com.iformall.flowable;

import com.iformall.enums.EnumRentContractAppStatus;
import com.iformall.service.WxFlowService;
import com.iformall.service.WxPropertyContractService;
import com.iformall.service.impl.WxFlowServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.flowable.engine.delegate.TaskListener;
import org.flowable.task.service.delegate.DelegateTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;

/**
 * 合同审批完成，修改状态
 *
 */
@Component(value="contractTaskFinishListener")
public class ContractTaskFinishHandler implements TaskListener {
    @Autowired
    private WxFlowService wxFlowService;
    @Autowired
    private WxPropertyContractService wxPropertyContractService;

    @Override
    public void notify(DelegateTask delegateTask) {
//        Long businessId = (Long)delegateTask.getVariable("businessId");
//        List<Map<String,String>> variables = (List)delegateTask.getVariable("variables");
//        Integer flowType = (Integer)delegateTask.getVariable("flowType");
//
//        Integer contractType = 0;
//        String str = WxFlowServiceImpl.getVariableByKey(variables,"contractType");
//        if(StringUtils.isNotBlank(str)){
//            contractType = Integer.parseInt(str);
//
//            if(3==contractType){
//                wxPropertyContractService.updatePropertyContractStatus(businessId);
//            }
//        }
//        wxFlowService.updateBusinessStatus(businessId,flowType,contractType,EnumRentContractAppStatus.FINISH.getCode());
    }

}
