Browse Source

基础管理代码

develop
ljlong_2630 1 year ago
parent
commit
5876d20fec
  1. 1
      lzbi-common/pom.xml
  2. 86
      lzbi-common/src/main/java/com/lzbi/common/core/domain/TreeSelect.java
  3. 40
      lzbi-common/src/main/java/com/lzbi/common/core/domain/entity/SysDept.java
  4. 99
      lzbi-module/src/main/java/com/lzbi/asset/controller/DcBaseAssetInfoController.java
  5. 285
      lzbi-module/src/main/java/com/lzbi/asset/domain/DcBaseAssetInfo.java
  6. 62
      lzbi-module/src/main/java/com/lzbi/asset/mapper/DcBaseAssetInfoMapper.java
  7. 62
      lzbi-module/src/main/java/com/lzbi/asset/service/IDcBaseAssetInfoService.java
  8. 87
      lzbi-module/src/main/java/com/lzbi/asset/service/impl/DcBaseAssetInfoServiceImpl.java
  9. 154
      lzbi-module/src/main/resources/mapper/asset/DcBaseAssetInfoMapper.xml
  10. 184
      lzbi-system/src/main/java/com/lzbi/system/service/impl/SysDeptServiceImpl.java
  11. 24
      lzbi-system/src/main/resources/mapper/system/SysDeptMapper.xml

1
lzbi-common/pom.xml

@ -141,6 +141,7 @@
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.3.0</version>
<type>pom</type>
</dependency>
<!-- -->
<dependency>

86
lzbi-common/src/main/java/com/lzbi/common/core/domain/TreeSelect.java

