Commit 71de797afa6720ec945476cf3b9f6e73ba4a92ac
1 parent
8cd90575
优化首页数据
Showing
8 changed files
with
480 additions
and
4 deletions
Bsth-admin/src/main/java/com/ruoyi/domain/DriverSchedulingV1.java
0 → 100644
Bsth-admin/src/main/java/com/ruoyi/in/domain/CalDriverScheduling.java
0 → 100644
| 1 | +package com.ruoyi.in.domain; | ||
| 2 | + | ||
| 3 | +import com.ruoyi.domain.DriverScheduling; | ||
| 4 | +import lombok.Data; | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * @author liujun | ||
| 8 | + * @date 2024年09月23日 11:29 | ||
| 9 | + */ | ||
| 10 | +@Data | ||
| 11 | +public class CalDriverScheduling { | ||
| 12 | + | ||
| 13 | + private Integer index; | ||
| 14 | + private DriverScheduling driverScheduling; | ||
| 15 | + | ||
| 16 | + public CalDriverScheduling(Integer index, DriverScheduling driverScheduling) { | ||
| 17 | + this.index = index; | ||
| 18 | + this.driverScheduling = driverScheduling; | ||
| 19 | + } | ||
| 20 | +} |
Bsth-admin/src/main/java/com/ruoyi/in/domain/SignInV1.java
0 → 100644
| 1 | +package com.ruoyi.in.domain; | ||
| 2 | + | ||
| 3 | +import com.alibaba.fastjson2.JSON; | ||
| 4 | +import com.baomidou.mybatisplus.annotation.TableField; | ||
| 5 | +import com.baomidou.mybatisplus.annotation.TableName; | ||
| 6 | +import com.fasterxml.jackson.annotation.JsonFormat; | ||
| 7 | +import com.ruoyi.common.annotation.Excel; | ||
| 8 | +import io.swagger.annotations.ApiModelProperty; | ||
| 9 | +import lombok.Data; | ||
| 10 | + | ||
| 11 | +import javax.validation.constraints.NotBlank; | ||
| 12 | +import javax.validation.constraints.NotNull; | ||
| 13 | +import java.math.BigDecimal; | ||
| 14 | +import java.util.Date; | ||
| 15 | + | ||
| 16 | +/** | ||
| 17 | + * @author liujun | ||
| 18 | + * @date 2024年09月23日 15:44 | ||
| 19 | + */ | ||
| 20 | +@Data | ||
| 21 | +@TableName("sign_in") | ||
| 22 | +public class SignInV1 { | ||
| 23 | + private static final long serialVersionUID = 1L; | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 主键 | ||
| 27 | + */ | ||
| 28 | + @ApiModelProperty("主键") | ||
| 29 | + private Long id; | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * 工号 | ||
| 33 | + */ | ||
| 34 | + @Excel(name = "工号") | ||
| 35 | + @ApiModelProperty("工号") | ||
| 36 | + @NotBlank(message = "工号不能为空") | ||
| 37 | + @TableField(value = "jobCode") | ||
| 38 | + private String jobCode; | ||
| 39 | + | ||
| 40 | + @Excel(name = "设备号") | ||
| 41 | + @ApiModelProperty("设备号") | ||
| 42 | + @NotBlank(message = "设备号不能为空") | ||
| 43 | + private String deviceId; | ||
| 44 | + /** | ||
| 45 | + * 设备地址 | ||
| 46 | + */ | ||
| 47 | + @Excel(name = "设备地址") | ||
| 48 | + @ApiModelProperty("设备ip 不用填写") | ||
| 49 | + private String ip; | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * 图片 | ||
| 53 | + */ | ||
| 54 | + @Excel(name = "图片") | ||
| 55 | + @ApiModelProperty("图片信息") | ||
| 56 | + @NotBlank(message = "图片信息不能为空") | ||
| 57 | + private String image; | ||
| 58 | + | ||
| 59 | + /** | ||
| 60 | + * 签到结果 | ||
| 61 | + */ | ||
| 62 | + @Excel(name = "签到结果") | ||
| 63 | + @ApiModelProperty("签到结果 1 成功 2 异常") | ||
| 64 | + private Integer status; | ||
| 65 | + | ||
| 66 | + /** | ||
| 67 | + * 签到类型 | ||
| 68 | + */ | ||
| 69 | + @Excel(name = "签到类型") | ||
| 70 | + @ApiModelProperty("签到类型 1 人脸 2 刷卡 3 其他 4 酒精 用可以多选 用,拼接 如 1,2,3,4") | ||
| 71 | + @NotBlank(message = "签到类型不能为空") | ||
| 72 | + private String singnIn; | ||
| 73 | + | ||
| 74 | + /** | ||
| 75 | + * 酒精测试 | ||
| 76 | + */ | ||
| 77 | + @Excel(name = "酒精测试") | ||
| 78 | + @ApiModelProperty("酒精测试 1 已测试 2 未测试") | ||
| 79 | + @NotNull(message = "酒精测试标识不能为空") | ||
| 80 | + private Integer alcoholFlag; | ||
| 81 | + | ||
| 82 | + /** | ||
| 83 | + * 签到签退 | ||
| 84 | + */ | ||
| 85 | + @Excel(name = "签到签退") | ||
| 86 | + @ApiModelProperty("签到签退 1 签到成功 2 签退成功") | ||
| 87 | + @NotNull(message = "签到类型不能为空") | ||
| 88 | + private Integer type; | ||
| 89 | + | ||
| 90 | + /** | ||
| 91 | + * 酒精摄入量 | ||
| 92 | + */ | ||
| 93 | + @Excel(name = "酒精摄入量") | ||
| 94 | + @ApiModelProperty("酒精摄入量 52.12") | ||
| 95 | + private BigDecimal alcoholIntake; | ||
| 96 | + @Excel(name = "异常类型", readConverterExp = "0=无异常,1=超时异常,2=无排班异常,3=酒精超标异常,200=早签,300=迟到") | ||
| 97 | + @ApiModelProperty("异常类型") | ||
| 98 | + private Integer exType; | ||
| 99 | + | ||
| 100 | + | ||
| 101 | + /** | ||
| 102 | + * 创建时间 | ||
| 103 | + */ | ||
| 104 | + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | ||
| 105 | + private Date createTime; | ||
| 106 | + | ||
| 107 | + /** | ||
| 108 | + * 更新者 | ||
| 109 | + */ | ||
| 110 | + private String updateBy; | ||
| 111 | + | ||
| 112 | + /** | ||
| 113 | + * 更新时间 | ||
| 114 | + */ | ||
| 115 | + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | ||
| 116 | + private Date updateTime; | ||
| 117 | + | ||
| 118 | + /** | ||
| 119 | + * 备注 | ||
| 120 | + */ | ||
| 121 | + private String remark; | ||
| 122 | + | ||
| 123 | + @TableField(exist = false) | ||
| 124 | + private String name; | ||
| 125 | + @TableField(exist = false) | ||
| 126 | + private String posts; | ||
| 127 | + @TableField(exist = false) | ||
| 128 | + private String siteName; | ||
| 129 | + @TableField(exist = false) | ||
| 130 | + private String address; | ||
| 131 | + | ||
| 132 | + @Override | ||
| 133 | + public String toString() { | ||
| 134 | + return JSON.toJSONString(this); | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | +} |
Bsth-admin/src/main/java/com/ruoyi/service/BigViewServiceV1.java
0 → 100644
| 1 | +package com.ruoyi.service; | ||
| 2 | + | ||
| 3 | +import com.ruoyi.common.core.domain.AjaxResult; | ||
| 4 | +import com.ruoyi.domain.DriverScheduling; | ||
| 5 | +import com.ruoyi.driver.domain.Driver; | ||
| 6 | +import com.ruoyi.in.domain.SignIn; | ||
| 7 | +import com.ruoyi.pojo.vo.bigViewVo.FleetState; | ||
| 8 | +import com.ruoyi.pojo.vo.bigViewVo.LineInfo; | ||
| 9 | + | ||
| 10 | +import java.util.Date; | ||
| 11 | + | ||
| 12 | +public interface BigViewServiceV1 { | ||
| 13 | + | ||
| 14 | + void asyncRefreshRedisValue(SignIn signIn, Driver driver, DriverScheduling driverScheduling,String dateStr) throws InterruptedException; | ||
| 15 | + | ||
| 16 | + AjaxResult queryBigViewQueryLineInfo(Date date); | ||
| 17 | + | ||
| 18 | + LineInfo.PersonInfoVo refreshRedisDriver(SignIn signIn, Driver driver); | ||
| 19 | + | ||
| 20 | + FleetState refreshRedisLine(SignIn signIn, DriverScheduling driverScheduling) throws InterruptedException; | ||
| 21 | + | ||
| 22 | + /*** | ||
| 23 | + * 判断酒测次数 | ||
| 24 | + * @author liujun | ||
| 25 | + * @date 2024/9/25 14:54 | ||
| 26 | + * | ||
| 27 | + * @param signIn | ||
| 28 | + * @return com.ruoyi.common.core.domain.AjaxResult | ||
| 29 | + */ | ||
| 30 | + AjaxResult getAjaxResultByDriverSignInfo(SignIn signIn); | ||
| 31 | + | ||
| 32 | + /*** | ||
| 33 | + * 是否是早签 | ||
| 34 | + * @author liujun | ||
| 35 | + * @date 2024/9/25 14:51 | ||
| 36 | + * | ||
| 37 | + * @param signIn | ||
| 38 | + * @return boolean | ||
| 39 | + */ | ||
| 40 | + boolean isEarly(SignIn signIn); | ||
| 41 | + | ||
| 42 | + /*** | ||
| 43 | + * 是否是酒驾 | ||
| 44 | + * @author liujun | ||
| 45 | + * @date 2024/9/25 14:33 | ||
| 46 | + * | ||
| 47 | + * @param signIn | ||
| 48 | + * @return boolean | ||
| 49 | + */ | ||
| 50 | + boolean isSignStatusWineEnum(SignIn signIn); | ||
| 51 | + | ||
| 52 | + | ||
| 53 | + /*** | ||
| 54 | + * 迟到 | ||
| 55 | + * @author liujun | ||
| 56 | + * @date 2024/9/25 14:35 | ||
| 57 | + * | ||
| 58 | + * @param signIn | ||
| 59 | + * @return boolean | ||
| 60 | + */ | ||
| 61 | + boolean isSignStatusDelayEnum(SignIn signIn); | ||
| 62 | + | ||
| 63 | + /*** | ||
| 64 | + * 酒测是否正常 | ||
| 65 | + * @author liujun | ||
| 66 | + * @date 2024/9/25 15:15 | ||
| 67 | + * | ||
| 68 | + * @param signIn | ||
| 69 | + * @return boolean | ||
| 70 | + */ | ||
| 71 | + boolean isSignStatusZoneEnum(SignIn signIn); | ||
| 72 | +} |
Bsth-admin/src/main/java/com/ruoyi/service/impl/BigViewServiceV1Impl.java
0 → 100644
| 1 | +package com.ruoyi.service.impl; | ||
| 2 | + | ||
| 3 | +import com.alibaba.fastjson2.JSON; | ||
| 4 | +import com.ruoyi.common.SignStatusEnum; | ||
| 5 | +import com.ruoyi.common.core.domain.AjaxResult; | ||
| 6 | +import com.ruoyi.common.core.redis.RedisCache; | ||
| 7 | +import com.ruoyi.domain.DriverScheduling; | ||
| 8 | +import com.ruoyi.driver.domain.Driver; | ||
| 9 | +import com.ruoyi.in.domain.SignIn; | ||
| 10 | +import com.ruoyi.in.domain.SignInV1; | ||
| 11 | +import com.ruoyi.pojo.vo.bigViewVo.FleetInfoVo; | ||
| 12 | +import com.ruoyi.pojo.vo.bigViewVo.FleetState; | ||
| 13 | +import com.ruoyi.pojo.vo.bigViewVo.LineInfo; | ||
| 14 | +import com.ruoyi.service.BigViewServiceV1; | ||
| 15 | +import com.ruoyi.template.domain.FleetLineTemplate; | ||
| 16 | +import com.ruoyi.template.service.IFleetLineTemplateService; | ||
| 17 | +import com.ruoyi.utils.ConstDateUtil; | ||
| 18 | +import lombok.extern.slf4j.Slf4j; | ||
| 19 | +import org.apache.commons.collections4.CollectionUtils; | ||
| 20 | +import org.apache.commons.lang3.StringUtils; | ||
| 21 | +import org.springframework.beans.BeanUtils; | ||
| 22 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 23 | +import org.springframework.scheduling.annotation.EnableAsync; | ||
| 24 | +import org.springframework.stereotype.Service; | ||
| 25 | + | ||
| 26 | +import java.text.MessageFormat; | ||
| 27 | +import java.util.*; | ||
| 28 | +import java.util.concurrent.TimeUnit; | ||
| 29 | +import java.util.stream.Collectors; | ||
| 30 | + | ||
| 31 | +import static com.ruoyi.common.ConstSignInConstSignInProperties.SIGN_IN_ERROR_COUNT; | ||
| 32 | +import static com.ruoyi.common.ErrorTypeProperties.SIGN_IN_ERROR; | ||
| 33 | +import static com.ruoyi.common.redispre.GlobalRedisPreName.REDIS_SIGN_IN_DRIVER_ALCOHOL_OVERFLOW; | ||
| 34 | + | ||
| 35 | +/** | ||
| 36 | + * @author liujun | ||
| 37 | + * @date 2024年09月25日 14:38 | ||
| 38 | + */ | ||
| 39 | +@Slf4j | ||
| 40 | +@Service | ||
| 41 | +@EnableAsync | ||
| 42 | +public class BigViewServiceV1Impl implements BigViewServiceV1 { | ||
| 43 | + @Autowired | ||
| 44 | + private IFleetLineTemplateService fleetLineTemplateService; | ||
| 45 | + @Autowired | ||
| 46 | + private RedisCache redisCache; | ||
| 47 | + | ||
| 48 | + private static final String DRIVER_SIGN_KEY = "sign:driver:{0}:{1}"; | ||
| 49 | + | ||
| 50 | + private static final String LINE_SIGN_KEY = "sign:line:{0}:{1}"; | ||
| 51 | + | ||
| 52 | + private static final String LOCK_LINE_SIGN_KEY = "sign:lock:{0}:{1}"; | ||
| 53 | + | ||
| 54 | + private static final String SIGN_REPORT_LIST = "sign:report:list:{0}"; | ||
| 55 | + | ||
| 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 | + | ||
| 60 | + refreshRedisDriver(signIn, driver); | ||
| 61 | + refreshRedisLine(signIn, driverScheduling); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + @Override | ||
| 65 | + public AjaxResult queryBigViewQueryLineInfo(Date date) { | ||
| 66 | + return null; | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + | ||
| 70 | + @Override | ||
| 71 | + public LineInfo.PersonInfoVo refreshRedisDriver(SignIn signIn, Driver driver) { | ||
| 72 | + LineInfo.PersonInfoVo personInfoVo = new LineInfo.PersonInfoVo(); | ||
| 73 | + personInfoVo.setName(driver.getPersonnelName()); | ||
| 74 | + | ||
| 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()); | ||
| 83 | + | ||
| 84 | + String dateStr = ConstDateUtil.formatDate(signIn.getCreateTime()); | ||
| 85 | + | ||
| 86 | + String key = MessageFormat.format(DRIVER_SIGN_KEY, dateStr, driver.getJobCode()); | ||
| 87 | + redisCache.setCacheObject(key, JSON.toJSONString(personInfoVo), 25, TimeUnit.HOURS); | ||
| 88 | + | ||
| 89 | + return personInfoVo; | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + | ||
| 93 | + @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); | ||
| 98 | + | ||
| 99 | + FleetState fleetState = new FleetState(); | ||
| 100 | + fleetState.setLineName(driverScheduling.getLineName()); | ||
| 101 | + | ||
| 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 | + } | ||
| 109 | + | ||
| 110 | + if (Objects.isNull(source) || Objects.isNull(source.getState()) || (fleetState.getState() > source.getState())) { | ||
| 111 | + boolean flag = true; | ||
| 112 | + String lockKey = MessageFormat.format(LOCK_LINE_SIGN_KEY, dateStr, driverScheduling.getLineName()); | ||
| 113 | + for (int i = 0; i < 10000; i++) { | ||
| 114 | + if (redisCache.setNx(lockKey, fleetState, 10L, TimeUnit.SECONDS)) { | ||
| 115 | + try { | ||
| 116 | + redisCache.setCacheObject(key, JSON.toJSONString(fleetState), 25, TimeUnit.HOURS); | ||
| 117 | + } finally { | ||
| 118 | + redisCache.deleteObject(lockKey); | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + flag = false; | ||
| 122 | + break; | ||
| 123 | + } | ||
| 124 | + log.info("redis的[{}]锁已经被占用,1秒钟后再试", key); | ||
| 125 | + Thread.sleep(1000); | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + if (flag) { | ||
| 129 | + log.warn("redis的[{}]数据没有刷新成功[{}]", key, fleetState); | ||
| 130 | + } | ||
| 131 | + } | ||
| 132 | + return fleetState; | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | + @Override | ||
| 136 | + public AjaxResult getAjaxResultByDriverSignInfo(SignIn signIn) { | ||
| 137 | + String key = StringUtils.join(REDIS_SIGN_IN_DRIVER_ALCOHOL_OVERFLOW, ConstDateUtil.FAST_YYYY_MM_DD.format(new Date()), ":", signIn.getJobCode()); | ||
| 138 | + // 驾驶员酒精测试连续超标两次则提示换人 | ||
| 139 | + Integer count = redisCache.getCacheObject(key); | ||
| 140 | + if (Objects.isNull(count) || count.equals(0)) { | ||
| 141 | + count = 1; | ||
| 142 | + redisCache.setCacheObject(key, count, 1, TimeUnit.DAYS); | ||
| 143 | + } else { | ||
| 144 | + redisCache.setCacheObject(key, ++count, 1, TimeUnit.DAYS); | ||
| 145 | + } | ||
| 146 | + if (SIGN_IN_ERROR_COUNT.compareTo(count) <= 0) { | ||
| 147 | + SignInV1 signInV1 = new SignInV1(); | ||
| 148 | + BeanUtils.copyProperties(signIn, signInV1); | ||
| 149 | + return AjaxResult.success(SIGN_IN_ERROR + ": " + (StringUtils.isEmpty(signIn.getRemark()) ? "" : signIn.getRemark()) + "酒精测试不通过" + count + "次请更换车辆驾驶员。", signIn); | ||
| 150 | + } | ||
| 151 | + return null; | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + | ||
| 155 | + @Override | ||
| 156 | + public boolean isEarly(SignIn signIn) { | ||
| 157 | + return Objects.nonNull(signIn) && signIn.getExType() >= 20 && signIn.getExType() < 30; | ||
| 158 | + } | ||
| 159 | + | ||
| 160 | + | ||
| 161 | + @Override | ||
| 162 | + public boolean isSignStatusWineEnum(SignIn signIn) { | ||
| 163 | + return Objects.equals(3, signIn.getExType()) || Objects.equals(23, signIn.getExType()) || Objects.equals(33, signIn.getExType()); | ||
| 164 | + } | ||
| 165 | + | ||
| 166 | + | ||
| 167 | + @Override | ||
| 168 | + public boolean isSignStatusDelayEnum(SignIn signIn) { | ||
| 169 | + return Objects.nonNull(signIn.getExType()) && signIn.getExType() >= 30 && signIn.getExType() < 40; | ||
| 170 | + } | ||
| 171 | + | ||
| 172 | + @Override | ||
| 173 | + public boolean isSignStatusZoneEnum(SignIn signIn) { | ||
| 174 | + return Objects.equals(0, signIn.getExType()); | ||
| 175 | + } | ||
| 176 | + | ||
| 177 | + private boolean chooseRedisData(String key, SignIn signIn, Driver driver, DriverScheduling driverScheduling) { | ||
| 178 | + try { | ||
| 179 | + String jsonStr = redisCache.getCacheObject(key); | ||
| 180 | + if (StringUtils.isEmpty(jsonStr)) { | ||
| 181 | + log.info("redis中没有当天的数据[{}],[{}],[{}],[{}]", key, signIn, driver, driverScheduling); | ||
| 182 | + return false; | ||
| 183 | + } | ||
| 184 | + | ||
| 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; | ||
| 189 | + } | ||
| 190 | + | ||
| 191 | + | ||
| 192 | + } catch (Exception e) { | ||
| 193 | + log.error("刷新签到数据异常[{}],[{}],[{}],[{}]", key, signIn, driver, driverScheduling, e); | ||
| 194 | + } | ||
| 195 | + return false; | ||
| 196 | + } | ||
| 197 | + | ||
| 198 | + private List<FleetInfoVo> saveFleetLineTemp() { | ||
| 199 | + List<FleetLineTemplate> fleetLineTemplates = fleetLineTemplateService.selectFleetLineTemplateList(); | ||
| 200 | + if (CollectionUtils.isEmpty(fleetLineTemplates)) { | ||
| 201 | + return null; | ||
| 202 | + } | ||
| 203 | + | ||
| 204 | + Map<String, List<FleetLineTemplate>> groupFleetLingTemp = fleetLineTemplates.stream().collect(Collectors.groupingBy(FleetLineTemplate::getFleetName, Collectors.toList())); | ||
| 205 | + | ||
| 206 | + List<FleetInfoVo> fleetInfoVos = new ArrayList<>(); | ||
| 207 | + | ||
| 208 | + groupFleetLingTemp.forEach((key, vals) -> { | ||
| 209 | + FleetInfoVo fleetInfoVo = new FleetInfoVo(); | ||
| 210 | + fleetInfoVo.setTitle(key); | ||
| 211 | + | ||
| 212 | + if (CollectionUtils.isNotEmpty(vals)) { | ||
| 213 | + List<FleetInfoVo.FleetInfo> fleetInfoVoFleetInfos = new ArrayList<>(); | ||
| 214 | + List<FleetState> fleetStates = new ArrayList<>(); | ||
| 215 | + vals.stream().forEach(fl -> { | ||
| 216 | + FleetInfoVo.FleetInfo fleetInfo = new FleetInfoVo.FleetInfo(); | ||
| 217 | + fleetInfo.setLineName(fl.getLineName()); | ||
| 218 | + fleetInfoVoFleetInfos.add(fleetInfo); | ||
| 219 | + | ||
| 220 | + FleetState fleetState = new FleetState(); | ||
| 221 | + fleetState.setLineName(fl.getLineName()); | ||
| 222 | + fleetState.setState(0); | ||
| 223 | + | ||
| 224 | + fleetStates.add(fleetState); | ||
| 225 | + }); | ||
| 226 | + fleetInfoVo.setFleetInfos(fleetInfoVoFleetInfos); | ||
| 227 | + fleetInfoVo.setFleetStates(fleetStates); | ||
| 228 | + } | ||
| 229 | + fleetInfoVos.add(fleetInfoVo); | ||
| 230 | + }); | ||
| 231 | + | ||
| 232 | + return fleetInfoVos; | ||
| 233 | + } | ||
| 234 | +} |
Bsth-admin/src/main/java/com/ruoyi/template/mapper/FleetLineTemplateMapper.java
| 1 | package com.ruoyi.template.mapper; | 1 | package com.ruoyi.template.mapper; |
| 2 | 2 | ||
| 3 | -import java.util.List; | ||
| 4 | - | ||
| 5 | import com.baomidou.mybatisplus.annotation.InterceptorIgnore; | 3 | import com.baomidou.mybatisplus.annotation.InterceptorIgnore; |
| 6 | import com.ruoyi.template.domain.FleetLineTemplate; | 4 | import com.ruoyi.template.domain.FleetLineTemplate; |
| 7 | import org.apache.ibatis.annotations.Delete; | 5 | import org.apache.ibatis.annotations.Delete; |
| 8 | import org.apache.ibatis.annotations.Param; | 6 | import org.apache.ibatis.annotations.Param; |
| 9 | 7 | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 10 | /** | 10 | /** |
| 11 | * 车队与线路对应模板Mapper接口 | 11 | * 车队与线路对应模板Mapper接口 |
| 12 | * | 12 | * |
| @@ -29,7 +29,7 @@ public interface FleetLineTemplateMapper | @@ -29,7 +29,7 @@ public interface FleetLineTemplateMapper | ||
| 29 | * @param fleetLineTemplate 车队与线路对应模板 | 29 | * @param fleetLineTemplate 车队与线路对应模板 |
| 30 | * @return 车队与线路对应模板集合 | 30 | * @return 车队与线路对应模板集合 |
| 31 | */ | 31 | */ |
| 32 | - public List<FleetLineTemplate> selectFleetLineTemplateList(FleetLineTemplate fleetLineTemplate); | 32 | + List<FleetLineTemplate> selectFleetLineTemplateList(FleetLineTemplate fleetLineTemplate); |
| 33 | 33 | ||
| 34 | /** | 34 | /** |
| 35 | * 新增车队与线路对应模板 | 35 | * 新增车队与线路对应模板 |
Bsth-admin/src/main/java/com/ruoyi/template/service/IFleetLineTemplateService.java
| @@ -35,6 +35,7 @@ public interface IFleetLineTemplateService | @@ -35,6 +35,7 @@ public interface IFleetLineTemplateService | ||
| 35 | */ | 35 | */ |
| 36 | List<FleetLineTemplate> selectFleetLineTemplateList(); | 36 | List<FleetLineTemplate> selectFleetLineTemplateList(); |
| 37 | 37 | ||
| 38 | + | ||
| 38 | /** | 39 | /** |
| 39 | * 新增车队与线路对应模板 | 40 | * 新增车队与线路对应模板 |
| 40 | * | 41 | * |
Bsth-admin/src/main/java/com/ruoyi/template/service/impl/FleetLineTemplateServiceImpl.java
| @@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired; | @@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired; | ||
| 14 | import org.springframework.stereotype.Service; | 14 | import org.springframework.stereotype.Service; |
| 15 | 15 | ||
| 16 | import java.util.List; | 16 | import java.util.List; |
| 17 | +import java.util.concurrent.TimeUnit; | ||
| 17 | 18 | ||
| 18 | /** | 19 | /** |
| 19 | * 车队与线路对应模板Service业务层处理 | 20 | * 车队与线路对应模板Service业务层处理 |
| @@ -60,7 +61,7 @@ public class FleetLineTemplateServiceImpl implements IFleetLineTemplateService { | @@ -60,7 +61,7 @@ public class FleetLineTemplateServiceImpl implements IFleetLineTemplateService { | ||
| 60 | if (CollectionUtils.isEmpty(fleetLineTemplates)) { | 61 | if (CollectionUtils.isEmpty(fleetLineTemplates)) { |
| 61 | fleetLineTemplates = selectFleetLineTemplateList(new FleetLineTemplate()); | 62 | fleetLineTemplates = selectFleetLineTemplateList(new FleetLineTemplate()); |
| 62 | if (CollectionUtils.isNotEmpty(fleetLineTemplates)) { | 63 | if (CollectionUtils.isNotEmpty(fleetLineTemplates)) { |
| 63 | - redisCache.setCacheObject(CONFIG_LINE, JSON.toJSONString(fleetLineTemplates)); | 64 | + redisCache.setCacheObject(CONFIG_LINE, JSON.toJSONString(fleetLineTemplates), 25, TimeUnit.HOURS); |
| 64 | } | 65 | } |
| 65 | } | 66 | } |
| 66 | 67 |