Commit f1152152b6e62256c91d9cfed0e464c3d0be212e

Authored by guzijian
1 parent 872f2e70

fix: 新增操作推荐,报表记录

Showing 35 changed files with 997 additions and 350 deletions
ruoyi-admin/src/main/java/com/ruoyi/common/ConstDriverProperties.java
... ... @@ -9,4 +9,14 @@ public interface ConstDriverProperties {
9 9  
10 10  
11 11 String PERSONNEL_POSTS_SALES = "售票员";
  12 +
  13 + /**
  14 + * 进站
  15 + */
  16 + String BC_TYPE_IN = "in";
  17 + /**
  18 + * 出站
  19 + */
  20 + String BC_TYPE_OUT = "out";
  21 +
12 22 }
... ...
ruoyi-admin/src/main/java/com/ruoyi/common/ConstSignInConstSignInProperties.java
... ... @@ -5,6 +5,14 @@ package com.ruoyi.common;
5 5 * @author 20412
6 6 */
7 7 public interface ConstSignInConstSignInProperties {
  8 + Integer SIGN_NO_EX_NUM = 0;
  9 + String SIGN_NO_EX_NUM_STRING = "无异常";
  10 + Integer SIGN_TIME_OUT_EX_NUM = 1;
  11 + String SIGN_TIME_OUT_EX_NUM_STRING = "超时异常";
  12 + Integer SIGN_NO_SCHEDULING_EX_NUM = 2;
  13 + String SIGN_NO_SCHEDULING_EX_NUM_STRING = "无排班异常";
  14 + Integer SIGN_ALCOHOL_EX_NUM = 3;
  15 + String SIGN_ALCOHOL_EX_NUM_STRING = "酒精超标异常";
8 16 /**
9 17 * 未完成人脸注册
10 18 */
... ... @@ -25,10 +33,11 @@ public interface ConstSignInConstSignInProperties {
25 33 * 签到
26 34 */
27 35 Integer SIGN_IN = 1;
  36 +
28 37 /**
29 38 * 签退
30 39 */
31   - Integer SIGNIN_OUT = 2;
  40 + Integer SIGN_OUT = 2;
32 41  
33 42 String SIGN_IN_STRING = "签到";
34 43 String SIGN_IN_OUT_STRING = "签退";
... ...
ruoyi-admin/src/main/java/com/ruoyi/common/ErrorTypeProperties.java
... ... @@ -8,6 +8,7 @@ public interface ErrorTypeProperties {
8 8 String EQUIPMENT_ERROR = "设备异常";
9 9 String ALCOHOL_SIGN_IN_ERROR = "酒精测试超标,";
10 10 String WORK_DAY_ERROR = "当天没有排班,";
11   - String SIGN_IN_TIMEOUT = "签到超时,";
  11 + String SIGN_IN_TIMEOUT = "签到异常,";
  12 + String SIGN_OUT_TIMEOUT = "签退异常,";
12 13  
13 14 }
... ...
ruoyi-admin/src/main/java/com/ruoyi/common/ReportProperties.java 0 → 100644
  1 +package com.ruoyi.common;
  2 +
  3 +public interface ReportProperties {
  4 + Integer DAY = 1;
  5 + Integer MONTH = 2;
  6 +}
... ...
ruoyi-admin/src/main/java/com/ruoyi/common/cache/SchedulingCache.java
1 1 package com.ruoyi.common.cache;
2 2  
3   -import com.ruoyi.job.DriverJob;
4   -import com.ruoyi.pojo.response.ResponseScheduling;
  3 +import com.ruoyi.pojo.response.ResponseSchedulingDto;
5 4 import com.ruoyi.utils.ConstDateUtil;
6 5 import org.slf4j.Logger;
7 6 import org.slf4j.LoggerFactory;
8   -import org.springframework.beans.factory.annotation.Value;
9 7 import org.springframework.core.ParameterizedTypeReference;
10 8 import org.springframework.http.HttpMethod;
11 9 import org.springframework.stereotype.Component;
... ... @@ -37,7 +35,7 @@ public class SchedulingCache {
37 35 private static final String PASSWORD = "c4dd3d8cb9a82f6d6a625818618b28ca7bebb464";
38 36 @Resource
39 37 private SchedulingCache schedulingCache;
40   - private static ConcurrentHashMap<String, Map<String, List<ResponseScheduling>>> cacheScheduling = new ConcurrentHashMap<>();
  38 + private static ConcurrentHashMap<String, Map<String, List<ResponseSchedulingDto>>> cacheScheduling = new ConcurrentHashMap<>();
41 39  
42 40 public SchedulingCache() {
43 41 log.info("项目启动加载中-----");
... ... @@ -48,12 +46,12 @@ public class SchedulingCache {
48 46 String formatNowDate = ConstDateUtil.formatDate(new Date());
49 47 String url = getUrl(formatNowDate);
50 48 log.info("初始化排班数据:{}", formatNowDate);
51   - saveSchedulingToRedis(url, formatNowDate);
  49 + saveSchedulingToCache(url, formatNowDate);
52 50 log.info("开始获取{}的排班数据", formatNowDate);
53 51 String formatYesterdayDate = ConstDateUtil.formatDate(ConstDateUtil.getTheSpecifiedNumberOfDaysOfTime(-1));
54 52 url = getUrl(formatYesterdayDate);
55 53 log.info("初始化排班数据:{}", formatYesterdayDate);
56   - saveSchedulingToRedis(url, formatYesterdayDate);
  54 + saveSchedulingToCache(url, formatYesterdayDate);
57 55 log.info("开始获取{}的排班数据", formatYesterdayDate);
58 56 }
59 57  
... ... @@ -110,16 +108,16 @@ public class SchedulingCache {
110 108 }
111 109  
112 110  
113   - private Map<String, List<ResponseScheduling>> saveSchedulingToRedis(String getSchedulingInfoUrl, String dateKey) {
  111 + private Map<String, List<ResponseSchedulingDto>> saveSchedulingToCache(String getSchedulingInfoUrl, String dateKey) {
114 112 log.info("开始拉取排班:{}", dateKey);
115   - List<ResponseScheduling> originSchedulingList = new RestTemplate().exchange(
  113 + List<ResponseSchedulingDto> originSchedulingList = new RestTemplate().exchange(
116 114 getSchedulingInfoUrl,
117 115 HttpMethod.GET,
118 116 null,
119   - new ParameterizedTypeReference<List<ResponseScheduling>>() {
  117 + new ParameterizedTypeReference<List<ResponseSchedulingDto>>() {
120 118 }).getBody();
121 119  
122   - Map<String, List<ResponseScheduling>> driverSchedulingMap = new HashMap<>(200);
  120 + Map<String, List<ResponseSchedulingDto>> driverSchedulingMap = new HashMap<>(200);
123 121 // 按照员工工号来获取排班信息
124 122 originSchedulingList = originSchedulingList.stream()
125 123 .map(subItem -> {
... ... @@ -138,8 +136,8 @@ public class SchedulingCache {
138 136 // 排序
139 137 List<String> keys = new ArrayList<>(driverSchedulingMap.keySet());
140 138 for (String key : keys) {
141   - List<ResponseScheduling> schedulingList = driverSchedulingMap.get(key);
142   - schedulingList.sort(Comparator.comparing(ResponseScheduling::getFcsjT));
  139 + List<ResponseSchedulingDto> schedulingList = driverSchedulingMap.get(key);
  140 + schedulingList.sort(Comparator.comparing(ResponseSchedulingDto::getFcsjT));
143 141 }
144 142 // 存入数据库
145 143 // DRIVER_SERVICE.saveDriverScheduling(originSchedulingList);
... ... @@ -150,10 +148,10 @@ public class SchedulingCache {
150 148 return driverSchedulingMap;
151 149 }
152 150  
153   - private void splitSaveScheduling(Map<String, List<ResponseScheduling>> driverSchedulingMap, String jobCode, ResponseScheduling item) {
  151 + private void splitSaveScheduling(Map<String, List<ResponseSchedulingDto>> driverSchedulingMap, String jobCode, ResponseSchedulingDto item) {
154 152 if (!Objects.isNull(jobCode))
155 153 if (Objects.isNull(driverSchedulingMap.get(jobCode))) {
156   - List<ResponseScheduling> oneDriverScheduling = new ArrayList<>();
  154 + List<ResponseSchedulingDto> oneDriverScheduling = new ArrayList<>();
157 155 oneDriverScheduling.add(item);
158 156 driverSchedulingMap.put(jobCode, oneDriverScheduling);
159 157 } else {
... ... @@ -169,7 +167,7 @@ public class SchedulingCache {
169 167 return configMap;
170 168 }
171 169  
172   - public void setCacheScheduling(String key, Map<String, List<ResponseScheduling>> mapValue) {
  170 + public void setCacheScheduling(String key, Map<String, List<ResponseSchedulingDto>> mapValue) {
173 171 cacheScheduling.put(key, mapValue);
174 172 }
175 173  
... ... @@ -177,11 +175,11 @@ public class SchedulingCache {
177 175 cacheScheduling.remove(key);
178 176 }
179 177  
180   - public List<ResponseScheduling> getCacheSchedulingMapValueByHKey(String key, String HKey) {
  178 + public List<ResponseSchedulingDto> getCacheSchedulingMapValueByHKey(String key, String HKey) {
181 179 if (Objects.isNull(cacheScheduling.get(key))) {
182 180 return null;
183 181 }
184   - List<ResponseScheduling> list = cacheScheduling.get(key).get(HKey);
  182 + List<ResponseSchedulingDto> list = cacheScheduling.get(key).get(HKey);
185 183  
186 184 return Objects.isNull(list) ? null : list;
187 185 }
... ...
ruoyi-admin/src/main/java/com/ruoyi/controller/ReportController.java
... ... @@ -32,15 +32,10 @@ public class ReportController {
32 32  
33 33 @ApiOperation("签到报表集合查询")
34 34 @GetMapping("/list")
35   - public AjaxResult getList(@ApiParam @ModelAttribute ReportViewRequestVo requestVo) {
36   - return AjaxResult.success(reportService.handlerList(reportService.getReportScrollViewTable(requestVo)));
  35 + public AjaxResult getList(HttpServletResponse response, @ApiParam @ModelAttribute ReportViewRequestVo requestVo) {
  36 + return AjaxResult.success(reportService.getReportScrollViewTable(requestVo,response));
37 37 }
38 38  
39   - @ApiOperation("签到报表大屏集合查询")
40   - @GetMapping("/bigView")
41   - public AjaxResult bigView(@ApiParam @ModelAttribute ReportViewRequestVo requestVo) {
42   - return AjaxResult.success(reportService.getReportScrollViewTable(requestVo));
43   - }
44 39  
45 40 @ApiOperation("异常报表集合查询")
46 41 @GetMapping("/error/list")
... ... @@ -51,10 +46,10 @@ public class ReportController {
51 46 @ApiOperation("签到报表导出")
52 47 @PostMapping("/export")
53 48 public void exportReport(@ApiParam ReportViewRequestVo requestVo, HttpServletResponse response) {
54   - List<ReportViewResponseVo> list = reportService.getReportScrollViewTable(requestVo);
  49 + List<ReportViewResponseVo> list = reportService.exportReportList(requestVo, response);
55 50 // 不导出图片清空路径信息
56 51 if (!EXPORT.equals(requestVo.getExportFlag())){
57   - list = list.stream().map(item->{item.setImage("");return item;}).collect(Collectors.toList());
  52 +// list = list.stream().map(item->{item.setImage("");return item;}).collect(Collectors.toList());
58 53 }
59 54 ExcelUtil<ReportViewResponseVo> util = new ExcelUtil<ReportViewResponseVo>(ReportViewResponseVo.class);
60 55 util.exportEasyExcel(response, list, "签到报表");
... ...
ruoyi-admin/src/main/java/com/ruoyi/driver/controller/DriverController.java
... ... @@ -6,6 +6,7 @@ import javax.servlet.http.HttpServletResponse;
6 6  
7 7 import com.ruoyi.common.global.Result;
8 8 import com.ruoyi.common.global.ResultCode;
  9 +import com.ruoyi.pojo.request.DriverRequestVo;
9 10 import com.ruoyi.pojo.request.DriverSignInRequestVo;
10 11 import com.ruoyi.pojo.request.FaceRegistrationFeedbackVo;
11 12 import com.ruoyi.pojo.request.FaceUpdateReqVo;
... ... @@ -64,9 +65,9 @@ public class DriverController extends BaseController {
64 65 // @PreAuthorize("@ss.hasPermi('driver:driver:list')")
65 66 @GetMapping("/list")
66 67 @ApiOperation(value = "查询驾驶员信息列表", notes = "查询驾驶员信息列表")
67   - public TableDataInfo list(Driver driver) {
  68 + public TableDataInfo list(DriverRequestVo driver) {
68 69 startPage();
69   - List<DriverResponseVo> list = driverService.selectDriverList(driver);
  70 + List<Driver> list = driverService.selectDriverList(driver);
70 71 return getDataTable(list);
71 72 }
72 73  
... ... @@ -89,9 +90,9 @@ public class DriverController extends BaseController {
89 90 // @Log(title = "驾驶员信息", businessType = BusinessType.EXPORT)
90 91 @PostMapping("/export")
91 92 @ApiOperation("导出驾驶员信息列表")
92   - public void export(HttpServletResponse response, Driver driver) {
93   - List<DriverResponseVo> list = driverService.selectDriverList(driver);
94   - ExcelUtil<DriverResponseVo> util = new ExcelUtil<>(DriverResponseVo.class);
  93 + public void export(HttpServletResponse response, DriverRequestVo driver) {
  94 + List<Driver> list = driverService.selectDriverList(driver);
  95 + ExcelUtil<Driver> util = new ExcelUtil<>(Driver.class);
95 96 util.exportExcel(response, list, "驾驶员信息数据");
96 97 }
97 98  
... ... @@ -123,9 +124,9 @@ public class DriverController extends BaseController {
123 124 // @PreAuthorize("@ss.hasPermi('driver:driver:add')")
124 125 // @Log(title = "驾驶员信息", businessType = BusinessType.INSERT)
125 126 @PostMapping("/driver/sign")
126   - @ApiOperation("新增驾驶员信息(设备传入)")
  127 + @ApiOperation("新增驾驶员信息(设备传入,更新人脸数据)")
127 128 public Result<?> addNewDriver(@ApiParam @RequestBody @Validated DriverSignInRequestVo vo) {
128   - driverService.saveDriverSignInfo(vo);
  129 + driverService.updateDriverSignInfo(vo);
129 130 return Result.OK();
130 131 }
131 132  
... ... @@ -223,7 +224,7 @@ public class DriverController extends BaseController {
223 224 }
224 225  
225 226 @GetMapping("/questionFeedback")
226   - @ApiOperation("人脸识别反馈")
  227 +// @ApiOperation("人脸识别反馈")
227 228 public Result<?> questionFeedback() {
228 229  
229 230 return null;
... ...
ruoyi-admin/src/main/java/com/ruoyi/driver/mapper/DriverMapper.java
... ... @@ -4,7 +4,9 @@ import java.util.List;
4 4 import java.util.Set;
5 5  
6 6 import com.ruoyi.driver.domain.Driver;
7   -import com.ruoyi.pojo.response.ResponseScheduling;
  7 +import com.ruoyi.pojo.request.DriverRequestVo;
  8 +import com.ruoyi.pojo.response.DriverResponseVo;
  9 +import com.ruoyi.pojo.response.ResponseSchedulingDto;
8 10 import org.apache.ibatis.annotations.Param;
9 11  
10 12 /**
... ... @@ -29,7 +31,7 @@ public interface DriverMapper
29 31 * @param driver 驾驶员信息
30 32 * @return 驾驶员信息集合
31 33 */
32   - public List<Driver> selectDriverList(Driver driver);
  34 + public List<Driver> selectDriverList(DriverRequestVo driver);
33 35  
34 36 /**
35 37 * 新增驾驶员信息
... ... @@ -103,4 +105,5 @@ public interface DriverMapper
103 105  
104 106 void updateDriverInfoByJobCodes(@Param("drivers") List<Driver> drivers);
105 107  
  108 + void saveScheduling(@Param("responseSchedulingDto") List<ResponseSchedulingDto> responseSchedulingDto);
106 109 }
... ...
ruoyi-admin/src/main/java/com/ruoyi/driver/mapper/DriverSchedulingMapper.java 0 → 100644
  1 +package com.ruoyi.driver.mapper;
  2 +
  3 +import com.ruoyi.pojo.entity.DriverScheduling;
  4 +import com.ruoyi.pojo.request.ReportViewRequestVo;
  5 +import com.ruoyi.pojo.response.ReportViewResponseVo;
  6 +import com.ruoyi.pojo.response.ResponseSchedulingDto;
  7 +import org.apache.ibatis.annotations.Param;
  8 +
  9 +import java.util.List;
  10 +
  11 +/**
  12 + * @author 20412
  13 + */
  14 +public interface DriverSchedulingMapper {
  15 +
  16 +
  17 + void insertRoster(@Param("list") List<DriverScheduling> list);
  18 +
  19 +
  20 + List<DriverScheduling> queryToDay(@Param("date") String date, @Param("jobCode") String jobCode);
  21 +
  22 + void updateRoster(@Param("scheduling") DriverScheduling scheduling, @Param("signInId") Long id, @Param("exType") Integer exType);
  23 +
  24 +}
... ...
ruoyi-admin/src/main/java/com/ruoyi/driver/service/IDriverService.java
... ... @@ -7,11 +7,10 @@ import com.ruoyi.common.core.domain.AjaxResult;
7 7 import com.ruoyi.common.exception.file.InvalidExtensionException;
8 8 import com.ruoyi.common.global.Result;
9 9 import com.ruoyi.driver.domain.Driver;
  10 +import com.ruoyi.pojo.request.DriverRequestVo;
10 11 import com.ruoyi.pojo.request.DriverSignInRequestVo;
11 12 import com.ruoyi.pojo.request.FaceUpdateReqVo;
12 13 import com.ruoyi.pojo.response.DriverResponseVo;
13   -import com.ruoyi.pojo.response.ResponseScheduling;
14   -import org.apache.ibatis.annotations.Param;
15 14 import org.springframework.web.multipart.MultipartFile;
16 15  
17 16 import javax.servlet.http.HttpServletRequest;
... ... @@ -39,7 +38,7 @@ public interface IDriverService
39 38 * @param driver 驾驶员信息
40 39 * @return 驾驶员信息集合
41 40 */
42   - public List<DriverResponseVo> selectDriverList(Driver driver);
  41 + public List<Driver> selectDriverList(DriverRequestVo driver);
43 42  
44 43 /**
45 44 * 新增驾驶员信息
... ... @@ -89,7 +88,7 @@ public interface IDriverService
89 88  
90 89 void downloadHeadImage(String jobCode, HttpServletResponse response);
91 90  
92   - List<Driver> getDrivers(Driver driver);
  91 + List<DriverResponseVo> getDrivers(Driver driver);
93 92  
94 93  
95 94 AjaxResult faceRegistrationFeedback(String deviceId, List<String> jobCode);
... ... @@ -98,9 +97,10 @@ public interface IDriverService
98 97  
99 98 Result updateFaceByJob(HttpServletRequest request, FaceUpdateReqVo vo);
100 99  
101   - void saveDriverSignInfo(DriverSignInRequestVo vo);
  100 + void updateDriverSignInfo(DriverSignInRequestVo vo);
102 101  
103 102 void updateDrivers(List<Driver> drivers);
104 103  
105 104 void clearExceptionRecordByJobCode(String jobCode);
  105 +
106 106 }
... ...
ruoyi-admin/src/main/java/com/ruoyi/driver/service/impl/DriverServiceImpl.java
... ... @@ -4,9 +4,12 @@ import java.io.File;
4 4 import java.io.IOException;
5 5 import java.io.InputStream;
6 6 import java.nio.file.Paths;
  7 +import java.time.LocalDateTime;
  8 +import java.time.temporal.ChronoUnit;
7 9 import java.util.*;
8 10 import java.util.stream.Collectors;
9 11  
  12 +import cn.hutool.core.collection.CollectionUtil;
10 13 import cn.hutool.http.HttpUtil;
11 14 import com.ruoyi.common.cache.SchedulingCache;
12 15 import com.ruoyi.common.config.RuoYiConfig;
... ... @@ -18,14 +21,19 @@ import com.ruoyi.common.global.ResultCode;
18 21 import com.ruoyi.common.utils.file.FileUploadUtils;
19 22 import com.ruoyi.common.utils.file.FileUtils;
20 23 import com.ruoyi.common.utils.file.MimeTypeUtils;
  24 +import com.ruoyi.driver.mapper.DriverSchedulingMapper;
21 25 import com.ruoyi.equipment.mapper.EquipmentMapper;
22 26 import com.ruoyi.framework.config.ServerConfig;
23 27 import com.ruoyi.job.DriverJob;
  28 +import com.ruoyi.pojo.DriverSignRecommendation;
24 29 import com.ruoyi.pojo.domain.EquipmentDriverExpand;
  30 +import com.ruoyi.pojo.entity.DriverScheduling;
  31 +import com.ruoyi.pojo.request.DriverRequestVo;
25 32 import com.ruoyi.pojo.request.DriverSignInRequestVo;
26 33 import com.ruoyi.pojo.request.FaceUpdateReqVo;
27 34 import com.ruoyi.pojo.response.DriverResponseVo;
28   -import com.ruoyi.pojo.response.ResponseScheduling;
  35 +import com.ruoyi.pojo.response.ResponseSchedulingDto;
  36 +import com.ruoyi.service.SchedulingService;
29 37 import com.ruoyi.service.ThreadJobService;
30 38 import com.ruoyi.utils.ConstDateUtil;
31 39 import com.ruoyi.utils.ListUtils;
... ... @@ -47,8 +55,8 @@ import javax.servlet.http.HttpServletRequest;
47 55 import javax.servlet.http.HttpServletResponse;
48 56  
49 57 import static com.ruoyi.common.ApiProperties.PERSONNEL_API_KEY;
50   -import static com.ruoyi.common.ConstSignInConstSignInProperties.SIGN_FACE_ACTIVE;
51   -import static com.ruoyi.common.global.ResultCode.CODE_207;
  58 +import static com.ruoyi.common.ConstDriverProperties.*;
  59 +import static com.ruoyi.common.ConstSignInConstSignInProperties.*;
52 60 import static com.ruoyi.common.redispre.GlobalRedisPreName.DRIVER_SCHEDULING_PRE;
53 61 import static com.ruoyi.common.redispre.GlobalRedisPreName.REDIS_SIGN_IN_DRIVER_ALCOHOL_OVERFLOW;
54 62  
... ... @@ -63,17 +71,20 @@ public class DriverServiceImpl implements IDriverService {
63 71  
64 72 private Logger log = LoggerFactory.getLogger(DriverServiceImpl.class);
65 73  
66   - @Resource
67   - private SchedulingCache schedulingCache;
68   -
69   - @Autowired
70   - private EquipmentMapper equipmentMapper;
71 74 @Value("${api.url.getSchedulingInfo}")
72 75 private String schedulingInfoUrl;
73 76 @Value("${api.config.password}")
74 77 private String password;
75 78 @Value("${api.config.nonce}")
76 79 private String nonce;
  80 + @Resource
  81 + private SchedulingCache schedulingCache;
  82 +
  83 + @Resource
  84 + private SchedulingService schedulingService;
  85 +
  86 + @Autowired
  87 + private EquipmentMapper equipmentMapper;
77 88 @Autowired
78 89 private DriverJob driverJob;
79 90  
... ... @@ -109,21 +120,49 @@ public class DriverServiceImpl implements IDriverService {
109 120 * @return 驾驶员信息
110 121 */
111 122 @Override
112   - public List<DriverResponseVo> selectDriverList(Driver driver) {
  123 + public List<Driver> selectDriverList(DriverRequestVo driver) {
113 124 List<Driver> drivers = driverMapper.selectDriverList(driver);
114   - List<DriverResponseVo> vos = new ArrayList<>(drivers.size());
115   - // 从缓存中获取排班记录
116   -// List<ResponseScheduling> schedulingList = schedulingCache.getCacheSchedulingMapValueByHKey(ConstDateUtil.formatDate(new Date()), driver.getJobCode());
117 125 List<EquipmentDriverExpand> list = equipmentMapper.querySignListByJobCode(drivers);
118 126 for (Driver item : drivers) {
119 127 // 查询对应工号的注册设备号 然后用,拼接展示在前端
120 128 List<String> collect = list.stream().filter(todo -> item.getJobCode().equals(todo.getJobCode())).map(EquipmentDriverExpand::getDeviceId).collect(Collectors.toList());
121 129 item.setSignInEquipment(StringUtils.join(collect));
122   - vos.add(new DriverResponseVo(item));
123 130 }
124   - return vos;
  131 + return drivers;
  132 + }
  133 +
  134 + private DriverSignRecommendation checkTime(List<DriverScheduling> dto, Long now) {
  135 + Map<Integer, DriverSignRecommendation> timeMap = new HashMap<>();
  136 + for (int i = 0; i < dto.size(); i++) {
  137 + timeMap.put(i, new DriverSignRecommendation(dto.get(i), i));
  138 + }
  139 + long minDiff = Long.MAX_VALUE;
  140 + Integer index = 0;
  141 + // 迭代比较每个时间戳与当前时间戳的差值
  142 + for (Integer i : timeMap.keySet()) {
  143 + long diff = Math.abs(now - timeMap.get(i).getTimestamps());
  144 + if (diff < minDiff) {
  145 + minDiff = diff;
  146 + index = i;
  147 + }
  148 + }
  149 +
  150 + // 如果当前记录是异常的记录且还在目前还在签到范围内
  151 + if (!Objects.isNull(timeMap.get(index).getSignInId())) {
  152 + LocalDateTime endTime = ConstDateUtil.getLocalDateTimeByLongTime(timeMap.get(index).getTimestamps());
  153 + LocalDateTime nowTime = ConstDateUtil.getLocalDateTimeByLongTime(now);
  154 + long nowBetween = ChronoUnit.MINUTES.between(endTime, nowTime);
  155 + // 如果当前有效范围内签到记录无效如酒精测试异常则重复当前操作
  156 + if ((Math.abs(nowBetween) <= 60) && timeMap.get(index).getExType().equals(SIGN_ALCOHOL_EX_NUM) && timeMap.get(index).getBcType().equals(BC_TYPE_OUT)) {
  157 + return timeMap.get(index);
  158 + }else {
  159 + index = index < timeMap.size() - 1 ? index + 1 : index;
  160 + }
  161 + }
  162 + return timeMap.get(index);
125 163 }
126 164  
  165 +
127 166 /**
128 167 * 新增驾驶员信息
129 168 *
... ... @@ -177,38 +216,30 @@ public class DriverServiceImpl implements IDriverService {
177 216 @Override
178 217 public AjaxResult getDriverSchedulingInfo(String schedulingDate, String jobCode) {
179 218 String key = DRIVER_SCHEDULING_PRE + schedulingDate;
180   - List<ResponseScheduling> cacheMapValue = schedulingCache.getCacheSchedulingMapValueByHKey(key, jobCode);
  219 + long now = System.currentTimeMillis();
  220 + List<ResponseSchedulingDto> cacheMapValue = schedulingCache.getCacheSchedulingMapValueByHKey(key, jobCode);
  221 + // 获取考勤表进行比对,因为排班数据是会变化的
  222 + List<DriverScheduling> dto = schedulingService.queryScheduling(jobCode, now);
181 223 log.info("获取到排班数据:{}", cacheMapValue);
182 224 // 优先从缓存中读取
183   - if (cacheMapValue != null && cacheMapValue.size() > 0) {
  225 + if (!CollectionUtil.isEmpty(cacheMapValue) && !CollectionUtil.isEmpty(dto)) {
184 226 return AjaxResult.success(cacheMapValue);
185 227 }
186 228 // 获取昨天的排班数据
187 229 String yesterdayKey = DRIVER_SCHEDULING_PRE + ConstDateUtil.formatDate(ConstDateUtil.getTheSpecifiedNumberOfDaysOfTime(-1));
188 230 cacheMapValue = schedulingCache.getCacheSchedulingMapValueByHKey(yesterdayKey, jobCode);
189   - if (cacheMapValue != null && cacheMapValue.size() > 0) {
190   - String endSignTime = ConstDateUtil.formatDate(new Date(cacheMapValue.get(cacheMapValue.size() - 1).getZdsjT()));
191   - if (endSignTime.equals(schedulingDate)) {
  231 + if (!CollectionUtil.isEmpty(cacheMapValue) && !CollectionUtil.isEmpty(dto)) {
  232 + LocalDateTime zdsjT = ConstDateUtil.getLocalDateTimeByLongTime(cacheMapValue.get(cacheMapValue.size() - 1).getZdsjT());
  233 + LocalDateTime nowTime = ConstDateUtil.getLocalDateTimeByLongTime(now);
  234 + long range = ChronoUnit.MINUTES.between(zdsjT, nowTime);
  235 + if (range <= 0L) {
192 236 return AjaxResult.success(cacheMapValue);
  237 + } else if (range <= 120L) {
  238 + return AjaxResult.success();
193 239 }
194 240 }
  241 + return AjaxResult.success();
195 242  
196   - // 没有再次请求地址获取值
197   - long timestamp = System.currentTimeMillis();
198   - // 请求资源地址格式化
199   - String getSchedulingInfoUrl = null;
200   - try {
201   - getSchedulingInfoUrl = String.format(schedulingInfoUrl, "99", schedulingDate, timestamp, nonce, password, driverJob.getSHA1(driverJob.getStringStringMap(String.valueOf(timestamp))));
202   - } catch (Exception e) {
203   - throw new RuntimeException(e);
204   - }
205   - Map<String, List<ResponseScheduling>> scheduling = driverJob.saveSchedulingToRedis(getSchedulingInfoUrl, schedulingDate);
206   - // 数据库中读取所有接收到的排班信息
207   -// List<ResponseScheduling> responseSchedulings = driverMapper.getDriverSchedulingList(schedulingDate, jobCode);
208   - if (jobCode.equals("700001") || jobCode.equals("700002")) {
209   - return AjaxResult.success(scheduling.get("724228"));
210   - }
211   - return AjaxResult.success(scheduling.get(jobCode));
212 243 }
213 244  
214 245  
... ... @@ -233,7 +264,6 @@ public class DriverServiceImpl implements IDriverService {
233 264 @Override
234 265 public AjaxResult uploadImage(MultipartFile file) throws InvalidExtensionException, IOException {
235 266 // 上传并返回新文件名称
236   -
237 267 // 上传文件路径
238 268 String baseUrl = RuoYiConfig.getUploadPath() + headImagePre;
239 269 // 校验文件格式
... ... @@ -277,10 +307,40 @@ public class DriverServiceImpl implements IDriverService {
277 307 }
278 308  
279 309 @Override
280   - public List<Driver> getDrivers(Driver driver) {
281   - // TODO 人事比对
  310 + public List<DriverResponseVo> getDrivers(Driver driver) {
282 311 List<Driver> drivers = driverMapper.getDrivers(driver);
283   - return drivers;
  312 + Long now = System.currentTimeMillis();
  313 + List<DriverResponseVo> vos = new ArrayList<>(drivers.size());
  314 +// List<ResponseSchedulingDto> schedulingList = schedulingCache.getCacheSchedulingMapValueByHKey(ConstDateUtil.formatDate(new Date()), driver.getJobCode());
  315 + List<DriverScheduling> dto = null;
  316 + Boolean schedulingFlag = true;
  317 + Boolean alcoholFlag = true;
  318 + dto = schedulingService.queryScheduling(driver.getJobCode(), now);
  319 +
  320 + DriverResponseVo vo = null;
  321 + // 给出计划操作
  322 + if (!CollectionUtil.isEmpty(dto)) {
  323 + DriverSignRecommendation item = checkTime(dto, now);
  324 + if (BC_TYPE_OUT.equals(item.getBcType()) && !CollectionUtil.isEmpty(drivers)) {
  325 + // 售票员无需酒精测试
  326 + if (item.getPosts().equals(PERSONNEL_POSTS_DRIVER))
  327 + vo = new DriverResponseVo(item.getTimestamps(), drivers.get(0), SIGN_IN_STRING, alcoholFlag, schedulingFlag);
  328 + else
  329 + vo = new DriverResponseVo(item.getTimestamps(), drivers.get(0), SIGN_IN_STRING, !alcoholFlag, schedulingFlag);
  330 + } else if (BC_TYPE_IN.equals(item.getBcType()) && !CollectionUtil.isEmpty(drivers)) {
  331 + vo = new DriverResponseVo(item.getTimestamps(), drivers.get(0), SIGN_IN_OUT_STRING, !alcoholFlag, !schedulingFlag);
  332 + }
  333 + }
  334 + // 更新信息
  335 + for (Driver item : drivers) {
  336 + // 无排班
  337 + if (Objects.isNull(vo)) {
  338 + vos.add(new DriverResponseVo(null, item, null, null, false));
  339 + } else {
  340 + vos.add(vo);
  341 + }
  342 + }
  343 + return vos;
284 344 }
285 345  
286 346  
... ... @@ -369,7 +429,7 @@ public class DriverServiceImpl implements IDriverService {
369 429 }
370 430  
371 431 @Override
372   - public void saveDriverSignInfo(DriverSignInRequestVo vo) {
  432 + public void updateDriverSignInfo(DriverSignInRequestVo vo) {
373 433 log.info("开始进行人员数据更新");
374 434 Driver driver = new Driver();
375 435 driver.setJobCode(vo.getJobCode());
... ...
ruoyi-admin/src/main/java/com/ruoyi/in/domain/SignIn.java
... ... @@ -95,14 +95,8 @@ public class SignIn extends BaseEntity {
95 95 @Excel(name = "酒精摄入量")
96 96 @ApiModelProperty("酒精摄入量 52.12")
97 97 private BigDecimal alcoholIntake;
98   - @Excel(name = "线路")
99   - @ApiModelProperty("线路")
100   - private String lineName;
101   - @Excel(name = "车辆自编号")
102   - @ApiModelProperty("车辆自编号")
103   - private String carNum;
104   - @Excel(name = "路牌")
105   - @ApiModelProperty("路牌")
106   - private String roadNum;
  98 + @Excel(name = "异常类型",readConverterExp = "0=无异常,1=超时异常,2=无排班异常,3=酒精超标异常")
  99 + @ApiModelProperty("异常类型")
  100 + private Integer exType;
107 101 }
108 102  
... ...
ruoyi-admin/src/main/java/com/ruoyi/in/service/impl/SignInServiceImpl.java
... ... @@ -7,6 +7,7 @@ import java.time.LocalDateTime;
7 7 import java.time.temporal.ChronoUnit;
8 8 import java.util.*;
9 9  
  10 +import cn.hutool.core.collection.CollectionUtil;
10 11 import com.ruoyi.common.cache.SchedulingCache;
11 12 import com.ruoyi.common.config.RuoYiConfig;
12 13 import com.ruoyi.common.constant.Constants;
... ... @@ -21,8 +22,11 @@ import com.ruoyi.driver.domain.Driver;
21 22 import com.ruoyi.driver.mapper.DriverMapper;
22 23 import com.ruoyi.equipment.domain.Equipment;
23 24 import com.ruoyi.equipment.mapper.EquipmentMapper;
24   -import com.ruoyi.pojo.response.ResponseScheduling;
  25 +import com.ruoyi.pojo.DriverSignRecommendation;
  26 +import com.ruoyi.pojo.GlobalIndex;
  27 +import com.ruoyi.pojo.entity.DriverScheduling;
25 28 import com.ruoyi.pojo.response.SignInResponseVo;
  29 +import com.ruoyi.service.SchedulingService;
26 30 import com.ruoyi.service.ThreadJobService;
27 31 import com.ruoyi.utils.ConstDateUtil;
28 32 import org.apache.commons.io.FilenameUtils;
... ... @@ -36,11 +40,9 @@ import com.ruoyi.in.service.ISignInService;
36 40  
37 41 import javax.annotation.Resource;
38 42  
39   -import static com.ruoyi.common.ConstDriverProperties.PERSONNEL_POSTS_DRIVER;
40   -import static com.ruoyi.common.ConstDriverProperties.PERSONNEL_POSTS_SALES;
  43 +import static com.ruoyi.common.ConstDriverProperties.*;
41 44 import static com.ruoyi.common.ErrorTypeProperties.*;
42 45 import static com.ruoyi.common.ConstSignInConstSignInProperties.*;
43   -import static com.ruoyi.common.redispre.GlobalRedisPreName.DRIVER_SCHEDULING_PRE;
44 46 import static com.ruoyi.common.redispre.GlobalRedisPreName.REDIS_SIGN_IN_DRIVER_ALCOHOL_OVERFLOW;
45 47  
46 48 /**
... ... @@ -55,10 +57,14 @@ public class SignInServiceImpl implements ISignInService {
55 57 private Logger log = LoggerFactory.getLogger(SignInServiceImpl.class);
56 58  
57 59 @Resource
  60 + private SchedulingService schedulingService;
  61 +
  62 + @Resource
58 63 private SchedulingCache schedulingCache;
59 64 @Autowired
60 65 private SignInMapper signInMapper;
61 66  
  67 +
62 68 @Autowired
63 69 private DriverMapper driverMapper;
64 70  
... ... @@ -112,7 +118,10 @@ public class SignInServiceImpl implements ISignInService {
112 118 signIn.setCreateTime(new Date());
113 119 signIn.setRemark("");
114 120 // 签到检查 酒精检查 超时检查 排班检查
115   - if (checkSignIn(signIn, driver)) {
  121 + GlobalIndex globalIndex = new GlobalIndex();
  122 + long now = System.currentTimeMillis();
  123 + List<DriverScheduling> dto = schedulingService.queryScheduling(signIn.getJobCode(), now);
  124 + if (checkSignIn(now, dto, globalIndex, signIn, driver)) {
116 125 signIn.setStatus(SIGN_IN_SUCCESS);
117 126 } else {
118 127 signIn.setStatus(SIGN_IN_FAIL);
... ... @@ -182,9 +191,13 @@ public class SignInServiceImpl implements ISignInService {
182 191 SignInResponseVo vo = getSignInResponseVo(signIn, equipment);
183 192 signIn.setCreateTime(new Date());
184 193 signIn.setRemark("");
  194 + GlobalIndex globalIndex = new GlobalIndex();
  195 + long now = System.currentTimeMillis();
  196 + List<DriverScheduling> dto = schedulingService.queryScheduling(signIn.getJobCode(), now);
185 197 // 签到检查
186   - if (checkSignIn(signIn, driver)) {
  198 + if (checkSignIn(now, dto, globalIndex, signIn, driver)) {
187 199 signIn.setStatus(SIGN_IN_SUCCESS);
  200 + signIn.setExType(SIGN_NO_EX_NUM);
188 201 } else {
189 202 signIn.setStatus(SIGN_IN_FAIL);
190 203 signIn.setRemark(signIn.getRemark().replaceFirst(",$", "。"));
... ... @@ -194,12 +207,12 @@ public class SignInServiceImpl implements ISignInService {
194 207  
195 208 uploadImage(signIn);
196 209 signInMapper.insertSignIn(signIn);
197   -
198   - // 测试用户特殊处理
  210 + // 更新考勤
  211 + schedulingService.computedSignInBySignIn(dto, signIn, globalIndex);
  212 + // 测试用户特殊处理 TODO 更新签到记录
199 213 if (signIn.getJobCode().equals("700002") || signIn.getJobCode().equals("700001")) {
200 214 return AjaxResult.success(SIGN_IN_SUCCESS_STRING, vo);
201 215 }
202   - // TODO redis 存储每个人的签到 用于后续考勤
203 216  
204 217 // 驾驶人员二次签到酒精测试异常
205 218 if (PERSONNEL_POSTS_DRIVER.equals(driver.getPosts()) && SIGN_IN_FAIL.equals(signIn.getStatus()) && signIn.getRemark().contains(ALCOHOL_SIGN_IN_ERROR)) {
... ... @@ -239,18 +252,19 @@ public class SignInServiceImpl implements ISignInService {
239 252 return null;
240 253 }
241 254  
242   - private boolean checkSignIn(SignIn signIn, Driver driver) {
  255 + private boolean checkSignIn(long now, List<DriverScheduling> dto, GlobalIndex globalIndex, SignIn signIn, Driver driver) {
243 256 boolean result = true;
244 257 if (Objects.isNull(driver)) {
245 258 return true;
246 259 }
247 260 // TODO 排班校验 和签到超时校验 非司售未作
248   - result = checkWorkDay(signIn, driver.getPosts());
  261 + result = checkWorkDay(now, dto, globalIndex, signIn, driver.getPosts());
249 262  
250 263 // 酒精测试校验 确定 且员工工种是驾驶员
251 264 if (ALCOHOL_FLAG_YES.equals(signIn.getAlcoholFlag()) && PERSONNEL_POSTS_DRIVER.equals(driver.getPosts())) {
252 265 if (new BigDecimal(20).compareTo(signIn.getAlcoholIntake()) <= 0) {
253 266 signIn.setRemark(signIn.getRemark() + ALCOHOL_SIGN_IN_ERROR + signIn.getAlcoholIntake().toString() + "mg/100ml。");
  267 + signIn.setExType(SIGN_ALCOHOL_EX_NUM);
254 268 result = false;
255 269 }
256 270 }
... ... @@ -261,37 +275,24 @@ public class SignInServiceImpl implements ISignInService {
261 275 /**
262 276 * 排班和超时检查
263 277 *
  278 + * @param globalIndex
264 279 * @param signIn
265 280 * @param posts
266 281 * @return
267 282 */
268   - private boolean checkWorkDay(SignIn signIn, String posts) {
  283 + private boolean checkWorkDay(long now, List<DriverScheduling> dto, GlobalIndex globalIndex, SignIn signIn, String posts) {
269 284 Boolean result = true;
270   - List<ResponseScheduling> jobs = null;
271 285 switch (posts) {
272 286 case "驾驶员":
273 287 case "售票员":
274   - String key = DRIVER_SCHEDULING_PRE + ConstDateUtil.formatDate("yyyyMMdd");
  288 + String key = ConstDateUtil.formatDate(now);
275 289 // 查询工号对应的排班 司售人员
276   - jobs = schedulingCache.getCacheSchedulingMapValueByHKey(key, signIn.getJobCode());
277   - log.debug("签到key:{},排班数据:{}", key, jobs);
278   - if (Objects.isNull(jobs) || jobs.size() == 0) {
279   - // 当天的排班没有记录的话
280   - key = DRIVER_SCHEDULING_PRE + ConstDateUtil.formatDate(ConstDateUtil.getTheSpecifiedNumberOfDaysOfTime(-1));
281   - jobs = schedulingCache.getCacheSchedulingMapValueByHKey(key, signIn.getJobCode());
282   - if (Objects.isNull(jobs) || jobs.size() == 0) {
283   - signIn.setRemark(signIn.getRemark() + WORK_DAY_ERROR);
284   - result = false;
285   - } else {
286   - ResponseScheduling responseScheduling = jobs.get(jobs.size() - 1);
287   - if (!ConstDateUtil.formatDate(new Date(responseScheduling.getZdsjT())).equals(ConstDateUtil.formatDate("yyyyMMdd"))) {
288   - signIn.setRemark(signIn.getRemark() + WORK_DAY_ERROR);
289   - result = false;
290   - }
291   - }
292   - } else {
293   - // TODO 获取线路和车辆自编号和路牌
294   -
  290 + dto = schedulingService.queryScheduling(signIn.getJobCode(), now);
  291 + log.debug("签到key:{},排班数据:{}", key, dto);
  292 + if (CollectionUtil.isEmpty(dto)) {
  293 + signIn.setRemark(signIn.getRemark() + WORK_DAY_ERROR);
  294 + signIn.setExType(SIGN_NO_SCHEDULING_EX_NUM);
  295 + result = false;
295 296 }
296 297 break;
297 298 default:
... ... @@ -300,35 +301,103 @@ public class SignInServiceImpl implements ISignInService {
300 301  
301 302 // 超时校验司售人员
302 303 if (result) {
303   - // TODO 非司售人员
304   - result = checkTimeOut(signIn, jobs, posts);
  304 + result = checkTimeOut(globalIndex, signIn, dto, posts, now);
  305 + if (!result) {
  306 + signIn.setExType(SIGN_TIME_OUT_EX_NUM);
  307 + }
305 308 }
306 309 return result;
307 310 }
308 311  
309   - private boolean checkTimeOut(SignIn signIn, List<ResponseScheduling> driver, String posts) {
  312 +
  313 + private static Date getDayKey() {
  314 + Calendar calendar = Calendar.getInstance();
  315 +
  316 + // 获取当前日期时间
  317 + Date currentDate = calendar.getTime();
  318 +
  319 + // 设置时间为2:30 AM
  320 + calendar.set(Calendar.HOUR_OF_DAY, 2);
  321 + calendar.set(Calendar.MINUTE, 30);
  322 + calendar.set(Calendar.SECOND, 0);
  323 +
  324 + // 判断当前时间是否在2:30 AM之前
  325 + if (currentDate.before(calendar.getTime())) {
  326 + // 当前时间在2:30 AM之前,将日期向前推一天
  327 + calendar.add(Calendar.DAY_OF_MONTH, -1);
  328 + }
  329 +
  330 + // 获取结果日期对象
  331 + return calendar.getTime();
  332 + }
  333 +
  334 + private boolean checkTimeOut(GlobalIndex globalIndex, SignIn signIn, List<DriverScheduling> dto, String posts, long now) {
310 335 // 那发车时间和到站时间作为开始上班的时间
311 336 if (PERSONNEL_POSTS_DRIVER.equals(posts) || PERSONNEL_POSTS_SALES.equals(posts)) {
312   - return driverCheckTimeOut(signIn, driver);
  337 + return driverCheckTimeOut(globalIndex, signIn, dto, now);
313 338 } else {
314 339 return true;
315 340 }
316 341 }
317 342  
318   - private static boolean driverCheckTimeOut(SignIn signIn, List<ResponseScheduling> driver) {
  343 + private boolean driverCheckTimeOut(GlobalIndex globalIndex, SignIn signIn, List<DriverScheduling> dto, long now) {
319 344 try {
320   - LocalDateTime startTime = ConstDateUtil.getLocalDateTimeByLongTime(driver.get(0).getFcsjT());
321   - LocalDateTime endTime = ConstDateUtil.getLocalDateTimeByLongTime(driver.get(driver.size() - 1).getZdsjT());
322   - LocalDateTime signTime = ConstDateUtil.getLocalDateTimeByLongTime(signIn.getCreateTime().getTime());
323   - long morningBetween = ChronoUnit.MINUTES.between(startTime, signTime);
324   - long afternoonBetween = ChronoUnit.MINUTES.between(endTime, signTime);
325   - // 签到范围一小时内 TODO 不合理后续会更改
326   - if (Math.abs(morningBetween) <= 60 || Math.abs(afternoonBetween) <= 60) {
327   - return true;
  345 + Boolean result = true;
  346 + DriverSignRecommendation currentScheduling = schedulingService.computedTheCurrentClosestTimestamp(dto, now, 0);
  347 + LocalDateTime endTime = ConstDateUtil.getLocalDateTimeByLongTime(currentScheduling.getTimestamps());
  348 + LocalDateTime nowTime = ConstDateUtil.getLocalDateTimeByLongTime(now);
  349 + long nowBetween = ChronoUnit.MINUTES.between(endTime, nowTime);
  350 + // 不在有效时间范围内,判断当前是否有签到记录 当前应签到还是签退
  351 + if (!(Math.abs(nowBetween) <= 60)) {
  352 + // 签到一个逻辑 当前无记录
  353 + if (currentScheduling.getBcType().equals(BC_TYPE_OUT) && Objects.isNull(currentScheduling.getSignInId())) {
  354 + DriverSignRecommendation lastClosestTimestamp = schedulingService.computedTheCurrentClosestTimestamp(dto, now, -1);
  355 + // 上一次无记|签到,type:签退 当前时间小于最近签到时间 -> 超时签退
  356 + if (nowBetween < -60L && Objects.isNull(lastClosestTimestamp.getSignInId()) && signIn.getType().equals(SIGN_OUT) && lastClosestTimestamp.getBcType().equals(BC_TYPE_IN)){
  357 + signIn.setRemark(SIGN_OUT_TIMEOUT);
  358 + globalIndex.setIndex(lastClosestTimestamp.getIndex());
  359 + result = false;
  360 + }
  361 + // 上一次无记无|签到,type:签退 当前时间小于最近签到时间 -> 超时签退
  362 + else if (nowBetween < -60L && Objects.isNull(lastClosestTimestamp.getSignInId()) && signIn.getType().equals(SIGN_OUT) && lastClosestTimestamp.getIndex().equals(currentScheduling.getIndex())) {
  363 + signIn.setRemark(SIGN_IN_TIMEOUT);
  364 + globalIndex.setIndex(currentScheduling.getIndex());
  365 + result = false;
  366 + }
  367 + // 当前最近无记录|签到,type:签到 -> 签到超时给上
  368 + else if (currentScheduling.getBcType().equals(BC_TYPE_OUT)) {
  369 + signIn.setRemark(SIGN_IN_TIMEOUT);
  370 + globalIndex.setIndex(currentScheduling.getIndex());
  371 + result = false;
  372 + }
  373 + }
  374 + // 签退一个逻辑 当前无记录
  375 + if (currentScheduling.getBcType().equals(BC_TYPE_IN) && Objects.isNull(currentScheduling.getSignInId())) {
  376 + DriverSignRecommendation lastClosestTimestamp = schedulingService.computedTheCurrentClosestTimestamp(dto, now, -1);
  377 + // 上一次无记|签退,type:签到 当前时间小于最近签退时间 -> 签到超时
  378 + if (nowBetween < -60L && Objects.isNull(lastClosestTimestamp.getSignInId()) && signIn.getType().equals(SIGN_OUT)) {
  379 + signIn.setRemark(SIGN_IN_TIMEOUT);
  380 + globalIndex.setIndex(lastClosestTimestamp.getIndex());
  381 + result = false;
  382 + }
  383 + // 当前无记|签退 , type:签退 ——> 超时签退
  384 + else if (signIn.getType().equals(SIGN_OUT)) {
  385 + signIn.setRemark(SIGN_OUT_TIMEOUT);
  386 + globalIndex.setIndex(currentScheduling.getIndex());
  387 + result = false;
  388 + }
  389 + }
  390 + // 签退|签到 当前有记录
  391 + if (!Objects.isNull(currentScheduling.getSignInId())) {
  392 + signIn.setRemark(currentScheduling.getBcType().equals(BC_TYPE_IN) ? SIGN_OUT_TIMEOUT : SIGN_IN_TIMEOUT);
  393 + globalIndex.setIndex(currentScheduling.getIndex());
  394 + result = false;
  395 + }
328 396 } else {
329   - signIn.setRemark(signIn.getRemark() + SIGN_IN_TIMEOUT);
330   - return false;
  397 + globalIndex.setIndex(currentScheduling.getIndex());
  398 + result = true;
331 399 }
  400 + return result;
332 401 } catch (Exception e) {
333 402 return true;
334 403 }
... ...
ruoyi-admin/src/main/java/com/ruoyi/job/DriverJob.java
... ... @@ -10,14 +10,14 @@ import com.ruoyi.driver.domain.Driver;
10 10 import com.ruoyi.driver.service.IDriverService;
11 11 import com.ruoyi.equipment.domain.Equipment;
12 12 import com.ruoyi.equipment.mapper.EquipmentMapper;
13   -import com.ruoyi.pojo.equipment.EquipmentOnline;
14 13 import com.ruoyi.pojo.request.PersonnelRequestVo;
15 14 import com.ruoyi.pojo.request.TokenRequestVo;
16   -import com.ruoyi.pojo.response.ResponseScheduling;
  15 +import com.ruoyi.pojo.response.ResponseSchedulingDto;
17 16 import com.ruoyi.pojo.response.personnel.*;
18 17 import com.ruoyi.service.ThreadJobService;
19 18 import com.ruoyi.utils.ConstDateUtil;
20 19 import lombok.extern.slf4j.Slf4j;
  20 +import org.springframework.beans.BeanUtils;
21 21 import org.springframework.beans.factory.InitializingBean;
22 22 import org.springframework.beans.factory.annotation.Autowired;
23 23 import org.springframework.beans.factory.annotation.Value;
... ... @@ -37,6 +37,8 @@ import java.util.*;
37 37 import java.util.concurrent.TimeUnit;
38 38 import java.util.stream.Collectors;
39 39  
  40 +import static com.ruoyi.common.ConstDriverProperties.PERSONNEL_POSTS_DRIVER;
  41 +import static com.ruoyi.common.ConstDriverProperties.PERSONNEL_POSTS_SALES;
40 42 import static com.ruoyi.common.ConstEquipmentProperties.*;
41 43 import static com.ruoyi.common.redispre.GlobalRedisPreName.*;
42 44  
... ... @@ -245,55 +247,56 @@ public class DriverJob implements InitializingBean {
245 247 EQUIPMENT_MAPPER.updateEquipments(list);
246 248 }
247 249  
248   - public Map<String, List<ResponseScheduling>> saveSchedulingToRedis(String getSchedulingInfoUrl, String dateKey) {
  250 + public Map<String, List<ResponseSchedulingDto>> saveSchedulingToRedis(String getSchedulingInfoUrl, String dateKey) {
249 251 log.info("开始拉取排班:{}", dateKey);
250   - List<ResponseScheduling> originSchedulingList = RESTTEMPLATE.exchange(
  252 + List<ResponseSchedulingDto> originSchedulingList = RESTTEMPLATE.exchange(
251 253 getSchedulingInfoUrl,
252 254 HttpMethod.GET,
253 255 null,
254   - new ParameterizedTypeReference<List<ResponseScheduling>>() {
  256 + new ParameterizedTypeReference<List<ResponseSchedulingDto>>() {
255 257 }).getBody();
256   -
257   - Map<String, List<ResponseScheduling>> driverSchedulingMap = new HashMap<>(200);
258   - // 按照员工工号来获取排班信息
259   - originSchedulingList = originSchedulingList.stream()
260   - .map(subItem -> {
261   - subItem.setJobCode(subItem.getJsy().split("/")[0]);
262   - return subItem;
263   - }).collect(Collectors.toList());
  258 + Map<String, List<ResponseSchedulingDto>> driverSchedulingMap = new HashMap<>(200);
264 259 // 以员工号为key存入排班集合
265 260 originSchedulingList.stream().forEach(item -> {
266 261 // 员工号为key
267   - String jobCode = item.getJsy().split("/")[0];
  262 + String[] infos = item.getJsy().split("/");
  263 + String driverJobCode = infos[0];
  264 + String driverName = infos[1];
268 265 String salePersonJobCode = item.getSpy().split("/").length > 0 ? item.getSpy().split("/")[0] : null;
269   - item.setJobCode(jobCode);
270   - splitSaveScheduling(driverSchedulingMap, jobCode, item);
271   - splitSaveScheduling(driverSchedulingMap, salePersonJobCode, item);
  266 + String salePersonName = item.getSpy().split("/").length > 0 ? item.getSpy().split("/")[1] : null;
  267 + splitSaveScheduling(driverSchedulingMap, driverJobCode, driverName, item, PERSONNEL_POSTS_DRIVER);
  268 + splitSaveScheduling(driverSchedulingMap, salePersonJobCode, salePersonName, item, PERSONNEL_POSTS_SALES);
272 269 });
273 270 // 排序
274 271 List<String> keys = new ArrayList<>(driverSchedulingMap.keySet());
275 272 for (String key : keys) {
276   - List<ResponseScheduling> schedulingList = driverSchedulingMap.get(key);
277   - schedulingList.sort(Comparator.comparing(ResponseScheduling::getFcsjT));
  273 + List<ResponseSchedulingDto> schedulingList = driverSchedulingMap.get(key);
  274 + schedulingList.sort(Comparator.comparing(ResponseSchedulingDto::getFcsjT));
278 275 }
279 276 // 存入数据库
280   -// DRIVER_SERVICE.saveDriverScheduling(originSchedulingList);
281   - // 存入redis
  277 + THREAD_JOB_SERVICE.asyncComputedScheduling(driverSchedulingMap);
  278 + // 存入缓存
282 279 SCHEDULING_CACHE.setCacheScheduling(DRIVER_SCHEDULING_PRE + dateKey, driverSchedulingMap);
283 280 // REDIS_CACHE.setCacheMap(DRIVER_SCHEDULING_PRE + dateKey, driverSchedulingMap, 2, TimeUnit.DAYS);
284 281 log.info("拉取排班完毕:{}", dateKey);
285 282 return driverSchedulingMap;
286 283 }
287 284  
288   - private void splitSaveScheduling(Map<String, List<ResponseScheduling>> driverSchedulingMap, String jobCode, ResponseScheduling item) {
289   - if (!Objects.isNull(jobCode))
  285 + private void splitSaveScheduling(Map<String, List<ResponseSchedulingDto>> driverSchedulingMap, String jobCode, String name, ResponseSchedulingDto item, String posts) {
  286 + if (!Objects.isNull(jobCode)) {
  287 + ResponseSchedulingDto scheduling = new ResponseSchedulingDto();
  288 + BeanUtils.copyProperties(item,scheduling);
  289 + scheduling.setPosts(posts);
  290 + scheduling.setJobCode(jobCode);
  291 + scheduling.setName(name);
290 292 if (Objects.isNull(driverSchedulingMap.get(jobCode))) {
291   - List<ResponseScheduling> oneDriverScheduling = new ArrayList<>();
292   - oneDriverScheduling.add(item);
  293 + List<ResponseSchedulingDto> oneDriverScheduling = new ArrayList<>();
  294 + oneDriverScheduling.add(scheduling);
293 295 driverSchedulingMap.put(jobCode, oneDriverScheduling);
294 296 } else {
295   - driverSchedulingMap.get(jobCode).add(item);
  297 + driverSchedulingMap.get(jobCode).add(scheduling);
296 298 }
  299 + }
297 300 }
298 301  
299 302  
... ...
ruoyi-admin/src/main/java/com/ruoyi/pojo/ConstTableDataInfo.java 0 → 100644
  1 +//package com.ruoyi.pojo;
  2 +//
  3 +//import com.ruoyi.common.core.page.TableDataInfo;
  4 +//import io.swagger.annotations.ApiModel;
  5 +//import io.swagger.annotations.ApiModelProperty;
  6 +//import lombok.Data;
  7 +//
  8 +//import java.io.Serializable;
  9 +//import java.util.List;
  10 +//
  11 +///**
  12 +// * 表格分页数据对象
  13 +// *
  14 +// * @author ruoyi
  15 +// */
  16 +//@ApiModel("表格分页数据对象")
  17 +//@Data
  18 +//public class ConstTableDataInfo extends TableDataInfo implements Serializable
  19 +//{
  20 +// private static final long serialVersionUID = 1L;
  21 +//
  22 +// /** 总记录数 */
  23 +// @ApiModelProperty("总记录数")
  24 +// private long total;
  25 +//
  26 +// /** 列表数据 */
  27 +// @ApiModelProperty("列表数据")
  28 +// private List<?> rows;
  29 +//
  30 +// /** 消息状态码 */
  31 +// @ApiModelProperty("消息状态码")
  32 +// private int code;
  33 +//
  34 +// /** 消息内容 */
  35 +// @ApiModelProperty("消息内容")
  36 +// private String msg;
  37 +//
  38 +// /**
  39 +// * 表格数据对象
  40 +// */
  41 +// public ConstTableDataInfo()
  42 +// {
  43 +// }
  44 +//
  45 +// /**
  46 +// * 分页
  47 +// *
  48 +// * @param list 列表数据
  49 +// * @param total 总记录数
  50 +// */
  51 +// public ConstTableDataInfo(List<?> list, int total)
  52 +// {
  53 +// this.rows = list;
  54 +// this.total = total;
  55 +// }
  56 +//
  57 +//}
... ...
ruoyi-admin/src/main/java/com/ruoyi/pojo/DriverSignRecommendation.java 0 → 100644
  1 +package com.ruoyi.pojo;
  2 +
  3 +import com.ruoyi.pojo.entity.DriverScheduling;
  4 +import lombok.Data;
  5 +
  6 +import static com.ruoyi.common.ConstDriverProperties.BC_TYPE_OUT;
  7 +
  8 +/**
  9 + * 驾驶员操作对象
  10 + *
  11 + * @author 20412
  12 + */
  13 +@Data
  14 +public class DriverSignRecommendation {
  15 + private Long id;
  16 + private String posts;
  17 + private String bcType;
  18 + private Integer index;
  19 + private Long timestamps;
  20 + private Long signInId;
  21 + private Integer exType;
  22 +
  23 + public DriverSignRecommendation() {
  24 + }
  25 +
  26 + public DriverSignRecommendation(DriverScheduling dto, Integer index) {
  27 + this.setIndex(index);
  28 + this.setBcType(dto.getBcType());
  29 + this.setTimestamps(BC_TYPE_OUT.equals(dto.getBcType()) ? dto.getFcsjT() : dto.getZdsjT());
  30 + this.setSignInId(dto.getSignInId());
  31 + this.setPosts(dto.getPosts());
  32 + this.setExType(dto.getExType());
  33 + }
  34 +}
... ...
ruoyi-admin/src/main/java/com/ruoyi/pojo/GlobalIndex.java 0 → 100644
  1 +package com.ruoyi.pojo;
  2 +
  3 +import lombok.Data;
  4 +
  5 +/**
  6 + * @author 20412
  7 + */
  8 +@Data
  9 +public class GlobalIndex {
  10 + private Integer index;
  11 + public GlobalIndex(){this.index = -1;}
  12 +}
... ...
ruoyi-admin/src/main/java/com/ruoyi/pojo/converter/SignInConvert.java
... ... @@ -35,7 +35,7 @@ public class SignInConvert implements Converter&lt;Integer&gt; {
35 35 if (SIGN_IN.equals(integer)){
36 36 str = SIGN_IN_STRING;
37 37 }
38   - if (SIGNIN_OUT.equals(integer)){
  38 + if (SIGN_OUT.equals(integer)){
39 39 str = SIGN_IN_OUT_STRING;
40 40 }
41 41 return new CellData(str);
... ...
ruoyi-admin/src/main/java/com/ruoyi/pojo/entity/DriverScheduling.java 0 → 100644
  1 +package com.ruoyi.pojo.entity;
  2 +
  3 +import lombok.Data;
  4 +
  5 +import java.util.Date;
  6 +
  7 +@Data
  8 +public class DriverScheduling {
  9 + private Long id;
  10 + private String jobCode;
  11 + private String name;
  12 + private String posts;
  13 + private Date scheduleDate;
  14 + private String lineName;
  15 + private String lpName;
  16 + private String nbbm;
  17 + private String bcType;
  18 + private Long fcsjT;
  19 + private Long zdsjT;
  20 + private Long signInId;
  21 + private Integer exType;
  22 +}
... ...
ruoyi-admin/src/main/java/com/ruoyi/pojo/equipment/EquipmentOnline.java
... ... @@ -29,7 +29,7 @@ public class EquipmentOnline {
29 29 @Autowired
30 30 private EquipmentOnline(EquipmentMapper mapper) {
31 31 log.info("初始化设备信息");
32   -// initClient(mapper);
  32 + initClient(mapper);
33 33 log.info("设备信息初始化完毕");
34 34 }
35 35  
... ...
ruoyi-admin/src/main/java/com/ruoyi/pojo/request/DriverRequestVo.java 0 → 100644
  1 +package com.ruoyi.pojo.request;
  2 +
  3 +import com.ruoyi.driver.domain.Driver;
  4 +import io.swagger.annotations.ApiModel;
  5 +import io.swagger.annotations.ApiModelProperty;
  6 +import lombok.Data;
  7 +
  8 +/**
  9 + * @author 20412
  10 + */
  11 +@Data
  12 +@ApiModel("驾驶员对象vo")
  13 +public class DriverRequestVo extends Driver {
  14 + @ApiModelProperty("设备号")
  15 + private String deviceId;
  16 +}
... ...
ruoyi-admin/src/main/java/com/ruoyi/pojo/request/ReportViewRequestVo.java
... ... @@ -22,15 +22,10 @@ public class ReportViewRequestVo {
22 22 @ApiModelProperty("员工工号")
23 23 private String jobCode;
24 24 /**
25   - * 开始时间
  25 + * 日期
26 26 */
27   - @ApiModelProperty("开始时间")
28   - String startTime;
29   - /**
30   - * 结束时间
31   - */
32   - @ApiModelProperty("结束时间")
33   - String endTime;
  27 + @ApiModelProperty("日期")
  28 + private String date;
34 29 /**
35 30 * 签到状态
36 31 */
... ... @@ -42,7 +37,7 @@ public class ReportViewRequestVo {
42 37 @ApiModelProperty("姓名")
43 38 String name;
44 39  
45   - @ApiModelProperty("是否导出图片")
  40 + @ApiModelProperty("导出天还是月 1 天 2 月")
46 41 Integer exportFlag;
47 42  
48 43 }
... ...
ruoyi-admin/src/main/java/com/ruoyi/pojo/response/DriverResponseVo.java
... ... @@ -18,11 +18,16 @@ public class DriverResponseVo extends Driver {
18 18 private Boolean checkAlcohol;
19 19 @ApiModelProperty("计划动作(签到,签退)")
20 20 private String planAction;
  21 + @ApiModelProperty("是否有排班(true:有,false:没有)")
  22 + private Boolean schedulingFlag;
  23 + @ApiModelProperty("打卡时间")
  24 + private Long signTime;
21 25  
22   - public DriverResponseVo(Driver driver){
23   -
24   - this.setCheckAlcohol(false);
25   - this.setPlanAction("签到");
  26 + public DriverResponseVo(Long signTime, Driver driver,String planAction,Boolean checkAlcohol,Boolean schedulingFlag){
  27 + this.setSignTime(signTime);
  28 + this.setSchedulingFlag(schedulingFlag);
  29 + this.setCheckAlcohol(checkAlcohol);
  30 + this.setPlanAction(planAction);
26 31 this.setId(driver.getId());
27 32 this.setJobCode(driver.getJobCode());
28 33 this.setCompanyCode(driver.getCompanyCode());
... ...
ruoyi-admin/src/main/java/com/ruoyi/pojo/response/ExportReportViewResponseVo.java 0 → 100644
  1 +package com.ruoyi.pojo.response;
  2 +
  3 +import io.swagger.annotations.ApiModel;
  4 +import lombok.Data;
  5 +
  6 +/**
  7 + * @author 20412
  8 + */
  9 +@Data
  10 +@ApiModel("报表对象表")
  11 +public class ExportReportViewResponseVo {
  12 +}
... ...
ruoyi-admin/src/main/java/com/ruoyi/pojo/response/ReportSignInResponseVo.java
... ... @@ -19,20 +19,20 @@ public class ReportSignInResponseVo extends ReportViewResponseVo{
19 19 */
20 20 List<ReportSignInResponseVo> children;
21 21 public ReportSignInResponseVo(ReportViewResponseVo vo){
22   - this.count = 1;
23   - this.children = new ArrayList<>();
24   - this.setPosts(vo.getPosts());
25   - this.setCreateTime(vo.getCreateTime());
26   - this.setId(vo.getId());
27   - this.setImage(vo.getImage());
28   - this.setAlcoholFlag(vo.getAlcoholFlag());
29   - this.setType(vo.getType());
30   - this.setJobCode(vo.getJobCode());
31   - this.setAlcoholIntake(vo.getAlcoholIntake());
32   - this.setName(vo.getName());
33   - this.setRemark(vo.getRemark());
34   - this.setStatus(vo.getStatus());
35   - this.setSingnIn(vo.getSingnIn());
  22 +// this.count = 1;
  23 +// this.children = new ArrayList<>();
  24 +// this.setPosts(vo.getPosts());
  25 +// this.setCreateTime(vo.getCreateTime());
  26 +// this.setId(vo.getId());
  27 +// this.setImage(vo.getImage());
  28 +// this.setAlcoholFlag(vo.getAlcoholFlag());
  29 +// this.setType(vo.getType());
  30 +// this.setJobCode(vo.getJobCode());
  31 +// this.setAlcoholIntake(vo.getAlcoholIntake());
  32 +// this.setName(vo.getName());
  33 +// this.setRemark(vo.getRemark());
  34 +// this.setStatus(vo.getStatus());
  35 +// this.setSingnIn(vo.getSingnIn());
36 36 }
37 37 public ReportSignInResponseVo(){
38 38  
... ...
ruoyi-admin/src/main/java/com/ruoyi/pojo/response/ReportViewResponseVo.java
... ... @@ -26,91 +26,38 @@ import java.util.Date;
26 26 @ApiModel("滚动大屏响应体数据")
27 27 @Data
28 28 public class ReportViewResponseVo {
29   - @ApiModelProperty("id")
30   - @ExcelIgnore
31   - private Long id;
32 29  
33   - @ExcelProperty(value = "工号")
34 30 @ApiModelProperty("工号")
35 31 private String jobCode;
36 32  
37   - @ExcelProperty(value = "签到类型", converter = SignInTypeConverter.class)
38   - @ColumnWidth(10)
39   - @ApiModelProperty("签到类型")
40   - private String singnIn;
41   -
42   - @ExcelProperty(value = "姓名")
43 33 @ApiModelProperty("姓名")
44 34 private String name;
45 35  
46   - @ExcelProperty(value = "签到时间")
47   - @ColumnWidth(27)
48   - @ApiModelProperty("签到时间")
49   - @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
50   - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
51   - private Date createTime;
  36 + @ApiModelProperty("工种")
  37 + private String posts;
52 38  
53   - @ExcelProperty(value = "签到状态", converter = SignInStatusConverter.class)
54   - @ColumnWidth(10)
55   - @ApiModelProperty("签到状态1 成功2 异常")
56   - private Integer status;
57   - /**
58   - * 签到签退
59   - */
60   - @ApiModelProperty("签到签退")
61   - @ExcelProperty(value = "签到签退", converter = SignInConvert.class)
62   - @ColumnWidth(10)
63   - private Integer type;
64   - /**
65   - * 是否酒精检测 1 检查 2 未检
66   - */
67   - @ExcelProperty(value = "酒精检测", converter = AlcoholFlagConverter.class)
68   - @ColumnWidth(10)
69   - @ApiModelProperty("是否酒精检测 1 检查 2 未检")
70   - private Integer alcoholFlag;
71   - /**
72   - * 酒精含量
73   - */
74   - @ExcelProperty(value = "酒精含量")
75   - @ColumnWidth(10)
76   - @ApiModelProperty("酒精含量")
77   - private BigDecimal alcoholIntake;
  39 + @ApiModelProperty("线路名称")
  40 + private String lineName;
78 41  
79   - @ExcelProperty(value = "头像",converter = ImageConverter.class)
80   - @ApiModelProperty("头像")
81   - private String image;
  42 + @ApiModelProperty("车队名称")
  43 + private String fleetName;
82 44  
83   - @ExcelProperty(value = "工种")
84   - @ApiModelProperty("工种")
85   - private String posts;
  45 + @ApiModelProperty("车辆自编号")
  46 + private String nbbm;
86 47  
87   - /**
88   - * 签到地址
89   - */
90   - @ExcelProperty("签到地址")
91   - @ColumnWidth(40)
92   - @ApiModelProperty("签到地址")
93   - String address;
  48 + private Integer planSignInCount;
  49 + private Integer actualSignInCount;
  50 + private Integer planSignOutCount;
  51 + private Integer actualSignOutCount;
94 52  
95   - /**
96   - * 设备id
97   - */
98   - @ApiModelProperty("设备号")
99   - @ExcelProperty("设备号")
100   - String deviceId;
  53 + @ExcelProperty(value = "签到状态", converter = SignInStatusConverter.class)
  54 + @ApiModelProperty("签到状态")
  55 + private Integer status;
  56 +
  57 + @ApiModelProperty("排班日期")
  58 + private Date schedulingDate;
101 59  
102   - @ExcelProperty(value = "备注")
103   - @ColumnWidth(40)
104 60 @ApiModelProperty("备注")
105 61 private String remark;
106 62  
107   - @ExcelProperty(value = "线路名称")
108   - @ApiModelProperty("线路名称")
109   - @ColumnWidth(20)
110   - private String lineName;
111   -
112   - @ExcelProperty(value = "车队名称")
113   - @ApiModelProperty("车队名称")
114   - @ColumnWidth(20)
115   - private String fleetName;
116 63 }
... ...
ruoyi-admin/src/main/java/com/ruoyi/pojo/response/ResponseScheduling.java renamed to ruoyi-admin/src/main/java/com/ruoyi/pojo/response/ResponseSchedulingDto.java
... ... @@ -13,7 +13,7 @@ import java.util.List;
13 13 * @website http://www.json.cn/java2pojo/
14 14 */
15 15 @Data
16   -public class ResponseScheduling {
  16 +public class ResponseSchedulingDto {
17 17  
18 18 private Long id;
19 19 @DateTimeFormat(pattern = "yyyy-MM-dd")
... ... @@ -21,6 +21,7 @@ public class ResponseScheduling {
21 21 private String lineName;
22 22 private String lineCode;
23 23 private String jobCode;
  24 + private String posts;
24 25 private String lpName;
25 26 private String nbbm;
26 27 private String jsy;
... ... @@ -44,4 +45,5 @@ public class ResponseScheduling {
44 45 private Boolean sflj;
45 46 private String remarks;
46 47 private List<CTasks> cTasks;
  48 + private String name;
47 49 }
48 50 \ No newline at end of file
... ...
ruoyi-admin/src/main/java/com/ruoyi/pojo/response/SignInResponseVo.java
... ... @@ -26,7 +26,7 @@ public class SignInResponseVo extends SignIn {
26 26  
27 27 public SignInResponseVo(SignIn signIn){
28 28 this.setDeviceId(signIn.getDeviceId());
29   - this.setId(0L);
  29 + this.setId(signIn.getId());
30 30 this.setJobCode(signIn.getJobCode());
31 31 this.setIp(signIn.getIp());
32 32 this.setImage(signIn.getImage());
... ... @@ -35,17 +35,12 @@ public class SignInResponseVo extends SignIn {
35 35 this.setAlcoholFlag(signIn.getAlcoholFlag());
36 36 this.setType(signIn.getType());
37 37 this.setAlcoholIntake(signIn.getAlcoholIntake());
38   - this.setLineName(signIn.getLineName());
39   - this.setCarNum(signIn.getCarNum());
40   - this.setRoadNum(signIn.getRoadNum());
41 38 this.setSearchValue(signIn.getSearchValue());
42 39 this.setCreateBy(signIn.getCreateBy());
43 40 this.setCreateTime(signIn.getCreateTime());
44 41 this.setUpdateBy(signIn.getUpdateBy());
45 42 this.setUpdateTime(signIn.getUpdateTime());
46 43 this.setRemark(signIn.getRemark());
47   -
48   -
49 44 }
50 45 public SignInResponseVo(){}
51 46  
... ...
ruoyi-admin/src/main/java/com/ruoyi/service/ReportService.java
... ... @@ -11,10 +11,10 @@ import com.ruoyi.pojo.request.ReportErrorRequestVo;
11 11 import com.ruoyi.pojo.response.ReportErrorResponseVo;
12 12 import com.ruoyi.pojo.response.ReportSignInResponseVo;
13 13 import com.ruoyi.pojo.response.ReportViewResponseVo;
14   -import org.apache.poi.ss.formula.functions.Offset;
15 14 import org.springframework.beans.factory.annotation.Autowired;
16 15 import org.springframework.stereotype.Service;
17 16  
  17 +import javax.servlet.http.HttpServletResponse;
18 18 import java.text.SimpleDateFormat;
19 19 import java.util.*;
20 20 import java.util.stream.Collectors;
... ... @@ -37,11 +37,14 @@ public class ReportService {
37 37 @Autowired
38 38 private DriverMapper driverMapper;
39 39  
  40 + @Autowired
  41 + private SchedulingService schedulingService;
  42 +
40 43 /**
41 44 * 查询报表信息
42 45 */
43   - public List<ReportViewResponseVo> getReportScrollViewTable(ReportViewRequestVo requestVo) {
44   - List<ReportViewResponseVo> reportScrollViewTable = signInMapper.getReportScrollViewTable(requestVo);
  46 + public List<ReportViewResponseVo> getReportScrollViewTable(ReportViewRequestVo requestVo, HttpServletResponse response) {
  47 + List<ReportViewResponseVo> reportScrollViewTable = schedulingService.queryReportTableResponseVo(requestVo,response);
45 48 return reportScrollViewTable;
46 49 }
47 50  
... ... @@ -109,29 +112,13 @@ public class ReportService {
109 112 });
110 113 }
111 114  
112   - public List<ReportSignInResponseVo> handlerList(List<ReportViewResponseVo> reportScrollViewTable) {
113   - Map<String, ReportSignInResponseVo> responseMapVo = new HashMap<>(30);
114   - for (ReportViewResponseVo originVo : reportScrollViewTable) {
115   - String dayKey = getDateDay(originVo.getCreateTime()) + originVo.getJobCode();
116   - if (Objects.isNull(responseMapVo.get(dayKey))) {
117   - responseMapVo.put(dayKey, new ReportSignInResponseVo(originVo));
118   - } else {
119   - ReportSignInResponseVo responseVo = responseMapVo.get(dayKey);
120   - responseVo.getChildren().add(new ReportSignInResponseVo(originVo));
121   - responseVo.setCount(responseVo.getCount() + 1);
122   - }
123   - }
124   - ArrayList<ReportSignInResponseVo> vos = new ArrayList<>(responseMapVo.values());
125   - for (ReportSignInResponseVo vo : vos) {
126   - if (!Objects.isNull(vo)){
127   - vo.getChildren().sort(Comparator.comparing(ReportSignInResponseVo::getCreateTime).reversed());
128   - }
129   - }
130   - return vos;
131   - }
132   -
133 115 public String getDateDay(Date createTime) {
134 116 SimpleDateFormat simple = new SimpleDateFormat("yyyy-MM-dd");
135 117 return simple.format(createTime);
136 118 }
  119 +
  120 + public List<ReportViewResponseVo> exportReportList(ReportViewRequestVo requestVo, HttpServletResponse response) {
  121 +
  122 + return null;
  123 + }
137 124 }
... ...
ruoyi-admin/src/main/java/com/ruoyi/service/SchedulingService.java 0 → 100644
  1 +package com.ruoyi.service;
  2 +
  3 +import com.ruoyi.driver.mapper.DriverSchedulingMapper;
  4 +import com.ruoyi.in.domain.SignIn;
  5 +import com.ruoyi.in.mapper.SignInMapper;
  6 +import com.ruoyi.pojo.DriverSignRecommendation;
  7 +import com.ruoyi.pojo.GlobalIndex;
  8 +import com.ruoyi.pojo.entity.DriverScheduling;
  9 +import com.ruoyi.pojo.request.ReportViewRequestVo;
  10 +import com.ruoyi.pojo.response.ReportViewResponseVo;
  11 +import com.ruoyi.utils.ConstDateUtil;
  12 +import org.springframework.beans.BeanUtils;
  13 +import org.springframework.beans.factory.annotation.Autowired;
  14 +import org.springframework.stereotype.Service;
  15 +
  16 +import javax.servlet.http.HttpServletResponse;
  17 +import java.time.LocalDate;
  18 +import java.time.LocalDateTime;
  19 +import java.time.YearMonth;
  20 +import java.time.temporal.ChronoUnit;
  21 +import java.util.*;
  22 +
  23 +import static com.ruoyi.common.ConstDriverProperties.BC_TYPE_IN;
  24 +import static com.ruoyi.common.ConstDriverProperties.BC_TYPE_OUT;
  25 +import static com.ruoyi.common.ConstSignInConstSignInProperties.*;
  26 +import static com.ruoyi.common.ErrorTypeProperties.SIGN_IN_TIMEOUT;
  27 +import static com.ruoyi.common.ErrorTypeProperties.SIGN_OUT_TIMEOUT;
  28 +import static com.ruoyi.common.ReportProperties.DAY;
  29 +import static com.ruoyi.common.ReportProperties.MONTH;
  30 +
  31 +/**
  32 + * @author 20412
  33 + */
  34 +@Service
  35 +public class SchedulingService {
  36 +
  37 + @Autowired
  38 + private DriverSchedulingMapper schedulingMapper;
  39 +
  40 + @Autowired
  41 + private SignInMapper signInMapper;
  42 +
  43 + /**
  44 + * 获取排班信息
  45 + *
  46 + * @param jobCode
  47 + * @param now
  48 + * @return
  49 + */
  50 + public List<DriverScheduling> queryScheduling(String jobCode, Long now) {
  51 + // TODO 查表变成缓存查询
  52 + List<DriverScheduling> dto = null;
  53 + for (int i = 0; i > -2; i--) {
  54 + dto = schedulingMapper.queryToDay(ConstDateUtil.formatDate(ConstDateUtil.getTheSpecifiedNumberOfDaysOfTime(i)), jobCode);
  55 + if (!Objects.isNull(dto)) {
  56 + dto.sort(Comparator.comparing(DriverScheduling::getZdsjT));
  57 + if (i == -1) {
  58 + LocalDateTime zdsjT = ConstDateUtil.getLocalDateTimeByLongTime(dto.get(dto.size() - 1).getZdsjT());
  59 + LocalDateTime nowTime = ConstDateUtil.getLocalDateTimeByLongTime(now);
  60 + long range = ChronoUnit.MINUTES.between(zdsjT, nowTime);
  61 + // 判定存在排班
  62 + if (range <= 120L) {
  63 + return dto;
  64 + } else {
  65 + dto = null;
  66 + }
  67 + }
  68 + break;
  69 + }
  70 + }
  71 + return dto;
  72 + }
  73 +
  74 + /**
  75 + * 计算签到逻辑
  76 + *
  77 + * @param dto
  78 + * @param now
  79 + * @return
  80 + */
  81 + public DriverSignRecommendation computedTheCurrentClosestTimestamp(List<DriverScheduling> dto, Long now, Integer result) {
  82 + Map<Integer, DriverSignRecommendation> timeMap = new HashMap<>();
  83 + for (int i = 0; i < dto.size(); i++) {
  84 + timeMap.put(i, new DriverSignRecommendation(dto.get(i), i));
  85 + }
  86 + long minDiff = Long.MAX_VALUE;
  87 + Integer index = 0;
  88 + // 迭代比较每个时间戳与当前时间戳的差值
  89 + for (Integer i : timeMap.keySet()) {
  90 + long diff = Math.abs(now - timeMap.get(i).getTimestamps());
  91 + if (diff < minDiff) {
  92 + minDiff = diff;
  93 + index = i;
  94 + }
  95 + }
  96 + if (index + result >= 0 && index + result < timeMap.size()) {
  97 + index = index + result;
  98 + }
  99 + return timeMap.get(index);
  100 + }
  101 +
  102 + /**
  103 + * 更具最新的签到记录判断是否需要更新考勤。
  104 + *
  105 + * @param dto
  106 + * @param signIn
  107 + * @param globalIndex
  108 + */
  109 + public void computedSignInBySignIn(List<DriverScheduling> dto, SignIn signIn, GlobalIndex globalIndex) {
  110 + // 更新最新的签到记录判断是否需要更新考勤
  111 + // 记录为空直接插入记录
  112 + if (Objects.isNull(dto.get(globalIndex.getIndex()).getSignInId())) {
  113 + schedulingMapper.updateRoster(dto.get(globalIndex.getIndex()), signIn.getId(), signIn.getExType());
  114 + }
  115 + // 之前的无效
  116 + else if (!dto.get(globalIndex.getIndex()).getExType().equals(SIGN_NO_EX_NUM)) {
  117 + schedulingMapper.updateRoster(dto.get(globalIndex.getIndex()), signIn.getId(), signIn.getExType());
  118 + }
  119 + // 之前的有效
  120 + else {
  121 + handleRecord(dto, signIn, globalIndex);
  122 + }
  123 +
  124 + }
  125 +
  126 + private void handleRecord(List<DriverScheduling> dto, SignIn signIn, GlobalIndex globalIndex) {
  127 + if (globalIndex.getIndex() == dto.size() - 1) {
  128 + return;
  129 + }
  130 + Integer index = globalIndex.getIndex() + 1;
  131 + // 之前是签到 | 目前有效记录 -》进行修改 变成无效
  132 + if (signIn.getExType().equals(SIGN_NO_EX_NUM)) {
  133 + signIn.setStatus(SIGN_IN_FAIL);
  134 + signIn.setExType(SIGN_TIME_OUT_EX_NUM);
  135 + signIn.setRemark(dto.get(index).getBcType().equals(BC_TYPE_IN) ? SIGN_OUT_TIMEOUT : SIGN_IN_TIMEOUT);
  136 + signIn.setRemark(signIn.getRemark().replaceFirst(",$", "。"));
  137 + signInMapper.updateSignIn(signIn);
  138 + }
  139 +
  140 + // 之前是签到 | 目前无效 -》往后更新
  141 + schedulingMapper.updateRoster(dto.get(globalIndex.getIndex() + 1), signIn.getId(), signIn.getExType());
  142 + }
  143 +
  144 + public List<ReportViewResponseVo> queryReportTableResponseVo(ReportViewRequestVo requestVo, HttpServletResponse response) {
  145 + // 处理天
  146 + if (requestVo.getExportFlag().equals(DAY)) {
  147 + return getDayReportTableResponseVo(requestVo.getDate(), response);
  148 + }
  149 +// // 处理月
  150 +// else if (requestVo.getExportFlag().equals(MONTH)) {
  151 +// return getMonthReportTableResponseVo(requestVo, response);
  152 +// }
  153 +
  154 + return null;
  155 + }
  156 +
  157 + private List<ReportViewResponseVo> getMonthReportTableResponseVo(ReportViewRequestVo requestVo, HttpServletResponse response) {
  158 + // TODO
  159 + // 获取当月到目前为止的所有数据
  160 + List<String> dayList = getAllDaysOfTheMonth();
  161 + for (String date : dayList) {
  162 + getDayReportTableResponseVo(date, response);
  163 + }
  164 + return null;
  165 + }
  166 +
  167 + private List<String> getAllDaysOfTheMonth() {
  168 + // 获取当前日期
  169 + LocalDate currentDate = LocalDate.now();
  170 +
  171 + // 获取当前月份
  172 + YearMonth currentMonth = YearMonth.from(currentDate);
  173 + int nowDay = Integer.parseInt(ConstDateUtil.formatDate("dd"));
  174 + // 构建日期集合
  175 + List<String> datesInMonth = new ArrayList<>();
  176 + for (int day = 1; day <= nowDay; day++) {
  177 + String date = currentMonth.atDay(day).toString();
  178 + datesInMonth.add(date);
  179 + }
  180 + return datesInMonth;
  181 + }
  182 +
  183 +
  184 + private List<ReportViewResponseVo> getDayReportTableResponseVo(String date, HttpServletResponse response) {
  185 + // 签到数据
  186 + List<DriverScheduling> toDay = schedulingMapper.queryToDay(date, null);
  187 + // 转换日期 + jobCode为key
  188 + Map<String, List<DriverScheduling>> orangeMap = new HashMap<>(1200);
  189 + for (DriverScheduling scheduling : toDay) {
  190 + String key = date + scheduling.getJobCode();
  191 + if (Objects.isNull(orangeMap.get(key))) {
  192 + orangeMap.put(key, new ArrayList<>(Arrays.asList(scheduling)));
  193 + } else {
  194 + orangeMap.get(key).add(scheduling);
  195 + }
  196 + }
  197 + Map<String, ReportViewResponseVo> resultMap = new HashMap<>(1200);
  198 + for (String key : orangeMap.keySet()) {
  199 + List<DriverScheduling> list = orangeMap.get(key);
  200 + ReportViewResponseVo vo = new ReportViewResponseVo();
  201 + handleScheduling(list, vo);
  202 + resultMap.put(key, vo);
  203 + }
  204 + return new ArrayList<>(resultMap.values());
  205 + }
  206 +
  207 + private static void handleScheduling(List<DriverScheduling> list, ReportViewResponseVo vo) {
  208 + int planSignInCount = 0;
  209 + int actualSignInCount = 0;
  210 + int planSignOutCount = 0;
  211 + int actualSignOutCount = 0;
  212 + Boolean exFlag = false;
  213 + BeanUtils.copyProperties(list.get(0), vo);
  214 + for (DriverScheduling scheduling : list) {
  215 + // 获取计划签到|签退次数
  216 + if (scheduling.getBcType().equals(BC_TYPE_OUT)) {
  217 + planSignInCount = planSignInCount + 1;
  218 + if (!Objects.isNull(scheduling.getSignInId())) {
  219 + actualSignInCount = actualSignInCount + 1;
  220 + }
  221 + } else {
  222 + planSignOutCount = planSignOutCount + 1;
  223 + if (!Objects.isNull(scheduling.getSignInId())) {
  224 + actualSignOutCount = actualSignOutCount + 1;
  225 + }
  226 + }
  227 + // 判断是否异常
  228 +// if (scheduling.getSignInId())
  229 + exFlag = true;
  230 + }
  231 + vo.setPlanSignInCount(planSignInCount);
  232 + vo.setPlanSignOutCount(planSignOutCount);
  233 + vo.setActualSignInCount(actualSignInCount);
  234 + vo.setActualSignOutCount(actualSignOutCount);
  235 + }
  236 +}
... ...
ruoyi-admin/src/main/java/com/ruoyi/service/ThreadJobService.java
1 1 package com.ruoyi.service;
2 2  
3 3  
  4 +import cn.hutool.core.collection.CollectionUtil;
4 5 import cn.hutool.http.HttpUtil;
5 6 import com.ruoyi.common.config.RuoYiConfig;
6 7 import com.ruoyi.common.exception.file.FileUploadException;
... ... @@ -8,8 +9,14 @@ import com.ruoyi.common.utils.StringUtils;
8 9 import com.ruoyi.common.utils.file.FileUploadUtils;
9 10 import com.ruoyi.driver.domain.Driver;
10 11 import com.ruoyi.driver.mapper.DriverMapper;
  12 +import com.ruoyi.driver.mapper.DriverSchedulingMapper;
11 13 import com.ruoyi.job.DriverJob;
  14 +import com.ruoyi.pojo.entity.DriverScheduling;
  15 +import com.ruoyi.pojo.response.ResponseSchedulingDto;
  16 +import com.ruoyi.utils.ConstDateUtil;
  17 +import com.ruoyi.utils.ToolUtils;
12 18 import lombok.extern.slf4j.Slf4j;
  19 +import org.springframework.beans.BeanUtils;
13 20 import org.springframework.beans.factory.annotation.Autowired;
14 21 import org.springframework.beans.factory.annotation.Value;
15 22 import org.springframework.scheduling.annotation.Async;
... ... @@ -23,8 +30,11 @@ import org.springframework.web.client.RestTemplate;
23 30 import sun.misc.BASE64Decoder;
24 31  
25 32 import java.io.*;
26   -import java.util.List;
27   -import java.util.Objects;
  33 +import java.util.*;
  34 +import java.util.stream.Collectors;
  35 +
  36 +import static com.ruoyi.common.ConstDriverProperties.BC_TYPE_IN;
  37 +import static com.ruoyi.common.ConstDriverProperties.BC_TYPE_OUT;
28 38  
29 39  
30 40 /**
... ... @@ -41,6 +51,10 @@ public class ThreadJobService {
41 51 private DriverMapper driverMapper;
42 52  
43 53 @Autowired
  54 + private DriverSchedulingMapper schedulingMapper;
  55 +
  56 +
  57 + @Autowired
44 58 private PlatformTransactionManager transactionManager;
45 59  
46 60 @Value("${api.headImage}")
... ... @@ -114,7 +128,7 @@ public class ThreadJobService {
114 128 } catch (Exception e) {
115 129 // 回滚事务
116 130 transactionManager.rollback(transaction);
117   - log.error("保存数据是出现了异常:{}",e.getMessage());
  131 + log.error("保存数据是出现了异常:{}", e.getMessage());
118 132 }
119 133 }
120 134  
... ... @@ -151,12 +165,12 @@ public class ThreadJobService {
151 165 try {
152 166 uploadImage(is, filePath);
153 167 } catch (IOException e) {
154   - log.error("工号:{}的人脸图像,上传失败:{}" , driver.getJobCode(), e.getMessage());
  168 + log.error("工号:{}的人脸图像,上传失败:{}", driver.getJobCode(), e.getMessage());
155 169 is = getImageInputStreamByUrl(imageUrl);
156 170 try {
157 171 uploadImage(is, filePath);
158 172 } catch (IOException ex) {
159   - log.error("工号:{}的人脸图像,再次上传失败:{}" , driver.getJobCode(), e.getMessage());
  173 + log.error("工号:{}的人脸图像,再次上传失败:{}", driver.getJobCode(), e.getMessage());
160 174 throw new RuntimeException(ex);
161 175 }
162 176 }
... ... @@ -230,4 +244,39 @@ public class ThreadJobService {
230 244 }
231 245  
232 246  
  247 + /**
  248 + * 保存当天的调度信息
  249 + *
  250 + * @param originSchedulingMap
  251 + */
  252 + @Async
  253 + @Transactional(rollbackFor = {Exception.class})
  254 + public void asyncComputedScheduling(Map<String, List<ResponseSchedulingDto>> originSchedulingMap) {
  255 + //查询当天是否保存过考情表 如果存在则保存
  256 + List<DriverScheduling> dto = schedulingMapper.queryToDay(ConstDateUtil.formatDate("yyyy-MM-dd"), null);
  257 + if (!CollectionUtil.isEmpty(dto) || originSchedulingMap.size() == 0) {
  258 +// log.info("今天已获取过考勤数据");
  259 + return;
  260 + }
  261 + List<DriverScheduling> bcList = new ArrayList<>(1000);
  262 + for (String key : originSchedulingMap.keySet()) {
  263 + List<ResponseSchedulingDto> schedulingList = originSchedulingMap.get(key);
  264 + List<DriverScheduling> nowScheduling = schedulingList.stream()
  265 + .filter(item -> BC_TYPE_IN.equals(item.getBcType()) || BC_TYPE_OUT.equals(item.getBcType()))
  266 + .map(item -> {
  267 + DriverScheduling scheduling = new DriverScheduling();
  268 + BeanUtils.copyProperties(item, scheduling);
  269 + return scheduling;
  270 + }).collect(Collectors.toList());
  271 + if (nowScheduling.size() > 4){
  272 + System.out.println("问题工号:" + key);
  273 + }
  274 + if (nowScheduling.size() % 2 == 1){
  275 + System.out.println("问题工号:" + key);
  276 + }
  277 + bcList.addAll(nowScheduling);
  278 + }
  279 + schedulingMapper.insertRoster(bcList);
  280 + }
  281 +
233 282 }
... ...
ruoyi-admin/src/main/java/com/ruoyi/utils/ToolUtils.java 0 → 100644
  1 +package com.ruoyi.utils;
  2 +
  3 +import com.ruoyi.common.utils.uuid.UUID;
  4 +
  5 +public class ToolUtils {
  6 +
  7 + public static String getUUID(){
  8 + return UUID.randomUUID().toString().replaceAll("-","");
  9 + }
  10 +}
... ...
ruoyi-admin/src/main/resources/mapper/driver/DriverMapper.xml
... ... @@ -57,29 +57,54 @@
57 57 </sql>
58 58  
59 59 <select id="selectDriverList" parameterType="Driver" resultMap="DriverResult">
60   - <include refid="selectDriverVo"/>
  60 + select
  61 + driver.id,
  62 + driver.job_code,
  63 + driver.company_code,
  64 + driver.branche_company_code,
  65 + driver.personnel_name,
  66 + driver.papers_code,
  67 + driver.ic_card_code,
  68 + driver.personnel_type,
  69 + driver.posts,
  70 + driver.card,
  71 + driver.telphone,
  72 + driver.ic_rfid,
  73 + driver.id_rfid,
  74 + driver.tag_rfid,
  75 + driver.remark,
  76 + driver.line_name,
  77 + driver.line_code,
  78 + driver.face_sign_in,
  79 + driver.image,
  80 + driver.update_time,
  81 + driver.sign_in_equipment,
  82 + driver.fleet_name
  83 + from driver
  84 + left join driver_face_device_id on driver.job_code = driver_face_device_id.job_code
61 85 <where>
62   - <if test="jobCode != null and jobCode != ''">and job_code = #{jobCode}</if>
63   - <if test="companyCode != null and companyCode != ''">and company_code = #{companyCode}</if>
64   - <if test="brancheCompanyCode != null and brancheCompanyCode != ''">and branche_company_code =
  86 + <if test="deviceId != null and deviceId != ''"> and device_id = #{deviceId}</if>
  87 + <if test="jobCode != null and jobCode != ''">and driver.job_code = #{jobCode}</if>
  88 + <if test="companyCode != null and companyCode != ''">and driver.company_code = #{companyCode}</if>
  89 + <if test="brancheCompanyCode != null and brancheCompanyCode != ''">and driver.branche_company_code =
65 90 #{brancheCompanyCode}
66 91 </if>
67   - <if test="personnelName != null and personnelName != ''">and personnel_name like concat('%',
  92 + <if test="personnelName != null and personnelName != ''">and driver.personnel_name like concat('%',
68 93 #{personnelName}, '%')
69 94 </if>
70   - <if test="papersCode != null and papersCode != ''">and papers_code = #{papersCode}</if>
71   - <if test="icCardCode != null and icCardCode != ''">and ic_card_code = #{icCardCode}</if>
72   - <if test="personnelType != null and personnelType != ''">and personnel_type = #{personnelType}</if>
73   - <if test="posts != null and posts != ''">and posts = #{posts}</if>
74   - <if test="card != null and card != ''">and card = #{card}</if>
75   - <if test="telphone != null and telphone != ''">and telphone = #{telphone}</if>
76   - <if test="icRfid != null and icRfid != ''">and ic_rfid = #{icRfid}</if>
77   - <if test="idRfid != null and idRfid != ''">and id_rfid = #{idRfid}</if>
78   - <if test="tagRfid != null and tagRfid != ''">and tag_rfid = #{tagRfid}</if>
79   - <if test="lineName != null and lineName != ''">and line_name like concat('%', #{lineName}, '%')</if>
80   - <if test="lineCode != null and lineCode != ''">and line_code = #{lineCode}</if>
81   - <if test="faceSignIn != null and faceSignIn != ''">and face_sign_in = #{faceSignIn}</if>
82   - <if test="fleetName != null and fleet_name != ''">and fleet_name = #{fleetName}</if>
  95 + <if test="papersCode != null and papersCode != ''">and driver.papers_code = #{papersCode}</if>
  96 + <if test="icCardCode != null and icCardCode != ''">and driver.ic_card_code = #{icCardCode}</if>
  97 + <if test="personnelType != null and personnelType != ''">and driver.personnel_type = #{personnelType}</if>
  98 + <if test="posts != null and posts != ''">and driver.posts = #{posts}</if>
  99 + <if test="card != null and card != ''">and driver.card = #{card}</if>
  100 + <if test="telphone != null and telphone != ''">and driver.telphone = #{telphone}</if>
  101 + <if test="icRfid != null and icRfid != ''">and driver.ic_rfid = #{icRfid}</if>
  102 + <if test="idRfid != null and idRfid != ''">and driver.id_rfid = #{idRfid}</if>
  103 + <if test="tagRfid != null and tagRfid != ''">and driver.tag_rfid = #{tagRfid}</if>
  104 + <if test="lineName != null and lineName != ''">and driver.line_name like concat('%', #{lineName}, '%')</if>
  105 + <if test="lineCode != null and lineCode != ''">and driver.line_code = #{lineCode}</if>
  106 + <if test="faceSignIn != null and faceSignIn != ''">and driver.face_sign_in = #{faceSignIn}</if>
  107 + <if test="fleetName != null and fleet_name != ''">and driver.fleet_name = #{fleetName}</if>
83 108 </where>
84 109 </select>
85 110  
... ... @@ -330,6 +355,41 @@
330 355 job_code = values(job_code),
331 356 device_id = values(device_id)
332 357 </insert>
  358 + <insert id="saveScheduling">
  359 + insert into
  360 + scheduling (id,schedule_date,line_name,line_code,job_code,posts,lp_name,nbbm,jsy,spy,up_down,qdz_code,qdz_name,zdz_code,zdz_name,fcsj_t,dfsj_t,zdsj_t,fcsj_actual_time,zdsj_actual_time,jhlc,jhlc_orig,bcsj,bc_type,`status`,adjust_exps,sflj,remarks)
  361 + values
  362 + <foreach collection="responseSchedulingDto" item="item" open="(" separator="," close=")">
  363 + #{item.id},
  364 + #{item.scheduleDate},
  365 + #{item.lineName},
  366 + #{item.lineCode},
  367 + #{item.jobCode},
  368 + #{item.posts},
  369 + #{item.lpName},
  370 + #{item.nbbm},
  371 + #{item.jsy},
  372 + #{item.spy},
  373 + #{item.upDown},
  374 + #{item.qdzCode},
  375 + #{item.qdzName},
  376 + #{item.zdzCode},
  377 + #{item.zdzName},
  378 + #{item.fcsjT},
  379 + #{item.dfsjT},
  380 + #{item.zdsjT},
  381 + #{item.fcsjActualTime},
  382 + #{item.zdsjActualTime},
  383 + #{item.jhlc},
  384 + #{item.jhlcOrig},
  385 + #{item.bcsj},
  386 + #{item.bcType},
  387 + #{item.status},
  388 + #{item.adjustExps},
  389 + #{item.sflj},
  390 + #{item.remarks}
  391 + </foreach>
333 392  
  393 + </insert>
334 394  
335 395 </mapper>
336 396 \ No newline at end of file
... ...
ruoyi-admin/src/main/resources/mapper/driver_scheduling/DriverSchedulingMapper.xml 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8" ?>
  2 +<!DOCTYPE mapper
  3 + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4 + "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5 +<mapper namespace="com.ruoyi.driver.mapper.DriverSchedulingMapper">
  6 +
  7 +
  8 + <resultMap id="Scheduling" type="com.ruoyi.pojo.entity.DriverScheduling">
  9 + <id column="id" jdbcType="BIGINT" property="id"/>
  10 + <result column="job_code" property="jobCode"/>
  11 + <result column="name" property="name"/>
  12 + <result column="posts" property="posts"/>
  13 + <result column="schedule_date" property="scheduleDate" jdbcType="DATE"/>
  14 + <result column="line_name" property="lineName"/>
  15 + <result column="lp_name" property="lpName"/>
  16 + <result column="nbbm" property="nbbm"/>
  17 + <result column="bc_type" property="bcType"/>
  18 + <result column="fcsj_t" property="fcsjT" jdbcType="BIGINT"/>
  19 + <result column="zdsj_t" property="zdsjT" jdbcType="BIGINT"/>
  20 + <result column="sign_in_id" property="signInId" jdbcType="BIGINT"/>
  21 + <result column="ex_type" property="exType" jdbcType="TINYINT"/>
  22 +
  23 + </resultMap>
  24 + <insert id="insertRoster" useGeneratedKeys="true" keyProperty="id">
  25 + insert into scheduling (schedule_date,line_name,job_code,`name`,posts,lp_name,nbbm,bc_type,fcsj_t,zdsj_t)
  26 + values
  27 + <foreach collection="list" item="item" index="index" separator=",">
  28 + (
  29 + #{item.scheduleDate},
  30 + #{item.lineName},
  31 + #{item.jobCode},
  32 + #{item.name},
  33 + #{item.posts},
  34 + #{item.lpName},
  35 + #{item.nbbm},
  36 + #{item.bcType},
  37 + #{item.fcsjT},
  38 + #{item.zdsjT}
  39 + )
  40 +
  41 + </foreach>
  42 + on duplicate key update
  43 + job_code = values(job_code)
  44 + </insert>
  45 + <update id="updateRoster">
  46 + update scheduling set sign_in_id = #{signInId}
  47 + where id = #{scheduling.id}
  48 + </update>
  49 +
  50 + <select id="queryToDay" resultType="com.ruoyi.pojo.entity.DriverScheduling" resultMap="Scheduling">
  51 + select * from
  52 + scheduling
  53 + where schedule_date = #{date}
  54 + <if test="jobCode !=null and jobCode != ''">
  55 + and job_code = #{jobCode}
  56 + </if>
  57 + <if test="jobCode ==null or jobCode == ''">
  58 + limit 1
  59 + </if>
  60 +
  61 + </select>
  62 +</mapper>
0 63 \ No newline at end of file
... ...
ruoyi-admin/src/main/resources/mapper/in/SignInMapper.xml
... ... @@ -20,9 +20,6 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
20 20 <result property="remark" column="remark" />
21 21 <result property="posts" column="posts" />
22 22 <result property="name" column="personnel_name" />
23   - <result property="lineName" column="line_name" />
24   - <result property="carNum" column="car_num" />
25   - <result property="roadNum" column="road_num" />
26 23 </resultMap>
27 24 <resultMap type="SignIn" id="SignInResult">
28 25 <result property="id" column="id" />
... ... @@ -39,9 +36,6 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
39 36 <result property="updateTime" column="update_time" />
40 37 <result property="alcoholIntake" column="alcohol_intake" />
41 38 <result property="remark" column="remark" />
42   - <result property="lineName" column="line_name" />
43   - <result property="carNum" column="car_num" />
44   - <result property="roadNum" column="road_num" />
45 39 </resultMap>
46 40  
47 41 <sql id="selectSignInVo">
... ... @@ -70,30 +64,7 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
70 64 where id = #{id}
71 65 </select>
72 66 <select id="getReportScrollViewTable" resultType="com.ruoyi.pojo.response.ReportViewResponseVo">
73   - SELECT
74   - sign_in.id,
75   - sign_in.singn_in singnIn,
76   - driver.job_code jobCode,
77   - sign_in.device_id deviceId,
78   - personnel_name `name`,
79   - sign_in.create_time createTime,
80   - sign_in.`status`,
81   - type,
82   - alcohol_flag alcoholFlag,
83   - alcohol_intake alcoholIntake,
84   - sign_in.image,
85   - sign_in.remark,
86   - driver.posts,
87   - equipment.address,
88   - driver.fleet_name,
89   - driver.line_name
90   - FROM
91   - equipment,
92   - sign_in,
93   - driver
94   - WHERE
95   - sign_in.jobCode = driver.job_code and
96   - sign_in.device_id = equipment.device_id
  67 +
97 68 <if test="jobCode != '' and jobCode != null">
98 69 and sign_in.jobCode = #{jobCode}
99 70 </if>
... ... @@ -144,6 +115,7 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
144 115 <if test="updateTime != null">update_time,</if>
145 116 <if test="alcoholIntake != null">alcohol_intake,</if>
146 117 <if test="remark != null">remark,</if>
  118 + <if test="exType != null">ex_type,</if>
147 119 </trim>
148 120 <trim prefix="values (" suffix=")" suffixOverrides=",">
149 121 <if test="createTime != null">#{createTime},</if>
... ... @@ -159,6 +131,7 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
159 131 <if test="updateTime != null">#{updateTime},</if>
160 132 <if test="alcoholIntake != null">#{alcoholIntake},</if>
161 133 <if test="remark != null">#{remark},</if>
  134 + <if test="exType != null">#{exType},</if>
162 135 </trim>
163 136 </insert>
164 137  
... ...