|
@@ -0,0 +1,98 @@
|
|
|
+package com.jpsoft.bus.modules.bus.controller;
|
|
|
+
|
|
|
+import com.github.pagehelper.Page;
|
|
|
+import com.jpsoft.bus.modules.bus.entity.DriverInfo;
|
|
|
+import com.jpsoft.bus.modules.bus.entity.DriverRecordInfo;
|
|
|
+import com.jpsoft.bus.modules.bus.service.DriverInfoService;
|
|
|
+import com.jpsoft.bus.modules.bus.service.DriverRecordInfoService;
|
|
|
+import com.jpsoft.bus.modules.common.dto.MessageResult;
|
|
|
+import com.jpsoft.bus.modules.common.dto.Sort;
|
|
|
+import com.jpsoft.bus.modules.common.utils.PojoUtils;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("/bus/driverRecordInfo")
|
|
|
+@Api(description = "driverRecordInfo")
|
|
|
+public class DriverRecordInfoController {
|
|
|
+ private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DriverInfoService driverInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DriverRecordInfoService driverRecordInfoService;
|
|
|
+
|
|
|
+ @ApiOperation(value="列表")
|
|
|
+ @RequestMapping(value = "pageList",method = RequestMethod.POST)
|
|
|
+ public MessageResult<Map> pageList(
|
|
|
+ String name,String licensePlateNumber,String recordTimeRanges,
|
|
|
+ @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
|
|
|
+ @RequestParam(value="pageSize",defaultValue="20") int pageSize,
|
|
|
+ @RequestAttribute String subject){
|
|
|
+
|
|
|
+ //当前用户ID
|
|
|
+ System.out.println(subject);
|
|
|
+
|
|
|
+ MessageResult<Map> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ Map<String,Object> searchParams = new HashMap<>();
|
|
|
+
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("a.create_time","desc"));
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(name)) {
|
|
|
+ searchParams.put("name", name);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(licensePlateNumber)) {
|
|
|
+ searchParams.put("licensePlateNumber","%" + licensePlateNumber + "%");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(StringUtils.isNotEmpty(recordTimeRanges)){
|
|
|
+ String[] timeRangeArray = recordTimeRanges.split(",");
|
|
|
+ String beginTime = "";
|
|
|
+ String endTime = "";
|
|
|
+ if (timeRangeArray.length == 1) {
|
|
|
+ beginTime = timeRangeArray[0];
|
|
|
+ beginTime+=" 00:00:00";
|
|
|
+ } else if (timeRangeArray.length == 2) {
|
|
|
+ beginTime = timeRangeArray[0];
|
|
|
+ endTime = timeRangeArray[1];
|
|
|
+ beginTime+=" 00:00:00";
|
|
|
+ endTime+=" 23:59:59";
|
|
|
+ }
|
|
|
+
|
|
|
+ searchParams.put("beginTime", beginTime);
|
|
|
+ searchParams.put("endTime", endTime);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Page<DriverRecordInfo> page = driverRecordInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
|
|
|
+
|
|
|
+ for (DriverRecordInfo driverRecordInfo:page) {
|
|
|
+ DriverInfo driverInfo = driverInfoService.get(driverRecordInfo.getDriverId().toString());
|
|
|
+ if(driverInfo!=null){
|
|
|
+ driverRecordInfo.setDriverName(driverInfo.getName());
|
|
|
+ }
|
|
|
+ if(StringUtils.isNoneEmpty(driverRecordInfo.getLongitude())&&StringUtils.isNoneEmpty(driverRecordInfo.getLatitude())){
|
|
|
+ driverRecordInfo.setLocation(driverRecordInfo.getLongitude()+","+driverRecordInfo.getLatitude());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(PojoUtils.pageWrapper(page));
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+}
|