Commit ade1de372eb912dac27ddddc3f0dafa6f62d6ddf
1 parent
dd0dee29
fix: 修改签到逻辑,修复接口注解错误
Showing
7 changed files
with
54 additions
and
18 deletions
ruoyi-admin/src/main/java/com/ruoyi/redispre/GlobalRedisPreName.java renamed to ruoyi-admin/src/main/java/com/ruoyi/common/redispre/GlobalRedisPreName.java
| 1 | -package com.ruoyi.redispre; | 1 | +package com.ruoyi.common.redispre; |
| 2 | 2 | ||
| 3 | /** | 3 | /** |
| 4 | * @author 20412 | 4 | * @author 20412 |
| 5 | */ | 5 | */ |
| 6 | public interface GlobalRedisPreName { | 6 | public interface GlobalRedisPreName { |
| 7 | String DRIVER_SCHEDULING_PRE = "driver:scheduling:"; | 7 | String DRIVER_SCHEDULING_PRE = "driver:scheduling:"; |
| 8 | + String REDIS_SIGN_IN = "sign:in:"; | ||
| 8 | } | 9 | } |
ruoyi-admin/src/main/java/com/ruoyi/driver/controller/DriverController.java
| @@ -168,7 +168,7 @@ public class DriverController extends BaseController { | @@ -168,7 +168,7 @@ public class DriverController extends BaseController { | ||
| 168 | /** | 168 | /** |
| 169 | * 头像下载 根据 工号 | 169 | * 头像下载 根据 工号 |
| 170 | */ | 170 | */ |
| 171 | - @ApiModelProperty("头像下载") | 171 | + @ApiOperation("头像下载") |
| 172 | @GetMapping("/download/{jobCode}") | 172 | @GetMapping("/download/{jobCode}") |
| 173 | public void downLoadHeadImage(@PathVariable("jobCode") String jobCode, HttpServletResponse response) { | 173 | public void downLoadHeadImage(@PathVariable("jobCode") String jobCode, HttpServletResponse response) { |
| 174 | driverService.downloadHeadImage(jobCode, response); | 174 | driverService.downloadHeadImage(jobCode, response); |
ruoyi-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; | 3 | import java.io.File; |
| 4 | -import java.io.FileInputStream; | ||
| 5 | import java.io.IOException; | 4 | import java.io.IOException; |
| 6 | import java.nio.file.Paths; | 5 | import java.nio.file.Paths; |
| 7 | import java.util.*; | 6 | import java.util.*; |
| @@ -10,7 +9,6 @@ import com.ruoyi.common.config.RuoYiConfig; | @@ -10,7 +9,6 @@ import com.ruoyi.common.config.RuoYiConfig; | ||
| 10 | import com.ruoyi.common.core.domain.AjaxResult; | 9 | import com.ruoyi.common.core.domain.AjaxResult; |
| 11 | import com.ruoyi.common.core.redis.RedisCache; | 10 | import com.ruoyi.common.core.redis.RedisCache; |
| 12 | import com.ruoyi.common.exception.file.InvalidExtensionException; | 11 | import com.ruoyi.common.exception.file.InvalidExtensionException; |
| 13 | -import com.ruoyi.common.utils.SecurityUtils; | ||
| 14 | import com.ruoyi.common.utils.file.FileUploadUtils; | 12 | import com.ruoyi.common.utils.file.FileUploadUtils; |
| 15 | import com.ruoyi.common.utils.file.FileUtils; | 13 | import com.ruoyi.common.utils.file.FileUtils; |
| 16 | import com.ruoyi.common.utils.file.MimeTypeUtils; | 14 | import com.ruoyi.common.utils.file.MimeTypeUtils; |
| @@ -31,7 +29,7 @@ import org.springframework.web.multipart.MultipartFile; | @@ -31,7 +29,7 @@ import org.springframework.web.multipart.MultipartFile; | ||
| 31 | import javax.servlet.ServletOutputStream; | 29 | import javax.servlet.ServletOutputStream; |
| 32 | import javax.servlet.http.HttpServletResponse; | 30 | import javax.servlet.http.HttpServletResponse; |
| 33 | 31 | ||
| 34 | -import static com.ruoyi.redispre.GlobalRedisPreName.DRIVER_SCHEDULING_PRE; | 32 | +import static com.ruoyi.common.redispre.GlobalRedisPreName.DRIVER_SCHEDULING_PRE; |
| 35 | 33 | ||
| 36 | /** | 34 | /** |
| 37 | * 驾驶员信息Service业务层处理 | 35 | * 驾驶员信息Service业务层处理 |
ruoyi-admin/src/main/java/com/ruoyi/in/service/impl/SignInServiceImpl.java
| @@ -3,6 +3,8 @@ package com.ruoyi.in.service.impl; | @@ -3,6 +3,8 @@ package com.ruoyi.in.service.impl; | ||
| 3 | import java.io.File; | 3 | import java.io.File; |
| 4 | import java.io.IOException; | 4 | import java.io.IOException; |
| 5 | import java.math.BigDecimal; | 5 | import java.math.BigDecimal; |
| 6 | +import java.time.LocalDateTime; | ||
| 7 | +import java.time.temporal.ChronoUnit; | ||
| 6 | import java.util.Base64; | 8 | import java.util.Base64; |
| 7 | import java.util.Date; | 9 | import java.util.Date; |
| 8 | import java.util.List; | 10 | import java.util.List; |
| @@ -33,6 +35,7 @@ import javax.annotation.Resource; | @@ -33,6 +35,7 @@ import javax.annotation.Resource; | ||
| 33 | 35 | ||
| 34 | import static com.ruoyi.common.ErrorTypeProperties.*; | 36 | import static com.ruoyi.common.ErrorTypeProperties.*; |
| 35 | import static com.ruoyi.common.SignInEnum.*; | 37 | import static com.ruoyi.common.SignInEnum.*; |
| 38 | +import static com.ruoyi.common.redispre.GlobalRedisPreName.REDIS_SIGN_IN; | ||
| 36 | 39 | ||
| 37 | /** | 40 | /** |
| 38 | * 签到Service业务层处理 | 41 | * 签到Service业务层处理 |
| @@ -129,10 +132,6 @@ public class SignInServiceImpl implements ISignInService { | @@ -129,10 +132,6 @@ public class SignInServiceImpl implements ISignInService { | ||
| 129 | 132 | ||
| 130 | @Override | 133 | @Override |
| 131 | public AjaxResult addSignIn(SignIn signIn) throws IOException { | 134 | public AjaxResult addSignIn(SignIn signIn) throws IOException { |
| 132 | - String resultMsg = "签到成功"; | ||
| 133 | - if (!StringUtils.isNotEmpty(signIn.getDeviceId())){ | ||
| 134 | - throw new RuntimeException("设备号不能为空"); | ||
| 135 | - } | ||
| 136 | // 签到检查 | 135 | // 签到检查 |
| 137 | checkSignIn(signIn); | 136 | checkSignIn(signIn); |
| 138 | // base64转图片 | 137 | // base64转图片 |
| @@ -140,6 +139,19 @@ public class SignInServiceImpl implements ISignInService { | @@ -140,6 +139,19 @@ public class SignInServiceImpl implements ISignInService { | ||
| 140 | signIn.setIp(IpUtils.getIpAddr()); | 139 | signIn.setIp(IpUtils.getIpAddr()); |
| 141 | uploadImage(signIn); | 140 | uploadImage(signIn); |
| 142 | signInMapper.insertSignIn(signIn); | 141 | signInMapper.insertSignIn(signIn); |
| 142 | + // TODO 驾驶人员二次签到酒精测试异常 | ||
| 143 | + if (true){ | ||
| 144 | + Integer count = redisCache.getCacheMapValue(ConstDateUtil.formatDate("yyyyMMdd") + REDIS_SIGN_IN, signIn.getJobCode()); | ||
| 145 | + if (Objects.isNull(count)){ | ||
| 146 | + redisCache.setCacheMapValue(ConstDateUtil.formatDate("yyyyMMdd") + REDIS_SIGN_IN, signIn.getJobCode(),0); | ||
| 147 | + } | ||
| 148 | + count = redisCache.increment(ConstDateUtil.formatDate("yyyyMMdd") + REDIS_SIGN_IN, signIn.getJobCode(), 1); | ||
| 149 | + if (count.equals(2) || count.compareTo(2) == 1){ | ||
| 150 | + | ||
| 151 | + } | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + | ||
| 143 | return SIGN_IN_SUCCESS.equals(signIn.getStatus()) ? AjaxResult.success(SIGN_IN_SUCCESS_STRING): AjaxResult.error(SIGN_IN_ERROR + signIn.getRemark()); | 155 | return SIGN_IN_SUCCESS.equals(signIn.getStatus()) ? AjaxResult.success(SIGN_IN_SUCCESS_STRING): AjaxResult.error(SIGN_IN_ERROR + signIn.getRemark()); |
| 144 | } | 156 | } |
| 145 | 157 | ||
| @@ -152,9 +164,8 @@ public class SignInServiceImpl implements ISignInService { | @@ -152,9 +164,8 @@ public class SignInServiceImpl implements ISignInService { | ||
| 152 | } | 164 | } |
| 153 | // TODO 排班校验 非司售未作 | 165 | // TODO 排班校验 非司售未作 |
| 154 | checkWorkDay(signIn,driver.getPersonnelType()); | 166 | checkWorkDay(signIn,driver.getPersonnelType()); |
| 155 | - // TODO 超时校验 | ||
| 156 | - checkTimeOut(signIn,driver); | ||
| 157 | - // 酒精测试校验 | 167 | + |
| 168 | + // 酒精测试校验 TODO 判断人员类型 | ||
| 158 | if (ALCOHOL_FLAG_YES.equals(signIn.getAlcoholFlag())){ | 169 | if (ALCOHOL_FLAG_YES.equals(signIn.getAlcoholFlag())){ |
| 159 | signIn.setStatus(signIn.getAlcoholIntake().compareTo(new BigDecimal(20)) < 0 ? SIGN_IN_SUCCESS : SIGN_IN_FAIL); | 170 | signIn.setStatus(signIn.getAlcoholIntake().compareTo(new BigDecimal(20)) < 0 ? SIGN_IN_SUCCESS : SIGN_IN_FAIL); |
| 160 | signIn.setRemark(signIn.getStatus().equals(SIGN_IN_FAIL) ? ALCOHOL_SIGN_IN_ERROR : ""); | 171 | signIn.setRemark(signIn.getStatus().equals(SIGN_IN_FAIL) ? ALCOHOL_SIGN_IN_ERROR : ""); |
| @@ -166,10 +177,11 @@ public class SignInServiceImpl implements ISignInService { | @@ -166,10 +177,11 @@ public class SignInServiceImpl implements ISignInService { | ||
| 166 | } | 177 | } |
| 167 | 178 | ||
| 168 | private void checkWorkDay(SignIn signIn, String personnelType) { | 179 | private void checkWorkDay(SignIn signIn, String personnelType) { |
| 180 | + List<ResponseScheduling> jobs = null; | ||
| 169 | switch (personnelType){ | 181 | switch (personnelType){ |
| 170 | case "0": | 182 | case "0": |
| 171 | // 查询工号对应的排班 司售人员 | 183 | // 查询工号对应的排班 司售人员 |
| 172 | - List<ResponseScheduling> jobs= redisCache.getCacheMapValue(ConstDateUtil.formatDate("yyyyMMdd"),signIn.getJobCode()); | 184 | + jobs = redisCache.getCacheMapValue(ConstDateUtil.formatDate("yyyyMMdd"),signIn.getJobCode()); |
| 173 | if (Objects.isNull(jobs)|| jobs.size() == 0){ | 185 | if (Objects.isNull(jobs)|| jobs.size() == 0){ |
| 174 | signIn.setStatus(SIGN_IN_FAIL); | 186 | signIn.setStatus(SIGN_IN_FAIL); |
| 175 | signIn.setRemark(WORK_DAY_ERROR); | 187 | signIn.setRemark(WORK_DAY_ERROR); |
| @@ -181,11 +193,25 @@ public class SignInServiceImpl implements ISignInService { | @@ -181,11 +193,25 @@ public class SignInServiceImpl implements ISignInService { | ||
| 181 | break; | 193 | break; |
| 182 | } | 194 | } |
| 183 | 195 | ||
| 196 | + // 超时校验司售人员 | ||
| 197 | + checkTimeOut(signIn,jobs); | ||
| 198 | + // TODO 非司售人员 | ||
| 184 | 199 | ||
| 185 | } | 200 | } |
| 186 | 201 | ||
| 187 | - private void checkTimeOut(SignIn signIn, Driver driver) { | ||
| 188 | - // SIGN_IN_TIMEOUT 签到超时 | 202 | + private void checkTimeOut(SignIn signIn, List<ResponseScheduling> driver) { |
| 203 | + // 那发车时间和到站时间作为开始上班的时间 | ||
| 204 | + LocalDateTime startTime = ConstDateUtil.getLocalDateTimeByLongTime(driver.get(0).getFcsjT()); | ||
| 205 | + LocalDateTime endTime = ConstDateUtil.getLocalDateTimeByLongTime(driver.get(0).getZdsjT()); | ||
| 206 | + LocalDateTime signTime = ConstDateUtil.getLocalDateTimeByLongTime(signIn.getCreateTime().getTime()); | ||
| 207 | + long morningBetween = ChronoUnit.MINUTES.between(startTime, signTime); | ||
| 208 | + long afternoonBetween = ChronoUnit.MINUTES.between(endTime, signTime); | ||
| 209 | + if (Math.abs(morningBetween) <= 60 || Math.abs(afternoonBetween) <= 60) { | ||
| 210 | + signIn.setStatus(SIGN_IN_SUCCESS); | ||
| 211 | + } else { | ||
| 212 | + signIn.setStatus(SIGN_IN_FAIL); | ||
| 213 | + signIn.setRemark(SIGN_IN_TIMEOUT); | ||
| 214 | + } | ||
| 189 | 215 | ||
| 190 | } | 216 | } |
| 191 | 217 |
ruoyi-admin/src/main/java/com/ruoyi/job/DriverJob.java
| 1 | package com.ruoyi.job; | 1 | package com.ruoyi.job; |
| 2 | 2 | ||
| 3 | import com.ruoyi.common.core.redis.RedisCache; | 3 | import com.ruoyi.common.core.redis.RedisCache; |
| 4 | -import com.ruoyi.common.utils.DateUtils; | ||
| 5 | import com.ruoyi.driver.domain.Driver; | 4 | import com.ruoyi.driver.domain.Driver; |
| 6 | import com.ruoyi.driver.service.IDriverService; | 5 | import com.ruoyi.driver.service.IDriverService; |
| 7 | import com.ruoyi.pojo.response.ResponseScheduling; | 6 | import com.ruoyi.pojo.response.ResponseScheduling; |
| 8 | import com.ruoyi.utils.ConstDateUtil; | 7 | import com.ruoyi.utils.ConstDateUtil; |
| 9 | import com.ruoyi.utils.ListUtils; | 8 | import com.ruoyi.utils.ListUtils; |
| 10 | -import org.apache.commons.math3.distribution.RealDistribution; | ||
| 11 | import org.springframework.beans.factory.InitializingBean; | 9 | import org.springframework.beans.factory.InitializingBean; |
| 12 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
| 13 | import org.springframework.beans.factory.annotation.Value; | 11 | import org.springframework.beans.factory.annotation.Value; |
| @@ -22,7 +20,7 @@ import java.util.*; | @@ -22,7 +20,7 @@ import java.util.*; | ||
| 22 | import java.util.concurrent.TimeUnit; | 20 | import java.util.concurrent.TimeUnit; |
| 23 | import java.util.stream.Collectors; | 21 | import java.util.stream.Collectors; |
| 24 | 22 | ||
| 25 | -import static com.ruoyi.redispre.GlobalRedisPreName.DRIVER_SCHEDULING_PRE; | 23 | +import static com.ruoyi.common.redispre.GlobalRedisPreName.DRIVER_SCHEDULING_PRE; |
| 26 | 24 | ||
| 27 | /** | 25 | /** |
| 28 | * 该定时任务用户获取驾驶员信息 | 26 | * 该定时任务用户获取驾驶员信息 |
ruoyi-admin/src/main/java/com/ruoyi/utils/ConstDateUtil.java
| 1 | package com.ruoyi.utils; | 1 | package com.ruoyi.utils; |
| 2 | 2 | ||
| 3 | import java.text.SimpleDateFormat; | 3 | import java.text.SimpleDateFormat; |
| 4 | +import java.time.Instant; | ||
| 5 | +import java.time.LocalDateTime; | ||
| 6 | +import java.time.ZoneId; | ||
| 4 | import java.util.Date; | 7 | import java.util.Date; |
| 5 | 8 | ||
| 6 | public class ConstDateUtil { | 9 | public class ConstDateUtil { |
| @@ -8,4 +11,10 @@ public class ConstDateUtil { | @@ -8,4 +11,10 @@ public class ConstDateUtil { | ||
| 8 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat(str); | 11 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat(str); |
| 9 | return simpleDateFormat.format(new Date()); | 12 | return simpleDateFormat.format(new Date()); |
| 10 | } | 13 | } |
| 14 | + | ||
| 15 | + public static LocalDateTime getLocalDateTimeByLongTime(long time){ | ||
| 16 | + Instant instant = Instant.ofEpochMilli(time); | ||
| 17 | + LocalDateTime localDateTime = instant.atZone(ZoneId.systemDefault()).toLocalDateTime(); | ||
| 18 | + return localDateTime; | ||
| 19 | + } | ||
| 11 | } | 20 | } |
ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java
| @@ -263,6 +263,10 @@ public class RedisCache { | @@ -263,6 +263,10 @@ public class RedisCache { | ||
| 263 | return redisTemplate.opsForHash().delete(key, hKey) > 0; | 263 | return redisTemplate.opsForHash().delete(key, hKey) > 0; |
| 264 | } | 264 | } |
| 265 | 265 | ||
| 266 | + public Integer increment(String key, String hkey,Integer value){ | ||
| 267 | + return redisTemplate.opsForHash().increment(key,hkey,value.longValue()).intValue(); | ||
| 268 | + } | ||
| 269 | + | ||
| 266 | /** | 270 | /** |
| 267 | * 获得缓存的基本对象列表 | 271 | * 获得缓存的基本对象列表 |
| 268 | * | 272 | * |