sap凭证本地文件生成
parent
9ed409364b
commit
ce6908f603
|
@ -2950,6 +2950,16 @@ public class Util extends weaver.general.Util {
|
|||
return mapper.selectDocImageInfo(docId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询文档信息
|
||||
*
|
||||
* @param docIds 文档ID
|
||||
* @return 文档信息
|
||||
*/
|
||||
public static List<DocImageInfo> selectImageInfoByDocIds(String docIds) {
|
||||
return mapper.selectDocImageInfos(docIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询流程节点配置
|
||||
*
|
||||
|
@ -3582,4 +3592,11 @@ public class Util extends weaver.general.Util {
|
|||
Map<String, String> pathParam = Util.parseCusInterfacePathParam(process);
|
||||
return o.execute(pathParam, requestId, billTable, workflowId, user, requestInfo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static String selectBillTableByFromId(String fromId){
|
||||
return mapper.selectBillTableByFromId(fromId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,4 +14,5 @@ import java.lang.annotation.*;
|
|||
@Documented
|
||||
public @interface RequiredMark {
|
||||
String value() default "";
|
||||
String desc() default "";
|
||||
}
|
||||
|
|
|
@ -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<DocImageInfo> 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<DocImageInfo> 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);
|
||||
|
||||
/**
|
||||
*
|
||||
* <h2>selectBillTableByFromId 根据fromId查询billTable表明</h2>
|
||||
* <i>2023/2/6 13:40</i>
|
||||
*************************************************************
|
||||
* @author youHong.ai
|
||||
*******************************************
|
||||
* @param fromId fromId
|
||||
* @return String 表名
|
||||
*/
|
||||
@Select("select * from workflow_bill where id = #{fromId}")
|
||||
String selectBillTableByFromId(@ParamMapper("fromId") String fromId);
|
||||
}
|
||||
|
|
|
@ -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<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getInt(i + 1));
|
||||
|
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* <h1>收付款action</h1>
|
||||
*
|
||||
* <p>create: 2023-02-03 14:44</p>
|
||||
*
|
||||
* @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<String> 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对接自动提交流程!");
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* <h1>应付凭证接口</h1>
|
||||
*
|
||||
* <p>create: 2023-02-02 10:55</p>
|
||||
*
|
||||
* @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对接自动提交流程!");
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* <h1>sap凭证</h1>
|
||||
*
|
||||
* <p>create: 2023-02-02 16:29</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@ToString
|
||||
public class SapVoucher {
|
||||
/** 凭证头 */
|
||||
private List<VoucherItem> voucherHead;
|
||||
|
||||
/** 凭证明细 */
|
||||
private List<List<VoucherItem>> voucherDetail;
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package weaver.youhong.ai.haripijiu.action.sapdocking.config.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
*
|
||||
* <p>create: 2023-02-02 18:45</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@ToString
|
||||
public class VoucherItem {
|
||||
private int id;
|
||||
|
||||
private String name;
|
||||
|
||||
private Object value;
|
||||
}
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* <h1>sap配置接口查询</h1>
|
||||
*
|
||||
* <p>create: 2023-02-02 13:01</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
|
||||
@SqlMapper
|
||||
public interface SapConfigMapper {
|
||||
|
||||
|
||||
/**
|
||||
* <h2>selectSapConfigByOnlyMark 查询sap配置表主表配置信息</h2>
|
||||
* <i>2023/2/2 14:21</i>
|
||||
* ************************************************************
|
||||
*
|
||||
* @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);
|
||||
|
||||
|
||||
/**
|
||||
* <h2>selectSapConfigDetail_1ByMainId 查询sap配置表明细1数据凭证头</h2>
|
||||
* <i>2023/2/2 14:22</i>
|
||||
* ************************************************************
|
||||
*
|
||||
* @param mainId 主表id
|
||||
* @return List<SapConfigDetail> 凭证头配置数据信息
|
||||
* @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<SapConfigDetail> selectSapConfigDetail_1ByMainId(@ParamMapper("mainId") int mainId);
|
||||
|
||||
|
||||
/**
|
||||
* <h2>selectSapConfigDetail_2ByMainId 查询sap配置表明细2数据凭证明细</h2>
|
||||
* <i>2023/2/2 14:23</i>
|
||||
* ************************************************************
|
||||
*
|
||||
* @param mainId 主表id
|
||||
* @return List<SapConfigDetail> 凭证明细配置数据
|
||||
* @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<SapConfigDetail> selectSapConfigDetail_2ByMainId(@ParamMapper("mainId") int mainId);
|
||||
|
||||
|
||||
/**
|
||||
* <h2>selectWorkflowDataByRequestId 查询流程数据</h2>
|
||||
* <i>2023/2/2 14:57</i>
|
||||
* ************************************************************
|
||||
*
|
||||
* @param requestId 流程请求id
|
||||
* @param billTable 流程主表表名
|
||||
* @return Map<String, Object>
|
||||
* @author youHong.ai ******************************************
|
||||
*/
|
||||
@Select("select * from $t{billTable} where requestid = #{requestId}")
|
||||
Map<String, Object> selectWorkflowDataByRequestId(@ParamMapper("requestId") String requestId,
|
||||
@ParamMapper("billTable") String billTable);
|
||||
|
||||
|
||||
/**
|
||||
* <h2>selectWorkflowDataByMainId 根据主表ID查询明细表数据</h2>
|
||||
* <i>2023/2/2 16:45</i>
|
||||
* ************************************************************
|
||||
*
|
||||
* @param mainId 主表ID
|
||||
* @param billTable 明细表
|
||||
* @return List<Map < String, Object>> 明细表数据
|
||||
* @author youHong.ai ******************************************
|
||||
*/
|
||||
@Select("select * from $t{billTable} where mainid = #{mainId}")
|
||||
List<Map<String, Object>> selectWorkflowDataByMainId(@ParamMapper("mainId") String mainId,
|
||||
@ParamMapper("billTable") String billTable);
|
||||
|
||||
|
||||
@Select(custom = true)
|
||||
String selectCustomerSql(@SqlString String sql, Map<String, Object> map);
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package weaver.youhong.ai.haripijiu.action.sapdocking.config.pojo;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* <h1>sap配置明细表实体类</h1>
|
||||
*
|
||||
* <p>create: 2023-02-02 13:51</p>
|
||||
*
|
||||
* @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;
|
||||
}
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* <h1>配置主表实体类</h1>
|
||||
*
|
||||
* <p>create: 2023-02-02 13:43</p>
|
||||
*
|
||||
* @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<SapConfigDetail> voucherHead;
|
||||
/** 凭证明细 */
|
||||
private List<SapConfigDetail> voucherDetails;
|
||||
}
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* <h1>sap配置表数据处理整合</h1>
|
||||
*
|
||||
* <p>create: 2023-02-02 13:02</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
|
||||
public class SapConfigService {
|
||||
|
||||
private final SapConfigMapper mapper = Util.getMapper(SapConfigMapper.class);
|
||||
private final Logger log = Util.getLogger();
|
||||
|
||||
public SapConfigService() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <h2>getVoucherData 获取凭证配置信息</h2>
|
||||
* <i>2023/2/2 13:29</i>
|
||||
* ************************************************************
|
||||
*
|
||||
* @param onlyMark 唯一标识
|
||||
* @param requestId 流程请求id
|
||||
* @param billTable 流程所在表
|
||||
* @return Map<String, Object> 凭证数据
|
||||
* @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<SapConfigDetail> sapConfigVoucherHead = mapper.selectSapConfigDetail_1ByMainId(sapConfigMain.getId());
|
||||
Assert.notEmpty(sapConfigVoucherHead, "sap voucher head config can not be null!");
|
||||
List<SapConfigDetail> 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* <h2>getReceiptPaymentData 获取收付款数据信息</h2>
|
||||
* <i>2023/2/3 15:55</i>
|
||||
* ************************************************************
|
||||
*
|
||||
* @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<SapConfigDetail> 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<String, Object> workflowMainData = mapper.selectWorkflowDataByRequestId(requestId, billTable);
|
||||
Assert.notNull(workflowMainData, "payment: query workflow data fail, query request id is {}", requestId);
|
||||
List<Map<String, Object>> 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<String, Object> workflowData = new HashMap<>();
|
||||
workflowData.put("main", workflowMainData);
|
||||
workflowData.put("dt", workflowDetailData);
|
||||
List<List<VoucherItem>> sapVoucherHead = parsePaymentVoucherHead(workflowData, sapConfigMain.getVoucherHead(), workflowDetailData);
|
||||
return Builder.builder(SapVoucher::new)
|
||||
.with(SapVoucher::setVoucherDetail, sapVoucherHead)
|
||||
.build();
|
||||
}
|
||||
|
||||
private List<List<VoucherItem>> parsePaymentVoucherHead(Map<String, Object> workflowData, List<SapConfigDetail> voucherHead,
|
||||
List<Map<String, Object>> workflowDetailData) {
|
||||
List<List<VoucherItem>> result = new ArrayList<>();
|
||||
for (Map<String, Object> workflowDetailDatum : workflowDetailData) {
|
||||
Map<String, Object> workflowDataTemp = new HashMap<>(workflowData);
|
||||
workflowDataTemp.put("dt", workflowDetailDatum);
|
||||
List<VoucherItem> voucherListRow = getVoucherItems(workflowDataTemp, voucherHead);
|
||||
result.add(voucherListRow);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private SapVoucher parsePaymentByMainTable(String requestId, String billTable, SapConfigMain sapConfigMain) {
|
||||
Map<String, Object> workflowMainData = mapper.selectWorkflowDataByRequestId(requestId, billTable);
|
||||
Assert.notNull(workflowMainData, "payment: query workflow data fail, query request id is {}", requestId);
|
||||
Map<String, Object> workflowData = new HashMap<>();
|
||||
workflowData.put("main", workflowMainData);
|
||||
List<VoucherItem> voucherListRow = getVoucherItems(workflowData, sapConfigMain.getVoucherHead());
|
||||
return Builder.builder(SapVoucher::new)
|
||||
.with(SapVoucher::setVoucherDetail, Collections.singletonList(voucherListRow))
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <h2>parseByMainTable 凭证数据在主表处理方法</h2>
|
||||
* <i>2023/2/2 14:48</i>
|
||||
* ************************************************************
|
||||
*
|
||||
* @param requestId 请求id
|
||||
* @param billTable 流程所在表
|
||||
* @param sapConfigMain sap配置数据
|
||||
* @return Map<String, Object> 凭证数据
|
||||
* @author youHong.ai *****************************************
|
||||
*/
|
||||
private SapVoucher parseByMainTable(String requestId,
|
||||
String billTable, SapConfigMain sapConfigMain) {
|
||||
Map<String, Object> workflowMainData = mapper.selectWorkflowDataByRequestId(requestId, billTable);
|
||||
Assert.notNull(workflowMainData, "query workflow data fail, query request id is {}", requestId);
|
||||
Map<String, Object> workflowData = new HashMap<>();
|
||||
workflowData.put("main", workflowMainData);
|
||||
List<VoucherItem> sapVoucherHead = parseVoucherHead(workflowData, sapConfigMain.getVoucherHead());
|
||||
List<List<VoucherItem>> sapVoucherDetails = parseVoucherDetailByMainTable(workflowData, sapConfigMain.getVoucherDetails());
|
||||
return Builder.builder(SapVoucher::new)
|
||||
.with(SapVoucher::setVoucherHead, sapVoucherHead)
|
||||
.with(SapVoucher::setVoucherDetail, sapVoucherDetails)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* <h2>parseVoucherHead 解析凭证头配置数据</h2>
|
||||
* <i>2023/2/2 16:01</i>
|
||||
* ************************************************************
|
||||
*
|
||||
* @param workflowData 流程数据
|
||||
* @param headConfigList 凭证头配置数据
|
||||
* @return List<VoucherItem> 解析后数据
|
||||
* @author youHong.ai ******************************************
|
||||
*/
|
||||
private List<VoucherItem> parseVoucherHead(Map<String, Object> workflowData, List<SapConfigDetail> headConfigList) {
|
||||
//Map<String, Object> result = new HashMap<>();
|
||||
return getVoucherItems(workflowData, headConfigList);
|
||||
}
|
||||
|
||||
/**
|
||||
* <h2>parseVoucherDetailByMainTable 解析凭证明细单条数据</h2>
|
||||
* <i>2023/2/2 16:50</i>
|
||||
* ************************************************************
|
||||
*
|
||||
* @param workflowData 流程数据
|
||||
* @param detailConfigList 凭证明细配置数据
|
||||
* @return List<Map < String, Object>> 凭证明细数据
|
||||
* @author youHong.ai ******************************************
|
||||
*/
|
||||
private List<List<VoucherItem>> parseVoucherDetailByMainTable(Map<String, Object> workflowData,
|
||||
List<SapConfigDetail> detailConfigList) {
|
||||
List<List<VoucherItem>> result = new ArrayList<>();
|
||||
Map<Integer, List<SapConfigDetail>> collect = detailConfigList.stream()
|
||||
.collect(Collectors.groupingBy(SapConfigDetail::getVoucherType));
|
||||
// 借方
|
||||
List<SapConfigDetail> debit = collect.get(0);
|
||||
//贷方
|
||||
|
||||
List<SapConfigDetail> credit = collect.get(1);
|
||||
|
||||
Assert.notEmpty(debit, "debit config not be null!");
|
||||
Assert.notEmpty(credit, "credit config not be bull!");
|
||||
|
||||
List<VoucherItem> debtorList = getVoucherItems(workflowData, debit);
|
||||
result.add(debtorList);
|
||||
List<VoucherItem> creditorList = getVoucherItems(workflowData, credit);
|
||||
result.add(creditorList);
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private List<VoucherItem> getVoucherItems(Map<String, Object> workflowData, List<SapConfigDetail> debit) {
|
||||
List<VoucherItem> 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* <h2>getValue 更具取值规则获取凭证字段值</h2>
|
||||
* <i>2023/2/2 16:00</i>
|
||||
* ************************************************************
|
||||
*
|
||||
* @param sapConfigDetail 凭证配置数据明细条
|
||||
* @param workflowData 流程数据
|
||||
* @return Object
|
||||
* @author youHong.ai ******************************************
|
||||
*/
|
||||
private Object getValue(SapConfigDetail sapConfigDetail, Map<String, Object> workflowData) {
|
||||
return ValueRuleMethod.VALUE_RULE_FUNCTION.get(sapConfigDetail.getValueRule())
|
||||
.apply(sapConfigDetail, workflowData);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <h2>parseByMainTable 凭证数据在明细表处理方法</h2>
|
||||
* <i>2023/2/2 14:48</i>
|
||||
* ************************************************************
|
||||
*
|
||||
* @param requestId 请求id
|
||||
* @param billTable 流程所在表
|
||||
* @param sapConfigMain sap配置数据
|
||||
* @return Map<String, Object> 凭证数据
|
||||
* @author youHong.ai ******************************************
|
||||
*/
|
||||
private SapVoucher parseByDetailTable(String requestId,
|
||||
String billTable, SapConfigMain sapConfigMain) {
|
||||
Map<String, Object> workflowMainData = mapper.selectWorkflowDataByRequestId(requestId, billTable);
|
||||
Assert.notNull(workflowMainData, "query workflow data fail, query request id is {}", requestId);
|
||||
List<Map<String, Object>> 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<String, Object> workflowData = new HashMap<>();
|
||||
workflowData.put("main", workflowMainData);
|
||||
workflowData.put("dt", workflowDetailData);
|
||||
List<VoucherItem> sapVoucherHead = parseVoucherHead(workflowData, sapConfigMain.getVoucherHead());
|
||||
List<List<VoucherItem>> sapVoucherDetails = parseVoucherDetail(workflowData, sapConfigMain.getVoucherDetails(), workflowDetailData);
|
||||
return Builder.builder(SapVoucher::new)
|
||||
.with(SapVoucher::setVoucherHead, sapVoucherHead)
|
||||
.with(SapVoucher::setVoucherDetail, sapVoucherDetails)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <h2>parseVoucherDetailByMainTable 解析凭证明细数据</h2>
|
||||
* <i>2023/2/2 16:50</i>
|
||||
* ************************************************************
|
||||
*
|
||||
* @param workflowData 流程数据
|
||||
* @param detailConfigList 凭证明细配置数据
|
||||
* @param workflowDetailData 明细表数据
|
||||
* @return List<Map < String, Object>> 凭证明细数据
|
||||
* @author youHong.ai ******************************************
|
||||
*/
|
||||
private List<List<VoucherItem>> parseVoucherDetail(Map<String, Object> workflowData,
|
||||
List<SapConfigDetail> detailConfigList,
|
||||
List<Map<String, Object>> workflowDetailData) {
|
||||
List<List<VoucherItem>> result = new ArrayList<>();
|
||||
for (Map<String, Object> workflowDetailDatum : workflowDetailData) {
|
||||
Map<String, Object> workflowDataTemp = new HashMap<>(workflowData);
|
||||
workflowDataTemp.put("dt", workflowDetailDatum);
|
||||
List<List<VoucherItem>> voucherListRow = parseVoucherDetailByMainTable(workflowDataTemp, detailConfigList);
|
||||
result.addAll(voucherListRow);
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* <h1>值处理方法</h1>
|
||||
*
|
||||
* <p>create: 2023-02-02 15:15</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
|
||||
public class ValueRuleMethod {
|
||||
|
||||
|
||||
public static final Map<Integer, BiFunction<SapConfigDetail, Map<String, Object>, Object>> VALUE_RULE_FUNCTION = new HashMap<>();
|
||||
|
||||
static {
|
||||
Class<ValueRuleMethod> 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<String, Object> workflowData) {
|
||||
return sapConfigDetail.getCustomerValue();
|
||||
}
|
||||
|
||||
|
||||
@ValueRuleMethodNo(value = 1, desc = "流程字段值")
|
||||
public Object getWorkflowValue(SapConfigDetail sapConfigDetail, Map<String, Object> 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<String, Object> 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<String, Object> workflowData) {
|
||||
// TODO 编写自定义接口
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ValueRuleMethodNo(value = 4, desc = "数据表id")
|
||||
public Object getDBTableId(SapConfigDetail sapConfigDetail, Map<String, Object> workflowData) {
|
||||
if (sapConfigDetail.getWorkflowTableName().contains("_dt")) {
|
||||
// 明细表字段
|
||||
return Util.getValueByKeyStr("dt.id", workflowData);
|
||||
} else {
|
||||
// 主表字段
|
||||
return Util.getValueByKeyStr("main.id", workflowData);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package weaver.youhong.ai.haripijiu.action.sapdocking.config.util;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* <h1>值处理方法编号注解</h1>
|
||||
*
|
||||
* <p>create: 2023-02-02 15:18</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface ValueRuleMethodNo {
|
||||
int value();
|
||||
String desc();
|
||||
}
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* <h1>对接sap凭证service</h1>
|
||||
*
|
||||
* <p>create: 2023-02-02 17:33</p>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* <h2>sendSapVoucher 获取凭证文件位置</h2>
|
||||
* <i>2023/2/3 11:34</i>
|
||||
* ************************************************************
|
||||
*
|
||||
* @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<VoucherItem> 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<List<VoucherItem>> voucherDetail = voucherData.getVoucherDetail();
|
||||
for (List<VoucherItem> 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<List<VoucherItem>> voucherDetail = voucherData.getVoucherDetail();
|
||||
for (int i = 0; i < voucherDetail.size(); i++) {
|
||||
List<VoucherItem> 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<String> sendPaymentVoucher(String onlyMark, String requestId, String billTable) {
|
||||
SapVoucher voucherData = configService.getReceiptPaymentData(onlyMark, requestId, billTable);
|
||||
List<String> filePathList = new ArrayList<>();
|
||||
/* ******************* 整理数据 ******************* */
|
||||
StringBuilder voucherHeadBuilder = new StringBuilder();
|
||||
List<List<VoucherItem>> voucherDetail = voucherData.getVoucherDetail();
|
||||
for (List<VoucherItem> 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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <h2>appendVoucherItems 拼接凭证明细</h2>
|
||||
* <i>2023/2/3 11:36</i>
|
||||
* ************************************************************
|
||||
*
|
||||
* @param voucherItems 凭证明细数据
|
||||
* @return String 拼接后字符串
|
||||
* @author youHong.ai ******************************************
|
||||
*/
|
||||
private String appendVoucherItems(List<VoucherItem> voucherItems) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (VoucherItem voucherItem : voucherItems) {
|
||||
result.append(voucherItem.getValue())
|
||||
.append("\t");
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* <h1>发送邮件给外部人员</h1>
|
||||
*
|
||||
* <p>create: 2023-02-03 12:10</p>
|
||||
*
|
||||
* @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<String, String> 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<DocImageInfo> docImageInfos = Util.selectImageInfoByDocIds(docIds);
|
||||
Assert.notEmpty(docImageInfos, "can not query docImageInfo by Util.selectImageInfoByDocIds method, param is [{}]", docIds);
|
||||
List<Integer> 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, "批量签署自动提交流程!");
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* <h1>保存自定义处理方法</h1>
|
||||
*
|
||||
* <p>create: 2023-02-06 12:57</p>
|
||||
*
|
||||
* @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<String, String> doModeExpand(Map<String, Object> param) {
|
||||
Map<String, String> 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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package weaver.youhong.ai.yihong.formmode.stagediagram.mapper;
|
||||
|
||||
import aiyh.utils.annotation.recordset.SqlMapper;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
*
|
||||
* <p>create: 2023-02-06 13:38</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
|
||||
@SqlMapper
|
||||
public class ModeExpandSaveActionMapper {
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* <h1>保存自定义处理方法service</h1>
|
||||
*
|
||||
* <p>create: 2023-02-06 14:01</p>
|
||||
*
|
||||
* @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<String, Object> 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<String, String> mainTableValue = getMainTableValue(requestInfo);
|
||||
String projectId = mainTableValue.get(stageDiagramProjectFieldName);
|
||||
/* ******************* 查询台账中对应的project是否存在, 台账中不存在则插入,存在则更新 ******************* */
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <h2>获取流程主表数据</h2>
|
||||
*
|
||||
* @return 流程主表数据
|
||||
*/
|
||||
protected Map<String, String> getMainTableValue(RequestInfo requestInfo) {
|
||||
// 获取主表数据
|
||||
Property[] propertyArr = requestInfo.getMainTableInfo().getProperty();
|
||||
return getStringMap(propertyArr);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Map<String, String> getStringMap(Property[] propertyArr) {
|
||||
if (null == propertyArr) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
Map<String, String> mainTable = new HashMap<>();
|
||||
for (Property property : propertyArr) {
|
||||
String fieldName = property.getName();
|
||||
String value = property.getValue();
|
||||
mainTable.put(fieldName, value);
|
||||
}
|
||||
return mainTable;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* <h1>测试</h1>
|
||||
*
|
||||
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue