带EXCEL附件邮件发送相关代码

news2024/11/23 20:21:46

1.查看生成的邮件

2.1 非面向对象的方式(demo直接copy即可)

​
REPORT Z12.
DATA: IT_DOCUMENT_DATA TYPE SODOCCHGI1,
      IT_CONTENT_TEXT  TYPE STANDARD TABLE OF SOLISTI1 WITH HEADER LINE,
      IT_PACKING_LIST  TYPE TABLE OF SOPCKLSTI1 WITH HEADER LINE,
      IT_RECEIVERS     TYPE STANDARD TABLE OF SOMLRECI1 WITH HEADER LINE,
      LC_MAIL_ATTACH   TYPE STRING,
      LT_CONTENT_HEX   TYPE STANDARD TABLE OF SOLIX WITH HEADER LINE,
      LT_OBJECT_HEADER TYPE STANDARD TABLE OF SOLISTI1 WITH HEADER LINE,
      LC_MAIL_XATTACH  TYPE XSTRING,
      LV_SEND_ALL      TYPE C,
      IT_MAKT          LIKE TABLE OF MAKT WITH HEADER LINE,
      FIR_DATE         TYPE SY-DATUM,
      MIMETYPE         TYPE CHAR64.
DATA: IT_ITAB TYPE TABLE OF ITAB WITH HEADER LINE,
      WA_ITAB TYPE ITAB.

CONSTANTS:LC_TAB  TYPE C VALUE CL_BCS_CONVERT=>GC_TAB,       "excel换格符
          LC_CTRL TYPE C VALUE CL_BCS_CONVERT=>GC_CRLF.      "excel换行符

  PERFORM SEND_EMAIL.


*&---------------------------------------------------------------------*
*&      Form  SEND_EMAIL
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM SEND_EMAIL.
  DATA SY_VLINE TYPE I.
  DATA:MBLNR TYPE STRING,   "物料凭证
       MATNR TYPE STRING,   "物料
       MJAHR TYPE STRING,   "年度
       MAKTX TYPE STRING.   "物料描述

****邮件标题信息
  IT_DOCUMENT_DATA-OBJ_DESCR = '邮件主题1' .    "内容的简短描述
  IT_DOCUMENT_DATA-PRIORITY = '1'.             "优先次序  1~9  1:最高优先权
  IT_DOCUMENT_DATA-OBJ_NAME = 'OFFER'.
  IT_DOCUMENT_DATA-OBJ_LANGU = SY-LANGU.

*****邮件正文信息
  IT_CONTENT_TEXT = '各位好:'.
  APPEND IT_CONTENT_TEXT.
  IT_CONTENT_TEXT = '  此邮件为测试邮件!!!!!!!'.
  APPEND IT_CONTENT_TEXT.

  DESCRIBE TABLE IT_CONTENT_TEXT LINES SY_VLINE.
  IT_DOCUMENT_DATA-DOC_SIZE = 255 * ( SY_VLINE - 1 ) + STRLEN( IT_CONTENT_TEXT ).  "SAPoffice 文档的大小(用于 API1)

  IT_PACKING_LIST-TRANSF_BIN = SPACE.
  IT_PACKING_LIST-HEAD_START = 1 .
  IT_PACKING_LIST-HEAD_NUM =  0 .
  IT_PACKING_LIST-BODY_START = 1. "控制从第几行开始读
  IT_PACKING_LIST-BODY_NUM = SY_VLINE."控制读到第几行
  IT_PACKING_LIST-DOC_TYPE = 'RAW'.
  APPEND IT_PACKING_LIST.


