<?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="zy.cloud.wms.manager.mapper.PriorMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="zy.cloud.wms.manager.entity.Prior">
|
<id column="id" property="id" />
|
<result column="host_id" property="hostId" />
|
<result column="uuid" property="uuid" />
|
<result column="name" property="name" />
|
<result column="mat_id" property="matId" />
|
<result column="matnr" property="matnr" />
|
<result column="maktx" property="maktx" />
|
<result column="node_id" property="nodeId" />
|
<result column="node_name" property="nodeName" />
|
<result column="safe_qua" property="safeQua" />
|
<result column="prio" property="prio" />
|
<result column="barcode" property="barcode" />
|
<result column="status" property="status" />
|
<result column="create_by" property="createBy" />
|
<result column="create_time" property="createTime" />
|
<result column="update_by" property="updateBy" />
|
<result column="update_time" property="updateTime" />
|
<result column="memo" property="memo" />
|
|
</resultMap>
|
|
|
<sql id="pageCondition">
|
<if test="host_id != null and host_id != ''">
|
and mp0.host_id = #{host_id}
|
</if>
|
<if test="matnr != null and matnr != ''">
|
and mp0.matnr like concat('%',#{matnr},'%')
|
</if>
|
<if test="maktx != null and maktx != ''">
|
and mp0.maktx like concat('%',#{maktx},'%')
|
</if>
|
<if test="node_id != null and node_id != ''">
|
and mp0.node_id like concat('%',#{node_id},'%')
|
</if>
|
</sql>
|
|
<select id="selectSafeStoPage" resultType="zy.cloud.wms.manager.entity.SafeStoDo">
|
select * from
|
(
|
select
|
ROW_NUMBER() over (order by isnull(round((dual.amount/mp0.safe_qua),2),0) asc, mp0.maktx) as row,
|
mp0.node_id,
|
mp0.node_name,
|
mp0.matnr,
|
mp0.maktx,
|
mp0.safe_qua,
|
ISNULL(dual.amount, 0) as amount,
|
ISNULL((cast(round((dual.amount/(mp0.safe_qua*1.0))*100,2) as varchar)+'%'), '0.00%') as progress,
|
case
|
when isnull(round((dual.amount/mp0.safe_qua),2),0) >= 1 then 1
|
when isnull(round((dual.amount/mp0.safe_qua),2),0) > 0.75 then 2
|
else 3
|
end as status
|
from man_prior mp0
|
left join
|
(
|
select
|
mp.node_id,
|
mp.matnr,
|
ISNULL(sum(ls.amount), 0) as amount
|
from man_prior mp
|
left join
|
(
|
select
|
mld.node_id,
|
mn.path,
|
mld.matnr,
|
sum(mld.anfme) as amount
|
from man_loc_detl mld
|
left join man_node mn on mld.node_id = mn.id
|
group by mld.node_id, mld.matnr, mn.path
|
) as ls on ls.matnr = mp.matnr and (ls.node_id = mp.node_id or CHARINDEX(','+cast(mp.node_id as varchar)+',', ','+ls.path+',') > 0)
|
group by mp.node_id, mp.matnr
|
) as dual on mp0.node_id = dual.node_id and mp0.matnr = dual.matnr
|
where 1=1
|
<include refid="pageCondition"></include>
|
) t where t.row between ((#{pageNumber}-1)*#{pageSize}+1) and (#{pageNumber}*#{pageSize})
|
</select>
|
|
<select id="selectSafeStoPageCount" resultType="java.lang.Integer">
|
select
|
count(1) as count
|
from man_prior mp0
|
left join
|
(
|
select
|
mp.node_id,
|
mp.matnr,
|
ISNULL(sum(ls.amount), 0) as amount
|
from man_prior mp
|
left join
|
(
|
select
|
mld.node_id,
|
mn.path,
|
mld.matnr,
|
sum(mld.anfme) as amount
|
from man_loc_detl mld
|
left join man_node mn on mld.node_id = mn.id
|
group by mld.node_id, mld.matnr, mn.path
|
) as ls on ls.matnr = mp.matnr and (ls.node_id = mp.node_id or CHARINDEX(','+cast(mp.node_id as varchar)+',', ','+ls.path+',') > 0)
|
group by mp.node_id, mp.matnr
|
) as dual on mp0.node_id = dual.node_id and mp0.matnr = dual.matnr
|
where 1=1
|
<include refid="pageCondition"></include>
|
</select>
|
|
<select id="selectSafeStoExportExcel" resultType="zy.cloud.wms.common.entity.SafeStoExport">
|
select
|
mp0.node_name,
|
mp0.matnr,
|
mp0.maktx,
|
mp0.safe_qua,
|
ISNULL(dual.amount, 0) as amount,
|
ISNULL((cast(round((dual.amount/(mp0.safe_qua*1.0))*100,2) as varchar)+'%'), '0.00%') as progress,
|
case
|
when isnull(round((dual.amount/mp0.safe_qua),2),0) >= 1 then '满仓'
|
when isnull(round((dual.amount/mp0.safe_qua),2),0) > 0.75 then '安全'
|
else '危险'
|
end as status
|
from man_prior mp0
|
left join
|
(
|
select
|
mp.node_id,
|
mp.matnr,
|
ISNULL(sum(ls.amount), 0) as amount
|
from man_prior mp
|
left join
|
(
|
select
|
mld.node_id,
|
mn.path,
|
mld.matnr,
|
sum(mld.anfme) as amount
|
from man_loc_detl mld
|
left join man_node mn on mld.node_id = mn.id
|
group by mld.node_id, mld.matnr, mn.path
|
) as ls on ls.matnr = mp.matnr and (ls.node_id = mp.node_id or CHARINDEX(','+cast(mp.node_id as varchar)+',', ','+ls.path+',') > 0)
|
group by mp.node_id, mp.matnr
|
) as dual on mp0.node_id = dual.node_id and mp0.matnr = dual.matnr
|
where 1=1
|
and mp0.host_id = #{hostId}
|
</select>
|
|
</mapper>
|