Commit 777fd955ddcf41f48e3a40fed5bbc7afcf2e316a

Authored by guzijian
1 parent e086a990

fix: save driver scheduling

ruoyi-admin/src/main/java/com/ruoyi/driver/controller/DriverController.java
@@ -3,6 +3,7 @@ package com.ruoyi.driver.controller; @@ -3,6 +3,7 @@ package com.ruoyi.driver.controller;
3 import java.util.List; 3 import java.util.List;
4 import javax.servlet.http.HttpServletResponse; 4 import javax.servlet.http.HttpServletResponse;
5 5
  6 +import com.ruoyi.pojo.response.ResponseScheduling;
6 import io.swagger.annotations.Api; 7 import io.swagger.annotations.Api;
7 import io.swagger.annotations.ApiOperation; 8 import io.swagger.annotations.ApiOperation;
8 import io.swagger.annotations.ApiParam; 9 import io.swagger.annotations.ApiParam;
@@ -27,26 +28,33 @@ import com.ruoyi.common.core.page.TableDataInfo; @@ -27,26 +28,33 @@ import com.ruoyi.common.core.page.TableDataInfo;
27 28
28 /** 29 /**
29 * 驾驶员信息Controller 30 * 驾驶员信息Controller
30 - * 31 + *
31 * @author 古自健 32 * @author 古自健
32 * @date 2023-07-04 33 * @date 2023-07-04
33 */ 34 */
34 @RestController 35 @RestController
35 @RequestMapping("/driver/driver") 36 @RequestMapping("/driver/driver")
36 @Api(tags = "驾驶员管理接口") 37 @Api(tags = "驾驶员管理接口")
37 -public class DriverController extends BaseController  
38 -{ 38 +public class DriverController extends BaseController {
39 @Autowired 39 @Autowired
40 private IDriverService driverService; 40 private IDriverService driverService;
41 41
42 /** 42 /**
  43 + * 获取驾驶员排班信息
  44 + */
  45 + @GetMapping("/{date}/{jobCode}")
  46 + @ApiOperation("获取驾驶员排班信息")
  47 + public AjaxResult getDriverSchedulingInfo(@PathVariable("date") String date, @PathVariable("jobCode") String jobCode) {
  48 + return driverService.getDriverSchedulingInfo(date,jobCode);
  49 + }
  50 +
  51 + /**
43 * 查询驾驶员信息列表 52 * 查询驾驶员信息列表
44 */ 53 */
45 // @PreAuthorize("@ss.hasPermi('driver:driver:list')") 54 // @PreAuthorize("@ss.hasPermi('driver:driver:list')")
46 @GetMapping("/list") 55 @GetMapping("/list")
47 - @ApiOperation(value = "查询驾驶员信息列表",notes = "查询驾驶员信息列表")  
48 - public TableDataInfo list(Driver driver)  
49 - { 56 + @ApiOperation(value = "查询驾驶员信息列表", notes = "查询驾驶员信息列表")
  57 + public TableDataInfo list(Driver driver) {
50 startPage(); 58 startPage();
51 List<Driver> list = driverService.selectDriverList(driver); 59 List<Driver> list = driverService.selectDriverList(driver);
52 return getDataTable(list); 60 return getDataTable(list);
@@ -59,8 +67,7 @@ public class DriverController extends BaseController @@ -59,8 +67,7 @@ public class DriverController extends BaseController
59 @Log(title = "驾驶员信息", businessType = BusinessType.EXPORT) 67 @Log(title = "驾驶员信息", businessType = BusinessType.EXPORT)
60 @PostMapping("/export") 68 @PostMapping("/export")
61 @ApiOperation("导出驾驶员信息列表") 69 @ApiOperation("导出驾驶员信息列表")
62 - public void export(HttpServletResponse response, Driver driver)  
63 - { 70 + public void export(HttpServletResponse response, Driver driver) {
64 List<Driver> list = driverService.selectDriverList(driver); 71 List<Driver> list = driverService.selectDriverList(driver);
65 ExcelUtil<Driver> util = new ExcelUtil<Driver>(Driver.class); 72 ExcelUtil<Driver> util = new ExcelUtil<Driver>(Driver.class);
66 util.exportExcel(response, list, "驾驶员信息数据"); 73 util.exportExcel(response, list, "驾驶员信息数据");
@@ -72,8 +79,7 @@ public class DriverController extends BaseController @@ -72,8 +79,7 @@ public class DriverController extends BaseController
72 // @PreAuthorize("@ss.hasPermi('driver:driver:query')") 79 // @PreAuthorize("@ss.hasPermi('driver:driver:query')")
73 @GetMapping(value = "/{id}") 80 @GetMapping(value = "/{id}")
74 @ApiOperation("获取驾驶员信息详细信息") 81 @ApiOperation("获取驾驶员信息详细信息")
75 - public AjaxResult getInfo(@ApiParam(value = "id",required = true) @PathVariable("id") Long id)  
76 - { 82 + public AjaxResult getInfo(@ApiParam(value = "id", required = true) @PathVariable("id") Long id) {
77 return success(driverService.selectDriverById(id)); 83 return success(driverService.selectDriverById(id));
78 } 84 }
79 85
@@ -84,8 +90,7 @@ public class DriverController extends BaseController @@ -84,8 +90,7 @@ public class DriverController extends BaseController
84 @Log(title = "驾驶员信息", businessType = BusinessType.INSERT) 90 @Log(title = "驾驶员信息", businessType = BusinessType.INSERT)
85 @PostMapping 91 @PostMapping
86 @ApiOperation("新增驾驶员信息") 92 @ApiOperation("新增驾驶员信息")
87 - public AjaxResult add(@ApiParam("driver") @RequestBody Driver driver)  
88 - { 93 + public AjaxResult add(@ApiParam("driver") @RequestBody Driver driver) {
89 return toAjax(driverService.insertDriver(driver)); 94 return toAjax(driverService.insertDriver(driver));
90 } 95 }
91 96
@@ -96,8 +101,7 @@ public class DriverController extends BaseController @@ -96,8 +101,7 @@ public class DriverController extends BaseController
96 @Log(title = "驾驶员信息", businessType = BusinessType.UPDATE) 101 @Log(title = "驾驶员信息", businessType = BusinessType.UPDATE)
97 @PutMapping 102 @PutMapping
98 @ApiOperation("修改驾驶员信息") 103 @ApiOperation("修改驾驶员信息")
99 - public AjaxResult edit(@ApiParam("driver") @RequestBody Driver driver)  
100 - { 104 + public AjaxResult edit(@ApiParam("driver") @RequestBody Driver driver) {
101 return toAjax(driverService.updateDriver(driver)); 105 return toAjax(driverService.updateDriver(driver));
102 } 106 }
103 107
@@ -106,10 +110,9 @@ public class DriverController extends BaseController @@ -106,10 +110,9 @@ public class DriverController extends BaseController
106 */ 110 */
107 // @PreAuthorize("@ss.hasPermi('driver:driver:remove')") 111 // @PreAuthorize("@ss.hasPermi('driver:driver:remove')")
108 @Log(title = "驾驶员信息", businessType = BusinessType.DELETE) 112 @Log(title = "驾驶员信息", businessType = BusinessType.DELETE)
109 - @DeleteMapping("/{ids}") 113 + @DeleteMapping("/{ids}")
110 @ApiOperation("删除驾驶员信息") 114 @ApiOperation("删除驾驶员信息")
111 - public AjaxResult remove(@ApiParam @PathVariable Long[] ids)  
112 - { 115 + public AjaxResult remove(@ApiParam @PathVariable Long[] ids) {
113 return toAjax(driverService.deleteDriverByIds(ids)); 116 return toAjax(driverService.deleteDriverByIds(ids));
114 } 117 }
115 } 118 }
ruoyi-admin/src/main/java/com/ruoyi/driver/mapper/DriverMapper.java
@@ -2,6 +2,7 @@ package com.ruoyi.driver.mapper; @@ -2,6 +2,7 @@ package com.ruoyi.driver.mapper;
2 2
3 import java.util.List; 3 import java.util.List;
4 import com.ruoyi.driver.domain.Driver; 4 import com.ruoyi.driver.domain.Driver;
  5 +import com.ruoyi.pojo.response.ResponseScheduling;
5 import org.apache.ibatis.annotations.Param; 6 import org.apache.ibatis.annotations.Param;
6 7
7 /** 8 /**
@@ -65,4 +66,6 @@ public interface DriverMapper @@ -65,4 +66,6 @@ public interface DriverMapper
65 * @param driverList 66 * @param driverList
66 */ 67 */
67 void saveDrivers(@Param("drivers") List<Driver> driverList); 68 void saveDrivers(@Param("drivers") List<Driver> driverList);
  69 +
  70 + void saveDriverScheduling(@Param("responseSchedulings") List<ResponseScheduling> responseSchedulings);
68 } 71 }
ruoyi-admin/src/main/java/com/ruoyi/driver/service/IDriverService.java
1 package com.ruoyi.driver.service; 1 package com.ruoyi.driver.service;
2 2
3 import java.util.List; 3 import java.util.List;
  4 +import java.util.Map;
  5 +
  6 +import com.ruoyi.common.core.domain.AjaxResult;
4 import com.ruoyi.driver.domain.Driver; 7 import com.ruoyi.driver.domain.Driver;
  8 +import com.ruoyi.pojo.response.ResponseScheduling;
5 9
6 /** 10 /**
7 * 驾驶员信息Service接口 11 * 驾驶员信息Service接口
@@ -64,4 +68,8 @@ public interface IDriverService @@ -64,4 +68,8 @@ public interface IDriverService
64 * @param driverList 68 * @param driverList
65 */ 69 */
66 void insertDrivers(List<Driver> driverList); 70 void insertDrivers(List<Driver> driverList);
  71 +
  72 + AjaxResult getDriverSchedulingInfo(String date,String jobCode);
  73 +
  74 + void saveDriverScheduling(Map<String, List<ResponseScheduling>> driverSchedulingMap);
67 } 75 }
ruoyi-admin/src/main/java/com/ruoyi/driver/service/impl/DriverServiceImpl.java
1 package com.ruoyi.driver.service.impl; 1 package com.ruoyi.driver.service.impl;
2 2
  3 +import java.util.ArrayList;
  4 +import java.util.Collection;
