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

236 lines
10 KiB
XML
Raw Normal View History

2024-11-12 16:38:35 +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.app.mapper.PartApplyAppMapper" >
2024-11-12 20:19:09 +08:00
<insert id="addPartApply" useGeneratedKeys="true" keyProperty="id">
INSERT INTO t_part_apply(
code, creator, user_name, create_time, type, remark, status, updater,
2024-11-16 16:53:04 +08:00
update_time,
<if test="deviceId!=null and deviceId!=''">
dev_id,
</if>
dev_code, dev_type,
<if test="proId!=null and proId!=''">
2025-03-07 10:46:14 +08:00
pro_id,
2024-11-16 16:53:04 +08:00
</if>
pro_name,
apply_num,status_type)values(
#{code},#{creator},#{userName},now(), #{type},#{remark},#{status},#{updater}, now(),
<if test="deviceId!=null and deviceId!=''">
#{deviceId},
</if>
#{devCode}, #{devType},
<if test="proId!=null and proId!=''">
#{proId},
</if>
2025-03-07 10:46:14 +08:00
#{proName},#{applyNum},#{statusType})
2024-11-12 20:19:09 +08:00
</insert>
<!--差人申请详情-->
<insert id="insertDetails">
2024-11-13 16:26:51 +08:00
insert into t_part_apply_details(
2024-11-14 19:03:07 +08:00
apply_id, part_id, apply_num,remark,
2024-11-13 16:26:51 +08:00
part_type, part_name, part_model,part_unit ) values
2024-11-12 20:19:09 +08:00
<foreach collection="list" item="item" separator=",">
2024-11-14 19:03:07 +08:00
(#{param.id},#{item.partId},#{item.applyNum},#{item.remark},
2024-11-13 16:26:51 +08:00
#{item.partType},#{item.partName},#{item.partModel},#{item.partUnit})
2024-11-12 20:19:09 +08:00
</foreach>
</insert>
<update id="updatePartApply">
update t_part_apply set
<if test="userName!=null and userName!=''">
user_name=#{userName},
</if>
<if test="type!=null and type!=''">
type=#{type},
</if>
<if test="remark!=null and remark!=''">
remark=#{remark},
</if>
<if test="status!=null and status!=''">
status=#{status},
</if>
<if test="updater!=null and updater!=''">
updater=#{updater},
</if>
<if test="deviceId!=null and deviceId!=''">
dev_id=#{deviceId},
</if>
<if test="devCode!=null and devCode!=''">
dev_code=#{devCode},
</if>
<if test="proId!=null and proId!=''">
pro_id=#{proId},
</if>
<if test="proName!=null and proName!=''">
pro_name=#{proName},
</if>
<if test="applyNum!=null and applyNum!=''">
apply_num=#{applyNum},
</if>
<if test="statusType!=null and statusType!=''">
status_type=#{statusType},
</if>
<if test="devType!=null and devType!=''">
dev_type=#{devType},
</if>
update_time=NOW()
where id=#{id}
</update>
<delete id="deleteDetails">
DELETE
FROM t_part_apply_details
WHERE apply_id = #{id}
</delete>
2024-11-12 20:19:09 +08:00
2024-11-12 16:38:35 +08:00
<select id="getDevList" resultType="com.bonus.gzgqj.business.app.entity.MachinesVo">
2025-03-07 10:46:14 +08:00
SELECT
mm.id,
2025-03-26 14:15:06 +08:00
mm.DEVICE_CODE deviceCode,mm.REMARK as remark,
2025-03-07 10:46:14 +08:00
concat(mt3.NAME,'/',mt2.NAME,'/',mt.NAME) module
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
2025-03-26 14:15:06 +08:00
<if test="deviceCode!=null and deviceCode!=''">
and mm.DEVICE_CODE like concat('%',#{deviceCode},'%')
</if>
<if test="remark!=null and remark!=''">
and mm.REMARK like concat('%',#{remark},'%')
</if>
2025-03-07 10:46:14 +08:00
<if test="keyWord!=null and keyWord!=''">
and (
mt2.NAME like concat('%',#{keyWord},'%') or
mt3.NAME like concat('%',#{keyWord},'%') or
mm.DEVICE_CODE like concat('%',#{keyWord},'%') or
2025-07-15 20:27:42 +08:00
mt.NAME like concat('%',#{keyWord},'%') or
mm.REMARK like concat('%',#{keyWord},'%')
2025-03-07 10:46:14 +08:00
)
</if>
2024-11-12 16:38:35 +08:00
</select>
2024-11-16 13:45:52 +08:00
<select id="getDevInfoById" resultType="com.bonus.gzgqj.business.app.entity.MachinesVo">
select mm.id ,mt2.NAME name ,mt3.`NAME` type ,mt.name module ,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 and mm.id=#{devId}
</select>
2024-11-12 16:48:06 +08:00
<select id="getWfRecordList" resultType="com.bonus.gzgqj.business.app.entity.MachinesVo">
2024-11-12 16:38:35 +08:00
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
2024-11-12 16:48:06 +08:00
</select>
<!--配件下拉选集合-->
<select id="getPaTypeList" resultType="com.bonus.gzgqj.business.bases.entity.PaTypeVo">
2024-11-12 20:19:09 +08:00
select pt.id, pt.parent_id parentId,pt.name model ,pt.num,
pt.price,pt.unit ,pt.weight,pt.is_consumables ,
2025-07-14 18:40:16 +08:00
pt.remarks,pt.is_active ,pt.level,pt.warn_num,pt1.`name` name ,pt2.name type,
pt.remarks
2024-11-12 20:19:09 +08:00
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
2024-11-15 18:23:52 +08:00
<if test="keyWord!=null and keyWord!=''">
and (
2024-11-16 14:38:06 +08:00
pt2.name like concat('%',#{keyWord},'%') or
pt1.name like concat('%',#{keyWord},'%') or
2025-07-14 18:40:16 +08:00
pt.name like concat('%',#{keyWord},'%') or
pt.remarks like concat('%',#{keyWord},'%')
2024-11-15 18:23:52 +08:00
)
</if>
<if test="name!=null and name!=''">
and (
pt2.name like concat('%',#{name},'%') or
pt1.name like concat('%',#{name},'%') or
pt.name like concat('%',#{name},'%')
)
</if>
2024-11-12 20:19:09 +08:00
</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
2024-11-12 16:48:06 +08:00
2024-11-12 16:38:35 +08:00
</select>
2024-11-12 20:19:09 +08:00
<!--配件申请查询记录-->
<select id="getPartApplyList" resultType="com.bonus.gzgqj.business.app.entity.PartApplyAppVo">
select tpa.id,tpa.code,tpa.creator,tpa.user_name userName,
2024-11-16 13:45:52 +08:00
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,
CASE tpa.status
when 1 THEN '待审核'
when 2 THEN '待出库'
when 3 THEN '已驳回'
when 4 THEN '已出库'
else '待审核'
END as statusName,
CASE tpa.type
when 0 then '设备'
when 1 then '工器具'
else '工器具'
END as typeName
2024-11-12 20:19:09 +08:00
FROM t_part_apply tpa
<where>
<if test="status != null and status !='' ">
tpa.status = #{status}
</if>
2024-11-12 20:19:09 +08:00
<if test="keyWord!=null and keyWord!=''">
and (
2024-11-16 17:31:50 +08:00
tpa.code like concat('%',#{keyWord},'%') or
2025-03-07 10:46:14 +08:00
tpa.user_name like concat('%',#{keyWord},'%')
2024-11-12 20:19:09 +08:00
)
</if>
2025-03-07 10:46:14 +08:00
<if test="startDay!=null and startDay!='' and endDay!=null and endDay!='' ">
and STR_TO_DATE(tpa.create_time, '%Y-%m-%d') between STR_TO_DATE(#{startDay} ,'%Y-%m-%d') AND STR_TO_DATE(#{endDay},'%Y-%m-%d')
</if>
2024-11-12 20:19:09 +08:00
</where>
order by tpa.create_time desc
2024-11-12 20:19:09 +08:00
</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,
2024-11-16 13:45:52 +08:00
tpa.zd_user ,fz_user ,ck_user ,zd_time zdTime,fz_time fzTime,ck_time ckTime,
CASE tpa.status when 1 THEN '待审核' when 2 THEN '待出库'
when 3 THEN '已驳回' when 4 THEN '已出库' else '待审核' END as statusName,
CASE tpa.type when 0 then '设备' when 1 then '工器具' else '工器具' END as typeName,
pu2.LOGIN_NAME zdUser,pu3.LOGIN_NAME ckUser,pu4.LOGIN_NAME fzUser
2024-11-12 20:19:09 +08:00
FROM t_part_apply tpa
2024-11-16 13:45:52 +08:00
left join pm_user pu on tpa.creator=pu.id -- 领用人
left join pm_user pu2 on tpa.zd_user=pu2.id -- 制单人
left join pm_user pu3 on tpa.ck_user=pu3.id -- 出库人
left join pm_user pu4 on tpa.fz_user=pu4.id -- 审核人
2024-11-12 20:19:09 +08:00
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,
2024-11-16 13:45:52 +08:00
ppd.part_type partType, ppd.part_name partName, ppd.part_model partModel,ppd.part_unit partUnit,
pt.price ,(ppd.apply_num*pt.price ) money,pt.num
2024-11-12 20:19:09 +08:00
from t_part_apply_details ppd
LEFT JOIN pa_type pt on pt.id=ppd.part_id
where ppd.apply_id=#{id}
</select>
2024-11-12 16:38:35 +08:00
</mapper>