|
@@ -4,6 +4,8 @@ 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;
|
|
@@ -28,14 +30,22 @@ import kd.bos.form.events.ClosedCallBackEvent;
|
|
|
import kd.bos.form.events.PreOpenFormEventArgs;
|
|
|
import kd.bos.form.operate.FormOperate;
|
|
|
import kd.bos.form.plugin.AbstractFormPlugin;
|
|
|
+import kd.bos.image.pojo.ImageSysInfo;
|
|
|
+import kd.bos.image.pojo.ViewImageVo;
|
|
|
+import kd.bos.imageplatform.util.SSCImageUtils;
|
|
|
import kd.bos.list.ListShowParameter;
|
|
|
+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.BusinessDataServiceHelper;
|
|
|
+import kd.bos.servicehelper.PrintServiceHelper;
|
|
|
import kd.bos.servicehelper.QueryServiceHelper;
|
|
|
+import kd.bos.servicehelper.image.ImageServiceNewHelper;
|
|
|
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
|
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
|
|
import kd.bos.servicehelper.permission.PermissionServiceHelper;
|
|
|
+import kd.bos.url.UrlService;
|
|
|
import kd.bos.util.CollectionUtils;
|
|
|
import nckd.jimin.jyyy.fi.common.constant.BillTypeConstants;
|
|
|
import nckd.jimin.jyyy.fi.common.constant.ErPrintUserConstant;
|
|
@@ -45,11 +55,15 @@ 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;
|
|
|
|
|
|
public class HandInReceiveTicketPlugin extends AbstractFormPlugin implements RowClickEventListener {
|
|
|
|
|
|
+ private static Log log = LogFactory.getLog(HandInReceiveTicketPlugin.class);
|
|
|
+
|
|
|
private static final String CLOSECALLBACK_MAIL = "closecallback_mail";
|
|
|
|
|
|
@Override
|
|
@@ -186,7 +200,8 @@ public class HandInReceiveTicketPlugin extends AbstractFormPlugin implements Row
|
|
|
String itemKey = evt.getItemKey();
|
|
|
|
|
|
if(HandInReceiveTicketConstant.OPERATE.NCKD_MAIL.equals(itemKey) || HandInReceiveTicketConstant.OPERATE.NCKD_CANCELMAIN.equals(itemKey)
|
|
|
- || HandInReceiveTicketConstant.OPERATE.NCKD_VIEW_VOUCHER.equals(itemKey) || HandInReceiveTicketConstant.OPERATE.NCKD_VIEW_ELECRECEIPT.equals(itemKey)){
|
|
|
+ || HandInReceiveTicketConstant.OPERATE.NCKD_VIEW_VOUCHER.equals(itemKey) || HandInReceiveTicketConstant.OPERATE.NCKD_VIEW_ELECRECEIPT.equals(itemKey)
|
|
|
+ || HandInReceiveTicketConstant.OPERATE.NCKD_IMAGEPREVIEW.equals(itemKey)){
|
|
|
String checkMsg = checkSelectSingle();
|
|
|
if(!StringUtils.isEmpty(checkMsg)) {
|
|
|
getView().showTipNotification(checkMsg);
|
|
@@ -202,6 +217,9 @@ public class HandInReceiveTicketPlugin extends AbstractFormPlugin implements Row
|
|
|
case HandInReceiveTicketConstant.OPERATE.NCKD_CANCELMAIN:
|
|
|
beforeCancleMail(evt);
|
|
|
break;
|
|
|
+ case HandInReceiveTicketConstant.OPERATE.NCKD_IMAGEPREVIEW:
|
|
|
+ beforeImagePreview(evt);
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -230,6 +248,11 @@ public class HandInReceiveTicketPlugin extends AbstractFormPlugin implements Row
|
|
|
|
|
|
}
|
|
|
|
|
|
+ protected void beforeImagePreview(BeforeItemClickEvent evt){
|
|
|
+ // 进行权限校验
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public void itemClick(ItemClickEvent evt) {
|
|
@@ -252,7 +275,52 @@ public class HandInReceiveTicketPlugin extends AbstractFormPlugin implements Row
|
|
|
case HandInReceiveTicketConstant.OPERATE.NCKD_REFRESH:
|
|
|
doRefresh();
|
|
|
break;
|
|
|
+ case HandInReceiveTicketConstant.OPERATE.NCKD_IMAGEPREVIEW:
|
|
|
+ doImagePreview();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ protected void doImagePreview(){
|
|
|
+ String userID = String.valueOf(RequestContext.get().getUserId());
|
|
|
+ String userName = String.valueOf(RequestContext.get().getUserName());
|
|
|
+
|
|
|
+ ImageSysInfo enableImageSysInfo = null;
|
|
|
+ DynamicObject selectBillInfo = getSelectBillInfo(String.join(",",ErReimBurseBillConstant.ID,ErReimBurseBillConstant.KEY_NUMBER));
|
|
|
+ String billType = selectBillInfo.getDataEntityType().getName();
|
|
|
+ try {
|
|
|
+ enableImageSysInfo = SSCImageUtils.getEnableImageSysInfo();
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("获取影像系统异常:" + e.getMessage());
|
|
|
+ }
|
|
|
+ String imageSys;
|
|
|
+ if (enableImageSysInfo == null) {
|
|
|
+ imageSys = ResManager.loadKDString("无启用的影像系统配置,请联系系统管理员。", "ImageReview_0", "bos-image-formplugin", new Object[0]);
|
|
|
+ getView().showTipNotification(imageSys);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ imageSys = enableImageSysInfo.getNumber();
|
|
|
+ log.info("获取到的imagesys:{}" , imageSys);
|
|
|
+ ViewImageVo viewImageVo = new ViewImageVo();
|
|
|
+ viewImageVo.setBillId(selectBillInfo.getString(ErReimBurseBillConstant.ID));
|
|
|
+ viewImageVo.setUserId(userID);
|
|
|
+ viewImageVo.setUserName(userName);
|
|
|
+ viewImageVo.setMobile(false);
|
|
|
+ viewImageVo.setBilltype(billType);
|
|
|
+ viewImageVo.setImageSys(imageSys);
|
|
|
+ viewImageVo = ImageServiceNewHelper.viewPhoto(viewImageVo);
|
|
|
+ if (viewImageVo.getUrl() == null) {
|
|
|
+ getView().showTipNotification(viewImageVo.getMessage());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String url = viewImageVo.getUrl();
|
|
|
+ String message = viewImageVo.getMessage();
|
|
|
+ if (kd.bos.util.StringUtils.isNotEmpty(message)) {
|
|
|
+ getView().showMessage(message);
|
|
|
+ return;
|
|
|
}
|
|
|
+ getView().openUrl(url);
|
|
|
}
|
|
|
|
|
|
protected void doViewVouhcer(){
|
|
@@ -302,9 +370,39 @@ public class HandInReceiveTicketPlugin extends AbstractFormPlugin implements Row
|
|
|
}
|
|
|
|
|
|
protected void doViewElecReceipt(){
|
|
|
+ DynamicObject selectRow = getSelectRows().get(0);
|
|
|
+
|
|
|
+ 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("");
|
|
|
+ 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);
|
|
|
+ }
|
|
|
|
|
|
+ byte[] bytes = PrintServiceHelper.mergeMultiPdf(mergeArray);//拼接文件流
|
|
|
+
|
|
|
+ String fileName = String.format("单据%s电子回单文件文件预览");
|
|
|
+ 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);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
protected void doRefresh(){
|
|
|
|
|
|
int entryRowCount = getModel().getEntryRowCount(HandInReceiveTicketConstant.SCANBILLENTRY.ENTITYID);
|
|
@@ -356,10 +454,21 @@ public class HandInReceiveTicketPlugin extends AbstractFormPlugin implements Row
|
|
|
args.setCancel(true);
|
|
|
return;
|
|
|
}
|
|
|
+ beforeDoPrint(args);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ protected void beforeDoPrint(BeforeDoOperationEventArgs args){
|
|
|
+ DynamicObject billInfo = getSelectBillInfo(ErReimBurseBillConstant.KEY_BILLSTATUS);
|
|
|
+ List<String> status = Arrays.asList("E", "F", "G");
|
|
|
+ if(!status.contains(billInfo.getString(ErReimBurseBillConstant.KEY_BILLSTATUS))){
|
|
|
+ getView().showTipNotification(String.format("单据%s打印失败:只有审核通过、等待付款、已付款状态的单据允许打印。",billInfo.getString(ErReimBurseBillConstant.KEY_BILLNO)));
|
|
|
+ args.setCancel(true);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void afterDoOperation(AfterDoOperationEventArgs args) {
|
|
|
super.afterDoOperation(args);
|
|
@@ -426,10 +535,11 @@ public class HandInReceiveTicketPlugin extends AbstractFormPlugin implements Row
|
|
|
String billId = selectRow.getString(HandInReceiveTicketConstant.SCANBILLENTRY.KEY_NCKD_BILLID);
|
|
|
|
|
|
// 通过打印配置获取单据打印信息
|
|
|
- List<MergePrintEntity> printPdfConfig = ReceiveTicketUtils.getPrintPdfConfig(formId,billId,companyId);
|
|
|
+ List<MergePrintEntity> printPdfConfig = ReceiveTicketUtils.getPrintPdfConfig(formId,Long.valueOf(billId),companyId);
|
|
|
String printFileName = String.format("%s报销信息打印",selectRow.getString(HandInReceiveTicketConstant.SCANBILLENTRY.KEY_NCKD_NUMBER));
|
|
|
String downloadUrl = ReceiveTicketUtils.mergePrintPdf(getView(), printPdfConfig, printFileName);
|
|
|
getView().download(downloadUrl);
|
|
|
+ getView().showSuccessNotification("打印成功。");
|
|
|
}
|
|
|
|
|
|
protected void reloadEntryRow(int[] indexArray){
|