***收件人信息
  IT_RECEIVERS-RECEIVER = 'MEIQIAN.LIANG@HAND-CHINA.COM'.  "收件人地址
  IT_RECEIVERS-REC_TYPE = 'U'.
  IT_RECEIVERS-COM_TYPE = 'INT'.
  IT_RECEIVERS-NOTIF_DEL =  'X'.
  IT_RECEIVERS-NOTIF_NDEL = 'X'.
  APPEND IT_RECEIVERS.

  CONCATENATE '物料'     LC_TAB
  '物料凭证' LC_TAB
  '物料描述' LC_TAB
  '年度'     LC_CTRL INTO LC_MAIL_ATTACH.   "lc_ctrl换行符

  CLEAR:MBLNR, MATNR, MJAHR, MAKTX.
  MBLNR  = '7777777'.
  MATNR  = '7777777'.
  MJAHR  = '7777'.
  MAKTX  = 'seven'."物料类型

  CONCATENATE LC_MAIL_ATTACH
  MATNR  LC_TAB
  MBLNR  LC_TAB
  MJAHR  LC_TAB
  MAKTX  LC_CTRL INTO LC_MAIL_ATTACH.      "lc_ctrl换行符

  CLEAR:MBLNR, MATNR, MJAHR, MAKTX.
  MBLNR  = '8888888'.
  MATNR  = '8888888'.
  MJAHR  = '8888'.
  MAKTX  = 'seven'."物料类型

  CONCATENATE LC_MAIL_ATTACH
  MATNR  LC_TAB
  MBLNR  LC_TAB
  MJAHR  LC_TAB
  MAKTX  LC_CTRL INTO LC_MAIL_ATTACH.      "lc_ctrl换行符

  MIMETYPE = 'APPLICATION/MSEXCEL;CHARSET=UTF-16LE'.
  CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
    EXPORTING
      TEXT     = LC_MAIL_ATTACH
      MIMETYPE = MIMETYPE
    IMPORTING
      BUFFER   = LC_MAIL_XATTACH
    EXCEPTIONS
      FAILED   = 1
      OTHERS   = 2.

  IF SY-SUBRC = 0.
    CONCATENATE CL_ABAP_CHAR_UTILITIES=>BYTE_ORDER_MARK_LITTLE LC_MAIL_XATTACH INTO LC_MAIL_XATTACH IN BYTE MODE.
  ENDIF.

  CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' "将Xtring转化成二进制格式并保存到内表中
    EXPORTING
      BUFFER     = LC_MAIL_XATTACH
    TABLES
      BINARY_TAB = LT_CONTENT_HEX.

  "不知道干啥用的
  LT_OBJECT_HEADER = 'Seven test'.
  APPEND LT_OBJECT_HEADER.

  DESCRIBE TABLE LT_CONTENT_HEX LINES SY_VLINE.

  IT_PACKING_LIST-TRANSF_BIN = 'X'.
  IT_PACKING_LIST-HEAD_START = 1 .
  IT_PACKING_LIST-HEAD_NUM =  0 .
  IT_PACKING_LIST-BODY_START = 1.
  IT_PACKING_LIST-BODY_NUM = SY_VLINE.
  IT_PACKING_LIST-DOC_TYPE = 'XLS'.
  IT_PACKING_LIST-DOC_SIZE = 255 * SY_VLINE.
  IT_PACKING_LIST-OBJ_NAME = '附件名'.
  IT_PACKING_LIST-OBJ_DESCR = IT_PACKING_LIST-OBJ_NAME."文档名字
  APPEND IT_PACKING_LIST.


  "方法1  无法指定发送人邮箱
  CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
      DOCUMENT_DATA              = IT_DOCUMENT_DATA
      PUT_IN_OUTBOX              = 'X'
      COMMIT_WORK                = 'X'
    IMPORTING
      SENT_TO_ALL                = LV_SEND_ALL
*     NEW_OBJECT_ID              =
    TABLES
      PACKING_LIST               = IT_PACKING_LIST[]
      OBJECT_HEADER              = LT_OBJECT_HEADER[]
*     contents_bin               =
      CONTENTS_TXT               = IT_CONTENT_TEXT[]
      CONTENTS_HEX               = LT_CONTENT_HEX[]
