Commit f8f7e078 by 仲光辉

feat: add sql.

parent 039a93f8
### 访人数据查询
### 访人数据查询
......@@ -119,4 +119,48 @@ WHERE c.is_delete = 0
AND c.is_draft = 0
AND r.uuid !='cfa7cfe133bb42d484e3260066903268'
AND c.contract_status NOT IN(11,12,13,9,10)
ORDER BY c.create_time DESC ;
SELECT C.uuid AS `合同ID`,
c.create_time AS `创建时间`,
c.contract_code AS `合同编号`,
r.name AS `城市名称`,
c.project_name AS `项目名称`,
CASE c.contract_status
WHEN 1 THEN '新建待审批'
WHEN 2 THEN '新建待修改'
WHEN 3 THEN '变更待审批'
WHEN 4 THEN '变更待修改'
WHEN 5 THEN '待执行'
WHEN 6 THEN '正常执行'
WHEN 7 THEN '退租待审批'
WHEN 8 THEN '退租待修改'
WHEN 9 THEN '退租待执行'
WHEN 10 THEN '已退租'
WHEN 11 THEN '作废待审批'
WHEN 12 THEN '作废待修改'
WHEN 13 THEN '已作废'
WHEN 14 THEN '到期未处理'
WHEN 15 THEN '续租待审批'
WHEN 16 THEN '续租待修改'
WHEN 17 THEN '变更中'
WHEN 18 THEN '变更待执行'
WHEN 19 THEN '续租待执行'
WHEN 20 THEN '续租正常执行'
ELSE '未知状态'
END AS `合同状态`
FROM contract AS C
INNER JOIN project AS p ON p.uuid = c.project_uuid
INNER JOIN region AS r ON r.uuid = p.region_uuid
LEFT JOIN (SELECT ccf.contract_uuid,
COUNT(ccf.contract_uuid) AS `count`
FROM contract_custom_fields ccf
WHERE ccf.field_name IN ('仲裁名称', '合同模版违约金说明')
GROUP BY ccf.contract_uuid
ORDER BY `count` desc) AS static ON static.contract_uuid = c.uuid
WHERE c.is_delete = 0
AND c.is_draft = 0
AND r.uuid !='cfa7cfe133bb42d484e3260066903268'
AND c.contract_status NOT IN(11,12,13,9,10)
AND static.contract_uuid is null
ORDER BY c.create_time DESC ;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment