|
@@ -0,0 +1,118 @@
|
|
|
+/*
|
|
|
+ * @Author: fuyu
|
|
|
+ * @Date: 2021-03-26 16:38:25
|
|
|
+ * @LastEditors: fuyu
|
|
|
+ * @LastEditTime: 2021-03-26 18:10:51
|
|
|
+ * @FilePath: /202103/code/sql_merge/src/service/html.js
|
|
|
+ */
|
|
|
+
|
|
|
+const FLAG_DELAULT = 0
|
|
|
+const FLAG_REPORT = 1
|
|
|
+const FLAG_PACS = 2
|
|
|
+import {Exams as OldExams} from '../dao_old'
|
|
|
+import {Exams as NewExams, Institution} from '../dao_new'
|
|
|
+export async function getHtml() {
|
|
|
+ const institution = await Institution.findAll({order: ['id', 'name']})
|
|
|
+ const map = {}, ids = []
|
|
|
+ institution.forEach(i => {
|
|
|
+ const id = i['id']
|
|
|
+ const name = i['name']
|
|
|
+ map[id] = {id, name}
|
|
|
+ ids.push(id)
|
|
|
+ })
|
|
|
+ const oldExams = await OldExams.count({attributes: ['institution_id', 'flag'], where: {institution_id: ids}, group: ['institution_id', 'flag']})
|
|
|
+ const newExams = await NewExams.count({attributes: ['institution_id', 'flag'], where: {institution_id: ids}, group: ['institution_id', 'flag']})
|
|
|
+
|
|
|
+ oldExams.forEach(item => {
|
|
|
+ const id = item['institution_id']
|
|
|
+ const flag = item['flag']
|
|
|
+ const count = item['count']
|
|
|
+ const tmp = map[id]
|
|
|
+ tmp['old-' + flag] = count
|
|
|
+ });
|
|
|
+
|
|
|
+ newExams.forEach(item => {
|
|
|
+ const id = item['institution_id']
|
|
|
+ const flag = item['flag']
|
|
|
+ const count = item['count']
|
|
|
+ const tmp = map[id]
|
|
|
+ tmp['new-' + flag] = count
|
|
|
+ });
|
|
|
+
|
|
|
+ const data = []
|
|
|
+ const trs = []
|
|
|
+ for(let key in map) {
|
|
|
+ const tmp = map[key]
|
|
|
+ const id = tmp['id']
|
|
|
+ const name = tmp['name']
|
|
|
+ const old0 = parseInt(tmp['old-0'] || 0)
|
|
|
+ const old1 = parseInt(tmp['old-1'] || 0)
|
|
|
+ const old2 = parseInt(tmp['old-2'] || 0)
|
|
|
+ const new0 = parseInt(tmp['new-0'] || 0)
|
|
|
+ const new1 = parseInt(tmp['new-1'] || 0)
|
|
|
+ const new2 = parseInt(tmp['new-2'] || 0)
|
|
|
+ const oldsum = old0 + old1 + old2
|
|
|
+ const newsum = new0 + new1 + new2
|
|
|
+ data.push({ id, name, old0, old1, old2, new0, new1, new2, oldsum, newsum})
|
|
|
+ trs.push(`<tr>
|
|
|
+ <td>${id}</td>
|
|
|
+ <td>${name}</td>
|
|
|
+ <td>${oldsum}</td>
|
|
|
+ <td>${old2}</td>
|
|
|
+ <td>${old1}</td>
|
|
|
+ <td>${old0}</td>
|
|
|
+ <td>${newsum}</td>
|
|
|
+ <td>${new0}</td>
|
|
|
+ <td>${new1}</td>
|
|
|
+ <td>${new2}</td>
|
|
|
+ </tr>`)
|
|
|
+ }
|
|
|
+ // return data
|
|
|
+ const tbody = trs.join('')
|
|
|
+ return `<html>
|
|
|
+ <style>
|
|
|
+ table {
|
|
|
+ width: 100%;
|
|
|
+ font-size: .938em;
|
|
|
+ border-collapse: collapse;/*边框会合并为一个单一的边框*/
|
|
|
+ }
|
|
|
+ caption {
|
|
|
+ margin: 1em 0 .7em 0;
|
|
|
+ text-align: center;
|
|
|
+ font-weight: bold;
|
|
|
+ font-size: 120%;
|
|
|
+ letter-spacing: .5px;
|
|
|
+ color: #fff;
|
|
|
+ }
|
|
|
+
|
|
|
+ th {
|
|
|
+ text-align: left;
|
|
|
+ padding: .5em .5em;
|
|
|
+ font-weight: bold;
|
|
|
+ background: #66677c;color: #fff;
|
|
|
+ }
|
|
|
+
|
|
|
+ td {
|
|
|
+ padding: .5em .5em;
|
|
|
+ border-bottom: solid 1px #ccc;
|
|
|
+ }
|
|
|
+
|
|
|
+ table,table tr th, table tr td { border:1px solid #0094ff; }/*设置边框的*/
|
|
|
+ </style>
|
|
|
+ <table border="0" cellspacing="1" cellpadding="0">
|
|
|
+ <thead>
|
|
|
+ <th>医院id</th>
|
|
|
+ <th>医院名称</th>
|
|
|
+ <th>公网总数</th>
|
|
|
+ <th>同步完成</th>
|
|
|
+ <th>同步报告</th>
|
|
|
+ <th>未同步</th>
|
|
|
+ <th>内网总数</th>
|
|
|
+ <th>未同步</th>
|
|
|
+ <th>同步报告</th>
|
|
|
+ <th>同步完成</th>
|
|
|
+ </thead>
|
|
|
+ <tbody>${tbody}</tbody>
|
|
|
+ </table>
|
|
|
+ </html>`
|
|
|
+}
|