<?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.plan.mapper.MpsRequirementsMapper">
|
|
<resultMap id="mpsRequirementsMap" type="com.chinaztt.mes.plan.dto.MpsRequirementsDTO">
|
<id property="id" column="id"/>
|
<result property="indeRequNo" column="inde_requ_no"/>
|
<result property="qtyRequired" column="qty_required"/>
|
<result property="requiredDate" column="required_date"/>
|
<result property="state" column="state"/>
|
<result property="remark" column="remark"/>
|
<result property="partNo" column="part_no"/>
|
<result property="partName" column="part_name"/>
|
<result property="partDescription" column="part_description"/>
|
<result property="remainderRequired" column="remainder_required"/>
|
<result property="qtyPlaned" column="remainder_required"/>
|
<result property="createTime" column="create_time"/>
|
<result property="updateTime" column="update_time"/>
|
<result property="createUser" column="create_user"/>
|
<result property="updateUser" column="update_user"/>
|
<result property="sourceType" column="source_type"/>
|
<result property="customerOrderNo" column="customer_order_no"/>
|
<result property="customerName" column="customer_name"/>
|
<result property="unit" column="unit"/>
|
</resultMap>
|
<select id="getMpsRequirementsPage" resultMap="mpsRequirementsMap">
|
select
|
D.id,
|
D.inde_requ_no,
|
D.qty_required,
|
D.required_date,
|
D.state,
|
D.remark,
|
D.part_no,
|
D.part_name,
|
D.part_description,
|
D.remainder_required,
|
D.create_time,
|
D.update_time,
|
D.create_user,
|
D.update_user,
|
D.source_type,
|
D.plan_required,
|
D.part_id,
|
D.unit,
|
D.customer_order_no,
|
D.customer_name
|
from (
|
select
|
pir.*,
|
bp.part_no,bp.description part_description,bp.part_name,
|
pir.qty_required - pir.plan_required remainder_required,
|
pco.customer_order_no,pco.customer_name,bp.unit
|
from plan_mps_requirements pir
|
left join basic_part bp on bp."id" = pir.part_id
|
left join plan_join_order_requirements pjor on pjor.mps_requirements_id=pir."id"
|
left join plan_customer_order pco on pco."id"=pjor.customer_order_id
|
)D
|
<where>
|
<if test="ew.emptyOfWhere == false">
|
and ${ew.sqlSegment}
|
</if>
|
</where>
|
</select>
|
|
<select id="selectDtoById" resultMap="mpsRequirementsMap">
|
select
|
pir.*,
|
bp.part_no,bp.part_name
|
from plan_mps_requirements pir
|
left join basic_part bp on bp."id" = pir.part_id
|
where pir.id = #{id}
|
</select>
|
|
<select id="getQtyRequiredSumById" resultType="java.math.BigDecimal">
|
select coalesce(sum(pir.qty_required),0) qty_required_sum
|
from plan_join_order_requirements pjor
|
left join plan_mps_requirements pir on pir."id"=pjor.mps_requirements_id
|
where pir."id"!=#{id} and exists(select 1 from plan_join_order_requirements pjor_a
|
where pjor_a.mps_requirements_id=#{id} and pjor_a.customer_order_id=pjor.customer_order_id)
|
</select>
|
|
<select id="getOrderQuantityById" resultType="java.math.BigDecimal">
|
select pco.buy_qty_due
|
from plan_customer_order pco
|
left join plan_join_order_requirements pjor on pjor.customer_order_id=pco."id"
|
where pjor.mps_requirements_id=#{id}
|
</select>
|
|
<update id="updatePlanRequiredById">
|
update plan_mps_requirements set plan_required=plan_required + #{param.qtyPlaned}
|
where id=#{param.id}
|
</update>
|
|
<select id="selectScheduleByRequirementsId" resultType="java.lang.String">
|
select pmps.mps_no
|
from plan_master_production_schedule pmps
|
left join plan_mps_source pms on pms.mps_id=pmps."id"
|
where pms.mps_requ_id=#{id}
|
</select>
|
</mapper>
|