diff --git a/lzbi-common/pom.xml b/lzbi-common/pom.xml index 99cf4f1..5be82e3 100644 --- a/lzbi-common/pom.xml +++ b/lzbi-common/pom.xml @@ -141,6 +141,7 @@ com.oracle ojdbc14 10.2.0.3.0 + pom diff --git a/lzbi-common/src/main/java/com/lzbi/common/core/domain/TreeSelect.java b/lzbi-common/src/main/java/com/lzbi/common/core/domain/TreeSelect.java index 94d9809..6b09d67 100644 --- a/lzbi-common/src/main/java/com/lzbi/common/core/domain/TreeSelect.java +++ b/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 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 getChildren() - { + public List getChildren() { return children; } - public void setChildren(List children) - { + public void setChildren(List 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; + } + } diff --git a/lzbi-common/src/main/java/com/lzbi/common/core/domain/entity/SysDept.java b/lzbi-common/src/main/java/com/lzbi/common/core/domain/entity/SysDept.java index 8679841..78d633a 100644 --- a/lzbi-common/src/main/java/com/lzbi/common/core/domain/entity/SysDept.java +++ b/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 children = new ArrayList(); @@ -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(); } } diff --git a/lzbi-module/src/main/java/com/lzbi/asset/controller/DcBaseAssetInfoController.java b/lzbi-module/src/main/java/com/lzbi/asset/controller/DcBaseAssetInfoController.java new file mode 100644 index 0000000..f087fff --- /dev/null +++ b/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 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 list = dcBaseAssetInfoService.selectDcBaseAssetInfoList(dcBaseAssetInfo); + ExcelUtil util = new ExcelUtil(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)); + } +} diff --git a/lzbi-module/src/main/java/com/lzbi/asset/domain/DcBaseAssetInfo.java b/lzbi-module/src/main/java/com/lzbi/asset/domain/DcBaseAssetInfo.java new file mode 100644 index 0000000..1181f85 --- /dev/null +++ b/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(); + } +} diff --git a/lzbi-module/src/main/java/com/lzbi/asset/mapper/DcBaseAssetInfoMapper.java b/lzbi-module/src/main/java/com/lzbi/asset/mapper/DcBaseAssetInfoMapper.java new file mode 100644 index 0000000..de06faf --- /dev/null +++ b/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 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); +} diff --git a/lzbi-module/src/main/java/com/lzbi/asset/service/IDcBaseAssetInfoService.java b/lzbi-module/src/main/java/com/lzbi/asset/service/IDcBaseAssetInfoService.java new file mode 100644 index 0000000..09ba29e --- /dev/null +++ b/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 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); +} diff --git a/lzbi-module/src/main/java/com/lzbi/asset/service/impl/DcBaseAssetInfoServiceImpl.java b/lzbi-module/src/main/java/com/lzbi/asset/service/impl/DcBaseAssetInfoServiceImpl.java new file mode 100644 index 0000000..a1cec8e --- /dev/null +++ b/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 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); + } +} diff --git a/lzbi-module/src/main/resources/mapper/asset/DcBaseAssetInfoMapper.xml b/lzbi-module/src/main/resources/mapper/asset/DcBaseAssetInfoMapper.xml new file mode 100644 index 0000000..abf2616 --- /dev/null +++ b/lzbi-module/src/main/resources/mapper/asset/DcBaseAssetInfoMapper.xml @@ -0,0 +1,154 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + + + + + insert into dc_base_asset_info + + TENANT_ID, + REVISION, + CREATED_BY, + CREATED_TIME, + UPDATED_BY, + UPDATED_TIME, + DELETE_BY, + DELETE_TIME, + asset_name, + asset_code, + asset_class, + flag_validate_dept, + flag_validate_role, + flag_validate_user, + status_asset, + comany_id, + dept_id, + + + #{tenantId}, + #{REVISION}, + #{createdBy}, + #{createdTime}, + #{updatedBy}, + #{updatedTime}, + #{deleteBy}, + #{deleteTime}, + #{assetName}, + #{assetCode}, + #{assetClass}, + #{flagValidateDept}, + #{flagValidateRole}, + #{flagValidateUser}, + #{statusAsset}, + #{comanyId}, + #{deptId}, + + + + + update dc_base_asset_info + + TENANT_ID = #{tenantId}, + REVISION = #{REVISION}, + CREATED_BY = #{createdBy}, + CREATED_TIME = #{createdTime}, + UPDATED_BY = #{updatedBy}, + UPDATED_TIME = #{updatedTime}, + DELETE_BY = #{deleteBy}, + DELETE_TIME = #{deleteTime}, + asset_name = #{assetName}, + asset_code = #{assetCode}, + asset_class = #{assetClass}, + flag_validate_dept = #{flagValidateDept}, + flag_validate_role = #{flagValidateRole}, + flag_validate_user = #{flagValidateUser}, + status_asset = #{statusAsset}, + comany_id = #{comanyId}, + dept_id = #{deptId}, + + where id = #{id} + + + + delete + from dc_base_asset_info + where id = #{id} + + + + delete from dc_base_asset_info where id in + + #{id} + + + \ No newline at end of file diff --git a/lzbi-system/src/main/java/com/lzbi/system/service/impl/SysDeptServiceImpl.java b/lzbi-system/src/main/java/com/lzbi/system/service/impl/SysDeptServiceImpl.java index 15eaf6d..0515b5e 100644 --- a/lzbi-system/src/main/java/com/lzbi/system/service/impl/SysDeptServiceImpl.java +++ b/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 selectDeptList(SysDept dept) - { + public List selectDeptList(SysDept dept) { return deptMapper.selectDeptList(dept); } /** * 查询部门树结构信息 - * + * * @param dept 部门信息 * @return 部门树信息集合 */ @Override - public List selectDeptTreeList(SysDept dept) - { + public List selectDeptTreeList(SysDept dept) { List depts = SpringUtils.getAopProxy(this).selectDeptList(dept); return buildDeptTreeSelect(depts); } /** * 构建前端所需要树结构 - * + * * @param depts 部门列表 * @return 树结构列表 */ @Override - public List buildDeptTree(List depts) - { + public List buildDeptTree(List depts) { List returnList = new ArrayList(); List 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 buildDeptTreeSelect(List depts) - { + public List buildDeptTreeSelect(List depts) { List deptTrees = buildDeptTree(depts); return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList()); } /** * 根据角色ID查询部门树信息 - * + * * @param roleId 角色ID * @return 选中部门列表 */ @Override - public List selectDeptListByRoleId(Long roleId) - { + public List 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 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 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 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 list, SysDept t) - { + private void recursionFn(List list, SysDept t) { // 得到子节点列表 List 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 getChildList(List list, SysDept t) - { + private List getChildList(List list, SysDept t) { List tlist = new ArrayList(); Iterator 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 list, SysDept t) - { + private boolean hasChild(List list, SysDept t) { return getChildList(list, t).size() > 0; } } diff --git a/lzbi-system/src/main/resources/mapper/system/SysDeptMapper.xml b/lzbi-system/src/main/resources/mapper/system/SysDeptMapper.xml index 1cdffe7..6b0ae77 100644 --- a/lzbi-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/lzbi-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -20,12 +20,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + + + - 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 @@ -61,7 +63,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"