Commit db8994686839638b818e8aaada797b3f778b23a8

Authored by guzijian
1 parent 2563f78e

feat: 可视化大屏接口

Bsth-admin/src/main/java/com/ruoyi/common/ConstSignInConstSignInProperties.java
... ... @@ -64,10 +64,23 @@ public interface ConstSignInConstSignInProperties {
64 64 Integer ALCOHOL_FLAG_NO = 0;
65 65 String ALCOHOL_FLAG_NO_STRING = "未测试";
66 66  
  67 + String DRIVER_STRING = "驾驶员";
  68 + String SALE_STRING = "售票员";
  69 +
67 70 /**
68 71 * 酒精测试异常指定次数 弹出更换驾驶员提示
69 72 */
70 73 Integer SIGN_IN_ERROR_COUNT = 2;
71 74  
  75 + /**
  76 + * 迟到
  77 + */
  78 + String DELAY = "迟到";
  79 +
  80 + /**
  81 + * 早签
  82 + */
  83 + String EARLY = "早签";
  84 +
72 85  
73 86 }
... ...
Bsth-admin/src/main/java/com/ruoyi/common/SignStatusEnum.java 0 → 100644
  1 +package com.ruoyi.common;
  2 +
  3 +/**
  4 + * 签到状态枚举
  5 + * @author 20412
  6 + */
  7 +public enum SignStatusEnum {
  8 + SIGN_STATUS_ZONE_ENUM(0,"今日签到正常"),
  9 + SIGN_STATUS_EMPTY_ENUM(1,"今日打卡未签"),
  10 + SIGN_STATUS_DELAY_ENUM(2,"今日签到迟到"),
  11 + SIGN_STATUS_WINE_ENUM(3,"今日酒测异常");
  12 +
  13 +
  14 + SignStatusEnum(Integer status,String description){
  15 + this.status = status;
  16 + this.description = description;
  17 + }
  18 + private String description;
  19 + private Integer status;
  20 +
  21 + public Integer getStatus() {
  22 + return status;
  23 + }
  24 +}
... ...
Bsth-admin/src/main/java/com/ruoyi/controller/BigViewController.java
1 1 package com.ruoyi.controller;
2 2  
3 3 import com.ruoyi.common.global.Result;
  4 +import com.ruoyi.pojo.vo.bigViewVo.FleetInfoVo;
  5 +import com.ruoyi.service.BigViewService;
4 6 import io.swagger.annotations.Api;
5 7 import io.swagger.annotations.ApiOperation;
  8 +import org.springframework.beans.factory.annotation.Autowired;
6 9 import org.springframework.web.bind.annotation.GetMapping;
  10 +import org.springframework.web.bind.annotation.PathVariable;
7 11 import org.springframework.web.bind.annotation.RequestMapping;
8 12 import org.springframework.web.bind.annotation.RestController;
9 13  
  14 +import java.util.List;
  15 +
10 16 /**
11 17 * 可视化大屏控制controller
12 18 * @author 20412
... ... @@ -16,11 +22,27 @@ import org.springframework.web.bind.annotation.RestController;
16 22 @Api(tags = "可视化大屏")
17 23 public class BigViewController {
18 24  
  25 + @Autowired
  26 + private BigViewService bigViewService;
  27 +
19 28  
20   - @ApiOperation("获取但当天打卡记录")
21   - @GetMapping("/getTodayRecord")
22   - public Result<?> getTodayRecord(){
23   - return Result.OK();
  29 + /**
  30 + * 类型 device 设备数量 line 线路数 car 车辆数
  31 + * sale 售票员签到数量 driver 驾驶员签到 auxiliary 辅助人员签到数量
  32 + * @param type
  33 + * @return
  34 + */
  35 + @ApiOperation("根据类型获取数值")
  36 + @GetMapping("/queryNumberByType/{type}")
  37 + public Result<Integer> queryNumberByType(@PathVariable("type") String type){
  38 + return Result.OK(bigViewService.queryNumberByType(type));
24 39 }
25 40  
  41 + @ApiOperation("获取车队信息")
  42 + @GetMapping("/queryLineInfo")
  43 + public Result<List<FleetInfoVo>> queryFleetInfoByFleetName(){
  44 + return Result.OK(bigViewService.queryFleetInfoByFleetName());
  45 + }
  46 +
  47 +
