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

import java.math.BigDecimal;
import java.text.MessageFormat;
import java.util.ArrayList;
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.swt.SWT;
import org.eclipse.swt.core.ImageResolver;
import org.eclipse.swt.core.widgets.ELink;
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.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;

import com.gx.obe.ColorConstants;
import com.gx.obe.business.entity.ExpertEvaluationStep;
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.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.ApplyReEvaluationDialog;
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.LogUtils;
import com.gx.obe.util.utils.ObjectUtils;
import com.gx.obe.util.utils.StringUtils;
import com.gx.obe.web.entity.Supplier;
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.SupplierOpeningResultService;
import com.gx.obe.web.service.SupplierService;
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.swtdesigner.ResourceManager;
import com.swtdesigner.SWTResourceManager;

import de.kupzog.ktable.KTable;
import de.kupzog.ktable.SWTX;
import de.kupzog.ktable.editors.KTableCellEditorLink;
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.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;

/**
 * @Description:
 * @author chenxw
 */
public class TotalPriceResultComposite extends Composite {
	
	private String EVAL_ACCESSMENT_YES = "不否决";//Messages.Qualified;
	private String EVAL_ACCESSMENT_NO = "否决";//Messages.Unqualified;
	private ImageResolver imageResolver = new ImageResolver();
	private Composite supplierComposite;
	private Label messageLabet;
	private ELink applyReEvaluation_link;
	private KTable table;
	private BidDocumentLoaderShell documentLoaderShell;
	private SupplierService supplierService = new SupplierService();
//	private ExpertEvaluationStepService expertEvaluationStepService ;
	private ExpertEvaluationResultService expertEvaluationResultService;
	private SupplierOpeningResultService supplierOpeningResultService ;
	private ExpertService expertService;
	private TenderProjectEntity tenderProjectEntity;
	private TenderProjectRuleEntity tenderProjectRuleEntity;
	private EvaluationStep evaluationStep;
	private Expert CURRENT_EXPERT;
	private String OPERATOR_USER_ID;
	private String supplierName;
	private List<Supplier> supplierList;
	private Map<String, ExpertEvaluationResult> expertEvaluationResultMap;
	private Map<String, BigDecimal> totalPriceMap;
	private ExecutorService executorService;
	private String curUserId;
	
	private ExpertEvaluationStepService expertEvaluationStepService = new ExpertEvaluationStepService();
	
	{
		LogUtils.logClass(TotalPriceResultComposite.class);
	}
	
