mk调试
This commit is contained in:
+7
@@ -60,6 +60,13 @@ public class BusinessProcessController extends BladeController {
|
||||
return R.data(businessProcessService.processSubmit(param));
|
||||
}
|
||||
|
||||
@GetMapping("/hasMkProcessInstance")
|
||||
@ApiOperationSupport(order = 8)
|
||||
@Operation(summary = "查询MK流程实例是否存在", description = "传入业务id(formInstanceId),有数据则无需删除/重新提交")
|
||||
public R<Boolean> hasMkProcessInstance(@Valid @NotBlank(message = "业务id不能为空") String bizId) {
|
||||
return R.data(businessProcessService.hasMkProcessInstance(bizId));
|
||||
}
|
||||
|
||||
@PostMapping("/processDelete")
|
||||
@ApiOperationSupport(order = 7)
|
||||
public R<Boolean> processDelete(@RequestBody MKProcessCreateDTO param) {
|
||||
|
||||
+8
@@ -34,6 +34,14 @@ public interface IBusinessProcessService extends IService<BusinessProcess> {
|
||||
*/
|
||||
String processSubmit(MKProcessCreateDTO param);
|
||||
|
||||
/**
|
||||
* 按业务 id 查询 MK 流程实例是否仍有数据(本地有 processInstanceId 且 MK getProcessInfo 有返回)
|
||||
*
|
||||
* @param bizId 业务 id(如客商 id / formInstanceId)
|
||||
* @return true=流程实例仍存在
|
||||
*/
|
||||
boolean hasMkProcessInstance(String bizId);
|
||||
|
||||
/**
|
||||
* 按业务表单实例 id 删除 MK 流程(不删除本地业务流程记录,供驳回后重新提交使用)
|
||||
*
|
||||
|
||||
+89
-16
@@ -137,6 +137,35 @@ public class BusinessProcessServiceImpl extends ServiceImpl<BusinessProcessMappe
|
||||
param.setSubmitIdentity(loginName);
|
||||
param.setLoginName(loginName);
|
||||
String bizType = param.getBizType();
|
||||
|
||||
Long bizId;
|
||||
try {
|
||||
bizId = Long.valueOf(param.getFormInstanceId());
|
||||
} catch (NumberFormatException e) {
|
||||
throw new ServiceException("表单实例id格式不正确");
|
||||
}
|
||||
BusinessProcess businessProcess = this.getOne(Wrappers.<BusinessProcess>lambdaQuery()
|
||||
.eq(BusinessProcess::getBizId, bizId)
|
||||
);
|
||||
// 已有流程实例且 MK 仍能查到详情时,不再删除、不再重新创建提交
|
||||
if (businessProcess != null && StringUtil.isNotBlank(businessProcess.getProcessInstanceId())) {
|
||||
String existingProcessInstanceId = businessProcess.getProcessInstanceId();
|
||||
Object existingProcessInfo = this.getProcessInfo(existingProcessInstanceId, loginName);
|
||||
if (hasProcessInfoData(existingProcessInfo)) {
|
||||
log.info("MK流程实例已存在,跳过创建并提交流程 formInstanceId={} processInstanceId={}",
|
||||
param.getFormInstanceId(), existingProcessInstanceId);
|
||||
businessProcess.setApproveStatus(ApproveStatusEnum.APPROVING.getValue());
|
||||
if (StringUtil.isNotBlank(param.getSubject())) {
|
||||
businessProcess.setSubject(param.getSubject());
|
||||
}
|
||||
businessProcess.setPromoterLoginName(loginName);
|
||||
this.updateById(businessProcess);
|
||||
this.getCurrentNodes(existingProcessInstanceId, loginName);
|
||||
this.syncBizFromProcessInfo(bizType, param.getFormInstanceId(), existingProcessInfo);
|
||||
return existingProcessInstanceId;
|
||||
}
|
||||
}
|
||||
|
||||
MKProcessCreateDTO mkParam = new MKProcessCreateDTO();
|
||||
mkParam.setFormInstanceId(param.getFormInstanceId());
|
||||
mkParam.setSubject(param.getSubject());
|
||||
@@ -149,15 +178,6 @@ public class BusinessProcessServiceImpl extends ServiceImpl<BusinessProcessMappe
|
||||
String processInstanceId = mkService.processSubmit(mkParam);
|
||||
AssertUtils.notBlank(processInstanceId, "提交流程失败,未返回流程实例id");
|
||||
|
||||
Long bizId;
|
||||
try {
|
||||
bizId = Long.valueOf(param.getFormInstanceId());
|
||||
} catch (NumberFormatException e) {
|
||||
throw new ServiceException("表单实例id格式不正确");
|
||||
}
|
||||
BusinessProcess businessProcess = this.getOne(Wrappers.<BusinessProcess>lambdaQuery()
|
||||
.eq(BusinessProcess::getBizId, bizId)
|
||||
);
|
||||
if (businessProcess == null) {
|
||||
businessProcess = new BusinessProcess();
|
||||
businessProcess.setBizId(bizId);
|
||||
@@ -186,6 +206,54 @@ public class BusinessProcessServiceImpl extends ServiceImpl<BusinessProcessMappe
|
||||
return processInstanceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMkProcessInstance(String bizId) {
|
||||
AssertUtils.notBlank(bizId, "业务id不能为空");
|
||||
Long id;
|
||||
try {
|
||||
id = Long.valueOf(bizId);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new ServiceException("业务id格式不正确");
|
||||
}
|
||||
BusinessProcess businessProcess = this.getOne(Wrappers.<BusinessProcess>lambdaQuery()
|
||||
.eq(BusinessProcess::getBizId, id)
|
||||
.last("limit 1")
|
||||
);
|
||||
if (businessProcess == null || StringUtil.isBlank(businessProcess.getProcessInstanceId())) {
|
||||
return false;
|
||||
}
|
||||
String loginName = businessProcess.getPromoterLoginName();
|
||||
if (StringUtil.isBlank(loginName)) {
|
||||
loginName = resolveCurrentUserPhone();
|
||||
}
|
||||
if (StringUtil.isBlank(loginName)) {
|
||||
log.warn("查询MK流程实例跳过,登录名为空 bizId={} processInstanceId={}",
|
||||
bizId, businessProcess.getProcessInstanceId());
|
||||
return false;
|
||||
}
|
||||
Object processInfo = this.getProcessInfo(businessProcess.getProcessInstanceId(), loginName);
|
||||
return hasProcessInfoData(processInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* MK getProcessInfo 是否返回有效数据
|
||||
*/
|
||||
private boolean hasProcessInfoData(Object processInfo) {
|
||||
if (processInfo == null) {
|
||||
return false;
|
||||
}
|
||||
if (processInfo instanceof Map<?, ?> map) {
|
||||
return !map.isEmpty();
|
||||
}
|
||||
if (processInfo instanceof Collection<?> collection) {
|
||||
return !collection.isEmpty();
|
||||
}
|
||||
if (processInfo instanceof CharSequence text) {
|
||||
return StringUtil.isNotBlank(text.toString());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean processDelete(String formInstanceId) {
|
||||
@@ -358,17 +426,20 @@ public class BusinessProcessServiceImpl extends ServiceImpl<BusinessProcessMappe
|
||||
}
|
||||
|
||||
/**
|
||||
* 从当前登录用户实体读取真实手机号(绕过接口返回脱敏)
|
||||
* 从当前登录用户实体读取真实手机号(库内 SM2 密文先解密,绕过接口脱敏)
|
||||
*/
|
||||
private String resolveCurrentUserPhone() {
|
||||
Long userId = AuthUtil.getUserId();
|
||||
if (userId != null) {
|
||||
User user = userService.getById(userId);
|
||||
if (user != null && StringUtil.isNotBlank(user.getPhone()) && !user.getPhone().contains("*")) {
|
||||
return user.getPhone().trim();
|
||||
}
|
||||
if (user != null && StringUtil.isNotBlank(user.getAccount()) && user.getAccount().matches("^1\\d{10}$")) {
|
||||
return user.getAccount().trim();
|
||||
if (user != null) {
|
||||
userService.decryptPhone(user);
|
||||
if (StringUtil.isNotBlank(user.getPhone()) && !user.getPhone().contains("*")) {
|
||||
return user.getPhone().trim();
|
||||
}
|
||||
if (StringUtil.isNotBlank(user.getAccount()) && user.getAccount().matches("^1\\d{10}$")) {
|
||||
return user.getAccount().trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
String account = AuthUtil.getUserAccount();
|
||||
@@ -494,7 +565,9 @@ public class BusinessProcessServiceImpl extends ServiceImpl<BusinessProcessMappe
|
||||
processInstanceId = businessProcess.getProcessInstanceId();
|
||||
}
|
||||
try {
|
||||
String mkApprovalUrl = mkService.getMKApprovalUrl(processInstanceId, AuthUtil.getUserAccount());
|
||||
String loginName = resolveCurrentUserPhone();
|
||||
AssertUtils.notBlank(loginName, "当前用户手机号为空,无法获取审核跳转地址");
|
||||
String mkApprovalUrl = mkService.getMKApprovalUrl(processInstanceId, loginName);
|
||||
AssertUtils.notBlank(mkApprovalUrl, "获取mk审批页面链接异常");
|
||||
return mkApprovalUrl;
|
||||
} catch (MKException e) {
|
||||
|
||||
+12
-12
@@ -1130,22 +1130,22 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
||||
|
||||
@Override
|
||||
public void decryptPhone(IPhone user) {
|
||||
// if (user == null) {
|
||||
// return;
|
||||
// }
|
||||
// if (user.getPhone() != null && user.getPhone().length() > 20) {
|
||||
// user.setPhone(SM2Util.decrypt(user.getPhone(), properties.getPublicKey(), properties.getPrivateKey()));
|
||||
// }
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
if (user.getPhone() != null && user.getPhone().length() > 20) {
|
||||
user.setPhone(SM2Util.decrypt(user.getPhone(), properties.getPublicKey(), properties.getPrivateKey()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encryptPhone(IPhone user) {
|
||||
// if (user == null) {
|
||||
// return;
|
||||
// }
|
||||
// if(StringUtil.isNotBlank(user.getPhone())) {
|
||||
// user.setPhone(Hex.toHexString(SM2Util.encrypt(user.getPhone(),properties.getPublicKey())));
|
||||
// }
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
if (StringUtil.isNotBlank(user.getPhone())) {
|
||||
user.setPhone(Hex.toHexString(SM2Util.encrypt(user.getPhone(), properties.getPublicKey())));
|
||||
}
|
||||
}
|
||||
|
||||
private void validatePlainPassword(String password) {
|
||||
|
||||
+5
-2
@@ -323,10 +323,13 @@ public class MKServiceImpl implements IMKService {
|
||||
return null;
|
||||
}
|
||||
String code = codeVO.getCode();
|
||||
// 跳转域名使用 thirdParty.mk.baseUrl(loginUrl 在部分环境未配置会导致拼出相对路径 null/...)
|
||||
AssertUtils.notBlank(properties.getBaseUrl(), "未配置 thirdParty.mk.baseUrl");
|
||||
String mkBaseUrl = StringUtil.removeSuffix(properties.getBaseUrl().trim(), StringPool.SLASH);
|
||||
// 审批页面地址
|
||||
String approvalUrl = String.format(APPROVAL_URL_FORMAT, properties.getLoginUrl(), processInstanceId, processInstanceId);
|
||||
String approvalUrl = String.format(APPROVAL_URL_FORMAT, mkBaseUrl, processInstanceId, processInstanceId);
|
||||
// sso回调地址
|
||||
return String.format(SSO_CALLBACK_URL_FORMAT, properties.getLoginUrl(), code, UrlUtil.encode(approvalUrl));
|
||||
return String.format(SSO_CALLBACK_URL_FORMAT, mkBaseUrl, code, UrlUtil.encode(approvalUrl));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user