@ -1,97 +1,182 @@
<?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">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace= "com.hw.mes.mapper.MesProductPlanMapper" >
<resultMap type= "MesProductPlan" id= "MesProductPlanResult" >
<result property= "planId" column= "plan_id" />
<result property= "productOrderId" column= "product_order_id" />
<result property= "planCode" column= "plan_code" />
<result property= "dispatchCode" column= "dispatch_code" />
<result property= "materialId" column= "material_id" />
<result property= "materialBomId" column= "material_bom_id" />
<result property= "processId" column= "process_id" />
<result property= "processOrder" column= "process_order" />
<result property= "lastProcessId" column= "last_process_id" />
<result property= "stationId" column= "station_id" />
<result property= "userId" column= "user_id" />
<result property= "productionTime" column= "production_time" />
<result property= "planAmount" column= "plan_amount" />
<result property= "completeAmount" column= "complete_amount" />
<result property= "planBeginTime" column= "plan_begin_time" />
<result property= "planEndTime" column= "plan_end_time" />
<result property= "realBeginTime" column= "real_begin_time" />
<result property= "realEndTime" column= "real_end_time" />
<result property= "attachId" column= "attach_id" />
<result property= "planStatus" column= "plan_status" />
<result property= "isFlag" column= "is_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= "planDeliveryDate" column= "plan_delivery_date" />
<result property= "materialName" column= "material_name" />
<result property= "planId" column= "plan_id" />
<result property= "productOrderId" column= "product_order_id" />
<result property= "orderCode" column= "order_code" />
<result property= "planCode" column= "plan_code" />
<result property= "dispatchCode" column= "dispatch_code" />
<result property= "materialId" column= "material_id" />
<result property= "materialName" column= "material_name" />
<result property= "materialBomId" column= "material_bom_id" />
<result property= "materialBomName" column= "materialBomName" />
<result property= "processId" column= "process_id" />
<result property= "processOrder" column= "process_order" />
<result property= "lastProcessId" column= "last_process_id" />
<result property= "lastProcessName" column= "lastProcessName" />
<result property= "stationId" column= "station_id" />
<result property= "userId" column= "user_id" />
<result property= "productionTime" column= "production_time" />
<result property= "planAmount" column= "plan_amount" />
<result property= "completeAmount" column= "complete_amount" />
<result property= "planBeginTime" column= "plan_begin_time" />
<result property= "planEndTime" column= "plan_end_time" />
<result property= "realBeginTime" column= "real_begin_time" />
<result property= "realEndTime" column= "real_end_time" />
<result property= "attachId" column= "attach_id" />
<result property= "planStatus" column= "plan_status" />
<result property= "isFlag" column= "is_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= "planDeliveryDate" column= "plan_delivery_date" />
<result property= "materialName" column= "material_name" />
<result property= "processName" column= "process_name" />
<result property= "stationName" column= "station_name" />
</resultMap>
<resultMap id= "MesProductPlanMesProductPlanDetailResult" type= "MesProductPlan" extends= "MesProductPlanResult" >
<collection property= "mesProductPlanDetailList" notNullColumn= "sub_plan_detail_id" javaType= "java.util.List" resultMap= "MesProductPlanDetailResult" />
<collection property= "mesProductPlanDetailList" notNullColumn= "sub_plan_detail_id" javaType= "java.util.List"
resultMap="MesProductPlanDetailResult"/>
</resultMap>
<resultMap type= "MesProductPlanDetail" id= "MesProductPlanDetailResult" >
<result property= "planDetailId" column= "sub_plan_detail_id" />
<result property= "planDetailCode" column= "sub_plan_detail_code" />
<result property= "planId" column= "sub_plan_id" />
<result property= "planCode" column= "sub_plan_code" />
<result property= "userId" column= "sub_user_id" />
<result property= "userName" column= "sub_user_name" />
<result property= "realBeginTime" column= "sub_real_begin_time" />
<result property= "realEndTime" column= "sub_real_end_time" />
<result property= "planDetailStatus" column= "sub_plan_detail_status" />
<result property= "isFlag" column= "sub_is_flag" />
<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" />
<result property= "planDetailId" column= "sub_plan_detail_id" />
<result property= "planDetailCode" column= "sub_plan_detail_code" />
<result property= "planId" column= "sub_plan_id" />
<result property= "planCode" column= "sub_plan_code" />
<result property= "userId" column= "sub_user_id" />
<result property= "userName" column= "sub_user_name" />
<result property= "realBeginTime" column= "sub_real_begin_time" />
<result property= "realEndTime" column= "sub_real_end_time" />
<result property= "planDetailStatus" column= "sub_plan_detail_status" />
<result property= "isFlag" column= "sub_is_flag" />
<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= "selectMesProductPlanVo" >
select plan_id, product_order_id, plan_code, dispatch_code, material_id, material_bom_id, process_id, process_order, last_process_id, station_id, user_id, production_time, plan_amount, complete_amount, plan_begin_time, plan_end_time, real_begin_time, real_end_time, attach_id, plan_status, is_flag, remark, create_by, create_time, update_by, update_time from mes_product_plan
select mpp.plan_id,
mpp.product_order_id,
po.order_code,
mpp.plan_code,
mpp.dispatch_code,
mpp.material_id,
mi.material_name,
mpp.material_bom_id,
concat(mb.material_name, '-', mb.material_bom_desc) materialBomName,
mpp.process_id,
bpi.process_name,
mpp.process_order,
mpp.last_process_id,
bp2.process_name lastProcessName,
mpp.station_id,
bsi.station_name,
mpp.user_id,
mpp.production_time,
mpp.plan_amount,
mpp.complete_amount,
mpp.plan_begin_time,
mpp.plan_end_time,
mpp.real_begin_time,
mpp.real_end_time,
mpp.attach_id,
mpp.plan_status,
mpp.is_flag,
mpp.remark,
mpp.create_by,
mpp.create_time,
mpp.update_by,
mpp.update_time
from mes_product_plan mpp
left join mes_base_process_info bpi on bpi.process_id = mpp.process_id
left join mes_base_station_info bsi on bsi.station_id = mpp.station_id
left join mes_base_material_info mi on mi.material_id = mpp.material_id
left join mes_material_bom mb on mb.material_bom_id = mpp.material_bom_id
left join mes_base_process_info bp2 on bp2.process_id = mpp.last_process_id
left join mes_product_order po on po.product_order_id = mpp.product_order_id
</sql>
<select id= "selectMesProductPlanList" parameterType= "MesProductPlan" resultMap= "MesProductPlanResult" >
<include refid= "selectMesProductPlanVo" />
<where >
<if test= "productOrderId != null " > and product_order_id = #{productOrderId}</if>
<if test= "planCode != null and planCode != ''" > and plan_code = #{planCode}</if>
<if test= "dispatchCode != null and dispatchCode != ''" > and dispatch_code = #{dispatchCode}</if>
<if test= "materialId != null " > and material_id = #{materialId}</if>
<if test= "materialBomId != null " > and material_bom_id = #{materialBomId}</if>
<if test= "processId != null " > and process_id = #{processId}</if>
<if test= "processOrder != null " > and process_order = #{processOrder}</if>
<if test= "lastProcessId != null " > and last_process_id = #{lastProcessId}</if>
<if test= "stationId != null " > and station_id = #{stationId}</if>
<if test= "userId != null " > and user_id = #{userId}</if>
<if test= "productionTime != null " > and production_time = #{productionTime}</if>
<if test= "planAmount != null " > and plan_amount = #{planAmount}</if>
<if test= "completeAmount != null " > and complete_amount = #{completeAmount}</if>
<if test= "planBeginTime != null " > and plan_begin_time = #{planBeginTime}</if>
<if test= "planEndTime != null " > and plan_end_time = #{planEndTime}</if>
<if test= "realBeginTime != null " > and real_begin_time = #{realBeginTime}</if>
<if test= "realEndTime != null " > and real_end_time = #{realEndTime}</if>
<if test= "attachId != null and attachId != ''" > and attach_id = #{attachId}</if>
<if test= "planStatus != null and planStatus != ''" > and plan_status = #{planStatus}</if>
<if test= "isFlag != null and isFlag != ''" > and is_flag = #{isFlag}</if>
<if test= "productOrderId != null " > and mpp. product_order_id = #{productOrderId}</if>
<if test= "planCode != null and planCode != ''" > and mpp. plan_code = #{planCode}</if>
<if test= "dispatchCode != null and dispatchCode != ''" > and mpp. dispatch_code = #{dispatchCode}</if>
<if test= "materialId != null " > and mpp. material_id = #{materialId}</if>
<if test= "materialBomId != null " > and mpp. material_bom_id = #{materialBomId}</if>
<if test= "processId != null " > and mpp. process_id = #{processId}</if>
<if test= "processOrder != null " > and mpp. process_order = #{processOrder}</if>
<if test= "lastProcessId != null " > and mpp. last_process_id = #{lastProcessId}</if>
<if test= "stationId != null " > and mpp. station_id = #{stationId}</if>
<if test= "userId != null " > and mpp. user_id = #{userId}</if>
<if test= "productionTime != null " > and mpp. production_time = #{productionTime}</if>
<if test= "planAmount != null " > and mpp. plan_amount = #{planAmount}</if>
<if test= "completeAmount != null " > and mpp. complete_amount = #{completeAmount}</if>
<if test= "planBeginTime != null " > and mpp. plan_begin_time = #{planBeginTime}</if>
<if test= "planEndTime != null " > and mpp. plan_end_time = #{planEndTime}</if>
<if test= "realBeginTime != null " > and mpp. real_begin_time = #{realBeginTime}</if>
<if test= "realEndTime != null " > and mpp. real_end_time = #{realEndTime}</if>
<if test= "attachId != null and attachId != ''" > and mpp. attach_id = #{attachId}</if>
<if test= "planStatus != null and planStatus != ''" > and mpp. plan_status = #{planStatus}</if>
<if test= "isFlag != null and isFlag != ''" > and mpp. is_flag = #{isFlag}</if>
</where>
order by mpp.dispatch_code
</select>
<select id= "selectMesProductPlanByPlanId" parameterType= "Long" resultMap= "MesProductPlanMesProductPlanDetailResult" >
select a.plan_id, a.product_order_id, a.plan_code, a.dispatch_code, a.material_id, a.material_bom_id, a.process_id, a.process_order, a.last_process_id, a.station_id, a.user_id, a.production_time, a.plan_amount, a.complete_amount, a.plan_begin_time, a.plan_end_time, a.real_begin_time, a.real_end_time, a.attach_id, a.plan_status, a.is_flag, a.remark, a.create_by, a.create_time, a.update_by, a.update_time,
b.plan_detail_id as sub_plan_detail_id, b.plan_detail_code as sub_plan_detail_code, b.plan_id as sub_plan_id, b.plan_code as sub_plan_code, b.user_id as sub_user_id, b.user_name as sub_user_name, b.real_begin_time as sub_real_begin_time, b.real_end_time as sub_real_end_time, b.plan_detail_status as sub_plan_detail_status, b.is_flag as sub_is_flag, 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
select a.plan_id,
a.product_order_id,
a.plan_code,
a.dispatch_code,
a.material_id,
a.material_bom_id,
a.process_id,
a.process_order,
a.last_process_id,
a.station_id,
a.user_id,
a.production_time,
a.plan_amount,
a.complete_amount,
a.plan_begin_time,
a.plan_end_time,
a.real_begin_time,
a.real_end_time,
a.attach_id,
a.plan_status,
a.is_flag,
a.remark,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
b.plan_detail_id as sub_plan_detail_id,
b.plan_detail_code as sub_plan_detail_code,
b.plan_id as sub_plan_id,
b.plan_code as sub_plan_code,
b.user_id as sub_user_id,
b.user_name as sub_user_name,
b.real_begin_time as sub_real_begin_time,
b.real_end_time as sub_real_end_time,
b.plan_detail_status as sub_plan_detail_status,
b.is_flag as sub_is_flag,
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 mes_product_plan a
left join mes_product_plan_detail b on b.plan_id = a.plan_id
left join mes_product_plan_detail b on b.plan_id = a.plan_id
where a.plan_id = #{planId}
</select>
@ -123,7 +208,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test= "createTime != null" > create_time,</if>
<if test= "updateBy != null" > update_by,</if>
<if test= "updateTime != null" > update_time,</if>
</trim>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "productOrderId != null" > #{productOrderId},</if>
<if test= "planCode != null and planCode != ''" > #{planCode},</if>
@ -150,7 +235,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test= "createTime != null" > #{createTime},</if>
<if test= "updateBy != null" > #{updateBy},</if>
<if test= "updateTime != null" > #{updateTime},</if>
</trim>
</trim>
</insert>
<update id= "updateMesProductPlan" parameterType= "MesProductPlan" >
@ -186,7 +271,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<delete id= "deleteMesProductPlanByPlanId" parameterType= "Long" >
delete from mes_product_plan where plan_id = #{planId}
delete
from mes_product_plan
where plan_id = #{planId}
</delete>
<delete id= "deleteMesProductPlanByPlanIds" parameterType= "String" >
@ -204,37 +291,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<delete id= "deleteMesProductPlanDetailByPlanId" parameterType= "Long" >
delete from mes_product_plan_detail where plan_id = #{planId}
delete
from mes_product_plan_detail
where plan_id = #{planId}
</delete>
<insert id= "batchMesProductPlanDetail" >
insert into mes_product_plan_detail( plan_detail_id, plan_detail_code, plan_id, plan_code, user_id, user_name, real_begin_time, real_end_time, plan_detail_status, is_flag, remark, create_by, create_time, update_by, update_time) values
<foreach item= "item" index= "index" collection= "list" separator= "," >
( #{item.planDetailId}, #{item.planDetailCode}, #{item.planId}, #{item.planCode}, #{item.userId}, #{item.userName}, #{item.realBeginTime}, #{item.realEndTime}, #{item.planDetailStatus}, #{item.isFlag}, #{item.remark}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime})
insert into mes_product_plan_detail( plan_detail_id, plan_detail_code, plan_id, plan_code, user_id, user_name,
real_begin_time, real_end_time, plan_detail_status, is_flag, remark, create_by, create_time, update_by,
update_time) values
<foreach item= "item" index= "index" collection= "list" separator= "," >
( #{item.planDetailId}, #{item.planDetailCode}, #{item.planId}, #{item.planCode}, #{item.userId},
#{item.userName}, #{item.realBeginTime}, #{item.realEndTime}, #{item.planDetailStatus}, #{item.isFlag},
#{item.remark}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime})
</foreach>
</insert>
<select id= "selectMesProductPlanJoinList" parameterType= "MesProductPlan" resultMap= "MesProductPlanResult" >
select mpp.plan_id, mpp.product_order_id, mpp.plan_code, mpp.dispatch_code, mpp.material_id, mpp.material_bom_id, mpp.process_id, mpp.process_order, mpp.last_process_id,
mpp.station_id, mpp.plan_amount, mpp.complete_amount, mpp.plan_begin_time, mpp.plan_end_time, mpp.real_begin_time, mpp.real_end_time,
select mpp.plan_id, mpp.product_order_id, mpp.plan_code, mpp.dispatch_code, mpp.material_id,
mpp.material_bom_id, mpp.process_id, mpp.process_order, mpp.last_process_id,
mpp.station_id, mpp.plan_amount, mpp.complete_amount, mpp.plan_begin_time, mpp.plan_end_time,
mpp.real_begin_time, mpp.real_end_time,
mpp.attach_id, mpp.plan_status, mpo.plan_delivery_date,mbmi.material_name
from mes_product_plan mpp left join mes_product_order mpo on mpp.product_order_id = mpo.product_order_id
left join mes_base_material_info mbmi on mpp.material_id=mbmi.material_id
from mes_product_plan mpp left join mes_product_order mpo on mpp.product_order_id = mpo.product_order_id
left join mes_base_material_info mbmi on mpp.material_id=mbmi.material_id
<where >
<if test= "stationId != null " > and mpp.station_id = #{stationId}</if>
<if test= "planStatus != null and planStatus != ''" > and mpp.plan_status = #{planStatus}</if>
<if test= "stationId != null " > and mpp.station_id = #{stationId}</if>
<if test= "planStatus != null and planStatus != ''" > and mpp.plan_status = #{planStatus}</if>
</where>
</select>