From 7737c1a11778a236592ff3677d54a44776fd440f Mon Sep 17 00:00:00 2001
From: skyouc <958836976@qq.com>
Date: 星期六, 11 十月 2025 15:15:46 +0800
Subject: [PATCH] 容器管理初始化功能

---
 rsf-server/src/main/java/com/vincent/rsf/server/manager/enums/QRCodeType.java                      |   20 +
 rsf-admin/src/page/container/ContainerList.jsx                                                     |   21 +
 rsf-admin/src/page/basicInfo/basContainer/PrintModal.jsx                                           |  249 ++++++++++++++++++++
 rsf-admin/src/page/basicInfo/basContainer/BasContainerInit.jsx                                     |  134 +++++++++++
 rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/BasContainer.java                   |    7 
 rsf-server/src/main/java/com/vincent/rsf/server/manager/service/BasContainerService.java           |    3 
 rsf-admin/src/page/basicInfo/basContainer/BasContainerList.jsx                                     |   76 +++++-
 rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/params/InitContainerParams.java |   31 ++
 rsf-server/src/main/resources/application.yml                                                      |    2 
 rsf-admin/src/i18n/zh.js                                                                           |    5 
 rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/BasContainerController.java     |   41 ++-
 rsf-admin/src/i18n/en.js                                                                           |    5 
 rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/BasContainerServiceImpl.java  |   67 +++++
 rsf-server/src/main/resources/application-dev.yml                                                  |   10 
 14 files changed, 638 insertions(+), 33 deletions(-)

