diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/DeptSchemaController.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/DeptSchemaController.java new file mode 100644 index 0000000..f2e1191 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/DeptSchemaController.java @@ -0,0 +1,42 @@ +package com.ruoyi.tc.controller; + +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.tc.service.UnitService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * 组织架构 + * @author du + * @since 2024/12/9 10:42 + */ +@Api(tags = "组织架构") +@RestController +@RequestMapping("/tc/schema") +public class DeptSchemaController { + + @Resource + private UnitService unitService; + + /** + * 根据资产类型返回组织架构 + */ + @ApiOperation(value = "根据资产类型返回组织架构") + @GetMapping + @ApiImplicitParams({ + @ApiImplicitParam(name = "type", value = "0:web资产,1:小程序资产,2:公众号资产,3:电子邮件资产,4:移动应用程序资产", required = true), + }) + public AjaxResult schema(@RequestParam("type") String type) { + return AjaxResult.success(unitService.getSchema(type)); + } + +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/AssetApp.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/AssetApp.java index 3557df0..6339693 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/AssetApp.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/AssetApp.java @@ -1,6 +1,7 @@ package com.ruoyi.tc.entity; import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.ruoyi.common.annotation.Excel; @@ -138,4 +139,7 @@ public class AssetApp extends BaseClass implements Serializable { @ApiModelProperty("删除标志(0代表存在 2代表删除)") private String delFlag; + @ApiModelProperty("组织机构名称(部门名称)") + @TableField(exist = false) + private String deptName; } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/AssetCurrent.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/AssetCurrent.java index e6b3c27..489b85f 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/AssetCurrent.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/AssetCurrent.java @@ -42,6 +42,11 @@ public class AssetCurrent extends BaseClass implements Serializable { @Excel(name = "*系统名称",sort = 2,width = 40,required = true) private String xtmc; + + @ApiModelProperty("组织机构名称(部门名称)") + @TableField(exist = false) + private String deptName; + /** * 单位名称 */ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/AssetEmail.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/AssetEmail.java index 464e048..126c873 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/AssetEmail.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/AssetEmail.java @@ -1,6 +1,7 @@ package com.ruoyi.tc.entity; import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.ruoyi.common.annotation.Excel; @@ -21,6 +22,9 @@ import java.io.Serializable; @TableName(value = "asset_email") public class AssetEmail extends BaseClass implements Serializable { + @ApiModelProperty("组织机构名称(部门名称)") + @TableField(exist = false) + private String deptName; @ApiModelProperty("id") @TableId(value = "id",type = IdType.AUTO) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/AssetMiniPrograms.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/AssetMiniPrograms.java index f07a30f..80190c2 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/AssetMiniPrograms.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/AssetMiniPrograms.java @@ -33,6 +33,10 @@ public class AssetMiniPrograms extends BaseClass implements Serializable { @ApiModelProperty("id") @TableId(value = "id",type = IdType.AUTO) private Long id; + + @ApiModelProperty("组织机构名称(部门名称)") + @TableField(exist = false) + private String deptName; /** * 所属单位 */ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/AssetOfficialAccount.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/AssetOfficialAccount.java index c812f12..e9135af 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/AssetOfficialAccount.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/entity/AssetOfficialAccount.java @@ -1,6 +1,7 @@ package com.ruoyi.tc.entity; import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.ruoyi.common.annotation.Excel; @@ -27,6 +28,10 @@ public class AssetOfficialAccount extends BaseClass implements Serializable { @TableId(value = "id",type = IdType.AUTO) private Long id; + @ApiModelProperty("组织机构名称(部门名称)") + @TableField(exist = false) + private String deptName; + /** * 所属单位 */ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/mapper/UnitMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/mapper/UnitMapper.java index a7d03fc..c5ab8cf 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/mapper/UnitMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/mapper/UnitMapper.java @@ -2,6 +2,7 @@ package com.ruoyi.tc.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.tc.entity.AssetTask; import com.ruoyi.tc.entity.Unit; import com.ruoyi.tc.entity.request.GeneralQueryRequest; @@ -84,4 +85,33 @@ public interface UnitMapper extends BaseMapper { * 根据单位名称和5种资产类型查询 */ Integer selectTaskId(@Param("dwmc") String dwmc,@Param("type") String type); + + + /** + * app资产的单位组织架构不为空的部门 + */ + List getAppSchema(); + + /** + * email资产的单位组织架构不为空的部门 + */ + List getEmailSchema(); + + + /** + * 小程序资产的单位组织架构不为空的部门 + */ + List getMiniSchema(); + + + /** + * 公众号资产的单位组织架构不为空的部门 + */ + List getGzpSchema(); + + + /** + * web资产的单位组织架构不为空的部门 + */ + List getWebSchema(); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/service/UnitService.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/service/UnitService.java index ded93c0..d673048 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/service/UnitService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/service/UnitService.java @@ -3,6 +3,7 @@ package com.ruoyi.tc.service; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.domain.TreeSelect; import com.ruoyi.tc.entity.AssetTask; import com.ruoyi.tc.entity.Unit; import com.ruoyi.tc.entity.request.GeneralQueryRequest; @@ -88,4 +89,10 @@ public interface UnitService extends IService { * @return */ Integer findBydwmc(String part); + + + /** + * 根据资产类型返回组织架构 + */ + List getSchema(String type); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/service/impl/UnitServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/service/impl/UnitServiceImpl.java index ba8f91d..6289d26 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/service/impl/UnitServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/service/impl/UnitServiceImpl.java @@ -2,13 +2,15 @@ package com.ruoyi.tc.service.impl; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.common.core.domain.TreeSelect; +import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.PasswordGenerator; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.system.service.ISysDeptService; import com.ruoyi.system.service.ISysUserService; -import com.ruoyi.tc.entity.AssetTask; import com.ruoyi.tc.entity.Unit; import com.ruoyi.tc.entity.request.GeneralQueryRequest; import com.ruoyi.tc.entity.request.UnitRequest; @@ -17,6 +19,7 @@ import com.ruoyi.tc.service.UnitService; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.List; /** @@ -28,9 +31,13 @@ import java.util.List; @Service public class UnitServiceImpl extends ServiceImpl implements UnitService { + @Resource private ISysUserService userService; + @Resource + private ISysDeptService iSysDeptService; + /** * 分页条件查询所有单位列表 * @@ -136,7 +143,7 @@ public class UnitServiceImpl extends ServiceImpl implements Un */ @Override public Integer selectTaskId(String dwmc, String type) { - return baseMapper.selectTaskId(dwmc,type); + return baseMapper.selectTaskId(dwmc, type); } @Override @@ -144,4 +151,32 @@ public class UnitServiceImpl extends ServiceImpl implements Un return baseMapper.findBydwmc(part); } + /** + * 根据资产类型返回组织架构 + */ + @Override + public List getSchema(String type) { + List appSchema = new ArrayList<>(); + switch (type) { + case "0": + appSchema = baseMapper.getWebSchema(); + break; + case "1": + appSchema = baseMapper.getMiniSchema(); + break; + case "2": + appSchema = baseMapper.getGzpSchema(); + break; + case "3": + appSchema = baseMapper.getEmailSchema(); + break; + case "4": + appSchema = baseMapper.getAppSchema(); + break; + default: + break; + } + return iSysDeptService.buildDeptTreeSelect(appSchema); + } + } diff --git a/ruoyi-admin/src/main/resources/mapper/AssetAppMapper.xml b/ruoyi-admin/src/main/resources/mapper/AssetAppMapper.xml index e2325a3..6c97939 100644 --- a/ruoyi-admin/src/main/resources/mapper/AssetAppMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/AssetAppMapper.xml @@ -15,26 +15,32 @@ - select * from asset_current + select a.* from asset_current a + left join unit_info b on a.dwmc = b.nick_name + left join sys_dept c on b.dept_id = c.dept_id - del_flag = '0' + a. del_flag = '0' and b.del_flag = '0' - and xtmc like concat('%',#{req.xtmc},'%') + and a.xtmc like concat('%',#{req.xtmc},'%') - and dwmc like concat('%',#{req.dwmc},'%') + and a.dwmc like concat('%',#{req.dwmc},'%') - and xtlx = #{req.xtlx} + and a.xtlx = #{req.xtlx} - and xtzt = #{req.xtzt} + and a.xtzt = #{req.xtzt} - and create_time >= #{req.startTime} + and a.create_time >= #{req.startTime} - and create_time <= #{req.endTime} + and a.create_time <= #{req.endTime} + + + AND (b.dept_id = #{req.deptId} OR b.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE + find_in_set(#{req.deptId}, ancestors) )) - order by create_time desc + order by a.create_time desc - select * from asset_email + select a.* from asset_email a + left join unit_info b on a.ssdw = b.nick_name + left join sys_dept c on b.dept_id = c.dept_id - del_flag = '0' + a.del_flag = '0' and b.del_flag = '0' - and dzyxhz like concat('%',#{req.dzyxhz},'%') + and a.dzyxhz like concat('%',#{req.dzyxhz},'%') - and ssdw like concat('%',#{req.dwmc},'%') + and a.ssdw like concat('%',#{req.dwmc},'%') - and create_time >= #{req.startTime} + and a.create_time >= #{req.startTime} - and create_time <= #{req.endTime} + and a.create_time <= #{req.endTime} - and yjxtzc = #{req.xtzt} + and a.yjxtzc = #{req.xtzt} + + + AND (b.dept_id = #{req.deptId} OR b.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE + find_in_set(#{req.deptId}, ancestors) )) - order by create_time desc + order by a.create_time desc - select * from asset_mini_programs + select a.* from asset_mini_programs a + left join unit_info b on a.ssdw = b.nick_name + left join sys_dept c on b.dept_id = c.dept_id - del_flag = '0' + a.del_flag = '0' and b.del_flag = '0' - and xcxmc like concat('%',#{req.xcxmc},'%') + and a.xcxmc like concat('%',#{req.xcxmc},'%') - and ssdw like concat('%',#{req.dwmc},'%') + and a.ssdw like concat('%',#{req.dwmc},'%') - and create_time >= #{req.startTime} + and a.create_time >= #{req.startTime} - and create_time <= #{req.endTime} + and a.create_time <= #{req.endTime} - and state = #{req.xtzt} + and a.state = #{req.xtzt} + + + AND (b.dept_id = #{req.deptId} OR b.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE + find_in_set(#{req.deptId}, ancestors) )) - order by create_time desc + order by a.create_time desc diff --git a/ruoyi-admin/src/main/resources/mapper/UnitMapper.xml b/ruoyi-admin/src/main/resources/mapper/UnitMapper.xml index 8fda3fc..6cb81dd 100644 --- a/ruoyi-admin/src/main/resources/mapper/UnitMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/UnitMapper.xml @@ -212,6 +212,176 @@ + + + + + update unit_info