From ce6908f6037b68da6cccd1b355d493303a6979f4 Mon Sep 17 00:00:00 2001 From: "youHong.ai" <774495953@qq.com> Date: Mon, 6 Feb 2023 18:57:02 +0800 Subject: [PATCH] =?UTF-8?q?sap=E5=87=AD=E8=AF=81=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/aiyh/utils/Util.java | 17 + .../aiyh/utils/annotation/RequiredMark.java | 1 + .../java/aiyh/utils/mapper/UtilMapper.java | 18 ++ .../aiyh/utils/recordset/ResultMapper.java | 7 +- .../sapdocking/ReceiptAndPaymentAction.java | 80 +++++ .../sapdocking/VoucherPayableAction.java | 78 +++++ .../sapdocking/config/dto/SapVoucher.java | 28 ++ .../sapdocking/config/dto/VoucherItem.java | 24 ++ .../config/mapper/SapConfigMapper.java | 120 ++++++++ .../config/pojo/SapConfigDetail.java | 43 +++ .../sapdocking/config/pojo/SapConfigMain.java | 43 +++ .../config/service/SapConfigService.java | 291 ++++++++++++++++++ .../config/util/ValueRuleMethod.java | 99 ++++++ .../config/util/ValueRuleMethodNo.java | 19 ++ .../service/VoucherPayableService.java | 203 ++++++++++++ .../SendEmailToExternalPersonnelAction.java | 119 +++++++ .../stagediagram/ModeExpandSaveAction.java | 38 +++ .../mapper/ModeExpandSaveActionMapper.java | 16 + .../service/ModeExpandSaveService.java | 65 ++++ src/test/java/youhong/ai/pcn/UtilTest.java | 41 +++ 20 files changed, 1349 insertions(+), 1 deletion(-) create mode 100644 src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/ReceiptAndPaymentAction.java create mode 100644 src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/VoucherPayableAction.java create mode 100644 src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/dto/SapVoucher.java create mode 100644 src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/dto/VoucherItem.java create mode 100644 src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/mapper/SapConfigMapper.java create mode 100644 src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/pojo/SapConfigDetail.java create mode 100644 src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/pojo/SapConfigMain.java create mode 100644 src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/service/SapConfigService.java create mode 100644 src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/util/ValueRuleMethod.java create mode 100644 src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/util/ValueRuleMethodNo.java create mode 100644 src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/service/VoucherPayableService.java create mode 100644 src/main/java/weaver/youhong/ai/pcn/actioin/sendemail/SendEmailToExternalPersonnelAction.java create mode 100644 src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/ModeExpandSaveAction.java create mode 100644 src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/mapper/ModeExpandSaveActionMapper.java create mode 100644 src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/service/ModeExpandSaveService.java diff --git a/src/main/java/aiyh/utils/Util.java b/src/main/java/aiyh/utils/Util.java index 2508486..7157faf 100644 --- a/src/main/java/aiyh/utils/Util.java +++ b/src/main/java/aiyh/utils/Util.java @@ -2950,6 +2950,16 @@ public class Util extends weaver.general.Util { return mapper.selectDocImageInfo(docId); } + /** + * 查询文档信息 + * + * @param docIds 文档ID + * @return 文档信息 + */ + public static List selectImageInfoByDocIds(String docIds) { + return mapper.selectDocImageInfos(docIds); + } + /** * 查询流程节点配置 * @@ -3582,4 +3592,11 @@ public class Util extends weaver.general.Util { Map pathParam = Util.parseCusInterfacePathParam(process); return o.execute(pathParam, requestId, billTable, workflowId, user, requestInfo); } + + + + public static String selectBillTableByFromId(String fromId){ + return mapper.selectBillTableByFromId(fromId); + } + } diff --git a/src/main/java/aiyh/utils/annotation/RequiredMark.java b/src/main/java/aiyh/utils/annotation/RequiredMark.java index e7f5dd9..8fff08f 100644 --- a/src/main/java/aiyh/utils/annotation/RequiredMark.java +++ b/src/main/java/aiyh/utils/annotation/RequiredMark.java @@ -14,4 +14,5 @@ import java.lang.annotation.*; @Documented public @interface RequiredMark { String value() default ""; + String desc() default ""; } diff --git a/src/main/java/aiyh/utils/mapper/UtilMapper.java b/src/main/java/aiyh/utils/mapper/UtilMapper.java index d6898ad..c73a0b0 100644 --- a/src/main/java/aiyh/utils/mapper/UtilMapper.java +++ b/src/main/java/aiyh/utils/mapper/UtilMapper.java @@ -60,6 +60,12 @@ public interface UtilMapper { @Select("select id,docid doc_id,imagefileid image_file_id,imagefilename image_file_name from docimagefile where docid = #{docId}") DocImageInfo selectDocImageInfo(@ParamMapper("docId") String docId); + @Select("select id,docid doc_id,imagefileid image_file_id,imagefilename image_file_name from docimagefile where docid in ($t{docIds})") + List selectDocImageInfos(@ParamMapper("docIds") String docIds); + + @Select("select id,docid doc_id,imagefileid image_file_id,imagefilename image_file_name from docimagefile where docid in (${docIds})") + List selectDocImageInfos(@ParamMapper("docIds") String[] docIds); + @Select("select id,workflow_type,mark_only,workflow_nodes,enable_nodes from uf_node_config where enable_nodes = 1 and workflow_type in ($t{allVersion}) and mark_only = #{markOnly}") WorkflowNodeConfig selectNodeConfig(@ParamMapper("allVersion") String allVersion, @ParamMapper("markOnly") String markOnly); @@ -131,4 +137,16 @@ public interface UtilMapper { @ParamMapper("paramDesc") String desc, @ParamMapper("configTableName") String configTableName); + /** + * + *

selectBillTableByFromId 根据fromId查询billTable表明

+ * 2023/2/6 13:40 + ************************************************************* + * @author youHong.ai + ******************************************* + * @param fromId fromId + * @return String 表名 + */ + @Select("select * from workflow_bill where id = #{fromId}") + String selectBillTableByFromId(@ParamMapper("fromId") String fromId); } diff --git a/src/main/java/aiyh/utils/recordset/ResultMapper.java b/src/main/java/aiyh/utils/recordset/ResultMapper.java index 083abee..9621a4e 100644 --- a/src/main/java/aiyh/utils/recordset/ResultMapper.java +++ b/src/main/java/aiyh/utils/recordset/ResultMapper.java @@ -387,7 +387,12 @@ public class ResultMapper { try { if (o instanceof Map) { for (int i = 0; i < columnName.length; i++) { - String columnType = columnTypeName[i]; + String columnType = ""; + if(i >= columnTypeName.length){ + columnType = "varchar"; + }else { + columnType = columnTypeName[i]; + } if ("int".equalsIgnoreCase(columnType) || "long".equalsIgnoreCase(columnType) || "number".equalsIgnoreCase(columnType) || "MEDIUMINT".equalsIgnoreCase(columnType) || "TINYINT".equalsIgnoreCase(columnType) || "SMALLINT".equalsIgnoreCase(columnType) || "BIGINT".equalsIgnoreCase(columnType) || "INTEGER".equalsIgnoreCase(columnType)) { if (enable) { ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getInt(i + 1)); diff --git a/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/ReceiptAndPaymentAction.java b/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/ReceiptAndPaymentAction.java new file mode 100644 index 0000000..4ecae21 --- /dev/null +++ b/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/ReceiptAndPaymentAction.java @@ -0,0 +1,80 @@ +package weaver.youhong.ai.haripijiu.action.sapdocking; + +import aiyh.utils.Util; +import aiyh.utils.action.SafeCusBaseAction; +import aiyh.utils.annotation.ActionDesc; +import aiyh.utils.annotation.ActionOptionalParam; +import aiyh.utils.annotation.PrintParamMark; +import aiyh.utils.annotation.RequiredMark; +import aiyh.utils.excention.CustomerException; +import lombok.Setter; +import lombok.ToString; +import weaver.hrm.User; +import weaver.soa.workflow.request.RequestInfo; +import weaver.youhong.ai.haripijiu.action.sapdocking.service.VoucherPayableService; + +import java.util.List; + +/** + *

收付款action

+ * + *

create: 2023-02-03 14:44

+ * + * @author youHong.ai + */ +@Setter +@ToString +@ActionDesc(author = "youhong.ai", value = "sap对接action,收付款文件生成发送给sap服务方") +public class ReceiptAndPaymentAction extends SafeCusBaseAction { + + + @PrintParamMark + @ActionOptionalParam(value = "false", desc = "是否自动提交流程 false : 不提交; true : 提交") + private String submitAction = "false"; + + @PrintParamMark + @ActionOptionalParam(value = "true", desc = "是否失败后阻断流程, false : 不阻断; true: 阻断") + private String block = "true"; + + + @PrintParamMark + @RequiredMark("sap对接配置表的唯一标识") + private String onlyMark; + + + @PrintParamMark + @RequiredMark("凭证类型,1- 付款单; 2- 收款单") + private String voucherType; + + @Override + public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) { + try { + VoucherPayableService server = new VoucherPayableService(); + String fileName = ""; + if (Integer.parseInt(voucherType) == 1) { + /* ******************* 一个明细对应一个文件 ******************* */ + List paymentFilePathList = server.sendPaymentVoucher(onlyMark, requestId, billTable); + for (String filePath : paymentFilePathList) { + fileName = "Receipt" + Util.getTime("yyyyMMddHHmmss") + ".txt"; + // TODO 根据不同的规则生成不同的文件名并将文件存储到指定位置 + } + } else if (Integer.parseInt(voucherType) == 2) { + String tempFilePath = server.sendReceiptVoucher(onlyMark, requestId, billTable); + fileName = "Payment" + Util.getTime("yyyyMMddHHmmss") + ".txt"; + // TODO 根据不同的规则生成不同的文件名并将文件存储到指定位置 + } + /* ******************* 是否提交流程 ******************* */ + if (Boolean.parseBoolean(submitAction)) { + this.submitWorkflow(requestId, user.getUID()); + } + } catch (Exception e) { + if (Boolean.parseBoolean(block)) { + throw new CustomerException(e.getMessage(), e); + } + } + } + + public void submitWorkflow(String requestId, Integer userId) { + Util.submitWorkflowThread(Integer.parseInt(requestId), userId, "sap对接自动提交流程!"); + } +} diff --git a/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/VoucherPayableAction.java b/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/VoucherPayableAction.java new file mode 100644 index 0000000..9dcfdb1 --- /dev/null +++ b/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/VoucherPayableAction.java @@ -0,0 +1,78 @@ +package weaver.youhong.ai.haripijiu.action.sapdocking; + +import aiyh.utils.Util; +import aiyh.utils.action.SafeCusBaseAction; +import aiyh.utils.annotation.ActionDesc; +import aiyh.utils.annotation.ActionOptionalParam; +import aiyh.utils.annotation.PrintParamMark; +import aiyh.utils.annotation.RequiredMark; +import aiyh.utils.excention.CustomerException; +import lombok.Setter; +import lombok.ToString; +import weaver.hrm.User; +import weaver.soa.workflow.request.RequestInfo; +import weaver.youhong.ai.haripijiu.action.sapdocking.service.VoucherPayableService; + +/** + *

应付凭证接口

+ * + *

create: 2023-02-02 10:55

+ * + * @author youHong.ai + */ + +@Setter +@ToString +@ActionDesc(author = "youhong.ai", value = "sap对接action,付款应付凭证文件生成发送给sap服务方") +public class VoucherPayableAction extends SafeCusBaseAction { + + + @PrintParamMark + @ActionOptionalParam(value = "false", desc = "是否自动提交流程 false : 不提交; true : 提交") + private String submitAction = "false"; + + @PrintParamMark + @ActionOptionalParam(value = "true", desc = "是否失败后阻断流程, false : 不阻断; true: 阻断") + private String block = "true"; + + + @PrintParamMark + @RequiredMark("sap对接配置表的唯一标识") + private String onlyMark; + + + @PrintParamMark + @RequiredMark("凭证类型,1- 应付凭证; 2- 付款凭证") + private String voucherType; + + + @Override + public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) { + + try { + VoucherPayableService server = new VoucherPayableService(); + String tempFilePath = server.sendSapVoucher(onlyMark, requestId, billTable); + String fileName = ""; + if (Integer.parseInt(voucherType) == 1) { + fileName = "Pav" + Util.getTime("yyyyMMddHHmmss") + ".txt"; + } else if (Integer.parseInt(voucherType) == 2) { + fileName = "Pmv" + Util.getTime("yyyyMMddHHmmss") + ".txt"; + } + // TODO 根据不同的规则生成不同的文件名并将文件存储到指定位置 + + /* ******************* 是否提交流程 ******************* */ + if (Boolean.parseBoolean(submitAction)) { + this.submitWorkflow(requestId, user.getUID()); + } + } catch (Exception e) { + if (Boolean.parseBoolean(block)) { + throw new CustomerException(e.getMessage(), e); + } + } + } + + public void submitWorkflow(String requestId, Integer userId) { + Util.submitWorkflowThread(Integer.parseInt(requestId), userId, "sap对接自动提交流程!"); + } + +} diff --git a/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/dto/SapVoucher.java b/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/dto/SapVoucher.java new file mode 100644 index 0000000..6177f5f --- /dev/null +++ b/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/dto/SapVoucher.java @@ -0,0 +1,28 @@ +package weaver.youhong.ai.haripijiu.action.sapdocking.config.dto; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.List; +import java.util.Map; + +/** + *

sap凭证

+ * + *

create: 2023-02-02 16:29

+ * + * @author youHong.ai + */ + +@Setter +@Getter +@ToString +public class SapVoucher { + /** 凭证头 */ + private List voucherHead; + + /** 凭证明细 */ + private List> voucherDetail; + +} diff --git a/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/dto/VoucherItem.java b/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/dto/VoucherItem.java new file mode 100644 index 0000000..d2f3fa2 --- /dev/null +++ b/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/dto/VoucherItem.java @@ -0,0 +1,24 @@ +package weaver.youhong.ai.haripijiu.action.sapdocking.config.dto; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + *

+ * + *

create: 2023-02-02 18:45

+ * + * @author youHong.ai + */ + +@Setter +@Getter +@ToString +public class VoucherItem { + private int id; + + private String name; + + private Object value; +} diff --git a/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/mapper/SapConfigMapper.java b/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/mapper/SapConfigMapper.java new file mode 100644 index 0000000..3ed9915 --- /dev/null +++ b/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/mapper/SapConfigMapper.java @@ -0,0 +1,120 @@ +package weaver.youhong.ai.haripijiu.action.sapdocking.config.mapper; + +import aiyh.utils.annotation.recordset.ParamMapper; +import aiyh.utils.annotation.recordset.Select; +import aiyh.utils.annotation.recordset.SqlMapper; +import aiyh.utils.annotation.recordset.SqlString; +import weaver.youhong.ai.haripijiu.action.sapdocking.config.pojo.SapConfigDetail; +import weaver.youhong.ai.haripijiu.action.sapdocking.config.pojo.SapConfigMain; + +import java.util.List; +import java.util.Map; + +/** + *

sap配置接口查询

+ * + *

create: 2023-02-02 13:01

+ * + * @author youHong.ai + */ + +@SqlMapper +public interface SapConfigMapper { + + + /** + *

selectSapConfigByOnlyMark 查询sap配置表主表配置信息

+ * 2023/2/2 14:21 + * ************************************************************ + * + * @param onlyMark 唯一标识 + * @return SapConfigMain 配置主表数据信息 + * @author youHong.ai ****************************************** + */ + @Select("select id,\n" + + " only_mark,\n" + + " workflow_type,\n" + + " document_table_type,\n" + + " document_detail_table,\n" + + " document_desc,\n" + + " document_detail_table_name\n" + + "from uf_sap_config where only_mark = #{onlyMark}") + SapConfigMain selectSapConfigByOnlyMark(@ParamMapper("onlyMark") String onlyMark); + + + /** + *

selectSapConfigDetail_1ByMainId 查询sap配置表明细1数据凭证头

+ * 2023/2/2 14:22 + * ************************************************************ + * + * @param mainId 主表id + * @return List 凭证头配置数据信息 + * @author youHong.ai ****************************************** + */ + @Select("select id,\n" + + " mainid,\n" + + " voucher_field,\n" + + " workflow_field,\n" + + " customer_value,\n" + + " workflow_field_name,\n" + + " workflow_table_name," + + " value_rule\n" + + "from uf_sap_config_dt1 where mainid = #{mainId}") + List selectSapConfigDetail_1ByMainId(@ParamMapper("mainId") int mainId); + + + /** + *

selectSapConfigDetail_2ByMainId 查询sap配置表明细2数据凭证明细

+ * 2023/2/2 14:23 + * ************************************************************ + * + * @param mainId 主表id + * @return List 凭证明细配置数据 + * @author youHong.ai ****************************************** + */ + @Select("select id,\n" + + " mainid,\n" + + " voucher_field,\n" + + " voucher_type,\n" + + " value_rule,\n" + + " workflow_field,\n" + + " customer_value,\n" + + " workflow_field_name,\n" + + " workflow_table_name\n" + + "from uf_sap_config_dt2 where mainid = #{mainId}") + List selectSapConfigDetail_2ByMainId(@ParamMapper("mainId") int mainId); + + + /** + *

selectWorkflowDataByRequestId 查询流程数据

+ * 2023/2/2 14:57 + * ************************************************************ + * + * @param requestId 流程请求id + * @param billTable 流程主表表名 + * @return Map + * @author youHong.ai ****************************************** + */ + @Select("select * from $t{billTable} where requestid = #{requestId}") + Map selectWorkflowDataByRequestId(@ParamMapper("requestId") String requestId, + @ParamMapper("billTable") String billTable); + + + /** + *

selectWorkflowDataByMainId 根据主表ID查询明细表数据

+ * 2023/2/2 16:45 + * ************************************************************ + * + * @param mainId 主表ID + * @param billTable 明细表 + * @return List> 明细表数据 + * @author youHong.ai ****************************************** + */ + @Select("select * from $t{billTable} where mainid = #{mainId}") + List> selectWorkflowDataByMainId(@ParamMapper("mainId") String mainId, + @ParamMapper("billTable") String billTable); + + + @Select(custom = true) + String selectCustomerSql(@SqlString String sql, Map map); +} diff --git a/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/pojo/SapConfigDetail.java b/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/pojo/SapConfigDetail.java new file mode 100644 index 0000000..123d27d --- /dev/null +++ b/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/pojo/SapConfigDetail.java @@ -0,0 +1,43 @@ +package weaver.youhong.ai.haripijiu.action.sapdocking.config.pojo; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + *

sap配置明细表实体类

+ * + *

create: 2023-02-02 13:51

+ * + * @author youHong.ai + */ + +@Setter +@Getter +@ToString +public class SapConfigDetail { + + /** 主表id */ + private int mainid; + + /** id */ + private int id; + + /** 凭证字段 */ + private String voucherField; + + /** 凭证类型 */ + private int voucherType; + + /** 取之规则 */ + private int valueRule; + + /** 自定义值 */ + private String customerValue; + + /** 流程字段名 */ + private String workflowFieldName; + + /** 流程表表名 */ + private String workflowTableName; +} diff --git a/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/pojo/SapConfigMain.java b/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/pojo/SapConfigMain.java new file mode 100644 index 0000000..0cace8c --- /dev/null +++ b/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/pojo/SapConfigMain.java @@ -0,0 +1,43 @@ +package weaver.youhong.ai.haripijiu.action.sapdocking.config.pojo; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.List; + +/** + *

配置主表实体类

+ * + *

create: 2023-02-02 13:43

+ * + * @author youHong.ai + */ + +@Setter +@Getter +@ToString +public class SapConfigMain { + /** 数据id */ + private int id; + + /** 唯一标识 */ + private String onlyMark; + + /** 流程类型 */ + private int workflowType; + + /** 凭证表类型 */ + private int documentTableType; + + /** 凭证描述 */ + private String documentDesc; + + /** 凭证明细表 */ + private String documentDetailTableName; + + /** 凭证头 */ + private List voucherHead; + /** 凭证明细 */ + private List voucherDetails; +} diff --git a/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/service/SapConfigService.java b/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/service/SapConfigService.java new file mode 100644 index 0000000..286aa9e --- /dev/null +++ b/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/service/SapConfigService.java @@ -0,0 +1,291 @@ +package weaver.youhong.ai.haripijiu.action.sapdocking.config.service; + +import aiyh.utils.Util; +import cn.hutool.core.lang.Assert; +import ebu7common.youhong.ai.bean.Builder; +import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; +import weaver.youhong.ai.haripijiu.action.sapdocking.config.dto.SapVoucher; +import weaver.youhong.ai.haripijiu.action.sapdocking.config.dto.VoucherItem; +import weaver.youhong.ai.haripijiu.action.sapdocking.config.mapper.SapConfigMapper; +import weaver.youhong.ai.haripijiu.action.sapdocking.config.pojo.SapConfigDetail; +import weaver.youhong.ai.haripijiu.action.sapdocking.config.pojo.SapConfigMain; +import weaver.youhong.ai.haripijiu.action.sapdocking.config.util.ValueRuleMethod; + +import java.util.*; +import java.util.stream.Collectors; + +/** + *

sap配置表数据处理整合

+ * + *

create: 2023-02-02 13:02

+ * + * @author youHong.ai + */ + +public class SapConfigService { + + private final SapConfigMapper mapper = Util.getMapper(SapConfigMapper.class); + private final Logger log = Util.getLogger(); + + public SapConfigService() { + } + + + /** + *

getVoucherData 获取凭证配置信息

+ * 2023/2/2 13:29 + * ************************************************************ + * + * @param onlyMark 唯一标识 + * @param requestId 流程请求id + * @param billTable 流程所在表 + * @return Map 凭证数据 + * @author youHong.ai ****************************************** + */ + public SapVoucher getVoucherData(String onlyMark, + String requestId, + String billTable) { + SapConfigMain sapConfigMain = mapper.selectSapConfigByOnlyMark(onlyMark); + Assert.notNull(sapConfigMain, "can not query sap config main data by onlyMark : [{}]", onlyMark); + /* ******************* 查询凭证配置明细 ******************* */ + List sapConfigVoucherHead = mapper.selectSapConfigDetail_1ByMainId(sapConfigMain.getId()); + Assert.notEmpty(sapConfigVoucherHead, "sap voucher head config can not be null!"); + List sapConfigVoucherDetails = mapper.selectSapConfigDetail_2ByMainId(sapConfigMain.getId()); + Assert.notEmpty(sapConfigVoucherDetails, "sap voucher detail config can not be null!"); + sapConfigMain.setVoucherHead(sapConfigVoucherHead); + sapConfigMain.setVoucherDetails(sapConfigVoucherDetails); + // 如果凭证数据来源于主表 + if (sapConfigMain.getDocumentTableType() == 0) { + return parseByMainTable(requestId, billTable, sapConfigMain); + } + // 来源于明细表 + return parseByDetailTable(requestId, billTable, sapConfigMain); + } + + /** + *

getReceiptPaymentData 获取收付款数据信息

+ * 2023/2/3 15:55 + * ************************************************************ + * + * @param onlyMark 唯一标识 + * @param requestId 流程请求id + * @param billTable 流程表名 + * @return SapVoucher sap凭证数据 + * @author youHong.ai ****************************************** + */ + public SapVoucher getReceiptPaymentData(String onlyMark, String requestId, String billTable) { + SapConfigMain sapConfigMain = mapper.selectSapConfigByOnlyMark(onlyMark); + Assert.notNull(sapConfigMain, "can not query sap payment config main data by onlyMark : [{}]", onlyMark); + /* ******************* 查询凭证配置明细 ******************* */ + List sapConfigVoucherHead = mapper.selectSapConfigDetail_1ByMainId(sapConfigMain.getId()); + Assert.notEmpty(sapConfigVoucherHead, "sap voucher payment head config can not be null!"); + sapConfigMain.setVoucherHead(sapConfigVoucherHead); + // 如果凭证数据来源于主表 + if (sapConfigMain.getDocumentTableType() == 0) { + return parsePaymentByMainTable(requestId, billTable, sapConfigMain); + } + // 来源于明细表 + return parseByPaymentDetailTable(requestId, billTable, sapConfigMain); + } + + private SapVoucher parseByPaymentDetailTable(String requestId, String billTable, SapConfigMain sapConfigMain) { + Map workflowMainData = mapper.selectWorkflowDataByRequestId(requestId, billTable); + Assert.notNull(workflowMainData, "payment: query workflow data fail, query request id is {}", requestId); + List> workflowDetailData = mapper.selectWorkflowDataByMainId(Util.null2String(workflowMainData.get("id")), + sapConfigMain.getDocumentDetailTableName()); + Assert.notNull(workflowDetailData, "payment: query workflow detail data fail, query request id is {}, mainId is {}", + requestId, workflowMainData.get("id")); + Map workflowData = new HashMap<>(); + workflowData.put("main", workflowMainData); + workflowData.put("dt", workflowDetailData); + List> sapVoucherHead = parsePaymentVoucherHead(workflowData, sapConfigMain.getVoucherHead(), workflowDetailData); + return Builder.builder(SapVoucher::new) + .with(SapVoucher::setVoucherDetail, sapVoucherHead) + .build(); + } + + private List> parsePaymentVoucherHead(Map workflowData, List voucherHead, + List> workflowDetailData) { + List> result = new ArrayList<>(); + for (Map workflowDetailDatum : workflowDetailData) { + Map workflowDataTemp = new HashMap<>(workflowData); + workflowDataTemp.put("dt", workflowDetailDatum); + List voucherListRow = getVoucherItems(workflowDataTemp, voucherHead); + result.add(voucherListRow); + } + return result; + } + + + private SapVoucher parsePaymentByMainTable(String requestId, String billTable, SapConfigMain sapConfigMain) { + Map workflowMainData = mapper.selectWorkflowDataByRequestId(requestId, billTable); + Assert.notNull(workflowMainData, "payment: query workflow data fail, query request id is {}", requestId); + Map workflowData = new HashMap<>(); + workflowData.put("main", workflowMainData); + List voucherListRow = getVoucherItems(workflowData, sapConfigMain.getVoucherHead()); + return Builder.builder(SapVoucher::new) + .with(SapVoucher::setVoucherDetail, Collections.singletonList(voucherListRow)) + .build(); + } + + + /** + *

parseByMainTable 凭证数据在主表处理方法

+ * 2023/2/2 14:48 + * ************************************************************ + * + * @param requestId 请求id + * @param billTable 流程所在表 + * @param sapConfigMain sap配置数据 + * @return Map 凭证数据 + * @author youHong.ai ***************************************** + */ + private SapVoucher parseByMainTable(String requestId, + String billTable, SapConfigMain sapConfigMain) { + Map workflowMainData = mapper.selectWorkflowDataByRequestId(requestId, billTable); + Assert.notNull(workflowMainData, "query workflow data fail, query request id is {}", requestId); + Map workflowData = new HashMap<>(); + workflowData.put("main", workflowMainData); + List sapVoucherHead = parseVoucherHead(workflowData, sapConfigMain.getVoucherHead()); + List> sapVoucherDetails = parseVoucherDetailByMainTable(workflowData, sapConfigMain.getVoucherDetails()); + return Builder.builder(SapVoucher::new) + .with(SapVoucher::setVoucherHead, sapVoucherHead) + .with(SapVoucher::setVoucherDetail, sapVoucherDetails) + .build(); + } + + /** + *

parseVoucherHead 解析凭证头配置数据

+ * 2023/2/2 16:01 + * ************************************************************ + * + * @param workflowData 流程数据 + * @param headConfigList 凭证头配置数据 + * @return List 解析后数据 + * @author youHong.ai ****************************************** + */ + private List parseVoucherHead(Map workflowData, List headConfigList) { + //Map result = new HashMap<>(); + return getVoucherItems(workflowData, headConfigList); + } + + /** + *

parseVoucherDetailByMainTable 解析凭证明细单条数据

+ * 2023/2/2 16:50 + * ************************************************************ + * + * @param workflowData 流程数据 + * @param detailConfigList 凭证明细配置数据 + * @return List> 凭证明细数据 + * @author youHong.ai ****************************************** + */ + private List> parseVoucherDetailByMainTable(Map workflowData, + List detailConfigList) { + List> result = new ArrayList<>(); + Map> collect = detailConfigList.stream() + .collect(Collectors.groupingBy(SapConfigDetail::getVoucherType)); + // 借方 + List debit = collect.get(0); + //贷方 + + List credit = collect.get(1); + + Assert.notEmpty(debit, "debit config not be null!"); + Assert.notEmpty(credit, "credit config not be bull!"); + + List debtorList = getVoucherItems(workflowData, debit); + result.add(debtorList); + List creditorList = getVoucherItems(workflowData, credit); + result.add(creditorList); + return result; + } + + @NotNull + private List getVoucherItems(Map workflowData, List debit) { + List debtorList = new ArrayList<>(); + for (SapConfigDetail sapConfigDetail : debit) { + //debtorMap.put(sapConfigDetail.getVoucherField(), getValue(sapConfigDetail, workflowData)); + VoucherItem voucherItem = Builder.builder(VoucherItem::new) + .with(VoucherItem::setId, sapConfigDetail.getId()) + .with(VoucherItem::setName, sapConfigDetail.getVoucherField()) + .with(VoucherItem::setValue, getValue(sapConfigDetail, workflowData)) + .build(); + debtorList.add(voucherItem); + } + return debtorList; + } + + /** + *

getValue 更具取值规则获取凭证字段值

+ * 2023/2/2 16:00 + * ************************************************************ + * + * @param sapConfigDetail 凭证配置数据明细条 + * @param workflowData 流程数据 + * @return Object + * @author youHong.ai ****************************************** + */ + private Object getValue(SapConfigDetail sapConfigDetail, Map workflowData) { + return ValueRuleMethod.VALUE_RULE_FUNCTION.get(sapConfigDetail.getValueRule()) + .apply(sapConfigDetail, workflowData); + } + + + /** + *

parseByMainTable 凭证数据在明细表处理方法

+ * 2023/2/2 14:48 + * ************************************************************ + * + * @param requestId 请求id + * @param billTable 流程所在表 + * @param sapConfigMain sap配置数据 + * @return Map 凭证数据 + * @author youHong.ai ****************************************** + */ + private SapVoucher parseByDetailTable(String requestId, + String billTable, SapConfigMain sapConfigMain) { + Map workflowMainData = mapper.selectWorkflowDataByRequestId(requestId, billTable); + Assert.notNull(workflowMainData, "query workflow data fail, query request id is {}", requestId); + List> workflowDetailData = mapper.selectWorkflowDataByMainId(Util.null2String(workflowMainData.get("id")), + sapConfigMain.getDocumentDetailTableName()); + Assert.notNull(workflowDetailData, "query workflow detail data fail, query request id is {}, mainId is {}", + requestId, workflowMainData.get("id")); + Map workflowData = new HashMap<>(); + workflowData.put("main", workflowMainData); + workflowData.put("dt", workflowDetailData); + List sapVoucherHead = parseVoucherHead(workflowData, sapConfigMain.getVoucherHead()); + List> sapVoucherDetails = parseVoucherDetail(workflowData, sapConfigMain.getVoucherDetails(), workflowDetailData); + return Builder.builder(SapVoucher::new) + .with(SapVoucher::setVoucherHead, sapVoucherHead) + .with(SapVoucher::setVoucherDetail, sapVoucherDetails) + .build(); + } + + + /** + *

parseVoucherDetailByMainTable 解析凭证明细数据

+ * 2023/2/2 16:50 + * ************************************************************ + * + * @param workflowData 流程数据 + * @param detailConfigList 凭证明细配置数据 + * @param workflowDetailData 明细表数据 + * @return List> 凭证明细数据 + * @author youHong.ai ****************************************** + */ + private List> parseVoucherDetail(Map workflowData, + List detailConfigList, + List> workflowDetailData) { + List> result = new ArrayList<>(); + for (Map workflowDetailDatum : workflowDetailData) { + Map workflowDataTemp = new HashMap<>(workflowData); + workflowDataTemp.put("dt", workflowDetailDatum); + List> voucherListRow = parseVoucherDetailByMainTable(workflowDataTemp, detailConfigList); + result.addAll(voucherListRow); + } + return result; + + } + +} diff --git a/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/util/ValueRuleMethod.java b/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/util/ValueRuleMethod.java new file mode 100644 index 0000000..9bde767 --- /dev/null +++ b/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/util/ValueRuleMethod.java @@ -0,0 +1,99 @@ +package weaver.youhong.ai.haripijiu.action.sapdocking.config.util; + +import aiyh.utils.Util; +import com.google.common.base.Strings; +import org.apache.log4j.Logger; +import weaver.youhong.ai.haripijiu.action.sapdocking.config.mapper.SapConfigMapper; +import weaver.youhong.ai.haripijiu.action.sapdocking.config.pojo.SapConfigDetail; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; +import java.util.function.BiFunction; + +/** + *

值处理方法

+ * + *

create: 2023-02-02 15:15

+ * + * @author youHong.ai + */ + +public class ValueRuleMethod { + + + public static final Map, Object>> VALUE_RULE_FUNCTION = new HashMap<>(); + + static { + Class valueRuleMethodClass = ValueRuleMethod.class; + Method[] methods = valueRuleMethodClass.getMethods(); + for (Method method : methods) { + if (method.isAnnotationPresent(ValueRuleMethodNo.class)) { + ValueRuleMethodNo annotation = method.getAnnotation(ValueRuleMethodNo.class); + int value = annotation.value(); + VALUE_RULE_FUNCTION.put(value, (sapConfigDetail, workflowData) -> { + try { + ValueRuleMethod valueRuleMethod = new ValueRuleMethod(); + return method.invoke(valueRuleMethod, sapConfigDetail, workflowData); + } catch (IllegalAccessException | InvocationTargetException e) { + throw new RuntimeException(e); + } + }); + } + } + } + + private final SapConfigMapper MAPPER = Util.getMapper(SapConfigMapper.class); + private final Logger log = Util.getLogger(); + + @ValueRuleMethodNo(value = 0, desc = "固定值") + public Object getFixValue(SapConfigDetail sapConfigDetail, Map workflowData) { + return sapConfigDetail.getCustomerValue(); + } + + + @ValueRuleMethodNo(value = 1, desc = "流程字段值") + public Object getWorkflowValue(SapConfigDetail sapConfigDetail, Map workflowData) { + if (sapConfigDetail.getWorkflowTableName().contains("_dt")) { + // 明细表字段 + return Util.getValueByKeyStr("dt." + sapConfigDetail.getWorkflowFieldName(), workflowData); + } else { + // 主表字段 + return Util.getValueByKeyStr("main." + sapConfigDetail.getWorkflowFieldName(), workflowData); + } + } + + + @ValueRuleMethodNo(value = 2, desc = "自定义sql") + public Object getCustomerSqlValue(SapConfigDetail sapConfigDetail, Map workflowData) { + if (Strings.isNullOrEmpty(sapConfigDetail.getCustomerValue())) { + return ""; + } + if (!sapConfigDetail.getCustomerValue().trim().split(" ")[0].equalsIgnoreCase("select")) { + log.error(Util.logStr("intercept danger customer sql in " + + "[weaver.youhong.ai.haripijiu.action.sapdocking.config.util.ValueRuleMethod]. " + + "sql [{}]", sapConfigDetail.getCustomerValue())); + return ""; + } + return MAPPER.selectCustomerSql(sapConfigDetail.getCustomerValue(), workflowData); + } + + @ValueRuleMethodNo(value = 3, desc = "自定义接口") + public Object getCustomerInterface(SapConfigDetail sapConfigDetail, Map workflowData) { + // TODO 编写自定义接口 + return null; + } + + + @ValueRuleMethodNo(value = 4, desc = "数据表id") + public Object getDBTableId(SapConfigDetail sapConfigDetail, Map workflowData) { + if (sapConfigDetail.getWorkflowTableName().contains("_dt")) { + // 明细表字段 + return Util.getValueByKeyStr("dt.id", workflowData); + } else { + // 主表字段 + return Util.getValueByKeyStr("main.id", workflowData); + } + } +} diff --git a/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/util/ValueRuleMethodNo.java b/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/util/ValueRuleMethodNo.java new file mode 100644 index 0000000..b60f8d9 --- /dev/null +++ b/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/config/util/ValueRuleMethodNo.java @@ -0,0 +1,19 @@ +package weaver.youhong.ai.haripijiu.action.sapdocking.config.util; + +import java.lang.annotation.*; + +/** + *

值处理方法编号注解

+ * + *

create: 2023-02-02 15:18

+ * + * @author youHong.ai + */ + +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface ValueRuleMethodNo { + int value(); + String desc(); +} diff --git a/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/service/VoucherPayableService.java b/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/service/VoucherPayableService.java new file mode 100644 index 0000000..7da6dd4 --- /dev/null +++ b/src/main/java/weaver/youhong/ai/haripijiu/action/sapdocking/service/VoucherPayableService.java @@ -0,0 +1,203 @@ +package weaver.youhong.ai.haripijiu.action.sapdocking.service; + +import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; +import org.jetbrains.annotations.NotNull; +import weaver.general.GCONST; +import weaver.youhong.ai.haripijiu.action.sapdocking.config.dto.SapVoucher; +import weaver.youhong.ai.haripijiu.action.sapdocking.config.dto.VoucherItem; +import weaver.youhong.ai.haripijiu.action.sapdocking.config.service.SapConfigService; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +/** + *

对接sap凭证service

+ * + *

create: 2023-02-02 17:33

+ * + * @author youHong.ai + */ + +public class VoucherPayableService { + + + private final SapConfigService configService = new SapConfigService(); + + @NotNull + private static String getFilePath() { + String sysFilePath = GCONST.getSysFilePath(); + String filePath = ""; + if (sysFilePath.endsWith(File.separator)) { + filePath = sysFilePath + "temp" + File.separator + "voucher" + File.separator + + System.currentTimeMillis() + "-voucher-" + UUID.randomUUID() + ".txt"; + } else { + filePath = sysFilePath + File.separator + "temp" + File.separator + "voucher" + File.separator + + System.currentTimeMillis() + "-voucher-" + UUID.randomUUID() + ".txt"; + } + Path path = Paths.get(filePath); + if (!Files.exists(path)) { + Path parent = path.getParent(); + try { + Files.createDirectories(parent); + } catch (IOException e) { + throw new CustomerException(Util.logStr("can not create file [{}]", filePath)); + } + } + return filePath; + } + + /** + *

sendSapVoucher 获取凭证文件位置

+ * 2023/2/3 11:34 + * ************************************************************ + * + * @param onlyMark 唯一标识 + * @param requestId 流程请求id + * @param billTable 流程表 + * @return String 凭证文件位置 + * @author youHong.ai ****************************************** + */ + public String sendSapVoucher(String onlyMark, String requestId, String billTable) { + + SapVoucher voucherData = configService.getVoucherData(onlyMark, requestId, billTable); + /* ******************* 整理数据 ******************* */ + StringBuilder voucherHeadBuilder = new StringBuilder(); + List voucherHead = voucherData.getVoucherHead(); + for (VoucherItem voucherItem : voucherHead) { + voucherHeadBuilder.append(voucherItem.getValue()) + .append("\t"); + } + String voucherHeadStr = voucherHeadBuilder.substring(0, voucherHeadBuilder.lastIndexOf("\t")) + "\r\n"; + StringBuilder voucherDetailBuilder = new StringBuilder(); + List> voucherDetail = voucherData.getVoucherDetail(); + for (List voucherItems : voucherDetail) { + voucherDetailBuilder.append(appendVoucherItems(voucherItems)) + .append("\r\n"); + } + String voucherDetailStr = voucherDetailBuilder.substring(0, voucherDetailBuilder.lastIndexOf("\r\n")); + String filePath = getFilePath(); + try { + BufferedWriter writer = new BufferedWriter(new OutputStreamWriter( + Files.newOutputStream(Paths.get(filePath)) + )); + writer.write(voucherHeadStr); + writer.write(voucherDetailStr); + writer.flush(); + writer.close(); + } catch (IOException e) { + throw new CustomerException(Util.logStr("can not writer file [{}]", filePath)); + } + + return filePath; + } + + public String sendReceiptVoucher(String onlyMark, String requestId, String billTable) { + SapVoucher voucherData = configService.getReceiptPaymentData(onlyMark, requestId, billTable); + /* ******************* 整理数据 ******************* */ + StringBuilder voucherHeadBuilder = new StringBuilder(); + List> voucherDetail = voucherData.getVoucherDetail(); + for (int i = 0; i < voucherDetail.size(); i++) { + List voucherItems = voucherDetail.get(i); + if (i == 0) { + for (VoucherItem voucherItem : voucherItems) { + voucherHeadBuilder.append(voucherItem.getName()) + .append("\t"); + } + voucherHeadBuilder = new StringBuilder(voucherHeadBuilder + .substring(0, voucherHeadBuilder.lastIndexOf("\t")) + "\r\n"); + + } + for (VoucherItem voucherItem : voucherItems) { + voucherHeadBuilder.append(voucherItem.getValue()) + .append("\t"); + } + if (i < voucherDetail.size() - 1) { + voucherHeadBuilder = new StringBuilder(voucherHeadBuilder + .substring(0, voucherHeadBuilder.lastIndexOf("\t")) + "\r\n"); + } else { + voucherHeadBuilder = new StringBuilder(voucherHeadBuilder + .substring(0, voucherHeadBuilder.lastIndexOf("\t")) + ""); + } + } + String filePath = getFilePath(); + try { + + BufferedWriter writer = new BufferedWriter(new OutputStreamWriter( + Files.newOutputStream(Paths.get(filePath)) + )); + writer.write(voucherHeadBuilder.toString()); + writer.flush(); + writer.close(); + } catch (IOException e) { + throw new CustomerException(Util.logStr("can not writer receipt voucher file [{}]", filePath)); + } + + return filePath; + } + + + public List sendPaymentVoucher(String onlyMark, String requestId, String billTable) { + SapVoucher voucherData = configService.getReceiptPaymentData(onlyMark, requestId, billTable); + List filePathList = new ArrayList<>(); + /* ******************* 整理数据 ******************* */ + StringBuilder voucherHeadBuilder = new StringBuilder(); + List> voucherDetail = voucherData.getVoucherDetail(); + for (List voucherItems : voucherDetail) { + for (VoucherItem voucherItem : voucherItems) { + voucherHeadBuilder.append(voucherItem.getName()) + .append("\t"); + } + voucherHeadBuilder = new StringBuilder(voucherHeadBuilder + .substring(0, voucherHeadBuilder.lastIndexOf("\t")) + "\r\n"); + + for (VoucherItem voucherItem : voucherItems) { + voucherHeadBuilder.append(voucherItem.getValue()) + .append("\t"); + } + voucherHeadBuilder = new StringBuilder(voucherHeadBuilder + .substring(0, voucherHeadBuilder.lastIndexOf("\t")) + ""); + + String filePath = getFilePath(); + try { + BufferedWriter writer = new BufferedWriter(new OutputStreamWriter( + Files.newOutputStream(Paths.get(filePath)) + )); + writer.write(voucherHeadBuilder.toString()); + writer.flush(); + writer.close(); + } catch (IOException e) { + throw new CustomerException(Util.logStr("can not writer payment voucher file [{}]", filePath)); + } + filePathList.add(filePath); + } + return filePathList; + } + + + /** + *

appendVoucherItems 拼接凭证明细

+ * 2023/2/3 11:36 + * ************************************************************ + * + * @param voucherItems 凭证明细数据 + * @return String 拼接后字符串 + * @author youHong.ai ****************************************** + */ + private String appendVoucherItems(List voucherItems) { + StringBuilder result = new StringBuilder(); + for (VoucherItem voucherItem : voucherItems) { + result.append(voucherItem.getValue()) + .append("\t"); + } + return result.toString(); + } +} diff --git a/src/main/java/weaver/youhong/ai/pcn/actioin/sendemail/SendEmailToExternalPersonnelAction.java b/src/main/java/weaver/youhong/ai/pcn/actioin/sendemail/SendEmailToExternalPersonnelAction.java new file mode 100644 index 0000000..f7b0b54 --- /dev/null +++ b/src/main/java/weaver/youhong/ai/pcn/actioin/sendemail/SendEmailToExternalPersonnelAction.java @@ -0,0 +1,119 @@ +package weaver.youhong.ai.pcn.actioin.sendemail; + +import aiyh.utils.Util; +import aiyh.utils.action.SafeCusBaseAction; +import aiyh.utils.annotation.ActionDesc; +import aiyh.utils.annotation.ActionOptionalParam; +import aiyh.utils.annotation.PrintParamMark; +import aiyh.utils.annotation.RequiredMark; +import aiyh.utils.entity.DocImageInfo; +import aiyh.utils.excention.CustomerException; +import cn.hutool.core.lang.Assert; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.h2.util.StringUtils; +import weaver.email.EmailWorkRunnable; +import weaver.hrm.User; +import weaver.soa.workflow.request.RequestInfo; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + *

发送邮件给外部人员

+ * + *

create: 2023-02-03 12:10

+ * + * @author youHong.ai + */ + +@Setter +@Getter +@ToString +@ActionDesc(value = "发送邮件到外部人员邮箱", author = "youhong.ai") +public class SendEmailToExternalPersonnelAction extends SafeCusBaseAction { + + + @PrintParamMark + @ActionOptionalParam(value = "false", desc = "是否自动提交流程") + private String submitAction = "false"; + + @PrintParamMark + @ActionOptionalParam(value = "true", desc = "是否失败后阻断流程") + private String block = "true"; + + + @PrintParamMark + @RequiredMark("用户邮箱对应表单字段") + private String emailField; + + @PrintParamMark + @ActionOptionalParam(value = "", desc = "发送邮箱内容自定义表单表单字段,不填则默认使用开发参数配置表(uf_cus_dev_config)中唯一标识为" + + "`SendEmailToExternalPersonnelEmail`的值的邮件内容") + private String customerContentField; + + @PrintParamMark + @ActionOptionalParam(value = "", desc = "邮箱携带附件字段,不填则没有附件") + private String emailFileField; + + @PrintParamMark + @ActionOptionalParam(value = "", desc = "邮件标题字段,不填写则默认使用`defaultEmailSubject`的参数值") + private String emailSubjectField; + + @PrintParamMark + @ActionOptionalParam(value = "", desc = "邮件标题默认") + private String defaultEmailSubject = ""; + + + @Override + public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) { + try { + + Map mainTableValue = super.getMainTableValue(requestInfo); + String content = ""; + String email = mainTableValue.get(emailField); + String emailSubject = StringUtils.isNullOrEmpty(emailSubjectField) ? defaultEmailSubject : mainTableValue.get(emailSubjectField); + if (StringUtils.isNullOrEmpty(customerContentField)) { + content = Util.getCusConfigDefaultValue("SendEmailToExternalPersonnelEmail", ""); + } else { + content = mainTableValue.get(customerContentField); + } + if (StringUtils.isNullOrEmpty(emailFileField)) { + EmailWorkRunnable.threadModeReminder(email, emailSubject, content); + if (Boolean.parseBoolean(submitAction)) { + this.submitWorkflow(requestId, user.getUID()); + } + return; + } + String docIds = mainTableValue.get(emailFileField); + if (StringUtils.isNullOrEmpty(docIds)) { + EmailWorkRunnable.threadModeReminder(email, emailSubject, content); + if (Boolean.parseBoolean(submitAction)) { + this.submitWorkflow(requestId, user.getUID()); + } + return; + } + List docImageInfos = Util.selectImageInfoByDocIds(docIds); + Assert.notEmpty(docImageInfos, "can not query docImageInfo by Util.selectImageInfoByDocIds method, param is [{}]", docIds); + List imageIdList = docImageInfos.stream().map(DocImageInfo::getImageFileId).collect(Collectors.toList()); + EmailWorkRunnable.threadModeReminder(email, "", "", + emailSubject, content, Util.intJoin(imageIdList, ",")); + if (Boolean.parseBoolean(submitAction)) { + this.submitWorkflow(requestId, user.getUID()); + } + } catch (Exception e) { + if (Boolean.parseBoolean(block)) { + throw new CustomerException(e.getMessage(), e); + } + } + } + + + public void submitWorkflow(String requestId, Integer userId) { + + Util.submitWorkflowThread(Integer.parseInt(requestId), userId, "批量签署自动提交流程!"); + } + +} diff --git a/src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/ModeExpandSaveAction.java b/src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/ModeExpandSaveAction.java new file mode 100644 index 0000000..92d404d --- /dev/null +++ b/src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/ModeExpandSaveAction.java @@ -0,0 +1,38 @@ +package weaver.youhong.ai.yihong.formmode.stagediagram; + +import aiyh.utils.Util; +import com.alibaba.fastjson.JSON; +import org.apache.log4j.Logger; +import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew; +import weaver.youhong.ai.yihong.formmode.stagediagram.mapper.ModeExpandSaveActionMapper; + +import java.util.HashMap; +import java.util.Map; + +/** + *

保存自定义处理方法

+ * + *

create: 2023-02-06 12:57

+ * + * @author youHong.ai + */ + +public class ModeExpandSaveAction extends AbstractModeExpandJavaCodeNew { + + private final Logger log = Util.getLogger(); + + private final ModeExpandSaveActionMapper mapper = Util.getMapper(ModeExpandSaveActionMapper.class); + + @Override + public Map doModeExpand(Map param) { + Map result = new HashMap<>(); + try { + log.info("自定义接口保存动作参数: " + JSON.toJSONString(param)); + }catch (Exception e){ + result.put("errmsg",e.getMessage()); + result.put("flag", "false"); + log.error("建模自定义保存接口错误:" + e.getMessage() + Util.getErrString(e)); + } + return result; + } +} diff --git a/src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/mapper/ModeExpandSaveActionMapper.java b/src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/mapper/ModeExpandSaveActionMapper.java new file mode 100644 index 0000000..b6683d4 --- /dev/null +++ b/src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/mapper/ModeExpandSaveActionMapper.java @@ -0,0 +1,16 @@ +package weaver.youhong.ai.yihong.formmode.stagediagram.mapper; + +import aiyh.utils.annotation.recordset.SqlMapper; + +/** + *

+ * + *

create: 2023-02-06 13:38

+ * + * @author youHong.ai + */ + +@SqlMapper +public class ModeExpandSaveActionMapper { + +} diff --git a/src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/service/ModeExpandSaveService.java b/src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/service/ModeExpandSaveService.java new file mode 100644 index 0000000..0ff3998 --- /dev/null +++ b/src/main/java/weaver/youhong/ai/yihong/formmode/stagediagram/service/ModeExpandSaveService.java @@ -0,0 +1,65 @@ +package weaver.youhong.ai.yihong.formmode.stagediagram.service; + +import aiyh.utils.Util; +import cn.hutool.core.lang.Assert; +import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; +import weaver.soa.workflow.request.Property; +import weaver.soa.workflow.request.RequestInfo; +import weaver.youhong.ai.yihong.formmode.stagediagram.mapper.ModeExpandSaveActionMapper; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +/** + *

保存自定义处理方法service

+ * + *

create: 2023-02-06 14:01

+ * + * @author youHong.ai + */ + +public class ModeExpandSaveService { + + private final Logger log = Util.getLogger(); + + private final ModeExpandSaveActionMapper mapper = Util.getMapper(ModeExpandSaveActionMapper.class); + + public void updateStageDiagramView(String projectFieldMark, Map param){ + /* ******************* 查询当前节点对应的projectId ******************* */ + String stageDiagramProjectFieldName = Util.getCusConfigValue(projectFieldMark); + Assert.notBlank(stageDiagramProjectFieldName, "cna not find projectFieldMark from uf_cus_dev_config! the config can not be null!"); + RequestInfo requestInfo = (RequestInfo) param.get("RequestInfo"); + Map mainTableValue = getMainTableValue(requestInfo); + String projectId = mainTableValue.get(stageDiagramProjectFieldName); + /* ******************* 查询台账中对应的project是否存在, 台账中不存在则插入,存在则更新 ******************* */ + + } + + + /** + *

获取流程主表数据

+ * + * @return 流程主表数据 + */ + protected Map getMainTableValue(RequestInfo requestInfo) { + // 获取主表数据 + Property[] propertyArr = requestInfo.getMainTableInfo().getProperty(); + return getStringMap(propertyArr); + } + + @NotNull + private Map getStringMap(Property[] propertyArr) { + if (null == propertyArr) { + return Collections.emptyMap(); + } + Map mainTable = new HashMap<>(); + for (Property property : propertyArr) { + String fieldName = property.getName(); + String value = property.getValue(); + mainTable.put(fieldName, value); + } + return mainTable; + } +} diff --git a/src/test/java/youhong/ai/pcn/UtilTest.java b/src/test/java/youhong/ai/pcn/UtilTest.java index 516502e..43905c9 100644 --- a/src/test/java/youhong/ai/pcn/UtilTest.java +++ b/src/test/java/youhong/ai/pcn/UtilTest.java @@ -1,12 +1,19 @@ package youhong.ai.pcn; +import aiyh.utils.GenerateFileUtil; import aiyh.utils.Util; import basetest.BaseTest; import ebu7common.youhong.ai.bean.Builder; import org.junit.Test; +import weaver.youhong.ai.haripijiu.action.sapdocking.config.pojo.SapConfigDetail; +import weaver.youhong.ai.haripijiu.action.sapdocking.config.util.ValueRuleMethod; +import weaver.youhong.ai.haripijiu.action.sapdocking.service.VoucherPayableService; +import weaver.youhong.ai.pcn.actioin.sendemail.SendEmailToExternalPersonnelAction; import youhong.ai.pcn.mapper.TransTestMapper; import youhong.ai.pcn.pojo.Student; +import java.util.HashMap; + /** *

测试

* @@ -31,4 +38,38 @@ public class UtilTest extends BaseTest { System.out.println(Util.commitTransMapper(TransTestMapper.class)); } + + + @Test + public void test1() { + System.out.println(ValueRuleMethod.VALUE_RULE_FUNCTION.get(0).apply( + Builder.builder(SapConfigDetail::new) + .with(SapConfigDetail::setCustomerValue, "哈哈哈") + .build(),new HashMap<>())); + } + + + @Test + public void test2(){ + VoucherPayableService voucherPayableService = new VoucherPayableService(); + System.out.println(voucherPayableService.sendSapVoucher("testVoucher", "57058", "formtable_main_20")); + System.out.println(voucherPayableService.sendReceiptVoucher("testPayment", "57058", "formtable_main_20")); + + } + + + + @Test + public void createDoc(){ + GenerateFileUtil.createActionDocument(SendEmailToExternalPersonnelAction.class); + } + + @Test + public void testSplit(){ + String str = "ReferenceNo\tPayType\tPayAccNameCN\tPayAccNameEN\tRecAccNo\tRecAccNameCN\n" + + "1\t234\taldkjf\t好的 啊\t不知道\t8382\n" + + "2\t283\t阿道夫\t也还是难过\t就啊u是的呢\t802\n" + + "3\t7738\t看剧方\t加上撒u给你\t真个吧\t736\n" + + "4\t83\t就啊啥地方\t纪念活动\t你先给你\t6383"; + } }