|
@@ -6,12 +6,18 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.zjugis.framework.common.pojo.CommonResult;
|
|
|
+import com.zjugis.framework.common.pojo.PageResult;
|
|
|
+import com.zjugis.module.system.api.dept.dto.DeptRespDTO;
|
|
|
+import com.zjugis.module.system.api.permission.dto.RoleRespDto;
|
|
|
import com.zjugis.z_workflow.base.utils.JsonUtils;
|
|
|
import com.zjugis.z_workflow.base.utils.Select;
|
|
|
import com.zjugis.z_workflow.base.utils.ServiceApiUtils;
|
|
|
import com.zjugis.z_workflow.dto.*;
|
|
|
import com.zjugis.z_workflow.entity.CodeTemplate;
|
|
|
import com.zjugis.z_workflow.entity.Form;
|
|
|
+import com.zjugis.z_workflow.remote.DeptClient;
|
|
|
+import com.zjugis.z_workflow.remote.RoleClient;
|
|
|
import com.zjugis.z_workflow.utils.*;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.logging.log4j.util.Strings;
|
|
@@ -45,6 +51,12 @@ public class CallInterfaceService {
|
|
|
@Autowired
|
|
|
CodeTemplateService codeTemplateService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RoleClient roleClient;
|
|
|
+ @Autowired
|
|
|
+ private DeptClient deptClient;
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -75,33 +87,24 @@ public class CallInterfaceService {
|
|
|
**/
|
|
|
public List<zTree> getDepartmentList(int iDeptUsers, Boolean iOpen, Integer informal) {
|
|
|
List<zTree> treeList = new ArrayList();
|
|
|
- //参数
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("dID", "");//部门ID,默认传空
|
|
|
- map.put("iChild", "1");//是否包含子部门(1:包含 0:不包含)
|
|
|
- map.put("iPosition", "0");//是否包含职位(1:包含 0:不包含)
|
|
|
- map.put("iPositionUsers", "0");//是否包含职位人员(1:包含 0:不包含)
|
|
|
- map.put("iDeptUsers", iDeptUsers);//是否包含部门人员(1:包含 0:不包含)
|
|
|
- if (!Objects.isNull(informal)) {
|
|
|
- map.put("informal", informal);//0:正式部门,1:非正式部门,null:全部
|
|
|
- }
|
|
|
//获取接口返回数据
|
|
|
- JSONArray arrayResult = callInterfaceReturnList("z_user_org_right", "DepartmentApi/getOrgTree", map);
|
|
|
- if (Objects.isNull(arrayResult)) {
|
|
|
+ CommonResult<List<DeptRespDTO>> result = deptClient.getSimpleDeptList();
|
|
|
+ List<DeptRespDTO> list = result.getData();
|
|
|
+ if (list == null || list.isEmpty()) {
|
|
|
return treeList;
|
|
|
}
|
|
|
//遍历数据,转换为需要的格式
|
|
|
- int arraySize = arrayResult.size();
|
|
|
+ int arraySize = list.size();
|
|
|
if (arraySize > 0) {
|
|
|
zTree ztree;
|
|
|
- JSONObject jsonObj;
|
|
|
+ DeptRespDTO dept;
|
|
|
for (int i = 0; i < arraySize; i++) {
|
|
|
- jsonObj = arrayResult.getJSONObject(i);
|
|
|
+ dept = list.get(i);
|
|
|
ztree = new zTree();
|
|
|
- ztree.setId(jsonObj.getString("id"));
|
|
|
- ztree.setName(jsonObj.getString("name"));
|
|
|
- ztree.setPid(jsonObj.getString("pid"));
|
|
|
- ztree.setType(jsonObj.getInteger("type"));
|
|
|
+ ztree.setId(String.valueOf(dept.getId()));
|
|
|
+ ztree.setName(dept.getName());
|
|
|
+ ztree.setPid(dept.getParentId() == 0?"":String.valueOf(dept.getParentId()));
|
|
|
+ ztree.setType(1);
|
|
|
if (ztree.getType() == 1) {
|
|
|
ztree.setAllowSelect(true);
|
|
|
} else {
|
|
@@ -238,23 +241,22 @@ public class CallInterfaceService {
|
|
|
**/
|
|
|
public List<zTree> getRoleList() {
|
|
|
List<zTree> treeList = new ArrayList();
|
|
|
- //参数
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
//获取接口返回数据
|
|
|
- JSONArray arrayResult = callInterfaceReturnList("z_user_org_right", "RoleApi/getList", map);
|
|
|
- if (arrayResult == null) {
|
|
|
+ CommonResult<List<RoleRespDto>> result = roleClient.getSimpleRoleList();
|
|
|
+ List<RoleRespDto> arrayResult = result.getData();
|
|
|
+ if (arrayResult == null) {
|
|
|
return treeList;
|
|
|
}
|
|
|
//遍历数据,转换为需要的格式
|
|
|
int arraySize = arrayResult.size();
|
|
|
if (arraySize > 0) {
|
|
|
zTree ztree;
|
|
|
- JSONObject jsonObj;
|
|
|
+ RoleRespDto role;
|
|
|
for (int i = 0; i < arraySize; i++) {
|
|
|
- jsonObj = arrayResult.getJSONObject(i);
|
|
|
+ role = arrayResult.get(i);
|
|
|
ztree = new zTree();
|
|
|
- ztree.setId(jsonObj.getString("id"));
|
|
|
- ztree.setName(jsonObj.getString("name"));
|
|
|
+ ztree.setId(String.valueOf(role.getId()));
|
|
|
+ ztree.setName(role.getName());
|
|
|
ztree.setType(1);
|
|
|
ztree.setAllowSelect(true);
|
|
|
treeList.add(ztree);
|
|
@@ -337,31 +339,28 @@ public class CallInterfaceService {
|
|
|
**/
|
|
|
public IPage<RoleDto> getRoleList(RoleDto roleDto, long page, long rows) {
|
|
|
IPage<RoleDto> rolePage = new Page<RoleDto>(page, rows);
|
|
|
- //参数
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("role", JSON.toJSONString(roleDto));//序列化查询对象
|
|
|
- map.put("page", "{\"page\":\"" + page + "\",\"rows\":\"" + rows + "\"}");//分页对象
|
|
|
- //获取接口返回数据
|
|
|
- JSONObject objectResult = callInterfaceReturnPageList("z_user_org_right", "RoleApi/getList", map);
|
|
|
- if (objectResult == null) {
|
|
|
+ //获取接口返回数据
|
|
|
+ CommonResult<PageResult<RoleRespDto>> result = roleClient.getRolePage(page, rows, null, roleDto.getName());
|
|
|
+ PageResult<RoleRespDto> pageResult = result.getData();
|
|
|
+ if (pageResult == null) {
|
|
|
return rolePage;
|
|
|
}
|
|
|
//将JSONObject转换为需要的分页数据
|
|
|
- int total = Integer.parseInt(String.valueOf(objectResult.get("records")));//总记录数
|
|
|
- JSONArray records = JSONArray.parseArray(String.valueOf(objectResult.get("rows")));//列表数据
|
|
|
- List<RoleDto> roleList = new ArrayList<>();
|
|
|
- if (records.size() > 0) {
|
|
|
+ int total = Math.toIntExact(pageResult.getTotal());//总记录数
|
|
|
+ List<RoleRespDto> records = pageResult.getList();//列表数据
|
|
|
+ List<RoleDto> roleList = new ArrayList<>();
|
|
|
+ if (!records.isEmpty()) {
|
|
|
RoleDto roleInfo;
|
|
|
- JSONObject jsonObj;
|
|
|
- for (int i = 0; i < records.size(); i++) {
|
|
|
- roleInfo = new RoleDto();
|
|
|
- jsonObj = records.getJSONObject(i);
|
|
|
- roleInfo.setId(jsonObj.getString("id"));
|
|
|
- roleInfo.setName(jsonObj.getString("name"));
|
|
|
- roleInfo.setClassify(jsonObj.getString("classify"));
|
|
|
- roleInfo.setIndexCode(jsonObj.getInteger("indexCode"));
|
|
|
- roleList.add(roleInfo);
|
|
|
- }
|
|
|
+ RoleRespDto role;
|
|
|
+ for (RoleRespDto record : records) {
|
|
|
+ roleInfo = new RoleDto();
|
|
|
+ role = record;
|
|
|
+ roleInfo.setId(String.valueOf(role.getId()));
|
|
|
+ roleInfo.setName(role.getName());
|
|
|
+ roleInfo.setClassify(String.valueOf(role.getType()));
|
|
|
+ roleInfo.setIndexCode(role.getSort());
|
|
|
+ roleList.add(roleInfo);
|
|
|
+ }
|
|
|
}
|
|
|
rolePage.setTotal(total);
|
|
|
rolePage.setRecords(roleList);
|
|
@@ -377,13 +376,12 @@ public class CallInterfaceService {
|
|
|
public String getRoleName(String id) {
|
|
|
//参数
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("id", id);//部门ID
|
|
|
//获取接口返回数据
|
|
|
- JSONObject objResult = callInterfaceReturnObj("z_user_org_right", "RoleApi/getRoleById", map);
|
|
|
- if (objResult == null) {
|
|
|
+ CommonResult<RoleRespDto> role = roleClient.get(Long.valueOf(id));
|
|
|
+ if (role == null) {
|
|
|
return Strings.EMPTY;
|
|
|
}
|
|
|
- return objResult.getString("name");
|
|
|
+ return role.getData().getName();
|
|
|
}
|
|
|
|
|
|
/**
|