<?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="com.qianwen.smartman.modules.mdc.mapper.SuperAggregateStateMapper">
|
|
<insert id="insertData">
|
insert into iot_data.aggregate_state_${workstationId}
|
values ${sql}
|
</insert>
|
<!--
|
<insert id="saveState">
|
insert into iot_data.aggregate_state_${workstationId} USING iot_data.super_aggregate_state
|
TAGS(${workstationId}) values
|
<foreach separator="," collection="list" item="item" index="index">
|
(#{item.startTime}, #{item.endTime}, #{item.durationCollect}, #{item.valueCollect}, #{item.calendarCode},
|
#{item.factoryYear}, #{item.factoryMonth}, #{item.factoryWeek}, #{item.factoryDate},
|
#{item.shiftIndex}, #{item.shiftTimeType}, #{item.wcs}, #{item.rps}, #{item.isDeleted},#{item.isPlan})
|
</foreach>
|
</insert>
|
|
<update id="createTable">
|
create table if not exists iot_data.aggregate_state_${workstationId} using super_aggregate_state tags
|
(
|
#{workstationId}
|
)
|
</update>
|
-->
|
<select id="countStatsShiftEndTimeNotNull" resultType="com.qianwen.smartman.modules.mdc.dto.CountResult">
|
select sum(duration_collect) as nums, value_collect status
|
from iot_data.super_aggregate_state
|
where workstation_id = #{workstationId}
|
and wcs > 0
|
and factory_date = #{factoryDate}
|
and shift_index = #{shiftIndex}
|
and calendar_code = #{calendarCode}
|
and is_deleted = 0
|
and end_time is not null
|
group by value_collect;
|
</select>
|
|
<select id="countStatsShift" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select ts as startTime,
|
end_time as endTime,
|
duration_collect,
|
value_collect,
|
calendar_code as calendarCode,
|
factory_year as factoryYear,
|
factory_month as factoryMonth,
|
factory_week as factoryWeek,
|
factory_date as factoryDate,
|
shift_index as shiftIndex,
|
shift_time_type as shiftTimeType,
|
wcs,
|
rps,
|
is_deleted as isDeleted,
|
workstation_id as workstationId,
|
is_plan as isPlan
|
from iot_data.super_aggregate_state
|
where workstation_id = #{workstationId}
|
and wcs > 0
|
and factory_date = #{factoryDate}
|
and shift_index = #{shiftIndex}
|
and calendar_code = #{calendarCode}
|
and is_deleted = 0
|
</select>
|
|
<select id="statusByWorkstation" resultType="com.qianwen.smartman.modules.mdc.vo.StatusAnalysisWorkstationVO">
|
select ts as startDate, end_time as endDate, value_collect as status
|
from iot_data.super_aggregate_state
|
where workstation_id = #{workstationId}
|
and is_deleted = 0
|
and wcs > 0
|
and ts >= #{startTime}
|
and end_time <= #{endTime};
|
</select>
|
|
<select id="statusByWorkstationByNull" resultType="com.qianwen.smartman.modules.mdc.vo.StatusAnalysisWorkstationVO">
|
select ts as startDate, end_time as endDate, value_collect as status
|
from iot_data.super_aggregate_state
|
where workstation_id = #{workstationId}
|
and is_deleted = 0
|
and wcs > 0
|
and ts >= #{startTime}
|
and end_time is null;
|
</select>
|
<select id="statusByWorkstationList"
|
resultType="com.qianwen.smartman.modules.mdc.vo.StatusAnalysisWorkstationVO">
|
select ts as startDate, end_time as endDate, value_collect as status
|
from iot_data.super_aggregate_state
|
where workstation_id IN
|
<foreach collection="workstationIdList" item="ids" index="index" open="(" close=")" separator=",">
|
#{ids}
|
</foreach>
|
and is_deleted = 0
|
and wcs > 0
|
and ts >= #{startTime}
|
and end_time <= #{endTime};
|
</select>
|
|
|
<select id="statusByWorkstationListByNull"
|
resultType="com.qianwen.smartman.modules.mdc.vo.StatusAnalysisWorkstationVO">
|
select ts as startDate, end_time as endDate, value_collect as status
|
from iot_data.super_aggregate_state
|
where workstation_id IN
|
<foreach collection="workstationIdList" item="ids" index="index" open="(" close=")" separator=",">
|
#{ids}
|
</foreach>
|
and is_deleted = 0
|
and wcs > 0
|
and ts >= #{startTime}
|
and end_time is null;
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="deviceStatusStatisticsList"
|
resultType="com.qianwen.smartman.modules.mdc.vo.DeviceStatusStatisticsVO">
|
select count(*) as deviceNum, value_collect as status
|
from iot_data.super_aggregate_state
|
where is_deleted = 0
|
and wcs > 0
|
and ts >= #{startTime}
|
and end_time is null
|
group by value_collect;
|
</select>
|
|
<select id="getStatusDataMonth" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select ts as startTime,
|
end_time as endTime,
|
duration_collect,
|
value_collect,
|
calendar_code as calendarCode,
|
factory_year as factoryYear,
|
factory_month as factoryMonth,
|
factory_week as factoryWeek,
|
factory_date as factoryDate,
|
shift_index as shiftIndex,
|
shift_time_type as shiftTimeType,
|
wcs,
|
rps,
|
is_deleted as isDeleted,
|
workstation_id as workstationId,
|
is_plan as isPlan
|
from iot_data.super_aggregate_state
|
where is_deleted = 0
|
and wcs > 0
|
<if test="intervalDateDtoList != null and intervalDateDtoList.size() > 0">
|
AND
|
<foreach collection="intervalDateDtoList" item="intervalDateDto" open="(" close=")" separator="or">
|
(factory_year = #{intervalDateDto.year}
|
<if test="intervalDateDto.monthList != null and intervalDateDto.monthList.size() > 0">
|
AND factory_month IN
|
<foreach collection="intervalDateDto.monthList" item="month" open="(" close=")" separator=",">
|
#{month}
|
</foreach>
|
</if>
|
)
|
</foreach>
|
</if>
|
<if test="workstationIds != null and workstationIds.size() > 0">
|
AND workstation_id IN
|
<foreach collection="workstationIds" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
</select>
|
|
<select id="getStatusDataWeek" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select ts as startTime,
|
end_time as endTime,
|
duration_collect,
|
value_collect,
|
calendar_code as calendarCode,
|
factory_year as factoryYear,
|
factory_month as factoryMonth,
|
factory_week as factoryWeek,
|
factory_date as factoryDate,
|
shift_index as shiftIndex,
|
shift_time_type as shiftTimeType,
|
wcs,
|
rps,
|
is_deleted as isDeleted,
|
workstation_id as workstationId,
|
is_plan as isPlan
|
from iot_data.super_aggregate_state
|
where is_deleted = 0
|
and wcs > 0
|
<if test="intervalDateDtoList != null and intervalDateDtoList.size() > 0">
|
AND
|
<foreach collection="intervalDateDtoList" item="intervalDateDto" open="(" close=")" separator="or">
|
(factory_year = #{intervalDateDto.year}
|
<if test="intervalDateDto.weekList != null and intervalDateDto.weekList.size() > 0">
|
AND factory_week IN
|
<foreach collection="intervalDateDto.weekList" item="week" open="(" close=")" separator=",">
|
#{week}
|
</foreach>
|
</if>
|
)
|
</foreach>
|
</if>
|
<if test="workstationIds != null and workstationIds.size() > 0">
|
AND workstation_id IN
|
<foreach collection="workstationIds" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
</select>
|
|
<select id="getStatusDataDay" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select ts as startTime,
|
end_time as endTime,
|
duration_collect,
|
value_collect,
|
calendar_code as calendarCode,
|
factory_year as factoryYear,
|
factory_month as factoryMonth,
|
factory_week as factoryWeek,
|
factory_date as factoryDate,
|
shift_index as shiftIndex,
|
shift_time_type as shiftTimeType,
|
wcs,
|
rps,
|
is_deleted as isDeleted,
|
workstation_id as workstationId,
|
is_plan as isPlan
|
from iot_data.super_aggregate_state
|
where is_deleted = 0
|
and wcs > 0
|
<if test="dayList != null and dayList.size() > 0">
|
AND factory_date IN
|
<foreach collection="dayList" item="day" open="(" separator="," close=")">
|
#{day}
|
</foreach>
|
</if>
|
<if test="workstationIds != null and workstationIds.size() > 0">
|
AND workstation_id IN
|
<foreach collection="workstationIds" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
</select>
|
|
<select id="getStatusDataShift" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select ts as startTime,
|
end_time as endTime,
|
duration_collect,
|
value_collect,
|
calendar_code as calendarCode,
|
factory_year as factoryYear,
|
factory_month as factoryMonth,
|
factory_week as factoryWeek,
|
factory_date as factoryDate,
|
shift_index as shiftIndex,
|
shift_time_type as shiftTimeType,
|
wcs,
|
rps,
|
is_deleted as isDeleted,
|
workstation_id as workstationId,
|
is_plan as isPlan
|
from iot_data.super_aggregate_state
|
where is_deleted = 0
|
and wcs > 0
|
and factory_date = #{factoryDate}
|
and shift_index = #{shiftIndex}
|
and rps > 0
|
<if test="workstationIds != null and workstationIds.size() > 0">
|
AND workstation_id IN
|
<foreach collection="workstationIds" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
</select>
|
|
|
|
<sql id="superAggregateStateColumnSql">
|
ts as startTime,
|
end_time as endTime,
|
duration_collect,
|
value_collect,
|
calendar_code as calendarCode,
|
factory_year as factoryYear,
|
factory_month as factoryMonth,
|
factory_week as factoryWeek,
|
factory_date as factoryDate,
|
shift_index as shiftIndex,
|
shift_time_type as shiftTimeType,
|
wcs,
|
rps,
|
is_deleted as isDeleted,
|
workstation_id as workstationId,
|
is_plan as isPlan
|
</sql>
|
|
|
|
|
|
|
|
<select id="getEquipmentStatusRecord" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select ts as startTime,
|
end_time as endTime,
|
duration_collect,
|
value_collect,
|
calendar_code as calendarCode,
|
factory_year as factoryYear,
|
factory_month as factoryMonth,
|
factory_week as factoryWeek,
|
factory_date as factoryDate,
|
shift_index as shiftIndex,
|
shift_time_type as shiftTimeType,
|
wcs,
|
rps,
|
is_deleted as isDeleted,
|
workstation_id as workstationId,
|
is_plan as isPlan
|
from iot_data.super_aggregate_state
|
where is_deleted = 0
|
and wcs > 0
|
and factory_date = #{factoryDate}
|
and shift_index = #{shiftIndex}
|
<if test="workstationIds != null and workstationIds.size() > 0">
|
AND workstation_id IN
|
<foreach collection="workstationIds" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
</select>
|
|
<select id="getStatusByFactory" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select ts as startTime,
|
end_time as endTime,
|
duration_collect,
|
value_collect,
|
calendar_code as calendarCode,
|
factory_year as factoryYear,
|
factory_month as factoryMonth,
|
factory_week as factoryWeek,
|
factory_date as factoryDate,
|
shift_index as shiftIndex,
|
shift_time_type as shiftTimeType,
|
wcs,
|
rps,
|
is_deleted as isDeleted,
|
workstation_id as workstationId,
|
is_plan as isPlan
|
from iot_data.super_aggregate_state
|
where is_deleted = 0
|
and wcs > 0
|
and factory_date = #{factoryDate}
|
and shift_index = #{shiftIndex}
|
AND workstation_id IN
|
<foreach collection="workstationIds" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</select>
|
|
<select id="listsState" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select ts as startTime,
|
end_time as endTime,
|
duration_collect,
|
value_collect,
|
calendar_code as calendarCode,
|
factory_year as factoryYear,
|
factory_month as factoryMonth,
|
factory_week as factoryWeek,
|
factory_date as factoryDate,
|
shift_index as shiftIndex,
|
shift_time_type as shiftTimeType,
|
wcs,
|
rps,
|
is_deleted as isDeleted,
|
workstation_id as workstationId
|
from iot_data.super_aggregate_state
|
where is_deleted = 0
|
and wcs > 0
|
and factory_date = #{factoryDate}
|
and shift_index IN
|
<foreach collection="shiftIndex" item="shift" open="(" separator="," close=")">
|
#{shift}
|
</foreach>
|
AND workstation_id IN
|
<foreach collection="workstationIds" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</select>
|
|
<select id="getDataByWeek" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select ts as startTime,
|
end_time as endTime,
|
duration_collect,
|
value_collect,
|
calendar_code as calendarCode,
|
factory_year as factoryYear,
|
factory_month as factoryMonth,
|
factory_week as factoryWeek,
|
factory_date as factoryDate,
|
shift_index as shiftIndex,
|
shift_time_type as shiftTimeType,
|
wcs,
|
rps,
|
is_deleted as isDeleted,
|
workstation_id as workstationId
|
from iot_data.super_aggregate_state
|
where is_deleted = 0
|
and wcs > 0
|
and factory_year = #{year}
|
and workstation_id IN
|
<foreach collection="workstationIds" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
and factory_week IN
|
<foreach collection="weekList" item="week" open="(" separator="," close=")">
|
#{week}
|
</foreach>
|
</select>
|
<!--
|
<select id="getDataByMonth" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select ts as startTime,
|
end_time as endTime,
|
duration_collect,
|
value_collect,
|
calendar_code as calendarCode,
|
factory_year as factoryYear,
|
factory_month as factoryMonth,
|
factory_week as factoryWeek,
|
factory_date as factoryDate,
|
shift_index as shiftIndex,
|
shift_time_type as shiftTimeType,
|
wcs,
|
rps,
|
is_deleted as isDeleted,
|
workstation_id as workstationId
|
from iot_data.super_aggregate_state
|
where is_deleted = 0
|
and wcs > 0
|
and factory_year = #{year}
|
and workstation_id IN
|
<foreach collection="workstationIds" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
and factory_month IN
|
<foreach collection="monthList" item="month" open="(" separator="," close=")">
|
#{month}
|
</foreach>
|
</select>
|
-->
|
|
<select id="getDataByMonth" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select
|
end_time as endTime,
|
duration_collect,
|
value_collect,
|
calendar_code as calendarCode,
|
factory_year as factoryYear,
|
factory_month as factoryMonth,
|
factory_week as factoryWeek,
|
factory_date as factoryDate,
|
shift_index as shiftIndex,
|
shift_time_type as shiftTimeType,
|
wcs,
|
rps,
|
is_deleted as isDeleted,
|
workstation_id as workstationId
|
from root.f2.aggregate_state_*
|
where is_deleted=false
|
and wcs > 0
|
and factory_year = #{year}
|
and workstation_id IN
|
<foreach collection="workstationIds" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
and factory_month IN
|
<foreach collection="monthList" item="month" open="(" separator="," close=")">
|
#{month}
|
</foreach>
|
align by device
|
</select>
|
|
<!-- 这个有用吗 -->
|
<select id="listCrossDay" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select ts as startTime,
|
end_time as endTime,
|
duration_collect,
|
value_collect,
|
calendar_code as calendarCode,
|
factory_year as factoryYear,
|
factory_month as factoryMonth,
|
factory_week as factoryWeek,
|
factory_date as factoryDate,
|
shift_index as shiftIndex,
|
shift_time_type as shiftTimeType,
|
wcs,
|
rps,
|
is_deleted as isDeleted,
|
workstation_id as workstationId
|
from iot_data.super_aggregate_state
|
where (ts between #{startTime} and #{endTime})
|
and (end_time < #{startTime} or end_time > #{endTime})
|
</select>
|
|
|
<select id="getStatusDataByFactoryDateAndWorkstationId"
|
resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select ts as startTime,
|
end_time as endTime,
|
duration_collect,
|
factory_year as factoryYear,
|
factory_month as factoryMonth,
|
factory_week as factoryWeek,
|
factory_date as factoryDate,
|
shift_index as shiftIndex,
|
shift_time_type as shiftTimeType,
|
wcs,
|
rps,
|
workstation_id as workstationId,
|
is_plan as isPlan
|
from iot_data.aggregate_state_${workstationId}
|
where factory_date between #{startDate} and #{endDate}
|
and rps > 0
|
and wcs > 0
|
and is_deleted = false
|
</select>
|
<select id="listInTime" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select ts as startTime,
|
end_time as endTime,
|
duration_collect,
|
value_collect,
|
calendar_code as calendarCode,
|
factory_year as factoryYear,
|
factory_month as factoryMonth,
|
factory_week as factoryWeek,
|
factory_date as factoryDate,
|
shift_index as shiftIndex,
|
shift_time_type as shiftTimeType,
|
wcs,
|
rps,
|
is_deleted as isDeleted,
|
workstation_id as workstationId
|
from iot_data.super_aggregate_state
|
where ts >= #{startTime} and end_time <= #{endTime}
|
and workstation_id IN
|
<foreach collection="workstationIds" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</select>
|
|
<select id="listTsInTime" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select ts as startTime,
|
end_time as endTime,
|
duration_collect,
|
value_collect,
|
calendar_code as calendarCode,
|
factory_year as factoryYear,
|
factory_month as factoryMonth,
|
factory_week as factoryWeek,
|
factory_date as factoryDate,
|
shift_index as shiftIndex,
|
shift_time_type as shiftTimeType,
|
wcs,
|
rps,
|
is_deleted as isDeleted,
|
workstation_id as workstationId
|
from iot_data.super_aggregate_state
|
where (ts between #{startTime} and #{endTime})
|
and (end_time >= #{endTime} or end_time is null)
|
and workstation_id IN
|
<foreach collection="workstationIds" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</select>
|
|
<select id="listEndTimeInTime" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select ts as startTime,
|
end_time as endTime,
|
duration_collect,
|
value_collect,
|
calendar_code as calendarCode,
|
factory_year as factoryYear,
|
factory_month as factoryMonth,
|
factory_week as factoryWeek,
|
factory_date as factoryDate,
|
shift_index as shiftIndex,
|
shift_time_type as shiftTimeType,
|
wcs,
|
rps,
|
is_deleted as isDeleted,
|
workstation_id as workstationId
|
from iot_data.super_aggregate_state
|
where (end_time between #{startTime} and #{endTime})
|
and ts < #{startTime}
|
and workstation_id IN
|
<foreach collection="workstationIds" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</select>
|
|
<select id="listOutTime" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select ts as startTime,
|
end_time as endTime,
|
duration_collect,
|
value_collect,
|
calendar_code as calendarCode,
|
factory_year as factoryYear,
|
factory_month as factoryMonth,
|
factory_week as factoryWeek,
|
factory_date as factoryDate,
|
shift_index as shiftIndex,
|
shift_time_type as shiftTimeType,
|
wcs,
|
rps,
|
is_deleted as isDeleted,
|
workstation_id as workstationId
|
from iot_data.super_aggregate_state
|
where ts < #{startTime}
|
and (end_time > #{endTime} or end_time is null)
|
and workstation_id IN
|
<foreach collection="workstationIds" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</select>
|
|
<select id="queryPerfByDay" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select ts as startTime,
|
end_time as endTime,
|
duration_collect,
|
value_collect,
|
calendar_code as calendarCode,
|
factory_year as factoryYear,
|
factory_month as factoryMonth,
|
factory_week as factoryWeek,
|
factory_date as factoryDate,
|
shift_index as shiftIndex,
|
shift_time_type as shiftTimeType,
|
wcs,
|
rps,
|
is_deleted as isDeleted,
|
workstation_id as workstationId,
|
employee_id as employeeId
|
from iot_data.super_aggregate_state
|
where factory_date >= #{startTime}
|
and factory_date <= #{endTime}
|
and workstation_id = #{workstationId}
|
and employee_id = #{employeeId}
|
and wcs is not null
|
</select>
|
|
<select id="queryPerfByWeek" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select ts as startTime,
|
end_time as endTime,
|
duration_collect,
|
value_collect,
|
calendar_code as calendarCode,
|
factory_year as factoryYear,
|
factory_month as factoryMonth,
|
factory_week as factoryWeek,
|
factory_date as factoryDate,
|
shift_index as shiftIndex,
|
shift_time_type as shiftTimeType,
|
wcs,
|
rps,
|
is_deleted as isDeleted,
|
workstation_id as workstationId,
|
employee_id as employeeId
|
from iot_data.super_aggregate_state
|
where factory_week in
|
<foreach collection="weeks" item="week" open="(" separator="," close=")">
|
#{week}
|
</foreach>
|
and workstation_id = #{workstationId}
|
and employee_id = #{employeeId}
|
and wcs is not null
|
</select>
|
|
<select id="queryPerfByMonth" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select ts as startTime,
|
end_time as endTime,
|
duration_collect,
|
value_collect,
|
calendar_code as calendarCode,
|
factory_year as factoryYear,
|
factory_month as factoryMonth,
|
factory_week as factoryWeek,
|
factory_date as factoryDate,
|
shift_index as shiftIndex,
|
shift_time_type as shiftTimeType,
|
wcs,
|
rps,
|
is_deleted as isDeleted,
|
workstation_id as workstationId,
|
employee_id as employeeId
|
from iot_data.super_aggregate_state
|
where factory_month in
|
<foreach collection="months" item="month" open="(" separator="," close=")">
|
#{month}
|
</foreach>
|
and workstation_id = #{workstationId}
|
and employee_id = #{employeeId}
|
and wcs is not null
|
</select>
|
|
<select id="queryPerfByEtDay" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select ts as startTime,
|
end_time as endTime,
|
duration_collect,
|
value_collect,
|
calendar_code as calendarCode,
|
factory_year as factoryYear,
|
factory_month as factoryMonth,
|
factory_week as factoryWeek,
|
factory_date as factoryDate,
|
shift_index as shiftIndex,
|
shift_time_type as shiftTimeType,
|
wcs,
|
rps,
|
is_deleted as isDeleted,
|
workstation_id as workstationId,
|
employee_id as employeeId
|
from iot_data.super_aggregate_state
|
where employee_id = #{employeeId}
|
and workstation_id is not null
|
and wcs is not null
|
and factory_date = #{queryTime}
|
</select>
|
|
<select id="queryPerfByEtWeek" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select ts as startTime,
|
end_time as endTime,
|
duration_collect,
|
value_collect,
|
calendar_code as calendarCode,
|
factory_year as factoryYear,
|
factory_month as factoryMonth,
|
factory_week as factoryWeek,
|
factory_date as factoryDate,
|
shift_index as shiftIndex,
|
shift_time_type as shiftTimeType,
|
wcs,
|
rps,
|
is_deleted as isDeleted,
|
workstation_id as workstationId,
|
employee_id as employeeId
|
from iot_data.super_aggregate_state
|
where employee_id = #{employeeId}
|
and workstation_id is not null
|
and wcs is not null
|
and factory_week = #{week}
|
</select>
|
|
<select id="queryPerfByEtMonth" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select ts as startTime,
|
end_time as endTime,
|
duration_collect,
|
value_collect,
|
calendar_code as calendarCode,
|
factory_year as factoryYear,
|
factory_month as factoryMonth,
|
factory_week as factoryWeek,
|
factory_date as factoryDate,
|
shift_index as shiftIndex,
|
shift_time_type as shiftTimeType,
|
wcs,
|
rps,
|
is_deleted as isDeleted,
|
workstation_id as workstationId,
|
employee_id as employeeId
|
from iot_data.super_aggregate_state
|
where employee_id = #{employeeId}
|
and workstation_id is not null
|
and wcs is not null
|
and factory_month = #{month}
|
</select>
|
|
<select id="queryPerfByWtDay" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select ts as startTime,
|
end_time as endTime,
|
duration_collect,
|
value_collect,
|
calendar_code as calendarCode,
|
factory_year as factoryYear,
|
factory_month as factoryMonth,
|
factory_week as factoryWeek,
|
factory_date as factoryDate,
|
shift_index as shiftIndex,
|
shift_time_type as shiftTimeType,
|
wcs,
|
rps,
|
is_deleted as isDeleted,
|
workstation_id as workstationId,
|
employee_id as employeeId
|
from iot_data.super_aggregate_state
|
where workstation_id = #{workstationId}
|
and employee_id is not null
|
and wcs is not null
|
and factory_date = #{time}
|
</select>
|
|
<select id="queryPerfByWtWeek" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select ts as startTime,
|
end_time as endTime,
|
duration_collect,
|
value_collect,
|
calendar_code as calendarCode,
|
factory_year as factoryYear,
|
factory_month as factoryMonth,
|
factory_week as factoryWeek,
|
factory_date as factoryDate,
|
shift_index as shiftIndex,
|
shift_time_type as shiftTimeType,
|
wcs,
|
rps,
|
is_deleted as isDeleted,
|
workstation_id as workstationId,
|
employee_id as employeeId
|
from iot_data.super_aggregate_state
|
where workstation_id = #{workstationId}
|
and employee_id is not null
|
and wcs is not null
|
and factory_week = #{week}
|
</select>
|
|
<select id="queryPerfByWtMonth" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select ts as startTime,
|
end_time as endTime,
|
duration_collect,
|
value_collect,
|
calendar_code as calendarCode,
|
factory_year as factoryYear,
|
factory_month as factoryMonth,
|
factory_week as factoryWeek,
|
factory_date as factoryDate,
|
shift_index as shiftIndex,
|
shift_time_type as shiftTimeType,
|
wcs,
|
rps,
|
is_deleted as isDeleted,
|
workstation_id as workstationId,
|
employee_id as employeeId
|
from iot_data.super_aggregate_state
|
where workstation_id = #{workstationId}
|
and employee_id is not null
|
and wcs is not null
|
and factory_month = #{month}
|
</select>
|
|
<select id="getCurrMonthState" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select ts as startTime,
|
end_time as endTime,
|
duration_collect,
|
value_collect,
|
calendar_code as calendarCode,
|
factory_year as factoryYear,
|
factory_month as factoryMonth,
|
factory_week as factoryWeek,
|
factory_date as factoryDate,
|
shift_index as shiftIndex,
|
shift_time_type as shiftTimeType,
|
wcs,
|
rps,
|
is_deleted as isDeleted,
|
workstation_id as workstationId,
|
is_plan as isPlan,
|
employee_id as employeeId
|
from iot_data.super_aggregate_state
|
where workstation_id in
|
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
and factory_month = #{month}
|
and wcs > 0
|
and rps > 0
|
and is_deleted = 0
|
</select>
|
|
<select id="getCurrMonthAlarmState" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select ts as startTime,
|
end_time as endTime,
|
duration_collect,
|
value_collect,
|
calendar_code as calendarCode,
|
factory_year as factoryYear,
|
factory_month as factoryMonth,
|
factory_week as factoryWeek,
|
factory_date as factoryDate,
|
shift_index as shiftIndex,
|
shift_time_type as shiftTimeType,
|
wcs,
|
rps,
|
is_deleted as isDeleted,
|
workstation_id as workstationId,
|
is_plan as isPlan,
|
employee_id as employeeId
|
from iot_data.super_aggregate_state
|
where workstation_id in
|
<foreach collection="workIds" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
and factory_month = #{month}
|
and wcs = #{code}
|
and rps > 0
|
and is_deleted = 0
|
</select>
|
|
<select id="getCurrWeekAlarmState" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select ts as startTime,
|
end_time as endTime,
|
duration_collect,
|
value_collect,
|
calendar_code as calendarCode,
|
factory_year as factoryYear,
|
factory_month as factoryMonth,
|
factory_week as factoryWeek,
|
factory_date as factoryDate,
|
shift_index as shiftIndex,
|
shift_time_type as shiftTimeType,
|
wcs,
|
rps,
|
is_deleted as isDeleted,
|
workstation_id as workstationId,
|
is_plan as isPlan,
|
employee_id as employeeId
|
from iot_data.super_aggregate_state
|
where workstation_id in
|
<foreach collection="workIds" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
and factory_week = #{week}
|
and wcs = #{code}
|
and rps > 0
|
and is_deleted = 0
|
</select>
|
|
<!-- 调整的sql开始 -->
|
<sql id="aggregateStateColumnSql">
|
end_time as endTime,
|
duration_collect as durationCollect,
|
value_collect as valueCollect,
|
calendar_code as calendarCode,
|
factory_year as factoryYear,
|
factory_month as factoryMonth,
|
factory_week as factoryWeek,
|
factory_date as factoryDate,
|
shift_index as shiftIndex,
|
shift_time_type as shiftTimeType,
|
wcs,
|
rps,
|
is_deleted as isDeleted,
|
workstation_id as workstationId,
|
is_plan as isPlan
|
</sql>
|
|
|
<!-- 原来是union2个sql,现在合并未一个 -->
|
<!--
|
OK: where ((time <![CDATA[<]]> #{startDate} and end_time <![CDATA[>=]]> #{startDate.time}) or (time <![CDATA[>=]]> #{startDate} and time <![CDATA[<=]]> #{endDate.time}))
|
where ((time <![CDATA[<]]> #{startDate} and #{startDate.time} <![CDATA[<=]]> end_time) or (time <![CDATA[>=]]> #{startDate} and time <![CDATA[<=]]> #{endDate.time})) -->
|
<select id="getEquipmentStatusDuration"
|
resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select
|
<include refid="aggregateStateColumnSql"/>
|
from root.f2.aggregate_state_*
|
where ((time <![CDATA[<]]> #{startDate} and end_time <![CDATA[>=]]> #{startDate}) or (time <![CDATA[>=]]> #{startDate} and time <![CDATA[<=]]> #{endDate}))
|
and is_deleted=false
|
and rps > 0
|
and wcs > 0
|
<if test="workstationIds != null and workstationIds.size() > 0">
|
AND workstation_id IN
|
<foreach collection="workstationIds" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
<if test="status != null and status !=''">
|
and wcs =#{status}
|
</if>
|
align by device
|
</select>
|
|
<select id="getStatusDataByTimeSection"
|
resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select
|
<include refid="aggregateStateColumnSql"/>
|
from root.f2.aggregate_state_*
|
where is_deleted = false
|
and wcs > 0
|
and ((time <![CDATA[<]]> #{startDate} and end_time <![CDATA[>=]]> #{startDate}) or (time <![CDATA[>=]]> #{startDate} and time <![CDATA[<=]]> #{endDate}))
|
<if test="workstationIds != null and workstationIds.size() > 0">
|
AND workstation_id IN
|
<foreach collection="workstationIds" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
align by device
|
</select>
|
|
<select id="getStatusData" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select
|
<include refid="aggregateStateColumnSql"/>
|
from root.f2.aggregate_state_*
|
where is_deleted = false
|
and wcs > 0
|
and time <![CDATA[>=]]> #{startDate} and time <![CDATA[<]]> #{endDate}
|
<if test="workstationIds != null and workstationIds.size() > 0">
|
AND workstation_id IN
|
<foreach collection="workstationIds" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
align by device
|
</select>
|
|
<select id="getStatusDataByFactoryDate"
|
resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select <include refid="aggregateStateColumnSql"/>
|
from root.f2.aggregate_state_*
|
where factory_date <![CDATA[>=]]> #{startFactoryDate} and factory_date <![CDATA[<=]]> #{endFactoryDate}
|
and rps > 0
|
and wcs > 0
|
and is_deleted = false
|
<if test="workstationIds != null and workstationIds.size() > 0">
|
AND workstation_id IN
|
<foreach collection="workstationIds" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
align by device
|
</select>
|
|
<!-- 查询按班次的状态数据,在用时分析中使用 and calendar_code = #{calendarCode,jdbcType=VARCHAR} -->
|
<select id="shiftState"
|
resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select <include refid="aggregateStateColumnSql"/>
|
from root.f2.aggregate_state_*
|
where factory_date = #{factoryDate}
|
and wcs > 0
|
and shift_index = #{shiftIndex}
|
and calendar_code = "#{calendarCode}"
|
and is_deleted = false
|
<if test="ids != null and ids.size() > 0">
|
AND workstation_id IN
|
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
align by device
|
</select>
|
|
<select id="weekState"
|
resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select <include refid="aggregateStateColumnSql"/>
|
from root.f2.aggregate_state_*
|
where factory_year = #{year}
|
and factory_week = #{week}
|
and is_deleted = false
|
and wcs > 0
|
<if test="ids != null and ids.size() > 0">
|
AND workstation_id IN
|
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
align by device
|
</select>
|
|
<select id="yearState"
|
resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select <include refid="aggregateStateColumnSql"/>
|
from root.f2.aggregate_state_*
|
where factory_year = #{year}
|
and factory_month = #{month}
|
and is_deleted = false
|
and wcs > 0
|
<if test="ids != null and ids.size() > 0">
|
AND workstation_id IN
|
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
align by device
|
</select>
|
|
<select id="dateState"
|
resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateState">
|
select <include refid="aggregateStateColumnSql"/>
|
from root.f2.aggregate_state_*
|
where is_deleted = false
|
and wcs > 0
|
and factory_date = #{factoryDate}
|
<if test="ids != null and ids.size() > 0">
|
AND workstation_id IN
|
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
align by device
|
</select>
|
</mapper>
|