Commit b588126796c39a2b7d85753486bbf163c2608abe
1 parent
8005ae85
优化首页功能
Showing
10 changed files
with
331 additions
and
79 deletions
Bsth-admin/src/main/java/com/ruoyi/driver/mapper/DriverMapper.java
| 1 | package com.ruoyi.driver.mapper; | 1 | package com.ruoyi.driver.mapper; |
| 2 | 2 | ||
| 3 | -import java.util.List; | ||
| 4 | -import java.util.Set; | ||
| 5 | - | ||
| 6 | import com.ruoyi.driver.domain.Driver; | 3 | import com.ruoyi.driver.domain.Driver; |
| 7 | import com.ruoyi.pojo.request.DriverRequestVo; | 4 | import com.ruoyi.pojo.request.DriverRequestVo; |
| 8 | -import com.ruoyi.pojo.response.DriverResponseVo; | ||
| 9 | import com.ruoyi.pojo.response.ResponseSchedulingDto; | 5 | import com.ruoyi.pojo.response.ResponseSchedulingDto; |
| 10 | import com.ruoyi.pojo.vo.PeopleResponseVo; | 6 | import com.ruoyi.pojo.vo.PeopleResponseVo; |
| 11 | import org.apache.ibatis.annotations.Param; | 7 | import org.apache.ibatis.annotations.Param; |
| 12 | 8 | ||
| 9 | +import java.util.List; | ||
| 10 | + | ||
| 13 | /** | 11 | /** |
| 14 | * 驾驶员信息Mapper接口 | 12 | * 驾驶员信息Mapper接口 |
| 15 | * | 13 | * |
| @@ -26,6 +24,8 @@ public interface DriverMapper | @@ -26,6 +24,8 @@ public interface DriverMapper | ||
| 26 | */ | 24 | */ |
| 27 | public Driver selectDriverById(Long id); | 25 | public Driver selectDriverById(Long id); |
| 28 | 26 | ||
| 27 | + Driver selectDriverByJobCode(String jobCode); | ||
| 28 | + | ||
| 29 | /** | 29 | /** |
| 30 | * 查询驾驶员信息列表 | 30 | * 查询驾驶员信息列表 |
| 31 | * | 31 | * |
Bsth-admin/src/main/java/com/ruoyi/driver/service/IDriverService.java
| 1 | package com.ruoyi.driver.service; | 1 | package com.ruoyi.driver.service; |
| 2 | 2 | ||
| 3 | -import java.io.IOException; | ||
| 4 | -import java.util.List; | ||
| 5 | - | ||
| 6 | import com.ruoyi.common.core.domain.AjaxResult; | 3 | import com.ruoyi.common.core.domain.AjaxResult; |
| 7 | import com.ruoyi.common.exception.file.InvalidExtensionException; | 4 | import com.ruoyi.common.exception.file.InvalidExtensionException; |
| 8 | import com.ruoyi.common.global.Result; | 5 | import com.ruoyi.common.global.Result; |
| @@ -15,6 +12,8 @@ import org.springframework.web.multipart.MultipartFile; | @@ -15,6 +12,8 @@ import org.springframework.web.multipart.MultipartFile; | ||
| 15 | 12 | ||
| 16 | import javax.servlet.http.HttpServletRequest; | 13 | import javax.servlet.http.HttpServletRequest; |
| 17 | import javax.servlet.http.HttpServletResponse; | 14 | import javax.servlet.http.HttpServletResponse; |
| 15 | +import java.io.IOException; | ||
| 16 | +import java.util.List; | ||
| 18 | 17 | ||
| 19 | /** | 18 | /** |
| 20 | * 驾驶员信息Service接口 | 19 | * 驾驶员信息Service接口 |
| @@ -32,6 +31,8 @@ public interface IDriverService | @@ -32,6 +31,8 @@ public interface IDriverService | ||
| 32 | */ | 31 | */ |
| 33 | public Driver selectDriverById(Long id); | 32 | public Driver selectDriverById(Long id); |
| 34 | 33 | ||
| 34 | + Driver selectDriverByJobCode(String jobCode); | ||
| 35 | + | ||
| 35 | /** | 36 | /** |
| 36 | * 查询驾驶员信息列表 | 37 | * 查询驾驶员信息列表 |
| 37 | * | 38 | * |
Bsth-admin/src/main/java/com/ruoyi/driver/service/impl/DriverServiceImpl.java
| 1 | package com.ruoyi.driver.service.impl; | 1 | package com.ruoyi.driver.service.impl; |
| 2 | 2 | ||
| 3 | -import java.io.File; | ||
| 4 | -import java.io.IOException; | ||
| 5 | -import java.io.InputStream; | ||
| 6 | -import java.nio.file.Paths; | ||
| 7 | -import java.time.LocalDateTime; | ||
| 8 | -import java.time.temporal.ChronoUnit; | ||
| 9 | -import java.util.*; | ||
| 10 | -import java.util.stream.Collectors; | ||
| 11 | - | ||
| 12 | import cn.hutool.core.collection.CollectionUtil; | 3 | import cn.hutool.core.collection.CollectionUtil; |
| 13 | import cn.hutool.http.HttpUtil; | 4 | import cn.hutool.http.HttpUtil; |
| 14 | import com.github.pagehelper.util.StringUtil; | 5 | import com.github.pagehelper.util.StringUtil; |
| @@ -25,12 +16,15 @@ import com.ruoyi.common.utils.DateUtils; | @@ -25,12 +16,15 @@ import com.ruoyi.common.utils.DateUtils; | ||
| 25 | import com.ruoyi.common.utils.file.FileUploadUtils; | 16 | import com.ruoyi.common.utils.file.FileUploadUtils; |
| 26 | import com.ruoyi.common.utils.file.FileUtils; | 17 | import com.ruoyi.common.utils.file.FileUtils; |
| 27 | import com.ruoyi.common.utils.file.MimeTypeUtils; | 18 | import com.ruoyi.common.utils.file.MimeTypeUtils; |
| 19 | +import com.ruoyi.domain.DriverScheduling; | ||
| 20 | +import com.ruoyi.domain.EquipmentDriverExpand; | ||
| 21 | +import com.ruoyi.driver.domain.Driver; | ||
| 22 | +import com.ruoyi.driver.mapper.DriverMapper; | ||
| 23 | +import com.ruoyi.driver.service.IDriverService; | ||
| 28 | import com.ruoyi.equipment.mapper.EquipmentMapper; | 24 | import com.ruoyi.equipment.mapper.EquipmentMapper; |
| 29 | import com.ruoyi.framework.config.ServerConfig; | 25 | import com.ruoyi.framework.config.ServerConfig; |
| 30 | import com.ruoyi.job.DriverJob; | 26 | import com.ruoyi.job.DriverJob; |
| 31 | import com.ruoyi.pojo.DriverSignInRecommendation; | 27 | import com.ruoyi.pojo.DriverSignInRecommendation; |
| 32 | -import com.ruoyi.domain.EquipmentDriverExpand; | ||
| 33 | -import com.ruoyi.domain.DriverScheduling; | ||
| 34 | import com.ruoyi.pojo.request.DriverRequestVo; | 28 | import com.ruoyi.pojo.request.DriverRequestVo; |
| 35 | import com.ruoyi.pojo.request.DriverSignInRequestVo; | 29 | import com.ruoyi.pojo.request.DriverSignInRequestVo; |
| 36 | import com.ruoyi.pojo.request.FaceUpdateReqVo; | 30 | import com.ruoyi.pojo.request.FaceUpdateReqVo; |
| @@ -52,15 +46,20 @@ import org.slf4j.LoggerFactory; | @@ -52,15 +46,20 @@ import org.slf4j.LoggerFactory; | ||
| 52 | import org.springframework.beans.factory.annotation.Autowired; | 46 | import org.springframework.beans.factory.annotation.Autowired; |
| 53 | import org.springframework.beans.factory.annotation.Value; | 47 | import org.springframework.beans.factory.annotation.Value; |
| 54 | import org.springframework.stereotype.Service; | 48 | import org.springframework.stereotype.Service; |
| 55 | -import com.ruoyi.driver.mapper.DriverMapper; | ||
| 56 | -import com.ruoyi.driver.domain.Driver; | ||
| 57 | -import com.ruoyi.driver.service.IDriverService; | ||
| 58 | import org.springframework.web.multipart.MultipartFile; | 49 | import org.springframework.web.multipart.MultipartFile; |
| 59 | 50 | ||
| 60 | import javax.annotation.Resource; | 51 | import javax.annotation.Resource; |
| 61 | import javax.servlet.ServletOutputStream; | 52 | import javax.servlet.ServletOutputStream; |
| 62 | import javax.servlet.http.HttpServletRequest; | 53 | import javax.servlet.http.HttpServletRequest; |
| 63 | import javax.servlet.http.HttpServletResponse; | 54 | import javax.servlet.http.HttpServletResponse; |
| 55 | +import java.io.File; | ||
| 56 | +import java.io.IOException; | ||
| 57 | +import java.io.InputStream; | ||
| 58 | +import java.nio.file.Paths; | ||
| 59 | +import java.time.LocalDateTime; | ||
| 60 | +import java.time.temporal.ChronoUnit; | ||
| 61 | +import java.util.*; | ||
| 62 | +import java.util.stream.Collectors; | ||
| 64 | 63 | ||
| 65 | import static com.ruoyi.common.ApiProperties.PERSONNEL_API_KEY; | 64 | import static com.ruoyi.common.ApiProperties.PERSONNEL_API_KEY; |
| 66 | import static com.ruoyi.common.ConstDriverProperties.*; | 65 | import static com.ruoyi.common.ConstDriverProperties.*; |
| @@ -133,6 +132,11 @@ public class DriverServiceImpl implements IDriverService { | @@ -133,6 +132,11 @@ public class DriverServiceImpl implements IDriverService { | ||
| 133 | return driverMapper.selectDriverById(id); | 132 | return driverMapper.selectDriverById(id); |
| 134 | } | 133 | } |
| 135 | 134 | ||
| 135 | + @Override | ||
| 136 | + public Driver selectDriverByJobCode(String jobCode) { | ||
| 137 | + return driverMapper.selectDriverByJobCode(jobCode); | ||
| 138 | + } | ||
| 139 | + | ||
| 136 | /** | 140 | /** |
| 137 | * 查询驾驶员信息列表 | 141 | * 查询驾驶员信息列表 |
| 138 | * | 142 | * |
Bsth-admin/src/main/java/com/ruoyi/in/domain/SignInV1.java
| @@ -128,6 +128,8 @@ public class SignInV1 { | @@ -128,6 +128,8 @@ public class SignInV1 { | ||
| 128 | private String siteName; | 128 | private String siteName; |
| 129 | @TableField(exist = false) | 129 | @TableField(exist = false) |
| 130 | private String address; | 130 | private String address; |
| 131 | + @TableField(exist = false) | ||
| 132 | + private Integer signStatus; | ||
| 131 | 133 | ||
| 132 | @Override | 134 | @Override |
| 133 | public String toString() { | 135 | public String toString() { |
Bsth-admin/src/main/java/com/ruoyi/pojo/vo/bigViewVo/FleetState.java
| @@ -10,6 +10,7 @@ import lombok.Data; | @@ -10,6 +10,7 @@ import lombok.Data; | ||
| 10 | public class FleetState { | 10 | public class FleetState { |
| 11 | private String lineName; | 11 | private String lineName; |
| 12 | private Integer state; | 12 | private Integer state; |
| 13 | + private String fleetName; | ||
| 13 | 14 | ||
| 14 | @Override | 15 | @Override |
| 15 | public String toString() { | 16 | public String toString() { |
Bsth-admin/src/main/java/com/ruoyi/scheduling/service/SchedulingServiceV1.java
| @@ -9,4 +9,6 @@ import java.util.List; | @@ -9,4 +9,6 @@ import java.util.List; | ||
| 9 | public interface SchedulingServiceV1 extends IService<DriverSchedulingV1> { | 9 | public interface SchedulingServiceV1 extends IService<DriverSchedulingV1> { |
| 10 | 10 | ||
| 11 | List<DriverSchedulingV1> queryByJobCodeAndSchedulingDate(String jobCode, Date date); | 11 | List<DriverSchedulingV1> queryByJobCodeAndSchedulingDate(String jobCode, Date date); |
| 12 | + | ||
| 13 | + List<DriverSchedulingV1> queryByNbbmAndDate(String nbbm, Date date); | ||
| 12 | } | 14 | } |
Bsth-admin/src/main/java/com/ruoyi/scheduling/service/impl/SchedulingServiceV1Impl.java
| @@ -20,4 +20,12 @@ public class SchedulingServiceV1Impl extends ServiceImpl<SchedulingMapperV1, Dri | @@ -20,4 +20,12 @@ public class SchedulingServiceV1Impl extends ServiceImpl<SchedulingMapperV1, Dri | ||
| 20 | wrapper.orderByAsc(DriverSchedulingV1::getFcsjT); | 20 | wrapper.orderByAsc(DriverSchedulingV1::getFcsjT); |
| 21 | return list(wrapper); | 21 | return list(wrapper); |
| 22 | } | 22 | } |
| 23 | + | ||
| 24 | + @Override | ||
| 25 | + public List<DriverSchedulingV1> queryByNbbmAndDate(String nbbm, Date date) { | ||
| 26 | + LambdaQueryWrapper<DriverSchedulingV1> wrapper = new LambdaQueryWrapper<>(); | ||
| 27 | + wrapper.eq(DriverSchedulingV1::getNbbm, nbbm).eq(DriverSchedulingV1::getScheduleDate, date); | ||
| 28 | + | ||
| 29 | + return list(wrapper); | ||
| 30 | + } | ||
| 23 | } | 31 | } |
Bsth-admin/src/main/java/com/ruoyi/service/BigViewServiceV1.java
| @@ -11,13 +11,13 @@ import java.util.Date; | @@ -11,13 +11,13 @@ import java.util.Date; | ||
| 11 | 11 | ||
| 12 | public interface BigViewServiceV1 { | 12 | public interface BigViewServiceV1 { |
| 13 | 13 | ||
| 14 | - void asyncRefreshRedisValue(SignIn signIn, Driver driver, DriverScheduling driverScheduling,String dateStr) throws InterruptedException; | 14 | + void asyncRefreshRedisValue(SignIn signIn, Driver driver, DriverScheduling driverScheduling,String dateStr, Date date) throws InterruptedException; |
| 15 | 15 | ||
| 16 | AjaxResult queryBigViewQueryLineInfo(Date date); | 16 | AjaxResult queryBigViewQueryLineInfo(Date date); |
| 17 | 17 | ||
| 18 | - LineInfo.PersonInfoVo refreshRedisDriver(SignIn signIn, Driver driver); | 18 | + LineInfo refreshRedisDriver(SignIn signIn, Driver driver, String dateStr, DriverScheduling driverScheduling, Date date); |
| 19 | 19 | ||
| 20 | - FleetState refreshRedisLine(SignIn signIn, DriverScheduling driverScheduling) throws InterruptedException; | 20 | + FleetState refreshRedisLine(SignIn signIn, DriverScheduling driverScheduling, String dateStr) throws InterruptedException; |
| 21 | 21 | ||
| 22 | /*** | 22 | /*** |
| 23 | * 判断酒测次数 | 23 | * 判断酒测次数 |
| @@ -69,4 +69,14 @@ public interface BigViewServiceV1 { | @@ -69,4 +69,14 @@ public interface BigViewServiceV1 { | ||
| 69 | * @return boolean | 69 | * @return boolean |
| 70 | */ | 70 | */ |
| 71 | boolean isSignStatusZoneEnum(SignIn signIn); | 71 | boolean isSignStatusZoneEnum(SignIn signIn); |
| 72 | + /*** | ||
| 73 | + * 是否是驾驶员 | ||
| 74 | + * @author liujun | ||
| 75 | + * @date 2024/10/9 13:53 | ||
| 76 | + * | ||
| 77 | + * @param driver | ||
| 78 | + * @return boolean | ||
| 79 | + */ | ||
| 80 | + boolean isDriver(Driver driver); | ||
| 81 | + | ||
| 72 | } | 82 | } |
Bsth-admin/src/main/java/com/ruoyi/service/impl/BigViewServiceV1Impl.java
| @@ -4,13 +4,18 @@ import com.alibaba.fastjson2.JSON; | @@ -4,13 +4,18 @@ import com.alibaba.fastjson2.JSON; | ||
| 4 | import com.ruoyi.common.SignStatusEnum; | 4 | import com.ruoyi.common.SignStatusEnum; |
| 5 | import com.ruoyi.common.core.domain.AjaxResult; | 5 | import com.ruoyi.common.core.domain.AjaxResult; |
| 6 | import com.ruoyi.common.core.redis.RedisCache; | 6 | import com.ruoyi.common.core.redis.RedisCache; |
| 7 | +import com.ruoyi.common.utils.DateUtils; | ||
| 7 | import com.ruoyi.domain.DriverScheduling; | 8 | import com.ruoyi.domain.DriverScheduling; |
| 9 | +import com.ruoyi.domain.DriverSchedulingV1; | ||
| 8 | import com.ruoyi.driver.domain.Driver; | 10 | import com.ruoyi.driver.domain.Driver; |
| 11 | +import com.ruoyi.driver.service.IDriverService; | ||
| 9 | import com.ruoyi.in.domain.SignIn; | 12 | import com.ruoyi.in.domain.SignIn; |
| 10 | import com.ruoyi.in.domain.SignInV1; | 13 | import com.ruoyi.in.domain.SignInV1; |
| 14 | +import com.ruoyi.in.service.SignInServiceV1; | ||
| 11 | import com.ruoyi.pojo.vo.bigViewVo.FleetInfoVo; | 15 | import com.ruoyi.pojo.vo.bigViewVo.FleetInfoVo; |
| 12 | import com.ruoyi.pojo.vo.bigViewVo.FleetState; | 16 | import com.ruoyi.pojo.vo.bigViewVo.FleetState; |
| 13 | import com.ruoyi.pojo.vo.bigViewVo.LineInfo; | 17 | import com.ruoyi.pojo.vo.bigViewVo.LineInfo; |
| 18 | +import com.ruoyi.scheduling.service.SchedulingServiceV1; | ||
| 14 | import com.ruoyi.service.BigViewServiceV1; | 19 | import com.ruoyi.service.BigViewServiceV1; |
| 15 | import com.ruoyi.template.domain.FleetLineTemplate; | 20 | import com.ruoyi.template.domain.FleetLineTemplate; |
| 16 | import com.ruoyi.template.service.IFleetLineTemplateService; | 21 | import com.ruoyi.template.service.IFleetLineTemplateService; |
| @@ -43,75 +48,105 @@ public class BigViewServiceV1Impl implements BigViewServiceV1 { | @@ -43,75 +48,105 @@ public class BigViewServiceV1Impl implements BigViewServiceV1 { | ||
| 43 | @Autowired | 48 | @Autowired |
| 44 | private IFleetLineTemplateService fleetLineTemplateService; | 49 | private IFleetLineTemplateService fleetLineTemplateService; |
| 45 | @Autowired | 50 | @Autowired |
| 51 | + private SchedulingServiceV1 schedulingServiceV1; | ||
| 52 | + @Autowired | ||
| 53 | + private IDriverService driverService; | ||
| 54 | + @Autowired | ||
| 55 | + private SignInServiceV1 signInServiceV1; | ||
| 56 | + | ||
| 57 | + @Autowired | ||
| 46 | private RedisCache redisCache; | 58 | private RedisCache redisCache; |
| 47 | 59 | ||
| 48 | - private static final String DRIVER_SIGN_KEY = "sign:driver:{0}:{1}"; | ||
| 49 | 60 | ||
| 50 | - private static final String LINE_SIGN_KEY = "sign:line:{0}:{1}"; | 61 | + private static final String LINE_SIGN_NBBM_KEY = "sign:report:nbbm:{0}:{1}"; |
| 62 | + private static final String LINE_SIGN_NBBM_LOCK_KEY = "sign:report:lock:nbbm:{0}:{1}"; | ||
| 51 | 63 | ||
| 52 | - private static final String LOCK_LINE_SIGN_KEY = "sign:lock:{0}:{1}"; | 64 | + private static final String LINE_SIGN_STATUS_KEY = "sign:report:status:{0}:{1}"; |
| 65 | + private static final String LINE_SIGN_STATUS_LOCK_KEY = "sign:report:lock:status:{0}:{1}"; | ||
| 53 | 66 | ||
| 54 | - private static final String SIGN_REPORT_LIST = "sign:report:list:{0}"; | 67 | + private static final String LINE_SIGN_REPORT_FLEET_KEY = "sign:report:fleet:{0}"; |
| 68 | + | ||
| 69 | + private static final String BIG_VIEW_LINE_KEY = "big:view:line:{0}"; | ||
| 55 | 70 | ||
| 56 | - @Override | ||
| 57 | - public void asyncRefreshRedisValue(SignIn signIn, Driver driver, DriverScheduling driverScheduling, String dateStr) throws InterruptedException { | ||
| 58 | - String key = MessageFormat.format(SIGN_REPORT_LIST, dateStr); | ||
| 59 | 71 | ||
| 60 | - refreshRedisDriver(signIn, driver); | ||
| 61 | - refreshRedisLine(signIn, driverScheduling); | 72 | + @Override |
| 73 | + public void asyncRefreshRedisValue(SignIn signIn, Driver driver, DriverScheduling driverScheduling, String dateStr, Date date) throws InterruptedException { | ||
| 74 | + refreshRedisDriver(signIn, driver, dateStr, driverScheduling, date); | ||
| 75 | + refreshRedisLine(signIn, driverScheduling, dateStr); | ||
| 62 | } | 76 | } |
| 63 | 77 | ||
| 64 | @Override | 78 | @Override |
| 65 | public AjaxResult queryBigViewQueryLineInfo(Date date) { | 79 | public AjaxResult queryBigViewQueryLineInfo(Date date) { |
| 66 | - return null; | 80 | + String dateStr = DateUtils.FAST_YYYY_MM_DD.format(date); |
| 81 | + String key = MessageFormat.format(BIG_VIEW_LINE_KEY, dateStr); | ||
| 82 | + | ||
| 83 | + List<FleetInfoVo> fleetInfoVos = getFleetInfoVoBtRedis(key); | ||
| 84 | + if (CollectionUtils.isEmpty(fleetInfoVos)) { | ||
| 85 | + fleetInfoVos = combationFleetInfoVoBtRedis(key, dateStr); | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + return AjaxResult.success(fleetInfoVos); | ||
| 67 | } | 89 | } |
| 68 | 90 | ||
| 69 | 91 | ||
| 70 | @Override | 92 | @Override |
| 71 | - public LineInfo.PersonInfoVo refreshRedisDriver(SignIn signIn, Driver driver) { | ||
| 72 | - LineInfo.PersonInfoVo personInfoVo = new LineInfo.PersonInfoVo(); | ||
| 73 | - personInfoVo.setName(driver.getPersonnelName()); | 93 | + public LineInfo refreshRedisDriver(SignIn signIn, Driver driver, String dateStr, DriverScheduling driverScheduling, Date date) { |
| 94 | + LineInfo.PersonInfoVo personInfoVo = combationPersonInfoVo(driver, signIn); | ||
| 74 | 95 | ||
| 75 | - if (isSignStatusZoneEnum(signIn)) { | ||
| 76 | - personInfoVo.setSignStatus(SignStatusEnum.SIGN_STATUS_ZONE_ENUM); | ||
| 77 | - } else if (isSignStatusWineEnum(signIn)) { | ||
| 78 | - personInfoVo.setSignStatus(SignStatusEnum.SIGN_STATUS_WINE_ENUM); | ||
| 79 | - } else if (isSignStatusDelayEnum(signIn)) { | ||
| 80 | - personInfoVo.setSignStatus(SignStatusEnum.SIGN_STATUS_DELAY_ENUM); | ||
| 81 | - } | ||
| 82 | - personInfoVo.setPosts(driver.getPosts()); | 96 | + LineInfo lineInfo = null; |
| 97 | + String key = MessageFormat.format(LINE_SIGN_NBBM_KEY, dateStr, driverScheduling.getNbbm()); | ||
| 83 | 98 | ||
| 84 | - String dateStr = ConstDateUtil.formatDate(signIn.getCreateTime()); | 99 | + for (int i = 0; i < 1000; i++) { |
| 100 | + String lockKey = MessageFormat.format(LINE_SIGN_NBBM_LOCK_KEY, dateStr, driverScheduling.getNbbm()); | ||
| 101 | + if (redisCache.setNx(lockKey, 1, 10L, TimeUnit.SECONDS)) { | ||
| 85 | 102 | ||
| 86 | - String key = MessageFormat.format(DRIVER_SIGN_KEY, dateStr, driver.getJobCode()); | ||
| 87 | - redisCache.setCacheObject(key, JSON.toJSONString(personInfoVo), 25, TimeUnit.HOURS); | 103 | + try { |
| 104 | + lineInfo = getLineInfoByRedis(key); | ||
| 105 | + if (Objects.isNull(lineInfo)) { | ||
| 106 | + lineInfo = queryLineInfo(date, signIn, driverScheduling); | ||
| 107 | + } | ||
| 88 | 108 | ||
| 89 | - return personInfoVo; | 109 | + if (Objects.isNull(lineInfo)) { |
| 110 | + return null; | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + setDriverByPost(driver, lineInfo, personInfoVo); | ||
| 114 | + redisCache.setCacheObject(key, JSON.toJSONString(lineInfo), 25, TimeUnit.HOURS); | ||
| 115 | + return lineInfo; | ||
| 116 | + } finally { | ||
| 117 | + redisCache.deleteObject(lockKey); | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + try { | ||
| 123 | + log.info("没有获取到redis锁,等待1秒钟后再试"); | ||
| 124 | + Thread.sleep(1000); | ||
| 125 | + } catch (InterruptedException e) { | ||
| 126 | + log.error("刷新redis中首页的driver数据异常,[{}],[{}],[{}]", signIn, driver, driverScheduling, e); | ||
| 127 | + } | ||
| 128 | + } | ||
| 129 | + log.info("已1000秒获取锁等待没有获取到锁,已放弃操作,[{}],[{}],[{}]", signIn, driver, driverScheduling); | ||
| 130 | + return lineInfo; | ||
| 90 | } | 131 | } |
| 91 | 132 | ||
| 92 | 133 | ||
| 93 | @Override | 134 | @Override |
| 94 | - public FleetState refreshRedisLine(SignIn signIn, DriverScheduling driverScheduling) throws InterruptedException { | ||
| 95 | - String dateStr = ConstDateUtil.formatDate(signIn.getCreateTime()); | ||
| 96 | - String key = MessageFormat.format(LINE_SIGN_KEY, dateStr, driverScheduling.getLineName()); | ||
| 97 | - FleetState source = redisCache.getCacheObject(key); | 135 | + public FleetState refreshRedisLine(SignIn signIn, DriverScheduling driverScheduling, String dateStr) throws InterruptedException { |
| 98 | 136 | ||
| 99 | FleetState fleetState = new FleetState(); | 137 | FleetState fleetState = new FleetState(); |
| 100 | fleetState.setLineName(driverScheduling.getLineName()); | 138 | fleetState.setLineName(driverScheduling.getLineName()); |
| 139 | + fleetState.setState(switchSignStatus(signIn)); | ||
| 140 | + fleetState.setFleetName(driverScheduling.getFleetName()); | ||
| 101 | 141 | ||
| 102 | - if (isSignStatusWineEnum(signIn)) { | ||
| 103 | - fleetState.setState(SignStatusEnum.SIGN_STATUS_WINE_ENUM.getStatus()); | ||
| 104 | - } else if (isSignStatusDelayEnum(signIn)) { | ||
| 105 | - fleetState.setState(SignStatusEnum.SIGN_STATUS_DELAY_ENUM.getStatus()); | ||
| 106 | - } else { | ||
| 107 | - fleetState.setState(SignStatusEnum.SIGN_STATUS_ZONE_ENUM.getStatus()); | ||
| 108 | - } | 142 | + String key = MessageFormat.format(LINE_SIGN_STATUS_KEY, dateStr, driverScheduling.getLineName()); |
| 143 | + FleetState source = redisCache.getCacheObject(key); | ||
| 109 | 144 | ||
| 110 | if (Objects.isNull(source) || Objects.isNull(source.getState()) || (fleetState.getState() > source.getState())) { | 145 | if (Objects.isNull(source) || Objects.isNull(source.getState()) || (fleetState.getState() > source.getState())) { |
| 111 | boolean flag = true; | 146 | boolean flag = true; |
| 112 | - String lockKey = MessageFormat.format(LOCK_LINE_SIGN_KEY, dateStr, driverScheduling.getLineName()); | 147 | + String lockKey = MessageFormat.format(LINE_SIGN_STATUS_LOCK_KEY, dateStr, driverScheduling.getLineName()); |
| 113 | for (int i = 0; i < 10000; i++) { | 148 | for (int i = 0; i < 10000; i++) { |
| 114 | - if (redisCache.setNx(lockKey, fleetState, 10L, TimeUnit.SECONDS)) { | 149 | + if (redisCache.setNx(lockKey, 1, 10L, TimeUnit.SECONDS)) { |
| 115 | try { | 150 | try { |
| 116 | redisCache.setCacheObject(key, JSON.toJSONString(fleetState), 25, TimeUnit.HOURS); | 151 | redisCache.setCacheObject(key, JSON.toJSONString(fleetState), 25, TimeUnit.HOURS); |
| 117 | } finally { | 152 | } finally { |
| @@ -160,42 +195,43 @@ public class BigViewServiceV1Impl implements BigViewServiceV1 { | @@ -160,42 +195,43 @@ public class BigViewServiceV1Impl implements BigViewServiceV1 { | ||
| 160 | 195 | ||
| 161 | @Override | 196 | @Override |
| 162 | public boolean isSignStatusWineEnum(SignIn signIn) { | 197 | public boolean isSignStatusWineEnum(SignIn signIn) { |
| 163 | - return Objects.equals(3, signIn.getExType()) || Objects.equals(23, signIn.getExType()) || Objects.equals(33, signIn.getExType()); | 198 | + return Objects.nonNull(signIn) && (Objects.equals(3, signIn.getExType()) || Objects.equals(23, signIn.getExType()) || Objects.equals(33, signIn.getExType())); |
| 164 | } | 199 | } |
| 165 | 200 | ||
| 166 | 201 | ||
| 167 | @Override | 202 | @Override |
| 168 | public boolean isSignStatusDelayEnum(SignIn signIn) { | 203 | public boolean isSignStatusDelayEnum(SignIn signIn) { |
| 169 | - return Objects.nonNull(signIn.getExType()) && signIn.getExType() >= 30 && signIn.getExType() < 40; | 204 | + return Objects.nonNull(signIn) && Objects.nonNull(signIn.getExType()) && signIn.getExType() >= 30 && signIn.getExType() < 40; |
| 170 | } | 205 | } |
| 171 | 206 | ||
| 172 | @Override | 207 | @Override |
| 173 | public boolean isSignStatusZoneEnum(SignIn signIn) { | 208 | public boolean isSignStatusZoneEnum(SignIn signIn) { |
| 174 | - return Objects.equals(0, signIn.getExType()); | 209 | + return Objects.nonNull(signIn) && Objects.equals(0, signIn.getExType()); |
| 210 | + } | ||
| 211 | + | ||
| 212 | + @Override | ||
| 213 | + public boolean isDriver(Driver driver) { | ||
| 214 | + return Objects.nonNull(driver) && StringUtils.isNotEmpty(driver.getPosts()) && StringUtils.indexOf(driver.getPosts(), "驾驶员") > -1; | ||
| 175 | } | 215 | } |
| 176 | 216 | ||
| 177 | - private boolean chooseRedisData(String key, SignIn signIn, Driver driver, DriverScheduling driverScheduling) { | 217 | + |
| 218 | + private List<FleetInfoVo> getFleetInfoVoOfRedis(String key) { | ||
| 178 | try { | 219 | try { |
| 179 | String jsonStr = redisCache.getCacheObject(key); | 220 | String jsonStr = redisCache.getCacheObject(key); |
| 180 | if (StringUtils.isEmpty(jsonStr)) { | 221 | if (StringUtils.isEmpty(jsonStr)) { |
| 181 | - log.info("redis中没有当天的数据[{}],[{}],[{}],[{}]", key, signIn, driver, driverScheduling); | ||
| 182 | - return false; | ||
| 183 | - } | ||
| 184 | 222 | ||
| 185 | - List<FleetInfoVo> fleetInfoVos = JSON.parseArray(jsonStr, FleetInfoVo.class); | ||
| 186 | - if (CollectionUtils.isEmpty(fleetInfoVos)) { | ||
| 187 | - log.info("redis中的数据为空[{}],[{}],[{}],[{}]", key, signIn, driver, driverScheduling); | ||
| 188 | - return false; | 223 | + log.info("redis中没有当天的数据[{}]", key); |
| 224 | + return Collections.emptyList(); | ||
| 189 | } | 225 | } |
| 190 | - | ||
| 191 | - | 226 | + return JSON.parseArray(jsonStr, FleetInfoVo.class); |
| 192 | } catch (Exception e) { | 227 | } catch (Exception e) { |
| 193 | - log.error("刷新签到数据异常[{}],[{}],[{}],[{}]", key, signIn, driver, driverScheduling, e); | 228 | + log.error("从redis中获取数据异常,[{}]", key, e); |
| 194 | } | 229 | } |
| 195 | - return false; | 230 | + return null; |
| 196 | } | 231 | } |
| 197 | 232 | ||
| 198 | - private List<FleetInfoVo> saveFleetLineTemp() { | 233 | + private List<FleetInfoVo> combationFleetInfoVo(String redisKey) { |
| 234 | + | ||
| 199 | List<FleetLineTemplate> fleetLineTemplates = fleetLineTemplateService.selectFleetLineTemplateList(); | 235 | List<FleetLineTemplate> fleetLineTemplates = fleetLineTemplateService.selectFleetLineTemplateList(); |
| 200 | if (CollectionUtils.isEmpty(fleetLineTemplates)) { | 236 | if (CollectionUtils.isEmpty(fleetLineTemplates)) { |
| 201 | return null; | 237 | return null; |
| @@ -212,7 +248,7 @@ public class BigViewServiceV1Impl implements BigViewServiceV1 { | @@ -212,7 +248,7 @@ public class BigViewServiceV1Impl implements BigViewServiceV1 { | ||
| 212 | if (CollectionUtils.isNotEmpty(vals)) { | 248 | if (CollectionUtils.isNotEmpty(vals)) { |
| 213 | List<FleetInfoVo.FleetInfo> fleetInfoVoFleetInfos = new ArrayList<>(); | 249 | List<FleetInfoVo.FleetInfo> fleetInfoVoFleetInfos = new ArrayList<>(); |
| 214 | List<FleetState> fleetStates = new ArrayList<>(); | 250 | List<FleetState> fleetStates = new ArrayList<>(); |
| 215 | - vals.stream().forEach(fl -> { | 251 | + vals.forEach(fl -> { |
| 216 | FleetInfoVo.FleetInfo fleetInfo = new FleetInfoVo.FleetInfo(); | 252 | FleetInfoVo.FleetInfo fleetInfo = new FleetInfoVo.FleetInfo(); |
| 217 | fleetInfo.setLineName(fl.getLineName()); | 253 | fleetInfo.setLineName(fl.getLineName()); |
| 218 | fleetInfoVoFleetInfos.add(fleetInfo); | 254 | fleetInfoVoFleetInfos.add(fleetInfo); |
| @@ -229,6 +265,189 @@ public class BigViewServiceV1Impl implements BigViewServiceV1 { | @@ -229,6 +265,189 @@ public class BigViewServiceV1Impl implements BigViewServiceV1 { | ||
| 229 | fleetInfoVos.add(fleetInfoVo); | 265 | fleetInfoVos.add(fleetInfoVo); |
| 230 | }); | 266 | }); |
| 231 | 267 | ||
| 268 | + redisCache.setCacheObject(redisKey, JSON.toJSONString(fleetInfoVos), 25, TimeUnit.HOURS); | ||
| 269 | + return fleetInfoVos; | ||
| 270 | + } | ||
| 271 | + | ||
| 272 | + private LineInfo getLineInfoByRedis(String key) { | ||
| 273 | + try { | ||
| 274 | + String jsonStr = redisCache.getCacheObject(key); | ||
| 275 | + if (StringUtils.isEmpty(jsonStr)) { | ||
| 276 | + return null; | ||
| 277 | + } | ||
| 278 | + return JSON.parseObject(jsonStr, LineInfo.class); | ||
| 279 | + } catch (Exception e) { | ||
| 280 | + log.error("从redis中获取LineInfo 异常:[{}]", key, e); | ||
| 281 | + } | ||
| 282 | + return null; | ||
| 283 | + } | ||
| 284 | + | ||
| 285 | + private LineInfo queryLineInfo(Date date, SignIn signIn, DriverScheduling driverScheduling) { | ||
| 286 | + List<DriverSchedulingV1> driverSchedulingV1List = schedulingServiceV1.queryByNbbmAndDate(driverScheduling.getNbbm(), date); | ||
| 287 | + if (CollectionUtils.isEmpty(driverSchedulingV1List)) { | ||
| 288 | + return null; | ||
| 289 | + } | ||
| 290 | + | ||
| 291 | + LineInfo lineInfo = new LineInfo(); | ||
| 292 | + lineInfo.setLineName(driverScheduling.getLineName()); | ||
| 293 | + lineInfo.setFleetName(driverScheduling.getFleetName()); | ||
| 294 | + lineInfo.setNbbm(driverScheduling.getNbbm()); | ||
| 295 | + | ||
| 296 | + List<DriverSchedulingV1> otherDriverSchedulingV1List = driverSchedulingV1List.stream().filter(dc -> !Objects.equals(dc.getJobCode(), signIn.getJobCode()) | ||
| 297 | + && Objects.nonNull(dc.getSignInId())).collect(Collectors.toList()); | ||
| 298 | + if (CollectionUtils.isEmpty(otherDriverSchedulingV1List)) { | ||
| 299 | + return lineInfo; | ||
| 300 | + } | ||
| 301 | + | ||
| 302 | + Map<String, List<DriverScheduling>> maps = otherDriverSchedulingV1List.stream().collect(Collectors.groupingBy(DriverSchedulingV1::getJobCode, Collectors.toList())); | ||
| 303 | + | ||
| 304 | + for (Map.Entry<String, List<DriverScheduling>> entry : maps.entrySet()) { | ||
| 305 | + if (Objects.isNull(entry.getValue())) { | ||
| 306 | + continue; | ||
| 307 | + } | ||
| 308 | + Driver otherDriver = driverService.selectDriverByJobCode(entry.getKey()); | ||
| 309 | + if (Objects.isNull(otherDriver)) { | ||
| 310 | + continue; | ||
| 311 | + } | ||
| 312 | + SignInV1 otherSign = null; | ||
| 313 | + SignIn otherTagetSign = null; | ||
| 314 | + | ||
| 315 | + for (DriverScheduling sourceDriverScheduling : entry.getValue()) { | ||
| 316 | + SignInV1 otherSign1 = signInServiceV1.getById(sourceDriverScheduling.getSignInId()); | ||
| 317 | + if (Objects.isNull(otherSign1)) { | ||
| 318 | + continue; | ||
| 319 | + } | ||
| 320 | + SignIn signIn1 = new SignIn(); | ||
| 321 | + BeanUtils.copyProperties(otherSign1, signIn1); | ||
| 322 | + otherSign1.setSignStatus(switchSignStatus(signIn1)); | ||
| 323 | + | ||
| 324 | + if (Objects.isNull(otherSign)) { | ||
| 325 | + otherSign = otherSign1; | ||
| 326 | + otherTagetSign = signIn1; | ||
| 327 | + } else if (Objects.nonNull(otherSign.getExType()) && Objects.nonNull(otherSign1.getExType()) && Objects.nonNull(otherSign1.getSignStatus()) && Objects.nonNull(otherSign.getSignStatus()) | ||
| 328 | + && otherSign1.getSignStatus() > otherSign.getSignStatus()) { | ||
| 329 | + otherSign = otherSign1; | ||
| 330 | + otherTagetSign = signIn1; | ||
| 331 | + } else if (Objects.nonNull(otherSign.getExType()) && Objects.nonNull(otherSign1.getExType()) && Objects.nonNull(otherSign1.getSignStatus()) && Objects.isNull(otherSign.getSignStatus())) { | ||
| 332 | + otherSign = otherSign1; | ||
| 333 | + otherTagetSign = signIn1; | ||
| 334 | + } | ||
| 335 | + } | ||
| 336 | + | ||
| 337 | + | ||
| 338 | + LineInfo.PersonInfoVo personInfoVo = combationPersonInfoVo(otherDriver, otherTagetSign); | ||
| 339 | + setDriverByPost(otherDriver, lineInfo, personInfoVo); | ||
| 340 | + } | ||
| 341 | + | ||
| 342 | + return lineInfo; | ||
| 343 | + } | ||
| 344 | + | ||
| 345 | + private LineInfo.PersonInfoVo combationPersonInfoVo(Driver driver, SignIn signIn) { | ||
| 346 | + LineInfo.PersonInfoVo personInfoVo = new LineInfo.PersonInfoVo(); | ||
| 347 | + personInfoVo.setName(driver.getPersonnelName()); | ||
| 348 | + | ||
| 349 | + personInfoVo.setSignStatus(switchSignStatus(signIn)); | ||
| 350 | + personInfoVo.setPosts(driver.getPosts()); | ||
| 351 | + | ||
| 352 | + return personInfoVo; | ||
| 353 | + } | ||
| 354 | + | ||
| 355 | + private Integer switchSignStatus(SignIn signIn) { | ||
| 356 | + if (Objects.isNull(signIn.getExType())) { | ||
| 357 | + return null; | ||
| 358 | + } | ||
| 359 | + if (isSignStatusWineEnum(signIn)) { | ||
| 360 | + return SignStatusEnum.SIGN_STATUS_WINE_ENUM.getStatus(); | ||
| 361 | + } | ||
| 362 | + | ||
| 363 | + if (isSignStatusDelayEnum(signIn)) { | ||
| 364 | + return SignStatusEnum.SIGN_STATUS_DELAY_ENUM.getStatus(); | ||
| 365 | + } | ||
| 366 | + | ||
| 367 | + if (isSignStatusZoneEnum(signIn)) { | ||
| 368 | + return SignStatusEnum.SIGN_STATUS_ZONE_ENUM.getStatus(); | ||
| 369 | + } | ||
| 370 | + return SignStatusEnum.SIGN_STATUS_EMPTY_ENUM.getStatus(); | ||
| 371 | + | ||
| 372 | + } | ||
| 373 | + | ||
| 374 | + private void setDriverByPost(Driver driver, LineInfo lineInfo, LineInfo.PersonInfoVo personInfoVo) { | ||
| 375 | + if (isDriver(driver)) { | ||
| 376 | + lineInfo.setDriverInfoVo(personInfoVo); | ||
| 377 | + } else { | ||
| 378 | + lineInfo.setDriverInfoVo(personInfoVo); | ||
| 379 | + } | ||
| 380 | + } | ||
| 381 | + | ||
| 382 | + private <T> List<T> getRedisData(String key, String dateStr, Class<T> calzz) { | ||
| 383 | + key = MessageFormat.format(key, dateStr, "*"); | ||
| 384 | + List<String> jsonStrs = redisCache.getCacheList(key); | ||
| 385 | + if (CollectionUtils.isEmpty(jsonStrs)) { | ||
| 386 | + return Collections.emptyList(); | ||
| 387 | + } | ||
| 388 | + return jsonStrs.stream().map(json -> { | ||
| 389 | + T t = JSON.parseObject(json, calzz); | ||
| 390 | + return t; | ||
| 391 | + }).collect(Collectors.toList()); | ||
| 392 | + } | ||
| 393 | + | ||
| 394 | + private List<FleetInfoVo> getFleetInfoVoBtRedis(String key) { | ||
| 395 | + try { | ||
| 396 | + String json = redisCache.getCacheObject(key); | ||
| 397 | + if (StringUtils.isEmpty(json)) { | ||
| 398 | + return Collections.emptyList(); | ||
| 399 | + } | ||
| 400 | + return JSON.parseArray(json, FleetInfoVo.class); | ||
| 401 | + } catch (Exception e) { | ||
| 402 | + log.error("[{}]从redis中获取页面数据异常", key, e); | ||
| 403 | + } | ||
| 404 | + return Collections.emptyList(); | ||
| 405 | + } | ||
| 406 | + | ||
| 407 | + private List<FleetInfoVo> combationFleetInfoVoBtRedis(String redisKey, String dateStr) { | ||
| 408 | + | ||
| 409 | + String key = MessageFormat.format(LINE_SIGN_REPORT_FLEET_KEY, dateStr); | ||
| 410 | + List<FleetInfoVo> fleetInfoVos = getFleetInfoVoOfRedis(key); | ||
| 411 | + if (CollectionUtils.isEmpty(fleetInfoVos)) { | ||
| 412 | + fleetInfoVos = combationFleetInfoVo(key); | ||
| 413 | + } | ||
| 414 | + | ||
| 415 | + if (CollectionUtils.isEmpty(fleetInfoVos)) { | ||
| 416 | + return Collections.emptyList(); | ||
| 417 | + } | ||
| 418 | + List<LineInfo> lineInfoList = getRedisData(LINE_SIGN_NBBM_KEY, dateStr, LineInfo.class); | ||
| 419 | + List<FleetState> fleetStates = getRedisData(LINE_SIGN_STATUS_KEY, dateStr, FleetState.class); | ||
| 420 | + | ||
| 421 | + int lineInfoListSize = CollectionUtils.size(lineInfoList); | ||
| 422 | + int fleetStatesSize = CollectionUtils.size(fleetStates); | ||
| 423 | + | ||
| 424 | + fleetInfoVos = fleetInfoVos.stream().map(fv -> { | ||
| 425 | + if (lineInfoListSize > 0) { | ||
| 426 | + if (CollectionUtils.isNotEmpty(fv.getFleetInfos())) { | ||
| 427 | + List<FleetInfoVo.FleetInfo> fleetInfos = fv.getFleetInfos().stream().map(fi -> { | ||
| 428 | + List<LineInfo> lineInfos = lineInfoList.stream().filter(l -> Objects.equals(fv.getTitle(), l.getFleetName()) && | ||
| 429 | + Objects.equals(fi.getLineName(), l.getLineName())).collect(Collectors.toList()); | ||
| 430 | + if (CollectionUtils.isNotEmpty(lineInfos)) { | ||
| 431 | + fi.setLineInfos(lineInfos); | ||
| 432 | + } | ||
| 433 | + return fi; | ||
| 434 | + }).collect(Collectors.toList()); | ||
| 435 | + | ||
| 436 | + fv.setFleetInfos(fleetInfos); | ||
| 437 | + } | ||
| 438 | + } | ||
| 439 | + | ||
| 440 | + if (fleetStatesSize > 0) { | ||
| 441 | + List<FleetState> fss = fleetStates.stream().filter(fs -> Objects.equals(fs.getFleetName(), fv.getTitle())).collect(Collectors.toList()); | ||
| 442 | + if (CollectionUtils.isNotEmpty(fss)) { | ||
| 443 | + fv.setFleetStates(fss); | ||
| 444 | + } | ||
| 445 | + } | ||
| 446 | + return fv; | ||
| 447 | + }).collect(Collectors.toList()); | ||
| 448 | + | ||
| 449 | + redisCache.setCacheObject(redisKey, JSON.toJSONString(fleetInfoVos), 10, TimeUnit.SECONDS); | ||
| 232 | return fleetInfoVos; | 450 | return fleetInfoVos; |
| 233 | } | 451 | } |
| 452 | + | ||
| 234 | } | 453 | } |
Bsth-admin/src/main/resources/mapper/driver/DriverMapper.xml
| @@ -120,6 +120,11 @@ | @@ -120,6 +120,11 @@ | ||
| 120 | <include refid="selectDriverVo"/> | 120 | <include refid="selectDriverVo"/> |
| 121 | where id = #{id} | 121 | where id = #{id} |
| 122 | </select> | 122 | </select> |
| 123 | + | ||
| 124 | + <select id="selectDriverByJobCode" parameterType="java.lang.String" resultMap="DriverResult"> | ||
| 125 | + <include refid="selectDriverVo"/> | ||
| 126 | + where job_code = #{jobCode} | ||
| 127 | + </select> | ||
| 123 | <select id="getNameByJobCode" resultMap="DriverResult"> | 128 | <select id="getNameByJobCode" resultMap="DriverResult"> |
| 124 | select personnel_name,job_code | 129 | select personnel_name,job_code |
| 125 | from driver | 130 | from driver |