|
@@ -6,7 +6,10 @@ import com.ruoyi.common.core.text.Convert;
|
|
import com.ruoyi.common.core.utils.SpringUtils;
|
|
import com.ruoyi.common.core.utils.SpringUtils;
|
|
import com.ruoyi.common.core.utils.StringUtils;
|
|
import com.ruoyi.common.core.utils.StringUtils;
|
|
import com.ruoyi.common.datascope.annotation.DataScope;
|
|
import com.ruoyi.common.datascope.annotation.DataScope;
|
|
|
|
+import com.ruoyi.common.redis.service.RedisService;
|
|
import com.ruoyi.common.security.utils.SecurityUtils;
|
|
import com.ruoyi.common.security.utils.SecurityUtils;
|
|
|
|
+import com.ruoyi.ext.api.utils.OpenDictUtil;
|
|
|
|
+import com.ruoyi.ext.api.utils.OtherConstants;
|
|
import com.ruoyi.system.api.domain.SysDept;
|
|
import com.ruoyi.system.api.domain.SysDept;
|
|
import com.ruoyi.system.api.domain.SysRole;
|
|
import com.ruoyi.system.api.domain.SysRole;
|
|
import com.ruoyi.system.domain.SysDeptJl;
|
|
import com.ruoyi.system.domain.SysDeptJl;
|
|
@@ -19,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -38,6 +42,9 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|
@Autowired
|
|
@Autowired
|
|
private SysDeptJlMapper sysDeptJlMapper;
|
|
private SysDeptJlMapper sysDeptJlMapper;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private RedisService redisService;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 查询部门管理数据
|
|
* 查询部门管理数据
|
|
*
|
|
*
|
|
@@ -58,19 +65,6 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|
return buildDeptTreeSelect(deptMapper.selectDeptTreeList(dept));
|
|
return buildDeptTreeSelect(deptMapper.selectDeptTreeList(dept));
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 查询部门树结构信息
|
|
|
|
- *
|
|
|
|
- * @param dept 部门信息
|
|
|
|
- * @return 部门树信息集合
|
|
|
|
- */
|
|
|
|
- @Override
|
|
|
|
- public List<TreeSelect> selectDeptTreeList(SysDept dept)
|
|
|
|
- {
|
|
|
|
- List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
|
|
|
|
- return buildDeptTreeSelect(depts);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 构建前端所需要树结构
|
|
* 构建前端所需要树结构
|
|
*
|
|
*
|
|
@@ -423,4 +417,64 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|
{
|
|
{
|
|
return getChildList(list, t).size() > 0 ? true : false;
|
|
return getChildList(list, t).size() > 0 ? true : false;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 同步行政区到部门表
|
|
|
|
+ *
|
|
|
|
+ * @return 结果
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public boolean syncToDept() {
|
|
|
|
+ Object sync_time = redisService.getCacheObject("sync_time");
|
|
|
|
+ if (sync_time != null) {
|
|
|
|
+ throw new ServiceException("正在同步中,请稍后重试");
|
|
|
|
+ }
|
|
|
|
+ redisService.setCacheObject("sync_time", 1, 5L, TimeUnit.MINUTES);
|
|
|
|
+ HashMap<String, String> map = OpenDictUtil.getDeptLabel();
|
|
|
|
+
|
|
|
|
+ // 同步一级地区
|
|
|
|
+ SysDeptJl item = sysDeptJlMapper.selectSysDeptJlById(OtherConstants.DEPT_ID_JL);
|
|
|
|
+// SysDept sysDept1 = syncD(item, 0L, map);
|
|
|
|
+ // 同步二级地区
|
|
|
|
+ List<SysDeptJl> sysDeptJls2 = sysDeptJlMapper.selectSysDeptJlByParentId(item.getId());
|
|
|
|
+ for (SysDeptJl item2 : sysDeptJls2) {
|
|
|
|
+ SysDept sysDept2 = syncD(item2, 1L, map);
|
|
|
|
+
|
|
|
|
+ List<SysDeptJl> sysDeptJls3 = sysDeptJlMapper.selectSysDeptJlByParentId(item2.getId());
|
|
|
|
+ for (SysDeptJl item3 : sysDeptJls3) {
|
|
|
|
+ SysDept sysDept3 = syncD(item3, sysDept2.getDeptId(), map);
|
|
|
|
+
|
|
|
|
+ List<SysDeptJl> sysDeptJls4 = sysDeptJlMapper.selectSysDeptJlByParentId(item3.getId());
|
|
|
|
+ for (SysDeptJl item4 : sysDeptJls4) {
|
|
|
|
+ SysDept sysDept4 = syncD(item4, sysDept3.getDeptId(), map);
|
|
|
|
+
|
|
|
|
+ List<SysDeptJl> sysDeptJls5 = sysDeptJlMapper.selectSysDeptJlByParentId(item4.getId());
|
|
|
|
+ for (SysDeptJl item5 : sysDeptJls5) {
|
|
|
|
+ syncD(item5, sysDept4.getDeptId(), map);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private SysDept syncD(SysDeptJl item, Long parentId, HashMap<String, String> map) {
|
|
|
|
+ try {
|
|
|
|
+ SysDept sysDept = new SysDept();
|
|
|
|
+// sysDept.setDeptId(Long.parseLong(item.getCode()));
|
|
|
|
+ sysDept.setDeptName(item.getName() + map.get(item.getLevel()));
|
|
|
|
+ sysDept.setOrderNum(0);
|
|
|
|
+ sysDept.setStatus("0");
|
|
|
|
+ sysDept.setParentId(parentId);
|
|
|
|
+ sysDept.setLocationCode(item.getCode());
|
|
|
|
+ this.insertDept(sysDept);
|
|
|
|
+ return sysDept;
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
}
|
|
}
|