gz_gqj/src/main/resources/mappers/plan/PlanOutMapper.xml

188 lines
9.0 KiB
XML
Raw Normal View History

2024-11-07 20:50:14 +08:00
<?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">
<mapper namespace="com.bonus.gzgqj.business.plan.mapper.PlanOutMapper">
<insert id="insertProOutInfo" useGeneratedKeys="true" keyProperty="id">
insert into t_plan_out( pro_id, consignor, shipment_date, remarks, create_time, create_day, creater
)VALUES (#{proId},#{userName},#{createDay},#{remarks},now(),CURRENT_DATE,#{creater})
</insert>
<insert id="insertProNeedDetails">
insert into t_plan_out_detail(
out_id, type, name, module, unit, module_id, fh_num, tz_num, remarks, data_type )values (
#{outId},#{type},#{name},#{module},#{unit},#{moduleId},#{fhNum},#{tzNum},#{remarks},#{dataType} )
</insert>
<insert id="addNeedInfo">
insert into t_pro_need_info (
pro_id, type, name, module, module_id, need_type, unit, need_num, fh_num, tz_num, remarks
) values (#{proId},#{type},#{name},#{module},#{moduleId},#{needType},#{unit},#{needNum},#{fhNum},#{tzNum},#{remarks})
</insert>
<update id="updateNeedInfo">
update t_pro_need_info set fh_num=#{fhNum} ,tz_num=#{tzNum},remarks=#{remarks}
where id=#{id}
</update>
<!--更新 统计数量-->
<update id="updatePriPlanInfo">
update t_pro_plan_info set record_num=#{recordNum},out_num=#{outNum},tz_num=#{tzNum},last_day=#{lastDay},
2024-11-08 15:32:57 +08:00
status=#{status},out2_num=#{outNum2},record2_num=#{recordNum}
2024-11-07 20:50:14 +08:00
where pro_id=#{proId}
</update>
<delete id="deleteProOut">
delete from t_plan_out where id=#{id}
</delete>
<select id="getProPlanPage" resultType="com.bonus.gzgqj.business.plan.entity.ProPlanInfoVo">
select
ppi.pro_id proId, ppi.need_num needNum,pro.`NAME` proName,tz_num,
ppi.plan_num planNum,ppi.record_num recordNum,
2024-11-09 17:03:21 +08:00
ppi.out_num outNum, ppi.status, IFNULL(ROUND((ppi.out_num+ppi.tz_num)*100/ppi.need_num,0),0) progress,
2024-11-07 20:50:14 +08:00
ppi.last_day lastDay
from t_pro_plan_info ppi
LEFT JOIN bm_project pro on ppi.pro_id=pro.id
<where>
<if test="status!=null and status!=''">
and ppi.status=#{status}
</if>
<if test="proName!=null and proName!=''">
and pro.`NAME` like concat('%',#{proName},'%')
</if>
</where>
</select>
<select id="getPorInfoDetail" resultType="com.bonus.gzgqj.business.plan.entity.ProNeedInfo">
select pni.id,pni.pro_id proId,pni.type,pni.name,pni.module,pni.module_id,pni.need_type needType,
2024-11-09 17:03:21 +08:00
IFNULL(pni.unit,'-') unit ,IFNULL(pni.need_num,0) needNum ,(pni.fh_num+pni.tz_num )fhNum ,pro.`NAME` proName ,
IF(pni.need_num-pni.fh_num-pni.tz_num >0,pni.need_num-pni.fh_num-pni.tz_num,0) diff, IFNULL(ROUND((pni.fh_num+pni.tz_num)*100/pni.need_num,0),0) progress,
IF(pni.need_type=1,'计划内','计划外') typeName ,pni.tz_num tzNum,pni.remarks
2024-11-07 20:50:14 +08:00
from t_pro_need_info pni
LEFT JOIN bm_project pro on pni.pro_id=pro.id
<where>
2024-11-09 17:03:21 +08:00
<if test="dataType==null || dataType==''">
and pni.need_type=1
</if>
<if test="proId!=null and proId!=''">
and pni.`pro_id` like concat('%',#{proId},'%')
</if>
<if test="module!=null and module!=''">
and pni.`module` like concat('%',#{module},'%')
</if>
<if test="name!=null and name!=''">
and pni.`name` like concat('%',#{name},'%')
</if>
</where>
</select>
<select id="getPorInfoDetail2" resultType="com.bonus.gzgqj.business.plan.entity.ProNeedInfo">
select pni.id,pni.pro_id proId,pni.type,pni.name,pni.module,pni.module_id,pni.need_type needType,
IFNULL(pni.unit,'-') unit ,IFNULL(pni.need_num,0) needNum ,(pni.fh_num )fhNum ,pro.`NAME` proName ,
IF(pni.need_num-pni.fh_num-pni.tz_num >0,pni.need_num-pni.fh_num-pni.tz_num,0) diff, IFNULL(ROUND((pni.fh_num+pni.tz_num)*100/pni.need_num,0),0) progress,
IF(pni.need_type=1,'计划内','计划外') typeName ,pni.tz_num tzNum,pni.remarks
from t_pro_need_info pni
LEFT JOIN bm_project pro on pni.pro_id=pro.id
<where>
<if test="proId!=null and proId!=''">
and pni.`pro_id` like concat('%',#{proId},'%')
</if>
2024-11-07 20:50:14 +08:00
<if test="module!=null and module!=''">
and pni.`module` like concat('%',#{module},'%')
</if>
<if test="name!=null and name!=''">
and pni.`name` like concat('%',#{name},'%')
</if>
</where>
</select>
2024-11-09 17:03:21 +08:00
2024-11-07 20:50:14 +08:00
<select id="getProDevSelected" resultType="com.bonus.gzgqj.business.plan.entity.ProDevSelect">
select distinct mt.id ,mt.`NAME`,mt.parent_id
from mm_type mt
where mt.`LEVEL`=3 and mt.IS_ACTIVE=1
</select>
<select id="getDevChilderList" resultType="com.bonus.gzgqj.business.plan.entity.ProDevSelect">
select distinct mt.id ,mt.`NAME`,mt.parent_id pId,mt.UNIT,mt.NUM,mt1.`NAME` pName,mt2.`NAME` ppName
from mm_type mt
LEFT JOIN mm_type mt1 on mt.PARENT_ID=mt1.id and mt.`LEVEL`=4 and mt1.`LEVEL`=3 and mt1.IS_ACTIVE=1
LEFT JOIN mm_type mt2 on mt1.PARENT_ID=mt2.id and mt1.`LEVEL`=3 and mt2.IS_ACTIVE=1
2024-11-09 11:47:01 +08:00
LEFT JOIN t_pro_need_info pni on pni.module_id=mt.id and pni.pro_id=#{proId}
2024-11-07 20:50:14 +08:00
where mt.`LEVEL`=4 and mt.IS_ACTIVE=1 and pni.id is null
2024-11-09 11:47:01 +08:00
and mt.parent_id=#{pId}
2024-11-07 20:50:14 +08:00
</select>
<select id="getProNeedInfo" resultType="com.bonus.gzgqj.business.plan.entity.ProNeedInfo">
select id, pro_id proId,type, name,
module,module_id moduleId,need_type needType,unit,need_num needNum,fh_num fhNum
,tz_num tzNum,remarks
from t_pro_need_info
WHERE id=#{id}
</select>
<select id="getProPlanInfo" resultType="com.bonus.gzgqj.business.plan.entity.ProPlanInfoVo">
select
ppi.pro_id proId, ppi.need_num needNum,
ppi.plan_num planNum,ppi.record_num recordNum,
2024-11-08 15:32:57 +08:00
ppi.out_num outNum, ppi.status,out2_num outNum2,record2_num recordNum2,
2024-11-07 20:50:14 +08:00
ppi.last_day lastDay
from t_pro_plan_info ppi
where ppi.pro_id=#{proId}
</select>
2024-11-08 15:32:57 +08:00
<select id="getStatistics" resultType="com.bonus.gzgqj.business.plan.entity.StatisticsVo">
select sum(need_num) needNum ,sum(fh_num) fhNum,SUM(IF(need_num>=fh_num,need_num-fh_num,0)) dfhNum
from t_pro_need_info
WHERE need_type=1
UNION
select IFNULL( sum(need_num),0) needNum ,IFNULL(sum(fh_num),0) fhNum,IFNULL(SUM(IF(need_num>=fh_num,need_num-fh_num,0)),0) dfhNum
from t_pro_need_info
WHERE need_type=2
</select>
<!--超出 数量-->
<select id="getOverNum" resultType="com.bonus.gzgqj.business.plan.entity.StatisticsVo">
SELECT IFNULL(SUM(pni.need_num-mt.NUM),0) num
from t_pro_need_info pni
left join mm_type mt on pni.module_id=mt.id
where pni.need_type=1
</select>
2024-11-09 17:03:21 +08:00
<select id="getOutTimes" resultType="com.bonus.gzgqj.business.plan.entity.OutDetailInfoVo">
select id, create_day createDay,create_time
from t_plan_out
where pro_id=#{proId}
order by create_time desc
</select>
2024-11-08 17:18:54 +08:00
2024-11-09 17:03:21 +08:00
<select id="getOutDetails" resultType="com.bonus.gzgqj.business.plan.entity.OutDetailInfoVo">
select consignor userName,create_day createDay,remarks,pro_id proId
from t_plan_out
where id=#{id}
</select>
2024-11-08 17:18:54 +08:00
2024-11-09 17:03:21 +08:00
<!--查询历史新增的-->
<select id="getHisAddData" resultType="com.bonus.gzgqj.business.plan.entity.ProNeedInfo">
select pni.id,pni.pro_id proId,pni.type,pni.name,pni.module,pni.module_id,pni.need_type needType,
IFNULL(pni.unit,'-') unit ,pni.need_num needNum ,pni.fh_num fhNum
,pni.tz_num,pni.remarks
from t_pro_need_info pni
where pni.module_id=#{moduleId} and pni.pro_id=#{proId}
2024-11-08 17:18:54 +08:00
</select>
2024-11-09 17:03:21 +08:00
<select id="getOutDetailsInfo" resultType="java.lang.String">
select CONCAT(name,":",SUM(fh_num)) detail
from t_plan_out_detail
where out_id=#{id}
GROUP BY name
</select>
<!--批次详情接口-->
<select id="getOutDetailList" resultType="com.bonus.gzgqj.business.plan.entity.ProNeedInfo">
select id,out_id id ,
type, name,
module, unit,
module_id moduleId, fh_num fhNum,
tz_num tzNum, remarks,
data_type dataType
from t_plan_out_detail pod
<where>
out_id=#{id}
<if test="module!=null and module!=''">
and pod.`module` like concat('%',#{module},'%')
</if>
<if test="name!=null and name!=''">
and pod.`name` like concat('%',#{name},'%')
</if>
</where>
2024-11-08 17:18:54 +08:00
</select>
2024-11-07 20:50:14 +08:00
</mapper>