|
@@ -3,16 +3,20 @@ package com.ruoyi.system.service.impl;
|
|
|
import com.ruoyi.common.core.exception.ServiceException;
|
|
|
import com.ruoyi.common.core.utils.StringUtils;
|
|
|
import com.ruoyi.common.core.utils.uuid.IdUtils;
|
|
|
+import com.ruoyi.common.security.utils.SysDeptJlUtils;
|
|
|
import com.ruoyi.system.domain.SysDeptJl;
|
|
|
import com.ruoyi.system.mapper.SysDeptJlMapper;
|
|
|
import com.ruoyi.system.service.ISysDeptJlService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import javax.annotation.PostConstruct;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
|
* 吉林地区管理Service业务层处理
|
|
@@ -119,7 +123,10 @@ public class SysDeptJlServiceImpl implements ISysDeptJlService {
|
|
|
sysDeptJl.setCode(s);
|
|
|
sysDeptJl.setLevel(Integer.parseInt(sysDeptJl1.getLevel()) + 1 + "");
|
|
|
sysDeptJl.setId(IdUtils.simpleUUID());
|
|
|
- return sysDeptJlMapper.insertSysDeptJl(sysDeptJl);
|
|
|
+ sysDeptJl.setFullName(getLocationName(sysDeptJl1.getCode() + " " + sysDeptJl.getName()));
|
|
|
+ int res = sysDeptJlMapper.insertSysDeptJl(sysDeptJl);
|
|
|
+ SysDeptJlUtils.setDeptCache(sysDeptJl.getCode(), sysDeptJl.getFullName());
|
|
|
+ return res;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -130,10 +137,14 @@ public class SysDeptJlServiceImpl implements ISysDeptJlService {
|
|
|
*/
|
|
|
@Override
|
|
|
public int updateSysDeptJl(SysDeptJl sysDeptJl) {
|
|
|
+ SysDeptJl old = sysDeptJlMapper.selectById(sysDeptJl.getId());
|
|
|
+ sysDeptJl.setFullName(getLocationName(old.getParentId()) + " " + sysDeptJl.getName());
|
|
|
sysDeptJl.setParentId(null);
|
|
|
sysDeptJl.setLevel(null);
|
|
|
sysDeptJl.setCode(null);
|
|
|
- return sysDeptJlMapper.updateSysDeptJl(sysDeptJl);
|
|
|
+ int res = sysDeptJlMapper.updateSysDeptJl(sysDeptJl);
|
|
|
+ SysDeptJlUtils.setDeptCache(old.getCode(), sysDeptJl.getFullName());
|
|
|
+ return res;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -144,6 +155,11 @@ public class SysDeptJlServiceImpl implements ISysDeptJlService {
|
|
|
*/
|
|
|
@Override
|
|
|
public int deleteSysDeptJlByIds(String[] ids) {
|
|
|
+ List<String> idList = Stream.of(ids).collect(Collectors.toList());
|
|
|
+ idList.forEach(i -> {
|
|
|
+ SysDeptJl delete = sysDeptJlMapper.selectById(i);
|
|
|
+ SysDeptJlUtils.removeDeptCache(delete.getCode());
|
|
|
+ });
|
|
|
return sysDeptJlMapper.deleteSysDeptJlByIds(ids);
|
|
|
}
|
|
|
|
|
@@ -155,6 +171,8 @@ public class SysDeptJlServiceImpl implements ISysDeptJlService {
|
|
|
*/
|
|
|
@Override
|
|
|
public int deleteSysDeptJlById(String id) {
|
|
|
+ SysDeptJl delete = sysDeptJlMapper.selectById(id);
|
|
|
+ SysDeptJlUtils.removeDeptCache(delete.getCode());
|
|
|
return sysDeptJlMapper.deleteSysDeptJlById(id);
|
|
|
}
|
|
|
|
|
@@ -243,4 +261,26 @@ public class SysDeptJlServiceImpl implements ISysDeptJlService {
|
|
|
public String getLocationName(String code) {
|
|
|
return sysDeptJlMapper.getXzqhNames(code);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 项目启动时,初始化行政区划到缓存
|
|
|
+ */
|
|
|
+ @PostConstruct
|
|
|
+ public void init()
|
|
|
+ {
|
|
|
+ loadingDeptCache();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void loadingDeptCache()
|
|
|
+ {
|
|
|
+ List<SysDeptJl> sysDeptJlList = sysDeptJlMapper.selectSysDeptJlUnderJl();
|
|
|
+ sysDeptJlList.forEach(s -> SysDeptJlUtils.setDeptCache(s.getCode(), s.getFullName()));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void clearDeptCache()
|
|
|
+ {
|
|
|
+ SysDeptJlUtils.clearDeptCache();
|
|
|
+ }
|
|
|
}
|