Commit d4f2d24b authored by wujipeng's avatar wujipeng
Browse files

优化

parent 79153234
...@@ -13,14 +13,12 @@ import com.ruzhoukj.sms.service.DingAttendanceService; ...@@ -13,14 +13,12 @@ import com.ruzhoukj.sms.service.DingAttendanceService;
import com.taobao.api.ApiException; import com.taobao.api.ApiException;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
...@@ -55,12 +53,12 @@ public class DingAttendanceController { ...@@ -55,12 +53,12 @@ public class DingAttendanceController {
List<DingAttendanceVO> data = Lists.newArrayList(); List<DingAttendanceVO> data = Lists.newArrayList();
rsp.getRecordresult().forEach(recordresult -> { rsp.getRecordresult().forEach(recordresult -> {
data.add(DingAttendanceVO.builder() data.add(DingAttendanceVO.builder()
.userId(recordresult.getUserId()) .userId(recordresult.getUserId())
.userAddress(recordresult.getUserAddress()) .userAddress(recordresult.getUserAddress())
.userCheckTime(recordresult.getUserCheckTime()) .userCheckTime(recordresult.getUserCheckTime())
.timeResult(recordresult.getTimeResult()) .timeResult(recordresult.getTimeResult())
.checkType(recordresult.getCheckType()) .checkType(recordresult.getCheckType())
.sourceType(recordresult.getSourceType()) .sourceType(recordresult.getSourceType())
.build()); .build());
}); });
......
...@@ -6,21 +6,24 @@ ...@@ -6,21 +6,24 @@
<select id="getSyncData" resultType="com.ruzhoukj.sms.model.vo.DingAttendanceVO"> <select id="getSyncData" resultType="com.ruzhoukj.sms.model.vo.DingAttendanceVO">
SELECT min.id, SELECT min.id,
min.name, min.name,
min.user_id as userId, min.user_id as userId,
MIN(min.user_check_time) AS checkTimeOn, MIN(min.user_check_time) AS checkTimeOn,
MAX(max.offduty_max_time) AS checkTimeOff, MAX(max.offduty_max_time) AS checkTimeOff,
min.user_address as userAddress, min.user_address as userAddress,
min.time_result as timeResult, min.time_result as timeResult
FROM ding_attendance min FROM ding_attendance min
LEFT JOIN (SELECT user_id, LEFT JOIN (SELECT user_id,
MAX(user_check_time) AS offduty_max_time MAX(user_check_time) AS offduty_max_time
FROM ding_attendance FROM ding_attendance
WHERE user_check_time BETWEEN #{checkDateFrom} AND #{checkDateTo} WHERE user_check_time BETWEEN #{checkDateFrom} AND #{checkDateTo}
AND check_type = 'OffDuty' AND check_type = 'OffDuty'
GROUP BY user_id -- 按 user_id 分组 GROUP BY user_id -- 按 user_id 分组
) max ON min.user_id = max.user_id ) max
WHERE min.user_check_time BETWEEN #{checkDateFrom} AND #{checkDateTo} ON min.user_id = max.user_id
WHERE min.user_check_time BETWEEN #{checkDateFrom}
AND #{checkDateTo}
AND min.check_type = 'OnDuty' AND min.check_type = 'OnDuty'
GROUP BY min.id, min.name, min.user_id, min.user_address, min.time_result; GROUP BY min.id, min.name, min.user_id, min.user_address, min.time_result, min.user_check_time
order by min.user_check_time
</select> </select>
</mapper> </mapper>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment