|
@@ -54,6 +54,7 @@ module.exports={
|
|
|
uploadToken:uploadToken,
|
|
|
downLoadProjectFile:downLoadProjectFile,
|
|
|
importChongqingProject:importChongqingProject,
|
|
|
+ importExampleProject:importExampleProject,
|
|
|
importProcessChecking:importProcessChecking,
|
|
|
copyConstructionProject,
|
|
|
importInterface,
|
|
@@ -1769,32 +1770,45 @@ async function importChongqingProject(data) {
|
|
|
};
|
|
|
await importLogsModel.create(log_data);
|
|
|
doImport(data.user_id,data.session.sessionCompilation._id,data.session.sessionCompilation.adProjects,data.key);
|
|
|
+ return "start importing";
|
|
|
+}
|
|
|
+
|
|
|
+//加载例题
|
|
|
+async function importExampleProject(data) {
|
|
|
|
|
|
+ let log_data = {
|
|
|
+ key:data.key,
|
|
|
+ content: '正在导入例题,请稍候……',
|
|
|
+ userID:data.user_id,
|
|
|
+ compilationID: data.session.sessionCompilation._id,
|
|
|
+ status:"start",
|
|
|
+ create_time:+new Date()
|
|
|
+ };
|
|
|
+ await importLogsModel.create(log_data);
|
|
|
+ doImport(data.user_id,data.session.sessionCompilation._id,data.session.sessionCompilation.example,data.key);
|
|
|
return "start importing";
|
|
|
- async function doImport(user_id,compilationId,projectIDs,key) {
|
|
|
- let doc = {status:"finish"};
|
|
|
- try {
|
|
|
- let r = await copyExample(user_id,compilationId,projectIDs);
|
|
|
- if(r == false){
|
|
|
- doc.errorMsg = "导入失败,请检查项目是否存在!";
|
|
|
- doc.status = "error";
|
|
|
- } else {
|
|
|
- doc.projectID = r;
|
|
|
- }
|
|
|
- }catch (error){
|
|
|
- console.log(error);
|
|
|
- doc.errorMsg = "导入失败,请检查项目是否存在!";
|
|
|
- doc.status = "error";
|
|
|
- }finally {
|
|
|
- await importLogsModel.update({key:key},doc);
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
-function testTimeout(time) {
|
|
|
- return new Promise(resolve => setTimeout(resolve, time));
|
|
|
+async function doImport(user_id,compilationId,projectIDs,key) {
|
|
|
+ let doc = {status:"finish"};
|
|
|
+ try {
|
|
|
+ let r = await copyExample(user_id,compilationId,projectIDs);
|
|
|
+ if(r == false){
|
|
|
+ doc.errorMsg = "导入失败,请检查项目是否存在!";
|
|
|
+ doc.status = "error";
|
|
|
+ } else {
|
|
|
+ doc.projectID = r;
|
|
|
+ }
|
|
|
+ }catch (error){
|
|
|
+ console.log(error);
|
|
|
+ doc.errorMsg = "导入失败,请检查项目是否存在!";
|
|
|
+ doc.status = "error";
|
|
|
+ }finally {
|
|
|
+ await importLogsModel.update({key:key},doc);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
//用户第一次进入费用定额的数据准备
|
|
|
async function prepareInitialData(userId, compilation, example) {
|
|
|
let first = await isFirst(userId, compilation);
|
|
@@ -1802,7 +1816,7 @@ async function prepareInitialData(userId, compilation, example) {
|
|
|
await updateUsedList(userId, compilation);
|
|
|
const logData = {
|
|
|
key: uuidV1(),
|
|
|
- content: '正在加载例题,请稍候……',
|
|
|
+ content: '正在初始化数据,请稍候……',
|
|
|
userID: userId,
|
|
|
compilationID: compilation,
|
|
|
status: 'start',
|
|
@@ -1819,9 +1833,10 @@ async function prepareInitialData(userId, compilation, example) {
|
|
|
copyCompleRationSection(userId, compilation),
|
|
|
copyCompleGljSection(userId, compilation)
|
|
|
];
|
|
|
- if (example && example.length > 0) {
|
|
|
+ /* 2021-01-19 第一次的时候不自动加载例题,右键加载
|
|
|
+ if (example && example.length > 0) {
|
|
|
prepareTask.push(copyExample(userId, compilation, example));
|
|
|
- }
|
|
|
+ } */
|
|
|
await Promise.all(prepareTask);
|
|
|
} catch (error) {
|
|
|
doc.errorMsg = '加载例题失败,请检查例题项目是否存在!';
|