项目管理接口相关逻辑补充,部门添加型行政区划树状层级业务等
This commit is contained in:
@ -1,5 +1,8 @@
|
||||
package com.fastbee.system.service.impl;
|
||||
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONException;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.fastbee.common.annotation.DataScope;
|
||||
import com.fastbee.common.constant.UserConstants;
|
||||
import com.fastbee.common.core.domain.TreeSelect;
|
||||
@ -9,6 +12,7 @@ import com.fastbee.common.core.domain.entity.SysUser;
|
||||
import com.fastbee.common.core.domain.model.LoginUser;
|
||||
import com.fastbee.common.core.text.Convert;
|
||||
import com.fastbee.common.exception.ServiceException;
|
||||
import com.fastbee.common.utils.DateUtils;
|
||||
import com.fastbee.common.utils.SecurityUtils;
|
||||
import com.fastbee.common.utils.StringUtils;
|
||||
import com.fastbee.common.utils.spring.SpringUtils;
|
||||
@ -245,10 +249,87 @@ public class SysDeptServiceImpl implements ISysDeptService
|
||||
{
|
||||
throw new ServiceException("部门停用,不允许新增");
|
||||
}
|
||||
//设置祖级别列表
|
||||
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
|
||||
//处理机构所管理行政区划信息
|
||||
parseAdministrativeDivisionInfo(dept);
|
||||
dept.setCreateTime(DateUtils.getNowDate());
|
||||
return deptMapper.insertDept(dept);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析项目行政区划信息
|
||||
* @param sysDept 部门
|
||||
*/
|
||||
private void parseAdministrativeDivisionInfo(SysDept sysDept) {
|
||||
//项目行政区域处理
|
||||
//拆解项目行政区域代码信息
|
||||
if(org.apache.commons.lang3.StringUtils.isBlank(sysDept.getAdministrativeAreaCode())){
|
||||
throw new ServiceException("项目行政区域代码不能为空!");
|
||||
}
|
||||
//判断行政区域代码json格式
|
||||
if(isNotValidJsonArray(sysDept.getAdministrativeAreaCode())){
|
||||
throw new ServiceException("项目行政区域代码多选列表非json数组!");
|
||||
}
|
||||
//项目省代码列表
|
||||
List<String> provincialCodeList =new ArrayList<>();
|
||||
//项目市代码列表
|
||||
List<String> cityCodeList =new ArrayList<>();
|
||||
//项目县代码列表
|
||||
List<String> countyCodeList =new ArrayList<>();
|
||||
//项目镇代码列表
|
||||
List<String> townCodeList =new ArrayList<>();
|
||||
//项目村代码列表
|
||||
List<String> villageCodeList =new ArrayList<>();
|
||||
JSONArray administrativeAreaList = JSONUtil.parseArray(sysDept.getAdministrativeAreaCode());
|
||||
administrativeAreaList.forEach(item->{
|
||||
if(isNotValidJsonArray(item.toString())){
|
||||
throw new ServiceException("项目行政区域代码多选列表的元素非json数组!");
|
||||
}
|
||||
//单个行政区划代码列表
|
||||
JSONArray administrativeArea = JSONUtil.parseArray(item);
|
||||
//拆解出每个行政区划代码里面的镇或村
|
||||
// if(administrativeArea.size()!=5){
|
||||
// throw new ServiceException("项目行政区域代码多选列表的元素长度必须为5,到达村级别!");
|
||||
// }
|
||||
//保存项目省代码列表
|
||||
provincialCodeList.add(administrativeArea.get(0).toString());
|
||||
//保存项目市代码列表
|
||||
cityCodeList.add(administrativeArea.get(1).toString());
|
||||
//保存项目县代码列表
|
||||
countyCodeList.add(administrativeArea.get(2).toString());
|
||||
//保存项目镇代码列表
|
||||
|
||||
if(administrativeArea.size()>=4){
|
||||
//保存项目镇代码列表
|
||||
townCodeList.add(administrativeArea.get(3).toString());
|
||||
}
|
||||
if(administrativeArea.size()>=5){
|
||||
//保存项目村代码列表
|
||||
villageCodeList.add(administrativeArea.get(4).toString());
|
||||
}
|
||||
});
|
||||
|
||||
//设置项目省、市、县、镇、村行政区划代码列表
|
||||
sysDept.setProvinceCode(JSONUtil.toJsonStr(provincialCodeList));
|
||||
sysDept.setCityCode(JSONUtil.toJsonStr(cityCodeList));
|
||||
sysDept.setCountyCode(JSONUtil.toJsonStr(countyCodeList));
|
||||
sysDept.setTownCode(JSONUtil.toJsonStr(townCodeList));
|
||||
sysDept.setVillageCode(JSONUtil.toJsonStr(villageCodeList));
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证json对象是否是数组
|
||||
*/
|
||||
public boolean isNotValidJsonArray(String jsonStr) {
|
||||
try {
|
||||
JSONUtil.parseArray(jsonStr);
|
||||
} catch (JSONException e) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存部门信息
|
||||
*
|
||||
@ -261,17 +342,26 @@ public class SysDeptServiceImpl implements ISysDeptService
|
||||
})
|
||||
@Override
|
||||
public int updateDept(SysDept dept)
|
||||
{
|
||||
{ //查询当前修改部门的父部门
|
||||
SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
|
||||
//查询当前修改部门修改前的旧数据
|
||||
SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId());
|
||||
if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept))
|
||||
{
|
||||
//更新部门的祖级列表
|
||||
String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
|
||||
String oldAncestors = oldDept.getAncestors();
|
||||
dept.setAncestors(newAncestors);
|
||||
updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
|
||||
}
|
||||
|
||||
//处理机构所管理行政区划信息
|
||||
parseAdministrativeDivisionInfo(dept);
|
||||
//更新部门信息
|
||||
dept.setUpdateTime(DateUtils.getNowDate());
|
||||
int result = deptMapper.updateDept(dept);
|
||||
|
||||
|
||||
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
|
||||
&& !StringUtils.equals("0", dept.getAncestors()))
|
||||
{
|
||||
@ -283,7 +373,6 @@ public class SysDeptServiceImpl implements ISysDeptService
|
||||
|
||||
/**
|
||||
* 修改该部门的父级部门状态
|
||||
*
|
||||
* @param dept 当前部门
|
||||
*/
|
||||
private void updateParentDeptStatusNormal(SysDept dept)
|
||||
|
@ -102,9 +102,9 @@ public class SysDistrictServiceImpl implements ISysDistrictService
|
||||
* @param mapOutlineUrl 地图轮廓json文件访问uel
|
||||
*/
|
||||
private void verifySaveJsonData(SysDistrict sysDistrict, String mapOutlineUrl) {
|
||||
//行政区划轮廓json文件url必须是绝对完整
|
||||
//行政区划轮廓json文件url是绝对url代表新上传过
|
||||
if(!(mapOutlineUrl.contains("http://") || mapOutlineUrl.contains("https://"))){
|
||||
throw new ServiceException("行政区划轮廓json文件url不正确!");
|
||||
return ;
|
||||
}
|
||||
//上传行政区划轮廓进行数据处理
|
||||
String jsonData = HttpUtil.get(mapOutlineUrl);
|
||||
@ -135,7 +135,7 @@ public class SysDistrictServiceImpl implements ISysDistrictService
|
||||
if(StringUtils.isBlank(mapOutlineUrl)){
|
||||
return sysDistrictMapper.updateSysDistrict(sysDistrict);
|
||||
}
|
||||
//判断行政区划轮廓json文件路url是否是完整url还是相对url
|
||||
//判断行政区划轮廓json文件路url是否是完整url还是相对url,如果是相对url则代表并未修改,绝对url代表修改过
|
||||
verifySaveJsonData(sysDistrict, mapOutlineUrl);
|
||||
|
||||
return sysDistrictMapper.updateSysDistrict(sysDistrict);
|
||||
|
Reference in New Issue
Block a user