Skip to content

Commit

Permalink
Merge pull request #124 from sj-distributor/camera-ai-1.1
Browse files Browse the repository at this point in the history
Camera ai 1.1
  • Loading branch information
mindy0-0 authored Aug 20, 2024
2 parents d6fa0a9 + 48a1aa2 commit 6b066e3
Show file tree
Hide file tree
Showing 9 changed files with 508 additions and 8 deletions.
9 changes: 9 additions & 0 deletions web/src/i18n/language/keys/monitor-configuration-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,13 @@ export default {
SELECT_RULE_TIPS: "SelectRuleTips",
BACK: "Back",
CONFIRM: "Confirm",
ANIMAL_TYPE_TIPS: "AnimalTypeTips",
COSTUME_TYPE_TIPS: "CostumeTypeTips",
EQUIPMENT_TYPE_TIPS: "EquipmentTypeTips",
EQUIPMENT_TYPE: "EquipmentType",
NOTICE_STRATEGY: "NoticeStrategy",
SINGLE_NOTICE: "SingleNotice",
SINGLE_NOTICE_TIME: "SingleNoticeTime",
SINGLE_NOTICE_TIME_TIPS: "SingleNoticeTimeTips",
SINGLE_NOTICE_TIPS: "SingleNoticeTips",
};
10 changes: 10 additions & 0 deletions web/src/i18n/language/keys/monitor-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,14 @@ export default {
IDENTIFY_VEHICLES: "IdentifyVehicles",
IDENTIFY_ABNORMAL_VEHICLES: "identifyAbnormalVehicles",
SECURITY: "Security",
ANIMAL: "Animal",
CAT: "Cat",
DOG: "Dog",
BIRD: "Bird",
SMOKE: "Smoke",
FIGHT: "Fight",
COSTUME: "Costume",
FlUORESCENTCLOTHING: "FluorescentClothing",
GLOVES: "Gloves",
SAFETYSHOES: "SafetyShoes",
};
20 changes: 19 additions & 1 deletion web/src/i18n/language/pages/monitor-configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ export default {
[KEYS.SELECT_RULE_TIPS]: "Please select(Multiple Choices)",
[KEYS.BACK]: "Back",
[KEYS.CONFIRM]: "Confirm",
[KEYS.ANIMAL_TYPE_TIPS]: "Please select at least one animal type",
[KEYS.COSTUME_TYPE_TIPS]: "Please select at least one safety type",
[KEYS.EQUIPMENT_TYPE_TIPS]: "Please select equipment type",
[KEYS.EQUIPMENT_TYPE]: "Equipment type",
[KEYS.NOTICE_STRATEGY]: "Notification strategy",
[KEYS.SINGLE_NOTICE]: "single notification",
[KEYS.SINGLE_NOTICE_TIME]: "limited time",
[KEYS.SINGLE_NOTICE_TIME_TIPS]: "Please enter a limited time",
[KEYS.SINGLE_NOTICE_TIPS]: "Note: Only notify once within a limited time",
},
ch: {
[KEYS.MONITOR]: "監測管理",
Expand All @@ -64,7 +73,7 @@ export default {
[KEYS.TITLE]: "標題",
[KEYS.TITLE_PLACEHOLDER]: "请输入预警标题",
[KEYS.RULE_SETTING]: "規則設置",
[KEYS.EXCEPTION_TYPE]: "異常類型",
[KEYS.EXCEPTION_TYPE]: "AI檢測事件模型",
[KEYS.DURATION_TIME]: "持續時長",
[KEYS.EXCEPTION_TYPE_PLACEHOLDER]: "選擇異常類型",
[KEYS.DURATION_TIME_PLACEHOLDER]: "请输入持續時長",
Expand Down Expand Up @@ -108,5 +117,14 @@ export default {
[KEYS.SELECT_RULE_TIPS]: "請選擇(可多選)",
[KEYS.BACK]: "返回",
[KEYS.CONFIRM]: "確定",
[KEYS.ANIMAL_TYPE_TIPS]: "請至少選擇一種動物配備類型",
[KEYS.COSTUME_TYPE_TIPS]: "請至少選擇一種安全配備類型",
[KEYS.EQUIPMENT_TYPE_TIPS]: "請選擇配備類型",
[KEYS.EQUIPMENT_TYPE]: "配備類型",
[KEYS.NOTICE_STRATEGY]: "通知策略",
[KEYS.SINGLE_NOTICE]: "單次通知",
[KEYS.SINGLE_NOTICE_TIME]: "限定時間",
[KEYS.SINGLE_NOTICE_TIME_TIPS]: "請輸入限定時間",
[KEYS.SINGLE_NOTICE_TIPS]: "說明:限定時間內只通知一次",
},
};
20 changes: 20 additions & 0 deletions web/src/i18n/language/pages/monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ export default {
[KEYS.IDENTIFY_VEHICLES]: "Identify vehicles",
[KEYS.IDENTIFY_ABNORMAL_VEHICLES]: "identify abnormal vehicles",
[KEYS.SECURITY]: "Security",
[KEYS.ANIMAL]: "Animal",
[KEYS.CAT]: "Cat",
[KEYS.DOG]: "Dog",
[KEYS.BIRD]: "Bird",
[KEYS.SMOKE]: "Smoke",
[KEYS.FIGHT]: "Fight",
[KEYS.COSTUME]: "Costume",
[KEYS.FlUORESCENTCLOTHING]: "FluorescentClothing",
[KEYS.GLOVES]: "Gloves",
[KEYS.SAFETYSHOES]: "SafetyShoes",
},
ch: {
[KEYS.MONITOR]: "監測管理",
Expand All @@ -48,5 +58,15 @@ export default {
[KEYS.IDENTIFY_VEHICLES]: "識別車輛",
[KEYS.IDENTIFY_ABNORMAL_VEHICLES]: "識別異常車輛",
[KEYS.SECURITY]: "防盜功能",
[KEYS.ANIMAL]: "識別動物入侵",
[KEYS.CAT]: "猫",
[KEYS.DOG]: "狗",
[KEYS.BIRD]: "鸟",
[KEYS.SMOKE]: "識別吸煙",
[KEYS.FIGHT]: "識別打架",
[KEYS.COSTUME]: "識別安全配備",
[KEYS.FlUORESCENTCLOTHING]: "螢光衣",
[KEYS.GLOVES]: "手套",
[KEYS.SAFETYSHOES]: "安全鞋",
},
};
16 changes: 16 additions & 0 deletions web/src/pages/monitor/component/add-select-type/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@ export const useAction = () => {
value: CameraAiMonitorType.Security,
label: `${t(MONITOR_KEY.SECURITY, monitorSource)}`,
},
{
value: CameraAiMonitorType.Smoke,
label: `${t(MONITOR_KEY.SMOKE, monitorSource)}`,
},
{
value: CameraAiMonitorType.Fight,
label: `${t(MONITOR_KEY.FIGHT, monitorSource)}`,
},
{
value: CameraAiMonitorType.Costume,
label: `${t(MONITOR_KEY.COSTUME, monitorSource)}`,
},
{
value: CameraAiMonitorType.Animal,
label: `${t(MONITOR_KEY.ANIMAL, monitorSource)}`,
},
];