diff --git a/rsf-admin/src/i18n/en.js b/rsf-admin/src/i18n/en.js
index 194a87e..b4c4cc8 100644
--- a/rsf-admin/src/i18n/en.js
+++ b/rsf-admin/src/i18n/en.js
@@ -126,6 +126,7 @@
     },
     create: {
         title: 'Create',
+        init: 'Init',
         empty: {
             title: 'Data Empty',
             desc: 'Please Create Data First',
@@ -227,6 +228,9 @@
             basContainer: {
                 containerType: 'containerType',
                 codeType: 'codeType',
+                startNo: 'Start No',
+                code: 'Barcode',
+                endNo: 'End No',
                 areas: 'areas',
             },
             basStation: {
@@ -1310,6 +1314,7 @@
         detail: "Detail",
         unenable: 'unenable',
         locInit: 'loc init',
+        init: "Init",
         siteInit: 'site init',
         batch: 'batch',
         pick: 'Pick',
diff --git a/rsf-admin/src/i18n/zh.js b/rsf-admin/src/i18n/zh.js
index 980968e..ee0284b 100644
--- a/rsf-admin/src/i18n/zh.js
+++ b/rsf-admin/src/i18n/zh.js
@@ -127,6 +127,7 @@
     },
     create: {
         title: '娣诲姞',
+        init: '鍒濆鍖�',
         empty: {
             title: '鏆傛棤鏁版嵁',
             desc: '璇峰厛娣诲姞鏁版嵁',
@@ -249,6 +250,9 @@
             },
             basContainer: {
                 containerType: '瀹瑰櫒绫诲瀷',
+                startNo: '璧峰鏁板��',
+                endNo: '缁撴潫鏁板��',
+                code: '鏉$爜',
                 codeType: '鏉$爜绫诲瀷',
                 areas: '鍙叆搴撳尯',
             },
@@ -1332,6 +1336,7 @@
         confirm: '纭',
         start: '鑷姩涓嬪彂',
         autoStartLocs: '鑷姩璺戝簱',
+        init: "鍒濆鍖�",
         stopPub: '缁堟涓嬪彂',
         pause: '鏆傚仠',
         pick: '鎷f枡',
diff --git a/rsf-admin/src/page/basicInfo/basContainer/BasContainerInit.jsx b/rsf-admin/src/page/basicInfo/basContainer/BasContainerInit.jsx
new file mode 100644
index 0000000..53c0b1a
--- /dev/null
+++ b/rsf-admin/src/page/basicInfo/basContainer/BasContainerInit.jsx
@@ -0,0 +1,134 @@
+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,
+    SelectArrayInput,
+} 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 DictionarySelect from "../../components/DictionarySelect";
+import MemoInput from "../../components/MemoInput";
+
+
+const BasContainerCreate = (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 (error) => {
+        notify(error.message || 'common.response.fail', { type: 'error', messageArgs: { _: error.message } });
+    };
+
+    return (
+        <>
+            <CreateBase
+                record={{}}
+                resource="/basContainer/init"
+                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.init')}
+                            <Box sx={{ position: 'absolute', top: 8, right: 8, zIndex: 1001 }}>
+                                <DialogCloseButton onClose={handleClose} />
+                            </Box>
+                        </DialogTitle>
+                        <DialogContent sx={{ mt: 2 }}>
+                            <Grid container rowSpacing={2} columnSpacing={2}>
+                                <Grid item xs={6} display="flex" gap={1}>
+                                    <BooleanInput
+                                        label="table.field.deviceSite.flagInit"
+                                        source="flagInit"
+                                        parse={v => v}
+                                    />
+                                </Grid>
+                                <Grid item xs={6} display="flex" gap={1}>
+                                    <DictionarySelect
+                                        label={translate("table.field.basStation.containerType")}
+                                        name="containerType"
+                                        size="small"
+                                        validate={[required()]}
+                                        dictTypeCode="sys_container_type"
+                                    />
+                                </Grid>
+                                <Grid item xs={6} display="flex" gap={1}>
+                                    <TextInput
+                                        label="table.field.basContainer.startNo"
+                                        source="startNo"
+                                        parse={v => v}
+                                    />
+                                </Grid>
+                                <Grid item xs={6} display="flex" gap={1}>
+                                    <TextInput
+                                        label="table.field.basContainer.endNo"
+                                        source="endNo"
+                                        parse={v => v}
+                                    />
+                                </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 BasContainerCreate;
diff --git a/rsf-admin/src/page/basicInfo/basContainer/BasContainerList.jsx b/rsf-admin/src/page/basicInfo/basContainer/BasContainerList.jsx
index 722bb6e..224f9f3 100644
--- a/rsf-admin/src/page/basicInfo/basContainer/BasContainerList.jsx
+++ b/rsf-admin/src/page/basicInfo/basContainer/BasContainerList.jsx
@@ -31,6 +31,7 @@
     ReferenceArrayInput,
     AutocompleteInput,
     DeleteButton,
+    Button,
 } from 'react-admin';
 import { Box, Typography, Card, Stack } from '@mui/material';
 import { styled } from '@mui/material/styles';
@@ -42,8 +43,11 @@
 import PageDrawer from "../../components/PageDrawer";
 import MyField from "../../components/MyField";
 import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting';
-import * as Common from '@/utils/common';
 import CrossZoneAreaField from "../basStation/CrossZoneAreaField";
+import AllInclusiveIcon from '@mui/icons-material/AllInclusive';
+import BasContainerInit from "./BasContainerInit";
+import PrintModal from './PrintModal'
+
 
 const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({
     '& .css-1vooibu-MuiSvgIcon-root': {
@@ -61,8 +65,8 @@
 
 const filters = [
     <SearchInput source="condition" alwaysOn />,
-    <DateInput label='common.time.after' source="timeStart"  />,
-    <DateInput label='common.time.before' source="timeEnd"  />,
+    <DateInput label='common.time.after' source="timeStart" />,
+    <DateInput label='common.time.before' source="timeEnd" />,
 
     <NumberInput source="containerType" label="table.field.basContainer.containerType" />,
     <TextInput source="codeType" label="table.field.basContainer.codeType" />,
@@ -85,6 +89,9 @@
     const [areaFieldDialog, setAreaFieldDialog] = useState(false);
     const [createDialog, setCreateDialog] = useState(false);
     const [drawerVal, setDrawerVal] = useState(false);
+    const [open, setOpen] = useState(false);
+    const [print, setPrint] = useState(false);
+    const [selectPrints, setSelectPrints] = useState([]);
 
     return (
         <Box display="flex">
@@ -98,11 +105,12 @@
                     marginRight: !!drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0,
                 }}
                 title={"menu.basContainer"}
-                empty={<EmptyData onClick={() => { setCreateDialog(true) }} />}
+                empty={false}
                 filters={filters}
                 sort={{ field: "create_time", order: "desc" }}
                 actions={(
                     <TopToolbar>
+                        <InitButton setOpen={setOpen} />
                         <FilterButton />
                         <MyCreateButton onClick={() => { setCreateDialog(true) }} />
                         <SelectColumnsButton preferenceKey='basContainer' />
@@ -113,21 +121,18 @@
             >
                 <StyledDatagrid
                     preferenceKey='basContainer'
-                    bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />}
-                    rowClick={(id, resource, record) => false}                    
+                    bulkActionButtons={<>
+                        <BulkPrintBarcode setPrint={setPrint} setSelectPrints={setSelectPrints} />
+                        <BulkDeleteButton mutationMode={OPERATE_MODE} />
+                    </>}
+                    rowClick={(id, resource, record) => false}
                     expandSingle={true}
-                    omit={['id', 'createTime', 'createBy', 'memo','statusBool']}
+                    omit={['id', 'statusBool']}
                 >
                     <NumberField source="id" />
                     <NumberField source="containerType$" label="table.field.basContainer.containerType" />
+                    <TextField source="code" label="table.field.basContainer.code" />
                     <TextField source="codeType" label="table.field.basContainer.codeType" />
-                    <WrapperField cellClassName="areas" label="table.field.basContainer.areas">
-                        <CrossZoneAreaField
-                            open={areaFieldDialog}
-                            setOpen={setAreaFieldDialog}                
-                        />                        
-                    </WrapperField> 
-
                     <ReferenceField source="updateBy" label="common.field.updateBy" reference="user" link={false} sortable={false}>
                         <TextField source="nickname" />
                     </ReferenceField>
@@ -148,6 +153,15 @@
                 open={createDialog}
                 setOpen={setCreateDialog}
             />
+            <BasContainerInit
+                open={open}
+                setOpen={setOpen}
+            />
+            <PrintModal
+                open={print}
+                setOpen={setPrint}
+                rows={selectPrints}
+            />
             <PageDrawer
                 title='BasContainer Detail'
                 drawerVal={drawerVal}
@@ -158,4 +172,38 @@
     )
 }
 
+//鍒濆鍖栨寜閽�
+const InitButton = ({ setOpen }) => {
+    const init = () => {
+        setOpen(true)
+    }
+    return (
+        <Button
+            label="toolbar.init"
+            variant="text"
+            size="small"
+            onClick={init}
+            startIcon={<AllInclusiveIcon />} />
+    )
+}
+
+const BulkPrintBarcode = ({ setPrint, setSelectPrints }) => {
+    const { selectedIds } = useListContext();
+    //鎵撳嵃
+    const print = () => {
+        setPrint(true);
+        setSelectPrints(selectedIds);
+    }
+
+    return (
+        <Button
+            label="toolbar.print"
+            variant="text"
+            size="small"
+            onClick={print}
+            startIcon={<AllInclusiveIcon />} />
+    )
+}
+
+
 export default BasContainerList;
diff --git a/rsf-admin/src/page/basicInfo/basContainer/PrintModal.jsx b/rsf-admin/src/page/basicInfo/basContainer/PrintModal.jsx
new file mode 100644
index 0000000..0681623
--- /dev/null
+++ b/rsf-admin/src/page/basicInfo/basContainer/PrintModal.jsx
@@ -0,0 +1,249 @@
+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,
+    useListContext,
+    useRefresh,
+} from 'react-admin';
+import {
+    Dialog,
+    DialogActions,
+    DialogContent,
+    DialogTitle,
+    Grid,
+    TextField,
+    Box,
+    Button,
+    Radio,
+    RadioGroup,
+    FormControlLabel,
+    FormControl,
+    FormLabel,
+    TableRow,
+    TableCell,
+    Tooltip,
+    IconButton,
+    styled
+
+
+} from '@mui/material';
+import DialogCloseButton from "../../components/DialogCloseButton";
+import DictionarySelect from "../../components/DictionarySelect";
+import { useForm, Controller, useWatch, FormProvider, useFormContext } from "react-hook-form";
+import SaveIcon from '@mui/icons-material/Save';
+import request from '@/utils/request';
+import { Add, Edit, Delete } from '@mui/icons-material';
+import _ from 'lodash';
+import { DataGrid } from '@mui/x-data-grid';
+import StatusSelectInput from "../../components/StatusSelectInput";
+
+import { useReactToPrint } from "react-to-print";
+import jsbarcode from 'jsbarcode'
+import { el } from "date-fns/locale";
+import { padding } from "@mui/system";
+
+const PrintModal = ({ open, setOpen, rows }) => {
+    const refresh = useRefresh();
+    const translate = useTranslate();
+    const notify = useNotify();
+    const contentRef = useRef();
+    const reactToPrintFn = useReactToPrint({
+        content: () => {
+            return contentRef.current
+        },
+        documentTitle: `鐗╂枡淇℃伅`,
+        pageStyle: `
+        @page {
+            
+            margin: 10mm;
+        }
+        @media print {
+             html, body {
+                width: 70mm;     // A4妯悜瀹藉害
+                height: 40mm;    // A4妯悜楂樺害
+            }
+        }`
+    });
+
+    const handleClose = (event, reason) => {
+        if (reason !== "backdropClick") {
+            setOpen(false);
+        }
+    };
+
+    const [value, setValue] = useState('temp1');
+
+    const handleChange = (event) => {
+        setValue(event.target.value);
+    };
+
+    const handlePrint = () => {
+        // handleClose()
+        reactToPrintFn()
+    };
+
+    return (
+        <Dialog open={open} maxWidth="sm" fullWidth>
+            <DialogCloseButton onClose={handleClose} />
+            <DialogTitle>{translate('toolbar.print')}</DialogTitle>
+            <DialogContent >
+                <FormControl >
+                    <RadioGroup
+                        row
+                        aria-labelledby="demo-controlled-radio-buttons-group"
+                        name="controlled-radio-buttons-group"
+                        value={value}
+                        onChange={handleChange}
+                        size="small"
+                        sx={{ justifyContent: 'center' }}
+                    >
+                        <FormControlLabel value="temp1" control={<Radio />} label="妯℃澘1" size="small" />
+                    </RadioGroup>
+                </FormControl>
+
+                <Box>
+                    <div style={{ textAlign: 'center', display: 'flex', justifyContent: 'center' }}>
+                        <table
+                            className="contain"
+                            style={{
+                                overflow: 'hidden',
+                                fontSize: 'small',
+                                tableLayout: 'fixed',
+                                width: '280px',
+                                borderCollapse: 'collapse', // 鍚堝苟杈规
+                                border: '1px solid black' // 璁剧疆琛ㄦ牸鏁翠綋杈规
+                            }}
+                        >
+                            <tbody>
+                                <tr style={{ height: '94px' ,padding: '5px', }}>
+                                    <td
+                                        align="center"
+                                        className="barcode"
+                                        colSpan={12}
+                                        style={{ border: '1px solid black' }}
+                                    >
+                                        <img className="template-code" src={'/img/barcode.jpeg'} style={{ width: '90%' }} alt="Barcode" />
+                                        <div style={{ letterSpacing: '2px', marginTop: '1px', textAlign: 'center' }}>
+                                            <span>{'xxxxxx'}</span>
+                                        </div>
+                                    </td>
+                                </tr>
+                            </tbody>
+                        </table>
+                    </div>
+                    <style>{`
+                    @media print {
+                    .print-content {
+                            display: block!important;
+                        }
+                    }`} </style>
+                    <div ref={contentRef} className="print-content" style={{ textAlign: 'center', display: 'none' }}>
+                        <PrintTemp key={'bb'} rows={rows} />
+                    </div>
+                </Box>
+            </DialogContent>
+            <DialogActions sx={{ position: 'sticky', bottom: 0, backgroundColor: 'background.paper', zIndex: 1000 }}>
+                <Box sx={{ width: '100%', display: 'flex', justifyContent: 'space-between' }}>
+                    <Button onClick={handlePrint} variant="contained" startIcon={<SaveIcon />}>
+                        {translate('toolbar.confirm')}
+                    </Button>
+                </Box>
+            </DialogActions>
+        </Dialog >
+    );
+}
+
+export default PrintModal;
+
+const PrintTemp = ({ rows }) => {
+    const notify = useNotify();
+    const [data, setData] = useState([]);
+    const http = async () => {
+        const res = await request.post(`/basContainer/many/${rows?.join()}`);
+        if (res?.data?.code === 200) {
+            let val = res.data.data.map((el => {
+                return {
+                    barcode: '/img/barcode.jpeg',
+                    code: el.code,
+                    name: el.name,
+                    memo: el.memo
+                }
+            }))
+            setData(val)
+            setTimeout(() => {
+                val.forEach((el) => {
+                    jsbarcode(`#barcode${el.code}`, el.code, { height: 30 });
+                });
+            }, 10);
+
+
+
+        } else {
+            notify(res.data.msg);
+        }
+    }
+
+    useEffect(() => {
+        if (rows?.length > 0) {
+            http();
+        }
+
+    }, [rows]);
+
+
+    return (
+        <>
+            {data.map((item, index) => (
+                <table
+                    key={index}
+                    className="contain"
+                    style={{
+                        overflow: 'hidden',
+                        fontSize: 'small',
+                        tableLayout: 'fixed',
+                        width: '520px',
+                        borderCollapse: 'collapse',
+                        borderSpacing: 0,
+                        margin: '0 auto',
+                        marginTop: '10px',
+                    }}
+                >
+                    <tbody>
+                        <tr style={{ height: '74px' }}>
+                            <td
+                                align="center"
+                                className="barcode"
+                                colSpan={9}
+                                style={{ border: '1px solid black' }}
+                            >
+                                {/* <img id={"barcode" + item.code} style={{ width: '70%', verticalAlign: 'middle' }} /> */}
+                                <img className="template-code" src={item.barcode} style={{ width: '90%', verticalAlign: 'middle' }} alt="Barcode" />
+                                <div style={{ letterSpacing: '2px', marginTop: '1px', textAlign: 'center' }}>
+                                    <span>{item.code}</span>
+                                </div>
+                            </td>
+                        </tr>
+                    </tbody>
+                </table>
+            ))}
+
+        </>
+    )
+}
+
+
diff --git a/rsf-admin/src/page/container/ContainerList.jsx b/rsf-admin/src/page/container/ContainerList.jsx
index b99b12a..7ab91e7 100644
--- a/rsf-admin/src/page/container/ContainerList.jsx
+++ b/rsf-admin/src/page/container/ContainerList.jsx
@@ -31,6 +31,7 @@
     ReferenceArrayInput,
     AutocompleteInput,
     DeleteButton,
+    Button,
 } from 'react-admin';
 import { Box, Typography, Card, Stack } from '@mui/material';
 import { styled } from '@mui/material/styles';
@@ -43,6 +44,7 @@
 import MyField from "../components/MyField";
 import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting';
 import * as Common from '@/utils/common';
+import AllInclusiveIcon from '@mui/icons-material/AllInclusive';
 
 const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({
     '& .css-1vooibu-MuiSvgIcon-root': {
@@ -122,6 +124,7 @@
                 sort={{ field: "create_time", order: "desc" }}
                 actions={(
                     <TopToolbar>
+                        <InitButton />
                         <FilterButton />
                         <MyCreateButton onClick={() => { setCreateDialog(true) }} />
                         <SelectColumnsButton preferenceKey='container' />
@@ -183,4 +186,22 @@
     )
 }
 
+//鍒濆鍖栨寜閽�
+const InitButton = ({ setOpen }) => {
+    const close = () => {
+        setOpen(false)
+    }
+    return (
+        <Button
+            label="toolbar.init"
+            variant="outlined"
+            size="medium"
+            onClick={close}
+            startIcon={<AllInclusiveIcon />}
+            sx={{ margin: '3.5em' }} />
+    )
+}
+
+
+
 export default ContainerList;
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/BasContainerController.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/BasContainerController.java
index e352697..264d337 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/BasContainerController.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/BasContainerController.java
@@ -9,6 +9,7 @@
 import com.vincent.rsf.server.common.domain.BaseParam;
 import com.vincent.rsf.server.common.domain.KeyValVo;
 import com.vincent.rsf.server.common.domain.PageParam;
+import com.vincent.rsf.server.manager.controller.params.InitContainerParams;
 import com.vincent.rsf.server.manager.entity.BasContainer;
 import com.vincent.rsf.server.manager.entity.BasStation;
 import com.vincent.rsf.server.manager.service.BasContainerService;
@@ -32,18 +33,18 @@
         BaseParam baseParam = buildParam(map, BaseParam.class);
         PageParam<BasContainer, BaseParam> pageParam = new PageParam<>(baseParam, BasContainer.class);
         PageParam<BasContainer, BaseParam> page = basContainerService.page(pageParam, pageParam.buildWrapper(true));
-        for (BasContainer container : page.getRecords()) {
-            if (!Cools.isEmpty(container.getAreas())) {
-                String content = container.getAreas().substring(1, container.getAreas().length() - 1);
-                String[] parts = content.split(",");
-                Long[] longArray = new Long[parts.length];
-                for (int i = 0; i < parts.length; i++) {
-                    longArray[i] = Long.parseLong(parts[i].trim());
-                }
-                container.setAreaIds(longArray);
-            }
-
-        }
+//        for (BasContainer container : page.getRecords()) {
+//            if (!Cools.isEmpty(container.getAreas())) {
+//                String content = container.getAreas().substring(1, container.getAreas().length() - 1);
+//                String[] parts = content.split(",");
+//                Long[] longArray = new Long[parts.length];
+//                for (int i = 0; i < parts.length; i++) {
+//                    longArray[i] = Long.parseLong(parts[i].trim());
+//                }
+//                container.setAreaIds(longArray);
+//            }
+//
+//        }
         return R.ok().add(page);
     }
 
@@ -133,6 +134,22 @@
         return R.ok().add(vos);
     }
 
+
+    /**
+     * 鍒濆鍖�
+     * @return
+     */
+    @PreAuthorize("hasAuthority('manager:basContainer:list')")
+    @OperationLog("瀹瑰櫒鍒濆鍖�")
+    @PostMapping("/basContainer/init/save")
+    public R init(@RequestBody InitContainerParams params) {
+        if (Objects.isNull(params)) {
+            return R.error("鍙傛暟涓嶈兘涓虹┖锛侊紒");
+        }
+        return basContainerService.init(params, getLoginUserId());
+    }
+
+
     @PreAuthorize("hasAuthority('manager:basContainer:list')")
     @PostMapping("/basContainer/export")
     public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception {
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/params/InitContainerParams.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/params/InitContainerParams.java
new file mode 100644
index 0000000..6977f0b
--- /dev/null
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/params/InitContainerParams.java
@@ -0,0 +1,31 @@
+package com.vincent.rsf.server.manager.controller.params;
+
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@ApiModel(value = "InitContainerParams", description = "瀹瑰櫒鍒濆鍖�")
+public class InitContainerParams {
+
+    @ApiModelProperty("璧峰鏁板��")
+    private Integer startNo;
+
+    @ApiModelProperty("缁撴潫鏁板��")
+    private Integer endNo;
+
+    @ApiModelProperty("瀹瑰櫒绫诲瀷")
+    private Long containerType;
+
+    @ApiModelProperty("闀垮害")
+    private Integer length = 6;
+
+    @ApiModelProperty("鍓嶇紑")
+    private String prefix = "31";
+
+    @ApiModelProperty("鏄惁鍒濆鍖�")
+    private Boolean flagInit = false;
+
+
+}
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/BasContainer.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/BasContainer.java
index 1ea353c..65ac662 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/BasContainer.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/BasContainer.java
@@ -8,6 +8,7 @@
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.vincent.rsf.server.system.entity.DictData;
 import com.vincent.rsf.server.system.service.DictDataService;
+import lombok.experimental.Accessors;
 import org.springframework.format.annotation.DateTimeFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
@@ -24,6 +25,7 @@
 import java.util.Date;
 
 @Data
+@Accessors(chain = true)
 @TableName("man_bas_container")
 public class BasContainer implements Serializable {
 
@@ -35,6 +37,10 @@
     @ApiModelProperty(value= "id")
     @TableId(value = "id", type = IdType.AUTO)
     private Long id;
+
+
+    @ApiModelProperty("鍞竴缂栫爜")
+    private String code;
 
     /**
      * 瀹瑰櫒绫诲瀷
@@ -58,7 +64,6 @@
      * 鏄惁鍒犻櫎 1: 鏄�  0: 鍚�  
      */
     @ApiModelProperty(value= "鏄惁鍒犻櫎 1: 鏄�  0: 鍚�  ")
-    @TableLogic
     private Integer deleted;
 
     /**
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/enums/QRCodeType.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/enums/QRCodeType.java
new file mode 100644
index 0000000..74acda5
--- /dev/null
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/enums/QRCodeType.java
@@ -0,0 +1,20 @@
+package com.vincent.rsf.server.manager.enums;
+
+/**
+ * 瀹瑰櫒缂栫爜绫诲瀷
+ */
+public enum QRCodeType {
+
+    //瀹瑰櫒缂栫爜绫诲瀷
+    QRCODE_TYPE_QRCODE(1, "浜岀淮鐮�"),
+    QRCODE_TYPE_BARCODE(0, "鏉″瀷鐮�")
+    ;
+
+    QRCodeType(Integer val, String desc) {
+        this.val = val;
+        this.desc = desc;
+    }
+
+    public Integer val;
+    public String desc;
+}
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/BasContainerService.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/BasContainerService.java
index 37fa24b..ac55cf5 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/BasContainerService.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/BasContainerService.java
@@ -1,8 +1,11 @@
 package com.vincent.rsf.server.manager.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.vincent.rsf.framework.common.R;
+import com.vincent.rsf.server.manager.controller.params.InitContainerParams;
 import com.vincent.rsf.server.manager.entity.BasContainer;
 
 public interface BasContainerService extends IService<BasContainer> {
 
+    R init(InitContainerParams params, Long loginUserId);
 }
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/BasContainerServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/BasContainerServiceImpl.java
index 5f36b75..b2c69ed 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/BasContainerServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/BasContainerServiceImpl.java
@@ -1,12 +1,79 @@
 package com.vincent.rsf.server.manager.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.vincent.rsf.framework.common.R;
+import com.vincent.rsf.framework.exception.CoolException;
+import com.vincent.rsf.server.manager.controller.params.InitContainerParams;
+import com.vincent.rsf.server.manager.entity.WarehouseAreas;
+import com.vincent.rsf.server.manager.enums.QRCodeType;
 import com.vincent.rsf.server.manager.mapper.BasContainerMapper;
 import com.vincent.rsf.server.manager.entity.BasContainer;
 import com.vincent.rsf.server.manager.service.BasContainerService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.vincent.rsf.server.manager.service.WarehouseAreasService;
+import org.apache.tika.utils.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Objects;
 
 @Service("basContainerService")
 public class BasContainerServiceImpl extends ServiceImpl<BasContainerMapper, BasContainer> implements BasContainerService {
 
+    @Autowired
+    private WarehouseAreasService warehouseAreasService;
+
+
+    /**
+     * 瀹瑰櫒鍒濆鍖�
+     *
+     * @param params
+     * @param loginUserId
+     * @return
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public R init(InitContainerParams params, Long loginUserId) {
+        if (Objects.isNull(params.getStartNo())) {
+            throw new CoolException("瀹瑰櫒璧峰鍊间笉鑳戒负绌猴紒锛�");
+        }
+        if (Objects.isNull(params.getEndNo())) {
+            throw new CoolException("瀹瑰櫒缁撴潫鍊间笉鑳戒负绌猴紒锛�");
+        }
+
+        WarehouseAreas areas = warehouseAreasService.getOne(new LambdaQueryWrapper<WarehouseAreas>().eq(WarehouseAreas::getId, 42L));
+        if (Objects.isNull(areas)) {
+            throw new CoolException("搴撳尯涓嶅瓨鍦紝璇疯仈绯荤鐞嗗憳锛侊紒");
+        }
+
+        if (params.getFlagInit()) {
+            this.remove(new LambdaQueryWrapper<>());
+        }
+
+        List<BasContainer> containerList = new ArrayList<>();
+        for (int i = params.getStartNo(); i <= params.getEndNo() ; i++) {
+            BasContainer container = new BasContainer();
+            String code = StringUtils.leftPad(i + "", params.getLength(), "0");
+
+            container.setAreas(areas.getName())
+                    .setCodeType(QRCodeType.QRCODE_TYPE_BARCODE.desc)
+                    .setCode(params.getPrefix() + code)
+                    .setCreateTime(new Date())
+                    .setCreateBy(loginUserId)
+                    .setUpdateBy(loginUserId)
+                    .setUpdateTime(new Date())
+                    .setContainerType(params.getContainerType());
+            containerList.add(container);
+        }
+
+        if (!this.saveBatch(containerList)) {
+            throw new CoolException("瀹瑰櫒淇濆瓨澶辫触,璇锋鏌ョ紪鐮佹槸鍚︽湁閲嶅锛侊紒");
+        }
+
+        return R.ok();
+    }
 }
diff --git a/rsf-server/src/main/resources/application-dev.yml b/rsf-server/src/main/resources/application-dev.yml
index af14af6..6373fc4 100644
--- a/rsf-server/src/main/resources/application-dev.yml
+++ b/rsf-server/src/main/resources/application-dev.yml
@@ -14,10 +14,10 @@
 #    url: jdbc:mysql://47.76.147.249:3306/rsf?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
 #    username: rsf
     username: root
-    url: jdbc:mysql://10.10.10.200:3306/rsf?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
-    password: xltys1995
-#    url: jdbc:mysql://127.0.0.1:3306/rsf?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
-#    password: 34821015
+#    url: jdbc:mysql://10.10.10.200:3306/rsf?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
+#    password: xltys1995
+    url: jdbc:mysql://127.0.0.1:3306/rsf-xiri?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
+    password: 34821015
     type: com.alibaba.druid.pool.DruidDataSource
     druid:
       initial-size: 5
@@ -30,7 +30,7 @@
       test-on-borrow: true
       test-on-return: false
       remove-abandoned: true
-      remove-abandoned-timeout: 1800
+      remove-abandoned-timeout: 18
       #pool-prepared-statements: false
       #max-pool-prepared-statement-per-connection-size: 20
       filters: stat, wall
diff --git a/rsf-server/src/main/resources/application.yml b/rsf-server/src/main/resources/application.yml
index 0c99aef..b5db333 100644
--- a/rsf-server/src/main/resources/application.yml
+++ b/rsf-server/src/main/resources/application.yml
@@ -25,7 +25,7 @@
   #  global-config:
   #    field-strategy: 0
   configuration:
-#    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
     map-underscore-to-camel-case: true
     cache-enabled: true
     call-setters-on-nulls: true

--
Gitblit v1.9.1