Commit b994af10c7c710c427c0711738519f2a7f7287d9

Authored by guzijian
1 parent db35f26f

fix: 新增执行日志

ruoyi-admin/src/main/java/com/ruoyi/common/ConstEquipmentProperties.java
... ... @@ -5,6 +5,9 @@ package com.ruoyi.common;
5 5 * @author 20412
6 6 */
7 7 public interface ConstEquipmentProperties {
  8 + /**
  9 + * 设备健康
  10 + */
8 11 Integer EQUIPMENT_STATUS_HEALTH = 1;
9 12 /**
10 13 * 设备异常
... ... @@ -19,7 +22,7 @@ public interface ConstEquipmentProperties {
19 22 */
20 23 Integer EQUIPMENT_PROCESS_FLOW_ACTIVE = 3;
21 24 /**
22   - * 处理王城
  25 + * 处理完成
23 26 */
24 27 Integer EQUIPMENT_PROCESS_FLOW_COMPLETE = 3;
25 28 }
... ...
ruoyi-admin/src/main/java/com/ruoyi/common/ConstSignInConstSignInProperties.java
... ... @@ -6,6 +6,18 @@ package com.ruoyi.common;
6 6 */
7 7 public interface ConstSignInConstSignInProperties {
8 8 /**
  9 + * 未完成人脸注册
  10 + */
  11 + Integer SIGN_FACE_ACTIVE = 2;
  12 + /**
  13 + * 人脸过期更新中
  14 + */
  15 + Integer SIGN_FACE_TIMEOUT = 1;
  16 + /**
  17 + * 已完成人脸注册
  18 + */
  19 + Integer SIGN_FACE_SUCCESS = 0;
  20 + /**
9 21 * 导出图片
10 22 */
11 23 Integer EXPORT = 1;
... ...
ruoyi-admin/src/main/java/com/ruoyi/driver/service/impl/DriverServiceImpl.java
... ... @@ -44,6 +44,7 @@ import javax.servlet.http.HttpServletRequest;
44 44 import javax.servlet.http.HttpServletResponse;
45 45  
46 46 import static com.ruoyi.common.ApiProperties.PERSONNEL_API_KEY;
  47 +import static com.ruoyi.common.ConstSignInConstSignInProperties.SIGN_FACE_ACTIVE;
47 48 import static com.ruoyi.common.global.ResultCode.CODE_207;
48 49 import static com.ruoyi.common.redispre.GlobalRedisPreName.DRIVER_SCHEDULING_PRE;
49 50  
... ... @@ -120,6 +121,7 @@ public class DriverServiceImpl implements IDriverService {
120 121 */
121 122 @Override
122 123 public int insertDriver(Driver driver) {
  124 + driver.setUpdateTime(new Date());
123 125 return driverMapper.insertDriver(driver);
124 126 }
125 127  
... ... @@ -285,15 +287,7 @@ public class DriverServiceImpl implements IDriverService {
285 287 // 查询当前人员信息库是否存在对应员工数据
286 288 List<String> jobCodes = vo.getFaceDataList().stream().map(FaceUpdateReqVo.FaceData::getJobCode).collect(Collectors.toList());
287 289 Map<String, String> existsSet = driverMapper.queryJobCodesIsExists(jobCodes).stream().collect(Collectors.toMap(item -> item, s -> s));
288   - // 更新失败人员工号列表
289   - List<String> insertDriverJobCodeList = new ArrayList<>();
290   - for (String jobCode : jobCodes) {
291   - if (Objects.isNull(existsSet.get(jobCode))) {
292   - insertDriverJobCodeList.add(jobCode);
293   - }
294   - }
295 290 jobCodes = new ArrayList<>(existsSet.values());
296   -
297 291 List<Driver> updateDrivers = getDriversByJobCode(vo, date, existsSet, true);
298 292 List<Driver> insertDrivers = getDriversByJobCode(vo, date, existsSet, false);
299 293 List<List<Driver>> lists = ListUtils.splitList(updateDrivers, 400);
... ... @@ -338,6 +332,7 @@ public class DriverServiceImpl implements IDriverService {
338 332 driver.setJobCode(item.getJobCode());
339 333 driver.setFleetName(item.getFleetName());
340 334 driver.setLineName(item.getLineName());
  335 + driver.setFaceSignIn(SIGN_FACE_ACTIVE);
341 336 try {
342 337 driver.setImage(getNewImageUrl(item.getJobCode(), item.getImageUrl()));
343 338 } catch (IOException e) {
... ...
ruoyi-admin/src/main/java/com/ruoyi/in/service/impl/SignInServiceImpl.java
... ... @@ -180,6 +180,7 @@ public class SignInServiceImpl implements ISignInService {
180 180 SignInResponseVo vo = getSignInResponseVo(signIn, equipment);
181 181 signIn.setCreateTime(new Date());
182 182 signIn.setRemark("");
  183 + // 测试用户特殊处理
183 184 if (signIn.getJobCode().equals("700002") || signIn.getJobCode().equals("700001")) {
184 185 return AjaxResult.success(SIGN_IN_SUCCESS_STRING, vo);
185 186 }
... ... @@ -297,17 +298,21 @@ public class SignInServiceImpl implements ISignInService {
297 298 }
298 299  
299 300 private static boolean driverCheckTimeOut(SignIn signIn, List<ResponseScheduling> driver) {
300   - LocalDateTime startTime = ConstDateUtil.getLocalDateTimeByLongTime(driver.get(0).getFcsjT());
301   - LocalDateTime endTime = ConstDateUtil.getLocalDateTimeByLongTime(driver.get(driver.size() - 1).getZdsjT());
302   - LocalDateTime signTime = ConstDateUtil.getLocalDateTimeByLongTime(signIn.getCreateTime().getTime());
303   - long morningBetween = ChronoUnit.MINUTES.between(startTime, signTime);
304   - long afternoonBetween = ChronoUnit.MINUTES.between(endTime, signTime);
305   - // 签到范围一小时内
306   - if (Math.abs(morningBetween) <= 60 || Math.abs(afternoonBetween) <= 60) {
  301 + try {
  302 + LocalDateTime startTime = ConstDateUtil.getLocalDateTimeByLongTime(driver.get(0).getFcsjT());
  303 + LocalDateTime endTime = ConstDateUtil.getLocalDateTimeByLongTime(driver.get(driver.size() - 1).getZdsjT());
  304 + LocalDateTime signTime = ConstDateUtil.getLocalDateTimeByLongTime(signIn.getCreateTime().getTime());
  305 + long morningBetween = ChronoUnit.MINUTES.between(startTime, signTime);
  306 + long afternoonBetween = ChronoUnit.MINUTES.between(endTime, signTime);
  307 + // 签到范围一小时内 TODO 不合理后续会更改
  308 + if (Math.abs(morningBetween) <= 60 || Math.abs(afternoonBetween) <= 60) {
  309 + return true;
  310 + } else {
  311 + signIn.setRemark(signIn.getRemark() + SIGN_IN_TIMEOUT);
  312 + return false;
  313 + }
  314 + } catch (Exception e) {
307 315 return true;
308   - } else {
309   - signIn.setRemark(signIn.getRemark() + SIGN_IN_TIMEOUT);
310   - return false;
311 316 }
312 317 }
313 318  
... ...
ruoyi-admin/src/main/java/com/ruoyi/job/DriverJob.java
... ... @@ -92,15 +92,18 @@ public class DriverJob implements InitializingBean {
92 92  
93 93 /**
94 94 * 通过该定时任务获取驾驶员信息 并保存到数据库
95   - * 排班信息映射 不低于2小时更新一次
96 95 */
97 96 public void getDriverInfo(String params) throws Exception {
98 97 try {
99 98 // String getDriverInfoUrl = String.format(GET_DRIVER_INFO_URL, params);
100 99 //获取token
  100 + log.info("开始获取人事接口token");
101 101 TokenResponseVo tokenVo = getToken(TOKEN_URL);
  102 + log.info("获取人事接口token完毕");
102 103 // 获取驾驶员信息
  104 + log.info("开始获取驾驶员信息");
103 105 getDrivers(tokenVo.getAccessToken());
  106 + log.info("获取驾驶员信息结束");
104 107  
105 108 } catch (Exception e) {
106 109 log.info("执行失败:" + e.getMessage());
... ... @@ -161,16 +164,21 @@ public class DriverJob implements InitializingBean {
161 164 * 24小时执行一次
162 165 */
163 166 public void getSchedulingInfo() {
164   - // 获取排班请求
165 167 long timestamp = System.currentTimeMillis();
  168 + log.info("获取排班任务触发时间:{}",timestamp);
  169 + // 获取排班请求
166 170 String getSchedulingInfoUrl = null;
  171 + String formatDate = ConstDateUtil.formatDate(timestamp);
  172 + log.info("开始获取{}的排班数据",formatDate);
167 173 try {
168   - getSchedulingInfoUrl = String.format(GET_SCHEDULING_INFO_URL, "99", ConstDateUtil.formatDate("yyyyMMdd"), timestamp, NONCE, PASSWORD, getSHA1(getStringStringMap(String.valueOf(timestamp))));
  174 + getSchedulingInfoUrl = String.format(GET_SCHEDULING_INFO_URL, "99", formatDate, timestamp, NONCE, PASSWORD, getSHA1(getStringStringMap(String.valueOf(timestamp))));
169 175 } catch (Exception e) {
170 176 throw new RuntimeException(e);
171 177 }
172 178 // 获取排班信息并存入redis
173   - saveSchedulingToRedis(getSchedulingInfoUrl, ConstDateUtil.formatDate("yyyyMMdd"));
  179 + saveSchedulingToRedis(getSchedulingInfoUrl, formatDate);
  180 +
  181 + log.info("获取{}的排班数据完毕",formatDate);
174 182 }
175 183  
176 184 /**
... ... @@ -202,9 +210,9 @@ public class DriverJob implements InitializingBean {
202 210 String jobCode = item.getJsy().split("/")[0];
203 211 item.setJobCode(jobCode);
204 212 if (Objects.isNull(driverSchedulingMap.get(jobCode))) {
205   - List<ResponseScheduling> oneDriverSchedulings = new ArrayList<>();
206   - oneDriverSchedulings.add(item);
207   - driverSchedulingMap.put(jobCode, oneDriverSchedulings);
  213 + List<ResponseScheduling> oneDriverScheduling = new ArrayList<>();
  214 + oneDriverScheduling.add(item);
  215 + driverSchedulingMap.put(jobCode, oneDriverScheduling);
208 216 } else {
209 217 driverSchedulingMap.get(jobCode).add(item);
210 218 }
... ... @@ -239,7 +247,9 @@ public class DriverJob implements InitializingBean {
239 247 }
240 248  
241 249 private static void updateDrivers(List<Driver> drivers) {
  250 + log.info("开始更新人脸注册状态");
242 251 DRIVER_SERVICE.updateDrivers(drivers);
  252 + log.info("更新人脸注册状态完毕");
243 253 }
244 254  
245 255 private static List<Driver> getDrivers(Date date, PersonnelResultResponseVo vo) {
... ...
ruoyi-admin/src/main/java/com/ruoyi/service/ThreadJobService.java
... ... @@ -122,7 +122,7 @@ public class ThreadJobService {
122 122 }
123 123  
124 124 private void insertDriverInfo(String token, Driver driver) {
125   - String headImageUrl = new String(driver.getImage());
  125 + String headImageUrl = driver.getImage();
126 126 // 生成文件路径
127 127 String fileName = driver.getJobCode() + ".png";
128 128 String filePath = RuoYiConfig.getUploadPath() + headImagePre + "/" + fileName;
... ...
ruoyi-admin/src/main/java/com/ruoyi/utils/ConstDateUtil.java
... ... @@ -11,6 +11,15 @@ public class ConstDateUtil {
11 11 SimpleDateFormat simpleDateFormat = new SimpleDateFormat(str);
12 12 return simpleDateFormat.format(new Date());
13 13 }
  14 + public static String formatDate(long time){
  15 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
  16 + return simpleDateFormat.format(new Date(time));
  17 + }
  18 + public static String formatDate(Date date){
  19 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
  20 + return simpleDateFormat.format(date);
  21 + }
  22 +
14 23  
15 24 public static LocalDateTime getLocalDateTimeByLongTime(long time){
16 25 Instant instant = Instant.ofEpochMilli(time);
... ...
ruoyi-admin/src/main/resources/application-druid-dev.yml
... ... @@ -153,4 +153,6 @@ api:
153 153 appKey: dingsclwvxui5zilg1xk
154 154 appSecret: ckV20k3jMKJpUkfXXSGhLk077rQQjsSaAusiSVY-nm4glwweCmb_SMJ62Cpf4YQ5
155 155 people:
156   - url: https://api.dingtalk.com/v1.0/yida/forms/instances/search
157 156 \ No newline at end of file
  157 + url: https://api.dingtalk.com/v1.0/yida/forms/instances/search
  158 +log:
  159 + path: D:/ruoyi/logs
... ...
ruoyi-admin/src/main/resources/application-druid-prd.yml
... ... @@ -177,4 +177,6 @@ api:
177 177 appKey: dingsclwvxui5zilg1xk
178 178 appSecret: ckV20k3jMKJpUkfXXSGhLk077rQQjsSaAusiSVY-nm4glwweCmb_SMJ62Cpf4YQ5
179 179 people:
180   - url: https://api.dingtalk.com/v1.0/yida/forms/instances/search
181 180 \ No newline at end of file
  181 + url: https://api.dingtalk.com/v1.0/yida/forms/instances/search
  182 +log:
  183 + path: E:/ruoyi/logs
182 184 \ No newline at end of file
... ...
ruoyi-admin/src/main/resources/application-druid-uat.yml
... ... @@ -173,4 +173,6 @@ api:
173 173 appKey: dingsclwvxui5zilg1xk
174 174 appSecret: ckV20k3jMKJpUkfXXSGhLk077rQQjsSaAusiSVY-nm4glwweCmb_SMJ62Cpf4YQ5
175 175 people:
176   - url: https://api.dingtalk.com/v1.0/yida/forms/instances/search
177 176 \ No newline at end of file
  177 + url: https://api.dingtalk.com/v1.0/yida/forms/instances/search
  178 +log:
  179 + path: /home/ruoyi/logs
178 180 \ No newline at end of file
... ...
ruoyi-admin/src/main/resources/logback.xml
... ... @@ -3,7 +3,7 @@
3 3 <!-- 日志存放路径 -->
4 4 <!-- <property name="log.path" value="E:/ruoyi/logs" />-->
5 5 <!-- <property name="log.path" value="D:/ruoyi/logs" />-->
6   - <property name="log.path" value="/home/ruoyi/logs" />
  6 + <springProperty scope="context" name="log.path" source="log.path"/>
7 7 <!-- 日志输出格式 -->
8 8 <property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
9 9  
... ...