<?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.mdc.mapper.MachiningDataNcMapper">
|
<resultMap id="BaseResultMap" type="com.qianwen.mdc.domain.MachiningDataNc">
|
<!--
|
WARNING - @mbg.generated
|
-->
|
<id column="id" jdbcType="BIGINT" property="id" />
|
<result column="machine_id" jdbcType="INTEGER" property="machineId" />
|
<result column="start_time" jdbcType="INTEGER" property="startTime" />
|
<result column="end_time" jdbcType="INTEGER" property="endTime" />
|
<result column="state" jdbcType="VARCHAR" property="state" />
|
</resultMap>
|
<!-- 机床状态分布,老方法,以后可能取消 -->
|
<select id="getNCStateListBy" resultType="java.util.HashMap">
|
select
|
d.id,
|
m.name name,
|
d.start_time stateStart,
|
d.end_time stateEnd,
|
d.state,
|
w.name workshopName,
|
s.name sectionName,
|
a.category
|
from
|
machining_data_nc_his d
|
left join mdc_machine m on d.machine_id = m.id
|
left join mdc_workshop w on m.workshop_id = w.id
|
left join mdc_section s on m.section_id = s.id
|
left join mdc_machine_account a on a.machine_id = m.id
|
where
|
(
|
d.start_time < #{startTime} and d.end_time > #{startTime}
|
or d.start_time BETWEEN #{startTime} and #{endTime}
|
)
|
and d.state != ""
|
<if test="workshop != null and workshop != ''">
|
and w.name = #{workshop}
|
</if>
|
<if test="section != null and section != ''">
|
and s.name = #{section}
|
</if>
|
<if test="list !=null and list.size() > 0">
|
and m.name in
|
<foreach collection="list" open="(" separator="," close=")" item="machineName">
|
#{machineName}
|
</foreach>
|
</if>
|
union all
|
select
|
d.id,
|
m.name name,
|
d.start_time stateStart,
|
d.end_time stateEnd,
|
d.state,
|
w.name workshopName,
|
s.name sectionName,
|
a.category
|
from
|
machining_data_nc d
|
left join machine m on d.machine_id = m.id
|
left join mdc_workshop w on m.workshop_id = w.id
|
left join mdc_section s on m.section_id = s.id
|
left join mdc_machine_account a on a.machine_id = m.id
|
where
|
(
|
d.start_time < #{startTime} and d.end_time > #{startTime}
|
or d.start_time BETWEEN #{startTime} and #{endTime}
|
)
|
and d.state != ""
|
<if test="workshop != null and workshop != ''">
|
and w.name = #{workshop}
|
</if>
|
<if test="section != null and section != ''">
|
and s.name = #{section}
|
</if>
|
<if test="list !=null and list.size() > 0">
|
and m.name in
|
<foreach collection="list" open="(" separator="," close=")" item="machineName">
|
#{machineName}
|
</foreach>
|
</if>
|
order by sectionName asc, name asc, stateStart asc
|
</select>
|
|
<!-- 机床状态分布,yangys -->
|
<select id="ncStateDistribute" resultType="com.qianwen.mdc.dto.NcDistributeResultDTO">
|
select
|
d.id,
|
m.name name,
|
d.start_time stateStart,
|
d.end_time stateEnd,
|
d.state,
|
w.name workshopName,
|
s.name sectionName,
|
a.category
|
from
|
machining_data_nc_his d
|
left join machine m on d.machine_id = m.id
|
left join workshop w on m.workshop_id = w.id
|
left join section s on m.section_id = s.id
|
left join machine_account a on a.machine_id = m.id
|
where
|
(
|
d.start_time < #{startTime} and d.end_time > #{startTime}
|
or d.start_time BETWEEN #{startTime} and #{endTime}
|
)
|
and d.state <> ''
|
<if test="workshopId != null">
|
and m.workshop_id = #{workshopId}
|
</if>
|
<if test="sectionId != null">
|
and m.section_id = #{sectionId}
|
</if>
|
<if test="machineIds != null">
|
and m.id in
|
<foreach collection="machineIds" open="(" separator="," close=")" item="machineId">
|
#{machineId}
|
</foreach>
|
</if>
|
union all
|
select
|
d.id,
|
m.name name,
|
d.start_time stateStart,
|
d.end_time stateEnd,
|
d.state,
|
w.name workshopName,
|
s.name sectionName,
|
a.category
|
from
|
machining_data_nc d
|
left join machine m on d.machine_id = m.id
|
left join workshop w on m.workshop_id = w.id
|
left join section s on m.section_id = s.id
|
left join machine_account a on a.machine_id = m.id
|
where
|
(
|
d.start_time < #{startTime} and d.end_time > #{startTime}
|
or d.start_time BETWEEN #{startTime} and #{endTime}
|
)
|
and d.state <> ''
|
<if test="workshopId != null">
|
and m.workshop_id = #{workshopId}
|
</if>
|
<if test="sectionId != null">
|
and m.section_id = #{sectionId}
|
</if>
|
<if test="machineIds != null">
|
and m.id in
|
<foreach collection="machineIds" open="(" separator="," close=")" item="machineId">
|
#{machineId}
|
</foreach>
|
</if>
|
order by stateStart asc
|
</select>
|
|
|
<select id="machineLastList" resultMap="BaseResultMap">
|
select id,machine_id,start_time,end_time,state
|
|
from machining_data_nc where machine_id=#{machineId} order by end_time desc limit 1
|
</select>
|
<!--
|
<select id="machineLastListByTTTTime" resultMap="BaseResultMap">
|
select id,machine_id,start_time,end_time,state
|
|
from machining_data_nc where machine_id=#{machineId} order by end_time desc limit 1
|
</select>
|
-->
|
</mapper>
|