浏览代码

feat: 优化

zhangjie 1 年之前
父节点
当前提交
2c54024d33

+ 16 - 0
electron/db/modelApi/trackTask.ts

@@ -36,6 +36,7 @@ export async function createTrackTask(
       {
       {
         where: {
         where: {
           status: { [Op.ne]: TRACK_TASK_STATUS.FINISH },
           status: { [Op.ne]: TRACK_TASK_STATUS.FINISH },
+          schoolId: data.schoolId,
         },
         },
         transaction: t,
         transaction: t,
       }
       }
@@ -58,6 +59,21 @@ export async function createTrackTask(
   }
   }
 }
 }
 
 
+export async function finishAllUnfinishTask(schoolId: string) {
+  await TrackTask.update(
+    {
+      status: TRACK_TASK_STATUS.FINISH,
+      error: '强制结束',
+    },
+    {
+      where: {
+        status: { [Op.ne]: TRACK_TASK_STATUS.FINISH },
+        schoolId,
+      },
+    }
+  );
+}
+
 export async function updateTrackTaskStatus(data: {
 export async function updateTrackTaskStatus(data: {
   id: number;
   id: number;
   status: TrackTaskStatusKey;
   status: TrackTaskStatusKey;

+ 4 - 2
electron/preload/api.ts

@@ -62,10 +62,12 @@ function drawTrack(
       if (track.type === 'text') {
       if (track.type === 'text') {
         const { x, y, text, color, fontSize } =
         const { x, y, text, color, fontSize } =
           track.option as DrawTrackTextOption;
           track.option as DrawTrackTextOption;
+        const fsize = fontSize || defaultFontSize;
+        const ny = y + fsize;
         gmObj
         gmObj
           .fill(color || defaultColor)
           .fill(color || defaultColor)
-          .fontSize(fontSize || defaultFontSize)
-          .drawText(x, y, text);
+          .fontSize(fsize)
+          .drawText(x, ny, text);
         return;
         return;
       }
       }
       // circle
       // circle

+ 2 - 0
electron/preload/apiDb.ts

@@ -8,6 +8,7 @@ import {
   getTrackTaskDetailCount,
   getTrackTaskDetailCount,
   getUnfinishTrackTaskDetail,
   getUnfinishTrackTaskDetail,
   updateTrackTaskDetailStatus,
   updateTrackTaskDetailStatus,
+  finishAllUnfinishTask,
 } from '../db/modelApi/trackTask';
 } from '../db/modelApi/trackTask';
 
 
 createDb();
 createDb();
@@ -22,6 +23,7 @@ const dbApi = {
   getTrackTaskDetailCount,
   getTrackTaskDetailCount,
   getUnfinishTrackTaskDetail,
   getUnfinishTrackTaskDetail,
   updateTrackTaskDetailStatus,
   updateTrackTaskDetailStatus,
+  finishAllUnfinishTask,
 };
 };
 
 
 export type DbApi = typeof dbApi;
 export type DbApi = typeof dbApi;

+ 1 - 0
electron/preload/utils.ts

@@ -33,6 +33,7 @@ export function getImagicPath() {
 }
 }
 
 
 export function getGmFontPath() {
 export function getGmFontPath() {
+  // return path.join(getResourcesDir(), './font/STHeiti Medium.ttc');
   return path.join(getResourcesDir(), './font/simsun.ttf');
   return path.join(getResourcesDir(), './font/simsun.ttf');
 }
 }
 
 

+ 22 - 2
src/views/base/track-export/index.vue

@@ -77,7 +77,7 @@
 </template>
 </template>
 
 
 <script setup lang="ts">
 <script setup lang="ts">
-  import { ref, reactive } from 'vue';
+  import { ref, reactive, onMounted } from 'vue';
   import { Message, TableColumnData } from '@arco-design/web-vue';
   import { Message, TableColumnData } from '@arco-design/web-vue';
 
 
   import useTable from '@/hooks/table';
   import useTable from '@/hooks/table';
@@ -90,6 +90,7 @@
   import { useAppStore, useUserStore } from '@/store';
   import { useAppStore, useUserStore } from '@/store';
   import { OptionListItem } from '@/types/global';
   import { OptionListItem } from '@/types/global';
   import useTask from './useTask';
   import useTask from './useTask';
+  import { modalConfirm } from '../../../utils/arco';
 
 
   import TaskDetailBuildProgess from './taskDetailBuildProgess.vue';
   import TaskDetailBuildProgess from './taskDetailBuildProgess.vue';
   import ModifySet from './modifySet.vue';
   import ModifySet from './modifySet.vue';
@@ -314,6 +315,25 @@
       const trackConfig = JSON.parse(res) as TrackConfigType;
       const trackConfig = JSON.parse(res) as TrackConfigType;
       appStore.setInfo({ trackConfig });
       appStore.setInfo({ trackConfig });
     }
     }
