<?xml version="1.0" encoding="UTF-8"?>
|
|
<!--
|
~
|
~ Copyright (c) 2018-2025, ztt All rights reserved.
|
~
|
~ Redistribution and use in source and binary forms, with or without
|
~ modification, are permitted provided that the following conditions are met:
|
~
|
~ Redistributions of source code must retain the above copyright notice,
|
~ this list of conditions and the following disclaimer.
|
~ Redistributions in binary form must reproduce the above copyright
|
~ notice, this list of conditions and the following disclaimer in the
|
~ documentation and/or other materials provided with the distribution.
|
~ Neither the name of the pig4cloud.com developer nor the names of its
|
~ contributors may be used to endorse or promote products derived from
|
~ this software without specific prior written permission.
|
~ Author: ztt
|
~
|
-->
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="com.chinaztt.mes.aps.mapper.ResourceMapper">
|
|
<resultMap id="resourceMap" type="com.chinaztt.mes.aps.entity.Resource">
|
<id property="id" column="id"/>
|
<result property="resourceNo" column="resource_no"/>
|
<result property="resourceName" column="resource_name"/>
|
<result property="remark" column="remark"/>
|
<result property="workstationId" column="workstation_id"/>
|
</resultMap>
|
|
<resultMap id="resourceBoMap" type="com.chinaztt.mes.aps.core.domain.ResourceBo">
|
<id property="id" column="id"/>
|
<result property="name" column="resource_name"/>
|
<result property="no" column="resource_no"/>
|
<result property="maxEndTime" column="maxEndTime"/>
|
</resultMap>
|
|
<resultMap id="resourceMapDTO" type="com.chinaztt.mes.aps.dto.ResourceDTO">
|
<id property="id" column="id"/>
|
<result property="resourceNo" column="resource_no"/>
|
<result property="resourceName" column="resource_name"/>
|
<result property="remark" column="remark"/>
|
<result property="workstationId" column="workstation_id"/>
|
<result property="rscGroupName" column="rsc_group_name"/>
|
</resultMap>
|
<select id="getAllWithMaxTime" resultMap="resourceBoMap">
|
SELECT
|
r.*,
|
GREATEST(A."maxTime", b."maxTime") "maxTime"
|
FROM
|
aps_resource r
|
LEFT JOIN (SELECT
|
MAX(CASE
|
WHEN T.actual_finish_date IS NULL THEN T.planned_finish_date
|
ELSE T.actual_finish_date END) "maxTime",
|
T.resource_id
|
FROM
|
production_operation_task T
|
GROUP BY
|
T.resource_id) A ON r.ID = A.resource_id
|
LEFT JOIN (SELECT
|
MAX(A.end_time) "maxTime",
|
A.resource_id
|
FROM aps_scene_task A
|
WHERE A.scene_id = #{sceneId}
|
GROUP BY A.resource_id) b ON b.resource_id = r.ID
|
</select>
|
|
<select id="getList" resultMap="resourceMap">
|
SELECT
|
aps_resource."id",
|
aps_resource.resource_no,
|
aps_resource.resource_name,
|
aps_resource.remark,
|
aps_resource.workstation_id
|
FROM
|
aps_resource
|
WHERE aps_resource."id" in (
|
SELECT
|
aps_resource_connector.to_resource_id
|
FROM aps_resource_connector
|
WHERE aps_resource_connector.from_resource_id = #{param4})
|
</select>
|
<select id="fetch" resultMap="resourceMap">
|
SELECT
|
"public".aps_resource."id",
|
"public".aps_resource.resource_no,
|
"public".aps_resource.resource_name,
|
"public".aps_resource.remark,
|
"public".aps_resource.workstation_id
|
FROM
|
"public".aps_resource
|
WHERE aps_resource."id" NOT in (SELECT
|
aps_resource_connector.to_resource_id
|
FROM
|
"public".aps_resource_connector
|
WHERE
|
"public".aps_resource_connector.from_resource_id = #{param4})
|
</select>
|
<select id="getResourcePage" resultMap="resourceMap">
|
SELECT
|
ajrg."id",
|
aps.resource_no,
|
aps.resource_name,
|
aps.workstation_id
|
FROM
|
aps_resource aps
|
LEFT JOIN aps_join_res_group ajrg on ajrg.resource_id = aps."id"
|
LEFT JOIN aps_resource_group asg on ajrg.rsc_group_id = asg."id"
|
WHERE asg."id" = #{id}
|
<if test="ew.emptyOfWhere == false">
|
and ${ew.SqlSegment}
|
</if>
|
</select>
|
<select id="getNoRepetitive" resultMap="resourceMap">
|
SELECT
|
aps_resource."id",
|
aps_resource.resource_no,
|
aps_resource.resource_name,
|
aps_resource.workstation_id
|
FROM
|
aps_resource
|
WHERE aps_resource."id" NOT in (SELECT
|
aps_resource."id"
|
FROM
|
aps_resource,
|
aps_resource_group,
|
aps_join_res_group
|
WHERE
|
aps_resource_group."id" = aps_join_res_group.rsc_group_id
|
AND
|
aps_join_res_group.resource_id = aps_resource."id"
|
AND aps_resource_group."id" = #{param4})
|
</select>
|
<select id="query" resultMap="resourceMap">
|
<bind name="searchKey" value="'%' + keyword + '%'"/>
|
select * from aps_resource a where a.resource_no like #{searchKey} or a.resource_name like #{searchKey} order by
|
id limit 100
|
</select>
|
<update id="updateNoById">
|
UPDATE aps_resource
|
SET resource_no= NULL,
|
workstation_id=0
|
WHERE aps_resource."id" = #{id}
|
</update>
|
<select id="selectDtoById" resultType="com.chinaztt.mes.aps.dto.ResourceDTO">
|
select *
|
from aps_resource
|
where id = #{id}
|
</select>
|
<select id="getAllResourcePage" resultMap="resourceMapDTO">
|
SELECT
|
ajrg."id",
|
aps.resource_no,
|
aps.resource_name,
|
aps.workstation_id,
|
asg.rsc_group_name
|
FROM
|
aps_join_res_group ajrg
|
LEFT JOIN aps_resource_group asg on ajrg.rsc_group_id = asg."id"
|
LEFT JOIN aps_resource aps on aps."id" = ajrg.resource_id
|
<if test="ew.emptyOfWhere == false">
|
${ew.customSqlSegment}
|
</if>
|
</select>
|
</mapper>
|