一体化平台初始化仓库
This commit is contained in:
45
cdaxxt-business/pom.xml
Normal file
45
cdaxxt-business/pom.xml
Normal file
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>integration-platform-access</artifactId>
|
||||
<groupId>com.tobacco.mp</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>cdaxxt-business</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.tobacco.mp</groupId>
|
||||
<artifactId>cdaxxt-common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.tobacco.mp</groupId>
|
||||
<artifactId>cdaxxt-core</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<include>**/*.xml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,75 @@
|
||||
package com.tobacco.mp.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.tobacco.mp.dto.PlatformMessageDTO;
|
||||
import com.tobacco.mp.dto.PlatformNoticeDTO;
|
||||
import com.tobacco.mp.dto.PlatformTaskDTO;
|
||||
import com.tobacco.mp.dto.PlatformTaskHandleDTO;
|
||||
import com.tobacco.mp.service.PlatformMessageService;
|
||||
import com.tobacco.mp.service.PlatformUserService;
|
||||
import com.tobacco.mp.model.ResponseResult;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
// 一体化平台对接
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/platform")
|
||||
public class PlatformController {
|
||||
|
||||
@Resource
|
||||
PlatformUserService userService;
|
||||
|
||||
@Resource
|
||||
PlatformMessageService messageService;
|
||||
|
||||
// 查询一体化平台的用户列表
|
||||
@GetMapping(value = "/getUserList")
|
||||
public ResponseResult<Void> getUserList() {
|
||||
userService.getUserList();
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
// 查询一体化平台的用户ID
|
||||
@GetMapping(value = "/getUserIdByAccount")
|
||||
public ResponseResult<String> getUserIdByAccount(@RequestParam String loginName) {
|
||||
return ResponseResult.success(userService.getUserIdByAccount(loginName));
|
||||
}
|
||||
|
||||
// 一体化平台身份令牌认证
|
||||
@GetMapping(value = "/tokenAccess")
|
||||
public ResponseResult<JSONObject> tokenAccess(@RequestParam String token) {
|
||||
return ResponseResult.success(userService.tokenAccess(token));
|
||||
}
|
||||
|
||||
// 向一体化平台发送消息
|
||||
@PostMapping(value = "/sendMessage")
|
||||
public ResponseResult<Void> sendMessage(@RequestBody PlatformMessageDTO dataDTO) {
|
||||
messageService.sendMessage(dataDTO);
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
// 向一体化平台发送通知/公告
|
||||
@PostMapping(value = "/sendNotice")
|
||||
public ResponseResult<Void> sendNotice(@RequestBody PlatformNoticeDTO dataDTO) {
|
||||
messageService.sendNotice(dataDTO);
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
// 向一体化平台发送待办
|
||||
@PostMapping(value = "/sendToDo")
|
||||
public ResponseResult<Void> sendToDo(@RequestBody PlatformTaskDTO taskDTO) {
|
||||
messageService.sendToDo(taskDTO);
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
// 向一体化平台发送待办处置信息
|
||||
@PostMapping(value = "/sendHandleToDo")
|
||||
public ResponseResult<Void> sendHandleToDo(@RequestBody PlatformTaskHandleDTO handleDTO) {
|
||||
messageService.sendHandleToDo(handleDTO);
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package com.tobacco.mp.dto;
|
||||
|
||||
import com.tobacco.mp.model.PlatformReceiverInfo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PlatformMessageDTO {
|
||||
|
||||
// 事件编码
|
||||
private String eventCode;
|
||||
|
||||
// 消息类型,值范围: 10-系统消息 20-流程通知 30-赋能通知
|
||||
private String msgType;
|
||||
|
||||
// 消息标题
|
||||
private String msgTitle;
|
||||
|
||||
// 消息内容
|
||||
private String msgContent;
|
||||
|
||||
// 消息链接
|
||||
private String msgLink;
|
||||
|
||||
// 发送者名称
|
||||
private String senderName;
|
||||
|
||||
// 发送者ID
|
||||
private String senderId;
|
||||
|
||||
// 来源应用ID
|
||||
private String fromAppId;
|
||||
|
||||
// 来源应用名称
|
||||
private String fromAppName;
|
||||
|
||||
// 来源业务id
|
||||
private String fromBusiId;
|
||||
|
||||
// 消息重要程度:URGENT-紧急 IMPORTANT-重要 NORMAL-普通
|
||||
private String msgPriority = "NORMAL";
|
||||
|
||||
// 消息接收人列表
|
||||
private List<PlatformReceiverInfo> msgUserList;
|
||||
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package com.tobacco.mp.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class PlatformNoticeDTO {
|
||||
|
||||
// 公告标题*
|
||||
private String title;
|
||||
|
||||
// 通知公告类型*
|
||||
private String type;
|
||||
|
||||
// 公告来源* (PORTAL-门户维护,API-系统接入)
|
||||
private String source;
|
||||
|
||||
// 内容类型* (TEXT-文字内容,LINK-跳转链接)
|
||||
private String contentType;
|
||||
|
||||
// 公告内容*
|
||||
private String content;
|
||||
|
||||
// 跳转链接url*
|
||||
private String linkUrl;
|
||||
|
||||
// 发布方式* (IMMEDIATE:立即发布;SCHEDULE:定时发布)
|
||||
private String publishType;
|
||||
|
||||
// 定时发布时间*
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date scheduleTime;
|
||||
|
||||
// 有效期类型* (PERMANENT-永久有效,TEMPORARY-非永久有效)
|
||||
private String expiryType;
|
||||
|
||||
// 有效期截止时间
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private Date expiryDate;
|
||||
|
||||
// 可见范围类型* (ALL-全省可见,CITY:全市可见,DEPT-下级组织可见)
|
||||
private String visibleType;
|
||||
|
||||
// 创建人名称*
|
||||
private String creatorName;
|
||||
|
||||
// 创建人用户id*
|
||||
private String creatorId;
|
||||
|
||||
// 应用id*
|
||||
private String clientId;
|
||||
|
||||
}
|
||||
@ -0,0 +1,92 @@
|
||||
package com.tobacco.mp.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PlatformTaskDTO {
|
||||
|
||||
// 任务名称*
|
||||
private String taskName;
|
||||
|
||||
// 任务描述*
|
||||
private String taskDesc;
|
||||
|
||||
// 业务主键*
|
||||
private String businessId;
|
||||
|
||||
// 需要关联的流程实例
|
||||
private String processId;
|
||||
|
||||
// 需要关联的流程名称
|
||||
private String processName;
|
||||
|
||||
// 会签分组标记,用于记录任务所属的会签分组,也可用于其他分组(按需维护)
|
||||
private String taskCollaborateId;
|
||||
|
||||
// 需要关联的流程任务实例
|
||||
private String processTaskId;
|
||||
|
||||
// 待办类型 (字典TTC_TODO_TYPE)
|
||||
private String todoType;
|
||||
|
||||
// 业务类型
|
||||
private String bizType;
|
||||
|
||||
// 紧急程度* (1高2中3低)
|
||||
private int todoPriority = 2;
|
||||
|
||||
// 中台消息中心的模板编码,发通知消息时,未指定模板则使用该默认模板
|
||||
private String eventCode;
|
||||
|
||||
// 上级任务ID,有撤回场景时需要维护
|
||||
private String preTaskId;
|
||||
|
||||
// 创建人账号ID*
|
||||
private String createUserId;
|
||||
|
||||
// 是否开始节点
|
||||
private Boolean isStart;
|
||||
|
||||
// 是否结束节点
|
||||
private Boolean isEnd;
|
||||
|
||||
// 相关附件
|
||||
private List<String> attachmentPath;
|
||||
|
||||
// 系统需要在业务中台AppId* (用户中心完成应用系统注册,得到appId)
|
||||
private String createAppId;
|
||||
|
||||
//系统需要在业务中台AppId* (用户中心完成应用系统注册,得到appId)
|
||||
private String handleAppId;
|
||||
|
||||
// 任务处理地址*
|
||||
private String optAddress;
|
||||
|
||||
// 移动任务处理地址,模糊查询*
|
||||
private String optAddressMobile;
|
||||
|
||||
// 拓展属性配置
|
||||
private String extraConfig;
|
||||
|
||||
// 处理截止时间
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date deadline;
|
||||
|
||||
// 移交前任务ID
|
||||
private String translateOriginId;
|
||||
|
||||
// 创建时间
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date gmtCreate;
|
||||
|
||||
// 操作人ID*
|
||||
private String optUserId;
|
||||
|
||||
// 操作人名称
|
||||
private String optUserName;
|
||||
|
||||
}
|
||||
@ -0,0 +1,50 @@
|
||||
package com.tobacco.mp.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class PlatformTaskHandleDTO {
|
||||
|
||||
// 待办任务ID*
|
||||
private String todoTaskId;
|
||||
|
||||
// 实际处理人ID*
|
||||
private String handleUserId;
|
||||
|
||||
// 相关附件
|
||||
private List<String> attachmentPath;
|
||||
|
||||
// 处理结果,字典TTC_TASK_OPT_RESULT
|
||||
private String optResult;
|
||||
|
||||
// 处理意见
|
||||
private String optComment;
|
||||
|
||||
// 操作人ID*
|
||||
private String optUserId;
|
||||
|
||||
// 操作人名称
|
||||
private String optUserName;
|
||||
|
||||
// 是否发送待办通知 (false或null则根据任务自动通知配置情况发送消息)
|
||||
private Boolean sendNotification;
|
||||
|
||||
// 中台消息模板,发送通知时有效,不传值则使用任务设置的默认模板
|
||||
private String eventCode;
|
||||
|
||||
// 消息接收人
|
||||
private String receiverId;
|
||||
|
||||
// 消息额外参数,不同消息类型的个性化参数与模板的动态参数
|
||||
private Map<String, String> extraProps;
|
||||
|
||||
// 任务处理地址
|
||||
private String optAddress;
|
||||
|
||||
// 移动任务处理地址,模糊查询
|
||||
private String optAddressMobile;
|
||||
|
||||
}
|
||||
202
cdaxxt-business/src/main/java/com/tobacco/mp/entity/SysUser.java
Normal file
202
cdaxxt-business/src/main/java/com/tobacco/mp/entity/SysUser.java
Normal file
@ -0,0 +1,202 @@
|
||||
package com.tobacco.mp.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TableName(value = "sys_user")
|
||||
public class SysUser implements Serializable {
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.INPUT)
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
private String id;
|
||||
|
||||
@TableField(value = "position_type")
|
||||
@ApiModelProperty(value = "岗位类型")
|
||||
private String positionType;
|
||||
|
||||
@TableField(value = "position_id")
|
||||
@ApiModelProperty(value = "岗位ID")
|
||||
private String positionId;
|
||||
|
||||
@TableField(value = "position_name")
|
||||
@ApiModelProperty(value = "岗位名称")
|
||||
private String positionName;
|
||||
|
||||
@TableField(value = "is_virtual_user")
|
||||
@ApiModelProperty(value = "是否虚拟用户:1、是 2、不是")
|
||||
private String isVirtualUser;
|
||||
|
||||
@TableField(value = "login_name")
|
||||
@ApiModelProperty(value = "登录账号")
|
||||
private String loginName;
|
||||
|
||||
@TableField(value = "password")
|
||||
@ApiModelProperty(value = "密码")
|
||||
private String password;
|
||||
|
||||
@TableField(value = "user_name")
|
||||
@ApiModelProperty(value = "用户昵称")
|
||||
private String userName;
|
||||
|
||||
@TableField(value = "user_type")
|
||||
@ApiModelProperty(value = "用户类型(00系统用户 01注册用户)")
|
||||
private String userType;
|
||||
|
||||
@TableField(value = "email")
|
||||
@ApiModelProperty(value = "用户邮箱")
|
||||
private String email;
|
||||
|
||||
@TableField(value = "mobile", updateStrategy = FieldStrategy.IGNORED)
|
||||
@ApiModelProperty(value = "移动电话")
|
||||
private String mobile;
|
||||
|
||||
@TableField(value = "tele_phone", updateStrategy = FieldStrategy.IGNORED)
|
||||
@ApiModelProperty(value = "电话号码")
|
||||
private String telePhone;
|
||||
|
||||
@TableField(value = "id_entity_card")
|
||||
@ApiModelProperty(value = "身份证号")
|
||||
private String idEntityCard;
|
||||
|
||||
@TableField(value = "in_dust_rial_id")
|
||||
@ApiModelProperty(value = "行业号码(如:警号)")
|
||||
private String inDustRialId;
|
||||
|
||||
@TableField(value = "sex")
|
||||
@ApiModelProperty(value = "用户性别(0男 1女 2未知)")
|
||||
private String sex;
|
||||
|
||||
@TableField(value = "nation", updateStrategy = FieldStrategy.IGNORED)
|
||||
@ApiModelProperty(value = "民族")
|
||||
private String nation;
|
||||
|
||||
@TableField(value = "politic", updateStrategy = FieldStrategy.IGNORED)
|
||||
@ApiModelProperty(value = "政治面貌")
|
||||
private String politic;
|
||||
|
||||
@TableField(value = "marital")
|
||||
@ApiModelProperty(value = "婚姻状态")
|
||||
private String marital;
|
||||
|
||||
@TableField(value = "type")
|
||||
@ApiModelProperty(value = "人员类别")
|
||||
private String type;
|
||||
|
||||
@TableField(value = "type_name")
|
||||
@ApiModelProperty(value = "人员类别中文")
|
||||
private String typeName;
|
||||
|
||||
@TableField(value = "whcd", updateStrategy = FieldStrategy.IGNORED)
|
||||
@ApiModelProperty(value = "文化程度")
|
||||
private String whcd;
|
||||
|
||||
@TableField(value = "user_no", updateStrategy = FieldStrategy.IGNORED)
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer userNo;
|
||||
|
||||
@TableField(value = "bz", updateStrategy = FieldStrategy.IGNORED)
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String bz;
|
||||
|
||||
@TableField(value = "birthday")
|
||||
@ApiModelProperty(value = "出生日期")
|
||||
private String birthday;
|
||||
|
||||
@TableField(value = "begin_time")
|
||||
@ApiModelProperty(value = " 用户有效开始时间,默认为当前日期(用户可改)")
|
||||
private Date beginTime;
|
||||
|
||||
@TableField(value = "end_time")
|
||||
@ApiModelProperty(value = " 用户有效结束时间,默认空")
|
||||
private Date endTime;
|
||||
|
||||
@TableField(value = "salt")
|
||||
@ApiModelProperty(value = "盐加密")
|
||||
private String salt;
|
||||
|
||||
@TableField("duty_code")
|
||||
@ApiModelProperty("职务code")
|
||||
private String dutyCode;
|
||||
|
||||
@TableField("duty_name")
|
||||
@ApiModelProperty("职务名称")
|
||||
private String dutyName;
|
||||
|
||||
@TableField("outsourcing_level")
|
||||
@ApiModelProperty("D_BZ_ZYWHRYLB-聘用人员类别 1.在岗在册 2.劳务派遣 3.业务外包")
|
||||
private String outsourcingLevel;
|
||||
|
||||
@TableField("long_term_sick_leave")
|
||||
@ApiModelProperty(" 是否长期病假人员")
|
||||
private String longTermSickLeave;
|
||||
|
||||
@TableField("platform_user_id")
|
||||
@ApiModelProperty(" 业务中台用户ID")
|
||||
private String platformUserId;
|
||||
|
||||
@TableField(value = "xzcs")
|
||||
@ApiModelProperty(value = "选择次数")
|
||||
private Integer xzcs;
|
||||
|
||||
@TableField(value = "xt_zxbz")
|
||||
private Integer xtZxbz;
|
||||
|
||||
@TableField(value = "xt_zxyz")
|
||||
private String xtZxyz;
|
||||
|
||||
@TableField(value = "xt_cjsj")
|
||||
private Date xtCjsj;
|
||||
|
||||
@TableField(value = "xt_lrsj")
|
||||
private Date xtLrsj;
|
||||
|
||||
@TableField(value = "xt_lrrxm")
|
||||
private String xtLrrxm;
|
||||
|
||||
@TableField(value = "xt_lrrid")
|
||||
private String xtLrrid;
|
||||
|
||||
@TableField(value = "xt_lrrbm")
|
||||
private String xtLrrbm;
|
||||
|
||||
@TableField(value = "xt_lrrbmid")
|
||||
private String xtLrrbmid;
|
||||
|
||||
@TableField(value = "xt_lrip")
|
||||
private String xtLrip;
|
||||
|
||||
@TableField(value = "xt_zhxgsj")
|
||||
private Date xtZhxgsj;
|
||||
|
||||
@TableField(value = "xt_zhxgrxm")
|
||||
private String xtZhxgrxm;
|
||||
|
||||
@TableField(value = "xt_zhxgid")
|
||||
private String xtZhxgid;
|
||||
|
||||
@TableField(value = "xt_zhxgrbm")
|
||||
private String xtZhxgrbm;
|
||||
|
||||
@TableField(value = "xt_zhxgrbmid")
|
||||
private String xtZhxgrbmid;
|
||||
|
||||
@TableField(value = "xt_zhxgrip")
|
||||
private String xtZhxgrip;
|
||||
|
||||
@TableField(value = "xt_city_code")
|
||||
private String xtCityCode;
|
||||
|
||||
@TableField(value = "xt_city_name")
|
||||
private String xtCityName;
|
||||
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package com.tobacco.mp.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.tobacco.mp.entity.SysUser;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||
|
||||
// 获取业务中台用户ID为空的用户账号列表
|
||||
List<String> getNullPlatformUserId();
|
||||
|
||||
// 给用户绑定业务中台的用户ID
|
||||
void setPlatformUserId(@Param("userName") String userName, @Param("platformUserId") String platformUserId);
|
||||
|
||||
// 更新任务的一体化平台ID
|
||||
void updateRwPlatformId(@Param("rwId") String rwId, @Param("platformId") String platformId);
|
||||
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.tobacco.mp.mapper.SysUserMapper">
|
||||
|
||||
<!--获取业务中台用户ID为空的用户账号列表-->
|
||||
<select id="getNullPlatformUserId" resultType="java.lang.String">
|
||||
SELECT user_name FROM mosty_base_gs.sys_user WHERE xt_zxbz = 0 AND platform_user_id IS NULL
|
||||
</select>
|
||||
|
||||
<!--给用户绑定业务中台的用户ID-->
|
||||
<update id="setPlatformUserId">
|
||||
UPDATE mosty_base_gs.sys_user SET platform_user_id = #{platformUserId} WHERE user_name = #{userName}
|
||||
</update>
|
||||
|
||||
<!--给用户绑定业务中台的用户ID-->
|
||||
<update id="updateRwPlatformId">
|
||||
UPDATE mosty_jcgl_gs.tb_rw SET platform_id = #{platformId} WHERE id = #{rwId}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@ -0,0 +1,14 @@
|
||||
package com.tobacco.mp.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PlatformReceiverInfo {
|
||||
|
||||
// 接收者名称
|
||||
private String receiverName;
|
||||
|
||||
// 接收者ID
|
||||
private String receiverId;
|
||||
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package com.tobacco.mp.model;
|
||||
|
||||
/**
|
||||
* 一体化平台响应状态码
|
||||
*/
|
||||
public class PlatformResponseCode {
|
||||
|
||||
// 成功
|
||||
public static final String SUCCESS = "200";
|
||||
|
||||
// 未授权
|
||||
public static final String UNAUTHORIZED = "401";
|
||||
|
||||
// 禁止访问
|
||||
public static final String ACCESS_DENIED = "403";
|
||||
|
||||
// 资源不存在
|
||||
public static final String NOT_EXIST = "404";
|
||||
|
||||
// 服务异常
|
||||
public static final String SERVICE_EXCEPTION = "500";
|
||||
|
||||
}
|
||||
@ -0,0 +1,136 @@
|
||||
package com.tobacco.mp.service;
|
||||
|
||||
import com.alibaba.bizworks.core.runtime.common.SingleResponse;
|
||||
import com.tobacco.mp.dto.PlatformMessageDTO;
|
||||
import com.tobacco.mp.dto.PlatformNoticeDTO;
|
||||
import com.tobacco.mp.dto.PlatformTaskDTO;
|
||||
import com.tobacco.mp.dto.PlatformTaskHandleDTO;
|
||||
import com.tobacco.mp.mcext.client.api.McExtNoticeServiceAPI;
|
||||
import com.tobacco.mp.mcext.client.api.MessageSendExtServiceAPI;
|
||||
import com.tobacco.mp.mcext.client.api.message.dto.SendMessageDTO;
|
||||
import com.tobacco.mp.mcext.client.api.message.req.SendInternalMessageRequest;
|
||||
import com.tobacco.mp.mcext.client.api.notice.dto.CreateNoticeResponse;
|
||||
import com.tobacco.mp.mcext.client.api.notice.req.CreateNoticeRequest;
|
||||
import com.tobacco.mp.model.PlatformResponseCode;
|
||||
import com.tobacco.mp.ttc.client.api.TodoTaskApi;
|
||||
import com.tobacco.mp.ttc.client.api.enums.TaskHandleTargetTypeEnum;
|
||||
import com.tobacco.mp.ttc.client.api.task.dto.TodoTaskDTO;
|
||||
import com.tobacco.mp.ttc.client.api.task.req.CreateTaskRequest;
|
||||
import com.tobacco.mp.ttc.client.api.task.req.SubmitTaskRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class PlatformMessageService {
|
||||
|
||||
@Resource
|
||||
private MessageSendExtServiceAPI messageSendExtServiceAPI;
|
||||
|
||||
@Resource
|
||||
private McExtNoticeServiceAPI mcExtNoticeServiceAPI;
|
||||
|
||||
@Resource
|
||||
private TodoTaskApi todoTaskApi;
|
||||
|
||||
@Resource
|
||||
private SysUserService sysUserService;
|
||||
|
||||
@Value("${bizworks.clientId}")
|
||||
private String clientId;
|
||||
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
* @param messageDTO
|
||||
*/
|
||||
public void sendMessage(PlatformMessageDTO messageDTO) {
|
||||
// 构建消息请求参数
|
||||
SendInternalMessageRequest request = new SendInternalMessageRequest();
|
||||
BeanUtils.copyProperties(messageDTO, request, "msgUserList");
|
||||
request.setFromAppId(clientId);
|
||||
request.setFromAppName("安管平台应用");
|
||||
List<SendInternalMessageRequest.ReceiverInfo> msgUserList = new ArrayList<>();
|
||||
BeanUtils.copyProperties(messageDTO.getMsgUserList(), msgUserList);
|
||||
request.setMsgUserList(msgUserList);
|
||||
// 发送消息请求
|
||||
SingleResponse<SendMessageDTO> response = messageSendExtServiceAPI.sendInternalMessage(request);
|
||||
if (response.getCode().equals(PlatformResponseCode.SUCCESS)) {
|
||||
log.info("消息【{}】请求处理成功", messageDTO.getMsgTitle());
|
||||
} else {
|
||||
log.error("消息【{}】请求处理失败。失败原因:{}", messageDTO.getMsgTitle(), response.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送通知/公告
|
||||
* @param noticeDTO
|
||||
*/
|
||||
public void sendNotice(PlatformNoticeDTO noticeDTO) {
|
||||
// 构建通知/公告请求参数
|
||||
CreateNoticeRequest request = new CreateNoticeRequest();
|
||||
BeanUtils.copyProperties(noticeDTO, request);
|
||||
request.setSource("API");
|
||||
request.setClientId(clientId);
|
||||
// 发送通知/公告请求
|
||||
SingleResponse<CreateNoticeResponse> response = mcExtNoticeServiceAPI.createNotice(request);
|
||||
if (response.getCode().equals(PlatformResponseCode.SUCCESS)) {
|
||||
log.info("通知【{}】请求处理成功", noticeDTO.getTitle());
|
||||
} else {
|
||||
log.error("通知【{}】请求处理失败。失败原因:{}", noticeDTO.getTitle(), response.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建待办任务
|
||||
* @param taskDTO
|
||||
*/
|
||||
public void sendToDo(PlatformTaskDTO taskDTO) {
|
||||
// 构建待办任务请求参数
|
||||
CreateTaskRequest request = new CreateTaskRequest();
|
||||
BeanUtils.copyProperties(taskDTO, request);
|
||||
request.setHandleTargetId(taskDTO.getOptUserId());
|
||||
request.setHandleTargetType(TaskHandleTargetTypeEnum.USER);
|
||||
request.setCreateAppId(clientId);
|
||||
request.setHandleAppId(clientId);
|
||||
// 发送待办任务请求
|
||||
SingleResponse<TodoTaskDTO> response = todoTaskApi.createTask(request);
|
||||
if (response.getCode().equals(PlatformResponseCode.SUCCESS)) {
|
||||
TodoTaskDTO todoTaskDTO = response.getData();
|
||||
if (todoTaskDTO != null && StringUtils.isNotEmpty(todoTaskDTO.getId())) {
|
||||
sysUserService.updateRwPlatformId(taskDTO.getBusinessId(), todoTaskDTO.getId());
|
||||
}
|
||||
log.info("待办【{}】请求处理成功", taskDTO.getTaskName());
|
||||
} else {
|
||||
log.error("待办【{}】请求处理失败。失败原因:{}", taskDTO.getTaskName(), response.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处置待办
|
||||
* @param handleDTO
|
||||
*/
|
||||
public void sendHandleToDo(PlatformTaskHandleDTO handleDTO) {
|
||||
// 处置待办参数校验
|
||||
if (StringUtils.isEmpty(handleDTO.getTodoTaskId())) {
|
||||
return;
|
||||
}
|
||||
// 构建处置待办请求参数
|
||||
SubmitTaskRequest request = new SubmitTaskRequest();
|
||||
BeanUtils.copyProperties(handleDTO, request);
|
||||
// 发送处置待办请求
|
||||
SingleResponse<Boolean> response = todoTaskApi.submitTask(request);
|
||||
if (response.getCode().equals(PlatformResponseCode.SUCCESS)) {
|
||||
log.info("待办处理【{}】请求处理成功", handleDTO.getTodoTaskId());
|
||||
} else {
|
||||
log.error("待办处理【{}】请求处理失败。失败原因:{}", handleDTO.getTodoTaskId(), response.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,127 @@
|
||||
package com.tobacco.mp.service;
|
||||
|
||||
import com.alibaba.bizworks.core.runtime.common.MultiDataDTO;
|
||||
import com.alibaba.bizworks.core.runtime.common.MultiResponse;
|
||||
import com.alibaba.bizworks.core.runtime.common.SingleResponse;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.tobacco.mp.auth.businessdomain.auth.client.api.SsoAuthI;
|
||||
import com.tobacco.mp.auth.businessdomain.auth.client.api.auth.dto.TokenCheckResultDTO;
|
||||
import com.tobacco.mp.auth.businessdomain.auth.client.api.auth.req.CheckTokenRequest;
|
||||
import com.tobacco.mp.constant.Constant;
|
||||
import com.tobacco.mp.model.PlatformResponseCode;
|
||||
import com.tobacco.mp.uc.client.api.UserServiceAPI;
|
||||
import com.tobacco.mp.uc.client.api.user.dto.GetUserByUserCodeDTO;
|
||||
import com.tobacco.mp.uc.client.api.user.dto.UserDTO;
|
||||
import com.tobacco.mp.uc.client.api.user.req.GetUserByUserCodeRequest;
|
||||
import com.tobacco.mp.uc.client.api.user.req.PageQueryUserRequest;
|
||||
import com.tobacco.mp.utils.JWTUtil;
|
||||
import com.tobacco.mp.utils.RandomUtil;
|
||||
import com.tobacco.mp.utils.RedisUtils;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class PlatformUserService {
|
||||
|
||||
@Resource
|
||||
private UserServiceAPI userServiceAPI;
|
||||
|
||||
@Resource
|
||||
private SsoAuthI ssoAuthI;
|
||||
|
||||
@Resource
|
||||
private RedisUtils redisUtils;
|
||||
|
||||
@Value("${bizworks.clientId}")
|
||||
private String clientId;
|
||||
|
||||
/**
|
||||
* 查询一体化平台的用户ID
|
||||
* @param loginName
|
||||
* @return
|
||||
*/
|
||||
public String getUserIdByAccount(String loginName) {
|
||||
// 构建查询平台用户请求参数
|
||||
GetUserByUserCodeRequest request = new GetUserByUserCodeRequest();
|
||||
request.setUserCode(loginName);
|
||||
// 发送查询平台用户请求
|
||||
SingleResponse<GetUserByUserCodeDTO> response = userServiceAPI.getUserByUserCode(request);
|
||||
if (response.getCode().equals(PlatformResponseCode.SUCCESS)) {
|
||||
GetUserByUserCodeDTO userDTO = response.getData();
|
||||
if (userDTO != null && StringUtils.isNotEmpty(userDTO.getUserId())) {
|
||||
return userDTO.getUserId();
|
||||
}
|
||||
} else {
|
||||
log.error("获取中台用户[{}]请求处理失败。失败原因:{}", loginName, response.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询一体化平台的用户列表
|
||||
*/
|
||||
public void getUserList() {
|
||||
// 构建查询平台用户列表请求参数
|
||||
PageQueryUserRequest request = new PageQueryUserRequest();
|
||||
request.setPageNumber(1);
|
||||
request.setPageSize(10);
|
||||
request.setManageUnitId("12");
|
||||
// 发送查询平台用户列表请求
|
||||
MultiResponse<UserDTO> response = userServiceAPI.pageQueryUser(request);
|
||||
if (response.getCode().equals(PlatformResponseCode.SUCCESS)) {
|
||||
MultiDataDTO<UserDTO> userDTO = response.getData();
|
||||
if (userDTO != null && !CollectionUtils.isEmpty(userDTO.getItems())) {
|
||||
for (UserDTO user : userDTO.getItems()) {
|
||||
System.out.println("userId:" + user.getUserId() + ", userName:" + user.getLoginName());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.error("分页获取中台用户请求处理失败。失败原因:{}", response.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验本系统登录页面的token(一体化平台的token)信息
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
public JSONObject tokenAccess(String token) {
|
||||
// 声明响应数据(用户名和系统登录校验码)
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
String account = "";
|
||||
|
||||
// 给一体化平台发送解析请求以验证令牌获取用户名
|
||||
SingleResponse<TokenCheckResultDTO> singleResponse = ssoAuthI.checkToken(new CheckTokenRequest(token, clientId));
|
||||
if (singleResponse.getCode().equals(PlatformResponseCode.SUCCESS)) {
|
||||
TokenCheckResultDTO data = singleResponse.getData();
|
||||
if (data != null && StringUtils.isNotEmpty(data.getUserInfo())) {
|
||||
Claims claims = JWTUtil.verifyJWTToken(data.getUserInfo(), JWTUtil.PUBLIC_KEY_STR);
|
||||
account = claims.get("account", String.class);
|
||||
} else {
|
||||
log.error("请求一体化平台响应数据:{}", JSONObject.toJSONString(data));
|
||||
return jsonObject;
|
||||
}
|
||||
} else {
|
||||
log.error("鉴权请求处理失败。失败原因:{}", singleResponse.getMessage());
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
// 验证通过后,给页面返回用户名和本系统登录校验码
|
||||
if (StringUtils.isNotEmpty(account)) {
|
||||
String verifyCode = RandomUtil.generateLowerString(16);
|
||||
redisUtils.set(Constant.LOGIN_VERIFY_CODE + account, verifyCode, 30);
|
||||
jsonObject.put("userName", account);
|
||||
jsonObject.put("verifyCode", verifyCode);
|
||||
log.info("--------一体化平台成功鉴权!----------");
|
||||
}
|
||||
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package com.tobacco.mp.service;
|
||||
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class SchedulerService {
|
||||
|
||||
@Resource
|
||||
SysUserService sysUserService;
|
||||
|
||||
@Resource
|
||||
PlatformUserService platformUserService;
|
||||
|
||||
/**
|
||||
* 刷新用户业务中台的ID
|
||||
*/
|
||||
// @Scheduled(cron = "0 0 3 * * ?")
|
||||
public void refreshUserPlatformId() {
|
||||
List<String> userNames = sysUserService.getNullPlatformUserId();
|
||||
for (String userName : userNames) {
|
||||
String platformUserId = platformUserService.getUserIdByAccount(userName);
|
||||
sysUserService.setPlatformUserId(userName, platformUserId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
package com.tobacco.mp.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.tobacco.mp.entity.SysUser;
|
||||
import com.tobacco.mp.mapper.SysUserMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class SysUserService extends ServiceImpl<SysUserMapper, SysUser> {
|
||||
|
||||
/**
|
||||
* 获取业务中台用户ID为空的用户账号列表
|
||||
* @return
|
||||
*/
|
||||
public List<String> getNullPlatformUserId() {
|
||||
return this.baseMapper.getNullPlatformUserId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 给用户绑定业务中台的用户ID
|
||||
* @param userName
|
||||
* @param platformUserId
|
||||
*/
|
||||
public void setPlatformUserId(String userName, String platformUserId) {
|
||||
this.baseMapper.setPlatformUserId(userName, platformUserId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新任务的一体化平台ID
|
||||
* @param rwId
|
||||
* @param platformId
|
||||
*/
|
||||
public void updateRwPlatformId(String rwId, String platformId) {
|
||||
this.baseMapper.updateRwPlatformId(rwId, platformId);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user