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,10 +33,11 @@ public class ApplicationUpdateController {
33 } 33 }
34 34
35 /** 35 /**
36 - * 下载最新apk 36 + * 下载最新apk 弃用
37 */ 37 */
  38 + @Deprecated
38 @PostMapping("/download") 39 @PostMapping("/download")
39 - @ApiOperation("下载最新apk") 40 +// @ApiOperation("下载最新apk")
40 public void downloadApk(String apkUrl, HttpServletResponse response) { 41 public void downloadApk(String apkUrl, HttpServletResponse response) {
41 try { 42 try {
42 appService.downloadApk(apkUrl, response); 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,7 +79,7 @@ public class DriverController extends BaseController {
79 * 导出驾驶员信息列表 79 * 导出驾驶员信息列表
80 */ 80 */
81 // @PreAuthorize("@ss.hasPermi('driver:driver:export')") 81 // @PreAuthorize("@ss.hasPermi('driver:driver:export')")
82 - @Log(title = "驾驶员信息", businessType = BusinessType.EXPORT) 82 +// @Log(title = "驾驶员信息", businessType = BusinessType.EXPORT)
83 @PostMapping("/export") 83 @PostMapping("/export")
84 @ApiOperation("导出驾驶员信息列表") 84 @ApiOperation("导出驾驶员信息列表")
85 public void export(HttpServletResponse response, Driver driver) { 85 public void export(HttpServletResponse response, Driver driver) {
@@ -115,18 +115,18 @@ public class DriverController extends BaseController { @@ -115,18 +115,18 @@ public class DriverController extends BaseController {
115 * 修改驾驶员信息 115 * 修改驾驶员信息
116 */ 116 */
117 // @PreAuthorize("@ss.hasPermi('driver:driver:edit')") 117 // @PreAuthorize("@ss.hasPermi('driver:driver:edit')")
118 - @Log(title = "驾驶员信息", businessType = BusinessType.UPDATE) 118 +// @Log(title = "驾驶员信息", businessType = BusinessType.UPDATE)
119 @PutMapping 119 @PutMapping
120 @ApiOperation("修改驾驶员信息") 120 @ApiOperation("修改驾驶员信息")
121 public AjaxResult edit(@ApiParam("driver") @RequestBody Driver driver) { 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 // @PreAuthorize("@ss.hasPermi('driver:driver:remove')") 128 // @PreAuthorize("@ss.hasPermi('driver:driver:remove')")
129 - @Log(title = "驾驶员信息", businessType = BusinessType.DELETE) 129 +// @Log(title = "驾驶员信息", businessType = BusinessType.DELETE)
130 @DeleteMapping("/{ids}") 130 @DeleteMapping("/{ids}")
131 @ApiOperation("删除驾驶员信息") 131 @ApiOperation("删除驾驶员信息")
132 public AjaxResult remove(@ApiParam @PathVariable Long[] ids) { 132 public AjaxResult remove(@ApiParam @PathVariable Long[] ids) {
@@ -156,6 +156,8 @@ public class DriverController extends BaseController { @@ -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 package com.ruoyi.eexception.service.impl; 1 package com.ruoyi.eexception.service.impl;
2 2
3 import java.util.List; 3 import java.util.List;
  4 +import java.util.Objects;
  5 +
4 import com.ruoyi.common.utils.DateUtils; 6 import com.ruoyi.common.utils.DateUtils;
5 import com.ruoyi.common.utils.SecurityUtils; 7 import com.ruoyi.common.utils.SecurityUtils;
6 import com.ruoyi.common.utils.StringUtils; 8 import com.ruoyi.common.utils.StringUtils;
  9 +import com.ruoyi.equipment.domain.Equipment;
  10 +import com.ruoyi.equipment.mapper.EquipmentMapper;
7 import org.springframework.beans.factory.annotation.Autowired; 11 import org.springframework.beans.factory.annotation.Autowired;
8 import org.springframework.stereotype.Service; 12 import org.springframework.stereotype.Service;
9 import com.ruoyi.eexception.mapper.EquipmentExceptionMapper; 13 import com.ruoyi.eexception.mapper.EquipmentExceptionMapper;
10 import com.ruoyi.eexception.domain.EquipmentException; 14 import com.ruoyi.eexception.domain.EquipmentException;
11 import com.ruoyi.eexception.service.IEquipmentExceptionService; 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 * 设备异常记录Service业务层处理 21 * 设备异常记录Service业务层处理
15 * 22 *
@@ -22,6 +29,9 @@ public class EquipmentExceptionServiceImpl implements IEquipmentExceptionService @@ -22,6 +29,9 @@ public class EquipmentExceptionServiceImpl implements IEquipmentExceptionService
22 @Autowired 29 @Autowired
23 private EquipmentExceptionMapper equipmentExceptionMapper; 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,6 +69,13 @@ public class EquipmentExceptionServiceImpl implements IEquipmentExceptionService
59 if (!StringUtils.isNotEmpty(equipmentException.getDeviceId())){ 69 if (!StringUtils.isNotEmpty(equipmentException.getDeviceId())){
60 throw new RuntimeException("设备号不能为空"); 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 return equipmentExceptionMapper.insertEquipmentException(equipmentException); 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,4 +68,6 @@ public interface EquipmentMapper
68 Integer count(); 68 Integer count();
69 69
70 List<EquipmentDriverExpand> querySignListByJobCode(@Param("drivers") List<Driver> drivers); 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,7 +88,7 @@ public class SignInController extends BaseController
88 @ApiOperation("新增签到(通过后台管理页面)") 88 @ApiOperation("新增签到(通过后台管理页面)")
89 public AjaxResult add(@ApiParam @RequestBody SignIn signIn) 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,7 +39,7 @@ public interface ISignInService
39 * @param signIn 签到 39 * @param signIn 签到
40 * @return 结果 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,17 +95,35 @@ public class SignInServiceImpl implements ISignInService {
95 * @return 结果 95 * @return 结果
96 */ 96 */
97 @Override 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,6 +167,8 @@ public class SignInServiceImpl implements ISignInService {
149 // 查询地址 167 // 查询地址
150 Equipment equipment = equipmentMapper.selectEquipmentByDeviceId(signIn.getDeviceId()); 168 Equipment equipment = equipmentMapper.selectEquipmentByDeviceId(signIn.getDeviceId());
151 SignInResponseVo vo = getSignInResponseVo(signIn, equipment); 169 SignInResponseVo vo = getSignInResponseVo(signIn, equipment);
  170 + signIn.setCreateTime(new Date());
  171 + signIn.setRemark("");
152 // 签到检查 172 // 签到检查
153 if (checkSignIn(signIn, driver)) { 173 if (checkSignIn(signIn, driver)) {
154 signIn.setStatus(SIGN_IN_SUCCESS); 174 signIn.setStatus(SIGN_IN_SUCCESS);
@@ -156,14 +176,13 @@ public class SignInServiceImpl implements ISignInService { @@ -156,14 +176,13 @@ public class SignInServiceImpl implements ISignInService {
156 signIn.setStatus(SIGN_IN_FAIL); 176 signIn.setStatus(SIGN_IN_FAIL);
157 } 177 }
158 // base64转图片 178 // base64转图片
159 - signIn.setCreateTime(new Date());  
160 signIn.setIp(IpUtils.getIpAddr()); 179 signIn.setIp(IpUtils.getIpAddr());
161 uploadImage(signIn); 180 uploadImage(signIn);
162 signInMapper.insertSignIn(signIn); 181 signInMapper.insertSignIn(signIn);
163 // TODO redis 存储每个人的签到 用于后续考勤 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 AjaxResult result = getAjaxResultByDriverSignInfo(signIn, vo); 186 AjaxResult result = getAjaxResultByDriverSignInfo(signIn, vo);
168 if (!Objects.isNull(result)) { 187 if (!Objects.isNull(result)) {
169 return result; 188 return result;
@@ -184,13 +203,14 @@ public class SignInServiceImpl implements ISignInService { @@ -184,13 +203,14 @@ public class SignInServiceImpl implements ISignInService {
184 } 203 }
185 204
186 private AjaxResult getAjaxResultByDriverSignInfo(SignIn signIn, SignInResponseVo vo) { 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 if (Objects.isNull(count) || count.equals(0)) { 209 if (Objects.isNull(count) || count.equals(0)) {
190 count = 1; 210 count = 1;
191 - redisCache.setCacheMapValue(ConstDateUtil.formatDate("yyyyMMdd") + REDIS_SIGN_IN, signIn.getJobCode(), count); 211 + redisCache.setCacheMapValue(key, signIn.getJobCode(), count);
192 } else { 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 if (SIGN_IN_ERROR_COUNT.compareTo(count) <= 0) { 215 if (SIGN_IN_ERROR_COUNT.compareTo(count) <= 0) {
196 // TODO 216 // TODO
@@ -212,7 +232,7 @@ public class SignInServiceImpl implements ISignInService { @@ -212,7 +232,7 @@ public class SignInServiceImpl implements ISignInService {
212 if (new BigDecimal(20).compareTo(signIn.getAlcoholIntake()) > 0) { 232 if (new BigDecimal(20).compareTo(signIn.getAlcoholIntake()) > 0) {
213 result = true; 233 result = true;
214 } else { 234 } else {
215 - signIn.setRemark(ALCOHOL_SIGN_IN_ERROR); 235 + signIn.setRemark(signIn.getRemark() + ALCOHOL_SIGN_IN_ERROR);
216 result = false; 236 result = false;
217 } 237 }
218 } 238 }
@@ -224,14 +244,14 @@ public class SignInServiceImpl implements ISignInService { @@ -224,14 +244,14 @@ public class SignInServiceImpl implements ISignInService {
224 * 排班和超时检查 244 * 排班和超时检查
225 * 245 *
226 * @param signIn 246 * @param signIn
227 - * @param personnelType 247 + * @param posts
228 * @return 248 * @return
229 */ 249 */
230 - private boolean checkWorkDay(SignIn signIn, String personnelType) { 250 + private boolean checkWorkDay(SignIn signIn, String posts) {
231 boolean result = true; 251 boolean result = true;
232 List<ResponseScheduling> jobs = null; 252 List<ResponseScheduling> jobs = null;
233 - switch (personnelType) {  
234 - case "0": 253 + switch (posts) {
  254 + case "驾驶员":
235 // 查询工号对应的排班 司售人员 255 // 查询工号对应的排班 司售人员
236 jobs = redisCache.getCacheMapValue(DRIVER_SCHEDULING_PRE + ConstDateUtil.formatDate("yyyyMMdd"), signIn.getJobCode()); 256 jobs = redisCache.getCacheMapValue(DRIVER_SCHEDULING_PRE + ConstDateUtil.formatDate("yyyyMMdd"), signIn.getJobCode());
237 if (Objects.isNull(jobs) || jobs.size() == 0) { 257 if (Objects.isNull(jobs) || jobs.size() == 0) {
@@ -257,7 +277,7 @@ public class SignInServiceImpl implements ISignInService { @@ -257,7 +277,7 @@ public class SignInServiceImpl implements ISignInService {
257 private boolean checkTimeOut(SignIn signIn, List<ResponseScheduling> driver) { 277 private boolean checkTimeOut(SignIn signIn, List<ResponseScheduling> driver) {
258 // 那发车时间和到站时间作为开始上班的时间 278 // 那发车时间和到站时间作为开始上班的时间
259 LocalDateTime startTime = ConstDateUtil.getLocalDateTimeByLongTime(driver.get(0).getFcsjT()); 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 LocalDateTime signTime = ConstDateUtil.getLocalDateTimeByLongTime(signIn.getCreateTime().getTime()); 281 LocalDateTime signTime = ConstDateUtil.getLocalDateTimeByLongTime(signIn.getCreateTime().getTime());
262 long morningBetween = ChronoUnit.MINUTES.between(startTime, signTime); 282 long morningBetween = ChronoUnit.MINUTES.between(startTime, signTime);
263 long afternoonBetween = ChronoUnit.MINUTES.between(endTime, signTime); 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,7 +141,7 @@ public class DriverJob implements InitializingBean {
141 } 141 }
142 Map<String, Object> param = new HashMap<>(); 142 Map<String, Object> param = new HashMap<>();
143 param.put("userId", "InterfaceManagement"); 143 param.put("userId", "InterfaceManagement");
144 - param.put("timeout", 86400000L); 144 + param.put("timeout", 7200000L);
145 param.put("fileUrl", fileUrl); 145 param.put("fileUrl", fileUrl);
146 param.put("systemToken", "16A66291CHE9K5DPE1IDO9E63FOE2VWA09QFLV"); 146 param.put("systemToken", "16A66291CHE9K5DPE1IDO9E63FOE2VWA09QFLV");
147 Map<String, String> header = new HashMap<>(); 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,6 +63,10 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
63 </if> 63 </if>
64 64
65 </select> 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 <insert id="insertEquipment" parameterType="Equipment" useGeneratedKeys="true" keyProperty="id"> 72 <insert id="insertEquipment" parameterType="Equipment" useGeneratedKeys="true" keyProperty="id">