|
@@ -10,8 +10,8 @@
|
|
|
t3.Purpose AS Purpose,
|
|
|
t4.`Name` AS materialCategoryName,
|
|
|
t4.ID,
|
|
|
- ( SELECT count( 1 ) FROM supplier_problem WHERE SupplierId = t1.id ) AS warningCount,
|
|
|
- ( SELECT SUM(ProblemTypeCount) FROM supplier_problem WHERE SupplierId = t1.id ) AS warningTypeCount,
|
|
|
+ (<include refid="warningCount_filed"/> ) AS warningCount,
|
|
|
+ (<include refid="warningTypeCount_filed"/> ) AS warningTypeCount,
|
|
|
(select `Name` from material_category where `Code` = t1.CategoryCode) AS categoryName
|
|
|
FROM
|
|
|
supplier t1
|
|
@@ -34,13 +34,12 @@
|
|
|
</select>
|
|
|
<select id="getPurList" resultType="com.fjhx.entity.supplier.Supplier">
|
|
|
SELECT
|
|
|
- t1.ID,
|
|
|
- t1.`Name`,
|
|
|
+ t1.*
|
|
|
t3.CategoryCode,
|
|
|
t3.TechnologyType AS TechnologyType,
|
|
|
t3.Purpose AS purpose,
|
|
|
- ( SELECT count( 1 ) FROM supplier_problem WHERE SupplierId = t1.id ) AS warningCount,
|
|
|
- ( SELECT SUM(ProblemTypeCount) FROM supplier_problem WHERE SupplierId = t1.id ) AS warningTypeCount,
|
|
|
+ (<include refid="warningCount_filed"/> ) AS warningCount,
|
|
|
+ (<include refid="warningTypeCount_filed"/> ) AS warningTypeCount,
|
|
|
FORMAT(IFNULL((<include refid="sumMoney_filed"/>),0),2)AS sumMoney,
|
|
|
FORMAT(IFNULL((<include refid="lastYearMoney_filed"/>),0),2)AS lastYearMoney,
|
|
|
FORMAT(IFNULL((<include refid="yearMoney_filed"/>),0),2)AS yearMoney,
|
|
@@ -77,6 +76,133 @@
|
|
|
GROUP BY
|
|
|
t3.TechnologyType
|
|
|
</select>
|
|
|
+ <select id="getSuById" resultType="com.fjhx.entity.supplier.Supplier">
|
|
|
+ SELECT
|
|
|
+ t1.*,
|
|
|
+ ( <include refid="warningCount_filed"/> ) AS warningCount,
|
|
|
+ ( <include refid="warningTypeCount_filed"/> ) AS warningTypeCount
|
|
|
+ FROM
|
|
|
+ supplier t1
|
|
|
+ WHERE IsDelete = 0
|
|
|
+ AND id = #{id}
|
|
|
+ </select>
|
|
|
+ <select id="getMaterialTypeCount" resultType="java.lang.Integer">
|
|
|
+ SELECT
|
|
|
+ count( 1 )
|
|
|
+ FROM
|
|
|
+ (SELECT
|
|
|
+ count( 1 )
|
|
|
+ FROM
|
|
|
+ supplier t1
|
|
|
+ LEFT JOIN purchase_contract t2 ON t1.ID = t2.SupplierId
|
|
|
+ WHERE
|
|
|
+ t1.`id` = #{id}
|
|
|
+ GROUP BY
|
|
|
+ t2.MaterialCode
|
|
|
+ ) AS t1
|
|
|
+ </select>
|
|
|
+ <select id="getBackCount" resultType="java.lang.Integer">
|
|
|
+ SELECT
|
|
|
+ count(1)
|
|
|
+ FROM
|
|
|
+ supplier t1
|
|
|
+ LEFT JOIN purchase_contract t2 ON t1.ID = t2.SupplierId
|
|
|
+ LEFT JOIN apply_scenebackdetail t3 ON t2.PurchaseBillNo = t3.PurchaseBillNo
|
|
|
+ WHERE
|
|
|
+ t1.`id` = #{id}
|
|
|
+ AND t3.PurchaseBillNo IS NOT NULL
|
|
|
+ AND t3.SceneBackType = 1
|
|
|
+ </select>
|
|
|
+ <select id="getSuPurMaterialAnalyse" resultType="com.fjhx.entity.supplier.Supplier">
|
|
|
+ SELECT
|
|
|
+ t3.`Name` AS materialName,
|
|
|
+ t4.`Name` AS categoryName,
|
|
|
+ FORMAT( IFNULL( SUM( t2.TotalAmount ), 0 ), 2 ) AS sumMoney,
|
|
|
+ FORMAT(IFNULL((<include refid="lastMonthMoney_filed"/> AND MaterialCode = t2.MaterialCode),0),2)AS lastMonthMoney,
|
|
|
+ FORMAT(IFNULL((<include refid="monthMoney_filed"/> AND MaterialCode = t2.MaterialCode),0),2)AS monthMoney,
|
|
|
+ count( 1 ) AS count
|
|
|
+ FROM
|
|
|
+ supplier t1
|
|
|
+ LEFT JOIN purchase_contract t2 ON t1.ID = t2.SupplierId
|
|
|
+ LEFT JOIN material t3 ON t2.MaterialCode = t3.`Code`
|
|
|
+ LEFT JOIN material_category t4 ON t1.CategoryCode = t4.`Code`
|
|
|
+ WHERE
|
|
|
+ t1.`id` = #{id}
|
|
|
+ GROUP BY
|
|
|
+ t2.MaterialCode
|
|
|
+ ORDER BY t2.CreatedTime DESC
|
|
|
+ <include refid="sql_limit"/>
|
|
|
+ </select>
|
|
|
+ <select id="getSuPurMaterialAnalyseCount" resultType="java.lang.Integer">
|
|
|
+ SELECT
|
|
|
+ count(1)
|
|
|
+ FROM
|
|
|
+ (SELECT
|
|
|
+ count( 1 ) AS count
|
|
|
+ FROM
|
|
|
+ supplier t1
|
|
|
+ LEFT JOIN purchase_contract t2 ON t1.ID = t2.SupplierId
|
|
|
+ LEFT JOIN material t3 ON t2.MaterialCode = t3.`Code`
|
|
|
+ LEFT JOIN material_category t4 ON t1.CategoryCode = t4.`Code`
|
|
|
+ WHERE
|
|
|
+ t1.`id` = #{id}
|
|
|
+ GROUP BY
|
|
|
+ t2.MaterialCode)AS a
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getBackSumMoneyAndCount" resultType="com.fjhx.entity.supplier.Supplier">
|
|
|
+ SELECT
|
|
|
+ count(1)AS count,
|
|
|
+ SUM(t3.Amount)AS sumMoney,
|
|
|
+ t3.CreatedTime AS CreatedTime
|
|
|
+ FROM
|
|
|
+ supplier t1
|
|
|
+ LEFT JOIN purchase_contract t2 ON t1.ID = t2.SupplierId
|
|
|
+ LEFT JOIN apply_scenebackdetail t3 ON t2.PurchaseBillNo = t3.PurchaseBillNo
|
|
|
+ WHERE
|
|
|
+ t1.`id` = #{id}
|
|
|
+ AND t3.PurchaseBillNo IS NOT NULL
|
|
|
+ AND t3.SceneBackType = 1
|
|
|
+ AND DATE_FORMAT(t2.CreatedTime,'%Y') = #{date}
|
|
|
+ GROUP BY
|
|
|
+ DATE_FORMAT(t3.CreatedTime,"%Y-%m")
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getAllSumMoneyAndCount" resultType="java.util.Map">
|
|
|
+ SELECT
|
|
|
+ Count(1) AS count,
|
|
|
+ IFNULL(SUM( t3.Amount ),0) AS sumMoney
|
|
|
+ FROM
|
|
|
+ supplier t1
|
|
|
+ LEFT JOIN purchase_contract t2 ON t1.ID = t2.SupplierId
|
|
|
+ LEFT JOIN apply_scenebackdetail t3 ON t2.PurchaseBillNo = t3.PurchaseBillNo
|
|
|
+ WHERE
|
|
|
+ t1.`id` = #{id}
|
|
|
+ AND t3.PurchaseBillNo IS NOT NULL
|
|
|
+ AND t3.SceneBackType = 1
|
|
|
+ AND DATE_FORMAT(t2.CreatedTime,'%Y') = #{date}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getMonthSumPurMoney" resultType="com.fjhx.entity.supplier.Supplier">
|
|
|
+ SELECT
|
|
|
+ SUM( TotalAmount ) AS money,
|
|
|
+ t2.CreatedTime AS CreatedTime
|
|
|
+ FROM
|
|
|
+ supplier t1
|
|
|
+ LEFT JOIN purchase_contract t2 ON t1.ID = t2.SupplierId
|
|
|
+ WHERE
|
|
|
+ t1.ID = #{id}
|
|
|
+ AND DATE_FORMAT( t2.CreatedTime, '%Y' ) = #{date}
|
|
|
+ GROUP BY
|
|
|
+ DATE_FORMAT( t2.CreatedTime, '%Y-%m' )
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <sql id="warningCount_filed">
|
|
|
+ SELECT count( 1 ) FROM supplier_problem WHERE SupplierId = t1.id
|
|
|
+ </sql>
|
|
|
+ <sql id="warningTypeCount_filed">
|
|
|
+ SELECT SUM( ProblemTypeCount ) FROM supplier_problem WHERE SupplierId = t1.id
|
|
|
+ </sql>
|
|
|
<sql id="sumMoney_filed">
|
|
|
SELECT SUM( TotalAmount ) FROM purchase_contract WHERE IsDelete = 0 AND SupplierId = t1.ID
|
|
|
</sql>
|