Commit 3f6190a91a2b1d611aa004e36c5bc0345b2dd65a

Authored by guzijian
1 parent 83856b07

fix: 修改签到逻辑

ruoyi-admin/src/main/java/com/ruoyi/common/ConstEquipmentProperties.java 0 → 100644
  1 +package com.ruoyi.common;
  2 +
  3 +/**
  4 + * 设备状态枚举
  5 + * @author 20412
  6 + */
  7 +public interface ConstEquipmentProperties {
  8 + Integer EQUIPMENT_STATUS_HEALTH = 1;
  9 + /**
  10 + * 设备异常
  11 + */
  12 + Integer EQUIPMENT_STATUS_ILLNESS = 2;
  13 + /**
  14 + * 刚提交 未处理
  15 + */
  16 + Integer EQUIPMENT_PROCESS_FLOW_COMMIT = 3;
  17 + /**
  18 + * 处理中
  19 + */
  20 + Integer EQUIPMENT_PROCESS_FLOW_ACTIVE = 3;
  21 + /**
  22 + * 处理王城
  23 + */
  24 + Integer EQUIPMENT_PROCESS_FLOW_COMPLETE = 3;
  25 +}
... ...
ruoyi-admin/src/main/java/com/ruoyi/controller/ApplicationUpdateController.java
... ... @@ -33,10 +33,11 @@ public class ApplicationUpdateController {
33 33 }
34 34  
35 35 /**
36   - * 下载最新apk
  36 + * 下载最新apk 弃用
37 37 */
  38 + @Deprecated
38 39 @PostMapping("/download")
39   - @ApiOperation("下载最新apk")
  40 +// @ApiOperation("下载最新apk")
