Merge branch 'Four-Way-Rack' of http://47.97.1.152:5880/r/zy-asrs-master into Four-Way-Rack
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="name" |
| | | label="名称" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | /> |
| | | </ProForm.Group> |
| | | <ProForm.Group> |
| | | <ProFormText |
| | | name="flag" |
| | | label="标识" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | /> |
| | | <ProFormSelect |
| | | name="status" |
| | | label="状态" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | options={[ |
| | | { label: '正常', value: 1 }, |
| | | { label: '禁用', value: 0 }, |
| | | ]} |
| | | /> |
| | | </ProForm.Group> |
| | | <ProForm.Group> |
| | | <ProFormDateTimePicker |
| | | name="createTime" |
| | | label="添加时间" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | transform={(value) => moment(value).toISOString()} |
| | | /> |
| | | <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; |
| | | }} |
| | | /> |
| | | </ProForm.Group> |
| | | <ProForm.Group> |
| | | <ProFormDateTimePicker |
| | | name="updateTime" |
| | | label="修改时间" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | transform={(value) => moment(value).toISOString()} |
| | | /> |
| | | <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; |
| | | }} |
| | | /> |
| | | </ProForm.Group> |
| | | <ProForm.Group> |
| | | <ProFormText |
| | | name="memo" |
| | | label="备注" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | /> |
| | | <ProFormDigit |
| | | name="taskNo" |
| | | label="当前ID" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | fieldProps={{ precision: 0 }} |
| | | /> |
| | | </ProForm.Group> |
| | | <ProForm.Group> |
| | | <ProFormDigit |
| | | name="startNo" |
| | | label="起始ID" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | fieldProps={{ precision: 0 }} |
| | | /> |
| | | <ProFormDigit |
| | | name="targetNo" |
| | | label="目标ID" |
| | | colProps={{ md: 12, xl: 12 }} |
| | | fieldProps={{ precision: 0 }} |
| | | /> |
| | | </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-taskSerialNo'; |
| | | |
| | | const handleSave = async (val, intl) => { |
| | | const hide = message.loading(intl.formatMessage({ id: 'page.adding', defaultMessage: '正在添加' })); |
| | | try { |
| | | const resp = await Http.doPost('api/taskSerialNo/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/taskSerialNo/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/taskSerialNo/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/taskSerialNo/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: 'name', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | copyable: true, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='name' |
| | | {...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: '当前ID', |
| | | dataIndex: 'taskNo', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='taskNo' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '起始ID', |
| | | dataIndex: 'startNo', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='startNo' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '目标ID', |
| | | dataIndex: 'targetNo', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='targetNo' |
| | | {...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="taskSerialNo" |
| | | 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/taskSerialNo/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; |
| | |
| | | mainService.loopShuttleCharge(); |
| | | // 穿梭车 ===>> 小车电量满电后回待机位 |
| | | mainService.loopShuttleToStandbyCauseCharge(); |
| | | // // 扫描已经在出库口的货物 => 呼叫agv至放货站点 |
| | | // mainService.scanOutCallAgv(); |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
New file |
| | |
| | | package com.zy.asrs.wcs.system.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.TaskSerialNo; |
| | | import com.zy.asrs.wcs.core.service.TaskSerialNoService; |
| | | 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 TaskSerialNoController extends BaseController { |
| | | |
| | | @Autowired |
| | | private TaskSerialNoService taskSerialNoService; |
| | | |
| | | @PreAuthorize("hasAuthority('core:taskSerialNo:list')") |
| | | @PostMapping("/taskSerialNo/page") |
| | | public R page(@RequestBody Map<String, Object> map) { |
| | | BaseParam baseParam = buildParam(map, BaseParam.class); |
| | | PageParam<TaskSerialNo, BaseParam> pageParam = new PageParam<>(baseParam, TaskSerialNo.class); |
| | | return R.ok().add(taskSerialNoService.page(pageParam, pageParam.buildWrapper(true))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('core:taskSerialNo:list')") |
| | | @PostMapping("/taskSerialNo/list") |
| | | public R list(@RequestBody Map<String, Object> map) { |
| | | return R.ok().add(taskSerialNoService.list()); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('core:taskSerialNo:list')") |
| | | @GetMapping("/taskSerialNo/{id}") |
| | | public R get(@PathVariable("id") Long id) { |
| | | return R.ok().add(taskSerialNoService.getById(id)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('core:taskSerialNo:save')") |
| | | @OperationLog("添加任务序列号") |
| | | @PostMapping("/taskSerialNo/save") |
| | | public R save(@RequestBody TaskSerialNo taskSerialNo) { |
| | | if (!taskSerialNoService.save(taskSerialNo)) { |
| | | return R.error("添加失败"); |
| | | } |
| | | return R.ok("添加成功"); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('core:taskSerialNo:update')") |
| | | @OperationLog("修改任务序列号") |
| | | @PostMapping("/taskSerialNo/update") |
| | | public R update(@RequestBody TaskSerialNo taskSerialNo) { |
| | | if (!taskSerialNoService.updateById(taskSerialNo)) { |
| | | return R.error("修改失败"); |
| | | } |
| | | return R.ok("修改成功"); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('core:taskSerialNo:remove')") |
| | | @OperationLog("删除任务序列号") |
| | | @PostMapping("/taskSerialNo/remove/{ids}") |
| | | public R remove(@PathVariable Long[] ids) { |
| | | if (!taskSerialNoService.removeByIds(Arrays.asList(ids))) { |
| | | return R.error("删除失败"); |
| | | } |
| | | return R.ok("删除成功"); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('core:taskSerialNo:list')") |
| | | @PostMapping("/taskSerialNo/query") |
| | | public R query(@RequestParam(required = false) String condition) { |
| | | List<KeyValVo> vos = new ArrayList<>(); |
| | | LambdaQueryWrapper<TaskSerialNo> wrapper = new LambdaQueryWrapper<>(); |
| | | if (!Cools.isEmpty(condition)) { |
| | | wrapper.like(TaskSerialNo::getName, condition); |
| | | } |
| | | taskSerialNoService.page(new Page<>(1, 30), wrapper).getRecords().forEach( |
| | | item -> vos.add(new KeyValVo(item.getId(), item.getName())) |
| | | ); |
| | | return R.ok().add(vos); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('core:taskSerialNo:list')") |
| | | @PostMapping("/taskSerialNo/export") |
| | | public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | ExcelUtil.build(ExcelUtil.create(taskSerialNoService.list(), TaskSerialNo.class), response); |
| | | } |
| | | |
| | | } |
| | |
| | | @ApiModelProperty(value= "备注") |
| | | private String memo; |
| | | |
| | | /** |
| | | * 四向穿梭车号 |
| | | */ |
| | | @ApiModelProperty(value= "四向穿梭车号") |
| | | private Integer shuttleNo; |
| | | |
| | | /** |
| | | * 提升机号 |
| | | */ |
| | | @ApiModelProperty(value= "提升机号") |
| | | private Integer liftNo; |
| | | |
| | | /** |
| | | * 堆垛机号 |
| | | */ |
| | | @ApiModelProperty(value= "堆垛机号") |
| | | private Integer crnNo; |
| | | |
| | | /** |
| | | * RGV号 |
| | | */ |
| | | @ApiModelProperty(value= "RGV号") |
| | | private Integer rgvNo; |
| | | |
| | | /** |
| | | * AGV号 |
| | | */ |
| | | @ApiModelProperty(value= "AGV号") |
| | | private Integer agvNo; |
| | | |
| | | public Task() {} |
| | | |
| | | public Task(String uuid,Long busId,String taskNo,String serialNum,String title,Long taskSts,Long taskCtg,Integer priority,String originSite,String originLoc,String destSite,String destLoc,Integer emptyMk,String zpallet,String phase,Date ioTime,Date startTime,Date endTime,Date exceptionTime,String exceptionDesc,Long hostId,Integer status,Integer deleted,Date createTime,Long createBy,Date updateTime,Long updateBy,String memo) { |
| | | public Task(String uuid, Long busId, String taskNo, String serialNum, String title, Long taskSts, Long taskCtg, Integer priority, String originSite, String originLoc, String destSite, String destLoc, Integer emptyMk, String zpallet, String phase, Date ioTime, Date startTime, Date endTime, Date exceptionTime, String exceptionDesc, Long hostId, Integer status, Integer deleted, Date createTime, Long createBy, Date updateTime, Long updateBy, String memo, Integer shuttleNo, Integer liftNo, Integer crnNo, Integer rgvNo, Integer agvNo) { |
| | | this.uuid = uuid; |
| | | this.busId = busId; |
| | | this.taskNo = taskNo; |
| | |
| | | this.updateTime = updateTime; |
| | | this.updateBy = updateBy; |
| | | this.memo = memo; |
| | | this.shuttleNo = shuttleNo; |
| | | this.liftNo = liftNo; |
| | | this.crnNo = crnNo; |
| | | this.rgvNo = rgvNo; |
| | | this.agvNo = agvNo; |
| | | } |
| | | |
| | | // Task task = new Task( |
| | | // Task task = new Task( |
| | | // null, // 编号 |
| | | // null, // 总线 |
| | | // null, // 任务号 |
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.system.entity.Host; |
| | | import com.zy.asrs.wcs.system.entity.User; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | | 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; |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | @TableName("wcs_task_serial_no") |
| | | public class TaskSerialNo 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 name; |
| | | |
| | | /** |
| | | * 标识 |
| | | */ |
| | | @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; |
| | | |
| | | /** |
| | | * 当前ID |
| | | */ |
| | | @ApiModelProperty(value= "当前ID") |
| | | private Integer taskNo; |
| | | |
| | | /** |
| | | * 起始ID |
| | | */ |
| | | @ApiModelProperty(value= "起始ID") |
| | | private Integer startNo; |
| | | |
| | | /** |
| | | * 目标ID |
| | | */ |
| | | @ApiModelProperty(value= "目标ID") |
| | | private Integer targetNo; |
| | | |
| | | public TaskSerialNo() {} |
| | | |
| | | public TaskSerialNo(String uuid,String name,String flag,Long hostId,Integer status,Integer deleted,Date createTime,Long createBy,Date updateTime,Long updateBy,String memo,Integer taskNo,Integer startNo,Integer targetNo) { |
| | | this.uuid = uuid; |
| | | this.name = name; |
| | | 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; |
| | | this.taskNo = taskNo; |
| | | this.startNo = startNo; |
| | | this.targetNo = targetNo; |
| | | } |
| | | |
| | | // TaskSerialNo taskSerialNo = new TaskSerialNo( |
| | | // null, // 编号 |
| | | // null, // 名称 |
| | | // null, // 标识 |
| | | // null, // 所属机构 |
| | | // null, // 状态 |
| | | // null, // 是否删除 |
| | | // null, // 添加时间 |
| | | // null, // 添加人员 |
| | | // null, // 修改时间 |
| | | // null, // 修改人员 |
| | | // null, // 备注 |
| | | // null, // 当前ID |
| | | // null, // 起始ID |
| | | // null // 目标ID |
| | | // ); |
| | | |
| | | 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; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | // /** |
| | | // * 生成充电动作 |
| | | // */ |
| | | // public List<Motion> generateChargeMotion(WrkCharge wrkCharge) { |
| | | // List<Motion> motionList = new ArrayList<>(); |
| | | /** |
| | | * 生成充电动作 |
| | | */ |
| | | public List<Motion> generateChargeMotion(Task task) { |
| | | List<Motion> motionList = new ArrayList<>(); |
| | | // if (wrkCharge.getWrkSts() != WrkMastStsType.NEW_CHARGE.sts || wrkCharge.getIoType() != WrkIoTypeType.CHARGE.sts) { |
| | | // return motionList; |
| | | // } |
| | |
| | | // dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue()); |
| | | // })) |
| | | // )); |
| | | // |
| | | // return motionList; |
| | | // } |
| | | // |
| | | // /** |
| | | // * 生成充电完成动作 |
| | | // */ |
| | | // public List<Motion> generateShuttleChargeWrkComplete(WrkCharge wrkCharge) { |
| | | // List<Motion> motionList = new ArrayList<>(); |
| | | |
| | | return motionList; |
| | | } |
| | | |
| | | /** |
| | | * 生成充电完成动作 |
| | | */ |
| | | public List<Motion> generateShuttleChargeWrkComplete(Task task) { |
| | | List<Motion> motionList = new ArrayList<>(); |
| | | // if (wrkCharge.getWrkSts() != WrkMastStsType.NEW_MOVE.sts || wrkCharge.getIoType() != WrkIoTypeType.MOVE.sts) { |
| | | // return motionList; |
| | | // } |
| | |
| | | // )); |
| | | // |
| | | // } |
| | | // return motionList; |
| | | // } |
| | | return motionList; |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | |
| | | List<Task> selectPakOut(); |
| | | |
| | | List<Task> hasChargeInLoc(String locNo); |
| | | |
| | | Task selectMoveWorking(Integer shuttleNo); |
| | | |
| | | Task selectChargeWorking(Integer shuttleNo); |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.wcs.core.mapper; |
| | | |
| | | import com.zy.asrs.wcs.core.entity.TaskSerialNo; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | @Mapper |
| | | @Repository |
| | | public interface TaskSerialNoMapper extends BaseMapper<TaskSerialNo> { |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.wcs.core.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.zy.asrs.wcs.core.entity.TaskSerialNo; |
| | | |
| | | public interface TaskSerialNoService extends IService<TaskSerialNo> { |
| | | |
| | | } |
| | |
| | | |
| | | List<Task> selectPakOut(); |
| | | |
| | | List<Task> hasChargeInLoc(String locNo); |
| | | |
| | | Task selectMoveWorking(Integer shuttleNo); |
| | | |
| | | Task selectChargeWorking(Integer shuttleNo); |
| | | |
| | | } |
| | |
| | | package com.zy.asrs.wcs.core.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.wcs.core.entity.Task; |
| | | import com.zy.asrs.framework.common.SnowflakeIdWorker; |
| | | import com.zy.asrs.wcs.core.entity.*; |
| | | import com.zy.asrs.wcs.core.kernel.AnalyzeService; |
| | | import com.zy.asrs.wcs.core.model.enums.DeviceCtgType; |
| | | import com.zy.asrs.wcs.core.model.enums.MotionStsType; |
| | | import com.zy.asrs.wcs.core.model.enums.TaskStsType; |
| | | import com.zy.asrs.wcs.core.service.TaskService; |
| | | import com.zy.asrs.wcs.core.service.*; |
| | | import com.zy.asrs.wcs.core.utils.Utils; |
| | | import com.zy.asrs.wcs.rcs.News; |
| | | import com.zy.asrs.wcs.core.entity.Motion; |
| | | import com.zy.asrs.wcs.core.service.MotionService; |
| | | import com.zy.asrs.wcs.rcs.cache.SlaveConnection; |
| | | import com.zy.asrs.wcs.rcs.entity.Device; |
| | | import com.zy.asrs.wcs.rcs.entity.DeviceType; |
| | | import com.zy.asrs.wcs.rcs.model.enums.ShuttleProtocolStatusType; |
| | | import com.zy.asrs.wcs.rcs.model.enums.SlaveType; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.StaProtocol; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceService; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceTypeService; |
| | | import com.zy.asrs.wcs.rcs.thread.DevpThread; |
| | | import com.zy.asrs.wcs.rcs.thread.ShuttleThread; |
| | | import com.zy.asrs.wcs.system.entity.Dict; |
| | | import com.zy.asrs.wcs.system.service.DictService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | 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; |
| | | |
| | |
| | | private AnalyzeService analyzeService; |
| | | @Autowired |
| | | private MotionService motionService; |
| | | @Autowired |
| | | private DeviceService deviceService; |
| | | @Autowired |
| | | private DeviceTypeService deviceTypeService; |
| | | @Autowired |
| | | private LocCtgService locCtgService; |
| | | @Autowired |
| | | private LocService locService; |
| | | @Autowired |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | @Autowired |
| | | private TaskCtgService taskCtgService; |
| | | @Autowired |
| | | private DictService dictService; |
| | | |
| | | /** |
| | | * 组托 |
| | |
| | | * 四向穿梭车电量检测 ===>> 发起充电 |
| | | */ |
| | | public synchronized void loopShuttleCharge() { |
| | | // ShuttleChargeType shuttleCharge = ShuttleChargeType.CHARGE_1; |
| | | // for (ShuttleSlave shuttle : slaveProperties.getShuttle()) { |
| | | // // 判断充电位是否被占用 |
| | | // if (wrkChargeService.hasShuttleInChargeLoc(shuttleCharge.locNo, shuttle.getId())) { |
| | | // continue; |
| | | // } |
| | | // |
| | | // //获取四向穿梭车线程 |
| | | // ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttle.getId()); |
| | | // ShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); |
| | | // if (shuttleProtocol == null) { |
| | | // continue; |
| | | // } |
| | | // if (motionService.selectCount(new EntityWrapper<Motion>() |
| | | // .eq("device_ctg", DeviceCtgType.SHUTTLE.val()) |
| | | // .eq("device", shuttle.getId()) |
| | | // .eq("motion_sts", MotionStsType.EXECUTING.val())) > 0) { |
| | | // continue; |
| | | // } |
| | | // |
| | | // //判断当前小车是否满足需要充电要求 |
| | | // if (!shuttleProtocol.isRequireCharge()) { |
| | | // continue; |
| | | // } |
| | | // |
| | | // WrkCharge wrkCharge = wrkChargeService.selectWorking(null); |
| | | // if (wrkCharge != null) {//已有充电任务 |
| | | // continue; |
| | | // } |
| | | // |
| | | // String chargeLocNo = shuttleCharge.locNo; |
| | | // wrkCharge = new WrkCharge(); |
| | | // wrkCharge.setShuttleNo(shuttle.getId()); |
| | | // wrkCharge.setCharge(shuttleCharge.id); |
| | | // wrkCharge.setWrkNo(commonService.getChargeWorkNo(4)); |
| | | // wrkCharge.setUuid(String.valueOf(snowflakeIdWorker.nextId())); |
| | | // wrkCharge.setWrkSts(WrkMastStsType.NEW_CHARGE.sts); // 充电任务 |
| | | // wrkCharge.setIoType(WrkIoTypeType.CHARGE.sts); |
| | | // wrkCharge.setIoPri((double) 10); |
| | | // wrkCharge.setLocNo(chargeLocNo); |
| | | // wrkCharge.setMemo("charge"); |
| | | // wrkCharge.setAppeTime(new Date()); |
| | | // |
| | | // // generate motion list |
| | | // List<Motion> motionList = analyzeService.generateChargeMotion(wrkCharge); |
| | | // if (Cools.isEmpty(motionList)) { |
| | | // News.error("保存{}号四向穿梭车充电任务失败!!!", shuttle.getId()); |
| | | // continue; |
| | | // } |
| | | // motionService.batchInsert(motionList, wrkCharge.getUuid(), wrkCharge.getWrkNo()); |
| | | // |
| | | // wrkCharge.setWrkSts(WrkMastStsType.ANALYZE_CHARGE.sts); |
| | | // |
| | | // if (!wrkChargeService.insert(wrkCharge)) { |
| | | // News.error("保存{}号四向穿梭车充电任务失败!!!", shuttle.getId()); |
| | | // continue; |
| | | // } |
| | | // |
| | | // News.info("保存{}号四向穿梭车充电任务成功!!!", shuttle.getId()); |
| | | // } |
| | | // 获取充电桩库位类型 |
| | | LocCtg locCtg = locCtgService.getOne(new LambdaQueryWrapper<LocCtg>() |
| | | .eq(LocCtg::getFlag, "CHARGE") |
| | | .eq(LocCtg::getStatus, 1)); |
| | | if (locCtg == null) { |
| | | return; |
| | | } |
| | | |
| | | //获取充电任务类型 |
| | | TaskCtg taskCtg = taskCtgService.getOne(new LambdaQueryWrapper<TaskCtg>() |
| | | .eq(TaskCtg::getFlag, "CHARGE") |
| | | .eq(TaskCtg::getStatus, 1)); |
| | | if (taskCtg == null) { |
| | | return; |
| | | } |
| | | |
| | | DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>() |
| | | .eq(DeviceType::getFlag, String.valueOf(SlaveType.Shuttle)) |
| | | .eq(DeviceType::getStatus, 1)); |
| | | if (deviceType == null) { |
| | | return; |
| | | } |
| | | |
| | | List<Device> list = deviceService.list(new LambdaQueryWrapper<Device>() |
| | | .eq(Device::getDeviceType, deviceType.getId()) |
| | | .eq(Device::getStatus, 1)); |
| | | for (Device device : list) { |
| | | //获取四向穿梭车线程 |
| | | ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue()); |
| | | if (shuttleThread == null) { |
| | | continue; |
| | | } |
| | | |
| | | ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); |
| | | if (shuttleProtocol == null) { |
| | | continue; |
| | | } |
| | | |
| | | if (!shuttleProtocol.getProtocolStatusType().equals(ShuttleProtocolStatusType.IDLE)) { |
| | | continue; |
| | | } |
| | | |
| | | String currentLocNo = shuttleProtocol.getCurrentLocNo(); |
| | | int lev = Utils.getLev(currentLocNo);//获取小车楼层 |
| | | //搜索小车当前楼层充电桩 |
| | | ArrayList<Loc> allChargeLoc = new ArrayList<>(); |
| | | List<Loc> list1 = locService.list(new LambdaQueryWrapper<Loc>() |
| | | .eq(Loc::getLocCtg, locCtg.getId()) |
| | | .eq(Loc::getStatus, 1) |
| | | .eq(Loc::getLev, lev)); |
| | | if (!list1.isEmpty()) { |
| | | allChargeLoc.addAll(list1); |
| | | } |
| | | |
| | | //搜索其他楼层充电桩 |
| | | List<Loc> list2 = locService.list(new LambdaQueryWrapper<Loc>() |
| | | .eq(Loc::getLocCtg, locCtg.getId()) |
| | | .eq(Loc::getStatus, 1) |
| | | .notIn(Loc::getLev, lev)); |
| | | if (!list2.isEmpty()) { |
| | | allChargeLoc.addAll(list2); |
| | | } |
| | | |
| | | //没有找到充电桩 |
| | | if (allChargeLoc.isEmpty()) { |
| | | continue; |
| | | } |
| | | |
| | | //选择空闲充电桩 |
| | | Loc chargeLoc = null; |
| | | for (Loc loc : allChargeLoc) { |
| | | // 判断充电位是否被占用(车辆位置) |
| | | if (Utils.hasShuttleInLoc(loc.getLocNo(), device.getId())) { |
| | | continue; |
| | | } |
| | | |
| | | // 盘点充电位是否存在任务档 |
| | | List<Task> tasks = taskService.hasChargeInLoc(loc.getLocNo()); |
| | | if (!tasks.isEmpty()) { |
| | | continue; |
| | | } |
| | | |
| | | chargeLoc = loc; |
| | | break; |
| | | } |
| | | |
| | | if (chargeLoc == null) { |
| | | continue;//未找到充电桩 |
| | | } |
| | | |
| | | if (motionService.count(new LambdaQueryWrapper<Motion>() |
| | | .eq(Motion::getDeviceCtg, DeviceCtgType.SHUTTLE.val()) |
| | | .eq(Motion::getDevice, device.getDeviceNo()) |
| | | .eq(Motion::getMotionSts, MotionStsType.EXECUTING.val())) > 0) { |
| | | continue; |
| | | } |
| | | |
| | | //判断当前小车是否满足需要充电要求 |
| | | if (!shuttleThread.isRequireCharge()) { |
| | | continue; |
| | | } |
| | | |
| | | Task taskCharge = taskService.selectChargeWorking(Integer.valueOf(device.getDeviceNo())); |
| | | if (taskCharge != null) {//已有充电任务 |
| | | continue; |
| | | } |
| | | |
| | | String chargeLocNo = chargeLoc.getLocNo(); |
| | | Task task = new Task(); |
| | | task.setUuid(String.valueOf(snowflakeIdWorker.nextId())); |
| | | task.setTaskNo(String.valueOf(Utils.getTaskNo("CHARGE"))); |
| | | task.setTaskSts(TaskStsType.NEW_CHARGE.sts); |
| | | task.setTaskCtg(taskCtg.getId()); |
| | | task.setPriority(10); |
| | | task.setOriginSite(null); |
| | | task.setOriginLoc(null); |
| | | task.setDestSite(null); |
| | | task.setDestLoc(chargeLocNo); |
| | | task.setIoTime(new Date()); |
| | | task.setStartTime(new Date()); |
| | | task.setHostId(device.getHostId()); |
| | | task.setStatus(1); |
| | | task.setMemo("charge"); |
| | | task.setShuttleNo(Integer.valueOf(device.getDeviceNo())); |
| | | |
| | | // generate motion list |
| | | List<Motion> motionList = analyzeService.generateChargeMotion(task); |
| | | if (Cools.isEmpty(motionList)) { |
| | | News.error("保存{}号四向穿梭车充电任务失败!!!", device.getDeviceNo()); |
| | | continue; |
| | | } |
| | | motionService.batchInsert(motionList, task.getUuid(), Integer.valueOf(task.getTaskNo())); |
| | | |
| | | task.setTaskSts(TaskStsType.ANALYZE_CHARGE.sts); |
| | | if (!taskService.save(task)) { |
| | | News.error("保存{}号四向穿梭车充电任务失败!!!", device.getDeviceNo()); |
| | | continue; |
| | | } |
| | | |
| | | News.info("保存{}号四向穿梭车充电任务成功!!!", device.getDeviceNo()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 四向穿梭车电量检测 ===>> 满电后回到待机位 |
| | | */ |
| | | public synchronized void loopShuttleToStandbyCauseCharge() { |
| | | // ShuttleChargeType shuttleCharge = ShuttleChargeType.CHARGE_1; |
| | | // Integer enoughPower = 90; |
| | | // Config config = configService.selectOne(new EntityWrapper<Config>() |
| | | // .eq("code", "chargeMaxValue") |
| | | // .eq("status", 1)); |
| | | // if (config != null) { |
| | | // enoughPower = Integer.parseInt(config.getValue()); |
| | | // } |
| | | // |
| | | // for (ShuttleSlave shuttle : slaveProperties.getShuttle()) { |
| | | // //获取四向穿梭车线程 |
| | | // ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttle.getId()); |
| | | // ShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); |
| | | // if (shuttleProtocol == null) { |
| | | // continue; |
| | | // } |
| | | // // 是否存在充电任务 |
| | | // WrkCharge wrkCharge = wrkChargeService.selectWorking(shuttle.getId()); |
| | | // if (wrkCharge == null) { |
| | | // continue; |
| | | // } |
| | | // |
| | | // if (motionService.selectCount(new EntityWrapper<Motion>() |
| | | // .eq("device_ctg", DeviceCtgType.SHUTTLE.val()) |
| | | // .eq("device", shuttle.getId()) |
| | | // .eq("motion_sts", MotionStsType.EXECUTING.val())) > 0) { |
| | | // continue; |
| | | // } |
| | | // // 不处于充电中 |
| | | // if (!shuttleProtocol.getPlcOutputCharge()) { |
| | | // continue; |
| | | // } |
| | | // // 在充电位 |
| | | // if (!shuttleProtocol.getCurrentLocNo().equals(shuttleCharge.locNo)) { |
| | | // continue; |
| | | // } |
| | | // // 电量是否达到满电要求 |
| | | // if (shuttleProtocol.getBatteryPower$().intValue() < enoughPower) { |
| | | // continue; |
| | | // } |
| | | // // 已有迁移任务 |
| | | // if (wrkChargeService.selectMoveWorking(shuttle.getId()) != null) { |
| | | // continue; |
| | | // } |
| | | // |
| | | // // 待机位 |
| | | // String standByLocNo = ShuttleTempLocType.query(shuttleProtocol.getShuttleNo().intValue(), 2, Utils.getLev(shuttleCharge.locNo)).locNo; |
| | | // |
| | | // shuttleDispatcher.generateShuttleChargeWrkComplete(shuttleProtocol.getShuttleNo().intValue(), standByLocNo); |
| | | // |
| | | // wrkCharge.setWrkSts(WrkMastStsType.COMPLETE_CHARGE.sts); |
| | | // wrkCharge.setIoTime(new Date()); |
| | | // wrkChargeMapper.updateById(wrkCharge); |
| | | // } |
| | | Integer enoughPower = 90; |
| | | Dict dict = dictService.getOne(new LambdaQueryWrapper<Dict>() |
| | | .eq(Dict::getFlag, "chargeMaxValue") |
| | | .eq(Dict::getStatus, 1)); |
| | | if (dict != null) { |
| | | enoughPower = Integer.parseInt(dict.getValue()); |
| | | } |
| | | |
| | | //获取迁移任务类型 |
| | | TaskCtg taskCtg = taskCtgService.getOne(new LambdaQueryWrapper<TaskCtg>() |
| | | .eq(TaskCtg::getFlag, "MOVE") |
| | | .eq(TaskCtg::getStatus, 1)); |
| | | if (taskCtg == null) { |
| | | return; |
| | | } |
| | | |
| | | DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>() |
| | | .eq(DeviceType::getFlag, String.valueOf(SlaveType.Shuttle)) |
| | | .eq(DeviceType::getStatus, 1)); |
| | | if (deviceType == null) { |
| | | return; |
| | | } |
| | | |
| | | List<Device> list = deviceService.list(new LambdaQueryWrapper<Device>() |
| | | .eq(Device::getDeviceType, deviceType.getId()) |
| | | .eq(Device::getStatus, 1)); |
| | | for (Device device : list) { |
| | | //获取四向穿梭车线程 |
| | | ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue()); |
| | | if (shuttleThread == null) { |
| | | continue; |
| | | } |
| | | |
| | | if (!shuttleThread.isCharging()) { |
| | | continue; |
| | | } |
| | | |
| | | if (!shuttleThread.isChargingCompleted()) { |
| | | continue; |
| | | } |
| | | |
| | | //查找充电任务 |
| | | Task chargeTask = taskService.getOne(new LambdaQueryWrapper<Task>() |
| | | .eq(Task::getTaskSts, TaskStsType.CHARGE_WORKING.sts) |
| | | .eq(Task::getShuttleNo, device.getDeviceNo())); |
| | | if (chargeTask == null) { |
| | | continue; |
| | | } |
| | | |
| | | //充电完成 |
| | | // 已有迁移任务 |
| | | if (taskService.selectMoveWorking(Integer.valueOf(device.getDeviceNo())) != null) { |
| | | continue; |
| | | } |
| | | |
| | | Task task = new Task(); |
| | | task.setUuid(String.valueOf(snowflakeIdWorker.nextId())); |
| | | task.setTaskNo(String.valueOf(Utils.getTaskNo("MOVE"))); |
| | | task.setTaskSts(TaskStsType.NEW_MOVE.sts); |
| | | task.setTaskCtg(taskCtg.getId()); |
| | | task.setPriority(10); |
| | | task.setOriginSite(null); |
| | | task.setOriginLoc(null); |
| | | task.setDestSite(null); |
| | | task.setDestLoc("1-1-1"); // 暂时未定 |
| | | task.setIoTime(new Date()); |
| | | task.setStartTime(new Date()); |
| | | task.setHostId(device.getHostId()); |
| | | task.setStatus(1); |
| | | task.setMemo("charge"); |
| | | task.setShuttleNo(Integer.valueOf(device.getDeviceNo())); |
| | | |
| | | // generate motion list |
| | | List<Motion> motionList = analyzeService.generateShuttleChargeWrkComplete(task); |
| | | if (Cools.isEmpty(motionList)) { |
| | | News.error("保存{}号四向穿梭车迁移任务失败!!!", device.getDeviceNo()); |
| | | continue; |
| | | } |
| | | motionService.batchInsert(motionList, task.getUuid(), Integer.valueOf(task.getTaskNo())); |
| | | |
| | | task.setTaskSts(TaskStsType.ANALYZE_MOVE.sts); |
| | | |
| | | if (!taskService.save(task)) { |
| | | News.error("保存{}号四向穿梭车迁移任务失败!!!", device.getDeviceNo()); |
| | | continue; |
| | | } |
| | | |
| | | chargeTask.setTaskSts(TaskStsType.COMPLETE_CHARGE.sts); |
| | | chargeTask.setIoTime(new Date()); |
| | | taskService.updateById(chargeTask); |
| | | } |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.wcs.core.service.impl; |
| | | |
| | | import com.zy.asrs.wcs.core.mapper.TaskSerialNoMapper; |
| | | import com.zy.asrs.wcs.core.entity.TaskSerialNo; |
| | | import com.zy.asrs.wcs.core.service.TaskSerialNoService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service("taskSerialNoService") |
| | | public class TaskSerialNoServiceImpl extends ServiceImpl<TaskSerialNoMapper, TaskSerialNo> implements TaskSerialNoService { |
| | | |
| | | } |
| | |
| | | public List<Task> selectPakOut() { |
| | | return this.baseMapper.selectPakOut(); |
| | | } |
| | | |
| | | @Override |
| | | public List<Task> hasChargeInLoc(String locNo) { |
| | | return this.baseMapper.hasChargeInLoc(locNo); |
| | | } |
| | | |
| | | @Override |
| | | public Task selectMoveWorking(Integer shuttleNo) { |
| | | return this.baseMapper.selectMoveWorking(shuttleNo); |
| | | } |
| | | |
| | | @Override |
| | | public Task selectChargeWorking(Integer shuttleNo) { |
| | | return this.baseMapper.selectChargeWorking(shuttleNo); |
| | | } |
| | | } |
| | |
| | | package com.zy.asrs.wcs.core.utils; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.SpringUtils; |
| | | import com.zy.asrs.framework.exception.CoolException; |
| | | import com.zy.asrs.wcs.core.entity.Task; |
| | | import com.zy.asrs.wcs.core.entity.TaskSerialNo; |
| | | import com.zy.asrs.wcs.core.service.TaskSerialNoService; |
| | | import com.zy.asrs.wcs.core.service.TaskService; |
| | | import com.zy.asrs.wcs.rcs.cache.SlaveConnection; |
| | | import com.zy.asrs.wcs.rcs.entity.Device; |
| | | import com.zy.asrs.wcs.rcs.entity.DeviceType; |
| | | import com.zy.asrs.wcs.rcs.model.enums.SlaveType; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceService; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceTypeService; |
| | | import com.zy.asrs.wcs.rcs.thread.ShuttleThread; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | return list; |
| | | } |
| | | |
| | | public static boolean hasShuttleInLoc(String locNo, Long deviceId) { |
| | | DeviceTypeService deviceTypeService = SpringUtils.getBean(DeviceTypeService.class); |
| | | DeviceService deviceService = SpringUtils.getBean(DeviceService.class); |
| | | |
| | | DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>() |
| | | .eq(DeviceType::getFlag, String.valueOf(SlaveType.Shuttle)) |
| | | .eq(DeviceType::getStatus, 1)); |
| | | if (deviceType == null) { |
| | | return false; |
| | | } |
| | | |
| | | List<Device> list = deviceService.list(new LambdaQueryWrapper<Device>() |
| | | .eq(Device::getDeviceType, deviceType.getId()) |
| | | .eq(Device::getStatus, 1)); |
| | | |
| | | for (Device device : list) { |
| | | if (deviceId.equals(device.getId())) { |
| | | continue; |
| | | } |
| | | |
| | | //获取四向穿梭车线程 |
| | | ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue()); |
| | | if (shuttleThread == null) { |
| | | continue; |
| | | } |
| | | |
| | | ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); |
| | | if (shuttleProtocol == null) { |
| | | continue; |
| | | } |
| | | |
| | | if (shuttleProtocol.getCurrentLocNo().equals(locNo)) { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 生成工作号 |
| | | * @return taskNo(工作号) |
| | | */ |
| | | public static int getTaskNo(String flag) { |
| | | TaskSerialNoService taskSerialNoService = SpringUtils.getBean(TaskSerialNoService.class); |
| | | TaskService taskService = SpringUtils.getBean(TaskService.class); |
| | | TaskSerialNo taskSerialNo = taskSerialNoService.getOne(new LambdaQueryWrapper<TaskSerialNo>() |
| | | .eq(TaskSerialNo::getFlag, flag) |
| | | .eq(TaskSerialNo::getStatus, 1)); |
| | | if (Cools.isEmpty(taskSerialNo)) { |
| | | throw new CoolException("数据异常,请联系管理员"); |
| | | } |
| | | |
| | | int taskNo = taskSerialNo.getTaskNo(); |
| | | int sNo = taskSerialNo.getStartNo(); |
| | | int eNo = taskSerialNo.getTargetNo(); |
| | | taskNo = taskNo >= eNo ? sNo : taskNo + 1; |
| | | while (true) { |
| | | Task task = taskService.getOne(new LambdaQueryWrapper<Task>() |
| | | .eq(Task::getTaskNo, taskNo)); |
| | | if (null != task) { |
| | | taskNo = taskNo >= eNo ? sNo : taskNo + 1; |
| | | } else { |
| | | break; |
| | | } |
| | | } |
| | | // 修改序号记录 |
| | | if (taskNo > 0){ |
| | | taskSerialNo.setTaskNo(taskNo); |
| | | taskSerialNoService.updateById(taskSerialNo); |
| | | return taskNo; |
| | | } |
| | | throw new CoolException("工作号生成失败"); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | boolean isIdle();//是否空闲 |
| | | |
| | | boolean isRequireCharge();//是否满足充电状态 |
| | | |
| | | boolean isCharging();//是否充电中 |
| | | |
| | | boolean isChargingCompleted();//是否充电完成 |
| | | |
| | | //***************获取命令***************** |
| | | |
| | | ShuttleCommand getMoveCommand(Integer taskNo, String startCodeNum, String distCodeNum, Integer allDistance, Integer runDirection, Integer runSpeed);//获取移动命令 |
| | |
| | | import com.zy.asrs.framework.common.DateUtils; |
| | | import com.zy.asrs.framework.common.SpringUtils; |
| | | import com.zy.asrs.framework.exception.CoolException; |
| | | import com.zy.asrs.wcs.core.entity.BasShuttle; |
| | | import com.zy.asrs.wcs.core.entity.Loc; |
| | | import com.zy.asrs.wcs.core.model.NavigateNode; |
| | | import com.zy.asrs.wcs.core.model.command.ShuttleCommand; |
| | | import com.zy.asrs.wcs.core.model.enums.ShuttleCommandModeType; |
| | | import com.zy.asrs.wcs.core.model.enums.ShuttleRunDirection; |
| | | import com.zy.asrs.wcs.core.service.BasShuttleService; |
| | | import com.zy.asrs.wcs.core.service.LocService; |
| | | import com.zy.asrs.wcs.core.utils.NavigateUtils; |
| | | import com.zy.asrs.wcs.rcs.News; |
| | |
| | | //----------读取四向穿梭车状态----------- |
| | | //小车设备状态 |
| | | Integer deviceStatus = data.getInteger("deviceStatus"); |
| | | if (deviceStatus == 255) { |
| | | //离线 |
| | | shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.OFFLINE); |
| | | } |
| | | shuttleProtocol.setDeviceStatus(deviceStatus); |
| | | //当前二维码 |
| | | shuttleProtocol.setCurrentCode(data.getString("groundCode") == null ? "0" : data.getString("groundCode")); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public boolean isRequireCharge() { |
| | | if (this.shuttleProtocol.getIdle() == null |
| | | || this.shuttleProtocol.getPakMk() == null |
| | | || this.shuttleProtocol.getErrorCode() == null |
| | | || this.shuttleProtocol.getProtocolStatus() == null |
| | | ) { |
| | | return false; |
| | | } |
| | | |
| | | boolean res = this.shuttleProtocol.getIdle() |
| | | && this.shuttleProtocol.getPakMk() |
| | | && this.shuttleProtocol.getErrorCode().equals("0") |
| | | && this.shuttleProtocol.getProtocolStatus() == ShuttleProtocolStatusType.IDLE.id |
| | | ; |
| | | if (!res) { |
| | | return res; |
| | | } else { |
| | | // 电量小于阈值需要进行充电 |
| | | try { |
| | | BasShuttleService shuttleService = SpringUtils.getBean(BasShuttleService.class); |
| | | if (shuttleService == null) { |
| | | return false; |
| | | } |
| | | BasShuttle basShuttle = shuttleService.getById(this.device.getDeviceNo()); |
| | | if (basShuttle == null) { |
| | | return false; |
| | | } |
| | | Integer chargeLine = basShuttle.getChargeLine(); |
| | | if (chargeLine == null) { |
| | | return false; |
| | | } |
| | | return Integer.valueOf(this.shuttleProtocol.getBatteryPower()) < chargeLine; |
| | | } catch (Exception e) { |
| | | News.error("fail", e); |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public boolean isCharging() { |
| | | if (this.shuttleProtocol.getDeviceStatus() == null) { |
| | | return false; |
| | | } |
| | | |
| | | if (this.shuttleProtocol.getDeviceStatus() == 5 || this.shuttleProtocol.getDeviceStatus() == 13) { |
| | | //充电中和电池均衡 =》 充电 |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public boolean isChargingCompleted() { |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public ShuttleCommand getMoveCommand(Integer taskNo, String startCodeNum, String distCodeNum, Integer allDistance, Integer runDirection, Integer runSpeed) { |
| | | HashMap<String, Object> body = new HashMap<>(); |
| | | body.put("messageName", "runOrder"); |
| | |
| | | order by priority desc,start_time,task_no asc |
| | | </select> |
| | | |
| | | <select id="hasChargeInLoc" resultType="com.zy.asrs.wcs.core.entity.Task"> |
| | | select * from wcs_task |
| | | where task_sts in (201,202,203,204) |
| | | and dest_loc = #{locNo} |
| | | order by priority desc,start_time,task_no asc |
| | | </select> |
| | | |
| | | <select id="selectMoveWorking" resultType="com.zy.asrs.wcs.core.entity.Task"> |
| | | select * from wcs_task |
| | | where task_sts in (301,302,303) |
| | | and shuttle_no = #{shuttleNo} |
| | | order by priority desc,start_time,task_no asc |
| | | </select> |
| | | |
| | | <select id="selectChargeWorking" resultType="com.zy.asrs.wcs.core.entity.Task"> |
| | | select * from wcs_task |
| | | where task_sts in (201,202,203,204) |
| | | and shuttle_no = #{shuttleNo} |
| | | order by priority desc,start_time,task_no asc |
| | | </select> |
| | | |
| | | </mapper> |
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.TaskSerialNoMapper"> |
| | | |
| | | </mapper> |