单位成本对比表
This commit is contained in:
parent
431515e1fb
commit
f3fd6fde63
|
@ -0,0 +1,225 @@
|
|||
package nc.vo.cm.meascostcontrast;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import nc.bd.framework.base.CMStringUtil;
|
||||
import nc.vo.pub.BeanHelper;
|
||||
import nc.vo.pub.SuperVO;
|
||||
import nc.vo.pub.lang.UFDouble;
|
||||
|
||||
/**
|
||||
* 单位成本对比表-界面显示的数据VO
|
||||
*
|
||||
* @since 6.0
|
||||
* @version 2011-7-14 下午05:04:12
|
||||
* @author wanghjd
|
||||
*/
|
||||
public class MeasCostItemVO extends SuperVO {
|
||||
|
||||
private static final long serialVersionUID = 50098708851615159L;
|
||||
|
||||
/**
|
||||
* 产品规格
|
||||
*/
|
||||
private String materialspec;
|
||||
|
||||
private String materialtype;
|
||||
|
||||
/**
|
||||
* 产品计量单位
|
||||
*/
|
||||
private String pk_measdoc;
|
||||
|
||||
/**
|
||||
* 成本中心编码
|
||||
*/
|
||||
private String cccode;
|
||||
|
||||
/**
|
||||
* 成本中心名称
|
||||
*/
|
||||
private String ccname;
|
||||
|
||||
/**
|
||||
* 产品编码
|
||||
*/
|
||||
private String vcostobjcode;
|
||||
|
||||
/**
|
||||
* 产品名称
|
||||
*/
|
||||
private String vcostobjname;
|
||||
|
||||
/**
|
||||
* 产品名称:默认主语言下的名称
|
||||
*/
|
||||
private String vcostobjname0;
|
||||
|
||||
/**
|
||||
* 产量
|
||||
*/
|
||||
private UFDouble nnum;
|
||||
|
||||
/**
|
||||
* 项目编码
|
||||
*/
|
||||
private String projectcode;
|
||||
|
||||
/**
|
||||
* 项目名称
|
||||
*/
|
||||
private String projectname;
|
||||
|
||||
// 保存动态属性的值
|
||||
private Map<String, Object> factorMap = new HashMap<String, Object>();
|
||||
|
||||
public Map<String, Object> getFactorMap() {
|
||||
return this.factorMap;
|
||||
}
|
||||
|
||||
public void setFactorMap(Map<String, Object> factorMap) {
|
||||
this.factorMap = factorMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttributeValue(String name, Object value) {
|
||||
this.factorMap.put(name, value);
|
||||
this.setFactorMap(this.factorMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAttributeValue(String name) {
|
||||
if (!this.getFactorMap().containsKey(name)) {
|
||||
Object value = BeanHelper.getProperty(this, name);
|
||||
if (value instanceof UFDouble) {
|
||||
// 如果金额是0,那么返回空
|
||||
if (UFDouble.ZERO_DBL.equals(value)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
Object value = this.getFactorMap().get(name);
|
||||
if (value instanceof UFDouble) {
|
||||
if (UFDouble.ZERO_DBL.equals(value)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == null || !(o instanceof MeasCostItemVO)) {
|
||||
return false;
|
||||
}
|
||||
MeasCostItemVO vo = (MeasCostItemVO) o;
|
||||
if (this.getVcostobjcode().equals(vo.getVcostobjcode())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode();
|
||||
}
|
||||
|
||||
public String getCccode() {
|
||||
return this.cccode;
|
||||
}
|
||||
|
||||
public void setCccode(String vcostcentercode) {
|
||||
this.cccode = vcostcentercode;
|
||||
}
|
||||
|
||||
public String getCcname() {
|
||||
return this.ccname;
|
||||
}
|
||||
|
||||
public void setCcname(String vcostcentername) {
|
||||
this.ccname = vcostcentername;
|
||||
}
|
||||
|
||||
public String getVcostobjcode() {
|
||||
return this.vcostobjcode;
|
||||
}
|
||||
|
||||
public void setVcostobjcode(String vcostobjcode) {
|
||||
this.vcostobjcode = vcostobjcode;
|
||||
}
|
||||
|
||||
public String getVcostobjname() {
|
||||
if (CMStringUtil.isNotEmpty(this.vcostobjname)) {
|
||||
return this.vcostobjname;
|
||||
}
|
||||
return this.vcostobjname0;
|
||||
|
||||
}
|
||||
|
||||
public void setVcostobjname(String vcostobjname) {
|
||||
this.vcostobjname = vcostobjname;
|
||||
}
|
||||
|
||||
public String getVcostobjname0() {
|
||||
return this.vcostobjname0;
|
||||
}
|
||||
|
||||
public void setVcostobjname0(String vcostobjname0) {
|
||||
this.vcostobjname0 = vcostobjname0;
|
||||
}
|
||||
|
||||
public UFDouble getNnum() {
|
||||
return this.nnum;
|
||||
}
|
||||
|
||||
public void setNnum(UFDouble nnum) {
|
||||
this.nnum = nnum;
|
||||
}
|
||||
|
||||
public String getProjectcode() {
|
||||
return this.projectcode;
|
||||
}
|
||||
|
||||
public void setProjectcode(String projectcode) {
|
||||
this.projectcode = projectcode;
|
||||
}
|
||||
|
||||
public String getProjectname() {
|
||||
return this.projectname;
|
||||
}
|
||||
|
||||
public void setProjectname(String projectname) {
|
||||
this.projectname = projectname;
|
||||
}
|
||||
|
||||
public void setAttrbuteByRule(String groupItemCode, String subItemCode, Object value) {
|
||||
String code = MeasCostUtil.getItemCodeByRule(groupItemCode, subItemCode);
|
||||
this.setAttributeValue(code, value);
|
||||
}
|
||||
|
||||
public String getMaterialspec() {
|
||||
return this.materialspec;
|
||||
}
|
||||
|
||||
public void setMaterialspec(String materialspec) {
|
||||
this.materialspec = materialspec;
|
||||
}
|
||||
|
||||
public String getPk_measdoc() {
|
||||
return this.pk_measdoc;
|
||||
}
|
||||
|
||||
public void setPk_measdoc(String pk_measdoc) {
|
||||
this.pk_measdoc = pk_measdoc;
|
||||
}
|
||||
|
||||
public String getMaterialtype() {
|
||||
return materialtype;
|
||||
}
|
||||
|
||||
public void setMaterialtype(String materialtype) {
|
||||
this.materialtype = materialtype;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,419 @@
|
|||
package nc.vo.cm.meascostcontrast;
|
||||
|
||||
import nc.bd.framework.base.CMStringUtil;
|
||||
import nc.vo.pub.SuperVO;
|
||||
import nc.vo.pub.lang.UFDouble;
|
||||
|
||||
/**
|
||||
* 单位成本对比表-查询结果VO
|
||||
*
|
||||
* @since 6.0
|
||||
* @version 2011-7-14 下午05:09:49
|
||||
* @author wanghjd
|
||||
*/
|
||||
public class MeasCostQueryResultVO extends SuperVO {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 产品规格
|
||||
*/
|
||||
private String materialspec;
|
||||
|
||||
/**
|
||||
* 产品规格
|
||||
*/
|
||||
private String materialtype;
|
||||
|
||||
/**
|
||||
* 产品计量单位
|
||||
*/
|
||||
private String pk_measdoc;
|
||||
|
||||
/**
|
||||
* 成本中心编码
|
||||
*/
|
||||
private String cccode;
|
||||
|
||||
/**
|
||||
* 成本中心名称
|
||||
*/
|
||||
private String ccname;
|
||||
|
||||
/**
|
||||
* 产品编码
|
||||
*/
|
||||
private String vcostobjcode;
|
||||
|
||||
/**
|
||||
* 产品名称
|
||||
*/
|
||||
private String vcostobjname;
|
||||
|
||||
/**
|
||||
* 产品名称:默认主语言下的名称
|
||||
*/
|
||||
private String vcostobjname0;
|
||||
|
||||
/**
|
||||
* 产量
|
||||
*/
|
||||
private UFDouble nnum;
|
||||
|
||||
/**
|
||||
* 单位成本
|
||||
*/
|
||||
private UFDouble nmeascost;
|
||||
|
||||
/**
|
||||
* 合计
|
||||
*/
|
||||
private UFDouble nsum;
|
||||
|
||||
/**
|
||||
* 核算要素编码
|
||||
*/
|
||||
private String factorcode;
|
||||
|
||||
/**
|
||||
* 核算要素名称
|
||||
*/
|
||||
private String factorname;
|
||||
|
||||
/**
|
||||
* 核算要素名称:默认主语言下的名称
|
||||
*/
|
||||
private String factorname0;
|
||||
|
||||
/**
|
||||
* 核算要素总成本
|
||||
*/
|
||||
private UFDouble factorNsum;
|
||||
|
||||
/**
|
||||
* 是否本下阶
|
||||
*/
|
||||
private String bsubtype;
|
||||
|
||||
/**
|
||||
* 是否来源于其他成本中心
|
||||
*/
|
||||
private String bfromcostcenter;
|
||||
|
||||
/**
|
||||
* 单位成本-标准成本
|
||||
*/
|
||||
private UFDouble nstdcostNmeascost;
|
||||
|
||||
/**
|
||||
* 单位成本-耗量差异
|
||||
*/
|
||||
private UFDouble nnumdiffNmeascost;
|
||||
|
||||
/**
|
||||
* 单位成本-价格差异
|
||||
*/
|
||||
private UFDouble npricediffNmeascost;
|
||||
|
||||
/**
|
||||
* 合计-标准成本
|
||||
*/
|
||||
private UFDouble nstdcostNsum;
|
||||
|
||||
/**
|
||||
* 合计-耗量差异
|
||||
*/
|
||||
private UFDouble nnumdiffNsum;
|
||||
|
||||
/**
|
||||
* 合计-价格差异
|
||||
*/
|
||||
private UFDouble npricediffNsum;
|
||||
|
||||
/**
|
||||
* 核算要素-标准成本
|
||||
*/
|
||||
private UFDouble nstdcostFactor;
|
||||
|
||||
/**
|
||||
* 核算要素-耗量差异
|
||||
*/
|
||||
private UFDouble nnumdiffFactor;
|
||||
|
||||
/**
|
||||
* 核算要素-价格差异
|
||||
*/
|
||||
private UFDouble npricediffFactor;
|
||||
|
||||
/**
|
||||
* 核算要素级次
|
||||
*/
|
||||
private String factorLev;
|
||||
|
||||
/**
|
||||
* 核算要素主键:resa_factorasoa.pk_factorasoa=cm_costobject.ccostobjectid
|
||||
*/
|
||||
private String pk_factorasoa;
|
||||
|
||||
/**
|
||||
* 项目编码
|
||||
*/
|
||||
private String projectcode;
|
||||
|
||||
/**
|
||||
* 项目名称
|
||||
*/
|
||||
private String projectname;
|
||||
|
||||
public String getPK_factorasoa() {
|
||||
return this.pk_factorasoa;
|
||||
}
|
||||
|
||||
public void setPK_factorasoa(String pk_factorasoa) {
|
||||
this.pk_factorasoa = pk_factorasoa;
|
||||
}
|
||||
|
||||
public String getFactorLev() {
|
||||
return this.factorLev;
|
||||
}
|
||||
|
||||
public String getMaterialspec() {
|
||||
return this.materialspec;
|
||||
}
|
||||
|
||||
public void setMaterialspec(String materialspec) {
|
||||
this.materialspec = materialspec;
|
||||
}
|
||||
|
||||
public String getPk_measdoc() {
|
||||
return this.pk_measdoc;
|
||||
}
|
||||
|
||||
public void setPk_measdoc(String pk_measdoc) {
|
||||
this.pk_measdoc = pk_measdoc;
|
||||
}
|
||||
|
||||
public void setFactorLev(String factorLev) {
|
||||
this.factorLev = factorLev;
|
||||
}
|
||||
|
||||
public String getCccode() {
|
||||
return this.cccode;
|
||||
}
|
||||
|
||||
public void setCccode(String vcostcentercode) {
|
||||
this.cccode = vcostcentercode;
|
||||
}
|
||||
|
||||
public String getCcname() {
|
||||
return this.ccname;
|
||||
}
|
||||
|
||||
public void setCcname(String vcostcentername) {
|
||||
this.ccname = vcostcentername;
|
||||
}
|
||||
|
||||
public String getVcostobjcode() {
|
||||
return this.vcostobjcode;
|
||||
}
|
||||
|
||||
public void setVcostobjcode(String vcostobjcode) {
|
||||
this.vcostobjcode = vcostobjcode;
|
||||
}
|
||||
|
||||
public String getVcostobjname() {
|
||||
if (CMStringUtil.isNotEmpty(this.vcostobjname)) {
|
||||
return this.vcostobjname;
|
||||
} else {
|
||||
return this.vcostobjname0;
|
||||
}
|
||||
}
|
||||
|
||||
public void setVcostobjname(String vcostobjname) {
|
||||
this.vcostobjname = vcostobjname;
|
||||
}
|
||||
|
||||
public String getVcostobjname0() {
|
||||
return this.vcostobjname0;
|
||||
}
|
||||
|
||||
public void setVcostobjname0(String vcostobjname0) {
|
||||
this.vcostobjname0 = vcostobjname0;
|
||||
}
|
||||
|
||||
public UFDouble getNnum() {
|
||||
return this.nnum;
|
||||
}
|
||||
|
||||
public void setNnum(UFDouble nnum) {
|
||||
this.nnum = nnum;
|
||||
}
|
||||
|
||||
public UFDouble getNmeascost() {
|
||||
return this.nmeascost;
|
||||
}
|
||||
|
||||
public void setNmeascost(UFDouble nmeascost) {
|
||||
this.nmeascost = nmeascost;
|
||||
}
|
||||
|
||||
public UFDouble getNsum() {
|
||||
return this.nsum;
|
||||
}
|
||||
|
||||
public void setNsum(UFDouble nsum) {
|
||||
this.nsum = nsum;
|
||||
}
|
||||
|
||||
public String getFactorcode() {
|
||||
return this.factorcode;
|
||||
}
|
||||
|
||||
public void setFactorcode(String factorcode) {
|
||||
this.factorcode = factorcode;
|
||||
}
|
||||
|
||||
public String getFactorname() {
|
||||
|
||||
if (CMStringUtil.isNotEmpty(this.factorname)) {
|
||||
return this.factorname;
|
||||
} else {
|
||||
return this.factorname0;
|
||||
}
|
||||
}
|
||||
|
||||
public void setFactorname(String factorname) {
|
||||
this.factorname = factorname;
|
||||
}
|
||||
|
||||
public String getFactorname0() {
|
||||
return this.factorname0;
|
||||
}
|
||||
|
||||
public void setFactorname0(String factorname0) {
|
||||
this.factorname0 = factorname0;
|
||||
}
|
||||
|
||||
public UFDouble getFactorNsum() {
|
||||
return this.factorNsum;
|
||||
}
|
||||
|
||||
public void setFactorNsum(UFDouble factorNsum) {
|
||||
this.factorNsum = factorNsum;
|
||||
}
|
||||
|
||||
public String getBsubtype() {
|
||||
return this.bsubtype;
|
||||
}
|
||||
|
||||
public void setBsubtype(String bsubtype) {
|
||||
this.bsubtype = bsubtype;
|
||||
}
|
||||
|
||||
public String getBfromcostcenter() {
|
||||
return this.bfromcostcenter;
|
||||
}
|
||||
|
||||
public void setBfromcostcenter(String bfromcostcenter) {
|
||||
this.bfromcostcenter = bfromcostcenter;
|
||||
}
|
||||
|
||||
public UFDouble getNstdcostNmeascost() {
|
||||
return this.nstdcostNmeascost;
|
||||
}
|
||||
|
||||
public void setNstdcostNmeascost(UFDouble nstdcostNmeascost) {
|
||||
this.nstdcostNmeascost = nstdcostNmeascost;
|
||||
}
|
||||
|
||||
public UFDouble getNnumdiffNmeascost() {
|
||||
return this.nnumdiffNmeascost;
|
||||
}
|
||||
|
||||
public void setNnumdiffNmeascost(UFDouble nnumdiffNmeascost) {
|
||||
this.nnumdiffNmeascost = nnumdiffNmeascost;
|
||||
}
|
||||
|
||||
public UFDouble getNpricediffNmeascost() {
|
||||
return this.npricediffNmeascost;
|
||||
}
|
||||
|
||||
public void setNpricediffNmeascost(UFDouble npricediffNmeascost) {
|
||||
this.npricediffNmeascost = npricediffNmeascost;
|
||||
}
|
||||
|
||||
public UFDouble getNstdcostNsum() {
|
||||
return this.nstdcostNsum;
|
||||
}
|
||||
|
||||
public void setNstdcostNsum(UFDouble nstdcostNsum) {
|
||||
this.nstdcostNsum = nstdcostNsum;
|
||||
}
|
||||
|
||||
public UFDouble getNnumdiffNsum() {
|
||||
return this.nnumdiffNsum;
|
||||
}
|
||||
|
||||
public void setNnumdiffNsum(UFDouble nnumdiffNsum) {
|
||||
this.nnumdiffNsum = nnumdiffNsum;
|
||||
}
|
||||
|
||||
public UFDouble getNpricediffNsum() {
|
||||
return this.npricediffNsum;
|
||||
}
|
||||
|
||||
public void setNpricediffNsum(UFDouble npricediffNsum) {
|
||||
this.npricediffNsum = npricediffNsum;
|
||||
}
|
||||
|
||||
public UFDouble getNstdcostFactor() {
|
||||
return this.nstdcostFactor;
|
||||
}
|
||||
|
||||
public void setNstdcostFactor(UFDouble nstdcostFactor) {
|
||||
this.nstdcostFactor = nstdcostFactor;
|
||||
}
|
||||
|
||||
public UFDouble getNnumdiffFactor() {
|
||||
return this.nnumdiffFactor;
|
||||
}
|
||||
|
||||
public void setNnumdiffFactor(UFDouble nnumdiffFactor) {
|
||||
this.nnumdiffFactor = nnumdiffFactor;
|
||||
}
|
||||
|
||||
public UFDouble getNpricediffFactor() {
|
||||
return this.npricediffFactor;
|
||||
}
|
||||
|
||||
public void setNpricediffFactor(UFDouble npricediffFactor) {
|
||||
this.npricediffFactor = npricediffFactor;
|
||||
}
|
||||
|
||||
public String getMaterialtype() {
|
||||
return materialtype;
|
||||
}
|
||||
|
||||
public void setMaterialtype(String materialtype) {
|
||||
this.materialtype = materialtype;
|
||||
}
|
||||
|
||||
public String getProjectcode() {
|
||||
return this.projectcode;
|
||||
}
|
||||
|
||||
public void setProjectcode(String projectcode) {
|
||||
this.projectcode = projectcode;
|
||||
}
|
||||
|
||||
public String getProjectname() {
|
||||
return this.projectname;
|
||||
}
|
||||
|
||||
public void setProjectname(String projectname) {
|
||||
this.projectname = projectname;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,466 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package nccloud.pubimpl.cm.cmreport.meascostcontrast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
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.cmpub.business.util.CMUtil;
|
||||
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.lang.UFDouble;
|
||||
import nc.vo.resa.factor.FactorVO;
|
||||
import nccloud.pubitf.cm.meascostcontrast.ColumnInfo;
|
||||
import nccloud.pubitf.cm.meascostcontrast.ColumnMultiHeadInfo;
|
||||
import nccloud.pubitf.cm.meascostcontrast.IColumnInfo;
|
||||
import nccloud.pubitf.cm.meascostcontrast.IMeascostcontrastComService;
|
||||
|
||||
/**
|
||||
* @since v6.3
|
||||
* @version 2019-4-29 上午11:02:23
|
||||
* @author wangjwt
|
||||
*/
|
||||
public class MeascostcontrastComServiceImpl implements IMeascostcontrastComService {
|
||||
/**
|
||||
* 动态汇总列
|
||||
*/
|
||||
private List<String> sumFieldCode = null;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryMeascostcontrast(MeasCostShowVO showVO, MeasCostParamVO paramVO)
|
||||
throws BusinessException {
|
||||
this.sumFieldCode = new ArrayList<String>();
|
||||
// 取得逻辑查询条件
|
||||
Map<String, CMConditionVO> conditionMap = paramVO.getConditionMap();
|
||||
// 获取动态处理完的列
|
||||
List<IColumnInfo> itemgroupMap = null;
|
||||
// 返回处理完整的列对应的数据
|
||||
List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
|
||||
// 返回总的结果
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
// 调用方法进行具体处理
|
||||
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()]);
|
||||
data = this.dealQueryResult(itemVOs, digitsMap);
|
||||
this.sortVOByCode2(data);
|
||||
}
|
||||
|
||||
}
|
||||
result.put("column", itemgroupMap);
|
||||
result.put("data", data);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按照编码对VO进行排序。
|
||||
*
|
||||
* @param vos
|
||||
*/
|
||||
private void sortVOByCode2(List<Map<String, Object>> data) {
|
||||
if (data != null) {
|
||||
Collections.sort(data, new Comparator<Map<String, Object>>() {
|
||||
@Override
|
||||
public int compare(Map<String, Object> o1, Map<String, Object> o2) {
|
||||
int flag;
|
||||
// // 首选按成本中心升序排序
|
||||
String code1 = (String) o1.get("cccode");
|
||||
String code2 = (String) o2.get("cccode");
|
||||
flag = code1.compareTo(code2);
|
||||
if (flag == 0) {
|
||||
// 再按产品编码升序排序
|
||||
code1 = (String) o1.get("vcostobjcode");
|
||||
code2 = (String) o2.get("vcostobjcode");
|
||||
flag = code1.compareTo(code2);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private List<Map<String, Object>> dealQueryResult(MeasCostItemVO[] itemVOs, Map<String, Integer> digitsMap) {
|
||||
if (CMArrayUtil.isEmpty(itemVOs)) {
|
||||
return null;
|
||||
}
|
||||
List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
|
||||
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;
|
||||
for (MeasCostItemVO measCostItemVO : result) {
|
||||
Map<String, Object> row = new HashMap<String, Object>();
|
||||
row.put(CMCommonConst1614.CCCODE, measCostItemVO.getCccode());
|
||||
row.put(CMCommonConst1614.CCNAME, measCostItemVO.getCcname());
|
||||
row.put(CMCommonConst1614.VCOSTOBJCODE, measCostItemVO.getVcostobjcode());
|
||||
row.put(CMCommonConst1614.VCOSTOBJNAME, measCostItemVO.getVcostobjname());
|
||||
row.put(CMCommonConst1614.NNUM,
|
||||
this.setColumnScale(measCostItemVO.getNnum(), digitsMap.get("NumDigitsKey")));// 产量
|
||||
// 增加两个个字段
|
||||
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());
|
||||
if (measCostItemVO.getFactorMap() != null) {
|
||||
for (String str : measCostItemVO.getFactorMap().keySet()) {
|
||||
if (str.equals("nmeascostncost")) {// 单位成本
|
||||
row.put(str, this.setColumnScale(measCostItemVO.getFactorMap().get(str),
|
||||
digitsMap.get("PriceDigitsKey")));
|
||||
} else if (str.equals("nsumncost")) {// 合计
|
||||
row.put(str, this.setColumnScale(measCostItemVO.getFactorMap().get(str),
|
||||
digitsMap.get("MoneyDigitsKey")));
|
||||
} else if (str.equals("nnum")) {// 产量
|
||||
row.put(str, this.setColumnScale(measCostItemVO.getFactorMap().get(str),
|
||||
digitsMap.get("NumDigitsKey")));
|
||||
} else {// 所有核算要素
|
||||
row.put(str, this.setColumnScale(measCostItemVO.getFactorMap().get(str),
|
||||
digitsMap.get("MoneyDigitsKey")));
|
||||
}
|
||||
// row.put(str, measCostItemVO.getFactorMap().get(str));
|
||||
}
|
||||
|
||||
}
|
||||
data.add(row);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 精度处理
|
||||
*
|
||||
* @param itemVOs 返回的数据
|
||||
* @param digitsMap 精度类型map
|
||||
*/
|
||||
private UFDouble setColumnScale(Object value, Integer scale) {
|
||||
if (value == null || ((UFDouble) value).equals(UFDouble.ZERO_DBL)) {
|
||||
return null;
|
||||
} else {
|
||||
UFDouble uf = new UFDouble(Double.valueOf(value.toString())).setScale(scale, 4);
|
||||
return uf;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重构动态列表头
|
||||
*
|
||||
* @param factorVOs "核算要素"动态列初始化所需数据
|
||||
* @param conditionMap 逻辑查询条件
|
||||
* @param digitsMap 列表精度----单价、数量、金额
|
||||
* @return 保存表头上下两层列的对应关系的map
|
||||
*/
|
||||
private List<IColumnInfo> 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 ----------getColumn
|
||||
List<IColumnInfo> itemsList = new ArrayList<IColumnInfo>();
|
||||
// // 保存两层列的对应关系
|
||||
// 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);
|
||||
}
|
||||
// 如果显示样式为双层,子父关系形式保存到list
|
||||
else {
|
||||
itemsList = this.setDoubleItems(itemsList, factorVOs, showDetailDiff, digitsMap);
|
||||
}
|
||||
//
|
||||
|
||||
return itemsList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置固定列(包括三个列:产品编码、产品名称、产量)
|
||||
*
|
||||
* @param ishowtype 显示方式(成本对象、产品、产品成本分类、产品基本分类)
|
||||
*/
|
||||
private void setCodeNameItems(List<IColumnInfo> itemsList, Integer ishowtype, Map<String, Integer> digitsMap) {
|
||||
// 取得产品编码和产品名称这两列的列名{0:产品编码列名,1:产品名称列名}
|
||||
String[] itemNames = this.getItemNameByShowType(ishowtype);
|
||||
// 创建集合放列的 编码名称
|
||||
// 设置"成本中心编码"列
|
||||
itemsList.add(new ColumnInfo(itemNames[0], CMCommonConst1614.CCCODE, ColumnInfo.LEFT));
|
||||
|
||||
// 设置"成本中心名称"列
|
||||
itemsList.add(new ColumnInfo(itemNames[1], CMCommonConst1614.CCNAME, ColumnInfo.LEFT));
|
||||
|
||||
// 设置"产品编码"列
|
||||
itemsList.add(new ColumnInfo(itemNames[2], CMCommonConst1614.VCOSTOBJCODE, ColumnInfo.LEFT));
|
||||
|
||||
// 设置"产品名称"列
|
||||
itemsList.add(new ColumnInfo(itemNames[3], CMCommonConst1614.VCOSTOBJNAME, ColumnInfo.LEFT));
|
||||
|
||||
// 设置"产量"列
|
||||
itemsList.add(new ColumnInfo(CMLangConst1614.GET_NNUM_NAME(), CMCommonConst1614.NNUM, ColumnInfo.RIGTH));
|
||||
// 确认用户无多语需求
|
||||
// 设置规格
|
||||
itemsList.add(new ColumnInfo("规格", CMCommonConst1614.MATERIALSPEC, ColumnInfo.LEFT));
|
||||
itemsList.add(new ColumnInfo("型号", CMCommonConst1614.MATERIALTYPE, ColumnInfo.LEFT));
|
||||
// 设置计量单位
|
||||
itemsList.add(new ColumnInfo("计量单位", CMCommonConst1614.PK_MEASDOC, ColumnInfo.LEFT));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据显示方式不同,取前两列的列名
|
||||
*
|
||||
* @param ishowtype 显示方式(成本对象、产品、产品成本分类、产品基本分类)
|
||||
* @return 字符串数组:{0:产品编码列名,1:产品名称列名}
|
||||
*/
|
||||
private String[] getItemNameByShowType(Integer ishowtype) {
|
||||
String[] itemName = new String[4];
|
||||
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();
|
||||
}
|
||||
return itemName;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 单层列时,将列保存到list
|
||||
*
|
||||
* @param itemsList 保存基本列的list
|
||||
* @param factorVOs "核算要素"动态列初始化所需数据
|
||||
*/
|
||||
private List<IColumnInfo> setSingleItems(List<IColumnInfo> itemsList, FactorVO[] factorVOs,
|
||||
Map<String, Integer> digitsMap) {
|
||||
// 设置"单位成本"单列
|
||||
itemsList.add(new ColumnInfo(CMLangConst1614.GET_NMEASCOST_NAME(),
|
||||
MeasCostUtil.getItemCodeByRule(CMCommonConst1614.NMEASCOST, CMCommonConst1614.NCOST),
|
||||
ColumnInfo.RIGTH));
|
||||
// 设置"合计"单列
|
||||
itemsList.add(new ColumnInfo(CMLangConst1614.GET_NSUM_NAME(),
|
||||
MeasCostUtil.getItemCodeByRule(CMCommonConst1614.NSUM, CMCommonConst1614.NCOST), ColumnInfo.RIGTH));
|
||||
// 设置"核算要素"列
|
||||
for (FactorVO factorVO : factorVOs) {
|
||||
String itemCode = MeasCostUtil.getItemCodeByRule(factorVO.getFactorcode(), CMCommonConst1614.NCOST);
|
||||
String itemName = factorVO.getFactorcode() + "-" + CMUtil.getNameByMultiLang(factorVO, FactorVO.FACTORNAME);
|
||||
// 添加动态列
|
||||
itemsList.add(new ColumnInfo(itemName, itemCode, ColumnInfo.RIGTH));
|
||||
this.sumFieldCode.add(itemCode);
|
||||
}
|
||||
return itemsList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 双层列时,将下层列保存到list,并返回保存表头上下两层列的对应关系Map
|
||||
*
|
||||
* @param itemsList 保存基本列的list
|
||||
* @param factorVOs "核算要素"动态列初始化所需数据
|
||||
* @param showDetailDiff 列的显示样式(区分本下阶、显示标准成本、区分成本中心、默认)
|
||||
* @return 保存两层列的对应关系的Map
|
||||
*/
|
||||
private List<IColumnInfo> setDoubleItems(List<IColumnInfo> itemsList, FactorVO[] factorVOs, String[] showDetailDiff,
|
||||
Map<String, Integer> digitsMap) {
|
||||
// 存放多表头时的儿子信息
|
||||
String[] childName = new String[showDetailDiff.length];
|
||||
String[] childAlign = new String[showDetailDiff.length];
|
||||
String[] childCode = new String[showDetailDiff.length];
|
||||
// 设置"单位成本"列
|
||||
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();
|
||||
}
|
||||
childName[i] = itemName;
|
||||
childCode[i] = itemCode;
|
||||
childAlign[i] = ColumnInfo.RIGTH;
|
||||
// itemsList.add(new ColumnInfo(itemName, itemCode, ColumnInfo.RIGTH));
|
||||
}
|
||||
// 多表头 时处理多表层的关系---单位成本
|
||||
itemsList.add(MeascostcontrastComServiceImpl.getMultHeadColum(CMLangConst1614.GET_NMEASCOST_NAME(), childName,
|
||||
childCode, childAlign));
|
||||
|
||||
// 设置"合计"列
|
||||
for (int i = 0; i < showDetailDiff.length; i++) {
|
||||
String itemCode = MeasCostUtil.getItemCodeByRule(CMCommonConst1614.NSUM, showDetailDiff[i]);
|
||||
String itemName = MeasCostUtil.getItemNameByCode(showDetailDiff[i]);
|
||||
childName[i] = itemName;
|
||||
childCode[i] = itemCode;
|
||||
childAlign[i] = ColumnInfo.RIGTH;
|
||||
// itemsList.add(new ColumnInfo(itemName, itemCode, ColumnInfo.RIGTH));
|
||||
}
|
||||
// 多表头 时处理多表层的关系---合计
|
||||
itemsList.add(MeascostcontrastComServiceImpl.getMultHeadColum(CMLangConst1614.GET_NSUM_NAME(), childName,
|
||||
childCode, childAlign));
|
||||
|
||||
// 设置"核算要素"列
|
||||
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++) {
|
||||
String itemCode = MeasCostUtil.getItemCodeByRule(groupItemCode, showDetailDiff[i]);
|
||||
String itemName1 = MeasCostUtil.getItemNameByCode(showDetailDiff[i]);
|
||||
childName[i] = itemName1;
|
||||
childCode[i] = itemCode;
|
||||
childAlign[i] = ColumnInfo.RIGTH;
|
||||
// itemsList.add(new ColumnInfo(itemName1, itemCode, ColumnInfo.RIGTH));
|
||||
this.sumFieldCode.add(MeasCostUtil.getItemCodeByRule(groupItemCode, showDetailDiff[0]));
|
||||
}
|
||||
// 多表头 时处理多表层的关系---核算要素
|
||||
itemsList.add(MeascostcontrastComServiceImpl.getMultHeadColum(itemName, childName, childCode, childAlign));
|
||||
}
|
||||
|
||||
return itemsList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造子父关系
|
||||
*/
|
||||
public static ColumnMultiHeadInfo getMultHeadColum(String multStr, String[] childStr, String[] childKey,
|
||||
String[] childAlign) {
|
||||
ColumnMultiHeadInfo multiHead = new ColumnMultiHeadInfo(multStr);
|
||||
ColumnInfo[] children = new ColumnInfo[childStr.length];
|
||||
for (int i = 0; i < children.length; i++) {
|
||||
children[i] = new ColumnInfo(childStr[i], childKey[i], childAlign[i]);
|
||||
}
|
||||
multiHead.setChildren(children);
|
||||
return multiHead;
|
||||
}
|
||||
|
||||
/**
|
||||
* 单据模板的列表视图
|
||||
*/
|
||||
// private BillListView listView;
|
||||
//
|
||||
// public BillListView getListView() {
|
||||
// return this.listView;
|
||||
// }
|
||||
//
|
||||
// public void setListView(BillListView listView) {
|
||||
// this.listView = listView;
|
||||
// }
|
||||
|
||||
}
|
Loading…
Reference in New Issue