+
+    const unfinishTask = await window.db.getUnfinishTrackTask(
+      userStore.curSchoolInfo.id
+    );
+    if (!unfinishTask) return;
+
+    const confirmRes = await modalConfirm(
+      '提示',
+      `存在未完成的下载任务,是否继续?`
+    ).catch(() => false);
+    if (confirmRes === 'confirm') {
+      taskProgressRef.value?.open();
+      return;
+    }
+
+    await window.db.finishAllUnfinishTask(userStore.curSchoolInfo.id);
   }
   }
-  initData();
+
+  onMounted(() => {
+    initData();
+  });
 </script>
 </script>

+ 10 - 3
src/views/base/track-export/taskProgress.vue

@@ -19,8 +19,14 @@
       :column="1"
       :column="1"
     />
     />
 
 
-    <a-descriptions title="进度">
-      <a-descriptions-item label="">
+    <a-descriptions title="进度" :column="1" :align="{ label: 'right' }">
+      <a-descriptions-item label="任务总数">
+        {{ total }}
+      </a-descriptions-item>
+      <a-descriptions-item label="完成数量">
+        {{ finishCount }}
+      </a-descriptions-item>
+      <a-descriptions-item label="总体进度">
         <a-progress :percent="progressNum" :stroke-width="10" />
         <a-progress :percent="progressNum" :stroke-width="10" />
       </a-descriptions-item>
       </a-descriptions-item>
     </a-descriptions>
     </a-descriptions>
@@ -149,7 +155,8 @@
     });
     });
     updateProgress();
     updateProgress();
 
 
-    window.electron.startWinProcess(3, getExportUrl());
+    // 开启导出进程
+    window.electron.startWinProcess(2, getExportUrl());
   }
   }
 
 
   async function toCancel() {
   async function toCancel() {

+ 48 - 9
src/views/base/track-export/useDraw.ts

@@ -275,6 +275,7 @@ export default function useDraw(winId: number) {
       const answerTags = paserRecogData(i);
       const answerTags = paserRecogData(i);
       drawTrackList.push(...answerTags);
       drawTrackList.push(...answerTags);
       drawTrackList.push(...markDeailList[i]);
       drawTrackList.push(...markDeailList[i]);
+      drawTrackList.push(getTotalTrack(img));
 
 
       trackData[i] = {
       trackData[i] = {
         url: img.url,
         url: img.url,
@@ -489,22 +490,46 @@ export default function useDraw(winId: number) {
         });
         });
       });
       });
 
 
