fuyu 4 years ago
parent
commit
f9112b11e4
7 changed files with 50 additions and 30 deletions
  1. 0 3
      move.sh
  2. 0 16
      pacs.sh
  3. 10 4
      src/modules/api/controller.js
  4. 5 1
      src/modules/api/router.js
  5. 23 0
      src/service/check.js
  6. 8 3
      src/service/html.js
  7. 4 3
      src/service/move.js

+ 0 - 3
move.sh

@@ -1,3 +0,0 @@
-curl -d 'institution_id=73090018' 127.0.0.1:22399/api/move &
-curl -d 'institution_id=73090026' 127.0.0.1:22399/api/move &
-curl -d 'institution_id=73090030' 127.0.0.1:22399/api/move &

+ 0 - 16
pacs.sh

@@ -1,16 +0,0 @@
-curl -d 'institution_id=73090001&offset=0' 127.0.0.1:22399/api/pacs &
-curl -d 'institution_id=73090001&offset=1000' 127.0.0.1:22399/api/pacs &
-curl -d 'institution_id=73090001&offset=2000' 127.0.0.1:22399/api/pacs &
-curl -d 'institution_id=73090001&offset=3000' 127.0.0.1:22399/api/pacs &
-curl -d 'institution_id=73090001&offset=4000' 127.0.0.1:22399/api/pacs &
-curl -d 'institution_id=73090001&offset=5000' 127.0.0.1:22399/api/pacs &
-curl -d 'institution_id=73090001&offset=6000' 127.0.0.1:22399/api/pacs &
-curl -d 'institution_id=73090001&offset=7000' 127.0.0.1:22399/api/pacs &
-curl -d 'institution_id=73090001&offset=8000' 127.0.0.1:22399/api/pacs &
-curl -d 'institution_id=73090001&offset=9000' 127.0.0.1:22399/api/pacs &
-curl -d 'institution_id=73090001&offset=10000' 127.0.0.1:22399/api/pacs &
-curl -d 'institution_id=73090001&offset=11000' 127.0.0.1:22399/api/pacs &
-curl -d 'institution_id=73090001&offset=12000' 127.0.0.1:22399/api/pacs &
-curl -d 'institution_id=73090001&offset=13000' 127.0.0.1:22399/api/pacs &
-curl -d 'institution_id=73090001&offset=14000' 127.0.0.1:22399/api/pacs &
-curl -d 'institution_id=73090001&offset=15000' 127.0.0.1:22399/api/pacs &

+ 10 - 4
src/modules/api/controller.js

@@ -2,13 +2,14 @@
  * @Author: fuyu
  * @Date: 2021-03-23 11:56:31
  * @LastEditors: fuyu
- * @LastEditTime: 2021-03-26 10:46:27
- * @FilePath: /202103/code/sql_merge/src/modules/api/controller.js
+ * @LastEditTime: 2021-03-28 19:33:48
+ * @FilePath: /sql_merge/src/modules/api/controller.js
  */
