Commit 4db44e6f24d2a4f28b4d90c562fd9d5b75eb6e7c
1 parent
3f6190a9
fix: 解决签到非司售工种处理报错空指针异常
Showing
7 changed files
with
42 additions
and
42 deletions
ruoyi-admin/src/main/java/com/ruoyi/common/ConstDriverProperties.java
ruoyi-admin/src/main/java/com/ruoyi/common/global/GlobalDriverInfoCache.java
| ... | ... | @@ -2,10 +2,8 @@ package com.ruoyi.common.global; |
| 2 | 2 | |
| 3 | 3 | import com.ruoyi.in.domain.SignIn; |
| 4 | 4 | import com.ruoyi.pojo.domain.SignInExpand; |
| 5 | -import com.ruoyi.utils.ConstDateUtil; | |
| 6 | 5 | import org.springframework.stereotype.Component; |
| 7 | 6 | |
| 8 | -import java.security.Principal; | |
| 9 | 7 | import java.util.*; |
| 10 | 8 | import java.util.concurrent.ConcurrentHashMap; |
| 11 | 9 | |
| ... | ... | @@ -15,13 +13,9 @@ import java.util.concurrent.ConcurrentHashMap; |
| 15 | 13 | @Component |
| 16 | 14 | public class GlobalDriverInfoCache { |
| 17 | 15 | /** |
| 18 | - * 上午签到汇总 | |
| 16 | + * 签到次数汇总 | |
| 19 | 17 | */ |
| 20 | - private final ConcurrentHashMap<String, List<SignInExpand>> morningUserSignInMap = new ConcurrentHashMap(); | |
| 21 | - /** | |
| 22 | - * 下午签到汇总 | |
| 23 | - */ | |
| 24 | - private final ConcurrentHashMap<String, List<SignInExpand>> afternoonUserSignInMap = new ConcurrentHashMap(); | |
| 18 | + private final ConcurrentHashMap<String, List<SignInExpand>> userCurrentMap = new ConcurrentHashMap<>(); | |
| 25 | 19 | |
| 26 | 20 | /** |
| 27 | 21 | * 驾驶员签到成功 |
| ... | ... | @@ -30,27 +24,19 @@ public class GlobalDriverInfoCache { |
| 30 | 24 | */ |
| 31 | 25 | public void putDriverSignInSuccess(SignIn signIn) { |
| 32 | 26 | ConcurrentHashMap<String, List<SignInExpand>> userCurrentMap = null; |
| 33 | - int hour = Integer.parseInt(ConstDateUtil.formatDate("HH")); | |
| 34 | - if (hour >= 0 && hour < 12) { | |
| 35 | - userCurrentMap = morningUserSignInMap; | |
| 36 | 27 | if (Objects.isNull(userCurrentMap.get(signIn.getJobCode()))) { |
| 37 | 28 | SignInExpand signInExpand = new SignInExpand(); |
| 38 | 29 | signInExpand.setJobCode(signIn.getJobCode()); |
| 39 | - signInExpand.setMorningSignInIds(signInExpand.getMorningSignInIds() + signIn.getId() + ","); | |
| 30 | + signInExpand.setSignCount(signIn.getId() + ","); | |
| 40 | 31 | userCurrentMap.put(signIn.getJobCode(), new ArrayList<>(Arrays.asList(signInExpand))); |
| 41 | 32 | } else { |
| 42 | - userCurrentMap.get(signIn.getJobCode()).add(null); | |
| 33 | + SignInExpand signInExpand = new SignInExpand(); | |
| 34 | + signInExpand.setJobCode(signIn.getJobCode()); | |
| 35 | + signInExpand.setSignCount(signInExpand.getSignCount() + signIn.getId() + ","); | |
| 36 | + userCurrentMap.get(signIn.getJobCode()).add(signInExpand); | |
| 43 | 37 | } |
| 44 | - }else { | |
| 45 | - userCurrentMap = afternoonUserSignInMap; | |
| 46 | 38 | } |
| 47 | - /** | |
| 48 | - * 存在判断 上下午只保留一条作为正式的签到结果 | |
| 49 | - * 上午签到 -》 成功 | 下午签到 -》异常,成功 | |
| 50 | - * 上午签到 -》 异常,异常 | 下午签到 -》 成功 | |
| 51 | - */ | |
| 52 | 39 | |
| 53 | 40 | } |
| 54 | 41 | |
| 55 | 42 | |
| 56 | -} | ... | ... |
ruoyi-admin/src/main/java/com/ruoyi/common/redispre/GlobalRedisPreName.java
| ... | ... | @@ -5,7 +5,10 @@ package com.ruoyi.common.redispre; |
| 5 | 5 | */ |
| 6 | 6 | public interface GlobalRedisPreName { |
| 7 | 7 | String DRIVER_SCHEDULING_PRE = "driver:scheduling:"; |
| 8 | - String REDIS_SIGN_IN = "sign:in:"; | |
| 8 | + /** | |
| 9 | + * 存储驾驶员酒精测试异常 | |
| 10 | + */ | |
| 11 | + String REDIS_SIGN_IN_DRIVER_ALCOHOL_OVERFLOW = "sign:in:driver"; | |
| 9 | 12 | /** |
| 10 | 13 | * 请求人事系统token |
| 11 | 14 | */ | ... | ... |
ruoyi-admin/src/main/java/com/ruoyi/in/service/impl/SignInServiceImpl.java
| ... | ... | @@ -15,7 +15,6 @@ import com.ruoyi.common.constant.Constants; |
| 15 | 15 | import com.ruoyi.common.core.domain.AjaxResult; |
| 16 | 16 | import com.ruoyi.common.core.redis.RedisCache; |
| 17 | 17 | import com.ruoyi.common.utils.DateUtils; |
| 18 | -import com.ruoyi.common.ConstSignInConstSignInProperties; | |
| 19 | 18 | import com.ruoyi.common.utils.StringUtils; |
| 20 | 19 | import com.ruoyi.common.utils.ip.IpUtils; |
| 21 | 20 | import com.ruoyi.common.utils.uuid.Seq; |
| ... | ... | @@ -29,6 +28,8 @@ import com.ruoyi.pojo.response.SignInResponseVo; |
| 29 | 28 | import com.ruoyi.service.ThreadJobService; |
| 30 | 29 | import com.ruoyi.utils.ConstDateUtil; |
| 31 | 30 | import org.apache.commons.io.FilenameUtils; |
| 31 | +import org.slf4j.Logger; | |
| 32 | +import org.slf4j.LoggerFactory; | |
| 32 | 33 | import org.springframework.beans.factory.annotation.Autowired; |
| 33 | 34 | import org.springframework.stereotype.Service; |
| 34 | 35 | import com.ruoyi.in.mapper.SignInMapper; |
| ... | ... | @@ -37,11 +38,11 @@ import com.ruoyi.in.service.ISignInService; |
| 37 | 38 | |
| 38 | 39 | import javax.annotation.Resource; |
| 39 | 40 | |
| 40 | -import static com.ruoyi.common.ConstDriverProperties.PERSONNEL_TYPE_DRIVER; | |
| 41 | +import static com.ruoyi.common.ConstDriverProperties.PERSONNEL_POSTS_DRIVER; | |
| 41 | 42 | import static com.ruoyi.common.ErrorTypeProperties.*; |
| 42 | 43 | import static com.ruoyi.common.ConstSignInConstSignInProperties.*; |
| 43 | 44 | import static com.ruoyi.common.redispre.GlobalRedisPreName.DRIVER_SCHEDULING_PRE; |
| 44 | -import static com.ruoyi.common.redispre.GlobalRedisPreName.REDIS_SIGN_IN; | |
| 45 | +import static com.ruoyi.common.redispre.GlobalRedisPreName.REDIS_SIGN_IN_DRIVER_ALCOHOL_OVERFLOW; | |
| 45 | 46 | |
| 46 | 47 | /** |
| 47 | 48 | * 签到Service业务层处理 |
| ... | ... | @@ -51,6 +52,8 @@ import static com.ruoyi.common.redispre.GlobalRedisPreName.REDIS_SIGN_IN; |
| 51 | 52 | */ |
| 52 | 53 | @Service |
| 53 | 54 | public class SignInServiceImpl implements ISignInService { |
| 55 | + | |
| 56 | + private Logger log = LoggerFactory.getLogger(SignInServiceImpl.class); | |
| 54 | 57 | @Autowired |
| 55 | 58 | private SignInMapper signInMapper; |
| 56 | 59 | |
| ... | ... | @@ -98,6 +101,7 @@ public class SignInServiceImpl implements ISignInService { |
| 98 | 101 | public AjaxResult insertSignIn(SignIn signIn) { |
| 99 | 102 | // 查询员工信息 |
| 100 | 103 | Driver driver = driverMapper.getDriverInfoByJobCode(signIn.getJobCode()); |
| 104 | + if (Objects.isNull(driver)) return AjaxResult.error("这个工号的员工不存在!"); | |
| 101 | 105 | // 查询地址 |
| 102 | 106 | Equipment equipment = equipmentMapper.selectEquipmentByDeviceId(signIn.getDeviceId()); |
| 103 | 107 | SignInResponseVo vo = getSignInResponseVo(signIn, equipment); |
| ... | ... | @@ -109,14 +113,14 @@ public class SignInServiceImpl implements ISignInService { |
| 109 | 113 | } else { |
| 110 | 114 | signIn.setStatus(SIGN_IN_FAIL); |
| 111 | 115 | } |
| 112 | - // base64转图片 | |
| 113 | 116 | signIn.setIp(IpUtils.getIpAddr()); |
| 117 | + // base64转图片 | |
| 114 | 118 | // uploadImage(signIn); |
| 115 | 119 | signInMapper.insertSignIn(signIn); |
| 116 | 120 | // TODO redis 存储每个人的签到 用于后续考勤 |
| 117 | 121 | |
| 118 | 122 | // 驾驶人员二次签到酒精测试异常 |
| 119 | - if (PERSONNEL_TYPE_DRIVER.equals(driver.getPosts()) && SIGN_IN_FAIL.equals(signIn.getStatus()) && signIn.getRemark().contains(ALCOHOL_SIGN_IN_ERROR)) { | |
| 123 | + if (PERSONNEL_POSTS_DRIVER.equals(driver.getPosts()) && SIGN_IN_FAIL.equals(signIn.getStatus()) && signIn.getRemark().contains(ALCOHOL_SIGN_IN_ERROR)) { | |
| 120 | 124 | AjaxResult result = getAjaxResultByDriverSignInfo(signIn, vo); |
| 121 | 125 | if (!Objects.isNull(result)) { |
| 122 | 126 | return result; |
| ... | ... | @@ -164,6 +168,7 @@ public class SignInServiceImpl implements ISignInService { |
| 164 | 168 | public AjaxResult addSignIn(SignIn signIn) throws IOException { |
| 165 | 169 | // 查询员工信息 |
| 166 | 170 | Driver driver = driverMapper.getDriverInfoByJobCode(signIn.getJobCode()); |
| 171 | + if (Objects.isNull(driver)) return AjaxResult.error("这个工号的员工不存在!"); | |
| 167 | 172 | // 查询地址 |
| 168 | 173 | Equipment equipment = equipmentMapper.selectEquipmentByDeviceId(signIn.getDeviceId()); |
| 169 | 174 | SignInResponseVo vo = getSignInResponseVo(signIn, equipment); |
| ... | ... | @@ -177,18 +182,18 @@ public class SignInServiceImpl implements ISignInService { |
| 177 | 182 | } |
| 178 | 183 | // base64转图片 |
| 179 | 184 | signIn.setIp(IpUtils.getIpAddr()); |
| 185 | + | |
| 180 | 186 | uploadImage(signIn); |
| 181 | 187 | signInMapper.insertSignIn(signIn); |
| 182 | 188 | // TODO redis 存储每个人的签到 用于后续考勤 |
| 183 | 189 | |
| 184 | 190 | // 驾驶人员二次签到酒精测试异常 |
| 185 | - if (PERSONNEL_TYPE_DRIVER.equals(driver.getPosts()) && SIGN_IN_FAIL.equals(signIn.getStatus()) && signIn.getRemark().contains(ALCOHOL_SIGN_IN_ERROR)) { | |
| 191 | + if (PERSONNEL_POSTS_DRIVER.equals(driver.getPosts()) && SIGN_IN_FAIL.equals(signIn.getStatus()) && signIn.getRemark().contains(ALCOHOL_SIGN_IN_ERROR)) { | |
| 186 | 192 | AjaxResult result = getAjaxResultByDriverSignInfo(signIn, vo); |
| 187 | 193 | if (!Objects.isNull(result)) { |
| 188 | 194 | return result; |
| 189 | 195 | } |
| 190 | 196 | } |
| 191 | - | |
| 192 | 197 | return SIGN_IN_SUCCESS.equals(signIn.getStatus()) ? AjaxResult.success(SIGN_IN_SUCCESS_STRING, vo) : AjaxResult.error(SIGN_IN_ERROR + signIn.getRemark(), vo); |
| 193 | 198 | } |
| 194 | 199 | |
| ... | ... | @@ -203,7 +208,7 @@ public class SignInServiceImpl implements ISignInService { |
| 203 | 208 | } |
| 204 | 209 | |
| 205 | 210 | private AjaxResult getAjaxResultByDriverSignInfo(SignIn signIn, SignInResponseVo vo) { |
| 206 | - String key = REDIS_SIGN_IN + ConstDateUtil.formatDate("yyyyMMdd"); | |
| 211 | + String key = REDIS_SIGN_IN_DRIVER_ALCOHOL_OVERFLOW + ConstDateUtil.formatDate("yyyyMMdd"); | |
| 207 | 212 | // 驾驶员酒精测试连续超标两次则提示换人 |
| 208 | 213 | Integer count = redisCache.getCacheMapValue(key, signIn.getJobCode()); |
| 209 | 214 | if (Objects.isNull(count) || count.equals(0)) { |
| ... | ... | @@ -228,7 +233,7 @@ public class SignInServiceImpl implements ISignInService { |
| 228 | 233 | result = checkWorkDay(signIn, driver.getPosts()); |
| 229 | 234 | |
| 230 | 235 | // 酒精测试校验 确定 且员工工种是驾驶员 |
| 231 | - if (ALCOHOL_FLAG_YES.equals(signIn.getAlcoholFlag()) && PERSONNEL_TYPE_DRIVER.equals(driver.getPosts())) { | |
| 236 | + if (ALCOHOL_FLAG_YES.equals(signIn.getAlcoholFlag()) && PERSONNEL_POSTS_DRIVER.equals(driver.getPosts())) { | |
| 232 | 237 | if (new BigDecimal(20).compareTo(signIn.getAlcoholIntake()) > 0) { |
| 233 | 238 | result = true; |
| 234 | 239 | } else { |
| ... | ... | @@ -269,13 +274,21 @@ public class SignInServiceImpl implements ISignInService { |
| 269 | 274 | // 超时校验司售人员 |
| 270 | 275 | if (result) { |
| 271 | 276 | // TODO 非司售人员 |
| 272 | - result = checkTimeOut(signIn, jobs); | |
| 277 | + result = checkTimeOut(signIn, jobs, posts); | |
| 273 | 278 | } |
| 274 | 279 | return result; |
| 275 | 280 | } |
| 276 | 281 | |
| 277 | - private boolean checkTimeOut(SignIn signIn, List<ResponseScheduling> driver) { | |
| 282 | + private boolean checkTimeOut(SignIn signIn, List<ResponseScheduling> driver, String posts) { | |
| 278 | 283 | // 那发车时间和到站时间作为开始上班的时间 |
| 284 | + if (PERSONNEL_POSTS_DRIVER.equals(posts)) { | |
| 285 | + return driverCheckTimeOut(signIn, driver); | |
| 286 | + } else { | |
| 287 | + return true; | |
| 288 | + } | |
| 289 | + } | |
| 290 | + | |
| 291 | + private static boolean driverCheckTimeOut(SignIn signIn, List<ResponseScheduling> driver) { | |
| 279 | 292 | LocalDateTime startTime = ConstDateUtil.getLocalDateTimeByLongTime(driver.get(0).getFcsjT()); |
| 280 | 293 | LocalDateTime endTime = ConstDateUtil.getLocalDateTimeByLongTime(driver.get(driver.size() - 1).getZdsjT()); |
| 281 | 294 | LocalDateTime signTime = ConstDateUtil.getLocalDateTimeByLongTime(signIn.getCreateTime().getTime()); | ... | ... |
ruoyi-admin/src/main/java/com/ruoyi/pojo/domain/SignInExpand.java
| ... | ... | @@ -14,13 +14,9 @@ public class SignInExpand { |
| 14 | 14 | private Integer id; |
| 15 | 15 | private String jobCode; |
| 16 | 16 | /** |
| 17 | - * 上午签到集合 1,2 | |
| 17 | + * 签到集合 1,2 | |
| 18 | 18 | */ |
| 19 | - private String morningSignInIds; | |
| 20 | - /** | |
| 21 | - * 下午签到集合 1,2 | |
| 22 | - */ | |
| 23 | - private String afternoonSignInIds; | |
| 19 | + private String signCount; | |
| 24 | 20 | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| 25 | 21 | private Date dated; |
| 26 | 22 | } | ... | ... |
ruoyi-admin/src/main/java/com/ruoyi/service/ThreadJobService.java
ruoyi-admin/src/main/java/com/ruoyi/upgrade/controller/VersionUpgradeController.java
| ... | ... | @@ -3,7 +3,6 @@ package com.ruoyi.upgrade.controller; |
| 3 | 3 | import java.util.List; |
| 4 | 4 | import javax.servlet.http.HttpServletResponse; |
| 5 | 5 | |
| 6 | -import io.swagger.annotations.ApiOperation; | |
| 7 | 6 | import org.springframework.security.access.prepost.PreAuthorize; |
| 8 | 7 | import org.springframework.beans.factory.annotation.Autowired; |
| 9 | 8 | import org.springframework.web.bind.annotation.GetMapping; |
| ... | ... | @@ -54,7 +53,6 @@ public class VersionUpgradeController extends BaseController |
| 54 | 53 | @PreAuthorize("@ss.hasPermi('upgrade:upgrade:export')") |
| 55 | 54 | @Log(title = "upgrade", businessType = BusinessType.EXPORT) |
| 56 | 55 | @PostMapping("/export") |
| 57 | - @ApiOperation("") | |
| 58 | 56 | public void export(HttpServletResponse response, VersionUpgrade versionUpgrade) |
| 59 | 57 | { |
| 60 | 58 | List<VersionUpgrade> list = versionUpgradeService.selectVersionUpgradeList(versionUpgrade); | ... | ... |