40 41 public void downloadApk(String apkUrl, HttpServletResponse response) {
41 42 try {
42 43 appService.downloadApk(apkUrl, response);
... ...
ruoyi-admin/src/main/java/com/ruoyi/driver/controller/DriverController.java
... ... @@ -79,7 +79,7 @@ public class DriverController extends BaseController {
79 79 * 导出驾驶员信息列表
80 80 */
81 81 // @PreAuthorize("@ss.hasPermi('driver:driver:export')")
82   - @Log(title = "驾驶员信息", businessType = BusinessType.EXPORT)
  82 +// @Log(title = "驾驶员信息", businessType = BusinessType.EXPORT)
83 83 @PostMapping("/export")
84 84 @ApiOperation("导出驾驶员信息列表")
85 85 public void export(HttpServletResponse response, Driver driver) {
... ... @@ -115,18 +115,18 @@ public class DriverController extends BaseController {
115 115 * 修改驾驶员信息
116 116 */
117 117 // @PreAuthorize("@ss.hasPermi('driver:driver:edit')")
118   - @Log(title = "驾驶员信息", businessType = BusinessType.UPDATE)
  118 +// @Log(title = "驾驶员信息", businessType = BusinessType.UPDATE)
119 119 @PutMapping
120 120 @ApiOperation("修改驾驶员信息")
121 121 public AjaxResult edit(@ApiParam("driver") @RequestBody Driver driver) {
122   - return toAjax(driverService.updateDriver(driver));
  122 + return toAjax(driverService.updateDriver(driver) + 1);
123 123 }
124 124  
125 125 /**
126 126 * 删除驾驶员信息
127 127 */
128 128 // @PreAuthorize("@ss.hasPermi('driver:driver:remove')")
129   - @Log(title = "驾驶员信息", businessType = BusinessType.DELETE)
  129 +// @Log(title = "驾驶员信息", businessType = BusinessType.DELETE)
130 130 @DeleteMapping("/{ids}")
131 131 @ApiOperation("删除驾驶员信息")
132 132 public AjaxResult remove(@ApiParam @PathVariable Long[] ids) {
... ... @@ -156,6 +156,8 @@ public class DriverController extends BaseController {
156 156 }
157 157 }
158 158  
  159 +
  160 +
159 161 /**
160 162 * 头像下载 根据 工号
161 163 */
... ...
ruoyi-admin/src/main/java/com/ruoyi/eexception/service/impl/EquipmentExceptionServiceImpl.java
1 1 package com.ruoyi.eexception.service.impl;
2 2  
3 3 import java.util.List;
  4 +import java.util.Objects;
  5 +
4 6 import com.ruoyi.common.utils.DateUtils;
5 7 import com.ruoyi.common.utils.SecurityUtils;
6 8 import com.ruoyi.common.utils.StringUtils;
  9 +import com.ruoyi.equipment.domain.Equipment;
  10 +import com.ruoyi.equipment.mapper.EquipmentMapper;
7 11 import org.springframework.beans.factory.annotation.Autowired;
8 12 import org.springframework.stereotype.Service;
9 13 import com.ruoyi.eexception.mapper.EquipmentExceptionMapper;
10 14 import com.ruoyi.eexception.domain.EquipmentException;
11 15 import com.ruoyi.eexception.service.IEquipmentExceptionService;
12 16  
  17 +import static com.ruoyi.common.ConstEquipmentProperties.EQUIPMENT_PROCESS_FLOW_COMMIT;
  18 +import static com.ruoyi.common.ConstEquipmentProperties.EQUIPMENT_STATUS_ILLNESS;
  19 +
13 20 /**
14 21 * 设备异常记录Service业务层处理
15 22 *
... ... @@ -22,6 +29,9 @@ public class EquipmentExceptionServiceImpl implements IEquipmentExceptionService
22 29 @Autowired
23 30 private EquipmentExceptionMapper equipmentExceptionMapper;
24 31  
  32 + @Autowired
  33 + private EquipmentMapper equipmentMapper;
  34 +
25 35 /**
26 36 * 查询设备异常记录
27 37 *
... ... @@ -59,6 +69,13 @@ public class EquipmentExceptionServiceImpl implements IEquipmentExceptionService
59 69 if (!StringUtils.isNotEmpty(equipmentException.getDeviceId())){
60 70 throw new RuntimeException("设备号不能为空");
61 71 }
  72 + Equipment equipment = equipmentMapper.queryEquipmentByDeviceId(equipmentException.getDeviceId());
  73 + if (Objects.isNull(equipment)){
  74 + throw new RuntimeException("设备不存在");
  75 + }
  76 + equipment.setStatus(EQUIPMENT_STATUS_ILLNESS);
  77 + equipmentMapper.updateEquipment(equipment);
  78 + equipmentException.setStatus(EQUIPMENT_PROCESS_FLOW_COMMIT);
62 79 return equipmentExceptionMapper.insertEquipmentException(equipmentException);
63 80 }
64 81  
... ...
ruoyi-admin/src/main/java/com/ruoyi/equipment/mapper/EquipmentMapper.java
... ... @@ -68,4 +68,6 @@ public interface EquipmentMapper
68 68 Integer count();
69 69  
70 70 List<EquipmentDriverExpand> querySignListByJobCode(@Param("drivers") List<Driver> drivers);
  71 +
  72 + Equipment queryEquipmentByDeviceId(@Param("deviceId") String deviceId);
71 73 }
... ...
ruoyi-admin/src/main/java/com/ruoyi/in/controller/SignInController.java
... ... @@ -88,7 +88,7 @@ public class SignInController extends BaseController
88 88 @ApiOperation("新增签到(通过后台管理页面)")
89 89 public AjaxResult add(@ApiParam @RequestBody SignIn signIn)
90 90 {
91   - return toAjax(signInService.insertSignIn(signIn));
  91 + return signInService.insertSignIn(signIn);
92 92 }
93 93  
94 94 /**
... ...
ruoyi-admin/src/main/java/com/ruoyi/in/service/ISignInService.java
... ... @@ -39,7 +39,7 @@ public interface ISignInService
39 39 * @param signIn 签到
40 40 * @return 结果
41 41 */
42   - public int insertSignIn(SignIn signIn);
  42 + public AjaxResult insertSignIn(SignIn signIn);
43 43  
44 44 /**
45 45 * 修改签到
... ...
ruoyi-admin/src/main/java/com/ruoyi/in/service/impl/SignInServiceImpl.java
... ... @@ -95,17 +95,35 @@ public class SignInServiceImpl implements ISignInService {
95 95 * @return 结果
96 96 */
97 97 @Override
98   - public int insertSignIn(SignIn signIn) {
99   - signIn.setIp(IpUtils.getIpAddr());
100   - signIn.setCreateTime(DateUtils.getNowDate());
101   - if (signIn.getType() == null) {
102   - signIn.setType(ConstSignInConstSignInProperties.SIGN_IN);
  98 + public AjaxResult insertSignIn(SignIn signIn) {
  99 + // 查询员工信息
  100 + Driver driver = driverMapper.getDriverInfoByJobCode(signIn.getJobCode());
  101 + // 查询地址
  102 + Equipment equipment = equipmentMapper.selectEquipmentByDeviceId(signIn.getDeviceId());
  103 + SignInResponseVo vo = getSignInResponseVo(signIn, equipment);
  104 + signIn.setCreateTime(new Date());
  105 + signIn.setRemark("");
  106 + // 签到检查 酒精检查 超时检查 排班检查
  107 + if (checkSignIn(signIn, driver)) {
  108 + signIn.setStatus(SIGN_IN_SUCCESS);
  109 + } else {
  110 + signIn.setStatus(SIGN_IN_FAIL);
103 111 }
104   - if (ALCOHOL_FLAG_YES.equals(signIn.getAlcoholFlag())) {
105   - signIn.setStatus(signIn.getAlcoholIntake().compareTo(new BigDecimal(20)) < 0 ? SIGN_IN_SUCCESS : SIGN_IN_FAIL);
106   - signIn.setRemark(signIn.getStatus().equals(SIGN_IN_FAIL) ? "酒精测试不通过超标:" + signIn.getAlcoholIntake().floatValue() + "%" : "");
  112 + // base64转图片
  113 + signIn.setIp(IpUtils.getIpAddr());
  114 +// uploadImage(signIn);
  115 + signInMapper.insertSignIn(signIn);
  116 + // TODO redis 存储每个人的签到 用于后续考勤
  117 +
  118 + // 驾驶人员二次签到酒精测试异常
  119 + if (PERSONNEL_TYPE_DRIVER.equals(driver.getPosts()) && SIGN_IN_FAIL.equals(signIn.getStatus()) && signIn.getRemark().contains(ALCOHOL_SIGN_IN_ERROR)) {
  120 + AjaxResult result = getAjaxResultByDriverSignInfo(signIn, vo);
  121 + if (!Objects.isNull(result)) {
  122 + return result;
  123 + }
107 124 }
108   - return signInMapper.insertSignIn(signIn);
  125 +
  126 + return SIGN_IN_SUCCESS.equals(signIn.getStatus()) ? AjaxResult.success(SIGN_IN_SUCCESS_STRING, vo) : AjaxResult.error(SIGN_IN_ERROR + signIn.getRemark(), vo);
109 127 }
110 128  
111 129 /**
... ... @@ -149,6 +167,8 @@ public class SignInServiceImpl implements ISignInService {
149 167 // 查询地址
150 168 Equipment equipment = equipmentMapper.selectEquipmentByDeviceId(signIn.getDeviceId());
151 169 SignInResponseVo vo = getSignInResponseVo(signIn, equipment);
  170 + signIn.setCreateTime(new Date());
  171 + signIn.setRemark("");
152 172 // 签到检查
153 173 if (checkSignIn(signIn, driver)) {
154 174 signIn.setStatus(SIGN_IN_SUCCESS);
... ... @@ -156,14 +176,13 @@ public class SignInServiceImpl implements ISignInService {
156 176 signIn.setStatus(SIGN_IN_FAIL);
157 177 }
158 178 // base64转图片
159   - signIn.setCreateTime(new Date());
160 179 signIn.setIp(IpUtils.getIpAddr());
161 180 uploadImage(signIn);
162 181 signInMapper.insertSignIn(signIn);
163 182 // TODO redis 存储每个人的签到 用于后续考勤
164 183  
165   - // TODO 驾驶人员二次签到酒精测试异常
166   - if (PERSONNEL_TYPE_DRIVER.equals(driver.getPosts())) {
  184 + // 驾驶人员二次签到酒精测试异常
  185 + if (PERSONNEL_TYPE_DRIVER.equals(driver.getPosts()) && SIGN_IN_FAIL.equals(signIn.getStatus()) && signIn.getRemark().contains(ALCOHOL_SIGN_IN_ERROR)) {
167 186 AjaxResult result = getAjaxResultByDriverSignInfo(signIn, vo);
168 187 if (!Objects.isNull(result)) {
169 188 return result;
... ... @@ -184,13 +203,14 @@ public class SignInServiceImpl implements ISignInService {
184 203 }
185 204  
186 205 private AjaxResult getAjaxResultByDriverSignInfo(SignIn signIn, SignInResponseVo vo) {
  206 + String key = REDIS_SIGN_IN + ConstDateUtil.formatDate("yyyyMMdd");
187 207 // 驾驶员酒精测试连续超标两次则提示换人
188   - Integer count = redisCache.getCacheMapValue(ConstDateUtil.formatDate("yyyyMMdd") + REDIS_SIGN_IN, signIn.getJobCode());
  208 + Integer count = redisCache.getCacheMapValue(key, signIn.getJobCode());
189 209 if (Objects.isNull(count) || count.equals(0)) {
190 210 count = 1;
191   - redisCache.setCacheMapValue(ConstDateUtil.formatDate("yyyyMMdd") + REDIS_SIGN_IN, signIn.getJobCode(), count);
  211 + redisCache.setCacheMapValue(key, signIn.getJobCode(), count);
192 212 } else {
193   - count = redisCache.setIncrementMapValue(ConstDateUtil.formatDate("yyyyMMdd") + REDIS_SIGN_IN, signIn.getJobCode(), 1);
  213 + count = redisCache.setIncrementMapValue(key, signIn.getJobCode(), 1);
194 214 }
195 215 if (SIGN_IN_ERROR_COUNT.compareTo(count) <= 0) {
196 216 // TODO
... ... @@ -212,7 +232,7 @@ public class SignInServiceImpl implements ISignInService {
212 232 if (new BigDecimal(20).compareTo(signIn.getAlcoholIntake()) > 0) {
213 233 result = true;
214 234 } else {
215   - signIn.setRemark(ALCOHOL_SIGN_IN_ERROR);
  235 + signIn.setRemark(signIn.getRemark() + ALCOHOL_SIGN_IN_ERROR);
216 236 result = false;
217 237 }
218 238 }
... ... @@ -224,14 +244,14 @@ public class SignInServiceImpl implements ISignInService {
224 244 * 排班和超时检查
225 245 *
226 246 * @param signIn
227   - * @param personnelType
  247 + * @param posts
228 248 * @return
229 249 */
230   - private boolean checkWorkDay(SignIn signIn, String personnelType) {
  250 + private boolean checkWorkDay(SignIn signIn, String posts) {
231 251 boolean result = true;
232 252 List<ResponseScheduling> jobs = null;
233   - switch (personnelType) {
234   - case "0":
  253 + switch (posts) {
  254 + case "驾驶员":
235 255 // 查询工号对应的排班 司售人员
236 256 jobs = redisCache.getCacheMapValue(DRIVER_SCHEDULING_PRE + ConstDateUtil.formatDate("yyyyMMdd"), signIn.getJobCode());
237 257 if (Objects.isNull(jobs) || jobs.size() == 0) {
... ... @@ -257,7 +277,7 @@ public class SignInServiceImpl implements ISignInService {
257 277 private boolean checkTimeOut(SignIn signIn, List<ResponseScheduling> driver) {
258 278 // 那发车时间和到站时间作为开始上班的时间
259 279 LocalDateTime startTime = ConstDateUtil.getLocalDateTimeByLongTime(driver.get(0).getFcsjT());
260   - LocalDateTime endTime = ConstDateUtil.getLocalDateTimeByLongTime(driver.get(0).getZdsjT());
  280 + LocalDateTime endTime = ConstDateUtil.getLocalDateTimeByLongTime(driver.get(driver.size() - 1).getZdsjT());
261 281 LocalDateTime signTime = ConstDateUtil.getLocalDateTimeByLongTime(signIn.getCreateTime().getTime());
262 282 long morningBetween = ChronoUnit.MINUTES.between(startTime, signTime);
263 283 long afternoonBetween = ChronoUnit.MINUTES.between(endTime, signTime);
... ...
ruoyi-admin/src/main/java/com/ruoyi/job/DriverJob.java
... ... @@ -141,7 +141,7 @@ public class DriverJob implements InitializingBean {
141 141 }
142 142 Map<String, Object> param = new HashMap<>();
143 143 param.put("userId", "InterfaceManagement");
144   - param.put("timeout", 86400000L);
  144 + param.put("timeout", 7200000L);
145 145 param.put("fileUrl", fileUrl);
146 146 param.put("systemToken", "16A66291CHE9K5DPE1IDO9E63FOE2VWA09QFLV");
147 147 Map<String, String> header = new HashMap<>();
... ...
ruoyi-admin/src/main/resources/mapper/equipment/EquipmentMapper.xml
... ... @@ -63,6 +63,10 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
63 63 </if>
64 64  
65 65 </select>
  66 + <select id="queryEquipmentByDeviceId" resultType="com.ruoyi.equipment.domain.Equipment">
  67 + select * from equipment
  68 + where device_id = #{deviceId}
  69 + </select>
66 70  
67 71  
68 72 <insert id="insertEquipment" parameterType="Equipment" useGeneratedKeys="true" keyProperty="id">
... ...