修改dealwithmapping获取字段数据bug
parent
dfc89e7d21
commit
9dacdd2751
|
@ -297,4 +297,25 @@ $(() => {
|
|||
})
|
||||
})
|
||||
|
||||
/* ******************* apa(employee)流程明细分数控制end ******************* */
|
||||
/* ******************* apa(employee)流程明细分数控制end ******************* */
|
||||
|
||||
const workflowInsertValueConfig = [
|
||||
{
|
||||
table: '',
|
||||
targetTable: '',
|
||||
filedMapping: [{
|
||||
source: '',
|
||||
target: ''
|
||||
}]
|
||||
}, {
|
||||
table: '',
|
||||
targetTable: '',
|
||||
filedMapping: []
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
/* ******************* 流程明细数据整合插入start ******************* */
|
||||
|
||||
|
||||
/* ******************* 流程明细数据整合插入end ******************* */
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -4,8 +4,13 @@ import aiyh.utils.ApiResult;
|
|||
import aiyh.utils.Util;
|
||||
import com.api.youhong.ai.pcn.workflow.doworkflowtomodel.service.ApaLevelByScoreService;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
/**
|
||||
|
@ -18,21 +23,36 @@ import javax.ws.rs.core.MediaType;
|
|||
|
||||
@Path("ayh/workflow/apa")
|
||||
public class ApaLevelByScoreController {
|
||||
|
||||
private final Logger log = Util.getLogger();
|
||||
private final ApaLevelByScoreService service = new ApaLevelByScoreService();
|
||||
|
||||
@Path("/level")
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public String getLevelByScore(@QueryParam("score") Double score) {
|
||||
try {
|
||||
Integer level = service.getLevelByScore(score);
|
||||
return ApiResult.success(level);
|
||||
} catch (Exception e) {
|
||||
log.error("get level error \n" + Util.getErrString(e));
|
||||
return ApiResult.error("get level error " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private final Logger log = Util.getLogger();
|
||||
private final ApaLevelByScoreService service = new ApaLevelByScoreService();
|
||||
|
||||
@Path("/level")
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public String getLevelByScore(@QueryParam("score") Double score) {
|
||||
try {
|
||||
Integer level = service.getLevelByScore(score);
|
||||
return ApiResult.success(level);
|
||||
} catch (Exception e) {
|
||||
log.error("get level error \n" + Util.getErrString(e));
|
||||
return ApiResult.error("get level error " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@GET
|
||||
@Path("/get-data-id")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public String getApaLastDateId(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
try {
|
||||
return ApiResult.success(service.getApaLastDateId(user));
|
||||
} catch (Exception e) {
|
||||
log.error("get apa workflow param(mode id) error ! \n" + Util.getErrString(e));
|
||||
return ApiResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package com.api.youhong.ai.pcn.workflow.doworkflowtomodel.mapper;
|
||||
|
||||
import aiyh.utils.annotation.recordset.ParamMapper;
|
||||
import aiyh.utils.annotation.recordset.Select;
|
||||
import aiyh.utils.annotation.recordset.SqlMapper;
|
||||
|
||||
|
@ -13,16 +14,22 @@ import aiyh.utils.annotation.recordset.SqlMapper;
|
|||
|
||||
@SqlMapper
|
||||
public interface ApaLevelByScoreMapper {
|
||||
|
||||
/**
|
||||
* <h2>通过apa分数查询对应的分数等级</h2>
|
||||
* <i>2022/12/13 10:47</i>
|
||||
* ************************************************************
|
||||
*
|
||||
* @param score 分数
|
||||
* @return Integer 当前分数对应的等级
|
||||
* @author youHong.ai ******************************************
|
||||
*/
|
||||
@Select("select level1 from uf_APAlevel where #{score} between zdf and zgf")
|
||||
Integer selectLevelByScore(Double score);
|
||||
|
||||
/**
|
||||
* <h2>通过apa分数查询对应的分数等级</h2>
|
||||
* <i>2022/12/13 10:47</i>
|
||||
* ************************************************************
|
||||
*
|
||||
* @param score 分数
|
||||
* @return Integer 当前分数对应的等级
|
||||
* @author youHong.ai ******************************************
|
||||
*/
|
||||
@Select("select level1 from uf_APAlevel where #{score} between zdf and zgf")
|
||||
Integer selectLevelByScore(Double score);
|
||||
|
||||
|
||||
@Select("select id from $t{tableName} where $t{userField} = #{uId}")
|
||||
Integer selectLevelByUserId(@ParamMapper("uId") int uid,
|
||||
@ParamMapper("tableName") String tableName,
|
||||
@ParamMapper("userField") String userField);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package com.api.youhong.ai.pcn.workflow.doworkflowtomodel.service;
|
|||
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.excention.CustomerException;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import com.api.youhong.ai.pcn.workflow.doworkflowtomodel.mapper.ApaLevelByScoreMapper;
|
||||
import weaver.hrm.User;
|
||||
|
||||
/**
|
||||
* <h1></h1>
|
||||
|
@ -13,22 +15,30 @@ import com.api.youhong.ai.pcn.workflow.doworkflowtomodel.mapper.ApaLevelByScoreM
|
|||
*/
|
||||
|
||||
public class ApaLevelByScoreService {
|
||||
private final ApaLevelByScoreMapper mapper = Util.getMapper(ApaLevelByScoreMapper.class);
|
||||
|
||||
/**
|
||||
* <h2>根据分数查询等级</h2>
|
||||
* <i>2022/12/13 10:55</i>
|
||||
* ************************************************************
|
||||
*
|
||||
* @param score 分数
|
||||
* @return Integer 等级
|
||||
* @author youHong.ai ******************************************
|
||||
*/
|
||||
public Integer getLevelByScore(Double score) {
|
||||
Integer level = mapper.selectLevelByScore(score);
|
||||
if (level < -1) {
|
||||
throw new CustomerException("query level error, score is [" + score + "");
|
||||
}
|
||||
return level;
|
||||
}
|
||||
private final ApaLevelByScoreMapper mapper = Util.getMapper(ApaLevelByScoreMapper.class);
|
||||
|
||||
/**
|
||||
* <h2>根据分数查询等级</h2>
|
||||
* <i>2022/12/13 10:55</i>
|
||||
* ************************************************************
|
||||
*
|
||||
* @param score 分数
|
||||
* @return Integer 等级
|
||||
* @author youHong.ai ******************************************
|
||||
*/
|
||||
public Integer getLevelByScore(Double score) {
|
||||
Integer level = mapper.selectLevelByScore(score);
|
||||
if (level < -1) {
|
||||
throw new CustomerException("query level error, score is [" + score + "");
|
||||
}
|
||||
return level;
|
||||
}
|
||||
|
||||
public Integer getApaLastDateId(User user) {
|
||||
String apaLastIdTableName = Util.getCusConfigValue("APA_LAST_ID_TABLE_NAME");
|
||||
String apaLastIdUserField = Util.getCusConfigValue("APA_LAST_ID_USER_FIELD");
|
||||
Assert.notBlank(apaLastIdTableName, "can not get config [APA_LAST_ID_TABLE_NAME] from uf_cus_dev_config!");
|
||||
Assert.notBlank(apaLastIdUserField, "can not get config [APA_LAST_ID_USER_FIELD] from uf_cus_dev_config!");
|
||||
return mapper.selectLevelByUserId(user.getUID(), apaLastIdTableName, apaLastIdUserField);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
package com.api.youhong.ai.zhishichanquan.ssocaiwu.controller;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.api.youhong.ai.zhishichanquan.ssocaiwu.util.AES;
|
||||
import com.sun.jersey.api.view.Viewable;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.core.Context;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <h1>知识产权局单点登录到财务系统</h1>
|
||||
*
|
||||
* <p>create: 2023/2/8 17:10</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
@Path("/aiyh/sso/caiwu/")
|
||||
public class SingleSignOnController {
|
||||
|
||||
private final Logger log = Util.getLogger();
|
||||
|
||||
@Path("/send-redirect")
|
||||
@GET
|
||||
public Viewable ssoSendRedirect(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
try {
|
||||
String url = Util.getCusConfigValue("FinancialAffairsURL");
|
||||
String key = Util.getCusConfigValue("FinancialAffairsKey");
|
||||
String initVector = Util.getCusConfigValue("FinancialAffairsInitVector");
|
||||
Assert.notBlank(url, "sendRedirect url is null, check config [FinancialAffairsURL] on uf_cus_dev_config table!");
|
||||
Assert.notBlank(key, "sendRedirect AES encrypt key is null, check config [FinancialAffairsKey] on uf_cus_dev_config table!");
|
||||
Assert.notBlank(initVector, "sendRedirect AES encrypt initVector is null, check config [FinancialAffairsInitVector] on uf_cus_dev_config table!");
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
String userCodeMethod = Util.getCusConfigValueNullOrEmpty("FinancialAffairsUserCodeMethod", "getLoginid");
|
||||
Method method = User.class.getMethod(userCodeMethod);
|
||||
Object value = method.invoke(user);
|
||||
Map<String, Object> param = new HashMap<>(8);
|
||||
param.put("user", value);
|
||||
param.put("ts", System.currentTimeMillis());
|
||||
String encrypt = AES.encrypt(key, initVector, JSON.toJSONString(param));
|
||||
response.sendRedirect(url + "?params=" + encrypt);
|
||||
} catch (Exception e) {
|
||||
log.error("单点登录路径处理失败!" + e.getMessage() + "\n" + Util.getErrString(e));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.api.youhong.ai.zhishichanquan.ssocaiwu.util;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.util.Base64;
|
||||
|
||||
public class AES {
|
||||
public static String encrypt(String key, String initVector, String value) {
|
||||
try {
|
||||
IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8"));
|
||||
SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
|
||||
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv);
|
||||
|
||||
byte[] encrypted = cipher.doFinal(value.getBytes());
|
||||
return Base64.getEncoder().encodeToString(encrypted);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String decrypt(String key, String initVector, String encrypted) {
|
||||
try {
|
||||
IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8"));
|
||||
SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
|
||||
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
|
||||
cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);
|
||||
|
||||
byte[] original = cipher.doFinal(Base64.getDecoder().decode(encrypted));
|
||||
|
||||
return new String(original);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -12,7 +12,10 @@ import lombok.ToString;
|
|||
import weaver.hrm.User;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import weaver.youhong.ai.haripijiu.action.sapdocking.service.VoucherPayableService;
|
||||
import weaver.youhong.ai.haripijiu.action.sapdocking.util.SmbjUtil;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -26,55 +29,87 @@ import java.util.List;
|
|||
@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对接自动提交流程!");
|
||||
}
|
||||
|
||||
|
||||
@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;
|
||||
|
||||
|
||||
@PrintParamMark
|
||||
@RequiredMark("收款单远程路径存储")
|
||||
private String receiptPath;
|
||||
|
||||
@PrintParamMark
|
||||
@RequiredMark("付款单远程路径存储")
|
||||
private String paymentPath;
|
||||
|
||||
@PrintParamMark
|
||||
@RequiredMark("用户名")
|
||||
private String userName;
|
||||
|
||||
@PrintParamMark
|
||||
@RequiredMark("密码")
|
||||
private String password;
|
||||
|
||||
|
||||
@PrintParamMark
|
||||
@RequiredMark("ip")
|
||||
private String ip;
|
||||
|
||||
@Override
|
||||
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
|
||||
try {
|
||||
SmbjUtil smbjUtil = new SmbjUtil();
|
||||
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 根据不同的规则生成不同的文件名并将文件存储到指定位置
|
||||
log.info("远程连接地址:" + "smb://" + ip + receiptPath);
|
||||
log.info("本地文件地址: " + filePath);
|
||||
smbjUtil.smbPut("smb://" + ip + receiptPath, filePath, userName, password, fileName);
|
||||
Files.delete(Paths.get(filePath));
|
||||
}
|
||||
} else if (Integer.parseInt(voucherType) == 2) {
|
||||
String tempFilePath = server.sendReceiptVoucher(onlyMark, requestId, billTable);
|
||||
fileName = "Payment" + Util.getTime("yyyyMMddHHmmss") + ".txt";
|
||||
// TODO 根据不同的规则生成不同的文件名并将文件存储到指定位置
|
||||
log.info("远程连接地址:" + "smb://" + ip + paymentPath);
|
||||
log.info("本地文件地址: " + tempFilePath);
|
||||
smbjUtil.smbPut("smb://" + ip + paymentPath, tempFilePath, userName, password, fileName);
|
||||
Files.delete(Paths.get(tempFilePath));
|
||||
}
|
||||
/* ******************* 是否提交流程 ******************* */
|
||||
if (Boolean.parseBoolean(submitAction)) {
|
||||
this.submitWorkflow(requestId, user.getUID());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("推送收付款凭证失败!" + e.getMessage());
|
||||
if (Boolean.parseBoolean(block)) {
|
||||
throw new CustomerException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void submitWorkflow(String requestId, Integer userId) {
|
||||
Util.submitWorkflowThread(Integer.parseInt(requestId), userId, "sap对接自动提交流程!");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,10 @@ import lombok.ToString;
|
|||
import weaver.hrm.User;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import weaver.youhong.ai.haripijiu.action.sapdocking.service.VoucherPayableService;
|
||||
import weaver.youhong.ai.haripijiu.action.sapdocking.util.SmbjUtil;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
/**
|
||||
* <h1>应付凭证接口</h1>
|
||||
|
@ -25,54 +29,83 @@ import weaver.youhong.ai.haripijiu.action.sapdocking.service.VoucherPayableServi
|
|||
@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对接自动提交流程!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@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;
|
||||
|
||||
|
||||
@PrintParamMark
|
||||
@RequiredMark("应付凭证远程路径")
|
||||
private String pavRemotePath;
|
||||
|
||||
|
||||
@PrintParamMark
|
||||
@RequiredMark("付款凭证远程路径")
|
||||
private String pmvRemotePath;
|
||||
|
||||
@PrintParamMark
|
||||
@RequiredMark("用户名")
|
||||
private String userName;
|
||||
|
||||
@PrintParamMark
|
||||
@RequiredMark("密码")
|
||||
private String password;
|
||||
|
||||
|
||||
@PrintParamMark
|
||||
@RequiredMark("ip")
|
||||
private String ip;
|
||||
|
||||
@Override
|
||||
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
|
||||
|
||||
try {
|
||||
SmbjUtil smbjUtil = new SmbjUtil();
|
||||
VoucherPayableService server = new VoucherPayableService();
|
||||
String tempFilePath = server.sendSapVoucher(onlyMark, requestId, billTable);
|
||||
String fileName = "";
|
||||
String remotePath = "";
|
||||
if (Integer.parseInt(voucherType) == 1) {
|
||||
fileName = "Pav" + Util.getTime("yyyyMMddHHmmss") + ".txt";
|
||||
remotePath = pavRemotePath;
|
||||
} else if (Integer.parseInt(voucherType) == 2) {
|
||||
fileName = "Pmv" + Util.getTime("yyyyMMddHHmmss") + ".txt";
|
||||
remotePath = pmvRemotePath;
|
||||
}
|
||||
log.info("远程连接地址:" + "smb://" + ip + remotePath);
|
||||
log.info("本地文件地址: " + tempFilePath);
|
||||
smbjUtil.smbPut("smb://" + ip + remotePath, tempFilePath, userName, password, fileName);
|
||||
Files.delete(Paths.get(tempFilePath));
|
||||
/* ******************* 是否提交流程 ******************* */
|
||||
if (Boolean.parseBoolean(submitAction)) {
|
||||
this.submitWorkflow(requestId, user.getUID());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("推送应付款凭证失败!" + e.getMessage());
|
||||
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,120 @@
|
|||
package weaver.youhong.ai.haripijiu.action.sapdocking.util;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.excention.CustomerException;
|
||||
import com.google.common.base.Strings;
|
||||
import jcifs.smb.*;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.MalformedURLException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <h1>windows共享文件夹访问工具</h1>
|
||||
*
|
||||
* <p>create: 2023/2/8 17:55</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
public class SmbjUtil {
|
||||
|
||||
|
||||
private final Logger log = Util.getLogger();
|
||||
|
||||
/**
|
||||
* Description: 从本地上传文件到共享目录
|
||||
*
|
||||
* @param remoteUrl 共享文件目录
|
||||
* @param localFilePath 本地文件绝对路径
|
||||
*/
|
||||
public void smbPut(String remoteUrl, String localFilePath, String userName, String pwd, String fileName) {
|
||||
InputStream in = null;
|
||||
OutputStream out = null;
|
||||
try {
|
||||
File localFile = new File(localFilePath);
|
||||
if (Strings.isNullOrEmpty(fileName)) {
|
||||
fileName = localFile.getName();
|
||||
}
|
||||
// 这里推荐使用这种方式进行用户名密码的校验,在url中拼接,如果需要特殊字符可能无法转换
|
||||
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(null, userName, pwd);
|
||||
SmbFile remoteFile = new SmbFile(remoteUrl + "/" + fileName, auth);
|
||||
in = new BufferedInputStream(Files.newInputStream(localFile.toPath()));
|
||||
out = new BufferedOutputStream(new SmbFileOutputStream(remoteFile));
|
||||
byte[] buffer = new byte[1024];
|
||||
while (in.read(buffer) != -1) {
|
||||
out.write(buffer);
|
||||
buffer = new byte[1024];
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("提交文件到 共享目录失败!\n" + Util.getErrString(e));
|
||||
throw new CustomerException("提交文件到 共享目录失败");
|
||||
} finally {
|
||||
closeStream(in, out);
|
||||
}
|
||||
}
|
||||
|
||||
private void closeStream(InputStream in, OutputStream out) {
|
||||
try {
|
||||
if (!Objects.isNull(out)) {
|
||||
out.close();
|
||||
}
|
||||
if (!Objects.isNull(in)) {
|
||||
in.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("流关闭失败!\n" + Util.getErrString(e));
|
||||
throw new CustomerException("流关闭失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Description: 从共享目录拷贝文件到本地
|
||||
*
|
||||
* @param remoteUrl 共享目录上的文件路径
|
||||
* @param localDir 本地目录
|
||||
*/
|
||||
public void smbGet(String remoteUrl, String localDir) {
|
||||
InputStream in = null;
|
||||
OutputStream out = null;
|
||||
try {
|
||||
SmbFile remoteFile = new SmbFile(remoteUrl);
|
||||
String fileName = remoteFile.getName();
|
||||
File localFile = new File(localDir + File.separator + fileName);
|
||||
in = new BufferedInputStream(new SmbFileInputStream(remoteFile));
|
||||
out = new BufferedOutputStream(Files.newOutputStream(localFile.toPath()));
|
||||
byte[] buffer = new byte[1024];
|
||||
while (in.read(buffer) != -1) {
|
||||
out.write(buffer);
|
||||
buffer = new byte[1024];
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("从共享目录拷贝文件到本地失败!\n" + Util.getErrString(e));
|
||||
throw new CustomerException("从共享目录拷贝文件到本地失败");
|
||||
} finally {
|
||||
closeStream(in, out);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
*
|
||||
* @param remoteUrl 共享文件目录
|
||||
* @param fileName 要删除的文件名
|
||||
*/
|
||||
public void deleteFile(String remoteUrl, String fileName, String userName, String pwd) {
|
||||
SmbFile smbFile;
|
||||
try {
|
||||
// smb://userName:passWord@host/path/shareFolderPath/fileName
|
||||
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(null, userName, pwd);
|
||||
smbFile = new SmbFile(remoteUrl + "/" + fileName, auth);
|
||||
if (smbFile.exists()) {
|
||||
smbFile.delete();
|
||||
}
|
||||
} catch (MalformedURLException | SmbException e) {
|
||||
log.error("删除共享目录文件失败!\n" + Util.getErrString(e));
|
||||
throw new CustomerException("删除共享目录文件失败");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package youhong.ai.haripijiu;
|
||||
|
||||
import aiyh.utils.GenerateFileUtil;
|
||||
import basetest.BaseTest;
|
||||
import org.junit.Test;
|
||||
import weaver.youhong.ai.haripijiu.action.sapdocking.ReceiptAndPaymentAction;
|
||||
import weaver.youhong.ai.haripijiu.action.sapdocking.VoucherPayableAction;
|
||||
|
||||
/**
|
||||
* <h1>测试</h1>
|
||||
*
|
||||
* <p>create: 2023/2/12 13:24</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
public class TestHaRiPiJiu extends BaseTest {
|
||||
|
||||
@Test
|
||||
public void testA() {
|
||||
GenerateFileUtil.createActionDocument(VoucherPayableAction.class);
|
||||
GenerateFileUtil.createActionDocument(ReceiptAndPaymentAction.class);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue