|
@@ -4,18 +4,22 @@
|
|
|
|
|
|
<select id="getSumList" resultType="com.fjhx.entity.supplier.Supplier">
|
|
|
SELECT
|
|
|
- t1.*,
|
|
|
- t3.TechnologyType AS TechnologyType,
|
|
|
- (<include refid="warningCount_filed"/> ) AS warningCount,
|
|
|
- (<include refid="warningTypeCount_filed"/> ) AS warningTypeCount,
|
|
|
- (select `Name` from material_category where `Code` = t1.CategoryCode) AS categoryName,
|
|
|
- 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,
|
|
|
- FORMAT(IFNULL((<include refid="lastMonthMoney_filed"/>),0),2)AS lastMonthMoney,
|
|
|
- FORMAT(IFNULL((<include refid="monthMoney_filed"/>),0),2)AS monthMoney
|
|
|
+ t1.*,
|
|
|
+ t3.TechnologyType AS TechnologyType,
|
|
|
+ (
|
|
|
+ <include refid="warningCount_filed"/>
|
|
|
+ ) AS warningCount,
|
|
|
+ (
|
|
|
+ <include refid="warningTypeCount_filed"/>
|
|
|
+ ) AS warningTypeCount,
|
|
|
+ (select `Name` from material_category where `Code` = t1.CategoryCode) AS categoryName,
|
|
|
+ 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,
|
|
|
+ FORMAT(IFNULL((<include refid="lastMonthMoney_filed"/>),0),2)AS lastMonthMoney,
|
|
|
+ FORMAT(IFNULL((<include refid="monthMoney_filed"/>),0),2)AS monthMoney
|
|
|
FROM
|
|
|
- supplier t1
|
|
|
+ supplier t1
|
|
|
LEFT JOIN supplier_price sp ON t1.ID = sp.FactoryId
|
|
|
LEFT JOIN material t3 ON t3.`Code` = sp.MaterialCode
|
|
|
<include refid="list_condition"/>
|
|
@@ -26,28 +30,32 @@
|
|
|
|
|
|
<select id="getSumListCount" resultType="java.lang.Integer">
|
|
|
SELECT
|
|
|
- Count( 1 )
|
|
|
+ Count( 1 )
|
|
|
FROM
|
|
|
(
|
|
|
- SELECT
|
|
|
- count(1)
|
|
|
- FROM
|
|
|
- supplier t1
|
|
|
- LEFT JOIN supplier_price sp ON t1.ID = sp.FactoryId
|
|
|
- LEFT JOIN material t3 ON t3.`Code` = sp.MaterialCode
|
|
|
+ SELECT
|
|
|
+ count(1)
|
|
|
+ FROM
|
|
|
+ supplier t1
|
|
|
+ LEFT JOIN supplier_price sp ON t1.ID = sp.FactoryId
|
|
|
+ LEFT JOIN material t3 ON t3.`Code` = sp.MaterialCode
|
|
|
<include refid="list_condition"/>
|
|
|
- GROUP BY t1.ID
|
|
|
+ GROUP BY t1.ID
|
|
|
)AS a
|
|
|
</select>
|
|
|
<select id="getList" resultType="com.fjhx.entity.supplier.Supplier">
|
|
|
SELECT
|
|
|
- t1.*,
|
|
|
- t3.TechnologyType AS TechnologyType,
|
|
|
- (<include refid="warningCount_filed"/> ) AS warningCount,
|
|
|
- (<include refid="warningTypeCount_filed"/> ) AS warningTypeCount,
|
|
|
- (select `Name` from material_category where `Code` = t1.CategoryCode) AS categoryName
|
|
|
+ t1.*,
|
|
|
+ t3.TechnologyType AS TechnologyType,
|
|
|
+ (
|
|
|
+ <include refid="warningCount_filed"/>
|
|
|
+ ) AS warningCount,
|
|
|
+ (
|
|
|
+ <include refid="warningTypeCount_filed"/>
|
|
|
+ ) AS warningTypeCount,
|
|
|
+ (select `Name` from material_category where `Code` = t1.CategoryCode) AS categoryName
|
|
|
FROM
|
|
|
- material t3
|
|
|
+ material t3
|
|
|
LEFT JOIN supplier_price sp ON t3.`Code` = sp.MaterialCode
|
|
|
LEFT JOIN supplier t1 ON sp.FactoryId = t1.ID
|
|
|
<include refid="list_condition"/>
|
|
@@ -59,36 +67,40 @@
|
|
|
</select>
|
|
|
<select id="getListCount" resultType="java.lang.Integer">
|
|
|
SELECT
|
|
|
- Count( 1 )
|
|
|
+ Count( 1 )
|
|
|
FROM
|
|
|
(
|
|
|
- SELECT
|
|
|
- count(1)
|
|
|
- FROM
|
|
|
- material t3
|
|
|
- LEFT JOIN supplier_price sp ON t3.`Code` = sp.MaterialCode
|
|
|
- LEFT JOIN supplier t1 ON sp.FactoryId = t1.ID
|
|
|
- <include refid="list_condition"/>
|
|
|
- AND t3.IsDelete = 0
|
|
|
- GROUP BY t1.ID,
|
|
|
- t3.TechnologyType
|
|
|
+ SELECT
|
|
|
+ count(1)
|
|
|
+ FROM
|
|
|
+ material t3
|
|
|
+ LEFT JOIN supplier_price sp ON t3.`Code` = sp.MaterialCode
|
|
|
+ LEFT JOIN supplier t1 ON sp.FactoryId = t1.ID
|
|
|
+ <include refid="list_condition"/>
|
|
|
+ AND t3.IsDelete = 0
|
|
|
+ GROUP BY t1.ID,
|
|
|
+ t3.TechnologyType
|
|
|
)AS a
|
|
|
</select>
|
|
|
<select id="getPurList" resultType="com.fjhx.entity.supplier.Supplier">
|
|
|
SELECT
|
|
|
- t1.*,
|
|
|
- t3.CategoryCode,
|
|
|
- t3.TechnologyType AS TechnologyType,
|
|
|
- t3.Purpose AS purpose,
|
|
|
- (<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,
|
|
|
- FORMAT(IFNULL((<include refid="lastMonthMoney_filed"/>),0),2)AS lastMonthMoney,
|
|
|
- FORMAT(IFNULL((<include refid="monthMoney_filed"/>),0),2)AS monthMoney
|
|
|
+ t1.*,
|
|
|
+ t3.CategoryCode,
|
|
|
+ t3.TechnologyType AS TechnologyType,
|
|
|
+ t3.Purpose AS purpose,
|
|
|
+ (
|
|
|
+ <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,
|
|
|
+ FORMAT(IFNULL((<include refid="lastMonthMoney_filed"/>),0),2)AS lastMonthMoney,
|
|
|
+ FORMAT(IFNULL((<include refid="monthMoney_filed"/>),0),2)AS monthMoney
|
|
|
FROM
|
|
|
- material t3
|
|
|
+ material t3
|
|
|
LEFT JOIN supplier_price sp ON t3.`Code` = sp.MaterialCode
|
|
|
LEFT JOIN supplier t1 ON sp.FactoryId = t1.ID
|
|
|
<include refid="list_condition"/>
|
|
@@ -100,223 +112,239 @@
|
|
|
</select>
|
|
|
<select id="getPurListCount" resultType="java.lang.Integer">
|
|
|
SELECT
|
|
|
- Count( 1 )
|
|
|
+ Count( 1 )
|
|
|
FROM
|
|
|
(
|
|
|
- SELECT
|
|
|
- count(1)
|
|
|
- FROM
|
|
|
- material t3
|
|
|
- LEFT JOIN supplier_price sp ON t3.`Code` = sp.MaterialCode
|
|
|
- LEFT JOIN supplier t1 ON sp.FactoryId = t1.ID
|
|
|
- <include refid="list_condition"/>
|
|
|
- AND t3.IsDelete = 0
|
|
|
- GROUP BY t1.ID,
|
|
|
- t3.TechnologyType
|
|
|
+ SELECT
|
|
|
+ count(1)
|
|
|
+ FROM
|
|
|
+ material t3
|
|
|
+ LEFT JOIN supplier_price sp ON t3.`Code` = sp.MaterialCode
|
|
|
+ LEFT JOIN supplier t1 ON sp.FactoryId = t1.ID
|
|
|
+ <include refid="list_condition"/>
|
|
|
+ AND t3.IsDelete = 0
|
|
|
+ GROUP BY t1.ID,
|
|
|
+ t3.TechnologyType
|
|
|
) AS a
|
|
|
</select>
|
|
|
<select id="getGroupByCategory" resultType="com.fjhx.entity.supplier.Supplier">
|
|
|
SELECT
|
|
|
- TechnologyType AS TechnologyType,
|
|
|
- Count( 1 ) AS CategoryCount
|
|
|
+ TechnologyType AS TechnologyType,
|
|
|
+ Count( 1 ) AS CategoryCount
|
|
|
FROM
|
|
|
- (
|
|
|
- SELECT
|
|
|
- t1.ID,
|
|
|
- t1.`Name`,
|
|
|
- t3.TechnologyType AS TechnologyType
|
|
|
- FROM
|
|
|
- material t3
|
|
|
- LEFT JOIN supplier_price sp ON t3.`Code` = sp.MaterialCode
|
|
|
- LEFT JOIN supplier t1 ON sp.FactoryId = t1.ID
|
|
|
- <where>
|
|
|
- t1.IsDelete = 0
|
|
|
- AND t3.IsDelete = 0
|
|
|
- <if test="search neq null and search neq '' ">
|
|
|
- AND ((INSTR(t1.`Name`, #{search}) > 0) OR (INSTR(t1.`Code`, #{search}) > 0) )
|
|
|
- </if>
|
|
|
- <if test="Purpose neq null and Purpose neq '' ">
|
|
|
- AND INSTR( t3.Purpose, #{Purpose} ) > 0
|
|
|
- </if>
|
|
|
- </where>
|
|
|
- GROUP BY t1.ID,t3.TechnologyType
|
|
|
- ) detail
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ t1.ID,
|
|
|
+ t1.`Name`,
|
|
|
+ t3.TechnologyType AS TechnologyType
|
|
|
+ FROM
|
|
|
+ material t3
|
|
|
+ LEFT JOIN supplier_price sp ON t3.`Code` = sp.MaterialCode
|
|
|
+ LEFT JOIN supplier t1 ON sp.FactoryId = t1.ID
|
|
|
+ <where>
|
|
|
+ t1.IsDelete = 0
|
|
|
+ AND t3.IsDelete = 0
|
|
|
+ <if test="search neq null and search neq '' ">
|
|
|
+ AND ((INSTR(t1.`Name`, #{search}) > 0) OR (INSTR(t1.`Code`, #{search}) > 0) )
|
|
|
+ </if>
|
|
|
+ <if test="Purpose neq null and Purpose neq '' ">
|
|
|
+ AND INSTR( t3.Purpose, #{Purpose} ) > 0
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY t1.ID,t3.TechnologyType
|
|
|
+ ) detail
|
|
|
GROUP BY
|
|
|
- TechnologyType
|
|
|
+ TechnologyType
|
|
|
ORDER BY
|
|
|
- TechnologyType
|
|
|
+ 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
|
|
|
+ t1.*,
|
|
|
+ (
|
|
|
+ <include refid="warningCount_filed"/>
|
|
|
+ ) AS warningCount,
|
|
|
+ (
|
|
|
+ <include refid="warningTypeCount_filed"/>
|
|
|
+ ) AS warningTypeCount
|
|
|
FROM
|
|
|
- supplier t1
|
|
|
+ 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 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}
|
|
|
+ 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,
|
|
|
- t5.totalMoney AS totalMoney,
|
|
|
- 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`
|
|
|
- LEFT JOIN ( SELECT IFNULL(SUM( TotalAmount ),0) AS totalMoney, MaterialCode FROM purchase_contract WHERE IsDelete = 0 GROUP BY MaterialCode ) t5 ON t5.MaterialCode = t2.MaterialCode
|
|
|
- WHERE
|
|
|
- t1.`id` = #{id}
|
|
|
- AND t2.IsDelete = 0
|
|
|
- GROUP BY
|
|
|
- t2.MaterialCode
|
|
|
- ORDER BY SUM( t2.TotalAmount ) DESC
|
|
|
- <include refid="sql_limit"/>
|
|
|
- </select>
|
|
|
- <select id="getSuPurMaterialAnalyseCount" resultType="java.lang.Integer">
|
|
|
- SELECT
|
|
|
- count(1)
|
|
|
- FROM
|
|
|
- (SELECT
|
|
|
- count( 1 ) AS count
|
|
|
+ t3.`Name` AS materialName,
|
|
|
+ t4.`Name` AS categoryName,
|
|
|
+ t5.totalMoney AS totalMoney,
|
|
|
+ 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`
|
|
|
+ LEFT JOIN ( SELECT IFNULL(SUM( TotalAmount ),0) AS totalMoney, MaterialCode FROM purchase_contract WHERE
|
|
|
+ IsDelete = 0 GROUP BY MaterialCode ) t5 ON t5.MaterialCode = t2.MaterialCode
|
|
|
WHERE
|
|
|
t1.`id` = #{id}
|
|
|
+ AND t2.IsDelete = 0
|
|
|
GROUP BY
|
|
|
- t2.MaterialCode)AS a
|
|
|
+ t2.MaterialCode
|
|
|
+ ORDER BY SUM( t2.TotalAmount ) 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
|
|
|
- a.CreatedTime,
|
|
|
- b.count,
|
|
|
- b.sumMoney
|
|
|
+ a.CreatedTime,
|
|
|
+ b.count,
|
|
|
+ b.sumMoney
|
|
|
FROM
|
|
|
- (<include refid="getMonth"/>)AS a
|
|
|
+ (<include refid="getMonth"/>)AS a
|
|
|
LEFT JOIN (
|
|
|
SELECT
|
|
|
- count(1)AS count,
|
|
|
- SUM(t3.Amount)AS sumMoney,
|
|
|
- t3.CreatedTime AS CreatedTime
|
|
|
+ count(1)AS count,
|
|
|
+ SUM(t3.Amount)AS sumMoney,
|
|
|
+ t3.CreatedTime AS CreatedTime
|
|
|
FROM
|
|
|
- supplier t1
|
|
|
+ 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}
|
|
|
+ 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"))AS b
|
|
|
+ DATE_FORMAT(t3.CreatedTime,"%Y-%m"))AS b
|
|
|
ON DATE_FORMAT(a.`CreatedTime`,'%c') = DATE_FORMAT(b.CreatedTime,"%c")
|
|
|
ORDER BY a.CreatedTime ASC
|
|
|
</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 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
|
|
|
- a.CreatedTime,
|
|
|
- IFNULL(b.money,0) AS money
|
|
|
+ a.CreatedTime,
|
|
|
+ IFNULL(b.money,0) AS money
|
|
|
FROM
|
|
|
(<include refid="getMonth"/>)AS a
|
|
|
LEFT JOIN (
|
|
|
SELECT
|
|
|
- SUM( TotalAmount ) AS money,
|
|
|
- t2.CreatedTime AS CreatedTime
|
|
|
+ SUM( TotalAmount ) AS money,
|
|
|
+ t2.CreatedTime AS CreatedTime
|
|
|
FROM
|
|
|
- supplier t1
|
|
|
+ supplier t1
|
|
|
LEFT JOIN purchase_contract t2 ON t1.ID = t2.SupplierId
|
|
|
WHERE
|
|
|
- t1.ID = #{id}
|
|
|
- AND t2.isDelete = 0
|
|
|
- AND DATE_FORMAT( t2.CreatedTime, '%Y' ) = #{date}
|
|
|
+ t1.ID = #{id}
|
|
|
+ AND t2.isDelete = 0
|
|
|
+ AND DATE_FORMAT( t2.CreatedTime, '%Y' ) = #{date}
|
|
|
GROUP BY
|
|
|
- DATE_FORMAT( t2.CreatedTime, '%Y-%m' ))AS b
|
|
|
+ DATE_FORMAT( t2.CreatedTime, '%Y-%m' ))AS b
|
|
|
ON DATE_FORMAT(a.`CreatedTime`,'%c') = DATE_FORMAT(b.CreatedTime,"%c")
|
|
|
ORDER BY a.CreatedTime ASC
|
|
|
</select>
|
|
|
|
|
|
<select id="selectList" resultType="com.fjhx.entity.supplier.Supplier">
|
|
|
SELECT
|
|
|
- *
|
|
|
+ *
|
|
|
FROM
|
|
|
- supplier t1
|
|
|
+ supplier t1
|
|
|
<include refid="list_condition"/>
|
|
|
ORDER BY CreatedTime DESC
|
|
|
<include refid="sql_limit"/>
|
|
|
</select>
|
|
|
+
|
|
|
+
|
|
|
<sql id="warningCount_filed">
|
|
|
- SELECT count( 1 ) FROM supplier_problem WHERE SupplierId = t1.id
|
|
|
+ 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
|
|
|
+ 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
|
|
|
+ SELECT SUM(TotalAmount)
|
|
|
+ FROM purchase_contract
|
|
|
+ WHERE IsDelete = 0
|
|
|
+ AND SupplierId = t1.ID
|
|
|
</sql>
|
|
|
<sql id="yearMoney_filed">
|
|
|
- select SUM(TotalAmount) from purchase_contract where IsDelete = 0 AND SupplierId = t1.ID AND YEAR(CreatedTime)=YEAR(NOW())
|
|
|
+ select SUM(TotalAmount)
|
|
|
+ from purchase_contract
|
|
|
+ where IsDelete = 0
|
|
|
+ AND SupplierId = t1.ID
|
|
|
+ AND YEAR(CreatedTime) = YEAR(NOW())
|
|
|
</sql>
|
|
|
<sql id="lastYearMoney_filed">
|
|
|
- select SUM(TotalAmount) from purchase_contract where IsDelete = 0 AND SupplierId = t1.ID AND YEAR(CreatedTime) = YEAR(DATE_SUB(NOW(),INTERVAL 1 YEAR))
|
|
|
+ select SUM(TotalAmount)
|
|
|
+ from purchase_contract
|
|
|
+ where IsDelete = 0
|
|
|
+ AND SupplierId = t1.ID
|
|
|
+ AND YEAR(CreatedTime) = YEAR(DATE_SUB(NOW(), INTERVAL 1 YEAR))
|
|
|
</sql>
|
|
|
<sql id="monthMoney_filed">
|
|
|
- select SUM(TotalAmount) from purchase_contract where IsDelete = 0 AND SupplierId = t1.ID AND DATE_FORMAT(CreatedTime,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m')
|
|
|
+ select SUM(TotalAmount)
|
|
|
+ from purchase_contract
|
|
|
+ where IsDelete = 0
|
|
|
+ AND SupplierId = t1.ID
|
|
|
+ AND DATE_FORMAT(CreatedTime, '%Y%m') = DATE_FORMAT(CURDATE(), '%Y%m')
|
|
|
</sql>
|
|
|
<sql id="lastMonthMoney_filed">
|
|
|
- select SUM(TotalAmount) from purchase_contract where IsDelete = 0 AND SupplierId = t1.ID AND PERIOD_DIFF(DATE_FORMAT(NOW(),'%Y%m'),DATE_FORMAT(CreatedTime,'%Y%m')) = 1
|
|
|
+ select SUM(TotalAmount)
|
|
|
+ from purchase_contract
|
|
|
+ where IsDelete = 0
|
|
|
+ AND SupplierId = t1.ID
|
|
|
+ AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'), DATE_FORMAT(CreatedTime, '%Y%m')) = 1
|
|
|
</sql>
|
|
|
<sql id="list_condition">
|
|
|
<where>
|
|
@@ -331,6 +359,10 @@
|
|
|
AND INSTR( t3.Purpose, #{Purpose} ) > 0
|
|
|
</if>
|
|
|
|
|
|
+ <if test="materialCode neq null and materialCode neq '' ">
|
|
|
+ AND t1.ID in ( select sp.FactoryId from supplier_price sp where sp.MaterialCode = #{materialCode} )
|
|
|
+ </if>
|
|
|
+
|
|
|
</where>
|
|
|
</sql>
|
|
|
<sql id="sql_limit">
|
|
@@ -339,29 +371,28 @@
|
|
|
</if>
|
|
|
</sql>
|
|
|
<sql id="getMonth">
|
|
|
- SELECT
|
|
|
- CONCAT(#{date},"-01-01 00:00:00") AS CreatedTime UNION
|
|
|
- SELECT
|
|
|
- CONCAT(#{date},"-02-01 00:00:00") AS CreatedTime UNION
|
|
|
- SELECT
|
|
|
- CONCAT(#{date},"-03-01 00:00:00") AS CreatedTime UNION
|
|
|
- SELECT
|
|
|
- CONCAT(#{date},"-04-01 00:00:00") AS CreatedTime UNION
|
|
|
- SELECT
|
|
|
- CONCAT(#{date},"-05-01 00:00:00") AS CreatedTime UNION
|
|
|
- SELECT
|
|
|
- CONCAT(#{date},"-06-01 00:00:00") AS CreatedTime UNION
|
|
|
- SELECT
|
|
|
- CONCAT(#{date},"-07-01 00:00:00") AS CreatedTime UNION
|
|
|
- SELECT
|
|
|
- CONCAT(#{date},"-08-01 00:00:00") AS CreatedTime UNION
|
|
|
- SELECT
|
|
|
- CONCAT(#{date},"-09-01 00:00:00") AS CreatedTime UNION
|
|
|
- SELECT
|
|
|
- CONCAT(#{date},"-10-01 00:00:00") AS CreatedTime UNION
|
|
|
- SELECT
|
|
|
- CONCAT(#{date},"-11-01 00:00:00") AS CreatedTime UNION
|
|
|
- SELECT
|
|
|
- CONCAT(#{date},"-12-01 00:00:00") AS CreatedTime
|
|
|
+ SELECT CONCAT(#{date}, "-01-01 00:00:00") AS CreatedTime
|
|
|
+ UNION
|
|
|
+ SELECT CONCAT(#{date}, "-02-01 00:00:00") AS CreatedTime
|
|
|
+ UNION
|
|
|
+ SELECT CONCAT(#{date}, "-03-01 00:00:00") AS CreatedTime
|
|
|
+ UNION
|
|
|
+ SELECT CONCAT(#{date}, "-04-01 00:00:00") AS CreatedTime
|
|
|
+ UNION
|
|
|
+ SELECT CONCAT(#{date}, "-05-01 00:00:00") AS CreatedTime
|
|
|
+ UNION
|
|
|
+ SELECT CONCAT(#{date}, "-06-01 00:00:00") AS CreatedTime
|
|
|
+ UNION
|
|
|
+ SELECT CONCAT(#{date}, "-07-01 00:00:00") AS CreatedTime
|
|
|
+ UNION
|
|
|
+ SELECT CONCAT(#{date}, "-08-01 00:00:00") AS CreatedTime
|
|
|
+ UNION
|
|
|
+ SELECT CONCAT(#{date}, "-09-01 00:00:00") AS CreatedTime
|
|
|
+ UNION
|
|
|
+ SELECT CONCAT(#{date}, "-10-01 00:00:00") AS CreatedTime
|
|
|
+ UNION
|
|
|
+ SELECT CONCAT(#{date}, "-11-01 00:00:00") AS CreatedTime
|
|
|
+ UNION
|
|
|
+ SELECT CONCAT(#{date}, "-12-01 00:00:00") AS CreatedTime
|
|
|
</sql>
|
|
|
</mapper>
|