| @@ -1,48 +1,52 @@ | |||||
| package com.ruoyi.web.controller.system; | package com.ruoyi.web.controller.system; | ||||
| import java.util.List; | |||||
| import org.apache.commons.lang3.ArrayUtils; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.security.access.prepost.PreAuthorize; | |||||
| import org.springframework.validation.annotation.Validated; | |||||
| import org.springframework.web.bind.annotation.DeleteMapping; | |||||
| import org.springframework.web.bind.annotation.GetMapping; | |||||
| import org.springframework.web.bind.annotation.PathVariable; | |||||
| import org.springframework.web.bind.annotation.PostMapping; | |||||
| import org.springframework.web.bind.annotation.PutMapping; | |||||
| import org.springframework.web.bind.annotation.RequestBody; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| import com.ruoyi.common.annotation.Log; | import com.ruoyi.common.annotation.Log; | ||||
| import com.ruoyi.common.constant.UserConstants; | import com.ruoyi.common.constant.UserConstants; | ||||
| import com.ruoyi.common.core.controller.BaseController; | import com.ruoyi.common.core.controller.BaseController; | ||||
| import com.ruoyi.common.core.domain.AjaxResult; | import com.ruoyi.common.core.domain.AjaxResult; | ||||
| import com.ruoyi.common.core.domain.entity.SysDept; | import com.ruoyi.common.core.domain.entity.SysDept; | ||||
| import com.ruoyi.common.core.domain.entity.SysUser; | |||||
| import com.ruoyi.common.core.domain.model.LoginUser; | |||||
| import com.ruoyi.common.core.page.TableDataInfo; | |||||
| import com.ruoyi.common.enums.BusinessType; | import com.ruoyi.common.enums.BusinessType; | ||||
| import com.ruoyi.common.utils.ServletUtils; | |||||
| import com.ruoyi.common.utils.StringUtils; | import com.ruoyi.common.utils.StringUtils; | ||||
| import com.ruoyi.common.utils.poi.ExcelUtil; | |||||
| import com.ruoyi.framework.web.service.TokenService; | |||||
| import com.ruoyi.system.service.ISysDeptService; | import com.ruoyi.system.service.ISysDeptService; | ||||
| import org.apache.commons.lang3.ArrayUtils; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.security.access.prepost.PreAuthorize; | |||||
| import org.springframework.validation.annotation.Validated; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import org.springframework.web.multipart.MultipartFile; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| import java.util.List; | |||||
| /** | /** | ||||
| * 部门信息 | * 部门信息 | ||||
| * | |||||
| * | |||||
| * @author ruoyi | * @author ruoyi | ||||
| */ | */ | ||||
| @RestController | @RestController | ||||
| @RequestMapping("/system/dept") | @RequestMapping("/system/dept") | ||||
| public class SysDeptController extends BaseController | |||||
| { | |||||
| public class SysDeptController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| private ISysDeptService deptService; | private ISysDeptService deptService; | ||||
| @Autowired | |||||
| private TokenService tokenService; | |||||
| /** | /** | ||||
| * 获取部门列表 | * 获取部门列表 | ||||
| */ | */ | ||||
| @PreAuthorize("@ss.hasPermi('system:dept:list')") | @PreAuthorize("@ss.hasPermi('system:dept:list')") | ||||
| @GetMapping("/list") | @GetMapping("/list") | ||||
| public AjaxResult list(SysDept dept) | |||||
| { | |||||
| public TableDataInfo list(SysDept dept) { | |||||
| startPage(); | |||||
| List<SysDept> depts = deptService.selectDeptList(dept); | List<SysDept> depts = deptService.selectDeptList(dept); | ||||
| return success(depts); | |||||
| return getDataTable(depts); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -50,8 +54,7 @@ public class SysDeptController extends BaseController | |||||
| */ | */ | ||||
| @PreAuthorize("@ss.hasPermi('system:dept:list')") | @PreAuthorize("@ss.hasPermi('system:dept:list')") | ||||
| @GetMapping("/list/exclude/{deptId}") | @GetMapping("/list/exclude/{deptId}") | ||||
| public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) | |||||
| { | |||||
| public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) { | |||||
| List<SysDept> depts = deptService.selectDeptList(new SysDept()); | List<SysDept> depts = deptService.selectDeptList(new SysDept()); | ||||
| depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")); | depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")); | ||||
| return success(depts); | return success(depts); | ||||
| @@ -62,8 +65,7 @@ public class SysDeptController extends BaseController | |||||
| */ | */ | ||||
| @PreAuthorize("@ss.hasPermi('system:dept:query')") | @PreAuthorize("@ss.hasPermi('system:dept:query')") | ||||
| @GetMapping(value = "/{deptId}") | @GetMapping(value = "/{deptId}") | ||||
| public AjaxResult getInfo(@PathVariable Long deptId) | |||||
| { | |||||
| public AjaxResult getInfo(@PathVariable Long deptId) { | |||||
| deptService.checkDeptDataScope(deptId); | deptService.checkDeptDataScope(deptId); | ||||
| return success(deptService.selectDeptById(deptId)); | return success(deptService.selectDeptById(deptId)); | ||||
| } | } | ||||
| @@ -74,10 +76,8 @@ public class SysDeptController extends BaseController | |||||
| @PreAuthorize("@ss.hasPermi('system:dept:add')") | @PreAuthorize("@ss.hasPermi('system:dept:add')") | ||||
| @Log(title = "部门管理", businessType = BusinessType.INSERT) | @Log(title = "部门管理", businessType = BusinessType.INSERT) | ||||
| @PostMapping | @PostMapping | ||||
| public AjaxResult add(@Validated @RequestBody SysDept dept) | |||||
| { | |||||
| if (!deptService.checkDeptNameUnique(dept)) | |||||
| { | |||||
| public AjaxResult add(@Validated @RequestBody SysDept dept) { | |||||
| if (!deptService.checkDeptNameUnique(dept)) { | |||||
| return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在"); | return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在"); | ||||
| } | } | ||||
| dept.setCreateBy(getUsername()); | dept.setCreateBy(getUsername()); | ||||
| @@ -90,20 +90,14 @@ public class SysDeptController extends BaseController | |||||
| @PreAuthorize("@ss.hasPermi('system:dept:edit')") | @PreAuthorize("@ss.hasPermi('system:dept:edit')") | ||||
| @Log(title = "部门管理", businessType = BusinessType.UPDATE) | @Log(title = "部门管理", businessType = BusinessType.UPDATE) | ||||
| @PutMapping | @PutMapping | ||||
| public AjaxResult edit(@Validated @RequestBody SysDept dept) | |||||
| { | |||||
| public AjaxResult edit(@Validated @RequestBody SysDept dept) { | |||||
| Long deptId = dept.getDeptId(); | Long deptId = dept.getDeptId(); | ||||
| deptService.checkDeptDataScope(deptId); | deptService.checkDeptDataScope(deptId); | ||||
| if (!deptService.checkDeptNameUnique(dept)) | |||||
| { | |||||
| if (!deptService.checkDeptNameUnique(dept)) { | |||||
| return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在"); | return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在"); | ||||
| } | |||||
| else if (dept.getParentId().equals(deptId)) | |||||
| { | |||||
| } else if (dept.getParentId().equals(deptId)) { | |||||
| return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); | return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); | ||||
| } | |||||
| else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0) | |||||
| { | |||||
| } else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0) { | |||||
| return error("该部门包含未停用的子部门!"); | return error("该部门包含未停用的子部门!"); | ||||
| } | } | ||||
| dept.setUpdateBy(getUsername()); | dept.setUpdateBy(getUsername()); | ||||
| @@ -116,17 +110,54 @@ public class SysDeptController extends BaseController | |||||
| @PreAuthorize("@ss.hasPermi('system:dept:remove')") | @PreAuthorize("@ss.hasPermi('system:dept:remove')") | ||||
| @Log(title = "部门管理", businessType = BusinessType.DELETE) | @Log(title = "部门管理", businessType = BusinessType.DELETE) | ||||
| @DeleteMapping("/{deptId}") | @DeleteMapping("/{deptId}") | ||||
| public AjaxResult remove(@PathVariable Long deptId) | |||||
| { | |||||
| if (deptService.hasChildByDeptId(deptId)) | |||||
| { | |||||
| public AjaxResult remove(@PathVariable Long deptId) { | |||||
| if (deptService.hasChildByDeptId(deptId)) { | |||||
| return warn("存在下级部门,不允许删除"); | return warn("存在下级部门,不允许删除"); | ||||
| } | } | ||||
| if (deptService.checkDeptExistUser(deptId)) | |||||
| { | |||||
| if (deptService.checkDeptExistUser(deptId)) { | |||||
| return warn("部门存在用户,不允许删除"); | return warn("部门存在用户,不允许删除"); | ||||
| } | } | ||||
| deptService.checkDeptDataScope(deptId); | deptService.checkDeptDataScope(deptId); | ||||
| return toAjax(deptService.deleteDeptById(deptId)); | return toAjax(deptService.deleteDeptById(deptId)); | ||||
| } | } | ||||
| /** | |||||
| * 部门导入模板 | |||||
| */ | |||||
| @PostMapping("/importTemplate") | |||||
| public void importTemplate(HttpServletResponse response) { | |||||
| ExcelUtil<SysDept> util = new ExcelUtil<SysDept>(SysDept.class); | |||||
| util.importTemplateExcel(response, "部门数据"); | |||||
| } | |||||
| /** | |||||
| * 部门导入 | |||||
| */ | |||||
| @Log(title = "部门", businessType = BusinessType.IMPORT) | |||||
| @PreAuthorize("@ss.hasPermi('system:dept:import')") | |||||
| @PostMapping("/importData") | |||||
| public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception { | |||||
| ExcelUtil<SysDept> util = new ExcelUtil<SysDept>(SysDept.class); | |||||
| List<SysDept> list = util.importExcel(file.getInputStream(), 0); | |||||
| String message = deptService.importSysDept(list, updateSupport, getUsername()); | |||||
| return AjaxResult.success(message); | |||||
| } | |||||
| /** | |||||
| * 更新所有部门的坐标信息 | |||||
| */ | |||||
| //@ApiOperation("更新所有部门的坐标信息") | |||||
| @PreAuthorize("@ss.hasPermi('system:dept:point')") | |||||
| @GetMapping("/coordinatesUpdate") | |||||
| public AjaxResult coordinatesUpdate() { | |||||
| if(deptService.coordinatesUpdateRunning()) | |||||
| return AjaxResult.success("最近的任务正在处理中,请等待完成结果"); | |||||
| LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); | |||||
| SysUser user = loginUser.getUser(); | |||||
| SysDept dept = new SysDept(); | |||||
| List<SysDept> deptList = deptService.selectDeptList(dept); | |||||
| deptService.coordinatesUpdate(deptList, user); | |||||
| return AjaxResult.success("处理中,请等待..."); | |||||
| } | |||||
| } | } | ||||
| @@ -0,0 +1,4 @@ | |||||
| # 天地图 | |||||
| map: | |||||
| world: | |||||
| key: cc4aba6e967096098249efa069733067 | |||||
| @@ -1,118 +1,130 @@ | |||||
| package com.ruoyi.common.core.domain; | package com.ruoyi.common.core.domain; | ||||
| import com.fasterxml.jackson.annotation.JsonFormat; | |||||
| import com.fasterxml.jackson.annotation.JsonIgnore; | |||||
| import com.fasterxml.jackson.annotation.JsonInclude; | |||||
| import java.io.Serializable; | import java.io.Serializable; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.HashMap; | import java.util.HashMap; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| import com.fasterxml.jackson.annotation.JsonFormat; | |||||
| import com.fasterxml.jackson.annotation.JsonIgnore; | |||||
| import com.fasterxml.jackson.annotation.JsonInclude; | |||||
| /** | /** | ||||
| * Entity基类 | * Entity基类 | ||||
| * | |||||
| * | |||||
| * @author ruoyi | * @author ruoyi | ||||
| */ | */ | ||||
| public class BaseEntity implements Serializable | |||||
| { | |||||
| public class BaseEntity implements Serializable { | |||||
| private static final long serialVersionUID = 1L; | private static final long serialVersionUID = 1L; | ||||
| /** 搜索值 */ | |||||
| /** | |||||
| * 搜索值 | |||||
| */ | |||||
| @JsonIgnore | @JsonIgnore | ||||
| private String searchValue; | private String searchValue; | ||||
| /** 创建者 */ | |||||
| /** | |||||
| * 创建者 | |||||
| */ | |||||
| private String createBy; | private String createBy; | ||||
| /** 创建时间 */ | |||||
| /** | |||||
| * 创建时间 | |||||
| */ | |||||
| @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | ||||
| private Date createTime; | private Date createTime; | ||||
| /** 更新者 */ | |||||
| /** | |||||
| * 更新者 | |||||
| */ | |||||
| private String updateBy; | private String updateBy; | ||||
| /** 更新时间 */ | |||||
| /** | |||||
| * 更新时间 | |||||
| */ | |||||
| @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | ||||
| private Date updateTime; | private Date updateTime; | ||||
| /** 备注 */ | |||||
| /** | |||||
| * 备注 | |||||
| */ | |||||
| private String remark; | private String remark; | ||||
| /** 请求参数 */ | |||||
| /** | |||||
| * 请求参数 | |||||
| */ | |||||
| @JsonInclude(JsonInclude.Include.NON_EMPTY) | @JsonInclude(JsonInclude.Include.NON_EMPTY) | ||||
| private Map<String, Object> params; | private Map<String, Object> params; | ||||
| public String getSearchValue() | |||||
| { | |||||
| public String getSearchValue() { | |||||
| return searchValue; | return searchValue; | ||||
| } | } | ||||
| public void setSearchValue(String searchValue) | |||||
| { | |||||
| public void setSearchValue(String searchValue) { | |||||
| this.searchValue = searchValue; | this.searchValue = searchValue; | ||||
| } | } | ||||
| public String getCreateBy() | |||||
| { | |||||
| public String getCreateBy() { | |||||
| return createBy; | return createBy; | ||||
| } | } | ||||
| public void setCreateBy(String createBy) | |||||
| { | |||||
| public void setCreateBy(String createBy) { | |||||
| this.createBy = createBy; | this.createBy = createBy; | ||||
| } | } | ||||
| public Date getCreateTime() | |||||
| { | |||||
| public Date getCreateTime() { | |||||
| return createTime; | return createTime; | ||||
| } | } | ||||
| public void setCreateTime(Date createTime) | |||||
| { | |||||
| public void setCreateTime(Date createTime) { | |||||
| this.createTime = createTime; | this.createTime = createTime; | ||||
| } | } | ||||
| public String getUpdateBy() | |||||
| { | |||||
| public String getUpdateBy() { | |||||
| return updateBy; | return updateBy; | ||||
| } | } | ||||
| public void setUpdateBy(String updateBy) | |||||
| { | |||||
| public void setUpdateBy(String updateBy) { | |||||
| this.updateBy = updateBy; | this.updateBy = updateBy; | ||||
| } | } | ||||
| public Date getUpdateTime() | |||||
| { | |||||
| public Date getUpdateTime() { | |||||
| return updateTime; | return updateTime; | ||||
| } | } | ||||
| public void setUpdateTime(Date updateTime) | |||||
| { | |||||
| public void setUpdateTime(Date updateTime) { | |||||
| this.updateTime = updateTime; | this.updateTime = updateTime; | ||||
| } | } | ||||
| public String getRemark() | |||||
| { | |||||
| public String getRemark() { | |||||
| return remark; | return remark; | ||||
| } | } | ||||
| public void setRemark(String remark) | |||||
| { | |||||
| public void setRemark(String remark) { | |||||
| this.remark = remark; | this.remark = remark; | ||||
| } | } | ||||
| public Map<String, Object> getParams() | |||||
| { | |||||
| if (params == null) | |||||
| { | |||||
| public Map<String, Object> getParams() { | |||||
| if (params == null) { | |||||
| params = new HashMap<>(); | params = new HashMap<>(); | ||||
| } | } | ||||
| return params; | return params; | ||||
| } | } | ||||
| public void setParams(Map<String, Object> params) | |||||
| { | |||||
| public void setParams(Map<String, Object> params) { | |||||
| this.params = params; | this.params = params; | ||||
| } | } | ||||
| public Object obtainParam(String name) { | |||||
| if (params == null) | |||||
| return null; | |||||
| return params.get(name); | |||||
| } | |||||
| @SuppressWarnings("unchecked") | |||||
| public <T extends BaseEntity> T putParam(String name, Object value) { | |||||
| getParams().put(name, value); | |||||
| return (T) this; | |||||
| } | |||||
| } | } | ||||
| @@ -1,18 +1,20 @@ | |||||
| package com.ruoyi.common.core.domain.entity; | package com.ruoyi.common.core.domain.entity; | ||||
| import java.util.ArrayList; | |||||
| import java.util.List; | |||||
| import com.ruoyi.common.annotation.Excel; | |||||
| import com.ruoyi.common.core.domain.BaseEntity; | |||||
| import org.apache.commons.lang3.builder.ToStringBuilder; | |||||
| import org.apache.commons.lang3.builder.ToStringStyle; | |||||
| import javax.validation.constraints.Email; | import javax.validation.constraints.Email; | ||||
| import javax.validation.constraints.NotBlank; | import javax.validation.constraints.NotBlank; | ||||
| import javax.validation.constraints.NotNull; | import javax.validation.constraints.NotNull; | ||||
| import javax.validation.constraints.Size; | import javax.validation.constraints.Size; | ||||
| import org.apache.commons.lang3.builder.ToStringBuilder; | |||||
| import org.apache.commons.lang3.builder.ToStringStyle; | |||||
| import com.ruoyi.common.core.domain.BaseEntity; | |||||
| import java.util.ArrayList; | |||||
| import java.util.List; | |||||
| /** | /** | ||||
| * 部门表 sys_dept | * 部门表 sys_dept | ||||
| * | |||||
| * | |||||
| * @author ruoyi | * @author ruoyi | ||||
| */ | */ | ||||
| public class SysDept extends BaseEntity | public class SysDept extends BaseEntity | ||||
| @@ -20,6 +22,7 @@ public class SysDept extends BaseEntity | |||||
| private static final long serialVersionUID = 1L; | private static final long serialVersionUID = 1L; | ||||
| /** 部门ID */ | /** 部门ID */ | ||||
| @Excel(name = "部门ID", type = Excel.Type.EXPORT) | |||||
| private Long deptId; | private Long deptId; | ||||
| /** 父部门ID */ | /** 父部门ID */ | ||||
| @@ -29,6 +32,7 @@ public class SysDept extends BaseEntity | |||||
| private String ancestors; | private String ancestors; | ||||
| /** 部门名称 */ | /** 部门名称 */ | ||||
| @Excel(name = "部门名称") | |||||
| private String deptName; | private String deptName; | ||||
| /** 显示顺序 */ | /** 显示顺序 */ | ||||
| @@ -51,10 +55,26 @@ public class SysDept extends BaseEntity | |||||
| /** 父部门名称 */ | /** 父部门名称 */ | ||||
| private String parentName; | private String parentName; | ||||
| /** 导入代码 */ | |||||
| @Excel(name = "导入代码") | |||||
| private String importCode; | |||||
| /** 行政代码 */ | |||||
| @Excel(name = "行政代码") | |||||
| private String orgCode; | |||||
| /** 经度 */ | |||||
| private String longitude; | |||||
| /** 纬度 */ | |||||
| private String latitude; | |||||
| /** 子部门 */ | /** 子部门 */ | ||||
| private List<SysDept> children = new ArrayList<SysDept>(); | private List<SysDept> children = new ArrayList<SysDept>(); | ||||
| public Long getDeptId() | public Long getDeptId() | ||||
| { | { | ||||
| return deptId; | return deptId; | ||||
| @@ -181,6 +201,38 @@ public class SysDept extends BaseEntity | |||||
| this.children = children; | this.children = children; | ||||
| } | } | ||||
| public String getImportCode() { | |||||
| return importCode; | |||||
| } | |||||
| public void setImportCode(String importCode) { | |||||
| this.importCode = importCode; | |||||
| } | |||||
| public String getOrgCode() { | |||||
| return orgCode; | |||||
| } | |||||
| public void setOrgCode(String orgCode) { | |||||
| this.orgCode = orgCode; | |||||
| } | |||||
| public String getLongitude() { | |||||
| return longitude; | |||||
| } | |||||
| public void setLongitude(String longitude) { | |||||
| this.longitude = longitude; | |||||
| } | |||||
| public String getLatitude() { | |||||
| return latitude; | |||||
| } | |||||
| public void setLatitude(String latitude) { | |||||
| this.latitude = latitude; | |||||
| } | |||||
| @Override | @Override | ||||
| public String toString() { | public String toString() { | ||||
| return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) | return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) | ||||
| @@ -0,0 +1,88 @@ | |||||
| package com.ruoyi.common.utils; | |||||
| import cn.hutool.core.util.URLUtil; | |||||
| import lombok.extern.slf4j.Slf4j; | |||||
| import java.io.BufferedReader; | |||||
| import java.io.IOException; | |||||
| import java.io.InputStreamReader; | |||||
| import java.net.MalformedURLException; | |||||
| import java.net.URL; | |||||
| import java.net.URLConnection; | |||||
| import java.nio.charset.StandardCharsets; | |||||
| import java.util.HashMap; | |||||
| import java.util.Map; | |||||
| /** | |||||
| * @description: 天地图接口 | |||||
| * @author: zzl | |||||
| * @date: Created in 2021/8/9 15:22 | |||||
| * @version: v1.0 | |||||
| * @modified By: | |||||
| */ | |||||
| @Slf4j | |||||
| public class WorldMapUtils { | |||||
| public static void main(String[] args){ | |||||
| String info=getLonLat("环翠区","cc4aba6e967096098249efa069733067"); | |||||
| System.out.println("info:"+info); | |||||
| /** | |||||
| {"msg":"ok","location":{"level":"地名地址","lon":122.11852599978,"lat":37.50107099973,"keyWord":"环翠区"},"searchVersion":"6.0.0","status":"0"} | |||||
| */ | |||||
| } | |||||
| /** | |||||
| * @description 获取经纬度坐标 | |||||
| * @author zzl | |||||
| * @date 2021/8/9 15:41 | |||||
| * @param location | |||||
| * @param tk | |||||
| * @return java.lang.String | |||||
| */ | |||||
| public static String getLonLat(String location, String tk){ | |||||
| //拼接路径获取经度纬度 | |||||
| String name_org = "{\"keyWord\":\"" + location +"\"}"; | |||||
| Map<String, String> query = new HashMap<>(); | |||||
| query.put("ds", name_org); | |||||
| query.put("tk", tk); | |||||
| String queryStr = URLUtil.buildQuery(query, StandardCharsets.UTF_8); | |||||
| String urlAll ="https://api.tianditu.gov.cn/geocoder?"+ queryStr; | |||||
| log.info("请求天地图坐标:{}", urlAll); | |||||
| BufferedReader in = null; | |||||
| try { | |||||
| URL urlObject = new URL(urlAll); | |||||
| URLConnection uc = urlObject.openConnection(); | |||||
| uc.addRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"); | |||||
| in = new BufferedReader(new InputStreamReader(uc.getInputStream(),"UTF-8")); | |||||
| String line; | |||||
| StringBuilder result = new StringBuilder(); | |||||
| while ((line = in.readLine()) != null) { | |||||
| result.append(line); | |||||
| } | |||||
| String jsons = result.toString(); | |||||
| log.info("返回天地图坐标:{}", jsons); | |||||
| return jsons; | |||||
| } catch (MalformedURLException e) { | |||||
| e.printStackTrace(); | |||||
| log.error("坐标获取失败:{}", urlAll); | |||||
| return null; | |||||
| } catch (IOException e) { | |||||
| e.printStackTrace(); | |||||
| log.error("坐标获取失败:{}", urlAll); | |||||
| return null; | |||||
| }finally { | |||||
| if (in != null) { | |||||
| try { | |||||
| in.close(); | |||||
| } catch (IOException e) { | |||||
| e.printStackTrace(); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -752,6 +752,10 @@ export default { | |||||
| this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true }) | this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true }) | ||||
| this.getList() | this.getList() | ||||
| }, | }, | ||||
| // 提交上传文件 | |||||
| submitFileForm() { | |||||
| this.$refs.upload.submit() | |||||
| }, | |||||
| #foreach($column in $columns) | #foreach($column in $columns) | ||||
| #if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "fileUpload") | #if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "fileUpload") | ||||
| getFileIcon(file) { | getFileIcon(file) { | ||||
| @@ -0,0 +1,15 @@ | |||||
| package com.ruoyi.system.domain; | |||||
| import lombok.Data; | |||||
| @Data | |||||
| public class SysMapLocation { | |||||
| private String level; | |||||
| private String longitude; | |||||
| private String latitude; | |||||
| private String keyWord; | |||||
| } | |||||
| @@ -0,0 +1,15 @@ | |||||
| package com.ruoyi.system.domain; | |||||
| import lombok.Data; | |||||
| @Data | |||||
| public class SysMapLocation { | |||||
| private String level; | |||||
| private String lon; | |||||
| private String lat; | |||||
| private String keyWord; | |||||
| } | |||||
| @@ -0,0 +1,15 @@ | |||||
| package com.ruoyi.system.domain; | |||||
| import lombok.Data; | |||||
| @Data | |||||
| public class SysMapWorld { | |||||
| private String msg; | |||||
| private SysMapLocation location; | |||||
| private String searchVersion; | |||||
| private String status; | |||||
| } | |||||
| @@ -1,19 +1,20 @@ | |||||
| package com.ruoyi.system.mapper; | package com.ruoyi.system.mapper; | ||||
| import java.util.List; | |||||
| import org.apache.ibatis.annotations.Param; | |||||
| import com.ruoyi.common.core.domain.entity.SysDept; | import com.ruoyi.common.core.domain.entity.SysDept; | ||||
| import org.apache.ibatis.annotations.Param; | |||||
| import java.util.List; | |||||
| /** | /** | ||||
| * 部门管理 数据层 | * 部门管理 数据层 | ||||
| * | |||||
| * | |||||
| * @author ruoyi | * @author ruoyi | ||||
| */ | */ | ||||
| public interface SysDeptMapper | public interface SysDeptMapper | ||||
| { | { | ||||
| /** | /** | ||||
| * 查询部门管理数据 | * 查询部门管理数据 | ||||
| * | |||||
| * | |||||
| * @param dept 部门信息 | * @param dept 部门信息 | ||||
| * @return 部门信息集合 | * @return 部门信息集合 | ||||
| */ | */ | ||||
| @@ -21,7 +22,7 @@ public interface SysDeptMapper | |||||
| /** | /** | ||||
| * 根据角色ID查询部门树信息 | * 根据角色ID查询部门树信息 | ||||
| * | |||||
| * | |||||
| * @param roleId 角色ID | * @param roleId 角色ID | ||||
| * @param deptCheckStrictly 部门树选择项是否关联显示 | * @param deptCheckStrictly 部门树选择项是否关联显示 | ||||
| * @return 选中部门列表 | * @return 选中部门列表 | ||||
| @@ -30,7 +31,7 @@ public interface SysDeptMapper | |||||
| /** | /** | ||||
| * 根据部门ID查询信息 | * 根据部门ID查询信息 | ||||
| * | |||||
| * | |||||
| * @param deptId 部门ID | * @param deptId 部门ID | ||||
| * @return 部门信息 | * @return 部门信息 | ||||
| */ | */ | ||||
| @@ -38,7 +39,7 @@ public interface SysDeptMapper | |||||
| /** | /** | ||||
| * 根据ID查询所有子部门 | * 根据ID查询所有子部门 | ||||
| * | |||||
| * | |||||
| * @param deptId 部门ID | * @param deptId 部门ID | ||||
| * @return 部门列表 | * @return 部门列表 | ||||
| */ | */ | ||||
| @@ -46,7 +47,7 @@ public interface SysDeptMapper | |||||
| /** | /** | ||||
| * 根据ID查询所有子部门(正常状态) | * 根据ID查询所有子部门(正常状态) | ||||
| * | |||||
| * | |||||
| * @param deptId 部门ID | * @param deptId 部门ID | ||||
| * @return 子部门数 | * @return 子部门数 | ||||
| */ | */ | ||||
| @@ -54,7 +55,7 @@ public interface SysDeptMapper | |||||
| /** | /** | ||||
| * 是否存在子节点 | * 是否存在子节点 | ||||
| * | |||||
| * | |||||
| * @param deptId 部门ID | * @param deptId 部门ID | ||||
| * @return 结果 | * @return 结果 | ||||
| */ | */ | ||||
| @@ -62,7 +63,7 @@ public interface SysDeptMapper | |||||
| /** | /** | ||||
| * 查询部门是否存在用户 | * 查询部门是否存在用户 | ||||
| * | |||||
| * | |||||
| * @param deptId 部门ID | * @param deptId 部门ID | ||||
| * @return 结果 | * @return 结果 | ||||
| */ | */ | ||||
| @@ -70,7 +71,7 @@ public interface SysDeptMapper | |||||
| /** | /** | ||||
| * 校验部门名称是否唯一 | * 校验部门名称是否唯一 | ||||
| * | |||||
| * | |||||
| * @param deptName 部门名称 | * @param deptName 部门名称 | ||||
| * @param parentId 父部门ID | * @param parentId 父部门ID | ||||
| * @return 结果 | * @return 结果 | ||||
| @@ -79,7 +80,7 @@ public interface SysDeptMapper | |||||
| /** | /** | ||||
| * 新增部门信息 | * 新增部门信息 | ||||
| * | |||||
| * | |||||
| * @param dept 部门信息 | * @param dept 部门信息 | ||||
| * @return 结果 | * @return 结果 | ||||
| */ | */ | ||||
| @@ -87,7 +88,7 @@ public interface SysDeptMapper | |||||
| /** | /** | ||||
| * 修改部门信息 | * 修改部门信息 | ||||
| * | |||||
| * | |||||
| * @param dept 部门信息 | * @param dept 部门信息 | ||||
| * @return 结果 | * @return 结果 | ||||
| */ | */ | ||||
| @@ -95,14 +96,14 @@ public interface SysDeptMapper | |||||
| /** | /** | ||||
| * 修改所在部门正常状态 | * 修改所在部门正常状态 | ||||
| * | |||||
| * | |||||
| * @param deptIds 部门ID组 | * @param deptIds 部门ID组 | ||||
| */ | */ | ||||
| public void updateDeptStatusNormal(Long[] deptIds); | public void updateDeptStatusNormal(Long[] deptIds); | ||||
| /** | /** | ||||
| * 修改子元素关系 | * 修改子元素关系 | ||||
| * | |||||
| * | |||||
| * @param depts 子元素 | * @param depts 子元素 | ||||
| * @return 结果 | * @return 结果 | ||||
| */ | */ | ||||
| @@ -110,9 +111,33 @@ public interface SysDeptMapper | |||||
| /** | /** | ||||
| * 删除部门管理信息 | * 删除部门管理信息 | ||||
| * | |||||
| * | |||||
| * @param deptId 部门ID | * @param deptId 部门ID | ||||
| * @return 结果 | * @return 结果 | ||||
| */ | */ | ||||
| public int deleteDeptById(Long deptId); | public int deleteDeptById(Long deptId); | ||||
| /** | |||||
| * 批量修改 部门 | |||||
| * | |||||
| * @param list 部门 | |||||
| * @return 结果 | |||||
| */ | |||||
| public int updateSysDeptBatch(List<SysDept> list); | |||||
| /** | |||||
| * 批量新增部门 | |||||
| * | |||||
| * @param list 部门 | |||||
| * @return 结果 | |||||
| */ | |||||
| public int insertSysDeptBatch(List<SysDept> list); | |||||
| public int deleteAllDept(); | |||||
| public SysDept selectDeptByOrgCode(String orgCode); | |||||
| public SysDept selectDeptByImportCode(String importCode); | |||||
| public Long selectDeptNextOrderNum(SysDept sysDept); | |||||
| } | } | ||||
| @@ -1,19 +1,21 @@ | |||||
| package com.ruoyi.system.service; | package com.ruoyi.system.service; | ||||
| import java.util.List; | |||||
| import com.ruoyi.common.core.domain.TreeSelect; | import com.ruoyi.common.core.domain.TreeSelect; | ||||
| import com.ruoyi.common.core.domain.entity.SysDept; | import com.ruoyi.common.core.domain.entity.SysDept; | ||||
| import com.ruoyi.common.core.domain.entity.SysUser; | |||||
| import java.util.List; | |||||
| /** | /** | ||||
| * 部门管理 服务层 | * 部门管理 服务层 | ||||
| * | |||||
| * | |||||
| * @author ruoyi | * @author ruoyi | ||||
| */ | */ | ||||
| public interface ISysDeptService | public interface ISysDeptService | ||||
| { | { | ||||
| /** | /** | ||||
| * 查询部门管理数据 | * 查询部门管理数据 | ||||
| * | |||||
| * | |||||
| * @param dept 部门信息 | * @param dept 部门信息 | ||||
| * @return 部门信息集合 | * @return 部门信息集合 | ||||
| */ | */ | ||||
| @@ -21,7 +23,7 @@ public interface ISysDeptService | |||||
| /** | /** | ||||
| * 查询部门树结构信息 | * 查询部门树结构信息 | ||||
| * | |||||
| * | |||||
| * @param dept 部门信息 | * @param dept 部门信息 | ||||
| * @return 部门树信息集合 | * @return 部门树信息集合 | ||||
| */ | */ | ||||
| @@ -29,7 +31,7 @@ public interface ISysDeptService | |||||
| /** | /** | ||||
| * 构建前端所需要树结构 | * 构建前端所需要树结构 | ||||
| * | |||||
| * | |||||
| * @param depts 部门列表 | * @param depts 部门列表 | ||||
| * @return 树结构列表 | * @return 树结构列表 | ||||
| */ | */ | ||||
| @@ -37,7 +39,7 @@ public interface ISysDeptService | |||||
| /** | /** | ||||
| * 构建前端所需要下拉树结构 | * 构建前端所需要下拉树结构 | ||||
| * | |||||
| * | |||||
| * @param depts 部门列表 | * @param depts 部门列表 | ||||
| * @return 下拉树结构列表 | * @return 下拉树结构列表 | ||||
| */ | */ | ||||
| @@ -45,7 +47,7 @@ public interface ISysDeptService | |||||
| /** | /** | ||||
| * 根据角色ID查询部门树信息 | * 根据角色ID查询部门树信息 | ||||
| * | |||||
| * | |||||
| * @param roleId 角色ID | * @param roleId 角色ID | ||||
| * @return 选中部门列表 | * @return 选中部门列表 | ||||
| */ | */ | ||||
| @@ -53,7 +55,7 @@ public interface ISysDeptService | |||||
| /** | /** | ||||
| * 根据部门ID查询信息 | * 根据部门ID查询信息 | ||||
| * | |||||
| * | |||||
| * @param deptId 部门ID | * @param deptId 部门ID | ||||
| * @return 部门信息 | * @return 部门信息 | ||||
| */ | */ | ||||
| @@ -61,7 +63,7 @@ public interface ISysDeptService | |||||
| /** | /** | ||||
| * 根据ID查询所有子部门(正常状态) | * 根据ID查询所有子部门(正常状态) | ||||
| * | |||||
| * | |||||
| * @param deptId 部门ID | * @param deptId 部门ID | ||||
| * @return 子部门数 | * @return 子部门数 | ||||
| */ | */ | ||||
| @@ -69,7 +71,7 @@ public interface ISysDeptService | |||||
| /** | /** | ||||
| * 是否存在部门子节点 | * 是否存在部门子节点 | ||||
| * | |||||
| * | |||||
| * @param deptId 部门ID | * @param deptId 部门ID | ||||
| * @return 结果 | * @return 结果 | ||||
| */ | */ | ||||
| @@ -77,7 +79,7 @@ public interface ISysDeptService | |||||
| /** | /** | ||||
| * 查询部门是否存在用户 | * 查询部门是否存在用户 | ||||
| * | |||||
| * | |||||
| * @param deptId 部门ID | * @param deptId 部门ID | ||||
| * @return 结果 true 存在 false 不存在 | * @return 结果 true 存在 false 不存在 | ||||
| */ | */ | ||||
| @@ -85,7 +87,7 @@ public interface ISysDeptService | |||||
| /** | /** | ||||
| * 校验部门名称是否唯一 | * 校验部门名称是否唯一 | ||||
| * | |||||
| * | |||||
| * @param dept 部门信息 | * @param dept 部门信息 | ||||
| * @return 结果 | * @return 结果 | ||||
| */ | */ | ||||
| @@ -93,14 +95,14 @@ public interface ISysDeptService | |||||
| /** | /** | ||||
| * 校验部门是否有数据权限 | * 校验部门是否有数据权限 | ||||
| * | |||||
| * | |||||
| * @param deptId 部门id | * @param deptId 部门id | ||||
| */ | */ | ||||
| public void checkDeptDataScope(Long deptId); | public void checkDeptDataScope(Long deptId); | ||||
| /** | /** | ||||
| * 新增保存部门信息 | * 新增保存部门信息 | ||||
| * | |||||
| * | |||||
| * @param dept 部门信息 | * @param dept 部门信息 | ||||
| * @return 结果 | * @return 结果 | ||||
| */ | */ | ||||
| @@ -108,7 +110,7 @@ public interface ISysDeptService | |||||
| /** | /** | ||||
| * 修改保存部门信息 | * 修改保存部门信息 | ||||
| * | |||||
| * | |||||
| * @param dept 部门信息 | * @param dept 部门信息 | ||||
| * @return 结果 | * @return 结果 | ||||
| */ | */ | ||||
| @@ -116,9 +118,24 @@ public interface ISysDeptService | |||||
| /** | /** | ||||
| * 删除部门管理信息 | * 删除部门管理信息 | ||||
| * | |||||
| * | |||||
| * @param deptId 部门ID | * @param deptId 部门ID | ||||
| * @return 结果 | * @return 结果 | ||||
| */ | */ | ||||
| public int deleteDeptById(Long deptId); | public int deleteDeptById(Long deptId); | ||||
| /** | |||||
| * 导入部门数据 | |||||
| * | |||||
| * @param list 部门数据列表 | |||||
| * @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据 | |||||
| * @param userName 操作用户 | |||||
| * @return 结果 | |||||
| */ | |||||
| public String importSysDept(List<SysDept> list, Boolean isUpdateSupport, String userName); | |||||
| void coordinatesUpdate(List<SysDept> deptList, SysUser user); | |||||
| boolean coordinatesUpdateRunning(); | |||||
| } | } | ||||
| @@ -1,11 +1,8 @@ | |||||
| package com.ruoyi.system.service.impl; | package com.ruoyi.system.service.impl; | ||||
| 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 cn.hutool.core.util.StrUtil; | |||||
| import com.alibaba.fastjson2.JSON; | |||||
| import com.alibaba.fastjson2.JSONObject; | |||||
| import com.ruoyi.common.annotation.DataScope; | import com.ruoyi.common.annotation.DataScope; | ||||
| import com.ruoyi.common.constant.UserConstants; | import com.ruoyi.common.constant.UserConstants; | ||||
| import com.ruoyi.common.core.domain.TreeSelect; | import com.ruoyi.common.core.domain.TreeSelect; | ||||
| @@ -14,75 +11,87 @@ import com.ruoyi.common.core.domain.entity.SysRole; | |||||
| import com.ruoyi.common.core.domain.entity.SysUser; | import com.ruoyi.common.core.domain.entity.SysUser; | ||||
| import com.ruoyi.common.core.text.Convert; | import com.ruoyi.common.core.text.Convert; | ||||
| import com.ruoyi.common.exception.ServiceException; | import com.ruoyi.common.exception.ServiceException; | ||||
| import com.ruoyi.common.utils.DateUtils; | |||||
| import com.ruoyi.common.utils.SecurityUtils; | import com.ruoyi.common.utils.SecurityUtils; | ||||
| import com.ruoyi.common.utils.StringUtils; | import com.ruoyi.common.utils.StringUtils; | ||||
| import com.ruoyi.common.utils.WorldMapUtils; | |||||
| import com.ruoyi.common.utils.spring.SpringUtils; | import com.ruoyi.common.utils.spring.SpringUtils; | ||||
| import com.ruoyi.system.domain.SysMapWorld; | |||||
| import com.ruoyi.system.mapper.SysDeptMapper; | import com.ruoyi.system.mapper.SysDeptMapper; | ||||
| import com.ruoyi.system.mapper.SysRoleMapper; | import com.ruoyi.system.mapper.SysRoleMapper; | ||||
| import com.ruoyi.system.service.ISysDeptService; | import com.ruoyi.system.service.ISysDeptService; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.beans.factory.annotation.Value; | |||||
| import org.springframework.scheduling.annotation.Async; | |||||
| import org.springframework.stereotype.Service; | |||||
| import org.springframework.transaction.annotation.Transactional; | |||||
| import java.util.*; | |||||
| import java.util.concurrent.atomic.AtomicInteger; | |||||
| import java.util.function.Consumer; | |||||
| import java.util.stream.Collectors; | |||||
| /** | /** | ||||
| * 部门管理 服务实现 | * 部门管理 服务实现 | ||||
| * | |||||
| * | |||||
| * @author ruoyi | * @author ruoyi | ||||
| */ | */ | ||||
| @Service | @Service | ||||
| public class SysDeptServiceImpl implements ISysDeptService | |||||
| { | |||||
| public class SysDeptServiceImpl implements ISysDeptService { | |||||
| @Autowired | @Autowired | ||||
| private SysDeptMapper deptMapper; | private SysDeptMapper deptMapper; | ||||
| @Autowired | @Autowired | ||||
| private SysRoleMapper roleMapper; | private SysRoleMapper roleMapper; | ||||
| @Value("${map.world.key}") | |||||
| private String tk; | |||||
| public static volatile boolean _coordinatesUpdateRunning = false; | |||||
| private static final Object _coordinatesUpdateLock = new Object(); | |||||
| /** | /** | ||||
| * 查询部门管理数据 | * 查询部门管理数据 | ||||
| * | |||||
| * | |||||
| * @param dept 部门信息 | * @param dept 部门信息 | ||||
| * @return 部门信息集合 | * @return 部门信息集合 | ||||
| */ | */ | ||||
| @Override | @Override | ||||
| @DataScope(deptAlias = "d") | @DataScope(deptAlias = "d") | ||||
| public List<SysDept> selectDeptList(SysDept dept) | |||||
| { | |||||
| public List<SysDept> selectDeptList(SysDept dept) { | |||||
| return deptMapper.selectDeptList(dept); | return deptMapper.selectDeptList(dept); | ||||
| } | } | ||||
| /** | /** | ||||
| * 查询部门树结构信息 | * 查询部门树结构信息 | ||||
| * | |||||
| * | |||||
| * @param dept 部门信息 | * @param dept 部门信息 | ||||
| * @return 部门树信息集合 | * @return 部门树信息集合 | ||||
| */ | */ | ||||
| @Override | @Override | ||||
| public List<TreeSelect> selectDeptTreeList(SysDept dept) | |||||
| { | |||||
| public List<TreeSelect> selectDeptTreeList(SysDept dept) { | |||||
| List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept); | List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept); | ||||
| return buildDeptTreeSelect(depts); | return buildDeptTreeSelect(depts); | ||||
| } | } | ||||
| /** | /** | ||||
| * 构建前端所需要树结构 | * 构建前端所需要树结构 | ||||
| * | |||||
| * | |||||
| * @param depts 部门列表 | * @param depts 部门列表 | ||||
| * @return 树结构列表 | * @return 树结构列表 | ||||
| */ | */ | ||||
| @Override | @Override | ||||
| public List<SysDept> buildDeptTree(List<SysDept> depts) | |||||
| { | |||||
| public List<SysDept> buildDeptTree(List<SysDept> depts) { | |||||
| List<SysDept> returnList = new ArrayList<SysDept>(); | List<SysDept> returnList = new ArrayList<SysDept>(); | ||||
| List<Long> tempList = depts.stream().map(SysDept::getDeptId).collect(Collectors.toList()); | 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); | recursionFn(depts, dept); | ||||
| returnList.add(dept); | returnList.add(dept); | ||||
| } | } | ||||
| } | } | ||||
| if (returnList.isEmpty()) | |||||
| { | |||||
| if (returnList.isEmpty()) { | |||||
| returnList = depts; | returnList = depts; | ||||
| } | } | ||||
| return returnList; | return returnList; | ||||
| @@ -90,93 +99,85 @@ public class SysDeptServiceImpl implements ISysDeptService | |||||
| /** | /** | ||||
| * 构建前端所需要下拉树结构 | * 构建前端所需要下拉树结构 | ||||
| * | |||||
| * | |||||
| * @param depts 部门列表 | * @param depts 部门列表 | ||||
| * @return 下拉树结构列表 | * @return 下拉树结构列表 | ||||
| */ | */ | ||||
| @Override | @Override | ||||
| public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts) | |||||
| { | |||||
| public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts) { | |||||
| List<SysDept> deptTrees = buildDeptTree(depts); | List<SysDept> deptTrees = buildDeptTree(depts); | ||||
| return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList()); | return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList()); | ||||
| } | } | ||||
| /** | /** | ||||
| * 根据角色ID查询部门树信息 | * 根据角色ID查询部门树信息 | ||||
| * | |||||
| * | |||||
| * @param roleId 角色ID | * @param roleId 角色ID | ||||
| * @return 选中部门列表 | * @return 选中部门列表 | ||||
| */ | */ | ||||
| @Override | @Override | ||||
| public List<Long> selectDeptListByRoleId(Long roleId) | |||||
| { | |||||
| public List<Long> selectDeptListByRoleId(Long roleId) { | |||||
| SysRole role = roleMapper.selectRoleById(roleId); | SysRole role = roleMapper.selectRoleById(roleId); | ||||
| return deptMapper.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly()); | return deptMapper.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly()); | ||||
| } | } | ||||
| /** | /** | ||||
| * 根据部门ID查询信息 | * 根据部门ID查询信息 | ||||
| * | |||||
| * | |||||
| * @param deptId 部门ID | * @param deptId 部门ID | ||||
| * @return 部门信息 | * @return 部门信息 | ||||
| */ | */ | ||||
| @Override | @Override | ||||
| public SysDept selectDeptById(Long deptId) | |||||
| { | |||||
| public SysDept selectDeptById(Long deptId) { | |||||
| return deptMapper.selectDeptById(deptId); | return deptMapper.selectDeptById(deptId); | ||||
| } | } | ||||
| /** | /** | ||||
| * 根据ID查询所有子部门(正常状态) | * 根据ID查询所有子部门(正常状态) | ||||
| * | |||||
| * | |||||
| * @param deptId 部门ID | * @param deptId 部门ID | ||||
| * @return 子部门数 | * @return 子部门数 | ||||
| */ | */ | ||||
| @Override | @Override | ||||
| public int selectNormalChildrenDeptById(Long deptId) | |||||
| { | |||||
| public int selectNormalChildrenDeptById(Long deptId) { | |||||
| return deptMapper.selectNormalChildrenDeptById(deptId); | return deptMapper.selectNormalChildrenDeptById(deptId); | ||||
| } | } | ||||
| /** | /** | ||||
| * 是否存在子节点 | * 是否存在子节点 | ||||
| * | |||||
| * | |||||
| * @param deptId 部门ID | * @param deptId 部门ID | ||||
| * @return 结果 | * @return 结果 | ||||
| */ | */ | ||||
| @Override | @Override | ||||
| public boolean hasChildByDeptId(Long deptId) | |||||
| { | |||||
| public boolean hasChildByDeptId(Long deptId) { | |||||
| int result = deptMapper.hasChildByDeptId(deptId); | int result = deptMapper.hasChildByDeptId(deptId); | ||||
| return result > 0; | return result > 0; | ||||
| } | } | ||||
| /** | /** | ||||
| * 查询部门是否存在用户 | * 查询部门是否存在用户 | ||||
| * | |||||
| * | |||||
| * @param deptId 部门ID | * @param deptId 部门ID | ||||
| * @return 结果 true 存在 false 不存在 | * @return 结果 true 存在 false 不存在 | ||||
| */ | */ | ||||
| @Override | @Override | ||||
| public boolean checkDeptExistUser(Long deptId) | |||||
| { | |||||
| public boolean checkDeptExistUser(Long deptId) { | |||||
| int result = deptMapper.checkDeptExistUser(deptId); | int result = deptMapper.checkDeptExistUser(deptId); | ||||
| return result > 0; | return result > 0; | ||||
| } | } | ||||
| /** | /** | ||||
| * 校验部门名称是否唯一 | * 校验部门名称是否唯一 | ||||
| * | |||||
| * | |||||
| * @param dept 部门信息 | * @param dept 部门信息 | ||||
| * @return 结果 | * @return 结果 | ||||
| */ | */ | ||||
| @Override | @Override | ||||
| public boolean checkDeptNameUnique(SysDept dept) | |||||
| { | |||||
| public boolean checkDeptNameUnique(SysDept dept) { | |||||
| Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId(); | Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId(); | ||||
| SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId()); | 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.NOT_UNIQUE; | ||||
| } | } | ||||
| return UserConstants.UNIQUE; | return UserConstants.UNIQUE; | ||||
| @@ -184,19 +185,16 @@ public class SysDeptServiceImpl implements ISysDeptService | |||||
| /** | /** | ||||
| * 校验部门是否有数据权限 | * 校验部门是否有数据权限 | ||||
| * | |||||
| * | |||||
| * @param deptId 部门id | * @param deptId 部门id | ||||
| */ | */ | ||||
| @Override | @Override | ||||
| public void checkDeptDataScope(Long deptId) | |||||
| { | |||||
| if (!SysUser.isAdmin(SecurityUtils.getUserId()) && StringUtils.isNotNull(deptId)) | |||||
| { | |||||
| public void checkDeptDataScope(Long deptId) { | |||||
| if (!SysUser.isAdmin(SecurityUtils.getUserId()) && StringUtils.isNotNull(deptId)) { | |||||
| SysDept dept = new SysDept(); | SysDept dept = new SysDept(); | ||||
| dept.setDeptId(deptId); | dept.setDeptId(deptId); | ||||
| List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept); | List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept); | ||||
| if (StringUtils.isEmpty(depts)) | |||||
| { | |||||
| if (StringUtils.isEmpty(depts)) { | |||||
| throw new ServiceException("没有权限访问部门数据!"); | throw new ServiceException("没有权限访问部门数据!"); | ||||
| } | } | ||||
| } | } | ||||
| @@ -204,17 +202,15 @@ public class SysDeptServiceImpl implements ISysDeptService | |||||
| /** | /** | ||||
| * 新增保存部门信息 | * 新增保存部门信息 | ||||
| * | |||||
| * | |||||
| * @param dept 部门信息 | * @param dept 部门信息 | ||||
| * @return 结果 | * @return 结果 | ||||
| */ | */ | ||||
| @Override | @Override | ||||
| public int insertDept(SysDept dept) | |||||
| { | |||||
| public int insertDept(SysDept dept) { | |||||
| SysDept info = deptMapper.selectDeptById(dept.getParentId()); | SysDept info = deptMapper.selectDeptById(dept.getParentId()); | ||||
| // 如果父节点不为正常状态,则不允许新增子节点 | // 如果父节点不为正常状态,则不允许新增子节点 | ||||
| if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) | |||||
| { | |||||
| if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) { | |||||
| throw new ServiceException("部门停用,不允许新增"); | throw new ServiceException("部门停用,不允许新增"); | ||||
| } | } | ||||
| dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); | dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); | ||||
| @@ -223,17 +219,15 @@ public class SysDeptServiceImpl implements ISysDeptService | |||||
| /** | /** | ||||
| * 修改保存部门信息 | * 修改保存部门信息 | ||||
| * | |||||
| * | |||||
| * @param dept 部门信息 | * @param dept 部门信息 | ||||
| * @return 结果 | * @return 结果 | ||||
| */ | */ | ||||
| @Override | @Override | ||||
| public int updateDept(SysDept dept) | |||||
| { | |||||
| public int updateDept(SysDept dept) { | |||||
| SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId()); | SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId()); | ||||
| SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId()); | 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 newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId(); | ||||
| String oldAncestors = oldDept.getAncestors(); | String oldAncestors = oldDept.getAncestors(); | ||||
| dept.setAncestors(newAncestors); | dept.setAncestors(newAncestors); | ||||
| @@ -241,8 +235,7 @@ public class SysDeptServiceImpl implements ISysDeptService | |||||
| } | } | ||||
| int result = deptMapper.updateDept(dept); | int result = deptMapper.updateDept(dept); | ||||
| if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors()) | if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors()) | ||||
| && !StringUtils.equals("0", dept.getAncestors())) | |||||
| { | |||||
| && !StringUtils.equals("0", dept.getAncestors())) { | |||||
| // 如果该部门是启用状态,则启用该部门的所有上级部门 | // 如果该部门是启用状态,则启用该部门的所有上级部门 | ||||
| updateParentDeptStatusNormal(dept); | updateParentDeptStatusNormal(dept); | ||||
| } | } | ||||
| @@ -251,11 +244,10 @@ public class SysDeptServiceImpl implements ISysDeptService | |||||
| /** | /** | ||||
| * 修改该部门的父级部门状态 | * 修改该部门的父级部门状态 | ||||
| * | |||||
| * | |||||
| * @param dept 当前部门 | * @param dept 当前部门 | ||||
| */ | */ | ||||
| private void updateParentDeptStatusNormal(SysDept dept) | |||||
| { | |||||
| private void updateParentDeptStatusNormal(SysDept dept) { | |||||
| String ancestors = dept.getAncestors(); | String ancestors = dept.getAncestors(); | ||||
| Long[] deptIds = Convert.toLongArray(ancestors); | Long[] deptIds = Convert.toLongArray(ancestors); | ||||
| deptMapper.updateDeptStatusNormal(deptIds); | deptMapper.updateDeptStatusNormal(deptIds); | ||||
| @@ -263,48 +255,41 @@ public class SysDeptServiceImpl implements ISysDeptService | |||||
| /** | /** | ||||
| * 修改子元素关系 | * 修改子元素关系 | ||||
| * | |||||
| * @param deptId 被修改的部门ID | |||||
| * | |||||
| * @param deptId 被修改的部门ID | |||||
| * @param newAncestors 新的父ID集合 | * @param newAncestors 新的父ID集合 | ||||
| * @param oldAncestors 旧的父ID集合 | * @param oldAncestors 旧的父ID集合 | ||||
| */ | */ | ||||
| public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) | |||||
| { | |||||
| public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) { | |||||
| List<SysDept> children = deptMapper.selectChildrenDeptById(deptId); | List<SysDept> children = deptMapper.selectChildrenDeptById(deptId); | ||||
| for (SysDept child : children) | |||||
| { | |||||
| for (SysDept child : children) { | |||||
| child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors)); | child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors)); | ||||
| } | } | ||||
| if (children.size() > 0) | |||||
| { | |||||
| if (children.size() > 0) { | |||||
| deptMapper.updateDeptChildren(children); | deptMapper.updateDeptChildren(children); | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * 删除部门管理信息 | * 删除部门管理信息 | ||||
| * | |||||
| * | |||||
| * @param deptId 部门ID | * @param deptId 部门ID | ||||
| * @return 结果 | * @return 结果 | ||||
| */ | */ | ||||
| @Override | @Override | ||||
| public int deleteDeptById(Long deptId) | |||||
| { | |||||
| public int deleteDeptById(Long deptId) { | |||||
| return deptMapper.deleteDeptById(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); | List<SysDept> childList = getChildList(list, t); | ||||
| t.setChildren(childList); | t.setChildren(childList); | ||||
| for (SysDept tChild : childList) | |||||
| { | |||||
| if (hasChild(list, tChild)) | |||||
| { | |||||
| for (SysDept tChild : childList) { | |||||
| if (hasChild(list, tChild)) { | |||||
| recursionFn(list, tChild); | recursionFn(list, tChild); | ||||
| } | } | ||||
| } | } | ||||
| @@ -313,15 +298,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>(); | List<SysDept> tlist = new ArrayList<SysDept>(); | ||||
| Iterator<SysDept> it = list.iterator(); | Iterator<SysDept> it = list.iterator(); | ||||
| while (it.hasNext()) | |||||
| { | |||||
| while (it.hasNext()) { | |||||
| SysDept n = (SysDept) it.next(); | 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); | tlist.add(n); | ||||
| } | } | ||||
| } | } | ||||
| @@ -331,8 +313,389 @@ 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; | return getChildList(list, t).size() > 0; | ||||
| } | } | ||||
| /** | |||||
| * 导入部门数据 | |||||
| * | |||||
| * @param list 部门数据列表 | |||||
| * @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据 | |||||
| * @param operName 操作用户 | |||||
| * @return 结果 | |||||
| */ | |||||
| @Override | |||||
| @Transactional(rollbackFor = Exception.class) | |||||
| public String importSysDept(List<SysDept> list, Boolean isUpdateSupport, String operName) { | |||||
| if (StringUtils.isEmpty(list)) { | |||||
| throw new ServiceException("导入部门数据不能为空!"); | |||||
| } | |||||
| int successNum = 0; | |||||
| int[] failureNum = {0}; | |||||
| StringBuilder successMsg = new StringBuilder(); | |||||
| StringBuilder failureMsg = new StringBuilder(); | |||||
| // 检验excel表中 【xxx】 是否存在重复,有重复的终止导入 | |||||
| List<String> repeatList = list.stream().collect(Collectors.groupingBy(SysDept::getOrgCode, Collectors.counting())) | |||||
| .entrySet().stream().filter(e -> e.getValue() > 1).map(Map.Entry::getKey).collect(Collectors.toList()); | |||||
| if (StringUtils.isNotEmpty(repeatList)) { | |||||
| failureMsg.insert(0, "很抱歉,存在重复项,导入失败!共 " + repeatList.size() + " 个重复错错误如下:"); | |||||
| for (int i = 0; i < repeatList.size(); i++) { | |||||
| String item = repeatList.get(i); | |||||
| failureNum[0] = repeatList.size(); | |||||
| failureMsg.append("<br/>" + failureNum + "、行政区划代码 " + item + " 重复"); | |||||
| } | |||||
| return failureMsg.toString(); | |||||
| } | |||||
| // 检验excel表中 【xxx】 是否存在重复,有重复的终止导入 | |||||
| List<String> repeatList2 = list.stream().collect(Collectors.groupingBy(SysDept::getImportCode, Collectors.counting())) | |||||
| .entrySet().stream().filter(e -> e.getValue() > 1).map(Map.Entry::getKey).collect(Collectors.toList()); | |||||
| if (StringUtils.isNotEmpty(repeatList2)) { | |||||
| failureMsg.insert(0, "很抱歉,存在重复项,导入失败!共 " + repeatList2.size() + " 个重复错错误如下:"); | |||||
| for (int i = 0; i < repeatList2.size(); i++) { | |||||
| String item = repeatList2.get(i); | |||||
| failureNum[0] = repeatList.size(); | |||||
| failureMsg.append("<br/>" + failureNum + "、导入代码 " + item + " 重复"); | |||||
| } | |||||
| return failureMsg.toString(); | |||||
| } | |||||
| // 初始化清空表 | |||||
| if (!isUpdateSupport) | |||||
| deptMapper.deleteAllDept(); // 事务 | |||||
| final Consumer<SysDept> updateOrInsertFunc = (dept) -> { | |||||
| SysDept d = deptMapper.selectDeptByImportCode(dept.getImportCode()); | |||||
| if (null != d) { | |||||
| d.setDeptName(dept.getDeptName()); | |||||
| deptMapper.updateDept(d); | |||||
| } else { | |||||
| dept.setOrderNum(Integer.parseInt(deptMapper.selectDeptNextOrderNum(dept) + "")); | |||||
| deptMapper.insertDept(dept); | |||||
| } | |||||
| }; | |||||
| int[] index = {0}; | |||||
| list.forEach((x) -> x.putParam("index", ++index[0])); | |||||
| AtomicInteger total = new AtomicInteger(0); | |||||
| AtomicInteger orderNnum = new AtomicInteger(0); | |||||
| Map<Integer, List<SysDept>> orgCodeLengthMap = list.stream().collect(Collectors.groupingBy(sysDept -> StrUtil.length(sysDept.getImportCode()))); | |||||
| orgCodeLengthMap.forEach((orgCodeLength, sysDepts) -> { | |||||
| switch (orgCodeLength) { | |||||
| case 2: | |||||
| if (isUpdateSupport) { | |||||
| sysDepts.forEach((x) -> { | |||||
| SysDept dept = deptMapper.selectDeptByImportCode(x.getImportCode()); | |||||
| if (null != dept) // 存在则更新名称 | |||||
| { | |||||
| dept.setDeptName(x.getDeptName()); | |||||
| deptMapper.updateDept(dept); | |||||
| } else { | |||||
| failureMsg.append(String.format("<br/>第%s行插入新增时不允许添加省级部门.", x.obtainParam("index"))); | |||||
| failureNum[0]++; | |||||
| } | |||||
| }); | |||||
| } else { | |||||
| orderNnum.set(0); | |||||
| sysDepts.stream().peek(sysDept -> { | |||||
| sysDept.setDeptId(100L); //最高级默认100 | |||||
| sysDept.setParentId(0L); | |||||
| sysDept.setAncestors(StrUtil.join(",", sysDept.getParentId())); | |||||
| sysDept.setOrderNum(orderNnum.incrementAndGet()); | |||||
| }).forEach(sysDept -> { | |||||
| deptMapper.insertDept(sysDept); | |||||
| total.incrementAndGet(); | |||||
| }); | |||||
| } | |||||
| break; | |||||
| case 4: | |||||
| if (isUpdateSupport) { | |||||
| sysDepts.forEach(sysDept -> { | |||||
| SysDept parentDept = deptMapper.selectDeptByImportCode(StringUtils.substring(sysDept.getImportCode(), 0, 2)); | |||||
| if (Objects.nonNull(parentDept)) { | |||||
| sysDept.setAncestors(StrUtil.join(",", parentDept.getAncestors(), parentDept.getDeptId())); | |||||
| sysDept.setParentId(parentDept.getDeptId()); | |||||
| } else { | |||||
| failureMsg.append(String.format("<br/>第%s行插入新增地市级时上级地区不存在.", sysDept.obtainParam("index"))); | |||||
| failureNum[0]++; | |||||
| return; | |||||
| } | |||||
| sysDept.setOrderNum(orderNnum.incrementAndGet()); | |||||
| updateOrInsertFunc.accept(sysDept); | |||||
| total.incrementAndGet(); | |||||
| }); | |||||
| } else { | |||||
| orderNnum.set(0); | |||||
| sysDepts.stream().peek(sysDept -> { | |||||
| SysDept parentDept = deptMapper.selectDeptByImportCode(StringUtils.substring(sysDept.getImportCode(), 0, 2)); | |||||
| if (Objects.nonNull(parentDept)) { | |||||
| sysDept.setAncestors(StrUtil.join(",", parentDept.getAncestors(), parentDept.getDeptId())); | |||||
| sysDept.setParentId(parentDept.getDeptId()); | |||||
| } else { | |||||
| sysDept.setDeptId(100L); //最高级默认100 | |||||
| sysDept.setParentId(0L); | |||||
| sysDept.setAncestors(StrUtil.join(",", sysDept.getParentId())); | |||||
| } | |||||
| sysDept.setOrderNum(orderNnum.incrementAndGet()); | |||||
| }).forEach(sysDept -> { | |||||
| deptMapper.insertDept(sysDept); | |||||
| total.incrementAndGet(); | |||||
| }); | |||||
| } | |||||
| break; | |||||
| case 6: | |||||
| if (isUpdateSupport) { | |||||
| orderNnum.set(0); | |||||
| sysDepts.forEach(sysDept -> { | |||||
| SysDept parentDept = deptMapper.selectDeptByImportCode(StringUtils.substring(sysDept.getImportCode(), 0, 4)); | |||||
| if (Objects.nonNull(parentDept)) { | |||||
| sysDept.setAncestors(StrUtil.join(",", parentDept.getAncestors(), parentDept.getDeptId())); | |||||
| sysDept.setParentId(parentDept.getDeptId()); | |||||
| } else { | |||||
| failureMsg.append(String.format("<br/>第%s行插入新增区县级时上级地区不存在.", sysDept.obtainParam("index"))); | |||||
| failureNum[0]++; | |||||
| return; | |||||
| } | |||||
| sysDept.setOrderNum(orderNnum.incrementAndGet()); | |||||
| updateOrInsertFunc.accept(sysDept); | |||||
| total.incrementAndGet(); | |||||
| }); | |||||
| } else { | |||||
| orderNnum.set(0); | |||||
| sysDepts.stream().peek(sysDept -> { | |||||
| SysDept parentDept = deptMapper.selectDeptByImportCode(StringUtils.substring(sysDept.getImportCode(), 0, 4)); | |||||
| if (Objects.nonNull(parentDept)) { | |||||
| sysDept.setAncestors(StrUtil.join(",", parentDept.getAncestors(), parentDept.getDeptId())); | |||||
| sysDept.setParentId(parentDept.getDeptId()); | |||||
| } else { | |||||
| sysDept.setDeptId(100L); //最高级默认100 | |||||
| sysDept.setParentId(0L); | |||||
| sysDept.setAncestors(StrUtil.join(",", sysDept.getParentId())); | |||||
| } | |||||
| sysDept.setOrderNum(orderNnum.incrementAndGet()); | |||||
| }).forEach(sysDept -> { | |||||
| deptMapper.insertDept(sysDept); | |||||
| total.incrementAndGet(); | |||||
| }); | |||||
| } | |||||
| break; | |||||
| case 9: | |||||
| if (isUpdateSupport) { | |||||
| sysDepts.forEach(sysDept -> { | |||||
| SysDept parentDept = deptMapper.selectDeptByImportCode(StringUtils.substring(sysDept.getImportCode(), 0, 6)); | |||||
| if (Objects.nonNull(parentDept)) { | |||||
| sysDept.setAncestors(StrUtil.join(",", parentDept.getAncestors(), parentDept.getDeptId())); | |||||
| sysDept.setParentId(parentDept.getDeptId()); | |||||
| sysDept.setOrderNum(orderNnum.incrementAndGet()); | |||||
| } else { | |||||
| failureMsg.append(String.format("<br/>第%s行插入新增镇街级时上级地区不存在.", sysDept.obtainParam("index"))); | |||||
| failureNum[0]++; | |||||
| return; | |||||
| } | |||||
| updateOrInsertFunc.accept(sysDept); | |||||
| total.incrementAndGet(); | |||||
| }); | |||||
| } else { | |||||
| orderNnum.set(0); | |||||
| sysDepts.stream().peek(sysDept -> { | |||||
| SysDept parentDept = deptMapper.selectDeptByImportCode(StringUtils.substring(sysDept.getImportCode(), 0, 6)); | |||||
| if (Objects.nonNull(parentDept)) { | |||||
| sysDept.setAncestors(StrUtil.join(",", parentDept.getAncestors(), parentDept.getDeptId())); | |||||
| sysDept.setParentId(parentDept.getDeptId()); | |||||
| sysDept.setOrderNum(orderNnum.incrementAndGet()); | |||||
| } | |||||
| }).forEach(sysDept -> { | |||||
| deptMapper.insertDept(sysDept); | |||||
| total.incrementAndGet(); | |||||
| }); | |||||
| } | |||||
| break; | |||||
| case 12: | |||||
| if (isUpdateSupport) { | |||||
| sysDepts.forEach(sysDept -> { | |||||
| SysDept parentDept = deptMapper.selectDeptByImportCode(StringUtils.substring(sysDept.getImportCode(), 0, 9)); | |||||
| if (Objects.nonNull(parentDept)) { | |||||
| sysDept.setAncestors(StrUtil.join(",", parentDept.getAncestors(), parentDept.getDeptId())); | |||||
| sysDept.setParentId(parentDept.getDeptId()); | |||||
| sysDept.setOrderNum(orderNnum.incrementAndGet()); | |||||
| } else { | |||||
| failureMsg.append(String.format("<br/>第%s行插入新增村级时上级地区不存在.", sysDept.obtainParam("index"))); | |||||
| failureNum[0]++; | |||||
| return; | |||||
| } | |||||
| updateOrInsertFunc.accept(sysDept); | |||||
| total.incrementAndGet(); | |||||
| }); | |||||
| } else { | |||||
| orderNnum.set(0); | |||||
| sysDepts.stream().peek(sysDept -> { | |||||
| SysDept parentDept = deptMapper.selectDeptByImportCode(StringUtils.substring(sysDept.getImportCode(), 0, 9)); | |||||
| if (Objects.nonNull(parentDept)) { | |||||
| sysDept.setAncestors(StrUtil.join(",", parentDept.getAncestors(), parentDept.getDeptId())); | |||||
| sysDept.setParentId(parentDept.getDeptId()); | |||||
| sysDept.setOrderNum(orderNnum.incrementAndGet()); | |||||
| } | |||||
| }).forEach(sysDept -> { | |||||
| deptMapper.insertDept(sysDept); | |||||
| total.incrementAndGet(); | |||||
| }); | |||||
| } | |||||
| break; | |||||
| case 14: | |||||
| if (isUpdateSupport) { | |||||
| sysDepts.forEach(sysDept -> { | |||||
| SysDept parentDept = deptMapper.selectDeptByImportCode(StringUtils.substring(sysDept.getImportCode(), 0, 12)); | |||||
| if (Objects.nonNull(parentDept)) { | |||||
| sysDept.setAncestors(StrUtil.join(",", parentDept.getAncestors(), parentDept.getDeptId())); | |||||
| sysDept.setParentId(parentDept.getDeptId()); | |||||
| sysDept.setOrderNum(orderNnum.incrementAndGet()); | |||||
| } else { | |||||
| failureMsg.append(String.format("<br/>第%s行插入新增组级时上级地区不存在.", sysDept.obtainParam("index"))); | |||||
| failureNum[0]++; | |||||
| return; | |||||
| } | |||||
| updateOrInsertFunc.accept(sysDept); | |||||
| total.incrementAndGet(); | |||||
| }); | |||||
| } else { | |||||
| orderNnum.set(0); | |||||
| sysDepts.stream().peek(sysDept -> { | |||||
| SysDept parentDept = deptMapper.selectDeptByImportCode(StringUtils.substring(sysDept.getImportCode(), 0, 12)); | |||||
| if (Objects.nonNull(parentDept)) { | |||||
| sysDept.setAncestors(StrUtil.join(",", parentDept.getAncestors(), parentDept.getDeptId())); | |||||
| sysDept.setParentId(parentDept.getDeptId()); | |||||
| sysDept.setOrderNum(orderNnum.incrementAndGet()); | |||||
| } | |||||
| }).forEach(sysDept -> { | |||||
| deptMapper.insertDept(sysDept); | |||||
| total.incrementAndGet(); | |||||
| }); | |||||
| } | |||||
| break; | |||||
| default: | |||||
| break; | |||||
| } | |||||
| }); | |||||
| if (failureNum[0] > 0) { | |||||
| failureMsg.insert(0, "很抱歉,存在导入失败数据!,共 " + failureNum[0] + " 条,如下:"); | |||||
| //throw new CustomException(failureMsg.toString()); | |||||
| return failureMsg.toString(); | |||||
| } else { | |||||
| successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + total + " 条。"); | |||||
| return successMsg.toString(); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public boolean coordinatesUpdateRunning() { | |||||
| return _coordinatesUpdateRunning; | |||||
| } | |||||
| /** | |||||
| * 更新所有部门的坐标信息 | |||||
| * 异步线程处理 | |||||
| */ | |||||
| @Override | |||||
| @Async("threadPoolTaskExecutor") | |||||
| public void coordinatesUpdate(List<SysDept> deptList, SysUser user) { | |||||
| synchronized (_coordinatesUpdateLock) { | |||||
| if (_coordinatesUpdateRunning) | |||||
| return; | |||||
| _coordinatesUpdateRunning = true; | |||||
| deptList.forEach(d -> { | |||||
| if (StringUtils.isNotEmpty(d.getLongitude())) { | |||||
| return; | |||||
| } | |||||
| d.setUpdateBy(user.getUserName()); | |||||
| d.setUpdateTime(DateUtils.getNowDate()); | |||||
| String d_orgCode = d.getOrgCode(); | |||||
| String deptName = d.getDeptName(); | |||||
| if (d_orgCode.length() == 4) { // 地市级 | |||||
| String json = WorldMapUtils.getLonLat(deptName, tk); | |||||
| if (StringUtils.isNull(json)) { | |||||
| return; | |||||
| } | |||||
| JSONObject jsonObject = JSON.parseObject(json); | |||||
| SysMapWorld mw = (SysMapWorld) JSON.toJavaObject(jsonObject, SysMapWorld.class); | |||||
| if (StringUtils.isNull(mw.getLocation())) { | |||||
| return; | |||||
| } | |||||
| d.setLatitude(mw.getLocation().getLat()); | |||||
| d.setLongitude(mw.getLocation().getLon()); | |||||
| } else if (d_orgCode.length() == 6) { // 县级 | |||||
| List<SysDept> filterDept = deptList.stream().filter(dl -> dl.getDeptId().equals(d.getParentId())).collect(Collectors.toList()); | |||||
| if (StringUtils.isNotEmpty(filterDept)) { | |||||
| deptName = filterDept.get(0).getDeptName() + deptName; | |||||
| } | |||||
| String json = WorldMapUtils.getLonLat(deptName, tk); | |||||
| if (StringUtils.isNull(json)) { | |||||
| return; | |||||
| } | |||||
| JSONObject jsonObject = JSON.parseObject(json); | |||||
| SysMapWorld mw = (SysMapWorld) JSON.toJavaObject(jsonObject, SysMapWorld.class); | |||||
| if (StringUtils.isNull(mw.getLocation())) { | |||||
| return; | |||||
| } | |||||
| d.setLatitude(mw.getLocation().getLat()); | |||||
| d.setLongitude(mw.getLocation().getLon()); | |||||
| } else if (d_orgCode.length() == 9) { // 镇级 | |||||
| List<SysDept> filterDept = deptList.stream().filter(dl -> dl.getDeptId().equals(d.getParentId())).collect(Collectors.toList()); | |||||
| if (StringUtils.isNotEmpty(filterDept)) { | |||||
| deptName = filterDept.get(0).getDeptName() + deptName; | |||||
| } | |||||
| String json = WorldMapUtils.getLonLat(deptName, tk); | |||||
| if (StringUtils.isNull(json)) { | |||||
| return; | |||||
| } | |||||
| JSONObject jsonObject = JSON.parseObject(json); | |||||
| SysMapWorld mw = (SysMapWorld) JSON.toJavaObject(jsonObject, SysMapWorld.class); | |||||
| if (StringUtils.isNull(mw.getLocation())) { | |||||
| return; | |||||
| } | |||||
| d.setLatitude(mw.getLocation().getLat()); | |||||
| d.setLongitude(mw.getLocation().getLon()); | |||||
| } else if (d_orgCode.length() == 12) { // 村级 | |||||
| List<SysDept> filterZhen = deptList.stream().filter(dl -> dl.getDeptId().equals(d.getParentId())).collect(Collectors.toList()); | |||||
| if (StringUtils.isNotEmpty(filterZhen)) { | |||||
| SysDept zhen = filterZhen.get(0); | |||||
| deptName = zhen.getDeptName() + deptName; | |||||
| List<SysDept> filterXian = deptList.stream().filter(dl -> dl.getDeptId().equals(zhen.getParentId())).collect(Collectors.toList()); | |||||
| if (StringUtils.isNotEmpty(filterXian)) { | |||||
| deptName = filterXian.get(0).getDeptName() + deptName; | |||||
| } | |||||
| } | |||||
| String json = WorldMapUtils.getLonLat(deptName, tk); | |||||
| if (StringUtils.isNull(json)) { | |||||
| return; | |||||
| } | |||||
| JSONObject jsonObject = JSON.parseObject(json); | |||||
| SysMapWorld mw = (SysMapWorld) JSON.toJavaObject(jsonObject, SysMapWorld.class); | |||||
| if (StringUtils.isNull(mw.getLocation())) { | |||||
| return; | |||||
| } | |||||
| d.setLatitude(mw.getLocation().getLat()); | |||||
| d.setLongitude(mw.getLocation().getLon()); | |||||
| } else { // 组级 | |||||
| return; | |||||
| } | |||||
| deptMapper.updateDept(d); | |||||
| }); | |||||
| _coordinatesUpdateRunning = false; | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -16,17 +16,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||||
| <result property="status" column="status" /> | <result property="status" column="status" /> | ||||
| <result property="delFlag" column="del_flag" /> | <result property="delFlag" column="del_flag" /> | ||||
| <result property="parentName" column="parent_name" /> | <result property="parentName" column="parent_name" /> | ||||
| <result property="importCode" column="import_code" /> | |||||
| <result property="orgCode" column="org_code" /> | |||||
| <result property="longitude" column="longitude" /> | |||||
| <result property="latitude" column="latitude" /> | |||||
| <result property="createBy" column="create_by" /> | <result property="createBy" column="create_by" /> | ||||
| <result property="createTime" column="create_time" /> | <result property="createTime" column="create_time" /> | ||||
| <result property="updateBy" column="update_by" /> | <result property="updateBy" column="update_by" /> | ||||
| <result property="updateTime" column="update_time" /> | <result property="updateTime" column="update_time" /> | ||||
| </resultMap> | </resultMap> | ||||
| <sql id="selectDeptVo"> | <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 | |||||
| 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.import_code, d.org_code, d.longitude, d.latitude | |||||
| from sys_dept d | from sys_dept d | ||||
| </sql> | </sql> | ||||
| <select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult"> | <select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult"> | ||||
| <include refid="selectDeptVo"/> | <include refid="selectDeptVo"/> | ||||
| where d.del_flag = '0' | where d.del_flag = '0' | ||||
| @@ -39,14 +45,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||||
| <if test="deptName != null and deptName != ''"> | <if test="deptName != null and deptName != ''"> | ||||
| AND dept_name like concat('%', #{deptName}, '%') | AND dept_name like concat('%', #{deptName}, '%') | ||||
| </if> | </if> | ||||
| <if test="orgCode != null and orgCode != ''"> | |||||
| AND org_code like concat(#{orgCode}, '%') | |||||
| </if> | |||||
| <if test="status != null and status != ''"> | <if test="status != null and status != ''"> | ||||
| AND status = #{status} | AND status = #{status} | ||||
| </if> | </if> | ||||
| <!-- 数据范围过滤 --> | <!-- 数据范围过滤 --> | ||||
| ${params.dataScope} | ${params.dataScope} | ||||
| order by d.parent_id, d.order_num | |||||
| </select> | </select> | ||||
| <select id="selectDeptListByRoleId" resultType="Long"> | <select id="selectDeptListByRoleId" resultType="Long"> | ||||
| select d.dept_id | select d.dept_id | ||||
| from sys_dept d | from sys_dept d | ||||
| @@ -57,36 +65,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||||
| </if> | </if> | ||||
| order by d.parent_id, d.order_num | order by d.parent_id, d.order_num | ||||
| </select> | </select> | ||||
| <select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult"> | <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, | ||||
| (select dept_name from sys_dept where dept_id = d.parent_id) parent_name | (select dept_name from sys_dept where dept_id = d.parent_id) parent_name | ||||
| from sys_dept d | from sys_dept d | ||||
| where d.dept_id = #{deptId} | where d.dept_id = #{deptId} | ||||
| </select> | </select> | ||||
| <select id="checkDeptExistUser" parameterType="Long" resultType="int"> | <select id="checkDeptExistUser" parameterType="Long" resultType="int"> | ||||
| select count(1) from sys_user where dept_id = #{deptId} and del_flag = '0' | select count(1) from sys_user where dept_id = #{deptId} and del_flag = '0' | ||||
| </select> | </select> | ||||
| <select id="hasChildByDeptId" parameterType="Long" resultType="int"> | <select id="hasChildByDeptId" parameterType="Long" resultType="int"> | ||||
| select count(1) from sys_dept | select count(1) from sys_dept | ||||
| where del_flag = '0' and parent_id = #{deptId} limit 1 | where del_flag = '0' and parent_id = #{deptId} limit 1 | ||||
| </select> | </select> | ||||
| <select id="selectChildrenDeptById" parameterType="Long" resultMap="SysDeptResult"> | <select id="selectChildrenDeptById" parameterType="Long" resultMap="SysDeptResult"> | ||||
| select * from sys_dept where find_in_set(#{deptId}, ancestors) | select * from sys_dept where find_in_set(#{deptId}, ancestors) | ||||
| </select> | </select> | ||||
| <select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int"> | <select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int"> | ||||
| select count(*) from sys_dept where status = 0 and del_flag = '0' and find_in_set(#{deptId}, ancestors) | select count(*) from sys_dept where status = 0 and del_flag = '0' and find_in_set(#{deptId}, ancestors) | ||||
| </select> | </select> | ||||
| <select id="checkDeptNameUnique" resultMap="SysDeptResult"> | <select id="checkDeptNameUnique" resultMap="SysDeptResult"> | ||||
| <include refid="selectDeptVo"/> | <include refid="selectDeptVo"/> | ||||
| where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1 | where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1 | ||||
| </select> | </select> | ||||
| <insert id="insertDept" parameterType="SysDept"> | <insert id="insertDept" parameterType="SysDept"> | ||||
| insert into sys_dept( | insert into sys_dept( | ||||
| <if test="deptId != null and deptId != 0">dept_id,</if> | <if test="deptId != null and deptId != 0">dept_id,</if> | ||||
| @@ -98,6 +106,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||||
| <if test="phone != null and phone != ''">phone,</if> | <if test="phone != null and phone != ''">phone,</if> | ||||
| <if test="email != null and email != ''">email,</if> | <if test="email != null and email != ''">email,</if> | ||||
| <if test="status != null">status,</if> | <if test="status != null">status,</if> | ||||
| <if test="importCode != null">import_code,</if> | |||||
| <if test="orgCode != null">org_code,</if> | |||||
| <if test="longitude != null">longitude,</if> | |||||
| <if test="latitude != null">latitude,</if> | |||||
| <if test="createBy != null and createBy != ''">create_by,</if> | <if test="createBy != null and createBy != ''">create_by,</if> | ||||
| create_time | create_time | ||||
| )values( | )values( | ||||
| @@ -110,11 +122,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||||
| <if test="phone != null and phone != ''">#{phone},</if> | <if test="phone != null and phone != ''">#{phone},</if> | ||||
| <if test="email != null and email != ''">#{email},</if> | <if test="email != null and email != ''">#{email},</if> | ||||
| <if test="status != null">#{status},</if> | <if test="status != null">#{status},</if> | ||||
| <if test="importCode != null">#{importCode},</if> | |||||
| <if test="orgCode != null">#{orgCode},</if> | |||||
| <if test="longitude != null">#{longitude},</if> | |||||
| <if test="latitude != null">#{latitude},</if> | |||||
| <if test="createBy != null and createBy != ''">#{createBy},</if> | <if test="createBy != null and createBy != ''">#{createBy},</if> | ||||
| sysdate() | sysdate() | ||||
| ) | ) | ||||
| </insert> | </insert> | ||||
| <update id="updateDept" parameterType="SysDept"> | <update id="updateDept" parameterType="SysDept"> | ||||
| update sys_dept | update sys_dept | ||||
| <set> | <set> | ||||
| @@ -126,12 +142,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||||
| <if test="phone != null">phone = #{phone},</if> | <if test="phone != null">phone = #{phone},</if> | ||||
| <if test="email != null">email = #{email},</if> | <if test="email != null">email = #{email},</if> | ||||
| <if test="status != null and status != ''">status = #{status},</if> | <if test="status != null and status != ''">status = #{status},</if> | ||||
| <if test="importCode != null and importCode != ''">import_code = #{importCode},</if> | |||||
| <if test="orgCode != null and orgCode != ''">org_code = #{orgCode},</if> | |||||
| <if test="longitude != null and longitude != ''">longitude = #{longitude},</if> | |||||
| <if test="latitude != null and latitude != ''">latitude = #{latitude},</if> | |||||
| <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> | <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> | ||||
| update_time = sysdate() | update_time = sysdate() | ||||
| </set> | </set> | ||||
| where dept_id = #{deptId} | where dept_id = #{deptId} | ||||
| </update> | </update> | ||||
| <update id="updateDeptChildren" parameterType="java.util.List"> | <update id="updateDeptChildren" parameterType="java.util.List"> | ||||
| update sys_dept set ancestors = | update sys_dept set ancestors = | ||||
| <foreach collection="depts" item="item" index="index" | <foreach collection="depts" item="item" index="index" | ||||
| @@ -144,16 +164,106 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||||
| #{item.deptId} | #{item.deptId} | ||||
| </foreach> | </foreach> | ||||
| </update> | </update> | ||||
| <update id="updateDeptStatusNormal" parameterType="Long"> | <update id="updateDeptStatusNormal" parameterType="Long"> | ||||
| update sys_dept set status = '0' where dept_id in | |||||
| update sys_dept set status = '0' where dept_id in | |||||
| <foreach collection="array" item="deptId" open="(" separator="," close=")"> | <foreach collection="array" item="deptId" open="(" separator="," close=")"> | ||||
| #{deptId} | #{deptId} | ||||
| </foreach> | </foreach> | ||||
| </update> | </update> | ||||
| <delete id="deleteDeptById" parameterType="Long"> | <delete id="deleteDeptById" parameterType="Long"> | ||||
| update sys_dept set del_flag = '2' where dept_id = #{deptId} | update sys_dept set del_flag = '2' where dept_id = #{deptId} | ||||
| </delete> | </delete> | ||||
| </mapper> | |||||
| <insert id="insertSysDeptBatch" parameterType="list" useGeneratedKeys="true" keyProperty="deptId"> | |||||
| insert into sys_dept | |||||
| <trim prefix="(" suffix=")" suffixOverrides=","> | |||||
| parent_id, | |||||
| ancestors, | |||||
| dept_name, | |||||
| order_num, | |||||
| leader, | |||||
| phone, | |||||
| email, | |||||
| status, | |||||
| del_flag, | |||||
| import_code, | |||||
| org_code, | |||||
| longitude, | |||||
| latitude, | |||||
| create_by, | |||||
| create_time, | |||||
| </trim> | |||||
| values | |||||
| <foreach item="item" collection="list" separator="," > | |||||
| <trim prefix="(" suffix=")" suffixOverrides=","> | |||||
| #{item.parentId}, | |||||
| #{item.ancestors}, | |||||
| #{item.deptName}, | |||||
| #{item.orderNum}, | |||||
| #{item.leader}, | |||||
| #{item.phone}, | |||||
| #{item.email}, | |||||
| #{item.status}, | |||||
| #{item.delFlag}, | |||||
| #{item.importCode}, | |||||
| #{item.orgCode}, | |||||
| #{item.longitude}, | |||||
| #{item.latitude}, | |||||
| #{item.createBy}, | |||||
| #{item.createTime}, | |||||
| </trim> | |||||
| </foreach> | |||||
| </insert> | |||||
| <!--批量更新--> | |||||
| <update id="updateSysDeptBatch" parameterType="list" > | |||||
| <foreach collection="list" item="item" index="index" open="" close="" separator=";"> | |||||
| update sys_dept | |||||
| <set> | |||||
| <if test="item.parentId != null">parent_id = #{item.parentId},</if> | |||||
| <if test="item.ancestors != null">ancestors = #{item.ancestors},</if> | |||||
| <if test="item.deptName != null">dept_name = #{item.deptName},</if> | |||||
| <if test="item.orderNum != null">order_num = #{item.orderNum},</if> | |||||
| <if test="item.leader != null">leader = #{item.leader},</if> | |||||
| <if test="item.phone != null">phone = #{item.phone},</if> | |||||
| <if test="item.email != null">email = #{item.email},</if> | |||||
| <if test="item.status != null">status = #{item.status},</if> | |||||
| <if test="item.delFlag != null">del_flag = #{item.delFlag},</if> | |||||
| <if test="item.importCode != null and item.importCode != ''">import_code = #{item.importCode},</if> | |||||
| <if test="item.orgCode != null and item.orgCode != ''">org_code = #{item.orgCode},</if> | |||||
| <if test="item.longitude != null">longitude = #{item.longitude},</if> | |||||
| <if test="item.latitude != null">latitude = #{item.latitude},</if> | |||||
| <if test="item.updateBy != null">update_by = #{item.updateBy},</if> | |||||
| <if test="item.updateTime != null">update_time = #{item.updateTime},</if> | |||||
| </set> | |||||
| where dept_id = #{item.deptId} | |||||
| </foreach> | |||||
| </update> | |||||
| <delete id="deleteAllDept"> | |||||
| delete from sys_dept | |||||
| </delete> | |||||
| <select id="selectDeptByOrgCode" parameterType="String" resultMap="SysDeptResult"> | |||||
| <include refid="selectDeptVo"/> | |||||
| where d.org_code = #{orgCode} | |||||
| </select> | |||||
| <select id="selectDeptByImportCode" parameterType="String" resultMap="SysDeptResult"> | |||||
| <include refid="selectDeptVo"/> | |||||
| where d.import_code = #{importCode} | |||||
| </select> | |||||
| <select id="selectDeptNextOrderNum" parameterType="SysDept" resultType="Long"> | |||||
| SELECT | |||||
| IFNULL(MAX(order_num), 0) + 1 | |||||
| FROM | |||||
| sys_dept | |||||
| where | |||||
| `parent_id` = #{parentId} | |||||
| </select> | |||||
| </mapper> | |||||