Signed-off-by: mzr <1562242162@qq.com>123
This commit is contained in:
		
							parent
							
								
									fd7c6b1f67
								
							
						
					
					
						commit
						a0bc1e2131
					
				|  | @ -0,0 +1,588 @@ | |||
| package nc.ui.cm.meascostcontrast.action; | ||||
| 
 | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.Comparator; | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| 
 | ||||
| import nc.bd.framework.base.CMArrayUtil; | ||||
| import nc.bd.framework.base.CMMapUtil; | ||||
| import nc.bd.framework.base.CMNumberUtil2; | ||||
| import nc.bs.framework.common.NCLocator; | ||||
| import nc.cmpub.business.util.CMUtil; | ||||
| import nc.cmpub.framework.query.CMQueryTemplateUtil; | ||||
| import nc.itf.cm.meascostcontrast.IMeasCostQueryService; | ||||
| import nc.ui.cm.meascostcontrast.view.MeasCostAppModel; | ||||
| import nc.ui.cmpub.business.util.CMBillPanelUtils; | ||||
| import nc.ui.pub.bill.BillItem; | ||||
| import nc.ui.pub.bill.BillListData; | ||||
| import nc.ui.pub.bill.BillListPanel; | ||||
| import nc.ui.pub.bill.IBillItem; | ||||
| import nc.ui.pubapp.uif2app.query2.action.DefaultQueryAction; | ||||
| import nc.ui.pubapp.uif2app.view.BillListView; | ||||
| import nc.ui.querytemplate.querytree.IQueryScheme; | ||||
| import nc.ui.uif2.IShowMsgConstant; | ||||
| import nc.ui.uif2.NCAction; | ||||
| import nc.ui.uif2.ShowStatusBarMsgUtil; | ||||
| import nc.vo.cm.meascostcontrast.CMCommonConst1614; | ||||
| import nc.vo.cm.meascostcontrast.CMLangConst1614; | ||||
| import nc.vo.cm.meascostcontrast.MeasCostItemVO; | ||||
| import nc.vo.cm.meascostcontrast.MeasCostParamVO; | ||||
| import nc.vo.cm.meascostcontrast.MeasCostQueryConditionVO; | ||||
| import nc.vo.cm.meascostcontrast.MeasCostShowVO; | ||||
| import nc.vo.cm.meascostcontrast.MeasCostUtil; | ||||
| import nc.vo.cmpub.framework.report.CMConditionVO; | ||||
| import nc.vo.pub.BusinessException; | ||||
| import nc.vo.pub.bill.BillTempletBodyVO; | ||||
| import nc.vo.pub.lang.UFDouble; | ||||
| import nc.vo.pubapp.pattern.exception.ExceptionUtils; | ||||
| import nc.vo.pubapp.pattern.pub.MapList; | ||||
| import nc.vo.resa.factor.FactorVO; | ||||
| 
 | ||||
