bug修复

This commit is contained in:
guo 2024-04-09 21:58:24 +08:00
parent 7e0badce4e
commit 3d03055709
5 changed files with 35 additions and 7 deletions

View File

@ -5,6 +5,7 @@ import java.util.Map;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhgd.jeecg.common.mybatis.EntityMap; import com.zhgd.jeecg.common.mybatis.EntityMap;
import com.zhgd.xmgl.base.entity.vo.TrendOneVo;
import com.zhgd.xmgl.entity.vo.NumberTimeTableVo; import com.zhgd.xmgl.entity.vo.NumberTimeTableVo;
import com.zhgd.xmgl.modules.worker.entity.bo.WorkerAttendanceBo; import com.zhgd.xmgl.modules.worker.entity.bo.WorkerAttendanceBo;
import com.zhgd.xmgl.modules.worker.entity.dto.GetPassRecordDto; import com.zhgd.xmgl.modules.worker.entity.dto.GetPassRecordDto;
@ -85,4 +86,6 @@ public interface WorkerAttendanceMapper extends BaseMapper<WorkerAttendance> {
List<NumberTimeTableVo> queryAttendanceTrend(Map<String, Object> map); List<NumberTimeTableVo> queryAttendanceTrend(Map<String, Object> map);
List<WorkerAttendance> queryPresenceList(Map<String, Object> map); List<WorkerAttendance> queryPresenceList(Map<String, Object> map);
List<TrendOneVo> queryTodayAttendanceTrend(Map<String, Object> map);
} }

View File

@ -808,4 +808,19 @@
GROUP BY person_sn) GROUP BY person_sn)
AND a.pass_type = 1 AND a.pass_type = 1
</select> </select>
<select id="queryTodayAttendanceTrend" resultType="com.zhgd.xmgl.base.entity.vo.TrendOneVo">
SELECT ifnull(round(sum(if(a.pass_type=1,1,-1)),2),0) y,DATE_FORMAT(a.create_time, '%Y-%m-%d %H:00') x
FROM worker_attendance a
INNER JOIN (
SELECT MAX(create_time) AS create_time,person_sn
FROM worker_attendance
WHERE project_sn = #{projectSn}
and create_time >= CURRENT_DATE
and create_time <![CDATA[<=]]> CONCAT(DATE_FORMAT(CURRENT_DATE, '%Y-%m-%d'), ' 23:59:59')
group by person_sn,DATE_FORMAT(create_time, '%Y-%m-%d %H:00')
) t2 on t2.create_time=a.create_time and t2.person_sn=a.person_sn
WHERE project_sn = #{projectSn}
group by DATE_FORMAT(a.create_time, '%Y-%m-%d %H:00')
</select>
</mapper> </mapper>

View File

@ -676,6 +676,7 @@
INNER JOIN team_info b ON a.team_id = b.id INNER JOIN team_info b ON a.team_id = b.id
WHERE a.project_sn = #{projectSn} WHERE a.project_sn = #{projectSn}
and a.inService_type = 1 and a.inService_type = 1
GROUP BY b.worker_type_id
) ap on w.id = ap.worker_type_id ) ap on w.id = ap.worker_type_id
WHERE w.project_sn = #{projectSn} WHERE w.project_sn = #{projectSn}
ORDER BY total_person_num desc ORDER BY total_person_num desc

View File

@ -1017,26 +1017,34 @@ status 状态码 String 1表示成功其余表示失败
}).collect(Collectors.groupingBy(WorkerAttendance::getCreateTimeHour)); }).collect(Collectors.groupingBy(WorkerAttendance::getCreateTimeHour));
ArrayList<NumberTimeTableVo> rtList = new ArrayList<>(); ArrayList<NumberTimeTableVo> rtList = new ArrayList<>();
List<String> allHourInDay = DateUtils.getDateTimeStrList(100, "HH:mm"); List<String> allHourInDay = DateUtils.getDateTimeStrList(100, "HH:mm");
int lastNum = 0; Set<String> inSet = new HashSet<>();
Set<String> outSet = new HashSet<>();
for (String hour : allHourInDay) { for (String hour : allHourInDay) {
List<WorkerAttendance> workerAttendances = timeDateListMap.get(hour); List<WorkerAttendance> workerAttendances = timeDateListMap.get(hour);
NumberTimeTableVo vo = new NumberTimeTableVo(); NumberTimeTableVo vo = new NumberTimeTableVo();
int num = 0;
if (CollUtil.isNotEmpty(workerAttendances)) { if (CollUtil.isNotEmpty(workerAttendances)) {
workerAttendances.sort((o1, o2) -> {
if (o1.getCreateTime() == null || o2.getCreateTime() == null) {
return 0;
}
return o1.getCreateTime().compareTo(o2.getCreateTime());
});
for (WorkerAttendance workerAttendance : workerAttendances) { for (WorkerAttendance workerAttendance : workerAttendances) {
if (Objects.equals(workerAttendance.getPassType(), 1)) { if (Objects.equals(workerAttendance.getPassType(), 1)) {
num++; if (!outSet.remove(workerAttendance.getPersonSn())) {
inSet.add(workerAttendance.getPersonSn());
}
} else if (Objects.equals(workerAttendance.getPassType(), 2)) { } else if (Objects.equals(workerAttendance.getPassType(), 2)) {
num--; if (!inSet.remove(workerAttendance.getPersonSn())) {
outSet.add(workerAttendance.getPersonSn());
}
} }
} }
} }
if (DateUtil.parse(nowHour).compareTo(DateUtil.parse(hour)) < 0) { if (DateUtil.parse(nowHour).compareTo(DateUtil.parse(hour)) < 0) {
//if (DateUtils.parse(nowHour).compareTo(DateUtils.parse(hour)) < 0&&false) { //测试语句
vo.setNum(null); vo.setNum(null);
} else { } else {
vo.setNum(Math.max(lastNum + num, 0)); vo.setNum(Math.max(inSet.size() - outSet.size(), 0));
lastNum = vo.getNum();
} }
vo.setTime(hour); vo.setTime(hour);
rtList.add(vo); rtList.add(vo);

View File

@ -13,6 +13,7 @@ import com.zhgd.xmgl.modules.basicdata.mapper.HikvisionRequestRetryMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;