26 48 }
... ...
Bsth-admin/src/main/java/com/ruoyi/driver/mapper/DriverSchedulingMapper.java
... ... @@ -2,6 +2,7 @@ package com.ruoyi.driver.mapper;
2 2  
3 3 import com.ruoyi.domain.DriverScheduling;
4 4 import org.apache.ibatis.annotations.Param;
  5 +import org.apache.ibatis.annotations.Select;
5 6  
6 7 import java.math.BigDecimal;
7 8 import java.util.Date;
... ... @@ -20,4 +21,11 @@ public interface DriverSchedulingMapper {
20 21  
21 22 void updateRoster(@Param("scheduling") DriverScheduling scheduling, @Param("signInId") Long id, @Param("exType") Integer exType, @Param("signTime")Date signTime, @Param("remark") String remark, @Param("signType") Integer signType, @Param("alcoholFlag") Integer alcoholFlag, @Param("alcoholIntake")BigDecimal alcoholIntake);
22 23  
  24 + /**
  25 + * 查询设备数量
  26 + * @return
  27 + */
  28 + @Select("select count(*) from equipment")
  29 + Integer queryNumberByDevice();
  30 +
23 31 }
... ...
Bsth-admin/src/main/java/com/ruoyi/pojo/vo/bigViewVo/FleetInfoVo.java 0 → 100644
  1 +package com.ruoyi.pojo.vo.bigViewVo;
  2 +
  3 +import io.swagger.annotations.ApiModel;
  4 +import io.swagger.annotations.ApiModelProperty;
  5 +import lombok.Data;
  6 +
  7 +import java.util.List;
  8 +
  9 +/**
  10 + * @author 20412
  11 + */
  12 +@Data
  13 +@ApiModel("车队信息对象")
  14 +public class FleetInfoVo {
  15 + /**
  16 + * 车队名称
  17 + */
  18 + @ApiModelProperty("车队名称")
  19 + private String title;
  20 + @ApiModelProperty("车队信息")
  21 + private List<FleetInfo> fleetInfos;
  22 +
  23 + @Data
  24 + public static class FleetInfo{
  25 + private String lineName;
  26 + private List<LineInfo> lineInfos;
  27 + }
  28 +
  29 +}
... ...
Bsth-admin/src/main/java/com/ruoyi/pojo/vo/bigViewVo/LineInfo.java 0 → 100644
  1 +package com.ruoyi.pojo.vo.bigViewVo;
  2 +
  3 +import com.ruoyi.common.SignStatusEnum;
  4 +import lombok.Data;
  5 +
  6 +/**
  7 + * 有销售人员
  8 + *
  9 + * @author 20412
  10 + */
  11 +@Data
  12 +public class LineInfo {
  13 + private String nbbm;
  14 + private PersonInfoVo driverInfoVo;
  15 + private PersonInfoVo saleInfoVo;
  16 + @Data
  17 + public static class PersonInfoVo {
  18 + private String jobCode;
  19 + private String name;
  20 + private Integer signStatus;
  21 +
  22 + public void setSignStatus(SignStatusEnum statusEnum) {
  23 + this.signStatus = statusEnum.getStatus();
  24 + }
  25 + public void setSignStatus(Integer status) {
  26 + this.signStatus = status;
  27 + }
  28 + }
  29 +}
... ...
Bsth-admin/src/main/java/com/ruoyi/service/BigViewService.java 0 → 100644
  1 +package com.ruoyi.service;
  2 +
  3 +import com.ruoyi.pojo.vo.bigViewVo.FleetInfoVo;
  4 +
  5 +import java.util.List;
  6 +
  7 +/**
  8 + * 可视化大屏服务
  9 + * @author 20412
  10 + */
  11 +public interface BigViewService {
  12 +
  13 + /**
  14 + * 根据类型获取数量
  15 + * @param type
  16 + * @return
  17 + */
  18 + Integer queryNumberByType(String type);
  19 +
  20 + /**
  21 + * 获取车队信息
  22 + * @return
  23 + */
  24 + List<FleetInfoVo> queryFleetInfoByFleetName();
  25 +
  26 +}
... ...
Bsth-admin/src/main/java/com/ruoyi/service/SchedulingService.java
... ... @@ -144,9 +144,9 @@ public class SchedulingService {
144 144 long nowBetween = ChronoUnit.MINUTES.between(ConstDateUtil.getLocalDateTimeByLongTime(date), ConstDateUtil.getLocalDateTimeByLongTime(signIn.getCreateTime().getTime()));
145 145 if (checkTimerSign(nowBetween, scheduling.getBcType())) {
146 146 if (nowBetween < -60L) {
147   - sb.append("早签");
  147 + sb.append(EARLY);
148 148 } else {
149   - sb.append("迟到");
  149 + sb.append(DELAY);
150 150 }
151 151 // 在规定时间就还原remark
152 152 }else {
... ...
Bsth-admin/src/main/java/com/ruoyi/service/ThreadJobService.java
... ... @@ -48,6 +48,7 @@ import java.io.*;
48 48 import java.math.BigDecimal;
49 49 import java.time.LocalDate;
50 50 import java.util.*;
  51 +import java.util.concurrent.CompletableFuture;
51 52 import java.util.stream.Collectors;
52 53  
53 54 import static com.ruoyi.common.ConstDriverProperties.BC_TYPE_IN;
... ...
Bsth-admin/src/main/java/com/ruoyi/service/impl/BigViewServiceImpl.java 0 → 100644
  1 +package com.ruoyi.service.impl;
  2 +
  3 +import cn.hutool.core.collection.CollectionUtil;
  4 +import com.ruoyi.common.SignStatusEnum;
  5 +import com.ruoyi.common.cache.NowSchedulingCache;
  6 +import com.ruoyi.domain.DriverScheduling;
  7 +import com.ruoyi.driver.mapper.DriverMapper;
  8 +import com.ruoyi.driver.mapper.DriverSchedulingMapper;
  9 +import com.ruoyi.pojo.vo.bigViewVo.FleetInfoVo;
  10 +import com.ruoyi.pojo.vo.bigViewVo.LineInfo;
  11 +import com.ruoyi.service.BigViewService;
  12 +import com.ruoyi.service.ThreadJobService;
  13 +import com.ruoyi.utils.ConstDateUtil;
  14 +import org.slf4j.Logger;
  15 +import org.slf4j.LoggerFactory;
  16 +import org.springframework.beans.factory.annotation.Autowired;
  17 +import org.springframework.stereotype.Service;
  18 +
  19 +import javax.annotation.Resource;
  20 +import java.util.*;
  21 +import java.util.stream.Collectors;
  22 +
  23 +import static com.ruoyi.common.ConstDriverProperties.BC_TYPE_OUT;
  24 +import static com.ruoyi.common.ConstSignInConstSignInProperties.*;
  25 +
  26 +/**
  27 + * @author 20412
  28 + */
  29 +@Service
  30 +public class BigViewServiceImpl implements BigViewService {
  31 +
  32 + private static final Logger log = LoggerFactory.getLogger(BigViewServiceImpl.class);
  33 +
  34 + @Resource
  35 + private ThreadJobService threadJobService;
  36 + @Autowired
  37 + private DriverSchedulingMapper schedulingMapper;
  38 +
  39 + @Autowired
  40 + private DriverMapper driverMapper;
  41 +
  42 + @Resource
  43 + private NowSchedulingCache cache;
  44 +
  45 + @Override
  46 + public Integer queryNumberByType(String type) {
  47 + Integer x = handleType(type);
  48 + if (x != null) return x;
  49 + return 0;
  50 + }
  51 +
  52 + @Override
  53 + public List<FleetInfoVo> queryFleetInfoByFleetName() {
  54 + // 从缓存中读取数据,但是调度表中还好包含飞司售人员信息 需要过滤一下 非司售人员nbbm不会存在
  55 + String key = ConstDateUtil.getStringNowLocalDate("-");
  56 + Map<String, List<DriverScheduling>> map = cache.getCacheScheduling(key);
  57 +
  58 + Map<String, LineInfo> matchMap = transformMapByMacheList(map);
  59 + // 车队和线路 车队为key
  60 + Map<String, Map<String, List<String>>> mapVo = new HashMap<>(4);
  61 +
  62 + // 记录所有得签到数据 以车队 -》 线路 -》 人员信息 层次
  63 + handleFleetWithLine(map, mapVo);
  64 + // 进一步处理人员信息
  65 + List<FleetInfoVo> fleetInfoVos = handleFleetWithLinePersonInfo(matchMap, mapVo);
  66 + return fleetInfoVos;
  67 + }
  68 +
  69 + private List<FleetInfoVo> handleFleetWithLinePersonInfo(Map<String, LineInfo> map, Map<String, Map<String, List<String>>> mapVo) {
  70 + List<FleetInfoVo> vos = new ArrayList<>(4);
  71 + for (Map.Entry<String, Map<String, List<String>>> entry : mapVo.entrySet()) {
  72 + Map<String, List<String>> value = entry.getValue();
  73 + String fleetName = entry.getKey();
  74 + FleetInfoVo vo = new FleetInfoVo();
  75 + vo.setTitle(fleetName);
  76 + vo.setFleetInfos(handleLineInfos(value, map));
  77 + vos.add(vo);
  78 + }
  79 +
  80 + return vos;
  81 + }
  82 +
  83 + /**
  84 + * 信息拼接
  85 + *
  86 + * @param value
  87 + * @param map
  88 + * @return
  89 + */
  90 + private List<FleetInfoVo.FleetInfo> handleLineInfos(Map<String, List<String>> value, Map<String, LineInfo> map) {
  91 + List<FleetInfoVo.FleetInfo> fleetInfos = new ArrayList<>();
  92 + for (Map.Entry<String, List<String>> entry : value.entrySet()) {
  93 + String lineName = entry.getKey();
  94 + List<String> nbbms = entry.getValue();
  95 + FleetInfoVo.FleetInfo fleetInfo = new FleetInfoVo.FleetInfo();
  96 + fleetInfo.setLineName(lineName);
  97 + List<LineInfo> lineInfos = new ArrayList<>();
  98 + for (String nbbm : nbbms) {
  99 + LineInfo info = map.get(nbbm);
  100 + lineInfos.add(info);
  101 + }
  102 + lineInfos.sort(Comparator.comparing(LineInfo::getNbbm).reversed());
  103 + fleetInfo.setLineInfos(lineInfos);
  104 + fleetInfos.add(fleetInfo);
  105 + }
  106 + return fleetInfos;
  107 + }
  108 +
  109 + /**
  110 + * 设置车队和线路 以车队为key
  111 + */
  112 + private void handleFleetWithLine(Map<String, List<DriverScheduling>> map, Map<String, Map<String, List<String>>> mapVo) {
  113 + // 整合车队
  114 + for (Map.Entry<String, List<DriverScheduling>> entry : map.entrySet()) {
  115 + // 过滤进场 系统设置出场为签到 进场为签退
  116 + List<DriverScheduling> value = entry.getValue().stream().filter(item -> BC_TYPE_OUT.equals(item.getBcType()) && !Objects.isNull(item.getNbbm())).collect(Collectors.toList());
  117 + if (CollectionUtil.isNotEmpty(value)) {
  118 + String fleetName = value.get(0).getFleetName();
  119 + Map<String, List<String>> distinctMap = mapVo.get(fleetName);
  120 + if (CollectionUtil.isEmpty(distinctMap)) {
  121 + distinctMap = new HashMap<>(value.size());
  122 + // 线路去重
  123 + for (DriverScheduling scheduling : value) {
  124 + handleDistinctMap(distinctMap, scheduling);
  125 + }
  126 + // 把线路和自编号放入集合
  127 + mapVo.put(fleetName, distinctMap);
  128 + } else {
  129 + for (DriverScheduling scheduling : value) {
  130 + handleDistinctMap(distinctMap, scheduling);
  131 + }
  132 + mapVo.put(fleetName, distinctMap);
  133 + }
  134 + }
  135 + }
  136 + // 对自编号进行去重
  137 + for (Map.Entry<String, Map<String, List<String>>> entry : mapVo.entrySet()) {
  138 + Map<String, List<String>> value = entry.getValue();
  139 + for (Map.Entry<String, List<String>> listEntry : value.entrySet()) {
  140 + listEntry.setValue(listEntry.getValue().stream().distinct().collect(Collectors.toList()));
  141 + }
  142 + }
  143 + }
  144 +
  145 + private void handleDistinctMap(Map<String, List<String>> distinctMap, DriverScheduling scheduling) {
  146 + List<String> distinct = distinctMap.get(scheduling.getLineName());
  147 + if (CollectionUtil.isEmpty(distinct)) {
  148 + distinctMap.put(scheduling.getLineName(), new ArrayList<>(Arrays.asList(scheduling.getNbbm())));
  149 + } else {
  150 + distinct.add(scheduling.getNbbm());
  151 + }
  152 + }
  153 +
  154 +
  155 + /**
  156 + * 自编号为key 存储人员信息
  157 + *
  158 + * @param map
  159 + * @return
  160 + */
  161 + private Map<String, LineInfo> transformMapByMacheList(Map<String, List<DriverScheduling>> map) {
  162 + Map<String, LineInfo> matchMap = new HashMap<>();
  163 + for (Map.Entry<String, List<DriverScheduling>> entry : map.entrySet()) {
  164 + List<DriverScheduling> value = entry.getValue();
  165 + List<DriverScheduling> list = value.stream().filter(item -> BC_TYPE_OUT.equals(item.getBcType()) && !Objects.isNull(item.getNbbm())).sorted(Comparator.comparing(DriverScheduling::getFcsjT)).collect(Collectors.toList());
  166 + for (DriverScheduling scheduling : list) {
  167 + // 把每辆车的人员信息收集起来
  168 + String nbbm = scheduling.getNbbm();
  169 + LineInfo lineInfoList = matchMap.get(nbbm);
  170 + if (Objects.isNull(lineInfoList)) {
  171 + LineInfo lineInfo = new LineInfo();
  172 + lineInfo.setNbbm(nbbm);
  173 + LineInfo.PersonInfoVo personInfoVo = getPersonInfoVo(scheduling);
  174 + if (DRIVER_STRING.equals(scheduling.getPosts())) {
  175 + lineInfo.setDriverInfoVo(personInfoVo);
  176 + } else {
  177 + lineInfo.setSaleInfoVo(personInfoVo);
  178 + }
  179 + matchMap.put(nbbm, lineInfo);
  180 + } else {
  181 + LineInfo.PersonInfoVo personInfoVo = getPersonInfoVo(scheduling);
  182 + handleMoreStatus(matchMap, scheduling, nbbm, personInfoVo, scheduling);
  183 + }
  184 + }
  185 + }
  186 + return matchMap;
  187 + }
  188 +
  189 + /**
  190 + * 判断是否有多次签到,且签到时间未到
  191 + *
  192 + * @param matchMap
  193 + * @param scheduling
  194 + * @param nbbm
  195 + * @param personInfoVo
  196 + * @param driverScheduling
  197 + */
  198 + private void handleMoreStatus(Map<String, LineInfo> matchMap, DriverScheduling scheduling, String nbbm, LineInfo.PersonInfoVo personInfoVo, DriverScheduling driverScheduling) {
  199 + long time = System.currentTimeMillis();
  200 + if (DRIVER_STRING.equals(scheduling.getPosts())) {
  201 + LineInfo.PersonInfoVo driverInfoVo = matchMap.get(nbbm).getDriverInfoVo();
  202 + // 第二次签到时间未到不记录状态
  203 + if (!Objects.isNull(driverInfoVo) && time - scheduling.getFcsjT() < 0) {
  204 + return;
  205 + }
  206 + matchMap.get(nbbm).setDriverInfoVo(personInfoVo);
  207 + } else {
  208 + LineInfo.PersonInfoVo saleInfoVo = matchMap.get(nbbm).getSaleInfoVo();
  209 + // 第二次签到时间未到不记录状态
  210 + if (!Objects.isNull(saleInfoVo) && time - scheduling.getFcsjT() < 0) {
  211 + return;
  212 + }
  213 + matchMap.get(nbbm).setSaleInfoVo(personInfoVo);
  214 + }
  215 + }
  216 +
  217 + private LineInfo.PersonInfoVo getPersonInfoVo(DriverScheduling scheduling) {
  218 + LineInfo.PersonInfoVo personInfoVo = new LineInfo.PersonInfoVo();
  219 + if (Objects.isNull(scheduling.getExType())) {
  220 + personInfoVo.setSignStatus(SignStatusEnum.SIGN_STATUS_EMPTY_ENUM);
  221 + } else {
  222 + switch (scheduling.getExType()) {
  223 + case 0:
  224 + personInfoVo.setSignStatus(SignStatusEnum.SIGN_STATUS_ZONE_ENUM);
  225 + break;
  226 + case 1:
  227 + // 不在规定范围内 早签不算迟到
  228 + if (EARLY.equals(scheduling.getRemark())) {
  229 + personInfoVo.setSignStatus(SignStatusEnum.SIGN_STATUS_DELAY_ENUM);
  230 + }
  231 + break;
  232 + case 3:
  233 + personInfoVo.setSignStatus(SignStatusEnum.SIGN_STATUS_WINE_ENUM);
  234 + break;
  235 + }
  236 + }
  237 + personInfoVo.setJobCode(scheduling.getJobCode());
  238 + personInfoVo.setName(scheduling.getName());
  239 + return personInfoVo;
  240 + }
  241 +
  242 + private Integer handleType(String type) {
  243 + String key = ConstDateUtil.getStringNowLocalDate("-");
  244 + Map<String, List<DriverScheduling>> map = cache.getCacheScheduling(key);
  245 + Map<String, Object> typeMap = new HashMap<>(map.size());
  246 + switch (type) {
  247 + case "device":
  248 + return schedulingMapper.queryNumberByDevice();
  249 + case "line":
  250 + for (Map.Entry<String, List<DriverScheduling>> entry : map.entrySet()) {
  251 + for (DriverScheduling scheduling : entry.getValue()) {
  252 + typeMap.put(scheduling.getLineName(), "");
  253 + }
  254 + }
  255 + return typeMap.size();
  256 + case "car":
  257 + for (Map.Entry<String, List<DriverScheduling>> entry : map.entrySet()) {
  258 + for (DriverScheduling scheduling : entry.getValue()) {
  259 + typeMap.put(scheduling.getNbbm(), "");
  260 + }
  261 + }
  262 + return typeMap.size();
  263 + case "sale":
  264 + for (Map.Entry<String, List<DriverScheduling>> entry : map.entrySet()) {
  265 + for (DriverScheduling scheduling : entry.getValue()) {
  266 + if (SALE_STRING.equals(scheduling.getPosts()) && BC_TYPE_OUT.equals(scheduling.getBcType()) && !Objects.isNull(scheduling.getNbbm()) && !Objects.isNull(scheduling.getSignInId())) {
  267 + typeMap.put(scheduling.getJobCode() + scheduling.getBcType(), "");
  268 + }
  269 + }
  270 + }
  271 + return typeMap.size();
  272 + case "driver":
  273 + for (Map.Entry<String, List<DriverScheduling>> entry : map.entrySet()) {
  274 + for (DriverScheduling scheduling : entry.getValue()) {
  275 + if (DRIVER_STRING.equals(scheduling.getPosts()) && BC_TYPE_OUT.equals(scheduling.getBcType()) && !Objects.isNull(scheduling.getNbbm()) && !Objects.isNull(scheduling.getSignInId())) {
  276 + typeMap.put(scheduling.getJobCode() + scheduling.getBcType(), "");
  277 + }
  278 + }
  279 + }
  280 + return typeMap.size();
  281 + case "auxiliary":
  282 + for (Map.Entry<String, List<DriverScheduling>> entry : map.entrySet()) {
  283 + for (DriverScheduling scheduling : entry.getValue()) {
  284 + if (Objects.isNull(scheduling.getNbbm()) && BC_TYPE_OUT.equals(scheduling.getBcType())) {
  285 + typeMap.put(scheduling.getJobCode() + scheduling.getBcType(), "");
  286 + }
  287 + }
  288 + }
  289 + return typeMap.size();
  290 + default:
  291 + return 0;
  292 + }
  293 + }
  294 +}
... ...
Bsth-admin/src/main/java/com/ruoyi/utils/ConstDateUtil.java
... ... @@ -11,6 +11,31 @@ import java.util.List;
11 11  
12 12 public class ConstDateUtil {
13 13  
  14 + public static String getStringNowLocalDate(){
  15 + // 指定当前日期和时间
  16 + LocalDate currentDate = LocalDate.now();
  17 + LocalTime timeRange = LocalTime.of(2, 50);
  18 + LocalTime now = LocalTime.now();
  19 + if (now.isBefore(timeRange)){
  20 + // 在日期的前一天
  21 + currentDate = currentDate.minusDays(1);
  22 + }
  23 + return currentDate.toString();
  24 + }
  25 +
  26 + public static String getStringNowLocalDate(String delStr){
  27 + // 指定当前日期和时间
  28 + LocalDate currentDate = LocalDate.now();
  29 + LocalTime timeRange = LocalTime.of(2, 50);
  30 + LocalTime now = LocalTime.now();
  31 + if (now.isBefore(timeRange)){
  32 + // 在日期的前一天
  33 + currentDate = currentDate.minusDays(1);
  34 + }
  35 + return currentDate.toString().replaceAll(delStr,"");
  36 + }
  37 +
  38 +
14 39 public static LocalDateTime stringTransformLocalDateTime(String dateString, String pattern){
15 40 DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
16 41 return LocalDateTime.parse(dateString,formatter);
... ...