Commit 68847d41 authored by 王琮's avatar 王琮

修改通行管理列表业务

parent db466436
......@@ -61,9 +61,7 @@ public class TimeUtils {
*/
public static Date getCurrentYear() {
Calendar calendar = Calendar.getInstance();// 获取当前日期
// TODO: 2023/1/1 获取去年的时间 2022
// calendar.add(Calendar.YEAR, 0);
calendar.add(Calendar.YEAR, -1);
calendar.add(Calendar.YEAR, 0);
calendar.add(Calendar.DATE, 0);
calendar.add(Calendar.MONTH, 0);
calendar.set(Calendar.DAY_OF_YEAR, 1);
......
......@@ -16,6 +16,7 @@ import java.util.List;
import com.baomidou.mybatisplus.annotation.TableName;
import org.springframework.data.annotation.Transient;
import org.springframework.format.annotation.DateTimeFormat;
/**
* Created with cy on 2022年11月24日 下午12:47:46.
......@@ -45,6 +46,20 @@ public class DoorRecord extends CyIdEntity<DoorRecord> {
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private String endTime;
/**
* 开始时间
*/
@Transient
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date startTime;
//结束时间
@Transient
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date closeTime;
//登记方式
@Transient
private String deviceIoType;
......
......@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang.StringUtils;
import org.rcisoft.core.exception.CyServiceException;
import org.rcisoft.core.util.CyUserUtil;
import org.rcisoft.core.aop.CyPageUtilAsp;
import org.rcisoft.core.model.CyPersistModel;
......@@ -145,14 +146,12 @@ public class DoorRecordServiceImpl extends ServiceImpl<DoorRecordRepository, Doo
*/
@Override
public IPage<DoorRecord> findAllByPagination(CyPageInfo<DoorRecord> paginationUtility, DoorRecord doorRecord) {
//TODO 需要重写
//条件加上年份,默认查询当年的,因此代码里面需要判断是否传递有年代的逻辑
Date nowYear = TimeUtils.getCurrentYear();
Date nowYearEnd = TimeUtils.getCurrentYearEnd();
List<Date> crossTimeRange = new ArrayList<>();
crossTimeRange.add(0, nowYear);
crossTimeRange.add(1, nowYearEnd);
// 处理设备id
if (!doorRecord.getDeviceId().equals("")) {
String[] deviceIdArr = doorRecord.getDeviceId().split(",");
......@@ -163,8 +162,17 @@ public class DoorRecordServiceImpl extends ServiceImpl<DoorRecordRepository, Doo
String deviceIdArrStr = StringUtils.join(deviceIdArrTemp, ",");
doorRecord.setDeviceId(deviceIdArrStr);
}
IPage<DoorRecord> doorRecordIPage = baseMapper.queryDoorRecordsPagedWithCrossTimeRange(paginationUtility, doorRecord, crossTimeRange);
if (StringUtils.isNotEmpty(doorRecord.getBeginTime()) && StringUtils.isNotEmpty(doorRecord.getEndTime())) {
try {
SimpleDateFormat simpleDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
doorRecord.setStartTime(simpleDate.parse(doorRecord.getBeginTime()+" 00:00:00"));
doorRecord.setCloseTime(simpleDate.parse(doorRecord.getEndTime()+" 23:59:59"));
} catch (Exception e) {
throw new CyServiceException("时间转换失败");
}
}
IPage<DoorRecord> doorRecordIPage = baseMapper.queryDoorRecordsPagedWithCrossTimeRange(paginationUtility,
doorRecord, crossTimeRange);
for (int i = 0; i < doorRecordIPage.getRecords().size(); i++) {
//获取登记时间
Date crossTime = doorRecordIPage.getRecords().get(i).getCrossTime();
......@@ -181,10 +189,8 @@ public class DoorRecordServiceImpl extends ServiceImpl<DoorRecordRepository, Doo
if (sysDictData != null) {
doorRecordIPage.getRecords().get(i).setCardTypeLabel(sysDictData.getDictLabel());
}
}
return doorRecordIPage;
}
/**
......
......@@ -28,7 +28,7 @@
<result column="position_label" jdbcType="VARCHAR" property="positionName"/>
<result column="dept_name" jdbcType="VARCHAR" property="deptName"/>
</resultMap>
<insert id="saveRecordData" parameterType="org.rcisoft.sys.sysuser.entity.DoorRecord" useGeneratedKeys="false">
insert into door_record
<trim prefix="(" suffix=")" suffixOverrides=",">
......@@ -183,17 +183,16 @@
SELECT
dr.record_id,su.name,su.business_id,dr.tenement_type,dr.cross_time,dr.create_date,dr.device_id,dr.device_type,dr.device_name,dr.card_type,dr.record_type,dr.card_type_label,dr.abnormal
FROM door_record dr
-- LEFT JOIN sys_user su ON dr.user_id = su.business_id
LEFT JOIN sys_user su ON dr.person_id = su.person_id
WHERE dr.del_flag = 0 and dr.cross_time between #{crossTimeRange[0]} and #{crossTimeRange[1]}
WHERE dr.del_flag = 0
<if test="entity.deviceType !=null and entity.deviceType != '' ">
and dr.device_type = #{entity.deviceType}
</if>
<if test="entity.beginTime != null and entity.beginTime !='' "><!-- 开始时间检索 -->
and date_format(dr.create_date,'%Y-%m-%d') &gt;= date_format(#{entity.beginTime},'%Y-%m-%d')
<if test="entity.beginTime != '' and entity.endTime !='' ">
and dr.cross_time between #{entity.startTime} and #{entity.closeTime}
</if>
<if test="entity.endTime != null and entity.endTime !='' "><!-- 结束时间检索 -->
and date_format(dr.create_date,'%Y-%m-%d') &lt;= date_format(#{entity.endTime},'%Y-%m-%d')
<if test="entity.endTime == '' and entity.beginTime == ''">
and dr.cross_time between #{crossTimeRange[0]} and #{crossTimeRange[1]}
</if>
<if test="entity.deviceId !=null and entity.deviceId != '' ">
and dr.device_id in(${entity.deviceId})
......
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