Browse Source

增加查询司机当天最后考勤记录

zhengqiang 4 năm trước cách đây
mục cha
commit
eaef089f35

+ 0 - 3
common/pom.xml

@@ -254,13 +254,10 @@
             <artifactId>gps</artifactId>
             <version>1.0.0</version>
         </dependency>
-
         <dependency>
             <groupId>org.gavaghan</groupId>
             <artifactId>geodesy</artifactId>
             <version>1.1.3</version>
         </dependency>
     </dependencies>
-
-
 </project>

+ 2 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/dao/DriverRecordInfoDAO.java

@@ -4,6 +4,7 @@ import com.jpsoft.bus.modules.bus.entity.DriverRecordInfo;
 import com.jpsoft.bus.modules.common.dto.Sort;
 import org.springframework.stereotype.Repository;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -20,4 +21,5 @@ public interface DriverRecordInfoDAO {
     int delete(String id);
     List<DriverRecordInfo> list();
     List<DriverRecordInfo> search(Map<String, Object> searchParams, List<Sort> sortList);
+    DriverRecordInfo findLastAttendanceRecord(Long driverId, String licensePlateNumber, Date startTime);
 }

+ 2 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/service/DriverRecordInfoService.java

@@ -5,6 +5,7 @@ import com.jpsoft.bus.modules.bus.entity.DriverInfo;
 import com.jpsoft.bus.modules.bus.entity.DriverRecordInfo;
 import com.jpsoft.bus.modules.common.dto.Sort;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -21,4 +22,5 @@ public interface DriverRecordInfoService {
     int delete(String id);
     List<DriverRecordInfo> list();
     Page<DriverRecordInfo> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize, boolean count, List<Sort> sortList);
+    DriverRecordInfo findLastAttendanceRecord(Long driverId, String licensePlateNumber, Date startTime);
 }

+ 5 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/service/impl/DriverRecordInfoServiceImpl.java

@@ -10,6 +10,7 @@ import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -73,4 +74,8 @@ public class DriverRecordInfoServiceImpl implements DriverRecordInfoService {
         return page;
     }
 
+    @Override
+    public DriverRecordInfo findLastAttendanceRecord(Long driverId, String licensePlateNumber, Date startTime) {
+        return driverRecordInfoDAO.findLastAttendanceRecord(driverId,licensePlateNumber, startTime);
+    }
 }

+ 11 - 1
common/src/main/resources/mapper/bus/DriverRecordInfo.xml

@@ -113,5 +113,15 @@
             ${sort.name} ${sort.order}
         </foreach>
     </select>
-
+    <select id="findLastAttendanceRecord" parameterType="hashmap" resultMap="DriverRecordInfoMap">
+        <![CDATA[
+            select * from bus_driver_record_info
+            where del_flag=0
+            and driver_id=#{driverId}
+            and license_plate_number = #{licensePlateNumber}
+            and record_time > #{startTime}
+            order by record_time desc
+            limit 1
+        ]]>
+    </select>
 </mapper>

+ 33 - 9
web/src/main/java/com/jpsoft/bus/modules/driver/controller/DriverApiController.java

@@ -18,10 +18,7 @@ import org.bouncycastle.crypto.signers.ECDSASigner;
 import org.joda.time.DateTime;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestAttribute;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.util.*;
@@ -146,19 +143,21 @@ public class DriverApiController {
             @ApiImplicitParam(name = "token", value = "令牌", paramType = "form"),
             @ApiImplicitParam(name = "subject", value = "目标(不传)", paramType = "form")
     })
-    public MessageResult<Map> driverAttendance(String driverId, String photoBase64Data, String recordTime, String token, @RequestAttribute String subject) {
-        MessageResult<Map> messageResult = new MessageResult<>();
+    public MessageResult<DriverRecordInfo> driverAttendance(String driverId, String photoBase64Data, String recordTime, String token, @RequestAttribute String subject) {
+        MessageResult<DriverRecordInfo> messageResult = new MessageResult<>();
 
         try {
-
             VehicleInfo vehicleInfo = vehicleInfoService.get(subject);
+
             if (vehicleInfo == null){
                 throw new Exception("当前车辆不存在");
             }
+
             DriverInfo driverInfo = driverInfoService.get(driverId);
             if (driverInfo == null){
                 throw new Exception("当前司机不存在");
             }
+
             String retFileUrl = OSSUtil.uploadBase64(photoBase64Data,driverInfo.getName()+".jpg",ossConfig);
            // String retFileUrl = OSSUtil.upload(ossConfig, "/faceImage", driverInfo.getName(), photoFile.getInputStream());
             DriverRecordInfo driverRecordInfo = new DriverRecordInfo();
@@ -173,8 +172,7 @@ public class DriverApiController {
             driverRecordInfo.setCreateTime(new Date());
             driverRecordInfoService.insert(driverRecordInfo);
 
-            Map<String,Object> map = new HashMap<>();
-            map.put("driverRecordInfo",driverRecordInfo);
+            messageResult.setData(driverRecordInfo);
             messageResult.setResult(true);
             messageResult.setCode(200);
         } catch (Exception ex) {
@@ -185,6 +183,32 @@ public class DriverApiController {
         return messageResult;
     }
 
+    @GetMapping("findLastAttendanceRecord")
+    @ApiOperation(value="查询司机今日最后考勤打卡")
+    public MessageResult<DriverRecordInfo> findLastAttendanceRecord(@RequestAttribute String subject,Long driverId){
+        MessageResult<DriverRecordInfo> messageResult = new MessageResult<>();
+
+        try {
+            VehicleInfo vehicleInfo = vehicleInfoService.get(subject);
+
+            Date startTime = DateTime.now().withTimeAtStartOfDay().toDate();
+
+            DriverRecordInfo driverRecordInfo = driverRecordInfoService.findLastAttendanceRecord(driverId,vehicleInfo.getLicensePlateNumber(),startTime);
+
+            //todo 填写具体代码
+            messageResult.setData(driverRecordInfo);
+            messageResult.setResult(true);
+        }
+        catch (Exception ex){
+            log.error(ex.getMessage(),ex);
+
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
+
 
     @PostMapping("busRouteInfo")
     @ApiOperation(value = "车辆线路信息")