return { monitorTypeOption, token, navigate, KEYS, t, source };
Expand Down
137 changes: 133 additions & 4 deletions web/src/pages/monitor/component/add-update-configuration/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { Moment } from "moment";
import { useAuth } from "@/hooks/use-auth";

import KEYS from "../../../../i18n/language/keys/monitor-configuration-keys";
import MONITOR_KEY from "../../../../i18n/language/keys/monitor-keys";

import {
ICronListDto,
IOptionsNumberDto,
Expand Down Expand Up @@ -75,10 +77,11 @@ export const useAction = () => {
title: t(KEYS.SHORT_MESSAGE, source),
type: CameraAiNotificationType.Sms,
},
{
title: t(KEYS.TELEPHONE, source),
type: CameraAiNotificationType.PhoneCall,
},
// 电话暂时隐藏
// {
// title: t(KEYS.TELEPHONE, source),
// type: CameraAiNotificationType.PhoneCall,
// },
];

const initCronList = [
Expand Down Expand Up @@ -145,8 +148,72 @@ export const useAction = () => {

const [submitLoading, setSubmitLoadin] = useState<boolean>(false);

const [selectModalType, setSelectModalType] = useState<CameraAiMonitorType[]>(
[]
);

const [costumeAnimalType, setCostumeAnimalType] = useState<
CameraAiMonitorType[]
>([]);

const [isSelecteSecurity, setIsSelectSecurity] = useState<boolean>(false);

const animalOptions = [
{
value: CameraAiMonitorType.Cat,
label: t(MONITOR_KEY.CAT, {
ns: "monitor",
}),
},
{
value: CameraAiMonitorType.Dog,
label: t(MONITOR_KEY.DOG, {
ns: "monitor",
}),
},
{
value: CameraAiMonitorType.Bird,
label: t(MONITOR_KEY.BIRD, {
ns: "monitor",
}),
},
];

const costumeOptions = [
{
value: CameraAiMonitorType.FluorescentClothing,
label: t(MONITOR_KEY.FlUORESCENTCLOTHING, {
ns: "monitor",
}),
},
{
value: CameraAiMonitorType.Gloves,
label: t(MONITOR_KEY.GLOVES, {
ns: "monitor",
}),
},
{
value: CameraAiMonitorType.SafetyShoes,
label: t(MONITOR_KEY.SAFETYSHOES, {
ns: "monitor",
}),
},
];

const costumeAnimalOption = useMemo(() => {
let options: { value: CameraAiMonitorType; label: string }[] = [];

if (selectModalType.includes(CameraAiMonitorType.Animal)) {
options = options.concat(animalOptions);
}

if (selectModalType.includes(CameraAiMonitorType.Costume)) {
options = options.concat(costumeOptions);
}

return options;
}, [selectModalType]);

const editDetailUser = useMemo(() => {
// 处理编辑数据中的 user列表
if (
Expand Down Expand Up @@ -330,6 +397,23 @@ export const useAction = () => {
);
}

if (
selectModalType.includes(CameraAiMonitorType.Animal) ||
selectModalType.includes(CameraAiMonitorType.Costume)
) {
data.monitorTypes = data.monitorTypes.concat(costumeAnimalType);
}

if (
selectModalType.includes(CameraAiMonitorType.Smoke) ||
selectModalType.includes(CameraAiMonitorType.Fight)
) {
data.singleNoticeTime = handleTotalDuration(
values.singleTime,
values.singleTimeType
);
}

setSubmitLoadin(true);
isAdd
? MonitorSettingCreate(data)
Expand Down Expand Up @@ -445,6 +529,20 @@ export const useAction = () => {
setIsSelectSecurity(
res.monitorTypes.includes(CameraAiMonitorType.Security)
);

setSelectModalType(res.monitorTypes);

setCostumeAnimalType(
res.monitorTypes.filter(
(type) =>
type === CameraAiMonitorType.Cat ||
type === CameraAiMonitorType.Dog ||
type === CameraAiMonitorType.Bird ||
type === CameraAiMonitorType.FluorescentClothing ||
type === CameraAiMonitorType.Gloves ||
type === CameraAiMonitorType.SafetyShoes
)
);
})
.catch(() => {
message.error("獲取詳情數據失敗");
Expand All @@ -462,6 +560,32 @@ export const useAction = () => {
setCronList(isAdd ? initCronList : editCronList);
}, [isAdd, editDetailData, editDetailUser]);

useEffect(() => {
let filterType: CameraAiMonitorType[] = [...costumeAnimalType];

if (!selectModalType.includes(CameraAiMonitorType.Animal)) {
filterType = filterType.filter(
(type) =>
type !== CameraAiMonitorType.Cat &&
type !== CameraAiMonitorType.Dog &&
type !== CameraAiMonitorType.Bird
);
}

if (!selectModalType.includes(CameraAiMonitorType.Costume)) {
filterType = filterType.filter(
(type) =>
type !== CameraAiMonitorType.FluorescentClothing &&
type !== CameraAiMonitorType.Gloves &&
type !== CameraAiMonitorType.SafetyShoes
);
}

setCostumeAnimalType(filterType);

form.setFieldsValue({ costumeAnimalType: filterType });
}, [selectModalType]);

return {
cronList,
userOptions,
Expand All @@ -479,6 +603,9 @@ export const useAction = () => {
detailLoading,
submitLoading,
isSelecteSecurity,
selectModalType,
costumeAnimalOption,
costumeAnimalType,
setCronList,
onDeleteNoticeUserItem,
onChangeNoticeUserList,
Expand All @@ -489,5 +616,7 @@ export const useAction = () => {
secondsToTime,
filterOption,
setIsSelectSecurity,
setSelectModalType,
setCostumeAnimalType,
};
};
Loading

0 comments on commit 6b066e3

Please sign in to comment.