	/**
	 * Create the composite.
	 * 
	 * @param parent
	 * @param style
	 */
	public TotalPriceResultComposite(Composite parent, int style) {
		super(parent, style);
		GridLayout gridLayout = new GridLayout(1, false);
		gridLayout.verticalSpacing = 0;
		gridLayout.marginHeight = 1;
		gridLayout.marginWidth = 1;
		setLayout(gridLayout);
		addDisposeListener(new DisposeListener() {
			public void widgetDisposed(DisposeEvent e) {
				imageResolver.disposite();
				if (null != executorService) {
					executorService.shutdownNow();
				}
				if (null != documentLoaderShell && !documentLoaderShell.isDisposed()) {
					documentLoaderShell.dispose();
				}
			}
		});
		
		Composite messageComposite = new Composite(this, SWT.NONE);
		messageComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
		GridLayout gl_composite_1 = new GridLayout(2, false);
		messageComposite.setLayout(gl_composite_1);
		
		messageLabet = new Label(messageComposite, SWT.WRAP);
		messageLabet.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
		messageLabet.setFont(SWTResourceManager.getFont("微软雅黑", 10, SWT.NORMAL));
		messageLabet.setForeground(ColorConstants.NOTE_TIPS_COLOR);
		
		applyReEvaluation_link = new ELink(messageComposite, SWT.NONE);
		applyReEvaluation_link.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
		applyReEvaluation_link.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/blue/hand.png"));
		applyReEvaluation_link.setText(Messages.Button_appllyForBack);
		applyReEvaluation_link.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseUp(MouseEvent e) {
				applyReEvaluationAction();
			}
		});
		
		Composite composite = new Composite(this, SWT.NONE);
		composite.setBackground(ColorConstants.BORDER_LINE_COLOR);
		composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		GridLayout gl_composite = new GridLayout(1, false);
		gl_composite.marginHeight = 1;
		gl_composite.marginWidth = 1;
		composite.setLayout(gl_composite);
		
		supplierComposite = new Composite(composite, SWT.NONE);
		supplierComposite.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
		supplierComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		GridLayout gl_supplierComposite = new GridLayout(1, false);
		gl_supplierComposite.marginHeight = 0;
		gl_supplierComposite.marginWidth = 0;
		supplierComposite.setLayout(gl_supplierComposite);
		expertService = new ExpertService();
	}
	
	/**
	 * @Description: 初始化
	 * @author guoyr
	 */
	public void refresh(TenderProjectEntity tenderProjectEntity, TenderProjectRuleEntity tenderProjectRuleEntity, EvaluationStep evaluationStep, String OPERATOR_USER_ID) {
		this.tenderProjectEntity = tenderProjectEntity;
		this.tenderProjectRuleEntity = null == tenderProjectRuleEntity ? new TenderProjectRuleEntity() : tenderProjectRuleEntity;
		this.evaluationStep = evaluationStep;
		this.OPERATOR_USER_ID = OPERATOR_USER_ID;
		this.CURRENT_EXPERT = expertService.getEvaluationStepExpert(tenderProjectEntity.getId(), evaluationStep);
		curUserId = CURRENT_EXPERT.getUserId();
		init();
	}
	
	private void init() {
		expertEvaluationResultService = new ExpertEvaluationResultService();
		supplierOpeningResultService = new SupplierOpeningResultService();
		applyReEvaluation_link.setText(MessageFormat.format(Messages.Button_appllyForBackFormat, evaluationStep.getStepName()));
		applyReEvaluation_link.setVisible(false);
		
		supplierName = com.gx.obe.components.core.I18N.getString(I18NEnum.SUPPLIERNAME, tenderProjectEntity.getTenderType());
		
		StringBuilder msg = new StringBuilder();
		if (null != evaluationStep.getStepStatus() && evaluationStep.getStepStatus().equals(CommonEnum.COMPLETE)) {
			msg.append(MessageFormat.format(Messages.Tips_progressComplate, evaluationStep.getStepName()));
			if(null != OPERATOR_USER_ID && OPERATOR_USER_ID.equals(Constants.USER.getId())){
				applyReEvaluation_link.setVisible(true);
			}
		} else if (null != evaluationStep.getStepStatus() && evaluationStep.getStepStatus().equals(CommonEnum.IN_PROGRESS)) {
			msg.append(MessageFormat.format(Messages.Tips_progressIn, evaluationStep.getStepName()));
		} else {
			msg.append(MessageFormat.format(Messages.Tips_progressNotStart, evaluationStep.getStepName()));
		}
		messageLabet.setText(msg.toString());
		
		expertEvaluationResultMap = new HashMap<String, ExpertEvaluationResult>();
		totalPriceMap = new HashMap<String, BigDecimal>();
		
		refreshSupplierList();
		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() {
		initEvaluationResult();
		showAllSupplierList();
		refreshTotalPrice();
	}
	
	/**
	 * @Description: 初始化评审结果
	 * @author chenxw
	 */
	private void initEvaluationResult() {
		List<ExpertEvaluationResult> resultList = expertEvaluationResultService.getExpertStepAllSupplierEvaluationResultList(tenderProjectEntity.getId(), evaluationStep.getId(), curUserId);
		for (final Supplier supplier : supplierList) {
			// 获取评标专家对投标人的评审记录
			ExpertEvaluationResult expertEvaluationResult = CollectionUtils.get(resultList, t -> {
				return ObjectUtils.equals(t.getSupplierId(), supplier.getId());
			});
			if (null == expertEvaluationResult) {
				expertEvaluationResult = new ExpertEvaluationResult();
				expertEvaluationResult.setTenderId(tenderProjectEntity.getId());
				expertEvaluationResult.setStepId(evaluationStep.getId());
				expertEvaluationResult.setUserId(curUserId);
				expertEvaluationResult.setSupplierId(supplier.getId());
			}
			expertEvaluationResultMap.put(supplier.getId(), expertEvaluationResult);
		}
	}
	
	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));
		
		final CommonKtableCModel tableCModel = new CommonKtableCModel(table, 1, 0, supplierList.size(), 7);
		table.setModel(tableCModel);
		
		//设置行高
		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 = 5;
		final int seeBidFileCol = 6;
		
		//设置列宽
		tableCModel.setColumnWidth(indexCol, 10);
		tableCModel.setColumnMaxWidth(indexCol, 80);
		tableCModel.setColumnWidth(supplierNameCol, 250);
		tableCModel.setColumnWidth(bidPriceCol, 100);
		tableCModel.setColumnWidth(totalPriceCol, 100);
		tableCModel.setColumnWidth(isAccessmentCol, 50);
		tableCModel.setColumnWidth(evaluationOpinionCol, 250);
		tableCModel.setColumnWidth(seeBidFileCol, 50);
		
		//设置单元格内容
		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;
			}
		});
		
		// 设置单元格编辑器
		tableCModel.setCellEditorRender(new CellEditorRender() {
			public Object receiveCellEditor(int row, int col) {
				if (row > 0) {
					switch (col) {
						case seeBidFileCol:
							int supplierIndex = row - 1;
							final Supplier supplier = supplierList.get(supplierIndex);
							return new KTableCellEditorLink(table, new CellEventActionRender() {
								public void receiveAction(int row, int col) {
									List<BidFile> fileList = BidFile.getBidPriceFileList(tenderProjectEntity.getId(), supplier.getId());
									if (null == documentLoaderShell || documentLoaderShell.isDisposed()) {
										documentLoaderShell = new BidDocumentLoaderShell(getShell());
										documentLoaderShell.setSize(900, 600);
										documentLoaderShell.open();
									}
									documentLoaderShell.refresh(fileList);
								}
							});
					}
				}
				return null;
			}
		});
		
		// 设置单元格图片
		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 seeBidFileCol:
							return attachmentsImage;
					}
				}
				return null;
			}
		});
		
		// 编辑单元格对齐方式
		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 ColorConstants.SKIN_BG;
					}
				}
				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 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) {
					SupplierOpeningResult supplierOpeningResult = supplier.getSupplierOpeningResult();
					String priceUint = tenderProjectRuleEntity.getPriceUnitUseDefault();
					if (null != supplierOpeningResult) {
						priceUint = supplierOpeningResult.getPriceUnitCN(priceUint);
					}
					totalPrice = BigDecimalUtils.add(totalPrice, MoneyUtils.getMoneyFromText(tr.getTds()[priceIndex].getContent(), priceUint));
				}
			}
		}
		return totalPrice;
	}
	
	/**
	 * @Description: 申请回退
	 * @author guoyr
	 */
	private void applyReEvaluationAction() {
		if (applyReEvaluation_link.getEnabled()) {
			ExpertEvaluationStep expertEvaluationStep = expertEvaluationStepService.getExpertEvaluationStep(tenderProjectEntity.getId(), evaluationStep.getId(), curUserId);
			if (null != expertEvaluationStep) {
				ApplyReEvaluationDialog applyReEvaluationDialog = new ApplyReEvaluationDialog(getShell(), evaluationStep, expertEvaluationStep);
				applyReEvaluationDialog.open();
			}
		}
	}
	
	@Override
	protected void checkSubclass() {
		// Disable the check that prevents subclassing of SWT components
	}
	
}
