@PostMapping("/shareTable") public R getNonstandardMetaCategoryAsTree(String JsonStr) { JSONObject jsonObject = JSONObject.parseObject(JsonStr); Integer ifStandard = jsonObject.getInteger("if_standard"); JSONArray tableClassId = jsonObject.getJSONArray("table_class_id"); String dept_id = jsonObject.getString("dept_id"); //拿到部门已经有的分类id QueryWrapper<SopDeptEntity> queryWrapper = new QueryWrapper<SopDeptEntity>().eq("dept_id", dept_id); List<SopDeptEntity> list = sopDeptService.list(queryWrapper); List<Long> collects = list.stream().map(SopDeptEntity::getTableClassId).collect(Collectors.toList()); //拿到传进来的分类id List<Long> longs = tableClassId.toJavaList(Long.class); boolean b = sopDeptService.hasDuplicate(collects, longs); if (b == true) { //拿到重复元素并删除 List<Long> duplicateAndDifferent = sopDeptService.findDuplicateAndDifferent(collects, longs); sopDeptService.deleteLogic(duplicateAndDifferent); //拿到现在所有分类id QueryWrapper<SopDeptEntity> queryWrapper1 = new QueryWrapper<SopDeptEntity>().eq("dept_id", dept_id); List<SopDeptEntity> list1 = sopDeptService.list(queryWrapper); List<Long> collects1 = list1.stream().map(SopDeptEntity::getTableClassId).collect(Collectors.toList()); //去除!数据库已有的元素 List<Long> longs1 = sopDeptService.deleteDuplication(collects1, longs); //保存其他元素 for (Long id : longs1) { SopDeptEntity sopDeptEntity = new SopDeptEntity(); sopDeptEntity.setDeptId(dept_id); sopDeptEntity.setIsDeleted(0); sopDeptEntity.setTableClassId(id); } } else if (longs.size() == 0) { } else { for (Long id : longs) { SopDeptEntity sopDeptEntity = new SopDeptEntity(); sopDeptEntity.setDeptId(dept_id); sopDeptEntity.setIsDeleted(0); sopDeptEntity.setTableClassId(id); } } }
部门授权表
最新推荐文章于 2024-05-05 13:57:09 发布