签字意见

main
youHong.ai 2023-04-17 22:47:28 +08:00
parent abf48d1d7d
commit a691c6def9
20 changed files with 2944 additions and 74 deletions

View File

@ -0,0 +1,114 @@
/* ******************* 德尔格 明细物料历史数据折扣带出提示 by youhong.ai ******************* */
$(() => {
let type = {
// 等于
equalTo: (value, target) => value == target,
// 不等于
notEqual: (value, target) => value != target,
// 大于
greaterThan: (value, target) => +value > +target,
// 小于
lessThan: (value, target) => +value < +target
}
// 值类型
let valueType = {
// 固定值
fixValue: 0,
// 流程字段
field: 1
}
let config = {
// 主表填main
table: 'main',
// 明细表明细1为detail_1,明细2为detail_2
detail: 'detail_1',
redField: 'zk',
// 条件集合
conditions: [{
// 所属表
table: 'detail_1',
// 字段
field: 'wllx',
// 对比值
value: 0,
// 值的类型
valueType: valueType.fixValue,
// 值字段所在表
valueTable: '',
// 条件类型
type: type.equalTo
}, {
// 所属表
table: 'detail_1',
// 字段
field: 'zkdc',
// 对比值
value: 'zk',
// 值的类型
valueType: valueType.field,
// 值字段所在表
valueTable: 'detail_1',
// 条件类型
type: type.notEqual
}]
}
runJs()
function runJs() {
let detailAllRowIndexStr = WfForm.getDetailAllRowIndexStr(config.detail);
let rowIndexArr = detailAllRowIndexStr.split(",");
let flag = true
rowIndexArr.forEach(rowIndex => {
if (flag) {
flag = isTrue(rowIndex)
} else {
isTrue(rowIndex)
}
})
if (!flag) {
WfForm.showConfirm("当前订单折扣不等于默认折扣");
}
}
function isTrue(rowIndex) {
let flag = true
for (let i = 0; i < config.conditions.length; i++) {
let item = config.conditions[i]
let fieldId = WfForm.convertFieldNameToId(config, item.table)
let fieldMark = `${fieldId}_${rowIndex}`
let fieldValue = WfForm.getFieldValue(fieldMark)
if (item.valueType == valueType.fixValue) {
if (item.type(fieldValue, item.value)) {
continue
}
renderRed(`${WfForm.convertFieldNameToId(config.redField, config.detail)}_${rowIndex}`)
flag = false
}
if (item.valueType == valueType.field) {
if (item.type(fieldValue, WfForm.getFieldValue(item.value, item.valueTable))) {
continue
}
renderRed(`${WfForm.convertFieldNameToId(config.redField, config.detail)}_${rowIndex}`)
flag = false
}
}
return flag
}
function renderRed(fieldMark) {
$(`#oTable0 .detail_odd_row.detail_data_row div[data-fieldmark='${fieldMark}'] .wf-form-input`).css({
color: '#FFF',
background: 'red',
})
$(`#oTable0 .detail_odd_row.detail_data_row div[data-fieldmark='${fieldMark}'] .wf-form-input input`).css({
'border-color': 'red',
background: 'red',
color: '#FFF'
})
}
})
/* ******************* 德尔格 明细物料历史数据折扣带出提示 end ******************* */

View File

