Commit 6073060076758619ac4ae5d6512a90831660a799

Authored by guzijian
1 parent d4bd94ed

fix: 修复分班无签退问题

ruoyi-admin/src/main/java/com/ruoyi/common/cache/NowSchedulingCache.java
... ... @@ -30,20 +30,20 @@ public class NowSchedulingCache {
30 30 private void cacheNowDaySchedulingInit() {
31 31 // 查询今天和昨天
32 32 for (int i = 0; i > -2; i--) {
33   - Map<String, List<DriverScheduling>> resultMap =new HashMap<>(800);
  33 + Map<String, List<DriverScheduling>> resultMap = new HashMap<>(800);
34 34 String date = ConstDateUtil.formatDate(ConstDateUtil.getTheSpecifiedNumberOfDaysOfTime(i));
35 35 List<DriverScheduling> schedulingList = schedulingMapper.queryToDay(date, null, null, null);
36   - handleResultMap(resultMap,schedulingList);
37   - cacheNowDayScheduling.put(date,resultMap);
  36 + handleResultMap(resultMap, schedulingList);
  37 + cacheNowDayScheduling.put(date, resultMap);
38 38 }
39 39 }
40 40  
41 41 private void handleResultMap(Map<String, List<DriverScheduling>> resultMap, List<DriverScheduling> schedulingList) {
42 42 for (DriverScheduling scheduling : schedulingList) {
43 43 List<DriverScheduling> list = resultMap.get(scheduling.getJobCode());
44   - if (CollectionUtil.isEmpty(list)){
45   - resultMap.put(scheduling.getJobCode(),new ArrayList<>(Arrays.asList(scheduling)));
46   - }else {
  44 + if (CollectionUtil.isEmpty(list)) {
  45 + resultMap.put(scheduling.getJobCode(), new ArrayList<>(Arrays.asList(scheduling)));
  46 + } else {
47 47 list.add(scheduling);
48 48 }
49 49 }
... ... @@ -52,19 +52,20 @@ public class NowSchedulingCache {
52 52 public void setCacheScheduling(String key, Map<String, List<DriverScheduling>> mapValue) {
53 53 cacheNowDayScheduling.put(key, mapValue);
54 54 }
55   - public Map<String,List<DriverScheduling>> getCacheScheduling(String key) {
56   - return cacheNowDayScheduling.get(key);
  55 +
  56 + public Map<String, List<DriverScheduling>> getCacheScheduling(String key) {
  57 + return cacheNowDayScheduling.get(key);
57 58 }
58 59  
59 60 public void removeCacheSchedulingByKey(String key) {
60 61 cacheNowDayScheduling.remove(key);
61 62 }
62 63  
63   - public List<String> getKeys(){
  64 + public List<String> getKeys() {
64 65 return new ArrayList<>(cacheNowDayScheduling.keySet());
65 66 }
66 67  
67   - public Integer size(){
  68 + public Integer size() {
68 69 return cacheNowDayScheduling.size();
69 70 }
70 71  
... ...
ruoyi-admin/src/main/java/com/ruoyi/common/cache/SchedulingCache.java
... ... @@ -30,7 +30,6 @@ public class SchedulingCache {
30 30 Logger log = LoggerFactory.getLogger(SchedulingCache.class);
31 31  
32 32  
33   -
34 33 // @Value("${api.url.getSchedulingInfoNew}")
35 34 private static final String getSchedulingInfoUrl = "http://101.95.136.206:9089/webservice/rest/schedule_real/sch_jk_db/%s/%s?timestamp=%d&nonce=%s&password=%s&sign=%s";
36 35 // @Value("${api.config.nonce}")
... ... @@ -50,7 +49,6 @@ public class SchedulingCache {
50 49 }
51 50  
52 51  
53   -
54 52 private void schedulingInit() {
55 53 String formatNowDate = ConstDateUtil.formatDate(new Date());
56 54 String url = getUrl(formatNowDate);
... ... @@ -182,11 +180,11 @@ public class SchedulingCache {
182 180 cacheScheduling.remove(key);
183 181 }
184 182  
185   - public List<String> getKeys(){
  183 + public List<String> getKeys() {
186 184 return new ArrayList<>(cacheScheduling.keySet());
187 185 }
188 186  
189   - public Integer size(){
  187 + public Integer size() {
190 188 return cacheScheduling.size();
191 189 }
192 190  
... ...
ruoyi-admin/src/main/java/com/ruoyi/controller/ApplicationUpdateController.java
... ... @@ -17,6 +17,7 @@ import java.io.IOException;
17 17  
18 18 /**
19 19 * 管理应用更新
  20 + *
20 21 * @author 20412
21 22 */
22 23 @RestController
... ... @@ -62,7 +63,7 @@ public class ApplicationUpdateController {
62 63  
63 64 @GetMapping("/checkDeviceHeart")
64 65 @ApiOperation("设备心跳检测")
65   - public Result<?> checkAppHeart(@Validated @ApiParam @ModelAttribute HeartPackageVo vo){
  66 + public Result<?> checkAppHeart(@Validated @ApiParam @ModelAttribute HeartPackageVo vo) {
66 67 appService.checkAppHeart(vo);
67 68 return Result.OK();
68 69 }
... ...
ruoyi-admin/src/main/java/com/ruoyi/controller/ReportController.java
... ... @@ -35,19 +35,19 @@ public class ReportController {
35 35 @ApiOperation("签到报表集合查询")
36 36 @GetMapping("/list")
37 37 public AjaxResult getList(HttpServletResponse response, @ApiParam @ModelAttribute ReportViewRequestVo requestVo) {
38   - return AjaxResult.success(reportService.getReportScrollViewTable(requestVo,response));
  38 + return AjaxResult.success(reportService.getReportScrollViewTable(requestVo, response));
39 39 }
40 40  
41 41 @ApiOperation("签到报表集合查询")
42 42 @GetMapping("/bigView")
43 43 public AjaxResult getBigView(HttpServletResponse response, @ApiParam @ModelAttribute ReportViewRequestVo requestVo) {
44   - return AjaxResult.success(reportService.getBigView(requestVo,response));
  44 + return AjaxResult.success(reportService.getBigView(requestVo, response));
45 45 }
46 46  
47 47 @ApiOperation("获取详情")
48 48 @GetMapping("/detail")
49 49 public AjaxResult getDetail(HttpServletResponse response, @ApiParam @ModelAttribute @Validated ReportViewRequestVo requestVo) {
50   - return AjaxResult.success(reportService.getReportDetail(requestVo,response));
  50 + return AjaxResult.success(reportService.getReportDetail(requestVo, response));
51 51 }
52 52  
53 53  
... ...
ruoyi-admin/src/main/java/com/ruoyi/driver/service/impl/DriverServiceImpl.java
... ... @@ -146,10 +146,21 @@ public class DriverServiceImpl implements IDriverService {
146 146 }
147 147 }
148 148  
  149 + LocalDateTime nowTime = ConstDateUtil.getLocalDateTimeByLongTime(now);
  150 + LocalDateTime signTime = ConstDateUtil.getLocalDateTimeByLongTime(timeMap.get(index).getTimestamps());
  151 + long range = ChronoUnit.MINUTES.between(signTime, nowTime);
  152 + // 如果当前记录靠近签退,但是未到签退小于合法范围 上一次记录未签到,则返回签到记录
  153 + if (BC_TYPE_IN.equals(timeMap.get(index).getBcType())
  154 + && range < -60L
  155 + && Objects.isNull(timeMap.get(index).getSignInId())
  156 + && Objects.isNull(timeMap.get(index - 1).getSignInId())) {
  157 + // 定位上次操作
  158 + index = index - 1;
  159 + }
  160 +
149 161 // 如果当前记录是异常的记录且还在目前还在签到范围内
150 162 if (!Objects.isNull(timeMap.get(index).getSignInId())) {
151 163 LocalDateTime endTime = ConstDateUtil.getLocalDateTimeByLongTime(timeMap.get(index).getTimestamps());
152   - LocalDateTime nowTime = ConstDateUtil.getLocalDateTimeByLongTime(now);
153 164 long nowBetween = ChronoUnit.MINUTES.between(endTime, nowTime);
154 165 // 如果当前有效范围内签到记录无效如酒精测试异常则重复当前操作
155 166 if ((Math.abs(nowBetween) <= 60) && timeMap.get(index).getExType().equals(SIGN_ALCOHOL_EX_NUM) && timeMap.get(index).getBcType().equals(BC_TYPE_OUT)) {
... ...
ruoyi-admin/src/main/java/com/ruoyi/pojo/response/ExportReportViewResponseVo.java
... ... @@ -129,33 +129,33 @@ public class ExportReportViewResponseVo {
129 129 }
130 130 }
131 131  
132   - private void handelSecond(List<DriverScheduling> driverSchedulings, int size) {
  132 + private void handelSecond(List<DriverScheduling> driverSchedulingList, int size) {
133 133 // 签到
134   - this.setSecondPlanSignInTime(new Date(driverSchedulings.get(2).getFcsjT()));
135   - this.setSecondActualSignInTime(driverSchedulings.get(2).getSignTime());
136   - this.setSecondAlcoholStringIn(ALCOHOL_FLAG_YES.equals(driverSchedulings.get(2).getAlcoholFlag()) ? ALCOHOL_FLAG_YES_STRING : ALCOHOL_FLAG_NO_STRING);
137   - this.setSecondAlcoholIntakeIn(driverSchedulings.get(2).getAlcoholIntake());
138   - this.setSecondSignInResultString(Objects.isNull(driverSchedulings.get(2).getSignInId()) ? "未签到" : driverSchedulings.get(2).getRemark());
  134 + this.setSecondPlanSignInTime(new Date(driverSchedulingList.get(2).getFcsjT()));
  135 + this.setSecondActualSignInTime(driverSchedulingList.get(2).getSignTime());
  136 + this.setSecondAlcoholStringIn(ALCOHOL_FLAG_YES.equals(driverSchedulingList.get(2).getAlcoholFlag()) ? ALCOHOL_FLAG_YES_STRING : ALCOHOL_FLAG_NO_STRING);
  137 + this.setSecondAlcoholIntakeIn(driverSchedulingList.get(2).getAlcoholIntake());
  138 + this.setSecondSignInResultString(Objects.isNull(driverSchedulingList.get(2).getSignInId()) ? "未签到" : driverSchedulingList.get(2).getRemark());
139 139 // 签退
140   - this.setSecondPlanSignOutTime(new Date(driverSchedulings.get(size - 1).getZdsjT()));
141   - this.setSecondActualSignOutTime(driverSchedulings.get(size - 1).getSignTime());
142   - this.setSecondAlcoholStringOut(ALCOHOL_FLAG_YES.equals(driverSchedulings.get(size - 1).getAlcoholFlag()) ? ALCOHOL_FLAG_YES_STRING : ALCOHOL_FLAG_NO_STRING);
143   - this.setSecondAlcoholIntakeOut(driverSchedulings.get(size - 1).getAlcoholIntake());
144   - this.setSecondSignInResultString(Objects.isNull(driverSchedulings.get(size -1).getSignInId()) ? "未签退" : driverSchedulings.get(size -1).getRemark());
  140 + this.setSecondPlanSignOutTime(new Date(driverSchedulingList.get(size - 1).getZdsjT()));
  141 + this.setSecondActualSignOutTime(driverSchedulingList.get(size - 1).getSignTime());
  142 + this.setSecondAlcoholStringOut(ALCOHOL_FLAG_YES.equals(driverSchedulingList.get(size - 1).getAlcoholFlag()) ? ALCOHOL_FLAG_YES_STRING : ALCOHOL_FLAG_NO_STRING);
  143 + this.setSecondAlcoholIntakeOut(driverSchedulingList.get(size - 1).getAlcoholIntake());
  144 + this.setSecondSignOutResultString(Objects.isNull(driverSchedulingList.get(size -1).getSignInId()) ? "未签退" : driverSchedulingList.get(size -1).getRemark());
145 145 }
146 146  
147   - private void handleFirst(List<DriverScheduling> driverSchedulings, int size) {
  147 + private void handleFirst(List<DriverScheduling> driverSchedulingList, int size) {
148 148 // 签到
149   - this.setPlanSignInTime(new Date(driverSchedulings.get(0).getFcsjT()));
150   - this.setActualSignInTime(driverSchedulings.get(0).getSignTime());
151   - this.setAlcoholStringIn(ALCOHOL_FLAG_YES.equals(driverSchedulings.get(0).getAlcoholFlag()) ? ALCOHOL_FLAG_YES_STRING : ALCOHOL_FLAG_NO_STRING);
152   - this.setAlcoholIntakeIn(driverSchedulings.get(0).getAlcoholIntake());
153   - this.setSignInResultString(Objects.isNull(driverSchedulings.get(0).getSignInId()) ? "未签到": driverSchedulings.get(0).getRemark());
  149 + this.setPlanSignInTime(new Date(driverSchedulingList.get(0).getFcsjT()));
  150 + this.setActualSignInTime(driverSchedulingList.get(0).getSignTime());
  151 + this.setAlcoholStringIn(ALCOHOL_FLAG_YES.equals(driverSchedulingList.get(0).getAlcoholFlag()) ? ALCOHOL_FLAG_YES_STRING : ALCOHOL_FLAG_NO_STRING);
  152 + this.setAlcoholIntakeIn(driverSchedulingList.get(0).getAlcoholIntake());
  153 + this.setSignInResultString(Objects.isNull(driverSchedulingList.get(0).getSignInId()) ? "未签到": driverSchedulingList.get(0).getRemark());
154 154 // 签退
155   - this.setPlanSignOutTime(new Date(driverSchedulings.get(size - 1).getZdsjT()));
156   - this.setActualSignOutTime(driverSchedulings.get(size - 1).getSignTime());
157   - this.setAlcoholStringOut(ALCOHOL_FLAG_YES.equals(driverSchedulings.get(size - 1).getAlcoholFlag()) ? ALCOHOL_FLAG_YES_STRING : ALCOHOL_FLAG_NO_STRING);
158   - this.setAlcoholIntakeOut(driverSchedulings.get(size - 1).getAlcoholIntake());
159   - this.setSignOutResultString(Objects.isNull(driverSchedulings.get(size - 1).getSignInId()) ? "未签退": driverSchedulings.get(size - 1).getRemark());
  155 + this.setPlanSignOutTime(new Date(driverSchedulingList.get(size - 1).getZdsjT()));
  156 + this.setActualSignOutTime(driverSchedulingList.get(size - 1).getSignTime());
  157 + this.setAlcoholStringOut(ALCOHOL_FLAG_YES.equals(driverSchedulingList.get(size - 1).getAlcoholFlag()) ? ALCOHOL_FLAG_YES_STRING : ALCOHOL_FLAG_NO_STRING);
  158 + this.setAlcoholIntakeOut(driverSchedulingList.get(size - 1).getAlcoholIntake());
  159 + this.setSignOutResultString(Objects.isNull(driverSchedulingList.get(size - 1).getSignInId()) ? "未签退": driverSchedulingList.get(size - 1).getRemark());
160 160 }
161 161 }
... ...
ruoyi-admin/src/main/java/com/ruoyi/service/ReportService.java
... ... @@ -64,7 +64,7 @@ public class ReportService {
64 64  
65 65 public List<ReportErrorResponseVo> getErrorReportList(ReportErrorRequestVo request) {
66 66 List<EquipmentExceptionResponseVo> list = exceptionMapper.selectEquipmentExceptionListByVo(request);
67   - return list.stream().map(item->{
  67 + return list.stream().map(item -> {
68 68 ReportErrorResponseVo vo = new ReportErrorResponseVo();
69 69 vo.setRemark(item.getRemark());
70 70 vo.setName(item.getPersonnelName());
... ... @@ -80,11 +80,10 @@ public class ReportService {
80 80 }
81 81  
82 82  
83   -
84 83 public List<ExportReportViewResponseVo> exportReportList(ReportViewRequestVo requestVo, HttpServletResponse response) {
85 84 // 处理天
86   - if (requestVo.getExportFlag().equals(DAY)){
87   - return getDayReportTableResponseVo(requestVo.getDate(),response);
  85 + if (requestVo.getExportFlag().equals(DAY)) {
  86 + return getDayReportTableResponseVo(requestVo.getDate(), response);
88 87 }
89 88 // 处理月
90 89 else if (requestVo.getExportFlag().equals(MONTH)) {
... ... @@ -95,26 +94,26 @@ public class ReportService {
95 94  
96 95 private List<ExportReportViewResponseVo> getDayReportTableResponseVo(String date, HttpServletResponse response) {
97 96 List<DriverScheduling> schedulingList = schedulingMapper.queryToDay(date, null, null, null);
98   - Map<String,List<DriverScheduling>> resultMap = new HashMap<>(800);
  97 + Map<String, List<DriverScheduling>> resultMap = new HashMap<>(800);
99 98 List<ExportReportViewResponseVo> vo = new ArrayList<>(800);
100   - handleResultMap(date,resultMap,schedulingList);
101   - handleResultList(vo,resultMap);
  99 + handleResultMap(date, resultMap, schedulingList);
  100 + handleResultList(vo, resultMap);
102 101 return vo;
103 102 }
104 103  
105 104 private void handleResultList(List<ExportReportViewResponseVo> vo, Map<String, List<DriverScheduling>> resultMap) {
106 105 for (String key : resultMap.keySet()) {
107 106 resultMap.get(key).sort(Comparator.comparing(DriverScheduling::getFcsjT));
108   - vo.add(new ExportReportViewResponseVo(resultMap.get(key)) );
  107 + vo.add(new ExportReportViewResponseVo(resultMap.get(key)));
109 108 }
110 109 }
111 110  
112 111 private void handleResultMap(@NotBlank String date, Map<String, List<DriverScheduling>> resultMap, List<DriverScheduling> schedulingList) {
113 112 for (DriverScheduling item : schedulingList) {
114 113 String key = date + item.getJobCode();
115   - if (Objects.isNull(resultMap.get(key))){
116   - resultMap.put(key,new ArrayList<>(Arrays.asList(item)));
117   - }else {
  114 + if (Objects.isNull(resultMap.get(key))) {
  115 + resultMap.put(key, new ArrayList<>(Arrays.asList(item)));
  116 + } else {
118 117 resultMap.get(key).add(item);
119 118 }
120 119 }
... ... @@ -136,7 +135,7 @@ public class ReportService {
136 135 LocalDate formatDate = LocalDate.parse(dateString, formatter);
137 136 int month = formatDate.getMonthValue();
138 137 int year = formatDate.getYear();
139   - YearMonth yearMonth = YearMonth.of(year,month);
  138 + YearMonth yearMonth = YearMonth.of(year, month);
140 139  
141 140 // 获取当前月份的第一天和最后一天日期
142 141 LocalDate firstDay = yearMonth.atDay(1);
... ...
ruoyi-admin/src/main/java/com/ruoyi/service/SchedulingService.java
... ... @@ -217,6 +217,7 @@ public class SchedulingService {
217 217 int planSignOutCount = 0;
218 218 int actualSignOutCount = 0;
219 219 BeanUtils.copyProperties(list.get(0), vo);
  220 + String exString = NO_EX;
220 221 for (DriverScheduling scheduling : list) {
221 222 // 获取计划签到|签退次数
222 223 if (scheduling.getBcType().equals(BC_TYPE_OUT)) {
... ... @@ -224,19 +225,20 @@ public class SchedulingService {
224 225 if (!Objects.isNull(scheduling.getSignInId())) {
225 226 actualSignInCount = actualSignInCount + 1;
226 227 }
  228 +
227 229 } else {
228 230 planSignOutCount = planSignOutCount + 1;
229 231 if (!Objects.isNull(scheduling.getSignInId())) {
230 232 actualSignOutCount = actualSignOutCount + 1;
231 233 }
232 234 }
  235 +
233 236 // 判断是否异常
234 237 if (!SIGN_NO_EX_NUM.equals(scheduling.getExType())) {
235   - vo.setExString(HAVE_EX);
236   - } else {
237   - vo.setExString(NO_EX);
  238 + exString = HAVE_EX;
238 239 }
239 240 }
  241 + vo.setExString(exString);
240 242 vo.setPlanSignInCount(planSignInCount);
241 243 vo.setPlanSignOutCount(planSignOutCount);
242 244 vo.setActualSignInCount(actualSignInCount);
... ...