钉钉审批配置优化

This commit is contained in:
geht
2026-06-08 19:05:29 +08:00
parent 1d0b4c9fbb
commit fd5205e33e
44 changed files with 3730 additions and 278 deletions

View File

@@ -56,6 +56,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.web.bind.annotation.*;
//update-begin---author:GHT ---date:2026-06-08 for【XSLMES-20260608】同步钉钉ID功能-----------
import com.jeecg.dingtalk.api.core.response.Response;
import com.jeecg.dingtalk.api.user.JdtUserAPI;
import org.jeecg.modules.system.service.impl.ThirdAppDingtalkServiceImpl;
//update-end---author:GHT ---date:2026-06-08 for【XSLMES-20260608】同步钉钉ID功能-----------
import org.springframework.web.servlet.ModelAndView;
import jakarta.servlet.http.HttpServletRequest;
@@ -125,6 +130,11 @@ public class SysUserController {
@Autowired(required = false)
private SimpMessagingTemplate simpMessagingTemplate;
//update-begin---author:GHT ---date:2026-06-08 for【XSLMES-20260608】注入钉钉服务用于同步钉钉ID-----------
@Autowired(required = false)
private ThirdAppDingtalkServiceImpl thirdAppDingtalkService;
//update-end---author:GHT ---date:2026-06-08 for【XSLMES-20260608】注入钉钉服务用于同步钉钉ID-----------
private void notifyScadaUserChanged(String action, String userId) {
try {
JSONObject payload = new JSONObject();
@@ -2246,6 +2256,60 @@ public class SysUserController {
* yes_{URL编码后的默认密码} -> 用户当前密码为默认初始密码,前端需弹出强制修改提示
* no -> 用户密码不是默认密码,或未开启默认密码检测开关
*/
//update-begin---author:GHT ---date:2026-06-08 for【XSLMES-20260608】批量同步钉钉用户ID接口-----------
/**
* 批量同步钉钉ID根据用户手机号查询钉钉userId并回写到sys_user.ding_user_id。
* 匹配不到的用户只做提示,不影响其他用户继续匹配。
*/
@Operation(summary = "同步钉钉用户ID")
@PostMapping("/syncDingUserId")
public Result<JSONObject> syncDingUserId() {
if (thirdAppDingtalkService == null) {
return Result.error("钉钉集成未配置,无法同步");
}
String accessToken = thirdAppDingtalkService.getAccessTokenForBackground();
if (oConvertUtils.isEmpty(accessToken)) {
return Result.error("获取钉钉 AccessToken 失败,请检查钉钉应用配置");
}
// 查询所有有手机号的用户
List<SysUser> users = sysUserService.list(
new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<SysUser>()
.isNotNull(SysUser::getPhone)
.ne(SysUser::getPhone, "")
.eq(SysUser::getDelFlag, 0)
);
int successCount = 0;
int failCount = 0;
List<String> failDetails = new ArrayList<>();
for (SysUser user : users) {
try {
Response<String> resp = JdtUserAPI.getUseridByMobile(user.getPhone(), accessToken);
if (resp != null && resp.isSuccess() && oConvertUtils.isNotEmpty(resp.getResult())) {
sysUserService.lambdaUpdate()
.eq(SysUser::getId, user.getId())
.set(SysUser::getDingUserId, resp.getResult())
.update();
successCount++;
} else {
failCount++;
failDetails.add(user.getRealname() + "(" + user.getPhone() + ")");
log.info("[syncDingUserId] 手机号未匹配到钉钉用户 realname={} phone={}", user.getRealname(), user.getPhone());
}
} catch (Exception e) {
failCount++;
failDetails.add(user.getRealname() + "(" + user.getPhone() + ")");
log.warn("[syncDingUserId] 查询钉钉ID异常 realname={} phone={}", user.getRealname(), user.getPhone(), e);
}
}
JSONObject result = new JSONObject();
result.put("successCount", successCount);
result.put("failCount", failCount);
result.put("failDetails", failDetails);
String msg = "同步完成:成功 " + successCount + " 人,未匹配 " + failCount + "";
return Result.OK(msg, result);
}
//update-end---author:GHT ---date:2026-06-08 for【XSLMES-20260608】批量同步钉钉用户ID接口-----------
@GetMapping("/verifyIzDefaultPwd")
public Result<String> verifyIzDefaultPwd() throws UnsupportedEncodingException {
// 未配置 Firewall 或已关闭默认密码检测开关 (enableDefaultPwdCheck=false) 时,直接返回 "no" 表示无需提示

View File

@@ -272,4 +272,11 @@ public class SysUser implements Serializable {
*/
@TableField(exist = false)
private String belongDepIds;
//update-begin---author:GHT ---date:2026-06-08 for【XSLMES-20260608】新增钉钉用户ID字段支持同步钉钉ID功能-----------
/**
* 钉钉用户ID
*/
private String dingUserId;
//update-end---author:GHT ---date:2026-06-08 for【XSLMES-20260608】新增钉钉用户ID字段支持同步钉钉ID功能-----------
}