Commit 488d555422348b80e57c96441dad09941a8b48fd
1 parent
16f71e97
fix: 全量更新人员信息接口
Showing
4 changed files
with
40 additions
and
3 deletions
Bsth-admin/src/main/java/com/ruoyi/driver/controller/DriverController.java
| @@ -213,4 +213,12 @@ public class DriverController extends BaseController { | @@ -213,4 +213,12 @@ public class DriverController extends BaseController { | ||
| 213 | return driverService.faceRegistrationFeedback(vo.getDeviceId(), vo.getJobCodes()); | 213 | return driverService.faceRegistrationFeedback(vo.getDeviceId(), vo.getJobCodes()); |
| 214 | } | 214 | } |
| 215 | 215 | ||
| 216 | + /** | ||
| 217 | + * 全量更新信息 | ||
| 218 | + */ | ||
| 219 | + @GetMapping("/allUpdateDriverInfo") | ||
| 220 | + public AjaxResult allUpdateDriverInfo(HttpServletRequest request) { | ||
| 221 | + return driverService.allUpdateDriverInfo(request); | ||
| 222 | + } | ||
| 223 | + | ||
| 216 | } | 224 | } |
Bsth-admin/src/main/java/com/ruoyi/driver/service/IDriverService.java
| @@ -121,4 +121,6 @@ public interface IDriverService | @@ -121,4 +121,6 @@ public interface IDriverService | ||
| 121 | List<String> queryEmptyJob(List<String> jobList); | 121 | List<String> queryEmptyJob(List<String> jobList); |
| 122 | 122 | ||
| 123 | void updateDriverBaseInfoByJobCodes(List<Driver> drivers, int filterImage); | 123 | void updateDriverBaseInfoByJobCodes(List<Driver> drivers, int filterImage); |
| 124 | + | ||
| 125 | + AjaxResult allUpdateDriverInfo(HttpServletRequest request); | ||
| 124 | } | 126 | } |
Bsth-admin/src/main/java/com/ruoyi/driver/service/impl/DriverServiceImpl.java
| @@ -35,6 +35,8 @@ import com.ruoyi.pojo.request.DriverSignInRequestVo; | @@ -35,6 +35,8 @@ import com.ruoyi.pojo.request.DriverSignInRequestVo; | ||
| 35 | import com.ruoyi.pojo.request.FaceUpdateReqVo; | 35 | import com.ruoyi.pojo.request.FaceUpdateReqVo; |
| 36 | import com.ruoyi.pojo.response.DriverResponseVo; | 36 | import com.ruoyi.pojo.response.DriverResponseVo; |
| 37 | import com.ruoyi.pojo.response.ResponseSchedulingDto; | 37 | import com.ruoyi.pojo.response.ResponseSchedulingDto; |
| 38 | +import com.ruoyi.pojo.response.personnel.PersonnelResultResponseVo; | ||
| 39 | +import com.ruoyi.pojo.response.personnel.TokenResponseVo; | ||
| 38 | import com.ruoyi.service.SchedulingService; | 40 | import com.ruoyi.service.SchedulingService; |
| 39 | import com.ruoyi.service.ThreadJobService; | 41 | import com.ruoyi.service.ThreadJobService; |
| 40 | import com.ruoyi.system.domain.SysNotice; | 42 | import com.ruoyi.system.domain.SysNotice; |
| @@ -75,6 +77,9 @@ public class DriverServiceImpl implements IDriverService { | @@ -75,6 +77,9 @@ public class DriverServiceImpl implements IDriverService { | ||
| 75 | 77 | ||
| 76 | private Logger log = LoggerFactory.getLogger(DriverServiceImpl.class); | 78 | private Logger log = LoggerFactory.getLogger(DriverServiceImpl.class); |
| 77 | 79 | ||
| 80 | + @Value("${api.personnel.token.tokenUrl}") | ||
| 81 | + private String tokenUrl; | ||
| 82 | + | ||
| 78 | @Resource | 83 | @Resource |
| 79 | private NowSchedulingCache cache; | 84 | private NowSchedulingCache cache; |
| 80 | 85 | ||
| @@ -588,6 +593,28 @@ public class DriverServiceImpl implements IDriverService { | @@ -588,6 +593,28 @@ public class DriverServiceImpl implements IDriverService { | ||
| 588 | driverMapper.updateDriverBaseInfoByJobCodes(drivers, filterImage); | 593 | driverMapper.updateDriverBaseInfoByJobCodes(drivers, filterImage); |
| 589 | } | 594 | } |
| 590 | 595 | ||
| 596 | + @Override | ||
| 597 | + public AjaxResult allUpdateDriverInfo(HttpServletRequest request) { | ||
| 598 | + String header = request.getHeader("X-TOKEN-AUTH"); | ||
| 599 | + if (!"gzjUse".equals(header)) { | ||
| 600 | + throw new RuntimeException("错误的认证"); | ||
| 601 | + } | ||
| 602 | + Date date = new Date(); | ||
| 603 | + int pageSize = 100; | ||
| 604 | + TokenResponseVo tokenVo = DriverJob.getToken(tokenUrl); | ||
| 605 | + PersonnelResultResponseVo vo = DriverJob.getPersonInfo(tokenVo.getAccessToken(), pageSize, 1); | ||
| 606 | + int countPage = vo.getTotalCount() / pageSize; | ||
| 607 | + countPage = vo.getTotalCount() % pageSize == 0 ? countPage : countPage + 1; | ||
| 608 | + List<Driver> drivers = DriverJob.getDrivers(date, vo); | ||
| 609 | + for (int i = 2; i <= countPage; i++) { | ||
| 610 | + drivers.addAll(DriverJob.getDrivers(date, DriverJob.getPersonInfo(tokenVo.getAccessToken(), 100, i))); | ||
| 611 | + } | ||
| 612 | + if (CollectionUtil.isNotEmpty(drivers)) { | ||
| 613 | + driverMapper.updateDriverBaseInfoByJobCodes(drivers, 1); | ||
| 614 | + } | ||
| 615 | + return AjaxResult.success(); | ||
| 616 | + } | ||
| 617 | + | ||
| 591 | private void sendNotice(List<DriverSignInRecommendation> nowTimerList) { | 618 | private void sendNotice(List<DriverSignInRecommendation> nowTimerList) { |
| 592 | List<SysNotice> noticeList = new ArrayList<>(nowTimerList.size()); | 619 | List<SysNotice> noticeList = new ArrayList<>(nowTimerList.size()); |
| 593 | for (DriverSignInRecommendation item : nowTimerList) { | 620 | for (DriverSignInRecommendation item : nowTimerList) { |
Bsth-admin/src/main/java/com/ruoyi/job/DriverJob.java
| @@ -410,7 +410,7 @@ public class DriverJob implements InitializingBean { | @@ -410,7 +410,7 @@ public class DriverJob implements InitializingBean { | ||
| 410 | drivers.addAll(getDrivers(date, getPersonInfo(accessToken, 100, i))); | 410 | drivers.addAll(getDrivers(date, getPersonInfo(accessToken, 100, i))); |
| 411 | } | 411 | } |
| 412 | List<String> jobList = drivers.stream().map(Driver::getJobCode).collect(Collectors.toList()); | 412 | List<String> jobList = drivers.stream().map(Driver::getJobCode).collect(Collectors.toList()); |
| 413 | - DRIVER_SERVICE.updateDriverBaseInfoByJobCodes(drivers, 1); | 413 | +// DRIVER_SERVICE.updateDriverBaseInfoByJobCodes(drivers, 1); |
| 414 | // 删除离职员工 | 414 | // 删除离职员工 |
| 415 | handleNotEmptyJob(jobList); | 415 | handleNotEmptyJob(jobList); |
| 416 | // 过滤已经存在的员工工号 | 416 | // 过滤已经存在的员工工号 |
| @@ -442,7 +442,7 @@ public class DriverJob implements InitializingBean { | @@ -442,7 +442,7 @@ public class DriverJob implements InitializingBean { | ||
| 442 | log.info("更新人脸注册状态完毕"); | 442 | log.info("更新人脸注册状态完毕"); |
| 443 | } | 443 | } |
| 444 | 444 | ||
| 445 | - private static List<Driver> getDrivers(Date date, PersonnelResultResponseVo vo) { | 445 | + public static List<Driver> getDrivers(Date date, PersonnelResultResponseVo vo) { |
| 446 | List<Driver> drivers = vo.getData().stream().map(item -> { | 446 | List<Driver> drivers = vo.getData().stream().map(item -> { |
| 447 | Driver driver = new Driver(); | 447 | Driver driver = new Driver(); |
| 448 | FormData formData = item.getFormData(); | 448 | FormData formData = item.getFormData(); |
| @@ -460,7 +460,7 @@ public class DriverJob implements InitializingBean { | @@ -460,7 +460,7 @@ public class DriverJob implements InitializingBean { | ||
| 460 | return drivers; | 460 | return drivers; |
| 461 | } | 461 | } |
| 462 | 462 | ||
| 463 | - private static PersonnelResultResponseVo getPersonInfo(String accessToken, Integer pageSize, Integer currentPage) { | 463 | + public static PersonnelResultResponseVo getPersonInfo(String accessToken, Integer pageSize, Integer currentPage) { |
| 464 | RestTemplate restTemplate = new RestTemplate(); | 464 | RestTemplate restTemplate = new RestTemplate(); |
| 465 | String url = "https://api.dingtalk.com/v1.0/yida/forms/instances/search"; | 465 | String url = "https://api.dingtalk.com/v1.0/yida/forms/instances/search"; |
| 466 | PersonnelRequestVo vo = new PersonnelRequestVo(); | 466 | PersonnelRequestVo vo = new PersonnelRequestVo(); |