*     object_para                =
*     object_parb                =
      RECEIVERS                  = IT_RECEIVERS[]
    EXCEPTIONS
      TOO_MANY_RECEIVERS         = 1
      DOCUMENT_NOT_SENT          = 2
      DOCUMENT_TYPE_NOT_EXIST    = 3
      OPERATION_NO_AUTHORIZATION = 4
      PARAMETER_ERROR            = 5
      X_ERROR                    = 6
      ENQUEUE_ERROR              = 7
      OTHERS                     = 8.

*  "方法2  可以指定发送人邮箱
*  CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
*    EXPORTING
*      DOCUMENT_DATA              = IT_DOCUMENT_DATA
*      PUT_IN_OUTBOX              = 'X'
*      SENDER_ADDRESS             = 'MEIQIAN.LIANG@HAND-CHINA.COM'
*      SENDER_ADDRESS_TYPE        = 'INT'
*      COMMIT_WORK                = 'X'
**     IP_ENCRYPT                 =
**     IP_SIGN                    =
**     IV_VSI_PROFILE             =
*    IMPORTING
*      SENT_TO_ALL                = LV_SEND_ALL
**     NEW_OBJECT_ID              =
**     SENDER_ID                  =
*    TABLES
*      PACKING_LIST               = IT_PACKING_LIST[]
*      OBJECT_HEADER              = LT_OBJECT_HEADER[]
**     CONTENTS_BIN               =
*      CONTENTS_TXT               = IT_CONTENT_TEXT[]
*      CONTENTS_HEX               = LT_CONTENT_HEX[]
**     OBJECT_PARA                =
**     OBJECT_PARB                =
*      RECEIVERS                  = IT_RECEIVERS[]
**     ET_VSI_ERROR               =
*    EXCEPTIONS
*      TOO_MANY_RECEIVERS         = 1
*      DOCUMENT_NOT_SENT          = 2
*      DOCUMENT_TYPE_NOT_EXIST    = 3
*      OPERATION_NO_AUTHORIZATION = 4
*      PARAMETER_ERROR            = 5
*      X_ERROR                    = 6
*      ENQUEUE_ERROR              = 7
*      OTHERS                     = 8.
*  IF SY-SUBRC <> 0.
**   Implement suitable error handling here
*  ELSE.
*  BREAK-POINT.
*  ENDIF.

ENDFORM.                    "SEND_EMAIL

​

非面向对象运行效果图:

如果要抄送则增加以下属性:

2.2面向对象的方法


REPORT Z1234.

TABLES:MSEG,SSCRFIELDS,MARA,ZOWMS_DAYSTOCK_R,ADR6.
TYPE-POOLS:ICON,SLIS.


TYPES: BEGIN OF TYS_DETAIL,
         TOTAL(100),
         SEL(1),
         STATUS(4),
         ITEM_STATUS(4),
         CYMENG         TYPE MSEG-MENGE, "差异数量
         XCHAR          TYPE MARC-XCHAR, "批次管理标识
         MAKTX          TYPE MAKT-MAKTX,
         LGOBE          TYPE T001L-LGOBE,
         MEINS          TYPE MARA-MEINS,
         LABST          TYPE MARD-LABST. "SAP库存
        INCLUDE STRUCTURE ZOWMS_DAYSTOCK_R.
TYPES:     END OF TYS_DETAIL.
DATA: GT_DETAIL     TYPE STANDARD TABLE OF TYS_DETAIL,
      GT_DETAIL_TMP TYPE TABLE OF TYS_DETAIL,
      GT_DETAIL_KEY TYPE TABLE OF TYS_DETAIL.


DATA FUNCTXT TYPE SMP_DYNTXT.


DATA: I_BDCDATA   LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

*ALV定义
DATA: GT_FIELDCAT TYPE LVC_T_FCAT,
      GV_CODE     LIKE SY-UCOMM,
      GW_LAYOUT   TYPE LVC_S_LAYO,
      I_CELLCLR   TYPE LVC_S_SCOL. "单元格颜色
