From 235c645ac1daea99fce53453745bef60ce5c21b0 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期五, 13 九月 2024 13:40:52 +0800 Subject: [PATCH] # --- zy-acs-flow/src/page/sta/index.jsx | 18 + zy-acs-flow/src/page/sta/StaEdit.jsx | 190 ++++++++++++ zy-acs-manager/src/main/java/com/zy/acs/manager/manager/entity/Sta.java | 2 zy-acs-flow/src/page/sta/StaCreate.jsx | 218 ++++++++++++++ zy-acs-flow/src/page/sta/StaPanel.jsx | 129 ++++++++ zy-acs-flow/src/i18n/en.js | 16 + zy-acs-manager/src/main/java/com/zy/acs/manager/common/CodeBuilder.java | 4 zy-acs-flow/src/page/ResourceContent.js | 3 zy-acs-flow/src/page/sta/StaList.jsx | 184 ++++++++++++ zy-acs-flow/src/i18n/zh.js | 16 + zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/StaController.java | 111 +++++++ 11 files changed, 887 insertions(+), 4 deletions(-) diff --git a/zy-acs-flow/src/i18n/en.js b/zy-acs-flow/src/i18n/en.js index 54385b0..c5d22db 100644 --- a/zy-acs-flow/src/i18n/en.js +++ b/zy-acs-flow/src/i18n/en.js @@ -95,6 +95,7 @@ staSts: 'Station Status', staType: 'Station Type', code: 'Code', + sta: 'Station', }, table: { field: { @@ -216,6 +217,21 @@ concer: "corner", scale: "scale", }, + sta: { + uuid: "uuid", + zoneId: "zone", + staNo: "staNo", + name: "name", + staType: "station type", + code: "code", + offset: "offset", + autoing: "autoing", + loading: "loading", + inEnable: "in enable", + outEnable: "out enable", + zpallet: "zpallet", + staSts: "station status", + }, } } }; diff --git a/zy-acs-flow/src/i18n/zh.js b/zy-acs-flow/src/i18n/zh.js index 57877db..f295bc9 100644 --- a/zy-acs-flow/src/i18n/zh.js +++ b/zy-acs-flow/src/i18n/zh.js @@ -95,6 +95,7 @@ staSts: '绔欑偣鐘舵��', staType: '绔欑偣绫诲瀷', code: '鏉$爜绠$悊', + sta: '绔欑偣绠$悊', }, table: { field: { @@ -215,6 +216,21 @@ concer: "鎷愯", scale: "姣斾緥", }, + sta: { + uuid: "缂栧彿", + zoneId: "搴撳尯", + staNo: "绔欑偣鍙�", + name: "绔欑偣鍚�", + staType: "绔欑偣绫诲瀷", + code: "鍦伴潰鐮�", + offset: "鍋忕Щ閲�", + autoing: "鑷姩", + loading: "杞借揣", + inEnable: "鍙叆", + outEnable: "鍙嚭", + zpallet: "鏂欑鐮�", + staSts: "绔欑偣鐘舵��", + }, } } }; diff --git a/zy-acs-flow/src/page/ResourceContent.js b/zy-acs-flow/src/page/ResourceContent.js index 48ca537..b4c9dff 100644 --- a/zy-acs-flow/src/page/ResourceContent.js +++ b/zy-acs-flow/src/page/ResourceContent.js @@ -17,6 +17,7 @@ import staSts from './staSts'; import staType from './staType'; import code from './code'; +import sta from './sta'; const ResourceContent = (node) => { @@ -47,6 +48,8 @@ return staType; case 'code': return code; + case 'sta': + return sta; default: return { list: ListGuesser, diff --git a/zy-acs-flow/src/page/sta/StaCreate.jsx b/zy-acs-flow/src/page/sta/StaCreate.jsx new file mode 100644 index 0000000..4e923b1 --- /dev/null +++ b/zy-acs-flow/src/page/sta/StaCreate.jsx @@ -0,0 +1,218 @@ +import React, { useState, useRef, useEffect, useMemo } from "react"; +import { + CreateBase, + useTranslate, + TextInput, + NumberInput, + BooleanInput, + DateInput, + SaveButton, + SelectInput, + ReferenceInput, + ReferenceArrayInput, + AutocompleteInput, + Toolbar, + required, + useDataProvider, + useNotify, + Form, + useCreateController, +} from 'react-admin'; +import { + Dialog, + DialogActions, + DialogContent, + DialogTitle, + Stack, + Grid, + Box, +} from '@mui/material'; +import DialogCloseButton from "../components/DialogCloseButton"; +import StatusSelectInput from "../components/StatusSelectInput"; +import MemoInput from "../components/MemoInput"; + +const StaCreate = (props) => { + const { open, setOpen } = props; + + const translate = useTranslate(); + const notify = useNotify(); + + const handleClose = (event, reason) => { + if (reason !== "backdropClick") { + setOpen(false); + } + }; + + const handleSuccess = async (data) => { + setOpen(false); + notify('common.response.success'); + }; + + const handleError = async (data) => { + notify('common.response.fail'); + }; + + return ( + <> + <CreateBase + record={{}} + transform={(data) => { + return data; + }} + mutationOptions={{ onSuccess: handleSuccess, onError: handleError }} + > + <Dialog + open={open} + onClose={handleClose} + aria-labelledby="form-dialog-title" + fullWidth + disableRestoreFocus + maxWidth="md" // 'xs' | 'sm' | 'md' | 'lg' | 'xl' + > + <Form> + <DialogTitle id="form-dialog-title" sx={{ + position: 'sticky', + top: 0, + backgroundColor: 'background.paper', + zIndex: 1000 + }} + > + {translate('create.title')} + <Box sx={{ position: 'absolute', top: 8, right: 8, zIndex: 1001 }}> + <DialogCloseButton onClose={handleClose} /> + </Box> + </DialogTitle> + <DialogContent> + <Grid container rowSpacing={2} columnSpacing={2}> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.sta.uuid" + source="uuid" + parse={v => v} + autoFocus + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <ReferenceInput + source="zoneId" + reference="zone" + > + <AutocompleteInput + label="table.field.sta.zoneId" + optionText="name" + /> + </ReferenceInput> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.sta.staNo" + source="staNo" + parse={v => v} + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.sta.name" + source="name" + parse={v => v} + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <ReferenceInput + source="staType" + reference="staType" + > + <AutocompleteInput + label="table.field.sta.staType" + optionText="name" + validate={required()} + /> + </ReferenceInput> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <ReferenceInput + source="code" + reference="code" + > + <AutocompleteInput + label="table.field.sta.code" + optionText="uuid" + /> + </ReferenceInput> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <NumberInput + label="table.field.sta.offset" + source="offset" + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.sta.autoing" + source="autoing" + parse={v => v} + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.sta.loading" + source="loading" + parse={v => v} + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.sta.inEnable" + source="inEnable" + parse={v => v} + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.sta.outEnable" + source="outEnable" + parse={v => v} + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <TextInput + label="table.field.sta.zpallet" + source="zpallet" + parse={v => v} + /> + </Grid> + <Grid item xs={6} display="flex" gap={1}> + <ReferenceInput + source="staSts" + reference="staSts" + > + <AutocompleteInput + label="table.field.sta.staSts" + optionText="name" + /> + </ReferenceInput> + </Grid> + + <Grid item xs={6} display="flex" gap={1}> + <StatusSelectInput /> + </Grid> + <Grid item xs={12} display="flex" gap={1}> + <Stack direction="column" spacing={1} width={'100%'}> + <MemoInput /> + </Stack> + </Grid> + </Grid> + </DialogContent> + <DialogActions sx={{ position: 'sticky', bottom: 0, backgroundColor: 'background.paper', zIndex: 1000 }}> + <Toolbar sx={{ width: '100%', justifyContent: 'space-between' }} > + <SaveButton /> + </Toolbar> + </DialogActions> + </Form> + </Dialog> + </CreateBase> + </> + ) +} + +export default StaCreate; diff --git a/zy-acs-flow/src/page/sta/StaEdit.jsx b/zy-acs-flow/src/page/sta/StaEdit.jsx new file mode 100644 index 0000000..908eb08 --- /dev/null +++ b/zy-acs-flow/src/page/sta/StaEdit.jsx @@ -0,0 +1,190 @@ +import React, { useState, useRef, useEffect, useMemo } from "react"; +import { + Edit, + SimpleForm, + FormDataConsumer, + useTranslate, + TextInput, + NumberInput, + BooleanInput, + DateInput, + SelectInput, + ReferenceInput, + ReferenceArrayInput, + AutocompleteInput, + SaveButton, + Toolbar, + Labeled, + NumberField, + required, + useRecordContext, + DeleteButton, +} from 'react-admin'; +import { useWatch, useFormContext } from "react-hook-form"; +import { Stack, Grid, Box, Typography } from '@mui/material'; +import * as Common from '@/utils/common'; +import { EDIT_MODE } from '@/config/setting'; +import EditBaseAside from "../components/EditBaseAside"; +import CustomerTopToolBar from "../components/EditTopToolBar"; +import MemoInput from "../components/MemoInput"; +import StatusSelectInput from "../components/StatusSelectInput"; + +const FormToolbar = () => { + const { getValues } = useFormContext(); + + return ( + <Toolbar sx={{ justifyContent: 'space-between' }}> + <SaveButton /> + <DeleteButton mutationMode="optimistic" /> + </Toolbar> + ) +} + +const StaEdit = () => { + const translate = useTranslate(); + + return ( + <Edit + redirect="list" + mutationMode={EDIT_MODE} + actions={<CustomerTopToolBar />} + aside={<EditBaseAside />} + > + <SimpleForm + shouldUnregister + warnWhenUnsavedChanges + toolbar={<FormToolbar />} + mode="onTouched" + defaultValues={{}} + // validate={(values) => { }} + > + <Grid container width={{ xs: '100%', xl: '80%' }} rowSpacing={3} columnSpacing={3}> + <Grid item xs={12} md={8}> + <Typography variant="h6" gutterBottom> + {translate('common.edit.title.main')} + </Typography> + <Stack direction='row' gap={2}> + <TextInput + label="table.field.sta.uuid" + source="uuid" + parse={v => v} + autoFocus + /> + </Stack> + <Stack direction='row' gap={2}> + <ReferenceInput + source="zoneId" + reference="zone" + > + <AutocompleteInput + label="table.field.sta.zoneId" + optionText="name" + /> + </ReferenceInput> + </Stack> + <Stack direction='row' gap={2}> + <TextInput + label="table.field.sta.staNo" + source="staNo" + parse={v => v} + /> + </Stack> + <Stack direction='row' gap={2}> + <TextInput + label="table.field.sta.name" + source="name" + parse={v => v} + /> + </Stack> + <Stack direction='row' gap={2}> + <ReferenceInput + source="staType" + reference="staType" + > + <AutocompleteInput + label="table.field.sta.staType" + optionText="name" + validate={required()} + /> + </ReferenceInput> + </Stack> + <Stack direction='row' gap={2}> + <ReferenceInput + source="code" + reference="code" + > + <AutocompleteInput + label="table.field.sta.code" + optionText="uuid" + /> + </ReferenceInput> + </Stack> + <Stack direction='row' gap={2}> + <NumberInput + label="table.field.sta.offset" + source="offset" + /> + </Stack> + <Stack direction='row' gap={2}> + <TextInput + label="table.field.sta.autoing" + source="autoing" + parse={v => v} + /> + </Stack> + <Stack direction='row' gap={2}> + <TextInput + label="table.field.sta.loading" + source="loading" + parse={v => v} + /> + </Stack> + <Stack direction='row' gap={2}> + <TextInput + label="table.field.sta.inEnable" + source="inEnable" + parse={v => v} + /> + </Stack> + <Stack direction='row' gap={2}> + <TextInput + label="table.field.sta.outEnable" + source="outEnable" + parse={v => v} + /> + </Stack> + <Stack direction='row' gap={2}> + <TextInput + label="table.field.sta.zpallet" + source="zpallet" + parse={v => v} + /> + </Stack> + <Stack direction='row' gap={2}> + <ReferenceInput + source="staSts" + reference="staSts" + > + <AutocompleteInput + label="table.field.sta.staSts" + optionText="name" + /> + </ReferenceInput> + </Stack> + + </Grid> + <Grid item xs={12} md={4}> + <Typography variant="h6" gutterBottom> + {translate('common.edit.title.common')} + </Typography> + <StatusSelectInput /> + <Box mt="2em" /> + <MemoInput /> + </Grid> + </Grid> + </SimpleForm> + </Edit > + ) +} + +export default StaEdit; diff --git a/zy-acs-flow/src/page/sta/StaList.jsx b/zy-acs-flow/src/page/sta/StaList.jsx new file mode 100644 index 0000000..10b751d --- /dev/null +++ b/zy-acs-flow/src/page/sta/StaList.jsx @@ -0,0 +1,184 @@ +import React, { useState, useRef, useEffect, useMemo, useCallback } from "react"; +import { useNavigate } from 'react-router-dom'; +import { + List, + DatagridConfigurable, + SearchInput, + TopToolbar, + SelectColumnsButton, + EditButton, + FilterButton, + CreateButton, + ExportButton, + BulkDeleteButton, + WrapperField, + useRecordContext, + useTranslate, + useListContext, + useCreatePath, + TextField, + NumberField, + DateField, + BooleanField, + ReferenceField, + TextInput, + DateTimeInput, + DateInput, + SelectInput, + NumberInput, + ReferenceInput, + ReferenceArrayInput, + AutocompleteInput, + DeleteButton, +} from 'react-admin'; +import { Box, Typography, Card, Stack } from '@mui/material'; +import { styled } from '@mui/material/styles'; +import StaCreate from "./StaCreate"; +import StaPanel from "./StaPanel"; +import EmptyData from "../components/EmptyData"; +import MyCreateButton from "../components/MyCreateButton"; +import MyExportButton from '../components/MyExportButton'; +import PageDrawer from "../components/PageDrawer"; +import MyField from "../components/MyField"; +import { PAGE_DRAWER_WIDTH, OPERATE_MODE } from '@/config/setting'; +import * as Common from '@/utils/common'; + +const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ + '& .css-1vooibu-MuiSvgIcon-root': { + height: '.9em' + }, + '& .RaDatagrid-row': { + cursor: 'auto' + }, + '& .column-name': { + }, + '& .opt': { + width: 200 + }, +})); + +const filters = [ + <SearchInput source="condition" alwaysOn />, + <DateInput label='common.time.after' source="timeStart" alwaysOn />, + <DateInput label='common.time.before' source="timeEnd" alwaysOn />, + + <TextInput source="uuid" label="table.field.sta.uuid" />, + <ReferenceInput source="zoneId" label="table.field.sta.zoneId" reference="zone"> + <AutocompleteInput label="table.field.sta.zoneId" optionText="name" /> + </ReferenceInput>, + <TextInput source="staNo" label="table.field.sta.staNo" />, + <TextInput source="name" label="table.field.sta.name" />, + <ReferenceInput source="staType" label="table.field.sta.staType" reference="staType"> + <AutocompleteInput label="table.field.sta.staType" optionText="name" /> + </ReferenceInput>, + <ReferenceInput source="code" label="table.field.sta.code" reference="code"> + <AutocompleteInput label="table.field.sta.code" optionText="uuid" /> + </ReferenceInput>, + <NumberInput source="offset" label="table.field.sta.offset" />, + <TextInput source="autoing" label="table.field.sta.autoing" />, + <TextInput source="loading" label="table.field.sta.loading" />, + <TextInput source="inEnable" label="table.field.sta.inEnable" />, + <TextInput source="outEnable" label="table.field.sta.outEnable" />, + <TextInput source="zpallet" label="table.field.sta.zpallet" />, + <ReferenceInput source="staSts" label="table.field.sta.staSts" reference="staSts"> + <AutocompleteInput label="table.field.sta.staSts" optionText="name" /> + </ReferenceInput>, + + <TextInput label="common.field.memo" source="memo" />, + <SelectInput + label="common.field.status" + source="status" + choices={[ + { id: '1', name: 'common.enums.statusTrue' }, + { id: '0', name: 'common.enums.statusFalse' }, + ]} + />, +] + +const StaList = () => { + const translate = useTranslate(); + + const [createDialog, setCreateDialog] = useState(false); + const [drawerVal, setDrawerVal] = useState(false); + + return ( + <Box display="flex"> + <List + sx={{ + flexGrow: 1, + transition: (theme) => + theme.transitions.create(['all'], { + duration: theme.transitions.duration.enteringScreen, + }), + marginRight: !!drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0, + }} + title={"menu.sta"} + empty={<EmptyData onClick={() => { setCreateDialog(true) }} />} + filters={filters} + sort={{ field: "create_time", order: "desc" }} + actions={( + <TopToolbar> + <FilterButton /> + <MyCreateButton onClick={() => { setCreateDialog(true) }} /> + <SelectColumnsButton preferenceKey='sta' /> + <MyExportButton /> + </TopToolbar> + )} + perPage={25} + > + <StyledDatagrid + preferenceKey='sta' + bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />} + rowClick={(id, resource, record) => false} + expand={() => <StaPanel />} + expandSingle={true} + omit={['id', 'createTime', 'memo']} + > + <NumberField source="id" /> + <TextField source="uuid" label="table.field.sta.uuid" /> + <ReferenceField source="zoneId" label="table.field.sta.zoneId" reference="zone" link={false} sortable={false}> + <TextField source="name" /> + </ReferenceField> + <TextField source="staNo" label="table.field.sta.staNo" /> + <TextField source="name" label="table.field.sta.name" /> + <ReferenceField source="staType" label="table.field.sta.staType" reference="staType" link={false} sortable={false}> + <TextField source="name" /> + </ReferenceField> + <ReferenceField source="code" label="table.field.sta.code" reference="code" link={false} sortable={false}> + <TextField source="uuid" /> + </ReferenceField> + <NumberField source="offset" label="table.field.sta.offset" /> + <TextField source="autoing" label="table.field.sta.autoing" /> + <TextField source="loading" label="table.field.sta.loading" /> + <TextField source="inEnable" label="table.field.sta.inEnable" /> + <TextField source="outEnable" label="table.field.sta.outEnable" /> + <TextField source="zpallet" label="table.field.sta.zpallet" /> + <ReferenceField source="staSts" label="table.field.sta.staSts" reference="staSts" link={false} sortable={false}> + <TextField source="name" /> + </ReferenceField> + + <DateField source="updateTime" label="common.field.updateTime" showTime /> + <DateField source="createTime" label="common.field.createTime" showTime /> + <BooleanField source="statusBool" label="common.field.status" sortable={false} /> + <TextField source="memo" label="common.field.memo" sortable={false} /> + <WrapperField cellClassName="opt" label="common.field.opt"> + <EditButton sx={{ padding: '1px', fontSize: '.75rem' }} /> + <DeleteButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} /> + </WrapperField> + </StyledDatagrid> + </List> + <StaCreate + open={createDialog} + setOpen={setCreateDialog} + /> + <PageDrawer + title='Sta Detail' + drawerVal={drawerVal} + setDrawerVal={setDrawerVal} + > + </PageDrawer> + </Box> + ) +} + +export default StaList; diff --git a/zy-acs-flow/src/page/sta/StaPanel.jsx b/zy-acs-flow/src/page/sta/StaPanel.jsx new file mode 100644 index 0000000..13638dd --- /dev/null +++ b/zy-acs-flow/src/page/sta/StaPanel.jsx @@ -0,0 +1,129 @@ +import React, { useState, useRef, useEffect, useMemo } from "react"; +import { Box, Card, CardContent, Grid, Typography, Tooltip } from '@mui/material'; +import { + useTranslate, + useRecordContext, +} from 'react-admin'; +import PanelTypography from "../components/PanelTypography"; +import * as Common from '@/utils/common' + +const StaPanel = () => { + const record = useRecordContext(); + if (!record) return null; + const translate = useTranslate(); + return ( + <> + <Card sx={{ width: { xs: 300, sm: 500, md: 600, lg: 800 }, margin: 'auto' }}> + <CardContent> + <Grid container spacing={2}> + <Grid item xs={12} sx={{ display: 'flex', justifyContent: 'space-between' }}> + <Typography variant="h6" gutterBottom align="left" sx={{ + maxWidth: { xs: '100px', sm: '180px', md: '260px', lg: '360px' }, + whiteSpace: 'nowrap', + overflow: 'hidden', + textOverflow: 'ellipsis', + }}> + {Common.camelToPascalWithSpaces(translate('table.field.sta.staNo'))}: {record.staNo} + </Typography> + {/* inherit, primary, secondary, textPrimary, textSecondary, error */} + <Typography variant="h6" gutterBottom align="right" > + ID: {record.id} + </Typography> + </Grid> + </Grid> + <Grid container spacing={2}> + <Grid item xs={12} container alignContent="flex-end"> + <Typography variant="caption" color="textSecondary" sx={{ wordWrap: 'break-word', wordBreak: 'break-all' }}> + {Common.camelToPascalWithSpaces(translate('common.field.memo'))}:{record.memo} + </Typography> + </Grid> + </Grid> + <Box height={20}> </Box> + <Grid container spacing={2}> + <Grid item xs={6}> + <PanelTypography + title="table.field.sta.uuid" + property={record.uuid} + /> + </Grid> + <Grid item xs={6}> + <PanelTypography + title="table.field.sta.zoneId" + property={record.zoneId$} + /> + </Grid> + <Grid item xs={6}> + <PanelTypography + title="table.field.sta.staNo" + property={record.staNo} + /> + </Grid> + <Grid item xs={6}> + <PanelTypography + title="table.field.sta.name" + property={record.name} + /> + </Grid> + <Grid item xs={6}> + <PanelTypography + title="table.field.sta.staType" + property={record.staType$} + /> + </Grid> + <Grid item xs={6}> + <PanelTypography + title="table.field.sta.code" + property={record.code$} + /> + </Grid> + <Grid item xs={6}> + <PanelTypography + title="table.field.sta.offset" + property={record.offset} + /> + </Grid> + <Grid item xs={6}> + <PanelTypography + title="table.field.sta.autoing" + property={record.autoing} + /> + </Grid> + <Grid item xs={6}> + <PanelTypography + title="table.field.sta.loading" + property={record.loading} + /> + </Grid> + <Grid item xs={6}> + <PanelTypography + title="table.field.sta.inEnable" + property={record.inEnable} + /> + </Grid> + <Grid item xs={6}> + <PanelTypography + title="table.field.sta.outEnable" + property={record.outEnable} + /> + </Grid> + <Grid item xs={6}> + <PanelTypography + title="table.field.sta.zpallet" + property={record.zpallet} + /> + </Grid> + <Grid item xs={6}> + <PanelTypography + title="table.field.sta.staSts" + property={record.staSts$} + /> + </Grid> + + </Grid> + </CardContent> + </Card > + </> + ); +}; + +export default StaPanel; diff --git a/zy-acs-flow/src/page/sta/index.jsx b/zy-acs-flow/src/page/sta/index.jsx new file mode 100644 index 0000000..ef6ecfa --- /dev/null +++ b/zy-acs-flow/src/page/sta/index.jsx @@ -0,0 +1,18 @@ +import React, { useState, useRef, useEffect, useMemo } from "react"; +import { + ListGuesser, + EditGuesser, + ShowGuesser, +} from "react-admin"; + +import StaList from "./StaList"; +import StaEdit from "./StaEdit"; + +export default { + list: StaList, + edit: StaEdit, + show: ShowGuesser, + recordRepresentation: (record) => { + return `${record.staNo}` + } +}; diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/common/CodeBuilder.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/common/CodeBuilder.java index 3729604..3ddbb2e 100644 --- a/zy-acs-manager/src/main/java/com/zy/acs/manager/common/CodeBuilder.java +++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/common/CodeBuilder.java @@ -22,8 +22,8 @@ // generator.username="sa"; // generator.password="Zoneyung@zy56$"; - generator.table="man_code"; - generator.tableDesc="Code"; + generator.table="man_sta"; + generator.tableDesc="Sta"; generator.packagePath="com.zy.acs.manager.manager"; generator.build(); diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/StaController.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/StaController.java new file mode 100644 index 0000000..ec549bc --- /dev/null +++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/StaController.java @@ -0,0 +1,111 @@ +package com.zy.acs.manager.manager.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.zy.acs.framework.common.Cools; +import com.zy.acs.framework.common.R; +import com.zy.acs.manager.common.utils.ExcelUtil; +import com.zy.acs.manager.common.annotation.OperationLog; +import com.zy.acs.manager.common.domain.BaseParam; +import com.zy.acs.manager.common.domain.KeyValVo; +import com.zy.acs.manager.common.domain.PageParam; +import com.zy.acs.manager.manager.entity.Sta; +import com.zy.acs.manager.manager.service.StaService; +import com.zy.acs.manager.system.controller.BaseController; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.*; + +@RestController +@RequestMapping("/api") +public class StaController extends BaseController { + + @Autowired + private StaService staService; + + @PreAuthorize("hasAuthority('manager:sta:list')") + @PostMapping("/sta/page") + public R page(@RequestBody Map<String, Object> map) { + BaseParam baseParam = buildParam(map, BaseParam.class); + PageParam<Sta, BaseParam> pageParam = new PageParam<>(baseParam, Sta.class); + return R.ok().add(staService.page(pageParam, pageParam.buildWrapper(true))); + } + + @PreAuthorize("hasAuthority('manager:sta:list')") + @PostMapping("/sta/list") + public R list(@RequestBody Map<String, Object> map) { + return R.ok().add(staService.list()); + } + + @PreAuthorize("hasAuthority('system:sta:list')") + @PostMapping({"/sta/many/{ids}", "/stas/many/{ids}"}) + public R many(@PathVariable Long[] ids) { + return R.ok().add(staService.listByIds(Arrays.asList(ids))); + } + + @PreAuthorize("hasAuthority('manager:sta:list')") + @GetMapping("/sta/{id}") + public R get(@PathVariable("id") Long id) { + return R.ok().add(staService.getById(id)); + } + + @PreAuthorize("hasAuthority('manager:sta:save')") + @OperationLog("Create Sta") + @PostMapping("/sta/save") + public R save(@RequestBody Sta sta) { + sta.setCreateBy(getLoginUserId()); + sta.setCreateTime(new Date()); + sta.setUpdateBy(getLoginUserId()); + sta.setUpdateTime(new Date()); + if (!staService.save(sta)) { + return R.error("Save Fail"); + } + return R.ok("Save Success").add(sta); + } + + @PreAuthorize("hasAuthority('manager:sta:update')") + @OperationLog("Update Sta") + @PostMapping("/sta/update") + public R update(@RequestBody Sta sta) { + sta.setUpdateBy(getLoginUserId()); + sta.setUpdateTime(new Date()); + if (!staService.updateById(sta)) { + return R.error("Update Fail"); + } + return R.ok("Update Success").add(sta); + } + + @PreAuthorize("hasAuthority('manager:sta:remove')") + @OperationLog("Delete Sta") + @PostMapping("/sta/remove/{ids}") + public R remove(@PathVariable Long[] ids) { + if (!staService.removeByIds(Arrays.asList(ids))) { + return R.error("Delete Fail"); + } + return R.ok("Delete Success").add(ids); + } + + @PreAuthorize("hasAuthority('manager:sta:list')") + @PostMapping("/sta/query") + public R query(@RequestParam(required = false) String condition) { + List<KeyValVo> vos = new ArrayList<>(); + LambdaQueryWrapper<Sta> wrapper = new LambdaQueryWrapper<>(); + if (!Cools.isEmpty(condition)) { + wrapper.like(Sta::getStaNo, condition); + } + staService.page(new Page<>(1, 30), wrapper).getRecords().forEach( + item -> vos.add(new KeyValVo(item.getId(), item.getStaNo())) + ); + return R.ok().add(vos); + } + + @PreAuthorize("hasAuthority('manager:sta:list')") + @PostMapping("/sta/export") + public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { + ExcelUtil.build(ExcelUtil.create(staService.list(), Sta.class), response); + } + +} diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/entity/Sta.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/entity/Sta.java index 367f898..a2e42f6 100644 --- a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/entity/Sta.java +++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/entity/Sta.java @@ -252,8 +252,6 @@ } } - - public Boolean getStatusBool(){ if (null == this.status){ return null; } switch (this.status){ -- Gitblit v1.9.1