Java项目学习Day4

知识点

Java8 Lambda

Lambda 表达式,也可称为闭包,它是推动 Java 8 发布的最重要新特性。
Lambda 允许把函数作为一个方法的参数(函数作为参数传递进方法中)。
使用 Lambda 表达式可以使代码变的更加简洁紧凑。
格式:

(parameters) -> expression
或
(parameters) ->{ statements; }
 return distinctProjects.stream().map(projectVO -> {
            ProjectInfoResponse projectInfoResponse = new ProjectInfoResponse();
            projectInfoResponse.setDescription(projectVO.getDescription());
            projectInfoResponse.setLogoColor(projectVO.getLogoColor());
            projectInfoResponse.setName(projectVO.getName());
            projectInfoResponse.setUserId(userId + "");
            projectInfoResponse.setRole(AuthRole.PROJECT_ADMIN);
            projectInfoResponse.setUuid(projectVO.getUuid());
            return projectInfoResponse;
        }).collect(Collectors.toList());

更复杂的例子:

@Override
    public List<XlyProjectComponentBean> queryProjectComponentBean(String company, String project) {
        List<Application> list1 = applicationService.queryApplications(company, true, false);
        List<Application> list2 = applicationService.queryApplications(company, false, true);
        List<Privilege> privilegeList = queryProjectPrivilegeComponent(company, project);
        return list1.stream().map(app -> {
            XlyProjectComponentBean bean = new XlyProjectComponentBean();
            bean.setCompanyUuid(company);
            bean.setProjectUuid(project);
            bean.setId(app.getId());
            bean.setName(app.getName());
            bean.setNum(app.getNum());
            // CHECKSTYLE:OFF
            bean.setLevel(1);
            bean.setKey(app.getCode());
            privilegeList.forEach(p -> {
                if (p.getDeleteStatus() == 0 && p.getPermissionAppId().equals(app.getId())) {
                    bean.setIschecked(true);
                }
            });
            // 组装二级组件
            List<XlyProjectComponentBean> childrenBeanList = new ArrayList<>();
            list2.forEach(appc -> {
                if (appc.getParentId().equals(app.getId())) {
                    XlyProjectComponentBean beanChild = new XlyProjectComponentBean();
                    beanChild.setCompanyUuid(company);
                    beanChild.setProjectUuid(project);
                    beanChild.setId(appc.getId());
                    beanChild.setName(appc.getName());
                    // CHECKSTYLE:OFF
                    beanChild.setLevel(2);
                    beanChild.setNum(appc.getNum());
                    beanChild.setKey(appc.getCode());
                    privilegeList.forEach(p -> {
                        if (p.getDeleteStatus() == 0 && p.getPermissionAppId().equals(appc.getId())) {
                            beanChild.setIschecked(true);
                        }
                    });
                    childrenBeanList.add(beanChild);
                }
            });
            bean.setChildren(childrenBeanList);
            return bean;
        }).sorted(Comparator.comparing(XlyProjectComponentBean::getNum)).collect(Collectors.toList());
    }

Thread

  1. What are Java Threads?
  • Facility to allow multiple activities within a single process
    Referred as lightweight process

  • A thread is a series of executed statements

  • Each thread has its own program counter, stack and local
    variables

  • A thread is a nested sequence of method callsIts shares
    memory, files and per-process state

  1. Whats the need of a thread or why we use Threads?
  • To perform asynchronous or background processing
  • Increases the responsiveness of GUI applications
  • Take advantage of multiprocessor systems
  • Simplify program logic when there are multiple independent entities
  1. What happens when a thread is invoked?
    When a thread is invoked, there will be two paths of execution. One path will execute the thread and the other path will follow the statement after the thread invocation. There will be a separate stack and memory space for each thread.

MultiThread

Let’s summarize the discussion in points:

  1. The main purpose of multithreading is to provide simultaneous execution of two or more parts of a program to maximum utilize the CPU time. A multithreaded program contains two or more parts that can run concurrently. Each such part of a program called thread.2. Threads are lightweight sub-processes, they share the common memory space. In Multithreaded environment, programs that are benefited from multithreading, utilize the maximum CPU time so that the idle time can be kept to minimum.3. A thread can be in one of the following states:
    NEW – A thread that has not yet started is in this state.
    RUNNABLE – A thread executing in the Java virtual machine is in this state.
    BLOCKED – A thread that is blocked waiting for a monitor lock is in this state.
    WAITING – A thread that is waiting indefinitely for another thread to perform a particular action is in this state.
    TIMED_WAITING – A thread that is waiting for another thread to perform an action for up to a specified waiting time is in this state.
    TERMINATED – A thread that has exited is in this state.
    A thread can be in only one state at a given point in time.

泛型嵌套

 @GetMapping("/code/application/{application}")
 @ApiOperation(value = "code全局设置权限列表", notes = "code全局设置权限列表") 
 public ResponseEntity<AdminResponse<PageBean<PermissionApplicationResponse>>> queryCodeList(
            @PathVariable String company,
            @PathVariable(value = "application") String application,
            @PathVariable(value = "project") String project,
            @RequestParam(value = "page", defaultValue = "1") Integer page,
            @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
        return ResponseEntity.status(HttpStatus.OK)
                .body(AdminResponse.result(GlobalConstant.SUCCESS, "授权列表查询成功!",
                        permissionService.queryPermissionList2(company, project, application, page, pageSize, true)));
    }
基于SSM框架的智能家政保洁预约系统,是一个旨在提高家政保洁服务预约效率和管理水平的平台。该系统通过集成现代信息技术,为家政公司、家政服务人员和消费者提供了一个便捷的在线预约和管理系统。 系统的主要功能包括: 1. **用户管理**:允许消费者注册、登录,并管理他们的个人资料和预约历史。 2. **家政人员管理**:家政服务人员可以注册并更新自己的个人信息、服务类别和服务时间。 3. **服务预约**:消费者可以浏览不同的家政服务选项,选择合适的服务人员,并在线预约服务。 4. **订单管理**:系统支持订单的创建、跟踪和管理,包括订单的确认、完成和评价。 5. **评价系统**:消费者可以在家政服务完成后对服务进行评价,帮助提高服务质量和透明度。 6. **后台管理**:管理员可以管理用户、家政人员信息、服务类别、预约订单以及处理用户反馈。 系统采用Java语言开发,使用MySQL数据库进行数据存储,通过B/S架构实现用户与服务的在线交互。系统设计考虑了不同用户角色的需求,包括管理员、家政服务人员和普通用户,每个角色都有相应的权限和功能。此外,系统还采用了软件组件化、精化体系结构、分离逻辑和数据等方法,以便于未来的系统升级和维护。 智能家政保洁预约系统通过提供一个集中的平台,不仅方便了消费者的预约和管理,也为家政服务人员提供了一个展示和推广自己服务的机会。同时,系统的后台管理功能为家政公司提供了强大的数据支持和决策辅助,有助于提高服务质量和管理效率。该系统的设计与实现,标志着家政保洁服务向现代化和网络化的转型,为管理决策和控制提供保障,是行业发展中的重要里程碑。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值