From 4eff17cad54005e3e519d34aedb50826f8709b38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=AD=A3=40=E7=94=A8=E5=8F=8B?= Date: Fri, 27 Jun 2025 13:52:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9D=90=E6=96=99=E5=87=BA=E5=BA=93=E5=8D=95?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=B1=87=E6=80=BB=E6=89=93=E5=8D=B0=5F?= =?UTF-8?q?=E5=A2=9E=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ic/pub/action/GeneralSumPrintAction.java | 15 +- .../operator/GeneralSumPrintOperator.java | 544 ++++++++++++++++++ 2 files changed, 555 insertions(+), 4 deletions(-) create mode 100644 ic/src/private/nccloud/pubimpl/ic/inbound/generalin/operator/GeneralSumPrintOperator.java diff --git a/ic/src/client/nccloud/web/ic/pub/action/GeneralSumPrintAction.java b/ic/src/client/nccloud/web/ic/pub/action/GeneralSumPrintAction.java index 3121091..9755524 100644 --- a/ic/src/client/nccloud/web/ic/pub/action/GeneralSumPrintAction.java +++ b/ic/src/client/nccloud/web/ic/pub/action/GeneralSumPrintAction.java @@ -48,7 +48,6 @@ public class GeneralSumPrintAction extends AbstractPrintAction { ExtBillCardConvertProcessor processor = new ExtBillCardConvertProcessor(); bill = processor.fromExtBillCard(billcard); }else if("400801214".equals(appcode)){ - BillCard[] billcardList = json.fromJson(billcardStr,BillCard[].class); BillCardConvertProcessor processor = new BillCardConvertProcessor(); List billVOList=new ArrayList<>(); newinfo.setAppcode(appcode); @@ -59,11 +58,19 @@ public class GeneralSumPrintAction extends AbstractPrintAction { printServiceClazz.setName(getPrintServiceName()); newinfo.setPrintServiceClazz(printServiceClazz); newinfo.setPrintTemplateID(info.getPrintTemplateID()); - for(BillCard billcard:billcardList ){ + //判断billcard是否为数组 + if(billcardStr.startsWith("[")){ + BillCard[] billcardList = json.fromJson(billcardStr,BillCard[].class); + for(BillCard billcard:billcardList ){ + bill = processor.fromBillCard(billcard); + billVOList.add(bill); + } + newinfo.setData(billVOList.toArray(new Object[0])); + }else{ + BillCard billcard = json.fromJson(billcardStr,BillCard.class); bill = processor.fromBillCard(billcard); - billVOList.add(bill); + newinfo.setData(new Object[] { bill }); } - newinfo.setData(billVOList.toArray(new Object[0])); return newinfo; }else{ BillCard billcard = json.fromJson(billcardStr,BillCard.class); diff --git a/ic/src/private/nccloud/pubimpl/ic/inbound/generalin/operator/GeneralSumPrintOperator.java b/ic/src/private/nccloud/pubimpl/ic/inbound/generalin/operator/GeneralSumPrintOperator.java new file mode 100644 index 0000000..6aad98d --- /dev/null +++ b/ic/src/private/nccloud/pubimpl/ic/inbound/generalin/operator/GeneralSumPrintOperator.java @@ -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 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; + } + + + /** + * 汇总以后重置价格 方法功能描述: + *

+ * 参数说明 + * + * @param itemvosnew + *

+ * @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))); + } + } + } + } + /** + * 获取汇总字段 方法功能描述:采购入库调用 + *

+ * 参数说明 + * + * @param isselected + * @return

+ * @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; + } + + /** + * 获取汇总字段 方法功能描述: + *

+ * 参数说明 + * 材料出库调用 + * @param isselected + * @return

+ * @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; + } + /** + * 通过选择框最终确定的分组字段 方法功能描述: + *

+ * 参数说明 + * + * @param alGroupBy + * @param Fields + * @return

+ * @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; + } + + + /** + * 对分组字段做特殊处理 方法功能描述: + *

+ * 参数说明 + * + * @param saGroupField + * @return

+ * @since 6.0 + * @author zhangsui + * @time 2011-7-19 下午03:13:03 + */ + protected String[] processSaGroupField(String[] saGroupField) { + List fields = Arrays.asList(saGroupField); + List newfields = new ArrayList(); + 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; + } + + + /** + * 获取分组字段 方法功能描述: + *

+ * 参数说明 + * + * @return

+ * @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 }; + } + + + + +}