TYPES: BEGIN OF SLIS_EXTAB,
         FCODE LIKE RSMPE-FUNC,
       END OF SLIS_EXTAB.
TYPES: SLIS_T_EXTAB TYPE SLIS_EXTAB OCCURS 1.
DATA:LS_CELLTAB TYPE LVC_S_STYL.
DATA LS_STABLE TYPE LVC_S_STBL.
DATA:GS_FIELDCAT TYPE LVC_S_FCAT.
DATA:GT_HEADER TYPE TABLE OF CHAR30,
     GV_CHAR30 TYPE CHAR30.
*子ALV调用
DATA:
  LT_FIELDCAT TYPE LVC_T_FCAT,
  LS_FCAT     TYPE LVC_S_FCAT,
  LS_SELFIELD TYPE SLIS_SELFIELD.



SELECTION-SCREEN BEGIN OF BLOCK BLK2 WITH FRAME TITLE TEXT-T02.
SELECT-OPTIONS: S_RECEP FOR ADR6-SMTP_ADDR NO INTERVALS
                                          MODIF ID MAL,"收件人
                S_SCR FOR ADR6-SMTP_ADDR  NO INTERVALS "抄送人
                                          MODIF ID MAL.
SELECTION-SCREEN END OF BLOCK BLK2 .


END-OF-SELECTION.


  PERFORM FRM_SEND_MAIL.



FORM FRM_SEND_MAIL .
  DATA: BCS_EXCEPTION        TYPE REF TO CX_BCS,
        ERRORTEXT            TYPE STRING,
        LCL_SEND_REQUEST     TYPE REF TO CL_BCS,
        LCL_DOCUMENT         TYPE REF TO CL_DOCUMENT_BCS,
        LCL_RECIPIENT        TYPE REF TO IF_RECIPIENT_BCS,
        LCL_SENDER           TYPE REF TO CL_CAM_ADDRESS_BCS,
        T_ATTACHMENT_HEADER  TYPE SOLI_TAB,
        WA_ATTACHMENT_HEADER LIKE LINE OF T_ATTACHMENT_HEADER,
        ATTACHMENT_SUBJECT   TYPE SOOD-OBJDES,
        SOOD_BYTECOUNT       TYPE SOOD-OBJLEN,
        MAIL_TITLE           TYPE SO_OBJ_DES,
        T_MAILTEXT           TYPE SOLI_TAB,
        WA_MAILTEXT          LIKE LINE OF T_MAILTEXT,
        SEND_TO              TYPE ADR6-SMTP_ADDR,
        SENT                 TYPE OS_BOOLEAN,
        LV_MAILNAME          TYPE SOOD-OBJDES,
        BINARY_CONTENT       TYPE SOLIX_TAB.
  DATA:LV_SMTP_ADDR          TYPE ADR6-SMTP_ADDR.

  " Set mail subject
  MAIL_TITLE     = '菜鸟&SAP库存比对邮件推送'.
  LV_MAILNAME = '菜鸟&SAP库存比对报表'.
  " Set mail context
  DATA(LV_STRING) = |您好,附件是菜鸟&SAP库存比对报表,请查阅,谢谢|.
  WA_MAILTEXT    = LV_STRING.

  APPEND WA_MAILTEXT TO T_MAILTEXT.
  CONCATENATE '事务码为:ZM390 程序为:ZMM390。' 'Job时间:' SY-DATUM '' SY-UZEIT INTO WA_MAILTEXT.
  APPEND WA_MAILTEXT TO T_MAILTEXT.

  TRY.
* Create send request
      LCL_SEND_REQUEST = CL_BCS=>CREATE_PERSISTENT( ).
* Create new document with mailtitle and mailtextg
      LCL_DOCUMENT = CL_DOCUMENT_BCS=>CREATE_DOCUMENT( I_TYPE    = 'RAW' "#EC NOTEXT
      I_TEXT    = T_MAILTEXT
      I_LANGUAGE = SY-LANGU
      I_SUBJECT = MAIL_TITLE ).

