|
@@ -2,7 +2,7 @@
|
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
<mapper namespace="com.dayou.mapper.AssetsStatisticalStatementMapper">
|
|
|
|
|
|
- <!--资产太差查询SQL-->
|
|
|
+ <!--资产台账查询SQL-->
|
|
|
<sql id="assetsLedgerQuery">
|
|
|
SELECT (@i := @i + 1) AS id,
|
|
|
assets.id AS assetsId,
|
|
@@ -13,20 +13,7 @@
|
|
|
report.valuation_basis_date AS valuationBasisDate,
|
|
|
report.create_production_date AS createReportDate,
|
|
|
COALESCE(report.assets_name, statement.assets_name, assets.name) AS projectName,
|
|
|
- IFNULL((SELECT node.`name`
|
|
|
- FROM work_flow_node_instance AS instance,
|
|
|
- work_node AS node
|
|
|
- WHERE instance.node_id = node.id
|
|
|
- AND node.deleted = 0
|
|
|
- AND instance.deleted = 0
|
|
|
- AND instance.business_id = assets.id
|
|
|
- AND (IF(statement.production_no IS NULL, instance.business_sub_id IS NULL,
|
|
|
- statement.production_no = instance.business_sub_id))
|
|
|
- AND (IF(report.production_no IS NULL, instance.business_min_id IS NULL,
|
|
|
- report.production_no = instance.business_min_id))
|
|
|
- AND (instance.state = 'PENDING' OR
|
|
|
- (instance.state = 'FINISHED' AND node.`code` = 'BUSINESS_ARCHIVING'))),
|
|
|
- IF(statement.production_no IS NULL, '撰写意见书', '撰写报告')) AS currentNodeName,
|
|
|
+ IF(nodeInfo.state = 'CLOSED','项目终止',IF(nodeInfo.name IS NULL,IF(statement.production_no IS NULL, '撰写意见书', '撰写报告'),nodeInfo.name)) AS currentNodeName,
|
|
|
assets.security AS security,
|
|
|
assets.significant_assets_reorganization AS significantAssetsReorganization,
|
|
|
assets.state_assets AS stateAssets,
|
|
@@ -120,9 +107,10 @@
|
|
|
AND instance.business_id = assets.id
|
|
|
AND instance.business_min_id = report.production_no
|
|
|
AND node.code = 'FOURTH_CHECK_REPORT'
|
|
|
+ AND instance.deleted = 0
|
|
|
) AS reportFourthCheckerName
|
|
|
FROM (SELECT @i := 0) AS sort,assets
|
|
|
- LEFT JOIN (
|
|
|
+ LEFT JOIN (
|
|
|
SELECT target.id,
|
|
|
target.assets_id,
|
|
|
purpose_name,
|
|
@@ -142,11 +130,25 @@
|
|
|
LEFT JOIN assets_evaluation_target_type AS secType ON evaluation_type_sec_id = type.id
|
|
|
LEFT JOIN assets_value_type AS vType ON assets_value_id = vType.id
|
|
|
) AS target ON assets.id = target.assets_id
|
|
|
- LEFT JOIN assets_production AS report ON report_no = report.production_no
|
|
|
- LEFT JOIN assets_production AS statement ON statement_no = statement.production_no
|
|
|
- LEFT JOIN user AS manager ON manager.id = assets.client_manager_id
|
|
|
- LEFT JOIN user AS principal ON principal.id = assets.principal_id
|
|
|
- LEFT JOIN order_fund AS fund ON fund.business_id = assets.id AND fund.business_type = 'ASSET_BUSINESS'
|
|
|
+ LEFT JOIN assets_production AS report ON report_no = report.production_no
|
|
|
+ LEFT JOIN assets_production AS statement ON statement_no = statement.production_no
|
|
|
+ LEFT JOIN user AS manager ON manager.id = assets.client_manager_id
|
|
|
+ LEFT JOIN user AS principal ON principal.id = assets.principal_id
|
|
|
+ LEFT JOIN order_fund AS fund ON fund.business_id = assets.id AND fund.business_type = 'ASSET_BUSINESS'
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT node.`name`,instance.business_id,instance.business_sub_id,instance.business_min_id,instance.state
|
|
|
+ FROM work_flow_node_instance AS instance,
|
|
|
+ work_node AS node
|
|
|
+ WHERE instance.node_id = node.id
|
|
|
+ AND node.deleted = 0
|
|
|
+ AND instance.deleted = 0
|
|
|
+ AND (instance.state = 'PENDING' OR instance.state = 'CLOSED' OR
|
|
|
+ (instance.state = 'FINISHED' AND node.`code` = 'BUSINESS_ARCHIVING'))
|
|
|
+ ) AS nodeInfo ON nodeInfo.business_id = assets.id
|
|
|
+ AND (IF(statement.production_no IS NULL, nodeInfo.business_sub_id IS NULL,
|
|
|
+ statement.production_no = nodeInfo.business_sub_id))
|
|
|
+ AND (IF(report.production_no IS NULL, nodeInfo.business_min_id IS NULL,
|
|
|
+ report.production_no = nodeInfo.business_min_id))
|
|
|
WHERE assets.deleted = 0
|
|
|
<if test="dto != null and dto.keyWord != null and dto.keyWord != '' ">
|
|
|
AND (
|
|
@@ -161,7 +163,7 @@
|
|
|
<if test="dto != null and dto.principalId">
|
|
|
AND assets.principal_id = #{dto.principalId}
|
|
|
</if>
|
|
|
- <if test="dto != null and dto.departmentId">
|
|
|
+ <if test="dto != null and dto.departmentId != null">
|
|
|
AND assets.principal_id = #{dto.departmentId}
|
|
|
</if>
|
|
|
<if test="dto != null and dto.startTime != null and dto.endTime!= null">
|
|
@@ -170,8 +172,8 @@
|
|
|
<if test="dto != null and dto.assetsBusinessGener">
|
|
|
AND assets.assets_business_gener = #{dto.assetsBusinessGener}
|
|
|
</if>
|
|
|
- GROUP BY statementNo,
|
|
|
- reportNo
|
|
|
+ GROUP BY statementNo,reportNo,assets.id
|
|
|
+ ORDER BY assets.created DESC
|
|
|
</sql>
|
|
|
|
|
|
<!--获取资产台账-->
|
|
@@ -183,4 +185,222 @@
|
|
|
<select id="assetsLedgerVOExport" resultType="com.dayou.vo.AssetsLedgerVO">
|
|
|
<include refid="assetsLedgerQuery" />
|
|
|
</select>
|
|
|
+
|
|
|
+ <sql id="assetsPerformanceDeductionQuery">
|
|
|
+ SELECT
|
|
|
+ department.id AS departmentId,
|
|
|
+ department.name AS departmentName,
|
|
|
+ COALESCE ( SUM( checkPer.normal_mistake ), 0 ) AS checkNormalMistakeScore,
|
|
|
+ COALESCE ( SUM( checkPer.hard_mistake ), 0 ) AS checkHardMistakeScore,
|
|
|
+ COALESCE ( SUM( checkPer.fatal_mistake ), 0 ) AS checkFatalMistakeScore,
|
|
|
+ COALESCE ( SUM( reCheckPer.normal_mistake ), 0 ) AS reCheckNormalMistakeScore,
|
|
|
+ COALESCE ( SUM( reCheckPer.hard_mistake ), 0 ) AS reCheckHardMistakeScore,
|
|
|
+ COALESCE ( SUM( reCheckPer.fatal_mistake ), 0 ) AS reCheckFatalMistakeScore,
|
|
|
+ COALESCE ( SUM( fourthCheckPer.normal_mistake ), 0 ) AS fourthCheckNormalMistakeScore,
|
|
|
+ COALESCE ( SUM( fourthCheckPer.hard_mistake ), 0 ) AS fourthCheckHardMistakeScore,
|
|
|
+ COALESCE ( SUM( fourthCheckPer.fatal_mistake ), 0 ) AS fourthCheckFatalMistakeScore,
|
|
|
+ COALESCE (
|
|
|
+ COALESCE ( SUM( checkPer.normal_mistake ), 0 ) + COALESCE ( SUM( checkPer.hard_mistake ), 0 ) + COALESCE ( SUM( checkPer.fatal_mistake ), 0 ) + COALESCE ( SUM( reCheckPer.normal_mistake ), 0 ) + COALESCE ( SUM( reCheckPer.hard_mistake ), 0 ) + COALESCE ( SUM( reCheckPer.fatal_mistake ), 0 ) + COALESCE ( SUM( fourthCheckPer.normal_mistake ), 0 ) + COALESCE ( SUM( fourthCheckPer.hard_mistake ), 0 ) + COALESCE ( SUM( fourthCheckPer.fatal_mistake ), 0 ),
|
|
|
+ 0
|
|
|
+ ) AS allMistakeScore
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ department.id,
|
|
|
+ department.name
|
|
|
+ FROM
|
|
|
+ department,
|
|
|
+ sorted_department
|
|
|
+ WHERE
|
|
|
+ department.id = sorted_department.department_id
|
|
|
+ AND department.deleted = 0
|
|
|
+ AND sorted_department.business_type = 'ASSET_BUSINESS'
|
|
|
+ ) AS department
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ department_id,
|
|
|
+ assets.created,
|
|
|
+ assets_production.id AS production_id
|
|
|
+ FROM
|
|
|
+ assets
|
|
|
+ LEFT JOIN assets_production ON assets_production.business_id = assets.id
|
|
|
+ AND assets_production.deleted = 0
|
|
|
+ ) AS orderInfo ON department.id = orderInfo.department_id
|
|
|
+ LEFT JOIN ( SELECT production_id, fatal_mistake, hard_mistake, normal_mistake FROM
|
|
|
+ business_production_performance WHERE business_type = 'ASSET_BUSINESS' AND check_loop = '初审'
|
|
|
+ <if test="dto != null and dto.startTime != null and dto.endTime!= null">
|
|
|
+ AND (business_production_performance.modified BETWEEN #{dto.startTime} AND #{dto.endTime})
|
|
|
+ </if>
|
|
|
+ ) AS checkPer ON checkPer.production_id = orderInfo.production_id
|
|
|
+ LEFT JOIN ( SELECT production_id, fatal_mistake, hard_mistake, normal_mistake FROM
|
|
|
+ business_production_performance WHERE business_type = 'ASSET_BUSINESS' AND check_loop = '复审'
|
|
|
+ <if test="dto != null and dto.startTime != null and dto.endTime!= null">
|
|
|
+ AND (business_production_performance.modified BETWEEN #{dto.startTime} AND #{dto.endTime})
|
|
|
+ </if>
|
|
|
+ ) AS reCheckPer ON reCheckPer.production_id = orderInfo.production_id
|
|
|
+ LEFT JOIN ( SELECT production_id, fatal_mistake, hard_mistake, normal_mistake FROM
|
|
|
+ business_production_performance WHERE business_type = 'ASSET_BUSINESS' AND check_loop = '四审'
|
|
|
+ <if test="dto != null and dto.startTime != null and dto.endTime!= null">
|
|
|
+ AND (business_production_performance.modified BETWEEN #{dto.startTime} AND #{dto.endTime})
|
|
|
+ </if>
|
|
|
+ ) AS fourthCheckPer ON fourthCheckPer.production_id = orderInfo.production_id
|
|
|
+ <where>
|
|
|
+ <if test="dto != null and dto.departmentId != null">
|
|
|
+ AND department.id = #{dto.departmentId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY department.id
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <!--评估部绩效扣分查询-->
|
|
|
+ <select id="getAssetsPerformanceDeductionVO" resultType="com.dayou.vo.AssetsPerformanceDeductionVO">
|
|
|
+ <include refid="assetsPerformanceDeductionQuery" />
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!--评估部绩效扣分导出-->
|
|
|
+ <select id="assetsPerformanceDeductionVOExport" resultType="com.dayou.vo.AssetsPerformanceDeductionVO">
|
|
|
+ <include refid="assetsPerformanceDeductionQuery" />
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!--查询错误详情SQL-->
|
|
|
+ <sql id="assetsPerformanceDeductionDetailQuery">
|
|
|
+ SELECT performance.id,
|
|
|
+ assets.order_id AS orderId,
|
|
|
+ assets.members AS members,
|
|
|
+ production.assets_name AS projectName,
|
|
|
+ customer.name AS customerName,
|
|
|
+ production.production_no AS productionNo,
|
|
|
+ (CASE production.production_type
|
|
|
+ WHEN 'STATEMENT' THEN '意见书'
|
|
|
+ WHEN 'LETTER' THEN '意见函'
|
|
|
+ WHEN 'CONSULT' THEN '咨询报告'
|
|
|
+ WHEN 'REPORT' THEN '评估报告'
|
|
|
+ END) AS productionType,
|
|
|
+ principal.name AS principalName,
|
|
|
+ checker.name AS checkerName,
|
|
|
+ (CASE #{dto.mistakeType}
|
|
|
+ WHEN 'normal' THEN performance.normal_mistake
|
|
|
+ WHEN 'hard' THEN performance.hard_mistake
|
|
|
+ WHEN 'fatal' THEN performance.fatal_mistake
|
|
|
+ ELSE '-'
|
|
|
+ END) AS mistakeCount,
|
|
|
+ production.evaluate_amount AS evaluateAmount,
|
|
|
+ performance.modified AS checkTime,
|
|
|
+ performance.reason AS reason
|
|
|
+ FROM assets
|
|
|
+ LEFT JOIN assets_production AS production ON assets.id = production.business_id
|
|
|
+ LEFT JOIN business_production_performance AS performance ON production.id = performance.production_id
|
|
|
+ LEFT JOIN customer_company AS customer ON customer.id = assets.clientele_id
|
|
|
+ LEFT JOIN user AS principal ON principal.id = assets.principal_id
|
|
|
+ LEFT JOIN user AS checker ON checker.id = performance.check_id
|
|
|
+ WHERE assets.department_id = #{dto.departmentId}
|
|
|
+ AND performance.check_loop = #{dto.checkLoop}
|
|
|
+ AND (performance.modified BETWEEN #{dto.startTime} AND #{dto.endTime})
|
|
|
+ <if test="dto.principalId != null">
|
|
|
+ AND assets.principal_id = #{dto.principalId}
|
|
|
+ </if>
|
|
|
+ <if test="dto.mistakeType == 'normal' ">
|
|
|
+ AND performance.normal_mistake > 0
|
|
|
+ </if>
|
|
|
+ <if test="dto.mistakeType == 'hard' ">
|
|
|
+ AND performance.hard_mistake > 0
|
|
|
+ </if>
|
|
|
+ <if test="dto.mistakeType == 'fatal' ">
|
|
|
+ AND performance.fatal_mistake > 0
|
|
|
+ </if>
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <!--查询错误详情列表-->
|
|
|
+ <select id="getAssetsPerformanceDeductionDetail" resultType="com.dayou.vo.AssetsPerformanceDeductionDetailVO">
|
|
|
+ <include refid="assetsPerformanceDeductionDetailQuery" />
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!--错误详情列表导出-->
|
|
|
+ <select id="assetsPerformanceDeductionDetailExport" resultType="com.dayou.vo.AssetsPerformanceDeductionDetailVO">
|
|
|
+ <include refid="assetsPerformanceDeductionDetailQuery" />
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!--评估人员绩效扣分查询SQL-->
|
|
|
+ <sql id="assetsPerformanceDeductionByUserQuery">
|
|
|
+ SELECT user.id AS userId,
|
|
|
+ user.userName,
|
|
|
+ user.departmentId,
|
|
|
+ user.departmentName,
|
|
|
+ COALESCE ( SUM( checkPer.normal_mistake ), 0 ) AS checkNormalMistakeScore,
|
|
|
+ COALESCE ( SUM( checkPer.hard_mistake ), 0 ) AS checkHardMistakeScore,
|
|
|
+ COALESCE ( SUM( checkPer.fatal_mistake ), 0 ) AS checkFatalMistakeScore,
|
|
|
+ COALESCE ( SUM( reCheckPer.normal_mistake ), 0 ) AS reCheckNormalMistakeScore,
|
|
|
+ COALESCE ( SUM( reCheckPer.hard_mistake ), 0 ) AS reCheckHardMistakeScore,
|
|
|
+ COALESCE ( SUM( reCheckPer.fatal_mistake ), 0 ) AS reCheckFatalMistakeScore,
|
|
|
+ COALESCE ( SUM( fourthCheckPer.normal_mistake ), 0 ) AS fourthCheckNormalMistakeScore,
|
|
|
+ COALESCE ( SUM( fourthCheckPer.hard_mistake ), 0 ) AS fourthCheckHardMistakeScore,
|
|
|
+ COALESCE ( SUM( fourthCheckPer.fatal_mistake ), 0 ) AS fourthCheckFatalMistakeScore,
|
|
|
+ COALESCE (
|
|
|
+ COALESCE ( SUM( checkPer.normal_mistake ), 0 ) + COALESCE ( SUM( checkPer.hard_mistake ), 0 ) + COALESCE ( SUM( checkPer.fatal_mistake ), 0 ) + COALESCE ( SUM( reCheckPer.normal_mistake ), 0 ) + COALESCE ( SUM( reCheckPer.hard_mistake ), 0 ) + COALESCE ( SUM( reCheckPer.fatal_mistake ), 0 ) + COALESCE ( SUM( fourthCheckPer.normal_mistake ), 0 ) + COALESCE ( SUM( fourthCheckPer.hard_mistake ), 0 ) + COALESCE ( SUM( fourthCheckPer.fatal_mistake ), 0 ),
|
|
|
+ 0
|
|
|
+ ) AS allMistakeScore
|
|
|
+ FROM (SELECT user.id AS id,
|
|
|
+ user.`name` AS userName,
|
|
|
+ department.name AS departmentName,
|
|
|
+ department.id AS departmentId
|
|
|
+ FROM user,post,user_post,sorted_department,department
|
|
|
+ WHERE `user`.id = user_post.user_id
|
|
|
+ AND user_post.post_id = post.id
|
|
|
+ AND post.department_id = sorted_department.department_id
|
|
|
+ AND sorted_department.department_id = department.id
|
|
|
+ AND sorted_department.deleted = 0
|
|
|
+ AND user_post.deleted = 0
|
|
|
+ AND sorted_department.business_type = 'ASSET_BUSINESS'
|
|
|
+ GROUP BY user.id
|
|
|
+ ) AS user
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ principal_id,
|
|
|
+ assets.created,
|
|
|
+ assets_production.id AS production_id
|
|
|
+ FROM
|
|
|
+ assets
|
|
|
+ LEFT JOIN assets_production ON assets_production.business_id = assets.id
|
|
|
+ AND assets_production.deleted = 0
|
|
|
+ ) AS orderInfo ON user.id = orderInfo.principal_id
|
|
|
+ LEFT JOIN ( SELECT production_id, fatal_mistake, hard_mistake, normal_mistake FROM
|
|
|
+ business_production_performance WHERE business_type = 'ASSET_BUSINESS' AND check_loop = '初审'
|
|
|
+ <if test="dto != null and dto.startTime != null and dto.endTime!= null">
|
|
|
+ AND (business_production_performance.modified BETWEEN #{dto.startTime} AND #{dto.endTime})
|
|
|
+ </if>
|
|
|
+ ) AS checkPer ON checkPer.production_id = orderInfo.production_id
|
|
|
+ LEFT JOIN ( SELECT production_id, fatal_mistake, hard_mistake, normal_mistake FROM
|
|
|
+ business_production_performance WHERE business_type = 'ASSET_BUSINESS' AND check_loop = '复审'
|
|
|
+ <if test="dto != null and dto.startTime != null and dto.endTime!= null">
|
|
|
+ AND (business_production_performance.modified BETWEEN #{dto.startTime} AND #{dto.endTime})
|
|
|
+ </if>
|
|
|
+ ) AS reCheckPer ON reCheckPer.production_id = orderInfo.production_id
|
|
|
+ LEFT JOIN ( SELECT production_id, fatal_mistake, hard_mistake, normal_mistake FROM
|
|
|
+ business_production_performance WHERE business_type = 'ASSET_BUSINESS' AND check_loop = '四审'
|
|
|
+ <if test="dto != null and dto.startTime != null and dto.endTime!= null">
|
|
|
+ AND (business_production_performance.modified BETWEEN #{dto.startTime} AND #{dto.endTime})
|
|
|
+ </if>
|
|
|
+ ) AS fourthCheckPer ON fourthCheckPer.production_id = orderInfo.production_id
|
|
|
+ <where>
|
|
|
+ <if test="dto != null and dto.departmentId != null">
|
|
|
+ AND user.departmentId = #{dto.departmentId}
|
|
|
+ </if>
|
|
|
+ <if test="dto != null and dto.userName != null">
|
|
|
+ AND user.userName LIKE CONCAT('%',#{dto.userName},'%')
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY user.id
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <!--评估人员绩效扣分查询-->
|
|
|
+ <select id="getAssetsPerformanceDeductionVOByEvaluator" resultType="com.dayou.vo.AssetsPerformanceDeductionVO">
|
|
|
+ <include refid="assetsPerformanceDeductionByUserQuery" />
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!--评估人员绩效扣分导出-->
|
|
|
+ <select id="assetsPerformanceDeductionVOByEvaluatorExport" resultType="com.dayou.vo.AssetsPerformanceDeductionVO">
|
|
|
+ <include refid="assetsPerformanceDeductionByUserQuery" />
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
</mapper>
|