[+]增加部门推动消息功能
This commit is contained in:
@@ -13,7 +13,6 @@ import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.zt.plat.module.system.api.esp;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.module.system.api.dept.dto.DeptSaveReqDTO;
|
||||
import com.zt.plat.module.system.api.esp.dto.EspDto;
|
||||
import com.zt.plat.module.system.service.dept.IEspService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@Validated
|
||||
public class EspApiImpl implements EspApi {
|
||||
|
||||
|
||||
@Resource
|
||||
private IEspService deptService;
|
||||
@Override
|
||||
public CommonResult<List<EspDto>> pushMsg(DeptSaveReqDTO syncReqDTO)
|
||||
{
|
||||
return CommonResult.success(deptService.pushMsg(syncReqDTO));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,4 +25,7 @@ public class EspSaveRespVo extends DeptExternalCodeBaseVO {
|
||||
@Schema(description = "最后更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@Schema(description = "是否发送消息")
|
||||
private Integer isSendMsg;
|
||||
|
||||
}
|
||||
|
||||
@@ -55,4 +55,9 @@ public class DeptPushMsgDO extends TenantBaseDO {
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 是否发送消息
|
||||
*/
|
||||
private Integer isSendMsg;
|
||||
|
||||
}
|
||||
|
||||
@@ -3,10 +3,12 @@ package com.zt.plat.module.system.dal.mysql.dept;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.zt.plat.module.system.api.dept.dto.DeptSaveReqDTO;
|
||||
import com.zt.plat.module.system.controller.admin.dept.vo.depexternalcode.EspPageReqVO;
|
||||
import com.zt.plat.module.system.controller.admin.dept.vo.depexternalcode.EspSaveRespVo;
|
||||
import com.zt.plat.module.system.dal.dataobject.dept.DeptPushMsgDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import java.util.List;
|
||||
/**
|
||||
* 部门推送消息接口Mapper
|
||||
@@ -54,4 +56,10 @@ public interface EspMapper extends BaseMapperX<DeptPushMsgDO> {
|
||||
return selectList(DeptPushMsgDO::getSystemCode, systemCode);
|
||||
}
|
||||
|
||||
@Select("SELECT ID,DEPT_ID, SYSTEM_CODE,EXTERNAL_DEPT_CODE,EXTERNAL_DEPT_NAME,STATUS,REMARK,TENANT_ID,CREATOR,CREATE_TIME,UPDATER,UPDATE_TIME\n" +
|
||||
"FROM \n" +
|
||||
"\t\tSYSTEM_DEPT_PUSH_MSG\n" +
|
||||
"WHERE\n" +
|
||||
" IS_SEND_MSG = '0' AND DELETED = '0' ")
|
||||
List<DeptPushMsgDO> selectpushMsg(@Param("syncReqDTO") DeptSaveReqDTO syncReqDTO);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.zt.plat.framework.common.enums.CommonStatusEnum;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.module.system.api.dept.dto.DeptSaveReqDTO;
|
||||
import com.zt.plat.module.system.api.esp.dto.EspDto;
|
||||
import com.zt.plat.module.system.controller.admin.dept.vo.depexternalcode.EspPageReqVO;
|
||||
import com.zt.plat.module.system.controller.admin.dept.vo.depexternalcode.EspSaveRespVo;
|
||||
import com.zt.plat.module.system.dal.dataobject.dept.DeptDO;
|
||||
@@ -12,6 +14,8 @@ import com.zt.plat.module.system.dal.mysql.dept.DeptMapper;
|
||||
import com.zt.plat.module.system.dal.mysql.dept.EspMapper;
|
||||
import com.zt.plat.module.system.dal.redis.RedisKeyConstants;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.seata.common.result.Result;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
@@ -51,6 +55,7 @@ public class EspServiceImpl implements IEspService {
|
||||
if (entity.getStatus() == null) {
|
||||
entity.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
}
|
||||
entity.setIsSendMsg(0);
|
||||
espMapper.insert(entity);
|
||||
return entity.getId();
|
||||
}
|
||||
@@ -68,6 +73,7 @@ public class EspServiceImpl implements IEspService {
|
||||
if (updateObj.getStatus() == null) {
|
||||
updateObj.setStatus(exists.getStatus() == null ? CommonStatusEnum.ENABLE.getStatus() : exists.getStatus());
|
||||
}
|
||||
updateObj.setIsSendMsg(updateReqVO.getIsSendMsg());
|
||||
espMapper.updateById(updateObj);
|
||||
evictCacheSafely(exists.getDeptId());
|
||||
evictCacheSafely(updateObj.getDeptId());
|
||||
@@ -97,68 +103,11 @@ public class EspServiceImpl implements IEspService {
|
||||
return espMapper.selectListByDeptId(deptId);
|
||||
}
|
||||
|
||||
/* @Override
|
||||
public DeptExternalCodeDO getBySystemCodeAndExternalCode(String systemCode, String externalDeptCode) {
|
||||
if (StrUtil.hasEmpty(systemCode, externalDeptCode)) {
|
||||
return null;
|
||||
}
|
||||
return espMapper.selectBySystemCodeAndExternalCode(systemCode.trim(), externalDeptCode.trim());
|
||||
}*/
|
||||
@Override
|
||||
public List<EspDto> pushMsg(DeptSaveReqDTO syncReqDTO) {
|
||||
|
||||
/* @Override
|
||||
public DeptExternalCodeDO getBySystemCodeAndDeptId(String systemCode, Long deptId) {
|
||||
if (StrUtil.isBlank(systemCode) || deptId == null) {
|
||||
return null;
|
||||
}
|
||||
return espMapper.selectBySystemCodeAndDeptId(systemCode.trim(), deptId);
|
||||
}*/
|
||||
|
||||
/* @Override
|
||||
public Long getDeptPushMsgDetails(Long deptId, String systemCode, String externalDeptCode,
|
||||
String externalDeptName, Integer status) {
|
||||
|
||||
if (StrUtil.hasEmpty(systemCode, externalDeptCode) || deptId == null) {
|
||||
return null;
|
||||
}
|
||||
String normalizedSystemCode = systemCode.trim();
|
||||
String normalizedExternalCode = externalDeptCode.trim();
|
||||
String normalizedExternalName = StrUtil.blankToDefault(StrUtil.trimToNull(externalDeptName), null);
|
||||
|
||||
disableActiveMappingIfConflict(deptId, normalizedSystemCode, normalizedExternalCode);
|
||||
|
||||
// 如果存在则更新,否则创建
|
||||
DeptExternalCodeDO exists = espMapper.selectBySystemCodeAndDeptId(normalizedSystemCode, deptId);
|
||||
if (exists != null) {
|
||||
DeptExternalCodeSaveReqVO updateReqVO = new DeptExternalCodeSaveReqVO();
|
||||
updateReqVO.setId(exists.getId());
|
||||
updateReqVO.setDeptId(deptId);
|
||||
updateReqVO.setSystemCode(normalizedSystemCode);
|
||||
updateReqVO.setExternalDeptCode(normalizedExternalCode);
|
||||
updateReqVO.setExternalDeptName(normalizedExternalName);
|
||||
updateReqVO.setStatus(status == null ? exists.getStatus() : status);
|
||||
|
||||
//TODO
|
||||
//getDeptPushMsgDetails(updateReqVO);
|
||||
return exists.getId();
|
||||
}
|
||||
|
||||
DeptExternalCodeSaveReqVO createReqVO = new DeptExternalCodeSaveReqVO();
|
||||
createReqVO.setDeptId(deptId);
|
||||
createReqVO.setSystemCode(normalizedSystemCode);
|
||||
createReqVO.setExternalDeptCode(normalizedExternalCode);
|
||||
createReqVO.setExternalDeptName(normalizedExternalName);
|
||||
createReqVO.setStatus(status == null ? CommonStatusEnum.ENABLE.getStatus() : status);
|
||||
return getDeptPushMsgDetails(createReqVO);
|
||||
}*/
|
||||
|
||||
/* @Override
|
||||
public void deleteDeptExternalCodesByDeptId(Long deptId) {
|
||||
if (deptId == null) {
|
||||
return;
|
||||
}
|
||||
espMapper.deleteByDeptId(deptId);
|
||||
evictCacheSafely(deptId);
|
||||
}*/
|
||||
return BeanUtils.toBean(espMapper.selectpushMsg(syncReqDTO), EspDto.class);
|
||||
}
|
||||
|
||||
private DeptPushMsgDO validateExists(Long id) {
|
||||
if (id == null) {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.zt.plat.module.system.service.dept;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.module.system.api.dept.dto.DeptSaveReqDTO;
|
||||
import com.zt.plat.module.system.api.esp.dto.EspDto;
|
||||
import com.zt.plat.module.system.controller.admin.dept.vo.depexternalcode.EspPageReqVO;
|
||||
import com.zt.plat.module.system.controller.admin.dept.vo.depexternalcode.EspSaveRespVo;
|
||||
import com.zt.plat.module.system.dal.dataobject.dept.DeptPushMsgDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -27,7 +28,6 @@ public interface IEspService {
|
||||
|
||||
/**
|
||||
* 删除映射关系
|
||||
*
|
||||
* @param id 记录编号
|
||||
*/
|
||||
void deleteDeptPushMsg(Long id);
|
||||
@@ -47,33 +47,11 @@ public interface IEspService {
|
||||
*/
|
||||
List<DeptPushMsgDO> getPushMsgByDeptId(Long deptId);
|
||||
|
||||
/**
|
||||
* 根据部门与外部系统保存/更新映射(存在则更新,不存在则创建)
|
||||
* @param deptId 本系统部门 ID
|
||||
* @param systemCode 外部系统标识
|
||||
* @param externalDeptCode 外部系统组织编码
|
||||
* @param externalDeptName 外部系统组织名称(可选)
|
||||
* @param status 状态,默认启用
|
||||
* @return 映射记录 ID
|
||||
*/
|
||||
/* Long getDeptPushMsgDetails(Long deptId, String systemCode, String externalDeptCode, String externalDeptName,
|
||||
Integer status);*/
|
||||
|
||||
/**
|
||||
* 根据部门删除全部外部编码映射
|
||||
*
|
||||
* @param deptId 部门编号
|
||||
* 推送部门数据到外部系统
|
||||
* @param syncReqDTO 同步请求
|
||||
*/
|
||||
//void deleteDeptExternalCodesByDeptId(Long deptId);
|
||||
|
||||
/**
|
||||
* 根据外部系统与外部组织编码查询映射
|
||||
*/
|
||||
//DeptExternalCodeDO getBySystemCodeAndExternalCode(String systemCode, String externalDeptCode);
|
||||
|
||||
/**
|
||||
* 根据外部系统与部门编号查询映射
|
||||
*/
|
||||
//DeptExternalCodeDO getBySystemCodeAndDeptId(String systemCode, Long deptId);
|
||||
List<EspDto> pushMsg(DeptSaveReqDTO syncReqDTO);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user