|
|
|
@ -4,4 +4,209 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
|
|
<mapper namespace="org.dromara.mes.mapper.ProdBaseRouteMapper">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<resultMap type="ProdBaseRoute" id="ProdBaseRouteResult">
|
|
|
|
|
<result property="routeId" column="route_id"/>
|
|
|
|
|
<result property="routeName" column="route_name"/>
|
|
|
|
|
<result property="routeDesc" column="route_desc"/>
|
|
|
|
|
<result property="activeFlag" column="active_flag"/>
|
|
|
|
|
<result property="remark" column="remark"/>
|
|
|
|
|
<result property="createBy" column="create_by"/>
|
|
|
|
|
<result property="createTime" column="create_time"/>
|
|
|
|
|
<result property="updateBy" column="update_by"/>
|
|
|
|
|
<result property="updateTime" column="update_time"/>
|
|
|
|
|
<result property="productionTime" column="production_time"/>
|
|
|
|
|
|
|
|
|
|
<result property="tenantId" column="tenant_id"/>
|
|
|
|
|
|
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
<resultMap id="ProdBaseRouteProdBaseRouteProcessResult" type="ProdBaseRoute" extends="ProdBaseRouteResult">
|
|
|
|
|
<collection property="prodBaseRouteProcessList" notNullColumn="sub_route_process_id" javaType="java.util.List"
|
|
|
|
|
resultMap="ProdBaseRouteProcessResult"/>
|
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
<resultMap type="ProdBaseRouteProcess" id="ProdBaseRouteProcessResult">
|
|
|
|
|
<result property="routeProcessId" column="sub_route_process_id"/>
|
|
|
|
|
<result property="routeId" column="sub_route_id"/>
|
|
|
|
|
<result property="processId" column="sub_process_id"/>
|
|
|
|
|
<result property="processOrder" column="sub_process_order"/>
|
|
|
|
|
<result property="remark" column="sub_remark"/>
|
|
|
|
|
<result property="createBy" column="sub_create_by"/>
|
|
|
|
|
<result property="createTime" column="sub_create_time"/>
|
|
|
|
|
<result property="updateBy" column="sub_update_by"/>
|
|
|
|
|
<result property="updateTime" column="sub_update_time"/>
|
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
<sql id="selectProdBaseRouteVo">
|
|
|
|
|
select a.route_id,
|
|
|
|
|
a.route_name,
|
|
|
|
|
a.route_desc,
|
|
|
|
|
a.active_flag,
|
|
|
|
|
a.remark,
|
|
|
|
|
a.create_by,
|
|
|
|
|
a.create_time,
|
|
|
|
|
a.update_by,
|
|
|
|
|
a.update_time,
|
|
|
|
|
sum(p.production_time) production_time,
|
|
|
|
|
|
|
|
|
|
a.tenant_id
|
|
|
|
|
|
|
|
|
|
from prod_base_route a
|
|
|
|
|
left join prod_base_route_process b on b.route_id = a.route_id
|
|
|
|
|
left join mes_base_process_info p on p.process_id = b.process_id
|
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
|
|
<select id="selectProdBaseRouteList" parameterType="ProdBaseRoute" resultMap="ProdBaseRouteResult">
|
|
|
|
|
<include refid="selectProdBaseRouteVo"/>
|
|
|
|
|
<where>
|
|
|
|
|
<if test="routeName != null and routeName != ''">and a.route_name like concat('%', #{routeName}, '%')</if>
|
|
|
|
|
<if test="routeDesc != null and routeDesc != ''">and a.route_desc = #{routeDesc}</if>
|
|
|
|
|
<if test="activeFlag != null and activeFlag != ''">and a.active_flag = #{activeFlag}</if>
|
|
|
|
|
<if test="createBy != null and createBy != ''">and a.create_by = #{createBy}</if>
|
|
|
|
|
<if test="createTime != null ">and a.create_time = #{createTime}</if>
|
|
|
|
|
<if test="updateBy != null and updateBy != ''">and a.update_by = #{updateBy}</if>
|
|
|
|
|
<if test="updateTime != null ">and a.update_time = #{updateTime}</if>
|
|
|
|
|
|
|
|
|
|
<if test="tenantId != null and tenantId != ''">and a.tenant_id = #{tenantId}</if>
|
|
|
|
|
|
|
|
|
|
</where>
|
|
|
|
|
group by a.route_id, a.route_name, a.route_desc, a.active_flag, a.remark, a.create_by, a.create_time, a.update_by,
|
|
|
|
|
a.update_time
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectProdBaseRouteByRouteId" parameterType="Long" resultMap="ProdBaseRouteProdBaseRouteProcessResult">
|
|
|
|
|
select a.route_id,
|
|
|
|
|
a.route_name,
|
|
|
|
|
a.route_desc,
|
|
|
|
|
a.active_flag,
|
|
|
|
|
a.remark,
|
|
|
|
|
a.create_by,
|
|
|
|
|
a.create_time,
|
|
|
|
|
a.update_by,
|
|
|
|
|
a.update_time,
|
|
|
|
|
|
|
|
|
|
a.tenant_id,
|
|
|
|
|
|
|
|
|
|
b.route_process_id as sub_route_process_id,
|
|
|
|
|
b.route_id as sub_route_id,
|
|
|
|
|
b.process_id as sub_process_id,
|
|
|
|
|
b.process_order as sub_process_order,
|
|
|
|
|
b.remark as sub_remark,
|
|
|
|
|
b.create_by as sub_create_by,
|
|
|
|
|
b.create_time as sub_create_time,
|
|
|
|
|
b.update_by as sub_update_by,
|
|
|
|
|
b.update_time as sub_update_time
|
|
|
|
|
from prod_base_route a
|
|
|
|
|
left join prod_base_route_process b on b.route_id = a.route_id
|
|
|
|
|
where a.route_id = #{routeId}
|
|
|
|
|
order by b.process_order
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<insert id="insertProdBaseRoute" parameterType="ProdBaseRoute" useGeneratedKeys="true" keyProperty="routeId">
|
|
|
|
|
insert into prod_base_route
|
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="routeName != null and routeName != ''">route_name,</if>
|
|
|
|
|
<if test="routeDesc != null">route_desc,</if>
|
|
|
|
|
<if test="activeFlag != null and activeFlag != ''">active_flag,</if>
|
|
|
|
|
<if test="remark != null">remark,</if>
|
|
|
|
|
<if test="createBy != null">create_by,</if>
|
|
|
|
|
<if test="createTime != null">create_time,</if>
|
|
|
|
|
<if test="updateBy != null">update_by,</if>
|
|
|
|
|
<if test="updateTime != null">update_time,</if>
|
|
|
|
|
|
|
|
|
|
<if test="tenantId != null and tenantId != ''">tenant_id,</if>
|
|
|
|
|
|
|
|
|
|
</trim>
|
|
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="routeName != null and routeName != ''">#{routeName},</if>
|
|
|
|
|
<if test="routeDesc != null">#{routeDesc},</if>
|
|
|
|
|
<if test="activeFlag != null and activeFlag != ''">#{activeFlag},</if>
|
|
|
|
|
<if test="remark != null">#{remark},</if>
|
|
|
|
|
<if test="createBy != null">#{createBy},</if>
|
|
|
|
|
<if test="createTime != null">#{createTime},</if>
|
|
|
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
|
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
|
|
|
|
|
|
|
|
<if test="tenantId != null and tenantId != ''">#{tenantId},</if>
|
|
|
|
|
|
|
|
|
|
</trim>
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<update id="updateProdBaseRoute" parameterType="ProdBaseRoute">
|
|
|
|
|
update prod_base_route
|
|
|
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
|
|
|
<if test="routeName != null and routeName != ''">route_name = #{routeName},</if>
|
|
|
|
|
<if test="routeDesc != null">route_desc = #{routeDesc},</if>
|
|
|
|
|
<if test="activeFlag != null and activeFlag != ''">active_flag = #{activeFlag},</if>
|
|
|
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
|
|
|
<if test="createBy != null">create_by = #{createBy},</if>
|
|
|
|
|
<if test="createTime != null">create_time = #{createTime},</if>
|
|
|
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
|
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
|
|
|
|
|
|
|
|
<if test="tenantId != null and tenantId != ''">tenant_id = #{tenantId},</if>
|
|
|
|
|
|
|
|
|
|
</trim>
|
|
|
|
|
where route_id = #{routeId}
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteProdBaseRouteByRouteId" parameterType="Long">
|
|
|
|
|
delete
|
|
|
|
|
from prod_base_route
|
|
|
|
|
where route_id = #{routeId}
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteProdBaseRouteByRouteIds" parameterType="String">
|
|
|
|
|
delete from prod_base_route where route_id in
|
|
|
|
|
<foreach item="routeId" collection="array" open="(" separator="," close=")">
|
|
|
|
|
#{routeId}
|
|
|
|
|
</foreach>
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteProdBaseRouteProcessByRouteIds" parameterType="String">
|
|
|
|
|
delete from prod_base_route_process where route_id in
|
|
|
|
|
<foreach item="routeId" collection="array" open="(" separator="," close=")">
|
|
|
|
|
#{routeId}
|
|
|
|
|
</foreach>
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteProdBaseRouteProcessByRouteId" parameterType="Long">
|
|
|
|
|
delete
|
|
|
|
|
from prod_base_route_process
|
|
|
|
|
where route_id = #{routeId}
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
<insert id="batchProdBaseRouteProcess">
|
|
|
|
|
insert into prod_base_route_process( route_id, process_id, process_order, remark, create_by,
|
|
|
|
|
create_time, update_by, update_time) values
|
|
|
|
|
<foreach item="item" index="index" collection="list" separator=",">
|
|
|
|
|
( #{item.routeId}, #{item.processId}, #{item.processOrder}, #{item.remark},
|
|
|
|
|
#{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime})
|
|
|
|
|
</foreach>
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<select id="getStationByRouteId" parameterType="Long" resultType="java.util.HashMap">
|
|
|
|
|
select brp.process_id processId,
|
|
|
|
|
bpi.process_name processName,
|
|
|
|
|
brp.process_order processOrder,
|
|
|
|
|
bsi.station_id stationId,
|
|
|
|
|
bsi.station_name stationName,
|
|
|
|
|
bsi.production_time productionTime,
|
|
|
|
|
mf.multiStationFlag
|
|
|
|
|
from prod_base_route_process brp
|
|
|
|
|
left join mes_base_process_info bpi on bpi.process_id = brp.process_id
|
|
|
|
|
left join mes_base_station_info bsi on bsi.process_id = bpi.process_id
|
|
|
|
|
left join (select brp.process_id, count(*) multiStationFlag
|
|
|
|
|
from prod_base_route_process brp
|
|
|
|
|
left join mes_base_station_info bsi on bsi.process_id = brp.process_id
|
|
|
|
|
where brp.route_id = #{routeId}
|
|
|
|
|
group by brp.process_id) mf on mf.process_id = bsi.process_id
|
|
|
|
|
where brp.route_id = #{routeId}
|
|
|
|
|
order by brp.process_order
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</mapper>
|
|
|
|
|