StatisticsInstoreMapper.xml
1.44 KB
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.stdinterface.modules.mapper.StatisticsInStoreMapper">
<resultMap id="BaseMap" type="cn.com.glsx.stdinterface.modules.entity.StatisticsInstore">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="sn" property="sn" jdbcType="VARCHAR"/>
<result column="instore_num" property="instoreNum" jdbcType="INTEGER"/>
<result column="instore_time" property="instoreTime" jdbcType="VARCHAR"/>
<result column="vd_id" property="vdId" jdbcType="INTEGER"/>
<result column="created_time" property="createdTime" jdbcType="TIMESTAMP"/>
<result column="updated_time" property="updatedTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="BaseColumns">
a.id, a.sn, a.instore_num, a.instore_time, a.vd_id, a.created_time, a.updated_time
</sql>
<insert id="statisticsAndInsertInStoreDataEveryDay">
INSERT t_statistics_instore_drive (instore_num ,instore_time ,vd_id ,created_time)
select
case when sum(case when gps_state = 2 then 1 else 0 end) = count(1) then 1 else 0 end as instore_num ,
left(gps_time,10) as instore_time ,
vd_id ,
NOW()
from t_electric_instore_drive
where left(gps_time,10) = #{yesterDayFormat}
GROUP BY vd_id;
</insert>
</mapper>