-import {moveAll, movePacs} from '../../service/move'
+import {moveReport, movePacs} from '../../service/move'
+import {_check} from '../../service/check'
 export async function move(ctx) {
   const institution_id = ctx.request.body.institution_id
-  await moveAll(institution_id)
+  await moveReport(institution_id)
 }
 
 export async function pacs(ctx) {
@@ -16,3 +17,8 @@ export async function pacs(ctx) {
   const offset = ctx.request.body.offset
   await movePacs(institution_id, offset)
 }
+
+export async function check(ctx) {
+  // await _check()
+  ctx.redirect('/html');
+}

+ 5 - 1
src/modules/api/router.js

@@ -2,7 +2,7 @@
  * @Author: fuyu
  * @Date: 2021-02-26 17:17:47
  * @LastEditors: fuyu
- * @LastEditTime: 2021-03-24 15:12:18
+ * @LastEditTime: 2021-03-28 19:20:09
  * @FilePath: /sql_merge/src/modules/api/router.js
  */
 import * as api from './controller'
@@ -17,5 +17,9 @@ export default [{
   method: 'POST',
   route: '/pacs',
   handlers: [api.pacs]
+}, {
+  method: 'ALL',
+  route: '/check',
+  handlers: [api.check]
 }
 ]

+ 23 - 0
src/service/check.js

@@ -0,0 +1,23 @@
+/*
+ * @Author: fuyu
+ * @Date: 2021-03-28 19:21:26
+ * @LastEditors: fuyu
+ * @LastEditTime: 2021-03-28 19:25:58
+ * @FilePath: /sql_merge/src/service/check.js
+ */
+let flag = false
+import {moveReport, movePacs} from './move'
+
+export function getFlag() {
+  return flag
+}
+
+export async function _check() {
+  if(flag) {
+    return
+  }
+  flag = true
+  await moveReport()
+  await movePacs()
+  flag = false
+}

+ 8 - 3
src/service/html.js

@@ -2,8 +2,8 @@
  * @Author: fuyu
  * @Date: 2021-03-26 16:38:25
  * @LastEditors: fuyu
- * @LastEditTime: 2021-03-26 18:31:29
- * @FilePath: /202103/code/sql_merge/src/service/html.js
+ * @LastEditTime: 2021-03-28 19:34:26
+ * @FilePath: /sql_merge/src/service/html.js
  */
 
 const FLAG_DELAULT = 0
@@ -11,6 +11,7 @@ const FLAG_REPORT = 1
 const FLAG_PACS = 2
 import {Exams as OldExams} from '../dao_old'
 import {Exams as NewExams, Institution} from '../dao_new'
+import {getFlag} from './check'
 export async function getHtml() {
   const institution = await Institution.findAll({order: ['id', 'name']})
   const map = {}, ids = []
@@ -22,7 +23,6 @@ export async function getHtml() {
   })
   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']
@@ -97,8 +97,12 @@ export async function getHtml() {
   </tr>`)
   // return data
   const tbody = trs.join('')
+  const flag = getFlag()
   return `<html>
     <title>白银市数据同步报告</title>
+    <body>
+    <div>${flag ? '同步中...': '同步完成'}</div>
+    <a href="./api/check">同步报告</a>
     <style>
     .report {
       color:#FF8C00
@@ -150,5 +154,6 @@ export async function getHtml() {
       <tbody>${tbody}</tbody>
     </table>
     <script>setTimeout(_ => window.location.reload(), 60000)</script>
+    </body>
   </html>`
 }

+ 4 - 3
src/service/move.js

@@ -2,8 +2,8 @@
  * @Author: fuyu
  * @Date: 2021-03-23 12:00:09
  * @LastEditors: fuyu
- * @LastEditTime: 2021-03-26 10:54:02
- * @FilePath: /202103/code/sql_merge/src/service/move.js
+ * @LastEditTime: 2021-03-28 19:24:47
+ * @FilePath: /sql_merge/src/service/move.js
  */
 
 import config from '../../config'
@@ -16,7 +16,8 @@ import {logSum, logSingle} from './log'
 import {RemoteApplication as OldRemoteApplication, ApplicationProgressLog as OldApplicationProgressLog, Bbs as OldBbs, RemoteOrder as OldRemoteOrder, RemoteWater as OldRemoteWater, Register as OldRegister, Exams as OldExams, PatientInfos as OldPatientInfos, Studies as OldStudies, Series as OldSeries, Images as OldImages, Report as OldReport, ReportRecord as OldReportRecord, QualityControl as OldQualityControl, QualityCause as OldQualityCause} from '../dao_old'
 import {Institution,  RemoteApplication as NewRemoteApplication, ApplicationProgressLog as NewApplicationProgressLog, Bbs as NewBbs, RemoteOrder as NewRemoteOrder, RemoteWater as NewRemoteWater, Register as NewRegister, Exams as NewExams, PatientInfos as NewPatientInfos, Studies as NewStudies, Series as NewSeries, Images as NewImages, Report as NewReport, ReportRecord as NewReportRecord, QualityControl as NewQualityControl, QualityCause as NewQualityCause} from '../dao_new'
 import {getInt} from './common'
-export async function moveAll(institution_id) {
+
+export async function moveReport(institution_id) {
   if(institution_id) {
     await moveSingle(institution_id)
     return