2024-11-14 16:20:34 +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.bases.mapper.StatisticsMapper" >
|
|
|
|
|
|
|
|
|
|
<select id="getPaTypeStatistics" resultType="java.lang.String">
|
|
|
|
|
select IFNULL( count(1),0) NUM
|
|
|
|
|
FROM pa_type
|
|
|
|
|
where pa_type.`level`=1 AND is_active=1
|
|
|
|
|
UNION ALL
|
|
|
|
|
select IFNULL( count(1),0)
|
|
|
|
|
FROM pa_type
|
|
|
|
|
where pa_type.`level`=3 AND is_active=1
|
|
|
|
|
UNION ALL
|
|
|
|
|
select IFNULL(SUM(price*num),0)
|
|
|
|
|
FROM pa_type
|
|
|
|
|
where pa_type.`level`=3 AND is_active=1
|
|
|
|
|
UNION ALL
|
|
|
|
|
select IFNULL( count(1),0)
|
|
|
|
|
FROM pa_type
|
|
|
|
|
where pa_type.`level`=3 AND is_active=1 and (num=0 or num is null)
|
|
|
|
|
</select>
|
|
|
|
|
<select id="findByPage" resultType="com.bonus.gzgqj.business.bases.entity.PaTypeVo">
|
|
|
|
|
select pt.id, pt.parent_id parentId,pt.name model ,pt.num,
|
|
|
|
|
pt.price,pt.unit ,pt.weight,pt.is_consumables ,
|
|
|
|
|
pt.remarks,pt.is_active ,pt.level,pt.warn_num,pt1.`name` name ,pt2.name type
|
|
|
|
|
FROM pa_type pt
|
|
|
|
|
left join pa_type pt1 on pt.parent_id=pt1.id and pt1.`level`=2 and pt1.is_active=1
|
|
|
|
|
left join pa_type pt2 on pt1.parent_id=pt2.id and pt2.`level`=1 and pt2.is_active=1
|
|
|
|
|
WHERE pt.is_active=1 and pt.`level`=3
|
|
|
|
|
<if test="type!=null and type !=''">
|
|
|
|
|
and pt2.name like concat('%',#{type},'%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="name!=null and name !=''">
|
|
|
|
|
and pt1.name like concat('%',#{name},'%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="model!=null and model !=''">
|
|
|
|
|
and pt.name like concat('%',#{model},'%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test='isWarn=="1"'>
|
|
|
|
|
and pt.num=0
|
|
|
|
|
</if>
|
|
|
|
|
<if test='isWarn=="2"'>
|
|
|
|
|
and pt.num>0
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
|
|
|
|
<!--工程统计领料单查询-->
|
|
|
|
|
<select id="getProListPage" resultType="com.bonus.gzgqj.business.bases.entity.ProjectInfoVo">
|
|
|
|
|
SELECT pro.id proId,pro.name proName,tpa.lyNum lyNum,tpa.lydNum,mm.money lyMoney
|
|
|
|
|
FROM bm_project pro
|
|
|
|
|
left join(
|
|
|
|
|
select count(1) lydNum ,sum(IFNULL(apply_num,0)) lyNum ,pro_id
|
|
|
|
|
from t_part_apply
|
|
|
|
|
where pro_id is not null and status=4
|
|
|
|
|
GROUP BY pro_id
|
|
|
|
|
)tpa on tpa.pro_id=pro.id
|
|
|
|
|
LEFT JOIN (
|
|
|
|
|
select sum(pad.apply_num*pt.price) money, tpa.pro_id
|
|
|
|
|
from t_part_apply tpa
|
|
|
|
|
LEFT JOIN t_part_apply_details pad on pad.apply_id=tpa.id
|
|
|
|
|
left join pa_type pt on pad.part_id=pt.id
|
|
|
|
|
where tpa.pro_id is not null and tpa.status=4
|
|
|
|
|
GROUP BY pro_id ) mm on mm.pro_id=pro.id
|
|
|
|
|
<where >
|
|
|
|
|
<if test="proName!=null and proName!=''">
|
|
|
|
|
and pro.name like concat('%',#{proName},'%')
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
|
|
|
|
|
</select>
|
|
|
|
|
<!--以工程为维度查询领料单详情-->
|
|
|
|
|
<select id="getProDetailsPage" resultType="com.bonus.gzgqj.business.app.entity.PartApplyDetailAppVo">
|
2024-11-16 16:53:04 +08:00
|
|
|
select pad.part_id partId, ANY_VALUE(pad.part_type) partType,ANY_VALUE(pad.part_name) partName,
|
|
|
|
|
ANY_VALUE(pad.part_model) partModel,ANY_VALUE(pad.part_unit) partUnit,ANY_VALUE(tpa.remark) remark ,
|
|
|
|
|
ANY_VALUE(sum(pad.apply_num)) applyNum,ANY_VALUE(pt.price) price ,ANY_VALUE(sum(pad.apply_num*pt.price)) money
|
2024-11-14 16:20:34 +08:00
|
|
|
from t_part_apply tpa
|
2024-11-16 16:53:04 +08:00
|
|
|
LEFT JOIN t_part_apply_details pad on pad.apply_id=tpa.id
|
|
|
|
|
left join pa_type pt on pad.part_id=pt.id
|
2024-11-14 16:20:34 +08:00
|
|
|
where tpa.`status`=4 and tpa.pro_id=#{proId}
|
|
|
|
|
<if test="partType!=null and partType !=''">
|
2024-11-16 16:53:04 +08:00
|
|
|
and pad.part_type like concat('%',#{partType},'%')
|
2024-11-14 16:20:34 +08:00
|
|
|
</if>
|
|
|
|
|
<if test="partName!=null and partName !=''">
|
2024-11-16 16:53:04 +08:00
|
|
|
and pad.part_name like concat('%',#{partName},'%')
|
2024-11-14 16:20:34 +08:00
|
|
|
</if>
|
|
|
|
|
<if test="partModel!=null and partModel !=''">
|
2024-11-16 16:53:04 +08:00
|
|
|
and pad.part_model like concat('%',#{partModel},'%')
|
2024-11-14 16:20:34 +08:00
|
|
|
</if>
|
|
|
|
|
GROUP BY pad.part_id
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getProDetailsFilePage" resultType="com.bonus.gzgqj.business.plan.entity.FileUploadVo">
|
|
|
|
|
select file.id, file.file_name fileName,
|
|
|
|
|
file.file_url fileUrl, file.create_time createTime,file.creator creator, file.model_table,
|
2024-11-15 19:12:50 +08:00
|
|
|
file.own_id ownId , file.suffix,file.type, file.file_type fileType,file.create_name createName,
|
|
|
|
|
tpa.remark
|
2024-11-14 16:20:34 +08:00
|
|
|
FROM t_part_apply tpa
|
|
|
|
|
left join bm_file_upload file on tpa.id=file.own_id and file.model_table='t_part_apply'
|
2024-11-15 19:12:50 +08:00
|
|
|
where tpa.`status`=4 and file.id is not null and tpa.pro_id=#{proId}
|
2024-11-14 16:20:34 +08:00
|
|
|
</select>
|
|
|
|
|
<select id="getProDetails" resultType="com.bonus.gzgqj.business.bases.entity.ProjectInfoVo">
|
|
|
|
|
SELECT pro.id proId,pro.name proName,tpa.lyNum lyNum,tpa.lydNum,mm.money lyMoney
|
|
|
|
|
FROM bm_project pro
|
|
|
|
|
left join(
|
|
|
|
|
select count(1) lydNum ,sum(IFNULL(apply_num,0)) lyNum ,pro_id
|
|
|
|
|
from t_part_apply
|
|
|
|
|
where pro_id is not null and status=4
|
|
|
|
|
GROUP BY pro_id
|
|
|
|
|
)tpa on tpa.pro_id=pro.id
|
|
|
|
|
LEFT JOIN (
|
|
|
|
|
select sum(pad.apply_num*pt.price) money, tpa.pro_id
|
|
|
|
|
from t_part_apply tpa
|
|
|
|
|
LEFT JOIN t_part_apply_details pad on pad.apply_id=tpa.id
|
|
|
|
|
left join pa_type pt on pad.part_id=pt.id
|
|
|
|
|
where tpa.pro_id is not null and tpa.status=4
|
|
|
|
|
GROUP BY pro_id ) mm on mm.pro_id=pro.id
|
|
|
|
|
where pro.id=#{proId}
|
|
|
|
|
</select>
|
|
|
|
|
</mapper>
|