钉钉审批配置优化
This commit is contained in:
@@ -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" 表示无需提示
|
||||
|
||||
@@ -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功能-----------
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
-- 【XSLMES-20260605-K8R4】台账增加 node_activity_map 字段
|
||||
-- 存储 processForecast 结果:JSON数组,每项含 approvalMethod/totalActioners/completionAt
|
||||
-- completionAt = 累计已处理任务数边界,用于会签/依次审批多人等待完成判断
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
ALTER TABLE `mes_xsl_approval_record`
|
||||
ADD COLUMN `node_activity_map` TEXT NULL COMMENT '钉钉节点活动映射(processForecast结果,JSON数组,含completionAt幂等边界)';
|
||||
@@ -0,0 +1,2 @@
|
||||
-- 用户表新增钉钉用户ID字段
|
||||
ALTER TABLE sys_user ADD COLUMN ding_user_id VARCHAR(100) DEFAULT NULL COMMENT '钉钉用户ID';
|
||||
@@ -0,0 +1,31 @@
|
||||
-- 【混炼示方】主表新增状态字段,复用配合示方状态字典
|
||||
-- author: cursor date: 2026-06-08 for:【XSLMES-20260608-A01】
|
||||
SET NAMES utf8mb4;
|
||||
SET @db = DATABASE();
|
||||
|
||||
SET @sql = IF(
|
||||
(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'mes_xsl_mixing_spec' AND COLUMN_NAME = 'status') = 0,
|
||||
'ALTER TABLE `mes_xsl_mixing_spec` ADD COLUMN `status` varchar(32) DEFAULT ''compile'' COMMENT ''状态(字典xslmes_formula_spec_status)'' AFTER `change_date`',
|
||||
'SELECT 1'
|
||||
);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- 按已有审批痕迹回填历史数据状态
|
||||
UPDATE `mes_xsl_mixing_spec` SET `status` = 'obsolete' WHERE `del_flag` = 1;
|
||||
UPDATE `mes_xsl_mixing_spec` SET `status` = 'recognition_pass' WHERE `del_flag` = 0 AND `approve_time` IS NOT NULL;
|
||||
UPDATE `mes_xsl_mixing_spec` SET `status` = 'review_pass' WHERE `del_flag` = 0 AND `approve_time` IS NULL AND `audit_time` IS NOT NULL;
|
||||
UPDATE `mes_xsl_mixing_spec` SET `status` = 'submit' WHERE `del_flag` = 0 AND `approve_time` IS NULL AND `audit_time` IS NULL AND `proofread_time` IS NOT NULL;
|
||||
|
||||
-- 混炼示方注册中心默认开启三环节并绑定 status 字段
|
||||
UPDATE `mes_xsl_biz_doc_registry`
|
||||
SET `enabled_stages` = 'proofread,audit,approve',
|
||||
`status_field` = 'status',
|
||||
`proofread_by_field` = 'proofread_by',
|
||||
`proofread_time_field` = 'proofread_time',
|
||||
`audit_by_field` = 'audit_by',
|
||||
`audit_time_field` = 'audit_time',
|
||||
`approve_by_field` = 'approve_by',
|
||||
`approve_time_field` = 'approve_time',
|
||||
`update_by` = 'admin',
|
||||
`update_time` = NOW()
|
||||
WHERE `doc_code` = 'mixing_spec' AND `del_flag` = 0;
|
||||
Reference in New Issue
Block a user