package com.prolog.cs.biz.inbound.service.impl.strategy;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.prolog.framework.bz.core.util.ObjectUtils;
import com.prolog.framework.utils.ArrayUtils;
import com.prolog.upcloud.base.strategy.domain.common.MatchTypeEnum;
import com.prolog.upcloud.base.strategy.domain.core.SearchFactor;
import com.prolog.upcloud.base.strategy.domain.core.StrategyContext;

import java.math.BigDecimal;
import java.util.List;

public class WhAreaCategoryContext extends StrategyContext<String> {

	private RcvLineData rcvLineData;

	private List<String> targetAreaCategoryCodes; // 也可能是结论集合

	@Override
	public boolean completed() {
		return ObjectUtils.isNotEmpty(targetAreaCategoryCodes);
	}

	@Override
	public Object getMatchFieldValue(String fieldName) {
		if ("billType".equals(fieldName)) {
			return this.rcvLineData.billType;
		} else if ("storageStatus".equals(fieldName)) {
			return this.rcvLineData.storageStatus;
		} else if ("isCase".equals(fieldName)) {
			return this.rcvLineData.isCase;
		} else if ("qty".equals(fieldName)) {
			return this.rcvLineData.qty;
		} else if ("isPieceOrCase".equals(fieldName)) {
			return this.rcvLineData.isPieceOrCase;
		} else if ("isExpiry".equals(fieldName)) {
			return this.rcvLineData.isExpiry;
		} else if ("conclusion".equals(fieldName)) {
			return this.rcvLineData.conclusion;
		} else if ("dataSource".equals(fieldName)) {
			return this.rcvLineData.dataSource;
		} else if ("oddCaseQty".equals(fieldName)) {
			return this.rcvLineData.oddCaseQty;
		} else if ("oddPieceQty".equals(fieldName)) {
			return this.rcvLineData.oddPieceQty;
		} else if ("stockStatus".equals(fieldName)) {
			return this.rcvLineData.stockStatus;
		} else if ("isAgv".equals(fieldName)) {
			return this.rcvLineData.isAgv;
		} else if ("categoryId".equals(fieldName)) {
			return this.rcvLineData.categoryId;
		}

		return null;
	}

	/**
	 * 根据查询的因子查询结果
	 */
	@Override
	public List<String> search(List<SearchFactor> searchFactors) {
		// TODO Auto-generated method stub
		if (ObjectUtils.isNotEmpty(searchFactors)) {
			SearchFactor sf = searchFactors.get(0);
			String fieldName = sf.getFieldName();
			if (sf.getValue() != null) {
				String astr = (String) sf.getValue();
				targetAreaCategoryCodes = ArrayUtils.toList(astr.split(","));
				return targetAreaCategoryCodes;
			}
		}
		return null;
	}

	public RcvLineData getRcvLineData() {
		return rcvLineData;
	}

	public void setRcvLineData(RcvLineData rcvLineData) {
		this.rcvLineData = rcvLineData;
	}

	public List<String> getTargetAreaCategoryCodes() {
		return targetAreaCategoryCodes;
	}

	public void setTargetAreaCategoryCodes(List<String> targetAreaCategoryCodes) {
		this.targetAreaCategoryCodes = targetAreaCategoryCodes;
	}

	public class RcvLineData {
		/**
		 * 单据类型1 采购入库 2 销售退货 3 调拨入库 4 移库入库 5 调账入库 6 越库入库 7 直调入库 8 代管入库 9 待检入库 10 器械入库 11
		 * 赠品入库
		 */
		private String billType;
		/**
		 * 收货数是否0整/1全散/2整散
		 */
		private String isCase;
		/**
		 * 是否整散合一 true/false
		 */
		private Boolean isPieceOrCase;
		/**
		 * 库存状态(0合格/1不合格)
		 */
		private String storageStatus;
		/**
		 * 数量(包装)
		 */
		private Double qty;
		/**
		 * 是否过期
		 */
		private Boolean isExpiry;

		/**
		 * 结论(0合格/1不合格/2待处理/3拒绝）
		 */
		private String conclusion;
		/**
		 * 数据来源(0:收货1:质检2:复检)
		 */
		private String dataSource;
		/**
		 * 冷藏字段("常温""阴凉" "冷藏" "冷冻"))
		 */
		private String storeTemperature;

		/**
		 * 是否能入AGV库(0:否1:是)
		 */
		private String isAgv;

		private Double oddCaseQty;

		private Double oddPieceQty;

		/**
		 * 库存状态(0合格/1不合格)
		 */
		private String stockStatus;

		private String categoryId;

		public String getConclusion() {
			return conclusion;
		}

		public void setConclusion(String conclusion) {
			this.conclusion = conclusion;
		}

		public String getDataSource() {
			return dataSource;
		}

		public void setDataSource(String dataSource) {
			this.dataSource = dataSource;
		}

		public String getStoreTemperature() {
			return storeTemperature;
		}

		public void setStoreTemperature(String storeTemperature) {
			this.storeTemperature = storeTemperature;
		}

		public Boolean getIsExpiry() {
			return isExpiry;
		}

		public void setIsExpiry(Boolean isExpiry) {
			this.isExpiry = isExpiry;
		}

		public String getBillType() {
			return billType;
		}

		public void setBillType(String billType) {
			this.billType = billType;
		}

		public String getIsCase() {
			return isCase;
		}

		public void setIsCase(String isCase) {
			this.isCase = isCase;
		}

		public Boolean getIsPieceOrCase() {
			return isPieceOrCase;
		}

		public void setIsPieceOrCase(Boolean isPieceOrCase) {
			this.isPieceOrCase = isPieceOrCase;
		}

		public String getStorageStatus() {
			return storageStatus;
		}

		public void setStorageStatus(String storageStatus) {
			this.storageStatus = storageStatus;
		}

		public Double getQty() {
			return qty;
		}

		public void setQty(Double qty) {
			this.qty = qty;
		}

		public String getIsAgv() {
			return isAgv;
		}

		public void setIsAgv(String isAgv) {
			this.isAgv = isAgv;
		}

		public String getStockStatus() {
			return stockStatus;
		}

		public void setStockStatus(String stockStatus) {
			this.stockStatus = stockStatus;
		}

		public Double getOddCaseQty() {
			return oddCaseQty;
		}

		public void setOddCaseQty(Double oddCaseQty) {
			this.oddCaseQty = oddCaseQty;
		}

		public Double getOddPieceQty() {
			return oddPieceQty;
		}

		public void setOddPieceQty(Double oddPieceQty) {
			this.oddPieceQty = oddPieceQty;
		}

		public String getCategoryId() {
			return categoryId;
		}

		public void setCategoryId(String categoryId) {
			this.categoryId = categoryId;
		}
	}

}
