gz_gqj/src/main/resources/mappers/app/PartApplyAppMapper.xml

118 lines
5.8 KiB
XML

<?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.app.mapper.PartApplyAppMapper" >
<insert id="addPartApply" useGeneratedKeys="true" keyProperty="id">
INSERT INTO t_part_apply(
code, creator, user_name, create_time, type, remark, status, updater,
update_time, dev_id,dev_code, dev_type, pro_id, pro_name,
apply_num,audit_type)values(
#{code},#{creater},#{userName},now(), #{type},#{remark},#{status},#{updater}, now(),#{deviceId},#{devCode}, #{devType},#{proId},#{proName}
,#{applyNum},#{statusType})
</insert>
<!--差人申请详情-->
<insert id="insertDetails">
insert into t_part_apply_details(
apply_id, part_id, apply_num,remark,
part_type, part_name, part_model,part_unit ) values
<foreach collection="list" item="item" separator=",">
(#{param.id},#{item.partId},#{item.applyNum},#{item.remark},
#{item.partType},#{item.partName},#{item.partModel},#{item.partUnit})
</foreach>
</insert>
<select id="getDevList" resultType="com.bonus.gzgqj.business.app.entity.MachinesVo">
select mm.id ,mt2.NAME name ,mt3.`NAME` type ,mt.name model ,mm.DEVICE_CODE deviceCode
from mm_machines mm
left join mm_type mt on mt.id=mm.TYPE and mt.`LEVEL`=4 and mt.IS_ACTIVE=1
left join mm_type mt2 on mt.PARENT_ID=mt2.id
left join mm_type mt3 on mt2.PARENT_ID=mt3.id
where mm.BATCH_STATUS=7
<if test="keyWord!=null and keyWord!=''">
and (
mt2.NAME like concat('%',#{name},'%') or
mt3.NAME like concat('%',#{type},'%') or
mt.NAME like concat('%',#{model},'%')
)
</if>
</select>
<select id="getWfRecordList" resultType="com.bonus.gzgqj.business.app.entity.MachinesVo">
select wir.sup_id ,wat.AGREEMENT_ID,
wir.id ,pro.`NAME` proName ,pro.Id proId
from wf_info_record wir
LEFT JOIN wf_return_material_details rmd on wir.SUP_ID=rmd.id
LEFT JOIN wf_agreement_task wat on rmd.TASK_ID=wat.TASK_ID
LEFT JOIN wf_lease_agreement wla on wat.AGREEMENT_ID=wla.id
left join bm_project pro on pro.id=wla.PROJECT
where TYPE=4 AND wir.MA_ID=#{id}
ORDER BY wir.TIME DESC
limit 1
</select>
<!--配件下拉选集合-->
<select id="getPaTypeList" 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="keyWord!=null and keyWord!=''">
and (
pt2.name like concat('%',#{type},'%') or
pt1.name like concat('%',#{name},'%') or
pt.name like concat('%',#{model},'%')
)
</if>
</select>
<select id="getSqList" resultType="java.lang.Integer">
select count(1)
from t_part_apply
where DATE_FORMAT(create_time,'%Y-%m-%d')=CURRENT_DATE
</select>
<!--配件申请查询记录-->
<select id="getPartApplyList" resultType="com.bonus.gzgqj.business.app.entity.PartApplyAppVo">
select tpa.id,tpa.code,tpa.creator,tpa.user_name userName,
tpa.create_time createTime,tpa.type ,
tpa.remark,tpa.status ,tpa.updater,
tpa.update_time updateTime,tpa.dev_id deviceId,tpa.dev_code devCode,
tpa.dev_type devType,tpa.pro_id proId,tpa.pro_name proName,
tpa.status_type statusType,tpa.apply_num applyNum,
tpa.zd_user zdUser,fz_user fzUser,ck_user ckUser,zd_time zdTime,fz_time fzTime,ck_time ckTime
FROM t_part_apply tpa
<where>
<if test="keyWord!=null and keyWord!=''">
and (
tpa.code like('%',#{keyWord},'%') or
tpa.user_name like('%',#{keyWord},'%') or
tpa.remark like('%',#{keyWord},'%') or
tpa.pro_name like('%',#{keyWord},'%')
)
</if>
</where>
</select>
<select id="getPartApplyDetails" resultType="com.bonus.gzgqj.business.app.entity.PartApplyAppVo">
select tpa.id,tpa.code,tpa.creator,tpa.user_name userName,
tpa.create_time createTime,tpa.type ,
tpa.remark,tpa.status ,tpa.updater,
tpa.update_time updateTime,tpa.dev_id deviceId,tpa.dev_code devCode,
tpa.dev_type devType,tpa.pro_id proId,tpa.pro_name proName,
tpa.status_type statusType,tpa.apply_num applyNum,
tpa.zd_user zdUser,fz_user fzUser,ck_user ckUser,zd_time zdTime,fz_time fzTime,ck_time ckTime
FROM t_part_apply tpa
where tpa.id=#{id}
</select>
<select id="getDetailsList" resultType="com.bonus.gzgqj.business.app.entity.PartApplyDetailAppVo">
select ppd.id,ppd.apply_id applyId, ppd.part_id partId, ppd.apply_num applyNum,
ppd.part_type partType, ppd.part_name partName, ppd.part_model partModel,
pt.price ,(ppd.apply_num*pt.price ) money
from t_part_apply_details ppd
LEFT JOIN pa_type pt on pt.id=ppd.part_id
where ppd.apply_id=#{id}
</select>
</mapper>