3 import java.util.List; 5 import java.util.List;
  6 +import java.util.Map;
  7 +
  8 +import com.ruoyi.common.core.domain.AjaxResult;
  9 +import com.ruoyi.common.core.redis.RedisCache;
4 import com.ruoyi.common.utils.SecurityUtils; 10 import com.ruoyi.common.utils.SecurityUtils;
  11 +import com.ruoyi.pojo.response.ResponseScheduling;
5 import org.springframework.beans.factory.annotation.Autowired; 12 import org.springframework.beans.factory.annotation.Autowired;
6 import org.springframework.stereotype.Service; 13 import org.springframework.stereotype.Service;
7 import com.ruoyi.driver.mapper.DriverMapper; 14 import com.ruoyi.driver.mapper.DriverMapper;
8 import com.ruoyi.driver.domain.Driver; 15 import com.ruoyi.driver.domain.Driver;
9 import com.ruoyi.driver.service.IDriverService; 16 import com.ruoyi.driver.service.IDriverService;
10 17
  18 +import static com.ruoyi.redispre.GlobalRedisPreName.DRIVER_SCHEDULING_PRE;
  19 +
11 /** 20 /**
12 * 驾驶员信息Service业务层处理 21 * 驾驶员信息Service业务层处理
13 - * 22 + *
14 * @author 古自健 23 * @author 古自健
15 * @date 2023-07-04 24 * @date 2023-07-04
16 */ 25 */
17 @Service 26 @Service
18 -public class DriverServiceImpl implements IDriverService  
19 -{ 27 +public class DriverServiceImpl implements IDriverService {
20 @Autowired 28 @Autowired
21 private DriverMapper driverMapper; 29 private DriverMapper driverMapper;
22 30
  31 + @Autowired
  32 + private RedisCache redisCache;
  33 +
23 /** 34 /**
24 * 查询驾驶员信息 35 * 查询驾驶员信息
25 - * 36 + *
26 * @param id 驾驶员信息主键 37 * @param id 驾驶员信息主键
27 * @return 驾驶员信息 38 * @return 驾驶员信息
28 */ 39 */
29 @Override 40 @Override
30 - public Driver selectDriverById(Long id)  
31 - { 41 + public Driver selectDriverById(Long id) {
32 return driverMapper.selectDriverById(id); 42 return driverMapper.selectDriverById(id);
33 } 43 }
34 44
35 /** 45 /**
36 * 查询驾驶员信息列表 46 * 查询驾驶员信息列表
37 - * 47 + *
38 * @param driver 驾驶员信息 48 * @param driver 驾驶员信息
39 * @return 驾驶员信息 49 * @return 驾驶员信息
40 */ 50 */
41 @Override 51 @Override
42 - public List<Driver> selectDriverList(Driver driver)  
43 - { 52 + public List<Driver> selectDriverList(Driver driver) {
44 return driverMapper.selectDriverList(driver); 53 return driverMapper.selectDriverList(driver);
45 } 54 }
46 55
47 /** 56 /**
48 * 新增驾驶员信息 57 * 新增驾驶员信息
49 - * 58 + *
50 * @param driver 驾驶员信息 59 * @param driver 驾驶员信息
51 * @return 结果 60 * @return 结果
52 */ 61 */
53 @Override 62 @Override
54 - public int insertDriver(Driver driver)  
55 - { 63 + public int insertDriver(Driver driver) {
56 return driverMapper.insertDriver(driver); 64 return driverMapper.insertDriver(driver);
57 } 65 }
58 66
59 /** 67 /**
60 * 修改驾驶员信息 68 * 修改驾驶员信息
61 - * 69 + *
62 * @param driver 驾驶员信息 70 * @param driver 驾驶员信息
63 * @return 结果 71 * @return 结果
64 */ 72 */
65 @Override 73 @Override
66 - public int updateDriver(Driver driver)  
67 - { 74 + public int updateDriver(Driver driver) {
68 return driverMapper.updateDriver(driver); 75 return driverMapper.updateDriver(driver);
69 } 76 }
70 77
71 /** 78 /**
72 * 批量删除驾驶员信息 79 * 批量删除驾驶员信息
73 - * 80 + *
74 * @param ids 需要删除的驾驶员信息主键 81 * @param ids 需要删除的驾驶员信息主键
75 * @return 结果 82 * @return 结果
76 */ 83 */
77 @Override 84 @Override
78 - public int deleteDriverByIds(Long[] ids)  
79 - { 85 + public int deleteDriverByIds(Long[] ids) {
80 return driverMapper.deleteDriverByIds(ids); 86 return driverMapper.deleteDriverByIds(ids);
81 } 87 }
82 88
83 /** 89 /**
84 * 删除驾驶员信息信息 90 * 删除驾驶员信息信息
85 - * 91 + *
86 * @param id 驾驶员信息主键 92 * @param id 驾驶员信息主键
87 * @return 结果 93 * @return 结果
88 */ 94 */
89 @Override 95 @Override
90 - public int deleteDriverById(Long id)  
91 - { 96 + public int deleteDriverById(Long id) {
92 return driverMapper.deleteDriverById(id); 97 return driverMapper.deleteDriverById(id);
93 } 98 }
94 99
@@ -96,4 +101,20 @@ public class DriverServiceImpl implements IDriverService @@ -96,4 +101,20 @@ public class DriverServiceImpl implements IDriverService
96 public void insertDrivers(List<Driver> driverList) { 101 public void insertDrivers(List<Driver> driverList) {
97 driverMapper.saveDrivers(driverList); 102 driverMapper.saveDrivers(driverList);
98 } 103 }
  104 +
  105 + @Override
  106 + public AjaxResult getDriverSchedulingInfo(String date, String jobCode) {
  107 + List<ResponseScheduling> cacheMapValue = redisCache.getCacheMapValue(DRIVER_SCHEDULING_PRE + date, jobCode);
  108 + Boolean aBoolean = redisCache.redisTemplate.opsForHash().hasKey(DRIVER_SCHEDULING_PRE + date, jobCode);
  109 + return AjaxResult.success(redisCache.getCacheMapValue(DRIVER_SCHEDULING_PRE + date, jobCode));
  110 + }
  111 +
  112 + @Override
  113 + public void saveDriverScheduling(Map<String, List<ResponseScheduling>> driverSchedulingMap) {
  114 + Collection<List<ResponseScheduling>> listCollection = driverSchedulingMap.values();
  115 + for (List<ResponseScheduling> responseSchedulings : listCollection) {
  116 + driverMapper.saveDriverScheduling(responseSchedulings);
  117 + }
  118 +
  119 + }
99 } 120 }
ruoyi-admin/src/main/java/com/ruoyi/eexception/controller/EquipmentExceptionController.java
@@ -2,6 +2,9 @@ package com.ruoyi.eexception.controller; @@ -2,6 +2,9 @@ package com.ruoyi.eexception.controller;
2 2
3 import java.util.List; 3 import java.util.List;
4 import javax.servlet.http.HttpServletResponse; 4 import javax.servlet.http.HttpServletResponse;
  5 +
  6 +import io.swagger.annotations.Api;
  7 +import io.swagger.annotations.ApiOperation;
