fuyu 4 years ago
parent
commit
b60cdc1cf4
4 changed files with 18 additions and 12 deletions
  1. 2 2
      src/modules/api/controller.js
  2. 9 3
      src/service/common.js
  3. 3 3
      src/service/move.js
  4. 4 4
      src/service/time.js

+ 2 - 2
src/modules/api/controller.js

@@ -2,7 +2,7 @@
  * @Author: fuyu
  * @Author: fuyu
  * @Date: 2021-03-23 11:56:31
  * @Date: 2021-03-23 11:56:31
  * @LastEditors: fuyu
  * @LastEditors: fuyu
- * @LastEditTime: 2021-03-26 10:38:33
+ * @LastEditTime: 2021-03-26 10:46:27
  * @FilePath: /202103/code/sql_merge/src/modules/api/controller.js
  * @FilePath: /202103/code/sql_merge/src/modules/api/controller.js
  */
  */
 import {moveAll, movePacs} from '../../service/move'
 import {moveAll, movePacs} from '../../service/move'
@@ -13,6 +13,6 @@ export async function move(ctx) {
 
 
 export async function pacs(ctx) {
 export async function pacs(ctx) {
   const institution_id = ctx.request.body.institution_id
   const institution_id = ctx.request.body.institution_id
-  const offset = ctx.request.body.offset || 0
+  const offset = ctx.request.body.offset
   await movePacs(institution_id, offset)
   await movePacs(institution_id, offset)
 }
 }

+ 9 - 3
src/service/common.js

@@ -2,10 +2,10 @@
  * @Author: fuyu
  * @Author: fuyu
  * @Date: 2021-03-23 16:43:11
  * @Date: 2021-03-23 16:43:11
  * @LastEditors: fuyu
  * @LastEditors: fuyu
- * @LastEditTime: 2021-03-23 16:49:39
+ * @LastEditTime: 2021-03-26 10:51:36
  * @FilePath: /202103/code/sql_merge/src/service/common.js
  * @FilePath: /202103/code/sql_merge/src/service/common.js
  */
  */
-export function fixNumber(number, fix, length) {
+export function fillNumber(number, fix, length) {
   if(typeof number === 'number') {
   if(typeof number === 'number') {
     number += ''
     number += ''
   }
   }
@@ -13,4 +13,10 @@ export function fixNumber(number, fix, length) {
     return number
     return number
   }
   }
   return number.padStart(length, fix)
   return number.padStart(length, fix)
-}
+}
+
+export function getInt(input, defaultValue) {
+  input = parseInt(input)
+  return isNaN(input) ? defaultValue: input
+}
+

+ 3 - 3
src/service/move.js

@@ -2,7 +2,7 @@
  * @Author: fuyu
  * @Author: fuyu
  * @Date: 2021-03-23 12:00:09
  * @Date: 2021-03-23 12:00:09
  * @LastEditors: fuyu
  * @LastEditors: fuyu
- * @LastEditTime: 2021-03-26 10:44:40
+ * @LastEditTime: 2021-03-26 10:51:45
  * @FilePath: /202103/code/sql_merge/src/service/move.js
  * @FilePath: /202103/code/sql_merge/src/service/move.js
  */
  */
 
 
@@ -15,7 +15,7 @@ const order = [['createdAt', 'DESC']]
 import {logSum, logSingle} from './log'
 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 {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 {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 moveAll(institution_id) {
   if(institution_id) {
   if(institution_id) {
     await moveSingle(institution_id)
     await moveSingle(institution_id)
@@ -29,7 +29,7 @@ export async function moveAll(institution_id) {
 
 
 export async function movePacs(institution_id, offset) {
 export async function movePacs(institution_id, offset) {
   if(institution_id) {
   if(institution_id) {
-    await moveSinglePacs(institution_id, offset)
+    await moveSinglePacs(institution_id, getInt(offset))
     return
     return
   }
   }
   const ids = await Institution.findAll({attributes: ['id']})
   const ids = await Institution.findAll({attributes: ['id']})

+ 4 - 4
src/service/time.js

@@ -2,16 +2,16 @@
  * @Author: fuyu
  * @Author: fuyu
  * @Date: 2021-03-23 16:42:13
  * @Date: 2021-03-23 16:42:13
  * @LastEditors: fuyu
  * @LastEditors: fuyu
- * @LastEditTime: 2021-03-23 17:25:20
+ * @LastEditTime: 2021-03-26 10:47:37
  * @FilePath: /202103/code/sql_merge/src/service/time.js
  * @FilePath: /202103/code/sql_merge/src/service/time.js
  */
  */
-import {fixNumber} from './common'
+import {fillNumber} from './common'
 export function getNowDay() {
 export function getNowDay() {
   const date = new Date()
   const date = new Date()
   const year = date.getFullYear()
   const year = date.getFullYear()
   const month = date.getMonth() + 1
   const month = date.getMonth() + 1
   const day = date.getDate()
   const day = date.getDate()
-  return fixNumber(year, 0, 4) + '-' + fixNumber(month, 0, 2) + '-' + fixNumber(day, 0, 2)
+  return fillNumber(year, 0, 4) + '-' + fillNumber(month, 0, 2) + '-' + fillNumber(day, 0, 2)
 }
 }
 
 
 export function getNowTime() {
 export function getNowTime() {
@@ -22,6 +22,6 @@ export function getNowTime() {
   const hours = date.getHours()
   const hours = date.getHours()
   const minutes = date.getMinutes()
   const minutes = date.getMinutes()
   const seconds = date.getSeconds()
   const seconds = date.getSeconds()
-  return fixNumber(year, 0, 4) + '-' + fixNumber(month, 0, 2) + '-' + fixNumber(day, 0, 2) + ' ' + fixNumber(hours, 0, 2) + ':' + fixNumber(minutes, 0, 2) + ':' + fixNumber(seconds, 0, 2)
+  return fillNumber(year, 0, 4) + '-' + fillNumber(month, 0, 2) + '-' + fillNumber(day, 0, 2) + ' ' + fillNumber(hours, 0, 2) + ':' + fillNumber(minutes, 0, 2) + ':' + fillNumber(seconds, 0, 2)
 }
 }