* add document to send request
      LCL_SEND_REQUEST->SET_DOCUMENT( LCL_DOCUMENT ).

*收件人
      LOOP AT S_RECEP.
        LV_SMTP_ADDR = S_RECEP-LOW.
        LCL_RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( LV_SMTP_ADDR  ).
        LCL_SEND_REQUEST->ADD_RECIPIENT( LCL_RECIPIENT ).
      ENDLOOP.

* 抄送人
      LOOP AT S_SCR.
        LV_SMTP_ADDR = S_SCR-LOW.
        LCL_RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( LV_SMTP_ADDR ).
        LCL_SEND_REQUEST->ADD_RECIPIENT(
        I_RECIPIENT  = LCL_RECIPIENT
        I_EXPRESS    = 'X'
        I_COPY       = 'X'
        I_BLIND_COPY = ' '
        I_NO_FORWARD = ' ' ).
      ENDLOOP.
*     添加抄送人

*lcl_document->
      CLEAR LV_STRING.
      PERFORM FRM_SET_DOCUMENT_BODY  CHANGING BINARY_CONTENT.

      LCL_DOCUMENT->ADD_ATTACHMENT(
      I_ATTACHMENT_TYPE    = 'XLS'                        " 附件格式
      I_ATTACHMENT_SUBJECT = LV_MAILNAME                  " 附件名称
*      i_attachment_size    = size                         "附件大小
      I_ATTACHMENT_LANGUAGE = SY-LANGU
*      I_ATTACHMENT_HEADER   =
      I_ATT_CONTENT_HEX    = BINARY_CONTENT
      ).            "附件内容


      LCL_SEND_REQUEST->SET_DOCUMENT( LCL_DOCUMENT ).
      SENT = LCL_SEND_REQUEST->SEND( I_WITH_ERROR_SCREEN = 'X' ).

    CATCH CX_BCS INTO BCS_EXCEPTION.
      ERRORTEXT = BCS_EXCEPTION->IF_MESSAGE~GET_TEXT( ).
      MESSAGE ERRORTEXT TYPE 'S' DISPLAY LIKE 'E'.
  ENDTRY.

  COMMIT WORK.

ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  FRM_SET_DOCUMENT_BODY
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--P_BINARY_CONTENT  text
*----------------------------------------------------------------------*
FORM FRM_SET_DOCUMENT_BODY  CHANGING PT_BODY TYPE SOLIX_TAB.
  TYPES: BEGIN OF TY_DATA,
           WERKS  TYPE ZOWMS_DAYSTOCK_R-WERKS, "工厂
           MATNR  TYPE ZOWMS_DAYSTOCK_R-MATNR, "物料
           MAKTX  TYPE MAKT-MAKTX,             "物料描述
           LGORT  TYPE ZOWMS_DAYSTOCK_R-LGORT, "库存地点
           LGOBE  TYPE T001L-LGOBE,            "库存地点描述
           CHARG  TYPE ZOWMS_DAYSTOCK_R-CHARG, "批次
           LABST  TYPE MARD-LABST,             "SAP库存数量
           OMENGE TYPE ZOWMS_DAYSTOCK_R-OMENGE, "未结库存
           WMENGE TYPE ZOWMS_DAYSTOCK_R-WMENGE, "OFS未传明细
           TMENGE TYPE ZOWMS_DAYSTOCK_R-TMENGE, "SAP库存数量(含未结)
           SMENGE TYPE ZOWMS_DAYSTOCK_R-SMENGE, "WMS库存数量
           CYMENG TYPE MSEG-MENGE.             "差异数量
  TYPES: END OF TY_DATA.

  DATA:LV_STRING   TYPE STRING,
       LC_MIMETYPE TYPE CHAR64 VALUE 'APPLICATION/MSEXCEL;charset=utf-16le',
       LV_XATTACH  TYPE XSTRING,
       LV_VALUE    TYPE STRING,
       LV_FLAG     TYPE C.
  DATA:LT_MAIL TYPE TABLE OF TY_DATA,
       LS_MAIL TYPE TY_DATA.

  CLEAR:GT_HEADER.

  APPEND '工厂' TO GT_HEADER.
  APPEND '物料' TO GT_HEADER.
  APPEND '物料描述' TO GT_HEADER.
  APPEND '库存地点' TO GT_HEADER.
  APPEND '库存地点描述' TO GT_HEADER.
  APPEND 'SAP库存数量' TO GT_HEADER.
  APPEND '未结库存' TO GT_HEADER.
  APPEND 'OFS未传SAP数量' TO GT_HEADER.
  APPEND 'SAP库存数量(含未结未传)' TO GT_HEADER.
  APPEND 'WMS库存数量' TO GT_HEADER.
  APPEND  '差异' TO GT_HEADER.

  LOOP AT GT_HEADER INTO GV_CHAR30.
    CONDENSE GV_CHAR30.
    LV_STRING = |{ LV_STRING }{ GV_CHAR30 }{ CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB }|.
  ENDLOOP.
  LV_STRING = LV_STRING && CL_ABAP_CHAR_UTILITIES=>CR_LF.

  "发送有差异的邮件数据
  MOVE-CORRESPONDING GT_DETAIL[] TO LT_MAIL[].
  DELETE  LT_MAIL[] WHERE CYMENG EQ '0.000'.
  "判断是否发送批次字段的数据
  DATA(LV_LINES1) = LINES( GT_HEADER ).
  IF LV_LINES1 = '11'.
    LV_FLAG = 'X'.
  ENDIF.

  DATA(LV_LINES) = LINES( GT_FIELDCAT ).

  LOOP AT LT_MAIL ASSIGNING FIELD-SYMBOL(<FS_STURC>).
    DO LV_LINES TIMES.
      IF SY-INDEX = 6 AND LV_FLAG = 'X'.
        CONTINUE.
      ENDIF.
      ASSIGN COMPONENT SY-INDEX OF STRUCTURE <FS_STURC> TO FIELD-SYMBOL(<FS_VALUE>).
      IF SY-SUBRC = 0.
        LV_VALUE = <FS_VALUE>.
        CONDENSE LV_VALUE.
        DATA(LV_LEN) = STRLEN( LV_VALUE ) - 1.
        IF LV_LEN > 0.
          IF LV_VALUE+LV_LEN = '-'.
            LV_VALUE = '-' && LV_VALUE(LV_LEN).
            CONDENSE LV_VALUE NO-GAPS.
            CLEAR LV_LEN.
          ENDIF.
        ENDIF.
      ELSE.
        LV_VALUE = ''.
      ENDIF.
      IF LV_LINES <> SY-INDEX.
        LV_STRING = |{ LV_STRING }{ LV_VALUE }{ CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB }|.
      ELSE.
        LV_STRING = |{ LV_STRING }{ LV_VALUE }{ CL_ABAP_CHAR_UTILITIES=>CR_LF }|.
      ENDIF.
    ENDDO.
  ENDLOOP.
  CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
    EXPORTING
      TEXT     = LV_STRING
      MIMETYPE = LC_MIMETYPE
    IMPORTING
      BUFFER   = LV_XATTACH
    EXCEPTIONS
      FAILED   = 1
      OTHERS   = 2.
