package com.gx.obe.evaluation.step.review.composite;

import java.math.BigDecimal;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import org.eclipse.nebula.widgets.grid.Grid;
import org.eclipse.nebula.widgets.grid.GridColumn;
import org.eclipse.nebula.widgets.grid.GridItem;
import org.eclipse.swt.SWT;
import org.eclipse.swt.core.MessageDialog;
import org.eclipse.swt.core.listener.MouseDragCompositeListener;
import org.eclipse.swt.core.widgets.EButton;
import org.eclipse.swt.core.widgets.ELabel;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;

import com.gx.obe.ColorConstants;
import com.gx.obe.action.bean.Action;
import com.gx.obe.business.enumeration.SupplierEnum;
import com.gx.obe.common.file.entity.BidFile;
import com.gx.obe.common.file.enumeration.FileConstants;
import com.gx.obe.common.file.utils.ParsingXmlUtils;
import com.gx.obe.common.icons.IconsActivator;
import com.gx.obe.common.widget.button.EvalLeftButton;
import com.gx.obe.components.core.Constants;
import com.gx.obe.components.core.I18NEnum;
import com.gx.obe.components.core.enumeration.CommonEnum;
import com.gx.obe.components.core.util.MoneyUtils;
import com.gx.obe.components.core.vo.BidPriceTable;
import com.gx.obe.components.core.vo.TableXML;
import com.gx.obe.components.core.vo.TableXML.Tr;
import com.gx.obe.components.core.vo.TableXML.Tr.Td;
import com.gx.obe.evaluation.step.dialog.EvaluationOpinionDialog;
import com.gx.obe.evaluation.step.listener.ExpertEvaluationListener;
import com.gx.obe.evaluation.step.shell.BidDocumentLoaderShell;
import com.gx.obe.evaluation.step.utils.ParsingBidPriceUtils;
import com.gx.obe.message.Messages;
import com.gx.obe.util.utils.BigDecimalUtils;
import com.gx.obe.util.utils.CollectionUtils;
import com.gx.obe.util.utils.ObjectUtils;
import com.gx.obe.util.utils.StringUtils;
import com.gx.obe.util.utils.UuidUtils;
import com.gx.obe.web.entity.Supplier;
import com.gx.obe.web.entity.SupplierEvaluationResult;
import com.gx.obe.web.entity.SupplierOpeningResult;
import com.gx.obe.web.entity.evaluation.EvaluationStep;
import com.gx.obe.web.entity.expert.Expert;
import com.gx.obe.web.entity.expert.ExpertEvaluationResult;
import com.gx.obe.web.entity.tender.TenderProjectEntity;
import com.gx.obe.web.entity.tender.TenderProjectRuleEntity;
import com.gx.obe.web.service.SupplierEvaluationResultService;
import com.gx.obe.web.service.SupplierOpeningResultService;
import com.gx.obe.web.service.SupplierService;
import com.gx.obe.web.service.evaluation.EvaluationStepService;
import com.gx.obe.web.service.expert.ExpertEvaluationResultService;
import com.gx.obe.web.service.expert.ExpertEvaluationStepService;
import com.gx.obe.web.service.expert.ExpertService;
import com.gx.utils.ActionLogUtils;
import com.swtdesigner.ResourceManager;
import com.swtdesigner.SWTResourceManager;

import de.kupzog.ktable.KTable;
import de.kupzog.ktable.KTableCellSelectionAdapter;
import de.kupzog.ktable.SWTX;
import de.kupzog.ktable.editors.KTableCellEditorGRadio;
import de.kupzog.ktable.editors.KTableCellEditorLink;
import de.kupzog.ktable.editors.KTableCellEditorMultilineWrapText;
import de.kupzog.ktable.editors.KTableCellEditorText;
import de.kupzog.ktable.model.CommonKtableCModel;
import de.kupzog.ktable.renderers.CellAlignmentRender;
import de.kupzog.ktable.renderers.CellBackgroundRender;
import de.kupzog.ktable.renderers.CellContentRender;
import de.kupzog.ktable.renderers.CellEditContentRender;
import de.kupzog.ktable.renderers.CellEditorRender;
import de.kupzog.ktable.renderers.CellEventActionRender;
import de.kupzog.ktable.renderers.CellForegroundRender;
import de.kupzog.ktable.renderers.CellImageRender;
import de.kupzog.ktable.renderers.CellRender;
import de.kupzog.ktable.renderers.FixedWrapCellRenderer;
import de.kupzog.ktable.renderers.LinkCellRenderer;
import de.kupzog.ktable.renderers.RowHeightRender;
import de.kupzog.ktable.renderers.TextWrapCellRenderer;

public class TotalPriceEvaluationComposite extends Composite {
	
	private String EVAL_ACCESSMENT_YES = Messages.Qualified;
	private String EVAL_ACCESSMENT_NO = Messages.Unqualified;
	private Composite left_tool_composite;
	private Composite composite;
	private Composite supplierComposite;
	private Composite bidPriceComposite;
	private Composite bidPriceTableComposite;
	private Composite subBidPriceComposite;
	private Composite subBidPriceTableComposite;
	private Composite button_composite;
	private KTable table;
	private Grid bidPriceGrid;
	private Grid subBidPriceGrid;
	private Label bidPriceTitleLabel;
	private EButton init_default_btn;
	private EButton save_result_btn;
	private EButton submit_result_btn;
	private BidDocumentLoaderShell documentLoaderShell;
	private ExpertEvaluationListener expertEvaluationListener;
	private EvaluationStepService evaluationStepService = new EvaluationStepService();
	private ExpertEvaluationStepService expertEvaluationStepService ;
	private ExpertEvaluationResultService expertEvaluationResultService;
	private SupplierOpeningResultService supplierOpeningResultService ;
	private SupplierEvaluationResultService supplierEvaluationResultService ;
	private SupplierService supplierService = new SupplierService();
	private ExpertService expertService;
	private TenderProjectEntity tenderProjectEntity;
	private EvaluationStep evaluationStep;
	private TenderProjectRuleEntity tenderProjectRuleEntity;
	private Expert CURRENT_EXPERT;
	private Object hideLeft;
	private String supplierName;
	private List<Supplier> supplierList;
	private Supplier curSupplier;
	private Map<String, ExpertEvaluationResult> expertEvaluationResultMap;
	private Map<String, BigDecimal> totalPriceMap;
	private ExecutorService executorService;
	private boolean isAllowEditPrice;
	private EvaluationStep noComplateFilterStep = null;
	
