材料出库单列表汇总打印_增量

This commit is contained in:
李正@用友 2025-06-27 13:52:49 +08:00 committed by mzr
parent d093aa5f33
commit 4eff17cad5
2 changed files with 555 additions and 4 deletions

View File

@ -48,7 +48,6 @@ public class GeneralSumPrintAction extends AbstractPrintAction {
ExtBillCardConvertProcessor processor = new ExtBillCardConvertProcessor(); ExtBillCardConvertProcessor processor = new ExtBillCardConvertProcessor();
bill = processor.fromExtBillCard(billcard); bill = processor.fromExtBillCard(billcard);
}else if("400801214".equals(appcode)){ }else if("400801214".equals(appcode)){
BillCard[] billcardList = json.fromJson(billcardStr,BillCard[].class);
BillCardConvertProcessor processor = new BillCardConvertProcessor(); BillCardConvertProcessor processor = new BillCardConvertProcessor();
List<ICBillVO> billVOList=new ArrayList<>(); List<ICBillVO> billVOList=new ArrayList<>();
newinfo.setAppcode(appcode); newinfo.setAppcode(appcode);
@ -59,11 +58,19 @@ public class GeneralSumPrintAction extends AbstractPrintAction {
printServiceClazz.setName(getPrintServiceName()); printServiceClazz.setName(getPrintServiceName());
newinfo.setPrintServiceClazz(printServiceClazz); newinfo.setPrintServiceClazz(printServiceClazz);
newinfo.setPrintTemplateID(info.getPrintTemplateID()); newinfo.setPrintTemplateID(info.getPrintTemplateID());
//判断billcard是否为数组
if(billcardStr.startsWith("[")){
BillCard[] billcardList = json.fromJson(billcardStr,BillCard[].class);
for(BillCard billcard:billcardList ){ for(BillCard billcard:billcardList ){
bill = processor.fromBillCard(billcard); bill = processor.fromBillCard(billcard);
billVOList.add(bill); billVOList.add(bill);
} }
newinfo.setData(billVOList.toArray(new Object[0])); newinfo.setData(billVOList.toArray(new Object[0]));
}else{
BillCard billcard = json.fromJson(billcardStr,BillCard.class);
bill = processor.fromBillCard(billcard);
newinfo.setData(new Object[] { bill });
}
return newinfo; return newinfo;
}else{ }else{
BillCard billcard = json.fromJson(billcardStr,BillCard.class); BillCard billcard = json.fromJson(billcardStr,BillCard.class);

View File

@ -0,0 +1,544 @@
package nccloud.pubimpl.ic.inbound.generalin.operator;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.TimeZone;
import nc.bs.framework.common.InvocationInfoProxy;
import nc.bs.framework.common.NCLocator;
import nc.ui.pub.print.IDataSource;
import nc.ui.pub.print.IMetaDataDataSource;
import nc.vo.ic.general.define.ICBillBodyVO;
import nc.vo.ic.general.define.ICBillVO;
import nc.vo.ic.general.define.MetaNameConst;
import nc.vo.ic.pub.define.ICPubMetaNameConst;
import nc.vo.pub.BusinessException;
import nc.vo.pub.CircularlyAccessibleValueObject;
import nc.vo.pub.SuperVO;
import nc.vo.pub.lang.UFDate;
import nc.vo.pub.lang.UFDateTime;
import nc.vo.pub.lang.UFDouble;
import nc.vo.pub.lang.UFTime;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
import nc.vo.pubapp.pattern.model.entity.bill.AbstractBill;
import nc.vo.pubapp.pattern.model.entity.view.AbstractDataView;
import nc.vo.pubapp.scale.BillVOScaleProcessor;
import nc.vo.pubapp.scale.TotalValueVOScaleProcessor;
import nc.vo.pubapp.util.DefaultVOMerger;
import nc.vo.scmpub.res.billtype.ICBillType;
import nccloud.dto.ic.pub.entity.GeneralSumPrintInfo;
import nccloud.pubimpl.ic.inbound.purchasein.operator.PurchaseInVOPrecisionHandler;
import nccloud.pubimpl.ic.outbound.materialout.operator.MaterialOutVOPrecisionHandler;
import nccloud.pubimpl.ic.outbound.saleout.operator.SaleOutVOPrecisionHandler;
import nccloud.pubimpl.ic.pub.print.ICBasePrintVOPrecisionHandler;
import nccloud.pubitf.ic.pub.service.IICBillVOQueryService;
import nccloud.pubitf.platform.print.AbstractPrintService;
import nccloud.pubitf.platform.print.IPrintInfo;
import nccloud.pubitf.scmpub.pub.print.CombinePrintInfo;
/**
* @description 出入库汇总打印
* @author zhegnxinm
* @date 2018-12-16 上午10:48:39
* @version ncc1.0
*/
public class GeneralSumPrintOperator extends AbstractPrintService{
/**
* 打印前处理类精度
*/
private IBeforePrintDataProcess processor;
public Object[] getDatas(GeneralSumPrintInfo info) {
return info.getData();
}
private void processData(ICBillVO cvo){
ICBillVO[] vos = new ICBillVO[]{cvo};
//精度处理
String pk_group = InvocationInfoProxy.getInstance().getGroupId();
BillVOScaleProcessor scale = new BillVOScaleProcessor(pk_group,vos);
TotalValueVOScaleProcessor totalScale = new TotalValueVOScaleProcessor(vos);
ICBasePrintVOPrecisionHandler handler = null;
if (vos[0].getHead().getBillType().getCode().equals(ICBillType.SaleOut.getCode())) {//销售出库
ICBillVO[] aggvos = NCLocator.getInstance().lookup(IICBillVOQueryService.class).query(
ICBillType.SaleOut, new String[] { vos[0].getHead().getCgeneralhid()});
if(aggvos == null || aggvos.length == 0) {
ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0","04008027-0180")/*@res "当前数据已被删除,请到列表页面刷新!"*/);
}
handler = new SaleOutVOPrecisionHandler(vos);
handler.processVos(scale, totalScale);
} else if (vos[0].getHead().getBillType().getCode().equals(ICBillType.MaterialOut.getCode())) {//材料出库
ICBillVO[] aggvos = NCLocator.getInstance().lookup(IICBillVOQueryService.class).query(
ICBillType.MaterialOut, new String[] { vos[0].getHead().getCgeneralhid()});
if(aggvos == null || aggvos.length == 0) {
ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0","04008027-0180")/*@res "当前数据已被删除,请到列表页面刷新!"*/);
}
handler = new MaterialOutVOPrecisionHandler(vos);
handler.processVos(scale, totalScale);
} else {//采购入库
ICBillVO[] aggvos = NCLocator.getInstance().lookup(IICBillVOQueryService.class).query(
ICBillType.PurchaseIn, new String[] { vos[0].getHead().getCgeneralhid()});
if(aggvos == null || aggvos.length == 0) {
ExceptionUtils.wrappBusinessException(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0","04008027-0180")/*@res "当前数据已被删除,请到列表页面刷新!"*/);
}
handler = new PurchaseInVOPrecisionHandler(vos);
handler.processVos(scale, totalScale);
}
}
@Override
public IDataSource[] getDataSources(IPrintInfo info) {
GeneralSumPrintInfo printInfo = (GeneralSumPrintInfo) info;
// 获取数据
Object[] datas = this.getDatas(printInfo);
List<Boolean> alGroupBy = printInfo.getAlGroupBy();
// 得到分组字段
ICBillVO cvo = (ICBillVO) datas[0];
String[] Fields = getGroupFields();
String[] saGroupField = getSelGroupFields(alGroupBy, Fields);
saGroupField = processSaGroupField(saGroupField);
DefaultVOMerger dvomerger = new DefaultVOMerger();
dvomerger.setGroupingAttr(saGroupField);
// 得到Summing字段
String[] saSummingField = null;
if (cvo.getHead().getBillType().getCode().equals(ICBillType.MaterialOut.getCode())) {
saSummingField = getSummingField((Boolean) alGroupBy.get(2));
} else {
saSummingField = getSummingField((Boolean) alGroupBy.get(2),printInfo.getInOutType());
}
dvomerger.setSummingAttr(saSummingField);
//2025年6月27日11点22分 --扩展材料出库列表添加汇总合并
if(cvo.getHead().getBillType().getCode().equals(ICBillType.MaterialOut.getCode())){
this.dealSumInfoDev(dvomerger,datas);
}else{
// 对表体分组
try {
ICBillBodyVO[] itemvosnew = (ICBillBodyVO[]) dvomerger.mergeByGroup(cvo
.getBodys());
reSetPrice(itemvosnew,cvo.getHead().getBillType().getCode());
cvo.setChildrenVO(itemvosnew);
} catch (BusinessException e) {
ExceptionUtils.wrappException(e);
}
//精度处理
this.processData(cvo);
}
//是否敏感时区
boolean isSensitive = InvocationInfoProxy.getInstance().getSensitiveTimeZone();
if(isSensitive) {
datas = this.processTimeZone(datas);
}
// 组装数据源
IDataSource[] ds = this.getDataSource(datas);
return ds;
}
private void dealSumInfoDev(DefaultVOMerger dvomerger, Object[] datas) {
// 对表体分组
try {
for(Object data : datas){
ICBillVO cvo = (ICBillVO) data;
ICBillBodyVO[] itemvosnew = (ICBillBodyVO[]) dvomerger.mergeByGroup(cvo
.getBodys());
reSetPrice(itemvosnew,cvo.getHead().getBillType().getCode());
cvo.setChildrenVO(itemvosnew);
//精度处理
this.processData(cvo);
}
} catch (BusinessException e) {
ExceptionUtils.wrappException(e);
}
}
/**
* 处理打印多时区
*
* @param datas
* @return
*
*/
private Object[] processTimeZone(Object[] datas) {
String timeZonestr = InvocationInfoProxy.getInstance().getTimeZone();
TimeZone timeZone = TimeZone.getTimeZone(timeZonestr);
for (Object data : datas) {
if (data instanceof SuperVO) {
this.processSuperVOTimeZone((SuperVO) data, timeZone);
} else if (data instanceof AbstractBill) {
AbstractBill bill = (AbstractBill) data;
CircularlyAccessibleValueObject vo = bill.getParentVO();
this.processSuperVOTimeZone((SuperVO) vo, timeZone);
CircularlyAccessibleValueObject[] childrenVO = bill.getAllChildrenVO();
for (CircularlyAccessibleValueObject item : childrenVO) {
this.processSuperVOTimeZone((SuperVO) item, timeZone);
}
} else if (data instanceof AbstractDataView) {
AbstractDataView view = (AbstractDataView) data;
this.processViewVOTimeZone(view, timeZone);
}
}
return datas;
}
/**
*
* 处理视图VO的多时区
*
* @param view
* @param timeZone
*
*/
private void processViewVOTimeZone(AbstractDataView view, TimeZone timeZone) {
String[] names = view.getAttributeNames();
for (String name : names) {
Object value = view.getAttributeValue(name);
if (value == null) {
continue;
}
if (value instanceof UFDate) {
UFDate date = (UFDate) value;
String stdString = date.toStdString(timeZone);
UFDate ufDate = new UFDate(stdString);
view.setAttributeValue(name, ufDate);
} else if (value instanceof UFDateTime) {
UFDateTime datetime = (UFDateTime) value;
String stdString = datetime.toStdString(timeZone);
UFDateTime ufDateTime = new UFDateTime(stdString);
view.setAttributeValue(name, ufDateTime);
} else if (value instanceof UFTime) {
UFTime time = (UFTime) value;
String stdString = time.toStdString(timeZone);
UFTime ufTime = new UFTime(stdString);
view.setAttributeValue(name, ufTime);
}
}
}
/**
* 处理SuperVO的多时区
*
* @param vo
* @param timeZone
*
*/
private void processSuperVOTimeZone(SuperVO vo, TimeZone timeZone) {
String[] attributeNames = vo.getAttributeNames();
for (String name : attributeNames) {
Object value = vo.getAttributeValue(name);
if (value == null) {
continue;
}
if (value instanceof UFDate) {
UFDate date = (UFDate) value;
String stdString = date.toStdString(timeZone);
UFDate ufDate = new UFDate(stdString);
vo.setAttributeValue(name, ufDate);
} else if (value instanceof UFDateTime) {
UFDateTime datetime = (UFDateTime) value;
String stdString = datetime.toStdString(timeZone);
UFDateTime ufDateTime = new UFDateTime(stdString);
vo.setAttributeValue(name, ufDateTime);
} else if (value instanceof UFTime) {
UFTime time = (UFTime) value;
String stdString = time.toStdString(timeZone);
UFTime ufTime = new UFTime(stdString);
vo.setAttributeValue(name, ufTime);
}
}
}
/**
*
* 组装数据源
*
* @param datas
* @return
*
*/
protected IDataSource[] getDataSource(Object[] datas) {
IDataSource[] ds = new IDataSource[datas.length];
for (int i = 0; i < datas.length; i++) {
ds[i] = new MetaDataSource(new Object[] { datas[i] });
}
return ds;
}
/**
*
* 获取数据
*
* @param ids
* @return
*
*/
protected Object[] getDatas(CombinePrintInfo printInfo) {
return printInfo.getData();
}
/**
*
* @description 元数据数据源
* @author guozhq
* @date 2018-7-2 下午4:32:45
* @version ncc1.0
*/
private class MetaDataSource implements IMetaDataDataSource {
/**
* @Fields serialVersionUID
*/
private static final long serialVersionUID = 6834183299513914654L;
private Object[] printData;
public MetaDataSource(Object[] printData) {
this.printData = printData;
}
@Override
public String[] getItemValuesByExpress(String itemExpress) {
return null;
}
@Override
public boolean isNumber(String itemExpress) {
return false;
}
@Override
public String[] getDependentItemExpressByExpress(String itemExpress) {
return null;
}
@Override
public String[] getAllDataItemExpress() {
return null;
}
@Override
public String[] getAllDataItemNames() {
return null;
}
@Override
public String getModuleName() {
return null;
}
@Override
public Object[] getMDObjects() {
// 处理前方法
if (GeneralSumPrintOperator.this.getProcessor() != null) {
return GeneralSumPrintOperator.this.getProcessor().processData(printData);
}
return printData;
}
}
/**
*
* @description 打印前接口
* @author guozhq
* @date 2018-7-2 下午4:33:10
* @version ncc1.0
*/
public interface IBeforePrintDataProcess {
Object[] processData(Object[] datas);
}
public IBeforePrintDataProcess getProcessor() {
return processor;
}
public void setProcessor(IBeforePrintDataProcess processor) {
this.processor = processor;
}
/**
* 汇总以后重置价格 方法功能描述
* <p>
* <b>参数说明</b>
*
* @param itemvosnew
* <p>
* @since 6.0
* @author zhangsui
* @time 2011-7-19 上午08:35:43
*/
protected void reSetPrice(ICBillBodyVO[] itemvosnew,String type) {
if (itemvosnew != null) {
UFDouble udNum = null;
UFDouble udMny = null;
for (int k = 0; k < itemvosnew.length; k++) {
udNum = itemvosnew[k].getNnum();
udMny = (UFDouble) itemvosnew[k]
.getAttributeValue(MetaNameConst.NMNY);
if (type.equals(ICBillType.MaterialOut.getCode())) {
udMny = (UFDouble) itemvosnew[k]
.getAttributeValue(MetaNameConst.NCOSTMNY);
} else {
udMny = (UFDouble) itemvosnew[k]
.getAttributeValue(MetaNameConst.NMNY);
}
if (udNum != null && udMny != null) {
itemvosnew[k].setAttributeValue(MetaNameConst.NPRICE,
(udMny.div(udNum)));
}
}
}
}
/**
* 获取汇总字段 方法功能描述采购入库调用
* <p>
* <b>参数说明</b>
*
* @param isselected
* @return <p>
* @since 6.0
* @author zhangsui
* @time 2011-7-19 上午08:35:12
*/
protected String[] getSummingField(Boolean isselected, String type) {
String[] saSummingField = null;
if ("in".equals(type)) {
if ((isselected).booleanValue() == true) {
saSummingField = new String[] { ICPubMetaNameConst.NSHOULDNUM,
ICPubMetaNameConst.NNUM, ICPubMetaNameConst.NASSISTNUM,
ICPubMetaNameConst.NSHOULDASSISTNUM,
MetaNameConst.NMNY,
/**
* 杭州锦江集团有限公司:采购入库汇总打印时部分字段没汇总
*/
MetaNameConst.NORIGMNY, MetaNameConst.NCALCOSTMNY,
MetaNameConst.NTAXMNY, MetaNameConst.NORIGTAXMNY };
} else {
saSummingField = new String[] { ICPubMetaNameConst.NSHOULDNUM,
ICPubMetaNameConst.NNUM, MetaNameConst.NMNY };
}
} else if ("out".equals(type)) {
if ((isselected).booleanValue() == true) {
saSummingField = new String[] { ICPubMetaNameConst.NSHOULDNUM,
ICPubMetaNameConst.NNUM, ICPubMetaNameConst.NASSISTNUM,
ICPubMetaNameConst.NSHOULDASSISTNUM, MetaNameConst.NMNY };
} else {
saSummingField = new String[] { ICPubMetaNameConst.NSHOULDNUM,
ICPubMetaNameConst.NNUM, MetaNameConst.NMNY
/*
* 返回打印模板中可合并计算的字段
* 现客户合并计算norigtaxmny(原币价税合计)的和需要添加该字段的返回
*/
, MetaNameConst.NORIGMNY, MetaNameConst.NTAXMNY,
MetaNameConst.NORIGTAXMNY };
}
}
return saSummingField;
}
/**
* 获取汇总字段 方法功能描述
* <p>
* <b>参数说明</b>
* 材料出库调用
* @param isselected
* @return <p>
* @since 6.0
* @author zhangsui
* @time 2011-7-19 上午08:35:12
*/
protected String[] getSummingField(Boolean isselected) {
String[] saSummingField = null;
if ((isselected).booleanValue() == true) {
saSummingField = new String[] { ICPubMetaNameConst.NSHOULDNUM,
ICPubMetaNameConst.NNUM, ICPubMetaNameConst.NASSISTNUM,
ICPubMetaNameConst.NSHOULDASSISTNUM, MetaNameConst.NCOSTMNY };
} else {
saSummingField = new String[] { ICPubMetaNameConst.NSHOULDNUM,
ICPubMetaNameConst.NNUM, MetaNameConst.NCOSTMNY };
}
return saSummingField;
}
/**
* 通过选择框最终确定的分组字段 方法功能描述
* <p>
* <b>参数说明</b>
*
* @param alGroupBy
* @param Fields
* @return <p>
* @since 6.0
* @author zhangsui
* @time 2011-7-19 上午08:41:30
*/
@SuppressWarnings("unchecked")
protected String[] getSelGroupFields(List alGroupBy, String[] Fields) {
ArrayList alChooseGroup = new ArrayList();
for (int i = 0; i < alGroupBy.size() - 1; i++) {
if (((Boolean) alGroupBy.get(i)).booleanValue()) {
alChooseGroup.add(Fields[i]);
}
}
String[] saGroupField = null;
if (alChooseGroup.size() > 0){
saGroupField = new String[alChooseGroup.size()];
alChooseGroup.toArray(saGroupField);
}
return saGroupField;
}
/**
* 对分组字段做特殊处理 方法功能描述
* <p>
* <b>参数说明</b>
*
* @param saGroupField
* @return <p>
* @since 6.0
* @author zhangsui
* @time 2011-7-19 下午03:13:03
*/
protected String[] processSaGroupField(String[] saGroupField) {
List<String> fields = Arrays.asList(saGroupField);
List<String> newfields = new ArrayList<String>();
if (fields.contains("vfree0")) {
for (int i = 0; i < saGroupField.length; i++) {
if (!"vfree0".equals(saGroupField[i])) {
newfields.add(saGroupField[i]);
}
}
for (int i = 1; i < 11; i++) {
newfields.add("vfree" + i);
}
return newfields.toArray(new String[0]);
}
return saGroupField;
}
/**
* 获取分组字段 方法功能描述
* <p>
* <b>参数说明</b>
*
* @return <p>
* @since 6.0
* @author zhangsui
* @time 2011-7-19 上午08:37:31
*/
protected String[] getGroupFields() {
return new String[] { ICPubMetaNameConst.CMATERIALVID,
ICPubMetaNameConst.VBATCHCODE, ICPubMetaNameConst.CASTUNITID,
"vfree0", ICPubMetaNameConst.CLOCATIONID,
ICPubMetaNameConst.CVENDORID };
}
}