diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml index 981e5278..0a5c3d00 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/TypeMapper.xml @@ -1,7 +1,7 @@ + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> @@ -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 @@ -261,8 +261,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" sampling_ratio, is_enter, jiJu_type, - company_id, - + #{typeName}, #{parentId}, @@ -299,8 +298,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{samplingRatio}, #{isEnter}, #{jiJuType}, - #{companyId}, - + @@ -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 - and mt3.company_id = #{deptId} + 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 - and mt2.company_id = #{deptId} + 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 - and mt1.company_id = #{deptId} + order by type_id - - - - - - - - - - - + + + + + + + + + + + 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) + + AND mt.company_id=#{companyId} + + 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' + + AND mt.company_id=#{companyId} + 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 + + AND mt.company_id=#{companyId} + 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 + + AND mt.company_id=#{companyId} + 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 m.del_flag = '0' + + AND m.company_id=#{companyId} + AND m.type_name like concat('%',#{typeName},'%') AND m.type_id = #{typeId} - - AND m.company_id = #{companyId} - @@ -639,44 +653,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 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 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 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 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 and mt1.type_id=#{typeId} @@ -784,17 +798,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 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 - 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"