New file |
| | |
| | | import React, { useState, useRef, useEffect } from 'react'; |
| | | import { |
| | | ProForm, |
| | | ProFormDigit, |
| | | ProFormText, |
| | | ProFormSelect, |
| | | ProFormDateTimePicker |
| | | } from '@ant-design/pro-components'; |
| | | import { Form, Modal } from 'antd'; |
| | | import { FormattedMessage, useIntl } from '@umijs/max'; |
| | | import moment from 'moment'; |
| | | import Http from '@/utils/http'; |
| | | |
| | | const Edit = (props) => { |
| | | const intl = useIntl(); |
| | | const [form] = Form.useForm(); |
| | | const { } = props; |
| | | |
| | | useEffect(() => { |
| | | form.resetFields(); |
| | | form.setFieldsValue({ |
| | | ...props.values |
| | | }) |
| | | }, [form, props]) |
| | | |
| | | const handleCancel = () => { |
| | | props.onCancel(); |
| | | }; |
| | | |
| | | const handleOk = () => { |
| | | form.submit(); |
| | | } |
| | | |
| | | const handleFinish = async (values) => { |
| | | props.onSubmit({ ...values }); |
| | | } |
| | | |
| | | return ( |
| | | <> |
| | | <Modal |
| | | title={ |
| | | Object.keys(props.values).length > 0 |
| | | ? intl.formatMessage({ id: 'page.edit', defaultMessage: '编辑' }) |
| | | : intl.formatMessage({ id: 'page.add', defaultMessage: '添加' }) |
| | | } |
| | | width={640} |
| | | forceRender |
| | | destroyOnClose |
| | | open={props.open} |
| | | onCancel={handleCancel} |
| | | onOk={handleOk} |
| | | > |
| | | <ProForm |
| | | form={form} |
| | | submitter={false} |
| | | onFinish={handleFinish} |
| | | layout="horizontal" |
| | | grid={true} |
| | | > |
| | | <ProFormDigit |
| | | name="id" |
| | | disabled |
| | | hidden={true} |
| | | /> |
| | | <ProForm.Group> |
| | | <ProFormText |
| | | name="uuid" |
| | | label="编号" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | /> |
| | | <ProFormText |
| | | name="staNo" |
| | | label="站点号" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | /> |
| | | </ProForm.Group> |
| | | <ProForm.Group> |
| | | <ProFormText |
| | | name="taskNo" |
| | | label="工作号" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | /> |
| | | <ProFormText |
| | | name="inEnable" |
| | | label="可入" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | /> |
| | | </ProForm.Group> |
| | | <ProForm.Group> |
| | | <ProFormText |
| | | name="outEnable" |
| | | label="可出" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | /> |
| | | <ProFormText |
| | | name="autoing" |
| | | label="自动" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | /> |
| | | </ProForm.Group> |
| | | <ProForm.Group> |
| | | <ProFormText |
| | | name="loading" |
| | | label="有物" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | /> |
| | | <ProFormText |
| | | name="canining" |
| | | label="能入" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | /> |
| | | </ProForm.Group> |
| | | <ProForm.Group> |
| | | <ProFormText |
| | | name="canouting" |
| | | label="能出" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | /> |
| | | <ProFormSelect |
| | | name="locType1" |
| | | label="高低类型" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | options={[ |
| | | { label: '未知', value: 0 }, |
| | | { label: '低库位', value: 1 }, |
| | | { label: '高库位', value: 2 }, |
| | | ]} |
| | | /> |
| | | </ProForm.Group> |
| | | <ProForm.Group> |
| | | <ProFormSelect |
| | | name="locType2" |
| | | label="宽窄类型" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | options={[ |
| | | { label: '未知', value: 0 }, |
| | | { label: '窄库位', value: 1 }, |
| | | { label: '宽库位', value: 2 }, |
| | | ]} |
| | | /> |
| | | <ProFormSelect |
| | | name="locType3" |
| | | label="轻重类型" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | options={[ |
| | | { label: '未知', value: 0 }, |
| | | { label: '轻库位', value: 1 }, |
| | | { label: '重库位', value: 2 }, |
| | | ]} |
| | | /> |
| | | </ProForm.Group> |
| | | <ProForm.Group> |
| | | <ProFormText |
| | | name="shuttleCode" |
| | | label="四向穿梭车所识别的二维码" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | /> |
| | | <ProFormText |
| | | name="locNo" |
| | | label="库位号" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | /> |
| | | </ProForm.Group> |
| | | <ProForm.Group> |
| | | <ProFormDigit |
| | | name="lev" |
| | | label="输送线楼层" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | fieldProps={{ precision: 0 }} |
| | | /> |
| | | <ProFormSelect |
| | | name="deviceId" |
| | | label="设备号" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | fieldProps={{ precision: 0 }} |
| | | showSearch |
| | | debounceTime={300} |
| | | request={async ({ keyWords }) => { |
| | | const resp = await Http.doPostForm('api/device/query', { condition: keyWords }); |
| | | return resp.data; |
| | | }} |
| | | /> |
| | | </ProForm.Group> |
| | | <ProForm.Group> |
| | | <ProFormSelect |
| | | name="deviceOtherId" |
| | | label="输送线绑定的其他设备号" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | fieldProps={{ precision: 0 }} |
| | | showSearch |
| | | debounceTime={300} |
| | | request={async ({ keyWords }) => { |
| | | const resp = await Http.doPostForm('api/device/query', { condition: keyWords }); |
| | | return resp.data; |
| | | }} |
| | | /> |
| | | <ProFormText |
| | | name="flag" |
| | | label="标识" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | /> |
| | | </ProForm.Group> |
| | | <ProForm.Group> |
| | | <ProFormSelect |
| | | name="status" |
| | | label="状态" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | options={[ |
| | | { label: '正常', value: 1 }, |
| | | { label: '禁用', value: 0 }, |
| | | ]} |
| | | /> |
| | | <ProFormDateTimePicker |
| | | name="createTime" |
| | | label="添加时间" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | transform={(value) => moment(value).toISOString()} |
| | | /> |
| | | </ProForm.Group> |
| | | <ProForm.Group> |
| | | <ProFormSelect |
| | | name="createBy" |
| | | label="添加人员" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | fieldProps={{ precision: 0 }} |
| | | showSearch |
| | | debounceTime={300} |
| | | request={async ({ keyWords }) => { |
| | | const resp = await Http.doPostForm('api/user/query', { condition: keyWords }); |
| | | return resp.data; |
| | | }} |
| | | /> |
| | | <ProFormDateTimePicker |
| | | name="updateTime" |
| | | label="修改时间" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | transform={(value) => moment(value).toISOString()} |
| | | /> |
| | | </ProForm.Group> |
| | | <ProForm.Group> |
| | | <ProFormSelect |
| | | name="updateBy" |
| | | label="修改人员" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | fieldProps={{ precision: 0 }} |
| | | showSearch |
| | | debounceTime={300} |
| | | request={async ({ keyWords }) => { |
| | | const resp = await Http.doPostForm('api/user/query', { condition: keyWords }); |
| | | return resp.data; |
| | | }} |
| | | /> |
| | | <ProFormText |
| | | name="memo" |
| | | label="备注" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | /> |
| | | </ProForm.Group> |
| | | |
| | | </ProForm> |
| | | </Modal> |
| | | </> |
| | | ) |
| | | } |
| | | |
| | | export default Edit; |
New file |
| | |
| | | |
| | | import React, { useState, useRef, useEffect } from 'react'; |
| | | import { Button, message, Modal, Tag } from 'antd'; |
| | | import { |
| | | FooterToolbar, |
| | | PageContainer, |
| | | ProTable, |
| | | LightFilter, |
| | | } from '@ant-design/pro-components'; |
| | | import { FormattedMessage, useIntl } from '@umijs/max'; |
| | | import { PlusOutlined, ExportOutlined } from '@ant-design/icons'; |
| | | import Http from '@/utils/http'; |
| | | import Edit from './components/edit' |
| | | import { TextFilter, SelectFilter, DatetimeRangeFilter, LinkFilter } from '@/components/TableSearch' |
| | | import { statusMap } from '@/utils/enum-util' |
| | | import { repairBug } from '@/utils/common-util'; |
| | | |
| | | const TABLE_KEY = 'pro-table-station'; |
| | | |
| | | const handleSave = async (val, intl) => { |
| | | const hide = message.loading(intl.formatMessage({ id: 'page.adding', defaultMessage: '正在添加' })); |
| | | try { |
| | | const resp = await Http.doPost('api/station/save', val); |
| | | if (resp.code === 200) { |
| | | message.success(intl.formatMessage({ id: 'page.add.success', defaultMessage: '添加成功' })); |
| | | return true; |
| | | } else { |
| | | message.error(resp.msg); |
| | | return false; |
| | | } |
| | | } catch (error) { |
| | | message.error(intl.formatMessage({ id: 'page.add.fail', defaultMessage: '添加失败请重试!' })); |
| | | return false; |
| | | } finally { |
| | | hide(); |
| | | } |
| | | }; |
| | | |
| | | const handleUpdate = async (val, intl) => { |
| | | const hide = message.loading(intl.formatMessage({ id: 'page.updating', defaultMessage: '正在更新' })); |
| | | try { |
| | | const resp = await Http.doPost('api/station/update', val); |
| | | if (resp.code === 200) { |
| | | message.success(intl.formatMessage({ id: 'page.update.success', defaultMessage: '更新成功' })); |
| | | return true; |
| | | } else { |
| | | message.error(resp.msg); |
| | | return false; |
| | | } |
| | | } catch (error) { |
| | | message.error(intl.formatMessage({ id: 'page.update.fail', defaultMessage: '更新失败请重试!' })); |
| | | return false; |
| | | } finally { |
| | | hide(); |
| | | } |
| | | }; |
| | | |
| | | const handleRemove = async (rows, intl) => { |
| | | if (!rows) return true; |
| | | const hide = message.loading(intl.formatMessage({ id: 'page.deleting', defaultMessage: '正在删除' })); |
| | | try { |
| | | const resp = await Http.doPost('api/station/remove/' + rows.map((row) => row.id).join(',')); |
| | | if (resp.code === 200) { |
| | | message.success(intl.formatMessage({ id: 'page.delete.success', defaultMessage: '删除成功' })); |
| | | return true; |
| | | } else { |
| | | message.error(resp.msg); |
| | | return false; |
| | | } |
| | | } catch (error) { |
| | | message.error(intl.formatMessage({ id: 'page.delete.fail', defaultMessage: '删除失败,请重试!' })); |
| | | return false; |
| | | } finally { |
| | | hide(); |
| | | } |
| | | }; |
| | | |
| | | const handleExport = async (intl) => { |
| | | const hide = message.loading(intl.formatMessage({ id: 'page.exporting', defaultMessage: '正在导出' })); |
| | | try { |
| | | const resp = await Http.doPostBlob('api/station/export'); |
| | | const blob = new Blob([resp], { type: 'application/vnd.ms-excel' }); |
| | | window.location.href = window.URL.createObjectURL(blob); |
| | | message.success(intl.formatMessage({ id: 'page.export.success', defaultMessage: '导出成功' })); |
| | | return true; |
| | | } catch (error) { |
| | | message.error(intl.formatMessage({ id: 'page.export.fail', defaultMessage: '导出失败,请重试' })); |
| | | return false; |
| | | } finally { |
| | | hide(); |
| | | } |
| | | }; |
| | | |
| | | |
| | | const Main = () => { |
| | | const intl = useIntl(); |
| | | const formTableRef = useRef(); |
| | | const actionRef = useRef(); |
| | | const [selectedRows, setSelectedRows] = useState([]); |
| | | const [modalVisible, setModalVisible] = useState(false); |
| | | const [currentRow, setCurrentRow] = useState(); |
| | | const [searchParam, setSearchParam] = useState({}); |
| | | |
| | | useEffect(() => { |
| | | |
| | | }, []); |
| | | |
| | | const columns = [ |
| | | { |
| | | title: intl.formatMessage({ |
| | | id: 'page.table.no', |
| | | defaultMessage: 'No' |
| | | }), |
| | | dataIndex: 'index', |
| | | valueType: 'indexBorder', |
| | | width: 48, |
| | | }, |
| | | { |
| | | title: '编号', |
| | | dataIndex: 'uuid', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='uuid' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '站点号', |
| | | dataIndex: 'staNo', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | copyable: true, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='staNo' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '工作号', |
| | | dataIndex: 'taskNo', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='taskNo' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '可入', |
| | | dataIndex: 'inEnable', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='inEnable' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '可出', |
| | | dataIndex: 'outEnable', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='outEnable' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '自动', |
| | | dataIndex: 'autoing', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='autoing' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '有物', |
| | | dataIndex: 'loading', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='loading' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '能入', |
| | | dataIndex: 'canining', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='canining' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '能出', |
| | | dataIndex: 'canouting', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='canouting' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '高低类型', |
| | | dataIndex: 'locType1$', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <SelectFilter |
| | | name='locType1' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | data={[ |
| | | { label: '未知', value: 0 }, |
| | | { label: '低库位', value: 1 }, |
| | | { label: '高库位', value: 2 }, |
| | | ]} |
| | | />, |
| | | }, |
| | | { |
| | | title: '宽窄类型', |
| | | dataIndex: 'locType2$', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <SelectFilter |
| | | name='locType2' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | data={[ |
| | | { label: '未知', value: 0 }, |
| | | { label: '窄库位', value: 1 }, |
| | | { label: '宽库位', value: 2 }, |
| | | ]} |
| | | />, |
| | | }, |
| | | { |
| | | title: '轻重类型', |
| | | dataIndex: 'locType3$', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <SelectFilter |
| | | name='locType3' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | data={[ |
| | | { label: '未知', value: 0 }, |
| | | { label: '轻库位', value: 1 }, |
| | | { label: '重库位', value: 2 }, |
| | | ]} |
| | | />, |
| | | }, |
| | | { |
| | | title: '四向穿梭车所识别的二维码', |
| | | dataIndex: 'shuttleCode', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='shuttleCode' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '库位号', |
| | | dataIndex: 'locNo', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='locNo' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '输送线楼层', |
| | | dataIndex: 'lev', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='lev' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '设备号', |
| | | dataIndex: 'deviceId$', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <LinkFilter |
| | | name='deviceId' |
| | | major='device' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '输送线绑定的其他设备号', |
| | | dataIndex: 'deviceOtherId$', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <LinkFilter |
| | | name='deviceOtherId' |
| | | major='device' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '标识', |
| | | dataIndex: 'flag', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='flag' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '状态', |
| | | dataIndex: 'status$', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <SelectFilter |
| | | name='status' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | data={[ |
| | | { label: '正常', value: 1 }, |
| | | { label: '禁用', value: 0 }, |
| | | ]} |
| | | />, |
| | | }, |
| | | { |
| | | title: '添加时间', |
| | | dataIndex: 'createTime$', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <DatetimeRangeFilter |
| | | name='createTime' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '添加人员', |
| | | dataIndex: 'createBy$', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <LinkFilter |
| | | name='createBy' |
| | | major='user' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '修改时间', |
| | | dataIndex: 'updateTime$', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <DatetimeRangeFilter |
| | | name='updateTime' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '修改人员', |
| | | dataIndex: 'updateBy$', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <LinkFilter |
| | | name='updateBy' |
| | | major='user' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '备注', |
| | | dataIndex: 'memo', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='memo' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | |
| | | { |
| | | title: '操作', |
| | | dataIndex: 'option', |
| | | width: 140, |
| | | valueType: 'option', |
| | | render: (_, record) => [ |
| | | <Button |
| | | type="link" |
| | | key="edit" |
| | | onClick={() => { |
| | | setModalVisible(true); |
| | | setCurrentRow(record); |
| | | }} |
| | | > |
| | | <FormattedMessage id='page.edit' defaultMessage='编辑' /> |
| | | </Button>, |
| | | <Button |
| | | type="link" |
| | | danger |
| | | key="batchRemove" |
| | | onClick={async () => { |
| | | Modal.confirm({ |
| | | title: intl.formatMessage({ id: 'page.delete', defaultMessage: '删除' }), |
| | | content: intl.formatMessage({ id: 'page.delete.confirm', defaultMessage: '确定删除该项吗?' }), |
| | | onOk: async () => { |
| | | const success = await handleRemove([record], intl); |
| | | if (success) { |
| | | if (actionRef.current) { |
| | | actionRef.current.reload(); |
| | | } |
| | | } |
| | | }, |
| | | }); |
| | | }} |
| | | > |
| | | <FormattedMessage id='page.delete' defaultMessage='删除' /> |
| | | </Button>, |
| | | ], |
| | | }, |
| | | ]; |
| | | |
| | | return ( |
| | | <PageContainer |
| | | header={{ |
| | | breadcrumb: {}, |
| | | }} |
| | | > |
| | | <div style={{ width: '100%', float: 'right' }}> |
| | | <ProTable |
| | | key="station" |
| | | rowKey="id" |
| | | actionRef={actionRef} |
| | | formRef={formTableRef} |
| | | columns={columns} |
| | | cardBordered |
| | | scroll={{ x: 1300 }} |
| | | dateFormatter="string" |
| | | pagination={{ pageSize: 16 }} |
| | | search={false} |
| | | toolbar={{ |
| | | search: { |
| | | onSearch: (value) => { |
| | | setSearchParam(prevState => ({ |
| | | ...prevState, |
| | | condition: value |
| | | })); |
| | | actionRef.current?.reload(); |
| | | }, |
| | | }, |
| | | filter: ( |
| | | <LightFilter |
| | | onValuesChange={(val) => { |
| | | }} |
| | | > |
| | | </LightFilter> |
| | | ), |
| | | actions: [ |
| | | <Button |
| | | type="primary" |
| | | key="save" |
| | | onClick={async () => { |
| | | setModalVisible(true) |
| | | }} |
| | | > |
| | | <PlusOutlined /> |
| | | <FormattedMessage id='page.add' defaultMessage='添加' /> |
| | | </Button>, |
| | | <Button |
| | | key="export" |
| | | onClick={async () => { |
| | | handleExport(intl); |
| | | }} |
| | | > |
| | | <ExportOutlined /> |
| | | <FormattedMessage id='page.export' defaultMessage='导出' /> |
| | | </Button>, |
| | | ], |
| | | }} |
| | | request={(params, sorter, filter) => |
| | | Http.doPostPromise('/api/station/page', { ...params, ...searchParam }, (res) => { |
| | | return { |
| | | data: res.data.records, |
| | | total: res.data.total, |
| | | success: true, |
| | | } |
| | | }) |
| | | } |
| | | rowSelection={{ |
| | | onChange: (ids, rows) => { |
| | | setSelectedRows(rows); |
| | | } |
| | | }} |
| | | columnsState={{ |
| | | persistenceKey: TABLE_KEY, |
| | | persistenceType: 'localStorage', |
| | | defaultValue: { |
| | | // memo: { show: repairBug(TABLE_KEY, 'memo', false) }, |
| | | option: { fixed: 'right', disable: true }, |
| | | }, |
| | | onChange(value) { |
| | | }, |
| | | }} |
| | | /> |
| | | </div> |
| | | |
| | | {selectedRows?.length > 0 && ( |
| | | <FooterToolbar |
| | | extra={ |
| | | <div> |
| | | <a style={{ fontWeight: 600 }}>{selectedRows.length}</a> |
| | | <FormattedMessage id='page.selected' defaultMessage=' 项已选择' /> |
| | | </div> |
| | | } |
| | | > |
| | | <Button |
| | | key="remove" |
| | | danger |
| | | onClick={async () => { |
| | | Modal.confirm({ |
| | | title: intl.formatMessage({ id: 'page.delete', defaultMessage: '删除' }), |
| | | content: intl.formatMessage({ id: 'page.delete.confirm', defaultMessage: '确定删除该项吗?' }), |
| | | onOk: async () => { |
| | | const success = await handleRemove(selectedRows, intl); |
| | | if (success) { |
| | | setSelectedRows([]); |
| | | actionRef.current?.reloadAndRest?.(); |
| | | } |
| | | }, |
| | | }); |
| | | }} |
| | | > |
| | | <FormattedMessage id='page.delete.batch' defaultMessage='批量删除' /> |
| | | </Button> |
| | | </FooterToolbar> |
| | | )} |
| | | |
| | | <Edit |
| | | open={modalVisible} |
| | | values={currentRow || {}} |
| | | onCancel={ |
| | | () => { |
| | | setModalVisible(false); |
| | | setCurrentRow(undefined); |
| | | } |
| | | } |
| | | onSubmit={async (values) => { |
| | | let ok = false; |
| | | if (values.id) { |
| | | ok = await handleUpdate({ ...values }, intl) |
| | | } else { |
| | | ok = await handleSave({ ...values }, intl) |
| | | } |
| | | if (ok) { |
| | | setModalVisible(false); |
| | | setCurrentRow(undefined); |
| | | if (actionRef.current) { |
| | | actionRef.current.reload(); |
| | | } |
| | | } |
| | | }} |
| | | /> |
| | | </PageContainer> |
| | | ); |
| | | }; |
| | | |
| | | export default Main; |
| | |
| | | package com.zy.asrs.wcs.system.controller; |
| | | package com.zy.asrs.wcs.core.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | import com.zy.asrs.wcs.common.domain.PageParam; |
| | | import com.zy.asrs.wcs.core.entity.ShuttleStandby; |
| | | import com.zy.asrs.wcs.core.service.ShuttleStandbyService; |
| | | import com.zy.asrs.wcs.system.controller.BaseController; |
| | | import com.zy.asrs.wcs.utils.ExcelUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
New file |
| | |
| | | package com.zy.asrs.wcs.core.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.R; |
| | | import com.zy.asrs.wcs.common.annotation.OperationLog; |
| | | import com.zy.asrs.wcs.common.domain.BaseParam; |
| | | import com.zy.asrs.wcs.common.domain.KeyValVo; |
| | | import com.zy.asrs.wcs.common.domain.PageParam; |
| | | import com.zy.asrs.wcs.core.entity.Station; |
| | | import com.zy.asrs.wcs.core.service.StationService; |
| | | import com.zy.asrs.wcs.system.controller.BaseController; |
| | | import com.zy.asrs.wcs.utils.ExcelUtil; |
| | | 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.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @RestController |
| | | @RequestMapping("/api") |
| | | public class StationController extends BaseController { |
| | | |
| | | @Autowired |
| | | private StationService stationService; |
| | | |
| | | @PreAuthorize("hasAuthority('core:station:list')") |
| | | @PostMapping("/station/page") |
| | | public R page(@RequestBody Map<String, Object> map) { |
| | | BaseParam baseParam = buildParam(map, BaseParam.class); |
| | | PageParam<Station, BaseParam> pageParam = new PageParam<>(baseParam, Station.class); |
| | | return R.ok().add(stationService.page(pageParam, pageParam.buildWrapper(true))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('core:station:list')") |
| | | @PostMapping("/station/list") |
| | | public R list(@RequestBody Map<String, Object> map) { |
| | | return R.ok().add(stationService.list()); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('core:station:list')") |
| | | @GetMapping("/station/{id}") |
| | | public R get(@PathVariable("id") Long id) { |
| | | return R.ok().add(stationService.getById(id)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('core:station:save')") |
| | | @OperationLog("添加站点列表") |
| | | @PostMapping("/station/save") |
| | | public R save(@RequestBody Station station) { |
| | | if (!stationService.save(station)) { |
| | | return R.error("添加失败"); |
| | | } |
| | | return R.ok("添加成功"); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('core:station:update')") |
| | | @OperationLog("修改站点列表") |
| | | @PostMapping("/station/update") |
| | | public R update(@RequestBody Station station) { |
| | | if (!stationService.updateById(station)) { |
| | | return R.error("修改失败"); |
| | | } |
| | | return R.ok("修改成功"); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('core:station:remove')") |
| | | @OperationLog("删除站点列表") |
| | | @PostMapping("/station/remove/{ids}") |
| | | public R remove(@PathVariable Long[] ids) { |
| | | if (!stationService.removeByIds(Arrays.asList(ids))) { |
| | | return R.error("删除失败"); |
| | | } |
| | | return R.ok("删除成功"); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('core:station:list')") |
| | | @PostMapping("/station/query") |
| | | public R query(@RequestParam(required = false) String condition) { |
| | | List<KeyValVo> vos = new ArrayList<>(); |
| | | LambdaQueryWrapper<Station> wrapper = new LambdaQueryWrapper<>(); |
| | | if (!Cools.isEmpty(condition)) { |
| | | wrapper.like(Station::getStaNo, condition); |
| | | } |
| | | stationService.page(new Page<>(1, 30), wrapper).getRecords().forEach( |
| | | item -> vos.add(new KeyValVo(item.getId(), item.getStaNo())) |
| | | ); |
| | | return R.ok().add(vos); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('core:station:list')") |
| | | @PostMapping("/station/export") |
| | | public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | ExcelUtil.build(ExcelUtil.create(stationService.list(), Station.class), response); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.zy.asrs.wcs.system.controller; |
| | | package com.zy.asrs.wcs.core.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | import com.zy.asrs.wcs.common.domain.PageParam; |
| | | import com.zy.asrs.wcs.core.entity.TaskSerialNo; |
| | | import com.zy.asrs.wcs.core.service.TaskSerialNoService; |
| | | import com.zy.asrs.wcs.system.controller.BaseController; |
| | | import com.zy.asrs.wcs.utils.ExcelUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
New file |
| | |
| | | package com.zy.asrs.wcs.core.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | |
| | | import com.zy.asrs.wcs.rcs.entity.Device; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceService; |
| | | import com.zy.asrs.wcs.system.entity.Host; |
| | | import com.zy.asrs.wcs.system.entity.User; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.SpringUtils; |
| | | import com.zy.asrs.wcs.system.service.UserService; |
| | | import com.zy.asrs.wcs.system.service.HostService; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | @Data |
| | | @TableName("wcs_station") |
| | | public class Station implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * ID |
| | | */ |
| | | @ApiModelProperty(value= "ID") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 编号 |
| | | */ |
| | | @ApiModelProperty(value= "编号") |
| | | private String uuid; |
| | | |
| | | /** |
| | | * 站点号 |
| | | */ |
| | | @ApiModelProperty(value= "站点号") |
| | | private String staNo; |
| | | |
| | | /** |
| | | * 工作号 |
| | | */ |
| | | @ApiModelProperty(value= "工作号") |
| | | private String taskNo; |
| | | |
| | | /** |
| | | * 可入 |
| | | */ |
| | | @ApiModelProperty(value= "可入") |
| | | private String inEnable; |
| | | |
| | | /** |
| | | * 可出 |
| | | */ |
| | | @ApiModelProperty(value= "可出") |
| | | private String outEnable; |
| | | |
| | | /** |
| | | * 自动 |
| | | */ |
| | | @ApiModelProperty(value= "自动") |
| | | private String autoing; |
| | | |
| | | /** |
| | | * 有物 |
| | | */ |
| | | @ApiModelProperty(value= "有物") |
| | | private String loading; |
| | | |
| | | /** |
| | | * 能入 |
| | | */ |
| | | @ApiModelProperty(value= "能入") |
| | | private String canining; |
| | | |
| | | /** |
| | | * 能出 |
| | | */ |
| | | @ApiModelProperty(value= "能出") |
| | | private String canouting; |
| | | |
| | | /** |
| | | * 高低类型 0: 未知 1: 低库位 2: 高库位 |
| | | */ |
| | | @ApiModelProperty(value= "高低类型 0: 未知 1: 低库位 2: 高库位 ") |
| | | private Integer locType1; |
| | | |
| | | /** |
| | | * 宽窄类型 0: 未知 1: 窄库位 2: 宽库位 |
| | | */ |
| | | @ApiModelProperty(value= "宽窄类型 0: 未知 1: 窄库位 2: 宽库位 ") |
| | | private Integer locType2; |
| | | |
| | | /** |
| | | * 轻重类型 0: 未知 1: 轻库位 2: 重库位 |
| | | */ |
| | | @ApiModelProperty(value= "轻重类型 0: 未知 1: 轻库位 2: 重库位 ") |
| | | private Integer locType3; |
| | | |
| | | /** |
| | | * 四向穿梭车所识别的二维码 |
| | | */ |
| | | @ApiModelProperty(value= "四向穿梭车所识别的二维码") |
| | | private String shuttleCode; |
| | | |
| | | /** |
| | | * 库位号 |
| | | */ |
| | | @ApiModelProperty(value= "库位号") |
| | | private String locNo; |
| | | |
| | | /** |
| | | * 输送线楼层 |
| | | */ |
| | | @ApiModelProperty(value= "输送线楼层") |
| | | private Integer lev; |
| | | |
| | | /** |
| | | * 设备号 |
| | | */ |
| | | @ApiModelProperty(value= "设备号") |
| | | private Integer deviceId; |
| | | |
| | | /** |
| | | * 输送线绑定的其他设备号 |
| | | */ |
| | | @ApiModelProperty(value= "输送线绑定的其他设备号") |
| | | private Integer deviceOtherId; |
| | | |
| | | /** |
| | | * 标识 |
| | | */ |
| | | @ApiModelProperty(value= "标识") |
| | | private String flag; |
| | | |
| | | /** |
| | | * 所属机构 |
| | | */ |
| | | @ApiModelProperty(value= "所属机构") |
| | | private Long hostId; |
| | | |
| | | /** |
| | | * 状态 1: 正常 0: 禁用 |
| | | */ |
| | | @ApiModelProperty(value= "状态 1: 正常 0: 禁用 ") |
| | | private Integer status; |
| | | |
| | | /** |
| | | * 是否删除 1: 是 0: 否 |
| | | */ |
| | | @ApiModelProperty(value= "是否删除 1: 是 0: 否 ") |
| | | @TableLogic |
| | | private Integer deleted; |
| | | |
| | | /** |
| | | * 添加时间 |
| | | */ |
| | | @ApiModelProperty(value= "添加时间") |
| | | @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 添加人员 |
| | | */ |
| | | @ApiModelProperty(value= "添加人员") |
| | | private Long createBy; |
| | | |
| | | /** |
| | | * 修改时间 |
| | | */ |
| | | @ApiModelProperty(value= "修改时间") |
| | | @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") |
| | | private Date updateTime; |
| | | |
| | | /** |
| | | * 修改人员 |
| | | */ |
| | | @ApiModelProperty(value= "修改人员") |
| | | private Long updateBy; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | @ApiModelProperty(value= "备注") |
| | | private String memo; |
| | | |
| | | public Station() {} |
| | | |
| | | public Station(String uuid,String staNo,String taskNo,String inEnable,String outEnable,String autoing,String loading,String canining,String canouting,Integer locType1,Integer locType2,Integer locType3,String shuttleCode,String locNo,Integer lev,Integer deviceId,Integer deviceOtherId,String flag,Long hostId,Integer status,Integer deleted,Date createTime,Long createBy,Date updateTime,Long updateBy,String memo) { |
| | | this.uuid = uuid; |
| | | this.staNo = staNo; |
| | | this.taskNo = taskNo; |
| | | this.inEnable = inEnable; |
| | | this.outEnable = outEnable; |
| | | this.autoing = autoing; |
| | | this.loading = loading; |
| | | this.canining = canining; |
| | | this.canouting = canouting; |
| | | this.locType1 = locType1; |
| | | this.locType2 = locType2; |
| | | this.locType3 = locType3; |
| | | this.shuttleCode = shuttleCode; |
| | | this.locNo = locNo; |
| | | this.lev = lev; |
| | | this.deviceId = deviceId; |
| | | this.deviceOtherId = deviceOtherId; |
| | | this.flag = flag; |
| | | this.hostId = hostId; |
| | | this.status = status; |
| | | this.deleted = deleted; |
| | | this.createTime = createTime; |
| | | this.createBy = createBy; |
| | | this.updateTime = updateTime; |
| | | this.updateBy = updateBy; |
| | | this.memo = memo; |
| | | } |
| | | |
| | | // Station station = new Station( |
| | | // null, // 编号 |
| | | // null, // 站点号 |
| | | // null, // 工作号 |
| | | // null, // 可入 |
| | | // null, // 可出 |
| | | // null, // 自动 |
| | | // null, // 有物 |
| | | // null, // 能入 |
| | | // null, // 能出 |
| | | // null, // 高低类型 |
| | | // null, // 宽窄类型 |
| | | // null, // 轻重类型 |
| | | // null, // 四向穿梭车所识别的二维码 |
| | | // null, // 库位号 |
| | | // null, // 输送线楼层 |
| | | // null, // 设备号 |
| | | // null, // 输送线绑定的其他设备号 |
| | | // null, // 标识 |
| | | // null, // 所属机构 |
| | | // null, // 状态 |
| | | // null, // 是否删除 |
| | | // null, // 添加时间 |
| | | // null, // 添加人员 |
| | | // null, // 修改时间 |
| | | // null, // 修改人员 |
| | | // null // 备注 |
| | | // ); |
| | | |
| | | public String getLocType1$(){ |
| | | if (null == this.locType1){ return null; } |
| | | switch (this.locType1){ |
| | | case 0: |
| | | return "未知"; |
| | | case 1: |
| | | return "低库位"; |
| | | case 2: |
| | | return "高库位"; |
| | | default: |
| | | return String.valueOf(this.locType1); |
| | | } |
| | | } |
| | | |
| | | public String getLocType2$(){ |
| | | if (null == this.locType2){ return null; } |
| | | switch (this.locType2){ |
| | | case 0: |
| | | return "未知"; |
| | | case 1: |
| | | return "窄库位"; |
| | | case 2: |
| | | return "宽库位"; |
| | | default: |
| | | return String.valueOf(this.locType2); |
| | | } |
| | | } |
| | | |
| | | public String getLocType3$(){ |
| | | if (null == this.locType3){ return null; } |
| | | switch (this.locType3){ |
| | | case 0: |
| | | return "未知"; |
| | | case 1: |
| | | return "轻库位"; |
| | | case 2: |
| | | return "重库位"; |
| | | default: |
| | | return String.valueOf(this.locType3); |
| | | } |
| | | } |
| | | |
| | | public String getDeviceId$(){ |
| | | DeviceService service = SpringUtils.getBean(DeviceService.class); |
| | | Device device = service.getById(this.deviceId); |
| | | if (!Cools.isEmpty(device)){ |
| | | return String.valueOf(device.getDeviceNo() + "-" + device.getDevicePlc$()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public String getDeviceOtherId$(){ |
| | | DeviceService service = SpringUtils.getBean(DeviceService.class); |
| | | Device device = service.getById(this.deviceOtherId); |
| | | if (!Cools.isEmpty(device)){ |
| | | return String.valueOf(device.getDeviceNo()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public String getHostId$(){ |
| | | HostService service = SpringUtils.getBean(HostService.class); |
| | | Host host = service.getById(this.hostId); |
| | | if (!Cools.isEmpty(host)){ |
| | | return String.valueOf(host.getName()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public String getStatus$(){ |
| | | if (null == this.status){ return null; } |
| | | switch (this.status){ |
| | | case 1: |
| | | return "正常"; |
| | | case 0: |
| | | return "禁用"; |
| | | default: |
| | | return String.valueOf(this.status); |
| | | } |
| | | } |
| | | |
| | | public String getDeleted$(){ |
| | | if (null == this.deleted){ return null; } |
| | | switch (this.deleted){ |
| | | case 1: |
| | | return "是"; |
| | | case 0: |
| | | return "否"; |
| | | default: |
| | | return String.valueOf(this.deleted); |
| | | } |
| | | } |
| | | |
| | | public String getCreateTime$(){ |
| | | if (Cools.isEmpty(this.createTime)){ |
| | | return ""; |
| | | } |
| | | return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.createTime); |
| | | } |
| | | |
| | | public String getCreateBy$(){ |
| | | UserService service = SpringUtils.getBean(UserService.class); |
| | | User user = service.getById(this.createBy); |
| | | if (!Cools.isEmpty(user)){ |
| | | return String.valueOf(user.getNickname()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public String getUpdateTime$(){ |
| | | if (Cools.isEmpty(this.updateTime)){ |
| | | return ""; |
| | | } |
| | | return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.updateTime); |
| | | } |
| | | |
| | | public String getUpdateBy$(){ |
| | | UserService service = SpringUtils.getBean(UserService.class); |
| | | User user = service.getById(this.updateBy); |
| | | if (!Cools.isEmpty(user)){ |
| | | return String.valueOf(user.getNickname()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.wcs.core.mapper; |
| | | |
| | | import com.zy.asrs.wcs.core.entity.Station; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | @Mapper |
| | | @Repository |
| | | public interface StationMapper extends BaseMapper<Station> { |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.wcs.core.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.zy.asrs.wcs.core.entity.Station; |
| | | |
| | | public interface StationService extends IService<Station> { |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.wcs.core.service.impl; |
| | | |
| | | import com.zy.asrs.wcs.core.mapper.StationMapper; |
| | | import com.zy.asrs.wcs.core.entity.Station; |
| | | import com.zy.asrs.wcs.core.service.StationService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service("stationService") |
| | | public class StationServiceImpl extends ServiceImpl<StationMapper, Station> implements StationService { |
| | | |
| | | } |
| | |
| | | wrapper.like(Device::getDeviceNo, condition); |
| | | } |
| | | deviceService.page(new Page<>(1, 30), wrapper).getRecords().forEach( |
| | | item -> vos.add(new KeyValVo(item.getId(), item.getDeviceNo())) |
| | | item -> vos.add(new KeyValVo(item.getId(), item.getDeviceNo() + "-" + item.getDevicePlc$())) |
| | | ); |
| | | return R.ok().add(vos); |
| | | } |
| | |
| | | package com.zy.asrs.wcs.system.controller; |
| | | package com.zy.asrs.wcs.rcs.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | import com.zy.asrs.wcs.common.domain.PageParam; |
| | | import com.zy.asrs.wcs.rcs.entity.DeviceDataLog; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceDataLogService; |
| | | import com.zy.asrs.wcs.system.controller.BaseController; |
| | | import com.zy.asrs.wcs.utils.ExcelUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | |
| | | package com.zy.asrs.wcs.rcs.model.protocol; |
| | | |
| | | import com.zy.asrs.wcs.core.entity.Station; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | |
| | | return null; |
| | | } |
| | | |
| | | public Station toSqlModel(Station station){ |
| | | station.setStaNo(String.valueOf(siteId)); |
| | | station.setTaskNo(String.valueOf(workNo)); |
| | | station.setAutoing(autoing?"Y":"N"); |
| | | station.setLoading(loading?"Y":"N"); |
| | | station.setInEnable(inEnable?"Y":"N"); |
| | | station.setOutEnable(outEnable?"Y":"N"); |
| | | station.setLocType1(0); // 高低类型{0:未知,1:低库位,2:高库位} |
| | | station.setLocType2(0); // 宽窄类型{0:未知,1:窄库位,2:宽库位} |
| | | station.setLocType3(0); // 轻重类型{0:未知,1:轻库位,2:重库位} |
| | | return station; |
| | | } |
| | | |
| | | } |
| | |
| | | import HslCommunication.Profinet.Siemens.SiemensPLCS; |
| | | import HslCommunication.Profinet.Siemens.SiemensS7Net; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.DateUtils; |
| | | import com.zy.asrs.framework.exception.CoolException; |
| | | import com.zy.asrs.framework.common.SpringUtils; |
| | | import com.zy.asrs.wcs.core.entity.Station; |
| | | import com.zy.asrs.wcs.core.service.StationService; |
| | | import com.zy.asrs.wcs.core.utils.RedisUtil; |
| | | import com.zy.asrs.wcs.rcs.News; |
| | | import com.zy.asrs.wcs.rcs.cache.MessageQueue; |
| | |
| | | import java.text.MessageFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | |
| | | |
| | | private Map<Integer, StaProtocol> station = new ConcurrentHashMap<>(); |
| | | |
| | | public static final ArrayList<Integer> staNos1 = new ArrayList<Integer>() {{ |
| | | add(100);add(101);add(102);add(103);add(104);add(105); |
| | | add(200);add(201);add(202);add(203);add(204);add(205);add(206); |
| | | }}; |
| | | public static ArrayList<Station> stationList = new ArrayList<>(); |
| | | |
| | | /** |
| | | * 条码数量 |
| | |
| | | this.redisUtil = redisUtil; |
| | | } |
| | | |
| | | private ArrayList<Integer> getStaNo() { |
| | | switch (Integer.parseInt(device.getDeviceNo())) { |
| | | case 1: |
| | | return staNos1; |
| | | default: |
| | | throw new CoolException("获取站点失败!"); |
| | | private ArrayList<Station> getStaNo() { |
| | | try { |
| | | if (stationList.isEmpty()) { |
| | | StationService stationService = SpringUtils.getBean(StationService.class); |
| | | List<Station> stations = stationService.list(new LambdaQueryWrapper<Station>() |
| | | .eq(Station::getDeviceId, device.getId()) |
| | | .eq(Station::getStatus, 1) |
| | | .eq(Station::getHostId, device.getHostId())); |
| | | stationList.addAll(stations); |
| | | } |
| | | return stationList; |
| | | } catch (Exception e) { |
| | | return stationList; |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | private void read() throws InterruptedException { |
| | | ArrayList<Integer> staNos = getStaNo(); |
| | | ArrayList<Station> staNos = getStaNo(); |
| | | int staNoSize = staNos.size(); |
| | | if (station.isEmpty()) { |
| | | return; |
| | | } |
| | | OperateResultExOne<byte[]> result = siemensS7Net.Read("DB101.0", (short) (staNoSize*8)); |
| | | if (result.IsSuccess) { |
| | | for (int i = 0; i < staNoSize; i++) { |
| | | Integer siteId = staNos.get(i); // 站点编号 |
| | | Station siteStation = staNos.get(i); |
| | | int siteId = Integer.parseInt(siteStation.getStaNo());// 站点编号 |
| | | StaProtocol staProtocol = station.get(siteId); |
| | | if (null == staProtocol) { |
| | | staProtocol = new StaProtocol(); |
| | |
| | | } |
| | | |
| | | Thread.sleep(200); |
| | | ArrayList<Integer> errorStaNo = getStaNo(); |
| | | ArrayList<Station> errorStaNo = getStaNo(); |
| | | OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB101.800.0", (short) (errorStaNo.size() * 4)); |
| | | if (result3.IsSuccess) { |
| | | for (int i = 0; i < errorStaNo.size(); i++) { |
| | | Integer siteId = errorStaNo.get(i); // 站点编号 |
| | | Station siteStation = errorStaNo.get(i); |
| | | Integer siteId = Integer.parseInt(siteStation.getStaNo()); // 站点编号 |
| | | StaProtocol staProtocol = station.get(siteId); |
| | | // staProtocol.setLocType1((short) siemensS7Net.getByteTransform().TransInt32(result3.Content, i * 4));//高低信号 |
| | | boolean[] status = siemensS7Net.getByteTransform().TransBool(result3.Content, (i * 4 + 2), 2); |
| | | staProtocol.setFrontErr(status[0]);//前超限 |
| | | staProtocol.setBackErr(status[1]);//后超限 |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | if (result.IsSuccess && !Cools.isEmpty(result) && result.IsSuccess) { |
| | | |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功",DateUtils.convert(new Date()), device.getId())); |
| | | |
| | | // 根据实时信息更新数据库 |
| | | try { |
| | | // List<BasDevp> basDevps = new ArrayList<>(); |
| | | // for (Integer siteId : staNos) { |
| | | // StaProtocol staProtocol = station.get(siteId); |
| | | // basDevps.add(staProtocol.toSqlModel()); |
| | | // } |
| | | // |
| | | // BasDevpService basDevpService = SpringUtils.getBean(BasDevpService.class); |
| | | // if (null != basDevpService && !basDevpService.updateBatchById(basDevps)) { |
| | | // throw new Exception("更新数据库数据失败"); |
| | | // } |
| | | List<Station> stations = new ArrayList<>(); |
| | | for (Station sta : getStaNo()) { |
| | | StaProtocol staProtocol = station.get(Integer.parseInt(sta.getStaNo())); |
| | | Station sqlModel = staProtocol.toSqlModel(sta); |
| | | stations.add(sqlModel); |
| | | } |
| | | |
| | | if (!stations.isEmpty()) { |
| | | StationService stationService = SpringUtils.getBean(StationService.class); |
| | | if (null != stationService && !stationService.updateBatchById(stations)) { |
| | | throw new Exception("更新数据库数据失败"); |
| | | } |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】更新数据库数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), device.getId(), device.getIp(), device.getPort(), device.getRack(), device.getSlot())); |
| | |
| | | |
| | | @Override |
| | | public boolean writeWorkNo(int siteId, short workNo) { |
| | | ArrayList<Integer> staNos = getStaNo(); |
| | | int index = staNos.indexOf(siteId); |
| | | int index = findStaNosIndex(siteId); |
| | | |
| | | OperateResult write = siemensS7Net.Write("DB100." + index*6, workNo); // 工作号 |
| | | |
| | | if (!write.IsSuccess) { |
| | |
| | | |
| | | @Override |
| | | public boolean writeStaNo(int siteId,short staNo) { |
| | | ArrayList<Integer> staNos = getStaNo(); |
| | | int index = staNos.indexOf(siteId); |
| | | int index = findStaNosIndex(siteId); |
| | | |
| | | OperateResult write = siemensS7Net.Write("DB100." + (index*6+4), staNo); // 目标站 |
| | | |
| | | if (!write.IsSuccess) { |
| | |
| | | public Map<Integer, StaProtocol> getStation() { |
| | | return this.station; |
| | | } |
| | | |
| | | private int findStaNosIndex(int siteId) { |
| | | ArrayList<Station> staNos = getStaNo(); |
| | | |
| | | int index = -1; |
| | | for (int i = 0; i < staNos.size(); i++) { |
| | | Station sta = staNos.get(i); |
| | | if (Integer.parseInt(sta.getStaNo()) == siteId) { |
| | | index = i; |
| | | break; |
| | | } |
| | | } |
| | | return index; |
| | | } |
| | | } |
| | |
| | | generator.frontendPrefixPath = "zy-asrs-flow/"; |
| | | |
| | | generator.sqlOsType = SqlOsType.MYSQL; |
| | | generator.url="192.168.4.15:3306/asrs"; |
| | | generator.url="127.0.0.1:3306/asrs"; |
| | | generator.username="root"; |
| | | generator.password="xltys1995"; |
| | | generator.password="root"; |
| | | // generator.url="47.97.1.152:51433;databasename=jkasrs"; |
| | | // generator.username="sa"; |
| | | // generator.password="Zoneyung@zy56$"; |
| | | |
| | | generator.table="wcs_shuttle_device_status"; |
| | | generator.tableName="四向车设备状态列表"; |
| | | generator.packagePath="com.zy.asrs.wcs.rcs"; |
| | | generator.table="wcs_station"; |
| | | generator.tableName="站点列表"; |
| | | generator.packagePath="com.zy.asrs.wcs.core"; |
| | | |
| | | generator.build(); |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.zy.asrs.wcs.core.mapper.StationMapper"> |
| | | |
| | | </mapper> |