|
@@ -1,11 +1,8 @@
|
|
|
package nckd.jimin.jyyy.fi.common.util;
|
|
|
|
|
|
import com.kingdee.bos.util.backport.Collections;
|
|
|
-import kd.bos.cache.CacheFactory;
|
|
|
-import kd.bos.cache.TempFileCache;
|
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
|
-import kd.bos.dataentity.resource.ResManager;
|
|
|
import kd.bos.dataentity.utils.StringUtils;
|
|
|
import kd.bos.db.DB;
|
|
|
import kd.bos.db.DBRoute;
|
|
@@ -22,10 +19,11 @@ import kd.bos.servicehelper.AttachmentServiceHelper;
|
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
|
import kd.bos.servicehelper.PrintServiceHelper;
|
|
|
import kd.bos.servicehelper.QueryServiceHelper;
|
|
|
+import kd.bos.svc.util.print.PrintFileUtil;
|
|
|
import kd.bos.util.CollectionUtils;
|
|
|
import kd.bos.web.actions.utils.FilePathUtil;
|
|
|
-import nckd.jimin.jyyy.fi.common.constant.ErPrintSetConstant;
|
|
|
import nckd.jimin.jyyy.fi.common.constant.BillTypeConstants;
|
|
|
+import nckd.jimin.jyyy.fi.common.constant.ErPrintSetConstant;
|
|
|
import nckd.jimin.jyyy.fi.common.entity.MergePrintEntity;
|
|
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
@@ -79,15 +77,15 @@ public class ReceiveTicketUtils {
|
|
|
}
|
|
|
|
|
|
if(CollectionUtils.isNotEmpty(mergeArray)){
|
|
|
- byte[] bytes = PrintServiceHelper.mergeMultiPdf(mergeArray);//拼接文件流
|
|
|
- ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
|
|
|
- TempFileCache tfc = CacheFactory.getCommonCacheFactory().getTempFileCache();
|
|
|
+ byte[] multiPdf = PrintServiceHelper.mergeMultiPdf(mergeArray);//拼接文件流
|
|
|
// 设置临时文件有效时间
|
|
|
- return tfc.saveAsUrl(fileName+".pdf", bin, 60 * 60 * 2);//文件流生成临时文件
|
|
|
+ return "tempfile/print.do?" + PrintFileUtil.saveInputStream2TempFile(fileName+".pdf",
|
|
|
+ new ByteArrayInputStream(multiPdf), 3600 * 2);
|
|
|
}
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
+
|
|
|
public static String getPrintTemplateId(String appId,String formId, Object billId) {
|
|
|
TplMatcherParam param = new TplMatcherParam();
|
|
|
param.setEntityId(formId);//表单id
|
|
@@ -146,20 +144,30 @@ public class ReceiveTicketUtils {
|
|
|
if(billEntryList.size() > 1){
|
|
|
throw new KDBizException("打印配置中单据存在多条配置。");
|
|
|
}
|
|
|
+ DynamicObject billConfigEntry = billEntryList.get(0);
|
|
|
|
|
|
Map<String, Set<Object>> relationBelowBillMap = ErFindRelationBillUtils.getRelationBelowBillMap(billId.toString(), formId);
|
|
|
- DynamicObject billConfigEntry = billEntryList.get(0);
|
|
|
+ // 打印单据
|
|
|
if(billConfigEntry.getBoolean(ErPrintSetConstant.BillPtSetEntry.KEY_NCKD_ISPTCOVER)){
|
|
|
- String printTemplateId = getPrintTemplateId(null, formId, billId);
|
|
|
- mergePrintList.add(new MergePrintEntity(formId,printTemplateId, Collections.singletonList(billId),billConfigEntry.getInt(ErPrintSetConstant.BillPtSetEntry.KEY_NCKD_COVERORDER)));
|
|
|
+ String mainBillTpl = getPrintTemplateId(null, formId, billId);
|
|
|
+ mergePrintList.add(new MergePrintEntity(formId,mainBillTpl, Collections.singletonList(billId),billConfigEntry.getInt(ErPrintSetConstant.BillPtSetEntry.KEY_NCKD_COVERORDER),true));
|
|
|
}
|
|
|
+
|
|
|
if(billConfigEntry.getBoolean(ErPrintSetConstant.BillPtSetEntry.KEY_NCKD_ISPTVOUCHER)){
|
|
|
if(relationBelowBillMap.containsKey(BillTypeConstants.GL_VOUCHER)){
|
|
|
Set<Object> voucherIdList = relationBelowBillMap.get(BillTypeConstants.GL_VOUCHER);
|
|
|
+ List<MergePrintEntity> vcPrintList = new ArrayList<>(voucherIdList.size());
|
|
|
for(Object voucherId : voucherIdList){
|
|
|
String printTemplateId = getPrintTemplateId(null, BillTypeConstants.GL_VOUCHER, voucherId);
|
|
|
- mergePrintList.add(new MergePrintEntity(BillTypeConstants.GL_VOUCHER,printTemplateId, Collections.singletonList(voucherId),billConfigEntry.getInt(ErPrintSetConstant.BillPtSetEntry.KEY_NCKD_VOUCHERORDER)));
|
|
|
+ vcPrintList.add(new MergePrintEntity(BillTypeConstants.GL_VOUCHER,printTemplateId, Collections.singletonList(voucherId),billConfigEntry.getInt(ErPrintSetConstant.BillPtSetEntry.KEY_NCKD_VOUCHERORDER)));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果不打印业务单据,则从凭证中选一条作为住单据
|
|
|
+ if(!billConfigEntry.getBoolean(ErPrintSetConstant.BillPtSetEntry.KEY_NCKD_ISPTCOVER)){
|
|
|
+ vcPrintList.get(0).setMainBill(true);
|
|
|
}
|
|
|
+
|
|
|
+ mergePrintList.addAll(vcPrintList);
|
|
|
}
|
|
|
}
|
|
|
if(billConfigEntry.getBoolean(ErPrintSetConstant.BillPtSetEntry.KEY_NCKD_ISPTRECEIPT)){
|