+      // 填空题的打分需要自动换行,目前一行只展示最多7个评分
+      let offsetY = -20;
       Object.values(userMap).forEach((user, index) => {
       Object.values(userMap).forEach((user, index) => {
-        const userScore = user.scores
-          .map((item) => `${item.subNumber}:${item.score}分`)
-          .join(',');
-
         const zhs = ['一', '二', '三'];
         const zhs = ['一', '二', '三'];
         const prename = isDoubleMark ? `${zhs[index] || ''}评` : '评卷员';
         const prename = isDoubleMark ? `${zhs[index] || ''}评` : '评卷员';
-        const content = `${prename}:${user.userName},评分:${userScore}`;
+
+        const userScore = user.scores.map(
+          (item) => `${item.subNumber}:${item.score}分`
+        );
+        const lineScoreCount = 10;
+        const groupCount = Math.ceil(userScore.length / lineScoreCount);
+        const groups: string[] = [];
+        for (let i = 0; i < groupCount; i++) {
+          groups.push(
+            userScore
+              .slice(i * lineScoreCount, (i + 1) * lineScoreCount)
+              .join(',')
+          );
+        }
+
+        offsetY += 20;
         dataArr.push({
         dataArr.push({
           type: 'text',
           type: 'text',
           option: {
           option: {
             x: area.x,
             x: area.x,
-            y: area.y + index * 20,
-            text: content,
+            y: area.y + offsetY,
+            text: `${prename}:${user.userName},评分:`,
           },
           },
         });
         });
+        groups.forEach((group) => {
+          offsetY += 20;
+          dataArr.push({
+            type: 'text',
+            option: {
+              x: area.x,
+              y: area.y + offsetY,
+              text: group,
+            },
+          });
+        });
       });
       });
 
 
       const score = calcSum(groupQuestions.map((item) => item.score || 0));
       const score = calcSum(groupQuestions.map((item) => item.score || 0));
@@ -514,7 +539,7 @@ export default function useDraw(winId: number) {
       dataArr.push({
       dataArr.push({
         type: 'text',
         type: 'text',
         option: {
         option: {
-          x: area.x + area.w - Math.ceil(tContLen * 20),
+          x: area.x + area.w - Math.ceil(tContLen * 30),
           y: area.y,
           y: area.y,
           text: tCont,
           text: tCont,
           fontSize: 30,
           fontSize: 30,
@@ -570,7 +595,7 @@ export default function useDraw(winId: number) {
       dataArr.push({
       dataArr.push({
         type: 'text',
         type: 'text',
         option: {
         option: {
-          x: area.x + area.w - Math.ceil(tContLen * 20),
+          x: area.x + area.w - Math.ceil(tContLen * 30),
           y: area.y,
           y: area.y,
           text: tCont,
           text: tCont,
           fontSize: 30,
           fontSize: 30,
@@ -581,6 +606,20 @@ export default function useDraw(winId: number) {
     return dataList;
     return dataList;
   }
   }
 
 
+  function getTotalTrack(image: ImageItem): DrawTrackItem {
+    const totalScore = rawTask.markerScore || 0;
+    const objectiveScore = rawTask.objectiveScore || 0;
+    const subjectiveScore = totalScore - objectiveScore;
+    return {
+      type: 'text',
+      option: {
+        x: 0.15 * image.width,
+        y: 0.01 * image.height,
+        text: `总分:${totalScore},主观题得分:${subjectiveScore},客观题得分:${objectiveScore}`,
+      },
+    };
+  }
+
   // 获取属于填空题的试题号
   // 获取属于填空题的试题号
   function getFillLines() {
   function getFillLines() {
     const questions: Record<number, string[]> = {};
     const questions: Record<number, string[]> = {};

+ 2 - 2
src/views/login/login/index.vue

@@ -83,8 +83,8 @@
   const formData = reactive<LoginData>({
   const formData = reactive<LoginData>({
     schoolCode: '',
     schoolCode: '',
     type: 'ACCOUNT',
     type: 'ACCOUNT',
-    loginName: 'admin',
-    password: 'autumn123',
+    loginName: '',
+    password: '',
   });
   });
 
 
   const rules: FormRules<keyof LoginData> = {
   const rules: FormRules<keyof LoginData> = {