	/**
	 * Create the composite.
	 * 
	 * @param parent
	 * @param style
	 */
	public TotalPriceEvaluationComposite(Composite parent,Action action, int style) {
		super(parent, style);
		addDisposeListener(new DisposeListener() {
			public void widgetDisposed(DisposeEvent e) {
				if (null != executorService) {
					executorService.shutdownNow();
				}
				if (null != documentLoaderShell && !documentLoaderShell.isDisposed()) {
					documentLoaderShell.dispose();
				}
			}
		});
		
		this.tenderProjectEntity = action.getTenderProject();
		this.evaluationStep = (EvaluationStep) parent.getData("evaluationStep");
		this.tenderProjectRuleEntity = null == action.getTenderProjectRule() ? new TenderProjectRuleEntity() : action.getTenderProjectRule();
		this.hideLeft = parent.getData("hideLeft");
		
		setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		setBackgroundMode(SWT.INHERIT_FORCE);
		
		GridLayout gridLayout = new GridLayout(2, false);
		gridLayout.verticalSpacing = 0;
		gridLayout.horizontalSpacing = 0;
		gridLayout.marginHeight = 0;
		gridLayout.marginWidth = 0;
		setLayout(gridLayout);
		
		left_tool_composite = new Composite(this, SWT.NONE);
		left_tool_composite.setBackground(EvalLeftButton.BG);
		left_tool_composite.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, true, 1, 1));
		GridLayout gl_left_tool_composite = new GridLayout(1, false);
		left_tool_composite.setLayout(gl_left_tool_composite);
		
		EvalLeftButton goto_back = new EvalLeftButton(left_tool_composite, SWT.SELECTED);
		goto_back.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
		goto_back.setImage(ResourceManager.getPluginImage("com.gx.obe.evaluation", "icons/back.png"));
		goto_back.setToolTipText(Messages.Button_return);
		goto_back.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				goBackAction();
			}
		});
		
		EvalLeftButton refresh_evaluation = new EvalLeftButton(left_tool_composite, SWT.SELECTED);
		refresh_evaluation.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
		refresh_evaluation.setImage(ResourceManager.getPluginImage("com.gx.obe.evaluation", "icons/refresh.png"));
		refresh_evaluation.setToolTipText(Messages.Button_refresh);
		refresh_evaluation.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				refreshTenderInfo();
			}
		});
		
		Composite right_composite = new Composite(this, SWT.NONE);
		right_composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		GridLayout gl_right_composite = new GridLayout(1, false);
		gl_right_composite.verticalSpacing = 0;
		gl_right_composite.marginHeight = 0;
		gl_right_composite.marginWidth = 0;
		gl_right_composite.horizontalSpacing = 0;
		right_composite.setLayout(gl_right_composite);
		
		Composite composite_1 = new Composite(right_composite, SWT.NONE);
		composite_1.setBackground(ColorConstants.BORDER_LINE_COLOR);
		composite_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		GridLayout gl_composite_1 = new GridLayout(1, false);
		gl_composite_1.marginHeight = 1;
		gl_composite_1.marginWidth = 1;
		composite_1.setLayout(gl_composite_1);
		
		composite = new Composite(composite_1, SWT.NONE);
		composite.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		composite.setLayout(new FormLayout());
		composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		
		subBidPriceComposite = new Composite(composite, SWT.NONE);
		FormData fd_subBidPriceComposite = new FormData();
		fd_subBidPriceComposite.bottom = new FormAttachment(50);
		fd_subBidPriceComposite.right = new FormAttachment(90);
		fd_subBidPriceComposite.top = new FormAttachment(0);
		fd_subBidPriceComposite.left = new FormAttachment(30);
		subBidPriceComposite.setLayoutData(fd_subBidPriceComposite);
		subBidPriceComposite.setBackground(ColorConstants.SKIN_BG);
		GridLayout gl_subBidPriceComposite = new GridLayout(1, false);
		gl_subBidPriceComposite.verticalSpacing = 1;
		gl_subBidPriceComposite.marginHeight = 1;
		gl_subBidPriceComposite.marginWidth = 1;
		subBidPriceComposite.setLayout(gl_subBidPriceComposite);
		
		Composite bidPriceTitleComposite = new Composite(subBidPriceComposite, SWT.NONE);
		GridLayout gl_bidPriceTitleComposite = new GridLayout(2, false);
		gl_bidPriceTitleComposite.marginHeight = 0;
		bidPriceTitleComposite.setLayout(gl_bidPriceTitleComposite);
		bidPriceTitleComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		
		bidPriceTitleLabel = new Label(bidPriceTitleComposite, SWT.NONE);
		bidPriceTitleLabel.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		bidPriceTitleLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		
		ELabel close_btn = new ELabel(bidPriceTitleComposite, SWT.NONE | SWT.SELECTED);
		close_btn.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/close.png"));
		close_btn.setMargins(5, 5, 5, 5);
		close_btn.setActiveColor(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		close_btn.setAlpha(10);
		close_btn.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				closeAction();
			}
		});
		
		subBidPriceTableComposite = new Composite(subBidPriceComposite, SWT.NONE);
		subBidPriceTableComposite.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		GridLayout gl_subBidPriceTableComposite = new GridLayout(1, false);
		gl_subBidPriceTableComposite.marginHeight = 0;
		gl_subBidPriceTableComposite.marginWidth = 0;
		subBidPriceTableComposite.setLayout(gl_subBidPriceTableComposite);
		subBidPriceTableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		
		bidPriceComposite = new Composite(composite, SWT.NONE);
		FormData fd_bidPriceComposite = new FormData();
		fd_bidPriceComposite.bottom = new FormAttachment(100);
		fd_bidPriceComposite.right = new FormAttachment(100);
		fd_bidPriceComposite.top = new FormAttachment(0);
		fd_bidPriceComposite.left = new FormAttachment(0);
		bidPriceComposite.setLayoutData(fd_bidPriceComposite);
		GridLayout gl_bidPriceComposite = new GridLayout(1, true);
		gl_bidPriceComposite.verticalSpacing = 0;
		gl_bidPriceComposite.horizontalSpacing = 0;
		gl_bidPriceComposite.marginHeight = 0;
		gl_bidPriceComposite.marginWidth = 0;
		bidPriceComposite.setLayout(gl_bidPriceComposite);
		
		supplierComposite = new Composite(bidPriceComposite, SWT.NONE);
		GridLayout gl_supplierComposite = new GridLayout(1, false);
		gl_supplierComposite.marginHeight = 0;
		gl_supplierComposite.marginWidth = 0;
		supplierComposite.setLayout(gl_supplierComposite);
		GridData gd_supplierComposite = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
		gd_supplierComposite.heightHint = 300;
		supplierComposite.setLayoutData(gd_supplierComposite);
		
		bidPriceTableComposite = new Composite(bidPriceComposite, SWT.NONE);
		GridData gd_bidPriceTableComposite = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
		gd_bidPriceTableComposite.heightHint = 300;
		bidPriceTableComposite.setLayoutData(gd_bidPriceTableComposite);
		GridLayout gl_bidPriceTableComposite = new GridLayout(1, false);
		gl_bidPriceTableComposite.marginHeight = 0;
		gl_bidPriceTableComposite.marginWidth = 0;
		bidPriceTableComposite.setLayout(gl_bidPriceTableComposite);
		
		button_composite = new Composite(right_composite, SWT.NONE);
		button_composite.setLayout(new GridLayout(3, false));
		button_composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		
		init_default_btn = new EButton(button_composite, SWT.NONE | EButton.CSS_BLUE);
		init_default_btn.setFont(SWTResourceManager.getFont("微软雅黑", 10, SWT.BOLD));
		init_default_btn.setText(Messages.Button_quickEvaluation);
		init_default_btn.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/white/select_all.png"));
		GridData gd_init_default_btn = new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1);
		gd_init_default_btn.widthHint = 200;
		gd_init_default_btn.heightHint = 35;
		init_default_btn.setLayoutData(gd_init_default_btn);
		init_default_btn.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				initDefaultAction();
			}
		});
		
		save_result_btn = new EButton(button_composite, SWT.NONE | EButton.CSS_GREEN);
		save_result_btn.setFont(SWTResourceManager.getFont("微软雅黑", 10, SWT.BOLD));
		save_result_btn.setText(Messages.Button_saveEvaluationResult);
		save_result_btn.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/white/save.png"));
		GridData gd_save_result_btn = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
		gd_save_result_btn.widthHint = 200;
		gd_save_result_btn.heightHint = 35;
		save_result_btn.setLayoutData(gd_save_result_btn);
		save_result_btn.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				saveEvaluationResultAction();
			}
		});
		
		submit_result_btn = new EButton(button_composite, SWT.NONE | EButton.CSS_GREEN);
		submit_result_btn.setFont(SWTResourceManager.getFont("微软雅黑", 10, SWT.BOLD));
		submit_result_btn.setText(Messages.Button_submitEvaluationResult);
		submit_result_btn.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/white/submit.png"));
		GridData gd_submit_result_btn = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1);
		gd_submit_result_btn.widthHint = 200;
		gd_submit_result_btn.heightHint = 35;
		submit_result_btn.setLayoutData(gd_submit_result_btn);
		submit_result_btn.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				submitEvaluationResultAction();
			}
		});
		
		init();
	}
	
	/**
	 * @Description: 初始化界面数据
	 * @author chenxw
	 */
	private void init() {
		expertEvaluationResultService = new ExpertEvaluationResultService();
		expertEvaluationStepService = new ExpertEvaluationStepService();
		supplierOpeningResultService = new SupplierOpeningResultService();
		expertService = new ExpertService();
		if (null != hideLeft) {
			left_tool_composite.dispose();
		}
		CURRENT_EXPERT = expertService.getEvaluationStepExpert(tenderProjectEntity.getId(), evaluationStep);
		MouseDragCompositeListener mouseDragListener = new MouseDragCompositeListener(subBidPriceComposite);
		bidPriceTitleLabel.addListener(SWT.MouseUp, mouseDragListener);
		bidPriceTitleLabel.addListener(SWT.MouseMove, mouseDragListener);
		bidPriceTitleLabel.addListener(SWT.MouseDown, mouseDragListener);
		
		// 修改状态为正在进行中
		ActionLogUtils.addServerLog(tenderProjectEntity.getId(), "进入" + evaluationStep.getStepName(), Constants.USER.getUserName());
		expertEvaluationStepService.updateExpertEvaluationStatus(CommonEnum.IN_PROGRESS, tenderProjectEntity.getId(), evaluationStep, CURRENT_EXPERT.getUserId());
		
		supplierName = com.gx.obe.components.core.I18N.getString(I18NEnum.SUPPLIERNAME, tenderProjectEntity.getTenderType());
		
		isAllowEditPrice = evaluationStep.getEvaluationParamByKey(com.gx.obe.components.core.enumeration.EvaluationStepEnum.ALLOW_EDIT_PRICE, Boolean.class);
		
		expertEvaluationResultMap = new HashMap<String, ExpertEvaluationResult>();
		totalPriceMap = new HashMap<String, BigDecimal>();
		
		refreshTenderInfo();
	}
	
	/**
	 * @Description: 获取供应商列表
	 * @author chenxw
	 * @return 
	 */
	private void refreshSupplierList(){
		supplierList = supplierService.getEvaluationStepSupplierList(tenderProjectEntity.getId(), evaluationStep);
		if (null == supplierList) {
			supplierList = new ArrayList<Supplier>();
		}
		// 则获取开标成功的投标人
		List<SupplierOpeningResult> supplierOpeningResultList = supplierOpeningResultService.getSupplierOpeningResultListByTenderIdAndBidOpeningStatus(tenderProjectEntity.getId(),  SupplierEnum.OPENBID_SUCCESS);
		
		for(final Supplier supplier : supplierList){
			SupplierOpeningResult supplierOpeningResult = CollectionUtils.get(supplierOpeningResultList, t -> {
				return ObjectUtils.equals(t.getSupplierId(), supplier.getId());
			});
			if(null == supplierOpeningResult){
				supplierOpeningResult = new SupplierOpeningResult();
				supplierOpeningResult.setTenderId(tenderProjectEntity.getId());
				supplierOpeningResult.setSupplierId(supplier.getId());
			}
			supplier.setSupplierOpeningResult(supplierOpeningResult);
		}
	}
	
	/**
	 * @Description: 刷新项目信息
	 * @author chenxw
	 */
	private void refreshTenderInfo() {
		getNoComplateFilterStep();
		refreshSupplierList();
		initEvaluationResult();
		showAllSupplierList();
		refreshTotalPrice();
	}
	
	/**
	 * @Description: 初始化评审结果
	 * @author chenxw 
	 */
	private void initEvaluationResult() {
		if(null == supplierEvaluationResultService){
			supplierEvaluationResultService = new SupplierEvaluationResultService();
		}
		List<SupplierEvaluationResult> supplierEvaluationResultList = supplierEvaluationResultService.getSupplierEvaluationResultListByTenderId(tenderProjectEntity.getId());
		List<ExpertEvaluationResult> resultList = expertEvaluationResultService.getExpertStepAllSupplierEvaluationResultList(tenderProjectEntity.getId(), evaluationStep.getId(), CURRENT_EXPERT.getUserId());
		for (final Supplier supplier : supplierList) {
			SupplierEvaluationResult supplierEvaluationResult = CollectionUtils.get(supplierEvaluationResultList, t -> {
				return ObjectUtils.equals(t.getSupplierId(), supplier.getId());
			});
			if (null == supplierEvaluationResult) {
				supplierEvaluationResult = new SupplierEvaluationResult();
				supplierEvaluationResult.setTenderId(tenderProjectEntity.getId());
				supplierEvaluationResult.setSupplierId(supplier.getId());
			}
			supplier.setSupplierEvaluationResult(supplierEvaluationResult);
			// 获取评标专家对投标人的评审记录
			ExpertEvaluationResult expertEvaluationResult = CollectionUtils.get(resultList, t -> {
				return ObjectUtils.equals(t.getSupplierId(), supplier.getId());
			});
			if (null == expertEvaluationResult) {
				expertEvaluationResult = new ExpertEvaluationResult();
				expertEvaluationResult.setId(UuidUtils.getUUID()		);
				expertEvaluationResult.setTenderId(tenderProjectEntity.getId());
				expertEvaluationResult.setStepId(evaluationStep.getId());
				expertEvaluationResult.setUserId(CURRENT_EXPERT.getUserId());
				expertEvaluationResult.setSupplierId(supplier.getId());
			}
			expertEvaluationResultMap.put(supplier.getId(), expertEvaluationResult);
		}
	}
	
	/**
	 * @Description: 显示供应商列表
	 * @author chenxw 
	 */
	private void showAllSupplierList() {
		if (null != table && !table.isDisposed()) {
			table.dispose();
		}
		
		table = new KTable(supplierComposite, SWTX.AUTO_SCROLL | SWT.FULL_SELECTION | SWTX.FILL_WITH_LASTCOL | SWTX.EDIT_ON_KEY);
		table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		table.addCellSelectionListener(new KTableCellSelectionAdapter() {
			public void cellSelected(int col, int row, int statemask) {
				if (row != 0) {
					int supplierIndex = row - 1;
					curSupplier = supplierList.get(supplierIndex);
					selectionSupplierAction();
				}
			}
		});
		
		final CommonKtableCModel tableCModel = new CommonKtableCModel(table, 1, 0, supplierList.size(), 6);
		table.setModel(tableCModel);
		table.setSelection(1, 1, true);
		
		//设置行高
		tableCModel.setRowHeightRender(new RowHeightRender() {
			public int receiveRowHeight(int row) {
				return Constants.ROW_HIGHT;
			}
		});
		
		final int indexCol = 0;
		final int supplierNameCol = 1;
		final int bidPriceCol = 2;
		final int totalPriceCol = 3;
		final int isAccessmentCol = 4;
		final int evaluationOpinionCol = -1;
		final int seeBidFileCol = 5;
		
		//设置列宽
		tableCModel.setColumnWidth(indexCol, 10);
		tableCModel.setColumnMaxWidth(indexCol, 80);
		tableCModel.setColumnWidth(supplierNameCol, 300);
		tableCModel.setColumnWidth(bidPriceCol, 150);
		tableCModel.setColumnWidth(totalPriceCol, 150);
		tableCModel.setColumnWidth(isAccessmentCol, 80);
//		tableCModel.setColumnWidth(evaluationOpinionCol, 300);
		tableCModel.setColumnWidth(seeBidFileCol, 80);
		
		//设置单元格内容
		tableCModel.setCellContentRender(new CellContentRender() {
			public Object receiveContent(int row, int col) {
				if (row == 0) {
					switch (col) {
						case indexCol: return Messages.Num;
						case supplierNameCol: return supplierName;
						case bidPriceCol: return Messages.BidPrice;
						case totalPriceCol: return "合量报价";
						case isAccessmentCol: return "评审结论";
//						case evaluationOpinionCol: return Messages.Title_evaluationOpinion;
						case seeBidFileCol: return "操作";
					}
				} else {
					int supplierIndex = row - 1;
					Supplier supplier = supplierList.get(supplierIndex);
					SupplierOpeningResult supplierOpeningResult = supplier.getSupplierOpeningResult();
					switch (col) {
						case indexCol: return row;
						case supplierNameCol: return supplier.getSupplierName();
						case bidPriceCol:
							if (null == supplierOpeningResult) {
								return "";
							}
							return supplierOpeningResult.getBidPriceWithUnit(tenderProjectRuleEntity.getPriceUnitUseDefault());
						case totalPriceCol: 
							if (totalPriceMap.containsKey(supplier.getId())) {
								String priceUintCN = tenderProjectRuleEntity.getPriceUnitUseDefault();
								if (null != supplierOpeningResult) {
									priceUintCN = supplierOpeningResult.getPriceUnitCN(tenderProjectRuleEntity.getPriceUnitUseDefault());
								}
								return MoneyUtils.getMoneyFormatByUnit(totalPriceMap.get(supplier.getId()), priceUintCN).concat(priceUintCN);
							}
							return "";
						case isAccessmentCol:
							String accessment = expertEvaluationResultMap.get(supplier.getId()).getAccessment();
							if (null != accessment) {
								if (accessment.equals(com.gx.obe.components.core.enumeration.EvaluationStepEnum.QUALIFIED)) {
									return EVAL_ACCESSMENT_YES;
								} else if (accessment.equals(com.gx.obe.components.core.enumeration.EvaluationStepEnum.UNQUALIFIED)) {
									return EVAL_ACCESSMENT_NO;
								}
							}
							return "";
						case evaluationOpinionCol:
							String supplierOpinion = expertEvaluationResultMap.get(supplier.getId()).getSupplierOpinion();
							if (null == supplierOpinion) {
								return "";
							}
							return supplierOpinion;
						case seeBidFileCol: return "查看标书";
					}
				}
				return "";
			}
		});
		
		// 设置单元格渲染器
		final FixedWrapCellRenderer fixedWrapCellRenderer = new FixedWrapCellRenderer();
		final TextWrapCellRenderer textWrapCellRenderer = new TextWrapCellRenderer();
		final LinkCellRenderer linkCellRenderer = new LinkCellRenderer();
		tableCModel.setCellRender(new CellRender() {
			public Object receiveCellRender(int row, int col) {
				if (tableCModel.isFixedCell(col, row)) {
					fixedWrapCellRenderer.setFont(SWTResourceManager.getFont("微软雅黑", 9, SWT.NORMAL));
					return fixedWrapCellRenderer;
				}
				if (col == seeBidFileCol) {
					return linkCellRenderer;
				}
				textWrapCellRenderer.setFont(SWTResourceManager.getFont("微软雅黑", 9, SWT.NORMAL));
				return textWrapCellRenderer;
			}
		});
		
		// 设置单元格编辑器
		final KTableCellEditorText text = new KTableCellEditorText();
		text.setSingleClickEdit(true);
		final KTableCellEditorGRadio radio = new KTableCellEditorGRadio();
		radio.setSingleClickEdit(true);
		radio.addItem(EVAL_ACCESSMENT_YES);
		radio.addItem(EVAL_ACCESSMENT_NO);
		final KTableCellEditorMultilineWrapText cellEditorText = new KTableCellEditorMultilineWrapText();
		cellEditorText.setTextLimit(500);
		cellEditorText.setSingleClickEdit(true);
		tableCModel.setCellEditorRender(new CellEditorRender() {
			public Object receiveCellEditor(int row, int col) {
				if (row > 0) {
					switch (col) {
						case bidPriceCol: 
							if (isAllowEditPrice) {
								return text;
							} else {
								return null;
							}
						case isAccessmentCol:
							radio.setItem(0, EVAL_ACCESSMENT_YES, com.gx.obe.components.core.enumeration.EvaluationStepEnum.QUALIFIED);
							radio.setItem(1, EVAL_ACCESSMENT_NO, com.gx.obe.components.core.enumeration.EvaluationStepEnum.UNQUALIFIED);
							return radio;
						case evaluationOpinionCol: return cellEditorText;
						case seeBidFileCol: 
							return new KTableCellEditorLink(table, new CellEventActionRender(){
								public void receiveAction(int row, int col) {
									List<BidFile> fileList = BidFile.getBidPriceFileList(tenderProjectEntity.getId(), supplierList.get(row - 1).getId());
									if (null == documentLoaderShell || documentLoaderShell.isDisposed()) {
										documentLoaderShell = new BidDocumentLoaderShell(getShell());
										documentLoaderShell.setSize(900, 600);
										documentLoaderShell.open();
									}
									documentLoaderShell.refresh(fileList);
								}
							});
					}
				}
				return null;
			}
		});
		
		// 设置单元格图片
		final Image editImage = ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/blue/edit.png");
		final Image attachmentsImage = ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/blue/attachments.png");
		tableCModel.setCellImageRender(new CellImageRender() {
			public Image receiveCellImage(int row, int col) {
				if (row > 0) {
					switch (col) {
						case bidPriceCol: 
							if (isAllowEditPrice) {
								return editImage;
							} else {
								return null;
							}
						case evaluationOpinionCol:return editImage;
						case seeBidFileCol: return attachmentsImage;
					}
				}
				return null;
			}
		});
		
		// 编辑单元格内容
		tableCModel.setCellEditContentRender(new CellEditContentRender() {
			public void receiveContent(int row, int col, Object content) {
				if (null == content) return;
				if (row > 0) {
					int supplierIndex = row - 1;
					Supplier supplier = supplierList.get(supplierIndex);
					if (col == bidPriceCol) {
						SupplierOpeningResult supplierOpeningResult = supplier.getSupplierOpeningResult();
						
						String priceUnitCN = null;
						if (null != supplierOpeningResult) {
							priceUnitCN  = supplierOpeningResult.getPriceUnit();
						}
						if (null == priceUnitCN) {
							priceUnitCN = tenderProjectRuleEntity.getPriceUnitUseDefault();
						}
						BigDecimal bidPriceMoney = MoneyUtils.getMoneyFromText(MoneyUtils.extractDigits(content.toString()), priceUnitCN);
						supplierOpeningResult.setBidPrice(bidPriceMoney);
						supplierOpeningResult.setEvaluationPrice(bidPriceMoney);
					} else {
						ExpertEvaluationResult expertEvaluationResult = expertEvaluationResultMap.get(supplier.getId());
						if (null != expertEvaluationResult) {
							if (col == isAccessmentCol) {
								expertEvaluationResult.setAccessment(content.toString());
								if(com.gx.obe.components.core.enumeration.EvaluationStepEnum.UNQUALIFIED.equals(content.toString())){
									expertEvaluationResult.setAccessment(com.gx.obe.components.core.enumeration.EvaluationStepEnum.UNQUALIFIED);
									EvaluationOpinionDialog dialog = new EvaluationOpinionDialog(getShell(), tenderProjectEntity, supplier, Constants.USER, expertEvaluationResult);
									dialog.open();
								}else {
									expertEvaluationResult.setSupplierOpinion(null);
								}
							} else if (col == evaluationOpinionCol) {
//								expertEvaluationResult.setSupplierOpinion(content.toString());
							}
						}
					}
				}
			}
		});
		
		// 编辑单元格对齐方式
		tableCModel.setCellAlignmentRender(new CellAlignmentRender() {
			public int receiveCellAlignment(int row, int col) {
				if (row > 0) {
					switch (col) {
						case supplierNameCol: return SWTX.ALIGN_VERTICAL_CENTER | SWTX.ALIGN_HORIZONTAL_LEFT;
						case bidPriceCol: return SWTX.ALIGN_VERTICAL_CENTER | SWTX.ALIGN_HORIZONTAL_RIGHT;
						case totalPriceCol: return SWTX.ALIGN_VERTICAL_CENTER | SWTX.ALIGN_HORIZONTAL_RIGHT;
						case evaluationOpinionCol: return SWTX.ALIGN_VERTICAL_CENTER | SWTX.ALIGN_HORIZONTAL_LEFT;
					}
				}
				return SWTX.ALIGN_VERTICAL_CENTER | SWTX.ALIGN_HORIZONTAL_CENTER;
			}
		});
		
		// 设置单元格前景颜色
		tableCModel.setCellForegroundRender(new CellForegroundRender() {
			public Color receiveCellForeground(int row, int col) {
				if (row > 0) {
					switch (col) {
						case isAccessmentCol:
							int supplierIndex = row - 1;
							Supplier supplier = supplierList.get(supplierIndex);
							String accessment = expertEvaluationResultMap.get(supplier.getId()).getAccessment();
							if (StringUtils.isNotEmpty(accessment)) {
								if (accessment.equals(com.gx.obe.components.core.enumeration.EvaluationStepEnum.QUALIFIED)) {
									return SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN);
								} else if (accessment.equals(com.gx.obe.components.core.enumeration.EvaluationStepEnum.UNQUALIFIED)) {
									return SWTResourceManager.getColor(SWT.COLOR_RED);
								}
							}
							return null;
						case seeBidFileCol:
							return SWTResourceManager.getColor(SWT.COLOR_BLUE);
					}
				}
				return null;
			}
		});
		
		// 设置单元格背景颜色
		tableCModel.setCellBackgroundRender(new CellBackgroundRender() {
			public Color receiveCellBackground(int row, int col) {
				return SWTResourceManager.getColor(SWT.COLOR_WHITE);
			}
		});
		supplierComposite.layout();
	}
	
	/**
	 * @Description: 选择供应商事件
	 * @author chenxw
	 */
	private void selectionSupplierAction() {
		bidPriceComposite.moveAbove(subBidPriceComposite);
		if (null != bidPriceGrid) {
			bidPriceGrid.dispose();
		}
		
		final BidPriceTable bidPriceTable = ParsingBidPriceUtils.parsintBidPriceTable(tenderProjectEntity.getId(), curSupplier.getId());
		if (null != bidPriceTable) {
			bidPriceGrid = refreshBidPriceTableInfoList(bidPriceTable, bidPriceTableComposite);
			bidPriceGrid.addSelectionListener(new SelectionAdapter() {
				public void widgetSelected(SelectionEvent e) {
					selectionBidPriceAction(bidPriceGrid, bidPriceTable);
				}
			});
		}
		
		bidPriceTableComposite.layout();
		composite.layout();
	}
	
	/**
	 * @Description: 选择投标报价事件
	 * @author chenxw 
	 * @param parentBidPriceGrid 
	 * @param curBidPriceTable 
	 */
	private void selectionBidPriceAction(Grid parentBidPriceGrid, BidPriceTable curBidPriceTable) {
		if (parentBidPriceGrid.getSelectionCount() == 0) {
			return;
		}
		
		GridItem item = parentBidPriceGrid.getSelection()[0];
		
		GridColumn parentColumn = CollectionUtils.get(Arrays.asList(parentBidPriceGrid.getColumns()), t -> {
			return "name".equals(t.getData("colType"));
		});
		if (null != parentColumn) {
			bidPriceTitleLabel.setText(item.getText(parentBidPriceGrid.indexOf(parentColumn)) + "明细");
		}
		
		subBidPriceComposite.moveAbove(bidPriceComposite);
		if (null != subBidPriceGrid) {
			subBidPriceGrid.dispose();
		}
		
		final String subjectTableID = (String) item.getData("subjectTableID");
		if (null != subjectTableID) {
			subBidPriceGrid = refreshBidPriceTableInfoList(CollectionUtils.get(curBidPriceTable.getBidPriceTableList(), t -> {
				return subjectTableID.equals(t.getSubjectTableID());
			}), subBidPriceTableComposite);
			if (null == subBidPriceGrid) {
				bidPriceComposite.moveAbove(subBidPriceComposite);
			}
		} else {
			bidPriceComposite.moveAbove(subBidPriceComposite);
		}
		
		subBidPriceTableComposite.layout();
	}
	
	/**
	 * @Description: 刷新投标价列表
	 * @author chenxw 
	 * @param bidPriceTable 
	 * @param composite 
	 */
	private Grid refreshBidPriceTableInfoList(final BidPriceTable bidPriceTable, Composite composite) {
		TableXML detailTable = ParsingXmlUtils.parsingTableXML(FileConstants.getBidFilePath(curSupplier.getTenderId(), curSupplier.getId()).concat(bidPriceTable.getDetailFileName()));
		if (null == detailTable) {
			return null;
		}
		
		Grid bidPriceGrid = new Grid(composite, SWT.V_SCROLL | SWT.H_SCROLL);
		bidPriceGrid.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		bidPriceGrid.setShowEvenBackground(false);
		bidPriceGrid.setLinesVisible(true);
		bidPriceGrid.setAutoHeight(true);
		bidPriceGrid.setHeaderVisible(true);
		bidPriceGrid.setItemHeight(Constants.ROW_HIGHT);
		
		refreshBidPriceTableCol(bidPriceGrid, detailTable.getHeadList());
		
		TableXML totalTable = ParsingXmlUtils.parsingTableXML(FileConstants.getBidFilePath(curSupplier.getTenderId(), curSupplier.getId()).concat(bidPriceTable.getTotalFileName()));
		refreshBidPriceTableRow(bidPriceGrid, totalTable, detailTable.getBodyList());
		
		return bidPriceGrid;
	}
	
	/**
	 * @Description: 刷新投标报价表格列
	 * @author chenxw
	 * @param bidPriceGrid
	 * @param trList 
	 */
	private void refreshBidPriceTableCol(Grid bidPriceGrid, List<Tr> trList) {
		if (null == trList || trList.size() != 1) {
			return;
		}
		Td[] tds = trList.get(0).getTds();
		if (null == tds || tds.length == 0) {
			return;
		}
		for (int i = 0; i < tds.length; i++) {
			GridColumn gridColumn = new GridColumn(bidPriceGrid, SWT.NONE);
			gridColumn.setText(tds[i].getContent());
			gridColumn.setWidth(100);
			gridColumn.setData("colType", tds[i].getColType());
		}
	}

	/**
	 * @Description: 刷新投标报价表格行
	 * @author chenxw
	 * @param bidPriceGrid
	 * @param totalTable 
	 * @param trList 
	 */
	private void refreshBidPriceTableRow(Grid bidPriceGrid, TableXML totalTable, List<Tr> trList) {
		if (null == trList || trList.isEmpty()) {
			return;
		}
		for (Tr tr : trList) {
			GridItem gridItem = new GridItem(bidPriceGrid, SWT.NONE);
			Td[] tds = tr.getTds();
			if (null == tds || tds.length == 0) {
				continue;
			}
			for (int i = 0; i < tds.length; i++) {
				gridItem.setText(i, tds[i].getContent());
			}
			gridItem.setData("subjectTableID", tr.getSubjectTableID());
		}
		
		if (null == totalTable) {
			return;
		}
		
		refreshTotalTable(bidPriceGrid, totalTable.getHeadList());
		refreshTotalTable(bidPriceGrid, totalTable.getBodyList());
	}

	/**
	 * @Description: 刷新汇总表
	 * @author chenxw
	 * @param bidPriceGrid
	 * @param trList 
	 */
	private void refreshTotalTable(Grid bidPriceGrid, List<Tr> trList) {
		if (null == trList || trList.isEmpty()) {
			return;
		}
		int columnCount = bidPriceGrid.getColumnCount();
		for (Tr tr : trList) {
			GridItem gridItem = new GridItem(bidPriceGrid, SWT.NONE);
			Td[] tds = tr.getTds();
			if (null == tds || tds.length == 0) {
				continue;
			}
			if (tds.length >  columnCount) {
				
			} else {
				int span = columnCount / tds.length;
				int remainder = columnCount % tds.length;
				for (int i = 0; i < tds.length - 1; i++) {
					gridItem.setColumnSpan(i * span, span - 1);
					gridItem.setText(i * span, tds[i].getContent());
				}
				gridItem.setColumnSpan((tds.length - 1) * span, span - 1 + remainder);
				gridItem.setText((tds.length - 1) * span, tds[tds.length - 1].getContent());
			}
		}
	}
	
	/**
	 * @Description: 刷新合量报价
	 * @author chenxw 
	 */
	private void refreshTotalPrice() {
		if(null != supplierList && supplierList.size() > 0){
			executorService = Executors.newFixedThreadPool(supplierList.size() > 5 ? 5 : supplierList.size());
			for (final Supplier supplier : supplierList) {
				executorService.submit(new Runnable() {
					public void run() {
						BidPriceTable bidPriceTable = ParsingBidPriceUtils.parsintBidPriceTable(tenderProjectEntity.getId(), supplier.getId());
						TableXML detailTable = ParsingXmlUtils.parsingTableXML(FileConstants.getBidFilePath(supplier.getTenderId(), supplier.getId()).concat(bidPriceTable.getDetailFileName()));
						if (null == detailTable) {
							return;
						}
						BigDecimal totalPrice = getTotalPrice(supplier, detailTable);
						totalPriceMap.put(supplier.getId(), totalPrice);
						SupplierOpeningResult supplierOpeningResult = supplier.getSupplierOpeningResult();
						BigDecimal bidPrice = null;
						if (null != supplierOpeningResult) {
							bidPrice = supplierOpeningResult.getBidPrice();
						}
						
						ExpertEvaluationResult expertEvaluationResult = expertEvaluationResultMap.get(supplier.getId());
						if (null == expertEvaluationResult.getAccessment()) {
							if (null != bidPrice && bidPrice.compareTo(totalPrice) == 0) {
								expertEvaluationResult.setAccessment(com.gx.obe.components.core.enumeration.EvaluationStepEnum.QUALIFIED);
							} else {
								expertEvaluationResult.setAccessment(com.gx.obe.components.core.enumeration.EvaluationStepEnum.UNQUALIFIED);
							}
						}
						
						Display.getDefault().syncExec(new Runnable() {
							public void run() {
								if(!table.isDisposed()){
									table.redraw();
								}
							}
						});
					}
				});
			}
		}
	}
	
	/**
	 * @Description: 获取合量报价
	 * @author chenxw
	 * @param supplier
	 * @param detailTable
	 * @return 
	 */
	private BigDecimal getTotalPrice(Supplier supplier, TableXML detailTable) {
		BigDecimal totalPrice = BigDecimal.ZERO;
		int priceIndex = 0;
		for (Tr tr : detailTable.getHeadList()) {
			Td[] tds = tr.getTds();
			if (null != tds && tds.length != 0) {
				for (int i = 0; i < tds.length; i++) {
					if ("price".equals(tds[i].getColType())) {
						priceIndex = i;
					}
				}
			}
		}
		for (Tr tr : detailTable.getBodyList()) {
			if (tr.isCount()) {
				Td[] tds = tr.getTds();
				if (null != tds && tds.length != 0) {
					totalPrice = BigDecimalUtils.add(totalPrice, MoneyUtils.getMoneyFromText(tr.getTds()[priceIndex].getContent(), null));
				}
			}
		}
		return totalPrice;
	}
	
	/**
	 * @Description: 关闭事件
	 * @author chenxw 
	 */
	private void closeAction() {
		bidPriceComposite.moveAbove(subBidPriceComposite);
		composite.layout();
	}
	
	/**
	 * @Description: 一键评审
	 * @author chenxw 
	 */
	private void initDefaultAction() {
		if (!save_result_btn.getEnabled()) {
			return;
		}
		if(!MessageDialog.openConfirm(getShell(), "确认将所有未评审的" + supplierName + "设置为"+EVAL_ACCESSMENT_YES+"吗？")){
			return;
		}
		table.closeCellEditor();
		
		for (String supplierId : expertEvaluationResultMap.keySet()) {
			ExpertEvaluationResult expertEvaluationResult = expertEvaluationResultMap.get(supplierId);
			if (null == expertEvaluationResult.getAccessment()) {
				expertEvaluationResult.setAccessment(com.gx.obe.components.core.enumeration.EvaluationStepEnum.QUALIFIED);
			}
		}
		
		table.redraw();
	}
	
	/**
	 * @Description: 保存评标结果
	 * @author chenxw
	 */
	private void saveEvaluationResultAction() {
		if (!save_result_btn.getEnabled()) {
			return;
		}
		setButtonStatus(false);
		boolean saveSuccess = expertEvaluationStepService.saveTotalPriceEvaluationResult(tenderProjectEntity.getId(), CURRENT_EXPERT.getUserId(), evaluationStep, expertEvaluationResultMap, supplierList);
		if(saveSuccess){
			MessageDialog.openShortMessage(Messages.Tips_saveEvalResultSuccess);
		}else { 
			MessageDialog.openInformation(getShell(), Messages.Dialog_warmTips, Messages.Tips_saveEvalResultFailed);
		}
		setButtonStatus(true);
	}
	
	/**
	 * @Description: 评审完成
	 * @author chenxw
	 */
	private void submitEvaluationResultAction() {
		if (!submit_result_btn.getEnabled()) {
			return;
		}
		setButtonStatus(false);
		if (!submitEvaluationResult()) {
			setButtonStatus(true);
		}
	}
	
	/**
	 * @Description: 提交评审结果
	 * @author chenxw 
	 */
	private boolean submitEvaluationResult() {
		if (!expertEvaluationStepService.saveTotalPriceEvaluationResult(tenderProjectEntity.getId(), CURRENT_EXPERT.getUserId(), evaluationStep, expertEvaluationResultMap, supplierList)) {
			MessageDialog.openWarning(getShell(), Messages.Dialog_warmTips, Messages.Tips_saveEvalResultFailed);
			return false;
		}
		if (isHasNotEvalSupplier()) {
			MessageDialog.openWarning(getShell(), "含有未评审的" + supplierName + "！");
			return false;
		}
		//个人不控制进度
		if (ObjectUtils.equals(tenderProjectRuleEntity.getOrderReview(), com.gx.obe.components.core.enumeration.EvaluationStepEnum.ORDER_SELF_FREE)) {
			List<EvaluationStep> evaluationStepList = evaluationStepService.getNotComplateStepList(tenderProjectEntity.getId(), evaluationStep.getSortNo());
			if (null != evaluationStepList && evaluationStepList.size() > 0) {
				MessageDialog.openWarning(getShell(), Messages.Dialog_warmTips, MessageFormat.format(Messages.Tips_saveAllComplate, evaluationStepList.get(0).getStepName()));
				return false;
			}
		}
		
		if(null != noComplateFilterStep){
			if (MessageDialog.openConfirm(getShell(), Messages.Dialog_warmTips, MessageFormat.format(Messages.Tips_preStepNotCompletedBeforeEntry, noComplateFilterStep.getStepName()), new String[]{Messages.Button_refresh, Messages.Button_cancel})) {
				refreshTenderInfo();
			}
			return false;
		}
		
		String message = MessageFormat.format(Messages.Tips_submitEvaluationResult, evaluationStep.getStepName());
		if (!MessageDialog.openConfirm(getShell(), Messages.Button_submitEvaluationResult, message, new String[] { Messages.Button_confirmComplate, Messages.Button_continueEvaluation})) {
			return false;
		}
		if (!expertEvaluationStepService.submitTotalPriceEvaluationResult(tenderProjectEntity.getId(), CURRENT_EXPERT.getUserId(), evaluationStep, supplierList)) {
			MessageDialog.openWarning(getShell(), Messages.Dialog_warmTips, Messages.Tips_submitEvalResultFailed);
			return false;
		}
		goBackAction();
		return true;
	}

	/**
	 * @Description: 获得未完成的可能会存在废标的评审节点
	 * @author guoyr 
	 */
	private void getNoComplateFilterStep(){
		List<EvaluationStep> evaluationStepList = evaluationStepService.getNotComplateFilterStepList(tenderProjectEntity.getId(), evaluationStep.getSortNo());
		if (null != evaluationStepList && evaluationStepList.size() > 0) {
			noComplateFilterStep =  evaluationStepList.get(0);
		}else {
			noComplateFilterStep = null;
		}
	}
	
	/**
	 * @Description: 是否含有未评审的供应商
	 * @author chenxw
	 * @return 
	 */
	private boolean isHasNotEvalSupplier() {
		for (String supplierId : expertEvaluationResultMap.keySet()) {
			ExpertEvaluationResult expertEvaluationResult = expertEvaluationResultMap.get(supplierId);
			if (StringUtils.isEmpty(expertEvaluationResult.getAccessment())) {
				return true;
			}
		}
		return false;
	}

	/**
	 * @Description: 设置按钮的状态
	 * @author guoyr
	 * @param enable
	 */
	private void setButtonStatus(boolean enable){
		for(Control control : button_composite.getChildren()){
			if(!control.isDisposed() && control instanceof EButton){
				((EButton)control).setEnabled(enable);
			}
		}
	}
	
	/**
	 * @Description: 返回
	 * @author chenxw
	 */
	private void goBackAction() {
		if (null != expertEvaluationListener) {
			expertEvaluationListener.complete();
		}
	}
	
	public void addExpertEvaluationListener(ExpertEvaluationListener expertEvaluationListener) {
		this.expertEvaluationListener = expertEvaluationListener;
	}
	
	@Override
	protected void checkSubclass() {
		// Disable the check that prevents subclassing of SWT components
	}
}
