<?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="org.springblade.modules.soldrecord.mapper.SoldrecordMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="soldrecordResultMap" type="org.springblade.modules.soldrecord.entity.Soldrecord">
|
<result column="id" property="id"/>
|
<result column="create_user" property="createUser"/>
|
<result column="create_dept" property="createDept"/>
|
<result column="create_time" property="createTime"/>
|
<result column="update_user" property="updateUser"/>
|
<result column="update_time" property="updateTime"/>
|
<result column="status" property="status"/>
|
<result column="is_deleted" property="isDeleted"/>
|
<result column="stock_id1" property="stockId1"/>
|
<result column="amount1" property="amount1"/>
|
<result column="time1" property="time1"/>
|
<result column="tenant_id1" property="tenantId1"/>
|
<result column="picture1" property="picture1"/>
|
<result column="remarks1" property="remarks1"/>
|
<result column="specs1" property="specs1"/>
|
<result column="specs_val1" property="specsVal1"/>
|
<result column="specs_val2" property="specsVal2"/>
|
</resultMap>
|
|
|
<select id="selectSoldrecordPage" resultMap="soldrecordResultMap">
|
select *
|
from sys_soldrecord
|
where is_deleted = 0
|
</select>
|
|
<select id="selectLists" resultType="org.springblade.modules.soldrecord.vo.SoldrecordVO">
|
SELECT st.stock_id1,
|
st.specs1,
|
SUM(st.amount1 ) AS amount1,
|
stf.factory_name AS factoryName,
|
a.dict_value AS stype,
|
d.dict_value AS dic1,
|
c.dict_value AS dic2,
|
stf.agricultural_name as agrname
|
FROM sys_soldrecord st
|
LEFT JOIN sys_stockfactory stf ON stf.id = st.stock_id1
|
LEFT JOIN (SELECT dict_key, dict_value
|
FROM blade_dict_biz
|
WHERE CODE = 'stockSpecs1' AND is_deleted = 0) d ON d.dict_key = st.specs_val1
|
LEFT JOIN (SELECT dict_key, dict_value
|
FROM blade_dict_biz
|
WHERE CODE = 'stockSpecs2' AND is_deleted = 0) c ON c.dict_key = st.specs_val2
|
LEFT JOIN ( SELECT dict_key, dict_value FROM blade_dict_biz WHERE CODE = 'stockType' AND is_deleted = 0 ) a ON
|
a.dict_key = stf.type
|
WHERE st.is_deleted = 0
|
<if test="soldrecord.stype!=null and soldrecord.stype != ''">
|
and stf.type = #{soldrecord.stype}
|
</if>
|
<if test="soldrecord.stockId1!=null and soldrecord.stockId1 != ''">
|
and st.stock_id1 = #{soldrecord.stockId1}
|
</if>
|
GROUP BY
|
st.stock_id1,
|
st.specs1,
|
stf.factory_name,
|
a.dict_value,
|
d.dict_value,
|
c.dict_value
|
</select>
|
<!--查看变更明细-->
|
<select id="selectListbg" resultType="org.springblade.modules.soldrecord.vo.SoldrecordVO">
|
SELECT st.stock_id1,
|
st.specs1,
|
st.amount1,
|
st.create_time,
|
f.real_name as username,
|
stf.factory_name AS factoryName,
|
stf.type as stype,
|
d.dict_value AS dic1,
|
c.dict_value AS dic2,
|
b.dict_value AS dic3,
|
stf.agricultural_name AS agrname
|
FROM sys_soldrecord st
|
LEFT JOIN sys_stockfactory stf ON stf.id = st.stock_id1
|
LEFT JOIN (SELECT dict_key, dict_value
|
FROM blade_dict_biz
|
WHERE CODE = 'stockSpecs1' AND is_deleted = 0 <if test="soldrecord.codes!=null and soldrecord.codes != ''">
|
AND blade_dict_biz.tenant_id = #{soldrecord.codes}
|
</if>) d ON d.dict_key = st.specs_val1
|
LEFT JOIN (SELECT dict_key, dict_value
|
FROM blade_dict_biz
|
WHERE CODE = 'stockSpecs2' AND is_deleted = 0 <if test="soldrecord.codes!=null and soldrecord.codes != ''">
|
AND blade_dict_biz.tenant_id = #{soldrecord.codes}
|
</if>) c ON c.dict_key = st.specs_val2
|
LEFT JOIN (SELECT dict_key, dict_value
|
FROM blade_dict_biz
|
WHERE CODE = 'stockPurchase1' AND is_deleted = 0 <if test="soldrecord.codes!=null and soldrecord.codes != ''">
|
AND blade_dict_biz.tenant_id = #{soldrecord.codes}
|
</if>) b ON b.dict_key = st.type
|
LEFT JOIN ( SELECT id, real_name FROM blade_user ) f ON f.id=st.create_user
|
LEFT JOIN sys_stockrecord str ON str.sr_id = st.id
|
WHERE st.is_deleted = 0
|
<if test="soldrecord.stockId1!=null and soldrecord.stockId1 != ''">
|
and st.sid= #{soldrecord.stockId1}
|
</if>
|
<if test="soldrecord.deptId != null and soldrecord.deptId !=''">
|
and str.dept_id = #{soldrecord.deptId}
|
</if>
|
ORDER BY st.create_time DESC
|
</select>
|
|
<update id="updateSold">
|
update sys_soldr
|
set amount1=#{amount}, census=#{census}
|
where sid = #{sid}
|
</update>
|
|
<delete id="delc">
|
delete
|
from sys_soldrecord
|
where stock_id1 = #{id}
|
</delete>
|
|
</mapper>
|