Commit 7035b74b authored by fangxinjiang's avatar fangxinjiang

Merge remote-tracking branch 'origin/MVP1.5.8' into MVP1.5.8

parents 7cd1f92f 0b10bd69
......@@ -93,4 +93,10 @@ public class SysUserPermission extends BaseEntity {
*/
@Schema(description = "部门id")
private String domainId;
/**
* 0:从EKP同步的;1:MVP新增的。
*/
@Schema(description = "来源")
private String sourceType;
}
package com.yifu.cloud.plus.v1.yifu.permission.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
/**
* @Author hgw
* @Date 2023-9-21 17:03:57
* @Description
* @Version 1.0
*/
@Data
public class IdTypeEkpVo implements Serializable {
/**
* 主键
*/
@Schema(description = "主键")
private String fdId;
/**
* 类型
*/
@Schema(description = "类型")
private String type;
}
package com.yifu.cloud.plus.v1.permission.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.permission.service.SysUserPermissionService;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.permission.entity.SysUserPermission;
import com.yifu.cloud.plus.v1.yifu.permission.vo.IdTypeEkpVo;
import com.yifu.cloud.plus.v1.yifu.permission.vo.SysDictVo;
import com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserDeptVo;
import com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserPermissionSearchVo;
......@@ -19,6 +22,8 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.List;
/**
......@@ -157,4 +162,26 @@ public class SysUserPermissionController {
public R<List<SysDictVo>> selectDictByType(@RequestParam String type) {
return new R<>(sysUserPermissionService.selectDictByType(type));
}
/**
* 修改项目表--EKP调用接口
* @author hyc
* @param jsonStr 项目表
* @return R
*/
@Operation(summary = "自动同步权限--EKP调用接口", description = "自动同步权限--EKP调用接口")
@SysLog("自动同步权限--EKP调用接口")
@PostMapping("/autoCreateAuth")
public R<String> autoCreateAuth(@RequestBody String jsonStr) {
try {
jsonStr = URLDecoder.decode(jsonStr, CommonConstants.UTF8).replace("=", "");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
List<IdTypeEkpVo> list= JSONObject.parseArray(jsonStr, IdTypeEkpVo.class);
if (list != null && !list.isEmpty()) {
return sysUserPermissionService.autoCreateAuth(list.get(0));
}
return R.failed("自动同步权限错误-无参数");
}
}
......@@ -190,5 +190,16 @@ public interface SysUserPermissionMapper extends BaseMapper<SysUserPermission> {
**/
List<SysUserPermission> getUserPermissionByUserId(@Param("userId") String userId);
List<SysUserPermission> getUserPermissionByAutoCreateKH(@Param("fdId") String fdId);
List<SysUserPermission> getUserPermissionByAutoCreateSJ(@Param("fdId") String fdId);
List<SysUserPermission> getUserPermissionByAutoCreateBJD(@Param("fdId") String fdId);
List<SysUserPermission> getUserPermissionByAutoCreateHT(@Param("fdId") String fdId);
List<SysUserPermission> getUserPermissionByAutoCreateXM(@Param("fdId") String fdId);
List<SysUserPermission> getUserPermissionByAutoCreateHTBG(@Param("fdId") String fdId);
List<SysUserPermission> getUserPermissionByAutoCreateXMBG(@Param("fdId") String fdId);
String selectCodeByFdId(@Param("fdId") String fdId);
void deleteUserPermissionByIdAndType(@Param("code") String code, @Param("permissionType") String permissionType);
}
......@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.permission.entity.SysUserPermission;
import com.yifu.cloud.plus.v1.yifu.permission.vo.IdTypeEkpVo;
import com.yifu.cloud.plus.v1.yifu.permission.vo.SysDictVo;
import com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserDeptVo;
import com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserPermissionSearchVo;
......@@ -46,4 +47,6 @@ public interface SysUserPermissionService extends IService<SysUserPermission> {
IPage<SysUserDeptVo> getNameCodePage(Page<SysUserDeptVo> page, SysUserDeptVo searchVo);
List<SysDictVo> selectDictByType(String type);
R<String> autoCreateAuth(IdTypeEkpVo vo);
}
......@@ -424,4 +424,66 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM
return baseMapper.selectSettleCount(name);
}
}
@Override
public R<String> autoCreateAuth(IdTypeEkpVo vo) {
String fdId = vo.getFdId();
String type = vo.getType();
// 先找到表(客户、项目、项目立项等),找到创建人、服务团队;
// 组装实体类,查重,新增或更新
List<SysUserPermission> list;
// 1客户;2商机;3报价单;4合同;5项目;
log.error("11111同步权限,EKP传过来的fdId=" + fdId + ",type="+ type);
String deleteType = CommonConstants.ONE_STRING;
switch (type) {
case "客户":
deleteType = CommonConstants.dingleDigitStrArray[1];
list = baseMapper.getUserPermissionByAutoCreateKH(fdId); break;
case "商机":
deleteType = CommonConstants.dingleDigitStrArray[2];
list = baseMapper.getUserPermissionByAutoCreateSJ(fdId); break;
case "报价单":
deleteType = CommonConstants.dingleDigitStrArray[3];
list = baseMapper.getUserPermissionByAutoCreateBJD(fdId); break;
case "合同":
deleteType = CommonConstants.dingleDigitStrArray[4];
list = baseMapper.getUserPermissionByAutoCreateHT(fdId); break;
case "合同变更":
deleteType = CommonConstants.dingleDigitStrArray[4];
list = baseMapper.getUserPermissionByAutoCreateHTBG(fdId); break;
case "项目":
deleteType = CommonConstants.dingleDigitStrArray[5];
list = baseMapper.getUserPermissionByAutoCreateXM(fdId); break;
case "项目变更":
deleteType = CommonConstants.dingleDigitStrArray[5];
list = baseMapper.getUserPermissionByAutoCreateXMBG(fdId); break;
default:
list = new ArrayList<>();
}
if (list != null && !list.isEmpty()) {
if (Common.isNotNull(list.get(0).getCode())) {
baseMapper.deleteUserPermissionByIdAndType(list.get(0).getCode(), deleteType);
}
for (SysUserPermission sysUserPermission : list) {
SysUserPermission permission = this.getOne(Wrappers.<SysUserPermission>query().lambda()
.eq(SysUserPermission::getDeleteFlag, CommonConstants.ONE_STRING)
.eq(SysUserPermission::getEmpLoginName, sysUserPermission.getEmpLoginName())
.eq(SysUserPermission::getPermissionType, sysUserPermission.getPermissionType())
.eq(SysUserPermission::getCode, sysUserPermission.getCode()).last(CommonConstants.LAST_ONE_SQL));
if (permission == null || Common.isEmpty(permission) || Common.isEmpty(permission.getId())) {
this.save(sysUserPermission);
}
}
} else {
String code = baseMapper.selectCodeByFdId(fdId);
if (Common.isNotNull(code)) {
baseMapper.deleteUserPermissionByIdAndType(code, deleteType);
}
}
return R.ok();
}
}
......@@ -19,6 +19,7 @@
<result property="createName" column="CREATE_NAME"/>
<result property="createTime" column="CREATE_TIME"/>
<result property="updateTime" column="UPDATE_TIME"/>
<result property="sourceType" column="SOURCE_TYPE"/>
</resultMap>
<resultMap id="sysUserPermissionExportMap" type="com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserPermissionExportVo">
......@@ -291,4 +292,159 @@
ORDER BY p.PERMISSION_TYPE
</select>
<!-- 查找权限,用来新建 - 客户 -->
<select id="getUserPermissionByAutoCreateKH" resultMap="sysUserPermissionMap">
select
e.fd_name EMP_NAME ,p.fd_login_name EMP_LOGIN_NAME ,SUBSTRING_INDEX(SUBSTRING_INDEX(e.fd_ldap_dn,',ou', 2),',ou=', -1) EMP_DEPT
,'1' PERMISSION_TYPE ,d.fd_3a9d1d4caeeeb8 NAME ,d.fd_3a9d1d4d438bfc CODE,0 SOURCE_TYPE
,'0' IS_CONTAINS ,'0' PERMISSION_STATUS ,'1' DELETE_FLAG ,e.fd_id USER_ID ,d.fd_id DOMAIN_ID
from ekp_fa3e25a1b6c472683e96 d
LEFT JOIN ekp_c472683e96_8b4d79b2c8 f on f.fd_parent_id = d.fd_id
LEFT JOIN sys_org_element e on e.fd_id = f.fd_3b118b5e5d1024
JOIN sys_org_person p on e.fd_id=p.fd_id
where d.fd_id = #{fdId} GROUP BY e.fd_id
</select>
<!-- 查找权限,用来新建 - 商机 -->
<select id="getUserPermissionByAutoCreateSJ" resultMap="sysUserPermissionMap">
select
e.fd_name EMP_NAME,p.fd_login_name EMP_LOGIN_NAME,SUBSTRING_INDEX(SUBSTRING_INDEX(e.fd_ldap_dn,',ou', 2),',ou=', -1) EMP_DEPT
,'2' PERMISSION_TYPE,d.fd_3b04b95268f19c NAME,d.fd_3b107f1084fd96 CODE,0 SOURCE_TYPE
,'0' IS_CONTAINS,'0' PERMISSION_STATUS,'1' DELETE_FLAG,e.fd_id USER_ID,d.fd_id DOMAIN_ID
from ekp_24385b8cc934eb8a9231 d
LEFT JOIN ekp_34eb8a9231_8c4fb81d42 f on f.fd_parent_id = d.fd_id
LEFT JOIN sys_org_element e on e.fd_id = f.fd_3b0e8c7f169ed2
JOIN sys_org_person p on e.fd_id=p.fd_id
where d.fd_id = #{fdId} GROUP BY e.fd_id
</select>
<!-- 查找权限,用来新建 - 报价单 -->
<select id="getUserPermissionByAutoCreateBJD" resultMap="sysUserPermissionMap">
select
e.fd_name EMP_NAME,p.fd_login_name EMP_LOGIN_NAME,SUBSTRING_INDEX(SUBSTRING_INDEX(e.fd_ldap_dn,',ou', 2),',ou=', -1) EMP_DEPT
,'3' PERMISSION_TYPE,d.fd_3b04b9d8688cfa NAME,d.fd_3b04b9dc64a9f4 CODE,0 SOURCE_TYPE
,'0' IS_CONTAINS,'0' PERMISSION_STATUS,'1' DELETE_FLAG,e.fd_id USER_ID,d.fd_id DOMAIN_ID
from ekp_fd06fd1251d4bac8cc91 d
LEFT JOIN ekp_d4bac8cc91_8aad2804b4 f1 on f1.fd_parent_id = d.fd_id
LEFT JOIN ekporg_18308def06b6c534b70e f on f.fd_parent_id = f1.fd_id
LEFT JOIN sys_org_element e on e.fd_id = f.sys_org_person_id JOIN sys_org_person p on e.fd_id=p.fd_id
where d.fd_id = #{fdId} GROUP BY e.fd_id
</select>
<!-- 查找权限,用来新建 - 合同 -->
<select id="getUserPermissionByAutoCreateHT" resultMap="sysUserPermissionMap">
select a.EMP_NAME,a.EMP_LOGIN_NAME,a.EMP_DEPT,a.PERMISSION_TYPE,a.NAME,a.CODE,a.SOURCE_TYPE,a.IS_CONTAINS,a.PERMISSION_STATUS,a.DELETE_FLAG,a.USER_ID,a.DOMAIN_ID
from (
select
e.fd_name EMP_NAME,p.fd_login_name EMP_LOGIN_NAME,SUBSTRING_INDEX(SUBSTRING_INDEX(e.fd_ldap_dn,',ou', 2),',ou=', -1) EMP_DEPT
,'4' PERMISSION_TYPE,d.fd_3ad97ed761c75c NAME,d.fd_3ade319226ed52 CODE,0 SOURCE_TYPE
,'0' IS_CONTAINS,'0' PERMISSION_STATUS,'1' DELETE_FLAG,e.fd_id USER_ID,d.fd_id DOMAIN_ID
from ekp_4834ce2ea964f1a8cfdb d
LEFT JOIN ekporg_183823dc7ae199aa37e9 f on f.fd_parent_id = d.fd_id
LEFT JOIN sys_org_element e on e.fd_id = f.sys_org_person_id JOIN sys_org_person p on e.fd_id=p.fd_id
where d.fd_id = #{fdId}
union ALL
select
e.fd_name EMP_NAME,p.fd_login_name EMP_LOGIN_NAME,SUBSTRING_INDEX(SUBSTRING_INDEX(e.fd_ldap_dn,',ou', 2),',ou=', -1) EMP_DEPT
,'4' PERMISSION_TYPE,d.fd_3ad97ed761c75c NAME,d.fd_3ade319226ed52 CODE,0 SOURCE_TYPE
,'0' IS_CONTAINS,'0' PERMISSION_STATUS,'1' DELETE_FLAG,e.fd_id USER_ID,d.fd_id DOMAIN_ID
from ekp_4834ce2ea964f1a8cfdb d
LEFT JOIN sys_org_element e on e.fd_id = d.fd_3ade318b64b54c
JOIN sys_org_person p on e.fd_id=p.fd_id
where d.fd_id = #{fdId}
) a GROUP BY a.USER_ID
</select>
<!-- 查找权限,用来新建 - 项目 -->
<select id="getUserPermissionByAutoCreateXM" resultMap="sysUserPermissionMap">
select a.EMP_NAME,a.EMP_LOGIN_NAME,a.EMP_DEPT,a.PERMISSION_TYPE,a.NAME,a.CODE,a.SOURCE_TYPE,a.IS_CONTAINS,a.PERMISSION_STATUS,a.DELETE_FLAG,a.USER_ID,a.DOMAIN_ID
from (
select
e.fd_name EMP_NAME,p.fd_login_name EMP_LOGIN_NAME,SUBSTRING_INDEX(SUBSTRING_INDEX(e.fd_ldap_dn,',ou', 2),',ou=', -1) EMP_DEPT
,'5' PERMISSION_TYPE,d.fd_3a829ae9bab760 NAME,d.fd_3a829aea0b84a4 CODE,0 SOURCE_TYPE
,'0' IS_CONTAINS,'0' PERMISSION_STATUS,'1' DELETE_FLAG,e.fd_id USER_ID,d.fd_id DOMAIN_ID
from ekp_fb3b8d0c8f148639b8e2 d
LEFT JOIN ekporg_1832fea7d722404c1e92 f on f.fd_parent_id = d.fd_id
LEFT JOIN sys_org_element e on e.fd_id = f.sys_org_person_id JOIN sys_org_person p on e.fd_id=p.fd_id
where d.fd_id = #{fdId}
union ALL
select
e.fd_name EMP_NAME,p.fd_login_name EMP_LOGIN_NAME,SUBSTRING_INDEX(SUBSTRING_INDEX(e.fd_ldap_dn,',ou', 2),',ou=', -1) EMP_DEPT
,'5' PERMISSION_TYPE,d.fd_3a829ae9bab760 NAME,d.fd_3a829aea0b84a4 CODE,0 SOURCE_TYPE
,'0' IS_CONTAINS,'0' PERMISSION_STATUS,'1' DELETE_FLAG,e.fd_id USER_ID,d.fd_id DOMAIN_ID
from ekp_fb3b8d0c8f148639b8e2 d
LEFT JOIN sys_org_element e on e.fd_id = d.fd_3ae55447e30d62
JOIN sys_org_person p on e.fd_id=p.fd_id
where d.fd_id = #{fdId}
) a GROUP BY a.USER_ID
</select>
<!-- 查找权限,用来新建 - 合同变更 -->
<select id="getUserPermissionByAutoCreateHTBG" resultMap="sysUserPermissionMap">
select a.EMP_NAME,a.EMP_LOGIN_NAME,a.EMP_DEPT,a.PERMISSION_TYPE,a.NAME,a.CODE,a.SOURCE_TYPE,a.IS_CONTAINS,a.PERMISSION_STATUS,a.DELETE_FLAG,a.USER_ID,a.DOMAIN_ID
from (
select
e.fd_name EMP_NAME,p.fd_login_name EMP_LOGIN_NAME,SUBSTRING_INDEX(SUBSTRING_INDEX(e.fd_ldap_dn,',ou', 2),',ou=', -1) EMP_DEPT
,'4' PERMISSION_TYPE,d.fd_3ad97ed761c75c NAME,d.fd_3ade319226ed52 CODE,0 SOURCE_TYPE
,'0' IS_CONTAINS,'0' PERMISSION_STATUS,'1' DELETE_FLAG,e.fd_id USER_ID,d.fd_id DOMAIN_ID
from ekp_da0575c280b465d8ec9e d
LEFT JOIN ekporg_186ad03fd6179c8a1c5e f on f.fd_parent_id = d.fd_id
LEFT JOIN sys_org_element e on e.fd_id = f.sys_org_person_id JOIN sys_org_person p on e.fd_id=p.fd_id
where d.fd_id = #{fdId}
union all
select
e.fd_name EMP_NAME,p.fd_login_name EMP_LOGIN_NAME,SUBSTRING_INDEX(SUBSTRING_INDEX(e.fd_ldap_dn,',ou', 2),',ou=', -1) EMP_DEPT
,'4' PERMISSION_TYPE,d.fd_3ad97ed761c75c NAME,d.fd_3ade319226ed52 CODE,0 SOURCE_TYPE
,'0' IS_CONTAINS,'0' PERMISSION_STATUS,'1' DELETE_FLAG,e.fd_id USER_ID,d.fd_id DOMAIN_ID
from ekp_da0575c280b465d8ec9e d
left join ekp_0103c453b2848c3bb31c h on d.fd_3ade319226ed52=h.fd_3ade33763baa0e
LEFT JOIN sys_org_element e on e.fd_id = h.fd_3ade318b64b54c JOIN sys_org_person p on e.fd_id=p.fd_id
where d.fd_id = #{fdId}
) a
GROUP BY a.USER_ID
</select>
<!-- 查找权限,用来新建 - 项目变更 -->
<select id="getUserPermissionByAutoCreateXMBG" resultMap="sysUserPermissionMap">
select a.EMP_NAME,a.EMP_LOGIN_NAME,a.EMP_DEPT,a.PERMISSION_TYPE,a.NAME,a.CODE,a.SOURCE_TYPE,a.IS_CONTAINS,a.PERMISSION_STATUS,a.DELETE_FLAG,a.USER_ID,a.DOMAIN_ID
from (
select
e.fd_name EMP_NAME,p.fd_login_name EMP_LOGIN_NAME,SUBSTRING_INDEX(SUBSTRING_INDEX(e.fd_ldap_dn,',ou', 2),',ou=', -1) EMP_DEPT
,'5' PERMISSION_TYPE,d.fd_3b8797876dc13c_text NAME,d.fd_3b879793d37afe CODE,0 SOURCE_TYPE
,'0' IS_CONTAINS,'0' PERMISSION_STATUS,'1' DELETE_FLAG,e.fd_id USER_ID,d.fd_id DOMAIN_ID
from ekp_d701e3e72794ff390ca8 d
LEFT JOIN ekporg_18622320f73771d520db f on f.fd_parent_id = d.fd_id
LEFT JOIN sys_org_element e on e.fd_id = f.sys_org_person_id JOIN sys_org_person p on e.fd_id=p.fd_id
where d.fd_id = #{fdId}
union all
select
e.fd_name EMP_NAME,p.fd_login_name EMP_LOGIN_NAME,SUBSTRING_INDEX(SUBSTRING_INDEX(e.fd_ldap_dn,',ou', 2),',ou=', -1) EMP_DEPT
,'5' PERMISSION_TYPE,d.fd_3b8797876dc13c_text NAME,d.fd_3b879793d37afe CODE,0 SOURCE_TYPE
,'0' IS_CONTAINS,'0' PERMISSION_STATUS,'1' DELETE_FLAG,e.fd_id USER_ID,d.fd_id DOMAIN_ID
from ekp_d701e3e72794ff390ca8 d
LEFT JOIN ekp_24a8e6a7fc143bb8c48a f on f.fd_3a37fe508071fe = d.fd_3b879793d37afe
LEFT JOIN sys_org_element e on e.fd_id = f.fd_3b212a2d7a65c6 JOIN sys_org_person p on e.fd_id=p.fd_id
where d.fd_id = #{fdId}
) a GROUP BY a.USER_ID
</select>
<!-- 查找fdId对应的code -->
<select id="selectCodeByFdId" resultType="java.lang.String">
select d.fd_3a9d1d4d438bfc CODE from ekp_fa3e25a1b6c472683e96 d where d.fd_id = #{fdId}
union ALL
select d.fd_3b107f1084fd96 CODE from ekp_24385b8cc934eb8a9231 d where d.fd_id = #{fdId}
union ALL
select d.fd_3b04b9dc64a9f4 CODE from ekp_fd06fd1251d4bac8cc91 d where d.fd_id = #{fdId}
union ALL
select d.fd_3ade319226ed52 CODE from ekp_4834ce2ea964f1a8cfdb d where d.fd_id = #{fdId}
union ALL
select d.fd_3a829aea0b84a4 CODE from ekp_fb3b8d0c8f148639b8e2 d where d.fd_id = #{fdId}
union ALL
select d.fd_3b879793d37afe CODE from ekp_d701e3e72794ff390ca8 d where d.fd_id = #{fdId}
union ALL
select d.fd_3ade319226ed52 CODE from ekp_da0575c280b465d8ec9e d where d.fd_id = #{fdId}
limit 1
</select>
<!-- 删除EKP新建的 -->
<delete id="deleteUserPermissionByIdAndType">
delete from sys_user_permission p
where SOURCE_TYPE = 0 and CODE = #{code} and PERMISSION_TYPE = #{permissionType}
</delete>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment