Skip to content

Commit

Permalink
feat: 公务员招录分析适应新表结构
Browse files Browse the repository at this point in the history
  • Loading branch information
huayemao committed Jun 24, 2024
1 parent d65be50 commit 58117f8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
1 change: 1 addition & 0 deletions app/(content)/data-process/constants.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const PROFESSION_TABLE_NAME = "普通高等学校本科专业目录";
8 changes: 5 additions & 3 deletions app/(content)/data-process/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { useContext, useEffect, useMemo, useState } from "react";
import { DBContext } from "./DBContext";
import ProfessionTable from "./ProfessionTable";
import { Table } from "./Table";
import { PROFESSION_TABLE_NAME } from "./constants";
import { Field } from "./types";

export default function Home() {
Expand Down Expand Up @@ -65,7 +66,7 @@ export default function Home() {

const shouldHavProfessionTable = baseTables
?.map((e) => e.name)
.includes("本科专业目录");
.includes(PROFESSION_TABLE_NAME);

return (
<div className="bg-white w-full p-8">
Expand Down Expand Up @@ -99,11 +100,12 @@ export default function Home() {
</BaseList>
<BaseInputFile
id="fileInput"
onChange={(files) => {
onChange={async (files) => {
const file = files?.[0] as File;
if (file) {
const url = URL.createObjectURL(file);
dbWorker?.readWriteDB(encodeURIComponent(file.name), url);
await dbWorker?.readWriteDB(encodeURIComponent(file.name), url);
refetch()
}
}}
/>
Expand Down
6 changes: 3 additions & 3 deletions app/(content)/data-process/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export type JobGroup = {
};

export type Profession = {
学科门类: string;
专业类: string;
专业: string;
学位授予门类: string;
"门类、专业类": string;
专业名称: string;
岗位数: number;
};
export interface Field {
Expand Down
12 changes: 6 additions & 6 deletions app/(content)/data-process/util.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function parseAlltables(dbWorker, baseTables: any[]) {

return execSql(professionsSql)
.then((res) => (jobGroupsByProfession = res as JobGroup[]))
.then(() => dbWorker?.execSql(`select * from 本科专业目录;`))
.then(() => dbWorker?.execSql(`select * from 普通高等学校本科专业目录;`))
.then((res) => {
professions = res.filter(
(e) => !["▲", "★"].some((s) => JSON.stringify(e).includes(s))
Expand Down Expand Up @@ -92,8 +92,8 @@ export function parseProfessionJobCount(

cats.forEach((c) => {
professions.forEach((p) => {
const pCat = p.学科门类.replace("【门类】", "");
if (c === pCat) {
const cats = p.学位授予门类.split(',');
if (cats.includes('c')) {
countJobGroup(jobGroup, p);
}
});
Expand All @@ -107,7 +107,7 @@ export function parseProfessionJobCount(
elements.forEach((c) => {
if (c.endsWith("门类")) {
professions.forEach((p) => {
if (p.学科门类 === c.replace("门类", "")) {
if (p.学位授予门类 === c.replace("门类", "")) {
countJobGroup(jobGroup, p);
}
});
Expand All @@ -124,14 +124,14 @@ export function parseProfessionJobCount(
});
} else if (c.endsWith("类")) {
professions.forEach((p) => {
const pCat = p.专业类.replace("【", "").replace("】", "");
const pCat = p["门类、专业类"];
if (c === pCat) {
countJobGroup(jobGroup, p);
}
});
} else {
professions.forEach((p) => {
if (c === p.专业) {
if (c === p.专业名称) {
countJobGroup(jobGroup, p);
}
});
Expand Down

0 comments on commit 58117f8

Please sign in to comment.