package com.prolog.rdc.tms.util;

import org.springframework.stereotype.Service;

import com.prolog.rdc.tms.constant.DataDictionaryConstant;

/**
 *
 *
 * 业务流程工具类
 *
 * @className :BusinessFlowUtil
 * @author :lhb
 * @creationTime :2022/06/22
 * @description :
 *
 * @modifier :lhb
 * @modifyTime :2022/06/22
 * @reviseRemarks:
 *
 * @version :1.0.0
 *
 */
@Service
public class BusinessFlowUtil {

	// 判定下一步流程,取状态
	public int judgmentNextFlowSts(String flowConfig, String currentSts) {
		int nextSts = 0;

		// 当前是审核
		if (DataDictionaryConstant.FLOW_CONFIG_REVIEW.equals(currentSts)) {
			if (flowConfig.contains(DataDictionaryConstant.FLOW_CONFIG_TRANSPORT_PLAN)) {
				// 下一步是待排计划单作成
				nextSts = DataDictionaryConstant.SHIPBILL_STATUS_PENDING_PLAN;
			} else {
				// 下一步是待调度
				nextSts = DataDictionaryConstant.SHIPBILL_STATUS_REVIEW;
			}
		}

		// 当前是调度审核
		if (DataDictionaryConstant.FLOW_CONFIG_CHECK.equals(currentSts)) {
			if (flowConfig.contains(DataDictionaryConstant.FLOW_CONFIG_APPOINTMENT)) {
				// 下一步是待预约
				nextSts = DataDictionaryConstant.SHIPBILL_STATUS_PENDING_APP;
			} else if (flowConfig.contains(DataDictionaryConstant.FLOW_CONFIG_ARRANGE_GOODS)) {
				// 下一步是待理货开始
				nextSts = DataDictionaryConstant.SHIPBILL_STATUS_LH_START;
			} else if (flowConfig.contains(DataDictionaryConstant.FLOW_CONFIG_LOAD_UNLOAD)) {
				// 下一步是待装卸开始
				nextSts = DataDictionaryConstant.SHIPBILL_STATUS_ZX_START;
			} else if (flowConfig.contains(DataDictionaryConstant.FLOW_CONFIG_SCANNING)) {
				// 下一步是待装车扫描
				nextSts = DataDictionaryConstant.SHIPBILL_STATUS_ZC_SCAN;
			} else {
				// 下一步是待提货
				nextSts = DataDictionaryConstant.SHIPBILL_STATUS_QY;
			}
		}

		// 当前是预约
		if (DataDictionaryConstant.FLOW_CONFIG_APPOINTMENT.equals(currentSts)) {
			if (flowConfig.contains(DataDictionaryConstant.FLOW_CONFIG_ARRANGE_GOODS)) {
				// 下一步是待理货开始
				nextSts = DataDictionaryConstant.SHIPBILL_STATUS_LH_START;
			} else if (flowConfig.contains(DataDictionaryConstant.FLOW_CONFIG_LOAD_UNLOAD)) {
				// 下一步是待装卸开始
				nextSts = DataDictionaryConstant.SHIPBILL_STATUS_ZX_START;
			} else if (flowConfig.contains(DataDictionaryConstant.FLOW_CONFIG_SCANNING)) {
				// 下一步是待装车扫描
				nextSts = DataDictionaryConstant.SHIPBILL_STATUS_ZC_SCAN;
			} else if (flowConfig.contains(DataDictionaryConstant.FLOW_CONFIG_SEND_OFF)){
				// 下一步是待提货
				nextSts = DataDictionaryConstant.SHIPBILL_STATUS_QY;
			} else if (flowConfig.contains(DataDictionaryConstant.FLOW_CONFIG_SELF_PICKUP_CONFIRM)){
				// 下一步是自提确认
				nextSts = DataDictionaryConstant.SHIPBILL_STATUS_HD_ZT;
			}
		}

		// 当前是理货
		if (DataDictionaryConstant.FLOW_CONFIG_ARRANGE_GOODS.equals(currentSts)) {
			if (flowConfig.contains(DataDictionaryConstant.FLOW_CONFIG_LOAD_UNLOAD)) {
				// 下一步是待装卸开始
				nextSts = DataDictionaryConstant.SHIPBILL_STATUS_ZX_START;
			} else if (flowConfig.contains(DataDictionaryConstant.FLOW_CONFIG_SCANNING)) {
				// 下一步是待装车扫描
				nextSts = DataDictionaryConstant.SHIPBILL_STATUS_ZC_SCAN;
			} else if (flowConfig.contains(DataDictionaryConstant.FLOW_CONFIG_SEND_OFF)){
				// 下一步是待提货
				nextSts = DataDictionaryConstant.SHIPBILL_STATUS_QY;
			} else if (flowConfig.contains(DataDictionaryConstant.FLOW_CONFIG_SELF_PICKUP_CONFIRM)){
				// 下一步是自提确认
				nextSts = DataDictionaryConstant.SHIPBILL_STATUS_HD_ZT;
			}
		}

		// 当前是装卸
		if (DataDictionaryConstant.FLOW_CONFIG_LOAD_UNLOAD.equals(currentSts)) {
			if (flowConfig.contains(DataDictionaryConstant.FLOW_CONFIG_SEND_OFF)){
				// 下一步是待提货
				nextSts = DataDictionaryConstant.SHIPBILL_STATUS_QY;
			} else if (flowConfig.contains(DataDictionaryConstant.FLOW_CONFIG_SELF_PICKUP_CONFIRM)){
				// 下一步是自提确认
				nextSts = DataDictionaryConstant.SHIPBILL_STATUS_HD_ZT;
			}
		}

		// 当前是装车扫描
		if (DataDictionaryConstant.FLOW_CONFIG_SCANNING.equals(currentSts)) {
			if (flowConfig.contains(DataDictionaryConstant.FLOW_CONFIG_LOAD_UNLOAD)) {
				// 下一步是待装卸开始
				nextSts = DataDictionaryConstant.SHIPBILL_STATUS_ZX_FINISH;
			} else if (flowConfig.contains(DataDictionaryConstant.FLOW_CONFIG_SEND_OFF)){
				// 下一步是待提货
				nextSts = DataDictionaryConstant.SHIPBILL_STATUS_QY;
			} else if (flowConfig.contains(DataDictionaryConstant.FLOW_CONFIG_SELF_PICKUP_CONFIRM)){
				// 下一步是自提确认
				nextSts = DataDictionaryConstant.SHIPBILL_STATUS_HD_ZT;
			}
		}

		// 当前是自提车俩登记
		if (DataDictionaryConstant.FLOW_CONFIG_SELF_PICKUP_VEH_REG.equals(currentSts)) {
			if (flowConfig.contains(DataDictionaryConstant.FLOW_CONFIG_APPOINTMENT)) {
				// 下一步是待预约
				nextSts = DataDictionaryConstant.SHIPBILL_STATUS_PENDING_APP;
			} else if (flowConfig.contains(DataDictionaryConstant.FLOW_CONFIG_ARRANGE_GOODS)) {
				// 下一步是待理货开始
				nextSts = DataDictionaryConstant.SHIPBILL_STATUS_LH_START;
			} else if (flowConfig.contains(DataDictionaryConstant.FLOW_CONFIG_LOAD_UNLOAD)) {
				// 下一步是待装卸开始
				nextSts = DataDictionaryConstant.SHIPBILL_STATUS_ZX_START;
			} else if (flowConfig.contains(DataDictionaryConstant.FLOW_CONFIG_SCANNING)) {
				// 下一步是待装车扫描
				nextSts = DataDictionaryConstant.SHIPBILL_STATUS_ZC_SCAN;
			} else if (flowConfig.contains(DataDictionaryConstant.FLOW_CONFIG_SELF_PICKUP_CONFIRM)) {
				// 下一步是自提确认
				nextSts = DataDictionaryConstant.SHIPBILL_STATUS_HD_ZT;
			}
		}

		return nextSts;
	}
}
