Commit 08088c357187184245449facb32e53293a8c6a16
1 parent
fac64741
酒测未通过审核
Showing
6 changed files
with
94 additions
and
46 deletions
Bsth-admin/src/main/java/com/ruoyi/controller/dss/KeyBoxController.java
| ... | ... | @@ -749,6 +749,7 @@ public class KeyBoxController extends BaseController { |
| 749 | 749 | location.setScheduleDate(DateUtil.shortDate(dto.getTime())); |
| 750 | 750 | location.setType(item.getState()); |
| 751 | 751 | location.setPlate(item.getPlate()); |
| 752 | + location.setTime(dto.getTime()); | |
| 752 | 753 | if (CollectionUtils.isNotEmpty(schedulings)) { |
| 753 | 754 | Optional<LinggangKeyWorkLocation> opt = schedulings.stream().filter(s -> Objects.equals(item.getKey(), s.getCabinetNo())).findFirst(); |
| 754 | 755 | if (opt.isPresent()) { | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/domain/key/location/LinggangKeyWorkLocation.java
| ... | ... | @@ -114,6 +114,12 @@ public class LinggangKeyWorkLocation { |
| 114 | 114 | @TableField(exist = false) |
| 115 | 115 | private Set<Integer> types; |
| 116 | 116 | |
| 117 | + @TableField(exist = false) | |
| 118 | + private Date time; | |
| 119 | + | |
| 120 | + @TableField(exist = false) | |
| 121 | + private Long zdsjT; | |
| 122 | + | |
| 117 | 123 | |
| 118 | 124 | public enum LinggangKeyWorkLocationEventTypeEnum { |
| 119 | 125 | TAKE_OUT(0, "取出"), | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/job/DriverJob.java
| ... | ... | @@ -271,15 +271,6 @@ public class DriverJob implements InitializingBean { |
| 271 | 271 | LinggangScheduling scheduling = new LinggangScheduling(); |
| 272 | 272 | scheduling.setStartScheduleDate(DateUtil.shortDate(date)); |
| 273 | 273 | scheduling.setEndScheduleDate(DateUtils.addDays(scheduling.getStartScheduleDate(), 1)); |
| 274 | - scheduling.setType(type); | |
| 275 | - if(Objects.isNull(schedulingService)){ | |
| 276 | - schedulingService = SpringUtils.getBean(LinggangSchedulingService.class); | |
| 277 | - } | |
| 278 | - Integer count = schedulingService.countId(scheduling); | |
| 279 | - if (Objects.nonNull(count) && count > 0) { | |
| 280 | - log.info("[{}]排班数据已经存在", date); | |
| 281 | - return; | |
| 282 | - } | |
| 283 | 274 | |
| 284 | 275 | Set<Long> idSets = null; |
| 285 | 276 | if (isSameDay) { |
| ... | ... | @@ -291,6 +282,18 @@ public class DriverJob implements InitializingBean { |
| 291 | 282 | } |
| 292 | 283 | } |
| 293 | 284 | |
| 285 | + scheduling.setType(type); | |
| 286 | + if(Objects.isNull(schedulingService)){ | |
| 287 | + schedulingService = SpringUtils.getBean(LinggangSchedulingService.class); | |
| 288 | + } | |
| 289 | + Integer count = schedulingService.countId(scheduling); | |
| 290 | + if (Objects.nonNull(count) && count > 0) { | |
| 291 | + log.info("[{}]排班数据已经存在", date); | |
| 292 | + return; | |
| 293 | + } | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 294 | 297 | |
| 295 | 298 | // String url = getSchedulingInfoPlan; |
| 296 | 299 | try { | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/mapper/key/location/LinggangKeyWorkLocationMapper.java
| ... | ... | @@ -6,7 +6,9 @@ import org.apache.ibatis.annotations.Mapper; |
| 6 | 6 | import org.apache.ibatis.annotations.Param; |
| 7 | 7 | |
| 8 | 8 | import java.util.Collection; |
| 9 | +import java.util.Date; | |
| 9 | 10 | import java.util.List; |
| 11 | +import java.util.Map; | |
| 10 | 12 | |
| 11 | 13 | |
| 12 | 14 | @Mapper |
| ... | ... | @@ -20,4 +22,6 @@ public interface LinggangKeyWorkLocationMapper extends BaseMapper<LinggangKeyWor |
| 20 | 22 | List<LinggangKeyWorkLocation> listOfDeviceKeyIdScheduleDate(@Param("localtions") List<LinggangKeyWorkLocation> locations); |
| 21 | 23 | |
| 22 | 24 | List<LinggangKeyWorkLocation> listRecent(@Param("localtions") Collection<LinggangKeyWorkLocation> locations); |
| 25 | + | |
| 26 | + List<LinggangKeyWorkLocation> listRecentDates(@Param("keyInfoIds") Collection<Integer> keyInfoIds, @Param("dates")List<Map<String, Date>> dates); | |
| 23 | 27 | } |
| 24 | 28 | \ No newline at end of file | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/service/impl/key/location/LinggangKeyWorkLocationServiceImpl.java
| ... | ... | @@ -77,7 +77,7 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 77 | 77 | LambdaQueryWrapper<LinggangKeyWorkLocation> countWrapper = new LambdaQueryWrapper<>(entity); |
| 78 | 78 | countWrapper.select(LinggangKeyWorkLocation::getId); |
| 79 | 79 | switchTime(entity, countWrapper); |
| 80 | - switchTypes(entity,countWrapper); | |
| 80 | + switchTypes(entity, countWrapper); | |
| 81 | 81 | int count = count(countWrapper); |
| 82 | 82 | |
| 83 | 83 | List<LinggangKeyWorkLocation> lists = Collections.emptyList(); |
| ... | ... | @@ -85,7 +85,7 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 85 | 85 | PageHelper.startPage((int) page.getCurrent(), (int) page.getSize(), false); |
| 86 | 86 | LambdaQueryWrapper<LinggangKeyWorkLocation> selectWrapper = new LambdaQueryWrapper<>(entity); |
| 87 | 87 | switchTime(entity, selectWrapper); |
| 88 | - switchTypes(entity,selectWrapper); | |
| 88 | + switchTypes(entity, selectWrapper); | |
| 89 | 89 | orderColumn(selectWrapper, orderEntity); |
| 90 | 90 | lists = list(selectWrapper); |
| 91 | 91 | } |
| ... | ... | @@ -110,9 +110,9 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - private static void switchTypes(LinggangKeyWorkLocation entity, LambdaQueryWrapper<LinggangKeyWorkLocation> wrapper){ | |
| 114 | - if(CollectionUtils.isNotEmpty(entity.getTypes())){ | |
| 115 | - wrapper.in(LinggangKeyWorkLocation::getType,entity.getTypes()); | |
| 113 | + private static void switchTypes(LinggangKeyWorkLocation entity, LambdaQueryWrapper<LinggangKeyWorkLocation> wrapper) { | |
| 114 | + if (CollectionUtils.isNotEmpty(entity.getTypes())) { | |
| 115 | + wrapper.in(LinggangKeyWorkLocation::getType, entity.getTypes()); | |
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | |
| ... | ... | @@ -120,7 +120,7 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 120 | 120 | public List<LinggangKeyWorkLocation> list(LinggangKeyWorkLocation entity) { |
| 121 | 121 | LambdaQueryWrapper<LinggangKeyWorkLocation> wrapper = new LambdaQueryWrapper<>(entity); |
| 122 | 122 | switchTime(entity, wrapper); |
| 123 | - switchTypes(entity,wrapper); | |
| 123 | + switchTypes(entity, wrapper); | |
| 124 | 124 | return list(wrapper); |
| 125 | 125 | } |
| 126 | 126 | |
| ... | ... | @@ -136,15 +136,15 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 136 | 136 | @Override |
| 137 | 137 | public List<LinggangKeyWorkLocation> listRecent(LinggangKeyWorkLocation entity, Collection<Long> schedulingIds) { |
| 138 | 138 | LambdaQueryWrapper<LinggangKeyWorkLocation> wrapper = null; |
| 139 | - if(Objects.isNull(entity)){ | |
| 139 | + if (Objects.isNull(entity)) { | |
| 140 | 140 | wrapper = new LambdaQueryWrapper<>(); |
| 141 | - }else { | |
| 141 | + } else { | |
| 142 | 142 | wrapper = new LambdaQueryWrapper<>(entity); |
| 143 | 143 | } |
| 144 | 144 | switchTime(entity, wrapper); |
| 145 | 145 | |
| 146 | - if(CollectionUtils.isNotEmpty(schedulingIds)){ | |
| 147 | - wrapper.in(LinggangKeyWorkLocation::getSchedulingId,schedulingIds); | |
| 146 | + if (CollectionUtils.isNotEmpty(schedulingIds)) { | |
| 147 | + wrapper.in(LinggangKeyWorkLocation::getSchedulingId, schedulingIds); | |
| 148 | 148 | } |
| 149 | 149 | return list(wrapper); |
| 150 | 150 | } |
| ... | ... | @@ -192,22 +192,27 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 192 | 192 | return linggangKeyWorkLocationMapper.listRecent(locations); |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - private List<LinggangKeyWorkLocation> listRecentDates(Collection<Date> dates,Set<Integer> keyInfoIds) { | |
| 195 | + private List<LinggangKeyWorkLocation> listRecentDates(Collection<Date> dates, Set<Integer> keyInfoIds) { | |
| 196 | 196 | if (CollectionUtils.isEmpty(dates)) { |
| 197 | 197 | return Collections.emptyList(); |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - LambdaQueryWrapper<LinggangKeyWorkLocation> wrapper = new LambdaQueryWrapper<>(); | |
| 201 | - if(CollectionUtils.isNotEmpty(keyInfoIds)){ | |
| 202 | - wrapper.in(LinggangKeyWorkLocation::getKeyInfoId,keyInfoIds); | |
| 200 | + if (CollectionUtils.isEmpty(keyInfoIds)) { | |
| 201 | + keyInfoIds = null; | |
| 203 | 202 | } |
| 203 | + | |
| 204 | + List<Map<String,Date>> dateMaps = new ArrayList<>(); | |
| 204 | 205 | for (Date date : dates) { |
| 205 | - Date endDate = DateUtils.addDays(date,1); | |
| 206 | - wrapper.or().between(LinggangKeyWorkLocation::getScheduleDate,date,endDate); | |
| 206 | + Date endDate = DateUtils.addDays(date, 1); | |
| 207 | + | |
| 208 | + Map<String,Date> maps = new HashMap<>(); | |
| 209 | + maps.put("startDate",date); | |
| 210 | + maps.put("endDate",endDate); | |
| 211 | + dateMaps.add(maps); | |
| 207 | 212 | |
| 208 | 213 | } |
| 209 | 214 | |
| 210 | - return list(wrapper); | |
| 215 | + return linggangKeyWorkLocationMapper.listRecentDates(keyInfoIds,dateMaps); | |
| 211 | 216 | } |
| 212 | 217 | |
| 213 | 218 | // @Override |
| ... | ... | @@ -268,22 +273,22 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 268 | 273 | |
| 269 | 274 | @Override |
| 270 | 275 | @Transactional(rollbackFor = Exception.class) |
| 271 | - public boolean insertJob(String timeStr,Set<Long> schedulingIds) { | |
| 276 | + public boolean insertJob(String timeStr, Set<Long> schedulingIds) { | |
| 272 | 277 | try { |
| 273 | - if(CollectionUtils.isNotEmpty(schedulingIds)){ | |
| 274 | - List<LinggangKeyWorkLocation> workLocations = listRecent(null,schedulingIds); | |
| 275 | - if(CollectionUtils.isNotEmpty(workLocations)){ | |
| 276 | - Set<Long> ids = workLocations.stream().map(LinggangKeyWorkLocation::getId).collect(Collectors.toSet()); | |
| 277 | - if(CollectionUtils.isNotEmpty(ids)){ | |
| 278 | - removeByIds(ids); | |
| 279 | - } | |
| 280 | - } | |
| 278 | + if (CollectionUtils.isNotEmpty(schedulingIds)) { | |
| 279 | + List<LinggangKeyWorkLocation> workLocations = listRecent(null, schedulingIds); | |
| 280 | + if (CollectionUtils.isNotEmpty(workLocations)) { | |
| 281 | + Set<Long> ids = workLocations.stream().map(LinggangKeyWorkLocation::getId).collect(Collectors.toSet()); | |
| 282 | + if (CollectionUtils.isNotEmpty(ids)) { | |
| 283 | + removeByIds(ids); | |
| 284 | + } | |
| 285 | + } | |
| 281 | 286 | } |
| 282 | 287 | |
| 283 | 288 | Date date = DateUtil.YYYY_MM_DD_LINK.parse(timeStr); |
| 284 | 289 | LinggangKeyWorkLocation workLocation = new LinggangKeyWorkLocation(); |
| 285 | 290 | workLocation.setStartScheduleDate(date); |
| 286 | - workLocation.setEndScheduleDate(DateUtils.addDays(date,1)); | |
| 291 | + workLocation.setEndScheduleDate(DateUtils.addDays(date, 1)); | |
| 287 | 292 | Integer count = countId(workLocation); |
| 288 | 293 | if (Objects.nonNull(count) && count > 0) { |
| 289 | 294 | log.error("当天的数据已经存在:[{}];[{}]", timeStr, count); |
| ... | ... | @@ -353,8 +358,9 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 353 | 358 | |
| 354 | 359 | public boolean update(LinggangKeyWorkLocation location) { |
| 355 | 360 | LambdaUpdateWrapper<LinggangKeyWorkLocation> wrapper = new LambdaUpdateWrapper<>(); |
| 356 | - wrapper.set(LinggangKeyWorkLocation::getEventType, location.getEventType()).set(LinggangKeyWorkLocation::getUpdateTime, new Date()).set(LinggangKeyWorkLocation::getType, location.getType()); | |
| 357 | - wrapper.eq(LinggangKeyWorkLocation::getId, location.getId()).ne(LinggangKeyWorkLocation::getType, location.getType()); | |
| 361 | + wrapper.set(LinggangKeyWorkLocation::getEventType, location.getEventType()).set(LinggangKeyWorkLocation::getUpdateTime, new Date()) | |
| 362 | + .set(LinggangKeyWorkLocation::getType, location.getType()).set(LinggangKeyWorkLocation::getDevice,location.getDevice()); | |
| 363 | + wrapper.eq(LinggangKeyWorkLocation::getId, location.getId()); | |
| 358 | 364 | |
| 359 | 365 | return update(wrapper); |
| 360 | 366 | } |
| ... | ... | @@ -438,27 +444,26 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 438 | 444 | |
| 439 | 445 | |
| 440 | 446 | private ResponseResult<List<LinggangKeyWorkLocation>> checkTaskKey(List<LinggangKeyWorkLocation> locations, LinggangKeyWorkLocation.LinggangKeyWorkLocationTypeEnum typeEnum) { |
| 441 | - Set<Integer> keyCodes = locations.stream().filter(l->Objects.nonNull(l.getKeyInfoId())).map(LinggangKeyWorkLocation::getKeyInfoId).collect(Collectors.toSet()); | |
| 447 | + Set<Integer> keyCodes = locations.stream().filter(l -> Objects.nonNull(l.getKeyInfoId())).map(LinggangKeyWorkLocation::getKeyInfoId).collect(Collectors.toSet()); | |
| 442 | 448 | |
| 443 | 449 | List<KeyInfo> keyInfos = null; |
| 444 | - if(CollectionUtils.isNotEmpty(keyCodes)){ | |
| 450 | + if (CollectionUtils.isNotEmpty(keyCodes)) { | |
| 445 | 451 | keyInfos = keyInfoService.listByIds(keyCodes); |
| 446 | 452 | } |
| 447 | 453 | |
| 448 | 454 | Set<Integer> keyIds = null; |
| 449 | 455 | Set<String> plates = locations.stream().map(LinggangKeyWorkLocation::getPlate).collect(Collectors.toSet()); |
| 450 | - if(CollectionUtils.isNotEmpty(plates)){ | |
| 456 | + if (CollectionUtils.isNotEmpty(plates)) { | |
| 451 | 457 | keyInfos = keyInfoService.listPlateNums(plates); |
| 452 | - if(CollectionUtils.isNotEmpty(keyInfos)){ | |
| 458 | + if (CollectionUtils.isNotEmpty(keyInfos)) { | |
| 453 | 459 | keyIds = keyInfos.stream().map(KeyInfo::getId).collect(Collectors.toSet()); |
| 454 | 460 | } |
| 455 | 461 | } |
| 456 | 462 | |
| 457 | - | |
| 458 | 463 | Set<Date> dates = locations.stream().map(LinggangKeyWorkLocation::getScheduleDate).collect(Collectors.toSet()); |
| 459 | 464 | |
| 460 | 465 | |
| 461 | - List<LinggangKeyWorkLocation> sources = listRecentDates(dates,keyIds).stream().filter(s -> !Objects.equals(s.getType(), typeEnum.getValue())).collect(Collectors.toList()); | |
| 466 | + List<LinggangKeyWorkLocation> sources = listRecentDates(dates, keyIds).stream().filter(s -> !Objects.equals(s.getType(), typeEnum.getValue())).collect(Collectors.toList()); | |
| 462 | 467 | if (CollectionUtils.isEmpty(sources)) { |
| 463 | 468 | return ResponseResult.error404("无法找到钥匙归还信息"); |
| 464 | 469 | } |
| ... | ... | @@ -481,6 +486,13 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 481 | 486 | return s; |
| 482 | 487 | }).collect(Collectors.toList()); |
| 483 | 488 | |
| 489 | + Set<Long> schedulingIds = sources.stream().map(LinggangKeyWorkLocation::getSchedulingId).collect(Collectors.toSet()); | |
| 490 | + List<LinggangScheduling> schedulings = schedulingService.listByIds(schedulingIds); | |
| 491 | + if (CollectionUtils.isEmpty(schedulings)) { | |
| 492 | + return ResponseResult.error404("无法找到排班信息"); | |
| 493 | + } | |
| 494 | + | |
| 495 | + | |
| 484 | 496 | List<LinggangKeyWorkLocation> workLocations = sources; |
| 485 | 497 | |
| 486 | 498 | locations = locations.stream().map(l -> { |
| ... | ... | @@ -491,8 +503,14 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 491 | 503 | if (optional.isPresent()) { |
| 492 | 504 | l.setId(optional.get().getId()); |
| 493 | 505 | } |
| 506 | + Optional<LinggangScheduling> scheOpt = schedulings.stream().filter(s1->Objects.equals(s1.getId(),l.getSchedulingId())).findFirst(); | |
| 507 | + if(scheOpt.isPresent()){ | |
| 508 | + if(l.getTime().getTime()<scheOpt.get().getZdsjT()){ | |
| 509 | + return null; | |
| 510 | + } | |
| 511 | + } | |
| 494 | 512 | return l; |
| 495 | - }).collect(Collectors.toList()); | |
| 513 | + }).filter(obj->Objects.nonNull(obj)).collect(Collectors.toList()); | |
| 496 | 514 | |
| 497 | 515 | |
| 498 | 516 | return ResponseResult.success(locations); |
| ... | ... | @@ -765,7 +783,7 @@ public class LinggangKeyWorkLocationServiceImpl extends ServiceImpl<LinggangKeyW |
| 765 | 783 | private List<LinggangScheduling> querySchedulingByTiime(Date date) { |
| 766 | 784 | LinggangScheduling scheduling = new LinggangScheduling(); |
| 767 | 785 | scheduling.setStartScheduleDate(DateUtil.shortDate(date)); |
| 768 | - scheduling.setEndScheduleDate(DateUtils.addDays(scheduling.getStartScheduleDate(),1)); | |
| 786 | + scheduling.setEndScheduleDate(DateUtils.addDays(scheduling.getStartScheduleDate(), 1)); | |
| 769 | 787 | scheduling.setBcType(BC_TYPE_OUT); |
| 770 | 788 | List<LinggangScheduling> schedulings = schedulingService.list(scheduling); |
| 771 | 789 | if (CollectionUtils.isEmpty(schedulings)) { | ... | ... |
Bsth-admin/src/main/resources/mapper/key/location/LinggangKeyWorkLocationMapper.xml
| ... | ... | @@ -40,6 +40,22 @@ |
| 40 | 40 | <include refid="where"></include> |
| 41 | 41 | </foreach> |
| 42 | 42 | </select> |
| 43 | + <select id="listRecentDates" resultType="com.ruoyi.domain.key.location.LinggangKeyWorkLocation"> | |
| 44 | + select <include refid="columns"></include> from key_work_location | |
| 45 | + where 1=1 | |
| 46 | + <if test="null != keyInfoIds"> | |
| 47 | + and key_info_id in | |
| 48 | + <foreach collection="keyInfoIds" item="item" separator="," open="(" close=")">#{item}</foreach> | |
| 49 | + </if> | |
| 50 | + | |
| 51 | + <if test="null!=dates"> | |
| 52 | + and ( | |
| 53 | + <foreach collection="dates" item="item" separator="or " open="(" close=")"> | |
| 54 | + schedule_date between #{item.startDate} and #{item.endDate} | |
| 55 | + </foreach> | |
| 56 | + ) | |
| 57 | + </if> | |
| 58 | + </select> | |
| 43 | 59 | |
| 44 | 60 | <sql id="columns"> |
| 45 | 61 | id | ... | ... |