|
@@ -7,6 +7,7 @@ import java.util.ArrayList;
|
|
|
import java.util.Iterator;
|
|
|
import java.util.List;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -262,4 +263,36 @@ public class SysDeptController extends BaseController
|
|
|
public List<SysDept> getByParentId(@PathVariable("parentId") Long parentId) {
|
|
|
return deptService.getByParentId(parentId);
|
|
|
}
|
|
|
+
|
|
|
+ public AjaxResult setAncestors(){
|
|
|
+ List<SysDept> sysDepts = deptService.selectDepts(new SysDept());
|
|
|
+ for (SysDept sysDept : sysDepts) {
|
|
|
+ String ancestors = sysDept.getAncestors();
|
|
|
+ if (StringUtils.isEmpty(ancestors)) {
|
|
|
+ Long id = sysDept.getId();
|
|
|
+ SysDept parent1 = deptService.getParentById(id);
|
|
|
+ if (parent1 == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 村
|
|
|
+ Long id1 = parent1.getId();
|
|
|
+ SysDept parent2 = deptService.getParentById(id1);
|
|
|
+ if (parent2 == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 镇
|
|
|
+ Long id2 = parent2.getId();
|
|
|
+ SysDept parent3 = deptService.getParentById(id2);
|
|
|
+ if (parent3 == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 潜山市
|
|
|
+ Long id3 = parent3.getId();
|
|
|
+ sysDept.setAncestors(id3 + "," + id2 + "," + id1);
|
|
|
+ System.out.println(JSON.toJSONString(sysDept));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
}
|