diff --git a/package.json b/package.json index 76040ca..cb79102 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "@ant-design/icons-angular": "^16.0.0", "crypto-js": "^4.1.1", "date-fns": "^2.30.0", + "echarts": "^5.4.3", "immer": "^10.0.2", "ng-zorro-antd": "16.1.0", "ngx-permissions": "^16.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f8a257e..0c89063 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -41,6 +41,9 @@ dependencies: date-fns: specifier: ^2.30.0 version: 2.30.0 + echarts: + specifier: ^5.4.3 + version: 5.4.3 immer: specifier: ^10.0.2 version: 10.0.2 @@ -3432,6 +3435,7 @@ packages: /debug@3.2.7: resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==} + requiresBuild: true peerDependencies: supports-color: '*' peerDependenciesMeta: @@ -3580,6 +3584,13 @@ packages: resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} dev: true + /echarts@5.4.3: + resolution: {integrity: sha512-mYKxLxhzy6zyTi/FaEbJMOZU1ULGEQHaeIeuMR5L+JnJTpz+YR03mnnpBhbR4+UYJAgiXgpyTVLffPAjOTLkZA==} + dependencies: + tslib: 2.3.0 + zrender: 5.4.4 + dev: false + /ee-first@1.1.1: resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==} dev: true @@ -5766,6 +5777,7 @@ packages: /pify@4.0.1: resolution: {integrity: sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==} engines: {node: '>=6'} + requiresBuild: true dev: true optional: true @@ -5980,6 +5992,7 @@ packages: /prr@1.0.1: resolution: {integrity: sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==} + requiresBuild: true dev: true optional: true @@ -6300,6 +6313,7 @@ packages: /sax@1.2.4: resolution: {integrity: sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==} + requiresBuild: true dev: true optional: true @@ -6336,6 +6350,7 @@ packages: /semver@5.7.2: resolution: {integrity: sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==} hasBin: true + requiresBuild: true dev: true optional: true @@ -7433,3 +7448,9 @@ packages: resolution: {integrity: sha512-7m3hNNyswsdoDobCkYNAy5WiUulkMd3+fWaGT9ij6iq3Zr/IwJo4RMCYPSDjT+r7tnPErmY9sZpKhWQ8S5k6XQ==} dependencies: tslib: 2.3.0 + + /zrender@5.4.4: + resolution: {integrity: sha512-0VxCNJ7AGOMCWeHVyTrGzUgrK4asT4ml9PEkeGirAkKNYXYzoPJCLvmyfdoOXcjTHPs10OZVMfD1Rwg16AZyYw==} + dependencies: + tslib: 2.3.0 + dev: false diff --git a/projects/admin/src/app/components/dish-form/dish-form.component.ts b/projects/admin/src/app/components/dish-form/dish-form.component.ts index 1e3df70..a770f86 100644 --- a/projects/admin/src/app/components/dish-form/dish-form.component.ts +++ b/projects/admin/src/app/components/dish-form/dish-form.component.ts @@ -126,7 +126,7 @@ export class DishFormComponent { } }); if (this.data["icon"]) { - this.iconPreview = "/icon/" + this.data["icon"]; + this.iconPreview = "/api/icon/" + this.data["icon"]; } this.formGroup.patchValue({ ...this.data, diff --git a/projects/admin/src/app/pages/dish/dish.component.html b/projects/admin/src/app/pages/dish/dish.component.html index 411fd98..245dca3 100644 --- a/projects/admin/src/app/pages/dish/dish.component.html +++ b/projects/admin/src/app/pages/dish/dish.component.html @@ -49,7 +49,7 @@
+ [ngStyle]="{'background-image':'url(/api/icon/' + data + ')'}">
diff --git a/projects/admin/src/app/pages/ingredients/ingredient-form/ingredient-form.component.ts b/projects/admin/src/app/pages/ingredients/ingredient-form/ingredient-form.component.ts index 80086d3..46eee0f 100644 --- a/projects/admin/src/app/pages/ingredients/ingredient-form/ingredient-form.component.ts +++ b/projects/admin/src/app/pages/ingredients/ingredient-form/ingredient-form.component.ts @@ -110,7 +110,7 @@ export class IngredientFormComponent implements OnInit { analysis() { this.drawer.create({ - nzWidth: 620, + nzWidth: 20, nzWrapClassName: "analysis-drawer", nzContent: IngredientAnalysisComponent, nzContentParams: { diff --git a/projects/admin/src/app/pages/organization/organization-form/organization-form.component.ts b/projects/admin/src/app/pages/organization/organization-form/organization-form.component.ts index f49c090..deae7da 100644 --- a/projects/admin/src/app/pages/organization/organization-form/organization-form.component.ts +++ b/projects/admin/src/app/pages/organization/organization-form/organization-form.component.ts @@ -63,7 +63,7 @@ export class OrganizationFormComponent { }); this.formGroup.patchValue(this.state); if (this.state["icon"]) { - this.iconPreview = "/icon/" + this.state["icon"]; + this.iconPreview = "/api/icon/" + this.state["icon"]; } } diff --git a/projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.html b/projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.html index 75b5407..79ac07d 100644 --- a/projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.html +++ b/projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.html @@ -1,4 +1,4 @@ - + - \ No newline at end of file + \ No newline at end of file diff --git a/projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.ts b/projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.ts index a0d9a73..38b0a6c 100644 --- a/projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.ts +++ b/projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.ts @@ -7,8 +7,11 @@ import { FormValidators } from "@cdk/validators"; import { NzMessageService } from "ng-zorro-antd/message"; export type StandardItemInterface = { + min: number; + max: number | null; + name: string; type: string; - value: number; + category: string[]; }; export type StandardPeopleInterface = { @@ -47,7 +50,11 @@ export class StandardSettingComponent { state: any; - calcType = "种"; + calcType = this.globalEnum.measurementType?.[0]?.key; + + get calcTypeText() { + return this.globalEnum.measurementType.find((f) => f.key === this.calcType)?.value; + } uploadLoading = false; @@ -89,20 +96,15 @@ export class StandardSettingComponent { if (!data) { return []; } - return Object.entries(data).map(([k, v]) => { - return { - type: k, - value: v as number, - }; - }); + return data; } onSubmit() { - if (this.foodCategoryDay.some((s) => !s.type || !s.value)) { + if (this.foodCategoryDay.some((s) => !s.name || typeof s.min !== "number" || s.category.length === 0)) { this.msg.error("请设置正确的食物种类及数量标准(日)"); return; } - if (this.foodCategoryWeek.some((s) => !s.type || !s.value)) { + if (this.foodCategoryWeek.some((s) => !s.name || typeof s.min !== "number" || s.category.length === 0)) { this.msg.error("请设置正确的食物种类及数量标准(周)"); return; } @@ -110,19 +112,9 @@ export class StandardSettingComponent { this.msg.error("请设置正确的营养标准人群"); return; } - const foodCategoryDay = this.foodCategoryDay.reduce((a, c) => { - return { - ...a, - [c.type]: c.value, - }; - }, {} as AnyObject); + const foodCategoryDay = this.foodCategoryDay; - const foodCategoryWeek = this.foodCategoryWeek.reduce((a, c) => { - return { - ...a, - [c.type]: c.value, - }; - }, {} as AnyObject); + const foodCategoryWeek = this.foodCategoryWeek; const ingredient = this.ingredient.reduce((a, c) => { return { @@ -149,8 +141,14 @@ export class StandardSettingComponent { addFoodType(type: string) { const item = type === "day" ? this.foodCategoryDay : this.foodCategoryWeek; - const withoutSelectType = this.globalEnum.category.find((f) => !item.some((s) => s.type === f.key)); - item.push({ type: withoutSelectType?.key ?? "", value: 1 }); + // const withoutSelectType = this.globalEnum.category.find((f) => !item.some((s) => s.type === f.key)); + item.push({ + category: [], + min: 0, + max: null, + name: "", + type: this.calcType, + }); } removeFoodType(type: string, foodType: string) { diff --git a/projects/cdk/src/dtos/enum.dto.ts b/projects/cdk/src/dtos/enum.dto.ts index 45f423f..176eb4e 100644 --- a/projects/cdk/src/dtos/enum.dto.ts +++ b/projects/cdk/src/dtos/enum.dto.ts @@ -7,6 +7,7 @@ export type GlobalEnum = { venderType: CategoryDTO[]; mealType: OptionItemInterface[]; menuStatus: OptionItemInterface[]; + measurementType: CategoryDTO[]; poly: { key: string; name: string }[]; }; diff --git a/projects/cdk/src/ingredient/confirm-ingredient/confirm-ingredient.component.html b/projects/cdk/src/ingredient/confirm-ingredient/confirm-ingredient.component.html index 5a38bba..25c6b9f 100644 --- a/projects/cdk/src/ingredient/confirm-ingredient/confirm-ingredient.component.html +++ b/projects/cdk/src/ingredient/confirm-ingredient/confirm-ingredient.component.html @@ -4,7 +4,7 @@ 天数 - {{data.day}}天 + 周{{item}} diff --git a/projects/cdk/src/ingredient/ingredient-analysis/ingredient-analysis.component.html b/projects/cdk/src/ingredient/ingredient-analysis/ingredient-analysis.component.html index 5606e50..18f5c38 100644 --- a/projects/cdk/src/ingredient/ingredient-analysis/ingredient-analysis.component.html +++ b/projects/cdk/src/ingredient/ingredient-analysis/ingredient-analysis.component.html @@ -1,9 +1,7 @@ - +
-
- @@ -95,6 +93,15 @@
+
+
+ + + + + +
+

周规则 @@ -129,7 +136,24 @@ {{w.supplied}} - {{w.lack}} + + +
+ +
+
+ + +
+ 超量 +
+
+ + {{w.lack}} + +
+
+ @@ -139,11 +163,13 @@ 日规则

-
+
+ - + + 种类名称 @@ -158,9 +184,9 @@ - - - 第{{d.day}}天 + + + 周{{d.day}} {{d.name}} @@ -172,13 +198,123 @@ {{d.supplied}} - {{d.lack}} + + +
+ +
+
+ + +
+ 超量 +
+
+ + {{d.lack}} + +
+
+
+ +
+
+ + + + + +
+
+
+

+ 人均盐、糖、油摄入量趋势变化 +

+
+ +
+
+
+ +
+
+ + + + + +
+
+
+

+ 总计 +

+
+ + + + + 烹饪方式 + + + 菜品数量 + + + + + + + + {{w.name}} + + + {{w.value}} + + + + +

+ 每日统计 +

+
+ + + + + + 烹饪方式 + + + 菜品数量 + + + + + + + + {{weekdayMap[$any(p.key)]}} + + + {{w.name}} + + + {{w.value}} + + + + + +
+
+
+
\ No newline at end of file diff --git a/projects/cdk/src/ingredient/ingredient-analysis/ingredient-analysis.component.ts b/projects/cdk/src/ingredient/ingredient-analysis/ingredient-analysis.component.ts index 1dc69da..ff7d652 100644 --- a/projects/cdk/src/ingredient/ingredient-analysis/ingredient-analysis.component.ts +++ b/projects/cdk/src/ingredient/ingredient-analysis/ingredient-analysis.component.ts @@ -1,8 +1,15 @@ -import { Component, Input, OnInit } from "@angular/core"; +import { Component, ElementRef, Input, OnInit, ViewChild } from "@angular/core"; import { ActivatedRoute } from "@angular/router"; import { ApiService } from "@cdk/services"; import { finalize } from "rxjs"; import { weekdayMap } from "../ingredient-form-basic/ingredient-form-basic.component"; +import { EChartsType, init } from "echarts"; + +const sugerMap = new Map([ + ["salt", "盐"], + ["sugar", "糖"], + ["oil", "油"], +]); @Component({ selector: "lib-ingredient-analysis", @@ -16,6 +23,10 @@ export class IngredientAnalysisComponent implements OnInit { @Input() current: any; + @ViewChild("sugerTpl", { static: true }) sugerEl!: ElementRef; + + sugerRef?: EChartsType; + currentDay: number = 1; currentPeople!: string; @@ -28,17 +39,22 @@ export class IngredientAnalysisComponent implements OnInit { energy: any; + poly = { + total: [] as any[], + days: {} as any, + }; + + suger: any; + analysisLoading = false; weekdayMap = weekdayMap; ngOnInit(): void { - console.log("this.current", this.menu); this.currentDay = this.current?.day ?? this.menu.day[0]; this.currentPeople = this.menu.crows[0]; this.id = this.route.snapshot.queryParamMap.get("newId") ?? this.menu.id; this.getAnalysis(); - this.getRule(); } getAnalysis() { @@ -56,6 +72,9 @@ export class IngredientAnalysisComponent implements OnInit { }); this.getEnergy(); + this.getRule(); + this.getSugar(); + this.getPoly(); } getEnergy() { @@ -69,4 +88,57 @@ export class IngredientAnalysisComponent implements OnInit { this.rules = res.body; }); } + + getSugar() { + this.api.getAnalysisSugar(this.id, this.currentPeople).subscribe((res) => { + this.suger = res.body; + }); + } + + getPoly() { + this.api.getAnalysisPoly(this.id, this.currentPeople).subscribe((res) => { + const poly = { + total: [] as any[], + days: {} as any, + }; + Object.entries(res.body).forEach(([k, v]) => { + if (k === "0") { + poly.total = Object.entries(v as any).map((o) => ({ name: o[0], value: o[1] })); + } else if (k !== "crow") { + poly.days[k] = Object.entries(v as any).map((o) => ({ name: o[0], value: o[1] })); + } + }); + this.poly = poly; + }); + } + + nzSelectedIndexChange(d: any) { + if (d === 2) { + const xAxis: string[] = Object.keys(this.suger["oil"]).map((i: any) => weekdayMap[i]); + const series: any[] = []; + Object.entries(this.suger).forEach(([k, v]) => { + if (k !== "crow") { + series.push({ + type: "line", + name: sugerMap.get(k), + data: Object.values(v as any), + }); + } + }); + + const option = { + legend: {}, + tooltip: { trigger: "axis" }, + xAxis: { type: "category", data: xAxis }, + yAxis: {}, + series, + }; + + if (!this.sugerRef) { + this.sugerRef = init(this.sugerEl.nativeElement); + } + + this.sugerRef.setOption(option); + } + } } diff --git a/projects/cdk/src/ingredient/ingredient-dish/ingredient-dish.component.ts b/projects/cdk/src/ingredient/ingredient-dish/ingredient-dish.component.ts index 4de393f..8e3d8fa 100644 --- a/projects/cdk/src/ingredient/ingredient-dish/ingredient-dish.component.ts +++ b/projects/cdk/src/ingredient/ingredient-dish/ingredient-dish.component.ts @@ -111,7 +111,7 @@ export class IngredientDishComponent implements OnChanges { const d = weekdayMap[i]; this.selectDay.push({ label: d, - value: String(d), + value: String(i), }); this.mealCurrentIndex[i] = 0; this.expanded.add(i); @@ -144,7 +144,7 @@ export class IngredientDishComponent implements OnChanges { reuse(day: number, nzContent: TemplateRef<{}>) { const thisDayDishs = this.mealDishList.filter((f) => f.day === day); - console.log("dayDishs", day, this.mealDishList, thisDayDishs); + console.log("dayDishs", day, this.mealDishList, thisDayDishs, this.selectDay); this.modal.create({ nzTitle: "请选择应用到的日期", nzContent, @@ -166,7 +166,7 @@ export class IngredientDishComponent implements OnChanges { analysis(day: number) { console.log("this.days", this.days); this.drawer.create({ - nzWidth: 620, + nzWidth: 720, nzWrapClassName: "analysis-drawer", nzContent: IngredientAnalysisComponent, nzContentParams: { diff --git a/projects/cdk/src/ingredient/ingredient-preview/ingredient-preview.component.ts b/projects/cdk/src/ingredient/ingredient-preview/ingredient-preview.component.ts index 3d64155..15a4139 100644 --- a/projects/cdk/src/ingredient/ingredient-preview/ingredient-preview.component.ts +++ b/projects/cdk/src/ingredient/ingredient-preview/ingredient-preview.component.ts @@ -140,7 +140,7 @@ export class IngredientPreviewComponent { analysis(day: number) { this.drawer.create({ - nzWidth: 620, + nzWidth: 720, nzWrapClassName: "analysis-drawer", nzContent: IngredientAnalysisComponent, nzContentParams: { diff --git a/projects/cdk/src/services/api.service.ts b/projects/cdk/src/services/api.service.ts index c0850c3..09ec496 100644 --- a/projects/cdk/src/services/api.service.ts +++ b/projects/cdk/src/services/api.service.ts @@ -556,6 +556,17 @@ export class ApiService { const params = Utils.objectStringify({ id, day, crow }); return this.http.get(`/api/menu/analysis/energy?${params}`); } + + getAnalysisSugar(id: string, crow?: string) { + const params = Utils.objectStringify({ id, crow }); + return this.http.get(`/api/menu/analysis/sugar?${params}`); + } + + getAnalysisPoly(id: string, crow?: string) { + const params = Utils.objectStringify({ id, crow }); + return this.http.get(`/api/menu/analysis/poly?${params}`); + } + getAnalysisRule(id: string, day?: number, crow?: string) { const params = Utils.objectStringify({ id, day, crow }); return this.http.get(`/api/menu/analysis/types?${params}`); diff --git a/projects/client/src/app/components/dish-form/dish-form.component.ts b/projects/client/src/app/components/dish-form/dish-form.component.ts index b704841..600bc08 100644 --- a/projects/client/src/app/components/dish-form/dish-form.component.ts +++ b/projects/client/src/app/components/dish-form/dish-form.component.ts @@ -125,7 +125,7 @@ export class DishFormComponent { mark: this.data.marks, }); if (this.data["icon"]) { - this.iconPreview = "/icon/" + this.data["icon"]; + this.iconPreview = "/api/icon/" + this.data["icon"]; } } } diff --git a/projects/client/src/app/components/org-form/org-form.component.ts b/projects/client/src/app/components/org-form/org-form.component.ts index 318408d..880776c 100644 --- a/projects/client/src/app/components/org-form/org-form.component.ts +++ b/projects/client/src/app/components/org-form/org-form.component.ts @@ -48,7 +48,7 @@ export class OrgFormComponent { }); this.formGroup.patchValue(this.state); if (this.state["icon"]) { - this.iconPreview = "/icon/" + this.state["icon"]; + this.iconPreview = "/api/icon/" + this.state["icon"]; } } diff --git a/projects/client/src/app/pages/dashboard/dashboard.component.html b/projects/client/src/app/pages/dashboard/dashboard.component.html index c2c0c07..9e92c70 100644 --- a/projects/client/src/app/pages/dashboard/dashboard.component.html +++ b/projects/client/src/app/pages/dashboard/dashboard.component.html @@ -91,7 +91,7 @@

  • - 点击右上角[食谐预览]完成查看食谱全貌 + 点击右上角[食谱预览]完成查看食谱全貌
  • 确认食谱应用分析结果 diff --git a/projects/client/src/app/pages/data-vis/data-vis.component.html b/projects/client/src/app/pages/data-vis/data-vis.component.html index db727a4..a028e3e 100644 --- a/projects/client/src/app/pages/data-vis/data-vis.component.html +++ b/projects/client/src/app/pages/data-vis/data-vis.component.html @@ -1,7 +1,7 @@

    {{orgName}}食谱营养报告

    {{showTime}}
    diff --git a/projects/client/src/app/pages/dish/dish.component.html b/projects/client/src/app/pages/dish/dish.component.html index 78e10f6..5bc9db4 100644 --- a/projects/client/src/app/pages/dish/dish.component.html +++ b/projects/client/src/app/pages/dish/dish.component.html @@ -60,7 +60,7 @@
    + [ngStyle]="{'background-image':'url(/api/icon/' + data + ')'}">
    diff --git a/projects/client/src/app/pages/ingredients/ingredient-form/ingredient-form.component.ts b/projects/client/src/app/pages/ingredients/ingredient-form/ingredient-form.component.ts index 21a3985..65a19d1 100644 --- a/projects/client/src/app/pages/ingredients/ingredient-form/ingredient-form.component.ts +++ b/projects/client/src/app/pages/ingredients/ingredient-form/ingredient-form.component.ts @@ -108,7 +108,7 @@ export class IngredientFormComponent implements OnInit { analysis() { this.drawer.create({ - nzWidth: 620, + nzWidth: 720, nzWrapClassName: "analysis-drawer", nzContent: IngredientAnalysisComponent, nzContentParams: { diff --git a/projects/client/src/app/pages/system/org-info/org-info.component.html b/projects/client/src/app/pages/system/org-info/org-info.component.html index bd941e5..b0c5755 100644 --- a/projects/client/src/app/pages/system/org-info/org-info.component.html +++ b/projects/client/src/app/pages/system/org-info/org-info.component.html @@ -25,7 +25,7 @@
    - +