jsk 类型规格权限改造 数量变动

This commit is contained in:
jiask 2026-01-09 10:49:06 +08:00
parent a9983a15c6
commit de622211a4
1 changed files with 197 additions and 190 deletions

View File

@ -1,7 +1,7 @@
<?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.bonus.material.ma.mapper.TypeMapper">
<resultMap type="com.bonus.material.ma.domain.Type" id="TypeResult">
@ -192,14 +192,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
WHERE t.type_id = #{typeId} and t.del_flag = 0
GROUP BY t.type_id
limit 1
limit 1
</select>
<select id="selectParentId" resultType="java.lang.Integer">
SELECT DISTINCT
mt2.type_id
mt2.type_id
FROM
ma_type mt
ma_type mt
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id
@ -219,7 +219,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
and mt2.type_id is not null
and mhs.house_id = #{houseId} and mhs.del_flag = 0
<if test="companyId != null">and mt2.company_id = #{companyId} and mhs.company_id = #{companyId}</if>
</where>
</select>
@ -261,8 +261,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="samplingRatio != null">sampling_ratio,</if>
<if test="isEnter != null">is_enter,</if>
<if test="jiJuType != null">jiJu_type,</if>
<if test="companyId != null">company_id,</if>
</trim>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="typeName != null and typeName != ''">#{typeName},</if>
<if test="parentId != null">#{parentId},</if>
@ -299,8 +298,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="samplingRatio != null">#{samplingRatio},</if>
<if test="isEnter != null">#{isEnter},</if>
<if test="jiJuType != null">#{jiJuType},</if>
<if test="companyId != null">#{companyId},</if>
</trim>
</trim>
</insert>
<update id="updateType" parameterType="com.bonus.material.ma.domain.Type">
@ -381,7 +379,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join ma_type mt1 on mt1.type_id=mt2.parent_id
left join wh_house_set whs on mt1.type_id=whs.type_id
where mt3.del_flag = 0 and mt3.level = 3
<if test="deptId != null">and mt3.company_id = #{deptId}</if>
UNION
select
@ -391,7 +389,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join ma_type mt1 on mt1.type_id=mt2.parent_id
left join wh_house_set whs on mt1.type_id=whs.type_id
where mt2.del_flag = 0 and mt2.level = 2
<if test="deptId != null">and mt2.company_id = #{deptId}</if>
UNION
select
@ -400,41 +398,41 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from ma_type mt1
left join wh_house_set whs on mt1.type_id=whs.type_id
where mt1.del_flag = 0 and mt1.level = 1
<if test="deptId != null">and mt1.company_id = #{deptId}</if>
order by type_id
</select>
<!-- <select id="selectMaTypeTree2" resultMap="TypeResult">-->
<!-- select-->
<!-- mt.type_id, mt.type_name, mt.parent_id, mt.storage_num, mt.type_code, mt.model_code, mt.unit_id, mt.unit_name,-->
<!-- mt.manage_type, mt.lease_price, mt.eff_time, mt.rent_price, mt.buy_price, mt.pay_ratio, mt.pay_price,-->
<!-- mt.tax_ratio, mt.level, mt.rated_load, mt.test_load, mt.holding_time, mt.warn_num,-->
<!-- mt.create_by, mt.create_time, mt.update_by, mt.update_time, mt.is_plan,mt.is_ancuo,-->
<!-- mt.remark, mt.fac_model, mt.intelligent_code, whs.house_id-->
<!-- from ma_type mt-->
<!-- left join wh_house_set whs on mt.type_id=whs.type_id-->
<!-- where mt.del_flag = 0 and mt.level != #{level}-->
<!-- </select>-->
<!-- <select id="selectMaTypeTree2" resultMap="TypeResult">-->
<!-- select-->
<!-- mt.type_id, mt.type_name, mt.parent_id, mt.storage_num, mt.type_code, mt.model_code, mt.unit_id, mt.unit_name,-->
<!-- mt.manage_type, mt.lease_price, mt.eff_time, mt.rent_price, mt.buy_price, mt.pay_ratio, mt.pay_price,-->
<!-- mt.tax_ratio, mt.level, mt.rated_load, mt.test_load, mt.holding_time, mt.warn_num,-->
<!-- mt.create_by, mt.create_time, mt.update_by, mt.update_time, mt.is_plan,mt.is_ancuo,-->
<!-- mt.remark, mt.fac_model, mt.intelligent_code, whs.house_id-->
<!-- from ma_type mt-->
<!-- left join wh_house_set whs on mt.type_id=whs.type_id-->
<!-- where mt.del_flag = 0 and mt.level != #{level}-->
<!-- </select>-->
<select id="selectTypeListAndParent" resultMap="MaTypeVoResult">
SELECT
a.*, -- 当前层级的所有字段
b.type_name AS parentThreeLevelName, -- 父层级名称
c.type_name AS parentTwoLevelName, -- 祖父层级名称
d.type_name AS parentOneLevelName, -- 曾祖父层级名称
whi.house_name
a.*, -- 当前层级的所有字段
b.type_name AS parentThreeLevelName, -- 父层级名称
c.type_name AS parentTwoLevelName, -- 祖父层级名称
d.type_name AS parentOneLevelName, -- 曾祖父层级名称
whi.house_name
FROM
ma_type a
ma_type a
LEFT JOIN
wh_house_set whs ON a.type_id = whs.type_id AND whs.del_flag = '0'
wh_house_set whs ON a.type_id = whs.type_id AND whs.del_flag = '0'
LEFT JOIN
wh_house_info whi ON whi.house_id = whs.house_id AND whs.del_flag = '0'
wh_house_info whi ON whi.house_id = whs.house_id AND whs.del_flag = '0'
LEFT JOIN
ma_type b ON a.parent_id = b.type_id and b.del_flag = '0' -- 第一层,父类型
ma_type b ON a.parent_id = b.type_id and b.del_flag = '0' -- 第一层,父类型
LEFT JOIN
ma_type c ON b.parent_id = c.type_id and c.del_flag = '0' -- 第二层,祖父类型
ma_type c ON b.parent_id = c.type_id and c.del_flag = '0' -- 第二层,祖父类型
LEFT JOIN
ma_type d ON c.parent_id = d.type_id and d.del_flag = '0' -- 第三层,曾祖父类型
ma_type d ON c.parent_id = d.type_id and d.del_flag = '0' -- 第三层,曾祖父类型
<where>
<if test="typeName != null and typeName != ''"> and a.type_name like concat('%', #{typeName}, '%')</if>
<if test="parentId != null and parentId != '0' "> and a.parent_id = #{parentId}</if>
@ -467,7 +465,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mt.type_name AS typeName,mt.parent_id AS parentId,mt.level
from
wh_house_set
left join
left join
ma_type mt on wh_house_set.type_id = mt.type_id
where
wh_house_set.house_id = #{mouseId} and wh_house_set.del_flag = 0
@ -495,15 +493,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
whs.house_id,whi.house_name
FROM
ma_type a
LEFT JOIN
LEFT JOIN
wh_house_set whs ON a.type_id = whs.type_id AND whs.del_flag = '0'
LEFT JOIN
LEFT JOIN
wh_house_info whi ON whi.house_id = whs.house_id AND whs.del_flag = '0'
LEFT JOIN
LEFT JOIN
ma_type b ON a.parent_id = b.type_id AND b.del_flag = '0' -- 第一层,父类型
LEFT JOIN
LEFT JOIN
ma_type c ON b.parent_id = c.type_id AND c.del_flag = '0' -- 第二层,祖父类型
LEFT JOIN
LEFT JOIN
ma_type d ON c.parent_id = d.type_id AND d.del_flag = '0' -- 第三层,曾祖父类型
WHERE
a.del_flag = 0 AND a.`level` = '4'
@ -528,29 +526,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectMaTypeList" resultMap="TypeResult">
select DISTINCT m.type_id, m.type_name, m.parent_id, m.unit_id, m.unit_name, m.unit_value,m.manage_type,
m.lease_price,m.eff_time, m.rent_price, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load,
m.holding_time, m.warn_num, m.sort_num,
m.del_flag, m.create_by, m.create_time,
m.remark,m.type_id id , m.type_name label,
CASE m.manage_type
WHEN 0 THEN
IFNULL(subquery0.num, 0)
ELSE
IFNULL(m.storage_num, 0)
END as storage_num,
m.company_id as companyId,
IFNULL(subquery1.pendingOutNum,0) as pendingOutNum,
m.jiju_type
m.lease_price,m.eff_time, m.rent_price, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load,
m.holding_time, m.warn_num, m.sort_num,
m.del_flag, m.create_by, m.create_time,
m.remark,m.type_id id , m.type_name label,
CASE m.manage_type
WHEN 0 THEN
IFNULL(subquery0.num, 0)
ELSE
IFNULL(m.storage_num, 0)
END as storage_num,
m.company_id as companyId,
IFNULL(subquery1.pendingOutNum,0) as pendingOutNum,
m.jiju_type
from ma_type m
left join (SELECT mt.type_id,
mt2.type_name AS typeName,
mt.type_name AS typeModelName,
count(mm.ma_id) num
FROM ma_machine mm
LEFT JOIN ma_type mt ON mt.type_id = mm.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
WHERE mm.ma_code is not null and mm.ma_status in (1)
GROUP BY mt.type_id) AS subquery0 ON subquery0.type_id = m.type_id
left join (SELECT mt.type_id,
mt2.type_name AS typeName,
mt.type_name AS typeModelName,
count(mm.ma_id) num
FROM ma_machine mm
LEFT JOIN ma_type mt ON mt.type_id = mm.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
WHERE mm.ma_code is not null and mm.ma_status in (1)
<if test="companyId != null and companyId !=''">
AND mt.company_id=#{companyId}
</if>
GROUP BY mt.type_id) AS subquery0 ON subquery0.type_id = m.type_id
LEFT JOIN (
SELECT
combined.typeId AS typeId,
@ -564,9 +565,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
lease_apply_info lai
LEFT JOIN lease_apply_details lad ON lad.parent_id = lai.id
LEFT JOIN tm_task tt ON lai.task_id = tt.task_id
left join ma_type mt on lad.type_id=mt.type_id
WHERE
tt.task_status = '3'
AND tt.task_type = '2'
<if test="companyId != null and companyId !=''">
AND mt.company_id=#{companyId}
</if>
GROUP BY
lad.type_id UNION ALL-- 第二个查询
SELECT
@ -580,11 +585,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SUM( lod.out_num ) AS alNum
FROM
lease_out_details lod
left join ma_type mt on lod.type_id=mt.type_id
WHERE
publish_task IS NOT NULL
<if test="companyId != null and companyId !=''">
AND mt.company_id=#{companyId}
</if>
GROUP BY
lod.type_id
) lod ON lpd.new_type = lod.typeId
left join ma_type mt on lpd.new_type=mt.type_id
where 1=1
<if test="companyId != null and companyId !=''">
AND mt.company_id=#{companyId}
</if>
GROUP BY
lpd.new_type
) combined
@ -593,15 +607,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
) subquery1 on subquery1.typeId=m.type_id
<where>
m.del_flag = '0'
<if test="companyId != null and companyId !=''">
AND m.company_id=#{companyId}
</if>
<if test="typeName != null and typeName !=''">
AND m.type_name like concat('%',#{typeName},'%')
</if>
<if test="typeId != null and typeId !=''">
AND m.type_id = #{typeId}
</if>
<if test="companyId != null">
AND m.company_id = #{companyId}
</if>
</where>
</select>
@ -639,44 +653,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getListByTypeName" resultType="com.bonus.material.ma.domain.vo.MaTypeVo">
SELECT DISTINCT
m3.type_name AS itemType,
m2.type_name AS materialType,
m1.type_name AS materialName,
m.type_id AS typeId,
m.storage_num AS storageNum,
m.type_name AS typeName,
m.parent_id as parentId,
m.manage_type as manageType,
m.unit_name as unitName,
m.lease_price as leasePrice,
m.rent_price as rentPrice,
m.eff_time as effTime,
m.buy_price as buyPrice,
m.LEVEL as level,
m.rated_load as ratedLoad,
m.test_load as testLoad,
m.holding_time as holdingTime,
m.remark as remark,whi.house_name as houseName,
m.fac_model AS facModel,su.user_name as keeperNickName,su2.user_name as repairNickName,
m.sort_num as sortNum
m3.type_name AS itemType,
m2.type_name AS materialType,
m1.type_name AS materialName,
m.type_id AS typeId,
m.storage_num AS storageNum,
m.type_name AS typeName,
m.parent_id as parentId,
m.manage_type as manageType,
m.unit_name as unitName,
m.lease_price as leasePrice,
m.rent_price as rentPrice,
m.eff_time as effTime,
m.buy_price as buyPrice,
m.LEVEL as level,
m.rated_load as ratedLoad,
m.test_load as testLoad,
m.holding_time as holdingTime,
m.remark as remark,whi.house_name as houseName,
m.fac_model AS facModel,su.user_name as keeperNickName,su2.user_name as repairNickName,
m.sort_num as sortNum
FROM
ma_type m
LEFT JOIN ma_type m1 ON m.parent_id = m1.type_id and m1.del_flag = '0'
LEFT JOIN ma_type m2 ON m1.parent_id = m2.type_id and m2.del_flag = '0'
LEFT JOIN ma_type m3 ON m2.parent_id = m3.type_id and m3.del_flag = '0'
left join ma_type_keeper mtk on m.type_id = mtk.type_id
left join ma_type_repair mtr on m.type_id = mtr.type_id
left join sys_user su on mtk.user_id = su.user_id
left join sys_user su2 on mtr.user_id = su2.user_id
left join wh_house_set whs on m.type_id = whs.type_id
left join wh_house_info whi on whs.house_id = whi.house_id
ma_type m
LEFT JOIN ma_type m1 ON m.parent_id = m1.type_id and m1.del_flag = '0'
LEFT JOIN ma_type m2 ON m1.parent_id = m2.type_id and m2.del_flag = '0'
LEFT JOIN ma_type m3 ON m2.parent_id = m3.type_id and m3.del_flag = '0'
left join ma_type_keeper mtk on m.type_id = mtk.type_id
left join ma_type_repair mtr on m.type_id = mtr.type_id
left join sys_user su on mtk.user_id = su.user_id
left join sys_user su2 on mtr.user_id = su2.user_id
left join wh_house_set whs on m.type_id = whs.type_id
left join wh_house_info whi on whs.house_id = whi.house_id
WHERE m.parent_id = #{typeId} and m.del_flag = '0'
<if test="type.keyword != null and type.keyword !=''">
AND (m.type_name like concat('%',#{type.keyword},'%')
or m1.type_name like concat('%',#{type.keyword},'%')
or m2.type_name like concat('%',#{type.keyword},'%')
or m3.type_name like concat('%',#{type.keyword},'%')
)
or m1.type_name like concat('%',#{type.keyword},'%')
or m2.type_name like concat('%',#{type.keyword},'%')
or m3.type_name like concat('%',#{type.keyword},'%')
)
</if>
GROUP BY m.type_id
ORDER BY
@ -703,17 +717,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectTypeList4Keeper" parameterType="com.bonus.material.ma.domain.Type" resultMap="TypeResult">
select
mt4.type_id, mt4.type_name, mt4.parent_id, mt4.storage_num, mt4.type_code, mt4.model_code, mt4.unit_id, mt4.unit_name, mt4.manage_type, mt4.lease_price,
mt4.eff_time, mt4.rent_price, mt4.buy_price, mt4.pay_ratio, mt4.pay_price, mt4.tax_ratio, mt4.level, mt4.rated_load, mt4.test_load, mt4.holding_time, mt4.warn_num,
mt4.create_by, mt4.create_time, mt4.update_by, mt4.update_time, mt4.is_plan,mt4.is_ancuo, mt4.remark, mt4.fac_model, mt4.intelligent_code, whs.house_id, whi.house_name,su.nick_name as keeper_nick_name
mt4.type_id, mt4.type_name, mt4.parent_id, mt4.storage_num, mt4.type_code, mt4.model_code, mt4.unit_id, mt4.unit_name, mt4.manage_type, mt4.lease_price,
mt4.eff_time, mt4.rent_price, mt4.buy_price, mt4.pay_ratio, mt4.pay_price, mt4.tax_ratio, mt4.level, mt4.rated_load, mt4.test_load, mt4.holding_time, mt4.warn_num,
mt4.create_by, mt4.create_time, mt4.update_by, mt4.update_time, mt4.is_plan,mt4.is_ancuo, mt4.remark, mt4.fac_model, mt4.intelligent_code, whs.house_id, whi.house_name,su.nick_name as keeper_nick_name
from ma_type mt4
left join ma_type mt3 on mt3.type_id=mt4.parent_id
left join ma_type mt2 on mt2.type_id=mt3.parent_id
left join ma_type mt1 on mt1.type_id=mt2.parent_id
left join wh_house_set whs on mt1.type_id=whs.type_id
left join wh_house_info whi on whs.house_id=whi.house_id
left join ma_type_keeper mtk on mt4.type_id=mtk.type_id
left join sys_user su on mtk.user_id=su.user_id
left join ma_type mt3 on mt3.type_id=mt4.parent_id
left join ma_type mt2 on mt2.type_id=mt3.parent_id
left join ma_type mt1 on mt1.type_id=mt2.parent_id
left join wh_house_set whs on mt1.type_id=whs.type_id
left join wh_house_info whi on whs.house_id=whi.house_id
left join ma_type_keeper mtk on mt4.type_id=mtk.type_id
left join sys_user su on mtk.user_id=su.user_id
where mt4.del_flag = 0 and mt4.level = 4
<if test="level == 1">
and mt1.type_id=#{typeId}
@ -728,14 +742,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
UNION
select
mt3.type_id, mt3.type_name, mt3.parent_id, mt3.storage_num, mt3.type_code, mt3.model_code, mt3.unit_id, mt3.unit_name, mt3.manage_type, mt3.lease_price,
mt3.eff_time, mt3.rent_price, mt3.buy_price, mt3.pay_ratio, mt3.pay_price, mt3.tax_ratio, mt3.level, mt3.rated_load, mt3.test_load, mt3.holding_time, mt3.warn_num,
mt3.create_by, mt3.create_time, mt3.update_by, mt3.update_time, mt3.is_plan,mt3.is_ancuo, mt3.remark, mt3.fac_model, mt3.intelligent_code, whs.house_id, whi.house_name,null as keeper_nick_name
mt3.type_id, mt3.type_name, mt3.parent_id, mt3.storage_num, mt3.type_code, mt3.model_code, mt3.unit_id, mt3.unit_name, mt3.manage_type, mt3.lease_price,
mt3.eff_time, mt3.rent_price, mt3.buy_price, mt3.pay_ratio, mt3.pay_price, mt3.tax_ratio, mt3.level, mt3.rated_load, mt3.test_load, mt3.holding_time, mt3.warn_num,
mt3.create_by, mt3.create_time, mt3.update_by, mt3.update_time, mt3.is_plan,mt3.is_ancuo, mt3.remark, mt3.fac_model, mt3.intelligent_code, whs.house_id, whi.house_name,null as keeper_nick_name
from ma_type mt3
left join ma_type mt2 on mt2.type_id=mt3.parent_id
left join ma_type mt1 on mt1.type_id=mt2.parent_id
left join wh_house_set whs on mt1.type_id=whs.type_id
left join wh_house_info whi on whs.house_id=whi.house_id
left join ma_type mt2 on mt2.type_id=mt3.parent_id
left join ma_type mt1 on mt1.type_id=mt2.parent_id
left join wh_house_set whs on mt1.type_id=whs.type_id
left join wh_house_info whi on whs.house_id=whi.house_id
where mt3.del_flag = 0 and mt3.level = 3
<if test="level == 1">
and mt1.type_id=#{typeId}
@ -750,13 +764,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
UNION
select
mt2.type_id, mt2.type_name, mt2.parent_id, mt2.storage_num, mt2.type_code, mt2.model_code, mt2.unit_id, mt2.unit_name, mt2.manage_type, mt2.lease_price,
mt2.eff_time, mt2.rent_price, mt2.buy_price, mt2.pay_ratio, mt2.pay_price, mt2.tax_ratio, mt2.level, mt2.rated_load, mt2.test_load, mt2.holding_time, mt2.warn_num,
mt2.create_by, mt2.create_time, mt2.update_by, mt2.update_time, mt2.is_plan,mt2.is_ancuo, mt2.remark, mt2.fac_model, mt2.intelligent_code, whs.house_id, whi.house_name, null as keeper_nick_name
mt2.type_id, mt2.type_name, mt2.parent_id, mt2.storage_num, mt2.type_code, mt2.model_code, mt2.unit_id, mt2.unit_name, mt2.manage_type, mt2.lease_price,
mt2.eff_time, mt2.rent_price, mt2.buy_price, mt2.pay_ratio, mt2.pay_price, mt2.tax_ratio, mt2.level, mt2.rated_load, mt2.test_load, mt2.holding_time, mt2.warn_num,
mt2.create_by, mt2.create_time, mt2.update_by, mt2.update_time, mt2.is_plan,mt2.is_ancuo, mt2.remark, mt2.fac_model, mt2.intelligent_code, whs.house_id, whi.house_name, null as keeper_nick_name
from ma_type mt2
left join ma_type mt1 on mt1.type_id=mt2.parent_id
left join wh_house_set whs on mt1.type_id=whs.type_id
left join wh_house_info whi on whs.house_id=whi.house_id
left join ma_type mt1 on mt1.type_id=mt2.parent_id
left join wh_house_set whs on mt1.type_id=whs.type_id
left join wh_house_info whi on whs.house_id=whi.house_id
where mt2.del_flag = 0 and mt2.level = 2
<if test="level == 1">
and mt1.type_id=#{typeId}
@ -768,12 +782,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
UNION
select
mt1.type_id, mt1.type_name, mt1.parent_id, mt1.storage_num, mt1.type_code, mt1.model_code, mt1.unit_id, mt1.unit_name, mt1.manage_type, mt1.lease_price,
mt1.eff_time, mt1.rent_price, mt1.buy_price, mt1.pay_ratio, mt1.pay_price, mt1.tax_ratio, mt1.level, mt1.rated_load, mt1.test_load, mt1.holding_time, mt1.warn_num,
mt1.create_by, mt1.create_time, mt1.update_by, mt1.update_time, mt1.is_plan,mt1.is_ancuo, mt1.remark, mt1.fac_model, mt1.intelligent_code, whs.house_id, whi.house_name,null as keeper_nick_name
mt1.type_id, mt1.type_name, mt1.parent_id, mt1.storage_num, mt1.type_code, mt1.model_code, mt1.unit_id, mt1.unit_name, mt1.manage_type, mt1.lease_price,
mt1.eff_time, mt1.rent_price, mt1.buy_price, mt1.pay_ratio, mt1.pay_price, mt1.tax_ratio, mt1.level, mt1.rated_load, mt1.test_load, mt1.holding_time, mt1.warn_num,
mt1.create_by, mt1.create_time, mt1.update_by, mt1.update_time, mt1.is_plan,mt1.is_ancuo, mt1.remark, mt1.fac_model, mt1.intelligent_code, whs.house_id, whi.house_name,null as keeper_nick_name
from ma_type mt1
left join wh_house_set whs on mt1.type_id=whs.type_id
left join wh_house_info whi on whs.house_id=whi.house_id
left join wh_house_set whs on mt1.type_id=whs.type_id
left join wh_house_info whi on whs.house_id=whi.house_id
where mt1.del_flag = 0 and mt1.level = 1
<if test="level == 1">
and mt1.type_id=#{typeId}
@ -784,17 +798,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectTypeList4Repair" parameterType="com.bonus.material.ma.domain.Type" resultMap="TypeResult">
select
mt4.type_id, mt4.type_name, mt4.parent_id, mt4.storage_num, mt4.type_code, mt4.model_code, mt4.unit_id, mt4.unit_name, mt4.manage_type, mt4.lease_price,
mt4.eff_time, mt4.rent_price, mt4.buy_price, mt4.pay_ratio, mt4.pay_price, mt4.tax_ratio, mt4.level, mt4.rated_load, mt4.test_load, mt4.holding_time, mt4.warn_num,
mt4.create_by, mt4.create_time, mt4.update_by, mt4.update_time, mt4.is_plan,mt4.is_ancuo, mt4.remark, mt4.fac_model, mt4.intelligent_code, whs.house_id, whi.house_name,su.nick_name as repair_nick_name
mt4.type_id, mt4.type_name, mt4.parent_id, mt4.storage_num, mt4.type_code, mt4.model_code, mt4.unit_id, mt4.unit_name, mt4.manage_type, mt4.lease_price,
mt4.eff_time, mt4.rent_price, mt4.buy_price, mt4.pay_ratio, mt4.pay_price, mt4.tax_ratio, mt4.level, mt4.rated_load, mt4.test_load, mt4.holding_time, mt4.warn_num,
mt4.create_by, mt4.create_time, mt4.update_by, mt4.update_time, mt4.is_plan,mt4.is_ancuo, mt4.remark, mt4.fac_model, mt4.intelligent_code, whs.house_id, whi.house_name,su.nick_name as repair_nick_name
from ma_type mt4
left join ma_type mt3 on mt3.type_id=mt4.parent_id
left join ma_type mt2 on mt2.type_id=mt3.parent_id
left join ma_type mt1 on mt1.type_id=mt2.parent_id
left join wh_house_set whs on mt1.type_id=whs.type_id
left join wh_house_info whi on whs.house_id=whi.house_id
left join ma_type_repair mtr on mt4.type_id=mtr.type_id
left join sys_user su on mtr.user_id=su.user_id
left join ma_type mt3 on mt3.type_id=mt4.parent_id
left join ma_type mt2 on mt2.type_id=mt3.parent_id
left join ma_type mt1 on mt1.type_id=mt2.parent_id
left join wh_house_set whs on mt1.type_id=whs.type_id
left join wh_house_info whi on whs.house_id=whi.house_id
left join ma_type_repair mtr on mt4.type_id=mtr.type_id
left join sys_user su on mtr.user_id=su.user_id
where mt4.del_flag = 0 and mt4.level = 4
<if test="level == 1">
and mt1.type_id=#{typeId}
@ -809,14 +823,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
UNION
select
mt3.type_id, mt3.type_name, mt3.parent_id, mt3.storage_num, mt3.type_code, mt3.model_code, mt3.unit_id, mt3.unit_name, mt3.manage_type, mt3.lease_price,
mt3.eff_time, mt3.rent_price, mt3.buy_price, mt3.pay_ratio, mt3.pay_price, mt3.tax_ratio, mt3.level, mt3.rated_load, mt3.test_load, mt3.holding_time, mt3.warn_num,
mt3.create_by, mt3.create_time, mt3.update_by, mt3.update_time, mt3.is_plan,mt3.is_ancuo, mt3.remark, mt3.fac_model, mt3.intelligent_code, whs.house_id, whi.house_name,null as repair_nick_name
mt3.type_id, mt3.type_name, mt3.parent_id, mt3.storage_num, mt3.type_code, mt3.model_code, mt3.unit_id, mt3.unit_name, mt3.manage_type, mt3.lease_price,
mt3.eff_time, mt3.rent_price, mt3.buy_price, mt3.pay_ratio, mt3.pay_price, mt3.tax_ratio, mt3.level, mt3.rated_load, mt3.test_load, mt3.holding_time, mt3.warn_num,
mt3.create_by, mt3.create_time, mt3.update_by, mt3.update_time, mt3.is_plan,mt3.is_ancuo, mt3.remark, mt3.fac_model, mt3.intelligent_code, whs.house_id, whi.house_name,null as repair_nick_name
from ma_type mt3
left join ma_type mt2 on mt2.type_id=mt3.parent_id
left join ma_type mt1 on mt1.type_id=mt2.parent_id
left join wh_house_set whs on mt1.type_id=whs.type_id
left join wh_house_info whi on whs.house_id=whi.house_id
left join ma_type mt2 on mt2.type_id=mt3.parent_id
left join ma_type mt1 on mt1.type_id=mt2.parent_id
left join wh_house_set whs on mt1.type_id=whs.type_id
left join wh_house_info whi on whs.house_id=whi.house_id
where mt3.del_flag = 0 and mt3.level = 3
<if test="level == 1">
and mt1.type_id=#{typeId}
@ -831,13 +845,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
UNION
select
mt2.type_id, mt2.type_name, mt2.parent_id, mt2.storage_num, mt2.type_code, mt2.model_code, mt2.unit_id, mt2.unit_name, mt2.manage_type, mt2.lease_price,
mt2.eff_time, mt2.rent_price, mt2.buy_price, mt2.pay_ratio, mt2.pay_price, mt2.tax_ratio, mt2.level, mt2.rated_load, mt2.test_load, mt2.holding_time, mt2.warn_num,
mt2.create_by, mt2.create_time, mt2.update_by, mt2.update_time, mt2.is_plan,mt2.is_ancuo, mt2.remark, mt2.fac_model, mt2.intelligent_code, whs.house_id, whi.house_name, null as repair_nick_name
mt2.type_id, mt2.type_name, mt2.parent_id, mt2.storage_num, mt2.type_code, mt2.model_code, mt2.unit_id, mt2.unit_name, mt2.manage_type, mt2.lease_price,
mt2.eff_time, mt2.rent_price, mt2.buy_price, mt2.pay_ratio, mt2.pay_price, mt2.tax_ratio, mt2.level, mt2.rated_load, mt2.test_load, mt2.holding_time, mt2.warn_num,
mt2.create_by, mt2.create_time, mt2.update_by, mt2.update_time, mt2.is_plan,mt2.is_ancuo, mt2.remark, mt2.fac_model, mt2.intelligent_code, whs.house_id, whi.house_name, null as repair_nick_name
from ma_type mt2
left join ma_type mt1 on mt1.type_id=mt2.parent_id
left join wh_house_set whs on mt1.type_id=whs.type_id
left join wh_house_info whi on whs.house_id=whi.house_id
left join ma_type mt1 on mt1.type_id=mt2.parent_id
left join wh_house_set whs on mt1.type_id=whs.type_id
left join wh_house_info whi on whs.house_id=whi.house_id
where mt2.del_flag = 0 and mt2.level = 2
<if test="level == 1">
and mt1.type_id=#{typeId}
@ -849,12 +863,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
UNION
select
mt1.type_id, mt1.type_name, mt1.parent_id, mt1.storage_num, mt1.type_code, mt1.model_code, mt1.unit_id, mt1.unit_name, mt1.manage_type, mt1.lease_price,
mt1.eff_time, mt1.rent_price, mt1.buy_price, mt1.pay_ratio, mt1.pay_price, mt1.tax_ratio, mt1.level, mt1.rated_load, mt1.test_load, mt1.holding_time, mt1.warn_num,
mt1.create_by, mt1.create_time, mt1.update_by, mt1.update_time, mt1.is_plan,mt1.is_ancuo, mt1.remark, mt1.fac_model, mt1.intelligent_code, whs.house_id, whi.house_name,null as repair_nick_name
mt1.type_id, mt1.type_name, mt1.parent_id, mt1.storage_num, mt1.type_code, mt1.model_code, mt1.unit_id, mt1.unit_name, mt1.manage_type, mt1.lease_price,
mt1.eff_time, mt1.rent_price, mt1.buy_price, mt1.pay_ratio, mt1.pay_price, mt1.tax_ratio, mt1.level, mt1.rated_load, mt1.test_load, mt1.holding_time, mt1.warn_num,
mt1.create_by, mt1.create_time, mt1.update_by, mt1.update_time, mt1.is_plan,mt1.is_ancuo, mt1.remark, mt1.fac_model, mt1.intelligent_code, whs.house_id, whi.house_name,null as repair_nick_name
from ma_type mt1
left join wh_house_set whs on mt1.type_id=whs.type_id
left join wh_house_info whi on whs.house_id=whi.house_id
left join wh_house_set whs on mt1.type_id=whs.type_id
left join wh_house_info whi on whs.house_id=whi.house_id
where mt1.del_flag = 0 and mt1.level = 1
<if test="level == 1">
and mt1.type_id=#{typeId}
@ -882,17 +896,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectByTypeId" resultType="com.bonus.material.ma.domain.Type">
select
type_id as typeId,
type_name as typeName,
parent_id as parentId,
storage_num as storageNum,
manage_type as manageType,
unit_name as unitName,
jiju_type as jijuType,
is_check as isCheck
type_id as typeId,
type_name as typeName,
parent_id as parentId,
storage_num as storageNum,
manage_type as manageType,
unit_name as unitName,
jiju_type as jijuType,
is_check as isCheck
from ma_type
WHERE
type_id = #{record.typeId}
type_id = #{record.typeId}
</select>
<select id="getMaType" resultType="com.bonus.material.ma.domain.Type">
@ -982,7 +996,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="maId != null">ma_id,</if>
create_time,
<if test="createBy != null and createBy != ''">creater,</if>
<if test="companyId != null">company_id,</if>
<if test="style != null and style != ''">style,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
@ -998,7 +1011,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="maId != null">#{maId},</if>
NOW(),
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="companyId != null">#{companyId},</if>
<if test="style != null and style != ''">#{style},</if>
</trim>
</insert>
@ -1019,7 +1031,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null">status,</if>
<if test="createBy != null and createBy != ''">creator,</if>
<if test="resultMsg != null and resultMsg != ''">result_msg,</if>
<if test="companyId != null">company_id,</if>
<if test="inputType != null">input_type,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
@ -1036,22 +1047,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null">#{status},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="resultMsg != null and resultMsg != ''">#{resultMsg},</if>
<if test="companyId != null">#{companyId},</if>
<if test="inputType != null">#{inputType},</if>
</trim>
</insert>
<insert id="addStockNum">
UPDATE ma_type SET storage_num = ifnull(#{inputNum},0) + ifnull(storage_num, 0) WHERE type_id = #{typeId}
UPDATE ma_type SET storage_num = ifnull(#{inputNum},0) + ifnull(storage_num, 0) WHERE type_id = #{typeId}
</insert>
<select id="getMaTypeHistoryListBy" resultType="com.bonus.material.ma.domain.MaTypeHistory">
select
mth.id, mth.type_id as typeId, mth.before_price as beforePrice, mth.after_price as afterPrice,
mth.create_time as createTime, mth.create_by as createBy,
mt4.type_name as maModel, mt3.type_name as maName, mt2.type_name as maType
mth.id, mth.type_id as typeId, mth.before_price as beforePrice, mth.after_price as afterPrice,
mth.create_time as createTime, mth.create_by as createBy,
mt4.type_name as maModel, mt3.type_name as maName, mt2.type_name as maType
from
ma_type_history mth
ma_type_history mth
left join ma_type mt4 on mt4.type_id = mth.type_id and mt4.level = 4 and mt4.del_flag = 0
left join ma_type mt3 on mt3.type_id = mt4.parent_id and mt3.level = 3 and mt3.del_flag = 0
left join ma_type mt2 on mt2.type_id = mt3.parent_id and mt2.level = 2 and mt2.del_flag = 0
@ -1176,25 +1186,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- 批量查询数量 - 性能优化 -->
<select id="getNumListBatch" resultType="com.bonus.material.ma.domain.Type">
SELECT
mt.type_id as typeId,
SUM(sai.num) AS useNum
mt.type_id as typeId,
SUM(sai.num) AS useNum
FROM
ma_type mt
LEFT JOIN clz_slt_agreement_info sai ON mt.type_id = sai.type_id
ma_type mt
LEFT JOIN clz_slt_agreement_info sai ON mt.type_id = sai.type_id
WHERE
sai.STATUS = '0'
AND mt.type_id IN
<foreach collection="typeIds" item="typeId" open="(" separator="," close=")">
#{typeId}
</foreach>
<foreach collection="typeIds" item="typeId" open="(" separator="," close=")">
#{typeId}
</foreach>
AND sai.agreement_id in
<foreach item="id" collection="agreementIds" open="(" separator="," close=")">
#{id}
</foreach>
GROUP BY
mt.type_id
mt.type_id
HAVING
useNum > 0
useNum > 0
</select>
<select id="getUserList" resultType="com.bonus.material.ma.domain.vo.MaTypeVo">
@ -1306,9 +1316,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
WHERE m.del_flag = '0'
<if test="list != null and list.size > 0">
and m.parent_id in
<foreach item="id" collection="list" open="(" separator="," close=")">
#{id}
</foreach>
<foreach item="id" collection="list" open="(" separator="," close=")">
#{id}
</foreach>
</if>
<if test="type.keyword != null and type.keyword !=''">
AND (m.type_name like concat('%',#{type.keyword},'%')
@ -1317,9 +1327,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
or m3.type_name like concat('%',#{type.keyword},'%')
)
</if>
<if test="type.companyId != null">
and m.company_id = #{type.companyId}
</if>
GROUP BY m.type_id
ORDER BY
m.sort_num ASC,
@ -1344,7 +1351,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND su2.del_flag = 0
WHERE
t.del_flag = 0 AND t.parent_id = #{parentId}
LIMIT 1
LIMIT 1
</select>
<select id="getUserDeptId" resultType="com.bonus.system.api.domain.SysUser">
SELECT