@ -3,75 +3,113 @@ package com.lzbi.common.core.domain;
import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.lzbi.common.core.domain.entity.SysDept;
import com.lzbi.common.core.domain.entity.SysMenu;
/**
* Treeselect树结构实体类
*
*
* @author ruoyi
*/
public class TreeSelect implements Serializable
{
public class TreeSelect implements Serializable {
private static final long serialVersionUID = 1L;
/** 节点ID */
/**
* 节点ID
*/
private Long id;
/** 节点名称 */
/**
* 节点名称
*/
private String label;
/** 子节点 */
/**
* 全名称
*/
private String allName;
/**
* 简称
*/
private String shortName;
/**
* 类别
*/
private String orgType;
/**
* 子节点
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<TreeSelect> children;
public TreeSelect()
{
public TreeSelect() {
}
public TreeSelect(SysDept dept)
{
public TreeSelect(SysDept dept) {
this.id = dept.getDeptId();
this.label = dept.getDeptName();
this.shortName = dept.getShortName();
this.orgType = dept.getOrgType();
this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
}
public TreeSelect(SysMenu menu)
{
public TreeSelect(SysMenu menu) {
this.id = menu.getMenuId();
this.label = menu.getMenuName();
this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
}
public Long getId()
{
public Long getId() {
return id;
}
public void setId(Long id)
{
public void setId(Long id) {
this.id = id;
}
public String getLabel()
{
public String getLabel() {
return label;
}
public void setLabel(String label)
{
public void setLabel(String label) {
this.label = label;
}
public List<TreeSelect> getChildren()
{
public List<TreeSelect> getChildren() {
return children;
}
public void setChildren(List<TreeSelect> children)
{
public void setChildren(List<TreeSelect> children) {
this.children = children;
}
public String getAllName() {
return allName;
}
public void setAllName(String allName) {
this.allName = allName;
}
public String getShortName() {
return shortName;
}
public void setShortName(String shortName) {
this.shortName = shortName;
}
public String getOrgType() {
return orgType;
}
public void setOrgType(String orgType) {
this.orgType = orgType;
}
}

40
lzbi-common/src/main/java/com/lzbi/common/core/domain/entity/SysDept.java

@ -51,8 +51,15 @@ public class SysDept extends BaseEntity
/** 父部门名称 */
private String parentName;
/** 部门类型 */
private String deptClass;
/** 全名称 */
private String allName;
/** 简称 */
private String shortName;
/** 类别 */
private String orgType;
/** 子部门 */
private List<SysDept> children = new ArrayList<SysDept>();
@ -182,14 +189,31 @@ public class SysDept extends BaseEntity
this.children = children;
}
public String getDeptClass() {
return deptClass;
public String getAllName() {
return allName;
}
public String getShortName() {
return shortName;
}
public String getOrgType() {
return orgType;
}
public void setAllName(String allName) {
this.allName = allName;
}
public void setDeptClass(String deptClass) {
this.deptClass = deptClass;
public void setShortName(String shortName) {
this.shortName = shortName;
}
public void setOrgType(String orgType) {
this.orgType = orgType;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@ -207,7 +231,9 @@ public class SysDept extends BaseEntity
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("deptClass", getDeptClass())
.append("allName", getAllName())
.append("shortName", getShortName())
.append("orgType", getOrgType())
.toString();
}
}

99
lzbi-module/src/main/java/com/lzbi/asset/controller/DcBaseAssetInfoController.java

@ -0,0 +1,99 @@
package com.lzbi.asset.controller;
import javax.servlet.http.HttpServletResponse;
import com.lzbi.asset.domain.DcBaseAssetInfo;
import com.lzbi.asset.service.IDcBaseAssetInfoService;
import com.lzbi.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lzbi.common.annotation.Log;
import com.lzbi.common.core.controller.BaseController;
import com.lzbi.common.core.domain.AjaxResult;
import com.lzbi.common.enums.BusinessType;
import com.lzbi.common.core.page.TableDataInfo;
import java.util.List;
/**
* 资产信息Controller
*
* @author Lu.JL
* @date 2023-11-27
*/
@RestController
@RequestMapping("/lzbi/asset_info")
public class DcBaseAssetInfoController extends BaseController {
@Autowired
private IDcBaseAssetInfoService dcBaseAssetInfoService;
/**
* 查询资产信息列表
*/
@PreAuthorize("@ss.hasPermi('lzbi:asset_info:list')")
@GetMapping("/list")
public TableDataInfo list(DcBaseAssetInfo dcBaseAssetInfo) {
startPage();
List<DcBaseAssetInfo> list = dcBaseAssetInfoService.selectDcBaseAssetInfoList(dcBaseAssetInfo);
return getDataTable(list);
}
/**
* 导出资产信息列表
*/
@PreAuthorize("@ss.hasPermi('lzbi:asset_info:export')")
@Log(title = "资产信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DcBaseAssetInfo dcBaseAssetInfo) {
List<DcBaseAssetInfo> list = dcBaseAssetInfoService.selectDcBaseAssetInfoList(dcBaseAssetInfo);
ExcelUtil<DcBaseAssetInfo> util = new ExcelUtil<DcBaseAssetInfo>(DcBaseAssetInfo.class);
util.exportExcel(response, list, "资产信息数据");
}
/**
* 获取资产信息详细信息
*/
@PreAuthorize("@ss.hasPermi('lzbi:asset_info:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(dcBaseAssetInfoService.selectDcBaseAssetInfoById(id));
}
/**
* 新增资产信息
*/
@PreAuthorize("@ss.hasPermi('lzbi:asset_info:add')")
@Log(title = "资产信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DcBaseAssetInfo dcBaseAssetInfo) {
return toAjax(dcBaseAssetInfoService.insertDcBaseAssetInfo(dcBaseAssetInfo));
}
/**
* 修改资产信息
*/
@PreAuthorize("@ss.hasPermi('lzbi:asset_info:edit')")
@Log(title = "资产信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DcBaseAssetInfo dcBaseAssetInfo) {
return toAjax(dcBaseAssetInfoService.updateDcBaseAssetInfo(dcBaseAssetInfo));
}
/**
* 删除资产信息
*/
@PreAuthorize("@ss.hasPermi('lzbi:asset_info:remove')")
@Log(title = "资产信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(dcBaseAssetInfoService.deleteDcBaseAssetInfoByIds(ids));
}
}

285
lzbi-module/src/main/java/com/lzbi/asset/domain/DcBaseAssetInfo.java

@ -0,0 +1,285 @@
package com.lzbi.asset.domain;
import java.util.Date;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.lzbi.common.annotation.Excel;
import com.lzbi.common.core.domain.BaseEntity;
/**
* 资产信息对象 dc_base_asset_info
*
* @author Lu.JL
* @date 2023-11-27
*/
public class DcBaseAssetInfo extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 租户号
*/
private String tenantId;
/**
* 乐观锁
*/
private Long REVISION;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
/**
* 删除人
*/
private String deleteBy;
/**
* 删除时间
*/
private Date deleteTime;
/**
* 资产ID
*/
private Long id;
/**
* 资产名称
*/
@Excel(name = "资产名称")
private String assetName;
/**
* 资产编码
*/
@Excel(name = "资产编码")
private String assetCode;
/**
* 资产类别;设备型资产管理型资产
*/
@Excel(name = "资产类别;设备型资产;管理型资产;")
private String assetClass;
/**
* 部门共享;0不共享1限定部门共享2所有部门可见
*/
@Excel(name = "部门共享;0不共享;1限定部门共享;2所有部门可见")
private String flagValidateDept;
/**
* 角色内共享;0不共享1限定角色共享2所有角色可见
*/
@Excel(name = "角色内共享;0不共享;1限定角色共享;2所有角色可见")
private String flagValidateRole;
/**
* 用户共享;0不共享1限定用户共享2所有用户可见
*/
@Excel(name = "用户共享;0不共享;1限定用户共享;2所有用户可见")
private String flagValidateUser;
/**
* 资产状态
*/
@Excel(name = "资产状态")
private String statusAsset;
/**
* 所属公司
*/
@Excel(name = "所属公司")
private Long comanyId;
/**
* 所属组织结构
*/
@Excel(name = "所属组织结构")
private Long deptId;
public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}
public String getTenantId() {
return tenantId;
}
public void setREVISION(Long REVISION) {
this.REVISION = REVISION;
}
public Long getREVISION() {
return REVISION;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public String getCreatedBy() {
return createdBy;
}
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
public Date getCreatedTime() {
return createdTime;
}
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}
public String getUpdatedBy() {
return updatedBy;
}
public void setUpdatedTime(Date updatedTime) {
this.updatedTime = updatedTime;
}
public Date getUpdatedTime() {
return updatedTime;
}
public void setDeleteBy(String deleteBy) {
this.deleteBy = deleteBy;
}
public String getDeleteBy() {
return deleteBy;
}
public void setDeleteTime(Date deleteTime) {
this.deleteTime = deleteTime;
}
public Date getDeleteTime() {
return deleteTime;
}
public void setId(Long id) {
this.id = id;
}
public Long getId() {
return id;
}
public void setAssetName(String assetName) {
this.assetName = assetName;
}
public String getAssetName() {
return assetName;
}
public void setAssetCode(String assetCode) {
this.assetCode = assetCode;
}
public String getAssetCode() {
return assetCode;
}
public void setAssetClass(String assetClass) {
this.assetClass = assetClass;
}
public String getAssetClass() {
return assetClass;
}
public void setFlagValidateDept(String flagValidateDept) {
this.flagValidateDept = flagValidateDept;
}
public String getFlagValidateDept() {
return flagValidateDept;
}
public void setFlagValidateRole(String flagValidateRole) {
this.flagValidateRole = flagValidateRole;
}
public String getFlagValidateRole() {
return flagValidateRole;
}
public void setFlagValidateUser(String flagValidateUser) {
this.flagValidateUser = flagValidateUser;
}
public String getFlagValidateUser() {
return flagValidateUser;
}
public void setStatusAsset(String statusAsset) {
this.statusAsset = statusAsset;
}
public String getStatusAsset() {
return statusAsset;
}
public void setComanyId(Long comanyId) {
this.comanyId = comanyId;
}
public Long getComanyId() {
return comanyId;
}
public void setDeptId(Long deptId) {
this.deptId = deptId;
}
public Long getDeptId() {
return deptId;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("tenantId", getTenantId())
.append("REVISION", getREVISION())
.append("createdBy", getCreatedBy())
.append("createdTime", getCreatedTime())
.append("updatedBy", getUpdatedBy())
.append("updatedTime", getUpdatedTime())
.append("deleteBy", getDeleteBy())
.append("deleteTime", getDeleteTime())
.append("id", getId())
.append("assetName", getAssetName())
.append("assetCode", getAssetCode())
.append("assetClass", getAssetClass())
.append("flagValidateDept", getFlagValidateDept())
.append("flagValidateRole", getFlagValidateRole())
.append("flagValidateUser", getFlagValidateUser())
.append("statusAsset", getStatusAsset())
.append("comanyId", getComanyId())
.append("deptId", getDeptId())
.toString();
}
}

