|
@@ -3,7 +3,7 @@
|
|
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
<mapper namespace="com.ktg.mes.wm.mapper.WmStockTakingResultMapper">
|
|
<mapper namespace="com.ktg.mes.wm.mapper.WmStockTakingResultMapper">
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
<resultMap type="WmStockTakingResult" id="WmStockTakingResultResult">
|
|
<resultMap type="WmStockTakingResult" id="WmStockTakingResultResult">
|
|
|
<result property="resultId" column="result_id" />
|
|
<result property="resultId" column="result_id" />
|
|
|
<result property="takingId" column="taking_id" />
|
|
<result property="takingId" column="taking_id" />
|
|
@@ -33,7 +33,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
|
|
|
<select id="selectWmStockTakingResultList" parameterType="WmStockTakingResult" resultMap="WmStockTakingResultResult">
|
|
<select id="selectWmStockTakingResultList" parameterType="WmStockTakingResult" resultMap="WmStockTakingResultResult">
|
|
|
<include refid="selectWmStockTakingResultVo"/>
|
|
<include refid="selectWmStockTakingResultVo"/>
|
|
|
- <where>
|
|
|
|
|
|
|
+ <where>
|
|
|
<if test="takingId != null "> and taking_id = #{takingId}</if>
|
|
<if test="takingId != null "> and taking_id = #{takingId}</if>
|
|
|
<if test="itemId != null "> and item_id = #{itemId}</if>
|
|
<if test="itemId != null "> and item_id = #{itemId}</if>
|
|
|
<if test="itemCode != null and itemCode != ''"> and item_code = #{itemCode}</if>
|
|
<if test="itemCode != null and itemCode != ''"> and item_code = #{itemCode}</if>
|
|
@@ -46,7 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="takingStatus != null and takingStatus != ''"> and taking_status = #{takingStatus}</if>
|
|
<if test="takingStatus != null and takingStatus != ''"> and taking_status = #{takingStatus}</if>
|
|
|
</where>
|
|
</where>
|
|
|
</select>
|
|
</select>
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
<select id="selectWmStockTakingResultByResultId" parameterType="Long" resultMap="WmStockTakingResultResult">
|
|
<select id="selectWmStockTakingResultByResultId" parameterType="Long" resultMap="WmStockTakingResultResult">
|
|
|
<include refid="selectWmStockTakingResultVo"/>
|
|
<include refid="selectWmStockTakingResultVo"/>
|
|
|
where result_id = #{resultId}
|
|
where result_id = #{resultId}
|
|
@@ -55,8 +55,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<insert id="calculateOpenWmStockTakingResult" parameterType="Long" useGeneratedKeys="true">
|
|
<insert id="calculateOpenWmStockTakingResult" parameterType="Long" useGeneratedKeys="true">
|
|
|
insert into wm_stock_taking_result (taking_id,item_id,item_code,item_name,specification,taking_quantity,quantity,taking_status)
|
|
insert into wm_stock_taking_result (taking_id,item_id,item_code,item_name,specification,taking_quantity,quantity,taking_status)
|
|
|
select sl.taking_id,sl.item_id,sl.item_code,sl.item_name,sl.specification,taking_quantity,quantity,
|
|
select sl.taking_id,sl.item_id,sl.item_code,sl.item_name,sl.specification,taking_quantity,quantity,
|
|
|
- case when IFNULL(taking_quantity,0) > IFNULL(quantity,0) then 'PROFIT'
|
|
|
|
|
- when IFNULL(taking_quantity,0) < IFNULL(quantity,0) then 'LOSS'
|
|
|
|
|
|
|
+ case when ISNULL(taking_quantity,0) > ISNULL(quantity,0) then 'PROFIT'
|
|
|
|
|
+ when ISNULL(taking_quantity,0) < ISNULL(quantity,0) then 'LOSS'
|
|
|
else 'NORMAL' end as taking_status
|
|
else 'NORMAL' end as taking_status
|
|
|
from wm_stock_taking_line sl
|
|
from wm_stock_taking_line sl
|
|
|
where sl.taking_id = #{takingId}
|
|
where sl.taking_id = #{takingId}
|
|
@@ -64,10 +64,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
|
|
|
<insert id="calculateWmStockTakingResult" parameterType="Long" useGeneratedKeys="true">
|
|
<insert id="calculateWmStockTakingResult" parameterType="Long" useGeneratedKeys="true">
|
|
|
insert into wm_stock_taking_result (item_id,item_code,item_name,specification,taking_quantity,quantity,taking_status)
|
|
insert into wm_stock_taking_result (item_id,item_code,item_name,specification,taking_quantity,quantity,taking_status)
|
|
|
- select IFNULL(m.item_id,t.item_id) as item_id, IFNULL(m.item_code,t.item_code) as item_code,IFNULL(m.item_name,t.item_name) as item_name,IFNULL(m.specification,t.specification) as specification,
|
|
|
|
|
- IFNULL(t.taking_quantity,0) as taking_quantity,IFNULL(m.onhand,0) as quantity,
|
|
|
|
|
- case when IFNULL(t.taking_quantity,0) > IFNULL(m.onhand,0) then 'PROFIT'
|
|
|
|
|
- when IFNULL(t.taking_quantity,0) < IFNULL(m.onhand,0) then 'LOSS'
|
|
|
|
|
|
|
+ select ISNULL(m.item_id,t.item_id) as item_id, ISNULL(m.item_code,t.item_code) as item_code,ISNULL(m.item_name,t.item_name) as item_name,ISNULL(m.specification,t.specification) as specification,
|
|
|
|
|
+ ISNULL(t.taking_quantity,0) as taking_quantity,ISNULL(m.onhand,0) as quantity,
|
|
|
|
|
+ case when ISNULL(t.taking_quantity,0) > ISNULL(m.onhand,0) then 'PROFIT'
|
|
|
|
|
+ when ISNULL(t.taking_quantity,0) < ISNULL(m.onhand,0) then 'LOSS'
|
|
|
else 'NORMAL' end as taking_status
|
|
else 'NORMAL' end as taking_status
|
|
|
from (
|
|
from (
|
|
|
select sl.item_id,sl.item_code,sl.item_name,sl.specification,sum(sl.taking_quantity) as taking_quantity
|
|
select sl.item_id,sl.item_code,sl.item_name,sl.specification,sum(sl.taking_quantity) as taking_quantity
|
|
@@ -91,10 +91,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
|
|
|
union
|
|
union
|
|
|
|
|
|
|
|
- select IFNULL(t.item_id,m.item_id) as item_id,IFNULL(t.item_code,m.item_code) as item_code,IFNULL(t.item_name,m.item_name) as item_name,IFNULL(t.specification,m.specification) as specification,
|
|
|
|
|
- IFNULL(t.taking_quantity,0) as taking_quantity,IFNULL(m.onhand,0) as quantity,
|
|
|
|
|
- case when IFNULL(t.taking_quantity,0) > IFNULL(m.onhand,0) then 'PROFIT'
|
|
|
|
|
- when IFNULL(t.taking_quantity,0) < IFNULL(m.onhand,0) then 'LOSS'
|
|
|
|
|
|
|
+ select ISNULL(t.item_id,m.item_id) as item_id,ISNULL(t.item_code,m.item_code) as item_code,ISNULL(t.item_name,m.item_name) as item_name,ISNULL(t.specification,m.specification) as specification,
|
|
|
|
|
+ ISNULL(t.taking_quantity,0) as taking_quantity,ISNULL(m.onhand,0) as quantity,
|
|
|
|
|
+ case when ISNULL(t.taking_quantity,0) > ISNULL(m.onhand,0) then 'PROFIT'
|
|
|
|
|
+ when ISNULL(t.taking_quantity,0) < ISNULL(m.onhand,0) then 'LOSS'
|
|
|
else 'NORMAL' end as taking_status
|
|
else 'NORMAL' end as taking_status
|
|
|
from (
|
|
from (
|
|
|
select ms.item_id,ms.item_code,ms.item_name,ms.specification,sum(ms.quantity_onhand) as onhand
|
|
select ms.item_id,ms.item_code,ms.item_name,ms.specification,sum(ms.quantity_onhand) as onhand
|
|
@@ -116,7 +116,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
and t.item_code = m.item_code
|
|
and t.item_code = m.item_code
|
|
|
where m.onhand !=0
|
|
where m.onhand !=0
|
|
|
</insert>
|
|
</insert>
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
<insert id="insertWmStockTakingResult" parameterType="WmStockTakingResult" useGeneratedKeys="true" keyProperty="resultId">
|
|
<insert id="insertWmStockTakingResult" parameterType="WmStockTakingResult" useGeneratedKeys="true" keyProperty="resultId">
|
|
|
insert into wm_stock_taking_result
|
|
insert into wm_stock_taking_result
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
@@ -194,7 +194,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</delete>
|
|
</delete>
|
|
|
|
|
|
|
|
<delete id="deleteWmStockTakingResultByResultIds" parameterType="String">
|
|
<delete id="deleteWmStockTakingResultByResultIds" parameterType="String">
|
|
|
- delete from wm_stock_taking_result where result_id in
|
|
|
|
|
|
|
+ delete from wm_stock_taking_result where result_id in
|
|
|
<foreach item="resultId" collection="array" open="(" separator="," close=")">
|
|
<foreach item="resultId" collection="array" open="(" separator="," close=")">
|
|
|
#{resultId}
|
|
#{resultId}
|
|
|
</foreach>
|
|
</foreach>
|
|
@@ -203,4 +203,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<delete id="deleteWmStockTakingResultByTakingId" parameterType="Long">
|
|
<delete id="deleteWmStockTakingResultByTakingId" parameterType="Long">
|
|
|
delete from wm_stock_taking_result where taking_id = #{takingId}
|
|
delete from wm_stock_taking_result where taking_id = #{takingId}
|
|
|
</delete>
|
|
</delete>
|
|
|
-</mapper>
|
|
|
|
|
|
|
+</mapper>
|