|
@@ -5,8 +5,6 @@ import com.kingdee.util.StringUtils;
|
|
|
import kd.bos.algo.DataSet;
|
|
|
import kd.bos.bill.BillShowParameter;
|
|
|
import kd.bos.bill.OperationStatus;
|
|
|
-import kd.bos.cache.CacheFactory;
|
|
|
-import kd.bos.cache.TempFileCache;
|
|
|
import kd.bos.context.RequestContext;
|
|
|
import kd.bos.dataentity.OperateOption;
|
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
@@ -41,8 +39,8 @@ import kd.bos.logging.Log;
|
|
|
import kd.bos.logging.LogFactory;
|
|
|
import kd.bos.orm.query.QCP;
|
|
|
import kd.bos.orm.query.QFilter;
|
|
|
+import kd.bos.servicehelper.AttachmentServiceHelper;
|
|
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
|
-import kd.bos.servicehelper.PrintServiceHelper;
|
|
|
import kd.bos.servicehelper.QueryServiceHelper;
|
|
|
import kd.bos.servicehelper.image.ImageServiceNewHelper;
|
|
|
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
|
@@ -51,6 +49,7 @@ import kd.bos.servicehelper.org.OrgViewType;
|
|
|
import kd.bos.servicehelper.permission.PermissionServiceHelper;
|
|
|
import kd.bos.url.UrlService;
|
|
|
import kd.bos.util.CollectionUtils;
|
|
|
+import kd.fi.cas.util.EmptyUtil;
|
|
|
import nckd.jimin.jyyy.fi.common.constant.BillTypeConstants;
|
|
|
import nckd.jimin.jyyy.fi.common.constant.ErPrintUserConstant;
|
|
|
import nckd.jimin.jyyy.fi.common.constant.ErReimBurseBillConstant;
|
|
@@ -59,8 +58,6 @@ import nckd.jimin.jyyy.fi.common.entity.MergePrintEntity;
|
|
|
import nckd.jimin.jyyy.fi.common.util.ErFindRelationBillUtils;
|
|
|
import nckd.jimin.jyyy.fi.common.util.ReceiveTicketUtils;
|
|
|
|
|
|
-import java.io.UnsupportedEncodingException;
|
|
|
-import java.net.URLEncoder;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -390,34 +387,107 @@ public class HandInReceiveTicketPlugin extends AbstractFormPlugin implements Row
|
|
|
|
|
|
Map<String, Set<Object>> relationBelowBillMap = ErFindRelationBillUtils.getRelationBelowBillMap(selectRow.getString(HandInReceiveTicketConstant.SCANBILLENTRY.KEY_NCKD_BILLID),
|
|
|
selectRow.getString(HandInReceiveTicketConstant.SCANBILLENTRY.KEY_NCKD_FORMID));
|
|
|
- if(!relationBelowBillMap.containsKey(BillTypeConstants.BEI_ELECRECEIPT)
|
|
|
- || CollectionUtils.isEmpty(relationBelowBillMap.get(BillTypeConstants.BEI_ELECRECEIPT))){
|
|
|
- getView().showTipNotification("没有匹配的电子回单信息。");
|
|
|
+
|
|
|
+ if (!relationBelowBillMap.containsKey(BillTypeConstants.CAS_PAYBILL)
|
|
|
+ || CollectionUtils.isEmpty(relationBelowBillMap.get(BillTypeConstants.CAS_PAYBILL))) {
|
|
|
+ getView().showTipNotification("没有相应的电子回单!");
|
|
|
return;
|
|
|
}
|
|
|
- List<byte[]> mergeArray = new ArrayList<>();
|
|
|
- Set<Object> elecReceiptIdSet = relationBelowBillMap.get(BillTypeConstants.BEI_ELECRECEIPT);
|
|
|
- for(Object elecReceiptId : elecReceiptIdSet){
|
|
|
- byte[] bytes = ReceiveTicketUtils.getElecReceiptPrintUrl(elecReceiptId);
|
|
|
- mergeArray.add(bytes);
|
|
|
+ Set<Object> casPayBillIdSet = relationBelowBillMap.get(BillTypeConstants.CAS_PAYBILL);
|
|
|
+ boolean isHasReceipt = false;
|
|
|
+ for (Object casPayBillId : casPayBillIdSet) {
|
|
|
+ Map<String, Object> fileMap = getElecreceiptByFile(casPayBillId.toString());
|
|
|
+ if (fileMap != null) {
|
|
|
+ isHasReceipt = true;
|
|
|
+ this.getView().previewAttachment(fileMap);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- byte[] bytes = PrintServiceHelper.mergeMultiPdf(mergeArray);//拼接文件流
|
|
|
-
|
|
|
- String fileName = String.format("单据%s电子回单文件文件预览",selectRow.getString(HandInReceiveTicketConstant.SCANBILLENTRY.KEY_NCKD_NUMBER));
|
|
|
- TempFileCache tfc = CacheFactory.getCommonCacheFactory().getTempFileCache();
|
|
|
- // 设置临时文件有效时间
|
|
|
- String tempUrl = tfc.saveAsFullUrl(fileName + ".pdf", bytes, 60 * 60 * 2);//文件流生成临时文件
|
|
|
- String url = null;
|
|
|
- try {
|
|
|
- url = URLEncoder.encode(tempUrl, "UTF-8");
|
|
|
- } catch (UnsupportedEncodingException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ if(isHasReceipt){
|
|
|
+ getView().showTipNotification("没有相应的电子回单!");
|
|
|
+ return;
|
|
|
}
|
|
|
- String previewurl = UrlService.getAttachmentPreviewUrl(url);
|
|
|
- getView().openUrl(previewurl);
|
|
|
- }
|
|
|
|
|
|
+// List<byte[]> mergeArray = new ArrayList<>();
|
|
|
+// Set<Object> elecReceiptIdSet = relationBelowBillMap.get(BillTypeConstants.BEI_ELECRECEIPT);
|
|
|
+// for(Object elecReceiptId : elecReceiptIdSet){
|
|
|
+// byte[] bytes = ReceiveTicketUtils.getElecReceiptPrintUrl(elecReceiptId);
|
|
|
+// mergeArray.add(bytes);
|
|
|
+// }
|
|
|
+//
|
|
|
+// byte[] bytes = PrintServiceHelper.mergeMultiPdf(mergeArray);//拼接文件流
|
|
|
+//
|
|
|
+// String fileName = String.format("单据%s电子回单文件文件预览",selectRow.getString(HandInReceiveTicketConstant.SCANBILLENTRY.KEY_NCKD_NUMBER));
|
|
|
+// TempFileCache tfc = CacheFactory.getCommonCacheFactory().getTempFileCache();
|
|
|
+// // 设置临时文件有效时间
|
|
|
+// String tempUrl = tfc.saveAsFullUrl(fileName + ".pdf", bytes, 60 * 60 * 2);//文件流生成临时文件
|
|
|
+// String url = null;
|
|
|
+// try {
|
|
|
+// url = URLEncoder.encode(tempUrl, "UTF-8");
|
|
|
+// } catch (UnsupportedEncodingException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+// String previewurl = UrlService.getAttachmentPreviewUrl(url);
|
|
|
+// getView().openUrl(previewurl);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public Map<String,Object> getElecreceiptByFile(String payBillId){
|
|
|
+ Long billId = Long.parseLong(payBillId);
|
|
|
+ QFilter qf = new QFilter("id", QCP.equals, billId);
|
|
|
+ DynamicObject billDyn = BusinessDataServiceHelper.loadSingle("cas_paybill", new QFilter[]{qf});
|
|
|
+ String transdetailId = billDyn.getString("detailseqid");
|
|
|
+ if(kd.bos.util.StringUtils.isEmpty(transdetailId)) return null;
|
|
|
+ QFilter qf1 = new QFilter("billno", QCP.equals, transdetailId);
|
|
|
+ DynamicObject transdetailDyn = BusinessDataServiceHelper.loadSingle("bei_transdetail", new QFilter[]{qf1});
|
|
|
+ if(EmptyUtil.isEmpty(transdetailDyn)) return null;
|
|
|
+ String elecreceiptNo = transdetailDyn.getString("receiptno");
|
|
|
+ QFilter qf2 = new QFilter("receiptno", QCP.equals, elecreceiptNo);
|
|
|
+ DynamicObject elecreceiptDyn = BusinessDataServiceHelper.loadSingle("bei_elecreceipt", new QFilter[]{qf2});
|
|
|
+
|
|
|
+ if(EmptyUtil.isEmpty(elecreceiptDyn)) return null;
|
|
|
+ Map<String, Object> attachmentMap = getAttachmentFile(elecreceiptDyn.getLong("id"));
|
|
|
+
|
|
|
+ if(attachmentMap == null) return null;
|
|
|
+ String filepath = elecreceiptDyn.getString("filepath");
|
|
|
+ /**
|
|
|
+ * 获取持久化附件的预览url
|
|
|
+ * @param path 持久化附件的downloadUrl相对路径
|
|
|
+ * @return 持久化附件的预览url
|
|
|
+ * 入参示例: /tenant_devcore_dev/1402323749146986496/202305/1683569603244172288/5b3c272f9d5a42fdbecddf2d84bcdd56/Wo rd文档.docx
|
|
|
+ */
|
|
|
+ String previewUrl = UrlService.getAttachmentPreviewUrl(filepath);
|
|
|
+ String downloadUrl = UrlService.getAttachmentDownloadUrl(filepath);
|
|
|
+ //previewUrl = previewUrl.replace("http://127.0.0.1:8881","https://d-kd.jeyoupharma.com:8022");
|
|
|
+ //downloadUrl = downloadUrl.replace("http://127.0.0.1:8881","https://d-kd.jeyoupharma.com:8022");
|
|
|
+
|
|
|
+ Map<String,Object> attMap = new HashMap<>();
|
|
|
+ attMap.put("previewurl",previewUrl);
|
|
|
+ attMap.put("url",downloadUrl);
|
|
|
+ attMap.put("uid",attachmentMap.get("uid"));
|
|
|
+ attMap.put("type", attachmentMap.get("type"));
|
|
|
+ attMap.put("name",attachmentMap.get("name"));
|
|
|
+ attMap.put("size", attachmentMap.get("size"));
|
|
|
+ attMap.put("status","success");
|
|
|
+ attMap.put("visible","1000");
|
|
|
+
|
|
|
+ return attMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Map<String, Object> getAttachmentFile(Long billId) {
|
|
|
+
|
|
|
+ //创建一条基础资料数据-附件字段
|
|
|
+ //获取单据信息,并查询单据中的附件字段
|
|
|
+ QFilter qf = new QFilter("id", QCP.equals, billId);
|
|
|
+ DynamicObject file =BusinessDataServiceHelper.loadSingle("bei_elecreceipt", "attachmentpanel",new QFilter[]{qf});
|
|
|
+ //获取单据中附件面板信息
|
|
|
+ List<Map<String, Object>> atts = AttachmentServiceHelper.getAttachments("bei_elecreceipt", file.getPkValue().toString(), "attachmentpanel");
|
|
|
+ //遍历文件 电子回单只有一条
|
|
|
+ for (Map<String, Object> att: atts) {
|
|
|
+ return att;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
protected void doRefresh(){
|