|
|
|
@ -12,10 +12,7 @@ import com.hxgk.lowcode.mapper.CustomerFormMapper; |
|
|
|
import com.hxgk.lowcode.mapper.CustomerFormViewMapper; |
|
|
|
import com.hxgk.lowcode.mapper.FieldRecordMapper; |
|
|
|
import com.hxgk.lowcode.model.entity.*; |
|
|
|
import com.hxgk.lowcode.service.CustomerFormService; |
|
|
|
import com.hxgk.lowcode.service.HrService; |
|
|
|
import com.hxgk.lowcode.service.SystemRoleService; |
|
|
|
import com.hxgk.lowcode.service.UserService; |
|
|
|
import com.hxgk.lowcode.service.*; |
|
|
|
import com.hxgk.lowcode.utils.HttpUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.http.protocol.HTTP; |
|
|
|
@ -45,11 +42,276 @@ public class CustomerFormServiceImpl implements CustomerFormService { |
|
|
|
@Autowired |
|
|
|
private HrService hrService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private CustomerFormGroupService customerFormGroupService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private AppmenusService appmenusService; |
|
|
|
|
|
|
|
private static final Logger logger = LogManager.getLogger(); |
|
|
|
|
|
|
|
/*@Override |
|
|
|
//根据用户权限查询表单列表
|
|
|
|
public Tree getCustomerFormList(String key, String token) { |
|
|
|
|
|
|
|
|
|
|
|
//查询出所有表单
|
|
|
|
ArrayList<CustomerForm> customerFormList = customerFormMapper.getCustomerFormList(); |
|
|
|
|
|
|
|
//获取用户信息 从redis中根据userkey和usertoken拿到userdetail
|
|
|
|
Map<String,String> keytokenmap = new HashMap<>(); |
|
|
|
keytokenmap.put("userkey",key); |
|
|
|
keytokenmap.put("usertoken",token); |
|
|
|
UserDetail userDetail = userService.getUserDetailFromRedis(keytokenmap); |
|
|
|
if(userDetail==null){ |
|
|
|
return null; |
|
|
|
}else{ |
|
|
|
//得到所有启用的系统角色(state=1的)
|
|
|
|
ArrayList<SystemRole> roleList = systemRoleService.getAllRole(); |
|
|
|
|
|
|
|
//根据权限算法过滤后的list
|
|
|
|
ArrayList<CustomerForm> customerFormList1 = new ArrayList<>(); |
|
|
|
|
|
|
|
Tree tree = new Tree(); |
|
|
|
tree.setId("rootid"); |
|
|
|
tree.setLabel("请选择表单"); |
|
|
|
tree.setValue("rootvalue"); |
|
|
|
//筛选出所有表单中,当前用户有权限的表单
|
|
|
|
for(CustomerForm c:customerFormList){//
|
|
|
|
|
|
|
|
//把权限相关字段字符串处理为数组
|
|
|
|
|
|
|
|
//可见人员
|
|
|
|
String userpermitArrStr = c.getUserpermit(); |
|
|
|
String[] userpermitArr = new String[0]; |
|
|
|
if(!StringUtils.isBlank(userpermitArrStr)){ |
|
|
|
if(userpermitArrStr.contains(",")){ |
|
|
|
userpermitArr = userpermitArrStr.split(","); |
|
|
|
}else{ |
|
|
|
userpermitArr = new String[]{userpermitArrStr}; |
|
|
|
} |
|
|
|
} |
|
|
|
//可见角色
|
|
|
|
String postpermitArrStr = c.getPostpermit(); |
|
|
|
String[] postpermitArr = new String[0]; |
|
|
|
if(!StringUtils.isBlank(postpermitArrStr)){ |
|
|
|
if(postpermitArrStr.contains(",")){ |
|
|
|
postpermitArr = postpermitArrStr.split(","); |
|
|
|
}else{ |
|
|
|
postpermitArr = new String[]{postpermitArrStr}; |
|
|
|
} |
|
|
|
} |
|
|
|
//授权范围
|
|
|
|
String permitArrStr = c.getPermit(); |
|
|
|
String[] permitArr = new String[0]; |
|
|
|
//对本表单有权限的组织机构list
|
|
|
|
ArrayList<String> permitArrList = new ArrayList<>(); |
|
|
|
if(!StringUtils.isBlank(permitArrStr)){ |
|
|
|
if(permitArrStr.contains("],[")) { |
|
|
|
permitArr = StringUtils.splitByWholeSeparator(permitArrStr, "],["); |
|
|
|
for(int i = 0; i < permitArr.length; i++){ |
|
|
|
String[] arr = StringUtils.splitByWholeSeparator(permitArr[i],","); |
|
|
|
for(int j = 0; j < arr.length; j++){ |
|
|
|
if(j == arr.length-1){ |
|
|
|
if(i == permitArr.length-1){ |
|
|
|
String lastOrg = arr[j]; |
|
|
|
lastOrg = lastOrg.split("]]")[0]; |
|
|
|
permitArrList.add(lastOrg);//
|
|
|
|
}else{ |
|
|
|
permitArrList.add(arr[j]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}else{ |
|
|
|
permitArr = StringUtils.splitByWholeSeparator(permitArrStr, ","); |
|
|
|
for(int i = 0; i < permitArr.length; i++){ |
|
|
|
if(i==permitArr.length-1){ |
|
|
|
permitArrList.add(permitArr[i].split("]")[0]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//StringUtils.isBlank() 判断null和""
|
|
|
|
if(StringUtils.isBlank(c.getPermit())&&StringUtils.isBlank(c.getPermitstr())&&StringUtils.isBlank(c.getUserpermit())&&StringUtils.isBlank(c.getPostpermit())){ |
|
|
|
//本表单所有用户都有权限
|
|
|
|
customerFormList1.add(c); |
|
|
|
}else if(StringUtils.isNotEmpty(c.getUserpermit())){ |
|
|
|
//按照可见人员判断权限 cus
|
|
|
|
for (int i = 0; i < userpermitArr.length; i++) { |
|
|
|
if(userpermitArr[i].equals(userDetail.getWmKey().toString())){ |
|
|
|
customerFormList1.add(c); |
|
|
|
} |
|
|
|
} |
|
|
|
}else if(StringUtils.isNotEmpty(c.getPostpermit())){ |
|
|
|
//按照可见角色判断权限
|
|
|
|
for (int i = 0; i < postpermitArr.length; i++) { |
|
|
|
if(postpermitArr[i].equals(userDetail.getRoleId().toString())){ |
|
|
|
customerFormList1.add(c); |
|
|
|
} |
|
|
|
} |
|
|
|
}else if(StringUtils.isNotEmpty(c.getPermit())){ |
|
|
|
//按照授权范围(org)判断权限
|
|
|
|
//userDetail.adminOrg在permitArrList中的话,则本用户对本表单有权限
|
|
|
|
for(String item: permitArrList){ |
|
|
|
if(item.equals(userDetail.getAdminorg().toString())){ |
|
|
|
customerFormList1.add(c); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//根据权限过滤完成customerFormList1
|
|
|
|
ArrayList<String> tablekeyList = new ArrayList<>(); |
|
|
|
for(CustomerForm item:customerFormList1){ |
|
|
|
tablekeyList.add(item.getTablename()); |
|
|
|
} |
|
|
|
ArrayList<CustomerFormView> customerFormViewArrayList = customerFormViewMapper.getCustomerFormViewListByTablekey(tablekeyList); |
|
|
|
ArrayList<Tree> treeArrayList1 = new ArrayList<>(); |
|
|
|
for(CustomerFormView item:customerFormViewArrayList){ |
|
|
|
|
|
|
|
Tree tree1 = new Tree(); |
|
|
|
if(item.getClassify()==3){//app
|
|
|
|
*//*String signCode = item.getSignCode();
|
|
|
|
//调用GO接口获取App结构,过滤掉非表单和目录的数据
|
|
|
|
|
|
|
|
String url = "http://172.20.2.87:7777/app/gainAppEditPsge";//本地+内网
|
|
|
|
//String url = "http://36.133.126.182:39250/app/gainAppEditPsge";//外网
|
|
|
|
|
|
|
|
JSONObject param = new JSONObject(); |
|
|
|
param.put("id", signCode); |
|
|
|
String post = null; |
|
|
|
|
|
|
|
try { |
|
|
|
post = HttpUtils.send(url, param, HTTP.UTF_8, key, token); |
|
|
|
System.out.println("post:"+post.toString()); |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
}*//*
|
|
|
|
|
|
|
|
tree1.setId(item.getCfid()); |
|
|
|
tree1.setParentId(tree.getId()); |
|
|
|
tree1.setLabel("App-"+item.getName()); |
|
|
|
tree1.setValue(item.getCfid()); |
|
|
|
tree1.setDisabled(true); |
|
|
|
|
|
|
|
ArrayList<CustomerFormView> appForms = customerFormViewMapper.getCustomerFormViewListByGroupid(item.getSignCode()); |
|
|
|
if(appForms.size()>0){ |
|
|
|
ArrayList<Tree> treeArrayListx = new ArrayList<>(); |
|
|
|
for(CustomerFormView itemx:appForms){ |
|
|
|
Tree tree2 = new Tree(); |
|
|
|
|
|
|
|
tree2.setId(itemx.getCfid()); |
|
|
|
tree2.setParentId(tree1.getId()); |
|
|
|
tree2.setLabel("Form-"+itemx.getName()); |
|
|
|
tree2.setValue(itemx.getCfid()); |
|
|
|
HashMap<String,Object> treeAttrs = new HashMap<>(); |
|
|
|
treeAttrs.put("version",itemx.getVersion().toString()); |
|
|
|
tree2.setTreeAttrs(treeAttrs); |
|
|
|
ArrayList<Tree> treeArrayList = new ArrayList<>(); |
|
|
|
if(!StringUtils.isBlank(itemx.getTableStructure())){ |
|
|
|
|
|
|
|
String tableStructure = itemx.getTableStructure(); |
|
|
|
tableStructure = tableStructure.replace("{",""); |
|
|
|
tableStructure = tableStructure.replace("}",""); |
|
|
|
tableStructure = tableStructure.replace("\"",""); |
|
|
|
String[] tableStructureArr = StringUtils.splitByWholeSeparator(tableStructure, ","); |
|
|
|
|
|
|
|
for(String item1:tableStructureArr){ |
|
|
|
String l = StringUtils.splitByWholeSeparator(item1, ":")[1]; |
|
|
|
Tree tree3 = new Tree(); |
|
|
|
tree3.setLabel("子表-"+l); |
|
|
|
tree3.setParentId(tree2.getId()); |
|
|
|
tree3.setId(tree2.getId()+":zibiaoid-"+l); |
|
|
|
tree3.setValue(tree3.getId()); |
|
|
|
treeArrayList.add(tree3); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
tree2.setChildren(treeArrayList); |
|
|
|
|
|
|
|
|
|
|
|
treeArrayListx.add(tree2); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
HashMap<String,Object> treeAttrs = new HashMap<>(); |
|
|
|
treeAttrs.put("version",item.getVersion().toString()); |
|
|
|
tree1.setChildren(treeArrayListx); |
|
|
|
tree1.setTreeAttrs(treeAttrs); |
|
|
|
|
|
|
|
} |
|
|
|
treeArrayList1.add(tree1); |
|
|
|
}else{ |
|
|
|
tree1.setId(item.getCfid()); |
|
|
|
tree1.setParentId(tree.getId()); |
|
|
|
tree1.setLabel("Form-"+item.getName()); |
|
|
|
tree1.setValue(item.getCfid()); |
|
|
|
HashMap<String,Object> treeAttrs = new HashMap<>(); |
|
|
|
treeAttrs.put("version",item.getVersion().toString()); |
|
|
|
tree1.setTreeAttrs(treeAttrs); |
|
|
|
ArrayList<Tree> treeArrayList = new ArrayList<>(); |
|
|
|
if(!StringUtils.isBlank(item.getTableStructure())){ |
|
|
|
|
|
|
|
String tableStructure = item.getTableStructure(); |
|
|
|
tableStructure = tableStructure.replace("{",""); |
|
|
|
tableStructure = tableStructure.replace("}",""); |
|
|
|
tableStructure = tableStructure.replace("\"",""); |
|
|
|
String[] tableStructureArr = StringUtils.splitByWholeSeparator(tableStructure, ","); |
|
|
|
|
|
|
|
for(String item1:tableStructureArr){ |
|
|
|
String l = StringUtils.splitByWholeSeparator(item1, ":")[1]; |
|
|
|
Tree tree2 = new Tree(); |
|
|
|
tree2.setLabel("子表-"+l); |
|
|
|
tree2.setParentId(tree1.getId()); |
|
|
|
tree2.setId(tree1.getId()+":zibiaoid-"+l); |
|
|
|
tree2.setValue(tree2.getId()); |
|
|
|
treeArrayList.add(tree2); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
tree1.setChildren(treeArrayList); |
|
|
|
treeArrayList1.add(tree1); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
tree.setChildren(treeArrayList1); |
|
|
|
return tree; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
//根据用户权限查询表单列表
|
|
|
|
public Tree getCustomerFormList(String key, String token) { |
|
|
|
//查询出所有分组
|
|
|
|
ArrayList<CustomerFormGroup> allCustomerFormGroup = customerFormGroupService.getAllCustomerFormGroup(); |
|
|
|
ArrayList<ArrayList<CustomerForm>> appslists = new ArrayList<>(); |
|
|
|
ArrayList<ArrayList<Tree>> AllGroupAppTreeList = new ArrayList<>(); |
|
|
|
for (CustomerFormGroup item: allCustomerFormGroup) { |
|
|
|
//获取分组中的所有App
|
|
|
|
ArrayList<CustomerForm> appsByGroupId = getAppsByGroupId(item); |
|
|
|
appslists.add(appsByGroupId); |
|
|
|
//获取App的目录树
|
|
|
|
ArrayList<Tree> singleGroupAppTreeList = new ArrayList<>(); |
|
|
|
for(CustomerForm item1:appsByGroupId){ |
|
|
|
String appmenusAppkey = item1.getSignCode(); |
|
|
|
Tree appTree = appmenusService.getAppTree(appmenusAppkey,item1); |
|
|
|
singleGroupAppTreeList.add(appTree); |
|
|
|
|
|
|
|
} |
|
|
|
AllGroupAppTreeList.add(singleGroupAppTreeList); |
|
|
|
|
|
|
|
} |
|
|
|
System.out.println(1); |
|
|
|
|
|
|
|
|
|
|
|
//查询出所有表单
|
|
|
|
@ -285,6 +547,8 @@ public class CustomerFormServiceImpl implements CustomerFormService { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public Tree getFieldTree(String key,String token,String cfid) { |
|
|
|
Boolean flag = StringUtils.isBlank(cfid); |
|
|
|
@ -3937,4 +4201,9 @@ public class CustomerFormServiceImpl implements CustomerFormService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ArrayList<CustomerForm> getAppsByGroupId(CustomerFormGroup customerFormGroup){ |
|
|
|
return customerFormMapper.getAppsByGroupId(customerFormGroup.getId()); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|