* Add the file header for utf-16le. .
  IF SY-SUBRC = 0.
    CONCATENATE CL_ABAP_CHAR_UTILITIES=>BYTE_ORDER_MARK_LITTLE
    LV_XATTACH INTO LV_XATTACH IN BYTE MODE.
  ENDIF.
  CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
      BUFFER     = LV_XATTACH
    TABLES
      BINARY_TAB = PT_BODY.
ENDFORM.

面向对象效果如下:

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1653078.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

ansible------inventory 主机清单

目录 inventory 中的变量 2&#xff09;组变量[webservers:vars] #表示为 webservers 组内所有主机定义变量&#xff0c;所有组内成 员都有效 ansible_userrootansible_passwordabc1234 3&#xff09; [all:vars…

数据湖与数据网格:引领组织数据策略的未来

十多年来&#xff0c;组织已经采用数据湖来克服数据仓库的技术限制&#xff0c;并发展成为更加以数据为中心的实体。虽然许多组织已经使用数据湖来探索新的数据用例并改进其数据驱动的方法&#xff0c;但其他组织发现所承诺的好处很难实现。因此&#xff0c;许多数据湖计划的有…

文件下载出现 IOExpcetion: closed

异常原因截图 : 异常代码位置 : 出现的原因是 使用 try-with-resources, downloadFile 方法执行完毕, 文件流被关闭了...导致前面读取文件字节, 异常提示已经关闭... try (Response response OkHttpUtils.getInstance().client.newCall(new Request.Builder().url(fileUrl)…

Etcd集群选举细节

日志级别 在 etcd 集群中&#xff0c;领导者选举是 Raft 协议的一部分&#xff0c;用于在当前领导者失败或无法与集群中的其他节点通信时选出新的领导者。以下是您提供的日志中与领导者选举相关的一些关键条目&#xff0c;以及对它们的详细说明&#xff1a; 节点失去领导者&am…

python分析预测退休后养老金金额

欢迎关注我👆,收藏下次不迷路┗|`O′|┛ 嗷~~ 目录 一.前言 二.代码 三.总结 一.前言 养老金,也称为退休金或退休费,是一种主要的社会养老保险待遇。它旨在保障职工退休后的基本生活需要,根据劳动者对社会所作的贡献和所具备的享受养老保险资格或退休条件,按月或一次…

电脑屏幕监控软件有哪些?8款受欢迎的电脑屏幕监控软件

电脑屏幕监控软件有哪些&#xff1f;8款受欢迎的电脑屏幕监控软件 市场上有很多监控软件&#xff0c;因为太多&#xff0c;很多老板不知道怎么选&#xff0c;今天小编从它们各自的特点、优势、未来发展趋势几方面&#xff0c;介绍8款受欢迎的电脑屏幕监控软件。 第一是&#x…

【优选算法】——Leetcode——611. 有效三角形的个数

目录 ​编辑 1.题目 2 .补充知识 3.解法⼀&#xff08;暴⼒求解&#xff09;&#xff08;可能会超时&#xff09;&#xff1a; 算法思路&#xff1a; 算法代码&#xff1a; 4.解法⼆&#xff08;排序双指针&#xff09;&#xff1a; 算法思路&#xff1a; 以输入: nums …

还有谁不想薅云渲染的羊毛?五种云渲染优惠知道就是省到

不管你是效果图设计师还是动画设计师&#xff0c;在面对紧急或大量的渲染任务时&#xff0c;总会有云渲染的需要。然而&#xff0c;现在的云渲染越来越贵&#xff0c;我们该如何尽可能地节约成本完成渲染任务呢&#xff1f;本文将为你介绍云渲染的五种优惠形式&#xff0c;看完…

Compose 生命周期和副作用

文章目录 Compose 生命周期和副作用生命周期副作用APIDisposableEffectSIdeEffectLaunchedEffectrememberCoroutineScoperememberUpdatedStatesnapshotFlowproduceStatederivedStateOf Compose 生命周期和副作用 生命周期 OnActive&#xff1a;添加到视图树。即Composable被首…

传闻不断!TCL紧急澄清 | 百能云芯

TCL科技5月7日晚间发布澄清公告称&#xff0c;近日关注到有媒体发布《TCL华星年内投630亿元加入8代oled线竞逐&#xff01;》《TCL华星计划年内投资第八代OLED》等相关报道。公司目前无新建8代或8.6代OLED产线的投资计划&#xff0c;公司不存在通过定增募集资金新建显示产线的计…

期权和期货有什么区别?

今天期权懂带你了解期权和期货有什么区别&#xff1f;期权和期货是两种常见的衍生金融工具&#xff0c;它们在结构和盈利方式上存在一些关键的区别&#xff1a; 期权 期权是一种给予持有者在未来某个时间以特定价格买入或卖出基础资产的权利&#xff0c;但不是义务。期权的主要…

直播报名 | 珈和科技携手潍柴雷沃共探“现代农场”未来式

数据赋农季系列直播第四期&#xff0c;我们将以“未来农业发展趋势之农场智慧化、管理数据化”为主题展开&#xff0c;此次系列直播由珈和科技及湖北珞珈实验室共同主办&#xff0c;第四期直播很荣幸邀请到潍柴雷沃参与其中&#xff0c;双方将就智慧农服平台和数据交易SaaS平台…

C#里如何设置输出路径,不要net7.0-windows

官网介绍&#xff1a; 更改生成输出目录 - Visual Studio (Windows) | Microsoft Learn <PropertyGroup> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <AppendRuntimeIdentifierToOutputPath>false</Appen…

RabbitMQ基础入门

初识MQ 微服务间通讯有同步和异步两种方式&#xff1a; 同步通讯&#xff1a;就像打电话&#xff0c;需要实时响应。 异步通讯&#xff1a;就像发邮件&#xff0c;不需要马上回复。 两种方式各有优劣&#xff0c;打电话可以立即得到响应&#xff0c;但是你却不能跟多个人同…

Python自动化下载指定公开页面文件

示例代码如下&#xff0c;但你拿到本地之需要做两件事才能运行 from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys import time# 设置Se…

【电路笔记】-Twin-T振荡器

Twin-T振荡器 文章目录 Twin-T振荡器1、概述2、Twin-T振荡器3、Twin-T放大4、Twin-T 振荡器示例5、总结Twin-T 振荡器是另一种 RC 振荡器电路,它使用两个并联的 RC 网络来产生单一频率的正弦输出波形。 1、概述 Twin-T 振荡器是另一种类型的 RC 振荡器,它产生正弦波输出,用…

已经安装tensorflow,仍报错No module named ‘tensorflow‘

在安装某些python虚拟环境的教程文章中&#xff0c;经常看到有评论区说安装了但是调用显示无模块&#xff0c;例如pytorch和tensorflow等等。 其实跟之前我写过的一篇文章解决方法类似&#xff0c;就是python项目中需要应用哪个虚拟环境&#xff0c;这个项目的python解释器就选…

LCD驱动IC-抗干扰液晶段码显示屏驱动芯片,液晶显示驱动原厂-VK2C23A/B LQFP64/48

产品品牌&#xff1a;永嘉微电/VINKA 产品型号&#xff1a;VK2C23A/B 封装形式&#xff1a;LQFP64/48 概述 VK2C23是一个点阵式存储映射的LCD驱动器&#xff0c;可支持最大224点&#xff08;56SEGx4COM&#xff09; 或者最大416点&#xff08;52SEGx8COM&#xff09;的LCD屏。…

API开发的必备神器:华为云CodeArts API实用体验入门篇

今天我想给大家推荐一款API全生命周期研发与管理工具&#xff1a;华为云CodeArts API。 作为互联网软件的开发者&#xff0c;在软件研发的过程中&#xff0c;API的开发、调试、测试是必不可少的。之前我使用的是Postman这类工具来辅助开发&#xff0c; Postman在接口调试方面确…

第 8 章 电机调速(自学二刷笔记)

重要参考&#xff1a; 课程链接:https://www.bilibili.com/video/BV1Ci4y1L7ZZ 讲义链接:Introduction Autolabor-ROS机器人入门课程《ROS理论与实践》零基础教程 8.3.5 电机调速01_PID控制理论 场景&#xff1a; 速度信息可以以m/s为单位&#xff0c;或者也可以转换成转速 …