62
lzbi-module/src/main/java/com/lzbi/asset/mapper/DcBaseAssetInfoMapper.java

@ -0,0 +1,62 @@
package com.lzbi.asset.mapper;
import com.lzbi.asset.domain.DcBaseAssetInfo;
import java.util.List;
/**
* 资产信息Mapper接口
*
* @author Lu.JL
* @date 2023-11-27
*/
public interface DcBaseAssetInfoMapper {
/**
* 查询资产信息
*
* @param id 资产信息主键
* @return 资产信息
*/
public DcBaseAssetInfo selectDcBaseAssetInfoById(Long id);
/**
* 查询资产信息列表
*
* @param dcBaseAssetInfo 资产信息
* @return 资产信息集合
*/
public List<DcBaseAssetInfo> selectDcBaseAssetInfoList(DcBaseAssetInfo dcBaseAssetInfo);
/**
* 新增资产信息
*
* @param dcBaseAssetInfo 资产信息
* @return 结果
*/
public int insertDcBaseAssetInfo(DcBaseAssetInfo dcBaseAssetInfo);
/**
* 修改资产信息
*
* @param dcBaseAssetInfo 资产信息
* @return 结果
*/
public int updateDcBaseAssetInfo(DcBaseAssetInfo dcBaseAssetInfo);
/**
* 删除资产信息
*
* @param id 资产信息主键
* @return 结果
*/
public int deleteDcBaseAssetInfoById(Long id);
/**
* 批量删除资产信息
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteDcBaseAssetInfoByIds(Long[] ids);
}

62
lzbi-module/src/main/java/com/lzbi/asset/service/IDcBaseAssetInfoService.java

@ -0,0 +1,62 @@
package com.lzbi.asset.service;
import com.lzbi.asset.domain.DcBaseAssetInfo;
import java.util.List;
/**
* 资产信息Service接口
*
* @author Lu.JL
* @date 2023-11-27
*/
public interface IDcBaseAssetInfoService {
/**
* 查询资产信息
*
* @param id 资产信息主键
* @return 资产信息
*/
public DcBaseAssetInfo selectDcBaseAssetInfoById(Long id);
/**
* 查询资产信息列表
*
* @param dcBaseAssetInfo 资产信息
* @return 资产信息集合
*/
public List<DcBaseAssetInfo> selectDcBaseAssetInfoList(DcBaseAssetInfo dcBaseAssetInfo);
/**
* 新增资产信息
*
* @param dcBaseAssetInfo 资产信息
* @return 结果
*/
public int insertDcBaseAssetInfo(DcBaseAssetInfo dcBaseAssetInfo);
/**
* 修改资产信息
*
* @param dcBaseAssetInfo 资产信息
* @return 结果
*/
public int updateDcBaseAssetInfo(DcBaseAssetInfo dcBaseAssetInfo);
/**
* 批量删除资产信息
*
* @param ids 需要删除的资产信息主键集合
* @return 结果
*/
public int deleteDcBaseAssetInfoByIds(Long[] ids);
/**
* 删除资产信息信息
*
* @param id 资产信息主键
* @return 结果
*/
public int deleteDcBaseAssetInfoById(Long id);
}

87
lzbi-module/src/main/java/com/lzbi/asset/service/impl/DcBaseAssetInfoServiceImpl.java

@ -0,0 +1,87 @@
package com.lzbi.asset.service.impl;
import java.util.List;
import com.lzbi.asset.domain.DcBaseAssetInfo;
import com.lzbi.asset.mapper.DcBaseAssetInfoMapper;
import com.lzbi.asset.service.IDcBaseAssetInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 资产信息Service业务层处理
*
* @author Lu.JL
* @date 2023-11-27
*/
@Service
public class DcBaseAssetInfoServiceImpl implements IDcBaseAssetInfoService {
@Autowired
private DcBaseAssetInfoMapper dcBaseAssetInfoMapper;
/**
* 查询资产信息
*
* @param id 资产信息主键
* @return 资产信息
*/
@Override
public DcBaseAssetInfo selectDcBaseAssetInfoById(Long id) {
return dcBaseAssetInfoMapper.selectDcBaseAssetInfoById(id);
}
/**
* 查询资产信息列表
*
* @param dcBaseAssetInfo 资产信息
* @return 资产信息
*/
@Override
public List<DcBaseAssetInfo> selectDcBaseAssetInfoList(DcBaseAssetInfo dcBaseAssetInfo) {
return dcBaseAssetInfoMapper.selectDcBaseAssetInfoList(dcBaseAssetInfo);
}
/**
* 新增资产信息
*
* @param dcBaseAssetInfo 资产信息
* @return 结果
*/
@Override
public int insertDcBaseAssetInfo(DcBaseAssetInfo dcBaseAssetInfo) {
return dcBaseAssetInfoMapper.insertDcBaseAssetInfo(dcBaseAssetInfo);
}
/**
* 修改资产信息
*
* @param dcBaseAssetInfo 资产信息
* @return 结果
*/
@Override
public int updateDcBaseAssetInfo(DcBaseAssetInfo dcBaseAssetInfo) {
return dcBaseAssetInfoMapper.updateDcBaseAssetInfo(dcBaseAssetInfo);
}
/**
* 批量删除资产信息
*
* @param ids 需要删除的资产信息主键
* @return 结果
*/
@Override
public int deleteDcBaseAssetInfoByIds(Long[] ids) {
return dcBaseAssetInfoMapper.deleteDcBaseAssetInfoByIds(ids);
}
/**
* 删除资产信息信息
*
* @param id 资产信息主键
* @return 结果
*/
@Override
public int deleteDcBaseAssetInfoById(Long id) {
return dcBaseAssetInfoMapper.deleteDcBaseAssetInfoById(id);
}
}

154
lzbi-module/src/main/resources/mapper/asset/DcBaseAssetInfoMapper.xml

@ -0,0 +1,154 @@
<?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.lzbi.asset.mapper.DcBaseAssetInfoMapper">
<resultMap type="DcBaseAssetInfo" id="DcBaseAssetInfoResult">
<result property="tenantId" column="TENANT_ID"/>
<result property="REVISION" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
<result property="deleteBy" column="DELETE_BY"/>
<result property="deleteTime" column="DELETE_TIME"/>
<result property="id" column="id"/>
<result property="assetName" column="asset_name"/>
<result property="assetCode" column="asset_code"/>
<result property="assetClass" column="asset_class"/>
<result property="flagValidateDept" column="flag_validate_dept"/>
<result property="flagValidateRole" column="flag_validate_role"/>
<result property="flagValidateUser" column="flag_validate_user"/>
<result property="statusAsset" column="status_asset"/>
<result property="comanyId" column="comany_id"/>
<result property="deptId" column="dept_id"/>
</resultMap>
<sql id="selectDcBaseAssetInfoVo">
select TENANT_ID,
REVISION,
CREATED_BY,
CREATED_TIME,
UPDATED_BY,
UPDATED_TIME,
DELETE_BY,
DELETE_TIME,
id,
asset_name,
asset_code,
asset_class,
flag_validate_dept,
flag_validate_role,
flag_validate_user,
status_asset,
comany_id,
dept_id
from dc_base_asset_info
</sql>
<select id="selectDcBaseAssetInfoList" parameterType="DcBaseAssetInfo" resultMap="DcBaseAssetInfoResult">
<include refid="selectDcBaseAssetInfoVo"/>
<where>
<if test="assetName != null and assetName != ''">and asset_name like concat('%', #{assetName}, '%')</if>
<if test="assetCode != null and assetCode != ''">and asset_code = #{assetCode}</if>
<if test="assetClass != null and assetClass != ''">and asset_class = #{assetClass}</if>
<if test="flagValidateDept != null and flagValidateDept != ''">and flag_validate_dept =
#{flagValidateDept}
</if>
<if test="flagValidateRole != null and flagValidateRole != ''">and flag_validate_role =
#{flagValidateRole}
</if>
<if test="flagValidateUser != null and flagValidateUser != ''">and flag_validate_user =
#{flagValidateUser}
</if>
<if test="statusAsset != null and statusAsset != ''">and status_asset = #{statusAsset}</if>
<if test="comanyId != null ">and comany_id = #{comanyId}</if>
<if test="deptId != null ">and dept_id = #{deptId}</if>
</where>
</select>
<select id="selectDcBaseAssetInfoById" parameterType="Long" resultMap="DcBaseAssetInfoResult">
<include refid="selectDcBaseAssetInfoVo"/>
where id = #{id}
</select>
<insert id="insertDcBaseAssetInfo" parameterType="DcBaseAssetInfo" useGeneratedKeys="true" keyProperty="id">
insert into dc_base_asset_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="tenantId != null">TENANT_ID,</if>
<if test="REVISION != null">REVISION,</if>
<if test="createdBy != null">CREATED_BY,</if>
<if test="createdTime != null">CREATED_TIME,</if>
<if test="updatedBy != null">UPDATED_BY,</if>
<if test="updatedTime != null">UPDATED_TIME,</if>
<if test="deleteBy != null">DELETE_BY,</if>
<if test="deleteTime != null">DELETE_TIME,</if>
<if test="assetName != null and assetName != ''">asset_name,</if>
<if test="assetCode != null and assetCode != ''">asset_code,</if>
<if test="assetClass != null and assetClass != ''">asset_class,</if>
<if test="flagValidateDept != null">flag_validate_dept,</if>
<if test="flagValidateRole != null">flag_validate_role,</if>
<if test="flagValidateUser != null">flag_validate_user,</if>
<if test="statusAsset != null">status_asset,</if>
<if test="comanyId != null">comany_id,</if>
<if test="deptId != null">dept_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="tenantId != null">#{tenantId},</if>
<if test="REVISION != null">#{REVISION},</if>
<if test="createdBy != null">#{createdBy},</if>
<if test="createdTime != null">#{createdTime},</if>
<if test="updatedBy != null">#{updatedBy},</if>
<if test="updatedTime != null">#{updatedTime},</if>
<if test="deleteBy != null">#{deleteBy},</if>
<if test="deleteTime != null">#{deleteTime},</if>
<if test="assetName != null and assetName != ''">#{assetName},</if>
<if test="assetCode != null and assetCode != ''">#{assetCode},</if>
<if test="assetClass != null and assetClass != ''">#{assetClass},</if>
<if test="flagValidateDept != null">#{flagValidateDept},</if>
<if test="flagValidateRole != null">#{flagValidateRole},</if>
<if test="flagValidateUser != null">#{flagValidateUser},</if>
<if test="statusAsset != null">#{statusAsset},</if>
<if test="comanyId != null">#{comanyId},</if>
<if test="deptId != null">#{deptId},</if>
</trim>
</insert>
<update id="updateDcBaseAssetInfo" parameterType="DcBaseAssetInfo">
update dc_base_asset_info
<trim prefix="SET" suffixOverrides=",">
<if test="tenantId != null">TENANT_ID = #{tenantId},</if>
<if test="REVISION != null">REVISION = #{REVISION},</if>
<if test="createdBy != null">CREATED_BY = #{createdBy},</if>
<if test="createdTime != null">CREATED_TIME = #{createdTime},</if>
<if test="updatedBy != null">UPDATED_BY = #{updatedBy},</if>
<if test="updatedTime != null">UPDATED_TIME = #{updatedTime},</if>
<if test="deleteBy != null">DELETE_BY = #{deleteBy},</if>
<if test="deleteTime != null">DELETE_TIME = #{deleteTime},</if>
<if test="assetName != null and assetName != ''">asset_name = #{assetName},</if>
<if test="assetCode != null and assetCode != ''">asset_code = #{assetCode},</if>
<if test="assetClass != null and assetClass != ''">asset_class = #{assetClass},</if>
<if test="flagValidateDept != null">flag_validate_dept = #{flagValidateDept},</if>
<if test="flagValidateRole != null">flag_validate_role = #{flagValidateRole},</if>
<if test="flagValidateUser != null">flag_validate_user = #{flagValidateUser},</if>
<if test="statusAsset != null">status_asset = #{statusAsset},</if>
<if test="comanyId != null">comany_id = #{comanyId},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteDcBaseAssetInfoById" parameterType="Long">
delete
from dc_base_asset_info
where id = #{id}
</delete>
<delete id="deleteDcBaseAssetInfoByIds" parameterType="String">
delete from dc_base_asset_info where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

184
lzbi-system/src/main/java/com/lzbi/system/service/impl/SysDeptServiceImpl.java

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.lzbi.common.annotation.DataScope;
@ -23,12 +24,11 @@ import com.lzbi.system.service.ISysDeptService;
/**
* 部门管理 服务实现
*
*
* @author ruoyi
*/
@Service
public class SysDeptServiceImpl implements ISysDeptService
{
public class SysDeptServiceImpl implements ISysDeptService {
@Autowired
private SysDeptMapper deptMapper;
@ -37,52 +37,46 @@ public class SysDeptServiceImpl implements ISysDeptService
/**
* 查询部门管理数据
*
*
* @param dept 部门信息
* @return 部门信息集合
*/
@Override
@DataScope(deptAlias = "d")
public List<SysDept> selectDeptList(SysDept dept)
{
public List<SysDept> selectDeptList(SysDept dept) {
return deptMapper.selectDeptList(dept);
}
/**
* 查询部门树结构信息
*
*
* @param dept 部门信息
* @return 部门树信息集合
*/
@Override
public List<TreeSelect> selectDeptTreeList(SysDept dept)
{
public List<TreeSelect> selectDeptTreeList(SysDept dept) {
List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
return buildDeptTreeSelect(depts);
}
/**
* 构建前端所需要树结构
*
*
* @param depts 部门列表
* @return 树结构列表
*/
@Override
public List<SysDept> buildDeptTree(List<SysDept> depts)
{
public List<SysDept> buildDeptTree(List<SysDept> depts) {
List<SysDept> returnList = new ArrayList<SysDept>();
List<Long> tempList = depts.stream().map(SysDept::getDeptId).collect(Collectors.toList());
for (SysDept dept : depts)
{
for (SysDept dept : depts) {
// 如果是顶级节点, 遍历该父节点的所有子节点
if (!tempList.contains(dept.getParentId()))
{
if (!tempList.contains(dept.getParentId())) {
recursionFn(depts, dept);
returnList.add(dept);
}
}
if (returnList.isEmpty())
{
if (returnList.isEmpty()) {
returnList = depts;
}
return returnList;
@ -90,93 +84,85 @@ public class SysDeptServiceImpl implements ISysDeptService
/**
* 构建前端所需要下拉树结构
*
*
* @param depts 部门列表
* @return 下拉树结构列表
*/
@Override
public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts)
{
public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts) {
List<SysDept> deptTrees = buildDeptTree(depts);
return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
}
/**
* 根据角色ID查询部门树信息
*
*
* @param roleId 角色ID
* @return 选中部门列表
*/
@Override
public List<Long> selectDeptListByRoleId(Long roleId)
{
public List<Long> selectDeptListByRoleId(Long roleId) {
SysRole role = roleMapper.selectRoleById(roleId);
return deptMapper.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly());
}
/**
* 根据部门ID查询信息
*
*
* @param deptId 部门ID
* @return 部门信息
*/
@Override
public SysDept selectDeptById(Long deptId)
{
public SysDept selectDeptById(Long deptId) {
return deptMapper.selectDeptById(deptId);
}
/**
* 根据ID查询所有子部门正常状态
*
*
* @param deptId 部门ID
* @return 子部门数
*/
@Override
public int selectNormalChildrenDeptById(Long deptId)
{
public int selectNormalChildrenDeptById(Long deptId) {
return deptMapper.selectNormalChildrenDeptById(deptId);
}
/**
* 是否存在子节点
*
*
* @param deptId 部门ID
* @return 结果
*/
@Override
public boolean hasChildByDeptId(Long deptId)
{
public boolean hasChildByDeptId(Long deptId) {
int result = deptMapper.hasChildByDeptId(deptId);
return result > 0;
}
/**
* 查询部门是否存在用户
*
*
* @param deptId 部门ID
* @return 结果 true 存在 false 不存在
*/
@Override
public boolean checkDeptExistUser(Long deptId)
{
public boolean checkDeptExistUser(Long deptId) {
int result = deptMapper.checkDeptExistUser(deptId);
return result > 0;
}
/**
* 校验部门名称是否唯一
*
*
* @param dept 部门信息
* @return 结果
*/
@Override
public boolean checkDeptNameUnique(SysDept dept)
{
public boolean checkDeptNameUnique(SysDept dept) {
Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId());
if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue())
{
if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue()) {
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
@ -184,19 +170,16 @@ public class SysDeptServiceImpl implements ISysDeptService
/**
* 校验部门是否有数据权限
*
*
* @param deptId 部门id
*/
@Override
public void checkDeptDataScope(Long deptId)
{
if (!SysUser.isAdmin(SecurityUtils.getUserId()))
{
public void checkDeptDataScope(Long deptId) {
if (!SysUser.isAdmin(SecurityUtils.getUserId())) {
SysDept dept = new SysDept();
dept.setDeptId(deptId);
List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
if (StringUtils.isEmpty(depts))
{
if (StringUtils.isEmpty(depts)) {
throw new ServiceException("没有权限访问部门数据!");
}
}
@ -204,17 +187,15 @@ public class SysDeptServiceImpl implements ISysDeptService
/**
* 新增保存部门信息
*
*
* @param dept 部门信息
* @return 结果
*/
@Override
public int insertDept(SysDept dept)
{
public int insertDept(SysDept dept) {
SysDept info = deptMapper.selectDeptById(dept.getParentId());
// 如果父节点不为正常状态,则不允许新增子节点
if (!UserConstants.DEPT_NORMAL.equals(info.getStatus()))
{
if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) {
throw new ServiceException("部门停用,不允许新增");
}
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
@ -223,26 +204,42 @@ public class SysDeptServiceImpl implements ISysDeptService
/**
* 修改保存部门信息
*
*
* @param dept 部门信息
* @return 结果
*/
@Override
public int updateDept(SysDept dept)
{
public int updateDept(SysDept dept) {
SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId());
if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept))
{
if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) {
String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
String newAllName = "";
if (StringUtils.isEmpty(newParentDept.getAllName())) {
if (!StringUtils.isEmpty(dept.getShortName())) {
newAllName = dept.getShortName();
}
} else {
if (StringUtils.isEmpty(dept.getShortName())) {
newAllName = dept.getDeptName();
} else {
newAllName = newParentDept.getAllName() + "/" + dept.getShortName();
}
}
String oldAncestors = oldDept.getAncestors();
dept.setAncestors(newAncestors);
updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
dept.setAllName(newAllName);
String oldAllName = oldDept.getAllName();
updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors, newAllName, oldAllName);
} else {
String newAllName = dept.getShortName();
String oldAllName = oldDept.getAllName();
dept.setAllName(dept.getShortName());
updateDeptChildrenNew(dept.getDeptId(), newAllName, oldAllName);
}
int result = deptMapper.updateDept(dept);
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
&& !StringUtils.equals("0", dept.getAncestors()))
{
&& !StringUtils.equals("0", dept.getAncestors())) {
// 如果该部门是启用状态,则启用该部门的所有上级部门
updateParentDeptStatusNormal(dept);
}
@ -251,11 +248,10 @@ public class SysDeptServiceImpl implements ISysDeptService
/**
* 修改该部门的父级部门状态
*
*
* @param dept 当前部门
*/
private void updateParentDeptStatusNormal(SysDept dept)
{
private void updateParentDeptStatusNormal(SysDept dept) {
String ancestors = dept.getAncestors();
Long[] deptIds = Convert.toLongArray(ancestors);
deptMapper.updateDeptStatusNormal(deptIds);
@ -263,48 +259,62 @@ public class SysDeptServiceImpl implements ISysDeptService
/**
* 修改子元素关系
*
* @param deptId 被修改的部门ID
*
* @param deptId 被修改的部门ID
* @param newAncestors 新的父ID集合
* @param oldAncestors 旧的父ID集合
*/
public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors)
{
public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors, String newAllName, String oldAllName) {
List<SysDept> children = deptMapper.selectChildrenDeptById(deptId);
for (SysDept child : children)
{
for (SysDept child : children) {
child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors));
if (!StringUtils.isEmpty(child.getAllName())) {
child.setAllName(child.getAllName().replaceFirst(oldAllName, newAllName));
}
}
if (children.size() > 0) {
deptMapper.updateDeptChildren(children);
}
}
/**
* 修改子元素关系
*
* @param deptId 被修改的部门ID
* @param newAllName 新的父ID集合
*/
public void updateDeptChildrenNew(Long deptId, String newAllName, String oldAllName) {
List<SysDept> children = deptMapper.selectChildrenDeptById(deptId);
for (SysDept child : children) {
if (!StringUtils.isEmpty(child.getAllName())) {
child.setAllName(child.getAllName().replaceFirst(oldAllName, newAllName));
}
}
if (children.size() > 0)
{
if (children.size() > 0) {
deptMapper.updateDeptChildren(children);
}
}
/**
* 删除部门管理信息
*
*
* @param deptId 部门ID
* @return 结果
*/
@Override
public int deleteDeptById(Long deptId)
{
public int deleteDeptById(Long deptId) {
return deptMapper.deleteDeptById(deptId);
}
/**
* 递归列表
*/
private void recursionFn(List<SysDept> list, SysDept t)
{
private void recursionFn(List<SysDept> list, SysDept t) {
// 得到子节点列表
List<SysDept> childList = getChildList(list, t);
t.setChildren(childList);
for (SysDept tChild : childList)
{
if (hasChild(list, tChild))
{
for (SysDept tChild : childList) {
if (hasChild(list, tChild)) {
recursionFn(list, tChild);
}
}
@ -313,15 +323,12 @@ public class SysDeptServiceImpl implements ISysDeptService
/**
* 得到子节点列表
*/
private List<SysDept> getChildList(List<SysDept> list, SysDept t)
{
private List<SysDept> getChildList(List<SysDept> list, SysDept t) {
List<SysDept> tlist = new ArrayList<SysDept>();
Iterator<SysDept> it = list.iterator();
while (it.hasNext())
{
while (it.hasNext()) {
SysDept n = (SysDept) it.next();
if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue())
{
if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue()) {
tlist.add(n);
}
}
@ -331,8 +338,7 @@ public class SysDeptServiceImpl implements ISysDeptService
/**
* 判断是否有子节点
*/
private boolean hasChild(List<SysDept> list, SysDept t)
{
private boolean hasChild(List<SysDept> list, SysDept t) {
return getChildList(list, t).size() > 0;
}
}

24
lzbi-system/src/main/resources/mapper/system/SysDeptMapper.xml

@ -20,12 +20,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="deptClass" column="dept_class" />
<result property="shortName" column="short_name"/>
<result property="allName" column="all_name"/>
<result property="orgType" column="org_type"/>
</resultMap>
<sql id="selectDeptVo">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time ,d.dept_class
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time,d.short_name,d.all_name,d.org_type
from sys_dept d
</sql>
@ -61,7 +63,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status,
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status,d.short_name,d.all_name,d.org_type,
(select dept_name from sys_dept where dept_id = d.parent_id) parent_name
from sys_dept d
where d.dept_id = #{deptId}
@ -101,6 +103,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="email != null and email != ''">email,</if>
<if test="status != null">status,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="shortName != null and shortName != ''">short_name,</if>
<if test="allName != null and allName != ''">all_name,</if>
<if test="orgType != null and orgType != ''">org_type,</if>
create_time
)values(
<if test="deptId != null and deptId != 0">#{deptId},</if>
@ -113,6 +118,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="email != null and email != ''">#{email},</if>
<if test="status != null">#{status},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="shortName != null and shortName != ''">#{shortName},</if>
<if test="allName != null and allName != ''">#{allName},</if>
<if test="orgType != null and orgType != ''">#{orgType},</if>
sysdate()
)
</insert>
@ -129,6 +137,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="email != null">email = #{email},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="shortName != null and shortName != ''">short_name = #{shortName},</if>
<if test="allName != null and allName != ''">all_name = #{allName},</if>
<if test="orgType != null and orgType != ''">org_type = #{orgType},</if>
update_time = sysdate()
</set>
where dept_id = #{deptId}
@ -139,7 +150,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<foreach collection="depts" item="item" index="index"
separator=" " open="case dept_id" close="end">
when #{item.deptId} then #{item.ancestors}
</foreach>
</foreach>,
all_name =
<foreach collection="depts" item="item" index="index"
separator=" " open="case dept_id" close="end">
when #{item.deptId} then #{item.allName}
</foreach>
where dept_id in
<foreach collection="depts" item="item" index="index"
separator="," open="(" close=")">

Loading…
Cancel
Save