|
@@ -21,7 +21,9 @@ import kd.bos.servicehelper.PrintServiceHelper;
|
|
import kd.bos.servicehelper.QueryServiceHelper;
|
|
import kd.bos.servicehelper.QueryServiceHelper;
|
|
import kd.bos.svc.util.print.PrintFileUtil;
|
|
import kd.bos.svc.util.print.PrintFileUtil;
|
|
import kd.bos.util.CollectionUtils;
|
|
import kd.bos.util.CollectionUtils;
|
|
|
|
+import kd.bos.util.ExceptionUtils;
|
|
import kd.bos.web.actions.utils.FilePathUtil;
|
|
import kd.bos.web.actions.utils.FilePathUtil;
|
|
|
|
+import kd.tmc.bei.common.helper.ReceiptPrintHelper;
|
|
import nckd.jimin.jyyy.fi.common.constant.BillTypeConstants;
|
|
import nckd.jimin.jyyy.fi.common.constant.BillTypeConstants;
|
|
import nckd.jimin.jyyy.fi.common.constant.ErPrintSetConstant;
|
|
import nckd.jimin.jyyy.fi.common.constant.ErPrintSetConstant;
|
|
import nckd.jimin.jyyy.fi.common.entity.MergePrintEntity;
|
|
import nckd.jimin.jyyy.fi.common.entity.MergePrintEntity;
|
|
@@ -36,8 +38,6 @@ import java.util.Map;
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
-import static java.util.Comparator.comparing;
|
|
|
|
-
|
|
|
|
public class ReceiveTicketUtils {
|
|
public class ReceiveTicketUtils {
|
|
private static Log logger = LogFactory.getLog(ReceiveTicketUtils.class);
|
|
private static Log logger = LogFactory.getLog(ReceiveTicketUtils.class);
|
|
|
|
|
|
@@ -223,22 +223,55 @@ public class ReceiveTicketUtils {
|
|
*/
|
|
*/
|
|
public static byte[] getElecReceiptPrintUrl(Object receiptId){
|
|
public static byte[] getElecReceiptPrintUrl(Object receiptId){
|
|
List<Map<String, Object>> attachments = AttachmentServiceHelper.getAttachments(BillTypeConstants.BEI_ELECRECEIPT, receiptId, "attachmentpanel");
|
|
List<Map<String, Object>> attachments = AttachmentServiceHelper.getAttachments(BillTypeConstants.BEI_ELECRECEIPT, receiptId, "attachmentpanel");
|
|
- if(attachments.size() > 1){
|
|
|
|
- throw new KDBizException("电子回单文件存在多个,请修复数据后再打印。");
|
|
|
|
- }
|
|
|
|
- Object relativeUrl = attachments.get(0).get("relativeUrl");
|
|
|
|
- if (StringUtils.isNotBlank(relativeUrl)) {
|
|
|
|
- try{
|
|
|
|
|
|
+ List<byte[]> resList = new ArrayList<>(10);
|
|
|
|
+ for (Map<String, Object> attachmentMap: attachments) {
|
|
|
|
+ if(attachmentMap.get("type") != null
|
|
|
|
+ && ("pdf".equals(attachmentMap.get("type").toString()) || "jpg".equals(attachmentMap.get("type").toString()))) {
|
|
|
|
+
|
|
|
|
+ if(attachmentMap == null) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Object relativeUrl = attachmentMap.get("relativeUrl");
|
|
|
|
+ if (relativeUrl == null) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
String path = FilePathUtil.dealPath(relativeUrl.toString(), "attach");
|
|
String path = FilePathUtil.dealPath(relativeUrl.toString(), "attach");
|
|
InputStream inputStream = FileServiceFactory.getAttachmentFileService().getInputStream(path);
|
|
InputStream inputStream = FileServiceFactory.getAttachmentFileService().getInputStream(path);
|
|
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
|
|
- return getBytes(inputStream,outputStream);
|
|
|
|
- }catch (Exception e){
|
|
|
|
- logger.error("getElecReceiptPrintUrl_getBytes_error",e);
|
|
|
|
- throw new KDBizException("获取电子回单文件异常:" + e.getMessage());
|
|
|
|
|
|
+
|
|
|
|
+ if("jpg".equals(attachmentMap.get("type").toString())){
|
|
|
|
+ ReceiptPrintHelper.imageConvertPdf(path, resList, inputStream);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ byte[] bytesAtt = null;
|
|
|
|
+ try {
|
|
|
|
+ bytesAtt = getBytes(inputStream,outputStream);
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
|
|
+ if(bytesAtt != null){
|
|
|
|
+ resList.add(bytesAtt);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ byte[] mergeMultiPdf = null;
|
|
|
|
+ if (!resList.isEmpty()) {
|
|
|
|
+ if (resList.size() > 1) {
|
|
|
|
+ try {
|
|
|
|
+ mergeMultiPdf = ReceiptPrintHelper.mergeMultiPdf(resList);
|
|
|
|
+ } catch (Exception var5) {
|
|
|
|
+ throw new KDBizException(ExceptionUtils.getExceptionStackTraceMessage(var5));
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ mergeMultiPdf = (byte[])resList.get(0);
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
- return null;
|
|
|
|
|
|
+ return mergeMultiPdf;
|
|
}
|
|
}
|
|
|
|
|
|
public static byte[] getBytes(InputStream inputStream, ByteArrayOutputStream outputStream) throws IOException {
|
|
public static byte[] getBytes(InputStream inputStream, ByteArrayOutputStream outputStream) throws IOException {
|