@ -1,6 +1,7 @@
package aiyh.utils.action;
import aiyh.utils.Util;
import aiyh.utils.action.mapper.SafeActionMapper;
import aiyh.utils.excention.CustomerException;
import com.google.common.base.Strings;
import org.apache.log4j.Logger;
@ -29,6 +30,8 @@ public abstract class SafeCusBaseAction implements Action {
protected final Logger log = Util.getLogger();
private final Map<String, SafeCusBaseActionHandleFunction> actionHandleMethod = new HashMap<>();
private final SafeActionMapper mapper = Util.getMapper(SafeActionMapper.class);
/**
* <h2></h2>
*/
@ -191,7 +194,12 @@ public abstract class SafeCusBaseAction implements Action {
protected Map<String, String> getMainTableValue(RequestInfo requestInfo) {
// 获取主表数据
Property[] propertyArr = requestInfo.getMainTableInfo().getProperty();
return getStringMap(propertyArr);
Map<String, String> result = getStringMap(propertyArr);
RequestManager requestManager = requestInfo.getRequestManager();
String billTable = requestManager.getBillTableName();
String id = mapper.selectIdByRequest(billTable, requestInfo.getRequestid());
result.put("id", id);
return result;
}
@NotNull

View File

@ -0,0 +1,20 @@
package aiyh.utils.action.mapper;
import aiyh.utils.annotation.recordset.ParamMapper;
import aiyh.utils.annotation.recordset.Select;
import aiyh.utils.annotation.recordset.SqlMapper;
/**
* <h1></h1>
*
* <p>create: 2023/4/17 17:47</p>
*
* @author youHong.ai
*/
@SqlMapper
public interface SafeActionMapper {
@Select("select id from $t{billTable} where requestid = #{requestId}")
String selectIdByRequest(@ParamMapper("billTable") String billTable,
@ParamMapper("requestId") String requestId);
}

View File

@ -38,7 +38,6 @@ public class RequestLogShowOrHiddenImpl extends AbstractServiceProxy implements
Logger log = Util.getLogger();
try {
privacyRequestLogUtil.requestLogList(result, params, request);
log.info("最终的返回结果: " + JSON.toJSONString(result));
} catch (Exception e) {
log.error("filter request log list error!" + Util.getErrString(e));
}

View File

@ -4,6 +4,7 @@ import aiyh.utils.annotation.recordset.*;
import com.customization.youhong.deerge.requestlog.pojo.RequestLogPrivacyEntity;
import java.util.List;
import java.util.Map;
/**
* <h1></h1>
@ -24,11 +25,11 @@ public interface InterceptRequestLogMapper {
* @param operator
* @return id
*/
@Select("select logid from workflow_requestlog where REQUESTID = #{requestId} " +
@Select("select logid,operatetime from workflow_requestlog where REQUESTID = #{requestId} " +
"and NODEID = #{nodeId} and OPERATOR = #{operator} order by LOGID desc ")
Integer selectRequestLogId(@ParamMapper("requestId") String requestId,
@ParamMapper("nodeId") String nodeId,
@ParamMapper("operator") String operator);
List<Map<String, Object>> selectRequestLogId(@ParamMapper("requestId") String requestId,
@ParamMapper("nodeId") String nodeId,
@ParamMapper("operator") String operator);
/**
* <h2></h2>

View File

@ -12,10 +12,7 @@ import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -58,10 +55,29 @@ public class PrivacyRequestLogUtil {
}
logger.info("添加隐私按钮!未开启隐私");
// 未开启隐私,更新签字意见隐私信息为不隐私
Integer logId = mapper.selectRequestLogId(requestId, nodeId, userId);
if (logId > 0) {
mapper.updateRequestLogStatus(logId, userId, nodeId, requestId, "0");
List<Map<String, Object>> nodeIdMapList = mapper.selectRequestLogId(requestId, nodeId, userId);
logger.info("查询的log日志列表" + nodeIdMapList);
if (CollectionUtil.isEmpty(nodeIdMapList)) {
return;
}
Map<String, Object> firstLog = nodeIdMapList.get(0);
String operateTime = Util.null2String(firstLog.get("operatetime"));
List<Integer> logList = new ArrayList<>();
for (Map<String, Object> item : nodeIdMapList) {
String itemOperateTime = Util.null2String(item.get("operatetime"));
int logId = Integer.parseInt(Util.null2String(item.get("logid")));
if (operateTime.equals(itemOperateTime)) {
logList.add(logId);
} else {
break;
}
}
for (Integer logId : logList) {
if (logId > 0) {
mapper.updateRequestLogStatus(logId, userId, nodeId, requestId, "0");
}
}
}
/**
@ -74,26 +90,45 @@ public class PrivacyRequestLogUtil {
* @param enablePrivacy
*/
private void insertRequestPrivacyLog(String userId, String nodeId, String requestId, String field5, String enablePrivacy) {
Integer logId = mapper.selectRequestLogId(requestId, nodeId, userId);
Logger logger = Util.getLogger();
logger.info("查询到的logId是:" + logId);
if (logId <= 0) {
throw new CustomerException("request log id query error!\n");
List<Map<String, Object>> nodeIdMapList = mapper.selectRequestLogId(requestId, nodeId, userId);
logger.info("查询的log日志列表" + nodeIdMapList);
if (CollectionUtil.isEmpty(nodeIdMapList)) {
return;
}
Integer dataId = mapper.selectRequestLogDataId(requestId, nodeId, userId, String.valueOf(logId));
logger.info("查询到的数据id是:" + logId);
if (dataId <= 0) {
// 插入logId隐私信息
dataId = Util.getModeDataId("uf_privacy_log_info", 1);
Map<String, Object> firstLog = nodeIdMapList.get(0);
String operateTime = Util.null2String(firstLog.get("operatetime"));
List<Integer> logList = new ArrayList<>();
for (Map<String, Object> item : nodeIdMapList) {
String itemOperateTime = Util.null2String(item.get("operatetime"));
int logId = Integer.parseInt(Util.null2String(item.get("logid")));
if (operateTime.equals(itemOperateTime)) {
logList.add(logId);
} else {
break;
}
}
Boolean flag = mapper.insertPrivacyLog(dataId, logId, userId, nodeId, requestId, field5, enablePrivacy);
if (!flag) {
logger.info("更新失败签字意见隐私信息失败!");
Util.deleteModeId("uf_privacy_log_info", dataId);
} else {
Util.rebuildModeDataShare(1,
Integer.parseInt(Util.getModeIdByTableName("uf_privacy_log_info")),
dataId);
for (Integer logId : logList) {
logger.info("查询到的logId是:" + logId);
if (logId <= 0) {
throw new CustomerException("request log id query error!\n");
}
Integer dataId = mapper.selectRequestLogDataId(requestId, nodeId, userId, String.valueOf(logId));
logger.info("查询到的数据id是:" + logId);
if (dataId <= 0) {
// 插入logId隐私信息
dataId = Util.getModeDataId("uf_privacy_log_info", 1);
}
Boolean flag = mapper.insertPrivacyLog(dataId, logId, userId, nodeId, requestId, field5, enablePrivacy);
if (!flag) {
logger.info("更新失败签字意见隐私信息失败!");
Util.deleteModeId("uf_privacy_log_info", dataId);
} else {
Util.rebuildModeDataShare(1,
Integer.parseInt(Util.getModeIdByTableName("uf_privacy_log_info")),
dataId);
}
}
}
@ -120,8 +155,6 @@ public class PrivacyRequestLogUtil {
}
String[] split = targetHrm.split(",");
List<String> hrmIds = Arrays.asList(split);
logger.info("查询到hrmIds数据" + JSON.toJSONString(hrmIds));
logger.info("当前用户Id:" + userId);
if (hrmIds.contains(userId)) {
// 默认签字意见隐私
insertRequestPrivacyLog(userId, nodeId, requestId, field5, "1");
@ -139,21 +172,17 @@ public class PrivacyRequestLogUtil {
*/
public void requestLogList(Map<String, Object> result, Map<String, Object> params, HttpServletRequest request) {
Logger logger = Util.getLogger();
String isMonitor = request.getParameter("ismonitor");
boolean isPrint = "1".equals(Util.null2String(request.getParameter("isprint")));
String requestId = Util.null2String(params.get("requestid"));
User user = HrmUserVarify.getUser(request, null);
logger.info("结果: " + JSON.toJSONString(result));
if (isPrint) {
// 打印
hiddenAll(result, requestId);
logger.info("最终的结果: " + JSON.toJSONString(result));
return;
}
// 是流程监控
if (!StrUtil.isBlank(isMonitor)) {
logger.info("流程监控最终的结果: " + JSON.toJSONString(result));
return;
}
@ -163,7 +192,6 @@ public class PrivacyRequestLogUtil {
if (CollectionUtil.isEmpty(privacyUserList)) {
// 不存在签字意见组中,所有隐私信息不可查看
hiddenAll(result, requestId);
logger.info("不在隐私组最终的结果: " + JSON.toJSONString(result));
return;
}
// 查询非本组隐私的隐私信息
@ -197,6 +225,7 @@ public class PrivacyRequestLogUtil {
*/
private static void hiddenContentOrHiddenLog(Map<String, Object> result, List<Map<String, Object>> logList, List<String> privacyLogIdList) {
String showContent = Util.getCusConfigValueNullOrEmpty("REQUEST_LOG_SHOW_CONTENT", "false");
String requestLogShowContentDefault = Util.getCusConfigValueNullOrEmpty("requestLogShowContentDefault", "");
if (!Boolean.parseBoolean(showContent)) {
List<Map<String, Object>> newLogList = logList.stream()
.filter(item -> !privacyLogIdList.contains(Util.null2String(item.get("logid"))))
@ -207,7 +236,7 @@ public class PrivacyRequestLogUtil {
List<Map<String, Object>> newLogList = logList.stream()
.peek(item -> {
if (privacyLogIdList.contains(Util.null2String(item.get("logid")))) {
item.put("log_remarkHtml", "");
item.put("log_remarkHtml", requestLogShowContentDefault);
}
})
.collect(Collectors.toList());

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,21 @@
package com.engine.youhong.ai.taibao.email;
import java.util.Set;
/**
* <h1></h1>
*
* <p>create: 2023/4/14 17:07</p>
*
* @author youHong.ai
*/
public interface BlackListExpansion {
/**
* <h2></h2>
*
* @param mailAddress
* @return
*/
Set<String> sendEmailHandler(Set<String> mailAddress);
}

View File

@ -0,0 +1,38 @@
package com.engine.youhong.ai.taibao.email;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* <h1></h1>
*
* <p>create: 2023/4/14 17:09</p>
*
* @author youHong.ai
*/
public class BlackListRegister {
private static final List<BlackListExpansion> EXPANSION_LIST = new ArrayList<>();
private static final List<BlackListExpansion> EXPANSION_APPROVE_LIST = new ArrayList<>();
public static void registerExpansion(BlackListExpansion blackListExpansion) {
if (Objects.nonNull(blackListExpansion)) {
EXPANSION_LIST.add(blackListExpansion);
}
}
public static void registerAPPROVEExpansion(BlackListExpansion blackListExpansion) {
if (Objects.nonNull(blackListExpansion)) {
EXPANSION_APPROVE_LIST.add(blackListExpansion);
}
}
public static List<BlackListExpansion> getExpansionList() {
return EXPANSION_LIST;
}
public static List<BlackListExpansion> getExpansionApproveList() {
return EXPANSION_APPROVE_LIST;
}
}

View File

@ -0,0 +1,64 @@
package com.engine.youhong.ai.taibao.email.impl;
import aiyh.utils.Util;
import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil;
import com.engine.youhong.ai.taibao.email.BlackListRegister;
import com.engine.youhong.ai.taibao.email.mapper.InitBlackEmailListMapper;
import com.weaverboot.frame.ioc.anno.classAnno.WeaSysInitComponent;
import com.weaverboot.frame.ioc.anno.methodAnno.WeaSysInit;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* <h1></h1>
*
* <p>create: 2023/4/14 17:15</p>
*
* @author youHong.ai
*/
@WeaSysInitComponent("注册email黑名单拦截器")
public class InitBlackListServiceImpl {
private final InitBlackEmailListMapper mapper = Util.getMapper(InitBlackEmailListMapper.class);
@WeaSysInit(order = 1, description = "注册拦截邮箱黑名单")
public void init() {
Util.getLogger().info("注册拦截邮箱黑名单,init");
BlackListRegister.registerExpansion(set -> {
if (Objects.isNull(set)) {
return null;
}
List<String> hrmList = mapper.selectWorkflowBlackEmailList();
String ids = Util.join(hrmList, ",");
List<String> blackEmailList = mapper.selectEmailListByHrmIds(ids);
if (CollectionUtil.isEmpty(blackEmailList)) {
return set;
}
return set.stream()
.filter(item -> !blackEmailList.contains(item))
.collect(Collectors.toSet());
});
}
@WeaSysInit(order = 2, description = "注册拦截邮箱黑名单")
public void initApprove() {
Util.getLogger().info("注册拦截邮箱黑名单,initApprove");
BlackListRegister.registerAPPROVEExpansion(set -> {
if (Objects.isNull(set)) {
return null;
}
String ids = mapper.selectWorkflowApproveBlackEmailList();
List<String> blackEmailList = mapper.selectEmailListByHrmIds(ids);
if (CollectionUtil.isEmpty(blackEmailList)) {
return set;
}
return set.stream()
.filter(item -> !blackEmailList.contains(item))
.collect(Collectors.toSet());
});
}
}

View File

@ -0,0 +1,44 @@
package com.engine.youhong.ai.taibao.email.mapper;
import aiyh.utils.annotation.recordset.Select;
import aiyh.utils.annotation.recordset.SqlMapper;
import java.util.List;
/**
* <h1></h1>
*
* <p>create: 2023/4/14 17:20</p>
*
* @author youHong.ai
*/
@SqlMapper
public interface InitBlackEmailListMapper {
/**
* <h2></h2>
*
* @return email
*/
@Select("select black_hrm from uf_black_email_conf where type = 0")
List<String> selectWorkflowBlackEmailList();
/**
* <h2></h2>
*
* @return email
*/
@Select("select email from uf_black_email_conf where type = 1")
String selectWorkflowApproveBlackEmailList();
/**
* <h2>idid</h2>
*
* @param ids ids
* @return
*/
@Select("select email from hrmresource where id in ($t{ids})")
List<String> selectEmailListByHrmIds(String ids);
}

View File

@ -10,35 +10,47 @@ import java.util.Map;
*/
public enum GetValueTypeEnum {
WORKFLOW_FIELD("0"),
DEFAULT_VALUE("1"),
CURRENT_TIME("3"),
CUS_SQL("4"),
REQUEST_ID("5"),
MAIN_DATA_ID("6"),
RANDOM("7"),
ATTACHMENT("8"),
CUS_INTERFACE("9"),
CUS_FIELD("10");
private static final Map<String, GetValueTypeEnum> LOOK_UP = new HashMap<>(8);
static {
for (GetValueTypeEnum getValueTypeEnum : EnumSet.allOf(GetValueTypeEnum.class)) {
LOOK_UP.put(getValueTypeEnum.value, getValueTypeEnum);
}
}
public final String value;
GetValueTypeEnum(String value) {
this.value = value;
}
public static GetValueTypeEnum getEnum(String value) {
return LOOK_UP.get(value);
}
/** 流程字段 */
WORKFLOW_FIELD("0"),
/** 默认值 */
DEFAULT_VALUE("1"),
/** 当前时间 */
CURRENT_TIME("3"),
/** 自定义sql */
CUS_SQL("4"),
/** 流程请求id */
REQUEST_ID("5"),
/** 主表数据id */
MAIN_DATA_ID("6"),
/** 随机值 */
RANDOM("7"),
/** 附件 */
ATTACHMENT("8"),
/** 自定义接口 */
CUS_INTERFACE("9"),
/** 自定义字段 */
CUS_FIELD("10"),
/** 自定义mapper sql */
CUS_MAPPER_SQL("11");
private static final Map<String, GetValueTypeEnum> LOOK_UP = new HashMap<>(8);
static {
for (GetValueTypeEnum getValueTypeEnum : EnumSet.allOf(GetValueTypeEnum.class)) {
LOOK_UP.put(getValueTypeEnum.value, getValueTypeEnum);
}
}
public final String value;
GetValueTypeEnum(String value) {
this.value = value;
}
public static GetValueTypeEnum getEnum(String value) {
return LOOK_UP.get(value);
}
}

View File

@ -0,0 +1,21 @@
package weaver.xiao.commons.config.mapper;
import aiyh.utils.annotation.recordset.Select;
import aiyh.utils.annotation.recordset.SqlMapper;
import aiyh.utils.annotation.recordset.SqlString;
import java.util.Map;
/**
* <h1></h1>
*
* <p>create: 2023/4/17 22:21</p>
*
* @author youHong.ai
*/
@SqlMapper
public interface DealWithMapper {
@Select(custom = true)
String selectCustomSql(@SqlString String sql, Map<String, Object> params);
}

View File

@ -15,6 +15,7 @@ import weaver.xiao.commons.config.enumtype.GetValueTypeEnum;
import weaver.xiao.commons.config.enumtype.ParamTypeEnum;
import weaver.xiao.commons.config.interfacies.CusInterfaceGetValue;
import weaver.xiao.commons.config.interfacies.CusInterfaceListValue;
import weaver.xiao.commons.config.mapper.DealWithMapper;
import weaver.xiao.commons.exception.ValueDealException;
import weaver.zwl.common.ToolUtil;
@ -57,6 +58,16 @@ public class DealWithMapping extends ToolUtil {
private RecordSet tempRs;
private DealWithMapper mapper = null;
{
try {
mapper = aiyh.utils.Util.getMapper(DealWithMapper.class);
} catch (Exception e) {
this.writeErrorLog("缺少 aiyh_utils.jar依赖初始化失败");
}
}
/**
* <h1>Date</h1>
*
@ -123,9 +134,9 @@ public class DealWithMapping extends ToolUtil {
*/
String val = Util.null2String(rs.getString(i));
BigDecimal decimal;
if(StringUtils.isBlank(val)){
if (StringUtils.isBlank(val)) {
decimal = new BigDecimal("0");
}else {
} else {
decimal = new BigDecimal(val);
}
map.put(key, decimal);
@ -748,6 +759,16 @@ public class DealWithMapping extends ToolUtil {
value = detailMap.get(valueContext.trim());
}
break;
case CUS_MAPPER_SQL: {
Map<String, Object> param = new HashMap<>();
param.put("main", mainMap);
param.put("dt", detailMap);
if (mapper == null) {
throw new RuntimeException("缺少 aiyh_utils.jar依赖无法使用mapper");
}
value = mapper.selectCustomSql(valueContext, param);
}
break;
default:
throw new ValueDealException("不支持的取值方式");
}
@ -1088,6 +1109,16 @@ public class DealWithMapping extends ToolUtil {
}
}
break;
case CUS_MAPPER_SQL: {
Map<String, Object> param = new HashMap<>();
param.put("main", mainMap);
param.put("dt", detailMap);
if (mapper == null) {
throw new RuntimeException("缺少 aiyh_utils.jar依赖无法使用mapper");
}
value = mapper.selectCustomSql(valueContext, param);
}
break;
default:
throw new ValueDealException("不支持的取值方式");
}

View File

@ -72,6 +72,16 @@ public class VoucherPayableAction extends SafeCusBaseAction {
@RequiredMark("ip")
private String ip;
@PrintParamMark
@RequiredMark("应付凭证远程文件名称前缀")
private String pavFileName;
@PrintParamMark
@RequiredMark("付款凭证远程文件名称前缀")
private String pmvFileName;
@PrintParamMark
@ActionOptionalParam(desc = "是否删除生成的临时本地文件,true - 删除 false - 不删除", value = "false")
private String deleteTemp = "false";
@ -86,10 +96,10 @@ public class VoucherPayableAction extends SafeCusBaseAction {
String fileName = "";
String remotePath = "";
if (Integer.parseInt(voucherType) == 1) {
fileName = "Pav" + Util.getTime("yyyyMMddHHmmss") + ".txt";
fileName = pavFileName + Util.getTime("yyyyMMddHHmmssSSSS") + ".txt";
remotePath = pavRemotePath;
} else if (Integer.parseInt(voucherType) == 2) {
fileName = "Pmv" + Util.getTime("yyyyMMddHHmmss") + ".txt";
fileName = pmvFileName + Util.getTime("yyyyMMddHHmmssSSSS") + ".txt";
remotePath = pmvRemotePath;
}
log.info("远程连接地址:" + "smb://" + ip + remotePath);

View File

@ -0,0 +1,246 @@
package weaver.youhong.ai.haripijiu.action.sapdocking;
import aiyh.utils.Util;
import aiyh.utils.action.SafeCusBaseAction;
import aiyh.utils.annotation.*;
import aiyh.utils.excention.CustomerException;
import aiyh.utils.tool.cn.hutool.core.lang.Assert;
import lombok.Setter;
import org.jetbrains.annotations.NotNull;
import weaver.general.GCONST;
import weaver.hrm.User;
import weaver.soa.workflow.request.RequestInfo;
import weaver.xiao.commons.config.entity.RequestMappingConfig;
import weaver.xiao.commons.config.service.DealWithMapping;
import weaver.youhong.ai.haripijiu.action.sapdocking.util.SmbjUtil;
import java.io.File;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
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.Map;
import java.util.UUID;
import java.util.stream.Collectors;
/**
* <h1>action</h1>
*
* <p>create: 2023/4/17 14:57</p>
*
* @author youHong.ai
*/
@ActionDesc(author = "youhong.ai", value = "对私凭证action")
@Setter
public class VoucherPayableNewAction extends SafeCusBaseAction {
private final DealWithMapping dealWithMapping = new DealWithMapping();
@PrintParamMark
@RequiredMark("请求参数配置表配置唯一标识字段!")
@ActionDefaultTestValue("duisi")
private String onlyMark;
@PrintParamMark
@ActionOptionalParam(value = "false", desc = "是否自动提交流程 false 不提交; true : 提交")
private String submitAction = "false";
@PrintParamMark
@ActionOptionalParam(value = "true", desc = "是否失败后阻断流程, false 不阻断; true 阻断")
private String block = "true";
@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;
@PrintParamMark
@RequiredMark("应付凭证远程文件名称前缀")
private String pavFileName;
@PrintParamMark
@RequiredMark("付款凭证远程文件名称前缀")
private String pmvFileName;
@PrintParamMark
@ActionOptionalParam(desc = "是否删除生成的临时本地文件,true - 删除 false - 不删除", value = "false")
private String deleteTemp = "false";
@Override
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
try {
SmbjUtil smbjUtil = new SmbjUtil();
String tempFilePath = getFile(billTable, requestInfo);
String fileName = "";
String remotePath = "";
if (Integer.parseInt(voucherType) == 1) {
fileName = pavFileName + Util.getTime("yyyyMMddHHmmssSSSS") + ".txt";
remotePath = pavRemotePath;
} else if (Integer.parseInt(voucherType) == 2) {
fileName = pmvFileName + Util.getTime("yyyyMMddHHmmssSSSS") + ".txt";
remotePath = pmvRemotePath;
}
log.info("远程连接地址:" + "smb://" + ip + remotePath);
log.info("本地文件地址: " + tempFilePath);
smbjUtil.smbPut("smb://" + ip + remotePath, tempFilePath, userName, password, fileName);
if (Boolean.parseBoolean(deleteTemp)) {
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对接自动提交流程");
}
private String getFile(String billTable, RequestInfo requestInfo) {
dealWithMapping.setMainTable(billTable);
RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(onlyMark);
Map<String, Object> requestParam = dealWithMapping.getRequestParam(getObjMainTableValue(requestInfo), requestMappingConfig);
Assert.notEmpty(requestParam, "query config error, can not query result by onlyMark:[{}],Please check the configuration table", onlyMark);
// 借方
List<Object> debit = (List<Object>) requestParam.get("debit");
// 贷方
List<Object> creditSide = (List<Object>) requestParam.get("creditSide");
// 凭证头
Map<String, Object> heads = (Map<String, Object>) requestParam.get("heads");
Assert.notEmpty(heads, "No relevant voucher header data was found. Please check the configuration table and process table data.");
Assert.notEmpty(debit, "No relevant voucher details have been queried. Please check whether there is data in the process schedule.");
Assert.notEmpty(creditSide, "No credit data was found. Please check whether the configuration table is configured correctly and whether the process data exists.");
return createFile(debit, creditSide, heads);
}
private String createFile(List<Object> debit, List<Object> creditSide, Map<String, Object> heads) {
StringBuilder sb = new StringBuilder();
// 写入凭证头
List<String> headKeys = new ArrayList<>();
for (Map.Entry<String, Object> entry : heads.entrySet()) {
headKeys.add(entry.getKey());
}
headKeys = sortKey(headKeys);
for (String headKey : headKeys) {
sb.append(heads.get(headKey)).append("\t");
}
sb.deleteCharAt(sb.lastIndexOf("\t"));
sb.append("\r\n");
// 写入借方信息
writeList(debit, sb);
// 写入贷方信息
writeList(creditSide, sb);
String filePath = getFilePath();
try {
OutputStreamWriter out = new OutputStreamWriter(
Files.newOutputStream(Paths.get(filePath)), StandardCharsets.UTF_8);
out.write(sb.toString());
out.close();
} catch (IOException e) {
throw new CustomerException(Util.logStr("can not writer file [{}]", filePath));
}
return filePath;
}
private void writeList(List<Object> list, StringBuilder sb) {
Map<String, Object> firstMap = (Map<String, Object>) list.get(0);
List<String> keys = new ArrayList<>();
for (Map.Entry<String, Object> entry : firstMap.entrySet()) {
keys.add(entry.getKey());
}
if (list.size() > 1) {
Map<String, Object> secondMap = (Map<String, Object>) list.get(1);
for (Map.Entry<String, Object> entry : secondMap.entrySet()) {
if (keys.contains(entry.getKey())) {
continue;
}
keys.add(entry.getKey());
}
}
keys = sortKey(keys);
for (Object o : list) {
Map<String, Object> map = (Map<String, Object>) o;
for (String key : keys) {
if (map.containsKey(key)) {
sb.append(map.get(key))
.append("\t");
}
}
sb.deleteCharAt(sb.lastIndexOf("\t"));
sb.append("\r\n");
}
}
private List<String> sortKey(List<String> list) {
return list.stream()
.map(Integer::parseInt)
.sorted()
.map(Util::null2String)
.collect(Collectors.toList());
}
@NotNull
private String getFilePath() {
String sysFilePath = GCONST.getSysFilePath();
String filePath;
if (sysFilePath.endsWith(File.separator)) {
filePath = sysFilePath + "cus_temp" + File.separator + "voucher-new" + File.separator +
System.currentTimeMillis() + "-voucher-new-" + UUID.randomUUID() + ".txt";
} else {
filePath = sysFilePath + File.separator + "cus_temp" + File.separator + "voucher" + File.separator +
System.currentTimeMillis() + "-voucher-new-" + 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;
}
}

View File

@ -1,10 +1,12 @@
package youhong.ai.haripijiu;
import aiyh.utils.GenerateFileUtil;
import aiyh.utils.Util;
import basetest.BaseTest;
import org.junit.Test;
import weaver.youhong.ai.haripijiu.action.sapdocking.ReceiptAndPaymentAction;
import weaver.youhong.ai.haripijiu.action.sapdocking.VoucherPayableAction;
import weaver.youhong.ai.haripijiu.action.sapdocking.VoucherPayableNewAction;
/**
* <h1></h1>
@ -24,6 +26,7 @@ public class TestHaRiPiJiu extends BaseTest {
@Test
public void test1() {
Util.actionTest(VoucherPayableNewAction.class, 405407);
}
}

View File

@ -296,4 +296,8 @@ public class UtilTest extends BaseTest {
}
@Test
public void testSS() {
out.println(Util.getTime("yyyyMMddHHmmssSSSS"));
}
}

View File

@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONArray;
import com.api.youhong.ai.taibao.fcuntionlist.service.FunctionListService;
import com.api.youhong.ai.taibao.qikan.service.PeriodicalService;
import com.cloudstore.dev.api.util.Util_DataCache;
import com.engine.youhong.ai.taibao.email.mapper.InitBlackEmailListMapper;
import org.junit.Test;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
@ -158,4 +159,14 @@ public class TestTaiBao extends BaseTest {
public void testTableModelId() {
System.out.println(Util.getModeIdByTableName("uf_privacy_log_info"));
}
@Test
public void testEmailSelect() {
InitBlackEmailListMapper mapper = Util.getMapper(InitBlackEmailListMapper.class);
List<String> hrmList = mapper.selectWorkflowBlackEmailList();
String ids = Util.join(hrmList, ",");
List<String> strings = mapper.selectEmailListByHrmIds(ids);
System.out.println(JSON.toJSONString(strings));
}
}

View File

@ -1,9 +1,11 @@
package youhong.ai.utiltest;
import aiyh.utils.GenerateFileUtil;
import aiyh.utils.Util;
import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil;
import basetest.BaseTest;
import org.junit.Test;
import weaver.youhong.ai.haripijiu.action.sapdocking.VoucherPayableNewAction;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
@ -82,4 +84,10 @@ public class GenericTest extends BaseTest {
System.out.println(aClass);
}
@Test
public void testGre() {
GenerateFileUtil.createActionDocument(VoucherPayableNewAction.class);
}
}