| /** | ||||
|  * 单位成本对比表-查询按钮 | ||||
|  */ | ||||
| @SuppressWarnings("serial") | ||||
| public class MeasCostQueryAction extends DefaultQueryAction { | ||||
| 
 | ||||
| 	private NCAction refreshAction; | ||||
| 
 | ||||
| 	private NCAction printAction; | ||||
| 
 | ||||
| 	private NCAction previewAction; | ||||
| 
 | ||||
| 	private NCAction outputAction; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 动态汇总列 | ||||
| 	 */ | ||||
| 	private List<String> sumFieldCode = null; | ||||
| 
 | ||||
| 	public void setPreviewAction(NCAction previewAction) { | ||||
| 		this.previewAction = previewAction; | ||||
| 	} | ||||
| 
 | ||||
| 	public void setPrintAction(NCAction printAction) { | ||||
| 		this.printAction = printAction; | ||||
| 	} | ||||
| 
 | ||||
| 	public void setRefreshAction(NCAction refreshAction) { | ||||
| 		this.refreshAction = refreshAction; | ||||
| 	} | ||||
| 
 | ||||
| 	public void setOutputAction(NCAction outputAction) { | ||||
| 		this.outputAction = outputAction; | ||||
| 	} | ||||
| 
 | ||||
| 	private CMQueryTemplateUtil queryUtil = null; | ||||
| 
 | ||||
| 	private CMQueryTemplateUtil getQueryUtil() { | ||||
| 		if (null == this.queryUtil) { | ||||
| 			this.queryUtil = new CMQueryTemplateUtil(); | ||||
| 		} | ||||
| 		return this.queryUtil; | ||||
| 	} | ||||
| 
 | ||||
| 	private FactorVO[] filteShowFactor(FactorVO[] vos, Map<String, String> factorMapShow) { | ||||
| 		List<FactorVO> tmp = new ArrayList<FactorVO>(); | ||||
| 		String[] factorcodes = factorMapShow.keySet().toArray(new String[0]); | ||||
| 
 | ||||
| 		for (String code : factorcodes) { | ||||
| 			for (FactorVO vo : vos) { | ||||
| 				if (vo.getFactorcode().equals(code)) { | ||||
| 					tmp.add(vo); | ||||
| 					break; | ||||
| 				} else if (vo.getFactorcode().startsWith(code)) { // liushy7 这里还需要改动,需要看看在哪里加上的核算要素 | ||||
| 					vo.setFactorcode(code); | ||||
| 					vo.setFactorname(factorMapShow.get(code)); | ||||
| 					tmp.add(vo); | ||||
| 					break; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		FactorVO[] result = tmp.toArray(new FactorVO[0]); | ||||
| 		// 对编码进行排序 | ||||
| 		this.sortVOByCode(result); | ||||
| 		return result; | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 按照编码对VO进行排序。 | ||||
| 	 * | ||||
| 	 * @param vos | ||||
| 	 */ | ||||
| 	private void sortVOByCode(FactorVO[] vos) { | ||||
| 		if (vos == null || vos.length < 2) { | ||||
| 			return; | ||||
| 		} | ||||
| 		Arrays.sort(vos, new Comparator<FactorVO>() { | ||||
| 
 | ||||
| 			@Override | ||||
| 			public int compare(FactorVO o1, FactorVO o2) { | ||||
| 				String code1 = (String) o1.getAttributeValue(FactorVO.FACTORCODE); | ||||
| 				String code2 = (String) o2.getAttributeValue(FactorVO.FACTORCODE); | ||||
| 				return code1.compareTo(code2); | ||||
| 			} | ||||
| 		}); | ||||
| 	} | ||||
| 
 | ||||
| 	@Override | ||||
| 	protected void showQueryInfo() { | ||||
| 		int size = this.getListView().getModel().getRowCount(); | ||||
| 		if (size > 0) { | ||||
| 			int currentSize = size - 1; | ||||
| 			ShowStatusBarMsgUtil.showStatusBarMsg(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("pubapp_0", | ||||
| 					"0pubapp-0265", null, new String[] { "" + currentSize })/* | ||||
| 																			 * @res "查询成功,已查到{0}张单据。" | ||||
| 																			 */, this.getModel().getContext()); | ||||
| 		} else { | ||||
| 			ShowStatusBarMsgUtil.showStatusBarMsg(IShowMsgConstant.getQueryNullInfo(), this.getModel().getContext()); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	@Override | ||||
| 	protected void executeQuery(IQueryScheme queryScheme) { | ||||
| 
 | ||||
| 		this.sumFieldCode = new ArrayList<String>(); | ||||
| 
 | ||||
| 		// 取得查询条件 | ||||
| 		MeasCostParamVO paramVO = this.getMeasCostParamVO(queryScheme); | ||||
| 		// 根据查询条件查询,返回显示VO | ||||
| 		MeasCostShowVO showVO = null; | ||||
| 		try { | ||||
| 			showVO = this.getQueryService().process(paramVO); | ||||
| 		} catch (BusinessException e) { | ||||
| 			ExceptionUtils.wrappException(e); | ||||
| 		} | ||||
| 		// 取得逻辑查询条件 | ||||
| 		Map<String, CMConditionVO> conditionMap = paramVO.getConditionMap(); | ||||
| 		Map<String, List<String>> itemgroupMap = null;// 保存表头上下两层列的对应关系的mapList | ||||
| 
 | ||||
| 		if (showVO != null) { | ||||
| 			Map<String, Integer> digitsMap = showVO.getDigitsMap();// 列表精度信息(单价、数量、金额) | ||||
| 			// 初始化动态表头------动态列只显示有数据的列 | ||||
| 			FactorVO[] factorVOs = this.filteShowFactor(showVO.getFactorVOs(), showVO.getFactorMapShow()); | ||||
| 
 | ||||
| 			if (factorVOs != null) { | ||||
| 				itemgroupMap = this.reBuildItem(conditionMap, factorVOs, digitsMap); | ||||
| 			} | ||||
| 			// 初始化数据 | ||||
| 			List<MeasCostItemVO> itemVOList = showVO.getItemVOList(); | ||||
| 			if (itemVOList != null) { | ||||
| 				MeasCostItemVO[] itemVOs = itemVOList.toArray(new MeasCostItemVO[itemVOList.size()]); | ||||
| 
 | ||||
| 				MeasCostItemVO[] result = this.dealQueryResult(itemVOs); | ||||
| 				this.getListView().getModel().initModel(result); | ||||
| 				BillListData billListData = this.getListView().getBillListPanel().getBillListData(); | ||||
| 				if (itemVOList.size() > 0) { | ||||
| 					this.previewAction.setEnabled(true); | ||||
| 					this.printAction.setEnabled(true); | ||||
| 					this.outputAction.setEnabled(true); | ||||
| 				} | ||||
| 
 | ||||
| 			} | ||||
| 
 | ||||
| 		} | ||||
| 		// 如果没有取得任何数据,初始化界面数据为空 | ||||
| 		else { | ||||
| 			this.getListView().getModel().initModel(null); | ||||
| 
 | ||||
| 			this.previewAction.setEnabled(false); | ||||
| 			this.printAction.setEnabled(false); | ||||
| 			this.outputAction.setEnabled(false); | ||||
| 
 | ||||
| 			return; | ||||
| 		} | ||||
| 		// 取得动态列的显示明细区分 | ||||
| 		String[] showDetailDiff = MeasCostUtil.getShowDetailDiff(conditionMap); | ||||
| 		// 单据列表模板 | ||||
| 		BillListPanel billListPanel = this.getListView().getBillListPanel(); | ||||
| 		// 页签编码 | ||||
| 		String tablecode = billListPanel.getHeadItem(CMCommonConst1614.VCOSTOBJCODE).getTableCode(); | ||||
| 		// 表头多层的情况时,设置表头上面一层的列名 | ||||
| 		if (CMArrayUtil.isNotEquals(CMCommonConst1614.DEFAULT_ITEMS, showDetailDiff)) { | ||||
| 			CMBillPanelUtils.createSingleLayMultiHeadTableForHead(billListPanel, tablecode, itemgroupMap); | ||||
| 		} | ||||
| 		// 刷新界面显示 | ||||
| 		this.getListView().getBillListPanel().getHeadTable().getTableHeader().invalidate(); | ||||
| 		this.getListView().getBillListPanel().getParentListPanel().getTable().getTableHeader().validate(); | ||||
| 
 | ||||
| 	} | ||||
| 
 | ||||
| 	private MeasCostItemVO[] dealQueryResult(MeasCostItemVO[] itemVOs) { | ||||
| 		if (CMArrayUtil.isEmpty(itemVOs)) { | ||||
| 			return itemVOs; | ||||
| 		} | ||||
| 
 | ||||
| 		MeasCostItemVO[] result = new MeasCostItemVO[itemVOs.length + 1]; | ||||
| 		UFDouble nsumncost = UFDouble.ZERO_DBL;// 合计 | ||||
| 		UFDouble nnum = UFDouble.ZERO_DBL;// 产量 | ||||
| 		Map<String, UFDouble> sumMap = new HashMap<String, UFDouble>(); | ||||
| 		for (String field : this.sumFieldCode) { | ||||
| 			sumMap.put(field, UFDouble.ZERO_DBL); | ||||
| 		} | ||||
| 
 | ||||
| 		int i = 0; | ||||
| 		for (MeasCostItemVO item : itemVOs) { | ||||
| 			if (item.getNnum() != null) { | ||||
| 				nnum = CMNumberUtil2.add(nnum, item.getNnum()); | ||||
| 			} | ||||
| 			if (item.getAttributeValue("nsumncost") != null) { | ||||
| 				nsumncost = CMNumberUtil2.add(nsumncost, (UFDouble) item.getAttributeValue("nsumncost")); | ||||
| 			} | ||||
| 			for (String key : sumMap.keySet()) { | ||||
| 				UFDouble oldVal = sumMap.get(key); | ||||
| 				if (item.getAttributeValue(key) != null) { | ||||
| 					UFDouble newVal = CMNumberUtil2.add(oldVal, (UFDouble) item.getAttributeValue(key)); | ||||
| 					sumMap.put(key, newVal); | ||||
| 				} | ||||
| 
 | ||||
| 			} | ||||
| 
 | ||||
| 			result[i] = item; | ||||
| 			i++; | ||||
| 		} | ||||
| 
 | ||||
| 		MeasCostItemVO newItem = new MeasCostItemVO(); | ||||
| 		newItem.setCccode(CMLangConst1614.GET_NSUM_NAME());// res:合计 | ||||
| 		newItem.setAttributeValue("nnum", nnum); | ||||
| 		newItem.setAttributeValue("nsumncost", nsumncost); | ||||
| 		for (String key : sumMap.keySet()) { | ||||
| 			newItem.setAttributeValue(key, sumMap.get(key)); | ||||
| 		} | ||||
| 		result[itemVOs.length] = newItem; | ||||
| 
 | ||||
| 		return result; | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 重构动态列表头 | ||||
| 	 * | ||||
| 	 * @param factorVOs    "核算要素"动态列初始化所需数据 | ||||
| 	 * @param conditionMap 逻辑查询条件 | ||||
| 	 * @param digitsMap    列表精度----单价、数量、金额 | ||||
| 	 * @return 保存表头上下两层列的对应关系的map | ||||
| 	 */ | ||||
| 	private Map<String, List<String>> reBuildItem(Map<String, CMConditionVO> conditionMap, FactorVO[] factorVOs, | ||||
| 			Map<String, Integer> digitsMap) { | ||||
| 
 | ||||
| 		// 取得列的显示明细区分(区分本下阶、显示标准成本、区分成本中心、默认) | ||||
| 		String[] showDetailDiff = MeasCostUtil.getShowDetailDiff(conditionMap); | ||||
| 		// 取得成本对象的显示方式(成本对象、产品、产品成本分类、产品基本分类) | ||||
| 		Integer ishowtype = MeasCostQueryConditionVO.PRODUCT_VALUE; | ||||
| 		if (conditionMap.containsKey(MeasCostQueryConditionVO.ISHOWTYPE) | ||||
| 				&& conditionMap.get(MeasCostQueryConditionVO.ISHOWTYPE).getSingleValue() != null) { | ||||
| 			ishowtype = Integer.valueOf(conditionMap.get(MeasCostQueryConditionVO.ISHOWTYPE).getSingleValue()); | ||||
| 		} | ||||
| 
 | ||||
| 		// 保存基本列的list | ||||
| 		List<BillItem> itemsList = new ArrayList<BillItem>(); | ||||
| 		// 保存两层列的对应关系 | ||||
| 		MapList<String, String> itemgroupMapList = new MapList<String, String>(); | ||||
| 		// 设置固定的前三列,保存到list | ||||
| 		this.setCodeNameItems(itemsList, ishowtype, digitsMap); | ||||
| 		// 如果显示样式为单层,单层列保存到list | ||||
| 		if (CMArrayUtil.isEquals(CMCommonConst1614.DEFAULT_ITEMS, showDetailDiff)) { | ||||
| 			this.setSingleItems(itemsList, factorVOs, digitsMap); | ||||
| 		} | ||||
| 		// 如果显示样式为双层,双层列的下层列保存到list,并返回保存两层列的对应关系的Map | ||||
| 		else { | ||||
| 			itemgroupMapList = this.setDoubleItems(itemsList, factorVOs, showDetailDiff, digitsMap); | ||||
| 		} | ||||
| 		// 单据列表模板 | ||||
| 		BillListPanel billListPanel = this.getListView().getBillListPanel(); | ||||
| 		// 设置表头的子列 | ||||
| 		billListPanel.getBillListData().setHeadItems(itemsList.toArray(new BillItem[0])); | ||||
| 		billListPanel.setListData(this.getListView().getBillListPanel().getBillListData()); | ||||
| 		return itemgroupMapList.toMap(); | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 设置固定列(包括三个列:产品编码、产品名称、产量) | ||||
| 	 * | ||||
| 	 * @param ishowtype 显示方式(成本对象、产品、产品成本分类、产品基本分类) | ||||
| 	 */ | ||||
| 	private void setCodeNameItems(List<BillItem> itemsList, Integer ishowtype, Map<String, Integer> digitsMap) { | ||||
| 
 | ||||
| 		// 单据列表模板 | ||||
| 		BillListPanel billListPanel = this.getListView().getBillListPanel(); | ||||
| 
 | ||||
| 		// 取得产品编码和产品名称这两列的列名{0:产品编码列名,1:产品名称列名} | ||||
| 		String[] itemNames = this.getItemNameByShowType(ishowtype); | ||||
| 		// 设置"成本中心编码"列 | ||||
| 		BillItem centercodeItem = billListPanel.getHeadItem(CMCommonConst1614.CCCODE); | ||||
| 		centercodeItem.setName(itemNames[0]); | ||||
| 		itemsList.add(centercodeItem); | ||||
| 
 | ||||
| 		// 设置"成本中心名称"列 | ||||
| 		BillItem centernameItem = billListPanel.getHeadItem(CMCommonConst1614.CCNAME); | ||||
| 		centernameItem.setName(itemNames[1]); | ||||
| 		itemsList.add(centernameItem); | ||||
| 
 | ||||
| 		// 设置"产品编码"列 | ||||
| 		BillItem codeItem = billListPanel.getHeadItem(CMCommonConst1614.VCOSTOBJCODE); | ||||
| 		codeItem.setName(itemNames[2]); | ||||
| 		itemsList.add(codeItem); | ||||
| 
 | ||||
| 		// 设置"产品名称"列 | ||||
| 		BillItem nameItem = billListPanel.getHeadItem(CMCommonConst1614.VCOSTOBJNAME); | ||||
| 		nameItem.setName(itemNames[3]); | ||||
| 		itemsList.add(nameItem); | ||||
| 
 | ||||
| 		if (MeasCostQueryConditionVO.COSTOBJECT_VALUE.equals(ishowtype) | ||||
| 				|| MeasCostQueryConditionVO.PRODUCT_VALUE.equals(ishowtype)) { | ||||
| 			// 设置"产品规格"列 | ||||
| 			BillItem materialspecItem = billListPanel.getHeadItem(CMCommonConst1614.MATERIALSPEC); | ||||
| 			materialspecItem.setName(itemNames[4]); | ||||
| 			itemsList.add(materialspecItem); | ||||
| 		} | ||||
| 
 | ||||
| 		if (MeasCostQueryConditionVO.COSTOBJECT_VALUE.equals(ishowtype) | ||||
| 				|| MeasCostQueryConditionVO.PRODUCT_VALUE.equals(ishowtype)) { | ||||
| 			// 设置"产品规格"列 | ||||
| 			BillItem materialspecItem = billListPanel.getHeadItem(CMCommonConst1614.MATERIALTYPE); | ||||
| 			materialspecItem.setName(itemNames[5]); | ||||
| 			itemsList.add(materialspecItem); | ||||
| 		} | ||||
| 
 | ||||
| 		if (MeasCostQueryConditionVO.COSTOBJECT_VALUE.equals(ishowtype) | ||||
| 				|| MeasCostQueryConditionVO.PRODUCT_VALUE.equals(ishowtype)) { | ||||
| 			// 设置"计量单位"列 | ||||
| 			BillItem materialspecItem = billListPanel.getHeadItem(CMCommonConst1614.PK_MEASDOC); | ||||
| 			materialspecItem.setName(itemNames[6]); | ||||
| 			itemsList.add(materialspecItem); | ||||
| 		} | ||||
| 
 | ||||
| 		String tableCode = nameItem.getTableCode(); | ||||
| 		int decimalDigits = nameItem.getDecimalDigits(); | ||||
| 		// 设置"项目编码"列 | ||||
| 		BillItem projectcodeItem = billListPanel.getHeadItem(CMCommonConst1614.PROJECTCODE); | ||||
| 		if (projectcodeItem == null) { | ||||
| 			projectcodeItem = CMBillPanelUtils.buildCellItems(tableCode, CMCommonConst1614.PROJECTCODE, "项目编码", 20, | ||||
| 					decimalDigits, null); | ||||
| 		} | ||||
| 		BillTempletBodyVO bodyVO = nameItem.getBodyVO(); | ||||
| 		projectcodeItem.initItem(bodyVO); | ||||
| 		projectcodeItem.setKey(CMCommonConst1614.PROJECTCODE); | ||||
| 		projectcodeItem.setName("项目编码"); | ||||
| 		// projectcodeItem.setTableCode(tableCode); | ||||
| 		// projectcodeItem.setDecimalDigits(decimalDigits); | ||||
| 		// projectcodeItem.setPk_org(nameItem.getPk_org()); | ||||
| 		itemsList.add(projectcodeItem); | ||||
| 
 | ||||
| 		// 设置"项目名称"列 | ||||
| 		BillItem projectnameItem = billListPanel.getHeadItem(CMCommonConst1614.PROJECTNAME); | ||||
| 		if (projectnameItem == null) { | ||||
| 			projectnameItem = CMBillPanelUtils.buildCellItems(tableCode, CMCommonConst1614.PROJECTNAME, "项目名称", 22, | ||||
| 					decimalDigits, null); | ||||
| 			projectnameItem.setName("项目名称"); | ||||
| 		} | ||||
| 		projectnameItem.initItem(bodyVO); | ||||
| 		projectnameItem.setKey(CMCommonConst1614.PROJECTNAME); | ||||
| 		projectnameItem.setName("项目名称"); | ||||
| 		itemsList.add(projectnameItem); | ||||
| 
 | ||||
| 		// 设置"产量"列 | ||||
| 		BillItem nnumItem = billListPanel.getHeadItem(CMCommonConst1614.NNUM); | ||||
| 		nnumItem.setDecimalDigits(digitsMap.get(MeasCostShowVO.NumDigitsKey)); | ||||
| 		nnumItem.setDataType(IBillItem.DECIMAL); | ||||
| 		itemsList.add(nnumItem); | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 根据显示方式不同,取前两列的列名 | ||||
| 	 * | ||||
| 	 * @param ishowtype 显示方式(成本对象、产品、产品成本分类、产品基本分类) | ||||
| 	 * @return 字符串数组:{0:产品编码列名,1:产品名称列名} | ||||
| 	 */ | ||||
| 	private String[] getItemNameByShowType(Integer ishowtype) { | ||||
| 		String[] itemName = new String[7]; | ||||
| 		itemName[0] = CMLangConst1614.GET_CENTERCODE_NAME(); | ||||
| 		itemName[1] = CMLangConst1614.GET_CENTERNAME_NAME(); | ||||
| 		// 显示方式:成本对象 | ||||
| 		if (MeasCostQueryConditionVO.COSTOBJECT_VALUE.equals(ishowtype)) { | ||||
| 			itemName[2] = CMLangConst1614.GET_OBJECT_CODE_NAME(); | ||||
| 			itemName[3] = CMLangConst1614.GET_OBJECT_NAME(); | ||||
| 		} | ||||
| 		// 显示方式:产品 | ||||
| 		else if (MeasCostQueryConditionVO.PRODUCT_VALUE.equals(ishowtype)) { | ||||
| 			itemName[2] = CMLangConst1614.GET_PRODUCT_CODE_NAME(); | ||||
| 			itemName[3] = CMLangConst1614.GET_PRODUCT_NAME(); | ||||
| 		} | ||||
| 		// 显示方式:产品成本分类 | ||||
| 		else if (MeasCostQueryConditionVO.PRODUCT_COST_VALUE.equals(ishowtype)) { | ||||
| 			itemName[2] = CMLangConst1614.GET_PRODUCT_COST_CODE_NAME(); | ||||
| 			itemName[3] = CMLangConst1614.GET_PRODUCT_COST_NAME(); | ||||
| 		} | ||||
| 		// 显示方式:产品基本分类 | ||||
| 		else if (MeasCostQueryConditionVO.PRODUCT_BASIC_VALUE.equals(ishowtype)) { | ||||
| 			itemName[2] = CMLangConst1614.GET_PRODUCT_BASIC_CODE_NAME(); | ||||
| 			itemName[3] = CMLangConst1614.GET_PRODUCT_BASIC_NAME(); | ||||
| 		} | ||||
| 		itemName[4] = "规格"; | ||||
| 		itemName[5] = "型号"; | ||||
| 		itemName[6] = "计量单位"; | ||||
| 		return itemName; | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 单层列时,将列保存到list | ||||
| 	 * | ||||
| 	 * @param itemsList 保存基本列的list | ||||
| 	 * @param factorVOs "核算要素"动态列初始化所需数据 | ||||
| 	 */ | ||||
| 	private void setSingleItems(List<BillItem> itemsList, FactorVO[] factorVOs, Map<String, Integer> digitsMap) { | ||||
| 		int moneyDigits = 8; | ||||
| 		int priceDigits = 8; | ||||
| 		if (digitsMap != null && digitsMap.size() > 0) { | ||||
| 			// 金额精度 | ||||
| 			moneyDigits = digitsMap.get(nc.vo.cm.meascostcontrast.ResultVO.MoneyDigitsKey); | ||||
| 			priceDigits = digitsMap.get(nc.vo.cm.meascostcontrast.ResultVO.PriceDigitsKey); | ||||
| 		} | ||||
| 
 | ||||
| 		// 页签编码 | ||||
| 		String tablecode = this.getListView().getBillListPanel().getHeadItem(CMCommonConst1614.VCOSTOBJCODE) | ||||
| 				.getTableCode(); | ||||
| 		// 单据列表模板 | ||||
| 		BillListPanel billListPanel = this.getListView().getBillListPanel(); | ||||
| 		int itemSeq = 9; // 该列是第4列 | ||||
| 		// 设置"单位成本"单列 | ||||
| 		BillItem item = CMBillPanelUtils.buildCellItems(tablecode, | ||||
| 				MeasCostUtil.getItemCodeByRule(CMCommonConst1614.NMEASCOST, CMCommonConst1614.NCOST), | ||||
| 				CMLangConst1614.GET_NMEASCOST_NAME(), itemSeq, priceDigits, null); | ||||
| 		itemsList.add(item); | ||||
| 		itemSeq++; | ||||
| 		// 设置"合计"单列 | ||||
| 		item = CMBillPanelUtils.buildCellItems(tablecode, | ||||
| 				MeasCostUtil.getItemCodeByRule(CMCommonConst1614.NSUM, CMCommonConst1614.NCOST), | ||||
| 				CMLangConst1614.GET_NSUM_NAME(), itemSeq, moneyDigits, null); | ||||
| 		itemsList.add(item); | ||||
| 		itemSeq++; | ||||
| 		// 设置"核算要素"列 | ||||
| 		for (FactorVO factorVO : factorVOs) { | ||||
| 			String itemCode = MeasCostUtil.getItemCodeByRule(factorVO.getFactorcode(), CMCommonConst1614.NCOST); | ||||
| 			String itemName = factorVO.getFactorcode() + "-" + CMUtil.getNameByMultiLang(factorVO, FactorVO.FACTORNAME); | ||||
| 
 | ||||
| 			item = CMBillPanelUtils.buildCellItems(tablecode, itemCode, itemName, itemSeq, moneyDigits, null); | ||||
| 			itemsList.add(item); | ||||
| 			itemSeq++; | ||||
| 
 | ||||
| 			this.sumFieldCode.add(itemCode); | ||||
| 		} | ||||
| 		// 设置表头的子列 | ||||
| 		billListPanel.getBillListData().setHeadItems(itemsList.toArray(new BillItem[0])); | ||||
| 		billListPanel.setListData(this.getListView().getBillListPanel().getBillListData()); | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 双层列时,将下层列保存到list,并返回保存表头上下两层列的对应关系Map | ||||
| 	 * | ||||
| 	 * @param itemsList      保存基本列的list | ||||
| 	 * @param factorVOs      "核算要素"动态列初始化所需数据 | ||||
| 	 * @param showDetailDiff 列的显示样式(区分本下阶、显示标准成本、区分成本中心、默认) | ||||
| 	 * @return 保存两层列的对应关系的Map | ||||
| 	 */ | ||||
| 	private MapList<String, String> setDoubleItems(List<BillItem> itemsList, FactorVO[] factorVOs, | ||||
| 			String[] showDetailDiff, Map<String, Integer> digitsMap) { | ||||
| 		int moneyDigits = 8; | ||||
| 		int priceDigits = 8; | ||||
| 		if (digitsMap != null && digitsMap.size() > 0) { | ||||
| 			// 金额精度 | ||||
| 			moneyDigits = digitsMap.get(nc.vo.cm.meascostcontrast.ResultVO.MoneyDigitsKey); | ||||
| 			priceDigits = digitsMap.get(nc.vo.cm.meascostcontrast.ResultVO.PriceDigitsKey); | ||||
| 		} | ||||
| 
 | ||||
| 		// 页签编码 | ||||
| 		String tablecode = this.getListView().getBillListPanel().getHeadItem(CMCommonConst1614.VCOSTOBJCODE) | ||||
| 				.getTableCode(); | ||||
| 		MapList<String, String> itemgroupMapList = new MapList<String, String>(); | ||||
| 		int itemSeq = 9; // 该列是第4列 | ||||
| 		// 设置"单位成本"列 | ||||
| 		for (int i = 0; i < showDetailDiff.length; i++) { | ||||
| 			String itemCode = MeasCostUtil.getItemCodeByRule(CMCommonConst1614.NMEASCOST, showDetailDiff[i]); | ||||
| 			String itemName = MeasCostUtil.getItemNameByCode(showDetailDiff[i]); | ||||
| 			if (CMLangConst1614.GET_NCOST_NAME().equals(itemName)) { | ||||
| 				itemName = CMLangConst1614.GET_ALL_NMEASCOST_NAME(); | ||||
| 			} | ||||
| 			BillItem item = CMBillPanelUtils.buildCellItems(tablecode, itemCode, itemName, itemSeq, priceDigits, null); | ||||
| 			itemsList.add(item); | ||||
| 			itemgroupMapList.put(CMLangConst1614.GET_NMEASCOST_NAME(), item.getKey()); | ||||
| 			itemSeq++; | ||||
| 		} | ||||
| 
 | ||||
| 		// 设置"合计"列 | ||||
| 		for (int i = 0; i < showDetailDiff.length; i++) { | ||||
| 			String itemCode = MeasCostUtil.getItemCodeByRule(CMCommonConst1614.NSUM, showDetailDiff[i]); | ||||
| 			String itemName = MeasCostUtil.getItemNameByCode(showDetailDiff[i]); | ||||
| 			BillItem item = CMBillPanelUtils.buildCellItems(tablecode, itemCode, itemName, itemSeq, moneyDigits, null); | ||||
| 			itemsList.add(item); | ||||
| 			itemgroupMapList.put(CMLangConst1614.GET_NSUM_NAME(), item.getKey()); | ||||
| 			itemSeq++; | ||||
| 		} | ||||
| 		// 设置"核算要素"列 | ||||
| 		for (FactorVO factorVO : factorVOs) { | ||||
| 			String groupItemCode = factorVO.getFactorcode(); | ||||
| 			String itemName = factorVO.getFactorcode() + "-" + CMUtil.getNameByMultiLang(factorVO, FactorVO.FACTORNAME); | ||||
| 
 | ||||
| 			for (int i = 0; i < showDetailDiff.length; i++) { | ||||
| 				BillItem item = CMBillPanelUtils.buildCellItems(tablecode, | ||||
| 						MeasCostUtil.getItemCodeByRule(groupItemCode, showDetailDiff[i]), | ||||
| 						MeasCostUtil.getItemNameByCode(showDetailDiff[i]), itemSeq, moneyDigits, null); | ||||
| 				itemsList.add(item); | ||||
| 				itemgroupMapList.put(itemName, item.getKey()); | ||||
| 				itemSeq++; | ||||
| 
 | ||||
| 				this.sumFieldCode.add(MeasCostUtil.getItemCodeByRule(groupItemCode, showDetailDiff[0])); | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		return itemgroupMapList; | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 前台传往后台的查询参数VO,其中包括: 1.全部查询条件conditions 2.逻辑查询条件map | ||||
| 	 * | ||||
| 	 * @return 查询参数VO | ||||
| 	 */ | ||||
| 	private MeasCostParamVO getMeasCostParamVO(IQueryScheme queryScheme) { | ||||
| 		// 保存查询参数VO | ||||
| 		MeasCostParamVO paramVO = new MeasCostParamVO(); | ||||
| 		// 从查询条件对话框代理取得查询条件VO数组 | ||||
| 		Map<String, CMConditionVO> conditionMap = this.getQueryUtil().getConditionVOMap(queryScheme); | ||||
| 
 | ||||
| 		// 缓存查询条件,供刷新按钮使用 | ||||
| 		((MeasCostAppModel) this.getModel()).setConditionMap(conditionMap); | ||||
| 		((MeasCostAppModel) this.getModel()).setIsDoQuery(true); | ||||
| 		if (CMMapUtil.isNotEmpty(conditionMap)) { | ||||
| 			this.refreshAction.setEnabled(true); | ||||
| 			paramVO.setConditionMap(conditionMap); | ||||
| 		} | ||||
| 		return paramVO; | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 得到单位成本对比表的查询服务接口 | ||||
| 	 * | ||||
| 	 * @return 查询服务接口 | ||||
| 	 */ | ||||
| 	private IMeasCostQueryService getQueryService() { | ||||
| 		return NCLocator.getInstance().lookup(IMeasCostQueryService.class); | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 单据模板的列表视图 | ||||
| 	 */ | ||||
| 	private BillListView listView; | ||||
| 
 | ||||
| 	public BillListView getListView() { | ||||
| 		return this.listView; | ||||
| 	} | ||||
| 
 | ||||
| 	public void setListView(BillListView listView) { | ||||
| 		this.listView = listView; | ||||
| 	} | ||||
| 
 | ||||
| } | ||||
|  | @ -0,0 +1,572 @@ | |||
| package nc.ui.cm.meascostcontrast.action; | ||||
| 
 | ||||
| import java.awt.event.ActionEvent; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.Comparator; | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| 
 | ||||
| import nc.bd.framework.base.CMArrayUtil; | ||||
| import nc.bd.framework.base.CMNumberUtil2; | ||||
| import nc.bs.framework.common.NCLocator; | ||||
| import nc.bs.uif2.IActionCode; | ||||
| import nc.cmpub.business.util.CMUtil; | ||||
| import nc.itf.cm.meascostcontrast.IMeasCostQueryService; | ||||
| import nc.ui.cm.meascostcontrast.view.MeasCostAppModel; | ||||
| import nc.ui.cmpub.business.util.CMBillPanelUtils; | ||||
| import nc.ui.pub.bill.BillItem; | ||||
| import nc.ui.pub.bill.BillListPanel; | ||||
| import nc.ui.pub.bill.IBillItem; | ||||
| import nc.ui.pubapp.uif2app.view.BillListView; | ||||
| import nc.ui.uif2.IShowMsgConstant; | ||||
| import nc.ui.uif2.NCAction; | ||||
| import nc.ui.uif2.ShowStatusBarMsgUtil; | ||||
| import nc.ui.uif2.actions.ActionInitializer; | ||||
| import nc.vo.cm.meascostcontrast.CMCommonConst1614; | ||||
| import nc.vo.cm.meascostcontrast.CMLangConst1614; | ||||
| import nc.vo.cm.meascostcontrast.MeasCostItemVO; | ||||
| import nc.vo.cm.meascostcontrast.MeasCostParamVO; | ||||
| import nc.vo.cm.meascostcontrast.MeasCostQueryConditionVO; | ||||
| import nc.vo.cm.meascostcontrast.MeasCostShowVO; | ||||
| import nc.vo.cm.meascostcontrast.MeasCostUtil; | ||||
| import nc.vo.cmpub.framework.report.CMConditionVO; | ||||
| import nc.vo.pub.BusinessException; | ||||
| import nc.vo.pub.bill.BillTempletBodyVO; | ||||
| import nc.vo.pub.lang.UFDouble; | ||||
| import nc.vo.pubapp.pattern.exception.ExceptionUtils; | ||||
| import nc.vo.pubapp.pattern.pub.MapList; | ||||
| import nc.vo.resa.factor.FactorVO; | ||||
| 
 | ||||
| public class MeasCostRefreshAction extends nc.ui.uif2.actions.RefreshSingleAction { | ||||
| 
 | ||||
| 	private static final long serialVersionUID = 1L; | ||||
| 
 | ||||
| 	private NCAction printAction; | ||||
| 
 | ||||
| 	private NCAction previewAction; | ||||
| 
 | ||||
| 	private NCAction outputAction; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 单据模板的列表视图 | ||||
| 	 */ | ||||
| 	private BillListView listView; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 动态汇总列 | ||||
| 	 */ | ||||
| 	private List<String> sumFieldCode = null; | ||||
| 
 | ||||
| 	public void setPreviewAction(NCAction previewAction) { | ||||
| 		this.previewAction = previewAction; | ||||
| 	} | ||||
| 
 | ||||
| 	public void setPrintAction(NCAction printAction) { | ||||
| 		this.printAction = printAction; | ||||
| 	} | ||||
| 
 | ||||
| 	public void setOutputAction(NCAction outputAction) { | ||||
| 		this.outputAction = outputAction; | ||||
| 	} | ||||
| 
 | ||||
| 	public BillListView getListView() { | ||||
| 		return this.listView; | ||||
| 	} | ||||
| 
 | ||||
| 	public void setListView(BillListView listView) { | ||||
| 		this.listView = listView; | ||||
| 	} | ||||
| 
 | ||||
| 	public MeasCostRefreshAction() { | ||||
| 		super(); | ||||
| 		ActionInitializer.initializeAction(this, IActionCode.REFRESH); | ||||
| 	} | ||||
| 
 | ||||
| 	@Override | ||||
| 	protected boolean isActionEnable() { | ||||
| 		return ((MeasCostAppModel) this.getModel()).getIsDoQuery(); | ||||
| 	} | ||||
| 
 | ||||
| 	@Override | ||||
| 	public void doAction(ActionEvent e) throws Exception { | ||||
| 		this.executeQuery(); | ||||
| 		this.showQueryInfo(); | ||||
| 	} | ||||
| 
 | ||||
| 	private void showQueryInfo() { | ||||
| 		int size = this.getListView().getModel().getRowCount(); | ||||
| 		if (size > 0) { | ||||
| 			int currentSize = size - 1; | ||||
| 			// ShowStatusBarMsgUtil.showStatusBarMsg("刷新成功,共刷新" + size + "条记录。", | ||||
| 			// this.getModel().getContext()); | ||||
| 			ShowStatusBarMsgUtil.showStatusBarMsg( | ||||
| 					nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("pubapp_0", "0pubapp-0266", null, | ||||
| 							new String[] { "" + currentSize })/* @res "刷新成功,共刷新{0}张单据。" */, | ||||
| 					this.getModel().getContext()); | ||||
| 		} else { | ||||
| 			ShowStatusBarMsgUtil.showStatusBarMsg(IShowMsgConstant.getQueryNullInfo(), this.getModel().getContext()); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	private void executeQuery() { | ||||
| 		this.sumFieldCode = new ArrayList<String>(); | ||||
| 
 | ||||
| 		// 取得查询条件 | ||||
| 		MeasCostParamVO paramVO = this.getMeasCostParamVO(); | ||||
| 		// 根据查询条件查询,返回显示VO | ||||
| 		MeasCostShowVO showVO = null; | ||||
| 		try { | ||||
| 			showVO = this.getQueryService().process(paramVO); | ||||
| 		} catch (BusinessException e) { | ||||
| 			ExceptionUtils.wrappException(e); | ||||
| 		} | ||||
| 		// 取得逻辑查询条件 | ||||
| 		Map<String, CMConditionVO> conditionMap = paramVO.getConditionMap(); | ||||
| 		Map<String, List<String>> itemgroupMap = null;// 保存表头上下两层列的对应关系的mapList | ||||
| 
 | ||||
| 		if (showVO != null) { | ||||
| 			Map<String, Integer> digitsMap = showVO.getDigitsMap();// 列表精度信息(单价、数量、金额) | ||||
| 			// 初始化动态表头------动态列只显示有数据的列 | ||||
| 			FactorVO[] factorVOs = this.filteShowFactor(showVO.getFactorVOs(), showVO.getFactorMapShow()); | ||||
| 
 | ||||
| 			if (factorVOs != null) { | ||||
| 				itemgroupMap = this.reBuildItem(conditionMap, factorVOs, digitsMap); | ||||
| 			} | ||||
| 			// 初始化数据 | ||||
| 			List<MeasCostItemVO> itemVOList = showVO.getItemVOList(); | ||||
| 			if (itemVOList != null) { | ||||
| 				MeasCostItemVO[] itemVOs = itemVOList.toArray(new MeasCostItemVO[itemVOList.size()]); | ||||
| 				MeasCostItemVO[] result = this.dealQueryResult(itemVOs); | ||||
| 				this.getListView().getModel().initModel(result); | ||||
| 
 | ||||
| 				if (itemVOList.size() > 0) { | ||||
| 					this.previewAction.setEnabled(true); | ||||
| 					this.printAction.setEnabled(true); | ||||
| 					this.outputAction.setEnabled(true); | ||||
| 				} | ||||
| 
 | ||||
| 			} | ||||
| 		} | ||||
| 		// 如果没有取得任何数据,初始化界面数据为空 | ||||
| 		else { | ||||
| 			this.getListView().getModel().initModel(null); | ||||
| 
 | ||||
| 			this.previewAction.setEnabled(false); | ||||
| 			this.printAction.setEnabled(false); | ||||
| 			this.outputAction.setEnabled(false); | ||||
| 
 | ||||
| 			return; | ||||
| 		} | ||||
| 		// 取得动态列的显示明细区分 | ||||
| 		String[] showDetailDiff = MeasCostUtil.getShowDetailDiff(conditionMap); | ||||
| 		// 单据列表模板 | ||||
| 		BillListPanel billListPanel = this.getListView().getBillListPanel(); | ||||
| 		// 页签编码 | ||||
| 		String tablecode = billListPanel.getHeadItem(CMCommonConst1614.VCOSTOBJCODE).getTableCode(); | ||||
| 		// 表头多层的情况时,设置表头上面一层的列名 | ||||
| 		if (CMArrayUtil.isNotEquals(CMCommonConst1614.DEFAULT_ITEMS, showDetailDiff)) { | ||||
| 			CMBillPanelUtils.createSingleLayMultiHeadTableForHead(billListPanel, tablecode, itemgroupMap); | ||||
| 		} | ||||
| 		// 刷新界面显示 | ||||
| 		this.getListView().getBillListPanel().getHeadTable().getTableHeader().invalidate(); | ||||
| 		this.getListView().getBillListPanel().getParentListPanel().getTable().getTableHeader().validate(); | ||||
| 
 | ||||
| 	} | ||||
| 
 | ||||
| 	private MeasCostItemVO[] dealQueryResult(MeasCostItemVO[] itemVOs) { | ||||
| 		if (CMArrayUtil.isEmpty(itemVOs)) { | ||||
| 			return itemVOs; | ||||
| 		} | ||||
| 
 | ||||
| 		MeasCostItemVO[] result = new MeasCostItemVO[itemVOs.length + 1]; | ||||
| 		UFDouble nsumncost = UFDouble.ZERO_DBL;// 合计 | ||||
| 		UFDouble nnum = UFDouble.ZERO_DBL;// 产量 | ||||
| 		Map<String, UFDouble> sumMap = new HashMap<String, UFDouble>(); | ||||
| 		for (String field : this.sumFieldCode) { | ||||
| 			sumMap.put(field, UFDouble.ZERO_DBL); | ||||
| 		} | ||||
| 
 | ||||
| 		int i = 0; | ||||
| 		for (MeasCostItemVO item : itemVOs) { | ||||
| 			if (item.getNnum() != null) { | ||||
| 				nnum = CMNumberUtil2.add(nnum, item.getNnum()); | ||||
| 			} | ||||
| 			if (item.getAttributeValue("nsumncost") != null) { | ||||
| 				nsumncost = CMNumberUtil2.add(nsumncost, (UFDouble) item.getAttributeValue("nsumncost")); | ||||
| 			} | ||||
| 			for (String key : sumMap.keySet()) { | ||||
| 				UFDouble oldVal = sumMap.get(key); | ||||
| 				if (item.getAttributeValue(key) != null) { | ||||
| 					UFDouble newVal = CMNumberUtil2.add(oldVal, (UFDouble) item.getAttributeValue(key)); | ||||
| 					sumMap.put(key, newVal); | ||||
| 				} | ||||
| 
 | ||||
| 			} | ||||
| 
 | ||||
| 			result[i] = item; | ||||
| 			i++; | ||||
| 		} | ||||
| 
 | ||||
| 		MeasCostItemVO newItem = new MeasCostItemVO(); | ||||
| 		newItem.setCccode(CMLangConst1614.GET_NSUM_NAME());// res:合计 | ||||
| 		newItem.setAttributeValue("nnum", nnum); | ||||
| 		newItem.setAttributeValue("nsumncost", nsumncost); | ||||
| 		for (String key : sumMap.keySet()) { | ||||
| 			newItem.setAttributeValue(key, sumMap.get(key)); | ||||
| 		} | ||||
| 		result[itemVOs.length] = newItem; | ||||
| 
 | ||||
| 		return result; | ||||
| 	} | ||||
| 
 | ||||
| 	private FactorVO[] filteShowFactor(FactorVO[] vos, Map<String, String> factorMapShow) { | ||||
| 		List<FactorVO> tmp = new ArrayList<FactorVO>(); | ||||
| 		String[] factorcodes = factorMapShow.keySet().toArray(new String[0]); | ||||
| 
 | ||||
| 		for (String code : factorcodes) { | ||||
| 			for (FactorVO vo : vos) { | ||||
| 				if (vo.getFactorcode().equals(code)) { | ||||
| 					tmp.add(vo); | ||||
| 					break; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		FactorVO[] result = tmp.toArray(new FactorVO[0]); | ||||
| 		// 对编码进行排序 | ||||
| 		this.sortVOByCode(result); | ||||
| 		return result; | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 按照编码对VO进行排序。 | ||||
| 	 * | ||||
| 	 * @param vos | ||||
| 	 */ | ||||
| 	private void sortVOByCode(FactorVO[] vos) { | ||||
| 		if (vos == null || vos.length < 2) { | ||||
| 			return; | ||||
| 		} | ||||
| 		Arrays.sort(vos, new Comparator<FactorVO>() { | ||||
| 
 | ||||
| 			@Override | ||||
| 			public int compare(FactorVO o1, FactorVO o2) { | ||||
| 				String code1 = (String) o1.getAttributeValue(FactorVO.FACTORCODE); | ||||
| 				String code2 = (String) o2.getAttributeValue(FactorVO.FACTORCODE); | ||||
| 				return code1.compareTo(code2); | ||||
| 			} | ||||
| 		}); | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 重构动态列表头 | ||||
| 	 * | ||||
| 	 * @param factorVOs    "核算要素"动态列初始化所需数据 | ||||
| 	 * @param conditionMap 逻辑查询条件 | ||||
| 	 * @param digitsMap    列表精度----单价、数量、金额 | ||||
| 	 * @return 保存表头上下两层列的对应关系的map | ||||
| 	 */ | ||||
| 	private Map<String, List<String>> reBuildItem(Map<String, CMConditionVO> conditionMap, FactorVO[] factorVOs, | ||||
| 			Map<String, Integer> digitsMap) { | ||||
| 
 | ||||
| 		// 取得列的显示明细区分(区分本下阶、显示标准成本、区分成本中心、默认) | ||||
| 		String[] showDetailDiff = MeasCostUtil.getShowDetailDiff(conditionMap); | ||||
| 		// 取得成本对象的显示方式(成本对象、产品、产品成本分类、产品基本分类) | ||||
| 		Integer ishowtype = MeasCostQueryConditionVO.PRODUCT_VALUE; | ||||
| 		if (conditionMap.containsKey(MeasCostQueryConditionVO.ISHOWTYPE) | ||||
| 				&& conditionMap.get(MeasCostQueryConditionVO.ISHOWTYPE).getSingleValue() != null) { | ||||
| 			ishowtype = Integer.valueOf(conditionMap.get(MeasCostQueryConditionVO.ISHOWTYPE).getSingleValue()); | ||||
| 		} | ||||
| 
 | ||||
| 		// 保存基本列的list | ||||
| 		List<BillItem> itemsList = new ArrayList<BillItem>(); | ||||
| 		// 保存两层列的对应关系 | ||||
| 		MapList<String, String> itemgroupMapList = new MapList<String, String>(); | ||||
| 		// 设置固定的前三列,保存到list | ||||
| 		this.setCodeNameItems(itemsList, ishowtype, digitsMap); | ||||
| 		// 如果显示样式为单层,单层列保存到list | ||||
| 		if (CMArrayUtil.isEquals(CMCommonConst1614.DEFAULT_ITEMS, showDetailDiff)) { | ||||
| 			this.setSingleItems(itemsList, factorVOs, digitsMap); | ||||
| 		} | ||||
| 		// 如果显示样式为双层,双层列的下层列保存到list,并返回保存两层列的对应关系的Map | ||||
| 		else { | ||||
| 			itemgroupMapList = this.setDoubleItems(itemsList, factorVOs, showDetailDiff, digitsMap); | ||||
| 		} | ||||
| 		// 单据列表模板 | ||||
| 		BillListPanel billListPanel = this.getListView().getBillListPanel(); | ||||
| 		// 设置表头的子列 | ||||
| 		billListPanel.getBillListData().setHeadItems(itemsList.toArray(new BillItem[0])); | ||||
| 		billListPanel.setListData(this.getListView().getBillListPanel().getBillListData()); | ||||
| 		return itemgroupMapList.toMap(); | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 设置固定列(包括三个列:产品编码、产品名称、产量) | ||||
| 	 * | ||||
| 	 * @param ishowtype 显示方式(成本对象、产品、产品成本分类、产品基本分类) | ||||
| 	 */ | ||||
| 	private void setCodeNameItems(List<BillItem> itemsList, Integer ishowtype, Map<String, Integer> digitsMap) { | ||||
| 
 | ||||
| 		// 单据列表模板 | ||||
| 		BillListPanel billListPanel = this.getListView().getBillListPanel(); | ||||
| 
 | ||||
| 		// 取得产品编码和产品名称这两列的列名{0:产品编码列名,1:产品名称列名} | ||||
| 		String[] itemNames = this.getItemNameByShowType(ishowtype); | ||||
| 		// 设置"成本中心编码"列 | ||||
| 		BillItem centercodeItem = billListPanel.getHeadItem(CMCommonConst1614.CCCODE); | ||||
| 		centercodeItem.setName(itemNames[0]); | ||||
| 		itemsList.add(centercodeItem); | ||||
| 
 | ||||
| 		// 设置"成本中心名称"列 | ||||
| 		BillItem centernameItem = billListPanel.getHeadItem(CMCommonConst1614.CCNAME); | ||||
| 		centernameItem.setName(itemNames[1]); | ||||
| 		itemsList.add(centernameItem); | ||||
| 		// 设置"产品编码"列 | ||||
| 		BillItem codeItem = billListPanel.getHeadItem(CMCommonConst1614.VCOSTOBJCODE); | ||||
| 		codeItem.setName(itemNames[2]); | ||||
| 		itemsList.add(codeItem); | ||||
| 
 | ||||
| 		// 设置"产品名称"列 | ||||
| 		BillItem nameItem = billListPanel.getHeadItem(CMCommonConst1614.VCOSTOBJNAME); | ||||
| 		nameItem.setName(itemNames[3]); | ||||
| 		itemsList.add(nameItem); | ||||
| 
 | ||||
| 		if (MeasCostQueryConditionVO.COSTOBJECT_VALUE.equals(ishowtype) | ||||
| 				|| MeasCostQueryConditionVO.PRODUCT_VALUE.equals(ishowtype)) { | ||||
| 			// 设置"产品规格"列 | ||||
| 			BillItem materialspecItem = billListPanel.getHeadItem(CMCommonConst1614.MATERIALSPEC); | ||||
| 			materialspecItem.setName(itemNames[4]); | ||||
| 			itemsList.add(materialspecItem); | ||||
| 		} | ||||
| 
 | ||||
| 		if (MeasCostQueryConditionVO.COSTOBJECT_VALUE.equals(ishowtype) | ||||
| 				|| MeasCostQueryConditionVO.PRODUCT_VALUE.equals(ishowtype)) { | ||||
| 			// 设置"产品规格"列 | ||||
| 			BillItem materialspecItem = billListPanel.getHeadItem(CMCommonConst1614.MATERIALTYPE); | ||||
| 			materialspecItem.setName(itemNames[5]); | ||||
| 			itemsList.add(materialspecItem); | ||||
| 		} | ||||
| 
 | ||||
| 		if (MeasCostQueryConditionVO.COSTOBJECT_VALUE.equals(ishowtype) | ||||
| 				|| MeasCostQueryConditionVO.PRODUCT_VALUE.equals(ishowtype)) { | ||||
| 			// 设置"计量单位"列 | ||||
| 			BillItem materialspecItem = billListPanel.getHeadItem(CMCommonConst1614.PK_MEASDOC); | ||||
| 			materialspecItem.setName(itemNames[6]); | ||||
| 			itemsList.add(materialspecItem); | ||||
| 		} | ||||
| 
 | ||||
| 		String tableCode = nameItem.getTableCode(); | ||||
| 		int decimalDigits = nameItem.getDecimalDigits(); | ||||
| 		// 设置"项目编码"列 | ||||
| 		BillItem projectcodeItem = billListPanel.getHeadItem(CMCommonConst1614.PROJECTCODE); | ||||
| 		if (projectcodeItem == null) { | ||||
| 			projectcodeItem = CMBillPanelUtils.buildCellItems(tableCode, CMCommonConst1614.PROJECTCODE, "项目编码", 20, | ||||
| 					decimalDigits, null); | ||||
| 		} | ||||
| 		BillTempletBodyVO bodyVO = nameItem.getBodyVO(); | ||||
| 		projectcodeItem.initItem(bodyVO); | ||||
| 		projectcodeItem.setKey(CMCommonConst1614.PROJECTCODE); | ||||
| 		projectcodeItem.setName("项目编码"); | ||||
| 		// projectcodeItem.setTableCode(tableCode); | ||||
| 		// projectcodeItem.setDecimalDigits(decimalDigits); | ||||
| 		// projectcodeItem.setPk_org(nameItem.getPk_org()); | ||||
| 		itemsList.add(projectcodeItem); | ||||
| 
 | ||||
| 		// 设置"项目名称"列 | ||||
| 		BillItem projectnameItem = billListPanel.getHeadItem(CMCommonConst1614.PROJECTNAME); | ||||
| 		if (projectnameItem == null) { | ||||
| 			projectnameItem = CMBillPanelUtils.buildCellItems(tableCode, CMCommonConst1614.PROJECTNAME, "项目名称", 22, | ||||
| 					decimalDigits, null); | ||||
| 			projectnameItem.setName("项目名称"); | ||||
| 		} | ||||
| 		projectnameItem.initItem(bodyVO); | ||||
| 		projectnameItem.setKey(CMCommonConst1614.PROJECTNAME); | ||||
| 		projectnameItem.setName("项目名称"); | ||||
| 		itemsList.add(projectnameItem); | ||||
| 
 | ||||
| 		// 设置"产量"列 | ||||
| 		BillItem nnumItem = billListPanel.getHeadItem(CMCommonConst1614.NNUM); | ||||
| 		nnumItem.setDecimalDigits(digitsMap.get(MeasCostShowVO.NumDigitsKey)); | ||||
| 		nnumItem.setDataType(IBillItem.DECIMAL); | ||||
| 		itemsList.add(nnumItem); | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 根据显示方式不同,取前两列的列名 | ||||
| 	 * | ||||
| 	 * @param ishowtype 显示方式(成本对象、产品、产品成本分类、产品基本分类) | ||||
| 	 * @return 字符串数组:{0:产品编码列名,1:产品名称列名} | ||||
| 	 */ | ||||
| 	private String[] getItemNameByShowType(Integer ishowtype) { | ||||
| 		String[] itemName = new String[7]; | ||||
| 		itemName[0] = CMLangConst1614.GET_CENTERCODE_NAME(); | ||||
| 		itemName[1] = CMLangConst1614.GET_CENTERNAME_NAME(); | ||||
| 		// 显示方式:成本对象 | ||||
| 		if (MeasCostQueryConditionVO.COSTOBJECT_VALUE.equals(ishowtype)) { | ||||
| 			itemName[2] = CMLangConst1614.GET_OBJECT_CODE_NAME(); | ||||
| 			itemName[3] = CMLangConst1614.GET_OBJECT_NAME(); | ||||
| 		} | ||||
| 		// 显示方式:产品 | ||||
| 		else if (MeasCostQueryConditionVO.PRODUCT_VALUE.equals(ishowtype)) { | ||||
| 			itemName[2] = CMLangConst1614.GET_PRODUCT_CODE_NAME(); | ||||
| 			itemName[3] = CMLangConst1614.GET_PRODUCT_NAME(); | ||||
| 		} | ||||
| 		// 显示方式:产品成本分类 | ||||
| 		else if (MeasCostQueryConditionVO.PRODUCT_COST_VALUE.equals(ishowtype)) { | ||||
| 			itemName[2] = CMLangConst1614.GET_PRODUCT_COST_CODE_NAME(); | ||||
| 			itemName[3] = CMLangConst1614.GET_PRODUCT_COST_NAME(); | ||||
| 		} | ||||
| 		// 显示方式:产品基本分类 | ||||
| 		else if (MeasCostQueryConditionVO.PRODUCT_BASIC_VALUE.equals(ishowtype)) { | ||||
| 			itemName[2] = CMLangConst1614.GET_PRODUCT_BASIC_CODE_NAME(); | ||||
| 			itemName[3] = CMLangConst1614.GET_PRODUCT_BASIC_NAME(); | ||||
| 		} | ||||
| 		itemName[4] = "规格"; | ||||
| 		itemName[5] = "型号"; | ||||
| 		itemName[6] = "计量单位"; | ||||
| 		return itemName; | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 单层列时,将列保存到list | ||||
| 	 * | ||||
| 	 * @param itemsList 保存基本列的list | ||||
| 	 * @param factorVOs "核算要素"动态列初始化所需数据 | ||||
| 	 */ | ||||
| 	private void setSingleItems(List<BillItem> itemsList, FactorVO[] factorVOs, Map<String, Integer> digitsMap) { | ||||
| 		int moneyDigits = 8; | ||||
| 		int priceDigits = 8; | ||||
| 
 | ||||
| 		if (digitsMap != null && digitsMap.size() > 0) { | ||||
| 			// 金额精度 | ||||
| 			moneyDigits = digitsMap.get(nc.vo.cm.meascostcontrast.ResultVO.MoneyDigitsKey); | ||||
| 			priceDigits = digitsMap.get(nc.vo.cm.meascostcontrast.ResultVO.PriceDigitsKey); | ||||
| 		} | ||||
| 
 | ||||
| 		// 页签编码 | ||||
| 		String tablecode = this.getListView().getBillListPanel().getHeadItem(CMCommonConst1614.VCOSTOBJCODE) | ||||
| 				.getTableCode(); | ||||
| 		// 单据列表模板 | ||||
| 		BillListPanel billListPanel = this.getListView().getBillListPanel(); | ||||
| 		int itemSeq = 9; // 该列是第4列 | ||||
| 		// 设置"单位成本"单列 | ||||
| 		BillItem item = CMBillPanelUtils.buildCellItems(tablecode, | ||||
| 				MeasCostUtil.getItemCodeByRule(CMCommonConst1614.NMEASCOST, CMCommonConst1614.NCOST), | ||||
| 				CMLangConst1614.GET_NMEASCOST_NAME(), itemSeq, priceDigits, null); | ||||
| 		itemsList.add(item); | ||||
| 		itemSeq++; | ||||
| 		// 设置"合计"单列 | ||||
| 		item = CMBillPanelUtils.buildCellItems(tablecode, | ||||
| 				MeasCostUtil.getItemCodeByRule(CMCommonConst1614.NSUM, CMCommonConst1614.NCOST), | ||||
| 				CMLangConst1614.GET_NSUM_NAME(), itemSeq, moneyDigits, null); | ||||
| 		itemsList.add(item); | ||||
| 		itemSeq++; | ||||
| 		// 设置"核算要素"列 | ||||
| 		for (FactorVO factorVO : factorVOs) { | ||||
| 			String itemCode = MeasCostUtil.getItemCodeByRule(factorVO.getFactorcode(), CMCommonConst1614.NCOST); | ||||
| 			String itemName = factorVO.getFactorcode() + "-" + CMUtil.getNameByMultiLang(factorVO, FactorVO.FACTORNAME); | ||||
| 
 | ||||
| 			item = CMBillPanelUtils.buildCellItems(tablecode, itemCode, itemName, itemSeq, moneyDigits, null); | ||||
| 			itemsList.add(item); | ||||
| 			itemSeq++; | ||||
| 
 | ||||
| 			this.sumFieldCode.add(itemCode); | ||||
| 		} | ||||
| 		// 设置表头的子列 | ||||
| 		billListPanel.getBillListData().setHeadItems(itemsList.toArray(new BillItem[0])); | ||||
| 		billListPanel.setListData(this.getListView().getBillListPanel().getBillListData()); | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 双层列时,将下层列保存到list,并返回保存表头上下两层列的对应关系Map | ||||
| 	 * | ||||
| 	 * @param itemsList      保存基本列的list | ||||
| 	 * @param factorVOs      "核算要素"动态列初始化所需数据 | ||||
| 	 * @param showDetailDiff 列的显示样式(区分本下阶、显示标准成本、区分成本中心、默认) | ||||
| 	 * @return 保存两层列的对应关系的Map | ||||
| 	 */ | ||||
| 	private MapList<String, String> setDoubleItems(List<BillItem> itemsList, FactorVO[] factorVOs, | ||||
| 			String[] showDetailDiff, Map<String, Integer> digitsMap) { | ||||
| 		int moneyDigits = 8; | ||||
| 		int priceDigits = 8; | ||||
| 
 | ||||
| 		if (digitsMap != null && digitsMap.size() > 0) { | ||||
| 			// 金额精度 | ||||
| 			moneyDigits = digitsMap.get(nc.vo.cm.meascostcontrast.ResultVO.MoneyDigitsKey); | ||||
| 			priceDigits = digitsMap.get(nc.vo.cm.meascostcontrast.ResultVO.PriceDigitsKey); | ||||
| 		} | ||||
| 
 | ||||
| 		// 页签编码 | ||||
| 		String tablecode = this.getListView().getBillListPanel().getHeadItem(CMCommonConst1614.VCOSTOBJCODE) | ||||
| 				.getTableCode(); | ||||
| 		MapList<String, String> itemgroupMapList = new MapList<String, String>(); | ||||
| 		int itemSeq = 9; // 该列是第4列 | ||||
| 		// 设置"单位成本"列 | ||||
| 		for (int i = 0; i < showDetailDiff.length; i++) { | ||||
| 			String itemCode = MeasCostUtil.getItemCodeByRule(CMCommonConst1614.NMEASCOST, showDetailDiff[i]); | ||||
| 			String itemName = MeasCostUtil.getItemNameByCode(showDetailDiff[i]); | ||||
| 			if (CMLangConst1614.GET_NCOST_NAME().equals(itemName)) { | ||||
| 				itemName = CMLangConst1614.GET_ALL_NMEASCOST_NAME(); | ||||
| 			} | ||||
| 			BillItem item = CMBillPanelUtils.buildCellItems(tablecode, itemCode, itemName, itemSeq, priceDigits, null); | ||||
| 			itemsList.add(item); | ||||
| 			itemgroupMapList.put(CMLangConst1614.GET_NMEASCOST_NAME(), item.getKey()); | ||||
| 			itemSeq++; | ||||
| 		} | ||||
| 
 | ||||
| 		// 设置"合计"列 | ||||
| 		for (int i = 0; i < showDetailDiff.length; i++) { | ||||
| 			String itemCode = MeasCostUtil.getItemCodeByRule(CMCommonConst1614.NSUM, showDetailDiff[i]); | ||||
| 			String itemName = MeasCostUtil.getItemNameByCode(showDetailDiff[i]); | ||||
| 			BillItem item = CMBillPanelUtils.buildCellItems(tablecode, itemCode, itemName, itemSeq, moneyDigits, null); | ||||
| 			itemsList.add(item); | ||||
| 			itemgroupMapList.put(CMLangConst1614.GET_NSUM_NAME(), item.getKey()); | ||||
| 			itemSeq++; | ||||
| 		} | ||||
| 		// 设置"核算要素"列 | ||||
| 		for (FactorVO factorVO : factorVOs) { | ||||
| 			String groupItemCode = factorVO.getFactorcode(); | ||||
| 			String itemName = factorVO.getFactorcode() + "-" + CMUtil.getNameByMultiLang(factorVO, FactorVO.FACTORNAME); | ||||
| 
 | ||||
| 			for (int i = 0; i < showDetailDiff.length; i++) { | ||||
| 				BillItem item = CMBillPanelUtils.buildCellItems(tablecode, | ||||
| 						MeasCostUtil.getItemCodeByRule(groupItemCode, showDetailDiff[i]), | ||||
| 						MeasCostUtil.getItemNameByCode(showDetailDiff[i]), itemSeq, moneyDigits, null); | ||||
| 				itemsList.add(item); | ||||
| 				itemgroupMapList.put(itemName, item.getKey()); | ||||
| 				itemSeq++; | ||||
| 
 | ||||
| 				this.sumFieldCode.add(MeasCostUtil.getItemCodeByRule(groupItemCode, showDetailDiff[0])); | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		return itemgroupMapList; | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 前台传往后台的查询参数VO,其中包括: 1.全部查询条件conditions 2.逻辑查询条件map | ||||
| 	 * | ||||
| 	 * @return 查询参数VO | ||||
| 	 */ | ||||
| 	private MeasCostParamVO getMeasCostParamVO() { | ||||
| 		// 缓存查询条件,供刷新按钮使用 | ||||
| 		Map<String, CMConditionVO> conditionMap = ((MeasCostAppModel) this.getModel()).getConditionMap(); | ||||
| 		// 保存查询参数VO | ||||
| 		MeasCostParamVO paramVO = new MeasCostParamVO(); | ||||
| 		paramVO.setConditionMap(conditionMap); | ||||
| 
 | ||||
| 		return paramVO; | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 得到单位成本对比表的查询服务接口 | ||||
| 	 * | ||||
| 	 * @return 查询服务接口 | ||||
| 	 */ | ||||
| 	private IMeasCostQueryService getQueryService() { | ||||
| 		return NCLocator.getInstance().lookup(IMeasCostQueryService.class); | ||||
| 	} | ||||
| 
 | ||||
| } | ||||
|  | @ -156,10 +156,10 @@ public class MeascostcontrastComServiceImpl implements IMeascostcontrastComServi | |||
| 			row.put(CMCommonConst1614.MATERIALSPEC, measCostItemVO.getMaterialspec()); | ||||
| 			row.put(CMCommonConst1614.MATERIALTYPE, measCostItemVO.getMaterialtype()); | ||||
| 			row.put(CMCommonConst1614.PK_MEASDOC, measCostItemVO.getPk_measdoc()); | ||||
| 			 | ||||
| 
 | ||||
| 			// todo 增加项目字段 | ||||
| 			row.put("projectcode", measCostItemVO.getProjectcode()); | ||||
| 			row.put("projectname", measCostItemVO.getProjectname()); | ||||
| 			row.put(CMCommonConst1614.PROJECTCODE, measCostItemVO.getProjectcode()); | ||||
| 			row.put(CMCommonConst1614.PROJECTNAME, measCostItemVO.getProjectname()); | ||||
| 			if (measCostItemVO.getFactorMap() != null) { | ||||
| 				for (String str : measCostItemVO.getFactorMap().keySet()) { | ||||
| 					if (str.equals("nmeascostncost")) {// 单位成本 | ||||
|  | @ -225,11 +225,7 @@ public class MeascostcontrastComServiceImpl implements IMeascostcontrastComServi | |||
| 		// MapList<String, String> itemgroupMapList = new MapList<String, String>(); | ||||
| 		// 设置固定的前三列,保存到list | ||||
| 		this.setCodeNameItems(itemsList, ishowtype, digitsMap); | ||||
| 		 | ||||
| 		// todo | ||||
| 		itemsList.add(new ColumnInfo("ĎîÄżąŕÂë", "projectcode", ColumnInfo.LEFT)); | ||||
| 		itemsList.add(new ColumnInfo("ĎîÄżĂűłĆ", "projectname", ColumnInfo.LEFT)); | ||||
| 		 | ||||
| 
 | ||||
| 		// 如果显示样式为单层,单层列保存到list | ||||
| 		if (CMArrayUtil.isEquals(CMCommonConst1614.DEFAULT_ITEMS, showDetailDiff)) { | ||||
| 			itemsList = this.setSingleItems(itemsList, factorVOs, digitsMap); | ||||
|  | @ -272,6 +268,10 @@ public class MeascostcontrastComServiceImpl implements IMeascostcontrastComServi | |||
| 		itemsList.add(new ColumnInfo("型号", CMCommonConst1614.MATERIALTYPE, ColumnInfo.LEFT)); | ||||
| 		// 设置计量单位 | ||||
| 		itemsList.add(new ColumnInfo("计量单位", CMCommonConst1614.PK_MEASDOC, ColumnInfo.LEFT)); | ||||
| 
 | ||||
| 		// todo | ||||
| 		itemsList.add(new ColumnInfo("ĎîÄżąŕÂë", CMCommonConst1614.PROJECTCODE, ColumnInfo.LEFT)); | ||||
| 		itemsList.add(new ColumnInfo("ĎîÄżĂűłĆ", CMCommonConst1614.PROJECTNAME, ColumnInfo.LEFT)); | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
|  |  | |||
|  | @ -0,0 +1,284 @@ | |||
| package nc.vo.cm.meascostcontrast; | ||||
| 
 | ||||
| /** | ||||
|  * 单位成本对比表-显示控制公共常量 | ||||
|  *  | ||||
|  * @version 2011-6-3 上午10:33:28 | ||||
|  * @author wanghjd | ||||
|  */ | ||||
| public class CMCommonConst1614 { | ||||
| 	/** | ||||
| 	 * 成本中心编码 | ||||
| 	 */ | ||||
| 	public static final String CCCODE = "cccode"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 成本中心名称 | ||||
| 	 */ | ||||
| 	public static final String CCNAME = "ccname"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 产品编码 | ||||
| 	 */ | ||||
| 	public static final String VCOSTOBJCODE = "vcostobjcode"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 产品名称 | ||||
| 	 */ | ||||
| 	public static final String VCOSTOBJNAME = "vcostobjname"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 规格 | ||||
| 	 */ | ||||
| 	public static final String MATERIALSPEC = "materialspec"; | ||||
| 	/** | ||||
| 	 * 型号 | ||||
| 	 */ | ||||
| 	public static final String MATERIALTYPE = "materialtype"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 产品计量单位 | ||||
| 	 */ | ||||
| 	public static final String PK_MEASDOC = "pk_measdoc"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 产品名称:默认主语言下的名称 | ||||
| 	 */ | ||||
| 	public static final String VCOSTOBJNAME0 = "vcostobjname0"; | ||||
| 	 | ||||
| 	/** | ||||
| 	 * 项目编码 | ||||
| 	 */ | ||||
| 	public static final String PROJECTCODE = "projectcode"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 项目名称 | ||||
| 	 */ | ||||
| 	public static final String PROJECTNAME = "projectname"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 产量 | ||||
| 	 */ | ||||
| 	public static final String NNUM = "nnum"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 单位成本 | ||||
| 	 */ | ||||
| 	public static final String NMEASCOST = "nmeascost"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 合计 | ||||
| 	 */ | ||||
| 	public static final String NSUM = "nsum"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 成本 | ||||
| 	 */ | ||||
| 	public static final String NCOST = "ncost"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 金额 | ||||
| 	 */ | ||||
| 	public static final String NMONEY = "nmoney"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 成本对象ID | ||||
| 	 */ | ||||
| 	public static final String CCOSTOBJECTID = "ccostobjectid"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 要素ID | ||||
| 	 */ | ||||
| 	public static final String CELEMENTID = "celementid"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 作业档案ID | ||||
| 	 */ | ||||
| 	public static final String CACTIVITYID = "cactivityid"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 作业相关 | ||||
| 	 */ | ||||
| 	public static final String BACT = "bAct"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 标准成本 | ||||
| 	 */ | ||||
| 	public static final String NSTDCOST = "nstdcost"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 耗量差异 | ||||
| 	 */ | ||||
| 	public static final String NNUMDIFF = "nnumdiff"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 价格差异 | ||||
| 	 */ | ||||
| 	public static final String NPRICEDIFF = "npricediff"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 本阶 | ||||
| 	 */ | ||||
| 	public static final String THISTYPE = "thistype"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 下阶 | ||||
| 	 */ | ||||
| 	public static final String SUBTYPE = "subtype"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 本中心成本 | ||||
| 	 */ | ||||
| 	public static final String THISCENTER = "thiscenter"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 其他中心转入 | ||||
| 	 */ | ||||
| 	public static final String OTHERCENTER = "othercenter"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 核算要素编码 | ||||
| 	 */ | ||||
| 	public static final String FACTORCODE = "factorcode"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 核算要素名称 | ||||
| 	 */ | ||||
| 	public static final String FACTORNAME = "factorname"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 核算要素名称:默认主语言下的名称 | ||||
| 	 */ | ||||
| 	public static final String FACTORNAME0 = "factorname0"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 核算要素级次 | ||||
| 	 */ | ||||
| 	public static final String FACTORlEV = "factorlev"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 管控范围对应的核算要素表主键 | ||||
| 	 */ | ||||
| 	public static final String PK_FACTORASOA = "pk_factorasoa"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 核算要素总成本 | ||||
| 	 */ | ||||
| 	public static final String FACTOR_NSUM = "factornsum"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 成本对象子查询表别名 | ||||
| 	 */ | ||||
| 	public static final String CM_COSTOBJ = "cm_costobj"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 核算要素子查询表别名 | ||||
| 	 */ | ||||
| 	public static final String COST_FACTOR = "cost_factor"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 成本对象表名 | ||||
| 	 */ | ||||
| 	public static final String CM_COSTOBJECT = "cm_costobject"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 区分本下阶 | ||||
| 	 */ | ||||
| 	public static final String BSUBTYPE = "bsubtype"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 区分成本中心 | ||||
| 	 */ | ||||
| 	public static final String BFROMCOSTCENTER = "bfromcostcenter"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 单位成本-标准成本 | ||||
| 	 */ | ||||
| 	public static final String NSTDCOST_NMEASCOST = "nstdcost_nmeascost"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 单位成本-耗量差异 | ||||
| 	 */ | ||||
| 	public static final String NNUMDIFF_NMEASCOST = "nnumdiff_nmeascost"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 单位成本-价格差异 | ||||
| 	 */ | ||||
| 	public static final String NPRICEDIFF_NMEASCOST = "npricediff_nmeascost"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 合计-标准成本 | ||||
| 	 */ | ||||
| 	public static final String NSTDCOST_NSUM = "nstdcost_nsum"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 合计-耗量差异 | ||||
| 	 */ | ||||
| 	public static final String NNUMDIFF_NSUM = "nnumdiff_nsum"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 合计-价格差异 | ||||
| 	 */ | ||||
| 	public static final String NPRICEDIFF_NSUM = "npricediff_nsum"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 核算要素-标准成本 | ||||
| 	 */ | ||||
| 	public static final String NSTDCOST_FACTOR = "nstdcost_factor"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 核算要素-耗量差异 | ||||
| 	 */ | ||||
| 	public static final String NNUMDIFF_FACTOR = "nnumdiff_factor"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 核算要素-价格差异 | ||||
| 	 */ | ||||
| 	public static final String NPRICEDIFF_FACTOR = "npricediff_factor"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 成本表别名 | ||||
| 	 */ | ||||
| 	public static final String CM_COST_TABLE = "cm_cost_table"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 成本子表别名 | ||||
| 	 */ | ||||
| 	public static final String CM_COST_TABLE_B = "cm_cost_table_b"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 完工成本表 、在产成本表 、还原成本表 | ||||
| 	 */ | ||||
| 	public static final String PK = "PK"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 核算要素-关联信息表别名 | ||||
| 	 */ | ||||
| 	public static final String RESA_FACTOR_SUB = "resa_factor_sub"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 物料生产信息表别名1 | ||||
| 	 */ | ||||
| 	public static final String BD_MATERIALPROD_TEMP1 = "bd_materialprod_temp1"; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 物料生产信息表别名2 | ||||
| 	 */ | ||||
| 	public static final String BD_MATERIALPROD_TEMP2 = "bd_materialprod_temp2"; | ||||
| 
 | ||||
| 	/** 区分本下阶成本时的显示字段 */ | ||||
| 	public static String[] SUBTYPE_ITEMS = new String[] { CMCommonConst1614.NCOST, CMCommonConst1614.THISTYPE, | ||||
| 			CMCommonConst1614.SUBTYPE }; | ||||
| 
 | ||||
| 	/** 显示标准成本时的显示字段 */ | ||||
| 	public static String[] STDCOST_ITEMS = new String[] { CMCommonConst1614.NCOST, CMCommonConst1614.NSTDCOST, | ||||
| 			CMCommonConst1614.NNUMDIFF, CMCommonConst1614.NPRICEDIFF }; | ||||
| 
 | ||||
| 	/** 区分成本中心转入时的显示字段 */ | ||||
| 	public static String[] CENTERFROM_ITEMS = new String[] { CMCommonConst1614.NCOST, CMCommonConst1614.THISCENTER, | ||||
| 			CMCommonConst1614.OTHERCENTER }; | ||||
| 
 | ||||
| 	/** 默认的显示字段 */ | ||||
| 	public static String[] DEFAULT_ITEMS = new String[] { CMCommonConst1614.NCOST }; | ||||
| 
 | ||||
| } | ||||
|  | @ -0,0 +1,102 @@ | |||
| package nccloud.web.ic.outbound.sapplybill.action; | ||||
| 
 | ||||
| import java.util.List; | ||||
| import nc.pub.templet.converter.util.helper.ExceptionUtils; | ||||
| import nc.pubitf.pu.m422x.ic.m4455.IQuery422XFor4455; | ||||
| import nc.ui.querytemplate.querytree.IQueryScheme; | ||||
| import nc.vo.ic.pub.util.StringUtil; | ||||
| import nc.vo.ic.pub.util.ValueCheckUtil; | ||||
| import nc.vo.pu.m422x.entity.StoreReqAppVO; | ||||
| import nc.vo.pub.BusinessException; | ||||
| import nc.vo.scmpub.res.billtype.ICBillType; | ||||
| import nccloud.dto.scmpub.page.entity.SCMQueryTreeFormatVO; | ||||
| import nccloud.framework.core.json.IJson; | ||||
| import nccloud.framework.service.ServiceLocator; | ||||
| import nccloud.framework.web.action.itf.ICommonAction; | ||||
| import nccloud.framework.web.container.ClientInfo; | ||||
| import nccloud.framework.web.container.IRequest; | ||||
| import nccloud.framework.web.container.SessionContext; | ||||
| import nccloud.framework.web.json.JsonFactory; | ||||
| import nccloud.framework.web.ui.pattern.billgrid.BillGrid; | ||||
| import nccloud.framework.web.ui.pattern.billgrid.BillGridOperator; | ||||
| import nccloud.nc.vo.pub.pf.PullBillInfoVO; | ||||
| import nccloud.pubitf.ic.pub.service.IICPubQueryService; | ||||
| import nccloud.pubitf.platform.query.INCCloudQueryService; | ||||
| import nccloud.pubitf.riart.businesstype.IPFBusinessTypeService; | ||||
| import nccloud.web.pu.storereq.util.StoreReqScaleUtil; | ||||
| 
 | ||||
| public class Query422XFor4455Action implements ICommonAction { | ||||
| 	public Object doAction(IRequest request) { | ||||
| 		String read = request.read(); | ||||
| 		IJson json = JsonFactory.create(); | ||||
| 		SCMQueryTreeFormatVO info = (SCMQueryTreeFormatVO) json.fromJson(read, SCMQueryTreeFormatVO.class); | ||||
| 
 | ||||
| 		INCCloudQueryService queryutil = (INCCloudQueryService) ServiceLocator.find(INCCloudQueryService.class); | ||||
| 		IQueryScheme scheme = queryutil.convertCondition(info.getQueryInfo()); | ||||
| 
 | ||||
| 		Object transtype = info.getQueryInfo().getUserdefObj().get("transtype"); | ||||
| 		PullBillInfoVO[] refbillinfos = queryRefPara(transtype); | ||||
| 		appendRefWhr(scheme, refbillinfos); | ||||
| 
 | ||||
| 		IICPubQueryService<?, ?> schemeservice = (IICPubQueryService) ServiceLocator.find(IICPubQueryService.class); | ||||
| 
 | ||||
| 		scheme = schemeservice.appendOrgPermission(scheme); | ||||
| 
 | ||||
| 		StoreReqAppVO[] vos = null; | ||||
| 
 | ||||
| 		IQuery422XFor4455 queryService = (IQuery422XFor4455) ServiceLocator.find(IQuery422XFor4455.class); | ||||
| 		try { | ||||
| 			vos = queryService.queryStoreReqAppsFor4455(scheme); | ||||
| 		} catch (BusinessException e) { | ||||
| 			ExceptionUtils.wrapException(e); | ||||
| 		} | ||||
| 		if (null == vos) { | ||||
| 			return null; | ||||
| 		} | ||||
| 		BillGridOperator operator = new BillGridOperator(info.getTempletid(), info.getPageCode()); | ||||
| 		BillGrid[] grids = operator.toBillGrids(vos); | ||||
| 		if (grids != null) { | ||||
| 			StoreReqScaleUtil util = new StoreReqScaleUtil(); | ||||
| 			for (BillGrid billGrid : grids) { | ||||
| 				util.processGrid(billGrid, false); | ||||
| 			} | ||||
| 		} | ||||
| 		return grids; | ||||
| 	} | ||||
| 
 | ||||
| 	private void appendRefWhr(IQueryScheme scheme, PullBillInfoVO[] refbillinfos) { | ||||
| 		if (null == refbillinfos || refbillinfos.length == 0) { | ||||
| 			return; | ||||
| 		} | ||||
| 
 | ||||
| 		for (PullBillInfoVO info : refbillinfos) { | ||||
| 			if ("422X".equals(info.getSrc_billtype())) { | ||||
| 				List<String> busitypes = info.getBusitypes(); | ||||
| 				if (!ValueCheckUtil.isNullORZeroLength(busitypes)) { | ||||
| 					scheme.put("busitypearray", busitypes.toArray(new String[0])); | ||||
| 					List<String> tranList = info.getTranstypes(); | ||||
| 					if (!ValueCheckUtil.isNullORZeroLength(tranList) | ||||
| 							&& !StringUtil.isSEmptyOrNull((String) tranList.get(0))) { | ||||
| 						scheme.put("transtypearray", tranList.toArray(new String[0])); | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	private PullBillInfoVO[] queryRefPara(Object transtype) { | ||||
| 		ClientInfo clientinfo = SessionContext.getInstance().getClientInfo(); | ||||
| 		String groupId = clientinfo.getPk_group(); | ||||
| 		String userId = clientinfo.getUserid(); | ||||
| 
 | ||||
| 		IPFBusinessTypeService pfservice = (IPFBusinessTypeService) ServiceLocator.find(IPFBusinessTypeService.class); | ||||
| 		PullBillInfoVO[] refbillinfos = null; | ||||
| 		try { | ||||
| 			refbillinfos = pfservice.getPullBillInfo(ICBillType.SapplyBill.getCode(), | ||||
| 					(null == transtype) ? null : (String) transtype, groupId, userId); | ||||
| 		} catch (BusinessException e) { | ||||
| 			ExceptionUtils.wrapException(e); | ||||
| 		} | ||||
| 		return refbillinfos; | ||||
| 	} | ||||
| } | ||||
|  | @ -0,0 +1,102 @@ | |||
| package nccloud.web.ic.outbound.sapplybill.action; | ||||
| 
 | ||||
| import java.util.List; | ||||
| import nc.pub.templet.converter.util.helper.ExceptionUtils; | ||||
| import nc.pubitf.pu.m422x.ic.m4455.IQuery422XFor4455; | ||||
| import nc.ui.querytemplate.querytree.IQueryScheme; | ||||
| import nc.vo.ic.pub.util.StringUtil; | ||||
| import nc.vo.ic.pub.util.ValueCheckUtil; | ||||
| import nc.vo.pu.m422x.entity.StoreReqAppVO; | ||||
| import nc.vo.pub.BusinessException; | ||||
| import nc.vo.scmpub.res.billtype.ICBillType; | ||||
| import nccloud.dto.scmpub.page.entity.SCMQueryTreeFormatVO; | ||||
| import nccloud.framework.core.json.IJson; | ||||
| import nccloud.framework.service.ServiceLocator; | ||||
| import nccloud.framework.web.action.itf.ICommonAction; | ||||
| import nccloud.framework.web.container.ClientInfo; | ||||
| import nccloud.framework.web.container.IRequest; | ||||
| import nccloud.framework.web.container.SessionContext; | ||||
| import nccloud.framework.web.json.JsonFactory; | ||||
| import nccloud.framework.web.ui.pattern.billgrid.BillGrid; | ||||
| import nccloud.framework.web.ui.pattern.billgrid.BillGridOperator; | ||||
| import nccloud.nc.vo.pub.pf.PullBillInfoVO; | ||||
| import nccloud.pubitf.ic.pub.service.IICPubQueryService; | ||||
| import nccloud.pubitf.platform.query.INCCloudQueryService; | ||||
| import nccloud.pubitf.riart.businesstype.IPFBusinessTypeService; | ||||
| import nccloud.web.pu.storereq.util.StoreReqScaleUtil; | ||||
| 
 | ||||
| public class QueryBljhXFor4455Action implements ICommonAction { | ||||
| 	public Object doAction(IRequest request) { | ||||
| 		String read = request.read(); | ||||
| 		IJson json = JsonFactory.create(); | ||||
| 		SCMQueryTreeFormatVO info = (SCMQueryTreeFormatVO) json.fromJson(read, SCMQueryTreeFormatVO.class); | ||||
| 
 | ||||
| 		INCCloudQueryService queryutil = (INCCloudQueryService) ServiceLocator.find(INCCloudQueryService.class); | ||||
| 		IQueryScheme scheme = queryutil.convertCondition(info.getQueryInfo()); | ||||
| 
 | ||||
| 		Object transtype = info.getQueryInfo().getUserdefObj().get("transtype"); | ||||
| 		PullBillInfoVO[] refbillinfos = queryRefPara(transtype); | ||||
| 		appendRefWhr(scheme, refbillinfos); | ||||
| 
 | ||||
| 		IICPubQueryService<?, ?> schemeservice = (IICPubQueryService) ServiceLocator.find(IICPubQueryService.class); | ||||
| 
 | ||||
| 		scheme = schemeservice.appendOrgPermission(scheme); | ||||
| 
 | ||||
| 		StoreReqAppVO[] vos = null; | ||||
| 
 | ||||
| 		IQuery422XFor4455 queryService = (IQuery422XFor4455) ServiceLocator.find(IQuery422XFor4455.class); | ||||
| 		try { | ||||
| 			vos = queryService.queryStoreReqAppsFor4455(scheme); | ||||
| 		} catch (BusinessException e) { | ||||
| 			ExceptionUtils.wrapException(e); | ||||
| 		} | ||||
| 		if (null == vos) { | ||||
| 			return null; | ||||
| 		} | ||||
| 		BillGridOperator operator = new BillGridOperator(info.getTempletid(), info.getPageCode()); | ||||
| 		BillGrid[] grids = operator.toBillGrids(vos); | ||||
| 		if (grids != null) { | ||||
| 			StoreReqScaleUtil util = new StoreReqScaleUtil(); | ||||
| 			for (BillGrid billGrid : grids) { | ||||
| 				util.processGrid(billGrid, false); | ||||
| 			} | ||||
| 		} | ||||
| 		return grids; | ||||
| 	} | ||||
| 
 | ||||
| 	private void appendRefWhr(IQueryScheme scheme, PullBillInfoVO[] refbillinfos) { | ||||
| 		if (null == refbillinfos || refbillinfos.length == 0) { | ||||
| 			return; | ||||
| 		} | ||||
| 
 | ||||
| 		for (PullBillInfoVO info : refbillinfos) { | ||||
| 			if ("422X".equals(info.getSrc_billtype())) { | ||||
| 				List<String> busitypes = info.getBusitypes(); | ||||
| 				if (!ValueCheckUtil.isNullORZeroLength(busitypes)) { | ||||
| 					scheme.put("busitypearray", busitypes.toArray(new String[0])); | ||||
| 					List<String> tranList = info.getTranstypes(); | ||||
| 					if (!ValueCheckUtil.isNullORZeroLength(tranList) | ||||
| 							&& !StringUtil.isSEmptyOrNull((String) tranList.get(0))) { | ||||
| 						scheme.put("transtypearray", tranList.toArray(new String[0])); | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	private PullBillInfoVO[] queryRefPara(Object transtype) { | ||||
| 		ClientInfo clientinfo = SessionContext.getInstance().getClientInfo(); | ||||
| 		String groupId = clientinfo.getPk_group(); | ||||
| 		String userId = clientinfo.getUserid(); | ||||
| 
 | ||||
| 		IPFBusinessTypeService pfservice = (IPFBusinessTypeService) ServiceLocator.find(IPFBusinessTypeService.class); | ||||
| 		PullBillInfoVO[] refbillinfos = null; | ||||
| 		try { | ||||
| 			refbillinfos = pfservice.getPullBillInfo(ICBillType.SapplyBill.getCode(), | ||||
| 					(null == transtype) ? null : (String) transtype, groupId, userId); | ||||
| 		} catch (BusinessException e) { | ||||
| 			ExceptionUtils.wrapException(e); | ||||
| 		} | ||||
| 		return refbillinfos; | ||||
| 	} | ||||
| } | ||||
		Loading…
	
		Reference in New Issue