5 import org.springframework.security.access.prepost.PreAuthorize; 8 import org.springframework.security.access.prepost.PreAuthorize;
6 import org.springframework.beans.factory.annotation.Autowired; 9 import org.springframework.beans.factory.annotation.Autowired;
7 import org.springframework.web.bind.annotation.GetMapping; 10 import org.springframework.web.bind.annotation.GetMapping;
@@ -29,6 +32,7 @@ import com.ruoyi.common.core.page.TableDataInfo; @@ -29,6 +32,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
29 */ 32 */
30 @RestController 33 @RestController
31 @RequestMapping("/eexception/eexception") 34 @RequestMapping("/eexception/eexception")
  35 +@Api(tags = "设备异常接口")
32 public class EquipmentExceptionController extends BaseController 36 public class EquipmentExceptionController extends BaseController
33 { 37 {
34 @Autowired 38 @Autowired
@@ -39,6 +43,7 @@ public class EquipmentExceptionController extends BaseController @@ -39,6 +43,7 @@ public class EquipmentExceptionController extends BaseController
39 */ 43 */
40 @PreAuthorize("@ss.hasPermi('eexception:eexception:list')") 44 @PreAuthorize("@ss.hasPermi('eexception:eexception:list')")
41 @GetMapping("/list") 45 @GetMapping("/list")
  46 + @ApiOperation("查询设备异常记录列表")
42 public TableDataInfo list(EquipmentException equipmentException) 47 public TableDataInfo list(EquipmentException equipmentException)
43 { 48 {
44 startPage(); 49 startPage();
@@ -52,6 +57,7 @@ public class EquipmentExceptionController extends BaseController @@ -52,6 +57,7 @@ public class EquipmentExceptionController extends BaseController
52 @PreAuthorize("@ss.hasPermi('eexception:eexception:export')") 57 @PreAuthorize("@ss.hasPermi('eexception:eexception:export')")
53 @Log(title = "设备异常记录", businessType = BusinessType.EXPORT) 58 @Log(title = "设备异常记录", businessType = BusinessType.EXPORT)
54 @PostMapping("/export") 59 @PostMapping("/export")
  60 + @ApiOperation("导出设备异常记录列表")
55 public void export(HttpServletResponse response, EquipmentException equipmentException) 61 public void export(HttpServletResponse response, EquipmentException equipmentException)
56 { 62 {
57 List<EquipmentException> list = equipmentExceptionService.selectEquipmentExceptionList(equipmentException); 63 List<EquipmentException> list = equipmentExceptionService.selectEquipmentExceptionList(equipmentException);
@@ -64,6 +70,7 @@ public class EquipmentExceptionController extends BaseController @@ -64,6 +70,7 @@ public class EquipmentExceptionController extends BaseController
64 */ 70 */
65 @PreAuthorize("@ss.hasPermi('eexception:eexception:query')") 71 @PreAuthorize("@ss.hasPermi('eexception:eexception:query')")
66 @GetMapping(value = "/{id}") 72 @GetMapping(value = "/{id}")
  73 + @ApiOperation("获取设备异常记录详细信息")
67 public AjaxResult getInfo(@PathVariable("id") Long id) 74 public AjaxResult getInfo(@PathVariable("id") Long id)
68 { 75 {
69 return success(equipmentExceptionService.selectEquipmentExceptionById(id)); 76 return success(equipmentExceptionService.selectEquipmentExceptionById(id));
@@ -75,6 +82,7 @@ public class EquipmentExceptionController extends BaseController @@ -75,6 +82,7 @@ public class EquipmentExceptionController extends BaseController
75 @PreAuthorize("@ss.hasPermi('eexception:eexception:add')") 82 @PreAuthorize("@ss.hasPermi('eexception:eexception:add')")
76 @Log(title = "设备异常记录", businessType = BusinessType.INSERT) 83 @Log(title = "设备异常记录", businessType = BusinessType.INSERT)
77 @PostMapping 84 @PostMapping
  85 + @ApiOperation("新增设备异常记录")
78 public AjaxResult add(@RequestBody EquipmentException equipmentException) 86 public AjaxResult add(@RequestBody EquipmentException equipmentException)
79 { 87 {
80 return toAjax(equipmentExceptionService.insertEquipmentException(equipmentException)); 88 return toAjax(equipmentExceptionService.insertEquipmentException(equipmentException));
@@ -86,6 +94,7 @@ public class EquipmentExceptionController extends BaseController @@ -86,6 +94,7 @@ public class EquipmentExceptionController extends BaseController
86 @PreAuthorize("@ss.hasPermi('eexception:eexception:edit')") 94 @PreAuthorize("@ss.hasPermi('eexception:eexception:edit')")
87 @Log(title = "设备异常记录", businessType = BusinessType.UPDATE) 95 @Log(title = "设备异常记录", businessType = BusinessType.UPDATE)
88 @PutMapping 96 @PutMapping
  97 + @ApiOperation("修改设备异常记录")
89 public AjaxResult edit(@RequestBody EquipmentException equipmentException) 98 public AjaxResult edit(@RequestBody EquipmentException equipmentException)
90 { 99 {
91 return toAjax(equipmentExceptionService.updateEquipmentException(equipmentException)); 100 return toAjax(equipmentExceptionService.updateEquipmentException(equipmentException));
@@ -97,6 +106,7 @@ public class EquipmentExceptionController extends BaseController @@ -97,6 +106,7 @@ public class EquipmentExceptionController extends BaseController
97 @PreAuthorize("@ss.hasPermi('eexception:eexception:remove')") 106 @PreAuthorize("@ss.hasPermi('eexception:eexception:remove')")
98 @Log(title = "设备异常记录", businessType = BusinessType.DELETE) 107 @Log(title = "设备异常记录", businessType = BusinessType.DELETE)
99 @DeleteMapping("/{ids}") 108 @DeleteMapping("/{ids}")
  109 + @ApiOperation("删除设备异常记录")
100 public AjaxResult remove(@PathVariable Long[] ids) 110 public AjaxResult remove(@PathVariable Long[] ids)
101 { 111 {
102 return toAjax(equipmentExceptionService.deleteEquipmentExceptionByIds(ids)); 112 return toAjax(equipmentExceptionService.deleteEquipmentExceptionByIds(ids));
ruoyi-admin/src/main/java/com/ruoyi/job/DriverJob.java
1 package com.ruoyi.job; 1 package com.ruoyi.job;
2 2
  3 +import com.ruoyi.common.core.redis.RedisCache;
3 import com.ruoyi.common.utils.DateUtils; 4 import com.ruoyi.common.utils.DateUtils;
4 import com.ruoyi.driver.domain.Driver; 5 import com.ruoyi.driver.domain.Driver;
5 import com.ruoyi.driver.service.IDriverService; 6 import com.ruoyi.driver.service.IDriverService;
  7 +import com.ruoyi.pojo.response.ResponseScheduling;
6 import com.ruoyi.utils.ListUtils; 8 import com.ruoyi.utils.ListUtils;
  9 +import org.apache.commons.math3.distribution.RealDistribution;
7 import org.springframework.beans.factory.InitializingBean; 10 import org.springframework.beans.factory.InitializingBean;
8 import org.springframework.beans.factory.annotation.Autowired; 11 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.beans.factory.annotation.Value; 12 import org.springframework.beans.factory.annotation.Value;
@@ -14,10 +17,10 @@ import org.springframework.web.client.RestTemplate; @@ -14,10 +17,10 @@ import org.springframework.web.client.RestTemplate;
14 17
15 import javax.annotation.Resource; 18 import javax.annotation.Resource;
16 import java.security.MessageDigest; 19 import java.security.MessageDigest;
17 -import java.util.Arrays;  
18 -import java.util.HashMap;  
19 -import java.util.List;  
20 -import java.util.Map; 20 +import java.util.*;
  21 +import java.util.concurrent.TimeUnit;
  22 +
  23 +import static com.ruoyi.redispre.GlobalRedisPreName.DRIVER_SCHEDULING_PRE;
21 24
22 /** 25 /**
23 * 该定时任务用户获取驾驶员信息 26 * 该定时任务用户获取驾驶员信息
@@ -27,6 +30,9 @@ import java.util.Map; @@ -27,6 +30,9 @@ import java.util.Map;
27 @Component("driverJob") 30 @Component("driverJob")
28 public class DriverJob implements InitializingBean { 31 public class DriverJob implements InitializingBean {
29 32
  33 + @Autowired
  34 + private RedisCache redisCache;
  35 +
30 @Resource 36 @Resource
31 private RestTemplate restTemplate; 37 private RestTemplate restTemplate;
32 38
@@ -36,7 +42,7 @@ public class DriverJob implements InitializingBean { @@ -36,7 +42,7 @@ public class DriverJob implements InitializingBean {
36 @Value("${api.url.getDriverInfo}") 42 @Value("${api.url.getDriverInfo}")
37 private String getDriverInfoUrl; 43 private String getDriverInfoUrl;
38 44
39 - @Value("api.url.getSchedulingInfo") 45 + @Value("${api.url.getSchedulingInfo}")
40 private String getSchedulingInfoUrl; 46 private String getSchedulingInfoUrl;
41 47
42 @Value("${api.config.password}") 48 @Value("${api.config.password}")
@@ -46,6 +52,7 @@ public class DriverJob implements InitializingBean { @@ -46,6 +52,7 @@ public class DriverJob implements InitializingBean {
46 private String nonce; 52 private String nonce;
47 53
48 private static IDriverService DRIVER_SERVICE; 54 private static IDriverService DRIVER_SERVICE;
  55 + private static RedisCache REDIS_CACHE;
49 private static RestTemplate RESTTEMPLATE; 56 private static RestTemplate RESTTEMPLATE;
50 57
51 58
@@ -62,14 +69,12 @@ public class DriverJob implements InitializingBean { @@ -62,14 +69,12 @@ public class DriverJob implements InitializingBean {
62 try { 69 try {
63 String getDriverInfoUrl = String.format(GET_DRIVER_INFO_URL, params); 70 String getDriverInfoUrl = String.format(GET_DRIVER_INFO_URL, params);
64 long timestamp = System.currentTimeMillis(); 71 long timestamp = System.currentTimeMillis();
65 -  
66 // 获取驾驶员信息 72 // 获取驾驶员信息
67 List<Driver> drivers = getDrivers(getDriverInfoUrl, String.valueOf(timestamp)); 73 List<Driver> drivers = getDrivers(getDriverInfoUrl, String.valueOf(timestamp));
68 -  
69 - // http://114.80.178.12:9089/webservice/rest/schedule_real/sch_jk/%s/%s?timestamp=%d&nonce=%s&password=%s&sign=%s  
70 -// String getSchedulingInfoUrl = String.format(GET_SCHEDULING_INFO_URL, "99", DateUtils.getDate("yyyyMMdd"), String.valueOf(timestamp), NONCE, PASSWORD, getSHA1(getStringStringMap(String.valueOf(timestamp)))); 74 + // 格式化请求
  75 + String getSchedulingInfoUrl = String.format(GET_SCHEDULING_INFO_URL, "99", DateUtils.getDate("yyyyMMdd"), timestamp, NONCE, PASSWORD, getSHA1(getStringStringMap(String.valueOf(timestamp))));
71 // 获取排班信息并存入redis 76 // 获取排班信息并存入redis
72 -// saveSchedulingToRedis(getSchedulingInfoUrl,drivers); 77 + saveSchedulingToRedis(getSchedulingInfoUrl, drivers);
73 // 分片插入 78 // 分片插入
74 List<List<Driver>> splitList = ListUtils.splitList(drivers, 1000); 79 List<List<Driver>> splitList = ListUtils.splitList(drivers, 1000);
75 System.out.println("开始更新数据-----"); 80 System.out.println("开始更新数据-----");
@@ -83,15 +88,33 @@ public class DriverJob implements InitializingBean { @@ -83,15 +88,33 @@ public class DriverJob implements InitializingBean {
83 System.out.println("执行结束"); 88 System.out.println("执行结束");
84 } 89 }
85 90
86 - private void saveSchedulingToRedis(String getSchedulingInfoUrl, List<Driver> drivers) {  
87 -// ESTTEMPLATE.exchange(  
88 -// url,  
89 -// HttpMethod.GET,  
90 -// null,  
91 -// new ParameterizedTypeReference<List<Driver>>() {  
92 -// }).getBody();  
93 -// Object forObject = restTemplate.getForObject(getSchedulingInfoUrl, Object.class); 91 + private static void saveSchedulingToRedis(String getSchedulingInfoUrl, List<Driver> drivers) {
  92 + List<ResponseScheduling> originSchedulingList = RESTTEMPLATE.exchange(
  93 + getSchedulingInfoUrl,
  94 + HttpMethod.GET,
  95 + null,
  96 + new ParameterizedTypeReference<List<ResponseScheduling>>() {
  97 + }).getBody();
94 98
  99 + Map<String, List<ResponseScheduling>> driverSchedulingMap = new HashMap<>();
  100 + // 按照员工工号来获取排班信息
  101 + originSchedulingList.stream().forEach(item -> {
  102 + // 员工号为key
  103 + String jobCode = item.getJsy().split("/")[0];
  104 + item.setJobCode(jobCode);
  105 + if (Objects.isNull(driverSchedulingMap.get(jobCode))) {
  106 + List<ResponseScheduling> oneDriverSchedulings = new ArrayList<>();
  107 + oneDriverSchedulings.add(item);
  108 + driverSchedulingMap.put(jobCode, oneDriverSchedulings);
  109 + } else {
  110 + driverSchedulingMap.get(jobCode).add(item);
  111 + }
  112 + });
  113 + originSchedulingList.clear();
  114 + // 存入数据库
  115 + DRIVER_SERVICE.saveDriverScheduling(driverSchedulingMap);
  116 + // 存入redis
  117 + REDIS_CACHE.setCacheMap(DRIVER_SCHEDULING_PRE + DateUtils.getDate("yyyyMMdd"), driverSchedulingMap, 1, TimeUnit.DAYS);
95 } 118 }
96 119
97 private static List<Driver> getDrivers(String format, String timestamp) throws Exception { 120 private static List<Driver> getDrivers(String format, String timestamp) throws Exception {
@@ -160,25 +183,25 @@ public class DriverJob implements InitializingBean { @@ -160,25 +183,25 @@ public class DriverJob implements InitializingBean {
160 183
161 } 184 }
162 185
163 - public static void main(String[] args) throws Exception {  
164 - RestTemplate restTemplate1 = new RestTemplate();  
165 -// String url = "http://101.95.136.206:9089/webservice/rest/person/company/%s";  
166 - String url = "http://101.95.136.206:9089/webservice/rest/schedule_real/sch_jk/%s/%s?timestamp=%d&nonce=%s&password=%s&sign=%s";  
167 -  
168 - long timestamp = System.currentTimeMillis();  
169 - Map<String, String> configMap = new HashMap<>(5);  
170 - configMap.put("timestamp", String.valueOf(timestamp));  
171 - configMap.put("nonce", "NONCE");  
172 - configMap.put("password", "c4dd3d8cb9a82f6d6a625818618b28ca7bebb464");  
173 - String format = String.format(url, "99", DateUtils.getDate("yyyyMMdd"), timestamp, "NONCE", "c4dd3d8cb9a82f6d6a625818618b28ca7bebb464", getSHA1(configMap));  
174 -// String sign = getSHA1(configMap);  
175 -// String httpUrl = format  
176 -// + "?timestamp=" + timestamp  
177 -// + "&nonce=" + "NONCE"  
178 -// + "&password=" + "c4dd3d8cb9a82f6d6a625818618b28ca7bebb464"  
179 -// + "&sign=" + sign;  
180 - Object forObject = restTemplate1.getForObject(format, Object.class);  
181 - } 186 +// public static void main(String[] args) throws Exception {
  187 +// RestTemplate restTemplate1 = new RestTemplate();
  188 +//// String url = "http://101.95.136.206:9089/webservice/rest/person/company/%s";
  189 +// String url = "http://101.95.136.206:9089/webservice/rest/schedule_real/sch_jk/%s/%s?timestamp=%d&nonce=%s&password=%s&sign=%s";
  190 +//
  191 +// long timestamp = System.currentTimeMillis();
  192 +// Map<String, String> configMap = new HashMap<>(5);
  193 +// configMap.put("timestamp", String.valueOf(timestamp));
  194 +// configMap.put("nonce", "NONCE");
  195 +// configMap.put("password", "c4dd3d8cb9a82f6d6a625818618b28ca7bebb464");
  196 +// String format = String.format(url, "99", DateUtils.getDate("yyyyMMdd"), timestamp, "NONCE", "c4dd3d8cb9a82f6d6a625818618b28ca7bebb464", getSHA1(configMap));
  197 +//// String sign = getSHA1(configMap);
  198 +//// String httpUrl = format
  199 +//// + "?timestamp=" + timestamp
  200 +//// + "&nonce=" + "NONCE"
  201 +//// + "&password=" + "c4dd3d8cb9a82f6d6a625818618b28ca7bebb464"
  202 +//// + "&sign=" + sign;
  203 +// Object forObject = restTemplate1.getForObject(format, Object.class);
  204 +// }
182 205
183 @Override 206 @Override
184 public void afterPropertiesSet() throws Exception { 207 public void afterPropertiesSet() throws Exception {
@@ -187,6 +210,8 @@ public class DriverJob implements InitializingBean { @@ -187,6 +210,8 @@ public class DriverJob implements InitializingBean {
187 PASSWORD = password; 210 PASSWORD = password;
188 RESTTEMPLATE = restTemplate; 211 RESTTEMPLATE = restTemplate;
189 DRIVER_SERVICE = driverService; 212 DRIVER_SERVICE = driverService;
  213 + REDIS_CACHE = redisCache;
190 GET_SCHEDULING_INFO_URL = getSchedulingInfoUrl; 214 GET_SCHEDULING_INFO_URL = getSchedulingInfoUrl;
  215 +
191 } 216 }
192 } 217 }
ruoyi-admin/src/main/java/com/ruoyi/pojo/response/ResponseScheduling.java
@@ -14,10 +14,11 @@ import java.util.List; @@ -14,10 +14,11 @@ import java.util.List;
14 @Data 14 @Data
15 public class ResponseScheduling { 15 public class ResponseScheduling {
16 16
17 - private long id; 17 + private Long id;
18 private Date scheduleDate; 18 private Date scheduleDate;
19 private String lineName; 19 private String lineName;
20 private String lineCode; 20 private String lineCode;
  21 + private String jobCode;
21 private String lpName; 22 private String lpName;
22 private String nbbm; 23 private String nbbm;
23 private String jsy; 24 private String jsy;
@@ -27,18 +28,18 @@ public class ResponseScheduling { @@ -27,18 +28,18 @@ public class ResponseScheduling {
27 private String qdzName; 28 private String qdzName;
28 private String zdzCode; 29 private String zdzCode;
29 private String zdzName; 30 private String zdzName;
30 - private long fcsjT;  
31 - private long dfsjT;  
32 - private long zdsjT;  
33 - private long fcsjActualTime;  
34 - private long zdsjActualTime;  
35 - private double jhlc;  
36 - private double jhlcOrig;  
37 - private int bcsj; 31 + private Long fcsjT;
  32 + private Long dfsjT;
  33 + private Long zdsjT;
  34 + private Long fcsjActualTime;
  35 + private Long zdsjActualTime;
  36 + private Double jhlc;
  37 + private Double jhlcOrig;
  38 + private Integer bcsj;
38 private String bcType; 39 private String bcType;
39 - private int status; 40 + private Integer status;
40 private String adjustExps; 41 private String adjustExps;
41 - private boolean sflj; 42 + private Boolean sflj;
42 private String remarks; 43 private String remarks;
43 - private List<CTasks> cTasks; 44 +// private List<CTasks> cTasks;
44 } 45 }
45 \ No newline at end of file 46 \ No newline at end of file
ruoyi-admin/src/main/java/com/ruoyi/redispre/GlobalRedisPreName.java 0 → 100644
  1 +package com.ruoyi.redispre;
  2 +
  3 +/**
  4 + * @author 20412
  5 + */
  6 +public interface GlobalRedisPreName {
  7 + String DRIVER_SCHEDULING_PRE = "driver:scheduling:";
  8 +}
ruoyi-admin/src/main/resources/application-druid-uat.yml
@@ -75,7 +75,8 @@ spring: @@ -75,7 +75,8 @@ spring:
75 # redis 配置 75 # redis 配置
76 redis: 76 redis:
77 # 地址 77 # 地址
78 - host: 1.14.107.94 78 +# host: 1.14.107.94
  79 + host: 121.41.83.61
79 database: 0 80 database: 0
80 password: "guzijian" 81 password: "guzijian"
81 port: 6379 82 port: 6379
@@ -150,6 +151,7 @@ api: @@ -150,6 +151,7 @@ api:
150 # 获取排班信息 151 # 获取排班信息
151 getSchedulingInfo: http://101.95.136.206:9089/webservice/rest/schedule_real/sch_jk/%s/%s?timestamp=%d&nonce=%s&password=%s&sign=%s 152 getSchedulingInfo: http://101.95.136.206:9089/webservice/rest/schedule_real/sch_jk/%s/%s?timestamp=%d&nonce=%s&password=%s&sign=%s
152 config: 153 config:
  154 + # 固定密码
153 password: c4dd3d8cb9a82f6d6a625818618b28ca7bebb464 155 password: c4dd3d8cb9a82f6d6a625818618b28ca7bebb464
154 # 随机字符串 156 # 随机字符串
155 nonce: adfsad 157 nonce: adfsad
156 \ No newline at end of file 158 \ No newline at end of file
ruoyi-admin/src/main/resources/application.yml
@@ -146,5 +146,4 @@ api: @@ -146,5 +146,4 @@ api:
146 config: 146 config:
147 password: c4dd3d8cb9a82f6d6a625818618b28ca7bebb464 147 password: c4dd3d8cb9a82f6d6a625818618b28ca7bebb464
148 # 随机字符串 148 # 随机字符串
149 - nonce: adfsad  
150 - 149 + nonce: adfsad
151 \ No newline at end of file 150 \ No newline at end of file
ruoyi-admin/src/main/resources/mapper/driver/DriverMapper.xml
1 <?xml version="1.0" encoding="UTF-8" ?> 1 <?xml version="1.0" encoding="UTF-8" ?>
2 <!DOCTYPE mapper 2 <!DOCTYPE mapper
3 -PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"  
4 -"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> 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.DriverMapper"> 5 <mapper namespace="com.ruoyi.driver.mapper.DriverMapper">
6 - 6 +
7 <resultMap type="Driver" id="DriverResult"> 7 <resultMap type="Driver" id="DriverResult">
8 - <result property="id" column="id" />  
9 - <result property="jobCode" column="job_code" />  
10 - <result property="companyCode" column="company_code" />  
11 - <result property="brancheCompanyCode" column="branche_company_code" />  
12 - <result property="personnelName" column="personnel_name" />  
13 - <result property="papersCode" column="papers_code" />  
14 - <result property="icCardCode" column="ic_card_code" />  
15 - <result property="personnelType" column="personnel_type" />  
16 - <result property="posts" column="posts" />  
17 - <result property="card" column="card" />  
18 - <result property="telphone" column="telphone" />  
19 - <result property="icRfid" column="ic_rfid" />  
20 - <result property="idRfid" column="id_rfid" />  
21 - <result property="tagRfid" column="tag_rfid" />  
22 - <result property="remark" column="remark" />  
23 - <result property="lineName" column="line_name" />  
24 - <result property="lineCode" column="line_code" /> 8 + <result property="id" column="id"/>
  9 + <result property="jobCode" column="job_code"/>
  10 + <result property="companyCode" column="company_code"/>
  11 + <result property="brancheCompanyCode" column="branche_company_code"/>
  12 + <result property="personnelName" column="personnel_name"/>
  13 + <result property="papersCode" column="papers_code"/>
  14 + <result property="icCardCode" column="ic_card_code"/>
  15 + <result property="personnelType" column="personnel_type"/>
  16 + <result property="posts" column="posts"/>
  17 + <result property="card" column="card"/>
  18 + <result property="telphone" column="telphone"/>
  19 + <result property="icRfid" column="ic_rfid"/>
  20 + <result property="idRfid" column="id_rfid"/>
  21 + <result property="tagRfid" column="tag_rfid"/>
  22 + <result property="remark" column="remark"/>
  23 + <result property="lineName" column="line_name"/>
  24 + <result property="lineCode" column="line_code"/>
25 </resultMap> 25 </resultMap>
26 26
27 <sql id="selectDriverVo"> 27 <sql id="selectDriverVo">
28 - select id, job_code, company_code, branche_company_code, personnel_name, papers_code, ic_card_code, personnel_type, posts, card, telphone, ic_rfid, id_rfid, tag_rfid, remark, line_name, line_code from driver 28 + select id,
  29 + job_code,
  30 + company_code,
  31 + branche_company_code,
  32 + personnel_name,
  33 + papers_code,
  34 + ic_card_code,
  35 + personnel_type,
  36 + posts,
  37 + card,
  38 + telphone,
  39 + ic_rfid,
  40 + id_rfid,
  41 + tag_rfid,
  42 + remark,
  43 + line_name,
  44 + line_code
  45 + from driver
29 </sql> 46 </sql>
30 <sql id="insertDriverVo"> 47 <sql id="insertDriverVo">
31 - job_code, company_code, branche_company_code, personnel_name, papers_code, ic_card_code, personnel_type, posts, card, telphone, ic_rfid, id_rfid, tag_rfid, remark, line_name, line_code 48 + job_code
  49 + , company_code, branche_company_code, personnel_name, papers_code, ic_card_code, personnel_type, posts, card, telphone, ic_rfid, id_rfid, tag_rfid, remark, line_name, line_code
32 </sql> 50 </sql>
33 51
34 <select id="selectDriverList" parameterType="Driver" resultMap="DriverResult"> 52 <select id="selectDriverList" parameterType="Driver" resultMap="DriverResult">
35 <include refid="selectDriverVo"/> 53 <include refid="selectDriverVo"/>
36 - <where>  
37 - <if test="jobCode != null and jobCode != ''"> and job_code = #{jobCode}</if>  
38 - <if test="companyCode != null and companyCode != ''"> and company_code = #{companyCode}</if>  
39 - <if test="brancheCompanyCode != null and brancheCompanyCode != ''"> and branche_company_code = #{brancheCompanyCode}</if>  
40 - <if test="personnelName != null and personnelName != ''"> and personnel_name like concat('%', #{personnelName}, '%')</if>  
41 - <if test="papersCode != null and papersCode != ''"> and papers_code = #{papersCode}</if>  
42 - <if test="icCardCode != null and icCardCode != ''"> and ic_card_code = #{icCardCode}</if>  
43 - <if test="personnelType != null and personnelType != ''"> and personnel_type = #{personnelType}</if>  
44 - <if test="posts != null and posts != ''"> and posts = #{posts}</if>  
45 - <if test="card != null and card != ''"> and card = #{card}</if>  
46 - <if test="telphone != null and telphone != ''"> and telphone = #{telphone}</if>  
47 - <if test="icRfid != null and icRfid != ''"> and ic_rfid = #{icRfid}</if>  
48 - <if test="idRfid != null and idRfid != ''"> and id_rfid = #{idRfid}</if>  
49 - <if test="tagRfid != null and tagRfid != ''"> and tag_rfid = #{tagRfid}</if>  
50 - <if test="lineName != null and lineName != ''"> and line_name like concat('%', #{lineName}, '%')</if>  
51 - <if test="lineCode != null and lineCode != ''"> and line_code = #{lineCode}</if> 54 + <where>
  55 + <if test="jobCode != null and jobCode != ''">and job_code = #{jobCode}</if>
  56 + <if test="companyCode != null and companyCode != ''">and company_code = #{companyCode}</if>
  57 + <if test="brancheCompanyCode != null and brancheCompanyCode != ''">and branche_company_code =
  58 + #{brancheCompanyCode}
  59 + </if>
  60 + <if test="personnelName != null and personnelName != ''">and personnel_name like concat('%',
  61 + #{personnelName}, '%')
  62 + </if>
  63 + <if test="papersCode != null and papersCode != ''">and papers_code = #{papersCode}</if>
  64 + <if test="icCardCode != null and icCardCode != ''">and ic_card_code = #{icCardCode}</if>
  65 + <if test="personnelType != null and personnelType != ''">and personnel_type = #{personnelType}</if>
  66 + <if test="posts != null and posts != ''">and posts = #{posts}</if>
  67 + <if test="card != null and card != ''">and card = #{card}</if>
  68 + <if test="telphone != null and telphone != ''">and telphone = #{telphone}</if>
  69 + <if test="icRfid != null and icRfid != ''">and ic_rfid = #{icRfid}</if>
  70 + <if test="idRfid != null and idRfid != ''">and id_rfid = #{idRfid}</if>
  71 + <if test="tagRfid != null and tagRfid != ''">and tag_rfid = #{tagRfid}</if>
  72 + <if test="lineName != null and lineName != ''">and line_name like concat('%', #{lineName}, '%')</if>
  73 + <if test="lineCode != null and lineCode != ''">and line_code = #{lineCode}</if>
52 </where> 74 </where>
53 </select> 75 </select>
54 - 76 +
55 <select id="selectDriverById" parameterType="Long" resultMap="DriverResult"> 77 <select id="selectDriverById" parameterType="Long" resultMap="DriverResult">
56 <include refid="selectDriverVo"/> 78 <include refid="selectDriverVo"/>
57 where id = #{id} 79 where id = #{id}
58 </select> 80 </select>
59 - 81 +
60 <insert id="insertDriver" parameterType="Driver" useGeneratedKeys="true" keyProperty="id"> 82 <insert id="insertDriver" parameterType="Driver" useGeneratedKeys="true" keyProperty="id">
61 insert into driver 83 insert into driver
62 <trim prefix="(" suffix=")" suffixOverrides=","> 84 <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -76,7 +98,7 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot; @@ -76,7 +98,7 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
76 <if test="remark != null">remark,</if> 98 <if test="remark != null">remark,</if>
77 <if test="lineName != null">line_name,</if> 99 <if test="lineName != null">line_name,</if>
78 <if test="lineCode != null">line_code,</if> 100 <if test="lineCode != null">line_code,</if>
79 - </trim> 101 + </trim>
80 <trim prefix="values (" suffix=")" suffixOverrides=","> 102 <trim prefix="values (" suffix=")" suffixOverrides=",">
81 <if test="jobCode != null and jobCode != ''">#{jobCode},</if> 103 <if test="jobCode != null and jobCode != ''">#{jobCode},</if>
82 <if test="companyCode != null and companyCode != ''">#{companyCode},</if> 104 <if test="companyCode != null and companyCode != ''">#{companyCode},</if>
@@ -94,7 +116,7 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot; @@ -94,7 +116,7 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
94 <if test="remark != null">#{remark},</if> 116 <if test="remark != null">#{remark},</if>
95 <if test="lineName != null">#{lineName},</if> 117 <if test="lineName != null">#{lineName},</if>
96 <if test="lineCode != null">#{lineCode},</if> 118 <if test="lineCode != null">#{lineCode},</if>
97 - </trim> 119 + </trim>
98 </insert> 120 </insert>
99 121
100 <update id="updateDriver" parameterType="Driver"> 122 <update id="updateDriver" parameterType="Driver">
@@ -119,13 +141,58 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot; @@ -119,13 +141,58 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
119 </trim> 141 </trim>
120 where id = #{id} 142 where id = #{id}
121 </update> 143 </update>
  144 + <insert id="saveDriverScheduling">
  145 + INSERT INTO driver_scheduling (
  146 + id, scheduleDate, lineName, lineCode, lpName,
  147 + nbbm, job_code,jsy, spy, upDown, qdzCode,
  148 + qdzName, zdzCode, zdzName, fcsjT, dfsjT,
  149 + zdsjT, fcsjActualTime, zdsjActualTime,
  150 + jhlc, jhlcOrig, bcsj, bcType, status, adjustExps,
  151 + sflj, remarks)
  152 + values
  153 + <foreach collection="responseSchedulings" item="item" index="index" separator=",">
  154 + (
  155 + #{item.id},
  156 + #{item.scheduleDate},
  157 + #{item.lineName,jdbcType=VARCHAR},
  158 + #{item.lineCode,jdbcType=VARCHAR},
  159 + #{item.lpName,jdbcType=VARCHAR},
  160 + #{item.nbbm,jdbcType=VARCHAR},
  161 + #{item.jobCode,jdbcType=VARCHAR},
  162 + #{item.jsy,jdbcType=VARCHAR},
  163 + #{item.spy,jdbcType=VARCHAR},
  164 + #{item.upDown,jdbcType=VARCHAR},
  165 + #{item.qdzCode,jdbcType=VARCHAR},
  166 + #{item.qdzName,jdbcType=VARCHAR},
  167 + #{item.zdzCode,jdbcType=VARCHAR},
  168 + #{item.zdzName,jdbcType=VARCHAR},
  169 + #{item.fcsjT},
  170 + #{item.dfsjT},
  171 + #{item.zdsjT},
  172 + #{item.fcsjActualTime},
  173 + #{item.zdsjActualTime},
  174 + #{item.jhlc,jdbcType=VARCHAR},
  175 + #{item.jhlcOrig,jdbcType=VARCHAR},
  176 + #{item.bcsj,jdbcType=VARCHAR},
  177 + #{item.bcType,jdbcType=VARCHAR},
  178 + #{item.status,jdbcType=VARCHAR},
  179 + #{item.adjustExps,jdbcType=VARCHAR},
  180 + #{item.sflj,jdbcType=VARCHAR},
  181 + #{item.remarks,jdbcType=VARCHAR}
  182 + )
  183 + </foreach>
  184 + on duplicate key update
  185 + job_code = values(job_code)
  186 + </insert>
122 187
123 <delete id="deleteDriverById" parameterType="Long"> 188 <delete id="deleteDriverById" parameterType="Long">
124 - delete from driver where id = #{id} 189 + delete
  190 + from driver
  191 + where id = #{id}
125 </delete> 192 </delete>
126 193
127 <delete id="deleteDriverByIds" parameterType="String"> 194 <delete id="deleteDriverByIds" parameterType="String">
128 - delete from driver where id in 195 + delete from driver where id in
129 <foreach item="id" collection="array" open="(" separator="," close=")"> 196 <foreach item="id" collection="array" open="(" separator="," close=")">
130 #{id} 197 #{id}
131 </foreach> 198 </foreach>
ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java
@@ -6,6 +6,7 @@ import java.util.List; @@ -6,6 +6,7 @@ import java.util.List;
6 import java.util.Map; 6 import java.util.Map;
7 import java.util.Set; 7 import java.util.Set;
8 import java.util.concurrent.TimeUnit; 8 import java.util.concurrent.TimeUnit;
  9 +
9 import org.springframework.beans.factory.annotation.Autowired; 10 import org.springframework.beans.factory.annotation.Autowired;
10 import org.springframework.data.redis.core.BoundSetOperations; 11 import org.springframework.data.redis.core.BoundSetOperations;
11 import org.springframework.data.redis.core.HashOperations; 12 import org.springframework.data.redis.core.HashOperations;
@@ -18,59 +19,54 @@ import org.springframework.stereotype.Component; @@ -18,59 +19,54 @@ import org.springframework.stereotype.Component;
18 * 19 *
19 * @author ruoyi 20 * @author ruoyi
20 **/ 21 **/
21 -@SuppressWarnings(value = { "unchecked", "rawtypes" }) 22 +@SuppressWarnings(value = {"unchecked", "rawtypes"})
22 @Component 23 @Component
23 -public class RedisCache  
24 -{ 24 +public class RedisCache {
25 @Autowired 25 @Autowired
26 public RedisTemplate redisTemplate; 26 public RedisTemplate redisTemplate;
27 27
28 /** 28 /**
29 * 缓存基本的对象,Integer、String、实体类等 29 * 缓存基本的对象,Integer、String、实体类等
30 * 30 *
31 - * @param key 缓存的键值 31 + * @param key 缓存的键值
32 * @param value 缓存的值 32 * @param value 缓存的值
33 */ 33 */
34 - public <T> void setCacheObject(final String key, final T value)  
35 - { 34 + public <T> void setCacheObject(final String key, final T value) {
36 redisTemplate.opsForValue().set(key, value); 35 redisTemplate.opsForValue().set(key, value);
37 } 36 }
38 37
39 /** 38 /**
40 * 缓存基本的对象,Integer、String、实体类等 39 * 缓存基本的对象,Integer、String、实体类等
41 * 40 *
42 - * @param key 缓存的键值  
43 - * @param value 缓存的值  
44 - * @param timeout 时间 41 + * @param key 缓存的键值
  42 + * @param value 缓存的值
  43 + * @param timeout 时间
45 * @param timeUnit 时间颗粒度 44 * @param timeUnit 时间颗粒度
46 */ 45 */
47 - public <T> void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit)  
48 - { 46 + public <T> void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit) {
49 redisTemplate.opsForValue().set(key, value, timeout, timeUnit); 47 redisTemplate.opsForValue().set(key, value, timeout, timeUnit);
50 } 48 }
51 49
52 /** 50 /**
53 * 设置有效时间 51 * 设置有效时间
54 * 52 *
55 - * @param key Redis键 53 + * @param key Redis键
56 * @param timeout 超时时间 54 * @param timeout 超时时间
57 * @return true=设置成功;false=设置失败 55 * @return true=设置成功;false=设置失败
58 */ 56 */
59 - public boolean expire(final String key, final long timeout)  
60 - { 57 + public boolean expire(final String key, final long timeout) {
61 return expire(key, timeout, TimeUnit.SECONDS); 58 return expire(key, timeout, TimeUnit.SECONDS);
62 } 59 }
63 60
64 /** 61 /**
65 * 设置有效时间 62 * 设置有效时间
66 * 63 *
67 - * @param key Redis键 64 + * @param key Redis键
68 * @param timeout 超时时间 65 * @param timeout 超时时间
69 - * @param unit 时间单位 66 + * @param unit 时间单位
70 * @return true=设置成功;false=设置失败 67 * @return true=设置成功;false=设置失败
71 */ 68 */
72 - public boolean expire(final String key, final long timeout, final TimeUnit unit)  
73 - { 69 + public boolean expire(final String key, final long timeout, final TimeUnit unit) {
74 return redisTemplate.expire(key, timeout, unit); 70 return redisTemplate.expire(key, timeout, unit);
75 } 71 }
76 72
@@ -80,8 +76,7 @@ public class RedisCache @@ -80,8 +76,7 @@ public class RedisCache
80 * @param key Redis键 76 * @param key Redis键
81 * @return 有效时间 77 * @return 有效时间
82 */ 78 */
83 - public long getExpire(final String key)  
84 - { 79 + public long getExpire(final String key) {
85 return redisTemplate.getExpire(key); 80 return redisTemplate.getExpire(key);
86 } 81 }
87 82
@@ -91,8 +86,7 @@ public class RedisCache @@ -91,8 +86,7 @@ public class RedisCache
91 * @param key 键 86 * @param key 键
92 * @return true 存在 false不存在 87 * @return true 存在 false不存在
93 */ 88 */
94 - public Boolean hasKey(String key)  
95 - { 89 + public Boolean hasKey(String key) {
96 return redisTemplate.hasKey(key); 90 return redisTemplate.hasKey(key);
97 } 91 }
98 92
@@ -102,8 +96,7 @@ public class RedisCache @@ -102,8 +96,7 @@ public class RedisCache
102 * @param key 缓存键值 96 * @param key 缓存键值
103 * @return 缓存键值对应的数据 97 * @return 缓存键值对应的数据
104 */ 98 */
105 - public <T> T getCacheObject(final String key)  
106 - { 99 + public <T> T getCacheObject(final String key) {
107 ValueOperations<String, T> operation = redisTemplate.opsForValue(); 100 ValueOperations<String, T> operation = redisTemplate.opsForValue();
108 return operation.get(key); 101 return operation.get(key);
109 } 102 }
@@ -113,8 +106,7 @@ public class RedisCache @@ -113,8 +106,7 @@ public class RedisCache
113 * 106 *
114 * @param key 107 * @param key
115 */ 108 */
116 - public boolean deleteObject(final String key)  
117 - { 109 + public boolean deleteObject(final String key) {
118 return redisTemplate.delete(key); 110 return redisTemplate.delete(key);
119 } 111 }
120 112
@@ -124,20 +116,18 @@ public class RedisCache @@ -124,20 +116,18 @@ public class RedisCache
124 * @param collection 多个对象 116 * @param collection 多个对象
125 * @return 117 * @return
126 */ 118 */
127 - public boolean deleteObject(final Collection collection)  
128 - { 119 + public boolean deleteObject(final Collection collection) {
129 return redisTemplate.delete(collection) > 0; 120 return redisTemplate.delete(collection) > 0;
130 } 121 }
131 122
132 /** 123 /**
133 * 缓存List数据 124 * 缓存List数据
134 * 125 *
135 - * @param key 缓存的键值 126 + * @param key 缓存的键值
136 * @param dataList 待缓存的List数据 127 * @param dataList 待缓存的List数据
137 * @return 缓存的对象 128 * @return 缓存的对象
138 */ 129 */
139 - public <T> long setCacheList(final String key, final List<T> dataList)  
140 - { 130 + public <T> long setCacheList(final String key, final List<T> dataList) {
141 Long count = redisTemplate.opsForList().rightPushAll(key, dataList); 131 Long count = redisTemplate.opsForList().rightPushAll(key, dataList);
142 return count == null ? 0 : count; 132 return count == null ? 0 : count;
143 } 133 }
@@ -148,24 +138,21 @@ public class RedisCache @@ -148,24 +138,21 @@ public class RedisCache
148 * @param key 缓存的键值 138 * @param key 缓存的键值
149 * @return 缓存键值对应的数据 139 * @return 缓存键值对应的数据
150 */ 140 */
151 - public <T> List<T> getCacheList(final String key)  
152 - { 141 + public <T> List<T> getCacheList(final String key) {
153 return redisTemplate.opsForList().range(key, 0, -1); 142 return redisTemplate.opsForList().range(key, 0, -1);
154 } 143 }
155 144
156 /** 145 /**
157 * 缓存Set 146 * 缓存Set
158 * 147 *
159 - * @param key 缓存键值 148 + * @param key 缓存键值
160 * @param dataSet 缓存的数据 149 * @param dataSet 缓存的数据
161 * @return 缓存数据的对象 150 * @return 缓存数据的对象
162 */ 151 */
163 - public <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet)  
164 - { 152 + public <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet) {
165 BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key); 153 BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
166 Iterator<T> it = dataSet.iterator(); 154 Iterator<T> it = dataSet.iterator();
167 - while (it.hasNext())  
168 - { 155 + while (it.hasNext()) {
169 setOperation.add(it.next()); 156 setOperation.add(it.next());
170 } 157 }
171 return setOperation; 158 return setOperation;
@@ -177,8 +164,7 @@ public class RedisCache @@ -177,8 +164,7 @@ public class RedisCache
177 * @param key 164 * @param key
178 * @return 165 * @return
179 */ 166 */
180 - public <T> Set<T> getCacheSet(final String key)  
181 - { 167 + public <T> Set<T> getCacheSet(final String key) {
182 return redisTemplate.opsForSet().members(key); 168 return redisTemplate.opsForSet().members(key);
183 } 169 }
184 170
@@ -188,10 +174,25 @@ public class RedisCache @@ -188,10 +174,25 @@ public class RedisCache
188 * @param key 174 * @param key
189 * @param dataMap 175 * @param dataMap
190 */ 176 */
191 - public <T> void setCacheMap(final String key, final Map<String, T> dataMap)  
192 - { 177 + public <T> void setCacheMap(final String key, final Map<String, T> dataMap) {
  178 + if (dataMap != null) {
  179 + redisTemplate.opsForHash().putAll(key, dataMap);
  180 + }
  181 + }
  182 +
  183 + /**
  184 + * 缓存map并设置key
  185 + *
  186 + * @param key
  187 + * @param dataMap
  188 + * @param timeOut
  189 + * @param timeUnit
  190 + * @param <T>
  191 + */
  192 + public <T> void setCacheMap(final String key, final Map<String, T> dataMap, long timeOut, TimeUnit timeUnit) {
193 if (dataMap != null) { 193 if (dataMap != null) {
194 redisTemplate.opsForHash().putAll(key, dataMap); 194 redisTemplate.opsForHash().putAll(key, dataMap);
  195 + redisTemplate.expire(key, timeOut, timeUnit);
195 } 196 }
196 } 197 }
197 198
@@ -201,32 +202,41 @@ public class RedisCache @@ -201,32 +202,41 @@ public class RedisCache
201 * @param key 202 * @param key
202 * @return 203 * @return
203 */ 204 */
204 - public <T> Map<String, T> getCacheMap(final String key)  
205 - { 205 + public <T> Map<String, T> getCacheMap(final String key) {
206 return redisTemplate.opsForHash().entries(key); 206 return redisTemplate.opsForHash().entries(key);
207 } 207 }
208 208
209 /** 209 /**
210 * 往Hash中存入数据 210 * 往Hash中存入数据
211 * 211 *
212 - * @param key Redis键  
213 - * @param hKey Hash键 212 + * @param key Redis键
  213 + * @param hKey Hash键
214 * @param value 值 214 * @param value 值
215 */ 215 */
216 - public <T> void setCacheMapValue(final String key, final String hKey, final T value)  
217 - { 216 + public <T> void setCacheMapValue(final String key, final String hKey, final T value) {
218 redisTemplate.opsForHash().put(key, hKey, value); 217 redisTemplate.opsForHash().put(key, hKey, value);
219 } 218 }
220 219
221 /** 220 /**
  221 + * 往Hash中存入数据 并设置过期时间
  222 + *
  223 + * @param key Redis键
  224 + * @param hKey Hash键
  225 + * @param value 值
  226 + */
  227 + public <T> void setCacheMapValue(final String key, final String hKey, final T value, long timeOut, TimeUnit timeUnit) {
  228 + redisTemplate.opsForHash().put(key, hKey, value);
  229 + redisTemplate.expire(key,timeOut,timeUnit);
  230 + }
  231 +
  232 + /**
222 * 获取Hash中的数据 233 * 获取Hash中的数据
223 * 234 *
224 - * @param key Redis键 235 + * @param key Redis键
225 * @param hKey Hash键 236 * @param hKey Hash键
226 * @return Hash中的对象 237 * @return Hash中的对象
227 */ 238 */
228 - public <T> T getCacheMapValue(final String key, final String hKey)  
229 - { 239 + public <T> T getCacheMapValue(final String key, final String hKey) {
230 HashOperations<String, String, T> opsForHash = redisTemplate.opsForHash(); 240 HashOperations<String, String, T> opsForHash = redisTemplate.opsForHash();
231 return opsForHash.get(key, hKey); 241 return opsForHash.get(key, hKey);
232 } 242 }
@@ -234,24 +244,22 @@ public class RedisCache @@ -234,24 +244,22 @@ public class RedisCache
234 /** 244 /**
235 * 获取多个Hash中的数据 245 * 获取多个Hash中的数据
236 * 246 *
237 - * @param key Redis键 247 + * @param key Redis键
238 * @param hKeys Hash键集合 248 * @param hKeys Hash键集合
239 * @return Hash对象集合 249 * @return Hash对象集合
240 */ 250 */
241 - public <T> List<T> getMultiCacheMapValue(final String key, final Collection<Object> hKeys)  
242 - { 251 + public <T> List<T> getMultiCacheMapValue(final String key, final Collection<Object> hKeys) {
243 return redisTemplate.opsForHash().multiGet(key, hKeys); 252 return redisTemplate.opsForHash().multiGet(key, hKeys);
244 } 253 }
245 254
246 /** 255 /**
247 * 删除Hash中的某条数据 256 * 删除Hash中的某条数据
248 * 257 *
249 - * @param key Redis键 258 + * @param key Redis键
250 * @param hKey Hash键 259 * @param hKey Hash键
251 * @return 是否成功 260 * @return 是否成功
252 */ 261 */
253 - public boolean deleteCacheMapValue(final String key, final String hKey)  
254 - { 262 + public boolean deleteCacheMapValue(final String key, final String hKey) {
255 return redisTemplate.opsForHash().delete(key, hKey) > 0; 263 return redisTemplate.opsForHash().delete(key, hKey) > 0;
256 } 264 }
257 265
@@ -261,8 +269,7 @@ public class RedisCache @@ -261,8 +269,7 @@ public class RedisCache
261 * @param pattern 字符串前缀 269 * @param pattern 字符串前缀
262 * @return 对象列表 270 * @return 对象列表
263 */ 271 */
264 - public Collection<String> keys(final String pattern)  
265 - { 272 + public Collection<String> keys(final String pattern) {
266 return redisTemplate.keys(pattern); 273 return redisTemplate.keys(pattern);
267 } 274 }
268 } 275 }