@ -8,67 +8,82 @@
<result property= "recordShutDownId" column= "record_shut_down_id" />
<result property= "recordShutDownId" column= "record_shut_down_id" />
<result property= "deviceId" column= "device_id" />
<result property= "deviceId" column= "device_id" />
<result property= "shutType" column= "shut_type" />
<result property= "shutType" column= "shut_type" />
<result property= "shutReasonId" column= "shut_reason_id" />
<result property= "shutReason" column= "shut_reason" />
<result property= "shutReason" column= "shut_reason" />
<result property= "shutBeginTime" column= "shut_begin_time" />
<result property= "shutBeginTime" column= "shut_begin_time" />
<result property= "shutEndTime" column= "shut_end_time" />
<result property= "shutEndTime" column= "shut_end_time" />
<result property= "shutTime" column= "shut_time" />
<result property= "shutTime" column= "shut_time" />
<result property= "downtimeFlag" column= "downtime_flag" />
<result property= "isFlag" column= "is_flag" />
<result property= "isFlag" column= "is_flag" />
<result property= "remark" column= "remark" />
<result property= "remark" column= "remark" />
<result property= "createBy" column= "create_by" />
<result property= "createBy" column= "create_by" />
<result property= "createTime" column= "create_time" />
<result property= "createTime" column= "create_time" />
<result property= "updateBy" column= "update_by" />
<result property= "updateBy" column= "update_by" />
<result property= "updateTime" column= "update_time" />
<result property= "updateTime" column= "update_time" />
<result property= "deviceCode" column= "device_code" />
<result property= "deviceName" column= "device_name" />
</resultMap>
</resultMap>
<!-- 注意: 实际表字段名与XML定义不同, 已修正字段映射 -->
<!-- 关联base_deviceledger查询设备编码和名称, 使用resultMap映射物理列名 -->
<sql id= "selectDmsRecordShutDownVo" >
<sql id= "selectDmsRecordShutDownVo" >
select record_shut_down_id,
select r.record_shut_down_id,
machine_id as device_id,
r.machine_id as device_id,
shut_type_id as shut_type,
r.shut_type_id as shut_type,
shut_reason,
r.shut_reason_id,
shut_begin_time,
r.shut_reason,
shut_end_time,
r.shut_begin_time,
shut_time,
r.shut_end_time,
active_flag as is_flag,
r.shut_time,
remark,
r.downtime_flag,
create_by,
r.active_flag as is_flag,
create_time,
r.remark,
update_by,
r.create_by,
update_time
r.create_time,
from dms_record_shut_down
r.update_by,
r.update_time,
d.device_code as device_code,
d.device_name as device_name
from dms_record_shut_down r
left join base_deviceledger d on r.machine_id = d.OBJ_ID
</sql>
</sql>
<select id= "selectDmsRecordShutDownList" parameterType= "DmsRecordShutDown" resultMap= "DmsRecordShutDownResult" >
<select id= "selectDmsRecordShutDownList" parameterType= "DmsRecordShutDown" resultMap= "DmsRecordShutDownResult" >
<include refid= "selectDmsRecordShutDownVo" />
<include refid= "selectDmsRecordShutDownVo" />
<where >
<where >
<if test= "shutType != null " > and shut_type_id = #{shutType}</if>
<if test= "shutType != null " > and r. shut_type_id = #{shutType}</if>
<if test= "shutReason != null and shutReason != ''" > and shut_reason = #{shutReason}</if>
<if test= "shutReason != null and shutReason != ''" > and r. shut_reason = #{shutReason}</if>
<if test= "params != null and params.beginTime != null and params.endTime != null" >
<if test= "params != null and params.beginTime != null and params.endTime != null" >
and shut_begin_time between #{params.beginTime} and #{params.endTime}
and r. shut_begin_time between #{params.beginTime} and #{params.endTime}
</if>
</if>
<if test= "shutBeginTime != null " > and shut_begin_time > = #{shutBeginTime}</if>
<if test= "shutBeginTime != null " > and r.shut_begin_time > = #{shutBeginTime}</if>
<if test= "shutEndTime != null " > and #{shutEndTime} > = shut_end_time</if>
<if test= "shutEndTime != null " > and #{shutEndTime} > = r.shut_end_time</if>
<if test= "shutTime != null " > and shut_time = #{shutTime}</if>
<if test= "shutTime != null " > and r.shut_time = #{shutTime}</if>
<if test= "deviceCode != null and deviceCode != ''" > and machine_id in (select OBJ_ID from base_deviceledger where device_code = #{deviceCode})</if>
<if test= "deviceCode != null and deviceCode != ''" > and d.device_code = #{deviceCode}</if>
<if test= "deviceName != null and deviceName != ''" > and d.device_name like concat(concat('%', #{deviceName}), '%')</if>
</where>
</where>
</select>
</select>
<select id= "selectDmsRecordShutDownByRecordShutDownId" parameterType= "Long" resultMap= "DmsRecordShutDownResult" >
<select id= "selectDmsRecordShutDownByRecordShutDownId" parameterType= "Long" resultMap= "DmsRecordShutDownResult" >
<include refid= "selectDmsRecordShutDownVo" />
<include refid= "selectDmsRecordShutDownVo" />
where record_shut_down_id = #{recordShutDownId}
where r.r ecord_shut_down_id = #{recordShutDownId}
</select>
</select>
<insert id= "insertDmsRecordShutDown" parameterType= "DmsRecordShutDown" useGeneratedKeys= "true"
<insert id= "insertDmsRecordShutDown" parameterType= "DmsRecordShutDown" >
keyProperty="recordShutDownId">
<selectKey keyProperty= "recordShutDownId" resultType= "long" order= "BEFORE" >
SELECT SEQ_DMS_REC_SHUT_DOWN.NEXTVAL FROM DUAL
</selectKey>
insert into dms_record_shut_down
insert into dms_record_shut_down
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "deviceId != null" > device_id,</if>
record_shut_down_id,
<if test= "shutType != null" > shut_type,</if>
<if test= "deviceId != null" > machine_id,</if>
<if test= "shutType != null" > shut_type_id,</if>
<if test= "shutReasonId != null" > shut_reason_id,</if>
<if test= "shutReason != null" > shut_reason,</if>
<if test= "shutReason != null" > shut_reason,</if>
<if test= "shutBeginTime != null" > shut_begin_time,</if>
<if test= "shutBeginTime != null" > shut_begin_time,</if>
<if test= "shutEndTime != null" > shut_end_time,</if>
<if test= "shutEndTime != null" > shut_end_time,</if>
<if test= "shutTime != null" > shut_time,</if>
<if test= "shutTime != null" > shut_time,</if>
<if test= "isFlag != null" > is_flag,</if>
<if test= "downtimeFlag != null" > downtime_flag,</if>
<if test= "isFlag != null" > active_flag,</if>
<if test= "remark != null" > remark,</if>
<if test= "remark != null" > remark,</if>
<if test= "createBy != null" > create_by,</if>
<if test= "createBy != null" > create_by,</if>
<if test= "createTime != null" > create_time,</if>
<if test= "createTime != null" > create_time,</if>
@ -76,12 +91,15 @@
<if test= "updateTime != null" > update_time,</if>
<if test= "updateTime != null" > update_time,</if>
</trim>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
#{recordShutDownId},
<if test= "deviceId != null" > #{deviceId},</if>
<if test= "deviceId != null" > #{deviceId},</if>
<if test= "shutType != null" > #{shutType},</if>
<if test= "shutType != null" > #{shutType},</if>
<if test= "shutReasonId != null" > #{shutReasonId},</if>
<if test= "shutReason != null" > #{shutReason},</if>
<if test= "shutReason != null" > #{shutReason},</if>
<if test= "shutBeginTime != null" > #{shutBeginTime},</if>
<if test= "shutBeginTime != null" > #{shutBeginTime},</if>
<if test= "shutEndTime != null" > #{shutEndTime},</if>
<if test= "shutEndTime != null" > #{shutEndTime},</if>
<if test= "shutTime != null" > #{shutTime},</if>
<if test= "shutTime != null" > #{shutTime},</if>
<if test= "downtimeFlag != null" > #{downtimeFlag},</if>
<if test= "isFlag != null" > #{isFlag},</if>
<if test= "isFlag != null" > #{isFlag},</if>
<if test= "remark != null" > #{remark},</if>
<if test= "remark != null" > #{remark},</if>
<if test= "createBy != null" > #{createBy},</if>
<if test= "createBy != null" > #{createBy},</if>
@ -94,13 +112,15 @@
<update id= "updateDmsRecordShutDown" parameterType= "DmsRecordShutDown" >
<update id= "updateDmsRecordShutDown" parameterType= "DmsRecordShutDown" >
update dms_record_shut_down
update dms_record_shut_down
<trim prefix= "SET" suffixOverrides= "," >
<trim prefix= "SET" suffixOverrides= "," >
<if test= "deviceId != null" > device_id = #{deviceId},</if>
<if test= "deviceId != null" > machine_id = #{deviceId},</if>
<if test= "shutType != null" > shut_type = #{shutType},</if>
<if test= "shutType != null" > shut_type_id = #{shutType},</if>
<if test= "shutReasonId != null" > shut_reason_id = #{shutReasonId},</if>
<if test= "shutReason != null" > shut_reason = #{shutReason},</if>
<if test= "shutReason != null" > shut_reason = #{shutReason},</if>
<if test= "shutBeginTime != null" > shut_begin_time = #{shutBeginTime},</if>
<if test= "shutBeginTime != null" > shut_begin_time = #{shutBeginTime},</if>
<if test= "shutEndTime != null" > shut_end_time = #{shutEndTime},</if>
<if test= "shutEndTime != null" > shut_end_time = #{shutEndTime},</if>
<if test= "shutTime != null" > shut_time = #{shutTime},</if>
<if test= "shutTime != null" > shut_time = #{shutTime},</if>
<if test= "isFlag != null" > is_flag = #{isFlag},</if>
<if test= "downtimeFlag != null" > downtime_flag = #{downtimeFlag},</if>
<if test= "isFlag != null" > active_flag = #{isFlag},</if>
<if test= "remark != null" > remark = #{remark},</if>
<if test= "remark != null" > remark = #{remark},</if>
<if test= "createBy != null" > create_by = #{createBy},</if>
<if test= "createBy != null" > create_by = #{createBy},</if>
<if test= "createTime != null" > create_time = #{createTime},</if>
<if test= "createTime != null" > create_time = #{createTime},</if>
@ -110,6 +130,13 @@
where record_shut_down_id = #{recordShutDownId}
where record_shut_down_id = #{recordShutDownId}
</update>
</update>
<select id= "selectPdaShutDownList" resultMap= "DmsRecordShutDownResult" >
<include refid= "selectDmsRecordShutDownVo" />
where r.active_flag = '1'
and (r.shut_end_time is null or r.shut_reason_id = 1)
order by r.create_time desc
</select>
<delete id= "deleteDmsRecordShutDownByRecordShutDownId" parameterType= "Long" >
<delete id= "deleteDmsRecordShutDownByRecordShutDownId" parameterType= "Long" >
delete
delete
from dms_record_shut_down
from dms_record_shut_down