• 开发中遇到的问题


    一.Mybatis

    1.链式SQL嵌套and,or

     List<UserMeetDO> meets = userMeetMapper.selectList(new LambdaQueryWrapper<UserMeetDO>()
                            .eq(UserMeetDO::getMeetId, userMeetVo.getMeetId())
                            .and(wrapper -> wrapper
                                    .and(w -> w.le(UserMeetDO::getStartTime, userMeetVo.getStartTime()).gt(UserMeetDO::getEndTime, userMeetVo.getStartTime()))
                                    .or(w -> w.lt(UserMeetDO::getStartTime, userMeetVo.getEndTime()).ge(UserMeetDO::getEndTime, userMeetVo.getEndTime()))
                                    .or(w -> w.ge(UserMeetDO::getStartTime,  userMeetVo.getStartTime()).le(UserMeetDO::getEndTime, userMeetVo.getEndTime()))
                            )
                    );
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    2.xml

    在xml中mybatis里认为0就是空字符串

    if和foreach

     	 <if test="deptIds != null">
                and (
                sl.dept_id in
                <foreach collection="deptIds" open="(" close=")" separator="," item="id">
                    #{id}
                foreach>
                or sl.owner_id in
                <foreach collection="deptIds" open="(" close=")" separator="," item="id">
                    #{id}
                foreach>
                )
            if>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    3.分页

    中规中矩

     Page<Object> iPage = PageHelper.startPage(page, size);
     return PageResult.of(iPage,list);
    
    • 1
    • 2

    手动分页

     public List<PlanReceiveBo> getPage(List<PlanReceiveBo> list, int pageNum, int pageSize) {
            List<PlanReceiveBo> result = new ArrayList<>();
            if (list == null || list.isEmpty()) {
                return result;
            }
            int totalSize = list.size();
            int totalPage = (totalSize + pageSize - 1) / pageSize;
            if (pageNum < 1 || pageNum > totalPage) {
                return result;
            }
            int startIndex = (pageNum - 1) * pageSize;
            int endIndex = Math.min(startIndex + pageSize, totalSize);
            for (int i = startIndex; i < endIndex; i++) {
                result.add(list.get(i));
            }
            return result;
        }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17

    二.SpringBoot

    1.定时任务

    @Scheduled(cron = “0 0 2 * * ?”)
    5位:* * * * * 分、时、天、月、周
    6位:* * * * * * 秒、分、时、天、月、周
    7位:* * * * * * * 秒、分、时、天、月、周、年

    三.Java

    1.常用的流

      BigDecimal totalAmount = list.stream()
            .map(e -> e.getPlanReceiveAmount())
            .reduce(BigDecimal.ZERO, BigDecimal::add);
    
    
    • 1
    • 2
    • 3
    • 4

    2.时间格式转换

    LocalDate->LocalDateTime

    param.setApplyStartTime(listParam.getStartTime().atStartOfDay());
    param.setApplyEndTime(listParam.getEndTime().atTime(23,59,59));
    
    • 1
    • 2

    LocalDateTime->LocalDate

    LocalDateTime dateTime = LocalDateTime.of(2023, 11, 17, 10, 30);
    LocalDate date = dateTime.toLocalDate();
    System.out.println(date); // 输出 2023-11-17
    
    • 1
    • 2
    • 3

    3.JSON问题

    如果为空就不返回该字段

    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    
    • 1

    JSON的相互转换

    String jsonString = "{\"name\":\"name\", \"age\":20}";
    SomeObject someObject = JSON.parseObject(jsonString, SomeObject.class);
    SomeObject someObject = new SomeObject("name", 20);
    String jsonString = JSON.toJSONString(someObject, SerializerFeature.PrettyFormat);
    
    • 1
    • 2
    • 3
    • 4
    		
    JSONObject jsonObject = new JSONObject(jsonString);
    JSONArray attributesArray = jsonObject.getJSONArray("attributes");
    JSONObject attributes1 = attributesArray.getJSONObject(0);
    String country = attributes1.getString("country");
    
    • 1
    • 2
    • 3
    • 4
    • 5

    四.Windows

    1.杀死端口

    netstat –ano | findstr <端口号>
    
    • 1
    taskkill /F /PID 39908
    
    • 1

    未完待续…

  • 相关阅读:
    Linux-网卡和网络配置
    Lumiprobe 脱氧核糖核酸丨炔烃dT亚磷酰胺
    【已验证】微信小程序php连接SQL Server数据库代码
    Linux界的老古董
    【Linux】Ubuntu升级nodejs版本
    Presto+yanagishima部署
    SpringBoot环境搭建与初创程序
    程序媛过中秋的正确打开方式——使用Python绘制月饼消消乐,素描图,词云图,字符画图及提取轮廓
    入坑机器学习:三,非监督学习
    antd vue实现table的分页组件固定位置的效果
  • 原文地址:https://blog.csdn.net/qq_46058550/article/details/134304753