|
@@ -42,7 +42,7 @@ import {
|
|
Wechat_bind as OldWechat_bind,
|
|
Wechat_bind as OldWechat_bind,
|
|
Wechat_pay_log as OldWechat_pay_log,
|
|
Wechat_pay_log as OldWechat_pay_log,
|
|
Wechat_refund_log as OldWechat_refund_log
|
|
Wechat_refund_log as OldWechat_refund_log
|
|
-} from '../../old_dao'
|
|
|
|
|
|
+} from '../../old_dao2'
|
|
|
|
|
|
|
|
|
|
import {
|
|
import {
|
|
@@ -88,8 +88,9 @@ import {
|
|
Version as TestVersion,
|
|
Version as TestVersion,
|
|
Wechat_bind as TestWechat_bind,
|
|
Wechat_bind as TestWechat_bind,
|
|
Wechat_pay_log as TestWechat_pay_log,
|
|
Wechat_pay_log as TestWechat_pay_log,
|
|
- Wechat_refund_log as TestWechat_refund_log
|
|
|
|
-} from '../../test_dao';
|
|
|
|
|
|
+ Wechat_refund_log as TestWechat_refund_log,
|
|
|
|
+ Register as TestRegister
|
|
|
|
+} from '../../new_dao';
|
|
// exam
|
|
// exam
|
|
// register
|
|
// register
|
|
// messages is_remote exam_id
|
|
// messages is_remote exam_id
|
|
@@ -107,136 +108,388 @@ import {
|
|
// Studies as TestStudies,
|
|
// Studies as TestStudies,
|
|
|
|
|
|
import Sequelize from 'sequelize'
|
|
import Sequelize from 'sequelize'
|
|
|
|
+const fs = require('fs');
|
|
|
|
+const path = require('path');
|
|
|
|
+
|
|
|
|
+export async function message(ctx) {
|
|
|
|
+ // is_remote exam_id doctor_id = req_doctor_id 相等是2
|
|
|
|
+ const messages = await TestMessages.findAll();
|
|
|
|
+ for (let i = 0; i < messages.length; i++) {
|
|
|
|
+ const message = messages[i];
|
|
|
|
+ const application_id = message.application_id;
|
|
|
|
+ const application = await TestRemote_application.findOne({ where: { id: application_id } });
|
|
|
|
+ if (application) {
|
|
|
|
+ message.exam_id = application.exam_id;
|
|
|
|
+ message.is_remote = application.req_doctor_id === message.doctor_id ? '2' : '1';
|
|
|
|
+ await message.save();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ctx.body = true;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+export async function report(ctx) {
|
|
|
|
+ const doctors = await TestDoctors.findAll();
|
|
|
|
+ const doctorMap = {}
|
|
|
|
+ for (let i = 0; i < doctors.length; i++) {
|
|
|
|
+ const doctor = doctors[i];
|
|
|
|
+ doctorMap[doctor.id] = doctor.realname;
|
|
|
|
+ }
|
|
|
|
+ let res = await limitCallBack(TestReport, 'report', reportCallback, { doctorMap });
|
|
|
|
+ ctx.body = res;
|
|
|
|
+ // report_doctor_name review_doctor_name confirm_doctor_name
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+export async function reportCallback(report, { doctorMap }) {
|
|
|
|
+ report.report_doctor_name = doctorMap[report.report_doctor_id];
|
|
|
|
+ report.review_doctor_name = doctorMap[report.review_doctor_id];
|
|
|
|
+ report.confirm_doctor_name = doctorMap[report.confirm_doctor_id];
|
|
|
|
+ await report.save();
|
|
|
|
+ // report_doctor_name review_doctor_name confirm_doctor_name
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+export async function exam(ctx) {
|
|
|
|
+ let res = await limitMultipleCallBack(TestExams, 'exams', examCallbck);
|
|
|
|
+ ctx.body = res;
|
|
|
|
+
|
|
|
|
+ // name card_num studyid sex age birthday exam_sub_class body_part device_name
|
|
|
|
+ // report_result report_status:远程
|
|
|
|
+ // del_datetime:del_time del_doctor_id:null
|
|
|
|
+}
|
|
|
|
+let count = 0;
|
|
|
|
+export async function examCallbck(exam) {
|
|
|
|
+ const patient = await TestPatient_infos.findOne({ where: { id: exam.patient_id } })
|
|
|
|
+ const study = await TestStudies.findOne({ where: { id: exam.study_id } })
|
|
|
|
+ const report = await TestReport.findOne({ where: { exam_id: exam.id, type: '1' } })
|
|
|
|
+ if (patient) {
|
|
|
|
+ let sex = patient && patient.sex;
|
|
|
|
+ if (sex === '男' || sex === 'M') {
|
|
|
|
+ sex = 'M';
|
|
|
|
+ } else if (sex === '女' || sex === 'F') {
|
|
|
|
+ sex = 'F';
|
|
|
|
+ } else {
|
|
|
|
+ sex = 'O';
|
|
|
|
+ }
|
|
|
|
+ exam.name = patient.name;
|
|
|
|
+ exam.sex = sex;
|
|
|
|
+ exam.age = patient.age;
|
|
|
|
+ exam.birthday = patient.birthday;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (report) {
|
|
|
|
+ exam.report_result = report.report_result;
|
|
|
|
+ }
|
|
|
|
+ if (study) {
|
|
|
|
+ study.exam_id = exam.id;
|
|
|
|
+ exam.studyid = study.studyid;
|
|
|
|
+ exam.studyuid = study.studyuid;
|
|
|
|
+ exam.body_part = study.partExamined;
|
|
|
|
+ await study.save();
|
|
|
|
+ } else {
|
|
|
|
+ exam.studyuid = 'nono';
|
|
|
|
+ }
|
|
|
|
+ await exam.save();
|
|
|
|
+ // const register = await TestRegister.findOne({ where: { exam_id: exam.id } });
|
|
|
|
+ // if (!register) {
|
|
|
|
+ // const oldExam = await OldExams.findOne({ where: { id: exam.id } });
|
|
|
|
+ // await TestRegister.create({
|
|
|
|
+ // id: uuid16(),
|
|
|
|
+ // exam_id: exam.id,
|
|
|
|
+ // register_datetime: oldExam.register_datetime,
|
|
|
|
+ // illness_desc: oldExam.illness_desc,
|
|
|
|
+ // phys_sign: oldExam.phys_sign,
|
|
|
|
+ // clin_symp: oldExam.lin_symp,
|
|
|
|
+ // anamnesis: oldExam.anamnesis,
|
|
|
|
+ // family_ill: oldExam.film_type,
|
|
|
|
+ // clin_diag: oldExam.clin_diag,
|
|
|
|
+ // ext: oldExam.ext
|
|
|
|
+ // })
|
|
|
|
+ // }
|
|
|
|
+ console.log(count++);
|
|
|
|
+ // name card_num studyid sex age birthday exam_sub_class body_part device_name
|
|
|
|
+ // report_result report_status:远程
|
|
|
|
+ // del_datetime:del_time del_doctor_id:null
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+export let uuid16 = () => {
|
|
|
|
+ function S4() {
|
|
|
|
+ return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
|
|
|
|
+ }
|
|
|
|
+ return ('1' + new Date().getTime().toString(16) + S4());
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+export async function register(ctx) {
|
|
|
|
+ // id: { type: Sequelize.STRING(255), allowNull: false, primaryKey: true, comment: ''},
|
|
|
|
+ // exam_id: { type: Sequelize.STRING(255), allowNull: true, primaryKey: false, comment: '检查key'},
|
|
|
|
+ // exam_sub_class: { type: Sequelize.STRING(255), allowNull: true, primaryKey: false, comment: '检查子类'},
|
|
|
|
+ // body_part: { type: Sequelize.STRING(255), allowNull: true, primaryKey: false, comment: '检查部位'},
|
|
|
|
+ // null device_name: { type: Sequelize.STRING(255), allowNull: true, primaryKey: false, comment: '检查设备'},
|
|
|
|
+ // null technician_id: { type: Sequelize.STRING(255), allowNull: true, primaryKey: false, comment: '检查技师ID'},
|
|
|
|
+ // null technician_name: { type: Sequelize.STRING(255), allowNull: true, primaryKey: false, comment: '检查技师姓名'},
|
|
|
|
+ // null technician_datetime: { type: Sequelize.DATE, allowNull: true, primaryKey: false, comment: '计划检查时间'},
|
|
|
|
+ // null register_id: { type: Sequelize.STRING(50), allowNull: true, primaryKey: false, comment: '登记医师ID'},
|
|
|
|
+ // null register_name: { type: Sequelize.STRING(255), allowNull: true, primaryKey: false, comment: '登记医师姓名'},
|
|
|
|
+ // register_datetime: { type: Sequelize.DATE, allowNull: true, primaryKey: false, comment: '登记时间'},
|
|
|
|
+ // illness_desc: { type: Sequelize.STRING(255), allowNull: true, primaryKey: false, comment: '患者主诉'},
|
|
|
|
+ // phys_sign: { type: Sequelize.STRING(255), allowNull: true, primaryKey: false, comment: '体征'},
|
|
|
|
+ // clin_symp: { type: Sequelize.STRING(255), allowNull: true, primaryKey: false, comment: '症状'},
|
|
|
|
+ // anamnesis: { type: Sequelize.STRING(255), allowNull: true, primaryKey: false, comment: '疾病史'},
|
|
|
|
+ // family_ill: { type: Sequelize.STRING(255), allowNull: true, primaryKey: false, comment: '家族病史'},
|
|
|
|
+ // application_department: { type: Sequelize.STRING(255), allowNull: true, primaryKey: false, comment: '申请科室'},
|
|
|
|
+ // clin_diag: { type: Sequelize.STRING(255), allowNull: true, primaryKey: false, comment: '初步诊断'},
|
|
|
|
+ // ext: { type: Sequelize.TEXT, allowNull: true, primaryKey: false, comment: '备注'},
|
|
|
|
+ // null clin_department: { type: Sequelize.STRING(255), allowNull: true, primaryKey: false, comment: '送诊科室'},
|
|
|
|
+ // null clin_doctors_id: { type: Sequelize.STRING(50), allowNull: true, primaryKey: false, comment: '送诊医生ID'},
|
|
|
|
+ // null clin_doctors_name: { type: Sequelize.STRING(255), allowNull: true, primaryKey: false, comment: '送诊医生姓名'},
|
|
|
|
+ // null clin_datetime: { type: Sequelize.DATE, allowNull: true, primaryKey: false, comment: '送诊时间'},
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// exam report
|
|
|
|
+export async function remoteApplication(ctx) {
|
|
|
|
+ const applications = await TestRemote_application.findAll();
|
|
|
|
+ const hospitals = await TestInstitution.findAll();
|
|
|
|
+ const hospitalMap = {}
|
|
|
|
+ for (let i = 0; i < hospitals.length; i++) {
|
|
|
|
+ const hospital = hospitals[i];
|
|
|
|
+ if (hospital)
|
|
|
|
+ hospitalMap[hospital.id] = hospital.name;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const doctors = await TestDoctors.findAll();
|
|
|
|
+ const doctorMap = {}
|
|
|
|
+ for (let i = 0; i < doctors.length; i++) {
|
|
|
|
+ const doctor = doctors[i];
|
|
|
|
+ doctorMap[doctor.id] = doctor.realname;
|
|
|
|
+ }
|
|
|
|
+ for (let i = 0; i < applications.length; i++) {
|
|
|
|
+ const application = applications[i];
|
|
|
|
+ const exam = await TestExams.findOne({ where: { id: application.exam_id } });
|
|
|
|
+ if (exam) {
|
|
|
|
+ application.name = exam.name;
|
|
|
|
+ application.patient_num = exam.patient_num;
|
|
|
|
+ application.accession_num = exam.accession_num;
|
|
|
|
+ application.card_num = exam.card_num;
|
|
|
|
+ application.sex = exam.sex;
|
|
|
|
+ application.age = exam.age;
|
|
|
|
+ application.birthday = exam.birthday;
|
|
|
|
+ application.exam_sub_class = exam.exam_sub_class;
|
|
|
|
+ application.body_part = exam.body_part;
|
|
|
|
+ application.device_name = exam.device_name;
|
|
|
|
+ application.exam_datetime = exam.exam_datetime;
|
|
|
|
+ application.exam_class = exam.exam_class;
|
|
|
|
+ application.exam_project = exam.exam_project;
|
|
|
|
+ application.study_id = exam.study_id;
|
|
|
|
+ application.studyid = exam.studyid;
|
|
|
|
+ application.exam_sub_class = exam.exam_sub_class;
|
|
|
|
+ application.body_part = exam.body_part;
|
|
|
|
+ application.device_name = exam.device_name;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ application.pay_status = '1';
|
|
|
|
+ application.local_institution_name = hospitalMap[application.local_institution_id];
|
|
|
|
+ application.remote_institution_name = hospitalMap[application.remote_institution_id];
|
|
|
|
+ application.req_doctor_name = doctorMap[application.req_doctor_id];
|
|
|
|
+ application.remote_doctor_name = doctorMap[application.req_doctor_id];
|
|
|
|
+ const report = await TestReport.findOne({ where: { exam_id: application.exam_id, type: '2' } })
|
|
|
|
+ if (report) {
|
|
|
|
+ application.report_result = report.report_result;
|
|
|
|
+ if (exam) {
|
|
|
|
+ exam.report_result = application.report_status;
|
|
|
|
+ await exam.save();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ await application.save();
|
|
|
|
+ }
|
|
|
|
+ ctx.body = true;
|
|
|
|
+ // report_result
|
|
|
|
+ // name sex age patient_num accession_num card_num birthday
|
|
|
|
+ // exam_datetime exam_class exam_project body_part exam_sub_class study_id
|
|
|
|
+ // local_institution_name req_doctor_name remote_institution_name
|
|
|
|
+ // pay_status:1
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
export async function normalLimit(ctx) {
|
|
export async function normalLimit(ctx) {
|
|
|
|
+ const res = {};
|
|
// await copyLimit(OldMessages, TestMessages, 'id');
|
|
// await copyLimit(OldMessages, TestMessages, 'id');
|
|
// await copyLimit(OldRemote_application, TestRemote_application, 'id');
|
|
// await copyLimit(OldRemote_application, TestRemote_application, 'id');
|
|
|
|
|
|
- await copyLimit(OldImages, TestImages, 'id');
|
|
|
|
- // await copyLimit(OldSeries, TestSeries, 'id');
|
|
|
|
- // await copyLimit(OldStudies, TestStudies, 'id');
|
|
|
|
- // await copyLimit(OldPatient_infos, TestPatient_infos, 'id');
|
|
|
|
|
|
+ // await copyLimit(OldImages, TestImages, 'id');
|
|
|
|
+
|
|
|
|
+ // res.patient_infos = await copyLimit(OldPatient_infos, TestPatient_infos, 'id', 'patient_infos');
|
|
|
|
+ // res.studies = await copyLimit(OldStudies, TestStudies, 'id', 'studies');
|
|
|
|
+ // res.exams = await copyLimit(OldExams, TestExams, 'id', 'exams');
|
|
|
|
+ // res.report = await copyLimit(OldReport, TestReport, 'id', 'report');
|
|
|
|
+ // res.series = await copyLimit(OldSeries, TestSeries, 'id', 'series');
|
|
|
|
+ res.images = await copyLimit(OldImages, TestImages, 'id', 'images');
|
|
|
|
+
|
|
|
|
+ const fileUri = path.join(__dirname, '../../logs', 'normalLimit.log');
|
|
|
|
+ fs.writeFileSync(fileUri, JSON.stringify(res));
|
|
|
|
+ ctx.body = res;
|
|
}
|
|
}
|
|
|
|
|
|
export async function normal(ctx) {
|
|
export async function normal(ctx) {
|
|
|
|
+ const res = {};
|
|
|
|
+
|
|
|
|
+ // Messages
|
|
|
|
+ res.message = await copy(OldMessages, TestMessages, 'id', 'message');
|
|
|
|
+ // Remote_application
|
|
|
|
+ res.remote_application = await copy(OldRemote_application, TestRemote_application, 'id', 'remote_application');
|
|
|
|
+
|
|
// Bbs
|
|
// Bbs
|
|
- await copy(OldBbs, TestBbs, 'id', 'bbs');
|
|
|
|
|
|
+ res.bbs = await copy(OldBbs, TestBbs, 'id', 'bbs');
|
|
// Bodypart
|
|
// Bodypart
|
|
- await copy(OldBodypart, TestBodypart, 'id', 'bodypart');
|
|
|
|
|
|
+ res.bodypart = await copy(OldBodypart, TestBodypart, 'id', 'bodypart');
|
|
// Constant
|
|
// Constant
|
|
- await copy(OldConstant, TestConstant, 'id', 'constant');
|
|
|
|
|
|
+ res.constant = await copy(OldConstant, TestConstant, 'id', 'constant');
|
|
// Default_cost
|
|
// Default_cost
|
|
- await copy(OldDefault_cost, TestDefault_cost, 'id', 'default_cost');
|
|
|
|
|
|
+ res.default_cost = await copy(OldDefault_cost, TestDefault_cost, 'id', 'default_cost');
|
|
// Department
|
|
// Department
|
|
- await copy(OldDepartment, TestDepartment, 'id', '');
|
|
|
|
|
|
+ res.department = await copy(OldDepartment, TestDepartment, 'id', 'department');
|
|
// Device
|
|
// Device
|
|
- await copy(OldDevice, TestDevice, 'id');
|
|
|
|
|
|
+ res.device = await copy(OldDevice, TestDevice, 'id', 'device');
|
|
// Doctor_class
|
|
// Doctor_class
|
|
- await copy(OldDoctor_class, TestDoctor_class, 'id');
|
|
|
|
|
|
+ res.doctor_class = await copy(OldDoctor_class, TestDoctor_class, 'id', 'doctor_class');
|
|
// Doctors
|
|
// Doctors
|
|
- await copy(OldDoctors, TestDoctors, 'id');
|
|
|
|
|
|
+ res.doctors = await copy(OldDoctors, TestDoctors, 'id', 'doctors');
|
|
// Dr_cla_permission
|
|
// Dr_cla_permission
|
|
- await copy(OldDr_cla_permission, TestDr_cla_permission, 'id');
|
|
|
|
|
|
+ res.dr_cla_permission = await copy(OldDr_cla_permission, TestDr_cla_permission, 'id', 'dr_cla_permission');
|
|
// Every_studies
|
|
// Every_studies
|
|
- await copy(OldEvery_studies, TestEvery_studies, 'id');
|
|
|
|
|
|
+ res.every_studies = await copy(OldEvery_studies, TestEvery_studies, 'id', 'every_studies');
|
|
// Exam_class
|
|
// Exam_class
|
|
- await copy(OldExam_class, TestExam_class, 'id');
|
|
|
|
|
|
+ res.exam_clas = await copy(OldExam_class, TestExam_class, 'id', 'exam_clas');
|
|
// Exam_project
|
|
// Exam_project
|
|
- await copy(OldExam_project, TestExam_project, 'id');
|
|
|
|
|
|
+ res.exam_project = await copy(OldExam_project, TestExam_project, 'id', 'exam_project');
|
|
// Exam_subclass
|
|
// Exam_subclass
|
|
- await copy(OldExam_subclass, TestExam_subclass, 'id');
|
|
|
|
|
|
+ res.exam_subclass = await copy(OldExam_subclass, TestExam_subclass, 'id', 'exam_subclass');
|
|
// Institution
|
|
// Institution
|
|
- await copy(OldInstitution, TestInstitution, 'id');
|
|
|
|
- // Menu as TestMenu,
|
|
|
|
- await copy(OldMenu, TestMenu, 'id');
|
|
|
|
- // Messages as TestMessages,
|
|
|
|
- await copy(OldManager, TestManager, 'id');
|
|
|
|
- // Open_application as TestOpen_application,
|
|
|
|
- await copy(OldOpen_application, TestOpen_application, 'id');
|
|
|
|
- // Operating as TestOperating,
|
|
|
|
- await copy(OldOperating, TestOperating, 'id');
|
|
|
|
- // Remote_contact as TestRemote_contact,
|
|
|
|
- await copy(OldRemote_contact, TestRemote_contact, 'id');
|
|
|
|
- // Remote_cost as TestRemote_cost,
|
|
|
|
- await copy(OldRemote_cost, TestRemote_cost, 'id');
|
|
|
|
- // Remote_order as TestRemote_order,
|
|
|
|
- await copy(OldRemote_order, TestRemote_order, 'id');
|
|
|
|
- // Remote_water as TestRemote_water,
|
|
|
|
- await copy(OldRemote_water, TestRemote_water, 'id');
|
|
|
|
- // Remote_water_log as TestRemote_water_log,
|
|
|
|
- await copy(OldRemote_water_log, TestRemote_water_log, 'id');
|
|
|
|
- // Report_record as TestReport_record,
|
|
|
|
- await copy(OldReport_record, TestReport_record, 'id');
|
|
|
|
- // Send_message as TestSend_message,
|
|
|
|
- await copy(OldSend_message, TestSend_message, 'id');
|
|
|
|
- // Sys_logs as TestSys_logs,
|
|
|
|
- await copy(OldSys_logs, TestSys_logs, 'id');
|
|
|
|
- // Sys_menus as TestSys_menus,
|
|
|
|
- await copy(OldSys_menus, TestSys_menus, 'id');
|
|
|
|
- // Templates as TestTemplates,
|
|
|
|
- await copy(OldTemplates, TestTemplates, 'id');
|
|
|
|
- // User as TestUser,
|
|
|
|
- await copy(OldUser, TestUser, 'id');
|
|
|
|
- // User_bind as TestUser_bind,
|
|
|
|
- await copy(OldUser_bind, TestUser_bind, 'id');
|
|
|
|
- // Version as TestVersion,
|
|
|
|
- await copy(OldVersion, TestVersion, 'id');
|
|
|
|
- // Wechat_bind as TestWechat_bind,
|
|
|
|
- await copy(OldWechat_bind, TestWechat_bind, 'id');
|
|
|
|
- // Wechat_pay_log as TestWechat_pay_log,
|
|
|
|
- await copy(OldWechat_pay_log, TestWechat_pay_log, 'id');
|
|
|
|
- // Wechat_refund_log as TestWechat_refund_log
|
|
|
|
- await copy(OldWechat_refund_log, TestWechat_refund_log, 'id');
|
|
|
|
|
|
+ res.institution = await copy(OldInstitution, TestInstitution, 'id', 'institution');
|
|
|
|
+ // Menu
|
|
|
|
+ res.menu = await copy(OldMenu, TestMenu, 'id', 'menu');
|
|
|
|
+ // Messages
|
|
|
|
+ res.messages = await copy(OldManager, TestManager, 'id', 'messages');
|
|
|
|
+ // Open_application
|
|
|
|
+ res.open_application = await copy(OldOpen_application, TestOpen_application, 'id', 'open_application');
|
|
|
|
+ // Operating
|
|
|
|
+ res.operating = await copy(OldOperating, TestOperating, 'id', 'operating');
|
|
|
|
+ // Remote_contact
|
|
|
|
+ res.remote_contact = await copy(OldRemote_contact, TestRemote_contact, 'id', 'remote_contact');
|
|
|
|
+ // Remote_cost
|
|
|
|
+ res.remote_cost = await copy(OldRemote_cost, TestRemote_cost, 'id', 'remote_cost');
|
|
|
|
+ // Remote_order
|
|
|
|
+ res.remote_order = await copy(OldRemote_order, TestRemote_order, 'id', 'remote_order');
|
|
|
|
+ // Remote_water
|
|
|
|
+ res.remote_water = await copy(OldRemote_water, TestRemote_water, 'id', 'remote_water');
|
|
|
|
+ // Remote_water_log
|
|
|
|
+ res.remote_water_log = await copy(OldRemote_water_log, TestRemote_water_log, 'id', 'remote_water_log');
|
|
|
|
+ // Report_record
|
|
|
|
+ res.report_record = await copy(OldReport_record, TestReport_record, 'id', 'report_record');
|
|
|
|
+ // Send_message
|
|
|
|
+ res.send_message = await copy(OldSend_message, TestSend_message, 'id', 'send_message');
|
|
|
|
+ // Sys_logs
|
|
|
|
+ res.sys_logs = await copy(OldSys_logs, TestSys_logs, 'id', 'sys_logs');
|
|
|
|
+ // Sys_menus
|
|
|
|
+ res.sys_menus = await copy(OldSys_menus, TestSys_menus, 'id', 'sys_menus');
|
|
|
|
+ // Templates
|
|
|
|
+ res.templates = await copy(OldTemplates, TestTemplates, 'id', 'templates');
|
|
|
|
+ // User
|
|
|
|
+ res.user = await copy(OldUser, TestUser, 'id', 'user');
|
|
|
|
+ // User_bind
|
|
|
|
+ res.user_bind = await copy(OldUser_bind, TestUser_bind, 'id', 'user_bind');
|
|
|
|
+ // Version
|
|
|
|
+ res.version = await copy(OldVersion, TestVersion, 'id', 'version');
|
|
|
|
+ // Wechat_bind
|
|
|
|
+ res.wechat_bind = await copy(OldWechat_bind, TestWechat_bind, 'id', 'wechat_bind');
|
|
|
|
+ // Wechat_pay_log
|
|
|
|
+ res.wechat_pay_log = await copy(OldWechat_pay_log, TestWechat_pay_log, 'id', 'wechat_pay_log');
|
|
|
|
+ // Wechat_refund_log
|
|
|
|
+ res.wechat_refund_log = await copy(OldWechat_refund_log, TestWechat_refund_log, 'id', 'wechat_refund_log');
|
|
|
|
+ ctx.body = res;
|
|
}
|
|
}
|
|
-
|
|
|
|
-async function copy(oldDb, newDb, key) {
|
|
|
|
|
|
+async function copy(oldDb, newDb, key, tableName) {
|
|
if (!newDb) {
|
|
if (!newDb) {
|
|
- return
|
|
|
|
|
|
+ return { tableName, err: '没有新库' }
|
|
}
|
|
}
|
|
let olds = await oldDb.findAll();
|
|
let olds = await oldDb.findAll();
|
|
-
|
|
|
|
|
|
+ const errors = [];
|
|
for (let i = 0; i < olds.length; i++) {
|
|
for (let i = 0; i < olds.length; i++) {
|
|
const where = {};
|
|
const where = {};
|
|
where[key] = olds[i][key];
|
|
where[key] = olds[i][key];
|
|
- console.log('where', where, newDb)
|
|
|
|
const old = await newDb.findOne({ where });
|
|
const old = await newDb.findOne({ where });
|
|
|
|
|
|
if (!old) {
|
|
if (!old) {
|
|
- console.log(olds[i].dataValues)
|
|
|
|
- newDb.create({...olds[i].dataValues });
|
|
|
|
|
|
+ try {
|
|
|
|
+ newDb.create({...olds[i].dataValues });
|
|
|
|
+ } catch (err) {
|
|
|
|
+ errors.push(err.getMessage());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ const oldCount = await oldDb.count();
|
|
|
|
+ const newCount = await newDb.count();
|
|
|
|
+
|
|
|
|
+ return {
|
|
|
|
+ tableName,
|
|
|
|
+ oldCount,
|
|
|
|
+ newCount,
|
|
|
|
+ dCount: newCount - oldCount,
|
|
|
|
+ errors
|
|
|
|
+ }
|
|
}
|
|
}
|
|
const Op = Sequelize.Op;
|
|
const Op = Sequelize.Op;
|
|
-async function copyLimit(oldDb, newDb, key) {
|
|
|
|
|
|
+async function copyLimit(oldDb, newDb, key, tableName) {
|
|
if (!newDb) {
|
|
if (!newDb) {
|
|
- return
|
|
|
|
|
|
+ return { tableName, err: '没有新表' }
|
|
}
|
|
}
|
|
let createdAt = null;
|
|
let createdAt = null;
|
|
let id = null;
|
|
let id = null;
|
|
- const limit = 1000;
|
|
|
|
|
|
+ const limit = 1;
|
|
const order = [
|
|
const order = [
|
|
['id', 'asc']
|
|
['id', 'asc']
|
|
];
|
|
];
|
|
-
|
|
|
|
- let olds = await oldDb.findAll({ limit, order });
|
|
|
|
|
|
+ const errors = [];
|
|
|
|
+ let olds = await oldDb.findAll({
|
|
|
|
+ limit,
|
|
|
|
+ order,
|
|
|
|
+ // where: {
|
|
|
|
+ // id: {
|
|
|
|
+ // [Sequelize.Op.gt]: '116cc1a93d0ad836'
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ });
|
|
while (olds && olds.length) {
|
|
while (olds && olds.length) {
|
|
for (let i = 0; i < olds.length; i++) {
|
|
for (let i = 0; i < olds.length; i++) {
|
|
const where = {};
|
|
const where = {};
|
|
where[key] = olds[i][key];
|
|
where[key] = olds[i][key];
|
|
-
|
|
|
|
- const old = await newDb.findOne({ where });
|
|
|
|
|
|
+ console.log('old', where)
|
|
|
|
+ const old = await newDb.findAll({ where });
|
|
|
|
+ console.log('old', old)
|
|
if (!old) {
|
|
if (!old) {
|
|
- console.log(olds[i].dataValues)
|
|
|
|
let obj = {...olds[i].dataValues };
|
|
let obj = {...olds[i].dataValues };
|
|
- if (!obj.size) {
|
|
|
|
- obj.size = 0;
|
|
|
|
|
|
+ // if (tableName === 'images') {
|
|
|
|
+ // obj.image_id = obj.imageId;
|
|
|
|
+ // obj.sop_uid = obj.sopUid;
|
|
|
|
+ // obj.image_number = obj.imageNumber;
|
|
|
|
+ // obj.window_width = obj.windowWidth;
|
|
|
|
+ // obj.windo_center = obj.windoCenter;
|
|
|
|
+ // obj.pixe_spacing = obj.pixeSpacing;
|
|
|
|
+ // obj.image_position = obj.imagePosition;
|
|
|
|
+ // obj.image_orientation = obj.imageOrientation;
|
|
|
|
+ // obj.institution_id = obj.hospitalId;
|
|
|
|
+ // }
|
|
|
|
+ try {
|
|
|
|
+ newDb.create(obj);
|
|
|
|
+ } catch (err) {
|
|
|
|
+ errors.push(err.getMessage());
|
|
}
|
|
}
|
|
- newDb.create(obj);
|
|
|
|
}
|
|
}
|
|
if (olds[i].id) {
|
|
if (olds[i].id) {
|
|
id = olds[i].id;
|
|
id = olds[i].id;
|
|
}
|
|
}
|
|
- console.log('where', where, newDb, olds[i], createdAt, { where: { id: { "$gte": id } } })
|
|
|
|
}
|
|
}
|
|
olds = await oldDb.findAll({
|
|
olds = await oldDb.findAll({
|
|
where: {
|
|
where: {
|
|
@@ -248,8 +501,129 @@ async function copyLimit(oldDb, newDb, key) {
|
|
order
|
|
order
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
+ const oldCount = await oldDb.count();
|
|
|
|
+ const newCount = await newDb.count();
|
|
|
|
+ return {
|
|
|
|
+ tableName,
|
|
|
|
+ oldCount,
|
|
|
|
+ newCount,
|
|
|
|
+ dCount: newCount - oldCount,
|
|
|
|
+ errors
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+export async function limitCallBack(DbController, tableName, callback, param) {
|
|
|
|
+ let id = null;
|
|
|
|
+ const limit = 1000;
|
|
|
|
+ const order = [
|
|
|
|
+ ['id', 'asc']
|
|
|
|
+ ];
|
|
|
|
+ const errors = [];
|
|
|
|
+ let olds = await DbController.findAll({
|
|
|
|
+ limit,
|
|
|
|
+ order
|
|
|
|
+ });
|
|
|
|
+ while (olds && olds.length) {
|
|
|
|
+ for (let i = 0; i < olds.length; i++) {
|
|
|
|
+ try {
|
|
|
|
+ await callback(olds[i], param);
|
|
|
|
+ id = olds[i].id;
|
|
|
|
+ } catch (err) {
|
|
|
|
+ console.log(err)
|
|
|
|
+ // return
|
|
|
|
+ errors.push(err.getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ olds = await DbController.findAll({
|
|
|
|
+ where: {
|
|
|
|
+ id: {
|
|
|
|
+ [Sequelize.Op.gt]: id
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ limit,
|
|
|
|
+ order
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ return {
|
|
|
|
+ tableName,
|
|
|
|
+ errors
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+export async function limitMultipleCallBack(DbController, tableName, callback, param) {
|
|
|
|
+ const dict = '0123456789abcdefghigklmnopqrstuvwxyz';
|
|
|
|
+
|
|
|
|
+ let i = 0;
|
|
|
|
+ let j = 0;
|
|
|
|
+ while (i < dict.length) {
|
|
|
|
+ j = 0;
|
|
|
|
+ while (j < dict.length) {
|
|
|
|
+ limitMultipleCallBackSingle(DbController, tableName, callback, param, dict[i] + dict[j], dict[i] + dict[j++] + 'ffffffffffffffff');
|
|
|
|
+ }
|
|
|
|
+ i++;
|
|
|
|
+ }
|
|
|
|
+ // limitMultipleCallBackSingle(DbController, tableName, callback, param, '116d6d', '116d' + 'ffffffffffffffff');
|
|
|
|
+ // limitMultipleCallBackSingle(DbController, tableName, callback, param, '116f', '116f' + 'ffffffffffffffff');
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+export async function limitMultipleCallBackSingle(DbController, tableName, callback, params, start, end) {
|
|
|
|
+ let id = start;
|
|
|
|
+ const limit = 1000;
|
|
|
|
+ const order = [
|
|
|
|
+ ['id', 'asc']
|
|
|
|
+ ];
|
|
|
|
+ const errors = [];
|
|
|
|
+ let olds = await DbController.findAll({
|
|
|
|
+ limit,
|
|
|
|
+ order,
|
|
|
|
+ where: {
|
|
|
|
+ id: {
|
|
|
|
+ [Sequelize.Op.gt]: id,
|
|
|
|
+ [Sequelize.Op.lt]: end
|
|
|
|
+ },
|
|
|
|
+ study_id: {
|
|
|
|
+ [Op.ne]: null
|
|
|
|
+ },
|
|
|
|
+ studyuid: null
|
|
|
|
+ },
|
|
|
|
+ });
|
|
|
|
+ while (olds && olds.length) {
|
|
|
|
+ for (let i = 0; i < olds.length; i++) {
|
|
|
|
+ try {
|
|
|
|
+ await callback(olds[i], params);
|
|
|
|
+ id = olds[i].id;
|
|
|
|
+ } catch (err) {
|
|
|
|
+ console.log(err)
|
|
|
|
+ // return
|
|
|
|
+ errors.push(err.getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ olds = await DbController.findAll({
|
|
|
|
+ where: {
|
|
|
|
+ id: {
|
|
|
|
+ [Sequelize.Op.gt]: id,
|
|
|
|
+ [Sequelize.Op.lt]: end
|
|
|
|
+ },
|
|
|
|
+ study_id: {
|
|
|
|
+ [Op.ne]: null
|
|
|
|
+ },
|
|
|
|
+ studyuid: null
|
|
|
|
+ },
|
|
|
|
+ limit,
|
|
|
|
+ order
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ return {
|
|
|
|
+ tableName,
|
|
|
|
+ errors
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
// 2.0
|
|
// 2.0
|
|
// bbs 表 (对话表)
|
|
// bbs 表 (对话表)
|